diff --git a/.gitignore b/.gitignore index 6304b080164d59..915a798c76d390 100644 --- a/.gitignore +++ b/.gitignore @@ -3,10 +3,14 @@ venv/ .tags .ipynb_checkpoints .idea +.overlay_init +.overlay_consistent .sconsign.dblite .vscode model2.png a.out + +*.dylib *.DSYM *.d *.pyc @@ -14,7 +18,11 @@ a.out .*.swp .*.swo .*.un~ +*.tmp *.o +*.o-* +*.os +*.os-* *.so *.a *.clb @@ -23,26 +31,40 @@ a.out *.vcd config.json clcache -launch_chffrplus.sh -.vscode/*.json -selfdrive/visiond/visiond -.vscode/ + +persist board/obj/ selfdrive/boardd/boardd selfdrive/logcatd/logcatd selfdrive/mapd/default_speeds_by_region.json selfdrive/proclogd/proclogd -selfdrive/ui/ui -selfdrive/test/tests/plant/out -openpilot_tools/ +selfdrive/ui/_ui +selfdrive/test/longitudinal_maneuvers/out selfdrive/visiond/visiond selfdrive/loggerd/loggerd -selfdrive/sensord/gpsd -selfdrive/sensord/sensord +selfdrive/sensord/_gpsd +selfdrive/sensord/_sensord +selfdrive/camerad/camerad +selfdrive/modeld/_modeld +selfdrive/modeld/_dmonitoringmodeld /src/ + one -.vscode/*.json -./launch_chffrplus.sh openpilot +notebooks xx +hyperthneed +panda_jungle +apks +openpilot-apks + +.coverage* +coverage.xml +htmlcov +pandaextra + +.mypy_cache/ +flycheck_* +cppcheck_report.txt +comma.sh diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index 64a55daf8fabb3..00000000000000 --- a/.pylintrc +++ /dev/null @@ -1,585 +0,0 @@ -[MASTER] - -# A comma-separated list of package or module names from where C extensions may -# be loaded. Extensions are loading into the active Python interpreter and may -# run arbitrary code -extension-pkg-whitelist=scipy - -# Add files or directories to the blacklist. They should be base names, not -# paths. -ignore=CVS - -# Add files or directories matching the regex patterns to the blacklist. The -# regex matches against base names, not paths. -ignore-patterns= - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -#init-hook= - -# Use multiple processes to speed up Pylint. -jobs=4 - -# List of plugins (as comma separated values of python modules names) to load, -# usually to register additional checkers. -load-plugins= - -# Pickle collected data for later comparisons. -persistent=yes - -# Specify a configuration file. -#rcfile= - -# When enabled, pylint would attempt to guess common misconfiguration and emit -# user-friendly hints instead of false-positive error messages -suggestion-mode=yes - -# Allow loading of arbitrary C extensions. Extensions are imported into the -# active Python interpreter and may run arbitrary code. -unsafe-load-any-extension=no - - -[MESSAGES CONTROL] - -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED -confidence= - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once).You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use"--disable=all --enable=classes -# --disable=W" -disable=print-statement, - parameter-unpacking, - unpacking-in-except, - old-raise-syntax, - backtick, - long-suffix, - old-ne-operator, - old-octal-literal, - import-star-module-level, - non-ascii-bytes-literal, - raw-checker-failed, - bad-inline-option, - locally-disabled, - locally-enabled, - file-ignored, - suppressed-message, - useless-suppression, - deprecated-pragma, - apply-builtin, - basestring-builtin, - buffer-builtin, - cmp-builtin, - coerce-builtin, - execfile-builtin, - file-builtin, - long-builtin, - raw_input-builtin, - reduce-builtin, - standarderror-builtin, - unicode-builtin, - xrange-builtin, - coerce-method, - delslice-method, - getslice-method, - setslice-method, - no-absolute-import, - old-division, - dict-iter-method, - dict-view-method, - next-method-called, - metaclass-assignment, - indexing-exception, - raising-string, - reload-builtin, - oct-method, - hex-method, - nonzero-method, - cmp-method, - input-builtin, - round-builtin, - intern-builtin, - unichr-builtin, - map-builtin-not-iterating, - zip-builtin-not-iterating, - range-builtin-not-iterating, - filter-builtin-not-iterating, - using-cmp-argument, - eq-without-hash, - div-method, - idiv-method, - rdiv-method, - exception-message-attribute, - invalid-str-codec, - sys-max-int, - bad-python3-import, - deprecated-string-function, - deprecated-str-translate-call, - deprecated-itertools-function, - deprecated-types-field, - next-method-defined, - dict-items-not-iterating, - dict-keys-not-iterating, - dict-values-not-iterating, - bad-indentation, - line-too-long, - missing-docstring, - multiple-statements, - bad-continuation, - invalid-name, - too-many-arguments, - too-many-locals, - superfluous-parens, - bad-whitespace, - too-many-instance-attributes, - wrong-import-position, - ungrouped-imports, - wrong-import-order, - protected-access, - trailing-whitespace, - too-many-branches, - too-few-public-methods, - too-many-statements, - trailing-newlines, - attribute-defined-outside-init, - too-many-return-statements, - too-many-public-methods, - unused-argument, - old-style-class, - no-init, - len-as-condition, - unneeded-not, - no-self-use, - multiple-imports, - no-else-return, - logging-not-lazy, - fixme, - redefined-outer-name, - unused-variable, - unsubscriptable-object, - expression-not-assigned, - too-many-boolean-expressions, - consider-using-ternary, - invalid-unary-operand-type, - relative-import, - deprecated-lambda - - -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time (only on the command line, not in the configuration file where -# it should appear only once). See also the "--disable" option for examples. -enable=c-extension-no-member - - -[REPORTS] - -# Python expression which should return a note less than 10 (10 is the highest -# note). You have access to the variables errors warning, statement which -# respectively contain the number of errors / warnings messages and the total -# number of statements analyzed. This is used by the global evaluation report -# (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details -#msg-template= - -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio).You can also give a reporter class, eg -# mypackage.mymodule.MyReporterClass. -output-format=text - -# Tells whether to display a full report or only the messages -reports=no - -# Activate the evaluation score. -score=yes - - -[REFACTORING] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 - -# Complete name of functions that never returns. When checking for -# inconsistent-return-statements if a never returning function is called then -# it will be considered as an explicit return statement and no message will be -# printed. -never-returning-functions=optparse.Values,sys.exit - - -[LOGGING] - -# Logging modules to check that the string format arguments are in logging -# function parameter format -logging-modules=logging - - -[SPELLING] - -# Limits count of emitted suggestions for spelling mistakes -max-spelling-suggestions=4 - -# Spelling dictionary name. Available dictionaries: none. To make it working -# install python-enchant package. -spelling-dict= - -# List of comma separated words that should not be checked. -spelling-ignore-words= - -# A path to a file that contains private dictionary; one word per line. -spelling-private-dict-file= - -# Tells whether to store unknown words to indicated private dictionary in -# --spelling-private-dict-file option instead of raising a message. -spelling-store-unknown-words=no - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME, - XXX, - TODO - - -[SIMILARITIES] - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=no - -# Minimum lines number of a similarity. -min-similarity-lines=4 - - -[TYPECHECK] - -# List of decorators that produce context managers, such as -# contextlib.contextmanager. Add to this list to register other decorators that -# produce valid context managers. -contextmanager-decorators=contextlib.contextmanager - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E1101 when accessed. Python regular -# expressions are accepted. -generated-members=capnp.* cereal.* pygame.* zmq.* setproctitle.* smbus2.* usb1.* serial.* cv2.* - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# This flag controls whether pylint should warn about no-member and similar -# checks whenever an opaque object is returned when inferring. The inference -# can return multiple potential results while evaluating a Python object, but -# some branches might not be evaluated, which results in partial inference. In -# that case, it might be useful to still emit no-member and other checks for -# the rest of the inferred objects. -ignore-on-opaque-inference=yes - -# List of class names for which member attributes should not be checked (useful -# for classes with dynamically set attributes). This supports the use of -# qualified names. -ignored-classes=optparse.Values,thread._local,_thread._local - -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis. It -# supports qualified module names, as well as Unix pattern matching. -ignored-modules=flask setproctitle usb1 flask.ext.socketio smbus2 usb1.* - -# Show a hint with possible names when a member name was not found. The aspect -# of finding the hint is based on edit distance. -missing-member-hint=yes - -# The minimum edit distance a name should have in order to be considered a -# similar match for a missing member name. -missing-member-hint-distance=1 - -# The total number of similar names that should be taken in consideration when -# showing a hint for a missing member. -missing-member-max-choices=1 - - -[VARIABLES] - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid to define new builtins when possible. -additional-builtins= - -# Tells whether unused global variables should be treated as a violation. -allow-global-unused-variables=yes - -# List of strings which can identify a callback function by name. A callback -# name must start or end with one of those strings. -callbacks=cb_, - _cb - -# A regular expression matching the name of dummy variables (i.e. expectedly -# not used). -dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore -ignored-argument-names=_.*|^ignored_|^unused_ - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -# List of qualified module names which can have objects that can redefine -# builtins. -redefining-builtins-modules=six.moves,past.builtins,future.builtins - - -[FORMAT] - -# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -expected-line-ending-format= - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^\s*(# )??$ - -# Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 - -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' - -# Maximum number of characters on a single line. -max-line-length=100 - -# Maximum number of lines in a module -max-module-lines=1000 - -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma, - dict-separator - -# Allow the body of a class to be on the same line as the declaration if body -# contains single statement. -single-line-class-stmt=no - -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no - - -[BASIC] - -# Naming style matching correct argument names -argument-naming-style=snake_case - -# Regular expression matching correct argument names. Overrides argument- -# naming-style -#argument-rgx= - -# Naming style matching correct attribute names -attr-naming-style=snake_case - -# Regular expression matching correct attribute names. Overrides attr-naming- -# style -#attr-rgx= - -# Bad variable names which should always be refused, separated by a comma -bad-names=foo, - bar, - baz, - toto, - tutu, - tata - -# Naming style matching correct class attribute names -class-attribute-naming-style=any - -# Regular expression matching correct class attribute names. Overrides class- -# attribute-naming-style -#class-attribute-rgx= - -# Naming style matching correct class names -class-naming-style=PascalCase - -# Regular expression matching correct class names. Overrides class-naming-style -#class-rgx= - -# Naming style matching correct constant names -const-naming-style=UPPER_CASE - -# Regular expression matching correct constant names. Overrides const-naming- -# style -#const-rgx= - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-1 - -# Naming style matching correct function names -function-naming-style=snake_case - -# Regular expression matching correct function names. Overrides function- -# naming-style -#function-rgx= - -# Good variable names which should always be accepted, separated by a comma -good-names=i, - j, - k, - ex, - Run, - _ - -# Include a hint for the correct naming format with invalid-name -include-naming-hint=no - -# Naming style matching correct inline iteration names -inlinevar-naming-style=any - -# Regular expression matching correct inline iteration names. Overrides -# inlinevar-naming-style -#inlinevar-rgx= - -# Naming style matching correct method names -method-naming-style=snake_case - -# Regular expression matching correct method names. Overrides method-naming- -# style -#method-rgx= - -# Naming style matching correct module names -module-naming-style=snake_case - -# Regular expression matching correct module names. Overrides module-naming- -# style -#module-rgx= - -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= - -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=^_ - -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -property-classes=abc.abstractproperty - -# Naming style matching correct variable names -variable-naming-style=snake_case - -# Regular expression matching correct variable names. Overrides variable- -# naming-style -#variable-rgx= - - -[DESIGN] - -# Maximum number of arguments for function / method -max-args=5 - -# Maximum number of attributes for a class (see R0902). -max-attributes=7 - -# Maximum number of boolean expressions in a if statement -max-bool-expr=5 - -# Maximum number of branch for function / method body -max-branches=12 - -# Maximum number of locals for function / method body -max-locals=15 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - -# Maximum number of return / yield for function / method body -max-returns=6 - -# Maximum number of statements in function / method body -max-statements=50 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=2 - - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__, - __new__, - setUp - -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict, - _fields, - _replace, - _source, - _make - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=mcs - - -[IMPORTS] - -# Allow wildcard imports from modules that define __all__. -allow-wildcard-with-all=no - -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - -# Deprecated modules which should not be used, separated by a comma -deprecated-modules=regsub, - TERMIOS, - Bastion, - rexec - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled) -ext-import-graph= - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled) -import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled) -int-import-graph= - -# Force import order to recognize a module as part of the standard -# compatibility libraries. -known-standard-library= - -# Force import order to recognize a module as part of a third party library. -known-third-party=enchant - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "Exception" -overgeneral-exceptions=Exception diff --git a/.python-version b/.python-version index 35b46aeacab588..cc1923a40b1a5e 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -2.7.16 +3.8 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8683d8bee015be..00000000000000 --- a/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -sudo: required - -services: - - docker - -script: - - ./run_docker_tests.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 738679aca5d5e6..45de84bd56563f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ Our software is open source so you can solve your own problems without needing help from others. And if you solve a problem and are so kind, you can upstream it for the rest of the world to use. -Most open source development activity is coordinated through our [Discord](https://discord.comma.ai). A lot of documentation is available on our [medium](https://medium.com/@comma_ai/) +Most open source development activity is coordinated through our [GitHub Discussions](https://github.com/commaai/openpilot/discussions) and [Discord](https://discord.comma.ai). A lot of documentation is available on our [medium](https://medium.com/@comma_ai/). ## Getting Started @@ -12,20 +12,34 @@ Most open source development activity is coordinated through our [Discord](https ## 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. +All PRs and commits are automatically checked by GitHub Actions. Check out `.github/workflows/` for what GitHub Actions runs. Any new tests should be added to GitHub Actions. ### 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`. +Code is automatically checked for style by GitHub Actions as part of the automated tests. You can also run these tests yourself by running `pre-commit run --all`. ## 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) +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). + +## Pull Requests + +Pull requests should be against the master branch. Before running master on in-car hardware, you'll need to clone the submodules too. That can be done by recursively cloning the repository: +``` +git clone https://github.com/commaai/openpilot.git --recursive +``` +Or alternatively, when on the master branch: +``` +git submodule update --init +``` +The reasons for having submodules on a dedicated repository and our new development philosophy can be found in our [post about externalization](https://medium.com/@comma_ai/a-2020-theme-externalization-13b33326d8b3). +Modules that are in seperate repositories include: +* cereal +* laika +* opendbc +* panda +* rednose diff --git a/Dockerfile.openpilot b/Dockerfile.openpilot deleted file mode 100644 index 6be64c13118aaa..00000000000000 --- a/Dockerfile.openpilot +++ /dev/null @@ -1,57 +0,0 @@ -FROM ubuntu:16.04 -ENV PYTHONUNBUFFERED 1 - -RUN apt-get update && apt-get install -y \ - autoconf \ - build-essential \ - bzip2 \ - clang \ - git \ - libarchive-dev \ - libavcodec-dev \ - libavdevice-dev \ - libavfilter-dev \ - libavresample-dev \ - libavutil-dev \ - libffi-dev \ - libglib2.0-0 \ - libssl-dev \ - libswscale-dev \ - libtool \ - libusb-1.0-0 \ - libzmq5-dev \ - ocl-icd-libopencl1 \ - ocl-icd-opencl-dev \ - opencl-headers \ - pkg-config \ - python-pip \ - wget - -COPY phonelibs/install_capnp.sh /tmp/install_capnp.sh -RUN /tmp/install_capnp.sh - -RUN pip install --upgrade pip==18.0 -RUN pip install pipenv==2018.11.26 - -COPY Pipfile /tmp/ -COPY Pipfile.lock /tmp/ -RUN cd /tmp && pipenv install --deploy --system - -ENV PYTHONPATH /tmp/openpilot:$PYTHONPATH - -RUN git clone --branch v0.6.2 https://github.com/commaai/openpilot-tools.git /tmp/openpilot/tools -RUN pip install -r /tmp/openpilot/tools/requirements.txt -RUN pip install fastcluster==1.1.20 scipy==0.19.1 dictdiffer==0.8.0 azure-batch==4.1.3 azure-common==1.1.16 azure-nspkg==3.0.0 azure-storage-blob==1.3.1 azure-storage-common==1.3.0 azure-storage-nspkg==3.0.0 - -COPY ./.pylintrc /tmp/openpilot/.pylintrc -COPY ./common /tmp/openpilot/common -COPY ./cereal /tmp/openpilot/cereal -COPY ./opendbc /tmp/openpilot/opendbc -COPY ./selfdrive /tmp/openpilot/selfdrive -COPY ./phonelibs /tmp/openpilot/phonelibs -COPY ./pyextra /tmp/openpilot/pyextra -COPY ./panda /tmp/openpilot/panda - -RUN mkdir -p /tmp/openpilot/selfdrive/test/out -RUN make -C /tmp/openpilot/selfdrive/controls/lib/longitudinal_mpc clean -RUN make -C /tmp/openpilot/selfdrive/controls/lib/lateral_mpc clean diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000000000..a9479a111b920f --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,160 @@ +def phone(String ip, String step_label, String cmd) { + def ci_env = "CI=1 TEST_DIR=${env.TEST_DIR} GIT_BRANCH=${env.GIT_BRANCH} GIT_COMMIT=${env.GIT_COMMIT}" + + withCredentials([file(credentialsId: 'id_rsa_public', variable: 'key_file')]) { + sh label: step_label, + script: """ + ssh -tt -o StrictHostKeyChecking=no -i ${key_file} -p 8022 root@${ip} '${ci_env} /usr/bin/bash -le' <<'EOF' +echo \$\$ > /dev/cpuset/app/tasks || true +echo \$PPID > /dev/cpuset/app/tasks || true +mkdir -p /dev/shm +chmod 777 /dev/shm +cd ${env.TEST_DIR} || true +${cmd} +exit 0 +EOF""" + } +} + +def phone_steps(String device_type, steps) { + lock(resource: "", label: device_type, inversePrecedence: true, variable: 'device_ip', quantity: 1) { + timeout(time: 60, unit: 'MINUTES') { + phone(device_ip, "kill old processes", "pkill -f comma || true") + phone(device_ip, "git checkout", readFile("selfdrive/test/setup_device_ci.sh"),) + steps.each { item -> + phone(device_ip, item[0], item[1]) + } + } + } +} + +pipeline { + agent none + environment { + COMMA_JWT = credentials('athena-test-jwt') + TEST_DIR = "/data/openpilot" + } + options { + timeout(time: 1, unit: 'HOURS') + } + + stages { + + stage('Release Build') { + agent { + docker { + image 'python:3.7.3' + args '--user=root' + } + } + when { + branch 'devel-staging' + } + steps { + phone_steps("eon-build", [ + ["build release2-staging and dashcam-staging", "cd release && PUSH=1 ./build_release2.sh"], + ]) + } + } + + stage('openpilot tests') { + when { + not { + anyOf { + branch 'master-ci'; branch 'devel'; branch 'devel-staging'; branch 'release2'; branch 'release2-staging'; branch 'dashcam'; branch 'dashcam-staging'; branch 'testing-closet*' + } + } + } + + + stages { + + /* + stage('PC tests') { + agent { + dockerfile { + filename 'Dockerfile.openpilotci' + args '--privileged --shm-size=1G --user=root' + } + } + stages { + stage('Build') { + steps { + sh 'scons -j$(nproc)' + } + } + } + post { + always { + // fix permissions since docker runs as another user + sh "chmod -R 777 ." + } + } + } + */ + + stage('On-device Tests') { + agent { + docker { + image 'python:3.7.3' + args '--user=root' + } + } + + stages { + stage('parallel tests') { + parallel { + + stage('Devel Build') { + environment { + CI_PUSH = "${env.BRANCH_NAME == 'master' ? 'master-ci' : ' '}" + } + steps { + phone_steps("eon", [ + ["build devel", "cd release && CI_PUSH=${env.CI_PUSH} ./build_devel.sh"], + ["test openpilot", "nosetests -s selfdrive/test/test_openpilot.py"], + ["test cpu usage", "cd selfdrive/test/ && ./test_cpu_usage.py"], + ["test car interfaces", "cd selfdrive/car/tests/ && ./test_car_interfaces.py"], + ["test spinner build", "cd selfdrive/ui/spinner && make clean && make"], + ["test text window build", "cd selfdrive/ui/text && make clean && make"], + ]) + } + } + + stage('Replay Tests') { + steps { + phone_steps("eon2", [ + ["camerad/modeld replay", "QCOM_REPLAY=1 scons -j4 && cd selfdrive/test/process_replay && ./camera_replay.py"], + ]) + } + } + + stage('HW + Unit Tests') { + steps { + phone_steps("eon", [ + ["build", "SCONS_CACHE=1 scons -j4"], + ["test sounds", "nosetests -s selfdrive/test/test_sounds.py"], + ["test boardd loopback", "nosetests -s selfdrive/boardd/tests/test_boardd_loopback.py"], + ["test loggerd", "CI=1 python selfdrive/loggerd/tests/test_loggerd.py"], + //["test camerad", "CI=1 python selfdrive/camerad/test/test_camerad.py"], // wait for shelf refactor + //["test updater", "python installer/updater/test_updater.py"], + ]) + } + } + + } + } + } + + post { + always { + cleanWs() + } + } + + } + + } + } + } +} diff --git a/Makefile b/Makefile deleted file mode 100644 index 4f690b2e7e88c1..00000000000000 --- a/Makefile +++ /dev/null @@ -1,9 +0,0 @@ - -code_dir := $(shell pwd) - -# TODO: Add a global build system - -.PHONY: all -all: - cd selfdrive && PYTHONPATH=$(code_dir) PREPAREONLY=1 ./manager.py - diff --git a/Pipfile b/Pipfile deleted file mode 100644 index 7afffb1e940942..00000000000000 --- a/Pipfile +++ /dev/null @@ -1,145 +0,0 @@ -[[source]] -name = "pypi" -url = "https://pypi.org/simple" -verify_ssl = true - -[dev-packages] -ipython = "<6.0" -aenum = "*" -azure-batch = "==4.1.3" -azure-common = "==1.1.16" -azure-nspkg = "==3.0.1" -azure-storage-blob = "==1.3.1" -azure-storage-common = "==1.3.0" -azure-storage-nspkg = "==3.0.0" -bincopy = "*" -bleach = "==1.5.0" -boto = "*" -"boto3" = "*" -celery = "*" -control = "*" -datadog = "*" -decorator = "*" -dlib = "*" -dominate = "*" -elasticsearch = "*" -entium = "==0.1.4" -fasteners = "*" -future = "*" -futures = "*" -gevent = "*" -pycocotools = {git = "https://github.com/cocodataset/cocoapi.git",subdirectory = "PythonAPI"} -gunicorn = "*" -"h5py" = "*" -hexdump = "*" -"html5lib" = "==0.9999999" -imageio = "*" -intervaltree = "*" -ipykernel = "<5.0" -joblib = "*" -json-logging-py = "*" -jupyter = "*" -libarchive = "*" -lru-dict = "*" -lxml = "*" -matplotlib = "==2.2.3" -"mpld3" = "*" -msgpack-python = "*" -nbstripout = "*" -nose-parameterized = "*" -numpy = "==1.14.5" -osmium = "==2.15.0" -pbr = "==5.1.3" -percache = "*" -pprofile = "*" -psutil = "*" -pycurl = "*" -git-pylint-commit-hook = "==2.5.1" -pymongo = "*" -"pynmea2" = "*" -pypolyline = "==0.1.17" -pysendfile = "*" -python-logstash = "*" -pyvcd = "*" -redis = "*" -redlock = "*" -"s2sphere" = "*" -scikit-image = "*" -"subprocess32" = "*" -supervisor = "*" -tenacity = "*" -tensorflow-gpu = "==1.13.0rc0" -"transforms3d" = "*" -utm = "*" -"v4l2" = "*" -visdom = "*" -PyJWT = "==1.4.1" -PyMySQL = "==0.9.2" -Theano = "*" -Werkzeug = "*" -"backports.lzma" = "*" -Flask-Cors = "*" -Flask-SocketIO = "*" -"GeoAlchemy2" = "*" -Keras = ">=2.1.6" -keras-maskrcnn = "*" -keras-retinanet = "*" -Pygments = "*" -PyNaCl = "*" -"PySDL2" = "*" -reverse_geocoder = "*" -Shapely = "*" -SQLAlchemy = "==1.2.7" -uWSGI = "*" -scipy = "*" -fastcluster = "==1.1.25" -backports-abc = "*" -pygame = "*" -simplejson = "*" -python-logstash-async = "*" -pandas = "*" -seaborn = "*" -tensorflow-estimator = "==1.10.12" -pyproj = "*" - -[packages] -overpy = {git = "https://github.com/commaai/python-overpy.git",ref = "f86529af402d4642e1faeb146671c40284007323"} -atomicwrites = "*" -cffi = "*" -crcmod = "*" -hexdump = "*" -libusb1 = "*" -numpy = "*" -psutil = "*" -pycapnp = "*" -cryptography = "*" -pyserial = "*" -python-dateutil = "*" -pyzmq = "*" -raven = "*" -requests = "*" -setproctitle = "*" -six = "*" -smbus2 = "*" -sympy = "*" -tqdm = "*" -Cython = "*" -PyYAML = "*" -websocket_client = "*" -Logentries = {git = "https://github.com/commaai/le_python.git",ref = "5eef8f5be5929d33973e1b10e686fa0cdcd6792f"} -urllib3 = "*" -chardet = "*" -idna = "*" -gunicorn = "*" -utm = "*" -json-rpc = "*" -Flask = "*" -PyJWT = "*" -"Jinja2" = "*" -nose = "*" -pyflakes = "*" -pylint = "*" -pycryptodome = "*" - -[requires] -python_version = "2.7" diff --git a/Pipfile.lock b/Pipfile.lock deleted file mode 100644 index 15416a7bf6acce..00000000000000 --- a/Pipfile.lock +++ /dev/null @@ -1,2887 +0,0 @@ -{ - "_meta": { - "hash": { - "sha256": "43f96719ff9a1b7eae6c7a88f903c4f5a137c2b195e3ba148f32767827b98710" - }, - "pipfile-spec": 6, - "requires": { - "python_version": "2.7" - }, - "sources": [ - { - "name": "pypi", - "url": "https://pypi.org/simple", - "verify_ssl": true - } - ] - }, - "default": { - "asn1crypto": { - "hashes": [ - "sha256:2f1adbb7546ed199e3c90ef23ec95c5cf3585bac7d11fb7eb562a3fe89c64e87", - "sha256:9d5c20441baf0cb60a4ac34cc447c6c189024b6b4c6cd7877034f4965c464e49" - ], - "version": "==0.24.0" - }, - "astroid": { - "hashes": [ - "sha256:87de48a92e29cedf7210ffa853d11441e7ad94cb47bacd91b023499b51cbc756", - "sha256:d25869fc7f44f1d9fb7d24fd7ea0639656f5355fc3089cd1f3d18c6ec6b124c7" - ], - "version": "==1.6.6" - }, - "atomicwrites": { - "hashes": [ - "sha256:03472c30eb2c5d1ba9227e4c2ca66ab8287fbfbbda3888aa93dc2e28fc6811b4", - "sha256:75a9445bac02d8d058d5e1fe689654ba5a6556a1dfd8ce6ec55a0ed79866cfa6" - ], - "index": "pypi", - "version": "==1.3.0" - }, - "backports.functools-lru-cache": { - "hashes": [ - "sha256:9d98697f088eb1b0fa451391f91afb5e3ebde16bbdb272819fd091151fda4f1a", - "sha256:f0b0e4eba956de51238e17573b7087e852dfe9854afd2e9c873f73fc0ca0a6dd" - ], - "markers": "python_version == '2.7'", - "version": "==1.5" - }, - "certifi": { - "hashes": [ - "sha256:046832c04d4e752f37383b628bc601a7ea7211496b4638f6514d0e5b9acc4939", - "sha256:945e3ba63a0b9f577b1395204e13c3a231f9bc0223888be653286534e5873695" - ], - "version": "==2019.6.16" - }, - "cffi": { - "hashes": [ - "sha256:041c81822e9f84b1d9c401182e174996f0bae9991f33725d059b771744290774", - "sha256:046ef9a22f5d3eed06334d01b1e836977eeef500d9b78e9ef693f9380ad0b83d", - "sha256:066bc4c7895c91812eff46f4b1c285220947d4aa46fa0a2651ff85f2afae9c90", - "sha256:066c7ff148ae33040c01058662d6752fd73fbc8e64787229ea8498c7d7f4041b", - "sha256:2444d0c61f03dcd26dbf7600cf64354376ee579acad77aef459e34efcb438c63", - "sha256:300832850b8f7967e278870c5d51e3819b9aad8f0a2c8dbe39ab11f119237f45", - "sha256:34c77afe85b6b9e967bd8154e3855e847b70ca42043db6ad17f26899a3df1b25", - "sha256:46de5fa00f7ac09f020729148ff632819649b3e05a007d286242c4882f7b1dc3", - "sha256:4aa8ee7ba27c472d429b980c51e714a24f47ca296d53f4d7868075b175866f4b", - "sha256:4d0004eb4351e35ed950c14c11e734182591465a33e960a4ab5e8d4f04d72647", - "sha256:4e3d3f31a1e202b0f5a35ba3bc4eb41e2fc2b11c1eff38b362de710bcffb5016", - "sha256:50bec6d35e6b1aaeb17f7c4e2b9374ebf95a8975d57863546fa83e8d31bdb8c4", - "sha256:55cad9a6df1e2a1d62063f79d0881a414a906a6962bc160ac968cc03ed3efcfb", - "sha256:5662ad4e4e84f1eaa8efce5da695c5d2e229c563f9d5ce5b0113f71321bcf753", - "sha256:59b4dc008f98fc6ee2bb4fd7fc786a8d70000d058c2bbe2698275bc53a8d3fa7", - "sha256:73e1ffefe05e4ccd7bcea61af76f36077b914f92b76f95ccf00b0c1b9186f3f9", - "sha256:a1f0fd46eba2d71ce1589f7e50a9e2ffaeb739fb2c11e8192aa2b45d5f6cc41f", - "sha256:a2e85dc204556657661051ff4bab75a84e968669765c8a2cd425918699c3d0e8", - "sha256:a5457d47dfff24882a21492e5815f891c0ca35fefae8aa742c6c263dac16ef1f", - "sha256:a8dccd61d52a8dae4a825cdbb7735da530179fea472903eb871a5513b5abbfdc", - "sha256:ae61af521ed676cf16ae94f30fe202781a38d7178b6b4ab622e4eec8cefaff42", - "sha256:b012a5edb48288f77a63dba0840c92d0504aa215612da4541b7b42d849bc83a3", - "sha256:d2c5cfa536227f57f97c92ac30c8109688ace8fa4ac086d19d0af47d134e2909", - "sha256:d42b5796e20aacc9d15e66befb7a345454eef794fdb0737d1af593447c6c8f45", - "sha256:dee54f5d30d775f525894d67b1495625dd9322945e7fee00731952e0368ff42d", - "sha256:e070535507bd6aa07124258171be2ee8dfc19119c28ca94c9dfb7efd23564512", - "sha256:e1ff2748c84d97b065cc95429814cdba39bcbd77c9c85c89344b317dc0d9cbff", - "sha256:ed851c75d1e0e043cbf5ca9a8e1b13c4c90f3fbd863dacb01c0808e2b5204201" - ], - "index": "pypi", - "version": "==1.12.3" - }, - "chardet": { - "hashes": [ - "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", - "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" - ], - "index": "pypi", - "version": "==3.0.4" - }, - "click": { - "hashes": [ - "sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13", - "sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7" - ], - "version": "==7.0" - }, - "configparser": { - "hashes": [ - "sha256:8be81d89d6e7b4c0d4e44bcc525845f6da25821de80cb5e06e7e0238a2899e32", - "sha256:da60d0014fd8c55eb48c1c5354352e363e2d30bbf7057e5e171a468390184c75" - ], - "markers": "python_version == '2.7'", - "version": "==3.7.4" - }, - "contextlib2": { - "hashes": [ - "sha256:509f9419ee91cdd00ba34443217d5ca51f5a364a404e1dce9e8979cea969ca48", - "sha256:f5260a6e679d2ff42ec91ec5252f4eeffdcf21053db9113bd0a8e4d953769c00" - ], - "markers": "python_version < '3.2'", - "version": "==0.5.5" - }, - "crcmod": { - "hashes": [ - "sha256:dc7051a0db5f2bd48665a990d3ec1cc305a466a77358ca4492826f41f283601e" - ], - "index": "pypi", - "version": "==1.7" - }, - "cryptography": { - "hashes": [ - "sha256:24b61e5fcb506424d3ec4e18bca995833839bf13c59fc43e530e488f28d46b8c", - "sha256:25dd1581a183e9e7a806fe0543f485103232f940fcfc301db65e630512cce643", - "sha256:3452bba7c21c69f2df772762be0066c7ed5dc65df494a1d53a58b683a83e1216", - "sha256:41a0be220dd1ed9e998f5891948306eb8c812b512dc398e5a01846d855050799", - "sha256:5751d8a11b956fbfa314f6553d186b94aa70fdb03d8a4d4f1c82dcacf0cbe28a", - "sha256:5f61c7d749048fa6e3322258b4263463bfccefecb0dd731b6561cb617a1d9bb9", - "sha256:72e24c521fa2106f19623a3851e9f89ddfdeb9ac63871c7643790f872a305dfc", - "sha256:7b97ae6ef5cba2e3bb14256625423413d5ce8d1abb91d4f29b6d1a081da765f8", - "sha256:961e886d8a3590fd2c723cf07be14e2a91cf53c25f02435c04d39e90780e3b53", - "sha256:96d8473848e984184b6728e2c9d391482008646276c3ff084a1bd89e15ff53a1", - "sha256:ae536da50c7ad1e002c3eee101871d93abdc90d9c5f651818450a0d3af718609", - "sha256:b0db0cecf396033abb4a93c95d1602f268b3a68bb0a9cc06a7cff587bb9a7292", - "sha256:cfee9164954c186b191b91d4193989ca994703b2fff406f71cf454a2d3c7327e", - "sha256:e6347742ac8f35ded4a46ff835c60e68c22a536a8ae5c4422966d06946b6d4c6", - "sha256:f27d93f0139a3c056172ebb5d4f9056e770fdf0206c2f422ff2ebbad142e09ed", - "sha256:f57b76e46a58b63d1c6375017f4564a28f19a5ca912691fd2e4261b3414b618d" - ], - "index": "pypi", - "version": "==2.7" - }, - "cython": { - "hashes": [ - "sha256:04ebf16df9406d3279a2489c3327803c782d9e17637d525bfb44ecf5ec65850f", - "sha256:1486ec88d1c73dea3846a5640054018b002608e04a791ccbd2082a47bce4440a", - "sha256:20da832a5e9a8e93d1e1eb64650258956723940968eb585506531719b55b804f", - "sha256:2464688b523d7a133b52cf1343c1c595b92fc6554af1015f74b9e49951e992d4", - "sha256:27827b68a8359e9ab6bf683c68d8ee79863a0c94a577acf56aa02cc302e16f51", - "sha256:27deeeeca0fd8933af07923e809c8fed0763d150a4fdd4082932a33b8c874ed6", - "sha256:31f4da785d5e09deb852ea59795a629c5befb6040929e7880c6f63e6668246ce", - "sha256:4828cf8fa638c35139e643f30201b240c0d156b1b9967a7321ae42d721d7224c", - "sha256:48b365e32cc5639ae2c239d7bd4f8a1d920a13a7ae92113c4c938903c9400147", - "sha256:4eb71856c1d1b33083df9318fd30143470ad6f0d1b9ad2ee61a120710842d28b", - "sha256:5b06ef8422d27d8128f8f80bdefa111eadcab246fba1d668720af4f0b97b7a0e", - "sha256:71c553640e1ddaaf143e38dbc6cd1863fa3c0738fb1830a9aaffba9a51838f30", - "sha256:73e2742ee1f923c5f213183bf493901f9630e395634fce5b739a53b7dc5d64be", - "sha256:82a632bc02063eff0b8e7ff3089aa3d912d1c7499709f51c8f04f57c8832cfe6", - "sha256:977ca1ac059e4d4a4bf5fe2224986baf42b69290453eda44822606f4deae6515", - "sha256:a7e6217d0dd864a7cc4f457172766864496efd64d24d4980df1521f75f992761", - "sha256:ad0ed7dd5dff76eb3aae8c18d95b1c9f885a91a92132728051a704fb8060d08c", - "sha256:b1b8eda9e931f0ca1aadb95a890811bdf530407e48c962643b85675329d99abf", - "sha256:cec99c79205131da3ee75becea1f3f55c57bf6a1c500431de9ae7a32ac8a5cc4", - "sha256:d4bbdaa6f61ce2ef26535a7d473d6ffa6e413013c5c580af999546bf1627ae11", - "sha256:d8bdb4208975b12048bdace46e9dd8e3dda3872432f95b53789700a1330e6060", - "sha256:dce0362ff9b61f8411d1efc9e16fc528dadbd3707a557561992457f5cb446297", - "sha256:defbbbf5653629ce5cc54091ce49c6830da8d3104de53ed2169c9efcb0720f27", - "sha256:e0c53a7e2b6d82ec3c26c009c937fc88eb8c7edf000c54334261beaf56bb08f2", - "sha256:e1065bacfe5303f107896e63263537dee90920d26050f2e23c4af12c37da2db6", - "sha256:e142837c4212c0b2c71e6773cb6740828922806b4c00ee4215be3ceb558671e6", - "sha256:f4cbbab28c93ffee6ec929cf0826f0b11d2488e53a708d51142a5e62f8cd9806", - "sha256:fa8f63b6551621eea9efea4db37ae401104352f0ebaee32f7d20be88cbe589c3" - ], - "index": "pypi", - "version": "==0.29.12" - }, - "enum34": { - "hashes": [ - "sha256:2d81cbbe0e73112bdfe6ef8576f2238f2ba27dd0d55752a776c41d38b7da2850", - "sha256:644837f692e5f550741432dd3f223bbb9852018674981b1664e5dc339387588a", - "sha256:6bd0f6ad48ec2aa117d3d141940d484deccda84d4fcd884f5c3d93c23ecd8c79", - "sha256:8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1" - ], - "markers": "python_version < '3'", - "version": "==1.1.6" - }, - "flask": { - "hashes": [ - "sha256:13f9f196f330c7c2c5d7a5cf91af894110ca0215ac051b5844701f2bfd934d52", - "sha256:45eb5a6fd193d6cf7e0cf5d8a5b31f83d5faae0293695626f539a823e93b13f6" - ], - "index": "pypi", - "version": "==1.1.1" - }, - "futures": { - "hashes": [ - "sha256:49b3f5b064b6e3afc3316421a3f25f66c137ae88f068abbf72830170033c5e16", - "sha256:7e033af76a5e35f58e56da7a91e687706faf4e7bdfb2cbc3f2cca6b9bcda9794" - ], - "markers": "python_version < '3.2'", - "version": "==3.3.0" - }, - "gunicorn": { - "hashes": [ - "sha256:aa8e0b40b4157b36a5df5e599f45c9c76d6af43845ba3b3b0efe2c70473c2471", - "sha256:fa2662097c66f920f53f70621c6c58ca4a3c4d3434205e608e121b5b3b71f4f3" - ], - "index": "pypi", - "version": "==19.9.0" - }, - "hexdump": { - "hashes": [ - "sha256:d781a43b0c16ace3f9366aade73e8ad3a7bd5137d58f0b45ab2d3f54876f20db" - ], - "index": "pypi", - "version": "==3.3" - }, - "idna": { - "hashes": [ - "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", - "sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c" - ], - "index": "pypi", - "version": "==2.8" - }, - "ipaddress": { - "hashes": [ - "sha256:64b28eec5e78e7510698f6d4da08800a5c575caa4a286c93d651c5d3ff7b6794", - "sha256:b146c751ea45cad6188dd6cf2d9b757f6f4f8d6ffb96a023e6f2e26eea02a72c" - ], - "markers": "python_version < '3'", - "version": "==1.0.22" - }, - "isort": { - "hashes": [ - "sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1", - "sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd" - ], - "version": "==4.3.21" - }, - "itsdangerous": { - "hashes": [ - "sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19", - "sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749" - ], - "version": "==1.1.0" - }, - "jinja2": { - "hashes": [ - "sha256:065c4f02ebe7f7cf559e49ee5a95fb800a9e4528727aec6f24402a5374c65013", - "sha256:14dd6caf1527abb21f08f86c784eac40853ba93edb79552aa1e4b8aef1b61c7b" - ], - "index": "pypi", - "version": "==2.10.1" - }, - "json-rpc": { - "hashes": [ - "sha256:bc84451268b48a576d3138744322a8ce673eccadf7424edf4d446b1ddb59e58c", - "sha256:d6ed3dae670a12e4caa738d309807357d22e2f6e222bb34e8ef019e8b5b1228b" - ], - "index": "pypi", - "version": "==1.12.1" - }, - "lazy-object-proxy": { - "hashes": [ - "sha256:159a745e61422217881c4de71f9eafd9d703b93af95618635849fe469a283661", - "sha256:23f63c0821cc96a23332e45dfaa83266feff8adc72b9bcaef86c202af765244f", - "sha256:3b11be575475db2e8a6e11215f5aa95b9ec14de658628776e10d96fa0b4dac13", - "sha256:3f447aff8bc61ca8b42b73304f6a44fa0d915487de144652816f950a3f1ab821", - "sha256:4ba73f6089cd9b9478bc0a4fa807b47dbdb8fad1d8f31a0f0a5dbf26a4527a71", - "sha256:4f53eadd9932055eac465bd3ca1bd610e4d7141e1278012bd1f28646aebc1d0e", - "sha256:64483bd7154580158ea90de5b8e5e6fc29a16a9b4db24f10193f0c1ae3f9d1ea", - "sha256:6f72d42b0d04bfee2397aa1862262654b56922c20a9bb66bb76b6f0e5e4f9229", - "sha256:7c7f1ec07b227bdc561299fa2328e85000f90179a2f44ea30579d38e037cb3d4", - "sha256:7c8b1ba1e15c10b13cad4171cfa77f5bb5ec2580abc5a353907780805ebe158e", - "sha256:8559b94b823f85342e10d3d9ca4ba5478168e1ac5658a8a2f18c991ba9c52c20", - "sha256:a262c7dfb046f00e12a2bdd1bafaed2408114a89ac414b0af8755c696eb3fc16", - "sha256:acce4e3267610c4fdb6632b3886fe3f2f7dd641158a843cf6b6a68e4ce81477b", - "sha256:be089bb6b83fac7f29d357b2dc4cf2b8eb8d98fe9d9ff89f9ea6012970a853c7", - "sha256:bfab710d859c779f273cc48fb86af38d6e9210f38287df0069a63e40b45a2f5c", - "sha256:c10d29019927301d524a22ced72706380de7cfc50f767217485a912b4c8bd82a", - "sha256:dd6e2b598849b3d7aee2295ac765a578879830fb8966f70be8cd472e6069932e", - "sha256:e408f1eacc0a68fed0c08da45f31d0ebb38079f043328dce69ff133b95c29dc1" - ], - "version": "==1.4.1" - }, - "libusb1": { - "hashes": [ - "sha256:adf64a4f3f5c94643a1286f8153bcf4bc787c348b38934aacd7fe17fbeebc571" - ], - "index": "pypi", - "version": "==1.7.1" - }, - "logentries": { - "git": "https://github.com/commaai/le_python.git", - "ref": "5eef8f5be5929d33973e1b10e686fa0cdcd6792f" - }, - "markupsafe": { - "hashes": [ - "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473", - "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161", - "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235", - "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5", - "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff", - "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b", - "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1", - "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e", - "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183", - "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66", - "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1", - "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1", - "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e", - "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b", - "sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905", - "sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735", - "sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d", - "sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e", - "sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d", - "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c", - "sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21", - "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2", - "sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5", - "sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b", - "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6", - "sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f", - "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f", - "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7" - ], - "version": "==1.1.1" - }, - "mccabe": { - "hashes": [ - "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", - "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" - ], - "version": "==0.6.1" - }, - "mpmath": { - "hashes": [ - "sha256:fc17abe05fbab3382b61a123c398508183406fa132e0223874578e20946499f6" - ], - "version": "==1.1.0" - }, - "nose": { - "hashes": [ - "sha256:9ff7c6cc443f8c51994b34a667bbcf45afd6d945be7477b52e97516fd17c53ac", - "sha256:dadcddc0aefbf99eea214e0f1232b94f2fa9bd98fa8353711dacb112bfcbbb2a", - "sha256:f1bffef9cbc82628f6e7d7b40d7e255aefaa1adb6a1b1d26c69a8b79e6208a98" - ], - "index": "pypi", - "version": "==1.3.7" - }, - "numpy": { - "hashes": [ - "sha256:0778076e764e146d3078b17c24c4d89e0ecd4ac5401beff8e1c87879043a0633", - "sha256:141c7102f20abe6cf0d54c4ced8d565b86df4d3077ba2343b61a6db996cefec7", - "sha256:14270a1ee8917d11e7753fb54fc7ffd1934f4d529235beec0b275e2ccf00333b", - "sha256:27e11c7a8ec9d5838bc59f809bfa86efc8a4fd02e58960fa9c49d998e14332d5", - "sha256:2a04dda79606f3d2f760384c38ccd3d5b9bb79d4c8126b67aff5eb09a253763e", - "sha256:3c26010c1b51e1224a3ca6b8df807de6e95128b0908c7e34f190e7775455b0ca", - "sha256:52c40f1a4262c896420c6ea1c6fda62cf67070e3947e3307f5562bd783a90336", - "sha256:6e4f8d9e8aa79321657079b9ac03f3cf3fd067bf31c1cca4f56d49543f4356a5", - "sha256:7242be12a58fec245ee9734e625964b97cf7e3f2f7d016603f9e56660ce479c7", - "sha256:7dc253b542bfd4b4eb88d9dbae4ca079e7bf2e2afd819ee18891a43db66c60c7", - "sha256:94f5bd885f67bbb25c82d80184abbf7ce4f6c3c3a41fbaa4182f034bba803e69", - "sha256:a89e188daa119ffa0d03ce5123dee3f8ffd5115c896c2a9d4f0dbb3d8b95bfa3", - "sha256:ad3399da9b0ca36e2f24de72f67ab2854a62e623274607e37e0ce5f5d5fa9166", - "sha256:b0348be89275fd1d4c44ffa39530c41a21062f52299b1e3ee7d1c61f060044b8", - "sha256:b5554368e4ede1856121b0dfa35ce71768102e4aa55e526cb8de7f374ff78722", - "sha256:cbddc56b2502d3f87fda4f98d948eb5b11f36ff3902e17cb6cc44727f2200525", - "sha256:d79f18f41751725c56eceab2a886f021d70fd70a6188fd386e29a045945ffc10", - "sha256:dc2ca26a19ab32dc475dbad9dfe723d3a64c835f4c23f625c2b6566ca32b9f29", - "sha256:dd9bcd4f294eb0633bb33d1a74febdd2b9018b8b8ed325f861fffcd2c7660bb8", - "sha256:e8baab1bc7c9152715844f1faca6744f2416929de10d7639ed49555a85549f52", - "sha256:ec31fe12668af687b99acf1567399632a7c47b0e17cfb9ae47c098644ef36797", - "sha256:f12b4f7e2d8f9da3141564e6737d79016fe5336cc92de6814eba579744f65b0a", - "sha256:f58ac38d5ca045a377b3b377c84df8175ab992c970a53332fa8ac2373df44ff7" - ], - "index": "pypi", - "version": "==1.16.4" - }, - "overpy": { - "git": "https://github.com/commaai/python-overpy.git", - "ref": "f86529af402d4642e1faeb146671c40284007323" - }, - "psutil": { - "hashes": [ - "sha256:028a1ec3c6197eadd11e7b46e8cc2f0720dc18ac6d7aabdb8e8c0d6c9704f000", - "sha256:503e4b20fa9d3342bcf58191bbc20a4a5ef79ca7df8972e6197cc14c5513e73d", - "sha256:863a85c1c0a5103a12c05a35e59d336e1d665747e531256e061213e2e90f63f3", - "sha256:954f782608bfef9ae9f78e660e065bd8ffcfaea780f9f2c8a133bb7cb9e826d7", - "sha256:b6e08f965a305cd84c2d07409bc16fbef4417d67b70c53b299116c5b895e3f45", - "sha256:bc96d437dfbb8865fc8828cf363450001cb04056bbdcdd6fc152c436c8a74c61", - "sha256:cf49178021075d47c61c03c0229ac0c60d5e2830f8cab19e2d88e579b18cdb76", - "sha256:d5350cb66690915d60f8b233180f1e49938756fb2d501c93c44f8fb5b970cc63", - "sha256:eba238cf1989dfff7d483c029acb0ac4fcbfc15de295d682901f0e2497e6781a" - ], - "index": "pypi", - "version": "==5.6.3" - }, - "pycapnp": { - "hashes": [ - "sha256:44e14a5ace399cf1753acb8bbce558b8c895c48fd2102d266c34eaff286824cf" - ], - "index": "pypi", - "version": "==0.6.4" - }, - "pycparser": { - "hashes": [ - "sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3" - ], - "version": "==2.19" - }, - "pycryptodome": { - "hashes": [ - "sha256:0281dc6a65a4d0d9e439f54e0ad5faf27bfdc2ebe9ead36912bac74a0920fa2e", - "sha256:02af9b284f5c9a55f06f5e4532c16c9b7bd958e293e93969934d864ef7bd87ee", - "sha256:09da99372fb69762e4b9690291176a166cc351793e2e1c9405d29ca291503aa8", - "sha256:0c2400ccfc049c3f24e65d4f02bb4208d86e408011019e455fab7f50d2b226c9", - "sha256:2081dd6dce6b21bf3596427edaedd4f2561dce616893b162ed2c674f3a3ca70a", - "sha256:28b86ec9fdb005a2a18e4862a3a7277046738825ee8dc89cda5657e75a396089", - "sha256:2d790c0d4c0d5edcf5fbab4e2af7b03757e40c5ae8d217f0dfe9ddea37fe130f", - "sha256:2f24906153dca16528cf5515b1afa9ef635423d5a654904e861765f88ca667b6", - "sha256:30d283939896fa4bacbdb9fa86e6fd51e9a5b953a511e210b38481f697f289f5", - "sha256:31f78b67f97830d137f74813c0502a181a03b43a32ed124049bb20428176c307", - "sha256:33c1f3a380fd38ab4dd4372bef17e98002b360b52814bb1b077693b1bd06ec87", - "sha256:34091e9a6650c44e25339f22fc821396f19f152f65be2546edd823a093fb5a04", - "sha256:567fb73951ab6865a2eb1a0060b54be1e27302574f6c65879525bdf53fab49e1", - "sha256:5bc40f8aa7ba8ca7f833ad2477b9d84e1bfd2630b22a46d9bbd221982f8c3ac0", - "sha256:6b0a0ccf33c7a6100c569667c888335a4aaf0d22218cb97b4963a65d70f6c343", - "sha256:71b93157f1ce93fc7cfff9359b76def2b4826a7ef7a7f95e070161368e7f584a", - "sha256:7d939d511b7dac29b2d936706786771ecb8256e43fade5cdb0e8bc58f02b86cf", - "sha256:7fbc5a93d52e4c51487f4648b00dc41700adb144d10fc567b05f852e76c243ad", - "sha256:9cb94b8f9c915a5d2b273d612a25a8e5d67b49543f8eb6bcec0275ac46cda421", - "sha256:a585ea1722f9731e75881d5ffcc51d11c794d244ac57e7c2a9cbb8d5ac729302", - "sha256:a6458dd7a10ae51f6fce56bdfc79bf6d3b54556237045d09e77fbda9d6d37864", - "sha256:a9fb92e948128bce0239b87c6efcf2cb1c5a703d0b41dd6835211e6fafd1c5df", - "sha256:b0b6b4ca1c53e7d6ca9f2720919f63837f05e7a5f92912a2bc29bfd03ed3b54f", - "sha256:b7d22c8d648aaa3a7ec785eda544402141eb78ac5ffbba4cbe2c3a1f52276870", - "sha256:bc9560574a868cfa2ba781b7bb0b4685b08ea251697abfc49070ffc05e1cbee6", - "sha256:c0c5a576f3f7b7de3f86889cb47eb51b59dc11db9cf1e2a0f51eb4d988010ea4", - "sha256:e1c91c2fa942a71c98a7a1f462de6dbbe82f34b9267eb8131314d97bd13bf0d4", - "sha256:ec936361ad78aa95382c313df95777795b8185aac5dd3ec5463363ea94b556fc" - ], - "index": "pypi", - "version": "==3.8.2" - }, - "pyflakes": { - "hashes": [ - "sha256:17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0", - "sha256:d976835886f8c5b31d47970ed689944a0262b5f3afa00a5a7b4dc81e5449f8a2" - ], - "index": "pypi", - "version": "==2.1.1" - }, - "pyjwt": { - "hashes": [ - "sha256:5c6eca3c2940464d106b99ba83b00c6add741c9becaec087fb7ccdefea71350e", - "sha256:8d59a976fb773f3e6a39c85636357c4f0e242707394cadadd9814f5cbaa20e96" - ], - "index": "pypi", - "version": "==1.7.1" - }, - "pylint": { - "hashes": [ - "sha256:367e3d49813d349a905390ac27989eff82ab84958731c5ef0bef867452cfdc42", - "sha256:97a42df23d436c70132971d1dcb9efad2fe5c0c6add55b90161e773caf729300" - ], - "index": "pypi", - "version": "==1.9.5" - }, - "pyserial": { - "hashes": [ - "sha256:6e2d401fdee0eab996cf734e67773a0143b932772ca8b42451440cfed942c627", - "sha256:e0770fadba80c31013896c7e6ef703f72e7834965954a78e71a3049488d4d7d8" - ], - "index": "pypi", - "version": "==3.4" - }, - "python-dateutil": { - "hashes": [ - "sha256:7e6584c74aeed623791615e26efd690f29817a27c73085b78e4bad02493df2fb", - "sha256:c89805f6f4d64db21ed966fda138f8a5ed7a4fdbc1a8ee329ce1b74e3c74da9e" - ], - "index": "pypi", - "version": "==2.8.0" - }, - "pyyaml": { - "hashes": [ - "sha256:57acc1d8533cbe51f6662a55434f0dbecfa2b9eaf115bede8f6fd00115a0c0d3", - "sha256:588c94b3d16b76cfed8e0be54932e5729cc185caffaa5a451e7ad2f7ed8b4043", - "sha256:68c8dd247f29f9a0d09375c9c6b8fdc64b60810ebf07ba4cdd64ceee3a58c7b7", - "sha256:70d9818f1c9cd5c48bb87804f2efc8692f1023dac7f1a1a5c61d454043c1d265", - "sha256:86a93cccd50f8c125286e637328ff4eef108400dd7089b46a7be3445eecfa391", - "sha256:a0f329125a926876f647c9fa0ef32801587a12328b4a3c741270464e3e4fa778", - "sha256:a3c252ab0fa1bb0d5a3f6449a4826732f3eb6c0270925548cac342bc9b22c225", - "sha256:b4bb4d3f5e232425e25dda21c070ce05168a786ac9eda43768ab7f3ac2770955", - "sha256:cd0618c5ba5bda5f4039b9398bb7fb6a317bb8298218c3de25c47c4740e4b95e", - "sha256:ceacb9e5f8474dcf45b940578591c7f3d960e82f926c707788a570b51ba59190", - "sha256:fe6a88094b64132c4bb3b631412e90032e8cfe9745a58370462240b8cb7553cd" - ], - "index": "pypi", - "version": "==5.1.1" - }, - "pyzmq": { - "hashes": [ - "sha256:00dd015159eaeb1c0731ad49310e1f5d839c9a35a15e4f3267f5052233fad99b", - "sha256:03913b6beb8e7b417b9910b0ee1fd5d62e9626d218faefbe879d70714ceab1a2", - "sha256:13f17386df81d5e6efb9a4faea341d8de22cdc82e49a326dded26e33f42a3112", - "sha256:16c6281d96885db1e15f7047ddc1a8f48ff4ea35d31ca709f4d2eb39f246d356", - "sha256:17efab4a804e31f58361631256d660214204046f9e2b962738b171b9ad674ea7", - "sha256:2b79919ddeff3d3c96aa6087c21d294c8db1c01f6bfeee73324944683685f419", - "sha256:2f832e4711657bb8d16ea1feba860f676ec5f14fb9fe3b449b5953a60e89edae", - "sha256:31a11d37ac73107363b47e14c94547dbfc6a550029c3fe0530be443199026fc2", - "sha256:33a3e928e6c3138c675e1d6702dd11f6b7050177d7aab3fc322db6e1d2274490", - "sha256:34a38195a6d3a9646cbcdaf8eb245b4d935c7a57f7e1b3af467814bc1a92467e", - "sha256:42900054f1500acef6df7428edf806abbf641bf92eb9ceded24aa863397c3bae", - "sha256:4ccc7f3c63aa9d744dadb62c49eda2d0e7de55649b80c45d7c684d70161a69af", - "sha256:5b220c37c346e6575db8c88a940c1fc234f99ce8e0068c408919bb8896c4b6d2", - "sha256:6074848da5c8b44a1ca40adf75cf65aa92bc80f635e8249aa8f37a69b2b9b6f5", - "sha256:61a4155964bd4a14ef95bf46cb1651bcf8dcbbed8c0108e9c974c1fcbb57788f", - "sha256:62b5774688326600c52f587f7a033ca6b6284bef4c8b1b5fda32480897759eac", - "sha256:65a9ffa4f9f085d696f16fd7541f34b3c357d25fe99c90e3bce2ea59c3b5b4b6", - "sha256:76a077d2c30f8adc5e919a55985a784b96aeca69b53c1ea6fd5723d3ae2e6f53", - "sha256:8e5b4c51557071d6379d6dc1f54f35e9f6a137f5e84e102efb869c8d3c13c8ff", - "sha256:917f73e07cc04f0678a96d93e7bb8b1adcccdde9ccfe202e622814f4d1d1ecfd", - "sha256:91c75d3c4c357f9643e739db9e79ab9681b2f6ae8ec5678d6ef2ea0d01532596", - "sha256:923dd91618b100bb4c92ab9ed7b65825a595b8524a094ce03c7cb2aaae7d353b", - "sha256:9849054e0355e2bc7f4668766a25517ba76095031c9ff5e39ae8949cee5bb024", - "sha256:c9d453933f0e3f44b9759189f2a18aa765f7f1a4345c727c18ebe8ad0d748d26", - "sha256:cb7514936277abce64c2f4c56883e5704d85ed04d98d2d432d1c6764003bb003" - ], - "index": "pypi", - "version": "==18.0.2" - }, - "raven": { - "hashes": [ - "sha256:3fa6de6efa2493a7c827472e984ce9b020797d0da16f1db67197bcc23c8fae54", - "sha256:44a13f87670836e153951af9a3c80405d36b43097db869a36e92809673692ce4" - ], - "index": "pypi", - "version": "==6.10.0" - }, - "requests": { - "hashes": [ - "sha256:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4", - "sha256:9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31" - ], - "index": "pypi", - "version": "==2.22.0" - }, - "setproctitle": { - "hashes": [ - "sha256:6283b7a58477dd8478fbb9e76defb37968ee4ba47b05ec1c053cb39638bd7398", - "sha256:6a035eddac62898786aed2c2eee7334c28cfc8106e8eb29fdd117cac56c6cdf0" - ], - "index": "pypi", - "version": "==1.1.10" - }, - "singledispatch": { - "hashes": [ - "sha256:5b06af87df13818d14f08a028e42f566640aef80805c3b50c5056b086e3c2b9c", - "sha256:833b46966687b3de7f438c761ac475213e53b306740f1abfaa86e1d1aae56aa8" - ], - "markers": "python_version < '3.4'", - "version": "==3.4.0.3" - }, - "six": { - "hashes": [ - "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", - "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" - ], - "index": "pypi", - "version": "==1.12.0" - }, - "smbus2": { - "hashes": [ - "sha256:4d5aae2f65d39056bb44e8906d5c503f8ee7e02fadb0a6433f1091a9ce528dde" - ], - "index": "pypi", - "version": "==0.2.3" - }, - "sympy": { - "hashes": [ - "sha256:71a11e5686ae7ab6cb8feb5bd2651ef4482f8fd43a7c27e645a165e4353b23e1", - "sha256:f9b00ec76151c98470e84f1da2d7d03633180b71fb318428ddccce1c867d3eaa" - ], - "index": "pypi", - "version": "==1.4" - }, - "tqdm": { - "hashes": [ - "sha256:14a285392c32b6f8222ecfbcd217838f88e11630affe9006cd0e94c7eff3cb61", - "sha256:25d4c0ea02a305a688e7e9c2cdc8f862f989ef2a4701ab28ee963295f5b109ab" - ], - "index": "pypi", - "version": "==4.32.2" - }, - "urllib3": { - "hashes": [ - "sha256:b246607a25ac80bedac05c6f282e3cdaf3afb65420fd024ac94435cabe6e18d1", - "sha256:dbe59173209418ae49d485b87d1681aefa36252ee85884c31346debd19463232" - ], - "index": "pypi", - "version": "==1.25.3" - }, - "utm": { - "hashes": [ - "sha256:07e55707ed660eec1ae983bd54a406c437962618a6261b38d70592fe30f5f508" - ], - "index": "pypi", - "version": "==0.5.0" - }, - "websocket-client": { - "hashes": [ - "sha256:1151d5fb3a62dc129164292e1227655e4bbc5dd5340a5165dfae61128ec50aa9", - "sha256:1fd5520878b68b84b5748bb30e592b10d0a91529d5383f74f4964e72b297fd3a" - ], - "index": "pypi", - "version": "==0.56.0" - }, - "werkzeug": { - "hashes": [ - "sha256:87ae4e5b5366da2347eb3116c0e6c681a0e939a33b2805e2c0cbd282664932c4", - "sha256:a13b74dd3c45f758d4ebdb224be8f1ab8ef58b3c0ffc1783a8c7d9f4f50227e6" - ], - "version": "==0.15.5" - }, - "wrapt": { - "hashes": [ - "sha256:565a021fd19419476b9362b05eeaa094178de64f8361e44468f9e9d7843901e1" - ], - "version": "==1.11.2" - } - }, - "develop": { - "absl-py": { - "hashes": [ - "sha256:b943d1c567743ed0455878fcd60bc28ac9fae38d129d1ccfad58079da00b8951" - ], - "version": "==0.7.1" - }, - "adal": { - "hashes": [ - "sha256:5a7f1e037c6290c6d7609cab33a9e5e988c2fbec5c51d1c4c649ee3faff37eaf", - "sha256:fd17e5661f60634ddf96a569b95d34ccb8a98de60593d729c28bdcfe360eaad1" - ], - "version": "==1.2.2" - }, - "aenum": { - "hashes": [ - "sha256:0e3589654ef090784971f7778dcb74b08c9b4ef80b33267c00f82ddeedac179a", - "sha256:b12a7be3d89b270f266f8643aaa126404e5cdc0929bd6f09548b8eaed85e2aa1", - "sha256:e4dab068cbe00295bbc3660cd562221b008687d0f7a4c40fc2dd7a80002126a7" - ], - "index": "pypi", - "version": "==2.2.1" - }, - "amqp": { - "hashes": [ - "sha256:aa4409446139676943a2eaa27d5f58caf750f4ca5a89f888c452afd86be6a67d", - "sha256:cbb6f87d53cac612a594f982b717cc1c54c6a1e17943a0a0d32dc6cc9e2120c8" - ], - "version": "==2.5.0" - }, - "asn1crypto": { - "hashes": [ - "sha256:2f1adbb7546ed199e3c90ef23ec95c5cf3585bac7d11fb7eb562a3fe89c64e87", - "sha256:9d5c20441baf0cb60a4ac34cc447c6c189024b6b4c6cd7877034f4965c464e49" - ], - "version": "==0.24.0" - }, - "astor": { - "hashes": [ - "sha256:0e41295809baf43ae8303350e031aff81ae52189b6f881f36d623fa8b2f1960e", - "sha256:37a6eed8b371f1228db08234ed7f6cfdc7817a3ed3824797e20cbb11dc2a7862" - ], - "version": "==0.8.0" - }, - "astroid": { - "hashes": [ - "sha256:87de48a92e29cedf7210ffa853d11441e7ad94cb47bacd91b023499b51cbc756", - "sha256:d25869fc7f44f1d9fb7d24fd7ea0639656f5355fc3089cd1f3d18c6ec6b124c7" - ], - "version": "==1.6.6" - }, - "attrs": { - "hashes": [ - "sha256:69c0dbf2ed392de1cb5ec704444b08a5ef81680a61cb899dc08127123af36a79", - "sha256:f0b870f674851ecbfbbbd364d6b5cbdff9dcedbc7f3f5e18a6891057f21fe399" - ], - "version": "==19.1.0" - }, - "azure-batch": { - "hashes": [ - "sha256:017be21a9e6db92473d2e33170d5dd445596fc70d706f73552ac9c6b57a6ef1c", - "sha256:cd71c7ebb5beab174b6225bbf79ae18d6db0c8d63227a7e514da0a75f138364c" - ], - "index": "pypi", - "version": "==4.1.3" - }, - "azure-common": { - "hashes": [ - "sha256:2606ae77ff81c0036965b92ec2efe03eaec02a66714140ca0f7aa401b8b9bbb0", - "sha256:c908621a71eb4ee9fab0962e35d3c27a18f09a854d8359c2f32c15b3f4fc576e" - ], - "index": "pypi", - "version": "==1.1.16" - }, - "azure-nspkg": { - "hashes": [ - "sha256:a908f96a695b12e31b6c56cda0bb8e6d2a054283c350881667f300b8563ece33", - "sha256:af81fd4512be5ad0834b8e82c43bbe80b016bd295a8794fac28d69bf243357e0", - "sha256:ce4173e06f2f423775c4ca8a635e9a89b5fe8e4ba9fefbbe2a1e0d525072392c" - ], - "index": "pypi", - "version": "==3.0.1" - }, - "azure-storage-blob": { - "hashes": [ - "sha256:308058abfd789f5830d91f6407eb00a7b04925b2b9af267aecfb46c335802cdc", - "sha256:8cab5420ba6646ead09fdb497646f735b12645cba8efed96a86f7b370e175ade" - ], - "index": "pypi", - "version": "==1.3.1" - }, - "azure-storage-common": { - "hashes": [ - "sha256:585658ebc784e843a285732a69aa69ef922e17c3063460c2c7b27c89f377004c", - "sha256:a412a78618e82bf99030ce56f1f2d5fc6c2c2eec7ee1beda86ce6ea5f2c9196b" - ], - "index": "pypi", - "version": "==1.3.0" - }, - "azure-storage-nspkg": { - "hashes": [ - "sha256:4fc4685aef941eab2f7fb53824254cca2e38f2a1bf33cda0c8ae654fe15827d6", - "sha256:855315c038c0e695868025127e1b3057a1f984af9ccfbaeac4fbfd6c5dd3b466" - ], - "index": "pypi", - "version": "==3.0.0" - }, - "backports-abc": { - "hashes": [ - "sha256:033be54514a03e255df75c5aee8f9e672f663f93abb723444caec8fe43437bde", - "sha256:52089f97fe7a9aa0d3277b220c1d730a85aefd64e1b2664696fe35317c5470a7" - ], - "index": "pypi", - "version": "==0.5" - }, - "backports.functools-lru-cache": { - "hashes": [ - "sha256:9d98697f088eb1b0fa451391f91afb5e3ebde16bbdb272819fd091151fda4f1a", - "sha256:f0b0e4eba956de51238e17573b7087e852dfe9854afd2e9c873f73fc0ca0a6dd" - ], - "markers": "python_version == '2.7'", - "version": "==1.5" - }, - "backports.lzma": { - "hashes": [ - "sha256:50829db66f0445442f6c796bba0ca62d1f87f54760c4682b6d1489e729a43744" - ], - "index": "pypi", - "version": "==0.0.13" - }, - "backports.shutil-get-terminal-size": { - "hashes": [ - "sha256:0975ba55054c15e346944b38956a4c9cbee9009391e41b86c68990effb8c1f64", - "sha256:713e7a8228ae80341c70586d1cc0a8caa5207346927e23d09dcbcaf18eadec80" - ], - "markers": "python_version == '2.7'", - "version": "==1.0.0" - }, - "backports.weakref": { - "hashes": [ - "sha256:81bc9b51c0abc58edc76aefbbc68c62a787918ffe943a37947e162c3f8e19e82", - "sha256:bc4170a29915f8b22c9e7c4939701859650f2eb84184aee80da329ac0b9825c2" - ], - "version": "==1.0.post1" - }, - "billiard": { - "hashes": [ - "sha256:756bf323f250db8bf88462cd042c992ba60d8f5e07fc5636c24ba7d6f4261d84" - ], - "version": "==3.6.0.0" - }, - "bincopy": { - "hashes": [ - "sha256:61d02c09910635599127056d2707c22bfa310cb31f935fbfdda406639017717e", - "sha256:a0e31dc5de70bffaf717bb76b136857eb78ea138fb49dc5a1bf06303f103dff8" - ], - "index": "pypi", - "version": "==16.0.0" - }, - "bleach": { - "hashes": [ - "sha256:978e758599b54cd3caa2e160d74102879b230ea8dc93871d0783721eef58bc65", - "sha256:e67f46adcec78dbc3c04462f3aba3213a673d5652eba2609ed1ef15492a44b8d" - ], - "index": "pypi", - "version": "==1.5.0" - }, - "boto": { - "hashes": [ - "sha256:147758d41ae7240dc989f0039f27da8ca0d53734be0eb869ef16e3adcfa462e8", - "sha256:ea0d3b40a2d852767be77ca343b58a9e3a4b00d9db440efb8da74b4e58025e5a" - ], - "index": "pypi", - "version": "==2.49.0" - }, - "boto3": { - "hashes": [ - "sha256:6a950bf98b22812896ea0f833a26d448acfdf43179f41f389d501af7a9fae328", - "sha256:cfbc062a76a7781af8e6a4ea26ebcafa3866872a8cceb05fdbf588c36e7848f0" - ], - "index": "pypi", - "version": "==1.9.195" - }, - "botocore": { - "hashes": [ - "sha256:691627c2aeff0fcbd9237985717c28404a628181fd3e86b7be500bf2ee156007", - "sha256:c59e9981db9dfc54f0d22f731ca8de904760049a9c60d86dcedde84ae64ef4f0" - ], - "version": "==1.12.195" - }, - "celery": { - "hashes": [ - "sha256:4c4532aa683f170f40bd76f928b70bc06ff171a959e06e71bf35f2f9d6031ef9", - "sha256:528e56767ae7e43a16cfef24ee1062491f5754368d38fcfffa861cdb9ef219be" - ], - "index": "pypi", - "version": "==4.3.0" - }, - "certifi": { - "hashes": [ - "sha256:046832c04d4e752f37383b628bc601a7ea7211496b4638f6514d0e5b9acc4939", - "sha256:945e3ba63a0b9f577b1395204e13c3a231f9bc0223888be653286534e5873695" - ], - "version": "==2019.6.16" - }, - "cffi": { - "hashes": [ - "sha256:041c81822e9f84b1d9c401182e174996f0bae9991f33725d059b771744290774", - "sha256:046ef9a22f5d3eed06334d01b1e836977eeef500d9b78e9ef693f9380ad0b83d", - "sha256:066bc4c7895c91812eff46f4b1c285220947d4aa46fa0a2651ff85f2afae9c90", - "sha256:066c7ff148ae33040c01058662d6752fd73fbc8e64787229ea8498c7d7f4041b", - "sha256:2444d0c61f03dcd26dbf7600cf64354376ee579acad77aef459e34efcb438c63", - "sha256:300832850b8f7967e278870c5d51e3819b9aad8f0a2c8dbe39ab11f119237f45", - "sha256:34c77afe85b6b9e967bd8154e3855e847b70ca42043db6ad17f26899a3df1b25", - "sha256:46de5fa00f7ac09f020729148ff632819649b3e05a007d286242c4882f7b1dc3", - "sha256:4aa8ee7ba27c472d429b980c51e714a24f47ca296d53f4d7868075b175866f4b", - "sha256:4d0004eb4351e35ed950c14c11e734182591465a33e960a4ab5e8d4f04d72647", - "sha256:4e3d3f31a1e202b0f5a35ba3bc4eb41e2fc2b11c1eff38b362de710bcffb5016", - "sha256:50bec6d35e6b1aaeb17f7c4e2b9374ebf95a8975d57863546fa83e8d31bdb8c4", - "sha256:55cad9a6df1e2a1d62063f79d0881a414a906a6962bc160ac968cc03ed3efcfb", - "sha256:5662ad4e4e84f1eaa8efce5da695c5d2e229c563f9d5ce5b0113f71321bcf753", - "sha256:59b4dc008f98fc6ee2bb4fd7fc786a8d70000d058c2bbe2698275bc53a8d3fa7", - "sha256:73e1ffefe05e4ccd7bcea61af76f36077b914f92b76f95ccf00b0c1b9186f3f9", - "sha256:a1f0fd46eba2d71ce1589f7e50a9e2ffaeb739fb2c11e8192aa2b45d5f6cc41f", - "sha256:a2e85dc204556657661051ff4bab75a84e968669765c8a2cd425918699c3d0e8", - "sha256:a5457d47dfff24882a21492e5815f891c0ca35fefae8aa742c6c263dac16ef1f", - "sha256:a8dccd61d52a8dae4a825cdbb7735da530179fea472903eb871a5513b5abbfdc", - "sha256:ae61af521ed676cf16ae94f30fe202781a38d7178b6b4ab622e4eec8cefaff42", - "sha256:b012a5edb48288f77a63dba0840c92d0504aa215612da4541b7b42d849bc83a3", - "sha256:d2c5cfa536227f57f97c92ac30c8109688ace8fa4ac086d19d0af47d134e2909", - "sha256:d42b5796e20aacc9d15e66befb7a345454eef794fdb0737d1af593447c6c8f45", - "sha256:dee54f5d30d775f525894d67b1495625dd9322945e7fee00731952e0368ff42d", - "sha256:e070535507bd6aa07124258171be2ee8dfc19119c28ca94c9dfb7efd23564512", - "sha256:e1ff2748c84d97b065cc95429814cdba39bcbd77c9c85c89344b317dc0d9cbff", - "sha256:ed851c75d1e0e043cbf5ca9a8e1b13c4c90f3fbd863dacb01c0808e2b5204201" - ], - "index": "pypi", - "version": "==1.12.3" - }, - "chardet": { - "hashes": [ - "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", - "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" - ], - "index": "pypi", - "version": "==3.0.4" - }, - "click": { - "hashes": [ - "sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13", - "sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7" - ], - "version": "==7.0" - }, - "cloudpickle": { - "hashes": [ - "sha256:603244e0f552b72a267d47a7d9b347b27a3430f58a0536037a290e7e0e212ecf", - "sha256:b8ba7e322f2394b9bbbdc1c976e6442c2c02acc784cb9e553cee9186166a6890" - ], - "version": "==1.2.1" - }, - "configparser": { - "hashes": [ - "sha256:8be81d89d6e7b4c0d4e44bcc525845f6da25821de80cb5e06e7e0238a2899e32", - "sha256:da60d0014fd8c55eb48c1c5354352e363e2d30bbf7057e5e171a468390184c75" - ], - "markers": "python_version == '2.7'", - "version": "==3.7.4" - }, - "control": { - "hashes": [ - "sha256:726e8c36a253a54c8886df31f860d740d70de4f8b041421d5df078c3bff3aadb" - ], - "index": "pypi", - "version": "==0.8.2" - }, - "cryptography": { - "hashes": [ - "sha256:24b61e5fcb506424d3ec4e18bca995833839bf13c59fc43e530e488f28d46b8c", - "sha256:25dd1581a183e9e7a806fe0543f485103232f940fcfc301db65e630512cce643", - "sha256:3452bba7c21c69f2df772762be0066c7ed5dc65df494a1d53a58b683a83e1216", - "sha256:41a0be220dd1ed9e998f5891948306eb8c812b512dc398e5a01846d855050799", - "sha256:5751d8a11b956fbfa314f6553d186b94aa70fdb03d8a4d4f1c82dcacf0cbe28a", - "sha256:5f61c7d749048fa6e3322258b4263463bfccefecb0dd731b6561cb617a1d9bb9", - "sha256:72e24c521fa2106f19623a3851e9f89ddfdeb9ac63871c7643790f872a305dfc", - "sha256:7b97ae6ef5cba2e3bb14256625423413d5ce8d1abb91d4f29b6d1a081da765f8", - "sha256:961e886d8a3590fd2c723cf07be14e2a91cf53c25f02435c04d39e90780e3b53", - "sha256:96d8473848e984184b6728e2c9d391482008646276c3ff084a1bd89e15ff53a1", - "sha256:ae536da50c7ad1e002c3eee101871d93abdc90d9c5f651818450a0d3af718609", - "sha256:b0db0cecf396033abb4a93c95d1602f268b3a68bb0a9cc06a7cff587bb9a7292", - "sha256:cfee9164954c186b191b91d4193989ca994703b2fff406f71cf454a2d3c7327e", - "sha256:e6347742ac8f35ded4a46ff835c60e68c22a536a8ae5c4422966d06946b6d4c6", - "sha256:f27d93f0139a3c056172ebb5d4f9056e770fdf0206c2f422ff2ebbad142e09ed", - "sha256:f57b76e46a58b63d1c6375017f4564a28f19a5ca912691fd2e4261b3414b618d" - ], - "index": "pypi", - "version": "==2.7" - }, - "cycler": { - "hashes": [ - "sha256:1d8a5ae1ff6c5cf9b93e8811e581232ad8920aeec647c37316ceac982b08cb2d", - "sha256:cd7b2d1018258d7247a71425e9f26463dfb444d411c39569972f4ce586b0c9d8" - ], - "version": "==0.10.0" - }, - "cython": { - "hashes": [ - "sha256:04ebf16df9406d3279a2489c3327803c782d9e17637d525bfb44ecf5ec65850f", - "sha256:1486ec88d1c73dea3846a5640054018b002608e04a791ccbd2082a47bce4440a", - "sha256:20da832a5e9a8e93d1e1eb64650258956723940968eb585506531719b55b804f", - "sha256:2464688b523d7a133b52cf1343c1c595b92fc6554af1015f74b9e49951e992d4", - "sha256:27827b68a8359e9ab6bf683c68d8ee79863a0c94a577acf56aa02cc302e16f51", - "sha256:27deeeeca0fd8933af07923e809c8fed0763d150a4fdd4082932a33b8c874ed6", - "sha256:31f4da785d5e09deb852ea59795a629c5befb6040929e7880c6f63e6668246ce", - "sha256:4828cf8fa638c35139e643f30201b240c0d156b1b9967a7321ae42d721d7224c", - "sha256:48b365e32cc5639ae2c239d7bd4f8a1d920a13a7ae92113c4c938903c9400147", - "sha256:4eb71856c1d1b33083df9318fd30143470ad6f0d1b9ad2ee61a120710842d28b", - "sha256:5b06ef8422d27d8128f8f80bdefa111eadcab246fba1d668720af4f0b97b7a0e", - "sha256:71c553640e1ddaaf143e38dbc6cd1863fa3c0738fb1830a9aaffba9a51838f30", - "sha256:73e2742ee1f923c5f213183bf493901f9630e395634fce5b739a53b7dc5d64be", - "sha256:82a632bc02063eff0b8e7ff3089aa3d912d1c7499709f51c8f04f57c8832cfe6", - "sha256:977ca1ac059e4d4a4bf5fe2224986baf42b69290453eda44822606f4deae6515", - "sha256:a7e6217d0dd864a7cc4f457172766864496efd64d24d4980df1521f75f992761", - "sha256:ad0ed7dd5dff76eb3aae8c18d95b1c9f885a91a92132728051a704fb8060d08c", - "sha256:b1b8eda9e931f0ca1aadb95a890811bdf530407e48c962643b85675329d99abf", - "sha256:cec99c79205131da3ee75becea1f3f55c57bf6a1c500431de9ae7a32ac8a5cc4", - "sha256:d4bbdaa6f61ce2ef26535a7d473d6ffa6e413013c5c580af999546bf1627ae11", - "sha256:d8bdb4208975b12048bdace46e9dd8e3dda3872432f95b53789700a1330e6060", - "sha256:dce0362ff9b61f8411d1efc9e16fc528dadbd3707a557561992457f5cb446297", - "sha256:defbbbf5653629ce5cc54091ce49c6830da8d3104de53ed2169c9efcb0720f27", - "sha256:e0c53a7e2b6d82ec3c26c009c937fc88eb8c7edf000c54334261beaf56bb08f2", - "sha256:e1065bacfe5303f107896e63263537dee90920d26050f2e23c4af12c37da2db6", - "sha256:e142837c4212c0b2c71e6773cb6740828922806b4c00ee4215be3ceb558671e6", - "sha256:f4cbbab28c93ffee6ec929cf0826f0b11d2488e53a708d51142a5e62f8cd9806", - "sha256:fa8f63b6551621eea9efea4db37ae401104352f0ebaee32f7d20be88cbe589c3" - ], - "index": "pypi", - "version": "==0.29.12" - }, - "datadog": { - "hashes": [ - "sha256:0e33727bd9ef0b8201359accdf12f61fb58ab541bf4062693aca16653f8e7a0a", - "sha256:995e51d142ae3624c86c78369b268f23386bb207df5345d718c241718387875c" - ], - "index": "pypi", - "version": "==0.29.3" - }, - "decorator": { - "hashes": [ - "sha256:86156361c50488b84a3f148056ea716ca587df2f0de1d34750d35c21312725de", - "sha256:f069f3a01830ca754ba5258fde2278454a0b5b79e0d7f5c13b3b97e57d4acff6" - ], - "index": "pypi", - "version": "==4.4.0" - }, - "defusedxml": { - "hashes": [ - "sha256:6687150770438374ab581bb7a1b327a847dd9c5749e396102de3fad4e8a3ef93", - "sha256:f684034d135af4c6cbb949b8a4d2ed61634515257a67299e5f940fbaa34377f5" - ], - "version": "==0.6.0" - }, - "dlib": { - "hashes": [ - "sha256:92587c81b0165e933593f505fdf099dface0d0f8ec874b1d8655fc774598911f" - ], - "index": "pypi", - "version": "==19.17.0" - }, - "docutils": { - "hashes": [ - "sha256:02aec4bd92ab067f6ff27a38a38a41173bf01bed8f89157768c1573f53e474a6", - "sha256:51e64ef2ebfb29cae1faa133b3710143496eca21c530f3f71424d77687764274", - "sha256:7a4bd47eaf6596e1295ecb11361139febe29b084a87bf005bf899f9a42edc3c6" - ], - "version": "==0.14" - }, - "dominate": { - "hashes": [ - "sha256:4076735c0745fe771e57b2313dbb4bfeec42731816ee23cee509f66e8912aa51", - "sha256:4b9fd42d2824b79761799590697db45bf93daad511b130c50513af38da33df9b" - ], - "index": "pypi", - "version": "==2.3.5" - }, - "elasticsearch": { - "hashes": [ - "sha256:cbc73831c63fa2824538df76fcb2c4be007b43dbd9e7788ae70ea6d24109925b", - "sha256:d1b176b87a7fb75dca82978c82a4023e8b21cbc98f4018cb51190fb0b8b43764" - ], - "index": "pypi", - "version": "==7.0.2" - }, - "entium": { - "hashes": [ - "sha256:233f39c6b5477e0c6fffd8d5cb7fc9df9deab80c79c7fb77e91f6d046782b0ce", - "sha256:4b14b4810a97ab041b629a0b59d21a98f5e197ee623d7b14925755ec4fd6888a" - ], - "index": "pypi", - "version": "==0.1.4" - }, - "entrypoints": { - "hashes": [ - "sha256:589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19", - "sha256:c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451" - ], - "version": "==0.3" - }, - "enum34": { - "hashes": [ - "sha256:2d81cbbe0e73112bdfe6ef8576f2238f2ba27dd0d55752a776c41d38b7da2850", - "sha256:644837f692e5f550741432dd3f223bbb9852018674981b1664e5dc339387588a", - "sha256:6bd0f6ad48ec2aa117d3d141940d484deccda84d4fcd884f5c3d93c23ecd8c79", - "sha256:8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1" - ], - "markers": "python_version < '3'", - "version": "==1.1.6" - }, - "fastcluster": { - "hashes": [ - "sha256:0024b1304d4618a32900473b809265694bc6d0a10bfbc272407443318644d405", - "sha256:0b33b076ea98939742e0734e944c903c8c67af3eecd5a9f8b4349407c1affdd3", - "sha256:244d400a81d23b48f2b825e50e99e1ff3c7d2be2acc40942e3359b4deef68483", - "sha256:2bb3bf8e1c7af42e47ef24bc2386a1d3e6ec8dc5e6be4123a491a36b89227b49", - "sha256:539d84d43fbe541a38d94c84bf0469c430cb7cda488364941ce57f680a07b091", - "sha256:5e7d81385bbc2148c554c4aaa32e26a00fbadc1190d5bad9c8719f6432629307", - "sha256:642e4d92220c1deede1e89409c5ad366e4a3f3ed55fff0a4e325d4eb2574d65a", - "sha256:66c868fdfc161e5c45cdf399f1274216602ea82c9fc46c632c9602dbaa149840", - "sha256:6952c9d25b3ea60d6a53ee92205e7f16cc6baf7caa4776fb1e55dc6e8e2965f2", - "sha256:8606da6f6f51f81c3b4e000edeb8668711a1769a6ebf3c99ab98f9c6d2fb7534", - "sha256:8d552d29ed054ce20f5bb0445b51bd7b6b8088fdae334625b4a9950189dcc2bf", - "sha256:922735fde2848a6f0478c6968048a16a5d3d6ba6e1d1a9596d578b59dce719d7", - "sha256:9f3cd227a9ebeec090e4186a63e46cd87d121968bd1d45ea8a7c2d483bc082fb", - "sha256:a382cb411610ca06a69e7b131239f0bb02961fec762d5b6804e653a32cd5ab52", - "sha256:a986b3afe823bcaea3dad9de1485b176c6dd5b0e2f154ede71aaf6635e82e159", - "sha256:b1902ab52418c6f4c2f3f7439aea711c6b5aa9bbb4c97b6d4b0c6f5e5c894342", - "sha256:bb56f6c7343bbb68beb1ffd13abdb87ce7a84ab391b3a4e63ed5c02b2d1ce46f", - "sha256:c2e5d11f5f96e6861fd632246f18bc6592ac439f236caffd4d2a75697a6f8969", - "sha256:c61973bb16117ee16b7642ff9da8e0899fb4d5eb5d0cc9c56d3269551ccd6307", - "sha256:d2deec11a6625c5578325f4dd10980e2981d1f1d1e658c7c79f2497377f92bdf", - "sha256:e0f2feb03f67b12f25538aa05b1150c7a2c1cd1c21ad7d0bde94e8169ef46627", - "sha256:e32e7287c47291eca2c83cd5cc6a5007eff2da00c12ac21fd721a16d0c428059", - "sha256:e889ea36c4e469ff3fb2a6a868c8e557fc988a81cd1cf3d09876107e59ee9cbd", - "sha256:e96f3b65e3748f2be06aa0977a00872ddeca4f8959703126f2b103978243bbdd" - ], - "index": "pypi", - "version": "==1.1.25" - }, - "fasteners": { - "hashes": [ - "sha256:007e4d2b2d4a10093f67e932e5166722d2eab83b77724156e92ad013c6226574", - "sha256:3a176da6b70df9bb88498e1a18a9e4a8579ed5b9141207762368a1017bf8f5ef" - ], - "index": "pypi", - "version": "==0.15" - }, - "flask": { - "hashes": [ - "sha256:13f9f196f330c7c2c5d7a5cf91af894110ca0215ac051b5844701f2bfd934d52", - "sha256:45eb5a6fd193d6cf7e0cf5d8a5b31f83d5faae0293695626f539a823e93b13f6" - ], - "index": "pypi", - "version": "==1.1.1" - }, - "flask-cors": { - "hashes": [ - "sha256:72170423eb4612f0847318afff8c247b38bd516b7737adfc10d1c2cdbb382d16", - "sha256:f4d97201660e6bbcff2d89d082b5b6d31abee04b1b3003ee073a6fd25ad1d69a" - ], - "index": "pypi", - "version": "==3.0.8" - }, - "flask-socketio": { - "hashes": [ - "sha256:aced332903522a52822fb1e21744549510ce8b26e074422d4cd9aff68e43be5b", - "sha256:f6f7e0205f0dd92d98a87e3f6d26d94ade29ca380ba383b505070674c804ae2e" - ], - "index": "pypi", - "version": "==4.1.0" - }, - "funcsigs": { - "hashes": [ - "sha256:330cc27ccbf7f1e992e69fef78261dc7c6569012cf397db8d3de0234e6c937ca", - "sha256:a7bb0f2cf3a3fd1ab2732cb49eba4252c2af4240442415b4abce3b87022a8f50" - ], - "markers": "python_version < '3.3'", - "version": "==1.0.2" - }, - "functools32": { - "hashes": [ - "sha256:89d824aa6c358c421a234d7f9ee0bd75933a67c29588ce50aaa3acdf4d403fa0", - "sha256:f6253dfbe0538ad2e387bd8fdfd9293c925d63553f5813c4e587745416501e6d" - ], - "markers": "python_version < '3'", - "version": "==3.2.3.post2" - }, - "future": { - "hashes": [ - "sha256:67045236dcfd6816dc439556d009594abf643e5eb48992e36beac09c2ca659b8" - ], - "index": "pypi", - "version": "==0.17.1" - }, - "futures": { - "hashes": [ - "sha256:49b3f5b064b6e3afc3316421a3f25f66c137ae88f068abbf72830170033c5e16", - "sha256:7e033af76a5e35f58e56da7a91e687706faf4e7bdfb2cbc3f2cca6b9bcda9794" - ], - "markers": "python_version < '3.2'", - "version": "==3.3.0" - }, - "gast": { - "hashes": [ - "sha256:fe939df4583692f0512161ec1c880e0a10e71e6a232da045ab8edd3756fbadf0" - ], - "version": "==0.2.2" - }, - "geoalchemy2": { - "hashes": [ - "sha256:0d1c9ea3ec13f6a522ccc3ffd2569ac524a6c6e80bab883e8805b28c48e77143", - "sha256:4dc4c6c2bda0fc82cccab4aaff185a6570e13a5351d85e29e12984a55d4138ee" - ], - "index": "pypi", - "version": "==0.6.3" - }, - "gevent": { - "hashes": [ - "sha256:0774babec518a24d9a7231d4e689931f31b332c4517a771e532002614e270a64", - "sha256:0e1e5b73a445fe82d40907322e1e0eec6a6745ca3cea19291c6f9f50117bb7ea", - "sha256:0ff2b70e8e338cf13bedf146b8c29d475e2a544b5d1fe14045aee827c073842c", - "sha256:107f4232db2172f7e8429ed7779c10f2ed16616d75ffbe77e0e0c3fcdeb51a51", - "sha256:14b4d06d19d39a440e72253f77067d27209c67e7611e352f79fe69e0f618f76e", - "sha256:1b7d3a285978b27b469c0ff5fb5a72bcd69f4306dbbf22d7997d83209a8ba917", - "sha256:1eb7fa3b9bd9174dfe9c3b59b7a09b768ecd496debfc4976a9530a3e15c990d1", - "sha256:2711e69788ddb34c059a30186e05c55a6b611cb9e34ac343e69cf3264d42fe1c", - "sha256:28a0c5417b464562ab9842dd1fb0cc1524e60494641d973206ec24d6ec5f6909", - "sha256:3249011d13d0c63bea72d91cec23a9cf18c25f91d1f115121e5c9113d753fa12", - "sha256:44089ed06a962a3a70e96353c981d628b2d4a2f2a75ea5d90f916a62d22af2e8", - "sha256:4bfa291e3c931ff3c99a349d8857605dca029de61d74c6bb82bd46373959c942", - "sha256:50024a1ee2cf04645535c5ebaeaa0a60c5ef32e262da981f4be0546b26791950", - "sha256:53b72385857e04e7faca13c613c07cab411480822ac658d97fd8a4ddbaf715c8", - "sha256:74b7528f901f39c39cdbb50cdf08f1a2351725d9aebaef212a29abfbb06895ee", - "sha256:7d0809e2991c9784eceeadef01c27ee6a33ca09ebba6154317a257353e3af922", - "sha256:896b2b80931d6b13b5d9feba3d4eebc67d5e6ec54f0cf3339d08487d55d93b0e", - "sha256:8d9ec51cc06580f8c21b41fd3f2b3465197ba5b23c00eb7d422b7ae0380510b0", - "sha256:9f7a1e96fec45f70ad364e46de32ccacab4d80de238bd3c2edd036867ccd48ad", - "sha256:ab4dc33ef0e26dc627559786a4fba0c2227f125db85d970abbf85b77506b3f51", - "sha256:d1e6d1f156e999edab069d79d890859806b555ce4e4da5b6418616322f0a3df1", - "sha256:d752bcf1b98174780e2317ada12013d612f05116456133a6acf3e17d43b71f05", - "sha256:e5bcc4270671936349249d26140c267397b7b4b1381f5ec8b13c53c5b53ab6e1" - ], - "index": "pypi", - "version": "==1.4.0" - }, - "git-pylint-commit-hook": { - "hashes": [ - "sha256:e1d39e7856b3ef0a0269121ca210dc3f5a97da158b322411e8e1185918a91b3c" - ], - "index": "pypi", - "version": "==2.5.1" - }, - "greenlet": { - "hashes": [ - "sha256:000546ad01e6389e98626c1367be58efa613fa82a1be98b0c6fc24b563acc6d0", - "sha256:0d48200bc50cbf498716712129eef819b1729339e34c3ae71656964dac907c28", - "sha256:23d12eacffa9d0f290c0fe0c4e81ba6d5f3a5b7ac3c30a5eaf0126bf4deda5c8", - "sha256:37c9ba82bd82eb6a23c2e5acc03055c0e45697253b2393c9a50cef76a3985304", - "sha256:51503524dd6f152ab4ad1fbd168fc6c30b5795e8c70be4410a64940b3abb55c0", - "sha256:8041e2de00e745c0e05a502d6e6db310db7faa7c979b3a5877123548a4c0b214", - "sha256:81fcd96a275209ef117e9ec91f75c731fa18dcfd9ffaa1c0adbdaa3616a86043", - "sha256:853da4f9563d982e4121fed8c92eea1a4594a2299037b3034c3c898cb8e933d6", - "sha256:8b4572c334593d449113f9dc8d19b93b7b271bdbe90ba7509eb178923327b625", - "sha256:9416443e219356e3c31f1f918a91badf2e37acf297e2fa13d24d1cc2380f8fbc", - "sha256:9854f612e1b59ec66804931df5add3b2d5ef0067748ea29dc60f0efdcda9a638", - "sha256:99a26afdb82ea83a265137a398f570402aa1f2b5dfb4ac3300c026931817b163", - "sha256:a19bf883b3384957e4a4a13e6bd1ae3d85ae87f4beb5957e35b0be287f12f4e4", - "sha256:a9f145660588187ff835c55a7d2ddf6abfc570c2651c276d3d4be8a2766db490", - "sha256:ac57fcdcfb0b73bb3203b58a14501abb7e5ff9ea5e2edfa06bb03035f0cff248", - "sha256:bcb530089ff24f6458a81ac3fa699e8c00194208a724b644ecc68422e1111939", - "sha256:beeabe25c3b704f7d56b573f7d2ff88fc99f0138e43480cecdfcaa3b87fe4f87", - "sha256:d634a7ea1fc3380ff96f9e44d8d22f38418c1c381d5fac680b272d7d90883720", - "sha256:d97b0661e1aead761f0ded3b769044bb00ed5d33e1ec865e891a8b128bf7c656" - ], - "markers": "platform_python_implementation == 'CPython'", - "version": "==0.4.15" - }, - "grpcio": { - "hashes": [ - "sha256:03b78b4e7dcdfe3e257bb528cc93923f9cbbab6d5babf15a60d21e9a4a70b1a2", - "sha256:1ce0ccfbdfe84387dbcbf44adb4ae16ec7ae70e166ffab478993eb1ea1cba3ce", - "sha256:22e167a9406d73dd19ffe8ed6a485f17e6eac82505be8c108897f15e68badcbb", - "sha256:31d0aeca8d8ee2301c62c5c340e0889d653b1280d68f9fa203982cb6337b050e", - "sha256:44c7f99ca17ebbcc96fc54ed00b454d8313f1eac28c563098d8b901025aff941", - "sha256:5471444f53f9db6a1f1f11f5dbc173228881df8446380b6b98f90afb8fd8348e", - "sha256:561bca3b1bde6d6564306eb05848fd155136e9c3a25d2961129b1e2edba22fce", - "sha256:5bf58e1d2c2f55365c06e8cb5abe067b88ca2e5550fb62009c41df4b54505acf", - "sha256:6b7163d1e85d76b0815df63fcc310daec02b44532bb433f743142d4febcb181f", - "sha256:766d79cddad95f5f6020037fe60ea8b98578afdf0c59d5a60c106c1bdd886303", - "sha256:770b7372d5ca68308ff66d7baee53369fa5ce985f84bcb6aa1948c1f2f7b02f2", - "sha256:7ab178da777fc0f55b6aef5a755f99726e8e4b75e3903954df07b27059b54fcf", - "sha256:8078305e77c2f6649d36b24d8778096413e474d9d7892c6f92cfb589c9d71b2e", - "sha256:85600b63a386d860eeaa955e9335e18dd0d7e5477e9214825abf2c2884488369", - "sha256:857d9b939ae128be1c0c792eb885c7ff6a386b9dea899ac4b06f4d90a31f9d87", - "sha256:87a41630c90c179fa5c593400f30a467c498972c702f348d41e19dafeb1d319e", - "sha256:8805d486c6128cc0fcc8ecf16c4095d99a8693a541ef851429ab334e028a4a97", - "sha256:8d71b7a89c306a41ccc7741fc9409b14f5b86727455c2a1c0c7cfcb0f784e1f2", - "sha256:9e1b80bd65f8f160880cb4dad7f55697f6d37b2d7f251fc0c2128e811928f369", - "sha256:9e290c84a145ae2411ee0ec9913c41cd7500e2e7485fe93632434d84ef4fda67", - "sha256:9ec9f88b5bc94bd99372f27cdd53af1c92ba06717380b127733b953cfb181174", - "sha256:a0a02a8b4ba6deadf706d5f849539b3685b72b186a3c9ef5d43e8972ed60fb6f", - "sha256:a4059c59519f5940e01a071f74ae2a60ea8f6185b03d22a09d40c7959a36b16b", - "sha256:a6e028c2a6da2ebfa2365a5b32531d311fbfec0e3600fc27e901b64f0ff7e54e", - "sha256:adcdebf9f8463df4120c427cf6c9aed39258bccd03ed37b6939e7a145d64d6e0", - "sha256:bdec982610259d07156a58f80b8c3e69be7751a9208bc577b059c5193d087fad", - "sha256:cefc4d4251ffb73feb303d4b7e9d6c367cb60f2db16d259ea28b114045f965aa", - "sha256:d4145c8aa6afbac10ad27e408f7ce15992fe89ba5d0b4abca31c0c2729864c03", - "sha256:da76dc5ad719ee99de5ea28a5629ff92172cbb4a70d8a6ae3a5b7a53c7382ce1", - "sha256:dde2452c08ef8b6426ccab6b5b6de9f06d836d9937d6870e68153cbf8cb49348", - "sha256:e3d88091d2539a4868750914a6fe7b9ec50e42b913851fc1b77423b5bd918530", - "sha256:f9c67cfe6278499d7f83559dc6322a8bbb108e307817a3d7acbfea807b3603cc" - ], - "version": "==1.22.0" - }, - "gunicorn": { - "hashes": [ - "sha256:aa8e0b40b4157b36a5df5e599f45c9c76d6af43845ba3b3b0efe2c70473c2471", - "sha256:fa2662097c66f920f53f70621c6c58ca4a3c4d3434205e608e121b5b3b71f4f3" - ], - "index": "pypi", - "version": "==19.9.0" - }, - "h5py": { - "hashes": [ - "sha256:05750b91640273c69989c657eaac34b091abdd75efc8c4824c82aaf898a2da0a", - "sha256:082a27208aa3a2286e7272e998e7e225b2a7d4b7821bd840aebf96d50977abbb", - "sha256:08e2e8297195f9e813e894b6c63f79372582787795bba2014a2db6a2de95f713", - "sha256:0dd2adeb2e9de5081eb8dcec88874e7fd35dae9a21557be3a55a3c7d491842a4", - "sha256:0f94de7a10562b991967a66bbe6dda9808e18088676834c0a4dcec3fdd3bcc6f", - "sha256:106e42e2e01e486a3d32eeb9ba0e3a7f65c12fa8998d63625fa41fb8bdc44cdb", - "sha256:1606c66015f04719c41a9863c156fc0e6b992150de21c067444bcb82e7d75579", - "sha256:1854c4beff9961e477e133143c5e5e355dac0b3ebf19c52cf7cc1b1ef757703c", - "sha256:1e9fb6f1746500ea91a00193ce2361803c70c6b13f10aae9a33ad7b5bd28e800", - "sha256:2cca17e80ddb151894333377675db90cd0279fa454776e0a4f74308376afd050", - "sha256:30e365e8408759db3778c361f1e4e0fe8e98a875185ae46c795a85e9bafb9cdf", - "sha256:3206bac900e16eda81687d787086f4ffd4f3854980d798e191a9868a6510c3ae", - "sha256:3c23d72058647cee19b30452acc7895621e2de0a0bd5b8a1e34204b9ea9ed43c", - "sha256:407b5f911a83daa285bbf1ef78a9909ee5957f257d3524b8606be37e8643c5f0", - "sha256:4162953714a9212d373ac953c10e3329f1e830d3c7473f2a2e4f25dd6241eef0", - "sha256:5fc7aba72a51b2c80605eba1c50dbf84224dcd206279d30a75c154e5652e1fe4", - "sha256:713ac19307e11de4d9833af0c4bd6778bde0a3d967cafd2f0f347223711c1e31", - "sha256:71b946d80ef3c3f12db157d7778b1fe74a517ca85e94809358b15580983c2ce2", - "sha256:8cc4aed71e20d87e0a6f02094d718a95252f11f8ed143bc112d22167f08d4040", - "sha256:9d41ca62daf36d6b6515ab8765e4c8c4388ee18e2a665701fef2b41563821002", - "sha256:a744e13b000f234cd5a5b2a1f95816b819027c57f385da54ad2b7da1adace2f3", - "sha256:b087ee01396c4b34e9dc41e3a6a0442158206d383c19c7d0396d52067b17c1cb", - "sha256:b0f03af381d33306ce67d18275b61acb4ca111ced645381387a02c8a5ee1b796", - "sha256:b9e4b8dfd587365bdd719ae178fa1b6c1231f81280b1375eef8626dfd8761bf3", - "sha256:c5dd4ec75985b99166c045909e10f0534704d102848b1d9f0992720e908928e7", - "sha256:d2b82f23cd862a9d05108fe99967e9edfa95c136f532a71cb3d28dc252771f50", - "sha256:e58a25764472af07b7e1c4b10b0179c8ea726446c7141076286e41891bf3a563", - "sha256:f3b49107fbfc77333fc2b1ef4d5de2abcd57e7ea3a1482455229494cf2da56ce" - ], - "index": "pypi", - "version": "==2.9.0" - }, - "hexdump": { - "hashes": [ - "sha256:d781a43b0c16ace3f9366aade73e8ad3a7bd5137d58f0b45ab2d3f54876f20db" - ], - "index": "pypi", - "version": "==3.3" - }, - "html5lib": { - "hashes": [ - "sha256:2612a191a8d5842bfa057e41ba50bbb9dcb722419d2408c78cff4758d0754868" - ], - "index": "pypi", - "version": "==0.9999999" - }, - "humanfriendly": { - "hashes": [ - "sha256:23057b10ad6f782e7bc3a20e3cb6768ab919f619bbdc0dd75691121bbde5591d", - "sha256:33ee8ceb63f1db61cce8b5c800c531e1a61023ac5488ccde2ba574a85be00a85" - ], - "version": "==4.18" - }, - "idna": { - "hashes": [ - "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", - "sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c" - ], - "index": "pypi", - "version": "==2.8" - }, - "imageio": { - "hashes": [ - "sha256:1a2bbbb7cd38161340fa3b14d806dfbf914abf3ee6fd4592af2afb87d049f209", - "sha256:42e65aadfc3d57a1043615c92bdf6319b67589e49a0aae2b985b82144aceacad" - ], - "index": "pypi", - "version": "==2.5.0" - }, - "intervaltree": { - "hashes": [ - "sha256:cb4f61c81dcb4fea6c09903f3599015a83c9bdad1f0bbd232495e6681e19e273" - ], - "index": "pypi", - "version": "==3.0.2" - }, - "ipaddress": { - "hashes": [ - "sha256:64b28eec5e78e7510698f6d4da08800a5c575caa4a286c93d651c5d3ff7b6794", - "sha256:b146c751ea45cad6188dd6cf2d9b757f6f4f8d6ffb96a023e6f2e26eea02a72c" - ], - "markers": "python_version < '3'", - "version": "==1.0.22" - }, - "ipykernel": { - "hashes": [ - "sha256:56d82987472f4b14ab0214e4aef55def006671885d285cd8821f2600861215a6", - "sha256:59b0855082d021f533cff477e1bb619e663b6aab11309a05bf88eaec9f53faed", - "sha256:699103c8e64886e3ec7053f2a6aa83bb90426063526f63a818732ff385202bad" - ], - "index": "pypi", - "version": "==4.10.0" - }, - "ipython": { - "hashes": [ - "sha256:0371b7e4bd74954a35086eac949beeac5b1c9f5ce231e2e77df2286a293765e3", - "sha256:37101b8cbe072fe17bff100bc03d096404e4a9a0357097aeb5b61677c042cab1", - "sha256:4bac649857611baaaf76bc82c173aa542f7486446c335fe1a6c05d0d491c8906" - ], - "index": "pypi", - "version": "==5.8.0" - }, - "ipython-genutils": { - "hashes": [ - "sha256:72dd37233799e619666c9f639a9da83c34013a73e8bbc79a7a6348d93c61fab8", - "sha256:eb2e116e75ecef9d4d228fdc66af54269afa26ab4463042e33785b887c628ba8" - ], - "version": "==0.2.0" - }, - "ipywidgets": { - "hashes": [ - "sha256:cb263c6974aca902d00a435711823bb4aaf6614a5f997f517e15fa84151e8fa2", - "sha256:eab6060f20f7f10d91f6efc8d33f9fd22133406980fcaee2738d836a910402f4" - ], - "version": "==7.5.0" - }, - "isodate": { - "hashes": [ - "sha256:2e364a3d5759479cdb2d37cce6b9376ea504db2ff90252a2e5b7cc89cc9ff2d8", - "sha256:aa4d33c06640f5352aca96e4b81afd8ab3b47337cc12089822d6f322ac772c81" - ], - "version": "==0.6.0" - }, - "isort": { - "hashes": [ - "sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1", - "sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd" - ], - "version": "==4.3.21" - }, - "itsdangerous": { - "hashes": [ - "sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19", - "sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749" - ], - "version": "==1.1.0" - }, - "jinja2": { - "hashes": [ - "sha256:065c4f02ebe7f7cf559e49ee5a95fb800a9e4528727aec6f24402a5374c65013", - "sha256:14dd6caf1527abb21f08f86c784eac40853ba93edb79552aa1e4b8aef1b61c7b" - ], - "index": "pypi", - "version": "==2.10.1" - }, - "jmespath": { - "hashes": [ - "sha256:3720a4b1bd659dd2eecad0666459b9788813e032b83e7ba58578e48254e0a0e6", - "sha256:bde2aef6f44302dfb30320115b17d030798de8c4110e28d5cf6cf91a7a31074c" - ], - "version": "==0.9.4" - }, - "joblib": { - "hashes": [ - "sha256:21e0c34a69ad7fde4f2b1f3402290e9ec46f545f15f1541c582edfe05d87b63a", - "sha256:315d6b19643ec4afd4c41c671f9f2d65ea9d787da093487a81ead7b0bac94524" - ], - "index": "pypi", - "version": "==0.13.2" - }, - "json-logging-py": { - "hashes": [ - "sha256:118b1fe1f4eacaea6370e5b9710d0f6d0c0a4599aef9d5b9875a6a579974fc9a" - ], - "index": "pypi", - "version": "==0.2" - }, - "jsonschema": { - "hashes": [ - "sha256:0c0a81564f181de3212efa2d17de1910f8732fa1b71c42266d983cd74304e20d", - "sha256:a5f6559964a3851f59040d3b961de5e68e70971afb88ba519d27e6a039efff1a" - ], - "version": "==3.0.1" - }, - "jupyter": { - "hashes": [ - "sha256:3e1f86076bbb7c8c207829390305a2b1fe836d471ed54be66a3b8c41e7f46cc7", - "sha256:5b290f93b98ffbc21c0c7e749f054b3267782166d72fa5e3ed1ed4eaf34a2b78", - "sha256:d9dc4b3318f310e34c82951ea5d6683f67bed7def4b259fafbfe4f1beb1d8e5f" - ], - "index": "pypi", - "version": "==1.0.0" - }, - "jupyter-client": { - "hashes": [ - "sha256:73a809a2964afa07adcc1521537fddb58c2ffbb7e84d53dc5901cf80480465b3", - "sha256:98e8af5edff5d24e4d31e73bc21043130ae9d955a91aa93fc0bc3b1d0f7b5880" - ], - "version": "==5.3.1" - }, - "jupyter-console": { - "hashes": [ - "sha256:3f928b817fc82cda95e431eb4c2b5eb21be5c483c2b43f424761a966bb808094", - "sha256:545dedd3aaaa355148093c5609f0229aeb121b4852995c2accfa64fe3e0e55cd" - ], - "version": "==5.2.0" - }, - "jupyter-core": { - "hashes": [ - "sha256:2c6e7c1e9f2ac45b5c2ceea5730bc9008d92fe59d0725eac57b04c0edfba24f7", - "sha256:f4fa22d6cf25f34807c995f22d2923693575c70f02557bcbfbe59bd5ec8d8b84" - ], - "version": "==4.5.0" - }, - "keras": { - "hashes": [ - "sha256:794d0c92c6c4122f1f0fcf3a7bc2f49054c6a54ddbef8d8ffafca62795d760b6", - "sha256:90b610a3dbbf6d257b20a079eba3fdf2eed2158f64066a7c6f7227023fd60bc9" - ], - "index": "pypi", - "version": "==2.2.4" - }, - "keras-applications": { - "hashes": [ - "sha256:5579f9a12bcde9748f4a12233925a59b93b73ae6947409ff34aa2ba258189fe5", - "sha256:df4323692b8c1174af821bf906f1e442e63fa7589bf0f1230a0b6bdc5a810c95" - ], - "version": "==1.0.8" - }, - "keras-maskrcnn": { - "hashes": [ - "sha256:9e2258390d749986fe6dc05aabdd7198ae689e60696b6a5568929379457a2e98" - ], - "index": "pypi", - "version": "==0.2.2" - }, - "keras-preprocessing": { - "hashes": [ - "sha256:44aee5f2c4d80c3b29f208359fcb336df80f293a0bb6b1c738da43ca206656fb", - "sha256:5a8debe01d840de93d49e05ccf1c9b81ae30e210d34dacbcc47aeb3049b528e5" - ], - "version": "==1.1.0" - }, - "keras-resnet": { - "hashes": [ - "sha256:8ce27ba782d1b45b127af51208aefdceb2de8d2c54646bac5fc786506ce558c0" - ], - "version": "==0.2.0" - }, - "keras-retinanet": { - "hashes": [ - "sha256:6d4da9d83a9a82cb025298a88256546bc625e9c78cd4f1bbec576d11295910b6" - ], - "index": "pypi", - "version": "==0.5.1" - }, - "kiwisolver": { - "hashes": [ - "sha256:05b5b061e09f60f56244adc885c4a7867da25ca387376b02c1efc29cc16bcd0f", - "sha256:26f4fbd6f5e1dabff70a9ba0d2c4bd30761086454aa30dddc5b52764ee4852b7", - "sha256:3b2378ad387f49cbb328205bda569b9f87288d6bc1bf4cd683c34523a2341efe", - "sha256:400599c0fe58d21522cae0e8b22318e09d9729451b17ee61ba8e1e7c0346565c", - "sha256:47b8cb81a7d18dbaf4fed6a61c3cecdb5adec7b4ac292bddb0d016d57e8507d5", - "sha256:53eaed412477c836e1b9522c19858a8557d6e595077830146182225613b11a75", - "sha256:58e626e1f7dfbb620d08d457325a4cdac65d1809680009f46bf41eaf74ad0187", - "sha256:5a52e1b006bfa5be04fe4debbcdd2688432a9af4b207a3f429c74ad625022641", - "sha256:5c7ca4e449ac9f99b3b9d4693debb1d6d237d1542dd6a56b3305fe8a9620f883", - "sha256:682e54f0ce8f45981878756d7203fd01e188cc6c8b2c5e2cf03675390b4534d5", - "sha256:79bfb2f0bd7cbf9ea256612c9523367e5ec51d7cd616ae20ca2c90f575d839a2", - "sha256:7f4dd50874177d2bb060d74769210f3bce1af87a8c7cf5b37d032ebf94f0aca3", - "sha256:8944a16020c07b682df861207b7e0efcd2f46c7488619cb55f65882279119389", - "sha256:8aa7009437640beb2768bfd06da049bad0df85f47ff18426261acecd1cf00897", - "sha256:939f36f21a8c571686eb491acfffa9c7f1ac345087281b412d63ea39ca14ec4a", - "sha256:9733b7f64bd9f807832d673355f79703f81f0b3e52bfce420fc00d8cb28c6a6c", - "sha256:a02f6c3e229d0b7220bd74600e9351e18bc0c361b05f29adae0d10599ae0e326", - "sha256:a0c0a9f06872330d0dd31b45607197caab3c22777600e88031bfe66799e70bb0", - "sha256:acc4df99308111585121db217681f1ce0eecb48d3a828a2f9bbf9773f4937e9e", - "sha256:b64916959e4ae0ac78af7c3e8cef4becee0c0e9694ad477b4c6b3a536de6a544", - "sha256:d3fcf0819dc3fea58be1fd1ca390851bdb719a549850e708ed858503ff25d995", - "sha256:d52e3b1868a4e8fd18b5cb15055c76820df514e26aa84cc02f593d99fef6707f", - "sha256:db1a5d3cc4ae943d674718d6c47d2d82488ddd94b93b9e12d24aabdbfe48caee", - "sha256:e3a21a720791712ed721c7b95d433e036134de6f18c77dbe96119eaf7aa08004", - "sha256:e8bf074363ce2babeb4764d94f8e65efd22e6a7c74860a4f05a6947afc020ff2", - "sha256:f16814a4a96dc04bf1da7d53ee8d5b1d6decfc1a92a63349bb15d37b6a263dd9", - "sha256:f2b22153870ca5cf2ab9c940d7bc38e8e9089fa0f7e5856ea195e1cf4ff43d5a", - "sha256:f790f8b3dff3d53453de6a7b7ddd173d2e020fb160baff578d578065b108a05f" - ], - "version": "==1.1.0" - }, - "kombu": { - "hashes": [ - "sha256:55b71d3785def3470a16217fe0780f9e6f95e61bf9ad39ef8dce0177224eab77", - "sha256:eb365ea795cd7e629ba2f1f398e0c3ba354b91ef4de225ffdf6ab45fdfc7d581" - ], - "version": "==4.6.3" - }, - "lazy-object-proxy": { - "hashes": [ - "sha256:159a745e61422217881c4de71f9eafd9d703b93af95618635849fe469a283661", - "sha256:23f63c0821cc96a23332e45dfaa83266feff8adc72b9bcaef86c202af765244f", - "sha256:3b11be575475db2e8a6e11215f5aa95b9ec14de658628776e10d96fa0b4dac13", - "sha256:3f447aff8bc61ca8b42b73304f6a44fa0d915487de144652816f950a3f1ab821", - "sha256:4ba73f6089cd9b9478bc0a4fa807b47dbdb8fad1d8f31a0f0a5dbf26a4527a71", - "sha256:4f53eadd9932055eac465bd3ca1bd610e4d7141e1278012bd1f28646aebc1d0e", - "sha256:64483bd7154580158ea90de5b8e5e6fc29a16a9b4db24f10193f0c1ae3f9d1ea", - "sha256:6f72d42b0d04bfee2397aa1862262654b56922c20a9bb66bb76b6f0e5e4f9229", - "sha256:7c7f1ec07b227bdc561299fa2328e85000f90179a2f44ea30579d38e037cb3d4", - "sha256:7c8b1ba1e15c10b13cad4171cfa77f5bb5ec2580abc5a353907780805ebe158e", - "sha256:8559b94b823f85342e10d3d9ca4ba5478168e1ac5658a8a2f18c991ba9c52c20", - "sha256:a262c7dfb046f00e12a2bdd1bafaed2408114a89ac414b0af8755c696eb3fc16", - "sha256:acce4e3267610c4fdb6632b3886fe3f2f7dd641158a843cf6b6a68e4ce81477b", - "sha256:be089bb6b83fac7f29d357b2dc4cf2b8eb8d98fe9d9ff89f9ea6012970a853c7", - "sha256:bfab710d859c779f273cc48fb86af38d6e9210f38287df0069a63e40b45a2f5c", - "sha256:c10d29019927301d524a22ced72706380de7cfc50f767217485a912b4c8bd82a", - "sha256:dd6e2b598849b3d7aee2295ac765a578879830fb8966f70be8cd472e6069932e", - "sha256:e408f1eacc0a68fed0c08da45f31d0ebb38079f043328dce69ff133b95c29dc1" - ], - "version": "==1.4.1" - }, - "libarchive": { - "hashes": [ - "sha256:829dc298a08877f62335d528973bc034f7c1e8a03c16bfc1fa561e164e76a365" - ], - "index": "pypi", - "version": "==0.4.7" - }, - "limits": { - "hashes": [ - "sha256:9df578f4161017d79f5188609f1d65f6b639f8aad2914c3960c9252e56a0ff95", - "sha256:a017b8d9e9da6761f4574642149c337f8f540d4edfe573fb91ad2c4001a2bc76" - ], - "version": "==1.3" - }, - "lru-dict": { - "hashes": [ - "sha256:365457660e3d05b76f1aba3e0f7fedbfcd6528e97c5115a351ddd0db488354cc" - ], - "index": "pypi", - "version": "==1.1.6" - }, - "lxml": { - "hashes": [ - "sha256:06c7616601430aa140a69f97e3116308fffe0848f543b639a5ec2e8920ae72fd", - "sha256:177202792f9842374a8077735c69c41a4282183f7851443d2beb8ee310720819", - "sha256:19317ad721ceb9e39847d11131903931e2794e447d4751ebb0d9236f1b349ff2", - "sha256:36d206e62f3e5dbaafd4ec692b67157e271f5da7fd925fda8515da675eace50d", - "sha256:387115b066c797c85f9861a9613abf50046a15aac16759bc92d04f94acfad082", - "sha256:3ce1c49d4b4a7bc75fb12acb3a6247bb7a91fe420542e6d671ba9187d12a12c2", - "sha256:4d2a5a7d6b0dbb8c37dab66a8ce09a8761409c044017721c21718659fa3365a1", - "sha256:58d0a1b33364d1253a88d18df6c0b2676a1746d27c969dc9e32d143a3701dda5", - "sha256:62a651c618b846b88fdcae0533ec23f185bb322d6c1845733f3123e8980c1d1b", - "sha256:69ff21064e7debc9b1b1e2eee8c2d686d042d4257186d70b338206a80c5bc5ea", - "sha256:7060453eba9ba59d821625c6af6a266bd68277dce6577f754d1eb9116c094266", - "sha256:7d26b36a9c4bce53b9cfe42e67849ae3c5c23558bc08363e53ffd6d94f4ff4d2", - "sha256:83b427ad2bfa0b9705e02a83d8d607d2c2f01889eb138168e462a3a052c42368", - "sha256:923d03c84534078386cf50193057aae98fa94cace8ea7580b74754493fda73ad", - "sha256:b773715609649a1a180025213f67ffdeb5a4878c784293ada300ee95a1f3257b", - "sha256:baff149c174e9108d4a2fee192c496711be85534eab63adb122f93e70aa35431", - "sha256:bca9d118b1014b4c2d19319b10a3ebed508ff649396ce1855e1c96528d9b2fa9", - "sha256:ce580c28845581535dc6000fc7c35fdadf8bea7ccb57d6321b044508e9ba0685", - "sha256:d34923a569e70224d88e6682490e24c842907ba2c948c5fd26185413cbe0cd96", - "sha256:dd9f0e531a049d8b35ec5e6c68a37f1ba6ec3a591415e6804cbdf652793d15d7", - "sha256:ecb805cbfe9102f3fd3d2ef16dfe5ae9e2d7a7dfbba92f4ff1e16ac9784dbfb0", - "sha256:ede9aad2197a0202caff35d417b671f5f91a3631477441076082a17c94edd846", - "sha256:ef2d1fc370400e0aa755aab0b20cf4f1d0e934e7fd5244f3dd4869078e4942b9", - "sha256:f2fec194a49bfaef42a548ee657362af5c7a640da757f6f452a35da7dd9f923c" - ], - "index": "pypi", - "version": "==4.3.4" - }, - "markdown": { - "hashes": [ - "sha256:2e50876bcdd74517e7b71f3e7a76102050edec255b3983403f1a63e7c8a41e7a", - "sha256:56a46ac655704b91e5b7e6326ce43d5ef72411376588afa1dd90e881b83c7e8c" - ], - "version": "==3.1.1" - }, - "markupsafe": { - "hashes": [ - "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473", - "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161", - "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235", - "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5", - "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff", - "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b", - "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1", - "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e", - "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183", - "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66", - "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1", - "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1", - "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e", - "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b", - "sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905", - "sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735", - "sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d", - "sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e", - "sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d", - "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c", - "sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21", - "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2", - "sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5", - "sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b", - "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6", - "sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f", - "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f", - "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7" - ], - "version": "==1.1.1" - }, - "matplotlib": { - "hashes": [ - "sha256:0ba8e3ec1b0feddc6b068fe70dc38dcf2917e301ad8d2b3f848c14ad463a4157", - "sha256:10a48e33e64dbd95f0776ba162f379c5cc55301c2d155506e79ce0c26b52f2ce", - "sha256:1376535fe731adbba55ab9e48896de226b7e89dbb55390c5fbd8f7161b7ae3be", - "sha256:16f0f8ba22df1e2c9f06c87088de45742322fde282a93b5c744c0f969cf7932e", - "sha256:1c6c999f2212858021329537f8e0f98f3f29086ec3683511dd1ecec84409f51d", - "sha256:2316dc177fc7b3d8848b49365498de0c385b4c9bba511edddd24c34fbe3d37a4", - "sha256:3398bfb533482bf21974cecf28224dd23784ad4e4848be582903f7a2436ec12e", - "sha256:3477cb1e1061b34210acc43d20050be8444478ff50b8adfac5fe2b45fc97df01", - "sha256:3cc06333b8264428d02231804e2e726b902e9161dc16f573183dee6cb7ef621f", - "sha256:4259ea7cb2c238355ee13275eddd261d869cefbdeb18a65f35459589d6d17def", - "sha256:4addcf93234b6122f530f90f485fd3d00d158911fbc1ed24db3fa66cd49fe565", - "sha256:50c0e24bcbce9c54346f4a2f4e97b0ed111f0413ac3fe9954061ae1c8aa7021f", - "sha256:62ed7597d9e54db6e133420d779c642503c25eba390e1178d85dfb2ba0d05948", - "sha256:69f6d51e41a17f6a5f70c56bb10b8ded9f299609204495a7fa2782a3a755ffc5", - "sha256:6d232e49b74e3d2db22c63c25a9a0166d965e87e2b057f795487f1f244b61d9d", - "sha256:7355bf757ecacd5f0ac9dd9523c8e1a1103faadf8d33c22664178e17533f8ce5", - "sha256:886b1045c5105631f10c1cbc999f910e44d33af3e9c7efd68c2123efc06ab636", - "sha256:9e1f353edd7fc7e5e9101abd5bc0201946f77a1b59e0da49095086c03db856ed", - "sha256:b3a343dfcbe296dbe0f26c731beee72a792ff948407e6979524298ae7bc3234e", - "sha256:d93675af09ca497a25f4f8d62f3313cf0f21e45427a87487049fe84898b99909", - "sha256:e2409ef9d37804dfb566f39c962e6ed70f281ff516b8131b3e6b4e6442711ff1", - "sha256:f8b653b0f89938ba72e92ab080c2f3aa24c1b72e2f61add22880cd1b9a6e3cdd" - ], - "index": "pypi", - "version": "==2.2.3" - }, - "mccabe": { - "hashes": [ - "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", - "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" - ], - "version": "==0.6.1" - }, - "meld3": { - "hashes": [ - "sha256:b28a9bfac342aadb4557aa144bea9f8e6208bfb0596190570d10a892d35ff7dc", - "sha256:f7b754a0fde7a4429b2ebe49409db240b5699385a572501bb0d5627d299f9558" - ], - "version": "==1.0.2" - }, - "mistune": { - "hashes": [ - "sha256:59a3429db53c50b5c6bcc8a07f8848cb00d7dc8bdb431a4ab41920d201d4756e", - "sha256:88a1051873018da288eee8538d476dffe1262495144b33ecb586c4ab266bb8d4" - ], - "version": "==0.8.4" - }, - "mock": { - "hashes": [ - "sha256:83657d894c90d5681d62155c82bda9c1187827525880eda8ff5df4ec813437c3", - "sha256:d157e52d4e5b938c550f39eb2fd15610db062441a9c2747d3dbfa9298211d0f8" - ], - "version": "==3.0.5" - }, - "monotonic": { - "hashes": [ - "sha256:23953d55076df038541e648a53676fb24980f7a1be290cdda21300b3bc21dfb0", - "sha256:552a91f381532e33cbd07c6a2655a21908088962bb8fa7239ecbcc6ad1140cc7" - ], - "markers": "python_version == '2.6' or python_version == '2.7' or python_version == '3.0' or python_version == '3.1' or python_version == '3.2'", - "version": "==1.5" - }, - "mpld3": { - "hashes": [ - "sha256:4d455884a211bf99b37ecc760759435c7bb6a5955de47d8daf4967e301878ab7" - ], - "index": "pypi", - "version": "==0.3" - }, - "msgpack-python": { - "hashes": [ - "sha256:378cc8a6d3545b532dfd149da715abae4fda2a3adb6d74e525d0d5e51f46909b" - ], - "index": "pypi", - "version": "==0.5.6" - }, - "msrest": { - "hashes": [ - "sha256:2c0909570913785a4408a17286e151f3b28d39277113e5c63378572f7395c660", - "sha256:c9e9cbb0c47745f9f5c82cce60849d7c3ec9e33fc6fad9e2987b7657ad1ba479" - ], - "version": "==0.6.8" - }, - "msrestazure": { - "hashes": [ - "sha256:070220fa9c86b55026360435b655d1d67ff4306fd1412687c400dc549e9647b7", - "sha256:e9d525b11d88f1073744e128ae19a4e023e4085893cfcfd02483fdd4cee25091" - ], - "version": "==0.6.1" - }, - "nbconvert": { - "hashes": [ - "sha256:138381baa41d83584459b5cfecfc38c800ccf1f37d9ddd0bd440783346a4c39c", - "sha256:4a978548d8383f6b2cfca4a3b0543afb77bc7cb5a96e8b424337ab58c12da9bc" - ], - "version": "==5.5.0" - }, - "nbformat": { - "hashes": [ - "sha256:b9a0dbdbd45bb034f4f8893cafd6f652ea08c8c1674ba83f2dc55d3955743b0b", - "sha256:f7494ef0df60766b7cabe0a3651556345a963b74dbc16bc7c18479041170d402" - ], - "version": "==4.4.0" - }, - "nbstripout": { - "hashes": [ - "sha256:1960caf7d1c1e281126c6c5cb98053db89eca8aaa616b58eed381e3e1508c0f4", - "sha256:d35c553f724d3fb7ec9e9602c6e55a75101064a6bbec4f8c28e8c84d6e3dd060" - ], - "index": "pypi", - "version": "==0.3.6" - }, - "networkx": { - "hashes": [ - "sha256:45e56f7ab6fe81652fb4bc9f44faddb0e9025f469f602df14e3b2551c2ea5c8b" - ], - "version": "==2.2" - }, - "nose": { - "hashes": [ - "sha256:9ff7c6cc443f8c51994b34a667bbcf45afd6d945be7477b52e97516fd17c53ac", - "sha256:dadcddc0aefbf99eea214e0f1232b94f2fa9bd98fa8353711dacb112bfcbbb2a", - "sha256:f1bffef9cbc82628f6e7d7b40d7e255aefaa1adb6a1b1d26c69a8b79e6208a98" - ], - "index": "pypi", - "version": "==1.3.7" - }, - "nose-parameterized": { - "hashes": [ - "sha256:8f519b9739ac67e3d95f69c15cc80416eea4d63559530d01a37b9565eb629277", - "sha256:d35e677aba2f15135b6b7ea7feb88f792b899492ba5365ec0e269015df5214ce" - ], - "index": "pypi", - "version": "==0.6.0" - }, - "notebook": { - "hashes": [ - "sha256:573e0ae650c5d76b18b6e564ba6d21bf321d00847de1d215b418acb64f056eb8", - "sha256:f64fa6624d2323fbef6210a621817d6505a45d0d4a9367f1843b20a38a4666ee" - ], - "version": "==5.7.8" - }, - "numpy": { - "hashes": [ - "sha256:0778076e764e146d3078b17c24c4d89e0ecd4ac5401beff8e1c87879043a0633", - "sha256:141c7102f20abe6cf0d54c4ced8d565b86df4d3077ba2343b61a6db996cefec7", - "sha256:14270a1ee8917d11e7753fb54fc7ffd1934f4d529235beec0b275e2ccf00333b", - "sha256:27e11c7a8ec9d5838bc59f809bfa86efc8a4fd02e58960fa9c49d998e14332d5", - "sha256:2a04dda79606f3d2f760384c38ccd3d5b9bb79d4c8126b67aff5eb09a253763e", - "sha256:3c26010c1b51e1224a3ca6b8df807de6e95128b0908c7e34f190e7775455b0ca", - "sha256:52c40f1a4262c896420c6ea1c6fda62cf67070e3947e3307f5562bd783a90336", - "sha256:6e4f8d9e8aa79321657079b9ac03f3cf3fd067bf31c1cca4f56d49543f4356a5", - "sha256:7242be12a58fec245ee9734e625964b97cf7e3f2f7d016603f9e56660ce479c7", - "sha256:7dc253b542bfd4b4eb88d9dbae4ca079e7bf2e2afd819ee18891a43db66c60c7", - "sha256:94f5bd885f67bbb25c82d80184abbf7ce4f6c3c3a41fbaa4182f034bba803e69", - "sha256:a89e188daa119ffa0d03ce5123dee3f8ffd5115c896c2a9d4f0dbb3d8b95bfa3", - "sha256:ad3399da9b0ca36e2f24de72f67ab2854a62e623274607e37e0ce5f5d5fa9166", - "sha256:b0348be89275fd1d4c44ffa39530c41a21062f52299b1e3ee7d1c61f060044b8", - "sha256:b5554368e4ede1856121b0dfa35ce71768102e4aa55e526cb8de7f374ff78722", - "sha256:cbddc56b2502d3f87fda4f98d948eb5b11f36ff3902e17cb6cc44727f2200525", - "sha256:d79f18f41751725c56eceab2a886f021d70fd70a6188fd386e29a045945ffc10", - "sha256:dc2ca26a19ab32dc475dbad9dfe723d3a64c835f4c23f625c2b6566ca32b9f29", - "sha256:dd9bcd4f294eb0633bb33d1a74febdd2b9018b8b8ed325f861fffcd2c7660bb8", - "sha256:e8baab1bc7c9152715844f1faca6744f2416929de10d7639ed49555a85549f52", - "sha256:ec31fe12668af687b99acf1567399632a7c47b0e17cfb9ae47c098644ef36797", - "sha256:f12b4f7e2d8f9da3141564e6737d79016fe5336cc92de6814eba579744f65b0a", - "sha256:f58ac38d5ca045a377b3b377c84df8175ab992c970a53332fa8ac2373df44ff7" - ], - "index": "pypi", - "version": "==1.16.4" - }, - "oauthlib": { - "hashes": [ - "sha256:40a63637707e9163eda62d0f5345120c65e001a790480b8256448543c1f78f66", - "sha256:b4d99ae8ccfb7d33ba9591b59355c64eef5241534aa3da2e4c0435346b84bc8e" - ], - "version": "==3.0.2" - }, - "opencv-python": { - "hashes": [ - "sha256:1703a296a96d3d46615e5053f224867977accb4240bcaa0fcabcb0768bf5ac13", - "sha256:1777ce7535ee7a1995cae168a107a1320e9df13648b930e72a1a2c2eccd64cda", - "sha256:1e5520482fb18fbd64d079e7f17ac0018f195fd75f6360a53bb82d7903106b50", - "sha256:25522dcf2529614750a71112a6659759080b4bdc2323f19d47f4d895960fd796", - "sha256:2af5f2842ad44c65ae2647377e0ff198719e1a1cfc9c6a19bc0c525c035d4bd8", - "sha256:31ec48d7eca13fc25c287dea7cecab453976e372cad8f50d55c054a247efda21", - "sha256:47cf48ff5dbd554e9f58cc9e98cf0b5de3f6a971172612bffa06bc5fb79ce872", - "sha256:494f98366bb5d6c2ac7e50e6617139f353704fd97a6d12ec9d392e72817d5cb0", - "sha256:4a9845870739e640e3350a8d98d511c92c087fe3d66090e83be7bf94e0ac64f7", - "sha256:4ac29cc0847d948a6636899014e84e165c30cc8779d6218394d44363462a01ce", - "sha256:5857ace03b7854221abf8072462d306c2c2ce4e366190b21d90ee8ee8aaf5bb4", - "sha256:5b4a23d99d5a2874767034466f5a8fd37b9f93ac14955a01b1a208983c76b9ad", - "sha256:734d87a5021c037064beb62133e135e66c7128e401a63b8b842b809ae2093749", - "sha256:78005c1c5d15ef4e32e0f485557bd15b5b6d87f49c19db7fe3e9246a61ebe7e4", - "sha256:81ae2283225c5c52fc3d72debd4241c30ccff2bb922578bf7867f9851cce3acb", - "sha256:88dbf900f297fdae0f62b899d6a784d8868ec2135854c5f8a9abbad00a6f0c5b", - "sha256:8c98ea7b8d327a31cd6028782a06147d0e0329ae8e829e881fb5d02f7ed8aec9", - "sha256:937d4686fef6967921145290f5b50c01c00c5b5d3542a6519e8a85cd88448723", - "sha256:a057958c0e362b3c4f03b9af1cbdb6d5af035fd22ecd7fd794eba8fdeb049eb8", - "sha256:c41eab31fa2c641226c6187caa391a688d064c99f078d604574f1912296b771f", - "sha256:cf4f7e62d1f80d1fa85a1693a3500def5cde54b2b75212b3609e552e4c25acfb", - "sha256:d90d60143e18334330c149f293071c9f2f3c79c896f33dc4ec65099e58baaaa7", - "sha256:db3106b7ca86999a7bd1f2fcc93e49314e5e6e451356774e421a69428df5020b", - "sha256:dbaf264db56f4771dfac6624f438bc4dc670aa94f61a6138848fcab7e9e77380", - "sha256:e65206c4cf651dc9cf0829962fae8bec986767c9f123d6a1ad17f9356bf7257e", - "sha256:eac94ddc78c58e891cff7180274317dad2938a4ddfc6ced1c04846c7f50e77e9", - "sha256:f2e828711f044a965509c862b3a59b3181e9c56c145a950cb53d43fec54e66d2" - ], - "version": "==4.1.0.25" - }, - "osmium": { - "hashes": [ - "sha256:008f89720d833a28ff875893bc90ca6314ed27f23dedbff6b8e7e0224c058076", - "sha256:0811d5453e9828f14dc14f7380570a71b2ac2e9fbfc849fb1485a198e1bc0825", - "sha256:08a427a7c3fe3dceb84e19bcef6edada0dde9a675f75189d89dd7f4b0cab3539", - "sha256:0a1e4200e678e18db9b291a6498385b4c8f66dc3898be8fc6d0c232fe7600360", - "sha256:2183610dfbd7831b819e5990ec47a9c25dec76084dbae1d55bdc092bfba9177c", - "sha256:227ab38197d45fced6e18a5000e27b7bc7ef2970f7adcb856370661340a03b8e", - "sha256:2928713aaadaeab38fa8d546d274c9545b20440f2019425b3a6bab9444bd935a", - "sha256:2a3a42252afcf7fd3558c582e6a38df63df038a027b6d5fe1eaf8dac66969d37", - "sha256:4617fc74d13e2373b239597c6a875b90f95f40ec0d0977f68ca4beb3383a6f63", - "sha256:4ea02b36332585b66fb52b49468fac7426a257d0ffeaf0e0aa7ef7205f0fc442", - "sha256:56f269587578fcdd406af43dc276f3a59c4763821f9e41ce7b777f6f97cdede4", - "sha256:62688a1a662bc2ef7f0b05908c9e68ba11926fc79f3d1df13cd62cee74a6ca66", - "sha256:72d1d43834610c3d802316b526c204ecf428d5bbd5dab189b0e469bc67858db1", - "sha256:8a316b6bba0f33250c232c8a10f550d8578b639857e286159e1e0767d5ac7107", - "sha256:8b4802472d974b4f05ee960c40ccd0c14881b73cd68a669f23ce9b35fe313157", - "sha256:8c6b5c489d78d398786547480f87a7d51ad51cf0044479f13ecb0c74fb5616c7", - "sha256:91baacc2b7ad28574ec8c204ba812c5bdd9b0fae79f8b6787bea450441cba52f", - "sha256:b0b2f925c45fdd1af4a79d3051359c3bc70e7e83939c6096ab91f80b3e2e8cf8", - "sha256:b96ab16db2537edf7fd36f5b819f4575b7be0dce6ac857a813822b85c790c8c3", - "sha256:ce9f170aa8cf03a497e3a42fff785e4ddd6937a0a074e480d03b2ae90b60f80d", - "sha256:d5ebe6bf0e2afc943125ab01980cd0762b3cae8bb47c50aa14ee1a934caf0c85" - ], - "index": "pypi", - "version": "==2.15.0" - }, - "pandas": { - "hashes": [ - "sha256:071e42b89b57baa17031af8c6b6bbd2e9a5c68c595bc6bf9adabd7a9ed125d3b", - "sha256:17450e25ae69e2e6b303817bdf26b2cd57f69595d8550a77c308be0cd0fd58fa", - "sha256:17916d818592c9ec891cbef2e90f98cc85e0f1e89ed0924c9b5220dc3209c846", - "sha256:2538f099ab0e9f9c9d09bbcd94b47fd889bad06dc7ae96b1ed583f1dc1a7a822", - "sha256:366f30710172cb45a6b4f43b66c220653b1ea50303fbbd94e50571637ffb9167", - "sha256:42e5ad741a0d09232efbc7fc648226ed93306551772fc8aecc6dce9f0e676794", - "sha256:4e718e7f395ba5bfe8b6f6aaf2ff1c65a09bb77a36af6394621434e7cc813204", - "sha256:4f919f409c433577a501e023943e582c57355d50a724c589e78bc1d551a535a2", - "sha256:4fe0d7e6438212e839fc5010c78b822664f1a824c0d263fd858f44131d9166e2", - "sha256:5149a6db3e74f23dc3f5a216c2c9ae2e12920aa2d4a5b77e44e5b804a5f93248", - "sha256:627594338d6dd995cfc0bacd8e654cd9e1252d2a7c959449228df6740d737eb8", - "sha256:83c702615052f2a0a7fb1dd289726e29ec87a27272d775cb77affe749cca28f8", - "sha256:8c872f7fdf3018b7891e1e3e86c55b190e6c5cee70cab771e8f246c855001296", - "sha256:90f116086063934afd51e61a802a943826d2aac572b2f7d55caaac51c13db5b5", - "sha256:a3352bacac12e1fc646213b998bce586f965c9d431773d9e91db27c7c48a1f7d", - "sha256:bcdd06007cca02d51350f96debe51331dec429ac8f93930a43eb8fb5639e3eb5", - "sha256:c1bd07ebc15285535f61ddd8c0c75d0d6293e80e1ee6d9a8d73f3f36954342d0", - "sha256:c9a4b7c55115eb278c19aa14b34fcf5920c8fe7797a09b7b053ddd6195ea89b3", - "sha256:cc8fc0c7a8d5951dc738f1c1447f71c43734244453616f32b8aa0ef6013a5dfb", - "sha256:d7b460bc316064540ce0c41c1438c416a40746fd8a4fb2999668bf18f3c4acf1" - ], - "index": "pypi", - "version": "==0.24.2" - }, - "pandocfilters": { - "hashes": [ - "sha256:b3dd70e169bb5449e6bc6ff96aea89c5eea8c5f6ab5e207fc2f521a2cf4a0da9" - ], - "version": "==1.4.2" - }, - "pathlib2": { - "hashes": [ - "sha256:2156525d6576d21c4dcaddfa427fae887ef89a7a9de5cbfe0728b3aafa78427e", - "sha256:446014523bb9be5c28128c4d2a10ad6bb60769e78bd85658fe44a450674e0ef8" - ], - "markers": "python_version in '2.6 2.7 3.2 3.3'", - "version": "==2.3.4" - }, - "pbr": { - "hashes": [ - "sha256:8257baf496c8522437e8a6cfe0f15e00aedc6c0e0e7c9d55eeeeab31e0853843", - "sha256:8c361cc353d988e4f5b998555c88098b9d5964c2e11acf7b0d21925a66bb5824" - ], - "index": "pypi", - "version": "==5.1.3" - }, - "percache": { - "hashes": [ - "sha256:b60043937aece6d154ccd1fd7380fc01ea482335716c2bd41efb85b097bc88df" - ], - "index": "pypi", - "version": "==0.3.0" - }, - "pexpect": { - "hashes": [ - "sha256:2094eefdfcf37a1fdbfb9aa090862c1a4878e5c7e0e7e7088bdb511c558e5cd1", - "sha256:9e2c1fd0e6ee3a49b28f95d4b33bc389c89b20af6a1255906e90ff1262ce62eb" - ], - "markers": "sys_platform != 'win32'", - "version": "==4.7.0" - }, - "pickleshare": { - "hashes": [ - "sha256:87683d47965c1da65cdacaf31c8441d12b8044cdec9aca500cd78fc2c683afca", - "sha256:9649af414d74d4df115d5d718f82acb59c9d418196b7b4290ed47a12ce62df56" - ], - "version": "==0.7.5" - }, - "pillow": { - "hashes": [ - "sha256:0804f77cb1e9b6dbd37601cee11283bba39a8d44b9ddb053400c58e0c0d7d9de", - "sha256:0ab7c5b5d04691bcbd570658667dd1e21ca311c62dcfd315ad2255b1cd37f64f", - "sha256:0b3e6cf3ea1f8cecd625f1420b931c83ce74f00c29a0ff1ce4385f99900ac7c4", - "sha256:365c06a45712cd723ec16fa4ceb32ce46ad201eb7bbf6d3c16b063c72b61a3ed", - "sha256:38301fbc0af865baa4752ddae1bb3cbb24b3d8f221bf2850aad96b243306fa03", - "sha256:3aef1af1a91798536bbab35d70d35750bd2884f0832c88aeb2499aa2d1ed4992", - "sha256:3fe0ab49537d9330c9bba7f16a5f8b02da615b5c809cdf7124f356a0f182eccd", - "sha256:45a619d5c1915957449264c81c008934452e3fd3604e36809212300b2a4dab68", - "sha256:49f90f147883a0c3778fd29d3eb169d56416f25758d0f66775db9184debc8010", - "sha256:571b5a758baf1cb6a04233fb23d6cf1ca60b31f9f641b1700bfaab1194020555", - "sha256:5ac381e8b1259925287ccc5a87d9cf6322a2dc88ae28a97fe3e196385288413f", - "sha256:6153db744a743c0c8c91b8e3b9d40e0b13a5d31dbf8a12748c6d9bfd3ddc01ad", - "sha256:6fd63afd14a16f5d6b408f623cc2142917a1f92855f0df997e09a49f0341be8a", - "sha256:70acbcaba2a638923c2d337e0edea210505708d7859b87c2bd81e8f9902ae826", - "sha256:70b1594d56ed32d56ed21a7fbb2a5c6fd7446cdb7b21e749c9791eac3a64d9e4", - "sha256:76638865c83b1bb33bcac2a61ce4d13c17dba2204969dedb9ab60ef62bede686", - "sha256:7b2ec162c87fc496aa568258ac88631a2ce0acfe681a9af40842fc55deaedc99", - "sha256:7cee2cef07c8d76894ebefc54e4bb707dfc7f258ad155bd61d87f6cd487a70ff", - "sha256:7d16d4498f8b374fc625c4037742fbdd7f9ac383fd50b06f4df00c81ef60e829", - "sha256:b50bc1780681b127e28f0075dfb81d6135c3a293e0c1d0211133c75e2179b6c0", - "sha256:bd0582f831ad5bcad6ca001deba4568573a4675437db17c4031939156ff339fa", - "sha256:cfd40d8a4b59f7567620410f966bb1f32dc555b2b19f82a91b147fac296f645c", - "sha256:e3ae410089de680e8f84c68b755b42bc42c0ceb8c03dbea88a5099747091d38e", - "sha256:e9046e559c299b395b39ac7dbf16005308821c2f24a63cae2ab173bd6aa11616", - "sha256:ef6be704ae2bc8ad0ebc5cb850ee9139493b0fc4e81abcc240fb392a63ebc808", - "sha256:f8dc19d92896558f9c4317ee365729ead9d7bbcf2052a9a19a3ef17abbb8ac5b" - ], - "version": "==6.1.0" - }, - "pprofile": { - "hashes": [ - "sha256:3469102f462f9fc2d889970afcf73d89c0d89a36c49a4c262c3edc302b4a22da" - ], - "index": "pypi", - "version": "==2.0.2" - }, - "progressbar2": { - "hashes": [ - "sha256:9ecb2d35edaa30ed86eb92fb0135eb19a6ef9b3657be4350cc3d0d3563e6af65", - "sha256:c086fc1f718839c0ec95caaeb7bd5a1d0268a8775960b8f9dee06f2a04c84628" - ], - "version": "==3.42.0" - }, - "prometheus-client": { - "hashes": [ - "sha256:71cd24a2b3eb335cb800c7159f423df1bd4dcd5171b234be15e3f31ec9f622da" - ], - "version": "==0.7.1" - }, - "prompt-toolkit": { - "hashes": [ - "sha256:1e71341526efa4b11bb44d323e687a5d9cef204aabe2907e3f0dc1534cda0ecc", - "sha256:955d81315bb7a049f19cd17d1a73f1a40861483260f7dffd825e98303a8bd6b6", - "sha256:c1cedd626e08b8ee830ee65897de754113ff3f3035880030c08b01674d85c5b4" - ], - "version": "==1.0.16" - }, - "protobuf": { - "hashes": [ - "sha256:05c36022fef3c7d3562ac22402965c0c2b9fe8421f459bb377323598996e407f", - "sha256:139b7eadcca0a861d60b523cb37d9475505e0dfb07972436b15407c2b968d87e", - "sha256:15f683006cb77fb849b1f561e509b03dd2b7dcc749086b8dd1831090d0ba4740", - "sha256:2ad566b7b7cdd8717c7af1825e19f09e8fef2787b77fcb979588944657679604", - "sha256:35cfcf97642ef62108e10a9431c77733ec7eaab8e32fe4653de20403429907cb", - "sha256:387822859ecdd012fdc25ec879f7f487da6e1d5b1ae6115e227e6be208836f71", - "sha256:4df14cbe1e7134afcfdbb9f058949e31c466de27d9b2f7fb4da9e0b67231b538", - "sha256:586c4ca37a7146d4822c700059f150ac3445ce0aef6f3ea258640838bb892dc2", - "sha256:58b11e530e954d29ab3180c48dc558a409f705bf16739fd4e0d3e07924ad7add", - "sha256:63c8c98ccb8c95f41c18fb829aeeab21c6249adee4ed75354125bdc44488f30e", - "sha256:72edcbacd0c73eef507d2ff1af99a6c27df18e66a3ff4351e401182e4de62b03", - "sha256:83dc8a561b3b954fd7002c690bb83278b8d1742a1e28abba9aaef28b0c8b437d", - "sha256:913171ecc84c2726b86574e40549a0ea619d569657c5a5ff782a3be7d81401a5", - "sha256:aabb7c741d3416671c3e6fe7c52970a226e6a8274417a97d7d795f953fadef36", - "sha256:b3452bbda12b1cbe2187d416779de07b2ab4c497d83a050e43c344778763721d", - "sha256:c5d5b8d4a9212338297fa1fa44589f69b470c0ba1d38168b432d577176b386a8", - "sha256:d86ee389c2c4fc3cebabb8ce83a8e97b6b3b5dc727b7419c1ccdc7b6e545a233", - "sha256:f2db8c754de788ab8be5e108e1e967c774c0942342b4f8aaaf14063889a6cfdc" - ], - "version": "==3.9.0" - }, - "psutil": { - "hashes": [ - "sha256:028a1ec3c6197eadd11e7b46e8cc2f0720dc18ac6d7aabdb8e8c0d6c9704f000", - "sha256:503e4b20fa9d3342bcf58191bbc20a4a5ef79ca7df8972e6197cc14c5513e73d", - "sha256:863a85c1c0a5103a12c05a35e59d336e1d665747e531256e061213e2e90f63f3", - "sha256:954f782608bfef9ae9f78e660e065bd8ffcfaea780f9f2c8a133bb7cb9e826d7", - "sha256:b6e08f965a305cd84c2d07409bc16fbef4417d67b70c53b299116c5b895e3f45", - "sha256:bc96d437dfbb8865fc8828cf363450001cb04056bbdcdd6fc152c436c8a74c61", - "sha256:cf49178021075d47c61c03c0229ac0c60d5e2830f8cab19e2d88e579b18cdb76", - "sha256:d5350cb66690915d60f8b233180f1e49938756fb2d501c93c44f8fb5b970cc63", - "sha256:eba238cf1989dfff7d483c029acb0ac4fcbfc15de295d682901f0e2497e6781a" - ], - "index": "pypi", - "version": "==5.6.3" - }, - "ptyprocess": { - "hashes": [ - "sha256:923f299cc5ad920c68f2bc0bc98b75b9f838b93b599941a6b63ddbc2476394c0", - "sha256:d7cc528d76e76342423ca640335bd3633420dc1366f258cb31d05e865ef5ca1f" - ], - "markers": "os_name != 'nt'", - "version": "==0.6.0" - }, - "pycocotools": { - "git": "https://github.com/cocodataset/cocoapi.git", - "ref": "aca78bcd6b4345d25405a64fdba1120dfa5da1ab", - "subdirectory": "PythonAPI" - }, - "pycparser": { - "hashes": [ - "sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3" - ], - "version": "==2.19" - }, - "pycurl": { - "hashes": [ - "sha256:6f08330c5cf79fa8ef68b9912b9901db7ffd34b63e225dce74db56bb21deda8e" - ], - "index": "pypi", - "version": "==7.43.0.3" - }, - "pygame": { - "hashes": [ - "sha256:0480fe82cd41a43e3eea497fa2c059c72ac54cb5d003d5aa2ed06a04541c384e", - "sha256:136a3b5711d9ec369a0407e4e08ffced3ba61aa41059e9280ffffa79c8614f65", - "sha256:2622b9dd95f445c887a36a57eade42c672598589f69a8052ccdb8eeeffa4dbb1", - "sha256:301c6428c0880ecd4a9e3951b80e539c33863b6ff356a443db1758de4f297957", - "sha256:398c42b605ecc514e62f68f1944a2d21e247938309f598de6cb0ad3c207324a8", - "sha256:4aaff572a273a32e70ec3593d213e59ab11c183a9916616562247930f17a5447", - "sha256:4e1065577f1b29111113be5deb2ea88553551a5e1cf33e0c08fa32768f285809", - "sha256:5f052dc2975a399aa1830c1f04c5f72856aa416bf3cd4b31375a058015a5c620", - "sha256:68ea43e51150316b9fb08e251209d4e2b4e76a340b5b6fc8cdf1a898c78f7e5b", - "sha256:698433a9fcefca0527244dc44dff9503eb26157494730b1cc80e6e4dbb246e92", - "sha256:6f714986f7987f10cb94f1be0753318e341a7ea6b12d66f37a4d5d6dd4695023", - "sha256:73cd9df328c7e72638dbcc1d18e7155225faed880a53db6bad90d1d7c0a71dfd", - "sha256:7876d1f29f66d3d7cac46479503891ee1ef409b0fbce54b0d74f3a6b33a46dba", - "sha256:854e87b8b2b76e3ed11d64985fcfdd7af919659503de99fc2b0a717b314c3cf0", - "sha256:8da13704ad45b7d5de8a8cca135a7f44c7fc6aa9f691abe7b0392468a34a8013", - "sha256:9ce22fb72298ea33dbb3a1c6c60a4a4e19d9698df6f3f5782eba4dada7b7736d", - "sha256:a37b6c59e7b8feadc51db5197052b86ceb6443f9fb2a6f7d6527620e707c558c", - "sha256:a6e8d2f99dbe1dfe72d0c019693c14d93c410f702d0b04ec9a81b36dacd55a23", - "sha256:a9ac862dd7159861f2c6443b0029089e1c0c4ec762a8074022914ec52fe4dfac", - "sha256:ae1bc3e78ed28f20878e7ca2c98663a6634e9c00d7746d39413fc18e907dc162", - "sha256:be7e70f91bd4eb35ae081062f16bf434619b3292358d9b061f8159ddc570c7f0", - "sha256:c895cf9c1b6d1cbba8cb8cc3f5427febcf8aa41a9333697741abeea1c537a350", - "sha256:f1f5714d2c23f6a64ef2ac4fcd36a2dd2689da85978d951a99a6ae5dfdf9bdbc", - "sha256:fa788f775680fc5d268ab00a2da29c9a22830032cfab732730298a2952cd87f3" - ], - "index": "pypi", - "version": "==1.9.6" - }, - "pygments": { - "hashes": [ - "sha256:71e430bc85c88a430f000ac1d9b331d2407f681d6f6aec95e8bcfbc3df5b0127", - "sha256:881c4c157e45f30af185c1ffe8d549d48ac9127433f2c380c24b84572ad66297" - ], - "index": "pypi", - "version": "==2.4.2" - }, - "pyjwt": { - "hashes": [ - "sha256:5c6eca3c2940464d106b99ba83b00c6add741c9becaec087fb7ccdefea71350e", - "sha256:8d59a976fb773f3e6a39c85636357c4f0e242707394cadadd9814f5cbaa20e96" - ], - "index": "pypi", - "version": "==1.7.1" - }, - "pylint": { - "hashes": [ - "sha256:367e3d49813d349a905390ac27989eff82ab84958731c5ef0bef867452cfdc42", - "sha256:97a42df23d436c70132971d1dcb9efad2fe5c0c6add55b90161e773caf729300" - ], - "index": "pypi", - "version": "==1.9.5" - }, - "pylogbeat": { - "hashes": [ - "sha256:11f3b1d04424151d406d8b844a8db6299442b4af1f10d5f622a6febf1ad5c41d", - "sha256:473494a0c798a560a8312ee662b333888181cf4db18cd8f87a8d7d1548beefd9" - ], - "version": "==1.0.2" - }, - "pymongo": { - "hashes": [ - "sha256:32421df60d06f479d71b6b539642e410ece3006e8910688e68df962c8eb40a21", - "sha256:324b22a8443e11faca44c96b20e7ec8a9e59a1e664457edeeb4f796080b31cde", - "sha256:4505ff8b7923dd7a8bed1bf25c9c4d0df5ab0b8b2821f2296533f2149a55f401", - "sha256:460b224681ea711e48e3638d15be2249024031b7dcb9622ba19c2e85bd5a26cc", - "sha256:47473b70c5f3cd5ddd2c49ab3b9ceafdafbbed5bc963f147df22a9343d7978f5", - "sha256:49375839af76834e9c5c3cc78c78386873fd0b2ad9a0860a7dc4ec9fe73af9dd", - "sha256:4a65f0f71ece86c860d30a1436b646db8ea32aec518845ef2903ca569faec32e", - "sha256:530621906c5dd6d27305b39c4e017701e5f4299aa68b93cde70eb985f94ca26f", - "sha256:54f4770b5810e8dc3cbeed675874195f02bb2bc4e95a9d665068edfb3baff4f7", - "sha256:5ed9382410e938b0ff76041c34018210504729a83bcf4f6a70c7092c28169f6f", - "sha256:61cad83637ae12c1c825130d7f9325cd6c162e3a64e8747a8144866020be3ff4", - "sha256:61e8e1c58b4fdf47ab79b7c7db8bb022c1e40b3b5fcbbaeea5fc94dc5c75638d", - "sha256:6e04e496af7d156b66cce70460011c621ecbadf5dcdce325c7acbb3cd6ea245d", - "sha256:7ef89ec435e89da902451dde6845066fe2770befaf0301fe2a1ac426b51fced3", - "sha256:854e8425e5eb775ccfffad04ecd094c99923d60a2c2d49babb5c435e836a91fa", - "sha256:9569796d48498e4db4e1d56284b626a8ed15f641ce3a8b2085f06bb03f4c2c88", - "sha256:9d50c99c6388863cbfdc5db9bad62e3a7c2e5fc151554a07c7f3c2530334a34f", - "sha256:9ea016c2c011df21f77c1f806ce45129a344ba2d414bd50f9e065b13a4a134be", - "sha256:a8421f0823174888fb12a5fa675322e756499d71e77ff712b4412d4b8f3c6503", - "sha256:aef7d88384ada699976350a285c7a333f96ebc959e98e7d2c98589f47bbf3b7f", - "sha256:b4d7ff9957ee770cf03bd7156a68a2f2e838e60712d9608eadc8741c15d01e72", - "sha256:c1db85c39e6a60588f855dbc7bd68fb0dab796096148ab5aa4abecaff19e1c6e", - "sha256:cee2fc0b94e66e7230da12fc4b3d34793c49957e16ee04f6468a94e264a1e41d", - "sha256:cf1dea28379a16b23e47db312883f07b3ba8d9d6abc1c59e51d4c8ae1820ab43", - "sha256:d1cd175df7c8b5fc976bade78bf4d9fb5aa7ab465c0f59931e380bbe188ef8fc", - "sha256:d48a94edf3cdd34524936a72ea01b352682b337f33a42db10ba29a96c37147d3", - "sha256:d9cc103a4e97f78bc77a1d72759ab3722f6cdf0374ad4fb4b0c53bd3238bdf98", - "sha256:fcb9ae8aa9158106c5d98a4349ec0d90b68f052d620b2d24622ba03b91e4d81d" - ], - "index": "pypi", - "version": "==3.8.0" - }, - "pymysql": { - "hashes": [ - "sha256:95f057328357e0e13a30e67857a8c694878b0175797a9a203ee7adbfb9b1ec5f", - "sha256:9ec760cbb251c158c19d6c88c17ca00a8632bac713890e465b2be01fdc30713f" - ], - "index": "pypi", - "version": "==0.9.2" - }, - "pynacl": { - "hashes": [ - "sha256:05c26f93964373fc0abe332676cb6735f0ecad27711035b9472751faa8521255", - "sha256:0c6100edd16fefd1557da078c7a31e7b7d7a52ce39fdca2bec29d4f7b6e7600c", - "sha256:0d0a8171a68edf51add1e73d2159c4bc19fc0718e79dec51166e940856c2f28e", - "sha256:1c780712b206317a746ace34c209b8c29dbfd841dfbc02aa27f2084dd3db77ae", - "sha256:2424c8b9f41aa65bbdbd7a64e73a7450ebb4aa9ddedc6a081e7afcc4c97f7621", - "sha256:2d23c04e8d709444220557ae48ed01f3f1086439f12dbf11976e849a4926db56", - "sha256:30f36a9c70450c7878053fa1344aca0145fd47d845270b43a7ee9192a051bf39", - "sha256:37aa336a317209f1bb099ad177fef0da45be36a2aa664507c5d72015f956c310", - "sha256:4943decfc5b905748f0756fdd99d4f9498d7064815c4cf3643820c9028b711d1", - "sha256:57ef38a65056e7800859e5ba9e6091053cd06e1038983016effaffe0efcd594a", - "sha256:5bd61e9b44c543016ce1f6aef48606280e45f892a928ca7068fba30021e9b786", - "sha256:6482d3017a0c0327a49dddc8bd1074cc730d45db2ccb09c3bac1f8f32d1eb61b", - "sha256:7d3ce02c0784b7cbcc771a2da6ea51f87e8716004512493a2b69016326301c3b", - "sha256:a14e499c0f5955dcc3991f785f3f8e2130ed504fa3a7f44009ff458ad6bdd17f", - "sha256:a39f54ccbcd2757d1d63b0ec00a00980c0b382c62865b61a505163943624ab20", - "sha256:aabb0c5232910a20eec8563503c153a8e78bbf5459490c49ab31f6adf3f3a415", - "sha256:bd4ecb473a96ad0f90c20acba4f0bf0df91a4e03a1f4dd6a4bdc9ca75aa3a715", - "sha256:e2da3c13307eac601f3de04887624939aca8ee3c9488a0bb0eca4fb9401fc6b1", - "sha256:f67814c38162f4deb31f68d590771a29d5ae3b1bd64b75cf232308e5c74777e0" - ], - "index": "pypi", - "version": "==1.3.0" - }, - "pynmea2": { - "hashes": [ - "sha256:8b83fa7e3e668af5e182ef1c2fd4a535433ecadf60d7b627280172d695a1646b", - "sha256:fe786594299588d1bfbd346ece2c2c1e5b24e160dcb740813c34bfa70d0a141d" - ], - "index": "pypi", - "version": "==1.15.0" - }, - "pyparsing": { - "hashes": [ - "sha256:1873c03321fc118f4e9746baf201ff990ceb915f433f23b395f5580d1840cb2a", - "sha256:9b6323ef4ab914af344ba97510e966d64ba91055d6b9afa6b30799340e89cc03" - ], - "version": "==2.4.0" - }, - "pypolyline": { - "hashes": [ - "sha256:09cc2192bc12063c7afa2d2718b739cd4bf3f8ec29eacde0cb728c9f5f7f7858", - "sha256:21acee0e31d867bde04583907ccb7afe4b21d33a63c23adc7cf0d82b6f2feab3", - "sha256:5e0643454b4471f4f23d38530467ee7093d3b375898d5e1b054876e5a50a6b89", - "sha256:6b0a1b573fe84c9ed0aa3a4eb9903d44864f37e405cdcc7396b61e6d00a937d6", - "sha256:6bdbc9210f29d4fd44c3e4d510ffcc1276e46a50d63365831e2e422dc0b3cb43", - "sha256:8efb93097c92c5894dcaf9e784b888f9426d170ae51d62164341bbb2b832c09a", - "sha256:9c843a35b2d02b04c1226db851834b55f0de30eef47ba057fd6f8623cdef6f2d", - "sha256:ad01fedf427536f391776b329c95e5f80f2b1a5d25c54ea7713c8cdb56947106", - "sha256:e4e4c857790f6a3067dab3ae661edda99d5cee55d107b3b4d0186159431165ef", - "sha256:f8c84f0d2aa6bd9ed14bdb671fab80f79b4ba93b4347b530ae4d3b56a3fb269a" - ], - "index": "pypi", - "version": "==0.1.17" - }, - "pyproj": { - "hashes": [ - "sha256:1303b343a1c4d83d1ac17494571d958335c0a4597d4aa623cd64df1f36fb18bf", - "sha256:1fd2f756f43ba762f5a1ae769c6cc9ae6f919996bf80c621f331e4a5d89ae74f", - "sha256:2b3f59b16cde23c0d95b1d9ba3dd1c0be3937d877df3b47a522d3c9a74d31668", - "sha256:2e5d8b892782db22c3d6ffcb272c8ac0a18995e22d45db762a893ec64cc039d6", - "sha256:512a59bc20587f88df78a69872ed8cb4ec7905415ba85b4de0af35601770fba1", - "sha256:5aa89b04855e439e2b96caf1f49fa2ab60e6e7c407034284d31d808abed0618a", - "sha256:75b4c5eba36060a00867e16e81755a44e93a95b0bbaa4d6ee40f10c330b62108", - "sha256:860fde3429f364767c88a8e7f14f330e3fdace9f438e0ef1b112108a44c1eee8", - "sha256:86886f21af819553990f0da9ad7737d52cd32076dd277db34e40cf805919e839", - "sha256:9417d46f2b5e6ba79bd6adea0aae9659501c8a0350a5a98c0d9cb1442d45b0b4", - "sha256:9bb81141715832bb8682dda3c2f8f1ad0f43cf8aec5db52e0992c16c7664e227", - "sha256:afe150d8f0b351df7a357cfce50a8a5c0a44bdfeec5e08075f873cfeddf63004", - "sha256:cc2e21c09245c3eb47014c3d4c58888cc8d48a168a03533f9ed3f8b2ee82a352", - "sha256:cefb4a1a5d51cd04c9dd31bb18047c2dafcb86bc33a0347746b5a0ef82c071d8", - "sha256:cfa2cd0ee23bcfc9f165b4f8e9c5b7ba829c7b49175fb73420544619148d91af", - "sha256:d3a78ce50e6c50e701d65929dc04ab751edaeae660455a9fef3c2231d609f8c1", - "sha256:d772ee53c8d316de1b7f68244ab654f864553bca177357f8787a65dc09816ae3", - "sha256:ddd99d6f2c813e44721c22039ddf333e4b95e8d0794b03d9962c94c01c823934", - "sha256:ec89e68a0cf210af0cc2724b5f8601d4b6809ff0f556e16efc8c955e79672f7a", - "sha256:f118762ed0abe8e988a20020241fe1e6133edb960d2665a44d6f48acc6d8e7c7" - ], - "index": "pypi", - "version": "==2.2.1" - }, - "pyrsistent": { - "hashes": [ - "sha256:50cffebc87ca91b9d4be2dcc2e479272bcb466b5a0487b6c271f7ddea6917e14" - ], - "version": "==0.15.3" - }, - "pysdl2": { - "hashes": [ - "sha256:b52acab5493a77b08c2afee1f385769fc2005f17cfeaf1886eff22dc78da2123" - ], - "index": "pypi", - "version": "==0.9.6" - }, - "pysendfile": { - "hashes": [ - "sha256:510a414b270986fba3c79cb76d90a4c910c701bfb43ff983a5d4e92846050e17" - ], - "index": "pypi", - "version": "==2.0.1" - }, - "python-dateutil": { - "hashes": [ - "sha256:7e6584c74aeed623791615e26efd690f29817a27c73085b78e4bad02493df2fb", - "sha256:c89805f6f4d64db21ed966fda138f8a5ed7a4fdbc1a8ee329ce1b74e3c74da9e" - ], - "index": "pypi", - "version": "==2.8.0" - }, - "python-engineio": { - "hashes": [ - "sha256:4850c3e04b2040e4fd262d1047797473d1815b37a073807e7b80304c1c5f4848", - "sha256:89b90ee3816ed440c68ac7b6143244ae7d56a46a49295fbac8e6696482e596d1" - ], - "version": "==3.8.2.post1" - }, - "python-logstash": { - "hashes": [ - "sha256:10943e5df83f592b4d61b63ad1afff855ccc8c9467f78718f0a59809ba1fe68c" - ], - "index": "pypi", - "version": "==0.4.6" - }, - "python-logstash-async": { - "hashes": [ - "sha256:994894e8b7e168e56f21e302334c08203af102c7bc760cacdb8d3d0f5aa74cea", - "sha256:ccd528a0a9c6b7aabd9944c01d628e9d6cc2149156011aafd3484c7c0abbce45" - ], - "index": "pypi", - "version": "==1.5.1" - }, - "python-socketio": { - "hashes": [ - "sha256:335bd0fab481d65edce4ab82c3bb5cac950afa843329ea7c38777cd56c8eba38", - "sha256:efec4844456791b7d702efefd543ed67a8e314ca45efb8f0bfca7ae18fdee60a" - ], - "version": "==4.2.0" - }, - "python-utils": { - "hashes": [ - "sha256:34aaf26b39b0b86628008f2ae0ac001b30e7986a8d303b61e1357dfcdad4f6d3", - "sha256:e25f840564554eaded56eaa395bca507b0b9e9f0ae5ecb13a8cb785305c56d25" - ], - "version": "==2.3.0" - }, - "pytz": { - "hashes": [ - "sha256:303879e36b721603cc54604edcac9d20401bdbe31e1e4fdee5b9f98d5d31dfda", - "sha256:d747dd3d23d77ef44c6a3526e274af6efeb0a6f1afd5a69ba4d5be4098c8e141" - ], - "version": "==2019.1" - }, - "pyvcd": { - "hashes": [ - "sha256:791fd7608fb8113c9658f699cb6292d66d7fb90bcab9ebc00b05adc40da7a5ce", - "sha256:bdcb848b79cea2196ebf317178eff2c9c7d6354b85f9eb4991e9175f98e26937" - ], - "index": "pypi", - "version": "==0.1.4" - }, - "pywavelets": { - "hashes": [ - "sha256:18b193b67937e805a8e79c036bd2aa4ea3a357737256efeefdabd19c95083c3b", - "sha256:1d7ba03baa81938b17d4819db36f018e680d929af329062af4d4b6d6236d02ba", - "sha256:21f39d86cc35e003576fc1400b15534e2999570418fcdb17ea62d1ff8773b076", - "sha256:250412f482d5cb358b7ec323b2a783d91e5cfc337fdf8fde3c59bf2c35d6366f", - "sha256:25c0c592bf43eaffb4d3c6b6444b14c7407db750b6f2d344d809d4af934319d9", - "sha256:2f2cdd96e4882b0c18e75cc90c4710de429ac226ce53b58a90c7420e3e307631", - "sha256:3abed8dcd3e94ead72ee8010b494df5a9bdbdd5e39129d52fbf8066efa323a51", - "sha256:3e99ab8feeb47755738fb8deb8154c9604c4a7996b1b7db6b090475105ca7c92", - "sha256:64926c4c78dd690ec0d61be20f7c27cfbde6de9fa66ab8205eb079d9db6927fc", - "sha256:687ec8877c10e3a03595ad167d1ea2662bc1ab13ef43d63a6e207a53b2ee4c26", - "sha256:6af0077c7a4c9935aa64301f6942468b494656b8812e801d4a635cf42088f96c", - "sha256:7215856a5d2e1a2dccca1f71d912ee6a7387086f3b3adcb55d7c41314c6abb0c", - "sha256:9e47b241533add77961093b1e40cfff031597d429e91ad7c675838be0f7cc0df", - "sha256:9e782f49dca57bc0fd2a40c0917949d77be2ecc999ccd44fff57fb10aa214135", - "sha256:a12c7a6258c0015d2c75d88b87393ee015494551f049009e8b63eafed2d78efc", - "sha256:a5027d47484498e70391b311a2688c4f74294de629b982ed17be57be4c77ade7", - "sha256:ab02363467ee3cb222c5b425bc53453270ddae72bce313e72fd14616692d725a", - "sha256:adc79308c65a2007bdbd5846fda70088e7ead0ef0a5a6f44d08829e9478a907f", - "sha256:afaaee392450785a346d9e5e5f6e5307b13958d8b0633818632cb38972a7752a", - "sha256:b26b836c7f71df7b2779e62d1338367cfe37b98324e9b0d54b428ac030e3d1f0", - "sha256:b9adbc27d70a2626c235a18b41315de2832c384651d03383db7a58c2a2bccc6f", - "sha256:bd6e62efb7839fd6bf894b7b9aec6d58be0c44a38ea0c9f3c5bea834d84d05eb", - "sha256:de083a3a71576a9c3d8ba73b6f0425e4690d6ac6e480562f30bec5cb20667324", - "sha256:e89551257233a3da717a9e6e2e303243df75faffe0b6781d21c15eb9d682ec6d", - "sha256:eafb7d609c41a04028144f4b6697792f448554960ef353244aaf0a5883263543", - "sha256:fb3ee9f65d25ee5c89104e533d5f341c253cdb9543ef6fcd6dfa599b12e84f1c" - ], - "version": "==1.0.3" - }, - "pyyaml": { - "hashes": [ - "sha256:57acc1d8533cbe51f6662a55434f0dbecfa2b9eaf115bede8f6fd00115a0c0d3", - "sha256:588c94b3d16b76cfed8e0be54932e5729cc185caffaa5a451e7ad2f7ed8b4043", - "sha256:68c8dd247f29f9a0d09375c9c6b8fdc64b60810ebf07ba4cdd64ceee3a58c7b7", - "sha256:70d9818f1c9cd5c48bb87804f2efc8692f1023dac7f1a1a5c61d454043c1d265", - "sha256:86a93cccd50f8c125286e637328ff4eef108400dd7089b46a7be3445eecfa391", - "sha256:a0f329125a926876f647c9fa0ef32801587a12328b4a3c741270464e3e4fa778", - "sha256:a3c252ab0fa1bb0d5a3f6449a4826732f3eb6c0270925548cac342bc9b22c225", - "sha256:b4bb4d3f5e232425e25dda21c070ce05168a786ac9eda43768ab7f3ac2770955", - "sha256:cd0618c5ba5bda5f4039b9398bb7fb6a317bb8298218c3de25c47c4740e4b95e", - "sha256:ceacb9e5f8474dcf45b940578591c7f3d960e82f926c707788a570b51ba59190", - "sha256:fe6a88094b64132c4bb3b631412e90032e8cfe9745a58370462240b8cb7553cd" - ], - "index": "pypi", - "version": "==5.1.1" - }, - "pyzmq": { - "hashes": [ - "sha256:00dd015159eaeb1c0731ad49310e1f5d839c9a35a15e4f3267f5052233fad99b", - "sha256:03913b6beb8e7b417b9910b0ee1fd5d62e9626d218faefbe879d70714ceab1a2", - "sha256:13f17386df81d5e6efb9a4faea341d8de22cdc82e49a326dded26e33f42a3112", - "sha256:16c6281d96885db1e15f7047ddc1a8f48ff4ea35d31ca709f4d2eb39f246d356", - "sha256:17efab4a804e31f58361631256d660214204046f9e2b962738b171b9ad674ea7", - "sha256:2b79919ddeff3d3c96aa6087c21d294c8db1c01f6bfeee73324944683685f419", - "sha256:2f832e4711657bb8d16ea1feba860f676ec5f14fb9fe3b449b5953a60e89edae", - "sha256:31a11d37ac73107363b47e14c94547dbfc6a550029c3fe0530be443199026fc2", - "sha256:33a3e928e6c3138c675e1d6702dd11f6b7050177d7aab3fc322db6e1d2274490", - "sha256:34a38195a6d3a9646cbcdaf8eb245b4d935c7a57f7e1b3af467814bc1a92467e", - "sha256:42900054f1500acef6df7428edf806abbf641bf92eb9ceded24aa863397c3bae", - "sha256:4ccc7f3c63aa9d744dadb62c49eda2d0e7de55649b80c45d7c684d70161a69af", - "sha256:5b220c37c346e6575db8c88a940c1fc234f99ce8e0068c408919bb8896c4b6d2", - "sha256:6074848da5c8b44a1ca40adf75cf65aa92bc80f635e8249aa8f37a69b2b9b6f5", - "sha256:61a4155964bd4a14ef95bf46cb1651bcf8dcbbed8c0108e9c974c1fcbb57788f", - "sha256:62b5774688326600c52f587f7a033ca6b6284bef4c8b1b5fda32480897759eac", - "sha256:65a9ffa4f9f085d696f16fd7541f34b3c357d25fe99c90e3bce2ea59c3b5b4b6", - "sha256:76a077d2c30f8adc5e919a55985a784b96aeca69b53c1ea6fd5723d3ae2e6f53", - "sha256:8e5b4c51557071d6379d6dc1f54f35e9f6a137f5e84e102efb869c8d3c13c8ff", - "sha256:917f73e07cc04f0678a96d93e7bb8b1adcccdde9ccfe202e622814f4d1d1ecfd", - "sha256:91c75d3c4c357f9643e739db9e79ab9681b2f6ae8ec5678d6ef2ea0d01532596", - "sha256:923dd91618b100bb4c92ab9ed7b65825a595b8524a094ce03c7cb2aaae7d353b", - "sha256:9849054e0355e2bc7f4668766a25517ba76095031c9ff5e39ae8949cee5bb024", - "sha256:c9d453933f0e3f44b9759189f2a18aa765f7f1a4345c727c18ebe8ad0d748d26", - "sha256:cb7514936277abce64c2f4c56883e5704d85ed04d98d2d432d1c6764003bb003" - ], - "index": "pypi", - "version": "==18.0.2" - }, - "qtconsole": { - "hashes": [ - "sha256:6a85456af7a98b0f554d140922b7b6a219757b039adb2b95e847cf115eaa20ae", - "sha256:767eb9ec3f9943bc84270198b5ff95d2d86d68d6b57792fafa4df4fc6b16cd7c" - ], - "version": "==4.5.2" - }, - "redis": { - "hashes": [ - "sha256:6946b5dca72e86103edc8033019cc3814c031232d339d5f4533b02ea85685175", - "sha256:8ca418d2ddca1b1a850afa1680a7d2fd1f3322739271de4b704e0d4668449273" - ], - "index": "pypi", - "version": "==3.2.1" - }, - "redlock": { - "hashes": [ - "sha256:b718646239d300745475a76e81d350ec523e7146cf84d696b3c4a7dfdd5dd4d4", - "sha256:ce7e6ab404882b64a9c5017c7a78b1a3714f2c712635bcb22cbb74d20719bbd1" - ], - "index": "pypi", - "version": "==1.2.0" - }, - "requests": { - "hashes": [ - "sha256:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4", - "sha256:9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31" - ], - "index": "pypi", - "version": "==2.22.0" - }, - "requests-oauthlib": { - "hashes": [ - "sha256:bd6533330e8748e94bf0b214775fed487d309b8b8fe823dc45641ebcd9a32f57", - "sha256:d3ed0c8f2e3bbc6b344fa63d6f933745ab394469da38db16bdddb461c7e25140" - ], - "version": "==1.2.0" - }, - "reverse-geocoder": { - "hashes": [ - "sha256:2a2e781b5f69376d922b78fe8978f1350c84fce0ddb07e02c834ecf98b57c75c" - ], - "index": "pypi", - "version": "==1.5.1" - }, - "s2sphere": { - "hashes": [ - "sha256:c2478c1ff7c601a59a7151a57b605435897514578fa6bdb8730721c182adbbaf", - "sha256:d2340c9cf458ddc9a89afd1d8048a4195ce6fa6b0095ab900d4be5271e537401" - ], - "index": "pypi", - "version": "==0.2.5" - }, - "s3transfer": { - "hashes": [ - "sha256:6efc926738a3cd576c2a79725fed9afde92378aa5c6a957e3af010cb019fac9d", - "sha256:b780f2411b824cb541dbcd2c713d0cb61c7d1bcadae204cdddda2b35cef493ba" - ], - "version": "==0.2.1" - }, - "scandir": { - "hashes": [ - "sha256:2586c94e907d99617887daed6c1d102b5ca28f1085f90446554abf1faf73123e", - "sha256:2ae41f43797ca0c11591c0c35f2f5875fa99f8797cb1a1fd440497ec0ae4b022", - "sha256:2b8e3888b11abb2217a32af0766bc06b65cc4a928d8727828ee68af5a967fa6f", - "sha256:2c712840c2e2ee8dfaf36034080108d30060d759c7b73a01a52251cc8989f11f", - "sha256:4d4631f6062e658e9007ab3149a9b914f3548cb38bfb021c64f39a025ce578ae", - "sha256:67f15b6f83e6507fdc6fca22fedf6ef8b334b399ca27c6b568cbfaa82a364173", - "sha256:7d2d7a06a252764061a020407b997dd036f7bd6a175a5ba2b345f0a357f0b3f4", - "sha256:8c5922863e44ffc00c5c693190648daa6d15e7c1207ed02d6f46a8dcc2869d32", - "sha256:92c85ac42f41ffdc35b6da57ed991575bdbe69db895507af88b9f499b701c188", - "sha256:b24086f2375c4a094a6b51e78b4cf7ca16c721dcee2eddd7aa6494b42d6d519d", - "sha256:cb925555f43060a1745d0a321cca94bcea927c50114b623d73179189a4e100ac" - ], - "markers": "python_version < '3.5'", - "version": "==1.10.0" - }, - "scikit-image": { - "hashes": [ - "sha256:056632aa964528c484758829d295f11c86a405aa0294f2578eac4acd945d4300", - "sha256:1600628c96b76f265dede2393115f77d93a427c617202622dfd6ba27e075efcc", - "sha256:1e85573ed37e0205ea918475c1fbd12e6c118c6f1e166dd159af04bcd9d4fa30", - "sha256:1fc4a596d6b7295bd05dce3df1105d1c7c7abe9c65f5d3ced2eace1cd746c15e", - "sha256:24ebe2a9cf40f2196393bc575345bc514bc845366545361785696a76e3aeb89b", - "sha256:331ee6db27e434e467831e21c8489bec23038ede790c53e0b6040e1e638fff45", - "sha256:4c17f2919029bd68907e2bf80dfecfb8b601bee4f392ef01f835ba4aa8c616e9", - "sha256:4e59c25be3e9760ba181832b9b33e27ff3cea9c362842260ac06644ae08b23c8", - "sha256:4f12cdf72155f77b736902e87c6b4544e311241070e9548c03ac0fcf9aa0bbed", - "sha256:62718e67f1f058501055c7e6b7206eea96f792039ea4c87af8e6b706a22ae11e", - "sha256:6b88c64f8351f1755ccc7feec26a7e55359acba2375498409fa1380bd3789b6f", - "sha256:755ee87e4b0332fd1645c67fd1e5780908937f35d28a6bd3377af304fd54a8d9", - "sha256:8508b9a2fccaa52a30785316ae4b29aaf339ef8fc3dab1bb35d36468397e0b0d", - "sha256:8541cefddad87b08105583e946132e822b196fff437f407afa92742e1e763387", - "sha256:8d76474ad59e5339584a9c4317868e51c0fbf2c2d11a936e836279fc281633d6", - "sha256:b26462abeee13ee249c814723a3038ccd74af2144349422d1b344e1378f9f702", - "sha256:b7b5605c7737073c1bdffbfea1f6a257dd6e96ab109fc37f43a7bd3d1d581e2a", - "sha256:c7afc4231e9bb9d0d2b44958e6e403117e6823bb16bca61ab95540e737f2941f", - "sha256:cc97cfc239f1f7ee8cc5129e3cb29fe553237fa62380b62d6f7c0909974d1400", - "sha256:ce114f536941348998665360ea6fbbf1577a3c49a5c2b4d416c71d3edde05ab7", - "sha256:db9f4fb00db5ce5855737c22abbdc22d9663d44643cbdad674e2c9fc32ba9c16", - "sha256:e312e914d6f97e525460268cd0d215cd9c9c4fe131457316bd32c6c760171660", - "sha256:e50d053133c292efe0e70eefc6a6481002b32d7b4b72ef38bd7caae6b24fb7d6", - "sha256:ef3fb33404fbf1717e3d268e1cc0983264fc3154036b29950fbc9c3fbed98ee3", - "sha256:f05eab2df885fb6fde3df0e4d24c9c620d6474ea0eb949fd45f6f634925dd514", - "sha256:fb1de3dabbc7a429b38a016d01502920226b59d277578291fb18a28888ed5792" - ], - "index": "pypi", - "version": "==0.14.3" - }, - "scipy": { - "hashes": [ - "sha256:0bcababa06ff83138a7f30a68f334dee034ce1cc7604f9278b96f62265fe7fd7", - "sha256:162b803984ebb76927990d7233cab825d146be8e2a3f6a0efb1b3a61ebacae73", - "sha256:271c6e56c8f9a3d6c3f0bc857d7a6e7cf7a8415c879a3915701cd011e82a83a3", - "sha256:2eb255b30dac7516c6f3c5237f2e0ad1f1213b5364de409d932249c9a8c5bffb", - "sha256:447c40d33ec5e0020750fadbb8599220b9eb9fd8798030efe9b308247800f364", - "sha256:4686d699f76068757a81269f1a111c0db689bf048a56b131a339803121534fa8", - "sha256:47d4623efa71948dc4a92f978fbf6b9fb69dac5b0f0fae4c1a1f3d955ac8aea9", - "sha256:49dcebc6f57bce0bd23cb55dbc6144f4990e5cbce9aab3128af03d6b1b4eab6a", - "sha256:5fa84b467b5f77c243c5701628ed7a4238e53bc4120db87be7dafa416e842fb9", - "sha256:67d2210c7f6f585e1055bee3dc9f15610b5ebb04e80bfaa757868937ee744fec", - "sha256:682b210ff7a65f6f5245fdf73d26a348b57e42d2059bc5fcf7ed25d063f35c45", - "sha256:7f58faa422aa493d7b70dd56d6e8783223e84dd6e7f4b4161bd776b39ecbac92", - "sha256:7fb4efff9895116428ad65564d2232fb1cac4b9d84398512a858b09dd4a7fd59", - "sha256:922e2370674c82dd1367fc13a08c8765f4e5281a584d871e7cb454828d84600f", - "sha256:97f26b4b5d4456f44849fd35cad8801f7cae4e64b75fc4e522d26a54aef17391", - "sha256:9a21d64d002cb3a9239a55c0aa100b48d58b5e38382c0fdfcdfc68cf417d8142", - "sha256:a4331e0b8dab1ff75d2c67b5158a8bb9a83c799d7140094dda936d876c7cfbb1", - "sha256:a9fc1fcaa560edf771d4545d7e6dd865a213fc5b485bb127de5dfd32f40094e1", - "sha256:b074a83299a82eae617dc46a830cfa7aaa588d07523990507848ee1ded3c52ce", - "sha256:bcd0d4b2de5cb3fab69007214a39737e917267f56f887ce9c7732ba3278fc33d", - "sha256:c390f1721757ec983616149f00e1bd0432aa32d2c1d9398930d7e7cc9542c922", - "sha256:c5b9db9e3f6537bf7b308de12c185b27f22fb9a66fd12efc7aefbcfa0adb4d82", - "sha256:d0d41a9ee3264f95820138170b447f5d3e453e5ebd10b411bca37c99237aac69", - "sha256:d18d1575d4a54f128c0f34422bd73ce0f177e462d6124f074388e211d8dc2616", - "sha256:e99cd49daffe7384fd35046c3b14bee98ce87d97c95865469227001905534e13", - "sha256:f4e355afa8fdda11010de308c2376edda29e064cec699974097364115f71e16f", - "sha256:f64e29a8b32d672fb6078f456bfff3cae8f36b6c8b64c337ad0942f29404b03f", - "sha256:fbdff021643c2dfa35efd29218e0318c4b4987f48ea432be7e8c02bdb1b0c314" - ], - "index": "pypi", - "version": "==1.2.2" - }, - "seaborn": { - "hashes": [ - "sha256:42e627b24e849c2d3bbfd059e00005f6afbc4a76e4895baf44ae23fe8a4b09a5", - "sha256:76c83f794ca320fb6b23a7c6192d5e185a5fcf4758966a0c0a54baee46d41e2f" - ], - "index": "pypi", - "version": "==0.9.0" - }, - "send2trash": { - "hashes": [ - "sha256:60001cc07d707fe247c94f74ca6ac0d3255aabcb930529690897ca2a39db28b2", - "sha256:f1691922577b6fa12821234aeb57599d887c4900b9ca537948d2dac34aea888b" - ], - "version": "==1.5.0" - }, - "shapely": { - "hashes": [ - "sha256:0378964902f89b8dbc332e5bdfa08e0bc2f7ab39fecaeb17fbb2a7699a44fe71", - "sha256:34e7c6f41fb27906ccdf2514ee44a5774b90b39a256b6511a6a57d11ffe64999", - "sha256:3ca69d4b12e2b05b549465822744b6a3a1095d8488cc27b2728a06d3c07d0eee", - "sha256:3e9388f29bd81fcd4fa5c35125e1fbd4975ee36971a87a90c093f032d0e9de24", - "sha256:3ef28e3f20a1c37f5b99ea8cf8dcb58e2f1a8762d65ed2d21fd92bf1d4811182", - "sha256:523c94403047eb6cacd7fc1863ebef06e26c04d8a4e7f8f182d49cd206fe787e", - "sha256:5d22a1a705c2f70f61ccadc696e33d922c1a92e00df8e1d58a6ade14dd7e3b4f", - "sha256:714b6680215554731389a1bbdae4cec61741aa4726921fa2b2b96a6f578a2534", - "sha256:7dfe1528650c3f0dc82f41a74cf4f72018288db9bfb75dcd08f6f04233ec7e78", - "sha256:ba58b21b9cf3c33725f7f530febff9ed6a6846f9d0bf8a120fc74683ff919f89", - "sha256:c4b87bb61fc3de59fc1f85e71a79b0c709dc68364d9584473697aad4aa13240f", - "sha256:ebb4d2bee7fac3f6c891fcdafaa17f72ab9c6480f6d00de0b2dc9a5137dfe342" - ], - "index": "pypi", - "version": "==1.6.4.post2" - }, - "simplegeneric": { - "hashes": [ - "sha256:dc972e06094b9af5b855b3df4a646395e43d1c9d0d39ed345b7393560d0b9173" - ], - "version": "==0.8.1" - }, - "simplejson": { - "hashes": [ - "sha256:067a7177ddfa32e1483ba5169ebea1bc2ea27f224853211ca669325648ca5642", - "sha256:2fc546e6af49fb45b93bbe878dea4c48edc34083729c0abd09981fe55bdf7f91", - "sha256:354fa32b02885e6dae925f1b5bbf842c333c1e11ea5453ddd67309dc31fdb40a", - "sha256:37e685986cf6f8144607f90340cff72d36acf654f3653a6c47b84c5c38d00df7", - "sha256:3af610ee72efbe644e19d5eaad575c73fb83026192114e5f6719f4901097fce2", - "sha256:3b919fc9cf508f13b929a9b274c40786036b31ad28657819b3b9ba44ba651f50", - "sha256:3dd289368bbd064974d9a5961101f080e939cbe051e6689a193c99fb6e9ac89b", - "sha256:6c3258ffff58712818a233b9737fe4be943d306c40cf63d14ddc82ba563f483a", - "sha256:75e3f0b12c28945c08f54350d91e624f8dd580ab74fd4f1bbea54bc6b0165610", - "sha256:b1f329139ba647a9548aa05fb95d046b4a677643070dc2afc05fa2e975d09ca5", - "sha256:ee9625fc8ee164902dfbb0ff932b26df112da9f871c32f0f9c1bcf20c350fe2a", - "sha256:fb2530b53c28f0d4d84990e945c2ebb470edb469d63e389bf02ff409012fe7c5" - ], - "index": "pypi", - "version": "==3.16.0" - }, - "singledispatch": { - "hashes": [ - "sha256:5b06af87df13818d14f08a028e42f566640aef80805c3b50c5056b086e3c2b9c", - "sha256:833b46966687b3de7f438c761ac475213e53b306740f1abfaa86e1d1aae56aa8" - ], - "markers": "python_version < '3.4'", - "version": "==3.4.0.3" - }, - "six": { - "hashes": [ - "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", - "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" - ], - "index": "pypi", - "version": "==1.12.0" - }, - "sortedcontainers": { - "hashes": [ - "sha256:974e9a32f56b17c1bac2aebd9dcf197f3eb9cd30553c5852a3187ad162e1a03a", - "sha256:d9e96492dd51fae31e60837736b38fe42a187b5404c16606ff7ee7cd582d4c60" - ], - "version": "==2.1.0" - }, - "sqlalchemy": { - "hashes": [ - "sha256:d6cda03b0187d6ed796ff70e87c9a7dce2c2c9650a7bc3c022cd331416853c31" - ], - "index": "pypi", - "version": "==1.2.7" - }, - "subprocess32": { - "hashes": [ - "sha256:88e37c1aac5388df41cc8a8456bb49ebffd321a3ad4d70358e3518176de3a56b", - "sha256:eb2937c80497978d181efa1b839ec2d9622cf9600a039a79d0e108d1f9aec79d" - ], - "index": "pypi", - "version": "==3.5.4" - }, - "supervisor": { - "hashes": [ - "sha256:43e87c7b572a94acdb586aaebb06844dae1aa02856b984c5a738032abd753fb7", - "sha256:9644990d21a1ba03b1a7ac5e9a0c0c62e12822e258f9e98f4a0b128461b3f10a" - ], - "index": "pypi", - "version": "==4.0.4" - }, - "tenacity": { - "hashes": [ - "sha256:a0c3c5f7ae0c33f5556c775ca059c12d6fd8ab7121613a713e8b7d649908571b", - "sha256:b87c1934daa0b2ccc7db153c37b8bf91d12f165936ade8628e7b962b92dc7705" - ], - "index": "pypi", - "version": "==5.0.4" - }, - "tensorboard": { - "hashes": [ - "sha256:6f194519f41762bfdf5eb410ccf33226d1c252caf5ad8893288648bfbcf4d135", - "sha256:81170f66bf8f95c2e9f6b3fefe0ddc5472655a9e3793e73b5b5d4ec0ba395e76" - ], - "version": "==1.12.2" - }, - "tensorflow-estimator": { - "hashes": [ - "sha256:3e460f43682c7d789e5fe966630029558434d32502e632ee7f6703451258528c" - ], - "index": "pypi", - "version": "==1.10.12" - }, - "tensorflow-gpu": { - "hashes": [ - "sha256:0c2fa74a53009f72eb73da46ef8e78ffc09514349ba3de179c6b419b69a4bf09", - "sha256:17460b5f3525ddbbb1fb9f639955d3a999f9656cc7bf1be65bc78dea1a0cedea", - "sha256:2f85fdfee4eb93432bf8ef11428f2b5e17fb3e1b733599612329e165bb74a3fd", - "sha256:38be54cb1e757f95f24b2e03e71d7bcab359429267ff36c9e32de2ed17943a42", - "sha256:42c13cf5538125d93177b7901f23a1f6759b64f9f3f2d8680099b1fbfec37b83", - "sha256:b771297d3b93f93a20af1d2d7dc049bb9617e2c2ab25c36156b011bf1a49bd7c", - "sha256:ca68f7eb91e6101300ffc59a59c3b5600359a0ab6f2e1e8cde4a8a65ec21bb92" - ], - "index": "pypi", - "version": "==1.13.0rc0" - }, - "termcolor": { - "hashes": [ - "sha256:1d6d69ce66211143803fbc56652b41d73b4a400a2891d7bf7a1cdf4c02de613b" - ], - "version": "==1.1.0" - }, - "terminado": { - "hashes": [ - "sha256:d9d012de63acb8223ac969c17c3043337c2fcfd28f3aea1ee429b345d01ef460", - "sha256:de08e141f83c3a0798b050ecb097ab6259c3f0331b2f7b7750c9075ced2c20c2" - ], - "version": "==0.8.2" - }, - "testpath": { - "hashes": [ - "sha256:46c89ebb683f473ffe2aab0ed9f12581d4d078308a3cb3765d79c6b2317b0109", - "sha256:b694b3d9288dbd81685c5d2e7140b81365d46c29f5db4bc659de5aa6b98780f8" - ], - "version": "==0.4.2" - }, - "theano": { - "hashes": [ - "sha256:35c9bbef56b61ffa299265a42a4e8f8cb5a07b2997dabaef0f8830b397086913" - ], - "index": "pypi", - "version": "==1.0.4" - }, - "torchfile": { - "hashes": [ - "sha256:a53dfe134b737845a9f2cb24fe0585317874f965932cebdb0439d13c8da4136e" - ], - "version": "==0.1.0" - }, - "tornado": { - "hashes": [ - "sha256:0662d28b1ca9f67108c7e3b77afabfb9c7e87bde174fbda78186ecedc2499a9d", - "sha256:4e5158d97583502a7e2739951553cbd88a72076f152b4b11b64b9a10c4c49409", - "sha256:732e836008c708de2e89a31cb2fa6c0e5a70cb60492bee6f1ea1047500feaf7f", - "sha256:8154ec22c450df4e06b35f131adc4f2f3a12ec85981a203301d310abf580500f", - "sha256:8e9d728c4579682e837c92fdd98036bd5cdefa1da2aaf6acf26947e6dd0c01c5", - "sha256:d4b3e5329f572f055b587efc57d29bd051589fb5a43ec8898c77a47ec2fa2bbb", - "sha256:e5f2585afccbff22390cddac29849df463b252b711aa2ce7c5f3f342a5b3b444" - ], - "version": "==5.1.1" - }, - "traitlets": { - "hashes": [ - "sha256:9c4bd2d267b7153df9152698efb1050a5d84982d3384a37b2c1f7723ba3e7835", - "sha256:c6cb5e6f57c5a9bdaa40fa71ce7b4af30298fbab9ece9815b5d995ab6217c7d9" - ], - "version": "==4.3.2" - }, - "transforms3d": { - "hashes": [ - "sha256:404c7797c78aa461cb8043081901fc5517cef342d5ff56becd74a7967ba88d78" - ], - "index": "pypi", - "version": "==0.3.1" - }, - "typing": { - "hashes": [ - "sha256:38566c558a0a94d6531012c8e917b1b8518a41e418f7f15f00e129cc80162ad3", - "sha256:53765ec4f83a2b720214727e319607879fec4acde22c4fbb54fa2604e79e44ce", - "sha256:84698954b4e6719e912ef9a42a2431407fe3755590831699debda6fba92aac55" - ], - "markers": "python_version < '3.5'", - "version": "==3.7.4" - }, - "urllib3": { - "hashes": [ - "sha256:b246607a25ac80bedac05c6f282e3cdaf3afb65420fd024ac94435cabe6e18d1", - "sha256:dbe59173209418ae49d485b87d1681aefa36252ee85884c31346debd19463232" - ], - "index": "pypi", - "version": "==1.25.3" - }, - "utm": { - "hashes": [ - "sha256:07e55707ed660eec1ae983bd54a406c437962618a6261b38d70592fe30f5f508" - ], - "index": "pypi", - "version": "==0.5.0" - }, - "uwsgi": { - "hashes": [ - "sha256:4972ac538800fb2d421027f49b4a1869b66048839507ccf0aa2fda792d99f583" - ], - "index": "pypi", - "version": "==2.0.18" - }, - "v4l2": { - "hashes": [ - "sha256:0d8f31f9d554ded4d0b50a31a7be5590b861df9e1ba256ee757e1c09175dd4a2" - ], - "index": "pypi", - "version": "==0.2" - }, - "vine": { - "hashes": [ - "sha256:133ee6d7a9016f177ddeaf191c1f58421a1dcc6ee9a42c58b34bed40e1d2cd87", - "sha256:ea4947cc56d1fd6f2095c8d543ee25dad966f78692528e68b4fada11ba3f98af" - ], - "version": "==1.3.0" - }, - "visdom": { - "hashes": [ - "sha256:77edd6811471282740846672a996348e963b5fa4220780f126c71481ad21d5a5" - ], - "index": "pypi", - "version": "==0.1.8.8" - }, - "wcwidth": { - "hashes": [ - "sha256:3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e", - "sha256:f4ebe71925af7b40a864553f761ed559b43544f8f71746c2d756c7fe788ade7c" - ], - "version": "==0.1.7" - }, - "websocket-client": { - "hashes": [ - "sha256:1151d5fb3a62dc129164292e1227655e4bbc5dd5340a5165dfae61128ec50aa9", - "sha256:1fd5520878b68b84b5748bb30e592b10d0a91529d5383f74f4964e72b297fd3a" - ], - "index": "pypi", - "version": "==0.56.0" - }, - "werkzeug": { - "hashes": [ - "sha256:87ae4e5b5366da2347eb3116c0e6c681a0e939a33b2805e2c0cbd282664932c4", - "sha256:a13b74dd3c45f758d4ebdb224be8f1ab8ef58b3c0ffc1783a8c7d9f4f50227e6" - ], - "version": "==0.15.5" - }, - "wheel": { - "hashes": [ - "sha256:5e79117472686ac0c4aef5bad5172ea73a1c2d1646b808c35926bd26bdfb0c08", - "sha256:62fcfa03d45b5b722539ccbc07b190e4bfff4bb9e3a4d470dd9f6a0981002565" - ], - "markers": "python_version < '3'", - "version": "==0.33.4" - }, - "widgetsnbextension": { - "hashes": [ - "sha256:120f85acc3976450220b03b8933ce48678e518905cca69fc3c856ea5a0144196", - "sha256:8c9b4d73e388f2484296be18432d3cc0b8d59de243079a0db16a56c5571e1f86" - ], - "version": "==3.5.0" - }, - "wrapt": { - "hashes": [ - "sha256:565a021fd19419476b9362b05eeaa094178de64f8361e44468f9e9d7843901e1" - ], - "version": "==1.11.2" - } - } -} diff --git a/README.md b/README.md index d4dd5b11da6980..56b83dc458c14a 100644 --- a/README.md +++ b/README.md @@ -1,184 +1,329 @@ -WARNING: TESLA ONLY OPENPILOT 0.6.3-T11 +WARNING: TESLA ONLY OPENPILOT 0.7.10 ====== This repo contains code that was modified specifically for Tesla and will not work on other cars! +Main Comma.ai code is Copyright (c) 2018, Comma.ai, Inc. Additonal work (ALCA, webcamera, any modifications to base Comma.ao code) is licensed under Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. -[![](https://i.imgur.com/UetIFyH.jpg)](#) - -Welcome to openpilot -====== - -[openpilot](http://github.com/commaai/openpilot) is an open source driving agent. Currently, it performs the functions of Adaptive Cruise Control (ACC) and Lane Keeping Assist System (LKAS) for selected Honda, Toyota, Acura, Lexus, Chevrolet, Hyundai, Kia. It's about on par with Tesla Autopilot and GM Super Cruise, and better than [all other manufacturers](http://www.thedrive.com/tech/5707/the-war-for-autonomous-driving-part-iii-us-vs-germany-vs-japan). - -The openpilot codebase has been written to be concise and to enable rapid prototyping. We look forward to your contributions - improving real vehicle automation has never been easier. +[![](https://i.imgur.com/UelUjKAh.png)](#) Table of Contents ======================= -* [Community](#community) -* [Hardware](#hardware) +* [What is openpilot?](#what-is-openpilot) +* [Integration with Stock Features](#integration-with-stock-features) +* [Supported Hardware](#supported-hardware) * [Supported Cars](#supported-cars) -* [Community Maintained Cars](#community-maintained-cars) -* [In Progress Cars](#in-progress-cars) -* [How can I add support for my car?](#how-can-i-add-support-for-my-car) -* [Directory structure](#directory-structure) -* [User Data / chffr Account / Crash Reporting](#user-data--chffr-account--crash-reporting) +* [Community Maintained Cars and Features](#community-maintained-cars-and-features) +* [Installation Instructions](#installation-instructions) +* [Limitations of openpilot ALC and LDW](#limitations-of-openpilot-alc-and-ldw) +* [Limitations of openpilot ACC and FCW](#limitations-of-openpilot-acc-and-fcw) +* [Limitations of openpilot DM](#limitations-of-openpilot-dm) +* [User Data and comma Account](#user-data-and-comma-account) +* [Safety and Testing](#safety-and-testing) * [Testing on PC](#testing-on-pc) -* [Contributing](#contributing) +* [Community and Contributing](#community-and-contributing) +* [Directory Structure](#directory-structure) * [Licensing](#licensing) --- -Community +What is openpilot? ------ -openpilot is developed by [comma.ai](https://comma.ai/) and users like you. - -We have a [Twitter you should follow](https://twitter.com/comma_ai). - -Also, we have a several thousand people community on [Discord](https://discord.comma.ai). +[openpilot](http://github.com/commaai/openpilot) is an open source driver assistance system. Currently, openpilot performs the functions of Adaptive Cruise Control (ACC), Automated Lane Centering (ALC), Forward Collision Warning (FCW) and Lane Departure Warning (LDW) for a growing variety of supported [car makes, models and model years](#supported-cars). In addition, while openpilot is engaged, a camera based Driver Monitoring (DM) feature alerts distracted and asleep drivers. - - - - + + + + - - - - + + + +
-Hardware +Integration with Stock Features ------ -At the moment openpilot supports the [EON Dashcam DevKit](https://comma.ai/shop/products/eon-dashcam-devkit). A [panda](https://shop.comma.ai/products/panda-obd-ii-dongle) and a [giraffe](https://comma.ai/shop/products/giraffe/) are recommended tools to interface the EON with the car. We'd like to support other platforms as well. +In all supported cars: +* Stock Lane Keep Assist (LKA) and stock ALC are replaced by openpilot ALC, which only functions when openpilot is engaged by the user. +* Stock LDW is replaced by openpilot LDW. + +Additionally, on specific supported cars (see ACC column in [supported cars](#supported-cars)): +* Stock ACC is replaced by openpilot ACC. +* openpilot FCW operates in addition to stock FCW. -Install openpilot on a neo device by entering ``https://openpilot.comma.ai`` during NEOS setup. +openpilot should preserve all other vehicle's stock features, including, but are not limited to: FCW, Automatic Emergency Braking (AEB), auto high-beam, blind spot warning, and side collision warning. + +Supported Hardware +------ + +At the moment, openpilot supports the [EON DevKit](https://comma.ai/shop/products/eon-dashcam-devkit) and the [comma two](https://comma.ai/shop/products/comma-two-devkit). A [car harness](https://comma.ai/shop/products/car-harness) is recommended to connect the EON or comma two to the car. For experimental purposes, openpilot can also run on an Ubuntu computer with external [webcams](https://github.com/commaai/openpilot/tree/master/tools/webcam). Supported Cars ------ -| Make | Model | Supported Package | Lateral | Longitudinal | No Accel Below | No Steer Below | Giraffe | -| ---------------------| -------------------------| ---------------------| --------| ---------------| -----------------| ---------------|-------------------| -| Acura | ILX 2016-18 | AcuraWatch Plus | Yes | Yes | 25mph1| 25mph | Nidec | -| Acura | RDX 2016-18 | AcuraWatch Plus | Yes | Yes | 25mph1| 12mph | Nidec | -| Buick3 | Regal 2018 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7| -| Chevrolet3| Malibu 2017 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7| -| Chevrolet3| Volt 2017-18 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7| -| Cadillac3 | ATS 2018 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7| -| Chrysler | Pacifica 2017-18 | Adaptive Cruise | Yes | Stock | 0mph | 9mph | FCA | -| Chrysler | Pacifica Hybrid 2017-18 | Adaptive Cruise | Yes | Stock | 0mph | 9mph | FCA | -| Chrysler | Pacifica Hybrid 2019 | Adaptive Cruise | Yes | Stock | 0mph | 39mph | FCA | -| GMC3 | Acadia Denali 2018 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7| -| Holden3 | Astra 2017 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7| -| Honda | Accord 2018-19 | All | Yes | Stock | 0mph | 3mph | Bosch | -| Honda | Accord Hybrid 2018-19 | All | Yes | Stock | 0mph | 3mph | Bosch | -| Honda | Civic Sedan/Coupe 2016-18| Honda Sensing | Yes | Yes | 0mph | 12mph | Nidec | -| 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 | 25mph1| 12mph | Nidec | -| Honda | CR-V 2017-19 | Honda Sensing | Yes | Stock | 0mph | 12mph | Bosch | -| Honda | CR-V Hybrid 2017-2019 | Honda Sensing | Yes | Stock | 0mph | 12mph | Bosch | -| Honda | Odyssey 2018-19 | Honda Sensing | Yes | Yes | 25mph1| 0mph | Inverted Nidec | -| Honda | Passport 2019 | All | Yes | Yes | 25mph1| 12mph | Inverted Nidec | -| Honda | Pilot 2016-18 | Honda Sensing | Yes | Yes | 25mph1| 12mph | Nidec | -| Honda | Pilot 2019 | All | Yes | Yes | 25mph1| 12mph | Inverted Nidec | -| Honda | Ridgeline 2017-19 | Honda Sensing | Yes | Yes | 25mph1| 12mph | Nidec | -| Hyundai | Santa Fe 2019 | All | Yes | Stock | 0mph | 0mph | Custom6| -| Hyundai | Elantra 2017-19 | SCC + LKAS | Yes | Stock | 19mph | 34mph | Custom6| -| Hyundai | Genesis 2018 | All | Yes | Stock | 19mph | 34mph | Custom6| -| Jeep | Grand Cherokee 2016-18 | Adaptive Cruise | Yes | Stock | 0mph | 9mph | FCA | -| Jeep | Grand Cherokee 2019 | Adaptive Cruise | Yes | Stock | 0mph | 39mph | FCA | -| Kia | Optima 2019 | SCC + LKAS | Yes | Stock | 0mph | 0mph | Custom6| -| Kia | Sorento 2018 | All | Yes | Stock | 0mph | 0mph | Custom6| -| Kia | Stinger 2018 | SCC + LKAS | Yes | Stock | 0mph | 0mph | Custom6| -| Lexus | ES Hybrid 2019 | All | Yes | Yes | 0mph | 0mph | Toyota | -| Lexus | RX Hybrid 2016-19 | All | Yes | Yes2| 0mph | 0mph | Toyota | -| Subaru | Crosstrek 2018 | EyeSight | Yes | Stock | 0mph | 0mph | Custom4| -| Subaru | Impreza 2019 | EyeSight | Yes | Stock | 0mph | 0mph | Custom4| -| Toyota | Avalon 2016 | TSS-P | Yes | Yes2| 20mph1| 0mph | Toyota | -| Toyota | Avalon 2017-18 | All | Yes | Yes2| 20mph1| 0mph | Toyota | -| Toyota | Camry 2018-19 | All | Yes | Stock | 0mph5 | 0mph | Toyota | -| Toyota | Camry Hybrid 2018-19 | All | Yes | Stock | 0mph5 | 0mph | Toyota | -| Toyota | C-HR 2017-19 | All | Yes | Stock | 0mph | 0mph | Toyota | -| Toyota | C-HR Hybrid 2017-19 | All | Yes | Stock | 0mph | 0mph | Toyota | -| Toyota | Corolla 2017-19 | All | Yes | Yes2| 20mph1| 0mph | Toyota | -| Toyota | Corolla 2020 | All | Yes | Yes | 0mph | 0mph | Toyota | -| Toyota | Corolla Hatchback 2019 | All | Yes | Yes | 0mph | 0mph | Toyota | -| Toyota | Highlander 2017-19 | All | Yes | Yes2| 0mph | 0mph | Toyota | -| Toyota | Highlander Hybrid 2017-19| All | Yes | Yes2| 0mph | 0mph | Toyota | -| Toyota | Prius 2016 | TSS-P | Yes | Yes2| 0mph | 0mph | Toyota | -| Toyota | Prius 2017-19 | All | Yes | Yes2| 0mph | 0mph | Toyota | -| Toyota | Prius Prime 2017-19 | All | Yes | Yes2| 0mph | 0mph | Toyota | -| Toyota | Rav4 2016 | TSS-P | Yes | Yes2| 20mph1| 0mph | Toyota | -| Toyota | Rav4 2017-18 | All | Yes | Yes2| 20mph1| 0mph | Toyota | -| Toyota | Rav4 2019 | All | Yes | Yes | 0mph | 0mph | Toyota | -| Toyota | Rav4 Hybrid 2016 | TSS-P | Yes | Yes2| 0mph | 0mph | Toyota | -| Toyota | Rav4 Hybrid 2017-18 | All | Yes | Yes2| 0mph | 0mph | Toyota | -| Toyota | Sienna 2018 | All | Yes | Yes2| 0mph | 0mph | Toyota | - -1[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).***
-2When 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).
-3[GM installation guide](https://zoneos.com/volt/).
-4Subaru Giraffe is DIY.
-528mph for Camry 4CYL L, 4CYL LE and 4CYL SE which don't have Full-Speed Range Dynamic Radar Cruise Control.
-6Open 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.
-7Community built Giraffe, find more information [here](https://zoneos.com/shop/).
- -Community Maintained Cars +| Make | Model (US Market Reference) | Supported Package | ACC | No ACC accel below | No ALC below | +| ----------| ------------------------------| ------------------| -----------------| -------------------| ------------------| +| Acura | ILX 2016-19 | AcuraWatch Plus | openpilot | 25mph1 | 25mph | +| Acura | RDX 2016-18 | AcuraWatch Plus | openpilot | 25mph1 | 12mph | +| Acura | RDX 2020 | All | Stock | 0mph | 3mph | +| Honda | Accord 2018-20 | All | Stock | 0mph | 3mph | +| Honda | Accord Hybrid 2018-20 | All | Stock | 0mph | 3mph | +| Honda | Civic Hatchback 2017-21 | Honda Sensing | Stock | 0mph | 12mph | +| Honda | Civic Sedan/Coupe 2016-18 | Honda Sensing | openpilot | 0mph | 12mph | +| Honda | Civic Sedan/Coupe 2019-20 | All | Stock | 0mph | 2mph2 | +| Honda | CR-V 2015-16 | Touring | openpilot | 25mph1 | 12mph | +| Honda | CR-V 2017-20 | Honda Sensing | Stock | 0mph | 12mph | +| Honda | CR-V Hybrid 2017-2019 | Honda Sensing | Stock | 0mph | 12mph | +| Honda | Fit 2018-19 | Honda Sensing | openpilot | 25mph1 | 12mph | +| Honda | HR-V 2019-20 | Honda Sensing | openpilot | 25mph1 | 12mph | +| Honda | Insight 2019-20 | All | Stock | 0mph | 3mph | +| Honda | Inspire 2018 | All | Stock | 0mph | 3mph | +| Honda | Odyssey 2018-20 | Honda Sensing | openpilot | 25mph1 | 0mph | +| Honda | Passport 2019 | All | openpilot | 25mph1 | 12mph | +| Honda | Pilot 2016-19 | Honda Sensing | openpilot | 25mph1 | 12mph | +| Honda | Ridgeline 2017-20 | Honda Sensing | openpilot | 25mph1 | 12mph | +| Hyundai | Palisade 2020 | All | Stock | 0mph | 0mph | +| Hyundai | Sonata 2020-21 | All | Stock | 0mph | 0mph | +| Lexus | CT Hybrid 2017-18 | LSS | Stock3| 0mph | 0mph | +| Lexus | ES 2019-20 | All | openpilot | 0mph | 0mph | +| Lexus | ES Hybrid 2019 | All | openpilot | 0mph | 0mph | +| Lexus | IS 2017-2019 | All | Stock | 22mph | 0mph | +| Lexus | IS Hybrid 2017 | All | Stock | 0mph | 0mph | +| Lexus | NX 2018 | All | Stock3| 0mph | 0mph | +| Lexus | NX Hybrid 2018 | All | Stock3| 0mph | 0mph | +| Lexus | RX 2016-18 | All | Stock3| 0mph | 0mph | +| Lexus | RX 2020-21 | All | openpilot | 0mph | 0mph | +| Lexus | RX Hybrid 2016-19 | All | Stock3| 0mph | 0mph | +| Lexus | RX Hybrid 2020 | All | openpilot | 0mph | 0mph | +| Toyota | Avalon 2016-18 | TSS-P | Stock3| 20mph1 | 0mph | +| Toyota | Camry 2018-20 | All | Stock | 0mph4 | 0mph | +| Toyota | Camry 2021 | All | openpilot | 0mph | 0mph | +| Toyota | Camry Hybrid 2018-20 | All | Stock | 0mph4 | 0mph | +| Toyota | C-HR 2017-19 | All | Stock | 0mph | 0mph | +| Toyota | C-HR Hybrid 2017-19 | All | Stock | 0mph | 0mph | +| Toyota | Corolla 2017-19 | All | Stock3| 20mph1 | 0mph | +| Toyota | Corolla 2020-21 | All | openpilot | 0mph | 0mph | +| Toyota | Corolla Hatchback 2019-20 | All | openpilot | 0mph | 0mph | +| Toyota | Corolla Hybrid 2020-21 | All | openpilot | 0mph | 0mph | +| Toyota | Highlander 2017-19 | All | Stock3| 0mph | 0mph | +| Toyota | Highlander 2020-21 | All | openpilot | 0mph | 0mph | +| Toyota | Highlander Hybrid 2017-19 | All | Stock3| 0mph | 0mph | +| Toyota | Highlander Hybrid 2020-21 | All | openpilot | 0mph | 0mph | +| Toyota | Prius 2016-20 | TSS-P | Stock3| 0mph | 0mph | +| Toyota | Prius 2021 | All | openpilot | 0mph | 0mph | +| Toyota | Prius Prime 2017-20 | All | Stock3| 0mph | 0mph | +| Toyota | Rav4 2016-18 | TSS-P | Stock3| 20mph1 | 0mph | +| Toyota | Rav4 2019-21 | All | openpilot | 0mph | 0mph | +| Toyota | Rav4 Hybrid 2016-18 | TSS-P | Stock3| 0mph | 0mph | +| Toyota | Rav4 Hybrid 2019-21 | All | openpilot | 0mph | 0mph | +| Toyota | Sienna 2018-20 | All | Stock3| 0mph | 0mph | + +1[Comma Pedal](https://github.com/commaai/openpilot/wiki/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. ***NOTE: The Comma Pedal is not officially supported by [comma](https://comma.ai).***
+22019 Honda Civic 1.6L Diesel Sedan does not have ALC below 12mph.
+3When disconnecting the Driver Support Unit (DSU), openpilot ACC will replace stock ACC. ***NOTE: disconnecting the DSU disables Automatic Emergency Braking (AEB).***
+428mph for Camry 4CYL L, 4CYL LE and 4CYL SE which don't have Full-Speed Range Dynamic Radar Cruise Control.
+ +Community Maintained Cars and Features +------ + +| Make | Model (US Market Reference) | Supported Package | ACC | No ACC accel below | No ALC below | +| ----------| ------------------------------| ------------------| -----------------| -------------------| -------------| +| Buick | Regal 20181 | Adaptive Cruise | openpilot | 0mph | 7mph | +| Cadillac | ATS 20181 | Adaptive Cruise | openpilot | 0mph | 7mph | +| Chevrolet | Malibu 20171 | Adaptive Cruise | openpilot | 0mph | 7mph | +| Chevrolet | Volt 2017-181 | Adaptive Cruise | openpilot | 0mph | 7mph | +| Chrysler | Pacifica 2017-18 | Adaptive Cruise | Stock | 0mph | 9mph | +| Chrysler | Pacifica 2020 | Adaptive Cruise | Stock | 0mph | 39mph | +| Chrysler | Pacifica Hybrid 2017-18 | Adaptive Cruise | Stock | 0mph | 9mph | +| Chrysler | Pacifica Hybrid 2019-20 | Adaptive Cruise | Stock | 0mph | 39mph | +| Genesis | G70 2018 | All | Stock | 0mph | 0mph | +| Genesis | G80 2018 | All | Stock | 0mph | 0mph | +| Genesis | G90 2018 | All | Stock | 0mph | 0mph | +| GMC | Acadia 20181 | Adaptive Cruise | openpilot | 0mph | 7mph | +| Holden | Astra 20171 | Adaptive Cruise | openpilot | 0mph | 7mph | +| Hyundai | Elantra 2017-19 | SCC + LKAS | Stock | 19mph | 34mph | +| Hyundai | Genesis 2015-16 | SCC + LKAS | Stock | 19mph | 37mph | +| Hyundai | Ioniq Electric 2019 | SCC + LKAS | Stock | 0mph | 32mph | +| Hyundai | Ioniq Electric 2020 | SCC + LKAS | Stock | 0mph | 0mph | +| Hyundai | Kona 2020 | SCC + LKAS | Stock | 0mph | 0mph | +| Hyundai | Kona EV 2019 | SCC + LKAS | Stock | 0mph | 0mph | +| Hyundai | Santa Fe 2019 | All | Stock | 0mph | 0mph | +| Hyundai | Sonata 2019 | SCC + LKAS | Stock | 0mph | 0mph | +| Hyundai | Veloster 2019 | SCC + LKAS | Stock | 5mph | 0mph | +| Jeep | Grand Cherokee 2016-18 | Adaptive Cruise | Stock | 0mph | 9mph | +| Jeep | Grand Cherokee 2019-20 | Adaptive Cruise | Stock | 0mph | 39mph | +| Kia | Forte 2018-19 | SCC + LKAS | Stock | 0mph | 0mph | +| Kia | Niro EV 2020 | SCC + LKAS | Stock | 0mph | 0mph | +| Kia | Optima 2017 | SCC + LKAS | Stock | 0mph | 32mph | +| Kia | Optima 2019 | SCC + LKAS | Stock | 0mph | 0mph | +| Kia | Sorento 2018 | SCC + LKAS | Stock | 0mph | 0mph | +| Kia | Stinger 2018 | SCC + LKAS | Stock | 0mph | 0mph | +| Nissan | Leaf 2018-20 | ProPILOT | Stock | 0mph | 0mph | +| Nissan | Rogue 2018-19 | ProPILOT | Stock | 0mph | 0mph | +| Nissan | X-Trail 2017 | ProPILOT | Stock | 0mph | 0mph | +| Subaru | Ascent 2019 | EyeSight | Stock | 0mph | 0mph | +| Subaru | Crosstrek 2018-19 | EyeSight | Stock | 0mph | 0mph | +| Subaru | Forester 2019-20 | EyeSight | Stock | 0mph | 0mph | +| Subaru | Impreza 2017-19 | EyeSight | Stock | 0mph | 0mph | +| Volkswagen| Golf 2015-19 | Driver Assistance | Stock | 0mph | 0mph | + +1Requires an [OBD-II car harness](https://comma.ai/shop/products/comma-car-harness) and [community built ASCM harness](https://github.com/commaai/openpilot/wiki/GM#hardware). ***NOTE: disconnecting the ASCM disables Automatic Emergency Braking (AEB).***
+ +Although it's not upstream, there's a community of people getting openpilot to run on Tesla's [here](https://tinkla.us/) + +Community Maintained Cars and Features are not verified by comma to meet our [safety model](SAFETY.md). Be extra cautious using them. They are only available after enabling the toggle in `Settings->Developer->Enable Community Features`. + +To promote a car from community maintained, it must meet a few requirements. We must own one from the brand, we must sell the harness for it, has full ISO26262 in both panda and openpilot, there must be a path forward for longitudinal control, it must have AEB still enabled, and it must support fingerprinting 2.0 + +Installation Instructions ------ -| Make | Model | Supported Package | Lateral | Longitudinal | No Accel Below | No Steer Below | Giraffe | -| ---------------------| -------------------------| ---------------------| --------| ---------------| -----------------| ---------------|-------------------| -| Honda | Fit 2018 | Honda Sensing | Yes | Yes | 25mph1| 12mph | Inverted Nidec | -| Tesla | Model S 2012-13 | All | Yes | Not yet | Not applicable | 0mph | Custom8| +Install openpilot on an EON or comma two by entering ``https://openpilot.comma.ai`` during the installer setup. + +Follow these [video instructions](https://youtu.be/lcjqxCymins) to properly mount the device on the windshield. Note: openpilot features an automatic pose calibration routine and openpilot performance should not be affected by small pitch and yaw misalignments caused by imprecise device mounting. -[[Honda Fit Pull Request]](https://github.com/commaai/openpilot/pull/266).
-[[Tesla Model S Pull Request]](https://github.com/commaai/openpilot/pull/246)
-8Community built Giraffe, find more information here [Community Tesla Giraffe](https://github.com/jeankalud/neo/tree/tesla_giraffe/giraffe/tesla)
+Before placing the device on your windshield, check the state and local laws and ordinances where you drive. Some state laws prohibit or restrict the placement of objects on the windshield of a motor vehicle. -Community Maintained Cars are not confirmed by comma.ai to meet our [safety model](https://github.com/commaai/openpilot/blob/devel/SAFETY.md). Be extra cautious using them. +You will be able to engage openpilot after reviewing the onboarding screens and finishing the calibration procedure. -In Progress Cars +Limitations of openpilot ALC and LDW ------ -- All TSS-P Toyota with Steering Assist and LSS-P Lexus with Steering Assist or Lane Keep Assist. - - Only remaining Toyota cars with no port yet are the Avalon and the Sienna. -- All Hyundai with SmartSense. -- All Kia with SCC and LKAS. -- All Chrysler, Jeep, Fiat with Adaptive Cruise Control and LaneSense. -How can I add support for my car? +openpilot ALC and openpilot LDW do not automatically drive the vehicle or reduce the amount of attention that must be paid to operate your vehicle. The driver must always keep control of the steering wheel and be ready to correct the openpilot ALC action at all times. + +While changing lanes, openpilot is not capable of looking next to you or checking your blind spot. Only nudge the wheel to initiate a lane change after you have confirmed it's safe to do so. + +Many factors can impact the performance of openpilot ALC and openpilot LDW, causing them to be unable to function as intended. These include, but are not limited to: + +* Poor visibility (heavy rain, snow, fog, etc.) or weather conditions that may interfere with sensor operation. +* The road facing camera is obstructed, covered or damaged by mud, ice, snow, etc. +* Obstruction caused by applying excessive paint or adhesive products (such as wraps, stickers, rubber coating, etc.) onto the vehicle. +* The device is mounted incorrectly. +* When in sharp curves, like on-off ramps, intersections etc...; openpilot is designed to be limited in the amount of steering torque it can produce. +* In the presence of restricted lanes or construction zones. +* When driving on highly banked roads or in presence of strong cross-wind. +* Extremely hot or cold temperatures. +* Bright light (due to oncoming headlights, direct sunlight, etc.). +* Driving on hills, narrow, or winding roads. + +The list above does not represent an exhaustive list of situations that may interfere with proper operation of openpilot components. It is the driver's responsibility to be in control of the vehicle at all times. + +Limitations of openpilot ACC and FCW +------ + +openpilot ACC and openpilot FCW are not systems that allow careless or inattentive driving. It is still necessary for the driver to pay close attention to the vehicle’s surroundings and to be ready to re-take control of the gas and the brake at all times. + +Many factors can impact the performance of openpilot ACC and openpilot FCW, causing them to be unable to function as intended. These include, but are not limited to: + +* Poor visibility (heavy rain, snow, fog, etc.) or weather conditions that may interfere with sensor operation. +* The road facing camera or radar are obstructed, covered, or damaged by mud, ice, snow, etc. +* Obstruction caused by applying excessive paint or adhesive products (such as wraps, stickers, rubber coating, etc.) onto the vehicle. +* The device is mounted incorrectly. +* Approaching a toll booth, a bridge or a large metal plate. +* When driving on roads with pedestrians, cyclists, etc... +* In presence of traffic signs or stop lights, which are not detected by openpilot at this time. +* When the posted speed limit is below the user selected set speed. openpilot does not detect speed limits at this time. +* In presence of vehicles in the same lane that are not moving. +* When abrupt braking maneuvers are required. openpilot is designed to be limited in the amount of deceleration and acceleration that it can produce. +* When surrounding vehicles perform close cut-ins from neighbor lanes. +* Driving on hills, narrow, or winding roads. +* Extremely hot or cold temperatures. +* Bright light (due to oncoming headlights, direct sunlight, etc.). +* Interference from other equipment that generates radar waves. + +The list above does not represent an exhaustive list of situations that may interfere with proper operation of openpilot components. It is the driver's responsibility to be in control of the vehicle at all times. + +Limitations of openpilot DM +------ + +openpilot DM should not be considered an exact measurement of the alertness of the driver. + +Many factors can impact the performance of openpilot DM, causing it to be unable to function as intended. These include, but are not limited to: + +* Low light conditions, such as driving at night or in dark tunnels. +* Bright light (due to oncoming headlights, direct sunlight, etc.). +* The driver's face is partially or completely outside field of view of the driver facing camera. +* The driver facing camera is obstructed, covered, or damaged. + +The list above does not represent an exhaustive list of situations that may interfere with proper operation of openpilot components. A driver should not rely on openpilot DM to assess their level of attention. + +User Data and comma Account ------ -If your car has adaptive cruise control and lane keep assist, you are in luck. Using a [panda](https://comma.ai/shop/products/panda-obd-ii-dongle/) and [cabana](https://community.comma.ai/cabana/), you can understand how to make your car drive by wire. +By default, openpilot uploads the driving data to our servers. You can also access your data by pairing with the comma connect app ([iOS](https://apps.apple.com/us/app/comma-connect/id1456551889), [Android](https://play.google.com/store/apps/details?id=ai.comma.connect&hl=en_US)). We use your data to train better models and improve openpilot for everyone. + +openpilot is open source software: the user is free to disable data collection if they wish to do so. + +openpilot logs the road facing camera, CAN, GPS, IMU, magnetometer, thermal sensors, crashes, and operating system logs. +The driver facing camera is only logged if you explicitly opt-in in settings. The microphone is not recorded. + +By using openpilot, you agree to [our Privacy Policy](https://my.comma.ai/privacy). You understand that use of this software or its related services will generate certain types of user data, which may be logged and stored at the sole discretion of comma. By accepting this agreement, you grant an irrevocable, perpetual, worldwide right to comma for the use of this data. -We've written guides for [Brand](https://medium.com/@comma_ai/how-to-write-a-car-port-for-openpilot-7ce0785eda84) and [Model](https://medium.com/@comma_ai/openpilot-port-guide-for-toyota-models-e5467f4b5fe6) ports. These guides might help you after you have the basics figured out. +Safety and Testing +---- -- BMW, Audi, Volvo, and Mercedes all use [FlexRay](https://en.wikipedia.org/wiki/FlexRay) and can be supported after [FlexRay support](https://github.com/commaai/openpilot/pull/463) is merged. -- We put time into a Ford port, but the steering has a 10 second cutout limitation that makes it unusable. -- The 2016-2017 Honda Accord uses a custom signaling protocol for steering that's unlikely to ever be upstreamed. +* openpilot observes ISO26262 guidelines, see [SAFETY.md](SAFETY.md) for more detail. +* openpilot has software in the loop [tests](.github/workflows/test.yaml) that run on every commit. +* The safety model code lives in panda and is written in C, see [code rigor](https://github.com/commaai/panda#code-rigor) for more details. +* panda has software in the loop [safety tests](https://github.com/commaai/panda/tree/master/tests/safety). +* Internally, we have a hardware in the loop Jenkins test suite that builds and unit tests the various processes. +* panda has additional hardware in the loop [tests](https://github.com/commaai/panda/blob/master/Jenkinsfile). +* We run the latest openpilot in a testing closet containing 10 EONs continuously replaying routes. -Directory structure +Testing on PC +------ +For simplified development and experimentation, openpilot can be run in the CARLA driving simulator, which allows you to develop openpilot without a car. The whole setup should only take a few minutes. + +Steps: +1) Start the CARLA server on first terminal +``` +bash -c "$(curl https://raw.githubusercontent.com/commaai/openpilot/master/tools/sim/start_carla.sh)" +``` +2) Start openpilot on second terminal +``` +bash -c "$(curl https://raw.githubusercontent.com/commaai/openpilot/master/tools/sim/start_openpilot_docker.sh)" +``` +3) Press 1 to engage openpilot + +See the full [README](tools/sim/README.md) + +You should also take a look at the tools directory in master: lots of tools you can use to replay driving data, test, and develop openpilot from your PC. + + +Community and Contributing +------ + +openpilot is developed by [comma](https://comma.ai/) and by users like you. We welcome both pull requests and issues on [GitHub](http://github.com/commaai/openpilot). Bug fixes and new car ports are encouraged. + +You can add support for your car by following guides we have written for [Brand](https://medium.com/@comma_ai/how-to-write-a-car-port-for-openpilot-7ce0785eda84) and [Model](https://medium.com/@comma_ai/openpilot-port-guide-for-toyota-models-e5467f4b5fe6) ports. Generally, a car with adaptive cruise control and lane keep assist is a good candidate. [Join our Discord](https://discord.comma.ai) to discuss car ports: most car makes have a dedicated channel. + +Want to get paid to work on openpilot? [comma is hiring](https://comma.ai/jobs/). + +And [follow us on Twitter](https://twitter.com/comma_ai). + +Directory Structure ------ . ├── apk # The apk files used for the UI - ├── cereal # The messaging spec used for all logs on EON + ├── cereal # The messaging spec and libs used for all logs ├── common # Library like functionality we've developed here ├── installer/updater # Manages auto-updates of openpilot ├── opendbc # Files showing how to interpret data from cars - ├── panda # Code used to communicate on CAN and LIN - ├── phonelibs # Libraries used on EON - ├── pyextra # Libraries used on EON + ├── panda # Code used to communicate on CAN + ├── phonelibs # Libraries used on NEOS devices + ├── pyextra # Libraries used on NEOS devices └── selfdrive # Code needed to drive the car - ├── assets # Fonts and images for UI + ├── assets # Fonts, images and sounds for UI ├── athena # Allows communication with the app ├── boardd # Daemon to talk to the board - ├── can # Helpers for parsing CAN messages + ├── camerad # Driver to capture images from the camera sensors ├── car # Car specific code to read states and control actuators ├── common # Shared C/C++ code for the daemons ├── controls # Perception, planning and controls @@ -186,54 +331,20 @@ Directory structure ├── locationd # Soon to be home of precise location ├── logcatd # Android logcat as a service ├── loggerd # Logger and uploader of car data + ├── modeld # Driving and monitoring model runners ├── proclogd # Logs information from proc ├── sensord # IMU / GPS interface code - ├── test # Car simulator running code through virtual maneuvers - ├── ui # The UI - └── visiond # Vision pipeline - -To understand how the services interact, see `selfdrive/service_list.yaml` - -User Data / chffr Account / Crash Reporting ------- + ├── test # Unit tests, system tests and a car simulator + └── ui # The UI -By default, openpilot creates an account and includes a client for chffr, our dashcam app. We use your data to train better models and improve openpilot for everyone. - -It's open source software, so you are free to disable it if you wish. - -It logs the road facing camera, CAN, GPS, IMU, magnetometer, thermal sensors, crashes, and operating system logs. -The user facing camera is only logged if you explicitly opt-in in settings. -It does not log the microphone. - -By using it, you agree to [our privacy policy](https://community.comma.ai/privacy.html). You understand that use of this software or its related services will generate certain types of user data, which may be logged and stored at the sole discretion of comma.ai. By accepting this agreement, you grant an irrevocable, perpetual, worldwide right to comma.ai for the use of this data. - -Testing on PC ------- - -Check out [openpilot-tools](https://github.com/commaai/openpilot-tools): lots of tools you can use to replay driving data, test and develop openpilot from your pc. - -Also, within openpilot there is a rudimentary infrastructure to run a basic simulation and generate a report of openpilot's behavior in different longitudinal control scenarios. - -```bash -# Requires working docker -./run_docker_tests.sh -``` - -Contributing ------- - -We welcome both pull requests and issues on [github](http://github.com/commaai/openpilot). Bug fixes and new car ports encouraged. - -We also have a [bounty program](https://comma.ai/bounties.html). - -Want to get paid to work on openpilot? [comma.ai is hiring](https://comma.ai/jobs/) +To understand how the services interact, see `cereal/service_list.yaml`. Licensing ------ openpilot is released under the MIT license. Some parts of the software are released under other licenses as specified. -Any user of this software shall indemnify and hold harmless Comma.ai, Inc. and its directors, officers, employees, agents, stockholders, affiliates, subcontractors and customers from and against all allegations, claims, actions, suits, demands, damages, liabilities, obligations, losses, settlements, judgments, costs and expenses (including without limitation attorneys’ fees and costs) which arise out of, relate to or result from any use of this software by user. +Any user of this software shall indemnify and hold harmless comma.ai, Inc. and its directors, officers, employees, agents, stockholders, affiliates, subcontractors and customers from and against all allegations, claims, actions, suits, demands, damages, liabilities, obligations, losses, settlements, judgments, costs and expenses (including without limitation attorneys’ fees and costs) which arise out of, relate to or result from any use of this software by user. **THIS IS ALPHA QUALITY SOFTWARE FOR RESEARCH PURPOSES ONLY. THIS IS NOT A PRODUCT. YOU ARE RESPONSIBLE FOR COMPLYING WITH LOCAL LAWS AND REGULATIONS. @@ -242,3 +353,9 @@ NO WARRANTY EXPRESSED OR IMPLIED.** --- + +[![openpilot tests](https://github.com/commaai/openpilot/workflows/openpilot%20tests/badge.svg?event=push)](https://github.com/commaai/openpilot/actions) +[![Total alerts](https://img.shields.io/lgtm/alerts/g/commaai/openpilot.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/commaai/openpilot/alerts/) +[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/commaai/openpilot.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/commaai/openpilot/context:python) +[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/commaai/openpilot.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/commaai/openpilot/context:cpp) +[![codecov](https://codecov.io/gh/commaai/openpilot/branch/master/graph/badge.svg)](https://codecov.io/gh/commaai/openpilot) diff --git a/README_chffrplus.md b/README_chffrplus.md deleted file mode 100644 index dc13e8c3f264c6..00000000000000 --- a/README_chffrplus.md +++ /dev/null @@ -1,36 +0,0 @@ -Welcome to chffrplus -====== - -[chffrplus](https://github.com/commaai/chffrplus) is an open source dashcam. - -This is the shipping reference software for the comma EON Dashcam DevKit. It keeps many of the niceities of [openpilot](https://github.com/commaai/openpilot), like high quality sensors, great camera, and good autostart and stop. Though unlike openpilot, it cannot control your car. chffrplus can interface with your car through a [panda](https://shop.comma.ai/products/panda-obd-ii-dongle), but just like our dashcam app [chffr](https://getchffr.com/), it is read only. - -It integrates with the rest of the comma ecosystem, so you can view your drives on the [chffr](https://getchffr.com/) app for Android or iOS, and reverse engineer your car with [cabana](https://community.comma.ai/cabana/?demo=1). - - -Hardware ------- - -Right now chffrplus supports the [EON Dashcam DevKit](https://shop.comma.ai/products/eon-dashcam-devkit) for hardware to run on. - -Install chffrplus on a EON device by entering ``https://chffrplus.comma.ai`` during NEOS setup. - - -User Data / chffr Account / Crash Reporting ------- - -By default chffrplus creates an account and includes a client for chffr, our dashcam app. - -It's open source software, so you are free to disable it if you wish. - -It logs the road facing camera, CAN, GPS, IMU, magnetometer, thermal sensors, crashes, and operating system logs. -It does not log the user facing camera or the microphone. - -By using it, you agree to [our privacy policy](https://beta.comma.ai/privacy.html). You understand that use of this software or its related services will generate certain types of user data, which may be logged and stored at the sole discretion of comma.ai. By accepting this agreement, you grant an irrevocable, perpetual, worldwide right to comma.ai for the use of this data. - - -Licensing ------- - -chffrplus is released under the MIT license. - diff --git a/RELEASES.md b/RELEASES.md index d847bb3f05bc8b..c427e60ddb5fcc 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,173 @@ +Version 0.8.1 (2020-12-21) +======================== + * Original EON is deprecated, upgrade to comma two + * Better model performance in heavy rain + * Better lane positioning in turns + * Fixed bug where model would cut turns on empty roads at night + * Fixed issue where some Toyotas would not completely stop thanks to briskspirit! + * Toyota Camry 2021 with TSS2.5 support + * Hyundai Ioniq Electric 2020 support thanks to baldwalker! + +Version 0.8.0 (2020-11-30) +======================== + * New driving model: fully 3D and improved cut-in detection + * UI draws 2 road edges, 4 lanelines and paths in 3D + * Major fixes to cut-in detection for openpilot longitudinal + * Grey panda is no longer supported, upgrade to comma two or black panda + * Lexus NX 2018 support thanks to matt12eagles! + * Kia Niro EV 2020 support thanks to nickn17! + * Toyota Prius 2021 support thanks to rav4kumar! + * Improved lane positioning with uncertain lanelines, wide lanes and exits + * Improved lateral control for Prius and Subaru + +Version 0.7.10 (2020-10-29) +======================== + * Grey panda is deprecated, upgrade to comma two or black panda + * NEOS update: update to Python 3.8.2 and lower CPU frequency + * Improved thermals due to reduced CPU frequency + * Update SNPE to 1.41.0 + * Reduced offroad power consumption + * Various system stability improvements + * Acura RDX 2020 support thanks to csouers! + +Version 0.7.9 (2020-10-09) +======================== + * Improved car battery power management + * Improved updater robustness + * Improved realtime performance + * Reduced UI and modeld lags + * Increased torque on 2020 Hyundai Sonata and Palisade + +Version 0.7.8 (2020-08-19) +======================== + * New driver monitoring model: improved face detection and better compatibility with sunglasses + * Download NEOS operating system updates in the background + * Improved updater reliability and responsiveness + * Hyundai Kona 2020, Veloster 2019, and Genesis G70 2018 support thanks to xps-genesis! + +Version 0.7.7 (2020-07-20) +======================== + * White panda is no longer supported, upgrade to comma two or black panda + * Improved vehicle model estimation using high precision localizer + * Improved thermal management on comma two + * Improved autofocus for road-facing camera + * Improved noise performance for driver-facing camera + * Block lane change start using blindspot monitor on select Toyota, Hyundai, and Subaru + * Fix GM ignition detection + * Code cleanup and smaller release sizes + * Hyundai Sonata 2020 promoted to officially supported car + * Hyundai Ioniq Electric Limited 2019 and Ioniq SE 2020 support thanks to baldwalker! + * Subaru Forester 2019 and Ascent 2019 support thanks to martinl! + +Version 0.7.6.1 (2020-06-16) +======================== + * Hotfix: update kernel on some comma twos (orders #8570-#8680) + +Version 0.7.6 (2020-06-05) +======================== + * White panda is deprecated, upgrade to comma two or black panda + * 2017 Nissan X-Trail, 2018-19 Leaf and 2019 Rogue support thanks to avolmensky! + * 2017 Mazda CX-5 support in dashcam mode thanks to Jafaral! + * Huge CPU savings in modeld by using thneed! + * Lots of code cleanup and refactors + +Version 0.7.5 (2020-05-13) +======================== + * Right-Hand Drive support for both driving and driver monitoring! + * New driving model: improved at sharp turns and lead speed estimation + * New driver monitoring model: overall improvement on comma two + * Driver camera preview in settings to improve mounting position + * Added support for many Hyundai, Kia, Genesis models thanks to xx979xx! + * Improved lateral tuning for 2020 Toyota Rav 4 (hybrid) + +Version 0.7.4 (2020-03-20) +======================== + * New driving model: improved lane changes and lead car detection + * Improved driver monitoring model: improve eye detection + * Improved calibration stability + * Improved lateral control on some 2019 and 2020 Toyota Prius + * Improved lateral control on VW Golf: 20% more steering torque + * Fixed bug where some 2017 and 2018 Toyota C-HR would use the wrong steering angle sensor + * Support for Honda Insight thanks to theantihero! + * Code cleanup in car abstraction layers and ui + +Version 0.7.3 (2020-02-21) +======================== + * Support for 2020 Highlander thanks to che220! + * Support for 2018 Lexus NX 300h thanks to kengggg! + * Speed up ECU firmware query + * Fix bug where manager would sometimes hang after shutting down the car + +Version 0.7.2 (2020-02-07) +======================== + * ECU firmware version based fingerprinting for Honda & Toyota + * New driving model: improved path prediction during turns and lane changes and better lead speed tracking + * Improve driver monitoring under extreme lighting and add low accuracy alert + * Support for 2019 Rav4 Hybrid thanks to illumiN8i! + * Support for 2016, 2017 and 2020 Lexus RX thanks to illumiN8i! + * Support for 2020 Chrysler Pacifica Hybrid thanks to adhintz! + +Version 0.7.1 (2020-01-20) +======================== + * comma two support! + * Lane Change Assist above 45 mph! + * Replace zmq with custom messaging library, msgq! + * Supercombo model: calibration and driving models are combined for better lead estimate + * More robust updater thanks to jyoung8607! Requires NEOS update + * Improve low speed ACC tuning + +Version 0.7 (2019-12-13) +======================== + * Move to SCons build system! + * Add Lane Departure Warning (LDW) for all supported vehicles! + * NEOS update: increase wifi speed thanks to jyoung8607! + * Adaptive driver monitoring based on scene + * New driving model trained end-to-end: improve lane lines and lead detection + * Smarter torque limit alerts for all cars + * Improve GM longitudinal control: proper computations for 15Hz radar + * Move GM port, Toyota with DSU removed, comma pedal in community features; toggle switch required + * Remove upload over cellular toggle: only upload qlog and qcamera files if not on wifi + * Refactor Panda code towards ISO26262 and SIL2 compliancy + * Forward stock FCW for Honda Nidec + * Volkswagen port now standard: comma Harness intercepts stock camera + +Version 0.6.6 (2019-11-05) +======================== + * Volkswagen support thanks to jyoung8607! + * Toyota Corolla Hybrid with TSS 2.0 support thanks to u8511049! + * Lexus ES with TSS 2.0 support thanks to energee! + * Fix GM ignition detection and lock safety mode not required anymore + * Log panda firmware and dongle ID thanks to martinl! + * New driving model: improve path prediction and lead detection + * New driver monitoring model, 4x smaller and running on DSP + * Display an alert and don't start openpilot if panda has wrong firmware + * Fix bug preventing EON from terminating processes after a drive + * Remove support for Toyota giraffe without the 120Ohm resistor + +Version 0.6.5 (2019-10-07) +======================== + * NEOS update: upgrade to Python3 and new installer! + * comma Harness support! + * New driving model: improve path prediction + * New driver monitoring model: more accurate face and eye detection + * Redesign offroad screen to display updates and alerts + * Increase maximum allowed acceleration + * Prevent car 12V battery drain by cutting off EON charge after 3 days of no drive + * Lexus CT Hybrid support thanks to thomaspich! + * Louder chime for critical alerts + * Add toggle to switch to dashcam mode + * Fix "invalid vehicle params" error on DSU-less Toyota + +Version 0.6.4 (2019-09-08) +======================== + * Forward stock AEB for Honda Nidec + * Improve lane centering on banked roads + * Always-on forward collision warning + * Always-on driver monitoring, except for right hand drive countries + * Driver monitoring learns the user's normal driving position + * Honda Fit support thanks to energee! + * Lexus IS support + Version 0.6.3 (2019-08-12) ======================== * Alert sounds from EON: requires NEOS update @@ -38,7 +208,7 @@ Version 0.6 (2019-07-01) * Panda safety code is MISRA compliant and ships with a signed version on release2 * New NEOS is 500MB smaller and has a reproducible usr/pipenv * Lexus ES Hybrid support thanks to wocsor! - * Improve tuning for supported Toyota with TSS2 + * Improve tuning for supported Toyota with TSS 2.0 * Various other stability improvements Version 0.5.13 (2019-05-31) @@ -344,96 +514,96 @@ Version 0.3.4 (2017-07-28) Version 0.3.3 (2017-06-28) =========================== - * Improved model trained on more data - * Alpha CR-V support thanks to energee and johnnwvs! - * Using the opendbc project for DBC files - * Minor performance improvements - * UI update thanks to pjlao307 - * Power off button - * 6% more torque on the Civic + * Improved model trained on more data + * Alpha CR-V support thanks to energee and johnnwvs! + * Using the opendbc project for DBC files + * Minor performance improvements + * UI update thanks to pjlao307 + * Power off button + * 6% more torque on the Civic Version 0.3.2 (2017-05-22) =========================== - * Minor stability bugfixes - * Added metrics and rear view mirror disable to settings - * Update model with more crowdsourced data + * Minor stability bugfixes + * Added metrics and rear view mirror disable to settings + * Update model with more crowdsourced data Version 0.3.1 (2017-05-17) =========================== - * visiond stability bugfix - * Add logging for angle and flashing + * visiond stability bugfix + * Add logging for angle and flashing Version 0.3.0 (2017-05-12) =========================== - * Add CarParams struct to improve the abstraction layer - * Refactor visiond IPC to support multiple clients - * Add raw GPS and beginning support for navigation - * Improve model in visiond using crowdsourced data - * Add improved system logging to diagnose instability - * Rewrite baseui in React Native - * Moved calibration to the cloud + * Add CarParams struct to improve the abstraction layer + * Refactor visiond IPC to support multiple clients + * Add raw GPS and beginning support for navigation + * Improve model in visiond using crowdsourced data + * Add improved system logging to diagnose instability + * Rewrite baseui in React Native + * Moved calibration to the cloud Version 0.2.9 (2017-03-01) =========================== - * Retain compatibility with NEOS v1 + * Retain compatibility with NEOS v1 Version 0.2.8 (2017-02-27) =========================== - * Fix bug where frames were being dropped in minute 71 + * Fix bug where frames were being dropped in minute 71 Version 0.2.7 (2017-02-08) =========================== - * Better performance and pictures at night - * Fix ptr alignment issue in boardd - * Fix brake error light, fix crash if too cold + * Better performance and pictures at night + * Fix ptr alignment issue in boardd + * Fix brake error light, fix crash if too cold Version 0.2.6 (2017-01-31) =========================== - * Fix bug in visiond model execution + * Fix bug in visiond model execution Version 0.2.5 (2017-01-30) =========================== - * Fix race condition in manager + * Fix race condition in manager Version 0.2.4 (2017-01-27) =========================== - * OnePlus 3T support - * Enable installation as NEOS app - * Various minor bugfixes + * OnePlus 3T support + * Enable installation as NEOS app + * Various minor bugfixes Version 0.2.3 (2017-01-11) =========================== - * Reduce space usage by 80% - * Add better logging - * Add Travis CI + * Reduce space usage by 80% + * Add better logging + * Add Travis CI Version 0.2.2 (2017-01-10) =========================== - * Board triggers started signal on CAN messages - * Improved autoexposure - * Handle out of space, improve upload status + * Board triggers started signal on CAN messages + * Improved autoexposure + * Handle out of space, improve upload status Version 0.2.1 (2016-12-14) =========================== - * Performance improvements, removal of more numpy - * Fix boardd process priority - * Make counter timer reset on use of steering wheel + * Performance improvements, removal of more numpy + * Fix boardd process priority + * Make counter timer reset on use of steering wheel Version 0.2 (2016-12-12) ========================= - * Car/Radar abstraction layers have shipped, see cereal/car.capnp - * controlsd has been refactored - * Shipped plant model and testing maneuvers - * visiond exits more gracefully now - * Hardware encoder in visiond should always init - * ui now turns off the screen after 30 seconds - * Switch to openpilot release branch for future releases - * Added preliminary Docker container to run tests on PC + * Car/Radar abstraction layers have shipped, see cereal/car.capnp + * controlsd has been refactored + * Shipped plant model and testing maneuvers + * visiond exits more gracefully now + * Hardware encoder in visiond should always init + * ui now turns off the screen after 30 seconds + * Switch to openpilot release branch for future releases + * Added preliminary Docker container to run tests on PC Version 0.1 (2016-11-29) ========================= - * Initial release of openpilot - * Adaptive cruise control is working - * Lane keep assist is working - * Support for Acura ILX 2016 with AcuraWatch Plus - * Support for Honda Civic 2016 Touring Edition + * Initial release of openpilot + * Adaptive cruise control is working + * Lane keep assist is working + * Support for Acura ILX 2016 with AcuraWatch Plus + * Support for Honda Civic 2016 Touring Edition diff --git a/SAFETY.md b/SAFETY.md index 3cda811e0cd9f9..9cf8933b930987 100644 --- a/SAFETY.md +++ b/SAFETY.md @@ -1,151 +1,34 @@ openpilot Safety ====== -openpilot is an Adaptive Cruise Control (ACC) and Lane Keeping Assist (LKA) system. -Like other ACC and LKA systems, openpilot requires the driver to be alert and to -pay attention at all times. We repeat, **driver alertness is necessary, but not -sufficient, for openpilot to be used safely**. +openpilot is an Adaptive Cruise Control (ACC) and Automated Lane Centering (ALC) system. +Like other ACC and ALC systems, openpilot is a failsafe passive system and it requires the +driver to be alert and to pay attention at all times. In order to enforce driver alertness, openpilot includes a driver monitoring feature that alerts the driver when distracted. However, even with an attentive driver, we must make further efforts for the system to be -safe. We have designed openpilot with two other safety considerations. +safe. We repeat, **driver alertness is necessary, but not sufficient, for openpilot to be +used safely** and openpilot is provided with no warranty of fitness for any purpose. -1. The driver must always be capable to immediately retake manual control of the vehicle, +openpilot is developed in good faith to be compliant with FMVSS requirements and to follow +industry standards of safety for Level 2 Driver Assistance Systems. In particular, we observe +ISO26262 guidelines, including those from [pertinent documents](https://www.nhtsa.gov/sites/nhtsa.dot.gov/files/documents/13498a_812_573_alcsystemreport.pdf) +released by NHTSA. In addition, we impose strict coding guidelines (like [MISRA C : 2012](https://www.misra.org.uk/MISRAHome/MISRAC2012/tabid/196/Default.aspx)) +on parts of openpilot that are safety relevant. We also perform software-in-the-loop, +hardware-in-the-loop and in-vehicle tests before each software release. + +Following Hazard and Risk Analysis and FMEA, at a very high level, we have designed openpilot +ensuring two main safety requirements. + +1. The driver must always be capable to immediately retake manual control of the vehicle, by stepping on either pedal or by pressing the cancel button. 2. The vehicle must not alter its trajectory too quickly for the driver to safely react. This means that while the system is engaged, the actuators are constrained to operate within reasonable limits. -Following are details of the car specific safety implementations: - -Honda/Acura ------- - - - While the system is engaged, gas, brake and steer commands are subject to the same limits used by - the stock system. - - - Without an interceptor, the gas is controlled by the Powertrain Control Module (PCM). - The PCM limits acceleration to what is reasonable for a cruise control system. With an - interceptor, the gas is clipped to 60%. - - - The brake is controlled by the 0x1FA CAN message. This message allows full - braking, although the panda firmware and openpilot clip it to 1/4th of the max. - This is approximately 0.3g of braking. - - - Steering is controlled by the 0xE4 CAN message. The Electronic Power Steering (EPS) - controller in the car limits the torque to a very small amount, so regardless of the - message, the controller cannot jerk the wheel. - - - Brake and gas pedal pressed signals are contained in the 0x17C CAN message. A rising edge of - either signals triggers a disengagement, which is enforced by the panda firmware and by openpilot. The - white led on the panda signifies if the panda is allowing control messages. - - - Honda CAN uses both a counter and a checksum to ensure integrity and prevent - replay of the same message. - -Toyota/Lexus ------- - - - While the system is engaged, gas, brake and steer commands are subject to the same limits used by - the stock system. - - - With the stock Driving Support Unit (DSU) connected (or in DSU-less models like Camry and C-HR), - the acceleration is controlled by the stock system and is subject to the stock adaptive cruise - control limits. Without the stock DSU connected, the acceleration command is controlled by the - 0x343 CAN message and its value is limited between .3g of deceleration and .15g of acceleration - by the panda firmware and by openpilot. The acceleration command is ignored by the Engine Control - Module (ECM) while the cruise control system is disengaged. - - - Steering torque is controlled through the 0x2E4 CAN message and it's limited by the panda firmware and by - openpilot to a value between -1500 and 1500. In addition, the vehicle EPS unit will not respond to - commands outside these limits. A steering torque rate limit is enforced by the panda firmware and by - openpilot, so that the commanded steering torque must rise from 0 to max value no faster than - 1.5s. Commanded steering torque is limited by the panda firmware and by openpilot to be no more than 350 - units above the actual EPS generated motor torque to ensure limited differences between - commanded and actual torques. - - - Brake and gas pedal pressed signals are contained in the 0x224 and 0x1D2 CAN messages, - respectively. A rising edge of either signals triggers a disengagement, which is enforced by the - panda firmware and by openpilot. Additionally, the cruise control system disengages on the rising edge of - the brake pedal pressed signal. - - - The cruise control system state is contained in the 0x1D2 message. No control messages are - allowed if the cruise control system is not active. This is enforced by openpilot and the - panda firmware. The white led on the panda signifies if the panda is allowing control messages. - -GM/Chevrolet ------- - - - While the system is engaged, gas, brake and steer commands are subject to the same limits used by - the stock system. - - - The gas and regen are controlled by the 0x2CB message and it's limited by the panda firmware and by - openpilot to a value between 1404 and 3072. the minimum value correspond to a mild decel due to regen, - while 3072 correspond to approximately 0.18g of acceleration from stop. - - - The friction brakes are controlled by the 0x315 message and its value is limited by the panda firmware - and openpilot to 350. This is approximately 0.3g of braking. - - - Steering torque is controlled through the 0x180 CAN message and it's limited by the panda firmware and by - openpilot to a value between -300 and 300. In addition, the vehicle EPS unit will fault for - commands outside these limits. A steering torque rate limit is enforced by the panda firmware and by - openpilot, so that the commanded steering torque must rise from 0 to max value no faster than - 0.75s. Commanded steering torque is gradually limited by the panda firmware and by openpilot if the driver's - torque exceeds 12 units in the opposite dicrection to ensure limited applied torque against the - driver's will. - - - Brake pedal and gas pedal potentiometer signals are contained in the 0xF1 and 0x1A1 CAN messages, - respectively. A rising edge of either signals triggers a disengagement, which is enforced by the - panda firmware and by openpilot. Additionally, the cruise control system disengages on the rising edge of - the brake pedal pressed signal. The regen paddle pressed signal is in the 0xBD message. When the - regen paddle is pressed, a disengagement is enforced by both the firmware and by openpilot. - - - GM CAN uses both a counter and a checksum to ensure integrity and prevent - replay of the same message. - -Hyundai/Kia (Lateral only) ------- - - - While the system is engaged, steer commands are subject to the same limits used by - the stock system. - - - Steering torque is controlled through the 0x340 CAN message and it's limited by the panda firmware and by - openpilot to a value between -255 and 255. In addition, the vehicle EPS unit will fault for - commands outside the values of -409 and 409. A steering torque rate limit is enforced by the panda firmware and by - openpilot, so that the commanded steering torque must rise from 0 to max value no faster than - 0.85s. Commanded steering torque is gradually limited by the panda firmware and by openpilot if the driver's - torque exceeds 50 units in the opposite dicrection to ensure limited applied torque against the - driver's will. - -Chrysler/Jeep/Fiat (Lateral only) ------- - - - While the system is engaged, steer commands are subject to the same limits used by - the stock system. - - - Steering torque is controlled through the 0x292 CAN message and it's limited by the panda firmware and by - openpilot to a value between -261 and 261. In addition, the vehicle EPS unit will fault for - commands outside these limits. A steering torque rate limit is enforced by the panda firmware and by - openpilot, so that the commanded steering torque must rise from 0 to max value no faster than - 0.87s. Commanded steering torque is limited by the panda firmware and by openpilot to be no more than 80 - units above the actual EPS generated motor torque to ensure limited differences between - commanded and actual torques. - -Subaru (Lateral only) ------- - - - While the system is engaged, steer commands are subject to the same limits used by - the stock system. - - - Steering torque is controlled through the 0x122 CAN message and it's limited by the panda firmware and by - openpilot to a value between -255 and 255. In addition, the vehicle EPS unit will fault for - commands outside the values of -2047 and 2047. A steering torque rate limit is enforced by the panda firmware and by - openpilot, so that the commanded steering torque must rise from 0 to max value no faster than - 0.41s. Commanded steering torque is gradually limited by the panda firmware and by openpilot if the driver's - torque exceeds 60 units in the opposite dicrection to ensure limited applied torque against the - driver's will. +For vehicle specific implementation of the safety concept, refer to `panda/board/safety/`. **Extra note**: comma.ai strongly discourages the use of openpilot forks with safety code either missing or not fully meeting the above requirements. diff --git a/SConstruct b/SConstruct new file mode 100644 index 00000000000000..609cea334af813 --- /dev/null +++ b/SConstruct @@ -0,0 +1,305 @@ +import os +import shutil +import subprocess +import sys +import sysconfig +import platform +import numpy as np + +TICI = os.path.isfile('/TICI') +Decider('MD5-timestamp') + +AddOption('--test', + action='store_true', + help='build test files') + +AddOption('--asan', + action='store_true', + help='turn on ASAN') + +real_arch = arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip() +is_tbp = os.path.isfile('/data/tinkla_buddy_pro') +if arch == "aarch64" and is_tbp: + arch = "jarch64" +if platform.system() == "Darwin": + arch = "Darwin" + +if arch == "aarch64" and TICI: + arch = "larch64" + +USE_WEBCAM = os.getenv("USE_WEBCAM") is not None +QCOM_REPLAY = arch == "aarch64" and os.getenv("QCOM_REPLAY") is not None + +if arch == "aarch64" or arch == "larch64": + lenv = { + "LD_LIBRARY_PATH": '/data/data/com.termux/files/usr/lib', + "PATH": os.environ['PATH'], + } + + if arch == "aarch64": + # android + lenv["ANDROID_DATA"] = os.environ['ANDROID_DATA'] + lenv["ANDROID_ROOT"] = os.environ['ANDROID_ROOT'] + + cpppath = [ + "#phonelibs/opencl/include", + "#phonelibs/snpe/include", + ] + + libpath = [ + "/usr/lib", + "/system/vendor/lib64", + "/system/comma/usr/lib", + "#phonelibs/nanovg", + ] + + if arch == "larch64": + cpppath += ["#phonelibs/capnp-cpp/include", "#phonelibs/capnp-c/include"] + libpath += [ + "#phonelibs/snpe/larch64", + "#phonelibs/libyuv/larch64/lib", + "/usr/lib/aarch64-linux-gnu" + ] + cflags = ["-DQCOM2", "-mcpu=cortex-a57"] + cxxflags = ["-DQCOM2", "-mcpu=cortex-a57"] + rpath = ["/usr/local/lib"] + else: + libpath += [ + "#phonelibs/snpe/aarch64", + "#phonelibs/libyuv/lib", + "/system/vendor/lib64" + ] + cflags = ["-DQCOM", "-mcpu=cortex-a57"] + cxxflags = ["-DQCOM", "-mcpu=cortex-a57"] + rpath = [] + + if QCOM_REPLAY: + cflags += ["-DQCOM_REPLAY"] + cxxflags += ["-DQCOM_REPLAY"] + +else: + cflags = [] + cxxflags = [] + + lenv = { + "PATH": "#external/bin:" + os.environ['PATH'], + } + cpppath = [ + "#external/tensorflow/include", + "#phonelibs/snpe/include", + ] + + if arch == "Darwin": + libpath = [ + "#phonelibs/libyuv/mac/lib", + "#cereal", + "#selfdrive/common", + "/usr/local/lib", + "/System/Library/Frameworks/OpenGL.framework/Libraries", + ] + cflags += ["-DGL_SILENCE_DEPRECATION"] + cxxflags += ["-DGL_SILENCE_DEPRECATION"] + else: + libpath = [ + "#phonelibs/snpe/x86_64-linux-clang", + "#phonelibs/libyuv/x64/lib", + "#external/tensorflow/lib", + "#cereal", + "#selfdrive/common", + "/usr/lib", + "/usr/local/lib", + ] + + rpath = [ + "phonelibs/snpe/x86_64-linux-clang", + "external/tensorflow/lib", + "cereal", + "selfdrive/common" + ] + + # allows shared libraries to work globally + rpath = [os.path.join(os.getcwd(), x) for x in rpath] + +if GetOption('asan'): + ccflags_asan = ["-fsanitize=address", "-fno-omit-frame-pointer"] + ldflags_asan = ["-fsanitize=address"] +else: + ccflags_asan = [] + ldflags_asan = [] + +# change pythonpath to this +lenv["PYTHONPATH"] = Dir("#").path + +env = Environment( + ENV=lenv, + CCFLAGS=[ + "-g", + "-fPIC", + "-O2", + "-Wunused", + "-Werror", + "-Wno-unknown-warning-option", + "-Wno-deprecated-register", + "-Wno-register", + "-Wno-inconsistent-missing-override", + "-Wno-c99-designator", + "-Wno-reorder-init-list", + ] + cflags + ccflags_asan, + + CPPPATH=cpppath + [ + "#", + "#selfdrive", + "#phonelibs/bzip2", + "#phonelibs/libyuv/include", + "#phonelibs/openmax/include", + "#phonelibs/json11", + "#phonelibs/curl/include", + "#phonelibs/libgralloc/include", + "#phonelibs/android_frameworks_native/include", + "#phonelibs/android_hardware_libhardware/include", + "#phonelibs/android_system_core/include", + "#phonelibs/linux/include", + "#phonelibs/snpe/include", + "#phonelibs/nanovg", + "#selfdrive/boardd", + "#selfdrive/common", + "#selfdrive/camerad", + "#selfdrive/camerad/include", + "#selfdrive/loggerd/include", + "#selfdrive/modeld", + "#selfdrive/sensord", + "#selfdrive/ui", + "#cereal/messaging", + "#cereal", + "#opendbc/can", + ], + + CC='clang', + CXX='clang++', + LINKFLAGS=ldflags_asan, + + RPATH=rpath, + + CFLAGS=["-std=gnu11"] + cflags, + CXXFLAGS=["-std=c++1z"] + cxxflags, + LIBPATH=libpath + [ + "#cereal", + "#phonelibs", + "#opendbc/can", + "#selfdrive/boardd", + "#selfdrive/common", + ], + CYTHONCFILESUFFIX=".cpp", + COMPILATIONDB_USE_ABSPATH=True, + tools=["default", "cython", "compilation_db"], +) + +if GetOption('test'): + env.CompilationDatabase('compile_commands.json') + +if os.environ.get('SCONS_CACHE'): + cache_dir = '/tmp/scons_cache' + if TICI: + cache_dir = '/data/scons_cache' + + if QCOM_REPLAY: + cache_dir = '/tmp/scons_cache_qcom_replay' + + CacheDir(cache_dir) + +node_interval = 5 +node_count = 0 +def progress_function(node): + global node_count + node_count += node_interval + sys.stderr.write("progress: %d\n" % node_count) + +if os.environ.get('SCONS_PROGRESS'): + Progress(progress_function, interval=node_interval) + +SHARED = False + +def abspath(x): + if arch == 'aarch64': + pth = os.path.join("/data/pythonpath", x[0].path) + env.Depends(pth, x) + return File(pth) + else: + # rpath works elsewhere + return x[0].path.rsplit("/", 1)[1][:-3] + +# Cython build enviroment +py_include = sysconfig.get_paths()['include'] +envCython = env.Clone() +envCython["CPPPATH"] += [py_include, np.get_include()] +envCython["CCFLAGS"] += ["-Wno-#warnings", "-Wno-deprecated-declarations"] + +envCython["LIBS"] = [] +if arch == "Darwin": + envCython["LINKFLAGS"] = ["-bundle", "-undefined", "dynamic_lookup"] +elif arch == "aarch64": + envCython["LINKFLAGS"] = ["-shared"] + envCython["LIBS"] = [os.path.basename(py_include)] +else: + envCython["LINKFLAGS"] = ["-pthread", "-shared"] + +Export('envCython') + +# still needed for apks +zmq = 'zmq' +Export('env', 'arch', 'real_arch', 'zmq', 'SHARED', 'USE_WEBCAM', 'QCOM_REPLAY') + +# cereal and messaging are shared with the system +SConscript(['cereal/SConscript']) +if SHARED: + cereal = abspath([File('cereal/libcereal_shared.so')]) + messaging = abspath([File('cereal/libmessaging_shared.so')]) +else: + cereal = [File('#cereal/libcereal.a')] + messaging = [File('#cereal/libmessaging.a')] +Export('cereal', 'messaging') + +SConscript(['selfdrive/common/SConscript']) +Import('_common', '_visionipc', '_gpucommon', '_gpu_libs') + +if SHARED: + common, visionipc, gpucommon = abspath(common), abspath(visionipc), abspath(gpucommon) +else: + common = [_common, 'json11'] + visionipc = _visionipc + gpucommon = [_gpucommon] + _gpu_libs + +Export('common', 'visionipc', 'gpucommon') + +SConscript(['opendbc/can/SConscript']) + +SConscript(['common/SConscript']) +SConscript(['common/kalman/SConscript']) +SConscript(['common/transformations/SConscript']) +SConscript(['phonelibs/SConscript']) + +SConscript(['selfdrive/camerad/SConscript']) +SConscript(['selfdrive/modeld/SConscript']) + +SConscript(['selfdrive/controls/lib/cluster/SConscript']) +SConscript(['selfdrive/controls/lib/lateral_mpc/SConscript']) +SConscript(['selfdrive/controls/lib/longitudinal_mpc/SConscript']) +SConscript(['selfdrive/controls/lib/longitudinal_mpc_model/SConscript']) + +SConscript(['selfdrive/boardd/SConscript']) +SConscript(['selfdrive/proclogd/SConscript']) +SConscript(['selfdrive/clocksd/SConscript']) + +SConscript(['selfdrive/loggerd/SConscript']) + +SConscript(['selfdrive/locationd/SConscript']) +SConscript(['selfdrive/locationd/models/SConscript']) +SConscript(['selfdrive/sensord/SConscript']) +SConscript(['selfdrive/ui/SConscript']) + +if arch != "Darwin": + SConscript(['selfdrive/logcatd/SConscript']) + +if arch == "x86_64": + SConscript(['tools/lib/index_log/SConscript']) + diff --git a/apk/ai.comma.plus.black.apk b/apk/ai.comma.plus.black.apk deleted file mode 100644 index 94b3a6a1915a8c..00000000000000 Binary files a/apk/ai.comma.plus.black.apk and /dev/null differ diff --git a/apk/ai.comma.plus.frame.apk b/apk/ai.comma.plus.frame.apk deleted file mode 100644 index 374862a792d77a..00000000000000 Binary files a/apk/ai.comma.plus.frame.apk and /dev/null differ diff --git a/apk/ai.comma.plus.offroad.apk b/apk/ai.comma.plus.offroad.apk index 5dd8b8f204fa3e..90570253edabdb 100644 Binary files a/apk/ai.comma.plus.offroad.apk and b/apk/ai.comma.plus.offroad.apk differ diff --git a/cereal/.gitignore b/cereal/.gitignore index 3f6de09fb90f69..40b416ea603930 100644 --- a/cereal/.gitignore +++ b/cereal/.gitignore @@ -1,6 +1,15 @@ gen node_modules package-lock.json +*.tmp *.pyc __pycache__ - +.*.swp +.*.swo +libcereal*.a +libmessaging.* +libmessaging_shared.* +services.h +.sconsign.dblite +libcereal_shared.* +.mypy_cache/ diff --git a/cereal/Makefile b/cereal/Makefile deleted file mode 100644 index 9a206a7c106322..00000000000000 --- a/cereal/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -PWD := $(shell pwd) - -SRCS := log.capnp car.capnp ui.capnp tinkla.capnp tesla.capnp - -GENS := gen/cpp/car.capnp.c++ gen/cpp/log.capnp.c++ gen/cpp/ui.capnp.c++ gen/cpp/tinkla.capnp.c++ gen/cpp/tesla.capnp.c++ -JS := gen/js/car.capnp.js gen/js/log.capnp.js gen/js/ui.capnp.js gen/js/tinkla.capnp.js gen/js/tesla.capnp.js - -UNAME_M ?= $(shell uname -m) - -GENS += gen/c/car.capnp.c gen/c/log.capnp.c gen/c/ui.capnp.c gen/c/tinkla.capnp.c gen/c/tesla.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 gen/java/Tesla.java gen/java/Ui.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 -else -CAPNPC=capnpc -endif - -.PHONY: all -all: $(GENS) -js: $(JS) - -.PHONY: clean -clean: - rm -rf gen - rm -rf node_modules - rm -rf package-lock.json - -gen/c/%.capnp.c: %.capnp - @echo "[ CAPNPC C ] $@" - mkdir -p gen/c/ - $(CAPNPC) '$<' -o c:gen/c/ - -gen/js/%.capnp.js: %.capnp - @echo "[ CAPNPC JavaScript ] $@" - mkdir -p gen/js/ - sh ./generate_javascript.sh - -gen/cpp/%.capnp.c++: %.capnp - @echo "[ CAPNPC C++ ] $@" - mkdir -p gen/cpp/ - $(CAPNPC) '$<' -o c++:gen/cpp/ - -gen/java/Car.java gen/java/Log.java: $(SRCS) - @echo "[ CAPNPC java ] $@" - mkdir -p gen/java/ - $(CAPNPC) $^ -o java:gen/java - -# c-capnproto needs some empty headers -gen/c/include/c++.capnp.h gen/c/include/java.capnp.h: - mkdir -p gen/c/include - touch '$@' diff --git a/cereal/SConscript b/cereal/SConscript new file mode 100644 index 00000000000000..5c9221445f9cf3 --- /dev/null +++ b/cereal/SConscript @@ -0,0 +1,69 @@ +Import('env', 'envCython', 'arch', 'zmq') + +import shutil + +cereal_dir = Dir('.') +gen_dir = Dir('gen') +messaging_dir = Dir('messaging') + +# TODO: remove src-prefix and cereal from command string. can we set working directory? +env.Command(["gen/c/include/c++.capnp.h", "gen/c/include/java.capnp.h"], [], "mkdir -p " + gen_dir.path + "/c/include && touch $TARGETS") +env.Command(['gen/cpp/car.capnp.c++', 'gen/cpp/log.capnp.c++', 'gen/cpp/car.capnp.h', 'gen/cpp/log.capnp.h', +'gen/cpp/tesla.capnp.c++', 'gen/cpp/tesla.capnp.h', 'gen/cpp/tinkla.capnp.c++', 'gen/cpp/tinkla.capnp.h', 'gen/cpp/ui.capnp.c++', 'gen/cpp/ui.capnp.h'], + ['car.capnp', 'log.capnp', +'tesla.capnp', 'tinkla.capnp', 'ui.capnp'], + f"capnpc --src-prefix={cereal_dir.path} $SOURCES -o c++:{gen_dir.path}/cpp/") + +if shutil.which('capnpc-java'): + env.Command(['gen/java/Car.java', 'gen/java/Log.java', +'gen/java/Tesla.java', 'gen/java/Tinkla.java', 'gen/java/Ui.java'], + ['car.capnp', 'log.capnp', +'tesla.capnp', 'tinkla.capnp', 'ui.capnp'], + f"capnpc $SOURCES --src-prefix={cereal_dir.path} -o java:{gen_dir.path}/java/") + +# TODO: remove non shared cereal and messaging +cereal_objects = env.SharedObject([ + 'gen/cpp/car.capnp.c++', + 'gen/cpp/log.capnp.c++', + 'gen/cpp/tesla.capnp.c++', + 'messaging/socketmaster.cc', + 'gen/cpp/ui.capnp.c++', + 'gen/cpp/tinkla.capnp.c++', +]) + +env.Library('cereal', cereal_objects) +env.SharedLibrary('cereal_shared', cereal_objects) + +cereal_dir = Dir('.') +services_h = env.Command(['services.h'], + ['service_list.yaml', 'services.py'], + 'python3 ' + cereal_dir.path + '/services.py > $TARGET') + +messaging_objects = env.SharedObject([ + 'messaging/messaging.cc', + 'messaging/impl_zmq.cc', + 'messaging/impl_msgq.cc', + 'messaging/msgq.cc', + 'messaging/socketmaster.cc', +]) + +messaging_lib = env.Library('messaging', messaging_objects) +Depends('messaging/impl_zmq.cc', services_h) + +# note, this rebuilds the deps shared, zmq is statically linked to make APK happy +# TODO: get APK to load system zmq to remove the static link +if arch == "aarch64": + zmq_static = FindFile("libzmq.a", "/usr/lib") + shared_lib_shared_lib = [zmq_static, 'm', 'stdc++', "gnustl_shared", "kj", "capnp"] + env.SharedLibrary('messaging_shared', messaging_objects, LIBS=shared_lib_shared_lib) + +env.Program('messaging/bridge', ['messaging/bridge.cc'], LIBS=[messaging_lib, 'zmq']) +Depends('messaging/bridge.cc', services_h) + +# different target? +#env.Program('messaging/demo', ['messaging/demo.cc'], LIBS=[messaging_lib, 'zmq']) + +envCython.Program('messaging/messaging_pyx.so', 'messaging/messaging_pyx.pyx', LIBS=envCython["LIBS"]+[messaging_lib, "zmq"]) + +if GetOption('test'): + env.Program('messaging/test_runner', ['messaging/test_runner.cc', 'messaging/msgq_tests.cc'], LIBS=[messaging_lib]) diff --git a/cereal/__init__.py b/cereal/__init__.py index 45c5c65e72550c..a9074bf9eeae82 100644 --- a/cereal/__init__.py +++ b/cereal/__init__.py @@ -1,3 +1,4 @@ +# pylint: skip-file import os import capnp diff --git a/cereal/car.capnp b/cereal/car.capnp index 6306abc759a218..a9f2e9034d258e 100644 --- a/cereal/car.capnp +++ b/cereal/car.capnp @@ -13,19 +13,18 @@ struct CarEvent @0x9b1657f34caf3ad3 { name @0 :EventName; enable @1 :Bool; noEntry @2 :Bool; - warning @3 :Bool; + warning @3 :Bool; # alerts presented only when enabled or soft disabling userDisable @4 :Bool; softDisable @5 :Bool; immediateDisable @6 :Bool; preEnable @7 :Bool; - permanent @8 :Bool; + permanent @8 :Bool; # alerts presented regardless of openpilot state enum EventName @0xbaa8c5d505f727de { # TODO: copy from error list canError @0; steerUnavailable @1; brakeUnavailable @2; - gasUnavailable @3; wrongGear @4; doorOpen @5; seatbeltNotLatched @6; @@ -38,7 +37,6 @@ struct CarEvent @0x9b1657f34caf3ad3 { pedalPressed @13; cruiseDisabled @14; radarCanError @15; - dataNeeded @16; speedTooLow @17; outOfSpace @18; overheat @19; @@ -49,29 +47,22 @@ struct CarEvent @0x9b1657f34caf3ad3 { pcmDisable @24; noTarget @25; radarFault @26; - modelCommIssueDEPRECATED @27; brakeHold @28; parkBrake @29; manualRestart @30; lowSpeedLockout @31; plannerError @32; - ipasOverride @33; debugAlert @34; steerTempUnavailableMute @35; resumeRequired @36; preDriverDistracted @37; promptDriverDistracted @38; driverDistracted @39; - geofence @40; - driverMonitorOn @41; - driverMonitorOff @42; preDriverUnresponsive @43; promptDriverUnresponsive @44; driverUnresponsive @45; belowSteerSpeed @46; - calibrationProgress @47; lowBattery @48; - invalidGiraffeHonda @49; vehicleModelInvalid @50; controlsFailed @51; sensorDataInvalid @52; @@ -79,6 +70,54 @@ struct CarEvent @0x9b1657f34caf3ad3 { tooDistracted @54; posenetInvalid @55; soundsUnavailable @56; + preLaneChangeLeft @57; + preLaneChangeRight @58; + laneChange @59; + internetConnectivityNeeded @61; + communityFeatureDisallowed @62; + lowMemory @63; + stockAeb @64; + ldw @65; + carUnrecognized @66; + radarCommIssue @67; + driverMonitorLowAcc @68; + invalidLkasSetting @69; + speedTooHigh @70; + laneChangeBlocked @71; + relayMalfunction @72; + gasPressed @73; + stockFcw @74; + startup @75; + startupNoCar @76; + startupNoControl @77; + startupMaster @78; + fcw @79; + steerSaturated @80; + belowEngageSpeed @84; + noGps @85; + wrongCruiseMode @87; + modeldLagging @89; + deviceFalling @90; + fanMalfunction @91; + cameraMalfunction @92; + + startupOneplus @82; + + gasUnavailableDEPRECATED @3; + dataNeededDEPRECATED @16; + modelCommIssueDEPRECATED @27; + ipasOverrideDEPRECATED @33; + geofenceDEPRECATED @40; + driverMonitorOnDEPRECATED @41; + driverMonitorOffDEPRECATED @42; + calibrationProgressDEPRECATED @47; + invalidGiraffeHondaDEPRECATED @49; + invalidGiraffeToyotaDEPRECATED @60; + whitePandaUnsupportedDEPRECATED @81; + commIssueWarningDEPRECATED @83; + focusRecoverActiveDEPRECATED @86; + neosUpdateRequiredDEPRECATED @88; + modelLagWarningDEPRECATED @93; } } @@ -107,11 +146,17 @@ struct CarState { brakeLights @19 :Bool; # steering wheel - steeringAngle @7 :Float32; # deg - steeringRate @15 :Float32; # deg/s - steeringTorque @8 :Float32; # TODO: standardize units + steeringAngle @7 :Float32; # deg + steeringRate @15 :Float32; # deg/s + steeringTorque @8 :Float32; # TODO: standardize units steeringTorqueEps @27 :Float32; # TODO: standardize units - steeringPressed @9 :Bool; # if the user is using the steering wheel + steeringPressed @9 :Bool; # if the user is using the steering wheel + steeringRateLimited @29 :Bool; # if the torque is limited by the rate limiter + steerWarning @35 :Bool; # temporary steer unavailble + steerError @36 :Bool; # permanent steer error + stockAeb @30 :Bool; + stockFcw @31 :Bool; + espDisabled @32 :Bool; # cruise state cruiseState @10 :CruiseState; @@ -130,9 +175,16 @@ struct CarState { seatbeltUnlatched @25 :Bool; canValid @26 :Bool; + # clutch (manual transmission only) + clutchPressed @28 :Bool; + # which packets this state came from canMonoTimes @12: List(UInt64); + # blindspot sensors + leftBlindspot @33 :Bool; # Is there something blocking the left lane change + rightBlindspot @34 :Bool; # Is there something blocking the right lane change + struct WheelSpeeds { # optional wheel speeds fl @0 :Float32; @@ -147,6 +199,7 @@ struct CarState { available @2 :Bool; speedOffset @3 :Float32; standstill @4 :Bool; + nonAdaptive @5 :Bool; } enum GearShifter { @@ -158,9 +211,10 @@ struct CarState { sport @5; low @6; brake @7; + eco @8; + manumatic @9; } - # send on change struct ButtonEvent { pressed @0 :Bool; @@ -176,6 +230,9 @@ struct CarState { altButton1 @6; altButton2 @7; altButton3 @8; + setCruise @9; + resumeCruise @10; + gapAdjustCruise @11; } } } @@ -268,6 +325,7 @@ struct CarControl { wrongGear @4; seatbeltUnbuckled @5; speedTooHigh @6; + ldw @7; } enum AudibleAlert { @@ -281,6 +339,7 @@ struct CarControl { chimeWarning2 @5; chimeWarningRepeat @6; chimePrompt @7; + chimeWarning2Repeat @8; } } } @@ -300,6 +359,7 @@ struct CarParams { minEnableSpeed @7 :Float32; minSteerSpeed @8 :Float32; safetyModel @9 :SafetyModel; + safetyModelPassive @42 :SafetyModel = silent; safetyParam @10 :Int16; steerMaxBP @11 :List(Float32); @@ -309,7 +369,6 @@ struct CarParams { 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 @@ -323,6 +382,7 @@ struct CarParams { tireStiffnessRear @24 :Float32; # [N/rad] rear tire coeff of stiff longitudinalTuning @25 :LongitudinalPIDTuning; + lateralParams @48 :LateralParams; lateralTuning :union { pid @26 :LateralPIDTuning; indi @27 :LateralINDITuning; @@ -330,6 +390,7 @@ struct CarParams { } steerLimitAlert @28 :Bool; + steerLimitTimer @47 :Float32; # time before steerLimitAlert is issued 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 @@ -338,11 +399,26 @@ struct CarParams { steerRateCost @33 :Float32; # Lateral MPC cost on steering rate steerControlType @34 :SteerControlType; radarOffCan @35 :Bool; # True when radar objects aren't visible on CAN + minSpeedCan @51 :Float32; # Minimum vehicle speed from CAN (below this value drops to 0) + stoppingBrakeRate @52 :Float32; # brake_travel/s while trying to stop + startingBrakeRate @53 :Float32; # brake_travel/s while releasing on restart 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 isPandaBlack @39: Bool; + dashcamOnly @41: Bool; + transmissionType @43 :TransmissionType; + carFw @44 :List(CarFw); + radarTimeStep @45: Float32 = 0.05; # time delta between radar updates, 20Hz is very standard + communityFeature @46: Bool; # true if a community maintained feature is detected + fingerprintSource @49: FingerprintSource; + networkLocation @50 :NetworkLocation; # Where Panda/C2 is integrated into the car's CAN network + + struct LateralParams { + torqueBP @0 :List(Int32); + torqueV @1 :List(Int32); + } struct LateralPIDTuning { kpBP @0 :List(Float32); @@ -361,7 +437,6 @@ struct CarParams { deadzoneV @5 :List(Float32); } - struct LateralINDITuning { outerLoopGain @0 :Float32; innerLoopGain @1 :Float32; @@ -383,25 +458,85 @@ struct CarParams { l @7 :List(Float32); # Kalman gain } - enum SafetyModel { - # does NOT match board setting - noOutput @0; - honda @1; + silent @0; + hondaNidec @1; toyota @2; elm327 @3; gm @4; - hondaBosch @5; + hondaBoschGiraffe @5; ford @6; cadillac @7; hyundai @8; chrysler @9; tesla @10; subaru @11; + gmPassive @12; + mazda @13; + nissan @14; + volkswagen @15; + toyotaIpas @16; + allOutput @17; + gmAscm @18; + noOutput @19; # like silent but without silent CAN TXs + hondaBoschHarness @20; + volkswagenPq @21; + subaruLegacy @22; # pre-Global platform + hyundaiLegacy @23; + hyundaiCommunity @24; } enum SteerControlType { torque @0; angle @1; } -} \ No newline at end of file + + enum TransmissionType { + unknown @0; + automatic @1; # Traditional auto, including DSG + manual @2; # True "stick shift" only + direct @3; # Electric vehicle or other direct drive + } + + struct CarFw { + ecu @0 :Ecu; + fwVersion @1 :Data; + address @2: UInt32; + subAddress @3: UInt8; + } + + enum Ecu { + eps @0; + esp @1; + fwdRadar @2; + fwdCamera @3; + engine @4; + unknown @5; + transmission @8; # Transmission Control Module + srs @9; # airbag + gateway @10; # can gateway + hud @11; # heads up display + combinationMeter @12; # instrument cluster + + # Toyota only + dsu @6; + apgs @7; + + # Honda only + vsa @13; # Vehicle Stability Assist + programmedFuelInjection @14; + electricBrakeBooster @15; + shiftByWire @16; + } + + enum FingerprintSource { + can @0; + fw @1; + fixed @2; + } + + enum NetworkLocation { + fwdCamera @0; # Standard/default integration at LKAS camera + gateway @1; # Integration at vehicle's CAN gateway + } +} diff --git a/cereal/generate_javascript.sh b/cereal/generate_javascript.sh deleted file mode 100755 index d6525a64d95eed..00000000000000 --- a/cereal/generate_javascript.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -rm -r gen/ts -rm -r gen/js - -mkdir gen/ts -mkdir gen/js - -echo "Installing needed npm modules" -npm i capnpc-ts capnp-ts - -capnpc -o node_modules/.bin/capnpc-ts:gen/ts log.capnp car.capnp -capnpc -o node_modules/.bin/capnpc-ts:gen/ts car.capnp - -cat log.capnp | egrep '\([a-zA-Z]*\.[^\s]+\.[^s]+\)' | sed 's/^.*([a-zA-Z]*\.\([a-zA-Z.]*\)).*/\1/' | while read line -do - TOKEN=`echo $line | sed 's/\./_/g'` - ROOT=`echo $line | sed 's/\..*$//g'` - cat gen/ts/log.capnp.ts | grep '^import.*'${TOKEN} - if [[ "$?" == "1" ]] - then - sed -i 's/^\(import {.*\)'${ROOT}'\(,*\) \(.*\)$/\1'${ROOT}', '${TOKEN}'\2 \3/' ./gen/ts/log.capnp.ts - fi -done - -tsc ./gen/ts/* --lib es2015 --outDir ./gen/js diff --git a/cereal/install_capnp.sh b/cereal/install_capnp.sh deleted file mode 100755 index b83e1ffda1d221..00000000000000 --- a/cereal/install_capnp.sh +++ /dev/null @@ -1,39 +0,0 @@ -set -e -echo "Installing capnp" - -cd /tmp -VERSION=0.6.1 -wget https://capnproto.org/capnproto-c++-${VERSION}.tar.gz -tar xvf capnproto-c++-${VERSION}.tar.gz -cd capnproto-c++-${VERSION} -CXXFLAGS="-fPIC" ./configure - -make -j4 - -# manually build binaries statically -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 - -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 - -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 - -cp .libs/capnp /usr/local/bin/ -ln -s /usr/local/bin/capnp /usr/local/bin/capnpc -cp .libs/capnpc-c++ /usr/local/bin/ -cp .libs/capnpc-capnp /usr/local/bin/ -cp .libs/*.a /usr/local/lib - -cd /tmp -echo "Installing c-capnp" -git clone https://github.com/commaai/c-capnproto.git -cd c-capnproto -git submodule update --init --recursive -autoreconf -f -i -s -CXXFLAGS="-fPIC" ./configure -make -j4 - -# manually build binaries statically -gcc -fPIC -o .libs/capnpc-c compiler/capnpc-c.o compiler/schema.capnp.o compiler/str.o ./.libs/libcapnp_c.a - -cp .libs/capnpc-c /usr/local/bin/ -cp .libs/*.a /usr/local/lib diff --git a/cereal/log.capnp b/cereal/log.capnp index 053c452113a838..11f49fa12f1ede 100644 --- a/cereal/log.capnp +++ b/cereal/log.capnp @@ -49,6 +49,8 @@ struct InitData { neo @1; chffrAndroid @2; chffrIos @3; + tici @4; + pc @5; } struct AndroidBuildInfo { @@ -126,6 +128,11 @@ struct FrameData { lensErr @13 :Float32; lensTruePos @14 :Float32; image @6 :Data; + gainFrac @15 :Float32; + focusVal @16 :List(Int16); + focusConf @17 :List(UInt8); + sharpnessScore @18 :List(UInt16); + recoverState @19 :Int32; frameType @7 :FrameType; timestampSof @8 :UInt64; @@ -137,6 +144,7 @@ struct FrameData { unknown @0; neo @1; chffrAndroid @2; + front @3; } struct AndroidCaptureResult { @@ -180,6 +188,7 @@ struct SensorEventData { gyroUncalibrated @12 :SensorVec; proximity @13: Float32; light @14: Float32; + temperature @15: Float32; } source @8 :SensorSource; @@ -197,6 +206,8 @@ struct SensorEventData { lsm6ds3 @5; # accelerometer (c2) bmp280 @6; # barometer (c2) mmc3416x @7; # magnetometer (c2) + bmx055 @8; + rpr0521 @9; } } @@ -261,13 +272,15 @@ struct CanData { } struct ThermalData { - cpu0 @0 :UInt16; - cpu1 @1 :UInt16; - cpu2 @2 :UInt16; - cpu3 @3 :UInt16; - mem @4 :UInt16; - gpu @5 :UInt16; - bat @6 :UInt32; + # Deprecated + cpu0DEPRECATED @0 :UInt16; + cpu1DEPRECATED @1 :UInt16; + cpu2DEPRECATED @2 :UInt16; + cpu3DEPRECATED @3 :UInt16; + memDEPRECATED @4 :UInt16; + gpuDEPRECATED @5 :UInt16; + batDEPRECATED @6 :UInt32; + pa0DEPRECATED @21 :UInt16; # not thermal freeSpace @7 :Float32; @@ -276,6 +289,10 @@ struct ThermalData { batteryCurrent @15 :Int32; batteryVoltage @16 :Int32; usbOnline @12 :Bool; + networkType @22 :NetworkType; + offroadPowerUsage @23 :UInt32; # Power usage since going offroad in uWh + networkStrength @24 :NetworkStrength; + carBatteryCapacity @25 :UInt32; # Estimated remaining car battery capacity in uWh fanSpeed @10 :UInt16; started @11 :Bool; @@ -285,27 +302,94 @@ struct ThermalData { chargingError @17 :Bool; chargingDisabled @18 :Bool; + memUsedPercent @19 :Int8; + cpuPerc @20 :Int8; + + cpu @26 :List(Float32); + gpu @27 :List(Float32); + mem @28 :Float32; + bat @29 :Float32; + ambient @30 :Float32; + enum ThermalStatus { green @0; # all processes run yellow @1; # critical processes run (kill uploader), engage still allowed red @2; # no engage, will disengage danger @3; # immediate process shutdown } + + enum NetworkType { + none @0; + wifi @1; + cell2G @2; + cell3G @3; + cell4G @4; + cell5G @5; + } + + enum NetworkStrength { + unknown @0; + poor @1; + moderate @2; + good @3; + great @4; + } } struct HealthData { # from can health voltage @0 :UInt32; current @1 :UInt32; - started @2 :Bool; + ignitionLine @2 :Bool; controlsAllowed @3 :Bool; gasInterceptorDetected @4 :Bool; startedSignalDetectedDeprecated @5 :Bool; hasGps @6 :Bool; canSendErrs @7 :UInt32; canFwdErrs @8 :UInt32; + canRxErrs @19 :UInt32; gmlanSendErrs @9 :UInt32; - hwType @10: HwType; + hwType @10 :HwType; + fanSpeedRpm @11 :UInt16; + usbPowerMode @12 :UsbPowerMode; + ignitionCan @13 :Bool; + safetyModel @14 :Car.CarParams.SafetyModel; + faultStatus @15 :FaultStatus; + powerSaveEnabled @16 :Bool; + uptime @17 :UInt32; + faults @18 :List(FaultType); + + enum FaultStatus { + none @0; + faultTemp @1; + faultPerm @2; + } + + enum FaultType { + relayMalfunction @0; + unusedInterruptHandled @1; + interruptRateCan1 @2; + interruptRateCan2 @3; + interruptRateCan3 @4; + interruptRateTach @5; + interruptRateGmlan @6; + interruptRateInterrupts @7; + interruptRateSpiDma @8; + interruptRateSpiCs @9; + interruptRateUart1 @10; + interruptRateUart2 @11; + interruptRateUart3 @12; + interruptRateUart5 @13; + interruptRateUartDma @14; + interruptRateUsb @15; + interruptRateTim1 @16; + interruptRateTim3 @17; + registerDivergent @18; + interruptRateKlineInit @19; + interruptRateClockSource @20; + interruptRateTim9 @21; + # Update max fault type in boardd when adding faults + } enum HwType { unknown @0; @@ -313,6 +397,15 @@ struct HealthData { greyPanda @2; blackPanda @3; pedal @4; + uno @5; + dos @6; + } + + enum UsbPowerMode { + none @0; + client @1; + cdp @2; + dcp @3; } } @@ -363,18 +456,22 @@ struct RadarState @0x9a185389d6fdd05f { struct LiveCalibrationData { # deprecated warpMatrix @0 :List(Float32); + # camera_frame_from_model_frame warpMatrix2 @5 :List(Float32); warpMatrixBig @6 :List(Float32); + calStatus @1 :Int8; calCycle @2 :Int32; calPerc @3 :Int8; + validBlocks @9 :Int32; # view_frame_from_road_frame # ui's is inversed needs new extrinsicMatrix @4 :List(Float32); # the direction of travel vector in device frame rpyCalib @7 :List(Float32); + rpyCalibSpread @8 :List(Float32); } struct LiveTracks { @@ -442,7 +539,7 @@ struct ControlsState @0x97ff69c53601abf1 { alertSoundDEPRECATED @45 :Text; alertSound @56 :Car.CarControl.HUDControl.AudibleAlert; awarenessStatus @26 :Float32; - angleModelBias @27 :Float32; + angleModelBiasDEPRECATED @27 :Float32; gpsPlannerActive @40 :Bool; engageable @41 :Bool; # can OP be engaged? driverMonitoringOn @43 :Bool; @@ -452,6 +549,7 @@ struct ControlsState @0x97ff69c53601abf1 { decelForTurn @47 :Bool; decelForModel @54 :Bool; + canErrorCounter @57 :UInt32; lateralControlState :union { indiState @52 :LateralINDIState; @@ -475,7 +573,7 @@ struct ControlsState @0x97ff69c53601abf1 { enum AlertStatus { normal @0; # low priority alert for user's convenience - userPrompt @1; # mid piority alert that might require user intervention + userPrompt @1; # mid priority alert that might require user intervention critical @2; # high priority alert that needs immediate user intervention } @@ -497,6 +595,7 @@ struct ControlsState @0x97ff69c53601abf1 { delayedOutput @7 :Float32; delta @8 :Float32; output @9 :Float32; + saturated @10 :Bool; } struct LateralPIDState { @@ -516,8 +615,9 @@ struct ControlsState @0x97ff69c53601abf1 { steerAngle @1 :Float32; i @2 :Float32; output @3 :Float32; - } - + lqrOutput @4 :Float32; + saturated @5 :Bool; + } } struct LiveEventData { @@ -527,6 +627,12 @@ struct LiveEventData { struct ModelData { frameId @0 :UInt32; + frameAge @12 :UInt32; + frameDropPerc @13 :Float32; + timestampEof @9 :UInt64; + modelExecutionTime @14 :Float32; + gpuExecutionTime @16 :Float32; + rawPred @15 :Data; path @1 :PathData; leftLane @2 :PathData; @@ -537,6 +643,8 @@ struct ModelData { settings @5 :ModelSettings; leadFuture @7 :LeadData; speed @8 :List(Float32); + meta @10 :MetaData; + longitudinal @11 :LongitudinalData; struct PathData { points @0 :List(Float32); @@ -544,6 +652,7 @@ struct ModelData { std @2 :Float32; stds @3 :List(Float32); poly @4 :List(Float32); + validLen @5 :Float32; } struct LeadData { @@ -567,8 +676,74 @@ struct ModelData { yuvCorrection @5 :List(Float32); inputTransform @6 :List(Float32); } + + struct MetaData { + engagedProb @0 :Float32; + desirePrediction @1 :List(Float32); + brakeDisengageProb @2 :Float32; + gasDisengageProb @3 :Float32; + steerOverrideProb @4 :Float32; + desireState @5 :List(Float32); + } + + struct LongitudinalData { + distances @2 :List(Float32); + speeds @0 :List(Float32); + accelerations @1 :List(Float32); + } +} + + +struct ModelDataV2 { + frameId @0 :UInt32; + frameAge @1 :UInt32; + frameDropPerc @2 :Float32; + timestampEof @3 :UInt64; + modelExecutionTime @15 :Float32; + gpuExecutionTime @17 :Float32; + rawPred @16 :Data; + + position @4 :XYZTData; + orientation @5 :XYZTData; + velocity @6 :XYZTData; + orientationRate @7 :XYZTData; + laneLines @8 :List(XYZTData); + laneLineProbs @9 :List(Float32); + laneLineStds @13 :List(Float32); + roadEdges @10 :List(XYZTData); + roadEdgeStds @14 :List(Float32); + leads @11 :List(LeadDataV2); + + meta @12 :MetaData; + + struct XYZTData { + x @0 :List(Float32); + y @1 :List(Float32); + z @2 :List(Float32); + t @3 :List(Float32); + xStd @4 :List(Float32); + yStd @5 :List(Float32); + zStd @6 :List(Float32); + } + + struct LeadDataV2 { + prob @0 :Float32; + t @1 :Float32; + xyva @2 :List(Float32); + xyvaStd @3 :List(Float32); + } + + struct MetaData { + engagedProb @0 :Float32; + desirePrediction @1 :List(Float32); + brakeDisengageProb @2 :Float32; + gasDisengageProb @3 :Float32; + steerOverrideProb @4 :Float32; + desireState @5 :List(Float32); + } } + struct CalibrationFeatures { frameId @0 :UInt32; @@ -589,6 +764,8 @@ struct EncodeIndex { segmentId @4 :UInt32; # index into camera file in segment in encode order segmentIdEncode @5 :UInt32; + timestampSof @6 :UInt64; + timestampEof @7 :UInt64; enum Type { bigBoxLossless @0; # rcamera.mkv @@ -697,6 +874,84 @@ struct PathPlan { sensorValid @14 :Bool; commIssue @15 :Bool; posenetValid @16 :Bool; + desire @17 :Desire; + laneChangeState @18 :LaneChangeState; + laneChangeDirection @19 :LaneChangeDirection; + + enum Desire { + none @0; + turnLeft @1; + turnRight @2; + laneChangeLeft @3; + laneChangeRight @4; + keepLeft @5; + keepRight @6; + } + + enum LaneChangeState { + off @0; + preLaneChange @1; + laneChangeStarting @2; + laneChangeFinishing @3; + } + + enum LaneChangeDirection { + none @0; + left @1; + right @2; + } +} + +struct LiveLocationKalman { + + # More info on reference frames: + # https://github.com/commaai/openpilot/tree/master/common/transformations + + positionECEF @0 : Measurement; + positionGeodetic @1 : Measurement; + velocityECEF @2 : Measurement; + velocityNED @3 : Measurement; + velocityDevice @4 : Measurement; + accelerationDevice @5: Measurement; + + + # These angles are all eulers and roll, pitch, yaw + # orientationECEF transforms to rot matrix: ecef_from_device + orientationECEF @6 : Measurement; + calibratedOrientationECEF @20 : Measurement; + orientationNED @7 : Measurement; + angularVelocityDevice @8 : Measurement; + + # orientationNEDCalibrated transforms to rot matrix: NED_from_calibrated + orientationNEDCalibrated @9 : Measurement; + + # Calibrated frame is simply device frame + # aligned with the vehicle + velocityCalibrated @10 : Measurement; + accelerationCalibrated @11 : Measurement; + angularVelocityCalibrated @12 : Measurement; + + gpsWeek @13 :Int32; + gpsTimeOfWeek @14 :Float64; + status @15 :Status; + unixTimestampMillis @16 :Int64; + inputsOK @17 :Bool = true; + posenetOK @18 :Bool = true; + gpsOK @19 :Bool = true; + sensorsOK @21 :Bool = true; + deviceStable @22 :Bool = true; + + enum Status { + uninitialized @0; + uncalibrated @1; + valid @2; + } + + struct Measurement { + value @0 : List(Float64); + std @1 : List(Float64); + valid @2 : Bool; + } } struct LiveLocationData { @@ -1342,6 +1597,7 @@ struct UbloxGnss { measurementReport @0 :MeasurementReport; ephemeris @1 :Ephemeris; ionoData @2 :IonoData; + hwStatus @3 :HwStatus; } struct MeasurementReport { @@ -1465,8 +1721,29 @@ struct UbloxGnss { healthValid @5 :Bool; ionoCoeffsValid @6 :Bool; } -} + struct HwStatus { + noisePerMS @0 :UInt16; + agcCnt @1 :UInt16; + aStatus @2 :AntennaSupervisorState; + aPower @3 :AntennaPowerStatus; + jamInd @4 :UInt8; + + enum AntennaSupervisorState { + init @0; + dontknow @1; + ok @2; + short @3; + open @4; + } + + enum AntennaPowerStatus { + off @0; + on @1; + dontknow @2; + } + } +} struct Clocks { bootTimeNanos @0 :UInt64; @@ -1603,11 +1880,14 @@ struct UiLayoutState { activeApp @0 :App; sidebarCollapsed @1 :Bool; mapEnabled @2 :Bool; + mockEngaged @3 :Bool; enum App { home @0; music @1; nav @2; + settings @3; + none @4; } } @@ -1673,8 +1953,12 @@ struct OrbKeyFrame { descriptors @3 :Data; } -struct DriverMonitoring { +struct DriverState { frameId @0 :UInt32; + modelExecutionTime @14 :Float32; + dspExecutionTime @16 :Float32; + rawPred @15 :Data; + descriptorDEPRECATED @1 :List(Float32); stdDEPRECATED @2 :Float32; faceOrientation @3 :List(Float32); @@ -1684,12 +1968,38 @@ struct DriverMonitoring { rightEyeProb @7 :Float32; leftBlinkProb @8 :Float32; rightBlinkProb @9 :Float32; + irPwrDEPRECATED @10 :Float32; + faceOrientationStd @11 :List(Float32); + facePositionStd @12 :List(Float32); + sgProb @13 :Float32; +} + +struct DMonitoringState { + # TODO: deprecate old fields in controlsState + events @0 :List(Car.CarEvent); + faceDetected @1 :Bool; + isDistracted @2 :Bool; + awarenessStatus @3 :Float32; + isRHD @4 :Bool; + posePitchOffset @6 :Float32; + posePitchValidCount @7 :UInt32; + poseYawOffset @8 :Float32; + poseYawValidCount @9 :UInt32; + stepChange @10 :Float32; + awarenessActive @11 :Float32; + awarenessPassive @12 :Float32; + isLowStd @13 :Bool; + hiStdCount @14 :UInt32; + isPreview @15 :Bool; + + rhdCheckedDEPRECATED @5 :Bool; } struct Boot { wallTimeNanos @0 :UInt64; lastKmsg @1 :Data; lastPmsg @2 :Data; + launchLog @3 :Text; } struct LiveParametersData { @@ -1726,6 +2036,8 @@ struct LiveMapData { } struct CameraOdometry { + frameId @4 :UInt32; + timestampEof @5 :UInt64; trans @0 :List(Float32); # m/s in device frame rot @1 :List(Float32); # rad/s in device frame transStd @2 :List(Float32); # std m/s in device frame @@ -1739,6 +2051,16 @@ struct KalmanOdometry { rotStd @3 :List(Float32); # std rad/s in device frame } +struct Sentinel { + enum SentinelType { + endOfSegment @0; + endOfRoute @1; + startOfSegment @2; + startOfRoute @3; + } + type @0 :SentinelType; +} + struct Event { # in nanoseconds? logMonoTime @0 :UInt64; @@ -1764,7 +2086,7 @@ struct Event { sendcan @17 :List(CanData); logMessage @18 :Text; liveCalibration @19 :LiveCalibrationData; - androidLogEntry @20 :AndroidLogEntry; + androidLog @20 :AndroidLogEntry; gpsLocation @21 :GpsLocationData; carState @22 :Car.CarState; carControl @23 :Car.CarControl; @@ -1795,7 +2117,7 @@ struct Event { gpsLocationExternal @48 :GpsLocationData; location @49 :LiveLocationData; uiNavigationEvent @50 :UiNavigationEvent; - liveLocationKalman @51 :LiveLocationData; + liveLocationKalmanDEPRECATED @51 :LiveLocationData; testJoystick @52 :Joystick; orbOdometry @53 :OrbOdometry; orbFeatures @54 :OrbFeatures; @@ -1803,7 +2125,7 @@ struct Event { orbKeyFrame @56 :OrbKeyFrame; uiLayoutState @57 :UiLayoutState; orbFeaturesSummary @58 :OrbFeaturesSummary; - driverMonitoring @59 :DriverMonitoring; + driverState @59 :DriverState; boot @60 :Boot; liveParameters @61 :LiveParametersData; liveMapData @62 :LiveMapData; @@ -1813,5 +2135,13 @@ struct Event { thumbnail @66: Thumbnail; carEvents @68: List(Car.CarEvent); carParams @69: Car.CarParams; + frontFrame @70: FrameData; # driver facing camera + dMonitoringState @71: DMonitoringState; + liveLocationKalman @72 :LiveLocationKalman; + sentinel @73 :Sentinel; + wideFrame @74: FrameData; + modelV2 @75 :ModelDataV2; + frontEncodeIdx @76 :EncodeIndex; # driver facing camera + wideEncodeIdx @77 :EncodeIndex; } -} \ No newline at end of file +} diff --git a/cereal/maptile.capnp b/cereal/maptile.capnp deleted file mode 100644 index 336901392aa306..00000000000000 --- a/cereal/maptile.capnp +++ /dev/null @@ -1,53 +0,0 @@ -using Cxx = import "./include/c++.capnp"; -$Cxx.namespace("cereal"); - -using Java = import "./include/java.capnp"; -$Java.package("ai.comma.openpilot.cereal"); -$Java.outerClassname("Map"); - -@0xa086df597ef5d7a0; - -# Geometry -struct Point { - x @0: Float64; - y @1: Float64; - z @2: Float64; -} - -struct PolyLine { - points @0: List(Point); -} - -# Map features -struct Lane { - id @0 :Text; - - leftBoundary @1 :LaneBoundary; - rightBoundary @2 :LaneBoundary; - - leftAdjacentId @3 :Text; - rightAdjacentId @4 :Text; - - inboundIds @5 :List(Text); - outboundIds @6 :List(Text); - - struct LaneBoundary { - polyLine @0 :PolyLine; - startHeading @1 :Float32; # WRT north - } -} - -# Map tiles -struct TileSummary { - version @0 :Text; - updatedAt @1 :UInt64; # Millis since epoch - - level @2 :UInt8; - x @3 :UInt16; - y @4 :UInt16; -} - -struct MapTile { - summary @0 :TileSummary; - lanes @1 :List(Lane); -} diff --git a/cereal/messaging/.gitignore b/cereal/messaging/.gitignore new file mode 100644 index 00000000000000..dbbe8e22aee488 --- /dev/null +++ b/cereal/messaging/.gitignore @@ -0,0 +1,10 @@ +demo +bridge +test_runner +*.o +*.os +*.d +*.a +*.so +messaging_pyx.cpp +build/ diff --git a/cereal/messaging/__init__.py b/cereal/messaging/__init__.py new file mode 100644 index 00000000000000..0b1204b47a550a --- /dev/null +++ b/cereal/messaging/__init__.py @@ -0,0 +1,225 @@ +# must be build with scons +from .messaging_pyx import Context, Poller, SubSocket, PubSocket # pylint: disable=no-name-in-module, import-error +from .messaging_pyx import MultiplePublishersError, MessagingError # pylint: disable=no-name-in-module, import-error +import capnp + +from typing import Optional, List, Union + +from cereal import log +from cereal.services import service_list + +assert MultiplePublishersError +assert MessagingError + +# sec_since_boot is faster, but allow to run standalone too +try: + from common.realtime import sec_since_boot +except ImportError: + import time + sec_since_boot = time.time + print("Warning, using python time.time() instead of faster sec_since_boot") + +context = Context() + +def new_message(service: Optional[str] = None, size: Optional[int] = None) -> capnp.lib.capnp._DynamicStructBuilder: + dat = log.Event.new_message() + dat.logMonoTime = int(sec_since_boot() * 1e9) + dat.valid = True + if service is not None: + if size is None: + dat.init(service) + else: + dat.init(service, size) + return dat + +def pub_sock(endpoint: str) -> PubSocket: + sock = PubSocket() + sock.connect(context, endpoint) + return sock + +def sub_sock(endpoint: str, poller: Optional[Poller] = None, addr: str = "127.0.0.1", + conflate: bool = False, timeout: Optional[int] = None) -> SubSocket: + sock = SubSocket() + sock.connect(context, endpoint, addr.encode('utf8'), conflate) + + if timeout is not None: + sock.setTimeout(timeout) + + if poller is not None: + poller.registerSocket(sock) + return sock + + +def drain_sock_raw(sock: SubSocket, wait_for_one: bool = False) -> List[bytes]: + """Receive all message currently available on the queue""" + ret: List[bytes] = [] + while 1: + if wait_for_one and len(ret) == 0: + dat = sock.receive() + else: + dat = sock.receive(non_blocking=True) + + if dat is None: + break + + ret.append(dat) + + return ret + +def drain_sock(sock: SubSocket, wait_for_one: bool = False) -> List[capnp.lib.capnp._DynamicStructReader]: + """Receive all message currently available on the queue""" + ret: List[capnp.lib.capnp._DynamicStructReader] = [] + while 1: + if wait_for_one and len(ret) == 0: + dat = sock.receive() + else: + dat = sock.receive(non_blocking=True) + + if dat is None: # Timeout hit + break + + dat = log.Event.from_bytes(dat) + ret.append(dat) + + return ret + + +# TODO: print when we drop packets? +def recv_sock(sock: SubSocket, wait: bool = False) -> Union[None, capnp.lib.capnp._DynamicStructReader]: + """Same as drain sock, but only returns latest message. Consider using conflate instead.""" + dat = None + + while 1: + if wait and dat is None: + rcv = sock.receive() + else: + rcv = sock.receive(non_blocking=True) + + if rcv is None: # Timeout hit + break + + dat = rcv + + if dat is not None: + dat = log.Event.from_bytes(dat) + + return dat + +def recv_one(sock: SubSocket) -> Union[None, capnp.lib.capnp._DynamicStructReader]: + dat = sock.receive() + if dat is not None: + dat = log.Event.from_bytes(dat) + return dat + +def recv_one_or_none(sock: SubSocket) -> Union[None, capnp.lib.capnp._DynamicStructReader]: + dat = sock.receive(non_blocking=True) + if dat is not None: + dat = log.Event.from_bytes(dat) + return dat + +def recv_one_retry(sock: SubSocket) -> capnp.lib.capnp._DynamicStructReader: + """Keep receiving until we get a message""" + while True: + dat = sock.receive() + if dat is not None: + return log.Event.from_bytes(dat) + +class SubMaster(): + def __init__(self, services: List[str], poll: Optional[List[str]] = None, + ignore_alive: Optional[List[str]] = None, addr:str ="127.0.0.1"): + self.frame = -1 + self.updated = {s: False for s in services} + self.rcv_time = {s: 0. for s in services} + self.rcv_frame = {s: 0 for s in services} + self.alive = {s: False for s in services} + self.sock = {} + self.freq = {} + self.data = {} + self.valid = {} + self.logMonoTime = {} + + self.poller = Poller() + self.non_polled_services = [s for s in services if poll is not None and + len(poll) and s not in poll] + + if ignore_alive is not None: + self.ignore_alive = ignore_alive + else: + self.ignore_alive = [] + + for s in services: + if addr is not None: + p = self.poller if s not in self.non_polled_services else None + self.sock[s] = sub_sock(s, poller=p, addr=addr, conflate=True) + self.freq[s] = service_list[s].frequency + + try: + data = new_message(s) + except capnp.lib.capnp.KjException: # pylint: disable=c-extension-no-member + data = new_message(s, 0) # lists + + self.data[s] = getattr(data, s) + self.logMonoTime[s] = 0 + self.valid[s] = data.valid + + def __getitem__(self, s: str) -> capnp.lib.capnp._DynamicStructReader: + return self.data[s] + + def update(self, timeout: int = 1000) -> None: + msgs = [] + for sock in self.poller.poll(timeout): + msgs.append(recv_one_or_none(sock)) + + # non-blocking receive for non-polled sockets + for s in self.non_polled_services: + msgs.append(recv_one_or_none(self.sock[s])) + self.update_msgs(sec_since_boot(), msgs) + + def update_msgs(self, cur_time: float, msgs: List[capnp.lib.capnp._DynamicStructReader]) -> None: + self.frame += 1 + self.updated = dict.fromkeys(self.updated, False) + for msg in msgs: + if msg is None: + continue + + s = msg.which() + self.updated[s] = True + self.rcv_time[s] = cur_time + self.rcv_frame[s] = self.frame + self.data[s] = getattr(msg, s) + self.logMonoTime[s] = msg.logMonoTime + self.valid[s] = msg.valid + + for s in self.data: + # arbitrary small number to avoid float comparison. If freq is 0, we can skip the check + if self.freq[s] > 1e-5: + # alive if delay is within 10x the expected frequency + self.alive[s] = (cur_time - self.rcv_time[s]) < (10. / self.freq[s]) + else: + self.alive[s] = True + + def all_alive(self, service_list=None) -> bool: + if service_list is None: # check all + service_list = self.alive.keys() + return all(self.alive[s] for s in service_list if s not in self.ignore_alive) + + def all_valid(self, service_list=None) -> bool: + if service_list is None: # check all + service_list = self.valid.keys() + return all(self.valid[s] for s in service_list) + + def all_alive_and_valid(self, service_list=None) -> bool: + if service_list is None: # check all + service_list = self.alive.keys() + return self.all_alive(service_list=service_list) and self.all_valid(service_list=service_list) + +class PubMaster(): + def __init__(self, services: List[str]): + self.sock = {} + for s in services: + self.sock[s] = pub_sock(s) + + def send(self, s: str, dat: Union[bytes, capnp.lib.capnp._DynamicStructBuilder]) -> None: + if not isinstance(dat, bytes): + dat = dat.to_bytes() + self.sock[s].send(dat) diff --git a/cereal/messaging/bridge.cc b/cereal/messaging/bridge.cc new file mode 100644 index 00000000000000..8e29566ca26c64 --- /dev/null +++ b/cereal/messaging/bridge.cc @@ -0,0 +1,64 @@ +#include +#include +#include +#include +#include + +typedef void (*sighandler_t)(int sig); + +#include "services.h" + +#include "impl_msgq.hpp" +#include "impl_zmq.hpp" + +void sigpipe_handler(int sig) { + assert(sig == SIGPIPE); + std::cout << "SIGPIPE received" << std::endl; +} + +static std::vector get_services() { + std::vector name_list; + + for (const auto& it : services) { + std::string name = it.name; + if (name == "plusFrame" || name == "uiLayoutState") continue; + name_list.push_back(name); + } + + return name_list; +} + + +int main(void){ + signal(SIGPIPE, (sighandler_t)sigpipe_handler); + + auto endpoints = get_services(); + + std::map sub2pub; + + Context *zmq_context = new ZMQContext(); + Context *msgq_context = new MSGQContext(); + Poller *poller = new MSGQPoller(); + + for (auto endpoint: endpoints){ + SubSocket * msgq_sock = new MSGQSubSocket(); + msgq_sock->connect(msgq_context, endpoint, "127.0.0.1", false); + poller->registerSocket(msgq_sock); + + PubSocket * zmq_sock = new ZMQPubSocket(); + zmq_sock->connect(zmq_context, endpoint); + + sub2pub[msgq_sock] = zmq_sock; + } + + + while (true){ + for (auto sub_sock : poller->poll(100)){ + Message * msg = sub_sock->receive(); + if (msg == NULL) continue; + sub2pub[sub_sock]->sendMessage(msg); + delete msg; + } + } + return 0; +} diff --git a/cereal/messaging/impl_msgq.cc b/cereal/messaging/impl_msgq.cc new file mode 100644 index 00000000000000..7da9a227c90d18 --- /dev/null +++ b/cereal/messaging/impl_msgq.cc @@ -0,0 +1,210 @@ +#include +#include +#include +#include +#include +#include + + +#include "impl_msgq.hpp" + +volatile sig_atomic_t msgq_do_exit = 0; + +void sig_handler(int signal) { + assert(signal == SIGINT || signal == SIGTERM); + msgq_do_exit = 1; +} + +static size_t get_size(std::string endpoint){ + size_t sz = DEFAULT_SEGMENT_SIZE; + +#if !defined(QCOM) && !defined(QCOM2) + if (endpoint == "frame" || endpoint == "frontFrame" || endpoint == "wideFrame"){ + sz *= 10; + } +#endif + + return sz; +} + + +MSGQContext::MSGQContext() { +} + +MSGQContext::~MSGQContext() { +} + +void MSGQMessage::init(size_t sz) { + size = sz; + data = new char[size]; +} + +void MSGQMessage::init(char * d, size_t sz) { + size = sz; + data = new char[size]; + memcpy(data, d, size); +} + +void MSGQMessage::takeOwnership(char * d, size_t sz) { + size = sz; + data = d; +} + +void MSGQMessage::close() { + if (size > 0){ + delete[] data; + } + size = 0; +} + +MSGQMessage::~MSGQMessage() { + this->close(); +} + +int MSGQSubSocket::connect(Context *context, std::string endpoint, std::string address, bool conflate){ + assert(context); + assert(address == "127.0.0.1"); + + q = new msgq_queue_t; + int r = msgq_new_queue(q, endpoint.c_str(), get_size(endpoint)); + if (r != 0){ + return r; + } + + msgq_init_subscriber(q); + + if (conflate){ + q->read_conflate = true; + } + + timeout = -1; + + return 0; +} + + +Message * MSGQSubSocket::receive(bool non_blocking){ + msgq_do_exit = 0; + + void (*prev_handler_sigint)(int); + void (*prev_handler_sigterm)(int); + if (!non_blocking){ + prev_handler_sigint = std::signal(SIGINT, sig_handler); + prev_handler_sigterm = std::signal(SIGTERM, sig_handler); + } + + msgq_msg_t msg; + + MSGQMessage *r = NULL; + + int rc = msgq_msg_recv(&msg, q); + + // Hack to implement blocking read with a poller. Don't use this + while (!non_blocking && rc == 0 && msgq_do_exit == 0){ + msgq_pollitem_t items[1]; + items[0].q = q; + + int t = (timeout != -1) ? timeout : 100; + + int n = msgq_poll(items, 1, t); + rc = msgq_msg_recv(&msg, q); + + // The poll indicated a message was ready, but the receive failed. Try again + if (n == 1 && rc == 0){ + continue; + } + + if (timeout != -1){ + break; + } + } + + + if (!non_blocking){ + std::signal(SIGINT, prev_handler_sigint); + std::signal(SIGTERM, prev_handler_sigterm); + } + + errno = msgq_do_exit ? EINTR : 0; + + if (rc > 0){ + if (msgq_do_exit){ + msgq_msg_close(&msg); // Free unused message on exit + } else { + r = new MSGQMessage; + r->takeOwnership(msg.data, msg.size); + } + } + + return (Message*)r; +} + +void MSGQSubSocket::setTimeout(int t){ + timeout = t; +} + +MSGQSubSocket::~MSGQSubSocket(){ + if (q != NULL){ + msgq_close_queue(q); + delete q; + } +} + +int MSGQPubSocket::connect(Context *context, std::string endpoint){ + assert(context); + + q = new msgq_queue_t; + int r = msgq_new_queue(q, endpoint.c_str(), get_size(endpoint)); + if (r != 0){ + return r; + } + + msgq_init_publisher(q); + + return 0; +} + +int MSGQPubSocket::sendMessage(Message *message){ + msgq_msg_t msg; + msg.data = message->getData(); + msg.size = message->getSize(); + + return msgq_msg_send(&msg, q); +} + +int MSGQPubSocket::send(char *data, size_t size){ + msgq_msg_t msg; + msg.data = data; + msg.size = size; + + return msgq_msg_send(&msg, q); +} + +MSGQPubSocket::~MSGQPubSocket(){ + if (q != NULL){ + msgq_close_queue(q); + delete q; + } +} + + +void MSGQPoller::registerSocket(SubSocket * socket){ + assert(num_polls + 1 < MAX_POLLERS); + polls[num_polls].q = (msgq_queue_t*)socket->getRawSocket(); + + sockets.push_back(socket); + num_polls++; +} + +std::vector MSGQPoller::poll(int timeout){ + std::vector r; + + msgq_poll(polls, num_polls, timeout); + for (size_t i = 0; i < num_polls; i++){ + if (polls[i].revents){ + r.push_back(sockets[i]); + } + } + + return r; +} diff --git a/cereal/messaging/impl_msgq.hpp b/cereal/messaging/impl_msgq.hpp new file mode 100644 index 00000000000000..98e6809457df6d --- /dev/null +++ b/cereal/messaging/impl_msgq.hpp @@ -0,0 +1,64 @@ +#pragma once +#include "messaging.hpp" +#include "msgq.hpp" +#include +#include + +#define MAX_POLLERS 128 + +class MSGQContext : public Context { +private: + void * context = NULL; +public: + MSGQContext(); + void * getRawContext() {return context;} + ~MSGQContext(); +}; + +class MSGQMessage : public Message { +private: + char * data; + size_t size; +public: + void init(size_t size); + void init(char *data, size_t size); + void takeOwnership(char *data, size_t size); + size_t getSize(){return size;} + char * getData(){return data;} + void close(); + ~MSGQMessage(); +}; + +class MSGQSubSocket : public SubSocket { +private: + msgq_queue_t * q = NULL; + int timeout; +public: + int connect(Context *context, std::string endpoint, std::string address, bool conflate=false); + void setTimeout(int timeout); + void * getRawSocket() {return (void*)q;} + Message *receive(bool non_blocking=false); + ~MSGQSubSocket(); +}; + +class MSGQPubSocket : public PubSocket { +private: + msgq_queue_t * q = NULL; +public: + int connect(Context *context, std::string endpoint); + int sendMessage(Message *message); + int send(char *data, size_t size); + ~MSGQPubSocket(); +}; + +class MSGQPoller : public Poller { +private: + std::vector sockets; + msgq_pollitem_t polls[MAX_POLLERS]; + size_t num_polls = 0; + +public: + void registerSocket(SubSocket *socket); + std::vector poll(int timeout); + ~MSGQPoller(){}; +}; diff --git a/cereal/messaging/impl_zmq.cc b/cereal/messaging/impl_zmq.cc new file mode 100644 index 00000000000000..195124de684121 --- /dev/null +++ b/cereal/messaging/impl_zmq.cc @@ -0,0 +1,155 @@ +#include +#include +#include +#include +#include + +#include + +#include "services.h" +#include "impl_zmq.hpp" + +static int get_port(std::string endpoint) { + int port = -1; + for (const auto& it : services) { + std::string name = it.name; + if (name == endpoint) { + port = it.port; + break; + } + } + + assert(port >= 0); + return port; +} + +ZMQContext::ZMQContext() { + context = zmq_ctx_new(); +} + +ZMQContext::~ZMQContext() { + zmq_ctx_term(context); +} + +void ZMQMessage::init(size_t sz) { + size = sz; + data = new char[size]; +} + +void ZMQMessage::init(char * d, size_t sz) { + size = sz; + data = new char[size]; + memcpy(data, d, size); +} + +void ZMQMessage::close() { + if (size > 0){ + delete[] data; + } + size = 0; +} + +ZMQMessage::~ZMQMessage() { + this->close(); +} + + +int ZMQSubSocket::connect(Context *context, std::string endpoint, std::string address, bool conflate){ + sock = zmq_socket(context->getRawContext(), ZMQ_SUB); + if (sock == NULL){ + return -1; + } + + zmq_setsockopt(sock, ZMQ_SUBSCRIBE, "", 0); + + if (conflate){ + int arg = 1; + zmq_setsockopt(sock, ZMQ_CONFLATE, &arg, sizeof(int)); + } + + int reconnect_ivl = 500; + zmq_setsockopt(sock, ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl, sizeof(reconnect_ivl)); + + full_endpoint = "tcp://" + address + ":"; + full_endpoint += std::to_string(get_port(endpoint)); + + return zmq_connect(sock, full_endpoint.c_str()); +} + + +Message * ZMQSubSocket::receive(bool non_blocking){ + zmq_msg_t msg; + assert(zmq_msg_init(&msg) == 0); + + int flags = non_blocking ? ZMQ_DONTWAIT : 0; + int rc = zmq_msg_recv(&msg, sock, flags); + Message *r = NULL; + + if (rc >= 0){ + // Make a copy to ensure the data is aligned + r = new ZMQMessage; + r->init((char*)zmq_msg_data(&msg), zmq_msg_size(&msg)); + } + + zmq_msg_close(&msg); + return r; +} + +void ZMQSubSocket::setTimeout(int timeout){ + zmq_setsockopt(sock, ZMQ_RCVTIMEO, &timeout, sizeof(int)); +} + +ZMQSubSocket::~ZMQSubSocket(){ + zmq_close(sock); +} + +int ZMQPubSocket::connect(Context *context, std::string endpoint){ + sock = zmq_socket(context->getRawContext(), ZMQ_PUB); + if (sock == NULL){ + return -1; + } + + full_endpoint = "tcp://*:"; + full_endpoint += std::to_string(get_port(endpoint)); + + return zmq_bind(sock, full_endpoint.c_str()); +} + +int ZMQPubSocket::sendMessage(Message *message){ + return zmq_send(sock, message->getData(), message->getSize(), ZMQ_DONTWAIT); +} + +int ZMQPubSocket::send(char *data, size_t size){ + return zmq_send(sock, data, size, ZMQ_DONTWAIT); +} + +ZMQPubSocket::~ZMQPubSocket(){ + zmq_close(sock); +} + + +void ZMQPoller::registerSocket(SubSocket * socket){ + assert(num_polls + 1 < MAX_POLLERS); + polls[num_polls].socket = socket->getRawSocket(); + polls[num_polls].events = ZMQ_POLLIN; + + sockets.push_back(socket); + num_polls++; +} + +std::vector ZMQPoller::poll(int timeout){ + std::vector r; + + int rc = zmq_poll(polls, num_polls, timeout); + if (rc < 0){ + return r; + } + + for (size_t i = 0; i < num_polls; i++){ + if (polls[i].revents){ + r.push_back(sockets[i]); + } + } + + return r; +} diff --git a/cereal/messaging/impl_zmq.hpp b/cereal/messaging/impl_zmq.hpp new file mode 100644 index 00000000000000..bfa9b74cdc30d8 --- /dev/null +++ b/cereal/messaging/impl_zmq.hpp @@ -0,0 +1,63 @@ +#pragma once +#include "messaging.hpp" +#include +#include + +#define MAX_POLLERS 128 + +class ZMQContext : public Context { +private: + void * context = NULL; +public: + ZMQContext(); + void * getRawContext() {return context;} + ~ZMQContext(); +}; + +class ZMQMessage : public Message { +private: + char * data; + size_t size; +public: + void init(size_t size); + void init(char *data, size_t size); + size_t getSize(){return size;} + char * getData(){return data;} + void close(); + ~ZMQMessage(); +}; + +class ZMQSubSocket : public SubSocket { +private: + void * sock; + std::string full_endpoint; +public: + int connect(Context *context, std::string endpoint, std::string address, bool conflate=false); + void setTimeout(int timeout); + void * getRawSocket() {return sock;} + Message *receive(bool non_blocking=false); + ~ZMQSubSocket(); +}; + +class ZMQPubSocket : public PubSocket { +private: + void * sock; + std::string full_endpoint; +public: + int connect(Context *context, std::string endpoint); + int sendMessage(Message *message); + int send(char *data, size_t size); + ~ZMQPubSocket(); +}; + +class ZMQPoller : public Poller { +private: + std::vector sockets; + zmq_pollitem_t polls[MAX_POLLERS]; + size_t num_polls = 0; + +public: + void registerSocket(SubSocket *socket); + std::vector poll(int timeout); + ~ZMQPoller(){}; +}; diff --git a/cereal/messaging/messaging.cc b/cereal/messaging/messaging.cc new file mode 100644 index 00000000000000..9e2ae409d1dc08 --- /dev/null +++ b/cereal/messaging/messaging.cc @@ -0,0 +1,123 @@ +#include "messaging.hpp" +#include "impl_zmq.hpp" +#include "impl_msgq.hpp" + +#ifdef __APPLE__ +const bool MUST_USE_ZMQ = true; +#else +const bool MUST_USE_ZMQ = false; +#endif + +Context * Context::create(){ + Context * c; + if (std::getenv("ZMQ") || MUST_USE_ZMQ){ + c = new ZMQContext(); + } else { + c = new MSGQContext(); + } + return c; +} + +SubSocket * SubSocket::create(){ + SubSocket * s; + if (std::getenv("ZMQ") || MUST_USE_ZMQ){ + s = new ZMQSubSocket(); + } else { + s = new MSGQSubSocket(); + } + return s; +} + +SubSocket * SubSocket::create(Context * context, std::string endpoint){ + SubSocket *s = SubSocket::create(); + int r = s->connect(context, endpoint, "127.0.0.1"); + + if (r == 0) { + return s; + } else { + delete s; + return NULL; + } +} + +SubSocket * SubSocket::create(Context * context, std::string endpoint, std::string address){ + SubSocket *s = SubSocket::create(); + int r = s->connect(context, endpoint, address); + + if (r == 0) { + return s; + } else { + delete s; + return NULL; + } +} + +SubSocket * SubSocket::create(Context * context, std::string endpoint, std::string address, bool conflate){ + SubSocket *s = SubSocket::create(); + int r = s->connect(context, endpoint, address, conflate); + + if (r == 0) { + return s; + } else { + delete s; + return NULL; + } +} + +PubSocket * PubSocket::create(){ + PubSocket * s; + if (std::getenv("ZMQ") || MUST_USE_ZMQ){ + s = new ZMQPubSocket(); + } else { + s = new MSGQPubSocket(); + } + return s; +} + +PubSocket * PubSocket::create(Context * context, std::string endpoint){ + PubSocket *s = PubSocket::create(); + int r = s->connect(context, endpoint); + + if (r == 0) { + return s; + } else { + delete s; + return NULL; + } +} + +Poller * Poller::create(){ + Poller * p; + if (std::getenv("ZMQ") || MUST_USE_ZMQ){ + p = new ZMQPoller(); + } else { + p = new MSGQPoller(); + } + return p; +} + +Poller * Poller::create(std::vector sockets){ + Poller * p = Poller::create(); + + for (auto s : sockets){ + p->registerSocket(s); + } + return p; +} + +extern "C" Context * messaging_context_create() { + return Context::create(); +} + +extern "C" SubSocket * messaging_subsocket_create(Context* context, const char* endpoint) { + return SubSocket::create(context, std::string(endpoint)); +} + +extern "C" PubSocket * messaging_pubsocket_create(Context* context, const char* endpoint) { + return PubSocket::create(context, std::string(endpoint)); +} + +extern "C" Poller * messaging_poller_create(SubSocket** sockets, int size) { + std::vector socketsVec(sockets, sockets + size); + return Poller::create(socketsVec); +} diff --git a/cereal/messaging/messaging.hpp b/cereal/messaging/messaging.hpp new file mode 100644 index 00000000000000..9ade8bf2b4381b --- /dev/null +++ b/cereal/messaging/messaging.hpp @@ -0,0 +1,121 @@ +#pragma once +#include +#include +#include +#include +#include +#include "../gen/cpp/log.capnp.h" + +#ifdef __APPLE__ +#define CLOCK_BOOTTIME CLOCK_MONOTONIC +#endif + +#define MSG_MULTIPLE_PUBLISHERS 100 + +class Context { +public: + virtual void * getRawContext() = 0; + static Context * create(); + virtual ~Context(){}; +}; + +class Message { +public: + virtual void init(size_t size) = 0; + virtual void init(char * data, size_t size) = 0; + virtual void close() = 0; + virtual size_t getSize() = 0; + virtual char * getData() = 0; + virtual ~Message(){}; +}; + + +class SubSocket { +public: + virtual int connect(Context *context, std::string endpoint, std::string address, bool conflate=false) = 0; + virtual void setTimeout(int timeout) = 0; + virtual Message *receive(bool non_blocking=false) = 0; + virtual void * getRawSocket() = 0; + static SubSocket * create(); + static SubSocket * create(Context * context, std::string endpoint); + static SubSocket * create(Context * context, std::string endpoint, std::string address); + static SubSocket * create(Context * context, std::string endpoint, std::string address, bool conflate); + virtual ~SubSocket(){}; +}; + +class PubSocket { +public: + virtual int connect(Context *context, std::string endpoint) = 0; + virtual int sendMessage(Message *message) = 0; + virtual int send(char *data, size_t size) = 0; + static PubSocket * create(); + static PubSocket * create(Context * context, std::string endpoint); + virtual ~PubSocket(){}; +}; + +class Poller { +public: + virtual void registerSocket(SubSocket *socket) = 0; + virtual std::vector poll(int timeout) = 0; + static Poller * create(); + static Poller * create(std::vector sockets); + virtual ~Poller(){}; +}; + +class SubMaster { +public: + SubMaster(const std::initializer_list &service_list, + const char *address = nullptr, const std::initializer_list &ignore_alive = {}); + int update(int timeout = 1000); + inline bool allAlive(const std::initializer_list &service_list = {}) { return all_(service_list, false, true); } + inline bool allValid(const std::initializer_list &service_list = {}) { return all_(service_list, true, false); } + inline bool allAliveAndValid(const std::initializer_list &service_list = {}) { return all_(service_list, true, true); } + void drain(); + ~SubMaster(); + + uint64_t frame = 0; + bool updated(const char *name) const; + uint64_t rcv_frame(const char *name) const; + cereal::Event::Reader &operator[](const char *name); + +private: + bool all_(const std::initializer_list &service_list, bool valid, bool alive); + Poller *poller_ = nullptr; + struct SubMessage; + std::map messages_; + std::map services_; +}; + +class MessageBuilder : public capnp::MallocMessageBuilder { +public: + MessageBuilder() = default; + + cereal::Event::Builder initEvent(bool valid = true) { + cereal::Event::Builder event = initRoot(); + struct timespec t; + clock_gettime(CLOCK_BOOTTIME, &t); + uint64_t current_time = t.tv_sec * 1000000000ULL + t.tv_nsec; + event.setLogMonoTime(current_time); + event.setValid(valid); + return event; + } + + kj::ArrayPtr toBytes() { + heapArray_ = capnp::messageToFlatArray(*this); + return heapArray_.asBytes(); + } + +private: + kj::Array heapArray_; +}; + +class PubMaster { +public: + PubMaster(const std::initializer_list &service_list); + inline int send(const char *name, capnp::byte *data, size_t size) { return sockets_.at(name)->send((char *)data, size); } + int send(const char *name, MessageBuilder &msg); + ~PubMaster(); + +private: + std::map sockets_; +}; diff --git a/cereal/messaging/messaging.pxd b/cereal/messaging/messaging.pxd new file mode 100644 index 00000000000000..8bbb2c7ab0564b --- /dev/null +++ b/cereal/messaging/messaging.pxd @@ -0,0 +1,39 @@ +# distutils: language = c++ +#cython: language_level=3 + +from libcpp.string cimport string +from libcpp.vector cimport vector +from libcpp cimport bool + + +cdef extern from "messaging.hpp": + cdef cppclass Context: + @staticmethod + Context * create() + + cdef cppclass Message: + void init(size_t) + void init(char *, size_t) + void close() + size_t getSize() + char *getData() + + cdef cppclass SubSocket: + @staticmethod + SubSocket * create() + int connect(Context *, string, string, bool) + Message * receive(bool) + void setTimeout(int) + + cdef cppclass PubSocket: + @staticmethod + PubSocket * create() + int connect(Context *, string) + int sendMessage(Message *) + int send(char *, size_t) + + cdef cppclass Poller: + @staticmethod + Poller * create() + void registerSocket(SubSocket *) + vector[SubSocket*] poll(int) nogil diff --git a/cereal/messaging/messaging_pyx.pyx b/cereal/messaging/messaging_pyx.pyx new file mode 100644 index 00000000000000..fa220c43543b73 --- /dev/null +++ b/cereal/messaging/messaging_pyx.pyx @@ -0,0 +1,151 @@ +# distutils: language = c++ +# cython: c_string_encoding=ascii, language_level=3 + +import sys +from libcpp.string cimport string +from libcpp cimport bool +from libc cimport errno + + +from .messaging cimport Context as cppContext +from .messaging cimport SubSocket as cppSubSocket +from .messaging cimport PubSocket as cppPubSocket +from .messaging cimport Poller as cppPoller +from .messaging cimport Message as cppMessage + + +class MessagingError(Exception): + pass + + +class MultiplePublishersError(MessagingError): + pass + + +cdef class Context: + cdef cppContext * context + + def __cinit__(self): + self.context = cppContext.create() + + def term(self): + del self.context + self.context = NULL + + def __dealloc__(self): + pass + # Deleting the context will hang if sockets are still active + # TODO: Figure out a way to make sure the context is closed last + # del self.context + + +cdef class Poller: + cdef cppPoller * poller + cdef list sub_sockets + + def __cinit__(self): + self.sub_sockets = [] + self.poller = cppPoller.create() + + def __dealloc__(self): + del self.poller + + def registerSocket(self, SubSocket socket): + self.sub_sockets.append(socket) + self.poller.registerSocket(socket.socket) + + def poll(self, timeout): + sockets = [] + cdef int t = timeout + + with nogil: + result = self.poller.poll(t) + + for s in result: + socket = SubSocket() + socket.setPtr(s) + sockets.append(socket) + + return sockets + +cdef class SubSocket: + cdef cppSubSocket * socket + cdef bool is_owner + + def __cinit__(self): + self.socket = cppSubSocket.create() + self.is_owner = True + + if self.socket == NULL: + raise MessagingError + + def __dealloc__(self): + if self.is_owner: + del self.socket + + cdef setPtr(self, cppSubSocket * ptr): + if self.is_owner: + del self.socket + + self.is_owner = False + self.socket = ptr + + def connect(self, Context context, string endpoint, string address=b"127.0.0.1", bool conflate=False): + r = self.socket.connect(context.context, endpoint, address, conflate) + + if r != 0: + if errno.errno == errno.EADDRINUSE: + raise MultiplePublishersError + else: + raise MessagingError + + def setTimeout(self, int timeout): + self.socket.setTimeout(timeout) + + def receive(self, bool non_blocking=False): + msg = self.socket.receive(non_blocking) + + if msg == NULL: + # If a blocking read returns no message check errno if SIGINT was caught in the C++ code + if errno.errno == errno.EINTR: + print("SIGINT received, exiting") + sys.exit(1) + + return None + else: + sz = msg.getSize() + m = msg.getData()[:sz] + del msg + + return m + + +cdef class PubSocket: + cdef cppPubSocket * socket + + def __cinit__(self): + self.socket = cppPubSocket.create() + if self.socket == NULL: + raise MessagingError + + def __dealloc__(self): + del self.socket + + def connect(self, Context context, string endpoint): + r = self.socket.connect(context.context, endpoint) + + if r != 0: + if errno.errno == errno.EADDRINUSE: + raise MultiplePublishersError + else: + raise MessagingError + + def send(self, bytes data): + length = len(data) + r = self.socket.send(data, length) + + if r != length: + if errno.errno == errno.EADDRINUSE: + raise MultiplePublishersError + else: + raise MessagingError diff --git a/cereal/messaging/msgq.cc b/cereal/messaging/msgq.cc new file mode 100644 index 00000000000000..30b0225cd7e77c --- /dev/null +++ b/cereal/messaging/msgq.cc @@ -0,0 +1,467 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "services.h" + +#include "msgq.hpp" + +void sigusr2_handler(int signal) { + assert(signal == SIGUSR2); +} + +uint64_t msgq_get_uid(void){ + std::random_device rd("/dev/urandom"); + std::uniform_int_distribution distribution(0,std::numeric_limits::max()); + + #ifdef __APPLE__ + // TODO: this doesn't work + uint64_t uid = distribution(rd) << 32 | getpid(); + #else + uint64_t uid = distribution(rd) << 32 | syscall(SYS_gettid); + #endif + + return uid; +} + +int msgq_msg_init_size(msgq_msg_t * msg, size_t size){ + msg->size = size; + msg->data = new(std::nothrow) char[size]; + + return (msg->data == NULL) ? -1 : 0; +} + + +int msgq_msg_init_data(msgq_msg_t * msg, char * data, size_t size) { + int r = msgq_msg_init_size(msg, size); + + if (r == 0) + memcpy(msg->data, data, size); + + return r; +} + +int msgq_msg_close(msgq_msg_t * msg){ + if (msg->size > 0) + delete[] msg->data; + + msg->size = 0; + + return 0; +} + +void msgq_reset_reader(msgq_queue_t * q){ + int id = q->reader_id; + q->read_valids[id]->store(true); + q->read_pointers[id]->store(*q->write_pointer); +} + +void msgq_wait_for_subscriber(msgq_queue_t *q){ + while (*q->num_readers == 0){ + ; + } + + return; +} + +bool service_exists(std::string path){ + for (const auto& it : services) { + if (it.name == path) { + return true; + } + } + return false; +} + +int msgq_new_queue(msgq_queue_t * q, const char * path, size_t size){ + assert(size < 0xFFFFFFFF); // Buffer must be smaller than 2^32 bytes + if (!service_exists(std::string(path))){ + std::cout << "Warning, " << std::string(path) << " is not in service list." << std::endl; + } + std::signal(SIGUSR2, sigusr2_handler); + + const char * prefix = "/dev/shm/"; + char * full_path = new char[strlen(path) + strlen(prefix) + 1]; + strcpy(full_path, prefix); + strcat(full_path, path); + + auto fd = open(full_path, O_RDWR | O_CREAT, 0777); + if (fd < 0) { + std::cout << "Warning, could not open: " << full_path << std::endl; + delete[] full_path; + return -1; + } + delete[] full_path; + + int rc = ftruncate(fd, size + sizeof(msgq_header_t)); + if (rc < 0){ + close(fd); + return -1; + } + char * mem = (char*)mmap(NULL, size + sizeof(msgq_header_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + close(fd); + + if (mem == NULL){ + return -1; + } + q->mmap_p = mem; + + msgq_header_t *header = (msgq_header_t *)mem; + + // Setup pointers to header segment + q->num_readers = reinterpret_cast*>(&header->num_readers); + q->write_pointer = reinterpret_cast*>(&header->write_pointer); + q->write_uid = reinterpret_cast*>(&header->write_uid); + + for (size_t i = 0; i < NUM_READERS; i++){ + q->read_pointers[i] = reinterpret_cast*>(&header->read_pointers[i]); + q->read_valids[i] = reinterpret_cast*>(&header->read_valids[i]); + q->read_uids[i] = reinterpret_cast*>(&header->read_uids[i]); + } + + q->data = mem + sizeof(msgq_header_t); + q->size = size; + q->reader_id = -1; + + q->endpoint = path; + q->read_conflate = false; + + return 0; +} + +void msgq_close_queue(msgq_queue_t *q){ + if (q->mmap_p != NULL){ + munmap(q->mmap_p, q->size + sizeof(msgq_header_t)); + } +} + + +void msgq_init_publisher(msgq_queue_t * q) { + //std::cout << "Starting publisher" << std::endl; + uint64_t uid = msgq_get_uid(); + + *q->write_uid = uid; + *q->num_readers = 0; + + for (size_t i = 0; i < NUM_READERS; i++){ + *q->read_valids[i] = false; + *q->read_uids[i] = 0; + } + + q->write_uid_local = uid; +} + +static void thread_signal(uint32_t tid) { + #ifndef SYS_tkill + // TODO: this won't work for multithreaded programs + kill(tid, SIGUSR2); + #else + syscall(SYS_tkill, tid, SIGUSR2); + #endif +} + +void msgq_init_subscriber(msgq_queue_t * q) { + assert(q != NULL); + assert(q->num_readers != NULL); + + uint64_t uid = msgq_get_uid(); + + // Get reader id + while (true){ + uint64_t cur_num_readers = *q->num_readers; + uint64_t new_num_readers = cur_num_readers + 1; + + // No more slots available. Reset all subscribers to kick out inactive ones + if (new_num_readers > NUM_READERS){ + std::cout << "Warning, evicting all subscribers!" << std::endl; + *q->num_readers = 0; + + for (size_t i = 0; i < NUM_READERS; i++){ + *q->read_valids[i] = false; + + uint64_t old_uid = *q->read_uids[i]; + *q->read_uids[i] = 0; + + // Wake up reader in case they are in a poll + thread_signal(old_uid & 0xFFFFFFFF); + } + + continue; + } + + // Use atomic compare and swap to handle race condition + // where two subscribers start at the same time + if (std::atomic_compare_exchange_strong(q->num_readers, + &cur_num_readers, + new_num_readers)){ + q->reader_id = cur_num_readers; + q->read_uid_local = uid; + + // We start with read_valid = false, + // on the first read the read pointer will be synchronized with the write pointer + *q->read_valids[cur_num_readers] = false; + *q->read_pointers[cur_num_readers] = 0; + *q->read_uids[cur_num_readers] = uid; + break; + } + } + + //std::cout << "New subscriber id: " << q->reader_id << " uid: " << q->read_uid_local << " " << q->endpoint << std::endl; + msgq_reset_reader(q); +} + +int msgq_msg_send(msgq_msg_t * msg, msgq_queue_t *q){ + // Die if we are no longer the active publisher + if (q->write_uid_local != *q->write_uid){ + std::cout << "Killing old publisher: " << q->endpoint << std::endl; + errno = EADDRINUSE; + return -1; + } + + uint64_t total_msg_size = ALIGN(msg->size + sizeof(int64_t)); + + // We need to fit at least three messages in the queue, + // then we can always safely access the last message + assert(3 * total_msg_size <= q->size); + + uint64_t num_readers = *q->num_readers; + + uint32_t write_cycles, write_pointer; + UNPACK64(write_cycles, write_pointer, *q->write_pointer); + + char *p = q->data + write_pointer; // add base offset + + // Check remaining space + // Always leave space for a wraparound tag for the next message, including alignment + int64_t remaining_space = q->size - write_pointer - total_msg_size - sizeof(int64_t); + if (remaining_space <= 0){ + // Write -1 size tag indicating wraparound + *(int64_t*)p = -1; + + // Invalidate all readers that are beyond the write pointer + // TODO: should we handle the case where a new reader shows up while this is running? + for (uint64_t i = 0; i < num_readers; i++){ + uint64_t read_pointer = *q->read_pointers[i]; + uint64_t read_cycles = read_pointer >> 32; + read_pointer &= 0xFFFFFFFF; + + if ((read_pointer > write_pointer) && (read_cycles != write_cycles)) { + *q->read_valids[i] = false; + } + } + + // Update global and local copies of write pointer and write_cycles + write_pointer = 0; + write_cycles = write_cycles + 1; + PACK64(*q->write_pointer, write_cycles, write_pointer); + + // Set actual pointer to the beginning of the data segment + p = q->data; + } + + // Invalidate readers that are in the area that will be written + uint64_t start = write_pointer; + uint64_t end = ALIGN(start + sizeof(int64_t) + msg->size); + + for (uint64_t i = 0; i < num_readers; i++){ + uint32_t read_cycles, read_pointer; + UNPACK64(read_cycles, read_pointer, *q->read_pointers[i]); + + if ((read_pointer >= start) && (read_pointer < end) && (read_cycles != write_cycles)) { + *q->read_valids[i] = false; + } + } + + + // Write size tag + std::atomic *size_p = reinterpret_cast*>(p); + *size_p = msg->size; + + // Copy data + memcpy(p + sizeof(int64_t), msg->data, msg->size); + __sync_synchronize(); + + // Update write pointer + uint32_t new_ptr = ALIGN(write_pointer + msg->size + sizeof(int64_t)); + PACK64(*q->write_pointer, write_cycles, new_ptr); + + // Notify readers + for (uint64_t i = 0; i < num_readers; i++){ + uint64_t reader_uid = *q->read_uids[i]; + thread_signal(reader_uid & 0xFFFFFFFF); + } + + return msg->size; +} + + +int msgq_msg_ready(msgq_queue_t * q){ + start: + int id = q->reader_id; + assert(id >= 0); // Make sure subscriber is initialized + + if (q->read_uid_local != *q->read_uids[id]){ + std::cout << q->endpoint << ": Reader was evicted, reconnecting" << std::endl; + msgq_init_subscriber(q); + goto start; + } + + // Check valid + if (!*q->read_valids[id]){ + msgq_reset_reader(q); + goto start; + } + + uint32_t read_cycles, read_pointer; + UNPACK64(read_cycles, read_pointer, *q->read_pointers[id]); + + uint32_t write_cycles, write_pointer; + UNPACK64(write_cycles, write_pointer, *q->write_pointer); + + // Check if new message is available + return (read_pointer != write_pointer); +} + +int msgq_msg_recv(msgq_msg_t * msg, msgq_queue_t * q){ + start: + int id = q->reader_id; + assert(id >= 0); // Make sure subscriber is initialized + + if (q->read_uid_local != *q->read_uids[id]){ + std::cout << q->endpoint << ": Reader was evicted, reconnecting" << std::endl; + msgq_init_subscriber(q); + goto start; + } + + // Check valid + if (!*q->read_valids[id]){ + msgq_reset_reader(q); + goto start; + } + + uint32_t read_cycles, read_pointer; + UNPACK64(read_cycles, read_pointer, *q->read_pointers[id]); + + uint32_t write_cycles, write_pointer; + UNPACK64(write_cycles, write_pointer, *q->write_pointer); + + char * p = q->data + read_pointer; + + // Check if new message is available + if (read_pointer == write_pointer) { + msg->size = 0; + return 0; + } + + // Read potential message size + std::atomic *size_p = reinterpret_cast*>(p); + std::int64_t size = *size_p; + + // Check if the size that was read is valid + if (!*q->read_valids[id]){ + msgq_reset_reader(q); + goto start; + } + + // If size is -1 the buffer was full, and we need to wrap around + if (size == -1){ + read_cycles++; + PACK64(*q->read_pointers[id], read_cycles, 0); + goto start; + } + + // crashing is better than passing garbage data to the consumer + // the size will have weird value if it was overwritten by data accidentally + assert((uint64_t)size < q->size); + assert(size > 0); + + uint32_t new_read_pointer = ALIGN(read_pointer + sizeof(std::int64_t) + size); + + // If conflate is true, check if this is the latest message, else start over + if (q->read_conflate){ + if (new_read_pointer != write_pointer){ + // Update read pointer + PACK64(*q->read_pointers[id], read_cycles, new_read_pointer); + goto start; + } + } + + // Copy message + if (msgq_msg_init_size(msg, size) < 0) + return -1; + + __sync_synchronize(); + memcpy(msg->data, p + sizeof(int64_t), size); + __sync_synchronize(); + + // Update read pointer + PACK64(*q->read_pointers[id], read_cycles, new_read_pointer); + + // Check if the actual data that was copied is valid + if (!*q->read_valids[id]){ + msgq_msg_close(msg); + msgq_reset_reader(q); + goto start; + } + + + return msg->size; +} + + + +int msgq_poll(msgq_pollitem_t * items, size_t nitems, int timeout){ + int num = 0; + + // Check if messages ready + for (size_t i = 0; i < nitems; i++) { + items[i].revents = msgq_msg_ready(items[i].q); + if (items[i].revents) num++; + } + + int ms = (timeout == -1) ? 100 : timeout; + struct timespec ts; + ts.tv_sec = ms / 1000; + ts.tv_nsec = (ms % 1000) * 1000 * 1000; + + + while (num == 0) { + int ret; + + ret = nanosleep(&ts, &ts); + + // Check if messages ready + for (size_t i = 0; i < nitems; i++) { + if (items[i].revents == 0 && msgq_msg_ready(items[i].q)){ + num += 1; + items[i].revents = 1; + } + } + + // exit if we had a timeout and the sleep finished + if (timeout != -1 && ret == 0){ + break; + } + } + + return num; +} diff --git a/cereal/messaging/msgq.hpp b/cereal/messaging/msgq.hpp new file mode 100644 index 00000000000000..3bead13d9d7e67 --- /dev/null +++ b/cereal/messaging/msgq.hpp @@ -0,0 +1,66 @@ +#pragma once +#include +#include +#include +#include + +#define DEFAULT_SEGMENT_SIZE (10 * 1024 * 1024) +#define NUM_READERS 8 +#define ALIGN(n) ((n + (8 - 1)) & -8) + +#define UNPACK64(higher, lower, input) do {uint64_t tmp = input; higher = tmp >> 32; lower = tmp & 0xFFFFFFFF;} while (0) +#define PACK64(output, higher, lower) output = ((uint64_t)higher << 32 ) | ((uint64_t)lower & 0xFFFFFFFF) + +struct msgq_header_t { + uint64_t num_readers; + uint64_t write_pointer; + uint64_t write_uid; + uint64_t read_pointers[NUM_READERS]; + uint64_t read_valids[NUM_READERS]; + uint64_t read_uids[NUM_READERS]; +}; + +struct msgq_queue_t { + std::atomic *num_readers; + std::atomic *write_pointer; + std::atomic *write_uid; + std::atomic *read_pointers[NUM_READERS]; + std::atomic *read_valids[NUM_READERS]; + std::atomic *read_uids[NUM_READERS]; + char * mmap_p; + char * data; + size_t size; + int reader_id; + uint64_t read_uid_local; + uint64_t write_uid_local; + + bool read_conflate; + std::string endpoint; +}; + +struct msgq_msg_t { + size_t size; + char * data; +}; + +struct msgq_pollitem_t { + msgq_queue_t *q; + int revents; +}; + +void msgq_wait_for_subscriber(msgq_queue_t *q); +void msgq_reset_reader(msgq_queue_t *q); + +int msgq_msg_init_size(msgq_msg_t *msg, size_t size); +int msgq_msg_init_data(msgq_msg_t *msg, char * data, size_t size); +int msgq_msg_close(msgq_msg_t *msg); + +int msgq_new_queue(msgq_queue_t * q, const char * path, size_t size); +void msgq_close_queue(msgq_queue_t *q); +void msgq_init_publisher(msgq_queue_t * q); +void msgq_init_subscriber(msgq_queue_t * q); + +int msgq_msg_send(msgq_msg_t *msg, msgq_queue_t *q); +int msgq_msg_recv(msgq_msg_t *msg, msgq_queue_t *q); +int msgq_msg_ready(msgq_queue_t * q); +int msgq_poll(msgq_pollitem_t * items, size_t nitems, int timeout); diff --git a/cereal/messaging/socketmaster.cc b/cereal/messaging/socketmaster.cc new file mode 100644 index 00000000000000..53821aa21fd039 --- /dev/null +++ b/cereal/messaging/socketmaster.cc @@ -0,0 +1,170 @@ +#include +#include +#include "messaging.hpp" +#include "services.h" + +static inline uint64_t nanos_since_boot() { + struct timespec t; + clock_gettime(CLOCK_BOOTTIME, &t); + return t.tv_sec * 1000000000ULL + t.tv_nsec; +} + +static const service *get_service(const char *name) { + for (const auto &it : services) { + if (strcmp(it.name, name) == 0) return ⁢ + } + return nullptr; +} + +static inline bool inList(const std::initializer_list &list, const char *value) { + for (auto &v : list) { + if (strcmp(value, v) == 0) return true; + } + return false; +} + +class MessageContext { +public: + MessageContext() { ctx_ = Context::create(); } + ~MessageContext() { delete ctx_; } + Context *ctx_; +}; +MessageContext ctx; + +struct SubMaster::SubMessage { + std::string name; + SubSocket *socket = nullptr; + int freq = 0; + bool updated = false, alive = false, valid = false, ignore_alive; + uint64_t rcv_time = 0, rcv_frame = 0; + void *allocated_msg_reader = nullptr; + capnp::FlatArrayMessageReader *msg_reader = nullptr; + kj::Array buf; + cereal::Event::Reader event; +}; + +SubMaster::SubMaster(const std::initializer_list &service_list, const char *address, + const std::initializer_list &ignore_alive) { + poller_ = Poller::create(); + for (auto name : service_list) { + const service *serv = get_service(name); + assert(serv != nullptr); + SubSocket *socket = SubSocket::create(ctx.ctx_, name, address ? address : "127.0.0.1", true); + assert(socket != 0); + poller_->registerSocket(socket); + SubMessage *m = new SubMessage{ + .socket = socket, + .freq = serv->frequency, + .ignore_alive = inList(ignore_alive, name), + .allocated_msg_reader = malloc(sizeof(capnp::FlatArrayMessageReader)), + .buf = kj::heapArray(1024)}; + messages_[socket] = m; + services_[name] = m; + } +} + +int SubMaster::update(int timeout) { + if (++frame == UINT64_MAX) frame = 1; + for (auto &kv : messages_) kv.second->updated = false; + + int updated = 0; + auto sockets = poller_->poll(timeout); + uint64_t current_time = nanos_since_boot(); + for (auto s : sockets) { + Message *msg = s->receive(true); + if (msg == nullptr) continue; + + SubMessage *m = messages_.at(s); + const size_t size = (msg->getSize() / sizeof(capnp::word)) + 1; + if (m->buf.size() < size) { + m->buf = kj::heapArray(size); + } + memcpy(m->buf.begin(), msg->getData(), msg->getSize()); + delete msg; + + if (m->msg_reader) { + m->msg_reader->~FlatArrayMessageReader(); + } + m->msg_reader = new (m->allocated_msg_reader) capnp::FlatArrayMessageReader(kj::ArrayPtr(m->buf.begin(), size)); + m->event = m->msg_reader->getRoot(); + m->updated = true; + m->rcv_time = current_time; + m->rcv_frame = frame; + m->valid = m->event.getValid(); + + ++updated; + } + + for (auto &kv : messages_) { + SubMessage *m = kv.second; + m->alive = (m->freq <= (1e-5) || ((current_time - m->rcv_time) * (1e-9)) < (10.0 / m->freq)); + } + return updated; +} + +bool SubMaster::all_(const std::initializer_list &service_list, bool valid, bool alive) { + int found = 0; + for (auto &kv : messages_) { + SubMessage *m = kv.second; + if (service_list.size() == 0 || inList(service_list, m->name.c_str())) { + found += (!valid || m->valid) && (!alive || (m->alive && !m->ignore_alive)); + } + } + return service_list.size() == 0 ? found == messages_.size() : found == service_list.size(); +} + +void SubMaster::drain() { + while (true) { + auto polls = poller_->poll(0); + if (polls.size() == 0) + break; + + for (auto sock : polls) { + Message *msg = sock->receive(true); + delete msg; + } + } +} + +bool SubMaster::updated(const char *name) const { + return services_.at(name)->updated; +} + +uint64_t SubMaster::rcv_frame(const char *name) const { + return services_.at(name)->rcv_frame; +} + +cereal::Event::Reader &SubMaster::operator[](const char *name) { + return services_.at(name)->event; +}; + +SubMaster::~SubMaster() { + delete poller_; + for (auto &kv : messages_) { + SubMessage *m = kv.second; + if (m->msg_reader) { + m->msg_reader->~FlatArrayMessageReader(); + } + free(m->allocated_msg_reader); + delete m->socket; + delete m; + } +} + +PubMaster::PubMaster(const std::initializer_list &service_list) { + for (auto name : service_list) { + assert(get_service(name) != nullptr); + PubSocket *socket = PubSocket::create(ctx.ctx_, name); + assert(socket); + sockets_[name] = socket; + } +} + +int PubMaster::send(const char *name, MessageBuilder &msg) { + auto bytes = msg.toBytes(); + return send(name, bytes.begin(), bytes.size()); +} + +PubMaster::~PubMaster() { + for (auto s : sockets_) delete s.second; +} diff --git a/selfdrive/service_list.yaml b/cereal/service_list.yaml similarity index 79% rename from selfdrive/service_list.yaml rename to cereal/service_list.yaml index 2d4535ca20035f..6d2e728c4da9e5 100644 --- a/selfdrive/service_list.yaml +++ b/cereal/service_list.yaml @@ -16,22 +16,22 @@ thermal: [8005, true, 2., 1] can: [8006, true, 100.] controlsState: [8007, true, 100., 100] #liveEvent: [8008, true, 0.] -model: [8009, true, 20.] +model: [8009, true, 20., 5] features: [8010, true, 0.] health: [8011, true, 2., 1] -radarState: [8012, true, 20.] +radarState: [8012, true, 20., 5] #liveUI: [8014, true, 0.] encodeIdx: [8015, true, 20.] liveTracks: [8016, true, 20.] sendcan: [8017, true, 100.] logMessage: [8018, true, 0.] -liveCalibration: [8019, true, 5.] +liveCalibration: [8019, true, 4., 4] androidLog: [8020, true, 0.] carState: [8021, true, 100., 10] # 8022 is reserved for sshd carControl: [8023, true, 100., 10] -plan: [8024, true, 20.] -liveLocation: [8025, true, 0.] +plan: [8024, true, 20., 2] +liveLocation: [8025, true, 0., 1] gpsLocation: [8026, true, 1., 1] ethernetData: [8027, true, 0.] navUpdate: [8028, true, 0.] @@ -40,10 +40,9 @@ lidarPts: [8030, true, 0.] procLog: [8031, true, 0.5] gpsLocationExternal: [8032, true, 10., 1] ubloxGnss: [8033, true, 10.] -clocks: [8034, true, 1.] +clocks: [8034, true, 1., 1] liveMpc: [8035, false, 20.] liveLongitudinalMpc: [8036, false, 20.] -plusFrame: [8037, false, 0.] navStatus: [8038, true, 0.] gpsLocationTrimble: [8039, true, 0.] trimbleGnss: [8041, true, 0.] @@ -58,23 +57,29 @@ orbslamCorrection: [8050, true, 0.] liveLocationCorrected: [8051, true, 0.] orbObservation: [8052, true, 0.] applanixLocation: [8053, true, 0.] -liveLocationKalman: [8054, true, 0.] +liveLocationKalman: [8054, true, 20., 2] uiNavigationEvent: [8055, true, 0.] orbOdometry: [8057, true, 0.] orbFeatures: [8058, false, 0.] orbKeyFrame: [8059, true, 0.] uiLayoutState: [8060, true, 0.] -frontEncodeIdx: [8061, true, 5.] +frontEncodeIdx: [8061, true, 5.] # should be 20fps on tici orbFeaturesSummary: [8062, true, 0.] -driverMonitoring: [8063, true, 5., 1] -liveParameters: [8064, true, 10.] +driverState: [8063, true, 5., 1] +liveParameters: [8064, true, 20., 2] liveMapData: [8065, true, 0.] -cameraOdometry: [8066, true, 5.] -pathPlan: [8067, true, 20.] +cameraOdometry: [8066, true, 20., 5] +pathPlan: [8067, true, 20., 2] kalmanOdometry: [8068, true, 0.] thumbnail: [8069, true, 0.2, 1] carEvents: [8070, true, 1., 1] carParams: [8071, true, 0.02, 1] +frontFrame: [8072, true, 10.] +dMonitoringState: [8073, true, 5., 1] +offroadLayout: [8074, false, 0.] +wideEncodeIdx: [8075, true, 20.] +wideFrame: [8076, true, 20.] +modelV2: [8077, true, 20., 20] testModel: [8040, false, 0.] testLiveLocation: [8045, false, 0.] @@ -97,6 +102,9 @@ uiIcLeads: [8211, false, 0.] alcaStatus: [8209, false, 0.] alcaState: [8210, false, 0.] +#auto high beam Events +ahbInfo: [8212, false, 0.] + # 8080 is reserved for slave testing daemon # 8762 is reserved for logserver @@ -119,19 +127,31 @@ alcaState: [8210, false, 0.] # gpsd -- publishes EON's gps # publishes: gpsNMEA -# visiond -- talks to the cameras, runs the model, saves the videos -# publishes: frame, model, driverMonitoring, cameraOdometry, thumbnail +# camerad -- publishes camera frames +# publishes: frame, frontFrame, thumbnail +# subscribes: driverState + +# dmonitoringmodeld -- runs face detection on camera frames +# publishes: driverState # **** stateful data transformers **** +# modeld -- runs & publishes the model +# publishes: model, cameraOdometry +# subscribes: liveCalibration, pathPlan + # plannerd -- decides where to drive the car # subscribes: carState, model, radarState, controlsState, liveParameters # publishes: plan, pathPlan, liveMpc, liveLongitudinalMpc # controlsd -- drives the car by sending CAN messages to panda -# subscribes: can, thermal, health, plan, pathPlan, driverMonitoring, liveCalibration +# subscribes: can, thermal, health, plan, pathPlan, dMonitoringState, liveCalibration, model # publishes: carState, carControl, sendcan, controlsState, carEvents, carParams +# dmonitoringd -- processes driver monitoring data and publishes driver awareness +# subscribes: driverState, liveCalibration, carState, model, gpsLocation +# publishes: dMonitoringState + # radard -- processes the radar and vision data # subscribes: can, controlsState, model, liveParameters # publishes: radarState, liveTracks diff --git a/cereal/services.py b/cereal/services.py new file mode 100755 index 00000000000000..b22305945fe7cd --- /dev/null +++ b/cereal/services.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +import os +import yaml + + +class Service(): + def __init__(self, port, should_log, frequency, decimation=None): + self.port = port + self.should_log = should_log + self.frequency = frequency + self.decimation = decimation + + +service_list_path = os.path.join(os.path.dirname(__file__), "service_list.yaml") + +service_list = {} +with open(service_list_path, "r") as f: + for k, v in yaml.safe_load(f).items(): + decimation = None + if len(v) == 4: + decimation = v[3] + + service_list[k] = Service(v[0], v[1], v[2], decimation) + +if __name__ == "__main__": + print("/* THIS IS AN AUTOGENERATED FILE, PLEASE EDIT service_list.yaml */") + print("#ifndef __SERVICES_H") + print("#define __SERVICES_H") + print("struct service { char name[0x100]; int port; bool should_log; int frequency; int decimation; };") + print("static struct service services[] = {") + for k, v in service_list.items(): + print(' { .name = "%s", .port = %d, .should_log = %s, .frequency = %d, .decimation = %d },' % (k, v.port, "true" if v.should_log else "false", v.frequency, -1 if v.decimation is None else v.decimation)) + print("};") + print("#endif") diff --git a/cereal/tesla.capnp b/cereal/tesla.capnp index 5f31f98edeb0e0..56134ef183c8e8 100644 --- a/cereal/tesla.capnp +++ b/cereal/tesla.capnp @@ -7,7 +7,7 @@ $Java.outerClassname("Alca"); @0xca61a35dedbd6327; -const interfaceVersion :Float32 = 4.0; +#const interfaceVersion :Float32 = 4.0; struct ALCAStatus { # ALCA info @@ -35,6 +35,7 @@ struct TeslaRadarPoint { movingState @3 :UInt8; # 0-indeterminate 1-moving 2-stopped 3-standing length @4 :Float32; # length in meters obstacleProb @5 :Float32; # probability to be an obstacle + timeStamp @6 :UInt64; #timestamp when the pair was received } struct ICCarsLR { @@ -69,6 +70,12 @@ struct ICLeads { lead2length @5 :Float32; } +struct AHBinfo { + source @0 :UInt8; #use 0 for radar, 1 for camera, 2 for other + radarCarDetected @1 :Bool; + cameraCarDetected @2 :Bool; +} + struct TeslaLeadPoint { trackId @0 :UInt8; # no trackId reuse oClass @1 :UInt8; # 0-unknown 1-four wheel vehicle 2-two wheel vehicle 3-pedestrian 4-construction element diff --git a/cereal/tinkla.capnp b/cereal/tinkla.capnp index 9e71cb789a07b7..ab35b430b4e7f9 100644 --- a/cereal/tinkla.capnp +++ b/cereal/tinkla.capnp @@ -7,7 +7,7 @@ $Java.outerClassname("Tinkla"); @0xfc8dda643156b95d; -const interfaceVersion :Float32 = 2.2; +const interfaceVersion :Float32 = 3; # Use integer values here struct Interface { diff --git a/check_code_quality.sh b/check_code_quality.sh deleted file mode 100644 index 854d757a847254..00000000000000 --- a/check_code_quality.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/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 diff --git a/common/.gitignore b/common/.gitignore new file mode 100644 index 00000000000000..ce1da4c53c0301 --- /dev/null +++ b/common/.gitignore @@ -0,0 +1 @@ +*.cpp diff --git a/common/SConscript b/common/SConscript new file mode 100644 index 00000000000000..542e10d437b658 --- /dev/null +++ b/common/SConscript @@ -0,0 +1,4 @@ +Import('envCython') + +envCython.Program('clock.so', 'clock.pyx') +envCython.Program('params_pyx.so', 'params_pyx.pyx') diff --git a/common/api/__init__.py b/common/api/__init__.py index e457272a12d8c8..b030c333343a78 100644 --- a/common/api/__init__.py +++ b/common/api/__init__.py @@ -1,13 +1,14 @@ import jwt import requests from datetime import datetime, timedelta - +from common.basedir import PERSIST from selfdrive.version import version -class Api(object): - def __init__(self, dongle_id, private_key): +class Api(): + def __init__(self, dongle_id): self.dongle_id = dongle_id - self.private_key = private_key + with open(PERSIST+'/comma/id_rsa') as f: + self.private_key = f.read() def get(self, *args, **kwargs): return self.request('GET', *args, **kwargs) @@ -19,7 +20,14 @@ def request(self, method, endpoint, timeout=None, access_token=None, **params): return api_get(endpoint, method=method, timeout=timeout, access_token=access_token, **params) def get_token(self): - return jwt.encode({'identity': self.dongle_id, 'exp': datetime.utcnow() + timedelta(hours=1)}, self.private_key, algorithm='RS256') + now = datetime.utcnow() + payload = { + 'identity': self.dongle_id, + 'nbf': now, + 'iat': now, + 'exp': now + timedelta(hours=1) + } + return jwt.encode(payload, self.private_key, algorithm='RS256').decode('utf8') def api_get(endpoint, method='GET', timeout=None, access_token=None, **params): backend = "https://api.commadotai.com/" @@ -30,5 +38,4 @@ def api_get(endpoint, method='GET', timeout=None, access_token=None, **params): headers['User-Agent'] = "openpilot-" + version - return requests.request(method, backend+endpoint, timeout=timeout, headers = headers, params=params) - + return requests.request(method, backend+endpoint, timeout=timeout, headers=headers, params=params) diff --git a/common/basedir.py b/common/basedir.py index 99760fa3343653..4511c6657ee829 100644 --- a/common/basedir.py +++ b/common/basedir.py @@ -1,4 +1,12 @@ import os BASEDIR = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../")) - +from selfdrive.hardware import PC +is_tbp = os.path.isfile('/data/tinkla_buddy_pro') +if PC: + PERSIST = os.path.join(BASEDIR, "persist") +elif is_tbp: + PERSIST = "/data/params/persist" + PARAMS = "/data/params" +else: + PERSIST = "/persist" diff --git a/common/clock.pyx b/common/clock.pyx index 6205eca10c2d54..81333565c58089 100644 --- a/common/clock.pyx +++ b/common/clock.pyx @@ -1,16 +1,24 @@ -from posix.time cimport clock_gettime, timespec, CLOCK_BOOTTIME, CLOCK_MONOTONIC_RAW +# distutils: language = c++ +# cython: language_level = 3 +from posix.time cimport clock_gettime, timespec, CLOCK_MONOTONIC_RAW, clockid_t -cdef double readclock(int clock_id): - cdef timespec ts - cdef double current +IF UNAME_SYSNAME == "Darwin": + # Darwin doesn't have a CLOCK_BOOTTIME + CLOCK_BOOTTIME = CLOCK_MONOTONIC_RAW +ELSE: + from posix.time cimport CLOCK_BOOTTIME - clock_gettime(clock_id, &ts) - current = ts.tv_sec + (ts.tv_nsec / 1000000000.) - return current +cdef double readclock(clockid_t 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) + return readclock(CLOCK_MONOTONIC_RAW) def sec_since_boot(): - return readclock(CLOCK_BOOTTIME) + return readclock(CLOCK_BOOTTIME) + diff --git a/common/cython_hacks.py b/common/cython_hacks.py new file mode 100644 index 00000000000000..d0e154746d3455 --- /dev/null +++ b/common/cython_hacks.py @@ -0,0 +1,23 @@ +import os +import sysconfig +from Cython.Distutils import build_ext + +def get_ext_filename_without_platform_suffix(filename): + name, ext = os.path.splitext(filename) + ext_suffix = sysconfig.get_config_var('EXT_SUFFIX') + + if ext_suffix == ext: + return filename + + ext_suffix = ext_suffix.replace(ext, '') + idx = name.find(ext_suffix) + + if idx == -1: + return filename + else: + return name[:idx] + ext + +class BuildExtWithoutPlatformSuffix(build_ext): + def get_ext_filename(self, ext_name): + filename = super().get_ext_filename(ext_name) + return get_ext_filename_without_platform_suffix(filename) diff --git a/common/ffi_wrapper.py b/common/ffi_wrapper.py index f41115d1ce721f..e6ee2c23f7af86 100644 --- a/common/ffi_wrapper.py +++ b/common/ffi_wrapper.py @@ -2,14 +2,20 @@ import sys import fcntl import hashlib +import platform from cffi import FFI +def suffix(): + if platform.system() == "Darwin": + return ".dylib" + else: + return ".so" def ffi_wrap(name, c_code, c_header, tmpdir="/tmp/ccache", cflags="", libraries=None): if libraries is None: libraries = [] - cache = name + "_" + hashlib.sha1(c_code).hexdigest() + cache = name + "_" + hashlib.sha1(c_code.encode('utf-8')).hexdigest() try: os.mkdir(tmpdir) except OSError: @@ -38,7 +44,7 @@ def compile_code(name, c_code, c_header, directory, cflags="", libraries=None): ffibuilder = FFI() ffibuilder.set_source(name, c_code, source_extension='.cpp', libraries=libraries) ffibuilder.cdef(c_header) - os.environ['OPT'] = "-fwrapv -O2 -DNDEBUG -std=c++11" + os.environ['OPT'] = "-fwrapv -O2 -DNDEBUG -std=c++1z" os.environ['CFLAGS'] = cflags ffibuilder.compile(verbose=True, debug=False, tmpdir=directory) diff --git a/common/file_helpers.py b/common/file_helpers.py index 3300ae595afe17..c7a70ab8791393 100644 --- a/common/file_helpers.py +++ b/common/file_helpers.py @@ -3,13 +3,17 @@ import tempfile from atomicwrites import AtomicWriter + def mkdirs_exists_ok(path): + if path.startswith('http://') or path.startswith('https://'): + raise ValueError('URL path') try: os.makedirs(path) except OSError: if not os.path.isdir(path): raise + def rm_not_exists_ok(path): try: os.remove(path) @@ -17,31 +21,25 @@ def rm_not_exists_ok(path): 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") or parts[1].startswith("datasets"): - 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" + if len(parts) > 1 and parts[1] == "scratch": + return "/scratch/tmp" + elif len(parts) > 2 and parts[2] == "runner": + return "/{}/runner/tmp".format(parts[1]) return "/tmp" -class AutoMoveTempdir(object): + +class AutoMoveTempdir(): def __init__(self, target_path, temp_dir=None): self._target_path = target_path self._path = tempfile.mkdtemp(dir=temp_dir) @@ -53,15 +51,17 @@ def name(self): def close(self): os.rename(self._path, self._target_path) - def __enter__(self): return self + def __enter__(self): + return self - def __exit__(self, type, value, traceback): - if type is None: + def __exit__(self, exc_type, exc_value, traceback): + if exc_type is None: self.close() else: shutil.rmtree(self._path) -class NamedTemporaryDir(object): + +class NamedTemporaryDir(): def __init__(self, temp_dir=None): self._path = tempfile.mkdtemp(dir=temp_dir) @@ -72,11 +72,13 @@ def name(self): def close(self): shutil.rmtree(self._path) - def __enter__(self): return self + def __enter__(self): + return self - def __exit__(self, type, value, traceback): + def __exit__(self, exc_type, exc_value, traceback): self.close() + def _get_fileobject_func(writer, temp_dir): def _get_fileobject(): file_obj = writer.get_fileobject(dir=temp_dir) @@ -84,6 +86,7 @@ def _get_fileobject(): 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. @@ -101,6 +104,7 @@ def atomic_write_in_dir(path, **kwargs): writer = AtomicWriter(path, **kwargs) return writer._open(_get_fileobject_func(writer, os.path.dirname(path))) + def atomic_write_in_dir_neos(path, contents, mode=None): """ Atomically writes contents to path using a temporary file in the same directory diff --git a/common/filter_simple.py b/common/filter_simple.py index a3206db1cc5684..fa291bcb6fdba6 100644 --- a/common/filter_simple.py +++ b/common/filter_simple.py @@ -6,5 +6,4 @@ def __init__(self, x0, ts, dt): def update(self, x): self.x = (1. - self.k) * self.x + self.k * x - - + return self.x diff --git a/common/fingerprints.py b/common/fingerprints.py deleted file mode 100644 index 0e29e6c1e71139..00000000000000 --- a/common/fingerprints.py +++ /dev/null @@ -1,62 +0,0 @@ -import os -from common.basedir import BASEDIR - -def get_fingerprint_list(): - # read all the folders in selfdrive/car and return a dict where: - # - keys are all the car models for which we have a fingerprint - # - values are lists dicts of messages that constitute the unique - # CAN fingerprint of each car model and all its variants - fingerprints = {} - for car_folder in [x[0] for x in os.walk(BASEDIR + '/selfdrive/car')]: - try: - car_name = car_folder.split('/')[-1] - values = __import__('selfdrive.car.%s.values' % car_name, fromlist=['FINGERPRINTS']) - if hasattr(values, 'FINGERPRINTS'): - car_fingerprints = values.FINGERPRINTS - else: - continue - for f, v in car_fingerprints.items(): - fingerprints[f] = v - except (ImportError, IOError): - pass - return fingerprints - - -_FINGERPRINTS = get_fingerprint_list() - -_DEBUG_ADDRESS = {1880: 8} # reserved for debug purposes - -def is_valid_for_fingerprint(msg, car_fingerprint): - adr = msg.address - # ignore addresses that are more than 11 bits - return (adr in car_fingerprint and car_fingerprint[adr] == len(msg.dat)) or adr >= 0x800 - - -def eliminate_incompatible_cars(msg, candidate_cars): - """Removes cars that could not have sent msg. - - Inputs: - msg: A cereal/log CanData message from the car. - candidate_cars: A list of cars to consider. - - Returns: - A list containing the subset of candidate_cars that could have sent msg. - """ - compatible_cars = [] - - for car_name in candidate_cars: - car_fingerprints = _FINGERPRINTS[car_name] - - for fingerprint in car_fingerprints: - fingerprint.update(_DEBUG_ADDRESS) # add alien debug address - - if is_valid_for_fingerprint(msg, fingerprint): - compatible_cars.append(car_name) - break - - return compatible_cars - - -def all_known_cars(): - """Returns a list of all known car strings.""" - return list(_FINGERPRINTS.keys()) diff --git a/common/gpio.py b/common/gpio.py new file mode 100644 index 00000000000000..cb0322146c14da --- /dev/null +++ b/common/gpio.py @@ -0,0 +1,14 @@ +def gpio_init(pin, output): + try: + with open(f"/sys/class/gpio/gpio{pin}/direction", 'wb') as f: + f.write(b"out" if output else b"in") + except Exception as e: + print(f"Failed to set gpio {pin} direction: {e}") + + +def gpio_set(pin, high): + try: + with open(f"/sys/class/gpio/gpio{pin}/value", 'wb') as f: + f.write(b"1" if high else b"0") + except Exception as e: + print(f"Failed to set gpio {pin} value: {e}") diff --git a/common/kalman/.gitignore b/common/kalman/.gitignore new file mode 100644 index 00000000000000..d86912e7d04c50 --- /dev/null +++ b/common/kalman/.gitignore @@ -0,0 +1 @@ +simple_kalman_impl.c diff --git a/common/kalman/Makefile b/common/kalman/Makefile deleted file mode 100644 index 88b032af1bc4f5..00000000000000 --- a/common/kalman/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: simple_kalman_impl.so - -simple_kalman_impl.so: simple_kalman_impl.pyx simple_kalman_impl.pxd simple_kalman_setup.py - python2 simple_kalman_setup.py build_ext --inplace - rm -rf build - rm simple_kalman_impl.c - -.PHONY: clean -clean: - rm -f simple_kalman_impl.so diff --git a/common/kalman/SConscript b/common/kalman/SConscript new file mode 100644 index 00000000000000..d60354c987ab60 --- /dev/null +++ b/common/kalman/SConscript @@ -0,0 +1,3 @@ +Import('envCython') + +envCython.Program('simple_kalman_impl.so', 'simple_kalman_impl.pyx') diff --git a/common/kalman/simple_kalman.py b/common/kalman/simple_kalman.py index 97b6d792dc967b..33289e4f509fbc 100644 --- a/common/kalman/simple_kalman.py +++ b/common/kalman/simple_kalman.py @@ -1,10 +1,3 @@ # 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) - -from simple_kalman_impl import KF1D as KF1D -# Silence pyflakes +from common.kalman.simple_kalman_impl import KF1D as KF1D assert KF1D diff --git a/common/kalman/simple_kalman_impl.pxd b/common/kalman/simple_kalman_impl.pxd index c81f959272610f..cb39a45bca2c36 100644 --- a/common/kalman/simple_kalman_impl.pxd +++ b/common/kalman/simple_kalman_impl.pxd @@ -1,3 +1,5 @@ +# cython: language_level = 3 + cdef class KF1D: cdef public: double x0_0 @@ -13,4 +15,4 @@ cdef class KF1D: double A_K_0 double A_K_1 double A_K_2 - double A_K_3 \ No newline at end of file + double A_K_3 diff --git a/common/kalman/simple_kalman_impl.pyx b/common/kalman/simple_kalman_impl.pyx index 43acf7e2a086fa..16aefba2e5b796 100644 --- a/common/kalman/simple_kalman_impl.pyx +++ b/common/kalman/simple_kalman_impl.pyx @@ -1,3 +1,5 @@ +# distutils: language = c++ +# cython: language_level=3 cdef class KF1D: def __init__(self, x0, A, C, K): @@ -32,4 +34,4 @@ cdef class KF1D: @x.setter def x(self, x): self.x0_0 = x[0][0] - self.x1_0 = x[1][0] \ No newline at end of file + self.x1_0 = x[1][0] diff --git a/common/kalman/simple_kalman_old.py b/common/kalman/simple_kalman_old.py index 3f7d049cc55342..d11770faf6cc74 100644 --- a/common/kalman/simple_kalman_old.py +++ b/common/kalman/simple_kalman_old.py @@ -8,7 +8,7 @@ class KF1D: def __init__(self, x0, A, C, K): self.x = x0 self.A = A - self.C = C + self.C = np.atleast_2d(C) self.K = K self.A_K = self.A - np.dot(self.K, self.C) diff --git a/common/kalman/simple_kalman_setup.py b/common/kalman/simple_kalman_setup.py deleted file mode 100644 index bccd9f888f33b7..00000000000000 --- a/common/kalman/simple_kalman_setup.py +++ /dev/null @@ -1,5 +0,0 @@ -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"]))) \ No newline at end of file diff --git a/common/kalman/tests/test_simple_kalman.py b/common/kalman/tests/test_simple_kalman.py index c1f9f7b03cd573..7b327918a3d33d 100644 --- a/common/kalman/tests/test_simple_kalman.py +++ b/common/kalman/tests/test_simple_kalman.py @@ -21,10 +21,10 @@ def setUp(self): 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_old = KF1D_old(x0=np.array([[x0_0], [x1_0]]), + A=np.array([[A0_0, A0_1], [A1_0, A1_1]]), + C=np.array([C0_0, C0_1]), + K=np.array([[K0_0], [K1_0]])) self.kf = KF1D(x0=[[x0_0], [x1_0]], A=[[A0_0, A0_1], [A1_0, A1_1]], @@ -47,9 +47,8 @@ def test_old_equal_new(self): 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]) - + np.testing.assert_almost_equal(x_old[0], x[0]) + np.testing.assert_almost_equal(x_old[1], x[1]) def test_new_is_faster(self): setup = """ @@ -70,10 +69,10 @@ def test_new_is_faster(self): 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_old = KF1D_old(x0=np.array([[x0_0], [x1_0]]), + A=np.array([[A0_0, A0_1], [A1_0, A1_1]]), + C=np.array([C0_0, C0_1]), + K=np.array([[K0_0], [K1_0]])) kf = KF1D(x0=[[x0_0], [x1_0]], A=[[A0_0, A0_1], [A1_0, A1_1]], @@ -83,3 +82,6 @@ def test_new_is_faster(self): 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) + +if __name__ == "__main__": + unittest.main() diff --git a/common/logging_extra.py b/common/logging_extra.py index 43ae48882b956e..ce8889b410583c 100644 --- a/common/logging_extra.py +++ b/common/logging_extra.py @@ -1,9 +1,11 @@ +import io import os import sys import copy import json import socket import logging +import traceback from threading import local from collections import OrderedDict from contextlib import contextmanager @@ -66,8 +68,11 @@ class SwagErrorFilter(logging.Filter): def filter(self, record): return record.levelno < logging.ERROR -_tmpfunc = lambda: 0 -_srcfile = os.path.normcase(_tmpfunc.__code__.co_filename) +def _tmpfunc(): + return 0 + +def _srcfile(): + return os.path.normcase(_tmpfunc.__code__.co_filename) class SwagLogger(logging.Logger): def __init__(self): @@ -78,28 +83,6 @@ def __init__(self): self.log_local = local() self.log_local.ctx = {} - def findCaller(self, stack_info=None): - """ - Find the stack frame of the caller so that we can note the source - file name, line number and function name. - """ - # f = currentframe() - f = sys._getframe(3) - #On some versions of IronPython, currentframe() returns None if - #IronPython isn't run with -X:Frames. - if f is not None: - f = f.f_back - rv = "(unknown file)", 0, "(unknown function)" - while hasattr(f, "f_code"): - co = f.f_code - filename = os.path.normcase(co.co_filename) - if filename in (logging._srcfile, _srcfile): - f = f.f_back - continue - rv = (co.co_filename, f.f_lineno, co.co_name) - break - return rv - def local_ctx(self): try: return self.log_local.ctx @@ -132,14 +115,49 @@ def event(self, event_name, *args, **kwargs): if args: evt['args'] = args evt.update(kwargs) - ctx = self.get_ctx() - if ctx: - evt['ctx'] = self.get_ctx() if 'error' in kwargs: self.error(evt) else: self.info(evt) + def findCaller(self, stack_info=False, stacklevel=1): + """ + Find the stack frame of the caller so that we can note the source + file name, line number and function name. + """ + f = sys._getframe(3) + #On some versions of IronPython, currentframe() returns None if + #IronPython isn't run with -X:Frames. + if f is not None: + f = f.f_back + orig_f = f + while f and stacklevel > 1: + f = f.f_back + stacklevel -= 1 + if not f: + f = orig_f + rv = "(unknown file)", 0, "(unknown function)", None + while hasattr(f, "f_code"): + co = f.f_code + filename = os.path.normcase(co.co_filename) + + # TODO: is this pylint exception correct? + if filename == _srcfile: # pylint: disable=comparison-with-callable + f = f.f_back + continue + sinfo = None + if stack_info: + sio = io.StringIO() + sio.write('Stack (most recent call last):\n') + traceback.print_stack(f, file=sio) + sinfo = sio.getvalue() + if sinfo[-1] == '\n': + sinfo = sinfo[:-1] + sio.close() + rv = (co.co_filename, f.f_lineno, co.co_name, sinfo) + break + return rv + if __name__ == "__main__": log = SwagLogger() diff --git a/common/numpy_fast.py b/common/numpy_fast.py index eb706a908ff643..a8361214d1ae44 100644 --- a/common/numpy_fast.py +++ b/common/numpy_fast.py @@ -6,13 +6,17 @@ def clip(x, lo, hi): def interp(x, xp, fp): N = len(xp) + def get_interp(xv): hi = 0 while hi < N and xv > xp[hi]: hi += 1 low = hi - 1 return fp[-1] if hi == N and xv > xp[low] else ( - fp[0] if hi == 0 else + fp[0] if hi == 0 else (xv - xp[low]) * (fp[hi] - fp[low]) / (xp[hi] - xp[low]) + fp[low]) - return [get_interp(v) for v in x] if hasattr( - x, '__iter__') else get_interp(x) + + return [get_interp(v) for v in x] if hasattr(x, '__iter__') else get_interp(x) + +def mean(x): + return sum(x) / len(x) diff --git a/common/params.py b/common/params.py old mode 100755 new mode 100644 index 461e53817ad7cc..5a7a0d41023f64 --- a/common/params.py +++ b/common/params.py @@ -1,369 +1,4 @@ -#!/usr/bin/env python -"""ROS has a parameter server, we have files. - -The parameter store is a persistent key value store, implemented as a directory with a writer lock. -On Android, we store params under params_dir = /data/params. The writer lock is a file -"/.lock" taken using flock(), and data is stored in a directory symlinked to by -"/d". - -Each key, value pair is stored as a file with named with contents , located in - /d/ - -Readers of a single key can just open("/d/") and read the file contents. -Readers who want a consistent snapshot of multiple keys should take the lock. - -Writers should take the lock before modifying anything. Writers should also leave the DB in a -consistent state after a crash. The implementation below does this by copying all params to a temp -directory /, then atomically symlinking / to / -before deleting the old / directory. - -Writers that only modify a single key can simply take the lock, then swap the corresponding value -file in place without messing with /d. -""" -import time -import os -import errno -import sys -import shutil -import fcntl -import tempfile -from enum import Enum - - -def mkdirs_exists_ok(path): - try: - os.makedirs(path) - except OSError: - if not os.path.isdir(path): - raise - - -class TxType(Enum): - PERSISTENT = 1 - CLEAR_ON_MANAGER_START = 2 - CLEAR_ON_PANDA_DISCONNECT = 3 - CLEAR_ON_CAR_START = 4 - - -class UnknownKeyName(Exception): - pass - - -keys = { - "AccessToken": [TxType.PERSISTENT], - "AthenadPid": [TxType.PERSISTENT], - "CalibrationParams": [TxType.PERSISTENT], - "CarParams": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT], #[TxType.CLEAR_ON_CAR_START], - "CarVin": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT], #[TxType.PERSISTENT], #[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], - "GithubSshKeys": [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], - "IsUploadRawEnabled": [TxType.PERSISTENT], - "IsUploadVideoOverCellularEnabled": [TxType.PERSISTENT], - "LimitSetSpeed": [TxType.PERSISTENT], - "LimitSetSpeedNeural": [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], - "TermsVersion": [TxType.PERSISTENT], - "TrainingVersion": [TxType.PERSISTENT], - "Version": [TxType.PERSISTENT], -} - - -def fsync_dir(path): - fd = os.open(path, os.O_RDONLY) - try: - os.fsync(fd) - finally: - os.close(fd) - - -class FileLock(object): - def __init__(self, path, create): - self._path = path - self._create = create - self._fd = None - - def acquire(self): - self._fd = os.open(self._path, os.O_CREAT if self._create else 0) - fcntl.flock(self._fd, fcntl.LOCK_EX) - - def release(self): - if self._fd is not None: - os.close(self._fd) - self._fd = None - - -class DBAccessor(object): - def __init__(self, path): - self._path = path - self._vals = None - - def keys(self): - self._check_entered() - return self._vals.keys() - - def get(self, key): - self._check_entered() - try: - return self._vals[key] - except KeyError: - return None - - def _get_lock(self, create): - lock = FileLock(os.path.join(self._path, ".lock"), create) - lock.acquire() - return lock - - def _read_values_locked(self): - """Callers should hold a lock while calling this method.""" - vals = {} - try: - data_path = self._data_path() - keys = os.listdir(data_path) - for key in keys: - with open(os.path.join(data_path, key), "rb") as f: - vals[key] = f.read() - except (OSError, IOError) as e: - # Either the DB hasn't been created yet, or somebody wrote a bug and left the DB in an - # inconsistent state. Either way, return empty. - if e.errno == errno.ENOENT: - return {} - - return vals - - def _data_path(self): - return os.path.join(self._path, "d") - - def _check_entered(self): - if self._vals is None: - raise Exception("Must call __enter__ before using DB") - - -class DBReader(DBAccessor): - def __enter__(self): - try: - lock = self._get_lock(False) - except OSError as e: - # Do not create lock if it does not exist. - if e.errno == errno.ENOENT: - self._vals = {} - return self - - try: - # Read everything. - self._vals = self._read_values_locked() - return self - finally: - lock.release() - - def __exit__(self, type, value, traceback): pass - - -class DBWriter(DBAccessor): - def __init__(self, path): - super(DBWriter, self).__init__(path) - self._lock = None - self._prev_umask = None - - def put(self, key, value): - self._vals[key] = value - - def delete(self, key): - self._vals.pop(key, None) - - def __enter__(self): - mkdirs_exists_ok(self._path) - - # Make sure we can write and that permissions are correct. - self._prev_umask = os.umask(0) - - try: - os.chmod(self._path, 0o777) - self._lock = self._get_lock(True) - self._vals = self._read_values_locked() - except: - os.umask(self._prev_umask) - self._prev_umask = None - raise - - return self - - def __exit__(self, type, value, traceback): - self._check_entered() - - try: - # data_path refers to the externally used path to the params. It is a symlink. - # old_data_path is the path currently pointed to by data_path. - # tempdir_path is a path where the new params will go, which the new data path will point to. - # new_data_path is a temporary symlink that will atomically overwrite data_path. - # - # The current situation is: - # data_path -> old_data_path - # We're going to write params data to tempdir_path - # tempdir_path -> params data - # Then point new_data_path to tempdir_path - # new_data_path -> tempdir_path - # Then atomically overwrite data_path with new_data_path - # data_path -> tempdir_path - old_data_path = None - new_data_path = None - tempdir_path = tempfile.mkdtemp(prefix=".tmp", dir=self._path) - - try: - # Write back all keys. - os.chmod(tempdir_path, 0o777) - for k, v in self._vals.items(): - with open(os.path.join(tempdir_path, k), "wb") as f: - f.write(v) - f.flush() - os.fsync(f.fileno()) - fsync_dir(tempdir_path) - - data_path = self._data_path() - try: - old_data_path = os.path.join(self._path, os.readlink(data_path)) - except (OSError, IOError): - # NOTE(mgraczyk): If other DB implementations have bugs, this could cause - # copies to be left behind, but we still want to overwrite. - pass - - new_data_path = "{}.link".format(tempdir_path) - os.symlink(os.path.basename(tempdir_path), new_data_path) - os.rename(new_data_path, data_path) - fsync_dir(self._path) - finally: - # If the rename worked, we can delete the old data. Otherwise delete the new one. - success = new_data_path is not None and os.path.exists(data_path) and ( - os.readlink(data_path) == os.path.basename(tempdir_path)) - - if success: - if old_data_path is not None: - shutil.rmtree(old_data_path) - else: - shutil.rmtree(tempdir_path) - - # Regardless of what happened above, there should be no link at new_data_path. - if new_data_path is not None and os.path.islink(new_data_path): - os.remove(new_data_path) - finally: - os.umask(self._prev_umask) - self._prev_umask = None - - # Always release the lock. - self._lock.release() - self._lock = None - - -def read_db(params_path, key): - path = "%s/d/%s" % (params_path, key) - try: - with open(path, "rb") as f: - return f.read() - except IOError: - return None - -def write_db(params_path, key, value): - prev_umask = os.umask(0) - lock = FileLock(params_path+"/.lock", True) - lock.acquire() - - try: - tmp_path = tempfile.mktemp(prefix=".tmp", dir=params_path) - with open(tmp_path, "wb") as f: - f.write(value) - f.flush() - os.fsync(f.fileno()) - - path = "%s/d/%s" % (params_path, key) - os.rename(tmp_path, path) - fsync_dir(os.path.dirname(path)) - finally: - os.umask(prev_umask) - lock.release() - -class Params(object): - def __init__(self, db='/data/params'): - self.db = db - - # create the database if it doesn't exist... - if not os.path.exists(self.db+"/d"): - with self.transaction(write=True): - pass - - def transaction(self, write=False): - if write: - return DBWriter(self.db) - else: - return DBReader(self.db) - - def _clear_keys_with_type(self, tx_type): - with self.transaction(write=True) as txn: - for key in keys: - if tx_type in keys[key]: - txn.delete(key) - - def manager_start(self): - self._clear_keys_with_type(TxType.CLEAR_ON_MANAGER_START) - - def panda_disconnect(self): - self._clear_keys_with_type(TxType.CLEAR_ON_PANDA_DISCONNECT) - - def car_start(self): - self._clear_keys_with_type(TxType.CLEAR_ON_CAR_START) - - def delete(self, key): - with self.transaction(write=True) as txn: - txn.delete(key) - - def get(self, key, block=False): - if key not in keys: - raise UnknownKeyName(key) - - while 1: - ret = read_db(self.db, key) - if not block or ret is not None: - break - # is polling really the best we can do? - time.sleep(0.05) - return ret - - def put(self, key, dat): - if key not in keys: - raise UnknownKeyName(key) - - write_db(self.db, key, dat) - -if __name__ == "__main__": - params = Params() - if len(sys.argv) > 2: - params.put(sys.argv[1], sys.argv[2]) - else: - for k in keys: - pp = params.get(k) - if pp is None: - print("%s is None" % k) - elif all(ord(c) < 128 and ord(c) >= 32 for c in pp): - print("%s = %s" % (k, pp)) - else: - print("%s = %s" % (k, pp.encode("hex"))) - - # Test multiprocess: - # seq 0 100000 | xargs -P20 -I{} python common/params.py DongleId {} && sleep 0.05 - # while python common/params.py DongleId; do sleep 0.05; done +from common.params_pyx import Params, UnknownKeyName, put_nonblocking # pylint: disable=no-name-in-module, import-error +assert Params +assert UnknownKeyName +assert put_nonblocking diff --git a/common/params_pxd.pxd b/common/params_pxd.pxd new file mode 100644 index 00000000000000..e437a09b043e66 --- /dev/null +++ b/common/params_pxd.pxd @@ -0,0 +1,16 @@ +from libcpp.string cimport string +from libcpp cimport bool + +cdef extern from "selfdrive/common/params.cc": + pass + +cdef extern from "selfdrive/common/util.c": + pass + +cdef extern from "selfdrive/common/params.h": + cdef cppclass Params: + Params(bool) + Params(string) + string get(string, bool) nogil + int delete_db_value(string) + int write_db_value(string, string) diff --git a/common/params_pyx.pyx b/common/params_pyx.pyx new file mode 100755 index 00000000000000..643501cd918e97 --- /dev/null +++ b/common/params_pyx.pyx @@ -0,0 +1,172 @@ +# distutils: language = c++ +# cython: language_level = 3 +from libcpp cimport bool +from libcpp.string cimport string +from common.params_pxd cimport Params as c_Params + +import os +import threading +from common.basedir import BASEDIR + +cdef enum TxType: + PERSISTENT = 1 + CLEAR_ON_MANAGER_START = 2 + CLEAR_ON_PANDA_DISCONNECT = 3 + +keys = { + b"AccessToken": [TxType.CLEAR_ON_MANAGER_START], + b"AthenadPid": [TxType.PERSISTENT], + b"CalibrationParams": [TxType.PERSISTENT], + b"CarBatteryCapacity": [TxType.PERSISTENT], + b"CarParams": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT], + b"CarParamsCache": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT], + b"CarVin": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT], + b"CommunityFeaturesToggle": [TxType.PERSISTENT], + b"CompletedTrainingVersion": [TxType.PERSISTENT], + b"DisablePowerDown": [TxType.PERSISTENT], + b"DisableUpdates": [TxType.PERSISTENT], + b"DoUninstall": [TxType.CLEAR_ON_MANAGER_START], + b"DongleId": [TxType.PERSISTENT], + b"GitBranch": [TxType.PERSISTENT], + b"GitCommit": [TxType.PERSISTENT], + b"GitRemote": [TxType.PERSISTENT], + b"GithubSshKeys": [TxType.PERSISTENT], + b"HasAcceptedTerms": [TxType.PERSISTENT], + b"HasCompletedSetup": [TxType.PERSISTENT], + b"IsDriverViewEnabled": [TxType.CLEAR_ON_MANAGER_START], + b"IsLdwEnabled": [TxType.PERSISTENT], + b"IsMetric": [TxType.PERSISTENT], + b"IsOffroad": [TxType.CLEAR_ON_MANAGER_START], + b"IsRHD": [TxType.PERSISTENT], + b"IsTakingSnapshot": [TxType.CLEAR_ON_MANAGER_START], + b"IsUpdateAvailable": [TxType.CLEAR_ON_MANAGER_START], + b"IsUploadRawEnabled": [TxType.PERSISTENT], + b"LastAthenaPingTime": [TxType.PERSISTENT], + b"LastUpdateTime": [TxType.PERSISTENT], + b"LastUpdateException": [TxType.PERSISTENT], + b"LiveParameters": [TxType.PERSISTENT], + b"OpenpilotEnabledToggle": [TxType.PERSISTENT], + b"LaneChangeEnabled": [TxType.PERSISTENT], + b"PandaFirmware": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT], + b"PandaFirmwareHex": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT], + b"PandaDongleId": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT], + b"Passive": [TxType.PERSISTENT], + b"RecordFront": [TxType.PERSISTENT], + b"ReleaseNotes": [TxType.PERSISTENT], + b"ShouldDoUpdate": [TxType.CLEAR_ON_MANAGER_START], + b"SubscriberInfo": [TxType.PERSISTENT], + b"TermsVersion": [TxType.PERSISTENT], + b"TrainingVersion": [TxType.PERSISTENT], + b"UpdateAvailable": [TxType.CLEAR_ON_MANAGER_START], + b"UpdateFailedCount": [TxType.CLEAR_ON_MANAGER_START], + b"Version": [TxType.PERSISTENT], + b"Offroad_ChargeDisabled": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT], + b"Offroad_ConnectivityNeeded": [TxType.CLEAR_ON_MANAGER_START], + b"Offroad_ConnectivityNeededPrompt": [TxType.CLEAR_ON_MANAGER_START], + b"Offroad_TemperatureTooHigh": [TxType.CLEAR_ON_MANAGER_START], + b"Offroad_PandaFirmwareMismatch": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT], + b"Offroad_InvalidTime": [TxType.CLEAR_ON_MANAGER_START], + b"Offroad_IsTakingSnapshot": [TxType.CLEAR_ON_MANAGER_START], + b"Offroad_NeosUpdate": [TxType.CLEAR_ON_MANAGER_START], + b"Offroad_UpdateFailed": [TxType.CLEAR_ON_MANAGER_START], + b"Offroad_HardwareUnsupported": [TxType.CLEAR_ON_MANAGER_START], + + #Tesla + b"DriverUsbCameraID": [TxType.PERSISTENT], + b"RoadUsbCameraID": [TxType.PERSISTENT], + b"DriverUsbCameraFx": [TxType.PERSISTENT], + b"DriverUsbCameraFlip": [TxType.PERSISTENT], + b"RoadUsbCameraFx": [TxType.PERSISTENT], + b"RoadUsbCameraFlip": [TxType.PERSISTENT], + b"TeslaModel": [TxType.PERSISTENT], + b"SpeedLimitOffset": [TxType.PERSISTENT], + b"LimitSetSpeed": [TxType.PERSISTENT], +} + +def ensure_bytes(v): + if isinstance(v, str): + return v.encode() + else: + return v + + +class UnknownKeyName(Exception): + pass + +cdef class Params: + cdef c_Params* p + + def __cinit__(self, d=None, bool persistent_params=False): + if d is None: + self.p = new c_Params(persistent_params) + else: + self.p = new c_Params(d.encode()) + + def __dealloc__(self): + del self.p + + def clear_all(self, tx_type=None): + for key in keys: + if tx_type is None or tx_type in keys[key]: + self.delete(key) + + def manager_start(self): + self.clear_all(TxType.CLEAR_ON_MANAGER_START) + + def panda_disconnect(self): + self.clear_all(TxType.CLEAR_ON_PANDA_DISCONNECT) + + def get(self, key, block=False, encoding=None): + key = ensure_bytes(key) + + if key not in keys: + raise UnknownKeyName(key) + + cdef string k = key + cdef bool b = block + + cdef string val + with nogil: + val = self.p.get(k, b) + + if val == b"": + if block: + # If we got no value while running in blocked mode + # it means we got an interrupt while waiting + raise KeyboardInterrupt + else: + return None + + if encoding is not None: + return val.decode(encoding) + else: + return val + + def put(self, key, dat): + """ + Warning: This function blocks until the param is written to disk! + In very rare cases this can take over a second, and your code will hang. + Use the put_nonblocking helper function in time sensitive code, but + in general try to avoid writing params as much as possible. + """ + key = ensure_bytes(key) + dat = ensure_bytes(dat) + + if key not in keys: + raise UnknownKeyName(key) + + self.p.write_db_value(key, dat) + + def delete(self, key): + key = ensure_bytes(key) + self.p.delete_db_value(key) + + +def put_nonblocking(key, val, d=None): + def f(key, val): + params = Params(d) + params.put(key, val) + + t = threading.Thread(target=f, args=(key, val)) + t.start() + return t diff --git a/common/profiler.py b/common/profiler.py index 7f9b1a41ffb188..e4d208acaeb058 100644 --- a/common/profiler.py +++ b/common/profiler.py @@ -1,6 +1,6 @@ import time -class Profiler(object): +class Profiler(): def __init__(self, enabled=False): self.enabled = enabled self.cp = {} @@ -36,11 +36,10 @@ def display(self): if not self.enabled: return self.iter += 1 - print("******* Profiling *******") + print("******* Profiling %d *******" % self.iter) for n, ms in sorted(self.cp.items(), key=lambda x: -x[1]): if n in self.cp_ignored: - print("%30s: %7.2f percent: %3.0f IGNORED" % (n, ms*1000.0, ms/self.tot*100)) + print("%30s: %9.2f avg: %7.2f percent: %3.0f IGNORED" % (n, ms*1000.0, ms*1000.0/self.iter, ms/self.tot*100)) else: - print("%30s: %7.2f percent: %3.0f" % (n, ms*1000.0, ms/self.tot*100)) + print("%30s: %9.2f avg: %7.2f percent: %3.0f" % (n, ms*1000.0, ms*1000.0/self.iter, ms/self.tot*100)) print("Iter clock: %2.6f TOTAL: %2.2f" % (self.tot/self.iter, self.tot)) - diff --git a/common/realtime.py b/common/realtime.py index 0c3d43476d5616..86029aba60e86a 100644 --- a/common/realtime.py +++ b/common/realtime.py @@ -1,49 +1,56 @@ """Utilities for reading real time clocks and keeping soft real time constraints.""" +import gc import os import time -import platform -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 +from common.clock import sec_since_boot # pylint: disable=no-name-in-module, import-error +from selfdrive.hardware import PC, TICI # time step for each process DT_CTRL = 0.01 # controlsd -DT_PLAN = 0.05 # mpc DT_MDL = 0.05 # model -DT_DMON = 0.1 # driver monitoring DT_TRML = 0.5 # thermald and manager +# driver monitoring +if TICI: + DT_DMON = 0.05 +else: + DT_DMON = 0.1 -ffi = FFI() -ffi.cdef("long syscall(long number, ...);") -libc = ffi.dlopen(None) + +class Priority: + # CORE 2 + # - modeld = 55 + # - camerad = 54 + CTRL_LOW = 51 # plannerd & radard + + # CORE 3 + # - boardd = 55 + CTRL_HIGH = 53 def set_realtime_priority(level): - if os.getuid() != 0: - print("not setting priority, not root") - return - if platform.machine() == "x86_64": - NR_gettid = 186 - elif platform.machine() == "aarch64": - NR_gettid = 178 - else: - raise NotImplementedError + if not PC: + os.sched_setscheduler(0, os.SCHED_FIFO, os.sched_param(level)) + + +def set_core_affinity(core): + if not PC: + try: + os.sched_setaffinity(0, [core,]) + except OSError: + print("Unable to set core affinity") + - tid = libc.syscall(NR_gettid) - return subprocess.call(['chrt', '-f', '-p', str(level), str(tid)]) +def config_realtime_process(core, priority): + gc.disable() + set_realtime_priority(priority) + set_core_affinity(core) -class Ratekeeper(object): +class Ratekeeper(): def __init__(self, rate, print_delay_threshold=0.): """Rate in Hz for ratekeeping. print_delay_threshold must be nonnegative.""" self._interval = 1. / rate @@ -62,12 +69,10 @@ def remaining(self): return self._remaining # Maintain loop rate by calling this at the end of each loop - def keep_time(self, offset=0.): + def keep_time(self): lagged = self.monitor_time() if self._remaining > 0: time.sleep(self._remaining) - elif not offset == 0.: - self._next_frame_time += offset return lagged # this only monitor the cumulative lag, but does not enforce a rate diff --git a/common/spinner.py b/common/spinner.py new file mode 100644 index 00000000000000..1232371d8ffe5b --- /dev/null +++ b/common/spinner.py @@ -0,0 +1,49 @@ +import os +import subprocess +from common.basedir import BASEDIR + + +class Spinner(): + def __init__(self): + try: + self.spinner_proc = subprocess.Popen(["./spinner"], + stdin=subprocess.PIPE, + cwd=os.path.join(BASEDIR, "selfdrive", "ui"), + close_fds=True) + except OSError: + self.spinner_proc = None + + def __enter__(self): + return self + + def update(self, spinner_text): + if self.spinner_proc is not None: + self.spinner_proc.stdin.write(spinner_text.encode('utf8') + b"\n") + try: + self.spinner_proc.stdin.flush() + except BrokenPipeError: + pass + + def close(self): + if self.spinner_proc is not None: + try: + self.spinner_proc.stdin.close() + except BrokenPipeError: + pass + self.spinner_proc.terminate() + self.spinner_proc = None + + def __del__(self): + self.close() + + def __exit__(self, exc_type, exc_value, traceback): + self.close() + + +if __name__ == "__main__": + import time + with Spinner() as s: + s.update("Spinner text") + time.sleep(5.0) + print("gone") + time.sleep(5.0) diff --git a/common/stat_live.py b/common/stat_live.py new file mode 100644 index 00000000000000..a91c1819bb9149 --- /dev/null +++ b/common/stat_live.py @@ -0,0 +1,73 @@ +import numpy as np + +class RunningStat(): + # tracks realtime mean and standard deviation without storing any data + def __init__(self, priors=None, max_trackable=-1): + self.max_trackable = max_trackable + if priors is not None: + # initialize from history + self.M = priors[0] + self.S = priors[1] + self.n = priors[2] + self.M_last = self.M + self.S_last = self.S + + else: + self.reset() + + def reset(self): + self.M = 0. + self.S = 0. + self.M_last = 0. + self.S_last = 0. + self.n = 0 + + def push_data(self, new_data): + # short term memory hack + if self.max_trackable < 0 or self.n < self.max_trackable: + self.n += 1 + if self.n == 0: + self.M_last = new_data + self.M = self.M_last + self.S_last = 0. + else: + self.M = self.M_last + (new_data - self.M_last) / self.n + self.S = self.S_last + (new_data - self.M_last) * (new_data - self.M) + self.M_last = self.M + self.S_last = self.S + + def mean(self): + return self.M + + def variance(self): + if self.n >= 2: + return self.S / (self.n - 1.) + else: + return 0 + + def std(self): + return np.sqrt(self.variance()) + + def params_to_save(self): + return [self.M, self.S, self.n] + +class RunningStatFilter(): + def __init__(self, raw_priors=None, filtered_priors=None, max_trackable=-1): + self.raw_stat = RunningStat(raw_priors, -1) + self.filtered_stat = RunningStat(filtered_priors, max_trackable) + + def reset(self): + self.raw_stat.reset() + self.filtered_stat.reset() + + def push_and_update(self, new_data): + _std_last = self.raw_stat.std() + self.raw_stat.push_data(new_data) + _delta_std = self.raw_stat.std() - _std_last + if _delta_std <= 0: + self.filtered_stat.push_data(new_data) + else: + pass + # self.filtered_stat.push_data(self.filtered_stat.mean()) + +# class SequentialBayesian(): diff --git a/common/sympy_helpers.py b/common/sympy_helpers.py deleted file mode 100644 index f20bdb08a7132b..00000000000000 --- a/common/sympy_helpers.py +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env python -import sympy as sp -import numpy as np - -def cross(x): - ret = sp.Matrix(np.zeros((3,3))) - ret[0,1], ret[0,2] = -x[2], x[1] - ret[1,0], ret[1,2] = x[2], -x[0] - ret[2,0], ret[2,1] = -x[1], x[0] - return ret - -def euler_rotate(roll, pitch, yaw): - # make symbolic rotation matrix from eulers - matrix_roll = sp.Matrix([[1, 0, 0], - [0, sp.cos(roll), -sp.sin(roll)], - [0, sp.sin(roll), sp.cos(roll)]]) - matrix_pitch = sp.Matrix([[sp.cos(pitch), 0, sp.sin(pitch)], - [0, 1, 0], - [-sp.sin(pitch), 0, sp.cos(pitch)]]) - matrix_yaw = sp.Matrix([[sp.cos(yaw), -sp.sin(yaw), 0], - [sp.sin(yaw), sp.cos(yaw), 0], - [0, 0, 1]]) - return matrix_yaw*matrix_pitch*matrix_roll - -def quat_rotate(q0, q1, q2, q3): - # make symbolic rotation matrix from quat - return sp.Matrix([[q0**2 + q1**2 - q2**2 - q3**2, 2*(q1*q2 + q0*q3), 2*(q1*q3 - q0*q2)], - [2*(q1*q2 - q0*q3), q0**2 - q1**2 + q2**2 - q3**2, 2*(q2*q3 + q0*q1)], - [2*(q1*q3 + q0*q2), 2*(q2*q3 - q0*q1), q0**2 - q1**2 - q2**2 + q3**2]]).T - -def quat_matrix_l(p): - return sp.Matrix([[p[0], -p[1], -p[2], -p[3]], - [p[1], p[0], -p[3], p[2]], - [p[2], p[3], p[0], -p[1]], - [p[3], -p[2], p[1], p[0]]]) - -def quat_matrix_r(p): - return sp.Matrix([[p[0], -p[1], -p[2], -p[3]], - [p[1], p[0], p[3], -p[2]], - [p[2], -p[3], p[0], p[1]], - [p[3], p[2], -p[1], p[0]]]) - - -def sympy_into_c(sympy_functions): - from sympy.utilities import codegen - routines = [] - for name, expr, args in sympy_functions: - r = codegen.make_routine(name, expr, language="C99") - - # argument ordering input to sympy is broken with function with output arguments - nargs = [] - # reorder the input arguments - for aa in args: - if aa is None: - nargs.append(codegen.InputArgument(sp.Symbol('unused'), dimensions=[1,1])) - continue - found = False - for a in r.arguments: - if str(aa.name) == str(a.name): - nargs.append(a) - found = True - break - if not found: - # [1,1] is a hack for Matrices - nargs.append(codegen.InputArgument(aa, dimensions=[1,1])) - # add the output arguments - for a in r.arguments: - if type(a) == codegen.OutputArgument: - nargs.append(a) - - #assert len(r.arguments) == len(args)+1 - r.arguments = nargs - - # add routine to list - routines.append(r) - - [(c_name, c_code), (h_name, c_header)] = codegen.get_code_generator('C', 'ekf', 'C99').write(routines, "ekf") - c_code = '\n'.join(x for x in c_code.split("\n") if len(x) > 0 and x[0] != '#') - c_header = '\n'.join(x for x in c_header.split("\n") if len(x) > 0 and x[0] != '#') - - return c_header, c_code diff --git a/common/testing.py b/common/testing.py deleted file mode 100644 index 7e8b16d5cfefc3..00000000000000 --- a/common/testing.py +++ /dev/null @@ -1,9 +0,0 @@ -import os -from nose.tools import nottest - -def phone_only(x): - if os.path.isfile("/init.qcom.rc"): - return x - else: - return nottest(x) - diff --git a/common/text_window.py b/common/text_window.py new file mode 100755 index 00000000000000..bea3a149f8d193 --- /dev/null +++ b/common/text_window.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +import os +import time +import subprocess +from common.basedir import BASEDIR + + +class TextWindow: + def __init__(self, text): + try: + self.text_proc = subprocess.Popen(["./text", text], + stdin=subprocess.PIPE, + cwd=os.path.join(BASEDIR, "selfdrive", "ui"), + close_fds=True) + except OSError: + self.text_proc = None + + def get_status(self): + if self.text_proc is not None: + self.text_proc.poll() + return self.text_proc.returncode + return None + + def __enter__(self): + return self + + def close(self): + if self.text_proc is not None: + self.text_proc.terminate() + self.text_proc = None + + def wait_for_exit(self): + if self.text_proc is not None: + while True: + if self.get_status() == 1: + return + time.sleep(0.1) + + def __del__(self): + self.close() + + def __exit__(self, exc_type, exc_value, traceback): + self.close() + + +if __name__ == "__main__": + text = """Traceback (most recent call last): + File "./controlsd.py", line 608, in + main() + File "./controlsd.py", line 604, in main + controlsd_thread(sm, pm, logcan) + File "./controlsd.py", line 455, in controlsd_thread + 1/0 +ZeroDivisionError: division by zero""" + print(text) + + with TextWindow(text) as s: + for _ in range(100): + if s.get_status() == 1: + print("Got exit button") + break + time.sleep(0.1) + print("gone") diff --git a/common/timeout.py b/common/timeout.py index c2c1f69712f208..4d424cdc0a865c 100644 --- a/common/timeout.py +++ b/common/timeout.py @@ -25,4 +25,3 @@ def __enter__(self): def __exit__(self, exc_type, exc_val, exc_tb): signal.alarm(0) - diff --git a/common/transformations/SConscript b/common/transformations/SConscript new file mode 100644 index 00000000000000..adc9642a49aa5c --- /dev/null +++ b/common/transformations/SConscript @@ -0,0 +1,3 @@ +Import('envCython') + +envCython.Program('transformations.so', 'transformations.pyx') diff --git a/common/transformations/camera.py b/common/transformations/camera.py index 2e04c5ac220747..9c365dc7e3adb8 100644 --- a/common/transformations/camera.py +++ b/common/transformations/camera.py @@ -1,30 +1,67 @@ import numpy as np + import common.transformations.orientation as orient -import math +from selfdrive.hardware import TICI -FULL_FRAME_SIZE = (1164, 874) -W, H = FULL_FRAME_SIZE[0], FULL_FRAME_SIZE[1] -eon_focal_length = FOCAL = 910.0 +## -- hardcoded hardware params -- +eon_f_focal_length = 910.0 +eon_d_focal_length = 860.0 +leon_d_focal_length = 650.0 +tici_f_focal_length = 2648.0 +tici_e_focal_length = tici_d_focal_length = 567.0 # probably wrong? magnification is not consistent across frame -# aka 'K' aka camera_frame_from_view_frame -eon_intrinsics = np.array([ - [FOCAL, 0., W/2.], - [ 0., FOCAL, H/2.], - [ 0., 0., 1.]]) +eon_f_frame_size = (1164, 874) +eon_d_frame_size = (1152, 864) +leon_d_frame_size = (816, 612) +tici_f_frame_size = tici_e_frame_size = tici_d_frame_size = (1928, 1208) +# aka 'K' aka camera_frame_from_view_frame +eon_fcam_intrinsics = np.array([ + [eon_f_focal_length, 0.0, float(eon_f_frame_size[0])/2], + [0.0, eon_f_focal_length, float(eon_f_frame_size[1])/2], + [0.0, 0.0, 1.0]]) +eon_intrinsics = eon_fcam_intrinsics # xx leon_dcam_intrinsics = np.array([ - [650, 0, 816//2], - [ 0, 650, 612//2], - [ 0, 0, 1]]) + [leon_d_focal_length, 0.0, float(leon_d_frame_size[0])/2], + [0.0, leon_d_focal_length, float(leon_d_frame_size[1])/2], + [0.0, 0.0, 1.0]]) eon_dcam_intrinsics = np.array([ - [860, 0, 1152//2], - [ 0, 860, 864//2], - [ 0, 0, 1]]) + [eon_d_focal_length, 0.0, float(eon_d_frame_size[0])/2], + [0.0, eon_d_focal_length, float(eon_d_frame_size[1])/2], + [0.0, 0.0, 1.0]]) + +tici_fcam_intrinsics = np.array([ + [tici_f_focal_length, 0.0, float(tici_f_frame_size[0])/2], + [0.0, tici_f_focal_length, float(tici_f_frame_size[1])/2], + [0.0, 0.0, 1.0]]) + +tici_dcam_intrinsics = np.array([ + [tici_d_focal_length, 0.0, float(tici_d_frame_size[0])/2], + [0.0, tici_d_focal_length, float(tici_d_frame_size[1])/2], + [0.0, 0.0, 1.0]]) + +tici_ecam_intrinsics = tici_dcam_intrinsics # aka 'K_inv' aka view_frame_from_camera_frame -eon_intrinsics_inv = np.linalg.inv(eon_intrinsics) +eon_fcam_intrinsics_inv = np.linalg.inv(eon_fcam_intrinsics) +eon_intrinsics_inv = eon_fcam_intrinsics_inv # xx + +tici_fcam_intrinsics_inv = np.linalg.inv(tici_fcam_intrinsics) +tici_ecam_intrinsics_inv = np.linalg.inv(tici_ecam_intrinsics) + + +if not TICI: + FULL_FRAME_SIZE = eon_f_frame_size + FOCAL = eon_f_focal_length + fcam_intrinsics = eon_fcam_intrinsics +else: + FULL_FRAME_SIZE = tici_f_frame_size + FOCAL = tici_f_focal_length + fcam_intrinsics = tici_fcam_intrinsics + +W, H = FULL_FRAME_SIZE[0], FULL_FRAME_SIZE[1] # device/mesh : x->forward, y-> right, z->down @@ -44,6 +81,7 @@ def get_calib_from_vp(vp): roll_calib = 0 return roll_calib, pitch_calib, yaw_calib + # aka 'extrinsic_matrix' # road : x->forward, y -> left, z->up def get_view_frame_from_road_frame(roll, pitch, yaw, height): @@ -52,6 +90,13 @@ def get_view_frame_from_road_frame(roll, pitch, yaw, height): return np.hstack((view_from_road, [[0], [height], [0]])) +# aka 'extrinsic_matrix' +def get_view_frame_from_calib_frame(roll, pitch, yaw, height): + device_from_calib= orient.rot_from_euler([roll, pitch, yaw]) + view_from_calib = view_frame_from_device_frame.dot(device_from_calib) + return np.hstack((view_from_calib, [[0], [height], [0]])) + + def vp_from_ke(m): """ Computes the vanishing point from the product of the intrinsic and extrinsic @@ -59,7 +104,14 @@ def vp_from_ke(m): The vanishing point is defined as lim x->infinity C (x, 0, 0, 1).T """ - return (m[0, 0]/m[2,0], m[1,0]/m[2,0]) + return (m[0, 0]/m[2, 0], m[1, 0]/m[2, 0]) + + +def vp_from_rpy(rpy, intrinsics=fcam_intrinsics): + e = get_view_frame_from_road_frame(rpy[0], rpy[1], rpy[2], 1.22) + ke = np.dot(intrinsics, e) + return vp_from_ke(ke) + def roll_from_ke(m): # note: different from calibration.h/RollAnglefromKE: i think that one's just wrong @@ -67,32 +119,32 @@ def roll_from_ke(m): -(m[0, 0] - m[0, 1] * m[2, 0] / m[2, 1])) -def normalize(img_pts, intrinsics=eon_intrinsics): +def normalize(img_pts, intrinsics=fcam_intrinsics): # normalizes image coordinates # accepts single pt or array of pts intrinsics_inv = np.linalg.inv(intrinsics) img_pts = np.array(img_pts) input_shape = img_pts.shape img_pts = np.atleast_2d(img_pts) - img_pts = np.hstack((img_pts, np.ones((img_pts.shape[0],1)))) + img_pts = np.hstack((img_pts, np.ones((img_pts.shape[0], 1)))) img_pts_normalized = img_pts.dot(intrinsics_inv.T) img_pts_normalized[(img_pts < 0).any(axis=1)] = np.nan - return img_pts_normalized[:,:2].reshape(input_shape) + return img_pts_normalized[:, :2].reshape(input_shape) -def denormalize(img_pts, intrinsics=eon_intrinsics): +def denormalize(img_pts, intrinsics=fcam_intrinsics, width=W, height=H): # denormalizes image coordinates # accepts single pt or array of pts img_pts = np.array(img_pts) input_shape = img_pts.shape img_pts = np.atleast_2d(img_pts) - img_pts = np.hstack((img_pts, np.ones((img_pts.shape[0],1)))) + img_pts = np.hstack((img_pts, np.ones((img_pts.shape[0], 1)))) img_pts_denormalized = img_pts.dot(intrinsics.T) - img_pts_denormalized[img_pts_denormalized[:,0] > W] = np.nan - img_pts_denormalized[img_pts_denormalized[:,0] < 0] = np.nan - img_pts_denormalized[img_pts_denormalized[:,1] > H] = np.nan - img_pts_denormalized[img_pts_denormalized[:,1] < 0] = np.nan - return img_pts_denormalized[:,:2].reshape(input_shape) + img_pts_denormalized[img_pts_denormalized[:, 0] > width] = np.nan + img_pts_denormalized[img_pts_denormalized[:, 0] < 0] = np.nan + img_pts_denormalized[img_pts_denormalized[:, 1] > height] = np.nan + img_pts_denormalized[img_pts_denormalized[:, 1] < 0] = np.nan + return img_pts_denormalized[:, :2].reshape(input_shape) def device_from_ecef(pos_ecef, orientation_ecef, pt_ecef): @@ -117,100 +169,16 @@ def img_from_device(pt_device): pt_view = np.einsum('jk,ik->ij', view_frame_from_device_frame, pt_device) # This function should never return negative depths - pt_view[pt_view[:,2] < 0] = np.nan - - pt_img = pt_view/pt_view[:,2:3] - return pt_img.reshape(input_shape)[:,:2] - - -#TODO please use generic img transform below -def rotate_img(img, eulers, crop=None, intrinsics=eon_intrinsics): - import cv2 - - size = img.shape[:2] - rot = orient.rot_from_euler(eulers) - quadrangle = np.array([[0, 0], - [size[1]-1, 0], - [0, size[0]-1], - [size[1]-1, size[0]-1]], dtype=np.float32) - quadrangle_norm = np.hstack((normalize(quadrangle, intrinsics=intrinsics), np.ones((4,1)))) - warped_quadrangle_full = np.einsum('ij, kj->ki', intrinsics.dot(rot), quadrangle_norm) - warped_quadrangle = np.column_stack((warped_quadrangle_full[:,0]/warped_quadrangle_full[:,2], - warped_quadrangle_full[:,1]/warped_quadrangle_full[:,2])).astype(np.float32) - if crop: - W_border = (size[1] - crop[0])/2 - H_border = (size[0] - crop[1])/2 - outside_crop = (((warped_quadrangle[:,0] < W_border) | - (warped_quadrangle[:,0] >= size[1] - W_border)) & - ((warped_quadrangle[:,1] < H_border) | - (warped_quadrangle[:,1] >= size[0] - H_border))) - if not outside_crop.all(): - raise ValueError("warped image not contained inside crop") - else: - H_border, W_border = 0, 0 - M = cv2.getPerspectiveTransform(quadrangle, warped_quadrangle) - img_warped = cv2.warpPerspective(img, M, size[::-1]) - return img_warped[H_border: size[0] - H_border, - W_border: size[1] - W_border] - - -def transform_img(base_img, - augment_trans=np.array([0,0,0]), - augment_eulers=np.array([0,0,0]), - from_intr=eon_intrinsics, - to_intr=eon_intrinsics, - calib_rot_view=None, - output_size=None, - pretransform=None, - top_hacks=True): - import cv2 - - size = base_img.shape[:2] - if not output_size: - output_size = size[::-1] - - cy = from_intr[1,2] - def get_M(h=1.22): - quadrangle = np.array([[0, cy + 20], - [size[1]-1, cy + 20], - [0, size[0]-1], - [size[1]-1, size[0]-1]], dtype=np.float32) - quadrangle_norm = np.hstack((normalize(quadrangle, intrinsics=from_intr), np.ones((4,1)))) - quadrangle_world = np.column_stack((h*quadrangle_norm[:,0]/quadrangle_norm[:,1], - h*np.ones(4), - h/quadrangle_norm[:,1])) - rot = orient.rot_from_euler(augment_eulers) - if calib_rot_view is not None: - rot = calib_rot_view.dot(rot) - to_extrinsics = np.hstack((rot.T, -augment_trans[:,None])) - to_KE = to_intr.dot(to_extrinsics) - warped_quadrangle_full = np.einsum('jk,ik->ij', to_KE, np.hstack((quadrangle_world, np.ones((4,1))))) - warped_quadrangle = np.column_stack((warped_quadrangle_full[:,0]/warped_quadrangle_full[:,2], - warped_quadrangle_full[:,1]/warped_quadrangle_full[:,2])).astype(np.float32) - M = cv2.getPerspectiveTransform(quadrangle, warped_quadrangle.astype(np.float32)) - return M - - M = get_M() - if pretransform is not None: - M = M.dot(pretransform) - augmented_rgb = cv2.warpPerspective(base_img, M, output_size, borderMode=cv2.BORDER_REPLICATE) - - if top_hacks: - cyy = int(math.ceil(to_intr[1,2])) - M = get_M(1000) - if pretransform is not None: - M = M.dot(pretransform) - 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 - import cv2 - 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) + pt_view[pt_view[:, 2] < 0] = np.nan + + pt_img = pt_view/pt_view[:, 2:3] + return pt_img.reshape(input_shape)[:, :2] + + +def get_camera_frame_from_calib_frame(camera_frame_from_road_frame, intrinsics=fcam_intrinsics): + camera_frame_from_ground = camera_frame_from_road_frame[:, (0, 1, 3)] + calib_frame_from_ground = np.dot(intrinsics, + get_view_frame_from_road_frame(0, 0, 0, 1.22))[:, (0, 1, 3)] + ground_from_calib_frame = np.linalg.inv(calib_frame_from_ground) + camera_frame_from_calib_frame = np.dot(camera_frame_from_ground, ground_from_calib_frame) + return camera_frame_from_calib_frame diff --git a/common/transformations/coordinates.cc b/common/transformations/coordinates.cc new file mode 100644 index 00000000000000..8a1aa0ad723250 --- /dev/null +++ b/common/transformations/coordinates.cc @@ -0,0 +1,104 @@ +#define _USE_MATH_DEFINES + +#include +#include +#include + +#include "coordinates.hpp" + +#define DEG2RAD(x) ((x) * M_PI / 180.0) +#define RAD2DEG(x) ((x) * 180.0 / M_PI) + + +double a = 6378137; // lgtm [cpp/short-global-name] +double b = 6356752.3142; // lgtm [cpp/short-global-name] +double esq = 6.69437999014 * 0.001; // lgtm [cpp/short-global-name] +double e1sq = 6.73949674228 * 0.001; + + +static Geodetic to_degrees(Geodetic geodetic){ + geodetic.lat = RAD2DEG(geodetic.lat); + geodetic.lon = RAD2DEG(geodetic.lon); + return geodetic; +} + +static Geodetic to_radians(Geodetic geodetic){ + geodetic.lat = DEG2RAD(geodetic.lat); + geodetic.lon = DEG2RAD(geodetic.lon); + return geodetic; +} + + +ECEF geodetic2ecef(Geodetic g){ + g = to_radians(g); + double xi = sqrt(1.0 - esq * pow(sin(g.lat), 2)); + double x = (a / xi + g.alt) * cos(g.lat) * cos(g.lon); + double y = (a / xi + g.alt) * cos(g.lat) * sin(g.lon); + double z = (a / xi * (1.0 - esq) + g.alt) * sin(g.lat); + return {x, y, z}; +} + +Geodetic ecef2geodetic(ECEF e){ + // Convert from ECEF to geodetic using Ferrari's methods + // https://en.wikipedia.org/wiki/Geographic_coordinate_conversion#Ferrari.27s_solution + double x = e.x; + double y = e.y; + double z = e.z; + + double r = sqrt(x * x + y * y); + double Esq = a * a - b * b; + double F = 54 * b * b * z * z; + double G = r * r + (1 - esq) * z * z - esq * Esq; + double C = (esq * esq * F * r * r) / (pow(G, 3)); + double S = cbrt(1 + C + sqrt(C * C + 2 * C)); + double P = F / (3 * pow((S + 1 / S + 1), 2) * G * G); + double Q = sqrt(1 + 2 * esq * esq * P); + double r_0 = -(P * esq * r) / (1 + Q) + sqrt(0.5 * a * a*(1 + 1.0 / Q) - P * (1 - esq) * z * z / (Q * (1 + Q)) - 0.5 * P * r * r); + double U = sqrt(pow((r - esq * r_0), 2) + z * z); + double V = sqrt(pow((r - esq * r_0), 2) + (1 - esq) * z * z); + double Z_0 = b * b * z / (a * V); + double h = U * (1 - b * b / (a * V)); + + double lat = atan((z + e1sq * Z_0) / r); + double lon = atan2(y, x); + + return to_degrees({lat, lon, h}); +} + +LocalCoord::LocalCoord(Geodetic g, ECEF e){ + init_ecef << e.x, e.y, e.z; + + g = to_radians(g); + + ned2ecef_matrix << + -sin(g.lat)*cos(g.lon), -sin(g.lon), -cos(g.lat)*cos(g.lon), + -sin(g.lat)*sin(g.lon), cos(g.lon), -cos(g.lat)*sin(g.lon), + cos(g.lat), 0, -sin(g.lat); + ecef2ned_matrix = ned2ecef_matrix.transpose(); +} + +NED LocalCoord::ecef2ned(ECEF e) { + Eigen::Vector3d ecef; + ecef << e.x, e.y, e.z; + + Eigen::Vector3d ned = (ecef2ned_matrix * (ecef - init_ecef)); + return {ned[0], ned[1], ned[2]}; +} + +ECEF LocalCoord::ned2ecef(NED n) { + Eigen::Vector3d ned; + ned << n.n, n.e, n.d; + + Eigen::Vector3d ecef = (ned2ecef_matrix * ned) + init_ecef; + return {ecef[0], ecef[1], ecef[2]}; +} + +NED LocalCoord::geodetic2ned(Geodetic g) { + ECEF e = ::geodetic2ecef(g); + return ecef2ned(e); +} + +Geodetic LocalCoord::ned2geodetic(NED n){ + ECEF e = ned2ecef(n); + return ::ecef2geodetic(e); +} diff --git a/common/transformations/coordinates.hpp b/common/transformations/coordinates.hpp new file mode 100644 index 00000000000000..d8beb59ea9286a --- /dev/null +++ b/common/transformations/coordinates.hpp @@ -0,0 +1,35 @@ +#pragma once + +struct ECEF { + double x, y, z; + Eigen::Vector3d to_vector(){ + return Eigen::Vector3d(x, y, z); + } +}; + +struct NED { + double n, e, d; +}; + +struct Geodetic { + double lat, lon, alt; + bool radians=false; +}; + +ECEF geodetic2ecef(Geodetic g); +Geodetic ecef2geodetic(ECEF e); + +class LocalCoord { +public: + Eigen::Matrix3d ned2ecef_matrix; + Eigen::Matrix3d ecef2ned_matrix; + Eigen::Vector3d init_ecef; + LocalCoord(Geodetic g, ECEF e); + LocalCoord(Geodetic g) : LocalCoord(g, ::geodetic2ecef(g)) {} + LocalCoord(ECEF e) : LocalCoord(::ecef2geodetic(e), e) {} + + NED ecef2ned(ECEF e); + ECEF ned2ecef(NED n); + NED geodetic2ned(Geodetic g); + Geodetic ned2geodetic(NED n); +}; diff --git a/common/transformations/coordinates.py b/common/transformations/coordinates.py index 568fb9bf2b3f4e..46cc0ded0d91fe 100644 --- a/common/transformations/coordinates.py +++ b/common/transformations/coordinates.py @@ -1,108 +1,19 @@ -import numpy as np -""" -Coordinate transformation module. All methods accept arrays as input -with each row as a position. -""" +# pylint: skip-file +from common.transformations.orientation import numpy_wrap +from common.transformations.transformations import (ecef2geodetic_single, + geodetic2ecef_single) +from common.transformations.transformations import LocalCoord as LocalCoord_single +class LocalCoord(LocalCoord_single): + ecef2ned = numpy_wrap(LocalCoord_single.ecef2ned_single, (3,), (3,)) + ned2ecef = numpy_wrap(LocalCoord_single.ned2ecef_single, (3,), (3,)) + geodetic2ned = numpy_wrap(LocalCoord_single.geodetic2ned_single, (3,), (3,)) + ned2geodetic = numpy_wrap(LocalCoord_single.ned2geodetic_single, (3,), (3,)) -a = 6378137 -b = 6356752.3142 -esq = 6.69437999014 * 0.001 -e1sq = 6.73949674228 * 0.001 +geodetic2ecef = numpy_wrap(geodetic2ecef_single, (3,), (3,)) +ecef2geodetic = numpy_wrap(ecef2geodetic_single, (3,), (3,)) -def geodetic2ecef(geodetic, radians=False): - geodetic = np.array(geodetic) - input_shape = geodetic.shape - geodetic = np.atleast_2d(geodetic) - - ratio = 1.0 if radians else (np.pi / 180.0) - lat = ratio*geodetic[:,0] - lon = ratio*geodetic[:,1] - alt = geodetic[:,2] - - xi = np.sqrt(1 - esq * np.sin(lat)**2) - x = (a / xi + alt) * np.cos(lat) * np.cos(lon) - y = (a / xi + alt) * np.cos(lat) * np.sin(lon) - z = (a / xi * (1 - esq) + alt) * np.sin(lat) - ecef = np.array([x, y, z]).T - return ecef.reshape(input_shape) - - -def ecef2geodetic(ecef, radians=False): - """ - Convert ECEF coordinates to geodetic using ferrari's method - """ - # Save shape and export column - ecef = np.atleast_1d(ecef) - input_shape = ecef.shape - ecef = np.atleast_2d(ecef) - x, y, z = ecef[:, 0], ecef[:, 1], ecef[:, 2] - - ratio = 1.0 if radians else (180.0 / np.pi) - - # Conver from ECEF to geodetic using Ferrari's methods - # https://en.wikipedia.org/wiki/Geographic_coordinate_conversion#Ferrari.27s_solution - r = np.sqrt(x * x + y * y) - Esq = a * a - b * b - F = 54 * b * b * z * z - G = r * r + (1 - esq) * z * z - esq * Esq - C = (esq * esq * F * r * r) / (pow(G, 3)) - S = np.cbrt(1 + C + np.sqrt(C * C + 2 * C)) - P = F / (3 * pow((S + 1 / S + 1), 2) * G * G) - Q = np.sqrt(1 + 2 * esq * esq * P) - r_0 = -(P * esq * r) / (1 + Q) + np.sqrt(0.5 * a * a*(1 + 1.0 / Q) - \ - P * (1 - esq) * z * z / (Q * (1 + Q)) - 0.5 * P * r * r) - U = np.sqrt(pow((r - esq * r_0), 2) + z * z) - V = np.sqrt(pow((r - esq * r_0), 2) + (1 - esq) * z * z) - Z_0 = b * b * z / (a * V) - h = U * (1 - b * b / (a * V)) - lat = ratio*np.arctan((z + e1sq * Z_0) / r) - lon = ratio*np.arctan2(y, x) - - # stack the new columns and return to the original shape - geodetic = np.column_stack((lat, lon, h)) - return geodetic.reshape(input_shape) - -class LocalCoord(object): - """ - Allows conversions to local frames. In this case NED. - That is: North East Down from the start position in - meters. - """ - def __init__(self, init_geodetic, init_ecef): - self.init_ecef = init_ecef - lat, lon, _ = (np.pi/180)*np.array(init_geodetic) - self.ned2ecef_matrix = np.array([[-np.sin(lat)*np.cos(lon), -np.sin(lon), -np.cos(lat)*np.cos(lon)], - [-np.sin(lat)*np.sin(lon), np.cos(lon), -np.cos(lat)*np.sin(lon)], - [np.cos(lat), 0, -np.sin(lat)]]) - self.ecef2ned_matrix = self.ned2ecef_matrix.T - - @classmethod - def from_geodetic(cls, init_geodetic): - init_ecef = geodetic2ecef(init_geodetic) - return LocalCoord(init_geodetic, init_ecef) - - @classmethod - def from_ecef(cls, init_ecef): - init_geodetic = ecef2geodetic(init_ecef) - return LocalCoord(init_geodetic, init_ecef) - - - def ecef2ned(self, ecef): - ecef = np.array(ecef) - return np.dot(self.ecef2ned_matrix, (ecef - self.init_ecef).T).T - - def ned2ecef(self, ned): - ned = np.array(ned) - # Transpose so that init_ecef will broadcast correctly for 1d or 2d ned. - return (np.dot(self.ned2ecef_matrix, ned.T).T + self.init_ecef) - - def geodetic2ned(self, geodetic): - ecef = geodetic2ecef(geodetic) - return self.ecef2ned(ecef) - - def ned2geodetic(self, ned): - ecef = self.ned2ecef(ned) - return ecef2geodetic(ecef) +geodetic_from_ecef = ecef2geodetic +ecef_from_geodetic = geodetic2ecef diff --git a/common/transformations/model.py b/common/transformations/model.py index e832cb7ee9f219..481240f99943b9 100644 --- a/common/transformations/model.py +++ b/common/transformations/model.py @@ -1,33 +1,33 @@ import numpy as np -from common.transformations.camera import eon_focal_length, \ - vp_from_ke, get_view_frame_from_road_frame, \ - FULL_FRAME_SIZE +from common.transformations.camera import (FULL_FRAME_SIZE, + FOCAL, + get_view_frame_from_road_frame, + get_view_frame_from_calib_frame, + vp_from_ke) # segnet - SEGNET_SIZE = (512, 384) -segnet_frame_from_camera_frame = np.array([ - [float(SEGNET_SIZE[0])/FULL_FRAME_SIZE[0], 0., ], - [ 0., float(SEGNET_SIZE[1])/FULL_FRAME_SIZE[1]]]) - +def get_segnet_frame_from_camera_frame(segnet_size=SEGNET_SIZE, full_frame_size=FULL_FRAME_SIZE): + return np.array([[float(segnet_size[0]) / full_frame_size[0], 0.0], + [0.0, float(segnet_size[1]) / full_frame_size[1]]]) +segnet_frame_from_camera_frame = get_segnet_frame_from_camera_frame() # xx # model - MODEL_INPUT_SIZE = (320, 160) MODEL_YUV_SIZE = (MODEL_INPUT_SIZE[0], MODEL_INPUT_SIZE[1] * 3 // 2) -MODEL_CX = MODEL_INPUT_SIZE[0]/2. +MODEL_CX = MODEL_INPUT_SIZE[0] / 2. MODEL_CY = 21. -model_zoom = 1.25 +model_fl = 728.0 model_height = 1.22 # canonical model transform -model_intrinsics = np.array( - [[ eon_focal_length / model_zoom, 0. , MODEL_CX], - [ 0. , eon_focal_length / model_zoom, MODEL_CY], - [ 0. , 0. , 1.]]) +model_intrinsics = np.array([ + [model_fl, 0.0, MODEL_CX], + [0.0, model_fl, MODEL_CY], + [0.0, 0.0, 1.0]]) # MED model @@ -35,32 +35,45 @@ MEDMODEL_YUV_SIZE = (MEDMODEL_INPUT_SIZE[0], MEDMODEL_INPUT_SIZE[1] * 3 // 2) MEDMODEL_CY = 47.6 -medmodel_zoom = 1. -medmodel_intrinsics = np.array( - [[ eon_focal_length / medmodel_zoom, 0. , 0.5 * MEDMODEL_INPUT_SIZE[0]], - [ 0. , eon_focal_length / medmodel_zoom, MEDMODEL_CY], - [ 0. , 0. , 1.]]) +medmodel_fl = 910.0 +medmodel_intrinsics = np.array([ + [medmodel_fl, 0.0, 0.5 * MEDMODEL_INPUT_SIZE[0]], + [0.0, medmodel_fl, MEDMODEL_CY], + [0.0, 0.0, 1.0]]) -# BIG model +# CAL model +CALMODEL_INPUT_SIZE = (512, 256) +CALMODEL_YUV_SIZE = (CALMODEL_INPUT_SIZE[0], CALMODEL_INPUT_SIZE[1] * 3 // 2) +CALMODEL_CY = 47.6 + +calmodel_fl = 606.7 +calmodel_intrinsics = np.array([ + [calmodel_fl, 0.0, 0.5 * CALMODEL_INPUT_SIZE[0]], + [0.0, calmodel_fl, CALMODEL_CY], + [0.0, 0.0, 1.0]]) -BIGMODEL_INPUT_SIZE = (864, 288) + +# BIG model +BIGMODEL_INPUT_SIZE = (1024, 512) BIGMODEL_YUV_SIZE = (BIGMODEL_INPUT_SIZE[0], BIGMODEL_INPUT_SIZE[1] * 3 // 2) -bigmodel_zoom = 1. -bigmodel_intrinsics = np.array( - [[ eon_focal_length / bigmodel_zoom, 0. , 0.5 * BIGMODEL_INPUT_SIZE[0]], - [ 0. , eon_focal_length / bigmodel_zoom, 0.2 * BIGMODEL_INPUT_SIZE[1]], - [ 0. , 0. , 1.]]) +bigmodel_fl = 910.0 +bigmodel_intrinsics = np.array([ + [bigmodel_fl, 0.0, 0.5 * BIGMODEL_INPUT_SIZE[0]], + [0.0, bigmodel_fl, 256 + MEDMODEL_CY], + [0.0, 0.0, 1.0]]) -bigmodel_border = np.array([ - [0,0,1], - [BIGMODEL_INPUT_SIZE[0], 0, 1], - [BIGMODEL_INPUT_SIZE[0], BIGMODEL_INPUT_SIZE[1], 1], - [0, BIGMODEL_INPUT_SIZE[1], 1], -]) +# SBIG model (big model with the size of small model) +SBIGMODEL_INPUT_SIZE = (512, 256) +SBIGMODEL_YUV_SIZE = (SBIGMODEL_INPUT_SIZE[0], SBIGMODEL_INPUT_SIZE[1] * 3 // 2) +sbigmodel_fl = 455.0 +sbigmodel_intrinsics = np.array([ + [sbigmodel_fl, 0.0, 0.5 * SBIGMODEL_INPUT_SIZE[0]], + [0.0, sbigmodel_fl, 0.5 * (256 + MEDMODEL_CY)], + [0.0, 0.0, 1.0]]) model_frame_from_road_frame = np.dot(model_intrinsics, get_view_frame_from_road_frame(0, 0, 0, model_height)) @@ -71,22 +84,27 @@ medmodel_frame_from_road_frame = np.dot(medmodel_intrinsics, get_view_frame_from_road_frame(0, 0, 0, model_height)) +medmodel_frame_from_calib_frame = np.dot(medmodel_intrinsics, + get_view_frame_from_calib_frame(0, 0, 0, 0)) + model_frame_from_bigmodel_frame = np.dot(model_intrinsics, np.linalg.inv(bigmodel_intrinsics)) +medmodel_frame_from_bigmodel_frame = np.dot(medmodel_intrinsics, np.linalg.inv(bigmodel_intrinsics)) + # 'camera from model camera' def get_model_height_transform(camera_frame_from_road_frame, height): camera_frame_from_road_ground = np.dot(camera_frame_from_road_frame, np.array([ - [1, 0, 0], - [0, 1, 0], - [0, 0, 0], - [0, 0, 1], + [1, 0, 0], + [0, 1, 0], + [0, 0, 0], + [0, 0, 1], ])) camera_frame_from_road_high = np.dot(camera_frame_from_road_frame, np.array([ - [1, 0, 0], - [0, 1, 0], - [0, 0, height - model_height], - [0, 0, 1], + [1, 0, 0], + [0, 1, 0], + [0, 0, height - model_height], + [0, 0, 1], ])) road_high_from_camera_frame = np.linalg.inv(camera_frame_from_road_high) @@ -97,18 +115,19 @@ def get_model_height_transform(camera_frame_from_road_frame, height): # camera_frame_from_model_frame aka 'warp matrix' # was: calibration.h/CalibrationTransform -def get_camera_frame_from_model_frame(camera_frame_from_road_frame, height=model_height): +def get_camera_frame_from_model_frame(camera_frame_from_road_frame, height=model_height, camera_fl=FOCAL): vp = vp_from_ke(camera_frame_from_road_frame) + model_zoom = camera_fl / model_fl model_camera_from_model_frame = np.array([ - [model_zoom, 0., vp[0] - MODEL_CX * model_zoom], - [ 0., model_zoom, vp[1] - MODEL_CY * model_zoom], - [ 0., 0., 1.], + [model_zoom, 0.0, vp[0] - MODEL_CX * model_zoom], + [0.0, model_zoom, vp[1] - MODEL_CY * model_zoom], + [0.0, 0.0, 1.0], ]) # This function is super slow, so skip it if height is very close to canonical # TODO: speed it up! - if abs(height - model_height) > 0.001: # + if abs(height - model_height) > 0.001: camera_from_model_camera = get_model_height_transform(camera_frame_from_road_frame, height) else: camera_from_model_camera = np.eye(3) @@ -138,9 +157,9 @@ def get_camera_frame_from_bigmodel_frame(camera_frame_from_road_frame): def get_model_frame(snu_full, camera_frame_from_model_frame, size): idxs = camera_frame_from_model_frame.dot(np.column_stack([np.tile(np.arange(size[0]), size[1]), - np.tile(np.arange(size[1]), (size[0],1)).T.flatten(), + np.tile(np.arange(size[1]), (size[0], 1)).T.flatten(), np.ones(size[0] * size[1])]).T).T.astype(int) - calib_flat = snu_full[idxs[:,1], idxs[:,0]] + calib_flat = snu_full[idxs[:, 1], idxs[:, 0]] if len(snu_full.shape) == 3: calib = calib_flat.reshape((size[1], size[0], 3)) elif len(snu_full.shape) == 2: diff --git a/common/transformations/orientation.cc b/common/transformations/orientation.cc new file mode 100644 index 00000000000000..086219d234d014 --- /dev/null +++ b/common/transformations/orientation.cc @@ -0,0 +1,147 @@ +#define _USE_MATH_DEFINES + +#include +#include +#include + +#include "orientation.hpp" +#include "coordinates.hpp" + +Eigen::Quaterniond ensure_unique(Eigen::Quaterniond quat){ + if (quat.w() > 0){ + return quat; + } else { + return Eigen::Quaterniond(-quat.w(), -quat.x(), -quat.y(), -quat.z()); + } +} + +Eigen::Quaterniond euler2quat(Eigen::Vector3d euler){ + Eigen::Quaterniond q; + + q = Eigen::AngleAxisd(euler(2), Eigen::Vector3d::UnitZ()) + * Eigen::AngleAxisd(euler(1), Eigen::Vector3d::UnitY()) + * Eigen::AngleAxisd(euler(0), Eigen::Vector3d::UnitX()); + return ensure_unique(q); +} + + +Eigen::Vector3d quat2euler(Eigen::Quaterniond quat){ + // TODO: switch to eigen implementation if the range of the Euler angles doesn't matter anymore + // Eigen::Vector3d euler = quat.toRotationMatrix().eulerAngles(2, 1, 0); + // return {euler(2), euler(1), euler(0)}; + double gamma = atan2(2 * (quat.w() * quat.x() + quat.y() * quat.z()), 1 - 2 * (quat.x()*quat.x() + quat.y()*quat.y())); + double theta = asin(2 * (quat.w() * quat.y() - quat.z() * quat.x())); + double psi = atan2(2 * (quat.w() * quat.z() + quat.x() * quat.y()), 1 - 2 * (quat.y()*quat.y() + quat.z()*quat.z())); + return {gamma, theta, psi}; +} + +Eigen::Matrix3d quat2rot(Eigen::Quaterniond quat){ + return quat.toRotationMatrix(); +} + +Eigen::Quaterniond rot2quat(Eigen::Matrix3d rot){ + return ensure_unique(Eigen::Quaterniond(rot)); +} + +Eigen::Matrix3d euler2rot(Eigen::Vector3d euler){ + return quat2rot(euler2quat(euler)); +} + +Eigen::Vector3d rot2euler(Eigen::Matrix3d rot){ + return quat2euler(rot2quat(rot)); +} + +Eigen::Matrix3d rot_matrix(double roll, double pitch, double yaw){ + return euler2rot({roll, pitch, yaw}); +} + +Eigen::Matrix3d rot(Eigen::Vector3d axis, double angle){ + Eigen::Quaterniond q; + q = Eigen::AngleAxisd(angle, axis); + return q.toRotationMatrix(); +} + + +Eigen::Vector3d ecef_euler_from_ned(ECEF ecef_init, Eigen::Vector3d ned_pose) { + /* + Using Rotations to Build Aerospace Coordinate Systems + Don Koks + https://apps.dtic.mil/dtic/tr/fulltext/u2/a484864.pdf + */ + LocalCoord converter = LocalCoord(ecef_init); + Eigen::Vector3d zero = ecef_init.to_vector(); + + Eigen::Vector3d x0 = converter.ned2ecef({1, 0, 0}).to_vector() - zero; + Eigen::Vector3d y0 = converter.ned2ecef({0, 1, 0}).to_vector() - zero; + Eigen::Vector3d z0 = converter.ned2ecef({0, 0, 1}).to_vector() - zero; + + Eigen::Vector3d x1 = rot(z0, ned_pose(2)) * x0; + Eigen::Vector3d y1 = rot(z0, ned_pose(2)) * y0; + Eigen::Vector3d z1 = rot(z0, ned_pose(2)) * z0; + + Eigen::Vector3d x2 = rot(y1, ned_pose(1)) * x1; + Eigen::Vector3d y2 = rot(y1, ned_pose(1)) * y1; + Eigen::Vector3d z2 = rot(y1, ned_pose(1)) * z1; + + Eigen::Vector3d x3 = rot(x2, ned_pose(0)) * x2; + Eigen::Vector3d y3 = rot(x2, ned_pose(0)) * y2; + + + x0 = Eigen::Vector3d(1, 0, 0); + y0 = Eigen::Vector3d(0, 1, 0); + z0 = Eigen::Vector3d(0, 0, 1); + + double psi = atan2(x3.dot(y0), x3.dot(x0)); + double theta = atan2(-x3.dot(z0), sqrt(pow(x3.dot(x0), 2) + pow(x3.dot(y0), 2))); + + y2 = rot(z0, psi) * y0; + z2 = rot(y2, theta) * z0; + + double phi = atan2(y3.dot(z2), y3.dot(y2)); + + return {phi, theta, psi}; +} + +Eigen::Vector3d ned_euler_from_ecef(ECEF ecef_init, Eigen::Vector3d ecef_pose){ + /* + Using Rotations to Build Aerospace Coordinate Systems + Don Koks + https://apps.dtic.mil/dtic/tr/fulltext/u2/a484864.pdf + */ + LocalCoord converter = LocalCoord(ecef_init); + + Eigen::Vector3d x0 = Eigen::Vector3d(1, 0, 0); + Eigen::Vector3d y0 = Eigen::Vector3d(0, 1, 0); + Eigen::Vector3d z0 = Eigen::Vector3d(0, 0, 1); + + Eigen::Vector3d x1 = rot(z0, ecef_pose(2)) * x0; + Eigen::Vector3d y1 = rot(z0, ecef_pose(2)) * y0; + Eigen::Vector3d z1 = rot(z0, ecef_pose(2)) * z0; + + Eigen::Vector3d x2 = rot(y1, ecef_pose(1)) * x1; + Eigen::Vector3d y2 = rot(y1, ecef_pose(1)) * y1; + Eigen::Vector3d z2 = rot(y1, ecef_pose(1)) * z1; + + Eigen::Vector3d x3 = rot(x2, ecef_pose(0)) * x2; + Eigen::Vector3d y3 = rot(x2, ecef_pose(0)) * y2; + + Eigen::Vector3d zero = ecef_init.to_vector(); + x0 = converter.ned2ecef({1, 0, 0}).to_vector() - zero; + y0 = converter.ned2ecef({0, 1, 0}).to_vector() - zero; + z0 = converter.ned2ecef({0, 0, 1}).to_vector() - zero; + + double psi = atan2(x3.dot(y0), x3.dot(x0)); + double theta = atan2(-x3.dot(z0), sqrt(pow(x3.dot(x0), 2) + pow(x3.dot(y0), 2))); + + y2 = rot(z0, psi) * y0; + z2 = rot(y2, theta) * z0; + + double phi = atan2(y3.dot(z2), y3.dot(y2)); + + return {phi, theta, psi}; +} + + + +int main(void){ +} diff --git a/common/transformations/orientation.hpp b/common/transformations/orientation.hpp new file mode 100644 index 00000000000000..da95f7099d58d1 --- /dev/null +++ b/common/transformations/orientation.hpp @@ -0,0 +1,17 @@ +#pragma once +#include +#include "coordinates.hpp" + + +Eigen::Quaterniond ensure_unique(Eigen::Quaterniond quat); + +Eigen::Quaterniond euler2quat(Eigen::Vector3d euler); +Eigen::Vector3d quat2euler(Eigen::Quaterniond quat); +Eigen::Matrix3d quat2rot(Eigen::Quaterniond quat); +Eigen::Quaterniond rot2quat(Eigen::Matrix3d rot); +Eigen::Matrix3d euler2rot(Eigen::Vector3d euler); +Eigen::Vector3d rot2euler(Eigen::Matrix3d rot); +Eigen::Matrix3d rot_matrix(double roll, double pitch, double yaw); +Eigen::Matrix3d rot(Eigen::Vector3d axis, double angle); +Eigen::Vector3d ecef_euler_from_ned(ECEF ecef_init, Eigen::Vector3d ned_pose); +Eigen::Vector3d ned_euler_from_ecef(ECEF ecef_init, Eigen::Vector3d ecef_pose); diff --git a/common/transformations/orientation.py b/common/transformations/orientation.py index 33a822ca3fd498..415e247ab26323 100644 --- a/common/transformations/orientation.py +++ b/common/transformations/orientation.py @@ -1,295 +1,52 @@ +# pylint: skip-file import numpy as np -from numpy import dot, inner, array, linalg -from common.transformations.coordinates import LocalCoord - - -''' -Vectorized functions that transform between -rotation matrices, euler angles and quaternions. -All support lists, array or array of arrays as inputs. -Supports both x2y and y_from_x format (y_from_x preferred!). -''' - -def euler2quat(eulers): - eulers = array(eulers) - if len(eulers.shape) > 1: - output_shape = (-1,4) - else: - output_shape = (4,) - eulers = np.atleast_2d(eulers) - gamma, theta, psi = eulers[:,0], eulers[:,1], eulers[:,2] - - q0 = np.cos(gamma / 2) * np.cos(theta / 2) * np.cos(psi / 2) + \ - np.sin(gamma / 2) * np.sin(theta / 2) * np.sin(psi / 2) - q1 = np.sin(gamma / 2) * np.cos(theta / 2) * np.cos(psi / 2) - \ - np.cos(gamma / 2) * np.sin(theta / 2) * np.sin(psi / 2) - q2 = np.cos(gamma / 2) * np.sin(theta / 2) * np.cos(psi / 2) + \ - np.sin(gamma / 2) * np.cos(theta / 2) * np.sin(psi / 2) - q3 = np.cos(gamma / 2) * np.cos(theta / 2) * np.sin(psi / 2) - \ - np.sin(gamma / 2) * np.sin(theta / 2) * np.cos(psi / 2) - - quats = array([q0, q1, q2, q3]).T - for i in xrange(len(quats)): - if quats[i,0] < 0: - quats[i] = -quats[i] - return quats.reshape(output_shape) - - -def quat2euler(quats): - quats = array(quats) - if len(quats.shape) > 1: - output_shape = (-1,3) - else: - output_shape = (3,) - quats = np.atleast_2d(quats) - q0, q1, q2, q3 = quats[:,0], quats[:,1], quats[:,2], quats[:,3] - - gamma = np.arctan2(2 * (q0 * q1 + q2 * q3), 1 - 2 * (q1**2 + q2**2)) - theta = np.arcsin(2 * (q0 * q2 - q3 * q1)) - psi = np.arctan2(2 * (q0 * q3 + q1 * q2), 1 - 2 * (q2**2 + q3**2)) - - eulers = array([gamma, theta, psi]).T - return eulers.reshape(output_shape) - - -def quat2rot(quats): - quats = array(quats) - input_shape = quats.shape - quats = np.atleast_2d(quats) - Rs = np.zeros((quats.shape[0], 3, 3)) - q0 = quats[:, 0] - q1 = quats[:, 1] - q2 = quats[:, 2] - q3 = quats[:, 3] - Rs[:, 0, 0] = q0 * q0 + q1 * q1 - q2 * q2 - q3 * q3 - Rs[:, 0, 1] = 2 * (q1 * q2 - q0 * q3) - Rs[:, 0, 2] = 2 * (q0 * q2 + q1 * q3) - Rs[:, 1, 0] = 2 * (q1 * q2 + q0 * q3) - Rs[:, 1, 1] = q0 * q0 - q1 * q1 + q2 * q2 - q3 * q3 - Rs[:, 1, 2] = 2 * (q2 * q3 - q0 * q1) - Rs[:, 2, 0] = 2 * (q1 * q3 - q0 * q2) - Rs[:, 2, 1] = 2 * (q0 * q1 + q2 * q3) - Rs[:, 2, 2] = q0 * q0 - q1 * q1 - q2 * q2 + q3 * q3 - - if len(input_shape) < 2: - return Rs[0] - else: - return Rs - - -def rot2quat(rots): - input_shape = rots.shape - if len(input_shape) < 3: - rots = array([rots]) - K3 = np.empty((len(rots), 4, 4)) - K3[:, 0, 0] = (rots[:, 0, 0] - rots[:, 1, 1] - rots[:, 2, 2]) / 3.0 - K3[:, 0, 1] = (rots[:, 1, 0] + rots[:, 0, 1]) / 3.0 - K3[:, 0, 2] = (rots[:, 2, 0] + rots[:, 0, 2]) / 3.0 - K3[:, 0, 3] = (rots[:, 1, 2] - rots[:, 2, 1]) / 3.0 - K3[:, 1, 0] = K3[:, 0, 1] - K3[:, 1, 1] = (rots[:, 1, 1] - rots[:, 0, 0] - rots[:, 2, 2]) / 3.0 - K3[:, 1, 2] = (rots[:, 2, 1] + rots[:, 1, 2]) / 3.0 - K3[:, 1, 3] = (rots[:, 2, 0] - rots[:, 0, 2]) / 3.0 - K3[:, 2, 0] = K3[:, 0, 2] - K3[:, 2, 1] = K3[:, 1, 2] - K3[:, 2, 2] = (rots[:, 2, 2] - rots[:, 0, 0] - rots[:, 1, 1]) / 3.0 - K3[:, 2, 3] = (rots[:, 0, 1] - rots[:, 1, 0]) / 3.0 - K3[:, 3, 0] = K3[:, 0, 3] - K3[:, 3, 1] = K3[:, 1, 3] - K3[:, 3, 2] = K3[:, 2, 3] - K3[:, 3, 3] = (rots[:, 0, 0] + rots[:, 1, 1] + rots[:, 2, 2]) / 3.0 - q = np.empty((len(rots), 4)) - for i in xrange(len(rots)): - _, eigvecs = linalg.eigh(K3[i].T) - eigvecs = eigvecs[:,3:] - q[i, 0] = eigvecs[-1] - q[i, 1:] = -eigvecs[:-1].flatten() - if q[i, 0] < 0: - q[i] = -q[i] - - if len(input_shape) < 3: - return q[0] - else: - return q - - -def euler2rot(eulers): - return rotations_from_quats(euler2quat(eulers)) - - -def rot2euler(rots): - return quat2euler(quats_from_rotations(rots)) +from common.transformations.transformations import (ecef_euler_from_ned_single, + euler2quat_single, + euler2rot_single, + ned_euler_from_ecef_single, + quat2euler_single, + quat2rot_single, + rot2euler_single, + rot2quat_single) + + +def numpy_wrap(function, input_shape, output_shape): + """Wrap a function to take either an input or list of inputs and return the correct shape""" + def f(*inps): + *args, inp = inps + inp = np.array(inp) + shape = inp.shape + + if len(shape) == len(input_shape): + out_shape = output_shape + else: + out_shape = (shape[0],) + output_shape + + # Add empty dimension if inputs is not a list + if len(shape) == len(input_shape): + inp.shape = (1, ) + inp.shape + + result = np.asarray([function(*args, i) for i in inp]) + result.shape = out_shape + return result + return f + + +euler2quat = numpy_wrap(euler2quat_single, (3,), (4,)) +quat2euler = numpy_wrap(quat2euler_single, (4,), (3,)) +quat2rot = numpy_wrap(quat2rot_single, (4,), (3, 3)) +rot2quat = numpy_wrap(rot2quat_single, (3, 3), (4,)) +euler2rot = numpy_wrap(euler2rot_single, (3,), (3, 3)) +rot2euler = numpy_wrap(rot2euler_single, (3, 3), (3,)) +ecef_euler_from_ned = numpy_wrap(ecef_euler_from_ned_single, (3,), (3,)) +ned_euler_from_ecef = numpy_wrap(ned_euler_from_ecef_single, (3,), (3,)) quats_from_rotations = rot2quat quat_from_rot = rot2quat rotations_from_quats = quat2rot -rot_from_quat= quat2rot -rot_from_quat= quat2rot +rot_from_quat = quat2rot euler_from_rot = rot2euler euler_from_quat = quat2euler rot_from_euler = euler2rot quat_from_euler = euler2quat - - - - - - -''' -Random helpers below -''' - - -def quat_product(q, r): - t = np.zeros(4) - t[0] = r[0] * q[0] - r[1] * q[1] - r[2] * q[2] - r[3] * q[3] - t[1] = r[0] * q[1] + r[1] * q[0] - r[2] * q[3] + r[3] * q[2] - t[2] = r[0] * q[2] + r[1] * q[3] + r[2] * q[0] - r[3] * q[1] - t[3] = r[0] * q[3] - r[1] * q[2] + r[2] * q[1] + r[3] * q[0] - return t - - -def rot_matrix(roll, pitch, yaw): - cr, sr = np.cos(roll), np.sin(roll) - cp, sp = np.cos(pitch), np.sin(pitch) - cy, sy = np.cos(yaw), np.sin(yaw) - rr = array([[1,0,0],[0, cr,-sr],[0, sr, cr]]) - rp = array([[cp,0,sp],[0, 1,0],[-sp, 0, cp]]) - ry = array([[cy,-sy,0],[sy, cy,0],[0, 0, 1]]) - return ry.dot(rp.dot(rr)) - - -def rot(axis, angle): - # Rotates around an arbitrary axis - ret_1 = (1 - np.cos(angle)) * array([[axis[0]**2, axis[0] * axis[1], axis[0] * axis[2]], [ - axis[1] * axis[0], axis[1]**2, axis[1] * axis[2] - ], [axis[2] * axis[0], axis[2] * axis[1], axis[2]**2]]) - ret_2 = np.cos(angle) * np.eye(3) - ret_3 = np.sin(angle) * array([[0, -axis[2], axis[1]], [axis[2], 0, -axis[0]], - [-axis[1], axis[0], 0]]) - return ret_1 + ret_2 + ret_3 - - -def ecef_euler_from_ned(ned_ecef_init, ned_pose): - ''' - Got it from here: - Using Rotations to Build Aerospace Coordinate Systems - -Don Koks - ''' - converter = LocalCoord.from_ecef(ned_ecef_init) - x0 = converter.ned2ecef([1, 0, 0]) - converter.ned2ecef([0, 0, 0]) - y0 = converter.ned2ecef([0, 1, 0]) - converter.ned2ecef([0, 0, 0]) - z0 = converter.ned2ecef([0, 0, 1]) - converter.ned2ecef([0, 0, 0]) - - x1 = rot(z0, ned_pose[2]).dot(x0) - y1 = rot(z0, ned_pose[2]).dot(y0) - z1 = rot(z0, ned_pose[2]).dot(z0) - - x2 = rot(y1, ned_pose[1]).dot(x1) - y2 = rot(y1, ned_pose[1]).dot(y1) - z2 = rot(y1, ned_pose[1]).dot(z1) - - x3 = rot(x2, ned_pose[0]).dot(x2) - y3 = rot(x2, ned_pose[0]).dot(y2) - #z3 = rot(x2, ned_pose[0]).dot(z2) - - x0 = array([1, 0, 0]) - y0 = array([0, 1, 0]) - z0 = array([0, 0, 1]) - - psi = np.arctan2(inner(x3, y0), inner(x3, x0)) - theta = np.arctan2(-inner(x3, z0), np.sqrt(inner(x3, x0)**2 + inner(x3, y0)**2)) - y2 = rot(z0, psi).dot(y0) - z2 = rot(y2, theta).dot(z0) - phi = np.arctan2(inner(y3, z2), inner(y3, y2)) - - ret = array([phi, theta, psi]) - return ret - - -def ned_euler_from_ecef(ned_ecef_init, ecef_poses): - ''' - Got the math from here: - Using Rotations to Build Aerospace Coordinate Systems - -Don Koks - - Also accepts array of ecef_poses and array of ned_ecef_inits. - Where each row is a pose and an ecef_init. - ''' - ned_ecef_init = array(ned_ecef_init) - ecef_poses = array(ecef_poses) - output_shape = ecef_poses.shape - ned_ecef_init = np.atleast_2d(ned_ecef_init) - if ned_ecef_init.shape[0] == 1: - ned_ecef_init = np.tile(ned_ecef_init[0], (output_shape[0], 1)) - ecef_poses = np.atleast_2d(ecef_poses) - - ned_poses = np.zeros(ecef_poses.shape) - for i, ecef_pose in enumerate(ecef_poses): - converter = LocalCoord.from_ecef(ned_ecef_init[i]) - x0 = array([1, 0, 0]) - y0 = array([0, 1, 0]) - z0 = array([0, 0, 1]) - - x1 = rot(z0, ecef_pose[2]).dot(x0) - y1 = rot(z0, ecef_pose[2]).dot(y0) - z1 = rot(z0, ecef_pose[2]).dot(z0) - - x2 = rot(y1, ecef_pose[1]).dot(x1) - y2 = rot(y1, ecef_pose[1]).dot(y1) - z2 = rot(y1, ecef_pose[1]).dot(z1) - - x3 = rot(x2, ecef_pose[0]).dot(x2) - y3 = rot(x2, ecef_pose[0]).dot(y2) - #z3 = rot(x2, ecef_pose[0]).dot(z2) - - x0 = converter.ned2ecef([1, 0, 0]) - converter.ned2ecef([0, 0, 0]) - y0 = converter.ned2ecef([0, 1, 0]) - converter.ned2ecef([0, 0, 0]) - z0 = converter.ned2ecef([0, 0, 1]) - converter.ned2ecef([0, 0, 0]) - - psi = np.arctan2(inner(x3, y0), inner(x3, x0)) - theta = np.arctan2(-inner(x3, z0), np.sqrt(inner(x3, x0)**2 + inner(x3, y0)**2)) - y2 = rot(z0, psi).dot(y0) - z2 = rot(y2, theta).dot(z0) - phi = np.arctan2(inner(y3, z2), inner(y3, y2)) - ned_poses[i] = array([phi, theta, psi]) - - return ned_poses.reshape(output_shape) - - -def ecef2car(car_ecef, psi, theta, points_ecef, ned_converter): - """ - TODO: add roll rotation - Converts an array of points in ecef coordinates into - x-forward, y-left, z-up coordinates - Parameters - ---------- - psi: yaw, radian - theta: pitch, radian - Returns - ------- - [x, y, z] coordinates in car frame - """ - - # input is an array of points in ecef cocrdinates - # output is an array of points in car's coordinate (x-front, y-left, z-up) - - # convert points to NED - points_ned = [] - for p in points_ecef: - points_ned.append(ned_converter.ecef2ned_matrix.dot(array(p) - car_ecef)) - - points_ned = np.vstack(points_ned).T - - # n, e, d -> x, y, z - # Calculate relative postions and rotate wrt to heading and pitch of car - invert_R = array([[1., 0., 0.], [0., -1., 0.], [0., 0., -1.]]) - - c, s = np.cos(psi), np.sin(psi) - yaw_R = array([[c, s, 0.], [-s, c, 0.], [0., 0., 1.]]) - - c, s = np.cos(theta), np.sin(theta) - pitch_R = array([[c, 0., -s], [0., 1., 0.], [s, 0., c]]) - - return dot(pitch_R, dot(yaw_R, dot(invert_R, points_ned))) diff --git a/common/transformations/transformations.pxd b/common/transformations/transformations.pxd new file mode 100644 index 00000000000000..7af009870198ad --- /dev/null +++ b/common/transformations/transformations.pxd @@ -0,0 +1,72 @@ +#cython: language_level=3 +from libcpp cimport bool + +cdef extern from "orientation.cc": + pass + +cdef extern from "orientation.hpp": + cdef cppclass Quaternion "Eigen::Quaterniond": + Quaternion() + Quaternion(double, double, double, double) + double w() + double x() + double y() + double z() + + cdef cppclass Vector3 "Eigen::Vector3d": + Vector3() + Vector3(double, double, double) + double operator()(int) + + cdef cppclass Matrix3 "Eigen::Matrix3d": + Matrix3() + Matrix3(double*) + + double operator()(int, int) + + Quaternion euler2quat(Vector3) + Vector3 quat2euler(Quaternion) + Matrix3 quat2rot(Quaternion) + Quaternion rot2quat(Matrix3) + Vector3 rot2euler(Matrix3) + Matrix3 euler2rot(Vector3) + Matrix3 rot_matrix(double, double, double) + Vector3 ecef_euler_from_ned(ECEF, Vector3) + Vector3 ned_euler_from_ecef(ECEF, Vector3) + + +cdef extern from "coordinates.cc": + cdef struct ECEF: + double x + double y + double z + + cdef struct NED: + double n + double e + double d + + cdef struct Geodetic: + double lat + double lon + double alt + bool radians + + ECEF geodetic2ecef(Geodetic) + Geodetic ecef2geodetic(ECEF) + + cdef cppclass LocalCoord_c "LocalCoord": + Matrix3 ned2ecef_matrix + Matrix3 ecef2ned_matrix + + LocalCoord_c(Geodetic, ECEF) + LocalCoord_c(Geodetic) + LocalCoord_c(ECEF) + + NED ecef2ned(ECEF) + ECEF ned2ecef(NED) + NED geodetic2ned(Geodetic) + Geodetic ned2geodetic(NED) + +cdef extern from "coordinates.hpp": + pass diff --git a/common/transformations/transformations.pyx b/common/transformations/transformations.pyx new file mode 100644 index 00000000000000..ce80d90d29ed07 --- /dev/null +++ b/common/transformations/transformations.pyx @@ -0,0 +1,174 @@ +# distutils: language = c++ +# cython: language_level = 3 +from common.transformations.transformations cimport Matrix3, Vector3, Quaternion +from common.transformations.transformations cimport ECEF, NED, Geodetic + +from common.transformations.transformations cimport euler2quat as euler2quat_c +from common.transformations.transformations cimport quat2euler as quat2euler_c +from common.transformations.transformations cimport quat2rot as quat2rot_c +from common.transformations.transformations cimport rot2quat as rot2quat_c +from common.transformations.transformations cimport euler2rot as euler2rot_c +from common.transformations.transformations cimport rot2euler as rot2euler_c +from common.transformations.transformations cimport rot_matrix as rot_matrix_c +from common.transformations.transformations cimport ecef_euler_from_ned as ecef_euler_from_ned_c +from common.transformations.transformations cimport ned_euler_from_ecef as ned_euler_from_ecef_c +from common.transformations.transformations cimport geodetic2ecef as geodetic2ecef_c +from common.transformations.transformations cimport ecef2geodetic as ecef2geodetic_c +from common.transformations.transformations cimport LocalCoord_c + + +import cython +import numpy as np +cimport numpy as np + +cdef np.ndarray[double, ndim=2] matrix2numpy(Matrix3 m): + return np.array([ + [m(0, 0), m(0, 1), m(0, 2)], + [m(1, 0), m(1, 1), m(1, 2)], + [m(2, 0), m(2, 1), m(2, 2)], + ]) + +cdef Matrix3 numpy2matrix(np.ndarray[double, ndim=2, mode="fortran"] m): + assert m.shape[0] == 3 + assert m.shape[1] == 3 + return Matrix3(m.data) + +cdef ECEF list2ecef(ecef): + cdef ECEF e; + e.x = ecef[0] + e.y = ecef[1] + e.z = ecef[2] + return e + +cdef NED list2ned(ned): + cdef NED n; + n.n = ned[0] + n.e = ned[1] + n.d = ned[2] + return n + +cdef Geodetic list2geodetic(geodetic): + cdef Geodetic g + g.lat = geodetic[0] + g.lon = geodetic[1] + g.alt = geodetic[2] + return g + +def euler2quat_single(euler): + cdef Vector3 e = Vector3(euler[0], euler[1], euler[2]) + cdef Quaternion q = euler2quat_c(e) + return [q.w(), q.x(), q.y(), q.z()] + +def quat2euler_single(quat): + cdef Quaternion q = Quaternion(quat[0], quat[1], quat[2], quat[3]) + cdef Vector3 e = quat2euler_c(q); + return [e(0), e(1), e(2)] + +def quat2rot_single(quat): + cdef Quaternion q = Quaternion(quat[0], quat[1], quat[2], quat[3]) + cdef Matrix3 r = quat2rot_c(q) + return matrix2numpy(r) + +def rot2quat_single(rot): + cdef Matrix3 r = numpy2matrix(np.asfortranarray(rot, dtype=np.double)) + cdef Quaternion q = rot2quat_c(r) + return [q.w(), q.x(), q.y(), q.z()] + +def euler2rot_single(euler): + cdef Vector3 e = Vector3(euler[0], euler[1], euler[2]) + cdef Matrix3 r = euler2rot_c(e) + return matrix2numpy(r) + +def rot2euler_single(rot): + cdef Matrix3 r = numpy2matrix(np.asfortranarray(rot, dtype=np.double)) + cdef Vector3 e = rot2euler_c(r) + return [e(0), e(1), e(2)] + +def rot_matrix(roll, pitch, yaw): + return matrix2numpy(rot_matrix_c(roll, pitch, yaw)) + +def ecef_euler_from_ned_single(ecef_init, ned_pose): + cdef ECEF init = list2ecef(ecef_init) + cdef Vector3 pose = Vector3(ned_pose[0], ned_pose[1], ned_pose[2]) + + cdef Vector3 e = ecef_euler_from_ned_c(init, pose) + return [e(0), e(1), e(2)] + +def ned_euler_from_ecef_single(ecef_init, ecef_pose): + cdef ECEF init = list2ecef(ecef_init) + cdef Vector3 pose = Vector3(ecef_pose[0], ecef_pose[1], ecef_pose[2]) + + cdef Vector3 e = ned_euler_from_ecef_c(init, pose) + return [e(0), e(1), e(2)] + +def geodetic2ecef_single(geodetic): + cdef Geodetic g = list2geodetic(geodetic) + cdef ECEF e = geodetic2ecef_c(g) + return [e.x, e.y, e.z] + +def ecef2geodetic_single(ecef): + cdef ECEF e = list2ecef(ecef) + cdef Geodetic g = ecef2geodetic_c(e) + return [g.lat, g.lon, g.alt] + + +cdef class LocalCoord: + cdef LocalCoord_c * lc + + def __init__(self, geodetic=None, ecef=None): + assert (geodetic is not None) or (ecef is not None) + if geodetic is not None: + self.lc = new LocalCoord_c(list2geodetic(geodetic)) + elif ecef is not None: + self.lc = new LocalCoord_c(list2ecef(ecef)) + + @property + def ned2ecef_matrix(self): + return matrix2numpy(self.lc.ned2ecef_matrix) + + @property + def ecef2ned_matrix(self): + return matrix2numpy(self.lc.ecef2ned_matrix) + + @property + def ned_from_ecef_matrix(self): + return self.ecef2ned_matrix + + @property + def ecef_from_ned_matrix(self): + return self.ned2ecef_matrix + + @classmethod + def from_geodetic(cls, geodetic): + return cls(geodetic=geodetic) + + @classmethod + def from_ecef(cls, ecef): + return cls(ecef=ecef) + + def ecef2ned_single(self, ecef): + assert self.lc + cdef ECEF e = list2ecef(ecef) + cdef NED n = self.lc.ecef2ned(e) + return [n.n, n.e, n.d] + + def ned2ecef_single(self, ned): + assert self.lc + cdef NED n = list2ned(ned) + cdef ECEF e = self.lc.ned2ecef(n) + return [e.x, e.y, e.z] + + def geodetic2ned_single(self, geodetic): + assert self.lc + cdef Geodetic g = list2geodetic(geodetic) + cdef NED n = self.lc.geodetic2ned(g) + return [n.n, n.e, n.d] + + def ned2geodetic_single(self, ned): + assert self.lc + cdef NED n = list2ned(ned) + cdef Geodetic g = self.lc.ned2geodetic(n) + return [g.lat, g.lon, g.alt] + + def __dealloc__(self): + del self.lc diff --git a/common/vin.py b/common/vin.py deleted file mode 100755 index 989aa0fa13f5bb..00000000000000 --- a/common/vin.py +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/env python -import selfdrive.messaging as messaging -from selfdrive.boardd.boardd import can_list_to_can_capnp - -VIN_UNKNOWN = "0" * 17 - -# 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 - - -class VinQuery(): - def __init__(self, bus): - self.bus = bus - # 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 - self.query_ext_msgs = [[0x18DB33F1, 0, '\x02\x09\x02'.ljust(8, "\x00"), bus], - [0x18DA10f1, 0, '\x30'.ljust(8, "\x00"), bus]] - self.query_nor_msgs = [[0x7df, 0, '\x02\x09\x02'.ljust(8, "\x00"), bus], - [0x7e0, 0, '\x30'.ljust(8, "\x00"), bus]] - - self.cnts = [1, 2] # number of messages to wait for at each iteration - self.step = 0 - self.cnt = 0 - self.responded = False - self.never_responded = True - self.dat = [] - self.vin = VIN_UNKNOWN - - def check_response(self, msg): - # have we got a VIN query response? - if msg.src == self.bus and msg.address in [0x18daf110, 0x7e8]: - self.never_responded = False - # basic sanity checks on ISO-TP response - if is_vin_response_valid(msg.dat, self.step, self.cnt): - self.dat += msg.dat[2:] if self.step == 0 else msg.dat[1:] - self.cnt += 1 - if self.cnt == self.cnts[self.step]: - self.responded = True - self.step += 1 - - def send_query(self, sendcan): - # keep sending VIN qury if ECU isn't responsing. - # sendcan is probably not ready due to the zmq slow joiner syndrome - if self.never_responded or (self.responded and self.step < len(self.cnts)): - sendcan.send(can_list_to_can_capnp([self.query_ext_msgs[self.step]], msgtype='sendcan')) - sendcan.send(can_list_to_can_capnp([self.query_nor_msgs[self.step]], msgtype='sendcan')) - self.responded = False - self.cnt = 0 - - def get_vin(self): - # only report vin if procedure is finished - if self.step == len(self.cnts) and self.cnt == self.cnts[-1]: - self.vin = "".join(self.dat[3:]) - return self.vin - - -def get_vin(logcan, sendcan, bus, query_time=1.): - vin_query = VinQuery(bus) - frame = 0 - - # 1s max of VIN query time - while frame < query_time * 100: - a = messaging.recv_one(logcan) - - for can in a.can: - vin_query.check_response(can) - - vin_query.send_query(sendcan) - frame += 1 - - return vin_query.get_vin() - - -if __name__ == "__main__": - from selfdrive.services import service_list - logcan = messaging.sub_sock(service_list['can'].port) - sendcan = messaging.pub_sock(service_list['sendcan'].port) - print get_vin(logcan, sendcan, 0) diff --git a/common/xattr.py b/common/xattr.py new file mode 100644 index 00000000000000..fa61b9e0fc5635 --- /dev/null +++ b/common/xattr.py @@ -0,0 +1,45 @@ +import os +from cffi import FFI + +# Workaround for the EON/termux build of Python having os.*xattr removed. +ffi = FFI() +ffi.cdef(""" +int setxattr(const char *path, const char *name, const void *value, size_t size, int flags); +ssize_t getxattr(const char *path, const char *name, void *value, size_t size); +ssize_t listxattr(const char *path, char *list, size_t size); +int removexattr(const char *path, const char *name); +""") +libc = ffi.dlopen(None) + +def setxattr(path, name, value, flags=0): + path = path.encode() + name = name.encode() + if libc.setxattr(path, name, value, len(value), flags) == -1: + raise OSError(ffi.errno, f"{os.strerror(ffi.errno)}: setxattr({path}, {name}, {value}, {flags})") + +def getxattr(path, name, size=128): + path = path.encode() + name = name.encode() + value = ffi.new(f"char[{size}]") + l = libc.getxattr(path, name, value, size) + if l == -1: + # errno 61 means attribute hasn't been set + if ffi.errno == 61: + return None + raise OSError(ffi.errno, f"{os.strerror(ffi.errno)}: getxattr({path}, {name}, {size})") + return ffi.buffer(value)[:l] + +def listxattr(path, size=128): + path = path.encode() + attrs = ffi.new(f"char[{size}]") + l = libc.listxattr(path, attrs, size) + if l == -1: + raise OSError(ffi.errno, f"{os.strerror(ffi.errno)}: listxattr({path}, {size})") + # attrs is b'\0' delimited values (so chop off trailing empty item) + return [a.decode() for a in ffi.buffer(attrs)[:l].split(b"\0")[0:-1]] + +def removexattr(path, name): + path = path.encode() + name = name.encode() + if libc.removexattr(path, name) == -1: + raise OSError(ffi.errno, f"{os.strerror(ffi.errno)}: removexattr({path}, {name})") diff --git a/installer/updater/Makefile b/installer/updater/Makefile index d252fc2aa050c7..54bd7c9df430f6 100644 --- a/installer/updater/Makefile +++ b/installer/updater/Makefile @@ -10,7 +10,7 @@ WARN_FLAGS = -Werror=implicit-function-declaration \ -Werror=format-extra-args CFLAGS = -std=gnu11 -g -fPIC -O2 $(WARN_FLAGS) -CXXFLAGS = -std=c++11 -g -fPIC -O2 $(WARN_FLAGS) +CXXFLAGS = -std=c++1z -g -fPIC -O2 $(WARN_FLAGS) CURL_FLAGS = -I$(PHONELIBS)/curl/include CURL_LIBS = $(PHONELIBS)/curl/lib/libcurl.a \ @@ -34,6 +34,7 @@ all: updater OBJS = opensans_regular.ttf.o \ opensans_semibold.ttf.o \ opensans_bold.ttf.o \ + ../../selfdrive/common/util.o \ ../../selfdrive/common/touch.o \ ../../selfdrive/common/framebuffer.o \ $(PHONELIBS)/json11/json11.o \ diff --git a/installer/updater/update.json b/installer/updater/update.json index 2715fcaccc0b06..ef02bfae8b5688 100644 --- a/installer/updater/update.json +++ b/installer/updater/update.json @@ -1,7 +1,7 @@ { - "ota_url": "https://commadist.azureedge.net/neosupdate/ota-signed-4db25072191d24e204a816d73ac9e8c727822a26ed3baf01ecae18167fa2eb11.zip", - "ota_hash": "4db25072191d24e204a816d73ac9e8c727822a26ed3baf01ecae18167fa2eb11", - "recovery_url": "https://commadist.azureedge.net/neosupdate/recovery-31ef14206d3102edf18fb7417ef32ba2d9f37dd2f4443e234c374a70d1bf4662.img", - "recovery_len": 15136044, - "recovery_hash": "31ef14206d3102edf18fb7417ef32ba2d9f37dd2f4443e234c374a70d1bf4662" + "ota_url": "https://commadist.azureedge.net/neosupdate/ota-signed-e85f507777cb6b22f88ba1c8be6bbaa2630c484b971344b645fca2d1c461cd47.zip", + "ota_hash": "e85f507777cb6b22f88ba1c8be6bbaa2630c484b971344b645fca2d1c461cd47", + "recovery_url": "https://commadist.azureedge.net/neosupdate/recovery-db31ffe79dfd60be966fba6d1525a5081a920062b883644dc8f5734bcc6806bb.img", + "recovery_len": 15926572, + "recovery_hash": "db31ffe79dfd60be966fba6d1525a5081a920062b883644dc8f5734bcc6806bb" } diff --git a/installer/updater/updater b/installer/updater/updater index 51886bd3341307..729de843467163 100755 Binary files a/installer/updater/updater and b/installer/updater/updater differ diff --git a/installer/updater/updater.cc b/installer/updater/updater.cc index 89ac7f63597c03..d737ea248772ca 100644 --- a/installer/updater/updater.cc +++ b/installer/updater/updater.cc @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -33,10 +34,10 @@ #define USER_AGENT "NEOSUpdater-0.2" -#define MANIFEST_URL_EON_STAGING "https://github.com/commaai/eon-neos/raw/master/update.staging.json" -#define MANIFEST_URL_EON_LOCAL "http://192.168.5.1:8000/neosupdate/update.local.json" -#define MANIFEST_URL_EON "https://github.com/commaai/eon-neos/raw/master/update.json" -const char *manifest_url = MANIFEST_URL_EON; +#define MANIFEST_URL_NEOS_STAGING "https://github.com/commaai/eon-neos/raw/master/update.staging.json" +#define MANIFEST_URL_NEOS_LOCAL "http://192.168.5.1:8000/neosupdate/update.local.json" +#define MANIFEST_URL_NEOS "https://github.com/commaai/eon-neos/raw/master/update.json" +const char *manifest_url = MANIFEST_URL_NEOS; #define RECOVERY_DEV "/dev/block/bootdevice/by-name/recovery" #define RECOVERY_COMMAND "/cache/recovery/command" @@ -96,7 +97,7 @@ std::string download_string(CURL *curl, std::string url) { curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); - curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); + curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 0); curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT); curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); curl_easy_setopt(curl, CURLOPT_RESUME_FROM, 0); @@ -117,11 +118,19 @@ size_t download_file_write(void *ptr, size_t size, size_t nmeb, void *up) { return fwrite(ptr, size, nmeb, (FILE*)up); } -bool check_battery() { +int battery_capacity() { std::string bat_cap_s = util::read_file("/sys/class/power_supply/battery/capacity"); - int bat_cap = atoi(bat_cap_s.c_str()); + return atoi(bat_cap_s.c_str()); +} + +int battery_current() { std::string current_now_s = util::read_file("/sys/class/power_supply/battery/current_now"); - int current_now = atoi(current_now_s.c_str()); + return atoi(current_now_s.c_str()); +} + +bool check_battery() { + int bat_cap = battery_capacity(); + int current_now = battery_current(); return bat_cap > 35 || (current_now < 0 && bat_cap > 10); } @@ -141,14 +150,38 @@ static void start_settings_activity(const char* name) { system(launch_cmd); } +bool is_settings_active() { + FILE *fp; + char sys_output[4096]; + + fp = popen("/bin/dumpsys window windows", "r"); + if (fp == NULL) { + return false; + } + + bool active = false; + while (fgets(sys_output, sizeof(sys_output), fp) != NULL) { + if (strstr(sys_output, "mCurrentFocus=null") != NULL) { + break; + } + + if (strstr(sys_output, "mCurrentFocus=Window") != NULL) { + active = true; + break; + } + } + + pclose(fp); + + return active; +} + struct Updater { bool do_exit = false; TouchState touch; int fb_w, fb_h; - EGLDisplay display; - EGLSurface surface; FramebufferState *fb = NULL; NVGcontext *vg = NULL; @@ -160,9 +193,9 @@ struct Updater { std::mutex lock; - // i hate state machines give me coroutines already enum UpdateState { CONFIRMATION, + LOW_BATTERY, RUNNING, ERROR, }; @@ -173,19 +206,33 @@ struct Updater { std::string error_text; + std::string low_battery_text; + std::string low_battery_title; + std::string low_battery_context; + std::string battery_cap_text; + int min_battery_cap = 35; + // button int b_x, b_w, b_y, b_h; int balt_x; + // download stage writes these for the installation stage + int recovery_len; + std::string recovery_hash; + std::string recovery_fn; + std::string ota_fn; + CURL *curl = NULL; - Updater() { + void ui_init() { touch_init(&touch); fb = framebuffer_init("updater", 0x00001000, false, - &display, &surface, &fb_w, &fb_h); + &fb_w, &fb_h); assert(fb); + framebuffer_set_power(fb, HWC_POWER_MODE_NORMAL); + vg = nvgCreateGLES3(NVG_ANTIALIAS | NVG_STENCIL_STROKES | NVG_DEBUG); assert(vg); @@ -205,7 +252,6 @@ struct Updater { b_h = 220; state = CONFIRMATION; - } int download_file_xferinfo(curl_off_t dltotal, curl_off_t dlno, @@ -238,7 +284,7 @@ struct Updater { curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); - curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); + curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 0); curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT); curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); curl_easy_setopt(curl, CURLOPT_RESUME_FROM, resume_from); @@ -296,86 +342,88 @@ struct Updater { state = ERROR; } - std::string stage_download(std::string url, std::string hash, std::string name) { + void set_battery_low() { + std::lock_guard guard(lock); + state = LOW_BATTERY; + } + + void set_running() { + std::lock_guard guard(lock); + state = RUNNING; + } + + std::string download(std::string url, std::string hash, std::string name) { std::string out_fn = UPDATE_DIR "/" + util::base_name(url); - set_progress("Downloading " + name + "..."); - bool r = download_file(url, out_fn); - if (!r) { - set_error("failed to download " + name); - return ""; + // start or resume downloading if hash doesn't match + std::string fn_hash = sha256_file(out_fn); + if (hash.compare(fn_hash) != 0) { + set_progress("Downloading " + name + "..."); + bool r = download_file(url, out_fn); + if (!r) { + set_error("failed to download " + name); + unlink(out_fn.c_str()); + return ""; + } + fn_hash = sha256_file(out_fn); } set_progress("Verifying " + name + "..."); - std::string fn_hash = sha256_file(out_fn); printf("got %s hash: %s\n", name.c_str(), hash.c_str()); if (fn_hash != hash) { set_error(name + " was corrupt"); unlink(out_fn.c_str()); return ""; } - return out_fn; } - void run_stages() { + bool download_stage() { curl = curl_easy_init(); assert(curl); - if (!check_battery()) { - set_error("Please plug power in to your EON and wait for charge"); - return; - } + // ** quick checks before download ** if (!check_space()) { set_error("2GB of free space required to update"); - return; + return false; } mkdir(UPDATE_DIR, 0777); - const int EON = (access("/EON", F_OK) != -1); - set_progress("Finding latest version..."); - std::string manifest_s; - if (EON) { - manifest_s = download_string(curl, manifest_url); - } else { - // don't update NEO - exit(0); - } - + std::string manifest_s = download_string(curl, manifest_url); printf("manifest: %s\n", manifest_s.c_str()); std::string err; auto manifest = json11::Json::parse(manifest_s, err); if (manifest.is_null() || !err.empty()) { set_error("failed to load update manifest"); - return; + return false; } std::string ota_url = manifest["ota_url"].string_value(); std::string ota_hash = manifest["ota_hash"].string_value(); std::string recovery_url = manifest["recovery_url"].string_value(); - std::string recovery_hash = manifest["recovery_hash"].string_value(); - int recovery_len = manifest["recovery_len"].int_value(); + recovery_hash = manifest["recovery_hash"].string_value(); + recovery_len = manifest["recovery_len"].int_value(); // std::string installer_url = manifest["installer_url"].string_value(); // std::string installer_hash = manifest["installer_hash"].string_value(); if (ota_url.empty() || ota_hash.empty()) { set_error("invalid update manifest"); - return; + return false; } - // std::string installer_fn = stage_download(installer_url, installer_hash, "installer"); + // std::string installer_fn = download(installer_url, installer_hash, "installer"); // if (installer_fn.empty()) { // //error'd // return; // } - std::string recovery_fn; + // ** handle recovery download ** if (recovery_url.empty() || recovery_hash.empty() || recovery_len == 0) { set_progress("Skipping recovery flash..."); } else { @@ -385,25 +433,61 @@ struct Updater { printf("existing recovery hash: %s\n", existing_recovery_hash.c_str()); if (existing_recovery_hash != recovery_hash) { - recovery_fn = stage_download(recovery_url, recovery_hash, "recovery"); + recovery_fn = download(recovery_url, recovery_hash, "recovery"); if (recovery_fn.empty()) { // error'd - return; + return false; } } } - std::string ota_fn = stage_download(ota_url, ota_hash, "update"); + // ** handle ota download ** + ota_fn = download(ota_url, ota_hash, "update"); if (ota_fn.empty()) { //error'd - return; + return false; } + // download sucessful + return true; + } + + // thread that handles downloading and installing the update + void run_stages() { + printf("run_stages start\n"); + + + // ** download update ** + if (!check_battery()) { - set_error("must have at least 35% battery to update"); + set_battery_low(); + int battery_cap = battery_capacity(); + while(battery_cap < min_battery_cap) { + battery_cap = battery_capacity(); + battery_cap_text = std::to_string(battery_cap); + usleep(1000000); + } + set_running(); + } + + bool sucess = download_stage(); + if (!sucess) { return; } + // ** install update ** + + if (!check_battery()) { + set_battery_low(); + int battery_cap = battery_capacity(); + while(battery_cap < min_battery_cap) { + battery_cap = battery_capacity(); + battery_cap_text = std::to_string(battery_cap); + usleep(1000000); + } + set_running(); + } + if (!recovery_fn.empty()) { // flash recovery set_progress("Flashing recovery..."); @@ -526,6 +610,27 @@ struct Updater { } } + void draw_battery_screen() { + low_battery_title = "Low Battery"; + low_battery_text = "Please connect EON to your charger. Update will continue once EON battery reaches 35%."; + low_battery_context = "Current battery charge: " + battery_cap_text + "%"; + + nvgFillColor(vg, nvgRGBA(255,255,255,255)); + nvgTextAlign(vg, NVG_ALIGN_CENTER | NVG_ALIGN_BASELINE); + + nvgFontFace(vg, "opensans_bold"); + nvgFontSize(vg, 120.0f); + nvgTextBox(vg, 110, 220, fb_w-240, low_battery_title.c_str(), NULL); + + nvgFontFace(vg, "opensans_regular"); + nvgFontSize(vg, 86.0f); + nvgTextBox(vg, 130, 380, fb_w-260, low_battery_text.c_str(), NULL); + + nvgFontFace(vg, "opensans_bold"); + nvgFontSize(vg, 86.0f); + nvgTextBox(vg, 130, 700, fb_w-260, low_battery_context.c_str(), NULL); + } + void draw_progress_screen() { // draw progress message nvgFontSize(vg, 64.0f); @@ -545,7 +650,7 @@ struct Updater { int powerprompt_y = 312; nvgFontFace(vg, "opensans_regular"); nvgFontSize(vg, 64.0f); - nvgText(vg, fb_w/2, 740, "Ensure EON is connected to power.", NULL); + nvgText(vg, fb_w/2, 740, "Ensure your device remains connected to a power source.", NULL); NVGpaint paint = nvgBoxGradient( vg, progress_x + 1, progress_y + 1, @@ -584,11 +689,14 @@ struct Updater { "Continue", "Connect to WiFi"); break; + case LOW_BATTERY: + draw_battery_screen(); + break; case RUNNING: draw_progress_screen(); break; case ERROR: - draw_ack_screen("There was an error.", ("ERROR: " + error_text + "\n\nYou will need to retry").c_str(), NULL, "exit"); + draw_ack_screen("There was an error", (error_text).c_str(), NULL, "Reboot"); break; } @@ -598,9 +706,7 @@ struct Updater { void ui_update() { std::lock_guard guard(lock); - switch (state) { - case ERROR: - case CONFIRMATION: { + if (state == ERROR || state == CONFIRMATION) { int touch_x = -1, touch_y = -1; int res = touch_poll(&touch, &touch_x, &touch_y, 0); if (res == 1 && !is_settings_active()) { @@ -619,13 +725,11 @@ struct Updater { } } } - default: - break; - } } - void go() { + ui_init(); + while (!do_exit) { ui_update(); @@ -647,7 +751,8 @@ struct Updater { glDisable(GL_BLEND); - eglSwapBuffers(display, surface); + framebuffer_swap(fb); + assert(glGetError() == GL_NO_ERROR); // no simple way to do 30fps vsync with surfaceflinger... @@ -658,51 +763,37 @@ struct Updater { update_thread_handle.join(); } + // reboot system("service call power 16 i32 0 i32 0 i32 1"); } - bool is_settings_active() { - FILE *fp; - char sys_output[4096]; - - fp = popen("/bin/dumpsys window windows", "r"); - if (fp == NULL) { - return false; - } - - bool active = false; - while (fgets(sys_output, sizeof(sys_output), fp) != NULL) { - if (strstr(sys_output, "mCurrentFocus=null") != NULL) { - break; - } - - if (strstr(sys_output, "mCurrentFocus=Window") != NULL) { - active = true; - break; - } - } - - pclose(fp); - - return active; - } - }; } + int main(int argc, char *argv[]) { + bool background_cache = false; if (argc > 1) { if (strcmp(argv[1], "local") == 0) { - manifest_url = MANIFEST_URL_EON_LOCAL; + manifest_url = MANIFEST_URL_NEOS_LOCAL; } else if (strcmp(argv[1], "staging") == 0) { - manifest_url = MANIFEST_URL_EON_STAGING; + manifest_url = MANIFEST_URL_NEOS_STAGING; + } else if (strcmp(argv[1], "bgcache") == 0) { + manifest_url = argv[2]; + background_cache = true; } else { manifest_url = argv[1]; } } + printf("updating from %s\n", manifest_url); Updater updater; - updater.go(); - return 0; + int err = 0; + if (background_cache) { + err = !updater.download_stage(); + } else { + updater.go(); + } + return err; } diff --git a/launch.sh b/launch.sh new file mode 100755 index 00000000000000..eeebfc9eb0eb1b --- /dev/null +++ b/launch.sh @@ -0,0 +1,4 @@ +#!/usr/bin/bash + +export PASSIVE="0" +exec ./launch_chffrplus.sh diff --git a/launch_chffrplus.sh b/launch_chffrplus.sh index f3e9ed12ecf7b7..8977b46b9a977b 100755 --- a/launch_chffrplus.sh +++ b/launch_chffrplus.sh @@ -1,46 +1,187 @@ #!/usr/bin/bash -export OMP_NUM_THREADS=1 -export MKL_NUM_THREADS=1 -export NUMEXPR_NUM_THREADS=1 -export OPENBLAS_NUM_THREADS=1 -export VECLIB_MAXIMUM_THREADS=1 - -if [ -z "$PASSIVE" ]; then - export PASSIVE="1" +if [ -z "$BASEDIR" ]; then + BASEDIR="/data/openpilot" fi +source "$BASEDIR/launch_env.sh" + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" + . /data/openpilot/selfdrive/car/tesla/readconfig.sh +function tici_init { + sudo su -c 'echo "performance" > /sys/class/devfreq/soc:qcom,memlat-cpu0/governor' + sudo su -c 'echo "performance" > /sys/class/devfreq/soc:qcom,memlat-cpu4/governor' +} + +function two_init { + # Wifi scan + wpa_cli IFNAME=wlan0 SCAN + + # *** shield cores 2-3 *** + + # android gets two cores + echo 0-1 > /dev/cpuset/background/cpus + echo 0-1 > /dev/cpuset/system-background/cpus + echo 0-1 > /dev/cpuset/foreground/cpus + echo 0-1 > /dev/cpuset/foreground/boost/cpus + echo 0-1 > /dev/cpuset/android/cpus + + # openpilot gets all the cores + echo 0-3 > /dev/cpuset/app/cpus + + # mask off 2-3 from RPS and XPS - Receive/Transmit Packet Steering + echo 3 | tee /sys/class/net/*/queues/*/rps_cpus + echo 3 | tee /sys/class/net/*/queues/*/xps_cpus + + # *** set up governors *** + + # +50mW offroad, +500mW onroad for 30% more RAM bandwidth + echo "performance" > /sys/class/devfreq/soc:qcom,cpubw/governor + echo 1056000 > /sys/class/devfreq/soc:qcom,m4m/max_freq + echo "performance" > /sys/class/devfreq/soc:qcom,m4m/governor + + # unclear if these help, but they don't seem to hurt + echo "performance" > /sys/class/devfreq/soc:qcom,memlat-cpu0/governor + echo "performance" > /sys/class/devfreq/soc:qcom,memlat-cpu2/governor + + # GPU + echo "performance" > /sys/class/devfreq/b00000.qcom,kgsl-3d0/governor + + # /sys/class/devfreq/soc:qcom,mincpubw is the only one left at "powersave" + # it seems to gain nothing but a wasted 500mW + + # *** set up IRQ affinities *** + + # Collect RIL and other possibly long-running I/O interrupts onto CPU 1 + echo 1 > /proc/irq/78/smp_affinity_list # qcom,smd-modem (LTE radio) + echo 1 > /proc/irq/33/smp_affinity_list # ufshcd (flash storage) + echo 1 > /proc/irq/35/smp_affinity_list # wifi (wlan_pci) + echo 1 > /proc/irq/6/smp_affinity_list # MDSS + + # USB traffic needs realtime handling on cpu 3 + [ -d "/proc/irq/733" ] && echo 3 > /proc/irq/733/smp_affinity_list # USB for LeEco + [ -d "/proc/irq/736" ] && echo 3 > /proc/irq/736/smp_affinity_list # USB for OP3T + + # GPU and camera get cpu 2 + CAM_IRQS="177 178 179 180 181 182 183 184 185 186 192" + for irq in $CAM_IRQS; do + echo 2 > /proc/irq/$irq/smp_affinity_list + done + echo 2 > /proc/irq/193/smp_affinity_list # GPU + + # give GPU threads RT priority + for pid in $(pgrep "kgsl"); do + chrt -f -p 52 $pid + done + + # the flippening! + LD_LIBRARY_PATH="" content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1 + + # disable bluetooth + service call bluetooth_manager 8 + + # Check for NEOS update + if [ $(< /VERSION) != "$REQUIRED_NEOS_VERSION" ]; then + if [ -f "$DIR/scripts/continue.sh" ]; then + cp "$DIR/scripts/continue.sh" "/data/data/com.termux/files/continue.sh" + fi + + if [ ! -f "$BASEDIR/prebuilt" ]; then + # Clean old build products, but preserve the scons cache + cd $DIR + scons --clean + git clean -xdf + git submodule foreach --recursive git clean -xdf + fi + + "$DIR/installer/updater/updater" "file://$DIR/installer/updater/update.json" + fi + + # One-time fix for a subset of OP3T with gyro orientation offsets. + # Remove and regenerate qcom sensor registry. Only done on OP3T mainboards. + # Performed exactly once. The old registry is preserved just-in-case, and + # doubles as a flag denoting we've already done the reset. + if ! $(grep -q "letv" /proc/cmdline) && [ ! -f "/persist/comma/op3t-sns-reg-backup" ]; then + echo "Performing OP3T sensor registry reset" + mv /persist/sensors/sns.reg /persist/comma/op3t-sns-reg-backup && + rm -f /persist/sensors/sensors_settings /persist/sensors/error_log /persist/sensors/gyro_sensitity_cal && + echo "restart" > /sys/kernel/debug/msm_subsys/slpi && + sleep 5 # Give Android sensor subsystem a moment to recover + fi +} function launch { - # apply update - if [ $do_auto_update == "True" ]; then - if [ "$(git rev-parse HEAD)" != "$(git rev-parse @{u})" ]; then - git reset --hard @{u} && - git clean -xdf && - - # Touch all files on release2 after checkout to prevent rebuild - BRANCH=$(git rev-parse --abbrev-ref HEAD) - if [[ "$BRANCH" == "release2" ]]; then - touch ** - fi + # Remove orphaned git lock if it exists on boot + [ -f "$DIR/.git/index.lock" ] && rm -f $DIR/.git/index.lock - exec "${BASH_SOURCE[0]}" + #BB here was to prevent the autoupdate; need to find another way + # # apply update + # if [ $do_auto_update == "True" ]; then + # if [ "$(git rev-parse HEAD)" != "$(git rev-parse @{u})" ]; then + # git reset --hard @{u} && + # git clean -xdf && + + # # Touch all files on release2 after checkout to prevent rebuild + # BRANCH=$(git rev-parse --abbrev-ref HEAD) + # if [[ "$BRANCH" == "release2" ]]; then + # touch ** + # fi + + # Check to see if there's a valid overlay-based update available. Conditions + # are as follows: + # + # 1. The BASEDIR init file has to exist, with a newer modtime than anything in + # the BASEDIR Git repo. This checks for local development work or the user + # switching branches/forks, which should not be overwritten. + # 2. The FINALIZED consistent file has to exist, indicating there's an update + # that completed successfully and synced to disk. + + if [ $do_auto_update == "True" ] && [ -f "${BASEDIR}/.overlay_init" ]; then + find ${BASEDIR}/.git -newer ${BASEDIR}/.overlay_init | grep -q '.' 2> /dev/null + if [ $? -eq 0 ]; then + echo "${BASEDIR} has been modified, skipping overlay update installation" + else + if [ -f "${STAGING_ROOT}/finalized/.overlay_consistent" ]; then + if [ ! -d /data/safe_staging/old_openpilot ]; then + echo "Valid overlay update found, installing" + LAUNCHER_LOCATION="${BASH_SOURCE[0]}" + + mv $BASEDIR /data/safe_staging/old_openpilot + mv "${STAGING_ROOT}/finalized" $BASEDIR + cd $BASEDIR + + # Partial mitigation for symlink-related filesystem corruption + # Ensure all files match the repo versions after update + git reset --hard + git submodule foreach --recursive git reset --hard + + echo "Restarting launch script ${LAUNCHER_LOCATION}" + unset REQUIRED_NEOS_VERSION + exec "${LAUNCHER_LOCATION}" + else + echo "openpilot backup found, not updating" + # TODO: restore backup? This means the updater didn't start after swapping + fi + fi fi fi - - # no cpu rationing for now - echo 0-3 > /dev/cpuset/background/cpus - echo 0-3 > /dev/cpuset/system-background/cpus - echo 0-3 > /dev/cpuset/foreground/boost/cpus - echo 0-3 > /dev/cpuset/foreground/cpus - echo 0-3 > /dev/cpuset/android/cpus + + # comma two init + if [ -f /EON ]; then + two_init + elif [ -f /TICI ]; then + tici_init + fi # handle pythonpath - ln -s /data/openpilot /data/pythonpath + ln -sfn $(pwd) /data/pythonpath export PYTHONPATH="$PWD" + # write tmux scrollback to a file + tmux capture-pane -pq -S-1000 > /tmp/launch_log + # start manager cd selfdrive ./manager.py diff --git a/launch_env.sh b/launch_env.sh new file mode 100755 index 00000000000000..ca8f4e8a14469b --- /dev/null +++ b/launch_env.sh @@ -0,0 +1,17 @@ +#!/usr/bin/bash + +export OMP_NUM_THREADS=1 +export MKL_NUM_THREADS=1 +export NUMEXPR_NUM_THREADS=1 +export OPENBLAS_NUM_THREADS=1 +export VECLIB_MAXIMUM_THREADS=1 + +if [ -z "$REQUIRED_NEOS_VERSION" ]; then + export REQUIRED_NEOS_VERSION="15-1" +fi + +if [ -z "$PASSIVE" ]; then + export PASSIVE="1" +fi + +export STAGING_ROOT="/data/safe_staging" diff --git a/models/dmonitoring_model_q.dlc b/models/dmonitoring_model_q.dlc new file mode 100644 index 00000000000000..9935584bf4c00a Binary files /dev/null and b/models/dmonitoring_model_q.dlc differ diff --git a/models/driving_bigmodel.dlc b/models/driving_bigmodel.dlc deleted file mode 100644 index 95c6ec232d36c1..00000000000000 Binary files a/models/driving_bigmodel.dlc and /dev/null differ diff --git a/models/driving_model.dlc b/models/driving_model.dlc deleted file mode 100644 index 79181185f7549e..00000000000000 Binary files a/models/driving_model.dlc and /dev/null differ diff --git a/models/monitoring_model.dlc b/models/monitoring_model.dlc deleted file mode 100644 index f7496fb925d873..00000000000000 Binary files a/models/monitoring_model.dlc and /dev/null differ diff --git a/models/posenet.dlc b/models/posenet.dlc deleted file mode 100644 index 58dee250f73032..00000000000000 Binary files a/models/posenet.dlc and /dev/null differ diff --git a/models/supercombo.dlc b/models/supercombo.dlc new file mode 100644 index 00000000000000..faef0b3d16b326 Binary files /dev/null and b/models/supercombo.dlc differ diff --git a/opendbc/.gitignore b/opendbc/.gitignore index d18402de39f8b0..bf8570d8b06488 100644 --- a/opendbc/.gitignore +++ b/opendbc/.gitignore @@ -1,2 +1,17 @@ +.mypy_cache/ *.pyc +*.os +*.o +*.tmp +*.dylib .*.swp +.DS_Store +.sconsign.dblite + +can/*.so +can/build/ +can/obj/ +can/packer_pyx.cpp +can/parser_pyx.cpp +can/packer_pyx.html +can/parser_pyx.html diff --git a/opendbc/ESR.dbc b/opendbc/ESR.dbc deleted file mode 100644 index e3837a68b2ff5a..00000000000000 --- a/opendbc/ESR.dbc +++ /dev/null @@ -1,1080 +0,0 @@ -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_: Gateway ESR -VAL_TABLE_ ForwardReverse 1 "Reverse" 0 "Forward" ; -VAL_TABLE_ LeftRight 1 "Right Clockwise" 0 "Left CounterClockwise" ; -VAL_TABLE_ ValidInvalid 1 "Valid" 0 "Invalid" ; -VAL_TABLE_ TrueFalse 1 "True" 0 "False" ; - - -BO_ 1343 Target64: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1342 Target63: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1341 Target62: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1340 Target61: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1339 Target60: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1338 Target59: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1337 Target58: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1336 Target57: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1335 Target56: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1334 Target55: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1333 Target54: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1332 Target53: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1331 Target52: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1330 Target51: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1329 Target50: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1328 Target49: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1327 Target48: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1326 Target47: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1325 Target46: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1324 Target45: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1323 Target44: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1322 Target43: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1321 Target42: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1320 Target41: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1319 Target40: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1318 Target39: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1317 Target38: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1316 Target37: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1315 Target36: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1314 Target35: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1313 Target34: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1312 Target33: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1311 Target32: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1310 Target31: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1309 Target30: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1308 Target29: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1307 Target28: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1306 Target27: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1305 Target26: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1304 Target25: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1303 Target24: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1302 Target23: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1301 Target22: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1300 Target21: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1299 Target20: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1298 Target19: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1297 Target18: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1296 Target17: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1295 Target16: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1294 Target15: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1293 Target14: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1292 Target13: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1291 Target12: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1290 Target11: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1289 Target10: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1288 Target9: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1287 Target8: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1285 Target6: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1286 Target7: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1284 Target5: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1283 Target4: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1282 Target3: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1281 Target2: 8 Vector__XXX - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1524 VehicleData3: 8 Gateway - SG_ CAN_RX_YAW_RATE_BIAS_SHIFT : 15|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_RX_WHEELBASE : 55|8@0+ (2,200) [200|710] "cm" Vector__XXX - SG_ CAN_RX_STEERING_GEAR_RATIO : 63|8@0+ (0.125,0) [0|31.875] "" Vector__XXX - SG_ CAN_RX_OVERSTEER_UNDERSTEER : 7|8@0- (1,0) [-128|127] "%" Vector__XXX - SG_ CAN_RX_FUNNEL_OFFSET_RIGHT : 31|8@0- (0.1,0) [-12.8|12.7] "m" Vector__XXX - SG_ CAN_RX_FUNNEL_OFFSET_LEFT : 23|8@0- (0.1,0) [-12.8|12.7] "m" Vector__XXX - SG_ CAN_RX_DISTANCE_REAR_AXLE : 47|8@0+ (2,200) [200|710] "cm" Vector__XXX - SG_ CAN_RX_CW_BLOCKAGE_TRESHOLD : 39|8@0+ (0.0078125,0) [0|1.9921875] "" Vector__XXX - SG_ CAN_RX_BEAMWIDTH_VERT : 14|7@0+ (0.0625,0) [0|7.9375] "deg" Vector__XXX - -BO_ 1523 FactoryAlignment: 8 Gateway - -BO_ 1522 Vehicle_Data2: 8 Gateway - SG_ CAN_RX_WHEEL_SLIP : 41|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_RX_SERV_ALIGN_UPDATES_NEED : 55|8@0+ (1,0) [0|255] "" Vector__XXX - SG_ CAN_RX_SERV_ALIGN_TYPE : 47|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_RX_RADAR_HEIGHT : 38|7@0+ (1,0) [0|127] "cm" Vector__XXX - SG_ CAN_RX_RADAR_FOV_MR : 30|7@0+ (1,0) [0|127] "deg" Vector__XXX - SG_ CAN_RX_RADAR_FOV_LR : 19|5@0+ (1,0) [0|31] "deg" Vector__XXX - SG_ CAN_RX_LONG_ACCEL_VALIDITY : 7|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_RX_LONG_ACCEL : 12|9@0- (0.03125,0) [-8|7.96875] "m/s^2" Vector__XXX - SG_ CAN_RX_LAT_ACCEL_VALIDITY : 6|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_RX_LAT_ACCEL : 5|9@0- (0.03125,0) [-8|7.96875] "m/s^2" Vector__XXX - SG_ CAN_RX_AUTO_ALIGN_DISABLE : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_RX_AUTO_ALIGN_CONVERGED : 42|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_RX_ANGLE_MOUNTING_OFFSET : 63|8@0- (0.0625,0) [-8|7.9375] "deg" Vector__XXX - SG_ CAN_RX_AALIGN_AVG_CTR_TOTAL : 45|3@0+ (250,250) [250|2000] "" Vector__XXX - -BO_ 1512 CIPV_Targets_Etc: 8 ESR - -BO_ 1511 ESR_History_Fault: 8 ESR - -BO_ 1510 ESR_Active_Fault: 8 ESR - -BO_ 1508 AD_Data: 8 ESR - -BO_ 1489 SensorValidation2: 8 ESR - SG_ CAN_TX_VALID_MR_SN : 7|8@0+ (1,0) [0|255] "" Vector__XXX - SG_ CAN_TX_VALID_MR_RANGE_RATE : 31|16@0- (0.0078125,0) [-256|255.9921875] "m/s" Vector__XXX - SG_ CAN_TX_VALID_MR_RANGE : 15|16@0+ (0.0078125,0) [0|511.9921875] "m" Vector__XXX - SG_ CAN_TX_VALID_MR_POWER : 63|8@0- (1,0) [-128|127] "db" Vector__XXX - SG_ CAN_TX_VALID_MR_ANGLE : 40|16@1- (0.0625,0) [-2048|2047.9375] "deg" Vector__XXX - -BO_ 1488 SensorValidation: 8 ESR - SG_ CAN_TX_VALID_LR_SN : 7|8@0+ (1,0) [0|255] "" Vector__XXX - SG_ CAN_TX_VALID_LR_RANGE_RATE : 31|16@0- (0.0078125,0) [-256|255.9921875] "m/s" Vector__XXX - SG_ CAN_TX_VALID_LR_RANGE : 15|16@0+ (0.0078125,0) [0|511.9921875] "m" Vector__XXX - SG_ CAN_TX_VALID_LR_POWER : 63|8@0- (1,0) [-128|127] "db" Vector__XXX - SG_ CAN_TX_VALID_LR_ANGLE : 47|16@0- (0.0625,0) [-2048|2047.9375] "deg" Vector__XXX - -BO_ 1344 Track_Sensor: 1 ESR - SG_ CAN_TX_TRACK_ROLLING_COUNT_2 : 4|1@0+ (1,0) [0|1] "" Vector__XXX - -BO_ 1280 Target1: 8 ESR - SG_ CAN_TX_TRACK_WIDTH : 37|4@0+ (0.5,0) [0|7.5] "" Vector__XXX - SG_ CAN_TX_TRACK_STATUS : 15|3@0+ (1,0) [0|7] "" Vector__XXX - SG_ CAN_TX_TRACK_ROLLING_COUNT : 38|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_RATE : 53|14@0- (0.01,0) [-81.92|81.91] "m/s" Vector__XXX - SG_ CAN_TX_TRACK_RANGE_ACCEL : 33|10@0- (0.05,0) [-25.6|25.55] "m/s^2" Vector__XXX - SG_ CAN_TX_TRACK_RANGE : 18|11@0+ (0.1,0) [0|204.7] "m" Vector__XXX - SG_ CAN_TX_TRACK_ONCOMING : 0|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_MED_RANGE_MODE : 55|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_TRACK_LAT_RATE : 7|6@0- (0.25,0) [-8|7.75] "" Vector__XXX - SG_ CAN_TX_TRACK_GROUPING_CHANGED : 1|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_BRIDGE_OBJECT : 39|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_TRACK_ANGLE : 12|10@0- (0.1,0) [-51.2|51.1] "" Vector__XXX - -BO_ 1265 SensorInput: 8 Gateway - SG_ CAN_RX_USE_ANGLE_MISALIGNMENT : 23|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CAN_RX_SCAN_INDEX_ACK : 7|16@0+ (1,0) [0|65535] "" Vector__XXX - SG_ CAN_RX_LATERAL_MOUNTING_OFFSET : 47|8@0- (0.01563,0) [-2.00064|1.98501] "m" Vector__XXX - SG_ CAN_RX_WIPER_STATUS : 57|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_RX_VOLVO_SHORT_TRACK_ROC : 31|4@0- (500,0) [-4000|3500] "m" Vector__XXX - SG_ CAN_RX_VEHICLE_SPEED_VALIDITY : 61|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_RX_TURN_SIGNAL_STATUS : 63|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_RX_RAW_DATA_ENABLE : 56|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_RX_RADAR_CMD_RADIATE : 55|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_RX_MR_ONLY_TRANSMIT : 25|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CAN_RX_MMR_UPSIDE_DOWN : 60|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_RX_MAXIMUM_TRACKS : 53|6@0+ (1,0) [0|63] "" Vector__XXX - SG_ CAN_RX_LR_ONLY_TRANSMIT : 24|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CAN_RX_HIGH_YAW_ANGLE : 21|6@0- (1,0) [-32|31] "deg" Vector__XXX - SG_ CAN_RX_GROUPING_MODE : 59|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_RX_CLEAR_FAULTS : 22|1@0- (1,0) [0|0] "" Vector__XXX - SG_ CAN_RX_BLOCKAGE_DISABLE : 54|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_RX_ANGLE_MISALIGNMENT : 39|8@0- (0.0625,0) [-8|7.9375] "deg" Vector__XXX - -BO_ 1264 Vehicle_Data: 8 Gateway - SG_ CAN_RX_YAW_RATE_VALIDITY : 31|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CAN_RX_YAW_RATE : 11|12@0- (0.0625,0) [-128|127.9375] "deg/s" Vector__XXX - SG_ CAN_RX_VEHICLE_SPEED_DIRECTION : 12|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_RX_VEHICLE_SPEED : 7|11@0+ (0.0625,0) [0|127.9375] "m/s" Vector__XXX - SG_ CAN_RX_RADIUS_CURVATURE : 29|14@0- (1,0) [-8192|8191] "m" Vector__XXX - SG_ CAN_RX_STEERING_VALIDITY : 47|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_RX_STEERING_ANGLE_SIGN : 46|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_RX_STEERING_ANGLE_RATE_SIGN : 30|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_RX_STEERING_ANGLE_RATE : 50|11@0+ (1,0) [0|2047] "deg/s" Vector__XXX - SG_ CAN_RX_STEERING_ANGLE : 45|11@0+ (1,0) [0|2047] "deg" Vector__XXX - -BO_ 1251 ESR_Output_InPath: 8 ESR - SG_ CAN_TX_PATH_ID_ACC_MOVE : 15|8@0+ (1,0) [0|255] "" Vector__XXX - SG_ CAN_TX_TRUCK_TARGET_DET : 7|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_SIDELOBE_BLOCKATE : 5|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_ROLLING_COUNT_3 : 1|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_PATH_ID_FCW_STAT : 47|8@0+ (1,0) [0|255] "" Vector__XXX - SG_ CAN_TX_PATH_ID_FCW_MOVE : 39|8@0+ (1,0) [0|255] "" Vector__XXX - SG_ CAN_TX_PATH_ID_CMBB_STAT : 31|8@0+ (1,0) [0|255] "" Vector__XXX - SG_ CAN_TX_PATH_ID_CMBB_MOVE : 23|8@0+ (1,0) [0|255] "" Vector__XXX - SG_ CAN_TX_PATH_ID_ACC_STAT : 63|8@0+ (1,0) [0|255] "" Vector__XXX - SG_ CAN_TX_PARTIAL_BLOCKAGE : 4|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_LR_ONLY_GRATING_LOBE_DET : 6|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_LMR_LR_MODE : 3|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_AUTO_ALIGN_ANGLE : 55|8@0- (0.0625,0) [-8|7.9375] "" Vector__XXX - -BO_ 1250 ESR_SW: 8 ESR - SG_ CAN_TX_SW_VERSION_PLD : 63|8@0+ (1,0) [0|255] "" Vector__XXX - SG_ CAN_TX_SW_VERSION_HOST : 15|24@0+ (1,0) [0|16777215] "" Vector__XXX - SG_ CAN_TX_SERIAL_NUM : 39|24@0+ (1,0) [0|16777215] "" Vector__XXX - SG_ CAN_TX_INTERFACE_VERSION : 7|4@0+ (1,0) [0|15] "" Vector__XXX - SG_ CAN_TX_HW_VERSION : 3|4@0+ (1,0) [0|15] "" Vector__XXX - -BO_ 1249 ESR_Status2: 8 ESR - SG_ CAN_TX_YAW_RATE_BIAS : 47|8@0- (0.125,0) [-16|15.875] "" Vector__XXX - SG_ CAN_TX_XCVR_OPERATIONAL : 12|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_VEH_SPD_COMP_FACTOR : 39|6@0- (0.00195,1) [0.9376|1.06045] "" Vector__XXX - SG_ CAN_TX_TEMPERATURE : 31|8@0- (1,0) [-128|127] "degC" Vector__XXX - SG_ CAN_TX_SW_VERSION_DSP : 55|16@0+ (1,0) [0|65535] "" Vector__XXX - SG_ CAN_TX_STEERING_ANGLE_ACK : 10|11@0+ (1,0) [0|2047] "deg" Vector__XXX - SG_ CAN_TX_ROLLING_COUNT_2 : 1|2@0+ (1,0) [0|3] "" Vector__XXX - SG_ CAN_TX_RAW_DATA_MODE : 11|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_RANGE_PERF_ERROR : 14|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_OVERHEAT_ERROR : 15|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_MAXIMUM_TRACKS_ACK : 7|6@0+ (1,1) [1|64] "" Vector__XXX - SG_ CAN_TX_INTERNAL_ERROR : 13|1@0+ (1,0) [0|1] "" Vector__XXX - SG_ CAN_TX_GROUPING_MODE : 33|2@0+ (1,0) [0|3] "" Vector__XXX - -BO_ 1248 ESR_Status: 8 ESR - SG_ CAN_TX_COMM_ERROR : 14|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CAN_TX_RADIUS_CURVATURE_CALC : 13|14@0- (1,0) [-8192|8191] "" Vector__XXX - SG_ CAN_TX_YAW_RATE_CALC : 47|12@0- (0.0625,0) [-128|127.9375] "deg/s" Vector__XXX - SG_ CAN_TX_VEHICLE_SPEED_CALC : 50|11@0+ (0.0625,0) [0|127.9375] "m/s" Vector__XXX - SG_ CAN_TX_DSP_TIMESTAMP : 5|7@0+ (2,0) [0|254] "ms" Vector__XXX - SG_ CAN_TX_SCAN_INDEX : 31|16@0+ (1,0) [0|65535] "" Vector__XXX - SG_ CAN_TX_ROLLING_COUNT_1 : 6|2@1+ (1,0) [0|3] "" Vector__XXX - - - -BA_DEF_ "BusType" STRING ; -BA_DEF_DEF_ "BusType" "CAN"; -VAL_ 1264 CAN_RX_YAW_RATE_VALIDITY 1 "Valid" 0 "Invalid" ; -VAL_ 1264 CAN_RX_VEHICLE_SPEED_DIRECTION 1 "Reverse" 0 "Forward" ; -VAL_ 1264 CAN_RX_STEERING_VALIDITY 1 "True" 0 "False" ; -VAL_ 1264 CAN_RX_STEERING_ANGLE_SIGN 1 "Right Clockwise" 0 "Left CounterClockwise" ; -VAL_ 1264 CAN_RX_STEERING_ANGLE_RATE_SIGN 1 "Right Clockwise" 0 "Left CounterClockwise" ; - diff --git a/opendbc/README.md b/opendbc/README.md deleted file mode 100644 index eec42dfefa7ff2..00000000000000 --- a/opendbc/README.md +++ /dev/null @@ -1,53 +0,0 @@ -opendbc -====== - -The project to democratize access to the decoder ring of your car. - - - -### DBC file basics - -A DBC file encodes, in a humanly readable way, the information needed to understand a vehicle's CAN bus traffic. A vehicle might have multiple CAN buses and every CAN bus is represented by its own dbc file. -Wondering what's the DBC file format? [Here](http://www.socialledge.com/sjsu/index.php?title=DBC_Format) and [Here](https://github.com/stefanhoelzl/CANpy/blob/master/docs/DBC_Specification.md) a couple of good overviews. - -### How to start reverse engineering cars - -[opendbc](https://github.com/commaai/opendbc) is integrated with [cabana](https://community.comma.ai/cabana/). - -Use [panda](https://github.com/commaai/panda) to connect your car to a computer. - -### DBC file preprocessor - -DBC files for different models of the same brand have a lot of overlap. Therefore, we wrote a preprocessor to create DBC files from a brand DBC file and a model specific DBC file. The source DBC files can be found in the generator folder. After changing one of the files run the generator.py script to regenerate the output files. These output files will be placed in the root of the opendbc repository and are suffixed by _generated. - -### Good practices for contributing to opendbc - -- Comments: the best way to store comments is to add them directly to the DBC files. For example: - ``` - CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; - ``` - is a comment that refers to signal `LONG_ACCEL` in message `490`. Using comments is highly recommended, especially for doubts and uncertainties. [cabana](https://community.comma.ai/cabana/) can easily display/add/edit comments to signals and messages. - -- Units: when applicable, it's recommended to convert signals into physical units, by using a proper signal factor. Using a SI unit is preferred, unless a non-SI unit rounds the signal factor much better. -For example: - ``` - SG_ VEHICLE_SPEED : 7|15@0+ (0.00278,0) [0|70] "m/s" PCM - ``` - is better than: - ``` - SG_ VEHICLE_SPEED : 7|15@0+ (0.00620,0) [0|115] "mph" PCM - ``` - However, the cleanest option is really: - ``` - SG_ VEHICLE_SPEED : 7|15@0+ (0.01,0) [0|250] "kph" PCM - ``` - -- Signal's size: always use the smallest amount of bits possible. For example, let's say I'm reverse engineering the gas pedal position and I've determined that it's in a 3 bytes message. For 0% pedal position I read a message value of `0x00 0x00 0x00`, while for 100% of pedal position I read `0x64 0x00 0x00`: clearly, the gas pedal position is within the first byte of the message and I might be tempted to define the signal `GAS_POS` as: - ``` - SG_ GAS_POS : 7|8@0+ (1,0) [0|100] "%" PCM - ``` - However, I can't be sure that the very first bit of the message is referred to the pedal position: I haven't seen it changing! Therefore, a safer way of defining the signal is: - ``` - SG_ GAS_POS : 6|7@0+ (1,0) [0|100] "%" PCM - ``` - which leaves the first bit unallocated. This prevents from very erroneous reading of the gas pedal position, in case the first bit is indeed used for something else. diff --git a/opendbc/acura_ilx_2016_can_generated.dbc b/opendbc/acura_ilx_2016_can_generated.dbc index 75557b1e709f85..361a75ceccc1e4 100644 --- a/opendbc/acura_ilx_2016_can_generated.dbc +++ b/opendbc/acura_ilx_2016_can_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +CM_ "Imported file _comma.dbc starts here"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR @@ -19,7 +19,7 @@ BO_ 513 GAS_SENSOR: 6 INTERCEPTOR 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 _honda_2017.dbc starts here" +CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" @@ -78,6 +78,7 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON @@ -85,6 +86,13 @@ BO_ 420 VSA_STATUS: 8 VSA SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON +BO_ 427 STEER_MOTOR_TORQUE: 3 EPS + SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON + SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON + SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON + BO_ 432 STANDSTILL: 7 VSA SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON @@ -123,7 +131,7 @@ BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM - SG_ AEB : 41|2@0+ (1,0) [0|3] "" XXX + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM @@ -163,7 +171,7 @@ BO_ 780 ACC_HUD: 8 ADAS SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY - SG_ BOH_2 : 35|1@0+ (1,0) [0|1] "" BDY + SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY 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 @@ -173,10 +181,12 @@ BO_ 780 ACC_HUD: 8 ADAS 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_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY + SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY + SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY + SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY + SG_ ICONS : 63|2@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 @@ -226,6 +236,7 @@ BO_ 1029 DOORS_STATUS: 8 BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; @@ -235,11 +246,12 @@ CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; -CM_ "acura_ilx_2016_can.dbc starts here" +CM_ "acura_ilx_2016_can.dbc starts here"; @@ -268,10 +280,11 @@ BO_ 342 STEERING_SENSORS: 6 EPS SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON + SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON + SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON diff --git a/opendbc/acura_rdx_2018_can_generated.dbc b/opendbc/acura_rdx_2018_can_generated.dbc index 0fa62693c2b221..895e11f0071b13 100644 --- a/opendbc/acura_rdx_2018_can_generated.dbc +++ b/opendbc/acura_rdx_2018_can_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +CM_ "Imported file _comma.dbc starts here"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR @@ -19,7 +19,7 @@ BO_ 513 GAS_SENSOR: 6 INTERCEPTOR 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 _honda_2017.dbc starts here" +CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" @@ -78,6 +78,7 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON @@ -85,6 +86,13 @@ BO_ 420 VSA_STATUS: 8 VSA SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON +BO_ 427 STEER_MOTOR_TORQUE: 3 EPS + SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON + SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON + SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON + BO_ 432 STANDSTILL: 7 VSA SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON @@ -123,7 +131,7 @@ BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM - SG_ AEB : 41|2@0+ (1,0) [0|3] "" XXX + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM @@ -163,7 +171,7 @@ BO_ 780 ACC_HUD: 8 ADAS SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY - SG_ BOH_2 : 35|1@0+ (1,0) [0|1] "" BDY + SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY 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 @@ -173,10 +181,12 @@ BO_ 780 ACC_HUD: 8 ADAS 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_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY + SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY + SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY + SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY + SG_ ICONS : 63|2@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 @@ -226,6 +236,7 @@ BO_ 1029 DOORS_STATUS: 8 BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; @@ -235,11 +246,12 @@ CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; -CM_ "acura_rdx_2018_can.dbc starts here" +CM_ "acura_rdx_2018_can.dbc starts here"; @@ -256,8 +268,8 @@ BO_ 392 GEARBOX: 6 XXX SG_ GEAR : 36|5@0+ (1,0) [0|31] "" EON BO_ 399 STEER_STATUS: 6 EPS - SG_ STEER_TORQUE_SENSOR : 7|12@0- (1,0) [-2047.5|2047.5] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON + SG_ STEER_TORQUE_SENSOR : 7|12@0- (-1,0) [-2047.5|2047.5] "tbd" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 35|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 36|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON diff --git a/opendbc/acura_rdx_2020_can_generated.dbc b/opendbc/acura_rdx_2020_can_generated.dbc new file mode 100644 index 00000000000000..d3c8f7c0032286 --- /dev/null +++ b/opendbc/acura_rdx_2020_can_generated.dbc @@ -0,0 +1,433 @@ +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; + + +CM_ "Imported file _bosch_2020.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_ + +BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB + +BO_ 148 KINEMATICS: 8 XXX + SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + +BO_ 228 STEERING_CONTROL: 5 EON + SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS + SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS + SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS + SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS + SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS + SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS + +BO_ 229 BOSCH_SUPPLEMENTAL_1: 8 XXX + SG_ SET_ME_X04 : 0|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X00 : 8|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X80 : 16|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X10 : 24|8@1+ (1,0) [0|255] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + +BO_ 232 BRAKE_HOLD: 7 XXX + SG_ XMISSION_SPEED : 7|14@0- (1,0) [1|0] "" XXX + SG_ COMPUTER_BRAKE : 39|16@0+ (1,0) [0|0] "" XXX + SG_ COMPUTER_BRAKE_REQUEST : 29|1@0+ (1,0) [0|0] "" XXX + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" XXX + +BO_ 342 STEERING_SENSORS: 6 EPS + SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (1,0) [-3000|3000] "deg/s" EON + SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" EON + +BO_ 344 ENGINE_DATA: 8 PCM + SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON + SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON + SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON + SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 380 POWERTRAIN_DATA: 8 PCM + SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON + SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON + SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON + SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "" EON + SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "" EON + SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "" EON + SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "" EON + SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON + SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 399 STEER_STATUS: 7 EPS + SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON + SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON + SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON + SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON + +BO_ 420 VSA_STATUS: 8 VSA + SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON + SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 427 STEER_MOTOR_TORQUE: 3 EPS + SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON + SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON + SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON + +BO_ 450 EPB_STATUS: 8 EPB + SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" EON + SG_ EPB_STATE : 29|2@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + +BO_ 464 WHEEL_SPEEDS: 8 VSA + SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 479 ACC_CONTROL: 8 EON + SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX + SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX + SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX + SG_ ACCEL_COMMAND : 31|11@0- (0.01,0) [0|0] "m/s2" XXX + SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_PREPARE : 43|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 + +BO_ 490 VEHICLE_DYNAMICS: 8 VSA + SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 495 ACC_CONTROL_ON: 8 XXX + SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX + SG_ ZEROS_BOH : 23|8@0+ (1,0) [0|255] "" XXX + SG_ ZEROS_BOH2 : 47|16@0+ (1,0) [0|255] "" XXX + SG_ SET_TO_FF : 15|8@0+ (1,0) [0|255] "" XXX + SG_ SET_TO_3 : 6|7@0+ (1,0) [0|4095] "" XXX + SG_ CONTROL_ON : 7|1@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + +BO_ 545 XXX_16: 6 SCM + SG_ ECON_ON : 23|1@0+ (1,0) [0|1] "" XXX + SG_ DRIVE_MODE : 37|2@0+ (1,0) [0|3] "" XXX + SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" BDY + +BO_ 576 LEFT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 577 LEFT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 579 RIGHT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 580 RIGHT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 582 ADJACENT_LEFT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 583 ADJACENT_LEFT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 585 ADJACENT_RIGHT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 586 ADJACENT_RIGHT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA + SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON + SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" XXX + SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON + SG_ LONG_COUNTER : 55|8@0+ (1,0) [0|255] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + + BO_ 662 SCM_BUTTONS: 4 SCM + SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON + SG_ CRUISE_SETTING : 3|2@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 27|4@0+ (1,0) [0|15] "" EON + +BO_ 773 SEATBELT_STATUS: 7 BDY + SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON + SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON + SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON + +BO_ 777 CAR_SPEED: 8 PCM + SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX + SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX + SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + +BO_ 780 ACC_HUD: 8 ADAS + SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY + SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY + SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY + 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_ 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_ ZEROS_BOH : 7|24@0+ (0.002759506,0) [0|100] "m/s" BDY + SG_ FCM_OFF : 35|1@0+ (1,0) [0|1] "" BDY + SG_ SET_TO_1 : 36|1@0+ (1,0) [0|1] "" XXX + SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY + SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY + 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_X1 : 55|1@0+ (1,0) [0|1] "" XXX + SG_ IMPERIAL_UNIT : 54|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 + +BO_ 804 CRUISE: 8 PCM + SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 806 SCM_FEEDBACK: 8 SCM + SG_ DRIVERS_DOOR_OPEN : 17|1@0+ (1,0) [0|1] "" XXX + SG_ MAIN_ON : 28|1@0+ (1,0) [0|1] "" EON + SG_ RIGHT_BLINKER : 27|1@0+ (1,0) [0|1] "" EON + SG_ LEFT_BLINKER : 26|1@0+ (1,0) [0|1] "" EON + SG_ CMBS_STATES : 22|2@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + +BO_ 829 LKAS_HUD: 5 ADAS + SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY + SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY + SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY + SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY + SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY + SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY + SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY + SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY + SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY + SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY + SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY + SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY + SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY + SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY + SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY + SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY + SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY + SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY + +BO_ 862 CAMERA_MESSAGES: 8 CAM + SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY + SG_ AUTO_HIGHBEAMS_ACTIVE : 53|1@0+ (1,0) [0|1] "" XXX + SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX + SG_ ZEROS_BOH_2 : 51|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + +BO_ 884 STALK_STATUS: 8 XXX + SG_ AUTO_HEADLIGHTS : 46|1@0+ (1,0) [0|1] "" EON + SG_ HIGH_BEAM_HOLD : 47|1@0+ (1,0) [0|1] "" EON + SG_ HIGH_BEAM_FLASH : 45|1@0+ (1,0) [0|1] "" EON + SG_ HEADLIGHTS_ON : 54|1@0+ (1,0) [0|1] "" EON + SG_ WIPER_SWITCH : 53|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + +BO_ 891 STALK_STATUS_2: 8 XXX + SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" EON + SG_ LOW_BEAMS : 35|1@0+ (1,0) [0|1] "" XXX + SG_ HIGH_BEAMS : 34|1@0+ (1,0) [0|1] "" XXX + SG_ PARK_LIGHTS : 36|1@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + +CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; +CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; +CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; +CM_ SG_ 576 LINE_DISTANCE_VISIBLE "Length of line visible, undecoded"; +CM_ SG_ 577 LINE_FAR_EDGE_POSITION "Appears to be a measure of line thickness, indicates location of the portion of the line furthest from the car, undecoded"; +CM_ SG_ 577 LINE_PARAMETER "Unclear if this is low quality line curvature rate or if this is something else, but it is correlated with line curvature, undecoded"; +CM_ SG_ 577 LINE_DASHED "1 = line is dashed"; +CM_ SG_ 577 LINE_SOLID "1 = line is solid"; +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_ "acura_rdx_2020_can.dbc starts here"; + + +BO_ 304 GAS_PEDAL_2: 8 PCM + SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON + SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON + SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 419 GEARBOX: 8 PCM + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ GEAR_SHIFTER : 29|6@0+ (1,0) [0|63] "" EON + SG_ GEAR : 7|8@0+ (1,0) [0|255] "" EON + +BO_ 432 STANDSTILL: 7 VSA + SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON + +BO_ 446 BRAKE_MODULE: 3 VSA + SG_ BRAKE_PRESSED : 4|1@0+ (1,0) [0|1] "" XXX + SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" XXX + +BO_ 927 RADAR_HUD: 8 RADAR + SG_ ZEROS_BOH : 7|10@0+ (1,0) [0|127] "" BDY + SG_ CMBS_OFF : 12|1@0+ (1,0) [0|1] "" BDY + SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|1] "" XXX + SG_ SET_TO_1 : 13|1@0+ (1,0) [0|1] "" BDY + SG_ ZEROS_BOH2 : 11|4@0+ (1,0) [0|1] "" XXX + SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|1] "" XXX + SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|1] "" BDY + SG_ SET_TO_0 : 22|1@0+ (1,0) [0|1] "" XXX + SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|255] "" XXX + SG_ BOH : 40|1@0+ (1,0) [0|1] "" XXX + SG_ BOH_2 : 30|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 + +BO_ 1302 ODOMETER: 8 XXX + SG_ ODOMETER : 7|24@0+ (1,0) [0|16777215] "km" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +VAL_ 419 GEAR_SHIFTER 32 "D" 8 "R" 4 "P" ; +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" ; +VAL_ 806 CMBS_BUTTON 3 "pressed" 0 "released" ; +VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; +VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; + +CM_ "CHFFR_METRIC 330 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/cadillac_ct6_chassis.dbc b/opendbc/cadillac_ct6_chassis.dbc deleted file mode 100644 index 9de969d762f9a2..00000000000000 --- a/opendbc/cadillac_ct6_chassis.dbc +++ /dev/null @@ -1,95 +0,0 @@ -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_: K182_PACM K43_PSCM K17_EBCM NEO K124_ASCM - - - -BO_ 823 PACMParkAssitCmd: 7 NEO - SG_ RollingCounter : 35|2@0+ (1,0) [0|0] "" NEO - SG_ SteeringWheelChecksum : 47|16@0+ (1,0) [0|0] "" NEO - SG_ SteeringWheelCmd : 23|16@0+ (1,0) [0|0] "" NEO - -BO_ 560 EBCMRegen: 6 K17_EBCM - SG_ Regen : 1|10@0+ (1,0) [0|0] "" NEO - -BO_ 338 ASCMLKASteeringCmd: 6 NEO - SG_ LKASteeringCmdActive : 7|1@0+ (1,0) [0|0] "" NEO - SG_ LKASteeringCmd : 5|14@0- (1,0) [0|0] "" NEO - SG_ RollingCounter : 23|2@0+ (1,0) [0|0] "" NEO - SG_ SetMe1 : 21|1@0+ (1,0) [0|0] "" NEO - SG_ LKASVehicleSpeed : 20|13@0+ (0.22,0) [0|0] "kph" NEO - SG_ LKASMode : 36|2@0+ (1,0) [0|0] "" NEO - SG_ LKASteeringCmdChecksum : 33|10@0+ (1,0) [0|0] "" NEO - -BO_ 340 ASCMBLKASteeringCmd: 6 NEO - SG_ LKASteeringCmdActive : 7|1@0+ (1,0) [0|0] "" NEO - SG_ LKASteeringCmd : 5|14@0- (1,0) [0|0] "" NEO - SG_ RollingCounter : 23|2@0+ (1,0) [0|0] "" NEO - SG_ SetMe1 : 21|1@0+ (1,0) [0|0] "" NEO - SG_ LKASVehicleSpeed : 20|13@0+ (0.22,0) [0|0] "kph" NEO - SG_ LKASteeringCmdActive2 : 35|1@0+ (1,0) [0|0] "" NEO - SG_ LKASteeringCmdChecksum : 33|10@0+ (1,0) [0|0] "" NEO - -BO_ 368 EBCMFrictionBrakeStatus: 8 K17_EBCM - SG_ FrictionBrakePressure : 23|16@0+ (1,0) [0|0] "" NEO - -BO_ 789 EBCMFrictionBrakeCmd: 5 K17_EBCM - SG_ RollingCounter : 37|6@0+ (1,0) [0|0] "" NEO - SG_ FrictionBrakeMode : 7|4@0+ (1,0) [0|0] "" NEO - SG_ FrictionBrakeChecksum : 23|16@0+ (1,0) [0|0] "" NEO - SG_ FrictionBrakeCmd : 3|12@0- (1,0) [0|0] "" NEO - -BO_TX_BU_ 823 : K43_PSCM,NEO; -BO_TX_BU_ 789 : NEO,K17_EBCM; - - -CM_ BU_ K182_PACM "Parking Assist Control Module"; -CM_ BU_ K43_PSCM "Power Steering Control Module"; -CM_ BU_ K17_EBCM "Electronic Brake Control Module"; -CM_ BU_ NEO "Comma NEO"; -CM_ BU_ K124_ASCM "Active Safety Control Module"; -BA_DEF_ "UseGMParameterIDs" INT 0 0; -BA_DEF_ "ProtocolType" STRING ; -BA_DEF_ "BusType" STRING ; -BA_DEF_DEF_ "UseGMParameterIDs" 1; -BA_DEF_DEF_ "ProtocolType" "GMLAN"; -BA_DEF_DEF_ "BusType" ""; -BA_ "UseGMParameterIDs" 0; -BA_ "BusType" "CAN"; -BA_ "ProtocolType" "GMLAN"; - -VAL_ 338 LKASteeringCmdActive 1 "Active" 0 "Inactive" ; -VAL_ 338 LKASMode 2 "supercruise" 1 "lkas" 0 "Inactive" ; diff --git a/opendbc/cadillac_ct6_object.dbc b/opendbc/cadillac_ct6_object.dbc deleted file mode 100644 index d83ae672b16307..00000000000000 --- a/opendbc/cadillac_ct6_object.dbc +++ /dev/null @@ -1,3470 +0,0 @@ -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_: RRSRR_FO LRSRR_FO CIPM_FO _DOFIMU2_FO _DOFIMU1_FO DMS_FO AMM_FO EOCM2B_IMX6_FO EOCM2B_K2_FO EOCM2B_K1_FO EOCM2A_IMX6_FO EOCM2A_K2_FO EOCM2A_K1_FO NVS_FO Dummy_FO TestTool_FO LRR_FO RFSRR_FO LFSRR_FO RSRR_FO VIS_FO EOCM_F_FO VIS2_FO -VAL_TABLE_ vt_BooleanValues 1 "true" 0 "false" ; -VAL_TABLE_ FrntVsnInPthVehBrkNwSt 10 "Active" 5 "Inactive" ; -VAL_TABLE_ FrntVsnClostPedBrkNwSt 10 "Active" 5 "Inactive" ; -VAL_TABLE_ DrvrMonSysEngSt 7 "Unused and Reserved 1" 6 "Recovering" 5 "Tracking" 4 "Searching" 3 "Video test port only" 2 "Idle" 1 "Invalid state" 0 "Does not exist or DME" ; -VAL_TABLE_ DrvrMonEngUnrecvrFltCod 7 "Unused and Reserved 3" 6 "Unused and Reserved 2" 5 "Unused and Reserved 1" 4 "Vehicle power supply Errors" 3 "Problem with LED illuminators" 2 "Vehicle input signals Errors" 1 "Problem with imager" 0 "Ok" ; -VAL_TABLE_ DrvrMonEngRecvrFltCod 3 "Engine is unable to find a face" 2 "Input Images too dark" 1 "Input images too bright" 0 "Ok" ; -VAL_TABLE_ DrvrMntrSysVTP 1 "Video test port active" 0 "Video test port inactive" ; -VAL_TABLE_ DrvrAttnStatCnfdc 3 "High" 2 "Medium" 1 "Low" 0 "Lowest" ; -VAL_TABLE_ DrvrAttnStat 7 "Invalid" 6 "Driver is exhibiting sleep" 5 "Driver is exhibiting microsleep" 4 "Attention is Center Console" 3 "Attention is Drivers Lap" 2 "Attention is Off Road" 1 "Attention is On Road" 0 "Unknown" ; -VAL_TABLE_ PPSMd 7 "GNSS and RTX and DR and MM" 6 "DR ONLY" 5 "GNSS and RTX and DR" 4 "GNSS and SBAS and DR" 3 "GNSS and DR" 2 "GNSS and RTX" 1 "GNSS and SBAS" 0 "GNSS Standalone" ; -VAL_TABLE_ AdvDrvAstMpPrfShrtAcur 3 "Accuracy Is Unknown" 2 "Lowest Accuracy" 1 "Medium Accuracy" 0 "Highest Accuracy" ; -VAL_TABLE_ AdvDrAstMpStbRtOfWay 3 "Not Applicable" 2 "Unknown" 1 "Sub Path Has Right Of Way Over Path" 0 "Path Has Right Of Way Over Sub Path" ; -VAL_TABLE_ AdvDrAstMpStbPrtCalRut 3 "Not Applicable" 2 "Unknown" 1 "Path From This Point On Is Part Of Calculated Route" 0 "Path From This Point On Is Not Part Of Calculated Route" ; -VAL_TABLE_ AdvDrAstMpStbMsgTyp 7 "Unused and Reserved 2" 6 "Metadata" 5 "Profile Long" 4 "Profile Short" 3 "Stub" 2 "Segment" 1 "Position" 0 "Unused and Reserved 1" ; -VAL_TABLE_ AdvDrAstMpStbFmOfWay 15 "Not Applicable" 14 "Pedestrian Zone" 13 "Entrance To Or Exit To Service" 12 "Entrance To Or Exit Of A Car Park" 11 "Service Road Or Frontage Road" 10 "Slip Road per Ramp" 9 "Slip Road per Ramp On A Freeway Or Controlled Access Road" 8 "Parallel Road" 7 "Unused and Reserved 2" 6 "Unused and Reserved 1" 5 "Traffic Square per Special Traffic Figure" 4 "Roundabout Circle" 3 "Single Carriageway" 2 "Multiple Carriageway Or Multiply Digitized Road" 1 "Freeway Or Controlled Access Road That Is Not A Slip Road Or Ramp" 0 "Unknown" ; -VAL_TABLE_ AdvDrAstMpStbCmplxInsct 3 "Not Applicable" 2 "Unknown" 1 "Stub Is Part Of Complex Intersection" 0 "Stub Is Not Part Of Complex Intersection" ; -VAL_TABLE_ AdvDrAstMpSegTunl 3 "Not Applicable" 2 "Unknown" 1 "Segment Is Part Of Tunnel" 0 "Segment Is Not A Part Of Tunnel" ; -VAL_TABLE_ AdvDrAstMpSegPrtCalRut 3 "Not Applicable" 2 "Unknown" 1 "Segment Is Part Of Calculated Route" 0 "Segment Is Not Part Of Calculated Route" ; -VAL_TABLE_ AdvDrAstMpSegMsgTyp 7 "Unused and Reserved 2" 6 "Metadata" 5 "Profile Long" 4 "Profile Short" 3 "Stub" 2 "Segment" 1 "Position" 0 "Unused and Reserved 1" ; -VAL_TABLE_ AdvDrAstMpSegFrmOfWay 15 "Not Applicable" 14 "Pedestrian Zone" 13 "Entrance To Or Exit To Service" 12 "Entrance To Or Exit Of A Car Park" 11 "Service Road Or Frontage Road" 10 "Slip Road per Ramp" 9 "Slip Road per Ramp On A Freeway Or Controlled Access Road" 8 "Parallel Road" 7 "Unused and Reserved 2" 6 "Unused and Reserved 1" 5 "Traffic Square per Special Traffic Figure" 4 "Roundabout Circle" 3 "Single Carriageway" 2 "Multiple Carriageway Or Multiply Digitized Road" 1 "Freeway Or Controlled Access Road That Is Not A Slip Road or Ramp" 0 "Unknown" ; -VAL_TABLE_ AdvDrAstMpSegEffSdLmtTp 7 "Not Applicable" 6 "Explicit Snow" 5 "Explicit Rain" 4 "Explicit Time Of Day" 3 "Explicit By Day" 2 "Explicit By Night" 1 "Explicit On Traffic Sign" 0 "Implicit" ; -VAL_TABLE_ AdvDrAstMpSegDivdRd 3 "Not Applicable" 2 "Unkown" 1 "Segment Is Part Of Divided Road" 0 "Segment Is Not Part Of Divided Road" ; -VAL_TABLE_ AdvDrAstMpSegCmplxInsct 3 "Not Applicable" 2 "Unknown" 1 "Segment Is Part Of Complex Intersection" 0 "Segment Is Not Part Of Complex Intersection" ; -VAL_TABLE_ AdvDrAstMpSegBrdg 3 "Not Applicable" 2 "Unknown" 1 "Segment Is Part Of Bridge" 0 "Segment Not Part Of Bridge" ; -VAL_TABLE_ AdvDrAstMpSegBldUpAra 3 "Not Applicable" 2 "Unknown" 1 "Segment Is Part Of Built Up Area" 0 "Segment Is Not Part Of Built Up Area" ; -VAL_TABLE_ AdvDrAstMpMtdtSpdUnt 1 "Miles Per Hour" 0 "Kilometers Per Hour" ; -VAL_TABLE_ AdvDrAstMpMtdtDrvSd 1 "Driving Side Right" 0 "Driving Side Left" ; -VAL_TABLE_ WSMR_WiFiAssnReq 3 "Unexpected Undefined Connection Behavior" 2 "Wi Fi association failed with available credentials" 1 "Failed to receive Wi Fi credentials after 255 attempts" 0 "SSID and Passphrase Request" ; -VAL_TABLE_ StrgColCommsFlt 2 "Disabled Communications DTC" 1 "No Communications Fault" 0 "Communications Fault" ; -VAL_TABLE_ CPMAPINFO4 1 "Hardware Or Software Error" 0 "No Hardware Or Software Error" ; -VAL_TABLE_ AdvDrvAstMpPrfShrt2Acur 3 "Accuracy Is Unknown" 2 "Lowest Accuracy" 1 "Medium Accuracy" 0 "Highest Accuracy" ; -VAL_TABLE_ InterLghtStat 1 "Interior Lights On" 0 "Interior Light Off" ; -VAL_TABLE_ VehLnStatConf 2 "High Confidence" 1 "Low Confidence" 0 "No Confidence" 3 "Very High Confidence" ; -VAL_TABLE_ VehLnStat 3 "Lane Change To Right" 2 "Lane Change To Left" 1 "Staying in Lane" 0 "Unkown" ; -VAL_TABLE_ HrznPrvdRstRq 1 "Reset Not Required" 0 "Reset Required" ; -VAL_TABLE_ ExptNxtTrnstnDirConf 3 "Very High Confidence" 2 "High Confidence" 1 "Low Confidence" 0 "No Confidence" ; -VAL_TABLE_ ExptNxtTrnstnDir 7 "Reserved4" 6 "Reserved3" 5 "Reserved2" 4 "Reserved1" 3 "Traversing Middle Transition" 2 "Traversing Next Transition Right" 1 "Traversing Next Transition Left" 0 "Unknown" ; -VAL_TABLE_ ADASISMsgTypRetrans 7 "GM System Specific" 6 "Meta Data" 5 "Profile Long" 4 "Profile Short" 3 "Stub" 2 "Segment" 1 "Position" 0 "Checksum" ; -VAL_TABLE_ NVSysStat 7 "Needs Headlights" 6 "Temporarily Unavailable" 5 "Not Dark" 4 "Needs Service" 3 "Active" 2 "Inactive" 1 "Initializing" 0 "Unknown" ; -VAL_TABLE_ NVSysPedWrnIndReq 3 "Unused & Reserved" 2 "Pedestrian Alert" 1 "Pedestrian Detected" 0 "None" ; -VAL_TABLE_ NVSysPedDetCstReq 2 "On" 1 "Off" 0 "No Value" ; -VAL_TABLE_ NVSysPedDetCsCrStVal 2 "On" 1 "Off" 0 "No Value" ; -VAL_TABLE_ FwVsnCinCoutPotT9Rev 2 "Right" 1 "Left" 0 "None" ; -VAL_TABLE_ FwVsnCinCoutPotT8Rev 2 "Right" 1 "Left" 0 "None" ; -VAL_TABLE_ FwVsnCinCoutPotT7Rev 2 "Right" 1 "Left" 0 "None" ; -VAL_TABLE_ FwVsnCinCoutPotT6Rev 2 "Right" 1 "Left" 0 "None" ; -VAL_TABLE_ FwVsnCinCoutPotT5Rev 2 "Right" 1 "Left" 0 "None" ; -VAL_TABLE_ FwVsnCinCoutPotT4Rev 2 "Right" 1 "Left" 0 "None" ; -VAL_TABLE_ FwVsnCinCoutPotT3Rev 2 "Right" 1 "Left" 0 "None" ; -VAL_TABLE_ FwVsnCinCoutPotT2Rev 2 "Right" 1 "Left" 0 "None" ; -VAL_TABLE_ FwVsnCinCoutPotT1Rev 2 "Right" 1 "Left" 0 "None" ; -VAL_TABLE_ FwVsnCinCoutPotT12Rev 2 "Right" 1 "Left" 0 "None" ; -VAL_TABLE_ FwVsnCinCoutPotT11Rev 2 "Right" 1 "Left" 0 "None" ; -VAL_TABLE_ FwVsnCinCoutPotT10Rev 2 "Right" 1 "Left" 0 "None" ; -VAL_TABLE_ GFHBObjDirTrk8 1 "Ahead Traffic" 0 "Incoming Traffic" ; -VAL_TABLE_ GFHBObjDirTrk7 1 "Ahead Traffic" 0 "Incoming Traffic" ; -VAL_TABLE_ GFHBObjDirTrk6 1 "Ahead Traffic" 0 "Incoming Traffic" ; -VAL_TABLE_ GFHBObjDirTrk5 1 "Ahead Traffic" 0 "Incoming Traffic" ; -VAL_TABLE_ GFHBObjDirTrk4 1 "Ahead Traffic" 0 "Incoming Traffic" ; -VAL_TABLE_ GFHBObjDirTrk3 1 "Ahead Traffic" 0 "Incoming Traffic" ; -VAL_TABLE_ GFHBObjDirTrk2 1 "Ahead Traffic" 0 "Incoming Traffic" ; -VAL_TABLE_ GFHBObjDirTrk1 1 "Ahead Traffic" 0 "Incoming Traffic" ; -VAL_TABLE_ GFHBFwVsnRelLaneTrk8 3 "Left Lane" 2 "Right Lane" 1 "Host Lane" 0 "Unknown" ; -VAL_TABLE_ GFHBFwVsnRelLaneTrk7 3 "Left Lane" 2 "Right Lane" 1 "Host Lane" 0 "Unknown" ; -VAL_TABLE_ GFHBFwVsnRelLaneTrk6 3 "Left Lane" 2 "Right Lane" 1 "Host Lane" 0 "Unknown" ; -VAL_TABLE_ GFHBFwVsnRelLaneTrk5 3 "Left Lane" 2 "Right Lane" 1 "Host Lane" 0 "Unknown" ; -VAL_TABLE_ GFHBFwVsnRelLaneTrk4 3 "Left Lane" 2 "Right Lane" 1 "Host Lane" 0 "Unknown" ; -VAL_TABLE_ GFHBFwVsnRelLaneTrk3 3 "Left Lane" 2 "Right Lane" 1 "Host Lane" 0 "Unknown" ; -VAL_TABLE_ GFHBFwVsnRelLaneTrk2 3 "Left Lane" 2 "Right Lane" 1 "Host Lane" 0 "Unknown" ; -VAL_TABLE_ GFHBFwVsnRelLaneTrk1 3 "Left Lane" 2 "Right Lane" 1 "Host Lane" 0 "Unknown" ; -VAL_TABLE_ GFHBFwVsnMesStatTrk8 3 "Measured this cycle" 2 "Latent track not detected this cycle" 1 "New Object" 0 "No Object" ; -VAL_TABLE_ GFHBFwVsnMesStatTrk7 3 "Measured this cycle" 2 "Latent track not detected this cycle" 1 "New Object" 0 "No Object" ; -VAL_TABLE_ GFHBFwVsnMesStatTrk6 3 "Measured this cycle" 2 "Latent track not detected this cycle" 1 "New Object" 0 "No Object" ; -VAL_TABLE_ GFHBFwVsnMesStatTrk5 3 "Measured this cycle" 2 "Latent track not detected this cycle" 1 "New Object" 0 "No Object" ; -VAL_TABLE_ GFHBFwVsnMesStatTrk4 3 "Measured this cycle" 2 "Latent track not detected this cycle" 1 "New Object" 0 "No Object" ; -VAL_TABLE_ GFHBFwVsnMesStatTrk3 3 "Measured this cycle" 2 "Latent track not detected this cycle" 1 "New Object" 0 "No Object" ; -VAL_TABLE_ GFHBFwVsnMesStatTrk2 3 "Measured this cycle" 2 "Latent track not detected this cycle" 1 "New Object" 0 "No Object" ; -VAL_TABLE_ GFHBFwVsnMesStatTrk1 3 "Measured this cycle" 2 "Latent track not detected this cycle" 1 "New Object" 0 "No Object" ; -VAL_TABLE_ GFHBFwVsnCnfdncTrk8 3 "Confident" 2 "Speculative" 1 "Highly Speculative" 0 "Invalid" ; -VAL_TABLE_ GFHBFwVsnCnfdncTrk7 3 "Confident" 2 "Speculative" 1 "Highly Speculative" 0 "Invalid" ; -VAL_TABLE_ GFHBFwVsnCnfdncTrk6 3 "Confident" 2 "Speculative" 1 "Highly Speculative" 0 "Invalid" ; -VAL_TABLE_ GFHBFwVsnCnfdncTrk5 3 "Confident" 2 "Speculative" 1 "Highly Speculative" 0 "Invalid" ; -VAL_TABLE_ GFHBFwVsnCnfdncTrk4 3 "Confident" 2 "Speculative" 1 "Highly Speculative" 0 "Invalid" ; -VAL_TABLE_ GFHBFwVsnCnfdncTrk3 3 "Confident" 2 "Speculative" 1 "Highly Speculative" 0 "Invalid" ; -VAL_TABLE_ GFHBFwVsnCnfdncTrk2 3 "Confident" 2 "Speculative" 1 "Highly Speculative" 0 "Invalid" ; -VAL_TABLE_ GFHBFwVsnCnfdncTrk1 0 "Invalid" 3 "Confident" 2 "Speculative" 1 "Highly Speculative" ; -VAL_TABLE_ GFHBFVsnObjTypTrkRev8 12 "Cluster Object" 11 "Child Close to Danger Zone" 10 "Pedestrian Moving Out of Danger Zone" 9 "Pedestrian Moving Into Danger Zone" 8 "Pedestrian Standing Outside Danger Zone" 7 "No Object Present" 6 "Fixed Roadside Object" 5 "Fixed Overhead Object" 4 "Pedestrian" 3 "Motorcycle/ Bicycle" 2 "Large Vehicle (Semi)" 1 "4 Wheel Vehicle (Car)" 0 "Unknown" ; -VAL_TABLE_ GFHBFVsnObjTypTrkRev7 12 "Cluster Object" 11 "Child Close to Danger Zone" 10 "Pedestrian Moving Out of Danger Zone" 9 "Pedestrian Moving Into Danger Zone" 8 "Pedestrian Standing Outside Danger Zone" 7 "No Object Present" 6 "Fixed Roadside Object" 5 "Fixed Overhead Object" 4 "Pedestrian" 3 "Motorcycle/ Bicycle" 2 "Large Vehicle (Semi)" 1 "4 Wheel Vehicle (Car)" 0 "Unknown" ; -VAL_TABLE_ GFHBFVsnObjTypTrkRev6 12 "Cluster Object" 11 "Child Close to Danger Zone" 10 "Pedestrian Moving Out of Danger Zone" 9 "Pedestrian Moving Into Danger Zone" 8 "Pedestrian Standing Outside Danger Zone" 7 "No Object Present" 6 "Fixed Roadside Object" 5 "Fixed Overhead Object" 4 "Pedestrian" 3 "Motorcycle/ Bicycle" 2 "Large Vehicle (Semi)" 1 "4 Wheel Vehicle (Car)" 0 "Unknown" ; -VAL_TABLE_ GFHBFVsnObjTypTrkRev5 12 "Cluster Object" 11 "Child Close to Danger Zone" 10 "Pedestrian Moving Out of Danger Zone" 9 "Pedestrian Moving Into Danger Zone" 8 "Pedestrian Standing Outside Danger Zone" 7 "No Object Present" 6 "Fixed Roadside Object" 5 "Fixed Overhead Object" 4 "Pedestrian" 3 "Motorcycle/ Bicycle" 2 "Large Vehicle (Semi)" 1 "4 Wheel Vehicle (Car)" 0 "Unknown" ; -VAL_TABLE_ GFHBFVsnObjTypTrkRev4 12 "Cluster Object" 11 "Child Close to Danger Zone" 10 "Pedestrian Moving Out of Danger Zone" 9 "Pedestrian Moving Into Danger Zone" 8 "Pedestrian Standing Outside Danger Zone" 7 "No Object Present" 6 "Fixed Roadside Object" 5 "Fixed Overhead Object" 4 "Pedestrian" 3 "Motorcycle/ Bicycle" 2 "Large Vehicle (Semi)" 1 "4 Wheel Vehicle (Car)" 0 "Unknown" ; -VAL_TABLE_ GFHBFVsnObjTypTrkRev3 12 "Cluster Object" 11 "Child Close to Danger Zone" 10 "Pedestrian Moving Out of Danger Zone" 9 "Pedestrian Moving Into Danger Zone" 8 "Pedestrian Standing Outside Danger Zone" 7 "No Object Present" 6 "Fixed Roadside Object" 5 "Fixed Overhead Object" 4 "Pedestrian" 3 "Motorcycle/ Bicycle" 2 "Large Vehicle (Semi)" 1 "4 Wheel Vehicle (Car)" 0 "Unknown" ; -VAL_TABLE_ GFHBFVsnObjTypTrkRev2 12 "Cluster Object" 11 "Child Close to Danger Zone" 10 "Pedestrian Moving Out of Danger Zone" 9 "Pedestrian Moving Into Danger Zone" 8 "Pedestrian Standing Outside Danger Zone" 7 "No Object Present" 6 "Fixed Roadside Object" 5 "Fixed Overhead Object" 4 "Pedestrian" 3 "Motorcycle/ Bicycle" 2 "Large Vehicle (Semi)" 1 "4 Wheel Vehicle (Car)" 0 "Unknown" ; -VAL_TABLE_ GFHBFVsnObjTypTrkRev1 12 "Cluster Object" 11 "Child Close to Danger Zone" 10 "Pedestrian Moving Out of Danger Zone" 9 "Pedestrian Moving Into Danger Zone" 8 "Pedestrian Standing Outside Danger Zone" 7 "No Object Present" 6 "Fixed Roadside Object" 5 "Fixed Overhead Object" 4 "Pedestrian" 3 "Motorcycle/ Bicycle" 2 "Large Vehicle (Semi)" 1 "4 Wheel Vehicle (Car" 0 "Unknown" ; -VAL_TABLE_ CRL_Cnfdnc 7 "Reserved4" 6 "Reserved3" 5 "Reserved2" 4 "Reserved1" 3 "Best" 2 "Marking Present" 1 "Weak Marking" 0 "No Lane" ; -VAL_TABLE_ CLL_Cnfdnc 7 "Reserved4" 6 "Reserved3" 5 "Reserved2" 4 "Reserved1" 3 "Best" 2 "Marking Present" 1 "Weak Marking" 0 "No Lane" ; -VAL_TABLE_ VBBrkCtrlSt 4 "Release Control" 3 "Hold Vehicle" 2 "Apply Brake" 1 "Decrease Torque" 0 "No Action" ; -VAL_TABLE_ ObstacleType 6 "NO_OBJECT" 5 "OBJ_GUARDRAIL" 4 "OBJ_TUNNEL " 3 "OBJ_TRAFFIC_SIGN" 2 "OBJ_VEHICLE" 1 "OBJ_BRIDGE " 0 "OBJ_UNKNOWN" ; -VAL_TABLE_ VpathMode 2 "Mid Hi Spped" 1 "Low Speed" 0 "Disabled" ; -VAL_TABLE_ LaneChngStatus 2 "Lane Change Right" 1 "Lane Change Left" 0 "Idle" ; -VAL_TABLE_ TravelDirection 3 "Other (excessive side slip)" 2 "reverse / stopped in rvrs gear" 1 "Forward / stopped in frwd gear" 0 "Unknown" ; -VAL_TABLE_ TrueOrFalse 1 "true" 0 "false" ; -VAL_TABLE_ ModeCommand 5 "Sensing with Reduced Power" 4 "Undefined" 3 "Radio Silent" 2 "Sensing" 1 "Not Sensing" 0 "Undefined" ; -VAL_TABLE_ LaneSnsLLnPosValid 1 "Invalid" 0 "Valid" ; -VAL_TABLE_ LnSnsRLnPosValid 1 "Invalid" 0 "Valid" ; -VAL_TABLE_ Elevation 3 "Low " 2 "mid (reserved)" 1 "high " 0 "Unknown" ; -VAL_TABLE_ ModeCommandFdbk 5 "Sensing with reduced power" 4 "Undefined" 3 "Radio Silent" 2 "Sensing" 1 "Not Sensing" 0 "Undefined" ; -VAL_TABLE_ relativeLane 3 "Left Lane" 2 "Right Lane" 1 "Host Lane" 0 "Unknown" ; -VAL_TABLE_ RoadTypeInfo 5 "Constiction Zone Exit" 4 "Construction Zone Entry" 3 "Highway" 2 "Secondary Road" 1 "City" 0 "Unknown" ; -VAL_TABLE_ ObjectLossInfo 2 "elevation conditions" 1 "tight curve" 0 "not lost" ; -VAL_TABLE_ MeasurementStatus 3 "Measured this cycle" 2 "Latent track not detctd this cyc" 1 "New Object" 0 "No Object" ; -VAL_TABLE_ ObjectType 7 "no object present" 6 "fixed roadside object" 5 "fixed overhead object" 4 "pedestrian" 3 "motocycle / bicycle" 2 "Large vehicle (semi)" 1 "4 Wheel Vehicle (car, small trk)" 0 "Unknown" ; -VAL_TABLE_ Confidence 3 "confident" 2 "speculative" 1 "highly speculative" 0 "invalid" ; -VAL_TABLE_ DynamicProp 4 "Moving in opposite direction" 3 "Moving in same direction as host" 2 "Has moved but currently stopped" 1 "Has never moved" 0 "Unknown" ; -VAL_TABLE_ DrvWndPosSt 6 "Fully Opened" 5 "Open More Than C" 4 "Position C" 3 "Posistion B" 2 "Posistion A" 1 "Open Less Than A" 0 "Fully Closed" ; -VAL_TABLE_ VehMovSta 4 "Invalid" 3 "Reverse" 2 "Forward" 1 "Neutral" 0 "Parked" ; -VAL_TABLE_ OtsdAmbtLtLvlStat 2 "Day" 1 "Night" 0 "Unknown" ; -VAL_TABLE_ RtTrnLmpAtv 2 "On with telltale" 1 "On without telltale" 0 "Off" ; -VAL_TABLE_ LftTrnLmpAtv 2 "On with telltale" 1 "On without telltale" 0 "Off" ; -VAL_TABLE_ HdlmpBmSelectStat 2 "High Beams" 1 "Low Beams" 0 "Unknown" ; -VAL_TABLE_ DTCI_DTCFaultType 3 "Type C" 2 "Type B" 1 "Type A" 0 "Not Supported" ; -VAL_TABLE_ TrnsShftLvrPos 13 "Forward Range J" 12 "Froward Range I" 15 "Lever Position Unknown" 11 "Forward Range H" 10 "Forward Range G" 9 "Forward Range F" 8 "Forward Range E" 7 "Forward Range D" 6 "Forward Range C" 5 "Forward Range B" 4 "Forward Range A" 3 "Neutral Range" 2 "Reverse Range" 1 "Park Range" 0 "Between Ranges" ; -VAL_TABLE_ SysPwrMd 3 "Crank Request" 2 "Run" 1 "Accessory" 0 "Off" ; -VAL_TABLE_ ValidityStates 1 "Invalid" 0 "Valid" ; - - -BO_ 1548 ADAS_Profile_Short2_FO: 8 AMM_FO - SG_ AdvDrvAstMpPrfShrt2Val1 : 1|10@0+ (1,0) [0|1023] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrvAstMpPrfShrt2Val0 : 33|10@0+ (1,0) [0|1023] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrvAstMpPrfShrt2Updt : 39|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrvAstMpPrfShrt2RTrns : 3|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrvAstMpPrfShrt2Typ : 38|5@0+ (1,0) [0|31] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrvAstMpPrfShrt2PthIdx : 23|6@0+ (1,0) [0|63] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrvAstMpPrfShrt2Ofst : 52|13@0+ (1,0) [0|8191] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrvAstMpPrfShrt2MsgTp : 55|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrvAstMpPrfShrt2Dist1 : 17|10@0+ (1,0) [0|1023] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrvAstMpPrfShrt2CycCnt : 7|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrvAstMpPrfShrt2CtlPt : 2|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrvAstMpPrfShrt2Acur : 5|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - -BO_ 1547 ADAS_Profile_Long2_FO: 8 AMM_FO - SG_ AdvDrAstMpProfLng2Val : 39|32@0+ (1,0) [0|4294967295] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrAstMpPrfLng2Updt : 7|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrAstMpPrfLng2RTrns : 6|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrAstMpPrfLng2PrfTyp : 4|5@0+ (1,0) [0|31] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrAstMpPrfLng2PthIdx : 13|6@0+ (1,0) [0|63] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrAstMpPrfLng2Ofst : 20|13@0+ (1,0) [0|8191] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrAstMpPrfLng2MgTyp : 23|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrAstMpPrfLng2CycCt : 15|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrAstMpPrfLng2CtrlPt : 5|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - -BO_ 1630 USDT_Resp_From_EOCM2B_K2_FO: 8 EOCM2B_K2_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1374 UUDT_Resp_From_EOCM2B_K2_FO: 8 EOCM2B_K2_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 606 USDT_Req_to_EOCM2B_K2_FO: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" EOCM2B_K2_FO - -BO_ 328 Vehicle_Info_FO: 5 EOCM2A_K1_FO - SG_ StrWhAngGrd : 27|12@0- (1,0) [-2048|2047] "deg/sec" DMS_FO - SG_ TrnsShftLvrPos : 31|4@0+ (1,0) [0|15] "" DMS_FO - SG_ StrWhAng_148 : 15|16@0- (0.0625,0) [-2048|2047.9375] "deg" DMS_FO - SG_ TrnsShftLvrPosV : 3|1@0+ (1,0) [0|1] "" DMS_FO - SG_ StrWhAngV_148 : 4|1@0+ (1,0) [0|1] "" DMS_FO - SG_ StrWhAngMsk_148 : 5|1@0+ (1,0) [0|1] "" DMS_FO - SG_ StrWhAngGrdV : 6|1@0+ (1,0) [0|1] "" DMS_FO - SG_ StrWhAngGrdMsk : 7|1@0+ (1,0) [0|1] "" DMS_FO - -BO_ 1930 DTC_Triggered_78A_FO: 7 LRSRR_FO - SG_ DTCI_CodeSupported_78A : 40|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_CurrentStatus_78A : 41|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_DTCFailType_78A : 39|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCFaultType_78A : 55|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCNumber_78A : 23|16@0+ (1,0) [0|65535] "" TestTool_FO - SG_ DTCI_DTCSource_78A : 15|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCTriggered_78A : 0|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_HistStat_78A : 44|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldCdClrdStat_78A : 43|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldPwrUpSt_78A : 46|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdCdClrdSt_78A : 42|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdPwrUpSt_78A : 45|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused1_78A : 7|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused2_78A : 6|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused3_78A : 5|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused4_78A : 4|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused5_78A : 3|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused6_78A : 2|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused7_78A : 1|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_WrnIndRqdSt_78A : 47|1@0+ (1,0) [0|1] "" TestTool_FO - -BO_ 1624 USDT_Resp_From_LRSRR: 8 LRSRR_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1368 UUDT_Resp_From_LRSRR: 8 LRSRR_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 600 USDT_Req_to_LRSRR: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" LRSRR_FO - -BO_ 613 PPS_QualMetrics_FO: 8 EOCM2A_K1_FO - SG_ PPSPstnDilPrcs : 47|10@0+ (0.1,0) [0|102.3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSMd : 53|3@0+ (1,0) [0|7] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPS3DAbsPosErrEstmt : 9|10@0+ (0.1,0) [0|102.3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSAbsHdngErrEstmt : 0|7@0+ (0.5,0) [0|63.5] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSAbsVelErrEstmt : 30|5@0+ (1,0) [0|31] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSPosQltyMtrcsChksm : 50|11@0+ (1,0) [0|2047] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPS2DAbsPosErrEstmt : 25|10@0+ (0.1,0) [0|102.3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSPosQltyMtcBrstID : 2|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPS2DAbsPosErrEstmtV : 5|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPS3DAbsPosErrEstmtV : 4|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSAbsHdngErrEstmtV : 3|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSAbsVelErrEstmtV : 31|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSMdV : 7|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSPstnDilPrcsV : 6|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - -BO_ 612 PPS_Time_FO: 8 EOCM2A_K1_FO - SG_ PPSTmdayV : 2|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSCldrDayV : 0|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSCldrDay : 8|9@0+ (1,0) [0|511] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSTmBrstID : 52|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSTmday : 31|27@0+ (1,0) [0|134217727] "ms" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSTmChksm : 50|11@0+ (1,0) [0|2047] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSCldrYrV : 1|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSCldrYr : 15|7@0+ (1,2014) [2014|2141] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - -BO_ 611 PPS_SigAcqTime_FO: 6 EOCM2A_K1_FO - SG_ PPSSigAqTmBrstID : 38|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSSigAcqTmV : 39|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSSigAcqTm : 7|32@0+ (1,0) [0|4294967295] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSSigAqTmChksm : 34|11@0+ (1,0) [0|2047] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - -BO_ 610 PPS_PosLong_FO: 6 EOCM2A_K1_FO - SG_ PPSLongBrstID : 39|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSLong : 6|31@0- (1,0) [-1073741824|1073741823] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSLongV : 7|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSLongChksm : 34|11@0+ (1,0) [0|2047] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - -BO_ 609 PPS_PosLat_FO: 6 EOCM2A_K1_FO - SG_ PPSLatV : 7|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSLatChksm : 34|11@0+ (1,0) [0|2047] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSLatBrstID : 36|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSLat : 5|30@0- (1,0) [-536870912|536870911] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - -BO_ 1160 PassPhrase_3_AMM_FO: 8 EOCM2A_K1_FO - SG_ WiFiPssPhrsDgts17to24_Mp : 7|64@0+ (1,0) [0|0] "" EOCM2B_K1_FO,AMM_FO - -BO_ 1159 PassPhrase_2_AMM_FO: 8 EOCM2A_K1_FO - SG_ WiFiPssPhrsDgts9to16_Mp : 7|64@0+ (1,0) [0|0] "" EOCM2B_K1_FO,AMM_FO - -BO_ 1158 PassPhrase_1_AMM_FO: 8 EOCM2A_K1_FO - SG_ WiFiPssPhrsDgts1to8_Mp : 7|64@0+ (1,0) [0|0] "" EOCM2B_K1_FO,AMM_FO - -BO_ 1546 ADAS_Protection_FO: 4 AMM_FO - SG_ AdvDrAstMpPrfLng2Avbl : 11|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrAstMpPosAvbl : 15|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrvAstMpHwFlt : 7|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpMtdtAvbl : 8|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrAstMpProtChksm : 23|16@0+ (1,0) [0|65535] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrAstMpProtRTrns : 0|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpProtCycCtMsg : 2|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpStbAvbl : 9|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrAstMpSegAvbl : 10|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrAstMpPrfShrtAvbl : 14|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrAstMpPrfShrt2Avbl : 13|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrAstMpPrfLngAvbl : 12|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ AdvDrvAstMpInpSigFld : 6|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - -BO_ 1545 ADAS_Metadata_FO: 8 AMM_FO - SG_ AdvDrAstMpMtdtVerYrQtr : 60|2@0+ (1,1) [1|4] "Qtr" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpMtdtVerYr : 53|6@0+ (1,2000) [2000|2063] "Year" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpMtdtSpdUnt : 39|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpMtdtPrvdr : 7|3@0+ (1,0) [0|7] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpMtdtMsgTyp : 58|3@0+ (1,0) [0|7] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpMtdtMnrPrtVr : 23|4@0+ (1,0) [0|15] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpMtdtCycCnt : 18|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpMtdtRgnCd : 38|15@0+ (1,0) [0|32767] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpMtdtHwVer : 16|9@0+ (1,0) [0|511] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpMtdtMnrPrtSbVr : 4|3@0+ (1,0) [0|7] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpMtdtMjrPrtVr : 55|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpMtdtDrvSd : 19|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpMtdtCntryCd : 1|10@0+ (1,0) [0|1023] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - -BO_ 1543 ADAS_Profile_Long_FO: 8 AMM_FO - SG_ AdvDrAstMpPrfLngUpdt : 7|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpPrfLngRTrns : 6|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpPrfLngCtlPt : 5|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpPrfLngTyp : 4|5@0+ (1,0) [0|31] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpPrfLngCycCt : 15|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpPrfLngPthIdx : 13|6@0+ (1,0) [0|63] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpPrfLngMsgTp : 23|3@0+ (1,0) [0|7] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpPrfLngOfst : 20|13@0+ (1,0) [0|8191] "m" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpPrfLngVal : 39|32@0+ (1,0) [0|4294967295] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - -BO_ 1544 ADAS_Profile_Short_FO: 8 AMM_FO - SG_ AdvDrvAstMpPrfShrtVal1 : 1|10@0+ (1,0) [0|1023] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrvAstMpPrfShrtVal0 : 33|10@0+ (1,0) [0|1023] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrvAstMpPrfShrtDist1 : 17|10@0+ (1,0) [0|1023] "m" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrvAstMpPrfShrtCycCnt : 7|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrvAstMpPrfShrtAcur : 5|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrvAstMpPrfShrtCtlPt : 2|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrvAstMpPrfShrtRetr : 3|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrvAstMpPrfShrtTyp : 38|5@0+ (1,0) [0|31] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrvAstMpPrfShrtUpdt : 39|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrvAstMpPrfShrtPthIdx : 23|6@0+ (1,0) [0|63] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrvAstMpPrfShrtMsgTp : 55|3@0+ (1,0) [0|7] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrvAstMpPrfShrtOfst : 52|13@0+ (1,0) [0|8191] "m" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - -BO_ 1542 ADAS_Stub_FO: 8 AMM_FO - SG_ AdvDrAstMpStbSubPthIdx : 63|6@0+ (1,0) [0|63] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpStbUpdt : 55|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpStbPrtCalRut : 57|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpStbNmLnDrvDir : 54|3@0+ (1,0) [0|7] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpStbCycCnt : 51|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpStbCmplxInsct : 49|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpStbTrnAngl : 47|8@0+ (1.417,0) [0|361.335] "deg" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpStbRtOfWay : 38|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpStbRelProb : 36|5@0+ (3.333,0) [0|103.323] "%" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpStbRetr : 39|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpStbNmLnOppDir : 31|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpStbPathIdx : 29|6@0+ (1,0) [0|63] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpStbLstStbOfst : 23|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpStbMsgTyp : 22|3@0+ (1,0) [0|7] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpStbFmOfWay : 19|4@0+ (1,0) [0|15] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpStbFuncRdCls : 7|3@0+ (1,0) [0|7] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpStbOfst : 4|13@0+ (1,0) [0|8191] "m" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - -BO_ 1541 ADAS_Segment_FO: 8 AMM_FO - SG_ AdvDrAstMpSegRelProb : 12|5@0+ (3.333,0) [0|103.323] "%" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpSegUpdt : 0|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpSegTunl : 25|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpSegCycCnt : 39|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpSegCmplxInsct : 37|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpSegBldUpAra : 43|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpSegBrdg : 41|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpSegRTrns : 1|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpSegDivdRd : 31|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpSegPthIdx : 7|6@0+ (1,0) [0|63] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpSegPrtCalRut : 27|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpSegNmLnOppDir : 29|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpSegNmLnDrvDir : 55|3@0+ (1,0) [0|7] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpSegMsgTyp : 46|3@0+ (1,0) [0|7] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpSegFunRdCls : 23|3@0+ (1,0) [0|7] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpSegFrmOfWay : 35|4@0+ (1,0) [0|15] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpSegEffSpdLmt : 20|5@0+ (1,0) [0|31] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpSegEffSdLmtTp : 15|3@0+ (1,0) [0|7] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpSegOffset : 52|13@0+ (1,0) [0|8191] "m" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - -BO_ 608 PPS_ElevHdSpd_FO: 8 EOCM2A_K1_FO - SG_ PPSVel : 31|8@0+ (1,0) [0|255] "km / h" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSVelV : 3|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSElvHedngSpdBrstID : 5|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSElvHdengSpdChksm : 50|11@0+ (1,0) [0|2047] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSHedngV : 6|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSHedng : 2|19@0+ (0.001,0) [0|524.287] "deg" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSElvtnV : 7|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - SG_ PPSElvtn : 39|21@0+ (1,-100000) [-100000|1997151] "cm" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,AMM_FO - -BO_ 1168 WiFi_Station_AMM_FO: 5 AMM_FO - SG_ WSMR_WiFiStnMpMACAddr : 15|32@0+ (1,0) [0|4294967295] "" EOCM2B_K1_FO,EOCM2A_K1_FO - SG_ WSMR_WiFiAssnReq : 1|2@0+ (1,0) [0|3] "" EOCM2B_K1_FO,EOCM2A_K1_FO - -BO_ 1161 WiFi_AP_Data_AMM_FO: 2 EOCM2A_K1_FO - SG_ WAPDM_SecurityType : 15|4@0+ (1,0) [0|15] "" EOCM2B_K1_FO,AMM_FO - SG_ WAPDM_WiFiEnStat : 0|1@0+ (1,0) [0|1] "" EOCM2B_K1_FO,AMM_FO - SG_ WAPDM_EncrptnType : 11|4@0+ (1,0) [0|15] "" EOCM2B_K1_FO,AMM_FO - -BO_ 1157 SSID_AMM_3_FO: 8 EOCM2A_K1_FO - SG_ WiFiSSIDDgts17to24_Mp : 7|64@0+ (1,0) [0|0] "" EOCM2B_K1_FO,AMM_FO - -BO_ 326 DMS_Eye_AOI_Info_FO: 6 DMS_FO - SG_ DrvrMontSysInit : 1|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrMontSysAvlbl : 3|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrMontMdlDatFlshProgrs : 2|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrMonEngRecvrFltCodARC : 36|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrAttnStatChksm : 34|11@0+ (1,0) [0|2047] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrAttnStat : 39|3@0+ (1,0) [0|7] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrAttnStatPrd : 22|15@0+ (0.025,0) [0|819.175] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrMonEngRecvrFltCodV : 23|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrMonEngUnrecvrFltCod : 10|3@0+ (1,0) [0|7] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrMonEngUnrecvrFltCodV : 11|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrAttnStatCnfdc : 13|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrMonEngRecvrFltCod : 15|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrAttnStatV : 0|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - -BO_ 324 DMS_RawMeasurement_Info2_FO: 8 DMS_FO - SG_ DrvrMonFrmNum : 47|8@0+ (1,0) [0|255] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrMntrSysVTP : 29|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrMonSysEngStV : 2|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrMonSysEngSt : 28|3@0+ (1,0) [0|7] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrMonFrmNumV : 3|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrHeadRotAngZV : 4|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrHeadRotAngYV : 5|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrHeadRotAngXV : 6|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrHeadRotAngARC : 52|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrMonLatV : 7|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrMonLat : 50|11@0+ (0.001,0) [0|2.047] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvHeadRotAngZ : 25|10@0- (0.00625,0) [-3.2|3.19375] "rad" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ DrvHeadRotAngY : 23|10@0- (0.00625,0) [-3.2|3.19375] "rad" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ DrvrHeadRotAngX : 1|10@0- (0.00625,0) [-3.2|3.19375] "rad" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - -BO_ 322 DMS_RawMeasurement_Info1_FO: 8 DMS_FO - SG_ DrvrEyeClosrRt : 47|8@0+ (0.005,0) [0|1.275] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrEyeClosrLft : 39|8@0+ (0.005,0) [0|1.275] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvHeadPosZV : 3|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvHeadPosYV : 4|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvHeadPosXV : 5|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrEyeClosrRtV : 6|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrEyeClosrLftV : 7|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvrEyeClosrARC : 52|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ DrvHeadPosZ : 50|11@0- (0.005,0) [-5.12|5.115] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ DrvHeadPosY : 18|11@0- (0.005,0) [-5.12|5.115] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ DrvHeadPosX : 2|11@0- (0.005,0) [-5.12|5.115] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - -BO_ 320 Inertial2_Rates_FO: 8 _DOFIMU2_FO - SG_ MstrTgrSyncInrtl2Rte : 55|5@0+ (1,0) [0|31] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ Inertial2YawRteV : 5|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ Inertial2YawRte : 36|13@0- (0.024,0) [-98.304|98.28] "deg/s" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ Inertial2RollRteV : 6|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ Inertial2RollRte : 20|13@0- (0.024,0) [-98.304|98.28] "deg/s" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ Inertial2RteChksum : 50|11@0+ (1,0) [0|2047] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ Inertial2PitchRteV : 7|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ Inertial2PitchRte : 4|13@0- (0.024,0) [-98.304|98.28] "deg/s" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - -BO_ 308 Inertial1_Rates_FO: 8 _DOFIMU1_FO - SG_ MstrTrgrSyncInrtl1Rte : 55|5@0+ (1,0) [0|31] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ Inertial1YawRteV : 5|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ Inertial1YawRte : 36|13@0- (0.024,0) [-98.304|98.28] "deg/s" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ Inertial1RollRteV : 6|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ Inertial1RollRte : 20|13@0- (0.024,0) [-98.304|98.28] "deg/s" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ Inertial1RteChksum : 50|11@0+ (1,0) [0|2047] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ Inertial1PitchRteV : 7|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ Inertial1PitchRte : 4|13@0- (0.024,0) [-98.304|98.28] "deg/s" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - -BO_ 312 Inertial2_Accel2_FO: 8 _DOFIMU2_FO - SG_ MstrTrigSyncInrtl22 : 55|5@0+ (1,0) [0|31] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InrtlSns2AccFrm2Chksm : 50|11@0+ (1,0) [0|2047] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InrtlSnsr2YawAccV : 5|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InrtlSnsr2YawAcc : 36|13@0- (0.024,0) [-98.304|98.28] "deg/s^2" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InrtlSnsr2RollAccV : 6|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InrtlSnsr2RollAcc : 20|13@0- (0.024,0) [-98.304|98.28] "deg/s^2" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InrtlSnsr2PtchAccV : 7|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InrtlSnsr2PtchAcc : 4|13@0- (0.024,0) [-98.304|98.28] "deg/s^2" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - -BO_ 306 Inertial1_Accel2_FO: 8 _DOFIMU1_FO - SG_ MstrTrigSyncInrtl12 : 55|5@0+ (1,0) [0|31] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InrtlSnsr1AccelFrm2Chksm : 50|11@0+ (1,0) [0|2047] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InrtlSnsr1YawAccV : 5|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InrtlSnsr1YawAcc : 36|13@0- (0.024,0) [-98.304|98.28] "deg/s^2" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InrtlSnsr1RollAccV : 6|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InrtlSnsr1RollAcc : 20|13@0- (0.024,0) [-98.304|98.28] "deg/s^2" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InrtlSnsr1PtchAccV : 7|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InrtlSnsr1PtchAcc : 4|13@0- (0.024,0) [-98.304|98.28] "deg/s^2" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - -BO_ 310 Inertial2_Accel1_FO: 8 _DOFIMU2_FO - SG_ MstrTrigSyncInrtl21 : 7|5@0+ (1,0) [0|31] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ Inertial2VertAccV : 34|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ Inertial2VertAcc : 33|10@0- (0.0625,0) [-32|31.9375] "m/s^2" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ Inertial2LonAccV : 2|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ Inertial2LonAcc : 1|10@0- (0.0625,0) [-32|31.9375] "m/s^2" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ Inertial2LatAccV : 18|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ Inertial2LatAcc : 17|10@0- (0.0625,0) [-32|31.9375] "m/s^2" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ IntlSnsr2AcelFm1Chksm : 50|11@0+ (1,0) [0|2047] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - -BO_ 304 Inertial1_Accel1_FO: 8 _DOFIMU1_FO - SG_ MstrTrigSyncInrtl11 : 7|5@0+ (1,0) [0|31] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InrtlSnsr1VertAccV : 34|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InrtlSnsr1VertAcc : 33|10@0- (0.0625,0) [-32|31.9375] "m/s^2" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InrtlSnsr1LonAccV : 2|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InrtlSnsr1LonAcc : 1|10@0- (0.0625,0) [-32|31.9375] "m/s^2" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InrtlSnsr1LatAccV : 18|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InrtlSnsr1LatAcc : 17|10@0- (0.0625,0) [-32|31.9375] "m/s^2" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ IntlSnsr1AcelFm1Chksm : 50|11@0+ (1,0) [0|2047] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - -BO_ 356 Map_Pos_Correction_FO: 4 EOCM2A_K1_FO - SG_ LongErrPstn : 7|8@0- (0.5,0) [-64|63.5] "m" AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ LatErrPstn : 15|8@0- (0.5,0) [-64|63.5] "m" AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ PstnErrChcksm : 18|11@0+ (1,0) [0|2047] "" AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ PstnErrARC : 20|2@0+ (1,0) [0|3] "" AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - -BO_ 354 Map_Retrans_Request_FO: 1 EOCM2A_K1_FO - SG_ HrznPrvdRstRq : 2|1@0+ (1,0) [0|1] "" AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ ADASISRwDtMplxdCycCnt : 7|2@0+ (1,0) [0|3] "" AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ ADASISMsgTypRetrans : 5|3@0+ (1,0) [0|7] "" AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - -BO_ 352 Map_Path_Correction_FO: 6 EOCM2A_K1_FO - SG_ ExptNxtTrnstnDir : 37|3@0+ (1,0) [0|7] "" AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ MstProbLnV : 15|1@0+ (1,0) [0|1] "" AMM_FO - SG_ MstProbLn : 14|5@0+ (1,0) [0|31] "" AMM_FO - SG_ PathCrtnChcksm : 34|11@0+ (1,0) [0|2047] "" AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ PathCrtnARC : 4|2@0+ (1,0) [0|3] "" AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ EgoLnCurvV : 2|1@0+ (1,0) [0|1] "" AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ EgoLnCurv : 23|16@0- (9.53E-007,0) [-0.031227904|0.031226951] "1/m^2" AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ VehLnStatV : 1|1@0+ (1,0) [0|1] "" AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ VehLnStatConf : 6|2@0+ (1,0) [0|3] "" AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ VehLnStat : 9|2@0+ (1,0) [0|3] "" AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ ExptNxtTransDirV : 0|1@0+ (1,0) [0|1] "" AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ ExptNxtTrnstnDirConf : 39|2@0+ (1,0) [0|3] "" AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - -BO_ 264 Inertial_Trigger_FO: 1 EOCM2A_K1_FO - SG_ InrtlSnsrMstrTrgrSync : 7|5@0+ (1,0) [0|31] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,_DOFIMU2_FO,_DOFIMU1_FO - -BO_ 1156 SSID_AMM_2_FO: 8 EOCM2A_K1_FO - SG_ WiFiSSIDDgts9to16_Mp : 7|64@0+ (1,0) [0|0] "" EOCM2B_K1_FO,AMM_FO - -BO_ 1155 SSID_AMM_1_FO: 8 EOCM2A_K1_FO - SG_ WiFiSSIDDgts1to8_Mp : 7|64@0+ (1,0) [0|0] "" EOCM2B_K1_FO,AMM_FO - -BO_ 1927 DTC_Triggered_787_FO: 7 DMS_FO - SG_ DTCI_CodeSupported_787 : 40|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_CurrentStatus_787 : 41|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_DTCFailType_787 : 39|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCFaultType_787 : 55|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCNumber_787 : 23|16@0+ (1,0) [0|65535] "" TestTool_FO - SG_ DTCI_DTCSource_787 : 15|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCTriggered_787 : 0|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_HistStat_787 : 44|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldCdClrdStat_787 : 43|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldPwrUpSt_787 : 46|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdCdClrdSt_787 : 42|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdPwrUpSt_787 : 45|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused1_787 : 7|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused2_787 : 6|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused3_787 : 5|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused4_787 : 4|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused5_787 : 3|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused6_787 : 2|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused7_787 : 1|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_WrnIndRqdSt_787 : 47|1@0+ (1,0) [0|1] "" TestTool_FO - -BO_ 1926 DTC_Triggered_786_FO: 7 AMM_FO - SG_ DTCI_CodeSupported_786 : 40|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_CurrentStatus_786 : 41|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_DTCFailType_786 : 39|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCFaultType_786 : 55|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCNumber_786 : 23|16@0+ (1,0) [0|65535] "" TestTool_FO - SG_ DTCI_DTCSource_786 : 15|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCTriggered_786 : 0|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_HistStat_786 : 44|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldCdClrdStat_786 : 43|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldPwrUpSt_786 : 46|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdCdClrdSt_786 : 42|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdPwrUpSt_786 : 45|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused1_786 : 7|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused2_786 : 6|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused3_786 : 5|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused4_786 : 4|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused5_786 : 3|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused6_786 : 2|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused7_786 : 1|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_WrnIndRqdSt_786 : 47|1@0+ (1,0) [0|1] "" TestTool_FO - -BO_ 1928 DTC_Triggered_788_FO: 7 _DOFIMU1_FO - SG_ DTCI_CodeSupported_788 : 40|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_CurrentStatus_788 : 41|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_DTCFailType_788 : 39|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCFaultType_788 : 55|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCNumber_788 : 23|16@0+ (1,0) [0|65535] "" TestTool_FO - SG_ DTCI_DTCSource_788 : 15|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCTriggered_788 : 0|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_HistStat_788 : 44|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldCdClrdStat_788 : 42|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldPwrUpSt_788 : 46|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdCdClrdSt_788 : 43|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdPwrUpSt_788 : 45|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused1_788 : 7|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused2_788 : 6|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused3_788 : 5|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused4_788 : 4|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused5_788 : 3|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused6_788 : 2|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused7_788 : 1|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_WrnIndRqdSt_788 : 47|1@0+ (1,0) [0|1] "" TestTool_FO - -BO_ 1929 DTC_Triggered_789_FO: 7 _DOFIMU2_FO - SG_ DTCI_CodeSupported_789 : 40|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_CurrentStatus_789 : 41|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_DTCFailType_789 : 39|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCFaultType_789 : 55|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCNumber_789 : 23|16@0+ (1,0) [0|65535] "" TestTool_FO - SG_ DTCI_DTCSource_789 : 15|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCTriggered_789 : 0|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_HistStat_789 : 44|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldCdClrdStat_789 : 43|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldPwrUpSt_789 : 46|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdCdClrdSt_789 : 42|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdPwrUpSt_789 : 45|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused1_789 : 7|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused2_789 : 6|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused3_789 : 5|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused4_789 : 4|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused5_789 : 3|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused6_789 : 2|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused7_789 : 1|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_WrnIndRqdSt_789 : 47|1@0+ (1,0) [0|1] "" TestTool_FO - -BO_ 1352 UUDT_Resp_From_6DOFIMU2_FO: 8 _DOFIMU2_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 588 USDT_Req_to_EOCM2B_K1_FO: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" EOCM2B_K1_FO - -BO_ 1356 UUDT_Resp_From_EOCM2B_K1_FO: 8 EOCM2B_K1_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1612 USDT_Resp_From_EOCM2B_K1_FO: 8 EOCM2B_K1_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1616 USDT_Resp_From_EOCM2A_IMX6_FO: 8 EOCM2A_IMX6_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1360 UUDT_Resp_From_EOCM2A_IMX6_FO: 8 EOCM2A_IMX6_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 592 USDT_Req_to_EOCM2A_IMX6_FO: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" EOCM2A_IMX6_FO - -BO_ 1610 USDT_Resp_From_EOCM2A_K1_FO: 8 EOCM2A_K1_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1354 UUDT_Resp_From_EOCM2A_K1_FO: 8 EOCM2A_K1_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 586 USDT_Req_to_EOCM2A_K1_FO: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" EOCM2A_K1_FO - -BO_ 1925 DTC_Triggered_785_FO: 7 NVS_FO - SG_ DTCI_CodeSupported_785 : 40|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_CurrentStatus_785 : 41|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_DTCFailType_785 : 39|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCFaultType_785 : 55|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCNumber_785 : 23|16@0+ (1,0) [0|65535] "" TestTool_FO - SG_ DTCI_DTCSource_785 : 15|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCTriggered_785 : 0|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_HistStat_785 : 44|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldCdClrdStat_785 : 43|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldPwrUpSt_785 : 46|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdCdClrdSt_785 : 42|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdPwrUpSt_785 : 45|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused1_785 : 7|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused2_785 : 6|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused3_785 : 5|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused4_785 : 4|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused5_785 : 3|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused6_785 : 2|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused7_785 : 1|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_WrnIndRqdSt_785 : 47|1@0+ (1,0) [0|1] "" TestTool_FO - -BO_ 1859 VIN_Digits_10_to_17_FO: 8 EOCM_F_FO - SG_ VehIdNmDig10_17 : 7|64@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,NVS_FO - -BO_ 1857 VIN_Digits_2_to_9_FO: 8 EOCM_F_FO - SG_ VehIdNmDig2_9 : 7|64@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,NVS_FO - -BO_ 771 Outside_Air_Temperature_FO: 2 EOCM_F_FO - SG_ OtsAirTmpCrValV : 0|1@0+ (1,0) [0|1] "" NVS_FO - SG_ OtsAirTmpCrVal : 15|8@0+ (0.5,-40) [-40|87.5] "deg C" NVS_FO - -BO_ 777 Night_Vision_System_Ped_FO: 1 NVS_FO - SG_ NVSysStat : 3|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ NVSysPedWrnIndReq : 7|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ NVSysPedDetCsCrStVal : 5|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ NVSysPedDetCstStAvl : 0|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - -BO_ 607 USDT_Req_to_NVS_FO: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" NVS_FO - -BO_ 1631 USDT_Resp_From_NVS_FO: 8 NVS_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1375 UUDT_Resp_From_NVS_FO: 8 NVS_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1540 ADAS_Position_FO: 8 AMM_FO - SG_ AdvDrAstMpLatOffst : 40|9@0+ (1,-256) [-256|255] "m" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpPstnIndx : 63|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpPstnCnf : 61|3@0+ (1,0) [0|7] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpPsnIdxCrLn : 58|3@0+ (1,0) [0|7] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpPstnPthIndx : 46|6@0+ (1,0) [0|63] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpPstnProb : 31|5@0+ (3.333,0) [0|103.323] "%" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpPstnCycCnt : 26|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpPstnAge : 24|9@0+ (5,0) [0|2555] "ms" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpPstnRelHd : 23|8@0+ (1.417,0) [0|361.335] "deg" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpPstnMsgTyp : 7|3@0+ (1,0) [0|7] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - SG_ AdvDrAstMpPstnOfst : 4|13@0+ (1,0) [0|8191] "m" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO - -BO_ 1608 USDT_Resp_From_6DOFIMU2_FO: 8 _DOFIMU2_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 871 LGT_ObjectDetect_Info_8_FO: 8 VIS2_FO - SG_ GFHBFwVsnWidthTrk8 : 62|7@0+ (0.1,0) [0|12.7] "deg" EOCM_F_FO - SG_ GFHBFwVsnVertPosTrk8 : 53|6@0+ (0.25,-3) [-3|12.75] "deg" EOCM_F_FO - SG_ GFHBFwVsnRelLaneTrk8 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnAzmthRtTrk8 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ GFHBFwVsnCnfdncTrk8 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnRngTrkRev8 : 16|12@0+ (0.2,0) [0|819] "m" EOCM_F_FO - SG_ GFHBFwVsnAzmthTrkRev8 : 10|10@0- (0.05,0) [-25.6|25.55] "deg" EOCM_F_FO - SG_ GFHBFVsnObjTypTrkRev8 : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ GFHBObjDirTrk8 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ GFHBFwVsnMesStatTrk8 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnObjIDTrk8 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 870 LGT_ObjectDetect_Info_7_FO: 8 VIS2_FO - SG_ GFHBFwVsnWidthTrk7 : 62|7@0+ (0.1,0) [0|12.7] "deg" EOCM_F_FO - SG_ GFHBFwVsnVertPosTrk7 : 53|6@0+ (0.25,-3) [-3|12.75] "deg" EOCM_F_FO - SG_ GFHBFwVsnRelLaneTrk7 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnAzmthRtTrk7 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ GFHBFwVsnCnfdncTrk7 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnRngTrkRev7 : 16|12@0+ (0.2,0) [0|819] "m" EOCM_F_FO - SG_ GFHBFwVsnAzmthTrkRev7 : 10|10@0- (0.05,0) [-25.6|25.55] "deg" EOCM_F_FO - SG_ GFHBFVsnObjTypTrkRev7 : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ GFHBObjDirTrk7 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ GFHBFwVsnMesStatTrk7 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnObjIDTrk7 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 869 LGT_ObjectDetect_Info_6_FO: 8 VIS2_FO - SG_ GFHBFwVsnWidthTrk6 : 62|7@0+ (0.1,0) [0|12.7] "deg" EOCM_F_FO - SG_ GFHBFwVsnVertPosTrk6 : 53|6@0+ (0.25,-3) [-3|12.75] "deg" EOCM_F_FO - SG_ GFHBFwVsnRelLaneTrk6 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnAzmthRtTrk6 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ GFHBFwVsnCnfdncTrk6 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnRngTrkRev6 : 16|12@0+ (0.2,0) [0|819] "m" EOCM_F_FO - SG_ GFHBFwVsnAzmthTrkRev6 : 10|10@0- (0.05,0) [-25.6|25.55] "deg" EOCM_F_FO - SG_ GFHBFVsnObjTypTrkRev6 : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ GFHBObjDirTrk6 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ GFHBFwVsnMesStatTrk6 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnObjIDTrk6 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 868 LGT_ObjectDetect_Info_5_FO: 8 VIS2_FO - SG_ GFHBFwVsnWidthTrk5 : 62|7@0+ (0.1,0) [0|12.7] "deg" EOCM_F_FO - SG_ GFHBFwVsnVertPosTrk5 : 53|6@0+ (0.25,-3) [-3|12.75] "deg" EOCM_F_FO - SG_ GFHBFwVsnRelLaneTrk5 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnAzmthRtTrk5 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ GFHBFwVsnCnfdncTrk5 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnRngTrkRev5 : 16|12@0+ (0.2,0) [0|819] "m" EOCM_F_FO - SG_ GFHBFwVsnAzmthTrkRev5 : 10|10@0- (0.05,0) [-25.6|25.55] "deg" EOCM_F_FO - SG_ GFHBFVsnObjTypTrkRev5 : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ GFHBObjDirTrk5 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ GFHBFwVsnMesStatTrk5 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnObjIDTrk5 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 867 LGT_ObjectDetect_Info_4_FO: 8 VIS2_FO - SG_ GFHBFwVsnWidthTrk4 : 62|7@0+ (0.1,0) [0|12.7] "deg" EOCM_F_FO - SG_ GFHBFwVsnVertPosTrk4 : 53|6@0+ (0.25,-3) [-3|12.75] "deg" EOCM_F_FO - SG_ GFHBFwVsnRelLaneTrk4 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnAzmthRtTrk4 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ GFHBFwVsnCnfdncTrk4 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnRngTrkRev4 : 16|12@0+ (0.2,0) [0|819] "m" EOCM_F_FO - SG_ GFHBFwVsnAzmthTrkRev4 : 10|10@0- (0.05,0) [-25.6|25.55] "deg" EOCM_F_FO - SG_ GFHBFVsnObjTypTrkRev4 : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ GFHBObjDirTrk4 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ GFHBFwVsnMesStatTrk4 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnObjIDTrk4 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 866 LGT_ObjectDetect_Info_3_FO: 8 VIS2_FO - SG_ GFHBFwVsnWidthTrk3 : 62|7@0+ (0.1,0) [0|12.7] "deg" EOCM_F_FO - SG_ GFHBFwVsnVertPosTrk3 : 53|6@0+ (0.25,-3) [-3|12.75] "deg" EOCM_F_FO - SG_ GFHBFwVsnRelLaneTrk3 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnAzmthRtTrk3 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ GFHBFwVsnCnfdncTrk3 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnRngTrkRev3 : 16|12@0+ (0.2,0) [0|819] "m" EOCM_F_FO - SG_ GFHBFwVsnAzmthTrkRev3 : 10|10@0- (0.05,0) [-25.6|25.55] "deg" EOCM_F_FO - SG_ GFHBFVsnObjTypTrkRev3 : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ GFHBObjDirTrk3 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ GFHBFwVsnMesStatTrk3 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnObjIDTrk3 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 865 LGT_ObjectDetect_Info_2_FO: 8 VIS2_FO - SG_ GFHBFwVsnWidthTrk2 : 62|7@0+ (0.1,0) [0|12.7] "deg" EOCM_F_FO - SG_ GFHBFwVsnVertPosTrk2 : 53|6@0+ (0.25,-3) [-3|12.75] "deg" EOCM_F_FO - SG_ GFHBFwVsnRelLaneTrk2 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnAzmthRtTrk2 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ GFHBFwVsnCnfdncTrk2 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnRngTrkRev2 : 16|12@0+ (0.2,0) [0|819] "m" EOCM_F_FO - SG_ GFHBFwVsnAzmthTrkRev2 : 10|10@0- (0.05,0) [-25.6|25.55] "deg" EOCM_F_FO - SG_ GFHBFVsnObjTypTrkRev2 : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ GFHBFwVsnMesStatTrk2 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBObjDirTrk2 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ GFHBFwVsnObjIDTrk2 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 864 LGT_ObjectDetect_Info_1_FO: 8 VIS2_FO - SG_ GFHBFwVsnWidthTrk1 : 62|7@0+ (0.1,0) [0|12.7] "deg" EOCM_F_FO - SG_ GFHBFwVsnVertPosTrk1 : 53|6@0+ (0.25,-3) [-3|12.75] "deg" EOCM_F_FO - SG_ GFHBFwVsnRelLaneTrk1 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnAzmthRtTrk1 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ GFHBFwVsnCnfdncTrk1 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnRngTrkRev1 : 16|12@0+ (0.2,0) [0|819] "m" EOCM_F_FO - SG_ GFHBFwVsnAzmthTrkRev1 : 10|10@0- (0.05,0) [-25.6|25.55] "deg" EOCM_F_FO - SG_ GFHBFVsnObjTypTrkRev1 : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ GFHBObjDirTrk1 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ GFHBFwVsnMesStatTrk1 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ GFHBFwVsnObjIDTrk1 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 1915 DTC_Triggered_77B_FO: 7 VIS_FO - SG_ DTCI_DTCFaultType_77B : 55|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_CodeSupported_77B : 40|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_CurrentStatus_77B : 41|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdCdClrdSt_77B : 42|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldCdClrdStat_77B : 43|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_HistStat_77B : 44|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdPwrUpSt_77B : 45|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldPwrUpSt_77B : 46|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_WrnIndRqdSt_77B : 47|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_DTCFailType_77B : 39|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCNumber_77B : 23|16@0+ (1,0) [0|65535] "" TestTool_FO - SG_ DTCI_DTCSource_77B : 15|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCTriggered_77B : 0|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused7_77B : 1|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused6_77B : 2|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused5_77B : 3|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused4_77B : 4|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused3_77B : 5|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused2_77B : 6|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused1_77B : 7|1@0+ (1,0) [0|1] "" TestTool_FO - -BO_ 1923 DTC_Triggered_783_FO: 7 RSRR_FO - SG_ DTCI_WrnIndRqdSt_783 : 47|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdPwrUpSt_783 : 45|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdCdClrdSt_783 : 42|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldPwrUpSt_783 : 46|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldCdClrdStat_783 : 43|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_HistStat_783 : 44|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_DTCTriggered_783 : 0|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_DTCSource_783 : 15|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCNumber_783 : 23|16@0+ (1,0) [0|65535] "" TestTool_FO - SG_ DTCI_DTCFaultType_783 : 55|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCFailType_783 : 39|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_CurrentStatus_783 : 41|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_CodeSupported_783 : 40|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused7_783 : 1|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused6_783 : 2|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused5_783 : 3|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused4_783 : 4|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused3_783 : 5|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused2_783 : 6|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused1_783 : 7|1@0+ (1,0) [0|1] "" TestTool_FO - -BO_ 1924 DTC_Triggered_784_FO: 7 RRSRR_FO - SG_ DTCI_HistStat_784 : 44|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldCdClrdStat_784 : 43|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldPwrUpSt_784 : 46|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdCdClrdSt_784 : 42|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdPwrUpSt_784 : 45|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused1_784 : 7|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused2_784 : 6|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused3_784 : 5|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused4_784 : 4|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused5_784 : 3|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused6_784 : 2|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused7_784 : 1|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_WrnIndRqdSt_784 : 47|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_CodeSupported_784 : 40|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_CurrentStatus_784 : 41|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_DTCFailType_784 : 39|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCFaultType_784 : 55|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCNumber_784 : 23|16@0+ (1,0) [0|65535] "" TestTool_FO - SG_ DTCI_DTCSource_784 : 15|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCTriggered_784 : 0|1@0+ (1,0) [0|1] "" TestTool_FO - -BO_ 1922 DTC_Triggered_782_FO: 7 RFSRR_FO - SG_ DTCI_WrnIndRqdSt_782 : 47|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused7_782 : 1|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused6_782 : 2|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused5_782 : 3|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused4_782 : 4|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused3_782 : 5|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused2_782 : 6|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused1_782 : 7|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdPwrUpSt_782 : 45|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdCdClrdSt_782 : 42|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldPwrUpSt_782 : 46|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldCdClrdStat_782 : 43|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_HistStat_782 : 44|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_DTCTriggered_782 : 0|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_DTCSource_782 : 15|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCNumber_782 : 23|16@0+ (1,0) [0|65535] "" TestTool_FO - SG_ DTCI_DTCFaultType_782 : 55|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCFailType_782 : 39|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_CurrentStatus_782 : 41|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_CodeSupported_782 : 40|1@0+ (1,0) [0|1] "" TestTool_FO - -BO_ 1920 DTC_Triggered_780_FO: 7 LRR_FO - SG_ DTCI_CurrentStatus_780 : 41|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_WrnIndRqdSt_780 : 47|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused7_780 : 1|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused6_780 : 2|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused5_780 : 3|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused4_780 : 4|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused3_780 : 5|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused2_780 : 6|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused1_780 : 7|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdPwrUpSt_780 : 45|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdCdClrdSt_780 : 42|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldPwrUpSt_780 : 46|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldCdClrdStat_780 : 43|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_HistStat_780 : 44|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_DTCTriggered_780 : 0|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_DTCSource_780 : 15|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCNumber_780 : 23|16@0+ (1,0) [0|65535] "" TestTool_FO - SG_ DTCI_DTCFaultType_780 : 55|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCFailType_780 : 39|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_CodeSupported_780 : 40|1@0+ (1,0) [0|1] "" TestTool_FO - -BO_ 1921 DTC_Triggered_781_FO: 7 LFSRR_FO - SG_ DTCI_CurrentStatus_781 : 41|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_WrnIndRqdSt_781 : 47|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused7_781 : 1|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused6_781 : 2|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused5_781 : 3|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused4_781 : 4|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused3_781 : 5|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused2_781 : 6|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCIUnused1_781 : 7|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdPwrUpSt_781 : 45|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstNPsdCdClrdSt_781 : 42|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldPwrUpSt_781 : 46|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_TstFldCdClrdStat_781 : 43|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_HistStat_781 : 44|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_DTCTriggered_781 : 0|1@0+ (1,0) [0|1] "" TestTool_FO - SG_ DTCI_DTCSource_781 : 15|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCNumber_781 : 23|16@0+ (1,0) [0|65535] "" TestTool_FO - SG_ DTCI_DTCFaultType_781 : 55|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_DTCFailType_781 : 39|8@0+ (1,0) [0|255] "" TestTool_FO - SG_ DTCI_CodeSupported_781 : 40|1@0+ (1,0) [0|1] "" TestTool_FO - -BO_ 1034 Curvature_Right_Line_FO: 7 VIS2_FO - SG_ CRL_Cnfdnc : 50|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM_F_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ CRL_ViewRng : 33|15@0+ (0.0039064,0) [0|128.0010088] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM_F_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ CRL_CoefdA : 17|16@0- (3.6622E-009,0) [-0.0001200029696|0.0001199993074] "1/m^2" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM_F_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ CRL_CoefA : 1|16@0- (6.1036E-007,0) [-0.02000027648|0.01999966612] "1/m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM_F_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - -BO_ 1033 Curvature_Left_Line_FO: 7 VIS2_FO - SG_ CLL_Cnfdnc : 50|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM_F_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ CLL_ViewRng : 33|15@0+ (0.0039064,0) [0|128.0010088] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM_F_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ CLL_CoefdA : 17|16@0- (3.6622E-009,0) [-0.0001200029696|0.0001199993074] "1/m^2" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM_F_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ CLL_CoefA : 1|16@0- (6.1036E-007,0) [-0.02000027648|0.01999966612] "1/m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM_F_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - -BO_ 1365 UUDT_Resp_From_VIS2_FO: 8 VIS2_FO - SG_ DgnInf_OBJ555 : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1621 USDT_Resp_From_VIS2_FO: 8 VIS2_FO - SG_ DgnInf_OBJ655 : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1094 F_Vision_Obj_Track_12: 8 VIS2_FO - SG_ FwdVsnObjTypTr12Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ FwdVsnAzmthTrk12Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO - SG_ FwdVsnRngTrk12Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO - SG_ FVisionWidthTrk12 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FVisionMeasStatTrk12 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnVertPosTrk12 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO - SG_ FVisionRelLaneTrk12 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionAzRateTrk12 : 34|11@0- (0.125,0) [-128|127.875] "deg/sec" EOCM_F_FO - SG_ FVisionConfTrk12 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ ObjDirTrk12 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FVisBurstIDTrk12 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionObjectIDTrk12 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 1093 F_Vision_Obj_Track_11: 8 VIS2_FO - SG_ FwdVsnObjTypTr11Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ FwdVsnAzmthTrk11Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO - SG_ FwdVsnRngTrk11Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO - SG_ FVisionWidthTrk11 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FVisionMeasStatTrk11 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnVertPosTrk11 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO - SG_ FVisionRelLaneTrk11 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionAzRateTrk11 : 34|11@0- (0.125,0) [-128|127.875] "deg/sec" EOCM_F_FO - SG_ FVisionConfTrk11 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ ObjDirTrk11 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FVisBurstIDTrk11 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionObjectIDTrk11 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 1100 F_Vision_Obj_Track_12_B: 8 VIS2_FO - SG_ FwVsnCinCoutPotT12Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnObjAgeTrk12 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO - SG_ FwdVsnLongVlctyTrk12 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO - SG_ FwdVsnLatOfstTrk12 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO - SG_ FwdVsnBrkLtStatTrk12 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnTrnSigStatTr12 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FwdVsnObjSclChgTrk12 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO - SG_ FrtVsnBrstIDAddInfo12 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1099 F_Vision_Obj_Track_11_B: 8 VIS2_FO - SG_ FwVsnCinCoutPotT11Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnObjAgeTrk11 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO - SG_ FwdVsnLongVlctyTrk11 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO - SG_ FwdVsnLatOfstTrk11 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO - SG_ FwdVsnBrkLtStatTrk11 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnTrnSigStatTr11 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FwdVsnObjSclChgTrk11 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO - SG_ FrtVsnBrstIDAddInfo11 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1098 F_Vision_Obj_Track_10_B: 8 VIS2_FO - SG_ FwVsnCinCoutPotT10Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnObjAgeTrk10 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO - SG_ FwdVsnLongVlctyTrk10 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO - SG_ FwdVsnLatOfstTrk10 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO - SG_ FwdVsnBrkLtStatTrk10 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnTrnSigStatTr10 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FwdVsnObjSclChgTrk10 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO - SG_ FrtVsnBrstIDAddInfo10 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1097 F_Vision_Obj_Track_9_B: 8 VIS2_FO - SG_ FwVsnCinCoutPotT9Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnObjAgeTrk9 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO - SG_ FwdVsnLongVlctyTrk9 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO - SG_ FwdVsnLatOfstTrk9 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO - SG_ FwdVsnBrkLtStatTrk9 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnTrnSigStatTr9 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FwdVsnObjSclChgTrk9 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO - SG_ FrtVsnBrstIDAddInfo9 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1096 F_Vision_Obj_Track_8_B: 8 VIS2_FO - SG_ FwVsnCinCoutPotT8Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnObjAgeTrk8 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO - SG_ FwdVsnLongVlctyTrk8 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO - SG_ FwdVsnLatOfstTrk8 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO - SG_ FwdVsnBrkLtStatTrk8 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnTrnSigStatTr8 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FwdVsnObjSclChgTrk8 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO - SG_ FrtVsnBrstIDAddInfo8 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1095 F_Vision_Obj_Track_7_B: 8 VIS2_FO - SG_ FwVsnCinCoutPotT7Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnObjAgeTrk7 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO - SG_ FwdVsnLongVlctyTrk7 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO - SG_ FwdVsnLatOfstTrk7 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO - SG_ FwdVsnBrkLtStatTrk7 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnTrnSigStatTr7 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FwdVsnObjSclChgTrk7 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO - SG_ FrtVsnBrstIDAddInfo7 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 863 F_Vision_GFHB_Data_FO: 8 VIS2_FO - SG_ RgDtLgtSrcHrtAngl : 49|10@0- (0.04,0) [-20.48|20.44] "deg" EOCM_F_FO - SG_ RgDtLgtSrcHrtAngVcty : 55|6@0- (1,0) [-32|31] "deg/sec" EOCM_F_FO - SG_ LfDtLgtSrcHrtAngl : 33|10@0- (0.04,0) [-20.48|20.44] "deg" EOCM_F_FO - SG_ LfDtLgtSrcHrtAnVcty : 39|6@0- (1,0) [-32|31] "deg/sec" EOCM_F_FO - SG_ AdvWthrStat : 25|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ DtctdLghtSrcDstnc : 22|7@0+ (10,0) [0|1270] "m" EOCM_F_FO - SG_ DtctdLghtSrcVrtclAngl : 1|10@0- (0.04,0) [-20.48|20.44] "deg" EOCM_F_FO - SG_ IntLghtRngAct : 2|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ DtctdLghtSrcDstncV : 3|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ TwnDtctnSts : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ DtctdLghtSrcDrvngDrctn : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 862 LGT_ControlHighBeamGlare_FO: 2 VIS2_FO - SG_ FwdCamSysOpStat : 10|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ EnvIllum : 2|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RdTyp : 5|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ AutoHgBmSts : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1068 F_Vision_Obj_Track_6_B: 8 VIS2_FO - SG_ FwVsnCinCoutPotT6Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnObjAgeTrk6 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO - SG_ FwdVsnLongVlctyTrk6 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO - SG_ FwdVsnLatOfstTrk6 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO - SG_ FwdVsnBrkLtStatTrk6 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnTrnSigStatTr6 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FwdVsnObjSclChgTrk6 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO - SG_ FrtVsnBrstIDAddInfo6 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1067 F_Vision_Obj_Track_5_B: 8 VIS2_FO - SG_ FwVsnCinCoutPotT5Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnObjAgeTrk5 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO - SG_ FwdVsnLongVlctyTrk5 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO - SG_ FwdVsnLatOfstTrk5 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO - SG_ FwdVsnBrkLtStatTrk5 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnTrnSigStatTr5 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FwdVsnObjSclChgTrk5 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO - SG_ FrtVsnBrstIDAddInfo5 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1066 F_Vision_Obj_Track_4_B: 8 VIS2_FO - SG_ FwVsnCinCoutPotT4Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnObjAgeTrk4 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO - SG_ FwdVsnLongVlctyTrk4 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO - SG_ FwdVsnLatOfstTrk4 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO - SG_ FwdVsnBrkLtStatTrk4 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnTrnSigStatTr4 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FwdVsnObjSclChgTrk4 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO - SG_ FrtVsnBrstIDAddInfo4 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1065 F_Vision_Obj_Track_3_B: 8 VIS2_FO - SG_ FwVsnCinCoutPotT3Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnObjAgeTrk3 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO - SG_ FwdVsnLongVlctyTrk3 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO - SG_ FwdVsnLatOfstTrk3 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO - SG_ FwdVsnBrkLtStatTrk3 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnTrnSigStatTr3 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FwdVsnObjSclChgTrk3 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO - SG_ FrtVsnBrstIDAddInfo3 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1064 F_Vision_Obj_Track_2_B: 8 VIS2_FO - SG_ FwVsnCinCoutPotT2Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnObjAgeTrk2 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO - SG_ FwdVsnLongVlctyTrk2 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO - SG_ FwdVsnLatOfstTrk2 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO - SG_ FwdVsnBrkLtStatTrk2 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnTrnSigStatTr2 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FwdVsnObjSclChgTrk2 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO - SG_ FrtVsnBrstIDAddInfo2 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1063 F_Vision_Obj_Track_1_B: 8 VIS2_FO - SG_ FwVsnCinCoutPotT1Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnObjSclChgTrk1 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO - SG_ FwdVsnObjAgeTrk1 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO - SG_ FwdVsnLongVlctyTrk1 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO - SG_ FwdVsnLatOfstTrk1 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO - SG_ FwdVsnBrkLtStatTrk1 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FwdVsnTrnSigStatTr1 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FrtVsnBrstIDAddInfo1 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1151 Long_Range_Radar_add_Info_5_FO: 8 LRR_FO - SG_ FrtRdrRdEdgLtLatRdEdgDst : 63|8@0- (0.1,0) [-12.8|12.7] "m/m" EOCM_F_FO - SG_ FrtRdrRdEdgLtCrvtPrvDst : 5|4@0+ (10,0) [0|150] "" EOCM_F_FO - SG_ FrtRdrRdEdgLtTanHdgAng : 15|8@0- (0.002,0) [-0.256|0.254] "m/m" EOCM_F_FO - SG_ FrtRdrRdEdgLtCrvtV : 48|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FrtRdrRdEdgLtCrvtGradV : 0|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FrtRdrRdEdgLtCrvtGrad : 39|16@0- (5.96E-008,0) [-0.0019529728|0.0019529132] "1/(m*sec)" EOCM_F_FO - SG_ FrtRdrRdEdgLtCrvtConf : 55|7@0+ (0.7874016,0) [0|100.0000032] "%" EOCM_F_FO - SG_ FrtRdrRdEdgLtCrvt : 23|16@0- (9.53E-007,0) [-0.031227904|0.031226951] "1/m" EOCM_F_FO - SG_ FrtRdrRdEdgLtTanHdgAngV : 1|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRAddInfo5BurstID : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1150 Long_Range_Radar_add_Info_4_FO: 8 LRR_FO - SG_ FrtRdrRdEdgRtLatRdEdgDst : 63|8@0- (0.1,0) [-12.8|12.7] "m/m" EOCM_F_FO - SG_ FrtRdrRdEdgRtCrvtPrvDst : 5|4@0+ (10,0) [0|150] "" EOCM_F_FO - SG_ FrtRdrRdEdgRtTanHdgAngV : 1|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FrtRdrRdEdgRtTanHdgAng : 15|8@0- (0.002,0) [-0.256|0.254] "m/m" EOCM_F_FO - SG_ FrtRdrRdEdgRtCrvtV : 48|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FrtRdrRdEdgRtCrvtGradV : 0|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FrtRdrRdEdgRtCrvtGrad : 39|16@0- (5.96E-008,0) [-0.0019529728|0.0019529132] "1/(m*sec)" EOCM_F_FO - SG_ FrtRdrRdEdgRtCrvtConf : 55|7@0+ (0.7874016,0) [0|100.0000032] "%" EOCM_F_FO - SG_ FrtRdrRdEdgRtCrvt : 23|16@0- (9.53E-007,0) [-0.031227904|0.031226951] "1/m" EOCM_F_FO - SG_ FLRRAddInfo4BurstID : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1088 F_Vision_Obj_Header_2: 8 VIS2_FO - SG_ FrntVsnInPthVehBrkNwSt : 35|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ FrntVsnClostPedBrkNwSt : 39|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ FrntVsnClostPedObjID : 29|6@0+ (1,0) [0|63] "" EOCM_F_FO - SG_ FrntVsnClostPedAlrtNwFlg : 30|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FrntVsnClostPedNotftnFlg : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FrntVsnInPthVehAlrtNwFlg : 2|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FrtVsnVldTgtNum2 : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ FrtVsnTmStmp2V : 31|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FrtVsnTmStmp2 : 10|11@0+ (1,0) [0|2047] "" EOCM_F_FO - SG_ FrtVsnRollCnt2 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FrtVsnBrstChksum2 : 55|16@0+ (1,0) [0|65535] "" EOCM_F_FO - -BO_ 854 F_Vision_Environment_7: 3 VIS2_FO - SG_ FwdVsnCnstrctAreaDst : 13|4@0+ (10,0) [0|150] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ FwdVsnCnstrctZnDet : 15|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ FwdVsnEgoVehLnPos : 17|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ FwdVsnRdTypDet : 9|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ FwdVsnTunnlDetd : 23|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ FwdVsnTunnlDst : 21|4@0+ (10,0) [0|150] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsBrstID5 : 1|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - -BO_ 853 F_Vision_Environment_6: 8 VIS2_FO - SG_ LnMrkg4LnSnsLnHdngTngtV : 7|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg4LnSnsLnHdngTngt : 23|8@0- (0.002,0) [-0.256|0.254] "m/m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg4LnSnsLnDstV : 56|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg4LnSnsLnDst : 15|8@0- (0.1,0) [-12.8|12.7] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg4LnSnsLnCrvtV : 6|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg4LnSnsLnCrvtGradV : 5|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg4LnSnsLnCrvtGrad : 47|16@0- (5.96E-008,0) [-0.0019529728|0.0019529132] "1/(m*sec)" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg4LnSnsLnCrvt : 31|16@0- (9.53E-007,0) [-0.031227904|0.031226951] "1/m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg4LnQltyConfLvl : 63|7@0+ (0.7874016,0) [0|100.0000032] "%" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg4LnMrkrTyp : 4|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsBrstID4 : 1|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - -BO_ 852 F_Vision_Environment_5: 8 VIS2_FO - SG_ LnMrkg3LnSnsLnHdngTngtV : 7|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg3LnSnsLnHdngTngt : 23|8@0- (0.002,0) [-0.256|0.254] "m/m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg3LnSnsLnDstV : 56|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg3LnSnsLnDst : 15|8@0- (0.1,0) [-12.8|12.7] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg3LnSnsLnCrvtV : 6|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg3LnSnsLnCrvtGradV : 5|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg3LnSnsLnCrvtGrad : 47|16@0- (5.96E-008,0) [-0.0019529728|0.0019529132] "1/(m*sec)" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg3LnSnsLnCrvt : 31|16@0- (9.53E-007,0) [-0.031227904|0.031226951] "1/m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg3LnQltyConfLvl : 63|7@0+ (0.7874016,0) [0|100.0000032] "%" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg3LnMrkrTyp : 4|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsBrstID3 : 1|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - -BO_ 602 USDT_Req_to_RRSRR: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" RRSRR_FO - -BO_ 1626 USDT_Resp_From_RRSRR: 8 RRSRR_FO - SG_ DgnInf_OBJ65A : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1370 UUDT_Resp_From_RRSRR: 8 RRSRR_FO - SG_ DgnInf_OBJ55A : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1536 RR_SRR_Trace_data: 8 RRSRR_FO - SG_ RRSRRYear : 7|8@0+ (1,0) [0|0] "" EOCM_F_FO - SG_ RRSRRSerialNmbr : 39|32@0+ (1,0) [0|0] "" EOCM_F_FO - SG_ RRSRRJulianDate : 15|24@0+ (1,0) [0|0] "" EOCM_F_FO - -BO_ 1210 RR_SRR_Object_Track10: 8 RRSRR_FO - SG_ RRSrrTrkRawAzimuth10 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - SG_ RRSrrTrkRRate10 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RRSrrTrkRange10 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RRSrrTrkObsRange10 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RRSrrTrkObjID10 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RRSrrTrkObjElevation10 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkMeasStatus10 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkDynamProp10 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RRSrrTrkAzimuth10 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RRSrrBurstID10 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1209 RR_SRR_Object_Track9: 8 RRSRR_FO - SG_ RRSrrTrkRawAzimuth9 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - SG_ RRSrrTrkRRate9 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RRSrrTrkRange9 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RRSrrTrkObsRange9 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RRSrrTrkObjID9 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RRSrrTrkObjElevation9 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkMeasStatus9 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkDynamProp9 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RRSrrTrkAzimuth9 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RRSrrBurstID9 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1208 RR_SRR_Object_Track8: 8 RRSRR_FO - SG_ RRSrrTrkRawAzimuth8 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - SG_ RRSrrTrkRRate8 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RRSrrTrkRange8 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RRSrrTrkObsRange8 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RRSrrTrkObjID8 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RRSrrTrkObjElevation8 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkMeasStatus8 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkDynamProp8 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RRSrrTrkAzimuth8 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RRSrrBurstID8 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1207 RR_SRR_Object_Track7: 8 RRSRR_FO - SG_ RRSrrTrkRawAzimuth7 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - SG_ RRSrrTrkRRate7 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RRSrrTrkRange7 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RRSrrTrkObsRange7 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RRSrrTrkObjID7 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RRSrrTrkObjElevation7 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkMeasStatus7 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkDynamProp7 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RRSrrTrkAzimuth7 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RRSrrBurstID7 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1206 RR_SRR_Object_Track6: 8 RRSRR_FO - SG_ RRSrrTrkRawAzimuth6 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - SG_ RRSrrTrkRRate6 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RRSrrTrkRange6 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RRSrrTrkObsRange6 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RRSrrTrkObjID6 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RRSrrTrkObjElevation6 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkMeasStatus6 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkDynamProp6 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RRSrrTrkAzimuth6 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RRSrrBurstID6 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1205 RR_SRR_Object_Track5: 8 RRSRR_FO - SG_ RRSrrTrkRawAzimuth5 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - SG_ RRSrrTrkRRate5 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RRSrrTrkRange5 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RRSrrTrkObsRange5 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RRSrrTrkObjID5 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RRSrrTrkObjElevation5 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkMeasStatus5 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkDynamProp5 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RRSrrTrkAzimuth5 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RRSrrBurstID5 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 262 LHT_AutoHighBeamAssistStatus_FO: 5 EOCM_F_FO - SG_ NtVsnSysEnbld : 6|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,NVS_FO - SG_ VehMovState : 5|3@0+ (1,0) [0|7] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,NVS_FO - SG_ NVSysPedDetCstReq : 2|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,NVS_FO - SG_ StrWhAngV : 8|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,NVS_FO,VIS_FO - SG_ StrWhAngMsk : 9|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS_FO - SG_ StrWhAng : 23|16@0- (0.0625,0) [-2048|2047.9375] "deg" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,NVS_FO,VIS_FO - SG_ RtTrnLmpAtv : 13|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS_FO - SG_ MpDataAvlbl : 0|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS_FO - SG_ LftTrnLmpAtv : 11|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS_FO - SG_ HdlmpBmSelectStat : 33|2@0+ (1,0) [0|3] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS_FO - SG_ BldUpArDet : 14|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS_FO - SG_ FrFogLmpsAct : 15|1@0+ (1,0) [0|1] "" EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,NVS_FO,VIS_FO - -BO_ 309 LHT_CameraObjConfirmation_FO: 1 VIS_FO - SG_ HiBmRecmnd : 1|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ CtLghtDet : 0|1@0+ (1,0) [0|1] "" EOCM_F_FO - -BO_ 2034 CCP_Data_Transmission_Object_FO: 8 VIS2_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 2032 CCP_Command_Receive_Object_FO: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" VIS2_FO - -BO_ 1362 F_Vis_Obj_Conf_CPS_1B: 8 EOCM_F_FO - SG_ FObjConfCPSTrkObjectIDB : 7|6@0+ (1,0) [0|63] "" VIS_FO - SG_ CPSVisConfLonPos1 : 20|12@0- (0.125,0) [-256|255.875] "m" VIS_FO - SG_ CPSVisConfLatPos1 : 15|10@0- (0.125,0) [-64|63.875] "m" VIS_FO - SG_ CPSVisConfChecksum : 50|11@0+ (1,0) [0|2047] "" VIS_FO - SG_ FObjConfCPSTrkRangeRate : 45|11@0- (0.125,0) [-128|127.875] "m/s" VIS_FO - SG_ CPSConfTimeStamp : 24|11@0+ (1,0) [0|2047] "ms" VIS_FO - SG_ CPSConfTimeStampV : 21|1@0+ (1,0) [0|1] "" VIS_FO - SG_ FObjConfCPSRollingTrkCnt : 1|2@0+ (1,0) [0|3] "" VIS_FO - -BO_ 1413 TOS_ACC_IDS: 5 EOCM_F_FO - SG_ TOS_ACC_IDSRollCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ TOS_ACC_IDSFuncState : 5|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ TOS_ACC_ID1 : 3|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ TOS_ACC_ID2 : 13|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ TOS_ACC_ID3 : 23|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ TOS_ACC_ID4 : 17|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ TOS_ACC_ID5 : 27|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ TOS_ACC_ID6 : 37|6@0+ (1,0) [0|63] "" Dummy_FO - -BO_ 1412 F_ACC_Target: 8 EOCM_F_FO - SG_ FACCTOSRollCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FACCTOSFuncState : 5|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FACCTOSLongPos : 3|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - SG_ FACCTOSLatPos : 23|11@0- (0.125,0) [-128|127.875] "m" Dummy_FO - SG_ FACCTOSMeasStat : 28|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FACCTOSLongVel : 26|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FACCTOSTrgtDecelFlg : 47|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FACCTOSDynProp : 46|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FACCTOSLatVel : 42|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FACCTOSRelLane : 63|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FACCTOSHiThrtID : 61|6@0+ (1,0) [0|63] "" Dummy_FO - -BO_ 1409 F_CPS_TOS_B: 8 EOCM_F_FO - SG_ CPSTOSObjType : 7|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ CPSTOSHiThrtPriNo : 60|5@0+ (1,0) [0|31] "" Dummy_FO - SG_ CPSTOSRelLongAcc : 53|9@0- (0.125,0) [-32|31.875] "m/s^2" Dummy_FO - SG_ CPSTOSConfAsmt : 21|12@0+ (1,0) [0|4095] "" Dummy_FO - SG_ CPSTOSNumCycTrkd : 4|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ CPSTOSTimeToColl : 1|12@0+ (0.025,0) [0|102.375] "s" Dummy_FO - SG_ CPSTOSClosestInPthVehRng : 47|10@0+ (0.25,0) [0|255.75] "m" Dummy_FO - SG_ CPSTOSClosestInPthObID : 37|6@0+ (1,0) [0|63] "m" Dummy_FO - SG_ CPSTOSMeasStat : 39|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ CPSTOSFuncState : 25|2@0+ (1,0) [0|3] "" Dummy_FO - -BO_ 1408 F_CPS_TOS_A: 8 EOCM_F_FO - SG_ CPSTOSLongPos : 7|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - SG_ CPSTOSLatPos : 11|11@0- (0.125,0) [-128|127.875] "m" Dummy_FO - SG_ CPSTOSLongVel : 16|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ CPSTOSDynProp : 37|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ CPSTOSLatVel : 34|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ CPSTOSARelLane : 63|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ CPSTOSHiThrtID : 61|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ CPSTOSHighestThreatObAsmt : 55|8@0+ (1,0) [0|255] "" Dummy_FO - -BO_ 1344 FLPEstimate: 8 EOCM_F_FO - SG_ FLPRollCount : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ NewLaneIndex : 5|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ VehPathInOK : 3|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ LaneSnsInOK : 2|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ MapInOK : 1|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FWDObjFusInOK : 0|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ LngthFrstSeg : 15|4@0+ (10,0) [0|150] "m" Dummy_FO - SG_ LngthScndSeg : 11|4@0+ (10,0) [0|150] "m" Dummy_FO - SG_ CurvFrstSeg : 23|13@0- (5E-005,0) [-0.2048|0.20475] "1/m" Dummy_FO - SG_ CurvScndSeg : 26|3@0- (0.001,0) [-0.004|0.003] "1/m" Dummy_FO - SG_ OffstLaneCntr : 39|8@0- (0.05,0) [-6.4|6.35] "m" Dummy_FO - SG_ TngntLaneHead : 47|8@0- (0.002,0) [-0.256|0.254] "m/m" Dummy_FO - SG_ LaneWidth : 55|8@0+ (0.05,0) [0|12.75] "m" Dummy_FO - SG_ FLPDataTimeStampV : 63|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FLPDataTimeStamp : 62|7@0+ (16,0) [0|2032] "ms" Dummy_FO - -BO_ 770 F_Fwd_Collision_Alert: 8 EOCM_F_FO - SG_ Vpath_Accel : 51|11@0- (0.125,0) [-128|127.875] "m/s^2" NVS_FO,Dummy_FO - SG_ FCA_Ra : 7|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - SG_ FCA_Range : 11|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - SG_ FCA_AlertLevel : 44|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FCA_Alert_Sup : 31|16@0+ (1,0) [0|65535] "" Dummy_FO - SG_ FCAStatus : 46|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FCA_VehAhead : 47|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FCA_CPS_Alert : 42|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FCAChime : 41|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FCADiagOK : 40|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ NBSMS_Alert : 55|1@0+ (1,0) [0|1] "" Dummy_FO - -BO_ 1601 USDT_Resp_From_VIS: 8 VIS_FO - SG_ DgnInf_OBJ641 : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1606 USDT_Resp_From_RFSRR: 8 RFSRR_FO - SG_ DgnInf_OBJ646 : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1603 USDT_Resp_From_LFSRR: 8 LFSRR_FO - SG_ DgnInf_OBJ643 : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1602 USDT_Resp_From_LRR: 8 LRR_FO - SG_ DgnInf_OBJ642 : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1625 USDT_Resp_From_RSRR: 8 RSRR_FO - SG_ DgnInf_OBJ644 : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1611 USDT_Resp_From_FEOCM_FO: 8 EOCM_F_FO - SG_ DgnInf_OBJ64B : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 768 F_Smgr_Vehicle_Motion: 8 EOCM_F_FO - SG_ SmgrMotRollAngle : 44|10@0- (0.1,0) [-51.2|51.1] "deg" CIPM_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS_FO - SG_ SmgrMotRollAngleV : 0|1@0+ (1,0) [0|1] "" CIPM_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS_FO - SG_ SmgrMotChecksum : 50|11@0+ (1,0) [0|2047] "" CIPM_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS_FO - SG_ SmgrMotPitchAngle : 39|11@0- (0.1,0) [-102.4|102.3] "deg" CIPM_FO,NVS_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS_FO - SG_ SmgrMotPitchAngleV : 1|1@0+ (1,0) [0|1] "" CIPM_FO,NVS_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS_FO - SG_ SmgrMotLongSpeedV : 2|1@0+ (1,0) [0|1] " " CIPM_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS_FO - SG_ SmgrMotLongSpeed : 18|11@0- (0.1,0) [-102.4|102.3] "m/s" CIPM_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS_FO - SG_ SmgrMotYawRate : 14|12@0- (0.05,0) [-102.4|102.35] "deg/s" CIPM_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS_FO - SG_ SmgrMotYawRateV : 15|1@0+ (1,0) [0|1] "" CIPM_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS_FO - SG_ SmgrMotRollingCnt : 4|2@0+ (1,0) [0|3] "" CIPM_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS_FO - -BO_ 1350 UUDT_Resp_From_RFSRR: 8 RFSRR_FO - SG_ DgnInf_OBJ546 : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1369 UUDT_Resp_From_RSRR: 8 RSRR_FO - SG_ DgnInf_OBJ544 : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1347 UUDT_Resp_From_LFSRR: 8 LFSRR_FO - SG_ DgnInf_OBJ543 : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1346 UUDT_Resp_From_LRR: 8 LRR_FO - SG_ DgnInf_OBJ542 : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1345 UUDT_Resp_From_VIS: 8 VIS_FO - SG_ DgnInf_OBJ541 : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 579 USDT_Req_to_LFSRR: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" LFSRR_FO - -BO_ 577 USDT_Req_to_VIS: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" VIS_FO - -BO_ 578 USDT_Req_to_LRR: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" LRR_FO - -BO_ 582 USDT_Req_to_RFSRR: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" RFSRR_FO - -BO_ 601 USDT_Req_to_RSRR: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" RSRR_FO - -BO_ 1355 UUDT_Resp_From_FEOCM_FO: 8 EOCM_F_FO - SG_ DgnInf_OBJ54B : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 587 USDT_Req_to_FEOCM_obj: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" EOCM2A_K2_FO,EOCM_F_FO - -BO_ 784 Body_Info_FOB: 6 EOCM_F_FO - SG_ StrgColUpDwnPos : 39|8@0+ (1,0) [0|255] "" DMS_FO - SG_ CPMAPINFO4 : 47|1@0+ (1,0) [0|1] "" DMS_FO - SG_ StrgColInOutPos : 31|8@0+ (1,0) [0|255] "" DMS_FO - SG_ StrgColCommsFlt : 19|2@0+ (1,0) [0|3] "" DMS_FO - SG_ DrDoorOpenSwActV : 16|1@0+ (1,0) [0|1] "" DMS_FO - SG_ DrDoorOpenSwAct : 17|1@0+ (1,0) [0|1] "" DMS_FO - SG_ DrvWndPosStat : 22|3@0+ (1,0) [0|7] "" CIPM_FO,DMS_FO,VIS2_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ InterLghtStat : 23|1@0+ (1,0) [0|1] "" CIPM_FO,DMS_FO,VIS2_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ DrvrHndsOnWhlZn3 : 13|1@0+ (1,0) [0|1] "" CIPM_FO,AMM_FO,DMS_FO,VIS2_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ DrvrHndsOnWhlZn2 : 14|1@0+ (1,0) [0|1] "" CIPM_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,DMS_FO,VIS2_FO - SG_ DrvrHndsOnWhlZn1 : 15|1@0+ (1,0) [0|1] "" CIPM_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,DMS_FO,VIS2_FO - SG_ WSWshSwAtv : 11|1@0+ (1,0) [0|1] "" CIPM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,DMS_FO,AMM_FO,VIS_FO,VIS2_FO - SG_ SysPwrMdV : 8|1@0+ (1,0) [0|1] "" NVS_FO,RRSRR_FO,VIS_FO,RSRR_FO,RFSRR_FO,LRR_FO,LFSRR_FO,LRSRR_FO,CIPM_FO,_DOFIMU2_FO,_DOFIMU1_FO,DMS_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,VIS2_FO - SG_ SysPwrMd : 10|2@0+ (1,0) [0|3] "" NVS_FO,RRSRR_FO,VIS_FO,RSRR_FO,RFSRR_FO,LRR_FO,LFSRR_FO,LRSRR_FO,CIPM_FO,_DOFIMU2_FO,_DOFIMU1_FO,DMS_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,VIS2_FO - SG_ WSWprAct : 2|1@0+ (1,0) [0|1] "" CIPM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,DMS_FO,AMM_FO,NVS_FO,VIS_FO,VIS2_FO - SG_ RtLwBmFld : 4|1@0+ (1,0) [0|1] "" CIPM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,DMS_FO,AMM_FO,NVS_FO,VIS_FO,VIS2_FO - SG_ OtsdAmbtLtLvlStatV : 5|1@0+ (1,0) [0|1] "" CIPM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,DMS_FO,AMM_FO,NVS_FO,VIS_FO,VIS2_FO - SG_ OtsdAmbtLtLvlStat : 7|2@0+ (1,0) [0|3] "" CIPM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,DMS_FO,AMM_FO,NVS_FO,VIS_FO,VIS2_FO - SG_ LowBmAct : 1|1@0+ (1,0) [0|1] "" CIPM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,DMS_FO,AMM_FO,NVS_FO,VIS_FO,VIS2_FO - SG_ LftLwBmFld : 3|1@0+ (1,0) [0|1] "" CIPM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,DMS_FO,AMM_FO,NVS_FO,VIS_FO,VIS2_FO - SG_ HighBmAct : 0|1@0+ (1,0) [0|1] "" CIPM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,DMS_FO,AMM_FO,NVS_FO,VIS_FO,VIS2_FO - SG_ TrStLgMdAtv : 12|1@0+ (1,0) [0|1] "" CIPM_FO,NVS_FO,RRSRR_FO,LRSRR_FO,_DOFIMU2_FO,_DOFIMU1_FO,DMS_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,LRR_FO,RFSRR_FO,LFSRR_FO,RSRR_FO,VIS_FO,VIS2_FO - -BO_ 1539 RF_SRR_Trace_Data: 8 RFSRR_FO - SG_ RFSRRYear : 7|8@0+ (1,0) [0|0] "" EOCM_F_FO - SG_ RFSRRSerialNmbr : 39|32@0+ (1,0) [0|0] "" EOCM_F_FO - SG_ RFSRRJulianDate : 15|24@0+ (1,0) [0|0] "" EOCM_F_FO - -BO_ 776 F_Vehicle_Path_Data_2: 7 EOCM_F_FO - SG_ Vpath_Data2ModeInfo : 44|2@0+ (1,0) [0|3] "" CIPM_FO,DMS_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,VIS_FO,RSRR_FO,RFSRR_FO,LRR_FO,LFSRR_FO - SG_ Vpath2_Checksum : 42|11@0+ (1,0) [0|2047] "" CIPM_FO,DMS_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,VIS_FO,RFSRR_FO,LFSRR_FO,RSRR_FO,LRR_FO - SG_ Vpath_Data2RollCnt : 46|2@0+ (1,0) [0|3] "" CIPM_FO,DMS_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,VIS_FO,RSRR_FO,RFSRR_FO,LRR_FO,LFSRR_FO - SG_ Vpath_Data2YawRateV : 2|1@0+ (1,0) [0|1] "" CIPM_FO,DMS_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,NVS_FO,RRSRR_FO,VIS_FO,RSRR_FO,RFSRR_FO,LRR_FO,LFSRR_FO - SG_ Vpath_Data2LongVelV : 1|1@0+ (1,0) [0|1] "" CIPM_FO,DMS_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,NVS_FO,VIS_FO,RSRR_FO,RFSRR_FO,LRR_FO,LFSRR_FO - SG_ Vpath_Data2LatVelV : 47|1@0+ (1,0) [0|1] "" CIPM_FO,DMS_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,VIS_FO,RSRR_FO,RFSRR_FO,LRR_FO,LFSRR_FO - SG_ Vpath_Data2TravlDirctn : 4|2@0+ (1,0) [0|3] "" CIPM_FO,DMS_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,VIS_FO,RSRR_FO,RFSRR_FO,LRR_FO,LFSRR_FO - SG_ Vpath_Data2LongVel : 15|12@0- (0.0625,0) [-128|127.9375] "m/s" CIPM_FO,DMS_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,NVS_FO,VIS_FO,RSRR_FO,RFSRR_FO,LRR_FO,LFSRR_FO - SG_ Vpath_Data2YawRate : 19|12@0- (0.0625,0) [-128|127.9375] "deg/s" CIPM_FO,DMS_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,NVS_FO,RRSRR_FO,VIS_FO,RSRR_FO,RFSRR_FO,LRR_FO,LFSRR_FO - SG_ Vpath_Data2LatVel : 39|8@0- (0.05,0) [-6.4|6.35] "m/s" CIPM_FO,DMS_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,VIS_FO,RSRR_FO,RFSRR_FO,LRR_FO,LFSRR_FO - -BO_ 161 F_Master_Time_Sync: 7 EOCM_F_FO - SG_ FTimeSyncMstrChksm : 35|12@0+ (1,0) [0|4095] "" AMM_FO,CIPM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,VIS_FO,RSRR_FO,RFSRR_FO,LRR_FO,LFSRR_FO - SG_ FTimeSyncMstrClock : 7|32@0+ (1,0) [0|4294967295] "ms" CIPM_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,VIS_FO,RSRR_FO,RFSRR_FO,LRR_FO,LFSRR_FO - SG_ SensorModeCmdLRR : 39|3@0+ (1,0) [0|7] "" CIPM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,VIS_FO,RSRR_FO,RFSRR_FO,LRR_FO,LFSRR_FO - SG_ SensorModeCmdSRR : 50|3@0+ (1,0) [0|7] "" CIPM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,VIS_FO,RSRR_FO,RFSRR_FO,LRR_FO,LFSRR_FO - SG_ SensorModeCmdFCamera : 53|3@0+ (1,0) [0|7] "" CIPM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,VIS_FO,RSRR_FO,RFSRR_FO,LRR_FO,LFSRR_FO - SG_ FTimeSyncMstrClockV : 36|1@0+ (1,0) [0|1] "" CIPM_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,VIS_FO,RSRR_FO,LRR_FO,RFSRR_FO,LFSRR_FO - -BO_ 774 F_Vehicle_Path_Estimate: 8 EOCM_F_FO - SG_ Vpath_RollingCount : 7|2@0+ (1,0) [0|3] "" CIPM_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,VIS_FO,RSRR_FO,RFSRR_FO,LRR_FO,LFSRR_FO - SG_ Vpath_TrnCtrLngOfstV : 1|1@0+ (1,0) [0|1] "" CIPM_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,LRR_FO,VIS_FO,RSRR_FO,RFSRR_FO,LFSRR_FO - SG_ Vpath_Checksum : 50|11@0+ (1,0) [0|2047] "" CIPM_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,VIS_FO,RSRR_FO,RFSRR_FO,LRR_FO,LFSRR_FO - SG_ Vpath_TrnCtrLngOfst : 15|8@0- (0.1,0) [-12.8|12.7] "m" CIPM_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,LRR_FO,VIS_FO,RSRR_FO,RFSRR_FO,LFSRR_FO - SG_ Vpath_TrnCtrLatOfst : 21|14@0- (1,0) [-8192|8191] "m" CIPM_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,LRR_FO,VIS_FO,RSRR_FO,RFSRR_FO,LFSRR_FO - SG_ Vpath_Curvature : 39|16@0- (1E-005,0) [-0.32768|0.32767] "1/m" CIPM_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,VIS_FO,RSRR_FO,RFSRR_FO,LRR_FO,LFSRR_FO - SG_ Vpath_CurvatureV : 0|1@0+ (1,0) [0|1] "" CIPM_FO,AMM_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,VIS2_FO,RRSRR_FO,VIS_FO,LRR_FO,RSRR_FO,RFSRR_FO,LFSRR_FO - -BO_ 848 F_Vision_Environment: 8 VIS_FO - SG_ FwdVsnEnvIllum : 37|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsTngtOfHdngLnRtV : 1|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsTngtOfHdngLnRt : 31|8@0- (0.002,0) [-0.256|0.254] "m/m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsLnChngStatus : 39|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsBurstChecksum : 55|16@0+ (1,0) [0|65535] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LaneSenseRollingCount : 7|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LaneSenseSystemOK : 4|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LaneSnsLLnPosValid : 2|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSenseDistToLLnEdge : 14|7@0+ (0.05,0) [0|6.35] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsRLnPosValid : 0|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsDistToRLnEdge : 22|7@0+ (0.05,0) [0|6.35] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LaneSenseTimeStampV : 5|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LaneSenseTimeStamp : 34|11@0+ (1,0) [0|2047] "ms" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LaneSenseSystemOKV : 3|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - -BO_ 849 F_Vision_Environment_2: 8 VIS_FO - SG_ LnSnsLatVRelToRgtMrkg : 23|8@0- (0.02,0) [-2.56|2.54] "m/s" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM_F_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO - SG_ LnSnsRtLnMrkgTypChgDst : 61|4@0+ (10,0) [0|150] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsCrvtGrdntRtV : 63|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsLnMrkgWdthRt : 62|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsRtAnchrLn : 57|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsLtAnchrLn : 56|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsLnCrvtrRghtV : 0|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsLnCrvtrRght : 47|16@0- (9.53E-007,0) [-0.031227904|0.031226951] "1/m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsCrvtGrdntRt : 31|16@0- (5.96E-008,0) [-0.0019529728|0.0019529132] "1/rad/s" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsBurstID : 2|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsLatVRelToLftMrkg : 15|8@0- (0.02,0) [-2.56|2.54] "m/s" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - -BO_ 1184 R_SRR_Object_Header: 8 RSRR_FO - SG_ RSRRNumValidTargets : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ RSrrRollingCnt : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSRRModeCmdFdbk : 4|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RSrrTimeStampV : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSrrTimeStamp : 10|11@0+ (1,0) [0|2047] "ms" EOCM_F_FO - SG_ RSrrBurstChecksum : 55|16@0+ (1,0) [0|65535] "" EOCM_F_FO - SG_ RSRRSnstvFltPrsntInt : 24|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRPlntAlgnInProc : 37|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRMsalgnYawRt : 47|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRMsalgnYawLt : 46|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRMsalgnRllRt : 35|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRMsalgnRllLt : 34|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRMsalgnPtchUp : 32|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRMsalgnPtchDn : 33|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRInitDiagCmplt : 40|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRHWFltPrsntInt : 25|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRExtIntrfrnc : 36|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRDiagSpare : 30|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRCANSgnlSpvFld : 29|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRCANRxErr : 28|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRCANIDAddrsUnsbl : 27|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRAntTngFltPrsnt : 26|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRAmbTmpOutRngLw : 42|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRAmbTmpOutRngHi : 41|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRAlgnFltPrsnt : 39|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRVltgOutRngLo : 44|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRVltgOutRngHi : 43|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRSvcAlgnInPrcs : 38|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RSRRSnsrBlckd : 45|1@0+ (1,0) [0|1] "" EOCM_F_FO - -BO_ 1185 R_SRR_Object_Track1: 8 RSRR_FO - SG_ RSrrBurstID1 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkRange1 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RSrrTrkRRate1 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RSrrTrkAzimuth1 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RSrrTrkObjID1 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RSrrTrkObjElevation1 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkDynamProp1 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RSrrTrkMeasStatus1 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkObsRange1 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RSrrTrkRawAzimuth1 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - -BO_ 1186 R_SRR_Object_Track2: 8 RSRR_FO - SG_ RSrrBurstID2 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkRange2 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RSrrTrkRRate2 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RSrrTrkAzimuth2 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RSrrTrkObjID2 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RSrrTrkObjElevation2 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkDynamProp2 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RSrrTrkMeasStatus2 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkObsRange2 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RSrrTrkRawAzimuth2 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - -BO_ 1187 R_SRR_Object_Track3: 8 RSRR_FO - SG_ RSrrBurstID3 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkRange3 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RSrrTrkRRate3 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RSrrTrkAzimuth3 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RSrrTrkObjID3 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RSrrTrkObjElevation3 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkDynamProp3 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RSrrTrkMeasStatus3 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkObsRange3 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RSrrTrkRawAzimuth3 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - -BO_ 1188 R_SRR_Object_Track4: 8 RSRR_FO - SG_ RSrrBurstID4 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkRange4 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RSrrTrkRRate4 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RSrrTrkAzimuth4 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RSrrTrkObjID4 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RSrrTrkObjElevation4 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkDynamProp4 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RSrrTrkMeasStatus4 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkObsRange4 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RSrrTrkRawAzimuth4 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - -BO_ 1189 R_SRR_Object_Track5: 8 RSRR_FO - SG_ RSrrBurstID5 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkRange5 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RSrrTrkRRate5 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RSrrTrkAzimuth5 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RSrrTrkObjID5 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RSrrTrkObjElevation5 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkDynamProp5 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RSrrTrkMeasStatus5 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkObsRange5 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RSrrTrkRawAzimuth5 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - -BO_ 1190 R_SRR_Object_Track6: 8 RSRR_FO - SG_ RSrrBurstID6 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkRange6 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RSrrTrkRRate6 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RSrrTrkAzimuth6 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RSrrTrkObjID6 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RSrrTrkObjElevation6 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkDynamProp6 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RSrrTrkMeasStatus6 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkObsRange6 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RSrrTrkRawAzimuth6 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - -BO_ 1191 R_SRR_Object_Track7: 8 RSRR_FO - SG_ RSrrBurstID7 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkRange7 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RSrrTrkRRate7 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RSrrTrkAzimuth7 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RSrrTrkObjID7 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RSrrTrkObjElevation7 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkDynamProp7 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RSrrTrkMeasStatus7 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkObsRange7 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RSrrTrkRawAzimuth7 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - -BO_ 1192 R_SRR_Object_Track8: 8 RSRR_FO - SG_ RSrrBurstID8 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkRange8 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RSrrTrkRRate8 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RSrrTrkAzimuth8 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RSrrTrkObjID8 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RSrrTrkObjElevation8 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkDynamProp8 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RSrrTrkMeasStatus8 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkObsRange8 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RSrrTrkRawAzimuth8 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - -BO_ 1193 R_SRR_Object_Track9: 8 RSRR_FO - SG_ RSrrBurstID9 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkRange9 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RSrrTrkRRate9 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RSrrTrkAzimuth9 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RSrrTrkObjID9 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RSrrTrkObjElevation9 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkDynamProp9 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RSrrTrkMeasStatus9 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkObsRange9 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RSrrTrkRawAzimuth9 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - -BO_ 1194 R_SRR_Object_Track10: 8 RSRR_FO - SG_ RSrrBurstID10 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkRange10 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RSrrTrkRRate10 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RSrrTrkAzimuth10 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RSrrTrkObjID10 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RSrrTrkObjElevation10 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkDynamProp10 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RSrrTrkMeasStatus10 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RSrrTrkObsRange10 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RSrrTrkRawAzimuth10 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - -BO_ 1410 RVB_TVR_Debug: 6 EOCM_F_FO - SG_ VBBrkRqActv : 7|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ PATOSTTC : 37|12@0+ (0.025,0) [0|102.375] "s" Dummy_FO - SG_ BWTOSObjID : 27|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ BWTOSLonPstn : 23|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - SG_ VBSwInd : 10|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ VBBrkCtrlSt : 15|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ BrkPlsRqst : 6|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VBOpSt : 12|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ VBAccelOvrrd : 0|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VBUnavail : 1|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VBFld : 2|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VBDisbld : 3|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VBEnbl : 4|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VBBrkPrfReq : 5|1@0+ (1,0) [0|1] "" Dummy_FO - -BO_ 1216 LF_SRR_Object_Header: 8 LFSRR_FO - SG_ LFSRRNumValidTargets : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ LFSrrRollingCnt : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSRRModeCmdFdbk : 4|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ LFSrrTimeStampV : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSrrTimeStamp : 10|11@0+ (1,0) [0|2047] "ms" EOCM_F_FO - SG_ LFSrrBurstChecksum : 55|16@0+ (1,0) [0|65535] "" EOCM_F_FO - SG_ LFSRRVltgOutRngLo : 44|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRVltgOutRngHi : 43|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRSvcAlgnInPrcs : 38|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRSnsrBlckd : 45|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRSnstvFltPrsntInt : 24|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRPlntAlgnInProc : 37|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRMsalgnYawRt : 47|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRMsalgnYawLt : 46|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRMsalgnRllRt : 35|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRMsalgnRllLt : 34|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRMsalgnPtchUp : 32|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRMsalgnPtchDn : 33|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRInitDiagCmplt : 40|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRHWFltPrsntInt : 25|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRExtIntrfrnc : 36|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRDiagSpare : 30|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRCANSgnlSpvFld : 29|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRCANRxErr : 28|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRCANIDAddrsUnsbl : 27|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRAntTngFltPrsnt : 26|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRAmbTmpOutRngLw : 42|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRAmbTmpOutRngHi : 41|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ LFSRRAlgnFltPrsnt : 39|1@0+ (1,0) [0|1] "" EOCM_F_FO - -BO_ 1217 LF_SRR_Object_Track1: 8 LFSRR_FO - SG_ LFSrrBurstID1 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkRange1 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ LFSrrTrkRRate1 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ LFSrrTrkAzimuth1 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ LFSrrTrkObjID1 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ LFSrrTrkObjElevation1 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkDynamProp1 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ LFSrrTrkMeasStatus1 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkObsRange1 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ LFSrrTrkRawAzimuth1 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - -BO_ 1218 LF_SRR_Object_Track2: 8 LFSRR_FO - SG_ LFSrrBurstID2 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkRange2 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ LFSrrTrkRRate2 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ LFSrrTrkAzimuth2 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ LFSrrTrkObjID2 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ LFSrrTrkObjElevation2 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkDynamProp2 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ LFSrrTrkMeasStatus2 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkObsRange2 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ LFSrrTrkRawAzimuth2 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - -BO_ 1219 LF_SRR_Object_Track3: 8 LFSRR_FO - SG_ LFSrrBurstID3 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkRange3 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ LFSrrTrkRRate3 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ LFSrrTrkAzimuth3 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ LFSrrTrkObjID3 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ LFSrrTrkObjElevation3 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkDynamProp3 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ LFSrrTrkMeasStatus3 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkObsRange3 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ LFSrrTrkRawAzimuth3 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - -BO_ 1220 LF_SRR_Object_Track4: 8 LFSRR_FO - SG_ LFSrrBurstID4 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkRange4 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ LFSrrTrkRRate4 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ LFSrrTrkObsRange4 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ LFSrrTrkAzimuth4 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ LFSrrTrkObjID4 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ LFSrrTrkObjElevation4 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkDynamProp4 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ LFSrrTrkMeasStatus4 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkRawAzimuth4 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - -BO_ 1221 LF_SRR_Object_Track5: 8 LFSRR_FO - SG_ LFSrrTrkObsRange5 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ LFSrrBurstID5 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkRange5 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ LFSrrTrkRRate5 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ LFSrrTrkAzimuth5 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ LFSrrTrkObjID5 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ LFSrrTrkObjElevation5 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkDynamProp5 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ LFSrrTrkMeasStatus5 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkRawAzimuth5 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - -BO_ 1222 LF_SRR_Object_Track6: 8 LFSRR_FO - SG_ LFSrrTrkObsRange6 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ LFSrrBurstID6 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkRange6 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ LFSrrTrkRRate6 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ LFSrrTrkAzimuth6 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ LFSrrTrkObjID6 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ LFSrrTrkObjElevation6 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkDynamProp6 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ LFSrrTrkMeasStatus6 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkRawAzimuth6 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - -BO_ 1223 LF_SRR_Object_Track7: 8 LFSRR_FO - SG_ LFSrrTrkObsRange7 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ LFSrrBurstID7 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkRange7 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ LFSrrTrkRRate7 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ LFSrrTrkAzimuth7 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ LFSrrTrkObjID7 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ LFSrrTrkObjElevation7 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkDynamProp7 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ LFSrrTrkMeasStatus7 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkRawAzimuth7 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - -BO_ 1224 LF_SRR_Object_Track8: 8 LFSRR_FO - SG_ LFSrrTrkObsRange8 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ LFSrrBurstID8 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkRange8 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ LFSrrTrkRRate8 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ LFSrrTrkAzimuth8 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ LFSrrTrkObjID8 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ LFSrrTrkObjElevation8 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkDynamProp8 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ LFSrrTrkMeasStatus8 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkRawAzimuth8 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - -BO_ 1225 LF_SRR_Object_Track9: 8 LFSRR_FO - SG_ LFSrrTrkObsRange9 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ LFSrrBurstID9 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkRange9 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ LFSrrTrkRRate9 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ LFSrrTrkAzimuth9 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ LFSrrTrkObjID9 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ LFSrrTrkObjElevation9 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkDynamProp9 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ LFSrrTrkMeasStatus9 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkRawAzimuth9 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - -BO_ 1226 LF_SRR_Object_Track10: 8 LFSRR_FO - SG_ LFSrrTrkObsRange10 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ LFSrrBurstID10 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkRange10 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ LFSrrTrkRRate10 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ LFSrrTrkAzimuth10 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ LFSrrTrkObjID10 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ LFSrrTrkObjElevation10 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkDynamProp10 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ LFSrrTrkMeasStatus10 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ LFSrrTrkRawAzimuth10 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - -BO_ 1232 RF_SRR_Object_Header: 8 RFSRR_FO - SG_ RFSRRVltgOutRngLo : 44|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRVltgOutRngHi : 43|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRSvcAlgnInPrcs : 38|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRSnsrBlckd : 45|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRSnstvFltPrsntInt : 24|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRPlntAlgnInProc : 37|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRMsalgnYawRt : 47|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRMsalgnYawLt : 46|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRMsalgnRllRt : 35|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRMsalgnRllLt : 34|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRMsalgnPtchUp : 32|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRMsalgnPtchDn : 33|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRInitDiagCmplt : 40|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRHWFltPrsntInt : 25|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRExtIntrfrnc : 36|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRDiagSpare : 30|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRCANSgnlSpvFld : 29|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRCANRxErr : 28|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRCANIDAddrsUnsbl : 27|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRAntTngFltPrsnt : 26|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRAmbTmpOutRngLw : 42|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRAmbTmpOutRngHi : 41|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRAlgnFltPrsnt : 39|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RFSRRNumValidTargets : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ RFSrrRollingCnt : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSRRModeCmdFdbk : 4|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RFSrrTimeStamp : 10|11@0+ (1,0) [0|2047] "ms" EOCM_F_FO - SG_ RFSrrBurstChecksum : 55|16@0+ (1,0) [0|65535] "" EOCM_F_FO - SG_ RFSrrTimeStampV : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - -BO_ 1233 RF_SRR_Object_Track1: 8 RFSRR_FO - SG_ RFSrrTrkObsRange1 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RFSrrTrkRawAzimuth1 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - SG_ RFSrrBurstID1 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSrrTrkRange1 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RFSrrTrkRRate1 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RFSrrTrkAzimuth1 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RFSrrTrkObjID1 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RFSrrTrkObjElevation1 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSrrTrkDynamProp1 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RFSrrTrkMeasStatus1 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1234 RF_SRR_Object_Track2: 8 RFSRR_FO - SG_ RFSrrTrkObsRange2 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RFSrrTrkRawAzimuth2 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - SG_ RFSrrBurstID2 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSrrTrkRange2 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RFSrrTrkRRate2 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RFSrrTrkAzimuth2 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RFSrrTrkObjID2 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RFSrrTrkObjElevation2 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSrrTrkDynamProp2 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RFSrrTrkMeasStatus2 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1235 RF_SRR_Object_Track3: 8 RFSRR_FO - SG_ RFSrrTrkObsRange3 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RFSrrTrkRawAzimuth3 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - SG_ RFSrrBurstID3 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSrrTrkRange3 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RFSrrTrkRRate3 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RFSrrTrkAzimuth3 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RFSrrTrkObjID3 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RFSrrTrkObjElevation3 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSrrTrkDynamProp3 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RFSrrTrkMeasStatus3 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1236 RF_SRR_Object_Track4: 8 RFSRR_FO - SG_ RFSrrTrkObsRange4 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RFSrrTrkRawAzimuth4 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - SG_ RFSrrBurstID4 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSrrTrkRange4 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RFSrrTrkRRate4 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RFSrrTrkAzimuth4 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RFSrrTrkObjID4 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RFSrrTrkObjElevation4 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSrrTrkDynamProp4 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RFSrrTrkMeasStatus4 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1237 RF_SRR_Object_Track5: 8 RFSRR_FO - SG_ RFSrrTrkObsRange5 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RFSrrTrkRawAzimuth5 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - SG_ RFSrrBurstID5 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSrrTrkRange5 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RFSrrTrkRRate5 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RFSrrTrkAzimuth5 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RFSrrTrkObjID5 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RFSrrTrkObjElevation5 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSrrTrkDynamProp5 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RFSrrTrkMeasStatus5 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1238 RF_SRR_Object_Track6: 8 RFSRR_FO - SG_ RFSrrTrkObsRange6 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RFSrrTrkRawAzimuth6 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - SG_ RFSrrBurstID6 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSrrTrkRange6 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RFSrrTrkRRate6 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RFSrrTrkAzimuth6 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RFSrrTrkObjID6 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RFSrrTrkObjElevation6 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSrrTrkDynamProp6 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RFSrrTrkMeasStatus6 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1239 RF_SRR_Object_Track7: 8 RFSRR_FO - SG_ RFSrrTrkObsRange7 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RFSrrTrkRawAzimuth7 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - SG_ RFSrrBurstID7 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSrrTrkRange7 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RFSrrTrkRRate7 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RFSrrTrkAzimuth7 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RFSrrTrkObjID7 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RFSrrTrkObjElevation7 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSrrTrkDynamProp7 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RFSrrTrkMeasStatus7 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1240 RF_SRR_Object_Track8: 8 RFSRR_FO - SG_ RFSrrTrkObsRange8 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RFSrrTrkRawAzimuth8 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - SG_ RFSrrBurstID8 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSrrTrkRange8 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RFSrrTrkRRate8 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RFSrrTrkAzimuth8 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RFSrrTrkObjID8 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RFSrrTrkObjElevation8 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSrrTrkDynamProp8 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RFSrrTrkMeasStatus8 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1241 RF_SRR_Object_Track9: 8 RFSRR_FO - SG_ RFSrrTrkObsRange9 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RFSrrTrkRawAzimuth9 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - SG_ RFSrrBurstID9 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSrrTrkRange9 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RFSrrTrkRRate9 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RFSrrTrkAzimuth9 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RFSrrTrkObjID9 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RFSrrTrkObjElevation9 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSrrTrkDynamProp9 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RFSrrTrkMeasStatus9 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1242 RF_SRR_Object_Track10: 8 RFSRR_FO - SG_ RFSrrTrkObsRange10 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RFSrrTrkRawAzimuth10 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - SG_ RFSrrBurstID10 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSrrTrkRange10 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RFSrrTrkRRate10 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RFSrrTrkAzimuth10 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RFSrrTrkObjID10 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RFSrrTrkObjElevation10 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RFSrrTrkDynamProp10 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RFSrrTrkMeasStatus10 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1056 F_Vision_Obj_Header: 6 VIS_FO - SG_ FVsnSnsrBlckd : 24|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ ClstInPathVehObjID : 30|6@0+ (1,0) [0|63] "" EOCM_F_FO - SG_ FrtVsnFld : 6|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FrtVsnIniDiagSuccCmpt : 5|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FrtVsnSrvAlgnInPrcs : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FrtVsnUnvlbl : 7|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FVisionRollingCnt : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVISModeCmdFdbk : 4|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FVisionNumValidTrgts : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ FVisionTimeStampV : 31|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FVisionTimeStamp : 10|11@0+ (1,0) [0|2047] "ms" EOCM_F_FO - SG_ VISBurstChecksum : 39|16@0+ (1,0) [0|65535] "" EOCM_F_FO - -BO_ 1057 F_Vision_Obj_Track_1: 8 VIS_FO - SG_ FwdVsnRngTrk1Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO - SG_ FwdVsnAzmthTrk1Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO - SG_ FwdVsnObjTypTr1Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ FwdVsnVertPosTrk1 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO - SG_ FVisBurstIDTrk1 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionObjectIDTrk1 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO - SG_ FVisionConfTrk1 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionAzRateTrk1 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FVisionRelLaneTrk1 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionMeasStatTrk1 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionWidthTrk1 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ ObjDirTrk1 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - -BO_ 1058 F_Vision_Obj_Track_2: 8 VIS_FO - SG_ FwdVsnVertPosTrk2 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO - SG_ FwdVsnRngTrk2Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO - SG_ FwdVsnAzmthTrk2Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO - SG_ ObjDirTrk2 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FwdVsnObjTypTr2Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ FVisBurstIDTrk2 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionObjectIDTrk2 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO - SG_ FVisionConfTrk2 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionAzRateTrk2 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FVisionRelLaneTrk2 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionMeasStatTrk2 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionWidthTrk2 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - -BO_ 1059 F_Vision_Obj_Track_3: 8 VIS_FO - SG_ FwdVsnVertPosTrk3 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO - SG_ FwdVsnRngTrk3Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO - SG_ FwdVsnAzmthTrk3Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO - SG_ FwdVsnObjTypTr3Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ ObjDirTrk3 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FVisBurstIDTrk3 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionObjectIDTrk3 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO - SG_ FVisionConfTrk3 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionAzRateTrk3 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FVisionRelLaneTrk3 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionMeasStatTrk3 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionWidthTrk3 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - -BO_ 1060 F_Vision_Obj_Track_4: 8 VIS_FO - SG_ FwdVsnVertPosTrk4 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO - SG_ FVisionMeasStatTrk4 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionWidthTrk4 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FwdVsnRngTrk4Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO - SG_ FwdVsnAzmthTrk4Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO - SG_ FwdVsnObjTypTr4Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ FVisBurstIDTrk4 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionObjectIDTrk4 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO - SG_ ObjDirTrk4 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FVisionConfTrk4 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionAzRateTrk4 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FVisionRelLaneTrk4 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1061 F_Vision_Obj_Track_5: 8 VIS_FO - SG_ FwdVsnVertPosTrk5 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO - SG_ FwdVsnRngTrk5Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO - SG_ FwdVsnAzmthTrk5Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO - SG_ FwdVsnObjTypTr5Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ ObjDirTrk5 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FVisBurstIDTrk5 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionObjectIDTrk5 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO - SG_ FVisionConfTrk5 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionAzRateTrk5 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FVisionRelLaneTrk5 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionMeasStatTrk5 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionWidthTrk5 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - -BO_ 1062 F_Vision_Obj_Track_6: 8 VIS_FO - SG_ FwdVsnVertPosTrk6 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO - SG_ FwdVsnRngTrk6Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO - SG_ FwdVsnAzmthTrk6Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO - SG_ FwdVsnObjTypTr6Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ ObjDirTrk6 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FVisBurstIDTrk6 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionObjectIDTrk6 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO - SG_ FVisionConfTrk6 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionAzRateTrk6 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FVisionRelLaneTrk6 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionMeasStatTrk6 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionWidthTrk6 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - -BO_ 1538 LF_SRR_Trace_Data: 8 LFSRR_FO - SG_ LFSRRYear : 7|8@0+ (1,0) [0|0] "" EOCM_F_FO - SG_ LFSRRSerialNmbr : 39|32@0+ (1,0) [0|0] "" EOCM_F_FO - SG_ LFSRRJulianDate : 15|24@0+ (1,0) [0|0] "" EOCM_F_FO - -BO_ 1537 R_SRR_Trace_data: 8 RSRR_FO - SG_ RSRRYear : 7|8@0+ (1,0) [0|0] "" EOCM_F_FO - SG_ RSRRSerialNmbr : 39|32@0+ (1,0) [0|0] "" EOCM_F_FO - SG_ RSRRJulianDate : 15|24@0+ (1,0) [0|0] "" EOCM_F_FO - -BO_ 1089 F_Vision_Obj_Track_7: 8 VIS2_FO - SG_ FVisBurstIDTrk7 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionObjectIDTrk7 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO - SG_ FVisionConfTrk7 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionAzRateTrk7 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FVisionRelLaneTrk7 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionMeasStatTrk7 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionWidthTrk7 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FwdVsnRngTrk7Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO - SG_ FwdVsnObjTypTr7Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ FwdVsnAzmthTrk7Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO - SG_ FwdVsnVertPosTrk7 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO - SG_ ObjDirTrk7 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - -BO_ 1090 F_Vision_Obj_Track_8: 8 VIS2_FO - SG_ FVisBurstIDTrk8 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionObjectIDTrk8 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO - SG_ FwdVsnAzmthTrk8Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO - SG_ FwdVsnVertPosTrk8 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO - SG_ FwdVsnRngTrk8Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO - SG_ FwdVsnObjTypTr8Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ ObjDirTrk8 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FVisionConfTrk8 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionAzRateTrk8 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FVisionRelLaneTrk8 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionMeasStatTrk8 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionWidthTrk8 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - -BO_ 1091 F_Vision_Obj_Track_9: 8 VIS2_FO - SG_ FwdVsnVertPosTrk9 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO - SG_ FwdVsnRngTrk9Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO - SG_ FwdVsnAzmthTrk9Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO - SG_ FwdVsnObjTypTr9Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ ObjDirTrk9 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FVisBurstIDTrk9 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionObjectIDTrk9 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO - SG_ FVisionConfTrk9 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionAzRateTrk9 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FVisionRelLaneTrk9 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionMeasStatTrk9 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionWidthTrk9 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - -BO_ 1092 F_Vision_Obj_Track_10: 8 VIS2_FO - SG_ FwdVsnRngTrk10Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO - SG_ FwdVsnAzmthTrk10Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO - SG_ FwdVsnObjTypTr10Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ FwdVsnVertPosTrk10 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO - SG_ ObjDirTrk10 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FVisBurstIDTrk10 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionObjectIDTrk10 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO - SG_ FVisionConfTrk10 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionAzRateTrk10 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FVisionRelLaneTrk10 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionMeasStatTrk10 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FVisionWidthTrk10 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - -BO_ 1120 F_LRR_Obj_Header: 8 LRR_FO - SG_ FLRRRollingCount : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRModeCmdFdbk : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRNumValidTargets : 20|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ FLRRTimeStampV : 31|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRTimeStamp : 2|11@0+ (1,0) [0|2047] "ms" EOCM_F_FO - SG_ FLRRRoadTypeInfo : 5|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRBurstChecksum : 55|16@0+ (1,0) [0|65535] "" EOCM_F_FO - SG_ FLRRDiagSpare : 30|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRVltgOutRngLo : 44|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRVltgOutRngHi : 43|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRSvcAlgnInPrcs : 38|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRSnsrBlckd : 45|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRSnstvFltPrsntInt : 24|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRPlntAlgnInProc : 37|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRMsalgnYawRt : 47|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRMsalgnYawLt : 46|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRLonVelPlsblityFlt : 35|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRYawRtPlsblityFlt : 34|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRMsalgnPtchUp : 32|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRMsalgnPtchDn : 33|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRInitDiagCmplt : 40|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRHWFltPrsntInt : 25|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRExtIntrfrnc : 36|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRCANSgnlSpvFld : 29|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRCANRxErr : 28|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRTunlDtctd : 27|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRAmbTmpOutRngLw : 42|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRAmbTmpOutRngHi : 41|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRAntTngFltPrsnt : 26|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ FLRRAlgnFltPrsnt : 39|1@0+ (1,0) [0|1] "" EOCM_F_FO - -BO_ 1121 F_LRR_Obj_Track_1: 8 LRR_FO - SG_ FLRRTrk1BurstID : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk1Range : 5|11@0+ (0.125,0) [0|255.875] "m" EOCM_F_FO - SG_ FLRRTrk1RangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ FLRRTrk1RangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" EOCM_F_FO - SG_ FLRRTrk1DynProp : 38|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk1Azimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" EOCM_F_FO - SG_ FLRRTrk1Width : 55|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FLRRTrk1MeasStatus : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk1ObjectID : 61|6@0+ (1,0) [0|63] "" EOCM_F_FO - SG_ FLRRTrk1Conf : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1122 F_LRR_Obj_Track_2: 8 LRR_FO - SG_ FLRRTrk2BurstID : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk2Range : 5|11@0+ (0.125,0) [0|255.875] "m" EOCM_F_FO - SG_ FLRRTrk2RangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ FLRRTrk2RangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" EOCM_F_FO - SG_ FLRRTrk2DynProp : 38|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk2Azimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" EOCM_F_FO - SG_ FLRRTrk2Width : 55|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FLRRTrk2MeasStatus : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk2ObjectID : 61|6@0+ (1,0) [0|63] "" EOCM_F_FO - SG_ FLRRTrk2Conf : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1123 F_LRR_Obj_Track_3: 8 LRR_FO - SG_ FLRRTrk3BurstID : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk3Range : 5|11@0+ (0.125,0) [0|255.875] "m" EOCM_F_FO - SG_ FLRRTrk3RangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ FLRRTrk3RangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" EOCM_F_FO - SG_ FLRRTrk3DynProp : 38|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk3Azimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" EOCM_F_FO - SG_ FLRRTrk3Width : 55|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FLRRTrk3MeasStatus : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk3ObjectID : 61|6@0+ (1,0) [0|63] "" EOCM_F_FO - SG_ FLRRTrk3Conf : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1124 F_LRR_Obj_Track_4: 8 LRR_FO - SG_ FLRRTrk4BurstID : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk4Range : 5|11@0+ (0.125,0) [0|255.875] "m" EOCM_F_FO - SG_ FLRRTrk4RangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ FLRRTrk4RangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" EOCM_F_FO - SG_ FLRRTrk4DynProp : 38|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk4Azimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" EOCM_F_FO - SG_ FLRRTrk4Width : 55|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FLRRTrk4MeasStatus : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk4ObjectID : 61|6@0+ (1,0) [0|63] "" EOCM_F_FO - SG_ FLRRTrk4Conf : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1125 F_LRR_Obj_Track_5: 8 LRR_FO - SG_ FLRRTrk5BurstID : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk5Range : 5|11@0+ (0.125,0) [0|255.875] "m" EOCM_F_FO - SG_ FLRRTrk5RangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ FLRRTrk5RangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" EOCM_F_FO - SG_ FLRRTrk5DynProp : 38|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk5Azimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" EOCM_F_FO - SG_ FLRRTrk5Width : 55|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FLRRTrk5MeasStatus : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk5ObjectID : 61|6@0+ (1,0) [0|63] "" EOCM_F_FO - SG_ FLRRTrk5Conf : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1126 F_LRR_Obj_Track_6: 8 LRR_FO - SG_ FLRRTrk6BurstID : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk6Range : 5|11@0+ (0.125,0) [0|255.875] "m" EOCM_F_FO - SG_ FLRRTrk6RangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ FLRRTrk6Conf : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk6RangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" EOCM_F_FO - SG_ FLRRTrk6DynProp : 38|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk6Azimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" EOCM_F_FO - SG_ FLRRTrk6Width : 55|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FLRRTrk6MeasStatus : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk6ObjectID : 61|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 1127 F_LRR_Obj_Track_7: 8 LRR_FO - SG_ FLRRTrk7Conf : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk7BurstID : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk7Range : 5|11@0+ (0.125,0) [0|255.875] "m" EOCM_F_FO - SG_ FLRRTrk7RangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ FLRRTrk7RangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" EOCM_F_FO - SG_ FLRRTrk7DynProp : 38|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk7Azimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" EOCM_F_FO - SG_ FLRRTrk7Width : 55|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FLRRTrk7MeasStatus : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk7ObjectID : 61|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 1128 F_LRR_Obj_Track_8: 8 LRR_FO - SG_ FLRRTrk8Conf : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk8BurstID : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk8Range : 5|11@0+ (0.125,0) [0|255.875] "m" EOCM_F_FO - SG_ FLRRTrk8RangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ FLRRTrk8RangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" EOCM_F_FO - SG_ FLRRTrk8DynProp : 38|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk8Azimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" EOCM_F_FO - SG_ FLRRTrk8Width : 55|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FLRRTrk8MeasStatus : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk8ObjectID : 61|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 1129 F_LRR_Obj_Track_9: 8 LRR_FO - SG_ FLRRTrk9Conf : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk9BurstID : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk9Range : 5|11@0+ (0.125,0) [0|255.875] "m" EOCM_F_FO - SG_ FLRRTrk9RangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ FLRRTrk9RangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" EOCM_F_FO - SG_ FLRRTrk9DynProp : 38|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk9Azimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" EOCM_F_FO - SG_ FLRRTrk9Width : 55|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FLRRTrk9MeasStatus : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk9ObjectID : 61|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 1130 F_LRR_Obj_Track_10: 8 LRR_FO - SG_ FLRRTrk10Conf : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk10BurstID : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk10Range : 5|11@0+ (0.125,0) [0|255.875] "m" EOCM_F_FO - SG_ FLRRTrk10RangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ FLRRTrk10RangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" EOCM_F_FO - SG_ FLRRTrk10DynProp : 38|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk10Azimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" EOCM_F_FO - SG_ FLRRTrk10Width : 55|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FLRRTrk10MeasStatus : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk10ObjectID : 61|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 1131 F_LRR_Obj_Track_11: 8 LRR_FO - SG_ FLRRTrk11Conf : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk11BurstID : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk11Range : 5|11@0+ (0.125,0) [0|255.875] "m" EOCM_F_FO - SG_ FLRRTrk11RangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ FLRRTrk11RangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" EOCM_F_FO - SG_ FLRRTrk11DynProp : 38|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk11Azimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" EOCM_F_FO - SG_ FLRRTrk11Width : 55|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FLRRTrk11MeasStatus : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk11ObjectID : 61|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 1132 F_LRR_Obj_Track_12: 8 LRR_FO - SG_ FLRRTrk12Conf : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk12BurstID : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk12Range : 5|11@0+ (0.125,0) [0|255.875] "m" EOCM_F_FO - SG_ FLRRTrk12RangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ FLRRTrk12RangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" EOCM_F_FO - SG_ FLRRTrk12DynProp : 38|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk12Azimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" EOCM_F_FO - SG_ FLRRTrk12Width : 55|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FLRRTrk12MeasStatus : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk12ObjectID : 61|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 1133 F_LRR_Obj_Track_13: 8 LRR_FO - SG_ FLRRTrk13Conf : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk13BurstID : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk13Range : 5|11@0+ (0.125,0) [0|255.875] "m" EOCM_F_FO - SG_ FLRRTrk13RangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ FLRRTrk13RangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" EOCM_F_FO - SG_ FLRRTrk13DynProp : 38|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk13Azimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" EOCM_F_FO - SG_ FLRRTrk13Width : 55|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FLRRTrk13MeasStatus : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk13ObjectID : 61|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 1134 F_LRR_Obj_Track_14: 8 LRR_FO - SG_ FLRRTrk14Conf : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk14BurstID : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk14Range : 5|11@0+ (0.125,0) [0|255.875] "m" EOCM_F_FO - SG_ FLRRTrk14RangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ FLRRTrk14RangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" EOCM_F_FO - SG_ FLRRTrk14DynProp : 38|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk14Azimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" EOCM_F_FO - SG_ FLRRTrk14Width : 55|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FLRRTrk14MeasStatus : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk14ObjectID : 61|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 1135 F_LRR_Obj_Track_15: 8 LRR_FO - SG_ FLRRTrk15Width : 55|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FLRRTrk15MeasStatus : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk15Conf : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk15ObjectID : 61|6@0+ (1,0) [0|63] "" EOCM_F_FO - SG_ FLRRTrk15BurstID : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk15Range : 5|11@0+ (0.125,0) [0|255.875] "m" EOCM_F_FO - SG_ FLRRTrk15RangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ FLRRTrk15RangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" EOCM_F_FO - SG_ FLRRTrk15DynProp : 38|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk15Azimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" EOCM_F_FO - -BO_ 1136 F_LRR_Obj_Track_16: 8 LRR_FO - SG_ FLRRTrk16Conf : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk16BurstID : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk16Range : 5|11@0+ (0.125,0) [0|255.875] "m" EOCM_F_FO - SG_ FLRRTrk16RangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ FLRRTrk16RangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" EOCM_F_FO - SG_ FLRRTrk16DynProp : 38|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk16Azimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" EOCM_F_FO - SG_ FLRRTrk16Width : 55|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FLRRTrk16MeasStatus : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk16ObjectID : 61|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 1137 F_LRR_Obj_Track_17: 8 LRR_FO - SG_ FLRRTrk17Conf : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk17BurstID : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk17Range : 5|11@0+ (0.125,0) [0|255.875] "m" EOCM_F_FO - SG_ FLRRTrk17RangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ FLRRTrk17RangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" EOCM_F_FO - SG_ FLRRTrk17DynProp : 38|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk17Azimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" EOCM_F_FO - SG_ FLRRTrk17Width : 55|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FLRRTrk17MeasStatus : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk17ObjectID : 61|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 1138 F_LRR_Obj_Track_18: 8 LRR_FO - SG_ FLRRTrk18Conf : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk18BurstID : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk18Range : 5|11@0+ (0.125,0) [0|255.875] "m" EOCM_F_FO - SG_ FLRRTrk18RangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ FLRRTrk18RangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" EOCM_F_FO - SG_ FLRRTrk18DynProp : 38|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk18Azimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" EOCM_F_FO - SG_ FLRRTrk18Width : 55|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FLRRTrk18MeasStatus : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk18ObjectID : 61|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 1139 F_LRR_Obj_Track_19: 8 LRR_FO - SG_ FLRRTrk19Conf : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk19BurstID : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk19Range : 5|11@0+ (0.125,0) [0|255.875] "m" EOCM_F_FO - SG_ FLRRTrk19RangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ FLRRTrk19RangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" EOCM_F_FO - SG_ FLRRTrk19DynProp : 38|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk19Azimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" EOCM_F_FO - SG_ FLRRTrk19Width : 55|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FLRRTrk19MeasStatus : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk19ObjectID : 61|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 1140 F_LRR_Obj_Track_20: 8 LRR_FO - SG_ FLRRTrk20Conf : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk20BurstID : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk20Range : 5|11@0+ (0.125,0) [0|255.875] "m" EOCM_F_FO - SG_ FLRRTrk20RangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ FLRRTrk20RangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" EOCM_F_FO - SG_ FLRRTrk20DynProp : 38|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk20Azimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" EOCM_F_FO - SG_ FLRRTrk20Width : 55|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO - SG_ FLRRTrk20MeasStatus : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk20ObjectID : 61|6@0+ (1,0) [0|63] "" EOCM_F_FO - -BO_ 1141 Long_Range_Radar_add_Info_1: 8 LRR_FO - SG_ FLRRAddInfo1BurstID : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ Cut_In_Out_Pot_Objtrk1 : 15|6@0+ (0.02,0) [0|1.26] "" EOCM_F_FO - SG_ ObjLossInfoObjTrk1 : 9|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ Cut_In_Out_Pot_Objtrk2 : 23|6@0+ (0.02,0) [0|1.26] "" EOCM_F_FO - SG_ ObjLossInfoObjTrk2 : 17|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ Cut_In_Out_Pot_Objtrk3 : 31|6@0+ (0.02,0) [0|1.26] "" EOCM_F_FO - SG_ ObjLossInfoObjTrk3 : 25|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ Cut_In_Out_Pot_Objtrk4 : 39|6@0+ (0.02,0) [0|1.26] "" EOCM_F_FO - SG_ ObjLossInfoObjTrk4 : 33|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ Cut_In_Out_Pot_Objtrk5 : 47|6@0+ (0.02,0) [0|1.26] "" EOCM_F_FO - SG_ ObjLossInfoObjTrk5 : 41|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ Cut_In_Out_Pot_Objtrk6 : 55|6@0+ (0.02,0) [0|1.26] "" EOCM_F_FO - SG_ ObjLossInfoObjTrk6 : 49|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1321 F_Fwd_Fus_Obj_TrackB_9: 7 EOCM_F_FO - SG_ FwdFusTrkBAnlgRlLn9 : 46|8@0- (0.1,0) [-12.8|12.7] "" Dummy_FO - SG_ FwdFusTrkB9RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB9Width : 5|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FwdFusTrkB9MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkB9DynProp : 11|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB9RelLnAccl : 8|9@0- (0.125,0) [-32|31.875] "m/s^2" Dummy_FO - SG_ FwdFusTrkB9RelLane : 31|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB9Height : 54|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FFusTrkB9ObjSrcLFSrr : 29|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB9ObjSrcLCSrr : 28|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB9ObjSrcRCSrr : 27|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB9ObjSrcRFSrr : 26|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB9ObjSrcVIs : 25|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB9ObjSrcLrr : 24|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB9NmCycTrkd : 39|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB9LatPosDev : 36|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB9LngPosDev : 33|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1320 F_Fwd_Fus_Obj_TrackB_8: 7 EOCM_F_FO - SG_ FwdFusTrkBAnlgRlLn8 : 46|8@0- (0.1,0) [-12.8|12.7] "" Dummy_FO - SG_ FwdFusTrkB8RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB8Width : 5|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FwdFusTrkB8MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkB8DynProp : 11|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB8RelLnAccl : 8|9@0- (0.125,0) [-32|31.875] "m/s^2" Dummy_FO - SG_ FwdFusTrkB8RelLane : 31|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB8Height : 54|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FFusTrkB8ObjSrcLFSrr : 29|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB8ObjSrcLCSrr : 28|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB8ObjSrcRCSrr : 27|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB8ObjSrcRFSrr : 26|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB8ObjSrcVIs : 25|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB8ObjSrcLrr : 24|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB8NmCycTrkd : 39|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB8LatPosDev : 36|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB8LngPosDev : 33|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1319 F_Fwd_Fus_Obj_TrackB_7: 7 EOCM_F_FO - SG_ FwdFusTrkBAnlgRlLn7 : 46|8@0- (0.1,0) [-12.8|12.7] "" Dummy_FO - SG_ FwdFusTrkB7RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB7Width : 5|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FwdFusTrkB7MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkB7DynProp : 11|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB7RelLnAccl : 8|9@0- (0.125,0) [-32|31.875] "m/s^2" Dummy_FO - SG_ FwdFusTrkB7RelLane : 31|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB7Height : 54|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FFusTrkB7ObjSrcLFSrr : 29|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB7ObjSrcLCSrr : 28|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB7ObjSrcRCSrr : 27|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB7ObjSrcRFSrr : 26|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB7ObjSrcVIs : 25|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB7ObjSrcLrr : 24|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB7NmCycTrkd : 39|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB7LatPosDev : 36|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB7LngPosDev : 33|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1318 F_Fwd_Fus_Obj_TrackB_6: 7 EOCM_F_FO - SG_ FwdFusTrkBAnlgRlLn6 : 46|8@0- (0.1,0) [-12.8|12.7] "" Dummy_FO - SG_ FwdFusTrkB6RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB6Width : 5|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FwdFusTrkB6MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkB6DynProp : 11|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB6RelLnAccl : 8|9@0- (0.125,0) [-32|31.875] "m/s^2" Dummy_FO - SG_ FwdFusTrkB6RelLane : 31|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB6Height : 54|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FFusTrkB6ObjSrcLFSrr : 29|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB6ObjSrcLCSrr : 28|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB6ObjSrcRCSrr : 27|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB6ObjSrcRFSrr : 26|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB6ObjSrcVIs : 25|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB6ObjSrcLrr : 24|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB6NmCycTrkd : 39|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB6LatPosDev : 36|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB6LngPosDev : 33|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1317 F_Fwd_Fus_Obj_TrackB_5: 7 EOCM_F_FO - SG_ FwdFusTrkBAnlgRlLn5 : 46|8@0- (0.1,0) [-12.8|12.7] "" Dummy_FO - SG_ FwdFusTrkB5RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB5Width : 5|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FwdFusTrkB5MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkB5DynProp : 11|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB5RelLnAccl : 8|9@0- (0.125,0) [-32|31.875] "m/s^2" Dummy_FO - SG_ FwdFusTrkB5RelLane : 31|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB5Height : 54|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FFusTrkB5ObjSrcLFSrr : 29|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB5ObjSrcLCSrr : 28|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB5ObjSrcRCSrr : 27|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB5ObjSrcRFSrr : 26|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB5ObjSrcVIs : 25|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB5ObjSrcLrr : 24|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB5NmCycTrkd : 39|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB5LatPosDev : 36|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB5LngPosDev : 33|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1316 F_Fwd_Fus_Obj_TrackB_4: 7 EOCM_F_FO - SG_ FwdFusTrkBAnlgRlLn4 : 46|8@0- (0.1,0) [-12.8|12.7] "" Dummy_FO - SG_ FwdFusTrkB4RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB4Width : 5|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FwdFusTrkB4MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkB4DynProp : 11|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB4RelLnAccl : 8|9@0- (0.125,0) [-32|31.875] "m/s^2" Dummy_FO - SG_ FwdFusTrkB4RelLane : 31|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB4Height : 54|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FFusTrkB4ObjSrcLFSrr : 29|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB4ObjSrcLCSrr : 28|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB4ObjSrcRCSrr : 27|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB4ObjSrcRFSrr : 26|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB4ObjSrcVIs : 25|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB4ObjSrcLrr : 24|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB4NmCycTrkd : 39|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB4LatPosDev : 36|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB4LngPosDev : 33|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1315 F_Fwd_Fus_Obj_TrackB_3: 7 EOCM_F_FO - SG_ FwdFusTrkBAnlgRlLn3 : 46|8@0- (0.1,0) [-12.8|12.7] "" Dummy_FO - SG_ FwdFusTrkB3RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB3Width : 5|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FwdFusTrkB3MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkB3DynProp : 11|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB3RelLnAccl : 8|9@0- (0.125,0) [-32|31.875] "m/s^2" Dummy_FO - SG_ FwdFusTrkB3RelLane : 31|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB3Height : 54|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FFusTrkB3ObjSrcLFSrr : 29|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB3ObjSrcLCSrr : 28|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB3ObjSrcRCSrr : 27|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB3ObjSrcRFSrr : 26|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB3ObjSrcVIs : 25|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB3ObjSrcLrr : 24|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB3NmCycTrkd : 39|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB3LatPosDev : 36|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB3LngPosDev : 33|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1314 F_Fwd_Fus_Obj_TrackB_2: 7 EOCM_F_FO - SG_ FwdFusTrkBAnlgRlLn2 : 46|8@0- (0.1,0) [-12.8|12.7] "" Dummy_FO - SG_ FwdFusTrkB2RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB2Width : 5|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FwdFusTrkB2MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkB2DynProp : 11|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB2RelLnAccl : 8|9@0- (0.125,0) [-32|31.875] "m/s^2" Dummy_FO - SG_ FwdFusTrkB2RelLane : 31|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB2Height : 54|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FFusTrkB2ObjSrcLFSrr : 29|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB2ObjSrcLCSrr : 28|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB2ObjSrcRCSrr : 27|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB2ObjSrcRFSrr : 26|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB2ObjSrcVIs : 25|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB2ObjSrcLrr : 24|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB2NmCycTrkd : 39|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB2LatPosDev : 36|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB2LngPosDev : 33|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1327 F_Fwd_Fus_Obj_TrackB_15: 7 EOCM_F_FO - SG_ FwdFusTrkBAnlgRlLn15 : 46|8@0- (0.1,0) [-12.8|12.7] "" Dummy_FO - SG_ FwdFusTrkB15RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB15Width : 5|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FwdFusTrkB15MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkB15DynProp : 11|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB15RelLnAccl : 8|9@0- (0.125,0) [-32|31.875] "m/s^2" Dummy_FO - SG_ FwdFusTrkB15RelLane : 31|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB15Height : 54|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FFusTrkB15ObjSrcLFSrr : 29|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB15ObjSrcLCSrr : 28|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB15ObjSrcRCSrr : 27|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB15ObjSrcRFSrr : 26|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTkB15ObjSrcVIs : 25|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB15ObjSrcLrr : 24|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB15NmCycTrkd : 39|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB15LatPosDev : 36|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB15LngPosDev : 33|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1326 F_Fwd_Fus_Obj_TrackB_14: 7 EOCM_F_FO - SG_ FwdFusTrkBAnlgRlLn14 : 46|8@0- (0.1,0) [-12.8|12.7] "" Dummy_FO - SG_ FwdFusTrkB14RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB14Width : 5|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FwdFusTrkB14MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkB14DynProp : 11|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB14RelLnAccl : 8|9@0- (0.125,0) [-32|31.875] "m/s^2" Dummy_FO - SG_ FwdFusTrkB14RelLane : 31|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB14Height : 54|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FFusTrkB14ObjSrcLFSrr : 29|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB14ObjSrcLCSrr : 28|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB14ObjSrcRCSrr : 27|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB14ObjSrcRFSrr : 26|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB14ObjSrcVIs : 25|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB14ObjSrcLrr : 24|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB14NmCycTrkd : 39|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB14LatPosDev : 36|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB14LngPosDev : 33|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1325 F_Fwd_Fus_Obj_TrackB_13: 7 EOCM_F_FO - SG_ FwdFusTrkBAnlgRlLn13 : 46|8@0- (0.1,0) [-12.8|12.7] "" Dummy_FO - SG_ FwdFusTrkB13RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB13Width : 5|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FwdFusTrkB13MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkB13DynProp : 11|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB13RelLnAccl : 8|9@0- (0.125,0) [-32|31.875] "m/s^2" Dummy_FO - SG_ FwdFusTrkB13RelLane : 31|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB13Height : 54|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FFusTrkB13ObjSrcLFSrr : 29|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB13ObjSrcLCSrr : 28|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB13ObjSrcRCSrr : 27|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB13ObjSrcRFSrr : 26|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB13ObjSrcVIs : 25|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB13ObjSrcLrr : 24|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB13NmCycTrkd : 39|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB13LatPosDev : 36|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB13LngPosDev : 33|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1324 F_Fwd_Fus_Obj_TrackB_12: 7 EOCM_F_FO - SG_ FwdFusTrkBAnlgRlLn12 : 46|8@0- (0.1,0) [-12.8|12.7] "" Dummy_FO - SG_ FwdFusTrkB12RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB12Width : 5|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FwdFusTrkB12MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkB12DynProp : 11|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB12RelLnAccl : 8|9@0- (0.125,0) [-32|31.875] "m/s^2" Dummy_FO - SG_ FwdFusTrkB12RelLane : 31|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB12Height : 54|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FFusTrkB12ObjSrcLFSrr : 29|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB12ObjSrcLCSrr : 28|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB12ObjSrcRCSrr : 27|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB12ObjSrcRFSrr : 26|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB12ObjSrcVIs : 25|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB12ObjSrcLrr : 24|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB12NmCycTrkd : 39|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB12LatPosDev : 36|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB12LngPosDev : 33|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1323 F_Fwd_Fus_Obj_TrackB_11: 7 EOCM_F_FO - SG_ FwdFusTrkB11DynProp : 11|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB11RelLnAccl : 8|9@0- (0.125,0) [-32|31.875] "m/s^2" Dummy_FO - SG_ FwdFusTrkB11RelLane : 31|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB11Height : 54|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FFusTrkB11ObjSrcLFSrr : 29|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB11ObjSrcLCSrr : 28|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB11ObjSrcRCSrr : 27|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB11ObjSrcRFSrr : 26|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB11ObjSrcVIs : 25|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB11ObjSrcLrr : 24|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB11NmCycTrkd : 39|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB11LatPosDev : 36|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB11LngPosDev : 33|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkBAnlgRlLn11 : 46|8@0- (0.1,0) [-12.8|12.7] "" Dummy_FO - SG_ FwdFusTrkB11RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB11Width : 5|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FwdFusTrkB11MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - -BO_ 1322 F_Fwd_Fus_Obj_TrackB_10: 7 EOCM_F_FO - SG_ FwdFusTrkBAnlgRlLn10 : 46|8@0- (0.1,0) [-12.8|12.7] "" Dummy_FO - SG_ FwdFusTrkB10RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB10Width : 5|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FwdFusTrkB10MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkB10DynProp : 11|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB10RelLnAccl : 8|9@0- (0.125,0) [-32|31.875] "m/s^2" Dummy_FO - SG_ FwdFusTrkB10RelLane : 31|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB10Height : 54|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FFusTrkB10ObjSrcLFSrr : 29|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB10ObjSrcLCSrr : 28|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB10ObjSrcRCSrr : 27|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB10ObjSrcRFSrr : 26|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB10ObjSrcVIs : 25|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB10ObjSrcLrr : 24|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB10NmCycTrkd : 39|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB10LatPosDev : 36|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB10LngPosDev : 33|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1313 F_Fwd_Fus_Obj_TrackB_1: 7 EOCM_F_FO - SG_ FwdFusTrkBAnlgRlLn1 : 46|8@0- (0.1,0) [-12.8|12.7] "" Dummy_FO - SG_ FwdFusTrkB1RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB1Width : 5|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FwdFusTrkB1MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkB1DynProp : 11|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB1RelLnAccl : 8|9@0- (0.125,0) [-32|31.875] "m/s^2" Dummy_FO - SG_ FwdFusTrkB1RelLane : 31|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkB1Height : 54|6@0+ (0.25,0) [0|15.75] "m" Dummy_FO - SG_ FFusTrkB1ObjSrcLFSrr : 29|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB1ObjSrcLCSrr : 28|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB1ObjSrcRCSrr : 27|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB1ObjSrcRFSrr : 26|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FFusTrkB1ObjSrcVIs : 25|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB1ObjSrcLrr : 24|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FwdFusTrkB1NmCycTrkd : 39|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB1LatPosDev : 36|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkB1LngPosDev : 33|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1305 F_Fwd_Fus_Obj_TrackA_9: 8 EOCM_F_FO - SG_ FwdFusTrkA9RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA9ObjectID : 5|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ FwdFusTrkA9MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkA9LongPos : 11|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - SG_ FwdFusTrkA9RelLongVel : 31|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA9Confidence : 36|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA9LatPos : 34|11@0- (0.125,0) [-128|127.875] "m" Dummy_FO - SG_ FwdFusTrkA9RelLatVel : 55|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA9MeasStatus : 60|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA9ObjType : 58|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1304 F_Fwd_Fus_Obj_TrackA_8: 8 EOCM_F_FO - SG_ FwdFusTrkA8RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA8ObjectID : 5|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ FwdFusTrkA8MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkA8LongPos : 11|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - SG_ FwdFusTrkA8RelLongVel : 31|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA8Confidence : 36|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA8LatPos : 34|11@0- (0.125,0) [-128|127.875] "m" Dummy_FO - SG_ FwdFusTrkA8RelLatVel : 55|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA8MeasStatus : 60|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA8ObjType : 58|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1303 F_Fwd_Fus_Obj_TrackA_7: 8 EOCM_F_FO - SG_ FwdFusTrkA7RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA7ObjectID : 5|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ FwdFusTrkA7MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkA7LongPos : 11|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - SG_ FwdFusTrkA7RelLongVel : 31|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA7Confidence : 36|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA7LatPos : 34|11@0- (0.125,0) [-128|127.875] "m" Dummy_FO - SG_ FwdFusTrkA7RelLatVel : 55|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA7MeasStatus : 60|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA7ObjType : 58|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1302 F_Fwd_Fus_Obj_TrackA_6: 8 EOCM_F_FO - SG_ FwdFusTrkA6RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA6ObjectID : 5|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ FwdFusTrkA6MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkA6LongPos : 11|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - SG_ FwdFusTrkA6RelLongVel : 31|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA6Confidence : 36|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA6LatPos : 34|11@0- (0.125,0) [-128|127.875] "m" Dummy_FO - SG_ FwdFusTrkA6RelLatVel : 55|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA6MeasStatus : 60|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA6ObjType : 58|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1301 F_Fwd_Fus_Obj_TrackA_5: 8 EOCM_F_FO - SG_ FwdFusTrkA5RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA5ObjectID : 5|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ FwdFusTrkA5MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkA5LongPos : 11|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - SG_ FwdFusTrkA5RelLongVel : 31|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA5Confidence : 36|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA5LatPos : 34|11@0- (0.125,0) [-128|127.875] "m" Dummy_FO - SG_ FwdFusTrkA5RelLatVel : 55|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA5MeasStatus : 60|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA5ObjType : 58|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1300 F_Fwd_Fus_Obj_TrackA_4: 8 EOCM_F_FO - SG_ FwdFusTrkA4RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA4ObjectID : 5|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ FwdFusTrkA4MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkA4LongPos : 11|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - SG_ FwdFusTrkA4RelLongVel : 31|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA4Confidence : 36|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA4LatPos : 34|11@0- (0.125,0) [-128|127.875] "m" Dummy_FO - SG_ FwdFusTrkA4RelLatVel : 55|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA4MeasStatus : 60|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA4ObjType : 58|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1299 F_Fwd_Fus_Obj_TrackA_3: 8 EOCM_F_FO - SG_ FwdFusTrkA3RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA3ObjectID : 5|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ FwdFusTrkA3MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkA3LongPos : 11|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - SG_ FwdFusTrkA3RelLongVel : 31|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA3Confidence : 36|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA3LatPos : 34|11@0- (0.125,0) [-128|127.875] "m" Dummy_FO - SG_ FwdFusTrkA3RelLatVel : 55|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA3MeasStatus : 60|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA3ObjType : 58|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1298 F_Fwd_Fus_Obj_TrackA_2: 8 EOCM_F_FO - SG_ FwdFusTrkA2RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA2ObjectID : 5|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ FwdFusTrkA2MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkA2LongPos : 11|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - SG_ FwdFusTrkA2RelLongVel : 31|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA2Confidence : 36|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA2LatPos : 34|11@0- (0.125,0) [-128|127.875] "m" Dummy_FO - SG_ FwdFusTrkA2RelLatVel : 55|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA2MeasStatus : 60|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA2ObjType : 58|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1311 F_Fwd_Fus_Obj_TrackA_15: 8 EOCM_F_FO - SG_ FwdFusTrkA15RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA15ObjectID : 5|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ FwdFusTrkA15MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkA15LongPos : 11|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - SG_ FwdFusTrkA15RelLongVel : 31|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA15Confidence : 36|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA15LatPos : 34|11@0- (0.125,0) [-128|127.875] "m" Dummy_FO - SG_ FwdFusTrkA15RelLatVel : 55|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA15MeasStatus : 60|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA15ObjType : 58|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1310 F_Fwd_Fus_Obj_TrackA_14: 8 EOCM_F_FO - SG_ FwdFusTrkA14RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA14ObjectID : 5|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ FwdFusTrkA14MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkA14LongPos : 11|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - SG_ FwdFusTrkA14RelLongVel : 31|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA14Confidence : 36|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA14LatPos : 34|11@0- (0.125,0) [-128|127.875] "m" Dummy_FO - SG_ FwdFusTrkA14RelLatVel : 55|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA14MeasStatus : 60|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA14ObjType : 58|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1309 F_Fwd_Fus_Obj_TrackA_13: 8 EOCM_F_FO - SG_ FwdFusTrkA13RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA13ObjectID : 5|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ FwdFusTrkA13MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkA13LongPos : 11|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - SG_ FwdFusTrkA13RelLongVel : 31|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA13Confidence : 36|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA13LatPos : 34|11@0- (0.125,0) [-128|127.875] "m" Dummy_FO - SG_ FwdFusTrkA13RelLatVel : 55|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA13MeasStatus : 60|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA13ObjType : 58|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1308 F_Fwd_Fus_Obj_TrackA_12: 8 EOCM_F_FO - SG_ FwdFusTrkA12RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA12ObjectID : 5|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ FwdFusTrkA12MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkA12LongPos : 11|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - SG_ FwdFusTrkA12RelLongVel : 31|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA12Confidence : 36|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA12LatPos : 34|11@0- (0.125,0) [-128|127.875] "m" Dummy_FO - SG_ FwdFusTrkA12RelLatVel : 55|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA12MeasStatus : 60|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA12ObjType : 58|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1307 F_Fwd_Fus_Obj_TrackA_11: 8 EOCM_F_FO - SG_ FwdFusTrkA11ObjectID : 5|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ FwdFusTrkA11MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkA11LongPos : 11|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - SG_ FwdFusTrkA11RelLongVel : 31|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA11Confidence : 36|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA11LatPos : 34|11@0- (0.125,0) [-128|127.875] "m" Dummy_FO - SG_ FwdFusTrkA11RelLatVel : 55|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA11MeasStatus : 60|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA11ObjType : 58|3@0+ (1,0) [0|7] "" Dummy_FO - SG_ FwdFusTrkA11RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - -BO_ 1306 F_Fwd_Fus_Obj_TrackA_10: 8 EOCM_F_FO - SG_ FwdFusTrkA10RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA10ObjectID : 5|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ FwdFusTrkA10MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkA10LongPos : 11|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - SG_ FwdFusTrkA10RelLongVel : 31|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA10Confidence : 36|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA10LatPos : 34|11@0- (0.125,0) [-128|127.875] "m" Dummy_FO - SG_ FwdFusTrkA10RelLatVel : 55|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA10MeasStatus : 60|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA10ObjType : 58|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1297 F_Fwd_Fus_Obj_TrackA_1: 8 EOCM_F_FO - SG_ FwdFusTrkA1RollingCnt : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA1ObjectID : 5|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ FwdFusTrkA1MsgIndex : 15|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ FwdFusTrkA1LongPos : 11|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - SG_ FwdFusTrkA1RelLongVel : 31|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA1Confidence : 36|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA1LatPos : 34|11@0- (0.125,0) [-128|127.875] "m" Dummy_FO - SG_ FwdFusTrkA1RelLatVel : 55|11@0- (0.125,0) [-128|127.875] "m/s" Dummy_FO - SG_ FwdFusTrkA1MeasStatus : 60|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ FwdFusTrkA1ObjType : 58|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 1296 F_Fwd_Fus_Obj_Header: 7 EOCM_F_FO - SG_ F_FusHeadRollingCount : 7|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ F_FusHeadFuncState : 5|2@0+ (1,0) [0|3] "" Dummy_FO - SG_ F_FusHedNmValTargts : 3|4@0+ (1,0) [0|15] "" Dummy_FO - SG_ F_FusHead_LrrOK : 15|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ F_FusHead_LFSRROK : 14|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ F_FusHead_VIsOK : 13|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ F_FusHead_MapDataOK : 12|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ F_FusHeadTimStmpV : 11|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ F_FusHeadTimStmp : 10|11@0+ (1,0) [0|2047] "ms" Dummy_FO - SG_ F_FusHead_LCSRROK : 31|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ F_FusHead_RCSRROK : 30|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ F_FusHead_RFSRROK : 29|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ F_FusHed_ObjClstrCurv : 28|13@0- (5E-005,0) [-0.2048|0.20475] "1/m" Dummy_FO - SG_ F_FusHdObjClstTanHdng : 47|8@0- (0.002,0) [-0.256|0.254] "m/m" Dummy_FO - SG_ RoadTypeInfo : 55|3@0+ (1,0) [0|7] "" Dummy_FO - -BO_ 257 USDT_Req_to_All_FO_ECUs: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" LRSRR_FO,_DOFIMU2_FO,_DOFIMU1_FO,DMS_FO,AMM_FO,EOCM2A_K2_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM2A_IMX6_FO,EOCM2A_K1_FO,NVS_FO,CIPM_FO,VIS2_FO,RRSRR_FO,VIS_FO,RFSRR_FO,LRR_FO,LFSRR_FO,RSRR_FO,EOCM_F_FO - -BO_ 584 USDT_Req_to_6DOFIMU2_FO: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" _DOFIMU2_FO - -BO_ 1348 UUDT_Resp_From_6DOFIMU1_FO: 8 _DOFIMU1_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1604 USDT_Resp_From_6DOFIMU1_FO: 8 _DOFIMU1_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 580 USDT_Req_to_6DOFIMU1_FO: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" _DOFIMU1_FO - -BO_ 1349 UUDT_Resp_From_DMS_FO: 8 DMS_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1605 USDT_Resp_From_DMS_FO: 8 DMS_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 581 USDT_Req_to_DMS_FO: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" DMS_FO - -BO_ 1372 UUDT_Resp_From_AMM_FO: 8 AMM_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1628 USDT_Resp_From_AMM_FO: 8 AMM_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 604 USDT_Req_to_AMM_FO: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" AMM_FO - -BO_ 1622 USDT_Resp_From_EOCM2B_IMX6_FO: 8 EOCM2B_IMX6_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 1366 UUDT_Resp_From_EOCM2B_IMX6_FO: 8 EOCM2B_IMX6_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" TestTool_FO - -BO_ 598 USDT_Req_to_EOCM2B_IMX6_FO: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" EOCM2B_IMX6_FO - -BO_ 590 USDT_Req_to_Free_4E_FO: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" Vector__XXX - -BO_ 1338 VPDR_Debug: 8 EOCM_F_FO - SG_ FrtRWARateDiagFA : 43|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FrtRWABiasDiagFA : 42|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ HWAFrtVal : 41|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ HWADotValFrt : 40|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S2VehAxRangeFA : 39|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S2VehAxRateFA : 38|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S2VehAxBiasFA : 37|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VehAxCompFA : 36|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S1VehAxVal : 35|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S2VehAxVal : 34|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FrtRWACorrFA : 33|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FrtRWARangeDiagFA : 32|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S2VehAyBiasFA : 31|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VehAyCompFA : 30|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S1VehAyVal : 29|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S2VehAyVal : 28|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VehAxCorrFA : 27|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S1VehAxRangeFA : 26|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S1VehAxRateFA : 25|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S1VehAxBiasFA : 24|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S1VehWzVal : 23|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S2VehWzVal : 22|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VehAyCorrDiagFA : 21|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S1VehAyRangeFA : 20|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S1VehAyRateFA : 19|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S1VehAyBiasFA : 18|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S2VehAyRangeFA : 17|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S2VehAyRateFA : 16|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VehWzCorrDiagFA : 15|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S1VehWzRangeFA : 14|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S1VehWzRateFA : 13|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S1VehWzBiasFA : 12|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S2VehWzRangeFA : 11|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S2VehWzRateFA : 10|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ S2VehWzBiasFA : 9|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VehWzCompFA : 8|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ WhlVxLFCorrDiagFA : 7|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ WhlVxRFCorrDiagFA : 6|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ WhlVxLRCorrDiagFA : 5|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ WhlVxRRCorrDiagFA : 4|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ WhlLFVal : 3|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ WhlRFVal : 2|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ WhlLRVal : 1|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ WhlRRVal : 0|1@0+ (1,0) [0|1] "" Dummy_FO - -BO_ 1328 Diag_Debug1: 8 EOCM_F_FO - SG_ AlrtWrnIndReqFP : 1|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ AlrtWrnIndReqFA : 0|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ILRSRRSnsr_FP : 24|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ILRSRRSnsr_FA : 23|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ILRSRRFrehns_FA : 22|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VehPathEstCrvCSFP : 21|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VehPathEstCrvCSFA : 20|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VehPathWzEstCSFP : 19|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VehPathWzEstCSFA : 18|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VehPathVyEstCSFP : 17|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VehPathVyEstCSFA : 16|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VehPathVxEstCSFP : 15|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VehPathVxEstCSFA : 14|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtTTCCSFP : 13|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtTTCCSFA : 12|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtLyCSFP : 11|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtLyCSFA : 10|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThLxVxAxCSFP : 9|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThLxVxAxCSFA : 8|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ CurSetValDiagFP : 7|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ CurSetValDiagFA : 6|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ CrsAltDvrSlTpDiagFP : 5|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ CrsAltDvrSlTpDiagFA : 4|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FCAStatDiagFP : 3|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FCAStatDiagFA : 2|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ RVBBrkCtrlStFP : 62|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ RVBBrkCtrlStFA : 61|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ RVBOpStFP : 60|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ RVBOpStFA : 59|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ RVBBrkCtrlAccFP : 58|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ RVBBrkCtrlAccFA : 57|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ RVBAxlTrqRqFP : 56|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ RVBAxlTrqRqFA : 55|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TVRUPATTCFP : 54|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TVRUPATTCFA : 53|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TVRHiThrtObjIDFP : 52|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TVRHiThrtObjIDFA : 51|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TVRHiThrtTTCFP : 50|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TVRHiThrtTTCFA : 49|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TVRHiThrtLxFP : 48|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TVRHiThrtLxFA : 47|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TVRHiThrtLyFP : 46|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TVRHiThrtLyFA : 45|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ROFFuncStFP : 44|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ROFFuncStFA : 43|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ROFObjIDFP : 42|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ROFObjIDFA : 41|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ROFLatPstnVelRatFP : 40|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ROFLatPstnVelRatFA : 39|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ROFLonPstnVelFP : 38|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ROFLonPstnVelFA : 37|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ROFRltvLatVelDiagFP : 36|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ROFRltvLatVelDiagFA : 35|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ROFRltvLatPstnDiagFP : 34|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ROFRltvLatPstnDiagFA : 33|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ROFNrRltvLonPstnFP : 32|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ROFNrRltvLonPstnFA : 31|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ROFLonPstnVelRatFP : 30|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ROFLonPstnVelRatFA : 29|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ROFConfDiagFP : 28|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ROFConfDiagFA : 27|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ROFRltvLnDiagFP : 26|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ROFRltvLnDiagFA : 25|1@0+ (1,0) [0|1] "" Dummy_FO - -BO_ 1335 Diag_Debug3: 8 EOCM_F_FO - SG_ BrkSysCmdAxDiagFPQ : 63|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ BrkSysCmdAxDiagFAQ : 62|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ AxleTorqReqDiagFPQ : 61|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ AxleTorqReqDiagFAQ : 60|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ AutoBrkTypeDiagFPQ : 59|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ AutoBrkTypeDiagFAQ : 58|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtTTCFPQ : 57|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtTTCFAQ : 56|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtTmpMemFPQ : 55|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtTmpMemFAQ : 54|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtLxVxAxFPQ : 53|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtLxVxAxFAQ : 52|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtVyFPQ : 51|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtVyFAQ : 50|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtLyFPQ : 49|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtLyFAQ : 48|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtConPriFPQ : 47|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtConPriFAQ : 46|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtCJLFPQ : 45|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtCJLFAQ : 44|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPDynPropDiagFPQ : 43|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPDynPropDiagFAQ : 42|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFRdTypInfoFPQ : 41|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFRdTypInfoFAQ : 40|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFRltvLnDiagFPQ : 39|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFRltvLnDiagFAQ : 38|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFNumCycDiagFPQ : 37|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFNumCycDiagFAQ : 36|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFNumFusCyclsFPQ : 35|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFNumFusCyclsFAQ : 34|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFNrRltvLonPstnFPQ : 33|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFNrRltvLonPstnFAQ : 32|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFLonVelAccRatFPQ : 31|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFLonVelAccRatFAQ : 30|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFLonPstnVelRatFPQ : 29|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFLonPstnVelRatFAQ : 28|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFLonPosVelAccFPQ : 27|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFLonPosVelAccFAQ : 26|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFLatVelDiagFPQ : 25|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFLatVelDiagFAQ : 24|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFLatPstnDiagFPQ : 23|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFLatPstnDiagFAQ : 22|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFConfDiagFPQ : 21|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFConfDiagFAQ : 20|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ILFOvrlpRtlChk_FAQ : 19|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ IRFOvrlpRtlChk_FAQ : 18|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ LRROvrlpRtlChk_FAQ : 17|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VISOvrlpRtlChk_FAQ : 16|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VISAlign_FAQ : 15|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VISSnsr_FAQ : 14|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VISSnsr_FPQ : 13|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VISFrshns_FAQ : 12|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ LRRAlign_FAQ : 11|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ LRRFrshns_FAQ : 10|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ LRRSnsr_FAQ : 9|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ LRRSnsr_FPQ : 8|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ IRFSRRAlign_FAQ : 7|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ IRFSRRFrehns_FAQ : 6|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ IRFSRRSnsr_FAQ : 5|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ IRFSRRSnsr_FPQ : 4|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ILFSRRSnsr_FPQ : 3|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ILFSRRSnsr_FAQ : 2|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ILFSRRFrshns_FAQ : 1|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ILFSRRAlign_FAQ : 0|1@0+ (1,0) [0|1] "" Dummy_FO - -BO_ 1331 Diag_Debug2: 8 EOCM_F_FO - SG_ TCPHiThrtTmpMemFP : 63|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtTmpMemFA : 62|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtConPriFP : 61|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtConPriFA : 60|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtCJLFP : 59|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtTTCFP : 58|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtTTCFA : 57|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtVyFP : 56|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtVyFA : 55|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtLyFP : 54|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtLyFA : 53|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtLxVxAxFP : 52|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtLxVxAxFA : 51|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFRdTypInfoFP : 50|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFRdTypInfoFA : 49|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ AutoBrkTypeDiagFA : 48|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ BrkSysCmdAxDiagFP : 47|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ BrkSysCmdAxDiagFA : 46|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ AxleTorqReqDiagFP : 45|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ AxleTorqReqDiagFA : 44|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPDynPropDiagFP : 43|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPDynPropDiagFA : 42|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ TCPHiThrtCJLFA : 41|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFNumFusCyclsFP : 40|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ AutoBrkTypeDiagFP : 39|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFNumFusCyclsFA : 38|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFLatVelDiagFP : 37|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFLatVelDiagFA : 36|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFLatPstnDiagFP : 35|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFLatPstnDiagFA : 34|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFNumCycDiagFP : 33|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFNumCycDiagFA : 32|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFRltvLnDiagFP : 31|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFRltvLnDiagFA : 30|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFConfDiagFP : 29|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFConfDiagFA : 28|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFLonVelAccRatFP : 27|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFLonVelAccRatFA : 26|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFLonPstnVelRatFP : 25|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFLonPstnVelRatFA : 24|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFNrRltvLonPstnFP : 23|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFNrRltvLonPstnFA : 22|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFLonPosVelAccFP : 21|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ FOFLonPosVelAccFA : 20|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VISOvrlpRtlChk_FA : 19|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ LRROvrlpRtlChk_FA : 18|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ IRFOvrlpRtlChk_FA : 17|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ILFOvrlpRtlChk_FA : 16|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VISAlign_FA : 15|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VISFrshns_FA : 14|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VISSnsr_FP : 13|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ VISSnsr_FA : 12|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ LRRAlign_FA : 11|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ LRRFrshns_FA : 10|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ LRRSnsr_FP : 9|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ LRRSnsr_FA : 8|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ IRFSRRAlign_FA : 7|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ IRFSRRFrehns_FA : 6|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ IRFSRRSnsr_FP : 5|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ IRFSRRSnsr_FA : 4|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ILFSRRAlign_FA : 3|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ILFSRRFrshns_FA : 2|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ILFSRRSnsr_FP : 1|1@0+ (1,0) [0|1] "" Dummy_FO - SG_ ILFSRRSnsr_FA : 0|1@0+ (1,0) [0|1] "" Dummy_FO - -BO_ 1787 AL_Test_Tool_Rsp_RFSRR: 8 RFSRR_FO - SG_ RFSRREngRspDta : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" Dummy_FO - -BO_ 1788 AL_Test_Tool_Rsp_LFSRR: 8 LFSRR_FO - SG_ LFSRREngRspDta : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" Dummy_FO - -BO_ 1790 AL_Test_Tool_Req_RFSRR: 8 Dummy_FO - SG_ RFSRREngCmdDta : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" RFSRR_FO - -BO_ 1791 AL_Test_Tool_Req_LFSRR: 8 Dummy_FO - SG_ LFSRREngCmdDta : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" LFSRR_FO - -BO_ 1786 AL_Test_Tool_Rsp_RSRR: 8 RSRR_FO - SG_ RSRREngRspDta : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" Dummy_FO - -BO_ 1789 AL_Test_Tool_Req_RSRR: 8 Dummy_FO - SG_ RSRREngCmdDta : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" RSRR_FO - -BO_ 1149 F_LRR_Azmth_Rate_Info_4: 8 LRR_FO - SG_ FLRRTrk20AzmthRate : 50|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FLRRTrk19AzmthRate : 45|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FLRRTrk18AzmthRate : 24|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FLRRTrk17AzmthRate : 19|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FLRRTrk16AzmthRate : 14|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FLRRAzRtInf4BurstID : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1148 F_LRR_Azmth_Rate_Info_3: 8 LRR_FO - SG_ FLRRTrk15AzmthRate : 50|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FLRRTrk14AzmthRate : 45|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FLRRTrk13AzmthRate : 24|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FLRRTrk12AzmthRate : 19|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FLRRTrk11AzmthRate : 14|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FLRRAzRtInf3BurstID : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1147 F_LRR_Azmth_Rate_Info_2: 8 LRR_FO - SG_ FLRRTrk9AzmthRate : 45|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FLRRTrk8AzmthRate : 24|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FLRRTrk7AzmthRate : 19|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FLRRTrk6AzmthRate : 14|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FLRRTrk10AzmthRate : 50|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FLRRAzRtInf2BurstID : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1146 F_LRR_Azmth_Rate_Info_1: 8 LRR_FO - SG_ FLRRTrk5AzmthRate : 50|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FLRRTrk4AzmthRate : 45|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FLRRTrk3AzmthRate : 24|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FLRRTrk2AzmthRate : 19|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FLRRTrk1AzmthRate : 14|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO - SG_ FLRRAzRtInf1BurstID : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1143 Long_Range_Radar_add_Info_3: 8 LRR_FO - SG_ FLRRAddInfo3BurstID : 57|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk13ObstType : 60|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk20ObstTypeConf : 52|5@0+ (0.0323,0) [0|1.0013] "" EOCM_F_FO - SG_ FLRRTrk20ObstType : 55|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk19ObstTypeConf : 44|5@0+ (0.0323,0) [0|1.0013] "" EOCM_F_FO - SG_ FLRRTrk19ObstType : 47|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk18ObstTypeConf : 36|5@0+ (0.0323,0) [0|1.0013] "" EOCM_F_FO - SG_ FLRRTrk18ObstType : 39|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk17ObstTypeConf : 28|5@0+ (0.0323,0) [0|1.0013] "" EOCM_F_FO - SG_ FLRRTrk17ObstType : 31|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk16ObstTypeConf : 20|5@0+ (0.0323,0) [0|1.0013] "" EOCM_F_FO - SG_ FLRRTrk16ObstType : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk15ObstTypeConf : 12|5@0+ (0.0323,0) [0|1.0013] "" EOCM_F_FO - SG_ FLRRTrk15ObstType : 15|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk14ObstTypeConf : 4|5@0+ (0.0323,0) [0|1.0013] "" EOCM_F_FO - SG_ FLRRTrk14ObstType : 7|3@0+ (1,0) [0|7] "" EOCM_F_FO - -BO_ 1142 Long_Range_Radar_add_Info_2: 8 LRR_FO - SG_ FLRRAddInfo2BurstID : 62|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ FLRRTrk13ObstTypeConf : 60|5@0+ (0.0323,0) [0|1.0013] "" EOCM_F_FO - SG_ FLRRTrk12ObstTypeConf : 52|5@0+ (0.0323,0) [0|1.0013] "" EOCM_F_FO - SG_ FLRRTrk12ObstType : 55|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk11ObstTypeConf : 44|5@0+ (0.0323,0) [0|1.0013] "" EOCM_F_FO - SG_ FLRRTrk11ObstType : 47|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk10ObstTypeConf : 36|5@0+ (0.0323,0) [0|1.0013] "" EOCM_F_FO - SG_ FLRRTrk10ObstType : 39|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk9ObstTypeConf : 28|5@0+ (0.0323,0) [0|1.0013] "" EOCM_F_FO - SG_ FLRRTrk9ObstType : 31|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk8ObstTypeConf : 20|5@0+ (0.0323,0) [0|1.0013] "" EOCM_F_FO - SG_ FLRRTrk8ObstType : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk7ObstTypeConf : 12|5@0+ (0.0323,0) [0|1.0013] "" EOCM_F_FO - SG_ FLRRTrk7ObstType : 15|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ FLRRTrk1ObstTypeConf : 4|5@0+ (0.0323,0) [0|1.0013] "" EOCM_F_FO - SG_ FLRRTrk1ObstType : 7|3@0+ (1,0) [0|7] "" EOCM_F_FO - -BO_ 851 F_Vision_Environment_4: 8 VIS_FO - SG_ LnMrkg3LnPrvwDst : 45|4@0+ (10,0) [0|150] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsTtlNmLnMrkgDetRt : 4|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsRtLinCrsTm : 25|5@0+ (0.1,0) [0|3.1] "s" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsNumPrlLnsDetRt : 33|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsNumPrlLnsDetLt : 36|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsCrvtGrdntLftV : 31|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsLtLinCrsTm : 30|5@0+ (0.1,0) [0|3.1] "s" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg4LnPrvwDst : 50|4@0+ (10,0) [0|150] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg4LnMrkgTypChgDst : 61|4@0+ (10,0) [0|150] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg3LnMrkgTypChgDst : 40|4@0+ (10,0) [0|150] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg4LnMrkgWdth : 62|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg4LnMarkrElvtd : 51|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg4AnchrLnLin : 57|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg3LnMrkgWdth : 41|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg3LnMarkrElvtd : 46|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkg3AnchrLnLin : 52|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsBurstID2 : 1|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsCrvtGrdntLft : 15|16@0- (5.96E-008,0) [-0.0019529728|0.0019529132] "1/rad/s" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - -BO_ 597 USDT_Req_to_VIS2_FO: 8 TestTool_FO - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" CIPM_FO,VIS2_FO - -BO_ 1204 RR_SRR_Object_Track4: 8 RRSRR_FO - SG_ RRSrrTrkRawAzimuth4 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - SG_ RRSrrTrkRRate4 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RRSrrTrkRange4 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RRSrrTrkObsRange4 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RRSrrTrkObjID4 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RRSrrTrkObjElevation4 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkMeasStatus4 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkDynamProp4 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RRSrrTrkAzimuth4 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RRSrrBurstID4 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1203 RR_SRR_Object_Track3: 8 RRSRR_FO - SG_ RRSrrTrkRawAzimuth3 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - SG_ RRSrrTrkRRate3 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RRSrrTrkRange3 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RRSrrTrkObsRange3 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RRSrrTrkObjID3 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RRSrrTrkObjElevation3 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkMeasStatus3 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkDynamProp3 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RRSrrTrkAzimuth3 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - SG_ RRSrrBurstID3 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - -BO_ 1202 RR_SRR_Object_Track2: 8 RRSRR_FO - SG_ RRSrrBurstID2 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkRawAzimuth2 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - SG_ RRSrrTrkRRate2 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RRSrrTrkRange2 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RRSrrTrkObsRange2 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RRSrrTrkObjID2 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RRSrrTrkObjElevation2 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkMeasStatus2 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkDynamProp2 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RRSrrTrkAzimuth2 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - -BO_ 1201 RR_SRR_Object_Track1: 8 RRSRR_FO - SG_ RRSrrBurstID1 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkRawAzimuth1 : 61|6@0- (1,0) [-32|31] "deg" EOCM_F_FO - SG_ RRSrrTrkRRate1 : 18|11@0- (0.125,0) [-128|127.875] "m/s" EOCM_F_FO - SG_ RRSrrTrkRange1 : 2|11@0+ (0.02,0) [0|40.94] "m" EOCM_F_FO - SG_ RRSrrTrkObsRange1 : 53|6@0- (0.02,0) [-0.64|0.62] "m" EOCM_F_FO - SG_ RRSrrTrkObjID1 : 39|5@0+ (1,0) [0|31] "" EOCM_F_FO - SG_ RRSrrTrkObjElevation1 : 20|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkMeasStatus1 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSrrTrkDynamProp1 : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RRSrrTrkAzimuth1 : 34|11@0- (0.125,0) [-128|127.875] "deg" EOCM_F_FO - -BO_ 1200 RR_SRR_Object_Header: 8 RRSRR_FO - SG_ RRSrrTimeStampV : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSrrTimeStamp : 10|11@0+ (1,0) [0|2047] "" EOCM_F_FO - SG_ RRSrrRollingCnt : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO - SG_ RRSRRNumValidTargets : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO - SG_ RRSRRModeCmdFdbk : 4|3@0+ (1,0) [0|7] "" EOCM_F_FO - SG_ RRSRRVltgOutRngLo : 44|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRVltgOutRngHi : 43|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRSvcAlgnInPrcs : 38|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRSnsrBlckd : 45|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRSnstvFltPrsntInt : 24|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRPlntAlgnInProc : 37|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRMsalgnYawRt : 47|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRMsalgnYawLt : 46|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRMsalgnRllRt : 35|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRMsalgnRllLt : 34|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRMsalgnPtchUp : 32|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRMsalgnPtchDn : 33|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRInitDiagCmplt : 40|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRHWFltPrsntInt : 25|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRExtIntrfrnc : 36|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRDiagSpare : 30|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRCANSgnlSpvFld : 29|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRCANRxErr : 28|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRCANIDAddrsUnsbl : 27|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRAntTngFltPrsnt : 26|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRAmbTmpOutRngLw : 42|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRAmbTmpOutRngHi : 41|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSRRAlgnFltPrsnt : 39|1@0+ (1,0) [0|1] "" EOCM_F_FO - SG_ RRSrrBurstChecksum : 55|16@0+ (1,0) [0|65535] "" EOCM_F_FO - -BO_ 850 F_Vision_Environment_3: 8 VIS_FO - SG_ LnSnsTtlNmLnMrkgDetLt : 58|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsLtLnMrkgWdth : 63|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsLtLnMrkgTypChgDst : 62|4@0+ (10,0) [0|150] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsTngtOfHdngLnLftV : 23|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsTngtOfHdngLnLft : 31|8@0- (0.002,0) [-0.256|0.254] "m/m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsLnCrvtrLftV : 15|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsLnCrvtrLft : 39|16@0- (9.53E-007,0) [-0.031227904|0.031226951] "1/m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkrTypRght : 50|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkrTypLft : 53|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkrElvtdRght : 54|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnMrkrElvtdLft : 55|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnSnsBurstID1 : 7|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnQltyCnfdncLvlRght : 22|7@0+ (0.7874016,0) [0|100.0000032] "%" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnQltyCnfdncLvlLft : 14|7@0+ (0.7874016,0) [0|100.0000032] "%" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnPrvwDstncRght : 2|3@0+ (10,0) [0|70] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - SG_ LnPrvwDstncLft : 5|3@0+ (10,0) [0|70] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO - -BO_ 1414 RVB_TVR_Debug2_FO: 7 EOCM_F_FO - SG_ VBBrkCntlAccel : 45|12@0- (0.01,0) [-20.48|20.47] "m/s^2" Dummy_FO - SG_ VBTOSObjID : 35|6@0+ (1,0) [0|63] "" Dummy_FO - SG_ VBTOSTTC : 31|12@0+ (0.025,0) [0|102.375] "s" Dummy_FO - SG_ VBTOSLatPstn : 11|11@0- (0.125,0) [-128|127.875] "m" Dummy_FO - SG_ VBTOSLonPstn : 7|12@0- (0.125,0) [-256|255.875] "m" Dummy_FO - diff --git a/opendbc/cadillac_ct6_powertrain.dbc b/opendbc/cadillac_ct6_powertrain.dbc deleted file mode 100644 index f139b1dbd4a734..00000000000000 --- a/opendbc/cadillac_ct6_powertrain.dbc +++ /dev/null @@ -1,244 +0,0 @@ -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_: K16_BECM K73_TCIC K9_BCM K43_PSCM K17_EBCM K20_ECM K114B_HPCM NEO K124_ASCM -VAL_TABLE_ TurnSignals 2 "Right Turn" 1 "Left Turn" 0 "None" ; -VAL_TABLE_ ACCLeadCar 1 "Present" 0 "Not Present" ; -VAL_TABLE_ ACCCmdActive 1 "Active" 0 "Inactive" ; -VAL_TABLE_ BrakePedalPressed 1 "Pressed" 0 "Depressed" ; -VAL_TABLE_ DistanceButton 1 "Active" 0 "Inactive" ; -VAL_TABLE_ LKAButton 1 "Active" 0 "Inactive" ; -VAL_TABLE_ ACCButtons 6 "Cancel" 5 "Main" 3 "Set" 2 "Resume" 1 "None" ; -VAL_TABLE_ PRNDL 3 "Reverse" 2 "Drive" 1 "Neutral" 0 "Park" ; -VAL_TABLE_ DoorStatus 1 "Opened" 0 "Closed" ; -VAL_TABLE_ SeatBeltStatus 1 "Latched" 0 "Unlatched" ; -VAL_TABLE_ LKASteeringCmdActive 1 "Active" 0 "Inactive" ; -VAL_TABLE_ ACCGapLevel 3 "Far" 2 "Med" 1 "Near" 0 "Inactive" ; -VAL_TABLE_ GasRegenCmdActiveInv 1 "Inactive" 0 "Active" ; -VAL_TABLE_ GasRegenCmdActive 1 "Active" 0 "Inactive" ; -VAL_TABLE_ LKATorqueDeliveredStatus 3 "Failed" 2 "Temp. Limited" 1 "Active" 0 "Inactive" ; -VAL_TABLE_ HandsOffSWDetectionStatus 1 "Hands On" 0 "Hands Off" ; -VAL_TABLE_ HandsOffSWDetectionMode 2 "Failed" 1 "Enabled" 0 "Disabled" ; - - -BO_ 717 ASCM_2CD: 5 K124_ASCM - -BO_ 869 ASCM_365: 4 K124_ASCM - -BO_ 1034 ASCM_40A: 7 K124_ASCM - -BO_ 1296 ASCM_510: 4 K124_ASCM - -BO_ 1930 ASCM_78A: 7 K124_ASCM - -BO_ 190 ECMAcceleratorPos: 6 K20_ECM - SG_ BrakePedalPos : 15|8@0+ (1,0) [0|0] "sticky" NEO - SG_ GasPedalAndAcc : 23|8@0+ (1,0) [0|0] "" NEO - -BO_ 201 ECMEngineStatus: 8 K20_ECM - SG_ EngineTPS : 39|8@0+ (0.392156863,0) [0|100.000000065] "%" NEO - SG_ EngineRPM : 15|16@0+ (0.25,0) [0|0] "RPM" NEO - -BO_ 209 EBCMBrakePedalTorque: 7 K17_EBCM - SG_ BrakePedalTorque : 3|12@0+ (1,0) [0|0] "" NEO - -BO_ 241 EBCMBrakePedalPosition: 6 K17_EBCM - SG_ BrakePedalPosition : 15|8@0+ (1,0) [0|255] "" NEO - -BO_ 298 BCMDoorBeltStatus: 8 K9_BCM - SG_ RearLeftDoor : 8|1@0+ (1,0) [0|0] "" NEO - SG_ FrontLeftDoor : 9|1@0+ (1,0) [0|0] "" NEO - SG_ FrontRightDoor : 10|1@0+ (1,0) [0|0] "" NEO - SG_ RearRightDoor : 23|1@0+ (1,0) [0|0] "" NEO - SG_ LeftSeatBelt : 12|1@0+ (1,0) [0|0] "" NEO - SG_ RightSeatBelt : 53|1@0+ (1,0) [0|0] "" NEO - -BO_ 309 ECMPRDNL: 8 K20_ECM - SG_ PRNDL : 2|3@0+ (1,0) [0|0] "" NEO - -BO_ 320 BCMTurnSignals: 3 K9_BCM - SG_ TurnSignals : 19|2@0+ (1,0) [0|0] "" NEO - -BO_ 336 ASCMLKASStatus: 1 NEO - SG_ Available : 7|1@0+ (1,0) [0|0] "" NEO - -BO_ 338 ASCMLKASteeringCmd: 6 NEO - SG_ LKASteeringCmdActive : 7|1@0+ (1,0) [0|0] "" NEO - SG_ LKASteeringCmd : 5|14@0- (1,0) [0|0] "" NEO - SG_ RollingCounter : 23|2@0+ (1,0) [0|0] "" NEO - SG_ SetMe1 : 21|1@0+ (1,0) [0|0] "" NEO - SG_ LKASVehicleSpeed : 20|13@0+ (0.22,0) [0|0] "kph" NEO - SG_ LKASMode : 36|2@0+ (1,0) [0|0] "" NEO - SG_ LKASteeringCmdChecksum : 33|10@0+ (1,0) [0|0] "" NEO - -BO_ 340 ASCMBLKASteeringCmd: 6 NEO - SG_ LKASteeringCmdActive : 7|1@0+ (1,0) [0|0] "" NEO - SG_ LKASteeringCmd : 5|14@0- (1,0) [0|0] "" NEO - SG_ RollingCounter : 23|2@0+ (1,0) [0|0] "" NEO - SG_ SetMe1 : 21|1@0+ (1,0) [0|0] "" NEO - SG_ LKASVehicleSpeed : 20|13@0+ (0.22,0) [0|0] "kph" NEO - SG_ LKASMode : 36|2@0+ (1,0) [0|0] "" NEO - SG_ LKASteeringCmdChecksum : 33|10@0+ (1,0) [0|0] "" NEO - -BO_ 381 MSG_17D: 8 K20_ECM - SG_ MSG17D_AccPower : 35|12@0- (1,0) [0|0] "" NEO - -BO_ 356 PSCMStatus: 8 K43_PSCM - SG_ LKATorqueDeliveredStatus : 7|3@0+ (1,0) [0|7] "" NEO - SG_ LKADriverAppldTrq : 2|11@0- (0.01,0) [-10.24|10.23] "Nm" NEO - SG_ LKATBDTorque : 21|14@0- (-0.005,0) [-10.24|10.23] "Nm" NEO - SG_ RollingCounter : 39|2@0+ (1,0) [0|0] "" NEO - SG_ LKATotalTorqueDelivered : 37|14@0- (0.01,0) [-10.24|10.23] "Nm" NEO - -BO_ 417 AcceleratorPedal: 7 XXX - SG_ AcceleratorPedal : 55|8@0+ (1,0) [0|0] "" NEO - -BO_ 451 GasAndAcc: 8 XXX - SG_ GasPedalAndAcc2 : 55|8@0+ (1,0) [0|0] "" NEO - -BO_ 452 AcceleratorPedal2: 8 XXX - SG_ AcceleratorPedal2 : 47|8@0+ (1,0) [0|0] "" NEO - -BO_ 481 ASCMSteeringButton: 7 K124_ASCM - SG_ DistanceButton : 22|1@0+ (1,0) [0|0] "" NEO - SG_ LKAButton : 23|1@0+ (1,0) [0|0] "" NEO - SG_ ACCButtons : 46|3@0+ (1,0) [0|0] "" NEO - -BO_ 485 PSCMSteeringAngle: 8 K43_PSCM - SG_ SteeringWheelAngle : 15|16@0- (0.0625,0) [-540|540] "deg" NEO - SG_ SteeringWheelRate : 27|12@0- (0.5,0) [-100|100] "deg/s" NEO - -BO_ 489 EBCMVehicleDynamic: 8 K17_EBCM - SG_ YawRate : 51|12@0- (0.0625,0) [-2047|2047] "grad/s" NEO - SG_ LateralAcceleration : 3|12@0- (0.0161,0) [-2047|2047] "m/s2" NEO - SG_ BrakePedalPressed : 6|1@0+ (1,0) [0|0] "" NEO - -BO_ 711 BECMBatteryVoltageCurrent: 6 K17_EBCM - SG_ HVBatteryVoltage : 31|12@0+ (0.125,0) [0|511.875] "V" NEO - SG_ HVBatteryCurrent : 12|13@0- (0.15,0) [-614.4|614.25] "A" NEO - -BO_ 715 ASCMGasRegenCmd: 8 K124_ASCM - SG_ GasRegenAlwaysOne : 9|1@0+ (1,1) [1|1] "" NEO - SG_ GasRegenAlwaysThree : 15|2@0+ (1,1) [1|1] "" NEO - SG_ GasRegenChecksum : 47|24@0+ (1,0) [0|0] "" NEO - SG_ GasRegenCmdActiveInv : 32|1@0+ (1,0) [0|0] "" NEO - SG_ GasRegenFullStopActive : 13|1@0+ (1,0) [0|0] "" NEO - SG_ GasRegenCmdActive : 0|1@0+ (1,0) [0|0] "" NEO - SG_ RollingCounter : 7|2@0+ (1,0) [0|0] "" NEO - SG_ RollingCounter2 : 36|4@0+ (1,0) [0|0] "" NEO - SG_ GasRegenAlwaysOne2 : 23|1@0+ (1,0) [0|1] "" NEO - SG_ GasRegenCmd : 22|15@0+ (1,0) [0|0] "" NEO - -BO_ 810 TCICOnStarGPSPosition: 8 K73_TCIC - SG_ GPSLongitude : 39|32@0+ (1,0) [0|0] "milliarcsecond" NEO - SG_ GPSLatitude : 7|32@0+ (1,0) [0|0] "milliarcsecond" NEO - -BO_ 840 EBCMWheelSpdFront: 4 K17_EBCM - SG_ FLWheelSpd : 7|16@0+ (0.0311,0) [0|255] "km/h" NEO - SG_ FRWheelSpd : 23|16@0+ (0.0311,0) [0|255] "km/h" NEO - -BO_ 842 EBCMWheelSpdRear: 4 K17_EBCM - SG_ RLWheelSpd : 7|16@0+ (0.0311,0) [0|255] "km/h" NEO - SG_ RRWheelSpd : 23|16@0+ (0.0311,0) [0|255] "km/h" NEO - -BO_ 880 ASCMActiveCruiseControlStatus: 6 K124_ASCM - SG_ ACCLeadCar : 44|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ ACCAlwaysOne2 : 32|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ ACCAlwaysOne : 0|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ ACCSpeedSetpoint : 19|12@0+ (1,0) [0|0] "km/h" NEO - SG_ ACCGapLevel : 21|2@0+ (1,0) [0|0] "" NEO - SG_ ACCResumeButton : 1|1@0+ (1,0) [0|0] "" NEO - SG_ ACCCmdActive : 23|1@0+ (1,0) [0|0] "" NEO - -BO_ 1001 ECMVehicleSpeed: 8 K20_ECM - SG_ VehicleSpeed : 7|16@0+ (0.01,0) [0|0] "mph" NEO - -BO_ 1033 ASCMKeepAlive: 7 NEO - SG_ ASCMKeepAliveAllZero : 7|56@0+ (1,0) [0|0] "" NEO - -BO_ 1217 ECMEngineCoolantTemp: 8 K20_ECM - SG_ EngineCoolantTemp : 23|8@0+ (1,-40) [0|0] "°C" NEO - -BO_ 1249 VIN_Part2: 8 K20_ECM - SG_ VINPart2 : 7|64@0+ (1,0) [0|0] "" NEO - -BO_ 1300 VIN_Part1: 8 K20_ECM - SG_ VINPart1 : 7|64@0+ (1,0) [0|0] "" NEO - -BO_ 1912 PSCM_778: 8 K43_PSCM - -BO_TX_BU_ 338 : K124_ASCM,NEO; -BO_TX_BU_ 880 : NEO,K124_ASCM; -BO_TX_BU_ 1033 : K124_ASCM,NEO; -BO_TX_BU_ 715 : NEO,K124_ASCM; - - -CM_ BU_ K16_BECM "Battery Energy Control Module"; -CM_ BU_ K73_TCIC "Telematics Communication Control Module"; -CM_ BU_ K9_BCM "Body Control Module"; -CM_ BU_ K43_PSCM "Power Steering Control Module"; -CM_ BU_ K17_EBCM "Electronic Brake Control Module"; -CM_ BU_ K20_ECM "Engine Control Module"; -CM_ BU_ K114B_HPCM "Hybrid Powertrain Control Module"; -CM_ BU_ NEO "Comma NEO"; -CM_ BU_ K124_ASCM "Active Safety Control Module"; -CM_ SG_ 381 MSG17D_AccPower "Need to investigate"; -CM_ SG_ 190 GasPedalAndAcc "ACC baseline is 62"; -CM_ SG_ 451 GasPedalAndAcc2 "ACC baseline is 62"; -CM_ SG_ 715 RollingCounter2 "Values cycle between 0, 7, 10, 13"; -BA_DEF_ "UseGMParameterIDs" INT 0 0; -BA_DEF_ "ProtocolType" STRING ; -BA_DEF_ "BusType" STRING ; -BA_DEF_DEF_ "UseGMParameterIDs" 1; -BA_DEF_DEF_ "ProtocolType" "GMLAN"; -BA_DEF_DEF_ "BusType" ""; -BA_ "BusType" "CAN"; -BA_ "ProtocolType" "GMLAN"; -BA_ "UseGMParameterIDs" 0; -VAL_ 481 DistanceButton 1 "Active" 0 "Inactive" ; -VAL_ 481 LKAButton 1 "Active" 0 "Inactive" ; -VAL_ 481 ACCButtons 6 "Cancel" 5 "Main" 3 "Set" 2 "Resume" 1 "None" ; -VAL_ 309 PRNDL 3 "Reverse" 2 "Drive" 1 "Neutral" 0 "Park" ; -VAL_ 338 LKASteeringCmdActive 1 "Active" 0 "Inactive" ; -VAL_ 338 LKASMode 2 "supercruise" 1 "lkas" 0 "Inactive" ; -VAL_ 880 ACCLeadCar 1 "Present" 0 "Not Present" ; -VAL_ 880 ACCGapLevel 3 "Far" 2 "Med" 1 "Near" 0 "Inactive" ; -VAL_ 880 ACCResumeButton 1 "Pressed" 0 "Depressed" ; -VAL_ 880 ACCCmdActive 1 "Active" 0 "Inactive" ; -VAL_ 356 LKATorqueDeliveredStatus 7 "Override Fault" 6 "LKAS Fault but Responsive" 5 "TBD but Responsive" 4 "TBD but Responsive" 3 "Fault" 1 "Active" 0 "Inactive" ; -VAL_ 489 BrakePedalPressed 1 "Pressed" 0 "Depressed" ; -VAL_ 715 GasRegenCmdActiveInv 1 "Inactive" 0 "Active" ; -VAL_ 715 GasRegenCmdActive 1 "Active" 0 "Inactive" ; - diff --git a/opendbc/can/SConscript b/opendbc/can/SConscript new file mode 100644 index 00000000000000..4e67fc7974000b --- /dev/null +++ b/opendbc/can/SConscript @@ -0,0 +1,22 @@ +Import('env', 'envCython', 'cereal') + +import os +from opendbc.can.process_dbc import process + +dbcs = [] +for x in sorted(os.listdir('../')): + if x.endswith(".dbc"): + def compile_dbc(target, source, env): + process(source[0].path, target[0].path) + in_fn = [os.path.join('../', x), 'dbc_template.cc'] + out_fn = os.path.join('dbc_out', x.replace(".dbc", ".cc")) + dbc = env.Command(out_fn, in_fn, compile_dbc) + dbcs.append(dbc) + +libdbc = env.SharedLibrary('libdbc', ["dbc.cc", "parser.cc", "packer.cc", "common.cc"]+dbcs, LIBS=["capnp", "kj"]) + +# Build packer and parser +lenv = envCython.Clone() +lenv["LINKFLAGS"] += [libdbc[0].get_labspath()] +lenv.Program('parser_pyx.so', 'parser_pyx.pyx') +lenv.Program('packer_pyx.so', 'packer_pyx.pyx') diff --git a/panda/examples/__init__.py b/opendbc/can/__init__.py similarity index 100% rename from panda/examples/__init__.py rename to opendbc/can/__init__.py diff --git a/opendbc/can/can_define.py b/opendbc/can/can_define.py new file mode 100644 index 00000000000000..ad79432a7ae436 --- /dev/null +++ b/opendbc/can/can_define.py @@ -0,0 +1,2 @@ +from opendbc.can.parser_pyx import CANDefine # pylint: disable=no-name-in-module, import-error +assert CANDefine diff --git a/opendbc/can/common.cc b/opendbc/can/common.cc new file mode 100644 index 00000000000000..d0ace8c8f0331f --- /dev/null +++ b/opendbc/can/common.cc @@ -0,0 +1,214 @@ +#include "common.h" + +unsigned int honda_checksum(unsigned int address, uint64_t d, int l) { + d >>= ((8-l)*8); // remove padding + d >>= 4; // remove checksum + + int s = 0; + while (address) { s += (address & 0xF); address >>= 4; } + while (d) { s += (d & 0xF); d >>= 4; } + s = 8-s; + s &= 0xF; + + return s; +} + +unsigned int toyota_checksum(unsigned int address, uint64_t d, int l) { + d >>= ((8-l)*8); // remove padding + d >>= 8; // remove checksum + + unsigned int s = l; + while (address) { s += address & 0xFF; address >>= 8; } + while (d) { s += d & 0xFF; d >>= 8; } + + return s & 0xFF; +} + +unsigned int subaru_checksum(unsigned int address, uint64_t d, int l) { + d >>= ((8-l)*8); // remove padding + + unsigned int s = 0; + while (address) { s += address & 0xFF; address >>= 8; } + l -= 1; // checksum is first byte + while (l) { s += d & 0xFF; d >>= 8; l -= 1; } + + return s & 0xFF; +} + +unsigned int chrysler_checksum(unsigned int address, uint64_t d, int l) { + /* This function does not want the checksum byte in the input data. + jeep chrysler canbus checksum from http://illmatics.com/Remote%20Car%20Hacking.pdf */ + uint8_t checksum = 0xFF; + for (int j = 0; j < (l - 1); j++) { + uint8_t shift = 0x80; + uint8_t curr = (d >> 8*j) & 0xFF; + for (int i=0; i<8; i++) { + uint8_t bit_sum = curr & shift; + uint8_t temp_chk = checksum & 0x80U; + if (bit_sum != 0U) { + bit_sum = 0x1C; + if (temp_chk != 0U) { + bit_sum = 1; + } + checksum = checksum << 1; + temp_chk = checksum | 1U; + bit_sum ^= temp_chk; + } else { + if (temp_chk != 0U) { + bit_sum = 0x1D; + } + checksum = checksum << 1; + bit_sum ^= checksum; + } + checksum = bit_sum; + shift = shift >> 1; + } + } + return ~checksum & 0xFF; +} + +// Static lookup table for fast computation of CRC8 poly 0x2F, aka 8H2F/AUTOSAR +uint8_t crc8_lut_8h2f[256]; + +void gen_crc_lookup_table(uint8_t poly, uint8_t crc_lut[]) { + uint8_t crc; + int i, j; + + for (i = 0; i < 256; i++) { + crc = i; + for (j = 0; j < 8; j++) { + if ((crc & 0x80) != 0) + crc = (uint8_t)((crc << 1) ^ poly); + else + crc <<= 1; + } + crc_lut[i] = crc; + } +} + +void init_crc_lookup_tables() { + // At init time, set up static lookup tables for fast CRC computation. + + gen_crc_lookup_table(0x2F, crc8_lut_8h2f); // CRC-8 8H2F/AUTOSAR for Volkswagen +} + +unsigned int volkswagen_crc(unsigned int address, uint64_t d, int l) { + // Volkswagen uses standard CRC8 8H2F/AUTOSAR, but they compute it with + // a magic variable padding byte tacked onto the end of the payload. + // https://www.autosar.org/fileadmin/user_upload/standards/classic/4-3/AUTOSAR_SWS_CRCLibrary.pdf + + uint8_t crc = 0xFF; // Standard init value for CRC8 8H2F/AUTOSAR + + // CRC the payload first, skipping over the first byte where the CRC lives. + for (int i = 1; i < l; i++) { + crc ^= (d >> (i*8)) & 0xFF; + crc = crc8_lut_8h2f[crc]; + } + + // Look up and apply the magic final CRC padding byte, which permutes by CAN + // address, and additionally (for SOME addresses) by the message counter. + uint8_t counter = ((d >> 8) & 0xFF) & 0x0F; + switch(address) { + case 0x86: // LWI_01 Steering Angle + crc ^= (uint8_t[]){0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86}[counter]; + break; + case 0x9F: // EPS_01 Electric Power Steering + crc ^= (uint8_t[]){0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5}[counter]; + break; + case 0xAD: // Getriebe_11 Automatic Gearbox + crc ^= (uint8_t[]){0x3F,0x69,0x39,0xDC,0x94,0xF9,0x14,0x64,0xD8,0x6A,0x34,0xCE,0xA2,0x55,0xB5,0x2C}[counter]; + break; + case 0xFD: // ESP_21 Electronic Stability Program + crc ^= (uint8_t[]){0xB4,0xEF,0xF8,0x49,0x1E,0xE5,0xC2,0xC0,0x97,0x19,0x3C,0xC9,0xF1,0x98,0xD6,0x61}[counter]; + break; + case 0x106: // ESP_05 Electronic Stability Program + crc ^= (uint8_t[]){0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07}[counter]; + break; + case 0x117: // ACC_10 Automatic Cruise Control + crc ^= (uint8_t[]){0xAC,0xAC,0xAC,0xAC,0xAC,0xAC,0xAC,0xAC,0xAC,0xAC,0xAC,0xAC,0xAC,0xAC,0xAC,0xAC}[counter]; + break; + case 0x120: // TSK_06 Drivetrain Coordinator + crc ^= (uint8_t[]){0xC4,0xE2,0x4F,0xE4,0xF8,0x2F,0x56,0x81,0x9F,0xE5,0x83,0x44,0x05,0x3F,0x97,0xDF}[counter]; + break; + case 0x121: // Motor_20 Driver Throttle Inputs + crc ^= (uint8_t[]){0xE9,0x65,0xAE,0x6B,0x7B,0x35,0xE5,0x5F,0x4E,0xC7,0x86,0xA2,0xBB,0xDD,0xEB,0xB4}[counter]; + break; + case 0x122: // ACC_06 Automatic Cruise Control + crc ^= (uint8_t[]){0x37,0x7D,0xF3,0xA9,0x18,0x46,0x6D,0x4D,0x3D,0x71,0x92,0x9C,0xE5,0x32,0x10,0xB9}[counter]; + break; + case 0x126: // HCA_01 Heading Control Assist + crc ^= (uint8_t[]){0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA}[counter]; + break; + case 0x12B: // GRA_ACC_01 Steering wheel controls for ACC + crc ^= (uint8_t[]){0x6A,0x38,0xB4,0x27,0x22,0xEF,0xE1,0xBB,0xF8,0x80,0x84,0x49,0xC7,0x9E,0x1E,0x2B}[counter]; + break; + case 0x187: // EV_Gearshift "Gear" selection data for EVs with no gearbox + crc ^= (uint8_t[]){0x7F,0xED,0x17,0xC2,0x7C,0xEB,0x44,0x21,0x01,0xFA,0xDB,0x15,0x4A,0x6B,0x23,0x05}[counter]; + break; + case 0x30C: // ACC_02 Automatic Cruise Control + crc ^= (uint8_t[]){0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F}[counter]; + break; + case 0x30F: // SWA_01 Lane Change Assist (SpurWechselAssistent) + crc ^= (uint8_t[]){0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C}[counter]; + break; + case 0x3C0: // Klemmen_Status_01 ignition and starting status + crc ^= (uint8_t[]){0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3}[counter]; + break; + case 0x65D: // ESP_20 Electronic Stability Program + crc ^= (uint8_t[]){0xAC,0xB3,0xAB,0xEB,0x7A,0xE1,0x3B,0xF7,0x73,0xBA,0x7C,0x9E,0x06,0x5F,0x02,0xD9}[counter]; + break; + default: // As-yet undefined CAN message, CRC check expected to fail + printf("Attempt to CRC check undefined Volkswagen message 0x%02X\n", address); + crc ^= (uint8_t[]){0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}[counter]; + break; + } + crc = crc8_lut_8h2f[crc]; + + return crc ^ 0xFF; // Return after standard final XOR for CRC8 8H2F/AUTOSAR +} + + +unsigned int pedal_checksum(uint64_t d, int l) { + uint8_t crc = 0xFF; + uint8_t poly = 0xD5; // standard crc8 + + d >>= ((8-l)*8); // remove padding + d >>= 8; // remove checksum + + int i, j; + for (i = 0; i < l - 1; i++) { + crc ^= (d >> (i*8)) & 0xFF; + for (j = 0; j < 8; j++) { + if ((crc & 0x80) != 0) { + crc = (uint8_t)((crc << 1) ^ poly); + } + else { + crc <<= 1; + } + } + } + return crc; +} + + +uint64_t read_u64_be(const uint8_t* v) { + return (((uint64_t)v[0] << 56) + | ((uint64_t)v[1] << 48) + | ((uint64_t)v[2] << 40) + | ((uint64_t)v[3] << 32) + | ((uint64_t)v[4] << 24) + | ((uint64_t)v[5] << 16) + | ((uint64_t)v[6] << 8) + | (uint64_t)v[7]); +} + +uint64_t read_u64_le(const uint8_t* v) { + return ((uint64_t)v[0] + | ((uint64_t)v[1] << 8) + | ((uint64_t)v[2] << 16) + | ((uint64_t)v[3] << 24) + | ((uint64_t)v[4] << 32) + | ((uint64_t)v[5] << 40) + | ((uint64_t)v[6] << 48) + | ((uint64_t)v[7] << 56)); +} diff --git a/opendbc/can/common.h b/opendbc/can/common.h new file mode 100644 index 00000000000000..dd91a6ce729a6f --- /dev/null +++ b/opendbc/can/common.h @@ -0,0 +1,72 @@ +#pragma once + +#include +#include +#include + +#include "common_dbc.h" +#include +#include "cereal/gen/cpp/log.capnp.h" + +#define MAX_BAD_COUNTER 5 + +// Helper functions +unsigned int honda_checksum(unsigned int address, uint64_t d, int l); +unsigned int toyota_checksum(unsigned int address, uint64_t d, int l); +unsigned int subaru_checksum(unsigned int address, uint64_t d, int l); +unsigned int chrysler_checksum(unsigned int address, uint64_t d, int l); +void init_crc_lookup_tables(); +unsigned int volkswagen_crc(unsigned int address, uint64_t d, int l); +unsigned int pedal_checksum(uint64_t d, int l); +uint64_t read_u64_be(const uint8_t* v); +uint64_t read_u64_le(const uint8_t* v); + +class MessageState { +public: + uint32_t address; + unsigned int size; + + std::vector parse_sigs; + std::vector vals; + + uint16_t ts; + uint64_t seen; + uint64_t check_threshold; + + uint8_t counter; + uint8_t counter_fail; + + bool parse(uint64_t sec, uint16_t ts_, uint8_t * dat); + bool update_counter_generic(int64_t v, int cnt_size); +}; + +class CANParser { +private: + const int bus; + + const DBC *dbc = NULL; + std::unordered_map message_states; + +public: + bool can_valid = false; + uint64_t last_sec = 0; + + CANParser(int abus, const std::string& dbc_name, + const std::vector &options, + const std::vector &sigoptions); + void UpdateCans(uint64_t sec, const capnp::List::Reader& cans); + void UpdateValid(uint64_t sec); + void update_string(std::string data, bool sendcan); + std::vector query_latest(); +}; + +class CANPacker { +private: + const DBC *dbc = NULL; + std::map, Signal> signal_lookup; + std::map message_lookup; + +public: + CANPacker(const std::string& dbc_name); + uint64_t pack(uint32_t address, const std::vector &signals, int counter); +}; diff --git a/opendbc/can/common.pxd b/opendbc/can/common.pxd new file mode 100644 index 00000000000000..5519140fa80d99 --- /dev/null +++ b/opendbc/can/common.pxd @@ -0,0 +1,84 @@ +# distutils: language = c++ +#cython: language_level=3 + +from libc.stdint cimport uint32_t, uint64_t, uint16_t +from libcpp.vector cimport vector +from libcpp.map cimport map +from libcpp.string cimport string +from libcpp.unordered_set cimport unordered_set +from libcpp cimport bool + + +cdef extern from "common_dbc.h": + ctypedef enum SignalType: + DEFAULT, + HONDA_CHECKSUM, + HONDA_COUNTER, + TOYOTA_CHECKSUM, + PEDAL_CHECKSUM, + PEDAL_COUNTER, + VOLKSWAGEN_CHECKSUM, + VOLKSWAGEN_COUNTER, + SUBARU_CHECKSUM, + CHRYSLER_CHECKSUM + + cdef struct Signal: + const char* name + int b1, b2, bo + bool is_signed + double factor, offset + SignalType type + + cdef struct Msg: + const char* name + uint32_t address + unsigned int size + size_t num_sigs + const Signal *sigs + + cdef struct Val: + const char* name + uint32_t address + const char* def_val + const Signal *sigs + + cdef struct DBC: + const char* name + size_t num_msgs + const Msg *msgs + const Val *vals + size_t num_vals + + cdef struct SignalParseOptions: + uint32_t address + const char* name + double default_value + + + cdef struct MessageParseOptions: + uint32_t address + int check_frequency + + cdef struct SignalValue: + uint32_t address + uint16_t ts + const char* name + double value + + cdef struct SignalPackValue: + const char * name + double value + + +cdef extern from "common.h": + cdef const DBC* dbc_lookup(const string); + + cdef cppclass CANParser: + bool can_valid + CANParser(int, string, vector[MessageParseOptions], vector[SignalParseOptions]) + void update_string(string, bool) + vector[SignalValue] query_latest() + + cdef cppclass CANPacker: + CANPacker(string) + uint64_t pack(uint32_t, vector[SignalPackValue], int counter) diff --git a/opendbc/can/common_dbc.h b/opendbc/can/common_dbc.h new file mode 100644 index 00000000000000..e5c12ba6c26474 --- /dev/null +++ b/opendbc/can/common_dbc.h @@ -0,0 +1,84 @@ +#pragma once + +#include +#include +#include + +#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0])) + +struct SignalPackValue { + const char* name; + double value; +}; + +struct SignalParseOptions { + uint32_t address; + const char* name; + double default_value; +}; + +struct MessageParseOptions { + uint32_t address; + int check_frequency; +}; + +struct SignalValue { + uint32_t address; + uint16_t ts; + const char* name; + double value; +}; + +enum SignalType { + DEFAULT, + HONDA_CHECKSUM, + HONDA_COUNTER, + TOYOTA_CHECKSUM, + PEDAL_CHECKSUM, + PEDAL_COUNTER, + VOLKSWAGEN_CHECKSUM, + VOLKSWAGEN_COUNTER, + SUBARU_CHECKSUM, + CHRYSLER_CHECKSUM, +}; + +struct Signal { + const char* name; + int b1, b2, bo; + bool is_signed; + double factor, offset; + bool is_little_endian; + SignalType type; +}; + +struct Msg { + const char* name; + uint32_t address; + unsigned int size; + size_t num_sigs; + const Signal *sigs; +}; + +struct Val { + const char* name; + uint32_t address; + const char* def_val; + const Signal *sigs; +}; + +struct DBC { + const char* name; + size_t num_msgs; + const Msg *msgs; + const Val *vals; + size_t num_vals; +}; + +const DBC* dbc_lookup(const std::string& dbc_name); + +void dbc_register(const DBC* dbc); + +#define dbc_init(dbc) \ +static void __attribute__((constructor)) do_dbc_init_ ## dbc(void) { \ + dbc_register(&dbc); \ +} diff --git a/selfdrive/can/dbc.cc b/opendbc/can/dbc.cc similarity index 92% rename from selfdrive/can/dbc.cc rename to opendbc/can/dbc.cc index 95d5e4d791394a..6587de7fe0163a 100644 --- a/selfdrive/can/dbc.cc +++ b/opendbc/can/dbc.cc @@ -1,7 +1,6 @@ -#include #include -#include "common.h" +#include "common_dbc.h" namespace { diff --git a/common/dbc.py b/opendbc/can/dbc.py similarity index 80% rename from common/dbc.py rename to opendbc/can/dbc.py index 693b2985a4cf62..32d8fffa4c1d2c 100755 --- a/common/dbc.py +++ b/opendbc/can/dbc.py @@ -12,15 +12,16 @@ def int_or_float(s): else: return float(s) + DBCSignal = namedtuple( "DBCSignal", ["name", "start_bit", "size", "is_little_endian", "is_signed", "factor", "offset", "tmin", "tmax", "units"]) -class dbc(object): +class dbc(): def __init__(self, fn): self.name, _ = os.path.splitext(os.path.basename(fn)) - with open(fn) as f: + with open(fn, encoding="ascii") as f: self.txt = f.readlines() self._warned_addresses = set() @@ -41,7 +42,7 @@ def __init__(self, fn): self.def_vals = defaultdict(list) # lookup to bit reverse each byte - self.bits_index = [(i & ~0b111) + ((-i-1) & 0b111) for i in xrange(64)] + self.bits_index = [(i & ~0b111) + ((-i - 1) & 0b111) for i in range(64)] for l in self.txt: l = l.strip() @@ -55,7 +56,7 @@ def __init__(self, fn): name = dat.group(2) size = int(dat.group(3)) - ids = int(dat.group(1), 0) # could be hex + ids = int(dat.group(1), 0) # could be hex if ids in self.msgs: sys.exit("Duplicate address detected %d %s" % (ids, self.name)) @@ -73,15 +74,15 @@ def __init__(self, fn): print("bad SG {0}".format(l)) sgname = dat.group(1) - start_bit = int(dat.group(go+2)) - signal_size = int(dat.group(go+3)) - is_little_endian = int(dat.group(go+4))==1 - is_signed = dat.group(go+5)=='-' - factor = int_or_float(dat.group(go+6)) - offset = int_or_float(dat.group(go+7)) - tmin = int_or_float(dat.group(go+8)) - tmax = int_or_float(dat.group(go+9)) - units = dat.group(go+10) + start_bit = int(dat.group(go + 2)) + signal_size = int(dat.group(go + 3)) + is_little_endian = int(dat.group(go + 4)) == 1 + is_signed = dat.group(go + 5) == '-' + factor = int_or_float(dat.group(go + 6)) + offset = int_or_float(dat.group(go + 7)) + tmin = int_or_float(dat.group(go + 8)) + tmax = int_or_float(dat.group(go + 9)) + units = dat.group(go + 10) self.msgs[ids][1].append( DBCSignal(sgname, start_bit, signal_size, is_little_endian, @@ -94,21 +95,16 @@ def __init__(self, fn): if dat is None: print("bad VAL {0}".format(l)) - ids = int(dat.group(1), 0) # could be hex + ids = int(dat.group(1), 0) # could be hex sgname = dat.group(2) defvals = dat.group(3) - defvals = defvals.replace("?",r"\?") #escape sequence in C++ + defvals = defvals.replace("?", r"\?") # escape sequence in C++ defvals = defvals.split('"')[:-1] - defs = defvals[1::2] - #cleanup, convert to UPPER_CASE_WITH_UNDERSCORES - for i,d in enumerate(defs): - d = defs[i].strip().upper() - defs[i] = d.replace(" ","_") - - defvals[1::2] = defs - defvals = '"'+"".join(str(i) for i in defvals)+'"' + # convert strings to UPPER_CASE_WITH_UNDERSCORES + defvals[1::2] = [d.strip().upper().replace(" ", "_") for d in defvals[1::2]] + defvals = '"' + "".join(str(i) for i in defvals) + '"' self.def_vals[ids].append((sgname, defvals)) @@ -152,22 +148,20 @@ def encode(self, msg_id, dd): ival = dd.get(s.name) if ival is not None: - b2 = s.size - if s.is_little_endian: - b1 = s.start_bit - else: - b1 = (s.start_bit // 8) * 8 + (-s.start_bit - 1) % 8 - bo = 64 - (b1 + s.size) - ival = (ival / s.factor) - s.offset ival = int(round(ival)) if s.is_signed and ival < 0: - ival = (1 << b2) + ival + ival = (1 << s.size) + ival - shift = b1 if s.is_little_endian else bo - mask = ((1 << b2) - 1) << shift - dat = (ival & ((1 << b2) - 1)) << shift + if s.is_little_endian: + shift = s.start_bit + else: + b1 = (s.start_bit // 8) * 8 + (-s.start_bit - 1) % 8 + shift = 64 - (b1 + s.size) + + mask = ((1 << s.size) - 1) << shift + dat = (ival & ((1 << s.size) - 1)) << shift if s.is_little_endian: mask = self.reverse_bytes(mask) @@ -200,12 +194,12 @@ def decode(self, x, arr=None, debug=False): if arr is None: out = {} else: - out = [None]*len(arr) + out = [None] * len(arr) msg = self.msgs.get(x[0]) if msg is None: if x[0] not in self._warned_addresses: - #print("WARNING: Unknown message address {}".format(x[0])) + # print("WARNING: Unknown message address {}".format(x[0])) self._warned_addresses.add(x[0]) return None, None @@ -213,7 +207,7 @@ def decode(self, x, arr=None, debug=False): if debug: print(name) - st = x[2].ljust(8, '\x00') + st = x[2].ljust(8, b'\x00') le, be = None, None for s in msg[1]: @@ -227,30 +221,24 @@ def decode(self, x, arr=None, debug=False): factor = s[5] offset = s[6] - b2 = signal_size - if little_endian: - b1 = start_bit - else: - b1 = (start_bit // 8) * 8 + (-start_bit - 1) % 8 - bo = 64 - (b1 + signal_size) - if little_endian: if le is None: le = struct.unpack("Q", st)[0] - shift_amount = bo tmp = be + b1 = (start_bit // 8) * 8 + (-start_bit - 1) % 8 + shift_amount = 64 - (b1 + signal_size) if shift_amount < 0: continue - tmp = (tmp >> shift_amount) & ((1 << b2) - 1) - if signed and (tmp >> (b2 - 1)): - tmp -= (1 << b2) + tmp = (tmp >> shift_amount) & ((1 << signal_size) - 1) + if signed and (tmp >> (signal_size - 1)): + tmp -= (1 << signal_size) tmp = tmp * factor + offset @@ -270,7 +258,6 @@ def get_signals(self, msg): if __name__ == "__main__": from opendbc import DBC_PATH - import numpy as np dbc_test = dbc(os.path.join(DBC_PATH, 'toyota_prius_2017_pt_generated.dbc')) msg = ('STEER_ANGLE_SENSOR', {'STEER_ANGLE': -6.0, 'STEER_RATE': 4, 'STEER_FRACTION': -0.2}) @@ -280,7 +267,7 @@ def get_signals(self, msg): dbc_test = dbc(os.path.join(DBC_PATH, 'hyundai_santa_fe_2019_ccan.dbc')) decoded = dbc_test.decode((0x2b0, 0, "\xfa\xfe\x00\x07\x12")) - assert np.isclose(decoded[1]['SAS_Angle'], -26.2) + assert abs(decoded[1]['SAS_Angle'] - (-26.2)) < 0.001 msg = ('SAS11', {'SAS_Stat': 7.0, 'MsgCount': 0.0, 'SAS_Angle': -26.200000000000003, 'SAS_Speed': 0.0, 'CheckSum': 0.0}) encoded = dbc_test.encode(*msg) diff --git a/selfdrive/can/dbc_out/.gitignore b/opendbc/can/dbc_out/.gitignore similarity index 100% rename from selfdrive/can/dbc_out/.gitignore rename to opendbc/can/dbc_out/.gitignore diff --git a/selfdrive/can/dbc_out/.gitkeep b/opendbc/can/dbc_out/.gitkeep similarity index 100% rename from selfdrive/can/dbc_out/.gitkeep rename to opendbc/can/dbc_out/.gitkeep diff --git a/selfdrive/can/dbc_template.cc b/opendbc/can/dbc_template.cc similarity index 80% rename from selfdrive/can/dbc_template.cc rename to opendbc/can/dbc_template.cc index 776403b22f03ff..f6d4988713767c 100644 --- a/selfdrive/can/dbc_template.cc +++ b/opendbc/can/dbc_template.cc @@ -1,6 +1,4 @@ -#include - -#include "common.h" +#include "common_dbc.h" namespace { @@ -27,6 +25,14 @@ const Signal sigs_{{address}}[] = { .type = SignalType::HONDA_COUNTER, {% elif checksum_type == "toyota" and sig.name == "CHECKSUM" %} .type = SignalType::TOYOTA_CHECKSUM, + {% elif checksum_type == "volkswagen" and sig.name == "CHECKSUM" %} + .type = SignalType::VOLKSWAGEN_CHECKSUM, + {% elif checksum_type == "volkswagen" and sig.name == "COUNTER" %} + .type = SignalType::VOLKSWAGEN_COUNTER, + {% elif checksum_type == "subaru" and sig.name == "CHECKSUM" %} + .type = SignalType::SUBARU_CHECKSUM, + {% elif checksum_type == "chrysler" and sig.name == "CHECKSUM" %} + .type = SignalType::CHRYSLER_CHECKSUM, {% elif address in [512, 513] and sig.name == "CHECKSUM_PEDAL" %} .type = SignalType::PEDAL_CHECKSUM, {% elif address in [512, 513] and sig.name == "COUNTER_PEDAL" %} diff --git a/opendbc/can/packer.cc b/opendbc/can/packer.cc new file mode 100644 index 00000000000000..ba675a5b01b202 --- /dev/null +++ b/opendbc/can/packer.cc @@ -0,0 +1,114 @@ +#include +#include +#include +#include +#include + +#include "common.h" + +#define WARN printf + +// this is the same as read_u64_le, but uses uint64_t as in/out +uint64_t ReverseBytes(uint64_t x) { + return ((x & 0xff00000000000000ull) >> 56) | + ((x & 0x00ff000000000000ull) >> 40) | + ((x & 0x0000ff0000000000ull) >> 24) | + ((x & 0x000000ff00000000ull) >> 8) | + ((x & 0x00000000ff000000ull) << 8) | + ((x & 0x0000000000ff0000ull) << 24) | + ((x & 0x000000000000ff00ull) << 40) | + ((x & 0x00000000000000ffull) << 56); +} + +uint64_t set_value(uint64_t ret, Signal sig, int64_t ival){ + int shift = sig.is_little_endian? sig.b1 : sig.bo; + uint64_t mask = ((1ULL << sig.b2)-1) << shift; + uint64_t dat = (ival & ((1ULL << sig.b2)-1)) << shift; + if (sig.is_little_endian) { + dat = ReverseBytes(dat); + mask = ReverseBytes(mask); + } + ret &= ~mask; + ret |= dat; + return ret; +} + +CANPacker::CANPacker(const std::string& dbc_name) { + dbc = dbc_lookup(dbc_name); + assert(dbc); + + for (int i=0; inum_msgs; i++) { + const Msg* msg = &dbc->msgs[i]; + message_lookup[msg->address] = *msg; + for (int j=0; jnum_sigs; j++) { + const Signal* sig = &msg->sigs[j]; + signal_lookup[std::make_pair(msg->address, std::string(sig->name))] = *sig; + } + } + init_crc_lookup_tables(); +} + +uint64_t CANPacker::pack(uint32_t address, const std::vector &signals, int counter) { + uint64_t ret = 0; + for (const auto& sigval : signals) { + std::string name = std::string(sigval.name); + double value = sigval.value; + + auto sig_it = signal_lookup.find(std::make_pair(address, name)); + if (sig_it == signal_lookup.end()) { + WARN("undefined signal %s - %d\n", name.c_str(), address); + continue; + } + auto sig = sig_it->second; + + int64_t ival = (int64_t)(round((value - sig.offset) / sig.factor)); + if (ival < 0) { + ival = (1ULL << sig.b2) + ival; + } + + ret = set_value(ret, sig, ival); + } + + if (counter >= 0){ + auto sig_it = signal_lookup.find(std::make_pair(address, "COUNTER")); + if (sig_it == signal_lookup.end()) { + WARN("COUNTER not defined\n"); + return ret; + } + auto sig = sig_it->second; + + if ((sig.type != SignalType::HONDA_COUNTER) && (sig.type != SignalType::VOLKSWAGEN_COUNTER)) { + WARN("COUNTER signal type not valid\n"); + } + + ret = set_value(ret, sig, counter); + } + + auto sig_it_checksum = signal_lookup.find(std::make_pair(address, "CHECKSUM")); + if (sig_it_checksum != signal_lookup.end()) { + auto sig = sig_it_checksum->second; + if (sig.type == SignalType::HONDA_CHECKSUM) { + unsigned int chksm = honda_checksum(address, ret, message_lookup[address].size); + ret = set_value(ret, sig, chksm); + } else if (sig.type == SignalType::TOYOTA_CHECKSUM) { + unsigned int chksm = toyota_checksum(address, ret, message_lookup[address].size); + ret = set_value(ret, sig, chksm); + } else if (sig.type == SignalType::VOLKSWAGEN_CHECKSUM) { + // FIXME: Hackish fix for an endianness issue. The message is in reverse byte order + // until later in the pack process. Checksums can be run backwards, CRCs not so much. + // The correct fix is unclear but this works for the moment. + unsigned int chksm = volkswagen_crc(address, ReverseBytes(ret), message_lookup[address].size); + ret = set_value(ret, sig, chksm); + } else if (sig.type == SignalType::SUBARU_CHECKSUM) { + unsigned int chksm = subaru_checksum(address, ret, message_lookup[address].size); + ret = set_value(ret, sig, chksm); + } else if (sig.type == SignalType::CHRYSLER_CHECKSUM) { + unsigned int chksm = chrysler_checksum(address, ReverseBytes(ret), message_lookup[address].size); + ret = set_value(ret, sig, chksm); + } else { + //WARN("CHECKSUM signal type not valid\n"); + } + } + + return ret; +} diff --git a/opendbc/can/packer.py b/opendbc/can/packer.py new file mode 100644 index 00000000000000..fc22cce005fb88 --- /dev/null +++ b/opendbc/can/packer.py @@ -0,0 +1,3 @@ +# pylint: skip-file +from opendbc.can.packer_pyx import CANPacker +assert CANPacker diff --git a/opendbc/can/packer_pyx.pyx b/opendbc/can/packer_pyx.pyx new file mode 100644 index 00000000000000..22b4b565f2a4c7 --- /dev/null +++ b/opendbc/can/packer_pyx.pyx @@ -0,0 +1,69 @@ +# distutils: language = c++ +# cython: c_string_encoding=ascii, language_level=3 + +from libc.stdint cimport uint32_t, uint64_t +from libcpp.vector cimport vector +from libcpp.map cimport map +from libcpp.string cimport string +from libcpp cimport bool +from posix.dlfcn cimport dlopen, dlsym, RTLD_LAZY + +from .common cimport CANPacker as cpp_CANPacker +from .common cimport dbc_lookup, SignalPackValue, DBC + + +cdef class CANPacker: + cdef: + cpp_CANPacker *packer + const DBC *dbc + map[string, (int, int)] name_to_address_and_size + map[int, int] address_to_size + + def __init__(self, dbc_name): + self.dbc = dbc_lookup(dbc_name) + if not self.dbc: + raise RuntimeError(f"Can't lookup {dbc_name}") + + self.packer = new cpp_CANPacker(dbc_name) + num_msgs = self.dbc[0].num_msgs + for i in range(num_msgs): + msg = self.dbc[0].msgs[i] + self.name_to_address_and_size[string(msg.name)] = (msg.address, msg.size) + self.address_to_size[msg.address] = msg.size + + cdef uint64_t pack(self, addr, values, counter): + cdef vector[SignalPackValue] values_thing + cdef SignalPackValue spv + + names = [] + + for name, value in values.iteritems(): + n = name.encode('utf8') + names.append(n) # TODO: find better way to keep reference to temp string around + + spv.name = n + spv.value = value + values_thing.push_back(spv) + + return self.packer.pack(addr, values_thing, counter) + + cdef inline uint64_t ReverseBytes(self, uint64_t x): + return (((x & 0xff00000000000000ull) >> 56) | + ((x & 0x00ff000000000000ull) >> 40) | + ((x & 0x0000ff0000000000ull) >> 24) | + ((x & 0x000000ff00000000ull) >> 8) | + ((x & 0x00000000ff000000ull) << 8) | + ((x & 0x0000000000ff0000ull) << 24) | + ((x & 0x000000000000ff00ull) << 40) | + ((x & 0x00000000000000ffull) << 56)) + + cpdef make_can_msg(self, name_or_addr, bus, values, counter=-1): + cdef int addr, size + if type(name_or_addr) == int: + addr = name_or_addr + size = self.address_to_size[name_or_addr] + else: + addr, size = self.name_to_address_and_size[name_or_addr.encode('utf8')] + cdef uint64_t val = self.pack(addr, values, counter) + val = self.ReverseBytes(val) + return [addr, 0, (&val)[:size], bus] diff --git a/opendbc/can/parser.cc b/opendbc/can/parser.cc new file mode 100644 index 00000000000000..c6d85d9eed965a --- /dev/null +++ b/opendbc/can/parser.cc @@ -0,0 +1,248 @@ +#include +#include + +#include +#include +#include +#include +#include + +#include "common.h" + +#define DEBUG(...) +// #define DEBUG printf +#define INFO printf + + +bool MessageState::parse(uint64_t sec, uint16_t ts_, uint8_t * dat) { + uint64_t dat_le = read_u64_le(dat); + uint64_t dat_be = read_u64_be(dat); + + for (int i=0; i < parse_sigs.size(); i++) { + auto& sig = parse_sigs[i]; + int64_t tmp; + + if (sig.is_little_endian){ + tmp = (dat_le >> sig.b1) & ((1ULL << sig.b2)-1); + } else { + tmp = (dat_be >> sig.bo) & ((1ULL << sig.b2)-1); + } + + if (sig.is_signed) { + tmp -= (tmp >> (sig.b2-1)) ? (1ULL << sig.b2) : 0; //signed + } + + DEBUG("parse 0x%X %s -> %lld\n", address, sig.name, tmp); + + if (sig.type == SignalType::HONDA_CHECKSUM) { + if (honda_checksum(address, dat_be, size) != tmp) { + INFO("0x%X CHECKSUM FAIL\n", address); + return false; + } + } else if (sig.type == SignalType::HONDA_COUNTER) { + if (!update_counter_generic(tmp, sig.b2)) { + return false; + } + } else if (sig.type == SignalType::TOYOTA_CHECKSUM) { + if (toyota_checksum(address, dat_be, size) != tmp) { + INFO("0x%X CHECKSUM FAIL\n", address); + return false; + } + } else if (sig.type == SignalType::VOLKSWAGEN_CHECKSUM) { + if (volkswagen_crc(address, dat_le, size) != tmp) { + INFO("0x%X CRC FAIL\n", address); + return false; + } + } else if (sig.type == SignalType::VOLKSWAGEN_COUNTER) { + if (!update_counter_generic(tmp, sig.b2)) { + return false; + } + } else if (sig.type == SignalType::SUBARU_CHECKSUM) { + if (subaru_checksum(address, dat_be, size) != tmp) { + INFO("0x%X CHECKSUM FAIL\n", address); + return false; + } + } else if (sig.type == SignalType::CHRYSLER_CHECKSUM) { + if (chrysler_checksum(address, dat_le, size) != tmp) { + INFO("0x%X CHECKSUM FAIL\n", address); + return false; + } + } else if (sig.type == SignalType::PEDAL_CHECKSUM) { + if (pedal_checksum(dat_be, size) != tmp) { + INFO("0x%X PEDAL CHECKSUM FAIL\n", address); + return false; + } + } else if (sig.type == SignalType::PEDAL_COUNTER) { + if (!update_counter_generic(tmp, sig.b2)) { + return false; + } + } + + vals[i] = tmp * sig.factor + sig.offset; + } + ts = ts_; + seen = sec; + + return true; +} + + +bool MessageState::update_counter_generic(int64_t v, int cnt_size) { + uint8_t old_counter = counter; + counter = v; + if (((old_counter+1) & ((1 << cnt_size) -1)) != v) { + counter_fail += 1; + if (counter_fail > 1) { + INFO("0x%X COUNTER FAIL %d -- %d vs %d\n", address, counter_fail, old_counter, (int)v); + } + if (counter_fail >= MAX_BAD_COUNTER) { + return false; + } + } else if (counter_fail > 0) { + counter_fail--; + } + return true; +} + + +CANParser::CANParser(int abus, const std::string& dbc_name, + const std::vector &options, + const std::vector &sigoptions) + : bus(abus) { + + dbc = dbc_lookup(dbc_name); + assert(dbc); + init_crc_lookup_tables(); + + for (const auto& op : options) { + MessageState state = { + .address = op.address, + // .check_frequency = op.check_frequency, + }; + + // msg is not valid if a message isn't received for 10 consecutive steps + if (op.check_frequency > 0) { + state.check_threshold = (1000000000ULL / op.check_frequency) * 10; + } + + + const Msg* msg = NULL; + for (int i=0; inum_msgs; i++) { + if (dbc->msgs[i].address == op.address) { + msg = &dbc->msgs[i]; + break; + } + } + if (!msg) { + fprintf(stderr, "CANParser: could not find message 0x%X in DBC %s\n", op.address, dbc_name.c_str()); + assert(false); + } + + state.size = msg->size; + + // track checksums and counters for this message + for (int i=0; inum_sigs; i++) { + const Signal *sig = &msg->sigs[i]; + if (sig->type != SignalType::DEFAULT) { + state.parse_sigs.push_back(*sig); + state.vals.push_back(0); + } + } + + // track requested signals for this message + for (const auto& sigop : sigoptions) { + if (sigop.address != op.address) continue; + + for (int i=0; inum_sigs; i++) { + const Signal *sig = &msg->sigs[i]; + if (strcmp(sig->name, sigop.name) == 0 + && sig->type == SignalType::DEFAULT) { + state.parse_sigs.push_back(*sig); + state.vals.push_back(sigop.default_value); + break; + } + } + + } + + message_states[state.address] = state; + } +} + +void CANParser::UpdateCans(uint64_t sec, const capnp::List::Reader& cans) { + int msg_count = cans.size(); + + DEBUG("got %d messages\n", msg_count); + + // parse the messages + for (int i = 0; i < msg_count; i++) { + auto cmsg = cans[i]; + if (cmsg.getSrc() != bus) { + // DEBUG("skip %d: wrong bus\n", cmsg.getAddress()); + continue; + } + auto state_it = message_states.find(cmsg.getAddress()); + if (state_it == message_states.end()) { + // DEBUG("skip %d: not specified\n", cmsg.getAddress()); + continue; + } + + if (cmsg.getDat().size() > 8) continue; //shouldn't ever happen + uint8_t dat[8] = {0}; + memcpy(dat, cmsg.getDat().begin(), cmsg.getDat().size()); + + state_it->second.parse(sec, cmsg.getBusTime(), dat); + } +} + +void CANParser::UpdateValid(uint64_t sec) { + can_valid = true; + for (const auto& kv : message_states) { + const auto& state = kv.second; + if (state.check_threshold > 0 && (sec - state.seen) > state.check_threshold) { + if (state.seen > 0) { + DEBUG("0x%X TIMEOUT\n", state.address); + } + can_valid = false; + } + } +} + +void CANParser::update_string(std::string data, bool sendcan) { + // format for board, make copy due to alignment issues, will be freed on out of scope + auto amsg = kj::heapArray((data.length() / sizeof(capnp::word)) + 1); + memcpy(amsg.begin(), data.data(), data.length()); + + // extract the messages + capnp::FlatArrayMessageReader cmsg(amsg); + cereal::Event::Reader event = cmsg.getRoot(); + + last_sec = event.getLogMonoTime(); + + auto cans = sendcan? event.getSendcan() : event.getCan(); + UpdateCans(last_sec, cans); + + UpdateValid(last_sec); +} + + +std::vector CANParser::query_latest() { + std::vector ret; + + for (const auto& kv : message_states) { + const auto& state = kv.second; + if (last_sec != 0 && state.seen != last_sec) continue; + + for (int i=0; iself.address_to_msg_name[cv.address].c_str() + cv_name = cv.name + + self.vl[cv.address][cv_name] = cv.value + self.ts[cv.address][cv_name] = cv.ts + + self.vl[name][cv_name] = cv.value + self.ts[name][cv_name] = cv.ts + + updated_val.insert(cv.address) + + return updated_val + + def update_string(self, dat, sendcan=False): + self.can.update_string(dat, sendcan) + return self.update_vl() + + def update_strings(self, strings, sendcan=False): + updated_vals = set() + + for s in strings: + updated_val = self.update_string(s, sendcan) + updated_vals.update(updated_val) + + return updated_vals + +cdef class CANDefine(): + cdef: + const DBC *dbc + + cdef public: + dict dv + string dbc_name + + def __init__(self, dbc_name): + self.dbc_name = dbc_name + self.dbc = dbc_lookup(dbc_name) + if not self.dbc: + raise RuntimeError("Can't lookup" + dbc_name) + + num_vals = self.dbc[0].num_vals + + address_to_msg_name = {} + + num_msgs = self.dbc[0].num_msgs + for i in range(num_msgs): + msg = self.dbc[0].msgs[i] + name = msg.name.decode('utf8') + address = msg.address + address_to_msg_name[address] = name + + dv = defaultdict(dict) + + for i in range(num_vals): + val = self.dbc[0].vals[i] + + sgname = val.name.decode('utf8') + address = val.address + def_val = val.def_val.decode('utf8') + + #separate definition/value pairs + def_val = def_val.split() + values = [int(v) for v in def_val[::2]] + defs = def_val[1::2] + + if address not in dv: + dv[address] = {} + msgname = address_to_msg_name[address] + dv[msgname] = {} + + # two ways to lookup: address or msg name + dv[address][sgname] = dict(zip(values, defs)) + dv[msgname][sgname] = dv[address][sgname] + + self.dv = dict(dv) diff --git a/opendbc/can/process_dbc.py b/opendbc/can/process_dbc.py new file mode 100755 index 00000000000000..9025331dd48ccb --- /dev/null +++ b/opendbc/can/process_dbc.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python3 +from __future__ import print_function +import os +import sys + +import jinja2 + +from collections import Counter +from opendbc.can.dbc import dbc + +def process(in_fn, out_fn): + dbc_name = os.path.split(out_fn)[-1].replace('.cc', '') + # print("processing %s: %s -> %s" % (dbc_name, in_fn, out_fn)) + + template_fn = os.path.join(os.path.dirname(__file__), "dbc_template.cc") + + with open(template_fn, "r") as template_f: + template = jinja2.Template(template_f.read(), trim_blocks=True, lstrip_blocks=True) + + can_dbc = dbc(in_fn) + + # process counter and checksums first + msgs = [(address, msg_name, msg_size, sorted(msg_sigs, key=lambda s: s.name not in ("COUNTER", "CHECKSUM"))) + for address, ((msg_name, msg_size), msg_sigs) in sorted(can_dbc.msgs.items()) if msg_sigs] + + def_vals = {a: sorted(set(b)) for a, b in can_dbc.def_vals.items()} # remove duplicates + def_vals = sorted(def_vals.items()) + + if can_dbc.name.startswith(("honda_", "acura_")): + checksum_type = "honda" + checksum_size = 4 + counter_size = 2 + checksum_start_bit = 3 + counter_start_bit = 5 + little_endian = False + elif can_dbc.name.startswith(("toyota_", "lexus_")): + checksum_type = "toyota" + checksum_size = 8 + counter_size = None + checksum_start_bit = 7 + counter_start_bit = None + little_endian = False + elif can_dbc.name.startswith(("vw_", "volkswagen_", "audi_", "seat_", "skoda_")): + checksum_type = "volkswagen" + checksum_size = 8 + counter_size = 4 + checksum_start_bit = 0 + counter_start_bit = 0 + little_endian = True + elif can_dbc.name.startswith(("subaru_global_")): + checksum_type = "subaru" + checksum_size = 8 + counter_size = None + checksum_start_bit = 0 + counter_start_bit = None + little_endian = True + elif can_dbc.name.startswith(("chrysler_")): + checksum_type = "chrysler" + checksum_size = 8 + counter_size = None + checksum_start_bit = 7 + counter_start_bit = None + little_endian = False + else: + checksum_type = None + checksum_size = None + counter_size = None + checksum_start_bit = None + counter_start_bit = None + little_endian = None + + # sanity checks on expected COUNTER and CHECKSUM rules, as packer and parser auto-compute those signals + for address, msg_name, _, sigs in msgs: + dbc_msg_name = dbc_name + " " + msg_name + for sig in sigs: + if checksum_type is not None: + # checksum rules + if sig.name == "CHECKSUM": + if sig.size != checksum_size: + sys.exit("%s: CHECKSUM is not %d bits long" % (dbc_msg_name, checksum_size)) + if sig.start_bit % 8 != checksum_start_bit: + sys.exit("%s: CHECKSUM starts at wrong bit" % dbc_msg_name) + if little_endian != sig.is_little_endian: + sys.exit("%s: CHECKSUM has wrong endianness" % dbc_msg_name) + # counter rules + if sig.name == "COUNTER": + if counter_size is not None and sig.size != counter_size: + sys.exit("%s: COUNTER is not %d bits long" % (dbc_msg_name, counter_size)) + if counter_start_bit is not None and sig.start_bit % 8 != counter_start_bit: + print(counter_start_bit, sig.start_bit) + sys.exit("%s: COUNTER starts at wrong bit" % dbc_msg_name) + if little_endian != sig.is_little_endian: + sys.exit("%s: COUNTER has wrong endianness" % dbc_msg_name) + # pedal rules + if address in [0x200, 0x201]: + if sig.name == "COUNTER_PEDAL" and sig.size != 4: + sys.exit("%s: PEDAL COUNTER is not 4 bits long" % dbc_msg_name) + if sig.name == "CHECKSUM_PEDAL" and sig.size != 8: + sys.exit("%s: PEDAL CHECKSUM is not 8 bits long" % dbc_msg_name) + + # Fail on duplicate message names + c = Counter([msg_name for address, msg_name, msg_size, sigs in msgs]) + for name, count in c.items(): + if count > 1: + sys.exit("%s: Duplicate message name in DBC file %s" % (dbc_name, name)) + + parser_code = template.render(dbc=can_dbc, checksum_type=checksum_type, msgs=msgs, def_vals=def_vals, len=len) + + with open(out_fn, "w") as out_f: + out_f.write(parser_code) + +def main(): + if len(sys.argv) != 3: + print("usage: %s dbc_directory output_filename" % (sys.argv[0],)) + sys.exit(0) + + dbc_dir = sys.argv[1] + out_fn = sys.argv[2] + + dbc_name = os.path.split(out_fn)[-1].replace('.cc', '') + in_fn = os.path.join(dbc_dir, dbc_name + '.dbc') + + process(in_fn, out_fn) + + +if __name__ == '__main__': + main() diff --git a/opendbc/chrysler_pacifica_2017_hybrid.dbc b/opendbc/chrysler_pacifica_2017_hybrid.dbc index be99769b5f8418..54e4819f23b316 100644 --- a/opendbc/chrysler_pacifica_2017_hybrid.dbc +++ b/opendbc/chrysler_pacifica_2017_hybrid.dbc @@ -43,7 +43,7 @@ BO_ 258 STEERING: 8 XXX SG_ STEERING_RATE : 20|13@0+ (0.3187251,-1305.498) [0|8191] "deg/s" XXX SG_ STEER_ANGLE : 4|13@0+ (0.3187251,-1307.888) [-360|360] "deg" XXX -BO_ 514 SPEED_1: 4 XXX +BO_ 514 SPEED_1: 8 XXX SG_ SPEED_LEFT : 7|12@0+ (0.071028,0) [0|65535] "m/s" XXX SG_ SPEED_RIGHT : 23|12@0+ (0.071028,0) [0|1023] "m/s" XXX @@ -132,13 +132,12 @@ BO_ 705 AUTO_PARK_BUTTON: 8 XXX BO_ 719 AUTO_PARK_SIGNALS_1: 8 XXX SG_ AUTO_PARK_UNKNOWN_1 : 7|16@0+ (1,0) [0|31] "" XXX -BO_ 671 AUTO_PARK_SIGNALS_2: 8 XXX - SG_ AUTO_PARK_PARALLEL : 21|1@0+ (1,0) [0|1] "" XXX - SG_ AUTO_PARK_PERPENDICULAR_1 : 22|1@0+ (1,0) [0|1] "" XXX - SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX +BO_ 671 AUTO_PARK_REQUEST: 8 XXX SG_ AUTO_PARK_CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - SG_ AUTO_PARK_MAYBE_TURNING : 3|12@0+ (1,0) [0|1023] "" XXX - SG_ AUTO_PARK_TURNING_STATUS : 7|4@0+ (1,0) [0|15] "" XXX + SG_ AUTO_PARK_STATUS : 7|5@0+ (1,0) [0|15] "" XXX + SG_ AUTO_PARK_COUNTER : 55|4@0+ (1,0) [0|15] "" XXX + SG_ AUTO_PARK_MODE : 22|2@0+ (1,0) [0|3] "" XXX + SG_ AUTO_PARK_CMD : 2|11@0+ (1,-1024) [0|1] "NM" XXX BO_ 784 AUTO_PARK_LESS_INTERESTING: 8 XXX SG_ INCREASING_UNKNOWN : 55|8@0+ (1,0) [0|7] "" XXX @@ -393,10 +392,8 @@ CM_ SG_ 678 LKAS_LANE_LINES "0x01 transparent lines, 0x02 left white, 0x03 right CM_ SG_ 678 LKAS_ALERTS "(0x01, 0x02) lane sense off, (0x03, 0x04, 0x06) place hands on steering wheel, 0x07 lane departure detected + place hands on steering wheel, (0x08, 0x09) lane sense unavailable + clean front windshield, 0x0b lane sense and auto high beam unavailable + clean front windshield, 0x0c lane sense unavailable + service required, (0x00, 0x05, 0x0a, 0x0d, 0x0e, 0x0f) null"; CM_ SG_ 705 AUTO_PARK_TOGGLE_1 "set briefly when turning on or off self-parking"; CM_ SG_ 705 INCREASING_UNKNOWN "sometimes decreasing"; -CM_ SG_ 671 AUTO_PARK_PARALLEL "parallel parking mode"; -CM_ SG_ 671 AUTO_PARK_PERPENDICULAR_1 "perpendicular parking mode"; -CM_ SG_ 671 AUTO_PARK_MAYBE_TURNING "something with autopark turning the steering wheel maybe."; -CM_ SG_ 671 AUTO_PARK_TURNING_STATUS "0 when not steering. when steering starts, 4 for two packets, and then 5 for the rest"; +CM_ SG_ 671 AUTO_PARK_CMD "Request Appears to be in NM"; +CM_ SG_ 671 AUTO_PARK_STATUS "1 = IDLE / NO REQUEST 9 = START REQUEST 10 = REQUEST MODE 11 = REQUEST MODE"; CM_ SG_ 784 INCREASING_UNKNOWN "perhaps distance traveled"; CM_ SG_ 826 AUTO_PARK_GEAR_1 "Reverse=0, Forward=f"; CM_ SG_ 826 AUTO_PARK_GEAR_2 "Reverse=0, Forward=f"; @@ -412,7 +409,7 @@ CM_ SG_ 571 CHECKSUM "standard checksum"; CM_ SG_ 825 BEEP_339 "sent every 0.5s. 0050 is no beep. To beep send 4355 or 4155. Used by ParkSense warning."; CM_ SG_ 270 ELECTRIC_MOTOR "0x7fff indicates electric motor not in use"; CM_ SG_ 291 ENERGY_GAIN_LOSS "unsure what this actually is"; -CM_ SG_ 291 ENERGY_SMOOTHER_CURVE "unusre what it is, but smoother"; +CM_ SG_ 291 ENERGY_SMOOTHER_CURVE "unsure what it is, but smoother"; CM_ SG_ 308 ACCEL_134 "only set when human presses accel pedal"; CM_ SG_ 532 NOISY_SLOWLY_DECREASING "perhaps battery but do not know"; CM_ SG_ 816 TRACTION_OFF "set when traction off button is enabled"; @@ -432,5 +429,5 @@ CM_ SG_ 625 SPEED "zero on non-acc drives"; CM_ SG_ 625 ACCEL_PERHAPS "set to 7767 on non-ACC drives. ACC drive 40k is constant speed, 42k is accelerating"; CM_ SG_ 268 BRAKE_PERHAPS "triggers only on ACC braking"; CM_ SG_ 384 NEW_SIGNAL_1 "set in ACC gas driving. not set in electric human. not sure about gas human driving."; -VAL_ 746 PRNDL 5 "Low" 4 "Drive" 3 "Neutral" 2 "Reverse" 1 "Park" ; +VAL_ 746 PRNDL 5 "L" 4 "D" 3 "N" 2 "R" 1 "P" ; VAL_ 792 TURN_SIGNALS 2 "Right" 1 "Left" ; diff --git a/opendbc/ford_cgea1_2_bodycan_2011.dbc b/opendbc/ford_cgea1_2_bodycan_2011.dbc deleted file mode 100644 index 49fcae19c2e4f8..00000000000000 --- a/opendbc/ford_cgea1_2_bodycan_2011.dbc +++ /dev/null @@ -1,1070 +0,0 @@ -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_ 58 BCM_m_FrP01: 8 XXX - SG_ ChildLockCmd : 13|1@0+ (1,0) [0|0] "" XXX - SG_ ChildLockCmd_UB : 12|1@0+ (1,0) [0|0] "" XXX - SG_ CLockCmd : 31|8@0+ (1,0) [0|0] "" XXX - SG_ CLockCmd_UB : 14|1@0+ (1,0) [0|0] "" XXX - SG_ DDShortDrop : 3|2@0+ (1,0) [0|0] "" XXX - SG_ DDShortDrop_UB : 4|1@0+ (1,0) [0|0] "" XXX - SG_ DirectionIndication : 11|2@0+ (1,0) [0|0] "" XXX - SG_ DirectionIndication_UB : 0|1@0+ (1,0) [0|0] "" XXX - SG_ EpsDrvInfo_D_Dsply : 36|4@0+ (1,0) [0|0] "" XXX - SG_ EpsDrvInfo_D_Dsply_UB : 39|1@0+ (1,0) [0|0] "" XXX - SG_ GearRvrseActv_D_Actl : 38|2@0+ (1,0) [0|0] "" XXX - SG_ GearRvrseActv_D_Actl_UB : 15|1@0+ (1,0) [0|0] "" XXX - SG_ VehVActlEng_D_Qf_3A : 9|2@0+ (1,0) [0|0] "" XXX - SG_ Veh_V_ActlEng_UB_3A : 1|1@0+ (1,0) [0|0] "" XXX - SG_ Veh_V_ActlEng_3A : 55|16@0+ (0.01,0) [0|0] "kph" XXX - SG_ Veh_V_DsplyCcSet : 23|8@0+ (1,0) [0|0] "" XXX - SG_ Veh_V_RqCcSet : 32|9@0+ (0.5,0) [0|0] "kph" XXX - SG_ WasherFluidLevelLow : 5|1@0+ (1,0) [0|0] "" XXX - -BO_ 64 BCM_m_FrP02: 8 XXX - SG_ FuelCutoffReq : 7|4@0+ (1,0) [0|0] "" XXX - SG_ FuelCutoffReq_UB : 8|1@0+ (1,0) [0|0] "" XXX - SG_ KVRFRSettings : 54|15@0+ (1,0) [0|0] "" XXX - SG_ KVRFRSettings_UB : 10|1@0+ (1,0) [0|0] "" XXX - SG_ PsngrFrntDetct_D_Actl : 23|2@0+ (1,0) [0|0] "" XXX - SG_ PsngrFrntDetct_D_Actl_UB : 3|1@0+ (1,0) [0|0] "" XXX - SG_ RILReq : 21|2@0+ (1,0) [0|0] "" XXX - SG_ RILReq_UB : 55|1@0+ (1,0) [0|0] "" XXX - SG_ SecondRowBuckleDriver : 31|2@0+ (1,0) [0|0] "" XXX - SG_ SecondRowBuckleDriver_UB : 0|1@0+ (1,0) [0|0] "" XXX - SG_ SecondRowBuckleMid : 29|2@0+ (1,0) [0|0] "" XXX - SG_ SecondRowBuckleMid_UB : 15|1@0+ (1,0) [0|0] "" XXX - SG_ SecondRowBucklePsngr : 27|2@0+ (1,0) [0|0] "" XXX - SG_ SecondRowBucklePsngr_UB : 14|1@0+ (1,0) [0|0] "" XXX - SG_ ThirdRowBuckleDriver : 25|2@0+ (1,0) [0|0] "" XXX - SG_ ThirdRowBuckleDriver_UB : 13|1@0+ (1,0) [0|0] "" XXX - SG_ ThirdRowBucklePsngr : 37|2@0+ (1,0) [0|0] "" XXX - SG_ ThirdRowBucklePsngr_UB : 11|1@0+ (1,0) [0|0] "" XXX - SG_ WheelRotationCnt : 47|8@0+ (1,0) [0|0] "" XXX - SG_ WheelRotationCnt_UB : 9|1@0+ (1,0) [0|0] "" XXX - SG_ WheelRotationCntQF : 35|2@0+ (1,0) [0|0] "" XXX - SG_ WhlDirRr_D_Actl_UB_40 : 2|1@0+ (1,0) [0|0] "" XXX - SG_ WhlDirRr_D_Actl_40 : 39|2@0+ (1,0) [0|0] "" XXX - SG_ WhlDirRl_D_Actl_UB_40 : 1|1@0+ (1,0) [0|0] "" XXX - SG_ WhlDirRl_D_Actl_40 : 33|2@0+ (1,0) [0|0] "" XXX - -BO_ 131 MS_Steering_Data: 8 XXX - SG_ SteColumn_Status_UB : 28|1@0+ (1,0) [0|0] "" XXX - SG_ SteColumn_Status : 31|3@0+ (1,0) [0|0] "" XXX - SG_ SteCol_Manual_Override_UB : 26|1@0+ (1,0) [0|0] "" XXX - SG_ SteCol_Manual_Override : 27|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Send_UB : 20|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Send : 6|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Phone_UB : 17|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Phone : 3|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_OK_UB : 16|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_OK : 2|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Volume_Up_UB : 23|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Volume_Down_UB : 22|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Voice_PTT_UB : 21|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Seek_Right_UB : 19|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Seek_Left_UB : 18|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Mode_UB : 11|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Mode : 13|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Media_UB : 9|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Volume_Up : 15|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Volume_Down : 14|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Voice_PTT : 7|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Seek_Right : 5|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Seek_Left : 4|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Media : 1|1@0+ (1,0) [0|0] "" XXX - SG_ VehYaw_W_Actl : 55|16@0+ (0.0002,-6.5) [0|0] "rad/s" XXX - SG_ SteWhlCtl_End_UB : 8|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_End : 0|1@0+ (1,0) [0|0] "" XXX - SG_ VehYaw_W_Actl_UB : 40|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Mute_UB : 10|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Mute : 12|1@0+ (1,0) [0|0] "" XXX - -BO_ 257 Driver_Seat_Information: 8 XXX - SG_ Reverse_Mirror_Stat : 3|2@0+ (1,0) [0|0] "" XXX - SG_ Memory_Feedback_Rqst : 5|1@0+ (1,0) [0|0] "" XXX - SG_ Easy_Entry_Exit_Stat : 7|2@0+ (1,0) [0|0] "" XXX - -BO_ 260 Driver_Seat_Information_2: 8 XXX - SG_ Memory_Cmd : 15|4@0+ (1,0) [0|0] "" XXX - SG_ Easy_Entry_Rqst : 4|2@0+ (1,0) [0|0] "" XXX - SG_ DrvSeat_Stat : 7|3@0+ (1,0) [0|0] "" XXX - SG_ Cancel_Auto_Movement : 1|1@0+ (1,0) [0|0] "" XXX - -BO_ 269 IdleShutdown_Legacy: 8 XXX - SG_ IDLE_ENGINE_SHUTDOWN : 23|2@0+ (1,0) [0|0] "" XXX - -BO_ 272 Keyfob_Pad_Stat: 8 XXX - SG_ L_Pwr_Sliding_Dr_Rqst : 28|1@0+ (1,0) [0|0] "" XXX - SG_ Power_Decklid_Rqst : 31|1@0+ (1,0) [0|0] "" XXX - SG_ R_Pwr_Sliding_Dr_Rqst : 29|1@0+ (1,0) [0|0] "" XXX - SG_ Keyfob_Pad_Msg_Count : 23|8@0+ (1,0) [0|0] "Counts" XXX - SG_ Keyfob_Pad_Id_Number : 15|8@0+ (1,0) [0|0] "" XXX - SG_ Keyfob_Pad_Button_Pressed : 7|8@0+ (1,0) [0|0] "" XXX - SG_ Power_Liftgate_Rqst : 30|1@0+ (1,0) [0|0] "" XXX - SG_ Keycode_Status : 27|20@0+ (1,0) [0|0] "" XXX - -BO_ 275 Power_Liftgate_Mode_StatM: 8 XXX - SG_ Power_Liftgate_Mode_Stat : 7|2@0+ (1,0) [0|0] "" XXX - SG_ DrTgateChime_D_Rq : 5|2@0+ (1,0) [0|0] "" XXX - -BO_ 276 Running_Board_CmdM: 8 XXX - SG_ Running_Board_Cmd : 7|2@0+ (1,0) [0|0] "" XXX - -BO_ 277 Running_Board_StatM: 8 XXX - SG_ Running_Board_Stat : 7|2@0+ (1,0) [0|0] "" XXX - -BO_ 288 ClmtCtrlSeat_SetCmdlegacy1: 8 XXX - SG_ ClmtCtrlSeat_SetCmd_Dvr : 7|8@0+ (1,0) [0|0] "" XXX - -BO_ 289 ClmtCtrlSeat_SetStat_DvrM: 8 XXX - SG_ ClmtCtrlSeat_SetStat_Dvr : 7|8@0+ (1,0) [0|0] "" XXX - -BO_ 290 ClmtCtrlSeat_SetCmdlegacy2: 8 XXX - SG_ ClmtCtrlSeat_SetCmd_Psgr : 7|8@0+ (1,0) [0|0] "" XXX - -BO_ 291 ClmtCtrlSeat_SetStat_PsgrM: 8 XXX - SG_ ClmtCtrlSeat_SetStat_Psgr : 7|8@0+ (1,0) [0|0] "" XXX - -BO_ 292 ClmtCtrlSeatSet_Cmd_v2_MS: 8 XXX - SG_ ClmtCtrlSeat_SetCmd_Psgr : 15|8@0+ (1,0) [0|0] "" XXX - SG_ ClmtCtrlSeat_SetCmd_Dvr : 7|8@0+ (1,0) [0|0] "" XXX - -BO_ 293 ClmtCtrlSeatSet_Stat_v2: 8 XXX - SG_ ClmtCtrlSeat_SetStat_Psgr : 15|8@0+ (1,0) [0|0] "" XXX - SG_ ClmtCtrlSeat_SetStat_Dvr : 7|8@0+ (1,0) [0|0] "" XXX - -BO_ 304 Mirror_Manual_Override_M: 8 XXX - SG_ Mirror_Manual_Override : 7|1@0+ (1,0) [0|0] "Binary" XXX - -BO_ 305 Memory_Sw_StatM: 8 XXX - SG_ Memory_Sw_Message_Count : 15|8@0+ (1,0) [0|0] "Counts" XXX - SG_ Memory_Set_Sw_Stat : 7|1@0+ (1,0) [0|0] "Binary" XXX - SG_ Memory_Set_Cancel : 3|1@0+ (1,0) [0|0] "Binary" XXX - SG_ Memory_3_Sw_Stat : 4|1@0+ (1,0) [0|0] "Binary" XXX - SG_ Memory_2_Sw_Stat : 5|1@0+ (1,0) [0|0] "Binary" XXX - SG_ Memory_1_Sw_Stat : 6|1@0+ (1,0) [0|0] "Binary" XXX - -BO_ 306 Driver_Lock_Sw_StatM: 8 XXX - SG_ Driver_Door_Key_Unlock : 12|1@0+ (1,0) [0|0] "" XXX - SG_ Driver_Door_Key_Lock : 13|1@0+ (1,0) [0|0] "" XXX - SG_ Driver_Lock_Sw_Message_Cnt : 7|8@0+ (1,0) [0|0] "Counts" XXX - SG_ Driver_Lock_Sw_Stat : 15|2@0+ (1,0) [0|0] "" XXX - -BO_ 309 Memory_Cancel_Cmd_M: 8 XXX - SG_ Memory_Cancel_Cmd : 7|1@0+ (1,0) [0|0] "Binary" XXX - -BO_ 310 Driver_Door_Lock_CmdM: 8 XXX - SG_ Driver_Door_Lock_Msg_Cnt : 7|8@0+ (1,0) [0|0] "Counts" XXX - SG_ Driver_Door_Lock_Cmd : 15|4@0+ (1,0) [0|0] "" XXX - -BO_ 311 Pass_Mirror_Sw_StatM: 8 XXX - SG_ Pass_Mirror_Sw_UD_Stat : 7|2@0+ (1,0) [0|0] "" XXX - SG_ Pass_Mirror_Sw_LR_Stat : 5|2@0+ (1,0) [0|0] "" XXX - -BO_ 313 RPwrSlideDr_Unlock_RqstM: 8 XXX - SG_ RPwrSlideDr_Unlock_Rqst : 7|1@0+ (1,0) [0|0] "" XXX - -BO_ 320 LPwrSlideDr_Unlock_RqstM: 8 XXX - SG_ LPwrSlideDr_Unlock_Rqst : 7|1@0+ (1,0) [0|0] "" XXX - -BO_ 321 Passive_Entry_Ctrl_Data: 8 XXX - SG_ PE_Control_Data_1 : 23|8@0+ (1,0) [0|0] "" XXX - SG_ PE_Control_Cmd : 7|3@0+ (1,0) [0|0] "" XXX - SG_ PK_SearchResults_Prog : 63|4@0+ (1,0) [0|0] "" XXX - SG_ PK_SearchResults_MyKey : 4|4@0+ (1,0) [0|0] "" XXX - SG_ PK_SearchResults_Found : 59|4@0+ (1,0) [0|0] "" XXX - SG_ PK_Search_EvNum : 15|8@0+ (1,0) [0|0] "Counts" XXX - SG_ PE_Control_Data_5 : 55|8@0+ (1,0) [0|0] "" XXX - SG_ PE_Control_Data_4 : 47|8@0+ (1,0) [0|0] "" XXX - SG_ PE_Control_Data_3 : 39|8@0+ (1,0) [0|0] "" XXX - SG_ PE_Control_Data_2 : 31|8@0+ (1,0) [0|0] "" XXX - -BO_ 322 Passive_Entry_Target_Data: 8 XXX - SG_ PE_Target_Data_5 : 47|8@0+ (1,0) [0|0] "" XXX - SG_ PE_Target_Cmd : 7|2@0+ (1,0) [0|0] "" XXX - SG_ PE_Target_Status : 5|1@0+ (1,0) [0|0] "" XXX - SG_ PE_Target_Data_1 : 15|8@0+ (1,0) [0|0] "" XXX - SG_ PE_Search_Rqst : 4|2@0+ (1,0) [0|0] "" XXX - SG_ PE_Target_Data_4 : 39|8@0+ (1,0) [0|0] "" XXX - SG_ PE_Target_Data_3 : 31|8@0+ (1,0) [0|0] "" XXX - SG_ PE_Target_Data_2 : 23|8@0+ (1,0) [0|0] "" XXX - -BO_ 577 BCM_m_FrP28: 8 XXX - SG_ WheelRotToothCntFrL : 15|8@0+ (1,0) [0|0] "" XXX - SG_ WheelRotToothCntFrL_UB : 42|1@0+ (1,0) [0|0] "" XXX - SG_ WheelRotToothCntFrR : 23|8@0+ (1,0) [0|0] "" XXX - SG_ WheelRotToothCntFrR_UB : 41|1@0+ (1,0) [0|0] "" XXX - SG_ WheelRotToothCntReL : 31|8@0+ (1,0) [0|0] "" XXX - SG_ WheelRotToothCntReL_UB : 40|1@0+ (1,0) [0|0] "" XXX - SG_ WheelRotToothCntReR : 39|8@0+ (1,0) [0|0] "" XXX - SG_ WheelRotToothCntReR_UB : 43|1@0+ (1,0) [0|0] "" XXX - -BO_ 736 FCIM_Button_Press: 8 XXX - SG_ FCIM_Target_ID : 13|4@0+ (1,0) [0|0] "" XXX - SG_ FCIM_Button_Type : 7|8@0+ (1,0) [0|0] "" XXX - SG_ FCIM_Button_State : 15|2@0+ (1,0) [0|0] "" XXX - -BO_ 806 Compressor_Req: 8 XXX - SG_ HvacEvap_Te_Rq : 33|10@0+ (0.125,-50.0) [0|0] "Degrees C" XXX - SG_ HvacEvap_Te_Actl : 17|10@0+ (0.125,-50.0) [0|0] "Degrees C" XXX - SG_ HvacAirCond_B_Rq : 7|1@0+ (1,0) [0|0] "" XXX - SG_ HvacEvap_Te_Offst : 1|10@0+ (0.125,-50.0) [0|0] "Degrees C" XXX - -BO_ 842 MassageSeat_Data1: 8 XXX - SG_ SeatLmbrUpDrv_Pc_Actl : 38|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatLmbrMidDrv_Pc_Actl : 30|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatLmbrLoDrv_Pc_Actl : 22|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatBlUpDrv_Pc_Actl : 14|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatBlLoDrv_Pc_Actl : 6|7@0+ (1,0) [0|0] "%" XXX - -BO_ 843 MassageSeat_Data2: 8 XXX - SG_ SeatLmbrUpPsgr_Pc_Actl : 38|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatLmbrMidPsgr_Pc_Actl : 30|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatLmbrLoPsgr_Pc_Actl : 22|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatBlUpPsgr_Pc_Actl : 14|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatBlLoPsgr_Pc_Actl : 6|7@0+ (1,0) [0|0] "%" XXX - -BO_ 844 MassageSeat_Stat1: 8 XXX - SG_ StmsLmbrDrv_D_Stat : 17|2@0+ (1,0) [0|0] "" XXX - SG_ StmsCshnDrv_D_Stat : 19|2@0+ (1,0) [0|0] "" XXX - SG_ SeatSwtchDrv_B_Stat : 31|1@0+ (1,0) [0|0] "" XXX - SG_ SeatFnDrv_D_Stat : 23|3@0+ (1,0) [0|0] "" XXX - SG_ SeatAirAmb_P_Actl : 7|16@0+ (0.01,0) [0|0] "KiloPascal" XXX - SG_ SeatPDrv_B_Stat : 20|1@0+ (1,0) [0|0] "" XXX - -BO_ 845 MassageSeat_Stat2: 8 XXX - SG_ StmsLmbrPsgr_D_Stat : 15|2@0+ (1,0) [0|0] "" XXX - SG_ StmsCshnPsgr_D_Stat : 13|2@0+ (1,0) [0|0] "" XXX - SG_ SeatSwtchPsgr_B_Stat : 11|1@0+ (1,0) [0|0] "" XXX - SG_ SeatPPsgr_B_Stat : 7|1@0+ (1,0) [0|0] "" XXX - SG_ SeatFnPsgr_D_Stat : 6|3@0+ (1,0) [0|0] "" XXX - SG_ PsgrMemFeedback_Rsp : 3|4@0+ (1,0) [0|0] "" XXX - -BO_ 846 MassageSeat_Req_MS: 8 XXX - SG_ SeatFnPsgr_D_Rq : 15|3@0+ (1,0) [0|0] "" XXX - SG_ SeatFnDrv_D_Rq : 12|3@0+ (1,0) [0|0] "" XXX - SG_ SeatFnDfaltPsgr_B_Rq : 9|1@0+ (1,0) [0|0] "" XXX - SG_ SeatFnDfaltDrv_B_Rq : 8|1@0+ (1,0) [0|0] "" XXX - SG_ SeatFnChngPsgr_D_Rq : 7|2@0+ (1,0) [0|0] "" XXX - SG_ SeatFnChngDrv_D_Rq : 5|2@0+ (1,0) [0|0] "" XXX - SG_ PsgrMemory_Rq : 3|4@0+ (1,0) [0|0] "" XXX - -BO_ 849 MassageSeat_Data3: 8 XXX - SG_ SeatCshnDrvRR_Pc_Actl : 30|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatCshnDrvRL_Pc_Actl : 22|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatCshnDrvFR_Pc_Actl : 14|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatCshnDrvFL_Pc_Actl : 6|7@0+ (1,0) [0|0] "%" XXX - -BO_ 850 MassageSeat_Data4: 8 XXX - SG_ SeatCshnPsgrRR_Pc_Actl : 30|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatCshnPsgrRL_Pc_Actl : 22|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatCshnPsgrFR_Pc_Actl : 14|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatCshnPsgrFL_Pc_Actl : 6|7@0+ (1,0) [0|0] "%" XXX - -BO_ 853 EFP_CC_Status_MS: 8 XXX - SG_ Save_My_Temp : 59|1@0+ (1,0) [0|0] "" XXX - SG_ Front_Left_Temp_Setpt : 31|8@0+ (1,0) [0|0] "Mixed" XXX - SG_ RrDefrost_HtdMirrorReq : 60|1@0+ (1,0) [0|0] "" XXX - SG_ Rear_Control_Status : 16|1@0+ (1,0) [0|0] "" XXX - SG_ MultipleButtonPressReq : 63|3@0+ (1,0) [0|0] "" XXX - SG_ Rear_System_Mode_Req : 19|3@0+ (1,0) [0|0] "" XXX - SG_ Recirc_Request : 23|2@0+ (1,0) [0|0] "" XXX - SG_ Front_Rt_Temp_Setpt : 39|8@0+ (1,0) [0|0] "Mixed" XXX - SG_ AC_Request : 21|2@0+ (1,0) [0|0] "" XXX - SG_ Windshield_ModeRequest : 15|4@0+ (8.33,0) [0|0] "%" XXX - SG_ Panel_Mode_Request : 7|4@0+ (8.33,0) [0|0] "%" XXX - SG_ Overriding_ModeReq : 10|3@0+ (1,0) [0|0] "" XXX - SG_ Floor_Mode_Request : 3|4@0+ (8.33,0) [0|0] "%" XXX - SG_ Rear_Right_Temp_Setpt : 55|8@0+ (1,0) [0|0] "Mixed" XXX - SG_ Forced_Recirc_Req : 11|1@0+ (1,0) [0|0] "" XXX - SG_ Rear_Left_Temp_Setpt : 47|8@0+ (1,0) [0|0] "Mixed" XXX - -BO_ 854 EFP_CC_Seat_Req_Stat_MS: 8 XXX - SG_ Front_Rear_Blower_Req : 31|6@0+ (1,0) [0|0] "Detents" XXX - SG_ Pass_Rr_Cond_Seat_Req : 21|2@0+ (1,0) [0|0] "" XXX - SG_ Pass_Rr_Cond_Seat_Lvl : 8|3@0+ (1,0) [0|0] "" XXX - SG_ Pass_Fr_Cond_Seat_Req : 13|2@0+ (1,0) [0|0] "" XXX - SG_ Pass_Fr_Cond_Seat_Lvl : 11|3@0+ (1,0) [0|0] "" XXX - SG_ Drvr_Rr_Cond_Seat_Req : 15|2@0+ (1,0) [0|0] "" XXX - SG_ Drvr_Rr_Cond_Seat_Lvl : 2|3@0+ (1,0) [0|0] "" XXX - SG_ Drvr_Fr_Cond_Seat_Req : 7|2@0+ (1,0) [0|0] "" XXX - SG_ Drvr_Fr_Cond_Seat_Lvl : 5|3@0+ (1,0) [0|0] "" XXX - -BO_ 855 RCCM_CC_Status: 8 XXX - SG_ RrBlwrCondStLdShedStat : 25|2@0+ (1,0) [0|0] "" XXX - SG_ FrBlwrCondStLdShedStat : 20|2@0+ (1,0) [0|0] "" XXX - SG_ RCCM_Rr_Rt_TempSetpt : 63|8@0+ (1,0) [0|0] "Mixed" XXX - SG_ RCCM_Rr_Left_TempSetpt : 55|8@0+ (1,0) [0|0] "Mixed" XXX - SG_ RCCM_Fr_Rt_TempSetpt : 47|8@0+ (1,0) [0|0] "Mixed" XXX - SG_ RCCM_Fr_Left_TempSetpt : 39|8@0+ (1,0) [0|0] "Mixed" XXX - SG_ RCCM_Fr_Rr_Blower_Req : 31|6@0+ (1,0) [0|0] "Detents" XXX - SG_ Panel_Mode_State : 7|4@0+ (8.33,0) [0|0] "%" XXX - SG_ RrDefHtdMirrLdShedStat : 18|2@0+ (1,0) [0|0] "" XXX - SG_ Windshield_Mode_State : 15|4@0+ (8.33,0) [0|0] "%" XXX - SG_ Recirc_Door_State : 11|2@0+ (1,0) [0|0] "" XXX - SG_ Rear_System_Mode_State : 23|3@0+ (1,0) [0|0] "" XXX - SG_ Default_Defrost_State : 9|1@0+ (1,0) [0|0] "" XXX - SG_ Auto_AC_Indicator_Temp : 16|1@0+ (1,0) [0|0] "" XXX - SG_ Floor_Mode_State : 3|4@0+ (8.33,0) [0|0] "%" XXX - SG_ RrDefrost_HtdMirrState : 8|1@0+ (1,0) [0|0] "" XXX - -BO_ 856 RCCM_CC_Seat_Status: 8 XXX - SG_ Active_My_Temp : 2|1@0+ (1,0) [0|0] "" XXX - SG_ CC_HtdStrWhl_Req : 24|1@0+ (1,0) [0|0] "" XXX - SG_ RCCM_PR_Cond_Seat_Lvl : 31|3@0+ (1,0) [0|0] "" XXX - SG_ RCCM_PR_Cond_Seat_Req : 28|2@0+ (1,0) [0|0] "" XXX - SG_ RCCM_PF_Cond_Seat_Req : 20|2@0+ (1,0) [0|0] "" XXX - SG_ RCCM_PF_Cond_Seat_Lvl : 23|3@0+ (1,0) [0|0] "" XXX - SG_ RCCM_DR_Cond_Seat_Req : 12|2@0+ (1,0) [0|0] "" XXX - SG_ RCCM_DR_Cond_Seat_Lvl : 15|3@0+ (1,0) [0|0] "" XXX - SG_ RCCM_DF_Cond_Seat_Req : 4|2@0+ (1,0) [0|0] "" XXX - SG_ RCCM_DF_Cond_Seat_Lvl : 7|3@0+ (1,0) [0|0] "" XXX - SG_ PassRrCondStLdShedStat : 26|2@0+ (1,0) [0|0] "" XXX - SG_ PassFrCondStLdShedStat : 18|2@0+ (1,0) [0|0] "" XXX - SG_ DrvRrCondStLdShedStat : 10|2@0+ (1,0) [0|0] "" XXX - SG_ DrvFrCondStLdShedStat : 1|2@0+ (1,0) [0|0] "" XXX - -BO_ 857 RCCM_CC_MBP_Press_Stat: 8 XXX - SG_ Report_Active : 33|2@0+ (1,0) [0|0] "" XXX - SG_ Pass_Temp_Units : 35|1@0+ (1,0) [0|0] "" XXX - SG_ Front_Fan_Bars_Disply : 39|3@0+ (1,0) [0|0] "" XXX - SG_ Drvr_Temp_Units : 36|1@0+ (1,0) [0|0] "" XXX - SG_ MultBtnPushDsplyPass10 : 23|8@0+ (1,0) [0|0] "" XXX - SG_ MultBtnPushDsplyPass1 : 31|8@0+ (1,0) [0|0] "" XXX - SG_ MultBtnPushDsplyDrvr10 : 7|8@0+ (1,0) [0|0] "" XXX - SG_ MultBtnPushDsplyDrvr1 : 15|8@0+ (1,0) [0|0] "" XXX - -BO_ 859 MFD_CC_Status_MS: 8 XXX - SG_ Rear_Mode_Bttn_Status : 38|1@0+ (1,0) [0|0] "" XXX - -BO_ 860 EFP_CC_Info_Status_MS: 8 XXX - SG_ Rear_Panel_Btn_State : 41|1@0+ (1,0) [0|0] "" XXX - SG_ Rear_Floor_Btn_State : 40|1@0+ (1,0) [0|0] "" XXX - SG_ HtdStrWhl_SftBtt_Stt : 39|2@0+ (1,0) [0|0] "" XXX - SG_ AC_Sft_Button_State : 23|2@0+ (1,0) [0|0] "" XXX - SG_ DrvRrCondSeatSftBttnSt : 47|3@0+ (1,0) [0|0] "" XXX - SG_ DrvFrCondSeatSftBtnStt : 37|3@0+ (1,0) [0|0] "" XXX - SG_ CC_RecircSBtn_St : 27|2@0+ (1,0) [0|0] "" XXX - SG_ CC_RrDefrSBtn_St : 24|1@0+ (1,0) [0|0] "" XXX - SG_ PasRrCondSeatSftBttnSt : 44|3@0+ (1,0) [0|0] "" XXX - SG_ PasFrCondSeatSftBtnStt : 34|3@0+ (1,0) [0|0] "" XXX - SG_ MyTemp_Soft_Bttn_State : 25|1@0+ (1,0) [0|0] "" XXX - SG_ CC_MaxACSBtn_St : 28|1@0+ (1,0) [0|0] "" XXX - SG_ RearPowerButtonState : 16|1@0+ (1,0) [0|0] "" XXX - SG_ RearCoolBarsDisplayed : 11|3@0+ (1,0) [0|0] "Bars_On" XXX - SG_ Rear_Sft_Control_Stat : 7|2@0+ (1,0) [0|0] "" XXX - SG_ CC_RrNeutralBarDsp_St : 8|1@0+ (1,0) [0|0] "" XXX - SG_ CC_RrHeatBarsDsp_St : 31|3@0+ (1,0) [0|0] "Bars_On" XXX - SG_ Rear_Fan_Bars_Displayed : 19|3@0+ (1,0) [0|0] "" XXX - SG_ CC_RrCtrlBtn_St : 20|1@0+ (1,0) [0|0] "" XXX - SG_ Rear_Auto_Button_State : 21|1@0+ (1,0) [0|0] "" XXX - SG_ CC_FrPowerSBtn_St : 14|1@0+ (1,0) [0|0] "" XXX - SG_ CC_FrDefrostSBtn_St : 15|1@0+ (1,0) [0|0] "" XXX - SG_ Front_AUTO_Soft_Btn_Stt : 13|1@0+ (1,0) [0|0] "" XXX - SG_ Front_AUTO_MODE_State : 1|1@0+ (1,0) [0|0] "" XXX - SG_ Front_AUTO_FAN_State : 0|1@0+ (1,0) [0|0] "" XXX - SG_ Dual_Button_State : 12|1@0+ (1,0) [0|0] "" XXX - SG_ CC_BarPnlSBtn_St : 5|1@0+ (1,0) [0|0] "" XXX - SG_ CC_BarPnFlrSBtn_St : 4|1@0+ (1,0) [0|0] "" XXX - SG_ CC_BarFlrWsSBtn_St : 2|1@0+ (1,0) [0|0] "" XXX - SG_ CC_BarDrvFlrSBtn_St : 3|1@0+ (1,0) [0|0] "" XXX - -BO_ 861 HSWheel_CC_Info_Stat: 8 XXX - SG_ HtdStrWhl_SftBtt_State : 57|2@0+ (1,0) [0|0] "" XXX - -BO_ 862 Climate_Control_Data_2: 8 XXX - SG_ HvacRec_Pc_Est : 31|7@0+ (1,0) [0|0] "%" XXX - SG_ HvacEngIdleInc_B_Rq : 24|1@0+ (1,0) [0|0] "" XXX - SG_ HvacAir_Flw_Est : 13|9@0+ (0.5,0) [0|0] "liter/second" XXX - SG_ AmbTempImpr : 7|10@0+ (0.25,-128.0) [0|0] "degreesC" XXX - -BO_ 900 Vehicle_Access_RqstM: 8 XXX - SG_ PE_AssocConfirm_D_Actl : 63|3@0+ (1,0) [0|0] "" XXX - SG_ DrTgateOpen_D_RqRfa : 51|2@0+ (1,0) [0|0] "" XXX - SG_ PE_Decklid_Inhibit_Rqst : 53|2@0+ (1,0) [0|0] "" XXX - SG_ PK_Program : 45|2@0+ (1,0) [0|0] "" XXX - SG_ PE_Packet_Cnt : 31|8@0+ (1,0) [0|0] "Counts" XXX - SG_ PE_Control_Status : 33|2@0+ (1,0) [0|0] "" XXX - SG_ PE_Control_Code : 7|8@0+ (1,0) [0|0] "" XXX - SG_ PE_Perimeter_Lighting_Stat : 15|2@0+ (1,0) [0|0] "" XXX - SG_ PE_RKE_Flash_Rqst : 34|1@0+ (1,0) [0|0] "" XXX - SG_ PE_Lock_EvNum : 23|8@0+ (1,0) [0|0] "Counts" XXX - SG_ PE_Lock_Requestor : 39|5@0+ (1,0) [0|0] "" XXX - SG_ PE_Lock_Sub_Id : 11|4@0+ (1,0) [0|0] "" XXX - SG_ PE_Lock_Status : 13|2@0+ (1,0) [0|0] "" XXX - SG_ PE_DrvCfg_Horn_Rqst : 47|2@0+ (1,0) [0|0] "" XXX - SG_ PEBackupSlot_Stats : 55|2@0+ (1,0) [0|0] "" XXX - SG_ PE_Fob_Number : 43|4@0+ (1,0) [0|0] "Number" XXX - SG_ PE_Keypad_LiftGlass_Rqst : 49|1@0+ (1,0) [0|0] "" XXX - -BO_ 901 Vehicle_Lock_Status: 8 XXX - SG_ CntrStkKeycodeActl : 55|16@0+ (1,0) [0|0] "" XXX - SG_ CntrStk_D_RqAssoc_UB : 40|1@0+ (1,0) [0|0] "" XXX - SG_ CntrStk_D_RqAssoc : 43|3@0+ (1,0) [0|0] "" XXX - SG_ KeyTypeChngMykey_D_Rq : 45|2@0+ (1,0) [0|0] "" XXX - SG_ Veh_Lock_Sub_Id : 21|4@0+ (1,0) [0|0] "" XXX - SG_ Veh_Lock_Status : 17|2@0+ (1,0) [0|0] "" XXX - SG_ Veh_Lock_Requestor : 39|5@0+ (1,0) [0|0] "" XXX - SG_ Veh_Lock_EvNum : 31|8@0+ (1,0) [0|0] "Counts" XXX - SG_ Trim_Switch_Status_Count : 15|8@0+ (1,0) [0|0] "Counts" XXX - SG_ Trim_Switch_Status : 23|2@0+ (1,0) [0|0] "" XXX - SG_ DF_KeyCyl_Switch_Stat_Cnt : 7|8@0+ (1,0) [0|0] "Counts" XXX - SG_ DF_KeyCyl_Switch_Stat : 34|2@0+ (1,0) [0|0] "" XXX - SG_ Perimeter_Alarm_Status : 47|2@0+ (1,0) [0|0] "" XXX - SG_ KeyTypeChngMykey_D_Rq_UB : 32|1@0+ (1,0) [0|0] "" XXX - -BO_ 902 Remote_Start: 8 XXX - SG_ Remote_Start_Req : 7|2@0+ (1,0) [0|0] "" XXX - -BO_ 903 CC_FCIM_Update: 8 XXX - SG_ Rr_Temp_M_H_Heat_Ind : 30|1@0+ (1,0) [0|0] "" XXX - SG_ Rr_Fan_7_Indicator : 45|1@0+ (1,0) [0|0] "" XXX - SG_ Rr_Fan_6_Indicator : 46|1@0+ (1,0) [0|0] "" XXX - SG_ Rr_Fan_5_Indicator : 47|1@0+ (1,0) [0|0] "" XXX - SG_ Rr_Fan_4_Indicator : 32|1@0+ (1,0) [0|0] "" XXX - SG_ Rr_Fan_3_Indicator : 33|1@0+ (1,0) [0|0] "" XXX - SG_ Rr_Fan_2_Indicator : 34|1@0+ (1,0) [0|0] "" XXX - SG_ Rr_Fan_Low_Indicator : 35|1@0+ (1,0) [0|0] "" XXX - SG_ AC_Indicator : 36|1@0+ (1,0) [0|0] "" XXX - SG_ Floor_Mode_Indicator : 37|1@0+ (1,0) [0|0] "" XXX - SG_ Panel_Mode_Indicator : 38|1@0+ (1,0) [0|0] "" XXX - SG_ Windshield_Mode_Indicator : 39|1@0+ (1,0) [0|0] "" XXX - SG_ Rr_Temp_High_Cool_Ind : 24|1@0+ (1,0) [0|0] "" XXX - SG_ Rr_Temp_M_H_Cool_Ind : 25|1@0+ (1,0) [0|0] "" XXX - SG_ Rr_Temp_M_L_Cool_Ind : 26|1@0+ (1,0) [0|0] "" XXX - SG_ Rr_Temp_Low_Cool_Ind : 27|1@0+ (1,0) [0|0] "" XXX - SG_ Rr_Temp_Center_Ind_On : 28|1@0+ (1,0) [0|0] "" XXX - SG_ Rr_Temp_High_Heat_Ind : 29|1@0+ (1,0) [0|0] "" XXX - SG_ Rr_Temp_M_L_Heat_Ind : 31|1@0+ (1,0) [0|0] "" XXX - SG_ Rr_Temp_Low_Heat_Ind : 16|1@0+ (1,0) [0|0] "" XXX - SG_ Rear_Control_Indicator : 17|1@0+ (1,0) [0|0] "" XXX - SG_ Auto_Indicator_Rear : 18|1@0+ (1,0) [0|0] "" XXX - SG_ Power_Indicator_Rear : 19|1@0+ (1,0) [0|0] "" XXX - SG_ Rt_Side_U_R_Seat_Cool_Ind : 20|1@0+ (1,0) [0|0] "" XXX - SG_ Rt_Side_M_Seat_Cool_Ind : 21|1@0+ (1,0) [0|0] "" XXX - SG_ Rt_Side_L_L_Seat_Cool_Ind : 22|1@0+ (1,0) [0|0] "" XXX - SG_ Rt_Side_U_R_Seat_Heat_Ind : 23|1@0+ (1,0) [0|0] "" XXX - SG_ Rt_Side_M_Seat_Heat_Ind : 8|1@0+ (1,0) [0|0] "" XXX - SG_ Rt_Side_L_L_Seat_Heat_Ind : 9|1@0+ (1,0) [0|0] "" XXX - SG_ Lft_Side_U_R_Seat_Cool_Ind : 10|1@0+ (1,0) [0|0] "" XXX - SG_ Lft_Side_M_Seat_Cool_Ind : 11|1@0+ (1,0) [0|0] "" XXX - SG_ Lft_Side_L_L_Seat_Cool_Ind : 12|1@0+ (1,0) [0|0] "" XXX - SG_ Lft_Side_U_R_Seat_Heat_Ind : 13|1@0+ (1,0) [0|0] "" XXX - SG_ Lft_Side_M_Seat_Heat_Ind : 14|1@0+ (1,0) [0|0] "" XXX - SG_ Lft_Side_L_L_Seat_Heat_Ind : 15|1@0+ (1,0) [0|0] "" XXX - SG_ Single_Mode_Indicator : 0|1@0+ (1,0) [0|0] "" XXX - SG_ Auto_Indicator : 1|1@0+ (1,0) [0|0] "" XXX - SG_ Recirc_Indicator : 2|1@0+ (1,0) [0|0] "" XXX - SG_ Max_AC_Econ_Indicator : 3|1@0+ (1,0) [0|0] "" XXX - SG_ Rear_DefHtd_Mirr_Indicator : 4|1@0+ (1,0) [0|0] "" XXX - SG_ Defrost_Indicator : 5|1@0+ (1,0) [0|0] "" XXX - SG_ Rt_Temp_Dual_Indicator : 6|1@0+ (1,0) [0|0] "" XXX - SG_ Power_Indicator_Front : 7|1@0+ (1,0) [0|0] "" XXX - -BO_ 904 CC_NavChassis_Info_Status: 8 XXX - SG_ Rear_Defrost_Soft_Bttn_Stt : 52|1@0+ (1,0) [0|0] "" XXX - SG_ Recirc_Soft_Button_State : 54|2@0+ (1,0) [0|0] "" XXX - SG_ Max_AC_Soft_Button_State : 55|1@0+ (1,0) [0|0] "" XXX - SG_ Front_AUTO_Soft_Btn_Stt : 24|1@0+ (1,0) [0|0] "" XXX - SG_ Front_Power_Soft_Btn_State : 25|1@0+ (1,0) [0|0] "" XXX - SG_ Front_Defrost_Soft_Btn_Stt : 26|1@0+ (1,0) [0|0] "" XXX - SG_ Rear_Power_Button_State : 33|1@0+ (1,0) [0|0] "" XXX - SG_ Front_AUTO_FAN_Indicator : 27|1@0+ (1,0) [0|0] "" XXX - SG_ Front_AUTO_MODE_Indicator : 28|1@0+ (1,0) [0|0] "" XXX - SG_ CC_Bar_Rear_Set_Temp_Display : 17|1@0+ (1,0) [0|0] "" XXX - SG_ CC_Bar_Rear_Set_Temp_Units : 19|2@0+ (1,0) [0|0] "" XXX - SG_ Rear_Heat_Bars_Displayed : 42|3@0+ (1,0) [0|0] "Bars_On" XXX - SG_ CC_Bar_Rear_Set_Temp_Dig3 : 21|2@0+ (1,0) [0|0] "" XXX - SG_ CC_Bar_Rear_Set_Temp_Dig2 : 15|8@0+ (1,0) [0|0] "ASCII" XXX - SG_ CC_Bar_Rear_Set_Temp_Dig1 : 7|8@0+ (1,0) [0|0] "ASCII" XXX - SG_ Rear_Neutral_Bar_Displayed : 43|1@0+ (1,0) [0|0] "" XXX - SG_ Rear_Fan_Bars_Displayed : 46|3@0+ (1,0) [0|0] "" XXX - SG_ Rear_Control_Button_State : 47|1@0+ (1,0) [0|0] "" XXX - SG_ Rear_Auto_Button_State : 32|1@0+ (1,0) [0|0] "" XXX - SG_ AC_Sft_Button_State : 35|2@0+ (1,0) [0|0] "" XXX - SG_ Rear_Cool_Bars_Displayed : 38|3@0+ (1,0) [0|0] "Bars_On" XXX - SG_ Dual_Button_State : 39|1@0+ (1,0) [0|0] "" XXX - SG_ CC_Bar_Sft_Btn_FlrWs_State : 29|1@0+ (1,0) [0|0] "" XXX - SG_ CC_Bar_Sft_Btn_Floor_State : 30|1@0+ (1,0) [0|0] "" XXX - SG_ CC_Bar_Sft_Btn_PnFlr_State : 31|1@0+ (1,0) [0|0] "" XXX - SG_ CC_Bar_Sft_Btn_Pnl_State : 16|1@0+ (1,0) [0|0] "" XXX - SG_ Rear_Sft_Control_Status : 23|2@0+ (1,0) [0|0] "" XXX - -BO_ 920 FCIM_CC_Status: 8 XXX - SG_ Manual_Temp_Knob_Pos : 8|9@0+ (1,0) [0|0] "Degrees CW" XXX - SG_ Manual_Blower_Knob_Pos : 24|9@0+ (1,0) [0|0] "Degrees CW" XXX - SG_ Rear_Blower_IncreaseButton : 40|1@0+ (1,0) [0|0] "" XXX - SG_ Rear_Blower_DecreaseButton : 55|1@0+ (1,0) [0|0] "" XXX - SG_ Rear_Temp_Decrease_Button : 41|1@0+ (1,0) [0|0] "" XXX - SG_ Rear_Temp_Increase_Button : 42|1@0+ (1,0) [0|0] "" XXX - SG_ Rear_Control_Button : 43|1@0+ (1,0) [0|0] "" XXX - SG_ Auto_Button_Rear : 44|1@0+ (1,0) [0|0] "" XXX - SG_ Power_Button_Rear : 45|1@0+ (1,0) [0|0] "" XXX - SG_ Rt_Side_Heated_Seat_Btn : 47|1@0+ (1,0) [0|0] "" XXX - SG_ Rt_Side_Cooled_Seat_Btn : 46|1@0+ (1,0) [0|0] "" XXX - SG_ Lft_Side_Cooled_Seat_Btn : 9|1@0+ (1,0) [0|0] "" XXX - SG_ Lft_Side_Heated_Seat_Btn : 10|1@0+ (1,0) [0|0] "" XXX - SG_ Blower_Decrease_Button : 25|1@0+ (1,0) [0|0] "" XXX - SG_ Blower_Increase_Button : 26|1@0+ (1,0) [0|0] "" XXX - SG_ Floor_Defrost_Mode_Button : 27|1@0+ (1,0) [0|0] "" XXX - SG_ Floor_Mode_Button : 28|1@0+ (1,0) [0|0] "" XXX - SG_ Panel_Floor_Mode_Button : 29|1@0+ (1,0) [0|0] "" XXX - SG_ Panel_Mode_Button : 30|1@0+ (1,0) [0|0] "" XXX - SG_ Mode_Change_Button : 31|1@0+ (1,0) [0|0] "" XXX - SG_ Rt_Side_Temp_Increase : 12|1@0+ (1,0) [0|0] "" XXX - SG_ Rt_Side_Temp_Decrease : 11|1@0+ (1,0) [0|0] "" XXX - SG_ Lft_Side_Temp_Decrease : 13|1@0+ (1,0) [0|0] "" XXX - SG_ Lft_Side_Temp_Increase : 14|1@0+ (1,0) [0|0] "" XXX - SG_ Auto_Button_Front : 15|1@0+ (1,0) [0|0] "" XXX - SG_ Recirc_Button : 0|1@0+ (1,0) [0|0] "" XXX - SG_ Max_AC_Econ_Button : 1|1@0+ (1,0) [0|0] "" XXX - SG_ AC_Button : 2|1@0+ (1,0) [0|0] "" XXX - SG_ Rr_Def_Htd_Mirr_Button : 3|1@0+ (1,0) [0|0] "" XXX - SG_ Front_Defrost_Button : 4|1@0+ (1,0) [0|0] "" XXX - SG_ Rt_Side_Temp_Dual_Button : 5|1@0+ (1,0) [0|0] "" XXX - SG_ Power_Button_Front : 6|1@0+ (1,0) [0|0] "" XXX - SG_ Climate_Button : 7|1@0+ (1,0) [0|0] "" XXX - SG_ CcdMde_D_Rq : 54|2@0+ (1,0) [0|0] "" XXX - -BO_ 921 Nav_CC_Status: 8 XXX - SG_ Front_System_Button_Status : 7|5@0+ (1,0) [0|0] "" XXX - SG_ Rear_Temp_Button_Status : 23|2@0+ (1,0) [0|0] "" XXX - SG_ Rear_Man_Temp_Bar_Status : 11|4@0+ (1,0) [0|0] "" XXX - SG_ Rear_Fan_Button_Status : 13|2@0+ (1,0) [0|0] "" XXX - SG_ Rear_Man_ATC_Button_Status : 15|2@0+ (1,0) [0|0] "" XXX - SG_ Rear_Blower_Bar_Status : 2|3@0+ (1,0) [0|0] "# of Bars" XXX - -BO_ 922 VoiceRec_CC_Request: 8 XXX - SG_ Recirculate_On : 10|1@0+ (1,0) [0|0] "" XXX - SG_ Recirculate_Off : 9|1@0+ (1,0) [0|0] "" XXX - SG_ Rear_Defrost_On : 12|1@0+ (1,0) [0|0] "" XXX - SG_ Rear_Defrost_Off : 11|1@0+ (1,0) [0|0] "" XXX - SG_ Max_AC_On : 0|1@0+ (1,0) [0|0] "" XXX - SG_ Max_AC_Off : 15|1@0+ (1,0) [0|0] "" XXX - SG_ Front_Defrost_On : 14|1@0+ (1,0) [0|0] "" XXX - SG_ Front_Defrost_Off : 13|1@0+ (1,0) [0|0] "" XXX - SG_ Front_Blower_Increment : 8|1@0+ (1,0) [0|0] "" XXX - SG_ Front_Blower_Decrement : 23|1@0+ (1,0) [0|0] "" XXX - SG_ Dual_Zone_Off : 5|1@0+ (1,0) [0|0] "" XXX - SG_ Driver_Temp_Increment : 22|1@0+ (1,0) [0|0] "" XXX - SG_ Driver_Temp_Decrement : 21|1@0+ (1,0) [0|0] "" XXX - SG_ Climate_On : 4|1@0+ (1,0) [0|0] "" XXX - SG_ Climate_Off : 3|1@0+ (1,0) [0|0] "" XXX - SG_ Automatic_Mode : 6|1@0+ (1,0) [0|0] "" XXX - SG_ AC_On : 2|1@0+ (1,0) [0|0] "" XXX - SG_ AC_Off : 1|1@0+ (1,0) [0|0] "" XXX - SG_ Voice_Blower_Limit : 7|1@0+ (1,0) [0|0] "" XXX - SG_ Driver_Set_Temp : 31|8@0+ (0.5,0) [0|0] "Degrees" XXX - -BO_ 928 Ignition_Switch_PositionM: 8 XXX - SG_ AirAmb_Te_ActlFilt_UB : 14|1@0+ (1,0) [0|0] "" XXX - SG_ AirAmb_Te_ActlFilt : 49|10@0+ (0.25,-128.0) [0|0] "deg C" XXX - SG_ OdometerMasterValue_UB : 15|1@0+ (1,0) [0|0] "" XXX - SG_ OdometerMasterValue : 31|24@0+ (1,0) [0|0] "km" XXX - SG_ Remote_Start_Status : 13|2@0+ (1,0) [0|0] "" XXX - SG_ Key_In_Ignition_Stat : 3|2@0+ (1,0) [0|0] "" XXX - SG_ Ignition_Switch_Stable : 1|2@0+ (1,0) [0|0] "" XXX - SG_ Ignition_Status : 7|4@0+ (1,0) [0|0] "" XXX - SG_ BOO_Switch_Status : 9|2@0+ (1,0) [0|0] "" XXX - SG_ Remote_Device_Feedback : 23|3@0+ (1,0) [0|0] "" XXX - -BO_ 934 Side_Detect_L_StatusM: 8 XXX - SG_ Cross_Traffic_L_SnState : 23|2@0+ (1,0) [0|0] "" XXX - SG_ SideDetect_L_SysOpState : 3|2@0+ (1,0) [0|0] "" XXX - SG_ SideDetect_L_SnsrState : 1|2@0+ (1,0) [0|0] "" XXX - SG_ Side_Detect_L_Illum : 15|8@0+ (1,0) [0|0] "%" XXX - SG_ Side_Detect_L_Detect : 7|2@0+ (1,0) [0|0] "" XXX - SG_ Cross_Traffic_L_Op_State : 21|2@0+ (1,0) [0|0] "" XXX - SG_ Cross_Traffic_L_Alert : 19|2@0+ (1,0) [0|0] "" XXX - SG_ Side_Detect_L_Alert : 5|2@0+ (1,0) [0|0] "" XXX - -BO_ 935 Side_Detect_R_StatusM: 8 XXX - SG_ Cross_Traffic_R_Alert : 23|2@0+ (1,0) [0|0] "" XXX - SG_ Cross_Traffic_R_SnState : 19|2@0+ (1,0) [0|0] "" XXX - SG_ Cross_Traffic_R_Op_State : 21|2@0+ (1,0) [0|0] "" XXX - SG_ Side_Detect_R_Detect : 7|2@0+ (1,0) [0|0] "" XXX - SG_ Side_Detect_R_Illum : 15|8@0+ (1,0) [0|0] "%" XXX - SG_ SideDetect_R_SnsrState : 1|2@0+ (1,0) [0|0] "" XXX - SG_ SideDetect_R_SysOpState : 3|2@0+ (1,0) [0|0] "" XXX - SG_ Side_Detect_R_Alert : 5|2@0+ (1,0) [0|0] "" XXX - -BO_ 944 Body_Information_6_MS: 8 XXX - SG_ DRV_SELECT_STAT : 3|4@0+ (1,0) [0|0] "" XXX - SG_ reserve_2bits : 7|2@0+ (1,0) [0|0] "" XXX - SG_ reserve_2 : 5|1@0+ (1,0) [0|0] "" XXX - SG_ reserve_3 : 4|1@0+ (1,0) [0|0] "" XXX - -BO_ 945 Ajar_Stat: 8 XXX - SG_ Decklid_Ajar_Status : 3|1@0+ (1,0) [0|0] "" XXX - SG_ Hood_Ajar_Status : 0|1@0+ (1,0) [0|0] "" XXX - SG_ LG_Glass_Ajar_Status : 2|1@0+ (1,0) [0|0] "" XXX - SG_ DF_Door_Ajar_Status : 7|1@0+ (1,0) [0|0] "" XXX - SG_ PF_Door_Ajar_Status : 6|1@0+ (1,0) [0|0] "" XXX - SG_ DR_Door_Ajar_Status : 5|1@0+ (1,0) [0|0] "" XXX - SG_ PR_Door_Ajar_Status : 4|1@0+ (1,0) [0|0] "" XXX - SG_ LG_Door_Ajar_Status : 1|1@0+ (1,0) [0|0] "" XXX - -BO_ 946 Body_Information_5_MS: 8 XXX - SG_ CoolantFanStepAct_UB : 8|1@0+ (1,0) [0|0] "" XXX - SG_ AirCondRec_B_Rq_UB : 38|1@0+ (1,0) [0|0] "" XXX - SG_ AirCondRec_B_Rq : 39|1@0+ (1,0) [0|0] "" XXX - SG_ AirCondEvdc_D_Stats_UB : 34|1@0+ (1,0) [0|0] "" XXX - SG_ AirCondEvdc_D_Stats : 37|3@0+ (1,0) [0|0] "" XXX - SG_ AirCondClutch_B_Stats_UB : 19|1@0+ (1,0) [0|0] "" XXX - SG_ AirCondClutch_B_Stats : 20|1@0+ (1,0) [0|0] "" XXX - SG_ CoolantFanStepAct : 47|5@0+ (1,0) [0|0] "Steps" XXX - SG_ AirCondFluidHi_P_Actl_UB : 18|1@0+ (1,0) [0|0] "" XXX - SG_ AirCondFluidHi_P_Actl : 31|8@0+ (0.125,0) [0|0] "bar" XXX - SG_ SECONDARY_HEATER_STAT_UB : 63|1@0+ (1,0) [0|0] "" XXX - SG_ CURRENT_DRAW_UB : 62|1@0+ (1,0) [0|0] "" XXX - SG_ SECONDARY_HEATER_STAT : 40|1@0+ (1,0) [0|0] "" XXX - SG_ CURRENT_DRAW : 55|8@0+ (0.5,0) [0|0] "Amps" XXX - -BO_ 947 BodyInformation_3_MS: 8 XXX - SG_ CamraDefog_B_Req_UB : 58|1@0+ (1,0) [0|0] "" XXX - SG_ TrStats_D_Actl_UB : 48|1@0+ (1,0) [0|0] "" XXX - SG_ RearFog_Lamp_Dbnce_UB : 49|1@0+ (1,0) [0|0] "" XXX - SG_ TrStats_D_Actl : 13|2@0+ (1,0) [0|0] "" XXX - SG_ CamraDefog_B_Req : 40|1@0+ (1,0) [0|0] "" XXX - SG_ RearFog_Lamp_Dbnce : 0|1@0+ (1,0) [0|0] "" XXX - SG_ CarMode : 53|4@0+ (1,0) [0|0] "" XXX - SG_ Day_Night_Status : 15|2@0+ (1,0) [0|0] "" XXX - SG_ Parklamp_Status : 3|2@0+ (1,0) [0|0] "" XXX - SG_ Dimming_Lvl : 31|8@0+ (1,0) [0|0] "" XXX - SG_ Litval : 23|8@0+ (1,0) [0|0] "" XXX - SG_ Mfs_Turn_Stalk_SW_Status : 11|2@0+ (1,0) [0|0] "" XXX - SG_ PwMdeExten_D_Actl : 63|5@0+ (1,0) [0|0] "" XXX - SG_ STR_WHL_ANGLE : 39|15@0+ (0.1,-1000.0) [0|0] "Degrees" XXX - SG_ Turn_Seq_Cmd_Right : 7|2@0+ (1,0) [0|0] "" XXX - SG_ Turn_Seq_Cmd_Left : 5|2@0+ (1,0) [0|0] "" XXX - SG_ Smart_Wiper_Motor_Stat_UB : 8|1@0+ (1,0) [0|0] "" XXX - SG_ Smart_Wiper_Motor_Stat : 55|2@0+ (1,0) [0|0] "" XXX - SG_ Mfs_Turn_Stalk_SW_Status_UB : 9|1@0+ (1,0) [0|0] "" XXX - SG_ reserve : 1|1@0+ (1,0) [0|0] "" XXX - -BO_ 950 RKE_Packet: 8 XXX - SG_ RemoteKey_Packet_TIC : 7|32@0+ (1,0) [0|0] "" XXX - SG_ RemoteKey_Packet_RollB : 55|8@0+ (1,0) [0|0] "" XXX - SG_ RemoteKey_Packet_RollA : 47|8@0+ (1,0) [0|0] "" XXX - SG_ RemoteKey_Packet_Ctrl : 39|8@0+ (1,0) [0|0] "" XXX - SG_ RemoteKey_Packet_CkSum : 63|8@0+ (1,0) [0|0] "" XXX - -BO_ 951 TPM_Frame: 8 XXX - SG_ TirePress_Frame_Temp : 47|8@0+ (1,0) [0|0] "" XXX - SG_ TirePress_Frame_Status : 55|8@0+ (1,0) [0|0] "" XXX - SG_ TirePress_Frame_Press : 39|8@0+ (1,0) [0|0] "" XXX - SG_ TirePress_Frame_ID : 7|32@0+ (1,0) [0|0] "" XXX - SG_ TirePress_Frame_CkSum : 63|8@0+ (1,0) [0|0] "" XXX - -BO_ 952 RKE_TPM_Info: 8 XXX - SG_ TirePress_HitRate_Ctrl : 15|1@0+ (1,0) [0|0] "" XXX - SG_ RemoteKey_HitRate_Ctrl : 14|1@0+ (1,0) [0|0] "" XXX - SG_ RemoteKey_Antenna_Ctrl : 7|2@0+ (1,0) [0|0] "" XXX - SG_ TirePress_Filter_Ctrl : 5|2@0+ (1,0) [0|0] "" XXX - SG_ RemoteKey_Filter_Ctrl : 3|2@0+ (1,0) [0|0] "" XXX - SG_ Modulation_Ctrl : 1|2@0+ (1,0) [0|0] "" XXX - -BO_ 953 RKE_Info: 8 XXX - SG_ RemoteKey_Info_TIC : 7|32@0+ (1,0) [0|0] "" XXX - SG_ RemoteKey_Info_RollB : 55|8@0+ (1,0) [0|0] "" XXX - SG_ RemoteKey_Info_RollA : 47|8@0+ (1,0) [0|0] "" XXX - SG_ RemoteKey_Info_Ctrl : 39|8@0+ (1,0) [0|0] "" XXX - SG_ RemoteKey_Info_CkSum : 63|8@0+ (1,0) [0|0] "" XXX - -BO_ 954 Tire_Pressure_Info: 8 XXX - SG_ TirePress_Info_MaxInd : 47|8@0+ (1,0) [0|0] "" XXX - SG_ TirePress_Info_Index : 39|8@0+ (1,0) [0|0] "" XXX - SG_ TirePress_Info_ID : 7|32@0+ (1,0) [0|0] "" XXX - -BO_ 956 Body_Information_7_MS: 8 XXX - SG_ GearLvrPos_D_Actl_UB : 21|1@0+ (1,0) [0|0] "" XXX - SG_ PrplWhlTot_Tq_Actl : 31|16@0+ (4.0,-131072.0) [0|0] "Nm" XXX - SG_ GearLvrPos_D_Actl : 7|4@0+ (1,0) [0|0] "" XXX - SG_ ApedPos_Pc_ActlArb : 15|10@0+ (0.1,0) [0|0] "%" XXX - SG_ PrplWhlTot_Tq_Actl_UB : 17|1@0+ (1,0) [0|0] "" XXX - SG_ EngOff_T_Actl : 47|16@0+ (1,0) [0|0] "seconds" XXX - SG_ ApedPos_Pc_ActlArb_UB : 20|1@0+ (1,0) [0|0] "" XXX - -BO_ 958 Rear_FoglampStat: 8 XXX - SG_ RearFog_Lamp_Ind : 7|1@0+ (1,0) [0|0] "" XXX - -BO_ 963 BCM_to_MS_Body: 8 XXX - SG_ LF_Low_Beam_CKT_CAN : 2|1@0+ (1,0) [0|0] "" XXX - SG_ IKT_Program_Status : 51|2@0+ (1,0) [0|0] "" XXX - SG_ Veh_Spd_Slow_Puddle_Status : 41|2@0+ (1,0) [0|0] "" XXX - SG_ Illuminated_Exit_Status : 43|2@0+ (1,0) [0|0] "" XXX - SG_ Illuminated_Entry_Status : 45|2@0+ (1,0) [0|0] "" XXX - SG_ Door_Courtesy_Light_Status : 47|2@0+ (1,0) [0|0] "" XXX - SG_ Courtesy_Demand_BSave_Stat : 33|2@0+ (1,0) [0|0] "" XXX - SG_ Alarm_Lights_Courtesy_Stat : 35|2@0+ (1,0) [0|0] "" XXX - SG_ Courtesy_Delay_Status : 37|2@0+ (1,0) [0|0] "" XXX - SG_ Courtesy_Mode_Status : 39|2@0+ (1,0) [0|0] "" XXX - SG_ Front_Fog_Light_SW_Status : 22|2@0+ (1,0) [0|0] "" XXX - SG_ Brake_Lamp_On_Status : 23|1@0+ (1,0) [0|0] "" XXX - SG_ ParkLamps_CKT_CAN : 8|1@0+ (1,0) [0|0] "" XXX - SG_ RF_Low_Beam_CKT_CAN : 13|1@0+ (1,0) [0|0] "" XXX - SG_ Brk_Fluid_Lvl_Low : 15|2@0+ (1,0) [0|0] "" XXX - SG_ Park_Brake_Status : 4|1@0+ (1,0) [0|0] "" XXX - SG_ High_Beam_Indicator_Rqst : 1|1@0+ (1,0) [0|0] "" XXX - SG_ Headlamp_On_Wrning_Cmd : 6|1@0+ (1,0) [0|0] "" XXX - SG_ Key_In_Ignition_Warn_Cmd : 5|1@0+ (1,0) [0|0] "" XXX - SG_ Park_Brake_Chime_Rqst : 3|1@0+ (1,0) [0|0] "" XXX - SG_ Daytime_Running_Lamps : 0|1@0+ (1,0) [0|0] "" XXX - SG_ AutoHighBeam_Cmd : 18|2@0+ (1,0) [0|0] "" XXX - SG_ Perimeter_Alarm_Chime_Rqst : 20|2@0+ (1,0) [0|0] "" XXX - SG_ OCSSensrDataUpperLim_UB : 11|1@0+ (1,0) [0|0] "" XXX - SG_ OCSSensrDataLowerLim_UB : 12|1@0+ (1,0) [0|0] "" XXX - SG_ OCSSensrDataUpperLim : 63|8@0+ (1,0) [0|0] "" XXX - SG_ OCSSensrDataLowerLim : 31|8@0+ (1,0) [0|0] "" XXX - SG_ AutoHighBeam_Cmd_UB : 16|1@0+ (1,0) [0|0] "" XXX - SG_ PrkBrkActv_B_Actl : 7|1@0+ (1,0) [0|0] "" XXX - SG_ Headlamp_Switch_Stat : 49|2@0+ (1,0) [0|0] "" XXX - SG_ Perimeter_Alarm_Inclin_Cmd : 53|2@0+ (1,0) [0|0] "" XXX - SG_ Perimeter_Alarm_Intrus_Cmd : 55|2@0+ (1,0) [0|0] "" XXX - -BO_ 964 BodyInformation_2_MS: 8 XXX - SG_ LockInhibit : 41|1@0+ (1,0) [0|0] "" XXX - SG_ MetricActvTe_B_Actl_UB : 12|1@0+ (1,0) [0|0] "" XXX - SG_ MetricActvTe_B_Actl : 14|1@0+ (1,0) [0|0] "" XXX - SG_ Power_Liftgate_Mode_Cmd : 42|1@0+ (1,0) [0|0] "" XXX - SG_ AirAmb_Te_Actl : 55|10@0+ (0.25,-128.0) [0|0] "degC" XXX - SG_ EngClntTe_D_Qf : 47|2@0+ (1,0) [0|0] "" XXX - SG_ Cross_Traffic_Cmd : 26|2@0+ (1,0) [0|0] "" XXX - SG_ Side_Detect_Cmd : 28|2@0+ (1,0) [0|0] "" XXX - SG_ SAPPStatusCoding : 39|8@0+ (1,0) [0|0] "" XXX - SG_ Delay_Accy : 31|1@0+ (1,0) [0|0] "" XXX - SG_ Volume_Cutback : 7|1@0+ (1,0) [0|0] "" XXX - SG_ MetricActv_B_Actl : 0|1@0+ (1,0) [0|0] "" XXX - SG_ DrStatTgate_B_Actl : 1|1@0+ (1,0) [0|0] "" XXX - SG_ DrStatRr_B_Actl : 2|1@0+ (1,0) [0|0] "" XXX - SG_ DrStatRl_B_Actl : 3|1@0+ (1,0) [0|0] "" XXX - SG_ DrStatPsngr_B_Actl : 4|1@0+ (1,0) [0|0] "" XXX - SG_ DrStatInnrTgate_B_Actl : 5|1@0+ (1,0) [0|0] "" XXX - SG_ DrStatHood_B_Actl : 6|1@0+ (1,0) [0|0] "" XXX - SG_ DrStatDrv_B_Actl : 10|1@0+ (1,0) [0|0] "" XXX - SG_ EngClnt_Te_Actl : 23|8@0+ (1,-60.0) [0|0] "degC" XXX - SG_ AirAmbTe_D_Qf_UB : 59|1@0+ (1,0) [0|0] "" XXX - SG_ Volume_Cutback_UB : 58|1@0+ (1,0) [0|0] "" XXX - SG_ Side_Detect_Cmd_UB : 57|1@0+ (1,0) [0|0] "" XXX - SG_ SAPPStatusCoding_UB : 56|1@0+ (1,0) [0|0] "" XXX - SG_ Power_Liftgate_Mode_Cmd_UB : 15|1@0+ (1,0) [0|0] "" XXX - SG_ MetricActv_B_Actl_UB : 13|1@0+ (1,0) [0|0] "" XXX - SG_ Cross_Traffic_Cmd_UB : 11|1@0+ (1,0) [0|0] "" XXX - SG_ AirAmbTe_D_Qf : 61|2@0+ (1,0) [0|0] "" XXX - SG_ AirAmb_Te_Actl_UB : 40|1@0+ (1,0) [0|0] "" XXX - SG_ EngClnt_Te_Actl_UB : 24|1@0+ (1,0) [0|0] "" XXX - -BO_ 966 Delay_AccyM_for_P473: 8 XXX - SG_ Delay_Accy : 7|1@0+ (1,0) [0|0] "" XXX - -BO_ 967 CMPS_FDM_Info_StatusMS: 8 XXX - SG_ Segment_MSD_UB : 37|1@0+ (1,0) [0|0] "" XXX - SG_ Segment_LSD_UB : 36|1@0+ (1,0) [0|0] "" XXX - SG_ Compass_Display_UB : 35|1@0+ (1,0) [0|0] "" XXX - SG_ Segment_LSD : 15|8@0+ (1,0) [0|0] "" XXX - SG_ Segment_MSD : 7|8@0+ (1,0) [0|0] "" XXX - SG_ Cal_Icon : 21|1@0+ (1,0) [0|0] "" XXX - SG_ Zone_Icon : 22|1@0+ (1,0) [0|0] "" XXX - SG_ Compass_Display : 23|1@0+ (1,0) [0|0] "" XXX - SG_ Zone_Icon_UB : 34|1@0+ (1,0) [0|0] "" XXX - SG_ Cal_Icon_UB : 33|1@0+ (1,0) [0|0] "" XXX - -BO_ 968 EATC_FDM_Info_Status: 8 XXX - SG_ Outside_Rear_Temp_Digit3 : 47|4@0+ (1,0) [0|0] "BCD" XXX - SG_ Outside_Rear_Temp_Digit2 : 35|4@0+ (1,0) [0|0] "BCD" XXX - SG_ Outside_Rear_Temp_Digit1 : 39|4@0+ (1,0) [0|0] "BCD" XXX - SG_ EATC_Out_Rear_Units : 58|2@0+ (1,0) [0|0] "" XXX - SG_ Outside_Rear_Temp_Digit4 : 55|2@0+ (1,0) [0|0] "" XXX - SG_ EATC_RHS_Units : 60|2@0+ (1,0) [0|0] "" XXX - SG_ EATC_Fan_Speed : 51|3@0+ (1,0) [0|0] "" XXX - SG_ EATC_Outside_Rear_Display : 62|2@0+ (1,0) [0|0] "" XXX - SG_ RHS_Temp_Display_Digit2 : 31|8@0+ (1,0) [0|0] "ASCII" XXX - SG_ RHS_Temp_Display_Digit3 : 41|2@0+ (1,0) [0|0] "" XXX - SG_ RHS_Temp_Display_Digit1 : 23|8@0+ (1,0) [0|0] "ASCII" XXX - SG_ EATC_RHS_Display : 63|1@0+ (1,0) [0|0] "" XXX - SG_ LHS_Temp_Display_Digit3 : 43|2@0+ (1,0) [0|0] "" XXX - SG_ LHS_Temp_Display_Digit2 : 15|8@0+ (1,0) [0|0] "ASCII" XXX - SG_ LHS_Temp_Display_Digit1 : 7|8@0+ (1,0) [0|0] "ASCII" XXX - SG_ EATC_LHS_Display : 48|1@0+ (1,0) [0|0] "" XXX - SG_ EATC_LHS_Units : 53|2@0+ (1,0) [0|0] "" XXX - -BO_ 969 Aux_Body_Ctrl_Mod_Status: 8 XXX - SG_ Perimeter_Alrm_Intrus_Stat : 7|2@0+ (1,0) [0|0] "" XXX - SG_ Turn_Outage_Stat_Rt_Rear : 15|2@0+ (1,0) [0|0] "" XXX - SG_ Turn_Outage_Stat_Left_Rear : 1|2@0+ (1,0) [0|0] "" XXX - SG_ Perimeter_Alrm_Inclin_Stat : 5|2@0+ (1,0) [0|0] "" XXX - -BO_ 976 Veh_Characteristic_Set_2: 8 XXX - SG_ VehMykey_Vl_LimRq_UB : 8|1@0+ (1,0) [0|0] "" XXX - SG_ CamraFrntStat_D_Stat : 21|2@0+ (1,0) [0|0] "" XXX - SG_ CamraZoomMan_D_Actl : 12|3@0+ (1,0) [0|0] "" XXX - SG_ CamZoomActiveState : 17|2@0+ (1,0) [0|0] "" XXX - SG_ CamraOvrlStat_D_Actl : 19|2@0+ (1,0) [0|0] "" XXX - SG_ CamraOvrlDyn_D_Actl : 39|2@0+ (1,0) [0|0] "" XXX - SG_ CamPDCGuidStat : 31|2@0+ (1,0) [0|0] "" XXX - SG_ VehMykey_Vl_LimRq : 14|1@0+ (1,0) [0|0] "" XXX - SG_ IgnKeyType_D_Actl : 4|4@0+ (1,0) [0|0] "" XXX - SG_ New_Module_Attn_Event : 0|1@0+ (1,0) [0|0] "" XXX - SG_ Beltminder_Warn_Stats : 9|1@0+ (1,0) [0|0] "" XXX - SG_ Attn_Info_Audio : 7|3@0+ (1,0) [0|0] "" XXX - -BO_ 977 ClmtCtrlSeat_SetCmd_LRPM: 8 XXX - SG_ ClmtCtrlSeat_SetCmd_LRP : 7|8@0+ (1,0) [0|0] "" XXX - -BO_ 978 ClmtCtrlSeat_SetStat_LRPM: 8 XXX - SG_ ClmtCtrlSeat_SetStat_LRP : 7|8@0+ (1,0) [0|0] "" XXX - -BO_ 979 ClmtCtrlSeat_SetCmd_RRPM: 8 XXX - SG_ ClmtCtrlSeat_SetCmd_RRP : 7|8@0+ (1,0) [0|0] "" XXX - -BO_ 980 ClmtCtrlSeat_SetStat_RRPM: 8 XXX - SG_ ClmtCtrlSeat_SetStat_RRP : 7|8@0+ (1,0) [0|0] "" XXX - -BO_ 981 Rear_HVAC_Control_Status: 8 XXX - SG_ Temp_Knob_Position : 23|9@0+ (1,0) [0|0] "Degrees CW" XXX - SG_ Rear_Lock_Ind_State : 13|1@0+ (1,0) [0|0] "" XXX - SG_ Blower_Knob_Position : 7|9@0+ (1,0) [0|0] "Degrees CW" XXX - SG_ AUTO_Ind_State : 12|1@0+ (1,0) [0|0] "" XXX - SG_ Panel_Mode_Ind_State : 11|1@0+ (1,0) [0|0] "" XXX - SG_ Panel_Floor_Md_Ind_State : 10|2@0+ (1,0) [0|0] "" XXX - SG_ Floor_Mode_Ind_State : 8|1@0+ (1,0) [0|0] "" XXX - SG_ Power_Status : 14|1@0+ (1,0) [0|0] "" XXX - -BO_ 982 Rear_HVAC_Control_Update: 8 XXX - SG_ Power_State_Commanded : 7|2@0+ (1,0) [0|0] "" XXX - SG_ Rear_Lock_Indicator : 15|1@0+ (1,0) [0|0] "" XXX - SG_ Panel_Floor_Mode_Indicator : 4|2@0+ (1,0) [0|0] "" XXX - SG_ R_Floor_Mode_Indicator : 2|1@0+ (1,0) [0|0] "" XXX - SG_ AUTO_Mode_Indicator : 1|2@0+ (1,0) [0|0] "" XXX - SG_ F_Panel_Mode_Indicator : 13|1@0+ (1,0) [0|0] "" XXX - SG_ R_Panel_Mode_Indicator : 12|2@0+ (1,0) [0|0] "" XXX - -BO_ 986 Personality_APIM_Data3_MS: 8 XXX - SG_ LightAmbIntSwtchInc_B : 22|1@0+ (1,0) [0|0] "" XXX - SG_ LightAmbIntSwtchDec_B : 21|1@0+ (1,0) [0|0] "" XXX - SG_ LightAmbIntsty_No_Rq : 15|8@0+ (1,0) [0|0] "% Intensity" XXX - SG_ LightAmbColor_No_Rq : 7|8@0+ (1,0) [0|0] "Color Index" XXX - SG_ LightAmbClrSwtchInc_B : 20|1@0+ (1,0) [0|0] "" XXX - SG_ LightAmbClrSwtchDec_B : 23|1@0+ (1,0) [0|0] "" XXX - -BO_ 987 RHVAC_Data: 8 XXX - SG_ CamraDefog_B_Actl : 7|1@0+ (1,0) [0|0] "" XXX - -BO_ 992 Personality_Data_MS: 8 XXX - SG_ PersSetupRestr_D_Actl : 45|2@0+ (1,0) [0|0] "" XXX - SG_ PersSetupAccessCtrl : 43|1@0+ (1,0) [0|0] "SES" XXX - SG_ PersSetup_No_Actl : 55|16@0+ (1,0) [0|0] "Number" XXX - SG_ MsgCntrPersIndex_D_Rq_UB : 47|1@0+ (1,0) [0|0] "" XXX - SG_ MsgCntrFeatNoRq_UB : 46|1@0+ (1,0) [0|0] "" XXX - SG_ MsgCntrFeatConfigRq_UB : 33|1@0+ (1,0) [0|0] "" XXX - SG_ MsgCntrDsplyOp_D_Rq_UB : 32|1@0+ (1,0) [0|0] "" XXX - SG_ MsgCntrPersIndex_D_Rq : 39|3@0+ (1,0) [0|0] "" XXX - SG_ MsgCntrFeatConfigRq : 23|16@0+ (1,0) [0|0] "" XXX - SG_ MsgCntrFeatNoRq : 7|16@0+ (1,0) [0|0] "Number" XXX - SG_ MsgCntrDsplyOp_D_Rq : 36|3@0+ (1,0) [0|0] "" XXX - -BO_ 993 Personality_DSM_Data: 8 XXX - SG_ PersIndexDsm_D_Actl : 47|3@0+ (1,0) [0|0] "" XXX - SG_ FeatNoDsmActl : 31|16@0+ (1,0) [0|0] "Number" XXX - SG_ FeatConfigDsmActl : 15|16@0+ (1,0) [0|0] "" XXX - SG_ PersStore_D_Actl : 7|2@0+ (1,0) [0|0] "" XXX - SG_ MemSwtch_D_RqRecall : 5|3@0+ (1,0) [0|0] "" XXX - SG_ MemSwtch_D_RqAssoc : 2|3@0+ (1,0) [0|0] "" XXX - -BO_ 994 Personality_Data_MS_2: 8 XXX - SG_ RecallEvent_No_Cnt : 63|8@0+ (1,0) [0|0] "Counts" XXX - SG_ PersNo_D_Actl : 55|3@0+ (1,0) [0|0] "" XXX - SG_ PersNoPos_D_Actl : 44|3@0+ (1,0) [0|0] "" XXX - SG_ PersStore_D_Rq_UB : 41|1@0+ (1,0) [0|0] "" XXX - SG_ CtrStkPersIndex_D_Actl_UB : 40|1@0+ (1,0) [0|0] "" XXX - SG_ CtrStkFeatNoActl_UB : 52|1@0+ (1,0) [0|0] "" XXX - SG_ CtrStkFeatConfigActl_UB : 33|1@0+ (1,0) [0|0] "" XXX - SG_ CtrStkDsplyOp_D_Rq_UB : 32|1@0+ (1,0) [0|0] "" XXX - SG_ CtrStkPersIndex_D_Actl : 39|3@0+ (1,0) [0|0] "" XXX - SG_ CtrStkFeatNoActl : 23|16@0+ (1,0) [0|0] "" XXX - SG_ PersStore_D_Rq : 36|3@0+ (1,0) [0|0] "" XXX - SG_ CtrStkFeatConfigActl : 7|16@0+ (1,0) [0|0] "" XXX - SG_ CtrStkDsplyOp_D_Rq : 47|3@0+ (1,0) [0|0] "" XXX - -BO_ 996 Personality_HCMB_Data: 8 XXX - SG_ PersIndexHcmb_D_Actl : 39|3@0+ (1,0) [0|0] "" XXX - SG_ FeatNoHcmbActl : 23|16@0+ (1,0) [0|0] "Number" XXX - SG_ FeatConfigHcmbActl : 7|16@0+ (1,0) [0|0] "" XXX - -BO_ 999 Personality_HVAC_Data: 8 XXX - SG_ LightAmbIntsty_No_Actl : 55|8@0+ (1,0) [0|0] "% Intensity" XXX - SG_ LightAmbColor_No_Actl : 47|8@0+ (1,0) [0|0] "Color Index" XXX - SG_ PersIndexHvac_D_Actl : 39|3@0+ (1,0) [0|0] "" XXX - SG_ FeatNoHvacActl : 23|16@0+ (1,0) [0|0] "Number" XXX - SG_ FeatConfigHvacActl : 7|16@0+ (1,0) [0|0] "" XXX - -BO_ 1000 ACM_Status_Message: 8 XXX - SG_ Multimedia_System : 26|1@0+ (1,0) [0|0] "" XXX - -BO_ 1001 Personality_RFA_Data: 8 XXX - SG_ PersIndexRfa_D_Actl : 39|3@0+ (1,0) [0|0] "" XXX - SG_ FeatNoRfaActl : 23|16@0+ (1,0) [0|0] "Number" XXX - SG_ FeatConfigRfaActl : 7|16@0+ (1,0) [0|0] "" XXX - -BO_ 1005 Personality_RHVAC_Data: 8 XXX - SG_ PersIndexRhvac_D_Actl : 39|3@0+ (1,0) [0|0] "" XXX - SG_ FeatNoRhvacActl : 23|16@0+ (1,0) [0|0] "Number" XXX - SG_ FeatConfigRhvacActl : 7|16@0+ (1,0) [0|0] "" XXX - -BO_ 1006 Nav_HMI_Status: 8 XXX - SG_ Nav_Unit_Setting : 14|1@0+ (1,0) [0|0] "" XXX - SG_ Fuel_Econ_AFE_Reset_Req : 15|1@0+ (1,0) [0|0] "" XXX - SG_ DistanceBarSetting : 23|1@0+ (1,0) [0|0] "" XXX - SG_ CamraZoomMan_D_Rq : 22|3@0+ (1,0) [0|0] "" XXX - SG_ CamraOvrlStat_D_Rq : 19|1@0+ (1,0) [0|0] "" XXX - SG_ CamraOvrlDyn_D_Rq : 18|1@0+ (1,0) [0|0] "" XXX - SG_ CamAutoTowbarZoom : 17|1@0+ (1,0) [0|0] "" XXX - -BO_ 1023 Reserve_3FF_MKX_Audio: 8 XXX - SG_ reserve : 7|1@0+ (1,0) [0|0] "" XXX - -BO_ 1034 GGCC_Config_Mgmt_ID_1: 8 XXX - SG_ VehicleGGCCData : 7|64@0+ (1,0) [0|0] "mixed" XXX - -BO_ 1050 Climate_Control_Data: 8 XXX - SG_ SecondaryHeater_Rqst : 31|1@0+ (1,0) [0|0] "" XXX - SG_ Passenger_Sunload_Raw : 15|8@0+ (5.0,0) [0|0] "W/m^2" XXX - SG_ Driver_Sunload_Raw : 7|8@0+ (5.0,0) [0|0] "W/m^2" XXX - SG_ HvacEvap_Te_Rq : 43|10@0+ (0.125,-50.0) [0|0] "Degrees C" XXX - SG_ HvacRemoteStrt_N_Rq : 47|4@0+ (100.0,450.0) [0|0] "RPM" XXX - SG_ Remote_Start_QuietMode : 28|1@0+ (1,0) [0|0] "" XXX - SG_ InCarTempQF : 30|2@0+ (1,0) [0|0] "" XXX - SG_ HvacAirCond_B_Rq : 27|1@0+ (1,0) [0|0] "" XXX - SG_ InCarTemp : 39|8@0+ (0.5,-57.0) [0|0] "degreesC" XXX - SG_ Outside_Air_Temp_Stat : 23|8@0+ (0.5,-40.0) [0|0] "Degrees C" XXX - SG_ HvacEvap_Te_Actl : 49|10@0+ (0.125,-50.0) [0|0] "Degrees C" XXX - -BO_ 1059 Engine_Data_MS: 8 XXX - SG_ Res_UreaLvlLo_B_Dsply_UB : 35|1@0+ (1,0) [0|0] "" XXX - SG_ Res_UreaLvlLo_B_Dsply : 36|1@0+ (1,0) [0|0] "" XXX - SG_ Fuel_Level_State : 47|2@0+ (1,0) [0|0] "" XXX - SG_ AwdOffRoadMode_D_Stats_UB : 55|1@0+ (1,0) [0|0] "" XXX - SG_ AwdRnge_D_Actl_UB : 42|1@0+ (1,0) [0|0] "" XXX - SG_ RearDiffLckLamp_D_Rq_UB : 32|1@0+ (1,0) [0|0] "" XXX - SG_ AwdOffRoadMode_D_Stats : 41|2@0+ (1,0) [0|0] "" XXX - SG_ AwdRnge_D_Actl : 45|3@0+ (1,0) [0|0] "" XXX - SG_ RearDiffLckLamp_D_Rq : 34|2@0+ (1,0) [0|0] "" XXX - SG_ VEH_SPD : 7|16@0+ (0.01,-100.0) [0|0] "KPH" XXX - SG_ ENG_SPD : 23|16@0+ (0.25,0) [0|0] "RPM" XXX - SG_ Fuel_Level_State_UB : 37|1@0+ (1,0) [0|0] "" XXX - -BO_ 1061 Engine_Data_2_MS: 8 XXX - SG_ RstrnImpactEvntStatus_UB : 56|1@0+ (1,0) [0|0] "" XXX - SG_ EngAirIn_Te_Actl_UB : 60|1@0+ (1,0) [0|0] "" XXX - SG_ EngAirIn_Te_Actl : 55|10@0+ (0.25,-128.0) [0|0] "degC" XXX - SG_ ACCompressorDisp_UB : 61|1@0+ (1,0) [0|0] "" XXX - SG_ ACCompressorDisp : 46|7@0+ (1,0) [0|0] "%" XXX - SG_ RstrnImpactEvntStatus : 59|3@0+ (1,0) [0|0] "" XXX - SG_ EngAout_N_Actl_UB : 47|1@0+ (1,0) [0|0] "" XXX - SG_ EngAout_N_Actl : 28|13@0+ (2.0,0) [0|0] "rpm" XXX - SG_ VehVActlEng_D_Qf : 31|2@0+ (1,0) [0|0] "" XXX - SG_ Veh_V_ActlEng_UB : 29|1@0+ (1,0) [0|0] "" XXX - SG_ Veh_V_ActlEng : 15|16@0+ (0.01,0) [0|0] "kph" XXX - SG_ PwPck_D_Stat_UB : 3|1@0+ (1,0) [0|0] "" XXX - SG_ PwPck_D_Stat : 7|4@0+ (1,0) [0|0] "" XXX - -BO_ 1062 ACM_NAV_WHEEL_INFO: 8 XXX - SG_ WhlRotatRr_No_Cnt_UB : 63|1@0+ (1,0) [0|0] "" XXX - SG_ WhlRotatRl_No_Cnt_UB : 40|1@0+ (1,0) [0|0] "" XXX - SG_ WhlRotatFr_No_Cnt_UB : 41|1@0+ (1,0) [0|0] "" XXX - SG_ WhlRotatFl_No_Cnt_UB : 42|1@0+ (1,0) [0|0] "" XXX - SG_ WhlDirRr_D_Actl_UB : 44|1@0+ (1,0) [0|0] "" XXX - SG_ WhlDirRl_D_Actl_UB : 45|1@0+ (1,0) [0|0] "" XXX - SG_ WhlDirFr_D_Actl_UB : 46|1@0+ (1,0) [0|0] "" XXX - SG_ WhlDirFl_D_Actl_UB : 47|1@0+ (1,0) [0|0] "" XXX - SG_ WHEEL_ROLLING_TIMESTAMP_UB : 62|1@0+ (1,0) [0|0] "" XXX - SG_ ACM_NAV_WHEEL_INFO_RESET : 43|1@0+ (1,0) [0|0] "" XXX - SG_ WhlRotatRr_No_Cnt : 39|8@0+ (1,0) [0|0] "" XXX - SG_ WhlRotatRl_No_Cnt : 31|8@0+ (1,0) [0|0] "" XXX - SG_ WhlRotatFr_No_Cnt : 23|8@0+ (1,0) [0|0] "" XXX - SG_ WhlRotatFl_No_Cnt : 15|8@0+ (1,0) [0|0] "" XXX - SG_ WhlDirRr_D_Actl : 1|2@0+ (1,0) [0|0] "" XXX - SG_ WhlDirRl_D_Actl : 3|2@0+ (1,0) [0|0] "" XXX - SG_ WhlDirFr_D_Actl : 5|2@0+ (1,0) [0|0] "" XXX - SG_ WhlDirFl_D_Actl : 7|2@0+ (1,0) [0|0] "" XXX - SG_ WHEEL_ROLLING_TIMESTAMP : 55|8@0+ (1,0) [0|0] "" XXX - -BO_ 1068 Battery_Mgmt_2_MS: 8 XXX - SG_ Shed_T_Eng_Off_B : 12|1@0+ (1,0) [0|0] "" XXX - SG_ Shed_Level_Req : 15|3@0+ (1,0) [0|0] "" XXX - SG_ Shed_Feature_Group_ID : 7|5@0+ (1,0) [0|0] "" XXX - SG_ Shed_Drain_Eng_Off_B : 2|1@0+ (1,0) [0|0] "" XXX - SG_ Batt_Lo_SoC_B : 1|1@0+ (1,0) [0|0] "" XXX - SG_ Batt_Crit_SoC_B : 0|1@0+ (1,0) [0|0] "" XXX - -BO_ 1125 GPS_Data_Nav_1: 8 XXX - SG_ GpsHsphLattSth_D_Actl : 25|2@0+ (1,0) [0|0] "" XXX - SG_ GpsHsphLongEast_D_Actl : 9|2@0+ (1,0) [0|0] "" XXX - SG_ GPS_Longitude_Minutes : 46|6@0+ (1,0) [0|0] "Minutes" XXX - SG_ GPS_Longitude_Min_dec : 55|14@0+ (0.0001,0) [0|0] "Minutes" XXX - SG_ GPS_Longitude_Degrees : 39|9@0+ (1,-179.0) [0|0] "Degrees" XXX - SG_ GPS_Latitude_Minutes : 15|6@0+ (1,0) [0|0] "Minutes" XXX - SG_ GPS_Latitude_Min_dec : 23|14@0+ (0.0001,0) [0|0] "Minutes" XXX - SG_ GPS_Latitude_Degrees : 7|8@0+ (1,-89.0) [0|0] "Degrees" XXX - -BO_ 1126 GPS_Data_Nav_2: 8 XXX - SG_ Gps_B_Falt : 2|1@0+ (1,0) [0|0] "" XXX - SG_ GpsUtcYr_No_Actl : 55|5@0+ (1,1.0) [0|0] "Year" XXX - SG_ GpsUtcMnth_No_Actl : 47|4@0+ (1,1.0) [0|0] "Month" XXX - SG_ GpsUtcDay_No_Actl : 37|5@0+ (1,1.0) [0|0] "Day" XXX - SG_ GPS_UTC_seconds : 23|6@0+ (1,0) [0|0] "seconds" XXX - SG_ GPS_UTC_minutes : 15|6@0+ (1,0) [0|0] "Minutes" XXX - SG_ GPS_UTC_hours : 7|5@0+ (1,0) [0|0] "Hours" XXX - SG_ GPS_Pdop : 31|5@0+ (0.2,0) [0|0] "" XXX - SG_ GPS_Compass_direction : 26|4@0+ (1,0) [0|0] "" XXX - SG_ GPS_Actual_vs_Infer_pos : 38|1@0+ (1,0) [0|0] "" XXX - -BO_ 1127 GPS_Data_Nav_3: 8 XXX - SG_ GPS_Vdop : 63|5@0+ (0.2,0) [0|0] "" XXX - SG_ GPS_Speed : 47|8@0+ (1,0) [0|0] "MPH" XXX - SG_ GPS_Sat_num_in_view : 7|5@0+ (1,0) [0|0] "" XXX - SG_ GPS_MSL_altitude : 15|12@0+ (10.0,-20460.0) [0|0] "feet" XXX - SG_ GPS_Heading : 31|16@0+ (0.01,0) [0|0] "Degrees" XXX - SG_ GPS_Hdop : 55|5@0+ (0.2,0) [0|0] "" XXX - SG_ GPS_dimension : 2|3@0+ (1,0) [0|0] "" XXX - -BO_ 1144 GPS_Data_Nav_4: 8 XXX - SG_ VehPos_L_Est : 39|32@0+ (0.01,0) [0|0] "meter" XXX - SG_ VehHead_W_Actl : 23|16@0+ (0.01,-327.68) [0|0] "degrees/second" XXX - SG_ VehHead_An_Est : 7|16@0+ (0.01,0) [0|0] "degrees" XXX diff --git a/opendbc/ford_cgea1_2_ptcan_2011.dbc b/opendbc/ford_cgea1_2_ptcan_2011.dbc deleted file mode 100644 index 128721cbbf7628..00000000000000 --- a/opendbc/ford_cgea1_2_ptcan_2011.dbc +++ /dev/null @@ -1,1487 +0,0 @@ -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_ 65 Global_PATS_Control_Info: 8 XXX - SG_ immoControlData_T1 : 15|40@0+ (1,0) [0|0] "" XXX - SG_ immoControlCmd_T1 : 7|3@0+ (1,0) [0|0] "" XXX - -BO_ 66 Global_PATS_Control_Info2: 8 XXX - SG_ immoControlData_T2 : 15|40@0+ (1,0) [0|0] "" XXX - SG_ immoControlCmd_T2 : 7|3@0+ (1,0) [0|0] "" XXX - -BO_ 71 Global_PATS_Target_Info: 8 XXX - SG_ immoTarget1Status : 7|3@0+ (1,0) [0|0] "" XXX - SG_ immoTarget1Data : 15|40@0+ (1,0) [0|0] "" XXX - SG_ immoTarget1Cmd : 4|3@0+ (1,0) [0|0] "" XXX - -BO_ 72 Global_PATS_Target_Info_2: 8 XXX - SG_ immoTarget2Status : 7|3@0+ (1,0) [0|0] "" XXX - SG_ immoTarget2Data : 15|40@0+ (1,0) [0|0] "" XXX - SG_ immoTarget2Cmd : 4|3@0+ (1,0) [0|0] "" XXX - -BO_ 73 Global_PATS_SubTarget_FoE: 8 XXX - SG_ immoSubTarget1Data_T1 : 15|40@0+ (1,0) [0|0] "" XXX - SG_ immoSubTarget1Cmd_T1 : 7|3@0+ (1,0) [0|0] "" XXX - -BO_ 74 VehEmergencyData1: 8 XXX - SG_ VedsPasSideBag_D_Ltchd : 60|3@0+ (1,0) [0|0] "" XXX - SG_ VedsPasCrtnBag_D_Ltchd : 55|3@0+ (1,0) [0|0] "" XXX - SG_ VedsPasBelt_D_Ltchd : 52|3@0+ (1,0) [0|0] "" XXX - SG_ VedsPasBag_D_Ltchd : 47|3@0+ (1,0) [0|0] "" XXX - SG_ VedsMultiEvnt_D_Ltchd : 44|3@0+ (1,0) [0|0] "" XXX - SG_ VedsMaxDeltaV_D_Ltchd : 39|8@0+ (1,0) [0|0] "" XXX - SG_ VedsKneeBag_D_Ltchd : 63|3@0+ (1,0) [0|0] "" XXX - SG_ VedsEvntType_D_Ltchd : 31|3@0+ (1,0) [0|0] "" XXX - SG_ VedsEvntRoll_D_Ltchd : 28|3@0+ (1,0) [0|0] "" XXX - SG_ VedsDrvSideBag_D_Ltchd : 23|3@0+ (1,0) [0|0] "" XXX - SG_ VedsDrvCrtnBag_D_Ltchd : 20|3@0+ (1,0) [0|0] "" XXX - SG_ VedsDrvBelt_D_Ltchd : 15|3@0+ (1,0) [0|0] "" XXX - SG_ VedsDrvBag_D_Ltchd : 12|3@0+ (1,0) [0|0] "" XXX - SG_ eCallNotification : 2|2@0+ (1,0) [0|0] "" XXX - -BO_ 75 VehEmergencyData2: 8 XXX - SG_ VedsRw3rBckl_D_Ltchd : 39|3@0+ (1,0) [0|0] "" XXX - SG_ VedsRw3mBckl_D_Ltchd : 31|3@0+ (1,0) [0|0] "" XXX - SG_ VedsRw3lBckl_D_Ltchd : 28|3@0+ (1,0) [0|0] "" XXX - SG_ VedsRw2rBckl_D_Ltchd : 23|3@0+ (1,0) [0|0] "" XXX - SG_ VedsRw2mBckl_D_Ltchd : 20|3@0+ (1,0) [0|0] "" XXX - SG_ VedsRw2lBckl_D_Ltchd : 15|3@0+ (1,0) [0|0] "" XXX - SG_ VedsRw1PasChld_D_Ltchd : 12|3@0+ (1,0) [0|0] "" XXX - SG_ VedsRw1PasBckl_D_Ltchd : 7|3@0+ (1,0) [0|0] "" XXX - SG_ VedsRw1DrvBckl_D_Ltchd : 4|3@0+ (1,0) [0|0] "" XXX - SG_ VedsRw2rRib_D_Ltchd : 47|3@0+ (1,0) [0|0] "" XXX - SG_ VedsRw2lRib_D_Ltchd : 36|3@0+ (1,0) [0|0] "" XXX - -BO_ 116 BrakeSnData_2_CG1: 8 XXX - SG_ VehDynamicsSOS : 55|1@0+ (1,0) [0|0] "" XXX - SG_ AwdLck_Tq_RqMx : 27|12@0+ (1,0) [0|0] "Nm" XXX - SG_ AwdLck_Tq_RqMn : 23|12@0+ (1,0) [0|0] "Nm" XXX - SG_ SteWhlComp_An_Est : 7|15@0+ (0.1,-1600.0) [0|0] "deg" XXX - SG_ StopLamp_B_RqBrk : 8|1@0+ (1,0) [0|0] "" XXX - SG_ BrkTerrMdeChng_D_Rdy : 45|3@0+ (1,0) [0|0] "" XXX - SG_ BrkTerrMde_D_Actl : 42|3@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCompAnEst_D_Qf : 47|2@0+ (1,0) [0|0] "" XXX - -BO_ 117 BrakeSnData_3_CG1: 8 XXX - SG_ HsaStat_D_Dsply : 35|3@0+ (1,0) [0|0] "" XXX - SG_ HsaTrnAout_Tq_Rq : 55|16@0+ (4.0,-131072.0) [0|0] "Nm" XXX - SG_ HsaStat_D_Actl : 38|3@0+ (1,0) [0|0] "" XXX - SG_ HsaRoad_Grad_Est : 32|9@0+ (0.5,-127.0) [0|0] "%" XXX - SG_ VehYawComp_W_Actl : 7|12@0+ (0.03663,-75.0) [0|0] "deg/s" XXX - SG_ VehYaw_W_Rq : 11|12@0+ (0.03663,-75.0) [0|0] "deg/s" XXX - SG_ VehSideSlip_An_Est : 31|9@0+ (0.002,-0.5) [0|0] "rad" XXX - -BO_ 124 BrakeSnData_4_CG1: 8 XXX - SG_ EngRun_D_ReqBrk : 10|2@0+ (1,0) [0|0] "" XXX - SG_ BrkTotTqRqArb_No_Cs : 23|8@0+ (1,0) [0|0] "" XXX - SG_ BrkTotTqRqArb_No_Cnt : 31|4@0+ (1,0) [0|0] "" XXX - SG_ BrkTot_Tq_RqArb : 7|13@0+ (4.0,0) [0|0] "Nm" XXX - SG_ BrkTot_Tq_Actl : 39|13@0+ (4.0,0) [0|0] "Nm" XXX - SG_ VehOverGnd_V_Est : 55|16@0+ (0.01,0) [0|0] "kph" XXX - -BO_ 129 Steering_Wheel_Data2: 8 XXX - SG_ SteWhlCtl_RSide_OK : 9|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_RSide_CursorUp : 8|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_RSide_CursorRt : 7|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_RSide_CursorLeft : 6|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_RSide_CursorDown : 5|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_LSide_OK : 4|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_LSide_CursorUp : 3|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_LSide_CursorRt : 2|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_LSide_CursorLeft : 1|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_LSide_CursorDown : 0|1@0+ (1,0) [0|0] "" XXX - -BO_ 130 EPAS_INFO: 8 XXX - SG_ SteMdule_U_Meas : 39|8@0+ (0.05,6.0) [0|0] "Volts" XXX - SG_ SteMdule_I_Est : 21|12@0+ (0.05,-64.0) [0|0] "Amps" XXX - SG_ EPAS_FAILURE : 9|2@0+ (1,0) [0|0] "" XXX - SG_ SteeringColumnTorque : 7|8@0+ (0.0625,-8.0) [0|0] "Nm" XXX - SG_ SAPPAngleControlStat6 : 15|1@0+ (1,0) [0|0] "" XXX - SG_ SAPPAngleControlStat5 : 14|1@0+ (1,0) [0|0] "" XXX - SG_ SAPPAngleControlStat4 : 13|1@0+ (1,0) [0|0] "" XXX - SG_ SAPPAngleControlStat3 : 12|1@0+ (1,0) [0|0] "" XXX - SG_ SAPPAngleControlStat2 : 11|1@0+ (1,0) [0|0] "" XXX - SG_ SAPPAngleControlStat1 : 23|2@0+ (1,0) [0|0] "" XXX - -BO_ 131 Steering_Data: 8 XXX - SG_ SteWhlCtl_Mute : 38|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Mode : 24|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_OK : 23|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Phone : 22|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_End : 21|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Send : 20|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Voice_PTT : 19|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Seek_Left : 10|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Seek_Right : 9|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Media : 8|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Volume_Down : 6|1@0+ (1,0) [0|0] "" XXX - SG_ SteWhlCtl_Volume_Up : 7|1@0+ (1,0) [0|0] "" XXX - SG_ Smart_Wiper_Motor_Stat : 15|2@0+ (1,0) [0|0] "" XXX - SG_ Mfs_Turn_Stalk_SW_Status : 1|2@0+ (1,0) [0|0] "" XXX - SG_ HighBeam_FlashToPassSw : 3|2@0+ (1,0) [0|0] "" XXX - SG_ SteColumn_Status : 13|3@0+ (1,0) [0|0] "" XXX - SG_ SteCol_Manual_Override : 4|1@0+ (1,0) [0|0] "" XXX - SG_ CcButtnStat_D_Actl : 34|11@0+ (1,0) [0|0] "" XXX - SG_ HeatedWash_Mode_Stat : 55|3@0+ (1,0) [0|0] "" XXX - SG_ LaSwtchPos_D_Stat : 18|2@0+ (1,0) [0|0] "" XXX - -BO_ 132 Steering_Wheel_Data_CG1: 8 XXX - SG_ SteWhlRelInit_An_Sns : 7|15@0+ (0.1,-1600.0) [0|0] "deg" XXX - SG_ SteWhlRelCalib_An_Sns : 23|15@0+ (0.1,-1600.0) [0|0] "deg" XXX - SG_ SteWhlRelInit2_An_Sns : 55|16@0+ (0.1,-3200.0) [0|0] "deg" XXX - SG_ SteWhlAn_No_Cs : 39|8@0+ (1,0) [0|0] "" XXX - SG_ SteWhlAn_No_Cnt : 47|4@0+ (1,0) [0|0] "Counts" XXX - -BO_ 145 Yaw_Data: 8 XXX - SG_ VehYaw_W_Actl : 39|16@0+ (0.0002,-6.5) [0|0] "rad/s" XXX - SG_ VehRol_W_Actl : 23|16@0+ (0.0002,-6.5) [0|0] "rad/s" XXX - SG_ VehPtch_W_Actl : 7|16@0+ (0.0002,-6.5) [0|0] "rad/s" XXX - -BO_ 146 Accel_Data: 8 XXX - SG_ VehVertAActl_D_Qf : 38|2@0+ (1,0) [0|0] "" XXX - SG_ VehLongAActl_D_Qf : 22|2@0+ (1,0) [0|0] "" XXX - SG_ VehLatAActl_D_Qf : 6|2@0+ (1,0) [0|0] "" XXX - SG_ VehVert_A_Actl : 36|13@0+ (0.01,-40.0) [0|0] "m/s^2" XXX - SG_ VehLong_A_Actl : 20|13@0+ (0.01,-40.0) [0|0] "m/s^2" XXX - SG_ VehLat_A_Actl : 4|13@0+ (0.01,-40.0) [0|0] "m/s^2" XXX - -BO_ 258 Cluster_Legacy: 8 XXX - SG_ Veh_V_CompLimMx : 27|12@0+ (0.1,0) [0|0] "km/h" XXX - SG_ DISPLAY_SPEED_SCALING : 20|4@0+ (0.5,100.0) [0|0] "%" XXX - SG_ DISPLAY_SPEED_OFFSET : 23|3@0+ (0.5,0) [0|0] "kph" XXX - SG_ Reverse_Mirror_Cmd : 10|1@0+ (1,0) [0|0] "" XXX - SG_ Autolamp_Delay_Cmd : 7|8@0+ (1,0) [0|0] "Seconds" XXX - SG_ Running_Board_Cmd : 13|2@0+ (1,0) [0|0] "" XXX - SG_ Power_Liftgate_Mode_Cmd : 11|1@0+ (1,0) [0|0] "" XXX - -BO_ 259 Body_MsgCntr_Stat_CG1: 8 XXX - SG_ PE_PEPS_System_Stat : 47|8@0+ (1,0) [0|0] "" XXX - SG_ Keycode_Status : 11|20@0+ (1,0) [0|0] "" XXX - SG_ Autolamp_Delay_Stat : 7|8@0+ (1,0) [0|0] "Seconds" XXX - SG_ HvacEvap_Te_Rq_UB : 61|1@0+ (1,0) [0|0] "" XXX - SG_ HvacEvap_Te_Rq : 55|10@0+ (0.125,-50.0) [0|0] "Degrees C" XXX - SG_ Remote_Start_QuietMode_UB : 33|1@0+ (1,0) [0|0] "" XXX - SG_ Remote_Start_QuietMode : 32|1@0+ (1,0) [0|0] "" XXX - -BO_ 264 Side_Detect_CmdM: 8 XXX - SG_ Cross_Traffic_Cmd : 5|2@0+ (1,0) [0|0] "" XXX - SG_ Side_Detect_Cmd : 7|2@0+ (1,0) [0|0] "" XXX - -BO_ 266 ParkAid_Audible_Warn_CmdM: 8 XXX - SG_ AutoPark_Cancel_Request : 15|2@0+ (1,0) [0|0] "" XXX - SG_ ParkAid_Audible_Warn_Cmd : 7|2@0+ (1,0) [0|0] "" XXX - SG_ ParkAid_Aud_Frt_Warn_Cmd : 5|2@0+ (1,0) [0|0] "" XXX - -BO_ 267 ParkAid_Audible_Warn_Stat: 8 XXX - SG_ RpaChime_D_Rq : 31|4@0+ (1,0) [0|0] "" XXX - SG_ FpaChime_D_Rq : 12|4@0+ (1,0) [0|0] "" XXX - SG_ SAPPStatusCoding : 23|8@0+ (1,0) [0|0] "" XXX - SG_ Volume_Cutback : 1|1@0+ (1,0) [0|0] "" XXX - SG_ ParkAid_Fault_Condition : 15|3@0+ (1,0) [0|0] "" XXX - SG_ ParkAid_Audible_Warn_Stat : 7|2@0+ (1,0) [0|0] "" XXX - SG_ ParkAid_Aud_Frt_Trgt_Warn : 3|2@0+ (1,0) [0|0] "" XXX - SG_ ParkAid_Aud_Frt_Warn_Stat : 5|2@0+ (1,0) [0|0] "" XXX - -BO_ 292 ClmtCtrlSeatSet_Cmd_v2: 8 XXX - SG_ ClmtCtrlSeat_SetCmd_Dvr : 7|8@0+ (1,0) [0|0] "" XXX - SG_ ClmtCtrlSeat_SetCmd_Psgr : 15|8@0+ (1,0) [0|0] "" XXX - -BO_ 293 ClmtCtrlSeatSetStat_v2_HS: 8 XXX - SG_ ClmtCtrlSeat_SetStat_Psgr : 15|8@0+ (1,0) [0|0] "" XXX - SG_ ClmtCtrlSeat_SetStat_Dvr : 7|8@0+ (1,0) [0|0] "" XXX - -BO_ 336 TransData_1_CG1: 8 XXX - SG_ TrnAinIdl_N_RqMn : 34|11@0+ (2.0,0) [0|0] "rpm" XXX - SG_ TrnAin_N_RqMxPrtct : 23|10@0+ (25.0,0) [0|0] "rpm" XXX - SG_ TrnAin_Tq_RqFstMx : 29|11@0+ (1,-500.0) [0|0] "Nm" XXX - SG_ TrnAin_Tq_RqSlwMxPrs : 7|11@0+ (1,-500.0) [0|0] "Nm" XXX - -BO_ 337 EngineData_1_CG1: 8 XXX - SG_ TrnEngBrk_B_Allw : 24|1@0+ (1,0) [0|0] "" XXX - SG_ TrnAout_W_ActlUnfilt : 23|15@0+ (0.1,0) [0|0] "rad/s" XXX - SG_ TrnIpcDsplyGear_D_Actl : 7|4@0+ (1,0) [0|0] "" XXX - SG_ TrnIpcDsplyMde_D_Stat : 13|2@0+ (1,0) [0|0] "" XXX - SG_ TrnIpcDsplyMde_D_Actl : 39|3@0+ (1,0) [0|0] "" XXX - SG_ TrnIpcDsplyGear_D_Stat : 9|2@0+ (1,0) [0|0] "" XXX - SG_ TurboBoostPressure : 55|16@0+ (0.01,0) [0|0] "bar" XXX - -BO_ 338 TransData_2_CG1: 8 XXX - SG_ GearPos_D_Actl : 55|4@0+ (1,0) [0|0] "" XXX - SG_ TrnAout2_Tq_Actl : 39|16@0+ (4.0,-131072.0) [0|0] "Nm" XXX - SG_ TrnTotTq_Rt_Actl : 23|16@0+ (0.001,0) [0|0] "" XXX - SG_ TrnGbox_Rt_Pred : 7|16@0+ (0.001,0) [0|0] "" XXX - -BO_ 339 EngineData_2_CG1: 8 XXX - SG_ TrnAin_Tq_MxSpcPdlEngN : 55|11@0+ (1,-500.0) [0|0] "Nm" XXX - SG_ TrnAin_Tq_MnSpcEngN : 31|11@0+ (1,-500.0) [0|0] "Nm" XXX - SG_ EngPtoEngag_B_Actl : 60|1@0+ (1,0) [0|0] "" XXX - SG_ TrnAin_N_SpcEcho : 4|13@0+ (2.0,0) [0|0] "rpm" XXX - -BO_ 340 EngineData_3_CG1: 8 XXX - SG_ AirAmb_Te_ActlFilt : 33|10@0+ (0.25,-128.0) [0|0] "deg C" XXX - SG_ EngAout_N_RqMxPrtct : 12|13@0+ (2.0,0) [0|0] "rpm" XXX - SG_ TqmTerrMdeChng_D_Rdy : 39|3@0+ (1,0) [0|0] "" XXX - SG_ EngAoutIdl_N_RqVsc : 7|11@0+ (2.0,0) [0|0] "rpm" XXX - SG_ TqmTerrMde_D_Actl : 36|3@0+ (1,0) [0|0] "" XXX - SG_ PrplWhlTotVrt_Tq_RqArb : 55|16@0+ (4.0,-131072.0) [0|0] "Nm" XXX - -BO_ 341 EngineData_11_CG1: 8 XXX - SG_ DieslPrtc_D_RqDsply : 42|3@0+ (1,0) [0|0] "" XXX - SG_ EngPullUpPullDown_D_Rq : 20|4@0+ (1,0) [0|0] "" XXX - SG_ TrnAin_Tq_RqDrv : 15|11@0+ (1,-500.0) [0|0] "Nm" XXX - SG_ DieslPrtcRgen_D_Actl : 4|2@0+ (1,0) [0|0] "" XXX - SG_ DieslPrtcRgen_D_Rq : 7|3@0+ (1,0) [0|0] "" XXX - SG_ EngAout_Aa_Actl : 39|10@0+ (0.05,-25.6) [0|0] "rpm/ms" XXX - SG_ EngIgnIndTq_Rt_MnEc : 31|8@0+ (0.005,0) [0|0] "" XXX - SG_ EngFuelCutFull_B_Allw : 45|1@0+ (1,0) [0|0] "" XXX - SG_ EngStrtStopDis_B_Rq : 0|1@0+ (1,0) [0|0] "" XXX - SG_ PrplTqSys_D_Stat : 2|2@0+ (1,0) [0|0] "" XXX - SG_ EngAoutTqDtrb_B_Actl : 16|1@0+ (1,0) [0|0] "" XXX - SG_ EngTurboMde_D_Actl : 44|2@0+ (1,0) [0|0] "" XXX - SG_ EngTeColdPrtct_D_Stats : 54|2@0+ (1,0) [0|0] "" XXX - SG_ EXHAUST_OVERTEMP_PROTECT : 63|1@0+ (1,0) [0|0] "" XXX - SG_ EngExhOvrTe_B_RqDsply : 55|1@0+ (1,0) [0|0] "" XXX - -BO_ 342 Engine_Data_6: 8 XXX - SG_ EngOvrhtMitgActv_D_Ind : 36|2@0+ (1,0) [0|0] "" XXX - SG_ Res_UreaLvlLo_B_Dsply : 34|1@0+ (1,0) [0|0] "" XXX - SG_ EngClntTe_D_Qf : 33|2@0+ (1,0) [0|0] "" XXX - SG_ EngAcsyArcPmp_Tq_Actl : 63|8@0+ (0.5,0) [0|0] "Nm" XXX - SG_ EngOilLvlDsply_D_Rq : 43|4@0+ (1,0) [0|0] "" XXX - SG_ EngCtlAlive_No_Cnt : 47|4@0+ (1,0) [0|0] "" XXX - SG_ EngCtl_No_Cs : 55|8@0+ (1,0) [0|0] "" XXX - SG_ EngOil_Te_Actl : 15|8@0+ (1,-60.0) [0|0] "degC" XXX - SG_ EngClnt_Te_Actl : 7|8@0+ (1,-60.0) [0|0] "degC" XXX - -BO_ 343 EngineData_13_CG1: 8 XXX - SG_ EngStrtFail_B_Actl : 40|1@0+ (1,0) [0|0] "" XXX - SG_ EngStrt_B_Complt : 24|1@0+ (1,0) [0|0] "" XXX - SG_ EngStrtSpin_B_Rdy : 58|1@0+ (1,0) [0|0] "" XXX - SG_ EngWarmUp_B_Complt : 41|1@0+ (1,0) [0|0] "" XXX - SG_ EngAoutTqCtl_B_Falt : 8|1@0+ (1,0) [0|0] "" XXX - SG_ EngAoutActl_No_Cs : 23|8@0+ (1,0) [0|0] "" XXX - SG_ EngAoutActl_No_Cnt : 45|4@0+ (1,0) [0|0] "" XXX - SG_ VehVLim_V_RqArb : 39|9@0+ (0.5,0) [0|0] "kph" XXX - -BO_ 344 EngineData_14: 8 XXX - SG_ ApedPosScal_Pc_Actl : 9|10@0+ (0.1,0) [0|0] "%" XXX - SG_ ApedPosPcActl_No_Cs : 39|8@0+ (1,0) [0|0] "" XXX - SG_ ApedPosPcActl_No_Cnt : 13|4@0+ (1,0) [0|0] "" XXX - -BO_ 345 Engine_Data_7_CG1: 8 XXX - SG_ EngDecelFuelCut_B_Allw : 25|1@0+ (1,0) [0|0] "" XXX - SG_ FuelFlw_Vl_Dsply : 55|10@0+ (25.0,0) [0|0] "Micro_Liter" XXX - SG_ FuelFillInlet_B_Dsply : 32|1@0+ (1,0) [0|0] "" XXX - SG_ EngSrvcRqd_B_Rq : 24|1@0+ (1,0) [0|0] "" XXX - SG_ OdoCount : 47|8@0+ (0.2,0) [0|0] "Meters" XXX - SG_ EngOilLife_Pc_Actl : 39|7@0+ (1,0) [0|0] "%" XXX - SG_ AirAmbTe_D_Qf : 28|2@0+ (1,0) [0|0] "" XXX - SG_ EngTqSlwDly_T_Est : 23|11@0+ (1,0) [0|0] "ms" XXX - SG_ TrnKickDown_B_RqDrv : 26|1@0+ (1,0) [0|0] "" XXX - SG_ AirAmb_Te_Actl : 1|10@0+ (0.25,-128.0) [0|0] "degC" XXX - SG_ AirAmb_P_Actl : 7|6@0+ (10.0,500.0) [0|0] "mbar" XXX - SG_ FuelFilterLamp_B_Dsply : 56|1@0+ (1,0) [0|0] "" XXX - SG_ AirCondRec_B_Rq : 61|1@0+ (1,0) [0|0] "" XXX - SG_ AirCondEvdc_D_Stats : 60|3@0+ (1,0) [0|0] "" XXX - SG_ AirCondClutch_B_Stats : 57|1@0+ (1,0) [0|0] "" XXX - -BO_ 346 EngineData_4_CG1: 8 XXX - SG_ TrnAin_Tq_Rq : 12|11@0+ (1,-500.0) [0|0] "Nm" XXX - SG_ TrnAin_Tq_RqWoMdfy : 55|11@0+ (1,-500.0) [0|0] "Nm" XXX - SG_ TrnAin_Tq_ActlWoMdfy : 36|11@0+ (1,-500.0) [0|0] "Nm" XXX - SG_ TrnAin_Tq_Actl : 7|11@0+ (1,-500.0) [0|0] "Nm" XXX - SG_ TrnAinCtlN_B_Allw : 41|1@0+ (1,0) [0|0] "" XXX - SG_ TrnAinTq_D_Qf : 17|2@0+ (1,0) [0|0] "" XXX - -BO_ 348 EngineData_16_CG1: 8 XXX - SG_ EngOilLvlWarn_D_Rq1 : 50|3@0+ (1,0) [0|0] "" XXX - SG_ EngExhBrkOnLamp_B_Rq : 51|1@0+ (1,0) [0|0] "" XXX - SG_ EngExhBrkAutoLamp_B_Rq : 8|1@0+ (1,0) [0|0] "" XXX - SG_ EngAout_N_MxAllw : 36|13@0+ (2.0,0) [0|0] "rpm" XXX - SG_ EngAoutIdl_N_MnAllw : 31|11@0+ (1,0) [0|0] "rpm" XXX - SG_ EngAoutIdlRqEc_No_Cs : 23|8@0+ (1,0) [0|0] "" XXX - SG_ EngAoutIdlRqEc_No_Cnt : 12|4@0+ (1,0) [0|0] "" XXX - SG_ EngAoutIdl_N_RqEc : 7|11@0+ (2.0,0) [0|0] "rpm" XXX - SG_ EngExhBrkMde_D_Actl : 55|4@0+ (1,0) [0|0] "" XXX - -BO_ 349 EngineData_17_CG1: 8 XXX - SG_ EngResv_Tq_Actl : 52|11@0+ (1,-500.0) [0|0] "Nm" XXX - SG_ EngAout_Tq_ActlSlw : 47|11@0+ (1,-500.0) [0|0] "Nm" XXX - SG_ EngExhCat_Te_Est : 13|10@0+ (2.0,-60.0) [0|0] "degC" XXX - SG_ EngCylCutIndTq_Rt_Actl : 39|8@0+ (0.005,0) [0|0] "Nm" XXX - SG_ Eng_Aa_CalcEvntCyc : 7|10@0+ (0.05,-25.6) [0|0] "rpm/ms" XXX - SG_ Eng_Aa_CalcEvntCbust : 19|10@0+ (0.05,-25.6) [0|0] "rpm/ms" XXX - SG_ WaterInFuel : 25|1@0+ (1,0) [0|0] "" XXX - SG_ GlowIndication : 24|1@0+ (1,0) [0|0] "" XXX - -BO_ 350 EngineData_18_CG1: 8 XXX - SG_ EngAoutTqActl_D_Qf : 17|2@0+ (1,0) [0|0] "" XXX - SG_ EngAout_Tq_MnSpcNRtrd : 36|11@0+ (1,-500.0) [0|0] "Nm" XXX - SG_ EngAout_Tq_Actl : 31|11@0+ (1,-500.0) [0|0] "Nm" XXX - SG_ EngAoutLss_Tq_EstSpcN : 12|11@0+ (1,-500.0) [0|0] "Nm" XXX - SG_ EngAout_Tq_MnSpcN : 7|11@0+ (1,-500.0) [0|0] "Nm" XXX - -BO_ 351 EngineData_19: 8 XXX - SG_ VehPreDelvr_V_LimMx : 15|16@0+ (0.01,0) [0|0] "kph" XXX - SG_ BattLo_U_MeasEngMdule : 7|8@0+ (0.1,0) [0|0] "V" XXX - SG_ EngStall_B_Actl : 47|1@0+ (1,0) [0|0] "" XXX - SG_ EngDashPotActv_B_Actl : 46|1@0+ (1,0) [0|0] "" XXX - SG_ EngAout_Tq_MnAllw : 42|11@0+ (1,-500.0) [0|0] "Nm" XXX - -BO_ 352 TransData_3_CG1: 8 XXX - SG_ TrnAinCtlN_N_RqMx : 7|13@0+ (2.0,0) [0|0] "rpm" XXX - SG_ TrnAin_Tq_RqSlwMxShif : 42|11@0+ (1,-500.0) [0|0] "Nm" XXX - SG_ TrnAinCtlN_B_RqEnbl : 10|1@0+ (1,0) [0|0] "" XXX - SG_ TrnGboxIn_N_Actl : 23|13@0+ (2.0,0) [0|0] "rpm" XXX - -BO_ 353 Engine_Data_8: 8 XXX - SG_ TrnAinTqDtrb_B_Actl : 5|1@0+ (1,0) [0|0] "" XXX - SG_ TrnAin_Tq_MnSpcEngN : 34|11@0+ (1,-500.0) [0|0] "Nm" XXX - SG_ EngAout_N_RqMnPrtct : 20|13@0+ (2.0,0) [0|0] "rpm" XXX - SG_ EngAout_N_MnAllw : 4|13@0+ (2.0,0) [0|0] "rpm" XXX - -BO_ 354 CGEA_Urea_Strategy_CG1: 8 XXX - SG_ UreaQltySys_D_RqDsply : 27|3@0+ (1,0) [0|0] "" XXX - SG_ UreaLvlTxt_D_RqDsply : 31|4@0+ (1,0) [0|0] "" XXX - SG_ VehUreaImmo_No_DsplyMx : 12|3@0+ (1,0) [0|0] "Counts" XXX - SG_ VehUreaWarn_V_DsplyMx : 23|7@0+ (1,0) [0|0] "km/h" XXX - SG_ VehUreaRnge_L_DsplyMx : 7|11@0+ (1,0) [0|0] "km" XXX - -BO_ 355 EngineData_10: 8 XXX - SG_ WhlRearDual_D_Stat : 57|2@0+ (1,0) [0|0] "" XXX - SG_ EngPtoMde_D_Actl : 60|3@0+ (1,0) [0|0] "" XXX - SG_ ManRgenVeh_V_MinAllw : 55|7@0+ (1,0) [0|0] "kilometer/hour" XXX - SG_ ManRgenTxt_D_RqDsply : 63|3@0+ (1,0) [0|0] "" XXX - SG_ ManRgenSoot_Pc_RqDsply : 39|7@0+ (1,0) [0|0] "%" XXX - SG_ ManRgenInhbt_T_RqDsply : 23|16@0+ (1,0) [0|0] "Minutes" XXX - SG_ ManRgenInhbt_Pc_Soot : 47|7@0+ (1,0) [0|0] "%" XXX - SG_ ManRgenInhbt_L_RqDsply : 7|16@0+ (1,0) [0|0] "kilometer" XXX - -BO_ 357 EngBrakeData: 8 XXX - SG_ CmbbDeny_B_ActlPrpl : 3|1@0+ (1,0) [0|0] "" XXX - SG_ BpedDrvAppl_No_Cs : 39|8@0+ (1,0) [0|0] "" XXX - SG_ BpedDrvAppl_No_Cnt : 27|4@0+ (1,0) [0|0] "" XXX - SG_ BpedDrvAppl_D_Actl : 31|2@0+ (1,0) [0|0] "" XXX - SG_ CmbbEngTqMn_B_Actl : 7|1@0+ (1,0) [0|0] "" XXX - SG_ Veh_V_DsplyCcSet : 23|8@0+ (1,0) [0|0] "" XXX - SG_ AccEngStat_D_Actl : 2|3@0+ (1,0) [0|0] "" XXX - SG_ CcMde_D_Actl : 13|3@0+ (1,0) [0|0] "" XXX - SG_ TrnAinTqDtrb_B_Actl : 6|1@0+ (1,0) [0|0] "" XXX - SG_ CcStat_D_Actl : 10|3@0+ (1,0) [0|0] "" XXX - SG_ CcOvrrdActv_B_Actl : 15|1@0+ (1,0) [0|0] "" XXX - SG_ PwPck_D_Stat : 59|4@0+ (1,0) [0|0] "" XXX - -BO_ 389 ACCDATA_CG1: 8 XXX - SG_ AccPrpl_A_Pred : 14|10@0+ (0.01,-5.0) [0|0] "m/s^2" XXX - SG_ AccBrkPrkEl_B_Rq : 41|1@0+ (1,0) [0|0] "" XXX - SG_ Cmbb_B_Enbl : 56|1@0+ (1,0) [0|0] "" XXX - SG_ CmbbOvrrd_B_RqDrv : 57|1@0+ (1,0) [0|0] "" XXX - SG_ CmbbDeny_B_Actl : 40|1@0+ (1,0) [0|0] "" XXX - SG_ AccVeh_V_Trg : 7|9@0+ (0.5,0) [0|0] "kph" XXX - SG_ CmbbEngTqMn_B_Rq : 58|1@0+ (1,0) [0|0] "" XXX - SG_ AccPrpl_A_Rq : 55|10@0+ (0.01,-5.0) [0|0] "m/s^2" XXX - SG_ AccDeny_B_Rq : 59|1@0+ (1,0) [0|0] "" XXX - SG_ AccCancl_B_Rq : 42|1@0+ (1,0) [0|0] "" XXX - SG_ AccBrkTot_A_Rq : 39|13@0+ (0.0039,-20.0) [0|0] "m/s^2" XXX - SG_ AccBrkPrchg_B_Rq : 60|1@0+ (1,0) [0|0] "" XXX - SG_ AccBrkDecel_B_Rq : 61|1@0+ (1,0) [0|0] "" XXX - -BO_ 392 HeadUpDisplayStat: 8 XXX - SG_ Hud_B_Falt : 5|1@0+ (1,0) [0|0] "" XXX - SG_ HudActv_B_Actl : 7|1@0+ (1,0) [0|0] "" XXX - SG_ Hud_B_Avail : 6|1@0+ (1,0) [0|0] "" XXX - -BO_ 393 ACCDATA_2_CG1: 8 XXX - SG_ ACC_AUTOBRAKE_CANCEL : 56|1@0+ (1,0) [0|0] "" XXX - SG_ ACC_RESUME_ACTIVE : 57|1@0+ (1,0) [0|0] "" XXX - SG_ FcwAudioWarn_B_Rq : 58|1@0+ (1,0) [0|0] "" XXX - SG_ CadsAudioMute_D_Rq : 61|2@0+ (1,0) [0|0] "" XXX - SG_ AccWarn_D_Dsply : 63|2@0+ (1,0) [0|0] "" XXX - SG_ HudDsplyIntns_No_Actl : 55|8@0+ (0.5,0) [0|0] "%" XXX - SG_ FcwVisblWarn_B_Rq : 40|1@0+ (1,0) [0|0] "" XXX - SG_ HudBlk3_B_Rq : 41|1@0+ (1,0) [0|0] "" XXX - SG_ HudBlk2_B_Rq : 43|1@0+ (1,0) [0|0] "" XXX - SG_ HudBlk1_B_Rq : 42|1@0+ (1,0) [0|0] "" XXX - SG_ HudFlashRate_D_Actl : 45|2@0+ (1,0) [0|0] "" XXX - SG_ CmbbBrkDecel_No_Cs : 39|8@0+ (1,0) [0|0] "" XXX - SG_ CmbbBrkDecel_A_Rq : 23|13@0+ (0.0039,-20.0) [0|0] "m/s^2" XXX - SG_ CmbbBrkPrchg_D_Rq : 47|2@0+ (1,0) [0|0] "" XXX - SG_ CmbbBrkDecel_B_Rq : 26|1@0+ (1,0) [0|0] "" XXX - SG_ CmbbBaSens_D_Rq : 25|2@0+ (1,0) [0|0] "" XXX - SG_ AccPrpl_V_Rq : 7|16@0+ (0.01,0) [0|0] "kph" XXX - -BO_ 394 ACCDATA_3: 8 XXX - SG_ CadsMntr_No_Chk : 55|8@0+ (1,0) [0|0] "" XXX - SG_ FcwDeny_B_Dsply : 10|1@0+ (1,0) [0|0] "" XXX - SG_ FdaWarn_B_Rq : 21|1@0+ (1,0) [0|0] "" XXX - SG_ FcwMemStat_B_Actl : 30|1@0+ (1,0) [0|0] "" XXX - SG_ AccTGap_B_Dsply : 35|1@0+ (1,0) [0|0] "" XXX - SG_ AccMsgTxt_D_Rq : 39|4@0+ (1,0) [0|0] "" XXX - SG_ CadsAlignIncplt_B_Actl : 29|1@0+ (1,0) [0|0] "" XXX - SG_ AccLowVMde_B_Dsply : 16|1@0+ (1,0) [0|0] "" XXX - SG_ AccFllwMde_B_Dsply : 17|1@0+ (1,0) [0|0] "" XXX - SG_ CadsRadrBlck_B_Actl : 22|1@0+ (1,0) [0|0] "" XXX - SG_ FdaStat_D_Dsply : 3|3@0+ (1,0) [0|0] "" XXX - SG_ FdaDeny_B_Dsply : 4|1@0+ (1,0) [0|0] "" XXX - SG_ AccTrgDist_D_Dsply : 28|4@0+ (1,0) [0|0] "" XXX - SG_ CadsChime_B_Rq : 24|1@0+ (1,0) [0|0] "" XXX - SG_ CmbbPostEvnt_B_Dsply : 15|1@0+ (1,0) [0|0] "" XXX - SG_ FcwCmbbSrvcRqd_B_Rq : 12|1@0+ (1,0) [0|0] "" XXX - SG_ AccStopMde_B_Dsply : 0|1@0+ (1,0) [0|0] "" XXX - SG_ CadsCamraBlck_B_Actl : 23|1@0+ (1,0) [0|0] "" XXX - SG_ FcwMemSens_D_Actl : 20|2@0+ (1,0) [0|0] "" XXX - SG_ FcwMemDfaltOn_B_Actl : 18|1@0+ (1,0) [0|0] "" XXX - SG_ AccSrvcRqd_B_Rq : 14|1@0+ (1,0) [0|0] "" XXX - SG_ FcwMsgTxt_D_Rq : 7|3@0+ (1,0) [0|0] "" XXX - SG_ FcwMemAudioOn_B_Actl : 9|1@0+ (1,0) [0|0] "" XXX - SG_ AccTGap_D_Dsply : 34|3@0+ (1,0) [0|0] "" XXX - SG_ AccMemEnbl_B_RqDrv : 42|1@0+ (1,0) [0|0] "" XXX - SG_ FdaMem_B_Stat : 41|1@0+ (1,0) [0|0] "" XXX - -BO_ 512 TorqueDataEngFlags: 8 XXX - SG_ BrkOnOffSwtch_D_Actl : 54|2@0+ (1,0) [0|0] "" XXX - SG_ PrplTqMnSat_B_Actl : 55|1@0+ (1,0) [0|0] "" XXX - SG_ PrplWhlTot_Tq_Rq : 39|16@0+ (4.0,-131072.0) [0|0] "Nm" XXX - SG_ PrplWhlTot_Tq_LimMn : 23|16@0+ (4.0,-131072.0) [0|0] "Nm" XXX - SG_ PrplWhlTot_Tq_Actl : 7|16@0+ (4.0,-131072.0) [0|0] "Nm" XXX - SG_ ACCompressorDisp : 63|7@0+ (1,0) [0|0] "%" XXX - -BO_ 513 EngVehicleSpThrottle_CG1: 8 XXX - SG_ ApedPos_PcRate_ActlArb : 63|8@0+ (0.04,-5.0) [0|0] "%/ms" XXX - SG_ Veh_V_RqCcSet : 45|9@0+ (0.5,0) [0|0] "kph" XXX - SG_ VehVActlEng_D_Qf : 9|2@0+ (1,0) [0|0] "" XXX - SG_ reserve : 10|1@0+ (1,0) [0|0] "" XXX - SG_ EngAout_N_Actl : 7|13@0+ (2.0,0) [0|0] "rpm" XXX - SG_ Veh_V_ActlEng : 23|16@0+ (0.01,0) [0|0] "kph" XXX - SG_ ApedPos_Pc_ActlArb : 39|10@0+ (0.1,0) [0|0] "%" XXX - SG_ ApedPosPcActl_D_Qf : 52|2@0+ (1,0) [0|0] "" XXX - SG_ Autostart_B_Stat : 50|1@0+ (1,0) [0|0] "" XXX - -BO_ 529 DesiredTorqBrk_CG1: 8 XXX - SG_ CmbbBrkDis_B_Actl : 56|1@0+ (1,0) [0|0] "" XXX - SG_ CMbbDeny_B_ActlBrk : 60|1@0+ (1,0) [0|0] "" XXX - SG_ RgenTqLimActv_B_Actl : 32|1@0+ (1,0) [0|0] "" XXX - SG_ CcDis_B_Cmd : 53|1@0+ (1,0) [0|0] "" XXX - SG_ TrlrBrk_Pc_Rq : 39|7@0+ (1,0) [0|0] "%" XXX - SG_ RearDiffLck_Tq_RqMx : 23|12@0+ (1,0) [0|0] "Nm" XXX - SG_ VehLongOvrGnd_A_Est : 47|10@0+ (0.035,-17.9) [0|0] "m/s^2" XXX - SG_ StabCtlBrkActv_B_Actl : 27|1@0+ (1,0) [0|0] "" XXX - SG_ CmbbBrkPrchg_B_Actl : 59|1@0+ (1,0) [0|0] "" XXX - SG_ CmbbBrkDecel_B_Actl : 58|1@0+ (1,0) [0|0] "" XXX - SG_ CmbbBaSensInc_B_Actl : 57|1@0+ (1,0) [0|0] "" XXX - SG_ AccBrkWarm_B_Actl : 63|1@0+ (1,0) [0|0] "" XXX - SG_ AccBrkTotTqMn_B_Actl : 62|1@0+ (1,0) [0|0] "" XXX - SG_ AccBrkPrchgActv_B_Actl : 61|1@0+ (1,0) [0|0] "" XXX - SG_ AccBrkDis_B_Actl : 50|1@0+ (1,0) [0|0] "" XXX - SG_ AccBrkDeny_B_Actl : 49|1@0+ (1,0) [0|0] "" XXX - SG_ AccBrkActv_B_Actl : 48|1@0+ (1,0) [0|0] "" XXX - SG_ PrplDrgCtlActv_B_Actl : 52|1@0+ (1,0) [0|0] "" XXX - SG_ PrplWhlTot_Tq_RqMx : 7|16@0+ (4.0,-131072.0) [0|0] "Nm" XXX - SG_ AbsActv_B_Actl : 51|1@0+ (1,0) [0|0] "" XXX - -BO_ 533 WheelSpeed_CG1: 8 XXX - SG_ WhlRr_W_Meas : 55|15@0+ (0.01,0) [0|0] "rad/s" XXX - SG_ WhlRl_W_Meas : 39|15@0+ (0.01,0) [0|0] "rad/s" XXX - SG_ WhlFr_W_Meas : 23|15@0+ (0.01,0) [0|0] "rad/s" XXX - SG_ WhlFl_W_Meas : 7|15@0+ (0.01,0) [0|0] "rad/s" XXX - -BO_ 534 WheelData: 8 XXX - SG_ WhlRotatRr_No_Cnt : 23|8@0+ (1,0) [0|0] "" XXX - SG_ WhlDirRr_D_Actl : 33|2@0+ (1,0) [0|0] "" XXX - SG_ WhlDirRl_D_Actl : 39|2@0+ (1,0) [0|0] "" XXX - SG_ WhlDirFr_D_Actl : 37|2@0+ (1,0) [0|0] "" XXX - SG_ WhlDirFl_D_Actl : 35|2@0+ (1,0) [0|0] "" XXX - SG_ WhlRotatRl_No_Cnt : 31|8@0+ (1,0) [0|0] "" XXX - SG_ WhlRotatFr_No_Cnt : 7|8@0+ (1,0) [0|0] "" XXX - SG_ WhlRotatFl_No_Cnt : 15|8@0+ (1,0) [0|0] "" XXX - SG_ WHEEL_ROLLING_TIMESTAMP : 47|8@0+ (1,0) [0|0] "" XXX - -BO_ 557 InfoCAN_22D: 8 XXX - SG_ Multimedia_System : 7|1@0+ (1,0) [0|0] "" XXX - -BO_ 560 TransGearData: 8 XXX - SG_ TrnIpcDsplyRng_D_Actl : 14|3@0+ (1,0) [0|0] "" XXX - SG_ TrnGbox_Rt_Actl : 47|16@0+ (0.001,0) [0|0] "" XXX - SG_ TrnShifMde_D_RqDrv : 3|3@0+ (1,0) [0|0] "" XXX - SG_ TrnSrvcRqd_B_Rq : 63|1@0+ (1,0) [0|0] "" XXX - SG_ GearPos_D_Trg : 7|4@0+ (1,0) [0|0] "" XXX - SG_ TrnCnvtClu_D_Actl : 11|2@0+ (1,0) [0|0] "" XXX - SG_ TrnShifActv_B_Actl : 0|1@0+ (1,0) [0|0] "" XXX - SG_ RtmTerrMdeChng_D_Rdy : 58|3@0+ (1,0) [0|0] "" XXX - SG_ RtmTerrMde_D_Actl : 61|3@0+ (1,0) [0|0] "" XXX - SG_ GearRvrseActv_B_Actl : 62|1@0+ (1,0) [0|0] "" XXX - SG_ GearLvrPos_D_Actl : 23|4@0+ (1,0) [0|0] "" XXX - SG_ GboxOil_Te_Actl : 31|8@0+ (1,-60.0) [0|0] "degC" XXX - -BO_ 561 TransGearData_2: 8 XXX - SG_ MtrGen1Aout_Tq_Rq : 53|14@0+ (0.1,-800.0) [0|0] "Nm" XXX - SG_ MtrGen1AoutTqRq_No_Cs : 7|8@0+ (1,0) [0|0] "" XXX - SG_ MtrGen1AoutTqRq_No_Cnt : 15|4@0+ (1,0) [0|0] "" XXX - SG_ CoolFanTrn_D_Rq : 31|5@0+ (1,0) [0|0] "" XXX - SG_ TrnMsgTxt_D_Rq : 39|4@0+ (1,0) [0|0] "" XXX - SG_ TrnMil_D_Rq : 26|2@0+ (1,0) [0|0] "" XXX - SG_ EngExhBrkTq_Pc_Rq : 23|7@0+ (1,0) [0|0] "%" XXX - -BO_ 562 TransGearData_3_CG1: 8 XXX - SG_ TrnPto_D_Rdy : 12|2@0+ (1,0) [0|0] "" XXX - SG_ TipInMgrInhbt_B_RqTrn : 41|1@0+ (1,0) [0|0] "" XXX - SG_ TrnAinIdl_Tq_Actl : 39|11@0+ (1,-500.0) [0|0] "Nm" XXX - SG_ TrnAinLss_Tq_Est : 7|11@0+ (1,-500.0) [0|0] "Nm" XXX - SG_ TrnAin_Tq_RqSlwMn : 23|11@0+ (1,-500.0) [0|0] "Nm" XXX - SG_ GearEngag_D_Actl : 10|3@0+ (1,0) [0|0] "" XXX - SG_ TrnAinTqDtrb_B_Rq : 40|1@0+ (1,0) [0|0] "" XXX - SG_ TrnTotLss_Tq_Actl : 55|8@0+ (0.5,0) [0|0] "Nm" XXX - -BO_ 563 TransGearData_4_CG1: 8 XXX - SG_ TrnAinCtlN_N_RqMn : 20|13@0+ (2.0,0) [0|0] "rpm" XXX - SG_ TrnAinTqMn_No_Cs : 63|8@0+ (1,0) [0|0] "" XXX - SG_ TrnAinTqMn_No_Cnt : 11|4@0+ (1,0) [0|0] "" XXX - SG_ TrnAinRq_Pc_SpcPdl : 7|10@0+ (0.1,0) [0|0] "%" XXX - SG_ TrnAin_Tq_RqFstMn : 42|11@0+ (1,-500.0) [0|0] "Nm" XXX - SG_ TrnAin_N_SpcEng : 39|13@0+ (2.0,0) [0|0] "rpm" XXX - -BO_ 570 Suspension_Stat: 8 XXX - SG_ CcdMsgTxt_D_RqDsply : 7|4@0+ (1,0) [0|0] "" XXX - SG_ SuspRear_L_Prev : 48|9@0+ (0.782779,-200.0) [0|0] "millimeter" XXX - SG_ SuspRear_L_Actl : 32|9@0+ (0.782779,-200.0) [0|0] "millimeter" XXX - SG_ SuspFrnt_L_Prev : 16|9@0+ (0.782779,-200.0) [0|0] "millimeter" XXX - SG_ SuspFrnt_L_Actl : 0|9@0+ (0.782779,-200.0) [0|0] "millimeter" XXX - -BO_ 571 ColumnLockData: 8 XXX - SG_ SteWhlLckMsgTxt_D_Rq : 7|2@0+ (1,0) [0|0] "" XXX - -BO_ 576 Body_Information_4_CG1: 8 XXX - SG_ HvacRec_Pc_Est_UB : 51|1@0+ (1,0) [0|0] "" XXX - SG_ HvacRec_Pc_Est : 38|7@0+ (1,0) [0|0] "%" XXX - SG_ HvacEngIdleInc_B_Rq_UB : 49|1@0+ (1,0) [0|0] "" XXX - SG_ HvacEngIdleInc_B_Rq : 53|1@0+ (1,0) [0|0] "" XXX - SG_ HvacAir_Flw_Est_UB : 52|1@0+ (1,0) [0|0] "" XXX - SG_ HvacAir_Flw_Est : 31|9@0+ (0.5,0) [0|0] "liter/second" XXX - SG_ AmbTempImpr_UB : 50|1@0+ (1,0) [0|0] "" XXX - SG_ AmbTempImpr : 47|10@0+ (0.25,-128.0) [0|0] "degreesC" XXX - SG_ DriverCrankingReq : 16|1@0+ (1,0) [0|0] "" XXX - SG_ Fcw_B_DenyMntr : 23|1@0+ (1,0) [0|0] "" XXX - SG_ EngOff_T_Actl : 7|16@0+ (1,0) [0|0] "seconds" XXX - SG_ CmbbMntr_B_Err : 22|1@0+ (1,0) [0|0] "" XXX - SG_ CmbbDeny_B_RqMntr : 21|1@0+ (1,0) [0|0] "" XXX - SG_ AccMntr_B_Err : 20|1@0+ (1,0) [0|0] "" XXX - SG_ AccDeny_B_RqMntr : 19|1@0+ (1,0) [0|0] "" XXX - -BO_ 592 EONV_Status: 8 XXX - SG_ EONV_FAULT : 59|1@0+ (1,0) [0|0] "" XXX - SG_ EONV_KAL_IC_RQST : 53|1@0+ (1,0) [0|0] "" XXX - SG_ EONV_T_STATUS : 61|2@0+ (1,0) [0|0] "" XXX - SG_ EONV_VREF_FLT : 62|1@0+ (1,0) [0|0] "" XXX - SG_ EONV_VBATT_FLT : 63|1@0+ (1,0) [0|0] "" XXX - SG_ EONV_CANISTER_VENT_FLT : 54|1@0+ (1,0) [0|0] "" XXX - SG_ EONV_CVS_CLOSED : 55|1@0+ (1,0) [0|0] "" XXX - SG_ EONV_BATT_VOLT : 23|16@0+ (0.0009765625,0) [0|0] "volts" XXX - SG_ EONV_TANK_FLT : 48|1@0+ (1,0) [0|0] "" XXX - SG_ EONV_TANK_PRESS : 7|16@0+ (0.001953125,-64.0) [0|0] "inches H2O" XXX - -BO_ 597 EONV_Control: 8 XXX - SG_ EONV_POS_DET_THRESHOLD : 23|16@0+ (0.001953125,-64.0) [0|0] "inches H2O" XXX - SG_ EONV_STAY_ALIVE : 15|1@0+ (1,0) [0|0] "" XXX - SG_ EONV_CVS_MODE : 7|3@0+ (1,0) [0|0] "" XXX - SG_ EONV_NEG_DET_THRESHOLD : 39|16@0+ (0.001953125,-64.0) [0|0] "inches H2O" XXX - SG_ EONV_MIL_ON : 14|1@0+ (1,0) [0|0] "" XXX - SG_ EonvMsgTxOff_B_Rq : 4|1@0+ (1,0) [0|0] "" XXX - -BO_ 608 Information4x4_CG1: 8 XXX - SG_ AwdRngeShifActv_B_Actl : 0|1@0+ (1,0) [0|0] "" XXX - SG_ TrnAout_Tq_RqMx : 47|13@0+ (1,-1250.0) [0|0] "Nm" XXX - SG_ AwdRngeFalt_D_Stat : 4|2@0+ (1,0) [0|0] "" XXX - SG_ AwdLck_Tq_Actl : 15|12@0+ (1,0) [0|0] "Nm" XXX - SG_ AwdRnge_D_Actl : 7|3@0+ (1,0) [0|0] "" XXX - SG_ AwdTerrMdeChng_D_Rdy : 50|3@0+ (1,0) [0|0] "" XXX - SG_ AwdTerrMde_D_Actl : 58|3@0+ (1,0) [0|0] "" XXX - SG_ AwdOffRoadMode_D_Stats : 25|2@0+ (1,0) [0|0] "" XXX - SG_ AwdStat_D_RqDsply : 63|5@0+ (1,0) [0|0] "" XXX - SG_ AwdLoLamp_D_RqDsply : 35|2@0+ (1,0) [0|0] "" XXX - SG_ AwdHiLamp_D_RqDsply : 19|2@0+ (1,0) [0|0] "" XXX - SG_ AwdAutoLamp_D_RqDsply : 17|2@0+ (1,0) [0|0] "" XXX - SG_ AwdLckLamp_D_RqDsply : 27|2@0+ (1,0) [0|0] "" XXX - SG_ AwdLck_D_Stat : 31|4@0+ (1,0) [0|0] "" XXX - SG_ Awd2wdLamp_D_RqDsply : 2|2@0+ (1,0) [0|0] "" XXX - -BO_ 609 AWD_4x4_Data: 8 XXX - SG_ AwdLck_Tq_Rq : 27|12@0+ (1,0) [0|0] "Nm" XXX - SG_ AwdSrvcRqd_B_Rq : 44|1@0+ (1,0) [0|0] "" XXX - -BO_ 613 PassengerSeatOCSInfo: 8 XXX - SG_ VehicleMYCalibrationId : 39|8@0+ (1,0) [0|0] "" XXX - SG_ VehicleCalibrationId : 31|8@0+ (1,0) [0|0] "" XXX - SG_ OCSSensrDataUpperLim : 15|8@0+ (1,0) [0|0] "" XXX - SG_ OCSSensrDataLowerLim : 23|8@0+ (1,0) [0|0] "" XXX - SG_ OCSLevel2Error : 0|1@0+ (1,0) [0|0] "" XXX - SG_ ObjectEntrapped : 2|1@0+ (1,0) [0|0] "" XXX - SG_ OCSLevel1Error : 7|1@0+ (1,0) [0|0] "" XXX - -BO_ 736 FCIM_Button_Press_HS: 8 XXX - SG_ FCIM_Target_ID : 13|4@0+ (1,0) [0|0] "" XXX - SG_ FCIM_Button_Type : 7|8@0+ (1,0) [0|0] "" XXX - SG_ FCIM_Button_State : 15|2@0+ (1,0) [0|0] "" XXX - SG_ FCIM_Target_ID_UB : 23|1@0+ (1,0) [0|0] "" XXX - SG_ FCIM_Button_Type_UB : 9|1@0+ (1,0) [0|0] "" XXX - SG_ FCIM_Button_State_UB : 8|1@0+ (1,0) [0|0] "" XXX - -BO_ 806 Compressor_Req_HS: 8 XXX - SG_ HvacEvap_Te_Rq : 33|10@0+ (0.125,-50.0) [0|0] "Degrees C" XXX - SG_ HvacEvap_Te_Actl : 17|10@0+ (0.125,-50.0) [0|0] "Degrees C" XXX - SG_ HvacAirCond_B_Rq : 7|1@0+ (1,0) [0|0] "" XXX - SG_ HvacEvap_Te_Offst : 1|10@0+ (0.125,-50.0) [0|0] "Degrees C" XXX - -BO_ 832 RCMStatusMessage: 8 XXX - SG_ eCallNotification : 2|2@0+ (1,0) [0|0] "" XXX - SG_ CrashNotification : 5|1@0+ (1,0) [0|0] "" XXX - SG_ ThirdRowBucklePsngr : 57|2@0+ (1,0) [0|0] "" XXX - SG_ ThirdRowBuckleMid : 59|2@0+ (1,0) [0|0] "" XXX - SG_ ThirdRowBuckleDriver : 61|2@0+ (1,0) [0|0] "" XXX - SG_ SecondRowBucklePsngr : 63|2@0+ (1,0) [0|0] "" XXX - SG_ SecondRowBuckleMid : 49|2@0+ (1,0) [0|0] "" XXX - SG_ SecondRowBuckleDriver : 51|2@0+ (1,0) [0|0] "" XXX - SG_ FirstRowBuckleDriver : 55|2@0+ (1,0) [0|0] "" XXX - SG_ RstrnTotalEvntCnt : 43|4@0+ (1,0) [0|0] "" XXX - SG_ RstrnCurrentEvntCnt : 39|8@0+ (1,0) [0|0] "" XXX - SG_ RILReq : 15|2@0+ (1,0) [0|0] "" XXX - SG_ FuelCutoffReq : 13|4@0+ (1,0) [0|0] "" XXX - SG_ SeatbeltIndicatorReq : 9|1@0+ (1,0) [0|0] "" XXX - SG_ SeatbeltChimeReq : 8|1@0+ (1,0) [0|0] "" XXX - SG_ BeltMinderProgConfReq : 21|2@0+ (1,0) [0|0] "" XXX - SG_ BeltMinderLevelReq : 19|4@0+ (1,0) [0|0] "" XXX - SG_ FirstRowBucklePsngr : 53|2@0+ (1,0) [0|0] "" XXX - SG_ InfoLampReq : 29|1@0+ (1,0) [0|0] "" XXX - SG_ GenRedLampReq : 28|1@0+ (1,0) [0|0] "" XXX - SG_ RstrnTextMsgReq : 27|2@0+ (1,0) [0|0] "" XXX - SG_ OCSSerialNumRcvd : 3|1@0+ (1,0) [0|0] "" XXX - SG_ RstrnStatDeployEnbld : 6|1@0+ (1,0) [0|0] "" XXX - SG_ RstrnImpactEvntStatus : 46|3@0+ (1,0) [0|0] "" XXX - SG_ PassRstrnInd_Req : 25|2@0+ (1,0) [0|0] "" XXX - SG_ RstrnStatTrigEvnt : 7|1@0+ (1,0) [0|0] "" XXX - SG_ PsngrFrntDetct_D_Actl : 31|2@0+ (1,0) [0|0] "" XXX - SG_ Beltminder_Warn_Stats : 22|1@0+ (1,0) [0|0] "" XXX - SG_ EDRTriggerEvntSync : 47|1@0+ (1,0) [0|0] "" XXX - -BO_ 842 MassageSeat_Data1_HS: 8 XXX - SG_ SeatLmbrUpDrv_Pc_Actl : 38|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatLmbrMidDrv_Pc_Actl : 30|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatLmbrLoDrv_Pc_Actl : 22|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatBlUpDrv_Pc_Actl : 14|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatBlLoDrv_Pc_Actl : 6|7@0+ (1,0) [0|0] "%" XXX - -BO_ 843 MassageSeat_Data2_HS: 8 XXX - SG_ SeatLmbrUpPsgr_Pc_Actl : 38|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatLmbrMidPsgr_Pc_Actl : 30|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatLmbrLoPsgr_Pc_Actl : 22|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatBlUpPsgr_Pc_Actl : 14|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatBlLoPsgr_Pc_Actl : 6|7@0+ (1,0) [0|0] "%" XXX - -BO_ 844 MassageSeat_Stat1_HS: 8 XXX - SG_ StmsLmbrDrv_D_Stat : 17|2@0+ (1,0) [0|0] "" XXX - SG_ StmsCshnDrv_D_Stat : 19|2@0+ (1,0) [0|0] "" XXX - SG_ SeatSwtchDrv_B_Stat : 31|1@0+ (1,0) [0|0] "" XXX - SG_ SeatFnDrv_D_Stat : 23|3@0+ (1,0) [0|0] "" XXX - SG_ SeatAirAmb_P_Actl : 7|16@0+ (0.01,0) [0|0] "KiloPascal" XXX - SG_ SeatPDrv_B_Stat : 20|1@0+ (1,0) [0|0] "" XXX - -BO_ 845 MassageSeat_Stat2_HS: 8 XXX - SG_ StmsLmbrPsgr_D_Stat : 15|2@0+ (1,0) [0|0] "" XXX - SG_ StmsCshnPsgr_D_Stat : 13|2@0+ (1,0) [0|0] "" XXX - SG_ SeatSwtchPsgr_B_Stat : 11|1@0+ (1,0) [0|0] "" XXX - SG_ SeatPPsgr_B_Stat : 7|1@0+ (1,0) [0|0] "" XXX - SG_ SeatFnPsgr_D_Stat : 6|3@0+ (1,0) [0|0] "" XXX - SG_ PsgrMemFeedback_Rsp : 3|4@0+ (1,0) [0|0] "" XXX - -BO_ 846 MassageSeat_Req: 8 XXX - SG_ SeatFnPsgr_D_Rq : 15|3@0+ (1,0) [0|0] "" XXX - SG_ SeatFnDrv_D_Rq : 12|3@0+ (1,0) [0|0] "" XXX - SG_ SeatFnDfaltPsgr_B_Rq : 9|1@0+ (1,0) [0|0] "" XXX - SG_ SeatFnDfaltDrv_B_Rq : 8|1@0+ (1,0) [0|0] "" XXX - SG_ SeatFnChngPsgr_D_Rq : 7|2@0+ (1,0) [0|0] "" XXX - SG_ SeatFnChngDrv_D_Rq : 5|2@0+ (1,0) [0|0] "" XXX - SG_ PsgrMemory_Rq : 3|4@0+ (1,0) [0|0] "" XXX - -BO_ 848 RestraintsData: 8 XXX - SG_ PassRstrnInd_Stat_UB : 9|1@0+ (1,0) [0|0] "" XXX - SG_ SeatBltWrnChmeStat : 1|1@0+ (1,0) [0|0] "" XXX - SG_ Seatbelt_IndctrStat : 4|3@0+ (1,0) [0|0] "" XXX - SG_ RILStat : 7|2@0+ (1,0) [0|0] "" XXX - SG_ PassRstrnInd_Stat : 15|4@0+ (1,0) [0|0] "" XXX - -BO_ 849 MassageSeat_Data3_HS: 8 XXX - SG_ SeatCshnDrvRR_Pc_Actl : 30|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatCshnDrvRL_Pc_Actl : 22|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatCshnDrvFR_Pc_Actl : 14|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatCshnDrvFL_Pc_Actl : 6|7@0+ (1,0) [0|0] "%" XXX - -BO_ 850 MassageSeat_Data4_HS: 8 XXX - SG_ SeatCshnPsgrRR_Pc_Actl : 30|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatCshnPsgrRL_Pc_Actl : 22|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatCshnPsgrFR_Pc_Actl : 14|7@0+ (1,0) [0|0] "%" XXX - SG_ SeatCshnPsgrFL_Pc_Actl : 6|7@0+ (1,0) [0|0] "%" XXX - -BO_ 853 EFP_CC_Status: 8 XXX - SG_ Save_My_Temp : 59|1@0+ (1,0) [0|0] "" XXX - SG_ Front_Left_Temp_Setpt : 31|8@0+ (1,0) [0|0] "Mixed" XXX - SG_ RrDefrost_HtdMirrorReq : 60|1@0+ (1,0) [0|0] "" XXX - SG_ Rear_Control_Status : 16|1@0+ (1,0) [0|0] "" XXX - SG_ MultipleButtonPressReq : 63|3@0+ (1,0) [0|0] "" XXX - SG_ Rear_System_Mode_Req : 19|3@0+ (1,0) [0|0] "" XXX - SG_ Rear_Left_Temp_Setpt : 47|8@0+ (1,0) [0|0] "Mixed" XXX - SG_ Recirc_Request : 23|2@0+ (1,0) [0|0] "" XXX - SG_ Front_Rt_Temp_Setpt : 39|8@0+ (1,0) [0|0] "Mixed" XXX - SG_ AC_Request : 21|2@0+ (1,0) [0|0] "" XXX - SG_ Windshield_ModeRequest : 15|4@0+ (8.33,0) [0|0] "%" XXX - SG_ Panel_Mode_Request : 7|4@0+ (8.33,0) [0|0] "%" XXX - SG_ Overriding_ModeReq : 10|3@0+ (1,0) [0|0] "" XXX - SG_ Forced_Recirc_Req : 11|1@0+ (1,0) [0|0] "" XXX - SG_ Floor_Mode_Request : 3|4@0+ (8.33,0) [0|0] "%" XXX - SG_ Rear_Right_Temp_Setpt : 55|8@0+ (1,0) [0|0] "Mixed" XXX - -BO_ 854 EFP_CC_Seat_Req_Stat: 8 XXX - SG_ Front_Rear_Blower_Req : 31|6@0+ (1,0) [0|0] "Detents" XXX - SG_ Pass_Rr_Cond_Seat_Req : 21|2@0+ (1,0) [0|0] "" XXX - SG_ Pass_Rr_Cond_Seat_Lvl : 8|3@0+ (1,0) [0|0] "" XXX - SG_ Pass_Fr_Cond_Seat_Req : 13|2@0+ (1,0) [0|0] "" XXX - SG_ Pass_Fr_Cond_Seat_Lvl : 11|3@0+ (1,0) [0|0] "" XXX - SG_ Drvr_Rr_Cond_Seat_Req : 15|2@0+ (1,0) [0|0] "" XXX - SG_ Drvr_Rr_Cond_Seat_Lvl : 2|3@0+ (1,0) [0|0] "" XXX - SG_ Drvr_Fr_Cond_Seat_Req : 7|2@0+ (1,0) [0|0] "" XXX - SG_ Drvr_Fr_Cond_Seat_Lvl : 5|3@0+ (1,0) [0|0] "" XXX - -BO_ 855 RCCM_CC_Status_HS: 8 XXX - SG_ RrBlwrCondStLdShedStat : 25|2@0+ (1,0) [0|0] "" XXX - SG_ FrBlwrCondStLdShedStat : 20|2@0+ (1,0) [0|0] "" XXX - SG_ RCCM_Rr_Rt_TempSetpt : 63|8@0+ (1,0) [0|0] "Mixed" XXX - SG_ RCCM_Rr_Left_TempSetpt : 55|8@0+ (1,0) [0|0] "Mixed" XXX - SG_ RCCM_Fr_Rt_TempSetpt : 47|8@0+ (1,0) [0|0] "Mixed" XXX - SG_ RCCM_Fr_Rr_Blower_Req : 31|6@0+ (1,0) [0|0] "Detents" XXX - SG_ Panel_Mode_State : 7|4@0+ (8.33,0) [0|0] "%" XXX - SG_ RrDefHtdMirrLdShedStat : 18|2@0+ (1,0) [0|0] "" XXX - SG_ Windshield_Mode_State : 15|4@0+ (8.33,0) [0|0] "%" XXX - SG_ Recirc_Door_State : 11|2@0+ (1,0) [0|0] "" XXX - SG_ Rear_System_Mode_State : 23|3@0+ (1,0) [0|0] "" XXX - SG_ Default_Defrost_State : 9|1@0+ (1,0) [0|0] "" XXX - SG_ Auto_AC_Indicator_Temp : 16|1@0+ (1,0) [0|0] "" XXX - SG_ Floor_Mode_State : 3|4@0+ (8.33,0) [0|0] "%" XXX - SG_ RCCM_Fr_Left_TempSetpt : 39|8@0+ (1,0) [0|0] "Mixed" XXX - SG_ RrDefrost_HtdMirrState : 8|1@0+ (1,0) [0|0] "" XXX - -BO_ 856 RCCM_CC_Seat_Status_HS: 8 XXX - SG_ Active_My_Temp : 2|1@0+ (1,0) [0|0] "" XXX - SG_ CC_HtdStrWhl_Req : 24|1@0+ (1,0) [0|0] "" XXX - SG_ RCCM_PR_Cond_Seat_Lvl : 31|3@0+ (1,0) [0|0] "" XXX - SG_ RCCM_PR_Cond_Seat_Req : 28|2@0+ (1,0) [0|0] "" XXX - SG_ RCCM_PF_Cond_Seat_Req : 20|2@0+ (1,0) [0|0] "" XXX - SG_ RCCM_PF_Cond_Seat_Lvl : 23|3@0+ (1,0) [0|0] "" XXX - SG_ RCCM_DR_Cond_Seat_Req : 12|2@0+ (1,0) [0|0] "" XXX - SG_ RCCM_DR_Cond_Seat_Lvl : 15|3@0+ (1,0) [0|0] "" XXX - SG_ RCCM_DF_Cond_Seat_Req : 4|2@0+ (1,0) [0|0] "" XXX - SG_ RCCM_DF_Cond_Seat_Lvl : 7|3@0+ (1,0) [0|0] "" XXX - SG_ PassRrCondStLdShedStat : 26|2@0+ (1,0) [0|0] "" XXX - SG_ PassFrCondStLdShedStat : 18|2@0+ (1,0) [0|0] "" XXX - SG_ DrvRrCondStLdShedStat : 10|2@0+ (1,0) [0|0] "" XXX - SG_ DrvFrCondStLdShedStat : 1|2@0+ (1,0) [0|0] "" XXX - -BO_ 857 RCCM_CC_MBP_Press_Stat_HS: 8 XXX - SG_ MultBtnPushDsplyPass10 : 23|8@0+ (1,0) [0|0] "" XXX - SG_ MultBtnPushDsplyPass1 : 31|8@0+ (1,0) [0|0] "" XXX - SG_ Report_Active : 33|2@0+ (1,0) [0|0] "" XXX - SG_ Pass_Temp_Units : 35|1@0+ (1,0) [0|0] "" XXX - SG_ Front_Fan_Bars_Disply : 39|3@0+ (1,0) [0|0] "" XXX - SG_ Drvr_Temp_Units : 36|1@0+ (1,0) [0|0] "" XXX - SG_ MultBtnPushDsplyDrvr10 : 7|8@0+ (1,0) [0|0] "" XXX - SG_ MultBtnPushDsplyDrvr1 : 15|8@0+ (1,0) [0|0] "" XXX - -BO_ 859 MFD_CC_Status_HS: 8 XXX - SG_ Rear_Mode_Bttn_Status : 38|1@0+ (1,0) [0|0] "" XXX - SG_ ConditionSt_ButtonStat : 20|5@0+ (1,0) [0|0] "" XXX - SG_ Driver_Set_Temp : 31|8@0+ (0.5,0) [0|0] "Degrees" XXX - SG_ Frt_System_Button_Stat : 7|5@0+ (1,0) [0|0] "" XXX - SG_ Rear_Blower_Bar_Status : 2|3@0+ (1,0) [0|0] "# of Bars" XXX - SG_ Rear_Fan_Button_Status : 13|2@0+ (1,0) [0|0] "" XXX - SG_ Rear_Man_Temp_Bar_Stat : 11|4@0+ (1,0) [0|0] "" XXX - SG_ Rear_Temp_Button_Status : 23|2@0+ (1,0) [0|0] "" XXX - SG_ Voice_Blower_Limit : 21|1@0+ (1,0) [0|0] "" XXX - -BO_ 860 EFP_CC_Info_Status: 8 XXX - SG_ Rear_Panel_Btn_State : 41|1@0+ (1,0) [0|0] "" XXX - SG_ Rear_Floor_Btn_State : 40|1@0+ (1,0) [0|0] "" XXX - SG_ HtdStrWhl_SftBtt_Stt : 39|2@0+ (1,0) [0|0] "" XXX - SG_ AC_Sft_Button_State : 23|2@0+ (1,0) [0|0] "" XXX - SG_ DrvRrCondSeatSftBttnSt : 47|3@0+ (1,0) [0|0] "" XXX - SG_ DrvFrCondSeatSftBtnStt : 37|3@0+ (1,0) [0|0] "" XXX - SG_ CC_RecircSBtn_St : 27|2@0+ (1,0) [0|0] "" XXX - SG_ CC_RrDefrSBtn_St : 24|1@0+ (1,0) [0|0] "" XXX - SG_ PasRrCondSeatSftBttnSt : 44|3@0+ (1,0) [0|0] "" XXX - SG_ PasFrCondSeatSftBtnStt : 34|3@0+ (1,0) [0|0] "" XXX - SG_ MyTemp_Soft_Bttn_State : 25|1@0+ (1,0) [0|0] "" XXX - SG_ CC_MaxACSBtn_St : 28|1@0+ (1,0) [0|0] "" XXX - SG_ RearPowerButtonState : 16|1@0+ (1,0) [0|0] "" XXX - SG_ RearCoolBarsDisplayed : 11|3@0+ (1,0) [0|0] "Bars_On" XXX - SG_ Rear_Sft_Control_Stat : 7|2@0+ (1,0) [0|0] "" XXX - SG_ CC_RrNeutralBarDsp_St : 8|1@0+ (1,0) [0|0] "" XXX - SG_ CC_RrHeatBarsDsp_St : 31|3@0+ (1,0) [0|0] "Bars_On" XXX - SG_ Rear_Fan_Bars_Displayed : 19|3@0+ (1,0) [0|0] "" XXX - SG_ CC_RrCtrlBtn_St : 20|1@0+ (1,0) [0|0] "" XXX - SG_ Rear_Auto_Button_State : 21|1@0+ (1,0) [0|0] "" XXX - SG_ CC_FrPowerSBtn_St : 14|1@0+ (1,0) [0|0] "" XXX - SG_ CC_FrDefrostSBtn_St : 15|1@0+ (1,0) [0|0] "" XXX - SG_ Front_AUTO_Soft_Btn_Stt : 13|1@0+ (1,0) [0|0] "" XXX - SG_ Front_AUTO_MODE_State : 1|1@0+ (1,0) [0|0] "" XXX - SG_ Front_AUTO_FAN_State : 0|1@0+ (1,0) [0|0] "" XXX - SG_ Dual_Button_State : 12|1@0+ (1,0) [0|0] "" XXX - SG_ CC_BarPnlSBtn_St : 5|1@0+ (1,0) [0|0] "" XXX - SG_ CC_BarPnFlrSBtn_St : 4|1@0+ (1,0) [0|0] "" XXX - SG_ CC_BarFlrWsSBtn_St : 2|1@0+ (1,0) [0|0] "" XXX - SG_ CC_BarDrvFlrSBtn_St : 3|1@0+ (1,0) [0|0] "" XXX - -BO_ 890 Active_Noise: 8 XXX - SG_ ANC_Chime_Supported : 4|2@0+ (1,0) [0|0] "" XXX - SG_ ActvNseAudio_D_Stat : 7|2@0+ (1,0) [0|0] "" XXX - SG_ ActvNse_B_Actv : 5|1@0+ (1,0) [0|0] "" XXX - -BO_ 891 Active_Noise_Data: 8 XXX - SG_ CabnSndAmb_Db_Actl : 7|8@0+ (1,30.0) [0|0] "decibel" XXX - -BO_ 906 Body_Information_1: 8 XXX - SG_ CcdMde_D_Rq_UB : 0|1@0+ (1,0) [0|0] "" XXX - SG_ CcdMde_D_Rq : 7|2@0+ (1,0) [0|0] "" XXX - SG_ CarMode : 5|4@0+ (1,0) [0|0] "" XXX - SG_ SecondaryHeater_Rqst : 55|1@0+ (1,0) [0|0] "" XXX - SG_ Passenger_Sunload_Raw : 47|8@0+ (5.0,0) [0|0] "W/m^2" XXX - SG_ Driver_Sunload_Raw : 39|8@0+ (5.0,0) [0|0] "W/m^2" XXX - SG_ HvacEvap_Te_Actl_UB : 1|1@0+ (1,0) [0|0] "" XXX - SG_ HvacEvap_Te_Actl : 17|10@0+ (0.125,-50.0) [0|0] "Degrees C" XXX - SG_ SecondaryHeater_Rqst_UB : 18|1@0+ (1,0) [0|0] "" XXX - SG_ Outside_Air_Temp_Stat_UB : 23|1@0+ (1,0) [0|0] "" XXX - SG_ Outside_Air_Temp_Stat : 15|8@0+ (0.5,-40.0) [0|0] "Degrees C" XXX - SG_ Veh_Lock_Status : 54|2@0+ (1,0) [0|0] "" XXX - SG_ Veh_Lock_Requestor : 52|5@0+ (1,0) [0|0] "" XXX - SG_ Veh_Lock_EvNum : 63|8@0+ (1,0) [0|0] "Counts" XXX - SG_ immoIndicatorCmd : 22|4@0+ (1,0) [0|0] "" XXX - -BO_ 909 Body_Information_6: 8 XXX - SG_ PEBackupSlot_Stats_UB : 43|1@0+ (1,0) [0|0] "" XXX - SG_ PEBackupSlot_Stats : 25|2@0+ (1,0) [0|0] "" XXX - SG_ KeyMykeyTot_No_Cnt : 47|4@0+ (1,0) [0|0] "Counts" XXX - SG_ SideDetect_R_SysOpState_UB : 26|1@0+ (1,0) [0|0] "" XXX - SG_ SideDetect_R_SysOpState : 28|2@0+ (1,0) [0|0] "" XXX - SG_ SideDetect_R_SnsrState_UB : 29|1@0+ (1,0) [0|0] "" XXX - SG_ SideDetect_R_SnsrState : 31|2@0+ (1,0) [0|0] "" XXX - SG_ SideDetect_L_SysOpState_UB : 16|1@0+ (1,0) [0|0] "" XXX - SG_ SideDetect_L_SysOpState : 18|2@0+ (1,0) [0|0] "" XXX - SG_ SideDetect_L_SnsrState_UB : 19|1@0+ (1,0) [0|0] "" XXX - SG_ SideDetect_L_SnsrState : 21|2@0+ (1,0) [0|0] "" XXX - SG_ Cross_Traffic_R_SnState_UB : 8|1@0+ (1,0) [0|0] "" XXX - SG_ Cross_Traffic_R_SnState : 23|2@0+ (1,0) [0|0] "" XXX - SG_ Cross_Traffic_R_Op_State_UB : 9|1@0+ (1,0) [0|0] "" XXX - SG_ Cross_Traffic_R_Op_State : 11|2@0+ (1,0) [0|0] "" XXX - SG_ Cross_Traffic_R_Alert_UB : 12|1@0+ (1,0) [0|0] "" XXX - SG_ Cross_Traffic_R_Alert : 14|2@0+ (1,0) [0|0] "" XXX - SG_ Cross_Traffic_L_SnState_UB : 15|1@0+ (1,0) [0|0] "" XXX - SG_ Cross_Traffic_L_SnState : 1|2@0+ (1,0) [0|0] "" XXX - SG_ Cross_Traffic_L_Op_State_UB : 2|1@0+ (1,0) [0|0] "" XXX - SG_ Cross_Traffic_L_Op_State : 4|2@0+ (1,0) [0|0] "" XXX - SG_ Cross_Traffic_L_Alert_UB : 5|1@0+ (1,0) [0|0] "" XXX - SG_ Cross_Traffic_L_Alert : 7|2@0+ (1,0) [0|0] "" XXX - SG_ IgnKeyType_D_Actl : 39|4@0+ (1,0) [0|0] "" XXX - SG_ KeyAdmnTot_No_Cnt : 35|4@0+ (1,0) [0|0] "Counts" XXX - -BO_ 936 ParkAid_Data: 8 XXX - SG_ SAPPErrorCoding : 23|8@0+ (1,0) [0|0] "" XXX - SG_ ExtSteeringAngleReq : 7|15@0+ (0.1,-1000.0) [0|0] "Degrees" XXX - SG_ EPASExtAngleStatReq : 8|1@0+ (1,0) [0|0] "" XXX - -BO_ 937 ParkAid_Range_to_Target: 8 XXX - SG_ RangeToClosestObstacle : 55|12@0+ (1,0) [0|0] "cm" XXX - SG_ RangeRearCornerRtSn : 35|12@0+ (1,0) [0|0] "cm" XXX - SG_ RangeRearCornerLeftSn : 31|12@0+ (1,0) [0|0] "cm" XXX - SG_ RangeRearCenterRtSn : 11|12@0+ (1,0) [0|0] "cm" XXX - SG_ RangeRearCenterLeftSn : 7|12@0+ (1,0) [0|0] "cm" XXX - -BO_ 939 ParkAid_Data_CG1: 8 XXX - SG_ EPASExtAngleStatReq : 7|1@0+ (1,0) [0|0] "" XXX - SG_ ExtSteeringAngleReq : 6|15@0+ (0.1,-1000.0) [0|0] "Degrees" XXX - SG_ SAPPErrorCoding : 23|8@0+ (1,0) [0|0] "" XXX - SG_ RangeToClosestObstacle : 27|12@0+ (1,0) [0|0] "cm" XXX - -BO_ 942 BodyInformation_2: 8 XXX - SG_ Easy_Entry_Exit_Stat : 14|2@0+ (1,0) [0|0] "" XXX - SG_ Memory_Feedback_Rqst : 15|1@0+ (1,0) [0|0] "" XXX - SG_ Delay_Accy : 41|1@0+ (1,0) [0|0] "" XXX - SG_ Fuel_Econ_AFE_Reset_Req_UB : 43|1@0+ (1,0) [0|0] "" XXX - SG_ Multimedia_System : 42|1@0+ (1,0) [0|0] "" XXX - SG_ DrStatDrv_B_Actl : 7|1@0+ (1,0) [0|0] "" XXX - SG_ DrStatHood_B_Actl : 6|1@0+ (1,0) [0|0] "" XXX - SG_ DrStatInnrTgate_B_Actl : 5|1@0+ (1,0) [0|0] "" XXX - SG_ DrStatPsngr_B_Actl : 4|1@0+ (1,0) [0|0] "" XXX - SG_ DrStatRl_B_Actl : 3|1@0+ (1,0) [0|0] "" XXX - SG_ DrStatRr_B_Actl : 2|1@0+ (1,0) [0|0] "" XXX - SG_ DrStatTgate_B_Actl : 1|1@0+ (1,0) [0|0] "" XXX - SG_ Fuel_Econ_AFE_Reset_Req : 0|1@0+ (1,0) [0|0] "" XXX - SG_ Nav_Unit_Setting : 11|1@0+ (1,0) [0|0] "" XXX - SG_ Cancel_Auto_Movement : 9|1@0+ (1,0) [0|0] "" XXX - SG_ Cancel_Auto_Movement_UB : 8|1@0+ (1,0) [0|0] "" XXX - SG_ DrvSeat_Stat : 34|3@0+ (1,0) [0|0] "" XXX - SG_ DrvSeat_Stat_UB : 10|1@0+ (1,0) [0|0] "" XXX - SG_ Easy_Entry_Rqst : 47|2@0+ (1,0) [0|0] "" XXX - SG_ Easy_Entry_Rqst_UB : 12|1@0+ (1,0) [0|0] "" XXX - SG_ Multimedia_System_UB : 40|1@0+ (1,0) [0|0] "" XXX - SG_ Memory_Cmd : 39|4@0+ (1,0) [0|0] "" XXX - SG_ Memory_Cmd_UB : 35|1@0+ (1,0) [0|0] "" XXX - SG_ Memory_Feedback_Rqst_UB : 45|1@0+ (1,0) [0|0] "" XXX - SG_ Decklid_Ajar_Status : 44|1@0+ (1,0) [0|0] "" XXX - -BO_ 947 BodyInformation_3: 8 XXX - SG_ RearFog_Lamp_Ind_UB : 49|1@0+ (1,0) [0|0] "" XXX - SG_ RearFog_Lamp_Ind : 50|1@0+ (1,0) [0|0] "" XXX - SG_ PwMdeExten_D_Actl : 63|5@0+ (1,0) [0|0] "" XXX - SG_ Turn_Ind_Cmd_Right : 8|1@0+ (1,0) [0|0] "" XXX - SG_ Turn_Ind_Cmd_Left : 9|1@0+ (1,0) [0|0] "" XXX - SG_ Ignition_Switch_Stable : 1|2@0+ (1,0) [0|0] "" XXX - SG_ Parklamp_Status : 3|2@0+ (1,0) [0|0] "" XXX - SG_ Litval : 47|8@0+ (1,0) [0|0] "" XXX - SG_ Key_In_Ignition_Stat : 11|2@0+ (1,0) [0|0] "" XXX - SG_ Ignition_Status : 7|4@0+ (1,0) [0|0] "" XXX - SG_ Dimming_Lvl : 31|8@0+ (1,0) [0|0] "" XXX - SG_ Day_Night_Status : 15|2@0+ (1,0) [0|0] "" XXX - SG_ Remote_Start_Status : 13|2@0+ (1,0) [0|0] "" XXX - SG_ DRV_SELECT_STAT : 19|4@0+ (1,0) [0|0] "" XXX - SG_ PrkBrkActv_B_Actl : 55|1@0+ (1,0) [0|0] "" XXX - SG_ HtdStrWhl_SftBtt_State_UB : 51|1@0+ (1,0) [0|0] "" XXX - SG_ HtdStrWhl_SftBtt_State : 53|2@0+ (1,0) [0|0] "" XXX - SG_ HvacRemoteStrt_N_Rq_UB : 56|1@0+ (1,0) [0|0] "" XXX - SG_ HvacRemoteStrt_N_Rq : 23|4@0+ (100.0,450.0) [0|0] "RPM" XXX - SG_ HvacAirCond_B_Rq_UB : 57|1@0+ (1,0) [0|0] "" XXX - SG_ Remote_Start_Warn_Req : 54|1@0+ (1,0) [0|0] "" XXX - SG_ HvacAirCond_B_Rq : 58|1@0+ (1,0) [0|0] "" XXX - -BO_ 948 Tire_Pressure_Status: 8 XXX - SG_ Tire_Press_ILR_Stat2 : 27|4@0+ (1,0) [0|0] "" XXX - SG_ Tire_Press_IRR_Stat2 : 31|4@0+ (1,0) [0|0] "" XXX - SG_ Tire_Press_LR_OLR_Stat2 : 19|4@0+ (1,0) [0|0] "" XXX - SG_ Tire_Press_RR_ORR_Stat2 : 23|4@0+ (1,0) [0|0] "" XXX - SG_ Tire_Press_RF_Stat2 : 11|4@0+ (1,0) [0|0] "" XXX - SG_ Tire_Press_LF_Stat2 : 15|4@0+ (1,0) [0|0] "" XXX - SG_ Tire_Press_System_Stat2 : 7|4@0+ (1,0) [0|0] "" XXX - SG_ Tire_Press_Telltale : 3|2@0+ (1,0) [0|0] "" XXX - -BO_ 949 Tire_Pressure_Data: 8 XXX - SG_ Tire_Press_RR_ORR_Data : 23|8@0+ (1,0) [0|0] "Psi" XXX - SG_ Tire_Press_RF_Data : 15|8@0+ (1,0) [0|0] "Psi" XXX - SG_ Tire_Press_LR_OLR_Data : 31|8@0+ (1,0) [0|0] "Psi" XXX - SG_ Tire_Press_IRR_Data : 39|8@0+ (1,0) [0|0] "Psi" XXX - SG_ Tire_Press_ILR_Data : 47|8@0+ (1,0) [0|0] "Psi" XXX - SG_ Tire_Press_LF_Data : 7|8@0+ (1,0) [0|0] "Psi" XXX - -BO_ 955 Smart_Headlamp_Stat: 8 XXX - SG_ Headlamp_Switch_Stat : 7|2@0+ (1,0) [0|0] "" XXX - SG_ Fog_Lamp_Dbnce : 5|2@0+ (1,0) [0|0] "" XXX - SG_ Digital_Dimmer_Sw_Stat : 3|3@0+ (1,0) [0|0] "" XXX - -BO_ 957 Rear_FogLamp: 8 XXX - SG_ RearFog_Lamp_Dbnce : 7|1@0+ (1,0) [0|0] "" XXX - -BO_ 963 BCM_to_HS_Body: 8 XXX - SG_ DrTgateChime_D_Rq_UB : 9|1@0+ (1,0) [0|0] "" XXX - SG_ DrTgateChime_D_Rq : 17|2@0+ (1,0) [0|0] "" XXX - SG_ CamraDefog_B_Actl : 4|1@0+ (1,0) [0|0] "" XXX - SG_ Reverse_Mirror_Stat : 61|2@0+ (1,0) [0|0] "" XXX - SG_ Power_Liftgate_Mode_Stat : 63|2@0+ (1,0) [0|0] "" XXX - SG_ IKT_Program_Status : 51|2@0+ (1,0) [0|0] "" XXX - SG_ Veh_Spd_Slow_Puddle_Status : 41|2@0+ (1,0) [0|0] "" XXX - SG_ Illuminated_Exit_Status : 43|2@0+ (1,0) [0|0] "" XXX - SG_ Illuminated_Entry_Status : 45|2@0+ (1,0) [0|0] "" XXX - SG_ Door_Courtesy_Light_Status : 47|2@0+ (1,0) [0|0] "" XXX - SG_ Courtesy_Demand_BSave_Stat : 33|2@0+ (1,0) [0|0] "" XXX - SG_ Alarm_Lights_Courtesy_Stat : 35|2@0+ (1,0) [0|0] "" XXX - SG_ Courtesy_Delay_Status : 37|2@0+ (1,0) [0|0] "" XXX - SG_ Courtesy_Mode_Status : 39|2@0+ (1,0) [0|0] "" XXX - SG_ Front_Fog_Light_SW_Status : 22|2@0+ (1,0) [0|0] "" XXX - SG_ Brake_Lamp_On_Status : 23|1@0+ (1,0) [0|0] "" XXX - SG_ LowBeam_CKT_CAN : 11|1@0+ (1,0) [0|0] "" XXX - SG_ ParkLamps_CKT_CAN : 8|1@0+ (1,0) [0|0] "" XXX - SG_ RF_Low_Beam_CKT_CAN : 13|1@0+ (1,0) [0|0] "" XXX - SG_ Brk_Fluid_Lvl_Low : 15|2@0+ (1,0) [0|0] "" XXX - SG_ LF_Low_Beam_CKT_CAN : 12|1@0+ (1,0) [0|0] "" XXX - SG_ High_Beam_Indicator_Rqst : 1|1@0+ (1,0) [0|0] "" XXX - SG_ Brake_Warn_Indicator_Rqst : 2|1@0+ (1,0) [0|0] "" XXX - SG_ Headlamp_On_Wrning_Cmd : 6|1@0+ (1,0) [0|0] "" XXX - SG_ Key_In_Ignition_Warn_Cmd : 5|1@0+ (1,0) [0|0] "" XXX - SG_ Fog_Lamps_Rly_Ckt_CAN : 10|1@0+ (1,0) [0|0] "" XXX - SG_ Power_Liftgate_Mode_Stat_UB : 18|1@0+ (1,0) [0|0] "" XXX - SG_ Reverse_Mirror_Stat_UB : 7|1@0+ (1,0) [0|0] "" XXX - SG_ Park_Brake_Chime_Rqst : 3|1@0+ (1,0) [0|0] "" XXX - SG_ Daytime_Running_Lamps : 0|1@0+ (1,0) [0|0] "" XXX - SG_ Running_Board_Stat_UB : 56|1@0+ (1,0) [0|0] "" XXX - SG_ Running_Board_Stat : 58|2@0+ (1,0) [0|0] "" XXX - SG_ Perimeter_Alarm_Chime_Rqst : 20|2@0+ (1,0) [0|0] "" XXX - -BO_ 967 CMPS_FDM_Info_Status: 8 XXX - SG_ CamraFrntStat_D_Stat : 41|2@0+ (1,0) [0|0] "" XXX - SG_ Zone_Icon_UB : 34|1@0+ (1,0) [0|0] "" XXX - SG_ GPS_Compass_direction : 47|4@0+ (1,0) [0|0] "" XXX - SG_ Segment_MSD_UB : 37|1@0+ (1,0) [0|0] "" XXX - SG_ Segment_LSD_UB : 36|1@0+ (1,0) [0|0] "" XXX - SG_ ExcessiveMagnetism : 32|1@0+ (1,0) [0|0] "" XXX - SG_ Compass_Display_UB : 35|1@0+ (1,0) [0|0] "" XXX - SG_ Segment_LSD : 15|8@0+ (1,0) [0|0] "" XXX - SG_ Segment_MSD : 7|8@0+ (1,0) [0|0] "" XXX - SG_ Cal_Icon : 21|1@0+ (1,0) [0|0] "" XXX - SG_ Zone_Icon : 22|1@0+ (1,0) [0|0] "" XXX - SG_ Compass_Display : 23|1@0+ (1,0) [0|0] "" XXX - SG_ Cal_Icon_UB : 33|1@0+ (1,0) [0|0] "" XXX - SG_ RearCameraDelayStat : 39|2@0+ (1,0) [0|0] "" XXX - SG_ CamraOvrlTow_D_Actl : 25|2@0+ (1,0) [0|0] "SE" XXX - SG_ CamZoomActiveState : 29|2@0+ (1,0) [0|0] "" XXX - SG_ CamraZoomMan_D_Actl : 18|3@0+ (1,0) [0|0] "" XXX - SG_ CamraOvrlStat_D_Actl : 27|2@0+ (1,0) [0|0] "" XXX - SG_ CamraOvrlDyn_D_Actl : 20|2@0+ (1,0) [0|0] "" XXX - SG_ CamPDCGuidStat : 31|2@0+ (1,0) [0|0] "" XXX - -BO_ 970 Lane_Assist_Data1: 8 XXX - SG_ LkaActvStats_D_Req : 7|3@0+ (1,0) [0|0] "" XXX - SG_ LdwActvStats_D_Req : 4|3@0+ (1,0) [0|0] "" XXX - SG_ LdwActvIntns_D_Req : 1|2@0+ (1,0) [0|0] "" XXX - -BO_ 971 Lane_Assist_Data2: 8 XXX - SG_ LaRefAng_No_Req : 19|12@0+ (0.05,-102.4) [0|0] "mrad" XXX - SG_ LaRampType_B_Req : 4|1@0+ (1,0) [0|0] "" XXX - SG_ LaCurvature_No_Calc : 3|12@0+ (5e-06,-0.01) [0|0] "1/m" XXX - -BO_ 972 Lane_Assist_Data3: 8 XXX - SG_ LaHandsOff_B_Actl : 7|1@0+ (1,0) [0|0] "" XXX - SG_ LaActDeny_B_Actl : 6|1@0+ (1,0) [0|0] "" XXX - SG_ LaActAvail_D_Actl : 5|2@0+ (1,0) [0|0] "" XXX - -BO_ 984 IPMA_Data: 8 XXX - SG_ LaSwtch_D_RqDrv : 45|1@0+ (1,0) [0|0] "" XXX - SG_ DasWarn_D_Dsply : 44|2@0+ (1,0) [0|0] "" XXX - SG_ DasStats_D_Dsply : 47|2@0+ (1,0) [0|0] "" XXX - SG_ DasAlrtLvl_D_Dsply : 55|3@0+ (1,0) [0|0] "" XXX - SG_ CamraStats_D_Dsply : 35|2@0+ (1,0) [0|0] "" XXX - SG_ CamraDefog_B_Req : 36|1@0+ (1,0) [0|0] "" XXX - SG_ LaSwtchStat_No_Actl : 63|1@0+ (1,0) [0|0] "" XXX - SG_ LaHandsOff_D_Dsply : 42|2@0+ (1,0) [0|0] "" XXX - SG_ LaDenyStats_B_Dsply : 40|1@0+ (1,0) [0|0] "" XXX - SG_ LaActvStats_D_Dsply : 52|5@0+ (1,0) [0|0] "" XXX - SG_ AhbcHiBeam_D_Rq : 33|2@0+ (1,0) [0|0] "" XXX - SG_ PersIndexIpma_D_Actl : 39|3@0+ (1,0) [0|0] "" XXX - SG_ FeatNoIpmaActl : 23|16@0+ (1,0) [0|0] "Number" XXX - SG_ FeatConfigIpmaActl : 7|16@0+ (1,0) [0|0] "" XXX - -BO_ 986 Personality_APIM_Data3: 8 XXX - SG_ LightAmbIntSwtchInc_B : 22|1@0+ (1,0) [0|0] "" XXX - SG_ LightAmbIntSwtchDec_B : 21|1@0+ (1,0) [0|0] "" XXX - SG_ LightAmbIntsty_No_Rq : 15|8@0+ (1,0) [0|0] "% Intensity" XXX - SG_ LightAmbColor_No_Rq : 7|8@0+ (1,0) [0|0] "Color Index" XXX - SG_ LightAmbClrSwtchInc_B : 20|1@0+ (1,0) [0|0] "" XXX - SG_ LightAmbClrSwtchDec_B : 23|1@0+ (1,0) [0|0] "" XXX - -BO_ 991 Personality_VDM_Data: 8 XXX - SG_ PersIndexVdm_D_Actl : 39|3@0+ (1,0) [0|0] "" XXX - SG_ FeatNoVdmActl : 23|16@0+ (1,0) [0|0] "Number" XXX - SG_ FeatConfigVdmActl : 7|16@0+ (1,0) [0|0] "" XXX - -BO_ 992 Personality_IPC_Data: 8 XXX - SG_ MsgCntrPersIndex_D_Rq : 39|3@0+ (1,0) [0|0] "" XXX - SG_ MsgCntrFeatConfigRq : 23|16@0+ (1,0) [0|0] "" XXX - SG_ MsgCntrFeatNoRq : 7|16@0+ (1,0) [0|0] "Number" XXX - SG_ MsgCntrDsplyOp_D_Rq : 36|3@0+ (1,0) [0|0] "" XXX - -BO_ 993 Personality_Data_HS: 8 XXX - SG_ PersSetupRestr_D_Actl : 21|2@0+ (1,0) [0|0] "" XXX - SG_ PersSetupAccessCtrl : 19|1@0+ (1,0) [0|0] "SES" XXX - SG_ PersSetup_No_Actl : 31|16@0+ (1,0) [0|0] "Number" XXX - SG_ PersConflict_D_Actl : 22|1@0+ (1,0) [0|0] "" XXX - SG_ AssocConfirm_D_Actl : 15|3@0+ (1,0) [0|0] "" XXX - SG_ RecallEvent_No_Cnt : 7|8@0+ (1,0) [0|0] "Counts" XXX - SG_ PersNo_D_Actl : 10|3@0+ (1,0) [0|0] "" XXX - SG_ PersStore_D_Actl_UB : 23|1@0+ (1,0) [0|0] "" XXX - SG_ PersStore_D_Actl : 12|2@0+ (1,0) [0|0] "" XXX - -BO_ 994 Personality_APIM_Data: 8 XXX - SG_ CamraOvrlTow_D_Rq : 42|1@0+ (1,0) [0|0] "" XXX - SG_ Pers4OptIn_B_Stats : 43|1@0+ (1,0) [0|0] "" XXX - SG_ Pers3OptIn_B_Stats : 33|1@0+ (1,0) [0|0] "" XXX - SG_ Pers2OptIn_B_Stats : 32|1@0+ (1,0) [0|0] "" XXX - SG_ Pers1OptIn_B_Stats : 44|1@0+ (1,0) [0|0] "" XXX - SG_ CtrStkPersIndex_D_Actl : 39|3@0+ (1,0) [0|0] "" XXX - SG_ CtrStkFeatNoActl : 23|16@0+ (1,0) [0|0] "" XXX - SG_ PersStore_D_Rq : 36|3@0+ (1,0) [0|0] "" XXX - SG_ CtrStkFeatConfigActl : 7|16@0+ (1,0) [0|0] "" XXX - SG_ CtrStkDsplyOp_D_Rq : 47|3@0+ (1,0) [0|0] "" XXX - -BO_ 995 Personality_BCM_Data: 8 XXX - SG_ PersIndexBcm_D_Actl : 39|3@0+ (1,0) [0|0] "" XXX - SG_ FeatNoBcm_No_Actl : 23|16@0+ (1,0) [0|0] "Number" XXX - SG_ FeatConfigBcmActl : 7|16@0+ (1,0) [0|0] "" XXX - -BO_ 996 Personality_HCMB_Data_HS: 8 XXX - SG_ PersIndexHcmb_D_Actl_UB : 34|1@0+ (1,0) [0|0] "" XXX - SG_ PersIndexHcmb_D_Actl : 39|3@0+ (1,0) [0|0] "" XXX - SG_ FeatNoHcmbActl_UB : 35|1@0+ (1,0) [0|0] "" XXX - SG_ FeatNoHcmbActl : 23|16@0+ (1,0) [0|0] "Number" XXX - SG_ FeatConfigHcmbActl_UB : 36|1@0+ (1,0) [0|0] "" XXX - SG_ FeatConfigHcmbActl : 7|16@0+ (1,0) [0|0] "" XXX - -BO_ 997 Personality_CCM_Data: 8 XXX - SG_ PersIndexCcm_D_Actl : 39|3@0+ (1,0) [0|0] "" XXX - SG_ FeatNoCcmActl : 23|16@0+ (1,0) [0|0] "Number" XXX - SG_ FeatConfigCcmActl : 7|16@0+ (1,0) [0|0] "" XXX - -BO_ 998 Personality_SCCM_Data: 8 XXX - SG_ PersIndexSccm_D_Actl : 39|3@0+ (1,0) [0|0] "" XXX - SG_ FeatNoSccmActl : 23|16@0+ (1,0) [0|0] "Number" XXX - SG_ FeatConfigSccmActl : 7|16@0+ (1,0) [0|0] "" XXX - -BO_ 999 Personality_HVAC_Data_HS: 8 XXX - SG_ LightAmbIntsty_No_Actl_UB : 33|1@0+ (1,0) [0|0] "" XXX - SG_ LightAmbIntsty_No_Actl : 55|8@0+ (1,0) [0|0] "% Intensity" XXX - SG_ LightAmbColor_No_Actl_UB : 32|1@0+ (1,0) [0|0] "" XXX - SG_ LightAmbColor_No_Actl : 47|8@0+ (1,0) [0|0] "Color Index" XXX - SG_ PersIndexHvac_D_Actl_UB : 34|1@0+ (1,0) [0|0] "" XXX - SG_ FeatNoHvacActl_UB : 35|1@0+ (1,0) [0|0] "" XXX - SG_ FeatConfigHvacActl_UB : 36|1@0+ (1,0) [0|0] "" XXX - SG_ PersIndexHvac_D_Actl : 39|3@0+ (1,0) [0|0] "" XXX - SG_ FeatNoHvacActl : 23|16@0+ (1,0) [0|0] "Number" XXX - SG_ FeatConfigHvacActl : 7|16@0+ (1,0) [0|0] "" XXX - -BO_ 1001 Personality_RFA_Data_HS: 8 XXX - SG_ PersIndexRfa_D_Actl_UB : 34|1@0+ (1,0) [0|0] "" XXX - SG_ FeatNoRfaActl_UB : 35|1@0+ (1,0) [0|0] "" XXX - SG_ FeatConfigRfaActl_UB : 36|1@0+ (1,0) [0|0] "" XXX - SG_ PersIndexRfa_D_Actl : 39|3@0+ (1,0) [0|0] "" XXX - SG_ FeatNoRfaActl : 23|16@0+ (1,0) [0|0] "Number" XXX - SG_ FeatConfigRfaActl : 7|16@0+ (1,0) [0|0] "" XXX - -BO_ 1002 Personality_APIM_Data2: 8 XXX - SG_ PersIndexApim_D_Actl : 63|3@0+ (1,0) [0|0] "" XXX - SG_ FeatNoApimActl : 39|16@0+ (1,0) [0|0] "Number" XXX - SG_ FeatConfigApimActl : 23|16@0+ (1,0) [0|0] "Number" XXX - SG_ CntrStkKeycodeActl : 7|16@0+ (1,0) [0|0] "" XXX - SG_ CntrStk_D_RqRecall : 52|3@0+ (1,0) [0|0] "" XXX - SG_ CntrStk_D_RqAssoc : 55|3@0+ (1,0) [0|0] "" XXX - -BO_ 1003 Personality_IPC_Data_2: 8 XXX - SG_ PersIndexIpc_D_Actl : 34|3@0+ (1,0) [0|0] "" XXX - SG_ FeatNoIpcActl : 23|16@0+ (1,0) [0|0] "Number" XXX - SG_ FeatConfigIpcActl : 7|16@0+ (1,0) [0|0] "" XXX - -BO_ 1004 Personality_DSM_Data_HS: 8 XXX - SG_ PersIndexDsm_D_Actl_UB : 34|1@0+ (1,0) [0|0] "" XXX - SG_ PersIndexDsm_D_Actl : 39|3@0+ (1,0) [0|0] "" XXX - SG_ FeatNoDsmActl_UB : 35|1@0+ (1,0) [0|0] "" XXX - SG_ FeatNoDsmActl : 23|16@0+ (1,0) [0|0] "Number" XXX - SG_ FeatConfigDsmActl_UB : 36|1@0+ (1,0) [0|0] "" XXX - SG_ FeatConfigDsmActl : 7|16@0+ (1,0) [0|0] "" XXX - -BO_ 1005 Personality_RHVAC_Data_HS: 8 XXX - SG_ PersIndexRhvac_D_Actl_UB : 34|1@0+ (1,0) [0|0] "" XXX - SG_ FeatNoRhvacActl_UB : 33|1@0+ (1,0) [0|0] "" XXX - SG_ FeatConfigRhvacActl_UB : 32|1@0+ (1,0) [0|0] "" XXX - SG_ PersIndexRhvac_D_Actl : 39|3@0+ (1,0) [0|0] "" XXX - SG_ FeatNoRhvacActl : 23|16@0+ (1,0) [0|0] "Number" XXX - SG_ FeatConfigRhvacActl : 7|16@0+ (1,0) [0|0] "" XXX - -BO_ 1031 Diesel_Data_Legacy_1: 8 XXX - SG_ W2S_COMMAND : 7|1@0+ (1,0) [0|0] "" XXX - SG_ TURBO_BOOST : 1|10@0+ (0.1,-30.0) [0|0] "PSI" XXX - SG_ IDLE_ENGINE_SHUTDOWN : 42|2@0+ (1,0) [0|0] "" XXX - -BO_ 1034 GGCC_Config_Mgmt_ID_1: 8 XXX - SG_ VehicleGGCCData : 7|64@0+ (1,0) [0|0] "mixed" XXX - -BO_ 1036 Desired_Torq_BrkSys_Stat: 8 XXX - SG_ BRK_TC_TEMPORARILY_UNAVAIL : 47|1@0+ (1,0) [0|0] "" XXX - SG_ TRLR_SWAY_EVNT_IN_PROGRESS : 22|1@0+ (1,0) [0|0] "" XXX - -BO_ 1043 ADAPTIVE_HEADLAMP_STAT: 8 XXX - SG_ ADAPTIVE_HEADLAMP_FAILURE : 7|1@0+ (1,0) [0|0] "" XXX - -BO_ 1044 AccelerationData: 8 XXX - SG_ VehVertComp_A_Actl : 1|10@0+ (0.01,-0.4) [0|0] "m/s^2" XXX - SG_ VehRolComp_W_Actl : 19|12@0+ (0.0002,-0.82) [0|0] "rad/s" XXX - SG_ VehYawNonLin_W_Rq : 51|12@0+ (0.03663,-75.0) [0|0] "deg/s" XXX - SG_ VehYawLin_W_Rq : 35|12@0+ (0.03663,-75.0) [0|0] "deg/s" XXX - -BO_ 1045 BrakeSysFeatures: 8 XXX - SG_ TCMode : 34|1@0+ (1,0) [0|0] "" XXX - SG_ DrvSlipCtlLamp_D_Rq : 63|2@0+ (1,0) [0|0] "" XXX - SG_ RSCMode : 48|1@0+ (1,0) [0|0] "" XXX - SG_ EBAMode : 40|1@0+ (1,0) [0|0] "" XXX - SG_ DrvAntiLckLamp_D_Rq : 17|2@0+ (1,0) [0|0] "" XXX - SG_ ChimeBrk_B_Rq : 38|1@0+ (1,0) [0|0] "" XXX - SG_ BrkLamp_B_Rq : 39|1@0+ (1,0) [0|0] "" XXX - SG_ VehVActlBrk_No_Cs : 31|8@0+ (1,0) [0|0] "" XXX - SG_ VehVActlBrk_No_Cnt : 23|4@0+ (1,0) [0|0] "" XXX - SG_ Veh_V_ActlBrk : 7|16@0+ (0.01,0) [0|0] "kph" XXX - SG_ DrvSlipCtlMde_D_Ind : 33|2@0+ (1,0) [0|0] "" XXX - SG_ VehRol_An_Dsply : 55|7@0+ (1,-64.0) [0|0] "Degrees" XXX - SG_ VehPtch_An_Dsply : 47|7@0+ (1,-64.0) [0|0] "Degrees" XXX - SG_ VehVActlBrk_D_Qf : 19|2@0+ (1,0) [0|0] "" XXX - SG_ HILL_DESC_MC : 37|3@0+ (1,0) [0|0] "" XXX - -BO_ 1046 BrakeSysFeatures_2: 8 XXX - SG_ BpedMove_No_Cs : 23|8@0+ (1,0) [0|0] "" XXX - SG_ BpedMove_No_Cnt : 3|4@0+ (1,0) [0|0] "" XXX - SG_ BpedMove_D_Actl : 7|2@0+ (1,0) [0|0] "" XXX - SG_ AbsMduleAlive_No_Cnt : 39|4@0+ (1,0) [0|0] "" XXX - SG_ Abs_No_Cs : 31|8@0+ (1,0) [0|0] "" XXX - SG_ BrkAsst_B_Actl : 33|1@0+ (1,0) [0|0] "" XXX - SG_ StabCtlBrk_B_Avail : 4|1@0+ (1,0) [0|0] "" XXX - SG_ DrvHdcWarnInfo_D_Rq : 35|2@0+ (1,0) [0|0] "" XXX - SG_ DrvHdcMsg_D_Rq : 10|3@0+ (1,0) [0|0] "" XXX - SG_ DrvHdcLampInfo_D_Rq : 12|2@0+ (1,0) [0|0] "" XXX - SG_ Abs_B_Falt : 5|1@0+ (1,0) [0|0] "" XXX - SG_ VehLongComp_A_Actl : 49|10@0+ (0.035,-17.9) [0|0] "m/s^2" XXX - SG_ TRAILER_SWAY_CONFIG_STAT : 32|1@0+ (1,0) [0|0] "" XXX - SG_ VehLatComp_A_Actl : 47|10@0+ (0.035,-17.9) [0|0] "m/s^2" XXX - -BO_ 1047 TractionCtrlStatus_CG1: 8 XXX - SG_ EngEotcCtlMde_B_Ind : 3|1@0+ (1,0) [0|0] "" XXX - SG_ YawStabilityIndex : 48|9@0+ (1,-256.0) [0|0] "%" XXX - SG_ TCS_ENG_FAILD : 0|1@0+ (1,0) [0|0] "" XXX - SG_ TCS_ENG_ONLY_PRESENT : 1|1@0+ (1,0) [0|0] "" XXX - SG_ TCS_BRK_FAILD : 2|1@0+ (1,0) [0|0] "" XXX - SG_ PrplWhlTqRqMn_No_Cnt : 47|4@0+ (1,0) [0|0] "" XXX - SG_ PrplWhlTot_Tq_RqMn : 23|16@0+ (4.0,-131072.0) [0|0] "Nm" XXX - SG_ EngEotcCtlLamp_D_Rq : 9|2@0+ (1,0) [0|0] "" XXX - SG_ PrplWhlTqRqMn_No_Cs : 39|8@0+ (1,0) [0|0] "" XXX - SG_ HdcMde_D_Actl : 12|3@0+ (1,0) [0|0] "" XXX - SG_ VehicleDir_D_Est : 5|2@0+ (1,0) [0|0] "" XXX - SG_ TracCtlPtActv_B_Actl : 6|1@0+ (1,0) [0|0] "" XXX - -BO_ 1056 PowertrainData_1_CG1: 8 XXX - SG_ FUEL_ALCOHOL_PERCNT : 63|8@0+ (0.3937008,0) [0|0] "%" XXX - SG_ TrnTotTq_Rt_Est : 39|16@0+ (0.001,0) [0|0] "" XXX - SG_ TrnTotLss_Tq_Est : 31|8@0+ (0.5,0) [0|0] "Nm" XXX - SG_ ECMMILRequest : 9|2@0+ (1,0) [0|0] "" XXX - SG_ AirCondFluidHi_P_Actl : 55|8@0+ (0.125,0) [0|0] "bar" XXX - SG_ OilPressureWarning : 18|1@0+ (1,0) [0|0] "" XXX - SG_ CluPdlPos_Pc_Meas : 7|10@0+ (0.1,0) [0|0] "%" XXX - SG_ VehVLimStat_D_Actl : 12|3@0+ (1,0) [0|0] "" XXX - SG_ VehVLimActv_B_Actl : 13|1@0+ (1,0) [0|0] "" XXX - SG_ CluPdlPosPcMeas_D_Qf : 17|2@0+ (1,0) [0|0] "" XXX - SG_ CoolantFanStepAct : 23|5@0+ (1,0) [0|0] "Steps" XXX - -BO_ 1058 PowertrainData_2_CG1: 8 XXX - SG_ EngIdlShutDown_D_Stat : 19|2@0+ (1,0) [0|0] "" XXX - SG_ EngAout2_Tq_Actl : 55|11@0+ (1,-500.0) [0|0] "Nm" XXX - SG_ EngMsgTxt_D_Rq : 21|2@0+ (1,0) [0|0] "" XXX - SG_ EngClnt_Te_ActlDiag : 39|8@0+ (1,-40.0) [0|0] "degC" XXX - SG_ ThrPos_Pc_CalcDiag : 7|8@0+ (0.392157,0) [0|0] "%" XXX - SG_ EngLoad_Pc_CalcDiag : 47|8@0+ (0.392157,0) [0|0] "%" XXX - SG_ EngAirIn_Te_Actl : 15|10@0+ (0.25,-128.0) [0|0] "degC" XXX - SG_ ApedPos_Pc_ActlDiag : 31|8@0+ (0.392157,0) [0|0] "%" XXX - -BO_ 1064 StrgWheel_PolicePkg: 8 XXX - SG_ PoliceAux4Lamp_B_Rq : 4|1@0+ (1,0) [0|0] "" XXX - SG_ PoliceAux3Lamp_B_Rq : 5|1@0+ (1,0) [0|0] "" XXX - SG_ PoliceAux2Lamp_B_Rq : 6|1@0+ (1,0) [0|0] "" XXX - SG_ PoliceAux1Lamp_B_Rq : 7|1@0+ (1,0) [0|0] "" XXX - -BO_ 1067 Battery_Mgmt_1: 8 XXX - SG_ AlternatorExcDutyCycle : 31|5@0+ (3.22581,0) [0|0] "%" XXX - SG_ EngineEffStatus : 39|2@0+ (1,0) [0|0] "" XXX - SG_ AvailableCurrentAtIdle : 23|8@0+ (1,0) [0|0] "Amps" XXX - SG_ AvailableCurrent : 15|8@0+ (1,0) [0|0] "Amps" XXX - SG_ ActualCurrent : 7|8@0+ (1,0) [0|0] "Amps" XXX - SG_ NoAlternatorResponse : 26|1@0+ (1,0) [0|0] "" XXX - SG_ AlternatorTempFault : 25|1@0+ (1,0) [0|0] "" XXX - SG_ AlternatorMechFault : 24|1@0+ (1,0) [0|0] "" XXX - SG_ AlternatorElFault : 37|1@0+ (1,0) [0|0] "" XXX - -BO_ 1068 Battery_Mgmt_2: 8 XXX - SG_ ChargeMode : 39|3@0+ (1,0) [0|0] "" XXX - SG_ ChargeVoltageReq : 7|6@0+ (0.1,10.6) [0|0] "Volts" XXX - SG_ ChargeVoltageReqMax : 23|6@0+ (0.1,10.6) [0|0] "Volts" XXX - SG_ FrontBatteryTemp : 47|8@0+ (1,-60.0) [0|0] "DegC" XXX - SG_ IBoost_Msg : 52|4@0+ (1,0) [0|0] "" XXX - SG_ IdleSpeedIncrease_El : 8|1@0+ (1,0) [0|0] "" XXX - SG_ MaxLashStep : 11|3@0+ (0.1,0) [0|0] "Volts" XXX - SG_ PowerSystemStatus : 15|4@0+ (1,0) [0|0] "" XXX - SG_ Shed_T_Eng_Off_B : 17|1@0+ (1,0) [0|0] "" XXX - SG_ Shed_Level_Req : 55|3@0+ (1,0) [0|0] "" XXX - SG_ Shed_Feature_Group_ID : 36|5@0+ (1,0) [0|0] "" XXX - SG_ Shed_Drain_Eng_Off_B : 16|1@0+ (1,0) [0|0] "" XXX - SG_ Batt_Lo_SoC_B : 25|1@0+ (1,0) [0|0] "" XXX - SG_ VoltageRampRateUpMax : 31|6@0+ (0.1,0) [0|0] "Volts/sec" XXX - SG_ Batt_Crit_SoC_B : 24|1@0+ (1,0) [0|0] "" XXX - -BO_ 1069 Battery_Mgmt_3: 8 XXX - SG_ BSFault : 23|1@0+ (1,0) [0|0] "" XXX - SG_ BSBattSOC : 30|7@0+ (1,0) [0|0] "%" XXX - SG_ BSBattQDeltaRideAh : 38|15@0+ (0.0078125,-100.0) [0|0] "Ah" XXX - SG_ BSBattQCapAh : 22|7@0+ (1,0) [0|0] "Ah" XXX - SG_ BSBattCurrent : 5|14@0+ (0.0625,-512.0) [0|0] "Amps" XXX - SG_ BattULoState_D_Qlty : 7|2@0+ (1,0) [0|0] "" XXX - -BO_ 1072 Cluster_Information: 8 XXX - SG_ ManRgen_D_Rq : 5|2@0+ (1,0) [0|0] "" XXX - SG_ Easy_Entry_Exit_Cmd : 49|1@0+ (1,0) [0|0] "" XXX - SG_ KeyTypeChngMykey_D_Rq : 53|2@0+ (1,0) [0|0] "" XXX - SG_ DrvSlipCtlMde_B_Rq : 19|1@0+ (1,0) [0|0] "" XXX - SG_ MetricActv_B_Actl : 6|1@0+ (1,0) [0|0] "" XXX - SG_ LdwDfaltOn_B_Actl : 0|1@0+ (1,0) [0|0] "" XXX - SG_ Fda_B_Stat : 9|1@0+ (1,0) [0|0] "" XXX - SG_ ePRNDL_MODE : 8|1@0+ (1,0) [0|0] "" XXX - SG_ AccDeny_B_RqIpc : 7|1@0+ (1,0) [0|0] "" XXX - SG_ MetricActvTe_B_Actl : 23|1@0+ (1,0) [0|0] "" XXX - SG_ EngOilLife_B_RqReset : 18|1@0+ (1,0) [0|0] "" XXX - SG_ OdometerMasterValue : 31|24@0+ (1,0) [0|0] "km" XXX - SG_ New_Module_Attn_Event : 56|1@0+ (1,0) [0|0] "" XXX - SG_ TRAILER_SWAY_CONFIG_CMD : 60|1@0+ (1,0) [0|0] "" XXX - SG_ ParkDetect_Stat : 62|1@0+ (1,0) [0|0] "" XXX - SG_ Attn_Info_Audio : 59|3@0+ (1,0) [0|0] "" XXX - SG_ TrlrBrkMde_D_Rq : 61|1@0+ (1,0) [0|0] "" XXX - SG_ TRAILER_BRAKE_CONFIG : 48|1@0+ (1,0) [0|0] "" XXX - SG_ VehMykey_Vl_LimRq : 63|1@0+ (1,0) [0|0] "" XXX - SG_ VehMykey_V_LimRqMx : 51|1@0+ (1,0) [0|0] "" XXX - SG_ EmgcyCallAsstMykey_Rq : 50|1@0+ (1,0) [0|0] "" XXX - SG_ DrvSlipCtlMde_D_Rq : 17|2@0+ (1,0) [0|0] "" XXX - SG_ AccEnbl_B_RqDrv : 20|1@0+ (1,0) [0|0] "" XXX - SG_ AutoHighBeam_Cmd : 55|2@0+ (1,0) [0|0] "" XXX - -BO_ 1075 Cluster_Information_3_CG1: 8 XXX - SG_ CamraFrntStat_D_Rq : 58|1@0+ (1,0) [0|0] "" XXX - SG_ DieslFuelBio_B_ActlDrv : 56|1@0+ (1,0) [0|0] "" XXX - SG_ RearCameraDelayCmd : 59|1@0+ (1,0) [0|0] "" XXX - SG_ UreaWarnReset : 60|1@0+ (1,0) [0|0] "" XXX - SG_ DistanceBarSetting : 49|1@0+ (1,0) [0|0] "" XXX - SG_ CamraZoomMan_D_Rq : 63|3@0+ (1,0) [0|0] "" XXX - SG_ CamraOvrlStat_D_Rq : 48|1@0+ (1,0) [0|0] "" XXX - SG_ CamraOvrlDyn_D_Rq : 25|1@0+ (1,0) [0|0] "" XXX - SG_ CamAutoTowbarZoom : 24|1@0+ (1,0) [0|0] "" XXX - SG_ FuelSecndActv_B_Actl : 39|1@0+ (1,0) [0|0] "" XXX - SG_ HILL_DESC_SW : 38|1@0+ (1,0) [0|0] "" XXX - SG_ FuelLvlPssvSide_No_Raw : 19|10@0+ (1,0) [0|0] "" XXX - SG_ SPDJBCompassCMDDecalibrate : 50|1@0+ (1,0) [0|0] "" XXX - SG_ SPDJBCompassCMDChangeZone : 51|1@0+ (1,0) [0|0] "" XXX - SG_ SPDJBCompassCmdDesiredZone : 55|4@0+ (1,0) [0|0] "" XXX - SG_ FUEL_SENSOR_NUM : 35|1@0+ (1,0) [0|0] "" XXX - SG_ W2S_LAMP_OK : 37|1@0+ (1,0) [0|0] "" XXX - SG_ Beltminder_Warn_Stats_IPC : 32|1@0+ (1,0) [0|0] "" XXX - SG_ FuelLvlActvSide_No_Raw : 13|10@0+ (1,0) [0|0] "" XXX - SG_ FuelLvl_Pc_Dsply : 7|10@0+ (0.108696,-5.22) [0|0] "%" XXX - SG_ FUEL_LVL_PER_MEAN : 47|8@0+ (0.434783,-5.22) [0|0] "% Indication" XXX - SG_ Fuel_Level_State : 34|2@0+ (1,0) [0|0] "" XXX - SG_ H2O_IN_FUEL_LAMP_OK_OBD : 36|1@0+ (1,0) [0|0] "" XXX - -BO_ 1093 TrailerBrakeInfo: 8 XXX - SG_ TrlrLampCnnct_B_Actl : 22|1@0+ (1,0) [0|0] "" XXX - SG_ TrlrBrkActCnnct_B_Actl : 16|1@0+ (1,0) [0|0] "" XXX - SG_ StopLamp_B_RqTrlrBrk : 7|1@0+ (1,0) [0|0] "" XXX - SG_ TrlrBrkOut_No_Dsply : 3|4@0+ (1,0) [0|0] "" XXX - SG_ TrlrBrkGain_No_Actl : 21|5@0+ (0.5,0) [0|0] "" XXX - SG_ TrlrBrkDsply_B_Rq : 6|1@0+ (1,0) [0|0] "" XXX - SG_ TrlrBrkDcnnt_B_Actl : 5|1@0+ (1,0) [0|0] "" XXX - SG_ TrlrBrkCtl_B_Falt : 4|1@0+ (1,0) [0|0] "" XXX - SG_ TrlrBrkActCirct_B_Falt : 39|1@0+ (1,0) [0|0] "" XXX - SG_ TrlrBrkMde_D_Actl : 23|1@0+ (1,0) [0|0] "" XXX - -BO_ 1104 SHCM_Status: 8 XXX - SG_ CURRENT_DRAW : 15|8@0+ (0.5,0) [0|0] "Amps" XXX - SG_ SECONDARY_HEATER_STAT : 7|1@0+ (1,0) [0|0] "" XXX - -BO_ 1107 PassengerOCSSerialNum: 8 XXX - SG_ OCSSerialNoByte8 : 63|8@0+ (1,0) [0|0] "" XXX - SG_ OCSSerialNoByte7 : 55|8@0+ (1,0) [0|0] "" XXX - SG_ OCSSerialNoByte6 : 47|8@0+ (1,0) [0|0] "" XXX - SG_ OCSSerialNoByte5 : 39|8@0+ (1,0) [0|0] "" XXX - SG_ OCSSerialNoByte4 : 31|8@0+ (1,0) [0|0] "" XXX - SG_ OCSSerialNoByte3 : 23|8@0+ (1,0) [0|0] "" XXX - SG_ OCSSerialNoByte2 : 15|8@0+ (1,0) [0|0] "" XXX - SG_ OCSSerialNoByte1 : 7|8@0+ (1,0) [0|0] "" XXX - -BO_ 1108 RCMSerialNumber: 8 XXX - SG_ RCMSerialNoByte8 : 63|8@0+ (1,0) [0|0] "" XXX - SG_ RCMSerialNoByte7 : 55|8@0+ (1,0) [0|0] "" XXX - SG_ RCMSerialNoByte6 : 47|8@0+ (1,0) [0|0] "" XXX - SG_ RCMSerialNoByte5 : 39|8@0+ (1,0) [0|0] "" XXX - SG_ RCMSerialNoByte4 : 31|8@0+ (1,0) [0|0] "" XXX - SG_ RCMSerialNoByte3 : 23|8@0+ (1,0) [0|0] "" XXX - SG_ RCMSerialNoByte2 : 15|8@0+ (1,0) [0|0] "" XXX - SG_ RCMSerialNoByte1 : 7|8@0+ (1,0) [0|0] "" XXX - -BO_ 1109 eCall_Info: 8 XXX - SG_ eCallConfirmation : 7|3@0+ (1,0) [0|0] "" XXX - -BO_ 1125 GPS_Data_Nav_1_HS: 8 XXX - SG_ GpsHsphLattSth_D_Actl : 25|2@0+ (1,0) [0|0] "" XXX - SG_ GpsHsphLongEast_D_Actl : 9|2@0+ (1,0) [0|0] "" XXX - SG_ GPS_Longitude_Minutes : 46|6@0+ (1,0) [0|0] "Minutes" XXX - SG_ GPS_Longitude_Min_dec : 55|14@0+ (0.0001,0) [0|0] "Minutes" XXX - SG_ GPS_Longitude_Degrees : 39|9@0+ (1,-179.0) [0|0] "Degrees" XXX - SG_ GPS_Latitude_Minutes : 15|6@0+ (1,0) [0|0] "Minutes" XXX - SG_ GPS_Latitude_Min_dec : 23|14@0+ (0.0001,0) [0|0] "Minutes" XXX - SG_ GPS_Latitude_Degrees : 7|8@0+ (1,-89.0) [0|0] "Degrees" XXX - -BO_ 1126 GPS_Data_Nav_2_HS: 8 XXX - SG_ Gps_B_Falt : 2|1@0+ (1,0) [0|0] "" XXX - SG_ GpsUtcYr_No_Actl : 55|5@0+ (1,1.0) [0|0] "Year" XXX - SG_ GpsUtcMnth_No_Actl : 47|4@0+ (1,1.0) [0|0] "Month" XXX - SG_ GpsUtcDay_No_Actl : 37|5@0+ (1,1.0) [0|0] "Day" XXX - SG_ GPS_UTC_seconds : 23|6@0+ (1,0) [0|0] "seconds" XXX - SG_ GPS_UTC_minutes : 15|6@0+ (1,0) [0|0] "Minutes" XXX - SG_ GPS_UTC_hours : 7|5@0+ (1,0) [0|0] "Hours" XXX - SG_ GPS_Pdop : 31|5@0+ (0.2,0) [0|0] "" XXX - SG_ GPS_Compass_direction : 26|4@0+ (1,0) [0|0] "" XXX - SG_ GPS_Actual_vs_Infer_pos : 38|1@0+ (1,0) [0|0] "" XXX - -BO_ 1127 GPS_Data_Nav_3_HS: 8 XXX - SG_ GPS_Vdop : 63|5@0+ (0.2,0) [0|0] "" XXX - SG_ GPS_Speed : 47|8@0+ (1,0) [0|0] "MPH" XXX - SG_ GPS_Sat_num_in_view : 7|5@0+ (1,0) [0|0] "" XXX - SG_ GPS_MSL_altitude : 15|12@0+ (10.0,-20460.0) [0|0] "feet" XXX - SG_ GPS_Heading : 31|16@0+ (0.01,0) [0|0] "Degrees" XXX - SG_ GPS_Hdop : 55|5@0+ (0.2,0) [0|0] "" XXX - SG_ GPS_dimension : 2|3@0+ (1,0) [0|0] "" XXX - -BO_ 1152 All_Terrain_Data: 8 XXX - SG_ HdcSwitchPos_B_Actl : 0|1@0+ (1,0) [0|0] "" XXX - SG_ TerrStat_D_RqDsply : 7|4@0+ (1,0) [0|0] "" XXX - SG_ TerrMde_D_RqDrv : 3|3@0+ (1,0) [0|0] "" XXX - -BO_ 1186 Information_4x4_2_CG1: 8 XXX - SG_ RearDiffFalt_D_Stat : 23|2@0+ (1,0) [0|0] "" XXX - SG_ RearDiffLck_Tq_Actl : 7|12@0+ (1,0) [0|0] "Nm" XXX - SG_ RearDiffLckMsg_D_Rq : 20|3@0+ (1,0) [0|0] "" XXX - SG_ AwdSrvcRqd_B_Rq : 21|1@0+ (1,0) [0|0] "" XXX - SG_ RearDiffLckLamp_D_Rq : 11|2@0+ (1,0) [0|0] "" XXX diff --git a/opendbc/generator/generator.py b/opendbc/generator/generator.py deleted file mode 100755 index 85f3f009e27d02..00000000000000 --- a/opendbc/generator/generator.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python2 -import os -import re - -cur_path = os.path.dirname(os.path.realpath(__file__)) -generator_path = os.path.join(cur_path, '../') -include_pattern = re.compile(r'CM_ "IMPORT (.*?)"') - - -def read_dbc(dir_name, filename): - with open(os.path.join(dir_name, filename)) as file_in: - return file_in.read() - - -def create_dbc(dir_name, filename): - dbc_file_in = read_dbc(dir_name, filename) - - includes = include_pattern.findall(dbc_file_in) - - output_filename = filename.replace('.dbc', '_generated.dbc') - output_file_location = os.path.join(generator_path, output_filename) - - with open(output_file_location, 'w') as dbc_file_out: - dbc_file_out.write('CM_ "AUTOGENERATED FILE, DO NOT EDIT"\n') - - for include_filename in reversed(includes): - include_file_header = '\n\nCM_ "Imported file %s starts here"\n' % include_filename - dbc_file_out.write(include_file_header) - - include_file = read_dbc(dir_name, include_filename) - dbc_file_out.write(include_file) - - dbc_file_out.write('\nCM_ "%s starts here"\n' % filename) - - core_dbc = include_pattern.sub('', dbc_file_in) - dbc_file_out.write(core_dbc) - - -for dir_name, _, filenames in os.walk(cur_path): - if dir_name == cur_path: - continue - - print dir_name - for filename in filenames: - if filename.startswith('_'): - continue - - print filename - create_dbc(dir_name, filename) diff --git a/opendbc/generator/honda/_bosch_2018.dbc b/opendbc/generator/honda/_bosch_2018.dbc deleted file mode 100644 index 302c254c217b7b..00000000000000 --- a/opendbc/generator/honda/_bosch_2018.dbc +++ /dev/null @@ -1,264 +0,0 @@ -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_ - -BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB - -BO_ 228 STEERING_CONTROL: 5 EON - SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS - SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS - SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS - SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS - SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS - -BO_ 232 BRAKE_HOLD: 7 XXX - SG_ XMISSION_SPEED : 7|14@0- (1,0) [1|0] "" XXX - SG_ COMPUTER_BRAKE : 39|16@0+ (1,0) [0|0] "" XXX - SG_ COMPUTER_BRAKE_REQUEST : 29|1@0+ (1,0) [0|0] "" XXX - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" XXX - -BO_ 304 GAS_PEDAL_2: 8 PCM - SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 330 STEERING_SENSORS: 8 EPS - SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON - SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON - SG_ STEER_ANGLE_OFFSET : 39|8@0- (-0.1,0) [-128|127] "deg" EON - SG_ STEER_WHEEL_ANGLE : 47|16@0- (-0.1,0) [-500|500] "deg" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 344 ENGINE_DATA: 8 PCM - SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON - SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON - SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON - SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 380 POWERTRAIN_DATA: 8 PCM - SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON - SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON - SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON - SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "" EON - SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "" EON - SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "" EON - SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "" EON - SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON - SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON - SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON - -BO_ 420 VSA_STATUS: 8 VSA - SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON - SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON - SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 450 EPB_STATUS: 8 EPB - SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" EON - SG_ EPB_STATE : 29|2@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 464 WHEEL_SPEEDS: 8 VSA - SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON - SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON - SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON - SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 479 ACC_CONTROL: 8 EON - SG_ SET_TO_1 : 20|5@0+ (1,0) [0|1] "" PCM - SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX - SG_ RELATED_TO_GAS : 7|7@0+ (1,0) [0|69] "" XXX - SG_ GAS_COMMAND : 0|9@0+ (1,0) [0|1] "" PCM - SG_ GAS_BRAKE : 31|14@0- (1,0) [0|1] "" XXX - SG_ ZEROS_BOH : 33|18@0+ (1,0) [100|100] "" XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 495 ACC_CONTROL_ON: 8 XXX - SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ ZEROS_BOH : 23|8@0+ (1,0) [0|255] "" XXX - SG_ ZEROS_BOH2 : 47|16@0+ (1,0) [0|255] "" XXX - SG_ SET_TO_FF : 15|8@0+ (1,0) [0|255] "" XXX - SG_ SET_TO_3 : 6|7@0+ (1,0) [0|4095] "" XXX - SG_ CONTROL_ON : 7|1@0+ (1,0) [0|1] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - -BO_ 545 XXX_16: 6 SCM - SG_ ECON_ON : 23|1@0+ (1,0) [0|1] "" XXX - SG_ DRIVE_MODE : 37|2@0+ (1,0) [0|3] "" XXX - SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" BDY - SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" BDY - -BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA - SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON - SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON - SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON - SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON - SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON - SG_ LONG_COUNTER : 55|8@0+ (1,0) [0|255] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - - BO_ 662 SCM_BUTTONS: 4 SCM - SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON - SG_ CRUISE_SETTING : 3|2@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 27|4@0+ (1,0) [0|15] "" EON - -BO_ 773 SEATBELT_STATUS: 7 BDY - SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON - SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON - SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON - SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON - SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON - SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON - SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON - -BO_ 777 CAR_SPEED: 8 PCM - SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "" XXX - SG_ CAR_SPEED : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 780 ACC_HUD: 8 ADAS - SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY - SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY - SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY - 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_ 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_ ZEROS_BOH : 7|24@0+ (0.002759506,0) [0|100] "m/s" BDY - SG_ FCM_OFF : 35|1@0+ (1,0) [0|1] "" BDY - SG_ SET_TO_1 : 36|1@0+ (1,0) [0|1] "" XXX - SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY - SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY - 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_ 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 - -BO_ 804 CRUISE: 8 PCM - SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 806 SCM_FEEDBACK: 8 SCM - SG_ DRIVERS_DOOR_OPEN : 17|1@0+ (1,0) [0|1] "" XXX - SG_ MAIN_ON : 28|1@0+ (1,0) [0|1] "" EON - SG_ RIGHT_BLINKER : 27|1@0+ (1,0) [0|1] "" EON - SG_ LEFT_BLINKER : 26|1@0+ (1,0) [0|1] "" EON - SG_ CMBS_STATES : 22|2@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 829 LKAS_HUD: 5 ADAS - SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY - SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY - SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY - SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY - SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY - SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY - SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY - SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY - SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY - SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY - SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY - SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY - SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY - SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY - SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY - SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY - SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY - SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY - -BO_ 862 CAMERA_MESSAGES: 8 CAM - SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY - SG_ AUTO_HIGHBEAMS_ACTIVE : 53|1@0+ (1,0) [0|1] "" XXX - SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX - SG_ ZEROS_BOH_2 : 51|4@0+ (1,0) [0|15] "" XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 884 STALK_STATUS: 8 XXX - SG_ AUTO_HEADLIGHTS : 46|1@0+ (1,0) [0|1] "" EON - SG_ HIGH_BEAM_HOLD : 47|1@0+ (1,0) [0|1] "" EON - SG_ HIGH_BEAM_FLASH : 45|1@0+ (1,0) [0|1] "" EON - SG_ HEADLIGHTS_ON : 54|1@0+ (1,0) [0|1] "" EON - SG_ WIPER_SWITCH : 53|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - -BO_ 891 STALK_STATUS_2: 8 XXX - SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" EON - SG_ LOW_BEAMS : 35|1@0+ (1,0) [0|1] "" XXX - SG_ HIGH_BEAMS : 34|1@0+ (1,0) [0|1] "" XXX - SG_ PARK_LIGHTS : 36|1@0+ (1,0) [0|1] "" 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" ; diff --git a/opendbc/generator/honda/_comma.dbc b/opendbc/generator/honda/_comma.dbc deleted file mode 100644 index c96250baedaa84..00000000000000 --- a/opendbc/generator/honda/_comma.dbc +++ /dev/null @@ -1,15 +0,0 @@ -BO_ 512 GAS_COMMAND: 6 EON - SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR - SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [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.253984064,-83.3) [0|1] "" EON - SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.126992032,-83.3) [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" ; diff --git a/opendbc/generator/honda/_honda_2017.dbc b/opendbc/generator/honda/_honda_2017.dbc deleted file mode 100644 index ee9a1e6483d34d..00000000000000 --- a/opendbc/generator/honda/_honda_2017.dbc +++ /dev/null @@ -1,218 +0,0 @@ -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_ - -BU_: EBCM ADAS PCM EPS VSA SCM BDY XXX EPB EON - -BO_ 344 ENGINE_DATA: 8 PCM - SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON - SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON - SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON - SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 380 POWERTRAIN_DATA: 8 PCM - SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON - SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON - SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON - SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "rpm" EON - SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "rpm" EON - SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "rpm" EON - SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "rpm" EON - SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON - SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "rpm" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 420 VSA_STATUS: 8 VSA - SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON - SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX - SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 432 STANDSTILL: 7 VSA - SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON - SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON - -BO_ 464 WHEEL_SPEEDS: 8 VSA - SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON - SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON - SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON - SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 490 VEHICLE_DYNAMICS: 8 VSA - SG_ LONG_ACCEL : 23|16@0- (0.0015384,0) [-20|20] "m/s2" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 506 BRAKE_COMMAND: 8 ADAS - SG_ COMPUTER_BRAKE : 7|10@0+ (1,0) [0|1] "" EBCM - SG_ SET_ME_X00 : 13|5@0+ (1,0) [0|1] "" EBCM - SG_ BRAKE_PUMP_REQUEST : 8|1@0+ (1,0) [0|1] "" EBCM - SG_ SET_ME_X00_2 : 23|3@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM - SG_ SET_ME_X00_3 : 19|1@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM - SG_ COMPUTER_BRAKE_REQUEST : 16|1@0+ (1,0) [0|1] "" EBCM - SG_ SET_ME_1 : 31|1@0+ (1,0) [0|1] "" EBCM - SG_ AEB_REQ_1 : 29|1@0+ (1,0) [0|1] "" XXX - SG_ AEB_REQ_2 : 26|3@0+ (1,0) [0|7] "" XXX - SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM - SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM - SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM - SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM - SG_ AEB : 41|2@0+ (1,0) [0|3] "" XXX - SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM - -BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA - SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON - SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON - SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON - SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON - SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" EON - SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 773 SEATBELT_STATUS: 7 BDY - SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON - SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON - SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON - SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON - SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON - SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON - SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON - -BO_ 777 LOCK_STATUS: 8 XXX - SG_ DOORS_UNLOCKED : 54|1@0+ (1,0) [0|1] "" EON - SG_ DOORS_LOCKED : 55|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 780 ACC_HUD: 8 ADAS - SG_ PCM_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" BDY - SG_ PCM_GAS : 23|8@0+ (1,0) [0|127] "" BDY - SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY - SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY - SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY - SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY - SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY - SG_ BOH_2 : 35|1@0+ (1,0) [0|1] "" BDY - 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_ 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_ 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 - -BO_ 804 CRUISE: 8 PCM - SG_ HUD_SPEED_KPH : 7|8@0+ (1,0) [0|255] "kph" EON - SG_ HUD_SPEED_MPH : 15|8@0+ (1,0) [0|255] "mph" EON - SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON - SG_ CRUISE_SPEED_PCM : 39|8@0+ (1,0) [0|255] "" EON - SG_ BOH2 : 47|8@0- (1,0) [0|255] "" EON - SG_ BOH3 : 55|8@0+ (1,0) [0|255] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 829 LKAS_HUD: 5 ADAS - SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY - SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY - SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY - SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY - SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY - SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY - SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY - SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY - SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY - SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY - SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY - SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY - SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY - SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY - SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY - SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY - SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY - SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY - -BO_ 892 CRUISE_PARAMS: 8 PCM - SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - -BO_ 1029 DOORS_STATUS: 8 BDY - SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON - SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON - SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON - SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON - SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; -CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; -CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; -CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; -CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; -CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; - - -VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; -VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; -VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; -VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; -VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; diff --git a/opendbc/generator/honda/acura_ilx_2016_can.dbc b/opendbc/generator/honda/acura_ilx_2016_can.dbc deleted file mode 100644 index e45426b3a67639..00000000000000 --- a/opendbc/generator/honda/acura_ilx_2016_can.dbc +++ /dev/null @@ -1,71 +0,0 @@ -CM_ "IMPORT _honda_2017.dbc" -CM_ "IMPORT _comma.dbc" - -BO_ 145 KINEMATICS: 8 XXX - SG_ LAT_ACCEL : 7|10@0+ (0.02,-512) [-20|20] "m/s2" EON - -BO_ 228 STEERING_CONTROL: 5 ADAS - SG_ STEER_TORQUE : 7|16@0- (1,0) [-3840|3840] "" EPS - SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS - SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|0] "" EPS - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS - SG_ CHECKSUM : 35|4@0+ (1,0) [0|3] "" EPS - -BO_ 304 GAS_PEDAL_2: 8 PCM - SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON - -BO_ 316 GAS_PEDAL: 8 PCM - SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON - -BO_ 342 STEERING_SENSORS: 6 EPS - SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON - SG_ STEER_ANGLE_RATE : 23|16@0- (1,0) [-3000|3000] "deg/s" EON - SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON - -BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON - SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON - -BO_ 419 GEARBOX: 8 PCM - SG_ GEAR : 7|8@0+ (1,0) [0|256] "" EON - SG_ GEAR_SHIFTER : 35|4@0+ (1,0) [0|15] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 422 SCM_BUTTONS: 8 SCM - SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON - SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON - SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON - SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 660 SCM_FEEDBACK: 8 SCM - SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON - SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON - SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" EON - -CM_ SG_ 419 GEAR "10 = reverse, 11 = transition"; -CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; -CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; -CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; -CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; - -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_ 419 GEAR_SHIFTER 10 "S" 4 "D" 3 "N" 2 "R" 1 "P" ; -VAL_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; -VAL_ 422 LIGHTS_SETTING 3 "high_beam" 2 "low_beam" 1 "position" 0 "no_lights" ; -VAL_ 422 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; -VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; -VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; -VAL_ 780 HUD_LEAD 3 "no_car" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; -VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; - -CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/generator/honda/acura_rdx_2018_can.dbc b/opendbc/generator/honda/acura_rdx_2018_can.dbc deleted file mode 100644 index 87389f8b2c6613..00000000000000 --- a/opendbc/generator/honda/acura_rdx_2018_can.dbc +++ /dev/null @@ -1,59 +0,0 @@ -CM_ "IMPORT _honda_2017.dbc" -CM_ "IMPORT _comma.dbc" - -BO_ 342 STEERING_SENSORS: 6 EPS - SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON - SG_ STEER_ANGLE_RATE : 23|16@0- (1,0) [-3000|3000] "deg/s" EON - SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" EON - -BO_ 392 GEARBOX: 6 XXX - SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" XXX - SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" XXX - SG_ GEAR_SHIFTER : 27|4@0+ (1,0) [0|15] "" EON - SG_ GEAR : 36|5@0+ (1,0) [0|31] "" EON - -BO_ 399 STEER_STATUS: 6 EPS - SG_ STEER_TORQUE_SENSOR : 7|12@0- (1,0) [-2047.5|2047.5] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_STATUS : 35|4@0+ (1,0) [0|15] "" EON - SG_ STEER_CONTROL_ACTIVE : 36|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" EON - -BO_ 404 STEERING_CONTROL: 4 EON - SG_ STEER_TORQUE : 7|12@0- (1,0) [-768|768] "" EPS - SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS - SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS - SG_ COUNTER : 29|2@0+ (1,0) [0|15] "" EPS - SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EPS - -BO_ 422 SCM_BUTTONS: 8 SCM - SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON - SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON - SG_ PARKING_BRAKE_LIGHT : 2|1@0+ (1,0) [0|1] "" EON - SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON - SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 487 BRAKE_PRESSURE: 4 VSA - SG_ BRAKE_PRESSURE1 : 7|10@0+ (0.015625,-103) [0|1000] "" EON - SG_ BRAKE_PRESSURE2 : 9|10@0+ (0.015625,-103) [0|1000] "" EON - SG_ COUNTER : 29|2@0+ (1,0) [0|15] "" EON - SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EON - -BO_ 660 SCM_FEEDBACK: 8 SCM - SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON - SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON - SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -CM_ SG_ 422 PARKING_BRAKE_LIGHT "Believe this is just the dash light for the parking break"; -VAL_ 392 GEAR_SHIFTER 0 "S" 1 "P" 2 "R" 4 "N" 8 "D" ; -VAL_ 392 GEAR 26 "S" 4 "D" 3 "N" 2 "R" 1 "P" ; -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_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; - -CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/generator/honda/honda_accord_lx15t_2018_can.dbc b/opendbc/generator/honda/honda_accord_lx15t_2018_can.dbc deleted file mode 100644 index 9e95f56dbb51be..00000000000000 --- a/opendbc/generator/honda/honda_accord_lx15t_2018_can.dbc +++ /dev/null @@ -1,52 +0,0 @@ -CM_ "IMPORT _bosch_2018.dbc" - -BO_ 401 GEARBOX: 8 PCM - SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" EON - SG_ BOH : 45|6@0+ (1,0) [0|63] "" XXX - SG_ GEAR2 : 31|8@0+ (1,0) [0|1] "" XXX - SG_ GEAR : 39|8@0+ (1,0) [0|255] "" XXX - SG_ ZEROS_BOH : 47|2@0+ (1,0) [0|3] "" XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 432 STANDSTILL: 7 VSA - SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON - -BO_ 446 BRAKE_MODULE: 3 VSA - SG_ BRAKE_PRESSED : 4|1@0+ (1,0) [0|1] "" XXX - SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" XXX - -BO_ 927 RADAR_HUD: 8 RADAR - SG_ ZEROS_BOH : 7|10@0+ (1,0) [0|127] "" BDY - SG_ CMBS_OFF : 12|1@0+ (1,0) [0|1] "" BDY - SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|1] "" XXX - SG_ SET_TO_1 : 13|1@0+ (1,0) [0|1] "" BDY - SG_ ZEROS_BOH2 : 11|4@0+ (1,0) [0|1] "" XXX - SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|1] "" XXX - SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|1] "" BDY - SG_ SET_TO_0 : 22|1@0+ (1,0) [0|1] "" XXX - SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|255] "" XXX - SG_ BOH : 40|1@0+ (1,0) [0|1] "" XXX - SG_ BOH_2 : 30|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 - -BO_ 1302 ODOMETER: 8 XXX - SG_ ODOMETER : 7|24@0+ (1,0) [0|16777215] "km" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -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_ 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" ; -VAL_ 806 CMBS_BUTTON 3 "pressed" 0 "released" ; -VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; -VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; - -CM_ "CHFFR_METRIC 330 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/generator/honda/honda_accord_s2t_2018_can.dbc b/opendbc/generator/honda/honda_accord_s2t_2018_can.dbc deleted file mode 100644 index e0a7ff328f6282..00000000000000 --- a/opendbc/generator/honda/honda_accord_s2t_2018_can.dbc +++ /dev/null @@ -1,48 +0,0 @@ -CM_ "IMPORT _bosch_2018.dbc" - -BO_ 419 GEARBOX: 8 PCM - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - SG_ GEAR_SHIFTER : 29|6@0+ (1,0) [0|63] "" EON - SG_ GEAR : 7|8@0+ (1,0) [0|255] "" EON - -BO_ 432 STANDSTILL: 7 VSA - SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON - -BO_ 446 BRAKE_MODULE: 3 VSA - SG_ BRAKE_PRESSED : 4|1@0+ (1,0) [0|1] "" XXX - SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" XXX - -BO_ 927 RADAR_HUD: 8 RADAR - SG_ ZEROS_BOH : 7|10@0+ (1,0) [0|127] "" BDY - SG_ CMBS_OFF : 12|1@0+ (1,0) [0|1] "" BDY - SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|1] "" XXX - SG_ SET_TO_1 : 13|1@0+ (1,0) [0|1] "" BDY - SG_ ZEROS_BOH2 : 11|4@0+ (1,0) [0|1] "" XXX - SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|1] "" XXX - SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|1] "" BDY - SG_ SET_TO_0 : 22|1@0+ (1,0) [0|1] "" XXX - SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|255] "" XXX - SG_ BOH : 40|1@0+ (1,0) [0|1] "" XXX - SG_ BOH_2 : 30|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 - -BO_ 1302 ODOMETER: 8 XXX - SG_ ODOMETER : 7|24@0+ (1,0) [0|16777215] "km" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -VAL_ 419 GEAR_SHIFTER 32 "D" 8 "R" 4 "P" ; -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" ; -VAL_ 806 CMBS_BUTTON 3 "pressed" 0 "released" ; -VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; -VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; - -CM_ "CHFFR_METRIC 330 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/generator/honda/honda_civic_hatchback_ex_2017_can.dbc b/opendbc/generator/honda/honda_civic_hatchback_ex_2017_can.dbc deleted file mode 100644 index 2de149ad5d0993..00000000000000 --- a/opendbc/generator/honda/honda_civic_hatchback_ex_2017_can.dbc +++ /dev/null @@ -1,55 +0,0 @@ -CM_ "IMPORT _bosch_2018.dbc" - -BO_ 401 GEARBOX: 8 PCM - SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" EON - SG_ BOH : 45|6@0+ (1,0) [0|63] "" XXX - SG_ GEAR2 : 31|8@0+ (1,0) [0|1] "" XXX - SG_ GEAR : 39|8@0+ (1,0) [0|255] "" XXX - SG_ ZEROS_BOH : 47|2@0+ (1,0) [0|3] "" XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 432 STANDSTILL: 7 VSA - SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON - -BO_ 892 CRUISE_PARAMS: 8 PCM - SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|15] "" EON - -BO_ 927 RADAR_HUD: 8 RADAR - SG_ ZEROS_BOH : 7|10@0+ (1,0) [0|127] "" BDY - SG_ CMBS_OFF : 12|1@0+ (1,0) [0|1] "" BDY - SG_ ZEROS_BOH3 : 31|32@0+ (1,0) [0|4294967295] "" XXX - SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|1] "" XXX - SG_ SET_TO_1 : 13|1@0+ (1,0) [0|1] "" BDY - SG_ ZEROS_BOH2 : 11|4@0+ (1,0) [0|1] "" XXX - SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|1] "" XXX - SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|1] "" BDY - SG_ SET_TO_0 : 22|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 - -BO_ 1029 DOORS_STATUS: 8 BDY - SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON - SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON - SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON - SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON - SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -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_ 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" ; -VAL_ 806 CMBS_BUTTON 3 "pressed" 0 "released" ; -VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; -VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; - -CM_ "CHFFR_METRIC 330 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/generator/honda/honda_civic_touring_2016_can.dbc b/opendbc/generator/honda/honda_civic_touring_2016_can.dbc deleted file mode 100644 index 1a7579d2a290bc..00000000000000 --- a/opendbc/generator/honda/honda_civic_touring_2016_can.dbc +++ /dev/null @@ -1,138 +0,0 @@ -CM_ "IMPORT _honda_2017.dbc" -CM_ "IMPORT _comma.dbc" - -BO_ 148 KINEMATICS: 8 XXX - SG_ LAT_ACCEL : 7|10@0+ (0.02,-512) [-20|20] "m/s2" EON - SG_ LONG_ACCEL : 24|9@0- (-0.02,0) [-20|20] "m/s2" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - -BO_ 228 STEERING_CONTROL: 5 ADAS - SG_ STEER_TORQUE : 7|16@0- (1,0) [-3840|3840] "" EPS - SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS - SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS - SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS - SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS - -BO_ 304 GAS_PEDAL_2: 8 PCM - SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 330 STEERING_SENSORS: 8 EPS - SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON - SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON - SG_ STEER_ANGLE_OFFSET : 39|8@0- (-0.1,0) [-128|127] "deg" EON - SG_ STEER_WHEEL_ANGLE : 47|16@0- (-0.1,0) [-500|500] "deg" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON - SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON - -BO_ 401 GEARBOX: 8 PCM - SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" EON - SG_ GEAR : 43|4@0+ (1,0) [0|15] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 450 EPB_STATUS: 8 EPB - SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" EON - SG_ EPB_STATE : 29|2@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" 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 - SG_ BRAKE_PRESSURE2 : 9|10@0+ (0.015625,-103) [0|1000] "" EON - SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON - -BO_ 545 ECON_STATUS: 6 XXX - SG_ ECON_ON_2 : 37|2@0+ (1,0) [0|3] "" EON - SG_ ECON_ON : 23|1@0+ (1,0) [0|1] "" EON - SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON - -BO_ 662 SCM_BUTTONS: 4 SCM - SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON - SG_ CRUISE_SETTING : 3|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON - -BO_ 806 SCM_FEEDBACK: 8 SCM - SG_ CMBS_BUTTON : 22|2@0+ (1,0) [0|3] "" EON - SG_ MAIN_ON : 28|1@0+ (1,0) [0|1] "" EON - SG_ RIGHT_BLINKER : 27|1@0+ (1,0) [0|1] "" EON - SG_ LEFT_BLINKER : 26|1@0+ (1,0) [0|1] "" EON - SG_ REVERSE_LIGHT : 18|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 862 HIGHBEAM_CONTROL: 8 ADAS - SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY - SG_ ZEROS_BOH_2 : 48|4@1+ (1,0) [0|15] "" XXX - SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX - SG_ AUTO_HIGHBEAMS_ACTIVE : 53|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 - -BO_ 884 STALK_STATUS: 8 XXX - SG_ AUTO_HEADLIGHTS : 46|1@0+ (1,0) [0|1] "" EON - SG_ HIGH_BEAM_HOLD : 47|1@0+ (1,0) [0|1] "" EON - SG_ HIGH_BEAM_FLASH : 45|1@0+ (1,0) [0|1] "" EON - SG_ HEADLIGHTS_ON : 54|1@0+ (1,0) [0|1] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - -BO_ 891 WIPERS: 8 XXX - SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - -BO_ 927 RADAR_HUD: 8 ADAS - SG_ ZEROS_BOH : 7|17@0+ (1,0) [0|127] "" BDY - SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|15] "" BDY - SG_ ZEROS_BOH2 : 31|8@0+ (1,0) [0|127] "" BDY - SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|15] "" BDY - SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|15] "" BDY - SG_ LEAD_SPEED : 39|9@0+ (1,0) [0|127] "" BDY - SG_ LEAD_STATE : 46|3@0+ (1,0) [0|127] "" BDY - SG_ LEAD_DISTANCE : 43|5@0+ (1,0) [0|31] "" BDY - SG_ ZEROS_BOH3 : 54|7@0+ (1,0) [0|127] "" BDY - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY - -BO_ 1302 ODOMETER: 8 XXX - SG_ ODOMETER : 7|24@0+ (1,0) [0|16777215] "km" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -CM_ SG_ 401 GEAR "10 = reverse, 11 = transition"; -CM_ SG_ 420 BRAKE_HOLD_RELATED "On when Brake Hold engaged"; -CM_ SG_ 450 EPB_STATE "3 \"engaged\" 2 \"disengaging\" 1 \"engaging\" 0 \"disengaged\""; -CM_ SG_ 806 REVERSE_LIGHT "Might be reverse gear selected and not the lights"; - -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_ 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_ 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" ; -VAL_ 806 CMBS_BUTTON 3 "pressed" 0 "released" ; -VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; -VAL_ 927 ACC_ALERTS 29 "esp_active_acc_canceled" 10 "b_pedal_applied" 9 "speed_too_low" 8 "speed_too_high" 7 "p_brake_applied" 6 "gear_no_d" 5 "seatbelt" 4 "too_steep_downhill" 3 "too_steep_uphill" 2 "too_close" 1 "no_vehicle_ahead" ; - -CM_ "CHFFR_METRIC 330 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/generator/honda/honda_crv_ex_2017_can.dbc b/opendbc/generator/honda/honda_crv_ex_2017_can.dbc deleted file mode 100644 index e8cc456bfcb8b0..00000000000000 --- a/opendbc/generator/honda/honda_crv_ex_2017_can.dbc +++ /dev/null @@ -1,66 +0,0 @@ -CM_ "IMPORT _bosch_2018.dbc" - -BO_ 401 GEARBOX: 8 PCM - SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" EON - SG_ BOH : 45|6@0+ (1,0) [0|63] "" XXX - SG_ GEAR2 : 31|8@0+ (1,0) [0|1] "" XXX - SG_ GEAR : 39|8@0+ (1,0) [0|255] "" XXX - SG_ ZEROS_BOH : 47|2@0+ (1,0) [0|3] "" XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 432 STANDSTILL: 7 VSA - SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON - -BO_ 446 BRAKE_MODULE: 3 VSA - SG_ BRAKE_PRESSED : 4|1@0+ (1,0) [0|1] "" XXX - SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" XXX - -BO_ 927 RADAR_HUD: 8 RADAR - SG_ ZEROS_BOH : 7|10@0+ (1,0) [0|127] "" BDY - SG_ CMBS_OFF : 12|1@0+ (1,0) [0|1] "" BDY - SG_ ZEROS_BOH3 : 31|32@0+ (1,0) [0|4294967295] "" XXX - SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|1] "" XXX - SG_ SET_TO_1 : 13|1@0+ (1,0) [0|1] "" BDY - SG_ ZEROS_BOH2 : 11|4@0+ (1,0) [0|1] "" XXX - SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|1] "" XXX - SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|1] "" BDY - SG_ SET_TO_0 : 22|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 - -BO_ 1029 DOORS_STATUS: 8 BDY - SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON - SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON - SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON - SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON - SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 1302 ODOMETER: 8 XXX - SG_ ODOMETER : 7|24@0+ (1,0) [0|16777215] "km" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -CM_ SG_ 344 DISTANCE_COUNTER ""; -CM_ SG_ 450 EPB_STATE "3: On, 2: Disengaging, 1: Engaging, 0: Off"; -CM_ SG_ 479 CONTROL_ON "Set to 5 when car is being controlled"; -CM_ SG_ 479 RELATED_TO_GAS "bits 7, 3, and 1 set to 1 when gas not applied"; -CM_ SG_ 479 GAS_BRAKE "Signed value, negative when braking and positive when applying gas"; - -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_ 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" ; -VAL_ 806 CMBS_BUTTON 3 "pressed" 0 "released" ; -VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; -VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; - -CM_ "CHFFR_METRIC 330 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/generator/honda/honda_crv_hybrid_2019_can.dbc b/opendbc/generator/honda/honda_crv_hybrid_2019_can.dbc deleted file mode 100644 index 2398526e04fc9d..00000000000000 --- a/opendbc/generator/honda/honda_crv_hybrid_2019_can.dbc +++ /dev/null @@ -1,48 +0,0 @@ -CM_ "IMPORT _bosch_2018.dbc" - -BO_ 419 GEARBOX: 8 PCM - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - SG_ GEAR_SHIFTER : 29|6@0+ (1,0) [0|63] "" EON - SG_ GEAR : 7|8@0+ (1,0) [0|255] "" EON - -BO_ 432 STANDSTILL: 7 VSA - SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON - -BO_ 927 RADAR_HUD: 8 RADAR - SG_ ZEROS_BOH : 7|10@0+ (1,0) [0|127] "" BDY - SG_ CMBS_OFF : 12|1@0+ (1,0) [0|1] "" BDY - SG_ ZEROS_BOH3 : 31|32@0+ (1,0) [0|4294967295] "" XXX - SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|1] "" XXX - SG_ SET_TO_1 : 13|1@0+ (1,0) [0|1] "" BDY - SG_ ZEROS_BOH2 : 11|4@0+ (1,0) [0|1] "" XXX - SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|1] "" XXX - SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|1] "" BDY - SG_ SET_TO_0 : 22|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 - -BO_ 1302 ODOMETER: 8 XXX - SG_ ODOMETER : 7|24@0+ (1,0) [0|16777215] "km" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -CM_ SG_ 344 DISTANCE_COUNTER ""; -CM_ SG_ 450 EPB_STATE "3: On, 2: Disengaging, 1: Engaging, 0: Off"; -CM_ SG_ 479 CONTROL_ON "Set to 5 when car is being controlled"; -CM_ SG_ 479 RELATED_TO_GAS "bits 7, 3, and 1 set to 1 when gas not applied"; -CM_ SG_ 479 GAS_BRAKE "Signed value, negative when braking and positive when applying gas"; - -VAL_ 419 GEAR_SHIFTER 32 "D" 8 "R" 4 "P" ; -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" ; -VAL_ 806 CMBS_BUTTON 3 "pressed" 0 "released" ; -VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; -VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; - -CM_ "CHFFR_METRIC 330 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/generator/honda/honda_crv_touring_2016_can.dbc b/opendbc/generator/honda/honda_crv_touring_2016_can.dbc deleted file mode 100644 index 3d9b48ab7154bc..00000000000000 --- a/opendbc/generator/honda/honda_crv_touring_2016_can.dbc +++ /dev/null @@ -1,69 +0,0 @@ -CM_ "IMPORT _honda_2017.dbc" -CM_ "IMPORT _comma.dbc" - -BO_ 342 STEERING_SENSORS: 6 EPS - SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON - SG_ STEER_ANGLE_RATE : 23|16@0- (1,0) [-3000|3000] "deg/s" EON - SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" EON - -BO_ 399 STEER_STATUS: 6 EPS - SG_ STEER_TORQUE_SENSOR : 7|12@0- (1,0) [-2047.5|2047.5] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_CONTROL_ACTIVE : 36|1@0+ (1,0) [0|1] "" EON - SG_ STEER_STATUS : 35|4@0+ (1,0) [0|15] "" EON - SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" EON - -BO_ 401 GEARBOX: 8 PCM - SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" EON - SG_ GEAR : 35|4@0+ (1,0) [0|15] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 404 STEERING_CONTROL: 4 EON - SG_ STEER_TORQUE : 7|12@0- (1,0) [-768|768] "" EPS - SG_ SET_ME_X00 : 11|4@0+ (1,0) [0|15] "" EPS - SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS - SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS - SG_ COUNTER : 29|2@0+ (1,0) [0|15] "" EPS - SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EPS - -BO_ 422 SCM_BUTTONS: 8 SCM - SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON - SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON - SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON - SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 487 BRAKE_PRESSURE: 4 VSA - SG_ BRAKE_PRESSURE1 : 7|10@0+ (0.015625,-103) [0|1000] "" EON - SG_ BRAKE_PRESSURE2 : 9|10@0+ (0.015625,-103) [0|1000] "" EON - SG_ COUNTER : 29|2@0+ (1,0) [0|15] "" EON - SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EON - -BO_ 660 SCM_FEEDBACK: 8 SCM - SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON - SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON - SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 891 WIPERS: 8 XXX - SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - - -CM_ SG_ 401 GEAR "10 = reverse, 11 = transition"; - -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_ 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_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; -VAL_ 422 LIGHTS_SETTING 3 "high_beam" 2 "low_beam" 1 "position" 0 "no_lights" ; -VAL_ 422 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; -VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; - -CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/generator/honda/honda_fit_ex_2018_can.dbc b/opendbc/generator/honda/honda_fit_ex_2018_can.dbc deleted file mode 100644 index ce02d4cf8a161e..00000000000000 --- a/opendbc/generator/honda/honda_fit_ex_2018_can.dbc +++ /dev/null @@ -1,89 +0,0 @@ -CM_ "IMPORT _honda_2017.dbc" -CM_ "IMPORT _comma.dbc" - -BO_ 145 KINEMATICS: 8 XXX - SG_ LAT_ACCEL : 7|10@0+ (0.02,-512) [-20|20] "m/s2" EON - -BO_ 228 STEERING_CONTROL: 5 ADAS - SG_ STEER_TORQUE : 7|16@0- (1,0) [-3840|3840] "" EPS - SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS - SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS - SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS - SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS - -BO_ 304 GAS_PEDAL_2: 8 PCM - SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 342 STEERING_SENSORS: 6 EPS - SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON - SG_ STEER_ANGLE_RATE : 23|16@0- (1,0) [-3000|3000] "deg/s" EON - SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON - -BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON - SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON - -BO_ 401 GEARBOX: 8 PCM - SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" EON - SG_ GEAR : 43|4@0+ (1,0) [0|15] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 422 SCM_BUTTONS: 8 SCM - SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON - SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON - SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON - SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 487 BRAKE_PRESSURE: 4 VSA - SG_ BRAKE_PRESSURE1 : 7|10@0+ (0.015625,-103) [0|1000] "" EON - SG_ BRAKE_PRESSURE2 : 9|10@0+ (0.015625,-103) [0|1000] "" EON - SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON - -BO_ 660 SCM_FEEDBACK: 8 SCM - SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON - SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON - SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 862 HIGHBEAM_CONTROL: 8 ADAS - SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY - SG_ ZEROS_BOH_2 : 48|4@1+ (1,0) [0|15] "" XXX - SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX - SG_ AUTO_HIGHBEAMS_ACTIVE : 53|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 - -BO_ 884 STALK_STATUS: 8 XXX - SG_ AUTO_HEADLIGHTS : 46|1@0+ (1,0) [0|1] "" EON - SG_ HIGH_BEAM_HOLD : 47|1@0+ (1,0) [0|1] "" EON - SG_ HIGH_BEAM_FLASH : 45|1@0+ (1,0) [0|1] "" EON - SG_ HEADLIGHTS_ON : 54|1@0+ (1,0) [0|1] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - -CM_ SG_ 401 GEAR "10 = reverse, 11 = transition"; -CM_ SG_ 420 BRAKE_HOLD_RELATED "On when Brake Hold engaged"; - -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_ 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_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; -VAL_ 422 LIGHTS_SETTING 3 "high_beam" 2 "low_beam" 1 "position" 0 "no_lights" ; -VAL_ 422 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; - -CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/generator/honda/honda_insight_ex_2019_can.dbc b/opendbc/generator/honda/honda_insight_ex_2019_can.dbc deleted file mode 100644 index ff988cf9dae796..00000000000000 --- a/opendbc/generator/honda/honda_insight_ex_2019_can.dbc +++ /dev/null @@ -1,44 +0,0 @@ -CM_ "IMPORT _bosch_2018.dbc" - -BO_ 419 GEARBOX: 8 PCM - SG_ GEAR : 7|8@0+ (1,0) [0|255] "" EON - SG_ GEAR_SHIFTER : 29|6@0+ (1,0) [0|63] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 432 STANDSTILL: 7 VSA - SG_ BRAKE_ERROR_1 : 13|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_ERROR_2 : 12|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON - -BO_ 927 RADAR_HUD: 8 RADAR - SG_ ZEROS_BOH : 7|10@0+ (1,0) [0|127] "" BDY - SG_ CMBS_OFF : 12|1@0+ (1,0) [0|1] "" BDY - SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|1] "" XXX - SG_ SET_TO_1 : 13|1@0+ (1,0) [0|1] "" BDY - SG_ ZEROS_BOH2 : 11|4@0+ (1,0) [0|1] "" XXX - SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|1] "" XXX - SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|1] "" BDY - SG_ SET_TO_0 : 22|1@0+ (1,0) [0|1] "" XXX - SG_ HUD_LEAD : 40|1@0+ (1,0) [0|1] "" XXX - SG_ SET_TO_64 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|255] "" XXX - SG_ ZEROS_BOH3 : 47|7@0+ (1,0) [0|127] "" XXX - SG_ ZEROS_BOH4 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 1029 DOORS_STATUS: 8 BDY - SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON - SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON - SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON - SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON - SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - - VAL_ 419 GEAR 10 "R" 1 "D" 0 "P"; - VAL_ 419 GEAR_SHIFTER 32 "D" 16 "N" 8 "R" 4 "P" ; - -CM_ "CHFFR_METRIC 330 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/generator/honda/honda_odyssey_exl_2018.dbc b/opendbc/generator/honda/honda_odyssey_exl_2018.dbc deleted file mode 100644 index fb54a29abc7955..00000000000000 --- a/opendbc/generator/honda/honda_odyssey_exl_2018.dbc +++ /dev/null @@ -1,105 +0,0 @@ -CM_ "IMPORT _honda_2017.dbc" -CM_ "IMPORT _comma.dbc" - -BO_ 228 STEERING_CONTROL: 5 ADAS - SG_ STEER_TORQUE : 7|16@0- (1,0) [-3840|3840] "" EPS - SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS - SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|0] "" EPS - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS - SG_ CHECKSUM : 35|4@0+ (1,0) [0|3] "" EPS - -BO_ 316 GAS_PEDAL: 8 PCM - SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON - -BO_ 342 STEERING_SENSORS: 6 EPS - SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON - SG_ STEER_ANGLE_RATE : 23|16@0- (1,0) [-3000|3000] "deg/s" EON - SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON - -BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON - SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON - -BO_ 419 GEARBOX: 8 PCM - SG_ GEAR : 7|8@0+ (1,0) [0|256] "" EON - SG_ GEAR_SHIFTER : 35|4@0+ (1,0) [0|15] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 450 EPB_STATUS: 8 XXX - SG_ EPB_BRAKE_AND_PULL : 6|1@0+ (1,0) [0|1] "" XXX - SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" XXX - SG_ EPB_STATE : 29|2@0+ (1,0) [0|1] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - -BO_ 662 SCM_BUTTONS: 4 SCM - SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON - SG_ CRUISE_SETTING : 3|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON - -BO_ 806 SCM_FEEDBACK: 8 SCM - SG_ CMBS_BUTTON : 22|2@0+ (1,0) [0|3] "" EON - SG_ MAIN_ON : 28|1@0+ (1,0) [0|1] "" EON - SG_ RIGHT_BLINKER : 27|1@0+ (1,0) [0|1] "" EON - SG_ LEFT_BLINKER : 26|1@0+ (1,0) [0|1] "" EON - SG_ REVERSE_LIGHT : 18|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 891 WIPERS: 8 XXX - SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - -BO_ 862 HIGHBEAM_CONTROL: 8 ADAS - SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY - SG_ ZEROS_BOH_2 : 48|4@1+ (1,0) [0|15] "" XXX - SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX - SG_ AUTO_HIGHBEAMS_ACTIVE : 53|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 - -BO_ 927 RADAR_HUD: 8 ADAS - SG_ ZEROS_BOH : 7|17@0+ (1,0) [0|127] "" BDY - SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|15] "" BDY - SG_ ZEROS_BOH2 : 31|8@0+ (1,0) [0|127] "" BDY - SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|15] "" BDY - SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|15] "" BDY - SG_ LEAD_SPEED : 39|9@0+ (1,0) [0|127] "" BDY - SG_ LEAD_STATE : 46|3@0+ (1,0) [0|127] "" BDY - SG_ LEAD_DISTANCE : 43|5@0+ (1,0) [0|31] "" BDY - SG_ ZEROS_BOH3 : 54|7@0+ (1,0) [0|127] "" BDY - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY - -BO_ 1302 ODOMETER: 8 XXX - SG_ ODOMETER : 7|24@0+ (1,0) [0|16777215] "km" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -CM_ SG_ 419 GEAR "10 = reverse, 11 = transition"; -CM_ SG_ 420 BRAKE_HOLD_RELATED "On when Brake Hold engaged"; -CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; -CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; -CM_ SG_ 806 REVERSE_LIGHT "Might be reverse gear selected and not the lights"; -CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnings etc..."; - -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_ 419 GEAR_SHIFTER 10 "S" 4 "D" 3 "N" 2 "R" 1 "P" ; -VAL_ 450 EPB_STATE 3 "engaged" 2 "disengaging" 1 "engaging" 0 "disengaged" ; -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" ; -VAL_ 780 HUD_LEAD 3 "no_car" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; -VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; -VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; -VAL_ 927 ACC_ALERTS 29 "esp_active_acc_canceled" 10 "b_pedal_applied" 9 "speed_too_low" 8 "speed_too_high" 7 "p_brake_applied" 6 "gear_no_d" 5 "seatbelt" 4 "too_steep_downhill" 3 "too_steep_uphill" 2 "too_close" 1 "no_vehicle_ahead" ; -VAL_ 806 CMBS_BUTTON 3 "pressed" 0 "released" ; - -CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/generator/honda/honda_pilot_touring_2017_can.dbc b/opendbc/generator/honda/honda_pilot_touring_2017_can.dbc deleted file mode 100644 index 779cd66f5be877..00000000000000 --- a/opendbc/generator/honda/honda_pilot_touring_2017_can.dbc +++ /dev/null @@ -1,61 +0,0 @@ -CM_ "IMPORT _honda_2017.dbc" -CM_ "IMPORT _comma.dbc" - -BO_ 145 KINEMATICS: 8 XXX - SG_ LAT_ACCEL : 7|10@0+ (0.02,-512) [-20|20] "m/s2" EON - -BO_ 228 STEERING_CONTROL: 5 ADAS - SG_ STEER_TORQUE : 7|16@0- (1,0) [-3840|3840] "" EPS - SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS - SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|0] "" EPS - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS - SG_ CHECKSUM : 35|4@0+ (1,0) [0|3] "" EPS - -BO_ 304 GAS_PEDAL_2: 8 PCM - SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON - -BO_ 316 GAS_PEDAL: 8 PCM - SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON - -BO_ 342 STEERING_SENSORS: 6 EPS - SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON - SG_ STEER_ANGLE_RATE : 23|16@0- (1,0) [-3000|3000] "deg/s" EON - SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON - -BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON - SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON - -BO_ 419 GEARBOX: 8 PCM - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - SG_ GEAR_SHIFTER : 29|6@0+ (1,0) [0|63] "" EON - SG_ GEAR : 7|8@0+ (1,0) [0|255] "" EON - -BO_ 422 SCM_BUTTONS: 8 SCM - SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON - SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON - SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON - SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 660 SCM_FEEDBACK: 8 SCM - SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON - SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON - SG_ WIPERS_SPEED : 4|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_ 419 GEAR_SHIFTER 32 "D" 8 "R" 4 "P" ; -VAL_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; -VAL_ 422 LIGHTS_SETTING 3 "high_beam" 2 "low_beam" 1 "position" 0 "no_lights" ; -VAL_ 422 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; - -CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/generator/honda/honda_ridgeline_black_edition_2017_can.dbc b/opendbc/generator/honda/honda_ridgeline_black_edition_2017_can.dbc deleted file mode 100644 index d070d314d59e53..00000000000000 --- a/opendbc/generator/honda/honda_ridgeline_black_edition_2017_can.dbc +++ /dev/null @@ -1,56 +0,0 @@ -CM_ "IMPORT _honda_2017.dbc" -CM_ "IMPORT _comma.dbc" - -BO_ 145 KINEMATICS: 8 XXX - SG_ LAT_ACCEL : 7|10@0+ (0.02,-512) [-20|20] "m/s2" EON - -BO_ 228 STEERING_CONTROL: 5 ADAS - SG_ STEER_TORQUE : 7|16@0- (1,0) [-3840|3840] "" EPS - SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS - SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|0] "" EPS - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS - SG_ CHECKSUM : 35|4@0+ (1,0) [0|3] "" EPS - -BO_ 316 GAS_PEDAL: 8 PCM - SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON - -BO_ 342 STEERING_SENSORS: 6 EPS - SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON - SG_ STEER_ANGLE_RATE : 23|16@0- (1,0) [-3000|3000] "deg/s" EON - SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON - -BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON - SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON - -BO_ 419 GEARBOX: 8 PCM - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - SG_ GEAR_SHIFTER : 29|6@0+ (1,0) [0|63] "" EON - SG_ GEAR : 7|8@0+ (1,0) [0|255] "" EON - -BO_ 422 SCM_BUTTONS: 8 SCM - SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON - SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON - SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON - SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 660 SCM_FEEDBACK: 8 SCM - SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON - SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON - SG_ WIPERS_SPEED : 4|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_ 419 GEAR_SHIFTER 32 "D" 8 "R" 4 "P" ; -VAL_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; -VAL_ 422 LIGHTS_SETTING 3 "high_beam" 2 "low_beam" 1 "position" 0 "no_lights" ; -VAL_ 422 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; - -CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/generator/toyota/_comma.dbc b/opendbc/generator/toyota/_comma.dbc deleted file mode 100644 index aa6a55f8b00bd3..00000000000000 --- a/opendbc/generator/toyota/_comma.dbc +++ /dev/null @@ -1,27 +0,0 @@ -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" ; diff --git a/opendbc/generator/toyota/_toyota_2017.dbc b/opendbc/generator/toyota/_toyota_2017.dbc deleted file mode 100644 index 9084d65b422113..00000000000000 --- a/opendbc/generator/toyota/_toyota_2017.dbc +++ /dev/null @@ -1,311 +0,0 @@ -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 CGW - -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_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" 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: 7 DSU - SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX - SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX - SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX - SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX - SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX - SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX - SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" 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_ 836 PRE_COLLISION_2: 8 DSU - SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX - -BO_ 869 DSU_CRUISE : 7 DSU - SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX - SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX - SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX - SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX - SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX - SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX - SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" 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_ 1408 VIN_PART_1: 8 CGW - SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX - -BO_ 1409 VIN_PART_2: 8 CGW - SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX - -BO_ 1410 VIN_PART_3: 8 CGW - SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" 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_ 643 COUNTER "only used on cars that use this msg for cruise control"; -CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; -CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; -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_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; -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"; diff --git a/opendbc/generator/toyota/lexus_ct200h_2018_pt.dbc b/opendbc/generator/toyota/lexus_ct200h_2018_pt.dbc deleted file mode 100644 index 55919570f94337..00000000000000 --- a/opendbc/generator/toyota/lexus_ct200h_2018_pt.dbc +++ /dev/null @@ -1,37 +0,0 @@ -CM_ "IMPORT _toyota_2017.dbc" -CM_ "IMPORT _comma.dbc" - -BO_ 548 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_ SPORT_ON : 2|1@0+ (1,0) [0|1] "" XXX - SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX - SG_ ECON_ON : 40|1@0+ (1,0) [0|1] "" XXX - -CM_ SG_ 548 BRAKE_PRESSURE "seems prop to pedal force"; -CM_ SG_ 548 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"; -VAL_ 956 SPORT_ON 0 "off" 1 "on"; -VAL_ 956 ECON_ON 0 "off" 1 "on"; \ No newline at end of file diff --git a/opendbc/generator/toyota/lexus_gs300h_2017_pt.dbc b/opendbc/generator/toyota/lexus_gs300h_2017_pt.dbc deleted file mode 100644 index 070b4e6e728a53..00000000000000 --- a/opendbc/generator/toyota/lexus_gs300h_2017_pt.dbc +++ /dev/null @@ -1,38 +0,0 @@ -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"; diff --git a/opendbc/generator/toyota/lexus_is_2018_pt.dbc b/opendbc/generator/toyota/lexus_is_2018_pt.dbc deleted file mode 100644 index aebf81a1681db9..00000000000000 --- a/opendbc/generator/toyota/lexus_is_2018_pt.dbc +++ /dev/null @@ -1,39 +0,0 @@ -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_ 705 GAS_PEDAL: 8 XXX - SG_ GAS_RELEASED : 3|1@0+ (1,0) [0|1] "" XXX - SG_ GAS_PEDAL : 55|8@0+ (0.005,0) [0|1] "" XXX - -BO_ 608 STEER_TORQUE_SENSOR: 8 XXX - SG_ STEER_TORQUE_EPS : 47|16@0- (0.66,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_ALT: 8 XXX - SG_ MAIN_ON : 13|1@0+ (1,0) [0|3] "" XXX - SG_ CRUISE_STATE : 10|1@0+ (1,0) [0|1] "" XXX - SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "mph" 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_ 610 TYPE "seems 1 on Corolla, 0 on all others"; -CM_ SG_ 1009 SET_SPEED "units seem to be whatever the car is set to"; -VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; -VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; -VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; diff --git a/opendbc/generator/toyota/lexus_is_hybrid_2017_pt.dbc b/opendbc/generator/toyota/lexus_is_hybrid_2017_pt.dbc deleted file mode 100644 index 7fb743770573c7..00000000000000 --- a/opendbc/generator/toyota/lexus_is_hybrid_2017_pt.dbc +++ /dev/null @@ -1,41 +0,0 @@ -CM_ "IMPORT _toyota_2017.dbc" -CM_ "IMPORT _comma.dbc" - -BO_ 581 GAS_PEDAL: 5 XXX - SG_ GAS_PEDAL : 23|8@0+ (0.005,0) [0|1] "" XXX - -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_ 608 STEER_TORQUE_SENSOR: 8 XXX - SG_ STEER_TORQUE_EPS : 47|16@0- (0.66,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_ISH: 8 XXX - SG_ MAIN_ON : 13|1@0+ (1,0) [0|3] "" XXX - SG_ CRUISE_STATE : 10|1@0+ (1,0) [0|1] "" XXX - SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX - -BO_ 1599 LIGHT_STALK_ISH: 8 SCM - SG_ AUTO_HIGH_BEAM : 19|1@0+ (1,0) [0|1] "" 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_ 610 TYPE "seems 1 on Corolla, 0 on all others"; -CM_ SG_ 1009 SET_SPEED "units seem to be whatever the car is set to"; -VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; -VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; -VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; diff --git a/opendbc/generator/toyota/lexus_rx_350_2016_pt.dbc b/opendbc/generator/toyota/lexus_rx_350_2016_pt.dbc deleted file mode 100644 index 4a6fe48fd91bf5..00000000000000 --- a/opendbc/generator/toyota/lexus_rx_350_2016_pt.dbc +++ /dev/null @@ -1,37 +0,0 @@ -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_ 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_ SPORT_ON : 2|1@0+ (1,0) [0|1] "" XXX - SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX - SG_ ECON_ON : 40|1@0+ (1,0) [0|1] "" XXX - -BO_ 705 GAS_PEDAL: 8 XXX - SG_ GAS_PEDAL : 55|8@0+ (1,0) [0|255] "" 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_ 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 SPORT_ON 0 "off" 1 "on" ; -VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P" ; -VAL_ 956 ECON_ON 0 "off" 1 "on" ; diff --git a/opendbc/generator/toyota/lexus_rx_hybrid_2017_pt.dbc b/opendbc/generator/toyota/lexus_rx_hybrid_2017_pt.dbc deleted file mode 100644 index fb42de9f68d36f..00000000000000 --- a/opendbc/generator/toyota/lexus_rx_hybrid_2017_pt.dbc +++ /dev/null @@ -1,37 +0,0 @@ -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_ SPORT_ON : 2|1@0+ (1,0) [0|1] "" XXX - SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX - SG_ ECON_ON : 40|1@0+ (1,0) [0|1] "" 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"; -VAL_ 956 SPORT_ON 0 "off" 1 "on"; -VAL_ 956 ECON_ON 0 "off" 1 "on"; diff --git a/opendbc/generator/toyota/toyota_avalon_2017_pt.dbc b/opendbc/generator/toyota/toyota_avalon_2017_pt.dbc deleted file mode 100644 index b867e937065b5f..00000000000000 --- a/opendbc/generator/toyota/toyota_avalon_2017_pt.dbc +++ /dev/null @@ -1,33 +0,0 @@ -CM_ "IMPORT _toyota_2017.dbc" -CM_ "IMPORT _comma.dbc" - -BO_ 550 BRAKE_MODULE: 8 XXX - SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|255] "" XXX - SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|65535] "" XXX - SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|3] "" XXX - -BO_ 705 GAS_PEDAL: 8 XXX - SG_ GAS_RELEASED : 3|1@0+ (1,0) [0|1] "" XXX - SG_ GAS_PEDAL : 55|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 - -CM_ SG_ 548 BRAKE_PRESSURE "seems prop to pedal force"; -CM_ SG_ 548 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; -CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; -VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; -VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; -VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; diff --git a/opendbc/generator/toyota/toyota_camry_hybrid_2018_pt.dbc b/opendbc/generator/toyota/toyota_camry_hybrid_2018_pt.dbc deleted file mode 100644 index 1d41d1e2020a49..00000000000000 --- a/opendbc/generator/toyota/toyota_camry_hybrid_2018_pt.dbc +++ /dev/null @@ -1,37 +0,0 @@ -CM_ "IMPORT _toyota_2017.dbc" -CM_ "IMPORT _comma.dbc" - -BO_ 295 GEAR_PACKET: 8 XXX - SG_ CAR_MOVEMENT : 39|8@0- (1,0) [0|255] "" XXX - SG_ COUNTER : 55|8@0+ (1,0) [0|255] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - SG_ GEAR : 47|4@0+ (1,0) [0|15] "" XXX - -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: 8 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 - SG_ STEER_ANGLE : 31|16@0- (0.05527,0) [-500|500] "" XXX - -BO_ 610 EPS_STATUS: 8 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 : 63|8@0+ (1,0) [0|255] "" 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_ 295 GEAR 0 "P" 1 "R" 2 "N" 3 "D" 4 "B"; -VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; -VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; diff --git a/opendbc/generator/toyota/toyota_corolla_2017_pt.dbc b/opendbc/generator/toyota/toyota_corolla_2017_pt.dbc deleted file mode 100644 index 724b6e834bb0a4..00000000000000 --- a/opendbc/generator/toyota/toyota_corolla_2017_pt.dbc +++ /dev/null @@ -1,33 +0,0 @@ -CM_ "IMPORT _toyota_2017.dbc" -CM_ "IMPORT _comma.dbc" - -BO_ 548 BRAKE_MODULE: 8 XXX - SG_ BRAKE_PRESSURE : 43|12@0+ (1,0) [0|4047] "" XXX - SG_ BRAKE_PRESSED : 5|1@0+ (1,0) [0|1] "" XXX - -BO_ 705 GAS_PEDAL: 8 XXX - SG_ GAS_RELEASED : 3|1@0+ (1,0) [0|1] "" XXX - SG_ GAS_PEDAL : 55|8@0+ (0.005,0) [0|1] "" XXX - -BO_ 608 STEER_TORQUE_SENSOR: 8 XXX - SG_ STEER_TORQUE_EPS : 47|16@0- (1.0,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 - SG_ SPORT_ON : 3|1@0+ (1,0) [0|1] "" XXX - -CM_ SG_ 548 BRAKE_PRESSURE "seems prop to pedal force"; -CM_ SG_ 548 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; -CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; -VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; -VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; -VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; diff --git a/opendbc/generator/toyota/toyota_highlander_2017_pt.dbc b/opendbc/generator/toyota/toyota_highlander_2017_pt.dbc deleted file mode 100644 index b867e937065b5f..00000000000000 --- a/opendbc/generator/toyota/toyota_highlander_2017_pt.dbc +++ /dev/null @@ -1,33 +0,0 @@ -CM_ "IMPORT _toyota_2017.dbc" -CM_ "IMPORT _comma.dbc" - -BO_ 550 BRAKE_MODULE: 8 XXX - SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|255] "" XXX - SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|65535] "" XXX - SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|3] "" XXX - -BO_ 705 GAS_PEDAL: 8 XXX - SG_ GAS_RELEASED : 3|1@0+ (1,0) [0|1] "" XXX - SG_ GAS_PEDAL : 55|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 - -CM_ SG_ 548 BRAKE_PRESSURE "seems prop to pedal force"; -CM_ SG_ 548 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; -CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; -VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; -VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; -VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; diff --git a/opendbc/generator/toyota/toyota_highlander_hybrid_2018_pt.dbc b/opendbc/generator/toyota/toyota_highlander_hybrid_2018_pt.dbc deleted file mode 100644 index 8fe5ec1991f18a..00000000000000 --- a/opendbc/generator/toyota/toyota_highlander_hybrid_2018_pt.dbc +++ /dev/null @@ -1,33 +0,0 @@ -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 - -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"; diff --git a/opendbc/generator/toyota/toyota_nodsu_hybrid_pt.dbc b/opendbc/generator/toyota/toyota_nodsu_hybrid_pt.dbc deleted file mode 100644 index 4f641575188073..00000000000000 --- a/opendbc/generator/toyota/toyota_nodsu_hybrid_pt.dbc +++ /dev/null @@ -1,37 +0,0 @@ -CM_ "IMPORT _toyota_2017.dbc" -CM_ "IMPORT _comma.dbc" - -BO_ 295 GEAR_PACKET: 8 XXX - SG_ CAR_MOVEMENT : 39|8@0- (1,0) [0|255] "" XXX - SG_ COUNTER : 55|8@0+ (1,0) [0|255] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - SG_ GEAR : 47|4@0+ (1,0) [0|15] "" XXX - -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: 8 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 - SG_ STEER_ANGLE : 31|16@0- (0.056,0) [-500|500] "" XXX - -BO_ 610 EPS_STATUS: 8 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 : 63|8@0+ (1,0) [0|255] "" XXX - -CM_ SG_ 548 BRAKE_PRESSURE "seems prop to pedal force"; -CM_ SG_ 548 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; -CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; -CM_ SG_ 581 GAS_PEDAL "it seems slightly filtered"; -VAL_ 295 GEAR 0 "P" 1 "R" 2 "N" 3 "D" 4 "B"; -VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; -VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; diff --git a/opendbc/generator/toyota/toyota_nodsu_pt.dbc b/opendbc/generator/toyota/toyota_nodsu_pt.dbc deleted file mode 100644 index 026abdd88162a8..00000000000000 --- a/opendbc/generator/toyota/toyota_nodsu_pt.dbc +++ /dev/null @@ -1,49 +0,0 @@ -CM_ "IMPORT _toyota_2017.dbc" -CM_ "IMPORT _comma.dbc" - -BO_ 401 STEERING_LTA: 8 XXX - SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - SG_ SETME_X3 : 29|2@0+ (1,0) [0|3] "" XXX - SG_ PERCENTAGE : 39|8@0+ (1,0) [0|255] "" XXX - SG_ SETME_X64 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ ANGLE : 55|8@0- (0.5,0) [0|255] "" XXX - SG_ STEER_ANGLE_CMD : 15|16@0- (0.056,0) [-540|540] "" XXX - SG_ STEER_REQUEST : 25|1@0+ (1,0) [0|1] "" XXX - SG_ BIT : 30|1@0+ (1,0) [0|1] "" XXX - -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_ 705 GAS_PEDAL: 8 XXX - SG_ GAS_RELEASED : 3|1@0+ (1,0) [0|1] "" XXX - SG_ GAS_PEDAL : 55|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 - SG_ STEER_ANGLE : 31|16@0- (0.056,0) [-500|500] "" XXX - -BO_ 610 EPS_STATUS: 8 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 : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 956 GEAR_PACKET: 8 XXX - SG_ SPORT_ON : 2|1@0+ (1,0) [0|1] "" XXX - SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX - SG_ ECON_ON : 40|1@0+ (1,0) [0|1] "" XXX - -CM_ SG_ 548 BRAKE_PRESSURE "seems prop to pedal force"; -CM_ SG_ 548 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; -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"; -VAL_ 956 SPORT_ON 0 "off" 1 "on"; -VAL_ 956 ECON_ON 0 "off" 1 "on"; diff --git a/opendbc/generator/toyota/toyota_prius_2017_pt.dbc b/opendbc/generator/toyota/toyota_prius_2017_pt.dbc deleted file mode 100644 index d1a6d27db87ca1..00000000000000 --- a/opendbc/generator/toyota/toyota_prius_2017_pt.dbc +++ /dev/null @@ -1,40 +0,0 @@ -CM_ "IMPORT _toyota_2017.dbc" -CM_ "IMPORT _comma.dbc" - -BO_ 295 GEAR_PACKET: 8 XXX - SG_ CAR_MOVEMENT : 39|8@0- (1,0) [0|255] "" XXX - SG_ COUNTER : 55|8@0+ (1,0) [0|255] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - SG_ GEAR : 47|4@0+ (1,0) [0|15] "" XXX - -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: 8 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.66,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: 8 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 : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 1083 AUTOPARK_STATUS: 8 IPAS - SG_ STATE : 7|4@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"; -CM_ SG_ 1083 STATE "when the dashboard button is pressed, the value changes from zero to non-zero"; -VAL_ 295 GEAR 0 "P" 1 "R" 2 "N" 3 "D" 4 "B"; -VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; -VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; diff --git a/opendbc/generator/toyota/toyota_rav4_2017_pt.dbc b/opendbc/generator/toyota/toyota_rav4_2017_pt.dbc deleted file mode 100644 index e9d748b6c258d6..00000000000000 --- a/opendbc/generator/toyota/toyota_rav4_2017_pt.dbc +++ /dev/null @@ -1,32 +0,0 @@ -CM_ "IMPORT _toyota_2017.dbc" -CM_ "IMPORT _comma.dbc" - -BO_ 548 BRAKE_MODULE: 8 XXX - SG_ BRAKE_PRESSURE : 43|12@0+ (1,0) [0|4047] "" XXX - SG_ BRAKE_PRESSED : 5|1@0+ (1,0) [0|1] "" XXX - -BO_ 705 GAS_PEDAL: 8 XXX - SG_ GAS_RELEASED : 3|1@0+ (1,0) [0|1] "" XXX - SG_ GAS_PEDAL : 55|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 - -CM_ SG_ 548 BRAKE_PRESSURE "seems prop to pedal force"; -CM_ SG_ 548 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; -CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; -VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; -VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; -VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; diff --git a/opendbc/generator/toyota/toyota_rav4_hybrid_2017_pt.dbc b/opendbc/generator/toyota/toyota_rav4_hybrid_2017_pt.dbc deleted file mode 100644 index d5a265fbb8386d..00000000000000 --- a/opendbc/generator/toyota/toyota_rav4_hybrid_2017_pt.dbc +++ /dev/null @@ -1,45 +0,0 @@ -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_ SPORT_ON : 2|1@0+ (1,0) [0|1] "" XXX - SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX - SG_ SPORT_GEAR_ON : 33|1@0+ (1,0) [0|1] "" XXX - SG_ SPORT_GEAR : 38|3@0+ (1,0) [0|7] "" XXX - SG_ ECON_ON : 40|1@0+ (1,0) [0|1] "" XXX - SG_ DRIVE_ENGAGED : 47|1@0+ (1,0) [0|1] "" 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 SPORT_ON 0 "off" 1 "on"; -VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; -VAL_ 956 SPORT_GEAR_ON 0 "off" 1 "on"; -VAL_ 956 SPORT_GEAR 1 "S1" 2 "S2" 3 "S3" 4 "S4" 5 "S5" 6 "S6"; -VAL_ 956 ECON_ON 0 "off" 1 "on"; -VAL_ 956 DRIVE_ENGAGED 0 "off" 1 "on"; diff --git a/opendbc/generator/toyota/toyota_sienna_xle_2018_pt.dbc b/opendbc/generator/toyota/toyota_sienna_xle_2018_pt.dbc deleted file mode 100644 index 0c6ba26bc1ed7d..00000000000000 --- a/opendbc/generator/toyota/toyota_sienna_xle_2018_pt.dbc +++ /dev/null @@ -1,33 +0,0 @@ -CM_ "IMPORT _toyota_2017.dbc" -CM_ "IMPORT _comma.dbc" - -BO_ 550 BRAKE_MODULE: 8 XXX - SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|255] "" XXX - SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|65535] "" XXX - SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|3] "" XXX - -BO_ 705 GAS_PEDAL: 8 XXX - SG_ GAS_RELEASED : 3|1@0+ (1,0) [0|1] "" XXX - SG_ GAS_PEDAL : 55|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 - -CM_ SG_ 548 BRAKE_PRESSURE "seems prop to pedal force"; -CM_ SG_ 548 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; -CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; -VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; -VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; -VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby" diff --git a/opendbc/gm_global_a_lowspeed.dbc b/opendbc/gm_global_a_lowspeed.dbc deleted file mode 100644 index 9ea4d1da3d93db..00000000000000 --- a/opendbc/gm_global_a_lowspeed.dbc +++ /dev/null @@ -1,110 +0,0 @@ -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_: GMLAN NEO -VAL_TABLE_ GearShifter 3 "Park" 0 "Drive/Low" ; -VAL_TABLE_ DriverDoorStatus 1 "Opened" 0 "Closed" ; -VAL_TABLE_ LKAGapButton 2 "???" 1 "??" 0 "None" ; -VAL_TABLE_ CruiseButtons 6 "Cancel" 5 "Main" 3 "Set" 2 "Resume" 1 "None" ; -VAL_TABLE_ CruiseControlActive 1 "Active" 0 "Inactive" ; -VAL_TABLE_ BlinkerStatus 1 "Active" 0 "Inactive" ; - - -BO_ 274923520 DriverDoorStatus: 1 GMLAN - SG_ DriverDoorOpened : 0|1@0+ (1,0) [0|0] "" NEO - -BO_ 272629760 Chime: 5 NEO - SG_ ChimeType : 7|8@0+ (1,0) [0|0] "" GMLAN - SG_ ChimeRepeat : 23|8@0+ (1,0) [0|0] "" GMLAN - SG_ ChimeDuration : 15|8@0+ (1,0) [0|0] "" GMLAN - SG_ ChimeByte5 : 39|8@0+ (1,0) [0|0] "" GMLAN - SG_ ChimeByte4 : 31|8@0+ (1,0) [0|0] "" GMLAN - -BO_ 270581760 BlinkerStatus: 5 GMLAN - SG_ RightBlinker : 6|1@0+ (1,0) [0|0] "" NEO - SG_ LeftBlinker : 7|1@0+ (1,0) [0|0] "" NEO - SG_ BlinkerLight : 25|1@0+ (1,0) [0|0] "" NEO - -BO_ 270794752 SteeringWheelAngle: 8 GMLAN - SG_ SteeringWheelAngle : 39|16@0- (0.0625,0) [-540|540] "deg" NEO - -BO_ 271368192 GearShifter: 8 GMLAN - SG_ GearShifter : 17|2@0+ (1,0) [0|3] "" NEO - -BO_ 271360000 GasPedalRegenCruise: 8 GMLAN - SG_ CruiseControlActive : 56|1@0+ (1,0) [0|0] "" GMLAN - SG_ MaxRegen : 12|1@0+ (1,0) [0|1] "" GMLAN,NEO - SG_ GasPedal : 47|8@0+ (1,0) [0|254] "" GMLAN,NEO - SG_ GearShifter2NotUsed : 55|8@0+ (1,0) [0|255] "" GMLAN,NEO - -BO_ 270860288 BrakePedal: 2 GMLAN - SG_ BrakeLevel : 2|2@0+ (1,0) [0|3] "" NEO - SG_ BrakeSensor : 15|8@0+ (1,0) [0|255] "" NEO - -BO_ 275480576 WheelSpeed: 8 GMLAN - SG_ WheelSpeedFL : 7|16@0+ (0.01,0) [0|70] "yd/s" NEO - SG_ WheelSpeedFR : 39|16@0+ (0.01,0) [0|70] "yd/s" NEO - SG_ WheelSpeedRL : 23|16@0+ (0.01,0) [0|70] "yd/s" NEO - SG_ WheelSpeedRR : 55|16@0+ (0.01,0) [0|70] "yd/s" NEO - -BO_ 270598144 VehicleSpeed: 8 GMLAN - SG_ VehicleSpeed1 : 7|16@0+ (0.01,0) [0|100] "mph" NEO - SG_ VehicleSpeed2 : 39|16@0+ (0.01,0) [0|100] "mph" NEO - -BO_ 276135936 CruiseButtons: 3 GMLAN - SG_ CruiseButtons : 3|3@0+ (1,0) [0|12] "" NEO - -BO_ 276127744 CruiseButtons2: 1 GMLAN - SG_ LKAGapButton : 1|2@0+ (1,0) [0|2] "" NEO - - - -BA_DEF_ "UseGMParameterIDs" INT 0 0; -BA_DEF_ "ProtocolType" STRING ; -BA_DEF_ "BusType" STRING ; -BA_DEF_DEF_ "UseGMParameterIDs" 1; -BA_DEF_DEF_ "ProtocolType" "GMLAN"; -BA_DEF_DEF_ "BusType" ""; -BA_ "BusType" "CAN"; -BA_ "ProtocolType" "GMLAN"; -VAL_ 274923520 DriverDoorOpened 1 "Opened" 0 "Closed" ; -VAL_ 270581760 RightBlinker 1 "Active" 0 "Inactive" ; -VAL_ 270581760 LeftBlinker 1 "Active" 0 "Inactive" ; -VAL_ 270581760 BlinkerLight 1 "Active" 0 "Inactive" ; -VAL_ 271368192 GearShifter 3 "Park" 0 "Drive/Low" ; -VAL_ 271360000 CruiseControlActive 1 "Active" 0 "Inactive" ; -VAL_ 276135936 CruiseButtons 6 "Cancel" 5 "Main" 3 "Set" 2 "Resume" 1 "None" ; -VAL_ 276127744 LKAGapButton 2 "???" 1 "??" 0 "None" ; - diff --git a/opendbc/gm_global_a_lowspeed_1818125.dbc b/opendbc/gm_global_a_lowspeed_1818125.dbc deleted file mode 100644 index 0920e47bc16478..00000000000000 --- a/opendbc/gm_global_a_lowspeed_1818125.dbc +++ /dev/null @@ -1,3993 +0,0 @@ -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_ 2152177664 OTA_Electric_Pwr_Readiness_LS: 1 XXX - SG_ RmtRflshElecPwrRdness : 7|8@0+ (0.025,0) [0|6.375] "AmpHour" XXX - -BO_ 2152013824 Smart_High_Beam_Cust_LS: 1 XXX - SG_ SmrtHgBmAstCstSetAvail : 4|1@0+ (1,0) [0|1] "" XXX - SG_ SmrtHgBmAstCstCurrSetVal : 7|3@0+ (1,0) [0|7] "" XXX - -BO_ 2159255552 ODI_CenterStack_2_BCM_LS: 8 XXX - SG_ ODI_CntrStck2BCM : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2159247360 ODI_BCM_2_CenterStack_LS: 8 XXX - SG_ ODI_BCM2CntrStck : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2152046592 Remote_Climate_Control_Req_LS: 5 XXX - SG_ RmClmCtrlHMIActIndReq : 0|1@0+ (1,0) [0|1] "" XXX - SG_ RmClmCtrlRcrcSetReq : 3|3@0+ (1,0) [0|7] "" XXX - SG_ RmClmCtrlACSetReq : 10|3@0+ (1,0) [0|7] "" XXX - SG_ RmClmCtrlFrntFanStReq : 15|5@0+ (1,0) [0|31] "" XXX - SG_ RmClmCtrlFLAirDtStReq : 19|4@0+ (1,0) [0|15] "" XXX - SG_ RmClmCtrlClmModSetReq : 23|4@0+ (1,0) [0|15] "" XXX - SG_ RmClmCtrlLtSTempStReq : 29|6@0+ (1,0) [0|63] "" XXX - SG_ RmClmCtrlRrDfgSetReq : 31|2@0+ (1,0) [0|3] "" XXX - SG_ RmClmCtrlRtSTempStReq : 37|6@0+ (1,0) [0|63] "" XXX - SG_ RmClmCtrlSyncSetReq : 39|2@0+ (1,0) [0|3] "" XXX - -BO_ 2152030208 Tuner_Frequency_Request_LS: 8 XXX - SG_ TnrFrqBndReq : 3|4@0+ (1,0) [0|15] "" XXX - SG_ TnrFrqChnlReq : 15|56@0+ (1,0) [0|1] "" XXX - -BO_ 2150531072 Regen_Power_Ind_LS: 4 XXX - SG_ RegPwrLmtdDspPrcnt : 0|9@0- (0.392157,0) [-100.392192|100.000035] "%" XXX - SG_ RegPwrLmtdDspPrcntVs : 1|1@0+ (1,0) [0|1] "" XXX - SG_ RegPwrLmtdIO : 2|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151833600 Heated_Wndshild_CstmrIhbt_Req_LS: 1 XXX - SG_ HtdFrntWSCustRqIhbt : 5|1@0+ (1,0) [0|1] "" XXX - SG_ HtdFrntWSDispReq : 7|2@0+ (1,0) [0|3] "" XXX - -BO_ 2151817216 Heated_Wndshild_Cstmr_Req_LS: 1 XXX - SG_ HtdFrntWSCustRq : 7|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151849984 Seat_Level_Setting_Request_LS: 2 XXX - SG_ AutoThrmlStPasLvlStRq : 2|3@0+ (1,0) [0|7] "" XXX - SG_ AutoThrmlStDrvLvStRq : 5|3@0+ (1,0) [0|7] "" XXX - SG_ AutoThrmlStPassMdStRq : 7|2@0+ (1,0) [0|3] "" XXX - SG_ AutoThrmlStDrvMdStRq : 15|2@0+ (1,0) [0|3] "" XXX - -BO_ 2153897984 ARB_OpMode_Customization_LS: 1 XXX - SG_ RunBrdExtdFtrAvail : 3|1@0+ (1,0) [0|1] "" XXX - SG_ RunBrdOpMdCstCurrStVal : 6|3@0+ (1,0) [0|7] "" XXX - SG_ RunBrdOpMdCstStAvail : 7|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151702528 Lane_Keeping_Assist_LS: 2 XXX - SG_ LnKpngAstRecfblIndRq : 2|3@0+ (1,0) [0|7] "" XXX - SG_ LnMrkngIndLft : 4|2@0+ (1,0) [0|3] "" XXX - SG_ LnKepAsstStIndLft : 7|3@0+ (1,0) [0|7] "" XXX - SG_ LnMrkngIndRgt : 12|2@0+ (1,0) [0|3] "" XXX - SG_ LnKepAsstStIndRgt : 15|3@0+ (1,0) [0|7] "" XXX - -BO_ 2156986368 PassPhrase_3_AMM_LS: 8 XXX - SG_ WiFiPssPhrsDgts17to24_Mp : 7|64@0+ (1,0) [0|0] "" XXX - -BO_ 2156978176 PassPhrase_2_AMM_LS: 8 XXX - SG_ WiFiPssPhrsDgts9to16_Mp : 7|64@0+ (1,0) [0|0] "" XXX - -BO_ 2156969984 PassPhrase_1_AMM_LS: 8 XXX - SG_ WiFiPssPhrsDgts1to8_Mp : 7|64@0+ (1,0) [0|0] "" XXX - -BO_ 2150236160 Unlock_Key_Store_Crypt_2_LS: 8 XXX - SG_ UlckKyStrCrptoDt2Group : 4|61@0+ (1,0) [0|0] "" XXX - SG_ UlckKyStrCrptoDt2 : 3|60@0+ (1,0) [0|1.15292150460685E+018] "" XXX - SG_ UlckKyStrCrptoDt2M : 4|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150170624 Unlock_Key_Store_Crypt_1_LS: 8 XXX - SG_ UlckKyStrCrptoDt1Group : 4|61@0+ (1,0) [0|0] "" XXX - SG_ UlckKyStrCrptoDt1 : 3|60@0+ (1,0) [0|1.15292150460685E+018] "" XXX - SG_ UlckKyStrCrptoDt1M : 4|1@0+ (1,0) [0|1] "" XXX - -BO_ 2155126784 Drvr_Seat_Rearward_Movmnt_LS: 1 XXX - SG_ DrvrSetRrwrdMvmnt : 7|3@0+ (1,0) [0|7] "" XXX - -BO_ 2154725376 Auxiliary_Heater_LS: 1 XXX - SG_ AuxHtrAtv378 : 6|1@0+ (1,0) [0|1] "" XXX - SG_ AuxHtrRq : 7|1@0+ (1,0) [0|1] "" XXX - -BO_ 2157051904 WiFi_Station_AMM_LS: 5 XXX - SG_ WiFiStatnMpReq : 1|34@0+ (1,0) [0|0] "" XXX - SG_ WSMR_WiFiAssnReq : 1|2@0+ (1,0) [0|3] "" XXX - SG_ WSMR_WiFiStnMpMACAddr : 15|32@0+ (1,0) [0|4294967295] "" XXX - -BO_ 2156994560 WiFi_AP_Data_AMM_LS: 2 XXX - SG_ WiFiAccsPntData_Mp : 0|9@0+ (1,0) [0|0] "" XXX - SG_ WAPDM_WiFiEnStat : 0|1@0+ (1,0) [0|1] "" XXX - SG_ WAPDM_EncrptnType : 11|4@0+ (1,0) [0|15] "" XXX - SG_ WAPDM_SecurityType : 15|4@0+ (1,0) [0|15] "" XXX - -BO_ 2158133248 Hill_Top_Customization_LS: 6 XXX - SG_ HTRCsStAvail : 0|1@0+ (1,0) [0|1] "" XXX - SG_ HTRCsAvail : 7|7@0+ (1,0) [0|0] "" XXX - SG_ HTRCA_Res3Avail : 1|1@0+ (1,0) [0|1] "" XXX - SG_ HTRCA_Res2Avail : 2|1@0+ (1,0) [0|1] "" XXX - SG_ HTRCA_Res1Avail : 3|1@0+ (1,0) [0|1] "" XXX - SG_ HTRCA_OnAwAvail : 4|1@0+ (1,0) [0|1] "" XXX - SG_ HTRCA_OnHmAvail : 5|1@0+ (1,0) [0|1] "" XXX - SG_ HTRCA_OnAvail : 6|1@0+ (1,0) [0|1] "" XXX - SG_ HTRCA_OffAvail : 7|1@0+ (1,0) [0|1] "" XXX - SG_ HTRCsCrStVal : 10|3@0+ (1,0) [0|7] "" XXX - SG_ HVDpltnMdMxCnfdcRgExt : 21|14@0+ (0.1,0) [0|1638.3] "km" XXX - SG_ HVDpltnMdMiCnfdcRgExt : 37|14@0+ (0.1,0) [0|1638.3] "km" XXX - -BO_ 2154651648 Telematics_Audio_Control_LS: 1 XXX - SG_ TeleAudCtl : 7|8@0+ (1,0) [0|0] "" XXX - SG_ TAC_AudConctOutcm : 3|4@0+ (1,0) [0|15] "" XXX - SG_ TAC_AudChConctStat : 7|4@0+ (1,0) [0|15] "" XXX - -BO_ 2154635264 Telematics_Audio_Request_LS: 1 XXX - SG_ TeleAudReq : 7|8@0+ (1,0) [0|0] "" XXX - SG_ TAR_AudSrcStat : 3|4@0+ (1,0) [0|15] "" XXX - SG_ TAR_AudConctReq : 7|4@0+ (1,0) [0|15] "" XXX - -BO_ 2152529920 LVM_Audio_Video_Command_LS: 2 XXX - SG_ LowVolModAudVidCmd : 5|14@0+ (1,0) [0|0] "" XXX - SG_ LVMAVC_StreoAudRsp : 0|2@0+ (1,0) [0|3] "" XXX - SG_ LVMAVC_PrmtAudRsp : 2|2@0+ (1,0) [0|3] "" XXX - SG_ LVMAVC_RemtEnbl : 5|3@0+ (1,0) [0|7] "" XXX - SG_ LVMAVC_SpchRcgnAval : 9|2@0+ (1,0) [0|3] "" XXX - SG_ LVMAVC_RemSpchRcgnActn : 11|2@0+ (1,0) [0|3] "" XXX - SG_ LVMAVC_RemSpchRcgnID : 14|3@0+ (1,0) [0|7] "" XXX - -BO_ 2152513536 LVM_Audio_Video_Req_LS: 2 XXX - SG_ LowVolModAudVidReq : 0|9@0+ (1,0) [0|0] "" XXX - SG_ LVMAVR_DispReq : 0|3@0+ (1,0) [0|7] "" XXX - SG_ LVMAVR_SpchRcgnAct : 9|2@0+ (1,0) [0|3] "" XXX - SG_ LVMAVR_PrmtAudReq : 11|2@0+ (1,0) [0|3] "" XXX - SG_ LVMAVR_StreoAudReq : 13|2@0+ (1,0) [0|3] "" XXX - -BO_ 2154889216 Cluster_HMI_Animation_Req_LS: 1 XXX - SG_ ClstrHMIAnmReq : 7|3@0+ (1,0) [0|7] "" XXX - -BO_ 2154872832 Infotainment_Activation_Req_LS: 1 XXX - SG_ RmRflshUpdtAvail : 6|1@0+ (1,0) [0|1] "" XXX - SG_ InfoActvnReq : 7|1@0+ (1,0) [0|1] "" XXX - -BO_ 2156961792 SSID_AMM_3_LS: 8 XXX - SG_ WiFiSSIDDgts17to24_Mp : 7|64@0+ (1,0) [0|0] "" XXX - -BO_ 2154569728 Infotainment_System_State_LS: 1 XXX - SG_ InfotnmntSysSt : 7|5@0+ (1,0) [0|31] "" XXX - -BO_ 2151931904 Custom_Launch_Ctrl_LS: 8 XXX - SG_ LnchCtrlMdStat : 2|3@0+ (1,0) [0|7] "" XXX - SG_ LnchCtrlWhlSlpStat : 7|5@0+ (1,0) [0|31] "" XXX - SG_ PTExPrtclFltWrng3IO : 8|1@0+ (1,0) [0|1] "" XXX - SG_ AWDRecmndIO : 9|1@0+ (1,0) [0|1] "" XXX - SG_ LnchCtrlEngRPMStat : 15|6@0+ (1,0) [0|63] "" XXX - SG_ ACCSysSltdMd : 17|2@0+ (1,0) [0|3] "" XXX - SG_ VehSpdCntlSystmType : 20|3@0+ (1,0) [0|7] "" XXX - SG_ PTExPartFltManRegStat : 23|3@0+ (1,0) [0|7] "" XXX - SG_ TCSTempDsblReqIO : 24|1@0+ (1,0) [0|1] "" XXX - SG_ VehStbCmptvMdCstAvl : 25|1@0+ (1,0) [0|1] "" XXX - SG_ VehStbEnmntCstAvl : 26|1@0+ (1,0) [0|1] "" XXX - SG_ TCSysCstAvl : 27|1@0+ (1,0) [0|1] "" XXX - SG_ VehStbCmptvMdCurSt : 28|1@0+ (1,0) [0|1] "" XXX - SG_ ElctShfPriLtdPerfMdIO : 29|1@0+ (1,0) [0|1] "" XXX - SG_ RegVltCtlEngyRcvryAct : 30|1@0+ (1,0) [0|1] "" XXX - SG_ ACCSysSltdMdDispIO : 31|1@0+ (1,0) [0|1] "" XXX - SG_ LnchCtrlTmrVal : 35|4@0+ (1,0) [0|15] "" XXX - SG_ VehStbEnhmntCurSt : 36|1@0+ (1,0) [0|1] "" XXX - SG_ TCSysCurSt : 37|1@0+ (1,0) [0|1] "" XXX - SG_ TracAndStbScrnCnfg : 39|2@0+ (1,0) [0|3] "" XXX - SG_ BiFuelRflGaslinIndReq : 42|3@0+ (1,0) [0|7] "" XXX - SG_ AutoShtdwnIO : 43|1@0+ (1,0) [0|1] "" XXX - SG_ LnchCtrlBrkPresVal : 47|4@0+ (10,0) [0|150] "%" XXX - SG_ AutoShtdwnTmr : 55|8@0+ (1,0) [0|255] "min" XXX - SG_ FuelMdTrnstnIndReq : 63|4@0+ (1,0) [0|15] "" XXX - -BO_ 2150244352 HMI_EngyConsmpHistGrph_1_LS: 8 XXX - SG_ EngyCnsHsGrphDspDtVal : 7|55@0+ (1,0) [0|0] "" XXX - SG_ ECHGDDV_Col1 : 2|5@0+ (1,0) [0|31] "" XXX - SG_ ECHGDDV_EngyConsAvg : 7|5@0+ (1,0) [0|31] "" XXX - SG_ ECHGDDV_Col3 : 8|5@0+ (1,0) [0|31] "" XXX - SG_ ECHGDDV_Col2 : 13|5@0+ (1,0) [0|31] "" XXX - SG_ ECHGDDV_Col4 : 19|5@0+ (1,0) [0|31] "" XXX - SG_ ECHGDDV_Col6 : 25|5@0+ (1,0) [0|31] "" XXX - SG_ ECHGDDV_Col5 : 30|5@0+ (1,0) [0|31] "" XXX - SG_ ECHGDDV_Col7 : 36|5@0+ (1,0) [0|31] "" XXX - SG_ ECHGDDV_Col9 : 42|5@0+ (1,0) [0|31] "" XXX - SG_ ECHGDDV_Col8 : 47|5@0+ (1,0) [0|31] "" XXX - SG_ ECHGDDV_Col10 : 53|5@0+ (1,0) [0|31] "" XXX - -BO_ 2156953600 SSID_AMM_2_LS: 8 XXX - SG_ WiFiSSIDDgts9to16_Mp : 7|64@0+ (1,0) [0|0] "" XXX - -BO_ 2151686144 SD_Card_LS: 2 XXX - SG_ SDCrdFullIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ SDCrdErrIO : 1|1@0+ (1,0) [0|1] "" XXX - SG_ NoSDCrdPrIO : 2|1@0+ (1,0) [0|1] "" XXX - -BO_ 2155028480 Lane_Change_Threat_LS: 2 XXX - SG_ RgtLnChgThrt : 0|1@0+ (1,0) [0|1] "" XXX - SG_ RtLnChngThrtAprchSpd : 15|8@0- (1,0) [-128|127] "km/h" XXX - -BO_ 2151915520 HMI_Display_LS: 8 XXX - SG_ AHDisbldDrOpnIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ AHDisbldStbltIO : 1|1@0+ (1,0) [0|1] "" XXX - SG_ AHAppBrkPedlIO : 2|1@0+ (1,0) [0|1] "" XXX - SG_ AHServcIO : 3|1@0+ (1,0) [0|1] "" XXX - SG_ ShfToPrkBfExtngIO : 4|1@0+ (1,0) [0|1] "" XXX - SG_ AHEnbld : 5|1@0+ (1,0) [0|1] "" XXX - SG_ AHAct : 6|1@0+ (1,0) [0|1] "" XXX - SG_ ESPDrvrIlkShfAtdIO : 7|1@0+ (1,0) [0|1] "" XXX - SG_ ESPTransMalfIO : 9|1@0+ (1,0) [0|1] "" XXX - SG_ ESPRngInvldReqIO : 10|1@0+ (1,0) [0|1] "" XXX - SG_ ESPPrkInvldReqIO : 11|1@0+ (1,0) [0|1] "" XXX - SG_ ESPHldShfLvrToEngRgIO : 12|1@0+ (1,0) [0|1] "" XXX - SG_ ESPDrvrPrkIlkSftAtdIO : 13|1@0+ (1,0) [0|1] "" XXX - SG_ EngIntkArBstPrExtRngGroup : 14|15@0+ (1,0) [0|0] "" XXX - SG_ EngIntkArBstPrExtRng : 8|9@0+ (1,-110) [-110|401] "kPa" XXX - SG_ EngIntkArBstPrExtRngV : 14|1@0+ (1,0) [0|1] "" XXX - SG_ ElcTransRngSlctVDA : 15|1@0+ (1,0) [0|1] "" XXX - SG_ ElecShfRngDispRCExtd : 27|4@0+ (1,0) [0|15] "" XXX - SG_ ElecShfRngDisp : 31|4@0+ (1,0) [0|15] "" XXX - SG_ DrvEffInd : 39|8@0- (0.78125,0) [-100|99.21875] "%" XXX - SG_ ESPShfToDrvTryAgnIO : 43|1@0+ (1,0) [0|1] "" XXX - SG_ ESPTrnVehOffFrPrkIO : 44|1@0+ (1,0) [0|1] "" XXX - SG_ ESPTrnsCtlrMalfIO : 45|1@0+ (1,0) [0|1] "" XXX - SG_ ElcShfPriTwoGrsSlInRq : 47|2@0+ (1,0) [0|3] "" XXX - -BO_ 2152153088 Right_Rear_Seat_Display_Stats_LS: 6 XXX - SG_ RRStCtlDispStat : 3|44@0+ (1,0) [0|0] "" XXX - SG_ RRSCDS_MassgTyp : 1|4@0+ (1,0) [0|15] "" XXX - SG_ RRSCDS_Massg : 3|2@0+ (1,0) [0|3] "" XXX - SG_ RRSCDS_HdrstFwdRrwd : 8|2@0+ (1,0) [0|3] "" XXX - SG_ RRSCDS_HdrstUpDn : 10|2@0+ (1,0) [0|3] "" XXX - SG_ RRSCDS_MassgIntsty : 13|3@0+ (1,0) [0|7] "" XXX - SG_ RRSCDS_HdrstTltFwdRr : 17|2@0+ (1,0) [0|3] "" XXX - SG_ RRSCDS_HdrstWngInOt : 19|2@0+ (1,0) [0|3] "" XXX - SG_ RRSCDS_HdrstFdRrUDn : 22|3@0+ (1,0) [0|7] "" XXX - SG_ RRSCDS_LmbrUDnFdRr : 25|3@0+ (1,0) [0|7] "" XXX - SG_ RRSCDS_LmbrFwdRr : 27|2@0+ (1,0) [0|3] "" XXX - SG_ RRSCDS_LmbrUpDwn : 29|2@0+ (1,0) [0|3] "" XXX - SG_ RRSCDS_UprShldrFdRr : 31|2@0+ (1,0) [0|3] "" XXX - SG_ RRSCDS_BkCshBlstInOt : 34|3@0+ (1,0) [0|7] "" XXX - SG_ RRSCDS_CshBlstrInOut : 36|2@0+ (1,0) [0|3] "" XXX - SG_ RRSCDS_BkBlstrInOut : 38|2@0+ (1,0) [0|3] "" XXX - SG_ RRSCDS_UnsdRsrvd : 42|3@0+ (1,0) [0|7] "" XXX - SG_ RRSCDS_DispReq : 43|1@0+ (1,0) [0|1] "" XXX - SG_ RRSCDS_DispSz : 45|2@0+ (1,0) [0|3] "" XXX - SG_ RRSCDS_CshLgAdjFdRr : 47|2@0+ (1,0) [0|3] "" XXX - -BO_ 2152136704 Right_Rear_Seat_Massage_LS: 8 XXX - SG_ RRStMassgPrty : 7|64@0+ (1,0) [0|0] "" XXX - SG_ RRSMP_Type2 : 3|4@0+ (1,0) [0|15] "" XXX - SG_ RRSMP_Type1 : 7|4@0+ (1,0) [0|15] "" XXX - SG_ RRSMP_Type4 : 11|4@0+ (1,0) [0|15] "" XXX - SG_ RRSMP_Type3 : 15|4@0+ (1,0) [0|15] "" XXX - SG_ RRSMP_Type6 : 19|4@0+ (1,0) [0|15] "" XXX - SG_ RRSMP_Type5 : 23|4@0+ (1,0) [0|15] "" XXX - SG_ RRSMP_Type8 : 27|4@0+ (1,0) [0|15] "" XXX - SG_ RRSMP_Type7 : 31|4@0+ (1,0) [0|15] "" XXX - SG_ RRSMP_Type10 : 35|4@0+ (1,0) [0|15] "" XXX - SG_ RRSMP_Type9 : 39|4@0+ (1,0) [0|15] "" XXX - SG_ RRSMP_Type12 : 43|4@0+ (1,0) [0|15] "" XXX - SG_ RRSMP_Type11 : 47|4@0+ (1,0) [0|15] "" XXX - SG_ RRSMP_Type14 : 51|4@0+ (1,0) [0|15] "" XXX - SG_ RRSMP_Type13 : 55|4@0+ (1,0) [0|15] "" XXX - SG_ RRSMP_UnsdRsrvd : 56|1@0+ (1,0) [0|1] "" XXX - SG_ RRSMP_MaxDispVal : 59|3@0+ (1,0) [0|7] "" XXX - SG_ RRSMP_Type15 : 63|4@0+ (1,0) [0|15] "" XXX - -BO_ 2152120320 Right_Rear_Seat_Actuator_LS: 8 XXX - SG_ RRStActPrty : 7|64@0+ (1,0) [0|0] "" XXX - SG_ RRSAP_HdrstUpDn : 3|4@0+ (1,0) [0|15] "" XXX - SG_ RRSAP_Massg : 7|4@0+ (1,0) [0|15] "" XXX - SG_ RRSAP_HdrstUpDnFdRr : 11|4@0+ (1,0) [0|15] "" XXX - SG_ RRSAP_HdrstFwdRrwd : 15|4@0+ (1,0) [0|15] "" XXX - SG_ RRSAP_HdrstTltFwdRr : 19|4@0+ (1,0) [0|15] "" XXX - SG_ RRSAP_HdrstWngsInOut : 23|4@0+ (1,0) [0|15] "" XXX - SG_ RRSAP_LmbrUpDwn : 27|4@0+ (1,0) [0|15] "" XXX - SG_ RRSAP_UprShldrFwdRr : 31|4@0+ (1,0) [0|15] "" XXX - SG_ RRSAP_LmbrUpDnFdRr : 35|4@0+ (1,0) [0|15] "" XXX - SG_ RRSAP_LmbrFwdRr : 39|4@0+ (1,0) [0|15] "" XXX - SG_ RRSAP_CshBlstrInOut : 43|4@0+ (1,0) [0|15] "" XXX - SG_ RRSAP_BkBlstrInOut : 47|4@0+ (1,0) [0|15] "" XXX - SG_ RRSAP_CshLgthAdjFdRr : 51|4@0+ (1,0) [0|15] "" XXX - SG_ RRSAP_BkCshBlstrInOut : 55|4@0+ (1,0) [0|15] "" XXX - SG_ RRSAP_UnsdRsrvd : 59|4@0+ (1,0) [0|15] "" XXX - SG_ RRSAP_DispSz : 63|4@0+ (1,0) [0|15] "" XXX - -BO_ 2152103936 Left_Rear_Seat_Display_Status_LS: 6 XXX - SG_ LRStCtlDispStat : 3|44@0+ (1,0) [0|0] "" XXX - SG_ LRSCDS_MassgTyp : 1|4@0+ (1,0) [0|15] "" XXX - SG_ LRSCDS_Massg : 3|2@0+ (1,0) [0|3] "" XXX - SG_ LRSCDS_HdrstFwdRrwd : 8|2@0+ (1,0) [0|3] "" XXX - SG_ LRSCDS_HdrstUpDn : 10|2@0+ (1,0) [0|3] "" XXX - SG_ LRSCDS_MassgIntsty : 13|3@0+ (1,0) [0|7] "" XXX - SG_ LRSCDS_HdrstTltFwdRr : 17|2@0+ (1,0) [0|3] "" XXX - SG_ LRSCDS_HdrstWngInOt : 19|2@0+ (1,0) [0|3] "" XXX - SG_ LRSCDS_HdrstFdRrUDn : 22|3@0+ (1,0) [0|7] "" XXX - SG_ LRSCDS_LmbrUDnFdRr : 25|3@0+ (1,0) [0|7] "" XXX - SG_ LRSCDS_LmbrFwdRr : 27|2@0+ (1,0) [0|3] "" XXX - SG_ LRSCDS_LmbrUpDwn : 29|2@0+ (1,0) [0|3] "" XXX - SG_ LRSCDS_UprShldrFdRr : 31|2@0+ (1,0) [0|3] "" XXX - SG_ LRSCDS_BkCshBlstInOt : 34|3@0+ (1,0) [0|7] "" XXX - SG_ LRSCDS_CshBlstrInOut : 36|2@0+ (1,0) [0|3] "" XXX - SG_ LRSCDS_BkBlstrInOut : 38|2@0+ (1,0) [0|3] "" XXX - SG_ LRSCDS_UnsdRsrvd : 42|3@0+ (1,0) [0|7] "" XXX - SG_ LRSCDS_DispReq : 43|1@0+ (1,0) [0|1] "" XXX - SG_ LRSCDS_DispSz : 45|2@0+ (1,0) [0|3] "" XXX - SG_ LRSCDS_CshLgAdjFdRr : 47|2@0+ (1,0) [0|3] "" XXX - -BO_ 2152087552 Left_Rear_Seat_Massage_LS: 8 XXX - SG_ LRStMassgPrty : 7|64@0+ (1,0) [0|0] "" XXX - SG_ LRSMP_Type2 : 3|4@0+ (1,0) [0|15] "" XXX - SG_ LRSMP_Type1 : 7|4@0+ (1,0) [0|15] "" XXX - SG_ LRSMP_Type4 : 11|4@0+ (1,0) [0|15] "" XXX - SG_ LRSMP_Type3 : 15|4@0+ (1,0) [0|15] "" XXX - SG_ LRSMP_Type6 : 19|4@0+ (1,0) [0|15] "" XXX - SG_ LRSMP_Type5 : 23|4@0+ (1,0) [0|15] "" XXX - SG_ LRSMP_Type8 : 27|4@0+ (1,0) [0|15] "" XXX - SG_ LRSMP_Type7 : 31|4@0+ (1,0) [0|15] "" XXX - SG_ LRSMP_Type10 : 35|4@0+ (1,0) [0|15] "" XXX - SG_ LRSMP_Type9 : 39|4@0+ (1,0) [0|15] "" XXX - SG_ LRSMP_Type12 : 43|4@0+ (1,0) [0|15] "" XXX - SG_ LRSMP_Type11 : 47|4@0+ (1,0) [0|15] "" XXX - SG_ LRSMP_Type14 : 51|4@0+ (1,0) [0|15] "" XXX - SG_ LRSMP_Type13 : 55|4@0+ (1,0) [0|15] "" XXX - SG_ LRSMP_UnsdRsrvd : 56|1@0+ (1,0) [0|1] "" XXX - SG_ LRSMP_MaxDispVal : 59|3@0+ (1,0) [0|7] "" XXX - SG_ LRSMP_Type15 : 63|4@0+ (1,0) [0|15] "" XXX - -BO_ 2152071168 Left_Rear_Seat_Actuator_LS: 8 XXX - SG_ LRStActPrty : 7|64@0+ (1,0) [0|0] "" XXX - SG_ LRSAP_HdrstUpDn : 3|4@0+ (1,0) [0|15] "" XXX - SG_ LRSAP_Massg : 7|4@0+ (1,0) [0|15] "" XXX - SG_ LRSAP_HdrstUpDnFdRr : 11|4@0+ (1,0) [0|15] "" XXX - SG_ LRSAP_HdrstFwdRrwd : 15|4@0+ (1,0) [0|15] "" XXX - SG_ LRSAP_HdrstTltFwdRr : 19|4@0+ (1,0) [0|15] "" XXX - SG_ LRSAP_HdrstWngsInOut : 23|4@0+ (1,0) [0|15] "" XXX - SG_ LRSAP_LmbrUpDwn : 27|4@0+ (1,0) [0|15] "" XXX - SG_ LRSAP_UprShldrFwdRr : 31|4@0+ (1,0) [0|15] "" XXX - SG_ LRSAP_LmbrUpDnFdRr : 35|4@0+ (1,0) [0|15] "" XXX - SG_ LRSAP_LmbrFwdRr : 39|4@0+ (1,0) [0|15] "" XXX - SG_ LRSAP_CshBlstrInOut : 43|4@0+ (1,0) [0|15] "" XXX - SG_ LRSAP_BkBlstrInOut : 47|4@0+ (1,0) [0|15] "" XXX - SG_ LRSAP_CshLgthAdjFdRr : 51|4@0+ (1,0) [0|15] "" XXX - SG_ LRSAP_BkCshBlstrInOut : 55|4@0+ (1,0) [0|15] "" XXX - SG_ LRSAP_UnsdRsrvd : 59|4@0+ (1,0) [0|15] "" XXX - SG_ LRSAP_DispSz : 63|4@0+ (1,0) [0|15] "" XXX - -BO_ 2153947136 Remote_Reflash_Stat_LS: 1 XXX - SG_ RmtRflshMdAct : 7|1@0+ (1,0) [0|1] "" XXX - -BO_ 2152628224 OnBoard_Tester_Response_LS: 2 XXX - SG_ OBTCResp : 2|11@0+ (1,0) [0|0] "" XXX - SG_ OBTCR_Stat : 2|3@0+ (1,0) [0|7] "" XXX - SG_ OBTCR_ReqstrID : 15|8@0+ (1,0) [0|255] "" XXX - SG_ OBTCMstrStat : 5|3@0+ (1,0) [0|7] "" XXX - -BO_ 2152112128 Performanc_Mode_Vis_Scrn_Stat_LS: 5 XXX - SG_ PerfMdVislztnScrnStat : 0|33@0+ (1,0) [0|0] "" XXX - SG_ PMVSS_Snd : 0|3@0+ (1,0) [0|7] "" XXX - SG_ PMVSS_Trans : 10|3@0+ (1,0) [0|7] "" XXX - SG_ PMVSS_Eng : 13|3@0+ (1,0) [0|7] "" XXX - SG_ PMVSS_Drvln : 17|3@0+ (1,0) [0|7] "" XXX - SG_ PMVSS_Susp : 20|3@0+ (1,0) [0|7] "" XXX - SG_ PMVSS_Strng : 23|3@0+ (1,0) [0|7] "" XXX - SG_ PMVSS_PsngrSeat : 24|3@0+ (1,0) [0|7] "" XXX - SG_ PMVSS_DrvrSeat : 27|3@0+ (1,0) [0|7] "" XXX - SG_ PMVSS_AdptCrsCnt : 30|3@0+ (1,0) [0|7] "" XXX - SG_ PMVSS_Disps : 34|3@0+ (1,0) [0|7] "" XXX - SG_ PMVSS_Exhst : 37|3@0+ (1,0) [0|7] "" XXX - SG_ PerfMdMainMenuType : 3|3@0+ (1,0) [0|7] "" XXX - -BO_ 2152775680 Front_360_Camera_On_LS: 3 XXX - SG_ DispFrt360CamOn : 0|1@0+ (1,0) [0|1] "" XXX - SG_ RrPedDetCstStAvl : 1|1@0+ (1,0) [0|1] "" XXX - SG_ RrPedDetCstStVal : 4|3@0+ (1,0) [0|7] "" XXX - SG_ RrPdDetHptcStVbRqSeqN : 6|2@0+ (1,0) [0|3] "" XXX - SG_ TrgdVidRecFetrPrsnt : 7|1@0+ (1,0) [0|1] "" XXX - SG_ RrPdDetHptcStVbRq : 13|6@0+ (1,0) [0|63] "Pulse" XXX - SG_ DispTrgdVidOn : 14|1@0+ (1,0) [0|1] "" XXX - SG_ a_360DegVidFetrPrsnt : 15|1@0+ (1,0) [0|1] "" XXX - SG_ DispSmrtTwVidOn : 16|1@0+ (1,0) [0|1] "" XXX - SG_ RrPedDetCstAvail : 23|7@0+ (1,0) [0|0] "" XXX - SG_ RPDCA_Resrv3Avail : 17|1@0+ (1,0) [0|1] "" XXX - SG_ RPDCA_Resrv2Avail : 18|1@0+ (1,0) [0|1] "" XXX - SG_ RPDCA_Resrv1Avail : 19|1@0+ (1,0) [0|1] "" XXX - SG_ RPDCA_AlrtBrkAvail : 20|1@0+ (1,0) [0|1] "" XXX - SG_ RPDCA_AlrtAvail : 21|1@0+ (1,0) [0|1] "" XXX - SG_ RPDCA_OnAvail : 22|1@0+ (1,0) [0|1] "" XXX - SG_ RPDCA_OfAvail : 23|1@0+ (1,0) [0|1] "" XXX - -BO_ 2153857024 Teen_Driver_Event_Report_2_LS: 8 XXX - SG_ TnDrvRptCrdAvlDspDat : 6|13@0+ (1,0) [0|0] "" XXX - SG_ TDRCADD_FCHdwyAlrt : 0|1@0+ (1,0) [0|1] "" XXX - SG_ TDRCADD_ABSAtvEvt : 1|1@0+ (1,0) [0|1] "" XXX - SG_ TDRCADD_StCtrlEvnts : 2|1@0+ (1,0) [0|1] "" XXX - SG_ TDRCADD_TrCtrlEvnts : 3|1@0+ (1,0) [0|1] "" XXX - SG_ TDRCADD_OvSpdEvnt : 4|1@0+ (1,0) [0|1] "" XXX - SG_ TDRCADD_DistDrvn : 5|1@0+ (1,0) [0|1] "" XXX - SG_ TDRCADD_MaxSpd : 6|1@0+ (1,0) [0|1] "" XXX - SG_ TDRCADD_LDWEvnts : 10|1@0+ (1,0) [0|1] "" XXX - SG_ TDRCADD_WOTEvnts : 11|1@0+ (1,0) [0|1] "" XXX - SG_ TDRCADD_DrwDrvAlrt : 12|1@0+ (1,0) [0|1] "" XXX - SG_ TDRCADD_FCMBrEvts : 13|1@0+ (1,0) [0|1] "" XXX - SG_ TDRCADD_RCMBrEvts : 14|1@0+ (1,0) [0|1] "" XXX - SG_ TDRCADD_FCImntAlrts : 15|1@0+ (1,0) [0|1] "" XXX - SG_ TeenDrvWOTEvntsRpt : 9|10@0+ (1,0) [0|1023] "counts" XXX - SG_ TnDrvABSAtvEvntsRpt : 31|10@0+ (1,0) [0|1023] "counts" XXX - SG_ TnDrvStblCtrlEvntsRpt : 37|10@0+ (1,0) [0|1023] "counts" XXX - SG_ TnDrvDrowDrvAlrtsRpt : 43|10@0+ (1,0) [0|1023] "counts" XXX - SG_ TnDrvTrCtrlEvntsRpt : 49|10@0+ (1,0) [0|1023] "counts" XXX - -BO_ 2153865216 Teen_Driver_Customization_Req_LS: 4 XXX - SG_ TeenDrvReq : 3|4@0+ (1,0) [0|15] "" XXX - SG_ TDOvSpdWrnCstStReq : 12|5@0+ (1,0) [0|0] "" XXX - SG_ TDOWCSR_DecSwAct : 8|1@0+ (1,0) [0|1] "" XXX - SG_ TDOWCSR_IncSwAct : 9|1@0+ (1,0) [0|1] "" XXX - SG_ TDOWCSR_StatReq : 12|3@0+ (1,0) [0|7] "" XXX - SG_ TnDrvSpdLmtCstStReq : 15|3@0+ (1,0) [0|7] "" XXX - SG_ TeenDrvPinCd : 23|16@0+ (1,0) [0|39321] "" XXX - -BO_ 2153840640 Teen_Driver_Event_Report_1_LS: 8 XXX - SG_ TDFwdClnHdwyAlrtsRpt : 5|10@0+ (1,0) [0|1023] "counts" XXX - SG_ TnDrvDRLOffUnbIO : 6|1@0+ (1,0) [0|1] "" XXX - SG_ TnDrvALCOffUnbIO : 7|1@0+ (1,0) [0|1] "" XXX - SG_ TDFwdClnImntAlrtsRpt : 11|10@0+ (1,0) [0|1023] "counts" XXX - SG_ TDFwdClnMtgnBrEvRpt : 17|10@0+ (1,0) [0|1023] "counts" XXX - SG_ TDRevClnMtgnBrEvRpt : 39|10@0+ (1,0) [0|1023] "counts" XXX - SG_ TeenDrvMaxSpdRpt : 45|12@0+ (0.0625,0) [0|255.9375] "km/h" XXX - SG_ TeenDrvLDWEvntsRpt : 49|10@0+ (1,0) [0|1023] "counts" XXX - -BO_ 2153824256 Teen_Driver_Control_Info_LS: 8 XXX - SG_ TnDrvSpdLmtCstCrStVl : 2|11@0+ (1,0) [0|0] "" XXX - SG_ TDSLCCSV_SpLmtStat : 2|3@0+ (1,0) [0|7] "" XXX - SG_ TDSLCCSV_SpLmDisVl : 15|8@0+ (2,0) [0|510] "km/h" XXX - SG_ TnDrvSpdLmtCstStAvl : 3|1@0+ (1,0) [0|1] "" XXX - SG_ TnDrvOvrSpdIO : 4|1@0+ (1,0) [0|1] "" XXX - SG_ TnDrvGapAdjUnbIO : 5|1@0+ (1,0) [0|1] "" XXX - SG_ TeenDrvPINStrd : 6|1@0+ (1,0) [0|1] "" XXX - SG_ TeenDrvFtrAvl : 7|1@0+ (1,0) [0|1] "" XXX - SG_ TDOvSpdWrnCstCrStVl : 22|15@0+ (1,0) [0|0] "" XXX - SG_ TDOWCCSV_CrStVl : 19|12@0+ (0.0625,0) [0|255.9375] "km/h" XXX - SG_ TDOWCCSV_CrStat : 22|3@0+ (1,0) [0|7] "" XXX - SG_ TDOvSpdWrnCstStAvl : 23|1@0+ (1,0) [0|1] "" XXX - SG_ TnDrvOvSpdEvntsRpt : 33|10@0+ (1,0) [0|1023] "counts" XXX - SG_ TeenDrvRsp : 37|4@0+ (1,0) [0|15] "" XXX - SG_ TeenDrvAct : 38|1@0+ (1,0) [0|1] "" XXX - SG_ TeenDrvAccelLimIO : 39|1@0+ (1,0) [0|1] "" XXX - SG_ TeenDrvDistDrvnRpt : 55|16@0+ (1,0) [0|65535] "km" XXX - -BO_ 2155151360 Psngr_Seat_Massage_Priority_LS: 8 XXX - SG_ PsngrStMassgPrty : 7|64@0+ (1,0) [0|0] "" XXX - SG_ PSMP_Type2 : 3|4@0+ (1,0) [0|15] "" XXX - SG_ PSMP_Type1 : 7|4@0+ (1,0) [0|15] "" XXX - SG_ PSMP_Type4 : 11|4@0+ (1,0) [0|15] "" XXX - SG_ PSMP_Type3 : 15|4@0+ (1,0) [0|15] "" XXX - SG_ PSMP_Type6 : 19|4@0+ (1,0) [0|15] "" XXX - SG_ PSMP_Type5 : 23|4@0+ (1,0) [0|15] "" XXX - SG_ PSMP_Type8 : 27|4@0+ (1,0) [0|15] "" XXX - SG_ PSMP_Type7 : 31|4@0+ (1,0) [0|15] "" XXX - SG_ PSMP_Type10 : 35|4@0+ (1,0) [0|15] "" XXX - SG_ PSMP_Type9 : 39|4@0+ (1,0) [0|15] "" XXX - SG_ PSMP_Type12 : 43|4@0+ (1,0) [0|15] "" XXX - SG_ PSMP_Type11 : 47|4@0+ (1,0) [0|15] "" XXX - SG_ PSMP_Type14 : 51|4@0+ (1,0) [0|15] "" XXX - SG_ PSMP_Type13 : 55|4@0+ (1,0) [0|15] "" XXX - SG_ PSMP_UnsdRsrvd : 56|1@0+ (1,0) [0|1] "" XXX - SG_ PSMP_MaxDispVal : 59|3@0+ (1,0) [0|7] "" XXX - SG_ PSMP_Type15 : 63|4@0+ (1,0) [0|15] "" XXX - -BO_ 2155134976 Psngr_Seat_Control_Disp_Stat_LS: 6 XXX - SG_ PsngrStCtlDispStat : 3|44@0+ (1,0) [0|0] "" XXX - SG_ PSCDS_MassgTyp : 1|4@0+ (1,0) [0|15] "" XXX - SG_ PSCDS_Massg : 3|2@0+ (1,0) [0|3] "" XXX - SG_ PSCDS_HdrstFwdRrwd : 8|2@0+ (1,0) [0|3] "" XXX - SG_ PSCDS_HdrstUpDn : 10|2@0+ (1,0) [0|3] "" XXX - SG_ PSCDS_MassgIntsty : 13|3@0+ (1,0) [0|7] "" XXX - SG_ PSCDS_HdrstTltFwdRr : 17|2@0+ (1,0) [0|3] "" XXX - SG_ PSCDS_HdrstWngInOt : 19|2@0+ (1,0) [0|3] "" XXX - SG_ PSCDS_HdrstUDnFdRr : 22|3@0+ (1,0) [0|7] "" XXX - SG_ PSCDS_LmbrUDnFdRr : 25|3@0+ (1,0) [0|7] "" XXX - SG_ PSCDS_LmbrFwdRr : 27|2@0+ (1,0) [0|3] "" XXX - SG_ PSCDS_LmbrUpDwn : 29|2@0+ (1,0) [0|3] "" XXX - SG_ PSCDS_UprShldrFdRr : 31|2@0+ (1,0) [0|3] "" XXX - SG_ PSCDS_BkCshBlstInOt : 34|3@0+ (1,0) [0|7] "" XXX - SG_ PSCDS_CshBlstrInOut : 36|2@0+ (1,0) [0|3] "" XXX - SG_ PSCDS_BkBlstrInOut : 38|2@0+ (1,0) [0|3] "" XXX - SG_ PSCDS_UnsdRsrvd : 42|3@0+ (1,0) [0|7] "" XXX - SG_ PSCDS_DispReq : 43|1@0+ (1,0) [0|1] "" XXX - SG_ PSCDS_DispSz : 45|2@0+ (1,0) [0|3] "" XXX - SG_ PSCDS_CshLgAdjFdRr : 47|2@0+ (1,0) [0|3] "" XXX - SG_ PsngrSetRrwdMvmnt : 6|3@0+ (1,0) [0|7] "" XXX - -BO_ 2155118592 Psngr_Seat_Actuator_Priority_LS: 8 XXX - SG_ PsngrStActPrty : 7|64@0+ (1,0) [0|0] "" XXX - SG_ PSAP_HdrstUpDn : 3|4@0+ (1,0) [0|15] "" XXX - SG_ PSAP_Massg : 7|4@0+ (1,0) [0|15] "" XXX - SG_ PSAP_HdrstUpDnFdRr : 11|4@0+ (1,0) [0|15] "" XXX - SG_ PSAP_HdrstFwdRrwd : 15|4@0+ (1,0) [0|15] "" XXX - SG_ PSAP_HdrstTltFwdRr : 19|4@0+ (1,0) [0|15] "" XXX - SG_ PSAP_HdrstWngsInOut : 23|4@0+ (1,0) [0|15] "" XXX - SG_ PSAP_LmbrUpDwn : 27|4@0+ (1,0) [0|15] "" XXX - SG_ PSAP_UprShldrFwdRr : 31|4@0+ (1,0) [0|15] "" XXX - SG_ PSAP_LmbrUpDnFdRr : 35|4@0+ (1,0) [0|15] "" XXX - SG_ PSAP_LmbrFwdRr : 39|4@0+ (1,0) [0|15] "" XXX - SG_ PSAP_CshBlstrInOut : 43|4@0+ (1,0) [0|15] "" XXX - SG_ PSAP_BkBlstrInOut : 47|4@0+ (1,0) [0|15] "" XXX - SG_ PSAP_CshLgthAdjFdRr : 51|4@0+ (1,0) [0|15] "" XXX - SG_ PSAP_BkCshBlstrInOut : 55|4@0+ (1,0) [0|15] "" XXX - SG_ PSAP_UnsdRsrvd : 59|4@0+ (1,0) [0|15] "" XXX - SG_ PSAP_DispSz : 63|4@0+ (1,0) [0|15] "" XXX - -BO_ 2155102208 Driver_Seat_Massage_Priority_LS: 8 XXX - SG_ DrvStMassgPrty : 7|64@0+ (1,0) [0|0] "" XXX - SG_ DSMP_Type2 : 3|4@0+ (1,0) [0|15] "" XXX - SG_ DSMP_Type1 : 7|4@0+ (1,0) [0|15] "" XXX - SG_ DSMP_Type4 : 11|4@0+ (1,0) [0|15] "" XXX - SG_ DSMP_Type3 : 15|4@0+ (1,0) [0|15] "" XXX - SG_ DSMP_Type6 : 19|4@0+ (1,0) [0|15] "" XXX - SG_ DSMP_Type5 : 23|4@0+ (1,0) [0|15] "" XXX - SG_ DSMP_Type8 : 27|4@0+ (1,0) [0|15] "" XXX - SG_ DSMP_Type7 : 31|4@0+ (1,0) [0|15] "" XXX - SG_ DSMP_Type10 : 35|4@0+ (1,0) [0|15] "" XXX - SG_ DSMP_Type9 : 39|4@0+ (1,0) [0|15] "" XXX - SG_ DSMP_Type12 : 43|4@0+ (1,0) [0|15] "" XXX - SG_ DSMP_Type11 : 47|4@0+ (1,0) [0|15] "" XXX - SG_ DSMP_Type14 : 51|4@0+ (1,0) [0|15] "" XXX - SG_ DSMP_Type13 : 55|4@0+ (1,0) [0|15] "" XXX - SG_ DSMP_UnsdRsrvd : 56|1@0+ (1,0) [0|1] "" XXX - SG_ DSMP_MaxDispVal : 59|3@0+ (1,0) [0|7] "" XXX - SG_ DSMP_Type15 : 63|4@0+ (1,0) [0|15] "" XXX - -BO_ 2155085824 Driver_Seat_Control_Disp_Stat_LS: 8 XXX - SG_ DrvStCtlDispStat : 3|44@0+ (1,0) [0|0] "" XXX - SG_ DSCDS_MassgTyp : 1|4@0+ (1,0) [0|15] "" XXX - SG_ DSCDS_Massg : 3|2@0+ (1,0) [0|3] "" XXX - SG_ DSCDS_HdrstFwdRrwd : 8|2@0+ (1,0) [0|3] "" XXX - SG_ DSCDS_HdrstUpDn : 10|2@0+ (1,0) [0|3] "" XXX - SG_ DSCDS_MassgIntsty : 13|3@0+ (1,0) [0|7] "" XXX - SG_ DSCDS_HdrstTltFwdRr : 17|2@0+ (1,0) [0|3] "" XXX - SG_ DSCDS_HdrstWngInOt : 19|2@0+ (1,0) [0|3] "" XXX - SG_ DSCDS_HdrstUDnFdRr : 22|3@0+ (1,0) [0|7] "" XXX - SG_ DSCDS_LmbrUDnFdRr : 25|3@0+ (1,0) [0|7] "" XXX - SG_ DSCDS_LmbrFwdRr : 27|2@0+ (1,0) [0|3] "" XXX - SG_ DSCDS_LmbrUpDwn : 29|2@0+ (1,0) [0|3] "" XXX - SG_ DSCDS_UprShldrFdRr : 31|2@0+ (1,0) [0|3] "" XXX - SG_ DSCDS_BkCshBlstInOt : 34|3@0+ (1,0) [0|7] "" XXX - SG_ DSCDS_CshBlstrInOut : 36|2@0+ (1,0) [0|3] "" XXX - SG_ DSCDS_BkBlstrInOut : 38|2@0+ (1,0) [0|3] "" XXX - SG_ DSCDS_UnsdRsrvd : 42|3@0+ (1,0) [0|7] "" XXX - SG_ DSCDS_DispReq : 43|1@0+ (1,0) [0|1] "" XXX - SG_ DSCDS_DispSz : 45|2@0+ (1,0) [0|3] "" XXX - SG_ DSCDS_CshLgAdjFdRr : 47|2@0+ (1,0) [0|3] "" XXX - SG_ CPMAPINFO4 : 5|1@0+ (1,0) [0|1] "" XXX - SG_ StrgColCommsFlt : 7|2@0+ (1,0) [0|3] "" XXX - SG_ StrgColInOutPos : 55|8@0+ (1,0) [0|255] "" XXX - SG_ StrgColUpDwnPos : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 2155069440 Driver_Seat_Actuator_Priority_LS: 8 XXX - SG_ DrvStActPrty : 7|64@0+ (1,0) [0|0] "" XXX - SG_ DSAP_HdrstUpDn : 3|4@0+ (1,0) [0|15] "" XXX - SG_ DSAP_Massg : 7|4@0+ (1,0) [0|15] "" XXX - SG_ DSAP_HdrstUpDnFdRr : 11|4@0+ (1,0) [0|15] "" XXX - SG_ DSAP_HdrstFwdRrwd : 15|4@0+ (1,0) [0|15] "" XXX - SG_ DSAP_HdrstTltFwdRr : 19|4@0+ (1,0) [0|15] "" XXX - SG_ DSAP_HdrstWngsInOut : 23|4@0+ (1,0) [0|15] "" XXX - SG_ DSAP_LmbrUpDwn : 27|4@0+ (1,0) [0|15] "" XXX - SG_ DSAP_UprShldrFwdRr : 31|4@0+ (1,0) [0|15] "" XXX - SG_ DSAP_LmbrUpDnFdRr : 35|4@0+ (1,0) [0|15] "" XXX - SG_ DSAP_LmbrFwdRr : 39|4@0+ (1,0) [0|15] "" XXX - SG_ DSAP_CshBlstrInOut : 43|4@0+ (1,0) [0|15] "" XXX - SG_ DSAP_BkBlstrInOut : 47|4@0+ (1,0) [0|15] "" XXX - SG_ DSAP_CshLgthAdjFdRr : 51|4@0+ (1,0) [0|15] "" XXX - SG_ DSAP_BkCshBlstrInOut : 55|4@0+ (1,0) [0|15] "" XXX - SG_ DSAP_UnsdRsrvd : 59|4@0+ (1,0) [0|15] "" XXX - SG_ DSAP_DispSz : 63|4@0+ (1,0) [0|15] "" XXX - -BO_ 2156937216 PassPhrase_Digits_17_to_24_LS: 8 XXX - SG_ WiFiPssPhrsDgts17to24 : 7|64@0+ (1,0) [0|0] "" XXX - -BO_ 2156929024 PassPhrase_Digits_9_to_16_LS: 8 XXX - SG_ WiFiPssPhrsDgts9to16 : 7|64@0+ (1,0) [0|0] "" XXX - -BO_ 2156920832 PassPhrase_Digits_1_to_8_LS: 8 XXX - SG_ WiFiPssPhrsDgts1to8 : 7|64@0+ (1,0) [0|0] "" XXX - -BO_ 2156871680 SSID_Digits_17_to_24_LS: 8 XXX - SG_ WiFiSSIDDgts17to24 : 7|64@0+ (1,0) [0|0] "" XXX - -BO_ 2156863488 SSID_Digits_9_to_16_LS: 8 XXX - SG_ WiFiSSIDDgts9to16 : 7|64@0+ (1,0) [0|0] "" XXX - -BO_ 2156855296 SSID_Digits_1_to_8_LS: 8 XXX - SG_ WiFiSSIDDgts1to8 : 7|64@0+ (1,0) [0|0] "" XXX - -BO_ 2152480768 Perfr_Data_Recorder_Lap_Info_LS: 6 XXX - SG_ PerfDatRecBstLpInfo : 2|19@0+ (1,0) [0|0] "" XXX - SG_ PDRBLI_BstLpTmMins : 2|6@0+ (1,0) [0|63] "min" XXX - SG_ PDRBLI_BstLpTmSecs : 12|6@0+ (1,0) [0|63] "sec" XXX - SG_ PDRBLI_BstLpTm100s : 22|7@0+ (0.01,0) [0|1.27] "sec" XXX - SG_ PerfDatRecLstLpInfo : 26|19@0+ (1,0) [0|0] "" XXX - SG_ PDRLLI_LstLpTmMins : 26|6@0+ (1,0) [0|63] "min" XXX - SG_ PDRLLI_LstLpTmSecs : 36|6@0+ (1,0) [0|63] "sec" XXX - SG_ PDRLLI_LstLpTm100s : 46|7@0+ (0.01,0) [0|1.27] "sec" XXX - -BO_ 2152497152 Perf_Data_Recroder_RT_Info_LS: 4 XXX - SG_ PerfDatRecRltmInfo : 1|26@0+ (1,0) [0|0] "" XXX - SG_ PDRRI_CrLpTmMins : 1|6@0+ (1,0) [0|63] "min" XXX - SG_ PDRRI_CrLpTmSecs : 11|6@0+ (1,0) [0|63] "" XXX - SG_ PDRRI_LpDiffTmSecs : 17|6@0+ (1,0) [0|63] "sec" XXX - SG_ PDRRI_CrLpTm10sSec : 21|4@0+ (0.1,0) [0|1.5] "sec" XXX - SG_ PDRRI_LpDiffTm10s : 27|4@0+ (0.1,0) [0|1.5] "sec" XXX - -BO_ 2153791488 ARB_State_LS: 1 XXX - SG_ ArtcldRngBrdSt : 2|3@0+ (1,0) [0|7] "" XXX - -BO_ 2149883904 BluetoothTetheringPairingRsp_LS: 7 XXX - SG_ BTTethrngPrngRsp : 4|53@0+ (1,0) [0|0] "" XXX - SG_ BTPR_RspInfoAvail : 0|1@0+ (1,0) [0|1] "" XXX - SG_ BTPR_RspStat : 4|4@0+ (1,0) [0|15] "" XXX - SG_ BTPR_RspVal : 15|48@0+ (1,0) [0|281474976710655] "" XXX - -BO_ 2150252544 HMI_EngyConsmpHistGrph_LS: 8 XXX - SG_ EngyConsmpHistGrph : 7|64@0+ (1,0) [0|0] "" XXX - SG_ ECHG_EngyCnsmdAvg : 4|5@0+ (1,0) [0|31] "" XXX - SG_ ECHG_MeasUnit : 7|3@0+ (1,0) [0|7] "" XXX - SG_ ECHG_Column02 : 10|5@0+ (1,0) [0|31] "" XXX - SG_ ECHG_Column01 : 15|5@0+ (1,0) [0|31] "" XXX - SG_ ECHG_Column04 : 16|5@0+ (1,0) [0|31] "" XXX - SG_ ECHG_Column03 : 21|5@0+ (1,0) [0|31] "" XXX - SG_ ECHG_Column05 : 27|5@0+ (1,0) [0|31] "" XXX - SG_ ECHG_Column07 : 33|5@0+ (1,0) [0|31] "" XXX - SG_ ECHG_Column06 : 38|5@0+ (1,0) [0|31] "" XXX - SG_ ECHG_Column08 : 44|5@0+ (1,0) [0|31] "" XXX - SG_ ECHG_Column10 : 50|5@0+ (1,0) [0|31] "" XXX - SG_ ECHG_Column09 : 55|5@0+ (1,0) [0|31] "" XXX - SG_ ECHG_YAxisMaxVal : 58|3@0+ (1,0) [0|7] "" XXX - SG_ ECHG_XAxisTkMrkIntvl : 61|3@0+ (1,0) [0|7] "" XXX - -BO_ 2150391808 HMI_Hourmeter_Data_LS: 6 XXX - SG_ EngIdlAtvTm : 7|24@0+ (1,0) [0|16777215] "min" XXX - SG_ EngRunAtvTm : 31|24@0+ (1,0) [0|16777215] "min" XXX - -BO_ 2155913216 Diesel_Information_2_LS: 7 XXX - SG_ DslExhFldRmngDstHRsGroup : 7|16@0+ (1,0) [0|0] "" XXX - SG_ DslExhFldRmngDstHRs : 6|15@0+ (2,0) [0|65534] "km" XXX - SG_ DslExhFldRmngDstHRsV : 7|1@0+ (1,0) [0|1] "" XXX - SG_ DslExhFluidLvlPrcntGroup : 16|9@0+ (1,0) [0|0] "" XXX - SG_ DslExhFluidLvlPrcntV : 16|1@0+ (1,0) [0|1] "" XXX - SG_ DslExhFluidLvlPrcnt : 31|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ DslEmnsOBDMrkt : 18|2@0+ (1,0) [0|3] "" XXX - SG_ PedFrndlyAlrtCsCrStVal : 21|3@0+ (1,0) [0|7] "" XXX - SG_ PedFrndlyAlrtCsSetAvl : 22|1@0+ (1,0) [0|1] "" XXX - SG_ PedFrndlyAlrtStat : 39|24@0+ (1,0) [0|0] "" XXX - SG_ PFAS_PFACrsOvrSpd : 34|8@0+ (1,0) [0|255] "km/h" XXX - SG_ PFAS_PFARevSnd : 36|2@0+ (1,0) [0|3] "" XXX - SG_ PFAS_PFAFwdSnd : 38|2@0+ (1,0) [0|3] "" XXX - SG_ PFAS_PFASndGenEn : 39|1@0+ (1,0) [0|1] "" XXX - SG_ PFAS_PFASndVolCtrl : 42|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ PFAS_SrvPedAlrtIO : 48|1@0+ (1,0) [0|1] "" XXX - SG_ PFAS_PFASysStat : 50|2@0+ (1,0) [0|3] "" XXX - -BO_ 2034 CCP_Data_Transmission_Object_LS: 8 XXX - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2032 CCP_Command_Receive_Object_LS: 8 XXX - SG_ DgnInf : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2152095744 HSGMLAN_Customization_Setings_LS: 5 XXX - SG_ DrvlnPerfMdCustAvl : 5|6@0+ (1,0) [0|0] "" XXX - SG_ DPMCA_DrvlPrfMd6Avl : 0|1@0+ (1,0) [0|1] "" XXX - SG_ DPMCA_DrvlPrfMd5Avl : 1|1@0+ (1,0) [0|1] "" XXX - SG_ DPMCA_DrvlPrfMd4Avl : 2|1@0+ (1,0) [0|1] "" XXX - SG_ DPMCA_DrvlPrfMd3Avl : 3|1@0+ (1,0) [0|1] "" XXX - SG_ DPMCA_DrvlPrfMd2Avl : 4|1@0+ (1,0) [0|1] "" XXX - SG_ DPMCA_DrvlPrfMd1Avl : 5|1@0+ (1,0) [0|1] "" XXX - SG_ DispPerfCustMdAvl : 13|6@0+ (1,0) [0|0] "" XXX - SG_ DPMCA_DispPrfMd6Avl : 8|1@0+ (1,0) [0|1] "" XXX - SG_ DPMCA_DispPrfMd5Avl : 9|1@0+ (1,0) [0|1] "" XXX - SG_ DPMCA_DispPrfMd4Avl : 10|1@0+ (1,0) [0|1] "" XXX - SG_ DPMCA_DispPrfMd3Avl : 11|1@0+ (1,0) [0|1] "" XXX - SG_ DPMCA_DispPrfMd2Avl : 12|1@0+ (1,0) [0|1] "" XXX - SG_ DPMCA_DispPrfMd1Avl : 13|1@0+ (1,0) [0|1] "" XXX - SG_ SndPerfMdCustAvl : 21|6@0+ (1,0) [0|0] "" XXX - SG_ SPMCA_SndPrfMd6Avl : 16|1@0+ (1,0) [0|1] "" XXX - SG_ SPMCA_SndPrfMd5Avl : 17|1@0+ (1,0) [0|1] "" XXX - SG_ SPMCA_SndPrfMd4Avl : 18|1@0+ (1,0) [0|1] "" XXX - SG_ SPMCA_SndPrfMd3Avl : 19|1@0+ (1,0) [0|1] "" XXX - SG_ SPMCA_SndPrfMd2Avl : 20|1@0+ (1,0) [0|1] "" XXX - SG_ SPMCA_SndPrfMd1Avl : 21|1@0+ (1,0) [0|1] "" XXX - SG_ StrPerfMdCustAvl : 29|6@0+ (1,0) [0|0] "" XXX - SG_ SPMCA_StrPrfMd6Avl : 24|1@0+ (1,0) [0|1] "" XXX - SG_ SPMCA_StrPrfMd5Avl : 25|1@0+ (1,0) [0|1] "" XXX - SG_ SPMCA_StrPrfMd4Avl : 26|1@0+ (1,0) [0|1] "" XXX - SG_ SPMCA_StrPrfMd3Avl : 27|1@0+ (1,0) [0|1] "" XXX - SG_ SPMCA_StrPrfMd2Avl : 28|1@0+ (1,0) [0|1] "" XXX - SG_ SPMCA_StrPrfMd1Avl : 29|1@0+ (1,0) [0|1] "" XXX - SG_ SusPerfMdCustAvl : 37|6@0+ (1,0) [0|0] "" XXX - SG_ SPMCA_SusPrfMd6Avl : 32|1@0+ (1,0) [0|1] "" XXX - SG_ SPMCA_SusPrfMd5Avl : 33|1@0+ (1,0) [0|1] "" XXX - SG_ SPMCA_SusPrfMd4Avl : 34|1@0+ (1,0) [0|1] "" XXX - SG_ SPMCA_SusPrfMd3Avl : 35|1@0+ (1,0) [0|1] "" XXX - SG_ SPMCA_SusPrfMd2Avl : 36|1@0+ (1,0) [0|1] "" XXX - SG_ SPMCA_SusPrfMd1Avl : 37|1@0+ (1,0) [0|1] "" XXX - -BO_ 2156945408 SSID_AMM_1_LS: 8 XXX - SG_ WiFiSSIDDgts1to8_Mp : 7|64@0+ (1,0) [0|0] "" XXX - -BO_ 2152611840 OnBoard_Tester_Request_LS: 2 XXX - SG_ OBTCReq : 4|5@0+ (1,0) [0|0] "" XXX - SG_ OBTCR_Prty : 3|4@0+ (1,0) [0|15] "" XXX - SG_ OBTCR_Actv : 4|1@0+ (1,0) [0|1] "" XXX - SG_ OBTCReqstrStat : 7|3@0+ (1,0) [0|7] "" XXX - SG_ OBTCReqstrID : 15|8@0+ (1,0) [0|255] "" XXX - -BO_ 2153308160 Hyb_Redundant_Batt_Data2_LS: 4 XXX - SG_ RdHVltBatPckCrntGroup : 6|15@0+ (1,0) [0|0] "" XXX - SG_ RdHVltBatPckCrnt : 4|13@0- (0.15,0) [-614.4|614.25] "A" XXX - SG_ RdHVltBatPckCrntV : 5|1@0+ (1,0) [0|1] "" XXX - SG_ RdHVltBatPckCrntM : 6|1@0+ (1,0) [0|1] "" XXX - SG_ RdHVltBatPckVltGroup : 21|14@0+ (1,0) [0|0] "" XXX - SG_ RdHVltBatPckVlt : 19|12@0+ (0.125,0) [0|511.875] "V" XXX - SG_ RdHVltBatPckVltV : 20|1@0+ (1,0) [0|1] "" XXX - SG_ RdHVltBatPckVltM : 21|1@0+ (1,0) [0|1] "" XXX - -BO_ 2155970560 HVAC_PowerManager_Status_LS: 1 XXX - SG_ ClmCntLdShdLvlRq : 3|4@0+ (1,0) [0|15] "" XXX - SG_ ClmCntBatSaverIO : 5|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151178240 Lighting_Customization_Rqst_1_LS: 4 XXX - SG_ LtRtHnTrGPSCstStRq : 2|3@0+ (1,0) [0|7] "" XXX - SG_ LtRtHnTrCstStReq : 5|3@0+ (1,0) [0|7] "" XXX - SG_ AutHgBmAsSnCsStRq : 10|3@0+ (1,0) [0|7] "" XXX - SG_ AutHgBmAstCstStRq : 13|3@0+ (1,0) [0|7] "" XXX - SG_ AdpHgBmAsSnCsStRq : 18|3@0+ (1,0) [0|7] "" XXX - SG_ AdpHgBmAstCstStRq : 21|3@0+ (1,0) [0|7] "" XXX - SG_ AFLGPSCstStReq : 26|3@0+ (1,0) [0|7] "" XXX - SG_ AFLCstStReq : 29|3@0+ (1,0) [0|7] "" XXX - -BO_ 2154790912 Lighting_Customization_Info_2_LS: 2 XXX - SG_ AutHgBmAsCsCrStVal : 2|3@0+ (1,0) [0|7] "" XXX - SG_ AutHgBmAsSnCsCrStVa : 5|3@0+ (1,0) [0|7] "" XXX - SG_ AutHgBmAsCsStAvl : 6|1@0+ (1,0) [0|1] "" XXX - SG_ AutHgBmAsSnCsStAvl : 7|1@0+ (1,0) [0|1] "" XXX - SG_ AdpHgBmAsCsCrStVal : 10|3@0+ (1,0) [0|7] "" XXX - SG_ AdpHgBmAsSnCsCrStVal : 13|3@0+ (1,0) [0|7] "" XXX - SG_ AdpHgBmAsCsStAvl : 14|1@0+ (1,0) [0|1] "" XXX - SG_ AdpHgBmAsSnCsStAvl : 15|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151292928 V2V_Customization_Menu_LS: 5 XXX - SG_ TrfRdsdInfCsStAvail : 0|1@0+ (1,0) [0|1] "" XXX - SG_ CntdVehBrkAltCsStAvl : 1|1@0+ (1,0) [0|1] "" XXX - SG_ IntrStopAlrtCsSetAvl : 2|1@0+ (1,0) [0|1] "" XXX - SG_ IntrStAlrtCsCrSetVal : 5|3@0+ (1,0) [0|7] "" XXX - SG_ TrfRdsdInfCsCrStVal : 10|3@0+ (1,0) [0|7] "" XXX - SG_ CntdVehBrAltCsCrStVal : 13|3@0+ (1,0) [0|7] "" XXX - SG_ IntrStAlrtCsAvail : 22|7@0+ (1,0) [0|0] "" XXX - SG_ ISACA_Resrv4Avail : 16|1@0+ (1,0) [0|1] "" XXX - SG_ ISACA_Resrv3Avail : 17|1@0+ (1,0) [0|1] "" XXX - SG_ ISACA_Resrv2Avail : 18|1@0+ (1,0) [0|1] "" XXX - SG_ ISACA_Resrv1Avail : 19|1@0+ (1,0) [0|1] "" XXX - SG_ ISACA_AlrtBrkAvail : 20|1@0+ (1,0) [0|1] "" XXX - SG_ ISACA_AlrtAvail : 21|1@0+ (1,0) [0|1] "" XXX - SG_ ISACA_OfAvail : 22|1@0+ (1,0) [0|1] "" XXX - SG_ CntdVehBrkAlrtCsAvail : 30|7@0+ (1,0) [0|0] "" XXX - SG_ CVBACA_Resrv5Avail : 24|1@0+ (1,0) [0|1] "" XXX - SG_ CVBACA_Resrv4Avail : 25|1@0+ (1,0) [0|1] "" XXX - SG_ CVBACA_Resrv3Avail : 26|1@0+ (1,0) [0|1] "" XXX - SG_ CVBACA_Resrv2Avail : 27|1@0+ (1,0) [0|1] "" XXX - SG_ CVBACA_Resrv1Avail : 28|1@0+ (1,0) [0|1] "" XXX - SG_ CVBACA_OnAvail : 29|1@0+ (1,0) [0|1] "" XXX - SG_ CVBACA_OfAvail : 30|1@0+ (1,0) [0|1] "" XXX - SG_ TrfRdsdInfCsAvail : 38|7@0+ (1,0) [0|0] "" XXX - SG_ TRICA_Resrv5Avail : 32|1@0+ (1,0) [0|1] "" XXX - SG_ TRICA_Resrv4Avail : 33|1@0+ (1,0) [0|1] "" XXX - SG_ TRICA_Resrv3Avail : 34|1@0+ (1,0) [0|1] "" XXX - SG_ TRICA_Resrv2Avail : 35|1@0+ (1,0) [0|1] "" XXX - SG_ TRICA_Resrv1Avail : 36|1@0+ (1,0) [0|1] "" XXX - SG_ TRICA_OnAvail : 37|1@0+ (1,0) [0|1] "" XXX - SG_ TRICA_OfAvail : 38|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151464960 V2V_Warnings_LS: 5 XXX - SG_ V2VWrngIndReq : 4|5@0+ (1,0) [0|31] "" XXX - SG_ V2VWrngDirctn : 7|3@0+ (1,0) [0|7] "" XXX - SG_ V2VWrngDistRemng : 9|10@0+ (1,0) [0|1023] "" XXX - SG_ V2VTrfLghtInfo : 28|13@0+ (1,0) [0|0] "" XXX - SG_ V2VTLI_TrfLghtTmPhsSw : 28|6@0+ (1,0) [0|63] "" XXX - SG_ V2VTLI_TrfLghtMntngDirctn : 32|1@0+ (1,0) [0|1] "" XXX - SG_ V2VTLI_TrfLghtValDirctn : 34|2@0+ (1,0) [0|3] "" XXX - SG_ V2VTLI_TrfLghtPhsArivl : 36|2@0+ (1,0) [0|3] "" XXX - SG_ V2VTLI_TrfLghtActlPhs : 38|2@0+ (1,0) [0|3] "" XXX - SG_ V2VSrvIndReq : 30|2@0+ (1,0) [0|3] "" XXX - -BO_ 2151448576 V2V_Seat_Vib_Request_LS: 3 XXX - SG_ V2VSysHptcStVibReq : 5|6@0+ (1,0) [0|63] "" XXX - SG_ V2VSysHptStVibRqSN : 7|2@0+ (1,0) [0|3] "" XXX - SG_ V2VSyLftHptStVbRq : 13|6@0+ (1,0) [0|63] "" XXX - SG_ V2VSyLftHptStVbRqSN : 15|2@0+ (1,0) [0|3] "" XXX - SG_ V2VSyRghtHptStVbRq : 21|6@0+ (1,0) [0|63] "" XXX - SG_ V2VSyRghtHptStVbRqSN : 23|2@0+ (1,0) [0|3] "" XXX - -BO_ 2153930752 Lane_Centering_Convenience_LS: 3 XXX - SG_ LCWrnIndReq : 4|5@0+ (1,0) [0|31] "" XXX - SG_ LCCDrvrAwrnsIO : 5|1@0+ (1,0) [0|1] "" XXX - SG_ LnCntrVhlStpd : 6|1@0+ (1,0) [0|1] "" XXX - SG_ LnCntrNonRspDrvrCnd : 7|1@0+ (1,0) [0|1] "" XXX - SG_ LCConvMsgIndreq : 12|5@0+ (1,0) [0|31] "" XXX - SG_ LCCIndReq : 15|3@0+ (1,0) [0|7] "" XXX - SG_ LnCntrEsclnStat : 17|2@0+ (1,0) [0|3] "" XXX - SG_ LnCntrSpchPrmtReq : 19|2@0+ (1,0) [0|3] "" XXX - SG_ LnCntrngCtlIcnLoctn : 23|4@0- (1,0) [-8|7] "" XXX - -BO_ 2153889792 Lane_Centering_Arrow_LS: 5 XXX - SG_ LCArrwBlk1Act : 0|1@0+ (1,0) [0|1] "" XXX - SG_ LCArrwBlk2Act : 1|1@0+ (1,0) [0|1] "" XXX - SG_ LCArrwBlk3Act : 2|1@0+ (1,0) [0|1] "" XXX - SG_ LCArrwBlk4Act : 3|1@0+ (1,0) [0|1] "" XXX - SG_ LCArrwBlk5Act : 4|1@0+ (1,0) [0|1] "" XXX - SG_ LCArrwBlk2Offst : 15|8@0- (1,0) [-128|127] "" XXX - SG_ LCArrwBlk3Offst : 23|8@0- (1,0) [-128|127] "" XXX - SG_ LCArrwBlk4Offst : 31|8@0- (1,0) [-128|127] "" XXX - SG_ LCArrwBlk5Offst : 39|8@0- (1,0) [-128|127] "" XXX - -BO_ 2153914368 Energy_Usage_LS: 7 XXX - SG_ EngyUsgScrScal : 7|56@0+ (1,0) [0|0] "" XXX - SG_ EUSS_OTEgUgScrMxScVal : 0|7@0- (0.1,0) [-5|5] "" XXX - SG_ EUSS_OTEgUgScrMnScVal : 7|7@0- (0.1,0) [-5|5] "" XXX - SG_ EUSS_ITEgUgScrMnScVal : 9|7@0- (0.1,0) [-5|5] "" XXX - SG_ EUSS_ITEgUgScrMxScVal : 18|7@0- (0.1,0) [-5|5] "" XXX - SG_ EUSS_TcEgUgScrMnScVal : 27|7@0- (0.1,0) [-5|5] "" XXX - SG_ EUSS_TcEgUgScrMxScVal : 36|7@0- (0.1,0) [-5|5] "" XXX - SG_ EUSS_TrEgUgScrMnScVal : 45|7@0- (0.1,0) [-5|5] "" XXX - SG_ EUSS_TrEgUgScrMxScVal : 54|7@0- (0.1,0) [-5|5] "" XXX - -BO_ 2151882752 PTO_Customization_Request_LS: 3 XXX - SG_ PTOTpStpSpdCsStReq : 2|3@0+ (1,0) [0|7] "" XXX - SG_ PTOEngRnTmrCsStRq : 11|4@0+ (1,0) [0|15] "" XXX - SG_ PTOStdbySpdCsStReq : 14|3@0+ (1,0) [0|7] "" XXX - SG_ PTOSet1SpdCsStReq : 19|4@0+ (1,0) [0|15] "" XXX - SG_ PTOSet2SpdCsStReq : 23|4@0+ (1,0) [0|15] "" XXX - -BO_ 2151899136 PTO_Status_LS: 5 XXX - SG_ PTORelBrkPedIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ PTORelAccPedIO : 1|1@0+ (1,0) [0|1] "" XXX - SG_ PTORedEngSpdIO : 2|1@0+ (1,0) [0|1] "" XXX - SG_ PTOPrsRelCltPedIO : 3|1@0+ (1,0) [0|1] "" XXX - SG_ PTOPrsRelBrkPedIO : 4|1@0+ (1,0) [0|1] "" XXX - SG_ PTOEngmntStatInd : 6|2@0+ (1,0) [0|3] "" XXX - SG_ PTODisengCrsCntlIO : 7|1@0+ (1,0) [0|1] "" XXX - SG_ PTOSet1SpdCsStAvl : 8|1@0+ (1,0) [0|1] "" XXX - SG_ PTOSet2SpdCsStAvl : 9|1@0+ (1,0) [0|1] "" XXX - SG_ PTOTpStpSpdCsStAvl : 10|1@0+ (1,0) [0|1] "" XXX - SG_ PTOEngRnTmrCsStAvl : 11|1@0+ (1,0) [0|1] "" XXX - SG_ PTOStdbySpdCsStAvl : 12|1@0+ (1,0) [0|1] "" XXX - SG_ PTOTransInGearIO : 13|1@0+ (1,0) [0|1] "" XXX - SG_ PTOSetPrkBrkIO : 14|1@0+ (1,0) [0|1] "" XXX - SG_ PTORelCltPedIO : 15|1@0+ (1,0) [0|1] "" XXX - SG_ PTOStdbSpdCsCrStVal : 18|3@0+ (1,0) [0|7] "" XXX - SG_ PTOGroup : 20|2@0+ (1,0) [0|0] "" XXX - SG_ PTOVDA : 19|1@0+ (1,0) [0|1] "" XXX - SG_ PTOVDM : 20|1@0+ (1,0) [0|1] "" XXX - SG_ PTOManTransInGrIO : 21|1@0+ (1,0) [0|1] "" XXX - SG_ PTOAccelUpnBrkRelIO : 22|1@0+ (1,0) [0|1] "" XXX - SG_ PTOEngUpnBrkRelIO : 23|1@0+ (1,0) [0|1] "" XXX - SG_ PTOTpStSpdCsCrStVal : 26|3@0+ (1,0) [0|7] "" XXX - SG_ PTOEnRnTmCsCrStVal : 30|4@0+ (1,0) [0|15] "" XXX - SG_ PTOServIndOn : 31|1@0+ (1,0) [0|1] "" XXX - SG_ PTOSet1SpdCsCrStVal : 35|4@0+ (1,0) [0|15] "" XXX - SG_ PTOSet2SpdCsCrStVal : 39|4@0+ (1,0) [0|15] "" XXX - -BO_ 2150580224 HMI_UtlChrgIntrfr_Indication_LS: 5 XXX - SG_ CstmrNonUsblSOCGroup : 1|10@0+ (1,0) [0|0] "" XXX - SG_ CstmrNonUsblSOCV : 1|1@0+ (1,0) [0|1] "" XXX - SG_ CstmrNonUsblSOC : 15|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ CstNonUsbSOCDspLvl : 23|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ PrpDspTtlPwrLvlPct : 24|9@0- (0.392157,0) [-100.392192|100.000035] "%" XXX - -BO_ 2151735296 Rear_Cross_Traffic_Alert_Ind_LS: 1 XXX - SG_ RrCrsTrfcAlrtOffIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ LnChgAlrtOffIndOn : 1|1@0+ (1,0) [0|1] "" XXX - SG_ RtRrCrsTrfcAlrtEnbld : 2|1@0+ (1,0) [0|1] "" XXX - SG_ RtSBZAlrtEnbld : 3|1@0+ (1,0) [0|1] "" XXX - SG_ RtLnChgAlrtEnbld : 4|1@0+ (1,0) [0|1] "" XXX - SG_ RtSdDetSysTmpDsbld : 5|1@0+ (1,0) [0|1] "" XXX - SG_ RtSdDetSysServDsbld : 6|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151792640 Rear_Cross_Traffic_Alert_Rght_LS: 5 XXX - SG_ RrCTfcRHptcStRqSqN : 1|2@0+ (1,0) [0|3] "" XXX - SG_ RrCTfcRHptcStReq : 7|6@0+ (1,0) [0|63] "" XXX - SG_ RrCrsTrfAltRgtIndCtrl : 34|3@0+ (1,0) [0|0] "" XXX - SG_ RCTARIC_IndReq : 33|2@0+ (1,0) [0|3] "" XXX - SG_ RCTARIC_Indctr1Act : 34|1@0+ (1,0) [0|1] "" XXX - -BO_ 2149826560 FCA_VisionBased_Info_2_LS: 4 XXX - SG_ FCAGpStng : 2|3@0+ (1,0) [0|7] "" XXX - SG_ FCAHdwyStngIO : 3|1@0+ (1,0) [0|1] "" XXX - SG_ FCACrusCtrlCnclReqd : 4|1@0+ (1,0) [0|1] "" XXX - SG_ FCABrkPrflReq : 5|1@0+ (1,0) [0|1] "" XXX - SG_ FwdClnAlrtOffIO11E : 6|1@0+ (1,0) [0|1] "" XXX - SG_ FwdClnAlrtPr11E : 7|1@0+ (1,0) [0|1] "" XXX - SG_ SpdLmtVsnFsdSpdGroup : 15|15@0+ (1,0) [0|0] "" XXX - SG_ SpdLmtVsnFsdSpd : 15|8@0+ (1,0) [0|255] "" XXX - SG_ SpdLmtVsnFsdSpdM : 17|1@0+ (1,0) [0|1] "" XXX - SG_ FwdObjAlrtInd11E : 16|9@0+ (1,0) [0|0] "" XXX - SG_ FOAI_AlrtChmIhbRq11E : 16|1@0+ (1,0) [0|1] "" XXX - SG_ FOAI_VehAhdIndRq11E : 27|4@0+ (1,0) [0|15] "" XXX - SG_ FOAI_AlrtWrnIndRq11E : 31|4@0+ (1,0) [0|15] "" XXX - SG_ SpdLmtVnFsSpdNwDet : 18|1@0+ (1,0) [0|1] "" XXX - SG_ SpdLmtVsnFsdSpdUnt : 19|1@0+ (1,0) [0|1] "" XXX - -BO_ 2149957632 Park_Assist_ESSprocess_Info_LS: 1 XXX - SG_ ClsnMtgtnInhbtd : 0|1@0+ (1,0) [0|1] "" XXX - SG_ PrkAstInhbtReq : 1|1@0+ (1,0) [0|1] "" XXX - SG_ PrkAstRrObjSnsngRqAct : 2|1@0+ (1,0) [0|1] "" XXX - SG_ PrkAstOprtrDsrdStat : 4|2@0+ (1,0) [0|3] "" XXX - -BO_ 2149941248 Park_Assist_ESSbased_Info_LS: 5 XXX - SG_ PrkAstRrExtdDstUnfltd : 3|12@0+ (0.01,0) [0|40.95] "m" XXX - SG_ PrkAstRrSysStatUnfltd : 5|2@0+ (1,0) [0|3] "" XXX - SG_ PrkAstFntnSnsDstrbdIO : 16|1@0+ (1,0) [0|1] "" XXX - SG_ PrkAstFntnSnrsBlkd : 17|1@0+ (1,0) [0|1] "" XXX - SG_ PrkAstFntnFld : 18|1@0+ (1,0) [0|1] "" XXX - SG_ PrkAstFntnDsbldIO : 19|1@0+ (1,0) [0|1] "" XXX - SG_ PrkAstFntnClnPrkAstIO : 20|1@0+ (1,0) [0|1] "" XXX - SG_ ClsnMtgtnInhbtReqtd : 21|1@0+ (1,0) [0|1] "" XXX - SG_ PrkAstRrObjSnsngAct : 22|1@0+ (1,0) [0|1] "" XXX - SG_ PARrRgn3ObjStatUnfltd : 27|4@0+ (1,0) [0|15] "" XXX - SG_ PARrRgn4ObjStatUnfltd : 31|4@0+ (1,0) [0|15] "" XXX - SG_ PARrRgn1ObjStatUnfltd : 35|4@0+ (1,0) [0|15] "" XXX - SG_ PARrRgn2ObjStatUnfltd : 39|4@0+ (1,0) [0|15] "" XXX - -BO_ 2156314624 High_Volt_Time_Based_Chrg_LS: 8 XXX - SG_ TODCNxtPlnndDprtrTm : 5|14@0+ (1,0) [0|0] "" XXX - SG_ TODCNPDT_Hr : 2|5@0+ (1,0) [0|31] "Hour" XXX - SG_ TODCNPDT_DyOfWk : 5|3@0+ (1,0) [0|7] "" XXX - SG_ TODCNPDT_Min : 13|6@0+ (1,0) [0|63] "Minute" XXX - SG_ OffBrdCSFltDtctd : 6|1@0+ (1,0) [0|1] "" XXX - SG_ OBVhCsACChgRqBnVs : 7|1@0+ (1,0) [0|1] "" XXX - SG_ HVChgSyChgLvlPrfDt : 16|25@0+ (1,0) [0|0] "" XXX - SG_ HVCSCLPD_UsrIntTyp : 16|2@0+ (1,0) [0|3] "" XXX - SG_ HVCSCLPD_NrmChrgC : 27|5@0+ (1,0) [0|31] "A" XXX - SG_ HVCSCLPD_ChgLvlPfS : 30|3@0+ (1,0) [0|7] "" XXX - SG_ HVCSCLPD_RdCrntLv2 : 33|5@0+ (1,0) [0|31] "A" XXX - SG_ HVCSCLPD_RdCrntLv1 : 38|5@0+ (1,0) [0|31] "A" XXX - SG_ HVCSCLPD_RdCrntLv3 : 44|5@0+ (1,0) [0|31] "A" XXX - SG_ HVChrgAbrtRsn : 19|3@0+ (1,0) [0|7] "" XXX - SG_ TODCOpMd : 22|3@0+ (1,0) [0|7] "" XXX - SG_ HVChrgSysSplyFltIO : 23|1@0+ (1,0) [0|1] "" XXX - SG_ TODCDspMnPgTmpOr : 52|5@0+ (1,0) [0|0] "" XXX - SG_ TODCDMPTO_TpOvR : 51|4@0+ (1,0) [0|15] "" XXX - SG_ TODCDMPTO_CmPgR : 52|1@0+ (1,0) [0|1] "" XXX - SG_ HVChrgSysStNot : 55|3@0+ (1,0) [0|7] "" XXX - SG_ HVBatBlkSOC : 63|8@0+ (0.392157,0) [0|100.000035] "%" XXX - -BO_ 2150449152 Engine_Information_5_LS: 4 XXX - SG_ SrvcFlSysPrkInOpnArIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ TnDrvTrCtrlOffUnbIO : 1|1@0+ (1,0) [0|1] "" XXX - SG_ TnDrvStblCtrlOffUnbIO : 2|1@0+ (1,0) [0|1] "" XXX - SG_ InActFuelMdFuelLvlIO : 3|1@0+ (1,0) [0|1] "" XXX - SG_ FuelSysNEmsRltMalfAct : 4|1@0+ (1,0) [0|1] "" XXX - SG_ EngInltSpcfcHmdtyGroup : 7|16@0+ (1,0) [0|0] "" XXX - SG_ EngInltSpcfcHmdtyM : 6|1@0+ (1,0) [0|1] "" XXX - SG_ EngInltSpcfcHmdtyV : 7|1@0+ (1,0) [0|1] "" XXX - SG_ EngInltSpcfcHmdty : 15|8@0+ (0.0196078,0) [0|4.999989] "% water" XXX - SG_ AutoStpInhbtRsnInd : 23|8@0+ (1,0) [0|0] "" XXX - SG_ ASIRI_Indication08 : 16|1@0+ (1,0) [0|1] "" XXX - SG_ ASIRI_Indication07 : 17|1@0+ (1,0) [0|1] "" XXX - SG_ ASIRI_Indication06 : 18|1@0+ (1,0) [0|1] "" XXX - SG_ ASIRI_Indication05 : 19|1@0+ (1,0) [0|1] "" XXX - SG_ ASIRI_Indication04 : 20|1@0+ (1,0) [0|1] "" XXX - SG_ ASIRI_Indication03 : 21|1@0+ (1,0) [0|1] "" XXX - SG_ ASIRI_Indication02 : 22|1@0+ (1,0) [0|1] "" XXX - SG_ ASIRI_Indication01 : 23|1@0+ (1,0) [0|1] "" XXX - SG_ SpdLmtrSttngTypAct : 25|2@0+ (1,0) [0|3] "" XXX - SG_ ManTransIndReq : 28|3@0+ (1,0) [0|7] "" XXX - SG_ ESPDrvrExtIO : 29|1@0+ (1,0) [0|1] "" XXX - SG_ ESPDrvrDrStIndtrmntIO : 30|1@0+ (1,0) [0|1] "" XXX - SG_ ESPAutoPrkIO : 31|1@0+ (1,0) [0|1] "" XXX - -BO_ 2149810176 FCA_VisionBased_Info_1_LS: 1 XXX - SG_ FCAHptcStVbnRqSeqN : 1|2@0+ (1,0) [0|3] "" XXX - SG_ FCAHptcStVbnReq : 7|6@0+ (1,0) [0|63] "" XXX - -BO_ 2149793792 FCA_VisionBased_Info_LS: 6 XXX - SG_ FwdClnAlrtCustCrntSetngVal : 3|3@0+ (1,0) [0|7] "" XXX - SG_ FCACustStngAvlbl : 6|1@0+ (1,0) [0|1] "" XXX - SG_ VhlAhdDstIndReq : 26|19@0+ (1,0) [0|0] "" XXX - SG_ VADIR_IndLvl : 26|4@0+ (1,0) [0|15] "" XXX - SG_ VADIR_FlwTme : 38|7@0+ (0.1,0) [0|12.7] "s" XXX - SG_ VADIR_FlwDst : 47|8@0+ (1,0) [0|255] "m" XXX - -BO_ 2150080512 Aux_Coolant_Heater_Status_LS: 8 XXX - SG_ EngAstHtDfrdHtMdAct : 0|1@0+ (1,0) [0|1] "" XXX - SG_ LBCCsCrStVal : 2|2@0+ (1,0) [0|3] "" XXX - SG_ AuxClntHtrVlvStat : 5|3@0+ (1,0) [0|7] "" XXX - SG_ LBCChrgLvlPrfExpIO : 6|1@0+ (1,0) [0|1] "" XXX - SG_ LBCCsStAvl : 7|1@0+ (1,0) [0|1] "" XXX - SG_ LBCCstmrDaRstResp : 12|5@0+ (1,0) [0|0] "" XXX - SG_ LBCCDRR_PosNumbr : 10|3@0+ (1,0) [0|7] "" XXX - SG_ LBCCDRR_ClrStrdPosResp : 12|2@0+ (1,0) [0|3] "" XXX - SG_ LBCPosStgStat : 20|5@0+ (1,0) [0|0] "" XXX - SG_ LBCPSS_PosUpdtLct : 18|3@0+ (1,0) [0|7] "" XXX - SG_ LBCPSS_PosUpdtStat : 20|2@0+ (1,0) [0|3] "" XXX - SG_ LBCVehLctStat : 27|4@0+ (1,0) [0|0] "" XXX - SG_ LBCVLS_VehGPSLct : 26|3@0+ (1,0) [0|7] "" XXX - SG_ LBCVLS_VehGPSLctV : 27|1@0+ (1,0) [0|1] "" XXX - SG_ LBCCstmrFdbk : 31|4@0+ (1,0) [0|0] "" XXX - SG_ LBCCF_Lct4PosStrdIO : 28|1@0+ (1,0) [0|1] "" XXX - SG_ LBCCF_Lct3PosStrdIO : 29|1@0+ (1,0) [0|1] "" XXX - SG_ LBCCF_Lct2PosStrdIO : 30|1@0+ (1,0) [0|1] "" XXX - SG_ LBCCF_Lct1PosStrdIO : 31|1@0+ (1,0) [0|1] "" XXX - SG_ ChrgCyclElecEngyEcnEq : 35|12@0+ (0.1,0) [0|409.5] "km/l" XXX - SG_ ChrgCyclOvrlEngyEcnEq : 51|12@0+ (0.1,0) [0|409.5] "km/l" XXX - -BO_ 2153873408 Heated_Steering_Whl_Rqsted_LS: 1 XXX - SG_ MnlHtdStWhlRqstd : 7|1@0+ (1,0) [0|1] "" XXX - -BO_ 2152128512 Performance_Mode_Cust_Setings_LS: 4 XXX - SG_ ACCPerfMdCustAvl : 5|6@0+ (1,0) [0|0] "" XXX - SG_ ACCPMCA_ACCPrfMd6Avl : 0|1@0+ (1,0) [0|1] "" XXX - SG_ ACCPMCA_ACCPrfMd5Avl : 1|1@0+ (1,0) [0|1] "" XXX - SG_ ACCPMCA_ACCPrfMd4Avl : 2|1@0+ (1,0) [0|1] "" XXX - SG_ ACCPMCA_ACCPrfMd3Avl : 3|1@0+ (1,0) [0|1] "" XXX - SG_ ACCPMCA_ACCPrfMd2Avl : 4|1@0+ (1,0) [0|1] "" XXX - SG_ ACCPMCA_ACCPrfMd1Avl : 5|1@0+ (1,0) [0|1] "" XXX - SG_ DrvrStPerfMdCustAvl : 13|6@0+ (1,0) [0|0] "" XXX - SG_ DSPMCA_DrvrStPrfMd6Avl : 8|1@0+ (1,0) [0|1] "" XXX - SG_ DSPMCA_DrvrStPrfMd5Avl : 9|1@0+ (1,0) [0|1] "" XXX - SG_ DSPMCA_DrvrStPrfMd4Avl : 10|1@0+ (1,0) [0|1] "" XXX - SG_ DSPMCA_DrvrStPrfMd3Avl : 11|1@0+ (1,0) [0|1] "" XXX - SG_ DSPMCA_DrvrStPrfMd2Avl : 12|1@0+ (1,0) [0|1] "" XXX - SG_ DSPMCA_DrvrStPrfMd1Avl : 13|1@0+ (1,0) [0|1] "" XXX - SG_ PsngStPerfMdCustAvl : 21|6@0+ (1,0) [0|0] "" XXX - SG_ PSPMCA_PsngStPrfMd6Avl : 16|1@0+ (1,0) [0|1] "" XXX - SG_ PSPMCA_PsngStPrfMd5Avl : 17|1@0+ (1,0) [0|1] "" XXX - SG_ PSPMCA_PsngStPrfMd4Avl : 18|1@0+ (1,0) [0|1] "" XXX - SG_ PSPMCA_PsngStPrfMd3Avl : 19|1@0+ (1,0) [0|1] "" XXX - SG_ PSPMCA_PsngStPrfMd2Avl : 20|1@0+ (1,0) [0|1] "" XXX - SG_ PSPMCA_PsngStPrfMd1Avl : 21|1@0+ (1,0) [0|1] "" XXX - SG_ DrvStyPerfMdCustAvl : 30|7@0+ (1,0) [0|0] "" XXX - SG_ DSPMCA_DrvStyPrfMd7Avl : 24|1@0+ (1,0) [0|1] "" XXX - SG_ DSPMCA_DrvStyPrfMd6Avl : 25|1@0+ (1,0) [0|1] "" XXX - SG_ DSPMCA_DrvStyPrfMd5Avl : 26|1@0+ (1,0) [0|1] "" XXX - SG_ DSPMCA_DrvStyPrfMd4Avl : 27|1@0+ (1,0) [0|1] "" XXX - SG_ DSPMCA_DrvStyPrfMd3Avl : 28|1@0+ (1,0) [0|1] "" XXX - SG_ DSPMCA_DrvStyPrfMd2Avl : 29|1@0+ (1,0) [0|1] "" XXX - SG_ DSPMCA_DrvStyPrfMd1Avl : 30|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151997440 Driver_Drowsiness_Dtctn_Stat_LS: 5 XXX - SG_ DrvDrowSysIndRq : 2|3@0+ (1,0) [0|7] "" XXX - SG_ DrvDrwDetCsCrStVal : 5|3@0+ (1,0) [0|7] "" XXX - SG_ DrvDrowDetCstStAvl : 6|1@0+ (1,0) [0|1] "" XXX - SG_ DrvDrsnHptcStRqSeqN : 9|2@0+ (1,0) [0|3] "" XXX - SG_ DrDrwSysHptcStVbnRq : 15|6@0+ (1,0) [0|63] "" XXX - -BO_ 2156331008 High_Voltage_EnergyMgmt_Ctrl_LS: 7 XXX - SG_ LwRngLVLdShdRq : 1|2@0+ (1,0) [0|3] "" XXX - SG_ HVDpltnMdMxCnfdcRg : 11|12@0+ (0.1,0) [0|409.5] "km" XXX - SG_ HVDpltnMdMiCnfdcRg : 27|12@0+ (0.1,0) [0|409.5] "km" XXX - SG_ HVDpltnMdMxGugRg : 43|12@0+ (0.1,0) [0|409.5] "km" XXX - -BO_ 2151776256 Rear_Cross_Traffic_Alert_Left_LS: 5 XXX - SG_ RrCTfcLHptcStRqSeqN : 1|2@0+ (1,0) [0|3] "" XXX - SG_ RrCTfcLHptcStReq : 7|6@0+ (1,0) [0|63] "" XXX - SG_ RrCrsTrfAltLftIndCtrl : 34|3@0+ (1,0) [0|0] "" XXX - SG_ RCTALIC_IndReq : 33|2@0+ (1,0) [0|3] "" XXX - SG_ RCTALIC_Indctr1Act : 34|1@0+ (1,0) [0|1] "" XXX - -BO_ 2154774528 Lighting_Customization_Info_1_LS: 1 XXX - SG_ LtRtHnTrCstStVal : 2|3@0+ (1,0) [0|7] "" XXX - SG_ LtRtHnTrGPCsCrStVal : 5|3@0+ (1,0) [0|7] "" XXX - SG_ LtRtHnTrCstStAvail : 6|1@0+ (1,0) [0|1] "" XXX - SG_ LtRtHnTrGPSCsStAvl : 7|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150375424 Eng_Maintenance_Mode_Strt_Req_LS: 3 XXX - SG_ MntnceMdStEngRq : 0|1@0+ (1,0) [0|1] "" XXX - SG_ EngAstHtCstStRq : 3|3@0+ (1,0) [0|7] "" XXX - SG_ EngAstHtPlgInCstStRq : 6|3@0+ (1,0) [0|7] "" XXX - SG_ DsplTrnsShftLvrLckRqd : 7|1@0+ (1,0) [0|1] "" XXX - SG_ EngyCnsHistGrphRstRq : 8|1@0+ (1,0) [0|1] "" XXX - SG_ USBProgInPrgrs : 9|1@0+ (1,0) [0|1] "" XXX - SG_ LBCPosMdfcReq : 12|3@0+ (1,0) [0|7] "" XXX - SG_ LBCCsStReq : 14|2@0+ (1,0) [0|3] "" XXX - SG_ LBCCstmrDaRstReq : 20|5@0+ (1,0) [0|0] "" XXX - SG_ LBCCDRR_PosNum : 18|3@0+ (1,0) [0|7] "" XXX - SG_ LBCCDRR_ClrStrdPosReq : 20|2@0+ (1,0) [0|3] "" XXX - -BO_ 2150383616 Engine_Maintenance_Mode_Req_LS: 8 XXX - SG_ MntnceMdDsplyRq : 3|4@0+ (1,0) [0|15] "" XXX - SG_ EngMntnceMdAct : 4|1@0+ (1,0) [0|1] "" XXX - SG_ EngMntncePrcntCpl : 15|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ EngPrpDspPwrLvlPct : 23|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ EstElecPrpCap : 31|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ PrpCapDspOpPs : 39|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ PrpDspTtlPwr : 45|13@0+ (0.5,-326.6) [-326.6|3768.9] "kW" XXX - SG_ BatPrpDspPwrLvlPct : 48|9@0- (0.392157,0) [-100.392192|100.000035] "%" XXX - -BO_ 2151981056 Drive_Cycle_Efficiency_LS: 8 XXX - SG_ DstTrvldDt : 7|51@0+ (1,0) [0|0] "" XXX - SG_ DTD_BattPrpDstTrvld : 7|17@0+ (0.015625,0) [0|2047.984375] "km" XXX - SG_ DTD_FuelPrpDstTrvld : 22|17@0+ (0.015625,0) [0|2047.984375] "km" XXX - SG_ DTD_DrvCyclDstTrvld : 37|17@0+ (0.015625,0) [0|2047.984375] "km" XXX - SG_ DrvCyclBatPropRat : 50|11@0+ (0.048852,0) [0|100.000044] "%" XXX - -BO_ 2151964672 Drive_Cycle_Energy_Efficiency_LS: 8 XXX - SG_ DrvCyclBatCondEnrgEfncy : 7|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ DrvCyclCbnCondEnrgEfncy : 23|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ DrvCyclDrvStEnrgEfncy : 31|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ DrvCyclTtlEnrgEfncy : 39|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ DrvCyclFuelEnmy : 47|12@0+ (0.1,0) [0|409.5] "km/liters" XXX - SG_ DrvCyclFuelUsd : 51|12@0+ (0.125,0) [0|511.875] "liters" XXX - -BO_ 2156298240 High_Volt_Batt_Time_Pwr_Chrg_LS: 8 XXX - SG_ HVBatCmpltTmHghPwrChrg : 7|14@0+ (1,0) [0|0] "" XXX - SG_ HVBCTHPC_HrOfDy : 4|5@0+ (1,0) [0|31] "Hour" XXX - SG_ HVBCTHPC_DyOfWk : 7|3@0+ (1,0) [0|7] "" XXX - SG_ HVBCTHPC_MntOfHr : 15|6@0+ (1,0) [0|63] "Minute" XXX - SG_ HVBatCmpltTmLwPwrChrg : 9|14@0+ (1,0) [0|0] "" XXX - SG_ HVBCTLPC_DyOfWk : 9|3@0+ (1,0) [0|7] "" XXX - SG_ HVBCTLPC_MntOfHr : 17|6@0+ (1,0) [0|63] "Minute" XXX - SG_ HVBCTLPC_HrOfDy : 22|5@0+ (1,0) [0|31] "Hour" XXX - SG_ HVBatStrTmHghPwrChrg : 27|14@0+ (1,0) [0|0] "" XXX - SG_ HVBSTHPC_HrOfDy : 24|5@0+ (1,0) [0|31] "Hour" XXX - SG_ HVBSTHPC_DyOfWk : 27|3@0+ (1,0) [0|7] "" XXX - SG_ HVBSTHPC_MntOfHr : 35|6@0+ (1,0) [0|63] "Minute" XXX - SG_ HVBatStrTmLwPwrChrg : 45|14@0+ (1,0) [0|0] "" XXX - SG_ HVBSTLPC_HrOfDy : 42|5@0+ (1,0) [0|31] "Hour" XXX - SG_ HVBSTLPC_DyOfWk : 45|3@0+ (1,0) [0|7] "" XXX - SG_ HVBSTLPC_MntOfHr : 53|6@0+ (1,0) [0|63] "Minute" XXX - SG_ HVChrgSysDpTmExdSt : 58|3@0+ (1,0) [0|0] "" XXX - SG_ HVCSDTES_NPDTIO : 56|1@0+ (1,0) [0|1] "" XXX - SG_ HVCSDTES_HiPwrCIO : 57|1@0+ (1,0) [0|1] "" XXX - SG_ HVCSDTES_LoPwrCIO : 58|1@0+ (1,0) [0|1] "" XXX - SG_ HTRActvIndOn : 59|1@0+ (1,0) [0|1] "" XXX - SG_ InsfcntTmTFlChrgIO : 60|1@0+ (1,0) [0|1] "" XXX - SG_ InvldHMIEtrIO : 61|1@0+ (1,0) [0|1] "" XXX - SG_ HVBatChrgCrdAlrtReq : 63|2@0+ (1,0) [0|3] "" XXX - -BO_ 2149924864 Drv_Pref_Mode_Switch_Status_LS: 8 XXX - SG_ DrvSelMd1Stat : 0|1@0+ (1,0) [0|1] "" XXX - SG_ DrvSelMd1ReqDnd : 1|1@0+ (1,0) [0|1] "" XXX - SG_ DrvSelMd2Stat : 2|1@0+ (1,0) [0|1] "" XXX - SG_ DrvSelMd2ReqDnd : 3|1@0+ (1,0) [0|1] "" XXX - SG_ DrvSelMd3Stat : 4|1@0+ (1,0) [0|1] "" XXX - SG_ DrvSelMd3ReqDnd : 5|1@0+ (1,0) [0|1] "" XXX - SG_ HilRlbkCtrlActIO : 6|1@0+ (1,0) [0|1] "" XXX - SG_ FwdClnMtgnBrkReqAct : 7|1@0+ (1,0) [0|1] "" XXX - SG_ DrvSelMdSelnStat : 8|17@0+ (1,0) [0|0] "" XXX - SG_ DSMSS_DrvSelMd1Un : 8|1@0+ (1,0) [0|1] "" XXX - SG_ DSMSS_DrvSelMd1Pn : 16|1@0+ (1,0) [0|1] "" XXX - SG_ DSMSS_DrvSelMd8Un : 17|1@0+ (1,0) [0|1] "" XXX - SG_ DSMSS_DrvSelMd7Un : 18|1@0+ (1,0) [0|1] "" XXX - SG_ DSMSS_DrvSelMd6Un : 19|1@0+ (1,0) [0|1] "" XXX - SG_ DSMSS_DrvSelMd5Un : 20|1@0+ (1,0) [0|1] "" XXX - SG_ DSMSS_DrvSelMd4Un : 21|1@0+ (1,0) [0|1] "" XXX - SG_ DSMSS_DrvSelMd3Un : 22|1@0+ (1,0) [0|1] "" XXX - SG_ DSMSS_DrvSelMd2Un : 23|1@0+ (1,0) [0|1] "" XXX - SG_ DSMSS_DrvSelMd0Pn : 24|1@0+ (1,0) [0|1] "" XXX - SG_ DSMSS_DrvSelMd8Pn : 25|1@0+ (1,0) [0|1] "" XXX - SG_ DSMSS_DrvSelMd7Pn : 26|1@0+ (1,0) [0|1] "" XXX - SG_ DSMSS_DrvSelMd6Pn : 27|1@0+ (1,0) [0|1] "" XXX - SG_ DSMSS_DrvSelMd5Pn : 28|1@0+ (1,0) [0|1] "" XXX - SG_ DSMSS_DrvSelMd4Pn : 29|1@0+ (1,0) [0|1] "" XXX - SG_ DSMSS_DrvSelMd3Pn : 30|1@0+ (1,0) [0|1] "" XXX - SG_ DSMSS_DrvSelMd2Pn : 31|1@0+ (1,0) [0|1] "" XXX - SG_ DrvSelMd4Stat : 9|1@0+ (1,0) [0|1] "" XXX - SG_ DrvSelMd4ReqDnd : 10|1@0+ (1,0) [0|1] "" XXX - SG_ DrvSelMd5Stat : 11|1@0+ (1,0) [0|1] "" XXX - SG_ DrvSelMd5ReqDnd : 12|1@0+ (1,0) [0|1] "" XXX - SG_ DrvSelMd6Stat : 13|1@0+ (1,0) [0|1] "" XXX - SG_ DrvSelMd6ReqDnd : 14|1@0+ (1,0) [0|1] "" XXX - SG_ PTOMobModTrnsInGrIO : 15|1@0+ (1,0) [0|1] "" XXX - SG_ ECODrvAsstDsplyStat : 34|11@0+ (1,0) [0|0] "" XXX - SG_ EDADS_ShftIndStat : 33|2@0+ (1,0) [0|3] "" XXX - SG_ EDADS_EcoDrvShftIO : 34|1@0+ (1,0) [0|1] "" XXX - SG_ EDADS_RcmndtFwdGr : 43|4@0+ (1,0) [0|15] "" XXX - SG_ EDADS_CrntFwdMsdG : 47|4@0+ (1,0) [0|15] "" XXX - SG_ DrvSelMd7Stat : 35|1@0+ (1,0) [0|1] "" XXX - SG_ DrvSelMd7ReqDnd : 36|1@0+ (1,0) [0|1] "" XXX - SG_ DrvSelMd8Stat : 37|1@0+ (1,0) [0|1] "" XXX - SG_ DrvSelMd8ReqDnd : 38|1@0+ (1,0) [0|1] "" XXX - SG_ FstIdlMdAct : 39|1@0+ (1,0) [0|1] "" XXX - SG_ DsplyPerfMdRq : 50|3@0+ (1,0) [0|7] "" XXX - SG_ TireLFLowTracIO : 51|1@0+ (1,0) [0|1] "" XXX - SG_ TireLRLowTracIO : 52|1@0+ (1,0) [0|1] "" XXX - SG_ TireRFLowTracIO : 53|1@0+ (1,0) [0|1] "" XXX - SG_ TireRRLowTracIO : 54|1@0+ (1,0) [0|1] "" XXX - SG_ a_12VBatSysUnstab : 55|1@0+ (1,0) [0|1] "" XXX - SG_ ColPrepSysCustAvail : 62|7@0+ (1,0) [0|0] "" XXX - SG_ CPSCA_Resrv3Avail : 56|1@0+ (1,0) [0|1] "" XXX - SG_ CPSCA_Resrv2Avail : 57|1@0+ (1,0) [0|1] "" XXX - SG_ CPSCA_Resrv1Avail : 58|1@0+ (1,0) [0|1] "" XXX - SG_ CPSCA_AlrtBrkStrAvail : 59|1@0+ (1,0) [0|1] "" XXX - SG_ CPSCA_AlrtBrkAvail : 60|1@0+ (1,0) [0|1] "" XXX - SG_ CPSCA_AlrtAvail : 61|1@0+ (1,0) [0|1] "" XXX - SG_ CPSCA_OffAvail : 62|1@0+ (1,0) [0|1] "" XXX - -BO_ 2152054784 HMI_Disp_Hyb_Animation_Status_LS: 1 XXX - SG_ AnmStrtReq : 2|3@0+ (1,0) [0|7] "" XXX - SG_ IntPnlClstrAnmtStat : 5|3@0+ (1,0) [0|7] "" XXX - SG_ FuelEconMetDispUnts : 6|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150301696 HMI_Animation_Initiator_LS: 1 XXX - SG_ WlcAnmReq : 0|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150563840 HMI_AnimationHybridRadio_LS: 3 XXX - SG_ RadAnmtStat : 2|3@0+ (1,0) [0|7] "" XXX - SG_ RadAudQueStat : 5|3@0+ (1,0) [0|7] "" XXX - SG_ DrStStatDispAct : 6|1@0+ (1,0) [0|1] "" XXX - SG_ PsStStatDispAct : 7|1@0+ (1,0) [0|1] "" XXX - -BO_ 2154758144 Auxiliary_Heater_Active_LS: 1 XXX - SG_ ChldLckOtSwAct : 1|1@0+ (1,0) [0|1] "" XXX - -BO_ 2154577920 Amp_Sink_Stat_LS: 2 XXX - SG_ AmpSnkStat : 4|13@0+ (1,0) [0|0] "" XXX - SG_ ASS_SurndAvail : 0|1@0+ (1,0) [0|1] "" XXX - SG_ ASS_DSPAvail : 1|1@0+ (1,0) [0|1] "" XXX - SG_ ASS_VehNoisCmpnAvail : 2|1@0+ (1,0) [0|1] "" XXX - SG_ ASS_PhLckdLpLckd : 3|1@0+ (1,0) [0|1] "" XXX - SG_ ASS_MtxSnkMutStat : 4|1@0+ (1,0) [0|1] "" XXX - SG_ ASS_DSPMd7Prsnt : 8|1@0+ (1,0) [0|1] "" XXX - SG_ ASS_DSPMd6Prsnt : 9|1@0+ (1,0) [0|1] "" XXX - SG_ ASS_DSPMd5Prsnt : 10|1@0+ (1,0) [0|1] "" XXX - SG_ ASS_DSPMd4Prsnt : 11|1@0+ (1,0) [0|1] "" XXX - SG_ ASS_DSPMd3Prsnt : 12|1@0+ (1,0) [0|1] "" XXX - SG_ ASS_DSPMd2Prsnt : 13|1@0+ (1,0) [0|1] "" XXX - SG_ ASS_DSPMd1Prsnt : 14|1@0+ (1,0) [0|1] "" XXX - SG_ ASS_DSPMd0Prsnt : 15|1@0+ (1,0) [0|1] "" XXX - -BO_ 2154594304 Amp_Settings_Tone_Ctrl_LS: 5 XXX - SG_ AmpSetTonCtrl : 1|34@0+ (1,0) [0|0] "" XXX - SG_ ASTC_ChimSnkLvl : 1|8@0+ (0.5,-127.5) [-127.5|0] "dB" XXX - SG_ ASTC_ChimSnkSpkrPos : 9|4@0+ (1,0) [0|15] "" XXX - SG_ ASTC_SurndLvl : 21|6@0- (1,0) [-32|31] "" XXX - SG_ ASTC_MtxSnkMutRmpTm : 25|8@0+ (5,0) [0|1275] "ms" XXX - SG_ ASTC_MtxSnkMut : 26|1@0+ (1,0) [0|1] "" XXX - SG_ ASTC_DSPMd : 30|4@0+ (1,0) [0|15] "" XXX - SG_ ASTC_VehNoisCmpnAct : 31|1@0+ (1,0) [0|1] "" XXX - SG_ ASTC_GblAudSnkMut : 32|1@0+ (1,0) [0|1] "" XXX - SG_ ASTC_AmpLwPwrSt : 33|1@0+ (1,0) [0|1] "" XXX - SG_ InfotnBkltngConfigSt : 3|2@0+ (1,0) [0|3] "" XXX - -BO_ 2154586112 Amp_Settings_Sink_Lvl_Ctrl_LS: 8 XXX - SG_ AmpSetSnkLvlCtrl : 7|64@0+ (1,0) [0|0] "" XXX - SG_ ASSLC_MtxSnkLvl : 7|8@0+ (0.5,-127.5) [-127.5|0] "dB" XXX - SG_ ASSLC_MxPrmtSnkLvl : 15|8@0+ (0.5,-127.5) [-127.5|0] "dB" XXX - SG_ ASSLC_AudFdbkSnkLvl : 23|8@0+ (0.5,-127.5) [-127.5|0] "dB" XXX - SG_ ASSLC_FvSnkLvl : 31|8@0+ (0.5,-127.5) [-127.5|0] "dB" XXX - SG_ ASSLC_MtxSnkFd : 33|6@0- (1,0) [-32|31] "" XXX - SG_ ASSLC_MtxSnkBal : 39|6@0- (1,0) [-32|31] "" XXX - SG_ ASSLC_MtxSnkBass : 43|6@0- (1,0) [-32|31] "" XXX - SG_ ASSLC_MtxSnkMdrng : 53|6@0- (1,0) [-32|31] "" XXX - SG_ ASSLC_AutoLdnsCmpnAct : 56|1@0+ (1,0) [0|1] "" XXX - SG_ ASSLC_VcSrcActOnMtx : 57|1@0+ (1,0) [0|1] "" XXX - SG_ ASSLC_MtxSnkTrbl : 63|6@0- (1,0) [-32|31] "" XXX - -BO_ 2152857600 ACC_TrafficJam_RouteSpd_Stat_LS: 3 XXX - SG_ ACCRteSpdDrvIntvReq : 1|2@0+ (1,0) [0|3] "" XXX - SG_ ACCTrfcJamAstActStat : 10|3@0+ (1,0) [0|7] "" XXX - SG_ ACCRteSpdAdaptStat : 12|2@0+ (1,0) [0|3] "" XXX - SG_ ACCGrnMdStat : 14|2@0+ (1,0) [0|3] "" XXX - SG_ ACCTrfcJamAstRmnTm : 23|8@0+ (1,0) [0|255] "sec" XXX - -BO_ 2158149632 High_Volt_Bat_Time_Bsd_Rsp_1_LS: 7 XXX - SG_ HVBatTmBsSsnChRsp : 0|14@0+ (1,0) [0|0] "" XXX - SG_ HVBTBSCR_SsnStat : 0|2@0+ (1,0) [0|3] "" XXX - SG_ HVBTBSCR_SsnMthStat : 11|4@0+ (1,0) [0|15] "" XXX - SG_ HVBTBSCR_SsnSlctStat : 14|3@0+ (1,0) [0|7] "" XXX - SG_ HVBTBSCR_SsnDyStat : 23|5@0+ (1,0) [0|31] "day" XXX - SG_ HVBatTmBsChrgStRsp : 3|3@0+ (1,0) [0|7] "" XXX - SG_ HVBatCrgDspStat : 6|3@0+ (1,0) [0|7] "" XXX - SG_ HVBatTmBsChrgRtRsp : 17|10@0+ (1,0) [0|0] "" XXX - SG_ HVBTBCRS_ChRtEnblStat : 17|2@0+ (1,0) [0|3] "" XXX - SG_ HVBTBCRS_ChRtSlctStat : 27|4@0+ (1,0) [0|15] "" XXX - SG_ HVBTBCRS_ChRtDStat : 31|4@0+ (1,0) [0|15] "" XXX - SG_ EngyCnsHsGrphCnfgDt : 36|13@0+ (1,0) [0|0] "" XXX - SG_ ECHGCD_YAxMaxVal : 32|6@0+ (4,0) [0|252] "" XXX - SG_ ECHGCD_MeasUt : 36|4@0+ (1,0) [0|15] "" XXX - SG_ ECHGCD_XAxTkMrkInterv : 42|3@0+ (1,0) [0|7] "" XXX - SG_ EgyCnsHstGphInsEgyCns : 55|5@0+ (1,0) [0|31] "" XXX - -BO_ 2158116864 High_Volt_Bat_Time_Bsd_Rsp_LS: 8 XXX - SG_ OBHVBCMinsRmng : 5|6@0+ (1,0) [0|63] "" XXX - SG_ OBHVBCCompTmDispFrmt : 7|2@0+ (1,0) [0|3] "" XXX - SG_ HVBatTmBsDelChrgRsp : 12|21@0+ (1,0) [0|0] "" XXX - SG_ HVBTBDCRS_DlChHRsp : 12|5@0+ (1,0) [0|31] "hr" XXX - SG_ HVBTBDCRS_DlChSlctStat : 19|4@0+ (1,0) [0|15] "" XXX - SG_ HVBTBDCRS_DlChDStat : 23|4@0+ (1,0) [0|15] "" XXX - SG_ HVBTBDCRS_DlChMHRsp : 29|6@0+ (1,0) [0|63] "min" XXX - SG_ HVBTBDCRS_DlChSsnStat : 31|2@0+ (1,0) [0|3] "" XXX - SG_ HVBatTmBsRtChrgRsp : 34|27@0+ (1,0) [0|0] "" XXX - SG_ HVBTBRCR_RtChMHRsp : 32|6@0+ (1,0) [0|63] "min" XXX - SG_ HVBTBRCR_RtChSsnStat : 34|2@0+ (1,0) [0|3] "" XXX - SG_ HVBTBRCR_RtChSlctStat : 42|3@0+ (1,0) [0|7] "" XXX - SG_ HVBTBRCR_RtChDStat : 50|4@0+ (1,0) [0|15] "" XXX - SG_ HVBTBRCR_RtChHRsp : 55|5@0+ (1,0) [0|31] "hr" XXX - SG_ HVBTBRCR_RtCHSlctTblRwStat : 58|3@0+ (1,0) [0|7] "rows" XXX - SG_ HVBTBRCR_RtChSlRtStat : 62|4@0+ (1,0) [0|15] "" XXX - -BO_ 2156281856 High_Volt_Bat_Time_Bsd_Req_1_LS: 7 XXX - SG_ HVBatTmBsSsnChStReq : 0|14@0+ (1,0) [0|0] "" XXX - SG_ HVBTBSCSR_SsnStReq : 0|2@0+ (1,0) [0|3] "" XXX - SG_ HVBTBSCSR_SsnMthStReq : 11|4@0+ (1,0) [0|15] "" XXX - SG_ HVBTBSCSR_SsnSlStReq : 14|3@0+ (1,0) [0|7] "" XXX - SG_ HVBTBSCSR_SsnDayStReq : 23|5@0+ (1,0) [0|31] "day" XXX - SG_ HVBatTmBsChrgMdReq : 3|3@0+ (1,0) [0|7] "" XXX - SG_ HVChgSyChgLvlPrfSt : 6|3@0+ (1,0) [0|7] "" XXX - SG_ StTODChrgTmpOvrd : 7|1@0+ (1,0) [0|1] "" XXX - SG_ HVBatTmBsChrgRtStReq : 17|10@0+ (1,0) [0|0] "" XXX - SG_ HVBTBCRSR_ChRtEnblStReq : 17|2@0+ (1,0) [0|3] "" XXX - SG_ HVBTBCRSR_ChRtSlStReq : 27|4@0+ (1,0) [0|15] "" XXX - SG_ HVBTBCRSR_ChRtDStReq : 31|4@0+ (1,0) [0|15] "" XXX - SG_ TmpOvdNxtPlnDptTmRq : 32|17@0+ (1,0) [0|0] "" XXX - SG_ TONPDTR_StTmpOvrAtv : 32|2@0+ (1,0) [0|3] "" XXX - SG_ TONPDTR_HrOfDy : 42|5@0+ (1,0) [0|31] "Hour" XXX - SG_ TONPDTR_DyOfWk : 46|4@0+ (1,0) [0|15] "" XXX - SG_ TONPDTR_MntOfHr : 53|6@0+ (1,0) [0|63] "Minute" XXX - SG_ RtBsChrgCmplnTmPrfReq : 34|2@0+ (1,0) [0|3] "" XXX - SG_ HTRCsStReq : 37|3@0+ (1,0) [0|7] "" XXX - -BO_ 2156265472 High_Volt_Bat_Time_Bsd_Req_LS: 8 XXX - SG_ ChgCdTfAlCzStRq : 2|3@0+ (1,0) [0|7] "" XXX - SG_ ChgPwLsAlCzStRq : 5|3@0+ (1,0) [0|7] "" XXX - SG_ PrtyChrgRq : 7|2@0+ (1,0) [0|3] "" XXX - SG_ HVBatTmBsDlChStReq : 12|21@0+ (1,0) [0|0] "" XXX - SG_ HVBTBDCSRQ_DlChHStReq : 12|5@0+ (1,0) [0|31] "hr" XXX - SG_ HVBTBDCSRQ_DlChSlStReq : 19|4@0+ (1,0) [0|15] "" XXX - SG_ HVBTBDCSRQ_DlChDStReq : 23|4@0+ (1,0) [0|15] "" XXX - SG_ HVBTBDCSRQ_DlChMHStReq : 29|6@0+ (1,0) [0|63] "min" XXX - SG_ HVBTBDCSRQ_DlChSsnStReq : 31|2@0+ (1,0) [0|3] "" XXX - SG_ ChgSysAudInCsStReq : 15|3@0+ (1,0) [0|7] "" XXX - SG_ HVBatTmBsRtChrgStReq : 34|27@0+ (1,0) [0|0] "" XXX - SG_ HVBTBRCSR_RtChDStReq : 34|4@0+ (1,0) [0|15] "" XXX - SG_ HVBTBRCSR_RtChSlStReq : 42|3@0+ (1,0) [0|7] "" XXX - SG_ HVBTBRCSR_RtChSlRtStReq : 46|4@0+ (1,0) [0|15] "" XXX - SG_ HVBTBRCSR_RtChMHStReq : 48|6@0+ (1,0) [0|63] "min" XXX - SG_ HVBTBRCSR_RtChSsnStReq : 50|2@0+ (1,0) [0|3] "" XXX - SG_ HVBTBRCSR_RtChHStReq : 55|5@0+ (1,0) [0|31] "hr" XXX - SG_ HVBTBRCSR_RtChSlTbRwReq : 58|3@0+ (1,0) [0|7] "rows" XXX - SG_ OffBrdHVCVehCsChRq : 35|1@0+ (1,0) [0|1] "" XXX - SG_ EngyUsgScrnMeasUtStat : 39|4@0+ (1,0) [0|15] "" XXX - -BO_ 2150113280 Energy_Storage_System_LS: 8 XXX - SG_ EngyStgSysActCoolEnb : 0|1@0+ (1,0) [0|1] "" XXX - SG_ DrvCycElEnrgUsd : 21|14@0+ (0.36,0) [0|5897.88] "MJ" XXX - SG_ DrvCyclElecEngyEcon : 32|9@0+ (0.1,0) [0|51.1] "" XXX - SG_ HVChrgInhbRsn : 36|4@0+ (1,0) [0|15] "" XXX - SG_ DrvCyclTrpDstTrvld : 54|15@0+ (0.1,0) [0|3276.7] "km" XXX - -BO_ 2150055936 Climate_Control_Status_LS: 5 XXX - SG_ ClmtCtrlUpprPwrLmt : 7|8@0+ (0.1,0) [0|25.5] "kW" XXX - SG_ ClmtCtrlLwrPwrLmt : 15|8@0+ (0.1,0) [0|25.5] "kW" XXX - SG_ ClimCtrlHVDvcShtdwnCmd : 16|1@0+ (1,0) [0|1] "" XXX - SG_ ClmCntCmpPwrUsdClc : 39|8@0+ (0.04,0) [0|10.2] "kW" XXX - -BO_ 2150039552 Thrml_Ref_Compressor_Status_LS: 5 XXX - SG_ ThrmlRefCompStat : 3|4@0+ (1,0) [0|15] "" XXX - SG_ EvpCorOtltAirTmpCalcdGroup : 4|13@0+ (1,0) [0|0] "" XXX - SG_ EvpCorOtltAirTmpCalcdV : 4|1@0+ (1,0) [0|1] "" XXX - SG_ EvpCorOtltAirTmpCalcd : 15|8@0+ (0.5,-40) [-40|87.5] "deg C" XXX - SG_ ThrmlRefCompSpdGroup : 22|15@0+ (1,0) [0|0] "" XXX - SG_ ThrmlRefCompSpd : 21|14@0+ (1,0) [0|16383] "rpm" XXX - SG_ ThrmlRefCompSpdV : 22|1@0+ (1,0) [0|1] "" XXX - SG_ ThrmlRfCmpOvTmpFltPr : 23|1@0+ (1,0) [0|1] "" XXX - -BO_ 2154856448 Humidity_Sensor_Status_LS: 5 XXX - SG_ HmdtySnsrGlssTemp : 1|10@0+ (0.146628,-50) [-50|100.000444] "deg C" XXX - SG_ HmdtySnsrTemp : 17|10@0+ (0.146628,-50) [-50|100.000444] "deg C" XXX - SG_ HmdtySnsrRltvHmdty : 39|8@0+ (0.392157,0) [0|100.000035] "%" XXX - -BO_ 2151342080 Park_Assistant_Right_Status_LS: 2 XXX - SG_ PARtRgn1ObjStat : 3|4@0+ (1,0) [0|15] "" XXX - SG_ PrkAstRtSysStat : 5|2@0+ (1,0) [0|3] "" XXX - SG_ PARtRgn3ObjStat : 11|4@0+ (1,0) [0|15] "" XXX - SG_ PARtRgn2ObjStat : 15|4@0+ (1,0) [0|15] "" XXX - -BO_ 2151325696 Park_Assistant_Left_Status_LS: 2 XXX - SG_ PALtRgn1ObjStat : 3|4@0+ (1,0) [0|15] "" XXX - SG_ PrkAstLtSysStat : 5|2@0+ (1,0) [0|3] "" XXX - SG_ PALtRgn3ObjStat : 11|4@0+ (1,0) [0|15] "" XXX - SG_ PALtRgn2ObjStat : 15|4@0+ (1,0) [0|15] "" XXX - -BO_ 2151809024 Drv_Cycl_Elec_Enrgy_Consumd_LS: 8 XXX - SG_ DrvCycElecEngySt5 : 5|14@0+ (0.36,0) [0|5897.88] "MJ" XXX - SG_ DrvCycElecEngyCnsmd : 23|32@0+ (1,0) [0|0] "" XXX - SG_ DCEEC_EngyPct1 : 23|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ DCEEC_EngyPct2 : 31|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ DCEEC_EngyPct3 : 39|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ DCEEC_EngyPct4 : 47|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ ElecEngyEconAvg : 48|9@0+ (0.1,0) [0|51.1] "" XXX - -BO_ 2151858176 Drv_Cycl_Elec_Enrgy_States_LS: 8 XXX - SG_ DrvCycElecEngySt1 : 5|14@0+ (0.36,0) [0|5897.88] "MJ" XXX - SG_ DrvCycElecEngySt2 : 21|14@0+ (0.36,0) [0|5897.88] "MJ" XXX - SG_ DrvCycElecEngySt3 : 37|14@0+ (0.36,0) [0|5897.88] "MJ" XXX - SG_ DrvCycElecEngySt4 : 53|14@0+ (0.36,0) [0|5897.88] "MJ" XXX - -BO_ 2150547456 HMI_Hybrid_Vehicle_Status_LS: 8 XXX - SG_ HVDpltnMdRng : 0|16@0+ (0.015625,0) [0|1023.984375] "km" XXX - SG_ VehChrgMdSt : 3|3@0+ (1,0) [0|7] "" XXX - SG_ GrnAudQueReq : 4|1@0+ (1,0) [0|1] "" XXX - SG_ SvcHybChrgSysIO : 5|1@0+ (1,0) [0|1] "" XXX - SG_ HVBatChrgCrdConnIO : 6|1@0+ (1,0) [0|1] "" XXX - SG_ CntrsOpnUndrTmpIO : 7|1@0+ (1,0) [0|1] "" XXX - SG_ OffBrdHVCVehCplrLkd : 16|1@0+ (1,0) [0|1] "" XXX - SG_ HVBatLimDTmpInd : 25|2@0+ (1,0) [0|3] "" XXX - SG_ OffBrdHVCVehPwrDrtd : 26|1@0+ (1,0) [0|1] "" XXX - SG_ HVChrgrSysStat : 29|3@0+ (1,0) [0|7] "" XXX - SG_ HVChrgrCplrStat : 31|2@0+ (1,0) [0|3] "" XXX - SG_ ChgrSysAdblIndReq : 33|2@0+ (1,0) [0|3] "" XXX - SG_ HVBatOutOfEnrgyInd : 36|3@0+ (1,0) [0|7] "" XXX - SG_ OffBrdHVBlkChrgCmp : 37|1@0+ (1,0) [0|1] "" XXX - SG_ ElecPrplsnMtrOvrSpdIO : 38|1@0+ (1,0) [0|1] "" XXX - SG_ HVBatCntctrsOpnIO : 39|1@0+ (1,0) [0|1] "" XXX - SG_ HVDpltnMdCnfdcTrndg : 47|8@0- (0.787402,0) [-100.787456|100.000054] "%" XXX - SG_ OffBrdHVBlkChgCpltTm : 53|14@0+ (1,0) [0|0] "" XXX - SG_ OBHVBCCT_HrofDay : 50|5@0+ (1,0) [0|31] "" XXX - SG_ OBHVBCCT_DayofWk : 53|3@0+ (1,0) [0|7] "" XXX - SG_ OBHVBCCT_MinofHr : 61|6@0+ (1,0) [0|63] "" XXX - SG_ OffBrdHVCVehPwrLvl : 55|2@0+ (1,0) [0|3] "" XXX - -BO_ 2151489536 CSV_EOCM_R_Indications_LS: 1 XXX - SG_ RVBShtToPrkBfExtngVehIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ RVBAutoBrkRlsIO : 1|1@0+ (1,0) [0|1] "" XXX - SG_ NVSysStat : 4|3@0+ (1,0) [0|7] "" XXX - -BO_ 2149761024 Chassis_Information_2_LS: 6 XXX - SG_ PerfTrcCrnExStngVal : 4|5@0+ (1,0) [0|31] "" XXX - SG_ ActVehAccelGroup : 5|22@0+ (1,0) [0|0] "" XXX - SG_ ActVehAccelV : 5|1@0+ (1,0) [0|1] "" XXX - SG_ ActVehAccel : 11|12@0- (0.01,0) [-20.48|20.47] "m/s^2" XXX - SG_ TrlrStabAstActIO : 6|1@0+ (1,0) [0|1] "" XXX - SG_ ElvtdIdlCstStAvl : 7|1@0+ (1,0) [0|1] "" XXX - SG_ ElvtdIdlCstCrStVal : 13|2@0+ (1,0) [0|3] "" XXX - SG_ TrnsCltchThrmlProtIndR : 27|20@0+ (1,0) [0|0] "" XXX - SG_ TCTPIR_DrvNotfn : 27|4@0+ (1,0) [0|15] "" XXX - SG_ TCTPIR_TnsEsClTmpD : 39|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ TCTPIR_TnsEsClCDwT : 47|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ PsngStPerfMdCsCrStVal : 30|3@0+ (1,0) [0|7] "" XXX - SG_ PsngStPerfMdCsStAvl : 31|1@0+ (1,0) [0|1] "" XXX - -BO_ 2155012096 SBZA_Right_Status_LS: 1 XXX - SG_ SODTmpUnavlbleIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ SODSnsClnRqdIO : 1|1@0+ (1,0) [0|1] "" XXX - SG_ SODRtIndCntl : 6|5@0+ (1,0) [0|0] "" XXX - SG_ SODRIC_Ind3 : 2|1@0+ (1,0) [0|1] "" XXX - SG_ SODRIC_Ind2 : 3|1@0+ (1,0) [0|1] "" XXX - SG_ SODRIC_Ind1 : 4|1@0+ (1,0) [0|1] "" XXX - SG_ SODRIC_IndReq : 6|2@0+ (1,0) [0|3] "" XXX - SG_ SrvSODSysIO : 7|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150514688 Power_Slidining_Door_Status_LS: 1 XXX - SG_ SldngDrRgtStat : 2|3@0+ (1,0) [0|7] "" XXX - SG_ SldngDrLftStat : 5|3@0+ (1,0) [0|7] "" XXX - SG_ PwrSldngDrUnavlblIO : 6|1@0+ (1,0) [0|1] "" XXX - SG_ SdClsrObstclDtctdStat : 7|1@0+ (1,0) [0|1] "" XXX - -BO_ 2158067712 Video_Master_Info_2_LS: 5 XXX - SG_ TchScnDsplUsrActnExt : 1|34@0+ (1,0) [0|0] "" XXX - SG_ TSDUAE_RotBtnPsh : 0|1@0+ (1,0) [0|1] "" XXX - SG_ TSDUAE_ScrnPrsdRq : 1|1@0+ (1,0) [0|1] "" XXX - SG_ TSDUAE_GrphStrkInfRq : 15|8@0+ (1,0) [0|255] "" XXX - SG_ TSDUAE_XCoOdntRq : 23|8@0+ (1,0) [0|255] "" XXX - SG_ TSDUAE_YCoOdntRq : 31|8@0+ (1,0) [0|255] "" XXX - SG_ TSDUAE_RotEnc : 39|8@0- (1,0) [-128|127] "Detentions" XXX - -BO_ 2158051328 Video_Master_Info_1_LS: 5 XXX - SG_ RemRcvrSrcInpCmd : 3|4@0+ (1,0) [0|15] "" XXX - SG_ VidMstrDsplyMd : 5|2@0+ (1,0) [0|3] "" XXX - SG_ VidSrcUICntrlStat : 6|1@0+ (1,0) [0|1] "" XXX - SG_ RmtRcvrTunCmnd : 12|5@0+ (1,0) [0|31] "" XXX - SG_ VidMstrArbCmd : 15|3@0+ (1,0) [0|7] "" XXX - SG_ RmtRcvrTunVal : 23|16@0- (1,0) [-32768|32767] "" XXX - SG_ VidMstrSrcType : 36|5@0+ (1,0) [0|31] "" XXX - SG_ TVDspCmd : 39|3@0+ (1,0) [0|7] "" XXX - -BO_ 2158034944 TV_Tuner_Info_LS: 6 XXX - SG_ VidSrcCompFormatER : 3|4@0+ (1,0) [0|15] "" XXX - SG_ CurntTVStnServc : 6|3@0+ (1,0) [0|7] "" XXX - SG_ CurntTVStnQual : 7|1@0+ (1,0) [0|1] "" XXX - SG_ RmtRcvrCmndStat : 10|3@0+ (1,0) [0|7] "" XXX - SG_ RmtRecvtDataTyp : 13|3@0+ (1,0) [0|7] "" XXX - SG_ RmtRcvrTunStat : 14|1@0+ (1,0) [0|1] "" XXX - SG_ TVTunerPres : 15|1@0+ (1,0) [0|1] "" XXX - SG_ RmtRcvrPrgrmServID : 23|16@0+ (1,0) [0|65535] "" XXX - SG_ VidSrcStatCode : 35|4@0+ (1,0) [0|15] "" XXX - SG_ RemRcvrSrcInpStat : 39|4@0+ (1,0) [0|15] "" XXX - SG_ VidSrcType : 44|5@0+ (1,0) [0|31] "" XXX - -BO_ 2158018560 TV_Station_Name_LS: 8 XXX - SG_ TVStatNmeChar1_8 : 7|64@0+ (1,0) [0|0] "" XXX - -BO_ 2156838912 WiFi_Station_LS: 7 XXX - SG_ WiFiStationResp : 3|52@0+ (1,0) [0|0] "" XXX - SG_ WSR_WiFiAssnStat : 3|4@0+ (1,0) [0|15] "" XXX - SG_ WSR_WiFiStnMACAddr : 15|48@0+ (1,0) [0|281474976710655] "" XXX - -BO_ 2156822528 WiFi_AP_Data_LS: 2 XXX - SG_ WiFiAccsPntData : 0|9@0+ (1,0) [0|0] "" XXX - SG_ WAPD_IHUWiFiEnStat : 0|1@0+ (1,0) [0|1] "" XXX - SG_ WAPD_EncrptnType : 11|4@0+ (1,0) [0|15] "" XXX - SG_ WAPD_SecurityType : 15|4@0+ (1,0) [0|15] "" XXX - -BO_ 2151948288 Driver_Drow_Det_Cst_Rqst_LS: 1 XXX - SG_ DrvDrowDetCstStRq : 2|3@0+ (1,0) [0|7] "" XXX - SG_ RunBrdOpMdCstStReq : 7|3@0+ (1,0) [0|7] "" XXX - -BO_ 2158002176 XM_Radio_Service_LS: 1 XXX - SG_ CurntStnServc : 2|3@0+ (1,0) [0|7] "" XXX - SG_ SrvcPrvdr : 5|3@0+ (1,0) [0|7] "" XXX - -BO_ 2149728256 Charging_Sys_Trans_Shift_Lock_LS: 5 XXX - SG_ ChrgSysTrnsShftLckRq : 0|1@0+ (1,0) [0|1] "" XXX - SG_ ChrgPrtDrStat : 2|2@0+ (1,0) [0|3] "" XXX - SG_ PrtyChrgActIO : 3|1@0+ (1,0) [0|1] "" XXX - SG_ PrtyChrgAct : 4|1@0+ (1,0) [0|1] "" XXX - SG_ HghVltgPropState : 7|3@0+ (1,0) [0|7] "" XXX - SG_ ChgCdTfAlCzCrStVal : 10|3@0+ (1,0) [0|7] "" XXX - SG_ ChgCdTfAlCzStAvbl : 11|1@0+ (1,0) [0|1] "" XXX - SG_ ChgPwLsAlCzCrStVal : 14|3@0+ (1,0) [0|7] "" XXX - SG_ ChgPwLsAlCzStAvbl : 15|1@0+ (1,0) [0|1] "" XXX - SG_ ChgSyAudInCsCrStVa : 18|3@0+ (1,0) [0|7] "" XXX - SG_ ChgSysAudInCsStAvl : 19|1@0+ (1,0) [0|1] "" XXX - SG_ HVChrgPwrLvl : 22|3@0+ (1,0) [0|7] "" XXX - SG_ EngAstHtCsCrStVal : 26|3@0+ (1,0) [0|7] "" XXX - SG_ EngAstHtCsStAvl : 27|1@0+ (1,0) [0|1] "" XXX - SG_ EngAstHtPlgInCsCrStVl : 30|3@0+ (1,0) [0|7] "" XXX - SG_ EngAstHtPlgInCsStAvl : 31|1@0+ (1,0) [0|1] "" XXX - SG_ PrtyChrgStPnt : 38|7@0+ (1,0) [0|127] "" XXX - -BO_ 2150023168 Hybrid_Information_LS: 5 XXX - SG_ HybChrgMdStat : 1|2@0+ (1,0) [0|3] "" XXX - SG_ HVInvRatVltGroup : 2|19@0+ (1,0) [0|0] "" XXX - SG_ HVInvRatVltV : 2|1@0+ (1,0) [0|1] "" XXX - SG_ HVInvRatVlt : 8|9@0+ (1,0) [0|511] "volts" XXX - SG_ OffBrdVehImmbNot : 5|3@0+ (1,0) [0|7] "" XXX - SG_ ElecPrplsnMtrTach : 28|13@0+ (1,0) [0|8191] "rpm" XXX - -BO_ 2153988096 Power_Elec_Info_LS: 7 XXX - SG_ PwrElecCoolLpTempGroup : 1|10@0+ (1,0) [0|0] "" XXX - SG_ PwrElecCoolLpTempV : 0|1@0+ (1,0) [0|1] "" XXX - SG_ PwrElecCoolLpTempM : 1|1@0+ (1,0) [0|1] "" XXX - SG_ PwrElecCoolLpTemp : 15|8@0+ (1,-40) [-40|215] "deg C" XXX - SG_ EngyUsgScr : 20|37@0+ (1,0) [0|0] "" XXX - SG_ EUS_TcEngyUsgScrAvVal : 20|7@0- (0.1,0) [-5|5] "" XXX - SG_ EUS_TrEngyUsgScrAvVal : 29|7@0- (0.1,0) [-5|5] "" XXX - SG_ EUS_OTEngyUsgScrAvVal : 38|7@0- (0.1,0) [-5|5] "" XXX - SG_ EUS_TtEngyUsgScrAvVal : 40|9@0- (0.1,0) [-20|20] "" XXX - SG_ EUS_ITEngyUsgScrAvVal : 47|7@0- (0.1,0) [-5|5] "" XXX - -BO_ 2155945984 Jump_Start_Req_LS: 1 XXX - SG_ JmpStrtReq : 0|1@0+ (1,0) [0|1] "" XXX - SG_ TCSysCurStReq : 2|2@0+ (1,0) [0|3] "" XXX - SG_ VehStbEnhmntCurStRq : 4|2@0+ (1,0) [0|3] "" XXX - SG_ VehStbCmptvMdCurStRq : 6|2@0+ (1,0) [0|3] "" XXX - -BO_ 2155585536 MSB_Customization_Setting_Req_LS: 1 XXX - SG_ StBltTgtCSRq : 2|3@0+ (1,0) [0|7] "" XXX - -BO_ 2155569152 CPS_Customization_Setting_Req_LS: 3 XXX - SG_ ColPrSysCustReq : 2|3@0+ (1,0) [0|7] "" XXX - SG_ ExtHlStrAssCsStRq : 5|3@0+ (1,0) [0|7] "" XXX - SG_ IntDimSeldClrTypStReq : 12|5@0+ (1,0) [0|31] "" XXX - SG_ HLOCCstSetReq : 15|3@0+ (1,0) [0|7] "" XXX - SG_ IntDimSeldAnmTypStReq : 19|4@0+ (1,0) [0|15] "" XXX - SG_ SmPhRmFunCstStReq : 22|3@0+ (1,0) [0|7] "" XXX - -BO_ 2155233280 VICM_Info_LS: 8 XXX - SG_ VehRefuelSt : 2|3@0+ (1,0) [0|7] "" XXX - SG_ FlDrOpenIndOn : 3|1@0+ (1,0) [0|1] "" XXX - SG_ UtlChrgPopUpAct : 4|1@0+ (1,0) [0|1] "" XXX - SG_ UtlChrgIntrfrIO : 5|1@0+ (1,0) [0|1] "" XXX - SG_ ShftPrkIO_3B2 : 6|1@0+ (1,0) [0|1] "" XXX - SG_ NtrlCstdwnCrtMdActvIO : 7|1@0+ (1,0) [0|1] "" XXX - SG_ RtBsChrgCmplnTmPrfRsp : 9|2@0+ (1,0) [0|3] "" XXX - SG_ EngRnngDutoVehSpdIO : 10|1@0+ (1,0) [0|1] "" XXX - SG_ NtrlGrWrngIO : 11|1@0+ (1,0) [0|1] "" XXX - SG_ LftmFuelEcon : 19|12@0+ (0.1,0) [0|409.5] "kilometers/liter" XXX - SG_ LiftimeFuelEcnEquiv : 35|12@0+ (0.1,0) [0|409.5] "km/l" XXX - SG_ ChrgCyclFuelEcn : 51|12@0+ (0.1,0) [0|409.5] "km/l" XXX - -BO_ 2152169472 Coolant_Heater_Status_LS: 3 XXX - SG_ ClntHtrSt : 1|2@0+ (1,0) [0|3] "" XXX - SG_ ClntHtrPCBOvTmpFlt : 2|1@0+ (1,0) [0|1] "" XXX - SG_ ClntHtrHtSnkOvTmpFlt : 3|1@0+ (1,0) [0|1] "" XXX - SG_ ClntHtrElecPwrGroup : 4|13@0+ (1,0) [0|0] "" XXX - SG_ ClntHtrElecPwrV : 4|1@0+ (1,0) [0|1] "" XXX - SG_ ClntHtrElecPwr : 15|8@0+ (0.04,0) [0|10.2] "kW" XXX - SG_ ClntHtrFlt : 7|3@0+ (1,0) [0|7] "" XXX - SG_ ClntHtrInltClntTmp : 23|8@0+ (1,-40) [-40|215] "deg C" XXX - -BO_ 2152759296 SITM_Front_Sensor_IO_LS: 1 XXX - SG_ FrtCmrBlckdIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ FrtEOCMMdlFldIO : 1|1@0+ (1,0) [0|1] "" XXX - SG_ FrtCmrFldIO : 2|1@0+ (1,0) [0|1] "" XXX - SG_ FrtRdrFldIO : 3|1@0+ (1,0) [0|1] "" XXX - SG_ PedWrnIndReq : 5|2@0+ (1,0) [0|3] "" XXX - -BO_ 2152742912 SITM_Rear_Sensor_IO_LS: 1 XXX - SG_ RrEOCMMdlFldIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ RrRdrBlckdIO : 1|1@0+ (1,0) [0|1] "" XXX - SG_ RrRdrFldIO : 2|1@0+ (1,0) [0|1] "" XXX - SG_ ShrtRngRdrOffIO : 3|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150891520 Go_Notifier_Req_LS: 5 XXX - SG_ DgtlMapSpdCat : 2|3@0+ (1,0) [0|7] "" XXX - SG_ FwdClnAlrtCustStngReq : 5|3@0+ (1,0) [0|7] "" XXX - SG_ GNCustStngReq : 7|2@0+ (1,0) [0|3] "" XXX - SG_ DgtlMapDrvngSd : 8|1@0+ (1,0) [0|1] "" XXX - SG_ DgtlMapPsgRstrctn : 11|3@0+ (1,0) [0|7] "" XXX - SG_ RrStRmndrCstSetReq : 14|3@0+ (1,0) [0|7] "" XXX - SG_ DgtlMapEffSpdLmt : 20|5@0+ (1,0) [0|31] "" XXX - SG_ DgtlMapEffSpdLmtTyp : 23|3@0+ (1,0) [0|7] "" XXX - SG_ DgtlMapVerYr : 29|6@0+ (1,0) [0|63] "" XXX - SG_ DgtlMapVerQtr : 31|2@0+ (1,0) [0|3] "" XXX - SG_ DgtlMapCndlSpdLmt : 36|5@0+ (1,0) [0|31] "" XXX - SG_ DgtlMapCndlSpdLmtTyp : 39|3@0+ (1,0) [0|7] "" XXX - -BO_ 2151751680 Haptic_Seat_Status_LS: 3 XXX - SG_ CrshAlrtDrvrSlctdType : 0|1@0+ (1,0) [0|1] "" XXX - SG_ CrshAlrtStPrsnt : 1|1@0+ (1,0) [0|1] "" XXX - SG_ HptcStVbnStat : 3|2@0+ (1,0) [0|3] "" XXX - SG_ HptcStFldIO : 4|1@0+ (1,0) [0|1] "" XXX - -BO_ 2155536384 Rear_Virtual_Bmper_Indication_LS: 1 XXX - SG_ RVBDsbldIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ RVBEnbldIO : 1|1@0+ (1,0) [0|1] "" XXX - SG_ RVBFldIO : 2|1@0+ (1,0) [0|1] "" XXX - SG_ RVBUnblIO : 3|1@0+ (1,0) [0|1] "" XXX - SG_ TnDrvRIMOffUnbIO : 4|1@0+ (1,0) [0|1] "" XXX - SG_ RevClnMtgnBrkReqAct : 5|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151481344 CSV_FSRACC_Indications_LS: 1 XXX - SG_ AutoBrkRlsIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ ShtToPrkBfExtngVehIO : 1|1@0+ (1,0) [0|1] "" XXX - SG_ HdUpDsplyUnblIO : 2|1@0+ (1,0) [0|1] "" XXX - SG_ FSRACCFrstRsmPrssIO : 3|1@0+ (1,0) [0|1] "" XXX - SG_ FrtRdrBlckdIO : 4|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151432192 ACC_Drv_Seat_Vib_Req_IO_LS: 1 XXX - SG_ ACCHptcStVbnRqSeqN : 1|2@0+ (1,0) [0|3] "" XXX - SG_ ACCHptcStVbnReq : 7|6@0+ (1,0) [0|63] "" XXX - -BO_ 2151415808 Ln_Dep_Wrn_Drv_Seat_Vib_Req_LS: 5 XXX - SG_ LDWLftHptcStRqSN : 1|2@0+ (1,0) [0|3] "" XXX - SG_ LDWLftHptcStRq : 7|6@0+ (1,0) [0|63] "" XXX - SG_ LDWRghtHptcStRqSN : 9|2@0+ (1,0) [0|3] "" XXX - SG_ LDWRghtHptcStRq : 15|6@0+ (1,0) [0|63] "" XXX - SG_ LftLnChgThrtHptStRqSN : 17|2@0+ (1,0) [0|3] "" XXX - SG_ LftLnChgThrtHptStRq : 23|6@0+ (1,0) [0|63] "Pulse" XXX - SG_ RgtLnChgThrtHptStRqSN : 25|2@0+ (1,0) [0|3] "" XXX - SG_ RgtLnChgThrtHptStRq : 31|6@0+ (1,0) [0|63] "Pulse" XXX - SG_ FrPedDetCsStAvl : 32|1@0+ (1,0) [0|1] "" XXX - SG_ FrPedDetCsCrStVal : 35|3@0+ (1,0) [0|7] "" XXX - -BO_ 2151350272 Frnt_Prk_Ast_Drv_Seat_Vib_Req_LS: 3 XXX - SG_ FPAHptcStVbnRqSeqN : 1|2@0+ (1,0) [0|3] "" XXX - SG_ FPAHptcStVbnReq : 7|6@0+ (1,0) [0|63] "" XXX - SG_ APAIconDispRq : 10|3@0+ (1,0) [0|7] "" XXX - SG_ APAIconFilPctRq : 22|7@0+ (1,0) [0|127] "" XXX - -BO_ 2151333888 Rear_Prk_Ast_Drv_Seat_Vib_Req_LS: 1 XXX - SG_ RPAHptcStVbRqSeqN : 1|2@0+ (1,0) [0|3] "" XXX - SG_ RPAHptcStVbnReq : 7|6@0+ (1,0) [0|63] "" XXX - -BO_ 2151522304 Reset_FuelLife_Request_LS: 1 XXX - SG_ FuelFltLfRstRqd : 0|1@0+ (1,0) [0|1] "" XXX - SG_ ElEngyEconAvgRstRq : 1|1@0+ (1,0) [0|1] "" XXX - SG_ TCSTmpDsblReqConf : 3|2@0+ (1,0) [0|3] "" XXX - SG_ LnchCtrlRelLnLockReqd : 4|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150629376 CV_System_Failure_LS: 1 XXX - SG_ CVSysFlrIO : 0|1@0+ (1,0) [0|1] "" XXX - -BO_ 2155929600 Diesel_Information_LS: 8 XXX - SG_ DslExFldTpWrngIndRq : 3|4@0+ (1,0) [0|15] "" XXX - SG_ DslExhFldDiagWrnIdRq : 6|3@0+ (1,0) [0|7] "" XXX - SG_ DslExhFldQlyWrngIReq : 11|4@0+ (1,0) [0|15] "" XXX - SG_ DslExhFldWrngIdRqER : 15|4@0+ (1,0) [0|15] "" XXX - SG_ DslExhFluidDistTIndcmt : 22|15@0+ (2,0) [0|65534] "km" XXX - SG_ DslExNxEmWrngIndRq : 35|4@0+ (1,0) [0|15] "" XXX - SG_ DslExFldCnWrngIndRq : 39|4@0+ (1,0) [0|15] "" XXX - SG_ DslExFldWrngVSpdLmt : 47|24@0+ (1,0) [0|0] "" XXX - SG_ DEFWVSL_S1SpdLmt : 47|8@0+ (1,0) [0|255] "km / h" XXX - SG_ DEFWVSL_S2SpdLmt : 55|8@0+ (1,0) [0|255] "km / h" XXX - SG_ DEFWVSL_S3SpdLmt : 63|8@0+ (1,0) [0|255] "km / h" XXX - -BO_ 2154741760 RSA_Status_LS: 1 XXX - SG_ RSAPrsnt : 0|1@0+ (1,0) [0|1] "" XXX - -BO_ 2154807296 Lighting_Customization_Info_3_LS: 4 XXX - SG_ AFLGPSCstCrStVal : 2|3@0+ (1,0) [0|7] "" XXX - SG_ AFLCstCrStVal : 5|3@0+ (1,0) [0|7] "" XXX - SG_ AFLGPSCstStAvl : 6|1@0+ (1,0) [0|1] "" XXX - SG_ AFLCstStAvl : 7|1@0+ (1,0) [0|1] "" XXX - SG_ AFLGPSMnu2CstStAvl : 8|1@0+ (1,0) [0|1] "" XXX - SG_ AFLMnu2CstStAvl : 9|1@0+ (1,0) [0|1] "" XXX - SG_ AFLMnu3CstStAvl : 10|1@0+ (1,0) [0|1] "" XXX - SG_ EngAutoStpNotProb : 11|1@0+ (1,0) [0|1] "" XXX - SG_ ESCMHiEleclLdReqAct : 12|1@0+ (1,0) [0|1] "" XXX - SG_ EngAutoStrtStpInfo : 17|10@0+ (1,0) [0|0] "" XXX - SG_ EASSI_StrtStpSt : 17|2@0+ (1,0) [0|3] "" XXX - SG_ EASSI_UnsdRsrvd2 : 24|1@0+ (1,0) [0|1] "" XXX - SG_ EASSI_TorqDetdIndet : 25|1@0+ (1,0) [0|1] "" XXX - SG_ EASSI_StlDetd : 26|1@0+ (1,0) [0|1] "" XXX - SG_ EASSI_TrqDetd : 27|1@0+ (1,0) [0|1] "" XXX - SG_ EASSI_FuelReqOn : 28|1@0+ (1,0) [0|1] "" XXX - SG_ EASSI_StrtTyp : 31|3@0+ (1,0) [0|7] "" XXX - -BO_ 2151079936 PDIM_Status_LS: 1 XXX - SG_ PDIMPrsnt : 0|1@0+ (1,0) [0|1] "" XXX - -BO_ 2155364352 Hybrid_Information_SuperSlow_LS: 5 XXX - SG_ SvcHybridSysIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ JmpStrtStat : 3|3@0+ (1,0) [0|7] "" XXX - SG_ HybMdDisp : 7|4@0+ (1,0) [0|15] "" XXX - SG_ CstmrUsblSOCGroup : 15|15@0+ (1,0) [0|0] "" XXX - SG_ CstmrUsblSOC : 15|8@0+ (0.39216,0) [0|100.0008] "%" XXX - SG_ CstmrUsblSOCV : 17|1@0+ (1,0) [0|1] "" XXX - SG_ BattCntrlPrcssrVDA : 16|1@0+ (1,0) [0|1] "" XXX - SG_ InstDrvEff : 31|8@0- (0.78125,0) [-100|99.21875] "%" XXX - SG_ ClntCrcFlwRtEst : 39|8@0+ (0.392157,0) [0|100.000035] "%" XXX - -BO_ 2154979328 Front_Seat_Heat_Cool_Req_LS: 1 XXX - SG_ FrntStVoltBstModReq : 0|1@0+ (1,0) [0|1] "" XXX - -BO_ 2155282432 RearSeat_HeatVent_Cool_LS: 1 XXX - SG_ RrStVoltBstModReq : 0|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151505920 VehInfoTripComputer_LS: 7 XXX - SG_ SpdCurvAdvSysEnbld : 0|1@0+ (1,0) [0|1] "" XXX - SG_ TrlrBrkDsplyAct : 1|1@0+ (1,0) [0|1] "" XXX - SG_ ACCSettingType : 3|2@0+ (1,0) [0|3] "" XXX - SG_ AutoMdSpdLmtCnfrmd : 4|1@0+ (1,0) [0|1] "" XXX - SG_ PTExPrtclFltManRgnRqd : 5|1@0+ (1,0) [0|1] "" XXX - SG_ Trp2OdomtrGroup : 6|55@0+ (1,0) [0|0] "" XXX - SG_ Trp2OdomtrV : 6|1@0+ (1,0) [0|1] "" XXX - SG_ Trp2Odomtr : 38|23@0+ (0.015625,0) [0|131071.984375] "km" XXX - SG_ Trp1OdomtrGroup : 7|32@0+ (1,0) [0|0] "" XXX - SG_ Trp1OdomtrV : 7|1@0+ (1,0) [0|1] "" XXX - SG_ Trp1Odomtr : 14|23@0+ (0.015625,0) [0|131071.984375] "km" XXX - -BO_ 2155896832 Alternative_Fuel_Information_LS: 5 XXX - SG_ FuelMdStat : 2|3@0+ (1,0) [0|7] "" XXX - SG_ AltFuelMdReqDndIO : 3|1@0+ (1,0) [0|1] "" XXX - SG_ FlLvlTank2PctGroup : 4|13@0+ (1,0) [0|0] "" XXX - SG_ FlLvlTank2PctV : 4|1@0+ (1,0) [0|1] "" XXX - SG_ FlLvlTank2Pct : 15|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ AltFuelAccWrnngAct : 5|1@0+ (1,0) [0|1] "" XXX - SG_ AltFuelLvlLo : 6|1@0+ (1,0) [0|1] "" XXX - SG_ AltFuelPHeatAct : 7|1@0+ (1,0) [0|1] "" XXX - SG_ FuelTotCapTnk2 : 19|12@0+ (0.125,0) [0|511.875] "liters" XXX - SG_ FuelAlchlCompAdptnPrg : 20|1@0+ (1,0) [0|1] "" XXX - SG_ FuelAlcoholCompGroup : 21|22@0+ (1,0) [0|0] "" XXX - SG_ FuelAlcoholCompV : 21|1@0+ (1,0) [0|1] "" XXX - SG_ FuelAlcoholComp : 39|8@0+ (0.392157,0) [0|100.000035] "%" XXX - -BO_ 2155552768 Exterior_Lock_Switch_Req_LS: 1 XXX - SG_ PsvEntCmftWndRq : 1|2@0+ (1,0) [0|3] "" XXX - -BO_ 2154496000 Rear_Closure_Soft_Top_Info_LS: 1 XXX - SG_ CmpSftTopMotBfrOpTrnkIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ TargaTopStateGroup : 2|2@0+ (1,0) [0|0] "" XXX - SG_ TargaTopState : 1|1@0+ (1,0) [0|1] "" XXX - SG_ TargaTopStateV : 2|1@0+ (1,0) [0|1] "" XXX - -BO_ 2155208704 Power_Conv_Top_Info_LS: 3 XXX - SG_ SftTpAbvWrngSpdIndOn : 0|1@0+ (1,0) [0|1] "" XXX - SG_ SftTpFlrIO : 1|1@0+ (1,0) [0|1] "" XXX - SG_ SftTpLtcIO : 2|1@0+ (1,0) [0|1] "" XXX - SG_ SftTpMnlLtchIndOn : 3|1@0+ (1,0) [0|1] "" XXX - SG_ SftTpMchnOvhtIO : 4|1@0+ (1,0) [0|1] "" XXX - SG_ SftTpRmCrgCrrIO : 5|1@0+ (1,0) [0|1] "" XXX - SG_ SftTpStrIO : 6|1@0+ (1,0) [0|1] "" XXX - SG_ SftTpTmpLwIO : 7|1@0+ (1,0) [0|1] "" XXX - SG_ SftTpTneuCvrIO : 8|1@0+ (1,0) [0|1] "" XXX - SG_ SftTpVehOvSpdIndOn : 9|1@0+ (1,0) [0|1] "" XXX - SG_ SftTpVltLwIO : 10|1@0+ (1,0) [0|1] "" XXX - SG_ CkSoftTpIO : 11|1@0+ (1,0) [0|1] "" XXX - SG_ ClsTrnkLidIO : 12|1@0+ (1,0) [0|1] "" XXX - SG_ FTUpdWndPsLmtEnbld : 13|1@0+ (1,0) [0|1] "" XXX - SG_ VltSwAtvIndOn : 14|1@0+ (1,0) [0|1] "" XXX - SG_ SftTpTrnLmpsRqd : 15|1@0+ (1,0) [0|1] "" XXX - SG_ FldngTpSt : 18|3@0+ (1,0) [0|7] "" XXX - SG_ FldngTpWndCmftRq : 20|2@0+ (1,0) [0|3] "" XXX - SG_ SftTpPlsDnSrtdIndOn : 21|1@0+ (1,0) [0|1] "" XXX - SG_ SftTpPlsDnWrngIndOn : 22|1@0+ (1,0) [0|1] "" XXX - -BO_ 2153390080 Manual_Liftgate_Control_LS: 1 XXX - SG_ RrClosOpenSwAct_2D1Group : 3|3@0+ (1,0) [0|0] "" XXX - SG_ RrClosOpenSwAct_2D1 : 1|1@0+ (1,0) [0|1] "" XXX - SG_ RrClosOpenSwAct_2D1V : 3|1@0+ (1,0) [0|1] "" XXX - -BO_ 2155175936 CruiseControlGapSwitch_LS: 1 XXX - SG_ AdptCrsGapSwAct : 1|2@0+ (1,0) [0|3] "" XXX - SG_ AdptCrsLKALDWSwAct : 2|1@0+ (1,0) [0|1] "" XXX - -BO_ 2156806144 Cellular_Network_Date_and_Time: 6 XXX - SG_ CldrDayCmpstdVal : 4|5@0+ (1,0) [0|31] "days" XXX - SG_ HrsCmpstdValGroup : 5|30@0+ (1,0) [0|0] "" XXX - SG_ HrsCmpstdValV : 5|1@0+ (1,0) [0|1] "" XXX - SG_ HrsCmpstdVal : 28|5@0+ (1,0) [0|31] "h" XXX - SG_ MinsCmpstdValGroup : 6|39@0+ (1,0) [0|0] "" XXX - SG_ MinsCmpstdValV : 6|1@0+ (1,0) [0|1] "" XXX - SG_ MinsCmpstdVal : 37|6@0+ (1,0) [0|63] "min" XXX - SG_ SecCmpstdValGroup : 7|48@0+ (1,0) [0|0] "" XXX - SG_ SecCmpstdValV : 7|1@0+ (1,0) [0|1] "" XXX - SG_ SecCmpstdVal : 45|6@0+ (1,0) [0|63] "secs" XXX - SG_ CldrMthCmpstdVal : 11|4@0+ (1,0) [0|15] "" XXX - SG_ CellNtwrkDtTmAvl : 12|1@0+ (1,0) [0|1] "" XXX - SG_ CldrYrCmpstdVal : 23|8@0+ (1,2000) [2000|2255] "year" XXX - -BO_ 2154078208 Window_Position_Status_LS: 2 XXX - SG_ DrvWndPosStat : 2|3@0+ (1,0) [0|7] "" XXX - SG_ LRWndPosStat : 5|3@0+ (1,0) [0|7] "" XXX - SG_ PsWndPosStat : 10|3@0+ (1,0) [0|7] "" XXX - SG_ RRWndPosStat : 13|3@0+ (1,0) [0|7] "" XXX - -BO_ 2159058944 ODIEvent_IPC_LS: 3 XXX - SG_ ODIEvntPkt_IPC : 5|22@0+ (1,0) [0|0] "" XXX - SG_ ODIEI_EvID : 5|6@0+ (1,0) [0|63] "" XXX - SG_ ODIEI_FUCID : 15|8@0+ (1,0) [0|255] "" XXX - SG_ ODIEI_MultiFrRetCh : 23|8@0+ (1,0) [0|255] "" XXX - -BO_ 2159042560 ODI_DynData_IPC_LS: 8 XXX - SG_ ODIDynData_IPC : 14|55@0+ (1,0) [0|0] "" XXX - SG_ ODDI_InvldData : 8|1@0+ (1,0) [0|1] "" XXX - SG_ ODDI_DataType : 14|6@0+ (1,0) [0|63] "" XXX - SG_ ODDI_FUCID : 23|8@0+ (1,0) [0|255] "" XXX - SG_ ODDI_DataId : 31|8@0+ (1,0) [0|255] "" XXX - SG_ ODDI_DataVal : 39|32@0+ (1,0) [0|4294967295] "" XXX - -BO_ 2150006784 System_Power_Mode_Pushbutton_LS: 1 XXX - SG_ SysPwrMdPshbtnActGroup : 1|2@0+ (1,0) [0|0] "" XXX - SG_ SysPwrMdPshbtnAct : 0|1@0+ (1,0) [0|1] "" XXX - SG_ SysPwrMdPshbtnActV : 1|1@0+ (1,0) [0|1] "" XXX - SG_ PEPSRunCrnkRlyDctd : 2|1@0+ (1,0) [0|1] "" XXX - -BO_ 2155216896 Road_Type_Information_LS: 6 XXX - SG_ MpDataAvlbl : 0|1@0+ (1,0) [0|1] "" XXX - SG_ BldUpArDet : 1|1@0+ (1,0) [0|1] "" XXX - SG_ SprtLnRd : 2|1@0+ (1,0) [0|1] "" XXX - SG_ CntrldAccRd : 3|1@0+ (1,0) [0|1] "" XXX - SG_ CurvAdvInd : 5|2@0+ (1,0) [0|3] "" XXX - SG_ SpdLmtPstdSpdGroup : 6|23@0+ (1,0) [0|0] "" XXX - SG_ SpdLmtPstdSpdM : 6|1@0+ (1,0) [0|1] "" XXX - SG_ SpdLmtPstdSpd : 23|8@0+ (1,0) [0|255] "" XXX - SG_ DgtlMapPstdSpdLimAsrd : 7|1@0+ (1,0) [0|1] "" XXX - SG_ FncRdClass : 10|3@0+ (1,0) [0|7] "" XXX - SG_ RdSpdCatType : 12|2@0+ (1,0) [0|3] "" XXX - SG_ LnCat : 14|2@0+ (1,0) [0|3] "" XXX - SG_ SpdLmtUnits : 15|1@0+ (1,0) [0|1] "" XXX - SG_ SpdLmtRecmndSpd : 31|8@0+ (1,0) [0|255] "" XXX - SG_ IntlStdAlph2CddCntryCd : 33|10@0+ (1,0) [0|0] "" XXX - SG_ ISA2CCC_FrstCdChr : 33|5@0+ (1,0) [0|31] "" XXX - SG_ ISA2CCC_ScndCdChr : 44|5@0+ (1,0) [0|31] "" XXX - -BO_ 2156216320 TTY_Status_LS: 1 XXX - SG_ TxtTelephoneDevPr : 0|1@0+ (1,0) [0|1] "" XXX - -BO_ 2158813184 ODIIndication_IPC_LS: 8 XXX - SG_ ODIInd_IPC : 7|64@0+ (1,0) [0|0] "" XXX - SG_ ODIIIPC_FUCID : 7|8@0+ (1,0) [0|255] "" XXX - SG_ ODIIIPC_ODIInd8 : 8|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd7 : 9|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd6 : 10|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd5 : 11|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd4 : 12|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd3 : 13|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd2 : 14|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd1 : 15|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd16 : 16|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd15 : 17|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd14 : 18|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd13 : 19|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd12 : 20|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd11 : 21|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd10 : 22|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd9 : 23|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd24 : 24|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd23 : 25|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd22 : 26|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd21 : 27|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd20 : 28|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd19 : 29|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd18 : 30|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd17 : 31|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd32 : 32|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd31 : 33|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd30 : 34|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd29 : 35|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd28 : 36|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd27 : 37|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd26 : 38|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd25 : 39|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd40 : 40|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd39 : 41|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd38 : 42|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd37 : 43|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd36 : 44|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd35 : 45|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd34 : 46|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd33 : 47|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd48 : 48|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd47 : 49|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd46 : 50|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd45 : 51|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd44 : 52|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd43 : 53|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd42 : 54|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd41 : 55|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd56 : 56|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd55 : 57|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd54 : 58|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd53 : 59|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd52 : 60|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd51 : 61|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd50 : 62|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIIPC_ODIInd49 : 63|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150277120 GPS_Geographical_Position_LS: 8 XXX - SG_ PsngSysLatGroup : 6|31@0+ (1,0) [0|0] "" XXX - SG_ PsngSysLat : 5|30@0- (1,0) [-536870912|536870911] "ms arc" XXX - SG_ PsngSysLatV : 6|1@0+ (1,0) [0|1] "" XXX - SG_ PsngSysLongGroup : 39|32@0+ (1,0) [0|0] "" XXX - SG_ PsngSysLong : 38|31@0- (1,0) [-1073741824|1073741823] "ms arc" XXX - SG_ PsngSysLongV : 39|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150285312 GPS_Elevation_and_Heading_LS: 8 XXX - SG_ PsngSysHdingGroup : 3|37@0+ (1,0) [0|0] "" XXX - SG_ PsngSysHding : 3|12@0+ (0.1,0) [0|409.5] "deg" XXX - SG_ PsngSysHdingV : 47|1@0+ (1,0) [0|1] "" XXX - SG_ PsngSysDilPrcsGroup : 4|29@0+ (1,0) [0|0] "" XXX - SG_ PsngSysDilPrcsV : 4|1@0+ (1,0) [0|1] "" XXX - SG_ PsngSysDilPrcs : 17|10@0+ (0.1,0) [0|102.3] "" XXX - SG_ PsngSysCalcSpdGroup : 39|10@0+ (1,0) [0|0] "" XXX - SG_ PsngSysCalcSpd : 39|8@0+ (1,0) [0|255] "km / h" XXX - SG_ PsngSysCalcSpdV : 46|1@0+ (1,0) [0|1] "" XXX - SG_ PsngSysElvtnGroup : 45|22@0+ (1,0) [0|0] "" XXX - SG_ PsngSysElvtn : 44|21@0+ (1,-100000) [-100000|1997151] "cm" XXX - SG_ PsngSysElvtnV : 45|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151890944 Telematics_Indication_Request_LS: 4 XXX - SG_ TlmtcsIndCntrlReq : 15|24@0+ (1,0) [0|0] "" XXX - SG_ TICR_Ind1Cnt : 11|4@0+ (1,0) [0|15] "" XXX - SG_ TICR_Ind1 : 13|2@0+ (1,0) [0|3] "" XXX - SG_ TICR_Ind1Req : 15|2@0+ (1,0) [0|3] "" XXX - SG_ TICR_Ind1FlshRtOff : 23|8@0+ (10,0) [0|2550] "ms" XXX - SG_ TICR_Ind1FlshRtOn : 31|8@0+ (10,0) [0|2550] "ms" XXX - -BO_ 2151251968 Telematics_Indication_Control_LS: 4 XXX - SG_ TlmtcsIndCntrlStat : 12|21@0+ (1,0) [0|0] "" XXX - SG_ TICS_Ind1V : 8|1@0+ (1,0) [0|1] "" XXX - SG_ TICS_Ind1 : 10|2@0+ (1,0) [0|3] "" XXX - SG_ TICS_Ind1Stat : 12|2@0+ (1,0) [0|3] "" XXX - SG_ TICS_Ind1FlshRtOffSt : 23|8@0+ (10,0) [0|2550] "ms" XXX - SG_ TICS_Ind1FlshRtOnSt : 31|8@0+ (10,0) [0|2550] "ms" XXX - -BO_ 2155495424 Remote_Start_Seat_Request_LS: 1 XXX - SG_ RmStrCldStEnReq : 0|1@0+ (1,0) [0|1] "" XXX - SG_ RmStrHtdStEnRq : 1|1@0+ (1,0) [0|1] "" XXX - -BO_ 2149990400 HS_Indications_Fast_LS: 8 XXX - SG_ ABSIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ StpOnBrkToRelPBIndOn : 1|1@0+ (1,0) [0|1] "" XXX - SG_ TrlrBrkngVDA : 2|1@0+ (1,0) [0|1] "" XXX - SG_ DrvThrtlOvrdIO : 3|1@0+ (1,0) [0|1] "" XXX - SG_ TreInfMonSysRstPrfmd : 4|1@0+ (1,0) [0|1] "" XXX - SG_ ACCHdwayStngIO : 5|1@0+ (1,0) [0|1] "" XXX - SG_ ACCDrvrSeltdSpdIO : 6|1@0+ (1,0) [0|1] "" XXX - SG_ TrlrWiringFltIO : 7|1@0+ (1,0) [0|1] "" XXX - SG_ AdvHlmpsVDA : 9|1@0+ (1,0) [0|1] "" XXX - SG_ SADmpVDA : 10|1@0+ (1,0) [0|1] "" XXX - SG_ ScndryAxleVDA : 11|1@0+ (1,0) [0|1] "" XXX - SG_ SrvTrlrBrkngSysIO : 12|1@0+ (1,0) [0|1] "" XXX - SG_ TrlrBrkngGainSetIO : 13|1@0+ (1,0) [0|1] "" XXX - SG_ TrlrCnctdIO : 14|1@0+ (1,0) [0|1] "" XXX - SG_ ChkTrlrIO : 15|1@0+ (1,0) [0|1] "" XXX - SG_ TrlrBrkngFrcOtpt : 23|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ TrlrBrkngGainSet : 31|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ TrlrHtchSwAtv_ITBC : 32|1@0+ (1,0) [0|1] "" XXX - SG_ TransNtrlCntrlMdStat : 34|2@0+ (1,0) [0|3] "" XXX - SG_ MotStBltFldIO : 35|1@0+ (1,0) [0|1] "" XXX - SG_ MotStBltUnblIO : 36|1@0+ (1,0) [0|1] "" XXX - SG_ TrnsfrCsRngShfSpdLmt : 47|8@0+ (1,0) [0|255] "km / h" XXX - SG_ InstFuelConsmpRate : 51|12@0+ (0.025,0) [0|102.375] "ltrs/hr" XXX - SG_ SecAxlOperMod : 55|4@0+ (1,0) [0|15] "" XXX - -BO_ 2155380736 HS_Indications_SuperSlow_LS: 6 XXX - SG_ VehOvrLdIndOn : 0|1@0+ (1,0) [0|1] "" XXX - SG_ SrvLevSysIO : 1|1@0+ (1,0) [0|1] "" XXX - SG_ HdLtLvlFlrIO : 2|1@0+ (1,0) [0|1] "" XXX - SG_ RrLevVDA : 3|1@0+ (1,0) [0|1] "" XXX - SG_ AirCndOffIO : 4|1@0+ (1,0) [0|1] "" XXX - SG_ EngOilHotIO : 5|1@0+ (1,0) [0|1] "" XXX - SG_ PTExPrtclFltrWrnIO : 6|1@0+ (1,0) [0|1] "" XXX - SG_ DslGlwPlgIO : 7|1@0+ (1,0) [0|1] "" XXX - SG_ EngHotFuelEnrchmntIO : 8|1@0+ (1,0) [0|1] "" XXX - SG_ EngOilChngIO : 9|1@0+ (1,0) [0|1] "" XXX - SG_ EngOilLvlLwIO : 10|1@0+ (1,0) [0|1] "" XXX - SG_ EngOilPrsLwIO : 11|1@0+ (1,0) [0|1] "" XXX - SG_ EngWtrInFlIO : 12|1@0+ (1,0) [0|1] "" XXX - SG_ RdcdPwrIO : 13|1@0+ (1,0) [0|1] "" XXX - SG_ CkFlFilrCapIO : 14|1@0+ (1,0) [0|1] "" XXX - SG_ EngHt_StpEngIO : 15|1@0+ (1,0) [0|1] "" XXX - SG_ StrAsstRdcdLvl2IO : 16|1@0+ (1,0) [0|1] "" XXX - SG_ PwrStrIO : 17|1@0+ (1,0) [0|1] "" XXX - SG_ PTExPrtclFltrWrn2IO : 18|1@0+ (1,0) [0|1] "" XXX - SG_ AdvFrntLghtSysIndRq : 21|3@0+ (1,0) [0|7] "" XXX - SG_ StrngAsstRdcdIO : 22|1@0+ (1,0) [0|1] "" XXX - SG_ StrAsstRdcdLvl3IO : 23|1@0+ (1,0) [0|1] "" XXX - SG_ PwrPckAirInTempFlt : 31|8@0+ (1,-40) [-40|215] "deg C" XXX - SG_ PwrPkFnSpd : 39|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ ARSFlrIO : 40|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150498304 Analog_Values_Slow_LS: 8 XXX - SG_ EngCltTmpGroup : 0|57@0+ (1,0) [0|0] "" XXX - SG_ EngCltTmpV : 0|1@0+ (1,0) [0|1] "" XXX - SG_ EngCltTmp : 63|8@0+ (1,-40) [-40|215] "deg C" XXX - SG_ EngIntAirTmpGroup : 1|50@0+ (1,0) [0|0] "" XXX - SG_ EngIntAirTmpV : 1|1@0+ (1,0) [0|1] "" XXX - SG_ EngIntAirTmp : 55|8@0+ (1,-40) [-40|215] "deg C" XXX - SG_ EngOilTmpGroup : 2|43@0+ (1,0) [0|0] "" XXX - SG_ EngOilTmpV : 2|1@0+ (1,0) [0|1] "" XXX - SG_ EngOilTmp : 47|8@0+ (1,-40) [-40|215] "deg C" XXX - SG_ OAT_PT_EstGroup : 4|37@0+ (1,0) [0|0] "" XXX - SG_ OAT_PT_EstV : 3|1@0+ (1,0) [0|1] "" XXX - SG_ OAT_PT_EstM : 4|1@0+ (1,0) [0|1] "" XXX - SG_ OAT_PT_Est : 39|8@0+ (0.5,-40) [-40|87.5] "deg C" XXX - SG_ TrnOilTmpGroup : 5|30@0+ (1,0) [0|0] "" XXX - SG_ TrnOilTmpV : 5|1@0+ (1,0) [0|1] "" XXX - SG_ TrnOilTmp : 31|8@0+ (1,-40) [-40|215] "deg C" XXX - SG_ BarPrsAbsGroup : 6|23@0+ (1,0) [0|0] "" XXX - SG_ BarPrsAbsV : 6|1@0+ (1,0) [0|1] "" XXX - SG_ BarPrsAbs : 23|8@0+ (0.5,0) [0|127.5] "kPa" XXX - SG_ EngOilPrsGroup : 7|16@0+ (1,0) [0|0] "" XXX - SG_ EngOilPrsV : 7|1@0+ (1,0) [0|1] "" XXX - SG_ EngOilPrs : 15|8@0+ (4,0) [0|1020] "kPa" XXX - -BO_ 2151047168 HUD_Status_LS: 1 XXX - SG_ HUDActv : 0|1@0+ (1,0) [0|1] "" XXX - SG_ HdUpDspAnmtStat : 3|3@0+ (1,0) [0|7] "" XXX - -BO_ 2155331584 Wheel_Pulses_LS: 4 XXX - SG_ WhlPlsPerRevDrvn : 6|7@0+ (1,0) [0|127] "" XXX - SG_ WhlPlsPerRevNonDrvn : 14|7@0+ (1,0) [0|127] "" XXX - SG_ WhlRotStatTmstmpRes : 18|11@0+ (0.002,0) [0|4.094] "uSec" XXX - -BO_ 2154225664 Door_Handle_Switch_Status_LS: 1 XXX - SG_ DrvDrHndleSwAtv : 0|1@0+ (1,0) [0|1] "" XXX - SG_ PasDrHndleSwAtv : 1|1@0+ (1,0) [0|1] "" XXX - SG_ RCHndleSwAtv : 2|1@0+ (1,0) [0|1] "" XXX - SG_ RRDrHndleSwAtv : 3|1@0+ (1,0) [0|1] "" XXX - SG_ RLDrHndleSwAtv : 4|1@0+ (1,0) [0|1] "" XXX - -BO_ 2149900288 Telematics_Contol_LS: 3 XXX - SG_ EnhSrvRClsRlsRq : 1|1@0+ (1,0) [0|1] "" XXX - SG_ EnhSrvVisAlRq : 3|2@0+ (1,0) [0|3] "" XXX - SG_ EnhSrvAudAlRq : 5|2@0+ (1,0) [0|3] "" XXX - SG_ EnhSrvRmStrtRq : 7|2@0+ (1,0) [0|3] "" XXX - SG_ EnhSrvLckRq : 10|3@0+ (1,0) [0|7] "" XXX - SG_ BTTethrngPrngReq : 14|4@0+ (1,0) [0|15] "" XXX - SG_ EnhSvVehTopSpdLim : 23|8@0+ (2,0) [0|510] "km / h" XXX - -BO_ 2159001600 ODIEnumDynamicData_IPC_LS: 8 XXX - SG_ ODIEnmDynData_IPC : 5|62@0+ (1,0) [0|0] "" XXX - SG_ ODIEDDIPC_Data2Value : 2|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDIPC_Data1Value : 5|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDIPC_Data5Value : 9|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDIPC_Data4Value : 12|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDIPC_Data3Value : 15|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDIPC_Data8Value : 16|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDIPC_Data7Value : 19|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDIPC_Data6Value : 22|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDIPC_Data10Value : 26|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDIPC_Data9Value : 29|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDIPC_Data13Value : 33|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDIPC_Data12Value : 36|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDIPC_Data11Value : 39|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDIPC_Data16Value : 40|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDIPC_Data15Value : 43|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDIPC_Data14Value : 46|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDIPC_Data18Value : 50|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDIPC_Data17Value : 53|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDIPC_FUCID : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 2158993408 ODIEnumDynamicData_CntrStack_LS: 8 XXX - SG_ ODIEnmDynData_CenterStack : 5|62@0+ (1,0) [0|0] "" XXX - SG_ ODIEDDCS_Data2Value : 2|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDCS_Data1Value : 5|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDCS_Data5Value : 9|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDCS_Data4Value : 12|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDCS_Data3Value : 15|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDCS_Data8Value : 16|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDCS_Data7Value : 19|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDCS_Data6Value : 22|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDCS_Data10Value : 26|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDCS_Data9Value : 29|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDCS_Data13Value : 33|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDCS_Data12Value : 36|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDCS_Data11Value : 39|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDCS_Data16Value : 40|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDCS_Data15Value : 43|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDCS_Data14Value : 46|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDCS_Data18Value : 50|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDCS_Data17Value : 53|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDDCS_FUCID : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 2154708992 Audio_Master_Source_Status_LS: 2 XXX - SG_ AudSrcStat2 : 3|12@0+ (1,0) [0|0] "" XXX - SG_ ASS2AudSrcType : 3|5@0+ (1,0) [0|31] "" XXX - SG_ ASS2AudSrcStatCode : 11|4@0+ (1,0) [0|15] "" XXX - SG_ ASS2AudSrcChType : 14|3@0+ (1,0) [0|7] "" XXX - -BO_ 2158985216 ODIDynDataMultiReq_OTIM_LS: 8 XXX - SG_ ODIDynDataMltRq_OTIM : 5|62@0+ (1,0) [0|0] "" XXX - SG_ ODDMO_DataID2Vld : 0|1@0+ (1,0) [0|1] "" XXX - SG_ ODDMO_DataID3Vld : 1|1@0+ (1,0) [0|1] "" XXX - SG_ ODDMO_DataID4Vld : 2|1@0+ (1,0) [0|1] "" XXX - SG_ ODDMO_DataID5Vld : 3|1@0+ (1,0) [0|1] "" XXX - SG_ ODDMO_ReqType : 5|2@0+ (1,0) [0|3] "" XXX - SG_ ODDMO_FUCID : 15|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMO_DispMID : 23|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMO_DataID1 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMO_DataID2 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMO_DataID3 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMO_DataID4 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMO_DataID5 : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 2154471424 Rear_Closure_Ajar_Switch_Status: 1 XXX - SG_ RrClosAjarSwAct : 0|1@0+ (1,0) [0|1] "" XXX - SG_ RrClsrSnwLdIO : 1|1@0+ (1,0) [0|1] "" XXX - -BO_ 2159149056 ODI_TEL_2_CenterStack_LS: 8 XXX - SG_ ODI_TEL2CntrStck : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2159116288 ODI_TEL_2_AuxIP_LS: 8 XXX - SG_ ODI_TEL2AxIP : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2158796800 ODIIndication_LS: 8 XXX - SG_ ODIInd : 7|64@0+ (1,0) [0|0] "" XXX - SG_ ODII_FUCID : 7|8@0+ (1,0) [0|255] "" XXX - SG_ ODII_ODIInd8 : 8|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd7 : 9|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd6 : 10|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd5 : 11|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd4 : 12|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd3 : 13|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd2 : 14|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd1 : 15|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd16 : 16|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd15 : 17|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd14 : 18|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd13 : 19|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd12 : 20|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd11 : 21|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd10 : 22|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd9 : 23|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd24 : 24|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd23 : 25|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd22 : 26|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd21 : 27|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd20 : 28|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd19 : 29|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd18 : 30|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd17 : 31|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd32 : 32|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd31 : 33|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd30 : 34|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd29 : 35|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd28 : 36|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd27 : 37|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd26 : 38|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd25 : 39|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd40 : 40|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd39 : 41|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd38 : 42|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd37 : 43|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd36 : 44|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd35 : 45|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd34 : 46|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd33 : 47|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd48 : 48|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd47 : 49|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd46 : 50|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd45 : 51|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd44 : 52|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd43 : 53|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd42 : 54|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd41 : 55|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd56 : 56|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd55 : 57|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd54 : 58|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd53 : 59|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd52 : 60|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd51 : 61|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd50 : 62|1@0+ (1,0) [0|1] "" XXX - SG_ ODII_ODIInd49 : 63|1@0+ (1,0) [0|1] "" XXX - -BO_ 2158755840 ODIEvent_LS: 4 XXX - SG_ ODIEvntPkt : 13|22@0+ (1,0) [0|0] "" XXX - SG_ ODIE_EvID : 13|6@0+ (1,0) [0|63] "" XXX - SG_ ODIE_FUCID : 23|8@0+ (1,0) [0|255] "" XXX - SG_ ODIE_MultiFrRetCh : 31|8@0+ (1,0) [0|255] "" XXX - -BO_ 2159157248 ODI_CenterStack_2_TEL_LS: 8 XXX - SG_ ODI_CntrStck2TEL : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2153955328 Infrastructure_Timer_Status_LS: 5 XXX - SG_ EngOffTmExtRngGroup : 0|33@0+ (1,0) [0|0] "" XXX - SG_ EngOffTmExtRngV : 0|1@0+ (1,0) [0|1] "" XXX - SG_ EngOffTmExtRng : 39|8@0+ (4,0) [0|1020] "min" XXX - SG_ ElpsdTimeCntRstOcc : 1|1@0+ (1,0) [0|1] "" XXX - SG_ ElpsdTimeCnt : 15|24@0+ (1,0) [0|16777215] "min" XXX - -BO_ 2151063552 Infotainment_Operation_LS: 7 XXX - SG_ InftnOprAlwd : 0|1@0+ (1,0) [0|1] "" XXX - SG_ ValetMdAct : 1|1@0+ (1,0) [0|1] "" XXX - SG_ Frnt360CamSwAct : 2|1@0+ (1,0) [0|1] "" XXX - SG_ CamVideoICSDispAct : 3|1@0+ (1,0) [0|1] "" XXX - SG_ LRStStatDispAct : 4|1@0+ (1,0) [0|1] "" XXX - SG_ RRStStatDispAct : 5|1@0+ (1,0) [0|1] "" XXX - SG_ TrgdVidRecSwAct : 6|1@0+ (1,0) [0|1] "" XXX - SG_ RrPedDetCstStReq : 10|3@0+ (1,0) [0|7] "" XXX - SG_ IntrStopAlrtCsSetReq : 13|3@0+ (1,0) [0|7] "" XXX - SG_ ICSTchStat : 17|34@0+ (1,0) [0|0] "" XXX - SG_ ICSTS_TchPrxmty : 17|2@0+ (1,0) [0|3] "" XXX - SG_ ICSTS_X1TchCrdnt : 31|16@0+ (0.001526,0) [0|100] "" XXX - SG_ ICSTS_Y1TchCrdnt : 47|16@0+ (0.001526,0) [0|100] "" XXX - SG_ TrfRdsdInfCsStReq : 20|3@0+ (1,0) [0|7] "" XXX - SG_ CntdVehBrAltCsStReq : 23|3@0+ (1,0) [0|7] "" XXX - -BO_ 2157985792 Fob_Programming_Request_LS: 1 XXX - SG_ FobProgEvntRqd : 0|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151284736 Park_Assistant_General_Status: 1 XXX - SG_ PrkAsstClnPrkAstIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ PrkAsstDisablIO : 1|1@0+ (1,0) [0|1] "" XXX - SG_ PrkAstFld : 2|1@0+ (1,0) [0|1] "" XXX - SG_ PrkAstSnrsBlk : 3|1@0+ (1,0) [0|1] "" XXX - SG_ PrkAstSnsDistrbdIO : 4|1@0+ (1,0) [0|1] "" XXX - SG_ TnDrvPrkAstOffUnbIO : 5|1@0+ (1,0) [0|1] "" XXX - SG_ PrkAstOprtrDsrdStat_1D0 : 7|2@0+ (1,0) [0|3] "" XXX - -BO_ 2159099904 ODI_DAB_2_AuxIP_LS: 8 XXX - SG_ ODI_DAB2AxIP : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2159067136 ODI_DAB_2_IPC_LS: 8 XXX - SG_ ODI_DAB2IPC : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2159206400 ODI_AuxIP_2_IPC_LS: 8 XXX - SG_ ODI_AxIP2IPC : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2159198208 ODI_IPC_2_AuxIP_LS: 8 XXX - SG_ ODI_IPC2AxIP : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2159190016 ODI_AuxIP_2_CenterStack_LS: 8 XXX - SG_ ODI_AxIP2CntrStck : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2159181824 ODI_CenterStack_2_AuxIP_LS: 8 XXX - SG_ ODI_CntrStck2AxIP : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2159173632 ODI_IPC_2_CenterStack_LS: 8 XXX - SG_ ODI_IPC2CntrStck : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2159165440 ODI_CenterStack_2_IPC_LS: 8 XXX - SG_ ODI_CntrStck2IPC : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2159108096 ODI_AuxIP_2_DAB_LS: 8 XXX - SG_ ODI_AxIP2DAB : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2159075328 ODI_IPC_2_DAB_LS: 8 XXX - SG_ ODI_IPC2DAB : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2151718912 Chime_Active: 1 XXX - SG_ ChmAct : 0|1@0+ (1,0) [0|1] "" XXX - SG_ ChmVolSt : 2|2@0+ (1,0) [0|3] "" XXX - -BO_ 2155479040 Customization_Setting_Request_LS: 5 XXX - SG_ DrvlnCustStngReq : 2|3@0+ (1,0) [0|7] "" XXX - SG_ RstrCustFctrDef : 3|1@0+ (1,0) [0|1] "" XXX - SG_ PedFrndlyAlrtCsStReq : 6|3@0+ (1,0) [0|7] "" XXX - SG_ SusCustStngReq : 10|3@0+ (1,0) [0|7] "" XXX - SG_ StrCustStngReq : 13|3@0+ (1,0) [0|7] "" XXX - SG_ ElvtdIdlCstStReq : 15|2@0+ (1,0) [0|3] "" XXX - SG_ SndPerfMdCsStRq : 18|3@0+ (1,0) [0|7] "" XXX - SG_ DispPerfMdCsStRq : 21|3@0+ (1,0) [0|7] "" XXX - SG_ ACCPerfMdCsStReq : 26|3@0+ (1,0) [0|7] "" XXX - SG_ DrvrStPerfMdCsStReq : 29|3@0+ (1,0) [0|7] "" XXX - SG_ PsngStPerfMdCsStReq : 34|3@0+ (1,0) [0|7] "" XXX - SG_ DrvStyPerfMdCsStReq : 37|3@0+ (1,0) [0|7] "" XXX - -BO_ 2151383040 Reset_TP_request_LS: 1 XXX - SG_ TreInfMonSysRstReq : 0|1@0+ (1,0) [0|1] "" XXX - -BO_ 2155421696 Passive_Entry_Challenge_LS: 5 XXX - SG_ PsvEntChlng : 7|32@0+ (1,0) [0|4294967295] "passwrd" XXX - SG_ ServKylsStSysIO : 32|1@0+ (1,0) [0|1] "" XXX - SG_ PsvEntApprchDtcd : 33|1@0+ (1,0) [0|1] "" XXX - SG_ PsvEntAprchDrctn : 36|3@0+ (1,0) [0|7] "" XXX - SG_ PsvEntApprchCnfgReq : 39|3@0+ (1,0) [0|7] "" XXX - -BO_ 2155413504 Drv_Dr_Key_Cyl_Status_LS: 3 XXX - SG_ DrvrDrKeyCylUlkSwActGroup : 1|2@0+ (1,0) [0|0] "" XXX - SG_ DrvrDrKeyCylUlkSwAct : 0|1@0+ (1,0) [0|1] "" XXX - SG_ DrvrDrKeyCylUlkSwActV : 1|1@0+ (1,0) [0|1] "" XXX - SG_ PsvLckngReqd : 2|1@0+ (1,0) [0|1] "" XXX - SG_ PsvApprchVehId : 15|16@0+ (1,0) [0|65535] "" XXX - -BO_ 2159026176 ODIDynamicData_LS: 8 XXX - SG_ ODIDynData : 14|55@0+ (1,0) [0|0] "" XXX - SG_ ODD_InvldData : 8|1@0+ (1,0) [0|1] "" XXX - SG_ ODD_DataType : 14|6@0+ (1,0) [0|63] "" XXX - SG_ ODD_FUCID : 23|8@0+ (1,0) [0|255] "" XXX - SG_ ODD_DataId : 31|8@0+ (1,0) [0|255] "" XXX - SG_ ODD_DataVal : 39|32@0+ (1,0) [0|4294967295] "" XXX - -BO_ 2158936064 ODIEnumDynamicData_LS: 8 XXX - SG_ ODIEnmDynData : 5|62@0+ (1,0) [0|0] "" XXX - SG_ ODIEDD_Data2Value : 2|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDD_Data1Value : 5|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDD_Data5Value : 9|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDD_Data4Value : 12|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDD_Data3Value : 15|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDD_Data8Value : 16|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDD_Data7Value : 19|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDD_Data6Value : 22|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDD_Data10Value : 26|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDD_Data9Value : 29|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDD_Data13Value : 33|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDD_Data12Value : 36|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDD_Data11Value : 39|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDD_Data16Value : 40|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDD_Data15Value : 43|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDD_Data14Value : 46|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDD_Data18Value : 50|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDD_Data17Value : 53|3@0+ (1,0) [0|7] "" XXX - SG_ ODIEDD_FUCID : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 2158845952 ODIAction_CntrStack_LS: 8 XXX - SG_ ODIActn_CntrStck : 5|62@0+ (1,0) [0|0] "" XXX - SG_ ODIAC_DaTy : 5|6@0+ (1,0) [0|63] "" XXX - SG_ ODIAC_FUCID : 15|8@0+ (1,0) [0|255] "" XXX - SG_ ODIAC_ActnID : 23|8@0+ (1,0) [0|255] "" XXX - SG_ ODIAC_DspMID : 31|8@0+ (1,0) [0|255] "" XXX - SG_ ODIAC_ActnVal : 39|32@0+ (1,0) [0|4294967295] "" XXX - -BO_ 2158886912 ODIDynDataListRequest_IPC_LS: 8 XXX - SG_ ODIDynDataLstRq_IPC : 7|64@0+ (1,0) [0|0] "" XXX - SG_ ODDLI_FUCID : 7|8@0+ (1,0) [0|255] "" XXX - SG_ ODDLI_DataId : 15|8@0+ (1,0) [0|255] "" XXX - SG_ ODDLI_DspMID : 23|8@0+ (1,0) [0|255] "" XXX - SG_ ODDLI_ReqDir : 24|1@0+ (1,0) [0|1] "" XXX - SG_ ODDLI_NmEntries : 31|7@0+ (1,0) [0|127] "" XXX - SG_ ODDLI_Idx : 39|16@0+ (1,0) [0|65535] "" XXX - SG_ ODDLI_SubIdReqM : 51|12@0+ (1,0) [0|4095] "" XXX - SG_ ODDLI_WrpArnd : 52|1@0+ (1,0) [0|1] "" XXX - SG_ ODDLI_BckgndFlag : 53|1@0+ (1,0) [0|1] "" XXX - SG_ ODDLI_ReqType : 55|2@0+ (1,0) [0|3] "" XXX - -BO_ 2151366656 Man_Prk_Brk_LS: 1 XXX - SG_ RrAxlLckIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ FrntAxlLckIO : 1|1@0+ (1,0) [0|1] "" XXX - SG_ PrkBrkSwAtv : 2|1@0+ (1,0) [0|1] "" XXX - SG_ AxlLcksServIO : 3|1@0+ (1,0) [0|1] "" XXX - SG_ AxlLckUnavailIndReq : 6|3@0+ (1,0) [0|7] "" XXX - SG_ AxlLcksVDA : 7|1@0+ (1,0) [0|1] "" XXX - -BO_ 2149842944 Vehicle_Stability_LS: 8 XXX - SG_ IMUProtLonAccGroup : 2|11@0+ (1,0) [0|0] "" XXX - SG_ IMUProtLonAcc : 1|10@0- (0.03,0) [-15.36|15.33] "m/s^2" XXX - SG_ IMUProtLonAccV : 2|1@0+ (1,0) [0|1] "" XXX - SG_ TCSysAtv : 3|1@0+ (1,0) [0|1] "" XXX - SG_ BrkSysAutBrkFld : 4|1@0+ (1,0) [0|1] "" XXX - SG_ VSEAct : 5|1@0+ (1,0) [0|1] "" XXX - SG_ StrWhAngGroup : 6|47@0+ (1,0) [0|0] "" XXX - SG_ StrWhAngV : 6|1@0+ (1,0) [0|1] "" XXX - SG_ StrWhAng : 39|16@0- (0.0625,0) [-2048|2047.9375] "deg" XXX - SG_ StWhAnVDA : 7|1@0+ (1,0) [0|1] "" XXX - SG_ VehStabEnhmntStat : 18|3@0+ (1,0) [0|7] "" XXX - SG_ VehStabEnhmntMd : 21|3@0+ (1,0) [0|7] "" XXX - SG_ StrWhlAngSenCalStat : 23|2@0+ (1,0) [0|3] "" XXX - SG_ TCSysOpMd : 26|3@0+ (1,0) [0|7] "" XXX - SG_ TCSysOpStat : 29|3@0+ (1,0) [0|7] "" XXX - SG_ VSELatAccGroup : 52|13@0+ (1,0) [0|0] "" XXX - SG_ VSELatAcc : 51|12@0- (0.015625,0) [-32|31.984375] "m/s^2" XXX - SG_ VSELatAccV : 52|1@0+ (1,0) [0|1] "" XXX - SG_ AdptDrvrSeatStng : 55|3@0+ (1,0) [0|7] "" XXX - -BO_ 2159132672 ODIAction_RearSeat_LS: 8 XXX - SG_ ODIActn_RSD : 5|62@0+ (1,0) [0|0] "" XXX - SG_ ODIAR_DaTy : 5|6@0+ (1,0) [0|63] "" XXX - SG_ ODIAR_FUCID : 15|8@0+ (1,0) [0|255] "" XXX - SG_ ODIAR_ActnID : 23|8@0+ (1,0) [0|255] "" XXX - SG_ ODIAR_DspMID : 31|8@0+ (1,0) [0|255] "" XXX - SG_ ODIAR_ActnVal : 39|32@0+ (1,0) [0|4294967295] "" XXX - -BO_ 2158968832 ODI_RearSeat_2_Centerstack_LS: 8 XXX - SG_ ODI_RSD2CntrStck : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2158960640 ODIIndication_Centerstack_LS: 8 XXX - SG_ ODIInd_CntrStck : 7|64@0+ (1,0) [0|0] "" XXX - SG_ ODIIC_FUCID : 7|8@0+ (1,0) [0|255] "" XXX - SG_ ODIIC_ODIInd8 : 8|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd7 : 9|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd6 : 10|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd5 : 11|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd4 : 12|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd3 : 13|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd2 : 14|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd1 : 15|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd16 : 16|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd15 : 17|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd14 : 18|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd13 : 19|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd12 : 20|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd11 : 21|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd10 : 22|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd9 : 23|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd24 : 24|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd23 : 25|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd22 : 26|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd21 : 27|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd20 : 28|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd19 : 29|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd18 : 30|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd17 : 31|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd32 : 32|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd31 : 33|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd30 : 34|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd29 : 35|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd28 : 36|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd27 : 37|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd26 : 38|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd25 : 39|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd40 : 40|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd39 : 41|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd38 : 42|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd37 : 43|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd36 : 44|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd35 : 45|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd34 : 46|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd33 : 47|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd48 : 48|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd47 : 49|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd46 : 50|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd45 : 51|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd44 : 52|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd43 : 53|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd42 : 54|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd41 : 55|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd56 : 56|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd55 : 57|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd54 : 58|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd53 : 59|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd52 : 60|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd51 : 61|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd50 : 62|1@0+ (1,0) [0|1] "" XXX - SG_ ODIIC_ODIInd49 : 63|1@0+ (1,0) [0|1] "" XXX - -BO_ 2158977024 ODIEvent_Centerstack_LS: 4 XXX - SG_ ODIEvntPkt_CntrStck : 13|22@0+ (1,0) [0|0] "" XXX - SG_ ODIEC_EvID : 13|6@0+ (1,0) [0|63] "" XXX - SG_ ODIEC_FUCID : 23|8@0+ (1,0) [0|255] "" XXX - SG_ ODIEC_MultiFrRetCh : 31|8@0+ (1,0) [0|255] "" XXX - -BO_ 2158952448 ODIDynDataMultiReq_RearSeat_LS: 8 XXX - SG_ ODIDynDataMltRq_RSD : 5|62@0+ (1,0) [0|0] "" XXX - SG_ ODDMR_DataID2Vld : 0|1@0+ (1,0) [0|1] "" XXX - SG_ ODDMR_DataID3Vld : 1|1@0+ (1,0) [0|1] "" XXX - SG_ ODDMR_DataID4Vld : 2|1@0+ (1,0) [0|1] "" XXX - SG_ ODDMR_DataID5Vld : 3|1@0+ (1,0) [0|1] "" XXX - SG_ ODDMR_ReqType : 5|2@0+ (1,0) [0|3] "" XXX - SG_ ODDMR_FUCID : 15|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMR_DispMID : 23|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMR_DataID1 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMR_DataID2 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMR_DataID3 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMR_DataID4 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMR_DataID5 : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 2158944256 ODIDynDataListReq_RearSeat_LS: 8 XXX - SG_ ODIDynDataLstRq_RSD : 7|64@0+ (1,0) [0|0] "" XXX - SG_ ODDLR_FUCID : 7|8@0+ (1,0) [0|255] "" XXX - SG_ ODDLR_DataId : 15|8@0+ (1,0) [0|255] "" XXX - SG_ ODDLR_DspMID : 23|8@0+ (1,0) [0|255] "" XXX - SG_ ODDLR_ReqDir : 24|1@0+ (1,0) [0|1] "" XXX - SG_ ODDLR_NmEntries : 31|7@0+ (1,0) [0|127] "" XXX - SG_ ODDLR_Idx : 39|16@0+ (1,0) [0|65535] "" XXX - SG_ ODDLR_SubIdReqM : 51|12@0+ (1,0) [0|4095] "" XXX - SG_ ODDLR_WrpArnd : 52|1@0+ (1,0) [0|1] "" XXX - SG_ ODDLR_BckgndFlag : 53|1@0+ (1,0) [0|1] "" XXX - SG_ ODDLR_ReqType : 55|2@0+ (1,0) [0|3] "" XXX - -BO_ 2158927872 ODI_DynData_CenterStack_LS: 8 XXX - SG_ ODIDynData_CntrStck : 14|55@0+ (1,0) [0|0] "" XXX - SG_ ODDC_InvldData : 8|1@0+ (1,0) [0|1] "" XXX - SG_ ODDC_DataType : 14|6@0+ (1,0) [0|63] "" XXX - SG_ ODDC_FUCID : 23|8@0+ (1,0) [0|255] "" XXX - SG_ ODDC_DataId : 31|8@0+ (1,0) [0|255] "" XXX - SG_ ODDC_DataVal : 39|32@0+ (1,0) [0|4294967295] "" XXX - -BO_ 2158895104 ODI_CenterStack_2_RearSeat_LS: 8 XXX - SG_ ODI_CntrStck2RSD : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2152038400 Infomatics_Response_Payload_LS: 8 XXX - SG_ InfMdRspPld : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2152022016 Infomatics_Metadata_Response_LS: 7 XXX - SG_ InfMdRspCmplt : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ InfMdRspInf : 23|16@0+ (1,0) [0|65535] "" XXX - SG_ InfMdStRsp : 35|4@0+ (1,0) [0|15] "" XXX - SG_ AudSelctdSrcReq : 44|5@0+ (1,0) [0|31] "" XXX - SG_ AudSysVolSetCtrl : 55|8@0+ (1,0) [0|0] "" XXX - SG_ ASVSC_ReqEnbld : 48|1@0+ (1,0) [0|1] "" XXX - SG_ ASVSC_VolReq : 55|7@0+ (0.787402,0) [0|100.000054] "" XXX - -BO_ 2152005632 Infomatics_Request_Payload_LS: 8 XXX - SG_ InfMdRqstPld : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2151989248 Infomatics_Metadata_Request_LS: 5 XXX - SG_ InfMdRqstCmplt : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ InfMdRqstInt : 23|16@0+ (1,0) [0|65535] "" XXX - SG_ InfMdStReq : 35|4@0+ (1,0) [0|15] "" XXX - -BO_ 2151972864 Fuel_Level_Status_LS: 4 XXX - SG_ FuelLvlLwIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ LnchCtrlMdReq : 2|2@0+ (1,0) [0|3] "" XXX - SG_ LnchCtrlWhlSlpReq : 7|5@0+ (1,0) [0|31] "" XXX - SG_ VehFuelRngCalcGroup : 9|18@0+ (1,0) [0|0] "" XXX - SG_ VehFuelRngCalc : 8|17@0+ (0.015625,0) [0|2047.984375] "km" XXX - SG_ VehFuelRngCalcV : 9|1@0+ (1,0) [0|1] "" XXX - SG_ LnchCtrlEngRPMReq : 15|6@0+ (1,0) [0|63] "" XXX - -BO_ 2154528768 Wheel_Grnd_Velocity_LS: 8 XXX - SG_ WhlGrndVlctyLftDrvnGroup : 6|15@0+ (1,0) [0|0] "" XXX - SG_ WhlGrndVlctyLftDrvn : 5|14@0+ (0.03125,0) [0|511.96875] "km / h" XXX - SG_ WhlGrndVlctyLftDrvnV : 6|1@0+ (1,0) [0|1] "" XXX - SG_ WhlGrndVlctyLftNnDrvnGroup : 22|15@0+ (1,0) [0|0] "" XXX - SG_ WhlGrndVlctyLftNnDrvn : 21|14@0+ (0.03125,0) [0|511.96875] "km / h" XXX - SG_ WhlGrndVlctyLftNnDrvnV : 22|1@0+ (1,0) [0|1] "" XXX - SG_ WhlGrndVlctyRtDrvnGroup : 38|15@0+ (1,0) [0|0] "" XXX - SG_ WhlGrndVlctyRtDrvn : 37|14@0+ (0.03125,0) [0|511.96875] "km / h" XXX - SG_ WhlGrndVlctyRtDrvnV : 38|1@0+ (1,0) [0|1] "" XXX - SG_ WhlGrndVlctyRtNnDrvnGroup : 54|15@0+ (1,0) [0|0] "" XXX - SG_ WhlGrndVlctyRtNnDrvn : 53|14@0+ (0.03125,0) [0|511.96875] "km / h" XXX - SG_ WhlGrndVlctyRtNnDrvnV : 54|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150916096 Park_Heater_Info_LS: 4 XXX - SG_ PrkHtrAtv : 0|1@0+ (1,0) [0|1] "" XXX - SG_ ClntCircPmpAct : 1|1@0+ (1,0) [0|1] "" XXX - SG_ PrkHtrCoolntTempGroup : 2|11@0+ (1,0) [0|0] "" XXX - SG_ PrkHtrCoolntTempV : 2|1@0+ (1,0) [0|1] "" XXX - SG_ PrkHtrCoolntTemp : 15|8@0+ (1,-40) [-40|215] "deg C" XXX - SG_ PrkHtrFlCsmdRlCntRsOc : 3|1@0+ (1,0) [0|1] "" XXX - SG_ PrkHtrFlCnsmdRolCntGroup : 4|29@0+ (1,0) [0|0] "" XXX - SG_ PrkHtrFlCnsmdRolCntV : 4|1@0+ (1,0) [0|1] "" XXX - SG_ PrkHtrFlCnsmdRolCnt : 23|16@0+ (3.05176E-006,0) [0|0.1999970916] "liters" XXX - SG_ PrkHtrPrhtAch : 5|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150367232 Immobilizer_Identifier_LS: 5 XXX - SG_ ImoId : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ LrnEnvId : 23|16@0+ (1,0) [0|65535] "" XXX - SG_ LrnEnvIdSt : 32|1@0+ (1,0) [0|1] "" XXX - SG_ ImoIdSt : 33|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150621184 Keyless_Start_Auth_LS: 1 XXX - SG_ KylsStrAuthRslt : 7|8@0+ (1,0) [0|0] "" XXX - SG_ KSARUID8 : 0|1@0+ (1,0) [0|1] "" XXX - SG_ KSARUID7 : 1|1@0+ (1,0) [0|1] "" XXX - SG_ KSARUID6 : 2|1@0+ (1,0) [0|1] "" XXX - SG_ KSARUID5 : 3|1@0+ (1,0) [0|1] "" XXX - SG_ KSARUID4 : 4|1@0+ (1,0) [0|1] "" XXX - SG_ KSARUID3 : 5|1@0+ (1,0) [0|1] "" XXX - SG_ KSARUID2 : 6|1@0+ (1,0) [0|1] "" XXX - SG_ KSARUID1 : 7|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151309312 Inflatable_Restraints_Key_Id_LS: 2 XXX - SG_ InflRestId : 7|16@0+ (1,0) [0|39321] "" XXX - -BO_ 2154061824 Window_Normalized_Indication_LS: 1 XXX - SG_ PsWndNtNrmIndOn : 0|1@0+ (1,0) [0|1] "" XXX - SG_ DrWndNtNrmIndOn : 1|1@0+ (1,0) [0|1] "" XXX - SG_ RLWndNtNrmIndOn : 2|1@0+ (1,0) [0|1] "" XXX - SG_ RRWndNtNrmIndOn : 3|1@0+ (1,0) [0|1] "" XXX - SG_ RmtWndMvmntAtv : 4|1@0+ (1,0) [0|1] "" XXX - SG_ WndOprAlwd : 5|1@0+ (1,0) [0|1] "" XXX - SG_ RrDrUnlckIO : 6|1@0+ (1,0) [0|1] "" XXX - -BO_ 2154512384 Rear_Closure_Rel_Sw_Sta_LS: 1 XXX - SG_ RrClosRelSwActGroup : 1|2@0+ (1,0) [0|0] "" XXX - SG_ RrClosRelSwAct : 0|1@0+ (1,0) [0|1] "" XXX - SG_ RrClosRelSwActV : 1|1@0+ (1,0) [0|1] "" XXX - -BO_ 2155347968 HS_Indications_Slow_LS: 8 XXX - SG_ ActVbnCtrlMlfIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ PedtrnProtSysDpl : 1|1@0+ (1,0) [0|1] "" XXX - SG_ TirePrsLowIO : 2|1@0+ (1,0) [0|1] "" XXX - SG_ ACCUnavlbleDTWthrIO : 3|1@0+ (1,0) [0|1] "" XXX - SG_ EngOilStrvtnIO : 5|1@0+ (1,0) [0|1] "" XXX - SG_ SecAxlNonEmMalfIO : 6|1@0+ (1,0) [0|1] "" XXX - SG_ BrkFldLvlLwGroup : 7|4@0+ (1,0) [0|0] "" XXX - SG_ BrkFldLvlLwV : 4|1@0+ (1,0) [0|1] "" XXX - SG_ BrkFldLvlLw : 7|1@0+ (1,0) [0|1] "" XXX - SG_ ACCSnsClnRqdIO : 8|1@0+ (1,0) [0|1] "" XXX - SG_ ACCTmpUnavlbleIO : 9|1@0+ (1,0) [0|1] "" XXX - SG_ EngRecmndUpshftIO : 10|1@0+ (1,0) [0|1] "" XXX - SG_ ServAdpCrsCtrlIndOn : 11|1@0+ (1,0) [0|1] "" XXX - SG_ SrvSuspSysIO : 12|1@0+ (1,0) [0|1] "" XXX - SG_ BrkPadWrnIO : 13|1@0+ (1,0) [0|1] "" XXX - SG_ BrkSysMalFuncIndOn : 15|1@0+ (1,0) [0|1] "" XXX - SG_ EngEmsRelMalfIndReq : 18|3@0+ (1,0) [0|7] "" XXX - SG_ RrAxlMalfIO : 19|1@0+ (1,0) [0|1] "" XXX - SG_ DrShftCntrlReqDndIO : 20|1@0+ (1,0) [0|1] "" XXX - SG_ CompOvrhtIndOn : 21|1@0+ (1,0) [0|1] "" XXX - SG_ TrnsSkpShftIO : 22|1@0+ (1,0) [0|1] "" XXX - SG_ RrAxlTmpInhIO : 23|1@0+ (1,0) [0|1] "" XXX - SG_ SecAxlTmpInhIO : 24|1@0+ (1,0) [0|1] "" XXX - SG_ CPSAlrtOnlIO : 25|1@0+ (1,0) [0|1] "" XXX - SG_ EPBSysStatIndReq : 27|2@0+ (1,0) [0|3] "" XXX - SG_ EPBSysWrnIndReq : 29|2@0+ (1,0) [0|3] "" XXX - SG_ CPSFldIO : 30|1@0+ (1,0) [0|1] "" XXX - SG_ CPSOffIO : 31|1@0+ (1,0) [0|1] "" XXX - SG_ CPSUnblIO : 32|1@0+ (1,0) [0|1] "" XXX - SG_ SrvPedtrnProtSysIO : 33|1@0+ (1,0) [0|1] "" XXX - SG_ PedtrnProtSysDisbld : 34|1@0+ (1,0) [0|1] "" XXX - SG_ PedtrnProtVDA : 35|1@0+ (1,0) [0|1] "" XXX - SG_ AppCltchAutSrtIO : 36|1@0+ (1,0) [0|1] "" XXX - SG_ StBltTgtSetAvl : 37|1@0+ (1,0) [0|1] "" XXX - SG_ FourWhlDrvIndReq : 42|3@0+ (1,0) [0|7] "" XXX - SG_ EngRecDwnshftIO : 43|1@0+ (1,0) [0|1] "" XXX - SG_ StBltTgtCrtSetVal : 46|3@0+ (1,0) [0|7] "" XXX - SG_ HillDesCtrlRedVehSpIO : 47|1@0+ (1,0) [0|1] "" XXX - SG_ VehRollAngleGroup : 55|8@0+ (1,0) [0|0] "" XXX - SG_ VehRollAngle : 54|7@0+ (0.703125,-45) [-45|44.296875] "deg" XXX - SG_ VehRollAngleV : 55|1@0+ (1,0) [0|1] "" XXX - SG_ ACCPerfMdCsCrStVal : 58|3@0+ (1,0) [0|7] "" XXX - SG_ ACCPerfMdCsStAvl : 59|1@0+ (1,0) [0|1] "" XXX - SG_ DrvrStPerfMdCsCrStVal : 62|3@0+ (1,0) [0|7] "" XXX - SG_ DrvrStPerfMdCsStAvl : 63|1@0+ (1,0) [0|1] "" XXX - -BO_ 2149777408 Non_Drvn_Whl_Rot_Status_LS: 8 XXX - SG_ WhlRotStatLftNDrvn : 7|32@0+ (1,0) [0|0] "" XXX - SG_ WRSLNDWhlDistPCntr : 1|10@0+ (1,0) [0|1023] "counts" XXX - SG_ WRSLNDWhlDistVal : 2|1@0+ (1,0) [0|1] "" XXX - SG_ WRSLNDWhlRotStRst : 3|1@0+ (1,0) [0|1] "" XXX - SG_ WRSLNDSeqNum : 5|2@0+ (1,0) [0|3] "counts" XXX - SG_ WRSLNDWhlDisTpRC : 7|2@0+ (1,0) [0|3] "counts" XXX - SG_ WRSLNDWhlDistTstm : 23|16@0+ (1,0) [0|65535] "counts" XXX - SG_ WhlRotStatRghtNDrvn : 39|32@0+ (1,0) [0|0] "" XXX - SG_ WRSRNDWhlDistPCntr : 33|10@0+ (1,0) [0|1023] "counts" XXX - SG_ WRSRNDWhlDistVal : 34|1@0+ (1,0) [0|1] "" XXX - SG_ WRSRNDWhlRotStRst : 35|1@0+ (1,0) [0|1] "" XXX - SG_ WRSRNDSeqNum : 37|2@0+ (1,0) [0|3] "counts" XXX - SG_ WRSRNDWhlDisTpRC : 39|2@0+ (1,0) [0|3] "counts" XXX - SG_ WRSRNDWhlDistTstm : 55|16@0+ (1,0) [0|65535] "counts" XXX - -BO_ 2149769216 Driven_Whl_Rotational_Stat_LS: 8 XXX - SG_ WhlRotatStatLftDrvn : 7|32@0+ (1,0) [0|0] "" XXX - SG_ WRSLDWhlDistPlsCntr : 1|10@0+ (1,0) [0|1023] "counts" XXX - SG_ WRSLDWhlDistVal : 2|1@0+ (1,0) [0|1] "" XXX - SG_ WRSLDWhlRotStatRst : 3|1@0+ (1,0) [0|1] "" XXX - SG_ WRSLDSeqNum : 5|2@0+ (1,0) [0|3] "counts" XXX - SG_ WRSLDWhlDisTpRC : 7|2@0+ (1,0) [0|3] "counts" XXX - SG_ WRSLDWhlDistTmstm : 23|16@0+ (1,0) [0|65535] "counts" XXX - SG_ WhlRotatStatRtDrvn : 39|32@0+ (1,0) [0|0] "" XXX - SG_ WRSRDWhlDistPlsCntr : 33|10@0+ (1,0) [0|1023] "counts" XXX - SG_ WRSRDWhlDistVal : 34|1@0+ (1,0) [0|1] "" XXX - SG_ WRSRDWhlRotStatRst : 35|1@0+ (1,0) [0|1] "" XXX - SG_ WRSRDSeqNum : 37|2@0+ (1,0) [0|3] "counts" XXX - SG_ WRSRDWhlDisTpRC : 39|2@0+ (1,0) [0|3] "counts" XXX - SG_ WRSRDWhlDistTmstm : 55|16@0+ (1,0) [0|65535] "counts" XXX - -BO_ 2156789760 Time_of_Day_LS: 6 XXX - SG_ CldrYr : 7|8@0+ (1,2000) [2000|2255] "year" XXX - SG_ CldrMth : 11|4@0+ (1,0) [0|15] "" XXX - SG_ FrPedDetCsStReq : 14|3@0+ (1,0) [0|7] "" XXX - SG_ CldrDay : 20|5@0+ (1,0) [0|31] "days" XXX - SG_ SmrtHgBmAstCstSetReq : 23|3@0+ (1,0) [0|7] "" XXX - SG_ TmofDay : 24|17@0+ (1,0) [0|0] "" XXX - SG_ TOD_HrofDay : 24|5@0+ (1,0) [0|31] "hr" XXX - SG_ TOD_MinofHr : 35|6@0+ (1,0) [0|63] "min" XXX - SG_ TOD_SecofMin : 45|6@0+ (1,0) [0|63] "s" XXX - SG_ TimeDispFormat : 25|1@0+ (1,0) [0|1] "" XXX - -BO_ 2155020288 Language_Selection_LS: 1 XXX - SG_ LngSelExt : 5|6@0+ (1,0) [0|63] "" XXX - SG_ ChVolRq2 : 7|2@0+ (1,0) [0|3] "" XXX - -BO_ 2150432768 Engine_Information_4_LS: 8 XXX - SG_ TransOilTempSensPres : 0|1@0+ (1,0) [0|1] "" XXX - SG_ GenFldDutCycGroup : 1|42@0+ (1,0) [0|0] "" XXX - SG_ GenFldDutCycV : 1|1@0+ (1,0) [0|1] "" XXX - SG_ GenFldDutCyc : 47|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ FuelFltLifRstPerf : 2|1@0+ (1,0) [0|1] "" XXX - SG_ TrnEmsMlfAtv : 3|1@0+ (1,0) [0|1] "" XXX - SG_ GrdBrkgAct : 4|1@0+ (1,0) [0|1] "" XXX - SG_ TrnsNEmsRltMalfActv : 5|1@0+ (1,0) [0|1] "" XXX - SG_ EngShtdwnPndgIO : 6|1@0+ (1,0) [0|1] "" XXX - SG_ EngManfldAirTempCrtdGroup : 7|16@0+ (1,0) [0|0] "" XXX - SG_ EngManfldAirTempCrtdV : 7|1@0+ (1,0) [0|1] "" XXX - SG_ EngManfldAirTempCrtd : 15|8@0+ (1,-40) [-40|215] "deg C" XXX - SG_ FuelTotCap : 19|12@0+ (0.125,0) [0|511.875] "liters" XXX - SG_ TrnsThrmlMngmntStat : 21|2@0+ (1,0) [0|3] "" XXX - SG_ PTHiElecLdReqd : 22|1@0+ (1,0) [0|1] "" XXX - SG_ EngOilRmnLf : 39|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ FuelFltRmnLf : 63|8@0+ (0.392157,0) [0|100.000035] "%" XXX - -BO_ 2155298816 Tire_Pressure_Sensor_Prog_Req_LS: 1 XXX - SG_ TrPrsSnsProgEvntRqd : 0|1@0+ (1,0) [0|1] "" XXX - SG_ TrPrsMntrTrLdRstRqstd : 2|2@0+ (1,0) [0|3] "" XXX - -BO_ 2158878720 ODIDynDataListReq_CntrStack_LS: 8 XXX - SG_ ODIDynDataLstRq_CntrStck : 7|64@0+ (1,0) [0|0] "" XXX - SG_ ODDLC_FUCID : 7|8@0+ (1,0) [0|255] "" XXX - SG_ ODDLC_DataId : 15|8@0+ (1,0) [0|255] "" XXX - SG_ ODDLC_DspMID : 23|8@0+ (1,0) [0|255] "" XXX - SG_ ODDLC_ReqDir : 24|1@0+ (1,0) [0|1] "" XXX - SG_ ODDLC_NmEntries : 31|7@0+ (1,0) [0|127] "" XXX - SG_ ODDLC_Idx : 39|16@0+ (1,0) [0|65535] "" XXX - SG_ ODDLC_SubIdReqM : 51|12@0+ (1,0) [0|4095] "" XXX - SG_ ODDLC_WrpArnd : 52|1@0+ (1,0) [0|1] "" XXX - SG_ ODDLC_BckgndFlag : 53|1@0+ (1,0) [0|1] "" XXX - SG_ ODDLC_ReqType : 55|2@0+ (1,0) [0|3] "" XXX - -BO_ 2158870528 ODIDynDataListRequest_AuxIP_LS: 8 XXX - SG_ ODIDynDataLstRq_AxIP : 7|64@0+ (1,0) [0|0] "" XXX - SG_ ODDLA_FUCID : 7|8@0+ (1,0) [0|255] "" XXX - SG_ ODDLA_DataId : 15|8@0+ (1,0) [0|255] "" XXX - SG_ ODDLA_DspMID : 23|8@0+ (1,0) [0|255] "" XXX - SG_ ODDLA_ReqDir : 24|1@0+ (1,0) [0|1] "" XXX - SG_ ODDLA_NmEntries : 31|7@0+ (1,0) [0|127] "" XXX - SG_ ODDLA_Idx : 39|16@0+ (1,0) [0|65535] "" XXX - SG_ ODDLA_SubIdReqM : 51|12@0+ (1,0) [0|4095] "" XXX - SG_ ODDLA_WrpArnd : 52|1@0+ (1,0) [0|1] "" XXX - SG_ ODDLA_BckgndFlag : 53|1@0+ (1,0) [0|1] "" XXX - SG_ ODDLA_ReqType : 55|2@0+ (1,0) [0|3] "" XXX - -BO_ 2154692608 Audio_Source_Status_LS: 2 XXX - SG_ AudSrcStat : 3|12@0+ (1,0) [0|0] "" XXX - SG_ ASSAudSrcType : 3|5@0+ (1,0) [0|31] "" XXX - SG_ ASSAudSrcStatCode : 11|4@0+ (1,0) [0|15] "" XXX - SG_ ASSAudSrcChType : 14|3@0+ (1,0) [0|7] "" XXX - SG_ LgclAVChnl : 7|4@0+ (1,0) [0|15] "" XXX - -BO_ 2154627072 Audio_Master_Arbitration_Command: 2 XXX - SG_ AudMstrArbCom : 3|4@0+ (1,0) [0|15] "" XXX - SG_ LgclAVChnl_368 : 7|4@0+ (1,0) [0|15] "" XXX - SG_ AudMstrSrcTyp : 12|5@0+ (1,0) [0|31] "" XXX - SG_ AudMstrChnnlTyp : 15|3@0+ (1,0) [0|7] "" XXX - -BO_ 2151112704 Occupant_Sensning_Status_LS: 2 XXX - SG_ FrntPassClass : 2|3@0+ (1,0) [0|7] "" XXX - SG_ FrPsSeatOccSnsOpMd : 5|3@0+ (1,0) [0|7] "N/A" XXX - SG_ FrPasSeatResCtrlOccStGroup : 7|14@0+ (1,0) [0|0] "" XXX - SG_ FrPasSeatResCtrlOccSt : 7|2@0+ (1,0) [0|3] "" XXX - SG_ FrPasSeatResCtrlOccStV : 10|1@0+ (1,0) [0|1] "" XXX - SG_ FrPsSeatOccFltSt : 9|2@0+ (1,0) [0|3] "N/A" XXX - SG_ FrPasSeatbltRemOccSt : 11|1@0+ (1,0) [0|1] "" XXX - -BO_ 2153938944 Remote_Reflash_Req_LS: 1 XXX - SG_ RmtRflshMdReqtd : 7|1@0+ (1,0) [0|1] "" XXX - -BO_ 2159239168 ODI_TEL_2_OTIM_LS: 8 XXX - SG_ ODI_TEL2OTIM : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2159230976 ODI_OTIM_2_TEL_LS: 8 XXX - SG_ ODI_OTIM2TEL : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2159222784 ODI_PDIM_2_CenterStack_LS: 8 XXX - SG_ ODI_PDIM2CntrStck : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2159214592 ODI_CenterStack_2_PDIM_LS: 8 XXX - SG_ ODI_CntrStck2PDIM : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2158862336 ODIAction_OTIM_LS: 8 XXX - SG_ ODIActn_OTIM : 5|62@0+ (1,0) [0|0] "" XXX - SG_ ODIAOT_DaTy : 5|6@0+ (1,0) [0|63] "" XXX - SG_ ODIAOT_FUCID : 15|8@0+ (1,0) [0|255] "" XXX - SG_ ODIAOT_ActnID : 23|8@0+ (1,0) [0|255] "" XXX - SG_ ODIAOT_DspMID : 31|8@0+ (1,0) [0|255] "" XXX - SG_ ODIAOT_ActnVal : 39|32@0+ (1,0) [0|4294967295] "" XXX - -BO_ 2150662144 Environment_Id_Resp_3_LS: 3 XXX - SG_ EnvIdRsp3 : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ EnvIdRspSt3 : 17|2@0+ (1,0) [0|3] "" XXX - -BO_ 2150653952 Environment_Id_Resp_2_LS: 3 XXX - SG_ EnvIdRsp2 : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ EnvIdRspSt2 : 17|2@0+ (1,0) [0|3] "" XXX - -BO_ 2150850560 Seatbelt_Information_LS: 1 XXX - SG_ DrSbltAtcGroup : 1|2@0+ (1,0) [0|0] "" XXX - SG_ DrSbltAtc : 0|1@0+ (1,0) [0|1] "" XXX - SG_ DrSbltAtcV : 1|1@0+ (1,0) [0|1] "" XXX - SG_ PsSbltAtcGroup : 3|2@0+ (1,0) [0|0] "" XXX - SG_ PsSbltAtc : 2|1@0+ (1,0) [0|1] "" XXX - SG_ PsSbltAtcV : 3|1@0+ (1,0) [0|1] "" XXX - -BO_ 2154659840 Column_Lock_Status_2: 2 XXX - SG_ UnlckRtryRotIndOn : 2|1@0+ (1,0) [0|1] "" XXX - SG_ UnlockRtryPshIndOn : 3|1@0+ (1,0) [0|1] "" XXX - SG_ StrgClmnLckVisNot : 4|1@0+ (1,0) [0|1] "" XXX - SG_ ClmnLckStatGroup : 5|6@0+ (1,0) [0|0] "" XXX - SG_ ClmnLckStat : 1|2@0+ (1,0) [0|3] "" XXX - SG_ ClmnLckStatV : 5|1@0+ (1,0) [0|1] "" XXX - SG_ ClmSysFlrIndOn : 7|1@0+ (1,0) [0|1] "" XXX - SG_ StrngClmnLckTT : 9|2@0+ (1,0) [0|3] "" XXX - -BO_ 2154938368 Fob_Programming_Mode_Status_LS: 1 XXX - SG_ FobProgMdStat : 1|2@0+ (1,0) [0|3] "" XXX - -BO_ 2155266048 Rear_Seat_Heat_Cool_Switches_LS: 1 XXX - SG_ RLHCSeatSw1Act : 0|1@0+ (1,0) [0|1] "" XXX - SG_ RLHCSeatSw2Act : 1|1@0+ (1,0) [0|1] "" XXX - SG_ RLHCSeatSw3Act : 2|1@0+ (1,0) [0|1] "" XXX - SG_ RRHCSeatSw1Act : 3|1@0+ (1,0) [0|1] "" XXX - SG_ RRHCSeatSw2Act : 4|1@0+ (1,0) [0|1] "" XXX - SG_ RRHCSeatSw3Act : 5|1@0+ (1,0) [0|1] "" XXX - -BO_ 2155249664 Rear_Seat_Heat_Cool_Control_LS: 4 XXX - SG_ RLHCSModeIndCtrl : 4|5@0+ (1,0) [0|0] "" XXX - SG_ RLHCSMInd3 : 0|1@0+ (1,0) [0|1] "" XXX - SG_ RLHCSMInd2 : 1|1@0+ (1,0) [0|1] "" XXX - SG_ RLHCSMInd1 : 2|1@0+ (1,0) [0|1] "" XXX - SG_ RLHCSMIndReq : 4|2@0+ (1,0) [0|3] "" XXX - SG_ RRHCSModeIndCtrl : 12|5@0+ (1,0) [0|0] "" XXX - SG_ RRHCSMInd3 : 8|1@0+ (1,0) [0|1] "" XXX - SG_ RRHCSMInd2 : 9|1@0+ (1,0) [0|1] "" XXX - SG_ RRHCSMInd1 : 10|1@0+ (1,0) [0|1] "" XXX - SG_ RRHCSMIndReq : 12|2@0+ (1,0) [0|3] "" XXX - SG_ RLHCSeatLevIndCtrl : 22|7@0+ (1,0) [0|0] "" XXX - SG_ RLHCSLSeatLev5 : 16|1@0+ (1,0) [0|1] "" XXX - SG_ RLHCSLSeatLev4 : 17|1@0+ (1,0) [0|1] "" XXX - SG_ RLHCSLSeatLev3 : 18|1@0+ (1,0) [0|1] "" XXX - SG_ RLHCSLSeatLev2 : 19|1@0+ (1,0) [0|1] "" XXX - SG_ RLHCSLSeatLev1 : 20|1@0+ (1,0) [0|1] "" XXX - SG_ RLHCSLIndReq : 22|2@0+ (1,0) [0|3] "" XXX - SG_ RRHCSeatLevIndCtrl : 30|7@0+ (1,0) [0|0] "" XXX - SG_ RRHCSLSeatLev5 : 24|1@0+ (1,0) [0|1] "" XXX - SG_ RRHCSLSeatLev4 : 25|1@0+ (1,0) [0|1] "" XXX - SG_ RRHCSLSeatLev3 : 26|1@0+ (1,0) [0|1] "" XXX - SG_ RRHCSLSeatLev2 : 27|1@0+ (1,0) [0|1] "" XXX - SG_ RRHCSLSeatLev1 : 28|1@0+ (1,0) [0|1] "" XXX - SG_ RRHCSLIndReq : 30|2@0+ (1,0) [0|3] "" XXX - -BO_ 2155184128 CruiseControl_LS: 3 XXX - SG_ CrsCntAtv : 0|1@0+ (1,0) [0|1] "" XXX - SG_ CrsSpdLmtrSwStat : 4|4@0+ (1,0) [0|15] "" XXX - SG_ TrnsShftLvrLckStat : 5|1@0+ (1,0) [0|1] "" XXX - SG_ RrStRmndrIO : 6|1@0+ (1,0) [0|1] "" XXX - SG_ RrStRmndrCstSetAvail : 7|1@0+ (1,0) [0|1] "" XXX - SG_ CrsCntrlSwStat : 15|8@0+ (1,0) [0|0] "" XXX - SG_ CrsCntrlSwStSwDataIntgty : 9|2@0+ (1,0) [0|3] "" XXX - SG_ CrsCntrlSwStSpDcSwAct : 10|1@0+ (1,0) [0|1] "" XXX - SG_ CrsCntrlSwStSpdInSwAct : 11|1@0+ (1,0) [0|1] "" XXX - SG_ CrsCntrlSwStSetSwAct : 12|1@0+ (1,0) [0|1] "" XXX - SG_ CrsCntrlSwStResSwAct : 13|1@0+ (1,0) [0|1] "" XXX - SG_ CrsCntrlSwStOnSwAct : 14|1@0+ (1,0) [0|1] "" XXX - SG_ CrsCntrlSwStCanSwAct : 15|1@0+ (1,0) [0|1] "" XXX - SG_ SmPhRmFunCstCurStVal : 18|3@0+ (1,0) [0|7] "" XXX - SG_ SmPhRmFunCstStAval : 19|1@0+ (1,0) [0|1] "" XXX - SG_ IdlRecmndToClEngIO : 20|1@0+ (1,0) [0|1] "" XXX - SG_ RrStRmndrCstCurrSetVal : 23|3@0+ (1,0) [0|7] "" XXX - -BO_ 2155167744 Power_Mode_Info_LS: 3 XXX - SG_ ShftPrkIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ ShftToNtrlIO : 1|1@0+ (1,0) [0|1] "" XXX - SG_ Ky_IdDevPr : 2|1@0+ (1,0) [0|1] "" XXX - SG_ SecPwrMdPshBtnAtv : 3|1@0+ (1,0) [0|1] "" XXX - SG_ TransModActIO : 4|1@0+ (1,0) [0|1] "" XXX - SG_ TransModInactIO : 5|1@0+ (1,0) [0|1] "" XXX - SG_ KylsStrtUseTxPckIO : 6|1@0+ (1,0) [0|1] "" XXX - SG_ TrStLgMdAtv : 7|1@0+ (1,0) [0|1] "" XXX - SG_ VehMovState : 10|3@0+ (1,0) [0|7] "" XXX - SG_ AutoShtdwnDsblIO : 11|1@0+ (1,0) [0|1] "" XXX - SG_ AppPrkBrkIO : 12|1@0+ (1,0) [0|1] "" XXX - SG_ NRmtDtdPsCluRstIO : 13|1@0+ (1,0) [0|1] "" XXX - SG_ ApplyBrkPdlIO : 14|1@0+ (1,0) [0|1] "" XXX - SG_ ApplyCltPdlIO : 15|1@0+ (1,0) [0|1] "" XXX - SG_ NoReDetInOn : 16|1@0+ (1,0) [0|1] "" XXX - SG_ NRmtDtdPsBrkRstIO : 17|1@0+ (1,0) [0|1] "" XXX - SG_ PrsBtnAgnTTrnEngOffIO : 18|1@0+ (1,0) [0|1] "" XXX - SG_ TSLgMdPwrCtOWAtv : 19|1@0+ (1,0) [0|1] "" XXX - SG_ NRmtDtctdRstrtAllwd : 20|1@0+ (1,0) [0|1] "" XXX - SG_ PrsStrtAgnIO : 21|1@0+ (1,0) [0|1] "" XXX - SG_ PrsCltchPrsStrtAgnIO : 22|1@0+ (1,0) [0|1] "" XXX - -BO_ 2154921984 Fob_Status_LS: 2 XXX - SG_ RFAFnc : 1|10@0+ (1,0) [0|0] "" XXX - SG_ RFRmtCntFobNm : 1|3@0+ (1,0) [0|7] "" XXX - SG_ RFRmtCntFobBatLw : 8|1@0+ (1,0) [0|1] "" XXX - SG_ RFRmtCntrlFobFnc : 14|6@0+ (1,0) [0|63] "" XXX - SG_ FobPogLimRchdIndOn : 2|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151317504 Park_Assistant_Rear_Status: 4 XXX - SG_ PrkAsstRrExtdDist : 3|12@0+ (0.01,0) [0|40.95] "m" XXX - SG_ PrkAstRrSysStat : 5|2@0+ (1,0) [0|3] "" XXX - SG_ PARrRgn1ObjStat : 19|4@0+ (1,0) [0|15] "" XXX - SG_ PARrRgn2ObjStat : 23|4@0+ (1,0) [0|15] "" XXX - SG_ PARrRgn3ObjStat : 27|4@0+ (1,0) [0|15] "" XXX - SG_ PARrRgn4ObjStat : 31|4@0+ (1,0) [0|15] "" XXX - -BO_ 2151301120 Park_Assistant_Front_Status: 4 XXX - SG_ PrkAsstFrtExtdDist : 3|12@0+ (0.01,0) [0|40.95] "m" XXX - SG_ PrkAstFrSysStat : 5|2@0+ (1,0) [0|3] "" XXX - SG_ PrkAstAdvSysAct : 6|1@0+ (1,0) [0|1] "" XXX - SG_ PrkAsstRrOffIO : 7|1@0+ (1,0) [0|1] "" XXX - SG_ PAFrtRgn1ObjStat : 19|4@0+ (1,0) [0|15] "" XXX - SG_ PAFrtRgn2ObjStat : 23|4@0+ (1,0) [0|15] "" XXX - SG_ PAFrtRgn3ObjStat : 27|4@0+ (1,0) [0|15] "" XXX - SG_ PAFrtRgn4ObjStat : 31|4@0+ (1,0) [0|15] "" XXX - -BO_ 2159083520 ODI_TEL_2_IPC_LS: 8 XXX - SG_ ODI_TEL2IPC : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2153922560 Climate_Control_Voltage_LS: 3 XXX - SG_ ClimCtrlVoltBstModReq : 0|1@0+ (1,0) [0|1] "" XXX - SG_ ClmtCtrlHtrEngRunRq : 1|1@0+ (1,0) [0|1] "" XXX - SG_ HtrVlvRqstdPstn : 3|2@0+ (1,0) [0|3] "" XXX - SG_ ClntHtrElecPwrRatGroup : 4|13@0+ (1,0) [0|0] "" XXX - SG_ ClntHtrElecPwrRatV : 4|1@0+ (1,0) [0|1] "" XXX - SG_ ClntHtrElecPwrRat : 15|8@0+ (0.04,0) [0|10.2] "kW" XXX - SG_ ClmCtrHiVltPwrRqtd : 23|8@0+ (0.1,0) [0|25.5] "kW" XXX - -BO_ 2153807872 Door_Open_Switch_Status_LS: 1 XXX - SG_ DrDoorOpenSwActGroup : 1|2@0+ (1,0) [0|0] "" XXX - SG_ DrDoorOpenSwAct : 0|1@0+ (1,0) [0|1] "" XXX - SG_ DrDoorOpenSwActV : 1|1@0+ (1,0) [0|1] "" XXX - SG_ PsDoorOpenSwActGroup : 3|2@0+ (1,0) [0|0] "" XXX - SG_ PsDoorOpenSwAct : 2|1@0+ (1,0) [0|1] "" XXX - SG_ PsDoorOpenSwActV : 3|1@0+ (1,0) [0|1] "" XXX - SG_ ClmSysAuxFlrIndOn : 4|1@0+ (1,0) [0|1] "" XXX - SG_ PsvStrtStrngClmnLckTT : 6|2@0+ (1,0) [0|3] "" XXX - -BO_ 2150703104 Audio_Amplifier_Status: 1 XXX - SG_ AudSysDigSigProcPres : 0|1@0+ (1,0) [0|1] "" XXX - SG_ AudSysSurSndSysPres : 1|1@0+ (1,0) [0|1] "" XXX - SG_ AudSysVNoisCompPres : 2|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151399424 Wash_Level_LS: 1 XXX - SG_ WshFldLw : 0|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151956480 Driver_Workload_LS: 2 XXX - SG_ DrvWrkldLvl : 3|4@0+ (1,0) [0|15] "" XXX - SG_ ClstrHMIAnmSt : 6|3@0+ (1,0) [0|7] "" XXX - SG_ ClstrHMIRdy : 7|1@0+ (1,0) [0|1] "" XXX - SG_ StrWhlThbwhlCnts : 13|6@0- (1,0) [-32|31] "counts" XXX - -BO_ 2151940096 Alarm_2_Request_LS: 7 XXX - SG_ Alrm2ExtRngReq : 1|26@0+ (1,0) [0|0] "" XXX - SG_ A2ERRAlrmReq : 1|2@0+ (1,0) [0|3] "" XXX - SG_ A2ERRAlrmTime : 15|24@0+ (1,0) [0|16777215] "min" XXX - SG_ EstBulkIntAirTmpGroup : 2|35@0+ (1,0) [0|0] "" XXX - SG_ EstBulkIntAirTmpV : 2|1@0+ (1,0) [0|1] "" XXX - SG_ EstBulkIntAirTmp : 39|8@0+ (0.5,-40) [-40|87.5] "deg C" XXX - SG_ EstIntRfSrfcTmpGroup : 3|44@0+ (1,0) [0|0] "" XXX - SG_ EstIntRfSrfcTmpV : 3|1@0+ (1,0) [0|1] "" XXX - SG_ EstIntRfSrfcTmp : 47|8@0+ (0.5,-40) [-40|87.5] "deg C" XXX - SG_ EstIntHorzDshSrfTmpGroup : 4|53@0+ (1,0) [0|0] "" XXX - SG_ EstIntHorzDshSrfTmpM : 4|1@0+ (1,0) [0|1] "" XXX - SG_ EstIntHorzDshSrfTmp : 55|8@0+ (1,-40) [-40|215] "deg C" XXX - -BO_ 2151923712 Alarm_1_Request_LS: 5 XXX - SG_ Alrm1ExtRngReq : 1|26@0+ (1,0) [0|0] "" XXX - SG_ A1ERRAlrmReq : 1|2@0+ (1,0) [0|3] "" XXX - SG_ A1ERRAlrmTime : 15|24@0+ (1,0) [0|16777215] "min" XXX - SG_ HLOCCstCurrSetVal : 6|3@0+ (1,0) [0|7] "" XXX - SG_ HLOCCstSetAvail : 7|1@0+ (1,0) [0|1] "" XXX - SG_ HLOCCstAvail : 39|7@0+ (1,0) [0|0] "" XXX - SG_ HLOCCA_Res4Avail : 33|1@0+ (1,0) [0|1] "" XXX - SG_ HLOCCA_Res3Avail : 34|1@0+ (1,0) [0|1] "" XXX - SG_ HLOCCA_Res2Avail : 35|1@0+ (1,0) [0|1] "" XXX - SG_ HLOCCA_Res1Avail : 36|1@0+ (1,0) [0|1] "" XXX - SG_ HLOCCA_OnOpnOnlyAvail : 37|1@0+ (1,0) [0|1] "" XXX - SG_ HLOCCA_OnAvail : 38|1@0+ (1,0) [0|1] "" XXX - SG_ HLOCCA_OffAvail : 39|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150645760 Environment_Id_Resp_1_LS: 3 XXX - SG_ EnvIdRsp1 : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ EnvIdRspSt1 : 17|2@0+ (1,0) [0|3] "" XXX - -BO_ 2152464384 Lane_Departure_Warning_LS: 3 XXX - SG_ LaneDepWrnDisbldIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ LnKpAstDisbldIO : 1|1@0+ (1,0) [0|1] "" XXX - SG_ SrvcLaneDepWrnSysIO : 2|1@0+ (1,0) [0|1] "" XXX - SG_ SrvcLnKpAstSysIO : 3|1@0+ (1,0) [0|1] "" XXX - SG_ HndsOffStrWhlDtIO : 4|1@0+ (1,0) [0|1] "" XXX - SG_ TnDrvLDWOffUnbIO : 5|1@0+ (1,0) [0|1] "" XXX - SG_ LftLnDepWrnSt : 7|2@0+ (1,0) [0|3] "" XXX - SG_ LaneDepWrnIndCntrl : 13|6@0+ (1,0) [0|0] "" XXX - SG_ LDWIC_LnDepWAWLn : 9|2@0+ (1,0) [0|3] "" XXX - SG_ LDWIC_Ind2 : 10|1@0+ (1,0) [0|1] "" XXX - SG_ LDWIC_Ind1 : 11|1@0+ (1,0) [0|1] "" XXX - SG_ LDWIC_IndReq : 13|2@0+ (1,0) [0|3] "" XXX - SG_ RtLnDepWrnSt : 15|2@0+ (1,0) [0|3] "" XXX - SG_ LnKpAstIndCntrl : 21|6@0+ (1,0) [0|0] "" XXX - SG_ LKAIC_AdbWngLn : 17|2@0+ (1,0) [0|3] "" XXX - SG_ LKAIC_Ind2 : 18|1@0+ (1,0) [0|1] "" XXX - SG_ LKAIC_Ind1 : 19|1@0+ (1,0) [0|1] "" XXX - SG_ LKAIC_IndReq : 21|2@0+ (1,0) [0|3] "" XXX - -BO_ 2154971136 Front_Seat_Heat_Cool_Switches_LS: 1 XXX - SG_ DrvHCSeatSw1Act : 0|1@0+ (1,0) [0|1] "" XXX - SG_ DrvHCSeatSw2Act : 1|1@0+ (1,0) [0|1] "" XXX - SG_ DrvHCSeatSw3Act : 2|1@0+ (1,0) [0|1] "" XXX - SG_ PassHCSeatSw1Act : 3|1@0+ (1,0) [0|1] "" XXX - SG_ PassHCSeatSw2Act : 4|1@0+ (1,0) [0|1] "" XXX - SG_ PassHCSeatSw3Act : 5|1@0+ (1,0) [0|1] "" XXX - -BO_ 2154962944 Front_Seat_Heat_Cool_Control_LS: 4 XXX - SG_ DrvHCSModeIndCtrl : 4|5@0+ (1,0) [0|0] "" XXX - SG_ DrvHCSMInd3 : 0|1@0+ (1,0) [0|1] "" XXX - SG_ DrvHCSMInd2 : 1|1@0+ (1,0) [0|1] "" XXX - SG_ DrvHCSMInd1 : 2|1@0+ (1,0) [0|1] "" XXX - SG_ DrvHCSMIndReq : 4|2@0+ (1,0) [0|3] "" XXX - SG_ PassHCSModeIndCtrl : 12|5@0+ (1,0) [0|0] "" XXX - SG_ PassHCSMInd3 : 8|1@0+ (1,0) [0|1] "" XXX - SG_ PassHCSMInd2 : 9|1@0+ (1,0) [0|1] "" XXX - SG_ PassHCSMInd1 : 10|1@0+ (1,0) [0|1] "" XXX - SG_ PassHCSMIndReq : 12|2@0+ (1,0) [0|3] "" XXX - SG_ DrvHCSLevIndCtrl : 22|7@0+ (1,0) [0|0] "" XXX - SG_ DrvHCSLSeatLev5 : 16|1@0+ (1,0) [0|1] "" XXX - SG_ DrvHCSLSeatLev4 : 17|1@0+ (1,0) [0|1] "" XXX - SG_ DrvHCSLSeatLev3 : 18|1@0+ (1,0) [0|1] "" XXX - SG_ DrvHCSLSeatLev2 : 19|1@0+ (1,0) [0|1] "" XXX - SG_ DrvHCSLSeatLev1 : 20|1@0+ (1,0) [0|1] "" XXX - SG_ DrvHCSLIndReq : 22|2@0+ (1,0) [0|3] "" XXX - SG_ PassHCSeatLevIndCtrl : 30|7@0+ (1,0) [0|0] "" XXX - SG_ PassHCSLSeatLev5 : 24|1@0+ (1,0) [0|1] "" XXX - SG_ PassHCSLSeatLev4 : 25|1@0+ (1,0) [0|1] "" XXX - SG_ PassHCSLSeatLev3 : 26|1@0+ (1,0) [0|1] "" XXX - SG_ PassHCSLSeatLev2 : 27|1@0+ (1,0) [0|1] "" XXX - SG_ PassHCSLSeatLev1 : 28|1@0+ (1,0) [0|1] "" XXX - SG_ PassHCSLIndReq : 30|2@0+ (1,0) [0|3] "" XXX - -BO_ 2156232704 Alarm_Clock_Status_LS: 4 XXX - SG_ AlrmClkStat : 7|32@0+ (1,0) [0|0] "" XXX - SG_ ACSAlarm3 : 1|2@0+ (1,0) [0|3] "" XXX - SG_ ACSAlarm2 : 3|2@0+ (1,0) [0|3] "" XXX - SG_ ACSAlarm1 : 5|2@0+ (1,0) [0|3] "" XXX - SG_ ACSAlarm0 : 7|2@0+ (1,0) [0|3] "" XXX - SG_ ACSAlarm7 : 9|2@0+ (1,0) [0|3] "" XXX - SG_ ACSAlarm6 : 11|2@0+ (1,0) [0|3] "" XXX - SG_ ACSAlarm5 : 13|2@0+ (1,0) [0|3] "" XXX - SG_ ACSAlarm4 : 15|2@0+ (1,0) [0|3] "" XXX - SG_ ACSAlarm11 : 17|2@0+ (1,0) [0|3] "" XXX - SG_ ACSAlarm10 : 19|2@0+ (1,0) [0|3] "" XXX - SG_ ACSAlarm9 : 21|2@0+ (1,0) [0|3] "" XXX - SG_ ACSAlarm8 : 23|2@0+ (1,0) [0|3] "" XXX - SG_ ACSAlarm15 : 25|2@0+ (1,0) [0|3] "" XXX - SG_ ACSAlarm14 : 27|2@0+ (1,0) [0|3] "" XXX - SG_ ACSAlarm13 : 29|2@0+ (1,0) [0|3] "" XXX - SG_ ACSAlarm12 : 31|2@0+ (1,0) [0|3] "" XXX - -BO_ 2154987520 Hood_Status_LS: 1 XXX - SG_ HdStGroup : 2|3@0+ (1,0) [0|0] "" XXX - SG_ HdSt : 1|2@0+ (1,0) [0|3] "" XXX - SG_ HdStV : 2|1@0+ (1,0) [0|1] "" XXX - SG_ WrlsChrgSysChrgStat : 5|3@0+ (1,0) [0|7] "" XXX - -BO_ 2154840064 Compass_Status_LS: 4 XXX - SG_ CmpsOctHdingDataSrc : 0|1@0+ (1,0) [0|1] "" XXX - SG_ CmpsModFltPrs : 1|1@0+ (1,0) [0|1] "" XXX - SG_ CmpsModManCalInPrc : 2|1@0+ (1,0) [0|1] "" XXX - SG_ CmpsZnNvrSet : 3|1@0+ (1,0) [0|1] "" XXX - SG_ CmpsDecZone : 11|4@0+ (1,0) [0|15] "" XXX - SG_ CmpsOctHding : 14|3@0+ (1,0) [0|7] "" XXX - SG_ CmpsSatrtd : 15|1@0+ (1,0) [0|1] "" XXX - SG_ CmpsCrHding : 23|16@0+ (0.0054932,0) [0|359.996862] "deg" XXX - -BO_ 2154676224 Compass_Request_LS: 1 XXX - SG_ CmpsDecZonCmndVal : 3|4@0+ (1,0) [0|15] "" XXX - SG_ CmpsDecZonSetReq : 4|1@0+ (1,0) [0|1] "" XXX - SG_ CmpsModManCalReq : 5|1@0+ (1,0) [0|1] "" XXX - SG_ CmpsModSlfTstReq : 6|1@0+ (1,0) [0|1] "" XXX - -BO_ 2154643456 Auxiliary_Heater_Status_LS: 3 XXX - SG_ AuxHtrAtv : 0|1@0+ (1,0) [0|1] "" XXX - SG_ HtrCoreInltClntTmpCalcGroup : 4|21@0+ (1,0) [0|0] "" XXX - SG_ HtrCoreInltClntTmpCalcV : 4|1@0+ (1,0) [0|1] "" XXX - SG_ HtrCoreInltClntTmpCalc : 23|8@0+ (1,-40) [-40|215] "deg C" XXX - SG_ CCClntCrcFlwRtReq : 15|8@0+ (0.392157,0) [0|100.000035] "%" XXX - -BO_ 2154905600 Driver_Identifier_LS: 1 XXX - SG_ DrId : 2|3@0+ (1,0) [0|7] "" XXX - SG_ DrvSeatPrsMemID : 5|3@0+ (1,0) [0|7] "" XXX - -BO_ 2154954752 High_Volt_Climate_Pwr_Status_LS: 5 XXX - SG_ ClmtHtPwrRqd : 0|1@0+ (1,0) [0|1] "" XXX - SG_ HtdStWhlCmd : 2|2@0+ (1,0) [0|3] "" XXX - SG_ HtdStWhlInd : 4|2@0+ (1,0) [0|3] "" XXX - SG_ HtdStWhlCtrlSrc : 5|1@0+ (1,0) [0|1] "" XXX - SG_ ClntHtrElecPwrReq : 15|8@0+ (0.04,0) [0|10.2] "kW" XXX - SG_ EstACCompPwrRchCbnCmf : 23|8@0+ (0.04,0) [0|10.2] "kw" XXX - SG_ EstACCompPwrMtnCbnCmf : 31|8@0+ (0.04,0) [0|10.2] "kW" XXX - -BO_ 2153381888 Control_Power_Liftgate_LS: 4 XXX - SG_ FnshRrClsrMtnBfrDrvIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ RrClsrObstclDtctd : 1|1@0+ (1,0) [0|1] "" XXX - SG_ RrClsrInMtn : 3|1@0+ (1,0) [0|1] "" XXX - SG_ RrClosOpenSwActGroup : 4|3@0+ (1,0) [0|0] "" XXX - SG_ RrClosOpenSwAct : 2|1@0+ (1,0) [0|1] "" XXX - SG_ RrClosOpenSwActV : 4|1@0+ (1,0) [0|1] "" XXX - SG_ RrWprInhbRq : 5|1@0+ (1,0) [0|1] "" XXX - SG_ GrgPrgMdCmpl : 6|1@0+ (1,0) [0|1] "" XXX - SG_ PwrLftgtInclAngGroup : 7|16@0+ (1,0) [0|0] "" XXX - SG_ PwrLftgtInclAngV : 7|1@0+ (1,0) [0|1] "" XXX - SG_ PwrLftgtInclAng : 15|8@0+ (1,0) [0|255] "" XXX - SG_ VehIncAngEst : 23|8@0+ (1,0) [0|255] "deg" XXX - SG_ PwrLftgtMotStat : 26|3@0+ (1,0) [0|7] "" XXX - SG_ VltActRrAccUnavlIO : 27|1@0+ (1,0) [0|1] "" XXX - -BO_ 2149752832 Chassis_Information_LS: 8 XXX - SG_ VehHghtStatGroup : 0|9@0+ (1,0) [0|0] "" XXX - SG_ VehHghtStatV : 0|1@0+ (1,0) [0|1] "" XXX - SG_ VehHghtStat : 11|4@0+ (1,0) [0|15] "" XXX - SG_ IntBrkAssPreFilReq : 1|1@0+ (1,0) [0|1] "N/A" XXX - SG_ BksOvht : 2|1@0+ (1,0) [0|1] "" XXX - SG_ HalfSysFail : 3|1@0+ (1,0) [0|1] "" XXX - SG_ BrkSysRedBrkTlltlReq : 4|1@0+ (1,0) [0|1] "" XXX - SG_ ABSAtv : 5|1@0+ (1,0) [0|1] "" XXX - SG_ DrvlnCustStngAvlbl : 6|1@0+ (1,0) [0|1] "" XXX - SG_ StrCustStngAvlbl : 7|1@0+ (1,0) [0|1] "" XXX - SG_ PrkBrkVDA : 12|1@0+ (1,0) [0|1] "" XXX - SG_ PowStVDA : 13|1@0+ (1,0) [0|1] "" XXX - SG_ RrDrCntVDA : 14|1@0+ (1,0) [0|1] "" XXX - SG_ BrkSysVDA : 15|1@0+ (1,0) [0|1] "" XXX - SG_ SprTireSt : 18|3@0+ (1,0) [0|7] "" XXX - SG_ EPBSysAudWarnReq : 20|2@0+ (1,0) [0|3] "" XXX - SG_ EPBSysDspMsgReq : 23|3@0+ (1,0) [0|7] "" XXX - SG_ DrvlnCustCurrStngVal : 26|3@0+ (1,0) [0|7] "" XXX - SG_ StrCustCurrStngVal : 29|3@0+ (1,0) [0|7] "" XXX - SG_ SusCustStngAvlbl : 30|1@0+ (1,0) [0|1] "" XXX - SG_ EBDFailed : 31|1@0+ (1,0) [0|1] "" XXX - SG_ SusCustCurrStngVal : 34|3@0+ (1,0) [0|7] "" XXX - SG_ HillDscntCntlSysStat : 37|3@0+ (1,0) [0|7] "" XXX - SG_ ElecPrkBrkStat : 39|2@0+ (1,0) [0|3] "" XXX - SG_ HlStrAssActIO : 41|1@0+ (1,0) [0|1] "" XXX - SG_ ColPrSysStngAvl : 42|1@0+ (1,0) [0|1] "" XXX - SG_ GNCustSetngAvlbl : 44|1@0+ (1,0) [0|1] "" XXX - SG_ GNCustCrntStngVal : 47|3@0+ (1,0) [0|7] "" XXX - SG_ CPSInfotmntMtReq : 49|2@0+ (1,0) [0|3] "" XXX - SG_ ColPrSysCrntStng : 52|3@0+ (1,0) [0|7] "" XXX - SG_ SndEnhcmtPerfMdRq : 55|3@0+ (1,0) [0|7] "" XXX - SG_ DispPerfMdCsCrStVal : 58|3@0+ (1,0) [0|7] "" XXX - SG_ DispPerfMdCsStAvl : 59|1@0+ (1,0) [0|1] "" XXX - SG_ SndPerfMdCsCrStVal : 62|3@0+ (1,0) [0|7] "" XXX - SG_ SndPerfMdCsStAvl : 63|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151514112 Reset_OilLife_Request_LS: 1 XXX - SG_ EngOilLfRstRq : 0|1@0+ (1,0) [0|1] "" XXX - -BO_ 2158903296 ODIDynDataMultiRequest_AuxIP_LS: 8 XXX - SG_ ODIDynDataMltRq_AuxIP : 5|62@0+ (1,0) [0|0] "" XXX - SG_ ODDMA_DataID2Vld : 0|1@0+ (1,0) [0|1] "" XXX - SG_ ODDMA_DataID3Vld : 1|1@0+ (1,0) [0|1] "" XXX - SG_ ODDMA_DataID4Vld : 2|1@0+ (1,0) [0|1] "" XXX - SG_ ODDMA_DataID5Vld : 3|1@0+ (1,0) [0|1] "" XXX - SG_ ODDMA_ReqType : 5|2@0+ (1,0) [0|3] "" XXX - SG_ ODDMA_FUCID : 15|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMA_DispMID : 23|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMA_DataID1 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMA_DataID2 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMA_DataID3 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMA_DataID4 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMA_DataID5 : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 2158911488 ODIDynDataMultiReq_CntrStack_LS: 8 XXX - SG_ ODIDynDataMltRq_CntrStck : 5|62@0+ (1,0) [0|0] "" XXX - SG_ ODDMC_DataID2Vld : 0|1@0+ (1,0) [0|1] "" XXX - SG_ ODDMC_DataID3Vld : 1|1@0+ (1,0) [0|1] "" XXX - SG_ ODDMC_DataID4Vld : 2|1@0+ (1,0) [0|1] "" XXX - SG_ ODDMC_DataID5Vld : 3|1@0+ (1,0) [0|1] "" XXX - SG_ ODDMC_ReqType : 5|2@0+ (1,0) [0|3] "" XXX - SG_ ODDMC_FUCID : 15|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMC_DispMID : 23|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMC_DataID1 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMC_DataID2 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMC_DataID3 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMC_DataID4 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMC_DataID5 : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 2158919680 ODIDynDataMultiRequest_IPC_LS: 8 XXX - SG_ ODIDynDataMltRq_IPC : 5|62@0+ (1,0) [0|0] "" XXX - SG_ ODDMI_DataID2Vld : 0|1@0+ (1,0) [0|1] "" XXX - SG_ ODDMI_DataID3Vld : 1|1@0+ (1,0) [0|1] "" XXX - SG_ ODDMI_DataID4Vld : 2|1@0+ (1,0) [0|1] "" XXX - SG_ ODDMI_DataID5Vld : 3|1@0+ (1,0) [0|1] "" XXX - SG_ ODDMI_ReqType : 5|2@0+ (1,0) [0|3] "" XXX - SG_ ODDMI_FUCID : 15|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMI_DispMID : 23|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMI_DataID1 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMI_DataID2 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMI_DataID3 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMI_DataID4 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ ODDMI_DataID5 : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 2151825408 Outside_Air_Temperature_LS: 3 XXX - SG_ OtsAirTmpCrValGroup : 0|9@0+ (1,0) [0|0] "" XXX - SG_ OtsAirTmpCrValV : 0|1@0+ (1,0) [0|1] "" XXX - SG_ OtsAirTmpCrVal : 15|8@0+ (0.5,-40) [-40|87.5] "deg C" XXX - SG_ OtsAirTmpGroup : 1|18@0+ (1,0) [0|0] "" XXX - SG_ OtsAirTmpV : 1|1@0+ (1,0) [0|1] "" XXX - SG_ OtsAirTmp : 23|8@0+ (0.5,-40) [-40|87.5] "deg C" XXX - SG_ OtsAirTmpCrValMsk : 2|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151153664 Rear_Window_Defog_Status_LS: 1 XXX - SG_ RrWndDfgOn : 0|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151170048 Trailer_Status_LS: 2 XXX - SG_ TrlrHtchSwAtv : 0|1@0+ (1,0) [0|1] "" XXX - SG_ TrlrBrkLtFld : 1|1@0+ (1,0) [0|1] "" XXX - SG_ TrlrFgLtFld : 2|1@0+ (1,0) [0|1] "" XXX - SG_ TrlrRvsLtFld : 3|1@0+ (1,0) [0|1] "" XXX - SG_ TrlrTlLtFld : 4|1@0+ (1,0) [0|1] "" XXX - SG_ TrlrFgLtPrs : 5|1@0+ (1,0) [0|1] "" XXX - SG_ TrlrRtTrInLtFld : 6|1@0+ (1,0) [0|1] "" XXX - SG_ TrlLfTrInLtFld : 7|1@0+ (1,0) [0|1] "" XXX - SG_ LftSecTrnIndFld : 8|1@0+ (1,0) [0|1] "" XXX - SG_ RtSecTrnIndFld : 9|1@0+ (1,0) [0|1] "" XXX - SG_ DisRrPrmryLmps : 10|1@0+ (1,0) [0|1] "" XXX - SG_ RLftPrkLmpFld : 11|1@0+ (1,0) [0|1] "" XXX - SG_ RRPrkLmpFld : 12|1@0+ (1,0) [0|1] "" XXX - SG_ RrEndCrrStat : 13|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151841792 Wipe_Wash_Status_LS: 1 XXX - SG_ TurnWprIntIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ RnSnsActIO : 1|1@0+ (1,0) [0|1] "" XXX - SG_ RnSnsOffIO : 2|1@0+ (1,0) [0|1] "" XXX - SG_ WSWprAct : 3|1@0+ (1,0) [0|1] "" XXX - SG_ HtdFrntWSSt : 4|1@0+ (1,0) [0|1] "" XXX - -BO_ 2154995712 Air_Conditioning_Comp_Type_LS: 1 XXX - SG_ HVHtrOvrTmpIndOn : 3|1@0+ (1,0) [0|1] "" XXX - SG_ HVHtrFldIO : 4|1@0+ (1,0) [0|1] "" XXX - -BO_ 2154094592 Adjustable_Pedal_Motion_Inh_LS: 8 XXX - SG_ AdjPdlMotInhbtd : 0|1@0+ (1,0) [0|1] "" XXX - SG_ IntDimSeldAnmTypStVal : 4|4@0+ (1,0) [0|15] "" XXX - SG_ IntDimSeldClrTypStVal : 12|5@0+ (1,0) [0|31] "" XXX - SG_ IntDimAnmTypAvl : 22|15@0+ (1,0) [0|0] "" XXX - SG_ IDATA_AnmTyp6Avl : 16|1@0+ (1,0) [0|1] "" XXX - SG_ IDATA_AnmTyp5Avl : 17|1@0+ (1,0) [0|1] "" XXX - SG_ IDATA_AnmTyp4Avl : 18|1@0+ (1,0) [0|1] "" XXX - SG_ IDATA_AnmTyp3Avl : 19|1@0+ (1,0) [0|1] "" XXX - SG_ IDATA_AnmTyp2Avl : 20|1@0+ (1,0) [0|1] "" XXX - SG_ IDATA_AnmTyp1Avl : 21|1@0+ (1,0) [0|1] "" XXX - SG_ IDATA_OffAvl : 22|1@0+ (1,0) [0|1] "" XXX - SG_ IDATA_AnmTyp14Avl : 24|1@0+ (1,0) [0|1] "" XXX - SG_ IDATA_AnmTyp13Avl : 25|1@0+ (1,0) [0|1] "" XXX - SG_ IDATA_AnmTyp12Avl : 26|1@0+ (1,0) [0|1] "" XXX - SG_ IDATA_AnmTyp11Avl : 27|1@0+ (1,0) [0|1] "" XXX - SG_ IDATA_AnmTyp10Avl : 28|1@0+ (1,0) [0|1] "" XXX - SG_ IDATA_AnmTyp9Avl : 29|1@0+ (1,0) [0|1] "" XXX - SG_ IDATA_AnmTyp8Avl : 30|1@0+ (1,0) [0|1] "" XXX - SG_ IDATA_AnmTyp7Avl : 31|1@0+ (1,0) [0|1] "" XXX - SG_ IntDimClrTypAvl : 38|31@0+ (1,0) [0|0] "" XXX - SG_ IDCTA_ClrTyp6Avl : 32|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp5Avl : 33|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp4Avl : 34|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp3Avl : 35|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp2Avl : 36|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp1Avl : 37|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_OffAvl : 38|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp14Avl : 40|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp13Avl : 41|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp12Avl : 42|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp11Avl : 43|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp10Avl : 44|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp9Avl : 45|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp8Avl : 46|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp7Avl : 47|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp22Avl : 48|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp21Avl : 49|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp20Avl : 50|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp19Avl : 51|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp18Avl : 52|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp17Avl : 53|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp16Avl : 54|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp15Avl : 55|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp30Avl : 56|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp29Avl : 57|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp28Avl : 58|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp27Avl : 59|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp26Avl : 60|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp25Avl : 61|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp24Avl : 62|1@0+ (1,0) [0|1] "" XXX - SG_ IDCTA_ClrTyp23Avl : 63|1@0+ (1,0) [0|1] "" XXX - -BO_ 2149711872 ACC_YawRate_Information_LS: 8 XXX - SG_ ACCDrvrSeltdSpd : 3|12@0+ (0.0625,0) [0|255.9375] "km / h" XXX - SG_ AdapCrsCntVDA : 4|1@0+ (1,0) [0|1] "" XXX - SG_ ACCAct370 : 6|1@0+ (1,0) [0|1] "" XXX - SG_ CrsCntlDrSelSpdAct : 7|1@0+ (1,0) [0|1] "" XXX - SG_ CrsSpdLmtrDrvSelSpd : 19|12@0+ (0.0625,0) [0|255.9375] "km / h" XXX - SG_ ACCHdwyStg : 22|3@0+ (1,0) [0|7] "" XXX - SG_ FwdClnAlrtPr : 23|1@0+ (1,0) [0|1] "" XXX - SG_ VehDynYawRateGroup : 36|13@0+ (1,0) [0|0] "" XXX - SG_ VehDynYawRate : 35|12@0- (0.0625,0) [-128|127.9375] "deg/sec" XXX - SG_ VehDynYawRateV : 36|1@0+ (1,0) [0|1] "" XXX - SG_ SpdLmtrSpdWrngEnbld : 37|1@0+ (1,0) [0|1] "" XXX - SG_ SpdLmtrSpdWrngAct : 38|1@0+ (1,0) [0|1] "" XXX - SG_ FwdClnAlrtOffIO : 39|1@0+ (1,0) [0|1] "" XXX - SG_ FwdObjAlrtInd : 48|9@0+ (1,0) [0|0] "" XXX - SG_ FOAI_AlrtChmIhbRq : 48|1@0+ (1,0) [0|1] "" XXX - SG_ FOAI_AlrtWrnIndRq : 59|4@0+ (1,0) [0|15] "" XXX - SG_ FOAI_VehAhdIndRq : 63|4@0+ (1,0) [0|15] "" XXX - SG_ AutoMdSpdLmtStat : 50|2@0+ (1,0) [0|3] "" XXX - SG_ ACCAutoSetSpdStat : 52|2@0+ (1,0) [0|3] "" XXX - SG_ SetSpdLmtRchd : 54|2@0+ (1,0) [0|3] "" XXX - -BO_ 2153979904 BulbOutage_LS: 2 XXX - SG_ CHMSLFld : 0|1@0+ (1,0) [0|1] "" XXX - SG_ FLTrnIndLtFld : 1|1@0+ (1,0) [0|1] "" XXX - SG_ FRTrnIndLtFld : 2|1@0+ (1,0) [0|1] "" XXX - SG_ LftBrkLtFld : 3|1@0+ (1,0) [0|1] "" XXX - SG_ LftLwBmFld : 4|1@0+ (1,0) [0|1] "" XXX - SG_ LftPrkLtFld : 5|1@0+ (1,0) [0|1] "" XXX - SG_ LicPltLtFld : 6|1@0+ (1,0) [0|1] "" XXX - SG_ RLTrnIndLtFld : 7|1@0+ (1,0) [0|1] "" XXX - SG_ RRTrnIndLtFld : 8|1@0+ (1,0) [0|1] "" XXX - SG_ RtBrkLtFld : 9|1@0+ (1,0) [0|1] "" XXX - SG_ RtLwBmFld : 10|1@0+ (1,0) [0|1] "" XXX - SG_ RtPrkLtFld : 11|1@0+ (1,0) [0|1] "" XXX - SG_ RFgLtFld : 12|1@0+ (1,0) [0|1] "" XXX - SG_ RvsLtFld : 13|1@0+ (1,0) [0|1] "" XXX - SG_ LftDytmRunLmpFld : 14|1@0+ (1,0) [0|1] "" XXX - SG_ RtDytmRunLmpFld : 15|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150154240 Passive_Entry_Reply_LS: 8 XXX - SG_ PsvEntVehIdExt : 7|32@0+ (1,0) [0|4294967295] "" XXX - SG_ PsvEntChlngRply : 39|32@0+ (1,0) [0|4294967295] "passwrd" XXX - -BO_ 2155003904 Side_Blind_Zone_Alert_Status: 2 XXX - SG_ SBZASysClnIndOn : 0|1@0+ (1,0) [0|1] "" XXX - SG_ SBZASysOffIndOn : 1|1@0+ (1,0) [0|1] "" XXX - SG_ SBZASysSrvIndOn : 2|1@0+ (1,0) [0|1] "" XXX - SG_ SBZATmpUnvIndOn : 3|1@0+ (1,0) [0|1] "" XXX - SG_ LftLnChgThrt : 4|1@0+ (1,0) [0|1] "" XXX - SG_ LfLnChngThrtAprchSpd : 15|8@0- (1,0) [-128|127] "km/h" XXX - -BO_ 2150817792 Airbag_Impact_Data_5: 3 XXX - SG_ ImpMaxLateralDeltaVel : 7|8@0- (1,0) [-128|127] "" XXX - SG_ ImpMaxLongDeltaVel : 15|8@0- (1,0) [-128|127] "" XXX - SG_ ImpTimeToMaxDeltaVel : 23|8@0+ (10,0) [0|2550] "ms" XXX - -BO_ 2150227968 Phone_Speech_Rec_Status_LS: 1 XXX - SG_ PhnSpRcgnApSt : 1|2@0+ (1,0) [0|3] "" XXX - -BO_ 2162982912 VIN_Digits_10_to_17: 8 XXX - SG_ VehIdNmDig10_17 : 7|64@0+ (1,0) [0|1] "" XXX - -BO_ 2162966528 VIN_Digits_2_to_9: 8 XXX - SG_ VehIdNmDig2_9 : 7|64@0+ (1,0) [0|1] "" XXX - -BO_ 2151497728 Tire_Pressure_Sensors_LS: 6 XXX - SG_ TireLFPrsGroup : 0|17@0+ (1,0) [0|0] "" XXX - SG_ TireLFPrsV : 0|1@0+ (1,0) [0|1] "" XXX - SG_ TireLFPrs : 23|8@0+ (4,0) [0|1020] "kPaG" XXX - SG_ TireRFPrsGroup : 1|34@0+ (1,0) [0|0] "" XXX - SG_ TireRFPrsV : 1|1@0+ (1,0) [0|1] "" XXX - SG_ TireRFPrs : 39|8@0+ (4,0) [0|1020] "kPaG" XXX - SG_ TireLFPrsStat : 4|3@0+ (1,0) [0|7] "" XXX - SG_ TireRFPrsStat : 7|3@0+ (1,0) [0|7] "" XXX - SG_ TireLRPrsGroup : 8|17@0+ (1,0) [0|0] "" XXX - SG_ TireLRPrsV : 8|1@0+ (1,0) [0|1] "" XXX - SG_ TireLRPrs : 31|8@0+ (4,0) [0|1020] "kPaG" XXX - SG_ TireRRPrsGroup : 9|34@0+ (1,0) [0|0] "" XXX - SG_ TireRRPrsV : 9|1@0+ (1,0) [0|1] "" XXX - SG_ TireRRPrs : 47|8@0+ (4,0) [0|1020] "kPaG" XXX - SG_ TireLRPrsStat : 12|3@0+ (1,0) [0|7] "" XXX - SG_ TireRRPrsStat : 15|3@0+ (1,0) [0|7] "" XXX - -BO_ 2151219200 Remote_Start_Status: 1 XXX - SG_ RemStrtSt : 0|1@0+ (1,0) [0|1] "" XXX - SG_ RmVehStrRq : 1|1@0+ (1,0) [0|1] "" XXX - -BO_ 2153775104 DTC_Triggered: 7 XXX - SG_ DTCInfo : 7|56@0+ (1,0) [0|0] "" XXX - SG_ DTCI_DTCTriggered : 0|1@0+ (1,0) [0|1] "" XXX - SG_ DTCIUnused1 : 1|1@0+ (1,0) [0|1] "" XXX - SG_ DTCIUnused2 : 2|1@0+ (1,0) [0|1] "" XXX - SG_ DTCIUnused3 : 3|1@0+ (1,0) [0|1] "" XXX - SG_ DTCIUnused4 : 4|1@0+ (1,0) [0|1] "" XXX - SG_ DTCIUnused5 : 5|1@0+ (1,0) [0|1] "" XXX - SG_ DTCIUnused6 : 6|1@0+ (1,0) [0|1] "" XXX - SG_ DTCIUnused7 : 7|1@0+ (1,0) [0|1] "" XXX - SG_ DTCI_DTCSource : 15|8@0+ (1,0) [0|255] "" XXX - SG_ DTCI_DTCNumber : 23|16@0+ (1,0) [0|65535] "" XXX - SG_ DTCI_DTCFailType : 39|8@0+ (1,0) [0|255] "" XXX - SG_ DTCI_CodeSupported : 40|1@0+ (1,0) [0|1] "" XXX - SG_ DTCI_CurrentStatus : 41|1@0+ (1,0) [0|1] "" XXX - SG_ DTCI_TstNPsdCdClrdSt : 42|1@0+ (1,0) [0|1] "" XXX - SG_ DTCI_TstFldCdClrdStat : 43|1@0+ (1,0) [0|1] "" XXX - SG_ DTCI_HistStat : 44|1@0+ (1,0) [0|1] "" XXX - SG_ DTCI_TstNPsdPwrUpSt : 45|1@0+ (1,0) [0|1] "" XXX - SG_ DTCI_TstFldPwrUpSt : 46|1@0+ (1,0) [0|1] "" XXX - SG_ DTCI_WrnIndRqdSt : 47|1@0+ (1,0) [0|1] "" XXX - SG_ DTCI_DTCFaultType : 55|8@0+ (1,0) [0|255] "" XXX - -BO_ 2151235584 Vehicle_Theft_Notification_Stat: 5 XXX - SG_ DrIdDevLrnd : 0|1@0+ (1,0) [0|1] "" XXX - SG_ VehSecSysFldIO : 1|1@0+ (1,0) [0|1] "" XXX - SG_ VTDTmprDetected : 2|1@0+ (1,0) [0|1] "" XXX - SG_ EhnSrvEngImmStat : 3|1@0+ (1,0) [0|1] "" XXX - SG_ IllDrIdDevDtctd : 4|1@0+ (1,0) [0|1] "" XXX - SG_ AlcKyIIncmIndOn : 5|1@0+ (1,0) [0|1] "" XXX - SG_ VehSecStrgColLckPwdGroup : 6|31@0+ (1,0) [0|0] "" XXX - SG_ VehSecStrgColLckPwdV : 6|1@0+ (1,0) [0|1] "" XXX - SG_ VehSecStrgColLckPwd : 23|16@0+ (1,0) [0|65535] "" XXX - SG_ VehSecAuthnSesComp : 7|1@0+ (1,0) [0|1] "" XXX - SG_ VhSecNImmoIndRq : 9|2@0+ (1,0) [0|3] "" XXX - SG_ StrgColLckCmd : 11|2@0+ (1,0) [0|3] "" XXX - SG_ NmofPrgKFbExtd : 15|4@0+ (1,0) [0|15] "" XXX - SG_ VehStatStAtv : 32|1@0+ (1,0) [0|1] "" XXX - SG_ EhnSrvImmbComRst : 33|1@0+ (1,0) [0|1] "" XXX - SG_ ClmSysBkupFlrIndOn : 34|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150809600 Airbag_Impact_Data_4: 8 XXX - SG_ ImpDltVlcSamp12 : 7|16@0+ (1,0) [0|0] "" XXX - SG_ IDVS12_Axis1 : 7|8@0- (1,0) [-128|127] "counts" XXX - SG_ IDVS12_Axis2 : 15|8@0- (1,0) [-128|127] "counts" XXX - SG_ ImpDltVlcSamp13 : 23|16@0+ (1,0) [0|0] "" XXX - SG_ IDVS13_Axis1 : 23|8@0- (1,0) [-128|127] "counts" XXX - SG_ IDVS13_Axis2 : 31|8@0- (1,0) [-128|127] "counts" XXX - SG_ ImpDltVlcSamp14 : 39|16@0+ (1,0) [0|0] "" XXX - SG_ IDVS14_Axis1 : 39|8@0- (1,0) [-128|127] "counts" XXX - SG_ IDVS14_Axis2 : 47|8@0- (1,0) [-128|127] "counts" XXX - SG_ ImpDltVlcSamp15 : 55|16@0+ (1,0) [0|0] "" XXX - SG_ IDVS15_Axis1 : 55|8@0- (1,0) [-128|127] "counts" XXX - SG_ IDVS15_Axis2 : 63|8@0- (1,0) [-128|127] "counts" XXX - -BO_ 2150793216 Airbag_Impact_Data_2: 8 XXX - SG_ ImpDltVlcSamp4 : 7|16@0+ (1,0) [0|0] "" XXX - SG_ IDVS4_Axis1 : 7|8@0- (1,0) [-128|127] "counts" XXX - SG_ IDVS4_Axis2 : 15|8@0- (1,0) [-128|127] "counts" XXX - SG_ ImpDltVlcSamp5 : 23|16@0+ (1,0) [0|0] "" XXX - SG_ IDVS5_Axis1 : 23|8@0- (1,0) [-128|127] "counts" XXX - SG_ IDVS5_Axis2 : 31|8@0- (1,0) [-128|127] "counts" XXX - SG_ ImpDltVlcSamp6 : 39|16@0+ (1,0) [0|0] "" XXX - SG_ IDVS6_Axis1 : 39|8@0- (1,0) [-128|127] "counts" XXX - SG_ IDVS6_Axis2 : 47|8@0- (1,0) [-128|127] "counts" XXX - SG_ ImpDltVlcSamp7 : 55|16@0+ (1,0) [0|0] "" XXX - SG_ IDVS7_Axis1 : 55|8@0- (1,0) [-128|127] "counts" XXX - SG_ IDVS7_Axis2 : 63|8@0- (1,0) [-128|127] "counts" XXX - -BO_ 2150801408 Airbag_Impact_Data_3: 8 XXX - SG_ ImpDltVlcSamp8 : 7|16@0+ (1,0) [0|0] "" XXX - SG_ IDVS8_Axis1 : 7|8@0- (1,0) [-128|127] "counts" XXX - SG_ IDVS8_Axis2 : 15|8@0- (1,0) [-128|127] "counts" XXX - SG_ ImpDltVlcSamp9 : 23|16@0+ (1,0) [0|0] "" XXX - SG_ IDVS9_Axis1 : 23|8@0- (1,0) [-128|127] "counts" XXX - SG_ IDVS9_Axis2 : 31|8@0- (1,0) [-128|127] "counts" XXX - SG_ ImpDltVlcSamp10 : 39|16@0+ (1,0) [0|0] "" XXX - SG_ IDVS10_Axis1 : 39|8@0- (1,0) [-128|127] "counts" XXX - SG_ IDVS10_Axis2 : 47|8@0- (1,0) [-128|127] "counts" XXX - SG_ ImpDltVlcSamp11 : 55|16@0+ (1,0) [0|0] "" XXX - SG_ IDVS11_Axis1 : 55|8@0- (1,0) [-128|127] "counts" XXX - SG_ IDVS11_Axis2 : 63|8@0- (1,0) [-128|127] "counts" XXX - -BO_ 2150785024 Airbag_Impact_Data_1: 8 XXX - SG_ ImpDltVlcScal : 7|8@0+ (0.00245,0.706) [0.706|1.33075] "kph/cnt" XXX - SG_ AirbgAccelOrien : 10|3@0+ (45,0) [0|315] "deg" XXX - SG_ ImpDltVlcSamp1 : 23|16@0+ (1,0) [0|0] "" XXX - SG_ IDVS1_Axis1 : 23|8@0- (1,0) [-128|127] "counts" XXX - SG_ IDVS1_Axis2 : 31|8@0- (1,0) [-128|127] "counts" XXX - SG_ ImpDltVlcSamp2 : 39|16@0+ (1,0) [0|0] "" XXX - SG_ IDVS2_Axis1 : 39|8@0- (1,0) [-128|127] "counts" XXX - SG_ IDVS2_Axis2 : 47|8@0- (1,0) [-128|127] "counts" XXX - SG_ ImpDltVlcSamp3 : 55|16@0+ (1,0) [0|0] "" XXX - SG_ IDVS3_Axis1 : 55|8@0- (1,0) [-128|127] "counts" XXX - SG_ IDVS3_Axis2 : 63|8@0- (1,0) [-128|127] "counts" XXX - -BO_ 2151202816 Rear_Window_Defog_Inhibit: 5 XXX - SG_ RrWndDfgInhRq : 0|1@0+ (1,0) [0|1] "" XXX - SG_ RrWndDfgSwAtv : 1|1@0+ (1,0) [0|1] "" XXX - SG_ ILSSCommErr : 2|1@0+ (1,0) [0|1] "" XXX - SG_ IPSnsrRwSolrIntFltd : 3|1@0+ (1,0) [0|1] "" XXX - SG_ IPSnsrSolrAnglFltd : 4|1@0+ (1,0) [0|1] "" XXX - SG_ IPSnsrTpCvrTempFltd : 5|1@0+ (1,0) [0|1] "" XXX - SG_ AuxHtrAlwd : 6|1@0+ (1,0) [0|1] "" XXX - SG_ IPSnsrRwSolrInt : 15|8@0+ (3,0) [0|765] "W/m2" XXX - SG_ IPSnsrSolrAzmthAngl : 23|8@0+ (2,-180) [-180|330] "deg" XXX - SG_ IPSnsrSolrElvtnAngl : 31|8@0+ (1,0) [0|255] "deg" XXX - SG_ IPSnsrTpCvrTemp : 39|8@0+ (0.5,-40) [-40|87.5] "deg C" XXX - -BO_ 2150825984 Airbag_Indications: 6 XXX - SG_ FsnDrvStbltIC : 7|8@0+ (1,0) [0|0] "" XXX - SG_ FDSIC_IndPer : 3|4@0+ (1,0) [0|15] "" XXX - SG_ FDSIC_IndDC : 6|3@0+ (12.5,12.5) [12.5|100] "%" XXX - SG_ FDSIC_IO : 7|1@0+ (1,0) [0|1] "" XXX - SG_ FsnPsngStbltIC : 15|8@0+ (1,0) [0|0] "" XXX - SG_ FPSIC_IndPer : 11|4@0+ (1,0) [0|15] "" XXX - SG_ FPSIC_IndDtCyc : 14|3@0+ (12.5,12.5) [12.5|100] "%" XXX - SG_ FPSIC_IO : 15|1@0+ (1,0) [0|1] "" XXX - SG_ AirbgIC : 23|8@0+ (1,0) [0|0] "" XXX - SG_ AirbgICIndPer : 19|4@0+ (1,0) [0|15] "" XXX - SG_ AirbgICDutCyc : 22|3@0+ (12.5,12.5) [12.5|100] "%" XXX - SG_ AirbgICIO : 23|1@0+ (1,0) [0|1] "" XXX - SG_ FstnSndRwLtPsStbtInR : 25|2@0+ (1,0) [0|3] "" XXX - SG_ FstnSndRwCtPsStbtInR : 27|2@0+ (1,0) [0|3] "" XXX - SG_ FstnSndRwRtPsStbtInR : 29|2@0+ (1,0) [0|3] "" XXX - SG_ FsnDrStbAuxIR : 31|2@0+ (1,0) [0|3] "" XXX - SG_ FsnPsStbAuxIR : 34|3@0+ (1,0) [0|7] "" XXX - SG_ AirbgFldIO : 35|1@0+ (1,0) [0|1] "" XXX - SG_ SndRwStbltRdIndMd : 37|2@0+ (1,0) [0|3] "" XXX - SG_ FstnThrdRwCtPsStbtInR : 39|2@0+ (1,0) [0|3] "" XXX - SG_ FstnThrdRwRtPsStbtInR : 41|2@0+ (1,0) [0|3] "" XXX - SG_ FstnThrdRwLtPsStbtInR : 43|2@0+ (1,0) [0|3] "" XXX - SG_ SrvIntdPdstProtSysIO : 44|1@0+ (1,0) [0|1] "" XXX - SG_ PdstIntdProtSysDsbld : 45|1@0+ (1,0) [0|1] "" XXX - SG_ PdstIntdProtSysDplyd : 46|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151759872 Door_Lock_Command: 4 XXX - SG_ CntrlLckRqwExtActFun : 9|18@0+ (1,0) [0|0] "" XXX - SG_ CLRAF_Unl_Lk : 9|3@0+ (1,0) [0|7] "" XXX - SG_ CLRAF_FuelD : 16|1@0+ (1,0) [0|1] "" XXX - SG_ CLRAF_RrCls : 17|1@0+ (1,0) [0|1] "" XXX - SG_ CLRAF_Hd : 18|1@0+ (1,0) [0|1] "" XXX - SG_ CLRAF_RLD : 19|1@0+ (1,0) [0|1] "" XXX - SG_ CLRAF_RRD : 20|1@0+ (1,0) [0|1] "" XXX - SG_ CLRAF_PD : 21|1@0+ (1,0) [0|1] "" XXX - SG_ CLRAF_DD : 22|1@0+ (1,0) [0|1] "" XXX - SG_ CLRAF_ActFunc : 28|5@0+ (1,0) [0|31] "" XXX - SG_ CLRAF_UnandRsv3 : 29|1@0+ (1,0) [0|1] "" XXX - SG_ CLRAF_UnandRsv2 : 30|1@0+ (1,0) [0|1] "" XXX - SG_ CLRAF_UnandRsv1 : 31|1@0+ (1,0) [0|1] "" XXX - SG_ RrClsRelRq : 10|1@0+ (1,0) [0|1] "" XXX - -BO_ 2149974016 Content_Theft_Sensor_Status: 3 XXX - SG_ SrvAlrmSysIO : 0|1@0+ (1,0) [0|1] "" XXX - SG_ IntrSnsDisbld : 1|1@0+ (1,0) [0|1] "" XXX - SG_ AlrmTrgDrvDr : 3|1@0+ (1,0) [0|1] "" XXX - SG_ AlrmTrgPsngDr : 4|1@0+ (1,0) [0|1] "" XXX - SG_ AlrmTrgRrRtDr : 5|1@0+ (1,0) [0|1] "" XXX - SG_ AlrmTrgRrLftDr : 6|1@0+ (1,0) [0|1] "" XXX - SG_ AlrmTrigTonn : 7|1@0+ (1,0) [0|1] "" XXX - SG_ AlrmTrgTrnk : 8|1@0+ (1,0) [0|1] "" XXX - SG_ AlrmTrgTltSns : 9|1@0+ (1,0) [0|1] "" XXX - SG_ AlrmTrgIntMvmntSns : 10|1@0+ (1,0) [0|1] "" XXX - SG_ AlrmTrggrdBattRcnctd : 11|1@0+ (1,0) [0|1] "" XXX - SG_ AlrmTrgGlsBrkSns : 12|1@0+ (1,0) [0|1] "" XXX - SG_ AlrmTrgNonOffPM : 13|1@0+ (1,0) [0|1] "" XXX - SG_ AlrmTrigMidClsr : 14|1@0+ (1,0) [0|1] "" XXX - SG_ AlrmTrgdIO : 15|1@0+ (1,0) [0|1] "" XXX - SG_ AlrmStat : 18|3@0+ (1,0) [0|7] "" XXX - SG_ AlrmTrgHd : 21|1@0+ (1,0) [0|1] "" XXX - -BO_ 2151907328 Steering_Wheel_Control_Switches: 1 XXX - SG_ StrgWhlUnit1SwStat : 3|4@0+ (1,0) [0|15] "" XXX - SG_ StrgWhlUnit2SwStat : 7|4@0+ (1,0) [0|15] "" XXX - -BO_ 2150219776 Voice_Recognition_Status: 1 XXX - SG_ PhnSpRcgnRq : 1|2@0+ (1,0) [0|3] "" XXX - SG_ VcRecVcFdbckSt : 3|2@0+ (1,0) [0|3] "" XXX - -BO_ 2152685568 Radiomarks_Response: 8 XXX - SG_ RadBrdcstSrc : 3|4@0+ (1,0) [0|15] "" XXX - SG_ RadConInfReqSrc : 7|4@0+ (1,0) [0|15] "" XXX - SG_ RadConInfCmd : 11|4@0+ (1,0) [0|15] "" XXX - SG_ RadConInfID : 31|40@0+ (1,0) [0|1099511627775] "" XXX - -BO_ 2151874560 Vehicle_Theft_Notify_Reset_Req: 8 XXX - SG_ EhnSrvEngImmbCom : 0|57@0+ (1,0) [0|0] "" XXX - SG_ ESEIC_EngImmbRq : 0|1@0+ (1,0) [0|1] "" XXX - SG_ ESEIC_EngImRqPsw : 15|56@0+ (1,0) [0|1] "" XXX - SG_ RstVTDTmprDtctd : 1|1@0+ (1,0) [0|1] "" XXX - SG_ RstIllDrIdDevDtctd : 2|1@0+ (1,0) [0|1] "" XXX - SG_ RstDrIdDevLrnd : 3|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150268928 GPS_Date_and_Time_LS: 6 XXX - SG_ CldrYr_154 : 7|8@0+ (1,2000) [2000|2255] "year" XXX - SG_ CldrMth_154 : 11|4@0+ (1,0) [0|15] "" XXX - SG_ CldrDay_154 : 20|5@0+ (1,0) [0|31] "days" XXX - SG_ HrsGroup : 29|6@0+ (1,0) [0|0] "" XXX - SG_ Hrs : 28|5@0+ (1,0) [0|31] "h" XXX - SG_ HrsV : 29|1@0+ (1,0) [0|1] "" XXX - SG_ MinsGroup : 38|7@0+ (1,0) [0|0] "" XXX - SG_ Mins : 37|6@0+ (1,0) [0|63] "min" XXX - SG_ MinsV : 38|1@0+ (1,0) [0|1] "" XXX - SG_ SecGroup : 46|7@0+ (1,0) [0|0] "" XXX - SG_ Sec : 45|6@0+ (1,0) [0|63] "s" XXX - SG_ SecV : 46|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150137856 RFA_Status_LS: 3 XXX - SG_ FobPrevLrndIndOn : 0|1@0+ (1,0) [0|1] "" XXX - SG_ Ky_IdDevNotPrIO : 1|1@0+ (1,0) [0|1] "" XXX - SG_ FbProgCustActRqd : 2|1@0+ (1,0) [0|1] "" XXX - SG_ KeyInWrnIO : 3|1@0+ (1,0) [0|1] "" XXX - SG_ VehSecAtoLrnAtv : 4|1@0+ (1,0) [0|1] "" XXX - SG_ Ky_IdDevPrgmAuthReq : 5|1@0+ (1,0) [0|1] "" XXX - SG_ LMTTCPrsnOffStat : 6|1@0+ (1,0) [0|1] "" XXX - SG_ VehSecAtoLrnDlyTmr : 12|5@0+ (1,0) [0|31] "min" XXX - SG_ FldTpMotReq : 15|3@0+ (1,0) [0|7] "" XXX - SG_ RemCtrlFobNumForProgER : 19|4@0+ (1,0) [0|15] "" XXX - -BO_ 2151677952 Chime_Command: 5 XXX - SG_ SndChrs : 3|28@0+ (1,0) [0|0] "" XXX - SG_ SC_SndTne : 3|4@0+ (1,0) [0|15] "" XXX - SG_ SC_SndCdnPrd : 15|8@0+ (10,0) [0|2550] "ms" XXX - SG_ SC_NmofRp : 23|8@0+ (1,0) [0|255] "reps" XXX - SG_ SC_SndDutCyc : 31|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ SndLoc : 7|4@0+ (1,0) [0|0] "" XXX - SG_ SndLocRtRr : 4|1@0+ (1,0) [0|1] "" XXX - SG_ SndLocLftRr : 5|1@0+ (1,0) [0|1] "" XXX - SG_ SndLocPasFr : 6|1@0+ (1,0) [0|1] "" XXX - SG_ SndLocDrFr : 7|1@0+ (1,0) [0|1] "" XXX - SG_ SndPriority : 39|8@0+ (1,0) [0|255] "" XXX - -BO_ 2150776832 Airbag_Status: 6 XXX - SG_ ShfUlkBrToShftIndCtrl : 0|1@0+ (1,0) [0|1] "" XXX - SG_ ShftLkdBuStbltIndCtrl : 1|1@0+ (1,0) [0|1] "" XXX - SG_ SbItlkTrnsShftLvLkRd : 2|1@0+ (1,0) [0|1] "" XXX - SG_ MmryRclImpctDisRq : 3|1@0+ (1,0) [0|1] "" XXX - SG_ EvntEnbld : 4|1@0+ (1,0) [0|1] "" XXX - SG_ SftyMuteRd : 5|1@0+ (1,0) [0|1] "" XXX - SG_ HybVehHiVltInvDisRqd : 6|1@0+ (1,0) [0|1] "" XXX - SG_ HybImpSnsDsbld : 7|1@0+ (1,0) [0|1] "" XXX - SG_ SIREvntSychCntr : 23|16@0+ (1,0) [0|65535] "" XXX - SG_ FrPsngrStOccSnsngPriDat : 39|16@0+ (1,0) [0|39321] "" XXX - -BO_ 2150760448 Airbag_Impact_Data: 8 XXX - SG_ SIRDpl : 1|1@0+ (1,0) [0|1] "" XXX - SG_ NotPsSeatStat : 5|2@0+ (1,0) [0|3] "" XXX - SG_ NotDrvSeatStat : 7|2@0+ (1,0) [0|3] "" XXX - SG_ NotSecRowRtSeaOccStat : 9|2@0+ (1,0) [0|3] "" XXX - SG_ NotSndRwMdlSeatStat : 11|2@0+ (1,0) [0|3] "" XXX - SG_ NotSndRwRtSeatStat : 13|2@0+ (1,0) [0|3] "" XXX - SG_ NotSndRwLtSeatStat : 15|2@0+ (1,0) [0|3] "" XXX - SG_ NotEventStat : 17|2@0+ (1,0) [0|3] "" XXX - SG_ NotSecRowLeSeaOccStat : 25|2@0+ (1,0) [0|3] "" XXX - SG_ NotSecRowCtSeaOccStat : 27|2@0+ (1,0) [0|3] "" XXX - SG_ NotiFrntPasSeatOccSta : 34|3@0+ (1,0) [0|7] "" XXX - SG_ NoEvDeLoSt : 46|7@0+ (1,0) [0|0] "" XXX - SG_ NEDLSSdCrtnArbgDpld : 40|1@0+ (1,0) [0|1] "" XXX - SG_ NEDLSRtSdArbgDld : 41|1@0+ (1,0) [0|1] "" XXX - SG_ NEDLSLtSdArbgDld : 42|1@0+ (1,0) [0|1] "" XXX - SG_ NEDLSPaFrSt2De : 43|1@0+ (1,0) [0|1] "" XXX - SG_ NEDLSPaFrSt1De : 44|1@0+ (1,0) [0|1] "" XXX - SG_ NEDLSDrFrSt2De : 45|1@0+ (1,0) [0|1] "" XXX - SG_ NEDLSDrFrSt1De : 46|1@0+ (1,0) [0|1] "" XXX - SG_ NoEvSevSt : 54|7@0+ (1,0) [0|0] "" XXX - SG_ NESSRoSevSt : 48|1@0+ (1,0) [0|1] "" XXX - SG_ NESSRiSiSevSt : 49|1@0+ (1,0) [0|1] "" XXX - SG_ NESSReImpSevSt : 50|1@0+ (1,0) [0|1] "" XXX - SG_ NESSLeSiSevSt : 51|1@0+ (1,0) [0|1] "" XXX - SG_ NESSFrImpSt2SevSt : 52|1@0+ (1,0) [0|1] "" XXX - SG_ NESSFrImpSt1SevSt : 53|1@0+ (1,0) [0|1] "" XXX - SG_ NESSFrImpPreSevSt : 54|1@0+ (1,0) [0|1] "" XXX - SG_ NotiEventCount : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 2155872256 Fuel_Information: 6 XXX - SG_ FlLvlPctGroup : 0|9@0+ (1,0) [0|0] "" XXX - SG_ FlLvlPctV : 0|1@0+ (1,0) [0|1] "" XXX - SG_ FlLvlPct : 15|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ FlInjRlCtRstOcc : 1|1@0+ (1,0) [0|1] "" XXX - SG_ FuelFltChgNwIO : 2|1@0+ (1,0) [0|1] "" XXX - SG_ DrvStyPerfMdCsCrStVal : 5|3@0+ (1,0) [0|7] "" XXX - SG_ DrvStyPerfMdCsStAvl : 6|1@0+ (1,0) [0|1] "" XXX - SG_ RdWhlAngGroup : 23|8@0+ (1,0) [0|0] "" XXX - SG_ RdWhlAng : 22|7@0+ (0.703125,-45) [-45|44.296875] "deg" XXX - SG_ RdWhlAngV : 23|1@0+ (1,0) [0|1] "" XXX - SG_ VehPitchAngleGroup : 31|8@0+ (1,0) [0|0] "" XXX - SG_ VehPitchAngle : 30|7@0+ (0.703125,-45) [-45|44.296875] "deg" XXX - SG_ VehPitchAngleV : 31|1@0+ (1,0) [0|1] "" XXX - SG_ FlInjRlCt : 39|16@0+ (3.05176E-005,0) [0|1.999970916] "liters" XXX - -BO_ 2156175360 Display_Measurement_System_LS: 1 XXX - SG_ DispMeasSysExt : 1|2@0+ (1,0) [0|3] "" XXX - SG_ DispMeasSys : 2|1@0+ (1,0) [0|1] "" XXX - SG_ NtVsnSysEnbld : 3|1@0+ (1,0) [0|1] "" XXX - -BO_ 2149859328 System_Power_Mode_Backup_LS: 1 XXX - SG_ SysBkupPwrMdEn : 2|1@0+ (1,0) [0|1] "" XXX - SG_ SysBkUpPwrMdGroup : 3|4@0+ (1,0) [0|0] "" XXX - SG_ SysBkUpPwrMd : 1|2@0+ (1,0) [0|3] "" XXX - SG_ SysBkUpPwrMdV : 3|1@0+ (1,0) [0|1] "" XXX - -BO_ 2158854144 ODIAction_IPC_LS: 8 XXX - SG_ ODIActn_IPC : 5|62@0+ (1,0) [0|0] "" XXX - SG_ ODIAI_DaTy : 5|6@0+ (1,0) [0|63] "" XXX - SG_ ODIAI_FUCID : 15|8@0+ (1,0) [0|255] "" XXX - SG_ ODIAI_ActnID : 23|8@0+ (1,0) [0|255] "" XXX - SG_ ODIAI_DspMID : 31|8@0+ (1,0) [0|255] "" XXX - SG_ ODIAI_ActnVal : 39|32@0+ (1,0) [0|4294967295] "" XXX - -BO_ 2158837760 ODIAction_AuxIP_LS: 8 XXX - SG_ ODIActn_AxIP : 5|62@0+ (1,0) [0|0] "" XXX - SG_ ODIAA_DaTy : 5|6@0+ (1,0) [0|63] "" XXX - SG_ ODIAA_FUCID : 15|8@0+ (1,0) [0|255] "" XXX - SG_ ODIAA_ActnID : 23|8@0+ (1,0) [0|255] "" XXX - SG_ ODIAA_DspMID : 31|8@0+ (1,0) [0|255] "" XXX - SG_ ODIAA_ActnVal : 39|32@0+ (1,0) [0|4294967295] "" XXX - -BO_ 2159091712 ODI_IPC_2_TEL_LS: 8 XXX - SG_ ODI_IPC2TEL : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2154561536 Vehicle_Odo_LS: 5 XXX - SG_ VehOdoGroup : 7|40@0+ (1,0) [0|0] "" XXX - SG_ VehOdo : 7|32@0+ (0.015625,0) [0|67108863.984375] "km" XXX - SG_ VehOdoV : 32|1@0+ (1,0) [0|1] "" XXX - -BO_ 2149908480 Brake_Pedal_Status_LS: 2 XXX - SG_ BrkPedInitTrvlAchvdStat : 1|2@0+ (1,0) [0|0] "" XXX - SG_ BrkPedTrvlAchvdV : 0|1@0+ (1,0) [0|1] "" XXX - SG_ BrkPedTrvlAchvd : 1|1@0+ (1,0) [0|1] "" XXX - SG_ BrkPdlModTrvlGroup : 3|2@0+ (1,0) [0|0] "" XXX - SG_ BrkPdlModTrvl : 2|1@0+ (1,0) [0|1] "" XXX - SG_ BrkPdlModTrvlV : 3|1@0+ (1,0) [0|1] "" XXX - SG_ BrkPdlPos : 15|8@0+ (0.392157,0) [0|100.000035] "% full" XXX - -BO_ 2151268352 Column_Lock_Status: 1 XXX - SG_ ClmnLckTT : 1|2@0+ (1,0) [0|3] "" XXX - -BO_ 2150604800 Right_Rear_Door_Status: 1 XXX - SG_ RRDoorAjarSwAct : 0|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150588416 Passenger_Door_Status_LS: 1 XXX - SG_ PDAjrSwAtv : 0|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150596608 Left_Rear_Door_Status: 1 XXX - SG_ RLDoorAjarSwAct : 0|1@0+ (1,0) [0|1] "" XXX - -BO_ 2155036672 Climate_Control_General_Status: 6 XXX - SG_ ACCompNormLdGroup : 0|9@0+ (1,0) [0|0] "" XXX - SG_ ACCompNormLdV : 0|1@0+ (1,0) [0|1] "" XXX - SG_ ACCompNormLd : 15|8@0+ (0.1,0) [0|25.5] "l/min" XXX - SG_ ACCmEngRunReq : 2|1@0+ (1,0) [0|1] "" XXX - SG_ ACCmpsrFldOn : 3|1@0+ (1,0) [0|1] "" XXX - SG_ ACCompModReq : 5|2@0+ (1,0) [0|3] "" XXX - SG_ ClmtCtrlTrgtTemp : 17|10@0+ (0.1,-10) [-10|92.3] "deg C" XXX - -BO_ 2150424576 Engine_Information_3_LS: 8 XXX - SG_ TrnsEngdStateGroup : 2|3@0+ (1,0) [0|0] "" XXX - SG_ TrnsEngdState : 1|2@0+ (1,0) [0|3] "" XXX - SG_ TrnsEngdStateV : 2|1@0+ (1,0) [0|1] "" XXX - SG_ ACRfHiSdFldPrsGroup : 3|20@0+ (1,0) [0|0] "" XXX - SG_ ACRfHiSdFldPrsV : 3|1@0+ (1,0) [0|1] "" XXX - SG_ ACRfHiSdFldPrs : 23|8@0+ (14,0) [0|3570] "kPaG" XXX - SG_ ACCompCmnd : 4|1@0+ (1,0) [0|1] "" XXX - SG_ RrAxlELSDCplLwResGroup : 5|46@0+ (1,0) [0|0] "" XXX - SG_ RrAxlELSDCplLwResV : 5|1@0+ (1,0) [0|1] "" XXX - SG_ RrAxlELSDCplLwRes : 47|8@0+ (10,0) [0|2550] "Nm" XXX - SG_ EngAirIntBstPrGroup : 6|39@0+ (1,0) [0|0] "" XXX - SG_ EngAirIntBstPrV : 6|1@0+ (1,0) [0|1] "" XXX - SG_ EngAirIntBstPr : 39|8@0- (1,0) [-128|127] "kPaG" XXX - SG_ ExtHlStrAssCsStAvl : 7|1@0+ (1,0) [0|1] "" XXX - SG_ TrnsRngInhbtStat : 10|3@0+ (1,0) [0|7] "" XXX - SG_ DrvtShftCntrlTrgtGear : 14|4@0+ (1,0) [0|15] "" XXX - SG_ ACCmpNrmLdGrdAld : 31|8@0+ (0.1,0) [0|25.5] "dm3/m/s" XXX - SG_ EngTrqDrRqdExtRngGroup : 52|13@0+ (1,0) [0|0] "" XXX - SG_ EngTrqDrRqdExtRng : 51|12@0+ (0.5,-848) [-848|1199.5] "Nm" XXX - SG_ EngTrqDrRqdExtRngV : 52|1@0+ (1,0) [0|1] "" XXX - SG_ ExtHlStrAssCsCrStVal : 55|3@0+ (1,0) [0|7] "" XXX - -BO_ 2150416384 Engine_Information_2_LS: 8 XXX - SG_ EngBstPrsIndGroup : 0|33@0+ (1,0) [0|0] "" XXX - SG_ EngBstPrsIndV : 0|1@0+ (1,0) [0|1] "" XXX - SG_ EngBstPrsInd : 39|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ VaccBoostFailure : 2|1@0+ (1,0) [0|1] "" XXX - SG_ GenFld : 3|1@0+ (1,0) [0|1] "" XXX - SG_ EngSpdLmtnMdAct : 4|1@0+ (1,0) [0|1] "" XXX - SG_ PTWrmgWtToShftIO : 5|1@0+ (1,0) [0|1] "" XXX - SG_ EngNEmsnsRelMalfAct : 6|1@0+ (1,0) [0|1] "" XXX - SG_ EngCstFlCutAct : 7|1@0+ (1,0) [0|1] "" XXX - SG_ EngRunAtv : 8|1@0+ (1,0) [0|1] "" XXX - SG_ EngIdlAtv : 11|1@0+ (1,0) [0|1] "" XXX - SG_ VehTopSpdLmtMdAct : 13|1@0+ (1,0) [0|1] "" XXX - SG_ EngCylDeactMd : 15|2@0+ (1,0) [0|3] "" XXX - SG_ TransEstGearGroup : 20|5@0+ (1,0) [0|0] "" XXX - SG_ TransEstGear : 19|4@0+ (1,0) [0|15] "" XXX - SG_ TransEstGearV : 20|1@0+ (1,0) [0|1] "" XXX - SG_ EngTrqActExtRngGroup : 21|46@0+ (1,0) [0|0] "" XXX - SG_ EngTrqActExtRngV : 21|1@0+ (1,0) [0|1] "" XXX - SG_ EngTrqActExtRng : 51|12@0+ (0.5,-848) [-848|1199.5] "Nm" XXX - SG_ EngVDA : 22|1@0+ (1,0) [0|1] "" XXX - SG_ TrnsVDA : 23|1@0+ (1,0) [0|1] "" XXX - SG_ EngCoolFanSpd : 31|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ VehTopSpdLmtArbVal : 47|8@0+ (2,0) [0|510] "km / h" XXX - SG_ EngSpdStat : 53|2@0+ (1,0) [0|3] "" XXX - SG_ RmVhStrtEngRng : 54|1@0+ (1,0) [0|1] "" XXX - SG_ TrnCrpMdAtv : 55|1@0+ (1,0) [0|1] "" XXX - -BO_ 2150408192 Engine_Information_1_LS: 8 XXX - SG_ TrnsSftMdStat : 2|3@0+ (1,0) [0|7] "" XXX - SG_ ThrPosGroup : 3|36@0+ (1,0) [0|0] "" XXX - SG_ ThrPosV : 3|1@0+ (1,0) [0|1] "" XXX - SG_ ThrPos : 39|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ AccActPosGroup : 4|45@0+ (1,0) [0|0] "" XXX - SG_ AccActPosV : 4|1@0+ (1,0) [0|1] "" XXX - SG_ AccActPos : 47|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ ElcRngSelDrvAct : 5|1@0+ (1,0) [0|1] "" XXX - SG_ TmpDrvrShftCtlAct : 6|1@0+ (1,0) [0|1] "" XXX - SG_ AccPdlOvrrdAtv : 7|1@0+ (1,0) [0|1] "" XXX - SG_ TrnShftPtrnActStat : 10|3@0+ (1,0) [0|7] "" XXX - SG_ TransTUDMdStat : 12|2@0+ (1,0) [0|3] "" XXX - SG_ Eng12vStrtrMtrCmmdOn : 13|1@0+ (1,0) [0|1] "" XXX - SG_ EngRunng : 14|1@0+ (1,0) [0|1] "" XXX - SG_ TrnsShftLvrPosGroup : 15|48@0+ (1,0) [0|0] "" XXX - SG_ TrnsShftLvrPosV : 15|1@0+ (1,0) [0|1] "" XXX - SG_ TrnsShftLvrPos : 51|4@0+ (1,0) [0|15] "" XXX - SG_ EngSpd : 23|16@0+ (0.25,0) [0|16383.75] "rpm" XXX - SG_ AutoTransComndGear : 55|4@0+ (1,0) [0|15] "" XXX - SG_ CrsCntEnbld : 56|1@0+ (1,0) [0|1] "" XXX - SG_ CltStartSwAtvGroup : 58|2@0+ (1,0) [0|0] "" XXX - SG_ CltStartSwAtv : 57|1@0+ (1,0) [0|1] "" XXX - SG_ CltStartSwAtvV : 58|1@0+ (1,0) [0|1] "" XXX - SG_ TopTrvlCltchSwActGroup : 60|2@0+ (1,0) [0|0] "" XXX - SG_ TopTrvlCltchSwAct : 59|1@0+ (1,0) [0|1] "" XXX - SG_ TopTrvlCltchSwActV : 60|1@0+ (1,0) [0|1] "" XXX - SG_ AdptPsngrSeatStng : 63|3@0+ (1,0) [0|7] "" XXX - -BO_ 2155954176 Climate_Control_Basic_Status_LS: 4 XXX - SG_ ACHtIdleBstLevReq : 1|2@0+ (1,0) [0|3] "" XXX - SG_ ClimCtrlAftBlowModActv : 2|1@0+ (1,0) [0|1] "" XXX - SG_ AirCndActIO : 5|1@0+ (1,0) [0|1] "" XXX - SG_ ClmCntlExtDefActIO : 6|1@0+ (1,0) [0|1] "" XXX - SG_ ClntCircPmpRq : 7|1@0+ (1,0) [0|1] "" XXX - SG_ ClmCntFrBlwFnSp : 15|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ AirCndCmptLdEst : 23|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ ClmCntRrBlwFnSp : 31|8@0+ (0.392157,0) [0|100.000035] "%" XXX - -BO_ 2153971712 Driver_Door_Status: 1 XXX - SG_ LftglsAjrSwAct : 1|1@0+ (1,0) [0|1] "" XXX - SG_ LftglsRelSwAct : 2|1@0+ (1,0) [0|1] "" XXX - SG_ DDAjrSwAtvGroup : 7|8@0+ (1,0) [0|0] "" XXX - SG_ DDAjrSwAtv : 0|1@0+ (1,0) [0|1] "" XXX - SG_ DDAjrSwAtvM : 7|1@0+ (1,0) [0|1] "" XXX - -BO_ 2149875712 Battery_Voltage: 7 XXX - SG_ BatVltGroup : 0|17@0+ (1,0) [0|0] "" XXX - SG_ BatVltV : 0|1@0+ (1,0) [0|1] "" XXX - SG_ BatVlt : 23|8@0+ (0.1,3) [3|28.5] "volts" XXX - SG_ BatSaverIO : 1|1@0+ (1,0) [0|1] "" XXX - SG_ SrvBattChrgSysIO : 2|1@0+ (1,0) [0|1] "" XXX - SG_ BatSOCGroup : 3|28@0+ (1,0) [0|0] "" XXX - SG_ BatSOCV : 3|1@0+ (1,0) [0|1] "" XXX - SG_ BatSOC : 31|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ BattStOfChrgCrtyLow : 4|1@0+ (1,0) [0|1] "" XXX - SG_ IntlgntBattSnsFldIO : 5|1@0+ (1,0) [0|1] "" XXX - SG_ BattStOfChrgLowIO : 6|1@0+ (1,0) [0|1] "" XXX - SG_ DCCnvStblznErrIO : 7|1@0+ (1,0) [0|1] "" XXX - SG_ EnrgMgtLdShdRq : 11|4@0+ (1,0) [0|15] "" XXX - SG_ BattVltIRq : 13|2@0+ (1,0) [0|3] "" XXX - SG_ PwrMdOffBattSOC : 39|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ BattCrntFltrd : 47|8@0- (0.5,0) [-64|63.5] "A" XXX - SG_ BatSvrMdSevLvl : 55|8@0+ (1,0) [0|255] "" XXX - -BO_ 2151186432 Auto_High_Beam_Status: 1 XXX - SG_ AutoBmSlctStat : 1|2@0+ (1,0) [0|3] "" XXX - SG_ CtLghtDet : 2|1@0+ (1,0) [0|1] "" XXX - SG_ AutoHgBmCtrlInOn : 3|1@0+ (1,0) [0|1] "" XXX - -BO_ 2149629952 Lighting_Status_LS: 5 XXX - SG_ OtsdAmbtLtLvlStatGroup : 0|23@0+ (1,0) [0|0] "" XXX - SG_ OtsdAmbtLtLvlStatV : 0|1@0+ (1,0) [0|1] "" XXX - SG_ OtsdAmbtLtLvlStat : 27|2@0+ (1,0) [0|3] "" XXX - SG_ DRLAct : 1|1@0+ (1,0) [0|1] "" XXX - SG_ HazSwAtv : 2|1@0+ (1,0) [0|1] "" XXX - SG_ PrkLtLeftIO : 3|1@0+ (1,0) [0|1] "" XXX - SG_ PrkLtRightIO : 4|1@0+ (1,0) [0|1] "" XXX - SG_ TrnSwAct : 6|2@0+ (1,0) [0|3] "" XXX - SG_ FrFogLmpsAct : 7|1@0+ (1,0) [0|1] "" XXX - SG_ PrkLtLeftOn : 8|1@0+ (1,0) [0|1] "" XXX - SG_ FrFgLtIO : 9|1@0+ (1,0) [0|1] "" XXX - SG_ AutoLtsInactIO : 10|1@0+ (1,0) [0|1] "" XXX - SG_ AutoLtsActIO : 11|1@0+ (1,0) [0|1] "" XXX - SG_ RrFgLtIO : 12|1@0+ (1,0) [0|1] "" XXX - SG_ HiBmIO : 13|1@0+ (1,0) [0|1] "" XXX - SG_ PrkLtIO : 14|1@0+ (1,0) [0|1] "" XXX - SG_ BrkLtsAtv : 15|1@0+ (1,0) [0|1] "" XXX - SG_ FlToPsSwAtv : 16|1@0+ (1,0) [0|1] "" XXX - SG_ RevLmpAtv : 17|1@0+ (1,0) [0|1] "N/A" XXX - SG_ PrkngLtsAct : 18|1@0+ (1,0) [0|1] "" XXX - SG_ RrFogLmpsAct : 19|1@0+ (1,0) [0|1] "" XXX - SG_ HiBmReqd : 20|1@0+ (1,0) [0|1] "" XXX - SG_ AutoBmSlctAllwd : 21|1@0+ (1,0) [0|1] "" XXX - SG_ PrkLtRightOn : 22|1@0+ (1,0) [0|1] "" XXX - SG_ SrvlnceMdAct : 23|1@0+ (1,0) [0|1] "" XXX - SG_ RtTrnLmpAtv : 25|2@0+ (1,0) [0|3] "" XXX - SG_ LftTrnLmpAtv : 29|2@0+ (1,0) [0|3] "" XXX - SG_ MainLghtSw : 31|2@0+ (1,0) [0|3] "N/A" XXX - SG_ HdlmpBmSelectStat : 33|2@0+ (1,0) [0|3] "" XXX - -BO_ 2149646336 Vehicle_Speed_Information: 8 XXX - SG_ VehSpdAvgDrvnGroup : 7|16@0+ (1,0) [0|0] "" XXX - SG_ VehSpdAvgDrvn : 6|15@0+ (0.015625,0) [0|511.984375] "km / h" XXX - SG_ VehSpdAvgDrvnV : 7|1@0+ (1,0) [0|1] "" XXX - SG_ DstRolCntAvgDrnRstOc : 21|1@0+ (1,0) [0|1] "" XXX - SG_ DistRollCntAvgDrvnGroup : 22|15@0+ (1,0) [0|0] "" XXX - SG_ DistRollCntAvgDrvn : 20|13@0+ (0.125,0) [0|1023.875] "m" XXX - SG_ DistRollCntAvgDrvnV : 22|1@0+ (1,0) [0|1] "" XXX - SG_ VehSpdAvgDrvnSrc : 23|1@0+ (1,0) [0|1] "" XXX - SG_ VehSpdAvgNDrvnGroup : 38|17@0+ (1,0) [0|0] "" XXX - SG_ VehSpdAvgNDrvn : 38|15@0+ (0.015625,0) [0|511.984375] "km / h" XXX - SG_ VehSpdAvgNDrvnV : 54|1@0+ (1,0) [0|1] "" XXX - SG_ DstRolCntAvgNonDrvnGroup : 39|32@0+ (1,0) [0|0] "" XXX - SG_ DstRolCntAvgNonDrvnV : 39|1@0+ (1,0) [0|1] "" XXX - SG_ DstRolCntAvgNonDrvn : 52|13@0+ (0.125,0) [0|1023.875] "m" XXX - SG_ DstRolCntAvNDrRstOc : 53|1@0+ (1,0) [0|1] "" XXX - SG_ DistRollCntAvgDrvnSrc : 55|1@0+ (1,0) [0|1] "" XXX - -BO_ 2154053632 Dimming_Information_LS: 3 XXX - SG_ IntDimNtPnlAtv : 0|1@0+ (1,0) [0|1] "" XXX - SG_ DispNtSchmAtv : 1|1@0+ (1,0) [0|1] "" XXX - SG_ CargoLmpActIO : 2|1@0+ (1,0) [0|1] "" XXX - SG_ IntDimLvl : 15|8@0+ (0.392157,0) [0|100.000035] "%" XXX - SG_ IntDimDspLvl : 23|8@0+ (0.392157,0) [0|100.000035] "%" XXX - -BO_ 2149851136 System_Power_Mode_LS: 1 XXX - SG_ SysPwrMdGroup : 2|3@0+ (1,0) [0|0] "" XXX - SG_ SysPwrMd : 1|2@0+ (1,0) [0|3] "" XXX - SG_ SysPwrMdV : 2|1@0+ (1,0) [0|1] "" XXX - SG_ KylsStrtAuthRq : 3|1@0+ (1,0) [0|1] "" XXX - -BO_ 2159124480 ODI_AuxIP_2_TEL_LS: 8 XXX - SG_ ODI_AxIP2TEL : 7|64@0+ (1,0) [0|1.84467440737096E+019] "" XXX - -BO_ 2151530496 TPM_Display_Commands: 6 XXX - SG_ TPMTrLrnMdCmplt : 0|1@0+ (1,0) [0|1] "" XXX - SG_ TrPrsMntrAtLocFld : 1|1@0+ (1,0) [0|1] "" XXX - SG_ TrPrsMntrTrLdStat : 3|2@0+ (1,0) [0|3] "" XXX - SG_ TireTrdTmpStat : 6|3@0+ (1,0) [0|7] "" XXX - SG_ TrFrntAxlPresStat : 9|2@0+ (1,0) [0|3] "" XXX - SG_ TrRrAxlPresStat : 11|2@0+ (1,0) [0|3] "" XXX - SG_ WintTrRecIndOn : 12|1@0+ (1,0) [0|1] "" XXX - SG_ TrPrsMntrFld : 13|1@0+ (1,0) [0|1] "" XXX - SG_ TireLocatnWarnEn : 15|1@0+ (1,0) [0|1] "" XXX - SG_ HVChgSyChgLvPfStRmt1 : 18|3@0+ (1,0) [0|7] "" XXX - SG_ StTODChrgTmpOvrdRmt1 : 20|2@0+ (1,0) [0|3] "" XXX - SG_ PrtyChrgRqRmt1 : 22|2@0+ (1,0) [0|3] "" XXX - SG_ OfBrdHVCVhCsChRqRmt1 : 23|1@0+ (1,0) [0|1] "" XXX - SG_ HVBatTmBsDlChStRqRmt1 : 28|21@0+ (1,0) [0|0] "" XXX - SG_ HVBTBDCSRR1_DChHStRq : 28|5@0+ (1,0) [0|31] "hr" XXX - SG_ HVBTBDCSRR1_DChSlSRq : 35|4@0+ (1,0) [0|15] "" XXX - SG_ HVBTBDCSRR1_DChDStRq : 39|4@0+ (1,0) [0|15] "" XXX - SG_ HVBTBDCSRR1_DChMHSRq : 45|6@0+ (1,0) [0|63] "min" XXX - SG_ HVBTBDCSRR1_DChSnSRq : 47|2@0+ (1,0) [0|3] "" XXX - SG_ HVBatTmBsChgMdRqRmt1 : 31|3@0+ (1,0) [0|7] "" XXX - - - -BA_DEF_ "UseGMParameterIDs" INT 0 0; -BA_DEF_ "ProtocolType" STRING ; -BA_DEF_ "BusType" STRING ; -BA_DEF_DEF_ "UseGMParameterIDs" 1; -BA_DEF_DEF_ "ProtocolType" "GMLAN"; -BA_DEF_DEF_ "BusType" ""; -BA_ "ProtocolType" "GMLAN"; -BA_ "BusType" "CAN"; - diff --git a/opendbc/gm_global_a_object.dbc b/opendbc/gm_global_a_object.dbc index 1532e90dadac90..4643a640ac85f4 100644 --- a/opendbc/gm_global_a_object.dbc +++ b/opendbc/gm_global_a_object.dbc @@ -37,7 +37,7 @@ BU_: K109_FCM B233B_LRR NEO VIS_FO VIS2_FO K124_ASCM Vector__XXX EOCM_F_FO EOCM2 VAL_TABLE_ RangeMode 1 "Active" 0 "Inactive" ; VAL_TABLE_ TrkConf 3 "Confident" 2 "Speculative" 1 "Highly speculative" 0 "Invalid" ; VAL_TABLE_ TrkMeasStatus 3 "Measured current cycle" 2 "Latent track not detected" 1 "New object" 0 "No object" ; -VAL_TABLE_ TrkDynProp 4 "Moving in opposite direction" 3 "Moving in same direction" 2 "Has moved but currenty stopped" 1 "Has never moved," 0 "Unkown" ; +VAL_TABLE_ TrkDynProp 4 "Moving in opposite direction" 3 "Moving in same direction" 2 "Has moved but currently stopped" 1 "Has never moved," 0 "Unknown" ; VAL_TABLE_ FrntVsnInPthVehBrkNwSt 10 "Active" 5 "Inactive" ; VAL_TABLE_ FrntVsnClostPedBrkNwSt 10 "Active" 5 "Inactive" ; VAL_TABLE_ LaneSnsLLnPosValid 1 "Invalid" 0 "Valid" ; diff --git a/opendbc/gm_global_a_powertrain.dbc b/opendbc/gm_global_a_powertrain.dbc index 3caf60ce4a01ec..948a519b03b5f2 100644 --- a/opendbc/gm_global_a_powertrain.dbc +++ b/opendbc/gm_global_a_powertrain.dbc @@ -116,7 +116,7 @@ BO_ 388 PSCMStatus: 8 K43_PSCM SG_ LKATorqueDelivered : 18|11@0- (0.01,0) [0|1] "" NEO SG_ LKATotalTorqueDelivered : 2|11@0- (0.01,0) [-10.24|10.23] "Nm" NEO -BO_ 417 AcceleratorPedal: 8 XXX +BO_ 417 AcceleratorPedal: 7 XXX SG_ AcceleratorPedal : 55|8@0+ (1,0) [0|0] "" NEO BO_ 451 GasAndAcc: 8 XXX @@ -170,7 +170,7 @@ BO_ 840 EBCMWheelSpdFront: 4 K17_EBCM SG_ FLWheelSpd : 7|16@0+ (0.0311,0) [0|255] "km/h" NEO SG_ FRWheelSpd : 23|16@0+ (0.0311,0) [0|255] "km/h" NEO -BO_ 842 EBCMWheelSpdRear: 4 K17_EBCM +BO_ 842 EBCMWheelSpdRear: 5 K17_EBCM SG_ RLWheelSpd : 7|16@0+ (0.0311,0) [0|255] "km/h" NEO SG_ RRWheelSpd : 23|16@0+ (0.0311,0) [0|255] "km/h" NEO @@ -195,7 +195,7 @@ BO_ 1033 ASCMKeepAlive: 7 NEO BO_ 1034 ASCM_40A: 7 K124_ASCM BO_ 1217 ECMEngineCoolantTemp: 8 K20_ECM - SG_ EngineCoolantTemp : 23|8@0+ (1,-40) [0|0] "°C" NEO + SG_ EngineCoolantTemp : 23|8@0+ (1,-40) [0|0] "C" NEO BO_ 1249 VIN_Part2: 8 K20_ECM SG_ VINPart2 : 7|64@0+ (1,0) [0|0] "" NEO @@ -241,7 +241,7 @@ VAL_ 481 LKAButton 1 "Active" 0 "Inactive" ; VAL_ 481 ACCButtons 6 "Cancel" 5 "Main" 3 "Set" 2 "Resume" 1 "None" ; VAL_ 481 DriveModeButton 1 "Active" 0 "Inactive" ; VAL_ 452 CruiseState 4 "Standstill" 3 "Faulted" 1 "Active" 0 "Off" ; -VAL_ 309 PRNDL 3 "Reverse" 2 "Drive" 1 "Neutral" 0 "Park" ; +VAL_ 309 PRNDL 3 "R" 2 "D" 1 "N" 0 "P" ; VAL_ 309 ESPButton 1 "Active" 0 "Inactive" ; VAL_ 384 LKASteeringCmdActive 1 "Active" 0 "Inactive" ; VAL_ 880 ACCLeadCar 1 "Present" 0 "Not Present" ; diff --git a/opendbc/honda_accord_lx15t_2018_can_generated.dbc b/opendbc/honda_accord_lx15t_2018_can_generated.dbc index 6159efb0e8144f..25b4c15a356f11 100644 --- a/opendbc/honda_accord_lx15t_2018_can_generated.dbc +++ b/opendbc/honda_accord_lx15t_2018_can_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _bosch_2018.dbc starts here" +CM_ "Imported file _bosch_2018.dbc starts here"; VERSION "" @@ -37,6 +37,12 @@ NS_ : BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB +BO_ 148 KINEMATICS: 8 XXX + SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + BO_ 228 STEERING_CONTROL: 5 EON SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS @@ -45,6 +51,14 @@ BO_ 228 STEERING_CONTROL: 5 EON SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS +BO_ 229 BOSCH_SUPPLEMENTAL_1: 8 XXX + SG_ SET_ME_X04 : 0|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X00 : 8|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X80 : 16|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X10 : 24|8@1+ (1,0) [0|255] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + BO_ 232 BRAKE_HOLD: 7 XXX SG_ XMISSION_SPEED : 7|14@0- (1,0) [1|0] "" XXX SG_ COMPUTER_BRAKE : 39|16@0+ (1,0) [0|0] "" XXX @@ -52,17 +66,12 @@ BO_ 232 BRAKE_HOLD: 7 XXX SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" XXX -BO_ 304 GAS_PEDAL_2: 8 PCM - SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - BO_ 330 STEERING_SENSORS: 8 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON - SG_ STEER_ANGLE_OFFSET : 39|8@0- (-0.1,0) [-128|127] "deg" EON + SG_ STEER_SENSOR_STATUS_1 : 34|1@0+ (1,0) [0|1] "" EON + SG_ STEER_SENSOR_STATUS_2 : 33|1@0+ (1,0) [0|1] "" EON + SG_ STEER_SENSOR_STATUS_3 : 32|1@0+ (1,0) [0|1] "" EON SG_ STEER_WHEEL_ANGLE : 47|16@0- (-0.1,0) [-500|500] "deg" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON @@ -89,10 +98,11 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON + SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON + SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON @@ -104,6 +114,13 @@ BO_ 420 VSA_STATUS: 8 VSA SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON +BO_ 427 STEER_MOTOR_TORQUE: 3 EPS + SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON + SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON + SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON + BO_ 450 EPB_STATUS: 8 EPB SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" EON SG_ EPB_STATE : 29|2@0+ (1,0) [0|3] "" EON @@ -118,15 +135,26 @@ BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 479 ACC_CONTROL: 8 EON - SG_ SET_TO_1 : 20|5@0+ (1,0) [0|1] "" PCM + SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX - SG_ RELATED_TO_GAS : 7|7@0+ (1,0) [0|69] "" XXX - SG_ GAS_COMMAND : 0|9@0+ (1,0) [0|1] "" PCM - SG_ GAS_BRAKE : 31|14@0- (1,0) [0|1] "" XXX - SG_ ZEROS_BOH : 33|18@0+ (1,0) [100|100] "" XXX + SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX + SG_ ACCEL_COMMAND : 31|11@0- (0.01,0) [0|0] "m/s2" XXX + SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_PREPARE : 43|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 +BO_ 490 VEHICLE_DYNAMICS: 8 VSA + SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + BO_ 495 ACC_CONTROL_ON: 8 XXX SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX @@ -144,6 +172,82 @@ BO_ 545 XXX_16: 6 SCM SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" BDY +BO_ 576 LEFT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 577 LEFT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 579 RIGHT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 580 RIGHT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 582 ADJACENT_LEFT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 583 ADJACENT_LEFT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 585 ADJACENT_RIGHT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 586 ADJACENT_RIGHT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON @@ -173,16 +277,16 @@ BO_ 773 SEATBELT_STATUS: 7 BDY SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 CAR_SPEED: 8 PCM - SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "" XXX - SG_ CAR_SPEED : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX + SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 780 ACC_HUD: 8 ADAS - SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY + SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY @@ -200,8 +304,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_ IMPERIAL_UNIT : 55|1@0+ (1,0) [0|1] "" XXX - SG_ SET_TO_X1 : 56|1@0+ (1,0) [0|1] "" XXX + SG_ SET_TO_X1 : 55|1@0+ (1,0) [0|1] "" XXX + SG_ IMPERIAL_UNIT : 54|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,11 +369,26 @@ 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 +CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; +CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; +CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; +CM_ SG_ 576 LINE_DISTANCE_VISIBLE "Length of line visible, undecoded"; +CM_ SG_ 577 LINE_FAR_EDGE_POSITION "Appears to be a measure of line thickness, indicates location of the portion of the line furthest from the car, undecoded"; +CM_ SG_ 577 LINE_PARAMETER "Unclear if this is low quality line curvature rate or if this is something else, but it is correlated with line curvature, undecoded"; +CM_ SG_ 577 LINE_DASHED "1 = line is dashed"; +CM_ SG_ 577 LINE_SOLID "1 = line is solid"; 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" +CM_ "honda_accord_lx15t_2018_can.dbc starts here"; +BO_ 304 GAS_PEDAL_2: 8 PCM + SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON + SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON + SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + BO_ 401 GEARBOX: 8 PCM SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" EON SG_ BOH : 45|6@0+ (1,0) [0|63] "" XXX diff --git a/opendbc/honda_accord_s2t_2018_can_generated.dbc b/opendbc/honda_accord_s2t_2018_can_generated.dbc index 7b3e99bc846542..6407b49feeb79a 100644 --- a/opendbc/honda_accord_s2t_2018_can_generated.dbc +++ b/opendbc/honda_accord_s2t_2018_can_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _bosch_2018.dbc starts here" +CM_ "Imported file _bosch_2018.dbc starts here"; VERSION "" @@ -37,6 +37,12 @@ NS_ : BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB +BO_ 148 KINEMATICS: 8 XXX + SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + BO_ 228 STEERING_CONTROL: 5 EON SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS @@ -45,6 +51,14 @@ BO_ 228 STEERING_CONTROL: 5 EON SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS +BO_ 229 BOSCH_SUPPLEMENTAL_1: 8 XXX + SG_ SET_ME_X04 : 0|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X00 : 8|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X80 : 16|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X10 : 24|8@1+ (1,0) [0|255] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + BO_ 232 BRAKE_HOLD: 7 XXX SG_ XMISSION_SPEED : 7|14@0- (1,0) [1|0] "" XXX SG_ COMPUTER_BRAKE : 39|16@0+ (1,0) [0|0] "" XXX @@ -52,17 +66,12 @@ BO_ 232 BRAKE_HOLD: 7 XXX SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" XXX -BO_ 304 GAS_PEDAL_2: 8 PCM - SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - BO_ 330 STEERING_SENSORS: 8 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON - SG_ STEER_ANGLE_OFFSET : 39|8@0- (-0.1,0) [-128|127] "deg" EON + SG_ STEER_SENSOR_STATUS_1 : 34|1@0+ (1,0) [0|1] "" EON + SG_ STEER_SENSOR_STATUS_2 : 33|1@0+ (1,0) [0|1] "" EON + SG_ STEER_SENSOR_STATUS_3 : 32|1@0+ (1,0) [0|1] "" EON SG_ STEER_WHEEL_ANGLE : 47|16@0- (-0.1,0) [-500|500] "deg" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON @@ -89,10 +98,11 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON + SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON + SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON @@ -104,6 +114,13 @@ BO_ 420 VSA_STATUS: 8 VSA SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON +BO_ 427 STEER_MOTOR_TORQUE: 3 EPS + SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON + SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON + SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON + BO_ 450 EPB_STATUS: 8 EPB SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" EON SG_ EPB_STATE : 29|2@0+ (1,0) [0|3] "" EON @@ -118,15 +135,26 @@ BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 479 ACC_CONTROL: 8 EON - SG_ SET_TO_1 : 20|5@0+ (1,0) [0|1] "" PCM + SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX - SG_ RELATED_TO_GAS : 7|7@0+ (1,0) [0|69] "" XXX - SG_ GAS_COMMAND : 0|9@0+ (1,0) [0|1] "" PCM - SG_ GAS_BRAKE : 31|14@0- (1,0) [0|1] "" XXX - SG_ ZEROS_BOH : 33|18@0+ (1,0) [100|100] "" XXX + SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX + SG_ ACCEL_COMMAND : 31|11@0- (0.01,0) [0|0] "m/s2" XXX + SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_PREPARE : 43|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 +BO_ 490 VEHICLE_DYNAMICS: 8 VSA + SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + BO_ 495 ACC_CONTROL_ON: 8 XXX SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX @@ -144,6 +172,82 @@ BO_ 545 XXX_16: 6 SCM SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" BDY +BO_ 576 LEFT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 577 LEFT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 579 RIGHT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 580 RIGHT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 582 ADJACENT_LEFT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 583 ADJACENT_LEFT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 585 ADJACENT_RIGHT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 586 ADJACENT_RIGHT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON @@ -173,16 +277,16 @@ BO_ 773 SEATBELT_STATUS: 7 BDY SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 CAR_SPEED: 8 PCM - SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "" XXX - SG_ CAR_SPEED : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX + SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 780 ACC_HUD: 8 ADAS - SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY + SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY @@ -200,8 +304,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_ IMPERIAL_UNIT : 55|1@0+ (1,0) [0|1] "" XXX - SG_ SET_TO_X1 : 56|1@0+ (1,0) [0|1] "" XXX + SG_ SET_TO_X1 : 55|1@0+ (1,0) [0|1] "" XXX + SG_ IMPERIAL_UNIT : 54|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,11 +369,26 @@ 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 +CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; +CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; +CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; +CM_ SG_ 576 LINE_DISTANCE_VISIBLE "Length of line visible, undecoded"; +CM_ SG_ 577 LINE_FAR_EDGE_POSITION "Appears to be a measure of line thickness, indicates location of the portion of the line furthest from the car, undecoded"; +CM_ SG_ 577 LINE_PARAMETER "Unclear if this is low quality line curvature rate or if this is something else, but it is correlated with line curvature, undecoded"; +CM_ SG_ 577 LINE_DASHED "1 = line is dashed"; +CM_ SG_ 577 LINE_SOLID "1 = line is solid"; 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" +CM_ "honda_accord_s2t_2018_can.dbc starts here"; +BO_ 304 GAS_PEDAL_2: 8 PCM + SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON + SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON + SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + BO_ 419 GEARBOX: 8 PCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON diff --git a/opendbc/honda_accord_touring_2016_can.dbc b/opendbc/honda_accord_touring_2016_can.dbc deleted file mode 100644 index e8f388de08692c..00000000000000 --- a/opendbc/honda_accord_touring_2016_can.dbc +++ /dev/null @@ -1,399 +0,0 @@ -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_: INTERCEPTOR EBCM NEO ADAS PCM EPS VSA SCM BDY XXX EPB - - -BO_ 57 XXX_1: 3 XXX - SG_ COUNTER : 21|2@0+ (1,0) [0|15] "" NEO - SG_ CHECKSUM : 19|4@0+ (1,0) [0|3] "" NEO - -BO_ 145 XXX_2: 8 XXX - SG_ LAT_ACCEL : 7|10@0+ (0.02,-512) [-20|20] "m/s2" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO - -BO_ 316 GAS_PEDAL: 8 PCM - SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO - -BO_ 342 STEERING_SENSORS: 6 EPS - SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" NEO - SG_ STEER_ANGLE_RATE : 23|16@0- (1,0) [-3000|3000] "deg/s" NEO - SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" NEO - -BO_ 344 POWERTRAIN_DATA: 8 PCM - SG_ XMISSION_SPEED : 7|16@0+ (0.002759506,0) [0|70] "m/s" NEO - SG_ ZEROS_BOH : 23|16@0+ (1,0) [0|15000] "" NEO - SG_ XMISSION_SPEED2 : 39|16@0+ (0.002759506,0) [0|70] "m/s" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO - -BO_ 380 POWERTRAIN_DATA2: 8 PCM - SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" NEO - SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" NEO - SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" NEO - SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "rpm" NEO - SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "rpm" NEO - SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "rpm" NEO - SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" NEO - SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "rpm" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO - -BO_ 398 XXX_3: 3 XXX - SG_ COUNTER : 21|2@0+ (1,0) [0|15] "" XXX - SG_ CHECKSUM : 19|4@0+ (1,0) [0|3] "" XXX - -BO_ 401 GEARBOX: 8 PCM - SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" NEO - SG_ GEAR : 35|4@0+ (1,0) [0|15] "" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO - -BO_ 420 VSA_STATUS: 8 VSA - SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON - SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX - SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 422 SCM_BUTTONS: 8 SCM - SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" NEO - SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" NEO - SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" NEO - SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO - -BO_ 426 XXX_4: 8 VSA - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO - -BO_ 432 STANDSTILL: 7 VSA - SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" NEO - SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" NEO - SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" NEO - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" NEO - -BO_ 464 WHEEL_SPEEDS: 8 VSA - SG_ WHEEL_SPEED_FL : 7|15@0+ (0.002759506,0) [0|70] "m/s" NEO - SG_ WHEEL_SPEED_FR : 8|15@0+ (0.002759506,0) [0|70] "m/s" NEO - SG_ WHEEL_SPEED_RL : 25|15@0+ (0.002759506,0) [0|70] "m/s" NEO - SG_ WHEEL_SPEED_RR : 42|15@0+ (0.002759506,0) [0|70] "m/s" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO - -BO_ 476 XXX_5: 4 XXX - SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 27|4@0+ (1,0) [0|15] "" XXX - -BO_ 487 XXX_6: 4 VSA - SG_ BRAKE_PRESSURE1 : 7|10@0+ (0.015625,-103) [0|1000] "" NEO - SG_ BRAKE_PRESSURE2 : 9|10@0+ (0.015625,-103) [0|1000] "" NEO - SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 27|4@0+ (1,0) [0|15] "" XXX - -BO_ 490 VEHICLE_DYNAMICS: 8 VSA - SG_ LONG_ACCEL : 23|16@0- (0.0015384,0) [-20|20] "m/s2" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 506 BRAKE_COMMAND: 8 ADAS - SG_ COMPUTER_BRAKE : 7|10@0+ (0.003906248,0) [0|1] "" EBCM - SG_ ZEROS_BOH : 13|5@0+ (1,0) [0|1] "" EBCM - SG_ COMPUTER_BRAKE_REQUEST : 8|1@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_BOH2 : 23|3@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_BOH3 : 19|1@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM - SG_ COMPUTER_BRAKE_REQUEST_2 : 16|1@0+ (1,0) [0|1] "" EBCM - SG_ SET_ME_0X80 : 31|8@0+ (1,0) [0|1] "" EBCM - SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM - SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM - SG_ ZEROS_BOH6 : 44|1@0+ (1,0) [0|1] "" EBCM - SG_ FCW : 43|1@0+ (1,0) [0|3] "" EBCM - SG_ ZEROS_BOH3 : 42|2@0+ (1,0) [0|0] "" EBCM - SG_ FCW2 : 40|1@0+ (1,0) [0|0] "" EBCM - SG_ ZEROS_BOH4 : 55|8@0+ (1,0) [0|0] "" EBCM - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM - -BO_ 507 XXX_7: 1 XXX - -BO_ 542 XXX_8: 7 XXX - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" XXX - -BO_ 545 XXX_9: 6 SCM - SG_ ECON_ON : 23|1@0+ (1,0) [0|1] "" XXX - SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" BDY - SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" BDY - -BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA - SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" NEO - SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" NEO - SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" NEO - SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" NEO - SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" NEO - SG_ LONG_COUNTER : 55|8@0+ (1,0) [0|255] "" XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@1+ (1,0) [0|15] "" XXX - -BO_ 660 SCM_COMMANDS: 8 SCM - SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" NEO - SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" NEO - SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@1+ (1,0) [0|15] "" XXX - -BO_ 661 XXX_10: 4 XXX - SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 27|4@0+ (1,0) [0|15] "" XXX - -BO_ 662 CRUISE_BUTTONS: 4 SCM - SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" NEO - SG_ CRUISE_SETTING : 3|2@0+ (1,0) [0|3] "" NEO - SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 27|4@0+ (1,0) [0|15] "" XXX - -BO_ 773 SEATBELT_STATUS: 7 BDY - SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" NEO - SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" NEO - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" NEO - -BO_ 777 XXX_11: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 780 ACC_HUD: 8 ADAS - SG_ PCM_SPEED : 7|16@0+ (0.002763889,0) [0|100] "m/s" BDY - SG_ PCM_GAS : 23|7@0+ (1,0) [0|127] "" BDY - SG_ ZEROS_BOH : 16|1@0+ (1,0) [0|255] "" BDY - SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY - SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY - SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY - SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY - SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY - SG_ BOH_2 : 35|1@0+ (1,0) [0|1] "" BDY - 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_ 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_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" BDY - -BO_ 800 XXX_12: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 804 CRUISE: 8 PCM - SG_ ENGINE_TEMPERATURE : 7|8@0+ (1,0) [0|255] "" NEO - SG_ BOH : 15|8@0+ (1,0) [0|255] "" NEO - SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" NEO - SG_ CRUISE_SPEED_PCM : 39|8@0+ (1,0) [0|255] "" NEO - SG_ BOH2 : 47|8@0- (1,0) [0|255] "" NEO - SG_ BOH3 : 55|8@0+ (1,0) [0|255] "" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO - -BO_ 808 XXX_13: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 829 LKAS_HUD: 5 ADAS - SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY - SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY - SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY - SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY - SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY - SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY - SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY - SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY - SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY - SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY - SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY - SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY - SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY - SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY - SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY - SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY - -BO_ 871 XXX_14: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 882 XXX_15: 2 XXX - SG_ COUNTER : 13|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 11|4@0+ (1,0) [0|15] "" XXX - -BO_ 884 XXX_16: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 891 XXX_17: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 892 CRUISE_PARAMS: 8 PCM - SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 918 XXX_18: 7 XXX - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" XXX - -BO_ 923 XXX_19: 2 XXX - SG_ COUNTER : 13|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 11|4@0+ (1,0) [0|15] "" XXX - -BO_ 927 ACC_HUD_2: 8 ADAS - SG_ ZEROS_BOH : 7|17@0+ (1,0) [0|127] "" BDY - SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|15] "" BDY - SG_ ZEROS_BOH2 : 31|8@0+ (1,0) [0|127] "" BDY - SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|15] "" BDY - SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|15] "" BDY - SG_ LEAD_SPEED : 39|9@0+ (1,0) [0|127] "" BDY - SG_ LEAD_STATE : 46|3@0+ (1,0) [0|127] "" BDY - SG_ LEAD_DISTANCE : 43|5@0+ (1,0) [0|31] "" BDY - SG_ ZEROS_BOH3 : 54|7@0+ (1,0) [0|127] "" BDY - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 929 XXX_20: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 983 XXX_21: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 985 XXX_22: 3 XXX - SG_ COUNTER : 21|2@0+ (1,0) [0|15] "" XXX - SG_ CHECKSUM : 19|4@0+ (1,0) [0|3] "" XXX - -BO_ 1024 XXX_23: 5 XXX - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" XXX - -BO_ 1027 XXX_24: 5 XXX - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" XXX - -BO_ 1029 DOORS_STATUS: 8 BDY - SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" NEO - SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" NEO - SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" NEO - SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO - -BO_ 1036 XXX_25: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 1039 XXX_26: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 1057 XXX_27: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 1064 XXX_28: 7 XXX - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" XXX - -BO_ 1088 XXX_29: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 1089 XXX_30: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 1108 XXX_31: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 1125 XXX_32: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 1296 XXX_33: 3 XXX - SG_ COUNTER : 21|2@0+ (1,0) [0|15] "" XXX - SG_ CHECKSUM : 19|4@0+ (1,0) [0|3] "" XXX - -BO_ 1365 XXX_34: 5 XXX - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" XXX - -BO_ 1424 XXX_35: 5 XXX - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" XXX - -BO_ 1600 XXX_36: 5 XXX - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" XXX - -BO_ 1601 XXX_37: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 1633 XXX_38: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - -BO_TX_BU_ 506 : NEO,ADAS; -BO_TX_BU_ 780 : NEO,ADAS; -BO_TX_BU_ 829 : NEO,ADAS; -BO_TX_BU_ 927 : NEO,ADAS; - -CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/honda_civic_hatchback_ex_2017_can_generated.dbc b/opendbc/honda_civic_hatchback_ex_2017_can_generated.dbc index 55f74cf9911028..0443f2d5c43486 100644 --- a/opendbc/honda_civic_hatchback_ex_2017_can_generated.dbc +++ b/opendbc/honda_civic_hatchback_ex_2017_can_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _bosch_2018.dbc starts here" +CM_ "Imported file _bosch_2018.dbc starts here"; VERSION "" @@ -37,6 +37,12 @@ NS_ : BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB +BO_ 148 KINEMATICS: 8 XXX + SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + BO_ 228 STEERING_CONTROL: 5 EON SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS @@ -45,6 +51,14 @@ BO_ 228 STEERING_CONTROL: 5 EON SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS +BO_ 229 BOSCH_SUPPLEMENTAL_1: 8 XXX + SG_ SET_ME_X04 : 0|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X00 : 8|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X80 : 16|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X10 : 24|8@1+ (1,0) [0|255] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + BO_ 232 BRAKE_HOLD: 7 XXX SG_ XMISSION_SPEED : 7|14@0- (1,0) [1|0] "" XXX SG_ COMPUTER_BRAKE : 39|16@0+ (1,0) [0|0] "" XXX @@ -52,17 +66,12 @@ BO_ 232 BRAKE_HOLD: 7 XXX SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" XXX -BO_ 304 GAS_PEDAL_2: 8 PCM - SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - BO_ 330 STEERING_SENSORS: 8 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON - SG_ STEER_ANGLE_OFFSET : 39|8@0- (-0.1,0) [-128|127] "deg" EON + SG_ STEER_SENSOR_STATUS_1 : 34|1@0+ (1,0) [0|1] "" EON + SG_ STEER_SENSOR_STATUS_2 : 33|1@0+ (1,0) [0|1] "" EON + SG_ STEER_SENSOR_STATUS_3 : 32|1@0+ (1,0) [0|1] "" EON SG_ STEER_WHEEL_ANGLE : 47|16@0- (-0.1,0) [-500|500] "deg" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON @@ -89,10 +98,11 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON + SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON + SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON @@ -104,6 +114,13 @@ BO_ 420 VSA_STATUS: 8 VSA SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON +BO_ 427 STEER_MOTOR_TORQUE: 3 EPS + SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON + SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON + SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON + BO_ 450 EPB_STATUS: 8 EPB SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" EON SG_ EPB_STATE : 29|2@0+ (1,0) [0|3] "" EON @@ -118,15 +135,26 @@ BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 479 ACC_CONTROL: 8 EON - SG_ SET_TO_1 : 20|5@0+ (1,0) [0|1] "" PCM + SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX - SG_ RELATED_TO_GAS : 7|7@0+ (1,0) [0|69] "" XXX - SG_ GAS_COMMAND : 0|9@0+ (1,0) [0|1] "" PCM - SG_ GAS_BRAKE : 31|14@0- (1,0) [0|1] "" XXX - SG_ ZEROS_BOH : 33|18@0+ (1,0) [100|100] "" XXX + SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX + SG_ ACCEL_COMMAND : 31|11@0- (0.01,0) [0|0] "m/s2" XXX + SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_PREPARE : 43|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 +BO_ 490 VEHICLE_DYNAMICS: 8 VSA + SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + BO_ 495 ACC_CONTROL_ON: 8 XXX SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX @@ -144,6 +172,82 @@ BO_ 545 XXX_16: 6 SCM SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" BDY +BO_ 576 LEFT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 577 LEFT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 579 RIGHT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 580 RIGHT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 582 ADJACENT_LEFT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 583 ADJACENT_LEFT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 585 ADJACENT_RIGHT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 586 ADJACENT_RIGHT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON @@ -173,16 +277,16 @@ BO_ 773 SEATBELT_STATUS: 7 BDY SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 CAR_SPEED: 8 PCM - SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "" XXX - SG_ CAR_SPEED : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX + SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 780 ACC_HUD: 8 ADAS - SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY + SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY @@ -200,8 +304,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_ IMPERIAL_UNIT : 55|1@0+ (1,0) [0|1] "" XXX - SG_ SET_TO_X1 : 56|1@0+ (1,0) [0|1] "" XXX + SG_ SET_TO_X1 : 55|1@0+ (1,0) [0|1] "" XXX + SG_ IMPERIAL_UNIT : 54|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,11 +369,26 @@ 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 +CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; +CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; +CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; +CM_ SG_ 576 LINE_DISTANCE_VISIBLE "Length of line visible, undecoded"; +CM_ SG_ 577 LINE_FAR_EDGE_POSITION "Appears to be a measure of line thickness, indicates location of the portion of the line furthest from the car, undecoded"; +CM_ SG_ 577 LINE_PARAMETER "Unclear if this is low quality line curvature rate or if this is something else, but it is correlated with line curvature, undecoded"; +CM_ SG_ 577 LINE_DASHED "1 = line is dashed"; +CM_ SG_ 577 LINE_SOLID "1 = line is solid"; 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" +CM_ "honda_civic_hatchback_ex_2017_can.dbc starts here"; +BO_ 304 GAS_PEDAL_2: 8 PCM + SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON + SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON + SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + BO_ 401 GEARBOX: 8 PCM SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" EON SG_ BOH : 45|6@0+ (1,0) [0|63] "" XXX @@ -286,6 +405,11 @@ BO_ 432 STANDSTILL: 7 VSA SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON +BO_ 506 LEGACY_BRAKE_COMMAND: 8 ADAS + SG_ CHIME : 40|8@1+ (1,0) [0|255] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + BO_ 892 CRUISE_PARAMS: 8 PCM SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON diff --git a/opendbc/honda_civic_sedan_16_diesel_2019_can_generated.dbc b/opendbc/honda_civic_sedan_16_diesel_2019_can_generated.dbc new file mode 100644 index 00000000000000..fecfc58865fef5 --- /dev/null +++ b/opendbc/honda_civic_sedan_16_diesel_2019_can_generated.dbc @@ -0,0 +1,444 @@ +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; + + +CM_ "Imported file _bosch_2018.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_ + +BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB + +BO_ 148 KINEMATICS: 8 XXX + SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + +BO_ 228 STEERING_CONTROL: 5 EON + SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS + SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS + SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS + SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS + SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS + SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS + +BO_ 229 BOSCH_SUPPLEMENTAL_1: 8 XXX + SG_ SET_ME_X04 : 0|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X00 : 8|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X80 : 16|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X10 : 24|8@1+ (1,0) [0|255] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + +BO_ 232 BRAKE_HOLD: 7 XXX + SG_ XMISSION_SPEED : 7|14@0- (1,0) [1|0] "" XXX + SG_ COMPUTER_BRAKE : 39|16@0+ (1,0) [0|0] "" XXX + SG_ COMPUTER_BRAKE_REQUEST : 29|1@0+ (1,0) [0|0] "" XXX + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" XXX + +BO_ 330 STEERING_SENSORS: 8 EPS + SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON + SG_ STEER_SENSOR_STATUS_1 : 34|1@0+ (1,0) [0|1] "" EON + SG_ STEER_SENSOR_STATUS_2 : 33|1@0+ (1,0) [0|1] "" EON + SG_ STEER_SENSOR_STATUS_3 : 32|1@0+ (1,0) [0|1] "" EON + SG_ STEER_WHEEL_ANGLE : 47|16@0- (-0.1,0) [-500|500] "deg" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 344 ENGINE_DATA: 8 PCM + SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON + SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON + SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON + SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 380 POWERTRAIN_DATA: 8 PCM + SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON + SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON + SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON + SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "" EON + SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "" EON + SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "" EON + SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "" EON + SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON + SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 399 STEER_STATUS: 7 EPS + SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON + SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON + SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON + SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON + +BO_ 420 VSA_STATUS: 8 VSA + SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON + SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 427 STEER_MOTOR_TORQUE: 3 EPS + SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON + SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON + SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON + +BO_ 450 EPB_STATUS: 8 EPB + SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" EON + SG_ EPB_STATE : 29|2@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + +BO_ 464 WHEEL_SPEEDS: 8 VSA + SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 479 ACC_CONTROL: 8 EON + SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX + SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX + SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX + SG_ ACCEL_COMMAND : 31|11@0- (0.01,0) [0|0] "m/s2" XXX + SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_PREPARE : 43|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 + +BO_ 490 VEHICLE_DYNAMICS: 8 VSA + SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 495 ACC_CONTROL_ON: 8 XXX + SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX + SG_ ZEROS_BOH : 23|8@0+ (1,0) [0|255] "" XXX + SG_ ZEROS_BOH2 : 47|16@0+ (1,0) [0|255] "" XXX + SG_ SET_TO_FF : 15|8@0+ (1,0) [0|255] "" XXX + SG_ SET_TO_3 : 6|7@0+ (1,0) [0|4095] "" XXX + SG_ CONTROL_ON : 7|1@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + +BO_ 545 XXX_16: 6 SCM + SG_ ECON_ON : 23|1@0+ (1,0) [0|1] "" XXX + SG_ DRIVE_MODE : 37|2@0+ (1,0) [0|3] "" XXX + SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" BDY + +BO_ 576 LEFT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 577 LEFT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 579 RIGHT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 580 RIGHT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 582 ADJACENT_LEFT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 583 ADJACENT_LEFT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 585 ADJACENT_RIGHT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 586 ADJACENT_RIGHT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA + SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON + SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" XXX + SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON + SG_ LONG_COUNTER : 55|8@0+ (1,0) [0|255] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + + BO_ 662 SCM_BUTTONS: 4 SCM + SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON + SG_ CRUISE_SETTING : 3|2@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 27|4@0+ (1,0) [0|15] "" EON + +BO_ 773 SEATBELT_STATUS: 7 BDY + SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON + SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON + SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON + +BO_ 777 CAR_SPEED: 8 PCM + SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX + SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX + SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + +BO_ 780 ACC_HUD: 8 ADAS + SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY + SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY + SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY + 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_ 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_ ZEROS_BOH : 7|24@0+ (0.002759506,0) [0|100] "m/s" BDY + SG_ FCM_OFF : 35|1@0+ (1,0) [0|1] "" BDY + SG_ SET_TO_1 : 36|1@0+ (1,0) [0|1] "" XXX + SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY + SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY + 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_X1 : 55|1@0+ (1,0) [0|1] "" XXX + SG_ IMPERIAL_UNIT : 54|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 + +BO_ 804 CRUISE: 8 PCM + SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 806 SCM_FEEDBACK: 8 SCM + SG_ DRIVERS_DOOR_OPEN : 17|1@0+ (1,0) [0|1] "" XXX + SG_ MAIN_ON : 28|1@0+ (1,0) [0|1] "" EON + SG_ RIGHT_BLINKER : 27|1@0+ (1,0) [0|1] "" EON + SG_ LEFT_BLINKER : 26|1@0+ (1,0) [0|1] "" EON + SG_ CMBS_STATES : 22|2@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + +BO_ 829 LKAS_HUD: 5 ADAS + SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY + SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY + SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY + SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY + SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY + SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY + SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY + SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY + SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY + SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY + SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY + SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY + SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY + SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY + SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY + SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY + SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY + SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY + +BO_ 862 CAMERA_MESSAGES: 8 CAM + SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY + SG_ AUTO_HIGHBEAMS_ACTIVE : 53|1@0+ (1,0) [0|1] "" XXX + SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX + SG_ ZEROS_BOH_2 : 51|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + +BO_ 884 STALK_STATUS: 8 XXX + SG_ AUTO_HEADLIGHTS : 46|1@0+ (1,0) [0|1] "" EON + SG_ HIGH_BEAM_HOLD : 47|1@0+ (1,0) [0|1] "" EON + SG_ HIGH_BEAM_FLASH : 45|1@0+ (1,0) [0|1] "" EON + SG_ HEADLIGHTS_ON : 54|1@0+ (1,0) [0|1] "" EON + SG_ WIPER_SWITCH : 53|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + +BO_ 891 STALK_STATUS_2: 8 XXX + SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" EON + SG_ LOW_BEAMS : 35|1@0+ (1,0) [0|1] "" XXX + SG_ HIGH_BEAMS : 34|1@0+ (1,0) [0|1] "" XXX + SG_ PARK_LIGHTS : 36|1@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + +CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; +CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; +CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; +CM_ SG_ 576 LINE_DISTANCE_VISIBLE "Length of line visible, undecoded"; +CM_ SG_ 577 LINE_FAR_EDGE_POSITION "Appears to be a measure of line thickness, indicates location of the portion of the line furthest from the car, undecoded"; +CM_ SG_ 577 LINE_PARAMETER "Unclear if this is low quality line curvature rate or if this is something else, but it is correlated with line curvature, undecoded"; +CM_ SG_ 577 LINE_DASHED "1 = line is dashed"; +CM_ SG_ 577 LINE_SOLID "1 = line is solid"; +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_sedan_16_diesel_2019_can.dbc starts here"; + + +BO_ 316 GAS_PEDAL_2: 8 XXX + SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + +BO_ 419 GEARBOX: 8 XXX + SG_ GEAR_SHIFTER : 24|8@1+ (1,0) [0|255] "" XXX + SG_ GEAR : 32|8@1+ (1,0) [0|255] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + +BO_ 432 STANDSTILL: 7 VSA + SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON + +BO_ 506 LEGACY_BRAKE_COMMAND: 8 ADAS + SG_ CHIME : 40|8@1+ (1,0) [0|255] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + +BO_ 892 CRUISE_PARAMS: 8 PCM + SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|15] "" EON + +BO_ 927 RADAR_HUD: 8 RADAR + SG_ ZEROS_BOH : 7|10@0+ (1,0) [0|127] "" BDY + SG_ CMBS_OFF : 12|1@0+ (1,0) [0|1] "" BDY + SG_ ZEROS_BOH3 : 31|32@0+ (1,0) [0|4294967295] "" XXX + SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|1] "" XXX + SG_ SET_TO_1 : 13|1@0+ (1,0) [0|1] "" BDY + SG_ ZEROS_BOH2 : 11|4@0+ (1,0) [0|1] "" XXX + SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|1] "" XXX + SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|1] "" BDY + SG_ SET_TO_0 : 22|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 + +BO_ 1029 DOORS_STATUS: 8 BDY + SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON + SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +VAL_ 419 GEAR_SHIFTER 2 "S" 32 "D" 16 "N" 8 "R" 4 "P" ; +VAL_ 419 GEAR 26 "S" 20 "D" 19 "N" 18 "R" 17 "P" ; +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" ; +VAL_ 806 CMBS_BUTTON 3 "pressed" 0 "released" ; +VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; +VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; + +CM_ "CHFFR_METRIC 330 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/honda_civic_touring_2016_can_generated.dbc b/opendbc/honda_civic_touring_2016_can_generated.dbc index a613aa0676e9c9..0d666332578fbe 100644 --- a/opendbc/honda_civic_touring_2016_can_generated.dbc +++ b/opendbc/honda_civic_touring_2016_can_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +CM_ "Imported file _comma.dbc starts here"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR @@ -19,7 +19,7 @@ BO_ 513 GAS_SENSOR: 6 INTERCEPTOR 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 _honda_2017.dbc starts here" +CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" @@ -78,6 +78,7 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON @@ -85,6 +86,13 @@ BO_ 420 VSA_STATUS: 8 VSA SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON +BO_ 427 STEER_MOTOR_TORQUE: 3 EPS + SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON + SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON + SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON + BO_ 432 STANDSTILL: 7 VSA SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON @@ -123,7 +131,7 @@ BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM - SG_ AEB : 41|2@0+ (1,0) [0|3] "" XXX + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM @@ -163,7 +171,7 @@ BO_ 780 ACC_HUD: 8 ADAS SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY - SG_ BOH_2 : 35|1@0+ (1,0) [0|1] "" BDY + SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY 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 @@ -173,10 +181,12 @@ BO_ 780 ACC_HUD: 8 ADAS 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_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY + SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY + SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY + SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY + SG_ ICONS : 63|2@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 @@ -226,6 +236,7 @@ BO_ 1029 DOORS_STATUS: 8 BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; @@ -235,11 +246,12 @@ CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; -CM_ "honda_civic_touring_2016_can.dbc starts here" +CM_ "honda_civic_touring_2016_can.dbc starts here"; @@ -267,16 +279,19 @@ BO_ 304 GAS_PEDAL_2: 8 PCM BO_ 330 STEERING_SENSORS: 8 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON - SG_ STEER_ANGLE_OFFSET : 39|8@0- (-0.1,0) [-128|127] "deg" EON + SG_ STEER_SENSOR_STATUS_1 : 34|1@0+ (1,0) [0|1] "" EON + SG_ STEER_SENSOR_STATUS_2 : 33|1@0+ (1,0) [0|1] "" EON + SG_ STEER_SENSOR_STATUS_3 : 32|1@0+ (1,0) [0|1] "" EON SG_ STEER_WHEEL_ANGLE : 47|16@0- (-0.1,0) [-500|500] "deg" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON + SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON + SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON diff --git a/opendbc/honda_clarity_hybrid_2018_can.dbc b/opendbc/honda_clarity_hybrid_2018_can.dbc deleted file mode 100644 index 3d46f52cd5433a..00000000000000 --- a/opendbc/honda_clarity_hybrid_2018_can.dbc +++ /dev/null @@ -1,433 +0,0 @@ -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_: INTERCEPTOR EBCM NEO ADAS PCM EPS VSA SCM BDY XXX EPB - - -BO_ 57 XXX_1: 3 XXX - SG_ CHECKSUM : 19|4@0+ (1,0) [0|3] "" NEO - SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" NEO - -BO_ 148 XXX_2: 8 XXX - SG_ LAT_ACCEL : 7|10@0+ (0.02,-512) [-20|20] "m/s2" NEO - SG_ LONG_ACCEL : 24|9@0- (-0.02,0) [-20|20] "m/s2" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - -BO_ 228 STEERING_CONTROL: 5 ADAS - SG_ STEER_TORQUE : 7|16@0- (1,0) [-3840|3840] "" EPS - SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS - SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS - SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS - SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS - -BO_ 304 GAS_PEDAL2: 8 PCM - SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" NEO - SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" NEO - SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 330 STEERING_SENSORS: 8 EPS - SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" NEO - SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" NEO - SG_ STEER_ANGLE_OFFSET : 39|8@0- (-0.1,0) [-128|127] "deg" NEO - SG_ STEER_WHEEL_ANGLE : 47|16@0- (-0.1,0) [-500|500] "deg" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 344 POWERTRAIN_DATA: 8 PCM - SG_ XMISSION_SPEED : 7|16@0+ (0.002759506,0) [0|70] "m/s" NEO - SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" NEO - SG_ XMISSION_SPEED2 : 39|16@0+ (0.002759506,0) [0|70] "m/s" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - SG_ TRIP_DISTANCE : 55|8@0+ (0.010588,0) [0|255] "km" NEO - -BO_ 380 POWERTRAIN_DATA2: 8 PCM - SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" NEO - SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" NEO - SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" NEO - SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "rpm" NEO - SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "rpm" NEO - SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "rpm" NEO - SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "rpm" NEO - SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" NEO - SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "rpm" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" NEO - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" NEO - SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" NEO - SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" NEO - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" NEO - -BO_ 401 GEARBOX_1: 8 PCM - SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" NEO - SG_ GEAR : 43|4@0+ (1,0) [0|15] "" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 420 VSA_STATUS: 8 VSA - SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" NEO - SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" NEO - SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" NEO - -BO_ 427 XXX_3: 3 VSA - SG_ CHECKSUM : 19|4@0+ (1,0) [0|6] "" NEO - SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" NEO - -BO_ 428 XXX_4: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 432 STANDSTILL: 7 VSA - SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" NEO - SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" NEO - SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" NEO - SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" NEO - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" NEO - -BO_ 450 XXX_5: 8 EPB - SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" NEO - SG_ EPB_STATE : 29|2@0+ (1,0) [0|3] "" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 464 WHEEL_SPEEDS: 8 VSA - SG_ WHEEL_SPEED_FL : 7|15@0+ (0.002759506,0) [0|70] "m/s" NEO - SG_ WHEEL_SPEED_FR : 8|15@0+ (0.002759506,0) [0|70] "m/s" NEO - SG_ WHEEL_SPEED_RL : 25|15@0+ (0.002759506,0) [0|70] "m/s" NEO - SG_ WHEEL_SPEED_RR : 42|15@0+ (0.002759506,0) [0|70] "m/s" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 476 XXX_7: 7 XXX - SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" NEO - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" NEO - -BO_ 487 XXX_8: 4 VSA - SG_ BRAKE_PRESSURE1 : 7|10@0+ (0.015625,-103) [0|1000] "" NEO - SG_ BRAKE_PRESSURE2 : 9|10@0+ (0.015625,-103) [0|1000] "" NEO - SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" NEO - SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" NEO - -BO_ 490 VEHICLE_DYNAMICS: 8 VSA - SG_ LONG_ACCEL : 23|16@0- (0.0015384,0) [-20|20] "m/s2" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 493 XXX_9: 5 VSA - SG_ CHECKSUM : 35|4@0+ (1,0) [0|3] "" NEO - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" NEO - -BO_ 506 BRAKE_COMMAND: 8 ADAS - SG_ COMPUTER_BRAKE : 55|10@0+ (0.003906248,0) [0|0] "" EBCM - SG_ COMPUTER_BRAKE_REQUEST : 11|1@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_BOH2 : 23|3@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_BOH3 : 19|1@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM - SG_ SET_ME_0X80 : 31|8@0+ (1,0) [0|1] "" EBCM - SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM - SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM - SG_ ZEROS_BOH6 : 44|1@0+ (1,0) [0|1] "" EBCM - SG_ FCW : 43|1@0+ (1,0) [0|3] "" EBCM - SG_ ZEROS_BOH3 : 42|2@0+ (1,0) [0|0] "" EBCM - SG_ FCW2 : 40|1@0+ (1,0) [0|0] "" EBCM - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EBCM - -BO_ 512 GAS_COMMAND: 3 NEO - SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR - SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" INTERCEPTOR - SG_ CHECKSUM : 19|4@0+ (1,0) [0|3] "" INTERCEPTOR - -BO_ 513 GAS_SENSOR: 5 INTERCEPTOR - SG_ INTERCEPTOR_GAS : 7|16@0+ (0.253984064,-83.3) [0|1] "" NEO - SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" NEO - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 35|4@0+ (1,0) [0|3] "" NEO - -BO_ 545 XXX_10: 5 XXX - SG_ ECON_ON : 23|1@0+ (1,0) [0|1] "" NEO - SG_ CHECKSUM : 35|4@0+ (1,0) [0|3] "" NEO - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" NEO - -BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA - SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" NEO - SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" NEO - SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" NEO - SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" NEO - SG_ SET_TO_X55 : 47|8@0+ (1,0) [0|255] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|6] "" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - -BO_ 662 CRUISE_BUTTONS: 4 SCM - SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" NEO - SG_ CRUISE_SETTING : 3|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" NEO - SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" NEO - -BO_ 773 SEATBELT_STATUS: 7 BDY - SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" NEO - SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" NEO - SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" NEO - SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" NEO - SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" NEO - SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" NEO - SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" NEO - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" NEO - -BO_ 777 XXX_11: 8 XXX - SG_ DOORS_UNLOCKED : 54|1@0+ (1,0) [0|1] "" NEO - SG_ DOORS_LOCKED : 55|1@0+ (1,0) [0|1] "" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 780 ACC_HUD: 8 ADAS - SG_ PCM_SPEED : 7|16@0+ (0.002759506,0) [0|100] "m/s" BDY - SG_ PCM_GAS : 23|7@0+ (1,0) [0|127] "" BDY - SG_ ZEROS_BOH : 16|1@0+ (1,0) [0|255] "" BDY - SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY - SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY - SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY - SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY - SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY - SG_ BOH_2 : 35|1@0+ (1,0) [0|1] "" BDY - 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_ 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_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY - -BO_ 795 XXX_12: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 800 XXX_13: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 804 CRUISE: 8 PCM - SG_ HUD_SPEED_KPH : 7|8@0+ (1,0) [0|255] "kph" NEO - SG_ HUD_SPEED_MPH : 15|8@0+ (1,0) [0|255] "mph" NEO - SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" NEO - SG_ CRUISE_SPEED_PCM : 39|8@0+ (1,0) [0|255] "" NEO - SG_ BOH2 : 47|8@0- (1,0) [0|255] "" NEO - SG_ BOH3 : 55|8@0+ (1,0) [0|255] "" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 806 SCM_FEEDBACK: 8 SCM - SG_ CMBS_BUTTON : 22|2@0+ (1,0) [0|3] "" NEO - SG_ MAIN_ON : 28|1@0+ (1,0) [0|1] "" NEO - SG_ RIGHT_BLINKER : 27|1@0+ (1,0) [0|1] "" NEO - SG_ LEFT_BLINKER : 26|1@0+ (1,0) [0|1] "" NEO - SG_ REVERSE_LIGHT : 18|1@0+ (1,0) [0|1] "" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 808 XXX_14: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 829 LKAS_HUD_2: 5 ADAS - SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY - SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY - SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY - SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY - SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY - SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY - SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY - SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY - SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY - SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY - SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY - SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY - SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY - SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY - SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY - SG_ CHECKSUM : 35|4@0+ (1,0) [0|3] "" BDY - -BO_ 862 XXX_15: 8 ADAS - SG_ UI_ALERTS : 7|56@0+ (1,0) [0|127] "" BDY - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY - -BO_ 884 STALK_STATUS: 8 XXX - SG_ AUTO_HEADLIGHTS : 46|1@0+ (1,0) [0|1] "" NEO - SG_ HIGH_BEAM_HOLD : 47|1@0+ (1,0) [0|1] "" NEO - SG_ HIGH_BEAM_FLASH : 45|1@0+ (1,0) [0|1] "" NEO - SG_ HEADLIGHTS_ON : 54|1@0+ (1,0) [0|1] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - -BO_ 891 XXX_17: 8 XXX - SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - -BO_ 892 CRUISE_PARAMS: 8 PCM - SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - -BO_ 927 XXX_19: 8 ADAS - SG_ ZEROS_BOH : 7|17@0+ (1,0) [0|127] "" BDY - SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|15] "" BDY - SG_ ZEROS_BOH2 : 31|8@0+ (1,0) [0|127] "" BDY - SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|15] "" BDY - SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|15] "" BDY - SG_ LEAD_SPEED : 39|9@0+ (1,0) [0|127] "" BDY - SG_ LEAD_STATE : 46|3@0+ (1,0) [0|127] "" BDY - SG_ LEAD_DISTANCE : 43|5@0+ (1,0) [0|31] "" BDY - SG_ ZEROS_BOH3 : 54|7@0+ (1,0) [0|127] "" BDY - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY - -BO_ 929 XXX_20: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 985 XXX_21: 3 XXX - SG_ CHECKSUM : 19|4@0+ (1,0) [0|3] "" NEO - SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" NEO - -BO_ 1024 XXX_22: 5 XXX - SG_ CHECKSUM : 35|4@0+ (1,0) [0|3] "" NEO - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" NEO - -BO_ 1027 XXX_23: 5 XXX - SG_ CHECKSUM : 35|4@0+ (1,0) [0|3] "" NEO - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" NEO - -BO_ 1029 DOORS_STATUS: 8 BDY - SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" NEO - SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" NEO - SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" NEO - SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" NEO - SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 1036 XXX_24: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 1039 XXX_25: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 1108 XXX_26: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 1302 XXX_27: 8 XXX - SG_ ODOMETER : 7|24@0+ (1,0) [0|16777215] "km" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 1322 XXX_28: 5 XXX - SG_ CHECKSUM : 35|4@0+ (1,0) [0|3] "" NEO - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" NEO - -BO_ 1361 XXX_29: 5 XXX - -BO_ 1365 XXX_30: 5 XXX - -BO_ 1424 XXX_31: 5 XXX - -BO_ 1600 XXX_32: 5 XXX - -BO_ 1601 XXX_33: 8 XXX - -BO_ 1633 XXX_34: 8 XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" NEO - -BO_ 419 GEARBOX_2: 8 XXX - SG_ GEAR : 29|6@0+ (1,0) [0|63] "" NEO - SG_ GEAR_SHIFTER : 34|3@0+ (1,0) [0|7] "" NEO - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO - -BO_TX_BU_ 228 : NEO,ADAS; -BO_TX_BU_ 506 : NEO,ADAS; -BO_TX_BU_ 780 : NEO,ADAS; -BO_TX_BU_ 829 : NEO,ADAS; -BO_TX_BU_ 862 : NEO,ADAS; -BO_TX_BU_ 927 : NEO,ADAS; - - -CM_ "CHFFR_METRIC 330 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; -CM_ SG_ 401 GEAR "10 = reverse, 11 = transition"; -CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; -CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; -CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; -CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; -CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; -CM_ SG_ 806 REVERSE_LIGHT "Might be reverse gear selected and not the lights"; -CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; -VAL_ 399 STEER_STATUS 5 "fault" 4 "no_torque_alert_2" 2 "no_torque_alert_1" 0 "normal" ; -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_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; -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" ; -VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; -VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; -VAL_ 806 CMBS_BUTTON 3 "pressed" 0 "released" ; -VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; -VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; -VAL_ 927 ACC_ALERTS 29 "esp_active_acc_canceled" 10 "b_pedal_applied" 9 "speed_too_low" 8 "speed_too_high" 7 "p_brake_applied" 6 "gear_no_d" 5 "seatbelt" 4 "too_steep_downhill" 3 "too_steep_uphill" 2 "too_close" 1 "no_vehicle_ahead" ; diff --git a/opendbc/honda_crv_ex_2017_body_generated.dbc b/opendbc/honda_crv_ex_2017_body_generated.dbc new file mode 100644 index 00000000000000..4d154e53f730b7 --- /dev/null +++ b/opendbc/honda_crv_ex_2017_body_generated.dbc @@ -0,0 +1,13 @@ +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; + +CM_ "honda_crv_ex_2017_body.dbc starts here"; +BO_ 318291879 BSM_STATUS_RIGHT: 8 XXX + SG_ BSM_ALERT : 4|1@0+ (1,0) [0|1] "" XXX + SG_ BSM_MODE : 6|2@0+ (1,0) [0|3] "" XXX + +BO_ 318291615 BSM_STATUS_LEFT: 8 XXX + SG_ BSM_ALERT : 4|1@0+ (1,0) [0|1] "" XXX + SG_ BSM_MODE : 6|2@0+ (1,0) [0|3] "" XXX + +VAL_ 318291879 BSM_MODE 2 "blind_spot" 1 "cross_traffic" 0 "off"; +VAL_ 318291615 BSM_MODE 2 "blind_spot" 1 "cross_traffic" 0 "off"; diff --git a/opendbc/honda_crv_ex_2017_can_generated.dbc b/opendbc/honda_crv_ex_2017_can_generated.dbc index 2a6449f524f0b3..2e6fbf8bf57dbf 100644 --- a/opendbc/honda_crv_ex_2017_can_generated.dbc +++ b/opendbc/honda_crv_ex_2017_can_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _bosch_2018.dbc starts here" +CM_ "Imported file _bosch_2018.dbc starts here"; VERSION "" @@ -37,6 +37,12 @@ NS_ : BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB +BO_ 148 KINEMATICS: 8 XXX + SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + BO_ 228 STEERING_CONTROL: 5 EON SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS @@ -45,6 +51,14 @@ BO_ 228 STEERING_CONTROL: 5 EON SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS +BO_ 229 BOSCH_SUPPLEMENTAL_1: 8 XXX + SG_ SET_ME_X04 : 0|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X00 : 8|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X80 : 16|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X10 : 24|8@1+ (1,0) [0|255] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + BO_ 232 BRAKE_HOLD: 7 XXX SG_ XMISSION_SPEED : 7|14@0- (1,0) [1|0] "" XXX SG_ COMPUTER_BRAKE : 39|16@0+ (1,0) [0|0] "" XXX @@ -52,17 +66,12 @@ BO_ 232 BRAKE_HOLD: 7 XXX SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" XXX -BO_ 304 GAS_PEDAL_2: 8 PCM - SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - BO_ 330 STEERING_SENSORS: 8 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON - SG_ STEER_ANGLE_OFFSET : 39|8@0- (-0.1,0) [-128|127] "deg" EON + SG_ STEER_SENSOR_STATUS_1 : 34|1@0+ (1,0) [0|1] "" EON + SG_ STEER_SENSOR_STATUS_2 : 33|1@0+ (1,0) [0|1] "" EON + SG_ STEER_SENSOR_STATUS_3 : 32|1@0+ (1,0) [0|1] "" EON SG_ STEER_WHEEL_ANGLE : 47|16@0- (-0.1,0) [-500|500] "deg" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON @@ -89,10 +98,11 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON + SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON + SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON @@ -104,6 +114,13 @@ BO_ 420 VSA_STATUS: 8 VSA SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON +BO_ 427 STEER_MOTOR_TORQUE: 3 EPS + SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON + SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON + SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON + BO_ 450 EPB_STATUS: 8 EPB SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" EON SG_ EPB_STATE : 29|2@0+ (1,0) [0|3] "" EON @@ -118,15 +135,26 @@ BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 479 ACC_CONTROL: 8 EON - SG_ SET_TO_1 : 20|5@0+ (1,0) [0|1] "" PCM + SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX - SG_ RELATED_TO_GAS : 7|7@0+ (1,0) [0|69] "" XXX - SG_ GAS_COMMAND : 0|9@0+ (1,0) [0|1] "" PCM - SG_ GAS_BRAKE : 31|14@0- (1,0) [0|1] "" XXX - SG_ ZEROS_BOH : 33|18@0+ (1,0) [100|100] "" XXX + SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX + SG_ ACCEL_COMMAND : 31|11@0- (0.01,0) [0|0] "m/s2" XXX + SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_PREPARE : 43|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 +BO_ 490 VEHICLE_DYNAMICS: 8 VSA + SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + BO_ 495 ACC_CONTROL_ON: 8 XXX SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX @@ -144,6 +172,82 @@ BO_ 545 XXX_16: 6 SCM SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" BDY +BO_ 576 LEFT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 577 LEFT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 579 RIGHT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 580 RIGHT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 582 ADJACENT_LEFT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 583 ADJACENT_LEFT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 585 ADJACENT_RIGHT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 586 ADJACENT_RIGHT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON @@ -173,16 +277,16 @@ BO_ 773 SEATBELT_STATUS: 7 BDY SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 CAR_SPEED: 8 PCM - SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "" XXX - SG_ CAR_SPEED : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX + SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 780 ACC_HUD: 8 ADAS - SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY + SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY @@ -200,8 +304,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_ IMPERIAL_UNIT : 55|1@0+ (1,0) [0|1] "" XXX - SG_ SET_TO_X1 : 56|1@0+ (1,0) [0|1] "" XXX + SG_ SET_TO_X1 : 55|1@0+ (1,0) [0|1] "" XXX + SG_ IMPERIAL_UNIT : 54|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,11 +369,26 @@ 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 +CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; +CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; +CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; +CM_ SG_ 576 LINE_DISTANCE_VISIBLE "Length of line visible, undecoded"; +CM_ SG_ 577 LINE_FAR_EDGE_POSITION "Appears to be a measure of line thickness, indicates location of the portion of the line furthest from the car, undecoded"; +CM_ SG_ 577 LINE_PARAMETER "Unclear if this is low quality line curvature rate or if this is something else, but it is correlated with line curvature, undecoded"; +CM_ SG_ 577 LINE_DASHED "1 = line is dashed"; +CM_ SG_ 577 LINE_SOLID "1 = line is solid"; 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" +CM_ "honda_crv_ex_2017_can.dbc starts here"; +BO_ 304 GAS_PEDAL_2: 8 PCM + SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON + SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON + SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + BO_ 401 GEARBOX: 8 PCM SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" EON SG_ BOH : 45|6@0+ (1,0) [0|63] "" XXX diff --git a/opendbc/honda_crv_executive_2016_can_generated.dbc b/opendbc/honda_crv_executive_2016_can_generated.dbc new file mode 100644 index 00000000000000..7a7334cd9c6cf1 --- /dev/null +++ b/opendbc/honda_crv_executive_2016_can_generated.dbc @@ -0,0 +1,319 @@ +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; + + +CM_ "Imported file _comma.dbc starts here"; +BO_ 512 GAS_COMMAND: 6 EON + SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR + SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [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.253984064,-83.3) [0|1] "" EON + SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.126992032,-83.3) [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 _honda_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_ + +BU_: EBCM ADAS PCM EPS VSA SCM BDY XXX EPB EON + +BO_ 344 ENGINE_DATA: 8 PCM + SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON + SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON + SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON + SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 380 POWERTRAIN_DATA: 8 PCM + SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON + SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON + SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON + SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "rpm" EON + SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "rpm" EON + SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "rpm" EON + SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "rpm" EON + SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON + SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "rpm" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 420 VSA_STATUS: 8 VSA + SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON + SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 427 STEER_MOTOR_TORQUE: 3 EPS + SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON + SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON + SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON + +BO_ 432 STANDSTILL: 7 VSA + SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON + SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON + +BO_ 464 WHEEL_SPEEDS: 8 VSA + SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 490 VEHICLE_DYNAMICS: 8 VSA + SG_ LONG_ACCEL : 23|16@0- (0.0015384,0) [-20|20] "m/s2" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 506 BRAKE_COMMAND: 8 ADAS + SG_ COMPUTER_BRAKE : 7|10@0+ (1,0) [0|1] "" EBCM + SG_ SET_ME_X00 : 13|5@0+ (1,0) [0|1] "" EBCM + SG_ BRAKE_PUMP_REQUEST : 8|1@0+ (1,0) [0|1] "" EBCM + SG_ SET_ME_X00_2 : 23|3@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM + SG_ SET_ME_X00_3 : 19|1@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM + SG_ COMPUTER_BRAKE_REQUEST : 16|1@0+ (1,0) [0|1] "" EBCM + SG_ SET_ME_1 : 31|1@0+ (1,0) [0|1] "" EBCM + SG_ AEB_REQ_1 : 29|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_REQ_2 : 26|3@0+ (1,0) [0|7] "" XXX + SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM + SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM + SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM + SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX + SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM + +BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA + SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON + SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" EON + SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 773 SEATBELT_STATUS: 7 BDY + SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON + SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON + SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON + +BO_ 777 LOCK_STATUS: 8 XXX + SG_ DOORS_UNLOCKED : 54|1@0+ (1,0) [0|1] "" EON + SG_ DOORS_LOCKED : 55|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 780 ACC_HUD: 8 ADAS + SG_ PCM_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" BDY + SG_ PCM_GAS : 23|8@0+ (1,0) [0|127] "" BDY + SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY + SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY + SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY + SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY + SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY + SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY + 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_ 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_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY + SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY + SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY + SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY + SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY + SG_ ICONS : 63|2@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 + +BO_ 804 CRUISE: 8 PCM + SG_ HUD_SPEED_KPH : 7|8@0+ (1,0) [0|255] "kph" EON + SG_ HUD_SPEED_MPH : 15|8@0+ (1,0) [0|255] "mph" EON + SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON + SG_ CRUISE_SPEED_PCM : 39|8@0+ (1,0) [0|255] "" EON + SG_ BOH2 : 47|8@0- (1,0) [0|255] "" EON + SG_ BOH3 : 55|8@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 829 LKAS_HUD: 5 ADAS + SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY + SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY + SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY + SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY + SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY + SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY + SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY + SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY + SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY + SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY + SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY + SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY + SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY + SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY + SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY + SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY + SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY + SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY + +BO_ 892 CRUISE_PARAMS: 8 PCM + SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + +BO_ 1029 DOORS_STATUS: 8 BDY + SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON + SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; +CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; +CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; +CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; +CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; +CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; + + +VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; +VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; +VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; +VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; +VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; + +CM_ "honda_crv_executive_2016_can.dbc starts here"; + + + +BO_ 342 STEERING_SENSORS: 6 EPS + SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (1,0) [-3000|3000] "deg/s" EON + SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" EON + +BO_ 399 STEER_STATUS: 6 EPS + SG_ STEER_TORQUE_SENSOR : 7|12@0- (-1,0) [-2047.5|2047.5] "tbd" EON + SG_ STEER_TORQUE_MOTOR : 23|16@0- (-1,0) [-31000|31000] "tbd" EON + SG_ STEER_CONTROL_ACTIVE : 36|1@0+ (1,0) [0|1] "" EON + SG_ STEER_STATUS : 35|4@0+ (1,0) [0|15] "" EON + SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" EON + +BO_ 419 GEARBOX: 8 PCM + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ GEAR_SHIFTER : 29|6@0+ (1,0) [0|63] "" EON + SG_ GEAR : 7|8@0+ (1,0) [0|255] "" EON + +BO_ 404 STEERING_CONTROL: 4 EON + SG_ STEER_TORQUE : 7|12@0- (1,0) [-768|768] "" EPS + SG_ SET_ME_X00 : 11|4@0+ (1,0) [0|15] "" EPS + SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS + SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS + SG_ COUNTER : 29|2@0+ (1,0) [0|15] "" EPS + SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EPS + +BO_ 422 SCM_BUTTONS: 8 SCM + SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON + SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON + SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON + SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 487 BRAKE_PRESSURE: 4 VSA + SG_ BRAKE_PRESSURE1 : 7|10@0+ (0.015625,-103) [0|1000] "" EON + SG_ BRAKE_PRESSURE2 : 9|10@0+ (0.015625,-103) [0|1000] "" EON + SG_ COUNTER : 29|2@0+ (1,0) [0|15] "" EON + SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EON + +BO_ 660 SCM_FEEDBACK: 8 SCM + SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON + SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON + SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 891 WIPERS: 8 XXX + SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" EON + 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_ 419 GEAR_SHIFTER 32 "D" 8 "R" 4 "P" ; +VAL_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; +VAL_ 422 LIGHTS_SETTING 3 "high_beam" 2 "low_beam" 1 "position" 0 "no_lights" ; +VAL_ 422 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; +VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; + +CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/honda_crv_hybrid_2019_can_generated.dbc b/opendbc/honda_crv_hybrid_2019_can_generated.dbc index 4fd8ae924a43ef..e29d032014ba55 100644 --- a/opendbc/honda_crv_hybrid_2019_can_generated.dbc +++ b/opendbc/honda_crv_hybrid_2019_can_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _bosch_2018.dbc starts here" +CM_ "Imported file _bosch_2018.dbc starts here"; VERSION "" @@ -37,6 +37,12 @@ NS_ : BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB +BO_ 148 KINEMATICS: 8 XXX + SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + BO_ 228 STEERING_CONTROL: 5 EON SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS @@ -45,6 +51,14 @@ BO_ 228 STEERING_CONTROL: 5 EON SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS +BO_ 229 BOSCH_SUPPLEMENTAL_1: 8 XXX + SG_ SET_ME_X04 : 0|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X00 : 8|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X80 : 16|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X10 : 24|8@1+ (1,0) [0|255] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + BO_ 232 BRAKE_HOLD: 7 XXX SG_ XMISSION_SPEED : 7|14@0- (1,0) [1|0] "" XXX SG_ COMPUTER_BRAKE : 39|16@0+ (1,0) [0|0] "" XXX @@ -52,17 +66,12 @@ BO_ 232 BRAKE_HOLD: 7 XXX SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" XXX -BO_ 304 GAS_PEDAL_2: 8 PCM - SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - BO_ 330 STEERING_SENSORS: 8 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON - SG_ STEER_ANGLE_OFFSET : 39|8@0- (-0.1,0) [-128|127] "deg" EON + SG_ STEER_SENSOR_STATUS_1 : 34|1@0+ (1,0) [0|1] "" EON + SG_ STEER_SENSOR_STATUS_2 : 33|1@0+ (1,0) [0|1] "" EON + SG_ STEER_SENSOR_STATUS_3 : 32|1@0+ (1,0) [0|1] "" EON SG_ STEER_WHEEL_ANGLE : 47|16@0- (-0.1,0) [-500|500] "deg" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON @@ -89,10 +98,11 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON + SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON + SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON @@ -104,6 +114,13 @@ BO_ 420 VSA_STATUS: 8 VSA SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON +BO_ 427 STEER_MOTOR_TORQUE: 3 EPS + SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON + SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON + SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON + BO_ 450 EPB_STATUS: 8 EPB SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" EON SG_ EPB_STATE : 29|2@0+ (1,0) [0|3] "" EON @@ -118,15 +135,26 @@ BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 479 ACC_CONTROL: 8 EON - SG_ SET_TO_1 : 20|5@0+ (1,0) [0|1] "" PCM + SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX - SG_ RELATED_TO_GAS : 7|7@0+ (1,0) [0|69] "" XXX - SG_ GAS_COMMAND : 0|9@0+ (1,0) [0|1] "" PCM - SG_ GAS_BRAKE : 31|14@0- (1,0) [0|1] "" XXX - SG_ ZEROS_BOH : 33|18@0+ (1,0) [100|100] "" XXX + SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX + SG_ ACCEL_COMMAND : 31|11@0- (0.01,0) [0|0] "m/s2" XXX + SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_PREPARE : 43|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 +BO_ 490 VEHICLE_DYNAMICS: 8 VSA + SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + BO_ 495 ACC_CONTROL_ON: 8 XXX SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX @@ -144,6 +172,82 @@ BO_ 545 XXX_16: 6 SCM SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" BDY +BO_ 576 LEFT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 577 LEFT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 579 RIGHT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 580 RIGHT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 582 ADJACENT_LEFT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 583 ADJACENT_LEFT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 585 ADJACENT_RIGHT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 586 ADJACENT_RIGHT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON @@ -173,16 +277,16 @@ BO_ 773 SEATBELT_STATUS: 7 BDY SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 CAR_SPEED: 8 PCM - SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "" XXX - SG_ CAR_SPEED : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX + SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 780 ACC_HUD: 8 ADAS - SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY + SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY @@ -200,8 +304,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_ IMPERIAL_UNIT : 55|1@0+ (1,0) [0|1] "" XXX - SG_ SET_TO_X1 : 56|1@0+ (1,0) [0|1] "" XXX + SG_ SET_TO_X1 : 55|1@0+ (1,0) [0|1] "" XXX + SG_ IMPERIAL_UNIT : 54|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,11 +369,26 @@ 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 +CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; +CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; +CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; +CM_ SG_ 576 LINE_DISTANCE_VISIBLE "Length of line visible, undecoded"; +CM_ SG_ 577 LINE_FAR_EDGE_POSITION "Appears to be a measure of line thickness, indicates location of the portion of the line furthest from the car, undecoded"; +CM_ SG_ 577 LINE_PARAMETER "Unclear if this is low quality line curvature rate or if this is something else, but it is correlated with line curvature, undecoded"; +CM_ SG_ 577 LINE_DASHED "1 = line is dashed"; +CM_ SG_ 577 LINE_SOLID "1 = line is solid"; 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" +CM_ "honda_crv_hybrid_2019_can.dbc starts here"; +BO_ 304 GAS_PEDAL_2: 8 PCM + SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON + SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON + SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + BO_ 419 GEARBOX: 8 PCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON diff --git a/opendbc/honda_crv_touring_2016_can_generated.dbc b/opendbc/honda_crv_touring_2016_can_generated.dbc index 94e20b13797532..a3d21d3b895970 100644 --- a/opendbc/honda_crv_touring_2016_can_generated.dbc +++ b/opendbc/honda_crv_touring_2016_can_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +CM_ "Imported file _comma.dbc starts here"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR @@ -19,7 +19,7 @@ BO_ 513 GAS_SENSOR: 6 INTERCEPTOR 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 _honda_2017.dbc starts here" +CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" @@ -78,6 +78,7 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON @@ -85,6 +86,13 @@ BO_ 420 VSA_STATUS: 8 VSA SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON +BO_ 427 STEER_MOTOR_TORQUE: 3 EPS + SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON + SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON + SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON + BO_ 432 STANDSTILL: 7 VSA SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON @@ -123,7 +131,7 @@ BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM - SG_ AEB : 41|2@0+ (1,0) [0|3] "" XXX + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM @@ -163,7 +171,7 @@ BO_ 780 ACC_HUD: 8 ADAS SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY - SG_ BOH_2 : 35|1@0+ (1,0) [0|1] "" BDY + SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY 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 @@ -173,10 +181,12 @@ BO_ 780 ACC_HUD: 8 ADAS 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_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY + SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY + SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY + SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY + SG_ ICONS : 63|2@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 @@ -226,6 +236,7 @@ BO_ 1029 DOORS_STATUS: 8 BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; @@ -235,11 +246,12 @@ CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; -CM_ "honda_crv_touring_2016_can.dbc starts here" +CM_ "honda_crv_touring_2016_can.dbc starts here"; @@ -250,8 +262,8 @@ BO_ 342 STEERING_SENSORS: 6 EPS SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" EON BO_ 399 STEER_STATUS: 6 EPS - SG_ STEER_TORQUE_SENSOR : 7|12@0- (1,0) [-2047.5|2047.5] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON + SG_ STEER_TORQUE_SENSOR : 7|12@0- (-1,0) [-2047.5|2047.5] "tbd" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_CONTROL_ACTIVE : 36|1@0+ (1,0) [0|1] "" EON SG_ STEER_STATUS : 35|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON diff --git a/opendbc/honda_fit_ex_2018_can_generated.dbc b/opendbc/honda_fit_ex_2018_can_generated.dbc index 4103fa29c6b67d..3f2e2a19d41205 100644 --- a/opendbc/honda_fit_ex_2018_can_generated.dbc +++ b/opendbc/honda_fit_ex_2018_can_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +CM_ "Imported file _comma.dbc starts here"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR @@ -19,7 +19,7 @@ BO_ 513 GAS_SENSOR: 6 INTERCEPTOR 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 _honda_2017.dbc starts here" +CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" @@ -78,6 +78,7 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON @@ -85,6 +86,13 @@ BO_ 420 VSA_STATUS: 8 VSA SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON +BO_ 427 STEER_MOTOR_TORQUE: 3 EPS + SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON + SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON + SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON + BO_ 432 STANDSTILL: 7 VSA SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON @@ -123,7 +131,7 @@ BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM - SG_ AEB : 41|2@0+ (1,0) [0|3] "" XXX + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM @@ -163,7 +171,7 @@ BO_ 780 ACC_HUD: 8 ADAS SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY - SG_ BOH_2 : 35|1@0+ (1,0) [0|1] "" BDY + SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY 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 @@ -173,10 +181,12 @@ BO_ 780 ACC_HUD: 8 ADAS 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_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY + SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY + SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY + SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY + SG_ ICONS : 63|2@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 @@ -226,6 +236,7 @@ BO_ 1029 DOORS_STATUS: 8 BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; @@ -235,11 +246,12 @@ CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; -CM_ "honda_fit_ex_2018_can.dbc starts here" +CM_ "honda_fit_ex_2018_can.dbc starts here"; @@ -268,10 +280,11 @@ BO_ 342 STEERING_SENSORS: 6 EPS SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON + SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON + SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON diff --git a/opendbc/honda_hrv_touring_2019_can_generated.dbc b/opendbc/honda_hrv_touring_2019_can_generated.dbc new file mode 100644 index 00000000000000..5aea74bc90af18 --- /dev/null +++ b/opendbc/honda_hrv_touring_2019_can_generated.dbc @@ -0,0 +1,341 @@ +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; + + +CM_ "Imported file _comma.dbc starts here"; +BO_ 512 GAS_COMMAND: 6 EON + SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR + SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [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.253984064,-83.3) [0|1] "" EON + SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.126992032,-83.3) [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 _honda_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_ + +BU_: EBCM ADAS PCM EPS VSA SCM BDY XXX EPB EON + +BO_ 344 ENGINE_DATA: 8 PCM + SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON + SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON + SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON + SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 380 POWERTRAIN_DATA: 8 PCM + SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON + SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON + SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON + SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "rpm" EON + SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "rpm" EON + SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "rpm" EON + SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "rpm" EON + SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON + SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "rpm" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 420 VSA_STATUS: 8 VSA + SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON + SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 427 STEER_MOTOR_TORQUE: 3 EPS + SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON + SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON + SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON + +BO_ 432 STANDSTILL: 7 VSA + SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON + SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON + +BO_ 464 WHEEL_SPEEDS: 8 VSA + SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 490 VEHICLE_DYNAMICS: 8 VSA + SG_ LONG_ACCEL : 23|16@0- (0.0015384,0) [-20|20] "m/s2" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 506 BRAKE_COMMAND: 8 ADAS + SG_ COMPUTER_BRAKE : 7|10@0+ (1,0) [0|1] "" EBCM + SG_ SET_ME_X00 : 13|5@0+ (1,0) [0|1] "" EBCM + SG_ BRAKE_PUMP_REQUEST : 8|1@0+ (1,0) [0|1] "" EBCM + SG_ SET_ME_X00_2 : 23|3@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM + SG_ SET_ME_X00_3 : 19|1@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM + SG_ COMPUTER_BRAKE_REQUEST : 16|1@0+ (1,0) [0|1] "" EBCM + SG_ SET_ME_1 : 31|1@0+ (1,0) [0|1] "" EBCM + SG_ AEB_REQ_1 : 29|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_REQ_2 : 26|3@0+ (1,0) [0|7] "" XXX + SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM + SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM + SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM + SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX + SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM + +BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA + SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON + SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" EON + SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 773 SEATBELT_STATUS: 7 BDY + SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON + SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON + SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON + +BO_ 777 LOCK_STATUS: 8 XXX + SG_ DOORS_UNLOCKED : 54|1@0+ (1,0) [0|1] "" EON + SG_ DOORS_LOCKED : 55|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 780 ACC_HUD: 8 ADAS + SG_ PCM_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" BDY + SG_ PCM_GAS : 23|8@0+ (1,0) [0|127] "" BDY + SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY + SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY + SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY + SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY + SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY + SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY + 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_ 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_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY + SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY + SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY + SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY + SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY + SG_ ICONS : 63|2@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 + +BO_ 804 CRUISE: 8 PCM + SG_ HUD_SPEED_KPH : 7|8@0+ (1,0) [0|255] "kph" EON + SG_ HUD_SPEED_MPH : 15|8@0+ (1,0) [0|255] "mph" EON + SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON + SG_ CRUISE_SPEED_PCM : 39|8@0+ (1,0) [0|255] "" EON + SG_ BOH2 : 47|8@0- (1,0) [0|255] "" EON + SG_ BOH3 : 55|8@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 829 LKAS_HUD: 5 ADAS + SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY + SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY + SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY + SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY + SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY + SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY + SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY + SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY + SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY + SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY + SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY + SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY + SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY + SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY + SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY + SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY + SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY + SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY + +BO_ 892 CRUISE_PARAMS: 8 PCM + SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + +BO_ 1029 DOORS_STATUS: 8 BDY + SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON + SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; +CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; +CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; +CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; +CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; +CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; + + +VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; +VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; +VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; +VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; +VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; + +CM_ "honda_hrv_touring_2019_can.dbc starts here"; + + + +BO_ 145 KINEMATICS: 8 XXX + SG_ LAT_ACCEL : 7|10@0+ (0.02,-512) [-20|20] "m/s2" EON + +BO_ 228 STEERING_CONTROL: 5 ADAS + SG_ STEER_TORQUE : 7|16@0- (1,0) [-3840|3840] "" EPS + SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS + SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS + SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS + SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS + SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS + +BO_ 316 GAS_PEDAL: 8 PCM + SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON + +BO_ 342 STEERING_SENSORS: 6 EPS + SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (1,0) [-3000|3000] "deg/s" EON + SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON + +BO_ 399 STEER_STATUS: 7 EPS + SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON + SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON + SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON + SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON + +BO_ 401 GEARBOX: 8 PCM + SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" EON + SG_ GEAR : 43|4@0+ (1,0) [0|15] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 422 SCM_BUTTONS: 8 SCM + SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON + SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON + SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON + SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ DRIVERS_DOOR_OPEN : 63|1@0+ (1,0) [0|1] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 487 BRAKE_PRESSURE: 4 VSA + SG_ BRAKE_PRESSURE1 : 7|10@0+ (0.015625,-103) [0|1000] "" EON + SG_ BRAKE_PRESSURE2 : 9|10@0+ (0.015625,-103) [0|1000] "" EON + SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON + +BO_ 660 SCM_FEEDBACK: 8 SCM + SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON + SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON + SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 862 HIGHBEAM_CONTROL: 8 ADAS + SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY + SG_ ZEROS_BOH_2 : 48|4@1+ (1,0) [0|15] "" XXX + SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX + SG_ AUTO_HIGHBEAMS_ACTIVE : 53|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 + +BO_ 884 STALK_STATUS: 8 XXX + SG_ AUTO_HEADLIGHTS : 46|1@0+ (1,0) [0|1] "" EON + SG_ HIGH_BEAM_HOLD : 47|1@0+ (1,0) [0|1] "" EON + SG_ HIGH_BEAM_FLASH : 45|1@0+ (1,0) [0|1] "" EON + SG_ HEADLIGHTS_ON : 54|1@0+ (1,0) [0|1] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + +CM_ SG_ 401 GEAR "10 = reverse, 11 = transition"; +CM_ SG_ 420 BRAKE_HOLD_RELATED "On when Brake Hold engaged"; + +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_ 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_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; +VAL_ 422 LIGHTS_SETTING 3 "high_beam" 2 "low_beam" 1 "position" 0 "no_lights" ; +VAL_ 422 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; + +CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/honda_insight_ex_2019_can_generated.dbc b/opendbc/honda_insight_ex_2019_can_generated.dbc index cbeff828b88502..7287af23dfbb82 100644 --- a/opendbc/honda_insight_ex_2019_can_generated.dbc +++ b/opendbc/honda_insight_ex_2019_can_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _bosch_2018.dbc starts here" +CM_ "Imported file _bosch_2018.dbc starts here"; VERSION "" @@ -37,6 +37,12 @@ NS_ : BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB +BO_ 148 KINEMATICS: 8 XXX + SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + BO_ 228 STEERING_CONTROL: 5 EON SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS @@ -45,6 +51,14 @@ BO_ 228 STEERING_CONTROL: 5 EON SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS +BO_ 229 BOSCH_SUPPLEMENTAL_1: 8 XXX + SG_ SET_ME_X04 : 0|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X00 : 8|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X80 : 16|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X10 : 24|8@1+ (1,0) [0|255] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + BO_ 232 BRAKE_HOLD: 7 XXX SG_ XMISSION_SPEED : 7|14@0- (1,0) [1|0] "" XXX SG_ COMPUTER_BRAKE : 39|16@0+ (1,0) [0|0] "" XXX @@ -52,17 +66,12 @@ BO_ 232 BRAKE_HOLD: 7 XXX SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" XXX -BO_ 304 GAS_PEDAL_2: 8 PCM - SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON - SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - BO_ 330 STEERING_SENSORS: 8 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON - SG_ STEER_ANGLE_OFFSET : 39|8@0- (-0.1,0) [-128|127] "deg" EON + SG_ STEER_SENSOR_STATUS_1 : 34|1@0+ (1,0) [0|1] "" EON + SG_ STEER_SENSOR_STATUS_2 : 33|1@0+ (1,0) [0|1] "" EON + SG_ STEER_SENSOR_STATUS_3 : 32|1@0+ (1,0) [0|1] "" EON SG_ STEER_WHEEL_ANGLE : 47|16@0- (-0.1,0) [-500|500] "deg" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON @@ -89,10 +98,11 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON + SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON + SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON @@ -104,6 +114,13 @@ BO_ 420 VSA_STATUS: 8 VSA SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON +BO_ 427 STEER_MOTOR_TORQUE: 3 EPS + SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON + SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON + SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON + BO_ 450 EPB_STATUS: 8 EPB SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" EON SG_ EPB_STATE : 29|2@0+ (1,0) [0|3] "" EON @@ -118,15 +135,26 @@ BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 479 ACC_CONTROL: 8 EON - SG_ SET_TO_1 : 20|5@0+ (1,0) [0|1] "" PCM + SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX - SG_ RELATED_TO_GAS : 7|7@0+ (1,0) [0|69] "" XXX - SG_ GAS_COMMAND : 0|9@0+ (1,0) [0|1] "" PCM - SG_ GAS_BRAKE : 31|14@0- (1,0) [0|1] "" XXX - SG_ ZEROS_BOH : 33|18@0+ (1,0) [100|100] "" XXX + SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX + SG_ ACCEL_COMMAND : 31|11@0- (0.01,0) [0|0] "m/s2" XXX + SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_PREPARE : 43|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 +BO_ 490 VEHICLE_DYNAMICS: 8 VSA + SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + BO_ 495 ACC_CONTROL_ON: 8 XXX SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX @@ -144,6 +172,82 @@ BO_ 545 XXX_16: 6 SCM SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" BDY +BO_ 576 LEFT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 577 LEFT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 579 RIGHT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 580 RIGHT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 582 ADJACENT_LEFT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 583 ADJACENT_LEFT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 585 ADJACENT_RIGHT_LANE_LINE_1: 8 CAM + SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX + SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX + SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX + SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX + SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + +BO_ 586 ADJACENT_RIGHT_LANE_LINE_2: 8 CAM + SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX + SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX + SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX + SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX + BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON @@ -173,16 +277,16 @@ BO_ 773 SEATBELT_STATUS: 7 BDY SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 CAR_SPEED: 8 PCM - SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "" XXX - SG_ CAR_SPEED : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (1,0) [0|65535] "" XXX - SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX + SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX + SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 780 ACC_HUD: 8 ADAS - SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY + SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY @@ -200,8 +304,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_ IMPERIAL_UNIT : 55|1@0+ (1,0) [0|1] "" XXX - SG_ SET_TO_X1 : 56|1@0+ (1,0) [0|1] "" XXX + SG_ SET_TO_X1 : 55|1@0+ (1,0) [0|1] "" XXX + SG_ IMPERIAL_UNIT : 54|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,11 +369,26 @@ 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 +CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; +CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; +CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; +CM_ SG_ 576 LINE_DISTANCE_VISIBLE "Length of line visible, undecoded"; +CM_ SG_ 577 LINE_FAR_EDGE_POSITION "Appears to be a measure of line thickness, indicates location of the portion of the line furthest from the car, undecoded"; +CM_ SG_ 577 LINE_PARAMETER "Unclear if this is low quality line curvature rate or if this is something else, but it is correlated with line curvature, undecoded"; +CM_ SG_ 577 LINE_DASHED "1 = line is dashed"; +CM_ SG_ 577 LINE_SOLID "1 = line is solid"; 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" +CM_ "honda_insight_ex_2019_can.dbc starts here"; +BO_ 304 GAS_PEDAL_2: 8 PCM + SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON + SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON + SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + BO_ 419 GEARBOX: 8 PCM SG_ GEAR : 7|8@0+ (1,0) [0|255] "" EON SG_ GEAR_SHIFTER : 29|6@0+ (1,0) [0|63] "" EON diff --git a/opendbc/honda_odyssey_exl_2018_generated.dbc b/opendbc/honda_odyssey_exl_2018_generated.dbc index 1bc6e96c175882..7c7526f08c7a67 100644 --- a/opendbc/honda_odyssey_exl_2018_generated.dbc +++ b/opendbc/honda_odyssey_exl_2018_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +CM_ "Imported file _comma.dbc starts here"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR @@ -19,7 +19,7 @@ BO_ 513 GAS_SENSOR: 6 INTERCEPTOR 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 _honda_2017.dbc starts here" +CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" @@ -78,6 +78,7 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON @@ -85,6 +86,13 @@ BO_ 420 VSA_STATUS: 8 VSA SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON +BO_ 427 STEER_MOTOR_TORQUE: 3 EPS + SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON + SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON + SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON + BO_ 432 STANDSTILL: 7 VSA SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON @@ -123,7 +131,7 @@ BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM - SG_ AEB : 41|2@0+ (1,0) [0|3] "" XXX + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM @@ -163,7 +171,7 @@ BO_ 780 ACC_HUD: 8 ADAS SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY - SG_ BOH_2 : 35|1@0+ (1,0) [0|1] "" BDY + SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY 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 @@ -173,10 +181,12 @@ BO_ 780 ACC_HUD: 8 ADAS 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_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY + SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY + SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY + SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY + SG_ ICONS : 63|2@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 @@ -226,6 +236,7 @@ BO_ 1029 DOORS_STATUS: 8 BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; @@ -235,11 +246,12 @@ CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; -CM_ "honda_odyssey_exl_2018.dbc starts here" +CM_ "honda_odyssey_exl_2018.dbc starts here"; @@ -260,10 +272,11 @@ BO_ 342 STEERING_SENSORS: 6 EPS SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON + SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON + SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON diff --git a/opendbc/honda_odyssey_extreme_edition_2018_china_can.dbc b/opendbc/honda_odyssey_extreme_edition_2018_china_can.dbc deleted file mode 100644 index 6bdcaab04b9dd6..00000000000000 --- a/opendbc/honda_odyssey_extreme_edition_2018_china_can.dbc +++ /dev/null @@ -1,299 +0,0 @@ -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_: EBCM ADAS PCM EPS VSA SCM BDY XXX EPB EON INTERCEPTOR - - -BO_ 344 ENGINE_DATA: 8 PCM - SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON - SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON - SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - SG_ ZEROS : 23|16@0+ (1,0) [0|15000] "" EON - -BO_ 380 POWERTRAIN_DATA: 8 PCM - SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON - SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON - SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON - SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "rpm" EON - SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "rpm" EON - SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "rpm" EON - SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "rpm" EON - SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON - SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "rpm" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 432 STANDSTILL: 7 VSA - SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON - SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON - -BO_ 464 WHEEL_SPEEDS: 8 VSA - SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON - SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON - SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON - SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 490 VEHICLE_DYNAMICS: 8 VSA - SG_ LONG_ACCEL : 23|16@0- (0.0015384,0) [-20|20] "m/s2" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 506 BRAKE_COMMAND: 8 ADAS - SG_ COMPUTER_BRAKE : 7|10@0+ (1,0) [0|1] "" EBCM - SG_ ZEROS_BOH : 13|5@0+ (1,0) [0|1] "" EBCM - SG_ BRAKE_PUMP_REQUEST : 8|1@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_BOH2 : 23|3@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_BOH3 : 19|1@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM - SG_ COMPUTER_BRAKE_REQUEST : 16|1@0+ (1,0) [0|1] "" EBCM - SG_ SET_ME_0X80 : 31|8@0+ (1,0) [0|1] "" EBCM - SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM - SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM - SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM - SG_ ZEROS_BOH6 : 44|1@0+ (1,0) [0|1] "" EBCM - SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM - SG_ ZEROS_BOH4 : 55|8@0+ (1,0) [0|0] "" EBCM - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM - -BO_ 512 GAS_COMMAND: 6 EON - SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR - SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR - SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR - SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" INTERCEPTOR - SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" INTERCEPTOR - -BO_ 513 GAS_SENSOR: 6 INTERCEPTOR - SG_ INTERCEPTOR_GAS : 7|16@0+ (0.253984064,-83.3) [0|1] "" EON - SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" EON - SG_ STATE : 39|8@0+ (1,0) [0|255] "" EON - SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON - -BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA - SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON - SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON - SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON - SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON - SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" EON - SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 773 SEATBELT_STATUS: 7 BDY - SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON - SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON - SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON - SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON - SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON - SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON - SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON - -BO_ 777 LOCK_STATUS: 8 XXX - SG_ DOORS_UNLOCKED : 54|1@0+ (1,0) [0|1] "" EON - SG_ DOORS_LOCKED : 55|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 780 ACC_HUD: 8 ADAS - SG_ PCM_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" BDY - SG_ PCM_GAS : 23|8@0+ (1,0) [0|127] "" BDY - SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY - SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY - SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY - SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY - SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY - SG_ BOH_2 : 35|1@0+ (1,0) [0|1] "" BDY - 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_ 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_ 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 - -BO_ 804 CRUISE: 8 PCM - SG_ HUD_SPEED_KPH : 7|8@0+ (1,0) [0|255] "kph" EON - SG_ HUD_SPEED_MPH : 15|8@0+ (1,0) [0|255] "mph" EON - SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON - SG_ CRUISE_SPEED_PCM : 39|8@0+ (1,0) [0|255] "" EON - SG_ BOH2 : 47|8@0- (1,0) [0|255] "" EON - SG_ BOH3 : 55|8@0+ (1,0) [0|255] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - -BO_ 829 LKAS_HUD: 5 ADAS - SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY - SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY - SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY - SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY - SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY - SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY - SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY - SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY - SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY - SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY - SG_ BOH2 : 23|2@0+ (1,0) [0|4] "" BDY - SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY - SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY - SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY - SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY - SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY - SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY - SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY - SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY - -BO_ 892 CRUISE_PARAMS: 8 PCM - SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - -BO_ 316 GAS_PEDAL: 8 PCM - SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON - -BO_ 342 STEERING_SENSORS: 6 EPS - SG_ STEER_ANGLE_RATE : 23|16@0- (1,0) [-3000|3000] "deg/s" EON - SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" EON - SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON - -BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-2985|2985] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON - SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON - SG_ STEER_STATUS : 43|4@0+ (1,0) [0|15] "" EON - SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON - -BO_ 401 GEARBOX: 8 PCM - SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" EON - SG_ GEAR : 35|4@0+ (1,0) [0|15] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 404 STEERING_CONTROL: 4 EON - SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS - SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS - SG_ COUNTER : 29|2@0+ (1,0) [0|15] "" EPS - SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EPS - SG_ STEER_TORQUE : 7|16@0- (-1,0) [-32767|32767] "" EPS - -BO_ 420 VSA_STATUS: 8 VSA - SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON - SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX - SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON - SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 422 SCM_BUTTONS: 8 SCM - SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON - SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON - SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON - SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON - SG_ DRIVERS_DOOR_OPEN : 63|1@0+ (1,0) [0|1] "" XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 450 EPB_STATUS: 8 XXX - SG_ EPB_BRAKE_AND_PULL : 6|1@0+ (1,0) [0|1] "" XXX - SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" XXX - SG_ EPB_STATE : 29|2@0+ (1,0) [0|1] "" XXX - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX - -BO_ 660 SCM_FEEDBACK: 8 SCM - SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON - SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON - SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON - -BO_ 862 HIGHBEAM_CONTROL: 8 ADAS - SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY - SG_ ZEROS_BOH_2 : 48|4@1+ (1,0) [0|15] "" XXX - SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX - SG_ AUTO_HIGHBEAMS_ACTIVE : 53|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 - -BO_ 1302 ODOMETER: 8 XXX - SG_ ODOMETER : 7|24@0+ (1,0) [0|16777215] "km" EON - SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON - SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON - - - - -CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; -CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; -CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; -CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; -CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; -CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; -CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; -CM_ SG_ 401 GEAR "10 = reverse, 11 = transition"; -VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; -VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; -VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; -VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; -VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; -VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; -VAL_ 399 STEER_STATUS 5 "fault" 4 "no_torque_alert_2" 2 "no_torque_alert_1" 0 "normal" ; -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_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; -VAL_ 422 LIGHTS_SETTING 3 "high_beam" 2 "low_beam" 1 "position" 0 "no_lights" ; -VAL_ 422 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; diff --git a/opendbc/honda_odyssey_extreme_edition_2018_china_can_generated.dbc b/opendbc/honda_odyssey_extreme_edition_2018_china_can_generated.dbc new file mode 100644 index 00000000000000..b5422c0190da0c --- /dev/null +++ b/opendbc/honda_odyssey_extreme_edition_2018_china_can_generated.dbc @@ -0,0 +1,331 @@ +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; + + +CM_ "Imported file _comma.dbc starts here"; +BO_ 512 GAS_COMMAND: 6 EON + SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR + SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [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.253984064,-83.3) [0|1] "" EON + SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.126992032,-83.3) [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 _honda_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_ + +BU_: EBCM ADAS PCM EPS VSA SCM BDY XXX EPB EON + +BO_ 344 ENGINE_DATA: 8 PCM + SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON + SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON + SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON + SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 380 POWERTRAIN_DATA: 8 PCM + SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON + SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON + SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON + SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "rpm" EON + SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "rpm" EON + SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "rpm" EON + SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "rpm" EON + SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON + SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "rpm" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 420 VSA_STATUS: 8 VSA + SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON + SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 427 STEER_MOTOR_TORQUE: 3 EPS + SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON + SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON + SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON + +BO_ 432 STANDSTILL: 7 VSA + SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON + SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON + SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON + +BO_ 464 WHEEL_SPEEDS: 8 VSA + SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON + SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 490 VEHICLE_DYNAMICS: 8 VSA + SG_ LONG_ACCEL : 23|16@0- (0.0015384,0) [-20|20] "m/s2" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 506 BRAKE_COMMAND: 8 ADAS + SG_ COMPUTER_BRAKE : 7|10@0+ (1,0) [0|1] "" EBCM + SG_ SET_ME_X00 : 13|5@0+ (1,0) [0|1] "" EBCM + SG_ BRAKE_PUMP_REQUEST : 8|1@0+ (1,0) [0|1] "" EBCM + SG_ SET_ME_X00_2 : 23|3@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM + SG_ SET_ME_X00_3 : 19|1@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM + SG_ COMPUTER_BRAKE_REQUEST : 16|1@0+ (1,0) [0|1] "" EBCM + SG_ SET_ME_1 : 31|1@0+ (1,0) [0|1] "" EBCM + SG_ AEB_REQ_1 : 29|1@0+ (1,0) [0|1] "" XXX + SG_ AEB_REQ_2 : 26|3@0+ (1,0) [0|7] "" XXX + SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM + SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM + SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM + SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM + SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX + SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM + +BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA + SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON + SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON + SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" EON + SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 773 SEATBELT_STATUS: 7 BDY + SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON + SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON + SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON + SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON + +BO_ 777 LOCK_STATUS: 8 XXX + SG_ DOORS_UNLOCKED : 54|1@0+ (1,0) [0|1] "" EON + SG_ DOORS_LOCKED : 55|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 780 ACC_HUD: 8 ADAS + SG_ PCM_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" BDY + SG_ PCM_GAS : 23|8@0+ (1,0) [0|127] "" BDY + SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY + SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY + SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY + SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY + SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY + SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY + 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_ 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_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY + SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY + SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY + SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY + SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY + SG_ ICONS : 63|2@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 + +BO_ 804 CRUISE: 8 PCM + SG_ HUD_SPEED_KPH : 7|8@0+ (1,0) [0|255] "kph" EON + SG_ HUD_SPEED_MPH : 15|8@0+ (1,0) [0|255] "mph" EON + SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON + SG_ CRUISE_SPEED_PCM : 39|8@0+ (1,0) [0|255] "" EON + SG_ BOH2 : 47|8@0- (1,0) [0|255] "" EON + SG_ BOH3 : 55|8@0+ (1,0) [0|255] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +BO_ 829 LKAS_HUD: 5 ADAS + SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY + SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY + SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY + SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY + SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY + SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY + SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY + SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY + SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY + SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY + SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY + SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY + SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY + SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY + SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY + SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY + SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY + SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY + +BO_ 892 CRUISE_PARAMS: 8 PCM + SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + +BO_ 1029 DOORS_STATUS: 8 BDY + SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON + SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON + SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; +CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; +CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; +CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; +CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; +CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; + + +VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; +VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; +VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; +VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; +VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; + +CM_ "honda_odyssey_extreme_edition_2018_china_can.dbc starts here"; + + + +BO_ 316 GAS_PEDAL: 8 PCM + SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON + +BO_ 342 STEERING_SENSORS: 6 EPS + SG_ STEER_ANGLE_RATE : 23|16@0- (1,0) [-3000|3000] "deg/s" EON + SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" EON + SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON + +BO_ 399 STEER_STATUS: 7 EPS + SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-2985|2985] "tbd" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON + SG_ STEER_STATUS : 43|4@0+ (1,0) [0|15] "" EON + SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON + SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON + SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON + SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON + +BO_ 401 GEARBOX: 8 PCM + SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" EON + SG_ GEAR : 35|4@0+ (1,0) [0|15] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 404 STEERING_CONTROL: 4 EON + SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS + SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS + SG_ COUNTER : 29|2@0+ (1,0) [0|15] "" EPS + SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EPS + SG_ STEER_TORQUE : 7|16@0- (-1,0) [-32767|32767] "" EPS + +BO_ 422 SCM_BUTTONS: 8 SCM + SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON + SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON + SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON + SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON + SG_ DRIVERS_DOOR_OPEN : 63|1@0+ (1,0) [0|1] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 450 EPB_STATUS: 8 XXX + SG_ EPB_BRAKE_AND_PULL : 6|1@0+ (1,0) [0|1] "" XXX + SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" XXX + SG_ EPB_STATE : 29|2@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX + +BO_ 660 SCM_FEEDBACK: 8 SCM + SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON + SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON + SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON + +BO_ 862 HIGHBEAM_CONTROL: 8 ADAS + SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY + SG_ ZEROS_BOH_2 : 48|4@1+ (1,0) [0|15] "" XXX + SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX + SG_ AUTO_HIGHBEAMS_ACTIVE : 53|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 + +BO_ 1302 ODOMETER: 8 XXX + SG_ ODOMETER : 7|24@0+ (1,0) [0|16777215] "km" EON + SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON + +CM_ SG_ 401 GEAR "10 = reverse, 11 = transition"; +VAL_ 399 STEER_STATUS 5 "fault" 4 "no_torque_alert_2" 2 "no_torque_alert_1" 0 "normal" ; +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_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; +VAL_ 422 LIGHTS_SETTING 3 "high_beam" 2 "low_beam" 1 "position" 0 "no_lights" ; +VAL_ 422 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; diff --git a/opendbc/honda_pilot_touring_2017_can_generated.dbc b/opendbc/honda_pilot_touring_2017_can_generated.dbc index c19871b9e622d3..9cca24912c6db3 100644 --- a/opendbc/honda_pilot_touring_2017_can_generated.dbc +++ b/opendbc/honda_pilot_touring_2017_can_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +CM_ "Imported file _comma.dbc starts here"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR @@ -19,7 +19,7 @@ BO_ 513 GAS_SENSOR: 6 INTERCEPTOR 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 _honda_2017.dbc starts here" +CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" @@ -78,6 +78,7 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON @@ -85,6 +86,13 @@ BO_ 420 VSA_STATUS: 8 VSA SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON +BO_ 427 STEER_MOTOR_TORQUE: 3 EPS + SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON + SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON + SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON + BO_ 432 STANDSTILL: 7 VSA SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON @@ -123,7 +131,7 @@ BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM - SG_ AEB : 41|2@0+ (1,0) [0|3] "" XXX + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM @@ -163,7 +171,7 @@ BO_ 780 ACC_HUD: 8 ADAS SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY - SG_ BOH_2 : 35|1@0+ (1,0) [0|1] "" BDY + SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY 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 @@ -173,10 +181,12 @@ BO_ 780 ACC_HUD: 8 ADAS 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_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY + SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY + SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY + SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY + SG_ ICONS : 63|2@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 @@ -226,6 +236,7 @@ BO_ 1029 DOORS_STATUS: 8 BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; @@ -235,11 +246,12 @@ CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; -CM_ "honda_pilot_touring_2017_can.dbc starts here" +CM_ "honda_pilot_touring_2017_can.dbc starts here"; @@ -268,10 +280,11 @@ BO_ 342 STEERING_SENSORS: 6 EPS SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON + SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON + SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON diff --git a/opendbc/honda_ridgeline_black_edition_2017_can_generated.dbc b/opendbc/honda_ridgeline_black_edition_2017_can_generated.dbc index 6d8186c19ddd0b..0c04d917940727 100644 --- a/opendbc/honda_ridgeline_black_edition_2017_can_generated.dbc +++ b/opendbc/honda_ridgeline_black_edition_2017_can_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +CM_ "Imported file _comma.dbc starts here"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR @@ -19,7 +19,7 @@ BO_ 513 GAS_SENSOR: 6 INTERCEPTOR 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 _honda_2017.dbc starts here" +CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" @@ -78,6 +78,7 @@ BO_ 380 POWERTRAIN_DATA: 8 PCM BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON + SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON @@ -85,6 +86,13 @@ BO_ 420 VSA_STATUS: 8 VSA SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON +BO_ 427 STEER_MOTOR_TORQUE: 3 EPS + SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON + SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON + SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON + SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON + SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON + BO_ 432 STANDSTILL: 7 VSA SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON @@ -123,7 +131,7 @@ BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM - SG_ AEB : 41|2@0+ (1,0) [0|3] "" XXX + SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM @@ -163,7 +171,7 @@ BO_ 780 ACC_HUD: 8 ADAS SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY - SG_ BOH_2 : 35|1@0+ (1,0) [0|1] "" BDY + SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY 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 @@ -173,10 +181,12 @@ BO_ 780 ACC_HUD: 8 ADAS 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_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY + SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY + SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY + SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY + SG_ ICONS : 63|2@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 @@ -226,6 +236,7 @@ BO_ 1029 DOORS_STATUS: 8 BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; +CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; @@ -235,11 +246,12 @@ CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; +VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; -CM_ "honda_ridgeline_black_edition_2017_can.dbc starts here" +CM_ "honda_ridgeline_black_edition_2017_can.dbc starts here"; @@ -263,10 +275,11 @@ BO_ 342 STEERING_SENSORS: 6 EPS SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON BO_ 399 STEER_STATUS: 7 EPS - SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON - SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON + SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON + SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON + SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON diff --git a/opendbc/hyundai_2015_ccan.dbc b/opendbc/hyundai_2015_ccan.dbc deleted file mode 100644 index addc0cac31fa08..00000000000000 --- a/opendbc/hyundai_2015_ccan.dbc +++ /dev/null @@ -1,1416 +0,0 @@ -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_: IAP ODS _4WD BCM HUD DATC MDPS AAF_Tester AEMC SMK _4WD EPB CUBIS MTS TMU EVP CGW TPMS LPI DI_BOX SPAS EMS LCA TCU IBOX FATC AFLS FPCM SCC AHLS AVM ABS SNV OPI PGS SAS AAF Dummy LDWS_LKAS LVR ESC PSB CLU ECS ACU REA - -BO_ 1532 ODS13: 5 ODS - SG_ CR_Ods_ID : 0|8@1+ (1.0,0.0) [0.0|255.0] "" ACU - SG_ CR_Ods_Chksum_H : 8|8@1+ (1.0,0.0) [0.0|255.0] "" Dummy - SG_ CR_Ods_Chksum_L : 16|8@1+ (1.0,0.0) [0.0|255.0] "" Dummy - SG_ CR_Ods_RomID_H : 24|8@1+ (1.0,0.0) [0.0|255.0] "" Dummy - SG_ CR_Ods_RomID_L : 32|8@1+ (1.0,0.0) [0.0|255.0] "" Dummy - -BO_ 1531 ODS12: 8 ODS - SG_ CR_Ods_SerNum0 : 0|8@1+ (1.0,0.0) [0.0|255.0] "" ACU - SG_ CR_Ods_SerNum1 : 8|8@1+ (1.0,0.0) [0.0|255.0] "" ACU - SG_ CR_Ods_SerNum2 : 16|8@1+ (1.0,0.0) [0.0|255.0] "" ACU - SG_ CR_Ods_SerNum3 : 24|8@1+ (1.0,0.0) [0.0|255.0] "" ACU - SG_ CR_Ods_SerNum4 : 32|8@1+ (1.0,0.0) [0.0|255.0] "" ACU - SG_ CR_Ods_SerNum5 : 40|8@1+ (1.0,0.0) [0.0|255.0] "" ACU - SG_ CR_Ods_SerNum6 : 48|8@1+ (1.0,0.0) [0.0|255.0] "" ACU - SG_ CR_Ods_SerNum7 : 56|8@1+ (1.0,0.0) [0.0|255.0] "" ACU - -BO_ 1530 ODS11: 8 ODS - SG_ CF_Ods_PrcCmd : 1|1@1+ (1.0,0.0) [0.0|1.0] "" Dummy - SG_ CF_Ods_BtsFail : 3|1@1+ (1.0,0.0) [0.0|1.0] "" Dummy - SG_ CF_Ods_AcuRcvSN : 4|1@1+ (1.0,0.0) [0.0|1.0] "" ACU - SG_ CF_Ods_EolCal : 5|1@1+ (1.0,0.0) [0.0|1.0] "" ACU - SG_ CF_Ods_PsFail : 6|1@1+ (1.0,0.0) [0.0|1.0] "" ACU - SG_ CF_Ods_EcuFail : 7|1@1+ (1.0,0.0) [0.0|1.0] "" ACU - SG_ CF_Ods_WgtStat : 8|1@1+ (1.0,0.0) [0.0|1.0] "" ACU - SG_ CF_Ods_OccStat : 16|1@1+ (1.0,0.0) [0.0|1.0] "" ACU - SG_ CR_Wcs_ErrStat : 32|8@1+ (1.0,0.0) [0.0|63.0] "" ACU - SG_ CR_Wcs_ClassStat : 40|8@1+ (1.0,0.0) [0.0|4.0] "" ACU,BCM - -BO_ 1017 ECS12: 4 ECS - SG_ Height_FL : 0|8@1+ (1.0,-128.0) [-128.0|127.0] "mm" AFLS - SG_ Height_FR : 8|8@1+ (1.0,-128.0) [-128.0|127.0] "mm" AFLS - SG_ Height_RL : 16|8@1+ (1.0,-128.0) [-128.0|127.0] "mm" AFLS - SG_ Height_RR : 24|8@1+ (1.0,-128.0) [-128.0|127.0] "mm" AFLS - -BO_ 1268 SPAS12: 8 SPAS - SG_ CF_Spas_HMI_Stat : 0|8@1+ (1.0,0.0) [0.0|255.0] "" CLU - SG_ CF_Spas_Disp : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,EMS - SG_ CF_Spas_FIL_Ind : 10|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU - SG_ CF_Spas_FIR_Ind : 13|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU - SG_ CF_Spas_FOL_Ind : 16|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU - SG_ CF_Spas_FOR_Ind : 19|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU - SG_ CF_Spas_VolDown : 22|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Spas_RIL_Ind : 24|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU - SG_ CF_Spas_RIR_Ind : 27|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU - SG_ CF_Spas_FLS_Alarm : 30|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Spas_ROL_Ind : 32|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU - SG_ CF_Spas_ROR_Ind : 35|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU - SG_ CF_Spas_FCS_Alarm : 38|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Spas_FI_Ind : 40|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU - SG_ CF_Spas_RI_Ind : 43|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU - SG_ CF_Spas_FRS_Alarm : 46|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Spas_FR_Alarm : 48|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU - SG_ CF_Spas_RR_Alarm : 50|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU - SG_ CF_Spas_BEEP_Alarm : 52|4@1+ (1.0,0.0) [0.0|15.0] "" BCM,CLU - SG_ CF_Spas_StatAlarm : 56|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Spas_RLS_Alarm : 57|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Spas_RCS_Alarm : 59|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Spas_RRS_Alarm : 61|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - -BO_ 1265 CLU11: 4 CLU - SG_ CF_Clu_CruiseSwState : 0|3@1+ (1.0,0.0) [0.0|7.0] "" EMS,LDWS_LKAS,SCC - SG_ CF_Clu_CruiseSwMain : 3|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,LDWS_LKAS,SCC - SG_ CF_Clu_SldMainSW : 4|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_Clu_ParityBit1 : 5|1@1+ (1.0,0.0) [0.0|1.0] "pulse count" EMS - SG_ CF_Clu_VanzDecimal : 6|2@1+ (0.125,0.0) [0.0|0.375] "" EMS - SG_ CF_Clu_Vanz : 8|9@1+ (0.5,0.0) [0.0|255.5] "km/h or MPH" BCM,CUBIS,EMS,IBOX,LDWS_LKAS,MDPS,SCC - SG_ CF_Clu_SPEED_UNIT : 17|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CUBIS,EMS,IBOX,LDWS_LKAS,MDPS,SCC - SG_ CF_Clu_DetentOut : 18|1@1+ (1.0,0.0) [0.0|1.0] "" AVM,BCM,LCA,PGS,SPAS - SG_ CF_Clu_RheostatLevel : 19|5@1+ (1.0,0.0) [0.0|31.0] "" AVM,BCM,LCA,PGS,SPAS - SG_ CF_Clu_CluInfo : 24|1@1+ (1.0,0.0) [0.0|1.0] "" BCM - SG_ CF_Clu_AmpInfo : 25|1@1+ (1.0,0.0) [0.0|1.0] "" BCM - SG_ CF_Clu_AliveCnt1 : 28|4@1+ (1.0,0.0) [0.0|15.0] "" AHLS,EMS,EPB,LDWS_LKAS,MDPS,SCC - -BO_ 1492 TMU_GW_PE_01: 8 CLU - SG_ TMU_IVRActivity : 0|2@1+ (1.0,0.0) [0.0|3.0] "" DATC - SG_ TMU_PhoneActivity : 2|2@1+ (1.0,0.0) [0.0|3.0] "" DATC - -BO_ 1491 HU_DATC_PE_00: 8 CLU - SG_ HU_VRActivity : 0|2@1+ (1.0,0.0) [0.0|3.0] "" DATC - SG_ HU_PhoneActivity : 2|2@1+ (1.0,0.0) [0.0|3.0] "" DATC - SG_ BlowerNoiseControl : 4|2@1+ (1.0,0.0) [0.0|3.0] "" DATC - -BO_ 1490 HU_DATC_E_02: 8 CLU - SG_ HU_DATC_RearOnOffSet : 6|2@1+ (1.0,0.0) [0.0|3.0] "" DATC - SG_ HU_DATC_ADSOnOffSet : 8|2@1+ (1.0,0.0) [0.0|3.0] "" DATC - -BO_ 1479 EMS21: 8 EMS - SG_ SCR_LEVEL_WARN_LAMP : 0|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ SCR_LEVEL_WARN : 1|3@1+ (1.0,0.0) [0.0|4.0] "" CLU - SG_ SCR_SYS_ERROR_WARN : 4|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - SG_ SCR_SYSTEM_WARN_LAMP : 7|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ SCR_INDUCEMENT_EXIT_COND : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ SCR_UREA_LEVEL : 16|8@1+ (0.5,0.0) [0.0|100.0] "%" CLU - SG_ SCR_NO_REMAINING_RESTARTS : 24|8@1+ (1.0,0.0) [0.0|255.0] "" CLU - SG_ SCR_REMAINING_DISTANCE : 32|16@1+ (1.0,0.0) [0.0|25000.0] "km" CLU - -BO_ 1472 GW_Warning_PE: 8 BCM - SG_ Audio_VolumeDown : 38|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ Pas_Spkr_Flh_Alarm : 48|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ Pas_Spkr_Fcnt_Alarm : 50|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ Pas_Spkr_Frh_Alarm : 52|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ Pas_Spkr_Rlh_Alarm : 56|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,PGS - SG_ Pas_Spkr_Rcnt_Alarm : 58|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ Pas_Spkr_Rrh_Alarm : 60|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,PGS - -BO_ 1984 CAL_SAS11: 2 ESC - SG_ CCW : 0|4@1+ (1.0,0.0) [0.0|15.0] "" SAS - SG_ SAS_CID : 4|11@1+ (1.0,0.0) [0.0|2047.0] "" SAS - -BO_ 1456 CLU12: 4 CLU - SG_ CF_Clu_Odometer : 0|24@1+ (0.1,0.0) [0.0|1677721.4] "km" _4WD,AAF,BCM,CUBIS,EMS,EPB,IBOX,LDWS_LKAS,SCC,TPMS - -BO_ 688 SAS11: 5 MDPS - SG_ SAS_Angle : 0|16@1- (0.1,0.0) [-3276.8|3276.7] "Deg" _4WD,ACU,AFLS,AVM,CLU,ECS,EMS,ESC,IBOX,LCA,LDWS_LKAS,PGS,PSB,SCC,SPAS,TCU,_4WD,ACU,AFLS,AVM,BCM,CLU,ECS,EMS,ESC,IBOX,LCA,LDWS_LKAS,PGS,PSB,SCC,SPAS,TCU - SG_ SAS_Speed : 16|8@1+ (4.0,0.0) [0.0|1016.0] "" AFLS,ECS,ESC,IBOX,LDWS_LKAS,SCC,SPAS,TCU,AFLS,ECS,ESC,IBOX,LDWS_LKAS,SCC,SPAS,TCU - SG_ SAS_Stat : 24|8@1+ (1.0,0.0) [0.0|255.0] "" ECS,ESC,IBOX,LDWS_LKAS,PSB,SCC,SPAS,TCU,ECS,ESC,IBOX,LDWS_LKAS,PSB,SCC,SPAS,TCU - SG_ MsgCount : 32|4@1+ (1.0,0.0) [0.0|15.0] "" ECS,ESC,IBOX,LDWS_LKAS,PSB,SCC,SPAS,ECS,ESC,IBOX,LDWS_LKAS,PSB,SCC,SPAS - SG_ CheckSum : 36|4@1+ (1.0,0.0) [0.0|15.0] "" ECS,EMS,ESC,IBOX,LDWS_LKAS,PSB,SCC,SPAS,ECS,EMS,ESC,IBOX,LDWS_LKAS,PSB,SCC,SPAS - -BO_ 1441 ACU12: 8 ACU - SG_ CR_Acu_SN : 0|64@1+ (1.0,0.0) [0.0|0.0] "" ODS - -BO_ 1440 ACU11: 8 ACU - SG_ CF_Ods_SNRcv : 1|1@1+ (1.0,0.0) [0.0|1.0] "" ODS - SG_ CF_Ods_IDRcv : 2|1@1+ (1.0,0.0) [0.0|1.0] "" ODS - SG_ CF_Ods_RZReq : 4|1@1+ (1.0,0.0) [0.0|1.0] "" ODS - SG_ CF_Abg_DepInhEnt : 6|1@1+ (1.0,0.0) [0.0|1.0] "" ODS - SG_ CF_Abg_DepEnt : 7|1@1+ (1.0,0.0) [0.0|1.0] "" ODS - SG_ CF_PasBkl_FltStat : 28|1@1+ (1.0,0.0) [0.0|1.0] "" ODS,PSB - SG_ CF_DriBkl_FltStat : 29|1@1+ (1.0,0.0) [0.0|1.0] "" ODS,PSB - SG_ CF_PasBkl_Stat : 30|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,ODS,PSB,TMU - SG_ CF_DriBkl_Stat : 31|1@1+ (1.0,0.0) [0.0|1.0] "" ODS,PSB - SG_ CF_SWL_Ind : 32|2@1+ (1.0,0.0) [0.0|3.0] "" CUBIS,IBOX - SG_ CF_Acu_FltStat : 34|2@1+ (1.0,0.0) [0.0|3.0] "" CUBIS,IBOX - SG_ CF_Acu_ExtOfSab : 36|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU,CUBIS,IBOX - SG_ CF_Acu_Dtc : 40|16@1+ (1.0,0.0) [0.0|65535.0] "" CUBIS,IBOX - SG_ CF_Acu_NumOfFlt : 56|8@1+ (1.0,0.0) [0.0|255.0] "" CUBIS,IBOX - -BO_ 1437 AHLS11: 8 AHLS - SG_ CF_Ahls_WarnLamp : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Ahls_WarnMsg : 2|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - -BO_ 1434 PSB11: 2 PSB - SG_ PSB_LH_FAIL : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ PSB_LH_TGL : 2|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ PSB_LH_ACT : 3|4@1+ (1.0,0.0) [0.0|4.0] "" Dummy - SG_ PSB_RH_FAIL : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ PSB_RH_TGL : 10|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ PSB_RH_ACT : 11|4@1+ (1.0,0.0) [0.0|4.0] "" Dummy - -BO_ 916 TCS13: 8 ESC - SG_ aBasis : 0|11@1+ (0.01,-10.23) [-10.23|10.24] "m/s^2" EMS,SCC - SG_ BrakeLight : 11|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,SCC - SG_ DCEnable : 12|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,SCC - SG_ AliveCounterTCS : 13|3@1+ (1.0,0.0) [0.0|7.0] "" EMS,SCC - SG_ ACCReqLim : 22|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,SCC - SG_ TQI_ACC : 24|8@1+ (0.390625,0.0) [0.0|99.609375] "%" EMS - SG_ ACCEL_REF_ACC : 32|11@1+ (0.01,-10.23) [-10.23|10.24] "m/s^2" EMS,SCC - SG_ ACCEnable : 43|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,SCC - SG_ DriverOverride : 45|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,SCC - SG_ StandStill : 47|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,SCC - SG_ CheckSum_TCS3 : 48|4@1+ (1.0,0.0) [0.0|15.0] "" EMS,SCC - SG_ ACC_EQUIP : 52|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,SCC - SG_ PBRAKE_ACT : 53|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,SCC - SG_ ACC_REQ : 54|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ DriverBraking : 55|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,SCC - SG_ CF_VSM_Coded : 56|1@1+ (1.0,0.0) [0.0|1.0] "" SCC - SG_ CF_VSM_Avail : 57|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,SCC - SG_ CF_VSM_Handshake : 59|1@1+ (1.0,0.0) [0.0|1.0] "" SCC - SG_ CF_DriBkeStat : 60|1@1+ (1.0,0.0) [0.0|1.0] "" SCC - SG_ CF_VSM_ConfSwi : 61|2@1+ (1.0,0.0) [0.0|3.0] "" SCC - SG_ AEB_EQUIP : 63|1@1+ (1.0,0.0) [0.0|1.0] "" SCC - -BO_ 1427 TPMS11: 6 BCM - SG_ TPMS_W_LAMP : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,CUBIS,HUD,IBOX,CLU,CUBIS,HUD,IBOX - SG_ TREAD_W_LAMP : 2|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,CUBIS,HUD,IBOX,CLU,CUBIS,HUD,IBOX - SG_ POS_FL_W_LAMP : 4|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,CUBIS,HUD,IBOX - SG_ POS_FR_W_LAMP : 5|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,CUBIS,HUD,IBOX - SG_ POS_RL_W_LAMP : 6|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,CUBIS,HUD,IBOX - SG_ POS_RR_W_LAMP : 7|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,CUBIS,HUD,IBOX - SG_ STATUS_TPMS : 8|3@1+ (1.0,0.0) [0.0|0.0] "" CLU - SG_ UNIT : 11|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ PRESSURE_FL : 16|8@1+ (1.0,0.0) [0.0|255.0] "" CLU - SG_ PRESSURE_FR : 24|8@1+ (1.0,0.0) [0.0|255.0] "" CLU - SG_ PRESSURE_RL : 32|8@1+ (1.0,0.0) [0.0|255.0] "" CLU - SG_ PRESSURE_RR : 40|8@1+ (1.0,0.0) [0.0|255.0] "" CLU - -BO_ 915 TCS12: 4 ESC - SG_ SA_COUNT : 0|16@1+ (2.0,-32768.0) [-32768.0|98302.0] "" _4WD,ACU,MDPS - SG_ SA_Z_COUNT : 16|15@1+ (2.0,-32768.0) [-32768.0|32766.0] "" _4WD,ACU,MDPS - SG_ SA_Z_FLAG : 31|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,MDPS - -BO_ 1170 EMS19: 8 EMS - SG_ CF_Ems_BrkReq : 0|1@1+ (1.0,0.0) [0.0|1.0] "" ESC,IBOX,TCU - SG_ CF_Ems_DnShftReq : 1|4@1+ (1.0,0.0) [0.0|14.0] "" IBOX,TCU - SG_ CF_Ems_RepModChk : 5|2@1+ (1.0,0.0) [0.0|3.0] "" IBOX - SG_ CF_Ems_AAFOpenReq : 7|1@1+ (1.0,0.0) [0.0|1.0] "" AAF,IBOX - SG_ CF_Ems_DecelReq : 8|12@1+ (0.0010,-4.094) [-4.094|0.0] "m/s^2" ESC,IBOX,TCU - SG_ CR_Ems_BstPre : 20|12@1+ (1.322,0.0) [0.0|4094.0] "hPa" CLU,IBOX - SG_ CR_Ems_EngOilTemp : 32|8@1+ (0.75,-40.0) [0.0|254.0] "deg" CLU,IBOX - SG_ DPF_LAMP_STAT : 40|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,IBOX - SG_ BAT_LAMP_STAT : 42|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX - SG_ CF_Ems_ModeledAmbTemp : 48|8@1+ (0.5,-41.0) [-41.0|85.5] "deg" AAF,IBOX - SG_ CF_Ems_OPSFail : 56|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX - SG_ CF_Ems_AliveCounterEMS9 : 58|2@1+ (1.0,0.0) [0.0|3.0] "" AAF,ABS,CUBIS,ECS,EPB,IBOX,MDPS,REA,SCC,SMK,TCU - SG_ CF_Ems_ChecksumEMS9 : 60|4@1+ (1.0,0.0) [0.0|15.0] "" AAF,ABS,CUBIS,ECS,EPB,IBOX,MDPS,REA,SCC,SMK,TCU - -BO_ 1425 AFLS11: 2 AFLS - SG_ AFLS_STAT : 1|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Afls_TrfChgStat : 3|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Afls_LedHLStat : 4|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - -BO_ 912 SPAS11: 7 SPAS - SG_ CF_Spas_Stat : 0|4@1+ (1.0,0.0) [0.0|15.0] "" ESC,MDPS - SG_ CF_Spas_TestMode : 4|2@1+ (1.0,0.0) [0.0|3.0] "" MDPS - SG_ CR_Spas_StrAngCmd : 8|16@1- (0.1,0.0) [-3276.8|3276.7] "" MDPS - SG_ CF_Spas_BeepAlarm : 24|4@1+ (1.0,0.0) [0.0|15.0] "" CLU - SG_ CF_Spas_Mode_Seq : 28|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Spas_AliveCnt : 32|8@1+ (1.0,0.0) [0.0|255.0] "" MDPS - SG_ CF_Spas_Chksum : 40|8@1+ (1.0,0.0) [0.0|255.0] "" MDPS - SG_ CF_Spas_PasVol : 48|3@1+ (1.0,0.0) [0.0|7.0] "" CGW,CLU - -BO_ 1168 EPB11: 7 EPB - SG_ EPB_I_LAMP : 0|4@1+ (1.0,0.0) [0.0|15.0] "" BCM,CLU,CUBIS,ESC,IBOX - SG_ EPB_F_LAMP : 4|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,CUBIS,ESC,IBOX - SG_ EPB_ALARM : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ESC - SG_ EPB_CLU : 8|8@1+ (1.0,0.0) [0.0|255.0] "" CLU,ESC - SG_ EPB_SWITCH : 16|2@1+ (1.0,0.0) [0.0|3.0] "" ESC,SCC - SG_ EPB_RBL : 18|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,ESC - SG_ EPB_STATUS : 19|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,EMS,ESC,SCC,TCU - SG_ EPB_FRC_ERR : 22|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,ESC,SCC,TCU - SG_ EPB_DBF_STAT : 24|1@1+ (1.0,0.0) [0.0|1.0] "" ESC - SG_ ESP_ACK : 25|1@1+ (1.0,0.0) [0.0|1.0] "" ESC - SG_ EPB_DBF_REQ : 26|1@1+ (1.0,0.0) [0.0|1.0] "" ESC - SG_ EPB_FAIL : 29|3@1+ (1.0,0.0) [0.0|7.0] "" ESC,SCC - SG_ EPB_FORCE : 32|12@1+ (1.0,-1000.0) [-1000.0|3000.0] "" ESC - SG_ EPB_DBF_DECEL : 48|8@1+ (0.01,0.0) [0.0|2.54] "g" ESC - -BO_ 399 EMS_H12: 8 EMS - SG_ R_TqAcnApvC : 0|8@1+ (0.2,0.0) [0.0|51.0] "Nm" DATC,IBOX - SG_ R_PAcnC : 8|8@1+ (125.0,0.0) [0.0|31875.0] "hPa" DATC,IBOX - SG_ TQI_B : 16|8@1+ (0.390625,0.0) [0.0|99.609375] "%" ABS,ESC,IBOX - SG_ SLD_VS : 24|8@1+ (1.0,0.0) [0.0|255.0] "km/h" CLU,IBOX - SG_ CF_CdaStat : 32|3@1+ (1.0,0.0) [0.0|7.0] "" AEMC,IBOX,TCU - SG_ CF_Ems_IsgStat : 35|3@1+ (1.0,0.0) [0.0|7.0] "" ABS,BCM,CLU,DATC,EPB,ESC,IBOX,LDWS_LKAS,MDPS,SMK,TCU - SG_ CF_Ems_OilChg : 38|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX - SG_ CF_Ems_EtcLimpMod : 39|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX - SG_ R_NEngIdlTgC : 40|8@1+ (10.0,0.0) [0.0|2550.0] "rpm" DATC,IBOX,TCU - SG_ CF_Ems_UpTarGr : 48|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX - SG_ CF_Ems_DownTarGr : 49|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX - SG_ CF_Ems_DesCurGr : 50|4@1+ (1.0,0.0) [0.0|15.0] "" CLU,IBOX - SG_ CF_Ems_SldAct : 54|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX - SG_ CF_Ems_SldPosAct : 55|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX - SG_ CF_Ems_HPresStat : 56|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,TCU - SG_ CF_Ems_IsgBuz : 57|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX - SG_ CF_Ems_IdlStpFCO : 58|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX - SG_ CF_Ems_FCopen : 59|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX - SG_ CF_Ems_ActEcoAct : 60|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX,TCU - SG_ CF_Ems_EngRunNorm : 61|1@1+ (1.0,0.0) [0.0|1.0] "" ABS,ESC,IBOX,TCU - SG_ CF_Ems_IsgStat2 : 62|2@1+ (2.0,0.0) [0.0|3.0] "" CLU,IBOX,TCU - -BO_ 1419 LCA11: 8 LCA - SG_ CF_Lca_Stat : 0|4@1+ (1.0,0.0) [0.0|15.0] "" BCM,CLU - SG_ CF_Rcta_Stat : 4|4@1+ (1.0,0.0) [0.0|15.0] "" BCM,CLU - SG_ CF_Lca_IndLeft : 8|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU - SG_ CF_Rcw_Stat : 10|4@1+ (1.0,0.0) [0.0|15.0] "" BCM,CLU - SG_ CF_RCW_Warning : 14|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU - SG_ CF_Lca_IndRight : 16|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU - SG_ CF_Lca_SndWan_Stat : 18|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU - SG_ CF_FR_SndWan : 20|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CLU - SG_ CF_FL_SndWan : 21|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CLU - SG_ CF_RR_SndWan : 22|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CLU - SG_ CF_RL_SndWan : 23|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CLU - SG_ CF_Lca_IndBriLeft : 24|8@1+ (1.0,0.0) [0.0|255.0] "" BCM,CLU - SG_ CF_Lca_IndBriRight : 32|8@1+ (1.0,0.0) [0.0|255.0] "" BCM,CLU - SG_ CF_RCTA_IndBriLeft : 40|8@1+ (1.0,0.0) [0.0|255.0] "" BCM,CLU - SG_ CF_RCTA_IndBriRight : 48|8@1+ (1.0,0.0) [0.0|255.0] "" BCM,CLU - SG_ CF_RCTA_IndLeft : 56|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU - SG_ CF_RCTA_IndRight : 58|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU - SG_ CF_SndWarnForClu : 60|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - -BO_ 906 ABS11: 8 ABS - SG_ ABS_DEF : 0|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,EMS,SPAS,TCU - SG_ EBD_DEF : 1|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,SPAS,TCU - SG_ ABS_ACT : 2|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,EPB,SPAS,TCU - SG_ ABS_W_LAMP : 3|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU,CUBIS,MTS,TMU - SG_ EBD_W_LAMP : 4|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU - SG_ ABS_DIAG : 5|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU - SG_ ESS_STAT : 6|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,BCM,CLU,EMS - -BO_ 903 WHL_PUL11: 6 ABS - SG_ WHL_PUL_FL : 0|8@1+ (0.5,0.0) [0.0|127.5] "pulse count" CUBIS,EPB,IBOX,SPAS,TMU,TPMS,CUBIS,EPB,IBOX,LDWS_LKAS,SPAS,TMU,TPMS - SG_ WHL_PUL_FR : 8|8@1+ (0.5,0.0) [0.0|127.5] "pulse count" CUBIS,EPB,IBOX,SPAS,TMU,TPMS,CUBIS,EPB,IBOX,LDWS_LKAS,SPAS,TMU,TPMS - SG_ WHL_PUL_RL : 16|8@1+ (0.5,0.0) [0.0|127.5] "pulse count" CUBIS,EPB,IBOX,SPAS,TMU,TPMS,CUBIS,EPB,IBOX,LDWS_LKAS,SPAS,TMU,TPMS - SG_ WHL_PUL_RR : 24|8@1+ (0.5,0.0) [0.0|127.5] "pulse count" CUBIS,EPB,IBOX,SPAS,TMU,TPMS,CUBIS,EPB,IBOX,LDWS_LKAS,SPAS,TMU,TPMS - SG_ WHL_DIR_FL : 32|2@1+ (1.0,0.0) [0.0|3.0] "" EPB,SPAS,TPMS,EPB,LCA,SPAS,TPMS - SG_ WHL_DIR_FR : 34|2@1+ (1.0,0.0) [0.0|3.0] "" EPB,SPAS,TPMS,EPB,LCA,SPAS,TPMS - SG_ WHL_DIR_RL : 36|2@1+ (1.0,0.0) [0.0|3.0] "" EPB,SPAS,TPMS,EPB,LCA,SPAS,TPMS - SG_ WHL_DIR_RR : 38|2@1+ (1.0,0.0) [0.0|3.0] "" EPB,SPAS,TPMS,EPB,LCA,SPAS,TPMS - SG_ WHL_PUL_Chksum : 40|8@1+ (1.0,0.0) [0.0|255.0] "" EPB,SPAS,TPMS,EPB,LCA,LDWS_LKAS,SPAS,TPMS - -BO_ 1415 TMU11: 8 IBOX - SG_ CF_Tmu_VehSld : 0|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_Tmu_VehImmo : 1|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_Tmu_ReqRepCnd : 2|2@1+ (1.0,0.0) [0.0|3.0] "" EMS - SG_ CF_Tmu_AirconCtr : 4|1@1+ (1.0,0.0) [0.0|1.0] "" DATC - SG_ CF_Tmu_TempMd : 5|1@1+ (1.0,0.0) [0.0|1.0] "" DATC - SG_ CF_Tmu_TempSet : 6|16@1+ (1.0,0.0) [0.0|20.0] "" DATC - SG_ CF_Tmu_DefrostCtr : 22|1@1+ (1.0,0.0) [0.0|1.0] "" DATC,FATC - SG_ CF_Tmu_AliveCnt1 : 56|4@1+ (1.0,0.0) [0.0|15.0] "" EMS - -BO_ 902 WHL_SPD11: 8 ABS - SG_ WHL_SPD_FL : 0|14@1+ (0.03125,0.0) [0.0|511.96875] "km/h" _4WD,AFLS,AHLS,AVM,CLU,CUBIS,ECS,EMS,EPB,IBOX,LDWS_LKAS,PGS,PSB,SCC,SMK,SPAS,TCU,TPMS,_4WD,ACU,AFLS,AHLS,AVM,CLU,ECS,EMS,EPB,IBOX,LCA,LDWS_LKAS,PGS,PSB,SCC,SMK,SPAS,TCU,TPMS - SG_ WHL_SPD_FR : 16|14@1+ (0.03125,0.0) [0.0|511.96875] "km/h" _4WD,ACU,AFLS,AHLS,AVM,CLU,CUBIS,ECS,EMS,EPB,IBOX,LDWS_LKAS,PGS,PSB,SCC,SMK,SPAS,TCU,TPMS,_4WD,ACU,AFLS,AHLS,AVM,CLU,ECS,EMS,EPB,IBOX,LCA,LDWS_LKAS,PGS,PSB,SCC,SMK,SPAS,TCU,TPMS - SG_ WHL_SPD_RL : 32|14@1+ (0.03125,0.0) [0.0|511.96875] "km/h" _4WD,AFLS,AHLS,AVM,BCM,CLU,CUBIS,ECS,EMS,EPB,IBOX,LDWS_LKAS,PGS,PSB,SCC,SMK,SPAS,TCU,TPMS,_4WD,ACU,AFLS,AHLS,AVM,BCM,CLU,ECS,EMS,EPB,IBOX,LCA,LDWS_LKAS,PGS,PSB,SCC,SMK,SPAS,TCU,TPMS - SG_ WHL_SPD_RR : 48|14@1+ (0.03125,0.0) [0.0|511.96875] "km/h" _4WD,AFLS,AHLS,AVM,CLU,CUBIS,ECS,EMS,EPB,IBOX,LDWS_LKAS,PGS,PSB,SCC,SMK,SPAS,TCU,TPMS,_4WD,ACU,AFLS,AHLS,AVM,CLU,ECS,EMS,EPB,IBOX,LCA,LDWS_LKAS,PGS,PSB,SCC,SMK,SPAS,TCU,TPMS - SG_ WHL_SPD_AliveCounter_LSB : 14|2@1+ (1.0,0.0) [0.0|15.0] "" _4WD,EMS,LPI,TCU,TMU - SG_ WHL_SPD_AliveCounter_MSB : 30|2@1+ (1.0,0.0) [0.0|15.0] "" _4WD,EMS,LPI,TCU,TMU - SG_ WHL_SPD_Checksum_LSB : 46|2@1+ (1.0,0.0) [0.0|15.0] "" _4WD,EMS,LPI,TCU,TMU - SG_ WHL_SPD_Checksum_MSB : 62|2@1+ (1.0,0.0) [0.0|15.0] "" _4WD,EMS,LPI,TCU,TMU - -BO_ 1414 EVP11: 3 EVP - SG_ CF_Evp_Stat : 0|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - -BO_ 1412 AAF11: 8 AAF - SG_ CF_Aaf_ActFlapStatus : 0|2@1+ (1.0,0.0) [0.0|3.0] "" AAF_Tester - SG_ CF_Aaf_ModeStatus : 2|3@1+ (1.0,0.0) [0.0|7.0] "" AAF_Tester - SG_ CF_Aaf_WrnLamp : 5|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Aaf_ErrStatus : 6|10@1+ (1.0,0.0) [0.0|1023.0] "" AAF_Tester,EMS - SG_ CF_Aaf_OpenRqSysAct : 16|8@1+ (1.0,0.0) [0.0|255.0] "" AAF_Tester - SG_ CF_Aaf_PStatus : 24|8@1+ (1.0,0.0) [0.0|100.0] "%" AAF_Tester - SG_ CF_Aaf_OpenRqSysSol : 32|8@1+ (1.0,0.0) [0.0|255.0] "" AAF_Tester - SG_ CF_Aaf_SolFlapStatus : 40|2@1+ (1.0,0.0) [0.0|3.0] "" AAF_Tester - SG_ CF_Aaf_MilOnReq : 42|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - -BO_ 900 EMS17: 8 EMS - SG_ CF_Ems_PkpCurMSV : 0|8@1+ (1.0,0.0) [0.0|255.0] "" DI_BOX - SG_ CF_Ems_HolCurMSV : 8|8@1+ (1.0,0.0) [0.0|255.0] "" DI_BOX - SG_ CF_Ems_InjVBnkAct : 16|8@1+ (1.0,0.0) [0.0|255.0] "" DI_BOX - SG_ CF_Ems_InjVActSet : 24|8@1+ (1.0,0.0) [0.0|255.0] "" DI_BOX - SG_ CF_Ems_DiagFulHDEV : 32|1@1+ (1.0,0.0) [0.0|1.0] "" DI_BOX - SG_ CF_Ems_SwiOffIC1 : 33|1@1+ (1.0,0.0) [0.0|1.0] "" DI_BOX - SG_ CF_Ems_SwiOffIC2 : 34|1@1+ (1.0,0.0) [0.0|1.0] "" DI_BOX - SG_ CF_Ems_DiagReqHDEV : 38|1@1+ (1.0,0.0) [0.0|1.0] "" DI_BOX - SG_ CR_Ems_DutyCycMSV : 40|8@1+ (0.3921568627,0.0) [0.0|100.0] "%" DI_BOX - SG_ CR_Ems_BatVolRly : 48|8@1+ (0.1,0.0) [0.0|25.5] "V" DI_BOX - -BO_ 387 REA11: 8 REA - SG_ CF_EndBst_PwmDuH : 0|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_EndBst_PwmDuL : 1|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_EndBst_PwmFqOutRng : 2|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_EndBst_HbriOverCur : 3|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_EndBst_HbriOverTemp : 4|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_EndBst_PosSnsKOR : 6|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_EndBst_PosSnsOSOR : 7|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_EndBst_EepFlt : 8|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_EndBst_RomFlt : 9|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_EndBst_RamFlt : 10|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_EndBst_CanFlt : 11|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_EndBst_AgH : 12|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_EndBst_AgL : 13|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_EndBst_ORVol : 14|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CR_EndBst_ActPos : 16|16@1+ (0.117,0.0) [1.989|118.053] "" EMS - SG_ CR_EndBst_DemPos : 32|16@1+ (0.117,0.0) [0.0|119.691] "" EMS - SG_ CR_EndBst_HbriPwr : 48|16@1+ (0.045,0.0) [0.0|99.99] "%" EMS - -BO_ 1411 CUBIS11: 8 CUBIS - SG_ CF_Cubis_HUDisp : 0|4@1+ (1.0,0.0) [0.0|15.0] "" CLU - -BO_ 899 FATC11: 8 DATC - SG_ CR_Fatc_TqAcnOut : 0|8@1+ (0.2,0.0) [0.0|50.8] "Nm" EMS,IBOX - SG_ CF_Fatc_AcnRqSwi : 8|1@1+ (1.0,0.0) [0.0|1.0] "" AAF,EMS,IBOX - SG_ CF_Fatc_AcnCltEnRq : 9|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX - SG_ CF_Fatc_EcvFlt : 10|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX - SG_ CF_Fatc_BlwrOn : 11|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX - SG_ CF_FATC_Iden : 12|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,IBOX - SG_ CF_Fatc_BlwrMax : 14|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,IBOX - SG_ CF_Fatc_EngStartReq : 15|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX - SG_ CF_Fatc_IsgStopReq : 16|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX - SG_ CF_Fatc_CtrInf : 17|3@1+ (1.0,0.0) [0.0|7.0] "" EMS,IBOX - SG_ CF_Fatc_MsgCnt : 20|4@1+ (1.0,0.0) [0.0|15.0] "" EMS,IBOX - SG_ CR_Fatc_OutTemp : 24|8@1+ (0.5,-40.0) [-40.0|60.0] "deg" BCM,CLU,EMS,IBOX,SPAS,TCU,TPMS - SG_ CR_Fatc_OutTempSns : 32|8@1+ (0.5,-40.0) [-40.0|60.0] "deg" AAF,AHLS,CLU,EMS,IBOX,SPAS,TCU - SG_ CF_Fatc_Compload : 40|3@1+ (1.0,0.0) [0.0|7.0] "" EMS,IBOX - SG_ CF_Fatc_ActiveEco : 43|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX - SG_ CF_Fatc_AutoActivation : 44|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX - SG_ CF_Fatc_DefSw : 45|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,IBOX - SG_ CF_Fatc_PtcRlyStat : 46|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX - SG_ CF_Fatc_ChkSum : 56|8@1+ (1.0,0.0) [0.0|255.0] "" EMS,IBOX,SPAS - -BO_ 129 EMS_DCT12: 8 EMS - SG_ CR_Ems_SoakTimeExt : 0|6@1+ (5.0,0.0) [0.0|315.0] "Min" TCU - SG_ BRAKE_ACT : 6|2@1+ (1.0,0.0) [0.0|3.0] "" TCU - SG_ CF_Ems_EngOperStat : 8|8@1+ (1.0,0.0) [0.0|255.0] "" TCU - SG_ CR_Ems_IndAirTemp : 16|8@1+ (0.75,-48.0) [-48.0|143.25] "deg" TCU - SG_ CF_Ems_Alive2 : 56|4@1+ (1.0,0.0) [0.0|15.0] "" TCU - SG_ CF_Ems_ChkSum2 : 60|4@1+ (1.0,0.0) [0.0|15.0] "" TCU - -BO_ 897 MDPS11: 8 MDPS - SG_ CF_Mdps_WLmp : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,CUBIS,EMS,IBOX,SPAS - SG_ CF_Mdps_Flex : 2|3@1+ (1.0,0.0) [0.0|3.0] "" CLU,LDWS_LKAS - SG_ CF_Mdps_FlexDisp : 5|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Mdps_Stat : 7|4@1+ (1.0,0.0) [0.0|15.0] "" SPAS - SG_ CR_Mdps_DrvTq : 11|12@1+ (0.01,-20.48) [-20.48|20.46] "" SPAS - SG_ CF_Mdps_ALTRequest : 23|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CR_Mdps_StrAng : 24|16@1- (0.1,0.0) [-3276.8|3276.7] "Deg" SPAS - SG_ CF_Mdps_AliveCnt : 40|8@1+ (1.0,0.0) [0.0|255.0] "" LDWS_LKAS,SPAS - SG_ CF_Mdps_Chksum : 48|8@1+ (1.0,0.0) [0.0|255.0] "" LDWS_LKAS,SPAS - SG_ CF_Mdps_SPAS_FUNC : 57|1@1+ (1.0,0.0) [0.0|1.0] "flag" SPAS - SG_ CF_Mdps_LKAS_FUNC : 58|1@1+ (1.0,0.0) [0.0|1.0] "flag" LDWS_LKAS - SG_ CF_Mdps_CurrMode : 59|2@1+ (1.0,0.0) [0.0|3.0] "" LDWS_LKAS - SG_ CF_Mdps_Type : 61|2@1+ (1.0,0.0) [0.0|2.0] "" LDWS_LKAS,SPAS - -BO_ 896 DI_BOX13: 8 DI_BOX - SG_ CF_DiBox_HPreInjVConfStat : 0|8@1+ (1.0,0.0) [0.0|255.0] "" EMS - SG_ CF_DiBox_HPreInjVStat1 : 8|8@1+ (1.0,0.0) [0.0|255.0] "" EMS - SG_ CF_DiBox_HPreInjVStat2 : 16|8@1+ (1.0,0.0) [0.0|255.0] "" EMS - SG_ CF_DiBox_HPreInjVPkp : 24|8@1+ (1.0,0.0) [0.0|255.0] "" EMS - SG_ CF_DiBox_HPreInjVBpt : 32|8@1+ (1.0,0.0) [0.0|255.0] "" EMS - SG_ CF_DiBox_ErrRegFrtMSV : 40|8@1+ (1.0,0.0) [0.0|255.0] "" EMS - SG_ CF_DiBox_ErrRegSedMSV : 48|8@1+ (1.0,0.0) [0.0|255.0] "" EMS - SG_ CF_DiBox_SPIErrSedMSV : 56|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_DiBox_SPIErrFrtMSV : 57|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_DiBox_IDErrSedMSV : 58|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_DiBox_IDErrFrtMSV : 59|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_DiBox_IniStatMSV : 60|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - -BO_ 640 EMS13: 8 EMS - SG_ LV_FUEL_TYPE_ECU : 0|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CLU,LPI,SMK - SG_ LV_BFS_CFIRM : 1|1@1+ (1.0,0.0) [0.0|1.0] "" LPI - SG_ LV_CRASH : 2|1@1+ (1.0,0.0) [0.0|1.0] "" LPI - SG_ LV_VB_OFF_ACT : 3|1@1+ (1.0,0.0) [0.0|1.0] "" LPI - SG_ LV_GSL_MAP M : 4|1@1+ (1.0,0.0) [0.0|1.0] "" LPI - SG_ LV_ENG_TURN : 5|1@1+ (1.0,0.0) [0.0|1.0] "" LPI - SG_ ERR_FUEL : 8|8@1+ (1.0,0.0) [0.0|255.0] "" LPI - SG_ EOS : 16|8@1+ (1.0,0.0) [0.0|255.0] "" LPI - SG_ TCO : 24|8@1+ (0.75,-48.0) [-48.0|143.25] "deg" LPI - SG_ N_32 : 32|8@1+ (32.0,0.0) [0.0|8160.0] "rpm" LPI - SG_ MAF : 40|8@1+ (5.447,0.0) [0.0|1388.985] "mg/TDC" LPI - SG_ TIA : 48|8@1+ (0.75,-48.0) [-48.0|143.25] "deg" LPI - SG_ MAP m1 : 56|8@1+ (0.47058,0.0) [0.0|119.9979] "kPa" LPI - SG_ AMP m0 : 56|8@1+ (21.22,0.0) [0.0|5411.1] "hPa" LPI - -BO_ 128 EMS_DCT11: 8 EMS - SG_ PV_AV_CAN : 0|8@1+ (0.3906,0.0) [0.0|99.603] "%" TCU - SG_ TQ_STND : 8|6@1+ (10.0,0.0) [0.0|630.0] "Nm" TCU - SG_ F_N_ENG : 14|1@1+ (1.0,0.0) [0.0|1.0] "" TCU - SG_ F_SUB_TQI : 15|1@1+ (1.0,0.0) [0.0|1.0] "" TCU - SG_ N : 16|16@1+ (0.25,0.0) [0.0|16383.75] "rpm" TCU - SG_ TQI_ACOR : 32|8@1+ (0.390625,0.0) [0.0|99.6094] "%" IBOX,TCU - SG_ TQFR : 40|8@1+ (0.390625,0.0) [0.0|99.6094] "%" TCU - SG_ TQI : 48|8@1+ (0.390625,0.0) [0.0|99.609375] "%" TCU - SG_ CF_Ems_Alive : 56|4@1+ (1.0,0.0) [0.0|15.0] "" TCU - SG_ CF_Ems_ChkSum : 60|4@1+ (1.0,0.0) [0.0|15.0] "" TCU - -BO_ 1407 HU_MON_PE_01: 8 CLU - SG_ HU_Type : 0|8@1+ (1.0,0.0) [0.0|255.0] "" AVM,PGS - -BO_ 127 CGW5: 8 BCM - SG_ C_StopLampLhOpenSts : 0|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_StopLampRhOpenSts : 1|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_HMSLOpenSts : 2|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_HLampLowLhOpenSts : 3|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_HLampLowRhOpenSts : 4|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_HLampHighLhOpenSts : 5|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_HLampHighRhOpenSts : 6|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_DRLLampLhOpenSts : 7|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_DRLLampRhOpenSts : 8|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_RearFOGLhOpenSts : 9|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_RearFOGRhOpenSts : 10|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_FrontFOGLhOpenSts : 11|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_FrontFOGRhOpenSts : 12|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_RearEXTTailLhOpenSts : 13|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_RearEXTTailRhOpenSts : 14|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_FrontEXTTailLhOpenSts : 15|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_FrontEXTTailRhOpenSts : 16|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_RearTSIGLhOpenSts : 17|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_RearTSIGRhOpenSts : 18|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_FrontTSIGLhOpenSts : 19|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_FrontTSIGRhOpenSts : 20|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_SBendingLhOpenSts : 21|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_SBendingRhOpenSts : 22|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_LicensePlateLhOpenSts : 23|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_LicensePlateRhOpenSts : 24|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - -BO_ 1151 ESP11: 6 ESC - SG_ AVH_STAT : 0|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,EPB,TCU - SG_ LDM_STAT : 2|1@1+ (1.0,0.0) [0.0|1.0] "" EPB,TCU - SG_ REQ_EPB_ACT : 3|2@1+ (1.0,0.0) [0.0|3.0] "" EPB,TCU - SG_ REQ_EPB_STAT : 5|1@1+ (1.0,0.0) [0.0|1.0] "" EPB - SG_ ECD_ACT : 6|1@1+ (1.0,0.0) [0.0|1.0] "" EPB - SG_ _4WD_LIM_REQ : 7|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS - SG_ ROL_CNT_ESP : 8|8@1+ (1.0,0.0) [0.0|255.0] "" EPB,TCU - SG_ _4WD_TQC_LIM : 16|16@1+ (1.0,0.0) [0.0|65535.0] "Nm" _4WD,EMS - SG_ _4WD_CLU_LIM : 32|8@1+ (0.390625,0.0) [0.0|99.609375] "%" _4WD,EMS - SG_ _4WD_OPEN : 40|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,EMS - SG_ _4WD_LIM_MODE : 42|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD - -BO_ 1397 HU_AVM_E_00: 8 CLU - SG_ HU_AVM_Cal_Cmd : 0|4@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS - SG_ HU_AVM_Cal_Method : 4|2@1+ (1.0,0.0) [0.0|3.0] "" AVM,PGS - SG_ HU_AVM_Save_Controlpoint : 6|2@1+ (1.0,0.0) [0.0|3.0] "" AVM,PGS - SG_ HU_AVM_PT_X : 8|12@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS - SG_ HU_AVM_RearViewPointOpt : 20|4@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS - SG_ HU_AVM_PT_Y : 24|12@1+ (1.0,0.0) [0.0|4095.0] "" AVM,PGS - SG_ HU_AVM_FrontViewPointOpt : 36|4@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS - SG_ HU_AVM_SelectedMenu : 40|5@1+ (1.0,0.0) [0.0|31.0] "" AVM,PGS - SG_ HU_AVM_CameraOff : 45|2@1+ (1.0,0.0) [0.0|3.0] "" AVM,PGS - SG_ HU_AVM_Option : 48|4@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS - SG_ HU_AVM_CrossLineMove_Cmd : 52|4@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS - SG_ HU_AVM_RearView_Option : 56|4@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS - SG_ HU_AVM_FrontView_Option : 60|4@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS - -BO_ 1395 HU_AVM_E_01: 8 CLU - SG_ HU_PGSSelectedMenu : 0|4@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS - SG_ HU_PGSOption : 8|5@1+ (1.0,0.0) [0.0|31.0] "" AVM,PGS - SG_ HU_AVM_ParkingAssistMenu : 56|4@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS - SG_ HU_AVM_ParkingAssistSB : 60|4@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS - -BO_ 1393 OPI11: 5 OPI - SG_ CR_Opi_Spd_Rpm : 0|8@1+ (20.0,0.0) [0.0|3500.0] "rpm" TCU - SG_ CF_Opi_Over_Temp : 8|1@1+ (1.0,0.0) [0.0|1.0] "" TCU - SG_ CF_Opi_Over_Cur : 9|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,TCU - SG_ CF_Opi_Over_Vol : 10|1@1+ (1.0,0.0) [0.0|1.0] "" TCU - SG_ CF_Opi_Hall_Fail : 11|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,TCU - SG_ CF_Opi_Flt : 12|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,TCU - SG_ CF_Opi_Motor_Dir : 15|1@1+ (1.0,0.0) [0.0|1.0] "" TCU - SG_ CF_Opi_Romver : 16|8@1+ (1.0,0.0) [0.0|255.0] "" TCU - SG_ CF_Opi_PWM_Rate : 24|12@1+ (1.0,0.0) [0.0|100.0] "%" TCU - -BO_ 625 LPI11: 8 LPI - SG_ FUP_LPG_MMV : 0|8@1+ (128.0,0.0) [0.0|32640.0] "hPa" EMS - SG_ LV_FUEL_TYPE_BOX : 8|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ LV_BFS_IN_PROGRESS : 9|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ LV_GAS_OK : 10|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ LV_FUP_ENA_THD : 11|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CLU,EMS,SMK - SG_ LPI_OBD : 12|4@1+ (1.0,0.0) [0.0|15.0] "" EMS - SG_ ERR_GAS : 16|8@1+ (1.0,0.0) [0.0|255.0] "" EMS - SG_ FAC_TI_GAS_COR : 24|16@1+ (3.05E-5,0.0) [0.0|1.9988175] "" EMS - SG_ FTL_AFU : 40|8@1+ (0.392,0.0) [0.0|99.96] "%" EMS - SG_ BFS_CYL : 48|8@1+ (1.0,0.0) [0.0|6.0] "Cyl Nr." EMS - SG_ LV_PRE_CDN_LEAK : 56|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ LV_CONF_INJECTION_DELAY : 57|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ LV_LPG_SW_DRIVER_REQ : 58|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - -BO_ 356 VSM11: 4 ESC - SG_ CR_Esc_StrTqReq : 0|12@1+ (0.01,-20.48) [-20.48|20.47] "Nm" MDPS - SG_ CF_Esc_Act : 12|1@1+ (1.0,0.0) [0.0|1.0] "" LDWS_LKAS,MDPS - SG_ CF_Esc_CtrMode : 13|3@1+ (1.0,0.0) [0.0|7.0] "" MDPS - SG_ CF_Esc_Def : 16|1@1+ (1.0,0.0) [0.0|1.0] "" MDPS - SG_ CF_Esc_AliveCnt : 17|4@1+ (1.0,0.0) [0.0|15.0] "" LDWS_LKAS,MDPS - SG_ CF_Esc_Chksum : 24|8@1+ (1.0,0.0) [0.0|255.0] "" LDWS_LKAS,MDPS - -BO_ 1379 PGS_HU_PE_01: 8 PGS - SG_ PGS_State : 0|4@1+ (1.0,0.0) [0.0|15.0] "" CLU - SG_ PGS_ParkGuideState : 8|5@1+ (1.0,0.0) [0.0|31.0] "" CLU - SG_ PGS_Option : 16|5@1+ (1.0,0.0) [0.0|31.0] "" CLU - SG_ PGS_Version : 32|16@1+ (1.0,0.0) [0.0|65535.0] "" CLU - -BO_ 354 TCU_DCT13: 3 TCU - SG_ Clutch_Driving_Tq : 0|10@1+ (1.0,-512.0) [0.0|0.0] "Nm" ESC - SG_ Cluster_Engine_RPM : 10|13@1+ (0.9766,0.0) [0.0|0.0] "" CLU - SG_ Cluster_Engine_RPM_Flag : 23|1@1+ (1.0,0.0) [0.0|0.0] "" CLU - -BO_ 1378 HUD11: 4 HUD - SG_ CF_Hud_HeightStaus : 0|5@1+ (1.0,0.0) [0.0|31.0] "" CLU - SG_ CF_Hud_PBackStatus : 6|2@1+ (1.0,0.0) [0.0|0.0] "" BCM,CLU - SG_ CF_Hud_Brightness : 8|5@1+ (1.0,0.0) [0.0|31.0] "" CLU - -BO_ 608 EMS16: 8 EMS - SG_ TQI_MIN : 0|8@1+ (0.390625,0.0) [0.0|99.609375] "%" ESC,IBOX,TCU - SG_ TQI : 8|8@1+ (0.390625,0.0) [0.0|99.609375] "%" ESC,IBOX,TCU - SG_ TQI_TARGET : 16|8@1+ (0.390625,0.0) [0.0|99.609375] "%" EPB,ESC,IBOX,TCU - SG_ GLOW_STAT : 24|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CLU,IBOX,SMK - SG_ CRUISE_LAMP_M : 25|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX,TCU - SG_ CRUISE_LAMP_S : 26|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX,TCU - SG_ PRE_FUEL_CUT_IN : 27|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,TCU - SG_ ENG_STAT : 28|3@1+ (1.0,0.0) [0.0|7.0] "" ABS,AHLS,AVM,BCM,CLU,EPB,ESC,EVP,FPCM,IBOX,LCA,LDWS_LKAS,MDPS,SCC,SMK,TCU - SG_ SOAK_TIME_ERROR : 31|1@1+ (1.0,0.0) [0.0|1.0] "" DATC,EPB,IBOX,TCU - SG_ SOAK_TIME : 32|8@1+ (1.0,0.0) [0.0|255.0] "Min" _4WD,DATC,EPB,IBOX,TCU - SG_ TQI_MAX : 40|8@1+ (0.390625,0.0) [0.0|99.609375] "%" ESC,IBOX,TCU - SG_ SPK_TIME_CUR : 48|8@1+ (0.375,-35.625) [-35.625|60.0] "" IBOX,TCU - SG_ Checksum : 56|4@1+ (1.0,0.0) [0.0|15.0] "" ECS,IBOX,LDWS_LKAS,MDPS,SCC - SG_ AliveCounter : 60|2@1+ (1.0,0.0) [0.0|3.0] "" IBOX,LDWS_LKAS,MDPS,SCC - SG_ CF_Ems_AclAct : 62|2@1+ (1.0,0.0) [0.0|3.0] "" IBOX,SCC - -BO_ 1371 AVM_HU_PE_00: 8 AVM - SG_ AVM_View : 0|5@1+ (1.0,0.0) [0.0|31.0] "" CLU - SG_ AVM_ParkingAssist_BtnSts : 5|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - SG_ AVM_Display_Message : 8|8@1+ (1.0,0.0) [0.0|255.0] "" CLU - SG_ AVM_Popup_Msg : 16|4@1+ (1.0,0.0) [0.0|15.0] "" CLU - SG_ AVM_Ready : 20|4@1+ (1.0,0.0) [0.0|15.0] "" CLU - SG_ AVM_ParkingAssist_Step : 24|4@1+ (1.0,0.0) [0.0|15.0] "" CLU - SG_ AVM_FrontBtn_Type : 28|4@1+ (1.0,0.0) [0.0|15.0] "" CLU - SG_ AVM_Option : 32|4@1+ (1.0,0.0) [0.0|15.0] "" CLU - SG_ AVM_HU_FrontViewPointOpt : 36|4@1+ (1.0,0.0) [0.0|15.0] "" CLU - SG_ AVM_HU_RearView_Option : 40|4@1+ (1.0,0.0) [0.0|15.0] "" CLU - SG_ AVM_HU_FrontView_Option : 44|4@1+ (1.0,0.0) [0.0|15.0] "" CLU - SG_ AVM_Version : 48|16@1+ (1.0,0.0) [0.0|65535.0] "" CLU - -BO_ 1370 HU_AVM_PE_00: 8 CLU - SG_ HU_AVM_Status : 0|2@1+ (1.0,0.0) [0.0|3.0] "" AVM,PGS - -BO_ 1369 CGW4: 8 BCM - SG_ CF_Gway_MemoryP1Cmd : 0|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Gway_MemoryP2Cmd : 1|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Gway_PBackP1Cmd : 2|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Gway_PBackP2Cmd : 3|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Gway_StrgWhlHeatedState : 4|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Gway_PBackStopCmd : 5|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,HUD - SG_ CF_Gway_StaticBendLhAct : 6|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Gway_StaticBendRhAct : 7|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Gway_DrvWdwStat : 8|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Gway_RLWdwState : 9|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Gway_RRWdwState : 10|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Gway_AstWdwStat : 11|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Gway_MemoryEnable : 12|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Gway_PBACKStopCmd : 13|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Gway_PBACKStop : 14|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,HUD - SG_ CF_Gway_IMSBuzzer : 15|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Gway_DrvSeatBeltInd : 36|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,Dummy - SG_ CF_Gway_AstSeatBeltInd : 38|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Gway_RCSeatBeltInd : 40|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Gway_RLSeatBeltInd : 42|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Gway_RRSeatBeltInd : 44|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Gway_RrWiperHighSw : 46|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Gway_RrWiperLowSw : 47|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - -BO_ 1367 EngFrzFrm12: 8 EMS - SG_ PID_06h : 0|8@1+ (0.78125,-100.0) [-100.0|99.22] "%" AAF,IBOX,TCU - SG_ PID_07h : 8|8@1+ (0.78125,-100.0) [-100.0|99.22] "%" AAF,IBOX,TCU - SG_ PID_08h : 16|8@1+ (0.78125,-100.0) [-100.0|99.22] "%" AAF,IBOX,TCU - SG_ PID_09h : 24|8@1+ (0.78125,-100.0) [-100.0|99.22] "%" AAF,IBOX,TCU - SG_ PID_0Bh : 32|8@1+ (1.0,0.0) [0.0|255.0] "kPa" AAF,IBOX,TCU - SG_ PID_23h : 40|16@1+ (10.0,0.0) [0.0|655350.0] "kPa" AAF,IBOX,TCU - -BO_ 1366 EngFrzFrm11: 8 EMS - SG_ PID_04h : 0|8@1+ (0.3921568627,0.0) [0.0|100.0] "%" AAF,TCU - SG_ PID_05h : 8|8@1+ (1.0,-40.0) [-40.0|215.0] "deg" AAF,TCU - SG_ PID_0Ch : 16|16@1+ (0.25,0.0) [0.0|16383.75] "rpm" AAF,TCU - SG_ PID_0Dh : 32|8@1+ (1.0,0.0) [0.0|255.0] "km/h" AAF,TCU - SG_ PID_11h : 40|8@1+ (0.3921568627,0.0) [0.0|100.0] "%" AAF,TCU - SG_ PID_03h : 48|16@1+ (1.0,0.0) [0.0|65535.0] "" AAF,TCU - -BO_ 1365 FPCM11: 8 FPCM - SG_ CR_Fpcm_LPActPre : 0|8@1+ (3.137254902,0.0) [0.0|800.0] "kPa" EMS - SG_ CF_Fpcm_LPPumpOverCur : 8|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_Fpcm_PreSnrHi : 9|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_Fpcm_PreSnrDisc : 10|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_Fpcm_PreSnrShort : 11|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_Fpcm_LPPumpDiscShort : 12|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_Fpcm_LP_System_Error : 13|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_Fpcm_PreSnrSigErr : 14|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_Fpcm_LPCtrCirFlt : 15|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - -BO_ 852 LVR11: 7 LVR - SG_ CF_Lvr_GearInf : 0|4@1+ (1.0,0.0) [0.0|15.0] "" CLU,TCU - SG_ CF_Lvr_PRelStat : 4|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CLU,SMK,TCU - SG_ CF_Lvr_BkeAct : 5|1@1+ (1.0,0.0) [0.0|1.0] "" TCU - SG_ CF_Lvr_NFnStat : 6|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Lvr_PosInf : 8|4@1+ (1.0,0.0) [0.0|15.0] "" TCU - SG_ CF_Lvr_PosCpl : 12|4@1+ (1.0,0.0) [0.0|15.0] "" TCU - SG_ CF_Lvr_UlkButStat : 18|2@1+ (1.0,0.0) [0.0|3.0] "" TCU - SG_ CF_Lvr_PNStat : 20|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Lvr_ShtLkStat : 24|4@1+ (1.0,0.0) [0.0|15.0] "" TCU - SG_ CF_Lvr_ShfErrInf : 28|20@1+ (1.0,0.0) [0.0|8191.0] "" CLU,TCU - SG_ CF_Lvr_AC : 48|4@1+ (1.0,0.0) [0.0|15.0] "" TCU - SG_ CF_Lvr_CS : 52|4@1+ (1.0,0.0) [0.0|15.0] "" TCU - -BO_ 1363 CGW2: 8 BCM - SG_ CF_Gway_GwayDiagState : 0|1@1+ (1.0,0.0) [0.0|3.0] "" CLU,Dummy - SG_ CF_Gway_DDMDiagState : 1|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_SCMDiagState : 2|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_PSMDiagState : 3|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_SJBDiagState : 4|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_IPMDiagState : 5|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_LDMFail : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,LDWS_LKAS,LDWS_LKAS - SG_ CF_Gway_CLUSwGuiCtrl : 10|3@1+ (1.0,0.0) [0.0|63.0] "" CLU,Dummy - SG_ CF_Gway_CLUSwGroup : 13|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_CLUSwMode : 14|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_CLUSwEnter : 15|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_AutoLightValue : 16|1@1+ (1.0,0.0) [0.0|1.0] "" LCA,LCA - SG_ CF_Gway_BrakeFluidSw : 17|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_DrvSeatBeltInd : 18|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Gway_AvTail : 20|1@1+ (1.0,0.0) [0.0|3.0] "" CLU,SNV,SNV - SG_ CF_Gway_RearFogAct : 21|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_ExtTailAct : 22|1@1+ (1.0,0.0) [0.0|1.0] "" AVM,CLU,LCA,PGS,SPAS,AVM,LCA,PGS,SPAS - SG_ CF_Gway_RRDrSw : 23|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_RLDrSw : 24|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_IntTailAct : 25|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_CountryCfg : 26|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU,PGS,Dummy - SG_ CF_Gway_WiperParkPosition : 32|1@1+ (1.0,0.0) [0.0|1.0] "" AFLS,EMS,LDWS_LKAS,AFLS,EMS,LDWS_LKAS - SG_ CF_Gway_HLLowLHFail : 33|1@1+ (1.0,0.0) [0.0|1.0] "" LDWS_LKAS,SNV,LDWS_LKAS,SNV - SG_ CF_Gway_HLLowRHFail : 34|1@1+ (1.0,0.0) [0.0|1.0] "" LDWS_LKAS,SNV,LDWS_LKAS,SNV - SG_ CF_Gway_ESCLFailWarn : 35|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_ESCLNotLockedWarn : 36|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_ESCLNotUnlockWarn : 37|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_IDoutWarn : 38|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_ImmoLp : 40|1@1+ (1.0,0.0) [0.0|3.0] "" CLU,Dummy - SG_ CF_Gway_BCMRKEID : 41|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,Dummy - SG_ CF_Gway_VehicleNotPWarn : 44|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_DeactivationWarn : 45|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_KeyBATDischargeWarn : 46|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_SSBWarn : 47|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_SMKFobID : 48|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,Dummy - SG_ CF_Gway_SMKRKECmd : 51|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,Dummy - SG_ CF_Gway_AutoLightOption : 54|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Gway_SJBDeliveryMode : 55|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_KeyoutLp : 56|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy - SG_ CF_Gway_SMKDispWarn : 57|4@1+ (1.0,0.0) [0.0|15.0] "" CLU,Dummy - SG_ CF_Gway_WngBuz : 61|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,Dummy - -BO_ 339 TCS11: 8 ESC - SG_ TCS_REQ : 0|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,EPB,TCU - SG_ MSR_C_REQ : 1|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,EPB,SCC,TCU - SG_ TCS_PAS : 2|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU,EMS,SCC,SPAS,TCU - SG_ TCS_GSC : 3|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,TCU - SG_ CF_Esc_LimoInfo : 4|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,SCC - SG_ ABS_DIAG : 6|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU,EMS,EPB - SG_ ABS_DEF : 7|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,ECS,EMS,EPB,SCC,SPAS,TCU - SG_ TCS_DEF : 8|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,EPB,SCC,SPAS,TCU - SG_ TCS_CTL : 9|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,EPB,SCC,SPAS,TCU - SG_ ABS_ACT : 10|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,ECS,EMS,EPB,LDWS_LKAS,SCC,SPAS,TCU - SG_ EBD_DEF : 11|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,EPB,SPAS,TCU - SG_ ESP_PAS : 12|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,CLU,EMS,EPB,LDWS_LKAS,SCC,TCU - SG_ ESP_DEF : 13|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,ECS,EMS,EPB,LDWS_LKAS,SCC,TCU - SG_ ESP_CTL : 14|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,ECS,EMS,EPB,LDWS_LKAS,SCC,SPAS,TCU - SG_ TCS_MFRN : 15|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,EPB,TCU - SG_ DBC_CTL : 16|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,EPB - SG_ DBC_PAS : 17|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,EPB - SG_ DBC_DEF : 18|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,EPB - SG_ HAC_CTL : 19|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU,EMS,EPB,TCU - SG_ HAC_PAS : 20|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU,EMS,EPB,TCU - SG_ HAC_DEF : 21|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU,EMS,EPB,TCU - SG_ ESS_STAT : 22|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,BCM,CLU,EMS,EPB - SG_ TQI_TCS : 24|8@1+ (0.390625,0.0) [0.0|99.609375] "%" EMS,EPB,TCU - SG_ TQI_MSR : 32|8@1+ (0.390625,0.0) [0.0|99.609375] "%" EMS,EPB,TCU - SG_ TQI_SLW_TCS : 40|8@1+ (0.390625,0.0) [0.0|99.609375] "%" EMS,EPB,TCU - SG_ CF_Esc_BrkCtl : 48|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ BLA_CTL : 49|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CGW,CLU - SG_ AliveCounter_TCS1 : 52|4@1+ (1.0,0.0) [0.0|14.0] "" EMS,EPB,LDWS_LKAS - SG_ CheckSum_TCS1 : 56|8@1+ (1.0,0.0) [0.0|255.0] "" EMS,EPB,LDWS_LKAS - -BO_ 1362 SNV11: 4 SNV - SG_ CF_SNV_DisplayControl : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,HUD - SG_ CF_Snv_BeepWarning : 2|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,HUD - SG_ CF_Snv_WarningMessage : 4|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,HUD - SG_ CF_Snv_DetectionEnable : 7|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CLU,HUD - SG_ CF_Snv_PedestrianDetect : 8|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU,HUD - SG_ CF_Snv_IRLampControl : 10|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU,HUD - -BO_ 593 MDPS12: 8 MDPS - SG_ CR_Mdps_StrColTq : 0|11@1+ (0.0078125,-8.0) [-8.0|7.9921875] "Nm" LDWS_LKAS - SG_ CF_Mdps_Def : 11|1@1+ (1.0,0.0) [0.0|1.0] "" ESC - SG_ CF_Mdps_ToiUnavail : 12|1@1+ (1.0,0.0) [0.0|1.0] "" LDWS_LKAS - SG_ CF_Mdps_ToiActive : 13|1@1+ (1.0,0.0) [0.0|1.0] "" LDWS_LKAS - SG_ CF_Mdps_ToiFlt : 14|1@1+ (1.0,0.0) [0.0|1.0] "" LDWS_LKAS - SG_ CF_Mdps_FailStat : 15|1@1+ (1.0,0.0) [0.0|1.0] "" LDWS_LKAS - SG_ CF_Mdps_MsgCount2 : 16|8@1+ (1.0,0.0) [0.0|255.0] "" ESC,LDWS_LKAS - SG_ CF_Mdps_Chksum2 : 24|8@1+ (1.0,0.0) [0.0|255.0] "" ESC,LDWS_LKAS - SG_ CF_Mdps_SErr : 37|1@1+ (1.0,0.0) [0.0|1.0] "" ESC - SG_ CR_Mdps_StrTq : 40|12@1+ (0.01,-20.48) [-20.48|20.47] "Nm" ESC - SG_ CR_Mdps_OutTq : 52|12@1+ (0.1,-204.8) [-204.8|204.7] "" ESC,LDWS_LKAS - -BO_ 1360 IAP11: 3 IAP - SG_ CF_Iap_EcoPmodSwi : 0|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Iap_EcoPmodAct : 1|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Iap_ReqWarn : 2|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - -BO_ 1356 TCU_DCT14: 8 TCU - SG_ Vehicle_Stop_Time : 0|5@1+ (1.0,0.0) [0.0|0.0] "" CLU - SG_ HILL_HOLD_WARNING : 5|1@1+ (1.0,0.0) [0.0|0.0] "" CLU - -BO_ 1353 BAT11: 8 EMS - SG_ BAT_SNSR_I : 0|16@1+ (0.01,-327.0) [-327.0|328.0] "A" CGW,CUBIS,IBOX,TMU - SG_ BAT_SOC : 16|8@1+ (1.0,0.0) [0.0|100.0] "%" CGW,CUBIS,IBOX,TMU - SG_ BAT_SNSR_V : 24|14@1+ (0.0010,6.0) [6.0|18.0] "V" CGW,CUBIS,IBOX,TMU - SG_ BAT_SNSR_Temp : 38|9@1- (0.5,-40.0) [-40.0|125.0] "deg" CGW,CUBIS,IBOX,TMU - SG_ BAT_SNSR_State : 47|1@1+ (1.0,0.0) [0.0|1.0] "" CGW,CUBIS,IBOX,TMU - SG_ BAT_SOH : 48|7@1+ (1.0,0.0) [0.0|100.0] "%" CGW,CUBIS,IBOX,TMU - SG_ BAT_SNSR_Invalid : 55|1@1+ (1.0,0.0) [0.0|1.0] "" CGW,CUBIS,IBOX,TMU - SG_ BAT_SOF : 56|7@1+ (0.1,0.0) [0.0|12.0] "V" CGW,CUBIS,IBOX,TMU - SG_ BAT_SNSR_Error : 63|1@1+ (1.0,0.0) [0.0|1.0] "" CGW,CUBIS,IBOX,TMU - -BO_ 1351 EMS15: 8 EMS - SG_ ECGPOvrd : 0|1@1+ (1.0,0.0) [0.0|1.0] "" ESC,IBOX,SCC - SG_ QECACC : 1|1@1+ (1.0,0.0) [0.0|1.0] "" ESC,IBOX - SG_ ECFail : 2|1@1+ (1.0,0.0) [0.0|1.0] "" ESC,IBOX - SG_ SwitchOffCondExt : 3|1@1+ (1.0,0.0) [0.0|1.0] "" ESC,IBOX - SG_ BLECFail : 4|1@1+ (1.0,0.0) [0.0|1.0] "" ESC,IBOX - SG_ CF_Ems_IsaAct : 5|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ FA_PV_CAN : 8|8@1+ (0.3906,0.0) [0.0|99.2] "%" IBOX,LDWS_LKAS,TCU - SG_ IntAirTemp : 16|8@1+ (0.75,-48.0) [-48.0|143.25] "deg" _4WD,ECS,EPB,IBOX,TCU - SG_ STATE_DC_OBD : 24|7@1+ (1.0,0.0) [0.0|127.0] "" IBOX,TCU - SG_ INH_DC_OBD : 31|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,TCU - SG_ CTR_IG_CYC_OBD : 32|16@1+ (1.0,0.0) [0.0|65535.0] "" ACU,IBOX,TCU - SG_ CTR_CDN_OBD : 48|16@1+ (1.0,0.0) [0.0|65535.0] "" IBOX,TCU - -BO_ 1350 DI_BOX12: 8 DI_BOX - SG_ CF_DiBox_FrtInjVDiagReg0 : 0|8@1+ (1.0,0.0) [0.0|255.0] "" EMS - SG_ CF_DiBox_FrtInjVDiagReg1 : 8|8@1+ (1.0,0.0) [0.0|255.0] "" EMS - SG_ CF_DiBox_FrtInjVDiagReg2 : 16|8@1+ (1.0,0.0) [0.0|255.0] "" EMS - SG_ CF_DiBox_SedInjVDiagReg0 : 24|8@1+ (1.0,0.0) [0.0|255.0] "" EMS - SG_ CF_DiBox_SedInjVDiagReg1 : 32|8@1+ (1.0,0.0) [0.0|255.0] "" EMS - SG_ CF_DiBox_SedInjVDiagReg2 : 40|8@1+ (1.0,0.0) [0.0|255.0] "" EMS - SG_ CR_DiBox_BatVol : 48|8@1+ (0.1,0.0) [0.0|25.5] "V" EMS - SG_ CF_DiBox_SedInjVChg : 56|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_DiBox_FrtInjVChg : 57|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_DiBox_SedInjVErrSPI : 58|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_DiBox_FrtInjVErrSPI : 59|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - -BO_ 1349 EMS14: 8 EMS - SG_ IMMO_LAMP_STAT : 0|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX - SG_ L_MIL : 1|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,CUBIS,IBOX - SG_ IM_STAT : 2|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX - SG_ AMP_CAN : 3|5@1+ (10.731613,458.98) [458.98|791.660003] "mmHg" CLU,IBOX,TCU,TPMS - SG_ BAT_Alt_FR_Duty : 8|8@1+ (0.4,0.0) [0.0|100.0] "%" CGW,CUBIS,IBOX,TMU - SG_ VB : 24|8@1+ (0.1015625,0.0) [0.0|25.8984375] "V" CLU,CUBIS,DATC,EPB,FPCM,IBOX - SG_ EMS_VS : 32|12@1+ (0.0625,0.0) [0.0|255.875] "km/h" CLU - SG_ TEMP_FUEL : 56|8@1+ (0.75,-48.0) [-48.0|143.25] "deg" FPCM - -BO_ 68 DATC11: 8 DATC - SG_ CF_Datc_Type : 0|8@1+ (1.0,0.0) [0.0|255.0] "" CLU - SG_ CF_Datc_VerMaj : 8|8@1+ (1.0,0.0) [0.0|255.0] "" CLU - SG_ CF_Datc_VerMin : 16|8@1+ (1.0,0.0) [0.0|255.0] "" CLU - SG_ CR_Datc_OutTempC : 24|8@1+ (0.5,-41.0) [-41.0|86.5] "deg" CLU,FPCM - SG_ CR_Datc_OutTempF : 32|8@1+ (1.0,-42.0) [-42.0|213.0] "deg" CLU - SG_ CF_Datc_IncarTemp : 40|8@1+ (0.5,-40.0) [-40.0|60.0] "deg" BCM,CLU - -BO_ 67 DATC13: 8 DATC - SG_ CF_Datc_TempDispUnit : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,IBOX - SG_ CF_Datc_ModDisp : 2|4@1+ (1.0,0.0) [0.0|15.0] "" CLU - SG_ CF_Datc_IonClean : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Datc_ChgReqDisp : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Datc_IntakeDisp : 10|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Datc_AutoDisp : 12|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Datc_FrDefLed : 14|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,IBOX - SG_ CF_Datc_AutoDefogBlink : 16|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Datc_ClmScanDisp : 18|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Datc_AqsDisp : 20|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Datc_AcDisp : 22|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Datc_OpSts : 25|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - SG_ CF_Mtc_MaxAcDisp : 28|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Datc_DualDisp : 30|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Datc_PwrInf : 32|4@1+ (1.0,0.0) [0.0|15.0] "" CLU - SG_ CF_Datc_RearManual : 38|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Datc_RearAutoDisp : 40|2@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Datc_RearOffDisp : 42|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Datc_RearClimateScnDisp : 44|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Datc_RearChgReqDisp : 46|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Datc_RearModDisp : 48|4@1+ (1.0,0.0) [0.0|15.0] "" CLU - SG_ CF_Datc_RearBlwDisp : 52|4@1+ (1.0,0.0) [0.0|15.0] "" CLU - SG_ CF_Datc_PSModDisp : 56|4@1+ (1.0,0.0) [0.0|15.0] "" CLU - SG_ CF_Datc_FrontBlwDisp : 60|4@1+ (1.0,0.0) [0.0|15.0] "" CLU,IBOX - -BO_ 66 DATC12: 8 DATC - SG_ CR_Datc_DrTempDispC : 0|8@1+ (0.5,14.0) [15.0|32.0] "deg" CLU,IBOX - SG_ CR_Datc_DrTempDispF : 8|8@1+ (1.0,56.0) [58.0|90.0] "¢µ" CLU,IBOX - SG_ CR_Datc_PsTempDispC : 16|8@1+ (0.5,14.0) [15.0|32.0] "deg" CLU,IBOX - SG_ CR_Datc_PsTempDispF : 24|8@1+ (1.0,56.0) [58.0|90.0] "¢µ" CLU,IBOX - SG_ CR_Datc_RearDrTempDispC : 40|8@1+ (0.5,14.0) [15.0|32.0] "deg" CLU - SG_ CR_Datc_RearDrTempDispF : 48|8@1+ (1.0,58.0) [58.0|90.0] "¢µ" CLU - SG_ CF_Datc_CO2_Warning : 56|8@1+ (1.0,0.0) [0.0|3.0] "" CLU - -BO_ 1345 CGW1: 8 BCM - SG_ CF_Gway_IGNSw : 0|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU,ECS,EMS,EPB,ESC,IBOX,LVR,MDPS,SAS,SCC,ECS,EMS,EPB,ESC,IBOX,LVR,MDPS,SAS,SCC - SG_ CF_Gway_RKECmd : 3|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,ECS,EMS,IBOX,ECS,EMS,IBOX - SG_ CF_Gway_DrvKeyLockSw : 6|1@1+ (1.0,0.0) [0.0|1.0] "" ECS,EMS,IBOX,ECS,EMS,IBOX - SG_ CF_Gway_DrvKeyUnlockSw : 7|1@1+ (1.0,0.0) [0.0|1.0] "" ECS,EMS,IBOX,ECS,EMS,IBOX - SG_ CF_Gway_DrvDrSw : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ECS,EMS,EPB,ESC,IBOX,SCC,TCU,ECS,EMS,EPB,ESC,IBOX,SCC,TCU - SG_ CF_Gway_DrvSeatBeltSw : 10|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,EPB,ESC,IBOX,PSB,TCU,EMS,EPB,ESC,IBOX,PSB,TCU - SG_ CF_Gway_TrunkTgSw : 12|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ECS,EMS,EPB,ESC,IBOX,ECS,EMS,EPB,ESC,IBOX - SG_ CF_Gway_AstSeatBeltSw : 14|2@1+ (1.0,0.0) [0.0|3.0] "" IBOX,PSB,IBOX,PSB - SG_ CF_Gway_SMKOption : 16|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,IBOX,EMS,IBOX,SMK - SG_ CF_Gway_HoodSw : 17|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,EMS,EPB,ESC,IBOX,EMS,EPB,ESC,IBOX - SG_ CF_Gway_TurnSigLh : 19|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,EMS,IBOX,LCA,LDWS_LKAS,SCC,EMS,IBOX,LCA,LDWS_LKAS,SCC - SG_ CF_Gway_WiperIntT : 21|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,EMS,IBOX,LDWS_LKAS,EMS,ESC,IBOX,LDWS_LKAS - SG_ CF_Gway_WiperIntSw : 24|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,IBOX,LDWS_LKAS,EMS,ESC,IBOX,LDWS_LKAS - SG_ CF_Gway_WiperLowSw : 25|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,IBOX,LDWS_LKAS,EMS,ESC,IBOX,LDWS_LKAS - SG_ CF_Gway_WiperHighSw : 26|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,IBOX,LDWS_LKAS,EMS,ESC,IBOX,LDWS_LKAS - SG_ CF_Gway_WiperAutoSw : 27|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,IBOX,LDWS_LKAS,EMS,ESC,IBOX,LDWS_LKAS - SG_ CF_Gway_RainSnsState : 28|3@1+ (1.0,0.0) [0.0|7.0] "" AFLS,EMS,IBOX,LDWS_LKAS,AFLS,EMS,ESC,IBOX,LDWS_LKAS - SG_ CF_Gway_HeadLampLow : 31|1@1+ (1.0,0.0) [0.0|1.0] "" AFLS,CLU,EMS,IBOX,LDWS_LKAS,SNV,AFLS,EMS,IBOX,LDWS_LKAS,SNV - SG_ CF_Gway_HeadLampHigh : 32|1@1+ (1.0,0.0) [0.0|1.0] "" AFLS,CLU,EMS,IBOX,LDWS_LKAS,AFLS,EMS,IBOX,LDWS_LKAS - SG_ CF_Gway_HazardSw : 33|2@1+ (1.0,0.0) [0.0|3.0] "" ABS,EMS,ESC,IBOX,LCA,LDWS_LKAS,ABS,EMS,ESC,IBOX,LCA,LDWS_LKAS - SG_ CF_Gway_AstDrSw : 35|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX,IBOX - SG_ CF_Gway_DefoggerRly : 36|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX,EMS,IBOX - SG_ CF_Gway_ALightStat : 37|1@1+ (1.0,0.0) [0.0|1.0] "" AFLS,IBOX,LDWS_LKAS,AFLS,IBOX,LDWS_LKAS - SG_ CF_Gway_LightSwState : 38|2@1+ (1.0,0.0) [0.0|3.0] "" AFLS,IBOX,LDWS_LKAS,AFLS,IBOX,LDWS_LKAS - SG_ CF_Gway_Frt_Fog_Act : 40|1@1+ (1.0,0.0) [0.0|1.0] "" AFLS,CLU,IBOX,LDWS_LKAS,AFLS,IBOX,LDWS_LKAS - SG_ CF_Gway_TSigRHSw : 41|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,LDWS_LKAS,IBOX,LDWS_LKAS - SG_ CF_Gway_TSigLHSw : 42|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,LDWS_LKAS,IBOX,LDWS_LKAS - SG_ CF_Gway_DriveTypeOption : 43|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX,LDWS_LKAS,IBOX,LDWS_LKAS - SG_ CF_Gway_StarterRlyState : 44|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX,EMS,IBOX,SMK - SG_ CF_Gway_PassiveAccessLock : 45|2@1+ (1.0,0.0) [0.0|7.0] "" CLU,ECS,EMS,IBOX,ECS,EMS,IBOX,SMK - SG_ CF_Gway_WiperMistSw : 47|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,IBOX,LDWS_LKAS - SG_ CF_Gway_PassiveAccessUnlock : 48|2@1+ (1.0,0.0) [0.0|7.0] "" CLU,ECS,EMS,IBOX,ECS,EMS,IBOX,SMK - SG_ CF_Gway_RrSunRoofOpenState : 50|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,DATC,IBOX - SG_ CF_Gway_PassingSW : 51|1@1+ (1.0,0.0) [0.0|1.0] "" AFLS,IBOX,LDWS_LKAS,AFLS,IBOX,LDWS_LKAS - SG_ CF_Gway_HBAControlMode : 52|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,LDWS_LKAS,IBOX,LDWS_LKAS - SG_ CF_Gway_HLpHighSw : 53|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,LDWS_LKAS,IBOX,LDWS_LKAS - SG_ CF_Gway_InhibitRMT : 54|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,EPB,ESC,IBOX,LCA,LDWS_LKAS,MDPS,PGS,SCC,SPAS,TPMS,EPB,ESC,IBOX,LCA,LDWS_LKAS,PGS,SCC,SPAS,TPMS - SG_ CF_Gway_RainSnsOption : 56|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ C_SunRoofOpenState : 57|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,DATC,IBOX,DATC,IBOX - SG_ CF_Gway_Ign1 : 58|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Gway_Ign2 : 59|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Gway_ParkBrakeSw : 60|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ESC,IBOX,SCC,ESC,IBOX,SCC - SG_ CF_Gway_TurnSigRh : 62|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,EMS,IBOX,LCA,LDWS_LKAS,SCC,EMS,IBOX,LCA,LDWS_LKAS,SCC - -BO_ 64 DATC14: 8 DATC - SG_ CF_Datc_AqsLevelOut : 0|4@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Datc_DiagMode : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CR_Datc_SelfDiagCode : 8|8@1+ (1.0,-1.0) [0.0|254.0] "" CLU - SG_ DATC_SyncDisp : 16|4@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ DATC_OffDisp : 20|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ DATC_SmartVentDisp : 22|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ DATC_SmartVentOnOffStatus : 24|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ DATC_AutoDefogSysOff_Disp : 26|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ DATC_ADSDisp : 28|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - -BO_ 832 LKAS11: 8 LDWS_LKAS - SG_ CF_Lkas_LdwsSysState : 2|4@1+ (1.0,0.0) [0.0|15.0] "" CLU,IBOX,PSB - SG_ CF_Lkas_SysWarning : 6|4@1+ (1.0,0.0) [0.0|15.0] "" BCM,CLU - SG_ CF_Lkas_LdwsLHWarning : 10|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU,PSB - SG_ CF_Lkas_LdwsRHWarning : 12|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU,PSB - SG_ CF_Lkas_HbaLamp : 14|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Lkas_FcwBasReq : 15|1@1+ (1.0,0.0) [0.0|1.0] "" ABS,ESC - SG_ CR_Lkas_StrToqReq : 16|11@1+ (0.0078125,-8.0) [-8.0|8.0] "Nm" MDPS - SG_ CF_Lkas_ActToi : 27|1@1+ (1.0,0.0) [0.0|1.0] "" MDPS - SG_ CF_Lkas_ToiFlt : 28|1@1+ (1.0,0.0) [0.0|1.0] "" MDPS - SG_ CF_Lkas_HbaSysState : 29|3@1+ (1.0,0.0) [0.0|7.0] "" BCM,CLU - SG_ CF_Lkas_FcwOpt : 32|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Lkas_HbaOpt : 34|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CGW - SG_ CF_Lkas_MsgCount : 36|4@1+ (1.0,0.0) [0.0|15.0] "" CLU,MDPS - SG_ CF_Lkas_FcwSysState : 40|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - SG_ CF_Lkas_FcwCollisionWarning : 43|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Lkas_FusionState : 45|2@1+ (1.0,0.0) [0.0|3.0] "" SCC - SG_ CF_Lkas_Chksum : 48|8@1+ (1.0,0.0) [0.0|255.0] "" MDPS - SG_ CF_Lkas_FcwOpt_USM : 56|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - SG_ CF_Lkas_LdwsOpt_USM : 59|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,MDPS - -BO_ 1342 LKAS12: 6 LDWS_LKAS - SG_ CF_Lkas_TsrSlifOpt : 10|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_LkasTsrStatus : 12|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Lkas_TsrSpeed_Display_Clu : 16|8@1+ (1.0,0.0) [0.0|255.0] "" CLU - SG_ CF_LkasTsrSpeed_Display_Navi : 24|8@1+ (1.0,0.0) [0.0|255.0] "" BCM,CLU - SG_ CF_Lkas_TsrAddinfo_Display : 32|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - -BO_ 1338 TMU_GW_E_01: 8 CLU - SG_ CF_Gway_TeleReqDrLock : 0|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ CF_Gway_TeleReqDrUnlock : 2|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ CF_Gway_TeleReqHazard : 4|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ CF_Gway_TeleReqHorn : 6|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ CF_Gway_TeleReqEngineOperate : 8|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - -BO_ 1078 PAS11: 4 BCM - SG_ CF_Gway_PASDisplayFLH : 0|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU,AVM - SG_ CF_Gway_PASDisplayFRH : 3|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU,AVM - SG_ CF_Gway_PASRsound : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,Dummy - SG_ CF_Gway_PASDisplayFCTR : 8|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU,AVM - SG_ CF_Gway_PASDisplayRCTR : 11|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU,PGS,AVM - SG_ CF_Gway_PASFsound : 14|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,Dummy - SG_ CF_Gway_PASDisplayRLH : 16|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU,PGS,AVM - SG_ CF_Gway_PASDisplayRRH : 19|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU,PGS,AVM - SG_ CF_Gway_PASCheckSound : 22|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,Dummy - SG_ CF_Gway_PASSystemOn : 24|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,Dummy - SG_ CF_Gway_PASOption : 26|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Gway_PASDistance : 28|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - -BO_ 48 EMS18: 6 EMS - SG_ CF_Ems_DC1NumPerMSV : 0|8@1+ (1.0,0.0) [0.0|255.0] "" DI_BOX - SG_ CF_Ems_DC2NumPerMSV : 8|16@1+ (1.0,0.0) [0.0|65535.0] "" DI_BOX - SG_ CR_Ems_DutyCyc1MSV : 24|8@1+ (0.1953,0.0) [0.0|49.8] "%" DI_BOX - SG_ CR_Ems_DutyCyc2MSV : 32|8@1+ (0.13725,0.0) [0.0|35.0] "%" DI_BOX - SG_ CR_Ems_DutyCyc3MSV : 40|8@1+ (0.392,0.0) [0.0|100.0] "%" DI_BOX - -BO_ 1322 CLU15: 8 CLU - SG_ CF_Clu_VehicleSpeed : 0|8@1+ (1.0,0.0) [0.0|255.0] "" BCM - SG_ CF_Clu_InhibitP : 9|1@1+ (1.0,0.0) [0.0|1.0] "" BCM - SG_ CF_Clu_InhibitR : 10|1@1+ (1.0,0.0) [0.0|1.0] "" BCM - SG_ CF_Clu_InhibitN : 11|1@1+ (1.0,0.0) [0.0|1.0] "" BCM - SG_ CF_Clu_InhibitD : 12|1@1+ (1.0,0.0) [0.0|1.0] "" BCM - SG_ CF_Clu_HudInfoSet : 13|7@1+ (1.0,0.0) [0.0|127.0] "" HUD - SG_ CF_Clu_HudFontColorSet : 20|2@1+ (1.0,0.0) [0.0|3.0] "" HUD - SG_ CF_Clu_HudBrightUpSW : 22|2@1+ (1.0,0.0) [0.0|3.0] "" HUD - SG_ CF_Clu_HudBrightDnSW : 24|2@1+ (1.0,0.0) [0.0|3.0] "" HUD - SG_ CF_Clu_HudHeightUpSW : 26|2@1+ (1.0,0.0) [0.0|3.0] "" HUD - SG_ CF_Clu_HudHeightDnSW : 28|2@1+ (1.0,0.0) [0.0|3.0] "" HUD - SG_ CF_Clu_HudSet : 30|1@1+ (1.0,0.0) [0.0|1.0] "" HUD - SG_ CF_Clu_HudFontSizeSet : 31|2@1+ (1.0,0.0) [0.0|3.0] "" HUD - SG_ CF_Clu_LanguageInfo : 33|5@1+ (1.0,0.0) [0.0|31.0] "" BCM,PGS - SG_ CF_Clu_ClusterSound : 38|1@1- (1.0,0.0) [0.0|0.0] "" BCM,CGW,FATC - -BO_ 1066 _4WD13: 6 _4WD - SG_ _4WD_CURRENT : 0|8@1+ (0.390625,0.0) [-50.0|50.0] "A" TCU - SG_ _4WD_POSITION : 8|16@1+ (0.015625,0.0) [-180.0|180.0] "Deg" TCU - SG_ _4WD_CLU_THERM_STR : 24|8@1+ (1.0,0.0) [0.0|100.0] "%" TCU - SG_ _4WD_STATUS : 32|8@1+ (1.0,0.0) [0.0|15.0] "" ESC,TCU - -BO_ 1065 _4WD12: 8 _4WD - SG_ Ster_Pos : 0|16@1+ (1.0,-600.0) [-600.0|600.0] "Deg" ESC - SG_ FRSS : 16|8@1+ (1.0,0.0) [0.0|254.0] "km/h" ESC - SG_ FLSS : 24|8@1+ (1.0,0.0) [0.0|254.0] "km/h" ESC - SG_ RRSS : 32|8@1+ (1.0,0.0) [0.0|254.0] "km/h" ESC - SG_ RLSS : 40|8@1+ (1.0,0.0) [0.0|254.0] "km/h" ESC - SG_ CLU_PRES : 48|16@1+ (0.0625,-50.0) [-50.0|50.0] "Bar" ESC - -BO_ 809 EMS12: 8 EMS - SG_ CONF_TCU m1 : 0|6@1+ (1.0,0.0) [0.0|63.0] "" _4WD,ACU,BCM,CLU,DATC,EPB,ESC,IBOX,LCA,SMK - SG_ CAN_VERS m0 : 0|6@1+ (1.0,0.0) [0.0|7.7] "" _4WD,ABS,ESC,IBOX - SG_ TQ_STND m3 : 0|6@1+ (10.0,0.0) [0.0|630.0] "Nm" _4WD,DATC,ECS,EPB,ESC,FATC,IBOX - SG_ OBD_FRF_ACK m2 : 0|6@1+ (1.0,0.0) [0.0|63.0] "" _4WD,ESC,IBOX - SG_ MUL_CODE M : 6|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,ABS,ACU,BCM,CLU,DATC,ECS,EPB,ESC,IBOX,LCA,SMK,TCU - SG_ TEMP_ENG : 8|8@1+ (0.75,-48.0) [-48.0|143.25] "deg" _4WD,BCM,CLU,DATC,EPB,ESC,IBOX,SMK,TCU - SG_ MAF_FAC_ALTI_MMV : 16|8@1+ (0.00781,0.0) [0.0|1.99155] "" IBOX,TCU - SG_ VB_OFF_ACT : 24|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,TCU - SG_ ACK_ES : 25|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,IBOX - SG_ CONF_MIL_FMY : 26|3@1+ (1.0,0.0) [0.0|7.0] "" ESC,IBOX,TCU - SG_ OD_OFF_REQ : 29|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,TCU - SG_ ACC_ACT : 30|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ABS,CLU,ESC,IAP,IBOX,SCC,TCU - SG_ CLU_ACK : 31|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EPB,ESC,IBOX - SG_ BRAKE_ACT : 32|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,ABS,ACU,AFLS,CLU,DATC,ECS,EPB,ESC,IBOX,LDWS_LKAS,TCU - SG_ ENG_CHR : 34|4@1+ (1.0,0.0) [0.0|15.0] "" _4WD,ABS,ACU,CLU,DATC,EPB,ESC,FATC,IBOX,SCC,SMK,TCU - SG_ GP_CTL : 38|2@1+ (1.0,0.0) [0.0|3.0] "" IBOX - SG_ TPS : 40|8@1+ (0.4694836,-15.0234742) [-15.0234742|104.6948357] "%" _4WD,ABS,ACU,CLU,DATC,ECS,EPB,ESC,IBOX,TCU - SG_ PV_AV_CAN : 48|8@1+ (0.3906,0.0) [0.0|99.603] "%" _4WD,AAF,ABS,ACU,AFLS,CLU,DATC,EPB,ESC,IAP,IBOX,LDWS_LKAS,SCC,TCU - SG_ ENG_VOL : 56|8@1+ (0.1,0.0) [0.0|25.5] "liter" _4WD,ABS,ACU,BCM,CLU,DATC,EPB,ESC,IBOX,LDWS_LKAS,SCC,SMK - -BO_ 1064 _4WD11: 8 _4WD - SG_ _4WD_TYPE : 0|2@1+ (1.0,0.0) [0.0|3.0] "" ACU,ESC,TPMS - SG_ _4WD_SUPPORT : 2|2@1+ (1.0,0.0) [0.0|3.0] "" ABS,ESC,TPMS - SG_ _4WD_ERR : 8|8@1+ (1.0,0.0) [0.0|255.0] "" CLU,ESC - SG_ CLU_DUTY : 16|8@1+ (1.0,0.0) [0.0|64.0] "%" ABS,ESC - SG_ R_TIRE : 24|8@1+ (1.0,200.0) [200.0|455.0] "mm" ABS,ESC,TPMS - SG_ _4WD_SW : 32|8@1+ (1.0,0.0) [0.0|9.9] "" ESC - SG_ _2H_ACT : 40|1@1+ (1.0,0.0) [0.0|1.0] "" ABS,ESC - SG_ _4H_ACT : 41|1@1+ (1.0,0.0) [0.0|1.0] "" ABS,CLU,ESC,TPMS - SG_ LOW_ACT : 42|1@1+ (1.0,0.0) [0.0|1.0] "" ABS,ESC,TCU,TPMS - SG_ AUTO_ACT : 43|1@1+ (1.0,0.0) [0.0|1.0] "" ABS,ESC,TPMS - SG_ LOCK_ACT : 44|1@1+ (1.0,0.0) [0.0|1.0] "" ABS,CLU,ESC,TPMS - SG_ _4WD_TQC_CUR : 48|16@1+ (1.0,0.0) [0.0|65535.0] "Nm" ABS,ESC - -BO_ 1319 HU_GW_E_01: 8 CLU - SG_ C_ADrLNValueSet : 0|3@1+ (1.0,0.0) [0.0|7.0] "" BCM - SG_ C_ADrUNValueSet : 4|3@1+ (1.0,0.0) [0.0|7.0] "" BCM - SG_ C_TwUnNValueSet : 8|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ C_ABuzzerNValueSet : 10|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ C_ArmWKeyNValueSet : 12|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ C_PSMNValueSet : 14|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ C_SCMNValueSet : 16|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ C_HLEscortNValueSet : 18|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ C_WELNValueSet : 20|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ C_TriTurnLNValueSet : 22|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ C_SNVWarnNValueSet : 24|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ C_LkasWarnNValueSet : 26|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - -BO_ 1318 HU_GW_E_00: 8 CLU - SG_ C_ADrLURValueReq : 0|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ C_TwUnRValueReq : 2|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ C_AlarmRValueReq : 4|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ C_IMSRValueReq : 6|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ C_HLEscortRValueReq : 8|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ C_WELRValueReq : 10|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ C_TriTurnLRValueReq : 12|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ C_SNVWarnRValueReq : 14|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ C_LkasWarnRValueReq : 16|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - -BO_ 1317 GW_HU_E_01: 8 BCM - SG_ C_ADrLRValue : 0|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - SG_ C_ADrURValue : 4|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - SG_ C_TwUnRValue : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_ABuzzerRValue : 10|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_ArmWKeyRValue : 12|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_PSMRValue : 14|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_SCMRValue : 16|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_HLEscortRValue : 18|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_WELRValue : 20|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_TriTurnLRValue : 22|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - -BO_ 1316 GW_HU_E_00: 8 BCM - SG_ C_ADrLUNValueConf : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_TwUnNValueConf : 2|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_AlarmNValueConf : 4|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_PSMNValueConf : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_SCMNValueConf : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_HLEscortNValueConf : 10|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_WELNValueConf : 12|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_TriTurnLNValueConf : 14|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - -BO_ 1315 GW_SWRC_PE: 8 BCM - SG_ C_ModeSW : 2|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_MuteSW : 4|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_SeekDnSW : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_SeekUpSW : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_BTPhoneCallSW : 10|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_BTPhoneHangUpSW : 12|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_DISCDownSW : 14|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_DISCUpSW : 16|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_SdsSW : 18|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_MTSSW : 20|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_VolDnSW : 22|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_VolUpSW : 24|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - -BO_ 1314 GW_IPM_PE_1: 8 BCM - SG_ C_AV_Tail : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_ParkingBrakeSW : 2|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_RKECMD : 4|4@1+ (1.0,0.0) [0.0|15.0] "" CLU - SG_ C_BAState : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_IGNSW : 12|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - SG_ C_CountryCfg : 16|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - SG_ C_TailLampActivity : 26|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ RearSW_RSELockOnOff : 28|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_SMKTeleCrankingState : 32|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_SMKTeleCrankingFailRes : 34|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - -BO_ 1057 SCC12: 8 SCC - SG_ CF_VSM_Prefill : 0|1@1+ (1.0,0.0) [0.0|1.0] "" ESC - SG_ CF_VSM_DecCmdAct : 1|1@1+ (1.0,0.0) [0.0|1.0] "" ESC - SG_ CF_VSM_HBACmd : 2|2@1+ (1.0,0.0) [0.0|3.0] "" ESC - SG_ CF_VSM_Warn : 4|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ESC,IAP - SG_ CF_VSM_Stat : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ESC,PSB - SG_ CF_VSM_BeltCmd : 8|3@1+ (1.0,0.0) [0.0|7.0] "" ESC,PSB - SG_ ACCFailInfo : 11|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,CUBIS,ESC,IBOX - SG_ ACCMode : 13|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ESC,IBOX,TCU - SG_ StopReq : 15|1@1+ (1.0,0.0) [0.0|1.0] "" EPB,ESC - SG_ CR_VSM_DecCmd : 16|8@1+ (0.01,0.0) [0.0|2.55] "g" ESC - SG_ aReqMax : 24|11@1+ (0.01,-10.23) [-10.23|10.24] "m/s^2" EMS,ESC,TCU - SG_ TakeOverReq : 35|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,ESC,TCU - SG_ PreFill : 36|1@1+ (1.0,0.0) [0.0|1.0] "" ESC,TCU - SG_ aReqMin : 37|11@1+ (0.01,-10.23) [-10.23|10.24] "m/s^2" EMS,ESC,TCU - SG_ CF_VSM_ConfMode : 48|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ESC - SG_ AEB_Failinfo : 50|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ESC - SG_ AEB_Status : 52|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ESC - SG_ AEB_CmdAct : 54|1@1+ (1.0,0.0) [0.0|1.0] "" ESC - SG_ AEB_StopReq : 55|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,ESC - SG_ CR_VSM_Alive : 56|4@1+ (1.0,0.0) [0.0|15.0] "" ESC,PSB - SG_ CR_VSM_ChkSum : 60|4@1+ (1.0,0.0) [0.0|15.0] "" ESC,PSB - -BO_ 1313 GW_DDM_PE: 8 BCM - SG_ C_DRVDoorStatus : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_ASTDoorStatus : 2|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_RLDoorStatus : 4|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_RRDoorStatus : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_TrunkStatus : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ C_OSMirrorStatus : 10|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - -BO_ 1056 SCC11: 8 SCC - SG_ MainMode_ACC : 0|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,ESC - SG_ SCCInfoDisplay : 1|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,ESC - SG_ AliveCounterACC : 4|4@1+ (1.0,0.0) [0.0|15.0] "" CLU,EMS,ESC,TCU - SG_ VSetDis : 8|8@1+ (1.0,0.0) [0.0|255.0] "km/h or MPH" CLU,ESC,TCU - SG_ ObjValid : 16|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,ESC,TCU - SG_ DriverAlertDisplay : 17|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ESC - SG_ TauGapSet : 19|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,ESC,TCU - SG_ ACC_ObjStatus : 22|2@1+ (1.0,0.0) [0.0|3.0] "" ABS,ESC - SG_ ACC_ObjLatPos : 24|9@1+ (0.1,-20.0) [-20.0|31.1] "m" ABS,ESC - SG_ ACC_ObjDist : 33|11@1+ (0.1,0.0) [0.0|204.7] "m" ABS,ESC - SG_ ACC_ObjRelSpd : 44|12@1+ (0.1,-170.0) [-170.0|239.5] "m/s" ABS,ESC - SG_ Navi_SCC_Curve_Status : 56|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ Navi_SCC_Curve_Act : 58|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ Navi_SCC_Camera_Act : 60|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ Navi_SCC_Camera_Status : 62|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - -BO_ 1312 CGW3: 8 BCM - SG_ CR_Photosensor_LH : 0|8@1+ (78.125,0.0) [0.0|20000.0] "" DATC,DATC - SG_ CR_Photosensor_RH : 10|8@1+ (78.125,0.0) [0.0|20000.0] "" DATC,DATC - SG_ CF_Hoodsw_memory : 22|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,EMS - SG_ C_MirOutTempSns : 24|8@1+ (0.5,-40.5) [-40.0|60.0] "deg" AAF,CLU,DATC,EMS,SPAS,AAF,DATC,EMS,SPAS - -BO_ 544 ESP12: 8 ESC - SG_ LAT_ACCEL : 0|11@1+ (0.01,-10.23) [-10.23|10.24] "m/s^2" _4WD,ECS,IBOX,LCA,LDWS_LKAS,MDPS,PSB,SCC,TCU - SG_ LAT_ACCEL_STAT : 11|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,IBOX,LDWS_LKAS,MDPS,PSB,SCC,TCU - SG_ LAT_ACCEL_DIAG : 12|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,IBOX,LDWS_LKAS,MDPS,PSB,SCC,TCU - SG_ LONG_ACCEL : 13|11@1+ (0.01,-10.23) [-10.23|10.24] "m/s^2" _4WD,ECS,EMS,EPB,IBOX,LCA,LDWS_LKAS,PSB,SCC,SPAS,TCU - SG_ LONG_ACCEL_STAT : 24|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,EPB,IBOX,LDWS_LKAS,PSB,SCC,SPAS,TCU - SG_ LONG_ACCEL_DIAG : 25|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,EPB,IBOX,LDWS_LKAS,PSB,SCC,SPAS,TCU - SG_ CYL_PRES : 26|12@1+ (0.1,0.0) [0.0|409.5] "Bar" _4WD,ECS,EMS,EPB,IBOX,LDWS_LKAS,PSB,SCC,TCU - SG_ CYL_PRES_STAT : 38|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ECS,EMS,EPB,IBOX,LDWS_LKAS,PSB,SCC,TCU - SG_ CYL_PRESS_DIAG : 39|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ECS,EMS,EPB,IBOX,PSB,SCC,TCU - SG_ YAW_RATE : 40|13@1+ (0.01,-40.95) [-40.95|40.96] "" _4WD,AFLS,IBOX,LCA,LDWS_LKAS,MDPS,PSB,SCC,SPAS,TCU - SG_ YAW_RATE_STAT : 53|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,AFLS,IBOX,LCA,LDWS_LKAS,MDPS,PSB,SCC,SPAS,TCU - SG_ YAW_RATE_DIAG : 54|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,AFLS,IBOX,LCA,LDWS_LKAS,MDPS,PSB,SCC,SPAS,TCU - SG_ ESP12_AliveCounter : 56|4@1+ (1.0,0.0) [0.0|15.0] "" _4WD,EMS,LPI,TCU,TMU - SG_ ESP12_Checksum : 60|4@1+ (1.0,0.0) [0.0|15.0] "" _4WD,EMS,LPI,TCU,TMU - -BO_ 1307 CLU16: 8 CLU - SG_ CF_Clu_TirePressUnitNValueSet : 0|3@1+ (1.0,0.0) [0.0|7.0] "" TPMS - SG_ CF_Clu_SlifNValueSet : 3|2@1+ (1.0,0.0) [0.0|3.0] "" LDWS_LKAS - SG_ CF_Clu_RearWiperNValueSet : 12|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - -BO_ 790 EMS11: 8 EMS - SG_ SWI_IGK : 0|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ABS,ACU,AHLS,CUBIS,DI_BOX,ECS,EPB,ESC,IBOX,LDWS_LKAS,MDPS,REA,SAS,SCC,TCU - SG_ F_N_ENG : 1|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,AFLS,CLU,CUBIS,DATC,ECS,EPB,ESC,IBOX,MDPS,SCC,TCU - SG_ ACK_TCS : 2|1@1+ (1.0,0.0) [0.0|1.0] "" ESC,IBOX - SG_ PUC_STAT : 3|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU,DATC,IBOX,TCU - SG_ TQ_COR_STAT : 4|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,ESC,IBOX,TCU - SG_ RLY_AC : 6|1@1+ (1.0,0.0) [0.0|1.0] "" DATC,IBOX,TCU - SG_ F_SUB_TQI : 7|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ECS,EPB,ESC,IBOX,TCU - SG_ TQI_ACOR : 8|8@1+ (0.390625,0.0) [0.0|99.6094] "%" _4WD,EPB,ESC,IBOX,TCU - SG_ N : 16|16@1+ (0.25,0.0) [0.0|16383.75] "rpm" _4WD,ACU,AFLS,CLU,CUBIS,DATC,ECS,EPB,ESC,FPCM,IBOX,MDPS,SCC,TCU - SG_ TQI : 32|8@1+ (0.390625,0.0) [0.0|99.6094] "%" _4WD,ECS,EPB,ESC,IBOX,TCU - SG_ TQFR : 40|8@1+ (0.390625,0.0) [0.0|99.6094] "%" _4WD,EPB,ESC,IBOX,TCU - SG_ VS : 48|8@1+ (1.0,0.0) [0.0|254.0] "km/h" _4WD,AAF,ACU,AHLS,BCM,CLU,DATC,ECS,EPB,IBOX,LCA,LDWS_LKAS,LVR,MDPS,ODS,SCC,SMK,SPAS,TCU,TPMS - SG_ RATIO_TQI_BAS_MAX_STND : 56|8@1+ (0.0078,0.0) [0.0|2.0] "" _4WD,IBOX,TCU - -BO_ 1301 CLU14: 8 CLU - SG_ CF_Clu_ADrUNValueSet : 0|3@1+ (1.0,0.0) [0.0|7.0] "" BCM - SG_ CF_Clu_ADrLNValueSet : 3|3@1+ (1.0,0.0) [0.0|7.0] "" BCM - SG_ CF_Clu_EscortHLNValueSet : 6|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ CF_Clu_DoorLSNValueSet : 8|3@1+ (1.0,0.0) [0.0|7.0] "" BCM - SG_ CF_Clu_PSMNValueSet : 11|3@1+ (1.0,0.0) [0.0|7.0] "" BCM - SG_ CF_Clu_TTUnlockNValueSet : 14|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ CF_Clu_PTGMNValueSet : 16|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ CF_Clu_SCMNValueSet : 18|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ CF_Clu_WlightNValueSet : 20|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ CF_Clu_TempUnitNValueSet : 22|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,DATC - SG_ CF_Clu_MoodLpNValueSet : 24|3@1+ (1.0,0.0) [0.0|7.0] "" BCM - SG_ CF_Clu_TrfChgSet : 27|2@1+ (1.0,0.0) [0.0|3.0] "" AFLS - SG_ CF_Clu_OTTurnNValueSet : 29|3@1+ (1.0,0.0) [0.0|7.0] "" BCM - SG_ CF_Clu_LcaNValueSet : 32|2@1+ (1.0,0.0) [0.0|3.0] "" LCA - SG_ CF_Clu_RctaNValueSet : 34|2@1+ (1.0,0.0) [0.0|3.0] "" LCA - SG_ CF_Clu_RcwNValueSet : 36|2@1+ (1.0,0.0) [0.0|3.0] "" LCA - SG_ CF_Clu_EscOffNValueSet : 38|3@1+ (1.0,0.0) [0.0|7.0] "" ESC - SG_ CF_Clu_SccNaviCrvNValueSet : 41|2@1+ (1.0,0.0) [0.0|3.0] "" SCC - SG_ CF_Clu_SccNaviCamNValueSet : 43|2@1+ (1.0,0.0) [0.0|3.0] "" SCC - SG_ CF_Clu_SccAebNValueSet : 45|2@1+ (1.0,0.0) [0.0|3.0] "" SCC - SG_ CF_Clu_LkasModeNValueSet : 47|2@1+ (1.0,0.0) [0.0|3.0] "" LDWS_LKAS - SG_ CF_Clu_FcwNValueSet : 51|2@1+ (1.0,0.0) [0.0|3.0] "" LDWS_LKAS - SG_ CF_Clu_PasSpkrLvNValueSet : 53|3@1+ (1.0,0.0) [0.0|7.0] "" BCM - SG_ CF_Clu_SccDrvModeNValueSet : 56|3@1+ (1.0,0.0) [0.0|7.0] "" SCC - SG_ CF_Clu_HAnBNValueSet : 59|2@1+ (1.0,0.0) [0.0|3.0] "" BCM - SG_ CF_Clu_HfreeTrunkTgNValueSet : 61|3@1+ (1.0,0.0) [0.0|7.0] "" BCM - -BO_ 275 TCU13: 8 TCU - SG_ N_TGT_LUP : 0|8@1+ (10.0,500.0) [500.0|3040.0] "rpm" EMS,IBOX - SG_ SLOPE_TCU : 8|6@1+ (0.5,-16.0) [-16.0|15.5] "%" CLU,CUBIS,EMS,IBOX - SG_ CF_Tcu_InhCda : 14|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX - SG_ CF_Tcu_IsgInhib : 15|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX - SG_ CF_Tcu_BkeOnReq : 16|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,IBOX - SG_ CF_Tcu_NCStat : 18|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,IBOX - SG_ CF_Tcu_TarGr : 20|4@1+ (1.0,0.0) [0.0|15.0] "" _4WD,CLU,DATC,EMS,EPB,ESC,IBOX,SCC - SG_ CF_Tcu_ShfPatt : 24|4@1+ (1.0,0.0) [0.0|15.0] "" CLU,CUBIS,EMS,IBOX - SG_ CF_Tcu_InhVis : 28|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX - SG_ CF_Tcu_PRelReq : 29|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,LVR - SG_ CF_Tcu_ITPhase : 30|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX - SG_ CF_Tcu_ActEcoRdy : 31|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX - SG_ CF_Tcu_TqGrdLim : 32|8@1+ (10.0,0.0) [0.0|2540.0] "Nm/s" EMS,IBOX - SG_ CR_Tcu_IsgTgtRPM : 40|8@1+ (20.0,0.0) [0.0|3500.0] "rpm" EMS,IBOX - SG_ CF_Tcu_SptRdy : 48|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX - SG_ CF_Tcu_SbwPInfo : 56|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX - SG_ CF_Tcu_Alive3 : 58|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,IBOX - SG_ CF_Tcu_ChkSum3 : 60|4@1+ (1.0,0.0) [0.0|15.0] "" EMS,IBOX - -BO_ 274 TCU12: 8 TCU - SG_ ETL_TCU : 0|8@1+ (2.0,0.0) [0.0|508.0] "Nm" EMS,IBOX - SG_ CUR_GR : 8|4@1+ (1.0,0.0) [0.0|15.0] "" _4WD,EMS,ESC,IBOX,SCC,TPMS - SG_ CF_Tcu_Alive : 12|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,ESC,IBOX,SCC - SG_ CF_Tcu_ChkSum : 14|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,ESC,IBOX,SCC - SG_ VS_TCU : 16|8@1+ (1.0,0.0) [0.0|254.0] "km/h" BCM,CLU,DATC,EMS,IBOX,LCA,LVR,PGS,SMK,SNV - SG_ FUEL_CUT_TCU : 28|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX - SG_ INH_FUEL_CUT : 29|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX - SG_ IDLE_UP_TCU : 30|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX - SG_ N_INC_TCU : 31|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX - SG_ SPK_RTD_TCU : 32|8@1+ (0.375,-23.625) [-15.0|15.0] "" EMS,IBOX - SG_ N_TC_RAW : 40|16@1+ (0.25,0.0) [0.0|16383.5] "rpm" EMS,IBOX - SG_ VS_TCU_DECIMAL : 56|8@1+ (0.0078125,0.0) [0.0|0.9921875] "km/h" CLU,EMS,IBOX,LCA - -BO_ 273 TCU11: 8 TCU - SG_ TQI_TCU_INC : 0|8@1+ (0.390625,0.0) [0.0|99.609375] "%" EMS,ESC,IBOX - SG_ G_SEL_DISP : 8|4@1+ (1.0,0.0) [0.0|15.0] "" _4WD,AFLS,AVM,BCM,CGW,CLU,CUBIS,ECS,EMS,EPB,ESC,IAP,IBOX,LCA,LDWS_LKAS,LVR,MDPS,PGS,SCC,SMK,SNV,SPAS,TPMS - SG_ F_TCU : 12|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,ESC,IBOX - SG_ TCU_TYPE : 14|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,EMS,ESC,IBOX - SG_ TCU_OBD : 16|3@1+ (1.0,0.0) [0.0|7.0] "" EMS,ESC,IBOX - SG_ SWI_GS : 19|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,EPB,ESC,IBOX,SCC - SG_ GEAR_TYPE : 20|4@1+ (1.0,0.0) [0.0|15.0] "" _4WD,CLU,EMS,ESC,IBOX,SCC - SG_ TQI_TCU : 24|8@1+ (0.390625,0.0) [0.0|99.609375] "%" EMS,ESC,IBOX - SG_ TEMP_AT : 32|8@1+ (1.0,-40.0) [-40.0|214.0] "deg" AAF,CLU,CUBIS,EMS,ESC,IBOX - SG_ N_TC : 40|16@1+ (0.25,0.0) [0.0|16383.5] "rpm" _4WD,EMS,EPB,ESC,IBOX - SG_ SWI_CC : 56|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,CLU,EMS,ESC,IBOX - SG_ CF_Tcu_Alive1 : 58|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,IBOX - SG_ CF_Tcu_ChkSum1 : 60|4@1+ (1.0,0.0) [0.0|15.0] "" EMS,IBOX - -BO_ 16 ACU13: 8 ACU - SG_ CF_Acu_CshAct : 0|1@1+ (1.0,0.0) [0.0|1.0] "" CUBIS,IBOX,ODS - -BO_ 1040 CGW_USM1: 8 BCM - SG_ CF_Gway_ATTurnRValue : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Gway_PTGMRValue : 2|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Gway_EscortHLRValue : 4|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Gway_TTUnlockRValue : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Gway_ADrLRValue : 8|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - SG_ CF_Gway_ADrURValue : 11|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - SG_ CF_Gway_SCMRValue : 14|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Gway_WlightRValue : 16|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Gway_PSMRValue : 18|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - SG_ CF_Gway_OTTurnRValue : 21|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - SG_ CF_Gway_DrLockSoundRValue : 24|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - SG_ CF_Gway_HAnBRValue : 27|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - SG_ CF_Gway_MoodLpRValue : 30|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Gway_HfreeTrunkRValue : 32|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - SG_ CF_Gway_AutoLightRValue : 35|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - SG_ CF_Gway_RearWiperRValue : 38|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_Gway_PasSpkrLvRValue : 40|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - -BO_ 1292 CLU13: 8 CLU - SG_ CF_Clu_LowfuelWarn : 0|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,FPCM,IBOX - SG_ CF_Clu_RefDetMod : 2|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX - SG_ CF_Clu_AvgFCU : 3|2@1+ (1.0,0.0) [0.0|3.0] "" IBOX - SG_ CF_Clu_AvsmCur : 5|1@1+ (1.0,0.0) [0.0|1.0] "" ESC,SCC - SG_ CF_Clu_AvgFCI : 6|10@1+ (0.1,0.0) [0.0|102.2] "" IBOX - SG_ CF_Clu_DrivingModeSwi : 16|2@1+ (1.0,0.0) [0.0|3.0] "" DATC,ECS,EMS,ESC,IAP,MDPS,TCU - SG_ CF_Clu_FuelDispLvl : 18|5@1+ (1.0,0.0) [0.0|31.0] "" CGW,IBOX - SG_ CF_Clu_FlexSteerSW : 23|1@1+ (1.0,0.0) [0.0|1.0] "" MDPS - SG_ CF_Clu_DTE : 24|10@1+ (1.0,0.0) [0.0|1023.0] "" DATC - SG_ CF_Clu_TripUnit : 34|2@1+ (1.0,0.0) [0.0|3.0] "" DATC - SG_ CF_Clu_SWL_Stat : 36|3@1+ (1.0,0.0) [0.0|7.0] "" ACU,EMS - SG_ CF_Clu_ActiveEcoSW : 39|1@1+ (1.0,0.0) [0.0|1.0] "" DATC,EMS,TCU - SG_ CF_Clu_EcoDriveInf : 40|3@1+ (1.0,0.0) [0.0|7.0] "" CUBIS,EMS,IAP,IBOX - SG_ CF_Clu_IsaMainSW : 43|1@1+ (1.0,0.0) [0.0|1.0] "" EMS - SG_ CF_Clu_LdwsLkasSW : 56|1@1+ (1.0,0.0) [0.0|1.0] "" LDWS_LKAS - SG_ CF_Clu_AltLStatus : 59|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,DATC,EMS - SG_ CF_Clu_AliveCnt2 : 60|4@1+ (1.0,0.0) [0.0|15.0] "" EMS,LDWS_LKAS - -BO_ 1290 SCC13: 8 SCC - SG_ SCCDrvModeRValue : 0|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - SG_ SCC_Equip : 3|1@1+ (1.0,0.0) [0.0|1.0] "" ESC - SG_ AebDrvSetStatus : 4|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,ESC - -BO_ 1287 TCS15: 4 ESC - SG_ ABS_W_LAMP : 0|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU,CUBIS,IBOX - SG_ TCS_OFF_LAMP : 1|2@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,CLU - SG_ TCS_LAMP : 3|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,ACU,CLU,CUBIS,IBOX,SCC - SG_ DBC_W_LAMP : 5|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU - SG_ DBC_F_LAMP : 6|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,CLU - SG_ ESC_Off_Step : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ AVH_CLU : 16|8@1+ (1.0,0.0) [0.0|255.0] "" CLU,EPB - SG_ AVH_I_LAMP : 24|2@1+ (1.0,0.0) [0.0|3.0] "" EPB - SG_ EBD_W_LAMP : 26|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU - SG_ AVH_ALARM : 27|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ AVH_LAMP : 29|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,EPB,SPAS - -BO_ 1282 TCU14: 4 TCU - SG_ CF_TCU_WarnMsg : 0|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - SG_ CF_TCU_WarnImg : 3|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_TCU_WarnSnd : 4|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ CF_Tcu_GSel_BlinkReq : 5|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,LVR - SG_ CF_Tcu_StRelStat : 12|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,ESC - SG_ CF_Tcu_DriWarn1 : 13|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,EMS,ESC - SG_ CF_Tcu_DriWarn2 : 16|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,EMS,ESC - -BO_ 1281 ECS11: 3 ECS - SG_ ECS_W_LAMP : 0|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,CUBIS,IBOX - SG_ SYS_NA : 1|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ ECS_DEF : 2|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ ECS_DIAG : 3|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ L_CHG_NA : 4|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ Leveling_Off : 5|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ LC_overheat : 6|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ Lifting : 8|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ Lowering : 9|1@1+ (1.0,0.0) [0.0|1.0] "" CLU - SG_ Damping_Mode : 10|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ REQ_Damping : 12|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ REQ_Height : 14|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ REQ_level : 16|4@1+ (1.0,0.0) [0.0|15.0] "" CLU - SG_ ACT_Height : 20|4@1+ (1.0,0.0) [0.0|15.0] "" CLU - -BO_ 1024 CLU_CFG11: 2 CLU - SG_ Vehicle_Type : 0|16@1+ (1.0,0.0) [0.0|65536.0] "" _4WD - -BO_ 1280 ACU14: 1 ACU - SG_ CF_SWL_Ind : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_TTL_Ind : 2|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ CF_SBR_Ind : 4|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU - -BO_ 512 EMS20: 6 EMS - SG_ FCO : 0|16@1+ (0.128,0.0) [0.0|8388.48] "ul" CLU,CUBIS,FPCM,IBOX - SG_ CF_Ems_PumpTPres : 16|8@1+ (3.137254902,0.0) [0.0|800.0] "kPa" FPCM,IBOX - SG_ Split_Stat : 32|1@1+ (1.0,0.0) [0.0|1.0] "" FPCM diff --git a/opendbc/hyundai_2015_mcan.dbc b/opendbc/hyundai_2015_mcan.dbc deleted file mode 100644 index 6bcd771e511205..00000000000000 --- a/opendbc/hyundai_2015_mcan.dbc +++ /dev/null @@ -1,1564 +0,0 @@ -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_: CLOCK HUD H_U DATC CCP KMA_TMU CUBIS TMU IPM RSE_R RRC CGW RSE_L AMP EDT SWRC IBOX CLU FHCU ASD MON AVM KBD - - -BO_ 3221225472 VECTOR__INDEPENDENT_SIG_MSG: 0 Vector__XXX - SG_ C_WHEEL_FL : 0|12@0+ (1,0) [0|0] "" Vector__XXX - SG_ C_WHEEL_FR : 0|12@0+ (1,0) [0|0] "" Vector__XXX - SG_ C_WHEEL_RL : 0|12@0+ (1,0) [0|0] "" Vector__XXX - SG_ C_WHEEL_RR : 0|12@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 2046 TP_EDT_AMP: 8 EDT - SG_ Byte0_TCP_7FE : 7|8@0+ (1,0) [0|0] "" AMP - SG_ Byte1_Data_7FE : 15|8@0+ (1,0) [0|0] "" AMP - SG_ Byte2_Data_7FE : 23|8@0+ (1,0) [0|0] "" AMP - SG_ Byte3_Data_7FE : 31|8@0+ (1,0) [0|0] "" AMP - SG_ Byte4_Data_7FE : 39|8@0+ (1,0) [0|0] "" AMP - SG_ Byte5_Data_7FE : 47|8@0+ (1,0) [0|0] "" AMP - SG_ Byte6_Data_7FE : 55|8@0+ (1,0) [0|0] "" AMP - SG_ Byte7_Data_7FE : 63|8@0+ (1,0) [0|0] "" AMP - -BO_ 251 HU_TMU_E_02: 8 H_U - SG_ HU_GPS_Year : 7|8@0+ (1,0) [0|0] "" CUBIS,TMU - SG_ HU_GPS_Month : 15|8@0+ (1,0) [0|0] "" CUBIS,TMU - SG_ HU_GPS_Day : 23|8@0+ (1,0) [0|0] "" CUBIS,TMU - SG_ HU_GPS_Hour : 31|8@0+ (1,0) [0|0] "" CUBIS,TMU - SG_ HU_GPS_Minute : 39|8@0+ (1,0) [0|0] "" CUBIS,TMU - SG_ HU_GPS_Second : 47|8@0+ (1,0) [0|0] "" CUBIS,TMU - -BO_ 250 HU_TMU_E_01: 8 H_U - SG_ HU_VoiceRecCom : 2|3@0+ (1,0) [0|0] "" TMU - SG_ HU_LangChgCom : 5|3@0+ (1,0) [0|0] "" TMU - SG_ HU_CallEndCmd : 9|2@0+ (1,0) [0|0] "" TMU - SG_ HU_ServiceReqtID : 13|4@0+ (1,0) [0|0] "" TMU - SG_ HU_MicReqCmd : 15|2@0+ (1,0) [0|0] "" TMU - SG_ HU_SeviceAction : 18|3@0+ (1,0) [0|0] "" TMU - SG_ HU_eCallStatus : 20|2@0+ (1,0) [0|0] "" TMU - -BO_ 1269 TP_CLU_ANDAUTO_HU: 8 CLU - SG_ Byte0_TCP_4F5 : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_4F5 : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_4F5 : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_4F5 : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_4F5 : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_4F5 : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_4F5 : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_4F5 : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 1268 TP_HU_ANDAUTO_CLU: 8 H_U - SG_ Byte0_TCP_4F4 : 7|8@0+ (1,0) [0|0] "" CLU - SG_ Byte1_Data_4F4 : 15|8@0+ (1,0) [0|0] "" CLU - SG_ Byte2_Data_4F4 : 23|8@0+ (1,0) [0|0] "" CLU - SG_ Byte3_Data_4F4 : 31|8@0+ (1,0) [0|0] "" CLU - SG_ Byte4_Data_4F4 : 39|8@0+ (1,0) [0|0] "" CLU - SG_ Byte5_Data_4F4 : 47|8@0+ (1,0) [0|0] "" CLU - SG_ Byte6_Data_4F4 : 55|8@0+ (1,0) [0|0] "" CLU - SG_ Byte7_Data_4F4 : 63|8@0+ (1,0) [0|0] "" CLU - -BO_ 1267 TP_CLU_CARPLAY_HU: 8 CLU - SG_ Byte0_TCP_4F3 : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_4F3 : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_4F3 : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_4F3 : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_4F3 : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_4F3 : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_4F3 : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_4F3 : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 1266 TP_HU_CARPLAY_CLU: 8 H_U - SG_ Byte0_TCP_4F2 : 7|8@0+ (1,0) [0|0] "" CLU - SG_ Byte1_Data_4F2 : 15|8@0+ (1,0) [0|0] "" CLU - SG_ Byte2_Data_4F2 : 23|8@0+ (1,0) [0|0] "" CLU - SG_ Byte3_Data_4F2 : 31|8@0+ (1,0) [0|0] "" CLU - SG_ Byte4_Data_4F2 : 39|8@0+ (1,0) [0|0] "" CLU - SG_ Byte5_Data_4F2 : 47|8@0+ (1,0) [0|0] "" CLU - SG_ Byte6_Data_4F2 : 55|8@0+ (1,0) [0|0] "" CLU - SG_ Byte7_Data_4F2 : 63|8@0+ (1,0) [0|0] "" CLU - -BO_ 1263 TP_CLU_IBOX_HU: 8 CLU - SG_ Byte0_TCP_4EF : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_4EF : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_4EF : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_4EF : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_4EF : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_4EF : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_4EF : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_4EF : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 1262 TP_HU_IBOX_CLU: 8 H_U - SG_ Byte0_TCP_4EE : 7|8@0+ (1,0) [0|0] "" CLU - SG_ Byte1_Data_4EE : 15|8@0+ (1,0) [0|0] "" CLU - SG_ Byte2_Data_4EE : 23|8@0+ (1,0) [0|0] "" CLU - SG_ Byte3_Data_4EE : 31|8@0+ (1,0) [0|0] "" CLU - SG_ Byte4_Data_4EE : 39|8@0+ (1,0) [0|0] "" CLU - SG_ Byte5_Data_4EE : 47|8@0+ (1,0) [0|0] "" CLU - SG_ Byte6_Data_4EE : 55|8@0+ (1,0) [0|0] "" CLU - SG_ Byte7_Data_4EE : 63|8@0+ (1,0) [0|0] "" CLU - -BO_ 1261 TP_CLU_DLNA_HU: 8 CLU - SG_ Byte0_TCP_4ED : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_4ED : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_4ED : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_4ED : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_4ED : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_4ED : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_4ED : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_4ED : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 1260 TP_HU_DLNA_CLU: 8 H_U - SG_ Byte0_TCP_4EC : 7|8@0+ (1,0) [0|0] "" CLU - SG_ Byte1_Data_4EC : 15|8@0+ (1,0) [0|0] "" CLU - SG_ Byte2_Data_4EC : 23|8@0+ (1,0) [0|0] "" CLU - SG_ Byte3_Data_4EC : 31|8@0+ (1,0) [0|0] "" CLU - SG_ Byte4_Data_4EC : 39|8@0+ (1,0) [0|0] "" CLU - SG_ Byte5_Data_4EC : 47|8@0+ (1,0) [0|0] "" CLU - SG_ Byte6_Data_4EC : 55|8@0+ (1,0) [0|0] "" CLU - SG_ Byte7_Data_4EC : 63|8@0+ (1,0) [0|0] "" CLU - -BO_ 491 GW_DDM_PE: 8 CLU - SG_ C_DRVDoorStatus : 1|2@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CUBIS,DATC,EDT,FHCU,HUD,H_U,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,SWRC,TMU - SG_ C_ASTDoorStatus : 3|2@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CUBIS,DATC,EDT,FHCU,HUD,H_U,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,SWRC,TMU - SG_ C_RLDoorStatus : 5|2@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CUBIS,DATC,EDT,FHCU,HUD,H_U,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,SWRC,TMU - SG_ C_RRDoorStatus : 7|2@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CUBIS,DATC,EDT,FHCU,HUD,H_U,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,SWRC,TMU - SG_ C_TrunkStatus : 9|2@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CUBIS,DATC,EDT,FHCU,HUD,H_U,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,SWRC,TMU - SG_ C_OSMirrorStatus : 11|2@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CUBIS,DATC,EDT,FHCU,HUD,H_U,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,SWRC,TMU - -BO_ 1259 TP_CLU_MP_HU: 8 CLU - SG_ Byte0_TCP_4EB : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_4EB : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_4EB : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_4EB : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_4EB : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_4EB : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_4EB : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_4EB : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 1258 TP_HU_MP_CLU: 8 H_U - SG_ Byte0_TCP_4EA : 7|8@0+ (1,0) [0|0] "" CLU - SG_ Byte1_Data_4EA : 15|8@0+ (1,0) [0|0] "" CLU - SG_ Byte2_Data_4EA : 23|8@0+ (1,0) [0|0] "" CLU - SG_ Byte3_Data_4EA : 31|8@0+ (1,0) [0|0] "" CLU - SG_ Byte4_Data_4EA : 39|8@0+ (1,0) [0|0] "" CLU - SG_ Byte5_Data_4EA : 47|8@0+ (1,0) [0|0] "" CLU - SG_ Byte6_Data_4EA : 55|8@0+ (1,0) [0|0] "" CLU - SG_ Byte7_Data_4EA : 63|8@0+ (1,0) [0|0] "" CLU - -BO_ 1257 TP_CLU_FM_HU: 8 CLU - SG_ Byte0_TCP_4E9 : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_4E9 : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_4E9 : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_4E9 : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_4E9 : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_4E9 : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_4E9 : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_4E9 : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 1256 TP_HU_FM_CLU: 8 H_U - SG_ Byte0_TCP_4E8 : 7|8@0+ (1,0) [0|0] "" CLU - SG_ Byte1_Data_4E8 : 15|8@0+ (1,0) [0|0] "" CLU - SG_ Byte2_Data_4E8 : 23|8@0+ (1,0) [0|0] "" CLU - SG_ Byte3_Data_4E8 : 31|8@0+ (1,0) [0|0] "" CLU - SG_ Byte4_Data_4E8 : 39|8@0+ (1,0) [0|0] "" CLU - SG_ Byte5_Data_4E8 : 47|8@0+ (1,0) [0|0] "" CLU - SG_ Byte6_Data_4E8 : 55|8@0+ (1,0) [0|0] "" CLU - SG_ Byte7_Data_4E8 : 63|8@0+ (1,0) [0|0] "" CLU - -BO_ 1255 TP_CLU_MLT_HU: 8 CLU - SG_ Byte0_TCP_4E7 : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_4E7 : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_4E7 : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_4E7 : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_4E7 : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_4E7 : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_4E7 : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_4E7 : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 487 HU_CLU_PE_13: 8 H_U - SG_ Navi_DistToPoint1_F : 11|4@0+ (1,0) [0|0] "" CLU,HUD - SG_ Navi_DistToPoint1_I : 7|12@0+ (1,0) [0|0] "" CLU,HUD - SG_ Navi_DistToPoint1_U : 23|4@0+ (1,0) [0|0] "" CLU,HUD - SG_ Navi_DistToPoint2_I : 19|12@0+ (1,0) [0|0] "" CLU,HUD - SG_ Navi_DistToPoint2_F : 35|4@0+ (1,0) [0|0] "" CLU,HUD - SG_ Navi_DistToPoint2_U : 39|4@0+ (1,0) [0|0] "" CLU,HUD - SG_ Navi_DistToPoint3_F : 51|4@0+ (1,0) [0|0] "" CLU,HUD - SG_ Navi_DistToPoint3_I : 47|12@0+ (1,0) [0|0] "" CLU,HUD - SG_ Navi_DistToPoint3_U : 63|4@0+ (1,0) [0|0] "" CLU,HUD - -BO_ 1254 TP_HU_MLT_CLU: 8 H_U - SG_ Byte0_TCP_4E6 : 7|8@0+ (1,0) [0|0] "" CLU - SG_ Byte1_Data_4E6 : 15|8@0+ (1,0) [0|0] "" CLU - SG_ Byte2_Data_4E6 : 23|8@0+ (1,0) [0|0] "" CLU - SG_ Byte3_Data_4E6 : 31|8@0+ (1,0) [0|0] "" CLU - SG_ Byte4_Data_4E6 : 39|8@0+ (1,0) [0|0] "" CLU - SG_ Byte5_Data_4E6 : 47|8@0+ (1,0) [0|0] "" CLU - SG_ Byte6_Data_4E6 : 55|8@0+ (1,0) [0|0] "" CLU - SG_ Byte7_Data_4E6 : 63|8@0+ (1,0) [0|0] "" CLU - -BO_ 486 HU_CLU_PE_12: 8 H_U - SG_ Navi_DistToDest_I : 7|16@0+ (1,0) [0|0] "" CLU,HUD - SG_ Navi_DistToDest_F : 19|4@0+ (1,0) [0|0] "" CLU,HUD - SG_ Navi_DistToDest_U : 23|4@0+ (1,0) [0|0] "" CLU,HUD - SG_ Navi_EstimHour : 31|8@0+ (1,0) [0|254] "hh" CLU,HUD - SG_ Navi_EstimMin : 37|6@0+ (1,0) [0|59] "mm" CLU,HUD - SG_ Navi_EstimTimeType : 39|2@0+ (1,0) [0|0] "" CLU,HUD - SG_ Navi_Compass : 45|6@0+ (7.5,-7.5) [0|352.5] "Degree" CLU,HUD - -BO_ 229 HU_SYS_E_00: 8 H_U - SG_ SYS_SW_Ver_Req : 1|2@0+ (1,0) [0|0] "" AMP,CCP,CGW,CLOCK,CLU,HUD,IBOX,RRC,RSE_L - SG_ SYS_CAN_Ver_Req : 3|2@0+ (1,0) [0|0] "" AMP,CCP,CGW,CLOCK,CLU,HUD,IBOX,RRC,RSE_L - SG_ SYS_HW_Ver_Req : 5|2@0+ (1,0) [0|0] "" AMP,CCP,CGW,CLOCK,CLU,IBOX,RRC - SG_ SYS_RBD_Req : 9|2@0+ (1,0) [0|0] "" AMP,IBOX - SG_ SYS_MOSTErrorDiag_Req : 11|2@0+ (1,0) [0|0] "" AMP,IBOX - SG_ SYS_Reset_Req : 17|2@0+ (1,0) [0|0] "" AMP,IBOX - -BO_ 1253 TP_CLU_VCDC_HU: 8 CLU - SG_ Byte0_TCP_4E5 : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_4E5 : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_4E5 : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_4E5 : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_4E5 : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_4E5 : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_4E5 : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_4E5 : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 485 HU_CLU_PE_11: 8 H_U - SG_ Navi_FixedSpdTrap : 3|4@0+ (10,0) [10|110] "Km/h" CLU,HUD - SG_ Navi_MobileSpdTrap : 7|4@0+ (10,0) [10|110] "Km/h" CLU,HUD - SG_ Navi_OverSpdAlarm : 11|2@0+ (1,0) [0|0] "" CGW,CLU,HUD - SG_ Navi_SpdRedlightTrap : 15|4@0+ (10,0) [10|110] "Km/h" CLU,HUD - SG_ Navi_NonSpdTrap : 20|5@0+ (1,0) [0|0] "" CLU,HUD - SG_ Navi_WarningZone : 27|4@0+ (1,0) [0|0] "" CLU,HUD - SG_ Navi_MergeWarning : 33|2@0+ (1,0) [0|0] "" CLU,HUD - SG_ Navi_CurveWarning : 39|4@0+ (1,0) [0|0] "" CLU,HUD - SG_ Navi_BusSpdTrap : 43|4@0+ (10,0) [10|110] "Km/h" CLU,HUD - SG_ Navi_SpdLimit_Type : 49|2@0+ (1,0) [0|0] "" CLU,HUD - SG_ Navi_SpdLimit_Unit : 51|2@0+ (1,0) [0|0] "" CLU,HUD - SG_ Navi_SpdInfo_Type : 55|4@0+ (1,0) [0|0] "" CLU,HUD - SG_ Navi_SpdLimit : 63|8@0+ (1,0) [1|254] "" CLU,HUD - -BO_ 1252 TP_HU_VCDC_CLU: 8 H_U - SG_ Byte0_TCP_4E4 : 7|8@0+ (1,0) [0|0] "" CLU - SG_ Byte1_Data_4E4 : 15|8@0+ (1,0) [0|0] "" CLU - SG_ Byte2_Data_4E4 : 23|8@0+ (1,0) [0|0] "" CLU - SG_ Byte3_Data_4E4 : 31|8@0+ (1,0) [0|0] "" CLU - SG_ Byte4_Data_4E4 : 39|8@0+ (1,0) [0|0] "" CLU - SG_ Byte5_Data_4E4 : 47|8@0+ (1,0) [0|0] "" CLU - SG_ Byte6_Data_4E4 : 55|8@0+ (1,0) [0|0] "" CLU - SG_ Byte7_Data_4E4 : 63|8@0+ (1,0) [0|0] "" CLU - -BO_ 1251 TP_CLU_JB_HU: 8 CLU - SG_ Byte0_TCP_4E3 : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_4E3 : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_4E3 : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_4E3 : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_4E3 : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_4E3 : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_4E3 : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_4E3 : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 1250 TP_HU_JB_CLU: 8 H_U - SG_ Byte0_TCP_4E2 : 7|8@0+ (1,0) [0|0] "" CLU - SG_ Byte1_Data_4E2 : 15|8@0+ (1,0) [0|0] "" CLU - SG_ Byte2_Data_4E2 : 23|8@0+ (1,0) [0|0] "" CLU - SG_ Byte3_Data_4E2 : 31|8@0+ (1,0) [0|0] "" CLU - SG_ Byte4_Data_4E2 : 39|8@0+ (1,0) [0|0] "" CLU - SG_ Byte5_Data_4E2 : 47|8@0+ (1,0) [0|0] "" CLU - SG_ Byte6_Data_4E2 : 55|8@0+ (1,0) [0|0] "" CLU - SG_ Byte7_Data_4E2 : 63|8@0+ (1,0) [0|0] "" CLU - -BO_ 1248 TP_TMU_HU: 8 TMU - SG_ Byte0_TCP_4E0 : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_4E0 : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_4E0 : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_4E0 : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_4E0 : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_4E0 : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_4E0 : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_4E0 : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 479 CLU_HU_PE_01: 8 CLU - SG_ CLU_Type : 7|8@0+ (1,0) [0|0] "" H_U - SG_ CLU_Region : 15|8@0+ (1,0) [0|0] "" H_U - SG_ CLU_VersionMinor : 23|8@0+ (1,0) [0|0] "" H_U - SG_ CLU_VersionMajor : 31|8@0+ (1,0) [0|0] "" H_U - SG_ CLU_CurrentDispState : 39|8@0+ (1,0) [0|0] "" H_U - SG_ C_DRVDRSW : 41|2@0+ (1,0) [0|0] "" H_U - SG_ CF_Clu_LowfuelWarning : 44|2@0+ (1,0) [0|0] "" H_U - SG_ CLU_PowerInfo : 46|2@0+ (1,0) [0|0] "" H_U - SG_ C_DrivingModeState : 50|3@0+ (1,0) [0|0] "" H_U - SG_ Clu_RheostatLvl : 55|5@0+ (1,0) [0|0] "" H_U,MON,SWRC - SG_ C_Clu_ActiveEcoSW : 57|2@0+ (1,0) [0|0] "" H_U - SG_ C_Detent : 59|2@0+ (1,0) [0|0] "" CCP,CLOCK,H_U,KBD,MON,RRC,RSE_L,RSE_R - SG_ C_DrivingModeOn : 61|2@0+ (1,0) [0|0] "" H_U - -BO_ 2015 TP_EDT_All_Req: 8 EDT - SG_ Byte0_TCP_7DF : 7|8@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CLU,CUBIS,DATC,FHCU,HUD,H_U,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,TMU - SG_ Byte1_Data_7DF : 15|8@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CLU,CUBIS,DATC,FHCU,HUD,H_U,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,TMU - SG_ Byte2_Data_7DF : 23|8@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CLU,CUBIS,DATC,FHCU,HUD,H_U,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,TMU - SG_ Byte3_Data_7DF : 31|8@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CLU,CUBIS,DATC,FHCU,HUD,H_U,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,TMU - SG_ Byte4_Data_7DF : 39|8@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CLU,CUBIS,DATC,FHCU,HUD,H_U,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,TMU - SG_ Byte5_Data_7DF : 47|8@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CLU,CUBIS,DATC,FHCU,HUD,H_U,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,TMU - SG_ Byte6_Data_7DF : 55|8@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CLU,CUBIS,DATC,FHCU,HUD,H_U,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,TMU - SG_ Byte7_Data_7DF : 63|8@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CLU,CUBIS,DATC,FHCU,HUD,H_U,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,TMU - -BO_ 474 CLU_HU_PE_02: 8 CLU - SG_ CF_Clu_AvgFCU : 1|2@0+ (1,0) [0|0] "" H_U - SG_ CF_Clu_AvgFCL : 9|10@0+ (1,0) [0|0] "" H_U - SG_ CF_Clu_TermAvgSync : 25|2@0+ (1,0) [0|0] "" H_U - SG_ CF_Clu_EcoDriveInf : 36|3@0+ (1,0) [0|0] "" H_U - SG_ CR_Clu_TermAvgFCI : 33|10@0+ (1,0) [0|0] "" H_U - SG_ CF_CLU_EcoScore : 55|16@0+ (1,0) [0|0] "" H_U - -BO_ 1495 CLU_HU_P_05: 8 CLU - SG_ Clu_TripUnit : 9|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ Clu_DTEWarn : 11|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ Clu_DTE : 7|12@0+ (1,0) [0|1500] "km" H_U,IBOX - SG_ Clu_AFC : 23|10@0+ (0.1,0) [0|99.9] "" H_U,IBOX - SG_ Clu_IFC : 29|10@0+ (0.1,0) [0|99.9] "" H_U,IBOX - SG_ Clu_Odometer : 47|24@0+ (1,0) [0|999999] "" H_U,IBOX - -BO_ 1494 CLU_HU_P_01: 8 CLU - SG_ CF_TripUnit : 13|2@0+ (1,0) [0|0] "" H_U - SG_ CF_DTE : 7|10@0+ (1,0) [0|0] "" H_U - -BO_ 214 AMP_HU_E_SYS: 8 AMP - SG_ AMP_SWVerMajor : 7|8@0+ (1,0) [0|254] "" H_U,IBOX - SG_ AMP_SWVerMinor : 15|8@0+ (1,0) [0|254] "" H_U,IBOX - SG_ AMP_CANVerMajor : 23|8@0+ (1,0) [0|254] "" H_U,IBOX - SG_ AMP_CANVerMinor : 31|8@0+ (1,0) [0|254] "" H_U,IBOX - SG_ AMP_RBDResult : 34|3@0+ (1,0) [0|0] "" H_U - SG_ AMP_MOSTErrorDiagResult : 38|3@0+ (1,0) [0|0] "" H_U - SG_ AMP_HWVerMajor : 55|8@0+ (1,0) [0|254] "" H_U,IBOX - SG_ AMP_HWVerMinor : 63|8@0+ (1,0) [0|254] "" H_U,IBOX - -BO_ 1492 CLU_HU_P_04: 8 CLU - SG_ MM_CR_Fatc_AcnComCst_W : 7|10@0+ (10,0) [0|8000] "W" H_U - SG_ MM_CR_Ldc_PwrMon_W : 12|8@0+ (10,0) [0|2550] "W" H_U - SG_ MM_CR_Fatc_PTCPwrCon_W : 17|10@0+ (10,0) [0|10000] "W" H_U - SG_ MM_CR_BmsChgExp_T_Fast : 39|16@0+ (1,0) [0|0] "minute" H_U - SG_ MM_CR_BmsChgExp_T_Slow : 55|16@0+ (1,0) [0|0] "minute" H_U - -BO_ 1491 CLU_HU_P_03: 8 CLU - SG_ MM_CF_Vcu_EvMod : 3|4@0+ (1,0) [0|0] "" H_U - SG_ MM_CF_Vcu_GarSelDisp : 7|4@0+ (999,0) [0|0] "" H_U - SG_ MM_CF_Vcu_ThiBatTir : 8|1@0+ (1,0) [0|0] "" H_U - SG_ CR_Mcu_MotEstTqPc : 23|10@0+ (0.2,-100) [-100|99.8] "%" H_U - SG_ CR_Mcu_MotActRotSpd_rpm : 39|16@0+ (1,-32768) [-32768|32767] "rpm" H_U - -BO_ 1490 CLU_HU_P_02: 8 CLU - SG_ MM_CR_Vcu_EcoSco : 3|4@0+ (1,0) [0|0] "" H_U - SG_ MM_CF_Vcu_PgmRun5 : 5|2@0+ (1,0) [0|0] "" H_U - SG_ MM_CR_Clu_Odometer_kph : 15|24@0+ (0.1,0) [0|0] "km" H_U - -BO_ 1489 DATC_P_B_01: 8 CLU - SG_ C_InhibitR_DATC : 51|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ C_InhibitP_DATC : 50|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ C_InhibitN_DATC : 49|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ C_InhibitD_DATC : 48|1@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 465 CLU_HU_PE_03: 8 CLU - SG_ CF_Clu_EVDTEDisp : 0|9@0+ (1,0) [0|0] "" H_U,IBOX - SG_ CF_Clu_GasDTEDisp : 17|10@0+ (1,0) [0|0] "" H_U,IBOX - SG_ MM_CR_Clu_TotalDTEDisp : 34|11@0+ (1,0) [0|0] "" H_U,IBOX - SG_ CF_Clu_TripUnit : 49|2@0+ (1,0) [0|0] "" H_U,IBOX - -BO_ 1232 TP_HU_TMU: 8 H_U - SG_ Byte0_TCP_4D0 : 7|8@0+ (1,0) [0|0] "" TMU - SG_ Byte1_Data_4D0 : 15|8@0+ (1,0) [0|0] "" TMU - SG_ Byte2_Data_4D0 : 23|8@0+ (1,0) [0|0] "" TMU - SG_ Byte3_Data_4D0 : 31|8@0+ (1,0) [0|0] "" TMU - SG_ Byte4_Data_4D0 : 39|8@0+ (1,0) [0|0] "" TMU - SG_ Byte5_Data_4D0 : 47|8@0+ (1,0) [0|0] "" TMU - SG_ Byte6_Data_4D0 : 55|8@0+ (1,0) [0|0] "" TMU - SG_ Byte7_Data_4D0 : 63|8@0+ (1,0) [0|0] "" TMU - -BO_ 1488 CLU_HU_P_00: 8 CLU - SG_ MM_CR_Mcu_VehSpd_Kph : 7|8@0+ (1,0) [0|0] "" H_U - SG_ MM_CR_Mcu_VehSpdDec_Kph : 15|8@0+ (1,0) [0|0] "" H_U - SG_ MM_CR_Bms_Soc_Pc : 23|8@0+ (1,0) [0|0] "" H_U - SG_ MM_CR_Vcu_TqMotClu_Pc : 31|8@0+ (1,-127) [0|0] "" H_U - SG_ MM_CR_Bms_DrvEnaDist : 39|8@0+ (1,0) [0|0] "" H_U - SG_ MM_CR_Clu_Soc_Seg : 44|5@0+ (1,0) [0|0] "" H_U,IBOX - -BO_ 208 CLU_HU_E_SYS: 8 CLU - SG_ CLU_SWVerMajor : 7|8@0+ (1,0) [0|254] "" H_U - SG_ CLU_SWVerMinor : 15|8@0+ (1,0) [0|254] "" H_U - SG_ CLU_CANVerMajor : 23|8@0+ (1,0) [0|254] "" H_U - SG_ CLU_CANVerMinor : 31|8@0+ (1,0) [0|254] "" H_U - SG_ CLU_HWVerMajor : 55|8@0+ (1,0) [0|254] "" H_U - SG_ CLU_HWVerMinor : 63|8@0+ (1,0) [0|254] "" H_U - -BO_ 448 HU_DATC_PE_00: 8 H_U - SG_ DATC_AqsLevelChg : 3|4@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ RSELockOnOff : 7|2@0+ (1,0) [0|0] "" CGW,DATC,IPM,RRC - SG_ DATC_AqsMode : 9|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_Graphreset_Info : 17|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_VRActivity : 33|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_PhoneActivity : 35|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ BlowerNoiseControl : 37|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - -BO_ 1211 TP_HU_TBT_CLU: 8 H_U - SG_ Byte0_TCP_4BB : 7|8@0+ (1,0) [0|0] "" CLU - SG_ Byte1_Data_4BB : 15|8@0+ (1,0) [0|0] "" CLU - SG_ Byte2_Data_4BB : 23|8@0+ (1,0) [0|0] "" CLU - SG_ Byte3_Data_4BB : 31|8@0+ (1,0) [0|0] "" CLU - SG_ Byte4_Data_4BB : 39|8@0+ (1,0) [0|0] "" CLU - SG_ Byte5_Data_4BB : 47|8@0+ (1,0) [0|0] "" CLU - SG_ Byte6_Data_4BB : 55|8@0+ (1,0) [0|0] "" CLU - SG_ Byte7_Data_4BB : 63|8@0+ (1,0) [0|0] "" CLU - -BO_ 1207 TP_HU_DAB_CLU: 8 H_U - SG_ Byte0_TCP_4B7 : 7|8@0+ (1,0) [0|0] "" CLU - SG_ Byte1_Data_4B7 : 15|8@0+ (1,0) [0|0] "" CLU - SG_ Byte2_Data_4B7 : 23|8@0+ (1,0) [0|0] "" CLU - SG_ Byte3_Data_4B7 : 31|8@0+ (1,0) [0|0] "" CLU - SG_ Byte4_Data_4B7 : 39|8@0+ (1,0) [0|0] "" CLU - SG_ Byte5_Data_4B7 : 47|8@0+ (1,0) [0|0] "" CLU - SG_ Byte6_Data_4B7 : 55|8@0+ (1,0) [0|0] "" CLU - SG_ Byte7_Data_4B7 : 63|8@0+ (1,0) [0|0] "" CLU - -BO_ 1206 TP_HU_XM_CLU: 8 H_U - SG_ Byte0_TCP_4B6 : 7|8@0+ (1,0) [0|0] "" CLU - SG_ Byte1_Data_4B6 : 15|8@0+ (1,0) [0|0] "" CLU - SG_ Byte2_Data_4B6 : 23|8@0+ (1,0) [0|0] "" CLU - SG_ Byte3_Data_4B6 : 31|8@0+ (1,0) [0|0] "" CLU - SG_ Byte4_Data_4B6 : 39|8@0+ (1,0) [0|0] "" CLU - SG_ Byte5_Data_4B6 : 47|8@0+ (1,0) [0|0] "" CLU - SG_ Byte6_Data_4B6 : 55|8@0+ (1,0) [0|0] "" CLU - SG_ Byte7_Data_4B6 : 63|8@0+ (1,0) [0|0] "" CLU - -BO_ 1204 TP_HU_DMB_CLU: 8 H_U - SG_ Byte0_TCP_4B4 : 7|8@0+ (1,0) [0|0] "" CLU - SG_ Byte1_Data_4B4 : 15|8@0+ (1,0) [0|0] "" CLU - SG_ Byte2_Data_4B4 : 23|8@0+ (1,0) [0|0] "" CLU - SG_ Byte3_Data_4B4 : 31|8@0+ (1,0) [0|0] "" CLU - SG_ Byte4_Data_4B4 : 39|8@0+ (1,0) [0|0] "" CLU - SG_ Byte5_Data_4B4 : 47|8@0+ (1,0) [0|0] "" CLU - SG_ Byte6_Data_4B4 : 55|8@0+ (1,0) [0|0] "" CLU - SG_ Byte7_Data_4B4 : 63|8@0+ (1,0) [0|0] "" CLU - -BO_ 432 TMU_GW_PE_01: 8 TMU - SG_ C_DATCOnOffReq : 1|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,H_U,IPM - SG_ C_DATCTempUnit : 3|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,H_U,IPM - SG_ C_DATCTempSet : 15|8@0+ (1,0) [0|0] "" CGW,CLU,DATC,H_U,IPM - SG_ TMU_IVRActivity : 33|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,H_U,IPM - SG_ TMU_PhoneActivity : 35|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,H_U,IPM - -BO_ 1195 TP_CLU_TBT_HU: 8 CLU - SG_ Byte0_TCP_4AB : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_4AB : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_4AB : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_4AB : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_4AB : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_4AB : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_4AB : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_4AB : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 1191 TP_CLU_DAB_HU: 8 CLU - SG_ Byte0_TCP_4A7 : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_4A7 : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_4A7 : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_4A7 : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_4A7 : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_4A7 : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_4A7 : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_4A7 : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 1190 TP_CLU_XM_HU: 8 CLU - SG_ Byte0_TCP_4A6 : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_4A6 : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_4A6 : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_4A6 : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_4A6 : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_4A6 : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_4A6 : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_4A6 : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 1188 TP_CLU_DMB_HU: 8 CLU - SG_ Byte0_TCP_4A4 : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_4A4 : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_4A4 : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_4A4 : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_4A4 : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_4A4 : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_4A4 : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_4A4 : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 1179 TP_HU_NAVI_CLU: 8 H_U - SG_ Byte0_TCP_49B : 7|8@0+ (1,0) [0|0] "" CLU - SG_ Byte1_Data_49B : 15|8@0+ (1,0) [0|0] "" CLU - SG_ Byte2_Data_49B : 23|8@0+ (1,0) [0|0] "" CLU - SG_ Byte3_Data_49B : 31|8@0+ (1,0) [0|0] "" CLU - SG_ Byte4_Data_49B : 39|8@0+ (1,0) [0|0] "" CLU - SG_ Byte5_Data_49B : 47|8@0+ (1,0) [0|0] "" CLU - SG_ Byte6_Data_49B : 55|8@0+ (1,0) [0|0] "" CLU - SG_ Byte7_Data_49B : 63|8@0+ (1,0) [0|0] "" CLU - -BO_ 1178 TP_CLU_Ipod_HU: 8 CLU - SG_ Byte0_TCP_49A : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_49A : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_49A : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_49A : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_49A : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_49A : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_49A : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_49A : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 410 HU_CLU_PE_08: 8 H_U - SG_ VCDC_SelDiscNo : 11|4@0+ (1,0) [0|0] "" CLU - SG_ VCDC_TrackChapterNo : 7|10@0+ (1,0) [0|0] "" CLU - SG_ VCDC_PlayTime : 23|24@0+ (1,0) [0|0] "" CLU - SG_ MLT_PlayTime : 47|24@0+ (1,0) [0|0] "" CLU - -BO_ 1176 TP_CLU_DVD_HU: 8 CLU - SG_ Byte0_TCP_498 : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_498 : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_498 : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_498 : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_498 : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_498 : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_498 : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_498 : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 1175 TP_CLU_USB_HU: 8 CLU - SG_ Byte0_TCP_497 : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_497 : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_497 : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_497 : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_497 : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_497 : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_497 : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_497 : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 407 HU_CLU_PE_05: 8 H_U - SG_ HU_LanguageInfo : 7|8@0+ (1,0) [0|0] "" CLU,HUD - SG_ HU_MuteStatus : 9|2@0+ (1,0) [0|0] "" CLU,HUD - SG_ HU_VolumeStatus : 15|6@0+ (1,0) [0|0] "" CLU,HUD - SG_ HU_NaviDisp : 17|2@0+ (1,0) [0|0] "" CLU,HUD - SG_ HU_NaviStatus : 19|2@0+ (1,0) [0|0] "" CGW,CLU,HUD,IPM - SG_ HU_DistanceUnit : 21|2@0+ (1,0) [0|0] "" CLU,HUD - SG_ HU_Navigation_On_Off : 23|2@0+ (1,0) [0|0] "" AVM,CGW,CLU,DATC,HUD,IPM - -BO_ 1942 TP_AMP_HU_DiagRes: 8 AMP - SG_ Byte0_TCP_796 : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_796 : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_796 : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_796 : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_796 : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_796 : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_796 : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_796 : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 406 HU_CLU_PE_04: 8 H_U - SG_ C_SDARS_ChannelNo : 7|8@0+ (1,0) [0|0] "" CLU - SG_ C_NaviRouteGuidance : 11|2@0+ (1,0) [0|0] "" CLU - SG_ HD_SPS_ChannelNo : 15|4@0+ (1,0) [0|0] "" CLU - SG_ C_SDARS_PresetNo : 19|4@0+ (1,0) [0|0] "" CLU - SG_ DAB_ServiceFollowing : 21|2@0+ (1,0) [0|0] "" CLU - SG_ SXM_ChannelNo : 25|10@0+ (1,0) [0|999] "" AMP,CLU,HUD - -BO_ 1941 TP_HU_AMP_DiagReq: 8 H_U - SG_ Byte0_TCP_795 : 7|8@0+ (1,0) [0|0] "" AMP - SG_ Byte1_Data_795 : 15|8@0+ (1,0) [0|0] "" AMP - SG_ Byte2_Data_795 : 23|8@0+ (1,0) [0|0] "" AMP - SG_ Byte3_Data_795 : 31|8@0+ (1,0) [0|0] "" AMP - SG_ Byte4_Data_795 : 39|8@0+ (1,0) [0|0] "" AMP - SG_ Byte5_Data_795 : 47|8@0+ (1,0) [0|0] "" AMP - SG_ Byte6_Data_795 : 55|8@0+ (1,0) [0|0] "" AMP - SG_ Byte7_Data_795 : 63|8@0+ (1,0) [0|0] "" AMP - -BO_ 1173 TP_CLU_CD_HU: 8 CLU - SG_ Byte0_TCP_495 : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_495 : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_495 : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_495 : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_495 : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_495 : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_495 : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_495 : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 405 HU_CLU_PE_03: 8 H_U - SG_ HU_IntegPresetNum : 7|8@0+ (1,0) [0|0] "" AMP,CLU,HUD - SG_ Radio_Area : 10|8@0+ (1,0) [0|0] "" CLU - SG_ DMB_PresetNo : 29|5@0+ (1,0) [0|0] "" CLU - SG_ RADIO_PresetNo : 18|5@0+ (1,0) [0|0] "" CLU - SG_ HU_Opstate_DIS2 : 38|7@0+ (1,0) [0|0] "" AMP,CLU,HUD - -BO_ 1168 TP_HU_USB_CLU: 8 H_U - SG_ Byte0_TCP_490 : 7|8@0+ (1,0) [0|0] "" CLU - SG_ Byte1_Data_490 : 15|8@0+ (1,0) [0|0] "" CLU - SG_ Byte2_Data_490 : 23|8@0+ (1,0) [0|0] "" CLU - SG_ Byte3_Data_490 : 31|8@0+ (1,0) [0|0] "" CLU - SG_ Byte4_Data_490 : 39|8@0+ (1,0) [0|0] "" CLU - SG_ Byte5_Data_490 : 47|8@0+ (1,0) [0|0] "" CLU - SG_ Byte6_Data_490 : 55|8@0+ (1,0) [0|0] "" CLU - SG_ Byte7_Data_490 : 63|8@0+ (1,0) [0|0] "" CLU - -BO_ 1936 TP_HU_All_Req: 8 H_U - SG_ Byte0_TCP_790 : 7|8@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CLU,CUBIS,DATC,EDT,FHCU,HUD,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,SWRC,TMU - SG_ Byte1_Data_790 : 15|8@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CLU,CUBIS,DATC,EDT,FHCU,HUD,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,SWRC,TMU - SG_ Byte2_Data_790 : 23|8@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CLU,CUBIS,DATC,EDT,FHCU,HUD,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,SWRC,TMU - SG_ Byte3_Data_790 : 31|8@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CLU,CUBIS,DATC,EDT,FHCU,HUD,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,SWRC,TMU - SG_ Byte4_Data_790 : 39|8@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CLU,CUBIS,DATC,EDT,FHCU,HUD,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,SWRC,TMU - SG_ Byte5_Data_790 : 47|8@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CLU,CUBIS,DATC,EDT,FHCU,HUD,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,SWRC,TMU - SG_ Byte6_Data_790 : 55|8@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CLU,CUBIS,DATC,EDT,FHCU,HUD,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,SWRC,TMU - SG_ Byte7_Data_790 : 63|8@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CGW,CLOCK,CLU,CUBIS,DATC,EDT,FHCU,HUD,IBOX,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,SWRC,TMU - -BO_ 1167 TP_HU_Ipod_CLU: 8 H_U - SG_ Byte0_TCP_48F : 7|8@0+ (1,0) [0|0] "" CLU - SG_ Byte1_Data_48F : 15|8@0+ (1,0) [0|0] "" CLU - SG_ Byte2_Data_48F : 23|8@0+ (1,0) [0|0] "" CLU - SG_ Byte3_Data_48F : 31|8@0+ (1,0) [0|0] "" CLU - SG_ Byte4_Data_48F : 39|8@0+ (1,0) [0|0] "" CLU - SG_ Byte5_Data_48F : 47|8@0+ (1,0) [0|0] "" CLU - SG_ Byte6_Data_48F : 55|8@0+ (1,0) [0|0] "" CLU - SG_ Byte7_Data_48F : 63|8@0+ (1,0) [0|0] "" CLU - -BO_ 1166 TP_HU_DVD_CLU: 8 H_U - SG_ Byte0_TCP_48E : 7|8@0+ (1,0) [0|0] "" CLU - SG_ Byte1_Data_48E : 15|8@0+ (1,0) [0|0] "" CLU - SG_ Byte2_Data_48E : 23|8@0+ (1,0) [0|0] "" CLU - SG_ Byte3_Data_48E : 31|8@0+ (1,0) [0|0] "" CLU - SG_ Byte4_Data_48E : 39|8@0+ (1,0) [0|0] "" CLU - SG_ Byte5_Data_48E : 47|8@0+ (1,0) [0|0] "" CLU - SG_ Byte6_Data_48E : 55|8@0+ (1,0) [0|0] "" CLU - SG_ Byte7_Data_48E : 63|8@0+ (1,0) [0|0] "" CLU - -BO_ 1165 TP_HU_CD_CLU: 8 H_U - SG_ Byte0_TCP_48D : 7|8@0+ (1,0) [0|0] "" CLU - SG_ Byte1_Data_48D : 15|8@0+ (1,0) [0|0] "" CLU - SG_ Byte2_Data_48D : 23|8@0+ (1,0) [0|0] "" CLU - SG_ Byte3_Data_48D : 31|8@0+ (1,0) [0|0] "" CLU - SG_ Byte4_Data_48D : 39|8@0+ (1,0) [0|0] "" CLU - SG_ Byte5_Data_48D : 47|8@0+ (1,0) [0|0] "" CLU - SG_ Byte6_Data_48D : 55|8@0+ (1,0) [0|0] "" CLU - SG_ Byte7_Data_48D : 63|8@0+ (1,0) [0|0] "" CLU - -BO_ 1164 TP_CLU_NAVI_HU: 8 CLU - SG_ Byte0_TCP_48C : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_48C : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_48C : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_48C : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_48C : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_48C : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_48C : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_48C : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 139 AMP_HU_E_12: 8 AMP - SG_ AMP_Beep2VolumeState : 7|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_Beep2FrequencyState : 15|16@0+ (1,0) [0|0] "" H_U - SG_ AMP_Beep2OutputMaskState : 31|16@0+ (1,0) [0|0] "" H_U - SG_ AMP_Beep2DOnState : 47|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_Beep2DOffState : 55|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_Beep2NOfCycleState : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 138 AMP_HU_E_11: 8 AMP - SG_ AMP_Beep1VolumeState : 7|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_Beep1FrequencyState : 15|16@0+ (1,0) [0|0] "" H_U - SG_ AMP_Beep1OutputMaskState : 31|16@0+ (1,0) [0|0] "" H_U - SG_ AMP_Beep1DOnState : 47|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_Beep1DOffState : 55|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_Beep1NOfCycleState : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 137 AMP_HU_E_10: 8 AMP - SG_ AMP_MTSOutputMaskSupport : 1|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_MTSMuteMaskSupport : 5|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_HFOutputMaskSupport : 9|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_HFMuteMaskSupport : 13|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_NaviOutputMaskSupport : 17|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_NaviMuteMaskSupport : 21|2@0+ (1,0) [0|0] "" H_U - -BO_ 1928 TP_HU_PhyRes: 8 H_U - SG_ Byte0_TCP_788 : 7|8@0+ (1,0) [0|0] "" EDT - SG_ Byte1_Data_788 : 15|8@0+ (1,0) [0|0] "" EDT - SG_ Byte2_Data_788 : 23|8@0+ (1,0) [0|0] "" EDT - SG_ Byte3_Data_788 : 31|8@0+ (1,0) [0|0] "" EDT - SG_ Byte4_Data_788 : 39|8@0+ (1,0) [0|0] "" EDT - SG_ Byte5_Data_788 : 47|8@0+ (1,0) [0|0] "" EDT - SG_ Byte6_Data_788 : 55|8@0+ (1,0) [0|0] "" EDT - SG_ Byte7_Data_788 : 63|8@0+ (1,0) [0|0] "" EDT - -BO_ 136 AMP_HU_E_09: 8 AMP - SG_ AMP_MaxBeep2VolumeState : 7|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_MaxBeep2Freq_State : 15|16@0+ (1,0) [0|0] "" H_U - SG_ AMP_Beep2OutputMaskSup : 33|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_MaxBeep2DOnState : 47|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_MaxBeep2DOffState : 55|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_MaxBeep2NOfCycleState : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 135 AMP_HU_E_08: 8 AMP - SG_ AMP_MaxBeep1VolumeState : 7|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_MaxBeep1Freq_State : 15|16@0+ (1,0) [0|0] "" H_U - SG_ AMP_Beep1OutputMaskSup : 33|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_MaxBeep1DOnState : 47|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_MaxBeep1DOffState : 55|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_MaxBeep1NOfCycleState : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 134 AMP_HU_E_07: 8 AMP - SG_ ASD_SetValue : 2|3@0+ (1,0) [0|0] "" H_U,IBOX - SG_ ASD_Version : 15|8@0+ (1,0) [0|0] "" H_U,IBOX - -BO_ 1157 TP_HU_CLU_HF: 8 H_U - SG_ Byte0_TCP_485 : 7|8@0+ (1,0) [0|0] "" CLU - SG_ Byte1_Data_485 : 15|8@0+ (1,0) [0|0] "" CLU - SG_ Byte2_Data_485 : 23|8@0+ (1,0) [0|0] "" CLU - SG_ Byte3_Data_485 : 31|8@0+ (1,0) [0|0] "" CLU - SG_ Byte4_Data_485 : 39|8@0+ (1,0) [0|0] "" CLU - SG_ Byte5_Data_485 : 47|8@0+ (1,0) [0|0] "" CLU - SG_ Byte6_Data_485 : 55|8@0+ (1,0) [0|0] "" CLU - SG_ Byte7_Data_485 : 63|8@0+ (1,0) [0|0] "" CLU - -BO_ 133 AMP_HU_E_06: 8 AMP - SG_ AMP_MaxVolumeStep : 7|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_MaxBalanceStep : 15|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_MaxFadeStep : 23|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_MaxBassStep : 31|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_MaxMidStep : 39|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_MaxTrebleStep : 47|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_ASDMajorVer : 55|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_ASDMinorVer : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 389 AMP_HU_PE_05: 8 AMP - SG_ AMP_EngOrderC2Setting : 7|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_EngOrderC4Setting : 15|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_EngOrderC6Setting : 23|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_APSBand0Setting : 31|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_APSBand1Setting : 39|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_APSBand2Setting : 47|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_APSBand3Setting : 55|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_APSBand4Setting : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 132 AMP_HU_E_05: 8 AMP - SG_ AMP_HFVolumeState : 7|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_HFAudioCutState : 15|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_HFOutputMaskState : 23|16@0+ (1,0) [0|0] "" H_U - SG_ AMP_HFMuteMaskState : 39|16@0+ (1,0) [0|0] "" H_U - SG_ AMP_MaxHFVolumeState : 55|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_MaxHFAudioCutState : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 388 AMP_HU_PE_04: 8 AMP - SG_ AMP_PESSModeState : 1|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_PESSDesignSetting : 4|3@0+ (1,0) [0|0] "" H_U - SG_ AMP_PESSAPSSetting : 7|3@0+ (1,0) [0|0] "" H_U - SG_ AMP_PESSVolumeSetting : 15|8@0+ (1,0) [0|0] "" H_U - -BO_ 1156 TP_CLU_HF_HU: 8 CLU - SG_ Byte0_TCP_484 : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_484 : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_484 : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_484 : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_484 : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_484 : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_484 : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_484 : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 131 AMP_HU_E_04: 8 AMP - SG_ AMP_MTSVolumeState : 7|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_MTSAudioCutState : 15|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_MTSOutputMaskState : 23|16@0+ (1,0) [0|0] "" H_U - SG_ AMP_MTSMuteMaskState : 39|16@0+ (1,0) [0|0] "" H_U - SG_ AMP_MaxMTSVolumeState : 55|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_MaxMTSAudioCutState : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 387 AMP_HU_PE_03: 8 AMP - SG_ AMP_MainVolumeSetting : 7|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_BalanceSetting : 15|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_FadeSetting : 23|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_BassSetting : 31|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_MidSetting : 39|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_TrebleSetting : 47|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_VehicleSpeedamp : 55|8@0+ (1,0) [0|0] "" H_U - -BO_ 130 AMP_HU_E_03: 8 AMP - SG_ AMP_NaviVolumeState : 7|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_NaviAudioCutState : 15|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_NaviOutputMaskState : 23|16@0+ (1,0) [0|0] "" H_U - SG_ AMP_NaviMuteMaskState : 39|16@0+ (1,0) [0|0] "" H_U - SG_ AMP_MaxNaviVolumeState : 55|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_MaxNaviAudioCutState : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 129 AMP_HU_E_02: 8 AMP - SG_ AMP_DriveState : 1|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_ConvertibleTopState : 5|2@0+ (1,0) [0|0] "" H_U - -BO_ 385 AMP_HU_PE_02: 8 AMP - SG_ AMP_MuteState : 1|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_RearSpMuteState : 3|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SurroundModeState : 9|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_EQState : 13|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SPDIFMuteSt : 17|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_BeatsModeState : 21|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_DefaultBeep1St : 25|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_DefaultBeep2St : 29|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_AudioSource : 39|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_VIPModeState : 41|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_QLSModeState : 43|2@0+ (1,0) [0|0] "" H_U - -BO_ 128 AMP_HU_E_01: 8 AMP - SG_ AMP_CurrentVehicleID : 7|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_SPDIFModeState : 11|4@0+ (1,0) [0|0] "" H_U - SG_ AMP_MajorVer : 23|8@0+ (1,0) [0|0] "" H_U,MON - SG_ AMP_MinorVer : 31|8@0+ (1,0) [0|0] "" H_U,MON - SG_ AMP_UpdateStartResp : 33|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_UpdateEndResp : 41|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_TuningMajorVer : 55|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_TuningMinorVer : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 384 AMP_HU_PE_01: 8 AMP - SG_ AMP_HFModeState : 1|2@0+ (1,0) [0|0] "" CLU,H_U - SG_ HU_InitInfo : 3|2@0+ (1,0) [0|0] "" CLU,H_U - SG_ AMP_ASDModeState : 6|3@0+ (1,0) [0|0] "" CLU,H_U - SG_ AMP_NaviModeState : 9|2@0+ (1,0) [0|0] "" CLU,H_U - SG_ AMP_SPDIFInfo : 12|3@0+ (1,0) [0|0] "" CLU,H_U - SG_ AMP_MTSModeState : 17|2@0+ (1,0) [0|0] "" CLU,H_U - SG_ AMP_VSCModeState : 25|2@0+ (1,0) [0|0] "" CLU,H_U - SG_ AMP_SDVCStepState : 29|3@0+ (1,0) [0|0] "" CLU,H_U - SG_ AMP_Beep1ModeState : 33|2@0+ (1,0) [0|0] "" CLU,H_U - SG_ AMP_Beep2ModeState : 41|2@0+ (1,0) [0|0] "" CLU,H_U - SG_ AMP_DistrInfoState : 55|8@0+ (1,0) [0|0] "" CLU,H_U - SG_ AMP_INFORM_TO_IPM : 57|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,H_U,IPM - SG_ AMP_SignalDoctorState : 59|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_AutoVolumeState : 61|2@0+ (1,0) [0|0] "" H_U - -BO_ 1408 AMP_HU_P_01: 8 AMP - SG_ AMP_SupportMute : 1|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportHFMode : 3|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportCfgBeep1 : 5|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportCfgBeep2 : 7|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportSpeedAdjust : 9|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportSurroundMode : 11|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportNaviMode : 13|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportMTSMode : 15|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportTopState : 17|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportBothLHDandRHD : 19|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportEQState : 21|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportVehicleID : 23|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportAudioSource : 25|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportSPDIFModeState : 27|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportRearSpMute : 29|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportVEQMode : 31|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_MakerID : 39|8@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportASDMode : 41|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportBeatsMode : 43|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportVIPMode : 45|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportQLS : 47|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportSignalDoctor : 49|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportAutoVolume : 51|2@0+ (1,0) [0|0] "" H_U - SG_ AMP_SupportPESSMode : 53|2@0+ (1,0) [0|0] "" H_U - -BO_ 1920 TP_HU_PhyReq: 8 EDT - SG_ Byte0_TCP_780 : 7|8@0+ (1,0) [0|0] "" H_U - SG_ Byte1_Data_780 : 15|8@0+ (1,0) [0|0] "" H_U - SG_ Byte2_Data_780 : 23|8@0+ (1,0) [0|0] "" H_U - SG_ Byte3_Data_780 : 31|8@0+ (1,0) [0|0] "" H_U - SG_ Byte4_Data_780 : 39|8@0+ (1,0) [0|0] "" H_U - SG_ Byte5_Data_780 : 47|8@0+ (1,0) [0|0] "" H_U - SG_ Byte6_Data_780 : 55|8@0+ (1,0) [0|0] "" H_U - SG_ Byte7_Data_780 : 63|8@0+ (1,0) [0|0] "" H_U - -BO_ 371 HU_TMU_PE_01: 8 H_U - SG_ HU_AliveStatus : 1|2@0+ (1,0) [0|0] "" CLU,CGW,TMU - SG_ HU_DeviceType : 5|4@0+ (1,0) [0|0] "" TMU - SG_ HU_DistanceUnit : 7|2@0+ (1,0) [0|0] "" TMU - SG_ HU_AudAllocStatus : 9|2@0+ (1,0) [0|0] "" TMU - SG_ HU_PowerStatus : 12|3@0+ (1,0) [0|0] "" TMU - SG_ HU_BTCallStatus : 15|3@0+ (1,0) [0|0] "" TMU - SG_ HU_VoiceRecStatus : 17|2@0+ (1,0) [0|0] "" TMU - SG_ HU_LangStatus : 20|3@0+ (1,0) [0|0] "" TMU - -BO_ 369 HU_Car_PE_01: 8 H_U - SG_ HU_VehiclePwr : 3|4@0+ (1,0) [0|0] "" AMP,ASD,AVM,CCP,CLOCK,CLU,CUBIS,DATC,FHCU,IPM,KBD,KMA_TMU,MON,RRC,RSE_L,RSE_R,TMU - -BO_ 1392 HU_TMU_P_01: 8 H_U - SG_ HU_GPS_Signal : 7|64@0+ (1,0) [0|0] "" TMU - -BO_ 112 HU_AMP_E_09: 8 H_U - SG_ AMP_Beep1VolumeStep : 7|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_Beep1Frequency : 15|16@0+ (1,0) [0|0] "" AMP - SG_ AMP_Beep1Ch_OutputMask : 31|16@0+ (1,0) [0|0] "" AMP - SG_ AMP_Beep1DurationOn : 47|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_Beep1DurationOff : 55|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_Beep1NumberOfCycles : 63|8@0+ (1,0) [0|0] "" AMP - -BO_ 1390 GW_CLU_P: 8 CLU - SG_ C_VehicleSpeed : 7|8@0+ (1,0) [0|254] "" H_U,IBOX - SG_ C_Odometer : 15|24@0+ (1,0) [0|999999] "" H_U,IBOX - -BO_ 363 GW_IPM_PE_2: 8 CLU - SG_ C_DRVUnlockState : 1|2@0+ (1,0) [0|0] "" CUBIS,TMU - SG_ C_ASTUnlockState : 3|2@0+ (1,0) [0|0] "" CUBIS,TMU - SG_ C_RLUnlockstate : 5|2@0+ (1,0) [0|0] "" CUBIS,TMU - SG_ C_RRUnlockState : 7|2@0+ (1,0) [0|0] "" CUBIS,TMU - SG_ C_VehicleInfoTMU : 9|2@0+ (1,0) [0|0] "" CUBIS,TMU - SG_ C_Engine_Status : 11|2@0+ (1,0) [0|0] "" CUBIS,TMU - SG_ C_TMULockFeedBack : 23|2@0+ (1,0) [0|0] "" CUBIS,TMU - -BO_ 362 GW_IPM_PE_1: 8 CLU - SG_ C_AV_Tail : 1|2@0+ (1,0) [0|0] "" AMP,CCP,CLOCK,CLU,HUD,H_U,IBOX,RRC,RSE_L - SG_ C_ParkingBrakeSW : 3|2@0+ (1,0) [0|0] "" H_U - SG_ C_RKECMD : 7|4@0+ (1,0) [0|0] "" H_U - SG_ C_BAState : 9|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ C_IGNSW : 14|3@0+ (1,0) [0|0] "" AMP,AVM,CUBIS,EDT,H_U,MON,RRC,SWRC - SG_ C_CountryCfg : 18|3@0+ (1,0) [0|0] "" AVM,H_U - SG_ C_AltL : 25|2@0+ (1,0) [0|0] "" H_U - SG_ C_TailLampActivity : 27|2@0+ (1,0) [0|0] "" AMP,CCP,CLOCK,HUD,H_U,IBOX,RRC,RSE_L,SWRC - SG_ RearSW_RSELockOnOff : 29|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ C_TMULockFeedBack : 31|2@0+ (1,0) [0|0] "" CUBIS,TMU - SG_ C_SMKTeleCrankingState : 33|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ C_SMKTeleCrankingFailRes : 35|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ C_RKECMD_GEN2 : 39|3@0+ (1,0) [0|0] "" H_U,IBOX - SG_ C_Acu_CshAct : 41|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ C_IntTailAct : 43|2@0+ (1,0) [0|0] "" AMP,CCP,CLOCK,CLU,HUD,H_U,IBOX,RRC,RSE_L - SG_ C_PassiveAccessUnlock : 47|3@0+ (1,0) [0|0] "" H_U,IBOX - SG_ Lca_IndLeft : 49|2@0+ (1,0) [0|0] "" H_U - SG_ FL_SndWarn : 51|2@0+ (1,0) [0|0] "" AMP - SG_ FR_SndWarn : 53|2@0+ (1,0) [0|0] "" AMP - SG_ Lca_IndRight : 55|2@0+ (1,0) [0|0] "" H_U - SG_ RCTA_IndLeft : 57|2@0+ (1,0) [0|0] "" H_U - SG_ RL_SndWarn : 59|2@0+ (1,0) [0|0] "" AMP - SG_ RR_SndWarn : 61|2@0+ (1,0) [0|0] "" AMP - SG_ RCTA_IndRight : 63|2@0+ (1,0) [0|0] "" H_U - -BO_ 361 GW_CHASSIS_PE_1: 8 CLU - SG_ C_Inhibit_State : 3|4@0+ (1,0) [0|0] "" AVM,H_U - SG_ C_P_BrakeStatus : 5|2@0+ (1,0) [0|0] "" AVM,H_U - SG_ C_Clu_AltLStatus : 7|2@0+ (1,0) [0|0] "" AVM,H_U - -BO_ 359 GW_WARNING_PE_01: 8 CLU - SG_ Spas_BEEP_Alarm : 3|4@0+ (1,0) [0|0] "" AMP - SG_ Spas_Audio_VolumeDown : 5|2@0+ (1,0) [0|0] "" AMP - SG_ Spas_Spkr_Flh_Alarm : 9|2@0+ (1,0) [0|0] "" AMP,H_U - SG_ Spas_Spkr_Fcnt_Alarm : 11|2@0+ (1,0) [0|0] "" AMP,H_U - SG_ Spas_Spkr_Frh_Alarm : 13|2@0+ (1,0) [0|0] "" AMP,H_U - SG_ Spas_Spkr_Rlh_Alarm : 17|2@0+ (1,0) [0|0] "" AMP,H_U - SG_ Spas_Spkr_Rcnt_Alarm : 19|2@0+ (1,0) [0|0] "" AMP,H_U - SG_ Spas_Spkr_Rrh_Alarm : 21|2@0+ (1,0) [0|0] "" AMP,H_U - SG_ Lkas_SysStatus : 27|4@0+ (1,0) [0|0] "" AMP,H_U - SG_ Lkas_LH_Warning : 29|2@0+ (1,0) [0|0] "" AMP,H_U - SG_ Lkas_RH_Warning : 31|2@0+ (1,0) [0|0] "" AMP,H_U - SG_ Spas_Spkr_Level : 35|3@0+ (1,0) [0|0] "" AMP - SG_ Lkas_Audio_VolumeDown : 37|2@0+ (1,0) [0|0] "" AMP,H_U - SG_ Audio_VolumeDown : 39|2@0+ (1,0) [0|0] "" AMP,H_U - SG_ Pas_BEEP_Alarm : 43|4@0+ (1,0) [0|0] "" AMP - SG_ Pas_Audio_VolumeDown : 45|2@0+ (1,0) [0|0] "" AMP,H_U - SG_ Pas_Spkr_Level : 32|3@0+ (1,0) [0|0] "" AMP - SG_ Pas_Spkr_Flh_Alarm : 49|2@0+ (1,0) [0|0] "" AMP,H_U - SG_ Pas_Spkr_Fcnt_Alarm : 51|2@0+ (1,0) [0|0] "" AMP,H_U - SG_ Pas_Spkr_Frh_Alarm : 53|2@0+ (1,0) [0|0] "" AMP,H_U - SG_ Pas_Spkr_Rlh_Alarm : 57|2@0+ (1,0) [0|0] "" AMP,H_U - SG_ Pas_Spkr_Rcnt_Alarm : 59|2@0+ (1,0) [0|0] "" AMP,H_U - SG_ Pas_Spkr_Rrh_Alarm : 61|2@0+ (1,0) [0|0] "" AMP,H_U - -BO_ 1376 HU_TMU_P_02: 8 H_U - SG_ HU_GPS_Signal2 : 7|8@0+ (2,0) [0|0] "Degree" TMU - SG_ HU_GPS_Signal3 : 9|2@0+ (1,0) [0|0] "" TMU - SG_ HU_GPS_Signal4 : 12|3@0+ (1,0) [0|0] "" TMU - -BO_ 93 DATC_HU_E_SYS: 8 CLU - SG_ DATC_SWVerMajor : 7|8@0+ (1,0) [0|254] "" H_U - SG_ DATC_SWVerMinor : 15|8@0+ (1,0) [0|254] "" H_U - SG_ DATC_CANVerMajor : 23|8@0+ (1,0) [0|254] "" H_U - SG_ DATC_CANVerMinor : 31|8@0+ (1,0) [0|254] "" H_U - -BO_ 344 GW_CLU_PE: 8 CLU - SG_ C_InhibitP : 1|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ C_InhibitR : 3|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ C_InhibitN : 5|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ C_InhibitD : 7|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ C_P_BrakeStatus : 9|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ C_Clu_AltLStatus : 11|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ CF_Clu_LowfuelWarning : 13|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ C_InhibitRMT : 15|2@0+ (1,0) [0|0] "" H_U - SG_ CF_SMKRKECmd : 18|3@0+ (1,0) [0|0] "" H_U - -BO_ 87 HU_E_02: 8 H_U - SG_ NaviValidity : 1|2@0+ (1,0) [0|0] "" CGW,CLU - -BO_ 343 GW_WARNING_PE_02: 8 CLU - SG_ CF_Lkas_TsrSlifOpt : 1|2@0+ (1,0) [0|3] "" H_U - SG_ CF_Lkas_TsrStatus : 3|2@0+ (1,0) [0|3] "" H_U - SG_ CF_Lkas_TsrAddinfo_Disp : 7|2@0+ (1,0) [0|3] "" H_U - SG_ CF_Lkas_TsrSpeed_Display : 15|8@0+ (1,0) [0|255] "" H_U - -BO_ 75 HU_AMP_E_12: 8 H_U - SG_ AMP_EngOrderC2GainSet : 7|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_EngOrderC4GainSet : 15|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_EngOrderC6GainSet : 23|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_APSBand0GainSet : 31|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_APSBand1GainSet : 39|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_APSBand2GainSet : 47|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_APSBand3GainSet : 55|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_APSBand4GainSet : 63|8@0+ (1,0) [0|0] "" AMP - -BO_ 74 HU_AMP_E_11: 8 H_U - SG_ AMP_PESSMode : 1|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_PESSDesignSet : 4|3@0+ (1,0) [0|0] "" AMP - SG_ AMP_PESSAPSSet : 7|3@0+ (1,0) [0|0] "" AMP - SG_ AMP_PESSVolumeSet : 15|8@0+ (1,0) [0|0] "" AMP - -BO_ 1864 TP_AMP_EDT: 8 AMP - SG_ Byte0_TCP_748 : 7|8@0+ (1,0) [0|0] "" EDT - SG_ Byte1_Data_748 : 15|8@0+ (1,0) [0|0] "" EDT - SG_ Byte2_Data_748 : 23|8@0+ (1,0) [0|0] "" EDT - SG_ Byte3_Data_748 : 31|8@0+ (1,0) [0|0] "" EDT - SG_ Byte4_Data_748 : 39|8@0+ (1,0) [0|0] "" EDT - SG_ Byte5_Data_748 : 47|8@0+ (1,0) [0|0] "" EDT - SG_ Byte6_Data_748 : 55|8@0+ (1,0) [0|0] "" EDT - SG_ Byte7_Data_748 : 63|8@0+ (1,0) [0|0] "" EDT - -BO_ 327 TMU_HU_PE_03: 8 TMU - SG_ TMU_TbT_TurnIcon : 7|8@0+ (1,0) [0|0] "" H_U - SG_ TMU_TbT_CountDownBar : 11|4@0+ (1,0) [0|0] "" H_U - SG_ TMU_TbT_Distance_Unit : 13|2@0+ (1,0) [0|0] "" H_U - SG_ TMU_TbT_DestDistance_Unit : 15|2@0+ (1,0) [0|0] "" H_U - SG_ TMU_TbT_DistanceLo : 27|4@0+ (1,0) [0|0] "" H_U - SG_ TMU_TbT_DistanceHi : 23|12@0+ (1,0) [0|0] "" H_U - SG_ TMU_TbT_DestDistanceLo : 43|4@0+ (1,0) [0|0] "" H_U - SG_ TMU_TbT_DestDistanceHi : 39|12@0+ (1,0) [0|0] "" H_U - SG_ TMU_TbT_ExpectRemainHour : 55|8@0+ (1,0) [0|0] "" H_U - SG_ TMU_TbT_ExpectRemainMin : 61|6@0+ (1,0) [0|0] "" H_U - -BO_ 326 TMU_HU_PE_02: 8 TMU - SG_ TMU_CallStatus : 3|4@0+ (1,0) [0|0] "" H_U - SG_ TMU_CallType : 6|3@0+ (1,0) [0|0] "" H_U - SG_ TMU_CDMA_Streng : 11|4@0+ (1,0) [0|0] "" H_U - SG_ TMU_PacketStatus : 13|2@0+ (1,0) [0|0] "" H_U - SG_ TMU_TalkTimeHour : 20|5@0+ (1,0) [0|0] "" H_U - SG_ TMU_TalkTimeMinute : 29|6@0+ (1,0) [0|0] "" H_U - SG_ TMU_TalkTimeSecond : 37|6@0+ (1,0) [0|0] "" H_U - -BO_ 325 TMU_HU_PE_01: 8 TMU - SG_ TMU_AliveStatus : 2|3@0+ (1,0) [0|0] "" H_U - SG_ TMU_AudioStatus : 4|2@0+ (1,0) [0|0] "" H_U - SG_ TMU_UpdateStatus : 7|3@0+ (1,0) [0|0] "" H_U - SG_ TMU_LangStatus : 10|3@0+ (1,0) [0|0] "" H_U - SG_ TMU_VoiceRecStatus : 12|2@0+ (1,0) [0|0] "" H_U - SG_ TMU_MicStatus : 14|2@0+ (1,0) [0|0] "" H_U - SG_ TMU_ServCommuStatus : 19|4@0+ (1,0) [0|0] "" H_U - SG_ TMU_PowerStatus : 21|2@0+ (1,0) [0|0] "" H_U - SG_ TMU_EngineStatus : 23|2@0+ (1,0) [0|0] "" H_U - SG_ TMU_DownProgress : 31|8@0+ (1,0) [0|0] "" H_U - -BO_ 69 TMU_HU_E_04: 8 TMU - SG_ TMU_eCall : 1|2@0+ (1,0) [0|0] "" H_U - -BO_ 67 TMU_GW_E_01: 8 TMU - SG_ C_ReqDrLock : 1|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ C_ReqDrUnlock : 3|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ C_ReqHazard : 5|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ C_ReqHorn : 7|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ C_ReqEngineOperate : 9|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - -BO_ 66 TMU_HU_E_03: 8 TMU - SG_ CDMA_SelfDiag : 1|2@0+ (1,0) [0|0] "" H_U - SG_ CDMA_Antena_SelfDiag : 3|2@0+ (1,0) [0|0] "" H_U - -BO_ 1345 TMU_HU_P_02: 8 TMU - SG_ TMU_SupVoiceTextService : 1|2@0+ (1,0) [0|0] "" H_U - SG_ TMU_SupEcoCoachService : 3|2@0+ (1,0) [0|0] "" H_U - SG_ TMU_SupSongTagService : 5|2@0+ (1,0) [0|0] "" H_U - SG_ TMU_SupContentService : 7|2@0+ (1,0) [0|0] "" H_U - SG_ TMU_MajorVersion : 15|8@0+ (1,0) [0|0] "" H_U - SG_ TMU_MinorVersion : 23|8@0+ (1,0) [0|0] "" H_U - SG_ TMU_DistributeInfo : 27|4@0+ (1,0) [0|0] "" H_U - -BO_ 65 TMU_HU_E_02: 8 TMU - SG_ TMU_BarLevel1 : 7|6@0+ (1,0) [0|0] "" H_U - SG_ TMU_BarLevel2 : 1|6@0+ (1,0) [0|0] "" H_U - SG_ TMU_BarLevel4 : 21|6@0+ (1,0) [0|0] "" H_U - SG_ TMU_BarLevel3 : 11|6@0+ (1,0) [0|0] "" H_U - SG_ TMU_BarLevel5 : 31|6@0+ (1,0) [0|0] "" H_U - SG_ TMU_BarLevel6 : 25|6@0+ (1,0) [0|0] "" H_U - SG_ TMU_BarLevel8 : 45|6@0+ (1,0) [0|0] "" H_U - SG_ TMU_BarLevel7 : 35|6@0+ (1,0) [0|0] "" H_U - SG_ TMU_BarLevel9 : 55|6@0+ (1,0) [0|0] "" H_U - SG_ TMU_BarLevel10 : 63|6@0+ (1,0) [0|0] "" H_U - -BO_ 1344 TMU_HU_P_01: 8 TMU - SG_ TMU_Arrow : 3|2@0+ (1,0) [0|0] "" H_U - SG_ TMU_ReFill_Info : 5|2@0+ (1,0) [0|0] "" H_U - SG_ TMU_AverageMPG : 1|10@0+ (1,0) [0|0] "" H_U - SG_ TMU_TotalMPG : 23|10@0+ (1,0) [0|0] "" H_U - SG_ TMU_RewardStar : 37|14@0+ (1,0) [0|0] "" H_U - -BO_ 64 TMU_HU_E_01: 8 TMU - SG_ TMU_DisMode : 3|4@0+ (1,0) [0|0] "" H_U - SG_ TMU_AudSrcType : 7|4@0+ (1,0) [0|0] "" CLU,DATC,H_U - SG_ TMU_AudReqCmd : 9|2@0+ (1,0) [0|0] "" H_U - SG_ TMU_LangCmd : 12|3@0+ (1,0) [0|0] "" H_U - SG_ TMU_ServReq : 15|3@0+ (1,0) [0|0] "" H_U - SG_ TMU_ErrorEvent : 23|8@0+ (1,0) [0|0] "" H_U - SG_ TMU_BeepCmd : 25|2@0+ (1,0) [0|0] "" H_U - SG_ TMU_eCall : 28|3@0+ (1,0) [0|0] "" H_U - -BO_ 62 HU_Navi_E_00: 8 H_U - SG_ Navi_SLIF_SpdUnit : 1|2@0+ (1,0) [0|0] "" CGW,CLU,HUD - SG_ Navi_SLIF_Frwinfo : 4|3@0+ (1,0) [0|0] "" CGW,CLU,HUD - SG_ Navi_SLIF_LinkClass : 7|3@0+ (1,0) [0|0] "" CGW,CLU,HUD - SG_ Navi_SLIF_SpdLimit : 15|8@0+ (1,0) [1|254] "" CGW,CLU,HUD - SG_ Navi_SLIFMapSource : 29|4@0+ (1,0) [0|8] "" CGW,CLU,HUD - SG_ Navi_SLIF_CountryCode : 23|10@0+ (1,0) [0|0] "" CGW,CLU,HUD - -BO_ 52 HU_DATC_E_02: 8 H_U - SG_ HU_DATC_DrTempUpDn : 1|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_DATC_PsTempUpDn : 3|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_DATC_RlTempUpDn : 5|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_DATC_RrTempUpDn : 7|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_DATC_MainBlower : 11|4@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_DATC_SubBlower : 15|4@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_DATC_RearBlower : 19|4@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_DATCRearPsModeSet : 23|4@0+ (1,0) [0|0] "" CGW,CLU - SG_ HU_DATC_FrontModeSet : 27|4@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_DATC_RearModeSet : 31|4@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_DATC_AutoSet : 33|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_DATC_OffReq : 35|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_DATC_IntakeSet : 37|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_DATC_RearOnOffSet : 39|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_DATC_AcSet : 41|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_DATC_AqsSet : 43|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_DATC_FrontDefog : 45|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_DATC_RearDefog : 47|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_DATC_ZoneControl : 49|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ HU_DATC_CO2Set : 51|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ DATC_SmartVentOnOffSet : 53|2@0+ (1,0) [0|0] "" CGW,CLU,DATC,IPM - SG_ DATC_ADSOnOffSet : 55|2@0+ (1,0) [0|0] "" CGW,CLU - SG_ HU_DATC_RearAutoDisp : 57|2@0+ (1,0) [0|0] "" CGW,CLU - SG_ HU_DATC_RearOffDisp : 59|2@0+ (1,0) [0|0] "" CGW,CLU - -BO_ 308 DATC_PE_05: 8 CLU - SG_ DATC_PwrInfo : 3|4@0+ (1,0) [0|0] "" AMP,AVM,CUBIS,H_U,MON - SG_ DATC_AltL : 5|2@0+ (1,0) [0|0] "" H_U,MON - SG_ DATC_CarInfo : 7|2@0+ (1,0) [0|0] "" H_U - SG_ DATC_ParkingBrake : 9|2@0+ (1,0) [0|0] "" H_U - SG_ DATC_LowFuelWarn : 11|2@0+ (1,0) [0|0] "" H_U - SG_ DATC_Rear_Off_Disp : 13|2@0+ (1,0) [0|0] "" H_U,MON - SG_ DATC_Rear_AutoDisp : 15|2@0+ (1,0) [0|0] "" H_U,MON - SG_ DATC_Rear_BlowerDisp : 19|4@0+ (1,0) [0|0] "" H_U,MON - SG_ DATC_DrSeatWarmerDisp : 22|3@0+ (1,0) [0|0] "" H_U,MON - SG_ DATC_SyncDisp : 27|4@0+ (1,0) [0|0] "" H_U,MON - SG_ DATC_RearDispCtrl : 31|4@0+ (1,0) [0|0] "" H_U,MON - SG_ DATC_RearDrModeDisp : 35|4@0+ (1,0) [0|0] "" H_U - SG_ DATC_PsSeatWarmerDisp : 38|3@0+ (1,0) [0|0] "" H_U,MON - SG_ DATC_DrVentSeatDisp : 42|3@0+ (1,0) [0|0] "" H_U,MON - SG_ DATC_PSVentSeatDisp : 46|3@0+ (1,0) [0|0] "" H_U,MON - SG_ DATC_RrDefLed : 49|2@0+ (1,0) [0|0] "" H_U,MON - SG_ DATC_SmartVentOnOffStatus : 51|2@0+ (1,0) [0|0] "" H_U - SG_ DATC_ADSOnOffStatus : 53|2@0+ (1,0) [0|0] "" H_U - SG_ DATC_AcDisp_OSD : 55|2@0+ (1,0) [0|0] "" H_U - SG_ DATC_PsModeDisp_OSD : 59|4@0+ (1,0) [0|0] "" H_U - SG_ DATC_ModeDisp_OSD : 63|4@0+ (1,0) [0|0] "" H_U - -BO_ 307 DATC_PE_04: 8 CLU - SG_ DATC_DiagMode : 1|2@0+ (1,0) [0|0] "" H_U,IBOX,MON - SG_ DATC_Rear_ChangeReqDisp : 3|2@0+ (1,0) [0|0] "" H_U,IBOX,MON - SG_ DATC_Rear_ClimateScnDisp : 5|2@0+ (1,0) [0|0] "" H_U,IBOX,MON - SG_ DATC_CO2OnOffStatus : 7|2@0+ (1,0) [0|0] "" H_U - SG_ DATC_SelfDiagDisp : 15|8@0+ (1,0) [0|0] "" H_U,IBOX,MON - SG_ DATC_RearBlwDisp_OSD : 19|4@0+ (1,0) [0|0] "" H_U - SG_ DATC_AqsLevelOut : 23|4@0+ (1,0) [0|0] "" H_U,IBOX,MON - SG_ DATC_RearModeDisp : 27|4@0+ (1,0) [0|0] "" H_U - SG_ DATC_RearPsModeDisp : 31|4@0+ (1,0) [0|0] "" H_U - SG_ DATC_FrontBlwDisp_Ps : 35|4@0+ (1,0) [0|0] "" H_U - SG_ DATC_AutoDisp_Ps : 39|2@0+ (1,0) [0|0] "" H_U - SG_ DATC_RearModeDisp_OSD : 43|4@0+ (1,0) [0|0] "" H_U - SG_ DATC_RearPSModeDisp_OSD : 47|4@0+ (1,0) [0|0] "" H_U - SG_ DATC_FrontBlwDisp_OSD : 51|4@0+ (1,0) [0|0] "" H_U - SG_ DATC_FrontBlwDispPs_OSD : 55|4@0+ (1,0) [0|0] "" H_U - SG_ DATC_Variant : 63|8@0+ (1,0) [0|0] "" H_U,IBOX,MON - -BO_ 306 DATC_PE_03: 8 CLU - SG_ DATC_ModeDisp : 3|4@0+ (1,0) [0|0] "" H_U,IBOX - SG_ DATC_TempUnit : 5|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ DATC_AutoDisp : 9|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ DATC_IntakeDisp : 11|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ DATC_ChangeReqDisp : 13|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ DATC_AcDisp : 17|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ DATC_AqsDisp : 19|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ DATC_ClimateScnDisp : 21|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ DATC_DualDisp : 25|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ DATC_OffDisp : 27|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ DATC_OpSts : 30|3@0+ (1,0) [0|0] "" H_U,IBOX - SG_ DATC_RearManual : 33|2@0+ (1,0) [0|0] "" H_U,MON - SG_ DATC_FrDefLed : 37|2@0+ (1,0) [0|0] "" H_U - SG_ DATC_SmartVentDisp : 39|2@0+ (1,0) [0|0] "" H_U - SG_ DATC_AutoDefogBlink : 41|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ DATC_ADSDisp : 43|2@0+ (1,0) [0|0] "" H_U - SG_ DATC_IonClean : 45|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ DATC_CO2Warning : 47|2@0+ (1,0) [0|0] "" H_U,IBOX - SG_ DATC_SubBlowerDisp : 51|4@0+ (1,0) [0|0] "" H_U,MON - SG_ DATC_BeepReq : 55|4@0+ (1,0) [0|0] "" H_U,KBD,MON - SG_ DATC_MainBlowerDisp : 59|4@0+ (1,0) [0|0] "" H_U,IBOX - SG_ DATC_PsModeDisp : 63|4@0+ (1,0) [0|0] "" H_U,IBOX - -BO_ 1329 DATC_P_02: 8 CLU - SG_ DATC_AmbientTemp_C : 7|8@0+ (1,0) [0|0] "" H_U,MON - SG_ DATC_AmbientTemp_F : 23|8@0+ (1,0) [0|0] "" H_U,MON - -BO_ 305 DATC_PE_02: 8 CLU - SG_ DATC_DrTempDispC : 7|8@0+ (0.5,14) [15|32] "C" H_U,IBOX,MON - SG_ DATC_Rear_DrTempDispC : 15|8@0+ (0.5,14) [15|32] "C" H_U,IBOX,MON - SG_ DATC_DrTempDispF : 23|8@0+ (1,56) [58|90] "F" H_U,IBOX,MON - SG_ DATC_Rear_DrTempDispF : 31|8@0+ (1,56) [58|90] "F" H_U,IBOX,MON - SG_ DATC_PsTempDispC : 39|8@0+ (0.5,14) [15|32] "C" H_U,IBOX,MON - SG_ Datc_RearPsTempDispC : 47|8@0+ (0.5,14) [15|32] "C" H_U,IBOX,MON - SG_ DATC_PsTempDispF : 55|8@0+ (1,56) [58|90] "F" H_U,IBOX,MON - SG_ DATC_RearPsTempDispF : 63|8@0+ (1,56) [58|90] "F" H_U,IBOX,MON - -BO_ 304 DATC_PE_01: 8 CLU - SG_ DATC_Type : 7|8@0+ (1,0) [0|0] "" H_U,MON - SG_ DATC_VerMMMajor : 15|8@0+ (1,0) [0|0] "" H_U,MON - SG_ DATC_VerMMMinor : 23|8@0+ (1,0) [0|0] "" H_U,MON - SG_ DATC_VerBDFMajor : 31|8@0+ (1,0) [0|0] "" H_U,MON - SG_ DATC_VerBDMinor : 39|8@0+ (1,0) [0|0] "" H_U,MON - SG_ DATC_VerCSMajor : 47|8@0+ (1,0) [0|0] "" H_U,MON - SG_ DATC_VerCSMinor : 55|8@0+ (1,0) [0|0] "" H_U,MON - -BO_ 291 HU_CLU_PE_07: 8 H_U - SG_ NV_DS_Curve : 3|4@0+ (1,0) [0|0] "" CLU - SG_ NV_DS_Merge : 7|4@0+ (1,0) [0|0] "" CLU - SG_ NV_DS_RailCross : 9|2@0+ (1,0) [0|0] "" CLU - SG_ NV_DS_FallingRocks : 11|2@0+ (1,0) [0|0] "" CLU - SG_ NV_DS_SchoolZone : 13|2@0+ (1,0) [0|0] "" CLU - SG_ NV_DS_AccidentBlack : 15|2@0+ (1,0) [0|0] "" CLU - SG_ NV_DS_SpeedBump : 17|2@0+ (1,0) [0|0] "" CLU - SG_ NV_DS_RoadKill : 19|2@0+ (1,0) [0|0] "" CLU - SG_ NV_DS_Downhill : 21|2@0+ (1,0) [0|0] "" CLU - SG_ NV_DS_Fog : 23|2@0+ (1,0) [0|0] "" CLU - SG_ NV_Display_TG : 31|2@0+ (1,0) [0|0] "" CLU,HUD - SG_ NV_Charge : 39|16@0+ (1,0) [0|0] "" CLU,HUD - SG_ NV_Charge_Unit : 55|8@0+ (1,0) [0|0] "" CLU,HUD - SG_ TBT_BarGraph100Level : 63|8@0+ (1,0) [0|100] "%" CLU,HUD - -BO_ 290 HU_CLU_PE_06: 8 H_U - SG_ NV_SD_SpdLimit2 : 3|4@0+ (10,0) [0|0] "km/h" CLU - SG_ NV_SD_SpdLimit1 : 7|4@0+ (10,0) [0|0] "km/h" CLU - SG_ NV_SD_EtcCam : 11|4@0+ (1,0) [0|0] "" CLU - SG_ NV_SD_SpdLimit3 : 15|4@0+ (10,0) [0|0] "km/h" CLU - SG_ NV_SD_SignCam : 17|2@0+ (1,0) [0|0] "" CLU - SG_ NV_SD_SignOverCam : 19|2@0+ (1,0) [0|0] "" CLU - SG_ NV_SD_MobileCam : 21|2@0+ (1,0) [0|0] "" CLU - SG_ NV_SD_FixedCam : 23|2@0+ (1,0) [0|0] "" CLU - SG_ NV_SD_OverLoadCam : 25|2@0+ (1,0) [0|0] "" CLU - SG_ NV_SD_ParkCam : 27|2@0+ (1,0) [0|0] "" CLU - SG_ NV_SD_CutInCam : 29|2@0+ (1,0) [0|0] "" CLU - SG_ NV_SD_BusOnlyCam : 31|2@0+ (1,0) [0|0] "" CLU - SG_ NV_SD_ShoulderCam : 35|2@0+ (1,0) [0|0] "" CLU - SG_ NV_SD_TrafficCam : 37|2@0+ (1,0) [0|0] "" CLU - SG_ NV_SD_PlateRcgCam : 39|2@0+ (1,0) [0|0] "" CLU - -BO_ 286 HU_CLU_PE_10: 8 H_U - SG_ Navi_TBTInfo : 63|8@0+ (1,0) [0|0] "" CGW,CLU - -BO_ 29 CLU_HU_E_00: 8 CLU - SG_ SYS_CLUVer : 7|16@0+ (1,0) [0|0] "" CUBIS,H_U - SG_ CLU_ClockInfoReq : 17|2@0+ (1,0) [0|0] "" H_U - SG_ CLU_DateInfoReq : 19|2@0+ (1,0) [0|0] "" H_U - -BO_ 27 AMP_HU_E_00: 8 AMP - SG_ SYS_AMPVer : 7|16@0+ (1,0) [0|0] "" H_U - -BO_ 23 HU_IPM_E_00: 8 H_U - SG_ C_ADrLNValueSet : 2|3@0+ (1,0) [0|0] "" DATC,IPM - SG_ C_ADrUNValueSet : 5|3@0+ (1,0) [0|0] "" DATC,IPM - SG_ SYS_Ver_Req : 7|2@0+ (1,0) [0|0] "" AMP,AVM,CLU,CUBIS,DATC,IPM - SG_ C_IMSRValueReq : 9|2@0+ (1,0) [0|0] "" DATC,IPM - SG_ C_PSMNValueSet : 11|2@0+ (1,0) [0|0] "" DATC,IPM - SG_ C_SCMNValueSet : 13|2@0+ (1,0) [0|0] "" DATC,IPM - SG_ C_ADrLURValueReq : 15|2@0+ (1,0) [0|0] "" DATC,IPM - SG_ C_ABuzzerNValueSet : 17|2@0+ (1,0) [0|0] "" DATC,IPM - SG_ C_AlarmRValueReq : 19|2@0+ (1,0) [0|0] "" DATC,IPM - SG_ C_ArmWKeyNValueSet : 21|2@0+ (1,0) [0|0] "" DATC,IPM - SG_ C_TwUnRValueReq : 23|2@0+ (1,0) [0|0] "" DATC,IPM - SG_ C_TwUnNValueSet : 25|2@0+ (1,0) [0|0] "" DATC,IPM - SG_ C_AutoMRFoldRValueReq : 27|2@0+ (1,0) [0|0] "" DATC,IPM - SG_ C_AutoMRFoldNValueSet : 29|2@0+ (1,0) [0|0] "" DATC,IPM - SG_ C_ADrLRValueReq : 31|2@0+ (1,0) [0|0] "" DATC,IPM - SG_ C_ArmWKeyRValueReq : 33|2@0+ (1,0) [0|0] "" DATC,IPM - SG_ C_ABuzzerRValueReq : 35|2@0+ (1,0) [0|0] "" DATC,IPM - SG_ C_ADrURValueReq : 37|2@0+ (1,0) [0|0] "" DATC,IPM - SG_ C_PSMRValueReq : 39|2@0+ (1,0) [0|0] "" DATC,IPM - SG_ C_SCMRValueReq : 47|2@0+ (1,0) [0|0] "" DATC,IPM - -BO_ 277 HU_CLU_PE_02: 8 H_U - SG_ TBT_Display_Type : 7|8@0+ (1,0) [0|0] "" CLU,HUD - SG_ TBT_Side_Street : 15|16@0+ (1,0) [0|0] "" CLU,HUD - SG_ TBT_Direction : 31|8@0+ (1,0) [0|0] "" CLU,HUD - SG_ TBT_Distance_Turn_Point : 39|16@0+ (1,0) [0|0] "m" CLU,HUD - SG_ TBT_Combined_Side_Street : 51|4@0+ (1,0) [0|0] "" CLU,HUD - SG_ TBT_Scale : 55|4@0+ (1,0) [0|0] "" CLU,HUD - SG_ TBT_DistancetoTurnPoint : 59|4@0+ (1,0) [0|0] "times" CLU,HUD - SG_ TBT_Bar_Graph_Level : 63|4@0+ (10,0) [0|100] "" CLU,HUD - -BO_ 276 HU_CLU_PE_01: 8 H_U - SG_ HU_OpState : 6|7@0+ (1,0) [0|0] "" AMP,CLU - SG_ HU_Navi_On_Off : 7|1@0+ (1,0) [0|0] "" CLU,HUD - SG_ HU_Preset_Number : 12|5@0+ (1,1) [1|30] "" AMP,CLU - SG_ HU_Tuner_Area : 15|3@0+ (1,0) [0|0] "" AMP,CLU - SG_ HU_Track_Number : 23|16@0+ (1,0) [0|0] "" CLU - SG_ HU_Play_time_Sec : 39|6@0+ (1,0) [0|0] "" CLU - SG_ HU_Play_time_Min : 33|7@0+ (1,0) [0|0] "" CLU - SG_ HU_Play_time_Hour : 42|6@0+ (1,0) [0|0] "" CLU - SG_ HU_Disc_select_No : 59|4@0+ (1,0) [0|0] "" CLU - SG_ HU_Frequency : 52|9@0+ (1,0) [0|0] "" AMP,CLU - -BO_ 17 HU_AMP_E_10: 8 H_U - SG_ AMP_Beep2VolumeStep : 7|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_Beep2Frequency : 15|16@0+ (1,0) [0|0] "" AMP - SG_ AMP_Beep2Ch_OutputMask : 31|16@0+ (1,0) [0|0] "" AMP - SG_ AMP_Beep2DurationOn : 47|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_Beep2DurationOff : 55|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_Beep2NumberOfCycles : 63|8@0+ (1,0) [0|0] "" AMP - -BO_ 15 HU_AMP_E_08: 8 H_U - SG_ AMP_MainVolumeSet : 7|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_BalanceSet : 15|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_FadeSet : 23|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_BassSet : 31|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_MidSet : 39|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_TrebleSet : 47|8@0+ (1,0) [0|0] "" AMP - -BO_ 14 HU_AMP_E_07: 8 H_U - SG_ AMP_HFVolumeStep : 7|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_HFMainAudioCut : 15|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_HFChannelOutputMask : 23|16@0+ (1,0) [0|0] "" AMP - SG_ AMP_HFChannelMuteMask : 39|16@0+ (1,0) [0|0] "" AMP - -BO_ 13 HU_AMP_E_06: 8 H_U - SG_ AMP_MTSVolumeStep : 7|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_MTSMainAudioCut : 15|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_MTSChannelOutputMask : 23|16@0+ (1,0) [0|0] "" AMP - SG_ AMP_MTSChannelMuteMask : 39|16@0+ (1,0) [0|0] "" AMP - -BO_ 12 HU_AMP_E_05: 8 H_U - SG_ AMP_NaviVolumeStep : 7|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_NaviMainAudioCut : 15|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_NaviChannelOutputMask : 23|16@0+ (1,0) [0|0] "" AMP - SG_ AMP_NaviChannelMuteMask : 39|16@0+ (1,0) [0|0] "" AMP - -BO_ 11 HU_AMP_E_04: 8 H_U - SG_ AMP_Drive : 1|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_ConvertibleTop : 5|2@0+ (1,0) [0|0] "" AMP - -BO_ 10 HU_AMP_E_03: 8 H_U - SG_ AMP_CrtVehicleID : 7|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_SPDIFMode : 11|4@0+ (1,0) [0|0] "" AMP - SG_ AMP_VersionReq : 17|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_UpdateStart : 25|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_UpdateEnd : 33|2@0+ (1,0) [0|0] "" AMP - -BO_ 9 HU_AMP_E_02: 8 H_U - SG_ AMP_Mute : 1|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_RearSpMute : 3|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_SurroundMode : 5|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_VEQMode : 7|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_AudioMode : 15|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_EQ : 17|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_Reset : 19|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_SPDIFMute : 21|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_DefaultBeep1 : 25|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_DefaultBeep2 : 29|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_BeatsMode : 33|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_VIPMode : 35|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_QLSMode : 37|2@0+ (1,0) [0|0] "" AMP - -BO_ 1288 HU_CLU_P_02: 8 H_U - SG_ NV_TIME_TYPE : 3|4@0+ (1,0) [0|0] "" CLU - SG_ NV_Hour : 15|8@0+ (1,0) [0|0] "" CLU - SG_ NV_Min : 23|8@0+ (1,0) [0|0] "" CLU - -BO_ 8 HU_AMP_E_01: 8 H_U - SG_ AMP_HFMode : 1|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_NaviMode : 3|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_MTSMode : 5|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_VSCMode : 7|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_Beep1Mode : 9|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_Beep2Mode : 11|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_SDVCStep : 14|3@0+ (1,0) [0|0] "" AMP - SG_ AMP_ASDMode : 18|3@0+ (1,0) [0|0] "" AMP - SG_ AMP_SignalDoctor : 20|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_AutoVolume : 22|2@0+ (1,0) [0|0] "" AMP - -BO_ 1287 HU_CLU_P_01: 8 H_U - SG_ NV_DistToTurn_F1 : 3|4@0+ (1,0) [0|0] "" CLU - SG_ NV_DistToTurn_Unit : 7|4@0+ (1,0) [0|0] "" CLU - SG_ NV_DistToTurn_F3 : 11|4@0+ (1,0) [0|0] "" CLU - SG_ NV_DistToTurn_F2 : 15|4@0+ (1,0) [0|0] "" CLU - SG_ NV_DistToTurn_I1 : 23|16@0+ (1,0) [0|0] "" CLU - SG_ NV_DistToTurn_I2 : 39|16@0+ (1,0) [0|0] "" CLU - SG_ NV_DistToTurn_I3 : 55|16@0+ (1,0) [0|0] "" CLU - -BO_ 1286 HU_CLU_P_00: 8 H_U - SG_ NV_EstDist_F : 3|4@0+ (1,0) [0|0] "" CLU,HUD - SG_ NV_EstDist_Unit : 7|4@0+ (1,0) [0|0] "" CLU,HUD - SG_ NV_EstHour : 15|8@0+ (1,0) [0|0] "" CLU,HUD - SG_ NV_EstMin : 23|8@0+ (1,0) [0|0] "" CLU,HUD - SG_ NV_Azimuth : 31|8@0+ (1,0) [0|0] "" CLU,HUD - SG_ NV_EstDist_I : 39|16@0+ (1,0) [0|0] "" CLU,HUD - SG_ NV_EstimTimeType : 49|2@0+ (1,0) [0|0] "" CGW,CLU,HUD - SG_ NV_EstimTimeFormat : 51|2@0+ (1,0) [0|0] "" CGW,CLU,HUD - -BO_ 1284 HU_AMP_P_01: 8 H_U - SG_ HU_VehicleSpeed : 7|8@0+ (1,0) [0|0] "" AMP - SG_ AMP_SetMaxMainVolStep : 9|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_LKASWarningOn : 21|2@0+ (1,0) [0|0] "" AMP - SG_ AMP_BSDWarningOn : 23|2@0+ (1,0) [0|0] "" AMP - -BO_ 256 HU_MON_PE_01: 8 H_U - SG_ HU_Type : 7|8@0+ (1,0) [0|0] "" AMP,CGW,CLU,HUD,KMA_TMU - SG_ HU_VerMajor : 15|8@0+ (1,0) [0|0] "" AMP,CLU,KMA_TMU,MON - SG_ HU_VerMinor : 23|8@0+ (1,0) [0|0] "" AMP,CLU,KMA_TMU,MON - SG_ HU_DistributeInfo : 31|8@0+ (1,0) [0|0] "" AMP,CGW,CLU,KMA_TMU,MON,RRC - SG_ HU_SubVerMajor : 39|8@0+ (1,0) [0|0] "" AMP,MON - SG_ HU_SubVerMinor : 47|8@0+ (1,0) [0|0] "" AMP,MON - SG_ HU_SDARSVersion : 55|8@0+ (1,0) [0|0] "" AMP,MON - SG_ HU_AdasSupport : 58|3@0+ (1,0) [0|0] "" CGW,CLU - -BO_ 1092 NM_CLOCK: 8 CLOCK - SG_ Destination_CLOCK : 7|8@0+ (1,0) [0|0] "" HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMSleepFlag_CLOCK : 13|2@0+ (1,0) [0|0] "" HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMCommandCode_CLOCK : 10|3@0+ (1,0) [0|0] "" HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - -BO_ 1108 NM_HUD: 8 HUD - SG_ Destination_HUD : 7|8@0+ (1,0) [0|0] "" CLOCK,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMSleepFlag_HUD : 13|2@0+ (1,0) [0|0] "" CLOCK,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMCommandCode_HUD : 10|3@0+ (1,0) [0|0] "" CLOCK,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - -BO_ 1088 NM_H_U: 8 H_U - SG_ Destination_H_U : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMSleepFlag_H_U : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMCommandCode_H_U : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - -BO_ 1091 NM_DATC: 8 DATC - SG_ Destination_DATC : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMSleepFlag_DATC : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMCommandCode_DATC : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - -BO_ 1105 NM_CCP: 8 CCP - SG_ Destination_CCP : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMSleepFlag_CCP : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMCommandCode_CCP : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - -BO_ 1100 NM_KMA_TMU: 8 KMA_TMU - SG_ Destination_KMA_TMU : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMSleepFlag_KMA_TMU : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMCommandCode_KMA_TMU : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - -BO_ 1098 NM_CUBIS: 8 CUBIS - SG_ Destination_CUBIS : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMSleepFlag_CUBIS : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMCommandCode_CUBIS : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - -BO_ 1099 NM_TMU: 8 TMU - SG_ Destination_TMU : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMSleepFlag_TMU : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMCommandCode_TMU : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - -BO_ 1095 NM_IPM: 8 IPM - SG_ Destination_IPM : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMSleepFlag_IPM : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMCommandCode_IPM : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - -BO_ 1107 NM_RSE_R: 8 RSE_R - SG_ Destination_RSE_R : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMSleepFlag_RSE_R : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMCommandCode_RSE_R : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - -BO_ 1093 NM_RRC: 8 RRC - SG_ Destination_RRC : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMSleepFlag_RRC : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMCommandCode_RRC : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - -BO_ 1109 NM_CGW: 8 CGW - SG_ Destination_CGW : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMSleepFlag_CGW : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMCommandCode_CGW : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - -BO_ 1106 NM_RSE_L: 8 RSE_L - SG_ Destination_RSE_L : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMSleepFlag_RSE_L : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMCommandCode_RSE_L : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - -BO_ 1096 NM_AMP: 8 AMP - SG_ Destination_AMP : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMSleepFlag_AMP : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMCommandCode_AMP : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - -BO_ 1103 NM_EDT: 8 EDT - SG_ Destination_EDT : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMSleepFlag_EDT : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMCommandCode_EDT : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - -BO_ 1110 NM_SWRC: 8 SWRC - SG_ Destination_SWRC : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMSleepFlag_SWRC : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMCommandCode_SWRC : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,IBOX,CLU,FHCU,ASD,MON,AVM,KBD - -BO_ 1102 NM_IBOX: 8 IBOX - SG_ Destination_IBOX : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMSleepFlag_IBOX : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,CLU,FHCU,ASD,MON,AVM,KBD - SG_ NMCommandCode_IBOX : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,CLU,FHCU,ASD,MON,AVM,KBD - -BO_ 1101 NM_CLU: 8 CLU - SG_ Destination_CLU : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,FHCU,ASD,MON,AVM,KBD - SG_ NMSleepFlag_CLU : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,FHCU,ASD,MON,AVM,KBD - SG_ NMCommandCode_CLU : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,FHCU,ASD,MON,AVM,KBD - -BO_ 1097 NM_FHCU: 8 FHCU - SG_ Destination_FHCU : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,ASD,MON,AVM,KBD - SG_ NMSleepFlag_FHCU : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,ASD,MON,AVM,KBD - SG_ NMCommandCode_FHCU : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,ASD,MON,AVM,KBD - -BO_ 1094 NM_ASD: 8 ASD - SG_ Destination_ASD : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,MON,AVM,KBD - SG_ NMSleepFlag_ASD : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,MON,AVM,KBD - SG_ NMCommandCode_ASD : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,MON,AVM,KBD - -BO_ 1089 NM_MON: 8 MON - SG_ Destination_MON : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,AVM,KBD - SG_ NMSleepFlag_MON : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,AVM,KBD - SG_ NMCommandCode_MON : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,AVM,KBD - -BO_ 1104 NM_AVM: 8 AVM - SG_ Destination_AVM : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,KBD - SG_ NMSleepFlag_AVM : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,KBD - SG_ NMCommandCode_AVM : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,KBD - -BO_ 1090 NM_KBD: 8 KBD - SG_ Destination_KBD : 7|8@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM - SG_ NMSleepFlag_KBD : 13|2@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM - SG_ NMCommandCode_KBD : 10|3@0+ (1,0) [0|0] "" CLOCK,HUD,H_U,DATC,CCP,KMA_TMU,CUBIS,TMU,IPM,RSE_R,RRC,CGW,RSE_L,AMP,EDT,SWRC,IBOX,CLU,FHCU,ASD,MON,AVM - diff --git a/opendbc/hyundai_i30_2014.dbc b/opendbc/hyundai_i30_2014.dbc deleted file mode 100644 index 3524f9b21a893c..00000000000000 --- a/opendbc/hyundai_i30_2014.dbc +++ /dev/null @@ -1,549 +0,0 @@ -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_ 128 EMS_DCT1: 8 XXX - SG_ PV_AV_CAN : 0|8@1+ (0.3906,0) [0|99.603] "%" XXX - SG_ TQ_STND : 8|6@1+ (10,0) [0|630] "Nm" XXX - SG_ F_N_ENG : 14|1@1+ (1,0) [0|1] "" XXX - SG_ F_SUB_TQI : 15|1@1+ (1,0) [0|1] "" XXX - SG_ N : 16|16@1+ (0.25,0) [0|16383.8] "rpm" XXX - SG_ TQI_ACOR : 32|8@1+ (0.390625,0) [0|99.6094] "%" XXX - SG_ TQFR : 40|8@1+ (0.390625,0) [0|99.6094] "%" XXX - SG_ TQI : 48|8@1+ (0.390625,0) [0|99.6094] "%" XXX - SG_ CF_Ems_Alive : 56|4@1+ (1,0) [0|15] "" XXX - SG_ CF_Ems_ChkSum : 60|4@1+ (1,0) [0|15] "" XXX - - -BO_ 129 EMS_DCT2: 8 XXX - SG_ CR_Ems_SoakTimeExt : 0|6@1+ (5,0) [0|315] "Min" XXX - SG_ BRAKE_ACT : 6|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Ems_EngOperStat : 8|8@1+ (1,0) [0|255] "" XXX - SG_ CR_Ems_IndAirTemp : 16|8@1+ (0.75,-48) [-48|143.25] "" XXX - SG_ CF_Ems_Alive2 : 56|4@1+ (1,0) [0|15] "" XXX - SG_ CF_Ems_ChkSum2 : 60|4@1+ (1,0) [0|15] "" XXX - - -BO_ 160 EngFrzFrm1: 8 XXX - SG_ PID_04h : 0|8@1+ (0.392157,0) [0|100] "%" XXX - SG_ PID_05h : 8|8@1+ (1,-40) [-40|215] "" XXX - SG_ PID_0Ch : 16|16@1+ (0.25,0) [0|16383.8] "rpm" XXX - SG_ PID_0Dh : 32|8@1+ (1,0) [0|255] "km/h" XXX - SG_ PID_11h : 40|8@1+ (0.392157,0) [0|100] "%" XXX - SG_ PID_03h : 48|16@1+ (1,0) [0|65535] "" XXX - - -BO_ 161 EngFrzFrm2: 8 XXX - SG_ PID_06h : 0|8@1+ (0.78125,-100) [-100|99.22] "%" XXX - SG_ PID_07h : 8|8@1+ (0.78125,-100) [-100|99.22] "%" XXX - SG_ PID_08h : 16|8@1+ (0.78125,-100) [-100|99.22] "%" XXX - SG_ PID_09h : 24|8@1+ (0.78125,-100) [-100|99.22] "%" XXX - SG_ PID_0Bh : 32|8@1+ (1,0) [0|255] "kPa" XXX - SG_ PID_23h : 40|16@1+ (10,0) [0|655350] "kPa" XXX - - -BO_ 304 YRS1: 8 XXX - SG_ CR_Yrs_Yr : 0|16@1+ (0.005,-163.84) [-163.84|163.83] "" XXX - SG_ CF_Yrs_SnsStat1 : 16|4@1+ (1,0) [0|15] "" XXX - SG_ CF_Yrs_YrStat : 20|4@1+ (1,0) [0|15] "" XXX - SG_ CR_Yrs_LatAc : 32|16@1+ (0.000127465,-4.17677) [-4.17677|4.17652] "g" XXX - SG_ CR_Yrs_MsgCnt1 : 48|4@1+ (1,0) [0|15] "" XXX - SG_ CF_Yrs_LatAcStat1 : 52|4@1+ (1,0) [0|15] "" XXX - SG_ CR_Yrs_Crc1 : 56|8@1+ (1,0) [0|255] "" XXX - - -BO_ 305 YRS3: 8 XXX - SG_ CR_Yrs_YawAcc : 0|16@1+ (0.125,-4096) [-4096|4095.75] "" XXX - SG_ CF_Yrs_YawAccStat : 20|4@1+ (1,0) [0|15] "" XXX - SG_ CR_Yrs_Ax : 32|16@1+ (0.000127465,-4.17677) [-4.17677|4.17652] "g" XXX - SG_ CR_Yrs_MsgCnt3 : 48|4@1+ (1,0) [0|15] "" XXX - SG_ CF_Yrs_AxStat : 52|4@1+ (1,0) [0|15] "" XXX - SG_ CR_Yrs_Crc3 : 56|8@1+ (1,0) [0|255] "" XXX - - -BO_ 320 YRS2: 8 XXX - SG_ CF_Yrs_McuStat : 0|8@1+ (1,0) [0|255] "" XXX - SG_ CF_Yrs_SnsStat2 : 8|8@1+ (1,0) [0|255] "" XXX - SG_ CF_Yrs_ExtSysStat : 32|8@1+ (1,0) [0|255] "" XXX - SG_ CR_Yrs_Diag : 40|8@1+ (1,0) [0|255] "" XXX - SG_ CR_Yrs_MsgCnt2 : 48|4@1+ (1,0) [0|15] "" XXX - SG_ CF_Yrs_Type : 52|4@1+ (1,0) [0|15] "" XXX - SG_ CR_Yrs_Crc2 : 56|8@1+ (1,0) [0|255] "" XXX - - -BO_ 339 TCS1: 8 XXX - SG_ TCS_REQ : 0|1@1+ (1,0) [0|1] "" XXX - SG_ MSR_C_REQ : 1|1@1+ (1,0) [0|1] "" XXX - SG_ TCS_PAS : 2|1@1+ (1,0) [0|1] "" XXX - SG_ TCS_GSC : 3|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Esc_LimoInfo : 4|2@1+ (1,0) [0|3] "" XXX - SG_ ABS_DIAG : 6|1@1+ (1,0) [0|1] "" XXX - SG_ ABS_DEF : 7|1@1+ (1,0) [0|1] "" XXX - SG_ TCS_DEF : 8|1@1+ (1,0) [0|1] "" XXX - SG_ TCS_CTL : 9|1@1+ (1,0) [0|1] "" XXX - SG_ ABS_ACT : 10|1@1+ (1,0) [0|1] "" XXX - SG_ EBD_DEF : 11|1@1+ (1,0) [0|1] "" XXX - SG_ ESP_PAS : 12|1@1+ (1,0) [0|1] "" XXX - SG_ ESP_DEF : 13|1@1+ (1,0) [0|1] "" XXX - SG_ ESP_CTL : 14|1@1+ (1,0) [0|1] "" XXX - SG_ TCS_MFRN : 15|1@1+ (1,0) [0|1] "" XXX - SG_ DBC_CTL : 16|1@1+ (1,0) [0|1] "" XXX - SG_ DBC_PAS : 17|1@1+ (1,0) [0|1] "" XXX - SG_ DBC_DEF : 18|1@1+ (1,0) [0|1] "" XXX - SG_ HAC_CTL : 19|1@1+ (1,0) [0|1] "" XXX - SG_ HAC_PAS : 20|1@1+ (1,0) [0|1] "" XXX - SG_ HAC_DEF : 21|1@1+ (1,0) [0|1] "" XXX - SG_ ESS_STAT : 22|2@1+ (1,0) [0|3] "" XXX - SG_ TQI_TCS : 24|8@1+ (0.390625,0) [0|99.6094] "%" XXX - SG_ TQI_MSR : 32|8@1+ (0.390625,0) [0|99.6094] "%" XXX - SG_ TQI_SLW_TCS : 40|8@1+ (0.390625,0) [0|99.6094] "%" XXX - SG_ CF_Esc_BrkCtl : 48|1@1+ (1,0) [0|1] "" XXX - SG_ ESC_OFF_STEP : 49|2@1+ (1,0) [0|3] "" XXX - SG_ _4WD_Status : 51|1@1+ (1,0) [0|1] "" XXX - SG_ AliveCounter_TCS1 : 52|4@1+ (1,0) [0|1] "" XXX - SG_ CheckSum_TCS1 : 56|8@1+ (1,0) [0|1] "" XXX - - -BO_ 356 VSM1: 8 XXX - SG_ CR_Esc_StrTqReq : 0|12@1+ (0.01,-20.48) [-20.48|20.47] "Nm" XXX - SG_ CF_Esc_Act : 12|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Esc_CtrMode : 13|3@1+ (1,0) [0|7] "" XXX - SG_ CF_Esc_Def : 16|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Esc_AliveCnt : 48|4@1+ (1,0) [0|15] "" XXX - SG_ CF_Esc_Chksum : 56|8@1+ (1,0) [0|255] "" XXX - - -BO_ 357 VSM2: 8 XXX - SG_ CR_Mdps_StrTq : 0|12@1+ (0.01,-20.48) [-20.48|20.47] "Nm" XXX - SG_ CR_Mdps_OutTq : 12|12@1+ (0.1,-204.8) [-204.8|204.7] "" XXX - SG_ CF_Mdps_Def : 24|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Mdps_SErr : 25|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Mdps_AliveCnt : 48|4@1+ (1,0) [0|15] "" XXX - SG_ CF_Mdps_Chksum : 56|8@1+ (1,0) [0|255] "" XXX - - -BO_ 399 EMS_H2: 8 XXX - SG_ R_TqAcnApvC : 0|8@1+ (0.2,0) [0|51] "Nm" XXX - SG_ R_PAcnC : 8|8@1+ (125,0) [0|31875] "hPa" XXX - SG_ TQI_B : 16|8@1+ (0.390625,0) [0|99.6094] "%" XXX - SG_ SLD_VS : 24|8@1+ (1,0) [0|255] "km/h" XXX - SG_ CF_CdaStat : 32|3@1+ (1,0) [0|7] "" XXX - SG_ CF_Ems_IsgStat : 35|3@1+ (1,0) [0|7] "" XXX - SG_ CF_Ems_OilChg : 38|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Ems_EtcLimpMod : 39|1@1+ (1,0) [0|1] "" XXX - SG_ R_NEngIdlTgC : 40|8@1+ (10,0) [0|2550] "rpm" XXX - SG_ CF_Ems_UpTarGr : 48|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Ems_DownTarGr : 49|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Ems_DesCurGr : 50|4@1+ (1,0) [0|15] "" XXX - SG_ CF_Ems_SldAct : 54|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Ems_SldPosAct : 55|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Ems_HPresStat : 56|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Ems_IsgBuz : 57|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Ems_IdlStpFCO : 58|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Ems_FCopen : 59|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Ems_ActEcoAct : 60|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Ems_EngRunNorm : 61|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Ems_IsgStat2 : 62|2@1+ (2,0) [0|3] "" XXX - - -BO_ 497 TCS5: 8 XXX - SG_ ABS_W_LAMP : 0|1@1+ (1,0) [0|1] "" XXX - SG_ EBD_W_LAMP : 1|1@1+ (1,0) [0|1] "" XXX - SG_ TCS_OFF_LAMP : 2|1@1+ (1,0) [0|1] "" XXX - SG_ TCS_LAMP : 3|2@1+ (1,0) [0|3] "" XXX - SG_ DBC_W_LAMP : 5|1@1+ (1,0) [0|1] "" XXX - SG_ DBC_F_LAMP : 6|2@1+ (1,0) [0|3] "" XXX - SG_ ODOMETER_LEFT : 8|4@1+ (1,0) [0|15] "m" XXX - SG_ ODOMETER_RIGHT : 12|4@1+ (1,0) [0|15] "m" XXX - SG_ WHEEL_FL : 16|12@1+ (0.125,0) [0|511.875] "km/h" XXX - SG_ WHEEL_FR : 28|12@1+ (0.125,0) [0|511.875] "km/h" XXX - SG_ WHEEL_RL : 40|12@1+ (0.125,0) [0|511.875] "km/h" XXX - SG_ WHEEL_RR : 52|12@1+ (0.125,0) [0|511.875] "km/h" XXX - - -BO_ 544 ESP2: 8 XXX - SG_ LAT_ACCEL : 0|11@1+ (0.01,-10.23) [-10.23|10.24] "m/s^2" XXX - SG_ ESP2_AliveCounter_LSB : 11|3@1+ (1,0) [0|7] "" XXX - SG_ LAT_ACCEL_STAT : 14|1@1+ (1,0) [0|1] "" XXX - SG_ LAT_ACCEL_DIAG : 15|1@1+ (1,0) [0|1] "" XXX - SG_ LONG_ACCEL : 16|11@1+ (0.01,-10.23) [-10.23|10.24] "m/s^2" XXX - SG_ ESP2_AliveCounter_MSB : 27|1@1+ (1,0) [0|1] "" XXX - SG_ ESP2_Checksum_LSB : 28|2@1+ (1,0) [0|3] "" XXX - SG_ LONG_ACCEL_STAT : 30|1@1+ (1,0) [0|1] "" XXX - SG_ LONG_ACCEL_DIAG : 31|1@1+ (1,0) [0|1] "" XXX - SG_ CYL_PRES : 32|12@1+ (0.1,0) [0|409.5] "Bar" XXX - SG_ ESP12_Checksum_MSB : 44|2@1+ (1,0) [0|3] "" XXX - SG_ CYL_PRES_STAT : 46|1@1+ (1,0) [0|1] "" XXX - SG_ CYL_PRESS_DIAG : 47|1@1+ (1,0) [0|1] "" XXX - SG_ YAW_RATE : 48|13@1+ (0.01,-40.95) [-40.95|40.96] "" XXX - SG_ CYL_PRES_FLAG : 61|1@1+ (1,0) [0|1] "" XXX - SG_ YAW_RATE_STAT : 62|1@1+ (1,0) [0|1] "" XXX - SG_ YAW_RATE_DIAG : 63|1@1+ (1,0) [0|1] "" XXX - - -BO_ 608 EMS6: 8 XXX - SG_ TQI_MIN : 0|8@1+ (0.390625,0) [0|99.6094] "%" XXX - SG_ TQI : 8|8@1+ (0.390625,0) [0|99.6094] "%" XXX - SG_ TQI_TARGET : 16|8@1+ (0.390625,0) [0|99.6094] "%" XXX - SG_ GLOW_STAT : 24|1@1+ (1,0) [0|1] "" XXX - SG_ CRUISE_LAMP_M : 25|1@1+ (1,0) [0|1] "" XXX - SG_ CRUISE_LAMP_S : 26|1@1+ (1,0) [0|1] "" XXX - SG_ PRE_FUEL_CUT_IN : 27|1@1+ (1,0) [0|1] "" XXX - SG_ ENG_STAT : 28|3@1+ (1,0) [0|7] "" XXX - SG_ SOAK_TIME_ERROR : 31|1@1+ (1,0) [0|1] "" XXX - SG_ SOAK_TIME : 32|8@1+ (1,0) [0|255] "Min" XXX - SG_ TQI_MAX : 40|8@1+ (0.390625,0) [0|99.6094] "%" XXX - SG_ SPK_TIME_CUR : 48|8@1+ (0.375,-35.625) [-35.625|60] "" XXX - SG_ Checksum : 56|4@1+ (1,0) [0|15] "" XXX - SG_ AliveCounter : 60|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Ems_AclAct : 62|2@1+ (1,0) [0|3] "" XXX - - -BO_ 672 EMS5: 8 XXX - SG_ ECGPOvrd : 0|1@1+ (1,0) [0|1] "" XXX - SG_ QECACC : 1|1@1+ (1,0) [0|1] "" XXX - SG_ ECFail : 2|1@1+ (1,0) [0|1] "" XXX - SG_ SwitchOffCondExt : 3|1@1+ (1,0) [0|1] "" XXX - SG_ BLECFail : 4|1@1+ (1,0) [0|1] "" XXX - SG_ AliveCounter : 5|2@1+ (1,0) [0|3] "" XXX - SG_ Byte0Parity : 7|1@1+ (1,0) [0|1] "" XXX - SG_ FA_PV_CAN : 8|8@1+ (0.3906,0) [0|99.2] "%" XXX - SG_ IntAirTemp : 16|8@1+ (0.75,-48) [-48|143.25] "" XXX - SG_ STATE_DC_OBD : 24|7@1+ (1,0) [0|127] "" XXX - SG_ INH_DC_OBD : 31|1@1+ (1,0) [0|1] "" XXX - SG_ CTR_IG_CYC_OBD : 32|16@1+ (1,0) [0|65535] "" XXX - SG_ CTR_CDN_OBD : 48|16@1+ (1,0) [0|65535] "" XXX - - -BO_ 688 SAS1: 8 XXX - SG_ SAS_Angle : 0|16@1+ (0.1,0) [-3276.8|3276.7] "Deg" XXX - SG_ SAS_Speed : 16|8@1+ (4,0) [0|1016] "" XXX - SG_ SAS_Stat : 24|8@1+ (1,0) [0|255] "" XXX - SG_ MsgCount : 32|4@1+ (1,0) [0|15] "" XXX - SG_ CheckSum : 36|4@1+ (1,0) [0|15] "" XXX - - -BO_ 790 EMS1: 8 XXX - SG_ SWI_IGK : 0|1@1+ (1,0) [0|1] "" XXX - SG_ F_N_ENG : 1|1@1+ (1,0) [0|1] "" XXX - SG_ ACK_TCS : 2|1@1+ (1,0) [0|1] "" XXX - SG_ PUC_STAT : 3|1@1+ (1,0) [0|1] "" XXX - SG_ TQ_COR_STAT : 4|2@1+ (1,0) [0|3] "" XXX - SG_ RLY_AC : 6|1@1+ (1,0) [0|1] "" XXX - SG_ F_SUB_TQI : 7|1@1+ (1,0) [0|1] "" XXX - SG_ TQI_ACOR : 8|8@1+ (0.390625,0) [0|99.6094] "%" XXX - SG_ N : 16|16@1+ (0.25,0) [0|16383.8] "rpm" XXX - SG_ TQI : 32|8@1+ (0.390625,0) [0|99.6094] "%" XXX - SG_ TQFR : 40|8@1+ (0.390625,0) [0|99.6094] "%" XXX - SG_ VS : 48|8@1+ (1,0) [0|254] "km/h" XXX - SG_ RATIO_TQI_BAS_MAX_STND : 56|8@1+ (0.0078,0) [0|2] "" XXX - - -BO_ 809 EMS2: 8 XXX - SG_ TQ_STND : 0|6@1+ (10,0) [0|630] "Nm" XXX - SG_ CAN_VERS : 0|6@1+ (1,0) [0|7.7] "" XXX - SG_ CONF_TCU : 0|6@1+ (1,0) [0|63] "" XXX - SG_ OBD_FRF_ACK : 0|6@1+ (1,0) [0|63] "" XXX - SG_ MUL_CODE : 6|2@1+ (1,0) [0|3] "" XXX - SG_ TEMP_ENG : 8|8@1+ (0.75,-48) [-48|143.25] "" XXX - SG_ MAF_FAC_ALTI_MMV : 16|8@1+ (0.00781,0) [0|1.99155] "" XXX - SG_ VB_OFF_ACT : 24|1@1+ (1,0) [0|1] "" XXX - SG_ ACK_ES : 25|1@1+ (1,0) [0|1] "" XXX - SG_ CONF_MIL_FMY : 26|3@1+ (1,0) [0|7] "" XXX - SG_ OD_OFF_REQ : 29|1@1+ (1,0) [0|1] "" XXX - SG_ ACC_ACT : 30|1@1+ (1,0) [0|1] "" XXX - SG_ CLU_ACK : 31|1@1+ (1,0) [0|1] "" XXX - SG_ BRAKE_ACT : 32|2@1+ (1,0) [0|3] "" XXX - SG_ ENG_CHR : 34|4@1+ (1,0) [0|15] "" XXX - SG_ GP_CTL : 38|2@1+ (1,0) [0|3] "" XXX - SG_ TPS : 40|8@1+ (0.469484,-15.0235) [-15.0235|104.695] "%" XXX - SG_ PV_AV_CAN : 48|8@1+ (0.3906,0) [0|99.603] "%" XXX - SG_ ENG_VOL : 56|8@1+ (0.1,0) [0|25.5] "liter" XXX - - -BO_ 848 FATC: 8 XXX - SG_ CR_Fatc_TqAcnOut : 0|8@1+ (0.2,0) [0|50.8] "Nm" XXX - SG_ CF_Fatc_AcnRqSwi : 8|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Fatc_AcnCltEnRq : 9|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Fatc_EcvFlt : 10|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Fatc_BlwrOn : 11|1@1+ (1,0) [0|1] "" XXX - SG_ CF_FATC_Iden : 12|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Fatc_BlwrMax : 14|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Fatc_EngStartReq : 15|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Fatc_IsgStopReq : 16|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Fatc_CtrInf : 17|3@1+ (1,0) [0|7] "" XXX - SG_ CF_Fatc_MsgCnt : 20|4@1+ (1,0) [0|15] "" XXX - SG_ CR_Fatc_OutTemp : 24|8@1+ (0.5,-40) [-40|60] "" XXX - SG_ CR_Fatc_OutTempSns : 32|8@1+ (0.5,-40) [-40|60] "" XXX - SG_ CF_Fatc_Compload : 40|3@1+ (1,0) [0|7] "" XXX - SG_ CF_Fatc_ActiveEco : 43|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Fatc_AutoActivation : 44|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Fatc_DefSw : 45|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Fatc_PtcRlyStat : 46|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Fatc_ChkSum : 56|8@1+ (1,0) [0|255] "" XXX - - -BO_ 880 TCU3: 8 XXX - SG_ N_TGT_LUP : 0|8@1+ (10,500) [500|3040] "rpm" XXX - SG_ SLOPE_TCU : 8|6@1+ (0.5,-16) [-16|15.5] "%" XXX - SG_ CF_Tcu_InhCda : 14|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Tcu_IsgInhib : 15|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Tcu_BkeOnReq : 16|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Tcu_NCStat : 18|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Tcu_TarGr : 20|4@1+ (1,0) [0|15] "" XXX - SG_ CF_Tcu_ShfPatt : 24|4@1+ (1,0) [0|15] "" XXX - SG_ CF_Tcu_InhVis : 28|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Tcu_PRelReq : 29|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Tcu_ITPhase : 30|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Tcu_ActEcoRdy : 31|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Tcu_TqGrdLim : 32|8@1+ (10,0) [0|2540] "Nm/s" XXX - SG_ CR_Tcu_IsgTgtRPM : 40|8@1+ (20,0) [0|3500] "rpm" XXX - SG_ TQI_TCU_INC : 48|8@1+ (0.390625,0) [0|99.6094] "%" XXX - SG_ CF_Tcu_SbwPInfo : 56|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Tcu_SptRdy : 57|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Tcu_Alive3 : 58|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Tcu_ChkSum3 : 60|4@1+ (1,0) [0|15] "" XXX - - -BO_ 898 EMS9: 8 XXX - SG_ CF_Ems_BrkReq : 0|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Ems_DnShftReq : 1|4@1+ (1,0) [0|14] "" XXX - SG_ CF_Ems_RepModChk : 5|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Ems_AAFOpenReq : 7|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Ems_DecelReq : 8|12@1+ (0.001,-4.094) [-4.094|0] "m/s^2" XXX - SG_ CR_Ems_BstPre : 20|12@1+ (1.322,0) [0|4094] "hPa" XXX - SG_ CR_Ems_EngOilTemp : 32|8@1+ (0.75,-40) [0|254] "" XXX - SG_ CF_Ems_PumpTPres : 40|8@1+ (3.13725,0) [0|800] "kPa" XXX - SG_ CF_Ems_ModeledAmbTemp : 48|8@1+ (0.5,-41) [-40|60] "" XXX - SG_ CF_Ems_OPSFail : 56|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Ems_ECTTRQLIM : 57|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Ems_AliveCounterEMS9 : 58|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Ems_ChecksumEMS9 : 60|4@1+ (1,0) [0|15] "" XXX - - -BO_ 1075 EPB1: 8 XXX - SG_ EPB_I_LAMP : 0|4@1+ (1,0) [0|15] "" XXX - SG_ EPB_F_LAMP : 4|2@1+ (1,0) [0|3] "" XXX - SG_ EPB_ALARM : 6|2@1+ (1,0) [0|3] "" XXX - SG_ EPB_CLU : 8|8@1+ (1,0) [0|255] "" XXX - SG_ EPB_SWITCH : 16|2@1+ (1,0) [0|3] "" XXX - SG_ EPB_RBL : 18|1@1+ (1,0) [0|1] "" XXX - SG_ EPB_STATUS : 19|3@1+ (1,0) [0|7] "" XXX - SG_ EPB_FRC_ERR : 22|2@1+ (1,0) [0|3] "" XXX - SG_ EPB_DBF_STAT : 24|1@1+ (1,0) [0|1] "" XXX - SG_ ESP_ACK : 25|1@1+ (1,0) [0|1] "" XXX - SG_ EPB_DBF_REQ : 26|1@1+ (1,0) [0|1] "" XXX - SG_ EPB_FAIL : 29|3@1+ (1,0) [0|7] "" XXX - SG_ EPB_FORCE : 32|12@1+ (1,-1000) [-1000|3000] "" XXX - SG_ EPB_DBF_DECEL : 48|8@1+ (0.01,0) [0|2.54] "g" XXX - - -BO_ 1087 TCU1: 8 XXX - SG_ ETL_TCU : 0|8@1+ (2,0) [0|508] "Nm" XXX - SG_ CUR_GR : 8|4@1+ (1,0) [0|15] "" XXX - SG_ CF_Tcu_Alive : 12|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Tcu_ChkSum : 14|2@1+ (1,0) [0|3] "" XXX - SG_ VS_TCU : 16|8@1+ (1,0) [0|254] "km/h" XXX - SG_ FAN_CTRL_TCU : 24|2@1+ (1,0) [0|3] "" XXX - SG_ BRAKE_ACT_TCU : 26|2@1+ (1,0) [0|3] "" XXX - SG_ FUEL_CUT_TCU : 28|1@1+ (1,0) [0|1] "" XXX - SG_ INH_FUEL_CUT : 29|1@1+ (1,0) [0|1] "" XXX - SG_ IDLE_UP_TCU : 30|1@1+ (1,0) [0|1] "" XXX - SG_ N_INC_TCU : 31|1@1+ (1,0) [0|1] "" XXX - SG_ SPK_RTD_TCU : 32|8@1+ (0.375,-23.625) [-15|15] "" XXX - SG_ N_TC_RAW : 40|16@1+ (0.25,0) [0|16383.5] "rpm" XXX - SG_ VS_TCU_DECIMAL : 56|8@1+ (0.0078125,0) [0|0.992188] "km/h" XXX - - -BO_ 1088 TCU2: 8 XXX - SG_ ETL_TCU : 0|8@1+ (2,0) [0|508] "Nm" XXX - SG_ CUR_GR : 8|4@1+ (1,0) [0|15] "" XXX - SG_ CF_Tcu_Alive : 12|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Tcu_ChkSum : 14|2@1+ (1,0) [0|3] "" XXX - SG_ VS_TCU : 16|8@1+ (1,0) [0|254] "km/h" XXX - SG_ FAN_CTRL_TCU : 24|2@1+ (1,0) [0|3] "" XXX - SG_ BRAKE_ACT_TCU : 26|2@1+ (1,0) [0|3] "" XXX - SG_ FUEL_CUT_TCU : 28|1@1+ (1,0) [0|1] "" XXX - SG_ INH_FUEL_CUT : 29|1@1+ (1,0) [0|1] "" XXX - SG_ IDLE_UP_TCU : 30|1@1+ (1,0) [0|1] "" XXX - SG_ N_INC_TCU : 31|1@1+ (1,0) [0|1] "" XXX - SG_ SPK_RTD_TCU : 32|8@1+ (0.375,-23.625) [-15|15] "" XXX - SG_ N_TC_RAW : 40|16@1+ (0.25,0) [0|16383.5] "rpm" XXX - SG_ VS_TCU_DECIMAL : 56|8@1+ (0.0078125,0) [0|0.992188] "km/h" XXX - - -BO_ 1200 WHL_SPD: 8 XXX - SG_ WHL_SPD_FL : 0|14@1+ (0.03125,0) [0|511.969] "km/h" XXX - SG_ WHL_SPD_FR : 16|14@1+ (0.03125,0) [0|511.969] "km/h" XXX - SG_ WHL_SPD_RL : 32|14@1+ (0.03125,0) [0|511.969] "km/h" XXX - SG_ WHL_SPD_RR : 48|14@1+ (0.03125,0) [0|511.969] "km/h" XXX - - -BO_ 1201 WHL_PUL: 8 XXX - SG_ WHL_PUL_FL : 0|8@1+ (0.5,0) [0|127.5] "pulse count" XXX - SG_ WHL_PUL_FR : 8|8@1+ (0.5,0) [0|127.5] "pulse count" XXX - SG_ WHL_PUL_RL : 16|8@1+ (0.5,0) [0|127.5] "pulse count" XXX - SG_ WHL_PUL_RR : 24|8@1+ (0.5,0) [0|127.5] "pulse count" XXX - SG_ WHL_DIR_FL : 32|2@1+ (1,0) [0|3] "" XXX - SG_ WHL_DIR_FR : 34|2@1+ (1,0) [0|3] "" XXX - SG_ WHL_DIR_RL : 36|2@1+ (1,0) [0|3] "" XXX - SG_ WHL_DIR_RR : 38|2@1+ (1,0) [0|3] "" XXX - SG_ WHL_PUL_Chksum : 56|8@1+ (1,0) [0|255] "" XXX - - -BO_ 1264 CLU1: 8 XXX - SG_ CF_Clu_CruiseSwState : 0|3@1+ (1,0) [0|7] "" XXX - SG_ CF_Blr_MaxStat : 3|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_SldMainSW : 4|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_ParityBit1 : 5|1@1+ (1,0) [0|1] "pulse count" XXX - SG_ CF_Clu_SPEED_UNIT : 6|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_ParkBrakeSw : 7|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_Vanz : 8|9@1+ (0.5,0) [0|255.5] "km/h or MPH" XXX - SG_ CF_Clu_AliveCounter : 17|7@1+ (1,0) [0|127] "" XXX - SG_ CF_Clu_CruiseSwMain : 24|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_VanzDecimal : 25|2@1+ (1,0) [0|0.375] "" XXX - SG_ VEHICLE_INFO : 27|3@1+ (1,0) [0|7] "" XXX - SG_ CF_Clu_StrRlyState : 30|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_SMKOption : 31|1@1+ (1,0) [0|1] "" XXX - SG_ R_TqAcnOutC : 32|8@1+ (1,0) [0|51] "Nm" XXX - SG_ CF_Clu_Odometer : 40|24@1+ (0.1,0) [0|1.67772e+006] "km" XXX - - -BO_ 1265 CLU3: 8 XXX - SG_ CF_Clu_AcnRqSwi : 0|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_AcnCltEnRq : 1|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_RefDetMod : 2|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_DefoggerRly : 5|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_LowfuelWarn : 16|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Clu_SportsModeSwi : 18|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Clu_ALightStat : 20|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_FrtFog : 21|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_DetentOut : 22|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_HeadLampTail : 23|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_TrailerMode : 24|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_DTE : 25|10@1+ (1,0) [0|1023] "" XXX - SG_ CF_Clu_TripUnit : 35|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Clu_IsaMainSW : 37|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_FlexSteerSW : 40|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_AvsmCur : 41|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_HudSpeedset : 42|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_HudTbtSet : 43|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_HudSccSet : 44|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_HudLdwsSet : 45|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_HudDisSet : 46|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_HudFontSizeSet : 47|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Clu_HudFontColorSet : 49|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Clu_HudBrightSet : 51|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Clu_HudHeightSet : 53|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Clu_CluInfo : 55|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_RheostatLevel : 56|5@1+ (1,0) [0|31] "" XXX - SG_ CF_Clu_DrivinglampStat : 61|3@1+ (1,0) [0|7] "" XXX - - -BO_ 1349 EMS4: 8 XXX - SG_ IMMO_LAMP_STAT : 0|1@1+ (1,0) [0|1] "" XXX - SG_ L_MIL : 1|1@1+ (1,0) [0|1] "" XXX - SG_ IM_STAT : 2|1@1+ (1,0) [0|1] "" XXX - SG_ AMP_CAN : 3|5@1+ (10.7316,458.98) [458.98|791.66] "mmHg" XXX - SG_ FCO : 8|16@1+ (0.128,0) [0|8388.48] "ul" XXX - SG_ VB : 24|8@1+ (0.101563,0) [0|25.8984] "V" XXX - SG_ TEMP_FUEL : 48|8@1+ (0.75,-48) [-48|143.25] "" XXX - SG_ Split_Stat : 56|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Ems_IsaAct : 57|1@1+ (1,0) [0|1] "" XXX - - -BO_ 1435 TCU4: 8 XXX - SG_ CF_TCU_WarnMsg : 0|3@1+ (1,0) [0|7] "" XXX - SG_ CF_TCU_WarnImg : 3|1@1+ (1,0) [0|1] "" XXX - SG_ CF_TCU_WarnSnd : 4|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Tcu_EolStat : 5|1@1+ (1,0) [0|1] "" XXX - SG_ CR_Tcu_GearSelDisp2 : 8|4@1+ (1,0) [0|15] "" XXX - SG_ CF_Tcu_StRelStat : 12|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Tcu_DriWarn1 : 13|3@1+ (1,0) [0|7] "" XXX - SG_ CF_Tcu_DriWarn2 : 16|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Tcu_DrivingModeReq : 18|4@1+ (1,0) [0|0] "" XXX - SG_ CF_Tcu_DrivingModeDisp : 22|4@1+ (1,0) [0|0] "" XXX - SG_ CF_Tcu_SiCluster : 26|5@1+ (1,0) [0|0] "" XXX - SG_ CF_Tcu_DSmode_Inf : 31|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Tcu_Alive4 : 58|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Tcu_ChkSum4 : 60|4@1+ (1,0) [0|15] "" XXX - - -BO_ 1508 MDPS1: 8 XXX - SG_ CF_Mdps_WLmp : 1|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Mdps_ALTRequest : 5|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Mdps_Flex : 8|3@1+ (1,0) [0|7] "" XXX - SG_ CF_Mdps_FlexDisp : 11|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Mdps_CurrMode : 12|2@1+ (1,0) [0|3] "" XXX - - -BO_ 1680 CLU2: 8 XXX - SG_ CF_Clu_IGNSw : 0|3@1+ (1,0) [0|7] "" XXX - SG_ RKE_CMD : 3|3@1+ (1,0) [0|7] "" XXX - SG_ CF_Clu_DrvDrSw : 6|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Clu_DrvKeyLockSw : 8|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_DrvKeyUnlockSw : 9|1@1+ (1,0) [0|1] "" XXX - SG_ PIC_Lock : 10|3@1+ (1,0) [0|7] "" XXX - SG_ PIC_Unlock : 13|3@1+ (1,0) [0|7] "" XXX - SG_ CF_Clu_DrvSeatBeltSw : 16|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Clu_TrunkTgSw : 18|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Clu_AstSeatBeltSw : 20|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Clu_HoodSw : 22|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Clu_TurnSigLh : 24|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_TurnSigRh : 25|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_LdwsLkasSW : 26|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_WiperIntT : 27|3@1+ (1,0) [0|7] "" XXX - SG_ CF_Clu_WiperIntSW : 30|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_WiperLow : 31|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_WiperHigh : 32|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_WiperAuto : 33|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_RainSnsStat : 34|3@1+ (1,0) [0|7] "" XXX - SG_ CF_Clu_HeadLampLow : 37|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_HeadLampHigh : 38|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_AltLStatus : 39|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_EcoDriveInf : 40|3@1+ (1,0) [0|7] "" XXX - SG_ CF_Clu_SwiGearR : 43|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Clu_SWL_Stat : 45|3@1+ (1,0) [0|7] "" XXX - SG_ CF_Clu_ActiveEcoSW : 48|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_HazardSW : 49|1@1+ (1,0) [0|1] "" XXX - SG_ CF_Clu_AliveCnt2 : 50|4@1+ (1,0) [0|15] "" XXX - SG_ CF_Clu_AstDrSw : 54|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Clu_LkasDispMode : 56|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Clu_AutoLightLevel : 58|2@1+ (1,0) [0|3] "" XXX - SG_ CF_Clu_SunRoofOpenState : 60|1@1+ (1,0) [0|1] "" XXX - - diff --git a/opendbc/hyundai_kia_generic.dbc b/opendbc/hyundai_kia_generic.dbc index bb1c06e09c2796..13ee8f3a1a0211 100644 --- a/opendbc/hyundai_kia_generic.dbc +++ b/opendbc/hyundai_kia_generic.dbc @@ -191,8 +191,12 @@ BO_ 916 TCS13: 8 ESC SG_ BrakeLight : 11|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,SCC SG_ DCEnable : 12|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,SCC SG_ AliveCounterTCS : 13|3@1+ (1.0,0.0) [0.0|7.0] "" EMS,SCC - SG_ ACCReqLim : 22|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,SCC - SG_ TQI_ACC : 24|8@1+ (0.390625,0.0) [0.0|99.609375] "%" EMS + SG_ Pre_TCS_CTL : 16|1@1+ (1.0,0.0) [0.0|1.0] "" Vector__XXX + SG_ EBA_ACK : 17|1@1+ (1.0,0.0) [0.0|1.0] "" Vector__XXX + SG_ FCA_ACK : 18|1@1+ (1.0,0.0) [0.0|1.0] "" Vector__XXX + SG_ DF_BF_STAT : 19|2@1+ (1.0,0.0) [0.0|3.0] "" BCW + SG_ SCCReqLim : 21|2@1+ (1.0,0.0) [0.0|3.0] "" SCC + SG_ TQI_SCC : 23|9@1+ (0.390625,0.0) [0.0|199.609375] "%" Vector__XXX SG_ ACCEL_REF_ACC : 32|11@1+ (0.01,-10.23) [-10.23|10.24] "m/s^2" EMS,SCC SG_ ACCEnable : 43|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,SCC SG_ DriverOverride : 45|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,SCC @@ -448,6 +452,7 @@ BO_ 897 MDPS11: 8 MDPS SG_ CF_Mdps_LKAS_FUNC : 58|1@1+ (1.0,0.0) [0.0|1.0] "flag" LDWS_LKAS SG_ CF_Mdps_CurrMode : 59|2@1+ (1.0,0.0) [0.0|3.0] "" LDWS_LKAS SG_ CF_Mdps_Type : 61|2@1+ (1.0,0.0) [0.0|2.0] "" LDWS_LKAS,SPAS + SG_ CF_MDPS_VSM_FUNC : 56|1@0+ (1.0,0.0) [0.0|1.0] "" XXX BO_ 896 DI_BOX13: 8 DI_BOX SG_ CF_DiBox_HPreInjVConfStat : 0|8@1+ (1.0,0.0) [0.0|255.0] "" EMS @@ -792,7 +797,7 @@ BO_ 1362 SNV11: 4 SNV SG_ CF_Snv_IRLampControl : 10|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU,HUD BO_ 593 MDPS12: 8 MDPS - SG_ CR_Mdps_StrColTq : 0|11@1+ (0.0078125,-8.0) [-8.0|7.9921875] "Nm" LDWS_LKAS + SG_ CR_Mdps_StrColTq : 0|11@1+ (1.0,-1024.0) [-1024.0|1024.0] "" LDWS_LKAS SG_ CF_Mdps_Def : 11|1@1+ (1.0,0.0) [0.0|1.0] "" ESC SG_ CF_Mdps_ToiUnavail : 12|1@1+ (1.0,0.0) [0.0|1.0] "" LDWS_LKAS SG_ CF_Mdps_ToiActive : 13|1@1+ (1.0,0.0) [0.0|1.0] "" LDWS_LKAS @@ -961,7 +966,7 @@ BO_ 64 DATC14: 8 DATC SG_ DATC_ADSDisp : 28|2@1+ (1.0,0.0) [0.0|3.0] "" CLU BO_ 832 LKAS11: 8 LDWS_LKAS - SG_ CF_Lkas_Bca_R : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,IBOX,PSB + SG_ CF_Lkas_LdwsActivemode : 0|2@1+ (1,0) [0|3] "" CLU,IBOX,PSB SG_ CF_Lkas_LdwsSysState : 2|4@1+ (1.0,0.0) [0.0|15.0] "" CLU,IBOX,PSB SG_ CF_Lkas_SysWarning : 6|4@1+ (1.0,0.0) [0.0|15.0] "" BCM,CLU SG_ CF_Lkas_LdwsLHWarning : 10|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU,PSB @@ -978,11 +983,11 @@ BO_ 832 LKAS11: 8 LDWS_LKAS SG_ CF_Lkas_FcwSysState : 40|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ CF_Lkas_FcwCollisionWarning : 43|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Lkas_FusionState : 45|2@1+ (1.0,0.0) [0.0|3.0] "" SCC + SG_ CF_Lkas_Unknown1 : 47|1@1+ (1.0,0.0) [0.0|1.0] "" XXX SG_ CF_Lkas_Chksum : 48|8@1+ (1.0,0.0) [0.0|255.0] "" MDPS SG_ CF_Lkas_FcwOpt_USM : 56|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ CF_Lkas_LdwsOpt_USM : 59|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,MDPS - SG_ CF_Lkas_Unknown1 : 47|1@1+ (1,0) [0|3] "" XXX - SG_ CF_Lkas_Unknown2 : 63|2@0+ (1,0) [0|3] "" XXX + SG_ CF_Lkas_Unknown2 : 62|2@1+ (1.0,0.0) [0.0|1.0] "" XXX BO_ 1342 LKAS12: 6 LDWS_LKAS SG_ CF_Lkas_TsrSlifOpt : 10|2@1+ (1.0,0.0) [0.0|3.0] "" CLU @@ -990,6 +995,8 @@ BO_ 1342 LKAS12: 6 LDWS_LKAS SG_ CF_Lkas_TsrSpeed_Display_Clu : 16|8@1+ (1.0,0.0) [0.0|255.0] "" CLU SG_ CF_LkasTsrSpeed_Display_Navi : 24|8@1+ (1.0,0.0) [0.0|255.0] "" BCM,CLU SG_ CF_Lkas_TsrAddinfo_Display : 32|2@1+ (1.0,0.0) [0.0|3.0] "" CLU + SG_ CF_LkasDawStatus : 40|3@1+ (1,0) [0|7] "" CLU + SG_ CF_Lkas_Daw_USM : 39|3@1+ (1,0) [0|7] "" CLU BO_ 1338 TMU_GW_E_01: 8 CLU SG_ CF_Gway_TeleReqDrLock : 0|2@1+ (1.0,0.0) [0.0|3.0] "" BCM @@ -1035,6 +1042,7 @@ BO_ 1322 CLU15: 8 CLU SG_ CF_Clu_HudFontSizeSet : 31|2@1+ (1.0,0.0) [0.0|3.0] "" HUD SG_ CF_Clu_LanguageInfo : 33|5@1+ (1.0,0.0) [0.0|31.0] "" BCM,PGS SG_ CF_Clu_ClusterSound : 38|1@1- (1.0,0.0) [0.0|0.0] "" BCM,CGW,FATC + SG_ CF_Clu_VehicleSpeed2 : 48|8@1+ (1,0) [0|255] "" XXX BO_ 1066 _4WD13: 6 _4WD SG_ _4WD_CURRENT : 0|8@1+ (0.390625,0.0) [-50.0|50.0] "A" TCU @@ -1159,27 +1167,27 @@ BO_ 1314 GW_IPM_PE_1: 8 BCM SG_ C_SMKTeleCrankingFailRes : 34|2@1+ (1.0,0.0) [0.0|3.0] "" CLU BO_ 1057 SCC12: 8 SCC - SG_ CF_VSM_Prefill : 0|1@1+ (1.0,0.0) [0.0|1.0] "" ESC - SG_ CF_VSM_DecCmdAct : 1|1@1+ (1.0,0.0) [0.0|1.0] "" ESC - SG_ CF_VSM_HBACmd : 2|2@1+ (1.0,0.0) [0.0|3.0] "" ESC - SG_ CF_VSM_Warn : 4|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ESC,IAP - SG_ CF_VSM_Stat : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ESC,PSB - SG_ CF_VSM_BeltCmd : 8|3@1+ (1.0,0.0) [0.0|7.0] "" ESC,PSB - SG_ ACCFailInfo : 11|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,CUBIS,ESC,IBOX - SG_ ACCMode : 13|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ESC,IBOX,TCU - SG_ StopReq : 15|1@1+ (1.0,0.0) [0.0|1.0] "" EPB,ESC - SG_ CR_VSM_DecCmd : 16|8@1+ (0.01,0.0) [0.0|2.55] "g" ESC - SG_ aReqMax : 24|11@1+ (0.01,-10.23) [-10.23|10.24] "m/s^2" EMS,ESC,TCU - SG_ TakeOverReq : 35|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,ESC,TCU - SG_ PreFill : 36|1@1+ (1.0,0.0) [0.0|1.0] "" ESC,TCU - SG_ aReqMin : 37|11@1+ (0.01,-10.23) [-10.23|10.24] "m/s^2" EMS,ESC,TCU - SG_ CF_VSM_ConfMode : 48|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ESC - SG_ AEB_Failinfo : 50|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ESC - SG_ AEB_Status : 52|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ESC - SG_ AEB_CmdAct : 54|1@1+ (1.0,0.0) [0.0|1.0] "" ESC - SG_ AEB_StopReq : 55|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,ESC - SG_ CR_VSM_Alive : 56|4@1+ (1.0,0.0) [0.0|15.0] "" ESC,PSB - SG_ CR_VSM_ChkSum : 60|4@1+ (1.0,0.0) [0.0|15.0] "" ESC,PSB + SG_ CF_VSM_Prefill : 0|1@1+ (1,0) [0|1] "" ESC + SG_ CF_VSM_DecCmdAct : 1|1@1+ (1,0) [0|1] "" ESC + SG_ CF_VSM_HBACmd : 2|2@1+ (1,0) [0|3] "" ESC + SG_ CF_VSM_Warn : 4|2@1+ (1,0) [0|3] "" CLU,ESC,IAP + SG_ CF_VSM_Stat : 6|2@1+ (1,0) [0|3] "" CLU,ESC,PSB + SG_ CF_VSM_BeltCmd : 8|3@1+ (1,0) [0|7] "" ESC,PSB + SG_ ACCFailInfo : 11|2@1+ (1,0) [0|3] "" CLU,CUBIS,ESC,IBOX + SG_ ACCMode : 13|2@1+ (1,0) [0|3] "" CLU,ESC,IBOX,TCU + SG_ StopReq : 15|1@1+ (1,0) [0|1] "" EPB,ESC + SG_ CR_VSM_DecCmd : 16|8@1+ (0.01,0) [0|2.55] "g" ESC + SG_ TakeOverReq : 35|1@1+ (1,0) [0|1] "" CLU,ESC,TCU + SG_ PreFill : 36|1@1+ (1,0) [0|1] "" ESC,TCU + SG_ CF_VSM_ConfMode : 48|2@1+ (1,0) [0|3] "" CLU,ESC + SG_ AEB_Failinfo : 50|2@1+ (1,0) [0|3] "" CLU,ESC + SG_ AEB_Status : 52|2@1+ (1,0) [0|3] "" CLU,ESC + SG_ AEB_CmdAct : 54|1@1+ (1,0) [0|1] "" ESC + SG_ AEB_StopReq : 55|1@1+ (1,0) [0|1] "" CLU,ESC + SG_ CR_VSM_Alive : 56|4@1+ (1,0) [0|15] "" ESC,PSB + SG_ CR_VSM_ChkSum : 60|4@1+ (1,0) [0|15] "" ESC,PSB + SG_ aReqValue : 37|11@1+ (0.01,-10.23) [-10.23|10.24] "m/s^2" Vector__XXX + SG_ aReqRaw : 24|11@1+ (0.01,-10.23) [-10.23|10.24] "m/s^2" Vector__XXX BO_ 1313 GW_DDM_PE: 8 BCM SG_ C_DRVDoorStatus : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU @@ -1188,23 +1196,23 @@ BO_ 1313 GW_DDM_PE: 8 BCM SG_ C_RRDoorStatus : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_TrunkStatus : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_OSMirrorStatus : 10|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - + BO_ 1056 SCC11: 8 SCC - SG_ MainMode_ACC : 0|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,ESC - SG_ SCCInfoDisplay : 1|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,ESC - SG_ AliveCounterACC : 4|4@1+ (1.0,0.0) [0.0|15.0] "" CLU,EMS,ESC,TCU - SG_ VSetDis : 8|8@1+ (1.0,0.0) [0.0|255.0] "km/h or MPH" CLU,ESC,TCU - SG_ ObjValid : 16|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,ESC,TCU - SG_ DriverAlertDisplay : 17|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ESC - SG_ TauGapSet : 19|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,ESC,TCU - SG_ ACC_ObjStatus : 22|2@1+ (1.0,0.0) [0.0|3.0] "" ABS,ESC - SG_ ACC_ObjLatPos : 24|9@1+ (0.1,-20.0) [-20.0|31.1] "m" ABS,ESC - SG_ ACC_ObjDist : 33|11@1+ (0.1,0.0) [0.0|204.7] "m" ABS,ESC - SG_ ACC_ObjRelSpd : 44|12@1+ (0.1,-170.0) [-170.0|239.5] "m/s" ABS,ESC - SG_ Navi_SCC_Curve_Status : 56|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ Navi_SCC_Curve_Act : 58|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ Navi_SCC_Camera_Act : 60|2@1+ (1.0,0.0) [0.0|3.0] "" CLU - SG_ Navi_SCC_Camera_Status : 62|2@1+ (1.0,0.0) [0.0|3.0] "" CLU + SG_ MainMode_ACC : 0|1@1+ (1,0) [0|1] "" CLU,EMS,ESC + SG_ SCCInfoDisplay : 1|3@1+ (1,0) [0|7] "" CLU,ESC + SG_ AliveCounterACC : 4|4@1+ (1,0) [0|15] "" CLU,EMS,ESC,TCU + SG_ VSetDis : 8|8@1+ (1,0) [0|255] "km/h or MPH" CLU,ESC,TCU + SG_ ObjValid : 16|1@1+ (1,0) [0|1] "" CLU,ESC,TCU + SG_ DriverAlertDisplay : 17|2@1+ (1,0) [0|3] "" CLU,ESC + SG_ TauGapSet : 19|3@1+ (1,0) [0|7] "" CLU,ESC,TCU + SG_ Navi_SCC_Curve_Status : 56|2@1+ (1,0) [0|3] "" CLU + SG_ Navi_SCC_Curve_Act : 58|2@1+ (1,0) [0|3] "" CLU + SG_ Navi_SCC_Camera_Act : 60|2@1+ (1,0) [0|3] "" CLU + SG_ Navi_SCC_Camera_Status : 62|2@1+ (1,0) [0|3] "" CLU + SG_ ACC_ObjStatus : 22|2@1+ (1,0) [0|3] "" ABS,ESC + SG_ ACC_ObjLatPos : 24|9@1+ (0.1,-20) [-20|31.1] "m" ABS,ESC + SG_ ACC_ObjRelSpd : 44|12@1+ (0.1,-170) [-170|239.5] "m/s" ABS,ESC + SG_ ACC_ObjDist : 33|11@1+ (0.1,0) [0|204.7] "m" ABS,ESC BO_ 1312 CGW3: 8 BCM SG_ CR_Photosensor_LH : 0|8@1+ (78.125,0.0) [0.0|20000.0] "" DATC,DATC @@ -1225,8 +1233,8 @@ BO_ 544 ESP12: 8 ESC SG_ YAW_RATE : 40|13@1+ (0.01,-40.95) [-40.95|40.96] "" _4WD,AFLS,IBOX,LCA,LDWS_LKAS,MDPS,PSB,SCC,SPAS,TCU SG_ YAW_RATE_STAT : 53|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,AFLS,IBOX,LCA,LDWS_LKAS,MDPS,PSB,SCC,SPAS,TCU SG_ YAW_RATE_DIAG : 54|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,AFLS,IBOX,LCA,LDWS_LKAS,MDPS,PSB,SCC,SPAS,TCU - SG_ ESP12_AliveCounter : 56|4@1+ (1.0,0.0) [0.0|15.0] "" _4WD,EMS,LPI,TCU,TMU - SG_ ESP12_Checksum : 60|4@1+ (1.0,0.0) [0.0|15.0] "" _4WD,EMS,LPI,TCU,TMU + SG_ ESP12_Checksum : 56|4@1+ (1.0,0.0) [0.0|15.0] "" _4WD,EMS,LPI,TCU,TMU + SG_ ESP12_AliveCounter : 60|4@1+ (1.0,0.0) [0.0|15.0] "" _4WD,EMS,LPI,TCU,TMU BO_ 1307 CLU16: 8 CLU SG_ CF_Clu_TirePressUnitNValueSet : 0|3@1+ (1.0,0.0) [0.0|7.0] "" TPMS @@ -1367,9 +1375,10 @@ BO_ 1292 CLU13: 8 CLU SG_ CF_Clu_AliveCnt2 : 60|4@1+ (1.0,0.0) [0.0|15.0] "" EMS,LDWS_LKAS BO_ 1290 SCC13: 8 SCC - SG_ SCCDrvModeRValue : 0|3@1+ (1.0,0.0) [0.0|7.0] "" CLU - SG_ SCC_Equip : 3|1@1+ (1.0,0.0) [0.0|1.0] "" ESC - SG_ AebDrvSetStatus : 4|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,ESC + SG_ SCCDrvModeRValue : 0|3@1+ (1,0) [0|7] "" CLU + SG_ SCC_Equip : 3|1@1+ (1,0) [0|1] "" ESC + SG_ AebDrvSetStatus : 4|3@1+ (1,0) [0|7] "" CLU,ESC + SG_ Lead_Veh_Dep_Alert_USM : 13|2@0+ (1,0) [0|3] "" XXX BO_ 1287 TCS15: 4 ESC SG_ ABS_W_LAMP : 0|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU,CUBIS,IBOX @@ -1421,3 +1430,206 @@ BO_ 512 EMS20: 6 EMS SG_ FCO : 0|16@1+ (0.128,0.0) [0.0|8388.48] "ul" CLU,CUBIS,FPCM,IBOX SG_ CF_Ems_PumpTPres : 16|8@1+ (3.137254902,0.0) [0.0|800.0] "kPa" FPCM,IBOX SG_ Split_Stat : 32|1@1+ (1.0,0.0) [0.0|1.0] "" FPCM + +BO_ 909 FCA11: 8 FCA + SG_ CF_VSM_Prefill : 0|1@1+ (1,0) [0|1] "" ESC + SG_ CF_VSM_HBACmd : 1|2@1+ (1,0) [0|3] "" ESC + SG_ CF_VSM_Warn : 3|2@1+ (1,0) [0|3] "" ACU,CLU,ESC + SG_ CF_VSM_BeltCmd : 5|3@1+ (1,0) [0|7] "" ESC + SG_ CR_VSM_DecCmd : 8|8@1+ (0.01,0) [0|2.55] "g" ESC + SG_ FCA_Status : 18|2@1+ (1,0) [0|3] "" ACU,CLU,ESC + SG_ FCA_CmdAct : 20|1@1+ (1,0) [0|1] "" ESC + SG_ FCA_StopReq : 21|1@1+ (1,0) [0|1] "" CLU,ESC + SG_ FCA_DrvSetStatus : 22|3@1+ (1,0) [0|7] "" CLU,ESC + SG_ CF_VSM_DecCmdAct : 31|1@1+ (1,0) [0|1] "" ESC + SG_ FCA_Failinfo : 32|3@1+ (1,0) [0|7] "" ACU,CLU,ESC + SG_ FCA_RelativeVelocity : 39|9@1+ (0.1,-25.5) [-25.5|25.5] "m/s" iBAU + SG_ FCA_TimetoCollision : 48|8@1+ (10,0) [0|2540] "ms" iBAU + SG_ CR_FCA_Alive : 56|4@1+ (1,0) [0|15] "" ESC + SG_ CR_FCA_ChkSum : 60|4@1+ (1,0) [0|15] "" ESC + SG_ Supplemental_Counter : 35|4@1+ (1,0) [0|15] "" XXX + SG_ PAINT1_Status : 16|2@1+ (1,0) [0|1] "" XXX + +BO_ 1156 HDA11_MFC: 8 XXX + SG_ Counter : 5|4@0+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_1 : 1|2@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 7|2@0+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_3 : 15|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 16|2@1+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_5 : 18|14@1+ (1,0) [0|63] "" XXX + SG_ NEW_SIGNAL_6 : 33|2@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_7 : 34|14@1+ (1,0) [0|16383] "" XXX + SG_ NEW_SIGNAL_8 : 49|2@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_9 : 50|14@1- (1,-4095) [0|16383] "" XXX + +BO_ 1155 FCA12: 8 FCA + SG_ FCA_USM : 0|3@1+ (1,0) [0|7] "" CGW,CLU,ESC + SG_ FCA_DrvSetState : 3|3@1+ (1,0) [0|7] "" CGW + +BO_ 1186 FRT_RADAR11: 2 FCA + SG_ CF_FCA_Equip_Front_Radar : 0|3@1+ (1,0) [0|7] "" LDWS_LKAS,LDW_LKA,ESC + +BO_ 905 SCC14: 8 SCC + SG_ ComfortBandUpper : 0|6@1+ (0.0986,-4.14) [0|1.26] "m/s^2" ESC + SG_ ComfortBandLower : 6|6@1+ (0.0986,-4.14) [0|1.26] "m/s^2" ESC + SG_ JerkUpperLimit : 12|7@1+ (1,0) [0|12.7] "m/s^3" ESC + SG_ JerkLowerLimit : 19|7@1+ (0.1,0) [0|12.7] "m/s^3" ESC + SG_ ACCMode : 32|3@1+ (1,0) [0|7] "" CLU,HUD,LDWS_LKAS,ESC + SG_ ObjGap : 56|8@1+ (1,0) [0|255] "" CLU,HUD,ESC + +BO_ 1157 LFAHDA_MFC: 4 XXX + SG_ HDA_USM : 0|2@1+ (1,0) [0|3] "" XXX + SG_ ACTIVE2 : 4|2@0+ (1,0) [0|3] "" XXX + SG_ LFA_SysWarning : 16|2@1+ (1,0) [0|3] "" XXX + SG_ ACTIVE : 25|1@1+ (1,0) [0|3] "" XXX + SG_ LFA_USM : 28|2@1+ (1,0) [0|3] "" XXX + +BO_ 913 BCM_PO_11: 8 Vector__XXX + SG_ BCM_Door_Dri_Status : 5|1@0+ (1,0) [0|1] "" PT_ESC_ABS + SG_ BCM_Shift_R_MT_SW_Status : 39|2@0+ (1,0) [0|3] "" PT_ESC_ABS + +BO_ 1426 LABEL11: 8 XXX + SG_ CC_React : 34|1@1+ (1,0) [0|1] "" XXX + +BO_ 910 WHL_SPD12_FS: 5 iBAU + SG_ CRC : 0|8@1+ (1,0) [0|0] "" Vector__XXX + SG_ WHL_SPD12_AliveCounter : 8|4@1+ (1,0) [0|15] "" Vector__XXX + SG_ WHL_SPD_FL : 12|14@1+ (0.03125,0) [0|511.96875] "km/h" Vector__XXX + SG_ WHL_SPD_FR : 26|14@1+ (0.03125,0) [0|511.96875] "km/h" Vector__XXX + +BO_ 911 WHL_SPD13_FS: 5 iBAU + SG_ CRC : 0|8@1+ (1,0) [0|0] "" Vector__XXX + SG_ WHL_SPD13_AliveCounter : 8|4@1+ (1,0) [0|15] "" Vector__XXX + SG_ WHL_SPD_RL : 12|14@1+ (0.03125,0) [0|511.96875] "km/h" Vector__XXX + SG_ WHL_SPD_RR : 26|14@1+ (0.03125,0) [0|511.96875] "km/h" Vector__XXX + +BO_ 865 ADAS_PRK_11: 8 ADAS_PRK + SG_ CF_PCA_BrkReq : 24|1@1+ (1,0) [0|0] "" Vector__XXX + SG_ CF_PCA_DclTrgtVal : 28|4@1+ (0.04,0) [0|0] "g" Vector__XXX + SG_ PCA_ALIVE_CNT : 40|4@1+ (1,0) [0|0] "" Vector__XXX + SG_ PCA_CHECK_SUM : 48|8@1+ (1,0) [0|0] "" Vector__XXX + +BO_ 882 ELECT_GEAR: 8 XXX + SG_ Elect_Gear_Shifter : 16|4@1+ (1,0) [0|7] "" CLU + +BO_ 881 E_EMS11: 8 XXX + SG_ Brake_Pedal_Pos : 0|8@1+ (1,0) [0|127] "" XXX + SG_ IG_Reactive_Stat : 8|3@1+ (1,0) [0|3] "" XXX + SG_ Gear_Change : 12|1@0+ (1,0) [0|31] "" XXX + SG_ Cruise_Limit_Status : 13|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Limit_Target : 23|8@1+ (1,0) [0|15] "" XXX + SG_ Accel_Pedal_Pos : 31|8@1+ (1,0) [0|7] "" XXX + +BO_ 1355 EV_PC6: 8 CGW + SG_ CF_Vcu_SbwWarnMsg : 16|3@1+ (1,0) [0|7] "" Vector__XXX + +BO_ 1430 EV_PC2: 8 CGW + SG_ CR_Ldc_ActVol_LS_V : 32|8@1+ (0.1,0) [0|0] "V" Vector__XXX + +BO_ 1535 EV_PC10: 8 CGW + SG_ CF_Vcu_EpbRequest : 37|1@1+ (1,0) [0|0] "" Vector__XXX + +BO_ 908 RSPA11: 8 RSPA + SG_ CF_RSPA_State : 0|4@1+ (1,0) [0|15] "" XXX + SG_ CF_RSPA_Act : 4|2@1+ (1,0) [0|3] "" XXX + SG_ CF_RSPA_DecCmd : 6|2@1+ (1,0) [0|3] "" XXX + SG_ CF_RSPA_Trgt_Spd : 8|10@1+ (0.01,0) [0|10.23] "km/h" XXX + SG_ CF_RSPA_StopReq : 18|1@1+ (1,0) [0|2] "" XXX + SG_ CR_RSPA_EPB_Req : 22|2@1+ (1,0) [0|3] "" XXX + SG_ CF_RSPA_ACC_ACT : 50|1@1+ (1,0) [0|2] "" XXX + SG_ CF_RSPA_AliveCounter : 52|4@1+ (1,0) [0|15] "" XXX + SG_ CF_RSPA_CRC : 56|8@1+ (1,0) [0|255] "" XXX + +BO_ 914 S_MDPS11: 8 XXX + SG_ CF_Mdps_Stat : 0|4@1+ (1,0) [0|15] "" XXX + SG_ CR_Mdps_DrvTq : 8|12@1+ (1,0) [0|15] "" XXX + SG_ CR_Mdps_StrAng : 24|16@1- (1,0) [0|65535] "" XXX + SG_ CF_Mdps_AliveCnt : 47|8@0+ (1,0) [0|255] "" XXX + SG_ CF_Mdps_Chksum : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 357 S_MDPS12: 8 XXX + SG_ NEW_SIGNAL_1 : 0|12@1+ (1,0) [0|4095] "" XXX + SG_ NEW_SIGNAL_2 : 12|12@1+ (1,0) [0|4095] "" XXX + SG_ Counter : 48|4@1+ (1,0) [0|15] "" XXX + SG_ Checksum : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 352 AHB1: 8 iBAU + SG_ CF_Ahb_SLmp : 0|2@1+ (1,0) [0|3] "" CLU + SG_ CF_Ahb_Def : 2|2@1+ (1,0) [0|3] "" CGW + SG_ CF_Ahb_Act : 4|2@1+ (1,0) [0|3] "" Vector__XXX + SG_ CF_Ahb_Diag : 6|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ CF_Ahb_WLmp : 7|1@1+ (1,0) [0|1] "" CLU + SG_ CR_Ahb_StDep_mm : 8|16@1- (0.1,0) [-3276.8|3276.7] "mm" Vector__XXX + SG_ CF_Ahb_SnsFail : 24|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ CF_Ahb_PedalCalStat : 25|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ CF_Ahb_Bzzr : 26|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ CF_Ahb_ChkSum : 56|8@1+ (1,0) [0|255] "" Vector__XXX + +BO_ 1191 4a7MFC: 8 XXX + SG_ PAINT1 : 0|1@0+ (1,0) [0|1] "" XXX + +BO_ 1162 BCA11: 8 BCW + SG_ CF_BCA_State : 16|3@1+ (1,0) [0|7] "" CLU,iBAU + SG_ CF_BCA_Warning : 19|2@1+ (1,0) [0|3] "" CLU,iBAU + SG_ AliveCounter : 21|4@1+ (1,0) [0|15] "" CLU,iBAU + SG_ RCCA_Brake_Command : 29|1@1+ (1,0) [0|1] "" iBAU + SG_ Check_Sum : 56|8@1+ (1,0) [0|16] "" iBAU + +BO_ 1136 P_STS: 6 CGW + SG_ HCU1_STS : 6|2@1+ (1,0) [0|3] "" BCW,EPB,FCA,MDPS,SCC,iBAU + SG_ HCU5_STS : 8|2@1+ (1,0) [0|3] "" EPB,FCA,MDPS,iBAU + +BO_ 304 YRS11: 8 ACU + SG_ CR_Yrs_Yr : 0|16@1+ (0.005,-163.84) [-163.84|163.83] "deg/s" CGW,iBAU + SG_ CR_Yrs_LatAc : 16|16@1+ (0.000127465,-4.17677312) [-4.17677312|4.17651819] "g" iBAU + SG_ CF_Yrs_YrStat : 32|4@1+ (1,0) [0|15] "" iBAU + SG_ CF_Yrs_LatAcStat : 36|4@1+ (1,0) [0|15] "" iBAU + SG_ CF_Yrs_MCUStat : 40|4@1+ (1,0) [0|15] "" iBAU + SG_ CR_Yrs_MsgCnt1 : 48|4@1+ (1,0) [0|15] "" iBAU + SG_ CR_Yrs_Crc1 : 56|8@1+ (1,0) [0|255] "" iBAU + +BO_ 320 YRS12: 8 ACU + SG_ CF_Yrs_LongAcStat : 16|4@1+ (1,0) [0|15] "" iBAU + SG_ CF_IMU_ResetStat : 20|4@1+ (1,0) [0|15] "" iBAU + SG_ YRS_Temp : 24|8@1+ (1,-68) [-68|187] "" iBAU + SG_ YRS_TempStat : 32|4@1+ (1,0) [0|15] "" iBAU + SG_ CF_Yrs_Type : 36|4@1+ (1,0) [0|15] "" iBAU + SG_ CR_Yrs_MsgCnt2 : 48|4@1+ (1,0) [0|15] "" iBAU + SG_ CR_Yrs_Crc2 : 56|8@1+ (1,0) [0|255] "" iBAU + SG_ CR_Yrs_LongAc : 0|16@1+ (0.000127465,-4.17677312) [-4.17677312|4.17651819] "g" CGW,iBAU + +BO_ 1173 YRS13: 8 ACU + SG_ YRS_SeralNo : 16|48@1+ (1,0) [0|281474976710655] "" iBAU + +BO_ 870 366_EMS: 8 EMS + SG_ N : 7|16@0+ (1,0.25) [0|16383.75] "rpm" XXX + SG_ EMS_Related : 23|16@0+ (1,0) [0|65535] "" XXX + SG_ TQFR : 39|8@0+ (0.390625,0) [0|99.6094] "%" XXX + SG_ VS : 40|8@1+ (1,0) [0|255] "km/h" MDPS + SG_ SWI_IGK : 48|1@0+ (1,0) [0|1] "" XXX + +BO_ 854 356: 8 XXX + SG_ PAINT1 : 32|1@0+ (1,0) [0|1] "" XXX + SG_ PAINT2 : 34|2@0+ (1,0) [0|1] "" XXX + SG_ PAINT3 : 36|2@0+ (1,0) [0|3] "" XXX + SG_ PAINT4 : 38|1@0+ (1,0) [0|1] "" XXX + +BO_ 1042 ICM_412h: 8 ICM + SG_ T_Outside_input : 0|9@0+ (0.01,0) [0|5] "V" Vector__XXX + SG_ WarningSoundOutput_1Group : 5|1@0+ (1,0) [0|1] "" Vector__XXX + SG_ WarningSoundOutput_2Group : 6|1@0+ (1,0) [0|1] "" Vector__XXX + SG_ WarningSoundOutput_3Group : 7|1@0+ (1,0) [0|1] "" Vector__XXX + SG_ TRIP_A_DT_Display_clock : 22|7@0+ (1,0) [0|99] "clock" Vector__XXX + SG_ TRIP_A_DT_Display_minute : 29|6@0+ (1,0) [0|59] "minute" Vector__XXX + SG_ TRIP_B_DT_Display_clock : 38|7@0+ (1,0) [0|99] "clock" Vector__XXX + SG_ TRIP_B_DT_Display_minute : 45|6@0+ (1,0) [0|59] "minute" Vector__XXX + SG_ PopupMessageOutput_1Level : 48|1@0+ (1,0) [0|1] "" Vector__XXX + SG_ PopupMessageOutput_2Level : 49|1@0+ (1,0) [0|1] "" Vector__XXX + SG_ PopupMessageOutput_3Level : 50|1@0+ (1,0) [0|1] "" Vector__XXX + SG_ PopupMessageOutput_4Level : 51|1@0+ (1,0) [0|1] "" Vector__XXX + SG_ PopupMessageOutput_5Level : 52|1@0+ (1,0) [0|1] "" Vector__XXX + SG_ PopupMessageOutput_6Level : 53|1@0+ (1,0) [0|1] "" Vector__XXX + SG_ PopupMessageOutput_7Level : 54|1@0+ (1,0) [0|1] "" Vector__XXX + SG_ PopupMessageOutput_8Level : 55|1@0+ (1,0) [0|1] "" Vector__XXX + +VAL_ 909 CF_VSM_Warn 2 "FCW" 3 "AEB"; diff --git a/opendbc/lexus_ct200h_2018_pt_generated.dbc b/opendbc/lexus_ct200h_2018_pt_generated.dbc index 6e41a0218aa878..54c812780a77ee 100644 --- a/opendbc/lexus_ct200h_2018_pt_generated.dbc +++ b/opendbc/lexus_ct200h_2018_pt_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +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 @@ -9,10 +9,10 @@ BO_ 359 STEERING_IPAS_COMMA: 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 -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"; +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 @@ -30,8 +30,13 @@ CM BO_ STEERING_IPAS_COMMA "Copy of msg 614 so we can do angle control while the VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; +BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX + SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX + +CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; -CM_ "Imported file _toyota_2017.dbc starts here" + +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -70,8 +75,8 @@ BS_: BU_: XXX DSU HCU EPS IPAS CGW 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_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX + SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX @@ -91,12 +96,15 @@ BO_ 170 WHEEL_SPEEDS: 8 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 + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 353 DSU_SPEED: 8 XXX +BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX +BO_ 452 ENGINE_RPM: 8 CGW + SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS + 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 @@ -159,10 +167,11 @@ BO_ 835 ACC_CONTROL: 8 DSU 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_ PERMIT_BRAKING : 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 + SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX @@ -184,6 +193,7 @@ BO_ 921 PCM_CRUISE_SM: 8 XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX + SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1041 ACC_HUD: 8 DSU @@ -208,6 +218,17 @@ BO_ 1042 LKAS_HUD: 8 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_ 1043 TIME : 8 CGW + SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX + SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX + SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX + SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX + SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX + SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX + SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX + SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX + SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX + BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX @@ -231,7 +252,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX @@ -295,7 +316,7 @@ 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 SET_SPEED "43 kph are shown as 28mph, so conversion isn't 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"; @@ -304,13 +325,15 @@ CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; +CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; +CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; 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_ 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"; @@ -344,23 +367,23 @@ 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_ct200h_2018_pt.dbc starts here" +CM_ "lexus_ct200h_2018_pt.dbc starts here"; BO_ 548 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 + SG_ BRAKE_PRESSURE : 43|12@0+ (1,0) [0|4047] "" XXX + SG_ BRAKE_PRESSED : 5|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_EPS : 47|16@0- (1,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 + SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX @@ -381,4 +404,4 @@ 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"; VAL_ 956 SPORT_ON 0 "off" 1 "on"; -VAL_ 956 ECON_ON 0 "off" 1 "on"; \ No newline at end of file +VAL_ 956 ECON_ON 0 "off" 1 "on"; diff --git a/opendbc/lexus_gs300h_2017_pt_generated.dbc b/opendbc/lexus_gs300h_2017_pt_generated.dbc deleted file mode 100644 index d6de0949376924..00000000000000 --- a/opendbc/lexus_gs300h_2017_pt_generated.dbc +++ /dev/null @@ -1,385 +0,0 @@ -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 CGW - -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_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" 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: 7 DSU - SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX - SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX - SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX - SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX - SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX - SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX - SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" 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_ 836 PRE_COLLISION_2: 8 DSU - SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX - -BO_ 869 DSU_CRUISE : 7 DSU - SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX - SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX - SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX - SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX - SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX - SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX - SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" 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_ 1408 VIN_PART_1: 8 CGW - SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX - -BO_ 1409 VIN_PART_2: 8 CGW - SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX - -BO_ 1410 VIN_PART_3: 8 CGW - SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" 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_ 643 COUNTER "only used on cars that use this msg for cruise control"; -CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; -CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; -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_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; -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"; diff --git a/opendbc/lexus_is_2018_pt_generated.dbc b/opendbc/lexus_is_2018_pt_generated.dbc index 10a0096f0b78dd..24aa111363f60d 100644 --- a/opendbc/lexus_is_2018_pt_generated.dbc +++ b/opendbc/lexus_is_2018_pt_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +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 @@ -9,10 +9,10 @@ BO_ 359 STEERING_IPAS_COMMA: 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 -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"; +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 @@ -30,8 +30,13 @@ CM BO_ STEERING_IPAS_COMMA "Copy of msg 614 so we can do angle control while the VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; +BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX + SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX + +CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; + -CM_ "Imported file _toyota_2017.dbc starts here" +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -70,8 +75,8 @@ BS_: BU_: XXX DSU HCU EPS IPAS CGW 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_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX + SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX @@ -91,12 +96,15 @@ BO_ 170 WHEEL_SPEEDS: 8 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 + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 353 DSU_SPEED: 8 XXX +BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX +BO_ 452 ENGINE_RPM: 8 CGW + SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS + 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 @@ -159,10 +167,11 @@ BO_ 835 ACC_CONTROL: 8 DSU 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_ PERMIT_BRAKING : 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 + SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX @@ -184,6 +193,7 @@ BO_ 921 PCM_CRUISE_SM: 8 XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX + SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1041 ACC_HUD: 8 DSU @@ -208,6 +218,17 @@ BO_ 1042 LKAS_HUD: 8 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_ 1043 TIME : 8 CGW + SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX + SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX + SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX + SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX + SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX + SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX + SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX + SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX + SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX + BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX @@ -231,7 +252,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX @@ -295,7 +316,7 @@ 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 SET_SPEED "43 kph are shown as 28mph, so conversion isn't 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"; @@ -304,13 +325,15 @@ CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; +CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; +CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; 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_ 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"; @@ -344,7 +367,7 @@ 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_is_2018_pt.dbc starts here" +CM_ "lexus_is_2018_pt.dbc starts here"; @@ -353,15 +376,19 @@ BO_ 550 BRAKE_MODULE: 8 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_ALT: 5 XXX + SG_ GAS_PEDAL : 23|8@0+ (0.005,0) [0|1] "" XXX + BO_ 705 GAS_PEDAL: 8 XXX SG_ GAS_RELEASED : 3|1@0+ (1,0) [0|1] "" XXX SG_ GAS_PEDAL : 55|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX - SG_ STEER_TORQUE_EPS : 47|16@0- (0.66,0) [-20000|20000] "" XXX + SG_ STEER_TORQUE_EPS : 47|16@0- (0.77,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 + SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX @@ -377,6 +404,9 @@ BO_ 1009 PCM_CRUISE_ALT: 8 XXX SG_ CRUISE_STATE : 10|1@0+ (1,0) [0|1] "" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX +BO_ 1599 LIGHT_STALK_ISH: 8 SCM + SG_ AUTO_HIGH_BEAM : 19|1@0+ (1,0) [0|1] "" 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_ 610 TYPE "seems 1 on Corolla, 0 on all others"; diff --git a/opendbc/lexus_is_hybrid_2017_pt_generated.dbc b/opendbc/lexus_is_hybrid_2017_pt_generated.dbc deleted file mode 100644 index 4444ec852d55a2..00000000000000 --- a/opendbc/lexus_is_hybrid_2017_pt_generated.dbc +++ /dev/null @@ -1,388 +0,0 @@ -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 CGW - -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_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" 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: 7 DSU - SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX - SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX - SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX - SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX - SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX - SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX - SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" 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_ 836 PRE_COLLISION_2: 8 DSU - SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX - -BO_ 869 DSU_CRUISE : 7 DSU - SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX - SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX - SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX - SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX - SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX - SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX - SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" 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_ 1408 VIN_PART_1: 8 CGW - SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX - -BO_ 1409 VIN_PART_2: 8 CGW - SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX - SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX - -BO_ 1410 VIN_PART_3: 8 CGW - SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" 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_ 643 COUNTER "only used on cars that use this msg for cruise control"; -CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; -CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; -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_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; -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_is_hybrid_2017_pt.dbc starts here" - - - -BO_ 581 GAS_PEDAL: 5 XXX - SG_ GAS_PEDAL : 23|8@0+ (0.005,0) [0|1] "" XXX - -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_ 608 STEER_TORQUE_SENSOR: 8 XXX - SG_ STEER_TORQUE_EPS : 47|16@0- (0.66,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_ISH: 8 XXX - SG_ MAIN_ON : 13|1@0+ (1,0) [0|3] "" XXX - SG_ CRUISE_STATE : 10|1@0+ (1,0) [0|1] "" XXX - SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX - -BO_ 1599 LIGHT_STALK_ISH: 8 SCM - SG_ AUTO_HIGH_BEAM : 19|1@0+ (1,0) [0|1] "" 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_ 610 TYPE "seems 1 on Corolla, 0 on all others"; -CM_ SG_ 1009 SET_SPEED "units seem to be whatever the car is set to"; -VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; -VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; -VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; diff --git a/opendbc/lexus_nx300_2018_pt_generated.dbc b/opendbc/lexus_nx300_2018_pt_generated.dbc new file mode 100644 index 00000000000000..824d301d00431c --- /dev/null +++ b/opendbc/lexus_nx300_2018_pt_generated.dbc @@ -0,0 +1,409 @@ +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_1 : 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" ; + +BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX + SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX + +CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; + + +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 CGW + +BO_ 36 KINEMATICS: 8 XXX + SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX + SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" 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_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 353 DSU_SPEED: 7 XXX + SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX + +BO_ 452 ENGINE_RPM: 8 CGW + SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS + +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_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" 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: 7 DSU + SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX + SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX + SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX + SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX + SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX + SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX + SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX + SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX + SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" 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_ PERMIT_BRAKING : 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 + SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX + +BO_ 836 PRE_COLLISION_2: 8 DSU + SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX + +BO_ 869 DSU_CRUISE : 7 DSU + SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX + SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX + SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX + SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX + SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX + SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX + SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" 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_ VSC_DISABLED : 12|2@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_ 1043 TIME : 8 CGW + SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX + SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX + SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX + SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX + SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX + SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX + SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX + SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX + SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX + +BO_ 1408 VIN_PART_1: 8 CGW + SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX + +BO_ 1409 VIN_PART_2: 8 CGW + SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX + +BO_ 1410 VIN_PART_3: 8 CGW + SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX + +BO_ 1553 UI_SETTING: 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 isn't 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_ 643 COUNTER "only used on cars that use this msg for cruise control"; +CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; +CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; +CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; +CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; +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_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; +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_nx300_2018_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_ 705 GAS_PEDAL: 8 XXX + SG_ GAS_RELEASED : 3|1@0+ (1,0) [0|1] "" XXX + SG_ GAS_PEDAL : 55|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 + SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" 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_ SPORT_ON : 2|1@0+ (1,0) [0|1] "" XXX + SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX + SG_ ECON_ON : 40|1@0+ (1,0) [0|1] "" 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"; +VAL_ 956 SPORT_ON 0 "off" 1 "on"; +VAL_ 956 ECON_ON 0 "off" 1 "on"; diff --git a/opendbc/lexus_nx300h_2018_pt_generated.dbc b/opendbc/lexus_nx300h_2018_pt_generated.dbc new file mode 100644 index 00000000000000..94e6818c81448e --- /dev/null +++ b/opendbc/lexus_nx300h_2018_pt_generated.dbc @@ -0,0 +1,408 @@ +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_1 : 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" ; + +BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX + SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX + +CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; + + +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 CGW + +BO_ 36 KINEMATICS: 8 XXX + SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX + SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" 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_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 353 DSU_SPEED: 7 XXX + SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX + +BO_ 452 ENGINE_RPM: 8 CGW + SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS + +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_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" 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: 7 DSU + SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX + SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX + SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX + SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX + SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX + SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX + SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX + SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX + SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" 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_ PERMIT_BRAKING : 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 + SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX + +BO_ 836 PRE_COLLISION_2: 8 DSU + SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX + +BO_ 869 DSU_CRUISE : 7 DSU + SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX + SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX + SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX + SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX + SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX + SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX + SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" 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_ VSC_DISABLED : 12|2@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_ 1043 TIME : 8 CGW + SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX + SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX + SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX + SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX + SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX + SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX + SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX + SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX + SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX + +BO_ 1408 VIN_PART_1: 8 CGW + SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX + +BO_ 1409 VIN_PART_2: 8 CGW + SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX + SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX + +BO_ 1410 VIN_PART_3: 8 CGW + SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX + +BO_ 1553 UI_SETTING: 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 isn't 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_ 643 COUNTER "only used on cars that use this msg for cruise control"; +CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; +CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; +CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; +CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; +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_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; +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_nx300h_2018_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 + SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" 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_ SPORT_ON : 2|1@0+ (1,0) [0|1] "" XXX + SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX + SG_ ECON_ON : 40|1@0+ (1,0) [0|1] "" 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"; +VAL_ 956 SPORT_ON 0 "off" 1 "on"; +VAL_ 956 ECON_ON 0 "off" 1 "on"; diff --git a/opendbc/lexus_rx_350_2016_pt_generated.dbc b/opendbc/lexus_rx_350_2016_pt_generated.dbc index b132c86dd3326a..58c21c5952da5e 100644 --- a/opendbc/lexus_rx_350_2016_pt_generated.dbc +++ b/opendbc/lexus_rx_350_2016_pt_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +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 @@ -9,10 +9,10 @@ BO_ 359 STEERING_IPAS_COMMA: 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 -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"; +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 @@ -30,8 +30,13 @@ CM BO_ STEERING_IPAS_COMMA "Copy of msg 614 so we can do angle control while the VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; +BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX + SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX + +CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; -CM_ "Imported file _toyota_2017.dbc starts here" + +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -70,8 +75,8 @@ BS_: BU_: XXX DSU HCU EPS IPAS CGW 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_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX + SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX @@ -91,12 +96,15 @@ BO_ 170 WHEEL_SPEEDS: 8 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 + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 353 DSU_SPEED: 8 XXX +BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX +BO_ 452 ENGINE_RPM: 8 CGW + SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS + 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 @@ -159,10 +167,11 @@ BO_ 835 ACC_CONTROL: 8 DSU 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_ PERMIT_BRAKING : 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 + SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX @@ -184,6 +193,7 @@ BO_ 921 PCM_CRUISE_SM: 8 XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX + SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1041 ACC_HUD: 8 DSU @@ -208,6 +218,17 @@ BO_ 1042 LKAS_HUD: 8 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_ 1043 TIME : 8 CGW + SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX + SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX + SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX + SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX + SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX + SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX + SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX + SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX + SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX + BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX @@ -231,7 +252,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX @@ -295,7 +316,7 @@ 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 SET_SPEED "43 kph are shown as 28mph, so conversion isn't 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"; @@ -304,13 +325,15 @@ CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; +CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; +CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; 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_ 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"; @@ -344,7 +367,7 @@ 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_rx_350_2016_pt.dbc starts here" +CM_ "lexus_rx_350_2016_pt.dbc starts here"; @@ -358,6 +381,7 @@ BO_ 608 STEER_TORQUE_SENSOR: 8 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 + SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX diff --git a/opendbc/lexus_rx_hybrid_2017_pt_generated.dbc b/opendbc/lexus_rx_hybrid_2017_pt_generated.dbc index e11ee65b61a8de..e8a358f460d079 100644 --- a/opendbc/lexus_rx_hybrid_2017_pt_generated.dbc +++ b/opendbc/lexus_rx_hybrid_2017_pt_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +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 @@ -9,10 +9,10 @@ BO_ 359 STEERING_IPAS_COMMA: 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 -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"; +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 @@ -30,8 +30,13 @@ CM BO_ STEERING_IPAS_COMMA "Copy of msg 614 so we can do angle control while the VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; +BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX + SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX + +CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; -CM_ "Imported file _toyota_2017.dbc starts here" + +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -70,8 +75,8 @@ BS_: BU_: XXX DSU HCU EPS IPAS CGW 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_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX + SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX @@ -91,12 +96,15 @@ BO_ 170 WHEEL_SPEEDS: 8 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 + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 353 DSU_SPEED: 8 XXX +BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX +BO_ 452 ENGINE_RPM: 8 CGW + SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS + 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 @@ -159,10 +167,11 @@ BO_ 835 ACC_CONTROL: 8 DSU 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_ PERMIT_BRAKING : 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 + SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX @@ -184,6 +193,7 @@ BO_ 921 PCM_CRUISE_SM: 8 XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX + SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1041 ACC_HUD: 8 DSU @@ -208,6 +218,17 @@ BO_ 1042 LKAS_HUD: 8 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_ 1043 TIME : 8 CGW + SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX + SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX + SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX + SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX + SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX + SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX + SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX + SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX + SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX + BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX @@ -231,7 +252,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX @@ -295,7 +316,7 @@ 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 SET_SPEED "43 kph are shown as 28mph, so conversion isn't 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"; @@ -304,13 +325,15 @@ CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; +CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; +CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; 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_ 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"; @@ -344,7 +367,7 @@ 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_rx_hybrid_2017_pt.dbc starts here" +CM_ "lexus_rx_hybrid_2017_pt.dbc starts here"; @@ -361,6 +384,7 @@ BO_ 608 STEER_TORQUE_SENSOR: 8 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 + SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX diff --git a/opendbc/mazda_2017.dbc b/opendbc/mazda_2017.dbc new file mode 100644 index 00000000000000..e763f153cfb449 --- /dev/null +++ b/opendbc/mazda_2017.dbc @@ -0,0 +1,776 @@ +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_ 117 STEER_RELATED: 8 XXX + SG_ CTR : 7|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_1 : 48|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_2 : 49|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_5 : 50|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_4 : 54|4@0+ (1,0) [0|31] "" XXX + SG_ NEW_SIGNAL_3 : 55|1@0+ (1,0) [0|63] "" XXX + SG_ STEER_ANGLE_2 : 39|16@0+ (0.1,-1800) [0|131071] "" XXX + SG_ STEER_TORQUE : 19|12@0+ (1,-2000) [0|255] "" XXX + +BO_ 118 RPM_RELATED: 8 XXX + SG_ CTR : 7|8@0+ (1,0) [0|127] "" XXX + SG_ NEW_SIGNAL_2 : 19|12@0+ (1,0) [0|4095] "" XXX + +BO_ 514 ENGINE_DATA: 8 XXX + SG_ CHKSUM : 63|8@0+ (1,0) [0|127] "" XXX + SG_ RPM : 7|16@0+ (0.25,0) [0|8500] "rpm" XXX + SG_ SPEED : 23|16@0+ (0.01,0) [0|32767] "kph" XXX + SG_ PEDAL_GAS : 39|12@0+ (1,0) [0|255] "%" XXX + +BO_ 357 PEDALS: 8 XXX + SG_ NEW_SIGNAL_6 : 31|4@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_7 : 8|3@1+ (1,0) [0|7] "" XXX + SG_ ACC_ACTIVE : 3|1@0+ (1,0) [0|1] "" XXX + SG_ ACC_OFF : 2|1@1+ (1,0) [0|15] "" XXX + SG_ CHKSUM : 63|8@0+ (1,0) [0|15] "" XXX + SG_ STANDSTILL : 26|1@0+ (1,0) [0|16777215] "" XXX + SG_ NEW_SIGNAL_3 : 23|8@0+ (1,0) [0|3] "" XXX + SG_ BRAKE_ON : 4|1@0+ (1,0) [0|1] "" XXX + SG_ NO_BRAKE : 6|1@0+ (1,0) [0|7] "" XXX + SG_ BRAKE_ON_2 : 7|1@1+ (1,0) [0|255] "" XXX + SG_ NO_BRAKE_2 : 15|1@0+ (1,0) [0|7] "" XXX + SG_ GEAR : 48|5@1+ (1,0) [0|255] "" XXX + +BO_ 533 WHEEL_SPEEDS: 8 XXX + SG_ FL : 7|16@0+ (0.01,-100) [0|16383] "kph" XXX + SG_ FR : 23|16@0+ (0.01,-100) [0|65535] "kph" XXX + SG_ RL : 39|16@0+ (0.01,-100) [0|15] "kph" XXX + SG_ RR : 55|16@0+ (0.01,-100) [0|65535] "kph" XXX + +BO_ 134 STEER2: 8 XXX + SG_ CTR : 22|4@0+ (1,0) [0|7] "" XXX + SG_ NEW_SIGNAL_4 : 23|1@0+ (1,0) [0|1] "" XXX + SG_ CTR_2 : 28|3@1+ (1,0) [0|7] "" XXX + SG_ STEER_ANGLE_ROUGH : 26|11@0+ (1,-1000) [0|15] "" XXX + SG_ NEW_SIGNAL_5 : 18|3@0+ (1,0) [0|1] "" XXX + SG_ STEER_ANGLE : 7|16@0+ (0.1,-1600) [-500|500] "deg" XXX + SG_ NEW_SIGNAL_1 : 63|2@0+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_3 : 55|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 47|8@0+ (1,0) [0|7] "" XXX + +BO_ 576 STEER_TORQUE: 8 XXX + SG_ NEW_SIGNAL_1 : 23|4@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_3 : 47|1@0+ (1,0) [0|1] "" XXX + SG_ SENSOR1 : 39|8@0+ (1,-128) [0|127] "" XXX + SG_ STEER_TORQUE_MOTOR : 46|15@0- (0.1,0) [-3000|3000] "tbd" XXX + SG_ NEW_SIGNAL_2 : 62|4@0+ (1,0) [0|31] "" XXX + SG_ NEW_SIGNAL_4 : 15|8@0+ (1,0) [0|127] "" XXX + SG_ STEER_TORQUE_SENSOR : 7|8@0+ (1,-127) [-85|85] "" XXX + +BO_ 577 STEER_RATE: 8 XXX + SG_ STEER_ANGLE_RATE : 23|16@0+ (0.25,-8192) [0|1] "deg/s" XXX + SG_ CTR : 7|4@0+ (1,0) [0|15] "" XXX + SG_ LKAS_REQUEST : 3|12@0+ (1,-2048) [0|15] "" XXX + SG_ LKAS_EFFECTIVE : 39|12@0+ (1,-2048) [0|255] "" XXX + SG_ HANDS_OFF_5_SECONDS : 51|1@0+ (1,0) [0|1] "" XXX + SG_ LKAS_BLOCK : 50|1@1+ (1,0) [0|3] "" XXX + SG_ LKAS_TRACK_STATE : 52|1@0+ (1,0) [0|3] "" XXX + SG_ CHKSUM : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 582 CAM_LANEMAYBE: 8 XXX + SG_ NEW_SIGNAL_4 : 40|8@1+ (1,0) [0|127] "" XXX + SG_ NEW_SIGNAL_1 : 31|16@0- (1,0) [0|65535] "" XXX + SG_ NEW_SIGNAL_2 : 55|16@0+ (1,0) [0|65535] "" XXX + SG_ CTR : 7|2@0+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_3 : 15|16@0+ (1,0) [0|65535] "" XXX + +BO_ 541 CAM_EMPTY: 8 XXX + +BO_ 605 CAM_PEDESTRIAN: 8 XXX + SG_ CTR : 17|4@0+ (1,0) [0|255] "" XXX + SG_ AEB_NOT_ENGAGED : 13|1@0+ (1,0) [0|1] "" XXX + SG_ PED_WARNING : 9|1@0+ (1,0) [0|255] "" XXX + SG_ PED_BRAKE : 3|3@0+ (1,0) [0|7] "" XXX + SG_ RST_CTR : 23|6@0+ (1,0) [0|63] "" XXX + SG_ S1 : 29|4@0+ (1,0) [0|31] "" XXX + SG_ BRAKE_WARNING : 25|1@0+ (1,0) [0|1] "" XXX + +BO_ 578 CAM_LANETRACK: 8 XXX + SG_ CHKSUM : 63|8@0+ (1,0) [0|255] "" XXX + SG_ ZERO : 53|6@0+ (1,0) [0|63] "" XXX + SG_ CTR : 7|4@0+ (1,0) [0|15] "" XXX + SG_ LINE2 : 9|10@0+ (1,-686) [0|255] "" XXX + SG_ LANE_CURVE : 31|8@0+ (1,-127) [0|255] "" XXX + SG_ SIG1 : 39|8@0+ (1,-128) [0|255] "" XXX + SG_ SIG2 : 47|8@0+ (1,0) [0|255] "" XXX + SG_ SIG3 : 55|2@0+ (1,0) [0|3] "" XXX + SG_ LINE1 : 3|10@0+ (1,-686) [0|1] "" XXX + +BO_ 579 CAM_LKAS: 8 XXX + SG_ CTR : 7|4@0+ (1,0) [0|15] "" XXX + SG_ ERR_BIT_1 : 16|1@0+ (1,0) [0|1] "" XXX + SG_ CHKSUM : 63|8@0+ (1,0) [0|15] "" XXX + SG_ LINE_NOT_VISIBLE : 19|1@0+ (1,0) [0|1] "" XXX + SG_ BIT_1 : 29|1@0+ (1,0) [0|1] "" XXX + SG_ LDW : 23|1@0+ (1,0) [0|1] "" XXX + SG_ LKAS_REQUEST : 3|12@0+ (1,-2048) [0|2048] "" XXX + SG_ ERR_BIT_2 : 30|1@0+ (1,0) [0|1] "" XXX + SG_ ANGLE_ENABLED : 52|1@0+ (1,0) [0|1] "" XXX + SG_ STEERING_ANGLE : 33|12@0+ (1,-2048) [-2048|2047] "" XXX + +BO_ 580 CAM_DISTANCE: 8 XXX + SG_ S1 : 0|8@1+ (1,0) [0|127] "" XXX + SG_ S2 : 15|8@0+ (1,0) [0|1] "" XXX + SG_ S3 : 16|8@1+ (1,0) [0|3] "" XXX + SG_ S4 : 24|8@1+ (1,0) [0|31] "" XXX + SG_ S5 : 32|8@1+ (1,0) [0|255] "" XXX + SG_ DISTANCE : 47|8@0+ (1,0) [0|65535] "" XXX + SG_ S6 : 55|16@0+ (1,0) [0|255] "" XXX + +BO_ 581 CAM_IDK3: 8 XXX + SG_ S1 : 0|8@1+ (1,0) [0|15] "" XXX + SG_ S2 : 8|6@1+ (1,0) [0|255] "" XXX + SG_ S3 : 15|2@0+ (1,0) [0|3] "" XXX + SG_ S4 : 16|8@1+ (1,0) [0|15] "" XXX + SG_ S5 : 24|8@1+ (1,0) [0|255] "" XXX + SG_ S6 : 32|8@1+ (1,0) [0|255] "" XXX + SG_ S7 : 40|8@1+ (1,0) [0|3] "" XXX + SG_ S8 : 48|8@1+ (1,0) [0|255] "" XXX + SG_ S9 : 56|8@1+ (1,0) [0|255] "" XXX + +BO_ 863 CAM_TRAFFIC_SIGNS: 8 XXX + SG_ STOP_SIGN : 31|4@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_3 : 55|1@0+ (1,0) [0|127] "" XXX + SG_ FORWARD_COLLISION : 40|8@1+ (1,0) [0|7] "" XXX + SG_ SPEED_SIGN : 4|7@0+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_2 : 52|5@0+ (1,0) [0|31] "" XXX + SG_ NEW_SIGNAL_4 : 33|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_1 : 13|2@0+ (1,0) [0|3] "" XXX + SG_ SPEED_SIGN_CAM : 32|1@0+ (1,0) [0|32767] "" XXX + +BO_ 1157 CAM_SETTINGS: 8 XXX + SG_ NEW_SIGNAL_2 : 14|1@0+ (1,0) [0|1] "" XXX + SG_ SBS_WARNING_DISTANCE : 25|2@0+ (1,0) [0|127] "" XXX + SG_ SBS_SCBC : 28|2@0+ (1,0) [0|7] "" XXX + SG_ LKAS_ASSIT_TIMING : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LKAS_SENSETIVITY : 10|1@0+ (1,0) [0|1] "" XXX + SG_ ILKAS_NTERVENTION_ON2 : 17|1@0+ (1,0) [0|255] "" XXX + SG_ LANEE_DEPARTURE_ALERT : 16|2@0+ (1,0) [0|1] "" XXX + SG_ LKAS_INERVENTION_ON1 : 15|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_1 : 12|1@0+ (1,0) [0|7] "" XXX + SG_ WARNING : 11|1@0+ (1,0) [0|1] "" XXX + +BO_ 1160 CAM_Empty3: 8 XXX + SG_ NEW_SIGNAL_1 : 47|24@0+ (1,0) [0|16777215] "" XXX + +BO_ 1088 CAM_LANEINFO: 8 XXX + SG_ BIT3 : 62|1@0+ (1,0) [0|3] "" XXX + SG_ HANDS_ON_STEER_WARN_2 : 59|1@0+ (1,0) [0|1] "" XXX + SG_ HANDS_ON_STEER_WARN : 56|1@0+ (1,0) [0|3] "" XXX + SG_ S1_HBEAM : 54|1@0+ (1,0) [0|31] "" XXX + SG_ S1 : 52|1@0+ (1,0) [0|1] "" XXX + SG_ HANDS_WARN_3_BITS : 51|3@0+ (1,0) [0|7] "" XXX + SG_ ERR_BIT : 40|1@0+ (1,0) [0|1] "" XXX + SG_ NO_ERR_BIT : 14|1@0+ (1,0) [0|1] "" XXX + SG_ BIT2 : 13|1@0+ (1,0) [0|15] "" XXX + SG_ LANE_LINES : 10|3@0+ (1,0) [0|3] "" XXX + SG_ BIT1 : 6|1@0+ (1,0) [0|65535] "" XXX + SG_ LINE_NOT_VISIBLE : 1|1@0+ (1,0) [0|1] "" XXX + SG_ LINE_VISIBLE : 0|1@0+ (1,0) [0|3] "" XXX + SG_ LDW_WARN_RL : 58|1@0+ (1,0) [0|1] "" XXX + SG_ LDW_WARN_LL : 57|1@0+ (1,0) [0|1] "" XXX + +BO_ 1479 NEW_MSG_470: 8 XXX + +BO_ 1456 NEW_MSG_300: 8 XXX + +BO_ 1446 NEW_MSG_a600: 8 XXX + +BO_ 1416 MSG_18: 8 XXX + +BO_ 1086 DOORS: 8 XXX + SG_ LEFTGATE : 32|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_3 : 53|1@0+ (1,0) [0|255] "" XXX + SG_ KEYFOB_HORN : 2|1@0+ (1,0) [0|1] "" XXX + SG_ KEYFOB_LOCK : 3|1@0+ (1,0) [0|1] "" XXX + SG_ KEYFOB_UNLOCK : 4|1@0+ (1,0) [0|1] "" XXX + SG_ CTR1 : 8|4@1+ (1,0) [0|3] "" XXX + SG_ CTR2 : 16|4@1+ (1,0) [0|15] "" XXX + SG_ BR : 34|1@0+ (1,0) [0|1] "" XXX + SG_ BL : 35|1@0+ (1,0) [0|1] "" XXX + SG_ FR : 36|1@0+ (1,0) [0|1] "" XXX + SG_ FL : 37|1@0+ (1,0) [0|255] "" XXX + SG_ DOORS_UNLOCKED : 30|1@0+ (1,0) [0|255] "" XXX + +BO_ 977 TWO_STATES: 8 XXX + SG_ NEW_SIGNAL_1 : 50|1@1+ (1,0) [0|7] "" XXX + SG_ NEW_SIGNAL_2 : 56|4@1+ (1,0) [0|7] "" XXX + SG_ NEW_SIGNAL_3 : 28|1@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 24|4@1+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_5 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_6 : 36|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_7 : 47|8@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_8 : 51|1@0+ (1,0) [0|1] "" XXX + +BO_ 1085 MSG_12: 8 XXX + SG_ NEW_SIGNAL_3 : 36|1@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_1 : 16|8@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_2 : 48|8@1+ (1,0) [0|65535] "" XXX + SG_ NEW_SIGNAL_4 : 31|1@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_5 : 24|1@0+ (1,0) [0|127] "" XXX + SG_ NEW_SIGNAL_6 : 40|3@1+ (1,0) [0|7] "" XXX + +BO_ 159 MSG_11: 8 XXX + SG_ NEW_SIGNAL_1 : 50|4@1+ (1,0) [0|15] "" XXX + SG_ INCREASEING : 39|8@0+ (1,0) [0|255] "" XXX + +BO_ 1278 NEW_MSG_3: 8 XXX + SG_ NEW_SIGNAL_2 : 23|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_3 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 39|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_5 : 47|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_6 : 55|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_7 : 63|8@0+ (1,0) [0|255] "" XXX + SG_ MILAGE_MAYBE : 7|16@0+ (1,0) [0|255] "" XXX + +BO_ 1277 NEW_MSG_10: 8 XXX + SG_ NEW_SIGNAL_3 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 15|8@0+ (1,0) [0|255] "" XXX + SG_ counter : 7|8@0+ (1,0) [0|255] "" XXX + +BO_ 1275 2017_5: 8 XXX + SG_ counter : 4|5@0+ (1,0) [0|255] "" XXX + +BO_ 1274 NEW_MSG_12: 8 XXX + SG_ NEW_SIGNAL_1 : 24|4@1+ (1,0) [0|15] "" XXX + SG_ CTR : 55|4@0+ (1,0) [0|63] "" XXX + SG_ NEW_SIGNAL_2 : 35|1@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_3 : 32|3@1+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_4 : 48|4@1+ (1,0) [0|7] "" XXX + +BO_ 1180 last_byte_roughRPM: 8 XXX + SG_ NEW_SIGNAL_1 : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 1078 HVAC: 8 XXX + SG_ NEW_SIGNAL_1 : 2|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_2 : 8|1@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_3 : 23|1@0+ (1,0) [0|65535] "" XXX + SG_ NEW_SIGNAL_4 : 56|5@0+ (1,0) [0|255] "" XXX + +BO_ 1056 CHECK_AND_TEMP: 8 XXX + SG_ NEW_SIGNAL_1 : 29|6@0+ (1,0) [0|255] "" XXX + SG_ counter_or_GEAR : 15|8@0+ (1,0) [0|255] "" XXX + SG_ CTR : 23|8@0+ (1,0) [0|255] "" XXX + SG_ STANDSTILL : 32|1@0+ (1,0) [0|255] "" XXX + SG_ COOLANT_TEMP : 7|8@0+ (1,0) [0|255] "" XXX + SG_ LOW_ENGINE_OIL_PRESSURE : 43|1@0+ (1,0) [0|1] "" XXX + SG_ CHECK_FUEL_CAP : 40|1@0+ (1,0) [0|1] "" XXX + SG_ CHARGING_SYSTEM_MALFUNCTION : 38|1@0+ (1,0) [0|1] "" XXX + SG_ OUTDOOR_TEMP : 63|8@0+ (0.25,-63) [0|255] "cel" XXX + +BO_ 1045 TRACTION: 8 XXX + SG_ NEW_SIGNAL_2 : 20|1@0+ (1,0) [0|3] "" XXX + SG_ CTR2 : 19|4@0+ (1,0) [0|31] "" XXX + SG_ CTR3 : 8|4@1+ (1,0) [0|15] "" XXX + SG_ IS_MOVING : 12|1@0+ (1,0) [0|3] "" XXX + SG_ CTR1 : 53|6@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_1 : 54|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE : 55|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_WARNING : 2|1@0+ (1,0) [0|1] "" XXX + SG_ ABS_MALFUNCTION : 1|2@0+ (1,0) [0|3] "" XXX + SG_ DSC_OFF : 3|1@0+ (1,0) [0|1] "" XXX + SG_ TCS_DCS_MALFUNCTION : 6|2@0+ (1,0) [0|3] "" XXX + SG_ LOUD_BEEP : 28|1@0+ (1,0) [0|1] "" XXX + SG_ TPMS_WARNING_DOUBLE_BLINK : 31|1@0+ (1,0) [0|1] "" XXX + +BO_ 1034 MSG_07: 8 XXX + SG_ NEW_SIGNAL_1 : 6|3@0+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_2 : 0|4@1+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_3 : 15|4@0+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_4 : 63|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_5 : 23|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_6 : 55|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_7 : 47|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_8 : 39|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_9 : 31|8@0+ (1,0) [0|255] "" XXX + +BO_ 870 NEW_MSG_16: 8 XXX + SG_ NEW_SIGNAL_1 : 7|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 15|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_3 : 23|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_5 : 39|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_6 : 47|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_7 : 55|8@0+ (1,0) [0|255] "" XXX + +BO_ 867 NEW_MSG_17: 8 XXX + SG_ NEW_SIGNAL_1 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 23|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_3 : 15|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 7|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_5 : 39|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_6 : 47|8@0+ (1,0) [0|255] "" XXX + SG_ CTR : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 130 STEER: 8 XXX + SG_ NEW_SIGNAL_5 : 55|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_6 : 63|8@0+ (1,0) [0|255] "" XXX + SG_ CTR : 47|4@0+ (1,0) [0|255] "" XXX + SG_ STEER_ANGLE : 23|16@0+ (0.05,-1600) [500|-500] "deg" XXX + SG_ CHKSUM_MAYBE : 39|8@0+ (1,0) [0|255] "" XXX + +BO_ 120 BRAKE: 8 XXX + SG_ NEW_SIGNAL_1 : 7|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 15|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_3 : 23|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ CTR : 55|8@0+ (1,0) [0|255] "" XXX + SG_ BRAKE_PRESSURE : 39|8@0+ (1,0) [0|255] "" XXX + +BO_ 304 GEAR_RELATED: 8 XXX + SG_ NEW_SIGNAL_1 : 55|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 47|8@0+ (1,0) [0|255] "" XXX + +BO_ 865 NEW_MSG_5: 8 XXX + SG_ SPEED_INVERSE : 55|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_1 : 47|1@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_3 : 40|1@0+ (1,0) [0|1] "" XXX + SG_ IS_MOVING : 43|3@0+ (1,0) [0|127] "" XXX + SG_ NEW_SIGNAL_2 : 46|1@0+ (1,0) [0|7] "" XXX + SG_ NEW_SIGNAL_4 : 44|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_7 : 23|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_8 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_10 : 39|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_6 : 15|3@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_5 : 7|8@0+ (1,0) [0|255] "" XXX + SG_ CTR : 56|4@1+ (1,0) [0|15] "" XXX + +BO_ 836 NEW_MSG_19: 8 XXX + SG_ CTR : 48|4@1+ (1,0) [0|15] "" XXX + SG_ CTR2 : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 832 SEATBELT: 8 XXX + SG_ NEW_SIGNAL_1 : 7|8@0+ (1,0) [0|255] "" XXX + SG_ PASSENGER_SEATBELT : 26|1@1+ (1,0) [0|7] "" XXX + SG_ CTR1 : 15|4@0+ (1,0) [0|15] "" XXX + SG_ CTR2 : 23|4@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 8|4@1+ (1,0) [0|3] "" XXX + SG_ DRIVER_SEATBELT : 27|1@0+ (1,0) [0|1] "" XXX + +BO_ 866 NEW_MSG_21: 8 XXX + SG_ NEW_SIGNAL_2 : 7|8@0+ (1,0) [0|131071] "" XXX + SG_ NEW_SIGNAL_1 : 15|8@0+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_3 : 55|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 47|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_5 : 39|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_6 : 27|4@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_7 : 23|8@0+ (1,0) [0|255] "" XXX + SG_ CTR : 59|4@0+ (1,0) [0|15] "" XXX + +BO_ 158 MSG_05: 8 XXX + SG_ NEW_SIGNAL_1 : 23|8@0+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_2 : 47|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_3 : 55|8@0+ (1,0) [0|255] "" XXX + +BO_ 157 CRZ_BTNS: 8 XXX + SG_ BIT1 : 16|1@0+ (1,0) [0|1] "" XXX + SG_ BIT2 : 18|1@0+ (1,0) [0|1] "" XXX + SG_ BIT3 : 20|1@0+ (1,0) [0|1] "" XXX + SG_ SET_P_INV : 21|1@0+ (1,0) [0|1] "" XXX + SG_ CAN_OFF_INV : 17|1@0+ (1,0) [0|1] "" XXX + SG_ CAN_OFF : 0|1@0+ (1,0) [0|1] "" XXX + SG_ SET_M_INV : 22|1@0+ (1,0) [0|1] "" XXX + SG_ SET_M : 5|1@0+ (1,0) [0|1] "" XXX + SG_ SET_P : 4|1@0+ (1,0) [0|1] "" XXX + SG_ RES_INV : 19|1@0+ (1,0) [0|1] "" XXX + SG_ RES : 2|1@0+ (1,0) [0|1] "" XXX + SG_ DISTANCE_LESS : 7|1@0+ (1,0) [0|1] "" XXX + SG_ DISTANCE_LESS_INV : 8|1@0+ (1,0) [0|1] "" XXX + SG_ DISTANCE_MORE : 6|1@0+ (1,0) [0|1] "" XXX + SG_ DISTANCE_MORE_INV : 23|1@0+ (1,0) [0|1] "" XXX + SG_ MODE_Y : 13|1@0+ (1,0) [0|1] "" XXX + SG_ MODE_X : 14|1@0+ (1,0) [0|1] "" XXX + SG_ MODE_Y_INV : 30|1@0+ (1,0) [0|1] "" XXX + SG_ MODE_X_INV : 31|1@0+ (1,0) [0|1] "" XXX + SG_ CTR : 29|4@0+ (1,0) [0|15] "" XXX + +BO_ 154 BLINK_INFO: 8 XXX + SG_ LEFT_BLINK : 18|1@1+ (1,0) [0|3] "" XXX + SG_ RIGHT_BLINK : 19|1@0+ (1,0) [0|255] "" XXX + SG_ REAR_WIPER_ON : 0|1@0+ (1,0) [0|1] "" XXX + SG_ WIPER_LO : 33|1@1+ (1,0) [0|31] "" XXX + SG_ WIPER_HI : 34|1@0+ (1,0) [0|1] "" XXX + SG_ LOW_BEAMS : 5|2@0+ (1,0) [0|3] "" XXX + SG_ HIGH_BEAMS : 7|2@0+ (1,0) [0|3] "" XXX + SG_ LBEAM1 : 17|1@0+ (1,0) [0|1] "" XXX + SG_ LBEAM2 : 50|1@0+ (1,0) [0|1] "" XXX + SG_ LBEAM3 : 60|1@0+ (1,0) [0|1] "" XXX + +BO_ 145 TURN_SWITCH: 8 XXX + SG_ HAZARD : 10|1@0+ (1,0) [0|1] "" XXX + SG_ TURN_RIGHT_SWITCH : 12|1@0+ (1,0) [0|3] "" XXX + SG_ TURN_LEFT_SWITCH : 13|1@0+ (1,0) [0|255] "" XXX + SG_ CTR : 27|4@0+ (1,0) [0|255] "" XXX + SG_ CHKSUM : 39|8@0+ (1,0) [0|15] "" XXX + +BO_ 80 MSG_04: 8 XXX + SG_ NEW_SIGNAL_1 : 25|1@0+ (1,0) [0|1] "" XXX + SG_ SIGNAL : 24|1@0+ (1,0) [0|1] "" XXX + +BO_ 978 MSG_03: 8 XXX + SG_ NEW_SIGNAL_2 : 15|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_3 : 23|8@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_4 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_5 : 39|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_6 : 47|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_7 : 55|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_8 : 63|8@0+ (1,0) [0|255] "" XXX + SG_ CTR : 1|2@0+ (1,0) [0|255] "" XXX + +BO_ 607 NEW_MSG_25: 8 XXX + +BO_ 1115 MSG_02: 8 XXX + SG_ NEW_SIGNAL_2 : 15|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_1 : 47|16@0+ (1,0) [0|65535] "" XXX + SG_ NEW_SIGNAL_3 : 63|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_4 : 23|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_5 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_6 : 39|8@0+ (1,0) [0|255] "" XXX + SG_ CTR : 2|3@0+ (1,0) [0|255] "" XXX + +BO_ 1067 NEW_MSG_27: 8 XXX + SG_ NEW_SIGNAL_2 : 3|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_4 : 0|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_1 : 2|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_5 : 1|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_3 : 12|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_6 : 11|1@1+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_7 : 10|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_8 : 9|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_9 : 8|1@0+ (1,0) [0|1] "" XXX + +BO_ 358 NEW_MSG_28: 8 XXX + +BO_ 608 NEW_MSG_29: 8 XXX + SG_ NEW_SIGNAL_1 : 8|5@1+ (1,0) [0|7] "" XXX + +BO_ 606 SPEED_TBD: 8 XXX + SG_ SPEED_TBD : 7|12@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_1 : 23|12@0- (1,0) [0|65535] "" XXX + +BO_ 552 GEAR: 8 XXX + SG_ NEW_SIGNAL_3 : 11|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_5 : 26|3@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_6 : 31|5@0+ (1,0) [0|31] "" XXX + SG_ NEW_SIGNAL_7 : 39|1@0+ (1,0) [0|255] "" XXX + SG_ MORE_GEAR : 7|4@0+ (1,0) [0|15] "" XXX + SG_ GEAR : 2|3@0+ (1,0) [0|7] "" XXX + SG_ GEAR_BOX : 36|4@0+ (1,0) [0|15] "" XXX + +BO_ 543 CRZ_EVENTS: 8 XXX + SG_ NEW_SIGNAL_3 : 34|1@0+ (1,0) [0|1] "" XXX + SG_ CHKSUM : 63|8@0+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_1 : 55|4@0+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_5 : 47|4@0+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_6 : 6|1@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_8 : 0|1@0+ (1,0) [0|31] "" XXX + SG_ NEW_SIGNAL_9 : 1|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_10 : 2|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_12 : 10|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_13 : 9|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_18 : 12|1@0+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_19 : 14|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_20 : 15|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_21 : 23|1@0+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_24 : 31|1@0+ (1,0) [0|1] "" XXX + SG_ GAS_PEDAL_PRESSED : 32|1@0+ (1,0) [0|255] "" XXX + SG_ CRZ_STARTED : 18|1@0+ (1,0) [0|1] "" XXX + SG_ PLUS_ONE_CRZ : 17|1@0+ (1,0) [0|255] "" XXX + SG_ PLUS_ONE_CRZ_2 : 19|1@0+ (1,0) [0|1] "" XXX + SG_ GAS_MAYBE : 22|1@0+ (1,0) [0|1] "" XXX + SG_ NONACC_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX + SG_ CRUISE_ACTIVE_CAR_MOVING : 16|1@0+ (1,0) [0|1] "" XXX + SG_ NONACC_RELATED : 11|1@0+ (1,0) [0|255] "" XXX + SG_ CTR : 51|4@0+ (1,0) [0|15] "" XXX + SG_ CAS_CMD_MAYBE : 30|7@0- (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 43|4@0+ (1,0) [0|255] "" XXX + +BO_ 542 NEW_MSG_33: 8 XXX + SG_ CTR : 48|4@1+ (1,0) [0|15] "" XXX + SG_ CTR2 : 56|4@1+ (1,0) [0|15] "" XXX + +BO_ 868 NEW_MSG_34: 8 XXX + SG_ CTR : 59|4@0+ (1,0) [0|255] "" XXX + +BO_ 869 NEW_MSG_35: 8 XXX + SG_ NEW_SIGNAL_1 : 7|4@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_3 : 23|16@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 39|16@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 55|2@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_5 : 50|4@1+ (1,0) [0|15] "" XXX + SG_ CTR : 59|4@0+ (1,0) [0|255] "" XXX + +BO_ 1114 NEW_MSG_4: 8 XXX + +BO_ 535 CURVE_CTRS: 8 XXX + SG_ CTR_A_1 : 4|3@0+ (1,0) [0|31] "" XXX + SG_ CTR_A_2 : 7|3@0+ (1,0) [0|255] "" XXX + SG_ CTR_B_1 : 12|3@0+ (1,0) [0|7] "" XXX + SG_ CTR_B_2 : 15|3@0+ (1,0) [0|7] "" XXX + SG_ CTR_C_1 : 20|3@0+ (1,0) [0|7] "" XXX + SG_ CTR_C_2 : 23|3@0+ (1,0) [0|255] "" XXX + SG_ CTR_D_2 : 31|3@0+ (1,0) [0|7] "" XXX + SG_ CTR_D_1 : 28|3@0+ (1,0) [0|7] "" XXX + SG_ SPEED : 39|16@0+ (0.01,0) [0|7] "kph" XXX + SG_ CTR : 55|8@0+ (1,0) [0|255] "" XXX + SG_ CHK_MAYBE : 63|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_1 : 0|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_2 : 1|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_6 : 17|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_7 : 24|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_8 : 25|1@0+ (1,0) [0|1] "" XXX + SG_ SEATBELT_MAYBE : 8|1@0+ (1,0) [0|1] "" XXX + SG_ NO_SEATBELT_MAYBE : 16|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_4 : 9|1@0+ (1,0) [0|1] "" XXX + +BO_ 540 CRZ_CTRL: 8 XXX + SG_ NEW_SIGNAL_3 : 1|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_4 : 8|1@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_5 : 9|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_6 : 10|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_7 : 18|3@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_9 : 31|1@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_10 : 30|1@0+ (1,0) [0|1] "" XXX + SG_ ACC_GAS_MAYBE : 23|1@0+ (1,0) [0|31] "" XXX + SG_ ACC_GAS_MAYBE2 : 29|1@0+ (1,0) [0|1] "" XXX + SG_ CRZ_ACTIVE : 3|1@0+ (1,0) [0|1] "" XXX + SG_ HANDS_OFF_STEERING : 48|1@0+ (1,0) [0|1] "" XXX + SG_ HANDS_ON_STEER_WARN : 59|4@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_1 : 52|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_2 : 45|3@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_8 : 0|1@0+ (1,0) [0|1] "" XXX + +BO_ 539 CRZ_INFO: 8 XXX + SG_ NEW_SIGNAL_1 : 17|1@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 16|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_5 : 34|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_7 : 47|1@0+ (1,0) [0|255] "" XXX + SG_ CTR1 : 55|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_3 : 37|1@0+ (1,0) [0|255] "" XXX + SG_ ACC_ACTIVE : 33|1@0+ (1,0) [0|1] "" XXX + SG_ ACCEL_CMD : 31|10@0- (1,0) [0|1] "" XXX + SG_ CHKSUM : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 121 EPB: 8 XXX + SG_ NEW_SIGNAL_1 : 4|4@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 0|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_3 : 15|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 25|2@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_6 : 39|8@0+ (1,0) [0|255] "" XXX + SG_ CTR : 55|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_7 : 63|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_8 : 41|2@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_9 : 47|1@0+ (1,0) [0|63] "" XXX + SG_ NEW_SIGNAL_10 : 46|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_11 : 45|1@0+ (1,0) [0|1] "" XXX + SG_ EPB_ACTIVE : 29|1@0+ (1,0) [0|15] "" XXX + +BO_ 1070 2017_1: 8 XXX + +BO_ 1183 2017_2: 8 XXX + +BO_ 1243 2017_3: 8 XXX + SG_ NEW_SIGNAL_1 : 7|64@0+ (1,0) [0|18446744073709552000] "" XXX + +BO_ 1269 MSG_2017_4: 8 XXX + SG_ NEW_SIGNAL_1 : 55|16@0+ (1,0) [0|18446744073709552000] "" XXX + +BO_ 1178 2017_6: 8 XXX + SG_ NEW_SIGNAL_1 : 7|64@0+ (1,0) [0|18446744073709552000] "" XXX + +BO_ 1179 2017_7: 8 XXX + SG_ NEW_SIGNAL_1 : 7|64@0+ (1,0) [0|18446744073709552000] "" XXX + +BO_ 1435 2017_8: 8 XXX + +BO_ 253 GAS: 8 XXX + SG_ NEW_SIGNAL_1 : 16|1@0+ (1,0) [0|65535] "" XXX + SG_ CTR : 23|4@0+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_2 : 41|1@0+ (1,0) [0|255] "" XXX + SG_ CRZ_NOT_ACTIVE : 61|1@0+ (1,0) [0|255] "" XXX + SG_ GAS_CMD : 55|8@0+ (1,0) [0|255] "" XXX + +BO_ 359 MORE_GAS: 8 XXX + SG_ NEW_SIGNAL_1 : 15|1@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 7|8@0+ (1,0) [0|255] "" XXX + SG_ CTR : 31|4@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_3 : 36|5@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 38|1@1+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_5 : 37|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_6 : 47|4@0+ (1,0) [0|255] "" XXX + +BO_ 512 NEW_MSG_30: 8 XXX + SG_ NEW_SIGNAL_1 : 6|7@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 7|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_3 : 15|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 23|1@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_5 : 22|7@0+ (1,0) [0|127] "" XXX + SG_ NEW_SIGNAL_6 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_7 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_8 : 38|7@0+ (1,0) [0|127] "" XXX + SG_ NEW_SIGNAL_9 : 40|4@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_10 : 47|4@0+ (1,0) [0|15] "" XXX + SG_ CTR : 51|3@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_11 : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 515 MSG_01: 8 XXX + SG_ CTR : 39|4@0+ (1,0) [0|65535] "" XXX + SG_ CHKSUM : 47|8@0+ (1,0) [0|255] "" XXX + SG_ START1 : 6|1@0+ (1,0) [0|1] "" XXX + SG_ START2 : 28|5@0+ (1,0) [0|255] "" XXX + +BO_ 529 NEW_MSG_36: 8 XXX + SG_ NEW_SIGNAL_1 : 22|5@0+ (1,0) [0|65535] "" XXX + SG_ NEW_SIGNAL_2 : 31|8@0+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_3 : 32|4@1+ (1,0) [0|3] "" XXX + SG_ CTR : 39|4@0+ (1,0) [0|255] "" XXX + SG_ CTR_2 : 47|4@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 40|4@1+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_5 : 53|1@0+ (1,0) [0|255] "" XXX + +BO_ 1242 NEW_MSG_37: 8 XXX + +BO_ 1266 MSG_09: 8 XXX + SG_ NEW_SIGNAL_1 : 20|1@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 19|4@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_3 : 31|1@0+ (1,0) [0|255] "" XXX + +BO_ 976 MSG_15: 8 XXX + SG_ NEW_SIGNAL_1 : 55|1@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 61|6@0+ (1,0) [0|1] "" XXX + +BO_ 155 MSG_14: 8 XXX + +BO_ 1267 MSG_10: 8 XXX + SG_ NEW_SIGNAL_1 : 40|1@0+ (1,0) [0|16777215] "" XXX + SG_ NEW_SIGNAL_2 : 42|1@0+ (1,0) [0|1] "" XXX + +BO_ 305 NEW_MSG_6: 8 XXX + SG_ NEW_SIGNAL_1 : 8|1@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 9|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_3 : 10|1@0+ (1,0) [0|1] "" XXX + +BO_ 1238 TEMPERATURE: 8 XXX + SG_ TEMPERATURE_MAYBE : 47|8@0+ (1,0) [0|4294967295] "" XXX + +BO_ 1087 NEW_MSG_1: 8 XXX + SG_ NEW_SIGNAL_1 : 7|8@0+ (1,0) [0|255] "" XXX + +BO_ 1143 BSM: 8 XXX + SG_ BSM_OFF : 0|1@0+ (1,0) [0|1] "" XXX + SG_ RIGHT_BS_3 : 37|1@0+ (1,0) [0|1] "" XXX + SG_ STANDSTILL : 8|1@0+ (1,0) [0|1] "" XXX + SG_ LEFT_BS1 : 12|1@0+ (1,0) [0|1] "" XXX + SG_ LEFT_BS3 : 38|1@0+ (1,0) [0|1] "" XXX + SG_ RIGHT_BS4 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ LEFT_BS_SIDE : 36|1@0+ (1,0) [0|1] "" XXX + SG_ IS_MOVING : 9|1@0+ (1,0) [0|1] "" XXX + SG_ LEFT_BS_BEHIND : 46|2@1+ (1,0) [0|16777215] "" XXX + SG_ RIGHT_BS1 : 14|1@0+ (1,0) [0|63] "" XXX + SG_ RIGHT_BS_DISTANCE : 35|3@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_1 : 32|1@0+ (1,0) [0|1] "" XXX + SG_ REAR_CT_ALERT : 23|5@0+ (1,0) [0|63] "" XXX + +BO_ 1361 KEY_POSITION: 8 XXX + +BO_ 1283 KEY_POSITION2: 8 XXX + +BO_ 628 MSG_06: 8 XXX + +BO_ 1154 MSG_08: 8 XXX + +BO_ 1139 MSG_13: 8 XXX + +BO_ 1270 MSG_16: 8 XXX + +BO_ 1272 MSG_17: 8 XXX + +BO_ 1425 MSG_19: 8 XXX + +BO_ 70 MOB1: 8 XXX + SG_ NEW_SIGNAL_1 : 1|3@1+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_2 : 14|6@0+ (1,0) [0|127] "" XXX + SG_ NEW_SIGNAL_3 : 23|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 30|6@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_5 : 38|6@0+ (1,0) [0|7] "" XXX + +BO_ 64 MOB2: 8 XXX + SG_ NEW_SIGNAL_1 : 7|2@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_2 : 10|3@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_3 : 16|1@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_4 : 24|1@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_5 : 35|4@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_6 : 0|3@1+ (1,0) [0|7] "" XXX + SG_ NEW_SIGNAL_7 : 13|3@0+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_8 : 15|2@0+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_9 : 19|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_10 : 31|6@0+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_11 : 37|1@0+ (1,0) [0|1] "" XXX + +BO_ 1171 MOB3: 8 XXX + +BO_ 1248 MOB4: 8 XXX + + + + +CM_ SG_ 357 GEAR "13P, 26R, 13N, 24D"; +CM_ SG_ 605 PED_BRAKE "3: no brake, 4: brake"; +CM_ SG_ 605 BRAKE_WARNING "Flashing brake warning and audible alert for potential forward collision"; +CM_ SG_ 579 STEERING_ANGLE "steering angle aligns with 0.022 factor and -45.06 offset"; +CM_ SG_ 863 SPEED_SIGN "speed limit in MPH"; +CM_ SG_ 863 SPEED_SIGN_CAM "1: The speed limit is recognized by the camera. 0: speed limit is map based or is not available"; +CM_ SG_ 1157 SBS_WARNING_DISTANCE "1 far, 2 mid, 3 near"; +CM_ SG_ 1157 SBS_SCBC "1 off, 2 on"; +CM_ SG_ 1157 LKAS_ASSIT_TIMING "1 at, 0 before"; +CM_ SG_ 1157 LKAS_SENSETIVITY "0 low, 1 high"; +CM_ SG_ 1157 LANEE_DEPARTURE_ALERT "1 off, 2 on"; +CM_ SG_ 1157 WARNING "1 Rare, 0 often"; +CM_ SG_ 1088 LANE_LINES "0 LKAS disabled, 1 no lines, 2 two lines, 3 left line, 4 right line"; +CM_ SG_ 1045 ABS_MALFUNCTION "off: 0, solid: 1, slow blink: 2, fast blink: 3"; +CM_ SG_ 157 CAN_OFF "Disengage Cruise if enabled, if already disabled TURN it OFF "; +CM_ SG_ 552 MORE_GEAR ""; +CM_ SG_ 552 GEAR "0 Shifting, 1 P, 2 R, 3 N, 4 D"; +CM_ SG_ 552 GEAR_BOX "0 P, 14 R, 1 though 6 D for speeds, 15 Shift"; +CM_ SG_ 540 HANDS_ON_STEER_WARN "0 no warning, b warning"; +CM_ SG_ 1143 REAR_CT_ALERT "Rear Cross Traffic Alert"; +VAL_ 552 GEAR 1 "P" 2 "R" 3 "N" 4 "D"; diff --git a/opendbc/mazda_cx5_gt_2017.dbc b/opendbc/mazda_cx5_gt_2017.dbc deleted file mode 100644 index 3926e2dfb7a456..00000000000000 --- a/opendbc/mazda_cx5_gt_2017.dbc +++ /dev/null @@ -1,694 +0,0 @@ -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_ 117 STEER_RELATED: 8 XXX - SG_ CTR : 7|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_1 : 48|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_2 : 49|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_3 : 55|1@0+ (1,0) [0|63] "" XXX - SG_ NEW_SIGNAL_4 : 54|4@0+ (1,0) [0|31] "" XXX - SG_ NEW_SIGNAL_5 : 50|1@0+ (1,0) [0|1] "" XXX - SG_ STEER_TORQUE : 19|12@0+ (1,0) [0|255] "" XXX - SG_ STEER_ANGLE_2 : 39|16@0+ (1,0) [0|131071] "" XXX - -BO_ 118 RPM_RELATED: 8 XXX - SG_ CTR : 7|8@0+ (1,0) [0|127] "" XXX - SG_ NEW_SIGNAL_2 : 19|12@0+ (1,0) [0|4095] "" XXX - -BO_ 514 ENGINE_DATA: 8 XXX - SG_ RPM : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ CHKSUM : 56|8@1+ (1,0) [0|127] "" XXX - SG_ SPEED : 23|16@0+ (0.01,0) [0|32767] "KPH" XXX - SG_ PEDAL_GAS : 39|12@0+ (1,0) [0|255] "" XXX - -BO_ 357 PEDALS: 8 XXX - SG_ NEW_SIGNAL_6 : 31|4@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_7 : 8|3@1+ (1,0) [0|7] "" XXX - SG_ ACC_ACTIVE : 3|1@0+ (1,0) [0|1] "" XXX - SG_ ACC_OFF : 2|1@1+ (1,0) [0|15] "" XXX - SG_ CHKSUM : 63|8@0+ (1,0) [0|15] "" XXX - SG_ STANDSTILL : 26|1@0+ (1,0) [0|16777215] "" XXX - SG_ NEW_SIGNAL_3 : 23|8@0+ (1,0) [0|3] "" XXX - SG_ GEAR : 48|5@1+ (1,0) [0|255] "" XXX - SG_ BRAKE_ON : 4|1@0+ (1,0) [0|1] "" XXX - SG_ NO_BRAKE : 6|1@0+ (1,0) [0|7] "" XXX - SG_ BRAKE_ON_2 : 7|1@1+ (1,0) [0|255] "" XXX - SG_ NO_BRAKE_2 : 15|1@0+ (1,0) [0|7] "" XXX - -BO_ 533 WHEEL_SPEEDS: 8 XXX - SG_ FL : 7|16@0+ (0.01,-100) [0|16383] "" XXX - SG_ RL : 39|16@0+ (0.01,-100) [0|15] "" XXX - SG_ RR : 55|16@0+ (0.01,-100) [0|65535] "" XXX - SG_ FR : 23|16@0+ (0.01,-100) [0|65535] "" XXX - -BO_ 134 STEER2: 8 XXX - SG_ NEW_SIGNAL_2 : 48|3@1+ (1,0) [0|7] "" XXX - SG_ CTR : 22|4@0+ (1,0) [0|7] "" XXX - SG_ NEW_SIGNAL_4 : 23|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_5 : 18|3@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_7 : 24|3@1+ (1,0) [0|7] "" XXX - SG_ CTR_2 : 28|3@1+ (1,0) [0|7] "" XXX - SG_ NEW_SIGNAL_1 : 63|2@0+ (1,0) [0|255] "" XXX - SG_ STEER_ANGLE : 7|16@0+ (0.1,-1600) [-500|500] "deg" XXX - SG_ STEER_ANGLE_ROUGH : 39|8@0- (1,0) [0|15] "" XXX - -BO_ 576 STEER_TORQUE: 8 XXX - SG_ NEW_SIGNAL_2 : 39|8@0+ (1,0) [0|127] "" XXX - SG_ NEW_SIGNAL_1 : 20|4@1+ (1,0) [0|255] "" XXX - SG_ STEER_TORQUE_SENSOR : 7|16@0+ (0.5,-15000) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 47|1@0+ (1,0) [0|1] "" XXX - SG_ STEER_TORQUE_MOTOR : 46|20@0- (0.01,0) [-3000|3000] "deg/s" XXX - -BO_ 577 STEER_RATE: 8 XXX - SG_ STEER_ANGLE_RATE : 23|16@0+ (0.25,-8192) [0|1] "deg/s" XXX - SG_ CTR : 7|4@0+ (1,0) [0|15] "" XXX - SG_ LKAS_REQUEST : 3|12@0+ (1,-2048) [0|15] "" XXX - SG_ LKAS_EFFECTIVE : 39|12@0+ (1,-2048) [0|255] "" XXX - SG_ HANDS_OFF_5_SECONDS : 51|1@0+ (1,0) [0|1] "" XXX - SG_ LKAS_BLOCK : 50|1@1+ (1,0) [0|3] "" XXX - SG_ LKAS_TRACK_STATE : 52|1@0+ (1,0) [0|3] "" XXX - SG_ CHKSUM : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 582 CAM_LANEMAYBE: 8 XXX - SG_ NEW_SIGNAL_4 : 40|8@1+ (1,0) [0|127] "" XXX - SG_ NEW_SIGNAL_1 : 31|16@0- (1,0) [0|65535] "" XXX - SG_ NEW_SIGNAL_2 : 55|16@0+ (1,0) [0|65535] "" XXX - SG_ CTR : 7|2@0+ (1,0) [0|3] "" XXX - -BO_ 541 CAM_EMPTY: 8 XXX - -BO_ 605 CAM_PEDESTRIAN: 8 XXX - SG_ CTR : 17|4@0+ (1,0) [0|255] "" XXX - SG_ AEB_NOT_ENGAGED : 13|1@0+ (1,0) [0|1] "" XXX - SG_ PED_WARNING : 9|1@0+ (1,0) [0|255] "" XXX - SG_ PED_BRAKE : 3|3@0+ (1,0) [0|7] "" XXX - SG_ RST_CTR : 23|6@0+ (1,0) [0|63] "" XXX - SG_ S1 : 29|4@0+ (1,0) [0|31] "" XXX - -BO_ 578 CAM_LANETRACK: 8 XXX - SG_ CHKSUM : 63|8@0+ (1,0) [0|255] "" XXX - SG_ ZERO : 53|6@0+ (1,0) [0|63] "" XXX - SG_ CTR : 7|4@0+ (1,0) [0|15] "" XXX - SG_ LINE2 : 9|10@0+ (1,-686) [0|255] "" XXX - SG_ LANE_CURVE : 31|8@0+ (1,-127) [0|255] "" XXX - SG_ SIG1 : 39|8@0+ (1,-128) [0|255] "" XXX - SG_ SIG2 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ SIG3 : 55|2@0+ (1,0) [0|3] "" XXX - SG_ LINE1 : 3|10@0+ (1,-686) [0|1] "" XXX - -BO_ 579 CAM_LKAS: 8 XXX - SG_ LKAS_REQUEST : 3|12@0+ (1,-2048) [0|2048] "" XXX - SG_ CTR : 7|4@0+ (1,0) [0|15] "" XXX - SG_ ERR_BIT_1 : 16|1@0+ (1,0) [0|1] "" XXX - SG_ CHKSUM : 63|8@0+ (1,0) [0|15] "" XXX - SG_ LINE_NOT_VISIBLE : 19|1@0+ (1,0) [0|1] "" XXX - SG_ BIT_1 : 29|1@0+ (1,0) [0|1] "" XXX - SG_ BIT_2 : 33|1@0+ (1,0) [0|1] "" XXX - SG_ ERR_BIT_2 : 30|1@0+ (1,0) [0|1] "" XXX - -BO_ 580 CAM_DISTANCE: 8 XXX - SG_ S1 : 0|8@1+ (1,0) [0|127] "" XXX - SG_ S2 : 15|8@0+ (1,0) [0|1] "" XXX - SG_ S3 : 16|8@1+ (1,0) [0|3] "" XXX - SG_ S4 : 24|8@1+ (1,0) [0|31] "" XXX - SG_ S5 : 32|8@1+ (1,0) [0|255] "" XXX - SG_ DISTANCE : 47|8@0+ (1,0) [0|65535] "" XXX - SG_ S6 : 55|16@0+ (1,0) [0|255] "" XXX - -BO_ 581 CAM_IDK3: 8 XXX - SG_ S1 : 0|8@1+ (1,0) [0|15] "" XXX - SG_ S2 : 8|6@1+ (1,0) [0|255] "" XXX - SG_ S3 : 15|2@0+ (1,0) [0|3] "" XXX - SG_ S4 : 16|8@1+ (1,0) [0|15] "" XXX - SG_ S5 : 24|8@1+ (1,0) [0|255] "" XXX - SG_ S6 : 32|8@1+ (1,0) [0|255] "" XXX - SG_ S7 : 40|8@1+ (1,0) [0|3] "" XXX - SG_ S8 : 48|8@1+ (1,0) [0|255] "" XXX - SG_ S9 : 56|8@1+ (1,0) [0|255] "" XXX - -BO_ 863 CAM_STATUS: 8 XXX - SG_ NEW_SIGNAL_1 : 32|1@0+ (1,0) [0|32767] "" XXX - SG_ NEW_SIGNAL_5 : 4|2@0+ (1,0) [0|32767] "" XXX - SG_ NEW_SIGNAL_4 : 15|4@0+ (1,0) [0|15] "" XXX - SG_ STOP_SIGN : 31|4@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_3 : 55|1@0+ (1,0) [0|127] "" XXX - SG_ NEW_SIGNAL_6 : 0|3@1+ (1,0) [0|7] "" XXX - SG_ FORWARD_COLLISION : 40|8@1+ (1,0) [0|7] "" XXX - -BO_ 1157 CAM_Empty2: 8 XXX - -BO_ 1160 CAM_Empty3: 8 XXX - SG_ NEW_SIGNAL_1 : 47|24@0+ (1,0) [0|16777215] "" XXX - -BO_ 1088 CAM_LANEINFO: 8 XXX - SG_ BIT3 : 62|1@0+ (1,0) [0|3] "" XXX - SG_ HANDS_ON_STEER_WARN_2 : 59|1@0+ (1,0) [0|1] "" XXX - SG_ HANDS_ON_STEER_WARN : 56|1@0+ (1,0) [0|3] "" XXX - SG_ S1_NOT : 54|1@0+ (1,0) [0|31] "" XXX - SG_ S1 : 52|1@0+ (1,0) [0|1] "" XXX - SG_ HANDS_WARN_3_BITS : 51|3@0+ (1,0) [0|7] "" XXX - SG_ ERR_BIT : 40|1@0+ (1,0) [0|1] "" XXX - SG_ NO_ERR_BIT : 14|1@0+ (1,0) [0|1] "" XXX - SG_ BIT2 : 13|1@0+ (1,0) [0|15] "" XXX - SG_ LANE_LINES : 10|3@0+ (1,0) [0|3] "" XXX - SG_ BIT1 : 6|1@0+ (1,0) [0|65535] "" XXX - SG_ LINE_NOT_VISIBLE : 1|1@0+ (1,0) [0|1] "" XXX - SG_ LINE_VISIBLE : 0|1@0+ (1,0) [0|3] "" XXX - -BO_ 1479 NEW_MSG_470: 8 XXX - -BO_ 1456 NEW_MSG_300: 8 XXX - -BO_ 1446 NEW_MSG_a600: 8 XXX - -BO_ 1416 MSG_18: 8 XXX - -BO_ 1086 DOORS: 8 XXX - SG_ DOOR_OPEN : 30|1@0+ (1,0) [0|255] "" XXX - SG_ LEFTGATE : 32|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_3 : 53|1@0+ (1,0) [0|255] "" XXX - SG_ KEYFOB_HORN : 2|1@0+ (1,0) [0|1] "" XXX - SG_ KEYFOB_LOCK : 3|1@0+ (1,0) [0|1] "" XXX - SG_ KEYFOB_UNLOCK : 4|1@0+ (1,0) [0|1] "" XXX - SG_ CTR1 : 8|4@1+ (1,0) [0|3] "" XXX - SG_ CTR2 : 16|4@1+ (1,0) [0|15] "" XXX - SG_ BR : 34|1@0+ (1,0) [0|1] "" XXX - SG_ BL : 35|1@0+ (1,0) [0|1] "" XXX - SG_ FR : 36|1@0+ (1,0) [0|1] "" XXX - SG_ FL : 37|1@0+ (1,0) [0|255] "" XXX - -BO_ 977 TWO_STATES: 8 XXX - SG_ NEW_SIGNAL_1 : 50|1@1+ (1,0) [0|7] "" XXX - SG_ NEW_SIGNAL_2 : 56|4@1+ (1,0) [0|7] "" XXX - SG_ NEW_SIGNAL_3 : 28|1@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 24|4@1+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_5 : 39|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_6 : 36|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_7 : 47|8@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_8 : 51|1@0+ (1,0) [0|1] "" XXX - -BO_ 1085 MSG_12: 8 XXX - SG_ NEW_SIGNAL_3 : 36|1@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_1 : 16|8@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_2 : 48|8@1+ (1,0) [0|65535] "" XXX - SG_ NEW_SIGNAL_4 : 31|1@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 24|1@0+ (1,0) [0|127] "" XXX - SG_ NEW_SIGNAL_6 : 40|3@1+ (1,0) [0|7] "" XXX - -BO_ 159 MSG_11: 8 XXX - SG_ NEW_SIGNAL_1 : 50|4@1+ (1,0) [0|15] "" XXX - -BO_ 1278 NEW_MSG_3: 8 XXX - SG_ NEW_SIGNAL_2 : 23|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_6 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_7 : 63|8@0+ (1,0) [0|255] "" XXX - SG_ MILAGE_MAYBE : 7|16@0+ (1,0) [0|255] "" XXX - -BO_ 1277 NEW_MSG_10: 8 XXX - SG_ NEW_SIGNAL_3 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 15|8@0+ (1,0) [0|255] "" XXX - SG_ counter : 7|8@0+ (1,0) [0|255] "" XXX - -BO_ 1275 MSG_2017_5: 8 XXX - SG_ counter : 4|5@0+ (1,0) [0|255] "" XXX - -BO_ 1274 NEW_MSG_12: 8 XXX - SG_ NEW_SIGNAL_1 : 24|4@1+ (1,0) [0|15] "" XXX - SG_ CTR : 55|4@0+ (1,0) [0|63] "" XXX - SG_ NEW_SIGNAL_2 : 35|1@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 32|3@1+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_4 : 48|4@1+ (1,0) [0|7] "" XXX - -BO_ 1180 last_byte_roughRPM: 8 XXX - SG_ NEW_SIGNAL_1 : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 1078 HVAC: 8 XXX - SG_ NEW_SIGNAL_1 : 2|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_2 : 8|1@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 23|1@0+ (1,0) [0|65535] "" XXX - SG_ NEW_SIGNAL_4 : 56|5@0+ (1,0) [0|255] "" XXX - -BO_ 1056 NEW_MSG_13: 8 XXX - SG_ BIG_COUNTER_MAYBE : 55|16@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_1 : 29|6@0+ (1,0) [0|255] "" XXX - SG_ counter_or_GEAR : 15|8@0+ (1,0) [0|255] "" XXX - SG_ INCREASING : 7|8@0+ (1,0) [0|255] "" XXX - SG_ CTR : 23|8@0+ (1,0) [0|255] "" XXX - SG_ STANDSTILL : 32|1@0+ (1,0) [0|255] "" XXX - -BO_ 1045 MOVING: 8 XXX - SG_ NEW_SIGNAL_2 : 20|1@0+ (1,0) [0|3] "" XXX - SG_ CTR2 : 19|4@0+ (1,0) [0|31] "" XXX - SG_ CTR3 : 8|4@1+ (1,0) [0|15] "" XXX - SG_ IS_MOVING : 12|1@0+ (1,0) [0|3] "" XXX - SG_ CTR1 : 53|6@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_1 : 54|1@0+ (1,0) [0|1] "" XXX - SG_ BRAKE : 55|1@0+ (1,0) [0|1] "" XXX - -BO_ 1034 MSG_07: 8 XXX - SG_ NEW_SIGNAL_1 : 6|3@0+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_2 : 0|4@1+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_3 : 15|4@0+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_4 : 63|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 23|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_6 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_7 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_8 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_9 : 31|8@0+ (1,0) [0|255] "" XXX - -BO_ 870 NEW_MSG_16: 8 XXX - SG_ NEW_SIGNAL_1 : 7|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 15|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 23|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_6 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_7 : 55|8@0+ (1,0) [0|255] "" XXX - -BO_ 867 NEW_MSG_17: 8 XXX - SG_ NEW_SIGNAL_1 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 23|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 15|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 7|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_6 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ CTR : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 130 STEER: 8 XXX - SG_ NEW_SIGNAL_5 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_6 : 63|8@0+ (1,0) [0|255] "" XXX - SG_ CTR : 47|8@0+ (1,0) [0|255] "" XXX - SG_ CTR_2 : 35|4@0+ (1,0) [0|255] "" XXX - SG_ STEER_ANGLE : 23|16@0+ (0.05,-1600) [500|-500] "deg" XXX - -BO_ 120 NEW_MSG_18: 8 XXX - SG_ NEW_SIGNAL_1 : 7|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 15|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 23|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ CTR : 55|8@0+ (1,0) [0|255] "" XXX - -BO_ 304 GEAR_RELATED: 8 XXX - SG_ NEW_SIGNAL_1 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 47|8@0+ (1,0) [0|255] "" XXX - -BO_ 865 NEW_MSG_5: 8 XXX - SG_ SPEED_INVERSE : 55|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_1 : 47|1@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 40|1@0+ (1,0) [0|1] "" XXX - SG_ IS_MOVING : 43|3@0+ (1,0) [0|127] "" XXX - SG_ NEW_SIGNAL_2 : 46|1@0+ (1,0) [0|7] "" XXX - SG_ NEW_SIGNAL_4 : 44|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_7 : 23|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_8 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_10 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_6 : 15|3@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 7|8@0+ (1,0) [0|255] "" XXX - SG_ CTR : 56|4@1+ (1,0) [0|15] "" XXX - -BO_ 836 NEW_MSG_19: 8 XXX - SG_ CTR : 48|4@1+ (1,0) [0|15] "" XXX - SG_ CTR2 : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 832 SEATBELT: 8 XXX - SG_ NEW_SIGNAL_1 : 7|8@0+ (1,0) [0|255] "" XXX - SG_ PASSENGER_SEATBELT : 26|1@1+ (1,0) [0|7] "" XXX - SG_ CTR1 : 15|4@0+ (1,0) [0|15] "" XXX - SG_ CTR2 : 23|4@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 8|4@1+ (1,0) [0|3] "" XXX - SG_ DRIVER_SEATBELT : 27|1@0+ (1,0) [0|1] "" XXX - -BO_ 866 NEW_MSG_21: 8 XXX - SG_ NEW_SIGNAL_2 : 7|8@0+ (1,0) [0|131071] "" XXX - SG_ NEW_SIGNAL_1 : 15|8@0+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_3 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_6 : 27|4@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_7 : 23|8@0+ (1,0) [0|255] "" XXX - SG_ CTR : 59|4@0+ (1,0) [0|15] "" XXX - -BO_ 158 MSG_05: 8 XXX - SG_ NEW_SIGNAL_1 : 23|8@0+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_2 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 55|8@0+ (1,0) [0|255] "" XXX - -BO_ 157 CRZ_BTNS: 8 XXX - SG_ SET_P_INV : 21|1@0+ (1,0) [0|3] "" XXX - SG_ CAN_OFF_INV : 17|1@1+ (1,0) [0|3] "" XXX - SG_ CAN_OFF : 0|1@1+ (1,0) [0|3] "" XXX - SG_ SET_M_INV : 22|1@0+ (1,0) [0|255] "" XXX - SG_ SET_M : 5|1@0+ (1,0) [0|3] "" XXX - SG_ SET_P : 4|1@0+ (1,0) [0|3] "" XXX - SG_ RES_INV : 19|1@1+ (1,0) [0|3] "" XXX - SG_ RES : 2|1@1+ (1,0) [0|3] "" XXX - SG_ DISTANCE_LESS : 7|1@0+ (1,0) [0|1] "" XXX - SG_ DISTANCE_LESS_INV : 8|1@0+ (1,0) [0|31] "" XXX - SG_ DISTANCE_MORE : 6|1@0+ (1,0) [0|3] "" XXX - SG_ DISTANCE_MORE_INV : 23|1@0+ (1,0) [0|1] "" XXX - SG_ MODE_Y : 13|1@1+ (1,0) [0|3] "" XXX - SG_ MODE_X : 14|1@0+ (1,0) [0|255] "" XXX - SG_ MODE_Y_INV : 30|1@0+ (1,0) [0|3] "" XXX - SG_ MODE_X_INV : 31|1@0+ (1,0) [0|3] "" XXX - SG_ CTR : 29|4@0+ (1,0) [0|255] "" XXX - -BO_ 154 BLINK_INFO: 8 XXX - SG_ LEFT_BLINK : 18|1@1+ (1,0) [0|3] "" XXX - SG_ RIGHT_BLINK : 19|1@0+ (1,0) [0|255] "" XXX - SG_ REAR_WIPER_ON : 0|1@0+ (1,0) [0|1] "" XXX - SG_ WIPER_LO : 33|1@1+ (1,0) [0|31] "" XXX - SG_ WIPER_HI : 34|1@0+ (1,0) [0|1] "" XXX - -BO_ 145 TURN_SWITCH: 8 XXX - SG_ NEW_SIGNAL_1 : 37|1@0+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_2 : 36|1@0+ (1,0) [0|3] "" XXX - SG_ TURN : 38|1@0+ (1,0) [0|3] "" XXX - SG_ TURN_LEFT_SWITCH : 13|1@0+ (1,0) [0|255] "" XXX - SG_ TURN_RIGHT_SWITCH : 12|1@1+ (1,0) [0|3] "" XXX - SG_ HAZARD : 10|1@0+ (1,0) [0|1] "" XXX - SG_ CTR : 27|4@0+ (1,0) [0|255] "" XXX - -BO_ 80 MSG_04: 8 XXX - SG_ NEW_SIGNAL_1 : 25|1@0+ (1,0) [0|1] "" XXX - SG_ SIGNAL : 24|1@0+ (1,0) [0|1] "" XXX - -BO_ 978 MSG_03: 8 XXX - SG_ NEW_SIGNAL_1 : 7|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 15|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 23|8@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_4 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_6 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_7 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_8 : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 607 NEW_MSG_25: 8 XXX - -BO_ 1115 MSG_02: 8 XXX - SG_ NEW_SIGNAL_2 : 15|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_1 : 47|16@0+ (1,0) [0|65535] "" XXX - SG_ NEW_SIGNAL_3 : 63|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_4 : 23|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_6 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ CTR : 2|3@0+ (1,0) [0|255] "" XXX - -BO_ 1067 NEW_MSG_27: 8 XXX - SG_ NEW_SIGNAL_2 : 3|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_4 : 0|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_1 : 2|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_5 : 1|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_3 : 12|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_6 : 11|1@1+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_7 : 10|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_8 : 9|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_9 : 8|1@0+ (1,0) [0|1] "" XXX - -BO_ 358 NEW_MSG_28: 8 XXX - -BO_ 608 NEW_MSG_29: 8 XXX - SG_ NEW_SIGNAL_1 : 8|5@1+ (1,0) [0|7] "" XXX - -BO_ 606 SPEED_TBD: 8 XXX - SG_ SPEED_TBD : 7|12@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_1 : 23|12@0- (1,0) [0|65535] "" XXX - -BO_ 552 GEAR: 8 XXX - SG_ NEW_SIGNAL_2 : 8|1@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 11|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_4 : 18|3@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 26|3@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_6 : 31|5@0+ (1,0) [0|31] "" XXX - SG_ NEW_SIGNAL_7 : 39|1@0+ (1,0) [0|255] "" XXX - SG_ GEAR : 35|4@0+ (1,0) [0|15] "" XXX - SG_ MORE_GEAR : 7|4@0+ (1,0) [0|255] "" XXX - -BO_ 543 CRZ_EVENTS: 8 XXX - SG_ NEW_SIGNAL_3 : 34|1@0+ (1,0) [0|1] "" XXX - SG_ CHKSUM : 63|8@0+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_1 : 55|4@0+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_5 : 47|4@0+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_6 : 6|1@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_8 : 0|1@0+ (1,0) [0|31] "" XXX - SG_ NEW_SIGNAL_9 : 1|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_10 : 2|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_12 : 10|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_13 : 9|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_18 : 12|1@0+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_19 : 14|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_20 : 15|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_21 : 23|1@0+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_24 : 31|1@0+ (1,0) [0|1] "" XXX - SG_ GAS_PEDAL_PRESSED : 32|1@0+ (1,0) [0|255] "" XXX - SG_ CRZ_STARTED : 18|1@0+ (1,0) [0|1] "" XXX - SG_ PLUS_ONE_CRZ : 17|1@0+ (1,0) [0|255] "" XXX - SG_ PLUS_ONE_CRZ_2 : 19|1@0+ (1,0) [0|1] "" XXX - SG_ GAS_MAYBE : 22|1@0+ (1,0) [0|1] "" XXX - SG_ NONACC_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX - SG_ CRUISE_ACTIVE_CAR_MOVING : 16|1@0+ (1,0) [0|1] "" XXX - SG_ NONACC_RELATED : 11|1@0+ (1,0) [0|255] "" XXX - SG_ CTR : 51|4@0+ (1,0) [0|15] "" XXX - SG_ CAS_CMD_MAYBE : 30|7@0- (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 43|4@0+ (1,0) [0|255] "" XXX - -BO_ 542 NEW_MSG_33: 8 XXX - SG_ CTR : 48|4@1+ (1,0) [0|15] "" XXX - SG_ CTR2 : 56|4@1+ (1,0) [0|15] "" XXX - -BO_ 868 NEW_MSG_34: 8 XXX - SG_ CTR : 59|4@0+ (1,0) [0|255] "" XXX - -BO_ 869 NEW_MSG_35: 8 XXX - SG_ NEW_SIGNAL_1 : 7|4@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 23|16@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 39|16@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 55|2@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 50|4@1+ (1,0) [0|15] "" XXX - SG_ CTR : 59|4@0+ (1,0) [0|255] "" XXX - -BO_ 1114 NEW_MSG_4: 8 XXX - -BO_ 535 CURVE_CTRS: 8 XXX - SG_ CTR_A_1 : 4|3@0+ (1,0) [0|31] "" XXX - SG_ CTR_A_2 : 7|3@0+ (1,0) [0|255] "" XXX - SG_ CTR_B_1 : 12|3@0+ (1,0) [0|7] "" XXX - SG_ CTR_B_2 : 15|3@0+ (1,0) [0|7] "" XXX - SG_ CTR_C_1 : 20|3@0+ (1,0) [0|7] "" XXX - SG_ CTR_C_2 : 23|3@0+ (1,0) [0|255] "" XXX - SG_ CTR_D_2 : 31|3@0+ (1,0) [0|7] "" XXX - SG_ CTR_D_1 : 28|3@0+ (1,0) [0|7] "" XXX - SG_ CURVE : 39|16@0+ (1,0) [0|7] "" XXX - SG_ CTR : 55|8@0+ (1,0) [0|255] "" XXX - SG_ CHK_MAYBE : 63|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_1 : 0|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_2 : 1|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_6 : 17|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_7 : 24|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_8 : 25|1@0+ (1,0) [0|1] "" XXX - SG_ SEATBELT_MAYBE : 8|1@0+ (1,0) [0|1] "" XXX - SG_ NO_SEATBELT_MAYBE : 16|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_4 : 9|1@0+ (1,0) [0|1] "" XXX - -BO_ 540 CRZ_CTRL: 8 XXX - SG_ NEW_SIGNAL_3 : 1|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_4 : 8|1@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 9|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_6 : 10|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_7 : 18|3@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_9 : 31|1@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_10 : 30|1@0+ (1,0) [0|1] "" XXX - SG_ ACC_GAS_MAYBE : 23|1@0+ (1,0) [0|31] "" XXX - SG_ ACC_GAS_MAYBE2 : 29|1@0+ (1,0) [0|1] "" XXX - SG_ CRZ_ACTIVE : 3|1@0+ (1,0) [0|1] "" XXX - -BO_ 539 CRZ_INFO: 8 XXX - SG_ NEW_SIGNAL_1 : 17|1@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 16|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_5 : 34|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_7 : 47|1@0+ (1,0) [0|255] "" XXX - SG_ CTR1 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ CTR2 : 63|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 37|1@0+ (1,0) [0|255] "" XXX - SG_ ACC_ACTIVE : 33|1@0+ (1,0) [0|1] "" XXX - SG_ ACCEL_CMD : 31|10@0- (1,0) [0|1] "" XXX - -BO_ 121 EPB: 8 XXX - SG_ NEW_SIGNAL_1 : 4|4@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 0|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_3 : 15|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 25|2@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_6 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ CTR : 55|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_7 : 63|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_8 : 41|2@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_9 : 47|1@0+ (1,0) [0|63] "" XXX - SG_ NEW_SIGNAL_10 : 46|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_11 : 45|1@0+ (1,0) [0|1] "" XXX - SG_ EPB_ACTIVE : 29|1@0+ (1,0) [0|15] "" XXX - -BO_ 1070 MSG_2017_1: 8 XXX - -BO_ 1183 MSG_2017_2: 8 XXX - -BO_ 1243 MSG_2017_3: 8 XXX - SG_ NEW_SIGNAL_1 : 7|64@0+ (1,0) [0|18446744073709552000] "" XXX - -BO_ 1269 MSG_2017_4: 8 XXX - SG_ NEW_SIGNAL_1 : 55|16@0+ (1,0) [0|18446744073709552000] "" XXX - -BO_ 1178 MSG_2017_6: 8 XXX - SG_ NEW_SIGNAL_1 : 7|64@0+ (1,0) [0|18446744073709552000] "" XXX - -BO_ 1179 MSG_2017_7: 8 XXX - SG_ NEW_SIGNAL_1 : 7|64@0+ (1,0) [0|18446744073709552000] "" XXX - -BO_ 1435 MSG_2017_8: 8 XXX - -BO_ 253 NEW_MSG_7: 8 XXX - SG_ NEW_SIGNAL_1 : 16|1@0+ (1,0) [0|65535] "" XXX - SG_ NEW_SIGNAL_2 : 41|1@0+ (1,0) [0|255] "" XXX - SG_ CTR : 23|4@0+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_3 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 61|1@0+ (1,0) [0|255] "" XXX - -BO_ 359 NEW_MSG_11: 8 XXX - SG_ NEW_SIGNAL_1 : 15|1@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 7|8@0+ (1,0) [0|255] "" XXX - SG_ CTR : 31|4@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 36|5@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 38|1@1+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_5 : 37|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_6 : 47|4@0+ (1,0) [0|255] "" XXX - -BO_ 512 NEW_MSG_30: 8 XXX - SG_ NEW_SIGNAL_1 : 6|7@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 7|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_3 : 15|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 23|1@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 22|7@0+ (1,0) [0|127] "" XXX - SG_ NEW_SIGNAL_6 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_7 : 39|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_8 : 38|7@0+ (1,0) [0|127] "" XXX - SG_ NEW_SIGNAL_9 : 40|4@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_10 : 47|4@0+ (1,0) [0|15] "" XXX - SG_ CTR : 51|3@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_11 : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 515 MSG_01: 8 XXX - SG_ CTR : 39|8@0+ (1,0) [0|65535] "" XXX - SG_ CTR_2 : 47|8@0+ (1,0) [0|255] "" XXX - -BO_ 529 NEW_MSG_36: 8 XXX - SG_ NEW_SIGNAL_1 : 22|5@0+ (1,0) [0|65535] "" XXX - SG_ NEW_SIGNAL_2 : 31|8@0+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_3 : 32|4@1+ (1,0) [0|3] "" XXX - SG_ CTR : 39|4@0+ (1,0) [0|255] "" XXX - SG_ CTR_2 : 47|4@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 40|4@1+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_5 : 53|1@0+ (1,0) [0|255] "" XXX - -BO_ 1242 NEW_MSG_37: 8 XXX - -BO_ 1266 MSG_09: 8 XXX - SG_ NEW_SIGNAL_1 : 20|1@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 19|4@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_3 : 31|1@0+ (1,0) [0|255] "" XXX - -BO_ 976 MSG_15: 8 XXX - SG_ NEW_SIGNAL_1 : 55|1@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 61|6@0+ (1,0) [0|1] "" XXX - -BO_ 155 MSG_14: 8 XXX - -BO_ 1267 MSG_10: 8 XXX - SG_ NEW_SIGNAL_1 : 40|1@0+ (1,0) [0|16777215] "" XXX - SG_ NEW_SIGNAL_2 : 42|1@0+ (1,0) [0|1] "" XXX - -BO_ 305 NEW_MSG_6: 8 XXX - SG_ NEW_SIGNAL_1 : 8|1@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 9|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_3 : 10|1@0+ (1,0) [0|1] "" XXX - -BO_ 1238 TEMPERATURE: 8 XXX - SG_ TEMPERATURE_MAYBE : 47|8@0+ (1,0) [0|4294967295] "" XXX - -BO_ 1087 NEW_MSG_1: 8 XXX - SG_ NEW_SIGNAL_1 : 7|8@0+ (1,0) [0|255] "" XXX - -BO_ 1143 BSM: 8 XXX - SG_ BSM_OFF : 0|1@0+ (1,0) [0|1] "" XXX - SG_ RIGHT_BS_3 : 37|1@0+ (1,0) [0|1] "" XXX - SG_ STANDSTILL : 8|1@0+ (1,0) [0|1] "" XXX - SG_ LEFT_BS1 : 12|1@0+ (1,0) [0|1] "" XXX - SG_ LEFT_BS3 : 38|1@0+ (1,0) [0|1] "" XXX - SG_ RIGHT_BS4 : 39|1@0+ (1,0) [0|1] "" XXX - SG_ LEFT_BS_SIDE : 36|1@0+ (1,0) [0|1] "" XXX - SG_ IS_MOVING : 9|1@0+ (1,0) [0|1] "" XXX - SG_ LEFT_BS_BEHIND : 46|2@1+ (1,0) [0|16777215] "" XXX - SG_ RIGHT_BS1 : 14|1@0+ (1,0) [0|63] "" XXX - SG_ RIGHT_BS_DISTANCE : 35|3@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_1 : 32|1@0+ (1,0) [0|1] "" XXX - -BO_ 1361 KEY_POSITION: 8 XXX - -BO_ 1283 KEY_POSITION2: 8 XXX - -BO_ 628 MSG_06: 8 XXX - -BO_ 1154 MSG_08: 8 XXX - -BO_ 1139 MSG_13: 8 XXX - -BO_ 1270 MSG_16: 8 XXX - -BO_ 1272 MSG_17: 8 XXX - -BO_ 1425 MSG_19: 8 XXX - - - - -CM_ SG_ 605 PED_BRAKE "3: no brake, 4: brake"; -CM_ SG_ 1088 LANE_LINES "0 LKAS disabled, 1 no lines, 2 two lines, 3 left line, 4 right line"; -CM_ SG_ 157 CAN_OFF "Disengage Cruise if enabled, if already disabled TURN it OFF "; -CM_ SG_ 552 GEAR "0 P/N, 12 R, 2 D M1, 4 M2, 14 Shift"; -CM_ SG_ 552 MORE_GEAR ""; diff --git a/opendbc/mercedes_benz_e350_2010.dbc b/opendbc/mercedes_benz_e350_2010.dbc deleted file mode 100644 index da6ae4c15ee66b..00000000000000 --- a/opendbc/mercedes_benz_e350_2010.dbc +++ /dev/null @@ -1,176 +0,0 @@ -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_ 3 STEER_SENSOR: 8 XXX - SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - SG_ STEER_RATE : 19|12@0- (0.5,0) [0|255] "" XXX - SG_ STEER_DIRECTION : 4|1@0+ (1,2) [0|1] "" XXX - SG_ STEER_ANGLE : 3|12@0- (-0.5,0) [-500|500] "degrees" XXX - -BO_ 5 BRAKE_MODULE: 8 XXX - SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - SG_ BRAKE_HOLD : 2|1@0+ (1,0) [0|1] "" XXX - SG_ BRAKE_POSITION : 17|10@0+ (1,0) [0|65535] "" XXX - SG_ DRIVER_BRAKE : 4|1@0+ (1,0) [0|1] "" XXX - SG_ COMPUTER_BRAKE : 10|1@0+ (1,0) [0|1] "" XXX - SG_ BRAKE_PRESSED : 0|1@1+ (1,0) [0|1] "" XXX - -BO_ 69 DRIVER_CONTROLS: 8 XXX - SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX - SG_ STEERING_WHEEL_BUTTONS : 32|16@1+ (1,0) [0|255] "4 directional, 2 volume control & 2 phone buttons" XXX - SG_ LEFT_BLINKER : 16|1@0+ (1,0) [0|1] "" XXX - SG_ RIGHT_BLINKER : 17|1@0+ (1,0) [0|1] "" XXX - SG_ HIGHBEAM_TOGGLE : 18|1@0+ (1,0) [0|1] "" XXX - SG_ HIGHBEAM_MOMENTARY : 19|1@0+ (1,0) [0|1] "" XXX - SG_ CRUISE_CONTROL_CANCEL : 0|1@0+ (1,0) [0|1] "" XXX - SG_ CRUISE_CONTROL_RESUME : 1|1@0+ (1,0) [0|1] "" XXX - SG_ CRUISE_CONTROL_ACCEL_HIGH : 2|1@0+ (1,0) [0|1] "" XXX - SG_ CRUISE_CONTROL_DECEL_HIGH : 3|1@0+ (1,0) [0|1] "" XXX - SG_ CRUISE_CONTROL_ACCEL_LOW : 4|1@0+ (1,0) [0|1] "" XXX - SG_ CRUISE_CONTROL_DECEL_LOW : 5|1@0+ (1,0) [0|1] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_XFF : 15|8@0+ (1,0) [0|255] "" XXX - -BO_ 513 WHEEL_ENCODERS: 8 XXX - SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX - SG_ WHEEL_ENCODER_2 : 15|8@0+ (1,0) [0|255] "" XXX - SG_ WHEEL_ENCODER_3 : 23|8@0+ (1,0) [0|255] "" XXX - SG_ WHEEL_ENCODER_4 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ CHECKSUM : 56|8@1+ (1,0) [0|255] "" XXX - SG_ WHEEL_ENCODER_1 : 7|8@0+ (1,0) [0|255] "" XXX - -BO_ 261 GAS_PEDAL: 8 XXX - SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - SG_ ENGINE_RPM : 4|5@0+ (1,0) [0|255] "" XXX - SG_ GAS_PEDAL : 39|8@0+ (1,0) [0|255] "" XXX - SG_ COMBINED_GAS : 31|8@0+ (1,0) [0|255] "" XXX - -BO_ 643 DOOR_SENSORS: 8 XXX - SG_ BRAKE_PRESSED : 27|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_OPEN_FR : 3|1@1+ (1,0) [0|3] "" XXX - SG_ DOOR_OPEN_RL : 5|1@0+ (1,0) [0|3] "" XXX - SG_ DOOR_OPEN_RR : 7|1@0+ (1,0) [0|3] "" XXX - SG_ DOOR_OPEN_FL : 1|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_CLOSED_FL : 0|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_CLOSED_FR : 2|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_CLOSED_RL : 4|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_CLOSED_RR : 6|1@0+ (1,0) [0|1] "" XXX - -BO_ 885 SEATBELT_SENSORS: 8 XXX - SG_ SEATBELT_DRIVER_LATCHED : 16|1@0+ (1,0) [0|1] "" XXX - SG_ SEATBELT_PASSENGER_LATCHED : 18|1@0+ (1,0) [0|1] "" XXX - -BO_ 257 CRUISE_CONTROL: 8 XXX - SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_1 : 6|1@0+ (1,0) [0|255] "" XXX - SG_ CRUISE_DISABLED : 23|1@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X002 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_X003 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_1 : 5|1@0+ (1,0) [0|1] "" XXX - SG_ CRUISE_ACCELERATING : 22|1@0+ (1,0) [0|1] "" XXX - SG_ LONGITUDINAL_ACCEL_REQUEST : 15|8@0- (1,0) [0|127] "" XXX - -BO_ 260 CRUISE_CONTROL2: 8 XXX - SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_X00 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_XFF : 31|8@0+ (1,0) [0|65535] "" XXX - SG_ SET_ME_X02 : 23|8@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_XFF2 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_1 : 7|4@0+ (1,0) [0|255] "" XXX - -BO_ 14 STEER_TORQUE: 8 XXX - SG_ STEER_TORQUE : 15|8@0+ (1,0) [0|255] "" XXX - SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 888 CRUISE_CONTROL3: 8 XXX - SG_ NEW_SIGNAL_2 : 7|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_1 : 38|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_5 : 32|1@0+ (1,0) [0|1] "" XXX - SG_ CRUISE_DISABLED : 36|1@0+ (1,0) [0|1] "" XXX - SG_ CRUISE_ENABLED : 34|1@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X003 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_X004 : 63|8@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_X002 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_X00 : 23|8@0+ (1,0) [0|255] "" XXX - SG_ CRUISE_SET_SPEED : 15|8@0+ (1,0) [0|63] "mph" XXX - SG_ CRUISE_SPEED_CHANGE : 55|1@0+ (1,0) [0|1] "" XXX - -BO_ 307 POWER_SEATS: 8 XXX - SG_ DRIVER_FORWARD : 0|1@0+ (1,0) [0|1] "" XXX - SG_ DRIVER_BACK : 1|1@0+ (1,0) [0|1] "" XXX - -BO_ 109 GEAR_LEVER: 8 XXX - SG_ PARK_BUTTON : 12|1@0+ (1,0) [0|1] "" XXX - SG_ NEUTRAL_UP : 9|1@0+ (1,0) [0|1] "" XXX - SG_ NEUTRAL_DOWN : 10|1@0+ (1,0) [0|1] "" XXX - SG_ DRIVE : 11|1@0+ (1,0) [0|1] "" XXX - SG_ REVERSE : 8|1@0+ (1,0) [0|1] "" XXX - SG_ COUNTER : 23|4@0+ (1,0) [0|15] "" XXX - SG_ CHECKSUM : 31|8@0+ (1,0) [0|255] "" XXX - -BO_ 115 GEAR_PACKET: 8 XXX - SG_ GEAR : 0|4@1+ (1,0) [0|15] "" XXX - -BO_ 581 IGNITION: 8 XXX - -BO_ 515 WHEEL_SPEEDS: 8 XXX - SG_ WHEEL_MOVING_FR : 22|1@1+ (1,0) [0|15] "" XXX - SG_ WHEEL_MOVING_RL : 38|1@0+ (1,0) [0|1] "" XXX - SG_ WHEEL_MOVING_FL : 6|1@0+ (1,0) [0|1] "" XXX - SG_ WHEEL_MOVING_RR : 54|1@0+ (1,0) [0|1] "" XXX - SG_ WHEEL_SPEED_FL : 2|11@0+ (0.0375,0) [0|255] "mph" XXX - SG_ WHEEL_SPEED_FR : 18|11@0+ (0.0375,0) [0|255] "mph" XXX - SG_ WHEEL_SPEED_RL : 34|11@0+ (0.0375,0) [0|255] "mph" XXX - SG_ WHEEL_SPEED_RR : 50|11@0+ (0.0375,0) [0|255] "mph" XXX - - - - -CM_ SG_ 3 STEER_DIRECTION "0 = left, 1 = right"; -CM_ SG_ 5 BRAKE_POSITION "computer and driver"; -CM_ SG_ 5 BRAKE_PRESSED "computer and driver"; -CM_ SG_ 261 GAS_PEDAL "user gas input"; -CM_ SG_ 261 COMBINED_GAS "computer and driver gas"; -CM_ SG_ 257 CRUISE_ACCELERATING ""; \ No newline at end of file diff --git a/opendbc/nissan_2017.dbc b/opendbc/nissan_2017.dbc deleted file mode 100644 index 1d03b7ab5f72d9..00000000000000 --- a/opendbc/nissan_2017.dbc +++ /dev/null @@ -1,184 +0,0 @@ -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_ 644 Speed_1: 8 XXX - SG_ Speed_FR : 7|16@0+ (0.0118,0) [0|65535] "" XXX - SG_ Speed_FL : 23|16@0+ (0.0118,0) [0|65535] "" XXX - SG_ Speed_Vehicle : 39|16@0+ (0.0245,0) [0|65535] "" XXX - -BO_ 645 WheelspeedRear: 8 XXX - SG_ RR : 7|16@0+ (0.00555,0) [0|65535] "KPH" XXX - SG_ RL : 23|16@0+ (0.00555,0) [0|65535] "KPH" XXX - -BO_ 768 STEER_TORQUE: 8 XXX - SG_ STEERING_TOURQUE : 0|7@1+ (1,0) [0|127] "" XXX - -BO_ 459 Maybe_RegenBraking: 8 XXX - -BO_ 372 Maybe_Gear_Selector: 8 XXX - SG_ Counter : 32|4@1+ (1,0) [0|15] "" XXX - -BO_ 374 Maybe_Motor_RPM_or_Speed: 8 XXX - SG_ Counter : 48|4@1+ (1,0) [0|15] "" XXX - -BO_ 460 Maybe_Brake_Related: 8 XXX - -BO_ 2 SteeringWheel: 8 XXX - SG_ Steering_RateChange : 23|8@0+ (1,0) [0|255] "" XXX - SG_ Always_07 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ Steering_Angle : 0|16@1- (-0.1,0) [0|65535] "" XXX - -BO_ 384 Maybe_PowerInfo: 8 XXX - SG_ Unknown_Timer_PowerInfo : 48|4@1+ (1,0) [0|15] "" XXX - SG_ EnginePower : 27|12@0- (1,0) [0|1] "" XXX - SG_ RequestedAccel : 23|12@0- (1,0) [0|4294967295] "" XXX - -BO_ 1107 Lights: 8 XXX - SG_ RIGHT_BLINKER : 12|1@0+ (1,0) [0|1] "" XXX - SG_ LEFT_BLINKER : 11|1@0+ (1,0) [0|1] "" XXX - SG_ _HEADLIGHTS : 5|1@0+ (1,0) [0|1] "" XXX - -BO_ 666 WheelspeedFront: 8 XXX - SG_ _FL_WHEELSPEED : 39|16@0+ (0.01014,0) [0|65535] "" XXX - SG_ FR : 7|16@0+ (0.00555,0) [0|65535] "KPH" XXX - SG_ FL : 23|16@0+ (0.00555,0) [0|65535] "KPH" XXX - -BO_ 398 NEW_MSG_2: 8 XXX - -BO_ 389 NEW_MSG_3: 8 XXX - SG_ NEW_SIGNAL_1 : 15|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 22|6@0+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_4 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 55|4@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_6 : 63|8@0+ (1,0) [0|127] "" XXX - SG_ COUNTER : 48|4@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_3 : 30|8@0- (1,0) [0|255] "" XXX - -BO_ 397 NEW_MSG_4: 8 XXX - SG_ NEW_SIGNAL_1 : 7|16@0+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_2 : 23|16@0+ (1,0) [0|32767] "" XXX - SG_ NEW_SIGNAL_3 : 39|16@0+ (1,0) [0|65535] "" XXX - SG_ NEW_SIGNAL_4 : 55|16@0+ (1,0) [0|31] "" XXX - -BO_ 658 NEW_MSG_5: 8 XXX - SG_ NEW_SIGNAL_1 : 7|16@0+ (1,0) [0|255] "" XXX - -BO_ 855 NEW_MSG_6: 8 XXX - SG_ NEW_SIGNAL_1 : 7|8@0+ (1,0) [0|255] "" XXX - -BO_ 773 NEW_MSG_7: 8 XXX - SG_ NEW_SIGNAL_1 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 47|8@0+ (1,0) [0|255] "" XXX - -BO_ 851 SPEED_RELATED: 8 XXX - SG_ SPEED_RELATED : 7|16@0+ (0.01014,0) [0|65535] "" XXX - -BO_ 386 Accelerator: 8 XXX - SG_ Accelerator : 38|7@0+ (1,0) [0|127] "" XXX - -BO_ 347 ACCELSOMETHING: 8 XXX - SG_ PowerMaybe : 9|10@0+ (1,0) [0|1023] "" XXX - SG_ ACCELERATOR2 : 6|11@0+ (1,-800) [0|65535] "" XXX - -BO_ 346 ANOTHER_ACCEL: 8 XXX - SG_ ANOTHERACCEL : 23|10@0+ (1,0) [0|1023] "" XXX - SG_ Reverse_ACCEL : 25|10@0+ (1,0) [0|1023] "" XXX - -BO_ 348 FULLRANGEACCEL: 8 XXX - SG_ AccelFullRange : 47|10@0+ (1,0) [0|1023] "" XXX - SG_ Accel : 26|11@0+ (1,0) [0|2047] "" XXX - SG_ NEW_SIGNAL_1 : 7|8@0+ (1,0) [0|255] "" XXX - -BO_ 566 ANOTHERFULLRANGEACCEL: 8 XXX - SG_ ANOTHERFULLRANGEACCEL : 43|8@0+ (1,0) [0|1023] "" XXX - SG_ RPMORTORQUE : 31|8@0+ (1,0) [0|255] "" XXX - -BO_ 523 Yetyetanotheraccel: 8 XXX - SG_ ANOTHERREVERSEACCEL : 37|10@0+ (1,0) [0|1023] "" XXX - SG_ yetyetanotheraccel : 31|10@0+ (1,0) [0|255] "" XXX - -BO_ 779 ANOTHERRRFULLRANGEACCEL: 8 XXX - SG_ ANOTHERRRFULLRANGEACCEL : 47|8@0+ (1,0) [0|255] "" XXX - -BO_ 1108 Doors: 8 XXX - SG_ DOOR_CLOSED_RR : 40|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_OPEN_RR : 41|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_CLOSED_RL : 42|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_OPEN_RL : 43|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_CLOSED_FL : 44|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_CLOSED_FR : 46|1@0+ (1,0) [0|3] "" XXX - SG_ DOOR_OPEN_FR : 47|1@0+ (1,0) [0|3] "" XXX - SG_ BOOT_OPEN : 55|1@0+ (1,0) [0|1] "" XXX - -BO_ 403 LKAS_OLD: 8 XXX - SG_ Checksum : 63|8@0+ (1,0) [0|255] "" XXX - SG_ Angle_2 : 32|13@0+ (1,-4000) [0|63] "" XXX - SG_ Counter : 48|4@1+ (1,0) [0|15] "" XXX - SG_ Angle_1 : 10|13@0+ (0.12,-480) [0|65535] "" XXX - SG_ Steering_Torque : 7|13@0+ (-1,4000) [0|65535] "" XXX - SG_ Torque_Command : 29|13@0+ (1,-4000) [0|255] "" XXX - -BO_ 412 NEW_MSG_9: 8 XXX - SG_ NEW_SIGNAL_1 : 7|16@0+ (1,0) [0|65535] "" XXX - SG_ NEW_SIGNAL_3 : 23|16@0+ (1,0) [0|65535] "" XXX - SG_ NEW_SIGNAL_2 : 39|8@0+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_4 : 47|8@0+ (1,0) [0|255] "" XXX - -BO_ 361 LKAS: 8 XXX - SG_ NEW_SIGNAL_4 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ SET_X80 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ LKA_Active : 52|1@0+ (1,0) [0|15] "" XXX - SG_ CRC : 63|8@0+ (1,0) [0|255] "" XXX - SG_ SET_0x80_2 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ Counter : 51|4@0+ (1,0) [0|15] "" XXX - SG_ Des_Angle : 7|18@0+ (-0.01,1310) [0|255] "" XXX - -BO_ 438 ProPilot: 8 XXX - SG_ NEW_SIGNAL_2 : 11|4@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 27|4@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_8 : 63|8@0+ (1,0) [0|7] "" XXX - SG_ Counter : 55|4@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_6 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ SET_3 : 32|2@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_1 : 7|12@0- (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 23|12@0- (-1,0) [0|255] "" XXX - SG_ CRUISE_ON : 36|1@0+ (1,0) [0|255] "" XXX - SG_ CRUISE_ACTIVATED : 38|1@0+ (1,0) [0|3] "" XXX - SG_ STEER_STATUS : 51|1@1+ (1,0) [0|3] "" XXX - diff --git a/opendbc/nissan_leaf_2018.dbc b/opendbc/nissan_leaf_2018.dbc new file mode 100644 index 00000000000000..5172e01c8e5aca --- /dev/null +++ b/opendbc/nissan_leaf_2018.dbc @@ -0,0 +1,211 @@ +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_ 2 STEER_ANGLE_SENSOR: 5 XXX + SG_ STEER_ANGLE_RATE : 16|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X07 : 24|8@1+ (1,0) [0|255] "" XXX + SG_ STEER_ANGLE : 0|16@1- (-0.1,0) [0|65535] "" XXX + SG_ COUNTER : 32|4@1+ (1,0) [0|15] "" XXX + +BO_ 42 SEATBELT: 8 XXX + SG_ SEATBELT_DRIVER_LATCHED : 27|1@1+ (1,0) [0|3] "" XXX + SG_ SEATBELT_DRIVER_UNLATCHED : 26|1@0+ (1,0) [0|1] "" XXX + SG_ unknown2 : 31|4@0+ (1,0) [0|15] "" XXX + SG_ unknown3 : 24|2@1+ (1,0) [0|3] "" XXX + SG_ unknown1 : 7|24@0+ (1,0) [0|16777215] "" XXX + SG_ unknown4 : 39|16@0+ (1,0) [0|65535] "" XXX + +BO_ 361 LKAS: 8 XXX + SG_ MAX_TORQUE : 39|8@0+ (0.01,0) [0|255] "Nm" XXX + SG_ SET_0x80 : 47|8@0+ (1,0) [0|255] "" XXX + SG_ LKA_ACTIVE : 52|1@0+ (1,0) [0|15] "" XXX + SG_ SET_0x80_2 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 51|4@0+ (1,0) [0|15] "" XXX + SG_ DESIRED_ANGLE : 7|18@0+ (-0.01,1310) [0|255] "" XXX + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 389 STEER_TORQUE_SENSOR: 8 XXX + SG_ LKAS_ACTIVE : 37|1@0+ (1,0) [0|3] "" XXX + SG_ STEER_TORQUE_LKAS : 47|8@0+ (1,0) [0|255] "" XXX + SG_ STEER_ANGLE : 23|18@0+ (-0.01,1310) [0|262143] "" XXX + SG_ STEER_TORQUE_DRIVER : 7|12@0+ (-0.01,20.47) [0|4095] "Nm" XXX + SG_ COUNTER : 51|4@0+ (1,0) [0|15] "" XXX + SG_ CHECKSUM : 63|8@0+ (1,0) [0|127] "" XXX + +BO_ 460 BRAKE_PEDAL: 8 XXX + SG_ BRAKE_PEDAL : 7|8@0+ (1,0) [0|256] "" XXX + +BO_ 569 CRUISE_THROTTLE: 8 XXX + SG_ GAS_PEDAL_INVERTED : 15|8@0+ (1,0) [0|255] "" XXX + SG_ GAS_PEDAL : 7|8@0+ (1,0) [0|255] "" XXX + SG_ CRUISE_AVAILABLE : 17|1@0+ (1,0) [0|1] "" XXX + SG_ unsure1 : 23|6@0+ (1,0) [0|63] "" XXX + SG_ unsure2 : 16|1@0+ (1,0) [0|1] "" XXX + SG_ unsure3 : 31|2@0+ (1,0) [0|3] "" XXX + SG_ NO_BUTTON_PRESSED : 29|1@0+ (1,0) [0|1] "" XXX + SG_ RES_BUTTON : 28|1@0+ (1,0) [0|1] "" XXX + SG_ SET_BUTTON : 27|1@0+ (1,0) [0|1] "" XXX + SG_ FOLLOW_DISTANCE_BUTTON : 26|1@0+ (1,0) [0|1] "" XXX + SG_ CANCEL_BUTTON : 25|1@0+ (1,0) [0|1] "" XXX + SG_ PROPILOT_BUTTON : 24|1@0+ (1,0) [0|1] "" XXX + SG_ unsure4 : 39|6@0+ (1,0) [0|63] "" XXX + SG_ COUNTER : 32|2@1+ (1,0) [0|3] "" XXX + SG_ unsure5 : 47|8@0+ (1,0) [0|255] "" XXX + SG_ unsure6 : 55|8@0+ (1,0) [0|255] "" XXX + SG_ unsure7 : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 640 CANCEL_MSG: 8 XXX + SG_ CANCEL_SEATBELT : 1|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_1 : 7|6@0+ (1,0) [0|63] "" XXX + SG_ NEW_SIGNAL_2 : 0|1@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_3 : 15|56@0+ (1,0) [0|72057594037927940] "" XXX + +BO_ 644 WHEEL_SPEEDS_FRONT: 8 XXX + SG_ WHEEL_SPEED_FR : 7|16@0+ (0.005,0) [0|65535] "KPH" XXX + SG_ WHEEL_SPEED_FL : 23|16@0+ (0.005,0) [0|65535] "KPH" XXX + +BO_ 645 WHEEL_SPEEDS_REAR: 8 XXX + SG_ WHEEL_SPEED_RR : 7|16@0+ (0.005,0) [0|65535] "KPH" XXX + SG_ WHEEL_SPEED_RL : 23|16@0+ (0.005,0) [0|65535] "KPH" XXX + +BO_ 689 PROPILOT_HUD: 8 XXX + SG_ LARGE_WARNING_FLASHING : 9|1@0+ (1,0) [0|1] "" XXX + SG_ SIDE_RADAR_ERROR_FLASHING1 : 10|1@0+ (1,0) [0|1] "" XXX + SG_ SIDE_RADAR_ERROR_FLASHING2 : 11|1@0+ (1,0) [0|1] "" XXX + SG_ RIGHT_LANE_YELLOW_FLASH : 12|1@0+ (1,0) [0|1] "" XXX + SG_ LEFT_LANE_YELLOW_FLASH : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LEAD_CAR : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LEAD_CAR_ERROR : 15|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_RADAR_ERROR : 16|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_RADAR_ERROR_FLASHING : 17|1@0+ (1,0) [0|1] "" XXX + SG_ RIGHT_LANE_GREEN : 24|1@0+ (1,0) [0|1] "" XXX + SG_ LEFT_LANE_GREEN : 25|1@0+ (1,0) [0|1] "" XXX + SG_ SIDE_RADAR_ERROR_FLASHING3 : 27|1@0+ (1,0) [0|1] "" XXX + SG_ LKAS_ERROR_FLASHING : 29|1@0+ (1,0) [0|1] "" XXX + SG_ SAFETY_SHIELD_ACTIVE : 44|1@0+ (1,0) [0|1] "" XXX + SG_ LARGE_STEERING_WHEEL_ICON : 61|2@0+ (1,0) [0|3] "" XXX + SG_ RIGHT_LANE_GREEN_FLASH : 62|1@0+ (1,0) [0|1] "" XXX + SG_ LEFT_LANE_GREEN_FLASH : 63|1@0+ (1,0) [0|1] "" XXX + SG_ FOLLOW_DISTANCE : 3|2@0+ (1,0) [0|3] "" XXX + SG_ AUDIBLE_TONE : 47|3@0+ (1,0) [0|8] "" XXX + SG_ SPEED_SET_ICON : 7|2@0+ (1,0) [0|3] "" XXX + SG_ SMALL_STEERING_WHEEL_ICON : 42|3@0+ (1,0) [0|7] "" XXX + SG_ SET_SPEED : 39|8@0+ (1,0) [0|255] "" XXX + SG_ unknown02 : 1|2@0+ (1,0) [0|3] "" XXX + SG_ unknown05 : 5|2@0+ (1,0) [0|3] "" XXX + SG_ unknown08 : 8|7@0+ (1,0) [0|63] "" XXX + SG_ unknown26 : 26|1@0+ (1,0) [0|1] "" XXX + SG_ unknown28 : 28|1@0+ (1,0) [0|1] "" XXX + SG_ unknown31 : 31|2@0+ (1,0) [0|3] "" XXX + SG_ unknown43 : 43|1@0+ (1,0) [0|1] "" XXX + SG_ unknown55 : 55|8@0+ (1,0) [0|63] "" XXX + SG_ unknown59 : 59|4@0+ (1,0) [0|15] "" XXX + +BO_ 783 CRUISE_STATE: 3 XXX + SG_ CRUISE_ENABLED : 3|1@0+ (1,0) [0|1] "" XXX + +BO_ 852 ESP: 8 XXX + SG_ ESP_DISABLED : 38|1@0+ (1,0) [0|1] "" XXX + +BO_ 853 HUD_SETTINGS: 8 XXX + SG_ SPEED_MPH : 37|1@0+ (1,0) [0|1] "" XXX + +BO_ 856 LIGHTS: 8 XXX + SG_ LEFT_BLINKER : 17|1@0+ (1,0) [0|1] "" XXX + SG_ RIGHT_BLINKER : 18|1@0+ (1,0) [0|1] "" XXX + +BO_ 1057 GEARBOX: 3 XXX + SG_ GEAR_SHIFTER : 5|3@0+ (1,0) [0|255] "" XXX + +BO_ 1228 PROPILOT_HUD_INFO_MSG: 8 XXX + SG_ NA_HIGH_ACCEL_TEMP : 0|1@0+ (1,0) [0|1] "" XXX + SG_ SIDE_RADAR_NA_HIGH_CABIN_TEMP : 8|1@0+ (1,0) [0|1] "" XXX + SG_ SIDE_RADAR_MALFUNCTION : 11|1@0+ (1,0) [0|1] "" XXX + SG_ LKAS_MALFUNCTION : 12|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_RADAR_MALFUNCTION : 13|1@0+ (1,0) [0|1] "" XXX + SG_ SIDE_RADAR_NA_CLEAN_REAR_CAMERA : 14|1@0+ (1,0) [0|1] "" XXX + SG_ NA_POOR_ROAD_CONDITIONS : 16|1@0+ (1,0) [0|1] "" XXX + SG_ CURRENTLY_UNAVAILABLE : 17|1@0+ (1,0) [0|1] "" XXX + SG_ SAFETY_SHIELD_OFF : 18|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_COLLISION_NA_FRONT_RADAR_OBSTRUCTION : 20|1@0+ (1,0) [0|1] "" XXX + SG_ PEDAL_MISSAPPLICATION_SYSTEM_ACTIVATED : 24|1@0+ (1,0) [0|1] "" XXX + SG_ SIDE_IMPACT_NA_RADAR_OBSTRUCTION : 25|1@0+ (1,0) [0|1] "" XXX + SG_ WARNING_DO_NOT_ENTER : 33|1@0+ (1,0) [0|1] "" XXX + SG_ SIDE_IMPACT_SYSTEM_OFF : 34|1@0+ (1,0) [0|1] "" XXX + SG_ SIDE_IMPACT_MALFUNCTION : 35|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_COLLISION_MALFUNCTION : 36|1@0+ (1,0) [0|1] "" XXX + SG_ SIDE_RADAR_MALFUNCTION2 : 37|1@0+ (1,0) [0|1] "" XXX + SG_ LKAS_MALFUNCTION2 : 38|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_RADAR_MALFUNCTION2 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ PROPILOT_NA_MSGS : 42|3@0+ (1,0) [0|7] "" XXX + SG_ BOTTOM_MSG : 45|3@0+ (1,0) [0|7] "" XXX + SG_ HANDS_ON_WHEEL_WARNING : 47|1@0+ (1,0) [0|1] "" XXX + SG_ WARNING_STEP_ON_BRAKE_NOW : 51|1@0+ (1,0) [0|1] "" XXX + SG_ PROPILOT_NA_FRONT_CAMERA_OBSTRUCTED : 52|1@0+ (1,0) [0|1] "" XXX + SG_ PROPILOT_NA_HIGH_CABIN_TEMP : 53|1@0+ (1,0) [0|1] "" XXX + SG_ WARNING_PROPILOT_MALFUNCTION : 54|1@0+ (1,0) [0|3] "" XXX + SG_ ACC_UNAVAILABLE_HIGH_CABIN_TEMP : 62|1@0+ (1,0) [0|1] "" XXX + SG_ ACC_NA_FRONT_CAMERA_IMPARED : 63|1@0+ (1,0) [0|1] "" XXX + SG_ unknown07 : 7|7@0+ (1,0) [0|127] "" XXX + SG_ unknown10 : 10|2@0+ (1,0) [0|3] "" XXX + SG_ unknown15 : 15|1@0+ (1,0) [0|1] "" XXX + SG_ unknown23 : 23|3@0+ (1,0) [0|7] "" XXX + SG_ unknown19 : 19|1@0+ (1,0) [0|1] "" XXX + SG_ unknown31 : 31|6@0+ (1,0) [0|63] "" XXX + SG_ unknown32 : 32|1@0+ (1,0) [0|1] "" XXX + SG_ unknown46 : 46|1@0+ (1,0) [0|1] "" XXX + SG_ unknown50 : 50|3@0+ (1,0) [0|7] "" XXX + SG_ unknown55 : 55|1@0+ (1,0) [0|1] "" XXX + SG_ unknown61 : 61|6@0+ (1,0) [0|63] "" XXX + +BO_ 1549 DOORS_LIGHTS: 8 XXX + SG_ DOOR_OPEN_FL : 3|1@0+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_FR : 4|1@0+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_RL : 5|1@0+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_RR : 6|1@0+ (1,0) [0|1] "" XXX + +BO_ 1227 LKAS_SETTINGS: 8 XXX + SG_ LKAS_ENABLED : 51|1@0+ (1,0) [0|1] "" XXX + +VAL_ 1057 GEAR_SHIFTER 7 "B" 4 "D" 3 "N" 2 "R" 1 "P" ; +VAL_ 1228 PROPILOT_NA_MSGS 0 "NO_MSG" 1 "NA_FRONT_CAMERA_IMPARED" 2 "STEERING_ASSIST_ON_STANDBY" 3 "NA_PARKING_ASSIST_ENABLED" 4 "STEER_ASSIST_CURRENTLY_NA" 5 "NA_BAD_WEATHER" 6 "NA_PARK_BRAKE_ON" 7 "NA_SEATBELT_NOT_FASTENED" ; +VAL_ 1228 BOTTOM_MSG 0 "OK_STEER_ASSIST_SETTINGS" 1 "NO_MSG" 2 "PRESS_SET_TO_SET_SPEED" 3 "PRESS_RES_SET_TO_CHANGE_SPEED" 4 "PRESS_RES_TO_RESTART" 5 "NO_MSG" 6 "CRUISE_NOT_AVAIL" 7 "NO_MSG" ; +VAL_ 689 FOLLOW_DISTANCE 0 "NO_FOLLOW_DISTANCE" 1 "FOLLOW_DISTANCE_1" 2 "FOLLOW_DISTANCE_2" 3 "FOLLOW_DISANCE_3" ; +VAL_ 689 AUDIBLE_TONE 0 "NO_TONE" 1 "CONT" 2 "FAST_BEEP_CONT" 3 "TRIPLE_FAST_BEEP_CONT" 4 "SLOW_BEEP_CONT" 5 "QUAD_SLOW_BEEP_CONT" 6 "SINGLE_BEEP_ONCE" 7 "DOUBLE_BEEP_ONCE" ; +VAL_ 689 SMALL_STEERING_WHEEL_ICON 0 "NO_ICON" 1 "GRAY_ICON" 2 "GRAY_ICON_FLASHING" 3 "GREEN_ICON" 4 "GREEN_ICON_FLASHING" 5 "RED_ICON" 6 "RED_ICON_FLASHING" 7 "YELLOW_ICON" ; +VAL_ 689 LARGE_STEERING_WHEEL_ICON 0 "NO_STEERINGWHEEL" 1 "GRAY_STEERINGWHEEL" 2 "GREEN_STEERINGWHEEL" 3 "GREEN_STEERINGWHEEL_FLASHING" ; diff --git a/opendbc/nissan_x_trail_2017.dbc b/opendbc/nissan_x_trail_2017.dbc new file mode 100644 index 00000000000000..ea27445d3286e2 --- /dev/null +++ b/opendbc/nissan_x_trail_2017.dbc @@ -0,0 +1,218 @@ +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_ 2 STEER_ANGLE_SENSOR: 5 XXX + SG_ STEER_ANGLE_RATE : 16|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_X07 : 24|8@1+ (1,0) [0|255] "" XXX + SG_ STEER_ANGLE : 0|16@1- (-0.1,0) [0|65535] "" XXX + SG_ COUNTER : 32|4@1+ (1,0) [0|15] "" XXX + +BO_ 348 GAS_PEDAL: 8 XXX + SG_ GAS_PEDAL_RAW : 26|11@0+ (1,0) [0|2047] "" XXX + SG_ GAS_PEDAL : 47|10@0+ (1,0) [0|1023] "" XXX + +BO_ 361 LKAS: 8 XXX + SG_ MAX_TORQUE : 39|8@0+ (0.01,0) [0|255] "Nm" XXX + SG_ SET_0x80 : 47|8@0+ (1,0) [0|255] "" XXX + SG_ LKA_ACTIVE : 52|1@0+ (1,0) [0|15] "" XXX + SG_ SET_0x80_2 : 31|8@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 51|4@0+ (1,0) [0|15] "" XXX + SG_ DESIRED_ANGLE : 7|18@0+ (-0.01,1310) [0|255] "" XXX + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX + +BO_ 389 STEER_TORQUE_SENSOR: 8 XXX + SG_ LKAS_ACTIVE : 37|1@0+ (1,0) [0|3] "" XXX + SG_ STEER_TORQUE_LKAS : 47|8@0+ (1,0) [0|255] "" XXX + SG_ STEER_ANGLE : 23|18@0+ (-0.01,1310) [0|262143] "" XXX + SG_ STEER_TORQUE_DRIVER : 7|12@0+ (-0.01,20.47) [0|4095] "Nm" XXX + SG_ COUNTER : 51|4@0+ (1,0) [0|15] "" XXX + SG_ CHECKSUM : 63|8@0+ (1,0) [0|127] "" XXX + +BO_ 438 PRO_PILOT: 8 XXX + SG_ COUNTER : 55|4@0+ (1,0) [0|255] "" XXX + SG_ SET_ME_X03 : 33|2@0+ (1,0) [0|15] "" XXX + SG_ CRUISE_ACTIVATED : 38|1@0+ (1,0) [0|3] "" XXX + SG_ CRUISE_ON : 36|1@0+ (1,0) [0|255] "" XXX + SG_ STEER_STATUS : 51|1@0+ (1,0) [0|3] "" XXX + +BO_ 523 CRUISE_THROTTLE: 6 XXX + SG_ PROPILOT_BUTTON : 8|1@0+ (1,0) [0|1] "" XXX + SG_ CANCEL_BUTTON : 9|1@0+ (1,0) [0|1] "" XXX + SG_ GAS_PEDAL_INVERTED : 37|10@0+ (1,0) [0|1023] "" XXX + SG_ SET_BUTTON : 11|1@0+ (1,0) [0|1] "" XXX + SG_ RES_BUTTON : 12|1@0+ (1,0) [0|1] "" XXX + SG_ FOLLOW_DISTANCE_BUTTON : 10|1@0+ (1,0) [0|1] "" XXX + SG_ NO_BUTTON_PRESSED : 13|1@0+ (1,0) [0|1] "" XXX + SG_ GAS_PEDAL : 31|10@0+ (1,0) [0|255] "" XXX + SG_ USER_BRAKE_PRESSED : 21|1@0+ (1,0) [0|1] "" XXX + SG_ USER_BRAKE_PRESSED_INVERTED : 22|1@0+ (1,0) [0|3] "" XXX + SG_ NEW_SIGNAL_2 : 23|1@0+ (1,0) [0|1] "" XXX + SG_ GAS_PRESSED_INVERTED : 20|1@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 17|2@0+ (1,0) [0|3] "" XXX + SG_ unsure1 : 7|10@0+ (1,0) [0|1023] "" XXX + SG_ unsure2 : 43|4@0+ (1,0) [0|1] "" XXX + SG_ unsure3 : 19|2@0+ (1,0) [0|3] "" XXX + +BO_ 645 WHEEL_SPEEDS_REAR: 8 XXX + SG_ WHEEL_SPEED_RR : 7|16@0+ (0.005,0) [0|65535] "KPH" XXX + SG_ WHEEL_SPEED_RL : 23|16@0+ (0.005,0) [0|65535] "KPH" XXX + +BO_ 665 ESP: 8 XXX + SG_ ESP_DISABLED : 24|1@0+ (1,0) [0|1] "" XXX + +BO_ 666 WHEEL_SPEEDS_FRONT: 8 XXX + SG_ WHEEL_SPEED_FR : 7|16@0+ (0.005,0) [0|65535] "KPH" XXX + SG_ WHEEL_SPEED_FL : 23|16@0+ (0.005,0) [0|65535] "KPH" XXX + +BO_ 689 PROPILOT_HUD: 8 XXX + SG_ LARGE_WARNING_FLASHING : 9|1@0+ (1,0) [0|1] "" XXX + SG_ SIDE_RADAR_ERROR_FLASHING1 : 10|1@0+ (1,0) [0|1] "" XXX + SG_ SIDE_RADAR_ERROR_FLASHING2 : 11|1@0+ (1,0) [0|1] "" XXX + SG_ RIGHT_LANE_YELLOW_FLASH : 12|1@0+ (1,0) [0|1] "" XXX + SG_ LEFT_LANE_YELLOW_FLASH : 13|1@0+ (1,0) [0|1] "" XXX + SG_ LEAD_CAR : 14|1@0+ (1,0) [0|1] "" XXX + SG_ LEAD_CAR_ERROR : 15|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_RADAR_ERROR : 16|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_RADAR_ERROR_FLASHING : 17|1@0+ (1,0) [0|1] "" XXX + SG_ RIGHT_LANE_GREEN : 24|1@0+ (1,0) [0|1] "" XXX + SG_ LEFT_LANE_GREEN : 25|1@0+ (1,0) [0|1] "" XXX + SG_ SIDE_RADAR_ERROR_FLASHING3 : 27|1@0+ (1,0) [0|1] "" XXX + SG_ LKAS_ERROR_FLASHING : 29|1@0+ (1,0) [0|1] "" XXX + SG_ SAFETY_SHIELD_ACTIVE : 44|1@0+ (1,0) [0|1] "" XXX + SG_ LARGE_STEERING_WHEEL_ICON : 61|2@0+ (1,0) [0|3] "" XXX + SG_ RIGHT_LANE_GREEN_FLASH : 62|1@0+ (1,0) [0|1] "" XXX + SG_ LEFT_LANE_GREEN_FLASH : 63|1@0+ (1,0) [0|1] "" XXX + SG_ FOLLOW_DISTANCE : 3|2@0+ (1,0) [0|3] "" XXX + SG_ AUDIBLE_TONE : 47|3@0+ (1,0) [0|8] "" XXX + SG_ SPEED_SET_ICON : 7|2@0+ (1,0) [0|3] "" XXX + SG_ SMALL_STEERING_WHEEL_ICON : 42|3@0+ (1,0) [0|7] "" XXX + SG_ SET_SPEED : 39|8@0+ (1,0) [0|255] "" XXX + SG_ unknown02 : 1|2@0+ (1,0) [0|3] "" XXX + SG_ unknown05 : 5|2@0+ (1,0) [0|3] "" XXX + SG_ unknown08 : 8|7@0+ (1,0) [0|63] "" XXX + SG_ unknown26 : 26|1@0+ (1,0) [0|1] "" XXX + SG_ unknown28 : 28|1@0+ (1,0) [0|1] "" XXX + SG_ unknown31 : 31|2@0+ (1,0) [0|3] "" XXX + SG_ unknown43 : 43|1@0+ (1,0) [0|1] "" XXX + SG_ unknown55 : 55|8@0+ (1,0) [0|63] "" XXX + SG_ unknown59 : 59|4@0+ (1,0) [0|15] "" XXX + +BO_ 768 STEER_TORQUE_SENSOR2: 2 XXX + SG_ STEERING_TORQUE : 6|7@0+ (1,0) [0|127] "" XXX + SG_ STEERING_PRESSED : 15|1@0+ (-1,1) [0|7] "" XXX + +BO_ 783 CRUISE_STATE: 3 XXX + SG_ CRUISE_ENABLED : 3|1@0+ (1,0) [0|1] "" XXX + +BO_ 1055 GEARBOX: 2 XXX + SG_ SPORTS_MODE : 13|1@0+ (1,0) [0|1] "" XXX + SG_ GEAR_SHIFTER : 5|3@0+ (1,0) [0|255] "" XXX + +BO_ 1107 LIGHTS: 8 XXX + SG_ RIGHT_BLINKER : 12|1@0+ (1,0) [0|1] "" XXX + SG_ LEFT_BLINKER : 11|1@0+ (1,0) [0|1] "" XXX + SG_ HEADLIGHTS : 5|1@0+ (1,0) [0|1] "" XXX + +BO_ 1108 DOORS_LIGHTS: 8 XXX + SG_ DOOR_CLOSED_RR : 40|1@0+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_RR : 41|1@0+ (1,0) [0|1] "" XXX + SG_ DOOR_CLOSED_RL : 42|1@0+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_RL : 43|1@0+ (1,0) [0|1] "" XXX + SG_ DOOR_CLOSED_FL : 44|1@0+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX + SG_ DOOR_CLOSED_FR : 46|1@0+ (1,0) [0|3] "" XXX + SG_ DOOR_OPEN_FR : 47|1@0+ (1,0) [0|3] "" XXX + SG_ BOOT_OPEN : 55|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE_LIGHT : 54|1@0+ (1,0) [0|1] "" XXX + SG_ USER_BRAKE_PRESSED : 23|1@0+ (1,0) [0|1] "" XXX + +BO_ 1228 PROPILOT_HUD_INFO_MSG: 8 XXX + SG_ NA_HIGH_ACCEL_TEMP : 0|1@0+ (1,0) [0|1] "" XXX + SG_ SIDE_RADAR_NA_HIGH_CABIN_TEMP : 8|1@0+ (1,0) [0|1] "" XXX + SG_ SIDE_RADAR_MALFUNCTION : 11|1@0+ (1,0) [0|1] "" XXX + SG_ LKAS_MALFUNCTION : 12|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_RADAR_MALFUNCTION : 13|1@0+ (1,0) [0|1] "" XXX + SG_ SIDE_RADAR_NA_CLEAN_REAR_CAMERA : 14|1@0+ (1,0) [0|1] "" XXX + SG_ NA_POOR_ROAD_CONDITIONS : 16|1@0+ (1,0) [0|1] "" XXX + SG_ CURRENTLY_UNAVAILABLE : 17|1@0+ (1,0) [0|1] "" XXX + SG_ SAFETY_SHIELD_OFF : 18|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_COLLISION_NA_FRONT_RADAR_OBSTRUCTION : 20|1@0+ (1,0) [0|1] "" XXX + SG_ PEDAL_MISSAPPLICATION_SYSTEM_ACTIVATED : 24|1@0+ (1,0) [0|1] "" XXX + SG_ SIDE_IMPACT_NA_RADAR_OBSTRUCTION : 25|1@0+ (1,0) [0|1] "" XXX + SG_ WARNING_DO_NOT_ENTER : 33|1@0+ (1,0) [0|1] "" XXX + SG_ SIDE_IMPACT_SYSTEM_OFF : 34|1@0+ (1,0) [0|1] "" XXX + SG_ SIDE_IMPACT_MALFUNCTION : 35|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_COLLISION_MALFUNCTION : 36|1@0+ (1,0) [0|1] "" XXX + SG_ SIDE_RADAR_MALFUNCTION2 : 37|1@0+ (1,0) [0|1] "" XXX + SG_ LKAS_MALFUNCTION2 : 38|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_RADAR_MALFUNCTION2 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ PROPILOT_NA_MSGS : 42|3@0+ (1,0) [0|7] "" XXX + SG_ BOTTOM_MSG : 45|3@0+ (1,0) [0|7] "" XXX + SG_ HANDS_ON_WHEEL_WARNING : 47|1@0+ (1,0) [0|1] "" XXX + SG_ WARNING_STEP_ON_BRAKE_NOW : 51|1@0+ (1,0) [0|1] "" XXX + SG_ PROPILOT_NA_FRONT_CAMERA_OBSTRUCTED : 52|1@0+ (1,0) [0|1] "" XXX + SG_ PROPILOT_NA_HIGH_CABIN_TEMP : 53|1@0+ (1,0) [0|1] "" XXX + SG_ WARNING_PROPILOT_MALFUNCTION : 54|1@0+ (1,0) [0|3] "" XXX + SG_ ACC_UNAVAILABLE_HIGH_CABIN_TEMP : 62|1@0+ (1,0) [0|1] "" XXX + SG_ ACC_NA_FRONT_CAMERA_IMPARED : 63|1@0+ (1,0) [0|1] "" XXX + SG_ unknown07 : 7|7@0+ (1,0) [0|127] "" XXX + SG_ unknown10 : 10|2@0+ (1,0) [0|3] "" XXX + SG_ unknown15 : 15|1@0+ (1,0) [0|1] "" XXX + SG_ unknown23 : 23|3@0+ (1,0) [0|7] "" XXX + SG_ unknown19 : 19|1@0+ (1,0) [0|1] "" XXX + SG_ unknown31 : 31|6@0+ (1,0) [0|63] "" XXX + SG_ unknown32 : 32|1@0+ (1,0) [0|1] "" XXX + SG_ unknown46 : 46|1@0+ (1,0) [0|1] "" XXX + SG_ unknown50 : 50|3@0+ (1,0) [0|7] "" XXX + SG_ unknown55 : 55|1@0+ (1,0) [0|1] "" XXX + SG_ unknown61 : 61|6@0+ (1,0) [0|63] "" XXX + +BO_ 1227 LKAS_SETTINGS: 8 XXX + SG_ LKAS_ENABLED : 51|1@0+ (1,0) [0|1] "" XXX + +BO_ 1273 HUD: 7 XXX + SG_ SEATBELT_DRIVER_LATCHED : 25|1@0+ (1,0) [0|1] "" XXX + SG_ SPEED_MPH : 5|1@0+ (1,0) [0|1] "" XXX + +VAL_ 1055 GEAR_SHIFTER 6 "L" 4 "D" 3 "N" 2 "R" 1 "P" ; +VAL_ 1228 PROPILOT_NA_MSGS 0 "NO_MSG" 1 "NA_FRONT_CAMERA_IMPARED" 2 "STEERING_ASSIST_ON_STANDBY" 3 "NA_PARKING_ASSIST_ENABLED" 4 "STEER_ASSIST_CURRENTLY_NA" 5 "NA_BAD_WEATHER" 6 "NA_PARK_BRAKE_ON" 7 "NA_SEATBELT_NOT_FASTENED" ; +VAL_ 1228 BOTTOM_MSG 0 "OK_STEER_ASSIST_SETTINGS" 1 "NO_MSG" 2 "PRESS_SET_TO_SET_SPEED" 3 "PRESS_RES_SET_TO_CHANGE_SPEED" 4 "PRESS_RES_TO_RESTART" 5 "NO_MSG" 6 "CRUISE_NOT_AVAIL" 7 "NO_MSG" ; +VAL_ 689 FOLLOW_DISTANCE 0 "NO_FOLLOW_DISTANCE" 1 "FOLLOW_DISTANCE_1" 2 "FOLLOW_DISTANCE_2" 3 "FOLLOW_DISANCE_3" ; +VAL_ 689 AUDIBLE_TONE 0 "NO_TONE" 1 "CONT" 2 "FAST_BEEP_CONT" 3 "TRIPLE_FAST_BEEP_CONT" 4 "SLOW_BEEP_CONT" 5 "QUAD_SLOW_BEEP_CONT" 6 "SINGLE_BEEP_ONCE" 7 "DOUBLE_BEEP_ONCE" ; +VAL_ 689 SMALL_STEERING_WHEEL_ICON 0 "NO_ICON" 1 "GRAY_ICON" 2 "GRAY_ICON_FLASHING" 3 "GREEN_ICON" 4 "GREEN_ICON_FLASHING" 5 "RED_ICON" 6 "RED_ICON_FLASHING" 7 "YELLOW_ICON" ; +VAL_ 689 LARGE_STEERING_WHEEL_ICON 0 "NO_STEERINGWHEEL" 1 "GRAY_STEERINGWHEEL" 2 "GREEN_STEERINGWHEEL" 3 "GREEN_STEERINGWHEEL_FLASHING" ; diff --git a/opendbc/subaru_forester_2017_generated.dbc b/opendbc/subaru_forester_2017_generated.dbc new file mode 100644 index 00000000000000..c1ef35fbc1d67f --- /dev/null +++ b/opendbc/subaru_forester_2017_generated.dbc @@ -0,0 +1,258 @@ +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; + + +CM_ "Imported file _subaru_preglobal_2015.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 X + + +BO_ 2 Steering: 8 XXX + SG_ Steering_Angle : 7|16@0- (0.1,0) [-500|500] "degree" XXX + SG_ Counter : 27|3@0+ (1,0) [0|7] "" XXX + SG_ Checksum : 39|8@0+ (1,0) [0|255] "" XXX + +BO_ 208 G_Sensor: 8 XXX + SG_ Steering_Angle : 0|16@1- (-0.1,0) [-500|500] "" XXX + SG_ Lateral : 16|16@1- (-0.0035,1) [-255|255] "" XXX + SG_ Longitudinal : 48|16@1- (-0.00035,0) [-255|255] "" XXX + +BO_ 209 Brake_Pedal: 8 XXX + SG_ Speed : 0|16@1+ (0.05625,0) [0|255] "KPH" XXX + SG_ Brake_Pedal : 16|8@1+ (1,0) [0|255] "" XXX + +BO_ 210 Brake_2: 8 XXX + SG_ Brake_Light : 35|1@1+ (1,0) [0|1] "" XXX + SG_ Brake_Related : 36|1@1+ (1,0) [0|1] "" XXX + SG_ Right_Brake : 48|8@1+ (1,0) [0|255] "" XXX + SG_ Left_Brake : 56|8@1+ (1,0) [0|255] "" XXX + +BO_ 211 Brake_Type: 8 XXX + SG_ Brake_Light : 21|1@1+ (1,0) [0|1] "" XXX + SG_ Speed_Counter : 32|8@1+ (1,0) [0|255] "" XXX + SG_ Brake_Cruise_On : 42|1@1+ (1,0) [0|1] "" XXX + SG_ Brake_Pedal_On : 46|1@1+ (1,0) [0|1] "" XXX + SG_ Counter : 48|8@1+ (1,0) [0|255] "" XXX + +BO_ 212 Wheel_Speeds: 8 XXX + SG_ FL : 0|16@1+ (0.0592,0) [0|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] "KPH" XXX + SG_ RR : 48|16@1+ (0.0592,0) [0|255] "KPH" XXX + +BO_ 320 Throttle: 8 XXX + SG_ Throttle_Pedal : 0|8@1+ (0.392157,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Not_Full_Throttle : 14|1@1+ (1,0) [0|1] "" XXX + SG_ Engine_RPM : 16|14@1+ (1,0) [0|32767] "" XXX + SG_ Off_Throttle : 30|1@1+ (1,0) [0|1] "" XXX + SG_ Throttle_Cruise : 32|8@1+ (1,0) [0|255] "" XXX + SG_ Throttle_Combo : 40|8@1+ (1,0) [0|255] "" XXX + SG_ Throttle_Body : 48|8@1+ (1,0) [0|255] "" XXX + SG_ Off_Throttle_2 : 56|1@1+ (1,0) [0|1] "" XXX + +BO_ 321 Engine: 8 XXX + SG_ Engine_Torque : 0|15@1+ (1,0) [0|255] "" XXX + SG_ Engine_Stop : 15|1@1+ (1,0) [0|1] "" XXX + SG_ Wheel_Torque : 16|12@1+ (1,0) [0|4095] "" XXX + SG_ Engine_RPM : 32|12@1+ (1,0) [0|8191] "" XXX + +BO_ 324 CruiseControl: 8 XXX + SG_ OnOffButton : 2|1@1+ (1,0) [0|1] "" XXX + SG_ SET_BUTTON : 3|1@1+ (1,0) [0|1] "" XXX + SG_ RES_BUTTON : 4|1@1+ (1,0) [0|1] "" XXX + SG_ Button : 13|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_On : 48|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Activated : 49|1@1+ (1,0) [0|1] "" XXX + SG_ Brake_Pedal_On : 51|1@1+ (1,0) [0|1] "" XXX + +BO_ 328 Transmission: 8 XXX + SG_ Manual_Gear : 4|4@1+ (1,0) [0|15] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Transmission_Engine : 16|15@1+ (1,0) [0|65535] "" XXX + SG_ Gear : 48|4@1+ (1,0) [0|15] "" XXX + SG_ Gear_2 : 52|4@1+ (1,0) [0|15] "" XXX + SG_ Paddle_Shift : 60|2@1+ (1,0) [0|3] "" XXX + +BO_ 329 CVT_Ratio: 8 XXX + +BO_ 336 Brake_Pressure: 8 XXX + SG_ Brake_Pressure_Right : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Brake_Pressure_Left : 8|8@1+ (1,0) [0|255] "" XXX + +BO_ 338 Stalk: 8 XXX + SG_ Counter : 12|4@1+ (1,0) [0|15] "" XXX + SG_ Brake_Light : 52|1@1+ (1,0) [0|1] "" XXX + SG_ Runlights : 58|1@1+ (1,0) [0|1] "" XXX + SG_ Headlights : 59|1@1+ (1,0) [0|1] "" XXX + SG_ Highbeam : 60|1@1+ (1,0) [0|1] "" XXX + SG_ Wiper : 62|1@1+ (1,0) [0|1] "" XXX + +BO_ 352 ES_Brake: 8 XXX + SG_ Brake_Pressure : 0|16@1+ (1,0) [0|255] "" XXX + SG_ Brake_Light : 20|1@1+ (1,0) [0|1] "" XXX + SG_ ES_Error : 21|1@1+ (1,0) [0|1] "" XXX + SG_ Brake_On : 22|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Activated : 23|1@1+ (1,0) [0|1] "" XXX + SG_ Counter : 48|3@1+ (1,0) [0|7] "" XXX + SG_ Checksum : 56|8@1+ (1,0) [0|255] "" XXX + +BO_ 353 ES_CruiseThrottle: 8 XXX + SG_ Throttle_Cruise : 0|12@1+ (1,0) [0|4095] "" XXX + SG_ Signal1 : 12|4@1+ (1,0) [0|15] "" XXX + SG_ Cruise_Activated : 16|1@1+ (1,0) [0|1] "" XXX + SG_ Signal2 : 17|3@1+ (1,0) [0|7] "" XXX + SG_ Brake_On : 20|1@1+ (1,0) [0|1] "" XXX + SG_ DistanceSwap : 21|1@1+ (1,0) [0|1] "" XXX + SG_ Standstill : 22|1@1+ (1,0) [0|1] "" XXX + SG_ Signal3 : 23|1@1+ (1,0) [0|1] "" XXX + SG_ CloseDistance : 24|8@1+ (0.0196,0) [0|255] "m" XXX + SG_ Signal4 : 32|9@1+ (1,0) [0|255] "" XXX + SG_ Standstill_2 : 41|1@1+ (1,0) [0|1] "" XXX + SG_ ES_Error : 42|1@1+ (1,0) [0|1] "" XXX + SG_ Signal5 : 43|1@1+ (1,0) [0|1] "" XXX + SG_ Counter : 44|3@1+ (1,0) [0|7] "" XXX + SG_ Signal6 : 47|1@1+ (1,0) [0|1] "" XXX + SG_ Button : 48|3@1+ (1,0) [0|7] "" XXX + SG_ Signal7 : 51|5@1+ (1,0) [0|31] "" XXX + SG_ Checksum : 56|8@1+ (1,0) [0|255] "" XXX + +BO_ 354 ES_RPM: 8 XXX + SG_ Brake : 8|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Activated : 9|1@1+ (1,0) [0|1] "" XXX + SG_ RPM : 16|16@1+ (1,0) [0|65535] "" XXX + SG_ Checksum : 32|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 48|3@1+ (1,0) [0|7] "" XXX + +BO_ 356 ES_LKAS: 8 XXX + SG_ Counter : 0|3@1+ (1,0) [0|7] "" XXX + SG_ LKAS_Command : 8|13@1- (-1,0) [-4096|4096] "" XXX + SG_ LKAS_Active : 24|1@1+ (1,0) [0|1] "" XXX + SG_ Checksum : 56|8@1+ (1,0) [0|255] "" XXX + +BO_ 359 ES_LDW: 8 XXX + SG_ All_depart_2015 : 0|1@1+ (1,0) [0|1] "" XXX + SG_ Right_Line_2017 : 24|1@1+ (1,0) [0|1] "" XXX + SG_ Left_Line_2017 : 25|1@1+ (1,0) [0|1] "" XXX + SG_ Sig1All_Depart : 28|1@1+ (1,0) [0|1] "" XXX + SG_ Sig2All_Depart : 31|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_Inactive_2017 : 36|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_Active : 37|1@1+ (1,0) [0|1] "" XXX + SG_ Sig1Right_Depart : 48|1@1+ (1,0) [0|1] "" XXX + SG_ Sig1Right_Depart_Front : 49|1@1+ (1,0) [0|1] "" XXX + SG_ Sig2Right_Depart : 50|1@1+ (1,0) [0|1] "" XXX + SG_ Left_Depart_Front : 51|1@1+ (1,0) [0|1] "" XXX + SG_ Sig3All_Depart : 52|1@1+ (1,0) [0|1] "" XXX + +BO_ 604 BSD_RCTA: 8 XXX + SG_ Counter : 0|3@1+ (1,0) [0|7] "" XXX + SG_ State : 5|1@1+ (1,0) [0|1] "" XXX + SG_ R_ADJACENT : 32|1@1+ (1,0) [0|1] "" XXX + SG_ L_ADJACENT : 33|1@1+ (1,0) [0|1] "" XXX + SG_ R_APPROACHING : 42|1@1+ (1,0) [0|1] "" XXX + SG_ L_APPROACHING : 43|1@1+ (1,0) [0|1] "" XXX + SG_ R_RCTA : 46|1@1+ (1,0) [0|1] "" XXX + SG_ L_RCTA : 47|1@1+ (1,0) [0|1] "" XXX + +BO_ 642 Dashlights: 8 XXX + SG_ Counter : 12|4@1+ (1,0) [0|15] "" XXX + SG_ SEATBELT_FL : 40|1@1+ (1,0) [0|1] "" XXX + SG_ LEFT_BLINKER : 44|1@1+ (1,0) [0|1] "" XXX + SG_ RIGHT_BLINKER : 45|1@1+ (1,0) [0|1] "" XXX + +BO_ 880 Steering_Torque_2: 8 XXX + SG_ Steering_Voltage_Flat : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Steer_Torque_Sensor : 29|11@1- (-1,0) [-1000|1000] "" XXX + SG_ Counter : 40|4@1+ (1,0) [0|15] "" XXX + +BO_ 884 BodyInfo: 8 XXX + SG_ DOOR_OPEN_FR : 24|1@1+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_FL : 25|1@1+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_RL : 26|1@1+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_RR : 27|1@1+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_Hatch : 28|1@1+ (1,0) [0|1] "" XXX + +BO_ 864 Engine_Temp: 8 XXX + SG_ Oil_Temp : 16|8@1+ (1,-40) [0|255] "" XXX + SG_ Coolant_Temp : 24|8@1+ (1,-40) [0|255] "" XXX + SG_ Cruise_Activated : 45|1@1+ (1,0) [0|1] "" XXX + SG_ Saved_Speed : 56|8@1+ (1,0) [0|255] "" XXX + +BO_ 866 Fuel: 8 XXX + +BO_ 1745 Dash_State: 8 XXX + SG_ Units : 15|1@1+ (1,0) [0|1] "" XXX + +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_ 353 Button "1 = main, 2 = set shallow, 3 = set deep, 4 = resume shallow, 5 resume deep"; +CM_ SG_ 354 RPM "20hz version of Transmission_Engine under Transmission"; +CM_ SG_ 359 Sig1Right_Depart "right depart, hill steep and seatbelt disengage"; +CM_ SG_ 359 LKAS_Inactive_2017 "1 when not steering, 0 when lkas steering"; +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_ 359 Sig1All_Depart "Left and right depart"; +CM_ SG_ 359 Sig2All_Depart "Left and right depart"; +CM_ SG_ 359 All_depart_2015 "always 1 on 2017"; +CM_ SG_ 604 R_APPROACHING "Faster car approaching in far right lane"; +CM_ SG_ 604 L_APPROACHING "Faster car approaching in far left lane"; +CM_ SG_ 604 R_RCTA "Rear cross traffic alert, only when in R gear"; +CM_ SG_ 604 L_RCTA "Rear cross traffic alert, only when in R gear"; +CM_ SG_ 642 Counter "Affected by signals"; +CM_ SG_ 642 SEATBELT_FL "Driver seatbelt"; +CM_ SG_ 880 Steering_Voltage_Flat "receives later than 371"; + +VAL_ 328 Gear 0 "N" 1 "D" 2 "D" 3 "D" 4 "D" 5 "D" 6 "D" 14 "R" 15 "P"; +VAL_ 1745 Units 0 "Metric" 1 "Imperial"; + +CM_ "subaru_forester_2017.dbc starts here"; + + +BO_ 355 ES_DashStatus: 8 XXX + SG_ Not_Ready_Startup : 4|2@1+ (1,0) [0|3] "" XXX + SG_ Cruise_On : 16|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Set_Speed : 24|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 40|3@1+ (1,0) [0|7] "" XXX + SG_ Cruise_Activated : 54|1@1+ (1,0) [0|1] "" XXX + +BO_ 881 Steering_Torque: 8 XXX + SG_ Steering_Motor_Flat : 0|10@1+ (32,0) [0|1000] "" XXX + SG_ Steer_Torque_Output : 16|11@1- (-32,0) [-1000|1000] "" XXX + SG_ LKA_Lockout : 27|1@1+ (1,0) [0|1] "" XXX + SG_ Steer_Torque_Sensor : 29|11@1- (-1,0) [-1000|1000] "" XXX + SG_ Steering_Angle : 40|16@1- (-0.033,0) [-600|600] "" XXX diff --git a/opendbc/subaru_global_2017.dbc b/opendbc/subaru_global_2017.dbc deleted file mode 100644 index 0e2c87f8137d4c..00000000000000 --- a/opendbc/subaru_global_2017.dbc +++ /dev/null @@ -1,363 +0,0 @@ -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 X - - -BO_ 2 Steering: 8 XXX - SG_ Counter : 25|3@1+ (1,0) [0|7] "" XXX - SG_ Checksum : 32|8@1+ (1,0) [0|255] "" XXX - SG_ Steering_Angle : 7|16@0- (0.1,0) [0|65535] "" XXX - -BO_ 64 Throttle: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|255] "" XXX - SG_ Off_Accel : 60|4@1+ (1,0) [0|7] "" XXX - SG_ NEW_SIGNAL_3 : 56|4@1+ (1,0) [0|255] "" XXX - SG_ Engine_RPM : 16|12@1+ (1,0) [0|255] "" XXX - SG_ Throttle_Cruise : 40|8@1+ (1,0) [0|255] "" XXX - SG_ Throttle_Combo : 55|8@1+ (1,0) [0|255] "" XXX - SG_ Throttle_Pedal : 32|8@1+ (1,0) [0|255] "" XXX - - -BO_ 65 NEW_MSG_1: 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_4 : 32|12@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 16|12@1+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_5 : 31|1@0+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_6 : 48|8@1+ (1,0) [0|63] "" XXX - SG_ NEW_SIGNAL_7 : 59|2@0+ (1,0) [0|255] "" XXX - -BO_ 72 NEW_MSG_2: 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 : 40|16@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 38|3@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 16|8@1+ (1,0) [0|255] "" XXX - -BO_ 316 NEW_MSG_3: 8 XXX - -BO_ 326 Cruise_Buttons: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX - SG_ Signal1 : 12|30@1+ (1,0) [0|1073741823] "" XXX - SG_ Main : 42|1@1+ (1,0) [0|1] "" XXX - SG_ set : 43|1@1+ (1,0) [0|1] "" XXX - SG_ Resume : 44|1@1+ (1,0) [0|1] "" XXX - SG_ Signal2 : 45|19@1+ (1,0) [0|524287] "" XXX - -BO_ 315 G_Sensor: 8 XXX - SG_ longitudinal : 63|8@0- (1,0) [0|255] "" XXX - SG_ Latitudinal : 48|8@1- (1,0) [0|255] "" XXX - -BO_ 314 Wheel_Speeds: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX - SG_ FR : 12|13@1+ (0.057,0) [0|255] "kph" XXX - SG_ RR : 25|13@1+ (0.057,0) [0|255] "kph" XXX - SG_ FL : 51|13@1+ (0.057,0) [0|255] "kph" XXX - SG_ RL : 38|13@1+ (0.057,0) [0|255] "kph" XXX - -BO_ 73 NEW_MSG_5: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_1 : 32|8@1+ (1,0) [0|4095] "" XXX - SG_ NEW_SIGNAL_2 : 24|8@1+ (1,0) [0|127] "" XXX - -BO_ 280 NEW_MSG_6: 8 XXX - SG_ NEW_SIGNAL_1 : 12|12@1- (1,0) [0|4095] "" XXX - SG_ NEW_SIGNAL_2 : 48|8@1- (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 61|1@1+ (1,0) [0|7] "" XXX - SG_ NEW_SIGNAL_4 : 40|4@1+ (1,0) [0|255] "" XXX - -BO_ 281 Steering_Torque: 8 XXX - SG_ checksum : 0|8@1+ (1,0) [0|3] "" XXX - SG_ counter : 8|4@1+ (1,0) [0|15] "" XXX - SG_ Steer_Torque_Sensor : 16|11@1- (-1,0) [0|3] "" XXX - SG_ Steering_Angle : 32|16@1- (-0.0217,0) [0|255] "" X - SG_ Steer_Torque_Output : 48|11@1- (-1,0) [0|31] "" XXX - -BO_ 312 Brake_Pressure_L_R: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|31] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|3] "" XXX - SG_ Brake_2 : 56|8@1+ (1,0) [0|255] "" XXX - SG_ Brake_1 : 48|8@1+ (1,0) [0|255] "" XXX - -BO_ 313 Brake_Pedal: 8 XXX - SG_ Brake_Pedal_On : 34|1@1+ (1,0) [0|7] "" XXX - SG_ Brake_Pedal : 36|12@1+ (1,0) [0|65535] "" XXX - -BO_ 290 ES_LKAS: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX - SG_ LKAS_Output : 16|13@1- (-1,0) [0|3] "" XXX - SG_ LKAS_Request : 29|1@0+ (1,0) [0|3] "" XXX - SG_ SET_1 : 12|1@0+ (1,0) [0|3] "" XXX - -BO_ 722 NEW_MSG_10: 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_1 : 27|3@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 56|2@1+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_5 : 45|2@0+ (1,0) [0|3] "" XXX - -BO_ 544 ES_Brake: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX - SG_ Brake_Pressure : 16|16@1+ (1,0) [0|255] "" XXX - SG_ __Status : 36|4@1+ (1,0) [0|63] "" XXX - -BO_ 545 ES_Distance: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX - SG_ Signal1 : 12|20@1+ (1,0) [0|15] "" XXX - SG_ Signal2 : 32|24@1+ (1,0) [0|15] "" XXX - SG_ Main : 56|1@1+ (1,0) [0|1] "" XXX - SG_ Signal3 : 57|7@1+ (1,0) [0|1] "" XXX - -BO_ 546 ES_Status: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX - SG_ RPM : 16|12@1+ (1,0) [0|255] "" XXX - SG_ Cruise_Activated : 29|1@0+ (1,0) [0|3] "" XXX - SG_ Cruise_Brake : 30|1@1+ (1,0) [0|3] "" XXX - -BO_ 554 ES_Blank: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX - SG_ SET_65535 : 39|16@1+ (1,0) [0|16777215] "" XXX - SG_ SET_1 : 13|1@1+ (1,0) [0|7] "" XXX - -BO_ 557 NEW_MSG_14: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX - -BO_ 576 CruiseControl: 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_5 : 42|1@1+ (1,0) [0|3] "" XXX - SG_ Cruise_On : 40|1@1+ (1,0) [0|3] "" XXX - SG_ Cruise_Activated : 41|1@1+ (1,0) [0|3] "" XXX - -BO_ 577 NEW_MSG_16: 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_1 : 16|12@1+ (1,0) [0|255] "" XXX - -BO_ 552 NEW_MSG_17: 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_1 : 48|1@1+ (1,0) [0|3] "" XXX - -BO_ 912 Dashlights: 8 XXX - SG_ NEW_SIGNAL_1 : 32|1@1+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_2 : 8|4@1+ (1,0) [0|15] "" XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ RIGHT_BLINKER : 51|1@1+ (1,0) [0|1] "" XXX - SG_ LEFT_BLINKER : 50|1@1+ (1,0) [0|3] "" XXX - SG_ SEATBELT_FL : 48|1@1+ (1,0) [0|1] "" XXX - -BO_ 940 BodyInfo: 8 XXX - SG_ DASH_BTN_LIGHTS : 56|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_OPEN_FL : 32|1@1+ (1,0) [0|255] "" XXX - SG_ DOOR_OPEN_FR : 33|1@1+ (1,0) [0|3] "" XXX - SG_ DOOR_OPEN_RL : 34|1@1+ (1,0) [0|1] "" XXX - SG_ DOOR_OPEN_RR : 35|1@1+ (1,0) [0|1] "" XXX - SG_ DOOR_OPEN_TRUNK : 36|1@0+ (1,0) [0|1] "" XXX - SG_ FOG_LIGHTS2 : 60|1@1+ (1,0) [0|1] "" XXX - SG_ Highbeam : 58|1@1+ (1,0) [0|1] "" XXX - SG_ Lowbeam : 57|1@1+ (1,0) [0|3] "" XXX - -BO_ 801 ES_DashStatus: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|7] "" XXX - SG_ NEW_SIGNAL_9 : 60|4@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_10 : 49|2@1+ (1,0) [0|3] "" XXX - SG_ Brake_Pedal : 51|1@1+ (1,0) [0|3] "" XXX - SG_ Cruise_Set_Speed : 40|8@1+ (1,0) [0|255] "" XXX - SG_ Cruise_Activated : 36|1@1+ (1,0) [0|3] "" XXX - SG_ Cruise_Disengaged : 35|1@1+ (1,0) [0|3] "" XXX - SG_ Far_Distance : 56|4@1+ (1,0) [0|15] "" XXX - SG_ Car_Follow : 52|1@1+ (1,0) [0|3] "" XXX - SG_ ACC_Distance : 28|3@1+ (1,0) [0|3] "" XXX - -BO_ 802 ES_LKAS_State: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX - SG_ Keep_Hands_On_Wheel : 12|1@1+ (1,0) [0|1] "" XXX - SG_ Empty_Box : 13|1@1+ (1,0) [0|1] "" XXX - SG_ Signal1 : 14|3@1+ (1,0) [0|7] "" XXX - SG_ LKAS_ACTIVE : 17|1@1+ (1,0) [0|3] "" XXX - SG_ Signal2 : 18|5@1+ (1,0) [0|7] "" XXX - SG_ Backward_Speed_Limit_Menu : 23|1@1+ (1,0) [0|1] "" 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|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 - SG_ Traffic_light_Ahead : 35|1@1+ (1,0) [0|1] "" XXX - SG_ Right_Depart : 36|1@1+ (1,0) [0|3] "" XXX - SG_ Signal5 : 37|27@1+ (1,0) [0|1] "" XXX - -BO_ 805 ES_NEW_MSG_22: 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 : 22|2@1+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_1 : 14|1@1+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_4 : 15|1@1+ (1,0) [0|3] "" XXX - -BO_ 808 NEW_MSG_23: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX - -BO_ 837 NEW_MSG_24: 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 : 40|8@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 32|4@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_5 : 24|8@1+ (1,0) [0|255] "" XXX - -BO_ 838 NEW_MSG_25: 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|8@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 40|1@1+ (1,0) [0|3] "" XXX - -BO_ 842 NEW_MSG_26: 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 : 32|8@1+ (1,0) [0|255] "" XXX - -BO_ 915 NEW_MSG_27: 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|8@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 32|9@1+ (1,0) [0|255] "" XXX - -BO_ 1788 NEW_MSG_28: 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 : 40|4@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_4 : 48|8@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 16|8@1+ (1,0) [0|255] "" XXX - -BO_ 816 NEW_MSG_29: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX - -BO_ 826 NEW_MSG_30: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX - -BO_ 839 NEW_MSG_31: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX - -BO_ 2015 NEW_MSG_32: 8 XXX - SG_ NEW_SIGNAL_2 : 16|8@1+ (1,0) [0|255] "" XXX - -BO_ 2024 NEW_MSG_33: 8 XXX - SG_ NEW_SIGNAL_1 : 24|8@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 0|3@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_3 : 16|8@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 32|8@1+ (1,0) [0|255] "" XXX - -BO_ 1614 NEW_MSG_34: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX - -BO_ 1617 NEW_MSG_35: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX - -BO_ 1632 NEW_MSG_36: 8 XXX - SG_ NEW_SIGNAL_1 : 55|16@0+ (1,0) [0|255] "" XXX - -BO_ 1650 NEW_MSG_37: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX - -BO_ 1657 NEW_MSG_38: 8 XXX - SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX - -BO_ 1658 NEW_MSG_39: 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 : 33|1@1+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_4 : 31|1@0+ (1,0) [0|3] "" 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 - SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX - -BO_ 1785 NEW_MSG_42: 8 XXX - SG_ NEW_SIGNAL_1 : 0|4@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 21|1@1+ (1,0) [0|31] "" XXX - SG_ NEW_SIGNAL_3 : 17|1@1+ (1,0) [0|7] "" XXX - -BO_ 1759 NEW_MSG_43: 8 XXX - SG_ NEW_SIGNAL_1 : 17|1@1+ (1,0) [0|3] "" XXX - -BO_ 1786 NEW_MSG_44: 8 XXX - SG_ NEW_SIGNAL_1 : 0|4@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_2 : 16|8@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 8|8@1+ (1,0) [0|15] "" XXX - -BO_ 1787 NEW_MSG_45: 8 XXX - SG_ NEW_SIGNAL_1 : 0|4@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_2 : 8|8@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 16|8@1+ (1,0) [0|255] "" XXX - - - - -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"; diff --git a/opendbc/subaru_global_2017_generated.dbc b/opendbc/subaru_global_2017_generated.dbc new file mode 100644 index 00000000000000..f17667e5624e24 --- /dev/null +++ b/opendbc/subaru_global_2017_generated.dbc @@ -0,0 +1,306 @@ +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; + + +CM_ "Imported file _subaru_global.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 X + + +BO_ 2 Steering: 8 XXX + SG_ Steering_Angle : 7|16@0- (0.1,0) [0|65535] "" XXX + SG_ Counter : 25|3@1+ (1,0) [0|7] "" XXX + SG_ CHECKSUM : 32|8@1+ (1,0) [0|255] "" XXX + +BO_ 64 Throttle: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Engine_RPM : 16|12@1+ (1,0) [0|4095] "" XXX + SG_ Throttle_Pedal : 32|8@1+ (1,0) [0|255] "" XXX + SG_ Throttle_Cruise : 40|8@1+ (1,0) [0|255] "" XXX + SG_ Throttle_Combo : 48|8@1+ (1,0) [0|255] "" XXX + SG_ Signal1 : 56|4@1+ (1,0) [0|15] "" XXX + SG_ Off_Accel : 60|4@1+ (1,0) [0|15] "" XXX + +BO_ 316 Brake_Status: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Signal1 : 12|46@1+ (1,0) [0|1] "" XXX + SG_ ES_Brake : 58|1@1+ (1,0) [0|1] "" XXX + SG_ Signal2 : 59|3@1+ (1,0) [0|1] "" XXX + SG_ Brake : 62|1@1+ (1,0) [0|1] "" XXX + SG_ Signal3 : 63|1@1+ (1,0) [0|1] "" XXX + +BO_ 326 Cruise_Buttons: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Signal1 : 12|30@1+ (1,0) [0|1073741823] "" XXX + SG_ Main : 42|1@1+ (1,0) [0|1] "" XXX + SG_ Set : 43|1@1+ (1,0) [0|1] "" XXX + SG_ Resume : 44|1@1+ (1,0) [0|1] "" XXX + SG_ Signal2 : 45|19@1+ (1,0) [0|524287] "" XXX + +BO_ 315 G_Sensor: 8 XXX + SG_ Lateral : 48|8@1- (-0.1,0) [0|255] "m/s2" XXX + SG_ Longitudinal : 56|8@1- (-0.1,0) [0|255] "m/s2" XXX + +BO_ 314 Wheel_Speeds: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ FR : 12|13@1+ (0.057,0) [0|255] "kph" XXX + SG_ RR : 25|13@1+ (0.057,0) [0|255] "kph" XXX + SG_ FL : 51|13@1+ (0.057,0) [0|255] "kph" XXX + SG_ RL : 38|13@1+ (0.057,0) [0|255] "kph" XXX + +BO_ 280 STOP_START: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ State : 63|1@1+ (1,0) [0|1] "" XXX + +BO_ 281 Steering_Torque: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Steer_Error_1 : 12|1@0+ (1,0) [0|1] "" XXX + SG_ Steer_Torque_Sensor : 16|11@1- (-1,0) [-1000|1000] "" XXX + SG_ Steer_Error_2 : 28|1@1+ (1,0) [0|1] "" XXX + SG_ Steer_Warning : 29|1@1+ (1,0) [0|1] "" XXX + SG_ Steering_Angle : 32|16@1- (-0.0217,0) [-600|600] "" X + SG_ Steer_Torque_Output : 48|11@1- (-1,0) [-1000|1000] "" XXX + +BO_ 312 Brake_Pressure_L_R: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Brake_1 : 48|8@1+ (1,0) [0|255] "" XXX + SG_ Brake_2 : 56|8@1+ (1,0) [0|255] "" XXX + +BO_ 313 Brake_Pedal: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Signal1 : 12|4@1+ (1,0) [0|15] "" XXX + SG_ Speed : 16|12@1+ (0.05625,0) [0|255] "kph" XXX + SG_ Signal2 : 28|6@1+ (1,0) [0|63] "" XXX + SG_ Brake_Lights : 34|1@1+ (1,0) [0|1] "" XXX + SG_ Signal3 : 35|1@1+ (1,0) [0|1] "" XXX + SG_ Brake_Pedal : 36|12@1+ (1,0) [0|4095] "" XXX + SG_ Signal4 : 48|16@1+ (1,0) [0|65535] "" XXX + +BO_ 290 ES_LKAS: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ SET_1 : 12|1@0+ (1,0) [0|1] "" XXX + SG_ LKAS_Output : 16|13@1- (-1,0) [-8191|8191] "" XXX + SG_ LKAS_Request : 29|1@0+ (1,0) [0|1] "" XXX + +BO_ 544 ES_Brake: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Signal1 : 12|4@1+ (1,0) [0|15] "" XXX + SG_ Brake_Pressure : 16|16@1+ (1,0) [0|65535] "" XXX + SG_ Signal2 : 32|4@1+ (1,0) [0|15] "" XXX + SG_ Cruise_Brake_Lights : 36|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Brake_Fault : 37|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Brake_Active : 38|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Activated : 39|1@1+ (1,0) [0|1] "" XXX + SG_ Signal3 : 40|24@1+ (1,0) [0|16777215] "" XXX + +BO_ 577 Cruise_Status: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Cruise_On : 54|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Activated : 55|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Active : 57|4@1+ (1,0) [0|15] "" XXX + +BO_ 552 BSD_RCTA: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ R_ADJACENT : 48|1@1+ (1,0) [0|1] "" XXX + SG_ L_ADJACENT : 49|1@1+ (1,0) [0|1] "" XXX + SG_ R_APPROACHING : 58|1@1+ (1,0) [0|1] "" XXX + SG_ L_APPROACHING : 59|1@1+ (1,0) [0|1] "" XXX + +BO_ 912 Dashlights: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ ICY_ROAD : 32|2@1+ (1,0) [0|3] "" XXX + SG_ SEATBELT_FL : 48|1@1+ (1,0) [0|1] "" XXX + SG_ LEFT_BLINKER : 50|1@1+ (1,0) [0|1] "" XXX + SG_ RIGHT_BLINKER : 51|1@1+ (1,0) [0|1] "" XXX + +BO_ 940 BodyInfo: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ DOOR_OPEN_FL : 32|1@1+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_FR : 33|1@1+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_RL : 34|1@1+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_RR : 35|1@1+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_TRUNK : 36|1@0+ (1,0) [0|1] "" XXX + SG_ DASH_BTN_LIGHTS : 56|1@0+ (1,0) [0|1] "" XXX + SG_ Lowbeam : 57|1@1+ (1,0) [0|1] "" XXX + SG_ Highbeam : 58|1@1+ (1,0) [0|1] "" XXX + SG_ FOG_LIGHTS2 : 60|1@1+ (1,0) [0|1] "" XXX + SG_ WIPERS : 62|1@0+ (1,0) [0|1] "" XXX + SG_ BRAKE : 54|1@1+ (1,0) [0|1] "" XXX + +BO_ 801 ES_DashStatus: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ PCB_Off : 12|1@1+ (1,0) [0|1] "" XXX + SG_ LDW_Off : 13|1@1+ (1,0) [0|1] "" XXX + SG_ Signal1 : 14|10@1+ (1,0) [0|1023] "" XXX + SG_ Cruise_Soft_Disable : 24|1@1+ (1,0) [0|1] "" XXX + SG_ Signal2 : 25|3@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Distance : 28|3@1+ (1,0) [0|7] "" XXX + SG_ Signal3 : 31|1@1+ (1,0) [0|1] "" XXX + SG_ Conventional_Cruise : 32|1@1+ (1,0) [0|1] "" XXX + SG_ Signal4 : 33|2@1+ (1,0) [0|3] "" XXX + SG_ Cruise_Disengaged : 35|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Activated : 36|1@1+ (1,0) [0|1] "" XXX + SG_ Signal5 : 37|3@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Set_Speed : 40|8@1+ (1,0) [0|255] "" XXX + SG_ Cruise_Fault : 48|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_On : 49|1@1+ (1,0) [0|1] "" XXX + SG_ Signal6 : 50|1@1+ (1,0) [0|1] "" XXX + SG_ Brake_Lights : 51|1@1+ (1,0) [0|1] "" XXX + SG_ Car_Follow : 52|1@1+ (1,0) [0|1] "" XXX + SG_ Signal7 : 53|3@1+ (1,0) [0|1] "" XXX + SG_ Far_Distance : 56|4@1+ (1,0) [0|15] "" XXX + SG_ Cruise_State : 60|4@1+ (1,0) [0|15] "" XXX + +BO_ 802 ES_LKAS_State: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Keep_Hands_On_Wheel : 12|1@1+ (1,0) [0|1] "" XXX + SG_ Empty_Box : 13|1@1+ (1,0) [0|1] "" XXX + SG_ Signal1 : 14|3@1+ (1,0) [0|7] "" XXX + SG_ LKAS_ACTIVE : 17|1@1+ (1,0) [0|1] "" XXX + SG_ Signal2 : 18|5@1+ (1,0) [0|31] "" XXX + SG_ Backward_Speed_Limit_Menu : 23|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_ENABLE_3 : 24|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_Left_Line_Light_Blink : 25|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_ENABLE_2 : 26|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_Right_Line_Light_Blink : 27|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_Left_Line_Visible : 28|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_Left_Line_Green : 29|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_Right_Line_Visible : 30|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_Right_Line_Green : 31|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_Alert : 32|4@1+ (1,0) [0|15] "" XXX + SG_ Signal3 : 36|28@1+ (1,0) [0|1] "" XXX + +BO_ 722 AC_State: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ AC_Mode : 37|3@1+ (1,0) [0|1] "" XXX + SG_ AC_ON : 24|2@1+ (1,0) [0|1] "" 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_ Units : 29|3@1+ (1,0) [0|7] "" XXX + +CM_ SG_ 64 Throttle_Combo "Throttle Cruise + Pedal"; +CM_ SG_ 313 Brake_Lights "Driver or Cruise Brake on"; +CM_ SG_ 544 Cruise_Brake_Lights "1 = switch on brake lights"; +CM_ SG_ 801 PCB_Off "Pre-Collision Braking off"; +CM_ SG_ 801 Brake_Lights "Driver or Cruise brake on"; +CM_ SG_ 801 Cruise_State "0 = Normal, 1 = Hold+User Brake, 2 = Ready, 3 = Hold"; +CM_ SG_ 801 Far_Distance "1=0-5m, 2=5-10m, 3=10-15m, 4=15-20m, 5=20-25m, 6=25-30m, 7=30-35m, 8=35-40m, 9=40-45m, 10=45-50m, 11=50-55m, 12=55-60m, 13=60-65m, 14=65-70m, 15=75m+"; +CM_ SG_ 801 Cruise_Soft_Disable "Eyesight soft disable (eg direct sunlight)"; +CM_ SG_ 802 LKAS_Alert "1 = FCW_Cont_Beep, 2 = FCW_Repeated_Beep, 3 = Throttle_Management_Activated_Warning, 4 = Throttle_Management_Activated_Alert, 8 = Traffic_Light_Ahead, 9 = Apply_Brake_to_Hold Position, 11 = LDW_Right, 12 = LDW_Left, 13 = Stay_Alert, 14 = Lead_Vehicle_Start_Alert"; +CM_ SG_ 912 ICY_ROAD "1 = DASHLIGHT ON, 2 = WARNING, 3 = OFF"; +CM_ SG_ 940 Highbeam "01 = low beam, 11 = high beam"; +CM_ SG_ 940 FOG_LIGHTS2 "yellow fog light in the dash"; +CM_ SG_ 1677 Units "AU/EU: 1 = imperial, 3 = metric US: 3 = imperial, 4 = metric"; + +CM_ "subaru_global_2017.dbc starts here"; + + +BO_ 72 Transmission: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Gear : 24|8@1+ (1,0) [0|255] "" XXX + SG_ RPM : 40|16@1+ (1,0) [0|65535] "" XXX + +BO_ 73 CVT: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ CVT_Gear : 24|8@1+ (1,0) [0|255] "" XXX + +BO_ 545 ES_Distance: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Signal1 : 12|3@1+ (1,0) [0|7] "" XXX + SG_ Cruise_Fault : 15|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Throttle : 16|12@1+ (1,0) [0|4095] "" XXX + SG_ Signal2 : 28|4@1+ (1,0) [0|15] "" XXX + SG_ Car_Follow : 32|1@1+ (1,0) [0|1] "" XXX + SG_ Signal3 : 33|3@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Brake_Active : 36|1@1+ (1,0) [0|1] "" XXX + SG_ Distance_Swap : 37|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_EPB : 38|1@1+ (1,0) [0|1] "" XXX + SG_ Signal4 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ Close_Distance : 40|8@1+ (1,0) [0|1] "" XXX + SG_ Signal5 : 48|8@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Cancel : 56|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Set : 57|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Resume : 58|1@1+ (1,0) [0|1] "" XXX + SG_ Signal6 : 59|5@1+ (1,0) [0|1] "" XXX + +BO_ 546 ES_Status: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Signal1 : 12|3@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Fault : 15|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_RPM : 16|12@1+ (1,0) [0|4095] "" XXX + SG_ Signal2 : 28|1@0+ (1,0) [0|1] "" XXX + SG_ Cruise_Activated : 29|1@0+ (1,0) [0|1] "" XXX + SG_ Brake_Lights : 30|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Hold : 31|1@1+ (1,0) [0|1] "" XXX + SG_ Signal3 : 32|32@1+ (1,0) [0|1] "" XXX + +BO_ 576 CruiseControl: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Signal1 : 12|28@1+ (1,0) [0|268435455] "" XXX + SG_ Cruise_On : 40|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Activated : 41|1@1+ (1,0) [0|1] "" XXX + SG_ Signal2 : 42|22@1+ (1,0) [0|4194303] "" XXX + +CM_ SG_ 545 Cruise_Throttle "RPM-like output signal"; +CM_ SG_ 545 Cruise_EPB "1 = Electric Parking Brake set"; +CM_ SG_ 545 Distance_Swap "Switch from Close to Far distance"; +CM_ SG_ 546 Cruise_RPM "ES RPM output for ECM and TCM"; +CM_ SG_ 546 Signal3 "0 when cruise_activated = 1"; +VAL_ 72 Gear 2 "N" 3 "R" 4 "P" 121 "D" 137 "1" 145 "2" 153 "3" 161 "4" 169 "5" 177 "6"; diff --git a/opendbc/subaru_outback_2015_eyesight.dbc b/opendbc/subaru_outback_2015_eyesight.dbc deleted file mode 100644 index 2f796558501817..00000000000000 --- a/opendbc/subaru_outback_2015_eyesight.dbc +++ /dev/null @@ -1,372 +0,0 @@ -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_ 2 Steering: 8 XXX - SG_ NEW_SIGNAL_1 : 31|4@0- (1,0) [0|65535] "" 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_ 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 - SG_ Steering_Angle : 0|16@1- (1,0) [0|65535] "" XXX - SG_ NEW_SIGNAL_1 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ _Latitudinal : 16|16@1- (0.0035,1) [0|65535] "" XXX - SG_ _Longitudinal : 48|16@1- (0.000035,0) [0|255] "" XXX - -BO_ 209 Brake_Pedal: 8 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 - SG_ NEW_SIGNAL_1 : 46|1@0+ (1,0) [0|4294967295] "" XXX - SG_ NEW_SIGNAL_2 : 39|3@0+ (1,0) [0|7] "" XXX - SG_ Right_Brake : 48|8@1+ (1,0) [0|255] "" XXX - SG_ Left_Brake : 63|8@0+ (1,0) [0|255] "" XXX - SG_ Brake_Light : 35|1@1+ (1,0) [0|15] "" XXX - SG_ Brake_Related : 36|1@1+ (1,0) [0|255] "" XXX - -BO_ 211 Brake_Type: 8 XXX - SG_ NEW_SIGNAL_4 : 28|4@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_3 : 7|1@0+ (1,0) [0|4294967295] "" XXX - SG_ NEW_SIGNAL_2 : 16|4@1+ (1,0) [0|15] "" XXX - SG_ Speed_Counter : 39|8@0+ (1,0) [0|15] "" XXX - SG_ Counter : 55|8@0+ (1,0) [0|255] "" XXX - SG_ Brake_Light : 21|1@0+ (1,0) [0|3] "" 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 - 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 - SG_ RR : 48|16@1+ (0.0592,0) [0|127] "KPH" XXX - -BO_ 320 Throttle: 8 XXX - SG_ Off_Throttle_2 : 56|1@1+ (1,0) [0|3] "" XXX - SG_ Throttle_Combo : 40|8@1+ (1,0) [0|255] "" XXX - SG_ Engine_RPM : 16|14@1+ (1,0) [0|15] "" XXX - SG_ Off_Throttle : 30|1@0+ (1,0) [0|3] "" XXX - SG_ Throttle_Cruise : 39|8@0+ (1,0) [0|255] "" XXX - SG_ Throttle_Body_ : 55|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 63|1@0+ (1,0) [0|15] "" XXX - SG_ Not_Full_Throttle : 14|1@0+ (1,0) [0|15] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX - SG_ Throttle_Pedal : 0|8@1+ (0.392157,0) [0|255] "" XXX - -BO_ 321 undefined: 8 XXX - SG_ NEW_SIGNAL_7 : 59|2@1+ (1,0) [0|63] "" XXX - SG_ NEW_SIGNAL_6 : 46|1@0+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_2 : 47|1@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_5 : 48|4@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_3 : 54|2@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_8 : 31|4@0+ (1,0) [0|15] "" XXX - SG_ Engine_RPM : 32|12@1+ (1,0) [0|8191] "" XXX - SG_ Engine_Torque : 0|15@1+ (1,0) [0|255] "" 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: 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 - SG_ RES_BUTTON : 4|1@0+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_6 : 50|1@0+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_4 : 28|5@0+ (1,0) [0|16777215] "" XXX - SG_ NEW_SIGNAL_9 : 15|1@1+ (1,0) [0|127] "" 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_ 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 - SG_ NEW_SIGNAL_7 : 63|1@0+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_4 : 15|4@0+ (1,0) [0|15] "" XXX - SG_ Paddle_Shift : 60|2@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_1 : 31|1@0+ (1,0) [0|3] "" XXX - SG_ Transmission_Engine : 16|15@1+ (1,0) [0|65535] "" XXX - SG_ NEW_SIGNAL_5 : 43|1@0+ (1,0) [0|65535] "" XXX - SG_ Gear : 48|4@1+ (1,0) [0|15] "" XXX - SG_ Gear_2 : 52|4@1+ (1,0) [0|15] "" XXX - SG_ Manual_Gear : 4|4@1+ (1,0) [0|255] "" XXX - -BO_ 329 CVT_Ratio: 8 XXX - SG_ NEW_SIGNAL_2 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 40|8@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 0|8@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 11|4@0+ (1,0) [0|65535] "" XXX - SG_ NEW_SIGNAL_1 : 39|8@0+ (1,0) [0|255] "" XXX - -BO_ 336 Brake_Pressure: 8 XXX - SG_ Brake_Pressure_Right : 0|8@1+ (1,0) [0|15] "" XXX - SG_ Brake_Pressure_Left : 15|8@0+ (1,0) [0|255] "" XXX - -BO_ 338 Stalk: 8 XXX - SG_ Wiper : 62|1@0+ (1,0) [0|3] "" XXX - SG_ brake_light : 52|1@0+ (1,0) [0|3] "" XXX - SG_ Headlights : 59|1@0+ (1,0) [0|3] "" XXX - SG_ Runlights : 58|1@1+ (1,0) [0|3] "" XXX - SG_ Highbeam : 60|1@0+ (1,0) [0|3] "" XXX - SG_ Counter : 15|4@0+ (1,0) [0|15] "" XXX - -BO_ 342 NEW_MSG_2: 8 XXX - -BO_ 346 Counter_3: 8 XXX - SG_ Counter : 0|4@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_1 : 20|1@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_2 : 57|1@1+ (1,0) [0|3] "" XXX - -BO_ 352 ES_Brake: 8 XXX - SG_ Counter : 48|3@1+ (1,0) [0|7] "" XXX - SG_ Checksum : 56|8@1+ (1,0) [0|7] "" XXX - SG_ Brake_On : 22|1@0+ (1,0) [0|3] "" 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 - SG_ Counter_1 : 46|3@0+ (1,0) [0|15] "" XXX - SG_ Wheel_stop : 22|1@0+ (1,0) [0|3] "" XXX - SG_ CloseDistance : 24|8@1+ (1,0) [0|255] "" XXX - SG_ Unknown : 18|1@1+ (1,0) [0|7] "" XXX - SG_ Button_Speed_Down : 49|1@1+ (1,0) [0|3] "" XXX - SG_ Button_Resume : 50|1@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_3_Blank : 15|4@0+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_2_Blank : 48|1@1+ (1,0) [0|3] "" XXX - SG_ Checksum : 56|8@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_9 : 17|1@1+ (1,0) [0|3] "" XXX - SG_ Cruise_Activatedish : 16|1@1+ (1,0) [0|7] "" 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 - SG_ Cruise_Activated : 9|1@0+ (1,0) [0|3] "" XXX - SG_ Checksum : 39|8@0+ (1,0) [0|65535] "" XXX - SG_ RPM : 16|16@1+ (1,0) [0|255] "" XXX - SG_ Brake : 8|1@1+ (1,0) [0|7] "" 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|7] "" XXX - SG_ LKAS_Active : 24|1@1+ (1,0) [0|1] "" XXX - SG_ LKAS_Command : 8|13@1- (-1,0) [-4096|4096] "" XXX - -BO_ 358 ES_DashStatus: 8 XXX - SG_ Counter : 39|3@0+ (1,0) [0|7] "" XXX - SG_ Obstacle_Distance : 48|4@1+ (1,0) [0|15] "" XXX - SG_ Cruise_Off : 22|1@0+ (1,0) [0|3] "" 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 - SG_ Untitled_Blank : 18|1@0+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_6_Blank : 21|1@0+ (1,0) [0|3] "" 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_ 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_ 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 : 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 - -BO_ 554 NEW_MSG_3: 8 XXX - SG_ Counter : 0|4@1+ (1,0) [0|255] "" XXX - -BO_ 604 undefined: 8 XXX - -BO_ 640 NEW_MSG_10: 8 XXX - SG_ NEW_SIGNAL_2 : 24|8@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 54|2@0+ (1,0) [0|15] "" XXX - SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_3 : 34|2@0+ (1,0) [0|63] "" XXX - SG_ NEW_SIGNAL_1 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 39|1@0+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_6 : 0|1@1+ (1,0) [0|7] "" XXX - SG_ NEW_SIGNAL_7 : 38|1@0+ (1,0) [0|3] "" XXX - -BO_ 642 Dashlights: 8 XXX - SG_ NEW_SIGNAL_2 : 32|1@1+ (1,0) [0|15] "" XXX - SG_ Counter : 15|4@0+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_1 : 0|12@1+ (1,0) [0|255] "" 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 - -BO_ 805 undefined: 8 XXX - -BO_ 880 Steer_Torque_2: 8 XXX - SG_ Counter : 40|4@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_3 : 48|4@1- (1,0) [0|15] "" XXX - SG_ Steering_Voltage_Flat : 7|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_1 : 8|1@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 30|1@0+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_4_2017 : 52|1@0+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_5_2017 : 54|1@0+ (1,0) [0|3] "" XXX - SG_ Steer_Torque_Sensor : 32|8@1- (-1,0) [0|255] "" XXX - -BO_ 881 Steering_Torque: 8 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 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 - -BO_ 864 Engine_Temp: 8 XXX - SG_ NEW_SIGNAL_1 : 32|8@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 44|1@1+ (1,0) [0|3] "" XXX - SG_ Saved_Speed : 56|8@1+ (1,0) [0|255] "" XXX - SG_ Cruise_Activated : 45|1@1+ (1,0) [0|3] "" XXX - SG_ Oil_Temp : 16|8@1+ (1,-40) [0|255] "" XXX - SG_ Coolant_Temp : 24|8@1+ (1,-40) [0|255] "" XXX - -BO_ 865 NEW_MSG_16: 8 XXX - SG_ NEW_SIGNAL_1 : 16|8@1+ (1,0) [0|255] "" XXX - SG_ Counter : 32|4@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_2 : 12|1@1+ (1,0) [0|255] "" XXX - -BO_ 866 Fuel__: 8 XXX - SG_ NEW_SIGNAL_2 : 55|8@0+ (1,0) [0|16777215] "" XXX - SG_ NEW_SIGNAL_3 : 35|4@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 47|8@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_1 : 0|16@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_5 : 24|1@0+ (1,0) [0|32767] "" XXX - -BO_ 872 NEW_MSG_15: 8 XXX - SG_ NEW_SIGNAL_1 : 31|8@0+ (1,0) [0|65535] "" XXX - -BO_ 977 NEW_MSG_12: 8 XXX - SG_ NEW_SIGNAL_1 : 0|8@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 16|12@1+ (1,0) [0|255] "" XXX - -BO_ 1632 Huge_Counter: 8 XXX - SG_ NEW_SIGNAL_1 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ Counter : 55|16@0+ (1,0) [0|255] "" XXX - -BO_ 1745 NEW_MSG_11: 8 XXX - SG_ NEW_SIGNAL_1 : 24|6@1+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 40|6@1+ (1,0) [0|15] "" XXX - SG_ NEW_SIGNAL_3 : 0|8@1+ (1,0) [0|255] "" XXX - -BO_ 1786 NEW_MSG_9: 8 XXX - SG_ Counter : 3|4@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_2 : 8|16@1+ (1,0) [0|15] "" XXX - - - - -CM_ SG_ 2 NEW_SIGNAL_1 ""; -CM_ SG_ 211 Brake_Pedal_On "high tolerance"; -CM_ SG_ 212 FL "KPH"; -CM_ SG_ 212 RL "KPH"; -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_ 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 Car_Follow "front car detected"; -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_ 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 "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_4_2017 "1 in 2017"; -CM_ SG_ 880 NEW_SIGNAL_5_2017 "1 in 2017"; diff --git a/opendbc/subaru_outback_2015_generated.dbc b/opendbc/subaru_outback_2015_generated.dbc new file mode 100644 index 00000000000000..c0a601589e0e6b --- /dev/null +++ b/opendbc/subaru_outback_2015_generated.dbc @@ -0,0 +1,273 @@ +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; + + +CM_ "Imported file _subaru_preglobal_2015.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 X + + +BO_ 2 Steering: 8 XXX + SG_ Steering_Angle : 7|16@0- (0.1,0) [-500|500] "degree" XXX + SG_ Counter : 27|3@0+ (1,0) [0|7] "" XXX + SG_ Checksum : 39|8@0+ (1,0) [0|255] "" XXX + +BO_ 208 G_Sensor: 8 XXX + SG_ Steering_Angle : 0|16@1- (-0.1,0) [-500|500] "" XXX + SG_ Lateral : 16|16@1- (-0.0035,1) [-255|255] "" XXX + SG_ Longitudinal : 48|16@1- (-0.00035,0) [-255|255] "" XXX + +BO_ 209 Brake_Pedal: 8 XXX + SG_ Speed : 0|16@1+ (0.05625,0) [0|255] "KPH" XXX + SG_ Brake_Pedal : 16|8@1+ (1,0) [0|255] "" XXX + +BO_ 210 Brake_2: 8 XXX + SG_ Brake_Light : 35|1@1+ (1,0) [0|1] "" XXX + SG_ Brake_Related : 36|1@1+ (1,0) [0|1] "" XXX + SG_ Right_Brake : 48|8@1+ (1,0) [0|255] "" XXX + SG_ Left_Brake : 56|8@1+ (1,0) [0|255] "" XXX + +BO_ 211 Brake_Type: 8 XXX + SG_ Brake_Light : 21|1@1+ (1,0) [0|1] "" XXX + SG_ Speed_Counter : 32|8@1+ (1,0) [0|255] "" XXX + SG_ Brake_Cruise_On : 42|1@1+ (1,0) [0|1] "" XXX + SG_ Brake_Pedal_On : 46|1@1+ (1,0) [0|1] "" XXX + SG_ Counter : 48|8@1+ (1,0) [0|255] "" XXX + +BO_ 212 Wheel_Speeds: 8 XXX + SG_ FL : 0|16@1+ (0.0592,0) [0|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] "KPH" XXX + SG_ RR : 48|16@1+ (0.0592,0) [0|255] "KPH" XXX + +BO_ 320 Throttle: 8 XXX + SG_ Throttle_Pedal : 0|8@1+ (0.392157,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Not_Full_Throttle : 14|1@1+ (1,0) [0|1] "" XXX + SG_ Engine_RPM : 16|14@1+ (1,0) [0|32767] "" XXX + SG_ Off_Throttle : 30|1@1+ (1,0) [0|1] "" XXX + SG_ Throttle_Cruise : 32|8@1+ (1,0) [0|255] "" XXX + SG_ Throttle_Combo : 40|8@1+ (1,0) [0|255] "" XXX + SG_ Throttle_Body : 48|8@1+ (1,0) [0|255] "" XXX + SG_ Off_Throttle_2 : 56|1@1+ (1,0) [0|1] "" XXX + +BO_ 321 Engine: 8 XXX + SG_ Engine_Torque : 0|15@1+ (1,0) [0|255] "" XXX + SG_ Engine_Stop : 15|1@1+ (1,0) [0|1] "" XXX + SG_ Wheel_Torque : 16|12@1+ (1,0) [0|4095] "" XXX + SG_ Engine_RPM : 32|12@1+ (1,0) [0|8191] "" XXX + +BO_ 324 CruiseControl: 8 XXX + SG_ OnOffButton : 2|1@1+ (1,0) [0|1] "" XXX + SG_ SET_BUTTON : 3|1@1+ (1,0) [0|1] "" XXX + SG_ RES_BUTTON : 4|1@1+ (1,0) [0|1] "" XXX + SG_ Button : 13|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_On : 48|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Activated : 49|1@1+ (1,0) [0|1] "" XXX + SG_ Brake_Pedal_On : 51|1@1+ (1,0) [0|1] "" XXX + +BO_ 328 Transmission: 8 XXX + SG_ Manual_Gear : 4|4@1+ (1,0) [0|15] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Transmission_Engine : 16|15@1+ (1,0) [0|65535] "" XXX + SG_ Gear : 48|4@1+ (1,0) [0|15] "" XXX + SG_ Gear_2 : 52|4@1+ (1,0) [0|15] "" XXX + SG_ Paddle_Shift : 60|2@1+ (1,0) [0|3] "" XXX + +BO_ 329 CVT_Ratio: 8 XXX + +BO_ 336 Brake_Pressure: 8 XXX + SG_ Brake_Pressure_Right : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Brake_Pressure_Left : 8|8@1+ (1,0) [0|255] "" XXX + +BO_ 338 Stalk: 8 XXX + SG_ Counter : 12|4@1+ (1,0) [0|15] "" XXX + SG_ Brake_Light : 52|1@1+ (1,0) [0|1] "" XXX + SG_ Runlights : 58|1@1+ (1,0) [0|1] "" XXX + SG_ Headlights : 59|1@1+ (1,0) [0|1] "" XXX + SG_ Highbeam : 60|1@1+ (1,0) [0|1] "" XXX + SG_ Wiper : 62|1@1+ (1,0) [0|1] "" XXX + +BO_ 352 ES_Brake: 8 XXX + SG_ Brake_Pressure : 0|16@1+ (1,0) [0|255] "" XXX + SG_ Brake_Light : 20|1@1+ (1,0) [0|1] "" XXX + SG_ ES_Error : 21|1@1+ (1,0) [0|1] "" XXX + SG_ Brake_On : 22|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Activated : 23|1@1+ (1,0) [0|1] "" XXX + SG_ Counter : 48|3@1+ (1,0) [0|7] "" XXX + SG_ Checksum : 56|8@1+ (1,0) [0|255] "" XXX + +BO_ 353 ES_CruiseThrottle: 8 XXX + SG_ Throttle_Cruise : 0|12@1+ (1,0) [0|4095] "" XXX + SG_ Signal1 : 12|4@1+ (1,0) [0|15] "" XXX + SG_ Cruise_Activated : 16|1@1+ (1,0) [0|1] "" XXX + SG_ Signal2 : 17|3@1+ (1,0) [0|7] "" XXX + SG_ Brake_On : 20|1@1+ (1,0) [0|1] "" XXX + SG_ DistanceSwap : 21|1@1+ (1,0) [0|1] "" XXX + SG_ Standstill : 22|1@1+ (1,0) [0|1] "" XXX + SG_ Signal3 : 23|1@1+ (1,0) [0|1] "" XXX + SG_ CloseDistance : 24|8@1+ (0.0196,0) [0|255] "m" XXX + SG_ Signal4 : 32|9@1+ (1,0) [0|255] "" XXX + SG_ Standstill_2 : 41|1@1+ (1,0) [0|1] "" XXX + SG_ ES_Error : 42|1@1+ (1,0) [0|1] "" XXX + SG_ Signal5 : 43|1@1+ (1,0) [0|1] "" XXX + SG_ Counter : 44|3@1+ (1,0) [0|7] "" XXX + SG_ Signal6 : 47|1@1+ (1,0) [0|1] "" XXX + SG_ Button : 48|3@1+ (1,0) [0|7] "" XXX + SG_ Signal7 : 51|5@1+ (1,0) [0|31] "" XXX + SG_ Checksum : 56|8@1+ (1,0) [0|255] "" XXX + +BO_ 354 ES_RPM: 8 XXX + SG_ Brake : 8|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Activated : 9|1@1+ (1,0) [0|1] "" XXX + SG_ RPM : 16|16@1+ (1,0) [0|65535] "" XXX + SG_ Checksum : 32|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 48|3@1+ (1,0) [0|7] "" XXX + +BO_ 356 ES_LKAS: 8 XXX + SG_ Counter : 0|3@1+ (1,0) [0|7] "" XXX + SG_ LKAS_Command : 8|13@1- (-1,0) [-4096|4096] "" XXX + SG_ LKAS_Active : 24|1@1+ (1,0) [0|1] "" XXX + SG_ Checksum : 56|8@1+ (1,0) [0|255] "" XXX + +BO_ 359 ES_LDW: 8 XXX + SG_ All_depart_2015 : 0|1@1+ (1,0) [0|1] "" XXX + SG_ Right_Line_2017 : 24|1@1+ (1,0) [0|1] "" XXX + SG_ Left_Line_2017 : 25|1@1+ (1,0) [0|1] "" XXX + SG_ Sig1All_Depart : 28|1@1+ (1,0) [0|1] "" XXX + SG_ Sig2All_Depart : 31|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_Inactive_2017 : 36|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_Active : 37|1@1+ (1,0) [0|1] "" XXX + SG_ Sig1Right_Depart : 48|1@1+ (1,0) [0|1] "" XXX + SG_ Sig1Right_Depart_Front : 49|1@1+ (1,0) [0|1] "" XXX + SG_ Sig2Right_Depart : 50|1@1+ (1,0) [0|1] "" XXX + SG_ Left_Depart_Front : 51|1@1+ (1,0) [0|1] "" XXX + SG_ Sig3All_Depart : 52|1@1+ (1,0) [0|1] "" XXX + +BO_ 604 BSD_RCTA: 8 XXX + SG_ Counter : 0|3@1+ (1,0) [0|7] "" XXX + SG_ State : 5|1@1+ (1,0) [0|1] "" XXX + SG_ R_ADJACENT : 32|1@1+ (1,0) [0|1] "" XXX + SG_ L_ADJACENT : 33|1@1+ (1,0) [0|1] "" XXX + SG_ R_APPROACHING : 42|1@1+ (1,0) [0|1] "" XXX + SG_ L_APPROACHING : 43|1@1+ (1,0) [0|1] "" XXX + SG_ R_RCTA : 46|1@1+ (1,0) [0|1] "" XXX + SG_ L_RCTA : 47|1@1+ (1,0) [0|1] "" XXX + +BO_ 642 Dashlights: 8 XXX + SG_ Counter : 12|4@1+ (1,0) [0|15] "" XXX + SG_ SEATBELT_FL : 40|1@1+ (1,0) [0|1] "" XXX + SG_ LEFT_BLINKER : 44|1@1+ (1,0) [0|1] "" XXX + SG_ RIGHT_BLINKER : 45|1@1+ (1,0) [0|1] "" XXX + +BO_ 880 Steering_Torque_2: 8 XXX + SG_ Steering_Voltage_Flat : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Steer_Torque_Sensor : 29|11@1- (-1,0) [-1000|1000] "" XXX + SG_ Counter : 40|4@1+ (1,0) [0|15] "" XXX + +BO_ 884 BodyInfo: 8 XXX + SG_ DOOR_OPEN_FR : 24|1@1+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_FL : 25|1@1+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_RL : 26|1@1+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_RR : 27|1@1+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_Hatch : 28|1@1+ (1,0) [0|1] "" XXX + +BO_ 864 Engine_Temp: 8 XXX + SG_ Oil_Temp : 16|8@1+ (1,-40) [0|255] "" XXX + SG_ Coolant_Temp : 24|8@1+ (1,-40) [0|255] "" XXX + SG_ Cruise_Activated : 45|1@1+ (1,0) [0|1] "" XXX + SG_ Saved_Speed : 56|8@1+ (1,0) [0|255] "" XXX + +BO_ 866 Fuel: 8 XXX + +BO_ 1745 Dash_State: 8 XXX + SG_ Units : 15|1@1+ (1,0) [0|1] "" XXX + +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_ 353 Button "1 = main, 2 = set shallow, 3 = set deep, 4 = resume shallow, 5 resume deep"; +CM_ SG_ 354 RPM "20hz version of Transmission_Engine under Transmission"; +CM_ SG_ 359 Sig1Right_Depart "right depart, hill steep and seatbelt disengage"; +CM_ SG_ 359 LKAS_Inactive_2017 "1 when not steering, 0 when lkas steering"; +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_ 359 Sig1All_Depart "Left and right depart"; +CM_ SG_ 359 Sig2All_Depart "Left and right depart"; +CM_ SG_ 359 All_depart_2015 "always 1 on 2017"; +CM_ SG_ 604 R_APPROACHING "Faster car approaching in far right lane"; +CM_ SG_ 604 L_APPROACHING "Faster car approaching in far left lane"; +CM_ SG_ 604 R_RCTA "Rear cross traffic alert, only when in R gear"; +CM_ SG_ 604 L_RCTA "Rear cross traffic alert, only when in R gear"; +CM_ SG_ 642 Counter "Affected by signals"; +CM_ SG_ 642 SEATBELT_FL "Driver seatbelt"; +CM_ SG_ 880 Steering_Voltage_Flat "receives later than 371"; + +VAL_ 328 Gear 0 "N" 1 "D" 2 "D" 3 "D" 4 "D" 5 "D" 6 "D" 14 "R" 15 "P"; +VAL_ 1745 Units 0 "Metric" 1 "Imperial"; + +CM_ "subaru_outback_2015.dbc starts here"; + + +BO_ 358 ES_DashStatus: 8 XXX + SG_ Not_Ready_Startup : 0|3@1+ (1,0) [0|7] "" XXX + SG_ Seatbelt_Disengage : 12|2@1+ (1,0) [0|3] "" XXX + SG_ Disengage_Alert : 14|2@1+ (1,0) [0|3] "" XXX + SG_ Cruise_On : 16|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Activated : 17|1@1+ (1,0) [0|1] "" XXX + SG_ Signal1 : 18|1@1+ (1,0) [0|1] "" XXX + SG_ WHEELS_MOVING_2015 : 19|1@1+ (1,0) [0|1] "" XXX + SG_ Driver_Input : 20|1@1+ (1,0) [0|1] "" XXX + SG_ Distance_Bars : 21|3@1+ (1,0) [0|7] "" XXX + SG_ Cruise_Set_Speed : 24|8@1+ (1,0) [0|255] "" XXX + SG_ ES_Error : 32|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_On_2 : 34|1@1+ (1,0) [0|1] "" XXX + SG_ Counter : 37|3@1+ (1,0) [0|7] "" XXX + SG_ Steep_Hill_Disengage : 44|1@1+ (1,0) [0|3] "" XXX + SG_ Lead_Car : 46|1@1+ (1,0) [0|1] "" XXX + SG_ Obstacle_Distance : 48|4@1+ (5,0) [0|15] "m" XXX + +BO_ 881 Steering_Torque: 8 XXX + SG_ Steering_Motor_Flat : 0|10@1+ (32,0) [0|1000] "" XXX + SG_ Steer_Torque_Output : 16|11@1- (-32,0) [-1000|1000] "" XXX + SG_ LKA_Lockout : 27|1@1+ (1,0) [0|1] "" XXX + SG_ Steer_Torque_Sensor : 29|11@1- (1,0) [-1000|1000] "" XXX + SG_ Steering_Angle : 40|16@1- (-0.033,0) [-600|600] "" XXX + +CM_ SG_ 358 Disengage_Alert "seatbelt and steep hill disengage"; +CM_ SG_ 358 ES_Error "No engagement until restart"; +CM_ SG_ 358 Lead_Car "front car detected"; diff --git a/opendbc/subaru_outback_2016_eyesight.dbc b/opendbc/subaru_outback_2016_eyesight.dbc deleted file mode 100644 index 871f7821843231..00000000000000 --- a/opendbc/subaru_outback_2016_eyesight.dbc +++ /dev/null @@ -1,73 +0,0 @@ -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_ 884 DoorStatus: 8 XXX - SG_ DoorOpenFD : 24|1@0+ (1,0) [0|1] "" XXX - SG_ DoorOpenFP : 25|1@0+ (1,0) [0|1] "" XXX - SG_ DoorOpenRP : 26|1@0+ (1,0) [0|1] "" XXX - SG_ DoorOpenRD : 27|1@0+ (1,0) [0|1] "" XXX - SG_ DoorOpenHatch : 28|1@0+ (1,0) [0|1] "" XXX - -BO_ 324 CruiseControl: 7 XXX - SG_ BrakeApplied : 8|1@0+ (1,0) [0|0] "" XXX - SG_ CruiseEnabled : 48|1@0+ (1,0) [0|0] "" XXX - SG_ BrakeStatus : 51|1@0+ (1,0) [0|0] "" XXX - SG_ CruiseButtons : 4|2@0+ (1,0) [0|3] "" XXX - -BO_ 320 Throttle: 8 XXX - SG_ ThrottlePosition : 7|8@0+ (1,0) [0|255] "" XXX - -BO_ 209 NEW_MSG_1: 8 XXX - SG_ BrakePosition : 23|8@0+ (1,0) [0|255] "" XXX - -BO_ 2 Steering: 8 XXX - SG_ SteeringAngle : 7|16@0- (0.1,0) [-500|500] "degree" XXX - -BO_ 642 NEW_MSG_2: 8 XXX - SG_ TurnSignal : 45|2@0+ (1,0) [0|3] "" XXX - - - -CM_ "CHFFR_METRIC 2 STEER_ANGLE STEER_ANGLE 0.36 180"; - -VAL_ 324 BrakeApplied 1 "On" 0 "Off" ; -VAL_ 324 CruiseEnabled 1 "On" 0 "Off" ; -VAL_ 324 BrakeStatus 1 "On" 0 "Off" ; -VAL_ 324 CruiseButtons 2 "Set" 1 "Resume" ; - -VAL_ 642 TurnSignal 2 "Left" 1 "Right" ; diff --git a/opendbc/subaru_outback_2019_generated.dbc b/opendbc/subaru_outback_2019_generated.dbc new file mode 100644 index 00000000000000..00b042487b8802 --- /dev/null +++ b/opendbc/subaru_outback_2019_generated.dbc @@ -0,0 +1,273 @@ +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; + + +CM_ "Imported file _subaru_preglobal_2015.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 X + + +BO_ 2 Steering: 8 XXX + SG_ Steering_Angle : 7|16@0- (0.1,0) [-500|500] "degree" XXX + SG_ Counter : 27|3@0+ (1,0) [0|7] "" XXX + SG_ Checksum : 39|8@0+ (1,0) [0|255] "" XXX + +BO_ 208 G_Sensor: 8 XXX + SG_ Steering_Angle : 0|16@1- (-0.1,0) [-500|500] "" XXX + SG_ Lateral : 16|16@1- (-0.0035,1) [-255|255] "" XXX + SG_ Longitudinal : 48|16@1- (-0.00035,0) [-255|255] "" XXX + +BO_ 209 Brake_Pedal: 8 XXX + SG_ Speed : 0|16@1+ (0.05625,0) [0|255] "KPH" XXX + SG_ Brake_Pedal : 16|8@1+ (1,0) [0|255] "" XXX + +BO_ 210 Brake_2: 8 XXX + SG_ Brake_Light : 35|1@1+ (1,0) [0|1] "" XXX + SG_ Brake_Related : 36|1@1+ (1,0) [0|1] "" XXX + SG_ Right_Brake : 48|8@1+ (1,0) [0|255] "" XXX + SG_ Left_Brake : 56|8@1+ (1,0) [0|255] "" XXX + +BO_ 211 Brake_Type: 8 XXX + SG_ Brake_Light : 21|1@1+ (1,0) [0|1] "" XXX + SG_ Speed_Counter : 32|8@1+ (1,0) [0|255] "" XXX + SG_ Brake_Cruise_On : 42|1@1+ (1,0) [0|1] "" XXX + SG_ Brake_Pedal_On : 46|1@1+ (1,0) [0|1] "" XXX + SG_ Counter : 48|8@1+ (1,0) [0|255] "" XXX + +BO_ 212 Wheel_Speeds: 8 XXX + SG_ FL : 0|16@1+ (0.0592,0) [0|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] "KPH" XXX + SG_ RR : 48|16@1+ (0.0592,0) [0|255] "KPH" XXX + +BO_ 320 Throttle: 8 XXX + SG_ Throttle_Pedal : 0|8@1+ (0.392157,0) [0|255] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Not_Full_Throttle : 14|1@1+ (1,0) [0|1] "" XXX + SG_ Engine_RPM : 16|14@1+ (1,0) [0|32767] "" XXX + SG_ Off_Throttle : 30|1@1+ (1,0) [0|1] "" XXX + SG_ Throttle_Cruise : 32|8@1+ (1,0) [0|255] "" XXX + SG_ Throttle_Combo : 40|8@1+ (1,0) [0|255] "" XXX + SG_ Throttle_Body : 48|8@1+ (1,0) [0|255] "" XXX + SG_ Off_Throttle_2 : 56|1@1+ (1,0) [0|1] "" XXX + +BO_ 321 Engine: 8 XXX + SG_ Engine_Torque : 0|15@1+ (1,0) [0|255] "" XXX + SG_ Engine_Stop : 15|1@1+ (1,0) [0|1] "" XXX + SG_ Wheel_Torque : 16|12@1+ (1,0) [0|4095] "" XXX + SG_ Engine_RPM : 32|12@1+ (1,0) [0|8191] "" XXX + +BO_ 324 CruiseControl: 8 XXX + SG_ OnOffButton : 2|1@1+ (1,0) [0|1] "" XXX + SG_ SET_BUTTON : 3|1@1+ (1,0) [0|1] "" XXX + SG_ RES_BUTTON : 4|1@1+ (1,0) [0|1] "" XXX + SG_ Button : 13|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_On : 48|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Activated : 49|1@1+ (1,0) [0|1] "" XXX + SG_ Brake_Pedal_On : 51|1@1+ (1,0) [0|1] "" XXX + +BO_ 328 Transmission: 8 XXX + SG_ Manual_Gear : 4|4@1+ (1,0) [0|15] "" XXX + SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Transmission_Engine : 16|15@1+ (1,0) [0|65535] "" XXX + SG_ Gear : 48|4@1+ (1,0) [0|15] "" XXX + SG_ Gear_2 : 52|4@1+ (1,0) [0|15] "" XXX + SG_ Paddle_Shift : 60|2@1+ (1,0) [0|3] "" XXX + +BO_ 329 CVT_Ratio: 8 XXX + +BO_ 336 Brake_Pressure: 8 XXX + SG_ Brake_Pressure_Right : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Brake_Pressure_Left : 8|8@1+ (1,0) [0|255] "" XXX + +BO_ 338 Stalk: 8 XXX + SG_ Counter : 12|4@1+ (1,0) [0|15] "" XXX + SG_ Brake_Light : 52|1@1+ (1,0) [0|1] "" XXX + SG_ Runlights : 58|1@1+ (1,0) [0|1] "" XXX + SG_ Headlights : 59|1@1+ (1,0) [0|1] "" XXX + SG_ Highbeam : 60|1@1+ (1,0) [0|1] "" XXX + SG_ Wiper : 62|1@1+ (1,0) [0|1] "" XXX + +BO_ 352 ES_Brake: 8 XXX + SG_ Brake_Pressure : 0|16@1+ (1,0) [0|255] "" XXX + SG_ Brake_Light : 20|1@1+ (1,0) [0|1] "" XXX + SG_ ES_Error : 21|1@1+ (1,0) [0|1] "" XXX + SG_ Brake_On : 22|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Activated : 23|1@1+ (1,0) [0|1] "" XXX + SG_ Counter : 48|3@1+ (1,0) [0|7] "" XXX + SG_ Checksum : 56|8@1+ (1,0) [0|255] "" XXX + +BO_ 353 ES_CruiseThrottle: 8 XXX + SG_ Throttle_Cruise : 0|12@1+ (1,0) [0|4095] "" XXX + SG_ Signal1 : 12|4@1+ (1,0) [0|15] "" XXX + SG_ Cruise_Activated : 16|1@1+ (1,0) [0|1] "" XXX + SG_ Signal2 : 17|3@1+ (1,0) [0|7] "" XXX + SG_ Brake_On : 20|1@1+ (1,0) [0|1] "" XXX + SG_ DistanceSwap : 21|1@1+ (1,0) [0|1] "" XXX + SG_ Standstill : 22|1@1+ (1,0) [0|1] "" XXX + SG_ Signal3 : 23|1@1+ (1,0) [0|1] "" XXX + SG_ CloseDistance : 24|8@1+ (0.0196,0) [0|255] "m" XXX + SG_ Signal4 : 32|9@1+ (1,0) [0|255] "" XXX + SG_ Standstill_2 : 41|1@1+ (1,0) [0|1] "" XXX + SG_ ES_Error : 42|1@1+ (1,0) [0|1] "" XXX + SG_ Signal5 : 43|1@1+ (1,0) [0|1] "" XXX + SG_ Counter : 44|3@1+ (1,0) [0|7] "" XXX + SG_ Signal6 : 47|1@1+ (1,0) [0|1] "" XXX + SG_ Button : 48|3@1+ (1,0) [0|7] "" XXX + SG_ Signal7 : 51|5@1+ (1,0) [0|31] "" XXX + SG_ Checksum : 56|8@1+ (1,0) [0|255] "" XXX + +BO_ 354 ES_RPM: 8 XXX + SG_ Brake : 8|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Activated : 9|1@1+ (1,0) [0|1] "" XXX + SG_ RPM : 16|16@1+ (1,0) [0|65535] "" XXX + SG_ Checksum : 32|8@1+ (1,0) [0|255] "" XXX + SG_ Counter : 48|3@1+ (1,0) [0|7] "" XXX + +BO_ 356 ES_LKAS: 8 XXX + SG_ Counter : 0|3@1+ (1,0) [0|7] "" XXX + SG_ LKAS_Command : 8|13@1- (-1,0) [-4096|4096] "" XXX + SG_ LKAS_Active : 24|1@1+ (1,0) [0|1] "" XXX + SG_ Checksum : 56|8@1+ (1,0) [0|255] "" XXX + +BO_ 359 ES_LDW: 8 XXX + SG_ All_depart_2015 : 0|1@1+ (1,0) [0|1] "" XXX + SG_ Right_Line_2017 : 24|1@1+ (1,0) [0|1] "" XXX + SG_ Left_Line_2017 : 25|1@1+ (1,0) [0|1] "" XXX + SG_ Sig1All_Depart : 28|1@1+ (1,0) [0|1] "" XXX + SG_ Sig2All_Depart : 31|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_Inactive_2017 : 36|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_Active : 37|1@1+ (1,0) [0|1] "" XXX + SG_ Sig1Right_Depart : 48|1@1+ (1,0) [0|1] "" XXX + SG_ Sig1Right_Depart_Front : 49|1@1+ (1,0) [0|1] "" XXX + SG_ Sig2Right_Depart : 50|1@1+ (1,0) [0|1] "" XXX + SG_ Left_Depart_Front : 51|1@1+ (1,0) [0|1] "" XXX + SG_ Sig3All_Depart : 52|1@1+ (1,0) [0|1] "" XXX + +BO_ 604 BSD_RCTA: 8 XXX + SG_ Counter : 0|3@1+ (1,0) [0|7] "" XXX + SG_ State : 5|1@1+ (1,0) [0|1] "" XXX + SG_ R_ADJACENT : 32|1@1+ (1,0) [0|1] "" XXX + SG_ L_ADJACENT : 33|1@1+ (1,0) [0|1] "" XXX + SG_ R_APPROACHING : 42|1@1+ (1,0) [0|1] "" XXX + SG_ L_APPROACHING : 43|1@1+ (1,0) [0|1] "" XXX + SG_ R_RCTA : 46|1@1+ (1,0) [0|1] "" XXX + SG_ L_RCTA : 47|1@1+ (1,0) [0|1] "" XXX + +BO_ 642 Dashlights: 8 XXX + SG_ Counter : 12|4@1+ (1,0) [0|15] "" XXX + SG_ SEATBELT_FL : 40|1@1+ (1,0) [0|1] "" XXX + SG_ LEFT_BLINKER : 44|1@1+ (1,0) [0|1] "" XXX + SG_ RIGHT_BLINKER : 45|1@1+ (1,0) [0|1] "" XXX + +BO_ 880 Steering_Torque_2: 8 XXX + SG_ Steering_Voltage_Flat : 0|8@1+ (1,0) [0|255] "" XXX + SG_ Steer_Torque_Sensor : 29|11@1- (-1,0) [-1000|1000] "" XXX + SG_ Counter : 40|4@1+ (1,0) [0|15] "" XXX + +BO_ 884 BodyInfo: 8 XXX + SG_ DOOR_OPEN_FR : 24|1@1+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_FL : 25|1@1+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_RL : 26|1@1+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_RR : 27|1@1+ (1,0) [0|1] "" XXX + SG_ DOOR_OPEN_Hatch : 28|1@1+ (1,0) [0|1] "" XXX + +BO_ 864 Engine_Temp: 8 XXX + SG_ Oil_Temp : 16|8@1+ (1,-40) [0|255] "" XXX + SG_ Coolant_Temp : 24|8@1+ (1,-40) [0|255] "" XXX + SG_ Cruise_Activated : 45|1@1+ (1,0) [0|1] "" XXX + SG_ Saved_Speed : 56|8@1+ (1,0) [0|255] "" XXX + +BO_ 866 Fuel: 8 XXX + +BO_ 1745 Dash_State: 8 XXX + SG_ Units : 15|1@1+ (1,0) [0|1] "" XXX + +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_ 353 Button "1 = main, 2 = set shallow, 3 = set deep, 4 = resume shallow, 5 resume deep"; +CM_ SG_ 354 RPM "20hz version of Transmission_Engine under Transmission"; +CM_ SG_ 359 Sig1Right_Depart "right depart, hill steep and seatbelt disengage"; +CM_ SG_ 359 LKAS_Inactive_2017 "1 when not steering, 0 when lkas steering"; +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_ 359 Sig1All_Depart "Left and right depart"; +CM_ SG_ 359 Sig2All_Depart "Left and right depart"; +CM_ SG_ 359 All_depart_2015 "always 1 on 2017"; +CM_ SG_ 604 R_APPROACHING "Faster car approaching in far right lane"; +CM_ SG_ 604 L_APPROACHING "Faster car approaching in far left lane"; +CM_ SG_ 604 R_RCTA "Rear cross traffic alert, only when in R gear"; +CM_ SG_ 604 L_RCTA "Rear cross traffic alert, only when in R gear"; +CM_ SG_ 642 Counter "Affected by signals"; +CM_ SG_ 642 SEATBELT_FL "Driver seatbelt"; +CM_ SG_ 880 Steering_Voltage_Flat "receives later than 371"; + +VAL_ 328 Gear 0 "N" 1 "D" 2 "D" 3 "D" 4 "D" 5 "D" 6 "D" 14 "R" 15 "P"; +VAL_ 1745 Units 0 "Metric" 1 "Imperial"; + +CM_ "subaru_outback_2019.dbc starts here"; + + +BO_ 358 ES_DashStatus: 8 XXX + SG_ Not_Ready_Startup : 0|3@1+ (1,0) [0|7] "" XXX + SG_ Seatbelt_Disengage : 12|2@1+ (1,0) [0|3] "" XXX + SG_ Disengage_Alert : 14|2@1+ (1,0) [0|3] "" XXX + SG_ Cruise_On : 16|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Activated : 17|1@1+ (1,0) [0|1] "" XXX + SG_ Signal1 : 18|1@1+ (1,0) [0|1] "" XXX + SG_ WHEELS_MOVING_2015 : 19|1@1+ (1,0) [0|1] "" XXX + SG_ Driver_Input : 20|1@1+ (1,0) [0|1] "" XXX + SG_ Distance_Bars : 21|3@1+ (1,0) [0|7] "" XXX + SG_ Cruise_Set_Speed : 24|8@1+ (1,0) [0|255] "" XXX + SG_ ES_Error : 32|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_On_2 : 34|1@1+ (1,0) [0|1] "" XXX + SG_ Counter : 37|3@1+ (1,0) [0|7] "" XXX + SG_ Steep_Hill_Disengage : 44|1@1+ (1,0) [0|3] "" XXX + SG_ Lead_Car : 46|1@1+ (1,0) [0|1] "" XXX + SG_ Obstacle_Distance : 48|4@1+ (5,0) [0|15] "m" XXX + +BO_ 881 Steering_Torque: 8 XXX + SG_ Steering_Motor_Flat : 0|10@1+ (32,0) [0|1000] "" XXX + SG_ Steer_Torque_Output : 16|11@1- (-32,0) [-1000|1000] "" XXX + SG_ LKA_Lockout : 27|1@1+ (1,0) [0|1] "" XXX + SG_ Steer_Torque_Sensor : 29|11@1- (-1,0) [-1000|1000] "" XXX + SG_ Steering_Angle : 40|16@1- (-0.033,0) [-600|600] "" XXX + +CM_ SG_ 358 Disengage_Alert "seatbelt and steep hill disengage"; +CM_ SG_ 358 ES_Error "No engagement until restart"; +CM_ SG_ 358 Lead_Car "front car detected"; diff --git a/opendbc/tesla_can.dbc b/opendbc/tesla_can.dbc index 60642f43c17ed1..b48d1319cbffd5 100644 --- a/opendbc/tesla_can.dbc +++ b/opendbc/tesla_can.dbc @@ -172,22 +172,26 @@ BO_ 532 EPB_epasControl: 3 EPB SG_ EPB_epasEACAllow : 2|3@0+ (1,0) [4|7] "" NEO,EPAS BO_ 792 GTW_carState: 8 GTW - SG_ BOOT_STATE : 47|2@0+ (1,0) [-1|4] "" NEO - SG_ CERRD : 7|1@0+ (1,0) [-1|2] "" NEO - SG_ DAY : 36|5@0+ (1,0) [2|31] "" NEO - SG_ DOOR_STATE_FL : 13|2@0+ (1,0) [-1|4] "" NEO - SG_ DOOR_STATE_FR : 15|2@0+ (1,0) [-1|4] "" NEO - SG_ DOOR_STATE_FrontTrunk : 51|2@0+ (1,0) [-1|4] "" NEO - SG_ DOOR_STATE_RL : 23|2@0+ (1,0) [-1|4] "" NEO - SG_ DOOR_STATE_RR : 30|2@0+ (1,0) [-1|4] "" NEO - SG_ GTW_updateInProgress : 49|2@0+ (1,0) [-1|4] "" NEO - SG_ Hour : 28|5@0+ (1,0) [0|29] "h" NEO - SG_ MCU_factoryMode : 52|1@0+ (1,0) [-1|2] "" NEO - SG_ MCU_transportModeOn : 53|1@0+ (1,0) [1|1] "" NEO - SG_ MINUTE : 45|6@0+ (1,0) [0|61] "min" NEO - SG_ MONTH : 11|4@0+ (1,0) [0|14] "Month" NEO - SG_ SECOND : 21|6@0+ (1,0) [0|61] "s" NEO - SG_ YEAR : 6|7@0+ (1,2000) [2000|2125] "Year" NEO + SG_ YEAR : 0|7@1+ (1,2000) [2000|2127] "Year" NEO + SG_ CERRD : 7|1@1+ (1,0) [0|1] "" NEO + SG_ MONTH : 8|4@1+ (1,0) [1|12] "Month" NEO + SG_ DOOR_STATE_FL : 12|2@1+ (1,0) [0|3] "" NEO + SG_ DOOR_STATE_FR : 14|2@1+ (1,0) [0|3] "" NEO + SG_ SECOND : 16|6@1+ (1,0) [0|59] "s" NEO + SG_ DOOR_STATE_RL : 22|2@1+ (1,0) [0|3] "" NEO + SG_ Hour : 24|5@1+ (1,0) [0|23] "h" NEO + SG_ DOOR_STATE_RR : 29|2@1+ (1,0) [0|3] "" NEO + SG_ DAY : 32|5@1+ (1,0) [0|31] "" NEO + SG_ MINUTE : 40|6@1+ (1,0) [0|59] "min" NEO + SG_ BOOT_STATE : 46|2@1+ (1,0) [0|3] "" NEO + SG_ GTW_updateInProgress : 48|2@1+ (1,0) [0|3] "" NEO + SG_ DOOR_STATE_FrontTrunk : 50|2@1+ (1,0) [0|3] "" NEO + SG_ MCU_factoryMode : 52|1@1+ (1,0) [0|1] "" NEO + SG_ MCU_transportModeOn : 53|1@0+ (1,0) [0|1] "" NEO + SG_ BC_headLightLStatus : 55|2@0+ (1,0) [0|3] "" NEO + SG_ BC_headLightRStatus : 57|2@0+ (1,0) [0|3] "" NEO + SG_ BC_indicatorLStatus : 59|2@0+ (1,0) [0|3] "" NEO + SG_ BC_indicatorRStatus : 61|2@0+ (1,0) [0|3] "" NEO BO_ 872 DI_state: 8 DI SG_ DI_systemState : 0|3@1+ (1,0) [0|0] "" NEO @@ -280,16 +284,15 @@ BO_ 643 BODY_R1: 8 GTW SG_ VTA_Alm_Actv : 13|1@0+ (1,0) [0|1] "" NEO SG_ WprOutsdPkPosn : 29|1@0+ (1,0) [0|1] "" NEO -BO_ 760 MCU_gpsVehicleSpeed: 8 GTW - SG_ MCU_gpsHDOP : 0|8@1+ (0.1,0) [0|25.5] "1" DAS - SG_ MCU_gpsVehicleHeading : 8|16@1+ (0.0078125,0) [0|511.9921875] "deg" DAS - SG_ MCU_gpsVehicleSpeed : 24|16@1+ (0.00390625,0) [0|250.996] "km/hr" DAS - SG_ MCU_userSpeedOffset : 40|6@1+ (1,-30) [-30|33] "kph/mph" DAS - SG_ MCU_mapSpeedLimitUnits : 46|1@1+ (1,0) [0|1] "" DAS - SG_ MCU_userSpeedOffsetUnits : 47|1@1+ (1,0) [0|1] "" DAS - SG_ MCU_mppSpeedLimit : 48|5@1+ (5,0) [0|155] "kph/mph" DAS - SG_ MCU_gpsNmeaMIA : 53|1@1+ (1,0) [0|0] "" DAS - SG_ MCU_gpsAntennaDisconnected : 54|1@1+ (1,0) [0|0] "" DAS +BO_ 760 UI_gpsVehicleSpeed: 8 GTW + SG_ UI_gpsHDOP : 0|8@1+ (0.1,0) [0|25.5] "1" DAS + SG_ UI_gpsVehicleHeading : 8|16@1+ (0.0078125,0) [0|511.9921875] "deg" DAS + SG_ UI_gpsVehicleSpeed : 24|16@1+ (0.00390625,0) [0|250.996] "km/hr" Vector__XXX + SG_ UI_userSpeedOffset : 40|6@1+ (1,-30) [-30|33] "kph/mph" DAS + SG_ UI_mapSpeedLimitUnits : 46|1@1+ (1,0) [0|1] "" DAS + SG_ UI_userSpeedOffsetUnits : 47|1@1+ (1,0) [0|1] "" DAS + SG_ UI_mppSpeedLimit : 48|5@1+ (5,0) [0|155] "kph/mph" DAS + SG_ UI_gpsNmeaMIA : 53|1@1+ (1,0) [0|0] "" DAS BO_ 536 MCU_chassisControl: 8 GTW SG_ MCU_dasDebugEnable : 0|1@1+ (1,0) [0|0] "" NEO @@ -352,20 +355,6 @@ BO_ 840 GTW_status: 8 GTW SG_ GTW_statusChecksum : 63|8@0+ (1,0) [0|255] "" NEO SG_ GTW_statusCounter : 51|4@0+ (1,0) [0|15] "" NEO -BO_ 1361 GAS_COMMAND: 6 EON - SG_ GAS_COMMAND : 7|16@0+ (0.0507968128,-22.85856576) [0|1] "" INTERCEPTOR - SG_ GAS_COMMAND2 : 23|16@0+ (0.1015936256,-22.85856576) [0|1] "" INTERCEPTOR - SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR - SG_ IDX : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR - SG_ CHECKSUM : 47|8@0+ (1,0) [0|3] "" INTERCEPTOR - -BO_ 1362 GAS_SENSOR: 6 INTERCEPTOR - SG_ INTERCEPTOR_GAS : 7|16@0+ (0.0507968128,-22.85856576) [0|1] "" EON - SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.1015936256,-22.85856576) [0|1] "" EON - SG_ STATE : 35|4@0+ (1,0) [0|15] "" EON - SG_ IDX : 39|4@0+ (1,0) [0|15] "" EON - SG_ CHECKSUM : 47|8@0+ (1,0) [0|3] "" EON - BO_ 920 GTW_carConfig: 8 GTW SG_ GTW_performanceConfig : 2|3@0+ (1,0) [0|0] "" NEO SG_ GTW_fourWheelDrive : 4|2@0+ (1,0) [0|0] "" NEO @@ -675,8 +664,9 @@ VAL_ 309 ESP_absFaultLamp 0 "OFF" 1 "ON" ; VAL_ 309 ESP_espOffLamp 0 "OFF" 1 "ON" ; VAL_ 309 ESP_stabilityControlSts 2 "ENGAGED" 3 "FAULTED" 5 "INIT" 4 "NOT_CONFIGURED" 0 "OFF" 1 "ON" ; VAL_ 309 ESP_tcLampFlash 1 "FLASH" 0 "OFF" ; -VAL_ 760 MCU_speedLimitUnits 1 "KPH" 0 "MPH" ; -VAL_ 760 MCU_userSpeedOffsetUnits 1 "KPH" 0 "MPH" ; +VAL_ 568 UI_mapSpeedLimit 31 "SNA" 30 "UNLIMITED" 29 "LESS_OR_EQ_160" 28 "LESS_OR_EQ_150" 27 "LESS_OR_EQ_140" 26 "LESS_OR_EQ_130" 25 "LESS_OR_EQ_120" 24 "LESS_OR_EQ_115" 23 "LESS_OR_EQ_110" 22 "LESS_OR_EQ_105" 21 "LESS_OR_EQ_100" 20 "LESS_OR_EQ_95" 19 "LESS_OR_EQ_90" 18 "LESS_OR_EQ_85" 17 "LESS_OR_EQ_80" 16 "LESS_OR_EQ_75" 15 "LESS_OR_EQ_70" 14 "LESS_OR_EQ_65" 13 "LESS_OR_EQ_60" 12 "LESS_OR_EQ_55" 11 "LESS_OR_EQ_50" 10 "LESS_OR_EQ_45" 9 "LESS_OR_EQ_40" 8 "LESS_OR_EQ_35" 7 "LESS_OR_EQ_30" 6 "LESS_OR_EQ_25" 5 "LESS_OR_EQ_20" 4 "LESS_OR_EQ_15" 3 "LESS_OR_EQ_10" 2 "LESS_OR_EQ_7" 1 "LESS_OR_EQ_5" 0 "UNKNOWN" ; +VAL_ 760 UI_mapSpeedLimitUnits 1 "KPH" 0 "MPH" ; +VAL_ 760 UI_userSpeedOffsetUnits 1 "KPH" 0 "MPH" ; VAL_ 643 AirTemp_Insd 255 "SNA" ; VAL_ 643 AirTemp_Outsd 254 "INIT" 255 "SNA" ; VAL_ 643 Bckl_Sw_RL_Stat_SAM_R 2 "FLT" 1 "NOT" 0 "OK" 3 "SNA" ; @@ -730,7 +720,6 @@ VAL_ 904 MCU_clusterReadyForDrive 0 "NO_SNA" 1 "YES" ; VAL_ 1160 DAS_steeringAngleRequest 16384 "ZERO_ANGLE" ; VAL_ 1160 DAS_steeringControlType 1 "ANGLE_CONTROL" 3 "DISABLED" 0 "NONE" 2 "RESERVED" ; VAL_ 1160 DAS_steeringHapticRequest 1 "ACTIVE" 0 "IDLE" ; -VAL_ 1362 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; CM_ "CHFFR_METRIC 1160 DAS_steeringAngleRequest STEER_ANGLE 0.1098666 180; CHFFR_METRIC 264 DI_motorRPM ENGINE_RPM 1 0"; diff --git a/opendbc/tesla_can1916.dbc b/opendbc/tesla_can1916.dbc index 97c42ab9de04ab..a02da2bb4b4ec8 100644 --- a/opendbc/tesla_can1916.dbc +++ b/opendbc/tesla_can1916.dbc @@ -172,22 +172,26 @@ BO_ 532 EPB_epasControl: 3 EPB SG_ EPB_epasEACAllow : 2|3@0+ (1,0) [4|7] "" NEO,EPAS BO_ 792 GTW_carState: 8 GTW - SG_ BOOT_STATE : 47|2@0+ (1,0) [-1|4] "" NEO - SG_ CERRD : 7|1@0+ (1,0) [-1|2] "" NEO - SG_ DAY : 36|5@0+ (1,0) [2|31] "" NEO - SG_ DOOR_STATE_FL : 13|2@0+ (1,0) [-1|4] "" NEO - SG_ DOOR_STATE_FR : 15|2@0+ (1,0) [-1|4] "" NEO - SG_ DOOR_STATE_FrontTrunk : 51|2@0+ (1,0) [-1|4] "" NEO - SG_ DOOR_STATE_RL : 23|2@0+ (1,0) [-1|4] "" NEO - SG_ DOOR_STATE_RR : 30|2@0+ (1,0) [-1|4] "" NEO - SG_ GTW_updateInProgress : 49|2@0+ (1,0) [-1|4] "" NEO - SG_ Hour : 28|5@0+ (1,0) [0|29] "h" NEO - SG_ MCU_factoryMode : 52|1@0+ (1,0) [-1|2] "" NEO - SG_ MCU_transportModeOn : 53|1@0+ (1,0) [1|1] "" NEO - SG_ MINUTE : 45|6@0+ (1,0) [0|61] "min" NEO - SG_ MONTH : 11|4@0+ (1,0) [0|14] "Month" NEO - SG_ SECOND : 21|6@0+ (1,0) [0|61] "s" NEO - SG_ YEAR : 6|7@0+ (1,2000) [2000|2125] "Year" NEO + SG_ YEAR : 0|7@1+ (1,2000) [2000|2127] "Year" NEO + SG_ CERRD : 7|1@1+ (1,0) [0|1] "" NEO + SG_ MONTH : 8|4@1+ (1,0) [1|12] "Month" NEO + SG_ DOOR_STATE_FL : 12|2@1+ (1,0) [0|3] "" NEO + SG_ DOOR_STATE_FR : 14|2@1+ (1,0) [0|3] "" NEO + SG_ SECOND : 16|6@1+ (1,0) [0|59] "s" NEO + SG_ DOOR_STATE_RL : 22|2@1+ (1,0) [0|3] "" NEO + SG_ Hour : 24|5@1+ (1,0) [0|23] "h" NEO + SG_ DOOR_STATE_RR : 29|2@1+ (1,0) [0|3] "" NEO + SG_ DAY : 32|5@1+ (1,0) [0|31] "" NEO + SG_ MINUTE : 40|6@1+ (1,0) [0|59] "min" NEO + SG_ BOOT_STATE : 46|2@1+ (1,0) [0|3] "" NEO + SG_ GTW_updateInProgress : 48|2@1+ (1,0) [0|3] "" NEO + SG_ DOOR_STATE_FrontTrunk : 50|2@1+ (1,0) [0|3] "" NEO + SG_ MCU_factoryMode : 52|1@1+ (1,0) [0|1] "" NEO + SG_ MCU_transportModeOn : 53|1@0+ (1,0) [0|1] "" NEO + SG_ BC_headLightLStatus : 55|2@0+ (1,0) [0|3] "" NEO + SG_ BC_headLightRStatus : 57|2@0+ (1,0) [0|3] "" NEO + SG_ BC_indicatorLStatus : 59|2@0+ (1,0) [0|3] "" NEO + SG_ BC_indicatorRStatus : 61|2@0+ (1,0) [0|3] "" NEO BO_ 872 DI_state: 8 DI SG_ DI_systemState : 0|3@1+ (1,0) [0|0] "" NEO @@ -280,16 +284,15 @@ BO_ 643 BODY_R1: 8 GTW SG_ VTA_Alm_Actv : 13|1@0+ (1,0) [0|1] "" NEO SG_ WprOutsdPkPosn : 29|1@0+ (1,0) [0|1] "" NEO -BO_ 760 MCU_gpsVehicleSpeed: 8 GTW - SG_ MCU_gpsHDOP : 0|8@1+ (0.1,0) [0|25.5] "1" DAS - SG_ MCU_gpsVehicleHeading : 8|16@1+ (0.0078125,0) [0|511.9921875] "deg" DAS - SG_ MCU_gpsVehicleSpeed : 24|16@1+ (0.00390625,0) [0|250.996] "km/hr" DAS - SG_ MCU_userSpeedOffset : 40|6@1+ (1,-30) [-30|33] "kph/mph" DAS - SG_ MCU_mapSpeedLimitUnits : 46|1@1+ (1,0) [0|1] "" DAS - SG_ MCU_userSpeedOffsetUnits : 47|1@1+ (1,0) [0|1] "" DAS - SG_ MCU_mppSpeedLimit : 48|5@1+ (5,0) [0|155] "kph/mph" DAS - SG_ MCU_gpsNmeaMIA : 53|1@1+ (1,0) [0|0] "" DAS - SG_ MCU_gpsAntennaDisconnected : 54|1@1+ (1,0) [0|0] "" DAS +BO_ 760 UI_gpsVehicleSpeed: 8 GTW + SG_ UI_gpsHDOP : 0|8@1+ (0.1,0) [0|25.5] "1" DAS + SG_ UI_gpsVehicleHeading : 8|16@1+ (0.0078125,0) [0|511.9921875] "deg" DAS + SG_ UI_gpsVehicleSpeed : 24|16@1+ (0.00390625,0) [0|250.996] "km/hr" Vector__XXX + SG_ UI_userSpeedOffset : 40|6@1+ (1,-30) [-30|33] "kph/mph" DAS + SG_ UI_mapSpeedLimitUnits : 46|1@1+ (1,0) [0|1] "" DAS + SG_ UI_userSpeedOffsetUnits : 47|1@1+ (1,0) [0|1] "" DAS + SG_ UI_mppSpeedLimit : 48|5@1+ (5,0) [0|155] "kph/mph" DAS + SG_ UI_gpsNmeaMIA : 53|1@1+ (1,0) [0|0] "" DAS BO_ 536 MCU_chassisControl: 8 GTW SG_ MCU_dasDebugEnable : 0|1@1+ (1,0) [0|0] "" NEO @@ -352,20 +355,6 @@ BO_ 840 GTW_status: 8 GTW SG_ GTW_statusChecksum : 63|8@0+ (1,0) [0|255] "" NEO SG_ GTW_statusCounter : 51|4@0+ (1,0) [0|15] "" NEO -BO_ 1361 GAS_COMMAND: 6 EON - SG_ GAS_COMMAND : 7|16@0+ (0.0507968128,-22.85856576) [0|1] "" INTERCEPTOR - SG_ GAS_COMMAND2 : 23|16@0+ (0.1015936256,-22.85856576) [0|1] "" INTERCEPTOR - SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR - SG_ IDX : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR - SG_ CHECKSUM : 47|8@0+ (1,0) [0|3] "" INTERCEPTOR - -BO_ 1362 GAS_SENSOR: 6 INTERCEPTOR - SG_ INTERCEPTOR_GAS : 7|16@0+ (0.0507968128,-22.85856576) [0|1] "" EON - SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.1015936256,-22.85856576) [0|1] "" EON - SG_ STATE : 35|4@0+ (1,0) [0|15] "" EON - SG_ IDX : 39|4@0+ (1,0) [0|15] "" EON - SG_ CHECKSUM : 47|8@0+ (1,0) [0|3] "" EON - BO_ 920 GTW_carConfig: 8 GTW SG_ GTW_performanceConfig : 2|3@0+ (1,0) [0|0] "" NEO SG_ GTW_fourWheelDrive : 4|2@0+ (1,0) [0|0] "" NEO @@ -675,8 +664,9 @@ VAL_ 309 ESP_absFaultLamp 0 "OFF" 1 "ON" ; VAL_ 309 ESP_espOffLamp 0 "OFF" 1 "ON" ; VAL_ 309 ESP_stabilityControlSts 2 "ENGAGED" 3 "FAULTED" 5 "INIT" 4 "NOT_CONFIGURED" 0 "OFF" 1 "ON" ; VAL_ 309 ESP_tcLampFlash 1 "FLASH" 0 "OFF" ; -VAL_ 760 MCU_speedLimitUnits 1 "KPH" 0 "MPH" ; -VAL_ 760 MCU_userSpeedOffsetUnits 1 "KPH" 0 "MPH" ; +VAL_ 568 UI_mapSpeedLimit 31 "SNA" 30 "UNLIMITED" 29 "LESS_OR_EQ_160" 28 "LESS_OR_EQ_150" 27 "LESS_OR_EQ_140" 26 "LESS_OR_EQ_130" 25 "LESS_OR_EQ_120" 24 "LESS_OR_EQ_115" 23 "LESS_OR_EQ_110" 22 "LESS_OR_EQ_105" 21 "LESS_OR_EQ_100" 20 "LESS_OR_EQ_95" 19 "LESS_OR_EQ_90" 18 "LESS_OR_EQ_85" 17 "LESS_OR_EQ_80" 16 "LESS_OR_EQ_75" 15 "LESS_OR_EQ_70" 14 "LESS_OR_EQ_65" 13 "LESS_OR_EQ_60" 12 "LESS_OR_EQ_55" 11 "LESS_OR_EQ_50" 10 "LESS_OR_EQ_45" 9 "LESS_OR_EQ_40" 8 "LESS_OR_EQ_35" 7 "LESS_OR_EQ_30" 6 "LESS_OR_EQ_25" 5 "LESS_OR_EQ_20" 4 "LESS_OR_EQ_15" 3 "LESS_OR_EQ_10" 2 "LESS_OR_EQ_7" 1 "LESS_OR_EQ_5" 0 "UNKNOWN" ; +VAL_ 760 UI_mapSpeedLimitUnits 1 "KPH" 0 "MPH" ; +VAL_ 760 UI_userSpeedOffsetUnits 1 "KPH" 0 "MPH" ; VAL_ 643 AirTemp_Insd 255 "SNA" ; VAL_ 643 AirTemp_Outsd 254 "INIT" 255 "SNA" ; VAL_ 643 Bckl_Sw_RL_Stat_SAM_R 2 "FLT" 1 "NOT" 0 "OK" 3 "SNA" ; @@ -730,7 +720,6 @@ VAL_ 904 MCU_clusterReadyForDrive 0 "NO_SNA" 1 "YES" ; VAL_ 1160 DAS_steeringAngleRequest 16384 "ZERO_ANGLE" ; VAL_ 1160 DAS_steeringControlType 1 "ANGLE_CONTROL" 3 "DISABLED" 0 "NONE" 2 "RESERVED" ; VAL_ 1160 DAS_steeringHapticRequest 1 "ACTIVE" 0 "IDLE" ; -VAL_ 1362 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; CM_ "CHFFR_METRIC 1160 DAS_steeringAngleRequest STEER_ANGLE 0.1098666 180; CHFFR_METRIC 264 DI_motorRPM ENGINE_RPM 1 0"; diff --git a/opendbc/tesla_can_epas.dbc b/opendbc/tesla_can_epas.dbc index abd3f1431cb4c8..b496cf23d230e9 100644 --- a/opendbc/tesla_can_epas.dbc +++ b/opendbc/tesla_can_epas.dbc @@ -45,7 +45,42 @@ BU_: APP DAS +BO_ 513 SDM1: 5 GTW + SG_ SDM_bcklPassStatus : 3|2@0+ (1,0) [0|3] "" NEO + SG_ SDM_bcklDrivStatus : 5|2@0+ (1,0) [0|3] "" NEO +BO_ 643 BODY_R1: 8 GTW + SG_ AirTemp_Insd : 47|8@0+ (0.25,0) [0|63.5] "C" NEO + SG_ AirTemp_Outsd : 63|8@0+ (0.5,-40) [-40|86.5] "C" NEO + SG_ Bckl_Sw_RL_Stat_SAM_R : 49|2@0+ (1,0) [-1|4] "" NEO + SG_ Bckl_Sw_RM_Stat_SAM_R : 53|2@0+ (1,0) [-1|4] "" NEO + SG_ Bckl_Sw_RR_Stat_SAM_R : 51|2@0+ (1,0) [-1|4] "" NEO + SG_ DL_RLtch_Stat : 9|2@0+ (1,0) [-1|4] "" NEO + SG_ DrRLtch_FL_Stat : 1|2@0+ (1,0) [-1|4] "" NEO + SG_ DrRLtch_FR_Stat : 3|2@0+ (1,0) [-1|4] "" NEO + SG_ DrRLtch_RL_Stat : 5|2@0+ (1,0) [-1|4] "" NEO + SG_ DrRLtch_RR_Stat : 7|2@0+ (1,0) [-1|4] "" NEO + SG_ EngHd_Stat : 11|2@0+ (1,0) [-1|4] "" NEO + SG_ LoBm_On_Rq : 32|1@0+ (1,0) [0|1] "" NEO + SG_ HiBm_On : 33|1@0+ (1,0) [0|1] "" NEO + SG_ Hrn_On : 26|1@0+ (1,0) [0|1] "" NEO + SG_ IrLmp_D_Lt_Flt : 34|1@0+ (1,0) [0|1] "" NEO + SG_ IrLmp_P_Rt_Flt : 35|1@0+ (1,0) [0|1] "" NEO + SG_ LgtSens_Twlgt : 18|3@0+ (1,0) [0|7] "Steps" NEO + SG_ LgtSens_SNA : 19|1@0+ (1,0) [0|1] "" NEO + SG_ LgtSens_Tunnel : 20|1@0+ (1,0) [0|1] "" NEO + SG_ LgtSens_Flt : 21|1@0+ (1,0) [0|1] "" NEO + SG_ LgtSens_Night : 22|1@0+ (1,0) [-1|2] "" NEO + SG_ ADL_LoBm_On_Rq : 23|1@0+ (1,0) [0|1] "" NEO + SG_ LoBm_D_Lt_Flt : 36|1@0+ (1,0) [0|1] "" NEO + SG_ LoBm_P_Rt_Flt : 37|1@0+ (1,0) [0|1] "" NEO + SG_ MPkBrk_Stat : 28|1@0+ (1,0) [-1|2] "" NEO + SG_ RevGr_Engg : 39|2@0+ (1,0) [-1|4] "" NEO + SG_ StW_Cond_Stat : 55|2@0+ (1,0) [-1|4] "" NEO + SG_ Term54_Actv : 27|1@0+ (1,0) [0|1] "" NEO + SG_ Trlr_Stat : 25|2@0+ (1,0) [-1|4] "" NEO + SG_ VTA_Alm_Actv : 13|1@0+ (1,0) [0|1] "" NEO + SG_ WprOutsdPkPosn : 29|1@0+ (1,0) [0|1] "" NEO BO_ 880 EPAS_sysStatus: 8 EPAS SG_ EPAS_currentTuneMode : 7|4@0+ (1,0) [8|15] "" NEO @@ -59,7 +94,23 @@ BO_ 880 EPAS_sysStatus: 8 EPAS SG_ EPAS_sysStatusChecksum : 63|8@0+ (1,0) [0|255] "" NEO SG_ EPAS_sysStatusCounter : 51|4@0+ (1,0) [0|15] "" NEO SG_ EPAS_torsionBarTorque : 19|12@0+ (0.01,-20.5) [0|0] "Nm" NEO - + +VAL_ 643 AirTemp_Insd 255 "SNA" ; +VAL_ 643 AirTemp_Outsd 254 "INIT" 255 "SNA" ; +VAL_ 643 Bckl_Sw_RL_Stat_SAM_R 2 "FLT" 1 "NOT" 0 "OK" 3 "SNA" ; +VAL_ 643 Bckl_Sw_RM_Stat_SAM_R 2 "FLT" 1 "NOT" 0 "OK" 3 "SNA" ; +VAL_ 643 Bckl_Sw_RR_Stat_SAM_R 2 "FLT" 1 "NOT" 0 "OK" 3 "SNA" ; +VAL_ 643 DL_RLtch_Stat 1 "CLS" 0 "NDEF0" 2 "OPN" 3 "SNA" ; +VAL_ 643 DrRLtch_FL_Stat 1 "CLS" 0 "NDEF0" 2 "OPN" 3 "SNA" ; +VAL_ 643 DrRLtch_FR_Stat 1 "CLS" 0 "NDEF0" 2 "OPN" 3 "SNA" ; +VAL_ 643 DrRLtch_RL_Stat 1 "CLS" 0 "NDEF0" 2 "OPN" 3 "SNA" ; +VAL_ 643 DrRLtch_RR_Stat 1 "CLS" 0 "NDEF0" 2 "OPN" 3 "SNA" ; +VAL_ 643 EngHd_Stat 1 "CLS" 0 "NDEF0" 2 "OPN" 3 "SNA" ; +VAL_ 643 LgtSens_Night 0 "DAY" 1 "NIGHT" ; +VAL_ 643 MPkBrk_Stat 1 "ENGG" 0 "RELS" ; +VAL_ 643 RevGr_Engg 0 "DISENGG" 1 "ENGG" 2 "NDEF2" 3 "SNA" ; +VAL_ 643 StW_Cond_Stat 3 "BLINK" 1 "NDEF1" 0 "OFF" 2 "ON" ; +VAL_ 643 Trlr_Stat 2 "NDEF2" 0 "NONE" 1 "OK" 3 "SNA" ; VAL_ 880 EPAS_currentTuneMode 1 "DM_COMFORT" 3 "DM_SPORT" 2 "DM_STANDARD" 0 "FAIL_SAFE_DEFAULT" 4 "RWD_COMFORT" 6 "RWD_SPORT" 5 "RWD_STANDARD" 7 "UNAVAILABLE" ; VAL_ 880 EPAS_eacErrorCode 14 "EAC_ERROR_EPB_INHIBIT" 3 "EAC_ERROR_HANDS_ON" 7 "EAC_ERROR_HIGH_ANGLE_RATE_REQ" 9 "EAC_ERROR_HIGH_ANGLE_RATE_SAFETY" 6 "EAC_ERROR_HIGH_ANGLE_REQ" 8 "EAC_ERROR_HIGH_ANGLE_SAFETY" 10 "EAC_ERROR_HIGH_MMOT_SAFETY" 11 "EAC_ERROR_HIGH_TORSION_SAFETY" 0 "EAC_ERROR_IDLE" 12 "EAC_ERROR_LOW_ASSIST" 2 "EAC_ERROR_MAX_SPEED" 1 "EAC_ERROR_MIN_SPEED" 13 "EAC_ERROR_PINION_VEL_DIFF" 4 "EAC_ERROR_TMP_FAULT" 5 "EAR_ERROR_MAX_STEER_DELTA" 15 "SNA" ; VAL_ 880 EPAS_eacStatus 2 "EAC_ACTIVE" 1 "EAC_AVAILABLE" 3 "EAC_FAULT" 0 "EAC_INHIBITED" 4 "SNA" ; diff --git a/opendbc/tesla_can_pedal.dbc b/opendbc/tesla_can_pedal.dbc index db30fb4fe572c4..dc65be3c5ad32c 100644 --- a/opendbc/tesla_can_pedal.dbc +++ b/opendbc/tesla_can_pedal.dbc @@ -58,4 +58,5 @@ BO_ 1362 GAS_SENSOR: 6 INTERCEPTOR SG_ STATE : 35|4@0+ (1,0) [0|15] "" EON SG_ IDX : 39|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM : 47|8@0+ (1,0) [0|3] "" EON - \ No newline at end of file + +VAL_ 1362 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; diff --git a/opendbc/toyota_2017_ref_pt.dbc b/opendbc/toyota_2017_ref_pt.dbc deleted file mode 100644 index 2622c9f42e5732..00000000000000 --- a/opendbc/toyota_2017_ref_pt.dbc +++ /dev/null @@ -1,1313 +0,0 @@ -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_: AFS BSR CGW CSR DS1 FCM FRD KSS MAV SCS Vector__XXX - - -BO_ 1196 ABG1D50: 8 CGW - SG_ DRABG01 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRABG02 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRABG03 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRABG04 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRABG05 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRABG06 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRABG07 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRABG08 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1212 ABG1D51: 8 CGW - SG_ DRABG09 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRABG10 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRABG11 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRABG12 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRABG13 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRABG14 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRABG15 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRABG16 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 945 ABG1S01: 8 CGW - SG_ CDT : 22|3@0+ (1,0) [0|0] "" DS1 - SG_ AB : 19|2@0+ (1,0) [0|0] "" DS1 - SG_ DBKLAB : 17|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ PODT : 27|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ PBKLAB : 25|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ EDRTRG : 44|2@0+ (1,0) [0|0] "" DS1 - -BO_ 836 ACC1F01: 8 DS1 - SG_ DSS1GDRV : 7|10@0- (0.1,0) [0|0] "m/s^2" Vector__XXX - SG_ DS1STAT2 : 13|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ DS1STBK2 : 10|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ PCSWAR : 18|1@0+ (1,0) [0|0] "" FCM - SG_ PCSALM : 17|1@0+ (1,0) [0|0] "" FCM - SG_ PCSOPR : 16|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PCSABK : 31|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PBATRGR : 30|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ PPTRGR : 28|1@0+ (1,0) [0|0] "" FCM - SG_ IBTRGR : 27|1@0+ (1,0) [0|0] "" FCM - SG_ CLEXTRGR : 26|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ IRLT_REQ : 25|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ BRKHLD : 37|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ AVSTRGR : 36|1@0+ (1,0) [0|0] "" SCS - SG_ VGRSTRGR : 35|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ PREFILL : 33|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PBRTRGR : 32|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PCSDIS : 43|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PBPREPMP : 40|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ ACCF01SM : 63|8@0+ (1,0) [0|0] "" FCM - -BO_ 1227 ACC1N01: 8 DS1 - SG_ ACCNID : 7|8@0+ (1,0) [0|0] "" CGW - SG_ ACCSNG : 15|1@0+ (1,0) [0|0] "" CGW - SG_ ACCSPF : 23|16@0+ (1,0) [0|0] "" CGW - SG_ ACCREV : 39|32@0+ (1,0) [0|0] "" CGW - -BO_ 835 ACC1S03: 8 DS1 - SG_ ATACC2 : 7|16@0- (0.001,0) [0|0] "m/s^2" Vector__XXX - SG_ ACCTYPE : 23|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ XTRGT2 : 21|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ XLTMD2 : 20|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LCDT2 : 19|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LCNG : 18|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ SMC : 17|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ STOKJD : 31|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PMTBRKG : 30|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LVSTP : 29|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LCCWOK : 25|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LCBW2 : 24|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CACC : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ AT_RAW : 47|8@0- (0.05,0) [0|0] "m/s^2" Vector__XXX - SG_ ACC03SUM : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 896 ACN1S01: 8 CGW - SG_ R_AC2 : 6|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ R_HTR : 5|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ ECOSW : 2|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ R_EGON : 1|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ BLWON : 15|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ SCAC : 13|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CGIH : 23|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ FAN_AC : 22|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ ACHI : 20|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ ACMAX : 19|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ R_VSCUS : 31|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ R_SHTR : 30|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ R_PTC : 29|2@0+ (1,0) [0|0] "piece" Vector__XXX - SG_ GNRTIH : 27|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ R_COL_TM : 26|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ R_HET_TM : 24|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ TAMOUT : 55|8@0- (0.625,0) [0|0] "ÂŽ" Vector__XXX - -BO_ 897 ACN1S04: 8 CGW - SG_ R_ACCALL : 7|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ R_AC_WNG : 6|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ R_SW_CON : 5|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ R_BEEP : 4|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_RA_AUT : 3|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_RA_AC : 2|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_RA_LO : 1|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_RA_HI : 0|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_AUTO_D : 15|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_AUTO_P : 14|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_DEF : 13|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_RRDEF : 12|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_RFAUT : 11|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_REC : 10|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_FRS : 9|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_AC : 8|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_MHTR : 23|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_WIPD : 22|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_DUSY : 21|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_SWNG : 20|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_BLW_F : 19|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_OAUT_D : 31|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_OLET_D : 30|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_OAUT_P : 27|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_OLET_P : 26|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ ST_BMN_F : 39|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_AIRPR : 47|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_O2 : 46|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_PLSM : 45|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_KAFUN : 43|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_SAFS : 42|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ I_ACOFF : 41|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ R_ONSCRN : 40|1@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 944 ACN1S07: 6 CGW - SG_ RDEF : 7|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ MHTR : 6|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ TR_TEMP : 15|8@0+ (0.25,-6.5) [0|0] "ÂŽ" Vector__XXX - SG_ ACN_AMB : 31|8@0+ (1,0) [0|0] "ÂŽ" CSR,DS1,FCM - SG_ AC_AMB05 : 44|1@0+ (1,0) [0|0] "ÂŽ" Vector__XXX - SG_ AC_MODE : 43|2@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1250 AFS1N01: 8 AFS - SG_ AFSNID : 7|8@0+ (1,0) [0|0] "" CGW - SG_ AFSSNG : 15|1@0+ (1,0) [0|0] "" CGW - SG_ AFSSPF : 23|16@0+ (1,0) [0|0] "" CGW - SG_ AFSREV : 39|32@0+ (1,0) [0|0] "" CGW - -BO_ 913 AFS1S01: 8 AFS - SG_ HLLI : 7|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ AZB_ADV : 5|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ HEDH_AZB : 3|1@0+ (1,0) [0|0] "" FCM - SG_ AZB_IND : 13|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ AZB_HIND : 11|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ AZB_PRE : 10|1@0+ (1,0) [0|0] "" FCM - SG_ LED_HLI : 9|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ LPECU_PR : 24|1@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 845 AFS1S02: 5 AFS - SG_ AHRR : 17|10@0+ (0.0048828125,0) [0|0] "V" Vector__XXX - SG_ AHVLD : 39|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ AHFAIL : 38|1@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1044 AHB1S01: 8 FCM - SG_ AHB_DUTY : 47|8@0+ (0.5,0) [0|0] "%" Vector__XXX - SG_ F_AHB : 55|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ C_AHB : 51|4@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 900 AVN1S01: 6 CGW - SG_ RDC : 7|4@0+ (1,0) [0|0] "" SCS - SG_ CONFID01 : 3|2@0+ (1,0) [0|0] "" SCS - SG_ CONF : 1|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ LYT : 15|4@0+ (1,0) [0|0] "" SCS - SG_ DRVW : 9|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ MWMP : 8|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ GRAD : 23|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ HARSHID : 19|4@0+ (1,0) [0|0] "" SCS - SG_ BRANCH : 27|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ HARSH : 35|2@0+ (1,0) [0|0] "" SCS - SG_ TOLLGATE : 33|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ TUNL : 32|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LEAVEOUT : 47|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ MRGLANE : 46|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LVLANE : 45|1@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 902 AVN1S03: 6 CGW - SG_ ANS : 7|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CRS1 : 15|1@0+ (1,0) [0|0] "" SCS - SG_ RQAC : 14|7@0+ (0.02,0) [0|0] "G" Vector__XXX - SG_ GUID : 23|1@0+ (1,0) [0|0] "" SCS - SG_ GYRO : 22|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ NCRN : 21|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CRN6 : 20|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CRN5 : 19|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CRN3 : 18|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CRN2 : 17|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CRN1 : 16|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CONFID03 : 31|2@0+ (1,0) [0|0] "" SCS - SG_ CURV : 29|2@0+ (1,0) [0|0] "" SCS - SG_ CVST : 27|1@0+ (1,0) [0|0] "" SCS - SG_ NAVI_STR : 26|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ MIND : 25|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ ONOFF : 24|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ HWPB : 39|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ RAD : 38|7@0+ (5,0) [0|0] "m" SCS - SG_ AFS_SW : 41|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ AVS_SW : 40|1@0+ (1,0) [0|0] "" SCS - -BO_ 911 AVN1S07: 8 CGW - SG_ TOFC_RST : 6|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ SL_CSTM : 3|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ SL_RMDG : 2|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ ST_RTCOM : 1|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ AVN07VLD : 0|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ ST_UCST : 15|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ RSCOM51 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ RSCOM52 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ RSCOM53 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ RSCOM54 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ RSCOM55 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ RSCOM56 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 905 AVN1S08: 8 CGW - SG_ VVSW : 7|3@0+ (1,0) [0|0] "" CSR - SG_ BZV : 4|3@0+ (1,0) [0|0] "" CSR - SG_ DFS : 1|2@0+ (1,0) [0|0] "" CSR - SG_ BZ_M_SW : 15|1@0+ (1,0) [0|0] "" CSR - SG_ VOL_SW : 14|1@0+ (1,0) [0|0] "" CSR - SG_ BM : 13|1@0+ (1,0) [0|0] "" CSR - SG_ DOFR : 12|1@0+ (1,0) [0|0] "" CSR - SG_ RDSW : 11|1@0+ (1,0) [0|0] "" CSR - SG_ FDSW : 10|1@0+ (1,0) [0|0] "" CSR - SG_ RBSW : 9|1@0+ (1,0) [0|0] "" CSR - SG_ FBSW : 8|1@0+ (1,0) [0|0] "" CSR - SG_ NVDP_OK : 23|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ DEVICE : 22|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ DISPSIZE : 31|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ HPTCSW_L : 30|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ HPTCSW_R : 29|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ HPTCSW_E : 28|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ D_MODE : 27|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ VARBGM : 26|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ WBGM : 24|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ X_LL : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ Y_LL : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ X_RH : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ Y_RH : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 998 AVN1S11: 5 CGW - SG_ SENSPFM : 7|3@0+ (1,0) [0|0] "" SCS - SG_ SENSFAIL : 4|3@0+ (1,0) [0|0] "" SCS - SG_ CONFID11 : 1|2@0+ (1,0) [0|0] "" SCS - SG_ CONFMMC : 15|8@0+ (1,0) [0|0] "" SCS - SG_ DISTERR : 23|8@0+ (1,0) [0|0] "" SCS - SG_ CONFLANE : 31|8@0+ (1,0) [0|0] "" SCS - SG_ CONFDIR : 39|8@0+ (1,0) [0|0] "" SCS - -BO_ 933 AVN1S13: 8 CGW - SG_ HUD_DISP : 7|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRVSIDE : 6|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ DT_GP : 5|6@0+ (1,0) [0|0] "" Vector__XXX - SG_ DT_UNIT : 15|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ DIR_TURN : 12|5@0+ (11.25,0) [0|0] "degree" Vector__XXX - SG_ ROTARY : 23|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ ROAD_TP1 : 22|15@0+ (1,0) [0|0] "" Vector__XXX - SG_ ROAD_TP2 : 39|16@0+ (1,0) [0|0] "" Vector__XXX - SG_ N_H_UP : 55|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ COMPASS : 54|6@0+ (11.25,0) [0|0] "degree" Vector__XXX - SG_ DIR : 63|6@0+ (11.25,0) [0|0] "degree" Vector__XXX - -BO_ 936 AVN1S16: 5 CGW - SG_ NDADVSRY : 7|5@0+ (1,0) [0|0] "" Vector__XXX - SG_ NDCAUTON : 15|5@0+ (1,0) [0|0] "" Vector__XXX - SG_ NDSSLCT : 23|5@0+ (1,0) [0|0] "" Vector__XXX - SG_ NDCNFDID : 18|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ NDINDST : 25|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ AVN16SUM : 39|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 999 AVN1S17: 7 CGW - SG_ AVN17VLD : 7|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LANEID17 : 6|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRVLANE : 3|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRV_SIDE : 12|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LANE_NS : 11|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ LANE1FLG : 23|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ LANE2FLG : 19|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ LANE1DIR : 31|16@0+ (1,0) [0|0] "" Vector__XXX - SG_ LANE2DIR : 47|16@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1000 AVN1S18: 8 CGW - SG_ AVN18VLD : 7|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LANEID18 : 6|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ LANE3FLG : 3|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ LANE4FLG : 15|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ LANE5FLG : 11|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ LANE3DIR : 23|16@0+ (1,0) [0|0] "" Vector__XXX - SG_ LANE4DIR : 39|16@0+ (1,0) [0|0] "" Vector__XXX - SG_ LANE5DIR : 55|16@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1001 AVN1S19: 8 CGW - SG_ AVN19VLD : 7|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LANEID19 : 6|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ LANE6FLG : 3|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ LANE7FLG : 15|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ LANE8FLG : 11|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ LANE6DIR : 23|16@0+ (1,0) [0|0] "" Vector__XXX - SG_ LANE7DIR : 39|16@0+ (1,0) [0|0] "" Vector__XXX - SG_ LANE8DIR : 55|16@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1076 AVN1S20: 8 CGW - SG_ A_LNG_ST : 7|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ A_LANG : 5|6@0+ (1,0) [0|0] "" Vector__XXX - SG_ A_LNGDB1 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ A_LNGDB2 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ A_LNGDB3 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ A_LNGDB4 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ A_LNGDB5 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ A_LNGDB6 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ A_LNGDB7 : 63|7@0+ (1,0) [0|0] "" Vector__XXX - SG_ A_LNGCHG : 56|1@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1077 AVN1S21: 8 CGW - SG_ A_OPEN_S : 7|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ OPENCHG : 6|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CAPSW_S : 5|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ A_CLR_S : 3|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ DISP_BRT : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DISP_CNT : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ MM_CLOCK : 31|11@0+ (1,0) [0|0] "" Vector__XXX - SG_ CLK_OFST : 36|4@0- (5,0) [0|0] "min" Vector__XXX - SG_ DST : 32|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CLK_TYP : 47|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ A_UNTTMP : 45|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ A_UNTSP : 43|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ A_UNTDST : 41|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ A_UNTCSP : 55|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ A_CLRCHG : 52|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ A_TMPCHG : 51|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ A_SPCHG : 50|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ A_DSTCHG : 49|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ A_CSPCHG : 48|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ A_SPLM : 63|6@0+ (5,0) [0|0] "" Vector__XXX - SG_ A_UTSPLM : 57|2@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1043 AVN1S31: 8 CGW - SG_ GPSTM_Y : 7|8@0+ (1,0) [0|0] "year" Vector__XXX - SG_ GPSTM_MO : 15|8@0+ (1,0) [0|0] "month" Vector__XXX - SG_ GPSTM_D : 23|8@0+ (1,0) [0|0] "day" Vector__XXX - SG_ GPSTM_H : 31|8@0+ (1,0) [0|0] "hour" Vector__XXX - SG_ GPSTM_MI : 39|8@0+ (1,0) [0|0] "minute" Vector__XXX - SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ GMTDIF_H : 54|4@0+ (1,0) [0|0] "hour" Vector__XXX - SG_ GMTDIF_M : 50|6@0+ (1,0) [0|0] "minute" Vector__XXX - SG_ SUMMERTM : 60|1@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1020 BDB1S19: 8 CGW - SG_ SOLAR_R : 23|9@0+ (100,0) [0|0] "" Vector__XXX - SG_ SOLAR_L : 39|9@0+ (100,0) [0|0] "" Vector__XXX - SG_ N_LX : 55|13@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1005 BGM1S01: 2 CGW - SG_ WCAA : 7|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ R_DISP : 1|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ BGM_BEEP : 11|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ BGM_MODE : 9|2@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1237 BSR1N01: 8 BSR - SG_ BSRNID : 7|8@0+ (1,0) [0|0] "" CGW - SG_ BSRSNG : 15|1@0+ (1,0) [0|0] "" CGW - SG_ BSRSPF : 23|16@0+ (1,0) [0|0] "" CGW - SG_ BSRREV : 39|32@0+ (1,0) [0|0] "" CGW - -BO_ 1014 BSR1S01: 8 BSR - SG_ BSD_STAT : 7|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ BSD_SW : 15|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ BSD_BUZ : 23|1@0+ (1,0) [0|0] "" CSR - -BO_ 1114 CGW1N02: 8 CGW - SG_ CGW2REV : 7|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1228 CSR1N01: 8 CSR - SG_ CSRNID : 7|8@0+ (1,0) [0|0] "" CGW - SG_ CSRSNG : 15|1@0+ (1,0) [0|0] "" CGW - SG_ CSRSPF : 23|16@0+ (1,0) [0|0] "" CGW - SG_ CSRREV : 39|32@0+ (1,0) [0|0] "" CGW - -BO_ 918 CSR1S01: 7 CSR - SG_ CSV : 7|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ CSSR : 4|2@0+ (1,0) [0|0] "" MAV - SG_ CSD : 2|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CSME : 1|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CSIN : 0|1@0+ (1,0) [0|0] "" MAV - SG_ FL_INFO : 15|4@0+ (1,0) [0|0] "" MAV - SG_ FR_INFO : 11|4@0+ (1,0) [0|0] "" MAV - SG_ RB_INFO : 23|4@0+ (1,0) [0|0] "" MAV - SG_ FC_INFO : 19|4@0+ (1,0) [0|0] "" MAV - SG_ RL_INFO : 31|4@0+ (1,0) [0|0] "" MAV - SG_ RR_INFO : 27|4@0+ (1,0) [0|0] "" MAV - SG_ CZV : 39|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ VOT : 47|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ FCZD : 43|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ RCZD : 42|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ FCDD : 41|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ RCDD : 40|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ VOL : 55|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ CDG : 52|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ MUTE : 49|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ BZ_OFF : 48|1@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 869 DS11D70: 7 DS1 - SG_ D_TRGJDG : 7|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ D_RESSW : 3|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ D_SETSW : 2|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ D_CANSW : 1|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ D_MAINSW : 0|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ D_VMCC : 15|8@0+ (1,0) [0|0] "km/h" Vector__XXX - SG_ D_VNCC : 23|8@0+ (1,0) [0|0] "km/h" Vector__XXX - SG_ D_CCREQ : 31|8@0+ (100,-12800) [0|0] "N" Vector__XXX - SG_ D_TGTDST : 39|8@0+ (1,0) [0|0] "m" Vector__XXX - SG_ D_VRCC : 47|8@0- (1,0) [0|0] "km/h" Vector__XXX - SG_ D_WSTL : 55|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ D_DSW : 54|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ D_FDJDG : 52|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ D_DSSJDG : 51|1@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 870 DS11D71: 7 DS1 - SG_ XREQALM : 7|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ XREQABK : 6|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ TGT_DIST : 5|14@0+ (0.01,0) [0|0] "m" Vector__XXX - SG_ XREQPBA : 23|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ XREQFPB : 22|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ XREQPB : 21|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ XREQEXT : 20|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ XREQPSB : 19|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ TGT_VGAP : 18|11@0+ (0.025,-51.175) [0|0] "m/s" Vector__XXX - SG_ PCSDISP : 39|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ XPCSRDY : 35|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ TGT_NUMB : 34|3@0+ (1,1) [0|0] "" Vector__XXX - SG_ TGT_POSX : 47|8@0- (0.04,0) [0|0] "m" Vector__XXX - -BO_ 871 DS11D72: 2 FCM - SG_ LKADRTRG : 7|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ LKADRSHR : 5|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LKADRSLK : 4|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LKADRSLD : 3|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LKADRCC : 2|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ LKADRTUR : 15|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ LKADRINV : 13|1@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 643 DS11F01: 7 DS1 - SG_ DSCOUNT : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DSLCCW1 : 15|1@0+ (1,0) [0|0] "" FCM - SG_ DSSTPBZ : 14|1@0+ (1,0) [0|0] "" FCM - SG_ PBRTRGR2 : 12|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ DSSFTRQD : 11|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ DSS1FDRV : 23|16@0- (2,0) [0|0] "N" Vector__XXX - SG_ DSS1STBK : 39|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ DSS1STAT : 36|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ DSBHOK : 33|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PPTRGR2 : 32|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ DSRQBH : 47|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ IBTRGR2 : 45|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PCSABK2 : 44|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PCSNOCHG : 41|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ DS1F01SM : 55|8@0+ (1,0) [0|0] "" FCM - -BO_ 1041 DS12F02: 8 DS1 - SG_ PCSINDI : 7|2@0+ (1,0) [0|0] "" FCM - SG_ PCSWM : 5|2@0+ (1,0) [0|0] "" FCM - SG_ PCSFCT : 3|1@0+ (1,0) [0|0] "" FCM - SG_ PCSTUCT : 2|1@0+ (1,0) [0|0] "" FCM - SG_ DS1LCCK : 1|2@0+ (1,0) [0|0] "" FCM - SG_ PBTUCT : 14|1@0+ (1,0) [0|0] "" FCM - SG_ PCSEXIST : 13|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PCSWDUCT : 11|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PCSWD : 9|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ PCSDW : 39|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ PCSDSRF : 36|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PCSTEMP : 35|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PCSDUST : 34|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PCSLCCK : 33|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ PCSPEDW : 47|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ PCSPVSN : 44|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ PCTEMP2 : 42|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PCSDUST2 : 41|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PCSOFFS : 40|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PCSWDS : 55|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ FRDADJ : 53|3@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1042 DS12F03: 8 FCM - SG_ LKAINDI : 7|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ LKAWLSL : 5|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ LKAWLSR : 3|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ LKAFCT : 15|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LKATUCT : 14|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LKACAMT : 13|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LDWEXIST : 10|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LKASPCND : 23|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ LKAWTCS : 18|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ LKASAUT : 16|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LDWBZ : 32|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LDAFCVB : 47|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LDARDA : 46|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ SWSSENSD : 45|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ SWSSWD : 43|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ SWSRAD : 55|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ SWSFLD : 53|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ SWSBUZ : 50|2@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1207 ECO1D50: 8 CGW - SG_ DRECO01 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECO02 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECO03 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECO04 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECO05 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECO06 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECO07 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECO08 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 355 ECO1S01: 5 CGW - SG_ ECOSTAON : 19|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ ECOMODE : 18|3@0+ (1,0) [0|0] "" KSS,SCS - SG_ FCREQ : 31|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ SSVMREQ : 27|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ E2MRXMK : 26|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ BPHLDRQ : 36|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ BPHLDRQ2 : 35|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ ECOEGSTP : 33|1@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 922 ECO1S90: 8 CGW - SG_ ECOBZR : 23|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ ECOLMP : 21|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ TESTECO : 30|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ OPLMPMSK : 29|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ MSTART : 28|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ ECOMODE3 : 27|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ INFSSCOP : 39|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ INFSSSTL : 36|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ ECLMP : 34|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ AUTOSTA : 47|1@0+ (1,0) [0|0] "" SCS - SG_ INFSSFAL : 46|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ INFSSINH : 45|6@0+ (1,0) [0|0] "" Vector__XXX - SG_ SSACMODE : 52|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ INFSSADV : 50|3@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1182 ECT1D50: 8 CGW - SG_ DRECT01 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT02 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT03 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT04 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT05 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT06 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT07 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT08 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1183 ECT1D51: 8 CGW - SG_ DRECT11 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT12 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT13 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT14 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT15 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT16 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT17 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT18 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1200 ECT1D52: 8 CGW - SG_ DRECT21 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT22 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT23 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT24 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT25 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT26 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT27 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT28 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1201 ECT1D53: 8 CGW - SG_ DRECT31 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT32 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT33 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT34 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT35 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT36 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT37 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT38 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1202 ECT1D54: 8 CGW - SG_ DRECT41 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT42 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT43 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT44 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT45 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT46 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT47 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT48 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1203 ECT1D55: 8 CGW - SG_ DRECT51 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT52 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT53 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT54 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT55 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT56 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT57 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRECT58 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 464 ECT1F03: 8 CGW - SG_ NT : 7|16@0- (0.390625,0) [0|0] "rpm" Vector__XXX - SG_ ACT : 23|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ XDMET : 20|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ XNTSW : 19|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ XNMET : 18|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ XRMET : 17|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ XPMET : 16|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ SFTOUT_S : 29|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ X3MET : 26|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ X2MET : 25|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ XLOMET : 24|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ L4SW : 38|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ SNOW : 36|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ XFSFT : 35|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ SFTOUT : 34|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ HSSLWN : 55|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ HSINH : 54|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CLTMODBK : 53|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ LUOUT : 51|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LUKG : 50|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ FBCOA : 48|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ ECTF03SM : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 725 ECT1S10: 2 CGW - SG_ VTORATIO : 7|16@0+ (0.0009765625,0) [0|0] "" Vector__XXX - -BO_ 956 ECT1S92: 8 CGW - SG_ B_OILW : 7|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_OILMD : 5|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_ISNW : 1|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_RJTB : 0|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_WNDL : 15|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_LMULRJ : 14|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_P : 13|1@0+ (1,0) [0|0] "" AFS,CSR,MAV - SG_ B_R : 12|1@0+ (1,0) [0|0] "" AFS,BSR,CSR,DS1,FCM,MAV - SG_ B_N : 11|1@0+ (1,0) [0|0] "" AFS,CSR,MAV - SG_ B_ISPTM : 10|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ BV_THOCL : 23|16@0+ (0.625,-50) [0|0] "ÂŽ" Vector__XXX - SG_ B_GEAR : 39|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_SMDE : 32|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_D : 47|1@0+ (1,0) [0|0] "" AFS,CSR,DS1,MAV - SG_ B_ECOMI : 40|1@0+ (1,0) [0|0] "" DS1 - SG_ B_SPTMI : 55|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_PWRM : 54|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_OILWM : 51|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_SPTMS : 49|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_DMODE : 61|3@0+ (1,0) [0|0] "" SCS - -BO_ 1176 ENG1D50: 8 CGW - SG_ DRENG01 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG02 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG03 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG04 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG05 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG06 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG07 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG08 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1177 ENG1D51: 8 CGW - SG_ DRENG11 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG12 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG13 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG14 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG15 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG16 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG17 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG18 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1178 ENG1D52: 8 CGW - SG_ DRENG21 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG22 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG23 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG24 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG25 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG26 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG27 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG28 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1179 ENG1D53: 8 CGW - SG_ DRENG31 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG32 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG33 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG34 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG35 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG36 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG37 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG38 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1180 ENG1D54: 8 CGW - SG_ DRENG41 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG42 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG43 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG44 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG45 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG46 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG47 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG48 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1181 ENG1D55: 8 CGW - SG_ DRENG51 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG52 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG53 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG54 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG55 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG56 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG57 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG58 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1192 ENG1D56: 8 CGW - SG_ DRENG61 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG62 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG63 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG64 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG65 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG66 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG67 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG68 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1191 ENG1D57: 8 CGW - SG_ DRENG71 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG72 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG73 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG74 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG75 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG76 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG77 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG78 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1197 ENG1D58: 8 CGW - SG_ DRENG81 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG82 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG83 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG84 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG85 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG86 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG87 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG88 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1198 ENG1D59: 8 CGW - SG_ DRENG91 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG92 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG93 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG94 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG95 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG96 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG97 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG98 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1199 ENG1D60: 8 CGW - SG_ DRENG101 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG102 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG103 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG104 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG105 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG106 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG107 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRENG108 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1017 ENG1F03: 8 CGW - SG_ VARENG1 : 7|4@0+ (1,0) [0|0] "" AFS,SCS - SG_ VARENG2 : 3|4@0+ (1,0) [0|0] "" AFS,SCS - SG_ VARENG3 : 15|4@0+ (1,0) [0|0] "" AFS,SCS - SG_ VARENG4 : 11|1@0+ (1,0) [0|0] "" AFS,SCS - SG_ HVFLAG : 10|1@0+ (1,0) [0|0] "" AFS,BSR,FCM,SCS - SG_ VARTRM1 : 23|4@0+ (1,0) [0|0] "" AFS,CSR,FCM,MAV,SCS - SG_ GEARINF : 19|4@0+ (1,0) [0|0] "" SCS - SG_ DVINF : 31|2@0+ (1,0) [0|0] "" AFS,DS1,FCM,SCS - SG_ OBDINF : 27|4@0+ (1,0) [0|0] "" BSR,DS1,FCM,SCS - SG_ ECOFLAG : 39|1@0+ (1,0) [0|0] "" FCM - SG_ CDYMD : 38|2@0+ (1,0) [0|0] "" DS1,FCM - SG_ ENGF03SM : 63|8@0+ (1,0) [0|0] "" DS1,FCM,MAV - -BO_ 452 ENG1F07: 8 CGW - SG_ NE1 : 7|16@0- (0.78125,0) [0|0] "rpm" SCS - SG_ THA1 : 23|8@0+ (2.5,-40) [0|0] "ÂŽ" Vector__XXX - SG_ THWX : 31|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ EGF : 30|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ T2ERXF : 29|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ T2ERXMK : 28|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ ASTEFI : 27|1@0+ (1,0) [0|0] "" AFS - SG_ B2ERXMK : 26|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PDLF : 24|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ ENTCAL2 : 39|8@0+ (12.5,0) [0|0] "rpm" Vector__XXX - SG_ EGFB : 46|1@0+ (1,0) [0|0] "" DS1,FCM - SG_ PTFB : 45|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ MILREQ : 43|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_ECOL : 55|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_IECOCR : 53|6@0+ (2,0) [0|0] "" Vector__XXX - SG_ ENGF07SM : 63|8@0+ (1,0) [0|0] "" AFS,DS1,FCM - -BO_ 114 ENG1F43: 5 CGW - SG_ FAVLMCHL : 7|16@0- (2,0) [0|0] "N" Vector__XXX - SG_ FAVLMONL : 23|16@0- (2,0) [0|0] "N" Vector__XXX - SG_ ENGF43SM : 39|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 705 ENG1S01: 8 CGW - SG_ ETCSFB : 7|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ ETCSF : 6|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ VSCTH : 5|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ THF : 4|1@0+ (1,0) [0|0] "" DS1 - SG_ IDL1 : 3|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ XCCACT2 : 2|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ STPSWF : 1|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ WTC : 0|1@0+ (1,0) [0|0] "" KSS,SCS - SG_ ETQLVSC : 15|16@0- (0.03125,0) [0|0] "Nm" Vector__XXX - SG_ ETQREAL : 31|16@0- (0.03125,0) [0|0] "Nm" SCS - SG_ ETQISC : 47|8@0+ (1,-192) [0|0] "Nm" Vector__XXX - SG_ EACCP : 55|8@0+ (0.5,0) [0|0] "%" DS1,FCM - SG_ ENG01SUM : 63|8@0+ (1,0) [0|0] "" DS1,FCM - -BO_ 961 ENG1S23: 3 CGW - SG_ EKLSM : 7|8@0+ (0.625,0) [0|0] "%" Vector__XXX - SG_ GATHW : 15|16@0- (0.625,0) [0|0] "ÂŽ" Vector__XXX - -BO_ 979 ENG1S28: 2 CGW - SG_ B_FC : 7|16@0+ (0.0005,0) [0|0] "ml" Vector__XXX - -BO_ 1408 ENG1S51: 8 CGW - SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1409 ENG1S52: 8 CGW - SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1410 ENG1S54: 8 CGW - SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ VC : 52|5@0+ (1,0) [0|0] "" Vector__XXX - SG_ TES : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 955 ENG1S92: 8 CGW - SG_ B_ST : 7|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_TC : 6|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_GLOW : 3|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_STPE : 0|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_OMWI : 15|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_SILUP : 13|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_SILDN : 12|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_WSTP : 11|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_LOUT : 10|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_OILPL : 9|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_TMP : 23|8@0+ (0.5,0) [0|0] "ÂŽ" Vector__XXX - SG_ OGENETCS : 30|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_DPFW : 28|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ BOSLAMP : 37|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ BOSMINF : 34|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ GOSLAMP : 45|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ GOSMINF : 42|3@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 921 ENG1S95: 8 CGW - SG_ B_LLSP2 : 7|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ TLSTBZ : 6|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_ASLBZ2 : 5|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_SPU2 : 4|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ ACASID1 : 3|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ ACASID2 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_LSP2 : 31|8@0+ (1,0) [0|0] "km/hÂEmph" Vector__XXX - SG_ B_ASLSP2 : 39|8@0+ (1,0) [0|0] "km/hÂEmph" Vector__XXX - SG_ CACCTRN : 47|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CACCINF : 46|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CACCFR2 : 45|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CACCFR1 : 44|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CACCFLD : 43|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CACCCM3 : 42|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CACCCM2 : 41|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CACCCM1 : 40|1@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 238 ENG2F01: 4 CGW - SG_ STOFOK : 7|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ GROWIND : 6|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_TMP3 : 15|8@0+ (0.5,0) [0|0] "ÂŽ" Vector__XXX - SG_ IMMINJST : 23|16@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 466 ENG2F04: 8 CGW - SG_ XLDR : 7|1@0+ (1,0) [0|0] "" DS1 - SG_ XACCACTV : 6|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ XACCACT : 5|1@0+ (1,0) [0|0] "" DS1,FCM - SG_ XPAIDLV : 4|1@0+ (1,0) [0|0] "" DS1 - SG_ XPAIDL : 3|1@0+ (1,0) [0|0] "" DS1 - SG_ BHOK : 2|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ RQBH : 1|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ ACCSTAT : 15|3@0+ (1,0) [0|0] "" DS1 - SG_ ACCSTBK : 12|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ STPBZ : 9|1@0+ (1,0) [0|0] "" DS1,FCM - SG_ PLOCKF : 8|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ ACCREQ : 23|16@0- (0.0009765625,0) [0|0] "m/s^2" DS1 - SG_ ACCAVL : 39|16@0- (2,0) [0|0] "N" Vector__XXX - SG_ SPDSTAT : 55|4@0+ (1,0) [0|0] "Â|" DS1 - SG_ SSTOK : 51|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CANREQ : 49|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ FCACT : 48|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ SM1D2 : 63|8@0+ (1,0) [0|0] "" DS1,FCM - -BO_ 467 ENG2F05: 8 CGW - SG_ LCCW2 : 4|1@0+ (1,0) [0|0] "" DS1,FCM - SG_ WSTL2 : 3|1@0+ (1,0) [0|0] "" DS1 - SG_ LCCHK : 2|3@0+ (1,0) [0|0] "" DS1 - SG_ XCCOK2 : 15|1@0+ (1,0) [0|0] "" DS1 - SG_ SLTACC : 14|2@0+ (1,0) [0|0] "" DS1 - SG_ LTME2 : 12|2@0+ (1,0) [0|0] "" DS1 - SG_ STPSWF2 : 10|1@0+ (1,0) [0|0] "" DS1 - SG_ CCSF : 9|1@0+ (1,0) [0|0] "" DS1 - SG_ CCSNG : 8|1@0+ (1,0) [0|0] "" DS1 - SG_ VM : 23|16@0+ (0.00390625,0) [0|0] "km/h" DS1 - SG_ INTG : 39|8@0- (0.04,0) [0|0] "m/s^2" DS1 - SG_ D2PRXMK : 47|1@0+ (1,0) [0|0] "" DS1 - SG_ SM1D3 : 63|8@0+ (1,0) [0|0] "" DS1,FCM - -BO_ 119 ENG2F41: 6 CGW - SG_ FDRV : 7|16@0- (2,0) [0|0] "N" Vector__XXX - SG_ FDRVREAL : 23|13@0- (10,0) [0|0] "N" Vector__XXX - SG_ XAECT : 39|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ XFDRVCOL : 38|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ FDRVSELP : 34|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ ENG2F41S : 47|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 120 ENG2F42: 4 CGW - SG_ FAVLMCHH : 7|16@0- (2,0) [0|0] "N" Vector__XXX - SG_ CCRNG : 23|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ FDRVTYPD : 22|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ GEARHD : 18|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ ENG2F42S : 31|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 916 EPS1S90: 1 CGW - SG_ B_WPS0 : 1|2@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1235 FCM1N01: 8 FCM - SG_ FCMNID : 7|8@0+ (1,0) [0|0] "" CGW - SG_ FCMSNG : 15|1@0+ (1,0) [0|0] "" CGW - SG_ FCMSPF : 23|16@0+ (1,0) [0|0] "" CGW - SG_ FCMREV : 39|32@0+ (1,0) [0|0] "" CGW - -BO_ 1161 FCM1S10: 8 FCM - SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1162 FCM1S11: 8 FCM - SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1163 FCM1S12: 8 FCM - SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" Vector__XXX - SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" Vector__XXX - SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" Vector__XXX - SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1279 FRD1N01: 8 FRD - SG_ FRDNID : 7|8@0+ (1,0) [0|0] "" CGW - SG_ FRDSNG : 15|1@0+ (1,0) [0|0] "" CGW - SG_ FRDSPF : 23|16@0+ (1,0) [0|0] "" CGW - SG_ FRDREV : 39|32@0+ (1,0) [0|0] "" CGW - -BO_ 737 FWM1S01: 2 CGW - SG_ ACTHLF : 7|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ MOT4WD : 6|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CCANCEL : 5|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ AI4WD : 4|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ LOW4 : 3|1@0+ (1,0) [0|0] "" MAV,SCS - SG_ DLOCK : 2|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ RDLOCK : 1|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ HLN : 0|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ F_SP4WD : 15|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ RQ_SP4WD : 14|7@0+ (1,73) [0|0] "km/h" Vector__XXX - -BO_ 1082263092 IDT1S03_82: 8 CGW - SG_ IDT03_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ IDT03_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ CO_IDT : 23|16@0+ (1,0) [0|0] "" Vector__XXX - SG_ UACK : 39|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ WRT : 38|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ RSTP : 37|1@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1082328629 IDT1S04_83: 8 CGW - SG_ IDT04_ID : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ IDT04_IF : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ OSID : 47|16@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1257 KSS1N01: 8 KSS - SG_ KSSNID : 7|8@0+ (1,0) [0|0] "" CGW - SG_ KSSSNG : 15|1@0+ (1,0) [0|0] "" CGW - SG_ KSSSPF : 23|16@0+ (1,0) [0|0] "" CGW - SG_ KSSREV : 39|32@0+ (1,0) [0|0] "" CGW - -BO_ 927 KSS1S90: 1 KSS - SG_ LKSS0 : 1|2@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1263 MAV1N01: 8 MAV - SG_ MAVNID : 7|8@0+ (1,0) [0|0] "" CGW - SG_ MAVSNG : 15|1@0+ (1,0) [0|0] "" CGW - SG_ MAVSPF : 23|16@0+ (1,0) [0|0] "" CGW - -BO_ 992 MET1S18: 8 CGW - SG_ M_LANG : 7|6@0+ (1,0) [0|0] "" Vector__XXX - SG_ M_LNG_ST : 1|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ M_LNGDB1 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ M_LNGDB2 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ M_LNGDB3 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ M_LNGDB4 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ M_LNGDB5 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ M_LNGDB6 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ M_LNGDB7 : 63|7@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1193 SCS1D50: 8 SCS - SG_ DRSCS01 : 7|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRSCS02 : 15|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRSCS03 : 23|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRSCS04 : 31|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRSCS05 : 39|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRSCS06 : 47|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRSCS07 : 55|8@0+ (1,0) [0|0] "" Vector__XXX - SG_ DRSCS08 : 63|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1226 SCS1N01: 8 SCS - SG_ SCSNID : 7|8@0+ (1,0) [0|0] "" CGW - SG_ SCSSNG : 15|1@0+ (1,0) [0|0] "" CGW - SG_ SCSSPF : 23|16@0+ (1,0) [0|0] "" CGW - SG_ SCSREV : 39|32@0+ (1,0) [0|0] "" CGW - -BO_ 744 SCS1S01: 8 SCS - SG_ SELECTOR : 3|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ AVS_MD : 63|3@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 815 SCS1S06: 5 SCS - SG_ RRVH : 23|8@0- (1,0) [0|0] "mm" AFS - SG_ RLVH : 31|8@0- (1,0) [0|0] "mm" AFS - SG_ SCECOINH : 35|1@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 917 SCS1S90: 4 SCS - SG_ B_LSUS6 : 7|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_LSUS4 : 5|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_LSUS2 : 3|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_LSUS8 : 9|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ DLR_HSID : 23|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ LAR_HS : 18|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ AVSNI : 16|1@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 37 Steering_Angle_sensor: 8 CGW - SG_ STS3 : 7|1@0+ (1,0) [0|0] "" AFS,BSR,DS1,FCM,MAV - SG_ STS2 : 6|1@0+ (1,0) [0|0] "" AFS,DS1,FCM,KSS,MAV,SCS - SG_ STS1 : 5|1@0+ (1,0) [0|0] "" AFS,BSR,DS1,FCM,KSS,MAV,SCS - SG_ STS0 : 4|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ SSA : 3|12@0- (1.5,0) [0|0] "deg" AFS,BSR,DS1,FCM,KSS,MAV,SCS - SG_ SAZS : 23|1@0+ (1,0) [0|0] "" AFS,BSR,DS1,FCM - SG_ SFRZ : 22|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ SSAZ : 19|12@0- (1.5,0) [0|0] "deg" AFS,BSR,DS1,FCM - SG_ SSAS : 39|4@0- (0.1,0) [0|0] "deg" FCM,KSS,SCS - SG_ SSAV : 35|12@0- (1,0) [0|0] "deg/s" FCM,KSS,SCS - SG_ STDID : 51|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ STR01SUM : 63|8@0+ (1,0) [0|0] "" AFS,DS1,FCM,MAV - -BO_ 1059 STR1S02: 1 CGW - SG_ SFR : 5|1@0+ (1,0) [0|0] "" MAV - SG_ STRWVG : 4|1@0+ (1,0) [0|0] "" AFS,BSR,DS1,FCM - -BO_ 170 Wheel_speeds: 8 CGW - SG_ VXFREF : 7|1@0+ (1,0) [0|0] "" AFS,FCM,MAV - SG_ VXFR : 6|15@0+ (0.01,-67.67) [0|0] "km/h" AFS,BSR,DS1,FCM,KSS,MAV,SCS - SG_ VXFLEF : 23|1@0+ (1,0) [0|0] "" AFS,FCM,MAV - SG_ VXFL : 22|15@0+ (0.01,-67.67) [0|0] "km/h" AFS,BSR,DS1,FCM,KSS,MAV,SCS - SG_ VXRREF : 39|1@0+ (1,0) [0|0] "" AFS,FCM,MAV - SG_ VXRR : 38|15@0+ (0.01,-67.67) [0|0] "km/h" AFS,BSR,DS1,FCM,KSS,MAV,SCS - SG_ VXRLEF : 55|1@0+ (1,0) [0|0] "" AFS,FCM,MAV - SG_ VXRL : 54|15@0+ (0.01,-67.67) [0|0] "km/h" AFS,BSR,DS1,FCM,KSS,MAV,SCS - -BO_ 426 VSC1F02: 6 CGW - SG_ VXFRF : 7|1@0+ (1,0) [0|0] "" AFS,BSR,FCM,MAV - SG_ VXFRIGS : 6|1@0+ (1,0) [0|0] "" BSR,DS1,FCM,MAV - SG_ VXFRHDS : 5|1@0+ (1,0) [0|0] "" FCM,KSS,MAV,SCS - SG_ VXFLF : 2|1@0+ (1,0) [0|0] "" AFS,BSR,FCM,MAV - SG_ VXFLIGS : 1|1@0+ (1,0) [0|0] "" BSR,DS1,FCM,MAV - SG_ VXFLHDS : 0|1@0+ (1,0) [0|0] "" FCM,KSS,MAV,SCS - SG_ VXRRF : 13|1@0+ (1,0) [0|0] "" AFS,BSR,FCM,MAV - SG_ VXRRIGS : 12|1@0+ (1,0) [0|0] "" BSR,DS1,FCM,MAV - SG_ VXRRHDS : 11|1@0+ (1,0) [0|0] "" FCM,KSS,MAV,SCS - SG_ VXRLF : 8|1@0+ (1,0) [0|0] "" AFS,BSR,FCM,MAV - SG_ VXRLIGS : 23|1@0+ (1,0) [0|0] "" BSR,DS1,FCM,MAV - SG_ VXRLHDS : 22|1@0+ (1,0) [0|0] "" FCM,KSS,MAV,SCS - SG_ VSCF02SM : 47|8@0+ (1,0) [0|0] "" AFS,DS1,FCM,MAV - -BO_ 550 Brake_module: 8 CGW - SG_ VSCF01FG : 7|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ AHCURQ : 4|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PMCF : 3|1@0+ (1,0) [0|0] "" DS1 - SG_ PMCS : 2|1@0+ (1,0) [0|0] "" DS1 - SG_ PMC : 1|10@0+ (0.02,0) [0|0] "Mpa" DS1 - SG_ ECOEN : 23|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ CCS : 22|1@0+ (1,0) [0|0] "" DS1 - SG_ FBA : 21|1@0+ (1,0) [0|0] "" DS1 - SG_ TRBRKSYS : 20|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ TS : 38|1@0+ (1,0) [0|0] "" KSS,SCS - SG_ WSTP : 37|1@0+ (1,0) [0|0] "" DS1,KSS,SCS - SG_ VSCACT : 36|1@0+ (1,0) [0|0] "" DS1,FCM - SG_ BAEX : 35|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ TEM : 34|3@0+ (1,0) [0|0] "" SCS - SG_ FSTP : 60|1@0+ (1,0) [0|0] "" DS1 - SG_ ABSACT : 59|1@0+ (1,0) [0|0] "" DS1,FCM,MAV - -BO_ 180 Speed : 8 CGW - SG_ SP1P : 39|6@0+ (1,0) [0|0] "" DS1,FCM - SG_ SP1S : 33|1@0+ (1,0) [0|0] "" BSR,DS1,FCM,MAV - SG_ SP1 : 47|16@0- (0.01,0) [0|0] "km/h" BSR,DS1,FCM,MAV - SG_ VSC03SUM : 63|8@0+ (1,0) [0|0] "" DS1,FCM,MAV - -BO_ 800 VSC1S07: 8 CGW - SG_ FBKRLY : 6|1@0+ (1,0) [0|0] "" DS1 - SG_ FVSCM : 4|1@0+ (1,0) [0|0] "" DS1 - SG_ FVSCSFT : 3|1@0+ (1,0) [0|0] "" DS1 - SG_ FABS : 2|1@0+ (1,0) [0|0] "" DS1,FCM - SG_ TSVSC : 1|1@0+ (1,0) [0|0] "" DS1 - SG_ FVSCL : 0|1@0+ (1,0) [0|0] "" DS1 - SG_ RQCSTBKB : 15|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PSBSTBY : 14|1@0+ (1,0) [0|0] "" DS1 - SG_ P2BRXMK : 13|1@0+ (1,0) [0|0] "" DS1 - SG_ MCC : 11|1@0+ (1,0) [0|0] "" DS1 - SG_ RQBKB : 10|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ BRSTOP : 9|1@0+ (1,0) [0|0] "" DS1,FCM - SG_ BRKON : 8|1@0+ (1,0) [0|0] "" DS1,FCM - SG_ ASLP : 23|8@0- (1,0) [0|0] "deg" DS1 - SG_ BRTYPACC : 31|2@0+ (1,0) [0|0] "" DS1 - SG_ BRKABT3 : 26|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ BRKABT2 : 25|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ BRKABT1 : 24|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ GVC : 39|8@0- (0.04,0) [0|0] "m/s^2" DS1 - SG_ XGVCINV : 43|1@0+ (1,0) [0|0] "" DS1 - SG_ S07CNT : 52|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ PCSBRSTA : 50|2@0+ (1,0) [0|0] "" DS1 - SG_ VSC07SUM : 63|8@0+ (1,0) [0|0] "" DS1,FCM - -BO_ 1056 VSC1S08: 8 CGW - SG_ YR1Z : 7|16@0- (1,0) [0|0] "rad/s" DS1,FCM,MAV - SG_ YR2Z : 23|16@0- (1,0) [0|0] "rad/s" DS1,FCM,MAV - SG_ GL1Z : 39|8@0- (0.0359,0) [0|0] "m/s^2" DS1,FCM,KSS,MAV,SCS - SG_ GL2Z : 47|8@0- (0.0359,0) [0|0] "m/s^2" DS1,FCM,KSS,MAV,SCS - SG_ YRGSDIR : 55|1@0+ (1,0) [0|0] "" DS1,FCM,KSS,SCS - SG_ GLZS : 51|1@0+ (1,0) [0|0] "" DS1,FCM,KSS,MAV,SCS - SG_ YRZF : 50|1@0+ (1,0) [0|0] "" DS1,FCM,MAV - SG_ YRZS : 49|1@0+ (1,0) [0|0] "" DS1,FCM,MAV - SG_ YRZKS : 48|1@0+ (1,0) [0|0] "" DS1,FCM,MAV - SG_ VSC08SUM : 63|8@0+ (1,0) [0|0] "" DS1,FCM,MAV - -BO_ 186 VSC1S12: 4 CGW - SG_ HAC2ESRQ : 21|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ FHACHOLD : 20|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ VSC12SUM : 31|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 562 VSC1S14: 6 CGW - SG_ VWPSUMFR : 7|8@0+ (1,0) [0|0] "" MAV - SG_ VWPSUMFL : 15|8@0+ (1,0) [0|0] "" MAV - SG_ VWPFRPM : 23|1@0+ (1,0) [0|0] "" MAV - SG_ VWPFLPM : 22|1@0+ (1,0) [0|0] "" MAV - SG_ S14CNT : 21|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ VWPFRPMS : 18|1@0+ (1,0) [0|0] "" MAV - SG_ VWPFLPMS : 17|1@0+ (1,0) [0|0] "" MAV - SG_ VWPSUMRR : 31|8@0+ (1,0) [0|0] "" MAV - SG_ VWPSUMRL : 39|8@0+ (1,0) [0|0] "" MAV - SG_ VSC14SUM : 47|8@0+ (1,0) [0|0] "" MAV - -BO_ 552 VSC1S29: 4 CGW - SG_ ICBACT : 7|1@0+ (1,0) [0|0] "" DS1 - SG_ DVS0PCS : 6|15@0- (0.001,0) [0|0] "m/s^2" DS1 - SG_ SM228 : 31|8@0+ (1,0) [0|0] "" DS1 - -BO_ 1168 VSC1S92: 1 CGW - SG_ C_DCMOD1 : 7|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ C_DCMOD2 : 6|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ C_DCMOD3 : 3|4@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 951 VSC1S95: 8 CGW - SG_ B_BRKW : 7|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_ABS : 5|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_BRLV : 14|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ TRCOFF : 13|1@0+ (1,0) [0|0] "" DS1,FCM - SG_ VSCOFF : 12|2@0+ (1,0) [0|0] "" DS1,FCM - SG_ SLP_WL : 10|3@0+ (1,0) [0|0] "" MAV - SG_ B_MCST : 19|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_BUZZER : 31|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_ALSD : 27|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_DACIND : 25|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ OGENVSC : 37|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_ATRC : 47|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_STRC : 46|3@0+ (1,0) [0|0] "" MAV - SG_ B_HZD : 43|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ VSCSWIH : 51|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ STRCDISP : 50|3@0+ (1,0) [0|0] "" Vector__XXX - SG_ STRCDSP2 : 60|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ VSCEXIST : 59|1@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 1063 VSC1S96: 8 CGW - SG_ MTS_DISP : 5|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ B_MTS : 1|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ TRCCONRL : 11|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ TRCCONRR : 10|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ TRCCONFL : 9|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ TRCCONFR : 8|1@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 545 VSC2F05: 5 CGW - SG_ TQER : 7|16@0- (0.03125,0) [0|0] "Nm" Vector__XXX - SG_ REQC : 23|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ REQ2 : 22|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ REQ1 : 21|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ AIDWI : 20|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ RTD : 19|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ LOMUSFT : 31|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ VSC2F05S : 39|8@0+ (1,0) [0|0] "" Vector__XXX - -BO_ 544 VSC2F07: 4 CGW - SG_ FSROT : 7|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ BRK2 : 4|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ BRK1 : 3|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ FCNG : 1|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ TSLP : 0|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ TRCACT : 15|1@0+ (1,0) [0|0] "" DS1,FCM - SG_ ABSSLP : 14|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ VDMACT : 13|1@0+ (1,0) [0|0] "" FCM - SG_ DAC_CND : 9|2@0+ (1,0) [0|0] "" Vector__XXX - SG_ VSC2F07S : 31|8@0+ (1,0) [0|0] "" DS1,FCM - -BO_ 36 Kinematics: 8 CGW - SG_ YRS11S : 7|1@0+ (1,0) [0|0] "" DS1,FCM,MAV - SG_ YRS14S : 6|1@0+ (1,0) [0|0] "" DS1,FCM,MAV - SG_ YRS21S : 5|1@0+ (1,0) [0|0] "" DS1,FCM,MAV - SG_ YRS24S : 4|1@0+ (1,0) [0|0] "" DS1,FCM,MAV - SG_ YGS1 : 3|1@0+ (1,0) [0|0] "" DS1,FCM,KSS,MAV,SCS - SG_ YGS0 : 2|1@0+ (1,0) [0|0] "" Vector__XXX - SG_ YR : 1|10@0+ (0.244,-125) [0|0] "deg/sec" DS1,FCM,MAV - SG_ YR_CPUMN : 23|4@0+ (1,0) [0|0] "" Vector__XXX - SG_ GS4S : 19|1@0+ (1,0) [0|0] "" DS1,FCM,KSS,MAV,SCS - SG_ GS1S : 18|1@0+ (1,0) [0|0] "" DS1,FCM,KSS,MAV,SCS - SG_ GL1X : 17|10@0+ (0.03589,-18.375) [0|0] "m/s^2" DS1,FCM,KSS,MAV,SCS - SG_ YG_ID : 39|4@0+ (1,0) [0|0] "" DS1,FCM,KSS,SCS - SG_ GS5S : 35|1@0+ (1,0) [0|0] "" DS1,FCM,KSS,MAV,SCS - SG_ GS2S : 34|1@0+ (1,0) [0|0] "" DS1,FCM,KSS,MAV,SCS - SG_ GL2Y : 33|10@0+ (0.03589,-18.375) [0|0] "m/s^2" DS1,FCM,KSS,MAV,SCS - SG_ YR_DIF : 55|8@0+ (0.244,-31) [0|0] "deg/sec" DS1,FCM,MAV - SG_ YGS03SUM : 63|8@0+ (1,0) [0|0] "" DS1,FCM,MAV - diff --git a/opendbc/toyota_avalon_2017_pt_generated.dbc b/opendbc/toyota_avalon_2017_pt_generated.dbc index 7749d9610e3c89..fb6a569d4bc539 100644 --- a/opendbc/toyota_avalon_2017_pt_generated.dbc +++ b/opendbc/toyota_avalon_2017_pt_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +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 @@ -9,10 +9,10 @@ BO_ 359 STEERING_IPAS_COMMA: 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 -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"; +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 @@ -30,8 +30,13 @@ CM BO_ STEERING_IPAS_COMMA "Copy of msg 614 so we can do angle control while the VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; +BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX + SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX + +CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; -CM_ "Imported file _toyota_2017.dbc starts here" + +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -70,8 +75,8 @@ BS_: BU_: XXX DSU HCU EPS IPAS CGW 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_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX + SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX @@ -91,12 +96,15 @@ BO_ 170 WHEEL_SPEEDS: 8 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 + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 353 DSU_SPEED: 8 XXX +BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX +BO_ 452 ENGINE_RPM: 8 CGW + SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS + 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 @@ -159,10 +167,11 @@ BO_ 835 ACC_CONTROL: 8 DSU 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_ PERMIT_BRAKING : 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 + SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX @@ -184,6 +193,7 @@ BO_ 921 PCM_CRUISE_SM: 8 XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX + SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1041 ACC_HUD: 8 DSU @@ -208,6 +218,17 @@ BO_ 1042 LKAS_HUD: 8 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_ 1043 TIME : 8 CGW + SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX + SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX + SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX + SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX + SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX + SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX + SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX + SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX + SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX + BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX @@ -231,7 +252,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX @@ -295,7 +316,7 @@ 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 SET_SPEED "43 kph are shown as 28mph, so conversion isn't 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"; @@ -304,13 +325,15 @@ CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; +CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; +CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; 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_ 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"; @@ -344,7 +367,7 @@ 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_ "toyota_avalon_2017_pt.dbc starts here" +CM_ "toyota_avalon_2017_pt.dbc starts here"; @@ -362,6 +385,7 @@ BO_ 608 STEER_TORQUE_SENSOR: 8 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 + SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX diff --git a/opendbc/toyota_camry_hybrid_2018_pt_generated.dbc b/opendbc/toyota_camry_hybrid_2018_pt_generated.dbc index e2561f18c44ea8..72f3d8bded5cfb 100644 --- a/opendbc/toyota_camry_hybrid_2018_pt_generated.dbc +++ b/opendbc/toyota_camry_hybrid_2018_pt_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +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 @@ -9,10 +9,10 @@ BO_ 359 STEERING_IPAS_COMMA: 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 -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"; +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 @@ -30,8 +30,13 @@ CM BO_ STEERING_IPAS_COMMA "Copy of msg 614 so we can do angle control while the VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; +BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX + SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX + +CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; -CM_ "Imported file _toyota_2017.dbc starts here" + +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -70,8 +75,8 @@ BS_: BU_: XXX DSU HCU EPS IPAS CGW 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_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX + SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX @@ -91,12 +96,15 @@ BO_ 170 WHEEL_SPEEDS: 8 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 + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 353 DSU_SPEED: 8 XXX +BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX +BO_ 452 ENGINE_RPM: 8 CGW + SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS + 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 @@ -159,10 +167,11 @@ BO_ 835 ACC_CONTROL: 8 DSU 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_ PERMIT_BRAKING : 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 + SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX @@ -184,6 +193,7 @@ BO_ 921 PCM_CRUISE_SM: 8 XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX + SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1041 ACC_HUD: 8 DSU @@ -208,6 +218,17 @@ BO_ 1042 LKAS_HUD: 8 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_ 1043 TIME : 8 CGW + SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX + SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX + SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX + SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX + SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX + SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX + SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX + SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX + SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX + BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX @@ -231,7 +252,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX @@ -295,7 +316,7 @@ 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 SET_SPEED "43 kph are shown as 28mph, so conversion isn't 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"; @@ -304,13 +325,15 @@ CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; +CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; +CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; 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_ 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"; @@ -344,7 +367,7 @@ 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_ "toyota_camry_hybrid_2018_pt.dbc starts here" +CM_ "toyota_camry_hybrid_2018_pt.dbc starts here"; @@ -367,7 +390,7 @@ BO_ 608 STEER_TORQUE_SENSOR: 8 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 - SG_ STEER_ANGLE : 31|16@0- (0.05527,0) [-500|500] "" XXX + SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 8 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX diff --git a/opendbc/toyota_corolla_2017_pt_generated.dbc b/opendbc/toyota_corolla_2017_pt_generated.dbc index e0a405dea9f926..d76e3cd71b4b42 100644 --- a/opendbc/toyota_corolla_2017_pt_generated.dbc +++ b/opendbc/toyota_corolla_2017_pt_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +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 @@ -9,10 +9,10 @@ BO_ 359 STEERING_IPAS_COMMA: 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 -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"; +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 @@ -30,8 +30,13 @@ CM BO_ STEERING_IPAS_COMMA "Copy of msg 614 so we can do angle control while the VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; +BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX + SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX + +CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; -CM_ "Imported file _toyota_2017.dbc starts here" + +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -70,8 +75,8 @@ BS_: BU_: XXX DSU HCU EPS IPAS CGW 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_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX + SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX @@ -91,12 +96,15 @@ BO_ 170 WHEEL_SPEEDS: 8 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 + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 353 DSU_SPEED: 8 XXX +BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX +BO_ 452 ENGINE_RPM: 8 CGW + SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS + 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 @@ -159,10 +167,11 @@ BO_ 835 ACC_CONTROL: 8 DSU 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_ PERMIT_BRAKING : 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 + SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX @@ -184,6 +193,7 @@ BO_ 921 PCM_CRUISE_SM: 8 XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX + SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1041 ACC_HUD: 8 DSU @@ -208,6 +218,17 @@ BO_ 1042 LKAS_HUD: 8 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_ 1043 TIME : 8 CGW + SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX + SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX + SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX + SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX + SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX + SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX + SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX + SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX + SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX + BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX @@ -231,7 +252,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX @@ -295,7 +316,7 @@ 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 SET_SPEED "43 kph are shown as 28mph, so conversion isn't 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"; @@ -304,13 +325,15 @@ CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; +CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; +CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; 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_ 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"; @@ -344,7 +367,7 @@ 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_ "toyota_corolla_2017_pt.dbc starts here" +CM_ "toyota_corolla_2017_pt.dbc starts here"; @@ -357,10 +380,11 @@ BO_ 705 GAS_PEDAL: 8 XXX SG_ GAS_PEDAL : 55|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX - SG_ STEER_TORQUE_EPS : 47|16@0- (1.0,0) [-20000|20000] "" XXX + SG_ STEER_TORQUE_EPS : 47|16@0- (0.88,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 + SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX diff --git a/opendbc/toyota_highlander_2017_pt_generated.dbc b/opendbc/toyota_highlander_2017_pt_generated.dbc index f5063df3fca89b..b81779fe784eb8 100644 --- a/opendbc/toyota_highlander_2017_pt_generated.dbc +++ b/opendbc/toyota_highlander_2017_pt_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +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 @@ -9,10 +9,10 @@ BO_ 359 STEERING_IPAS_COMMA: 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 -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"; +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 @@ -30,8 +30,13 @@ CM BO_ STEERING_IPAS_COMMA "Copy of msg 614 so we can do angle control while the VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; +BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX + SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX + +CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; -CM_ "Imported file _toyota_2017.dbc starts here" + +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -70,8 +75,8 @@ BS_: BU_: XXX DSU HCU EPS IPAS CGW 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_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX + SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX @@ -91,12 +96,15 @@ BO_ 170 WHEEL_SPEEDS: 8 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 + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 353 DSU_SPEED: 8 XXX +BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX +BO_ 452 ENGINE_RPM: 8 CGW + SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS + 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 @@ -159,10 +167,11 @@ BO_ 835 ACC_CONTROL: 8 DSU 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_ PERMIT_BRAKING : 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 + SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX @@ -184,6 +193,7 @@ BO_ 921 PCM_CRUISE_SM: 8 XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX + SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1041 ACC_HUD: 8 DSU @@ -208,6 +218,17 @@ BO_ 1042 LKAS_HUD: 8 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_ 1043 TIME : 8 CGW + SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX + SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX + SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX + SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX + SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX + SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX + SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX + SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX + SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX + BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX @@ -231,7 +252,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX @@ -295,7 +316,7 @@ 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 SET_SPEED "43 kph are shown as 28mph, so conversion isn't 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"; @@ -304,13 +325,15 @@ CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; +CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; +CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; 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_ 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"; @@ -344,7 +367,7 @@ 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_ "toyota_highlander_2017_pt.dbc starts here" +CM_ "toyota_highlander_2017_pt.dbc starts here"; @@ -362,6 +385,7 @@ BO_ 608 STEER_TORQUE_SENSOR: 8 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 + SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX diff --git a/opendbc/toyota_highlander_hybrid_2018_pt_generated.dbc b/opendbc/toyota_highlander_hybrid_2018_pt_generated.dbc index 193735a0ff3f79..6e22e0e2260b87 100644 --- a/opendbc/toyota_highlander_hybrid_2018_pt_generated.dbc +++ b/opendbc/toyota_highlander_hybrid_2018_pt_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +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 @@ -9,10 +9,10 @@ BO_ 359 STEERING_IPAS_COMMA: 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 -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"; +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 @@ -30,8 +30,13 @@ CM BO_ STEERING_IPAS_COMMA "Copy of msg 614 so we can do angle control while the VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; +BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX + SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX + +CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; -CM_ "Imported file _toyota_2017.dbc starts here" + +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -70,8 +75,8 @@ BS_: BU_: XXX DSU HCU EPS IPAS CGW 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_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX + SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX @@ -91,12 +96,15 @@ BO_ 170 WHEEL_SPEEDS: 8 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 + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 353 DSU_SPEED: 8 XXX +BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX +BO_ 452 ENGINE_RPM: 8 CGW + SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS + 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 @@ -159,10 +167,11 @@ BO_ 835 ACC_CONTROL: 8 DSU 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_ PERMIT_BRAKING : 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 + SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX @@ -184,6 +193,7 @@ BO_ 921 PCM_CRUISE_SM: 8 XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX + SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1041 ACC_HUD: 8 DSU @@ -208,6 +218,17 @@ BO_ 1042 LKAS_HUD: 8 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_ 1043 TIME : 8 CGW + SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX + SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX + SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX + SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX + SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX + SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX + SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX + SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX + SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX + BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX @@ -231,7 +252,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX @@ -295,7 +316,7 @@ 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 SET_SPEED "43 kph are shown as 28mph, so conversion isn't 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"; @@ -304,13 +325,15 @@ CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; +CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; +CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; 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_ 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"; @@ -344,7 +367,7 @@ 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_ "toyota_highlander_hybrid_2018_pt.dbc starts here" +CM_ "toyota_highlander_hybrid_2018_pt.dbc starts here"; @@ -361,6 +384,7 @@ BO_ 608 STEER_TORQUE_SENSOR: 8 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 + SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX diff --git a/opendbc/toyota_iQ_2009_can.dbc b/opendbc/toyota_iQ_2009_can.dbc deleted file mode 100644 index 90f91d7cb283b5..00000000000000 --- a/opendbc/toyota_iQ_2009_can.dbc +++ /dev/null @@ -1,197 +0,0 @@ -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_ 1552 CONTAINS_LRES_SPEED: 8 XXX - SG_ SPEED_LOWRES : 16|8@1+ (1,0) [0|255] "km/h?" XXX - SG_ NEW_SIGNAL_1 : 7|8@0+ (1,0) [0|255] "" XXX - -BO_ 452 ENGINE: 8 XXX - SG_ ENGINE_RPM : 7|16@0+ (1,0) [0|65535] "rpm" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - SG_ DIFFERENT_EACH_RIDE : 23|8@0+ (1,0) [0|255] "" XXX - SG_ A_DECREASING_VALUE : 39|8@0+ (1,0) [0|255] "" XXX - -BO_ 37 STEERING: 8 XXX - SG_ STEER_DIRECTION : 3|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_1 : 39|8@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_4 : 42|2@0- (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_2 : 44|2@0- (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 46|2@0- (1,0) [0|3] "" XXX - SG_ STEER_ANGLE : 2|11@0- (1,0) [-350|350] "" XXX - -BO_ 36 ACCELERATIONS: 8 XXX - SG_ ACC_LAT_CLEAN : 2|11@0- (1,0) [0|255] "" XXX - SG_ ACC_LATERAL : 63|8@0- (1,0) [0|255] "" XXX - SG_ ACC_FRONT_BACK_1 : 31|8@0- (1,0) [0|255] "" XXX - SG_ ACC_FRONT_BACK_2 : 47|8@0- (1,0) [0|255] "" XXX - -BO_ 947 LOW_RES_INDICATORS: 8 XXX - SG_ LOW_RES_ACC_PEDAL : 23|7@0+ (1,0) [0|63] "" XXX - SG_ LOW_RES_RPM : 7|16@0+ (1,0) [0|255] "rpm" XXX - -BO_ 955 BRAKING_PLUS_OTHER: 8 XXX - SG_ IS_BRAKING_2 : 0|1@0+ (1,0) [0|1] "" XXX - SG_ ENGINE_TEMPERATURE : 23|8@0+ (1,0) [0|255] "" XXX - SG_ MAYBE_CLUTCH : 13|1@0+ (1,0) [0|1] "" XXX - -BO_ 1595 CONTAINS_TIME: 8 XXX - SG_ TIME_ON : 55|16@0+ (0.1,0) [0|65535] "s" XXX - SG_ BETWEEN_RIDES : 7|32@0+ (1,0) [0|4294967295] "" XXX - -BO_ 170 WHEELS_SPEEDS: 8 XXX - SG_ FRONT_LEFT_WHEEL_SPEED : 23|16@0+ (0.01,-67.67) [0|65535] "km/h" XXX - SG_ REAR_RIGHT_WHEEL_SPEED : 39|16@0+ (0.01,-67.67) [0|65535] "km/h" XXX - SG_ REAR_LEFT_WHEEL_SPEED : 55|16@0+ (0.01,-67.67) [0|65535] "km/h" XXX - SG_ FRONT_RIGHT_WHEEL_SPEED : 7|16@0+ (0.01,-67.67) [0|65535] "km/h" XXX - -BO_ 180 VEHICLE_DYNAMICS: 8 XXX - SG_ WIERD_STUFF : 8|2@1+ (1,0) [0|3] "" XXX - SG_ VEHICLE_SPEED : 47|16@0+ (0.01,0) [0|255] "km/h" XXX - SG_ SPEED_MOD_256 : 63|8@0- (1,0) [0|255] "" XXX - SG_ MAYBE_DISTANCE_MOD_256 : 39|8@0+ (1,0) [0|255] "" XXX - -BO_ 186 NEW_MSG_9: 8 XXX - SG_ NEW_SIGNAL_2 : 31|8@0+ (1,0) [0|255] "" XXX - -BO_ 426 NEW_MSG_5: 8 XXX - SG_ CONSTANT : 47|8@0+ (1,0) [0|255] "" XXX - -BO_ 906 BOOLS: 8 XXX - SG_ MAY_CONTAIN_LIGHTS : 7|4@0+ (1,0) [0|127] "" XXX - SG_ NEW_SIGNAL_1 : 3|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_2 : 2|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_3 : 1|1@0+ (1,0) [0|1] "" XXX - SG_ MOVEMENT_START_TRIGGER : 0|1@0+ (1,0) [0|1] "" XXX - -BO_ 979 LOW_RES_ACCELERATOR: 8 XXX - SG_ VERY_LRES_ACC : 7|16@0+ (1,0) [0|65535] "" XXX - -BO_ 1600 SLOW_VARIABLE_INFOS: 8 XXX - SG_ CHANGES_EACH_RIDE : 31|8@0+ (1,0) [0|255] "" XXX - SG_ INCREASING_VALUE_FUEL : 47|8@0+ (1,0) [0|255] "" XXX - -BO_ 1568 DOORS: 8 XXX - SG_ KEY_ACC : 36|1@0+ (1,0) [0|1] "" XXX - SG_ KEY_ON : 37|1@0+ (1,0) [0|1] "" XXX - SG_ KEY_INSERT : 46|1@0+ (1,0) [0|1] "" XXX - SG_ NOT_ON : 63|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_RIGHT : 44|1@0+ (1,0) [0|3] "" XXX - SG_ DOOR_TRUNK : 41|1@1+ (1,0) [0|3] "" XXX - SG_ DOOR_LEFT : 45|1@0+ (1,0) [0|255] "" XXX - SG_ HANDBRAKE : 60|1@0+ (1,0) [0|3] "" XXX - SG_ NEW_SIGNAL_1 : 4|1@0+ (1,0) [0|1] "" XXX - SG_ DRIVER_SEATBELT : 62|1@0+ (1,0) [0|1] "" XXX - SG_ TRIGGER_BOOL : 15|1@0+ (1,0) [0|1] "" XXX - -BO_ 705 COMMAND: 8 XXX - SG_ NOT_ACCELERATING_PEDAL : 3|1@1+ (1,0) [0|1] "" XXX - SG_ ACC_PEDAL_SENSOR : 55|16@0+ (1,0) [0|65535] "" XXX - SG_ ACC_COMMAND : 31|16@0- (1,0) [0|7] "" XXX - SG_ ACC_PEDAL_MEAN : 15|16@0- (1,0) [0|255] "" XXX - SG_ NEGATIVE_COMMAND_OFFSET : 47|8@0- (1,0) [0|255] "" XXX - -BO_ 928 STEER2_MAYBE: 8 XXX - SG_ NEW_SIGNAL_1 : 13|6@0+ (1,0) [0|63] "" XXX - SG_ NEW_SIGNAL_2 : 60|5@0+ (1,0) [0|31] "" XXX - SG_ NEW_SIGNAL_4 : 5|6@0+ (1,0) [0|255] "" XXX - SG_ NEW_SIGNAL_3 : 46|7@0+ (1,0) [0|15] "" XXX - -BO_ 896 LONG_TERM_2: 8 XXX - SG_ NEW_SIGNAL_1 : 55|8@0+ (1,0) [0|255] "" XXX - -BO_ 944 LONG_TERM_MSG: 8 XXX - SG_ LONG_TERM_SIGN : 31|8@0+ (1,0) [0|255] "" XXX - -BO_ 1553 TOTAL_DIST: 8 XXX - SG_ TOTAL_DISTANCE : 55|16@0+ (1,0) [0|65535] "" XXX - -BO_ 1572 WHY_THESE_VALUES: 8 XXX - -BO_ 1555 BETWEEN_RIDES_CHANGE_1: 8 XXX - SG_ BETWEEN_RIDES : 23|1@0+ (1,0) [0|1] "" XXX - -BO_ 1090 ASYNC_MSG_ACK: 8 XXX - SG_ NEW_SIGNAL_1 : 13|2@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_2 : 23|1@0+ (1,0) [0|1] "" XXX - -BO_ 1592 NEW_MSG_14: 8 XXX - SG_ DOORS_LOCKED2 : 20|1@0+ (1,0) [0|1] "" XXX - SG_ DOORS_LOCKED1 : 16|1@0+ (1,0) [0|1] "" XXX - -BO_ 608 NEW_MSG_6: 8 XXX - SG_ VERY_SMALL_SIGNAL2 : 56|1@0+ (1,0) [0|255] "" XXX - SG_ VERY_SMALL_SIGNAL1 : 0|1@0+ (1,0) [0|1] "" XXX - -BO_ 945 BETWEEN_RIDES_CHANGES_2: 8 XXX - SG_ BETWEEN_RIDES : 24|1@0+ (1,0) [0|65535] "" XXX - - - - -CM_ SG_ 1552 SPEED_LOWRES "Negative values to check"; -CM_ SG_ 452 CHECKSUM "Follows path of RPMs but more precise & 1 byte only"; -CM_ SG_ 452 A_DECREASING_VALUE "stabilizes to 62 after ~10 mins"; -CM_ SG_ 37 STEER_DIRECTION "Could be intended as 12 bit steering angle"; -CM_ SG_ 37 STEER_ANGLE "can convert to degrees (imprecise) or percentage of max amplitude"; -CM_ SG_ 36 ACC_FRONT_BACK_1 "more likely up-down"; -CM_ SG_ 36 ACC_FRONT_BACK_2 "more likely front-back"; -CM_ SG_ 947 LOW_RES_ACC_PEDAL "Follows rather closely other acceleration commands"; -CM_ SG_ 947 LOW_RES_RPM "Mabe used for onboard display?"; -CM_ SG_ 955 MAYBE_CLUTCH "might be related to shifting gears"; -CM_ SG_ 1595 TIME_ON "Time since last ignition, tenth of seconds"; -CM_ SG_ 1595 BETWEEN_RIDES "the fourth byte (at least) changes between rides"; -CM_ SG_ 180 WIERD_STUFF "Might be a signed value on the whole two bytes (sometimes all set)"; -CM_ SG_ 180 VEHICLE_SPEED "Roughly 2 seconds before wheel speeds"; -CM_ SG_ 180 SPEED_MOD_256 "One byte speed, a bit before vehicle speed"; -CM_ SG_ 180 MAYBE_DISTANCE_MOD_256 "Looks like measure for distance or wheel angle"; -CM_ SG_ 906 MOVEMENT_START_TRIGGER "trigger of when speed becomes != 0"; -CM_ SG_ 979 VERY_LRES_ACC "Power used by engine? moves alongside speed, very low res, goes from 0 to 9 max?"; -CM_ SG_ 1600 CHANGES_EACH_RIDE "Small decrementation during some rides, possibly long term fuel"; -CM_ SG_ 1600 INCREASING_VALUE_FUEL "Fuel/distance? Average fuel consumption?"; -CM_ SG_ 705 NOT_ACCELERATING_PEDAL "Looks like opposite of accelerating bit"; -CM_ SG_ 705 ACC_PEDAL_SENSOR "similar to pedal sensor maybe checksum."; -CM_ SG_ 705 ACC_COMMAND "Similar to other pedal indicator., cleaner, must be sent back to engine"; -CM_ SG_ 705 ACC_PEDAL_MEAN "Actual sensor for pedal (works when engine off)"; -CM_ SG_ 705 NEGATIVE_COMMAND_OFFSET "Mysterious for now"; -CM_ SG_ 928 NEW_SIGNAL_1 "Very slow changing noisy value, 45-49 in 10 min"; -CM_ SG_ 928 NEW_SIGNAL_2 "Other very slow changing 24-26 in 10 min"; -CM_ SG_ 928 NEW_SIGNAL_4 "Inconsistent across rides"; -CM_ SG_ 896 NEW_SIGNAL_1 "there is a difference at the beginning of 2017-10-31--12-04-05"; -CM_ SG_ 1553 TOTAL_DISTANCE "Probably also contains the previous/two previous bytes but can't confirm"; -CM_ SG_ 945 BETWEEN_RIDES "Might be others in the same message. at least this one"; - -CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 452 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 955 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; diff --git a/opendbc/toyota_nodsu_hybrid_pt_generated.dbc b/opendbc/toyota_nodsu_hybrid_pt_generated.dbc index 14193330a17006..6d77072b01848e 100644 --- a/opendbc/toyota_nodsu_hybrid_pt_generated.dbc +++ b/opendbc/toyota_nodsu_hybrid_pt_generated.dbc @@ -1,7 +1,24 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +CM_ "Imported file _toyota_nodsu_bsm.dbc starts here"; +BO_ 1014 BSM: 8 XXX + SG_ L_ADJACENT : 0|1@0+ (1,0) [0|1] "" XXX + SG_ L_APPROACHING : 8|1@0+ (1,0) [0|1] "" XXX + SG_ R_ADJACENT : 1|1@0+ (1,0) [0|1] "" XXX + SG_ R_APPROACHING : 10|1@0+ (1,0) [0|1] "" XXX + SG_ ADJACENT_ENABLED : 7|1@0+ (1,0) [0|1] "" XXX + SG_ APPROACHING_ENABLED : 15|1@0+ (1,0) [0|1] "" XXX + +CM_ SG_ 1014 L_ADJACENT "vehicle adjacent left side of car. enabled above 10mph, regardless of ADJACENT_ENABLED or APPROACHING_ENABLED"; +CM_ SG_ 1014 L_APPROACHING "vehicle approaching from left side of car. enabled above 10mph, regardless of ADJACENT_ENABLED or APPROACHING_ENABLED"; +CM_ SG_ 1014 R_ADJACENT "vehicle adjacent right side of car. enabled above 10mph, regardless of ADJACENT_ENABLED or APPROACHING_ENABLED"; +CM_ SG_ 1014 R_APPROACHING "vehicle approaching from right side of car. enabled above 10mph, regardless of ADJACENT_ENABLED or APPROACHING_ENABLED"; +CM_ SG_ 1014 ADJACENT_ENABLED "when BSM is enabled in settings, this is on along with APPROACHING_ENABLED. this controls bsm alert visibility"; +CM_ SG_ 1014 APPROACHING_ENABLED "when BSM is enabled in settings, this is on along with ADJACENT_ENABLED. this controls bsm alert visibility"; + + +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 @@ -9,10 +26,10 @@ BO_ 359 STEERING_IPAS_COMMA: 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 -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"; +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 @@ -30,8 +47,13 @@ CM BO_ STEERING_IPAS_COMMA "Copy of msg 614 so we can do angle control while the VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; +BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX + SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX + +CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; + -CM_ "Imported file _toyota_2017.dbc starts here" +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -70,8 +92,8 @@ BS_: BU_: XXX DSU HCU EPS IPAS CGW 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_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX + SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX @@ -91,12 +113,15 @@ BO_ 170 WHEEL_SPEEDS: 8 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 + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 353 DSU_SPEED: 8 XXX +BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX +BO_ 452 ENGINE_RPM: 8 CGW + SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS + 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 @@ -159,10 +184,11 @@ BO_ 835 ACC_CONTROL: 8 DSU 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_ PERMIT_BRAKING : 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 + SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX @@ -184,6 +210,7 @@ BO_ 921 PCM_CRUISE_SM: 8 XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX + SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1041 ACC_HUD: 8 DSU @@ -208,6 +235,17 @@ BO_ 1042 LKAS_HUD: 8 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_ 1043 TIME : 8 CGW + SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX + SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX + SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX + SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX + SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX + SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX + SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX + SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX + SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX + BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX @@ -231,7 +269,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX @@ -295,7 +333,7 @@ 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 SET_SPEED "43 kph are shown as 28mph, so conversion isn't 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"; @@ -304,13 +342,15 @@ CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; +CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; +CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; 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_ 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"; @@ -344,7 +384,8 @@ 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_ "toyota_nodsu_hybrid_pt.dbc starts here" +CM_ "toyota_nodsu_hybrid_pt.dbc starts here"; + @@ -367,7 +408,7 @@ BO_ 608 STEER_TORQUE_SENSOR: 8 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 - SG_ STEER_ANGLE : 31|16@0- (0.056,0) [-500|500] "" XXX + SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 8 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX diff --git a/opendbc/toyota_nodsu_pt_generated.dbc b/opendbc/toyota_nodsu_pt_generated.dbc index 8d304954baf626..068766894ba8d0 100644 --- a/opendbc/toyota_nodsu_pt_generated.dbc +++ b/opendbc/toyota_nodsu_pt_generated.dbc @@ -1,7 +1,24 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +CM_ "Imported file _toyota_nodsu_bsm.dbc starts here"; +BO_ 1014 BSM: 8 XXX + SG_ L_ADJACENT : 0|1@0+ (1,0) [0|1] "" XXX + SG_ L_APPROACHING : 8|1@0+ (1,0) [0|1] "" XXX + SG_ R_ADJACENT : 1|1@0+ (1,0) [0|1] "" XXX + SG_ R_APPROACHING : 10|1@0+ (1,0) [0|1] "" XXX + SG_ ADJACENT_ENABLED : 7|1@0+ (1,0) [0|1] "" XXX + SG_ APPROACHING_ENABLED : 15|1@0+ (1,0) [0|1] "" XXX + +CM_ SG_ 1014 L_ADJACENT "vehicle adjacent left side of car. enabled above 10mph, regardless of ADJACENT_ENABLED or APPROACHING_ENABLED"; +CM_ SG_ 1014 L_APPROACHING "vehicle approaching from left side of car. enabled above 10mph, regardless of ADJACENT_ENABLED or APPROACHING_ENABLED"; +CM_ SG_ 1014 R_ADJACENT "vehicle adjacent right side of car. enabled above 10mph, regardless of ADJACENT_ENABLED or APPROACHING_ENABLED"; +CM_ SG_ 1014 R_APPROACHING "vehicle approaching from right side of car. enabled above 10mph, regardless of ADJACENT_ENABLED or APPROACHING_ENABLED"; +CM_ SG_ 1014 ADJACENT_ENABLED "when BSM is enabled in settings, this is on along with APPROACHING_ENABLED. this controls bsm alert visibility"; +CM_ SG_ 1014 APPROACHING_ENABLED "when BSM is enabled in settings, this is on along with ADJACENT_ENABLED. this controls bsm alert visibility"; + + +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 @@ -9,10 +26,10 @@ BO_ 359 STEERING_IPAS_COMMA: 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 -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"; +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 @@ -30,8 +47,13 @@ CM BO_ STEERING_IPAS_COMMA "Copy of msg 614 so we can do angle control while the VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; +BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX + SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX + +CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; + -CM_ "Imported file _toyota_2017.dbc starts here" +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -70,8 +92,8 @@ BS_: BU_: XXX DSU HCU EPS IPAS CGW 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_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX + SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX @@ -91,12 +113,15 @@ BO_ 170 WHEEL_SPEEDS: 8 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 + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 353 DSU_SPEED: 8 XXX +BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX +BO_ 452 ENGINE_RPM: 8 CGW + SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS + 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 @@ -159,10 +184,11 @@ BO_ 835 ACC_CONTROL: 8 DSU 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_ PERMIT_BRAKING : 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 + SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX @@ -184,6 +210,7 @@ BO_ 921 PCM_CRUISE_SM: 8 XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX + SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1041 ACC_HUD: 8 DSU @@ -208,6 +235,17 @@ BO_ 1042 LKAS_HUD: 8 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_ 1043 TIME : 8 CGW + SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX + SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX + SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX + SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX + SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX + SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX + SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX + SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX + SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX + BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX @@ -231,7 +269,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX @@ -295,7 +333,7 @@ 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 SET_SPEED "43 kph are shown as 28mph, so conversion isn't 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"; @@ -304,13 +342,15 @@ CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; +CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; +CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; 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_ 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"; @@ -344,20 +384,23 @@ 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_ "toyota_nodsu_pt.dbc starts here" +CM_ "toyota_nodsu_pt.dbc starts here"; + BO_ 401 STEERING_LTA: 8 XXX - SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ SETME_X3 : 29|2@0+ (1,0) [0|3] "" XXX SG_ PERCENTAGE : 39|8@0+ (1,0) [0|255] "" XXX SG_ SETME_X64 : 47|8@0+ (1,0) [0|255] "" XXX SG_ ANGLE : 55|8@0- (0.5,0) [0|255] "" XXX - SG_ STEER_ANGLE_CMD : 15|16@0- (0.056,0) [-540|540] "" XXX + SG_ STEER_ANGLE_CMD : 15|16@0- (0.0573,0) [-540|540] "" XXX SG_ STEER_REQUEST : 25|1@0+ (1,0) [0|1] "" XXX SG_ BIT : 30|1@0+ (1,0) [0|1] "" XXX + SG_ COUNTER : 6|6@0+ (1,0) [0|255] "" XXX + SG_ STEER_REQUEST_2 : 0|1@0+ (1,0) [0|1] "" XXX + SG_ SETME_X1 : 7|1@0+ (1,0) [0|1] "" XXX BO_ 550 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|511] "" XXX @@ -373,7 +416,7 @@ BO_ 608 STEER_TORQUE_SENSOR: 8 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 - SG_ STEER_ANGLE : 31|16@0- (0.056,0) [-500|500] "" XXX + SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 8 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX diff --git a/opendbc/toyota_prius_2010_pt.dbc b/opendbc/toyota_prius_2010_pt.dbc deleted file mode 100644 index 634b1dc0bf0b80..00000000000000 --- a/opendbc/toyota_prius_2010_pt.dbc +++ /dev/null @@ -1,203 +0,0 @@ -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_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX - SG_ YAW_RATE : 1|10@0+ (1,-512) [0|65535] "" 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.0062,-67.67) [0|250] "mph" XXX - SG_ WHEEL_SPEED_FL : 23|16@0+ (0.0062,-67.67) [0|250] "mph" XXX - SG_ WHEEL_SPEED_RR : 39|16@0+ (0.0062,-67.67) [0|250] "mph" XXX - SG_ WHEEL_SPEED_RL : 55|16@0+ (0.0062,-67.67) [0|250] "mph" XXX - -BO_ 180 SPEED: 8 XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - SG_ SPEED : 47|16@0+ (0.0062,0) [0|115] "mph" XXX - SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX - -BO_ 295 GEAR_PACKET: 8 XXX - SG_ CAR_MOVEMENT : 39|8@0- (1,0) [0|255] "" XXX - SG_ COUNTER : 55|8@0+ (1,0) [0|255] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - SG_ GEAR : 47|4@0+ (1,0) [0|15] "" XXX - -BO_ 466 PCM_CRUISE: 8 XXX - SG_ GAS_RELEASED : 4|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_ 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_ 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: 8 XXX - SG_ BRAKE_LIGHTS : 26|1@0+ (1,0) [0|1] "" XXX - -BO_ 581 GAS_PEDAL: 8 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.66,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_ STATE : 3|4@0+ (1,0) [0|15] "" XXX - SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX - SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX - -BO_ 614 STEERING_IPAS: 8 IPAS - SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX - SG_ ANGLE : 3|12@0- (1,0) [0|16777215] "" XXX - SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_X00 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 643 PRE_COLLISION: 8 XXX - -BO_ 740 STEERING_LKA: 8 XXX - SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX - SG_ CHECKSUM : 39|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 - -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 - -BO_ 1556 STEERING_LEVERS: 8 XXX - SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" 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_ 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_ 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_ 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 - -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_1 : 7|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 - -BO_ 1553 UI_SEETING: 8 XXX - SG_ UNITS : 26|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_ 452 POWERTRAIN: 8 XXX - SG_ ENGINE_RPM : 7|16@0+ (1,0) [0|65535] "rpm" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - - - - -CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; -CM_ SG_ 36 ACCEL_Y "unit is tbd"; -CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; -CM_ SG_ 36 YAW_RATE "verify"; -CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; -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_ 560 BRAKE_LIGHTS "double check"; -CM_ SG_ 581 GAS_PEDAL "it seems slightly filtered"; -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_ 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_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; -CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isnt perfect"; -CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; -CM_ SG_ 1042 SET_ME_1 "unclear what this is, nut it's always 1 in drive traces"; -VAL_ 295 GEAR 0 "P" 1 "R" 2 "N" 3 "D" 4 "B" ; -VAL_ 466 CRUISE_STATE 8 "active" 7 "standstill" 1 "off" ; -VAL_ 610 STATE 5 "override" 3 "enabled" 1 "disabled" ; -VAL_ 610 LKA_STATE 50 "temporary_fault" ; -VAL_ 614 STATE 3 "enabled" 1 "disabled" ; -VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left" ; -VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left" ; -VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok" ; -VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted" ; -VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none" ; -VAL_ 1042 RIGHT_LINE 3 "orange" 2 "double" 1 "solid" 0 "none" ; -VAL_ 1042 LEFT_LINE 3 "orange" 2 "double" 1 "solid" 0 "none" ; -VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none" ; -VAL_ 1553 UNITS 1 "km" 2 "miles" ; diff --git a/opendbc/toyota_prius_2017_pt_generated.dbc b/opendbc/toyota_prius_2017_pt_generated.dbc index 9b02b364e36a31..868381e5e56014 100644 --- a/opendbc/toyota_prius_2017_pt_generated.dbc +++ b/opendbc/toyota_prius_2017_pt_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +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 @@ -9,10 +9,10 @@ BO_ 359 STEERING_IPAS_COMMA: 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 -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"; +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 @@ -30,8 +30,13 @@ CM BO_ STEERING_IPAS_COMMA "Copy of msg 614 so we can do angle control while the VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; +BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX + SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX + +CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; -CM_ "Imported file _toyota_2017.dbc starts here" + +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -70,8 +75,8 @@ BS_: BU_: XXX DSU HCU EPS IPAS CGW 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_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX + SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX @@ -91,12 +96,15 @@ BO_ 170 WHEEL_SPEEDS: 8 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 + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 353 DSU_SPEED: 8 XXX +BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX +BO_ 452 ENGINE_RPM: 8 CGW + SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS + 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 @@ -159,10 +167,11 @@ BO_ 835 ACC_CONTROL: 8 DSU 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_ PERMIT_BRAKING : 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 + SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX @@ -184,6 +193,7 @@ BO_ 921 PCM_CRUISE_SM: 8 XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX + SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1041 ACC_HUD: 8 DSU @@ -208,6 +218,17 @@ BO_ 1042 LKAS_HUD: 8 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_ 1043 TIME : 8 CGW + SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX + SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX + SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX + SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX + SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX + SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX + SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX + SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX + SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX + BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX @@ -231,7 +252,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX @@ -295,7 +316,7 @@ 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 SET_SPEED "43 kph are shown as 28mph, so conversion isn't 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"; @@ -304,13 +325,15 @@ CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; +CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; +CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; 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_ 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"; @@ -344,7 +367,7 @@ 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_ "toyota_prius_2017_pt.dbc starts here" +CM_ "toyota_prius_2017_pt.dbc starts here"; @@ -367,6 +390,7 @@ BO_ 608 STEER_TORQUE_SENSOR: 8 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 + SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 8 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX diff --git a/opendbc/toyota_rav4_2017_pt_generated.dbc b/opendbc/toyota_rav4_2017_pt_generated.dbc index 5825028dbe2880..19c5271d8df0e4 100644 --- a/opendbc/toyota_rav4_2017_pt_generated.dbc +++ b/opendbc/toyota_rav4_2017_pt_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +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 @@ -9,10 +9,10 @@ BO_ 359 STEERING_IPAS_COMMA: 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 -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"; +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 @@ -30,8 +30,13 @@ CM BO_ STEERING_IPAS_COMMA "Copy of msg 614 so we can do angle control while the VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; +BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX + SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX + +CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; -CM_ "Imported file _toyota_2017.dbc starts here" + +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -70,8 +75,8 @@ BS_: BU_: XXX DSU HCU EPS IPAS CGW 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_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX + SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX @@ -91,12 +96,15 @@ BO_ 170 WHEEL_SPEEDS: 8 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 + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 353 DSU_SPEED: 8 XXX +BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX +BO_ 452 ENGINE_RPM: 8 CGW + SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS + 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 @@ -159,10 +167,11 @@ BO_ 835 ACC_CONTROL: 8 DSU 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_ PERMIT_BRAKING : 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 + SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX @@ -184,6 +193,7 @@ BO_ 921 PCM_CRUISE_SM: 8 XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX + SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1041 ACC_HUD: 8 DSU @@ -208,6 +218,17 @@ BO_ 1042 LKAS_HUD: 8 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_ 1043 TIME : 8 CGW + SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX + SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX + SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX + SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX + SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX + SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX + SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX + SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX + SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX + BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX @@ -231,7 +252,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX @@ -295,7 +316,7 @@ 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 SET_SPEED "43 kph are shown as 28mph, so conversion isn't 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"; @@ -304,13 +325,15 @@ CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; +CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; +CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; 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_ 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"; @@ -344,7 +367,7 @@ 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_ "toyota_rav4_2017_pt.dbc starts here" +CM_ "toyota_rav4_2017_pt.dbc starts here"; @@ -361,6 +384,7 @@ BO_ 608 STEER_TORQUE_SENSOR: 8 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 + SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX diff --git a/opendbc/toyota_rav4_hybrid_2017_pt_generated.dbc b/opendbc/toyota_rav4_hybrid_2017_pt_generated.dbc index 6004bfd941564b..bb98e0d30c6d0d 100644 --- a/opendbc/toyota_rav4_hybrid_2017_pt_generated.dbc +++ b/opendbc/toyota_rav4_hybrid_2017_pt_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +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 @@ -9,10 +9,10 @@ BO_ 359 STEERING_IPAS_COMMA: 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 -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"; +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 @@ -30,8 +30,13 @@ CM BO_ STEERING_IPAS_COMMA "Copy of msg 614 so we can do angle control while the VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; +BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX + SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX + +CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; -CM_ "Imported file _toyota_2017.dbc starts here" + +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -70,8 +75,8 @@ BS_: BU_: XXX DSU HCU EPS IPAS CGW 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_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX + SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX @@ -91,12 +96,15 @@ BO_ 170 WHEEL_SPEEDS: 8 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 + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 353 DSU_SPEED: 8 XXX +BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX +BO_ 452 ENGINE_RPM: 8 CGW + SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS + 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 @@ -159,10 +167,11 @@ BO_ 835 ACC_CONTROL: 8 DSU 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_ PERMIT_BRAKING : 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 + SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX @@ -184,6 +193,7 @@ BO_ 921 PCM_CRUISE_SM: 8 XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX + SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1041 ACC_HUD: 8 DSU @@ -208,6 +218,17 @@ BO_ 1042 LKAS_HUD: 8 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_ 1043 TIME : 8 CGW + SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX + SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX + SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX + SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX + SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX + SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX + SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX + SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX + SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX + BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX @@ -231,7 +252,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX @@ -295,7 +316,7 @@ 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 SET_SPEED "43 kph are shown as 28mph, so conversion isn't 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"; @@ -304,13 +325,15 @@ CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; +CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; +CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; 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_ 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"; @@ -344,7 +367,7 @@ 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_ "toyota_rav4_hybrid_2017_pt.dbc starts here" +CM_ "toyota_rav4_hybrid_2017_pt.dbc starts here"; @@ -361,6 +384,7 @@ BO_ 608 STEER_TORQUE_SENSOR: 8 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 + SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX diff --git a/opendbc/toyota_sienna_xle_2018_pt_generated.dbc b/opendbc/toyota_sienna_xle_2018_pt_generated.dbc index 3bff57f44a0010..ad0d1f31dd0b7b 100644 --- a/opendbc/toyota_sienna_xle_2018_pt_generated.dbc +++ b/opendbc/toyota_sienna_xle_2018_pt_generated.dbc @@ -1,7 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; -CM_ "Imported file _comma.dbc starts here" +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 @@ -9,10 +9,10 @@ BO_ 359 STEERING_IPAS_COMMA: 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 -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"; +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 @@ -30,8 +30,13 @@ CM BO_ STEERING_IPAS_COMMA "Copy of msg 614 so we can do angle control while the VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; +BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX + SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX + +CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; -CM_ "Imported file _toyota_2017.dbc starts here" + +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -70,8 +75,8 @@ BS_: BU_: XXX DSU HCU EPS IPAS CGW 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_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX + SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX @@ -91,12 +96,15 @@ BO_ 170 WHEEL_SPEEDS: 8 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 + SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 353 DSU_SPEED: 8 XXX +BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX +BO_ 452 ENGINE_RPM: 8 CGW + SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS + 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 @@ -159,10 +167,11 @@ BO_ 835 ACC_CONTROL: 8 DSU 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_ PERMIT_BRAKING : 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 + SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX @@ -184,6 +193,7 @@ BO_ 921 PCM_CRUISE_SM: 8 XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX + SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1041 ACC_HUD: 8 DSU @@ -208,6 +218,17 @@ BO_ 1042 LKAS_HUD: 8 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_ 1043 TIME : 8 CGW + SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX + SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX + SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX + SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX + SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX + SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX + SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX + SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX + SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX + BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX @@ -231,7 +252,7 @@ BO_ 1409 VIN_PART_2: 8 CGW BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX -BO_ 1553 UI_SEETING: 8 XXX +BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX @@ -295,7 +316,7 @@ 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 SET_SPEED "43 kph are shown as 28mph, so conversion isn't 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"; @@ -304,13 +325,15 @@ CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; +CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; +CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; 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_ 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"; @@ -344,7 +367,7 @@ 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_ "toyota_sienna_xle_2018_pt.dbc starts here" +CM_ "toyota_sienna_xle_2018_pt.dbc starts here"; @@ -362,6 +385,7 @@ BO_ 608 STEER_TORQUE_SENSOR: 8 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 + SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX diff --git a/opendbc/vw_golf_mk4.dbc b/opendbc/vw_golf_mk4.dbc deleted file mode 100644 index 596f2d082ad041..00000000000000 --- a/opendbc/vw_golf_mk4.dbc +++ /dev/null @@ -1,1041 +0,0 @@ -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_ - -BS_: - -BU_: XXX - - -BO_ 1394 ZAS_1: 2 XXX - SG_ Fehlerspeichereintrag__ZAS_ : 15|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_ZAS_1_3 : 8|7@1+ (1,0) [0|0] "" XXX - SG_ Frei_ZAS_1_2 : 7|1@1+ (1,0) [0|0] "" XXX - SG_ Klemme_15_SV : 6|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_ZAS_1_1 : 5|1@1+ (1,0) [0|0] "" XXX - SG_ Klemme_P__Parklichtstellung_ : 4|1@1+ (1,0) [0|0] "" XXX - SG_ Klemme_50__Starten_ : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Klemme_X__Startvorgang_ : 2|1@1+ (1,0) [0|0] "" XXX - SG_ Klemme_15__Z_ndung_ein_ : 1|1@1+ (1,0) [0|0] "" XXX - SG_ S_Kontakt__Schl_ssel_steckt_ : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 1336 Wischer_1: 2 XXX - SG_ Blockierung_Heckwischer_erkannt : 15|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Wischer_1_2 : 12|3@1+ (1,0) [0|0] "" XXX - SG_ Fehlerspeichereintrag__Wischer_ : 11|1@1+ (1,0) [0|0] "" XXX - SG_ Ansteuerung_Scheibenwischer_Hec : 10|1@1+ (1,0) [0|0] "" XXX - SG_ Ansteuerung_Wascher_Heck : 9|1@1+ (1,0) [0|0] "" XXX - SG_ Scheibenwischer_Heck_eingeschal : 8|1@1+ (1,0) [0|0] "" XXX - SG_ Blockierung_Frontwischer_erkann : 7|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Wischer_1_1 : 6|1@1+ (1,0) [0|0] "" XXX - SG_ Status_Waschduesenheizung : 5|1@1+ (1,0) [0|0] "" XXX - SG_ Parklage_Frontwischer : 4|1@1+ (1,0) [0|0] "" XXX - SG_ Ansteuerung_Frontwischer_Schnel : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Ansteuerung_Frontwischer_Normal : 2|1@1+ (1,0) [0|0] "" XXX - SG_ Ansteuerung_Wascher_Front : 1|1@1+ (1,0) [0|0] "" XXX - SG_ Frontwischer__eingeschaltet : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 1464 WFS_1: 2 XXX - SG_ WFS_Textbits : 8|8@1+ (1,0) [0|0] "" XXX - SG_ Frei_WFS_1_1 : 1|7@1+ (1,0) [0|0] "" XXX - SG_ WFS_LED : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 1096 Waehlhebel_1: 4 XXX - SG_ Frei_Waehlhebel_1_1 : 29|3@1+ (1,0) [0|0] "" XXX - SG_ Test_aktiv_Flag : 28|1@1+ (1,0) [0|0] "" XXX - SG_ Zaehler_Waehlhebel_1 : 24|4@1+ (1,0) [0|15] "" XXX - SG_ Waehlhebel_Testergebnis : 16|8@1+ (1,0) [0|255] "" XXX - SG_ Fehler_Waehlhebel : 8|8@1+ (1,0) [0|0] "" XXX - SG_ Waehlhebelposition : 4|4@1+ (1,0) [0|0] "" XXX - SG_ Waehlhebel_Initialisierung : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Shiftlock_Position : 0|3@1+ (1,0) [0|0] "" XXX - -BO_ 1496 Verbauliste_1: 8 XXX - SG_ TV_Tuner : 63|1@1+ (1,0) [0|0] "" XXX - SG_ DSP : 62|1@1+ (1,0) [0|0] "" XXX - SG_ CD_Wechsler : 61|1@1+ (1,0) [0|0] "" XXX - SG_ Spracheingabe : 60|1@1+ (1,0) [0|0] "" XXX - SG_ Telematik : 59|1@1+ (1,0) [0|0] "" XXX - SG_ Navigation : 58|1@1+ (1,0) [0|0] "" XXX - SG_ Telefon : 57|1@1+ (1,0) [0|0] "" XXX - SG_ Radio : 56|1@1+ (1,0) [0|0] "" XXX - SG_ MMI_vorne : 55|1@1+ (1,0) [0|0] "" XXX - SG_ MMI_hinten : 54|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Verbauliste_1_11 : 53|1@1+ (1,0) [0|0] "" XXX - SG_ Klimabedienteil_HL : 52|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Verbauliste_1_10 : 50|2@1+ (1,0) [0|0] "" XXX - SG_ Tankgeber : 49|1@1+ (1,0) [0|0] "" XXX - SG_ Assistenzfahrlicht : 48|1@1+ (1,0) [0|0] "" XXX - SG_ Memory_hinter_Fahrer : 47|1@1+ (1,0) [0|0] "" XXX - SG_ Sitzmemory_hinten : 46|1@1+ (1,0) [0|0] "" XXX - SG_ Sitzmemory_Beifahrer : 45|1@1+ (1,0) [0|0] "" XXX - SG_ Anh_ngersteuergeraet : 44|1@1+ (1,0) [0|0] "" XXX - SG_ Energiemanagement : 43|1@1+ (1,0) [0|0] "" XXX - SG_ Wischermodul : 42|1@1+ (1,0) [0|0] "" XXX - SG_ EZS___Kessy__Komfort_ : 41|1@1+ (1,0) [0|0] "" XXX - SG_ Verdecksteuergeraet : 40|1@1+ (1,0) [0|0] "" XXX - SG_ Standheizung : 39|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Verbauliste_1_9 : 38|1@1+ (1,0) [0|0] "" XXX - SG_ Einparkhilfe : 37|1@1+ (1,0) [0|0] "" XXX - SG_ Klimasteuergeraet_Komfort : 36|1@1+ (1,0) [0|0] "" XXX - SG_ Gateway : 35|1@1+ (1,0) [0|0] "" XXX - SG_ Lenksaeulenmodul : 34|1@1+ (1,0) [0|0] "" XXX - SG_ Reifendruck : 33|1@1+ (1,0) [0|0] "" XXX - SG_ Kombiinstrument_Komfort : 32|1@1+ (1,0) [0|0] "" XXX - SG_ Dachmodul : 31|1@1+ (1,0) [0|0] "" XXX - SG_ Memory : 30|1@1+ (1,0) [0|0] "" XXX - SG_ TSG_HR : 29|1@1+ (1,0) [0|0] "" XXX - SG_ TSG_HL : 28|1@1+ (1,0) [0|0] "" XXX - SG_ TSG_BT : 27|1@1+ (1,0) [0|0] "" XXX - SG_ TSG_FT : 26|1@1+ (1,0) [0|0] "" XXX - SG_ ZKE : 25|1@1+ (1,0) [0|0] "" XXX - SG_ BSG_Komfort : 24|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Verbauliste_1_8 : 19|5@1+ (1,0) [0|0] "" XXX - SG_ Stabi_Entkopplung : 18|1@1+ (1,0) [0|0] "" XXX - SG_ Waehlhebel : 17|1@1+ (1,0) [0|0] "" XXX - SG_ Batteriemanager : 16|1@1+ (1,0) [0|0] "" XXX - SG_ Daempfer_SG : 15|1@1+ (1,0) [0|0] "" XXX - SG_ Niveauregulierung : 14|1@1+ (1,0) [0|0] "" XXX - SG_ EZS___Kessy__Antrieb_ : 13|1@1+ (1,0) [0|0] "" XXX - SG_ Bremsbooster : 12|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkhilfe : 11|1@1+ (1,0) [0|0] "" XXX - SG_ Kombi_Antrieb : 10|1@1+ (1,0) [0|0] "" XXX - SG_ Einspritzpumpe : 9|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkwinkel : 8|1@1+ (1,0) [0|0] "" XXX - SG_ Allrad : 7|1@1+ (1,0) [0|0] "" XXX - SG_ BSG_Antrieb : 6|1@1+ (1,0) [0|0] "" XXX - SG_ ADR : 5|1@1+ (1,0) [0|0] "" XXX - SG_ Airbag : 4|1@1+ (1,0) [0|0] "" XXX - SG_ Climatronic_Antrieb : 3|1@1+ (1,0) [0|0] "" XXX - SG_ ABS : 2|1@1+ (1,0) [0|0] "" XXX - SG_ Getriebesteuergeraet : 1|1@1+ (1,0) [0|0] "" XXX - SG_ Motorsteuergeraet : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 1488 Systeminfo_1: 6 XXX - SG_ CAN_Stand_4_1_Antrieb_Daten_Hau : 44|4@1+ (1,0) [0|15] "" XXX - SG_ CAN_Stand_4_1_Antrieb_Daten_Neb : 40|4@1+ (1,0) [0|15] "" XXX - SG_ CAN_Stand_4_1_Komfort_Daten_Hau : 36|4@1+ (1,0) [0|15] "" XXX - SG_ CAN_Stand_4_1_Komfort_Daten_Neb : 32|4@1+ (1,0) [0|15] "" XXX - SG_ Frei_Systeminfo_1_6 : 30|1@1+ (1,0) [0|0] "" XXX - SG_ Viertuerer : 29|1@1+ (1,0) [0|0] "" XXX - SG_ Rechtslenker : 28|1@1+ (1,0) [0|0] "" XXX - SG_ Fahrzeug_Index : 24|4@1+ (1,0) [0|0] "" XXX - SG_ Fahrzeug_Generation : 20|4@1+ (1,0) [0|15] "" XXX - SG_ Fahrzeug_Derivat : 16|4@1+ (1,0) [0|15] "" XXX - SG_ Fahrzeug_Marke_2 : 12|4@1+ (1,0) [0|15] "" XXX - SG_ Fahrzeug_Klasse : 8|4@1+ (1,0) [0|15] "" XXX - SG_ Verbauinformation_gueltig : 7|1@1+ (1,0) [0|0] "" XXX - SG_ CAN_Infotainment_verbaut : 6|1@1+ (1,0) [0|0] "" XXX - SG_ CAN_Infotainment_in_Diagnose : 5|1@1+ (1,0) [0|0] "" XXX - SG_ Sleep_CAN_Infotainment : 4|1@1+ (1,0) [0|0] "" XXX - SG_ CAN_Komfort_in_Diagnose : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Sleep_CAN_Komfort : 2|1@1+ (1,0) [0|0] "" XXX - SG_ CAN_Antrieb_in_Diagnose : 1|1@1+ (1,0) [0|0] "" XXX - SG_ CAN_Extern_zugeschaltet : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 268 Slave_1: 8 XXX - SG_ Delta_reduziertes_Sollmoment : 48|1@1+ (1,0) [0|0] "" XXX - SG_ Delta_Drosselklappenwinkel : 32|16@1+ (1,0) [0|0] "" XXX - SG_ Frei_Slave_1_1 : 25|7@1+ (1,0) [0|0] "" XXX - SG_ Delta_Zuendwinkelausgabe : 24|1@1+ (1,0) [0|0] "" XXX - SG_ Ubat_Freigabe_DVE__Slave_ : 23|1@1+ (1,0) [0|0] "" XXX - SG_ Drosselklappe_Sollwertbegrenzun : 22|1@1+ (1,0) [0|0] "" XXX - SG_ Einspritzverbot_lernen__Slave_ : 21|1@1+ (1,0) [0|0] "" XXX - SG_ Master_erkannt__Slave_ : 20|1@1+ (1,0) [0|0] "" XXX - SG_ Fehler_Momentenausgabe : 19|1@1+ (1,0) [0|0] "" XXX - SG_ Fehler_Getriebe_Moment : 18|1@1+ (1,0) [0|0] "" XXX - SG_ Fehler_Bremsenbotschaft : 17|1@1+ (1,0) [0|0] "" XXX - SG_ Indiziertes_Istmoment__Slave_ : 0|16@1+ (0.0015259,0) [0|99.998] "%" XXX - SG_ Timeout_Bremsenbotschaft : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 1332 Sitz_info: 2 XXX - SG_ Positionserkennung_Beifahrersit : 15|1@1+ (1,0) [0|0] "" XXX - SG_ Beifahrersitz_im_vorderen_Dritt : 14|1@1+ (1,0) [0|0] "" XXX - SG_ Positionserkennung_Fahrersitz_u : 13|1@1+ (1,0) [0|0] "" XXX - SG_ Fahrersitz_im_vorderen_Drittel : 12|1@1+ (1,0) [0|0] "" XXX - SG_ Zaehler_Sitzinfo : 8|4@1+ (1,0) [0|15] "" XXX - SG_ Checksumme_Sitzinfo : 0|8@1+ (1,0) [0|0] "" XXX - -BO_ 1810 PSG_3: 2 XXX - SG_ Selbsttestergebnis : 0|16@1+ (1,0) [0|0] "" XXX - -BO_ 1298 PSG_2: 8 XXX - SG_ RAM_Inhalt_4 : 48|16@1+ (1,0) [0|0] "" XXX - SG_ RAM_Inhalt_3 : 32|16@1+ (1,0) [0|0] "" XXX - SG_ RAM_Inhalt_2 : 16|16@1+ (1,0) [0|0] "" XXX - SG_ RAM_Inhalt_1 : 0|16@1+ (1,0) [0|0] "" XXX - -BO_ 274 PSG_1: 8 XXX - SG_ Pumpentemperatur__2_1_ : 48|16@1+ (0.0625,0) [0|4096] "°K" XXX - SG_ Pumpentemperatur__3_2_2_ : 44|12@1+ (1,0) [0|0] "" XXX - SG_ Zylinderzaehler__3_2_2_ : 43|3@1+ (1,0) [1|8] "Zähler" XXX - SG_ Ansteuerdauer__3_2_2_ : 32|11@1+ (0.0469,0) [0|96] "°NW" XXX - SG_ Nockenwellendrehzahl__3_2_2_ : 20|12@1+ (4,0) [0|16380] "upm" XXX - SG_ Pumpen_Statuswort__3_2_2_ : 0|20@1+ (1,0) [0|0] "" XXX - -BO_ 1300 NOX_1: 8 XXX - SG_ OBD_fuer_NOX : 56|8@1+ (1,0) [0|0] "" XXX - SG_ Frei_NOX1_4 : 53|3@1+ (1,0) [0|0] "" XXX - SG_ IP2 : 52|1@1+ (1,0) [0|0] "" XXX - SG_ IP1 : 51|1@1+ (1,0) [0|0] "" XXX - SG_ IP0 : 50|1@1+ (1,0) [0|0] "" XXX - SG_ Sondenheizung_NOX : 49|1@1+ (1,0) [0|0] "" XXX - SG_ Offsetkorrektur_NOX : 48|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_NOX1_3 : 43|5@1+ (1,0) [0|0] "" XXX - SG_ Sauerstoff_binaer : 32|11@1+ (1,-200) [-200|1847] "mV" XXX - SG_ Frei_NOX1_2 : 27|5@1+ (1,0) [0|0] "" XXX - SG_ Sauerstoff_linear : 16|11@1+ (1,0) [0|2047] "1000/Lambd" XXX - SG_ Frei_NOX1_1 : 11|5@1+ (1,0) [0|0] "" XXX - SG_ NOX_Signal : 0|11@1+ (1,0) [0|2047] "ppm" XXX - -BO_ 1424 Niveau_1: 6 XXX - SG_ Beladungszustand : 40|8@1+ (1,0) [0|253] "Zuladung" XXX - SG_ Fehlerspeichereintrag__Niveau_1 : 39|1@1+ (1,0) [0|0] "" XXX - SG_ Systemstatus__Niveau_1_ : 38|1@1+ (1,0) [0|0] "" XXX - SG_ Reserve_Fahrzeugart : 37|1@1+ (1,0) [0|0] "" XXX - SG_ Fahrzeugart_Niveau : 36|1@1+ (1,0) [0|0] "" XXX - SG_ Textbits__Niveau_1_ : 32|4@1+ (1,0) [0|0] "" XXX - SG_ Verstellung_HL : 31|1@1+ (1,0) [0|0] "" XXX - SG_ Verstellung_HR : 30|1@1+ (1,0) [0|0] "" XXX - SG_ Verstellung_VL : 29|1@1+ (1,0) [0|0] "" XXX - SG_ Verstellung_VR : 28|1@1+ (1,0) [0|0] "" XXX - SG_ Absenkung_Fahrzeug : 27|1@1+ (1,0) [0|0] "" XXX - SG_ Anhebung_Fahrzeug : 26|1@1+ (1,0) [0|0] "" XXX - SG_ Verstellung_aktiv : 25|1@1+ (1,0) [0|0] "" XXX - SG_ Kompressorlauf_in_Kuerze : 24|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Niveau_1_5 : 23|1@1+ (1,0) [0|0] "" XXX - SG_ Taster_Niveau : 22|1@1+ (1,0) [0|0] "" XXX - SG_ Parkniveau : 21|1@1+ (1,0) [0|0] "" XXX - SG_ Zwischenniveau : 20|1@1+ (1,0) [0|0] "" XXX - SG_ Niveaustati : 16|4@1+ (1,0) [0|0] "" XXX - SG_ MSG_Einschraenkung : 15|1@1+ (1,0) [0|0] "" XXX - SG_ ESP_Beeinflussung : 14|1@1+ (1,0) [0|0] "" XXX - SG_ Warnlampe_Niveau_1 : 13|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Niveau_1_1 : 12|1@1+ (1,0) [0|0] "" XXX - SG_ Zaehler_Niveau_1 : 8|4@1+ (1,0) [0|15] "Zähler" XXX - SG_ Checksumme_Niveau_1 : 0|8@1+ (1,0) [0|0] "" XXX - -BO_ 1328 Navigation_1: 7 XXX - SG_ Kreuzungstyp : 54|2@1+ (1,0) [0|3] "" XXX - SG_ Entfernung_bis_Kreuzung : 48|6@1+ (5,0) [0|315] "m" XXX - SG_ Entfernung_bis_Kurvenanfang : 40|8@1+ (1,0) [0|255] "m" XXX - SG_ Voarusliegende_Kurvenrichtung : 39|1@1+ (1,0) [0|0] "" XXX - SG_ Vorausliegender_Kurvenverlauf : 32|7@1+ (50,0) [0|6350] "m" XXX - SG_ Fehler_Navigation : 31|1@1+ (1,0) [0|0] "" XXX - SG_ Anzahl_Fahrbahnen__0_ist_unguel : 28|3@1+ (1,0) [1|7] "" XXX - SG_ Strassentyp : 24|4@1+ (1,0) [0|15] "" XXX - SG_ Laenderkennung : 16|8@1+ (1,0) [0|0] "" XXX - SG_ Vorzeichen_Gierrate______ : 15|1@1+ (1,0) [0|0] "" XXX - SG_ Gierratenfehler : 14|1@1+ (1,0) [0|0] "" XXX - SG_ Gierrate : 0|14@1+ (0.01,0) [0|100] "°/sek" XXX - -BO_ 1792 MSG_3: 3 XXX - SG_ MSG_Konfiguration : 16|8@1+ (1,0) [0|0] "" XXX - SG_ Lage_des_OT_Impuls : 0|16@1+ (0.01172,-384) [-384|384] "°KW" XXX - -BO_ 1280 MSG_2: 8 XXX - SG_ RAM_Adresse_4 : 48|16@1+ (1,0) [0|0] "" XXX - SG_ RAM_Adresse_3 : 32|16@1+ (1,0) [0|0] "" XXX - SG_ RAM_Adresse_2 : 16|16@1+ (1,0) [0|0] "" XXX - SG_ Ram_Adresse_1 : 0|16@1+ (1,0) [0|0] "" XXX - -BO_ 256 MSG_1: 8 XXX - SG_ Kurbelwellendrehzahl__3_2_2_ : 56|8@1+ (1,0) [0|0] "" XXX - SG_ Soll_Foerderbeginn_KW__3_2_2_ : 40|16@1+ (0.01172,-384) [-384|384] "°KW" XXX - SG_ Soll_Foerderbeginn_NW__3_2_2_ : 28|12@1+ (0.01172,0) [0|768] "°NW" XXX - SG_ Soll_Voreinspritzung : 16|12@1+ (1,0) [0|0] "" XXX - SG_ Soll_Einspritzmenge : 0|16@1+ (0.03125,0) [0|2047] "mg/H" XXX - -BO_ 1796 Motor_NOX: 8 XXX - SG_ Frei_Motor_NOX_1_2 : 24|40@1+ (1,0) [0|0] "" XXX - SG_ Frei_Motor_NOX_1_1 : 19|5@1+ (1,0) [0|0] "" XXX - SG_ Heizleistungsanforderung : 18|1@1+ (1,0) [0|0] "" XXX - SG_ Offsetkorrektur_moeglich : 17|1@1+ (1,0) [0|0] "" XXX - SG_ Betriebsbereich : 16|1@1+ (1,0) [0|0] "" XXX - SG_ Abgastemperatur_NOX : 8|8@1+ (5,-40) [-40|1230] "°C" XXX - SG_ Abgasdruck_NOX : 0|8@1+ (5,600) [600|1870] "mbar" XXX - -BO_ 900 Motor_Momente: 8 XXX - SG_ Momentenangaben_ungenau__Moment : 35|2@1+ (1,0) [0|0] "" XXX - -BO_ 1408 Motor_Flexia: 8 XXX - SG_ Ansaugsystem m0 : 63|1@1+ (1,0) [0|0] "" XXX - SG_ Hubraum m0 : 56|7@1+ (0.1,0) [0|12.7] "l" XXX - SG_ Steigung_der_Befuellungskennlin m1 : 56|8@1+ (0.001,0) [0|0.255] "l/mm" XXX - SG_ Anzahl_Zylinder m0 : 52|4@1+ (1,0) [0|15] "Vent./Zyl." XXX - SG_ Bewertungsfaktor_Russindex_Turb m1 : 50|6@1+ (0.1,0) [0|6.3] "" XXX - SG_ Anzahl_Ventile m0 : 49|3@1+ (1,0) [0|7] "Vent./Zyl." XXX - SG_ Bewertungsfaktor_Verschleissind m1 : 44|6@1+ (0.1,0) [0|6.3] "" XXX - SG_ Hersteller_Code m1 : 40|4@1+ (1,0) [0|15] "" XXX - SG_ Motorleistung m0 : 40|9@1+ (1,0) [0|512] "KW" XXX - SG_ Max_Drehmoment m0 : 32|8@1+ (10,0) [0|2550] "Nm" XXX - SG_ Normierter_Verbrauch m1 : 32|8@1+ (10,0) [0|2550] "l/Zyl." XXX - SG_ Oelniveauschwelle m1 : 24|8@1+ (0.25,0) [0|63.75] "cm" XXX - SG_ Drehzahl_MaxNorm m0 : 24|8@1+ (100,0) [0|25500] "U/min" XXX - SG_ Verschleissindex : 16|8@1+ (1,0) [0|254] "" XXX - SG_ Russindex : 8|8@1+ (1,0) [0|254] "" XXX - SG_ Verbrennungsart : 7|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Motor_Flexia_1 : 4|3@1+ (1,0) [0|0] "" XXX - SG_ Zaehler_Motor_Flexia : 1|3@1+ (1,0) [0|15] "" XXX - SG_ Multiplex_Schalter_Motor_Flexia M : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 1416 Motor_7: 8 XXX - SG_ Frei_Motor_7_3 : 40|24@1+ (1,0) [0|0] "" XXX - SG_ Ladedruck : 32|8@1+ (0.01,0) [0|2.54] "bar" XXX - SG_ Vorzeichen_Motordrehzahlgradien : 31|1@1+ (1,0) [0|0] "" XXX - SG_ Motordrehzahlgradient : 24|7@1+ (1,0) [0|126] "U/min" XXX - SG_ Hoeheninfo__Motor_7_ : 16|8@1+ (0.00787,0) [0|2] "" XXX - SG_ Klemme_DFM : 8|8@1+ (0.4,0) [0|101.6] "%" XXX - SG_ PTC___Gluehstifte_ausgeschaltet : 5|3@1+ (1,0) [0|0] "" XXX - SG_ Frei_Motor_7_1 : 4|1@1+ (1,0) [0|0] "" XXX - SG_ Fehlerspeichereintrag__Motor_7_ : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Statusbit_Geschwindikeitsbegren : 2|1@1+ (1,0) [0|0] "" XXX - SG_ Geschwindigkegrenzung_aktivierb : 1|1@1+ (1,0) [0|0] "" XXX - SG_ Leerlauf_Solldrehzahl_auf_Max_W : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 1160 Motor_6: 8 XXX - SG_ Zaehler_Motor_6 : 60|4@1+ (1,0) [0|15] "" XXX - SG_ Frei_Motor_6_4 : 58|2@1+ (1,0) [0|0] "" XXX - SG_ ltemperaturschutz : 57|1@1+ (1,0) [0|0] "" XXX - SG_ GRA_Bremseingriff_Freigabe : 56|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Motor_6_3 : 40|16@1+ (1,0) [0|0] "" XXX - SG_ GRA_Sollbeschleunigung : 32|8@1+ (0.024,-3.984) [-3.984|2.112] "m/s2" XXX - SG_ Hoeheninfo__Motor_6_ : 24|8@1+ (0.00787,0) [0|2] "" XXX - SG_ Istmoment_f_r_Getriebe : 16|8@1+ (0.39,0) [0|99] "MDI" XXX - SG_ Sollmoment_f_r_Getriebe : 8|8@1+ (0.39,0) [0|99] "MDI" XXX - SG_ Checksumme_Motor_6 : 0|8@1+ (1,0) [0|0] "" XXX - -BO_ 1152 Motor_5: 8 XXX - SG_ Checksumme_Motor_5 : 56|8@1+ (1,0) [0|0] "" XXX - SG_ Motortext_Bits__4_1_ : 52|4@1+ (1,0) [0|0] "" XXX - SG_ Doppelte_Momente : 51|1@1+ (1,0) [0|0] "" XXX - SG_ GRA_Hauptschalter : 50|1@1+ (1,0) [0|0] "" XXX - SG_ Anlasser_Ausspuren : 49|1@1+ (1,0) [0|0] "" XXX - SG_ Anlasser_Freigabe : 48|1@1+ (1,0) [0|0] "" XXX - SG_ Klimadrucksignal__Motor_5_ : 40|8@1+ (0.2,0) [0|50.8] "bar" XXX - SG_ K_hlerluefteransteuerung : 32|8@1+ (0.4,0) [0|101.6] "%" XXX - SG_ Verbrauch_Ueberlauf : 31|1@1+ (1,0) [0|0] "" XXX - SG_ Kraftstoffverbrauchssignal : 16|15@1+ (1,0) [0|32767] "ul" XXX - SG_ Klimakompressor_Leistungsreduzi : 15|1@1+ (1,0) [0|0] "" XXX - SG_ Kennfeldkuehlung : 14|1@1+ (1,0) [0|0] "" XXX - SG_ Klimakompressor_aus__Motor_5_ : 13|1@1+ (1,0) [0|0] "" XXX - SG_ CAT_Warnung : 12|1@1+ (1,0) [0|0] "" XXX - SG_ OBD_2_Lampe : 11|1@1+ (1,0) [0|0] "" XXX - SG_ E_Gas_Lampe : 10|1@1+ (1,0) [0|0] "" XXX - SG_ Vorgluehlampe__Motor_5_ : 9|1@1+ (1,0) [0|0] "" XXX - SG_ Ladekontroll_Lampe : 8|1@1+ (1,0) [0|0] "" XXX - SG_ Multiplex_Code M : 6|2@1+ (1,0) [0|0] "" XXX - SG_ Multiplex_Info_norm__Verbrauch m3 : 0|6@1+ (20,0) [0|1260] "l/Zyl" XXX - SG_ Multiplex_Info_Motortyp m2 : 0|6@1+ (1,0) [0|0] "" XXX - SG_ Multiplex_Info_Drehzahl_MD_Max m1 : 0|6@1+ (100,0) [0|6300] "U/min" XXX - SG_ Multiplex_Info_Max_Drehmoment m0 : 0|6@1+ (10,0) [0|630] "Nm" XXX - -BO_ 896 Motor_3: 8 XXX - SG_ Drosselklappenpoti : 56|8@1+ (0.4,0) [0|101.6] "%" XXX - SG_ Motor_Wunschdrehzahl : 48|8@1+ (25,0) [0|6350] "U/min" XXX - SG_ Motordrehzahlbeeinflussung : 40|8@1+ (0.392,0) [0|100] "%" XXX - SG_ Kein_Start_Stop : 39|1@1+ (1,0) [0|0] "" XXX - SG_ Kein_E_Gas : 38|1@1+ (1,0) [0|0] "" XXX - SG_ Reserviert_Motor_3_1 : 37|1@1+ (1,0) [0|0] "" XXX - SG_ Vorzeichen_Rad_Wunschmoment : 36|1@1+ (1,0) [0|0] "" XXX - SG_ Rad_Wunschmoment : 24|12@1+ (0.39,0) [0|1597] "MDI" XXX - SG_ Fahrpedal_Rohsignal : 16|8@1+ (0.4,0) [0|101.6] "%" XXX - SG_ Ansauglufttemperatur : 8|8@1+ (0.75,-48) [-48|142.5] "°" XXX - SG_ Fehlerstatus_Ansauglufttemperat : 7|1@1+ (1,0) [0|0] "" XXX - SG_ Motorsteuerger_t_gesperrt : 6|1@1+ (1,0) [0|0] "" XXX - SG_ Drosselklappenwinkel_ungenau : 5|1@1+ (1,0) [0|0] "" XXX - SG_ Fahrpedalwert_ungenau__Motor_3_ : 4|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Motor_3_1 : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Motor_Wunschdrehzahl_Priorit_t : 2|1@1+ (1,0) [0|0] "" XXX - SG_ Uebertemperaturschutz__Motor_3_ : 1|1@1+ (1,0) [0|0] "" XXX - SG_ Vorgluehmeldung : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 648 Motor_2: 8 XXX - SG_ Minimales_Motormoment_bei_Zuend : 56|8@1+ (0.39,0) [0|99] "MDI" XXX - SG_ Begrenzungsmoment : 48|8@1+ (0.39,0) [0|99] "MDI" XXX - SG_ Leerlaufsolldrehzahl__Motor_2_ : 40|8@1+ (10,0) [0|2540] "U/min" XXX - SG_ Soll_Geschwindigkeit_bei_GRA_Be : 32|8@1+ (1.28,0) [0|325] "km/h" XXX - SG_ Fahrzeuggeschwindigkeit : 24|8@1+ (1.28,0) [0|325] "km/h" XXX - SG_ GRA_Status : 22|2@1+ (1,0) [0|0] "" XXX - SG_ OBD_2_freeze_frame : 21|1@1+ (1,0) [0|0] "" XXX - SG_ Status_Normalbetrieb : 20|1@1+ (1,0) [0|0] "" XXX - SG_ Ansteuerung_Klima__4_1_ : 19|1@1+ (1,0) [0|0] "" XXX - SG_ Fehlerstatus_Kuhlmitteltempera : 18|1@1+ (1,0) [0|0] "" XXX - SG_ Bremstestschalter : 17|1@1+ (1,0) [0|0] "" XXX - SG_ Bremslichtschalter : 16|1@1+ (1,0) [0|0] "" XXX - SG_ Kuehlmitteltemperatur__Motor_2_ : 8|8@1+ (0.75,-48) [-48|142.5] "°" XXX - SG_ Multiplex_Code_Motor_2 M : 6|2@1+ (1,0) [0|0] "" XXX - SG_ Multiplex_Info_Motorcode__4_x_ m1 : 0|6@1+ (1,0) [0|0] "" XXX - SG_ Multiplex_Info_Getriebecode m2 : 0|6@1+ (1,0) [0|0] "" XXX - SG_ Multiplex_Info_Max_Moment__Norm m3 : 0|6@1+ (10,0) [0|630] "Nm" XXX - SG_ Multiplex_Info_CAN_Stand m0 : 0|6@1+ (1,0) [0|0] "" XXX - -BO_ 640 Motor_1: 8 XXX - SG_ Fahrerwunschmoment : 56|8@1+ (0.39,0) [0|99] "MDI" XXX - SG_ mechanisches_Motor_Verlustmomen : 48|8@1+ (0.39,0) [0|99] "MDI" XXX - SG_ Fahrpedalwert_oder_Drosselklapp : 40|8@1+ (0.4,0) [0|101.6] "%" XXX - SG_ inneres_Motor_Moment_ohne_exter : 32|8@1+ (0.39,0) [0|99] "MDI" XXX - SG_ Motordrehzahl : 16|16@1+ (0.25,0) [0|16256] "U/min" XXX - SG_ inneres_Motor_Moment : 8|8@1+ (0.39,0) [0|99] "MDI" XXX - SG_ Momentenangaben_ungenau : 7|1@1+ (1,0) [0|0] "" XXX - SG_ Fehlerstatus_Getriebe_Momentene : 6|1@1+ (1,0) [0|0] "" XXX - SG_ Fehlerstatus_Brems_Momenteneing : 5|1@1+ (1,0) [0|0] "" XXX - SG_ Time_Out_Bremsen_Botschaft : 4|1@1+ (1,0) [0|0] "" XXX - SG_ Kupplungsschalter : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Kickdownschalter : 2|1@1+ (1,0) [0|0] "" XXX - SG_ Fahrpedalwert_ungenau__Motor_1_ M : 1|1@1+ (1,0) [0|0] "" XXX - SG_ Leergasinformation : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 262 Master_3: 8 XXX - SG_ Frei_Master_3_1 : 56|8@1+ (1,0) [0|0] "" XXX - SG_ Motortemperatur_linearisiert : 48|8@1+ (0.75,-48) [-48|143.25] "°" XXX - SG_ Indiziertes_Sollmoment_f_r_Vmax : 32|16@1+ (0.0015259,0) [0|100] "%" XXX - SG_ Relative_Momentenanforderung_de : 16|16@1+ (0.003052,0) [0|200] "%" XXX - SG_ Delta_Motormoment_aus_Verlustmo : 0|16@1+ (0.003052,-100) [-100|100] "%" XXX - -BO_ 260 Master_2: 8 XXX - SG_ Ubat_Freigabe_DVE : 45|1@1+ (1,0) [0|0] "" XXX - SG_ DK_Sollwertbegrenzung : 44|1@1+ (1,0) [0|0] "" XXX - SG_ Einspritzverbot_DV_E_lernen : 43|1@1+ (1,0) [0|0] "" XXX - SG_ Master_erkannt : 42|1@1+ (1,0) [0|0] "" XXX - SG_ Vmax_Begrenzung_aktiv : 41|1@1+ (1,0) [0|0] "" XXX - SG_ SA_Verbot_von_FGR : 40|1@1+ (1,0) [0|0] "" XXX - SG_ Pedalwert_Komplement : 24|16@1+ (1,0) [0|0] "" XXX - SG_ Zaehler__Master_2_ : 16|8@1+ (1,0) [0|255] "" XXX - SG_ Normierter_Fahrpedalwinkel : 0|16@1+ (0.001526,0) [0|100] "%" XXX - -BO_ 258 Master_1: 8 XXX - SG_ Stationaere_Solldrehzahl : 56|8@1+ (10,0) [0|2550] "Umin" XXX - SG_ Drehmoment_LLR__I_Anteil_ : 40|16@1+ (0.003052,-100) [-100|100] "%" XXX - SG_ Drehmoment_LLR__PD_Anteil_ : 24|16@1+ (0.003052,-100) [-100|100] "%" XXX - SG_ Drehmoment_LLR__Luftpfad_ : 8|16@1+ (0.003052,-100) [-100|100] "%" XXX - SG_ Frei_Master_1_1 : 4|4@1+ (1,0) [0|0] "" XXX - SG_ LLR_ist_aktiv : 3|1@1+ (1,0) [0|0] "" XXX - SG_ I_Anteil_der_LLR_aktiv : 2|1@1+ (1,0) [0|0] "" XXX - SG_ PD_Anteil_der_LLR_aktiv : 1|1@1+ (1,0) [0|0] "" XXX - SG_ LLR_Freigabe_nach_Start : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 1984 LWS_Kalibrierung: 2 XXX - SG_ Frei_LWS_Kalibrierung_1_1 : 15|1@1+ (1,0) [0|0] "" XXX - SG_ LWS_Identifier : 8|7@1+ (1,0) [0|0] "" XXX - SG_ Frei_LWS_Kalibrierung_1_2 : 4|4@1+ (1,0) [0|0] "" XXX - SG_ Command_Dode_Word : 0|4@1+ (1,0) [0|0] "" XXX - -BO_ 1986 Lenkwinkel_Init: 4 XXX - SG_ Kodierbytes : 8|24@1+ (1,0) [0|0] "" XXX - SG_ Identiifier_f_r_LWS_Init : 0|8@1+ (1,0) [0|0] "" XXX - -BO_ 192 Lenkwinkel_1__RB_: 2 XXX - SG_ Vorzeichen__RB_ : 15|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkwinkel__RB_ : 5|10@1+ (2.5,-720) [-720|720] "°" XXX - SG_ LWS_OK__RB_ : 4|1@1+ (1,0) [0|0] "" XXX - SG_ LWS_Abgleich__RB_ : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Lenkwinkel_1_1__RB_ : 2|1@1+ (1,0) [0|0] "" XXX - SG_ FINE_CHECK__RB_ : 1|1@1+ (1,0) [0|0] "" XXX - SG_ COARSE_CHECK__RB_ : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 196 Lenkwinkel_1__ITT_: 2 XXX - SG_ Vorzeichen__ITT_ : 15|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkwinkel__ITT_ : 5|10@1+ (1.5,-768) [-768|766.5] "°" XXX - SG_ LWS_OK : 4|1@1+ (1,0) [0|0] "" XXX - SG_ LWS_Abgleich__ITT_ : 3|1@1+ (1,0) [0|0] "" XXX - SG_ LWS_Initialisierung__ITT_ : 2|1@1+ (1,0) [0|0] "" XXX - SG_ FINE_CHECK__ITT_ : 1|1@1+ (1,0) [0|0] "" XXX - SG_ COARSE_CHECK__ITT_ : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 194 Lenkwinkel_1: 8 XXX - SG_ Checksumme_Lenkwinkel_1 : 56|8@1+ (1,0) [0|0] "" XXX - SG_ Kodierdaten : 48|8@1+ (1,0) [0|0] "" XXX - SG_ Zaehler_Lenkwinkel_1 : 44|4@1+ (1,0) [0|15] "" XXX - SG_ Status_KL30_Ausfall__z_Zt__nur : 43|1@1+ (1,0) [0|0] "" XXX - SG_ Interner_Status : 41|2@1+ (1,0) [0|0] "" XXX - SG_ Frei_Lenkwinkel_1_1 : 40|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkwinkel_ID : 32|8@1+ (1,0) [0|0] "" XXX - SG_ Lenkradwinkel_Geschwindigkeit_S : 31|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkradwinkel_Geschwindigkeit : 16|15@1+ (0.04375,0) [0|1433.6] "Grad/Sek" XXX - SG_ Lenkradwinkel_Sign : 15|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkradwinkel : 0|15@1+ (0.04375,0) [0|1433.6] "Grad" XXX - -BO_ 1502 Lenkhilfe_Fehler: 7 XXX - SG_ Werkstattcode : 48|8@1+ (1,0) [0|0] "" XXX - SG_ Multiplex_Signal : 45|3@1+ (1,0) [0|7] "" XXX - SG_ Sensorcodierung_Lenkhilfe : 44|1@1+ (1,0) [0|0] "" XXX - SG_ Kennliniencodierung_Lenkhilfe : 40|4@1+ (1,0) [0|15] "Kennlinie" XXX - SG_ Geber_f__Lenkw__Speicher_ausles : 39|1@1+ (1,0) [0|0] "" XXX - SG_ Kombiinstr__Speicher_auslesen : 38|1@1+ (1,0) [0|0] "" XXX - SG_ Steuerger__Speicher_auslesen : 37|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkhilfe_Steuergeraet_defekt : 36|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Lenkhilfe_1_3 : 32|4@1+ (1,0) [0|0] "" XXX - SG_ Frei_Lenkhilfe_1_4 : 30|2@1+ (1,0) [0|0] "" XXX - SG_ Geber_f__Lenkwi__k__CAN_Komm_sp : 29|1@1+ (1,0) [0|0] "" XXX - SG_ Geber_f__Lenkwinkel_k__CAN_Komm : 28|1@1+ (1,0) [0|0] "" XXX - SG_ Kombiinstr__k__CAN_Kommunik__sp : 27|1@1+ (1,0) [0|0] "" XXX - SG_ Kombiinstrument_k__CAN_Kommunik : 26|1@1+ (1,0) [0|0] "" XXX - SG_ Steuergeraet_k__CAN_Kommunik__S : 25|1@1+ (1,0) [0|0] "" XXX - SG_ Steuergeraet_keine_CAN_Kommunik : 24|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkhilfe_Spannung_Ks__nach_Mas : 23|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkhilfe_Spannung_Ks_nach_Mass : 22|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkhilfe_Spannung_Ks__nach___s : 21|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkhilfe_Spannung_Ks__nach__ : 20|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkhilfe_Temperaturschutz_sp_ : 19|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkhilfe_Temperaturschutz : 18|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkhilfe_Betrieb_unpl__Sig__sp : 17|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkhilfe_Betrieb_unpl__Signal : 16|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkhilfesensor_k__Kommunik__sp : 15|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkhilfesensor_keine_Kommunik_ : 14|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkhilfesensor_defekt_sp_ : 13|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkhilfesensor_defekt : 12|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkhilfesensor_Unterbrechung_s : 11|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkhilfesensor_Unterbrechung : 10|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkhilfesensor_Ks_nach_Masse_s : 9|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkhifesensor_Ks_nach_Masse : 8|1@1+ (1,0) [0|0] "" XXX - SG_ Spannung_Kl_15_zu_klein_sp_ : 7|1@1+ (1,0) [0|0] "" XXX - SG_ Spannung_Kl_15_zu_klein : 6|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Lenkhilfe_1_5 : 4|2@1+ (1,0) [0|0] "" XXX - SG_ Spannung_Kl_30_zu_klein_sp_ : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Spannung_Kl_30_zu_klein : 2|1@1+ (1,0) [0|0] "" XXX - SG_ Spannung_Kl_30_zu_gro__sp_ : 1|1@1+ (1,0) [0|0] "" XXX - SG_ Spannung_Kl_30_zu_gro_ : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 976 Lenkhilfe_1: 2 XXX - SG_ Fehlerspeichereintrag__Lenkhilf : 15|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Lenkhilfe_1_2 : 9|6@1+ (1,0) [0|0] "" XXX - SG_ Fehlerlampe_Lenkhilfe : 8|1@1+ (1,0) [0|0] "" XXX - SG_ Fehlerstatus_Lastinformation : 7|1@1+ (1,0) [0|0] "" XXX - SG_ Lastinformation : 0|7@1+ (1,0) [0|127] "A" XXX - -BO_ 1312 Kombi_3: 8 XXX - SG_ Frei_Kombi_3_2 : 60|4@1+ (1,0) [0|0] "" XXX - SG_ Kilometerstand : 40|20@1+ (1,0) [0|1000000] "km" XXX - SG_ Fehlerstatus_Standzeit : 39|1@1+ (1,0) [0|0] "" XXX - SG_ Standzeit : 24|15@1+ (4,0) [0|131068] "sec" XXX - SG_ Frei_Kombi_3_1 : 20|4@1+ (1,0) [0|0] "" XXX - SG_ Schluesselinfo : 16|4@1+ (1,0) [0|15] "" XXX - SG_ Kombi_Multiplex_Code M : 14|2@1+ (1,0) [0|0] "" XXX - SG_ Kombi_Verbauliste_Niveauregulie m3 : 11|1@1+ (1,0) [0|0] "" XXX - SG_ Kombi_Multiplex_Marke m1 : 11|3@1+ (1,0) [0|0] "" XXX - SG_ Kombi_Verbauliste_Lenkhilfe m3 : 10|1@1+ (1,0) [0|0] "" XXX - SG_ Kombi_Verbauliste_Dieselpumpe m3 : 9|1@1+ (1,0) [0|0] "" XXX - SG_ Kombi_Verbauliste_Lenkwinkel m3 : 8|1@1+ (1,0) [0|0] "" XXX - SG_ Kombi_Multiplex_Baureihe m1 : 8|3@1+ (1,0) [0|0] "" XXX - SG_ Kombi_Multiplex_Laendervariante m0 : 8|6@1+ (1,0) [0|0] "" XXX - SG_ Kombi_Verbauliste_Allrad m3 : 7|1@1+ (1,0) [0|0] "" XXX - SG_ Kombi_Verbauliste_Bordnetz m3 : 6|1@1+ (1,0) [0|0] "" XXX - SG_ Kombi_Verbauliste_ACC m3 : 5|1@1+ (1,0) [0|0] "" XXX - SG_ Kombi_Verbauliste_Airbag m3 : 4|1@1+ (1,0) [0|0] "" XXX - SG_ Kombi_Multiplex_Generation m1 : 4|4@1+ (1,0) [0|0] "" XXX - SG_ Kombi_Verbauliste_Klima m3 : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Kombi_Verbauliste_ABS m3 : 2|1@1+ (1,0) [0|0] "" XXX - SG_ Kombi_Verbauliste_Motor m3 : 0|1@1+ (1,0) [0|0] "" XXX - SG_ Kombi_Multiplex_Derivat m1 : 0|4@1+ (1,0) [0|0] "" XXX - SG_ Kombi_Multiplex_Sprachvariante m0 : 0|8@1+ (1,0) [0|0] "" XXX - SG_ Kombi_Multiplex_Reifenumfang m2 : 0|12@1+ (1,0) [0|4095] "mm" XXX - -BO_ 1056 Kombi_2: 8 XXX - SG_ Frei_Kombi_2_2 : 56|8@1+ (1,0) [0|0] "" XXX - SG_ Fehlerstatus_Kl__58_s : 55|1@1+ (1,0) [0|0] "" XXX - SG_ Klemme_58s__Kombi_2_ : 48|7@1+ (1,0) [0|100] "%" XXX - SG_ Fehlerstatus_Kl__58_d : 47|1@1+ (1,0) [0|0] "" XXX - SG_ Klemme_58d__Kombi_2_ : 40|7@1+ (1,0) [0|100] "%" XXX - SG_ Kuehlmitteltemp__4_1__Kombi_2_ : 32|8@1+ (0.75,-48) [-48|142.5] "°C" XXX - SG_ Oeltemperatur_4_1 : 24|8@1+ (1,-60) [-60|194] "°C" XXX - SG_ Aussentemp__ungefiltert_4_1__Ko : 16|8@1+ (0.5,-50) [-50|77] "°C" XXX - SG_ Aussentemperatur_gefiltert : 8|8@1+ (0.5,-50) [-50|77] "°C" XXX - SG_ Fehlerspeichereintrag__Kombi_ : 7|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Kombi_2_1 : 4|3@1+ (1,0) [0|0] "" XXX - SG_ Anhaenger_erkannt : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Fehlerst__Kuehlmitteltemp__4_1 : 2|1@1+ (1,0) [0|0] "" XXX - SG_ Fehlerstatus_Oeltemperatur_4_1 : 1|1@1+ (1,0) [0|0] "" XXX - SG_ Fehlerstatus_Aussentemp__4_1 : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 800 Kombi_1: 8 XXX - SG_ Frei_Kombi_1_3 : 56|8@1+ (1,0) [0|0] "" XXX - SG_ Angezeigte_Geschwindigkeit : 46|10@1+ (0.32,0) [0|325] "km/h" XXX - SG_ Blinker_rechts_4_1 : 45|1@1+ (1,0) [0|0] "" XXX - SG_ Blinker_links_4_1 : 44|1@1+ (1,0) [0|0] "" XXX - SG_ Gesetzte_Zeitluecke__Kombi_1_ : 43|1@1+ (1,0) [0|0] "" XXX - SG_ ADR_Summer_abgeschaltet : 42|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Kombi_1_2 : 40|2@1+ (1,0) [0|0] "" XXX - SG_ Geschwindigkeit__Kombi_1_ : 25|15@1+ (0.01,0) [0|326] "km/h" XXX - SG_ Signalquelle_Geschwindigkeit_4_ : 24|1@1+ (1,0) [0|0] "" XXX - SG_ Tankwarnung : 23|1@1+ (1,0) [0|0] "" XXX - SG_ Tankinhalt : 16|7@1+ (1,0) [0|126] "l" XXX - SG_ Tankstop : 15|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Kombi_1_7 : 12|3@1+ (1,0) [0|0] "" XXX - SG_ Kombi_im_Stellgliedtest : 11|1@1+ (1,0) [0|0] "" XXX - SG_ Ladekontroll_Lampe__Kombi_ : 10|1@1+ (1,0) [0|0] "" XXX - SG_ Bremsinfo : 8|2@1+ (1,0) [0|0] "" XXX - SG_ Vorgluehlampe__Kombi_1_ : 7|1@1+ (1,0) [0|0] "" XXX - SG_ Tankwarnlampe : 6|1@1+ (1,0) [0|0] "" XXX - SG_ Heissleuchten_Vorwarnung : 5|1@1+ (1,0) [0|0] "" XXX - SG_ Kuehlmittelmangel : 4|1@1+ (1,0) [0|0] "" XXX - SG_ Dynamische_Oeldruckwarnung : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Oeldruck : 2|1@1+ (1,0) [0|0] "" XXX - SG_ Fehlerstatus_Tank : 1|1@1+ (1,0) [0|0] "" XXX - SG_ Fahrertuer_4_1 : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 1504 Klima_1: 8 XXX - SG_ Aussentemp__ungef__Sto_f__4_1 : 56|8@1+ (0.5,-50) [-50|77] "°C" XXX - SG_ Fehlerspeichereintrag__Klima_ : 55|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Klima_1_5 : 50|5@1+ (1,0) [0|0] "" XXX - SG_ AC_Schalter : 49|1@1+ (1,0) [0|0] "" XXX - SG_ Temperatureinheit : 48|1@1+ (1,0) [0|0] "" XXX - SG_ Kuehlerluefteransteuerung__Klim : 40|8@1+ (0.4,0) [0|101.6] "%" XXX - SG_ Geblaeselast_4_1 : 32|8@1+ (0.4,0) [0|101.6] "%" XXX - SG_ Kompressorlast : 24|8@1+ (0.25,0) [0|63.5] "Nm" XXX - SG_ Klimadrucksignal__Klima_1_ : 16|8@1+ (0.2,0) [0|50.8] "bar" XXX - SG_ Aussentemp__ungef__4_1__Klima_1 : 8|8@1+ (0.5,-50) [-50|77] "°C" XXX - SG_ Kaeltemitteldruck_veraltet : 7|1@1+ (1,0) [0|0] "" XXX - SG_ Kompressormoment_veraltet_4_1 : 6|1@1+ (1,0) [0|0] "" XXX - SG_ Keine_Heizleistg_gewuenscht_4_1 : 5|1@1+ (1,0) [0|0] "" XXX - SG_ Kompressorzustand__4_1_ : 4|1@1+ (1,0) [0|0] "" XXX - SG_ Heizbare_Frontscheibe : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Heizbare_Heckscheibe : 2|1@1+ (1,0) [0|0] "" XXX - SG_ Fahrerwunsch_Zuheizer : 1|1@1+ (1,0) [0|0] "" XXX - SG_ Drehzahlanhebung : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 906 GRA_neu: 4 XXX - SG_ Tiptronik_Bedienteilfehler : 31|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_GRA_neu_1_2 : 29|2@1+ (1,0) [0|0] "" XXX - SG_ Limiter_ein : 28|1@1+ (1,0) [0|0] "" XXX - SG_ Zeitlueckenverstellung : 26|2@1+ (1,0) [0|0] "" XXX - SG_ Tiptronic_Tip_Up__4_1_ : 25|1@1+ (1,0) [0|0] "" XXX - SG_ Tiptronic_Tip_Down__4_1_ : 24|1@1+ (1,0) [0|0] "" XXX - SG_ Zaehler__GRA_neu_ : 20|4@1+ (1,0) [0|15] "" XXX - SG_ Sender_Codierung__4_1_ : 18|2@1+ (1,0) [0|0] "" XXX - SG_ Wiederaufnahme : 17|1@1+ (1,0) [0|0] "" XXX - SG_ Setzen : 16|1@1+ (1,0) [0|0] "" XXX - SG_ GRA_Neu_frei_1 : 15|1@1+ (1,0) [0|0] "" XXX - SG_ Bedienteil_Fehler : 14|1@1+ (1,0) [0|0] "" XXX - SG_ Lang_Tip_up : 13|1@1+ (1,0) [0|0] "" XXX - SG_ Lang_Tip_down : 12|1@1+ (1,0) [0|0] "" XXX - SG_ Kurz_Tip_up : 11|1@1+ (1,0) [0|0] "" XXX - SG_ Kurz_Tip_down : 10|1@1+ (1,0) [0|0] "" XXX - SG_ Abbrechen : 9|1@1+ (1,0) [0|0] "" XXX - SG_ Hauptschalter : 8|1@1+ (1,0) [0|0] "" XXX - SG_ Checksumme_GRA_Neu : 0|8@1+ (1,0) [0|0] "" XXX - -BO_ 904 GRA: 3 XXX - SG_ Checksumme_GRA_alt : 16|8@1+ (1,0) [0|0] "" XXX - SG_ Frei_GRA_alt : 15|1@1+ (1,0) [0|0] "" XXX - SG_ GRA_alt__ADR_Bedienteil_Fehler : 14|1@1+ (1,0) [0|0] "" XXX - SG_ GRA_alt__ADR_beschleunigen : 13|1@1+ (1,0) [0|0] "" XXX - SG_ GRA_alt__ADR_verzoegern : 12|1@1+ (1,0) [0|0] "" XXX - SG_ GRA_alt__ADR___Tipschalter__Wie : 11|1@1+ (1,0) [0|0] "" XXX - SG_ GRA_alt__ADR___Tipschalter__Set : 10|1@1+ (1,0) [0|0] "" XXX - SG_ GRA_alt__ADR___Tipschalter__Aus : 9|1@1+ (1,0) [0|0] "" XXX - SG_ GRA_alt__ADR___Hauptschalter : 8|1@1+ (1,0) [0|0] "" XXX - SG_ Zaehler_GRA_alt : 0|8@1+ (1,0) [0|255] "" XXX - -BO_ 1352 Getriebe_4: 3 XXX - SG_ Testparameter_2 : 16|8@1+ (1,0) [0|255] "" XXX - SG_ Testparameter_1 : 8|8@1+ (1,0) [0|255] "" XXX - SG_ Waehlhebelausleuchtung : 4|4@1+ (1,0) [0|0] "" XXX - SG_ Frei_Getriebe_4_1 : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Testfreigabeflag : 2|1@1+ (1,0) [0|0] "" XXX - SG_ Handbremserinnerung_s_Lampe : 1|1@1+ (1,0) [0|0] "" XXX - SG_ Shiftlock_Getriebe_4 : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 1344 Getriebe_2: 8 XXX - SG_ eingelegte_Fahrstufe : 60|4@1+ (1,0) [0|0] "" XXX - SG_ Ganganzeige_Kombi___Getriebe_Va : 56|4@1+ (1,0) [0|15] "" XXX - SG_ Fehlerlampe_f_r_Kupplung_bei_VL : 55|1@1+ (1,0) [0|0] "" XXX - SG_ Anforderung_Kriechadaption : 54|1@1+ (1,0) [0|0] "" XXX - SG_ ECO_Anzeige__4_1_ : 53|1@1+ (1,0) [0|0] "" XXX - SG_ Shift_Lock_Lampe : 52|1@1+ (1,0) [0|0] "" XXX - SG_ Unterdrueckung_von_Warnungen : 51|1@1+ (1,0) [0|0] "" XXX - SG_ Gong : 50|1@1+ (1,0) [0|0] "" XXX - SG_ Starter_wird_angesteuert : 49|1@1+ (1,0) [0|0] "" XXX - SG_ Hochschaltlampe : 48|1@1+ (1,0) [0|0] "" XXX - SG_ Synchronisationszeit : 40|8@1+ (20,0) [0|5080] "ms" XXX - SG_ invertierte_Synchronisations_Wu : 32|8@1+ (25,0) [0|6350] "U/min" XXX - SG_ Synchronisations_Wunschdrehzahl : 24|8@1+ (25,0) [0|6350] "U/min" XXX - SG_ Gradientenbegrenzung : 16|8@1+ (10,0) [0|2540] "Nm/s" XXX - SG_ Leerlaufsolldrehzahl__Getriebe : 8|8@1+ (10,0) [0|2540] "U/min" XXX - SG_ Zahler_Getriebe_2 : 4|4@1+ (1,0) [0|15] "" XXX - SG_ Zwischengasflag : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Ecomatic__4_1_ : 2|1@1+ (1,0) [0|0] "" XXX - SG_ Schubabschaltunterstuetzung : 1|1@1+ (1,0) [0|0] "" XXX - SG_ LFR_Adaption_Freigabeflag : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 1088 Getriebe_1: 8 XXX - SG_ Wandlerverlustmoment : 56|8@1+ (0.39,0) [0|99.06] "MDI" XXX - SG_ Fehlerspeichereintrag__Getriebe : 55|1@1+ (1,0) [0|0] "" XXX - SG_ Zaehler_Getriebe_1 : 51|4@1+ (1,0) [0|15] "" XXX - SG_ Gang_eingelegt : 50|1@1+ (1,0) [0|0] "" XXX - SG_ Schaltabsicht : 49|1@1+ (1,0) [0|0] "" XXX - SG_ Motor_aus : 48|1@1+ (1,0) [0|0] "" XXX - SG_ OBD_Status__Getriebe_1___4_1_ : 46|2@1+ (1,0) [0|0] "" XXX - SG_ Kuehlleistung : 44|2@1+ (1,0) [0|0] "" XXX - SG_ Getriebe_Notlauf : 40|4@1+ (1,0) [0|0] "" XXX - SG_ Fahrwiderstandsindex : 32|8@1+ (0.249,-31.6) [-31.6|31.6] "" XXX - SG_ inneres_Soll_Motormoment : 24|8@1+ (0.39,0) [0|99.06] "MDI" XXX - SG_ Uebertragungsfunktion : 16|8@1+ (0.1,0) [0|25.4] "" XXX - SG_ Waehlhebelposition__Getriebe_1_ : 12|4@1+ (1,0) [0|0] "" XXX - SG_ Zielgang_oder_eingelegter_Gang : 8|4@1+ (1,0) [0|0] "" XXX - SG_ EGS_Anforderung : 7|1@1+ (1,0) [0|0] "" XXX - SG_ Kodierung_im_MSG : 6|1@1+ (1,0) [0|0] "" XXX - SG_ Leerlaufsolldrehzahlanhebung : 5|1@1+ (1,0) [0|0] "" XXX - SG_ Wandlerkupplung : 3|2@1+ (1,0) [0|0] "" XXX - SG_ Klimakompressor_aus__Getriebe_1 : 2|1@1+ (1,0) [0|0] "" XXX - SG_ Status_Getriebe_und_Wandlerschu : 1|1@1+ (1,0) [0|0] "" XXX - SG_ Schaltung_aktiv__Getriebe_1_ : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 912 Gateway_Komfort_1: 6 XXX - SG_ Bremslicht_Anhaenger : 47|1@1+ (1,0) [0|0] "" XXX - SG_ Anhaenger_erkannt_Gateway : 46|1@1+ (1,0) [0|0] "" XXX - SG_ ECD_AAG_unplausibel : 45|1@1+ (1,0) [0|0] "" XXX - SG_ BLS_AAG_unplausibel : 44|1@1+ (1,0) [0|0] "" XXX - SG_ Zaehler_Anhaenger : 40|4@1+ (1,0) [0|15] "" XXX - SG_ Frei_Gateway_Komfort_1_4 : 34|6@1+ (1,0) [0|0] "" XXX - SG_ ECD_ILM_unplausibel : 33|1@1+ (1,0) [0|0] "" XXX - SG_ BLS_ILM_unplausibel : 32|1@1+ (1,0) [0|0] "" XXX - SG_ Bremslicht_mitte_defekt : 31|1@1+ (1,0) [0|0] "" XXX - SG_ Bremslicht_rechts_defekt : 30|1@1+ (1,0) [0|0] "" XXX - SG_ Bremslicht_links_defekt : 29|1@1+ (1,0) [0|0] "" XXX - SG_ Rueckfahrlicht_Gateway : 28|1@1+ (1,0) [0|0] "" XXX - SG_ Zaehler_Bremslicht : 24|4@1+ (1,0) [0|15] "" XXX - SG_ Frei_Gateway_Komfort_1_3 : 17|7@1+ (1,0) [0|0] "" XXX - SG_ Fahrertuerkontakt : 16|1@1+ (1,0) [0|0] "" XXX - SG_ RDK_Systemfehler : 15|1@1+ (1,0) [0|0] "" XXX - SG_ RDK_Warnstufe_1 : 14|1@1+ (1,0) [0|0] "" XXX - SG_ RDK_Warnstufe_2 : 13|1@1+ (1,0) [0|0] "" XXX - SG_ Reifendruckwarnung_Reserverad : 12|1@1+ (1,0) [0|0] "" XXX - SG_ Reifendruckwarnung_hinten_recht : 11|1@1+ (1,0) [0|0] "" XXX - SG_ Reifendruckwarnung_hinten_links : 10|1@1+ (1,0) [0|0] "" XXX - SG_ Reifendruckwarnung_vorn_rechts : 9|1@1+ (1,0) [0|0] "" XXX - SG_ Reifendruckwarnung_vorn_links : 8|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Gateway_Komfort_1_2 : 5|3@1+ (1,0) [0|0] "" XXX - SG_ Fahrertuerkontakt_veraltet : 4|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Gateway_Komfort_1_1 : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Licht_1_Botschaft_veraltet : 2|1@1+ (1,0) [0|0] "" XXX - SG_ Anhaenger_Botschaft_veraltet : 1|1@1+ (1,0) [0|0] "" XXX - SG_ Reifendruckwarnung_veraltet : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 1340 Fahrwerk_1: 1 XXX - SG_ Frei_Fahrwerk_1_2 : 7|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Fahrwerk_1_1 : 6|2@1+ (1,0) [0|0] "" XXX - SG_ Einstellung_Fahrwerkdaempfung_4 : 4|3@1+ (1,0) [0|7] "" XXX - SG_ Ansteuererung_Fahrzeugniveau : 0|4@1+ (1,0) [0|15] "" XXX - -BO_ 1472 EPB_1: 8 XXX - SG_ Textmeldungen_EPB : 52|4@1+ (1,0) [0|0] "" XXX - SG_ Aufmerksamkeits_Gtong_EPB : 51|1@1+ (1,0) [0|0] "" XXX - SG_ Fehler_Gong_EBP : 50|1@1+ (1,0) [0|0] "" XXX - SG_ Warnton_EPB : 49|1@1+ (1,0) [0|0] "" XXX - SG_ Funktionslampe_EPB : 48|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_EPB_1_1 : 33|15@1+ (1,0) [0|0] "" XXX - SG_ Fehlerspeichereintrag_EPB : 32|1@1+ (1,0) [0|0] "" XXX - SG_ Neigungswinkel : 24|8@1+ (1,-128) [-128|127] "g" XXX - SG_ Verzoegerungsanforderung__EPB_ : 24|8@1+ (0.5,0) [0|255] "g" XXX - SG_ Status_Neigungswinkelgeber : 15|1@1+ (1,0) [0|0] "" XXX - SG_ Schalterinfo_Parkbremse : 13|2@1+ (1,0) [0|0] "" XXX - SG_ Erreichte_Spannkraft : 8|5@1+ (1,0) [0|30] "kN" XXX - SG_ Checksumme_Parkbremse : 8|8@1+ (1,0) [0|255] "" XXX - SG_ Schalterstatus_Parkbremse : 7|1@1+ (1,0) [0|0] "" XXX - SG_ Status_Parkbremse : 6|1@1+ (1,0) [0|0] "" XXX - SG_ Fehlerstatus_Parkbremse : 4|2@1+ (1,0) [0|0] "" XXX - SG_ Zaehler_Parkbremse : 0|4@1+ (1,0) [0|0] "" XXX - -BO_ 1326 Diag_Lenkhilfe: 3 XXX - SG_ Werkstattcode__Diag_ : 16|8@1+ (1,0) [0|0] "" XXX - SG_ Multiplex_Signal__Diag_ : 13|3@1+ (1,0) [0|7] "" XXX - SG_ Befehl_Sensorcodierung_Lenkhilf : 12|1@1+ (1,0) [0|0] "" XXX - SG_ Befehl_Kennliniencodierung_Lenk : 8|4@1+ (1,0) [0|0] "" XXX - SG_ Befehl_Fehlerspeicher_loeschen : 0|8@1+ (1,0) [0|0] "" XXX - -BO_ 1432 Daempfer_1: 2 XXX - SG_ Frei_Daempfer_1_4 : 12|4@1+ (1,0) [0|0] "" XXX - SG_ Textbits_Daempfer : 8|4@1+ (1,0) [0|0] "" XXX - SG_ Fehlerspeicherbit__Daempfer_1_ : 7|1@1+ (1,0) [0|0] "" XXX - SG_ Systemstatus__Daempfer_1_ : 6|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Daempfer_1_3 : 5|1@1+ (1,0) [0|0] "" XXX - SG_ Status_CDC_Taster : 4|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Daempfer_1_2 : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Status_Daempferregelung_4_1 : 0|3@1+ (1,0) [0|7] "" XXX - -BO_ 1392 BSG_Last: 4 XXX - SG_ Klimaanlage_abschalten : 31|1@1+ (1,0) [0|0] "" XXX - SG_ Sitzbelueftung_abschalten : 30|1@1+ (1,0) [0|0] "" XXX - SG_ Wischwasserheizung_abschalten : 29|1@1+ (1,0) [0|0] "" XXX - SG_ Lenkradheizung_abschalten : 28|1@1+ (1,0) [0|0] "" XXX - SG_ Heizbare_Sitze_abschalten : 27|1@1+ (1,0) [0|0] "" XXX - SG_ Heizbare_Aussenspiegel_abschalt : 26|1@1+ (1,0) [0|0] "" XXX - SG_ Heizbare_Frontscheibe_abschalte : 25|1@1+ (1,0) [0|0] "" XXX - SG_ Heizbare_Heckscheibe_abschalten : 24|1@1+ (1,0) [0|0] "" XXX - SG_ Batteriespannung_Bordnetzbatter : 16|8@1+ (0.05,5) [5|17.7] "V" XXX - SG_ Motorhaubenkontakt : 15|1@1+ (1,0) [0|0] "" XXX - SG_ Leuchtweitenregulierung : 14|1@1+ (1,0) [0|0] "" XXX - SG_ Fehlerspeichereintrag__BSG_Last : 13|1@1+ (1,0) [0|0] "" XXX - SG_ Zustand_der_Starterbatterie : 11|2@1+ (1,0) [0|0] "" XXX - SG_ Zustand_der_Bordnetzbatterie : 9|2@1+ (1,0) [0|0] "" XXX - SG_ LL_Drehzahlanhebung : 8|1@1+ (1,0) [0|0] "" XXX - SG_ Klemme_L : 7|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_BSG_Last_1_1 : 4|3@1+ (1,0) [0|0] "" XXX - SG_ ZAS_Klemme_50 : 3|1@1+ (1,0) [0|0] "" XXX - SG_ ZAS_Klemme_X : 2|1@1+ (1,0) [0|0] "" XXX - SG_ ZAS_Klemme_15 : 1|1@1+ (1,0) [0|0] "" XXX - SG_ ZAS_Klemme_S : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 1136 BSG_Kombi: 5 XXX - SG_ Frei_BSG_Kombi_1_3 : 36|4@1+ (1,0) [0|0] "" XXX - SG_ Ruecksitzlehne_HR_verr__4_1 : 35|1@1+ (1,0) [0|0] "" XXX - SG_ Ruecksitzlehne_HL_verr__4_1 : 34|1@1+ (1,0) [0|0] "" XXX - SG_ Fehlerlampe_Lenkhilfe_veraltet : 33|1@1+ (1,0) [0|0] "" XXX - SG_ Fehlerlampe_Lenkhilfe__BSG_Komb : 32|1@1+ (1,0) [0|0] "" XXX - SG_ Fehlerstatus_Kl__58s : 31|1@1+ (1,0) [0|0] "" XXX - SG_ Klemme_58s__BSG_Kombi_ : 24|7@1+ (1,0) [0|100] "%" XXX - SG_ Fehlerstatus_Kl__58d : 23|1@1+ (1,0) [0|0] "" XXX - SG_ Klemme_58d__BSG_Kombi_ : 16|7@1+ (1,0) [0|100] "%" XXX - SG_ Unterspannung : 15|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_BSG_Kombi_1_2 : 14|1@1+ (1,0) [0|0] "" XXX - SG_ Heckdeckel_geoeffnet : 13|1@1+ (1,0) [0|0] "" XXX - SG_ Motorhaube_geoeffnet : 12|1@1+ (1,0) [0|0] "" XXX - SG_ Tuer_hinten_rechts_geoeffnet : 11|1@1+ (1,0) [0|0] "" XXX - SG_ Tuer_hinten_links_geoeffnet : 10|1@1+ (1,0) [0|0] "" XXX - SG_ Beifahrertuer_geoeffnet : 9|1@1+ (1,0) [0|0] "" XXX - SG_ Fahrertuer_geoeffnet : 8|1@1+ (1,0) [0|0] "" XXX - SG_ Lade_Kontrollampe : 7|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_BSG_Kombi_1_1 : 6|1@1+ (1,0) [0|0] "" XXX - SG_ Rueckfahrlicht : 5|1@1+ (1,0) [0|0] "" XXX - SG_ DWA_Akku : 4|1@1+ (1,0) [0|0] "" XXX - SG_ Warnblink_Mode : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Anhaenger_Kontrollampe : 2|1@1+ (1,0) [0|0] "" XXX - SG_ Blinker_rechts_Kontrollampe : 1|1@1+ (1,0) [0|0] "" XXX - SG_ Blinker_links_Kontrollampe : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 424 Bremse_6: 3 XXX - SG_ Checksumme_Bremse_6 : 16|8@1+ (1,0) [0|0] "" XXX - SG_ Zaehler_Bremse_6 : 12|4@1+ (1,0) [0|15] "" XXX - SG_ Status_Bremsdruck__Bremse_6__du : 11|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Bremse_6_1 : 10|1@1+ (1,0) [0|0] "" XXX - SG_ Bremsdruck__Bremse_6_ : 0|10@1+ (0.3255,-40) [-40|293] "bar" XXX - -BO_ 1192 Bremse_5: 8 XXX - SG_ Checksumme_Bremse_5 : 56|8@1+ (1,0) [0|0] "" XXX - SG_ Zaehler_Bremse_5 : 52|4@1+ (1,0) [0|15] "" XXX - SG_ Bremslicht_ECD : 51|1@1+ (1,0) [0|0] "" XXX - SG_ Bremsentemperatur_vorn : 48|3@1+ (125,125) [125|1000] "°C" XXX - SG_ Frei_Bremse_5_5 : 40|8@1+ (1,0) [0|0] "" XXX - SG_ Offset_Gierrate : 32|8@1+ (0.05,-6.375) [-6.375|6.375] "°/s" XXX - SG_ Vorzeichen_Bremsdruck : 31|1@1+ (1,0) [0|0] "" XXX - SG_ Status_Bremsdruck_durch_ESP_Sys : 30|1@1+ (1,0) [0|0] "" XXX - SG_ Bremsdruck_ungueltig : 29|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Bremse_5_3 : 28|1@1+ (1,0) [0|0] "" XXX - SG_ Bremsdruck : 16|12@1+ (0.1,0) [0|250] "bar" XXX - SG_ Vorzeichen_der_Giergeschwindigk : 15|1@1+ (1,0) [0|0] "" XXX - SG_ Gierrate_ungueltig : 14|1@1+ (1,0) [0|0] "" XXX - SG_ Giergeschwindigkeit : 0|14@1+ (0.01,0) [0|100] "Grad/sec" XXX - -BO_ 672 Bremse_4: 3 XXX - SG_ Frei_Bremse_4_1 : 17|7@1+ (1,0) [0|0] "" XXX - SG_ Einheit_Kupplungssteifigkeit : 16|1@1+ (1,0) [0|0] "" XXX - SG_ ABS_Vorgabewert_hinten_Kupplung : 8|8@1+ (0.7874,0) [0|100] "%" XXX - SG_ ABS_Vorgabewert_mitte_Kupplungs : 0|8@1+ (3,-381) [-381|378] "Nm/min" XXX - -BO_ 1184 Bremse_3: 8 XXX - SG_ Radgeschw__HR_4_1 : 49|15@1+ (0.01,0) [0|326] "km/h" XXX - SG_ Frei_Bremse_3_4 : 48|1@1+ (1,0) [0|0] "" XXX - SG_ Radgeschw__HL_4_1 : 33|15@1+ (0.01,0) [0|326] "km/h" XXX - SG_ Frei_Bremse_3_3 : 32|1@1+ (1,0) [0|0] "" XXX - SG_ Radgeschw__VR_4_1 : 17|15@1+ (0.01,0) [0|326] "km/h" XXX - SG_ Frei_Bremse_3_2 : 16|1@1+ (0.01,0) [0|325] "km/h" XXX - SG_ Radgeschw__VL_4_1 : 1|15@1+ (0.01,0) [0|326] "km/h" XXX - SG_ Frei_Bremse_3_1 : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 1440 Bremse_2: 8 XXX - SG_ gemessene_Querbeschleunigung : 63|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Bremse_2_2 : 62|1@1+ (1,0) [0|0] "" XXX - SG_ Impulszahl : 56|6@1+ (1,0) [0|63] "" XXX - SG_ Fehlerstatus_Wegimpulse_4_1 : 55|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Bremse_2_5 : 54|1@1+ (1,0) [0|0] "" XXX - SG_ Warnlampe_DDS : 53|1@1+ (1,0) [0|0] "" XXX - SG_ Fehlerspeichereintrag_Bremse : 52|1@1+ (1,0) [0|0] "" XXX - SG_ Wegimpulszaehlerstatus : 51|1@1+ (1,0) [0|0] "" XXX - SG_ Wegimpulse_Vorderachse : 40|11@1+ (1,0) [0|2047] "" XXX - SG_ Zeitstempel : 24|16@1+ (1,0) [0|65535] "tics" XXX - SG_ mittlere_Raddrehzahl__Bremse_2 : 9|15@1+ (0.002,0) [0|65.278] "U/sec" XXX - SG_ Querbeschl__TimerTic M : 8|1@1+ (1,0) [0|0] "" XXX - SG_ Timer m1 : 0|8@1+ (0.04,0) [0|10.2] "usec" XXX - SG_ Querbeschleunigung m0 : 0|8@1+ (0.01,-1.27) [-1.27|1.27] "g" XXX - -BO_ 416 Bremse_1: 8 XXX - SG_ Geschwindigkeitsersatzwert : 63|1@1+ (1,0) [0|0] "" XXX - SG_ ESP_Systemstatus_4_1 : 62|1@1+ (1,0) [0|0] "" XXX - SG_ ESP_Passiv_getastet : 61|1@1+ (1,0) [0|0] "" XXX - SG_ ASR_Steuerger_t : 60|1@1+ (1,0) [0|0] "" XXX - SG_ Zaehler_Bremse_1 : 56|4@1+ (1,0) [0|15] "" XXX - SG_ MSR_Eingriffsmoment : 48|8@1+ (0.39,0) [0|99.06] "MDI" XXX - SG_ ASR_Eingriffsmoment_schnell : 40|8@1+ (0.39,0) [0|99.06] "MDI" XXX - SG_ ASR_Eingriffsmoment_langsam : 32|8@1+ (0.39,0) [0|99.06] "MDI" XXX - SG_ Geschwindigkeit_neu__Bremse_1_ : 17|15@1+ (0.01,0) [0|326.39] "km/h" XXX - SG_ Aktiver_Bremskraftverstaerker : 16|1@1+ (1,0) [0|0] "" XXX - SG_ ABS_in_Diagnose : 15|1@1+ (1,0) [0|0] "" XXX - SG_ Fehlerstatus_Schlechtwegausblen : 14|1@1+ (1,0) [0|0] "" XXX - SG_ Schlechtwegausblendung : 13|1@1+ (1,0) [0|0] "" XXX - SG_ Fahrer_bremst__Bremse_1___4_1_ : 11|1@1+ (1,0) [0|0] "" XXX - SG_ Bremskontroll_Lampe : 10|1@1+ (1,0) [0|0] "" XXX - SG_ Lampe_ASR___ESP : 9|1@1+ (1,0) [0|0] "" XXX - SG_ Lampe_ABS : 8|1@1+ (1,0) [0|0] "" XXX - SG_ EBV_Eingriff : 7|1@1+ (1,0) [0|0] "" XXX - SG_ ASR_Schaltbeeinflussung : 5|2@1+ (1,0) [0|0] "" XXX - SG_ ESP_Eingriff : 4|1@1+ (1,0) [0|0] "" XXX - SG_ EDS_Eingriff : 3|1@1+ (1,0) [0|0] "" XXX - SG_ ABS_Bremsung__4_1_ : 2|1@1+ (1,0) [0|0] "" XXX - SG_ MSR_Anforderung : 1|1@1+ (1,0) [0|0] "" XXX - SG_ ASR_Anforderung : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 680 Bremsbooster_1: 3 XXX - SG_ Fehlerspeichereintrag_Booster : 23|1@1+ (1,0) [0|0] "" XXX - SG_ Loseschalter_unplausibel_Boost : 22|1@1+ (1,0) [0|0] "" XXX - SG_ Position_Standby : 21|1@1+ (1,0) [0|0] "" XXX - SG_ ADR_Relais_ge_ffnet : 20|1@1+ (1,0) [0|0] "" XXX - SG_ Status_Bremsbooster_Steuerung : 19|1@1+ (1,0) [0|0] "" XXX - SG_ Bremsbooster_verf_gbar : 18|1@1+ (1,0) [0|0] "" XXX - SG_ Eingriff_Bremsbooster : 17|1@1+ (1,0) [0|0] "" XXX - SG_ Bremseingriff_Fahrer : 16|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Bremsbooster_1_1 : 12|4@1+ (1,0) [0|0] "" XXX - SG_ Zaehler_Booster_1 : 8|4@1+ (1,0) [0|15] "" XXX - SG_ Checksumme_Booster_1 : 0|8@1+ (1,0) [0|0] "" XXX - -BO_ 1400 BatMan_1: 1 XXX - SG_ Fehlerspeichereintrag__BatMan_ : 7|1@1+ (1,0) [0|0] "" XXX - SG_ Leistungsrelais : 6|1@1+ (1,0) [0|0] "" XXX - SG_ Messung_Starterleitung : 5|1@1+ (1,0) [0|0] "" XXX - SG_ Zustand_Starterleitung : 4|1@1+ (1,0) [0|0] "" XXX - SG_ Umschaltrelais_Bordnetzbatterie : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Ladung_Starterbatterie : 1|2@1+ (1,0) [0|0] "" XXX - SG_ Startmodus : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 704 Allrad_1: 5 XXX - SG_ Kupplungssteifigkeit_Hinten__Is : 32|8@1+ (0.7874,0) [0|100] "%" XXX - SG_ Fehlerspeichereintrag_Allrad_1 : 31|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Allrad_1_1 : 26|5@1+ (1,0) [0|0] "" XXX - SG_ Schaltung_Vorwarnung : 25|1@1+ (1,0) [0|0] "" XXX - SG_ Schaltung_aktiv__Allrad_1_ : 24|1@1+ (1,0) [0|0] "" XXX - SG_ Ganginfo__PNG_ : 20|4@1+ (1,0) [0|0] "" XXX - SG_ PNG_Anzeige_blinkend : 19|1@1+ (1,0) [0|0] "" XXX - SG_ PNG_Status_4_1 : 16|3@1+ (1,0) [0|0] "" XXX - SG_ Kupplungssteifigkeit_Mitte__Ist : 8|8@1+ (3,-381) [-381|378] "Nm/min" XXX - SG_ Einheit_der_Kupplungssteifigkei : 7|1@1+ (1,0) [0|0] "" XXX - SG_ Geschwindigkeitsbegrenzung : 6|1@1+ (1,0) [0|0] "" XXX - SG_ Allrad_Warnlampe : 5|1@1+ (1,0) [0|0] "" XXX - SG_ Notlauf : 4|1@1+ (1,0) [0|0] "" XXX - SG_ Kupplung_komplett_offen : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Fehlerstatus_Kupplungssteifigke : 2|1@1+ (1,0) [0|0] "" XXX - SG_ Ubertemperaturschutz__Allrad_1_ : 1|1@1+ (1,0) [0|0] "" XXX - SG_ Fehler_Allrad_Kupplung : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 1360 Airbag_2: 2 XXX - SG_ OOP_Beifahrer : 14|2@1+ (1,0) [0|0] "" XXX - SG_ OOP_Fahrer : 12|2@1+ (1,0) [0|0] "" XXX - SG_ Belegungserkennung_hinten_mitte : 11|1@1+ (1,0) [0|0] "" XXX - SG_ Belegungserkennung_hinten_recht : 10|1@1+ (1,0) [0|0] "" XXX - SG_ Belegungserkennung_hinten_links : 9|1@1+ (1,0) [0|0] "" XXX - SG_ Belegungserkennung_Beifahrersit : 8|1@1+ (1,0) [0|0] "" XXX - SG_ Checksumme_Airbag_2__reserviert : 0|8@1+ (1,0) [0|0] "" XXX - -BO_ 80 Airbag_1: 4 XXX - SG_ Checksumme_Airbag_1 : 24|8@1+ (1,0) [0|0] "" XXX - SG_ Zaehler_Airbag_1 : 20|4@1+ (1,0) [0|15] "" XXX - SG_ Fehlerspeichereintrag : 19|1@1+ (1,0) [0|0] "" XXX - SG_ Frei_Airbag_1_2 : 18|1@1+ (1,0) [0|0] "" XXX - SG_ Airbag_im_Stellgliedtest : 17|1@1+ (1,0) [0|0] "" XXX - SG_ Airbag_in_Diagnose : 16|1@1+ (1,0) [0|0] "" XXX - SG_ Gurtwarnung_Beifahrer : 15|1@1+ (1,0) [0|0] "" XXX - SG_ Gurtschalter_Beifahrer : 14|1@1+ (1,0) [0|0] "" XXX - SG_ Gurtwarnung_Fahrer : 13|1@1+ (1,0) [0|0] "" XXX - SG_ Gurtschalter_Fahrer : 12|1@1+ (1,0) [0|0] "" XXX - SG_ Airbag_Systemfehler : 11|1@1+ (1,0) [0|0] "" XXX - SG_ Kindersitzerkennung : 10|1@1+ (1,0) [0|0] "" XXX - SG_ Airbag_deaktiviert : 9|1@1+ (1,0) [0|0] "" XXX - SG_ Airbag_Lampe : 8|1@1+ (1,0) [0|0] "" XXX - SG_ Crash_Intensitaet : 5|3@1+ (1,0) [0|111] "B" XXX - SG_ Rollover : 4|1@1+ (1,0) [0|0] "" XXX - SG_ Seiten_Crash_Beifahrer : 3|1@1+ (1,0) [0|0] "" XXX - SG_ Seiten_Crash_Fahrer : 2|1@1+ (1,0) [0|0] "" XXX - SG_ Heck_Crash : 1|1@1+ (1,0) [0|0] "" XXX - SG_ Front_Crash : 0|1@1+ (1,0) [0|0] "" XXX - -BO_ 864 ADR_System: 8 XXX - SG_ S_Checksumme_ADR_1 : 56|8@1+ (1,0) [0|0] "" XXX - SG_ S_Frei_ADR_1_1 : 52|4@1+ (1,0) [0|0] "" XXX - SG_ S_Zeitluecke_gemessen : 48|4@1+ (1,0) [0|15] "" XXX - SG_ S_Fehlerspeichereintrag_ADR : 47|1@1+ (1,0) [0|0] "" XXX - SG_ S_Fehlerspeichereintrag_Bremsbo : 46|1@1+ (1,0) [0|0] "" XXX - SG_ S_ADR_Relais_geoeffnet : 45|1@1+ (1,0) [0|0] "" XXX - SG_ S_Bremsbooster_Status : 43|2@1+ (1,0) [0|0] "" XXX - SG_ S_Eingriff_Bremsbooster : 42|1@1+ (1,0) [0|0] "" XXX - SG_ S_Loeseschalter_unplausibel : 41|1@1+ (1,0) [0|0] "" XXX - SG_ S_Bremseingriff_Fahrer : 40|1@1+ (1,0) [0|0] "" XXX - SG_ S_Anzeige_Sensor_blind : 39|1@1+ (1,0) [0|0] "" XXX - SG_ S_Ansteuerung_optischer_Fahrerh : 38|1@1+ (1,0) [0|0] "" XXX - SG_ S_Ansteuerung_Gong_2 : 37|1@1+ (1,0) [0|0] "" XXX - SG_ S_Ansteuerung_Gong_1 : 36|1@1+ (1,0) [0|0] "" XXX - SG_ S_Schaltaufforderung : 34|2@1+ (1,0) [0|0] "" XXX - SG_ S_Anzeige_Prioritaet : 33|1@1+ (1,0) [0|0] "" XXX - SG_ S_Anzeige_Zeitluecke : 32|1@1+ (1,0) [0|0] "" XXX - SG_ S_Wunschgeschwindigkeit : 24|8@1+ (1,0) [0|254] "km/h" XXX - SG_ S_Objekt_erfasst : 22|2@1+ (1,0) [0|0] "" XXX - SG_ S_Gesetzte_Zeitluecke__ADR_1_ : 18|4@1+ (1,0) [0|15] "" XXX - SG_ S_Synchronisation_Bremsbooster : 17|1@1+ (1,0) [0|0] "" XXX - SG_ S_Momentenanforderung_Freigabe : 16|1@1+ (1,0) [0|0] "" XXX - SG_ S_Verhinderung_Schubabschaltung : 15|1@1+ (1,0) [0|0] "" XXX - SG_ S_Status_ADR_1__S_ : 13|2@1+ (1,0) [0|0] "" XXX - SG_ S_Fehler_ADR_1__S_ : 12|1@1+ (1,0) [0|0] "" XXX - SG_ S_Zaehler_ADR_1 : 8|4@1+ (1,0) [0|15] "" XXX - SG_ S_Momentenanforderung_ADR : 0|8@1+ (0.39,0) [0|99] "MDI" XXX - -BO_ 608 ADR_2: 4 XXX - SG_ Frei_ADR_2_2 : 27|5@1+ (1,0) [0|0] "" XXX - SG_ Anforderung_Bremsdruck : 16|11@1+ (0.0625,0) [0|127.9375] "bar" XXX - SG_ Frei_ADR_2_1 : 14|2@1+ (1,0) [0|0] "" XXX - SG_ Relais_Test_Fehler : 13|1@1+ (1,0) [0|0] "" XXX - SG_ Standby : 12|1@1+ (1,0) [0|0] "" XXX - SG_ Zaehler_ADR_2 : 8|4@1+ (1,0) [0|15] "" XXX - SG_ Checksumme_ADR_2 : 0|8@1+ (1,0) [0|0] "" XXX - -BO_ 1324 ADR_1: 8 XXX - SG_ Checksumme_ADR_1 : 56|8@1+ (1,0) [0|0] "" XXX - SG_ Frei_ADR_1_5 : 52|4@1+ (1,0) [0|0] "" XXX - SG_ Zeitluecke_gemessen : 48|4@1+ (1,0) [0|15] "" XXX - SG_ Fehlerspeichereintrag_ADR : 47|1@1+ (1,0) [0|0] "" XXX - SG_ Reserviert_ADR_1_1 : 40|7@1+ (1,0) [0|0] "" XXX - SG_ Anzeige_Sensor_blind : 39|1@1+ (1,0) [0|0] "" XXX - SG_ Ansteuerung_optischer_Fahrerhin : 38|1@1+ (1,0) [0|0] "" XXX - SG_ Ansteuerung_Gong_2 : 37|1@1+ (1,0) [0|0] "" XXX - SG_ Ansteuerung_Gong_1 : 36|1@1+ (1,0) [0|0] "" XXX - SG_ Schaltaufforderung : 34|2@1+ (1,0) [0|0] "" XXX - SG_ Anzeige_Prioritaet : 33|1@1+ (1,0) [0|0] "" XXX - SG_ Anzeige_Zeitluecke : 32|1@1+ (1,0) [0|0] "" XXX - SG_ Wunschgeschwindigkeit : 24|8@1+ (1,0) [0|254] "km/h" XXX - SG_ Objekt_erfasst : 22|2@1+ (1,0) [0|0] "" XXX - SG_ Gesetzte_Zeitluecke__ADR_1_ : 18|4@1+ (1,0) [0|15] "" XXX - SG_ Synchronisation_Bremsbooster : 17|1@1+ (1,0) [0|0] "" XXX - SG_ Momentenanforderung_Freigabe : 16|1@1+ (1,0) [0|0] "" XXX - SG_ Verhinderung_Schubabschaltung : 15|1@1+ (1,0) [0|0] "" XXX - SG_ Status_ADR_1 : 13|2@1+ (1,0) [0|0] "" XXX - SG_ Fehler_ADR_1 : 12|1@1+ (1,0) [0|0] "" XXX - SG_ Zaehler_ADR_1 : 8|4@1+ (1,0) [0|15] "" XXX - SG_ Momentenanforderung_ADR : 0|8@1+ (0.39,0) [0|99] "MDI" XXX diff --git a/opendbc/vw_mqb_2010.dbc b/opendbc/vw_mqb_2010.dbc index 4529f8847a0b87..c542b31f4f6602 100644 --- a/opendbc/vw_mqb_2010.dbc +++ b/opendbc/vw_mqb_2010.dbc @@ -37,8 +37,8 @@ BU_: Airbag_MQB BAP_Tester_MQB BMS_MQB Datenlogger_MQB Gateway_MQB Getriebe_DQ_H BO_ 290 ACC_06: 8 Gateway_MQB - SG_ ACC_06_CRC : 0|8@1+ (1,0) [0|255] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB - SG_ ACC_06_BZ : 8|4@1+ (1,0) [0|15] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ACC_limitierte_Anfahrdyn : 12|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ACC_zul_Regelabw_unten : 16|6@1+ (0.024,0) [0|1.512] "Unit_MeterPerSeconSquar" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ACC_StartStopp_Info : 22|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Otto_MQB @@ -53,8 +53,8 @@ BO_ 290 ACC_06: 8 Gateway_MQB SG_ ACC_Minimale_Bremsung : 63|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB BO_ 279 ACC_10: 8 Gateway_MQB - SG_ ACC_10_CRC : 0|8@1+ (1,0) [0|255] "" Airbag_MQB - SG_ ACC_10_BZ : 8|4@1+ (1,0) [0|15] "" Airbag_MQB + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Airbag_MQB + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Airbag_MQB SG_ AWV1_Anf_Prefill : 16|1@1+ (1,0) [0|1] "" Airbag_MQB SG_ ANB_CM_Info : 17|1@1+ (1,0) [0|1] "" Vector__XXX SG_ AWV2_Freigabe : 18|1@1+ (1,0) [0|1] "" Airbag_MQB @@ -281,8 +281,8 @@ BO_ 257 ESP_02: 8 Gateway_MQB SG_ ESP_Status_ESP_PLA : 60|4@1+ (1,0) [0|15] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB BO_ 262 ESP_05: 8 Gateway_MQB - SG_ ESP_05_CRC : 0|8@1+ (1,0) [0|255] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB - SG_ ESP_05_BZ : 8|4@1+ (1,0) [0|15] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_QBit_Bremsdruck : 12|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_QBit_Fahrer_bremst : 13|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Schwelle_Unterdruck : 14|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB @@ -360,8 +360,8 @@ BO_ 178 ESP_19: 8 Gateway_MQB SG_ ESP_VR_Radgeschw_02 : 48|16@1+ (0.0075,0) [0|491.49] "Unit_KiloMeterPerHour" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB BO_ 1629 ESP_20: 8 Gateway_MQB - SG_ ESP_20_CRC : 0|8@1+ (1,0) [0|255] "" Vector__XXX - SG_ ESP_20_BZ : 8|4@1+ (1,0) [0|15] "" Vector__XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Vector__XXX + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Vector__XXX SG_ BR_Systemart : 12|2@1+ (1,0) [0|3] "" Vector__XXX SG_ ESP_Zaehnezahl : 16|8@1+ (1,0) [0|255] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ ESP_Charisma_FahrPr : 24|4@1+ (1,0) [0|15] "" Vector__XXX @@ -370,8 +370,8 @@ BO_ 1629 ESP_20: 8 Gateway_MQB SG_ BR_Reifenumfang : 52|12@1+ (1,0) [0|4095] "Unit_MilliMeter" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB BO_ 253 ESP_21: 8 Gateway_MQB - SG_ ESP_21_CRC : 0|8@1+ (1,0) [0|255] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB - SG_ ESP_21_BZ : 8|4@1+ (1,0) [0|15] "" Airbag_MQB,BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Airbag_MQB,BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ BR_Eingriffsmoment : 12|10@1+ (1,-509) [-509|509] "Unit_NewtoMeter" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_v_Signal : 32|16@1+ (0.01,0) [0|655.32] "Unit_KiloMeterPerHour" Airbag_MQB,BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB,SAK_MQB SG_ ASR_Tastung_passiv : 48|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB @@ -451,8 +451,8 @@ BO_ 296 Getriebe_06: 3 Getriebe_DQ_Hybrid_MQB SG_ GE_Testparameter_2 : 16|8@1+ (1,0) [0|255] "" Waehlhebel_MQB BO_ 173 Getriebe_11: 8 Getriebe_DQ_Hybrid_MQB - SG_ Getriebe_11_CRC : 0|8@1+ (1,0) [0|255] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB - SG_ Getriebe_11_BZ : 8|4@1+ (1,0) [0|15] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ COUNTERXX : 8|4@1+ (1,0) [0|15] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_MMom_Soll_02 : 12|10@1+ (1,-509) [-509|509] "Unit_NewtoMeter" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_MMom_Vorhalt_02 : 22|10@1+ (1,-509) [-509|509] "Unit_NewtoMeter" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Uefkt : 32|10@1+ (0.1,0) [0|102.2] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB @@ -520,8 +520,8 @@ BO_ 158 Getriebe_Hybrid_01: 8 Getriebe_DQ_Hybrid_MQB SG_ GE_HYB_VM_Startkontr : 63|1@1+ (1,0) [0|1] "" Motor_Hybrid_MQB BO_ 299 GRA_ACC_01: 8 Gateway_MQB - SG_ GRA_ACC_01_CRC : 0|8@1+ (1,0) [0|255] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB - SG_ GRA_ACC_01_BZ : 8|4@1+ (1,0) [0|15] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GRA_Hauptschalter : 12|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GRA_Abbrechen : 13|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GRA_Typ_Hauptschalter : 14|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB @@ -535,10 +535,11 @@ BO_ 299 GRA_ACC_01: 8 Gateway_MQB SG_ GRA_Fehler : 24|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GRA_Typ468 : 25|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GRA_Tip_Stufe_2 : 27|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ GRA_ButtonTypeInfo : 28|2@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB BO_ 960 Klemmen_Status_01: 4 Gateway_MQB - SG_ Klemmen_Status_01_CRC : 0|8@1+ (1,0) [0|255] "" Airbag_MQB,BMS_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB - SG_ Klemmen_Status_01_BZ : 8|4@1+ (1,0) [0|15] "" Airbag_MQB,BMS_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Airbag_MQB,BMS_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Airbag_MQB,BMS_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ZAS_Kl_S : 16|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ZAS_Kl_15 : 17|1@1+ (1,0) [0|1] "" Airbag_MQB,BMS_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ZAS_Kl_X : 18|1@1+ (1,0) [0|1] "" Vector__XXX @@ -683,16 +684,16 @@ BO_ 982 Licht_hinten_01: 8 Gateway_MQB SG_ LH_Bremsl_re_ges_def : 55|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB BO_ 134 LWI_01: 8 Gateway_MQB - SG_ LWI_01_CRC : 0|8@1+ (1,0) [0|255] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB - SG_ LWI_01_BZ : 8|4@1+ (1,0) [0|15] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ LWI_Sensorstatus : 12|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ LWI_QBit_Sub_Daten : 13|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ LWI_QBit_Lenkradwinkel : 15|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ LWI_Lenkradwinkel : 16|13@1+ (0.1,0) [0|800] "Unit_DegreOfArc" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ LWI_VZ_Lenkradwinkel : 29|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ LWI_VZ_Lenkradw_Geschw : 30|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LWI_Lenkradw_Geschw : 31|9@1+ (5,0) [0|2500] "Unit_DegreOfArcPerSecon" Vector__XXX SG_ LWI_Sub_Daten : 40|16@1+ (1,0) [0|65535] "" Vector__XXX - SG_ LWI_Lenkradwinkel : 16|13@1+ (0.1,0) [0|800] "Unit_DegreOfArc" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB - SG_ LWI_QBit_Lenkradwinkel : 15|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB - SG_ LWI_VZ_Lenkradwinkel : 29|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB BO_ 263 Motor_04: 8 Motor_Diesel_MQB SG_ MO_Istgang : 8|4@1+ (1,0) [0|15] "" Gateway_MQB @@ -824,6 +825,8 @@ BO_ 1648 Motor_18: 8 Motor_Diesel_MQB SG_ MO_obere_Drehzahlgrenze : 56|8@1+ (50,0) [50|12750] "Unit_MinutInver" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB BO_ 289 Motor_20: 8 Motor_Diesel_MQB + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ COUNTER : 8|4@1+ (1,0) [0|255] "" XXX SG_ MO_Fahrpedalrohwert_01 : 12|8@1+ (0.4,0) [0|101.6] "Unit_PerCent" Airbag_MQB,Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_QBit_Fahrpedalwerte_01 : 20|1@1+ (1,0) [0|1] "" Airbag_MQB,Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Fahrpedalgradient : 21|8@1+ (25,0) [0|6350] "Unit_PerCentPerSecon" Airbag_MQB,Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB @@ -1105,8 +1108,8 @@ BO_ 1413 Systeminfo_01: 8 Gateway_MQB SG_ SI_BUS_15 : 30|1@1+ (1,0) [0|1] "" Vector__XXX BO_ 288 TSK_06: 8 Motor_Diesel_MQB - SG_ TSK_06_CRC : 0|8@1+ (1,0) [0|255] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB - SG_ TSK_06_BZ : 8|4@1+ (1,0) [0|15] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ TSK_Radbremsmom : 12|12@1+ (8,0) [0|32760] "Unit_NewtoMeter" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ TSK_Status : 24|3@1+ (1,0) [0|7] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ TSK_v_Begrenzung_aktiv : 27|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB @@ -1126,6 +1129,28 @@ BO_ 798 TSK_07: 8 Motor_Diesel_MQB SG_ TSK_Status_Anzeige : 61|3@1+ (1,0) [0|7] "" Gateway_MQB BO_ 1716 VIN_01: 8 Gateway_MQB + SG_ VIN_01_MUX M : 0|2@1+ (1,0) [0|3] "" Airbag_MQB + SG_ KS_Geheimnis_1 m0 : 8|8@1+ (1,0) [0|255] "" Vector__XXX + SG_ VIN_4 m1 : 8|8@1+ (1,0) [0|255] "" Airbag_MQB + SG_ VIN_11 m2 : 8|8@1+ (1,0) [0|255] "" Airbag_MQB + SG_ KS_Geheimnis_2 m0 : 16|8@1+ (1,0) [0|255] "" Vector__XXX + SG_ VIN_5 m1 : 16|8@1+ (1,0) [0|255] "" Airbag_MQB + SG_ VIN_12 m2 : 16|8@1+ (1,0) [0|255] "" Airbag_MQB + SG_ KS_Geheimnis_3 m0 : 24|8@1+ (1,0) [0|255] "" Vector__XXX + SG_ VIN_6 m1 : 24|8@1+ (1,0) [0|255] "" Airbag_MQB + SG_ VIN_13 m2 : 24|8@1+ (1,0) [0|255] "" Airbag_MQB + SG_ KS_Geheimnis_4 m0 : 32|8@1+ (1,0) [0|255] "" Vector__XXX + SG_ VIN_7 m1 : 32|8@1+ (1,0) [0|255] "" Airbag_MQB + SG_ VIN_14 m2 : 32|8@1+ (1,0) [0|255] "" Airbag_MQB + SG_ VIN_1 m0 : 40|8@1+ (1,0) [0|255] "" Airbag_MQB + SG_ VIN_8 m1 : 40|8@1+ (1,0) [0|255] "" Airbag_MQB + SG_ VIN_15 m2 : 40|8@1+ (1,0) [0|255] "" Airbag_MQB + SG_ VIN_2 m0 : 48|8@1+ (1,0) [0|255] "" Airbag_MQB + SG_ VIN_9 m1 : 48|8@1+ (1,0) [0|255] "" Airbag_MQB + SG_ VIN_16 m2 : 48|8@1+ (1,0) [0|255] "" Airbag_MQB + SG_ VIN_3 m0 : 56|8@1+ (1,0) [0|255] "" Airbag_MQB + SG_ VIN_10 m1 : 56|8@1+ (1,0) [0|255] "" Airbag_MQB + SG_ VIN_17 m2 : 56|8@1+ (1,0) [0|255] "" Airbag_MQB BO_ 175 Waehlhebel_03: 4 Waehlhebel_MQB SG_ WH_Status_Sperre : 0|3@1+ (1,0) [0|7] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB @@ -1157,30 +1182,30 @@ BO_ 1602 WIV_01: 8 Motor_Diesel_MQB SG_ WIV_W_max : 56|7@1+ (1000,0) [0|127000] "Unit_KiloMeter" Gateway_MQB BO_ 294 HCA_01: 8 XXX - SG_ 3 : 15|4@0+ (1,0) [0|15] "" XXX - SG_ 7 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ 254 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ HCA_01_CRC : 7|8@0+ (1,0) [0|255] "" XXX - SG_ HCA_01_BZ : 11|4@0+ (1,0) [0|255] "" XXX - SG_ Assist_Requested : 30|1@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ COUNTER : 8|4@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_0X3 : 12|4@1+ (1,0) [0|15] "" XXX SG_ Assist_Torque : 16|14@1+ (1,0) [0|300] "Nm" XXX - SG_ Assist_VZ : 31|1@0+ (1,0) [0|1] "" XXX + SG_ Assist_Requested : 30|1@1+ (1,0) [0|1] "" XXX + SG_ Assist_VZ : 31|1@1+ (1,0) [0|1] "" XXX SG_ HCA_Available : 32|1@1+ (1,0) [0|1] "" XXX - SG_ HCA_Standby : 33|1@0+ (1,0) [0|1] "" XXX - SG_ HCA_Active : 34|1@0+ (1,0) [0|1] "" XXX + SG_ HCA_Standby : 33|1@1+ (1,0) [0|1] "" XXX + SG_ HCA_Active : 34|1@1+ (1,0) [0|1] "" XXX + SG_ SET_ME_0XFE : 40|8@1+ (1,0) [0|255] "" XXX + SG_ SET_ME_0X07 : 48|8@1+ (1,0) [0|255] "" XXX BO_ 159 EPS_01: 8 XXX - SG_ EPS_01_CRC : 0|8@1+ (1,0) [0|255] "" XXX - SG_ EPS_01_BZ : 8|4@1+ (1,0) [0|15] "" XXX - SG_ Steering_Wheel_Angle : 16|13@1+ (0.075,0) [0|16383] "Unit_DegreOfArc" XXX - SG_ Steering_Wheel_Angle_VZ : 31|1@0+ (1,0) [0|1] "" XXX - SG_ HCA_Active : 34|1@0+ (1,0) [0|1] "" XXX - SG_ HCA_Standby : 33|1@0+ (1,0) [0|1] "" XXX - SG_ Unknown_Status2 : 63|1@0+ (1,0) [0|1] "" XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" XXX + SG_ Steering_Wheel_Angle : 16|13@1+ (0.15,0) [0|16383] "Unit_DegreOfArc" XXX + SG_ Steering_Wheel_Angle_VZ : 31|1@1+ (1,0) [0|1] "" XXX + SG_ HCA_Active : 34|1@1+ (1,0) [0|1] "" XXX + SG_ HCA_Standby : 33|1@1+ (1,0) [0|1] "" XXX + SG_ Unknown_Status2 : 63|1@1+ (1,0) [0|1] "" XXX SG_ HCA_Ready : 32|1@1+ (1,0) [0|3] "" XXX SG_ Driver_Strain : 40|13@1+ (1,0) [0|255] "Nm" XXX SG_ Driver_Strain_VZ : 55|1@1+ (1,0) [0|1] "" XXX - SG_ Unknown_Status1 : 62|1@0+ (1,0) [0|1] "" XXX + SG_ Unknown_Status1 : 62|1@1+ (1,0) [0|1] "" XXX BO_ 286 VehicleSpeed: 8 XXX SG_ VehicleSpeed_CRC : 0|8@1+ (1,0) [0|255] "" XXX @@ -1190,16 +1215,20 @@ BO_ 286 VehicleSpeed: 8 XXX BO_ 919 LDW_02: 8 XXX SG_ LDW_DLC : 40|8@1+ (0.01,0) [0|255] "m" XXX SG_ LDW_TLC : 48|5@1+ (0.05,0) [0|255] "Seconds" XXX - SG_ LDW_Unknown : 15|2@0+ (1,0) [0|3] "" XXX + SG_ LDW_Unknown : 14|2@1+ (1,0) [0|3] "" XXX SG_ Alert_Message : 16|4@1+ (1,0) [0|15] "" XXX - SG_ LDW_Direction : 20|1@0+ (1,0) [0|1] "" XXX + SG_ LDW_Direction : 20|1@1+ (1,0) [0|1] "" XXX SG_ Right_Lane_Status : 36|2@1+ (1,0) [0|3] "" XXX SG_ Left_Lane_Status : 38|2@1+ (1,0) [0|3] "" XXX - SG_ Kombi_Lamp_Orange : 61|1@0+ (1,0) [0|1] "" XXX - SG_ Kombi_Lamp_Green : 62|1@0+ (1,0) [0|1] "" XXX + SG_ Kombi_Lamp_Orange : 61|1@1+ (1,0) [0|1] "" XXX + SG_ Kombi_Lamp_Green : 62|1@1+ (1,0) [0|1] "" XXX BO_ 780 ACC_02: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" XXX + SG_ SetSpeed : 12|10@1+ (0.08865,0) [0|90.68] "Unit_MeterPerSecond" XXX SG_ Kollision1 : 23|1@1+ (1,0) [0|1] "" XXX + SG_ Abstand : 24|10@1+ (0.1,0) [0|102.3] "m" XXX SG_ ACC_MinusInv : 36|2@1+ (1,0) [0|3] "" XXX SG_ ACC_Minus : 38|2@1+ (1,0) [0|3] "" XXX SG_ Kollision2 : 40|1@1+ (1,0) [0|1] "" XXX @@ -1212,10 +1241,6 @@ BO_ 780 ACC_02: 8 XXX SG_ MotorbitB5_7 : 47|1@1+ (1,0) [0|1] "" XXX SG_ SetAbstand : 48|4@1+ (1,0) [0|15] "" XXX SG_ Hebel : 56|4@1+ (1,0) [0|15] "" XXX - SG_ SetSpeed : 12|10@1+ (0.32,0) [0|320] "kmh" XXX - SG_ Abstand : 24|10@1+ (0.1,0) [0|102.3] "m" XXX - SG_ ACC_02_CRC : 0|8@1+ (1,0) [0|255] "" XXX - SG_ ACC_02_BZ : 8|4@1+ (1,0) [0|15] "" XXX BO_ 302 ACC_07: 8 XXX SG_ ACC_07_BZ : 8|4@1+ (1,0) [0|15] "" XXX @@ -1229,9 +1254,26 @@ BO_ 695 RCTA_01: 8 XXX SG_ RCTA_01_BZ : 8|4@1+ (1,0) [0|15] "" XXX SG_ RCTA_01_CRC : 0|8@1+ (1,0) [0|255] "" XXX -BO_ 783 SWA_01: 8 XXX - SG_ SWA_01_BZ : 8|4@1+ (1,0) [0|15] "" XXX - SG_ SWA_01_CRC : 0|8@1+ (1,0) [0|255] "" XXX +BO_ 783 SWA_01: 8 Gateway_MQB + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Vector__XXX + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Vector__XXX + SG_ SWA_Anzeigen : 12|4@1+ (1,0) [0|15] "" Kombi_D4 + SG_ SWA_Blindheit_erkannt : 16|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ SWA_rel_Nichtverf : 17|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ SWA_rel_Fehler : 18|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ SWA_Sta_aktiv : 19|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ SWA_Sta_passiv : 20|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ SWA_Standziele_li : 24|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ SWA_Kolonne_li : 25|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ SWA_Infostufe_SWA_li : 26|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ SWA_Warnung_SWA_li : 27|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ SWA_Kolonne_mi : 33|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ SWA_Standziele_re : 40|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ SWA_Kolonne_re : 41|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ SWA_Infostufe_SWA_re : 42|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ SWA_Warnung_SWA_re : 43|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ SWA_Gischtzaehler : 48|7@1+ (1,0) [0|100] "Unit_PerCent" Vector__XXX + SG_ SWA_KD_Fehler : 59|1@1+ (1,0) [0|1] "" Vector__XXX BO_ 804 ACC_04: 8 XXX SG_ ACC_04_CRC : 0|8@1+ (1,0) [0|255] "" XXX @@ -1251,9 +1293,47 @@ BO_ 427 ESP_33: 8 XXX SG_ ESP_33_BZ : 8|4@1+ (1,0) [0|15] "" XXX SG_ ESP_33_CRC : 0|8@1+ (1,0) [0|255] "" XXX +BO_ 418 ESP_15: 8 XXX + SG_ ESP_15_CRC : 0|8@1+ (1,0) [0|255] "" XXX + SG_ ESP_15_BZ : 8|4@1+ (1,0) [0|15] "" XXX + +BO_ 1122 PSD_04: 8 XXX + SG_ PSD_Object_Index : 0|6@1+ (1,0) [0|63] "" XXX + +BO_ 1123 PSD_05: 8 XXX + SG_ PSD_Current_Route_Index : 0|6@1+ (1,0) [0|63] "" XXX + SG_ Route_Distance_Remaining : 8|5@1+ (1,0) [0|31] "" XXX + +BO_ 1124 PSD_06: 8 XXX +BO_ 988 Gateway_73: 8 XXX +BO_ 792 Kamera_Status: 8 XXX +BO_ 981 Licht_Anf_01: 8 XXX + +BO_ 1440 RLS_01: 8 XXX + +BO_ 870 Blinkmodi_02: 8 XXX + +BO_ 1385 HVEM_04: 8 XXX + +BO_ 1605 FLA_01: 8 XXX + +BO_ 1624 Licht_vorne_01: 8 XXX + +BO_ 1646 Klima_03: 8 XXX + +BO_ 1720 Kombi_03: 8 XXX + +BO_ 391 EV_Gearshift: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" XXX + SG_ GearPosition : 16|4@1+ (1,0) [0|255] "" XXX + SG_ RegenBrakingMode : 12|2@1+ (1,0) [0|3] "" XXX + +CM_ SG_ 173 COUNTERXX "Message not renamed to COUNTER because J533 rate-limiting makes it look like messages are being lost"; +CM_ SG_ 134 LWI_Lenkradwinkel "Steering angle WITH variable ratio effect included"; CM_ SG_ 294 3 "May be zero when sent by older cameras"; CM_ SG_ 294 7 "May be zero when sent by older cameras"; CM_ SG_ 294 254 "May be zero when sent by older cameras"; @@ -1263,6 +1343,7 @@ CM_ SG_ 294 HCA_Available "Must be 1 for steering rack to accept HCA commands"; CM_ SG_ 159 HCA_Ready "1 if HCA is okay, 0 if the rack doesn't have HCA configured or a timer/constraint has been violated, rack will not respond to HCA commands"; CM_ SG_ 159 Driver_Strain "Steering input by driver, torque"; CM_ SG_ 159 Driver_Strain_VZ "Steering input by driver, sign (direction)"; +CM_ SG_ 159 Steering_Wheel_Angle "Steering angle WITHOUT variable ratio effect included"; CM_ SG_ 919 LDW_DLC "Probable DLC (distance to line crossing)"; CM_ SG_ 919 LDW_TLC "Probable TLC (time to line crossing)"; CM_ SG_ 919 LDW_Unknown "Might be a steering pressed / driver active flag"; @@ -1274,6 +1355,10 @@ CM_ SG_ 919 Kombi_Lamp_Orange "Enables orange LDW light in instrument cluster"; CM_ SG_ 919 Kombi_Lamp_Green "Enables green LDW light in instrument cluster"; CM_ SG_ 780 Folgefahrt "Following another vehicle"; CM_ SG_ 780 SetAbstand "Set following distance"; -CM_ SG_ 780 SetSpeed "ACC set speed"; CM_ SG_ 780 Abstand "Following distance"; -VAL_ 173 GE_Fahrstufe 5 "P" 6 "R" 7 "N" 8 "D" 9 "S" 10 "E" 14 "T" ; +CM_ SG_ 780 SetSpeed "ACC set speed"; +CM_ SG_ 391 GearPosition "Traditional PRND plus B-mode aggressive regen, B-mode mapped to Drive"; +CM_ SG_ 960 ZAS_Kl_15 "Indicates ignition on"; +VAL_ 173 GE_Fahrstufe 5 "P" 6 "R" 7 "N" 8 "D" 9 "S" 10 "E" 14 "T"; +VAL_ 391 GearPosition 2 "P" 3 "R" 4 "N" 5 "D" 6 "D"; +VAL_ 391 RegenBrakingMode 0 "default" 1 "B1" 2 "B2" 3 "B3"; diff --git a/panda/.circleci/config.yml b/panda/.circleci/config.yml deleted file mode 100644 index d74c1a20e09686..00000000000000 --- a/panda/.circleci/config.yml +++ /dev/null @@ -1,103 +0,0 @@ -version: 2 -jobs: - safety: - machine: - docker_layer_caching: true - steps: - - checkout - - run: - name: Build image - command: "docker build -t panda_safety -f tests/safety/Dockerfile ." - - run: - 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 cppcheck test output - path: /tmp/misra/cppcheck_output.txt - - store_artifacts: - name: Store misra test output - path: /tmp/misra/misra_output.txt - - build: - machine: - docker_layer_caching: true - steps: - - checkout - - run: - name: Build image - command: "docker build -t panda_build -f tests/build/Dockerfile ." - - run: - name: Test python package installer - command: | - docker run panda_build /bin/bash -c "cd /panda; python setup.py install" - - run: - name: Build Panda STM image - command: | - docker run panda_build /bin/bash -c "cd /panda/board; make bin" - - run: - name: Build Panda STM bootstub image - command: | - docker run panda_build /bin/bash -c "cd /panda/board; make obj/bootstub.panda.bin" - - run: - name: Build Pedal STM image - command: | - docker run panda_build /bin/bash -c "cd /panda/board/pedal; make obj/comma.bin" - - run: - 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 ESP image - command: | - docker run panda_build /bin/bash -c "cd /panda/boardesp; make user1.bin" - - safety_replay: - machine: - docker_layer_caching: true - steps: - - checkout - - run: - name: Build image - command: "docker build -t panda_safety_replay -f tests/safety_replay/Dockerfile ." - - run: - name: Replay drives - command: | - docker run panda_safety_replay /bin/bash -c "cd /openpilot/panda/tests/safety_replay; PYTHONPATH=/openpilot ./test_safety_replay.py" - - language_check: - machine: - docker_layer_caching: true - steps: - - checkout - - run: - name: Build image - command: "docker build -t language_check -f tests/language/Dockerfile ." - - run: - name: Check code for bad language - command: | - docker run language_check /bin/bash -c "cd /panda/tests/language; ./test_language.py" - -workflows: - version: 2 - main: - jobs: - - safety - - misra-c2012 - - build - - safety_replay - - language_check diff --git a/panda/.dockerignore b/panda/.dockerignore deleted file mode 100644 index f04ae5c0aa6892..00000000000000 --- a/panda/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -.git -.DS_Store -boardesp/esp-open-sdk diff --git a/panda/.gitignore b/panda/.gitignore index 70d010fabf3d7f..503ce91c7f0992 100644 --- a/panda/.gitignore +++ b/panda/.gitignore @@ -4,6 +4,7 @@ *.o *.so *.d +*.dump a.out *~ .#* @@ -12,4 +13,6 @@ pandacan.egg-info/ board/obj/ examples/output.csv .DS_Store +.vscode nosetests.xml +.mypy_cache/ diff --git a/panda/Dockerfile b/panda/Dockerfile deleted file mode 100644 index 1a0d924661d6ce..00000000000000 --- a/panda/Dockerfile +++ /dev/null @@ -1,62 +0,0 @@ -FROM ubuntu:16.04 -ENV PYTHONUNBUFFERED 1 - -RUN apt-get update && apt-get install -y \ - autoconf \ - automake \ - bash \ - bison \ - bzip2 \ - curl \ - dfu-util \ - flex \ - g++ \ - gawk \ - gcc \ - git \ - gperf \ - help2man \ - iputils-ping \ - libexpat-dev \ - libstdc++-arm-none-eabi-newlib \ - libtool \ - libtool-bin \ - libusb-1.0-0 \ - make \ - ncurses-dev \ - network-manager \ - python-dev \ - python-serial \ - sed \ - texinfo \ - unrar-free \ - unzip \ - wget \ - build-essential \ - python-dev \ - python-pip \ - screen \ - vim \ - wget \ - wireless-tools - -RUN pip install --upgrade pip==18.0 - -COPY requirements.txt /tmp/ -RUN pip install -r /tmp/requirements.txt - -RUN mkdir -p /home/batman -ENV HOME /home/batman - -ENV PYTHONPATH /tmp:$PYTHONPATH - -COPY ./boardesp/get_sdk_ci.sh /tmp/panda/boardesp/ - -RUN useradd --system -s /sbin/nologin pandauser -RUN mkdir -p /tmp/panda/boardesp/esp-open-sdk -RUN chown pandauser /tmp/panda/boardesp/esp-open-sdk -USER pandauser -RUN cd /tmp/panda/boardesp && ./get_sdk_ci.sh -USER root - -ADD ./panda.tar.gz /tmp/panda diff --git a/panda/Jenkinsfile b/panda/Jenkinsfile deleted file mode 100644 index 19dc3d4c80863c..00000000000000 --- a/panda/Jenkinsfile +++ /dev/null @@ -1,73 +0,0 @@ -pipeline { - agent any - environment { - AUTHOR = """${sh( - returnStdout: true, - script: "git --no-pager show -s --format='%an' ${GIT_COMMIT}" - ).trim()}""" - - 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 archive -v -o panda.tar.gz --format=tar.gz HEAD' - dockerImage = docker.build("${env.DOCKER_IMAGE_TAG}") - } - } - } - } - stage('Test Dev Build (no WIFI)') { - steps { - lock(resource: "Pandas", inversePrecedence: true, quantity: 1){ - timeout(time: 60, unit: 'MINUTES') { - script { - sh "docker run --name ${env.DOCKER_NAME} --privileged --volume /dev/bus/usb:/dev/bus/usb --volume /var/run/dbus:/var/run/dbus --net host ${env.DOCKER_IMAGE_TAG} bash -c 'cd /tmp/panda; SKIPWIFI=1 ./run_automated_tests.sh'" - sh "docker cp ${env.DOCKER_NAME}:/tmp/panda/nosetests.xml test_results_dev_nowifi.xml" - sh "docker rm ${env.DOCKER_NAME}" - } - } - } - } - } - stage('Test EON Build') { - steps { - lock(resource: "Pandas", inversePrecedence: true, quantity: 1){ - timeout(time: 60, unit: 'MINUTES') { - script { - sh "docker run --name ${env.DOCKER_NAME} --privileged --volume /dev/bus/usb:/dev/bus/usb --volume /var/run/dbus:/var/run/dbus --net host ${env.DOCKER_IMAGE_TAG} bash -c 'touch /EON; cd /tmp/panda; ./run_automated_tests.sh'" - sh "docker cp ${env.DOCKER_NAME}:/tmp/panda/nosetests.xml test_results_eon.xml" - sh "docker rm ${env.DOCKER_NAME}" - } - } - } - } - } - stage('Test Dev Build (WIFI)') { - steps { - lock(resource: "Pandas", inversePrecedence: true, quantity: 1){ - timeout(time: 60, unit: 'MINUTES') { - script { - sh "docker run --name ${env.DOCKER_NAME} --privileged --volume /dev/bus/usb:/dev/bus/usb --volume /var/run/dbus:/var/run/dbus --net host ${env.DOCKER_IMAGE_TAG} bash -c 'cd /tmp/panda; ./run_automated_tests.sh'" - sh "docker cp ${env.DOCKER_NAME}:/tmp/panda/nosetests.xml test_results_dev.xml" - sh "docker rm ${env.DOCKER_NAME}" - } - } - } - } - } - } - post { - failure { - script { - sh "docker rm ${env.DOCKER_NAME} || true" - } - } - always { - junit "test_results*.xml" - } - } -} diff --git a/panda/LICENSE b/panda/LICENSE deleted file mode 100644 index 8a6c6976b70de3..00000000000000 --- a/panda/LICENSE +++ /dev/null @@ -1,7 +0,0 @@ -Copyright (c) 2016, Comma.ai, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/panda/README.md b/panda/README.md deleted file mode 100644 index 42f432dfc32a38..00000000000000 --- a/panda/README.md +++ /dev/null @@ -1,95 +0,0 @@ -Welcome to panda -====== - -[panda](http://github.com/commaai/panda) is the nicest universal car interface ever. - - - - - -It supports 3x CAN, 2x LIN, and 1x GMLAN. It also charges a phone. On the computer side, it has both USB and Wi-Fi. - -It uses an [STM32F413](http://www.st.com/en/microcontrollers/stm32f413-423.html?querycriteria=productId=LN2004) for low level stuff and an [ESP8266](https://en.wikipedia.org/wiki/ESP8266) for Wi-Fi. They are connected over high speed SPI, so the panda is actually capable of dumping the full contents of the busses over Wi-Fi, unlike every other dongle on amazon. ELM327 is weak, panda is strong. - -It is 2nd gen hardware, reusing code and parts from the [NEO](https://github.com/commaai/neo) interface board. - -[![CircleCI](https://circleci.com/gh/commaai/panda.svg?style=svg)](https://circleci.com/gh/commaai/panda) - -Usage (Python) ------- - -To install the library: -``` -# pip install pandacan -``` - -See [this class](https://github.com/commaai/panda/blob/master/python/__init__.py#L80) for how to interact with the panda. - -For example, to receive CAN messages: -``` ->>> from panda import Panda ->>> panda = Panda() ->>> panda.can_recv() -``` -And to send one on bus 0: -``` ->>> panda.can_send(0x1aa, "message", 0) -``` -Find user made scripts on the [wiki](https://community.comma.ai/wiki/index.php/Panda_scripts) - -Usage (JavaScript) -------- - -See [PandaJS](https://github.com/commaai/pandajs) - - -Software interface support ------- - -As a universal car interface, it should support every reasonable software interface. - -- [User space](https://github.com/commaai/panda/tree/master/python) -- [socketcan in kernel](https://github.com/commaai/panda/tree/master/drivers/linux) (alpha) -- [ELM327](https://github.com/commaai/panda/blob/master/boardesp/elm327.c) -- [Windows J2534](https://github.com/commaai/panda/tree/master/drivers/windows) - -Directory structure ------- - -- board -- Code that runs on the STM32 -- boardesp -- Code that runs on the ESP8266 -- drivers -- Drivers (not needed for use with python) -- python   -- Python userspace library for interfacing with the panda -- tests -- Tests and helper programs for panda - -Programming (over USB) ------- - -[Programming the Board (STM32)](board/README.md) - -[Programming the ESP](boardesp/README.md) - - -Debugging ------- - -To print out the serial console from the STM32, run tests/debug_console.py - -To print out the serial console from the ESP8266, run PORT=1 tests/debug_console.py - -Safety Model ------- - -When a panda powers up, by default it's in "SAFETY_NOOUTPUT" mode. While in no output mode, the buses are also forced to be silent. In order to send messages, you have to select a safety mode. Currently, setting safety modes is only supported over USB. - -Safety modes can also optionally support "controls_allowed", which allows or blocks a subset of messages based on a piece of state in the board. - -Hardware ------- - -Check out the hardware [guide](https://github.com/commaai/panda/blob/master/docs/guide.pdf) - -Licensing ------- - -panda software is released under the MIT license unless otherwise specified. diff --git a/panda/TODO b/panda/TODO deleted file mode 100644 index 4e4a3551549dc1..00000000000000 --- a/panda/TODO +++ /dev/null @@ -1,31 +0,0 @@ -** Projects ** - -== ELM327 Emulator == - -Write an elm327 emulator in boardesp/elm327.c and make it work with Torque - -You'll find a start at this in the "elm327" branch. - -== socketcan Kernel Driver == - -Write a kernel driver version of lib/panda.py that exposes the Panda on socketcan and makes it work with those tools. - -You may want to switch to interrupt endpoint first. Should LIN be exposed as a serial interface? - -== Windows J2534 DLL == - -Write a Windows DLL that exposes the J2534 API. - -Will make the Panda work with car diagnostic software. - - -** Refactors ** - -== USB Interrupt Endpoint == - -Switch USB to use an interrupt endpoint instead of a bulk endpoint for can recv - -== WebSocket Support == - -Add CAN streaming over WebSocket to the ELM code in addition to the UDP pipe. - diff --git a/panda/UPDATING.md b/panda/UPDATING.md deleted file mode 100644 index 100acc6bab5fbc..00000000000000 --- a/panda/UPDATING.md +++ /dev/null @@ -1,9 +0,0 @@ -# Updating your panda - -Panda should update automatically via the [Chffr](http://chffr.comma.ai/) app ([apple](https://itunes.apple.com/us/app/chffr-dash-cam-that-remembers/id1146683979) and [android](https://play.google.com/store/apps/details?id=ai.comma.chffr)) - -If it doesn't however, you can use the following commands on linux or Mac OSX - `sudo pip install --upgrade pandacan` -` PYTHONPATH="" sudo python -c "import panda; panda.flash_release()"` - -(You'll need to have `pip` and `sudo` installed.) diff --git a/panda/VERSION b/panda/VERSION index 5beebea89c0857..ad90322ab87e78 100644 --- a/panda/VERSION +++ b/panda/VERSION @@ -1 +1 @@ -v1.4.3 \ No newline at end of file +v1.7.5 \ No newline at end of file diff --git a/panda/__init__.py b/panda/__init__.py index b802cf5a59582a..09466ddd579f72 100644 --- a/panda/__init__.py +++ b/panda/__init__.py @@ -1 +1,3 @@ -from .python import Panda, PandaWifiStreaming, PandaDFU, ESPROM, CesantaFlasher, flash_release, BASEDIR, ensure_st_up_to_date, build_st, PandaSerial +# flake8: noqa +# pylint: skip-file +from .python import Panda, PandaWifiStreaming, PandaDFU, flash_release, BASEDIR, ensure_st_up_to_date, build_st, PandaSerial diff --git a/panda/board/README.md b/panda/board/README.md index 5fe2e4b238c2dd..7151bfbf93e32a 100644 --- a/panda/board/README.md +++ b/panda/board/README.md @@ -4,6 +4,7 @@ Dependencies **Mac** ``` +xcode-select --install ./get_sdk_mac.sh ``` diff --git a/panda/board/board.h b/panda/board/board.h index 5379f94643bb04..19392c9eaa2dc6 100644 --- a/panda/board/board.h +++ b/panda/board/board.h @@ -7,22 +7,35 @@ // ///// Board definition and detection ///// // #include "drivers/harness.h" #ifdef PANDA + #include "drivers/fan.h" + #include "drivers/rtc.h" + #include "drivers/clock_source.h" #include "boards/white.h" #include "boards/grey.h" #include "boards/black.h" + #include "boards/uno.h" + #include "boards/dos.h" #else #include "boards/pedal.h" #endif void detect_board_type(void) { #ifdef PANDA - // SPI lines floating: white (TODO: is this reliable?) - if((detect_with_pull(GPIOA, 4, PULL_DOWN)) || (detect_with_pull(GPIOA, 5, PULL_DOWN)) || (detect_with_pull(GPIOA, 6, PULL_DOWN)) || (detect_with_pull(GPIOA, 7, PULL_DOWN))){ + // SPI lines floating: white (TODO: is this reliable? Not really, we have to enable ESP/GPS to be able to detect this on the UART) + set_gpio_output(GPIOC, 14, 1); + set_gpio_output(GPIOC, 5, 1); + if(!detect_with_pull(GPIOB, 1, PULL_UP) && !detect_with_pull(GPIOB, 7, PULL_UP)){ + hw_type = HW_TYPE_DOS; + current_board = &board_dos; + } else if((detect_with_pull(GPIOA, 4, PULL_DOWN)) || (detect_with_pull(GPIOA, 5, PULL_DOWN)) || (detect_with_pull(GPIOA, 6, PULL_DOWN)) || (detect_with_pull(GPIOA, 7, PULL_DOWN))){ hw_type = HW_TYPE_WHITE_PANDA; current_board = &board_white; } else if(detect_with_pull(GPIOA, 13, PULL_DOWN)) { // Rev AB deprecated, so no pullup means black. In REV C, A13 is pulled up to 5V with a 10K hw_type = HW_TYPE_GREY_PANDA; current_board = &board_grey; + } else if(!detect_with_pull(GPIOB, 15, PULL_UP)) { + hw_type = HW_TYPE_UNO; + current_board = &board_uno; } else { hw_type = HW_TYPE_BLACK_PANDA; current_board = &board_black; @@ -31,7 +44,7 @@ void detect_board_type(void) { #ifdef PEDAL hw_type = HW_TYPE_PEDAL; current_board = &board_pedal; - #else + #else hw_type = HW_TYPE_UNKNOWN; puts("Hardware type is UNKNOWN!\n"); #endif @@ -41,21 +54,34 @@ void detect_board_type(void) { // ///// Configuration detection ///// // bool has_external_debug_serial = 0; -bool is_entering_bootmode = 0; void detect_configuration(void) { // detect if external serial debugging is present has_external_debug_serial = detect_with_pull(GPIOA, 3, PULL_DOWN); - - #ifdef PANDA - // check if the ESP is trying to put me in boot mode - is_entering_bootmode = !detect_with_pull(GPIOB, 0, PULL_UP); - #else - is_entering_bootmode = 0; - #endif } // ///// Board functions ///// // +// TODO: Make these config options in the board struct bool board_has_gps(void) { - return ((hw_type == HW_TYPE_GREY_PANDA) || (hw_type == HW_TYPE_BLACK_PANDA)); + return ((hw_type == HW_TYPE_GREY_PANDA) || (hw_type == HW_TYPE_BLACK_PANDA) || (hw_type == HW_TYPE_UNO)); +} + +bool board_has_gmlan(void) { + return ((hw_type == HW_TYPE_WHITE_PANDA) || (hw_type == HW_TYPE_GREY_PANDA)); +} + +bool board_has_obd(void) { + return ((hw_type == HW_TYPE_BLACK_PANDA) || (hw_type == HW_TYPE_UNO) || (hw_type == HW_TYPE_DOS)); +} + +bool board_has_lin(void) { + return ((hw_type == HW_TYPE_WHITE_PANDA) || (hw_type == HW_TYPE_GREY_PANDA)); +} + +bool board_has_rtc(void) { + return ((hw_type == HW_TYPE_UNO) || (hw_type == HW_TYPE_DOS)); +} + +bool board_has_relay(void) { + return ((hw_type == HW_TYPE_BLACK_PANDA) || (hw_type == HW_TYPE_UNO) || (hw_type == HW_TYPE_DOS)); } diff --git a/panda/board/board_declarations.h b/panda/board/board_declarations.h index 7a44113f613bf2..963539e00805af 100644 --- a/panda/board/board_declarations.h +++ b/panda/board/board_declarations.h @@ -1,51 +1,65 @@ // ******************** Prototypes ******************** typedef void (*board_init)(void); -typedef void (*board_enable_can_transciever)(uint8_t transciever, bool enabled); -typedef void (*board_enable_can_transcievers)(bool enabled); +typedef void (*board_enable_can_transceiver)(uint8_t transceiver, bool enabled); +typedef void (*board_enable_can_transceivers)(bool enabled); typedef void (*board_set_led)(uint8_t color, bool enabled); typedef void (*board_set_usb_power_mode)(uint8_t mode); -typedef void (*board_set_esp_gps_mode)(uint8_t mode); +typedef void (*board_set_gps_mode)(uint8_t mode); typedef void (*board_set_can_mode)(uint8_t mode); -typedef void (*board_usb_power_mode_tick)(uint64_t tcnt); +typedef void (*board_usb_power_mode_tick)(uint32_t uptime); typedef bool (*board_check_ignition)(void); +typedef uint32_t (*board_read_current)(void); +typedef void (*board_set_ir_power)(uint8_t percentage); +typedef void (*board_set_fan_power)(uint8_t percentage); +typedef void (*board_set_phone_power)(bool enabled); +typedef void (*board_set_clock_source_mode)(uint8_t mode); +typedef void (*board_set_siren)(bool enabled); struct board { const char *board_type; const harness_configuration *harness_config; board_init init; - board_enable_can_transciever enable_can_transciever; - board_enable_can_transcievers enable_can_transcievers; + board_enable_can_transceiver enable_can_transceiver; + board_enable_can_transceivers enable_can_transceivers; board_set_led set_led; board_set_usb_power_mode set_usb_power_mode; - board_set_esp_gps_mode set_esp_gps_mode; + board_set_gps_mode set_gps_mode; board_set_can_mode set_can_mode; board_usb_power_mode_tick usb_power_mode_tick; board_check_ignition check_ignition; + board_read_current read_current; + board_set_ir_power set_ir_power; + board_set_fan_power set_fan_power; + board_set_phone_power set_phone_power; + board_set_clock_source_mode set_clock_source_mode; + board_set_siren set_siren; }; // ******************* Definitions ******************** -// These should match the enum in cereal/log.capnp +// These should match the enums in cereal/log.capnp and __init__.py #define HW_TYPE_UNKNOWN 0U #define HW_TYPE_WHITE_PANDA 1U #define HW_TYPE_GREY_PANDA 2U #define HW_TYPE_BLACK_PANDA 3U #define HW_TYPE_PEDAL 4U +#define HW_TYPE_UNO 5U +#define HW_TYPE_DOS 6U // LED colors #define LED_RED 0U #define LED_GREEN 1U #define LED_BLUE 2U -// USB power modes +// USB power modes (from cereal.log.health) #define USB_POWER_NONE 0U #define USB_POWER_CLIENT 1U #define USB_POWER_CDP 2U #define USB_POWER_DCP 3U -// ESP modes -#define ESP_GPS_DISABLED 0U -#define ESP_GPS_ENABLED 1U -#define ESP_GPS_BOOTMODE 2U +// GPS modes +#define GPS_DISABLED 0U +#define GPS_ENABLED 1U +#define GPS_BOOTMODE 2U // CAN modes #define CAN_MODE_NORMAL 0U @@ -54,4 +68,12 @@ struct board { #define CAN_MODE_OBD_CAN2 3U // ********************* Globals ********************** -uint8_t usb_power_mode = USB_POWER_NONE; \ No newline at end of file +uint8_t usb_power_mode = USB_POWER_NONE; + +// ************ Board function prototypes ************* +bool board_has_gps(void); +bool board_has_gmlan(void); +bool board_has_obd(void); +bool board_has_lin(void); +bool board_has_rtc(void); +bool board_has_relay(void); diff --git a/panda/board/boards/black.h b/panda/board/boards/black.h index 0372aa3d079ae2..fa5a542d05dd4e 100644 --- a/panda/board/boards/black.h +++ b/panda/board/boards/black.h @@ -2,8 +2,8 @@ // Black Panda + Harness // // ///////////////////// // -void black_enable_can_transciever(uint8_t transciever, bool enabled) { - switch (transciever){ +void black_enable_can_transceiver(uint8_t transceiver, bool enabled) { + switch (transceiver){ case 1U: set_gpio_output(GPIOC, 1, !enabled); break; @@ -17,14 +17,20 @@ void black_enable_can_transciever(uint8_t transciever, bool enabled) { set_gpio_output(GPIOB, 10, !enabled); break; default: - puts("Invalid CAN transciever ("); puth(transciever); puts("): enabling failed\n"); + puts("Invalid CAN transceiver ("); puth(transceiver); puts("): enabling failed\n"); break; } } -void black_enable_can_transcievers(bool enabled) { - for(uint8_t i=1; i<=4U; i++) - black_enable_can_transciever(i, enabled); +void black_enable_can_transceivers(bool enabled) { + for(uint8_t i=1U; i<=4U; i++){ + // Leave main CAN always on for CAN-based ignition detection + if((car_harness_status == HARNESS_STATUS_FLIPPED) ? (i == 3U) : (i == 1U)){ + black_enable_can_transceiver(i, true); + } else { + black_enable_can_transceiver(i, enabled); + } + } } void black_set_led(uint8_t color, bool enabled) { @@ -37,35 +43,58 @@ void black_set_led(uint8_t color, bool enabled) { break; case LED_BLUE: set_gpio_output(GPIOC, 6, !enabled); - break; + break; default: break; } } -void black_set_usb_power_mode(uint8_t mode){ - usb_power_mode = mode; - puts("Trying to set USB power mode on black panda. This is not supported.\n"); +void black_set_gps_load_switch(bool enabled) { + set_gpio_output(GPIOC, 12, enabled); +} + +void black_set_usb_load_switch(bool enabled) { + set_gpio_output(GPIOB, 1, !enabled); +} + +void black_set_usb_power_mode(uint8_t mode) { + bool valid = false; + switch (mode) { + case USB_POWER_CLIENT: + black_set_usb_load_switch(false); + valid = true; + break; + case USB_POWER_CDP: + black_set_usb_load_switch(true); + valid = true; + break; + default: + puts("Invalid USB power mode\n"); + break; + } + if (valid) { + usb_power_mode = mode; + } } -void black_set_esp_gps_mode(uint8_t mode) { +void black_set_gps_mode(uint8_t mode) { switch (mode) { - case ESP_GPS_DISABLED: - // ESP OFF + case GPS_DISABLED: + // GPS OFF set_gpio_output(GPIOC, 14, 0); set_gpio_output(GPIOC, 5, 0); break; - case ESP_GPS_ENABLED: - // ESP ON + case GPS_ENABLED: + // GPS ON set_gpio_output(GPIOC, 14, 1); set_gpio_output(GPIOC, 5, 1); break; - case ESP_GPS_BOOTMODE: + case GPS_BOOTMODE: set_gpio_output(GPIOC, 14, 1); set_gpio_output(GPIOC, 5, 0); break; default: - puts("Invalid ESP/GPS mode\n"); + puts("Invalid GPS mode\n"); break; } } @@ -74,7 +103,7 @@ void black_set_can_mode(uint8_t mode){ switch (mode) { case CAN_MODE_NORMAL: case CAN_MODE_OBD_CAN2: - if ((bool)(mode == CAN_MODE_NORMAL) != (bool)(car_harness_status == HARNESS_STATUS_NORMAL)) { + if ((bool)(mode == CAN_MODE_NORMAL) != (bool)(car_harness_status == HARNESS_STATUS_FLIPPED)) { // B12,B13: disable OBD mode set_gpio_mode(GPIOB, 12, MODE_INPUT); set_gpio_mode(GPIOB, 13, MODE_INPUT); @@ -90,7 +119,7 @@ void black_set_can_mode(uint8_t mode){ // B12,B13: OBD mode set_gpio_alternate(GPIOB, 12, GPIO_AF9_CAN2); set_gpio_alternate(GPIOB, 13, GPIO_AF9_CAN2); - } + } break; default: puts("Tried to set unsupported CAN mode: "); puth(mode); puts("\n"); @@ -98,8 +127,8 @@ void black_set_can_mode(uint8_t mode){ } } -void black_usb_power_mode_tick(uint64_t tcnt){ - UNUSED(tcnt); +void black_usb_power_mode_tick(uint32_t uptime){ + UNUSED(uptime); // Not applicable } @@ -108,6 +137,31 @@ bool black_check_ignition(void){ return harness_check_ignition(); } +uint32_t black_read_current(void){ + // No current sense on black panda + return 0U; +} + +void black_set_ir_power(uint8_t percentage){ + UNUSED(percentage); +} + +void black_set_fan_power(uint8_t percentage){ + UNUSED(percentage); +} + +void black_set_phone_power(bool enabled){ + UNUSED(enabled); +} + +void black_set_clock_source_mode(uint8_t mode){ + UNUSED(mode); +} + +void black_set_siren(bool enabled){ + UNUSED(enabled); +} + void black_init(void) { common_init_gpio(); @@ -120,6 +174,9 @@ void black_init(void) { set_gpio_mode(GPIOC, 0, MODE_ANALOG); set_gpio_mode(GPIOC, 3, MODE_ANALOG); + // Set default state of GPS + current_board->set_gps_mode(GPS_ENABLED); + // C10: OBD_SBU1_RELAY (harness relay driving output) // C11: OBD_SBU2_RELAY (harness relay driving output) set_gpio_mode(GPIOC, 10, MODE_OUTPUT); @@ -129,18 +186,20 @@ void black_init(void) { set_gpio_output(GPIOC, 10, 1); set_gpio_output(GPIOC, 11, 1); - // C8: FAN aka TIM3_CH3 - set_gpio_alternate(GPIOC, 8, GPIO_AF2_TIM3); + // Turn on GPS load switch. + black_set_gps_load_switch(true); + + // Turn on USB load switch. + black_set_usb_load_switch(true); - // C12: GPS load switch. Turn on permanently for now - set_gpio_output(GPIOC, 12, true); - //set_gpio_output(GPIOC, 12, false); //TODO: stupid inverted switch on prototype + // Set right power mode + black_set_usb_power_mode(USB_POWER_CDP); // Initialize harness harness_init(); - // Enable CAN transcievers - black_enable_can_transcievers(true); + // Enable CAN transceivers + black_enable_can_transceivers(true); // Disable LEDs black_set_led(LED_RED, false); @@ -151,7 +210,7 @@ void black_init(void) { black_set_can_mode(CAN_MODE_NORMAL); // flip CAN0 and CAN2 if we are flipped - if (car_harness_status == HARNESS_STATUS_NORMAL) { + if (car_harness_status == HARNESS_STATUS_FLIPPED) { can_flip_buses(0, 2); } @@ -163,12 +222,12 @@ const harness_configuration black_harness_config = { .has_harness = true, .GPIO_SBU1 = GPIOC, .GPIO_SBU2 = GPIOC, - .GPIO_relay_normal = GPIOC, - .GPIO_relay_flipped = GPIOC, + .GPIO_relay_SBU1 = GPIOC, + .GPIO_relay_SBU2 = GPIOC, .pin_SBU1 = 0, .pin_SBU2 = 3, - .pin_relay_normal = 10, - .pin_relay_flipped = 11, + .pin_relay_SBU1 = 10, + .pin_relay_SBU2 = 11, .adc_channel_SBU1 = 10, .adc_channel_SBU2 = 13 }; @@ -177,12 +236,18 @@ const board board_black = { .board_type = "Black", .harness_config = &black_harness_config, .init = black_init, - .enable_can_transciever = black_enable_can_transciever, - .enable_can_transcievers = black_enable_can_transcievers, + .enable_can_transceiver = black_enable_can_transceiver, + .enable_can_transceivers = black_enable_can_transceivers, .set_led = black_set_led, .set_usb_power_mode = black_set_usb_power_mode, - .set_esp_gps_mode = black_set_esp_gps_mode, + .set_gps_mode = black_set_gps_mode, .set_can_mode = black_set_can_mode, .usb_power_mode_tick = black_usb_power_mode_tick, - .check_ignition = black_check_ignition -}; \ No newline at end of file + .check_ignition = black_check_ignition, + .read_current = black_read_current, + .set_fan_power = black_set_fan_power, + .set_ir_power = black_set_ir_power, + .set_phone_power = black_set_phone_power, + .set_clock_source_mode = black_set_clock_source_mode, + .set_siren = black_set_siren +}; diff --git a/panda/board/boards/common.h b/panda/board/boards/common.h index d176e4eaf561a0..2f35c34febd780 100644 --- a/panda/board/boards/common.h +++ b/panda/board/boards/common.h @@ -23,7 +23,7 @@ void common_init_gpio(void){ set_gpio_alternate(GPIOA, 12, GPIO_AF10_OTG_FS); GPIOA->OSPEEDR = GPIO_OSPEEDER_OSPEEDR11 | GPIO_OSPEEDER_OSPEEDR12; - // A9,A10: USART 1 for talking to the ESP / GPS + // A9,A10: USART 1 for talking to the GPS set_gpio_alternate(GPIOA, 9, GPIO_AF7_USART1); set_gpio_alternate(GPIOA, 10, GPIO_AF7_USART1); @@ -58,20 +58,22 @@ void peripherals_init(void){ #endif RCC->APB1ENR |= RCC_APB1ENR_DACEN; 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->APB1ENR |= RCC_APB1ENR_TIM3EN; // pedal and fan PWM + RCC->APB1ENR |= RCC_APB1ENR_TIM4EN; // gmlan_alt and IR PWM + RCC->APB1ENR |= RCC_APB1ENR_TIM5EN; // k-line init + RCC->APB1ENR |= RCC_APB1ENR_TIM6EN; // interrupt timer + RCC->APB1ENR |= RCC_APB1ENR_PWREN; // for RTC config RCC->APB2ENR |= RCC_APB2ENR_USART1EN; RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN; - //RCC->APB2ENR |= RCC_APB2ENR_TIM1EN; + RCC->APB2ENR |= RCC_APB2ENR_TIM1EN; // clock source timer RCC->APB2ENR |= RCC_APB2ENR_ADC1EN; RCC->APB2ENR |= RCC_APB2ENR_SPI1EN; RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN; + RCC->APB2ENR |= RCC_APB2ENR_TIM9EN; // slow loop } // Detection with internal pullup -#define PULL_EFFECTIVE_DELAY 10 +#define PULL_EFFECTIVE_DELAY 4096 bool detect_with_pull(GPIO_TypeDef *GPIO, int pin, int mode) { set_gpio_mode(GPIO, pin, MODE_INPUT); set_gpio_pullup(GPIO, pin, mode); @@ -79,4 +81,4 @@ bool detect_with_pull(GPIO_TypeDef *GPIO, int pin, int mode) { bool ret = get_gpio_input(GPIO, pin); set_gpio_pullup(GPIO, pin, PULL_NONE); return ret; -} \ No newline at end of file +} diff --git a/panda/board/boards/dos.h b/panda/board/boards/dos.h new file mode 100644 index 00000000000000..307ae724713d4e --- /dev/null +++ b/panda/board/boards/dos.h @@ -0,0 +1,230 @@ +// ///////////// // +// Dos + Harness // +// ///////////// // + +void dos_enable_can_transceiver(uint8_t transceiver, bool enabled) { + switch (transceiver){ + case 1U: + set_gpio_output(GPIOC, 1, !enabled); + break; + case 2U: + set_gpio_output(GPIOC, 13, !enabled); + break; + case 3U: + set_gpio_output(GPIOA, 0, !enabled); + break; + case 4U: + set_gpio_output(GPIOB, 10, !enabled); + break; + default: + puts("Invalid CAN transceiver ("); puth(transceiver); puts("): enabling failed\n"); + break; + } +} + +void dos_enable_can_transceivers(bool enabled) { + for(uint8_t i=1U; i<=4U; i++){ + // Leave main CAN always on for CAN-based ignition detection + if((car_harness_status == HARNESS_STATUS_FLIPPED) ? (i == 3U) : (i == 1U)){ + uno_enable_can_transceiver(i, true); + } else { + uno_enable_can_transceiver(i, enabled); + } + } +} + +void dos_set_led(uint8_t color, bool enabled) { + switch (color){ + case LED_RED: + set_gpio_output(GPIOC, 9, !enabled); + break; + case LED_GREEN: + set_gpio_output(GPIOC, 7, !enabled); + break; + case LED_BLUE: + set_gpio_output(GPIOC, 6, !enabled); + break; + default: + break; + } +} + +void dos_set_gps_load_switch(bool enabled) { + UNUSED(enabled); +} + +void dos_set_bootkick(bool enabled){ + set_gpio_output(GPIOC, 4, !enabled); +} + +void dos_set_phone_power(bool enabled){ + UNUSED(enabled); +} + +void dos_set_usb_power_mode(uint8_t mode) { + dos_set_bootkick(mode == USB_POWER_CDP); +} + +void dos_set_gps_mode(uint8_t mode) { + UNUSED(mode); +} + +void dos_set_can_mode(uint8_t mode){ + switch (mode) { + case CAN_MODE_NORMAL: + case CAN_MODE_OBD_CAN2: + if ((bool)(mode == CAN_MODE_NORMAL) != (bool)(car_harness_status == HARNESS_STATUS_FLIPPED)) { + // B12,B13: disable OBD mode + set_gpio_mode(GPIOB, 12, MODE_INPUT); + set_gpio_mode(GPIOB, 13, MODE_INPUT); + + // B5,B6: normal CAN2 mode + set_gpio_alternate(GPIOB, 5, GPIO_AF9_CAN2); + set_gpio_alternate(GPIOB, 6, GPIO_AF9_CAN2); + } else { + // B5,B6: disable normal CAN2 mode + set_gpio_mode(GPIOB, 5, MODE_INPUT); + set_gpio_mode(GPIOB, 6, MODE_INPUT); + + // B12,B13: OBD mode + set_gpio_alternate(GPIOB, 12, GPIO_AF9_CAN2); + set_gpio_alternate(GPIOB, 13, GPIO_AF9_CAN2); + } + break; + default: + puts("Tried to set unsupported CAN mode: "); puth(mode); puts("\n"); + break; + } +} + +void dos_usb_power_mode_tick(uint32_t uptime){ + UNUSED(uptime); +} + +bool dos_check_ignition(void){ + // ignition is checked through harness + return harness_check_ignition(); +} + +void dos_set_usb_switch(bool phone){ + set_gpio_output(GPIOB, 3, phone); +} + +void dos_set_ir_power(uint8_t percentage){ + pwm_set(TIM4, 2, percentage); +} + +void dos_set_fan_power(uint8_t percentage){ + // Enable fan power only if percentage is non-zero. + set_gpio_output(GPIOA, 1, (percentage != 0U)); + fan_set_power(percentage); +} + +uint32_t dos_read_current(void){ + // No current sense on Dos + return 0U; +} + +void dos_set_clock_source_mode(uint8_t mode){ + clock_source_init(mode); +} + +void dos_set_siren(bool enabled){ + set_gpio_output(GPIOC, 12, enabled); +} + +void dos_init(void) { + common_init_gpio(); + + // A8,A15: normal CAN3 mode + set_gpio_alternate(GPIOA, 8, GPIO_AF11_CAN3); + set_gpio_alternate(GPIOA, 15, GPIO_AF11_CAN3); + + // C0: OBD_SBU1 (orientation detection) + // C3: OBD_SBU2 (orientation detection) + set_gpio_mode(GPIOC, 0, MODE_ANALOG); + set_gpio_mode(GPIOC, 3, MODE_ANALOG); + + // C10: OBD_SBU1_RELAY (harness relay driving output) + // C11: OBD_SBU2_RELAY (harness relay driving output) + set_gpio_mode(GPIOC, 10, MODE_OUTPUT); + set_gpio_mode(GPIOC, 11, MODE_OUTPUT); + set_gpio_output_type(GPIOC, 10, OUTPUT_TYPE_OPEN_DRAIN); + set_gpio_output_type(GPIOC, 11, OUTPUT_TYPE_OPEN_DRAIN); + set_gpio_output(GPIOC, 10, 1); + set_gpio_output(GPIOC, 11, 1); + + // C8: FAN PWM aka TIM3_CH3 + set_gpio_alternate(GPIOC, 8, GPIO_AF2_TIM3); + + // Initialize IR PWM and set to 0% + set_gpio_alternate(GPIOB, 7, GPIO_AF2_TIM4); + pwm_init(TIM4, 2); + dos_set_ir_power(0U); + + // Initialize fan and set to 0% + fan_init(); + dos_set_fan_power(0U); + + // Initialize harness + harness_init(); + + // Initialize RTC + rtc_init(); + + // Enable CAN transceivers + dos_enable_can_transceivers(true); + + // Disable LEDs + dos_set_led(LED_RED, false); + dos_set_led(LED_GREEN, false); + dos_set_led(LED_BLUE, false); + + // Set normal CAN mode + dos_set_can_mode(CAN_MODE_NORMAL); + + // flip CAN0 and CAN2 if we are flipped + if (car_harness_status == HARNESS_STATUS_FLIPPED) { + can_flip_buses(0, 2); + } + + // init multiplexer + can_set_obd(car_harness_status, false); + + // Init clock source as internal free running + dos_set_clock_source_mode(CLOCK_SOURCE_MODE_FREE_RUNNING); +} + +const harness_configuration dos_harness_config = { + .has_harness = true, + .GPIO_SBU1 = GPIOC, + .GPIO_SBU2 = GPIOC, + .GPIO_relay_SBU1 = GPIOC, + .GPIO_relay_SBU2 = GPIOC, + .pin_SBU1 = 0, + .pin_SBU2 = 3, + .pin_relay_SBU1 = 10, + .pin_relay_SBU2 = 11, + .adc_channel_SBU1 = 10, + .adc_channel_SBU2 = 13 +}; + +const board board_dos = { + .board_type = "Dos", + .harness_config = &dos_harness_config, + .init = dos_init, + .enable_can_transceiver = dos_enable_can_transceiver, + .enable_can_transceivers = dos_enable_can_transceivers, + .set_led = dos_set_led, + .set_usb_power_mode = dos_set_usb_power_mode, + .set_gps_mode = dos_set_gps_mode, + .set_can_mode = dos_set_can_mode, + .usb_power_mode_tick = dos_usb_power_mode_tick, + .check_ignition = dos_check_ignition, + .read_current = dos_read_current, + .set_fan_power = dos_set_fan_power, + .set_ir_power = dos_set_ir_power, + .set_phone_power = dos_set_phone_power, + .set_clock_source_mode = dos_set_clock_source_mode, + .set_siren = dos_set_siren +}; diff --git a/panda/board/boards/grey.h b/panda/board/boards/grey.h index 1927b5459196bb..bd5b1559eba63d 100644 --- a/panda/board/boards/grey.h +++ b/panda/board/boards/grey.h @@ -3,16 +3,52 @@ // ////////// // // Most hardware functionality is similar to white panda + +void grey_init(void) { + white_grey_common_init(); + + // Set default state of GPS + current_board->set_gps_mode(GPS_ENABLED); +} + +void grey_set_gps_mode(uint8_t mode) { + switch (mode) { + case GPS_DISABLED: + // GPS OFF + set_gpio_output(GPIOC, 14, 0); + set_gpio_output(GPIOC, 5, 0); + break; + case GPS_ENABLED: + // GPS ON + set_gpio_output(GPIOC, 14, 1); + set_gpio_output(GPIOC, 5, 1); + break; + case GPS_BOOTMODE: + set_gpio_output(GPIOC, 14, 1); + set_gpio_output(GPIOC, 5, 0); + break; + default: + puts("Invalid ESP/GPS mode\n"); + break; + } +} + const board board_grey = { .board_type = "Grey", .harness_config = &white_harness_config, - .init = white_init, - .enable_can_transciever = white_enable_can_transciever, - .enable_can_transcievers = white_enable_can_transcievers, + .init = grey_init, + .enable_can_transceiver = white_enable_can_transceiver, + .enable_can_transceivers = white_enable_can_transceivers, .set_led = white_set_led, .set_usb_power_mode = white_set_usb_power_mode, - .set_esp_gps_mode = white_set_esp_gps_mode, + .set_gps_mode = grey_set_gps_mode, .set_can_mode = white_set_can_mode, .usb_power_mode_tick = white_usb_power_mode_tick, - .check_ignition = white_check_ignition -}; \ No newline at end of file + .check_ignition = white_check_ignition, + .read_current = white_read_current, + .set_fan_power = white_set_fan_power, + .set_ir_power = white_set_ir_power, + .set_phone_power = white_set_phone_power, + .set_clock_source_mode = white_set_clock_source_mode, + .set_siren = white_set_siren +}; diff --git a/panda/board/boards/pedal.h b/panda/board/boards/pedal.h index 9209a33ba79fdf..31abe9c5c710fd 100644 --- a/panda/board/boards/pedal.h +++ b/panda/board/boards/pedal.h @@ -2,19 +2,19 @@ // Pedal // // ///// // -void pedal_enable_can_transciever(uint8_t transciever, bool enabled) { - switch (transciever){ +void pedal_enable_can_transceiver(uint8_t transceiver, bool enabled) { + switch (transceiver){ case 1: set_gpio_output(GPIOB, 3, !enabled); break; default: - puts("Invalid CAN transciever ("); puth(transciever); puts("): enabling failed\n"); + puts("Invalid CAN transceiver ("); puth(transceiver); puts("): enabling failed\n"); break; } } -void pedal_enable_can_transcievers(bool enabled) { - pedal_enable_can_transciever(1U, enabled); +void pedal_enable_can_transceivers(bool enabled) { + pedal_enable_can_transceiver(1U, enabled); } void pedal_set_led(uint8_t color, bool enabled) { @@ -35,7 +35,7 @@ void pedal_set_usb_power_mode(uint8_t mode){ puts("Trying to set USB power mode on pedal. This is not supported.\n"); } -void pedal_set_esp_gps_mode(uint8_t mode) { +void pedal_set_gps_mode(uint8_t mode) { UNUSED(mode); puts("Trying to set ESP/GPS mode on pedal. This is not supported.\n"); } @@ -50,8 +50,8 @@ void pedal_set_can_mode(uint8_t mode){ } } -void pedal_usb_power_mode_tick(uint64_t tcnt){ - UNUSED(tcnt); +void pedal_usb_power_mode_tick(uint32_t uptime){ + UNUSED(uptime); // Not applicable } @@ -60,6 +60,31 @@ bool pedal_check_ignition(void){ return false; } +uint32_t pedal_read_current(void){ + // No current sense on pedal + return 0U; +} + +void pedal_set_ir_power(uint8_t percentage){ + UNUSED(percentage); +} + +void pedal_set_fan_power(uint8_t percentage){ + UNUSED(percentage); +} + +void pedal_set_phone_power(bool enabled){ + UNUSED(enabled); +} + +void pedal_set_clock_source_mode(uint8_t mode){ + UNUSED(mode); +} + +void pedal_set_siren(bool enabled){ + UNUSED(enabled); +} + void pedal_init(void) { common_init_gpio(); @@ -69,8 +94,8 @@ void pedal_init(void) { // DAC outputs on A4 and A5 // apparently they don't need GPIO setup - // Enable transciever - pedal_enable_can_transcievers(true); + // Enable transceiver + pedal_enable_can_transceivers(true); // Disable LEDs pedal_set_led(LED_RED, false); @@ -85,12 +110,18 @@ const board board_pedal = { .board_type = "Pedal", .harness_config = &pedal_harness_config, .init = pedal_init, - .enable_can_transciever = pedal_enable_can_transciever, - .enable_can_transcievers = pedal_enable_can_transcievers, + .enable_can_transceiver = pedal_enable_can_transceiver, + .enable_can_transceivers = pedal_enable_can_transceivers, .set_led = pedal_set_led, .set_usb_power_mode = pedal_set_usb_power_mode, - .set_esp_gps_mode = pedal_set_esp_gps_mode, + .set_gps_mode = pedal_set_gps_mode, .set_can_mode = pedal_set_can_mode, .usb_power_mode_tick = pedal_usb_power_mode_tick, .check_ignition = pedal_check_ignition, -}; \ No newline at end of file + .read_current = pedal_read_current, + .set_fan_power = pedal_set_fan_power, + .set_ir_power = pedal_set_ir_power, + .set_phone_power = pedal_set_phone_power, + .set_clock_source_mode = pedal_set_clock_source_mode, + .set_siren = pedal_set_siren +}; diff --git a/panda/board/boards/uno.h b/panda/board/boards/uno.h new file mode 100644 index 00000000000000..cc9c4c0dc4ad67 --- /dev/null +++ b/panda/board/boards/uno.h @@ -0,0 +1,299 @@ +// ///////////// // +// Uno + Harness // +// ///////////// // +#define BOOTKICK_TIME 3U +uint8_t bootkick_timer = 0U; + +void uno_enable_can_transceiver(uint8_t transceiver, bool enabled) { + switch (transceiver){ + case 1U: + set_gpio_output(GPIOC, 1, !enabled); + break; + case 2U: + set_gpio_output(GPIOC, 13, !enabled); + break; + case 3U: + set_gpio_output(GPIOA, 0, !enabled); + break; + case 4U: + set_gpio_output(GPIOB, 10, !enabled); + break; + default: + puts("Invalid CAN transceiver ("); puth(transceiver); puts("): enabling failed\n"); + break; + } +} + +void uno_enable_can_transceivers(bool enabled) { + for(uint8_t i=1U; i<=4U; i++){ + // Leave main CAN always on for CAN-based ignition detection + if((car_harness_status == HARNESS_STATUS_FLIPPED) ? (i == 3U) : (i == 1U)){ + uno_enable_can_transceiver(i, true); + } else { + uno_enable_can_transceiver(i, enabled); + } + } +} + +void uno_set_led(uint8_t color, bool enabled) { + switch (color){ + case LED_RED: + set_gpio_output(GPIOC, 9, !enabled); + break; + case LED_GREEN: + set_gpio_output(GPIOC, 7, !enabled); + break; + case LED_BLUE: + set_gpio_output(GPIOC, 6, !enabled); + break; + default: + break; + } +} + +void uno_set_gps_load_switch(bool enabled) { + set_gpio_output(GPIOC, 12, enabled); +} + +void uno_set_bootkick(bool enabled){ + if(enabled){ + set_gpio_output(GPIOB, 14, false); + } else { + // We want the pin to be floating, not forced high! + set_gpio_mode(GPIOB, 14, MODE_INPUT); + } +} + +void uno_bootkick(void) { + bootkick_timer = BOOTKICK_TIME; + uno_set_bootkick(true); +} + +void uno_set_phone_power(bool enabled){ + set_gpio_output(GPIOB, 4, enabled); +} + +void uno_set_usb_power_mode(uint8_t mode) { + bool valid = false; + switch (mode) { + case USB_POWER_CLIENT: + valid = true; + break; + case USB_POWER_CDP: + uno_bootkick(); + valid = true; + break; + default: + puts("Invalid USB power mode\n"); + break; + } + if (valid) { + usb_power_mode = mode; + } +} + +void uno_set_gps_mode(uint8_t mode) { + switch (mode) { + case GPS_DISABLED: + // GPS OFF + set_gpio_output(GPIOB, 1, 0); + set_gpio_output(GPIOC, 5, 0); + uno_set_gps_load_switch(false); + break; + case GPS_ENABLED: + // GPS ON + set_gpio_output(GPIOB, 1, 1); + set_gpio_output(GPIOC, 5, 1); + uno_set_gps_load_switch(true); + break; + case GPS_BOOTMODE: + set_gpio_output(GPIOB, 1, 1); + set_gpio_output(GPIOC, 5, 0); + uno_set_gps_load_switch(true); + break; + default: + puts("Invalid ESP/GPS mode\n"); + break; + } +} + +void uno_set_can_mode(uint8_t mode){ + switch (mode) { + case CAN_MODE_NORMAL: + case CAN_MODE_OBD_CAN2: + if ((bool)(mode == CAN_MODE_NORMAL) != (bool)(car_harness_status == HARNESS_STATUS_FLIPPED)) { + // B12,B13: disable OBD mode + set_gpio_mode(GPIOB, 12, MODE_INPUT); + set_gpio_mode(GPIOB, 13, MODE_INPUT); + + // B5,B6: normal CAN2 mode + set_gpio_alternate(GPIOB, 5, GPIO_AF9_CAN2); + set_gpio_alternate(GPIOB, 6, GPIO_AF9_CAN2); + } else { + // B5,B6: disable normal CAN2 mode + set_gpio_mode(GPIOB, 5, MODE_INPUT); + set_gpio_mode(GPIOB, 6, MODE_INPUT); + + // B12,B13: OBD mode + set_gpio_alternate(GPIOB, 12, GPIO_AF9_CAN2); + set_gpio_alternate(GPIOB, 13, GPIO_AF9_CAN2); + } + break; + default: + puts("Tried to set unsupported CAN mode: "); puth(mode); puts("\n"); + break; + } +} + +void uno_usb_power_mode_tick(uint32_t uptime){ + UNUSED(uptime); + if(bootkick_timer != 0U){ + bootkick_timer--; + } else { + uno_set_bootkick(false); + } +} + +bool uno_check_ignition(void){ + // ignition is checked through harness + return harness_check_ignition(); +} + +void uno_set_usb_switch(bool phone){ + set_gpio_output(GPIOB, 3, phone); +} + +void uno_set_ir_power(uint8_t percentage){ + pwm_set(TIM4, 2, percentage); +} + +void uno_set_fan_power(uint8_t percentage){ + // Enable fan power only if percentage is non-zero. + set_gpio_output(GPIOA, 1, (percentage != 0U)); + fan_set_power(percentage); +} + +uint32_t uno_read_current(void){ + // No current sense on Uno + return 0U; +} + +void uno_set_clock_source_mode(uint8_t mode){ + UNUSED(mode); +} + +void uno_set_siren(bool enabled){ + UNUSED(enabled); +} + +void uno_init(void) { + common_init_gpio(); + + // A8,A15: normal CAN3 mode + set_gpio_alternate(GPIOA, 8, GPIO_AF11_CAN3); + set_gpio_alternate(GPIOA, 15, GPIO_AF11_CAN3); + + // C0: OBD_SBU1 (orientation detection) + // C3: OBD_SBU2 (orientation detection) + set_gpio_mode(GPIOC, 0, MODE_ANALOG); + set_gpio_mode(GPIOC, 3, MODE_ANALOG); + + // Set default state of GPS + current_board->set_gps_mode(GPS_ENABLED); + + // C10: OBD_SBU1_RELAY (harness relay driving output) + // C11: OBD_SBU2_RELAY (harness relay driving output) + set_gpio_mode(GPIOC, 10, MODE_OUTPUT); + set_gpio_mode(GPIOC, 11, MODE_OUTPUT); + set_gpio_output_type(GPIOC, 10, OUTPUT_TYPE_OPEN_DRAIN); + set_gpio_output_type(GPIOC, 11, OUTPUT_TYPE_OPEN_DRAIN); + set_gpio_output(GPIOC, 10, 1); + set_gpio_output(GPIOC, 11, 1); + + // C8: FAN PWM aka TIM3_CH3 + set_gpio_alternate(GPIOC, 8, GPIO_AF2_TIM3); + + // Turn on GPS load switch. + uno_set_gps_load_switch(true); + + // Turn on phone regulator + uno_set_phone_power(true); + + // Initialize IR PWM and set to 0% + set_gpio_alternate(GPIOB, 7, GPIO_AF2_TIM4); + pwm_init(TIM4, 2); + uno_set_ir_power(0U); + + // Initialize fan and set to 0% + fan_init(); + uno_set_fan_power(0U); + + // Initialize harness + harness_init(); + + // Initialize RTC + rtc_init(); + + // Enable CAN transceivers + uno_enable_can_transceivers(true); + + // Disable LEDs + uno_set_led(LED_RED, false); + uno_set_led(LED_GREEN, false); + uno_set_led(LED_BLUE, false); + + // Set normal CAN mode + uno_set_can_mode(CAN_MODE_NORMAL); + + // flip CAN0 and CAN2 if we are flipped + if (car_harness_status == HARNESS_STATUS_FLIPPED) { + can_flip_buses(0, 2); + } + + // init multiplexer + can_set_obd(car_harness_status, false); + + // Switch to phone usb mode if harness connection is powered by less than 7V + if(adc_get_voltage() < 7000U){ + uno_set_usb_switch(true); + } else { + uno_set_usb_switch(false); + } + + // Bootkick phone + uno_bootkick(); +} + +const harness_configuration uno_harness_config = { + .has_harness = true, + .GPIO_SBU1 = GPIOC, + .GPIO_SBU2 = GPIOC, + .GPIO_relay_SBU1 = GPIOC, + .GPIO_relay_SBU2 = GPIOC, + .pin_SBU1 = 0, + .pin_SBU2 = 3, + .pin_relay_SBU1 = 10, + .pin_relay_SBU2 = 11, + .adc_channel_SBU1 = 10, + .adc_channel_SBU2 = 13 +}; + +const board board_uno = { + .board_type = "Uno", + .harness_config = &uno_harness_config, + .init = uno_init, + .enable_can_transceiver = uno_enable_can_transceiver, + .enable_can_transceivers = uno_enable_can_transceivers, + .set_led = uno_set_led, + .set_usb_power_mode = uno_set_usb_power_mode, + .set_gps_mode = uno_set_gps_mode, + .set_can_mode = uno_set_can_mode, + .usb_power_mode_tick = uno_usb_power_mode_tick, + .check_ignition = uno_check_ignition, + .read_current = uno_read_current, + .set_fan_power = uno_set_fan_power, + .set_ir_power = uno_set_ir_power, + .set_phone_power = uno_set_phone_power, + .set_clock_source_mode = uno_set_clock_source_mode, + .set_siren = uno_set_siren +}; diff --git a/panda/board/boards/white.h b/panda/board/boards/white.h index a4e65d67bacde5..44d8f512b0fe46 100644 --- a/panda/board/boards/white.h +++ b/panda/board/boards/white.h @@ -2,8 +2,8 @@ // White Panda // // /////////// // -void white_enable_can_transciever(uint8_t transciever, bool enabled) { - switch (transciever){ +void white_enable_can_transceiver(uint8_t transceiver, bool enabled) { + switch (transceiver){ case 1U: set_gpio_output(GPIOC, 1, !enabled); break; @@ -14,14 +14,16 @@ void white_enable_can_transciever(uint8_t transciever, bool enabled) { set_gpio_output(GPIOA, 0, !enabled); break; default: - puts("Invalid CAN transciever ("); puth(transciever); puts("): enabling failed\n"); + puts("Invalid CAN transceiver ("); puth(transceiver); puts("): enabling failed\n"); break; } } -void white_enable_can_transcievers(bool enabled) { - for(uint8_t i=1; i<=3U; i++) - white_enable_can_transciever(i, enabled); +void white_enable_can_transceivers(bool enabled) { + uint8_t t1 = enabled ? 1U : 2U; // leave transceiver 1 enabled to detect CAN ignition + for(uint8_t i=t1; i<=3U; i++) { + white_enable_can_transceiver(i, enabled); + } } void white_set_led(uint8_t color, bool enabled) { @@ -34,7 +36,7 @@ void white_set_led(uint8_t color, bool enabled) { break; case LED_BLUE: set_gpio_output(GPIOC, 6, !enabled); - break; + break; default: break; } @@ -69,19 +71,21 @@ void white_set_usb_power_mode(uint8_t mode){ } } -void white_set_esp_gps_mode(uint8_t mode) { +void white_set_gps_mode(uint8_t mode) { switch (mode) { - case ESP_GPS_DISABLED: + case GPS_DISABLED: // ESP OFF set_gpio_output(GPIOC, 14, 0); set_gpio_output(GPIOC, 5, 0); break; - case ESP_GPS_ENABLED: +#ifndef EON + case GPS_ENABLED: // ESP ON set_gpio_output(GPIOC, 14, 1); set_gpio_output(GPIOC, 5, 1); break; - case ESP_GPS_BOOTMODE: +#endif + case GPS_BOOTMODE: set_gpio_output(GPIOC, 14, 1); set_gpio_output(GPIOC, 5, 0); break; @@ -125,7 +129,7 @@ void white_set_can_mode(uint8_t mode){ // A8,A15: normal CAN3 mode set_gpio_alternate(GPIOA, 8, GPIO_AF11_CAN3); - set_gpio_alternate(GPIOA, 15, GPIO_AF11_CAN3); + set_gpio_alternate(GPIOA, 15, GPIO_AF11_CAN3); break; case CAN_MODE_GMLAN_CAN3: // A8,A15: disable CAN3 mode @@ -143,79 +147,90 @@ void white_set_can_mode(uint8_t mode){ // B5,B6: normal CAN2 mode set_gpio_alternate(GPIOB, 5, GPIO_AF9_CAN2); set_gpio_alternate(GPIOB, 6, GPIO_AF9_CAN2); - break; + break; default: puts("Tried to set unsupported CAN mode: "); puth(mode); puts("\n"); break; } } -uint64_t marker = 0; -void white_usb_power_mode_tick(uint64_t tcnt){ - #ifndef BOOTSTUB +uint32_t white_read_current(void){ + return adc_get(ADCCHAN_CURRENT); +} + +uint32_t marker = 0; +void white_usb_power_mode_tick(uint32_t uptime){ + + // on EON or BOOTSTUB, no state machine +#if !defined(BOOTSTUB) && !defined(EON) #define CURRENT_THRESHOLD 0xF00U #define CLICKS 5U // 5 seconds to switch modes - uint32_t current = adc_get(ADCCHAN_CURRENT); + uint32_t current = white_read_current(); // ~0x9a = 500 ma // puth(current); puts("\n"); switch (usb_power_mode) { case USB_POWER_CLIENT: - if ((tcnt - marker) >= CLICKS) { + if ((uptime - marker) >= CLICKS) { if (!is_enumerated) { puts("USBP: didn't enumerate, switching to CDP mode\n"); // switch to CDP white_set_usb_power_mode(USB_POWER_CDP); - marker = tcnt; + marker = uptime; } } // keep resetting the timer if it's enumerated if (is_enumerated) { - marker = tcnt; + marker = uptime; } 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"); - white_set_usb_power_mode(USB_POWER_DCP); - marker = tcnt; - } + // been CLICKS clicks since we switched to CDP + if ((uptime - 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"); + white_set_usb_power_mode(USB_POWER_DCP); + marker = uptime; } - // keep resetting the timer if there's no current draw in CDP - if (current >= CURRENT_THRESHOLD) { - marker = tcnt; - } - #endif + } + // keep resetting the timer if there's no current draw in CDP + if (current >= CURRENT_THRESHOLD) { + marker = uptime; + } break; case USB_POWER_DCP: // been at least CLICKS clicks since we switched to DCP - if ((tcnt-marker) >= CLICKS) { + if ((uptime - 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"); white_set_usb_power_mode(USB_POWER_CDP); - marker = tcnt; + marker = uptime; } } // keep resetting the timer if there's current draw in DCP if (current < CURRENT_THRESHOLD) { - marker = tcnt; + marker = uptime; } break; default: puts("USB power mode invalid\n"); // set_usb_power_mode prevents assigning invalid values break; } - #else - UNUSED(tcnt); - #endif +#else + UNUSED(uptime); +#endif +} + +void white_set_ir_power(uint8_t percentage){ + UNUSED(percentage); +} + +void white_set_fan_power(uint8_t percentage){ + UNUSED(percentage); } bool white_check_ignition(void){ @@ -223,7 +238,19 @@ bool white_check_ignition(void){ return !get_gpio_input(GPIOA, 1); } -void white_init(void) { +void white_set_phone_power(bool enabled){ + UNUSED(enabled); +} + +void white_set_clock_source_mode(uint8_t mode){ + UNUSED(mode); +} + +void white_set_siren(bool enabled){ + UNUSED(enabled); +} + +void white_grey_common_init(void) { common_init_gpio(); // C3: current sense @@ -242,9 +269,6 @@ void white_init(void) { set_gpio_alternate(GPIOA, 6, GPIO_AF5_SPI1); set_gpio_alternate(GPIOA, 7, GPIO_AF5_SPI1); - // Set USB power mode - white_set_usb_power_mode(USB_POWER_CLIENT); - // B12: GMLAN, ignition sense, pull up set_gpio_pullup(GPIOB, 12, PULL_UP); @@ -275,8 +299,8 @@ void white_init(void) { set_gpio_alternate(GPIOC, 11, GPIO_AF7_USART3); set_gpio_pullup(GPIOC, 11, PULL_UP); - // Enable CAN transcievers - white_enable_can_transcievers(true); + // Enable CAN transceivers + white_enable_can_transceivers(true); // Disable LEDs white_set_led(LED_RED, false); @@ -285,6 +309,23 @@ void white_init(void) { // Set normal CAN mode white_set_can_mode(CAN_MODE_NORMAL); + + // Init usb power mode + uint32_t voltage = adc_get_voltage(); + // Init in CDP mode only if panda is powered by 12V. + // Otherwise a PC would not be able to flash a standalone panda with EON build + if (voltage > 8000U) { // 8V threshold + white_set_usb_power_mode(USB_POWER_CDP); + } else { + white_set_usb_power_mode(USB_POWER_CLIENT); + } +} + +void white_init(void) { + white_grey_common_init(); + + // Set ESP off by default + current_board->set_gps_mode(GPS_DISABLED); } const harness_configuration white_harness_config = { @@ -295,12 +336,18 @@ const board board_white = { .board_type = "White", .harness_config = &white_harness_config, .init = white_init, - .enable_can_transciever = white_enable_can_transciever, - .enable_can_transcievers = white_enable_can_transcievers, + .enable_can_transceiver = white_enable_can_transceiver, + .enable_can_transceivers = white_enable_can_transceivers, .set_led = white_set_led, .set_usb_power_mode = white_set_usb_power_mode, - .set_esp_gps_mode = white_set_esp_gps_mode, + .set_gps_mode = white_set_gps_mode, .set_can_mode = white_set_can_mode, .usb_power_mode_tick = white_usb_power_mode_tick, - .check_ignition = white_check_ignition -}; \ No newline at end of file + .check_ignition = white_check_ignition, + .read_current = white_read_current, + .set_fan_power = white_set_fan_power, + .set_ir_power = white_set_ir_power, + .set_phone_power = white_set_phone_power, + .set_clock_source_mode = white_set_clock_source_mode, + .set_siren = white_set_siren +}; diff --git a/panda/board/bootstub.c b/panda/board/bootstub.c index 9644326d4d0253..1521b5324030d0 100644 --- a/panda/board/bootstub.c +++ b/panda/board/bootstub.c @@ -1,5 +1,8 @@ #define BOOTSTUB +#define VERS_TAG 0x53524556 +#define MIN_VERSION 2 + #include "config.h" #include "obj/gitversion.h" @@ -29,9 +32,15 @@ const board *current_board; // ********************* Includes ********************* #include "libc.h" #include "provision.h" +#include "critical.h" +#include "faults.h" +#include "drivers/registers.h" +#include "drivers/interrupts.h" #include "drivers/clock.h" #include "drivers/llgpio.h" +#include "drivers/adc.h" +#include "drivers/pwm.h" #include "board.h" @@ -63,13 +72,14 @@ extern void *_app_start[]; // BOUNTY: $200 coupon on shop.comma.ai or $100 check. int main(void) { - __disable_irq(); + // Init interrupt table + init_interrupts(true); + + disable_interrupts(); clock_init(); detect_configuration(); detect_board_type(); - current_board->set_usb_power_mode(USB_POWER_CLIENT); - if (enter_bootloader_mode == ENTER_SOFTLOADER_MAGIC) { enter_bootloader_mode = 0; soft_flasher_start(); @@ -83,6 +93,13 @@ int main(void) { uint8_t digest[SHA_DIGEST_SIZE]; SHA_hash(&_app_start[1], len-4, digest); + // verify version, last bytes in the signed area + uint32_t vers[2] = {0}; + memcpy(&vers, ((void*)&_app_start[0]) + len - sizeof(vers), sizeof(vers)); + if (vers[0] != VERS_TAG || vers[1] < MIN_VERSION) { + goto fail; + } + // verify RSA signature if (RSA_verify(&release_rsa_key, ((void*)&_app_start[0]) + len, RSANUMBYTES, digest, SHA_DIGEST_SIZE)) { goto good; diff --git a/panda/board/build.mk b/panda/board/build.mk index f435476e1faee2..a891fae38f3929 100644 --- a/panda/board/build.mk +++ b/panda/board/build.mk @@ -13,9 +13,10 @@ else DFU_UTIL = "tools/dfu-util-aarch64" endif -CC = arm-none-eabi-gcc -OBJCOPY = arm-none-eabi-objcopy -OBJDUMP = arm-none-eabi-objdump +#COMPILER_PATH = /home/batman/Downloads/gcc-arm-none-eabi-9-2020-q2-update/bin/ +CC = $(COMPILER_PATH)arm-none-eabi-gcc +OBJCOPY = $(COMPILER_PATH)arm-none-eabi-objcopy +OBJDUMP = $(COMPILER_PATH)arm-none-eabi-objdump ifeq ($(RELEASE),1) CERT = ../../pandaextra/certs/release @@ -33,7 +34,7 @@ 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')" + PYTHONPATH=../ python3 -c "from python import Panda; Panda().flash('obj/$(PROJ_NAME).bin')" ota: obj/$(PROJ_NAME).bin curl http://192.168.0.10/stupdate --upload-file $< @@ -42,8 +43,8 @@ bin: obj/$(PROJ_NAME).bin # this flashes everything recover: obj/bootstub.$(PROJ_NAME).bin obj/$(PROJ_NAME).bin - -PYTHONPATH=../ python -c "from python import Panda; Panda().reset(enter_bootloader=True)" - sleep 1.0 + -PYTHONPATH=../ python3 -c "from python import Panda; Panda().reset(enter_bootstub=True); Panda().reset(enter_bootloader=True)" + sleep 2.0 $(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08004000 -D obj/$(PROJ_NAME).bin $(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08000000:leave -D obj/bootstub.$(PROJ_NAME).bin diff --git a/panda/board/config.h b/panda/board/config.h index 7fd203fc30e958..335d2e1ec5e54d 100644 --- a/panda/board/config.h +++ b/panda/board/config.h @@ -2,8 +2,10 @@ #define PANDA_CONFIG_H //#define DEBUG +//#define DEBUG_UART //#define DEBUG_USB //#define DEBUG_SPI +//#define DEBUG_FAULTS #ifdef STM32F4 #define PANDA @@ -22,7 +24,7 @@ #include #define NULL ((void*)0) -#define COMPILE_TIME_ASSERT(pred) ((void)sizeof(char[1 - (2 * (!(pred)))])) +#define COMPILE_TIME_ASSERT(pred) ((void)sizeof(char[1 - (2 * ((int)(!(pred))))])) #define MIN(a,b) \ ({ __typeof__ (a) _a = (a); \ @@ -34,7 +36,14 @@ __typeof__ (b) _b = (b); \ (_a > _b) ? _a : _b; }) +#define ABS(a) \ + ({ __typeof__ (a) _a = (a); \ + (_a > 0) ? _a : (-_a); }) + #define MAX_RESP_LEN 0x40U +// Around (1Mbps / 8 bits/byte / 12 bytes per message) +#define CAN_INTERRUPT_RATE 12000U + #endif diff --git a/panda/board/crc.h b/panda/board/crc.h new file mode 100644 index 00000000000000..ab969e5176c8b9 --- /dev/null +++ b/panda/board/crc.h @@ -0,0 +1,16 @@ +uint8_t crc_checksum(uint8_t *dat, int len, const uint8_t poly) { + uint8_t crc = 0xFF; + int i, j; + for (i = len - 1; i >= 0; i--) { + crc ^= dat[i]; + for (j = 0; j < 8; j++) { + if ((crc & 0x80U) != 0U) { + crc = (uint8_t)((crc << 1) ^ poly); + } + else { + crc <<= 1; + } + } + } + return crc; +} diff --git a/panda/board/critical.h b/panda/board/critical.h new file mode 100644 index 00000000000000..c8cf52c7a11533 --- /dev/null +++ b/panda/board/critical.h @@ -0,0 +1,23 @@ +// ********************* Critical section helpers ********************* +volatile bool interrupts_enabled = false; + +void enable_interrupts(void) { + interrupts_enabled = true; + __enable_irq(); +} + +void disable_interrupts(void) { + interrupts_enabled = false; + __disable_irq(); +} + +uint8_t global_critical_depth = 0U; +#define ENTER_CRITICAL() \ + __disable_irq(); \ + global_critical_depth += 1U; + +#define EXIT_CRITICAL() \ + global_critical_depth -= 1U; \ + if ((global_critical_depth == 0U) && interrupts_enabled) { \ + __enable_irq(); \ + } diff --git a/panda/board/drivers/adc.h b/panda/board/drivers/adc.h index efd0a168787471..358497adbfdcda 100644 --- a/panda/board/drivers/adc.h +++ b/panda/board/drivers/adc.h @@ -9,26 +9,16 @@ #define ADCCHAN_CURRENT 13 void adc_init(void) { - // global setup - ADC->CCR = ADC_CCR_TSVREFE | ADC_CCR_VBATE; - //ADC1->CR2 = ADC_CR2_ADON | ADC_CR2_EOCS | ADC_CR2_DDS; - ADC1->CR2 = ADC_CR2_ADON; - - // long - //ADC1->SMPR1 = ADC_SMPR1_SMP10 | ADC_SMPR1_SMP11 | ADC_SMPR1_SMP12 | ADC_SMPR1_SMP13; - ADC1->SMPR1 = ADC_SMPR1_SMP12 | ADC_SMPR1_SMP13; + register_set(&(ADC->CCR), ADC_CCR_TSVREFE | ADC_CCR_VBATE, 0xC30000U); + register_set(&(ADC1->CR2), ADC_CR2_ADON, 0xFF7F0F03U); + register_set(&(ADC1->SMPR1), ADC_SMPR1_SMP12 | ADC_SMPR1_SMP13, 0x7FFFFFFU); } uint32_t adc_get(unsigned int channel) { - // includes length - //ADC1->SQR1 = 0; - - // select channel - ADC1->JSQR = channel << 15; - - //ADC1->CR1 = ADC_CR1_DISCNUM_0; - //ADC1->CR1 = ADC_CR1_EOCIE; + // Select channel + register_set(&(ADC1->JSQR), (channel << 15U), 0x3FFFFFU); + // Start conversion ADC1->SR &= ~(ADC_SR_JEOC); ADC1->CR2 |= ADC_CR2_JSWSTART; while (!(ADC1->SR & ADC_SR_JEOC)); @@ -36,3 +26,13 @@ uint32_t adc_get(unsigned int channel) { return ADC1->JDR1; } +uint32_t adc_get_voltage(void) { + // 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, so output in mV + return (adc_get(ADCCHAN_VOLTAGE) * 8862U) / 1000U; +} diff --git a/panda/board/drivers/can.h b/panda/board/drivers/can.h index 2d77281346332c..2ca7cbc719b015 100644 --- a/panda/board/drivers/can.h +++ b/panda/board/drivers/can.h @@ -14,6 +14,7 @@ typedef struct { #define BUS_MAX 4U +uint32_t can_rx_errs = 0; uint32_t can_send_errs = 0; uint32_t can_fwd_errs = 0; uint32_t gmlan_send_errs = 0; @@ -25,11 +26,17 @@ extern uint32_t can_speed[4]; void can_set_forwarding(int from, int to); -void can_init(uint8_t can_number); +bool can_init(uint8_t can_number); void can_init_all(void); -void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number); +bool can_tx_check_min_slots_free(uint32_t min); +void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number, bool skip_tx_hook); bool can_pop(can_ring *q, CAN_FIFOMailBox_TypeDef *elem); +// Ignition detected from CAN meessages +bool ignition_can = false; +bool ignition_cadillac = false; +uint32_t ignition_can_cnt = 0U; + // end API #define ALL_CAN_SILENT 0xFF @@ -62,7 +69,7 @@ int can_overflow_cnt = 0; bool can_pop(can_ring *q, CAN_FIFOMailBox_TypeDef *elem) { bool ret = 0; - enter_critical_section(); + ENTER_CRITICAL(); if (q->w_ptr != q->r_ptr) { *elem = q->elems[q->r_ptr]; if ((q->r_ptr + 1U) == q->fifo_size) { @@ -72,7 +79,7 @@ bool can_pop(can_ring *q, CAN_FIFOMailBox_TypeDef *elem) { } ret = 1; } - exit_critical_section(); + EXIT_CRITICAL(); return ret; } @@ -81,7 +88,7 @@ bool can_push(can_ring *q, CAN_FIFOMailBox_TypeDef *elem) { bool ret = false; uint32_t next_w_ptr; - enter_critical_section(); + ENTER_CRITICAL(); if ((q->w_ptr + 1U) == q->fifo_size) { next_w_ptr = 0; } else { @@ -92,7 +99,7 @@ bool can_push(can_ring *q, CAN_FIFOMailBox_TypeDef *elem) { q->w_ptr = next_w_ptr; ret = true; } - exit_critical_section(); + EXIT_CRITICAL(); if (!ret) { can_overflow_cnt++; #ifdef DEBUG @@ -102,11 +109,25 @@ bool can_push(can_ring *q, CAN_FIFOMailBox_TypeDef *elem) { return ret; } +uint32_t can_slots_empty(can_ring *q) { + uint32_t ret = 0; + + ENTER_CRITICAL(); + if (q->w_ptr >= q->r_ptr) { + ret = q->fifo_size - 1U - q->w_ptr + q->r_ptr; + } else { + ret = q->r_ptr - q->w_ptr - 1U; + } + EXIT_CRITICAL(); + + return ret; +} + void can_clear(can_ring *q) { - enter_critical_section(); + ENTER_CRITICAL(); q->w_ptr = 0; q->r_ptr = 0; - exit_critical_section(); + EXIT_CRITICAL(); } // assign CAN numbering @@ -124,43 +145,31 @@ 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 CAN_MAX 3U #define CANIF_FROM_CAN_NUM(num) (cans[num]) #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")) #define BUS_NUM_FROM_CAN_NUM(num) (bus_lookup[num]) #define CAN_NUM_FROM_BUS_NUM(num) (can_num_lookup[num]) void process_can(uint8_t can_number); -void can_set_speed(uint8_t can_number) { +bool can_set_speed(uint8_t can_number) { + bool ret = true; CAN_TypeDef *CAN = CANIF_FROM_CAN_NUM(can_number); uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number); - if (!llcan_set_speed(CAN, can_speed[bus_number], can_loopback, (unsigned int)(can_silent) & (1U << can_number))) { - puts("CAN init FAILED!!!!!\n"); - puth(can_number); puts(" "); - puth(BUS_NUM_FROM_CAN_NUM(can_number)); puts("\n"); - } -} - -void can_init(uint8_t can_number) { - if (can_number != 0xffU) { - CAN_TypeDef *CAN = CANIF_FROM_CAN_NUM(can_number); - can_set_speed(can_number); - - llcan_init(CAN); - - // in case there are queued up messages - process_can(can_number); - } + ret &= llcan_set_speed(CAN, can_speed[bus_number], can_loopback, (unsigned int)(can_silent) & (1U << can_number)); + return ret; } void can_init_all(void) { - for (int i=0; i < CAN_MAX; i++) { - can_init(i); + bool ret = true; + for (uint8_t i=0U; i < CAN_MAX; i++) { + can_clear(can_queues[i]); + ret &= can_init(i); } + UNUSED(ret); } void can_flip_buses(uint8_t bus1, uint8_t bus2){ @@ -172,7 +181,7 @@ void can_flip_buses(uint8_t bus1, uint8_t bus2){ // TODO: Cleanup with new abstraction void can_set_gmlan(uint8_t bus) { - if(hw_type != HW_TYPE_BLACK_PANDA){ + if(board_has_gmlan()){ // first, disable GMLAN on prev bus uint8_t prev_bus = can_num_lookup[3]; if (bus != prev_bus) { @@ -186,7 +195,8 @@ void can_set_gmlan(uint8_t bus) { bus_lookup[prev_bus] = prev_bus; can_num_lookup[prev_bus] = prev_bus; can_num_lookup[3] = -1; - can_init(prev_bus); + bool ret = can_init(prev_bus); + UNUSED(ret); break; default: // GMLAN was not set on either BUS 1 or 2 @@ -205,7 +215,8 @@ void can_set_gmlan(uint8_t bus) { bus_lookup[bus] = 3; can_num_lookup[bus] = -1; can_num_lookup[3] = bus; - can_init(bus); + bool ret = can_init(bus); + UNUSED(ret); break; case 0xFF: //-1 unsigned break; @@ -225,7 +236,7 @@ void can_set_obd(uint8_t harness_orientation, bool obd){ } else { puts("setting CAN2 to be normal\n"); } - if(hw_type == HW_TYPE_BLACK_PANDA){ + if(board_has_obd()){ if(obd != (bool)(harness_orientation == HARNESS_STATUS_NORMAL)){ // B5,B6: disable normal mode set_gpio_mode(GPIOB, 5, MODE_INPUT); @@ -242,13 +253,13 @@ void can_set_obd(uint8_t harness_orientation, bool obd){ set_gpio_mode(GPIOB, 13, MODE_INPUT); } } else { - puts("OBD CAN not available on non-black panda\n"); + puts("OBD CAN not available on this board\n"); } } // CAN error void can_sce(CAN_TypeDef *CAN) { - enter_critical_section(); + ENTER_CRITICAL(); #ifdef DEBUG if (CAN==CAN1) puts("CAN1: "); @@ -271,7 +282,7 @@ void can_sce(CAN_TypeDef *CAN) { can_err_cnt += 1; llcan_clear_send(CAN); - exit_critical_section(); + EXIT_CRITICAL(); } // ***************************** CAN ***************************** @@ -279,7 +290,7 @@ void can_sce(CAN_TypeDef *CAN) { void process_can(uint8_t can_number) { if (can_number != 0xffU) { - enter_critical_section(); + ENTER_CRITICAL(); CAN_TypeDef *CAN = CANIF_FROM_CAN_NUM(can_number); uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number); @@ -297,7 +308,7 @@ void process_can(uint8_t can_number) { to_push.RDTR = (CAN->sTxMailBox[0].TDTR & 0xFFFF000FU) | ((CAN_BUS_RET_FLAG | bus_number) << 4); to_push.RDLR = CAN->sTxMailBox[0].TDLR; to_push.RDHR = CAN->sTxMailBox[0].TDHR; - can_send_errs += !can_push(&can_rx_q, &to_push); + can_send_errs += can_push(&can_rx_q, &to_push) ? 0U : 1U; } if ((CAN->TSR & CAN_TSR_TERR0) == CAN_TSR_TERR0) { @@ -324,10 +335,42 @@ void process_can(uint8_t can_number) { CAN->sTxMailBox[0].TDHR = to_send.RDHR; CAN->sTxMailBox[0].TDTR = to_send.RDTR; CAN->sTxMailBox[0].TIR = to_send.RIR; + + if (can_tx_check_min_slots_free(MAX_CAN_MSGS_PER_BULK_TRANSFER)) { + usb_outep3_resume_if_paused(); + } } } - exit_critical_section(); + EXIT_CRITICAL(); + } +} + +void ignition_can_hook(CAN_FIFOMailBox_TypeDef *to_push) { + int bus = GET_BUS(to_push); + int addr = GET_ADDR(to_push); + int len = GET_LEN(to_push); + + ignition_can_cnt = 0U; // reset counter + + if (bus == 0) { + // TODO: verify on all supported GM models that we can reliably detect ignition using only this signal, + // since the 0x1F1 signal can briefly go low immediately after ignition + if ((addr == 0x160) && (len == 5)) { + // this message isn't all zeros when ignition is on + ignition_cadillac = GET_BYTES_04(to_push) != 0; + } + // GM exception + if ((addr == 0x1F1) && (len == 8)) { + // Bit 5 is ignition "on" + bool ignition_gm = ((GET_BYTE(to_push, 0) & 0x20) != 0); + ignition_can = ignition_gm || ignition_cadillac; + } + // Tesla exception + if ((addr == 0x348) && (len == 8)) { + // GTW_status + ignition_can = (GET_BYTE(to_push, 0) & 0x1) != 0; + } } } @@ -360,42 +403,50 @@ void can_rx(uint8_t can_number) { 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); + can_send(&to_send, bus_fwd_num, true); } - safety_rx_hook(&to_push); + can_rx_errs += safety_rx_hook(&to_push) ? 0U : 1U; + ignition_can_hook(&to_push); current_board->set_led(LED_BLUE, true); - can_send_errs += !can_push(&can_rx_q, &to_push); + can_send_errs += can_push(&can_rx_q, &to_push) ? 0U : 1U; // next CAN->RF0R |= CAN_RF0R_RFOM0; } } -void CAN1_TX_IRQHandler(void) { process_can(0); } -void CAN1_RX0_IRQHandler(void) { can_rx(0); } -void CAN1_SCE_IRQHandler(void) { can_sce(CAN1); } +void CAN1_TX_IRQ_Handler(void) { process_can(0); } +void CAN1_RX0_IRQ_Handler(void) { can_rx(0); } +void CAN1_SCE_IRQ_Handler(void) { can_sce(CAN1); } -void CAN2_TX_IRQHandler(void) { process_can(1); } -void CAN2_RX0_IRQHandler(void) { can_rx(1); } -void CAN2_SCE_IRQHandler(void) { can_sce(CAN2); } +void CAN2_TX_IRQ_Handler(void) { process_can(1); } +void CAN2_RX0_IRQ_Handler(void) { can_rx(1); } +void CAN2_SCE_IRQ_Handler(void) { can_sce(CAN2); } -void CAN3_TX_IRQHandler(void) { process_can(2); } -void CAN3_RX0_IRQHandler(void) { can_rx(2); } -void CAN3_SCE_IRQHandler(void) { can_sce(CAN3); } +void CAN3_TX_IRQ_Handler(void) { process_can(2); } +void CAN3_RX0_IRQ_Handler(void) { can_rx(2); } +void CAN3_SCE_IRQ_Handler(void) { can_sce(CAN3); } -void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number) { - if (safety_tx_hook(to_push) != 0) { +bool can_tx_check_min_slots_free(uint32_t min) { + return + (can_slots_empty(&can_tx1_q) >= min) && + (can_slots_empty(&can_tx2_q) >= min) && + (can_slots_empty(&can_tx3_q) >= min) && + (can_slots_empty(&can_txgmlan_q) >= min); +} + +void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number, bool skip_tx_hook) { + if (skip_tx_hook || safety_tx_hook(to_push) != 0) { if (bus_number < BUS_MAX) { // add CAN packet to send queue // bus number isn't passed through to_push->RDTR &= 0xF; if ((bus_number == 3U) && (can_num_lookup[3] == 0xFFU)) { - // TODO: why uint8 bro? only int8? - gmlan_send_errs += !bitbang_gmlan(to_push); + gmlan_send_errs += bitbang_gmlan(to_push) ? 0U : 1U; } else { - can_fwd_errs += !can_push(can_queues[bus_number], to_push); + can_fwd_errs += can_push(can_queues[bus_number], to_push) ? 0U : 1U; process_can(CAN_NUM_FROM_BUS_NUM(bus_number)); } } @@ -406,3 +457,26 @@ void can_set_forwarding(int from, int to) { can_forwarding[from] = to; } +bool can_init(uint8_t can_number) { + bool ret = false; + + REGISTER_INTERRUPT(CAN1_TX_IRQn, CAN1_TX_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) + REGISTER_INTERRUPT(CAN1_RX0_IRQn, CAN1_RX0_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) + REGISTER_INTERRUPT(CAN1_SCE_IRQn, CAN1_SCE_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) + REGISTER_INTERRUPT(CAN2_TX_IRQn, CAN2_TX_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_2) + REGISTER_INTERRUPT(CAN2_RX0_IRQn, CAN2_RX0_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_2) + REGISTER_INTERRUPT(CAN2_SCE_IRQn, CAN2_SCE_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_2) + REGISTER_INTERRUPT(CAN3_TX_IRQn, CAN3_TX_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_3) + REGISTER_INTERRUPT(CAN3_RX0_IRQn, CAN3_RX0_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_3) + REGISTER_INTERRUPT(CAN3_SCE_IRQn, CAN3_SCE_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_3) + + if (can_number != 0xffU) { + CAN_TypeDef *CAN = CANIF_FROM_CAN_NUM(can_number); + ret &= can_set_speed(can_number); + ret &= llcan_init(CAN); + // in case there are queued up messages + process_can(can_number); + } + return ret; +} + diff --git a/panda/board/drivers/clock.h b/panda/board/drivers/clock.h index d564c7f01db28d..b75692438ec63a 100644 --- a/panda/board/drivers/clock.h +++ b/panda/board/drivers/clock.h @@ -1,25 +1,24 @@ void clock_init(void) { // enable external oscillator - RCC->CR |= RCC_CR_HSEON; + register_set_bits(&(RCC->CR), RCC_CR_HSEON); while ((RCC->CR & RCC_CR_HSERDY) == 0); // divide things - RCC->CFGR = RCC_CFGR_HPRE_DIV1 | RCC_CFGR_PPRE2_DIV2 | RCC_CFGR_PPRE1_DIV4; + register_set(&(RCC->CFGR), RCC_CFGR_HPRE_DIV1 | RCC_CFGR_PPRE2_DIV2 | RCC_CFGR_PPRE1_DIV4, 0xFF7FFCF3U); // 16mhz crystal - RCC->PLLCFGR = RCC_PLLCFGR_PLLQ_2 | RCC_PLLCFGR_PLLM_3 | - RCC_PLLCFGR_PLLN_6 | RCC_PLLCFGR_PLLN_5 | RCC_PLLCFGR_PLLSRC_HSE; + register_set(&(RCC->PLLCFGR), RCC_PLLCFGR_PLLQ_2 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLN_6 | RCC_PLLCFGR_PLLN_5 | RCC_PLLCFGR_PLLSRC_HSE, 0x7F437FFFU); // start PLL - RCC->CR |= RCC_CR_PLLON; + register_set_bits(&(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; + register_set(&(FLASH->ACR), FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_5WS, 0x1F0FU); // switch to PLL - RCC->CFGR |= RCC_CFGR_SW_PLL; + register_set_bits(&(RCC->CFGR), RCC_CFGR_SW_PLL); while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL); // *** running on PLL *** @@ -27,14 +26,15 @@ void clock_init(void) { void watchdog_init(void) { // setup watchdog - IWDG->KR = 0x5555; - IWDG->PR = 0; // divider /4 + IWDG->KR = 0x5555U; + register_set(&(IWDG->PR), 0x0U, 0x7U); // divider/4 + // 0 = 0.125 ms, let's have a 50ms watchdog - IWDG->RLR = 400 - 1; - IWDG->KR = 0xCCCC; + register_set(&(IWDG->RLR), (400U-1U), 0xFFFU); + IWDG->KR = 0xCCCCU; } void watchdog_feed(void) { - IWDG->KR = 0xAAAA; + IWDG->KR = 0xAAAAU; } diff --git a/panda/board/drivers/clock_source.h b/panda/board/drivers/clock_source.h new file mode 100644 index 00000000000000..966dee452e0839 --- /dev/null +++ b/panda/board/drivers/clock_source.h @@ -0,0 +1,100 @@ + +#define CLOCK_SOURCE_MODE_DISABLED 0U +#define CLOCK_SOURCE_MODE_FREE_RUNNING 1U +#define CLOCK_SOURCE_MODE_EXTERNAL_SYNC 2U + +#define CLOCK_SOURCE_PERIOD_MS 50U +#define CLOCK_SOURCE_PULSE_LEN_MS 2U + +uint8_t clock_source_mode = CLOCK_SOURCE_MODE_DISABLED; + +void EXTI0_IRQ_Handler(void) { + volatile unsigned int pr = EXTI->PR & (1U << 0); + if (pr != 0U) { + if(clock_source_mode == CLOCK_SOURCE_MODE_EXTERNAL_SYNC){ + // TODO: Implement! + } + } + EXTI->PR = (1U << 0); +} + +void TIM1_UP_TIM10_IRQ_Handler(void) { + if((TIM1->SR & TIM_SR_UIF) != 0) { + if(clock_source_mode != CLOCK_SOURCE_MODE_DISABLED) { + // Start clock pulse + set_gpio_output(GPIOB, 14, true); + set_gpio_output(GPIOB, 15, true); + } + + // Reset interrupt + TIM1->SR &= ~(TIM_SR_UIF); + } +} + +void TIM1_CC_IRQ_Handler(void) { + if((TIM1->SR & TIM_SR_CC1IF) != 0) { + if(clock_source_mode != CLOCK_SOURCE_MODE_DISABLED) { + // End clock pulse + set_gpio_output(GPIOB, 14, false); + set_gpio_output(GPIOB, 15, false); + } + + // Reset interrupt + TIM1->SR &= ~(TIM_SR_CC1IF); + } +} + +void clock_source_init(uint8_t mode){ + // Setup external clock signal interrupt + REGISTER_INTERRUPT(EXTI0_IRQn, EXTI0_IRQ_Handler, 110U, FAULT_INTERRUPT_RATE_CLOCK_SOURCE) + register_set(&(SYSCFG->EXTICR[0]), SYSCFG_EXTICR1_EXTI0_PB, 0xFU); + register_set_bits(&(EXTI->IMR), (1U << 0)); + register_set_bits(&(EXTI->RTSR), (1U << 0)); + register_clear_bits(&(EXTI->FTSR), (1U << 0)); + + // Setup timer + REGISTER_INTERRUPT(TIM1_UP_TIM10_IRQn, TIM1_UP_TIM10_IRQ_Handler, (1200U / CLOCK_SOURCE_PERIOD_MS) , FAULT_INTERRUPT_RATE_TIM1) + REGISTER_INTERRUPT(TIM1_CC_IRQn, TIM1_CC_IRQ_Handler, (1200U / CLOCK_SOURCE_PERIOD_MS) , FAULT_INTERRUPT_RATE_TIM1) + register_set(&(TIM1->PSC), (9600-1), 0xFFFFU); // Tick on 0.1 ms + register_set(&(TIM1->ARR), ((CLOCK_SOURCE_PERIOD_MS*10U) - 1U), 0xFFFFU); // Period + register_set(&(TIM1->CCMR1), 0U, 0xFFFFU); // No output on compare + register_set_bits(&(TIM1->CCER), TIM_CCER_CC1E); // Enable compare 1 + register_set(&(TIM1->CCR1), (CLOCK_SOURCE_PULSE_LEN_MS*10U), 0xFFFFU); // Compare 1 value + register_set_bits(&(TIM1->DIER), TIM_DIER_UIE | TIM_DIER_CC1IE); // Enable interrupts + register_set(&(TIM1->CR1), TIM_CR1_CEN, 0x3FU); // Enable timer + + // Set mode + switch(mode) { + case CLOCK_SOURCE_MODE_DISABLED: + // No clock signal + NVIC_DisableIRQ(EXTI0_IRQn); + NVIC_DisableIRQ(TIM1_UP_TIM10_IRQn); + NVIC_DisableIRQ(TIM1_CC_IRQn); + + // Disable pulse if we were in the middle of it + set_gpio_output(GPIOB, 14, false); + set_gpio_output(GPIOB, 15, false); + + clock_source_mode = CLOCK_SOURCE_MODE_DISABLED; + break; + case CLOCK_SOURCE_MODE_FREE_RUNNING: + // Clock signal is based on internal timer + NVIC_DisableIRQ(EXTI0_IRQn); + NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn); + NVIC_EnableIRQ(TIM1_CC_IRQn); + + clock_source_mode = CLOCK_SOURCE_MODE_FREE_RUNNING; + break; + case CLOCK_SOURCE_MODE_EXTERNAL_SYNC: + // Clock signal is based on external timer + NVIC_EnableIRQ(EXTI0_IRQn); + NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn); + NVIC_EnableIRQ(TIM1_CC_IRQn); + + clock_source_mode = CLOCK_SOURCE_MODE_EXTERNAL_SYNC; + break; + default: + puts("Unknown clock source mode: "); puth(mode); puts("\n"); + break; + } +} \ No newline at end of file diff --git a/panda/board/drivers/dac.h b/panda/board/drivers/dac.h index ac565eb221cd05..4bdb16100c7bb6 100644 --- a/panda/board/drivers/dac.h +++ b/panda/board/drivers/dac.h @@ -2,22 +2,19 @@ void puth(unsigned int i); void puts(const char *a); void dac_init(void) { - // no buffers required since we have an opamp - //DAC->CR = DAC_CR_EN1 | DAC_CR_BOFF1 | DAC_CR_EN2 | DAC_CR_BOFF2; - DAC->DHR12R1 = 0; - DAC->DHR12R2 = 0; - DAC->CR = DAC_CR_EN1 | DAC_CR_EN2; + // No buffers required since we have an opamp + register_set(&(DAC->DHR12R1), 0U, 0xFFFU); + register_set(&(DAC->DHR12R2), 0U, 0xFFFU); + register_set(&(DAC->CR), DAC_CR_EN1 | DAC_CR_EN2, 0x3FFF3FFFU); } void dac_set(int channel, uint32_t value) { if (channel == 0) { - DAC->DHR12R1 = value; + register_set(&(DAC->DHR12R1), value, 0xFFFU); } else if (channel == 1) { - DAC->DHR12R2 = value; + register_set(&(DAC->DHR12R2), value, 0xFFFU); } else { - puts("Failed to set DAC: invalid channel value: "); - puth(value); - puts("\n"); + puts("Failed to set DAC: invalid channel value: 0x"); puth(value); puts("\n"); } } diff --git a/panda/board/drivers/fan.h b/panda/board/drivers/fan.h new file mode 100644 index 00000000000000..2f10e5ca8d7b51 --- /dev/null +++ b/panda/board/drivers/fan.h @@ -0,0 +1,39 @@ +void fan_set_power(uint8_t percentage){ + pwm_set(TIM3, 3, percentage); +} + +uint16_t fan_tach_counter = 0U; +uint16_t fan_rpm = 0U; + +// Can be way more acurate than this, but this is probably good enough for our purposes. + +// Call this every second +void fan_tick(void){ + // 4 interrupts per rotation + fan_rpm = fan_tach_counter * 15U; + fan_tach_counter = 0U; +} + +// TACH interrupt handler +void EXTI2_IRQ_Handler(void) { + volatile unsigned int pr = EXTI->PR & (1U << 2); + if ((pr & (1U << 2)) != 0U) { + fan_tach_counter++; + } + EXTI->PR = (1U << 2); +} + +void fan_init(void){ + // 5000RPM * 4 tach edges / 60 seconds + REGISTER_INTERRUPT(EXTI2_IRQn, EXTI2_IRQ_Handler, 700U, FAULT_INTERRUPT_RATE_TACH) + + // Init PWM speed control + pwm_init(TIM3, 3); + + // Init TACH interrupt + register_set(&(SYSCFG->EXTICR[0]), SYSCFG_EXTICR1_EXTI2_PD, 0xF00U); + register_set_bits(&(EXTI->IMR), (1U << 2)); + register_set_bits(&(EXTI->RTSR), (1U << 2)); + register_set_bits(&(EXTI->FTSR), (1U << 2)); + NVIC_EnableIRQ(EXTI2_IRQn); +} \ No newline at end of file diff --git a/panda/board/drivers/gmlan_alt.h b/panda/board/drivers/gmlan_alt.h index c697a21b41ef9c..2f2e568055b02f 100644 --- a/panda/board/drivers/gmlan_alt.h +++ b/panda/board/drivers/gmlan_alt.h @@ -122,17 +122,22 @@ int get_bit_message(char *out, CAN_FIFOMailBox_TypeDef *to_bang) { return len; } +void TIM4_IRQ_Handler(void); + void setup_timer4(void) { + // register interrupt + REGISTER_INTERRUPT(TIM4_IRQn, TIM4_IRQ_Handler, 40000U, FAULT_INTERRUPT_RATE_GMLAN) + // setup - TIM4->PSC = 48-1; // tick on 1 us - TIM4->CR1 = TIM_CR1_CEN; // enable - TIM4->ARR = 30-1; // 33.3 kbps + register_set(&(TIM4->PSC), (48-1), 0xFFFFU); // Tick on 1 us + register_set(&(TIM4->CR1), TIM_CR1_CEN, 0x3FU); // Enable + register_set(&(TIM4->ARR), (30-1), 0xFFFFU); // 33.3 kbps // in case it's disabled NVIC_EnableIRQ(TIM4_IRQn); // run the interrupt - TIM4->DIER = TIM_DIER_UIE; // update interrupt + register_set(&(TIM4->DIER), TIM_DIER_UIE, 0x5F5FU); // Update interrupt TIM4->SR = 0; } @@ -171,9 +176,9 @@ void reset_gmlan_switch_timeout(void) { void set_bitbanged_gmlan(int val) { if (val != 0) { - GPIOB->ODR |= (1U << 13); + register_set_bits(&(GPIOB->ODR), (1U << 13)); } else { - GPIOB->ODR &= ~(1U << 13); + register_clear_bits(&(GPIOB->ODR), (1U << 13)); } } @@ -187,7 +192,7 @@ int gmlan_fail_count = 0; #define REQUIRED_SILENT_TIME 10 #define MAX_FAIL_COUNT 10 -void TIM4_IRQHandler(void) { +void TIM4_IRQ_Handler(void) { if (gmlan_alt_mode == BITBANG) { if ((TIM4->SR & TIM_SR_UIF) && (gmlan_sendmax != -1)) { int read = get_gpio_input(GPIOB, 12); @@ -231,12 +236,11 @@ void TIM4_IRQHandler(void) { if ((gmlan_sending == gmlan_sendmax) || (gmlan_fail_count == MAX_FAIL_COUNT)) { set_bitbanged_gmlan(1); // recessive set_gpio_mode(GPIOB, 13, MODE_INPUT); - TIM4->DIER = 0; // no update interrupt - TIM4->CR1 = 0; // disable timer + register_clear_bits(&(TIM4->DIER), TIM_DIER_UIE); // No update interrupt + register_set(&(TIM4->CR1), 0U, 0x3FU); // Disable timer gmlan_sendmax = -1; // exit } } - TIM4->SR = 0; } else if (gmlan_alt_mode == GPIO_SWITCH) { if ((TIM4->SR & TIM_SR_UIF) && (gmlan_switch_below_timeout != -1)) { if ((can_timeout_counter == 0) && gmlan_switch_timeout_enable) { @@ -259,10 +263,10 @@ void TIM4_IRQHandler(void) { } } } - TIM4->SR = 0; } else { - puts("invalid gmlan_alt_mode\n"); + // Invalid GMLAN mode. Do not put a print statement here, way too fast to keep up with } + TIM4->SR = 0; } bool bitbang_gmlan(CAN_FIFOMailBox_TypeDef *to_bang) { @@ -279,6 +283,7 @@ bool bitbang_gmlan(CAN_FIFOMailBox_TypeDef *to_bang) { set_bitbanged_gmlan(1); // recessive set_gpio_mode(GPIOB, 13, MODE_OUTPUT); + // 33kbps setup_timer4(); } return gmlan_send_ok; diff --git a/panda/board/drivers/harness.h b/panda/board/drivers/harness.h index 17520a4bab8055..4aeb41fe6300b0 100644 --- a/panda/board/drivers/harness.h +++ b/panda/board/drivers/harness.h @@ -8,14 +8,14 @@ uint8_t car_harness_status = 0U; struct harness_configuration { const bool has_harness; - GPIO_TypeDef *GPIO_SBU1; + GPIO_TypeDef *GPIO_SBU1; GPIO_TypeDef *GPIO_SBU2; - GPIO_TypeDef *GPIO_relay_normal; - GPIO_TypeDef *GPIO_relay_flipped; + GPIO_TypeDef *GPIO_relay_SBU1; + GPIO_TypeDef *GPIO_relay_SBU2; uint8_t pin_SBU1; uint8_t pin_SBU2; - uint8_t pin_relay_normal; - uint8_t pin_relay_flipped; + uint8_t pin_relay_SBU1; + uint8_t pin_relay_SBU2; uint8_t adc_channel_SBU1; uint8_t adc_channel_SBU2; }; @@ -30,9 +30,9 @@ void set_intercept_relay(bool intercept) { } if(car_harness_status == HARNESS_STATUS_NORMAL){ - set_gpio_output(current_board->harness_config->GPIO_relay_normal, current_board->harness_config->pin_relay_normal, !intercept); + set_gpio_output(current_board->harness_config->GPIO_relay_SBU2, current_board->harness_config->pin_relay_SBU2, !intercept); } else { - set_gpio_output(current_board->harness_config->GPIO_relay_flipped, current_board->harness_config->pin_relay_flipped, !intercept); + set_gpio_output(current_board->harness_config->GPIO_relay_SBU1, current_board->harness_config->pin_relay_SBU1, !intercept); } } } @@ -41,10 +41,10 @@ bool harness_check_ignition(void) { bool ret = false; switch(car_harness_status){ case HARNESS_STATUS_NORMAL: - ret = !get_gpio_input(current_board->harness_config->GPIO_SBU2, current_board->harness_config->pin_SBU2); + ret = !get_gpio_input(current_board->harness_config->GPIO_SBU1, current_board->harness_config->pin_SBU1); break; case HARNESS_STATUS_FLIPPED: - ret = !get_gpio_input(current_board->harness_config->GPIO_SBU1, current_board->harness_config->pin_SBU1); + ret = !get_gpio_input(current_board->harness_config->GPIO_SBU2, current_board->harness_config->pin_SBU2); break; default: break; @@ -52,28 +52,6 @@ bool harness_check_ignition(void) { return ret; } -// TODO: refactor to use harness config -void harness_setup_ignition_interrupts(void){ - if(car_harness_status == HARNESS_STATUS_NORMAL){ - SYSCFG->EXTICR[0] = SYSCFG_EXTICR1_EXTI3_PC; - EXTI->IMR |= (1U << 3); - EXTI->RTSR |= (1U << 3); - EXTI->FTSR |= (1U << 3); - puts("setup interrupts: normal\n"); - } else if(car_harness_status == HARNESS_STATUS_FLIPPED) { - SYSCFG->EXTICR[0] = SYSCFG_EXTICR1_EXTI0_PC; - EXTI->IMR |= (1U << 0); - EXTI->RTSR |= (1U << 0); - EXTI->FTSR |= (1U << 0); - NVIC_EnableIRQ(EXTI1_IRQn); - puts("setup interrupts: flipped\n"); - } else { - puts("tried to setup ignition interrupts without harness connected\n"); - } - NVIC_EnableIRQ(EXTI0_IRQn); - NVIC_EnableIRQ(EXTI3_IRQn); -} - uint8_t harness_detect_orientation(void) { uint8_t ret = HARNESS_STATUS_NC; @@ -84,11 +62,11 @@ uint8_t harness_detect_orientation(void) { // Detect connection and orientation if((sbu1_voltage < HARNESS_CONNECTED_THRESHOLD) || (sbu2_voltage < HARNESS_CONNECTED_THRESHOLD)){ if (sbu1_voltage < sbu2_voltage) { - // orientation normal - ret = HARNESS_STATUS_NORMAL; - } else { - // orientation flipped + // orientation flipped (PANDA_SBU1->HARNESS_SBU1(relay), PANDA_SBU2->HARNESS_SBU2(ign)) ret = HARNESS_STATUS_FLIPPED; + } else { + // orientation normal (PANDA_SBU2->HARNESS_SBU1(relay), PANDA_SBU1->HARNESS_SBU2(ign)) + ret = HARNESS_STATUS_NORMAL; } } #endif @@ -112,19 +90,9 @@ void harness_init(void) { set_gpio_mode(current_board->harness_config->GPIO_SBU1, current_board->harness_config->pin_SBU1, MODE_INPUT); set_gpio_mode(current_board->harness_config->GPIO_SBU2, current_board->harness_config->pin_SBU2, MODE_INPUT); - // now we have orientation, set pin ignition detection - if(car_harness_status == HARNESS_STATUS_NORMAL){ - set_gpio_mode(current_board->harness_config->GPIO_SBU2, current_board->harness_config->pin_SBU2, MODE_INPUT); - } else { - set_gpio_mode(current_board->harness_config->GPIO_SBU1, current_board->harness_config->pin_SBU1, MODE_INPUT); - } - // keep busses connected by default set_intercept_relay(false); - - // setup ignition interrupts - harness_setup_ignition_interrupts(); } else { puts("failed to detect car harness!\n"); } -} \ No newline at end of file +} diff --git a/panda/board/drivers/interrupts.h b/panda/board/drivers/interrupts.h new file mode 100644 index 00000000000000..f15c441ab04dfe --- /dev/null +++ b/panda/board/drivers/interrupts.h @@ -0,0 +1,164 @@ +typedef struct interrupt { + IRQn_Type irq_type; + void (*handler)(void); + uint32_t call_counter; + uint32_t max_call_rate; // Call rate is defined as the amount of calls each second + uint32_t call_rate_fault; +} interrupt; + +void unused_interrupt_handler(void) { + // Something is wrong if this handler is called! + puts("Unused interrupt handler called!\n"); + fault_occurred(FAULT_UNUSED_INTERRUPT_HANDLED); +} + +#define NUM_INTERRUPTS 102U // There are 102 external interrupt sources (see stm32f413.h) +interrupt interrupts[NUM_INTERRUPTS]; + +#define REGISTER_INTERRUPT(irq_num, func_ptr, call_rate, rate_fault) \ + interrupts[irq_num].irq_type = irq_num; \ + interrupts[irq_num].handler = func_ptr; \ + interrupts[irq_num].call_counter = 0U; \ + interrupts[irq_num].max_call_rate = call_rate; \ + interrupts[irq_num].call_rate_fault = rate_fault; + +bool check_interrupt_rate = false; + +void handle_interrupt(IRQn_Type irq_type){ + interrupts[irq_type].call_counter++; + interrupts[irq_type].handler(); + + // Check that the interrupts don't fire too often + if(check_interrupt_rate && (interrupts[irq_type].call_counter > interrupts[irq_type].max_call_rate)){ + puts("Interrupt 0x"); puth(irq_type); puts(" fired too often (0x"); puth(interrupts[irq_type].call_counter); puts("/s)!\n"); + fault_occurred(interrupts[irq_type].call_rate_fault); + } +} + +// Reset interrupt counter every second +void TIM6_DAC_IRQ_Handler(void) { + if (TIM6->SR != 0) { + for(uint16_t i=0U; iSR = 0; +} + +void init_interrupts(bool check_rate_limit){ + check_interrupt_rate = check_rate_limit; + + for(uint16_t i=0U; iAPB1ENR), RCC_APB1ENR_TIM6EN); // Enable interrupt timer peripheral + REGISTER_INTERRUPT(TIM6_DAC_IRQn, TIM6_DAC_IRQ_Handler, 1, FAULT_INTERRUPT_RATE_INTERRUPTS) + register_set(&(TIM6->PSC), (732-1), 0xFFFFU); + register_set(&(TIM6->DIER), TIM_DIER_UIE, 0x5F5FU); + register_set(&(TIM6->CR1), TIM_CR1_CEN, 0x3FU); + TIM6->SR = 0; + NVIC_EnableIRQ(TIM6_DAC_IRQn); +} + +// ********************* Bare interrupt handlers ********************* +// Only implemented the STM32F413 interrupts for now, the STM32F203 specific ones do not fall into the scope of SIL2 + +void WWDG_IRQHandler(void) {handle_interrupt(WWDG_IRQn);} +void PVD_IRQHandler(void) {handle_interrupt(PVD_IRQn);} +void TAMP_STAMP_IRQHandler(void) {handle_interrupt(TAMP_STAMP_IRQn);} +void RTC_WKUP_IRQHandler(void) {handle_interrupt(RTC_WKUP_IRQn);} +void FLASH_IRQHandler(void) {handle_interrupt(FLASH_IRQn);} +void RCC_IRQHandler(void) {handle_interrupt(RCC_IRQn);} +void EXTI0_IRQHandler(void) {handle_interrupt(EXTI0_IRQn);} +void EXTI1_IRQHandler(void) {handle_interrupt(EXTI1_IRQn);} +void EXTI2_IRQHandler(void) {handle_interrupt(EXTI2_IRQn);} +void EXTI3_IRQHandler(void) {handle_interrupt(EXTI3_IRQn);} +void EXTI4_IRQHandler(void) {handle_interrupt(EXTI4_IRQn);} +void DMA1_Stream0_IRQHandler(void) {handle_interrupt(DMA1_Stream0_IRQn);} +void DMA1_Stream1_IRQHandler(void) {handle_interrupt(DMA1_Stream1_IRQn);} +void DMA1_Stream2_IRQHandler(void) {handle_interrupt(DMA1_Stream2_IRQn);} +void DMA1_Stream3_IRQHandler(void) {handle_interrupt(DMA1_Stream3_IRQn);} +void DMA1_Stream4_IRQHandler(void) {handle_interrupt(DMA1_Stream4_IRQn);} +void DMA1_Stream5_IRQHandler(void) {handle_interrupt(DMA1_Stream5_IRQn);} +void DMA1_Stream6_IRQHandler(void) {handle_interrupt(DMA1_Stream6_IRQn);} +void ADC_IRQHandler(void) {handle_interrupt(ADC_IRQn);} +void CAN1_TX_IRQHandler(void) {handle_interrupt(CAN1_TX_IRQn);} +void CAN1_RX0_IRQHandler(void) {handle_interrupt(CAN1_RX0_IRQn);} +void CAN1_RX1_IRQHandler(void) {handle_interrupt(CAN1_RX1_IRQn);} +void CAN1_SCE_IRQHandler(void) {handle_interrupt(CAN1_SCE_IRQn);} +void EXTI9_5_IRQHandler(void) {handle_interrupt(EXTI9_5_IRQn);} +void TIM1_BRK_TIM9_IRQHandler(void) {handle_interrupt(TIM1_BRK_TIM9_IRQn);} +void TIM1_UP_TIM10_IRQHandler(void) {handle_interrupt(TIM1_UP_TIM10_IRQn);} +void TIM1_TRG_COM_TIM11_IRQHandler(void) {handle_interrupt(TIM1_TRG_COM_TIM11_IRQn);} +void TIM1_CC_IRQHandler(void) {handle_interrupt(TIM1_CC_IRQn);} +void TIM2_IRQHandler(void) {handle_interrupt(TIM2_IRQn);} +void TIM3_IRQHandler(void) {handle_interrupt(TIM3_IRQn);} +void TIM4_IRQHandler(void) {handle_interrupt(TIM4_IRQn);} +void I2C1_EV_IRQHandler(void) {handle_interrupt(I2C1_EV_IRQn);} +void I2C1_ER_IRQHandler(void) {handle_interrupt(I2C1_ER_IRQn);} +void I2C2_EV_IRQHandler(void) {handle_interrupt(I2C2_EV_IRQn);} +void I2C2_ER_IRQHandler(void) {handle_interrupt(I2C2_ER_IRQn);} +void SPI1_IRQHandler(void) {handle_interrupt(SPI1_IRQn);} +void SPI2_IRQHandler(void) {handle_interrupt(SPI2_IRQn);} +void USART1_IRQHandler(void) {handle_interrupt(USART1_IRQn);} +void USART2_IRQHandler(void) {handle_interrupt(USART2_IRQn);} +void USART3_IRQHandler(void) {handle_interrupt(USART3_IRQn);} +void EXTI15_10_IRQHandler(void) {handle_interrupt(EXTI15_10_IRQn);} +void RTC_Alarm_IRQHandler(void) {handle_interrupt(RTC_Alarm_IRQn);} +void OTG_FS_WKUP_IRQHandler(void) {handle_interrupt(OTG_FS_WKUP_IRQn);} +void TIM8_BRK_TIM12_IRQHandler(void) {handle_interrupt(TIM8_BRK_TIM12_IRQn);} +void TIM8_UP_TIM13_IRQHandler(void) {handle_interrupt(TIM8_UP_TIM13_IRQn);} +void TIM8_TRG_COM_TIM14_IRQHandler(void) {handle_interrupt(TIM8_TRG_COM_TIM14_IRQn);} +void TIM8_CC_IRQHandler(void) {handle_interrupt(TIM8_CC_IRQn);} +void DMA1_Stream7_IRQHandler(void) {handle_interrupt(DMA1_Stream7_IRQn);} +void FSMC_IRQHandler(void) {handle_interrupt(FSMC_IRQn);} +void SDIO_IRQHandler(void) {handle_interrupt(SDIO_IRQn);} +void TIM5_IRQHandler(void) {handle_interrupt(TIM5_IRQn);} +void SPI3_IRQHandler(void) {handle_interrupt(SPI3_IRQn);} +void UART4_IRQHandler(void) {handle_interrupt(UART4_IRQn);} +void UART5_IRQHandler(void) {handle_interrupt(UART5_IRQn);} +void TIM6_DAC_IRQHandler(void) {handle_interrupt(TIM6_DAC_IRQn);} +void TIM7_IRQHandler(void) {handle_interrupt(TIM7_IRQn);} +void DMA2_Stream0_IRQHandler(void) {handle_interrupt(DMA2_Stream0_IRQn);} +void DMA2_Stream1_IRQHandler(void) {handle_interrupt(DMA2_Stream1_IRQn);} +void DMA2_Stream2_IRQHandler(void) {handle_interrupt(DMA2_Stream2_IRQn);} +void DMA2_Stream3_IRQHandler(void) {handle_interrupt(DMA2_Stream3_IRQn);} +void DMA2_Stream4_IRQHandler(void) {handle_interrupt(DMA2_Stream4_IRQn);} +void CAN2_TX_IRQHandler(void) {handle_interrupt(CAN2_TX_IRQn);} +void CAN2_RX0_IRQHandler(void) {handle_interrupt(CAN2_RX0_IRQn);} +void CAN2_RX1_IRQHandler(void) {handle_interrupt(CAN2_RX1_IRQn);} +void CAN2_SCE_IRQHandler(void) {handle_interrupt(CAN2_SCE_IRQn);} +void OTG_FS_IRQHandler(void) {handle_interrupt(OTG_FS_IRQn);} +void DMA2_Stream5_IRQHandler(void) {handle_interrupt(DMA2_Stream5_IRQn);} +void DMA2_Stream6_IRQHandler(void) {handle_interrupt(DMA2_Stream6_IRQn);} +void DMA2_Stream7_IRQHandler(void) {handle_interrupt(DMA2_Stream7_IRQn);} +void USART6_IRQHandler(void) {handle_interrupt(USART6_IRQn);} +void I2C3_EV_IRQHandler(void) {handle_interrupt(I2C3_EV_IRQn);} +void I2C3_ER_IRQHandler(void) {handle_interrupt(I2C3_ER_IRQn);} +#ifdef STM32F4 + void DFSDM1_FLT0_IRQHandler(void) {handle_interrupt(DFSDM1_FLT0_IRQn);} + void DFSDM1_FLT1_IRQHandler(void) {handle_interrupt(DFSDM1_FLT1_IRQn);} + void CAN3_TX_IRQHandler(void) {handle_interrupt(CAN3_TX_IRQn);} + void CAN3_RX0_IRQHandler(void) {handle_interrupt(CAN3_RX0_IRQn);} + void CAN3_RX1_IRQHandler(void) {handle_interrupt(CAN3_RX1_IRQn);} + void CAN3_SCE_IRQHandler(void) {handle_interrupt(CAN3_SCE_IRQn);} + void RNG_IRQHandler(void) {handle_interrupt(RNG_IRQn);} + void FPU_IRQHandler(void) {handle_interrupt(FPU_IRQn);} + void UART7_IRQHandler(void) {handle_interrupt(UART7_IRQn);} + void UART8_IRQHandler(void) {handle_interrupt(UART8_IRQn);} + void SPI4_IRQHandler(void) {handle_interrupt(SPI4_IRQn);} + void SPI5_IRQHandler(void) {handle_interrupt(SPI5_IRQn);} + void SAI1_IRQHandler(void) {handle_interrupt(SAI1_IRQn);} + void UART9_IRQHandler(void) {handle_interrupt(UART9_IRQn);} + void UART10_IRQHandler(void) {handle_interrupt(UART10_IRQn);} + void QUADSPI_IRQHandler(void) {handle_interrupt(QUADSPI_IRQn);} + void FMPI2C1_EV_IRQHandler(void) {handle_interrupt(FMPI2C1_EV_IRQn);} + void FMPI2C1_ER_IRQHandler(void) {handle_interrupt(FMPI2C1_ER_IRQn);} + void LPTIM1_IRQHandler(void) {handle_interrupt(LPTIM1_IRQn);} + void DFSDM2_FLT0_IRQHandler(void) {handle_interrupt(DFSDM2_FLT0_IRQn);} + void DFSDM2_FLT1_IRQHandler(void) {handle_interrupt(DFSDM2_FLT1_IRQn);} + void DFSDM2_FLT2_IRQHandler(void) {handle_interrupt(DFSDM2_FLT2_IRQn);} + void DFSDM2_FLT3_IRQHandler(void) {handle_interrupt(DFSDM2_FLT3_IRQn);} +#endif \ No newline at end of file diff --git a/panda/board/drivers/kline_init.h b/panda/board/drivers/kline_init.h new file mode 100644 index 00000000000000..a8a859cba7704e --- /dev/null +++ b/panda/board/drivers/kline_init.h @@ -0,0 +1,119 @@ +void TIM5_IRQ_Handler(void); + +void setup_timer5(void) { + // register interrupt + REGISTER_INTERRUPT(TIM5_IRQn, TIM5_IRQ_Handler, 1050000U, FAULT_INTERRUPT_RATE_KLINE_INIT) + + // setup + register_set(&(TIM5->PSC), (48-1), 0xFFFFU); // Tick on 1 us + register_set(&(TIM5->CR1), TIM_CR1_CEN, 0x3FU); // Enable + register_set(&(TIM5->ARR), (5000-1), 0xFFFFFFFFU); // Reset every 5 ms + + // in case it's disabled + NVIC_EnableIRQ(TIM5_IRQn); + + // run the interrupt + register_set(&(TIM5->DIER), TIM_DIER_UIE, 0x5F5FU); // Update interrupt + TIM5->SR = 0; +} + +bool k_init = false; +bool l_init = false; +void setup_kline(bool bitbang) { + if (bitbang) { + if (k_init) { + set_gpio_output(GPIOC, 12, true); + } + if (l_init) { + set_gpio_output(GPIOC, 10, true); + } + } else { + if (k_init) { + set_gpio_mode(GPIOC, 12, MODE_ALTERNATE); + } + if (l_init) { + set_gpio_mode(GPIOC, 10, MODE_ALTERNATE); + } + } +} + +void set_bitbanged_kline(bool marking) { + // tickle needs to be super fast (so logic level doesn't change) + ENTER_CRITICAL(); + if (k_init) { + register_set_bits(&(GPIOC->ODR), (1U << 12)); + if (!marking) { + register_clear_bits(&(GPIOC->ODR), (1U << 12)); + } + } + if (l_init) { + register_set_bits(&(GPIOC->ODR), (1U << 10)); + if (!marking) { + register_clear_bits(&(GPIOC->ODR), (1U << 10)); + } + } + EXIT_CRITICAL(); + // blink blue LED each time line is pulled low + current_board->set_led(LED_BLUE, marking); +} + +uint16_t kline_data = 0; +uint16_t kline_data_len = 0; +uint16_t kline_bit_count = 0; +uint16_t kline_tick_count = 0; +uint16_t kline_ticks_per_bit = 0; + +void TIM5_IRQ_Handler(void) { + if ((TIM5->SR & TIM_SR_UIF) && (kline_data != 0U)) { + if (kline_bit_count < kline_data_len) { + bool marking = (kline_data & (1U << kline_bit_count)) != 0U; + set_bitbanged_kline(marking); + } else { + register_clear_bits(&(TIM5->DIER), TIM_DIER_UIE); // No update interrupt + register_set(&(TIM5->CR1), 0U, 0x3FU); // Disable timer + setup_kline(false); + kline_data = 0U; + USB_WritePacket(NULL, 0, 0); // required call (so send nothing) + USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; + } + kline_tick_count++; + if ((kline_tick_count % kline_ticks_per_bit) == 0U) { + kline_bit_count++; + } + } + TIM5->SR = 0; +} + +bool bitbang_five_baud_addr(bool k, bool l, uint8_t addr) { + bool result = false; + if (kline_data == 0U) { + k_init = k; + l_init = l; + kline_data = (addr << 1) + 0x200U; // add start/stop bits + kline_data_len = 10U; + kline_bit_count = 0; + kline_tick_count = 0; + kline_ticks_per_bit = 40U; // 200ms == 5bps + setup_kline(true); + setup_timer5(); + result = true; + } + return result; +} + +bool bitbang_wakeup(bool k, bool l) { + bool result = false; + if (kline_data == 0U) { + k_init = k; + l_init = l; + kline_data = 2U; // low then high + kline_data_len = 2U; + kline_bit_count = 0; + kline_tick_count = 0; + kline_ticks_per_bit = 5U; // 25ms == 40bps + setup_kline(true); + setup_timer5(); + result = true; + } + return result; +} diff --git a/panda/board/drivers/lin.h b/panda/board/drivers/lin.h deleted file mode 100644 index 6f9106af3728d0..00000000000000 --- a/panda/board/drivers/lin.h +++ /dev/null @@ -1,175 +0,0 @@ -//-------------------------------------------------------------- -// LIN Defines -//-------------------------------------------------------------- -#define LIN_SYNC_DATA 0x55 // SyncField (do not change) -#define LIN_MAX_DATA 8 // max 8 databytes - - -//-------------------------------------------------------------- -// LIN error messages -//-------------------------------------------------------------- -typedef enum { - LIN_OK = 0, // no error - LIN_WRONG_LEN, // wrong number of data - LIN_RX_EMPTY, // no frame received - LIN_WRONG_CRC // Checksum wrong -}LIN_ERR_t; - -//-------------------------------------------------------------- -// LIN frame Struct -//-------------------------------------------------------------- -typedef struct { - uint8_t has_response; // set to 1 if message expects a response; else set to 0 - uint8_t frame_id; // ID number of the frame - uint8_t data_len; // number of data bytes - uint8_t data[LIN_MAX_DATA]; // data -}LIN_FRAME_t; - -uint8_t p_LIN_makeChecksum(LIN_FRAME_t *frame); -void USART_SendBreak(uart_ring *u); - - -// -------------------------------------------------------------- -// sends data via LIN interface -// frame: -// frame_id = Unique ID [0x00 to 0xFF] -// data_len = length of data to be sent -// data [] = data to be sent -// -// return_value: -// LIN_OK = Frame has been sent -// LIN_WRONG_LEN = invalid data length -// -------------------------------------------------------------- -LIN_ERR_t LIN_SendData(uart_ring *LIN_UART, LIN_FRAME_t *frame) -{ - uint8_t checksum,n; - - // check the length - if((frame -> data_len < 1) || (frame -> data_len > LIN_MAX_DATA)) { - return(LIN_WRONG_LEN); - } - - // calculate checksum - checksum=p_LIN_makeChecksum(frame); - - //------------------------ - // Break-Field - //------------------------ - USART_SendBreak(LIN_UART); - - //------------------------ - // Sync-Field - //------------------------ - putc(LIN_UART, LIN_SYNC_DATA); - - //------------------------ - // ID-Field - //------------------------ - putc(LIN_UART, frame->frame_id); - - //------------------------ - // Data-Field [1...n] - //------------------------ - for(n=0; n < frame -> data_len; n++) { - putc(LIN_UART, frame -> data[n]); - } - - //------------------------ - // CRC-Field - //------------------------ - putc(LIN_UART, checksum); - - return(LIN_OK); -} - - -// -------------------------------------------------------------- -// receives data via LIN interface -// frame: -// frame_id = Unique ID [0x00 to 0xFF] -// data_len = number of data to be received -// return: -// data [] = data received (if LIN_OK) -// -// return_value: -// LIN_OK = Frame was received -// LIN_WRONG_LEN = wrong number of data -// LIN_RX_EMPTY = no frame received -// LIN_WRONG_CRC = Checksum wrong -// -------------------------------------------------------------- -LIN_ERR_t LIN_SendReceiveFrame(uart_ring *LIN_UART, LIN_FRAME_t *frame) -{ - // check the length - if((frame -> data_len < 1) || (frame -> data_len > LIN_MAX_DATA)) { - return(LIN_WRONG_LEN); - } - - //------------------------------- - // Break-Field - //------------------------------- - USART_SendBreak(LIN_UART); - - //------------------------------- - // Sync-Field - //------------------------------- - putc(LIN_UART, LIN_SYNC_DATA); - - //------------------------------- - // ID-Field - //------------------------------- - putc(LIN_UART, frame->frame_id); - - //now wait for the slave device to respond with the data - - return(LIN_OK); -} - -LIN_ERR_t LIN_ReceiveData(uart_ring *LIN_UART, LIN_FRAME_t *frame) -{ - //------------------------------- - // copy received data - //------------------------------- - - //TODO: Get receive working. Do I need to add a small delay here? - - uint8_t *resp = 0; - int resp_len = 0; - - while ((resp_len < frame -> data_len) && getc(LIN_UART, (char*)&resp[resp_len])) { - ++resp_len; - frame->data[resp_len]=resp[resp_len]; - } - - return(LIN_OK); -} - -void USART_SendBreak(uart_ring *u) -{ - SET_BIT(u -> uart -> CR1, USART_CR1_SBK); -} - -// -------------------------------------------------------------- -// internal function -// Calculate checksum over all data -// (classic-mode = inverted modulo256 sum) -// -// ret_value = checksum -//-------------------------------------------------------------- -uint8_t p_LIN_makeChecksum(LIN_FRAME_t *frame) -{ - uint8_t ret_value=0, n; - uint16_t dummy; - - // calculate checksum - dummy = 0; - for(n = 0; n < frame -> data_len; n++) { - dummy += frame -> data[n]; - if (dummy > 0xFF) { - dummy -= 0xFF; - } - } - ret_value = (uint8_t)(dummy); - ret_value ^= 0xFF; - - return(ret_value); -} diff --git a/panda/board/drivers/llcan.h b/panda/board/drivers/llcan.h index 0a698d4e8d9b93..68ca242bdefd9b 100644 --- a/panda/board/drivers/llcan.h +++ b/panda/board/drivers/llcan.h @@ -11,83 +11,127 @@ #define GET_BUS(msg) (((msg)->RDTR >> 4) & 0xFF) #define GET_LEN(msg) ((msg)->RDTR & 0xF) #define GET_ADDR(msg) ((((msg)->RIR & 4) != 0) ? ((msg)->RIR >> 3) : ((msg)->RIR >> 21)) -#define GET_BYTE(msg, b) (((int)(b) > 3) ? (((msg)->RDHR >> (8U * ((unsigned int)(b) % 4U))) & 0XFFU) : (((msg)->RDLR >> (8U * (unsigned int)(b))) & 0xFFU)) +#define GET_BYTE(msg, b) (((int)(b) > 3) ? (((msg)->RDHR >> (8U * ((unsigned int)(b) % 4U))) & 0xFFU) : (((msg)->RDLR >> (8U * (unsigned int)(b))) & 0xFFU)) #define GET_BYTES_04(msg) ((msg)->RDLR) #define GET_BYTES_48(msg) ((msg)->RDHR) +#define GET_FLAG(value, mask) (((__typeof__(mask))param & mask) == mask) + +#define CAN_INIT_TIMEOUT_MS 500U +#define CAN_NAME_FROM_CANIF(CAN_DEV) (((CAN_DEV)==CAN1) ? "CAN1" : (((CAN_DEV) == CAN2) ? "CAN2" : "CAN3")) void puts(const char *a); bool llcan_set_speed(CAN_TypeDef *CAN_obj, uint32_t speed, bool loopback, bool silent) { - // initialization mode - CAN_obj->MCR = CAN_MCR_TTCM | CAN_MCR_INRQ; - while((CAN_obj->MSR & CAN_MSR_INAK) != CAN_MSR_INAK); - - // set time quanta from defines - CAN_obj->BTR = (CAN_BTR_TS1_0 * (CAN_SEQ1-1)) | - (CAN_BTR_TS2_0 * (CAN_SEQ2-1)) | - (can_speed_to_prescaler(speed) - 1U); + bool ret = true; - // silent loopback mode for debugging - if (loopback) { - CAN_obj->BTR |= CAN_BTR_SILM | CAN_BTR_LBKM; - } - if (silent) { - CAN_obj->BTR |= CAN_BTR_SILM; + // initialization mode + register_set(&(CAN_obj->MCR), CAN_MCR_TTCM | CAN_MCR_INRQ, 0x180FFU); + uint32_t timeout_counter = 0U; + while((CAN_obj->MSR & CAN_MSR_INAK) != CAN_MSR_INAK){ + // Delay for about 1ms + delay(10000); + timeout_counter++; + + if(timeout_counter >= CAN_INIT_TIMEOUT_MS){ + puts(CAN_NAME_FROM_CANIF(CAN_obj)); puts(" set_speed timed out (1)!\n"); + ret = false; + break; + } } - // reset - // cppcheck-suppress redundantAssignment ; it's a register - CAN_obj->MCR = CAN_MCR_TTCM | CAN_MCR_ABOM; - - #define CAN_TIMEOUT 1000000 - int tmp = 0; - bool ret = false; - while(((CAN_obj->MSR & CAN_MSR_INAK) == CAN_MSR_INAK) && (tmp < CAN_TIMEOUT)) tmp++; - if (tmp < CAN_TIMEOUT) { - ret = true; + if(ret){ + // set time quanta from defines + register_set(&(CAN_obj->BTR), ((CAN_BTR_TS1_0 * (CAN_SEQ1-1)) | + (CAN_BTR_TS2_0 * (CAN_SEQ2-1)) | + (can_speed_to_prescaler(speed) - 1U)), 0xC37F03FFU); + + // silent loopback mode for debugging + if (loopback) { + register_set_bits(&(CAN_obj->BTR), CAN_BTR_SILM | CAN_BTR_LBKM); + } + if (silent) { + register_set_bits(&(CAN_obj->BTR), CAN_BTR_SILM); + } + + // reset + register_set(&(CAN_obj->MCR), CAN_MCR_TTCM | CAN_MCR_ABOM, 0x180FFU); + + timeout_counter = 0U; + while(((CAN_obj->MSR & CAN_MSR_INAK) == CAN_MSR_INAK)) { + // Delay for about 1ms + delay(10000); + timeout_counter++; + + if(timeout_counter >= CAN_INIT_TIMEOUT_MS){ + puts(CAN_NAME_FROM_CANIF(CAN_obj)); puts(" set_speed timed out (2)!\n"); + ret = false; + break; + } + } } return ret; } -void llcan_init(CAN_TypeDef *CAN_obj) { - // accept all filter - CAN_obj->FMR |= CAN_FMR_FINIT; - - // no mask - CAN_obj->sFilterRegister[0].FR1 = 0; - CAN_obj->sFilterRegister[0].FR2 = 0; - CAN_obj->sFilterRegister[14].FR1 = 0; - CAN_obj->sFilterRegister[14].FR2 = 0; - CAN_obj->FA1R |= 1U | (1U << 14); - - CAN_obj->FMR &= ~(CAN_FMR_FINIT); - - // enable certain CAN interrupts - CAN_obj->IER |= CAN_IER_TMEIE | CAN_IER_FMPIE0 | CAN_IER_WKUIE; - - if (CAN_obj == CAN1) { - NVIC_EnableIRQ(CAN1_TX_IRQn); - NVIC_EnableIRQ(CAN1_RX0_IRQn); - NVIC_EnableIRQ(CAN1_SCE_IRQn); - } else if (CAN_obj == CAN2) { - NVIC_EnableIRQ(CAN2_TX_IRQn); - NVIC_EnableIRQ(CAN2_RX0_IRQn); - NVIC_EnableIRQ(CAN2_SCE_IRQn); -#ifdef CAN3 - } else if (CAN_obj == CAN3) { - NVIC_EnableIRQ(CAN3_TX_IRQn); - NVIC_EnableIRQ(CAN3_RX0_IRQn); - NVIC_EnableIRQ(CAN3_SCE_IRQn); -#endif - } else { - puts("Invalid CAN: initialization failed\n"); +bool llcan_init(CAN_TypeDef *CAN_obj) { + bool ret = true; + + // Enter init mode + register_set_bits(&(CAN_obj->FMR), CAN_FMR_FINIT); + + // Wait for INAK bit to be set + uint32_t timeout_counter = 0U; + while(((CAN_obj->MSR & CAN_MSR_INAK) == CAN_MSR_INAK)) { + // Delay for about 1ms + delay(10000); + timeout_counter++; + + if(timeout_counter >= CAN_INIT_TIMEOUT_MS){ + puts(CAN_NAME_FROM_CANIF(CAN_obj)); puts(" initialization timed out!\n"); + ret = false; + break; + } } + + if(ret){ + // no mask + // For some weird reason some of these registers do not want to set properly on CAN2 and CAN3. Probably something to do with the single/dual mode and their different filters. + CAN_obj->sFilterRegister[0].FR1 = 0U; + CAN_obj->sFilterRegister[0].FR2 = 0U; + CAN_obj->sFilterRegister[14].FR1 = 0U; + CAN_obj->sFilterRegister[14].FR2 = 0U; + CAN_obj->FA1R |= 1U | (1U << 14); + + // Exit init mode, do not wait + register_clear_bits(&(CAN_obj->FMR), CAN_FMR_FINIT); + + // enable certain CAN interrupts + register_set_bits(&(CAN_obj->IER), CAN_IER_TMEIE | CAN_IER_FMPIE0 | CAN_IER_WKUIE); + + if (CAN_obj == CAN1) { + NVIC_EnableIRQ(CAN1_TX_IRQn); + NVIC_EnableIRQ(CAN1_RX0_IRQn); + NVIC_EnableIRQ(CAN1_SCE_IRQn); + } else if (CAN_obj == CAN2) { + NVIC_EnableIRQ(CAN2_TX_IRQn); + NVIC_EnableIRQ(CAN2_RX0_IRQn); + NVIC_EnableIRQ(CAN2_SCE_IRQn); + #ifdef CAN3 + } else if (CAN_obj == CAN3) { + NVIC_EnableIRQ(CAN3_TX_IRQn); + NVIC_EnableIRQ(CAN3_RX0_IRQn); + NVIC_EnableIRQ(CAN3_SCE_IRQn); + #endif + } else { + puts("Invalid CAN: initialization failed\n"); + } + } + return ret; } void llcan_clear_send(CAN_TypeDef *CAN_obj) { CAN_obj->TSR |= CAN_TSR_ABRQ0; - CAN_obj->MSR &= ~(CAN_MSR_ERRI); + register_clear_bits(&(CAN_obj->MSR), CAN_MSR_ERRI); // cppcheck-suppress selfAssignment ; needed to clear the register CAN_obj->MSR = CAN_obj->MSR; } diff --git a/panda/board/drivers/llgpio.h b/panda/board/drivers/llgpio.h index a89c8a8e2d5dcf..0bd58c3b8a5316 100644 --- a/panda/board/drivers/llgpio.h +++ b/panda/board/drivers/llgpio.h @@ -11,42 +11,52 @@ #define OUTPUT_TYPE_OPEN_DRAIN 1U void set_gpio_mode(GPIO_TypeDef *GPIO, unsigned int pin, unsigned int mode) { + ENTER_CRITICAL(); uint32_t tmp = GPIO->MODER; tmp &= ~(3U << (pin * 2U)); tmp |= (mode << (pin * 2U)); - GPIO->MODER = tmp; + register_set(&(GPIO->MODER), tmp, 0xFFFFFFFFU); + EXIT_CRITICAL(); } void set_gpio_output(GPIO_TypeDef *GPIO, unsigned int pin, bool enabled) { + ENTER_CRITICAL(); if (enabled) { - GPIO->ODR |= (1U << pin); + register_set_bits(&(GPIO->ODR), (1U << pin)); } else { - GPIO->ODR &= ~(1U << pin); + register_clear_bits(&(GPIO->ODR), (1U << pin)); } set_gpio_mode(GPIO, pin, MODE_OUTPUT); + EXIT_CRITICAL(); } void set_gpio_output_type(GPIO_TypeDef *GPIO, unsigned int pin, unsigned int output_type){ + ENTER_CRITICAL(); if(output_type == OUTPUT_TYPE_OPEN_DRAIN) { - GPIO->OTYPER |= (1U << pin); + register_set_bits(&(GPIO->OTYPER), (1U << pin)); } else { - GPIO->OTYPER &= ~(1U << pin); + register_clear_bits(&(GPIO->OTYPER), (1U << pin)); } + EXIT_CRITICAL(); } void set_gpio_alternate(GPIO_TypeDef *GPIO, unsigned int pin, unsigned int mode) { + ENTER_CRITICAL(); uint32_t tmp = GPIO->AFR[pin >> 3U]; tmp &= ~(0xFU << ((pin & 7U) * 4U)); tmp |= mode << ((pin & 7U) * 4U); - GPIO->AFR[pin >> 3] = tmp; + register_set(&(GPIO->AFR[pin >> 3]), tmp, 0xFFFFFFFFU); set_gpio_mode(GPIO, pin, MODE_ALTERNATE); + EXIT_CRITICAL(); } void set_gpio_pullup(GPIO_TypeDef *GPIO, unsigned int pin, unsigned int mode) { + ENTER_CRITICAL(); uint32_t tmp = GPIO->PUPDR; tmp &= ~(3U << (pin * 2U)); tmp |= (mode << (pin * 2U)); - GPIO->PUPDR = tmp; + register_set(&(GPIO->PUPDR), tmp, 0xFFFFFFFFU); + EXIT_CRITICAL(); } int get_gpio_input(GPIO_TypeDef *GPIO, unsigned int pin) { diff --git a/panda/board/drivers/pwm.h b/panda/board/drivers/pwm.h new file mode 100644 index 00000000000000..c3709200c1ce1e --- /dev/null +++ b/panda/board/drivers/pwm.h @@ -0,0 +1,56 @@ +#define PWM_COUNTER_OVERFLOW 2000U // To get ~50kHz + +// TODO: Implement for 32-bit timers + +void pwm_init(TIM_TypeDef *TIM, uint8_t channel){ + // Enable timer and auto-reload + register_set(&(TIM->CR1), TIM_CR1_CEN | TIM_CR1_ARPE, 0x3FU); + + // Set channel as PWM mode 1 and enable output + switch(channel){ + case 1U: + register_set_bits(&(TIM->CCMR1), (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1PE)); + register_set_bits(&(TIM->CCER), TIM_CCER_CC1E); + break; + case 2U: + register_set_bits(&(TIM->CCMR1), (TIM_CCMR1_OC2M_2 | TIM_CCMR1_OC2M_1 | TIM_CCMR1_OC2PE)); + register_set_bits(&(TIM->CCER), TIM_CCER_CC2E); + break; + case 3U: + register_set_bits(&(TIM->CCMR2), (TIM_CCMR2_OC3M_2 | TIM_CCMR2_OC3M_1 | TIM_CCMR2_OC3PE)); + register_set_bits(&(TIM->CCER), TIM_CCER_CC3E); + break; + case 4U: + register_set_bits(&(TIM->CCMR2), (TIM_CCMR2_OC4M_2 | TIM_CCMR2_OC4M_1 | TIM_CCMR2_OC4PE)); + register_set_bits(&(TIM->CCER), TIM_CCER_CC4E); + break; + default: + break; + } + + // Set max counter value + register_set(&(TIM->ARR), PWM_COUNTER_OVERFLOW, 0xFFFFU); + + // Update registers and clear counter + TIM->EGR |= TIM_EGR_UG; +} + +void pwm_set(TIM_TypeDef *TIM, uint8_t channel, uint8_t percentage){ + uint16_t comp_value = (((uint16_t) percentage * PWM_COUNTER_OVERFLOW) / 100U); + switch(channel){ + case 1U: + register_set(&(TIM->CCR1), comp_value, 0xFFFFU); + break; + case 2U: + register_set(&(TIM->CCR2), comp_value, 0xFFFFU); + break; + case 3U: + register_set(&(TIM->CCR3), comp_value, 0xFFFFU); + break; + case 4U: + register_set(&(TIM->CCR4), comp_value, 0xFFFFU); + break; + default: + break; + } +} \ No newline at end of file diff --git a/panda/board/drivers/registers.h b/panda/board/drivers/registers.h new file mode 100644 index 00000000000000..76748295d9f7be --- /dev/null +++ b/panda/board/drivers/registers.h @@ -0,0 +1,81 @@ + +typedef struct reg { + volatile uint32_t *address; + uint32_t value; + uint32_t check_mask; +} reg; + +// 10 bit hash with 23 as a prime +#define REGISTER_MAP_SIZE 0x3FFU +#define HASHING_PRIME 23U +#define CHECK_COLLISION(hash, addr) (((uint32_t) register_map[hash].address != 0U) && (register_map[hash].address != addr)) + +reg register_map[REGISTER_MAP_SIZE]; + +// Hash spread in first and second iterations seems to be reasonable. +// See: tests/development/register_hashmap_spread.py +// Also, check the collision warnings in the debug output, and minimize those. +uint16_t hash_addr(uint32_t input){ + return (((input >> 16U) ^ ((((input + 1U) & 0xFFFFU) * HASHING_PRIME) & 0xFFFFU)) & REGISTER_MAP_SIZE); +} + +// Do not put bits in the check mask that get changed by the hardware +void register_set(volatile uint32_t *addr, uint32_t val, uint32_t mask){ + ENTER_CRITICAL() + // Set bits in register that are also in the mask + (*addr) = ((*addr) & (~mask)) | (val & mask); + + // Add these values to the map + uint16_t hash = hash_addr((uint32_t) addr); + uint16_t tries = REGISTER_MAP_SIZE; + while(CHECK_COLLISION(hash, addr) && (tries > 0U)) { hash = hash_addr((uint32_t) hash); tries--;} + if (tries != 0U){ + register_map[hash].address = addr; + register_map[hash].value = (register_map[hash].value & (~mask)) | (val & mask); + register_map[hash].check_mask |= mask; + } else { + #ifdef DEBUG_FAULTS + puts("Hash collision: address 0x"); puth((uint32_t) addr); puts("!\n"); + #endif + } + EXIT_CRITICAL() +} + +// Set individual bits. Also add them to the check_mask. +// Do not use this to change bits that get reset by the hardware +void register_set_bits(volatile uint32_t *addr, uint32_t val) { + return register_set(addr, val, val); +} + +// Clear individual bits. Also add them to the check_mask. +// Do not use this to clear bits that get set by the hardware +void register_clear_bits(volatile uint32_t *addr, uint32_t val) { + return register_set(addr, (~val), val); +} + +// To be called periodically +void check_registers(void){ + for(uint16_t i=0U; i> 4U) * 10U) + (value & 0x0FU); +} + +void rtc_init(void){ + if(board_has_rtc()){ + // Initialize RTC module and clock if not done already. + if((RCC->BDCR & RCC_BDCR_MASK) != RCC_BDCR_OPTIONS){ + puts("Initializing RTC\n"); + // Reset backup domain + register_set_bits(&(RCC->BDCR), RCC_BDCR_BDRST); + + // Disable write protection + register_set_bits(&(PWR->CR), PWR_CR_DBP); + + // Clear backup domain reset + register_clear_bits(&(RCC->BDCR), RCC_BDCR_BDRST); + + // Set RTC options + register_set(&(RCC->BDCR), RCC_BDCR_OPTIONS, RCC_BDCR_MASK); + + // Enable write protection + register_clear_bits(&(PWR->CR), PWR_CR_DBP); + } + } +} + +void rtc_set_time(timestamp_t time){ + if(board_has_rtc()){ + puts("Setting RTC time\n"); + + // Disable write protection + register_set_bits(&(PWR->CR), PWR_CR_DBP); + RTC->WPR = 0xCA; + RTC->WPR = 0x53; + + // Enable initialization mode + register_set_bits(&(RTC->ISR), RTC_ISR_INIT); + while((RTC->ISR & RTC_ISR_INITF) == 0){} + + // Set time + RTC->TR = (to_bcd(time.hour) << RTC_TR_HU_Pos) | (to_bcd(time.minute) << RTC_TR_MNU_Pos) | (to_bcd(time.second) << RTC_TR_SU_Pos); + RTC->DR = (to_bcd(time.year - YEAR_OFFSET) << RTC_DR_YU_Pos) | (time.weekday << RTC_DR_WDU_Pos) | (to_bcd(time.month) << RTC_DR_MU_Pos) | (to_bcd(time.day) << RTC_DR_DU_Pos); + + // Set options + register_set(&(RTC->CR), 0U, 0xFCFFFFU); + + // Disable initalization mode + register_clear_bits(&(RTC->ISR), RTC_ISR_INIT); + + // Wait for synchronization + while((RTC->ISR & RTC_ISR_RSF) == 0){} + + // Re-enable write protection + RTC->WPR = 0x00; + register_clear_bits(&(PWR->CR), PWR_CR_DBP); + } +} + +timestamp_t rtc_get_time(void){ + timestamp_t result; + // Init with zero values in case there is no RTC running + result.year = 0U; + result.month = 0U; + result.day = 0U; + result.weekday = 0U; + result.hour = 0U; + result.minute = 0U; + result.second = 0U; + + if(board_has_rtc()){ + // Wait until the register sync flag is set + while((RTC->ISR & RTC_ISR_RSF) == 0){} + + // Read time and date registers. Since our HSE > 7*LSE, this should be fine. + uint32_t time = RTC->TR; + uint32_t date = RTC->DR; + + // Parse values + result.year = from_bcd((date & (RTC_DR_YT | RTC_DR_YU)) >> RTC_DR_YU_Pos) + YEAR_OFFSET; + result.month = from_bcd((date & (RTC_DR_MT | RTC_DR_MU)) >> RTC_DR_MU_Pos); + result.day = from_bcd((date & (RTC_DR_DT | RTC_DR_DU)) >> RTC_DR_DU_Pos); + result.weekday = ((date & RTC_DR_WDU) >> RTC_DR_WDU_Pos); + result.hour = from_bcd((time & (RTC_TR_HT | RTC_TR_HU)) >> RTC_TR_HU_Pos); + result.minute = from_bcd((time & (RTC_TR_MNT | RTC_TR_MNU)) >> RTC_TR_MNU_Pos); + result.second = from_bcd((time & (RTC_TR_ST | RTC_TR_SU)) >> RTC_TR_SU_Pos); + } + return result; +} \ No newline at end of file diff --git a/panda/board/drivers/spi.h b/panda/board/drivers/spi.h index 26690984de7bb8..29963b6bdfce77 100644 --- a/panda/board/drivers/spi.h +++ b/panda/board/drivers/spi.h @@ -10,45 +10,22 @@ uint8_t spi_buf[SPI_BUF_SIZE]; int spi_buf_count = 0; int spi_total_count = 0; -void spi_init(void) { - //puts("SPI init\n"); - SPI1->CR1 = SPI_CR1_SPE; - - // enable SPI interrupts - //SPI1->CR2 = SPI_CR2_RXNEIE | SPI_CR2_ERRIE | SPI_CR2_TXEIE; - SPI1->CR2 = SPI_CR2_RXNEIE; - - NVIC_EnableIRQ(DMA2_Stream2_IRQn); - NVIC_EnableIRQ(DMA2_Stream3_IRQn); - //NVIC_EnableIRQ(SPI1_IRQn); - - // reset handshake back to pull up - set_gpio_mode(GPIOB, 0, MODE_INPUT); - set_gpio_pullup(GPIOB, 0, PULL_UP); - - // setup interrupt on falling edge of SPI enable (on PA4) - SYSCFG->EXTICR[2] = SYSCFG_EXTICR2_EXTI4_PA; - EXTI->IMR |= (1U << 4); - EXTI->FTSR |= (1U << 4); - NVIC_EnableIRQ(EXTI4_IRQn); -} - void spi_tx_dma(void *addr, int len) { // disable DMA - SPI1->CR2 &= ~SPI_CR2_TXDMAEN; - DMA2_Stream3->CR &= ~DMA_SxCR_EN; + register_clear_bits(&(SPI1->CR2), SPI_CR2_TXDMAEN); + register_clear_bits(&(DMA2_Stream3->CR), DMA_SxCR_EN); // DMA2, stream 3, channel 3 - DMA2_Stream3->M0AR = (uint32_t)addr; + register_set(&(DMA2_Stream3->M0AR), (uint32_t)addr, 0xFFFFFFFFU); DMA2_Stream3->NDTR = len; - DMA2_Stream3->PAR = (uint32_t)&(SPI1->DR); + register_set(&(DMA2_Stream3->PAR), (uint32_t)&(SPI1->DR), 0xFFFFFFFFU); // channel3, increment memory, memory -> periph, enable - DMA2_Stream3->CR = DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0 | DMA_SxCR_EN; + register_set(&(DMA2_Stream3->CR), (DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0 | DMA_SxCR_EN), 0x1E077EFEU); delay(0); - DMA2_Stream3->CR |= DMA_SxCR_TCIE; + register_set_bits(&(DMA2_Stream3->CR), DMA_SxCR_TCIE); - SPI1->CR2 |= SPI_CR2_TXDMAEN; + register_set_bits(&(SPI1->CR2), SPI_CR2_TXDMAEN); // signal data is ready by driving low // esp must be configured as input by this point @@ -57,33 +34,32 @@ void spi_tx_dma(void *addr, int len) { void spi_rx_dma(void *addr, int len) { // disable DMA - SPI1->CR2 &= ~SPI_CR2_RXDMAEN; - DMA2_Stream2->CR &= ~DMA_SxCR_EN; + register_clear_bits(&(SPI1->CR2), SPI_CR2_RXDMAEN); + register_clear_bits(&(DMA2_Stream2->CR), DMA_SxCR_EN); // drain the bus volatile uint8_t dat = SPI1->DR; (void)dat; // DMA2, stream 2, channel 3 - DMA2_Stream2->M0AR = (uint32_t)addr; + register_set(&(DMA2_Stream2->M0AR), (uint32_t)addr, 0xFFFFFFFFU); DMA2_Stream2->NDTR = len; - DMA2_Stream2->PAR = (uint32_t)&(SPI1->DR); + register_set(&(DMA2_Stream2->PAR), (uint32_t)&(SPI1->DR), 0xFFFFFFFFU); // channel3, increment memory, periph -> memory, enable - DMA2_Stream2->CR = DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_0 | DMA_SxCR_MINC | DMA_SxCR_EN; + register_set(&(DMA2_Stream2->CR), (DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_0 | DMA_SxCR_MINC | DMA_SxCR_EN), 0x1E077EFEU); delay(0); - DMA2_Stream2->CR |= DMA_SxCR_TCIE; + register_set_bits(&(DMA2_Stream2->CR), DMA_SxCR_TCIE); - SPI1->CR2 |= SPI_CR2_RXDMAEN; + register_set_bits(&(SPI1->CR2), SPI_CR2_RXDMAEN); } // ***************************** SPI IRQs ***************************** - // can't go on the stack cause it's DMAed uint8_t spi_tx_buf[0x44]; // SPI RX -void DMA2_Stream2_IRQHandler(void) { +void DMA2_Stream2_IRQ_Handler(void) { int *resp_len = (int*)spi_tx_buf; (void)memset(spi_tx_buf, 0xaa, 0x44); *resp_len = spi_cb_rx(spi_buf, 0x14, spi_tx_buf+4); @@ -99,7 +75,7 @@ void DMA2_Stream2_IRQHandler(void) { } // SPI TX -void DMA2_Stream3_IRQHandler(void) { +void DMA2_Stream3_IRQ_Handler(void) { #ifdef DEBUG_SPI puts("SPI handshake\n"); #endif @@ -112,7 +88,7 @@ void DMA2_Stream3_IRQHandler(void) { DMA2->LIFCR = DMA_LIFCR_CTCIF3; } -void EXTI4_IRQHandler(void) { +void EXTI4_IRQ_Handler(void) { volatile unsigned int pr = EXTI->PR & (1U << 4); #ifdef DEBUG_SPI puts("exti4\n"); @@ -125,3 +101,31 @@ void EXTI4_IRQHandler(void) { EXTI->PR = pr; } +// ***************************** SPI init ***************************** +void spi_init(void) { + // Max SPI clock the ESP can produce is 80MHz. At buffer size of 256 bytes, that's a max of about 40k buffers per second + REGISTER_INTERRUPT(DMA2_Stream2_IRQn, DMA2_Stream2_IRQ_Handler, 50000U, FAULT_INTERRUPT_RATE_SPI_DMA) + REGISTER_INTERRUPT(DMA2_Stream3_IRQn, DMA2_Stream3_IRQ_Handler, 50000U, FAULT_INTERRUPT_RATE_SPI_DMA) + REGISTER_INTERRUPT(EXTI4_IRQn, EXTI4_IRQ_Handler, 50000U, FAULT_INTERRUPT_RATE_SPI_CS) // TODO: Figure out if this is a reasonable limit + + //puts("SPI init\n"); + register_set(&(SPI1->CR1), SPI_CR1_SPE, 0xFFFFU); + + // enable SPI interrupts + //SPI1->CR2 = SPI_CR2_RXNEIE | SPI_CR2_ERRIE | SPI_CR2_TXEIE; + register_set(&(SPI1->CR2), SPI_CR2_RXNEIE, 0xF7U); + + NVIC_EnableIRQ(DMA2_Stream2_IRQn); + NVIC_EnableIRQ(DMA2_Stream3_IRQn); + //NVIC_EnableIRQ(SPI1_IRQn); + + // reset handshake back to pull up + set_gpio_mode(GPIOB, 0, MODE_INPUT); + set_gpio_pullup(GPIOB, 0, PULL_UP); + + // setup interrupt on falling edge of SPI enable (on PA4) + register_set(&(SYSCFG->EXTICR[2]), SYSCFG_EXTICR2_EXTI4_PA, 0xFFFFU); + register_set_bits(&(EXTI->IMR), (1U << 4)); + register_set_bits(&(EXTI->FTSR), (1U << 4)); + NVIC_EnableIRQ(EXTI4_IRQn); +} \ No newline at end of file diff --git a/panda/board/drivers/timer.h b/panda/board/drivers/timer.h index a14b619e4b81e3..d7aa7e8811093a 100644 --- a/panda/board/drivers/timer.h +++ b/panda/board/drivers/timer.h @@ -1,7 +1,7 @@ void timer_init(TIM_TypeDef *TIM, int psc) { - TIM->PSC = psc-1; - TIM->DIER = TIM_DIER_UIE; - TIM->CR1 = TIM_CR1_CEN; + register_set(&(TIM->PSC), (psc-1), 0xFFFFU); + register_set(&(TIM->DIER), TIM_DIER_UIE, 0x5F5FU); + register_set(&(TIM->CR1), TIM_CR1_CEN, 0x3FU); TIM->SR = 0; } diff --git a/panda/board/drivers/uart.h b/panda/board/drivers/uart.h index 5c5452483d0479..e4f23ead011911 100644 --- a/panda/board/drivers/uart.h +++ b/panda/board/drivers/uart.h @@ -1,18 +1,43 @@ // IRQs: USART1, USART2, USART3, UART5 -#define FIFO_SIZE 0x400U +// ***************************** Definitions ***************************** +#define FIFO_SIZE_INT 0x400U +#define FIFO_SIZE_DMA 0x1000U + typedef struct uart_ring { volatile uint16_t w_ptr_tx; volatile uint16_t r_ptr_tx; - uint8_t elems_tx[FIFO_SIZE]; + uint8_t *elems_tx; + uint32_t tx_fifo_size; volatile uint16_t w_ptr_rx; volatile uint16_t r_ptr_rx; - uint8_t elems_rx[FIFO_SIZE]; + uint8_t *elems_rx; + uint32_t rx_fifo_size; USART_TypeDef *uart; void (*callback)(struct uart_ring*); + bool dma_rx; } uart_ring; -void uart_init(USART_TypeDef *u, int baud); +#define UART_BUFFER(x, size_rx, size_tx, uart_ptr, callback_ptr, rx_dma) \ + uint8_t elems_rx_##x[size_rx]; \ + uint8_t elems_tx_##x[size_tx]; \ + uart_ring uart_ring_##x = { \ + .w_ptr_tx = 0, \ + .r_ptr_tx = 0, \ + .elems_tx = ((uint8_t *)&elems_tx_##x), \ + .tx_fifo_size = size_tx, \ + .w_ptr_rx = 0, \ + .r_ptr_rx = 0, \ + .elems_rx = ((uint8_t *)&elems_rx_##x), \ + .rx_fifo_size = size_rx, \ + .uart = uart_ptr, \ + .callback = callback_ptr, \ + .dma_rx = rx_dma \ + }; + + +// ***************************** Function prototypes ***************************** +void uart_init(uart_ring *q, int baud); bool getc(uart_ring *q, char *elem); bool putc(uart_ring *q, char elem); @@ -21,48 +46,35 @@ void puts(const char *a); void puth(unsigned int i); void hexdump(const void *a, int l); +void debug_ring_callback(uart_ring *ring); -// ***************************** serial port queues ***************************** +// ******************************** UART buffers ******************************** -// esp = USART1 -uart_ring esp_ring = { .w_ptr_tx = 0, .r_ptr_tx = 0, - .w_ptr_rx = 0, .r_ptr_rx = 0, - .uart = USART1, - .callback = NULL}; +// gps = USART1 +UART_BUFFER(gps, FIFO_SIZE_DMA, FIFO_SIZE_INT, USART1, NULL, true) // lin1, K-LINE = UART5 // lin2, L-LINE = USART3 -uart_ring lin1_ring = { .w_ptr_tx = 0, .r_ptr_tx = 0, - .w_ptr_rx = 0, .r_ptr_rx = 0, - .uart = UART5, - .callback = NULL}; -uart_ring lin2_ring = { .w_ptr_tx = 0, .r_ptr_tx = 0, - .w_ptr_rx = 0, .r_ptr_rx = 0, - .uart = USART3, - .callback = NULL}; +UART_BUFFER(lin1, FIFO_SIZE_INT, FIFO_SIZE_INT, UART5, NULL, false) +UART_BUFFER(lin2, FIFO_SIZE_INT, FIFO_SIZE_INT, USART3, NULL, false) // debug = USART2 -void debug_ring_callback(uart_ring *ring); -uart_ring debug_ring = { .w_ptr_tx = 0, .r_ptr_tx = 0, - .w_ptr_rx = 0, .r_ptr_rx = 0, - .uart = USART2, - .callback = debug_ring_callback}; - +UART_BUFFER(debug, FIFO_SIZE_INT, FIFO_SIZE_INT, USART2, debug_ring_callback, false) uart_ring *get_ring_by_number(int a) { uart_ring *ring = NULL; switch(a) { case 0: - ring = &debug_ring; + ring = &uart_ring_debug; break; case 1: - ring = &esp_ring; + ring = &uart_ring_gps; break; case 2: - ring = &lin1_ring; + ring = &uart_ring_lin1; break; case 3: - ring = &lin2_ring; + ring = &uart_ring_lin2; break; default: ring = NULL; @@ -71,63 +83,249 @@ uart_ring *get_ring_by_number(int a) { return ring; } -// ***************************** serial port ***************************** - -void uart_ring_process(uart_ring *q) { - enter_critical_section(); - // TODO: check if external serial is connected - int sr = q->uart->SR; +// ***************************** Interrupt handlers ***************************** +void uart_tx_ring(uart_ring *q){ + ENTER_CRITICAL(); + // Send out next byte of TX buffer if (q->w_ptr_tx != q->r_ptr_tx) { - if ((sr & USART_SR_TXE) != 0) { - q->uart->DR = q->elems_tx[q->r_ptr_tx]; - q->r_ptr_tx = (q->r_ptr_tx + 1U) % FIFO_SIZE; + // Only send if transmit register is empty (aka last byte has been sent) + if ((q->uart->SR & USART_SR_TXE) != 0) { + q->uart->DR = q->elems_tx[q->r_ptr_tx]; // This clears TXE + q->r_ptr_tx = (q->r_ptr_tx + 1U) % q->tx_fifo_size; + } + + // Enable TXE interrupt if there is still data to be sent + if(q->r_ptr_tx != q->w_ptr_tx){ + q->uart->CR1 |= USART_CR1_TXEIE; + } else { + q->uart->CR1 &= ~USART_CR1_TXEIE; } - // there could be more to send - q->uart->CR1 |= USART_CR1_TXEIE; - } else { - // nothing to send - q->uart->CR1 &= ~USART_CR1_TXEIE; } + EXIT_CRITICAL(); +} - if ((sr & USART_SR_RXNE) || (sr & USART_SR_ORE)) { - uint8_t c = q->uart->DR; // TODO: can drop packets - if (q != &esp_ring) { - uint16_t next_w_ptr = (q->w_ptr_rx + 1U) % FIFO_SIZE; - if (next_w_ptr != q->r_ptr_rx) { - q->elems_rx[q->w_ptr_rx] = c; - q->w_ptr_rx = next_w_ptr; - if (q->callback != NULL) { - q->callback(q); - } +void uart_rx_ring(uart_ring *q){ + // Do not read out directly if DMA enabled + if (q->dma_rx == false) { + ENTER_CRITICAL(); + + // Read out RX buffer + uint8_t c = q->uart->DR; // This read after reading SR clears a bunch of interrupts + + uint16_t next_w_ptr = (q->w_ptr_rx + 1U) % q->rx_fifo_size; + // Do not overwrite buffer data + if (next_w_ptr != q->r_ptr_rx) { + q->elems_rx[q->w_ptr_rx] = c; + q->w_ptr_rx = next_w_ptr; + if (q->callback != NULL) { + q->callback(q); } } + + EXIT_CRITICAL(); } +} + +// This function should be called on: +// * Half-transfer DMA interrupt +// * Full-transfer DMA interrupt +// * UART IDLE detection +uint32_t prev_w_index = 0; +void dma_pointer_handler(uart_ring *q, uint32_t dma_ndtr) { + ENTER_CRITICAL(); + uint32_t w_index = (q->rx_fifo_size - dma_ndtr); + + // Check for new data + if (w_index != prev_w_index){ + // Check for overflow + if ( + ((prev_w_index < q->r_ptr_rx) && (q->r_ptr_rx <= w_index)) || // No rollover + ((w_index < prev_w_index) && ((q->r_ptr_rx <= w_index) || (prev_w_index < q->r_ptr_rx))) // Rollover + ){ + // We lost data. Set the new read pointer to the oldest byte still available + q->r_ptr_rx = (w_index + 1U) % q->rx_fifo_size; + } - if ((sr & USART_SR_ORE) != 0) { - // set dropped packet flag? + // Set write pointer + q->w_ptr_rx = w_index; } - exit_critical_section(); + prev_w_index = w_index; + EXIT_CRITICAL(); } -// interrupt boilerplate +// This read after reading SR clears all error interrupts. We don't want compiler warnings, nor optimizations +#define UART_READ_DR(uart) volatile uint8_t t = (uart)->DR; UNUSED(t); + +void uart_interrupt_handler(uart_ring *q) { + ENTER_CRITICAL(); -void USART1_IRQHandler(void) { uart_ring_process(&esp_ring); } -void USART2_IRQHandler(void) { uart_ring_process(&debug_ring); } -void USART3_IRQHandler(void) { uart_ring_process(&lin2_ring); } -void UART5_IRQHandler(void) { uart_ring_process(&lin1_ring); } + // Read UART status. This is also the first step necessary in clearing most interrupts + uint32_t status = q->uart->SR; + + // If RXNE is set, perform a read. This clears RXNE, ORE, IDLE, NF and FE + if((status & USART_SR_RXNE) != 0U){ + uart_rx_ring(q); + } + + // Detect errors and clear them + uint32_t err = (status & USART_SR_ORE) | (status & USART_SR_NE) | (status & USART_SR_FE) | (status & USART_SR_PE); + if(err != 0U){ + #ifdef DEBUG_UART + puts("Encountered UART error: "); puth(err); puts("\n"); + #endif + UART_READ_DR(q->uart) + } + // Send if necessary + uart_tx_ring(q); + + // Run DMA pointer handler if the line is idle + if(q->dma_rx && (status & USART_SR_IDLE)){ + // Reset IDLE flag + UART_READ_DR(q->uart) + + if(q == &uart_ring_gps){ + dma_pointer_handler(&uart_ring_gps, DMA2_Stream5->NDTR); + } else { + #ifdef DEBUG_UART + puts("No IDLE dma_pointer_handler implemented for this UART."); + #endif + } + } + + EXIT_CRITICAL(); +} + +void USART1_IRQ_Handler(void) { uart_interrupt_handler(&uart_ring_gps); } +void USART2_IRQ_Handler(void) { uart_interrupt_handler(&uart_ring_debug); } +void USART3_IRQ_Handler(void) { uart_interrupt_handler(&uart_ring_lin2); } +void UART5_IRQ_Handler(void) { uart_interrupt_handler(&uart_ring_lin1); } + +void DMA2_Stream5_IRQ_Handler(void) { + ENTER_CRITICAL(); + + // Handle errors + if((DMA2->HISR & DMA_HISR_TEIF5) || (DMA2->HISR & DMA_HISR_DMEIF5) || (DMA2->HISR & DMA_HISR_FEIF5)){ + #ifdef DEBUG_UART + puts("Encountered UART DMA error. Clearing and restarting DMA...\n"); + #endif + + // Clear flags + DMA2->HIFCR = DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5; + + // Re-enable the DMA if necessary + DMA2_Stream5->CR |= DMA_SxCR_EN; + } + + // Re-calculate write pointer and reset flags + dma_pointer_handler(&uart_ring_gps, DMA2_Stream5->NDTR); + DMA2->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5; + + EXIT_CRITICAL(); +} + +// ***************************** Hardware setup ***************************** + +void dma_rx_init(uart_ring *q) { + // Initialization is UART-dependent + if(q == &uart_ring_gps){ + // DMA2, stream 5, channel 4 + + // Disable FIFO mode (enable direct) + DMA2_Stream5->FCR &= ~DMA_SxFCR_DMDIS; + + // Setup addresses + DMA2_Stream5->PAR = (uint32_t)&(USART1->DR); // Source + DMA2_Stream5->M0AR = (uint32_t)q->elems_rx; // Destination + DMA2_Stream5->NDTR = q->rx_fifo_size; // Number of bytes to copy + + // Circular, Increment memory, byte size, periph -> memory, enable + // Transfer complete, half transfer, transfer error and direct mode error interrupt enable + DMA2_Stream5->CR = DMA_SxCR_CHSEL_2 | DMA_SxCR_MINC | DMA_SxCR_CIRC | DMA_SxCR_HTIE | DMA_SxCR_TCIE | DMA_SxCR_TEIE | DMA_SxCR_DMEIE | DMA_SxCR_EN; + + // Enable DMA receiver in UART + q->uart->CR3 |= USART_CR3_DMAR; + + // Enable UART IDLE interrupt + q->uart->CR1 |= USART_CR1_IDLEIE; + + // Enable interrupt + NVIC_EnableIRQ(DMA2_Stream5_IRQn); + } else { + puts("Tried to initialize RX DMA for an unsupported UART\n"); + } +} + +#define __DIV(_PCLK_, _BAUD_) (((_PCLK_) * 25U) / (4U * (_BAUD_))) +#define __DIVMANT(_PCLK_, _BAUD_) (__DIV((_PCLK_), (_BAUD_)) / 100U) +#define __DIVFRAQ(_PCLK_, _BAUD_) ((((__DIV((_PCLK_), (_BAUD_)) - (__DIVMANT((_PCLK_), (_BAUD_)) * 100U)) * 16U) + 50U) / 100U) +#define __USART_BRR(_PCLK_, _BAUD_) ((__DIVMANT((_PCLK_), (_BAUD_)) << 4) | (__DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0FU)) + +void uart_set_baud(USART_TypeDef *u, unsigned int baud) { + if (u == USART1) { + // USART1 is on APB2 + u->BRR = __USART_BRR(48000000U, baud); + } else { + u->BRR = __USART_BRR(24000000U, baud); + } +} + +void uart_init(uart_ring *q, int baud) { + // Register interrupts (max data rate: 115200 baud) + if(q->uart == USART1){ + REGISTER_INTERRUPT(USART1_IRQn, USART1_IRQ_Handler, 150000U, FAULT_INTERRUPT_RATE_UART_1) + } else if (q->uart == USART2){ + REGISTER_INTERRUPT(USART2_IRQn, USART2_IRQ_Handler, 150000U, FAULT_INTERRUPT_RATE_UART_2) + } else if (q->uart == USART3){ + REGISTER_INTERRUPT(USART3_IRQn, USART3_IRQ_Handler, 150000U, FAULT_INTERRUPT_RATE_UART_3) + } else if (q->uart == UART5){ + REGISTER_INTERRUPT(UART5_IRQn, UART5_IRQ_Handler, 150000U, FAULT_INTERRUPT_RATE_UART_5) + } else { + // UART not used. Skip registering interrupts + } + if(q->dma_rx){ + REGISTER_INTERRUPT(DMA2_Stream5_IRQn, DMA2_Stream5_IRQ_Handler, 100U, FAULT_INTERRUPT_RATE_UART_DMA) // Called twice per buffer + } + + // Set baud and enable peripheral with TX and RX mode + uart_set_baud(q->uart, baud); + q->uart->CR1 = USART_CR1_UE | USART_CR1_TE | USART_CR1_RE; + if ((q->uart == USART2) || (q->uart == USART3) || (q->uart == UART5)) { + q->uart->CR1 |= USART_CR1_RXNEIE; + } + + // Enable UART interrupts + if(q->uart == USART1){ + NVIC_EnableIRQ(USART1_IRQn); + } else if (q->uart == USART2){ + NVIC_EnableIRQ(USART2_IRQn); + } else if (q->uart == USART3){ + NVIC_EnableIRQ(USART3_IRQn); + } else if (q->uart == UART5){ + NVIC_EnableIRQ(UART5_IRQn); + } else { + // UART not used. Skip enabling interrupts + } + + // Initialise RX DMA if used + if(q->dma_rx){ + dma_rx_init(q); + } +} + +// ************************* Low-level buffer functions ************************* bool getc(uart_ring *q, char *elem) { bool ret = false; - enter_critical_section(); + ENTER_CRITICAL(); if (q->w_ptr_rx != q->r_ptr_rx) { if (elem != NULL) *elem = q->elems_rx[q->r_ptr_rx]; - q->r_ptr_rx = (q->r_ptr_rx + 1U) % FIFO_SIZE; + q->r_ptr_rx = (q->r_ptr_rx + 1U) % q->rx_fifo_size; ret = true; } - exit_critical_section(); + EXIT_CRITICAL(); return ret; } @@ -136,14 +334,14 @@ bool injectc(uart_ring *q, char elem) { int ret = false; uint16_t next_w_ptr; - enter_critical_section(); - next_w_ptr = (q->w_ptr_rx + 1U) % FIFO_SIZE; + ENTER_CRITICAL(); + next_w_ptr = (q->w_ptr_rx + 1U) % q->tx_fifo_size; if (next_w_ptr != q->r_ptr_rx) { q->elems_rx[q->w_ptr_rx] = elem; q->w_ptr_rx = next_w_ptr; ret = true; } - exit_critical_section(); + EXIT_CRITICAL(); return ret; } @@ -152,20 +350,22 @@ bool putc(uart_ring *q, char elem) { bool ret = false; uint16_t next_w_ptr; - enter_critical_section(); - next_w_ptr = (q->w_ptr_tx + 1U) % FIFO_SIZE; + ENTER_CRITICAL(); + next_w_ptr = (q->w_ptr_tx + 1U) % q->tx_fifo_size; if (next_w_ptr != q->r_ptr_tx) { q->elems_tx[q->w_ptr_tx] = elem; q->w_ptr_tx = next_w_ptr; ret = true; } - exit_critical_section(); + EXIT_CRITICAL(); - uart_ring_process(q); + uart_tx_ring(q); return ret; } +// Seems dangerous to use (might lock CPU if called with interrupts disabled f.e.) +// TODO: Remove? Not used anyways void uart_flush(uart_ring *q) { while (q->w_ptr_tx != q->r_ptr_tx) { __WFI(); @@ -175,7 +375,7 @@ void uart_flush(uart_ring *q) { void uart_flush_sync(uart_ring *q) { // empty the TX buffer while (q->w_ptr_tx != q->r_ptr_tx) { - uart_ring_process(q); + uart_tx_ring(q); } } @@ -185,127 +385,23 @@ void uart_send_break(uart_ring *u) { } void clear_uart_buff(uart_ring *q) { - enter_critical_section(); + ENTER_CRITICAL(); q->w_ptr_tx = 0; q->r_ptr_tx = 0; q->w_ptr_rx = 0; q->r_ptr_rx = 0; - exit_critical_section(); -} - -// ***************************** start UART code ***************************** - -#define __DIV(_PCLK_, _BAUD_) (((_PCLK_) * 25U) / (4U * (_BAUD_))) -#define __DIVMANT(_PCLK_, _BAUD_) (__DIV((_PCLK_), (_BAUD_)) / 100U) -#define __DIVFRAQ(_PCLK_, _BAUD_) ((((__DIV((_PCLK_), (_BAUD_)) - (__DIVMANT((_PCLK_), (_BAUD_)) * 100U)) * 16U) + 50U) / 100U) -#define __USART_BRR(_PCLK_, _BAUD_) ((__DIVMANT((_PCLK_), (_BAUD_)) << 4) | (__DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0FU)) - -void uart_set_baud(USART_TypeDef *u, unsigned int baud) { - if (u == USART1) { - // USART1 is on APB2 - u->BRR = __USART_BRR(48000000U, baud); - } else { - u->BRR = __USART_BRR(24000000U, baud); - } -} - -#define USART1_DMA_LEN 0x20 -char usart1_dma[USART1_DMA_LEN]; - -void uart_dma_drain(void) { - uart_ring *q = &esp_ring; - - enter_critical_section(); - - if ((DMA2->HISR & DMA_HISR_TCIF5) || (DMA2->HISR & DMA_HISR_HTIF5) || (DMA2_Stream5->NDTR != USART1_DMA_LEN)) { - // disable DMA - q->uart->CR3 &= ~USART_CR3_DMAR; - DMA2_Stream5->CR &= ~DMA_SxCR_EN; - while ((DMA2_Stream5->CR & DMA_SxCR_EN) != 0); - - unsigned int i; - for (i = 0; i < (USART1_DMA_LEN - DMA2_Stream5->NDTR); i++) { - char c = usart1_dma[i]; - uint16_t next_w_ptr = (q->w_ptr_rx + 1U) % FIFO_SIZE; - if (next_w_ptr != q->r_ptr_rx) { - q->elems_rx[q->w_ptr_rx] = c; - q->w_ptr_rx = next_w_ptr; - } - } - - // reset DMA len - DMA2_Stream5->NDTR = USART1_DMA_LEN; - - // clear interrupts - DMA2->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5; - //DMA2->HIFCR = DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5; - - // enable DMA - DMA2_Stream5->CR |= DMA_SxCR_EN; - q->uart->CR3 |= USART_CR3_DMAR; - } - - exit_critical_section(); -} - -void DMA2_Stream5_IRQHandler(void) { - //set_led(LED_BLUE, 1); - uart_dma_drain(); - //set_led(LED_BLUE, 0); -} - -void uart_init(USART_TypeDef *u, int baud) { - // enable uart and tx+rx mode - u->CR1 = USART_CR1_UE; - uart_set_baud(u, baud); - - u->CR1 |= USART_CR1_TE | USART_CR1_RE; - //u->CR2 = USART_CR2_STOP_0 | USART_CR2_STOP_1; - //u->CR2 = USART_CR2_STOP_0; - // ** UART is ready to work ** - - // enable interrupts - if (u != USART1) { - u->CR1 |= USART_CR1_RXNEIE; - } - - if (u == USART1) { - // DMA2, stream 2, channel 3 - DMA2_Stream5->M0AR = (uint32_t)usart1_dma; - DMA2_Stream5->NDTR = USART1_DMA_LEN; - DMA2_Stream5->PAR = (uint32_t)&(USART1->DR); - - // channel4, increment memory, periph -> memory, enable - DMA2_Stream5->CR = DMA_SxCR_CHSEL_2 | DMA_SxCR_MINC | DMA_SxCR_HTIE | DMA_SxCR_TCIE | DMA_SxCR_EN; - - // this one uses DMA receiver - u->CR3 = USART_CR3_DMAR; - - NVIC_EnableIRQ(DMA2_Stream5_IRQn); - NVIC_EnableIRQ(USART1_IRQn); - } else if (u == USART2) { - NVIC_EnableIRQ(USART2_IRQn); - } else if (u == USART3) { - NVIC_EnableIRQ(USART3_IRQn); - } else if (u == UART5) { - NVIC_EnableIRQ(UART5_IRQn); - } else { - // USART type undefined, skip - } + EXIT_CRITICAL(); } +// ************************ High-level debug functions ********************** void putch(const char a) { if (has_external_debug_serial) { - /*while ((debug_ring.uart->SR & USART_SR_TXE) == 0); - debug_ring.uart->DR = a;*/ - // assuming debugging is important if there's external serial connected - while (!putc(&debug_ring, a)); + while (!putc(&uart_ring_debug, a)); - //putc(&debug_ring, a); } else { // misra-c2012-17.7: serial debug function, ok to ignore output - (void)injectc(&debug_ring, a); + (void)injectc(&uart_ring_debug, a); } } @@ -327,7 +423,7 @@ void putui(uint32_t i) { idx--; i_copy /= 10; } while (i_copy != 0U); - puts(str + idx + 1U); + puts(&str[idx + 1U]); } void puth(unsigned int i) { @@ -345,10 +441,12 @@ void puth2(unsigned int i) { } void hexdump(const void *a, int l) { - for (int i=0; i < l; i++) { - if ((i != 0) && ((i & 0xf) == 0)) puts("\n"); - puth2(((const unsigned char*)a)[i]); - puts(" "); + if (a != NULL) { + for (int i=0; i < l; i++) { + if ((i != 0) && ((i & 0xf) == 0)) puts("\n"); + puth2(((const unsigned char*)a)[i]); + puts(" "); + } } puts("\n"); } diff --git a/panda/board/drivers/uja1023.h b/panda/board/drivers/uja1023.h deleted file mode 100644 index fcf8c120f5c533..00000000000000 --- a/panda/board/drivers/uja1023.h +++ /dev/null @@ -1,224 +0,0 @@ -/* -This driver configures the NXP UJA1023 chip on revB tesla giraffe -for output on startup and then allows the user to set the output -pins via set_uja1023_output_bits() and set_uja1023_output_buffer() - -Set UJA1023 output pins. Bits = pins -P0 = bit 0 -P1 = bit 1 -... -P7 = bit 7 -0b10101010 = P0 off, P1 on, P2 off, P3 on, P4 off, P5 on, P6 off, P7 on - -Examples: -set bit 5: -set_uja1023_output_bits(1 << 5); //turn on any pins that = 1, leave all other pins alone - -clear bit 5: -clear_uja1023_output_bits(1 << 5); //turn off any pins that = 1, leave all other pins alone - -Or set the whole buffer at once: -set_uja1023_output_buffer(0xFF); //turn all output pins on -set_uja1023_output_buffer(0x00); //turn all output pins off -*/ - -#define TICKS_PER_FRAME 2000 //1s = 33000 - -#ifdef PANDA -int lin_send_timer = TICKS_PER_FRAME; - -LIN_FRAME_t assign_id_frame, io_cfg_1_frame, io_cfg_2_frame, io_cfg_3_frame, io_cfg_4_frame, px_req_frame, frame_to_send, frame_to_receive; - - -int initial_loop_num = 0; - - -void UJA_TIM5_IRQHandler(void) { - if (TIM5->SR & TIM_SR_UIF) { - if (lin_send_timer == 0) { - //send every 1s - lin_send_timer = TICKS_PER_FRAME; - if (initial_loop_num <= 3) { - switch(initial_loop_num) { - case 0 : - frame_to_send = assign_id_frame; - puts("UJA1023 init stage 0\n"); - break; - case 1 : - frame_to_send = io_cfg_1_frame; - puts("UJA1023 init stage 1\n"); - break; - case 2 : - frame_to_send = io_cfg_2_frame; - puts("UJA1023 init stage 2\n"); - break; - case 3 : - frame_to_send = io_cfg_3_frame; - puts("UJA1023 init stage 3\n"); - break; - } - initial_loop_num++; - } - else { - - /* - if (px_req_frame.data[0] == 0x02) { - px_req_frame.data[0] = 0x00; - } - else { - px_req_frame.data[0] = 0x02; - } - */ - frame_to_send = px_req_frame; - } - LIN_SendData(&lin2_ring, &frame_to_send); - /* - puts("Set UJA to output: "); - puth(px_req_frame.data[0]); - puts("\n"); - */ - - - } //if counter = 0 - - if (lin_send_timer == (TICKS_PER_FRAME / 10) && frame_to_send.has_response) { - //send empty header to slave - LIN_SendReceiveFrame(&lin2_ring, &frame_to_receive); - } - - if (lin_send_timer == ((TICKS_PER_FRAME / 10) * 2) && frame_to_send.has_response) { - LIN_ReceiveData(&lin2_ring, &frame_to_receive); - puts("Received Lin frame: "); - - /* - for(int n=0; n < frame_to_receive.data_len; n++) { - puth(frame_to_receive.data[n]); - } - */ - puts("\n"); - } - - lin_send_timer--; - } //interrupt - TIM5->SR = 0; -} - -void uja1023_init(void) { - //make receive frame - //LIN_FRAME_t frame_to_receive; - frame_to_receive.data_len = 8; - frame_to_receive.frame_id = 0x7D; //Response PID, 0x7D = 2 bit parity + 0x3C raw ID - - //make frame for Assign frame ID - //LIN_FRAME_t assign_id_frame; - assign_id_frame.has_response = 1; - assign_id_frame.data_len = 8; - assign_id_frame.frame_id = 0x3C; //0x3C is for diagnostic frames - assign_id_frame.data[0] = 0x60; //D0, iniital node address, set to 0x60 default - assign_id_frame.data[1] = 0x06; //D1, protocol control info (PCI); should be 0x06 - assign_id_frame.data[2] = 0xB1; //D2, service id (SID); should be 0xB4 - assign_id_frame.data[3] = 0x11; //D3, supplier ID low byte; should be 0x11 - assign_id_frame.data[4] = 0x00; //D4, supplier ID high byte; should be 0x00 - assign_id_frame.data[5] = 0x00; //D5, function id low byte; should be 0x00 - assign_id_frame.data[6] = 0x00; //D6, function id high byte; should be 0x00 - assign_id_frame.data[7] = 0x04; //D7, slave node address (NAD). 0x04 means ID(PxReq) = 04, ID(PxResp) = 05 - - //make frame for io_cfg_1; configure Px pins for push pull level output - //LIN_FRAME_t io_cfg_1_frame; - io_cfg_1_frame.has_response = 1; - io_cfg_1_frame.data_len = 8; - io_cfg_1_frame.frame_id = 0x3C; //0x3C is for diagnostic frames - io_cfg_1_frame.data[0] = 0x60; //D0, slave node address (NAD) (default 0x60) - io_cfg_1_frame.data[1] = 0x06; //D1, protocol control info (PCI); should be 0x06 - io_cfg_1_frame.data[2] = 0xB4; //D2, service id (SID); should be 0xB4 - io_cfg_1_frame.data[3] = 0x00; //D3, bits 7-6 are 00 for first cfg block. Bits 5-0 are for IM/INH, RxDL, ADCIN cfg. D3 default is 0x00 - io_cfg_1_frame.data[4] = 0xFF; //D4, High side enable (HSE). Set to 0xFF for High side driver or push pull - io_cfg_1_frame.data[5] = 0x00; //D4, Low side enable (LSE). Set to 0xFF for Low side driver or push pull - io_cfg_1_frame.data[6] = 0x00; //D6, Output mode (low byte) (OM0). Set to 0x00 for level output - io_cfg_1_frame.data[7] = 0x00; //D7, Output mode (high byte) (OM1). Set to 0x00 for level output - - //make frame for io_cfg_2; defaults - //LIN_FRAME_t io_cfg_2_frame; - io_cfg_2_frame.has_response = 1; - io_cfg_2_frame.data_len = 8; - io_cfg_2_frame.frame_id = 0x3C; //0x3C is for diagnostic frames - io_cfg_2_frame.data[0] = 0x60; //D0, slave node address (NAD) (default 0x60) - io_cfg_2_frame.data[1] = 0x06; //D1, protocol control info (PCI); should be 0x06 - io_cfg_2_frame.data[2] = 0xB4; //D2, service id (SID); should be 0xB4 - io_cfg_2_frame.data[3] = 0x40; //D3, bits 7-6 are 01 for second cfg block. Bits 5-0 are for LSLP, TxDL, SMC, SMW, SM. D3 default is 0x40 (every bit 0 except for 7-6) - io_cfg_2_frame.data[4] = 0x00; //D4, Capture Mode (low byte) CM0. Set to 0x00 for no capture - io_cfg_2_frame.data[5] = 0x00; //D5, Capture Mode (high byte) CM1. Set to 0x00 for no capture - io_cfg_2_frame.data[6] = 0x00; //D6, Threshold select TH2 TH1. Default 0x00 - io_cfg_2_frame.data[7] = 0x00; //D7, Local Wake up pin mask LWM. Default 0x00 - - //make frame for io_cfg_3; set LH value, classic checksum, and LIN speeds up to 20kbps - //LIN_FRAME_t io_cfg_3_frame; - io_cfg_3_frame.has_response = 1; - io_cfg_3_frame.data_len = 8; - io_cfg_3_frame.frame_id = 0x3C; //0x3C is for diagnostic frames - io_cfg_3_frame.data[0] = 0x60; //D0, slave node address (NAD) (default 0x60) - io_cfg_3_frame.data[1] = 0x04; //D1, protocol control info (PCI); should be 0x04 - io_cfg_3_frame.data[2] = 0xB4; //D2, service id (SID); should be 0xB4 - io_cfg_3_frame.data[3] = 0x80; //D3, bits 7-6 are 10 for third cfg block. Bits 5-0 are for LSC and ECC (classic vs enhanced checksum). D3 default is 0x80 (every bit 0 except for 7-6) - io_cfg_3_frame.data[4] = 0x00; //D4, Limp home mode output value. This is the value the output pins will go to if the bus times out or another error occurs - io_cfg_3_frame.data[5] = 0x10; //D5, PWM initial value; shouldn't matter but is 0x10 per datasheet example - io_cfg_3_frame.data[6] = 0xFF; //D6, Not used, set to 0xFF - io_cfg_3_frame.data[7] = 0xFF; //D7, Not used, set to 0xFF - - - //make frame for io_cfg_4; diagnostic data frame - //LIN_FRAME_t io_cfg_4_frame; - io_cfg_4_frame.has_response = 1; - io_cfg_4_frame.data_len = 8; - io_cfg_4_frame.frame_id = 0x3C; //0x3C is for diagnostic frames - io_cfg_4_frame.data[0] = 0x60; //D0, slave node address (NAD) (default 0x60) - io_cfg_4_frame.data[1] = 0x02; //D1, protocol control info (PCI); should be 0x02 - io_cfg_4_frame.data[2] = 0xB4; //D2, service id (SID); should be 0xB4 - io_cfg_4_frame.data[3] = 0xC0; //D3, bits 7-6 are 11 for fourth cfg block. Bits 5-0 are unused and should be set to 0; should be 0xC0 - io_cfg_4_frame.data[4] = 0xFF; //D4, Not used, set to 0xFF - io_cfg_4_frame.data[5] = 0xFF; //D5, Not used, set to 0xFF - io_cfg_4_frame.data[6] = 0xFF; //D6, Not used, set to 0xFF - io_cfg_4_frame.data[7] = 0xFF; //D7, Not used, set to 0xFF - - - //make frame for PxReq frame (this is what sets the UJA1023's output pins) - //LIN_FRAME_t px_req_frame; - px_req_frame.has_response = 0; - px_req_frame.data_len = 2; - px_req_frame.frame_id = 0xC4; //PID, 0xC4 = 2 bit parity + 0x04 raw ID - px_req_frame.data[0] = 0x00; //D0, bit 7 = P7, bit 6 = P6 ... bit 0 = P0. 0x02 would set P1 to on - px_req_frame.data[1] = 0x80; //D1, PWM Value; shouldn't matter but is 0x80 per datasheet example - - // setup - TIM5->PSC = 48-1; // tick on 1 us - TIM5->CR1 = TIM_CR1_CEN; // enable - TIM5->ARR = 30-1; // 33.3 kbps - - // in case it's disabled - NVIC_EnableIRQ(TIM5_IRQn); - - // run the interrupt - TIM5->DIER = TIM_DIER_UIE; // update interrupt - TIM5->SR = 0; - - initial_loop_num = 0; - -} - -//turn on any pins that = 1, leave all other pins alone -void set_uja1023_output_bits(uint8_t to_set) { - px_req_frame.data[0] |= to_set; -} - -//turn off any pins that = 1, leave all other pins alone -void clear_uja1023_output_bits(uint8_t to_clear) { - px_req_frame.data[0] &= ~to_clear; -} - -//Set the whole Px output buffer at once: -void set_uja1023_output_buffer(uint8_t to_set) { - px_req_frame.data[0] = to_set; -} - -#endif - diff --git a/panda/board/drivers/usb.h b/panda/board/drivers/usb.h index e55906d89eb8a2..e85af95af587c3 100644 --- a/panda/board/drivers/usb.h +++ b/panda/board/drivers/usb.h @@ -23,12 +23,18 @@ typedef union _USB_Setup { } USB_Setup_TypeDef; +#define MAX_CAN_MSGS_PER_BULK_TRANSFER 4U + +bool usb_eopf_detected = false; + void usb_init(void); int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired); int usb_cb_ep1_in(void *usbdata, int len, bool hardwired); void usb_cb_ep2_out(void *usbdata, int len, bool hardwired); void usb_cb_ep3_out(void *usbdata, int len, bool hardwired); +void usb_cb_ep3_out_complete(void); void usb_cb_enumeration_complete(void); +void usb_outep3_resume_if_paused(void); // **** supporting defines **** @@ -281,15 +287,8 @@ uint8_t binary_object_store_desc[] = { // BOS header BINARY_OBJECT_STORE_DESCRIPTOR_LENGTH, // bLength, this is only the length of the header BINARY_OBJECT_STORE_DESCRIPTOR, // bDescriptorType - 0x40, 0x00, // wTotalLength (LSB, MSB) - 0x03, // bNumDeviceCaps (USB 2.0 + WebUSB + WinUSB) - - // ------------------------------------------------- - // USB 2.0 extension descriptor - 0x07, // bLength, Descriptor size - 0x10, // bDescriptorType, Device Capability Descriptor Type - 0x02, // bDevCapabilityType, USB 2.0 extension capability type - 0x00, 0x00, 0x00, 0x00, // bmAttributes, LIBUSB_BM_LPM_SUPPORT = 2 and its the only option + 0x39, 0x00, // wTotalLength (LSB, MSB) + 0x02, // bNumDeviceCaps (WebUSB + WinUSB) // ------------------------------------------------- // WebUSB descriptor @@ -387,6 +386,7 @@ USB_Setup_TypeDef setup; uint8_t usbdata[0x100]; uint8_t* ep0_txdata = NULL; uint16_t ep0_txlen = 0; +bool outep3_processing = false; // Store the current interface alt setting. int current_int0_alt_setting = 0; @@ -439,7 +439,7 @@ void USB_WritePacket_EP0(uint8_t *src, uint16_t len) { USB_WritePacket(src, wplen, 0); if (wplen < len) { - ep0_txdata = src + wplen; + ep0_txdata = &src[wplen]; ep0_txlen = len - wplen; USBx_DEVICE->DIEPEMPMSK |= 1; } else { @@ -662,81 +662,15 @@ void usb_setup(void) { break; default: resp_len = usb_cb_control_msg(&setup, resp, 1); - USB_WritePacket(resp, MIN(resp_len, setup.b.wLength.w), 0); - USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; + // response pending if -1 was returned + if (resp_len != -1) { + USB_WritePacket(resp, MIN(resp_len, setup.b.wLength.w), 0); + USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; + } } } -void usb_init(void) { - // full speed PHY, do reset and remove power down - /*puth(USBx->GRSTCTL); - puts(" resetting PHY\n");*/ - while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_AHBIDL) == 0); - //puts("AHB idle\n"); - - // reset PHY here - USBx->GRSTCTL |= USB_OTG_GRSTCTL_CSRST; - while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_CSRST) == USB_OTG_GRSTCTL_CSRST); - //puts("reset done\n"); - - // internal PHY, force device mode - USBx->GUSBCFG = USB_OTG_GUSBCFG_PHYSEL | USB_OTG_GUSBCFG_FDMOD; - - // slowest timings - USBx->GUSBCFG |= ((USBD_FS_TRDT_VALUE << 10) & USB_OTG_GUSBCFG_TRDT); - - // power up the PHY -#ifdef STM32F4 - USBx->GCCFG = USB_OTG_GCCFG_PWRDWN; - - //USBx->GCCFG |= USB_OTG_GCCFG_VBDEN | USB_OTG_GCCFG_SDEN |USB_OTG_GCCFG_PDEN | USB_OTG_GCCFG_DCDEN; - - /* B-peripheral session valid override enable*/ - USBx->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL; - USBx->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN; -#else - USBx->GCCFG = USB_OTG_GCCFG_PWRDWN | USB_OTG_GCCFG_NOVBUSSENS; -#endif - - // be a device, slowest timings - //USBx->GUSBCFG = USB_OTG_GUSBCFG_FDMOD | USB_OTG_GUSBCFG_PHYSEL | USB_OTG_GUSBCFG_TRDT | USB_OTG_GUSBCFG_TOCAL; - //USBx->GUSBCFG |= (uint32_t)((USBD_FS_TRDT_VALUE << 10) & USB_OTG_GUSBCFG_TRDT); - //USBx->GUSBCFG = USB_OTG_GUSBCFG_PHYSEL | USB_OTG_GUSBCFG_TRDT | USB_OTG_GUSBCFG_TOCAL; - - // **** for debugging, doesn't seem to work **** - //USBx->GUSBCFG |= USB_OTG_GUSBCFG_CTXPKT; - - // reset PHY clock - USBx_PCGCCTL = 0; - - // enable the fancy OTG things - // DCFG_FRAME_INTERVAL_80 is 0 - //USBx->GUSBCFG |= USB_OTG_GUSBCFG_HNPCAP | USB_OTG_GUSBCFG_SRPCAP; - USBx_DEVICE->DCFG |= USB_OTG_SPEED_FULL | USB_OTG_DCFG_NZLSOHSK; - - //USBx_DEVICE->DCFG = USB_OTG_DCFG_NZLSOHSK | USB_OTG_DCFG_DSPD; - //USBx_DEVICE->DCFG = USB_OTG_DCFG_DSPD; - // clear pending interrupts - USBx->GINTSTS = 0xBFFFFFFFU; - - // setup USB interrupts - // all interrupts except TXFIFO EMPTY - //USBx->GINTMSK = 0xFFFFFFFF & ~(USB_OTG_GINTMSK_NPTXFEM | USB_OTG_GINTMSK_PTXFEM | USB_OTG_GINTSTS_SOF | USB_OTG_GINTSTS_EOPF); - //USBx->GINTMSK = 0xFFFFFFFF & ~(USB_OTG_GINTMSK_NPTXFEM | USB_OTG_GINTMSK_PTXFEM); - USBx->GINTMSK = USB_OTG_GINTMSK_USBRST | USB_OTG_GINTMSK_ENUMDNEM | USB_OTG_GINTMSK_OTGINT | - USB_OTG_GINTMSK_RXFLVLM | USB_OTG_GINTMSK_GONAKEFFM | USB_OTG_GINTMSK_GINAKEFFM | - USB_OTG_GINTMSK_OEPINT | USB_OTG_GINTMSK_IEPINT | USB_OTG_GINTMSK_USBSUSPM | - USB_OTG_GINTMSK_CIDSCHGM | USB_OTG_GINTMSK_SRQIM | USB_OTG_GINTMSK_MMISM; - - USBx->GAHBCFG = USB_OTG_GAHBCFG_GINT; - - // DCTL startup value is 2 on new chip, 0 on old chip - USBx_DEVICE->DCTL = 0; - - // enable the IRQ - NVIC_EnableIRQ(OTG_FS_IRQn); -} // ***************************** USB port ***************************** @@ -767,6 +701,10 @@ void usb_irqhandler(void) { puts("ESUSP detected\n"); } + if ((gintsts & USB_OTG_GINTSTS_EOPF) != 0) { + usb_eopf_detected = true; + } + if ((gintsts & USB_OTG_GINTSTS_USBRST) != 0) { puts("USB reset\n"); usb_reset(); @@ -820,6 +758,7 @@ void usb_irqhandler(void) { } if (endpoint == 3) { + outep3_processing = true; usb_cb_ep3_out(usbdata, len, 1); } } else if (status == STS_SETUP_UPDT) { @@ -892,15 +831,17 @@ void usb_irqhandler(void) { #ifdef DEBUG_USB puts(" OUT3 PACKET XFRC\n"); #endif - USBx_OUTEP(3)->DOEPTSIZ = (1U << 19) | 0x40U; - USBx_OUTEP(3)->DOEPCTL |= USB_OTG_DOEPCTL_EPENA | USB_OTG_DOEPCTL_CNAK; + // NAK cleared by process_can (if tx buffers have room) + outep3_processing = false; + usb_cb_ep3_out_complete(); } else if ((USBx_OUTEP(3)->DOEPINT & 0x2000) != 0) { #ifdef DEBUG_USB puts(" OUT3 PACKET WTF\n"); #endif // if NAK was set trigger this, unknown interrupt - USBx_OUTEP(3)->DOEPTSIZ = (1U << 19) | 0x40U; - USBx_OUTEP(3)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; + // TODO: why was this here? fires when TX buffers when we can't clear NAK + // USBx_OUTEP(3)->DOEPTSIZ = (1U << 19) | 0x40U; + // USBx_OUTEP(3)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; } else if ((USBx_OUTEP(3)->DOEPINT) != 0) { puts("OUTEP3 error "); puth(USBx_OUTEP(3)->DOEPINT); @@ -985,7 +926,7 @@ void usb_irqhandler(void) { if ((ep0_txlen != 0U) && ((USBx_INEP(0)->DTXFSTS & USB_OTG_DTXFSTS_INEPTFSAV) >= 0x40U)) { uint16_t len = MIN(ep0_txlen, 0x40); USB_WritePacket(ep0_txdata, len, 0); - ep0_txdata += len; + ep0_txdata = &ep0_txdata[len]; ep0_txlen -= len; if (ep0_txlen == 0U) { ep0_txdata = NULL; @@ -1008,7 +949,16 @@ void usb_irqhandler(void) { //USBx->GINTMSK = 0xFFFFFFFF & ~(USB_OTG_GINTMSK_NPTXFEM | USB_OTG_GINTMSK_PTXFEM | USB_OTG_GINTSTS_SOF | USB_OTG_GINTSTS_EOPF); } -void OTG_FS_IRQHandler(void) { +void usb_outep3_resume_if_paused() { + ENTER_CRITICAL(); + if (!outep3_processing && (USBx_OUTEP(3)->DOEPCTL & USB_OTG_DOEPCTL_NAKSTS) != 0) { + USBx_OUTEP(3)->DOEPTSIZ = (1U << 19) | 0x40U; + USBx_OUTEP(3)->DOEPCTL |= USB_OTG_DOEPCTL_EPENA | USB_OTG_DOEPCTL_CNAK; + } + EXIT_CRITICAL(); +} + +void OTG_FS_IRQ_Handler(void) { NVIC_DisableIRQ(OTG_FS_IRQn); //__disable_irq(); usb_irqhandler(); @@ -1016,3 +966,89 @@ void OTG_FS_IRQHandler(void) { NVIC_EnableIRQ(OTG_FS_IRQn); } +bool usb_enumerated(void) { + // This relies on the USB being suspended after no activity for 3ms. + // Seems pretty stable in combination with the EOPF to reject noise. + bool ret = false; + if(!(USBx_DEVICE->DSTS & USB_OTG_DSTS_SUSPSTS)){ + // Check to see if an end of periodic frame is detected + ret = usb_eopf_detected; + } + usb_eopf_detected = false; + return ret; +} + +// ***************************** USB init ***************************** + +void usb_init(void) { + REGISTER_INTERRUPT(OTG_FS_IRQn, OTG_FS_IRQ_Handler, 1500000U, FAULT_INTERRUPT_RATE_USB) //TODO: Find out a better rate limit for USB. Now it's the 1.5MB/s rate + + // full speed PHY, do reset and remove power down + /*puth(USBx->GRSTCTL); + puts(" resetting PHY\n");*/ + while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_AHBIDL) == 0); + //puts("AHB idle\n"); + + // reset PHY here + USBx->GRSTCTL |= USB_OTG_GRSTCTL_CSRST; + while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_CSRST) == USB_OTG_GRSTCTL_CSRST); + //puts("reset done\n"); + + // internal PHY, force device mode + USBx->GUSBCFG = USB_OTG_GUSBCFG_PHYSEL | USB_OTG_GUSBCFG_FDMOD; + + // slowest timings + USBx->GUSBCFG |= ((USBD_FS_TRDT_VALUE << 10) & USB_OTG_GUSBCFG_TRDT); + + // power up the PHY +#ifdef STM32F4 + USBx->GCCFG = USB_OTG_GCCFG_PWRDWN; + + //USBx->GCCFG |= USB_OTG_GCCFG_VBDEN | USB_OTG_GCCFG_SDEN |USB_OTG_GCCFG_PDEN | USB_OTG_GCCFG_DCDEN; + + /* B-peripheral session valid override enable*/ + USBx->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL; + USBx->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN; +#else + USBx->GCCFG = USB_OTG_GCCFG_PWRDWN | USB_OTG_GCCFG_NOVBUSSENS; +#endif + + // be a device, slowest timings + //USBx->GUSBCFG = USB_OTG_GUSBCFG_FDMOD | USB_OTG_GUSBCFG_PHYSEL | USB_OTG_GUSBCFG_TRDT | USB_OTG_GUSBCFG_TOCAL; + //USBx->GUSBCFG |= (uint32_t)((USBD_FS_TRDT_VALUE << 10) & USB_OTG_GUSBCFG_TRDT); + //USBx->GUSBCFG = USB_OTG_GUSBCFG_PHYSEL | USB_OTG_GUSBCFG_TRDT | USB_OTG_GUSBCFG_TOCAL; + + // **** for debugging, doesn't seem to work **** + //USBx->GUSBCFG |= USB_OTG_GUSBCFG_CTXPKT; + + // reset PHY clock + USBx_PCGCCTL = 0; + + // enable the fancy OTG things + // DCFG_FRAME_INTERVAL_80 is 0 + //USBx->GUSBCFG |= USB_OTG_GUSBCFG_HNPCAP | USB_OTG_GUSBCFG_SRPCAP; + USBx_DEVICE->DCFG |= USB_OTG_SPEED_FULL | USB_OTG_DCFG_NZLSOHSK; + + //USBx_DEVICE->DCFG = USB_OTG_DCFG_NZLSOHSK | USB_OTG_DCFG_DSPD; + //USBx_DEVICE->DCFG = USB_OTG_DCFG_DSPD; + + // clear pending interrupts + USBx->GINTSTS = 0xBFFFFFFFU; + + // setup USB interrupts + // all interrupts except TXFIFO EMPTY + //USBx->GINTMSK = 0xFFFFFFFF & ~(USB_OTG_GINTMSK_NPTXFEM | USB_OTG_GINTMSK_PTXFEM | USB_OTG_GINTSTS_SOF | USB_OTG_GINTSTS_EOPF); + //USBx->GINTMSK = 0xFFFFFFFF & ~(USB_OTG_GINTMSK_NPTXFEM | USB_OTG_GINTMSK_PTXFEM); + USBx->GINTMSK = USB_OTG_GINTMSK_USBRST | USB_OTG_GINTMSK_ENUMDNEM | USB_OTG_GINTMSK_OTGINT | + USB_OTG_GINTMSK_RXFLVLM | USB_OTG_GINTMSK_GONAKEFFM | USB_OTG_GINTMSK_GINAKEFFM | + USB_OTG_GINTMSK_OEPINT | USB_OTG_GINTMSK_IEPINT | USB_OTG_GINTMSK_USBSUSPM | + USB_OTG_GINTMSK_CIDSCHGM | USB_OTG_GINTMSK_SRQIM | USB_OTG_GINTMSK_MMISM | USB_OTG_GINTMSK_EOPFM; + + USBx->GAHBCFG = USB_OTG_GAHBCFG_GINT; + + // DCTL startup value is 2 on new chip, 0 on old chip + USBx_DEVICE->DCTL = 0; + + // enable the IRQ + NVIC_EnableIRQ(OTG_FS_IRQn); +} \ No newline at end of file diff --git a/panda/board/faults.h b/panda/board/faults.h new file mode 100644 index 00000000000000..0825586d1683d2 --- /dev/null +++ b/panda/board/faults.h @@ -0,0 +1,52 @@ +#define FAULT_STATUS_NONE 0U +#define FAULT_STATUS_TEMPORARY 1U +#define FAULT_STATUS_PERMANENT 2U + +// Fault types +#define FAULT_RELAY_MALFUNCTION (1U << 0) +#define FAULT_UNUSED_INTERRUPT_HANDLED (1U << 1) +#define FAULT_INTERRUPT_RATE_CAN_1 (1U << 2) +#define FAULT_INTERRUPT_RATE_CAN_2 (1U << 3) +#define FAULT_INTERRUPT_RATE_CAN_3 (1U << 4) +#define FAULT_INTERRUPT_RATE_TACH (1U << 5) +#define FAULT_INTERRUPT_RATE_GMLAN (1U << 6) +#define FAULT_INTERRUPT_RATE_INTERRUPTS (1U << 7) +#define FAULT_INTERRUPT_RATE_SPI_DMA (1U << 8) +#define FAULT_INTERRUPT_RATE_SPI_CS (1U << 9) +#define FAULT_INTERRUPT_RATE_UART_1 (1U << 10) +#define FAULT_INTERRUPT_RATE_UART_2 (1U << 11) +#define FAULT_INTERRUPT_RATE_UART_3 (1U << 12) +#define FAULT_INTERRUPT_RATE_UART_5 (1U << 13) +#define FAULT_INTERRUPT_RATE_UART_DMA (1U << 14) +#define FAULT_INTERRUPT_RATE_USB (1U << 15) +#define FAULT_INTERRUPT_RATE_TIM1 (1U << 16) +#define FAULT_INTERRUPT_RATE_TIM3 (1U << 17) +#define FAULT_REGISTER_DIVERGENT (1U << 18) +#define FAULT_INTERRUPT_RATE_KLINE_INIT (1U << 19) +#define FAULT_INTERRUPT_RATE_CLOCK_SOURCE (1U << 20) +#define FAULT_INTERRUPT_RATE_TIM9 (1U << 21) + +// Permanent faults +#define PERMANENT_FAULTS 0U + +uint8_t fault_status = FAULT_STATUS_NONE; +uint32_t faults = 0U; + +void fault_occurred(uint32_t fault) { + faults |= fault; + if((PERMANENT_FAULTS & fault) != 0U){ + puts("Permanent fault occurred: 0x"); puth(fault); puts("\n"); + fault_status = FAULT_STATUS_PERMANENT; + } else { + puts("Temporary fault occurred: 0x"); puth(fault); puts("\n"); + fault_status = FAULT_STATUS_TEMPORARY; + } +} + +void fault_recovered(uint32_t fault) { + if((PERMANENT_FAULTS & fault) == 0U){ + faults &= ~fault; + } else { + puts("Cannot recover from a permanent fault!\n"); + } +} \ No newline at end of file diff --git a/panda/board/get_sdk.sh b/panda/board/get_sdk.sh index 7b8d1f9154c0ac..84964244ed02b3 100755 --- a/panda/board/get_sdk.sh +++ b/panda/board/get_sdk.sh @@ -1,3 +1,3 @@ #!/bin/bash sudo apt-get install gcc-arm-none-eabi python-pip -sudo pip2 install libusb1 pycrypto requests +sudo pip install libusb1 pycryptodome requests diff --git a/panda/board/get_sdk_mac.sh b/panda/board/get_sdk_mac.sh index a6f641dce12116..2daba2a141d7a7 100755 --- a/panda/board/get_sdk_mac.sh +++ b/panda/board/get_sdk_mac.sh @@ -1,5 +1,7 @@ #!/bin/bash # Need formula for gcc +sudo easy_install pip +/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" brew tap ArmMbed/homebrew-formulae brew install python dfu-util arm-none-eabi-gcc -pip2 install libusb1 pycrypto requests +pip install --user libusb1 pycryptodome requests diff --git a/panda/board/gpio.h b/panda/board/gpio.h index 1acf0288ad8d1f..b50de50c333640 100644 --- a/panda/board/gpio.h +++ b/panda/board/gpio.h @@ -20,6 +20,15 @@ void jump_to_bootloader(void) { } void early(void) { + // Reset global critical depth + global_critical_depth = 0; + + // Init register and interrupt tables + init_registers(); + + // neccesary for DFU flashing on a non-power cycled white panda + enable_interrupts(); + // after it's been in the bootloader, things are initted differently, so we reset if ((enter_bootloader_mode != BOOT_NORMAL) && (enter_bootloader_mode != ENTER_BOOTLOADER_MAGIC) && @@ -53,22 +62,11 @@ void early(void) { detect_configuration(); detect_board_type(); - #ifdef PANDA - // enable the ESP, disable ESP boot mode - // dont disable on grey panda - current_board->set_esp_gps_mode(ESP_GPS_ENABLED); - #endif - - if (enter_bootloader_mode == ENTER_BOOTLOADER_MAGIC) { #ifdef PANDA - current_board->set_esp_gps_mode(ESP_GPS_DISABLED); + current_board->set_gps_mode(GPS_DISABLED); #endif current_board->set_led(LED_GREEN, 1); jump_to_bootloader(); } - - if (is_entering_bootmode) { - enter_bootloader_mode = ENTER_SOFTLOADER_MAGIC; - } -} \ No newline at end of file +} diff --git a/panda/board/inc/cmsis_compiler.h b/panda/board/inc/cmsis_compiler.h new file mode 100644 index 00000000000000..d0f39eef67ed91 --- /dev/null +++ b/panda/board/inc/cmsis_compiler.h @@ -0,0 +1,284 @@ +/**************************************************************************//** + * @file cmsis_compiler.h + * @brief CMSIS compiler generic header file + * @version V5.1.0 + * @date 09. October 2018 + ******************************************************************************/ +/* + * Copyright (c) 2009-2018 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CMSIS_COMPILER_H +#define __CMSIS_COMPILER_H + +#include + +/* + * Arm Compiler 4/5 + */ +#if defined ( __CC_ARM ) + #include "cmsis_armcc.h" + + +/* + * Arm Compiler 6.6 LTM (armclang) + */ +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100) + #include "cmsis_armclang_ltm.h" + + /* + * Arm Compiler above 6.10.1 (armclang) + */ +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100) + #include "cmsis_armclang.h" + + +/* + * GNU Compiler + */ +#elif defined ( __GNUC__ ) + #include "cmsis_gcc.h" + + +/* + * IAR Compiler + */ +#elif defined ( __ICCARM__ ) + #include + + +/* + * TI Arm Compiler + */ +#elif defined ( __TI_ARM__ ) + #include + + #ifndef __ASM + #define __ASM __asm + #endif + #ifndef __INLINE + #define __INLINE inline + #endif + #ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline + #endif + #ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __STATIC_INLINE + #endif + #ifndef __NO_RETURN + #define __NO_RETURN __attribute__((noreturn)) + #endif + #ifndef __USED + #define __USED __attribute__((used)) + #endif + #ifndef __WEAK + #define __WEAK __attribute__((weak)) + #endif + #ifndef __PACKED + #define __PACKED __attribute__((packed)) + #endif + #ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed)) + #endif + #ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed)) + #endif + #ifndef __UNALIGNED_UINT32 /* deprecated */ + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) + #endif + #ifndef __UNALIGNED_UINT16_WRITE + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT16_READ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) + #endif + #ifndef __UNALIGNED_UINT32_WRITE + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT32_READ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) + #endif + #ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) + #endif + #ifndef __RESTRICT + #define __RESTRICT __restrict + #endif + #ifndef __COMPILER_BARRIER + #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. + #define __COMPILER_BARRIER() (void)0 + #endif + + +/* + * TASKING Compiler + */ +#elif defined ( __TASKING__ ) + /* + * The CMSIS functions have been implemented as intrinsics in the compiler. + * Please use "carm -?i" to get an up to date list of all intrinsics, + * Including the CMSIS ones. + */ + + #ifndef __ASM + #define __ASM __asm + #endif + #ifndef __INLINE + #define __INLINE inline + #endif + #ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline + #endif + #ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __STATIC_INLINE + #endif + #ifndef __NO_RETURN + #define __NO_RETURN __attribute__((noreturn)) + #endif + #ifndef __USED + #define __USED __attribute__((used)) + #endif + #ifndef __WEAK + #define __WEAK __attribute__((weak)) + #endif + #ifndef __PACKED + #define __PACKED __packed__ + #endif + #ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __packed__ + #endif + #ifndef __PACKED_UNION + #define __PACKED_UNION union __packed__ + #endif + #ifndef __UNALIGNED_UINT32 /* deprecated */ + struct __packed__ T_UINT32 { uint32_t v; }; + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) + #endif + #ifndef __UNALIGNED_UINT16_WRITE + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT16_READ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) + #endif + #ifndef __UNALIGNED_UINT32_WRITE + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT32_READ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) + #endif + #ifndef __ALIGNED + #define __ALIGNED(x) __align(x) + #endif + #ifndef __RESTRICT + #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. + #define __RESTRICT + #endif + #ifndef __COMPILER_BARRIER + #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. + #define __COMPILER_BARRIER() (void)0 + #endif + + +/* + * COSMIC Compiler + */ +#elif defined ( __CSMC__ ) + #include + + #ifndef __ASM + #define __ASM _asm + #endif + #ifndef __INLINE + #define __INLINE inline + #endif + #ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline + #endif + #ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __STATIC_INLINE + #endif + #ifndef __NO_RETURN + // NO RETURN is automatically detected hence no warning here + #define __NO_RETURN + #endif + #ifndef __USED + #warning No compiler specific solution for __USED. __USED is ignored. + #define __USED + #endif + #ifndef __WEAK + #define __WEAK __weak + #endif + #ifndef __PACKED + #define __PACKED @packed + #endif + #ifndef __PACKED_STRUCT + #define __PACKED_STRUCT @packed struct + #endif + #ifndef __PACKED_UNION + #define __PACKED_UNION @packed union + #endif + #ifndef __UNALIGNED_UINT32 /* deprecated */ + @packed struct T_UINT32 { uint32_t v; }; + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) + #endif + #ifndef __UNALIGNED_UINT16_WRITE + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT16_READ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) + #endif + #ifndef __UNALIGNED_UINT32_WRITE + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT32_READ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) + #endif + #ifndef __ALIGNED + #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored. + #define __ALIGNED(x) + #endif + #ifndef __RESTRICT + #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. + #define __RESTRICT + #endif + #ifndef __COMPILER_BARRIER + #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. + #define __COMPILER_BARRIER() (void)0 + #endif + + +#else + #error Unknown compiler. +#endif + + +#endif /* __CMSIS_COMPILER_H */ + + diff --git a/panda/board/inc/cmsis_gcc.h b/panda/board/inc/cmsis_gcc.h index bb89fbba9e4000..2f68473f64e216 100644 --- a/panda/board/inc/cmsis_gcc.h +++ b/panda/board/inc/cmsis_gcc.h @@ -1,48 +1,186 @@ /**************************************************************************//** * @file cmsis_gcc.h - * @brief CMSIS Cortex-M Core Function/Instruction Header File - * @version V4.30 - * @date 20. October 2015 + * @brief CMSIS compiler GCC header file + * @version V5.2.0 + * @date 08. May 2019 ******************************************************************************/ -/* Copyright (c) 2009 - 2015 ARM LIMITED - - All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of ARM nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - * - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------------*/ - +/* + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef __CMSIS_GCC_H #define __CMSIS_GCC_H /* ignore some GCC warnings */ -#if defined ( __GNUC__ ) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsign-conversion" #pragma GCC diagnostic ignored "-Wconversion" #pragma GCC diagnostic ignored "-Wunused-parameter" + +/* Fallback for __has_builtin */ +#ifndef __has_builtin + #define __has_builtin(x) (0) +#endif + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __attribute__((always_inline)) static inline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __attribute__((__noreturn__)) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed, aligned(1))) +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START + +/** + \brief Initializes data and bss sections + \details This default implementations initialized all data and additional bss + sections relying on .copy.table and .zero.table specified properly + in the used linker script. + + */ +__STATIC_FORCEINLINE __NO_RETURN void __cmsis_start(void) +{ + extern void _start(void) __NO_RETURN; + + typedef struct { + uint32_t const* src; + uint32_t* dest; + uint32_t wlen; + } __copy_table_t; + + typedef struct { + uint32_t* dest; + uint32_t wlen; + } __zero_table_t; + + extern const __copy_table_t __copy_table_start__; + extern const __copy_table_t __copy_table_end__; + extern const __zero_table_t __zero_table_start__; + extern const __zero_table_t __zero_table_end__; + + for (__copy_table_t const* pTable = &__copy_table_start__; pTable < &__copy_table_end__; ++pTable) { + for(uint32_t i=0u; iwlen; ++i) { + pTable->dest[i] = pTable->src[i]; + } + } + + for (__zero_table_t const* pTable = &__zero_table_start__; pTable < &__zero_table_end__; ++pTable) { + for(uint32_t i=0u; iwlen; ++i) { + pTable->dest[i] = 0u; + } + } + + _start(); +} + +#define __PROGRAM_START __cmsis_start #endif +#ifndef __INITIAL_SP +#define __INITIAL_SP __StackTop +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT __StackLimit +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute((used, section(".vectors"))) +#endif /* ########################### Core Function Access ########################### */ /** \ingroup CMSIS_Core_FunctionInterface @@ -55,7 +193,7 @@ \details Enables IRQ interrupts by clearing the I-bit in the CPSR. Can only be executed in Privileged modes. */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_irq(void) +__STATIC_FORCEINLINE void __enable_irq(void) { __ASM volatile ("cpsie i" : : : "memory"); } @@ -64,9 +202,9 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_irq(void) /** \brief Disable IRQ Interrupts \details Disables IRQ interrupts by setting the I-bit in the CPSR. - Can only be executed in Privileged modes. + Can only be executed in Privileged modes. */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void) +__STATIC_FORCEINLINE void __disable_irq(void) { __ASM volatile ("cpsid i" : : : "memory"); } @@ -77,7 +215,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void) \details Returns the content of the Control Register. \return Control Register value */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(void) +__STATIC_FORCEINLINE uint32_t __get_CONTROL(void) { uint32_t result; @@ -86,23 +224,52 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(void) } +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Control Register (non-secure) + \details Returns the content of the non-secure Control Register when in secure mode. + \return non-secure Control Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control_ns" : "=r" (result) ); + return(result); +} +#endif + + /** \brief Set Control Register \details Writes the given value to the Control Register. \param [in] control Control Register value to set */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_CONTROL(uint32_t control) +__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) { __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); } +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Control Register (non-secure) + \details Writes the given value to the non-secure Control Register when in secure state. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory"); +} +#endif + + /** \brief Get IPSR Register \details Returns the content of the IPSR Register. \return IPSR Register value */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_IPSR(void) +__STATIC_FORCEINLINE uint32_t __get_IPSR(void) { uint32_t result; @@ -116,7 +283,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_IPSR(void) \details Returns the content of the APSR Register. \return APSR Register value */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_APSR(void) +__STATIC_FORCEINLINE uint32_t __get_APSR(void) { uint32_t result; @@ -128,10 +295,9 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_APSR(void) /** \brief Get xPSR Register \details Returns the content of the xPSR Register. - - \return xPSR Register value + \return xPSR Register value */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_xPSR(void) +__STATIC_FORCEINLINE uint32_t __get_xPSR(void) { uint32_t result; @@ -145,13 +311,29 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_xPSR(void) \details Returns the current value of the Process Stack Pointer (PSP). \return PSP Register value */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PSP(void) +__STATIC_FORCEINLINE uint32_t __get_PSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer (non-secure) + \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state. + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void) { - register uint32_t result; + uint32_t result; - __ASM volatile ("MRS %0, psp\n" : "=r" (result) ); + __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); return(result); } +#endif /** @@ -159,10 +341,23 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PSP(void) \details Assigns the given value to the Process Stack Pointer (PSP). \param [in] topOfProcStack Process Stack Pointer value to set */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack) +__STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state. + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) { - __ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) : "sp"); + __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : ); } +#endif /** @@ -170,39 +365,110 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PSP(uint32_t topOf \details Returns the current value of the Main Stack Pointer (MSP). \return MSP Register value */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_MSP(void) +__STATIC_FORCEINLINE uint32_t __get_MSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer (non-secure) + \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state. + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void) { - register uint32_t result; + uint32_t result; - __ASM volatile ("MRS %0, msp\n" : "=r" (result) ); + __ASM volatile ("MRS %0, msp_ns" : "=r" (result) ); return(result); } +#endif /** \brief Set Main Stack Pointer \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : ); +} + - \param [in] topOfMainStack Main Stack Pointer value to set +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state. + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : ); +} +#endif + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Stack Pointer (non-secure) + \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state. + \return SP Register value */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack) +__STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void) { - __ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) : "sp"); + uint32_t result; + + __ASM volatile ("MRS %0, sp_ns" : "=r" (result) ); + return(result); } +/** + \brief Set Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state. + \param [in] topOfStack Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack) +{ + __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : ); +} +#endif + + /** \brief Get Priority Mask \details Returns the current state of the priority mask bit from the Priority Mask Register. \return Priority Mask value */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PRIMASK(void) +__STATIC_FORCEINLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) :: "memory"); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Priority Mask (non-secure) + \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void) { uint32_t result; - __ASM volatile ("MRS %0, primask" : "=r" (result) ); + __ASM volatile ("MRS %0, primask_ns" : "=r" (result) :: "memory"); return(result); } +#endif /** @@ -210,20 +476,34 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PRIMASK(void) \details Assigns the given value to the Priority Mask Register. \param [in] priMask Priority Mask */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask) +__STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask) { __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); } -#if (__CORTEX_M >= 0x03U) +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Priority Mask (non-secure) + \details Assigns the given value to the non-secure Priority Mask Register when in secure state. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) +{ + __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); +} +#endif + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) /** \brief Enable FIQ \details Enables FIQ interrupts by clearing the F-bit in the CPSR. Can only be executed in Privileged modes. */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_fault_irq(void) +__STATIC_FORCEINLINE void __enable_fault_irq(void) { __ASM volatile ("cpsie f" : : : "memory"); } @@ -234,7 +514,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_fault_irq(void) \details Disables FIQ interrupts by setting the F-bit in the CPSR. Can only be executed in Privileged modes. */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_fault_irq(void) +__STATIC_FORCEINLINE void __disable_fault_irq(void) { __ASM volatile ("cpsid f" : : : "memory"); } @@ -245,7 +525,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_fault_irq(void \details Returns the current value of the Base Priority register. \return Base Priority register value */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_BASEPRI(void) +__STATIC_FORCEINLINE uint32_t __get_BASEPRI(void) { uint32_t result; @@ -254,15 +534,44 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_BASEPRI(void) } +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Base Priority (non-secure) + \details Returns the current value of the non-secure Base Priority register when in secure state. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) ); + return(result); +} +#endif + + /** \brief Set Base Priority \details Assigns the given value to the Base Priority register. \param [in] basePri Base Priority value to set */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI(uint32_t value) +__STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Base Priority (non-secure) + \details Assigns the given value to the non-secure Base Priority register when in secure state. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri) { - __ASM volatile ("MSR basepri, %0" : : "r" (value) : "memory"); + __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory"); } +#endif /** @@ -271,9 +580,9 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI(uint32_t v or the new value increases the BASEPRI priority level. \param [in] basePri Base Priority value to set */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t value) +__STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri) { - __ASM volatile ("MSR basepri_max, %0" : : "r" (value) : "memory"); + __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory"); } @@ -282,7 +591,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI_MAX(uint32 \details Returns the current value of the Fault Mask register. \return Fault Mask register value */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FAULTMASK(void) +__STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void) { uint32_t result; @@ -291,38 +600,253 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FAULTMASK(void } +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Fault Mask (non-secure) + \details Returns the current value of the non-secure Fault Mask register when in secure state. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) ); + return(result); +} +#endif + + /** \brief Set Fault Mask \details Assigns the given value to the Fault Mask register. \param [in] faultMask Fault Mask value to set */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask) +__STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask) { __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); } -#endif /* (__CORTEX_M >= 0x03U) */ +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Fault Mask (non-secure) + \details Assigns the given value to the non-secure Fault Mask register when in secure state. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); +} +#endif + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + +/** + \brief Get Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim" : "=r" (result) ); + return result; +#endif +} + +#if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); +#endif +} +#endif + + +/** + \brief Get Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim" : "=r" (result) ); + return result; +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). + \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state. + \param [in] MainStackPtrLimit Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); +#endif +} +#endif + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ -#if (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U) /** \brief Get FPSCR \details Returns the current value of the Floating Point Status/Control register. \return Floating Point Status/Control register value */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void) -{ -#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) +__STATIC_FORCEINLINE uint32_t __get_FPSCR(void) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#if __has_builtin(__builtin_arm_get_fpscr) +// Re-enable using built-in when GCC has been fixed +// || (__GNUC__ > 7) || (__GNUC__ == 7 && __GNUC_MINOR__ >= 2) + /* see https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00443.html */ + return __builtin_arm_get_fpscr(); +#else uint32_t result; - /* Empty asm statement works as a scheduling barrier */ - __ASM volatile (""); __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); - __ASM volatile (""); return(result); +#endif #else - return(0); + return(0U); #endif } @@ -332,19 +856,23 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void) \details Assigns the given value to the Floating Point Status/Control register. \param [in] fpscr Floating Point Status/Control value to set */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr) -{ -#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) - /* Empty asm statement works as a scheduling barrier */ - __ASM volatile (""); - __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc"); - __ASM volatile (""); +__STATIC_FORCEINLINE void __set_FPSCR(uint32_t fpscr) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#if __has_builtin(__builtin_arm_set_fpscr) +// Re-enable using built-in when GCC has been fixed +// || (__GNUC__ > 7) || (__GNUC__ == 7 && __GNUC_MINOR__ >= 2) + /* see https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00443.html */ + __builtin_arm_set_fpscr(fpscr); +#else + __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc", "memory"); +#endif +#else + (void)fpscr; #endif } -#endif /* (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U) */ - - /*@} end of CMSIS_Core_RegAccFunctions */ @@ -360,9 +888,11 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPSCR(uint32_t fps * Otherwise, use general registers, specified by constraint "r" */ #if defined (__thumb__) && !defined (__thumb2__) #define __CMSIS_GCC_OUT_REG(r) "=l" (r) +#define __CMSIS_GCC_RW_REG(r) "+l" (r) #define __CMSIS_GCC_USE_REG(r) "l" (r) #else #define __CMSIS_GCC_OUT_REG(r) "=r" (r) +#define __CMSIS_GCC_RW_REG(r) "+r" (r) #define __CMSIS_GCC_USE_REG(r) "r" (r) #endif @@ -370,41 +900,28 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPSCR(uint32_t fps \brief No Operation \details No Operation does nothing. This instruction can be used for code alignment purposes. */ -__attribute__((always_inline)) __STATIC_INLINE void __NOP(void) -{ - __ASM volatile ("nop"); -} - +#define __NOP() __ASM volatile ("nop") /** \brief Wait For Interrupt \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. */ -__attribute__((always_inline)) __STATIC_INLINE void __WFI(void) -{ - __ASM volatile ("wfi"); -} +#define __WFI() __ASM volatile ("wfi") /** \brief Wait For Event \details Wait For Event is a hint instruction that permits the processor to enter - a low-power state until one of a number of events occurs. + a low-power state until one of a number of events occurs. */ -__attribute__((always_inline)) __STATIC_INLINE void __WFE(void) -{ - __ASM volatile ("wfe"); -} +#define __WFE() __ASM volatile ("wfe") /** \brief Send Event \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. */ -__attribute__((always_inline)) __STATIC_INLINE void __SEV(void) -{ - __ASM volatile ("sev"); -} +#define __SEV() __ASM volatile ("sev") /** @@ -413,7 +930,7 @@ __attribute__((always_inline)) __STATIC_INLINE void __SEV(void) so that all instructions following the ISB are fetched from cache or memory, after the instruction has been completed. */ -__attribute__((always_inline)) __STATIC_INLINE void __ISB(void) +__STATIC_FORCEINLINE void __ISB(void) { __ASM volatile ("isb 0xF":::"memory"); } @@ -424,7 +941,7 @@ __attribute__((always_inline)) __STATIC_INLINE void __ISB(void) \details Acts as a special kind of Data Memory Barrier. It completes when all explicit memory accesses before this instruction complete. */ -__attribute__((always_inline)) __STATIC_INLINE void __DSB(void) +__STATIC_FORCEINLINE void __DSB(void) { __ASM volatile ("dsb 0xF":::"memory"); } @@ -435,7 +952,7 @@ __attribute__((always_inline)) __STATIC_INLINE void __DSB(void) \details Ensures the apparent order of the explicit memory operations before and after the instruction, without ensuring their completion. */ -__attribute__((always_inline)) __STATIC_INLINE void __DMB(void) +__STATIC_FORCEINLINE void __DMB(void) { __ASM volatile ("dmb 0xF":::"memory"); } @@ -443,11 +960,11 @@ __attribute__((always_inline)) __STATIC_INLINE void __DMB(void) /** \brief Reverse byte order (32 bit) - \details Reverses the byte order in integer value. + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. \param [in] value Value to reverse \return Reversed value */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __REV(uint32_t value) +__STATIC_FORCEINLINE uint32_t __REV(uint32_t value) { #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) return __builtin_bswap32(value); @@ -455,41 +972,41 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __REV(uint32_t value) uint32_t result; __ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); - return(result); + return result; #endif } /** \brief Reverse byte order (16 bit) - \details Reverses the byte order in two unsigned short values. + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. \param [in] value Value to reverse \return Reversed value */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value) +__STATIC_FORCEINLINE uint32_t __REV16(uint32_t value) { uint32_t result; __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); - return(result); + return result; } /** - \brief Reverse byte order in signed short value - \details Reverses the byte order in a signed short value with sign extension to integer. + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. \param [in] value Value to reverse \return Reversed value */ -__attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value) +__STATIC_FORCEINLINE int16_t __REVSH(int16_t value) { #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) - return (short)__builtin_bswap16(value); + return (int16_t)__builtin_bswap16(value); #else - int32_t result; + int16_t result; __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); - return(result); + return result; #endif } @@ -497,12 +1014,17 @@ __attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value) /** \brief Rotate Right in unsigned value (32 bit) \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. - \param [in] value Value to rotate - \param [in] value Number of Bits to rotate + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate \return Rotated value */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2) { + op2 %= 32U; + if (op2 == 0U) + { + return op1; + } return (op1 >> op2) | (op1 << (32U - op2)); } @@ -523,17 +1045,19 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint \param [in] value Value to reverse \return Reversed value */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value) +__STATIC_FORCEINLINE uint32_t __RBIT(uint32_t value) { uint32_t result; -#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) ); #else - int32_t s = 4 /*sizeof(v)*/ * 8 - 1; /* extra shift needed at end */ + uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */ result = value; /* r will be reversed bits of v; first get LSB of v */ - for (value >>= 1U; value; value >>= 1U) + for (value >>= 1U; value != 0U; value >>= 1U) { result <<= 1U; result |= value & 1U; @@ -541,7 +1065,7 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value) } result <<= s; /* shift when v's highest bits are zero */ #endif - return(result); + return result; } @@ -551,18 +1075,36 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value) \param [in] value Value to count the leading zeros \return number of leading zeros in value */ -#define __CLZ __builtin_clz - +__STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value) +{ + /* Even though __builtin_clz produces a CLZ instruction on ARM, formally + __builtin_clz(0) is undefined behaviour, so handle this case specially. + This guarantees ARM-compatible results if happening to compile on a non-ARM + target, and ensures the compiler doesn't decide to activate any + optimisations using the logic "value was passed to __builtin_clz, so it + is non-zero". + ARM GCC 7.3 and possibly earlier will optimise this test away, leaving a + single CLZ instruction. + */ + if (value == 0U) + { + return 32U; + } + return __builtin_clz(value); +} -#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) /** \brief LDR Exclusive (8 bit) \details Executes a exclusive LDR instruction for 8 bit value. \param [in] ptr Pointer to data \return value of type uint8_t at (*ptr) */ -__attribute__((always_inline)) __STATIC_INLINE uint8_t __LDREXB(volatile uint8_t *addr) +__STATIC_FORCEINLINE uint8_t __LDREXB(volatile uint8_t *addr) { uint32_t result; @@ -584,7 +1126,7 @@ __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDREXB(volatile uint8_t \param [in] ptr Pointer to data \return value of type uint16_t at (*ptr) */ -__attribute__((always_inline)) __STATIC_INLINE uint16_t __LDREXH(volatile uint16_t *addr) +__STATIC_FORCEINLINE uint16_t __LDREXH(volatile uint16_t *addr) { uint32_t result; @@ -606,7 +1148,7 @@ __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDREXH(volatile uint16 \param [in] ptr Pointer to data \return value of type uint32_t at (*ptr) */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __LDREXW(volatile uint32_t *addr) +__STATIC_FORCEINLINE uint32_t __LDREXW(volatile uint32_t *addr) { uint32_t result; @@ -623,7 +1165,7 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDREXW(volatile uint32 \return 0 Function succeeded \return 1 Function failed */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr) +__STATIC_FORCEINLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr) { uint32_t result; @@ -640,7 +1182,7 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXB(uint8_t value, \return 0 Function succeeded \return 1 Function failed */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr) +__STATIC_FORCEINLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr) { uint32_t result; @@ -657,7 +1199,7 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXH(uint16_t value, \return 0 Function succeeded \return 1 Function failed */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr) +__STATIC_FORCEINLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr) { uint32_t result; @@ -670,22 +1212,31 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXW(uint32_t value, \brief Remove the exclusive lock \details Removes the exclusive lock which is created by LDREX. */ -__attribute__((always_inline)) __STATIC_INLINE void __CLREX(void) +__STATIC_FORCEINLINE void __CLREX(void) { __ASM volatile ("clrex" ::: "memory"); } +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) /** \brief Signed Saturate \details Saturates a signed value. - \param [in] value Value to be saturated - \param [in] sat Bit position to saturate to (1..32) + \param [in] ARG1 Value to be saturated + \param [in] ARG2 Bit position to saturate to (1..32) \return Saturated value */ #define __SSAT(ARG1,ARG2) \ +__extension__ \ ({ \ - uint32_t __RES, __ARG1 = (ARG1); \ + int32_t __RES, __ARG1 = (ARG1); \ __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ __RES; \ }) @@ -694,11 +1245,12 @@ __attribute__((always_inline)) __STATIC_INLINE void __CLREX(void) /** \brief Unsigned Saturate \details Saturates an unsigned value. - \param [in] value Value to be saturated - \param [in] sat Bit position to saturate to (0..31) + \param [in] ARG1 Value to be saturated + \param [in] ARG2 Bit position to saturate to (0..31) \return Saturated value */ #define __USAT(ARG1,ARG2) \ + __extension__ \ ({ \ uint32_t __RES, __ARG1 = (ARG1); \ __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ @@ -713,7 +1265,7 @@ __attribute__((always_inline)) __STATIC_INLINE void __CLREX(void) \param [in] value Value to rotate \return Rotated value */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value) +__STATIC_FORCEINLINE uint32_t __RRX(uint32_t value) { uint32_t result; @@ -728,17 +1280,17 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value) \param [in] ptr Pointer to data \return value of type uint8_t at (*ptr) */ -__attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *addr) +__STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr) { uint32_t result; #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) - __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*addr) ); + __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) ); #else /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not accepted by assembler. So has to use following less efficient pattern. */ - __ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); + __ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" ); #endif return ((uint8_t) result); /* Add explicit type cast here */ } @@ -750,17 +1302,17 @@ __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t \param [in] ptr Pointer to data \return value of type uint16_t at (*ptr) */ -__attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *addr) +__STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr) { uint32_t result; #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) - __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*addr) ); + __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) ); #else /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not accepted by assembler. So has to use following less efficient pattern. */ - __ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); + __ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" ); #endif return ((uint16_t) result); /* Add explicit type cast here */ } @@ -772,11 +1324,11 @@ __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_ \param [in] ptr Pointer to data \return value of type uint32_t at (*ptr) */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *addr) +__STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr) { uint32_t result; - __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*addr) ); + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); return(result); } @@ -787,9 +1339,9 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t \param [in] value Value to store \param [in] ptr Pointer to location */ -__attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *addr) +__STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) { - __ASM volatile ("strbt %1, %0" : "=Q" (*addr) : "r" ((uint32_t)value) ); + __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); } @@ -799,9 +1351,9 @@ __attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volat \param [in] value Value to store \param [in] ptr Pointer to location */ -__attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *addr) +__STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) { - __ASM volatile ("strht %1, %0" : "=Q" (*addr) : "r" ((uint32_t)value) ); + __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); } @@ -811,12 +1363,249 @@ __attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, vola \param [in] value Value to store \param [in] ptr Pointer to location */ -__attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *addr) +__STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); +} + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief Load-Acquire (8 bit) + \details Executes a LDAB instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr) { - __ASM volatile ("strt %1, %0" : "=Q" (*addr) : "r" (value) ); + uint32_t result; + + __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint8_t) result); } -#endif /* (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) */ + +/** + \brief Load-Acquire (16 bit) + \details Executes a LDAH instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire (32 bit) + \details Executes a LDA instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief Store-Release (8 bit) + \details Executes a STLB instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief Store-Release (16 bit) + \details Executes a STLH instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief Store-Release (32 bit) + \details Executes a STL instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief Load-Acquire Exclusive (8 bit) + \details Executes a LDAB exclusive instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAEXB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldaexb %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire Exclusive (16 bit) + \details Executes a LDAH exclusive instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAEXH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldaexh %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire Exclusive (32 bit) + \details Executes a LDA exclusive instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDAEX(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldaex %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief Store-Release Exclusive (8 bit) + \details Executes a STLB exclusive instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("stlexb %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) ); + return(result); +} + + +/** + \brief Store-Release Exclusive (16 bit) + \details Executes a STLH exclusive instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("stlexh %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) ); + return(result); +} + + +/** + \brief Store-Release Exclusive (32 bit) + \details Executes a STL exclusive instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("stlex %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) ); + return(result); +} + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ @@ -827,9 +1616,9 @@ __attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volat @{ */ -#if (__CORTEX_M >= 0x04U) /* only for Cortex-M4 and above */ +#if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) { uint32_t result; @@ -837,7 +1626,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SADD8(uint32_t op1 return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) { uint32_t result; @@ -845,7 +1634,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QADD8(uint32_t op1 return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) { uint32_t result; @@ -853,7 +1642,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHADD8(uint32_t op return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) { uint32_t result; @@ -861,7 +1650,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UADD8(uint32_t op1 return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) { uint32_t result; @@ -869,7 +1658,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQADD8(uint32_t op return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) { uint32_t result; @@ -878,7 +1667,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHADD8(uint32_t op } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) { uint32_t result; @@ -886,7 +1675,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1 return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) { uint32_t result; @@ -894,7 +1683,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1 return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) { uint32_t result; @@ -902,7 +1691,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) { uint32_t result; @@ -910,7 +1699,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USUB8(uint32_t op1 return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) { uint32_t result; @@ -918,7 +1707,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) { uint32_t result; @@ -927,7 +1716,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) { uint32_t result; @@ -935,7 +1724,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SADD16(uint32_t op return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) { uint32_t result; @@ -943,7 +1732,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QADD16(uint32_t op return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) { uint32_t result; @@ -951,7 +1740,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHADD16(uint32_t o return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) { uint32_t result; @@ -959,7 +1748,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UADD16(uint32_t op return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) { uint32_t result; @@ -967,7 +1756,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQADD16(uint32_t o return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) { uint32_t result; @@ -975,7 +1764,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHADD16(uint32_t o return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) { uint32_t result; @@ -983,7 +1772,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSUB16(uint32_t op return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) { uint32_t result; @@ -991,7 +1780,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSUB16(uint32_t op return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) { uint32_t result; @@ -999,7 +1788,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSUB16(uint32_t o return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) { uint32_t result; @@ -1007,7 +1796,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USUB16(uint32_t op return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) { uint32_t result; @@ -1015,7 +1804,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSUB16(uint32_t o return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) { uint32_t result; @@ -1023,7 +1812,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSUB16(uint32_t o return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2) { uint32_t result; @@ -1031,7 +1820,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SASX(uint32_t op1, return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2) { uint32_t result; @@ -1039,7 +1828,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QASX(uint32_t op1, return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) { uint32_t result; @@ -1047,7 +1836,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHASX(uint32_t op1 return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2) { uint32_t result; @@ -1055,7 +1844,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UASX(uint32_t op1, return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) { uint32_t result; @@ -1063,7 +1852,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQASX(uint32_t op1 return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) { uint32_t result; @@ -1071,7 +1860,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHASX(uint32_t op1 return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) { uint32_t result; @@ -1079,7 +1868,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) { uint32_t result; @@ -1087,7 +1876,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) { uint32_t result; @@ -1095,7 +1884,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1 return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2) { uint32_t result; @@ -1103,7 +1892,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USAX(uint32_t op1, return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) { uint32_t result; @@ -1111,7 +1900,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1 return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) { uint32_t result; @@ -1119,7 +1908,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1 return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) { uint32_t result; @@ -1127,7 +1916,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USAD8(uint32_t op1 return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) +__STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) { uint32_t result; @@ -1149,7 +1938,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USADA8(uint32_t op __RES; \ }) -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1) +__STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1) { uint32_t result; @@ -1157,7 +1946,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UXTB16(uint32_t op return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) { uint32_t result; @@ -1165,7 +1954,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UXTAB16(uint32_t o return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1) +__STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1) { uint32_t result; @@ -1173,7 +1962,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SXTB16(uint32_t op return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) { uint32_t result; @@ -1181,7 +1970,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SXTAB16(uint32_t o return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) { uint32_t result; @@ -1189,7 +1978,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUAD (uint32_t o return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) { uint32_t result; @@ -1197,7 +1986,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUADX (uint32_t o return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) +__STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) { uint32_t result; @@ -1205,7 +1994,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLAD (uint32_t op return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) +__STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) { uint32_t result; @@ -1213,7 +2002,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLADX (uint32_t o return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) +__STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) { union llreg_u{ uint32_t w32[2]; @@ -1230,7 +2019,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLALD (uint32_t o return(llr.w64); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) +__STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) { union llreg_u{ uint32_t w32[2]; @@ -1247,7 +2036,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLALDX (uint32_t return(llr.w64); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) { uint32_t result; @@ -1255,7 +2044,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUSD (uint32_t o return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) { uint32_t result; @@ -1263,7 +2052,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUSDX (uint32_t o return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) +__STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) { uint32_t result; @@ -1271,7 +2060,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLSD (uint32_t op return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) +__STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) { uint32_t result; @@ -1279,7 +2068,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLSDX (uint32_t o return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) +__STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) { union llreg_u{ uint32_t w32[2]; @@ -1296,7 +2085,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLSLD (uint32_t o return(llr.w64); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) +__STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) { union llreg_u{ uint32_t w32[2]; @@ -1313,7 +2102,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t return(llr.w64); } -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SEL (uint32_t op1, uint32_t op2) +__STATIC_FORCEINLINE uint32_t __SEL (uint32_t op1, uint32_t op2) { uint32_t result; @@ -1321,7 +2110,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SEL (uint32_t op1 return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __QADD( int32_t op1, int32_t op2) +__STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2) { int32_t result; @@ -1329,7 +2118,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __QADD( int32_t op1, return(result); } -__attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __QSUB( int32_t op1, int32_t op2) +__STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2) { int32_t result; @@ -1337,6 +2126,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __QSUB( int32_t op1, return(result); } +#if 0 #define __PKHBT(ARG1,ARG2,ARG3) \ ({ \ uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ @@ -1353,8 +2143,15 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __QSUB( int32_t op1, __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ __RES; \ }) +#endif + +#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ + ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) +#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ + ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) + +__STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) { int32_t result; @@ -1362,12 +2159,11 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMMLA (int32_t op1 return(result); } -#endif /* (__CORTEX_M >= 0x04) */ +#endif /* (__ARM_FEATURE_DSP == 1) */ /*@} end of group CMSIS_SIMD_intrinsics */ -#if defined ( __GNUC__ ) #pragma GCC diagnostic pop -#endif #endif /* __CMSIS_GCC_H */ + diff --git a/panda/board/inc/cmsis_version.h b/panda/board/inc/cmsis_version.h new file mode 100644 index 00000000000000..bf57cf3e805348 --- /dev/null +++ b/panda/board/inc/cmsis_version.h @@ -0,0 +1,40 @@ +/**************************************************************************//** + * @file cmsis_version.h + * @brief CMSIS Core(M) Version definitions + * @version V5.0.3 + * @date 24. June 2019 + ******************************************************************************/ +/* + * Copyright (c) 2009-2019 ARM Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CMSIS_VERSION_H +#define __CMSIS_VERSION_H + +/* CMSIS Version definitions */ +#define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ +#define __CM_CMSIS_VERSION_SUB ( 3U) /*!< [15:0] CMSIS Core(M) sub version */ +#define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ + __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ +#endif + diff --git a/panda/board/inc/core_cm3.h b/panda/board/inc/core_cm3.h index b4ac4c7b05a799..0918c5eb4c827b 100644 --- a/panda/board/inc/core_cm3.h +++ b/panda/board/inc/core_cm3.h @@ -1,40 +1,30 @@ /**************************************************************************//** * @file core_cm3.h * @brief CMSIS Cortex-M3 Core Peripheral Access Layer Header File - * @version V4.30 - * @date 20. October 2015 + * @version V5.1.0 + * @date 13. March 2019 ******************************************************************************/ -/* Copyright (c) 2009 - 2015 ARM LIMITED - - All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of ARM nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - * - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------------*/ - +/* + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #if defined ( __ICCARM__ ) - #pragma system_include /* treat file as system include file for MISRA check */ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) #pragma clang system_header /* treat file as system include file */ #endif @@ -70,53 +60,15 @@ @{ */ +#include "cmsis_version.h" + /* CMSIS CM3 definitions */ -#define __CM3_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ -#define __CM3_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ +#define __CM3_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM3_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ #define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16U) | \ - __CM3_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ - -#define __CORTEX_M (0x03U) /*!< Cortex-M Core */ - - -#if defined ( __CC_ARM ) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline - -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline - -#elif defined ( __GNUC__ ) - #define __ASM __asm /*!< asm keyword for GNU Compiler */ - #define __INLINE inline /*!< inline keyword for GNU Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __ICCARM__ ) - #define __ASM __asm /*!< asm keyword for IAR Compiler */ - #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ - #define __STATIC_INLINE static inline - -#elif defined ( __TMS470__ ) - #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __TASKING__ ) - #define __ASM __asm /*!< asm keyword for TASKING Compiler */ - #define __INLINE inline /*!< inline keyword for TASKING Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __CSMC__ ) - #define __packed - #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ - #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ - #define __STATIC_INLINE static inline + __CM3_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ -#else - #error Unknown compiler -#endif +#define __CORTEX_M (3U) /*!< Cortex-M Core */ /** __FPU_USED indicates whether an FPU is used or not. This core does not support an FPU at all @@ -128,8 +80,8 @@ #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #endif -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #if defined __ARM_PCS_VFP +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #endif @@ -143,7 +95,7 @@ #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #endif -#elif defined ( __TMS470__ ) +#elif defined ( __TI_ARM__ ) #if defined __TI_VFP_SUPPORT__ #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #endif @@ -160,8 +112,8 @@ #endif -#include "core_cmInstr.h" /* Core Instruction Access */ -#include "core_cmFunc.h" /* Core Function Access */ +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + #ifdef __cplusplus } @@ -191,7 +143,7 @@ #endif #ifndef __NVIC_PRIO_BITS - #define __NVIC_PRIO_BITS 4U + #define __NVIC_PRIO_BITS 3U #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" #endif @@ -308,9 +260,11 @@ typedef union struct { uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ - uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ - uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ - uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t _reserved0:1; /*!< bit: 9 Reserved */ + uint32_t ICI_IT_1:6; /*!< bit: 10..15 ICI/IT part 1 */ + uint32_t _reserved1:8; /*!< bit: 16..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit */ + uint32_t ICI_IT_2:2; /*!< bit: 25..26 ICI/IT part 2 */ uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ uint32_t C:1; /*!< bit: 29 Carry condition code flag */ @@ -336,12 +290,15 @@ typedef union #define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ #define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ -#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ -#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ +#define xPSR_ICI_IT_2_Pos 25U /*!< xPSR: ICI/IT part 2 Position */ +#define xPSR_ICI_IT_2_Msk (3UL << xPSR_ICI_IT_2_Pos) /*!< xPSR: ICI/IT part 2 Mask */ #define xPSR_T_Pos 24U /*!< xPSR: T Position */ #define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ +#define xPSR_ICI_IT_1_Pos 10U /*!< xPSR: ICI/IT part 1 Position */ +#define xPSR_ICI_IT_1_Msk (0x3FUL << xPSR_ICI_IT_1_Pos) /*!< xPSR: ICI/IT part 1 Mask */ + #define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ #define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ @@ -385,7 +342,7 @@ typedef struct __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ uint32_t RESERVED0[24U]; __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ - uint32_t RSERVED1[24U]; + uint32_t RESERVED1[24U]; __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ uint32_t RESERVED2[24U]; __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ @@ -487,7 +444,7 @@ typedef struct #define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ /* SCB Vector Table Offset Register Definitions */ -#if (__CM3_REV < 0x0201U) /* core r2p1 */ +#if defined (__CM3_REV) && (__CM3_REV < 0x0201U) /* core r2p1 */ #define SCB_VTOR_TBLBASE_Pos 29U /*!< SCB VTOR: TBLBASE Position */ #define SCB_VTOR_TBLBASE_Msk (1UL << SCB_VTOR_TBLBASE_Pos) /*!< SCB VTOR: TBLBASE Mask */ @@ -602,6 +559,60 @@ typedef struct #define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ #define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + /* SCB Hard Fault Status Register Definitions */ #define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ #define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ @@ -645,7 +656,7 @@ typedef struct { uint32_t RESERVED0[1U]; __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ -#if ((defined __CM3_REV) && (__CM3_REV >= 0x200U)) +#if defined (__CM3_REV) && (__CM3_REV >= 0x200U) __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ #else uint32_t RESERVED1[1U]; @@ -657,6 +668,12 @@ typedef struct #define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ /* Auxiliary Control Register Definitions */ +#if defined (__CM3_REV) && (__CM3_REV >= 0x200U) +#define SCnSCB_ACTLR_DISOOFP_Pos 9U /*!< ACTLR: DISOOFP Position */ +#define SCnSCB_ACTLR_DISOOFP_Msk (1UL << SCnSCB_ACTLR_DISOOFP_Pos) /*!< ACTLR: DISOOFP Mask */ + +#define SCnSCB_ACTLR_DISFPCA_Pos 8U /*!< ACTLR: DISFPCA Position */ +#define SCnSCB_ACTLR_DISFPCA_Msk (1UL << SCnSCB_ACTLR_DISFPCA_Pos) /*!< ACTLR: DISFPCA Mask */ #define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ #define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ @@ -666,6 +683,7 @@ typedef struct #define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ #define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ +#endif /*@} end of group CMSIS_SCnotSCB */ @@ -746,10 +764,7 @@ typedef struct __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ uint32_t RESERVED2[15U]; __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ - uint32_t RESERVED3[29U]; - __OM uint32_t IWR; /*!< Offset: 0xEF8 ( /W) ITM Integration Write Register */ - __IM uint32_t IRR; /*!< Offset: 0xEFC (R/ ) ITM Integration Read Register */ - __IOM uint32_t IMCR; /*!< Offset: 0xF00 (R/W) ITM Integration Mode Control Register */ + uint32_t RESERVED3[32U]; uint32_t RESERVED4[43U]; __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ @@ -770,7 +785,7 @@ typedef struct /* ITM Trace Privilege Register Definitions */ #define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ -#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ /* ITM Trace Control Register Definitions */ #define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ @@ -800,18 +815,6 @@ typedef struct #define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ #define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ -/* ITM Integration Write Register Definitions */ -#define ITM_IWR_ATVALIDM_Pos 0U /*!< ITM IWR: ATVALIDM Position */ -#define ITM_IWR_ATVALIDM_Msk (1UL /*<< ITM_IWR_ATVALIDM_Pos*/) /*!< ITM IWR: ATVALIDM Mask */ - -/* ITM Integration Read Register Definitions */ -#define ITM_IRR_ATREADYM_Pos 0U /*!< ITM IRR: ATREADYM Position */ -#define ITM_IRR_ATREADYM_Msk (1UL /*<< ITM_IRR_ATREADYM_Pos*/) /*!< ITM IRR: ATREADYM Mask */ - -/* ITM Integration Mode Control Register Definitions */ -#define ITM_IMCR_INTEGRATION_Pos 0U /*!< ITM IMCR: INTEGRATION Position */ -#define ITM_IMCR_INTEGRATION_Msk (1UL /*<< ITM_IMCR_INTEGRATION_Pos*/) /*!< ITM IMCR: INTEGRATION Mask */ - /* ITM Lock Status Register Definitions */ #define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ #define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ @@ -984,7 +987,7 @@ typedef struct */ typedef struct { - __IOM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ uint32_t RESERVED0[2U]; __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ @@ -995,7 +998,7 @@ typedef struct __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ uint32_t RESERVED3[759U]; - __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER */ + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ uint32_t RESERVED4[1U]; @@ -1044,13 +1047,13 @@ typedef struct /* TPI Integration ETM Data Register Definitions (FIFO0) */ #define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ -#define TPI_FIFO0_ITM_ATVALID_Msk (0x3UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x1UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ #define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ #define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ #define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ -#define TPI_FIFO0_ETM_ATVALID_Msk (0x3UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x1UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ #define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ #define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ @@ -1065,18 +1068,21 @@ typedef struct #define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ /* TPI ITATBCTR2 Register Definitions */ -#define TPI_ITATBCTR2_ATREADY_Pos 0U /*!< TPI ITATBCTR2: ATREADY Position */ -#define TPI_ITATBCTR2_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY_Pos*/) /*!< TPI ITATBCTR2: ATREADY Mask */ +#define TPI_ITATBCTR2_ATREADY2_Pos 0U /*!< TPI ITATBCTR2: ATREADY2 Position */ +#define TPI_ITATBCTR2_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2_Pos*/) /*!< TPI ITATBCTR2: ATREADY2 Mask */ + +#define TPI_ITATBCTR2_ATREADY1_Pos 0U /*!< TPI ITATBCTR2: ATREADY1 Position */ +#define TPI_ITATBCTR2_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1_Pos*/) /*!< TPI ITATBCTR2: ATREADY1 Mask */ /* TPI Integration ITM Data Register Definitions (FIFO1) */ #define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ -#define TPI_FIFO1_ITM_ATVALID_Msk (0x3UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x1UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ #define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ #define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ #define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ -#define TPI_FIFO1_ETM_ATVALID_Msk (0x3UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x1UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ #define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ #define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ @@ -1091,12 +1097,15 @@ typedef struct #define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ /* TPI ITATBCTR0 Register Definitions */ -#define TPI_ITATBCTR0_ATREADY_Pos 0U /*!< TPI ITATBCTR0: ATREADY Position */ -#define TPI_ITATBCTR0_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY_Pos*/) /*!< TPI ITATBCTR0: ATREADY Mask */ +#define TPI_ITATBCTR0_ATREADY2_Pos 0U /*!< TPI ITATBCTR0: ATREADY2 Position */ +#define TPI_ITATBCTR0_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2_Pos*/) /*!< TPI ITATBCTR0: ATREADY2 Mask */ + +#define TPI_ITATBCTR0_ATREADY1_Pos 0U /*!< TPI ITATBCTR0: ATREADY1 Position */ +#define TPI_ITATBCTR0_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1_Pos*/) /*!< TPI ITATBCTR0: ATREADY1 Mask */ /* TPI Integration Mode Control Register Definitions */ #define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ -#define TPI_ITCTRL_Mode_Msk (0x1UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ /* TPI DEVID Register Definitions */ #define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ @@ -1118,16 +1127,16 @@ typedef struct #define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ /* TPI DEVTYPE Register Definitions */ -#define TPI_DEVTYPE_MajorType_Pos 4U /*!< TPI DEVTYPE: MajorType Position */ -#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ - -#define TPI_DEVTYPE_SubType_Pos 0U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ #define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + /*@}*/ /* end of group CMSIS_TPI */ -#if (__MPU_PRESENT == 1U) +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) /** \ingroup CMSIS_core_register \defgroup CMSIS_MPU Memory Protection Unit (MPU) @@ -1153,6 +1162,8 @@ typedef struct __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ } MPU_Type; +#define MPU_TYPE_RALIASES 4U + /* MPU Type Register Definitions */ #define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ #define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ @@ -1337,18 +1348,18 @@ typedef struct /** \brief Mask and shift a bit field value for use in a register bit range. \param[in] field Name of the register bit field. - \param[in] value Value of the bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. \return Masked and shifted value. */ -#define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk) +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) /** \brief Mask and shift a register value to extract a bit filed value. \param[in] field Name of the register bit field. - \param[in] value Value of register. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. \return Masked and shifted bit field value. */ -#define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos) +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) /*@} end of group CMSIS_core_bitfield */ @@ -1360,7 +1371,7 @@ typedef struct @{ */ -/* Memory mapping of Cortex-M3 Hardware */ +/* Memory mapping of Core Hardware */ #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ @@ -1379,7 +1390,7 @@ typedef struct #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ -#if (__MPU_PRESENT == 1U) +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ #endif @@ -1410,6 +1421,45 @@ typedef struct @{ */ +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + /** \brief Set Priority Grouping \details Sets the priority grouping field using the required unlock sequence. @@ -1419,7 +1469,7 @@ typedef struct priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. \param [in] PriorityGroup Priority grouping field. */ -__STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) { uint32_t reg_value; uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ @@ -1428,7 +1478,7 @@ __STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ reg_value = (reg_value | ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | - (PriorityGroupTmp << 8U) ); /* Insert write key and priorty group */ + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ SCB->AIRCR = reg_value; } @@ -1438,121 +1488,180 @@ __STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) \details Reads the priority grouping field from the NVIC Interrupt Controller. \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). */ -__STATIC_INLINE uint32_t NVIC_GetPriorityGrouping(void) +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) { return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); } /** - \brief Enable External Interrupt - \details Enables a device-specific interrupt in the NVIC interrupt controller. - \param [in] IRQn External interrupt number. Value cannot be negative. + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. */ -__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) { - NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } } /** - \brief Disable External Interrupt - \details Disables a device-specific interrupt in the NVIC interrupt controller. - \param [in] IRQn External interrupt number. Value cannot be negative. + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. */ -__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) { - NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } } /** \brief Get Pending Interrupt - \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. - \param [in] IRQn Interrupt number. + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. \return 0 Interrupt status is not pending. \return 1 Interrupt status is pending. + \note IRQn must not be negative. */ -__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) { - return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } } /** \brief Set Pending Interrupt - \details Sets the pending bit of an external interrupt. - \param [in] IRQn Interrupt number. Value cannot be negative. + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. */ -__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) { - NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } } /** \brief Clear Pending Interrupt - \details Clears the pending bit of an external interrupt. - \param [in] IRQn External interrupt number. Value cannot be negative. + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. */ -__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) { - NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } } /** \brief Get Active Interrupt - \details Reads the active register in NVIC and returns the active bit. - \param [in] IRQn Interrupt number. + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. \return 0 Interrupt status is not active. \return 1 Interrupt status is active. + \note IRQn must not be negative. */ -__STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn) +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) { - return((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } } /** \brief Set Interrupt Priority - \details Sets the priority of an interrupt. - \note The priority cannot be set for every core interrupt. + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. \param [in] IRQn Interrupt number. \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. */ -__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) { - if ((int32_t)(IRQn) < 0) + if ((int32_t)(IRQn) >= 0) { - SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); } else { - NVIC->IP[((uint32_t)(int32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); } } /** \brief Get Interrupt Priority - \details Reads the priority of an interrupt. - The interrupt number can be positive to specify an external (device specific) interrupt, - or negative to specify an internal (core) interrupt. + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. \param [in] IRQn Interrupt number. \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. */ -__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) { - if ((int32_t)(IRQn) < 0) + if ((int32_t)(IRQn) >= 0) { - return(((uint32_t)SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + return(((uint32_t)NVIC->IP[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); } else { - return(((uint32_t)NVIC->IP[((uint32_t)(int32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + return(((uint32_t)SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); } } @@ -1609,11 +1718,43 @@ __STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGr } +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t vectors = (uint32_t )SCB->VTOR; + (* (int *) (vectors + ((int32_t)IRQn + NVIC_USER_IRQ_OFFSET) * 4)) = vector; + /* ARM Application Note 321 states that the M3 does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t vectors = (uint32_t )SCB->VTOR; + return (uint32_t)(* (int *) (vectors + ((int32_t)IRQn + NVIC_USER_IRQ_OFFSET) * 4)); +} + + /** \brief System Reset \details Initiates a system reset request to reset the MCU. */ -__STATIC_INLINE void NVIC_SystemReset(void) +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) { __DSB(); /* Ensure all outstanding memory accesses included buffered write are completed before reset */ @@ -1630,6 +1771,39 @@ __STATIC_INLINE void NVIC_SystemReset(void) /*@} end of CMSIS_Core_NVICFunctions */ +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv7.h" + +#endif + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + /* ################################## SysTick function ############################################ */ @@ -1640,7 +1814,7 @@ __STATIC_INLINE void NVIC_SystemReset(void) @{ */ -#if (__Vendor_SysTickConfig == 0U) +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) /** \brief System Tick Configuration @@ -1683,8 +1857,8 @@ __STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) @{ */ -extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ -#define ITM_RXBUFFER_EMPTY 0x5AA55AA5U /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ /** @@ -1761,3 +1935,4 @@ __STATIC_INLINE int32_t ITM_CheckChar (void) #endif /* __CORE_CM3_H_DEPENDANT */ #endif /* __CMSIS_GENERIC */ + diff --git a/panda/board/inc/core_cm4.h b/panda/board/inc/core_cm4.h index dc840ebf222138..0d40081a385dc1 100644 --- a/panda/board/inc/core_cm4.h +++ b/panda/board/inc/core_cm4.h @@ -1,40 +1,30 @@ /**************************************************************************//** * @file core_cm4.h * @brief CMSIS Cortex-M4 Core Peripheral Access Layer Header File - * @version V4.30 - * @date 20. October 2015 + * @version V5.1.0 + * @date 13. March 2019 ******************************************************************************/ -/* Copyright (c) 2009 - 2015 ARM LIMITED - - All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of ARM nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - * - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------------*/ - +/* + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #if defined ( __ICCARM__ ) - #pragma system_include /* treat file as system include file for MISRA check */ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) #pragma clang system_header /* treat file as system include file */ #endif @@ -70,60 +60,22 @@ @{ */ -/* CMSIS CM4 definitions */ -#define __CM4_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ -#define __CM4_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ -#define __CM4_CMSIS_VERSION ((__CM4_CMSIS_VERSION_MAIN << 16U) | \ - __CM4_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ - -#define __CORTEX_M (0x04U) /*!< Cortex-M Core */ - - -#if defined ( __CC_ARM ) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline - -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline - -#elif defined ( __GNUC__ ) - #define __ASM __asm /*!< asm keyword for GNU Compiler */ - #define __INLINE inline /*!< inline keyword for GNU Compiler */ - #define __STATIC_INLINE static inline +#include "cmsis_version.h" -#elif defined ( __ICCARM__ ) - #define __ASM __asm /*!< asm keyword for IAR Compiler */ - #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ - #define __STATIC_INLINE static inline - -#elif defined ( __TMS470__ ) - #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __TASKING__ ) - #define __ASM __asm /*!< asm keyword for TASKING Compiler */ - #define __INLINE inline /*!< inline keyword for TASKING Compiler */ - #define __STATIC_INLINE static inline +/* CMSIS CM4 definitions */ +#define __CM4_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM4_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM4_CMSIS_VERSION ((__CM4_CMSIS_VERSION_MAIN << 16U) | \ + __CM4_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ -#elif defined ( __CSMC__ ) - #define __packed - #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ - #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ - #define __STATIC_INLINE static inline - -#else - #error Unknown compiler -#endif +#define __CORTEX_M (4U) /*!< Cortex-M Core */ /** __FPU_USED indicates whether an FPU is used or not. For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. */ #if defined ( __CC_ARM ) #if defined __TARGET_FPU_VFP - #if (__FPU_PRESENT == 1U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" @@ -133,9 +85,9 @@ #define __FPU_USED 0U #endif -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #if defined __ARM_PCS_VFP - #if (__FPU_PRESENT == 1) +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" @@ -147,7 +99,7 @@ #elif defined ( __GNUC__ ) #if defined (__VFP_FP__) && !defined(__SOFTFP__) - #if (__FPU_PRESENT == 1U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" @@ -159,7 +111,7 @@ #elif defined ( __ICCARM__ ) #if defined __ARMVFP__ - #if (__FPU_PRESENT == 1U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" @@ -169,9 +121,9 @@ #define __FPU_USED 0U #endif -#elif defined ( __TMS470__ ) +#elif defined ( __TI_ARM__ ) #if defined __TI_VFP_SUPPORT__ - #if (__FPU_PRESENT == 1U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" @@ -183,7 +135,7 @@ #elif defined ( __TASKING__ ) #if defined __FPU_VFP__ - #if (__FPU_PRESENT == 1U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" @@ -195,7 +147,7 @@ #elif defined ( __CSMC__ ) #if ( __CSMC__ & 0x400U) - #if (__FPU_PRESENT == 1U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" @@ -207,9 +159,8 @@ #endif -#include "core_cmInstr.h" /* Core Instruction Access */ -#include "core_cmFunc.h" /* Core Function Access */ -#include "core_cmSimd.h" /* Compiler specific SIMD Intrinsics */ +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + #ifdef __cplusplus } @@ -244,7 +195,7 @@ #endif #ifndef __NVIC_PRIO_BITS - #define __NVIC_PRIO_BITS 4U + #define __NVIC_PRIO_BITS 3U #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" #endif @@ -367,11 +318,12 @@ typedef union struct { uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ - uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t _reserved0:1; /*!< bit: 9 Reserved */ + uint32_t ICI_IT_1:6; /*!< bit: 10..15 ICI/IT part 1 */ uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ - uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ - uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t T:1; /*!< bit: 24 Thumb bit */ + uint32_t ICI_IT_2:2; /*!< bit: 25..26 ICI/IT part 2 */ uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ uint32_t C:1; /*!< bit: 29 Carry condition code flag */ @@ -397,8 +349,8 @@ typedef union #define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ #define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ -#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ -#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ +#define xPSR_ICI_IT_2_Pos 25U /*!< xPSR: ICI/IT part 2 Position */ +#define xPSR_ICI_IT_2_Msk (3UL << xPSR_ICI_IT_2_Pos) /*!< xPSR: ICI/IT part 2 Mask */ #define xPSR_T_Pos 24U /*!< xPSR: T Position */ #define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ @@ -406,6 +358,9 @@ typedef union #define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ #define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ +#define xPSR_ICI_IT_1_Pos 10U /*!< xPSR: ICI/IT part 1 Position */ +#define xPSR_ICI_IT_1_Msk (0x3FUL << xPSR_ICI_IT_1_Pos) /*!< xPSR: ICI/IT part 1 Mask */ + #define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ #define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ @@ -453,7 +408,7 @@ typedef struct __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ uint32_t RESERVED0[24U]; __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ - uint32_t RSERVED1[24U]; + uint32_t RESERVED1[24U]; __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ uint32_t RESERVED2[24U]; __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ @@ -662,6 +617,66 @@ typedef struct #define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ #define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + /* SCB Hard Fault Status Register Definitions */ #define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ #define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ @@ -807,10 +822,7 @@ typedef struct __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ uint32_t RESERVED2[15U]; __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ - uint32_t RESERVED3[29U]; - __OM uint32_t IWR; /*!< Offset: 0xEF8 ( /W) ITM Integration Write Register */ - __IM uint32_t IRR; /*!< Offset: 0xEFC (R/ ) ITM Integration Read Register */ - __IOM uint32_t IMCR; /*!< Offset: 0xF00 (R/W) ITM Integration Mode Control Register */ + uint32_t RESERVED3[32U]; uint32_t RESERVED4[43U]; __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ @@ -831,7 +843,7 @@ typedef struct /* ITM Trace Privilege Register Definitions */ #define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ -#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ /* ITM Trace Control Register Definitions */ #define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ @@ -861,18 +873,6 @@ typedef struct #define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ #define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ -/* ITM Integration Write Register Definitions */ -#define ITM_IWR_ATVALIDM_Pos 0U /*!< ITM IWR: ATVALIDM Position */ -#define ITM_IWR_ATVALIDM_Msk (1UL /*<< ITM_IWR_ATVALIDM_Pos*/) /*!< ITM IWR: ATVALIDM Mask */ - -/* ITM Integration Read Register Definitions */ -#define ITM_IRR_ATREADYM_Pos 0U /*!< ITM IRR: ATREADYM Position */ -#define ITM_IRR_ATREADYM_Msk (1UL /*<< ITM_IRR_ATREADYM_Pos*/) /*!< ITM IRR: ATREADYM Mask */ - -/* ITM Integration Mode Control Register Definitions */ -#define ITM_IMCR_INTEGRATION_Pos 0U /*!< ITM IMCR: INTEGRATION Position */ -#define ITM_IMCR_INTEGRATION_Msk (1UL /*<< ITM_IMCR_INTEGRATION_Pos*/) /*!< ITM IMCR: INTEGRATION Mask */ - /* ITM Lock Status Register Definitions */ #define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ #define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ @@ -1045,7 +1045,7 @@ typedef struct */ typedef struct { - __IOM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ uint32_t RESERVED0[2U]; __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ @@ -1056,7 +1056,7 @@ typedef struct __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ uint32_t RESERVED3[759U]; - __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER */ + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ uint32_t RESERVED4[1U]; @@ -1105,13 +1105,13 @@ typedef struct /* TPI Integration ETM Data Register Definitions (FIFO0) */ #define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ -#define TPI_FIFO0_ITM_ATVALID_Msk (0x3UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x1UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ #define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ #define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ #define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ -#define TPI_FIFO0_ETM_ATVALID_Msk (0x3UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x1UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ #define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ #define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ @@ -1126,18 +1126,21 @@ typedef struct #define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ /* TPI ITATBCTR2 Register Definitions */ -#define TPI_ITATBCTR2_ATREADY_Pos 0U /*!< TPI ITATBCTR2: ATREADY Position */ -#define TPI_ITATBCTR2_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY_Pos*/) /*!< TPI ITATBCTR2: ATREADY Mask */ +#define TPI_ITATBCTR2_ATREADY2_Pos 0U /*!< TPI ITATBCTR2: ATREADY2 Position */ +#define TPI_ITATBCTR2_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2_Pos*/) /*!< TPI ITATBCTR2: ATREADY2 Mask */ + +#define TPI_ITATBCTR2_ATREADY1_Pos 0U /*!< TPI ITATBCTR2: ATREADY1 Position */ +#define TPI_ITATBCTR2_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1_Pos*/) /*!< TPI ITATBCTR2: ATREADY1 Mask */ /* TPI Integration ITM Data Register Definitions (FIFO1) */ #define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ -#define TPI_FIFO1_ITM_ATVALID_Msk (0x3UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x1UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ #define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ #define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ #define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ -#define TPI_FIFO1_ETM_ATVALID_Msk (0x3UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x1UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ #define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ #define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ @@ -1152,12 +1155,15 @@ typedef struct #define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ /* TPI ITATBCTR0 Register Definitions */ -#define TPI_ITATBCTR0_ATREADY_Pos 0U /*!< TPI ITATBCTR0: ATREADY Position */ -#define TPI_ITATBCTR0_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY_Pos*/) /*!< TPI ITATBCTR0: ATREADY Mask */ +#define TPI_ITATBCTR0_ATREADY2_Pos 0U /*!< TPI ITATBCTR0: ATREADY2 Position */ +#define TPI_ITATBCTR0_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2_Pos*/) /*!< TPI ITATBCTR0: ATREADY2 Mask */ + +#define TPI_ITATBCTR0_ATREADY1_Pos 0U /*!< TPI ITATBCTR0: ATREADY1 Position */ +#define TPI_ITATBCTR0_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1_Pos*/) /*!< TPI ITATBCTR0: ATREADY1 Mask */ /* TPI Integration Mode Control Register Definitions */ #define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ -#define TPI_ITCTRL_Mode_Msk (0x1UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ /* TPI DEVID Register Definitions */ #define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ @@ -1179,16 +1185,16 @@ typedef struct #define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ /* TPI DEVTYPE Register Definitions */ -#define TPI_DEVTYPE_MajorType_Pos 4U /*!< TPI DEVTYPE: MajorType Position */ -#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ - -#define TPI_DEVTYPE_SubType_Pos 0U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ #define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + /*@}*/ /* end of group CMSIS_TPI */ -#if (__MPU_PRESENT == 1U) +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) /** \ingroup CMSIS_core_register \defgroup CMSIS_MPU Memory Protection Unit (MPU) @@ -1214,6 +1220,8 @@ typedef struct __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ } MPU_Type; +#define MPU_TYPE_RALIASES 4U + /* MPU Type Register Definitions */ #define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ #define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ @@ -1280,10 +1288,9 @@ typedef struct #define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ /*@} end of group CMSIS_MPU */ -#endif +#endif /* defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) */ -#if (__FPU_PRESENT == 1U) /** \ingroup CMSIS_core_register \defgroup CMSIS_FPU Floating Point Unit (FPU) @@ -1302,6 +1309,7 @@ typedef struct __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and FP Feature Register 0 */ __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and FP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and FP Feature Register 2 */ } FPU_Type; /* Floating-Point Context Control Register Definitions */ @@ -1387,8 +1395,12 @@ typedef struct #define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ #define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ +/* Media and FP Feature Register 2 Definitions */ + +#define FPU_MVFR2_VFP_Misc_Pos 4U /*!< MVFR2: VFP Misc bits Position */ +#define FPU_MVFR2_VFP_Misc_Msk (0xFUL << FPU_MVFR2_VFP_Misc_Pos) /*!< MVFR2: VFP Misc bits Mask */ + /*@} end of group CMSIS_FPU */ -#endif /** @@ -1506,18 +1518,18 @@ typedef struct /** \brief Mask and shift a bit field value for use in a register bit range. \param[in] field Name of the register bit field. - \param[in] value Value of the bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. \return Masked and shifted value. */ -#define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk) +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) /** \brief Mask and shift a register value to extract a bit filed value. \param[in] field Name of the register bit field. - \param[in] value Value of register. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. \return Masked and shifted bit field value. */ -#define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos) +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) /*@} end of group CMSIS_core_bitfield */ @@ -1529,7 +1541,7 @@ typedef struct @{ */ -/* Memory mapping of Cortex-M4 Hardware */ +/* Memory mapping of Core Hardware */ #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ @@ -1548,15 +1560,13 @@ typedef struct #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ -#if (__MPU_PRESENT == 1U) +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ #endif -#if (__FPU_PRESENT == 1U) - #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ - #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ -#endif +#define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ +#define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ /*@} */ @@ -1584,6 +1594,48 @@ typedef struct @{ */ +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ +#define EXC_RETURN_HANDLER_FPU (0xFFFFFFE1UL) /* return to Handler mode, uses MSP after return, restore floating-point state */ +#define EXC_RETURN_THREAD_MSP_FPU (0xFFFFFFE9UL) /* return to Thread mode, uses MSP after return, restore floating-point state */ +#define EXC_RETURN_THREAD_PSP_FPU (0xFFFFFFEDUL) /* return to Thread mode, uses PSP after return, restore floating-point state */ + + /** \brief Set Priority Grouping \details Sets the priority grouping field using the required unlock sequence. @@ -1593,7 +1645,7 @@ typedef struct priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. \param [in] PriorityGroup Priority grouping field. */ -__STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) { uint32_t reg_value; uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ @@ -1602,7 +1654,7 @@ __STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ reg_value = (reg_value | ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | - (PriorityGroupTmp << 8U) ); /* Insert write key and priorty group */ + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ SCB->AIRCR = reg_value; } @@ -1612,121 +1664,180 @@ __STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) \details Reads the priority grouping field from the NVIC Interrupt Controller. \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). */ -__STATIC_INLINE uint32_t NVIC_GetPriorityGrouping(void) +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) { return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); } /** - \brief Enable External Interrupt - \details Enables a device-specific interrupt in the NVIC interrupt controller. - \param [in] IRQn External interrupt number. Value cannot be negative. + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. */ -__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) { - NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } } /** - \brief Disable External Interrupt - \details Disables a device-specific interrupt in the NVIC interrupt controller. - \param [in] IRQn External interrupt number. Value cannot be negative. + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. */ -__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) { - NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } } /** \brief Get Pending Interrupt - \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. - \param [in] IRQn Interrupt number. + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. \return 0 Interrupt status is not pending. \return 1 Interrupt status is pending. + \note IRQn must not be negative. */ -__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) { - return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } } /** \brief Set Pending Interrupt - \details Sets the pending bit of an external interrupt. - \param [in] IRQn Interrupt number. Value cannot be negative. + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. */ -__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) { - NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } } /** \brief Clear Pending Interrupt - \details Clears the pending bit of an external interrupt. - \param [in] IRQn External interrupt number. Value cannot be negative. + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. */ -__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) { - NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } } /** \brief Get Active Interrupt - \details Reads the active register in NVIC and returns the active bit. - \param [in] IRQn Interrupt number. + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. \return 0 Interrupt status is not active. \return 1 Interrupt status is active. + \note IRQn must not be negative. */ -__STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn) +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) { - return((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } } /** \brief Set Interrupt Priority - \details Sets the priority of an interrupt. - \note The priority cannot be set for every core interrupt. + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. \param [in] IRQn Interrupt number. \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. */ -__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) { - if ((int32_t)(IRQn) < 0) + if ((int32_t)(IRQn) >= 0) { - SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); } else { - NVIC->IP[((uint32_t)(int32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); } } /** \brief Get Interrupt Priority - \details Reads the priority of an interrupt. - The interrupt number can be positive to specify an external (device specific) interrupt, - or negative to specify an internal (core) interrupt. + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. \param [in] IRQn Interrupt number. \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. */ -__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) { - if ((int32_t)(IRQn) < 0) + if ((int32_t)(IRQn) >= 0) { - return(((uint32_t)SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + return(((uint32_t)NVIC->IP[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); } else { - return(((uint32_t)NVIC->IP[((uint32_t)(int32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + return(((uint32_t)SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); } } @@ -1783,11 +1894,43 @@ __STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGr } +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t vectors = (uint32_t )SCB->VTOR; + (* (int *) (vectors + ((int32_t)IRQn + NVIC_USER_IRQ_OFFSET) * 4)) = vector; + /* ARM Application Note 321 states that the M4 does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t vectors = (uint32_t )SCB->VTOR; + return (uint32_t)(* (int *) (vectors + ((int32_t)IRQn + NVIC_USER_IRQ_OFFSET) * 4)); +} + + /** \brief System Reset \details Initiates a system reset request to reset the MCU. */ -__STATIC_INLINE void NVIC_SystemReset(void) +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) { __DSB(); /* Ensure all outstanding memory accesses included buffered write are completed before reset */ @@ -1805,6 +1948,50 @@ __STATIC_INLINE void NVIC_SystemReset(void) /*@} end of CMSIS_Core_NVICFunctions */ +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv7.h" + +#endif + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + /* ################################## SysTick function ############################################ */ /** @@ -1814,7 +2001,7 @@ __STATIC_INLINE void NVIC_SystemReset(void) @{ */ -#if (__Vendor_SysTickConfig == 0U) +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) /** \brief System Tick Configuration @@ -1857,8 +2044,8 @@ __STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) @{ */ -extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ -#define ITM_RXBUFFER_EMPTY 0x5AA55AA5U /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ /** @@ -1935,3 +2122,4 @@ __STATIC_INLINE int32_t ITM_CheckChar (void) #endif /* __CORE_CM4_H_DEPENDANT */ #endif /* __CMSIS_GENERIC */ + diff --git a/panda/board/inc/core_cmFunc.h b/panda/board/inc/core_cmFunc.h deleted file mode 100644 index 652a48af07a93d..00000000000000 --- a/panda/board/inc/core_cmFunc.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************//** - * @file core_cmFunc.h - * @brief CMSIS Cortex-M Core Function Access Header File - * @version V4.30 - * @date 20. October 2015 - ******************************************************************************/ -/* Copyright (c) 2009 - 2015 ARM LIMITED - - All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of ARM nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - * - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------------*/ - - -#if defined ( __ICCARM__ ) - #pragma system_include /* treat file as system include file for MISRA check */ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #pragma clang system_header /* treat file as system include file */ -#endif - -#ifndef __CORE_CMFUNC_H -#define __CORE_CMFUNC_H - - -/* ########################### Core Function Access ########################### */ -/** \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions - @{ -*/ - -/*------------------ RealView Compiler -----------------*/ -#if defined ( __CC_ARM ) - #include "cmsis_armcc.h" - -/*------------------ ARM Compiler V6 -------------------*/ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #include "cmsis_armcc_V6.h" - -/*------------------ GNU Compiler ----------------------*/ -#elif defined ( __GNUC__ ) - #include "cmsis_gcc.h" - -/*------------------ ICC Compiler ----------------------*/ -#elif defined ( __ICCARM__ ) - #include - -/*------------------ TI CCS Compiler -------------------*/ -#elif defined ( __TMS470__ ) - #include - -/*------------------ TASKING Compiler ------------------*/ -#elif defined ( __TASKING__ ) - /* - * The CMSIS functions have been implemented as intrinsics in the compiler. - * Please use "carm -?i" to get an up to date list of all intrinsics, - * Including the CMSIS ones. - */ - -/*------------------ COSMIC Compiler -------------------*/ -#elif defined ( __CSMC__ ) - #include - -#endif - -/*@} end of CMSIS_Core_RegAccFunctions */ - -#endif /* __CORE_CMFUNC_H */ diff --git a/panda/board/inc/core_cmInstr.h b/panda/board/inc/core_cmInstr.h deleted file mode 100644 index f474b0e6f362c7..00000000000000 --- a/panda/board/inc/core_cmInstr.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************//** - * @file core_cmInstr.h - * @brief CMSIS Cortex-M Core Instruction Access Header File - * @version V4.30 - * @date 20. October 2015 - ******************************************************************************/ -/* Copyright (c) 2009 - 2015 ARM LIMITED - - All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of ARM nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - * - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------------*/ - - -#if defined ( __ICCARM__ ) - #pragma system_include /* treat file as system include file for MISRA check */ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #pragma clang system_header /* treat file as system include file */ -#endif - -#ifndef __CORE_CMINSTR_H -#define __CORE_CMINSTR_H - - -/* ########################## Core Instruction Access ######################### */ -/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface - Access to dedicated instructions - @{ -*/ - -/*------------------ RealView Compiler -----------------*/ -#if defined ( __CC_ARM ) - #include "cmsis_armcc.h" - -/*------------------ ARM Compiler V6 -------------------*/ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #include "cmsis_armcc_V6.h" - -/*------------------ GNU Compiler ----------------------*/ -#elif defined ( __GNUC__ ) - #include "cmsis_gcc.h" - -/*------------------ ICC Compiler ----------------------*/ -#elif defined ( __ICCARM__ ) - #include - -/*------------------ TI CCS Compiler -------------------*/ -#elif defined ( __TMS470__ ) - #include - -/*------------------ TASKING Compiler ------------------*/ -#elif defined ( __TASKING__ ) - /* - * The CMSIS functions have been implemented as intrinsics in the compiler. - * Please use "carm -?i" to get an up to date list of all intrinsics, - * Including the CMSIS ones. - */ - -/*------------------ COSMIC Compiler -------------------*/ -#elif defined ( __CSMC__ ) - #include - -#endif - -/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ - -#endif /* __CORE_CMINSTR_H */ diff --git a/panda/board/inc/core_cmSimd.h b/panda/board/inc/core_cmSimd.h deleted file mode 100644 index 66bf5c2a725b6d..00000000000000 --- a/panda/board/inc/core_cmSimd.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************//** - * @file core_cmSimd.h - * @brief CMSIS Cortex-M SIMD Header File - * @version V4.30 - * @date 20. October 2015 - ******************************************************************************/ -/* Copyright (c) 2009 - 2015 ARM LIMITED - - All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of ARM nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - * - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------------*/ - - -#if defined ( __ICCARM__ ) - #pragma system_include /* treat file as system include file for MISRA check */ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #pragma clang system_header /* treat file as system include file */ -#endif - -#ifndef __CORE_CMSIMD_H -#define __CORE_CMSIMD_H - -#ifdef __cplusplus - extern "C" { -#endif - - -/* ################### Compiler specific Intrinsics ########################### */ -/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics - Access to dedicated SIMD instructions - @{ -*/ - -/*------------------ RealView Compiler -----------------*/ -#if defined ( __CC_ARM ) - #include "cmsis_armcc.h" - -/*------------------ ARM Compiler V6 -------------------*/ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #include "cmsis_armcc_V6.h" - -/*------------------ GNU Compiler ----------------------*/ -#elif defined ( __GNUC__ ) - #include "cmsis_gcc.h" - -/*------------------ ICC Compiler ----------------------*/ -#elif defined ( __ICCARM__ ) - #include - -/*------------------ TI CCS Compiler -------------------*/ -#elif defined ( __TMS470__ ) - #include - -/*------------------ TASKING Compiler ------------------*/ -#elif defined ( __TASKING__ ) - /* - * The CMSIS functions have been implemented as intrinsics in the compiler. - * Please use "carm -?i" to get an up to date list of all intrinsics, - * Including the CMSIS ones. - */ - -/*------------------ COSMIC Compiler -------------------*/ -#elif defined ( __CSMC__ ) - #include - -#endif - -/*@} end of group CMSIS_SIMD_intrinsics */ - - -#ifdef __cplusplus -} -#endif - -#endif /* __CORE_CMSIMD_H */ diff --git a/panda/board/inc/mpu_armv7.h b/panda/board/inc/mpu_armv7.h new file mode 100644 index 00000000000000..e72cc4623db517 --- /dev/null +++ b/panda/board/inc/mpu_armv7.h @@ -0,0 +1,273 @@ +/****************************************************************************** + * @file mpu_armv7.h + * @brief CMSIS MPU API for Armv7-M MPU + * @version V5.1.0 + * @date 08. March 2019 + ******************************************************************************/ +/* + * Copyright (c) 2017-2019 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef ARM_MPU_ARMV7_H +#define ARM_MPU_ARMV7_H + +#define ARM_MPU_REGION_SIZE_32B ((uint8_t)0x04U) ///!< MPU Region Size 32 Bytes +#define ARM_MPU_REGION_SIZE_64B ((uint8_t)0x05U) ///!< MPU Region Size 64 Bytes +#define ARM_MPU_REGION_SIZE_128B ((uint8_t)0x06U) ///!< MPU Region Size 128 Bytes +#define ARM_MPU_REGION_SIZE_256B ((uint8_t)0x07U) ///!< MPU Region Size 256 Bytes +#define ARM_MPU_REGION_SIZE_512B ((uint8_t)0x08U) ///!< MPU Region Size 512 Bytes +#define ARM_MPU_REGION_SIZE_1KB ((uint8_t)0x09U) ///!< MPU Region Size 1 KByte +#define ARM_MPU_REGION_SIZE_2KB ((uint8_t)0x0AU) ///!< MPU Region Size 2 KBytes +#define ARM_MPU_REGION_SIZE_4KB ((uint8_t)0x0BU) ///!< MPU Region Size 4 KBytes +#define ARM_MPU_REGION_SIZE_8KB ((uint8_t)0x0CU) ///!< MPU Region Size 8 KBytes +#define ARM_MPU_REGION_SIZE_16KB ((uint8_t)0x0DU) ///!< MPU Region Size 16 KBytes +#define ARM_MPU_REGION_SIZE_32KB ((uint8_t)0x0EU) ///!< MPU Region Size 32 KBytes +#define ARM_MPU_REGION_SIZE_64KB ((uint8_t)0x0FU) ///!< MPU Region Size 64 KBytes +#define ARM_MPU_REGION_SIZE_128KB ((uint8_t)0x10U) ///!< MPU Region Size 128 KBytes +#define ARM_MPU_REGION_SIZE_256KB ((uint8_t)0x11U) ///!< MPU Region Size 256 KBytes +#define ARM_MPU_REGION_SIZE_512KB ((uint8_t)0x12U) ///!< MPU Region Size 512 KBytes +#define ARM_MPU_REGION_SIZE_1MB ((uint8_t)0x13U) ///!< MPU Region Size 1 MByte +#define ARM_MPU_REGION_SIZE_2MB ((uint8_t)0x14U) ///!< MPU Region Size 2 MBytes +#define ARM_MPU_REGION_SIZE_4MB ((uint8_t)0x15U) ///!< MPU Region Size 4 MBytes +#define ARM_MPU_REGION_SIZE_8MB ((uint8_t)0x16U) ///!< MPU Region Size 8 MBytes +#define ARM_MPU_REGION_SIZE_16MB ((uint8_t)0x17U) ///!< MPU Region Size 16 MBytes +#define ARM_MPU_REGION_SIZE_32MB ((uint8_t)0x18U) ///!< MPU Region Size 32 MBytes +#define ARM_MPU_REGION_SIZE_64MB ((uint8_t)0x19U) ///!< MPU Region Size 64 MBytes +#define ARM_MPU_REGION_SIZE_128MB ((uint8_t)0x1AU) ///!< MPU Region Size 128 MBytes +#define ARM_MPU_REGION_SIZE_256MB ((uint8_t)0x1BU) ///!< MPU Region Size 256 MBytes +#define ARM_MPU_REGION_SIZE_512MB ((uint8_t)0x1CU) ///!< MPU Region Size 512 MBytes +#define ARM_MPU_REGION_SIZE_1GB ((uint8_t)0x1DU) ///!< MPU Region Size 1 GByte +#define ARM_MPU_REGION_SIZE_2GB ((uint8_t)0x1EU) ///!< MPU Region Size 2 GBytes +#define ARM_MPU_REGION_SIZE_4GB ((uint8_t)0x1FU) ///!< MPU Region Size 4 GBytes + +#define ARM_MPU_AP_NONE 0U ///!< MPU Access Permission no access +#define ARM_MPU_AP_PRIV 1U ///!< MPU Access Permission privileged access only +#define ARM_MPU_AP_URO 2U ///!< MPU Access Permission unprivileged access read-only +#define ARM_MPU_AP_FULL 3U ///!< MPU Access Permission full access +#define ARM_MPU_AP_PRO 5U ///!< MPU Access Permission privileged access read-only +#define ARM_MPU_AP_RO 6U ///!< MPU Access Permission read-only access + +/** MPU Region Base Address Register Value +* +* \param Region The region to be configured, number 0 to 15. +* \param BaseAddress The base address for the region. +*/ +#define ARM_MPU_RBAR(Region, BaseAddress) \ + (((BaseAddress) & MPU_RBAR_ADDR_Msk) | \ + ((Region) & MPU_RBAR_REGION_Msk) | \ + (MPU_RBAR_VALID_Msk)) + +/** +* MPU Memory Access Attributes +* +* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral. +* \param IsShareable Region is shareable between multiple bus masters. +* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache. +* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy. +*/ +#define ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable) \ + ((((TypeExtField) << MPU_RASR_TEX_Pos) & MPU_RASR_TEX_Msk) | \ + (((IsShareable) << MPU_RASR_S_Pos) & MPU_RASR_S_Msk) | \ + (((IsCacheable) << MPU_RASR_C_Pos) & MPU_RASR_C_Msk) | \ + (((IsBufferable) << MPU_RASR_B_Pos) & MPU_RASR_B_Msk)) + +/** +* MPU Region Attribute and Size Register Value +* +* \param DisableExec Instruction access disable bit, 1= disable instruction fetches. +* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode. +* \param AccessAttributes Memory access attribution, see \ref ARM_MPU_ACCESS_. +* \param SubRegionDisable Sub-region disable field. +* \param Size Region size of the region to be configured, for example 4K, 8K. +*/ +#define ARM_MPU_RASR_EX(DisableExec, AccessPermission, AccessAttributes, SubRegionDisable, Size) \ + ((((DisableExec) << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) | \ + (((AccessPermission) << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | \ + (((AccessAttributes) & (MPU_RASR_TEX_Msk | MPU_RASR_S_Msk | MPU_RASR_C_Msk | MPU_RASR_B_Msk))) | \ + (((SubRegionDisable) << MPU_RASR_SRD_Pos) & MPU_RASR_SRD_Msk) | \ + (((Size) << MPU_RASR_SIZE_Pos) & MPU_RASR_SIZE_Msk) | \ + (((MPU_RASR_ENABLE_Msk)))) + +/** +* MPU Region Attribute and Size Register Value +* +* \param DisableExec Instruction access disable bit, 1= disable instruction fetches. +* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode. +* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral. +* \param IsShareable Region is shareable between multiple bus masters. +* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache. +* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy. +* \param SubRegionDisable Sub-region disable field. +* \param Size Region size of the region to be configured, for example 4K, 8K. +*/ +#define ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, SubRegionDisable, Size) \ + ARM_MPU_RASR_EX(DisableExec, AccessPermission, ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable), SubRegionDisable, Size) + +/** +* MPU Memory Access Attribute for strongly ordered memory. +* - TEX: 000b +* - Shareable +* - Non-cacheable +* - Non-bufferable +*/ +#define ARM_MPU_ACCESS_ORDERED ARM_MPU_ACCESS_(0U, 1U, 0U, 0U) + +/** +* MPU Memory Access Attribute for device memory. +* - TEX: 000b (if shareable) or 010b (if non-shareable) +* - Shareable or non-shareable +* - Non-cacheable +* - Bufferable (if shareable) or non-bufferable (if non-shareable) +* +* \param IsShareable Configures the device memory as shareable or non-shareable. +*/ +#define ARM_MPU_ACCESS_DEVICE(IsShareable) ((IsShareable) ? ARM_MPU_ACCESS_(0U, 1U, 0U, 1U) : ARM_MPU_ACCESS_(2U, 0U, 0U, 0U)) + +/** +* MPU Memory Access Attribute for normal memory. +* - TEX: 1BBb (reflecting outer cacheability rules) +* - Shareable or non-shareable +* - Cacheable or non-cacheable (reflecting inner cacheability rules) +* - Bufferable or non-bufferable (reflecting inner cacheability rules) +* +* \param OuterCp Configures the outer cache policy. +* \param InnerCp Configures the inner cache policy. +* \param IsShareable Configures the memory as shareable or non-shareable. +*/ +#define ARM_MPU_ACCESS_NORMAL(OuterCp, InnerCp, IsShareable) ARM_MPU_ACCESS_((4U | (OuterCp)), IsShareable, ((InnerCp) & 2U), ((InnerCp) & 1U)) + +/** +* MPU Memory Access Attribute non-cacheable policy. +*/ +#define ARM_MPU_CACHEP_NOCACHE 0U + +/** +* MPU Memory Access Attribute write-back, write and read allocate policy. +*/ +#define ARM_MPU_CACHEP_WB_WRA 1U + +/** +* MPU Memory Access Attribute write-through, no write allocate policy. +*/ +#define ARM_MPU_CACHEP_WT_NWA 2U + +/** +* MPU Memory Access Attribute write-back, no write allocate policy. +*/ +#define ARM_MPU_CACHEP_WB_NWA 3U + + +/** +* Struct for a single MPU Region +*/ +typedef struct { + uint32_t RBAR; //!< The region base address register value (RBAR) + uint32_t RASR; //!< The region attribute and size register value (RASR) \ref MPU_RASR +} ARM_MPU_Region_t; + +/** Enable the MPU. +* \param MPU_Control Default access permissions for unconfigured regions. +*/ +__STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control) +{ + MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk; +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; +#endif + __DSB(); + __ISB(); +} + +/** Disable the MPU. +*/ +__STATIC_INLINE void ARM_MPU_Disable(void) +{ + __DMB(); +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; +#endif + MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk; +} + +/** Clear and disable the given MPU region. +* \param rnr Region number to be cleared. +*/ +__STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr) +{ + MPU->RNR = rnr; + MPU->RASR = 0U; +} + +/** Configure an MPU region. +* \param rbar Value for RBAR register. +* \param rsar Value for RSAR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rbar, uint32_t rasr) +{ + MPU->RBAR = rbar; + MPU->RASR = rasr; +} + +/** Configure the given MPU region. +* \param rnr Region number to be configured. +* \param rbar Value for RBAR register. +* \param rsar Value for RSAR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegionEx(uint32_t rnr, uint32_t rbar, uint32_t rasr) +{ + MPU->RNR = rnr; + MPU->RBAR = rbar; + MPU->RASR = rasr; +} + +/** Memcopy with strictly ordered memory access, e.g. for register targets. +* \param dst Destination data is copied to. +* \param src Source data is copied from. +* \param len Amount of data words to be copied. +*/ +__STATIC_INLINE void ARM_MPU_OrderedMemcpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len) +{ + uint32_t i; + for (i = 0U; i < len; ++i) + { + dst[i] = src[i]; + } +} + +/** Load the given number of MPU regions from a table. +* \param table Pointer to the MPU configuration table. +* \param cnt Amount of regions to be configured. +*/ +__STATIC_INLINE void ARM_MPU_Load(ARM_MPU_Region_t const* table, uint32_t cnt) +{ + const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U; + while (cnt > MPU_TYPE_RALIASES) { + ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), MPU_TYPE_RALIASES*rowWordSize); + table += MPU_TYPE_RALIASES; + cnt -= MPU_TYPE_RALIASES; + } + ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), cnt*rowWordSize); +} + +#endif + diff --git a/panda/board/inc/stm32f413xx.h b/panda/board/inc/stm32f413xx.h index 0fd9f4c387d405..0962a8def1a3a6 100644 --- a/panda/board/inc/stm32f413xx.h +++ b/panda/board/inc/stm32f413xx.h @@ -141,6 +141,7 @@ typedef enum TIM8_TRG_COM_TIM14_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt */ TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare global interrupt */ DMA1_Stream7_IRQn = 47, /*!< DMA1 Stream7 Interrupt */ + FSMC_IRQn = 48, /*!< FSMC global Interrupt */ SDIO_IRQn = 49, /*!< SDIO global Interrupt */ TIM5_IRQn = 50, /*!< TIM5 global Interrupt */ SPI3_IRQn = 51, /*!< SPI3 global Interrupt */ diff --git a/panda/board/libc.h b/panda/board/libc.h index 83adb9c09663e8..c731dad93d83a0 100644 --- a/panda/board/libc.h +++ b/panda/board/libc.h @@ -1,7 +1,7 @@ // **** libc **** -void delay(int a) { - volatile int i; +void delay(uint32_t a) { + volatile uint32_t i; for (i = 0; i < a; i++); } @@ -40,26 +40,3 @@ int memcmp(const void * ptr1, const void * ptr2, unsigned int num) { return ret; } -// ********************* IRQ helpers ********************* - -int interrupts_enabled = 0; -void enable_interrupts(void) { - interrupts_enabled = 1; - __enable_irq(); -} - -int critical_depth = 0; -void enter_critical_section(void) { - __disable_irq(); - // this is safe because interrupts are disabled - critical_depth += 1; -} - -void exit_critical_section(void) { - // this is safe because interrupts are disabled - critical_depth -= 1; - if ((critical_depth == 0) && interrupts_enabled) { - __enable_irq(); - } -} - diff --git a/panda/board/main.c b/panda/board/main.c index 410c54a58a8d72..4893c15c8dd4f2 100644 --- a/panda/board/main.c +++ b/panda/board/main.c @@ -1,29 +1,35 @@ -//#define EON +//#define EON //#define PANDA // ********************* Includes ********************* #include "config.h" #include "obj/gitversion.h" +#include "main_declarations.h" +#include "critical.h" + #include "libc.h" #include "provision.h" +#include "faults.h" -#include "main_declarations.h" +#include "drivers/registers.h" +#include "drivers/interrupts.h" #include "drivers/llcan.h" #include "drivers/llgpio.h" #include "drivers/adc.h" +#include "drivers/pwm.h" #include "board.h" #include "drivers/uart.h" #include "drivers/usb.h" #include "drivers/gmlan_alt.h" +#include "drivers/kline_init.h" #include "drivers/timer.h" #include "drivers/clock.h" #include "gpio.h" -#include "drivers/lin.h" #ifndef EON #include "drivers/spi.h" @@ -34,18 +40,49 @@ #include "drivers/can.h" +uint16_t prev_safety_mode = 0; +extern int _app_start[0xc000]; // Only first 3 sectors of size 0x4000 are used + +struct __attribute__((packed)) health_t { + uint32_t uptime_pkt; + uint32_t voltage_pkt; + uint32_t current_pkt; + uint32_t can_rx_errs_pkt; + uint32_t can_send_errs_pkt; + uint32_t can_fwd_errs_pkt; + uint32_t gmlan_send_errs_pkt; + uint32_t faults_pkt; + uint8_t ignition_line_pkt; + uint8_t ignition_can_pkt; + uint8_t controls_allowed_pkt; + uint8_t gas_interceptor_detected_pkt; + uint8_t car_harness_status_pkt; + uint8_t usb_power_mode_pkt; + uint8_t safety_mode_pkt; + uint8_t fault_status_pkt; + uint8_t power_save_enabled_pkt; +}; + + // ********************* Serial debugging ********************* +bool check_started(void) { + return current_board->check_ignition() || ignition_can; +} + void debug_ring_callback(uart_ring *ring) { char rcv; while (getc(ring, &rcv)) { (void)putc(ring, rcv); // misra-c2012-17.7: cast to void is ok: debug function - // jump to DFU flash - if (rcv == 'z') { - enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC; - NVIC_SystemReset(); - } + // only allow bootloader entry on debug builds + #ifdef ALLOW_DEBUG + // jump to DFU flash + if (rcv == 'z') { + enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC; + NVIC_SystemReset(); + } + #endif // normal reset if (rcv == 'x') { @@ -68,145 +105,107 @@ void debug_ring_callback(uart_ring *ring) { } } -// ***************************** started logic ***************************** -void started_interrupt_handler(uint8_t interrupt_line) { - volatile unsigned int pr = EXTI->PR & (1U << interrupt_line); - if ((pr & (1U << interrupt_line)) != 0U) { - #ifdef DEBUG - puts("got started interrupt\n"); - #endif - - // jenky debounce - delay(100000); - - // set power savings mode here - int power_save_state = current_board->check_ignition() ? POWER_SAVE_STATUS_DISABLED : POWER_SAVE_STATUS_ENABLED; - set_power_save_state(power_save_state); - } - EXTI->PR = (1U << interrupt_line); -} - -// cppcheck-suppress unusedFunction ; used in headers not included in cppcheck -void EXTI0_IRQHandler(void) { - started_interrupt_handler(0); -} - -// cppcheck-suppress unusedFunction ; used in headers not included in cppcheck -void EXTI1_IRQHandler(void) { - started_interrupt_handler(1); -} - -// cppcheck-suppress unusedFunction ; used in headers not included in cppcheck -void EXTI3_IRQHandler(void) { - started_interrupt_handler(3); -} - -void started_interrupt_init(void) { - SYSCFG->EXTICR[1] = SYSCFG_EXTICR1_EXTI1_PA; - EXTI->IMR |= (1U << 1); - EXTI->RTSR |= (1U << 1); - EXTI->FTSR |= (1U << 1); - NVIC_EnableIRQ(EXTI1_IRQn); -} - // ****************************** safety mode ****************************** // this is the only way to leave silent mode void set_safety_mode(uint16_t mode, int16_t param) { - int err = safety_set_mode(mode, param); + //BB to prevent any changes to safety + UNUSED(mode); + UNUSED(param); +} + +// this is the only way to leave silent mode +void set_safety_mode2(uint16_t mode, int16_t param) { + if (prev_safety_mode == mode) { + return; + } + //BB we had this now they changed it to below: int err = safety_set_mode2(mode, param); + uint16_t mode_copy = mode; + int err = set_safety_hooks2(mode_copy, param); if (err == -1) { - puts("Error: safety set mode failed\n"); - } else { - if (mode == SAFETY_NOOUTPUT) { + puts("Error: safety set mode failed. Falling back to SILENT\n"); + mode_copy = SAFETY_SILENT; + err = set_safety_hooks2(mode_copy, 0); + if (err == -1) { + puts("Error: Failed setting SILENT mode. Hanging\n"); + while (true) { + // TERMINAL ERROR: we can't continue if SILENT safety mode isn't succesfully set + } + } + } + switch (mode_copy) { + case SAFETY_SILENT: + set_intercept_relay(false); + if (board_has_obd()) { + current_board->set_can_mode(CAN_MODE_NORMAL); + } can_silent = ALL_CAN_SILENT; - } else { + break; + case SAFETY_NOOUTPUT: + set_intercept_relay(false); + if (board_has_obd()) { + current_board->set_can_mode(CAN_MODE_NORMAL); + } can_silent = ALL_CAN_LIVE; - } - - switch (mode) { - case SAFETY_NOOUTPUT: - set_intercept_relay(false); - if(hw_type == HW_TYPE_BLACK_PANDA){ - current_board->set_can_mode(CAN_MODE_NORMAL); - } - break; - case SAFETY_ELM327: - set_intercept_relay(false); - if(hw_type == HW_TYPE_BLACK_PANDA){ - current_board->set_can_mode(CAN_MODE_OBD_CAN2); - } - break; - default: - set_intercept_relay(true); - if(hw_type == HW_TYPE_BLACK_PANDA){ - current_board->set_can_mode(CAN_MODE_NORMAL); - } - 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) - set_power_save_state(POWER_SAVE_STATUS_DISABLED); - } else { - // power mode is already POWER_SAVE_STATUS_DISABLED and CAN TXs are active - } - can_init_all(); + break; + case SAFETY_ELM327: + set_intercept_relay(false); + heartbeat_counter = 0U; + if (board_has_obd()) { + current_board->set_can_mode(CAN_MODE_OBD_CAN2); + } + can_silent = ALL_CAN_LIVE; + break; + default: + set_intercept_relay(true); + heartbeat_counter = 0U; + if (board_has_obd()) { + current_board->set_can_mode(CAN_MODE_NORMAL); + } + can_silent = ALL_CAN_LIVE; + break; } + prev_safety_mode = mode; + can_init_all(); } // ***************************** USB port ***************************** int get_health_pkt(void *dat) { - struct __attribute__((packed)) { - uint32_t voltage_pkt; - uint32_t current_pkt; - uint32_t can_send_errs_pkt; - uint32_t can_fwd_errs_pkt; - uint32_t gmlan_send_errs_pkt; - uint8_t started_pkt; - uint8_t controls_allowed_pkt; - uint8_t gas_interceptor_detected_pkt; - uint8_t car_harness_status_pkt; - } *health = dat; - - //Voltage will be measured in mv. 5000 = 5V - uint32_t voltage = adc_get(ADCCHAN_VOLTAGE); - - // 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_pkt = (voltage * 8862U) / 1000U; - - // No current sense on panda black - if(hw_type != HW_TYPE_BLACK_PANDA){ - health->current_pkt = adc_get(ADCCHAN_CURRENT); - } else { - health->current_pkt = 0; - } + COMPILE_TIME_ASSERT(sizeof(struct health_t) <= MAX_RESP_LEN); + struct health_t * health = (struct health_t*)dat; - int safety_ignition = safety_ignition_hook(); - if (safety_ignition < 0) { - //Use the GPIO pin to determine ignition - health->started_pkt = 1; // (uint8_t)(current_board->check_ignition()); - } else { - //Current safety hooks want to determine ignition (ex: GM) - health->started_pkt = safety_ignition; - } + health->uptime_pkt = uptime_cnt; + health->voltage_pkt = adc_get_voltage(); + health->current_pkt = current_board->read_current(); + + //Use the GPIO pin to determine ignition or use a CAN based logic + health->ignition_line_pkt = (uint8_t)(current_board->check_ignition()); + health->ignition_can_pkt = (uint8_t)(ignition_can); health->controls_allowed_pkt = controls_allowed; health->gas_interceptor_detected_pkt = gas_interceptor_detected; + health->can_rx_errs_pkt = can_rx_errs; health->can_send_errs_pkt = can_send_errs; health->can_fwd_errs_pkt = can_fwd_errs; health->gmlan_send_errs_pkt = gmlan_send_errs; health->car_harness_status_pkt = car_harness_status; - + health->usb_power_mode_pkt = usb_power_mode; + health->safety_mode_pkt = (uint8_t)(current_safety_mode); + health->power_save_enabled_pkt = (uint8_t)(power_save_status == POWER_SAVE_STATUS_ENABLED); + + health->fault_status_pkt = fault_status; + health->faults_pkt = faults; + return sizeof(*health); } +int get_rtc_pkt(void *dat) { + timestamp_t t = rtc_get_time(); + (void)memcpy(dat, &t, sizeof(t)); + return sizeof(t); +} + int usb_cb_ep1_in(void *usbdata, int len, bool hardwired) { UNUSED(hardwired); CAN_FIFOMailBox_TypeDef *reply = (CAN_FIFOMailBox_TypeDef *)usbdata; @@ -223,7 +222,7 @@ void usb_cb_ep2_out(void *usbdata, int len, bool hardwired) { uint8_t *usbdata8 = (uint8_t *)usbdata; uart_ring *ur = get_ring_by_number(usbdata8[0]); if ((len != 0) && (ur != NULL)) { - if ((usbdata8[0] < 2U) || safety_tx_lin_hook(usbdata8[0] - 2U, usbdata8 + 1, len - 1)) { + if ((usbdata8[0] < 2U) || safety_tx_lin_hook(usbdata8[0] - 2U, &usbdata8[1], len - 1)) { for (int i = 1; i < len; i++) { while (!putc(ur, usbdata8[i])) { // wait @@ -246,7 +245,13 @@ void usb_cb_ep3_out(void *usbdata, int len, bool hardwired) { to_push.RIR = d32[dpkt]; uint8_t bus_number = (to_push.RDTR >> 4) & CAN_BUS_NUM_MASK; - can_send(&to_push, bus_number); + can_send(&to_push, bus_number, false); + } +} + +void usb_cb_ep3_out_complete() { + if (can_tx_check_min_slots_free(MAX_CAN_MSGS_PER_BULK_TRANSFER)) { + usb_outep3_resume_if_paused(); } } @@ -258,8 +263,72 @@ void usb_cb_enumeration_complete() { int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) { unsigned int resp_len = 0; uart_ring *ur = NULL; - int i; + timestamp_t t; switch (setup->b.bRequest) { + // **** 0xa0: get rtc time + case 0xa0: + resp_len = get_rtc_pkt(resp); + break; + // **** 0xa1: set rtc year + case 0xa1: + t = rtc_get_time(); + t.year = setup->b.wValue.w; + rtc_set_time(t); + break; + // **** 0xa2: set rtc month + case 0xa2: + t = rtc_get_time(); + t.month = setup->b.wValue.w; + rtc_set_time(t); + break; + // **** 0xa3: set rtc day + case 0xa3: + t = rtc_get_time(); + t.day = setup->b.wValue.w; + rtc_set_time(t); + break; + // **** 0xa4: set rtc weekday + case 0xa4: + t = rtc_get_time(); + t.weekday = setup->b.wValue.w; + rtc_set_time(t); + break; + // **** 0xa5: set rtc hour + case 0xa5: + t = rtc_get_time(); + t.hour = setup->b.wValue.w; + rtc_set_time(t); + break; + // **** 0xa6: set rtc minute + case 0xa6: + t = rtc_get_time(); + t.minute = setup->b.wValue.w; + rtc_set_time(t); + break; + // **** 0xa7: set rtc second + case 0xa7: + t = rtc_get_time(); + t.second = setup->b.wValue.w; + rtc_set_time(t); + break; + // **** 0xb0: set IR power + case 0xb0: + current_board->set_ir_power(setup->b.wValue.w); + break; + // **** 0xb1: set fan power + case 0xb1: + current_board->set_fan_power(setup->b.wValue.w); + break; + // **** 0xb2: get fan rpm + case 0xb2: + resp[0] = (fan_rpm & 0x00FFU); + resp[1] = ((fan_rpm & 0xFF00U) >> 8U); + resp_len = 2; + break; + // **** 0xb3: set phone power + case 0xb3: + current_board->set_phone_power(setup->b.wValue.w > 0U); + break; // **** 0xc0: get CAN debug info case 0xc0: puts("can tx: "); puth(can_tx_cnt); @@ -290,11 +359,14 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) // so it's blocked over wifi switch (setup->b.wValue.w) { case 0: - if (hardwired) { - puts("-> entering bootloader\n"); - enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC; - NVIC_SystemReset(); - } + // only allow bootloader entry on debug builds + #ifdef ALLOW_DEBUG + if (hardwired) { + puts("-> entering bootloader\n"); + enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC; + NVIC_SystemReset(); + } + #endif break; case 1: puts("-> entering softloader\n"); @@ -310,6 +382,24 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) case 0xd2: resp_len = get_health_pkt(resp); break; + // **** 0xd3: get first 64 bytes of signature + case 0xd3: + { + resp_len = 64; + char * code = (char*)_app_start; + int code_len = _app_start[0]; + (void)memcpy(resp, &code[code_len], resp_len); + } + break; + // **** 0xd4: get second 64 bytes of signature + case 0xd4: + { + resp_len = 64; + char * code = (char*)_app_start; + int code_len = _app_start[0]; + (void)memcpy(resp, &code[code_len + 64], resp_len); + } + break; // **** 0xd6: get version case 0xd6: COMPILE_TIME_ASSERT(sizeof(gitversion) <= MAX_RESP_LEN); @@ -323,35 +413,35 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) // **** 0xd9: set ESP power case 0xd9: if (setup->b.wValue.w == 1U) { - current_board->set_esp_gps_mode(ESP_GPS_ENABLED); + current_board->set_gps_mode(GPS_ENABLED); } else if (setup->b.wValue.w == 2U) { - current_board->set_esp_gps_mode(ESP_GPS_BOOTMODE); + current_board->set_gps_mode(GPS_BOOTMODE); } else { - current_board->set_esp_gps_mode(ESP_GPS_DISABLED); + current_board->set_gps_mode(GPS_DISABLED); } break; // **** 0xda: reset ESP, with optional boot mode case 0xda: - current_board->set_esp_gps_mode(ESP_GPS_DISABLED); + current_board->set_gps_mode(GPS_DISABLED); delay(1000000); if (setup->b.wValue.w == 1U) { - current_board->set_esp_gps_mode(ESP_GPS_BOOTMODE); + current_board->set_gps_mode(GPS_BOOTMODE); } else { - current_board->set_esp_gps_mode(ESP_GPS_ENABLED); + current_board->set_gps_mode(GPS_ENABLED); } delay(1000000); - current_board->set_esp_gps_mode(ESP_GPS_ENABLED); + current_board->set_gps_mode(GPS_ENABLED); break; // **** 0xdb: set GMLAN (white/grey) or OBD CAN (black) multiplexing mode case 0xdb: - if(hw_type == HW_TYPE_BLACK_PANDA){ + if(board_has_obd()){ if (setup->b.wValue.w == 1U) { // Enable OBD CAN current_board->set_can_mode(CAN_MODE_OBD_CAN2); } else { // Disable OBD CAN current_board->set_can_mode(CAN_MODE_NORMAL); - } + } } else { if (setup->b.wValue.w == 1U) { // GMLAN ON @@ -367,12 +457,14 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) } } break; - + // **** 0xdc: set safety mode case 0xdc: // Blocked over WiFi. - // Allow NOOUTPUT and ELM security mode to be set over wifi. - if (hardwired || (setup->b.wValue.w == SAFETY_NOOUTPUT) || (setup->b.wValue.w == SAFETY_ELM327)) { + // Allow SILENT, NOOUTPUT and ELM security mode to be set over wifi. + if (hardwired || (setup->b.wValue.w == SAFETY_SILENT) || + (setup->b.wValue.w == SAFETY_NOOUTPUT) || + (setup->b.wValue.w == SAFETY_ELM327)) { set_safety_mode(setup->b.wValue.w, (uint16_t) setup->b.wIndex.w); } break; @@ -394,12 +486,19 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) if (setup->b.wValue.w < BUS_MAX) { can_speed[setup->b.wValue.w] = setup->b.wIndex.w; can_init(CAN_NUM_FROM_BUS_NUM(setup->b.wValue.w)); + /* Tesla branch commented out: + bool ret = can_init(CAN_NUM_FROM_BUS_NUM(setup->b.wValue.w)); + UNUSED(ret); } break; - // **** 0xdf: set long controls allowed + // **** 0xdf: set unsafe mode case 0xdf: - if (hardwired) { - long_controls_allowed = setup->b.wValue.w & 1U; + // you can only set this if you are in a non car safety mode + if ((current_safety_mode == SAFETY_SILENT) || + (current_safety_mode == SAFETY_NOOUTPUT) || + (current_safety_mode == SAFETY_ELM327)) { + unsafe_mode = setup->b.wValue.w; + */ } break; // **** 0xe0: uart read @@ -408,9 +507,12 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) if (!ur) { break; } - if (ur == &esp_ring) { - uart_dma_drain(); + + // TODO: Remove this again and fix boardd code to hande the message bursts instead of single chars + if (ur == &uart_ring_gps) { + dma_pointer_handler(ur, DMA2_Stream5->NDTR); } + // read while ((resp_len < MIN(setup->b.wLength.w, MAX_RESP_LEN)) && getc(ur, (char*)&resp[resp_len])) { @@ -465,49 +567,21 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) break; // **** 0xe6: set USB power case 0xe6: - if (setup->b.wValue.w == 1U) { - puts("user setting CDP mode\n"); - current_board->set_usb_power_mode(USB_POWER_CDP); - } else if (setup->b.wValue.w == 2U) { - puts("user setting DCP mode\n"); - current_board->set_usb_power_mode(USB_POWER_DCP); - } else { - puts("user setting CLIENT mode\n"); - current_board->set_usb_power_mode(USB_POWER_CLIENT); - } + current_board->set_usb_power_mode(setup->b.wValue.w); + break; + // **** 0xe7: set power save state + case 0xe7: + set_power_save_state(setup->b.wValue.w); break; - // **** 0xf0: do k-line wValue pulse on uart2 for Acura + // **** 0xf0: k-line/l-line wake-up pulse for KWP2000 fast initialization case 0xf0: - if (setup->b.wValue.w == 1U) { - GPIOC->ODR &= ~(1U << 10); - GPIOC->MODER &= ~GPIO_MODER_MODER10_1; - GPIOC->MODER |= GPIO_MODER_MODER10_0; - } else { - GPIOC->ODR &= ~(1U << 12); - GPIOC->MODER &= ~GPIO_MODER_MODER12_1; - GPIOC->MODER |= GPIO_MODER_MODER12_0; - } - - for (i = 0; i < 80; i++) { - delay(8000); - if (setup->b.wValue.w == 1U) { - GPIOC->ODR |= (1U << 10); - GPIOC->ODR &= ~(1U << 10); - } else { - GPIOC->ODR |= (1U << 12); - GPIOC->ODR &= ~(1U << 12); + if(board_has_lin()) { + bool k = (setup->b.wValue.w == 0U) || (setup->b.wValue.w == 2U); + bool l = (setup->b.wValue.w == 1U) || (setup->b.wValue.w == 2U); + if (bitbang_wakeup(k, l)) { + resp_len = -1; // do not clear NAK yet (wait for bit banging to finish) } } - - if (setup->b.wValue.w == 1U) { - GPIOC->MODER &= ~GPIO_MODER_MODER10_0; - GPIOC->MODER |= GPIO_MODER_MODER10_1; - } else { - GPIOC->MODER &= ~GPIO_MODER_MODER12_0; - GPIOC->MODER |= GPIO_MODER_MODER12_1; - } - - delay(140 * 9000); break; // **** 0xf1: Clear CAN ring buffer. case 0xf1: @@ -537,6 +611,25 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) heartbeat_counter = 0U; break; } + // **** 0xf4: k-line/l-line 5 baud initialization + case 0xf4: + if(board_has_lin()) { + bool k = (setup->b.wValue.w == 0U) || (setup->b.wValue.w == 2U); + bool l = (setup->b.wValue.w == 1U) || (setup->b.wValue.w == 2U); + uint8_t five_baud_addr = (setup->b.wIndex.w & 0xFFU); + if (bitbang_five_baud_addr(k, l, five_baud_addr)) { + resp_len = -1; // do not clear NAK yet (wait for bit banging to finish) + } + } + break; + // **** 0xf5: set clock source mode + case 0xf5: + current_board->set_clock_source_mode(setup->b.wValue.w); + break; + // **** 0xf6: set siren enabled + case 0xf6: + siren_enabled = (setup->b.wValue.w != 0U); + break; default: puts("NO HANDLER "); puth(setup->b.bRequest); @@ -590,65 +683,118 @@ void __attribute__ ((noinline)) enable_fpu(void) { SCB->CPACR |= ((3UL << (10U * 2U)) | (3UL << (11U * 2U))); } -uint64_t tcnt = 0; +// go into SILENT when the EON does not send a heartbeat for this amount of seconds. +#define EON_HEARTBEAT_IGNITION_CNT_ON 5U +#define EON_HEARTBEAT_IGNITION_CNT_OFF 2U -// go into NOOUTPUT when the EON does not send a heartbeat for this amount of seconds. -#define EON_HEARTBEAT_THRESHOLD_IGNITION_ON 5U -#define EON_HEARTBEAT_THRESHOLD_IGNITION_OFF 2U +// called at 8Hz +uint8_t loop_counter = 0U; +void TIM1_BRK_TIM9_IRQ_Handler(void) { + if (TIM9->SR != 0) { + // siren + current_board->set_siren((loop_counter & 1U) && siren_enabled); -// called once per second -// cppcheck-suppress unusedFunction ; used in headers not included in cppcheck -void TIM3_IRQHandler(void) { - if (TIM3->SR != 0) { - can_live = pending_can_live; + // decimated to 1Hz + if(loop_counter == 0U){ + can_live = pending_can_live; - current_board->usb_power_mode_tick(tcnt); + current_board->usb_power_mode_tick(uptime_cnt); - //puth(usart1_dma); puts(" "); puth(DMA2_Stream5->M0AR); puts(" "); puth(DMA2_Stream5->NDTR); puts("\n"); + //puth(usart1_dma); puts(" "); puth(DMA2_Stream5->M0AR); puts(" "); puth(DMA2_Stream5->NDTR); puts("\n"); - // reset this every 16th pass - if ((tcnt & 0xFU) == 0U) { - pending_can_live = 0; - } - #ifdef DEBUG - //TODO: re-enable - //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 + // reset this every 16th pass + if ((uptime_cnt & 0xFU) == 0U) { + 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 + + // Tick drivers + fan_tick(); + + // set green LED to be controls allowed + current_board->set_led(LED_GREEN, controls_allowed); + + // turn off the blue LED, turned on by CAN + // unless we are in power saving mode + current_board->set_led(LED_BLUE, (uptime_cnt & 1U) && (power_save_status == POWER_SAVE_STATUS_ENABLED)); + + // increase heartbeat counter and cap it at the uint32 limit + if (heartbeat_counter < __UINT32_MAX__) { + heartbeat_counter += 1U; + } - // set green LED to be controls allowed - current_board->set_led(LED_GREEN, controls_allowed); + //BB we do not want to disable safety mode when on tesla + /* + #ifdef EON + // check heartbeat counter if we are running EON code. + // if the heartbeat has been gone for a while, go to SILENT safety mode and enter power save + if (heartbeat_counter >= (check_started() ? EON_HEARTBEAT_IGNITION_CNT_ON : EON_HEARTBEAT_IGNITION_CNT_OFF)) { + puts("EON hasn't sent a heartbeat for 0x"); + puth(heartbeat_counter); + puts(" seconds. Safety is set to SILENT mode.\n"); + if (current_safety_mode != SAFETY_SILENT) { + set_safety_mode(SAFETY_SILENT, 0U); + } + if (power_save_status != POWER_SAVE_STATUS_ENABLED) { + set_power_save_state(POWER_SAVE_STATUS_ENABLED); + } - // turn off the blue LED, turned on by CAN - // unless we are in power saving mode - current_board->set_led(LED_BLUE, (tcnt & 1U) && (power_save_status == POWER_SAVE_STATUS_ENABLED)); + // Also disable IR when the heartbeat goes missing + current_board->set_ir_power(0U); - // increase heartbeat counter and cap it at the uint32 limit - if (heartbeat_counter < __UINT32_MAX__) { - heartbeat_counter += 1U; - } + // If enumerated but no heartbeat (phone up, boardd not running), turn the fan on to cool the device + if(usb_enumerated()){ + current_board->set_fan_power(50U); + } else { + current_board->set_fan_power(0U); + } + } - // check heartbeat counter if we are running EON code. If the heartbeat has been gone for a while, go to NOOUTPUT safety mode. - //BB we do not want to disable safety mode when on tesla - /* - #ifdef EON - if (heartbeat_counter >= (current_board->check_ignition() ? EON_HEARTBEAT_THRESHOLD_IGNITION_ON : EON_HEARTBEAT_THRESHOLD_IGNITION_OFF)) { - puts("EON hasn't sent a heartbeat for 0x"); puth(heartbeat_counter); puts(" seconds. Safety is set to NOOUTPUT mode.\n"); - set_safety_mode(SAFETY_NOOUTPUT, 0U); - } - #endif + // enter CDP mode when car starts to ensure we are charging a turned off EON + if (check_started() && (usb_power_mode != USB_POWER_CDP)) { + current_board->set_usb_power_mode(USB_POWER_CDP); + } + #endif */ - // on to the next one - tcnt += 1U; + + // check registers + check_registers(); + + // set ignition_can to false after 2s of no CAN seen + if (ignition_can_cnt > 2U) { + ignition_can = false; + }; + + // on to the next one + uptime_cnt += 1U; + safety_mode_cnt += 1U; + ignition_can_cnt += 1U; + + // synchronous safety check + safety_tick(current_hooks); + } + + loop_counter++; + loop_counter %= 8U; } - TIM3->SR = 0; + TIM9->SR = 0; } +#define MAX_FADE 8192U int main(void) { + // Init interrupt table + init_interrupts(true); + + // 8Hz timer + REGISTER_INTERRUPT(TIM1_BRK_TIM9_IRQn, TIM1_BRK_TIM9_IRQ_Handler, 10U, FAULT_INTERRUPT_RATE_TIM9) + // shouldn't have interrupts here, but just in case - __disable_irq(); + disable_interrupts(); // init early devices clock_init(); @@ -656,7 +802,7 @@ int main(void) { detect_configuration(); detect_board_type(); adc_init(); - + // print hello puts("\n\n\n************************ MAIN START ************************\n"); @@ -669,7 +815,6 @@ int main(void) { puts("Config:\n"); puts(" Board type: "); puts(current_board->board_type); puts("\n"); puts(has_external_debug_serial ? " Real serial\n" : " USB serial\n"); - puts(is_entering_bootmode ? " ESP wants bootmode\n" : " No bootmode\n"); // init board current_board->init(); @@ -681,22 +826,21 @@ int main(void) { if (has_external_debug_serial) { // WEIRDNESS: without this gate around the UART, it would "crash", but only if the ESP is enabled // assuming it's because the lines were left floating and spurious noise was on them - uart_init(USART2, 115200); + uart_init(&uart_ring_debug, 115200); } if (board_has_gps()) { - uart_init(USART1, 9600); + uart_init(&uart_ring_gps, 9600); } else { // enable ESP uart - uart_init(USART1, 115200); + uart_init(&uart_ring_gps, 115200); } - // there is no LIN on panda black - if(hw_type != HW_TYPE_BLACK_PANDA){ + if(board_has_lin()){ // enable LIN - uart_init(UART5, 10400); + uart_init(&uart_ring_lin1, 10400); UART5->CR2 |= USART_CR2_LINEN; - uart_init(USART3, 10400); + uart_init(&uart_ring_lin2, 10400); USART3->CR2 |= USART_CR2_LINEN; } @@ -708,41 +852,20 @@ int main(void) { TIM2->EGR = TIM_EGR_UG; // use TIM2->CNT to read - // 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 - int err = safety_set_mode(SAFETY_NOOUTPUT, 0); - if (err == -1) { - puts("Failed to set safety mode\n"); - while (true) { - // if SAFETY_NOOUTPUT isn't succesfully set, we can't continue - } - } - can_silent = ALL_CAN_SILENT; - can_init_all(); + // init to SILENT and can silent + //set_safety_mode(SAFETY_SILENT, 0); + set_safety_mode2(SAFETY_TESLA, 0); + + // enable CAN TXs + current_board->enable_can_transceivers(true); #ifndef EON spi_init(); #endif -#ifdef EON - // have to save power - if (hw_type == HW_TYPE_WHITE_PANDA) { - current_board->set_esp_gps_mode(ESP_GPS_DISABLED); - } - // only enter power save after the first cycle - /*if (current_board->check_ignition()) { - set_power_save_state(POWER_SAVE_STATUS_ENABLED); - }*/ - - if (hw_type != HW_TYPE_BLACK_PANDA) { - // interrupt on started line - started_interrupt_init(); - } -#endif - - // 48mhz / 65536 ~= 732 / 732 = 1 - timer_init(TIM3, 732); - NVIC_EnableIRQ(TIM3_IRQn); + // 8hz + timer_init(TIM9, 183); + NVIC_EnableIRQ(TIM1_BRK_TIM9_IRQn); #ifdef DEBUG puts("DEBUG ENABLED\n"); @@ -758,19 +881,34 @@ int main(void) { for (cnt=0;;cnt++) { if (power_save_status == POWER_SAVE_STATUS_DISABLED) { - int div_mode = ((usb_power_mode == USB_POWER_DCP) ? 4 : 1); - - // 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++) { - current_board->set_led(LED_RED, 1); - if (fade < 512) { delay(fade); } else { delay(1024-fade); } - current_board->set_led(LED_RED, 0); - if (fade < 512) { delay(512-fade); } else { delay(fade-512); } - } + #ifdef DEBUG_FAULTS + if(fault_status == FAULT_STATUS_NONE){ + #endif + uint32_t div_mode = ((usb_power_mode == USB_POWER_DCP) ? 4U : 1U); + + // useful for debugging, fade breaks = panda is overloaded + for(uint32_t fade = 0U; fade < MAX_FADE; fade += div_mode){ + current_board->set_led(LED_RED, true); + delay(fade >> 4); + current_board->set_led(LED_RED, false); + delay((MAX_FADE - fade) >> 4); } - } + + for(uint32_t fade = MAX_FADE; fade > 0U; fade -= div_mode){ + current_board->set_led(LED_RED, true); + delay(fade >> 4); + current_board->set_led(LED_RED, false); + delay((MAX_FADE - fade) >> 4); + } + + #ifdef DEBUG_FAULTS + } else { + current_board->set_led(LED_RED, 1); + delay(512000U); + current_board->set_led(LED_RED, 0); + delay(512000U); + } + #endif } else { __WFI(); } diff --git a/panda/board/main_declarations.h b/panda/board/main_declarations.h index 8929e9ac0e0cd9..7fa2c4bbb3f8f9 100644 --- a/panda/board/main_declarations.h +++ b/panda/board/main_declarations.h @@ -11,4 +11,6 @@ void can_set_obd(uint8_t harness_orientation, bool obd); uint8_t hw_type = 0; const board *current_board; bool is_enumerated = 0; -uint32_t heartbeat_counter = 0; \ No newline at end of file +uint32_t heartbeat_counter = 0; +uint32_t uptime_cnt = 0; +bool siren_enabled = false; diff --git a/panda/board/pedal/Makefile b/panda/board/pedal/Makefile index 7ce6dd07684da5..e8d5c646836ce2 100644 --- a/panda/board/pedal/Makefile +++ b/panda/board/pedal/Makefile @@ -21,12 +21,16 @@ CFLAGS += "-DALLOW_DEBUG" canflash: obj/$(PROJ_NAME).bin ../../tests/pedal/enter_canloader.py $< +canflash2: obj/$(PROJ_NAME).bin + ../../tests/pedal/enter_canloader_can2.py $< + + usbflash: obj/$(PROJ_NAME).bin ../../tests/pedal/enter_canloader.py; sleep 0.5 PYTHONPATH=../../ python -c "from python import Panda; p = [x for x in [Panda(x) for x in Panda.list()] if x.bootstub]; assert(len(p)==1); p[0].flash('obj/$(PROJ_NAME).bin', reconnect=False)" recover: obj/bootstub.bin obj/$(PROJ_NAME).bin - ../../tests/pedal/enter_canloader.py --recover; sleep 0.5 + ../../tests/pedal/enter_canloader_tesla.py --recover; sleep 0.5 $(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08004000 -D obj/$(PROJ_NAME).bin $(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08000000:leave -D obj/bootstub.bin @@ -61,7 +65,7 @@ obj/$(PROJ_NAME).bin: obj/$(STARTUP_FILE).o obj/main.o obj/bootstub.bin: obj/$(STARTUP_FILE).o obj/bootstub.o obj/sha.o obj/rsa.o $(CC) $(CFLAGS) -o obj/bootstub.$(PROJ_NAME).elf $^ $(OBJCOPY) -v -O binary obj/bootstub.$(PROJ_NAME).elf $@ - + clean: rm -f obj/* diff --git a/panda/board/pedal/main.c b/panda/board/pedal/main.c index 194370fa389ce1..932684eb54039a 100644 --- a/panda/board/pedal/main.c +++ b/panda/board/pedal/main.c @@ -3,7 +3,11 @@ #include "libc.h" #include "main_declarations.h" +#include "critical.h" +#include "faults.h" +#include "drivers/registers.h" +#include "drivers/interrupts.h" #include "drivers/llcan.h" #include "drivers/llgpio.h" #include "drivers/adc.h" @@ -15,6 +19,7 @@ #include "drivers/timer.h" #include "gpio.h" +#include "crc.h" #define CAN CAN1 @@ -55,22 +60,23 @@ void debug_ring_callback(uart_ring *ring) { } } -int usb_cb_ep1_in(uint8_t *usbdata, int len, bool hardwired) { +int usb_cb_ep1_in(void *usbdata, int len, bool hardwired) { UNUSED(usbdata); UNUSED(len); UNUSED(hardwired); return 0; } -void usb_cb_ep2_out(uint8_t *usbdata, int len, bool hardwired) { +void usb_cb_ep2_out(void *usbdata, int len, bool hardwired) { UNUSED(usbdata); UNUSED(len); UNUSED(hardwired); } -void usb_cb_ep3_out(uint8_t *usbdata, int len, bool hardwired) { +void usb_cb_ep3_out(void *usbdata, int len, bool hardwired) { UNUSED(usbdata); UNUSED(len); UNUSED(hardwired); } +void usb_cb_ep3_out_complete(void) {} void usb_cb_enumeration_complete(void) {} int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) { @@ -84,9 +90,6 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) if (!ur) { break; } - if (ur == &esp_ring) { - uart_dma_drain(); - } // read while ((resp_len < MIN(setup->b.wLength.w, MAX_RESP_LEN)) && getc(ur, (char*)&resp[resp_len])) { @@ -106,34 +109,27 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) // ***************************** pedal can checksum ***************************** -uint8_t pedal_checksum(uint8_t *dat, int len) { - uint8_t crc = 0xFF; - uint8_t poly = 0xD5; // standard crc8 - int i, j; - for (i = len - 1; i >= 0; i--) { - crc ^= dat[i]; - for (j = 0; j < 8; j++) { - if ((crc & 0x80U) != 0U) { - crc = (uint8_t)((crc << 1) ^ poly); - } - else { - crc <<= 1; - } - } + +// ***************************** tesla can checksum ***************************** +uint8_t tesla_can_cksum(uint8_t *dat, int len, int addr) { + int i; + uint8_t s = 0; + s += ((addr)&0xFF) + ((addr>>8)&0xFF); + for (i = 0; i < len; i++) { + s = (s + dat[i]) & 0xFF; } - return crc; + return s; } // ***************************** can port ***************************** // addresses to be used on CAN -#define CAN_GAS_INPUT 0x200 -#define CAN_GAS_OUTPUT 0x201U +#define CAN_GAS_INPUT 0x551U +#define CAN_GAS_OUTPUT 0x552U #define CAN_GAS_SIZE 6 #define COUNTER_CYCLE 0xFU -// cppcheck-suppress unusedFunction ; used in headers not included in cppcheck -void CAN1_TX_IRQHandler(void) { +void CAN1_TX_IRQ_Handler(void) { // clear interrupt CAN->TSR |= CAN_TSR_RQCP0; } @@ -155,8 +151,9 @@ uint32_t current_index = 0; #define FAULT_INVALID 6U uint8_t state = FAULT_STARTUP; -// cppcheck-suppress unusedFunction ; used in headers not included in cppcheck -void CAN1_RX0_IRQHandler(void) { +const uint8_t crc_poly = 0xD5; // standard crc8 + +void CAN1_RX0_IRQ_Handler(void) { while ((CAN->RF0R & CAN_RF0R_FMP0) != 0) { #ifdef DEBUG puts("CAN RX\n"); @@ -174,6 +171,7 @@ void CAN1_RX0_IRQHandler(void) { } else { puts("Failed entering Softloader or Bootloader\n"); } + return; } // normal packet @@ -185,7 +183,7 @@ void CAN1_RX0_IRQHandler(void) { uint16_t value_1 = (dat[2] << 8) | dat[3]; bool enable = ((dat[4] >> 7) & 1U) != 0U; uint8_t index = dat[4] & COUNTER_CYCLE; - if (pedal_checksum(dat, CAN_GAS_SIZE - 1) == dat[5]) { + if (tesla_can_cksum(dat, CAN_GAS_SIZE - 1,CAN_GAS_INPUT) == dat[5]) { if (((current_index + 1U) & COUNTER_CYCLE) == index) { #ifdef DEBUG puts("setting gas "); @@ -219,8 +217,7 @@ void CAN1_RX0_IRQHandler(void) { } } -// cppcheck-suppress unusedFunction ; used in headers not included in cppcheck -void CAN1_SCE_IRQHandler(void) { +void CAN1_SCE_IRQ_Handler(void) { state = FAULT_SCE; llcan_clear_send(CAN); } @@ -231,8 +228,7 @@ unsigned int pkt_idx = 0; int led_value = 0; -// cppcheck-suppress unusedFunction ; used in headers not included in cppcheck -void TIM3_IRQHandler(void) { +void TIM3_IRQ_Handler(void) { #ifdef DEBUG puth(TIM3->CNT); puts(" "); @@ -250,7 +246,7 @@ void TIM3_IRQHandler(void) { dat[2] = (pdl1 >> 8) & 0xFFU; dat[3] = (pdl1 >> 0) & 0xFFU; dat[4] = ((state & 0xFU) << 4) | pkt_idx; - dat[5] = pedal_checksum(dat, CAN_GAS_SIZE - 1); + dat[5] = tesla_can_cksum(dat, CAN_GAS_SIZE - 1,CAN_GAS_OUTPUT); CAN->sTxMailBox[0].TDLR = dat[0] | (dat[1] << 8) | (dat[2] << 16) | (dat[3] << 24); CAN->sTxMailBox[0].TDHR = dat[4] | (dat[5] << 8); CAN->sTxMailBox[0].TDTR = 6; // len of packet is 5 @@ -288,8 +284,16 @@ void pedal(void) { // write the pedal to the DAC if (state == NO_FAULT) { - dac_set(0, MAX(gas_set_0, pdl0)); - dac_set(1, MAX(gas_set_1, pdl1)); + if (pdl0 > 500) { + dac_set(0, MAX(gas_set_0, pdl0)); + dac_set(1, MAX(gas_set_1, pdl1)); + } else if (gas_set_0 > 0) { + dac_set(0, gas_set_0); + dac_set(1, gas_set_1); + } else { + dac_set(0, pdl0); + dac_set(1, pdl1); + } } else { dac_set(0, pdl0); dac_set(1, pdl1); @@ -299,7 +303,17 @@ void pedal(void) { } int main(void) { - __disable_irq(); + // Init interrupt table + init_interrupts(true); + + REGISTER_INTERRUPT(CAN1_TX_IRQn, CAN1_TX_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) + REGISTER_INTERRUPT(CAN1_RX0_IRQn, CAN1_RX0_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) + REGISTER_INTERRUPT(CAN1_SCE_IRQn, CAN1_SCE_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) + + // Should run at around 732Hz (see init below) + REGISTER_INTERRUPT(TIM3_IRQn, TIM3_IRQ_Handler, 1000U, FAULT_INTERRUPT_RATE_TIM3) + + disable_interrupts(); // init devices clock_init(); @@ -307,6 +321,9 @@ int main(void) { detect_configuration(); detect_board_type(); + // init board + current_board->init(); + #ifdef PEDAL_USB // enable USB usb_init(); @@ -322,7 +339,8 @@ int main(void) { puts("Failed to set llcan speed"); } - llcan_init(CAN1); + bool ret = llcan_init(CAN1); + UNUSED(ret); // 48mhz / 65536 ~= 732 timer_init(TIM3, 15); @@ -331,7 +349,7 @@ int main(void) { watchdog_init(); puts("**** INTERRUPTS ON ****\n"); - __enable_irq(); + enable_interrupts(); // main pedal loop while (1) { diff --git a/panda/board/pedal_tesla/Makefile b/panda/board/pedal_tesla/Makefile index c49f7aa33aa44a..938d57426a0ca0 100644 --- a/panda/board/pedal_tesla/Makefile +++ b/panda/board/pedal_tesla/Makefile @@ -1,5 +1,8 @@ # :set noet PROJ_NAME = comma +OUT = obj + + CFLAGS = -O2 -Wall -std=gnu11 -DPEDAL CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m3 @@ -17,51 +20,66 @@ DFU_UTIL = "dfu-util" # pedal only uses the debug cert CERT = ../../certs/debug CFLAGS += "-DALLOW_DEBUG" +$(shell mkdir -p $(OUT)) +$(shell tmux kill-session -t comma) -canflash: obj/$(PROJ_NAME).bin - ../../tests/pedal/enter_canloader_tesla.py $< +canflash: $(OUT)/$(PROJ_NAME).bin + ../../tests/pedal/enter_canloader.py $< -usbflash: obj/$(PROJ_NAME).bin +usbflash: $(OUT)/$(PROJ_NAME).bin ../../tests/pedal/enter_canloader_tesla.py; sleep 0.5 - PYTHONPATH=../../ python -c "from python import Panda; p = [x for x in [Panda(x) for x in Panda.list()] if x.bootstub]; assert(len(p)==1); p[0].flash('obj/$(PROJ_NAME).bin', reconnect=False)" + PYTHONPATH=../../ python -c "from python import Panda; p = [x for x in [Panda(x) for x in Panda.list()] if x.bootstub]; assert(len(p)==1); p[0].flash('$(OUT)/$(PROJ_NAME).bin', reconnect=False)" -recover: obj/bootstub.bin obj/$(PROJ_NAME).bin +recover: $(OUT)/bootstub.bin $(OUT)/$(PROJ_NAME).bin ../../tests/pedal/enter_canloader_tesla.py --recover; sleep 0.5 - $(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08004000 -D obj/$(PROJ_NAME).bin - $(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08000000:leave -D obj/bootstub.bin + $(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08004000 -D $(OUT)/$(PROJ_NAME).bin + $(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08000000:leave -D $(OUT)/bootstub.bin + +tesla: $(OUT)/$(PROJ_NAME).bin + ../../tests/pedal/enter_canloader_tesla.py $< + +can2: $(OUT)/$(PROJ_NAME).bin + ../../tests/pedal/enter_canloader_can2.py $< + +tesla2: $(OUT)/$(PROJ_NAME).bin + ../../tests/pedal/enter_canloader_tesla2.py $< + include ../../common/version.mk -obj/cert.h: ../../crypto/getcertheader.py + +$(OUT)/cert.h: ../../crypto/getcertheader.py ../../crypto/getcertheader.py ../../certs/debug.pub ../../certs/release.pub > $@ -obj/main.o: main.c ../*.h - mkdir -p obj +$(OUT)/main.o: main.c ../*.h + mkdir -p $(OUT) $(CC) $(CFLAGS) -o $@ -c $< -obj/bootstub.o: ../bootstub.c ../*.h obj/gitversion.h obj/cert.h - mkdir -p obj - mkdir -p ../obj - cp obj/gitversion.h ../obj/gitversion.h - cp obj/cert.h ../obj/cert.h +$(OUT)/bootstub.o: ../bootstub.c ../*.h $(OUT)/gitversion.h $(OUT)/cert.h + mkdir -p $(OUT) + mkdir -p ../$(OUT) + cp $(OUT)/gitversion.h ../$(OUT)/gitversion.h + cp $(OUT)/cert.h ../$(OUT)/cert.h $(CC) $(CFLAGS) -o $@ -c $< -obj/$(STARTUP_FILE).o: ../$(STARTUP_FILE).s +$(OUT)/$(STARTUP_FILE).o: ../$(STARTUP_FILE).s $(CC) $(CFLAGS) -o $@ -c $< -obj/%.o: ../../crypto/%.c +$(OUT)/%.o: ../../crypto/%.c $(CC) $(CFLAGS) -o $@ -c $< -obj/$(PROJ_NAME).bin: obj/$(STARTUP_FILE).o obj/main.o +$(OUT)/$(PROJ_NAME).bin: $(OUT)/$(STARTUP_FILE).o $(OUT)/main.o # hack - $(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) + $(CC) -Wl,--section-start,.isr_vector=0x8004000 $(CFLAGS) -o $(OUT)/$(PROJ_NAME).elf $^ + $(OBJCOPY) -v -O binary $(OUT)/$(PROJ_NAME).elf $(OUT)/code.bin + SETLEN=1 ../../crypto/sign.py $(OUT)/code.bin $@ $(CERT) + +$(OUT)/bootstub.bin: $(OUT)/$(STARTUP_FILE).o $(OUT)/bootstub.o $(OUT)/sha.o $(OUT)/rsa.o + $(CC) $(CFLAGS) -o $(OUT)/bootstub.$(PROJ_NAME).elf $^ + $(OBJCOPY) -v -O binary $(OUT)/bootstub.$(PROJ_NAME).elf $@ + -obj/bootstub.bin: obj/$(STARTUP_FILE).o obj/bootstub.o obj/sha.o obj/rsa.o - $(CC) $(CFLAGS) -o obj/bootstub.$(PROJ_NAME).elf $^ - $(OBJCOPY) -v -O binary obj/bootstub.$(PROJ_NAME).elf $@ clean: - rm -f obj/* + rm -f $(OUT)/* diff --git a/panda/board/pedal_tesla/main.c b/panda/board/pedal_tesla/main.c index d211d439e6bef9..5c7f4ba0402b08 100644 --- a/panda/board/pedal_tesla/main.c +++ b/panda/board/pedal_tesla/main.c @@ -1,95 +1,150 @@ -//#define DEBUG -//#define CAN_LOOPBACK_MODE -//#define USE_INTERNAL_OSC - +// ********************* Includes ********************* #include "../config.h" +#include "libc.h" + +#include "main_declarations.h" -//#include "drivers/drivers.h" +#include "drivers/llcan.h" #include "drivers/llgpio.h" -#include "gpio.h" +#include "drivers/adc.h" -#define CUSTOM_CAN_INTERRUPTS +#include "board.h" -#include "libc.h" -#include "safety.h" -#include "drivers/adc.h" -#include "drivers/uart.h" +#include "drivers/clock.h" #include "drivers/dac.h" -#include "drivers/can.h" #include "drivers/timer.h" +#include "gpio.h" + #define CAN CAN1 //#define PEDAL_USB #ifdef PEDAL_USB + #include "drivers/uart.h" #include "drivers/usb.h" +#else + // no serial either + void puts(const char *a) { + UNUSED(a); + } + void puth(unsigned int i) { + UNUSED(i); + } + void puth2(unsigned int i) { + UNUSED(i); + } #endif #define ENTER_BOOTLOADER_MAGIC 0xdeadbeef uint32_t enter_bootloader_mode; -void __initialize_hardware_early() { +// cppcheck-suppress unusedFunction ; used in headers not included in cppcheck +void __initialize_hardware_early(void) { early(); } // ********************* serial debugging ********************* +#ifdef PEDAL_USB + void debug_ring_callback(uart_ring *ring) { char rcv; - while (getc(ring, &rcv)) { - putc(ring, rcv); + while (getc(ring, &rcv) != 0) { + (void)putc(ring, rcv); } } -#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) {} -void usb_cb_enumeration_complete() {} +int usb_cb_ep1_in(uint8_t *usbdata, int len, bool hardwired) { + UNUSED(usbdata); + UNUSED(len); + UNUSED(hardwired); + return 0; +} +void usb_cb_ep2_out(uint8_t *usbdata, int len, bool hardwired) { + UNUSED(usbdata); + UNUSED(len); + UNUSED(hardwired); +} +void usb_cb_ep3_out(uint8_t *usbdata, int len, bool hardwired) { + UNUSED(usbdata); + UNUSED(len); + UNUSED(hardwired); +} +void usb_cb_enumeration_complete(void) {} -int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, int hardwired) { - int resp_len = 0; +int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) { + UNUSED(hardwired); + unsigned int resp_len = 0; uart_ring *ur = NULL; switch (setup->b.bRequest) { // **** 0xe0: uart read case 0xe0: ur = get_ring_by_number(setup->b.wValue.w); - if (!ur) break; - if (ur == &esp_ring) uart_dma_drain(); + if (!ur) { + break; + } + if (ur == &esp_ring) { + uart_dma_drain(); + } // read - while ((resp_len < min(setup->b.wLength.w, MAX_RESP_LEN)) && + while ((resp_len < MIN(setup->b.wLength.w, MAX_RESP_LEN)) && getc(ur, (char*)&resp[resp_len])) { ++resp_len; } break; + default: + puts("NO HANDLER "); + puth(setup->b.bRequest); + puts("\n"); + break; } return resp_len; } #endif -// ***************************** tesla pedal checksum ***************************** -int can_cksum(uint8_t *dat, int len, int addr) { +// ***************************** pedal can checksum ***************************** + +uint8_t pedal_checksum(uint8_t *dat, int len) { + uint8_t crc = 0xFF; + uint8_t poly = 0xD5; // standard crc8 + int i, j; + for (i = len - 1; i >= 0; i--) { + crc ^= dat[i]; + for (j = 0; j < 8; j++) { + if ((crc & 0x80U) != 0U) { + crc = (uint8_t)((crc << 1) ^ poly); + } + else { + crc <<= 1; + } + } + } + return crc; +} + +// ***************************** tesla can checksum ***************************** +uint8_t tesla_can_cksum(uint8_t *dat, int len, int addr) { int i; - int s = 0; + uint8_t s = 0; s += ((addr)&0xFF) + ((addr>>8)&0xFF); for (i = 0; i < len; i++) { s = (s + dat[i]) & 0xFF; - } - return s; + } + return s; } // ***************************** can port ***************************** // addresses to be used on CAN -#define CAN_GAS_INPUT 0x551 -#define CAN_GAS_OUTPUT 0x552 +#define CAN_GAS_INPUT 0x551U +#define CAN_GAS_OUTPUT 0x552U #define CAN_GAS_SIZE 6 -#define COUNTER_CYCLE 0xF +#define COUNTER_CYCLE 0xFU -void CAN1_TX_IRQHandler() { +// cppcheck-suppress unusedFunction ; used in headers not included in cppcheck +void CAN1_TX_IRQHandler(void) { // clear interrupt CAN->TSR |= CAN_TSR_RQCP0; } @@ -98,49 +153,54 @@ void CAN1_TX_IRQHandler() { uint16_t gas_set_0 = 0; uint16_t gas_set_1 = 0; -#define MAX_TIMEOUT 10 +#define MAX_TIMEOUT 10U uint32_t timeout = 0; uint32_t current_index = 0; -#define NO_FAULT 0 -#define FAULT_BAD_CHECKSUM 1 -#define FAULT_SEND 2 -#define FAULT_SCE 3 -#define FAULT_STARTUP 4 -#define FAULT_TIMEOUT 5 -#define FAULT_INVALID 6 +#define NO_FAULT 0U +#define FAULT_BAD_CHECKSUM 1U +#define FAULT_SEND 2U +#define FAULT_SCE 3U +#define FAULT_STARTUP 4U +#define FAULT_TIMEOUT 5U +#define FAULT_INVALID 6U uint8_t state = FAULT_STARTUP; -void CAN1_RX0_IRQHandler() { - while (CAN->RF0R & CAN_RF0R_FMP0) { +// cppcheck-suppress unusedFunction ; used in headers not included in cppcheck +void CAN1_RX0_IRQHandler(void) { + while ((CAN->RF0R & CAN_RF0R_FMP0) != 0) { #ifdef DEBUG puts("CAN RX\n"); #endif - uint32_t address = CAN->sFIFOMailBox[0].RIR>>21; + int address = CAN->sFIFOMailBox[0].RIR >> 21; if (address == CAN_GAS_INPUT) { // softloader entry - if (CAN->sFIFOMailBox[0].RDLR == 0xdeadface) { - if (CAN->sFIFOMailBox[0].RDHR == 0x0ab00b1e) { + if (GET_BYTES_04(&CAN->sFIFOMailBox[0]) == 0xdeadface) { + if (GET_BYTES_48(&CAN->sFIFOMailBox[0]) == 0x0ab00b1e) { enter_bootloader_mode = ENTER_SOFTLOADER_MAGIC; NVIC_SystemReset(); - } else if (CAN->sFIFOMailBox[0].RDHR == 0x02b00b1e) { + } else if (GET_BYTES_48(&CAN->sFIFOMailBox[0]) == 0x02b00b1e) { enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC; NVIC_SystemReset(); + } else { + puts("Failed entering Softloader or Bootloader\n"); } } // normal packet - uint8_t *dat = (uint8_t *)&CAN->sFIFOMailBox[0].RDLR; - uint8_t *dat2 = (uint8_t *)&CAN->sFIFOMailBox[0].RDHR; + uint8_t dat[8]; + for (int i=0; i<8; i++) { + dat[i] = GET_BYTE(&CAN->sFIFOMailBox[0], i); + } uint16_t value_0 = (dat[0] << 8) | dat[1]; uint16_t value_1 = (dat[2] << 8) | dat[3]; - uint8_t enable = (dat2[0] >> 7) & 1; - uint8_t index = (dat2[0] ) & 0xF; - if (can_cksum(dat, 5, CAN_GAS_INPUT) == (dat2[1] & 0xFF)) { - if (((current_index+1)&0xF) == index) { + bool enable = ((dat[4] >> 7) & 1U) != 0U; + uint8_t index = dat[4] & COUNTER_CYCLE; + if (tesla_can_cksum(dat, CAN_GAS_SIZE - 1,CAN_GAS_INPUT) == dat[5]) { + if (((current_index + 1U) & COUNTER_CYCLE) == index) { #ifdef DEBUG puts("setting gas "); - puth(value); + puth(value_0); puts("\n"); #endif if (enable) { @@ -148,12 +208,13 @@ void CAN1_RX0_IRQHandler() { gas_set_1 = value_1; } else { // clear the fault state if values are 0 - if (value_0 == 0 && value_1 == 0) { + if ((value_0 == 0U) && (value_1 == 0U)) { state = NO_FAULT; } else { state = FAULT_INVALID; } - gas_set_0 = gas_set_1 = 0; + gas_set_0 = 0; + gas_set_1 = 0; } // clear the timeout timeout = 0; @@ -169,17 +230,20 @@ void CAN1_RX0_IRQHandler() { } } -void CAN1_SCE_IRQHandler() { +// cppcheck-suppress unusedFunction ; used in headers not included in cppcheck +void CAN1_SCE_IRQHandler(void) { state = FAULT_SCE; - can_sce(CAN); + llcan_clear_send(CAN); } -int pdl0 = 0, pdl1 = 0; -int pkt_idx = 0; +uint32_t pdl0 = 0; +uint32_t pdl1 = 0; +unsigned int pkt_idx = 0; int led_value = 0; -void TIM3_IRQHandler() { +// cppcheck-suppress unusedFunction ; used in headers not included in cppcheck +void TIM3_IRQHandler(void) { #ifdef DEBUG puth(TIM3->CNT); puts(" "); @@ -192,18 +256,18 @@ void TIM3_IRQHandler() { // check timer for sending the user pedal and clearing the CAN if ((CAN->TSR & CAN_TSR_TME0) == CAN_TSR_TME0) { uint8_t dat[8]; - dat[0] = (pdl0>>8)&0xFF; - dat[1] = (pdl0>>0)&0xFF; - dat[2] = (pdl1>>8)&0xFF; - dat[3] = (pdl1>>0)&0xFF; - dat[4] = ((state<<0) | (pkt_idx<<4))&0xFF; - dat[5] = can_cksum(dat, 5, CAN_GAS_OUTPUT); - CAN->sTxMailBox[0].TDLR = dat[0] | (dat[1]<<8) | (dat[2]<<16) | (dat[3]<<24); - CAN->sTxMailBox[0].TDHR = dat[4] | (dat[5]<<8); + dat[0] = (pdl0 >> 8) & 0xFFU; + dat[1] = (pdl0 >> 0) & 0xFFU; + dat[2] = (pdl1 >> 8) & 0xFFU; + dat[3] = (pdl1 >> 0) & 0xFFU; + dat[4] = ((state & 0xFU) << 4) | pkt_idx; + dat[5] = tesla_can_cksum(dat, CAN_GAS_SIZE - 1,CAN_GAS_OUTPUT); + CAN->sTxMailBox[0].TDLR = dat[0] | (dat[1] << 8) | (dat[2] << 16) | (dat[3] << 24); + CAN->sTxMailBox[0].TDHR = dat[4] | (dat[5] << 8); CAN->sTxMailBox[0].TDTR = 6; // len of packet is 5 - CAN->sTxMailBox[0].TIR = (CAN_GAS_OUTPUT << 21) | 1; + CAN->sTxMailBox[0].TIR = (CAN_GAS_OUTPUT << 21) | 1U; ++pkt_idx; - pkt_idx &= 0xF; + pkt_idx &= COUNTER_CYCLE; } else { // old can packet hasn't sent! state = FAULT_SEND; @@ -213,7 +277,7 @@ void TIM3_IRQHandler() { } // blink the LED - set_led(LED_GREEN, led_value); + current_board->set_led(LED_GREEN, led_value); led_value = !led_value; TIM3->SR = 0; @@ -222,13 +286,13 @@ void TIM3_IRQHandler() { if (timeout == MAX_TIMEOUT) { state = FAULT_TIMEOUT; } else { - timeout += 1; + timeout += 1U; } } // ***************************** main code ***************************** -void pedal() { +void pedal(void) { // read/write pdl0 = adc_get(ADCCHAN_ACCEL0); pdl1 = adc_get(ADCCHAN_ACCEL1); @@ -236,8 +300,8 @@ void pedal() { // write the pedal to the DAC if (state == NO_FAULT) { if (pdl0 > 500) { - dac_set(0, max(gas_set_0, pdl0)); - dac_set(1, max(gas_set_1, pdl1)); + dac_set(0, MAX(gas_set_0, pdl0)); + dac_set(1, MAX(gas_set_1, pdl1)); } else if (gas_set_0 > 0) { dac_set(0, gas_set_0); dac_set(1, gas_set_1); @@ -250,17 +314,17 @@ void pedal() { dac_set(1, pdl1); } - // feed the watchdog - IWDG->KR = 0xAAAA; + watchdog_feed(); } -int main() { +int main(void) { __disable_irq(); // init devices clock_init(); - periph_init(); - gpio_init(); + peripherals_init(); + detect_configuration(); + detect_board_type(); #ifdef PEDAL_USB // enable USB @@ -272,19 +336,18 @@ int main() { adc_init(); // init can - can_silent = ALL_CAN_LIVE; - can_init(0); + bool llcan_speed_set = llcan_set_speed(CAN1, 5000, false, false); + if (!llcan_speed_set) { + puts("Failed to set llcan speed"); + } + + 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(); @@ -296,4 +359,3 @@ int main() { return 0; } - diff --git a/panda/board/pedal_tesla/main_declarations.h b/panda/board/pedal_tesla/main_declarations.h new file mode 100644 index 00000000000000..9a40f8ae3af447 --- /dev/null +++ b/panda/board/pedal_tesla/main_declarations.h @@ -0,0 +1,11 @@ +// ******************** Prototypes ******************** +void puts(const char *a); +void puth(unsigned int i); +void puth2(unsigned int i); +typedef struct board board; +typedef struct harness_configuration harness_configuration; + +// ********************* Globals ********************** +uint8_t hw_type = 0; +const board *current_board; +bool is_enumerated = 0; \ No newline at end of file diff --git a/panda/board/power_saving.h b/panda/board/power_saving.h index 94ebbb53cf9a0a..9805411470ec69 100644 --- a/panda/board/power_saving.h +++ b/panda/board/power_saving.h @@ -1,4 +1,7 @@ -#define POWER_SAVE_STATUS_DISABLED 0 +// WARNING: To stay in compliance with the SIL2 rules laid out in STM UM1840, we should never implement any of the available hardware low power modes. +// See rule: CoU_3 + +#define POWER_SAVE_STATUS_DISABLED 1 #define POWER_SAVE_STATUS_ENABLED 1 int power_save_status = POWER_SAVE_STATUS_DISABLED; @@ -25,19 +28,32 @@ void set_power_save_state(int state) { enable = true; } - // Switch CAN transcievers - current_board->enable_can_transcievers(enable); + current_board->enable_can_transceivers(enable); + + // Switch EPS/GPS + if (enable) { + current_board->set_gps_mode(GPS_ENABLED); + } else { + current_board->set_gps_mode(GPS_DISABLED); + } - if(hw_type != HW_TYPE_BLACK_PANDA){ + if(board_has_gmlan()){ // turn on GMLAN set_gpio_output(GPIOB, 14, enable); set_gpio_output(GPIOB, 15, enable); + } - // turn on LIN + if(board_has_lin()){ + // turn on LIN set_gpio_output(GPIOB, 7, enable); set_gpio_output(GPIOA, 14, enable); } + // Switch off IR when in power saving + if(!enable){ + current_board->set_ir_power(0U); + } + power_save_status = state; } } diff --git a/panda/board/provision.h b/panda/board/provision.h index 9091322f1a1091..0b09d8ff8be337 100644 --- a/panda/board/provision.h +++ b/panda/board/provision.h @@ -11,3 +11,9 @@ void get_provision_chunk(uint8_t *resp) { } } +uint8_t chunk[PROVISION_CHUNK_LEN]; +bool is_provisioned(void) { + (void)memcpy(chunk, (uint8_t *)0x1fff79e0, PROVISION_CHUNK_LEN); + return (memcmp(chunk, "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", 0x20) != 0); +} + diff --git a/panda/board/safety.h b/panda/board/safety.h index d56f640a3e00b4..5ec8a639cdecd5 100644 --- a/panda/board/safety.h +++ b/panda/board/safety.h @@ -4,21 +4,47 @@ #include "safety/safety_defaults.h" #include "safety/safety_honda.h" #include "safety/safety_toyota.h" -#include "safety/safety_toyota_ipas.h" #include "safety/safety_tesla.h" #include "safety/safety_gm_ascm.h" #include "safety/safety_gm.h" #include "safety/safety_ford.h" -#include "safety/safety_cadillac.h" #include "safety/safety_hyundai.h" #include "safety/safety_chrysler.h" #include "safety/safety_subaru.h" +#include "safety/safety_mazda.h" +#include "safety/safety_nissan.h" +#include "safety/safety_volkswagen.h" #include "safety/safety_elm327.h" +// from cereal.car.CarParams.SafetyModel +#define SAFETY_SILENT 0U +#define SAFETY_HONDA_NIDEC 1U +#define SAFETY_TOYOTA 2U +#define SAFETY_ELM327 3U +#define SAFETY_GM 4U +#define SAFETY_HONDA_BOSCH_GIRAFFE 5U +#define SAFETY_FORD 6U +#define SAFETY_HYUNDAI 8U +#define SAFETY_CHRYSLER 9U +#define SAFETY_TESLA 10U +#define SAFETY_SUBARU 11U +#define SAFETY_MAZDA 13U +#define SAFETY_NISSAN 14U +#define SAFETY_VOLKSWAGEN_MQB 15U +#define SAFETY_ALLOUTPUT 17U +#define SAFETY_GM_ASCM 18U +#define SAFETY_NOOUTPUT 19U +#define SAFETY_HONDA_BOSCH_HARNESS 20U +#define SAFETY_VOLKSWAGEN_PQ 21U +#define SAFETY_SUBARU_LEGACY 22U +#define SAFETY_HYUNDAI_LEGACY 23U +#define SAFETY_HYUNDAI_COMMUNITY 24U + +uint16_t current_safety_mode = SAFETY_SILENT; const safety_hooks *current_hooks = &nooutput_hooks; -void safety_rx_hook(CAN_FIFOMailBox_TypeDef *to_push){ - current_hooks->rx(to_push); +int safety_rx_hook(CAN_FIFOMailBox_TypeDef *to_push){ + return current_hooks->rx(to_push); } int safety_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { @@ -29,68 +55,265 @@ int safety_tx_lin_hook(int lin_num, uint8_t *data, int len){ return current_hooks->tx_lin(lin_num, data, len); } -// -1 = Disabled (Use GPIO to determine ignition) -// 0 = Off (not started) -// 1 = On (started) -int safety_ignition_hook() { - return current_hooks->ignition(); -} int safety_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { return current_hooks->fwd(bus_num, to_fwd); } +// Given a CRC-8 poly, generate a static lookup table to use with a fast CRC-8 +// algorithm. Called at init time for safety modes using CRC-8. +void gen_crc_lookup_table(uint8_t poly, uint8_t crc_lut[]) { + for (int i = 0; i < 256; i++) { + uint8_t crc = i; + for (int j = 0; j < 8; j++) { + if ((crc & 0x80U) != 0U) + crc = (uint8_t)((crc << 1) ^ poly); + else + crc <<= 1; + } + crc_lut[i] = crc; + } +} + +bool msg_allowed(CAN_FIFOMailBox_TypeDef *to_send, const CanMsg msg_list[], int len) { + int addr = GET_ADDR(to_send); + int bus = GET_BUS(to_send); + int length = GET_LEN(to_send); + + bool allowed = false; + for (int i = 0; i < len; i++) { + if ((addr == msg_list[i].addr) && (bus == msg_list[i].bus) && (length == msg_list[i].len)) { + allowed = true; + break; + } + } + return allowed; +} + +// compute the time elapsed (in microseconds) from 2 counter samples +// case where ts < ts_last is ok: overflow is properly re-casted into uint32_t +uint32_t get_ts_elapsed(uint32_t ts, uint32_t ts_last) { + return ts - ts_last; +} + +int get_addr_check_index(CAN_FIFOMailBox_TypeDef *to_push, AddrCheckStruct addr_list[], const int len) { + int bus = GET_BUS(to_push); + int addr = GET_ADDR(to_push); + int length = GET_LEN(to_push); + + int index = -1; + for (int i = 0; i < len; i++) { + // if multiple msgs are allowed, determine which one is present on the bus + if (!addr_list[i].msg_seen) { + for (uint8_t j = 0U; addr_list[i].msg[j].addr != 0; j++) { + if ((addr == addr_list[i].msg[j].addr) && (bus == addr_list[i].msg[j].bus) && + (length == addr_list[i].msg[j].len)) { + addr_list[i].index = j; + addr_list[i].msg_seen = true; + break; + } + } + } + + int idx = addr_list[i].index; + if ((addr == addr_list[i].msg[idx].addr) && (bus == addr_list[i].msg[idx].bus) && + (length == addr_list[i].msg[idx].len)) { + index = i; + break; + } + } + return index; +} + +// 1Hz safety function called by main. Now just a check for lagging safety messages +void safety_tick(const safety_hooks *hooks) { + uint32_t ts = TIM2->CNT; + if (hooks->addr_check != NULL) { + for (int i=0; i < hooks->addr_check_len; i++) { + uint32_t elapsed_time = get_ts_elapsed(ts, hooks->addr_check[i].last_timestamp); + // lag threshold is max of: 1s and MAX_MISSED_MSGS * expected timestep. + // Quite conservative to not risk false triggers. + // 2s of lag is worse case, since the function is called at 1Hz + bool lagging = elapsed_time > MAX(hooks->addr_check[i].msg[hooks->addr_check[i].index].expected_timestep * MAX_MISSED_MSGS, 1e6); + hooks->addr_check[i].lagging = lagging; + if (lagging) { + controls_allowed = 0; + } + } + } +} + +void update_counter(AddrCheckStruct addr_list[], int index, uint8_t counter) { + if (index != -1) { + uint8_t expected_counter = (addr_list[index].last_counter + 1U) % (addr_list[index].msg[addr_list[index].index].max_counter + 1U); + addr_list[index].wrong_counters += (expected_counter == counter) ? -1 : 1; + addr_list[index].wrong_counters = MAX(MIN(addr_list[index].wrong_counters, MAX_WRONG_COUNTERS), 0); + addr_list[index].last_counter = counter; + } +} + +bool is_msg_valid(AddrCheckStruct addr_list[], int index) { + bool valid = true; + if (index != -1) { + if ((!addr_list[index].valid_checksum) || (addr_list[index].wrong_counters >= MAX_WRONG_COUNTERS)) { + valid = false; + controls_allowed = 0; + } + } + return valid; +} + +void update_addr_timestamp(AddrCheckStruct addr_list[], int index) { + if (index != -1) { + uint32_t ts = TIM2->CNT; + addr_list[index].last_timestamp = ts; + } +} + +bool addr_safety_check(CAN_FIFOMailBox_TypeDef *to_push, + AddrCheckStruct *rx_checks, + const int rx_checks_len, + uint8_t (*get_checksum)(CAN_FIFOMailBox_TypeDef *to_push), + uint8_t (*compute_checksum)(CAN_FIFOMailBox_TypeDef *to_push), + uint8_t (*get_counter)(CAN_FIFOMailBox_TypeDef *to_push)) { + + int index = get_addr_check_index(to_push, rx_checks, rx_checks_len); + update_addr_timestamp(rx_checks, index); + + if (index != -1) { + // checksum check + if ((get_checksum != NULL) && (compute_checksum != NULL) && rx_checks[index].msg[rx_checks[index].index].check_checksum) { + uint8_t checksum = get_checksum(to_push); + uint8_t checksum_comp = compute_checksum(to_push); + rx_checks[index].valid_checksum = checksum_comp == checksum; + } else { + rx_checks[index].valid_checksum = true; + } + + // counter check (max_counter == 0 means skip check) + if ((get_counter != NULL) && (rx_checks[index].msg[rx_checks[index].index].max_counter > 0U)) { + uint8_t counter = get_counter(to_push); + update_counter(rx_checks, index, counter); + } else { + rx_checks[index].wrong_counters = 0U; + } + } + return is_msg_valid(rx_checks, index); +} + +void generic_rx_checks(bool stock_ecu_detected) { + // exit controls on rising edge of gas press + if (gas_pressed && !gas_pressed_prev && !(unsafe_mode & UNSAFE_DISABLE_DISENGAGE_ON_GAS)) { + controls_allowed = 0; + } + gas_pressed_prev = gas_pressed; + + // exit controls on rising edge of brake press + if (brake_pressed && (!brake_pressed_prev || vehicle_moving)) { + controls_allowed = 0; + } + brake_pressed_prev = brake_pressed; + + // check if stock ECU is on bus broken by car harness + if ((safety_mode_cnt > RELAY_TRNS_TIMEOUT) && stock_ecu_detected) { + relay_malfunction_set(); + } +} + +void relay_malfunction_set(void) { + relay_malfunction = true; + fault_occurred(FAULT_RELAY_MALFUNCTION); +} + +void relay_malfunction_reset(void) { + relay_malfunction = false; + fault_recovered(FAULT_RELAY_MALFUNCTION); +} + typedef struct { uint16_t id; const safety_hooks *hooks; } safety_hook_config; -#define SAFETY_NOOUTPUT 0U -#define SAFETY_HONDA 1U -#define SAFETY_TOYOTA 2U -#define SAFETY_GM 3U -#define SAFETY_HONDA_BOSCH 4U -#define SAFETY_FORD 5U -#define SAFETY_CADILLAC 6U -#define SAFETY_HYUNDAI 7U -#define SAFETY_TESLA 8U -#define SAFETY_CHRYSLER 9U -#define SAFETY_SUBARU 10U -#define SAFETY_GM_ASCM 0x1334U -#define SAFETY_TOYOTA_IPAS 0x1335U -#define SAFETY_ALLOUTPUT 0x1337U -#define SAFETY_ELM327 0xE327U - const safety_hook_config safety_hook_registry[] = { - {SAFETY_NOOUTPUT, &nooutput_hooks}, - {SAFETY_HONDA, &honda_hooks}, - {SAFETY_HONDA_BOSCH, &honda_bosch_hooks}, + {SAFETY_SILENT, &nooutput_hooks}, + {SAFETY_HONDA_NIDEC, &honda_nidec_hooks}, {SAFETY_TOYOTA, &toyota_hooks}, + {SAFETY_ELM327, &elm327_hooks}, {SAFETY_GM, &gm_hooks}, - {SAFETY_FORD, &ford_hooks}, - {SAFETY_CADILLAC, &cadillac_hooks}, + {SAFETY_HONDA_BOSCH_GIRAFFE, &honda_bosch_giraffe_hooks}, + {SAFETY_HONDA_BOSCH_HARNESS, &honda_bosch_harness_hooks}, {SAFETY_HYUNDAI, &hyundai_hooks}, {SAFETY_CHRYSLER, &chrysler_hooks}, {SAFETY_SUBARU, &subaru_hooks}, - {SAFETY_TOYOTA_IPAS, &toyota_ipas_hooks}, - {SAFETY_GM_ASCM, &gm_ascm_hooks}, + {SAFETY_VOLKSWAGEN_MQB, &volkswagen_mqb_hooks}, + {SAFETY_NISSAN, &nissan_hooks}, + {SAFETY_NOOUTPUT, &nooutput_hooks}, + {SAFETY_HYUNDAI_LEGACY, &hyundai_legacy_hooks}, +#ifdef ALLOW_DEBUG + {SAFETY_MAZDA, &mazda_hooks}, + {SAFETY_SUBARU_LEGACY, &subaru_legacy_hooks}, + {SAFETY_VOLKSWAGEN_PQ, &volkswagen_pq_hooks}, {SAFETY_TESLA, &tesla_hooks}, {SAFETY_ALLOUTPUT, &alloutput_hooks}, - {SAFETY_ELM327, &elm327_hooks}, + {SAFETY_GM_ASCM, &gm_ascm_hooks}, + {SAFETY_FORD, &ford_hooks}, +#endif }; int current_safety = -1; -int safety_set_mode(uint16_t mode, int16_t param) { - int set_status = -1; // not set - int hook_config_count = sizeof(safety_hook_registry) / sizeof(safety_hook_config); +int set_safety_hooks(uint16_t mode, int16_t param) { + //BB prevent resetting if already in the correct mode + UNUSED(mode); + UNUSED(param); + return 1; +} + +int set_safety_hooks2(uint16_t mode, int16_t param) { + // reset state set by safety mode + safety_mode_cnt = 0U; // reset safety mode timer + //BB prevent resetting if already in the correct mode if ((mode > 0) && (current_safety == mode)) { return 1; } + + relay_malfunction = false; + gas_interceptor_detected = false; + gas_interceptor_prev = 0; + gas_pressed = false; + gas_pressed_prev = false; + brake_pressed = false; + brake_pressed_prev = false; + cruise_engaged_prev = false; + vehicle_speed = 0; + vehicle_moving = false; + desired_torque_last = 0; + rt_torque_last = 0; + ts_angle_last = 0; + desired_angle_last = 0; + ts_last = 0; + + torque_meas.max = 0; + torque_meas.max = 0; + torque_driver.min = 0; + torque_driver.max = 0; + angle_meas.min = 0; + angle_meas.max = 0; + + int set_status = -1; // not set + int hook_config_count = sizeof(safety_hook_registry) / sizeof(safety_hook_config); + for (int i = 0; i < hook_config_count; i++) { if (safety_hook_registry[i].id == mode) { current_hooks = safety_hook_registry[i].hooks; - set_status = 0; // set - break; + current_safety_mode = safety_hook_registry[i].id; + set_status = 0; // set + } + + // reset message index and seen flags in addr struct + for (int j = 0; j < safety_hook_registry[i].hooks->addr_check_len; j++) { + safety_hook_registry[i].hooks->addr_check[j].index = 0; + safety_hook_registry[i].hooks->addr_check[j].msg_seen = false; } } if ((set_status == 0) && (current_hooks->init != NULL)) { @@ -99,12 +322,6 @@ int safety_set_mode(uint16_t mode, int16_t param) { return set_status; } -// compute the time elapsed (in microseconds) from 2 counter samples -// case where ts < ts_last is ok: overflow is properly re-casted into uint32_t -uint32_t get_ts_elapsed(uint32_t ts, uint32_t ts_last) { - return ts - ts_last; -} - // convert a trimmed integer to signed 32 bit int int to_signed(int d, int bits) { int d_signed = d; @@ -207,7 +424,7 @@ float interpolate(struct lookup_t xy, float x) { float y0 = xy.y[i]; float dx = xy.x[i+1] - x0; float dy = xy.y[i+1] - y0; - // dx should not be zero as xy.x is supposed ot be monotonic + // dx should not be zero as xy.x is supposed to be monotonic if (dx <= 0.) { dx = 0.0001; } diff --git a/panda/board/safety/safety_cadillac.h b/panda/board/safety/safety_cadillac.h deleted file mode 100644 index ef63360955fe7f..00000000000000 --- a/panda/board/safety/safety_cadillac.h +++ /dev/null @@ -1,135 +0,0 @@ -#define CADILLAC_TORQUE_MSG_N 4 // 4 torque messages: 0x151, 0x152, 0x153, 0x154 - -const int CADILLAC_MAX_STEER = 150; // 1s -// real time torque limit to prevent controls spamming -// the real time limit is 1500/sec -const int CADILLAC_MAX_RT_DELTA = 75; // max delta torque allowed for real time checks -const uint32_t CADILLAC_RT_INTERVAL = 250000; // 250ms between real time checks -const int CADILLAC_MAX_RATE_UP = 2; -const int CADILLAC_MAX_RATE_DOWN = 5; -const int CADILLAC_DRIVER_TORQUE_ALLOWANCE = 50; -const int CADILLAC_DRIVER_TORQUE_FACTOR = 4; - -bool cadillac_ign = 0; -int cadillac_cruise_engaged_last = 0; -int cadillac_rt_torque_last = 0; -const int cadillac_torque_msgs_n = 4; -int cadillac_desired_torque_last[CADILLAC_TORQUE_MSG_N] = {0}; -uint32_t cadillac_ts_last = 0; -bool cadillac_supercruise_on = 0; -struct sample_t cadillac_torque_driver; // last few driver torques measured - -int cadillac_get_torque_idx(int addr, int array_size) { - return MIN(MAX(addr - 0x151, 0), array_size); // 0x151 is id 0, 0x152 is id 1 and so on... -} - -static void cadillac_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { - int bus = GET_BUS(to_push); - int addr = GET_ADDR(to_push); - - if (addr == 356) { - int torque_driver_new = ((GET_BYTE(to_push, 0) & 0x7U) << 8) | (GET_BYTE(to_push, 1)); - - torque_driver_new = to_signed(torque_driver_new, 11); - // update array of samples - update_sample(&cadillac_torque_driver, torque_driver_new); - } - - // this message isn't all zeros when ignition is on - if ((addr == 0x160) && (bus == 0)) { - cadillac_ign = GET_BYTES_04(to_push) != 0; - } - - // enter controls on rising edge of ACC, exit controls on ACC off - if ((addr == 0x370) && (bus == 0)) { - int cruise_engaged = GET_BYTE(to_push, 2) & 0x80; // bit 23 - if (cruise_engaged && !cadillac_cruise_engaged_last) { - controls_allowed = 1; - } - if (!cruise_engaged) { - controls_allowed = 0; - } - cadillac_cruise_engaged_last = cruise_engaged; - } - - // know supercruise mode and block openpilot msgs if on - if ((addr == 0x152) || (addr == 0x154)) { - cadillac_supercruise_on = (GET_BYTE(to_push, 4) & 0x10) != 0; - } -} - -static int cadillac_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { - int tx = 1; - int addr = GET_ADDR(to_send); - - // steer cmd checks - if ((addr == 0x151) || (addr == 0x152) || (addr == 0x153) || (addr == 0x154)) { - int desired_torque = ((GET_BYTE(to_send, 0) & 0x3f) << 8) | GET_BYTE(to_send, 1); - int violation = 0; - uint32_t ts = TIM2->CNT; - int idx = cadillac_get_torque_idx(addr, CADILLAC_TORQUE_MSG_N); - desired_torque = to_signed(desired_torque, 14); - - if (controls_allowed) { - - // *** global torque limit check *** - violation |= max_limit_check(desired_torque, CADILLAC_MAX_STEER, -CADILLAC_MAX_STEER); - - // *** torque rate limit check *** - int desired_torque_last = cadillac_desired_torque_last[idx]; - violation |= driver_limit_check(desired_torque, desired_torque_last, &cadillac_torque_driver, - CADILLAC_MAX_STEER, CADILLAC_MAX_RATE_UP, CADILLAC_MAX_RATE_DOWN, - CADILLAC_DRIVER_TORQUE_ALLOWANCE, CADILLAC_DRIVER_TORQUE_FACTOR); - - // used next time - cadillac_desired_torque_last[idx] = desired_torque; - - // *** torque real time rate limit check *** - violation |= rt_rate_limit_check(desired_torque, cadillac_rt_torque_last, CADILLAC_MAX_RT_DELTA); - - // every RT_INTERVAL set the new limits - uint32_t ts_elapsed = get_ts_elapsed(ts, cadillac_ts_last); - if (ts_elapsed > CADILLAC_RT_INTERVAL) { - cadillac_rt_torque_last = desired_torque; - cadillac_ts_last = ts; - } - } - - // no torque if controls is not allowed - if (!controls_allowed && (desired_torque != 0)) { - violation = 1; - } - - // reset to 0 if either controls is not allowed or there's a violation - if (violation || !controls_allowed) { - cadillac_desired_torque_last[idx] = 0; - cadillac_rt_torque_last = 0; - cadillac_ts_last = ts; - } - - if (violation || cadillac_supercruise_on) { - tx = 0; - } - - } - return tx; -} - -static void cadillac_init(int16_t param) { - UNUSED(param); - controls_allowed = 0; - cadillac_ign = 0; -} - -static int cadillac_ign_hook(void) { - return cadillac_ign; -} - -const safety_hooks cadillac_hooks = { - .init = cadillac_init, - .rx = cadillac_rx_hook, - .tx = cadillac_tx_hook, - .tx_lin = nooutput_tx_lin_hook, - .ignition = cadillac_ign_hook, - .fwd = default_fwd_hook, -}; diff --git a/panda/board/safety/safety_chrysler.h b/panda/board/safety/safety_chrysler.h index e608785739b109..044485cb6bc03d 100644 --- a/panda/board/safety/safety_chrysler.h +++ b/panda/board/safety/safety_chrysler.h @@ -4,55 +4,130 @@ const uint32_t CHRYSLER_RT_INTERVAL = 250000; // 250ms between real time checks const int CHRYSLER_MAX_RATE_UP = 3; const int CHRYSLER_MAX_RATE_DOWN = 3; const int CHRYSLER_MAX_TORQUE_ERROR = 80; // max torque cmd in excess of torque motor +const int CHRYSLER_GAS_THRSLD = 30; // 7% more than 2m/s +const int CHRYSLER_STANDSTILL_THRSLD = 10; // about 1m/s +const CanMsg CHRYSLER_TX_MSGS[] = {{571, 0, 3}, {658, 0, 6}, {678, 0, 8}}; + +AddrCheckStruct chrysler_rx_checks[] = { + {.msg = {{544, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}}}, + {.msg = {{514, 0, 8, .check_checksum = false, .max_counter = 0U, .expected_timestep = 10000U}}}, + {.msg = {{500, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}}}, + {.msg = {{308, 0, 8, .check_checksum = false, .max_counter = 15U, .expected_timestep = 20000U}}}, + {.msg = {{320, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}}}, +}; +const int CHRYSLER_RX_CHECK_LEN = sizeof(chrysler_rx_checks) / sizeof(chrysler_rx_checks[0]); -bool chrysler_camera_detected = 0; // is giraffe switch 2 high? -int chrysler_rt_torque_last = 0; -int chrysler_desired_torque_last = 0; -int chrysler_cruise_engaged_last = 0; -uint32_t chrysler_ts_last = 0; -struct sample_t chrysler_torque_meas; // last few torques measured +static uint8_t chrysler_get_checksum(CAN_FIFOMailBox_TypeDef *to_push) { + int checksum_byte = GET_LEN(to_push) - 1; + return (uint8_t)(GET_BYTE(to_push, checksum_byte)); +} -static void chrysler_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { - int bus = GET_BUS(to_push); - int addr = GET_ADDR(to_push); +static uint8_t chrysler_compute_checksum(CAN_FIFOMailBox_TypeDef *to_push) { + /* This function does not want the checksum byte in the input data. + jeep chrysler canbus checksum from http://illmatics.com/Remote%20Car%20Hacking.pdf */ + uint8_t checksum = 0xFF; + int len = GET_LEN(to_push); + for (int j = 0; j < (len - 1); j++) { + uint8_t shift = 0x80; + uint8_t curr = (uint8_t)GET_BYTE(to_push, j); + for (int i=0; i<8; i++) { + uint8_t bit_sum = curr & shift; + uint8_t temp_chk = checksum & 0x80U; + if (bit_sum != 0U) { + bit_sum = 0x1C; + if (temp_chk != 0U) { + bit_sum = 1; + } + checksum = checksum << 1; + temp_chk = checksum | 1U; + bit_sum ^= temp_chk; + } else { + if (temp_chk != 0U) { + bit_sum = 0x1D; + } + checksum = checksum << 1; + bit_sum ^= checksum; + } + checksum = bit_sum; + shift = shift >> 1; + } + } + return ~checksum; +} + +static uint8_t chrysler_get_counter(CAN_FIFOMailBox_TypeDef *to_push) { + // Well defined counter only for 8 bytes messages + return (uint8_t)(GET_BYTE(to_push, 6) >> 4); +} - // Measured eps torque - if (addr == 544) { - int torque_meas_new = ((GET_BYTE(to_push, 4) & 0x7U) << 8) + GET_BYTE(to_push, 5) - 1024U; +static int chrysler_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { - // update array of samples - update_sample(&chrysler_torque_meas, torque_meas_new); - } + bool valid = addr_safety_check(to_push, chrysler_rx_checks, CHRYSLER_RX_CHECK_LEN, + chrysler_get_checksum, chrysler_compute_checksum, + chrysler_get_counter); - // enter controls on rising edge of ACC, exit controls on ACC off - if (addr == 0x1F4) { - int cruise_engaged = ((GET_BYTE(to_push, 2) & 0x38) >> 3) == 7; - if (cruise_engaged && !chrysler_cruise_engaged_last) { - controls_allowed = 1; + if (valid && (GET_BUS(to_push) == 0)) { + int addr = GET_ADDR(to_push); + + // Measured eps torque + if (addr == 544) { + int torque_meas_new = ((GET_BYTE(to_push, 4) & 0x7U) << 8) + GET_BYTE(to_push, 5) - 1024U; + + // update array of samples + update_sample(&torque_meas, torque_meas_new); } - if (!cruise_engaged) { - controls_allowed = 0; + + // enter controls on rising edge of ACC, exit controls on ACC off + if (addr == 500) { + int cruise_engaged = ((GET_BYTE(to_push, 2) & 0x38) >> 3) == 7; + if (cruise_engaged && !cruise_engaged_prev) { + controls_allowed = 1; + } + if (!cruise_engaged) { + controls_allowed = 0; + } + cruise_engaged_prev = cruise_engaged; + } + + // update speed + if (addr == 514) { + int speed_l = (GET_BYTE(to_push, 0) << 4) + (GET_BYTE(to_push, 1) >> 4); + int speed_r = (GET_BYTE(to_push, 2) << 4) + (GET_BYTE(to_push, 3) >> 4); + vehicle_speed = (speed_l + speed_r) / 2; + vehicle_moving = (int)vehicle_speed > CHRYSLER_STANDSTILL_THRSLD; } - chrysler_cruise_engaged_last = cruise_engaged; - } - // check if stock camera ECU is still online - if ((bus == 0) && (addr == 0x292)) { - chrysler_camera_detected = 1; - controls_allowed = 0; + // exit controls on rising edge of gas press + if (addr == 308) { + gas_pressed = ((GET_BYTE(to_push, 5) & 0x7F) != 0) && ((int)vehicle_speed > CHRYSLER_GAS_THRSLD); + } + + // exit controls on rising edge of brake press + if (addr == 320) { + brake_pressed = (GET_BYTE(to_push, 0) & 0x7) == 5; + if (brake_pressed && (!brake_pressed_prev || vehicle_moving)) { + controls_allowed = 0; + } + brake_pressed_prev = brake_pressed; + } + + generic_rx_checks((addr == 0x292)); } + return valid; } static int chrysler_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int tx = 1; + int addr = GET_ADDR(to_send); - // If camera is on bus 0, then nothing can be sent - if (chrysler_camera_detected) { + if (!msg_allowed(to_send, CHRYSLER_TX_MSGS, sizeof(CHRYSLER_TX_MSGS) / sizeof(CHRYSLER_TX_MSGS[0]))) { tx = 0; } - int addr = GET_ADDR(to_send); + if (relay_malfunction) { + tx = 0; + } // LKA STEER if (addr == 0x292) { @@ -66,20 +141,20 @@ static int chrysler_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { violation |= max_limit_check(desired_torque, CHRYSLER_MAX_STEER, -CHRYSLER_MAX_STEER); // *** torque rate limit check *** - violation |= dist_to_meas_check(desired_torque, chrysler_desired_torque_last, - &chrysler_torque_meas, CHRYSLER_MAX_RATE_UP, CHRYSLER_MAX_RATE_DOWN, CHRYSLER_MAX_TORQUE_ERROR); + violation |= dist_to_meas_check(desired_torque, desired_torque_last, + &torque_meas, CHRYSLER_MAX_RATE_UP, CHRYSLER_MAX_RATE_DOWN, CHRYSLER_MAX_TORQUE_ERROR); // used next time - chrysler_desired_torque_last = desired_torque; + desired_torque_last = desired_torque; // *** torque real time rate limit check *** - violation |= rt_rate_limit_check(desired_torque, chrysler_rt_torque_last, CHRYSLER_MAX_RT_DELTA); + violation |= rt_rate_limit_check(desired_torque, rt_torque_last, CHRYSLER_MAX_RT_DELTA); // every RT_INTERVAL set the new limits - uint32_t ts_elapsed = get_ts_elapsed(ts, chrysler_ts_last); + uint32_t ts_elapsed = get_ts_elapsed(ts, ts_last); if (ts_elapsed > CHRYSLER_RT_INTERVAL) { - chrysler_rt_torque_last = desired_torque; - chrysler_ts_last = ts; + rt_torque_last = desired_torque; + ts_last = ts; } } @@ -90,9 +165,9 @@ static int chrysler_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { // reset to 0 if either controls is not allowed or there's a violation if (violation || !controls_allowed) { - chrysler_desired_torque_last = 0; - chrysler_rt_torque_last = 0; - chrysler_ts_last = ts; + desired_torque_last = 0; + rt_torque_last = 0; + ts_last = ts; } if (violation) { @@ -100,42 +175,41 @@ static int chrysler_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { } } - // FORCE CANCEL: safety check only relevant when spamming the cancel button. - // ensuring that only the cancel button press is sent when controls are off. - // This avoids unintended engagements while still allowing resume spam - // TODO: fix bug preventing the button msg to be fwd'd on bus 2 + // FORCE CANCEL: only the cancel button press is allowed + if (addr == 571) { + if ((GET_BYTE(to_send, 0) != 1) || ((GET_BYTE(to_send, 1) & 1) == 1)) { + tx = 0; + } + } - // 1 allows the message through return tx; } -static void chrysler_init(int16_t param) { - UNUSED(param); - controls_allowed = 0; - chrysler_camera_detected = 0; -} - static int chrysler_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { int bus_fwd = -1; int addr = GET_ADDR(to_fwd); - // forward CAN 0 -> 2 so stock LKAS camera sees messages - if ((bus_num == 0) && !chrysler_camera_detected) { - bus_fwd = 2; - } - // forward all messages from camera except LKAS_COMMAND and LKAS_HUD - if ((bus_num == 2) && !chrysler_camera_detected && (addr != 658) && (addr != 678)) { - bus_fwd = 0; + + if (!relay_malfunction) { + // forward CAN 0 -> 2 so stock LKAS camera sees messages + if (bus_num == 0) { + bus_fwd = 2; + } + // forward all messages from camera except LKAS_COMMAND and LKAS_HUD + if ((bus_num == 2) && (addr != 658) && (addr != 678)) { + bus_fwd = 0; + } } return bus_fwd; } const safety_hooks chrysler_hooks = { - .init = chrysler_init, + .init = nooutput_init, .rx = chrysler_rx_hook, .tx = chrysler_tx_hook, .tx_lin = nooutput_tx_lin_hook, - .ignition = default_ign_hook, .fwd = chrysler_fwd_hook, + .addr_check = chrysler_rx_checks, + .addr_check_len = sizeof(chrysler_rx_checks) / sizeof(chrysler_rx_checks[0]), }; diff --git a/panda/board/safety/safety_defaults.h b/panda/board/safety/safety_defaults.h index 9dc23b54b79906..793dc9615888ca 100644 --- a/panda/board/safety/safety_defaults.h +++ b/panda/board/safety/safety_defaults.h @@ -1,16 +1,14 @@ -void default_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { +int default_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { UNUSED(to_push); -} - -int default_ign_hook(void) { - return -1; // use GPIO to determine ignition + return true; } // *** no output safety mode *** static void nooutput_init(int16_t param) { UNUSED(param); - controls_allowed = 0; + controls_allowed = false; + relay_malfunction_reset(); } static int nooutput_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { @@ -36,7 +34,6 @@ const safety_hooks nooutput_hooks = { .rx = default_rx_hook, .tx = nooutput_tx_hook, .tx_lin = nooutput_tx_lin_hook, - .ignition = default_ign_hook, .fwd = default_fwd_hook, }; @@ -44,7 +41,8 @@ const safety_hooks nooutput_hooks = { static void alloutput_init(int16_t param) { UNUSED(param); - controls_allowed = 1; + controls_allowed = true; + relay_malfunction_reset(); } static int alloutput_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { @@ -64,6 +62,5 @@ const safety_hooks alloutput_hooks = { .rx = default_rx_hook, .tx = alloutput_tx_hook, .tx_lin = alloutput_tx_lin_hook, - .ignition = default_ign_hook, .fwd = default_fwd_hook, }; diff --git a/panda/board/safety/safety_elm327.h b/panda/board/safety/safety_elm327.h index bbad909f28cb37..a39c4125cefee5 100644 --- a/panda/board/safety/safety_elm327.h +++ b/panda/board/safety/safety_elm327.h @@ -12,7 +12,7 @@ static int elm327_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { //Check valid 29 bit send addresses for ISO 15765-4 //Check valid 11 bit send addresses for ISO 15765-4 if ((addr != 0x18DB33F1) && ((addr & 0x1FFF00FF) != 0x18DA00F1) && - ((addr != 0x7DF) && ((addr & 0x7F8) != 0x7E0))) { + ((addr & 0x1FFFFF00) != 0x700)) { tx = 0; } return tx; @@ -38,6 +38,5 @@ const safety_hooks elm327_hooks = { .rx = default_rx_hook, .tx = elm327_tx_hook, .tx_lin = elm327_tx_lin_hook, - .ignition = default_ign_hook, .fwd = default_fwd_hook, }; diff --git a/panda/board/safety/safety_ford.h b/panda/board/safety/safety_ford.h index 0bb839f2f6513d..2c0c677a882a7f 100644 --- a/panda/board/safety/safety_ford.h +++ b/panda/board/safety/safety_ford.h @@ -7,19 +7,18 @@ // brake rising edge // brake > 0mph -int ford_brake_prev = 0; -int ford_gas_prev = 0; -bool ford_moving = false; -static void ford_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { +static int ford_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { int addr = GET_ADDR(to_push); + int bus = GET_BUS(to_push); + bool unsafe_allow_gas = unsafe_mode & UNSAFE_DISABLE_DISENGAGE_ON_GAS; if (addr == 0x217) { // wheel speeds are 14 bits every 16 - ford_moving = false; + vehicle_moving = false; for (int i = 0; i < 8; i += 2) { - ford_moving |= GET_BYTE(to_push, i) | (GET_BYTE(to_push, (int)(i + 1)) & 0xFCU); + vehicle_moving |= GET_BYTE(to_push, i) | (GET_BYTE(to_push, (int)(i + 1)) & 0xFCU); } } @@ -38,21 +37,26 @@ static void ford_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { // exit controls on rising edge of brake press or on brake press when // speed > 0 if (addr == 0x165) { - int brake = GET_BYTE(to_push, 0) & 0x20; - if (brake && (!(ford_brake_prev) || ford_moving)) { + brake_pressed = GET_BYTE(to_push, 0) & 0x20; + if (brake_pressed && (!brake_pressed_prev || vehicle_moving)) { controls_allowed = 0; } - ford_brake_prev = brake; + brake_pressed_prev = brake_pressed; } // exit controls on rising edge of gas press if (addr == 0x204) { - int gas = (GET_BYTE(to_push, 0) & 0x03) | GET_BYTE(to_push, 1); - if (gas && !(ford_gas_prev)) { + gas_pressed = ((GET_BYTE(to_push, 0) & 0x03) | GET_BYTE(to_push, 1)) != 0; + if (!unsafe_allow_gas && gas_pressed && !gas_pressed_prev) { controls_allowed = 0; } - ford_gas_prev = gas; + gas_pressed_prev = gas_pressed; } + + if ((safety_mode_cnt > RELAY_TRNS_TIMEOUT) && (bus == 0) && (addr == 0x3CA)) { + relay_malfunction_set(); + } + return 1; } // all commands: just steering @@ -64,11 +68,20 @@ static void ford_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { static int ford_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int tx = 1; + int addr = GET_ADDR(to_send); + // disallow actuator commands if gas or brake (with vehicle moving) are pressed // and the the latching controls_allowed flag is True - int pedal_pressed = ford_gas_prev || (ford_brake_prev && ford_moving); + int pedal_pressed = brake_pressed_prev && vehicle_moving; + bool unsafe_allow_gas = unsafe_mode & UNSAFE_DISABLE_DISENGAGE_ON_GAS; + if (!unsafe_allow_gas) { + pedal_pressed = pedal_pressed || gas_pressed_prev; + } bool current_controls_allowed = controls_allowed && !(pedal_pressed); - int addr = GET_ADDR(to_send); + + if (relay_malfunction) { + tx = 0; + } // STEER: safety check if (addr == 0x3CA) { @@ -92,11 +105,12 @@ static int ford_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { return tx; } +// TODO: keep camera on bus 2 and make a fwd_hook + const safety_hooks ford_hooks = { .init = nooutput_init, .rx = ford_rx_hook, .tx = ford_tx_hook, .tx_lin = nooutput_tx_lin_hook, - .ignition = default_ign_hook, .fwd = default_fwd_hook, }; diff --git a/panda/board/safety/safety_gm.h b/panda/board/safety/safety_gm.h index 9ca5ca32366e8d..0e9624ddc6a8f2 100644 --- a/panda/board/safety/safety_gm.h +++ b/panda/board/safety/safety_gm.h @@ -18,98 +18,84 @@ const int GM_DRIVER_TORQUE_FACTOR = 4; const int GM_MAX_GAS = 3072; const int GM_MAX_REGEN = 1404; const int GM_MAX_BRAKE = 350; +const CanMsg GM_TX_MSGS[] = {{384, 0, 4}, {1033, 0, 7}, {1034, 0, 7}, {715, 0, 8}, {880, 0, 6}, // pt bus + {161, 1, 7}, {774, 1, 8}, {776, 1, 7}, {784, 1, 2}, // obs bus + {789, 2, 5}, // ch bus + {0x104c006c, 3, 3}, {0x10400060, 3, 5}}; // gmlan + +// TODO: do checksum and counter checks. Add correct timestep, 0.1s for now. +AddrCheckStruct gm_rx_checks[] = { + {.msg = {{388, 0, 8, .expected_timestep = 100000U}}}, + {.msg = {{842, 0, 5, .expected_timestep = 100000U}}}, + {.msg = {{481, 0, 7, .expected_timestep = 100000U}}}, + {.msg = {{241, 0, 6, .expected_timestep = 100000U}}}, + {.msg = {{417, 0, 7, .expected_timestep = 100000U}}}, +}; +const int GM_RX_CHECK_LEN = sizeof(gm_rx_checks) / sizeof(gm_rx_checks[0]); -int gm_brake_prev = 0; -int gm_gas_prev = 0; -bool gm_moving = false; -// silence everything if stock car control ECUs are still online -bool gm_ascm_detected = 0; -bool gm_ignition_started = 0; -int gm_rt_torque_last = 0; -int gm_desired_torque_last = 0; -uint32_t gm_ts_last = 0; -struct sample_t gm_torque_driver; // last few driver torques measured - -static void gm_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { - int bus_number = GET_BUS(to_push); - int addr = GET_ADDR(to_push); - - if (addr == 388) { - int torque_driver_new = ((GET_BYTE(to_push, 6) & 0x7) << 8) | GET_BYTE(to_push, 7); - torque_driver_new = to_signed(torque_driver_new, 11); - // update array of samples - update_sample(&gm_torque_driver, torque_driver_new); - } +static int gm_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { - if ((addr == 0x1F1) && (bus_number == 0)) { - //Bit 5 should be ignition "on" - //Backup plan is Bit 2 (accessory power) - bool ign = (GET_BYTE(to_push, 0) & 0x20) != 0; - gm_ignition_started = ign; - } + bool valid = addr_safety_check(to_push, gm_rx_checks, GM_RX_CHECK_LEN, + NULL, NULL, NULL); - // sample speed, really only care if car is moving or not - // rear left wheel speed - if (addr == 842) { - gm_moving = GET_BYTE(to_push, 0) | GET_BYTE(to_push, 1); - } + if (valid && (GET_BUS(to_push) == 0)) { + int addr = GET_ADDR(to_push); - // Check if ASCM or LKA camera are online - // on powertrain bus. - // 384 = ASCMLKASteeringCmd - // 715 = ASCMGasRegenCmd - if ((bus_number == 0) && ((addr == 384) || (addr == 715))) { - gm_ascm_detected = 1; - controls_allowed = 0; - } + if (addr == 388) { + int torque_driver_new = ((GET_BYTE(to_push, 6) & 0x7) << 8) | GET_BYTE(to_push, 7); + torque_driver_new = to_signed(torque_driver_new, 11); + // update array of samples + update_sample(&torque_driver, torque_driver_new); + } - // ACC steering wheel buttons - if (addr == 481) { - int button = (GET_BYTE(to_push, 5) & 0x70) >> 4; - switch (button) { - case 2: // resume - case 3: // set - controls_allowed = 1; - break; - case 6: // cancel - controls_allowed = 0; - break; - default: - break; // any other button is irrelevant + // sample speed, really only care if car is moving or not + // rear left wheel speed + if (addr == 842) { + vehicle_moving = GET_BYTE(to_push, 0) | GET_BYTE(to_push, 1); } - } - // exit controls on rising edge of brake press or on brake press when - // speed > 0 - if (addr == 241) { - int brake = GET_BYTE(to_push, 1); - // Brake pedal's potentiometer returns near-zero reading - // even when pedal is not pressed - if (brake < 10) { - brake = 0; + // ACC steering wheel buttons + if (addr == 481) { + int button = (GET_BYTE(to_push, 5) & 0x70) >> 4; + switch (button) { + case 2: // resume + case 3: // set + controls_allowed = 1; + break; + case 6: // cancel + controls_allowed = 0; + break; + default: + break; // any other button is irrelevant + } } - if (brake && (!gm_brake_prev || gm_moving)) { - controls_allowed = 0; + + // speed > 0 + if (addr == 241) { + // Brake pedal's potentiometer returns near-zero reading + // even when pedal is not pressed + brake_pressed = GET_BYTE(to_push, 1) >= 10; } - gm_brake_prev = brake; - } - // exit controls on rising edge of gas press - if (addr == 417) { - int gas = GET_BYTE(to_push, 6); - if (gas && !gm_gas_prev && long_controls_allowed) { - controls_allowed = 0; + if (addr == 417) { + gas_pressed = GET_BYTE(to_push, 6) != 0; } - gm_gas_prev = gas; - } - // exit controls on regen paddle - if (addr == 189) { - bool regen = GET_BYTE(to_push, 0) & 0x20; - if (regen) { - controls_allowed = 0; + // exit controls on regen paddle + if (addr == 189) { + bool regen = GET_BYTE(to_push, 0) & 0x20; + if (regen) { + controls_allowed = 0; + } } + + // Check if ASCM or LKA camera are online + // on powertrain bus. + // 384 = ASCMLKASteeringCmd + // 715 = ASCMGasRegenCmd + generic_rx_checks(((addr == 384) || (addr == 715))); } + return valid; } // all commands: gas/regen, friction brake and steering @@ -121,24 +107,30 @@ static void gm_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { static int gm_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int tx = 1; + int addr = GET_ADDR(to_send); - // There can be only one! (ASCM) - if (gm_ascm_detected) { + if (!msg_allowed(to_send, GM_TX_MSGS, sizeof(GM_TX_MSGS)/sizeof(GM_TX_MSGS[0]))) { + tx = 0; + } + + if (relay_malfunction) { tx = 0; } // disallow actuator commands if gas or brake (with vehicle moving) are pressed // and the the latching controls_allowed flag is True - int pedal_pressed = gm_gas_prev || (gm_brake_prev && gm_moving); + int pedal_pressed = brake_pressed_prev && vehicle_moving; + bool unsafe_allow_gas = unsafe_mode & UNSAFE_DISABLE_DISENGAGE_ON_GAS; + if (!unsafe_allow_gas) { + pedal_pressed = pedal_pressed || gas_pressed_prev; + } bool current_controls_allowed = controls_allowed && !pedal_pressed; - int addr = GET_ADDR(to_send); - // BRAKE: safety check if (addr == 789) { int brake = ((GET_BYTE(to_send, 0) & 0xFU) << 8) + GET_BYTE(to_send, 1); brake = (0x1000 - brake) & 0xFFF; - if (!current_controls_allowed || !long_controls_allowed) { + if (!current_controls_allowed) { if (brake != 0) { tx = 0; } @@ -161,21 +153,21 @@ static int gm_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { violation |= max_limit_check(desired_torque, GM_MAX_STEER, -GM_MAX_STEER); // *** torque rate limit check *** - violation |= driver_limit_check(desired_torque, gm_desired_torque_last, &gm_torque_driver, + violation |= driver_limit_check(desired_torque, desired_torque_last, &torque_driver, GM_MAX_STEER, GM_MAX_RATE_UP, GM_MAX_RATE_DOWN, GM_DRIVER_TORQUE_ALLOWANCE, GM_DRIVER_TORQUE_FACTOR); // used next time - gm_desired_torque_last = desired_torque; + desired_torque_last = desired_torque; // *** torque real time rate limit check *** - violation |= rt_rate_limit_check(desired_torque, gm_rt_torque_last, GM_MAX_RT_DELTA); + violation |= rt_rate_limit_check(desired_torque, rt_torque_last, GM_MAX_RT_DELTA); // every RT_INTERVAL set the new limits - uint32_t ts_elapsed = get_ts_elapsed(ts, gm_ts_last); + uint32_t ts_elapsed = get_ts_elapsed(ts, ts_last); if (ts_elapsed > GM_RT_INTERVAL) { - gm_rt_torque_last = desired_torque; - gm_ts_last = ts; + rt_torque_last = desired_torque; + ts_last = ts; } } @@ -186,9 +178,9 @@ static int gm_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { // reset to 0 if either controls is not allowed or there's a violation if (violation || !current_controls_allowed) { - gm_desired_torque_last = 0; - gm_rt_torque_last = 0; - gm_ts_last = ts; + desired_torque_last = 0; + rt_torque_last = 0; + ts_last = ts; } if (violation) { @@ -196,17 +188,12 @@ static int gm_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { } } - // PARK ASSIST STEER: unlimited torque, no thanks - if (addr == 823) { - tx = 0; - } - // GAS/REGEN: safety check if (addr == 715) { int gas_regen = ((GET_BYTE(to_send, 2) & 0x7FU) << 5) + ((GET_BYTE(to_send, 3) & 0xF8U) >> 3); - // Disabled message is !engaed with gas + // Disabled message is !engaged with gas // value that corresponds to max regen. - if (!current_controls_allowed || !long_controls_allowed) { + if (!current_controls_allowed) { bool apply = GET_BYTE(to_send, 0) & 1U; if (apply || (gas_regen != GM_MAX_REGEN)) { tx = 0; @@ -221,21 +208,13 @@ static int gm_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { return tx; } -static void gm_init(int16_t param) { - UNUSED(param); - controls_allowed = 0; - gm_ignition_started = 0; -} - -static int gm_ign_hook(void) { - return gm_ignition_started; -} const safety_hooks gm_hooks = { - .init = gm_init, + .init = nooutput_init, .rx = gm_rx_hook, .tx = gm_tx_hook, .tx_lin = nooutput_tx_lin_hook, - .ignition = gm_ign_hook, .fwd = default_fwd_hook, + .addr_check = gm_rx_checks, + .addr_check_len = sizeof(gm_rx_checks) / sizeof(gm_rx_checks[0]), }; diff --git a/panda/board/safety/safety_gm_ascm.h b/panda/board/safety/safety_gm_ascm.h index 82f1db6ae5741e..e7eddf454a1963 100644 --- a/panda/board/safety/safety_gm_ascm.h +++ b/panda/board/safety/safety_gm_ascm.h @@ -39,7 +39,5 @@ const safety_hooks gm_ascm_hooks = { .rx = default_rx_hook, .tx = alloutput_tx_hook, .tx_lin = nooutput_tx_lin_hook, - .ignition = default_ign_hook, .fwd = gm_ascm_fwd_hook, }; - diff --git a/panda/board/safety/safety_honda.h b/panda/board/safety/safety_honda.h index 80237dccbe3611..39234462424bff 100644 --- a/panda/board/safety/safety_honda.h +++ b/panda/board/safety/safety_honda.h @@ -6,81 +6,173 @@ // accel rising edge // brake rising edge // brake > 0mph +const CanMsg HONDA_N_TX_MSGS[] = {{0xE4, 0, 5}, {0x194, 0, 4}, {0x1FA, 0, 8}, {0x200, 0, 6}, {0x30C, 0, 8}, {0x33D, 0, 5}}; +const CanMsg HONDA_BG_TX_MSGS[] = {{0xE4, 2, 5}, {0xE5, 2, 8}, {0x296, 0, 4}, {0x33D, 2, 5}}; // Bosch Giraffe +const CanMsg HONDA_BH_TX_MSGS[] = {{0xE4, 0, 5}, {0xE5, 0, 8}, {0x296, 1, 4}, {0x33D, 0, 5}}; // Bosch Harness +const CanMsg HONDA_BG_LONG_TX_MSGS[] = {{0xE4, 0, 5}, {0x1DF, 0, 8}, {0x1EF, 0, 8}, {0x1FA, 0, 8}, {0x30C, 0, 8}, {0x33D, 0, 5}, {0x39F, 0, 8}, {0x18DAB0F1, 0, 8}}; // Bosch Giraffe w/ gas and brakes +const CanMsg HONDA_BH_LONG_TX_MSGS[] = {{0xE4, 1, 5}, {0x1DF, 1, 8}, {0x1EF, 1, 8}, {0x1FA, 1, 8}, {0x30C, 1, 8}, {0x33D, 1, 5}, {0x39F, 1, 8}, {0x18DAB0F1, 1, 8}}; // Bosch Harness w/ gas and brakes -const int HONDA_GAS_INTERCEPTOR_THRESHOLD = 328; // ratio between offset and gain from dbc file -int honda_brake_prev = 0; -int honda_gas_prev = 0; -bool honda_moving = false; -bool honda_bosch_hardware = false; +// Roughly calculated using the offsets in openpilot +5%: +// In openpilot: ((gas1_norm + gas2_norm)/2) > 15 +// gas_norm1 = ((gain_dbc1*gas1) + offset_dbc) +// gas_norm2 = ((gain_dbc2*gas2) + offset_dbc) +// assuming that 2*(gain_dbc1*gas1) == (gain_dbc2*gas2) +// In this safety: ((gas1 + (gas2/2))/2) > THRESHOLD +const int HONDA_GAS_INTERCEPTOR_THRESHOLD = 344; +#define HONDA_GET_INTERCEPTOR(msg) (((GET_BYTE((msg), 0) << 8) + GET_BYTE((msg), 1) + ((GET_BYTE((msg), 2) << 8) + GET_BYTE((msg), 3)) / 2 ) / 2) // avg between 2 tracks +const int HONDA_BOSCH_NO_GAS_VALUE = -30000; // value sent when not requesting gas +const int HONDA_BOSCH_GAS_MAX = 2000; +const int HONDA_BOSCH_ACCEL_MIN = -350; // max braking == -3.5m/s2 + +// Nidec and Bosch giraffe have pt on bus 0 +AddrCheckStruct honda_rx_checks[] = { + {.msg = {{0x1A6, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 40000U}, + {0x296, 0, 4, .check_checksum = true, .max_counter = 3U, .expected_timestep = 40000U}}}, + {.msg = {{0x158, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}}}, + {.msg = {{0x17C, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}}}, +}; +const int HONDA_RX_CHECKS_LEN = sizeof(honda_rx_checks) / sizeof(honda_rx_checks[0]); + +// Bosch harness has pt on bus 1 +AddrCheckStruct honda_bh_rx_checks[] = { + {.msg = {{0x296, 1, 4, .check_checksum = true, .max_counter = 3U, .expected_timestep = 40000U}}}, + {.msg = {{0x158, 1, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}}}, + {.msg = {{0x17C, 1, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}}}, +}; +const int HONDA_BH_RX_CHECKS_LEN = sizeof(honda_bh_rx_checks) / sizeof(honda_bh_rx_checks[0]); + +const uint16_t HONDA_PARAM_ALT_BRAKE = 1; +const uint16_t HONDA_PARAM_BOSCH_LONG = 2; + +int honda_brake = 0; bool honda_alt_brake_msg = false; +bool honda_fwd_brake = false; +bool honda_bosch_long = false; +enum {HONDA_N_HW, HONDA_BG_HW, HONDA_BH_HW} honda_hw = HONDA_N_HW; -static void honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { - int addr = GET_ADDR(to_push); - int len = GET_LEN(to_push); +static uint8_t honda_get_checksum(CAN_FIFOMailBox_TypeDef *to_push) { + int checksum_byte = GET_LEN(to_push) - 1; + return (uint8_t)(GET_BYTE(to_push, checksum_byte)) & 0xFU; +} - // sample speed - if (addr == 0x158) { - // first 2 bytes - honda_moving = GET_BYTE(to_push, 0) | GET_BYTE(to_push, 1); +static uint8_t honda_compute_checksum(CAN_FIFOMailBox_TypeDef *to_push) { + int len = GET_LEN(to_push); + uint8_t checksum = 0U; + unsigned int addr = GET_ADDR(to_push); + while (addr > 0U) { + checksum += (addr & 0xFU); addr >>= 4; } - - // state machine to enter and exit controls - // 0x1A6 for the ILX, 0x296 for the Civic Touring - if ((addr == 0x1A6) || (addr == 0x296)) { - int button = (GET_BYTE(to_push, 0) & 0xE0) >> 5; - switch (button) { - case 2: // cancel - controls_allowed = 0; - break; - case 3: // set - case 4: // resume - controls_allowed = 1; - break; - default: - break; // any other button is irrelevant + for (int j = 0; j < len; j++) { + uint8_t byte = GET_BYTE(to_push, j); + checksum += (byte & 0xFU) + (byte >> 4U); + if (j == (len - 1)) { + checksum -= (byte & 0xFU); // remove checksum in message } } + return (8U - checksum) & 0xFU; +} - // user brake signal on 0x17C reports applied brake from computer brake on accord - // and crv, which prevents the usual brake safety from working correctly. these - // cars have a signal on 0x1BE which only detects user's brake being applied so - // in these cases, this is used instead. - // most hondas: 0x17C bit 53 - // accord, crv: 0x1BE bit 4 - // exit controls on rising edge of brake press or on brake press when speed > 0 - bool is_user_brake_msg = honda_alt_brake_msg ? ((addr) == 0x1BE) : ((addr) == 0x17C); - if (is_user_brake_msg) { - int brake = honda_alt_brake_msg ? (GET_BYTE((to_push), 0) & 0x10) : (GET_BYTE((to_push), 6) & 0x20); - if (brake && (!(honda_brake_prev) || honda_moving)) { - controls_allowed = 0; - } - honda_brake_prev = brake; - } +static uint8_t honda_get_counter(CAN_FIFOMailBox_TypeDef *to_push) { + int counter_byte = GET_LEN(to_push) - 1; + return ((uint8_t)(GET_BYTE(to_push, counter_byte)) >> 4U) & 0x3U; +} - // exit controls on rising edge of gas press if interceptor (0x201 w/ len = 6) - // length check because bosch hardware also uses this id (0x201 w/ len = 8) - if ((addr == 0x201) && (len == 6)) { - gas_interceptor_detected = 1; - int gas_interceptor = GET_INTERCEPTOR(to_push); - if ((gas_interceptor > HONDA_GAS_INTERCEPTOR_THRESHOLD) && - (gas_interceptor_prev <= HONDA_GAS_INTERCEPTOR_THRESHOLD) && - long_controls_allowed) { - controls_allowed = 0; - } - gas_interceptor_prev = gas_interceptor; +static int honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { + + bool valid; + if (honda_hw == HONDA_BH_HW) { + valid = addr_safety_check(to_push, honda_bh_rx_checks, HONDA_BH_RX_CHECKS_LEN, + honda_get_checksum, honda_compute_checksum, honda_get_counter); + } else { + valid = addr_safety_check(to_push, honda_rx_checks, HONDA_RX_CHECKS_LEN, + honda_get_checksum, honda_compute_checksum, honda_get_counter); } - // exit controls on rising edge of gas press if no interceptor - if (!gas_interceptor_detected) { - if (addr == 0x17C) { - int gas = GET_BYTE(to_push, 0); - if (gas && !(honda_gas_prev) && long_controls_allowed) { - controls_allowed = 0; + if (valid) { + int addr = GET_ADDR(to_push); + int len = GET_LEN(to_push); + int bus = GET_BUS(to_push); + + // sample speed + if (addr == 0x158) { + // first 2 bytes + vehicle_moving = GET_BYTE(to_push, 0) | GET_BYTE(to_push, 1); + } + + // state machine to enter and exit controls + // 0x1A6 for the ILX, 0x296 for the Civic Touring + if ((addr == 0x1A6) || (addr == 0x296)) { + int button = (GET_BYTE(to_push, 0) & 0xE0) >> 5; + switch (button) { + case 2: // cancel + controls_allowed = 0; + break; + case 3: // set + case 4: // resume + controls_allowed = 1; + break; + default: + break; // any other button is irrelevant } - honda_gas_prev = gas; } + + // user brake signal on 0x17C reports applied brake from computer brake on accord + // and crv, which prevents the usual brake safety from working correctly. these + // cars have a signal on 0x1BE which only detects user's brake being applied so + // in these cases, this is used instead. + // most hondas: 0x17C bit 53 + // accord, crv: 0x1BE bit 4 + bool is_user_brake_msg = honda_alt_brake_msg ? ((addr) == 0x1BE) : ((addr) == 0x17C); + if (is_user_brake_msg) { + brake_pressed = honda_alt_brake_msg ? (GET_BYTE((to_push), 0) & 0x10) : (GET_BYTE((to_push), 6) & 0x20); + } + + // length check because bosch hardware also uses this id (0x201 w/ len = 8) + if ((addr == 0x201) && (len == 6)) { + gas_interceptor_detected = 1; + int gas_interceptor = HONDA_GET_INTERCEPTOR(to_push); + gas_pressed = gas_interceptor > HONDA_GAS_INTERCEPTOR_THRESHOLD; + gas_interceptor_prev = gas_interceptor; + } + + if (!gas_interceptor_detected) { + if (addr == 0x17C) { + gas_pressed = GET_BYTE(to_push, 0) != 0; + } + } + + // disable stock Honda AEB in unsafe mode + if ( !(unsafe_mode & UNSAFE_DISABLE_STOCK_AEB) ) { + if ((bus == 2) && (addr == 0x1FA)) { + bool honda_stock_aeb = GET_BYTE(to_push, 3) & 0x20; + int honda_stock_brake = (GET_BYTE(to_push, 0) << 2) + ((GET_BYTE(to_push, 1) >> 6) & 0x3); + + // Forward AEB when stock braking is higher than openpilot braking + // only stop forwarding when AEB event is over + if (!honda_stock_aeb) { + honda_fwd_brake = false; + } else if (honda_stock_brake >= honda_brake) { + honda_fwd_brake = true; + } else { + // Leave Honda forward brake as is + } + } + } + + // if steering controls messages are received on the destination bus, it's an indication + // that the relay might be malfunctioning + bool stock_ecu_detected = false; + int bus_rdr_car = (honda_hw == HONDA_BH_HW) ? 0 : 2; // radar bus, car side + if ((safety_mode_cnt > RELAY_TRNS_TIMEOUT) && ((addr == 0xE4) || (addr == 0x194))) { + if (((honda_hw != HONDA_N_HW) && (bus == bus_rdr_car)) || + ((honda_hw == HONDA_N_HW) && (bus == 0))) { + stock_ecu_detected = true; + } + } + generic_rx_checks(stock_ecu_detected); } + return valid; } // all commands: gas, brake and steering @@ -95,21 +187,69 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int addr = GET_ADDR(to_send); int bus = GET_BUS(to_send); + if ((honda_hw == HONDA_BG_HW) && !honda_bosch_long) { + tx = msg_allowed(to_send, HONDA_BG_TX_MSGS, sizeof(HONDA_BG_TX_MSGS)/sizeof(HONDA_BG_TX_MSGS[0])); + } else if ((honda_hw == HONDA_BG_HW) && honda_bosch_long) { + tx = msg_allowed(to_send, HONDA_BG_LONG_TX_MSGS, sizeof(HONDA_BG_LONG_TX_MSGS)/sizeof(HONDA_BG_LONG_TX_MSGS[0])); + } else if ((honda_hw == HONDA_BH_HW) && !honda_bosch_long) { + tx = msg_allowed(to_send, HONDA_BH_TX_MSGS, sizeof(HONDA_BH_TX_MSGS)/sizeof(HONDA_BH_TX_MSGS[0])); + } else if ((honda_hw == HONDA_BH_HW) && honda_bosch_long) { + tx = msg_allowed(to_send, HONDA_BH_LONG_TX_MSGS, sizeof(HONDA_BH_LONG_TX_MSGS)/sizeof(HONDA_BH_LONG_TX_MSGS[0])); + } else { + tx = msg_allowed(to_send, HONDA_N_TX_MSGS, sizeof(HONDA_N_TX_MSGS)/sizeof(HONDA_N_TX_MSGS[0])); + } + + if (relay_malfunction) { + tx = 0; + } + // disallow actuator commands if gas or brake (with vehicle moving) are pressed // and the the latching controls_allowed flag is True - int pedal_pressed = honda_gas_prev || (gas_interceptor_prev > HONDA_GAS_INTERCEPTOR_THRESHOLD) || - (honda_brake_prev && honda_moving); + int pedal_pressed = brake_pressed_prev && vehicle_moving; + bool unsafe_allow_gas = unsafe_mode & UNSAFE_DISABLE_DISENGAGE_ON_GAS; + if (!unsafe_allow_gas) { + pedal_pressed = pedal_pressed || gas_pressed_prev || (gas_interceptor_prev > HONDA_GAS_INTERCEPTOR_THRESHOLD); + } bool current_controls_allowed = controls_allowed && !(pedal_pressed); + int bus_pt = (honda_hw == HONDA_BH_HW)? 1 : 0; + + // BRAKE: safety check (nidec) + if ((addr == 0x1FA) && (bus == bus_pt)) { + honda_brake = (GET_BYTE(to_send, 0) << 2) + ((GET_BYTE(to_send, 1) >> 6) & 0x3); + if (!current_controls_allowed) { + if (honda_brake != 0) { + tx = 0; + } + } + if (honda_brake > 255) { + tx = 0; + } + if (honda_fwd_brake) { + tx = 0; + } + } - // BRAKE: safety check - if (addr == 0x1FA) { - int brake = (GET_BYTE(to_send, 0) << 2) + (GET_BYTE(to_send, 1) & 0x3); - if (!current_controls_allowed || !long_controls_allowed) { - if (brake != 0) { + // BRAKE/GAS: safety check (bosch) + if ((addr == 0x1DF) && (bus == bus_pt)) { + int accel = (GET_BYTE(to_send, 3) << 3) | ((GET_BYTE(to_send, 4) >> 5) & 0x7); + accel = to_signed(accel, 11); + if (!current_controls_allowed) { + if (accel != 0) { tx = 0; } } - if (brake > 255) { + if (accel < HONDA_BOSCH_ACCEL_MIN) { + tx = 0; + } + + int gas = (GET_BYTE(to_send, 0) << 8) | GET_BYTE(to_send, 1); + gas = to_signed(gas, 16); + if (!current_controls_allowed) { + if (gas != HONDA_BOSCH_NO_GAS_VALUE) { + tx = 0; + } + } + if (gas > HONDA_BOSCH_GAS_MAX) { tx = 0; } } @@ -124,9 +264,16 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { } } - // GAS: safety check + // Bosch supplemental control check + if (addr == 0xE5) { + if ((GET_BYTES_04(to_send) != 0x10800004) || ((GET_BYTES_48(to_send) & 0x00FFFFFF) != 0x0)) { + tx = 0; + } + } + + // GAS: safety check (interceptor) if (addr == 0x200) { - if (!current_controls_allowed || !long_controls_allowed) { + if (!current_controls_allowed) { if (GET_BYTE(to_send, 0) || GET_BYTE(to_send, 1)) { tx = 0; } @@ -136,9 +283,7 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { // FORCE CANCEL: safety check only relevant when spamming the cancel button in Bosch HW // ensuring that only the cancel button press is sent (VAL 2) when controls are off. // This avoids unintended engagements while still allowing resume spam - int bus_pt = ((hw_type == HW_TYPE_BLACK_PANDA) && honda_bosch_hardware)? 1 : 0; - if ((addr == 0x296) && honda_bosch_hardware && - !current_controls_allowed && (bus == bus_pt)) { + if ((addr == 0x296) && !current_controls_allowed && (bus == bus_pt)) { if (((GET_BYTE(to_send, 0) >> 5) & 0x7) != 2) { tx = 0; } @@ -148,38 +293,56 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { return tx; } -static void honda_init(int16_t param) { +static void honda_nidec_init(int16_t param) { UNUSED(param); - controls_allowed = 0; - honda_bosch_hardware = false; + controls_allowed = false; + relay_malfunction_reset(); + gas_interceptor_detected = 0; + honda_hw = HONDA_N_HW; honda_alt_brake_msg = false; + honda_bosch_long = false; } -static void honda_bosch_init(int16_t param) { - controls_allowed = 0; - honda_bosch_hardware = true; +static void honda_bosch_giraffe_init(int16_t param) { + controls_allowed = false; + relay_malfunction_reset(); + honda_hw = HONDA_BG_HW; // Checking for alternate brake override from safety parameter - honda_alt_brake_msg = (param == 1) ? true : false; + honda_alt_brake_msg = GET_FLAG(param, HONDA_PARAM_ALT_BRAKE); + // radar disabled so allow gas/brakes + honda_bosch_long = GET_FLAG(param, HONDA_PARAM_BOSCH_LONG); } -static int honda_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { +static void honda_bosch_harness_init(int16_t param) { + controls_allowed = false; + relay_malfunction_reset(); + honda_hw = HONDA_BH_HW; + // Checking for alternate brake override from safety parameter + honda_alt_brake_msg = GET_FLAG(param, HONDA_PARAM_ALT_BRAKE); + // radar disabled so allow gas/brakes + honda_bosch_long = GET_FLAG(param, HONDA_PARAM_BOSCH_LONG); +} + +static int honda_nidec_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { // fwd from car to camera. also fwd certain msgs from camera to car // 0xE4 is steering on all cars except CRV and RDX, 0x194 for CRV and RDX, // 0x1FA is brake control, 0x30C is acc hud, 0x33D is lkas hud, - // 0x39f is radar hud int bus_fwd = -1; - if (bus_num == 0) { - bus_fwd = 2; - } - if (bus_num == 2) { - // block stock lkas messages and stock acc messages (if OP is doing ACC) - int addr = GET_ADDR(to_fwd); - int is_lkas_msg = (addr == 0xE4) || (addr == 0x194) || (addr == 0x33D); - int is_acc_msg = (addr == 0x1FA) || (addr == 0x30C) || (addr == 0x39F); - int block_fwd = is_lkas_msg || (is_acc_msg && long_controls_allowed); - if (!block_fwd) { - bus_fwd = 0; + if (!relay_malfunction) { + if (bus_num == 0) { + bus_fwd = 2; + } + if (bus_num == 2) { + // block stock lkas messages and stock acc messages (if OP is doing ACC) + int addr = GET_ADDR(to_fwd); + bool is_lkas_msg = (addr == 0xE4) || (addr == 0x194) || (addr == 0x33D); + bool is_acc_hud_msg = addr == 0x30C; + bool is_brake_msg = addr == 0x1FA; + bool block_fwd = is_lkas_msg || is_acc_hud_msg || (is_brake_msg && !honda_fwd_brake); + if (!block_fwd) { + bus_fwd = 0; + } } } return bus_fwd; @@ -187,36 +350,50 @@ static int honda_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { static int honda_bosch_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { int bus_fwd = -1; - int bus_rdr_cam = (hw_type == HW_TYPE_BLACK_PANDA) ? 2 : 1; // radar bus, camera side - int bus_rdr_car = (hw_type == HW_TYPE_BLACK_PANDA) ? 0 : 2; // radar bus, car side + int bus_rdr_cam = (honda_hw == HONDA_BH_HW) ? 2 : 1; // radar bus, camera side + int bus_rdr_car = (honda_hw == HONDA_BH_HW) ? 0 : 2; // radar bus, car side - if (bus_num == bus_rdr_car) { - bus_fwd = bus_rdr_cam; - } - if (bus_num == bus_rdr_cam) { - int addr = GET_ADDR(to_fwd); - int is_lkas_msg = (addr == 0xE4) || (addr == 0x33D); - if (!is_lkas_msg) { - bus_fwd = bus_rdr_car; + if (!relay_malfunction) { + if (bus_num == bus_rdr_car) { + bus_fwd = bus_rdr_cam; + } + if (bus_num == bus_rdr_cam) { + int addr = GET_ADDR(to_fwd); + int is_lkas_msg = (addr == 0xE4) || (addr == 0xE5) || (addr == 0x33D); + if (!is_lkas_msg) { + bus_fwd = bus_rdr_car; + } } } return bus_fwd; } -const safety_hooks honda_hooks = { - .init = honda_init, +const safety_hooks honda_nidec_hooks = { + .init = honda_nidec_init, .rx = honda_rx_hook, .tx = honda_tx_hook, .tx_lin = nooutput_tx_lin_hook, - .ignition = default_ign_hook, - .fwd = honda_fwd_hook, + .fwd = honda_nidec_fwd_hook, + .addr_check = honda_rx_checks, + .addr_check_len = sizeof(honda_rx_checks) / sizeof(honda_rx_checks[0]), +}; + +const safety_hooks honda_bosch_giraffe_hooks = { + .init = honda_bosch_giraffe_init, + .rx = honda_rx_hook, + .tx = honda_tx_hook, + .tx_lin = nooutput_tx_lin_hook, + .fwd = honda_bosch_fwd_hook, + .addr_check = honda_rx_checks, + .addr_check_len = sizeof(honda_rx_checks) / sizeof(honda_rx_checks[0]), }; -const safety_hooks honda_bosch_hooks = { - .init = honda_bosch_init, +const safety_hooks honda_bosch_harness_hooks = { + .init = honda_bosch_harness_init, .rx = honda_rx_hook, .tx = honda_tx_hook, .tx_lin = nooutput_tx_lin_hook, - .ignition = default_ign_hook, .fwd = honda_bosch_fwd_hook, + .addr_check = honda_bh_rx_checks, + .addr_check_len = sizeof(honda_bh_rx_checks) / sizeof(honda_bh_rx_checks[0]), }; diff --git a/panda/board/safety/safety_hyundai.h b/panda/board/safety/safety_hyundai.h index aed30621f44b00..a4a6d4c2a32c2b 100644 --- a/panda/board/safety/safety_hyundai.h +++ b/panda/board/safety/safety_hyundai.h @@ -1,58 +1,152 @@ -const int HYUNDAI_MAX_STEER = 255; // like stock +const int HYUNDAI_MAX_STEER = 384; // like stock const int HYUNDAI_MAX_RT_DELTA = 112; // max delta torque allowed for real time checks -const uint32_t HYUNDAI_RT_INTERVAL = 250000; // 250ms between real time checks +const uint32_t HYUNDAI_RT_INTERVAL = 250000; // 250ms between real time checks const int HYUNDAI_MAX_RATE_UP = 3; const int HYUNDAI_MAX_RATE_DOWN = 7; const int HYUNDAI_DRIVER_TORQUE_ALLOWANCE = 50; const int HYUNDAI_DRIVER_TORQUE_FACTOR = 2; +const int HYUNDAI_STANDSTILL_THRSLD = 30; // ~1kph +const CanMsg HYUNDAI_TX_MSGS[] = { + {832, 0, 8}, // LKAS11 Bus 0 + {1265, 0, 4}, // CLU11 Bus 0 + {1157, 0, 4}, // LFAHDA_MFC Bus 0 + // {1056, 0, 8}, // SCC11, Bus 0 + // {1057, 0, 8}, // SCC12, Bus 0 + // {1290, 0, 8}, // SCC13, Bus 0 + // {905, 0, 8}, // SCC14, Bus 0 + // {1186, 0, 8} // 4a2SCC, Bus 0 + }; -bool hyundai_camera_detected = 0; -bool hyundai_giraffe_switch_2 = 0; // is giraffe switch 2 high? -int hyundai_camera_bus = 0; -int hyundai_rt_torque_last = 0; -int hyundai_desired_torque_last = 0; -int hyundai_cruise_engaged_last = 0; -uint32_t hyundai_ts_last = 0; -struct sample_t hyundai_torque_driver; // last few driver torques measured - -static void hyundai_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { - int bus = GET_BUS(to_push); +// TODO: missing checksum for wheel speeds message,worst failure case is +// wheel speeds stuck at 0 and we don't disengage on brake press +AddrCheckStruct hyundai_rx_checks[] = { + {.msg = {{608, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}}}, + {.msg = {{902, 0, 8, .check_checksum = false, .max_counter = 15U, .expected_timestep = 10000U}}}, + {.msg = {{916, 0, 8, .check_checksum = true, .max_counter = 7U, .expected_timestep = 10000U}}}, + {.msg = {{1057, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}}}, +}; +const int HYUNDAI_RX_CHECK_LEN = sizeof(hyundai_rx_checks) / sizeof(hyundai_rx_checks[0]); + +// older hyundai models have less checks due to missing counters and checksums +AddrCheckStruct hyundai_legacy_rx_checks[] = { + {.msg = {{608, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}, + {881, 0, 8, .expected_timestep = 10000U}}}, + {.msg = {{902, 0, 8, .expected_timestep = 10000U}}}, + {.msg = {{916, 0, 8, .expected_timestep = 10000U}}}, + {.msg = {{1057, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}}}, +}; +const int HYUNDAI_LEGACY_RX_CHECK_LEN = sizeof(hyundai_legacy_rx_checks) / sizeof(hyundai_legacy_rx_checks[0]); + +bool hyundai_legacy = false; + +static uint8_t hyundai_get_counter(CAN_FIFOMailBox_TypeDef *to_push) { int addr = GET_ADDR(to_push); - if (addr == 897) { - int torque_driver_new = ((GET_BYTES_04(to_push) >> 11) & 0xfff) - 2048; - // update array of samples - update_sample(&hyundai_torque_driver, torque_driver_new); + uint8_t cnt; + if (addr == 608) { + cnt = (GET_BYTE(to_push, 7) >> 4) & 0x3; + } else if (addr == 902) { + cnt = ((GET_BYTE(to_push, 3) >> 6) << 2) | (GET_BYTE(to_push, 1) >> 6); + } else if (addr == 916) { + cnt = (GET_BYTE(to_push, 1) >> 5) & 0x7; + } else if (addr == 1057) { + cnt = GET_BYTE(to_push, 7) & 0xF; + } else { + cnt = 0; } + return cnt; +} - // check if stock camera ECU is still online - if ((bus == 0) && (addr == 832)) { - hyundai_camera_detected = 1; - controls_allowed = 0; +static uint8_t hyundai_get_checksum(CAN_FIFOMailBox_TypeDef *to_push) { + int addr = GET_ADDR(to_push); + + uint8_t chksum; + if (addr == 608) { + chksum = GET_BYTE(to_push, 7) & 0xF; + } else if (addr == 916) { + chksum = GET_BYTE(to_push, 6) & 0xF; + } else if (addr == 1057) { + chksum = GET_BYTE(to_push, 7) >> 4; + } else { + chksum = 0; } + return chksum; +} - // Find out which bus the camera is on - if (addr == 832) { - hyundai_camera_bus = bus; +static uint8_t hyundai_compute_checksum(CAN_FIFOMailBox_TypeDef *to_push) { + int addr = GET_ADDR(to_push); + + uint8_t chksum = 0; + // same algorithm, but checksum is in a different place + for (int i = 0; i < 8; i++) { + uint8_t b = GET_BYTE(to_push, i); + if (((addr == 608) && (i == 7)) || ((addr == 916) && (i == 6)) || ((addr == 1057) && (i == 7))) { + b &= (addr == 1057) ? 0x0FU : 0xF0U; // remove checksum + } + chksum += (b % 16U) + (b / 16U); + } + return (16U - (chksum % 16U)) % 16U; +} + +static int hyundai_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { + + bool valid; + if (hyundai_legacy) { + valid = addr_safety_check(to_push, hyundai_legacy_rx_checks, HYUNDAI_LEGACY_RX_CHECK_LEN, + hyundai_get_checksum, hyundai_compute_checksum, + hyundai_get_counter); + + } else { + valid = addr_safety_check(to_push, hyundai_rx_checks, HYUNDAI_RX_CHECK_LEN, + hyundai_get_checksum, hyundai_compute_checksum, + hyundai_get_counter); } - // enter controls on rising edge of ACC, exit controls on ACC off - if (addr == 1057) { - // 2 bits: 13-14 - int cruise_engaged = (GET_BYTES_04(to_push) >> 13) & 0x3; - if (cruise_engaged && !hyundai_cruise_engaged_last) { - controls_allowed = 1; + if (valid && (GET_BUS(to_push) == 0)) { + int addr = GET_ADDR(to_push); + + if (addr == 593) { + int torque_driver_new = ((GET_BYTES_04(to_push) & 0x7ff) * 0.79) - 808; // scale down new driver torque signal to match previous one + // update array of samples + update_sample(&torque_driver, torque_driver_new); } - if (!cruise_engaged) { - controls_allowed = 0; + + // enter controls on rising edge of ACC, exit controls on ACC off + if (addr == 1057) { + // 2 bits: 13-14 + int cruise_engaged = (GET_BYTES_04(to_push) >> 13) & 0x3; + if (cruise_engaged && !cruise_engaged_prev) { + controls_allowed = 1; + } + if (!cruise_engaged) { + controls_allowed = 0; + } + cruise_engaged_prev = cruise_engaged; + } + + if ((addr == 608) || (hyundai_legacy && (addr == 881))) { + if (addr == 608) { + gas_pressed = (GET_BYTE(to_push, 7) >> 6) != 0; + } else { + gas_pressed = (((GET_BYTE(to_push, 4) & 0x7F) << 1) | GET_BYTE(to_push, 3) >> 7) != 0; + } + } + + // sample wheel speed, averaging opposite corners + if (addr == 902) { + int hyundai_speed = GET_BYTES_04(to_push) & 0x3FFF; // FL + hyundai_speed += (GET_BYTES_48(to_push) >> 16) & 0x3FFF; // RL + hyundai_speed /= 2; + vehicle_moving = hyundai_speed > HYUNDAI_STANDSTILL_THRSLD; + } + + if (addr == 916) { + brake_pressed = (GET_BYTE(to_push, 6) >> 7) != 0; } - hyundai_cruise_engaged_last = cruise_engaged; - } - // 832 is lkas cmd. If it is on camera bus, then giraffe switch 2 is high - if ((addr == 832) && (bus == hyundai_camera_bus) && (hyundai_camera_bus != 0)) { - hyundai_giraffe_switch_2 = 1; + generic_rx_checks((addr == 832)); } + return valid; } static int hyundai_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { @@ -60,8 +154,11 @@ static int hyundai_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int tx = 1; int addr = GET_ADDR(to_send); - // There can be only one! (camera) - if (hyundai_camera_detected) { + if (!msg_allowed(to_send, HYUNDAI_TX_MSGS, sizeof(HYUNDAI_TX_MSGS)/sizeof(HYUNDAI_TX_MSGS[0]))) { + tx = 0; + } + + if (relay_malfunction) { tx = 0; } @@ -77,21 +174,21 @@ static int hyundai_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { violation |= max_limit_check(desired_torque, HYUNDAI_MAX_STEER, -HYUNDAI_MAX_STEER); // *** torque rate limit check *** - violation |= driver_limit_check(desired_torque, hyundai_desired_torque_last, &hyundai_torque_driver, + violation |= driver_limit_check(desired_torque, desired_torque_last, &torque_driver, HYUNDAI_MAX_STEER, HYUNDAI_MAX_RATE_UP, HYUNDAI_MAX_RATE_DOWN, HYUNDAI_DRIVER_TORQUE_ALLOWANCE, HYUNDAI_DRIVER_TORQUE_FACTOR); // used next time - hyundai_desired_torque_last = desired_torque; + desired_torque_last = desired_torque; // *** torque real time rate limit check *** - violation |= rt_rate_limit_check(desired_torque, hyundai_rt_torque_last, HYUNDAI_MAX_RT_DELTA); + violation |= rt_rate_limit_check(desired_torque, rt_torque_last, HYUNDAI_MAX_RT_DELTA); // every RT_INTERVAL set the new limits - uint32_t ts_elapsed = get_ts_elapsed(ts, hyundai_ts_last); + uint32_t ts_elapsed = get_ts_elapsed(ts, ts_last); if (ts_elapsed > HYUNDAI_RT_INTERVAL) { - hyundai_rt_torque_last = desired_torque; - hyundai_ts_last = ts; + rt_torque_last = desired_torque; + ts_last = ts; } } @@ -102,9 +199,9 @@ static int hyundai_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { // reset to 0 if either controls is not allowed or there's a violation if (violation || !controls_allowed) { - hyundai_desired_torque_last = 0; - hyundai_rt_torque_last = 0; - hyundai_ts_last = ts; + desired_torque_last = 0; + rt_torque_last = 0; + ts_last = ts; } if (violation) { @@ -115,12 +212,11 @@ static int hyundai_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { // FORCE CANCEL: safety check only relevant when spamming the cancel button. // ensuring that only the cancel button press is sent (VAL 4) when controls are off. // This avoids unintended engagements while still allowing resume spam - // TODO: fix bug preventing the button msg to be fwd'd on bus 2 - //if ((addr == 1265) && !controls_allowed && (bus == 0) { - // if ((GET_BYTES_04(to_send) & 0x7) != 4) { - // tx = 0; - // } - //} + if ((addr == 1265) && !controls_allowed) { + if ((GET_BYTES_04(to_send) & 0x7) != 4) { + tx = 0; + } + } // 1 allows the message through return tx; @@ -129,16 +225,14 @@ static int hyundai_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { static int hyundai_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { int bus_fwd = -1; + int addr = GET_ADDR(to_fwd); // forward cam to ccan and viceversa, except lkas cmd - if (hyundai_giraffe_switch_2) { + if (!relay_malfunction) { if (bus_num == 0) { - bus_fwd = hyundai_camera_bus; + bus_fwd = 2; } - if (bus_num == hyundai_camera_bus) { - int addr = GET_ADDR(to_fwd); - if (addr != 832) { - bus_fwd = 0; - } + if ((bus_num == 2) && (addr != 832) && (addr != 1157)) { + bus_fwd = 0; } } return bus_fwd; @@ -146,8 +240,18 @@ static int hyundai_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { static void hyundai_init(int16_t param) { UNUSED(param); - controls_allowed = 0; - hyundai_giraffe_switch_2 = 0; + controls_allowed = false; + relay_malfunction_reset(); + + hyundai_legacy = false; +} + +static void hyundai_legacy_init(int16_t param) { + UNUSED(param); + controls_allowed = false; + relay_malfunction_reset(); + + hyundai_legacy = true; } const safety_hooks hyundai_hooks = { @@ -155,6 +259,17 @@ const safety_hooks hyundai_hooks = { .rx = hyundai_rx_hook, .tx = hyundai_tx_hook, .tx_lin = nooutput_tx_lin_hook, - .ignition = default_ign_hook, .fwd = hyundai_fwd_hook, + .addr_check = hyundai_rx_checks, + .addr_check_len = sizeof(hyundai_rx_checks) / sizeof(hyundai_rx_checks[0]), +}; + +const safety_hooks hyundai_legacy_hooks = { + .init = hyundai_legacy_init, + .rx = hyundai_rx_hook, + .tx = hyundai_tx_hook, + .tx_lin = nooutput_tx_lin_hook, + .fwd = hyundai_fwd_hook, + .addr_check = hyundai_legacy_rx_checks, + .addr_check_len = sizeof(hyundai_legacy_rx_checks) / sizeof(hyundai_legacy_rx_checks[0]), }; diff --git a/panda/board/safety/safety_mazda.h b/panda/board/safety/safety_mazda.h new file mode 100644 index 00000000000000..12e92404064efb --- /dev/null +++ b/panda/board/safety/safety_mazda.h @@ -0,0 +1,201 @@ +// CAN msgs we care about +#define MAZDA_LKAS 0x243 +#define MAZDA_CRZ_CTRL 0x21c +#define MAZDA_CRZ_BTNS 0x09d +#define MAZDA_STEER_TORQUE 0x240 +#define MAZDA_ENGINE_DATA 0x202 +#define MAZDA_PEDALS 0x165 + +// CAN bus numbers +#define MAZDA_MAIN 0 +#define MAZDA_AUX 1 +#define MAZDA_CAM 2 + +#define MAZDA_MAX_STEER 2048 + +// max delta torque allowed for real time checks +#define MAZDA_MAX_RT_DELTA 940 +// 250ms between real time checks +#define MAZDA_RT_INTERVAL 250000 +#define MAZDA_MAX_RATE_UP 10 +#define MAZDA_MAX_RATE_DOWN 25 +#define MAZDA_DRIVER_TORQUE_ALLOWANCE 15 +#define MAZDA_DRIVER_TORQUE_FACTOR 1 +#define MAZDA_MAX_TORQUE_ERROR 350 + +// lkas enable speed 52kph, disable at 45kph +#define MAZDA_LKAS_ENABLE_SPEED 5200 +#define MAZDA_LKAS_DISABLE_SPEED 4500 + +const CanMsg MAZDA_TX_MSGS[] = {{MAZDA_LKAS, 0, 8}, {MAZDA_CRZ_BTNS, 0, 8}}; +bool mazda_lkas_allowed = false; + +AddrCheckStruct mazda_rx_checks[] = { + {.msg = {{MAZDA_CRZ_CTRL, 0, 8, .expected_timestep = 20000U}}}, + {.msg = {{MAZDA_CRZ_BTNS, 0, 8, .expected_timestep = 100000U}}}, + {.msg = {{MAZDA_STEER_TORQUE, 0, 8, .expected_timestep = 12000U}}}, + {.msg = {{MAZDA_ENGINE_DATA, 0, 8, .expected_timestep = 10000U}}}, + {.msg = {{MAZDA_PEDALS, 0, 8, .expected_timestep = 20000U}}}, +}; +const int MAZDA_RX_CHECKS_LEN = sizeof(mazda_rx_checks) / sizeof(mazda_rx_checks[0]); + +// track msgs coming from OP so that we know what CAM msgs to drop and what to forward +static int mazda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { + bool valid = addr_safety_check(to_push, mazda_rx_checks, MAZDA_RX_CHECKS_LEN, + NULL, NULL, NULL); + if (valid && (GET_BUS(to_push) == MAZDA_MAIN)) { + int addr = GET_ADDR(to_push); + + if (addr == MAZDA_ENGINE_DATA) { + // sample speed: scale by 0.01 to get kph + int speed = (GET_BYTE(to_push, 2) << 8) | GET_BYTE(to_push, 3); + + vehicle_moving = speed > 10; // moving when speed > 0.1 kph + + // Enable LKAS at 52kph going up, disable at 45kph going down + if (speed > MAZDA_LKAS_ENABLE_SPEED) { + mazda_lkas_allowed = true; + } else if (speed < MAZDA_LKAS_DISABLE_SPEED) { + mazda_lkas_allowed = false; + } else { + // Misra-able appeasment block! + } + } + + if (addr == MAZDA_STEER_TORQUE) { + int torque_driver_new = GET_BYTE(to_push, 0) - 127; + // update array of samples + update_sample(&torque_driver, torque_driver_new); + } + + // enter controls on rising edge of ACC, exit controls on ACC off + if (addr == MAZDA_CRZ_CTRL) { + bool cruise_engaged = GET_BYTE(to_push, 0) & 8; + if (cruise_engaged) { + if (!cruise_engaged_prev) { + // do not engage until we hit the speed at which lkas is on + if (mazda_lkas_allowed) { + controls_allowed = 1; + } else { + controls_allowed = 0; + cruise_engaged = false; + } + } + } else { + controls_allowed = 0; + } + cruise_engaged_prev = cruise_engaged; + } + + if (addr == MAZDA_ENGINE_DATA) { + gas_pressed = (GET_BYTE(to_push, 4) || (GET_BYTE(to_push, 5) & 0xF0)); + } + + if (addr == MAZDA_PEDALS) { + brake_pressed = (GET_BYTE(to_push, 0) & 0x10); + } + + generic_rx_checks((addr == MAZDA_LKAS)); + } + return valid; +} + +static int mazda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { + int tx = 1; + int addr = GET_ADDR(to_send); + int bus = GET_BUS(to_send); + + if (!msg_allowed(to_send, MAZDA_TX_MSGS, sizeof(MAZDA_TX_MSGS)/sizeof(MAZDA_TX_MSGS[0]))) { + tx = 0; + } + + if (relay_malfunction) { + tx = 0; + } + + // Check if msg is sent on the main BUS + if (bus == MAZDA_MAIN) { + + // steer cmd checks + if (addr == MAZDA_LKAS) { + int desired_torque = (((GET_BYTE(to_send, 0) & 0x0f) << 8) | GET_BYTE(to_send, 1)) - MAZDA_MAX_STEER; + bool violation = 0; + uint32_t ts = TIM2->CNT; + + if (controls_allowed) { + + // *** global torque limit check *** + violation |= max_limit_check(desired_torque, MAZDA_MAX_STEER, -MAZDA_MAX_STEER); + + // *** torque rate limit check *** + violation |= driver_limit_check(desired_torque, desired_torque_last, &torque_driver, + MAZDA_MAX_STEER, MAZDA_MAX_RATE_UP, MAZDA_MAX_RATE_DOWN, + MAZDA_DRIVER_TORQUE_ALLOWANCE, MAZDA_DRIVER_TORQUE_FACTOR); + + // used next time + desired_torque_last = desired_torque; + + // *** torque real time rate limit check *** + violation |= rt_rate_limit_check(desired_torque, rt_torque_last, MAZDA_MAX_RT_DELTA); + + // every RT_INTERVAL set the new limits + uint32_t ts_elapsed = get_ts_elapsed(ts, ts_last); + if (ts_elapsed > ((uint32_t) MAZDA_RT_INTERVAL)) { + rt_torque_last = desired_torque; + ts_last = ts; + } + } + + // no torque if controls is not allowed + if (!controls_allowed && (desired_torque != 0)) { + violation = 1; + } + + // reset to 0 if either controls is not allowed or there's a violation + if (violation || !controls_allowed) { + desired_torque_last = 0; + rt_torque_last = 0; + ts_last = ts; + } + + if (violation) { + tx = 0; + } + } + } + return tx; +} + +static int mazda_fwd_hook(int bus, CAN_FIFOMailBox_TypeDef *to_fwd) { + int bus_fwd = -1; + if (!relay_malfunction) { + int addr = GET_ADDR(to_fwd); + if (bus == MAZDA_MAIN) { + bus_fwd = MAZDA_CAM; + } else if (bus == MAZDA_CAM) { + if (!(addr == MAZDA_LKAS)) { + bus_fwd = MAZDA_MAIN; + } + } else { + bus_fwd = -1; + } + } + return bus_fwd; +} + +static void mazda_init(int16_t param) { + UNUSED(param); + controls_allowed = false; + relay_malfunction_reset(); + mazda_lkas_allowed = false; +} + +const safety_hooks mazda_hooks = { + .init = mazda_init, + .rx = mazda_rx_hook, + .tx = mazda_tx_hook, + .tx_lin = nooutput_tx_lin_hook, + .fwd = mazda_fwd_hook, + .addr_check = mazda_rx_checks, + .addr_check_len = sizeof(mazda_rx_checks) / sizeof(mazda_rx_checks[0]), +}; diff --git a/panda/board/safety/safety_nissan.h b/panda/board/safety/safety_nissan.h new file mode 100644 index 00000000000000..ca0f54e53a7c6f --- /dev/null +++ b/panda/board/safety/safety_nissan.h @@ -0,0 +1,207 @@ + +const uint32_t NISSAN_RT_INTERVAL = 250000; // 250ms between real time checks + +const struct lookup_t NISSAN_LOOKUP_ANGLE_RATE_UP = { + {2., 7., 17.}, + {5., .8, .15}}; + +const struct lookup_t NISSAN_LOOKUP_ANGLE_RATE_DOWN = { + {2., 7., 17.}, + {5., 3.5, .5}}; + +const int NISSAN_DEG_TO_CAN = 100; + +const CanMsg NISSAN_TX_MSGS[] = {{0x169, 0, 8}, {0x2b1, 0, 8}, {0x4cc, 0, 8}, {0x20b, 2, 6}, {0x20b, 1, 6}, {0x280, 2, 8}}; + +// Signals duplicated below due to the fact that these messages can come in on either CAN bus, depending on car model. +AddrCheckStruct nissan_rx_checks[] = { + {.msg = {{0x2, 0, 5, .expected_timestep = 10000U}, + {0x2, 1, 5, .expected_timestep = 10000U}}}, // STEER_ANGLE_SENSOR (100Hz) + {.msg = {{0x285, 0, 8, .expected_timestep = 20000U}, + {0x285, 1, 8, .expected_timestep = 20000U}}}, // WHEEL_SPEEDS_REAR (50Hz) + {.msg = {{0x30f, 2, 3, .expected_timestep = 100000U}, + {0x30f, 1, 3, .expected_timestep = 100000U}}}, // CRUISE_STATE (10Hz) + {.msg = {{0x15c, 0, 8, .expected_timestep = 20000U}, + {0x15c, 1, 8, .expected_timestep = 20000U}, + {0x239, 0, 8, .expected_timestep = 20000U}}}, // GAS_PEDAL (100Hz / 50Hz) + {.msg = {{0x454, 0, 8, .expected_timestep = 100000U}, + {0x454, 1, 8, .expected_timestep = 100000U}, + {0x1cc, 0, 4, .expected_timestep = 10000U}}}, // DOORS_LIGHTS (10Hz) / BRAKE (100Hz) +}; +const int NISSAN_RX_CHECK_LEN = sizeof(nissan_rx_checks) / sizeof(nissan_rx_checks[0]); + +// EPS Location. false = V-CAN, true = C-CAN +bool nissan_alt_eps = false; + +static int nissan_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { + + bool valid = addr_safety_check(to_push, nissan_rx_checks, NISSAN_RX_CHECK_LEN, + NULL, NULL, NULL); + + if (valid) { + int bus = GET_BUS(to_push); + int addr = GET_ADDR(to_push); + + if (((bus == 0) && (!nissan_alt_eps)) || ((bus == 1) && (nissan_alt_eps))) { + if (addr == 0x2) { + // Current steering angle + // Factor -0.1, little endian + int angle_meas_new = (GET_BYTES_04(to_push) & 0xFFFF); + // Need to multiply by 10 here as LKAS and Steering wheel are different base unit + angle_meas_new = to_signed(angle_meas_new, 16) * 10; + + // update array of samples + update_sample(&angle_meas, angle_meas_new); + } + + if (addr == 0x285) { + // Get current speed + // Factor 0.005 + vehicle_speed = ((GET_BYTE(to_push, 2) << 8) | (GET_BYTE(to_push, 3))) * 0.005 / 3.6; + vehicle_moving = vehicle_speed > 0.; + } + + // X-Trail 0x15c, Leaf 0x239 + if ((addr == 0x15c) || (addr == 0x239)) { + if (addr == 0x15c){ + gas_pressed = ((GET_BYTE(to_push, 5) << 2) | ((GET_BYTE(to_push, 6) >> 6) & 0x3)) > 3; + } else { + gas_pressed = GET_BYTE(to_push, 0) > 3; + } + } + } + + // X-trail 0x454, Leaf 0x1cc + if ((addr == 0x454) || (addr == 0x1cc)) { + if (addr == 0x454){ + brake_pressed = (GET_BYTE(to_push, 2) & 0x80) != 0; + } else { + brake_pressed = GET_BYTE(to_push, 0) > 3; + } + } + + // Handle cruise enabled + if ((addr == 0x30f) && (((bus == 2) && (!nissan_alt_eps)) || ((bus == 1) && (nissan_alt_eps)))) { + bool cruise_engaged = (GET_BYTE(to_push, 0) >> 3) & 1; + + if (cruise_engaged && !cruise_engaged_prev) { + controls_allowed = 1; + } + if (!cruise_engaged) { + controls_allowed = 0; + } + cruise_engaged_prev = cruise_engaged; + } + + generic_rx_checks((addr == 0x169) && (bus == 0)); + } + return valid; +} + + +static int nissan_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { + int tx = 1; + int addr = GET_ADDR(to_send); + bool violation = 0; + + if (!msg_allowed(to_send, NISSAN_TX_MSGS, sizeof(NISSAN_TX_MSGS) / sizeof(NISSAN_TX_MSGS[0]))) { + tx = 0; + } + + if (relay_malfunction) { + tx = 0; + } + + // steer cmd checks + if (addr == 0x169) { + int desired_angle = ((GET_BYTE(to_send, 0) << 10) | (GET_BYTE(to_send, 1) << 2) | ((GET_BYTE(to_send, 2) >> 6) & 0x3)); + bool lka_active = (GET_BYTE(to_send, 6) >> 4) & 1; + + // offeset 1310 * NISSAN_DEG_TO_CAN + desired_angle = desired_angle - 131000; + + if (controls_allowed && lka_active) { + // add 1 to not false trigger the violation + float delta_angle_float; + delta_angle_float = (interpolate(NISSAN_LOOKUP_ANGLE_RATE_UP, vehicle_speed) * NISSAN_DEG_TO_CAN) + 1.; + int delta_angle_up = (int)(delta_angle_float); + delta_angle_float = (interpolate(NISSAN_LOOKUP_ANGLE_RATE_DOWN, vehicle_speed) * NISSAN_DEG_TO_CAN) + 1.; + int delta_angle_down = (int)(delta_angle_float); + int highest_desired_angle = desired_angle_last + ((desired_angle_last > 0) ? delta_angle_up : delta_angle_down); + int lowest_desired_angle = desired_angle_last - ((desired_angle_last >= 0) ? delta_angle_down : delta_angle_up); + + // check for violation; + violation |= max_limit_check(desired_angle, highest_desired_angle, lowest_desired_angle); + } + desired_angle_last = desired_angle; + + // desired steer angle should be the same as steer angle measured when controls are off + if ((!controls_allowed) && + ((desired_angle < (angle_meas.min - 1)) || + (desired_angle > (angle_meas.max + 1)))) { + violation = 1; + } + + // no lka_enabled bit if controls not allowed + if (!controls_allowed && lka_active) { + violation = 1; + } + } + + // acc button check, only allow cancel button to be sent + if (addr == 0x20b) { + // Violation of any button other than cancel is pressed + violation |= ((GET_BYTE(to_send, 1) & 0x3d) > 0); + } + + if (violation) { + controls_allowed = 0; + tx = 0; + } + + return tx; +} + + +static int nissan_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { + int bus_fwd = -1; + int addr = GET_ADDR(to_fwd); + + if (bus_num == 0) { + int block_msg = (addr == 0x280); // CANCEL_MSG + if (!block_msg) { + bus_fwd = 2; // ADAS + } + } + + if (bus_num == 2) { + // 0x169 is LKAS, 0x2b1 LKAS_HUD, 0x4cc LKAS_HUD_INFO_MSG + int block_msg = ((addr == 0x169) || (addr == 0x2b1) || (addr == 0x4cc)); + if (!block_msg) { + bus_fwd = 0; // V-CAN + } + } + + if (relay_malfunction) { + bus_fwd = -1; + } + + // fallback to do not forward + return bus_fwd; +} + +static void nissan_init(int16_t param) { + controls_allowed = 0; + nissan_alt_eps = param ? 1 : 0; + relay_malfunction_reset(); +} + +const safety_hooks nissan_hooks = { + .init = nissan_init, + .rx = nissan_rx_hook, + .tx = nissan_tx_hook, + .tx_lin = nooutput_tx_lin_hook, + .fwd = nissan_fwd_hook, + .addr_check = nissan_rx_checks, + .addr_check_len = sizeof(nissan_rx_checks) / sizeof(nissan_rx_checks[0]), +}; diff --git a/panda/board/safety/safety_subaru.h b/panda/board/safety/safety_subaru.h index 3eda8369be4c49..b2e8c0738f9b4e 100644 --- a/panda/board/safety/safety_subaru.h +++ b/panda/board/safety/safety_subaru.h @@ -7,48 +7,165 @@ const int SUBARU_MAX_RATE_UP = 50; const int SUBARU_MAX_RATE_DOWN = 70; const int SUBARU_DRIVER_TORQUE_ALLOWANCE = 60; const int SUBARU_DRIVER_TORQUE_FACTOR = 10; +const int SUBARU_STANDSTILL_THRSLD = 20; // about 1kph -int subaru_cruise_engaged_last = 0; -int subaru_rt_torque_last = 0; -int subaru_desired_torque_last = 0; -uint32_t subaru_ts_last = 0; -struct sample_t subaru_torque_driver; // last few driver torques measured +const int SUBARU_L_DRIVER_TORQUE_ALLOWANCE = 75; +const int SUBARU_L_DRIVER_TORQUE_FACTOR = 10; +const CanMsg SUBARU_TX_MSGS[] = {{0x122, 0, 8}, {0x221, 0, 8}, {0x322, 0, 8}}; +const int SUBARU_TX_MSGS_LEN = sizeof(SUBARU_TX_MSGS) / sizeof(SUBARU_TX_MSGS[0]); -static void subaru_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { - int bus = GET_BUS(to_push); +AddrCheckStruct subaru_rx_checks[] = { + {.msg = {{ 0x40, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}}}, + {.msg = {{0x119, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}}}, + {.msg = {{0x139, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}}}, + {.msg = {{0x13a, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}}}, + {.msg = {{0x240, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 50000U}}}, +}; +const int SUBARU_RX_CHECK_LEN = sizeof(subaru_rx_checks) / sizeof(subaru_rx_checks[0]); + +const CanMsg SUBARU_L_TX_MSGS[] = {{0x161, 0, 8}, {0x164, 0, 8}}; +const int SUBARU_L_TX_MSGS_LEN = sizeof(SUBARU_L_TX_MSGS) / sizeof(SUBARU_L_TX_MSGS[0]); + +// TODO: do checksum and counter checks after adding the signals to the outback dbc file +AddrCheckStruct subaru_l_rx_checks[] = { + {.msg = {{0x140, 0, 8, .expected_timestep = 10000U}}}, + {.msg = {{0x371, 0, 8, .expected_timestep = 20000U}}}, + {.msg = {{0x144, 0, 8, .expected_timestep = 50000U}}}, +}; +const int SUBARU_L_RX_CHECK_LEN = sizeof(subaru_l_rx_checks) / sizeof(subaru_l_rx_checks[0]); + +static uint8_t subaru_get_checksum(CAN_FIFOMailBox_TypeDef *to_push) { + return (uint8_t)GET_BYTE(to_push, 0); +} + +static uint8_t subaru_get_counter(CAN_FIFOMailBox_TypeDef *to_push) { + return (uint8_t)(GET_BYTE(to_push, 1) & 0xF); +} + +static uint8_t subaru_compute_checksum(CAN_FIFOMailBox_TypeDef *to_push) { int addr = GET_ADDR(to_push); + int len = GET_LEN(to_push); + uint8_t checksum = (uint8_t)(addr) + (uint8_t)((unsigned int)(addr) >> 8U); + for (int i = 1; i < len; i++) { + checksum += (uint8_t)GET_BYTE(to_push, i); + } + return checksum; +} - if ((addr == 0x119) && (bus == 0)){ - int torque_driver_new = ((GET_BYTES_04(to_push) >> 16) & 0x7FF); - torque_driver_new = to_signed(torque_driver_new, 11); - // update array of samples - update_sample(&subaru_torque_driver, torque_driver_new); +static int subaru_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { + + bool valid = addr_safety_check(to_push, subaru_rx_checks, SUBARU_RX_CHECK_LEN, + subaru_get_checksum, subaru_compute_checksum, subaru_get_counter); + + if (valid && (GET_BUS(to_push) == 0)) { + int addr = GET_ADDR(to_push); + if (addr == 0x119) { + int torque_driver_new; + torque_driver_new = ((GET_BYTES_04(to_push) >> 16) & 0x7FF); + torque_driver_new = -1 * to_signed(torque_driver_new, 11); + update_sample(&torque_driver, torque_driver_new); + } + + // enter controls on rising edge of ACC, exit controls on ACC off + if (addr == 0x240) { + int cruise_engaged = ((GET_BYTES_48(to_push) >> 9) & 1); + if (cruise_engaged && !cruise_engaged_prev) { + controls_allowed = 1; + } + if (!cruise_engaged) { + controls_allowed = 0; + } + cruise_engaged_prev = cruise_engaged; + } + + // sample wheel speed, averaging opposite corners + if (addr == 0x13a) { + int subaru_speed = (GET_BYTES_04(to_push) >> 12) & 0x1FFF; // FR + subaru_speed += (GET_BYTES_48(to_push) >> 6) & 0x1FFF; // RL + subaru_speed /= 2; + vehicle_moving = subaru_speed > SUBARU_STANDSTILL_THRSLD; + } + + if (addr == 0x139) { + brake_pressed = (GET_BYTES_48(to_push) & 0xFFF0) > 0; + } + + if (addr == 0x40) { + gas_pressed = GET_BYTE(to_push, 4) != 0; + } + + generic_rx_checks((addr == 0x122)); } + return valid; +} + +static int subaru_legacy_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { - // enter controls on rising edge of ACC, exit controls on ACC off - if ((addr == 0x240) && (bus == 0)) { - int cruise_engaged = GET_BYTE(to_push, 5) & 2; - if (cruise_engaged && !subaru_cruise_engaged_last) { - controls_allowed = 1; + bool valid = addr_safety_check(to_push, subaru_l_rx_checks, SUBARU_L_RX_CHECK_LEN, + NULL, NULL, NULL); + + if (valid && (GET_BUS(to_push) == 0)) { + int addr = GET_ADDR(to_push); + if (addr == 0x371) { + int torque_driver_new; + torque_driver_new = (GET_BYTE(to_push, 3) >> 5) + (GET_BYTE(to_push, 4) << 3); + torque_driver_new = to_signed(torque_driver_new, 11); + update_sample(&torque_driver, torque_driver_new); + } + + // enter controls on rising edge of ACC, exit controls on ACC off + if (addr == 0x144) { + int cruise_engaged = ((GET_BYTES_48(to_push) >> 17) & 1); + if (cruise_engaged && !cruise_engaged_prev) { + controls_allowed = 1; + } + if (!cruise_engaged) { + controls_allowed = 0; + } + cruise_engaged_prev = cruise_engaged; + } + + // sample wheel speed, averaging opposite corners + if (addr == 0xD4) { + int subaru_speed = (GET_BYTES_04(to_push) >> 16) & 0xFFFF; // FR + subaru_speed += GET_BYTES_48(to_push) & 0xFFFF; // RL + subaru_speed /= 2; + vehicle_moving = subaru_speed > SUBARU_STANDSTILL_THRSLD; } - if (!cruise_engaged) { - controls_allowed = 0; + + if (addr == 0xD1) { + brake_pressed = ((GET_BYTES_04(to_push) >> 16) & 0xFF) > 0; + } + + if (addr == 0x140) { + gas_pressed = GET_BYTE(to_push, 0) != 0; } - subaru_cruise_engaged_last = cruise_engaged; + + generic_rx_checks((addr == 0x164)); } + return valid; } static int subaru_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int tx = 1; int addr = GET_ADDR(to_send); + if (!msg_allowed(to_send, SUBARU_TX_MSGS, SUBARU_TX_MSGS_LEN)) { + tx = 0; + } + + if (relay_malfunction) { + tx = 0; + } + // steer cmd checks if (addr == 0x122) { int desired_torque = ((GET_BYTES_04(to_send) >> 16) & 0x1FFF); bool violation = 0; uint32_t ts = TIM2->CNT; - desired_torque = to_signed(desired_torque, 13); + + desired_torque = -1 * to_signed(desired_torque, 13); if (controls_allowed) { @@ -56,22 +173,21 @@ static int subaru_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { violation |= max_limit_check(desired_torque, SUBARU_MAX_STEER, -SUBARU_MAX_STEER); // *** torque rate limit check *** - int desired_torque_last = subaru_desired_torque_last; - violation |= driver_limit_check(desired_torque, desired_torque_last, &subaru_torque_driver, + violation |= driver_limit_check(desired_torque, desired_torque_last, &torque_driver, SUBARU_MAX_STEER, SUBARU_MAX_RATE_UP, SUBARU_MAX_RATE_DOWN, SUBARU_DRIVER_TORQUE_ALLOWANCE, SUBARU_DRIVER_TORQUE_FACTOR); // used next time - subaru_desired_torque_last = desired_torque; + desired_torque_last = desired_torque; // *** torque real time rate limit check *** - violation |= rt_rate_limit_check(desired_torque, subaru_rt_torque_last, SUBARU_MAX_RT_DELTA); + violation |= rt_rate_limit_check(desired_torque, rt_torque_last, SUBARU_MAX_RT_DELTA); // every RT_INTERVAL set the new limits - uint32_t ts_elapsed = get_ts_elapsed(ts, subaru_ts_last); + uint32_t ts_elapsed = get_ts_elapsed(ts, ts_last); if (ts_elapsed > SUBARU_RT_INTERVAL) { - subaru_rt_torque_last = desired_torque; - subaru_ts_last = ts; + rt_torque_last = desired_torque; + ts_last = ts; } } @@ -82,9 +198,9 @@ static int subaru_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { // reset to 0 if either controls is not allowed or there's a violation if (violation || !controls_allowed) { - subaru_desired_torque_last = 0; - subaru_rt_torque_last = 0; - subaru_ts_last = ts; + desired_torque_last = 0; + rt_torque_last = 0; + ts_last = ts; } if (violation) { @@ -95,24 +211,111 @@ static int subaru_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { return tx; } -static int subaru_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { +static int subaru_legacy_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { + int tx = 1; + int addr = GET_ADDR(to_send); - int bus_fwd = -1; - if (bus_num == 0) { - bus_fwd = 2; // Camera CAN + if (!msg_allowed(to_send, SUBARU_L_TX_MSGS, SUBARU_L_TX_MSGS_LEN)) { + tx = 0; } - if (bus_num == 2) { - // 356 is LKAS for outback 2015 - // 356 is LKAS for Global Platform - // 545 is ES_Distance - // 802 is ES_LKAS - int addr = GET_ADDR(to_fwd); - int block_msg = (addr == 290) || (addr == 356) || (addr == 545) || (addr == 802); - if (!block_msg) { - bus_fwd = 0; // Main CAN + + if (relay_malfunction) { + tx = 0; + } + + // steer cmd checks + if (addr == 0x164) { + int desired_torque = ((GET_BYTES_04(to_send) >> 8) & 0x1FFF); + bool violation = 0; + uint32_t ts = TIM2->CNT; + + desired_torque = -1 * to_signed(desired_torque, 13); + + if (controls_allowed) { + + // *** global torque limit check *** + violation |= max_limit_check(desired_torque, SUBARU_MAX_STEER, -SUBARU_MAX_STEER); + + // *** torque rate limit check *** + violation |= driver_limit_check(desired_torque, desired_torque_last, &torque_driver, + SUBARU_MAX_STEER, SUBARU_MAX_RATE_UP, SUBARU_MAX_RATE_DOWN, + SUBARU_L_DRIVER_TORQUE_ALLOWANCE, SUBARU_L_DRIVER_TORQUE_FACTOR); + + // used next time + desired_torque_last = desired_torque; + + // *** torque real time rate limit check *** + violation |= rt_rate_limit_check(desired_torque, rt_torque_last, SUBARU_MAX_RT_DELTA); + + // every RT_INTERVAL set the new limits + uint32_t ts_elapsed = get_ts_elapsed(ts, ts_last); + if (ts_elapsed > SUBARU_RT_INTERVAL) { + rt_torque_last = desired_torque; + ts_last = ts; + } + } + + // no torque if controls is not allowed + if (!controls_allowed && (desired_torque != 0)) { + violation = 1; + } + + // reset to 0 if either controls is not allowed or there's a violation + if (violation || !controls_allowed) { + desired_torque_last = 0; + rt_torque_last = 0; + ts_last = ts; + } + + if (violation) { + tx = 0; + } + + } + return tx; +} + +static int subaru_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { + int bus_fwd = -1; + + if (!relay_malfunction) { + if (bus_num == 0) { + bus_fwd = 2; // Camera CAN + } + if (bus_num == 2) { + // Global platform + // 0x122 ES_LKAS + // 0x221 ES_Distance + // 0x322 ES_LKAS_State + int addr = GET_ADDR(to_fwd); + int block_msg = ((addr == 0x122) || (addr == 0x221) || (addr == 0x322)); + if (!block_msg) { + bus_fwd = 0; // Main CAN + } } } + // fallback to do not forward + return bus_fwd; +} +static int subaru_legacy_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { + int bus_fwd = -1; + + if (!relay_malfunction) { + if (bus_num == 0) { + bus_fwd = 2; // Camera CAN + } + if (bus_num == 2) { + // Preglobal platform + // 0x161 is ES_CruiseThrottle + // 0x164 is ES_LKAS + int addr = GET_ADDR(to_fwd); + int block_msg = ((addr == 0x161) || (addr == 0x164)); + if (!block_msg) { + bus_fwd = 0; // Main CAN + } + } + } // fallback to do not forward return bus_fwd; } @@ -122,6 +325,17 @@ const safety_hooks subaru_hooks = { .rx = subaru_rx_hook, .tx = subaru_tx_hook, .tx_lin = nooutput_tx_lin_hook, - .ignition = default_ign_hook, .fwd = subaru_fwd_hook, + .addr_check = subaru_rx_checks, + .addr_check_len = sizeof(subaru_rx_checks) / sizeof(subaru_rx_checks[0]), +}; + +const safety_hooks subaru_legacy_hooks = { + .init = nooutput_init, + .rx = subaru_legacy_rx_hook, + .tx = subaru_legacy_tx_hook, + .tx_lin = nooutput_tx_lin_hook, + .fwd = subaru_legacy_fwd_hook, + .addr_check = subaru_l_rx_checks, + .addr_check_len = sizeof(subaru_l_rx_checks) / sizeof(subaru_l_rx_checks[0]), }; diff --git a/panda/board/safety/safety_tesla.h b/panda/board/safety/safety_tesla.h index 02726bf356a8e6..646e367024e2f8 100644 --- a/panda/board/safety/safety_tesla.h +++ b/panda/board/safety/safety_tesla.h @@ -8,7 +8,7 @@ // brake rising edge // brake > 0mph - +void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number, bool skip_tx_hook); // 2m/s are added to be less restrictive const struct lookup_t TESLA_LOOKUP_ANGLE_RATE_UP = { {2., 7., 17.}, @@ -22,6 +22,25 @@ const struct lookup_t TESLA_LOOKUP_MAX_ANGLE = { {2., 29., 38.}, {500., 500., 500.}}; +// TODO: do checksum and counter checks. Add correct timestep, 0.1s for now. +AddrCheckStruct tesla_rx_checks[] = { + //STW_ANGLHP_STAT + {.msg = {{ 0x00E, 0, 8, .check_checksum = false, .max_counter = 15U, .expected_timestep = 100000U}}}, + //STW_ACTN_RQ + {.msg = {{ 0x045, 0, 8, .check_checksum = false, .max_counter = 15U, .expected_timestep = 100000U}}}, + //DI_torque1 + {.msg = {{ 0x108, 0, 8, .check_checksum = false, .max_counter = 15U, .expected_timestep = 100000U}}}, + //DI_torque2 + {.msg = {{ 0x118, 0, 6, .check_checksum = false, .max_counter = 15U, .expected_timestep = 100000U}}}, + //GTW_carState + {.msg = {{ 0x318, 0, 8, .check_checksum = false, .max_counter = 15U, .expected_timestep = 100000U}}}, + //GTW_status + {.msg = {{ 0x348, 0, 8, .check_checksum = false, .max_counter = 15U, .expected_timestep = 100000U}}}, + //DI_state + {.msg = {{ 0x368, 0, 8, .check_checksum = false, .max_counter = 15U, .expected_timestep = 100000U}}}, +}; +const int TESLA_RX_CHECK_LEN = sizeof(tesla_rx_checks) / sizeof(tesla_rx_checks[0]); + const uint32_t TESLA_RT_INTERVAL = 250000; // 250ms between real time checks struct sample_t tesla_angle_meas; // last 3 steer angles @@ -41,9 +60,8 @@ int current_car_time = -1; int time_at_last_stalk_pull = -1; int eac_status = 0; -int tesla_ignition_started = 0; - /* <-- revB giraffe GPIO */ +/* #include "../drivers/uja1023.h" uint32_t tesla_ts_brakelight_on_last = 0; @@ -55,24 +73,24 @@ int stw_menu_current_output_state = 0; int stw_menu_btn_state_last = 0; int stw_menu_output_flag = 0; int high_beam_lever_state = 0; +*/ /* revB giraffe GPIO --> */ int tesla_radar_status = 0; //0-not present, 1-initializing, 2-active uint32_t tesla_last_radar_signal = 0; -const uint32_t TESLA_RADAR_TIMEOUT = 1000000; // 1 second between real time checks +const uint32_t TESLA_RADAR_TIMEOUT = 10000000; // 10s second between real time checks char radar_VIN[] = " "; //leave empty if your radar VIN matches the car VIN int tesla_radar_vin_complete = 0; -int tesla_radar_can = 1; +uint8_t tesla_radar_can = 1; +uint8_t tesla_epas_can = 2; int tesla_radar_trigger_message_id = 0; //not used by tesla, to showcase for other cars int radarPosition = 0; //0 nosecone, 1 facelift int radarEpasType = 0; //0/1 bosch, 2-4 mando -//EPB enable counter -int EPB_epasControl_idx = 0; //settings from bb_openpilot.cfg - +int DAS_gtwConfigReceived = 0; int enable_das_emulation = 1; int enable_radar_emulation = 1; @@ -86,6 +104,7 @@ int streetSignObject_b3 = 0; int streetSignObject_active = 0; //fake DAS counters +int DAS_uom = 0; //units of measure, 0 = MPH, 1 = km/h int DAS_bootID_sent = 0; int fake_DAS_counter = 0; int DAS_object_idx = 0; @@ -108,6 +127,7 @@ int DI_locStatus_idx = 0; int DAS_carLog_idx = 0; int DAS_telemetry_idx = 0; + //fake DAS variables int DAS_longC_enabled = 0; int DAS_speed_limit_kph = 0; @@ -119,6 +139,8 @@ int DAS_jerk_min = 0x000; int DAS_jerk_max = 0x0F; int DAS_gas_to_resume = 0; int DAS_206_apUnavailable = 0; +int DAS_haptic_request = 0; +uint8_t EPB_epasControl_idx = 0; //fake DAS objects int DAS_LEAD_OBJECT_MLB = 0xFFFFFF00; @@ -133,8 +155,9 @@ int DAS_op_status_last_received = 1; int DAS_alca_state = 0x05; int DAS_hands_on_state = 0; int DAS_forward_collision_warning = 0; +int DAS_units_included = 0; int DAS_cc_state = 0; -int DAS_acc_speed_limit_mph = 0; +int DAS_acc_speed_limit = 0; //in car speed units int DAS_acc_speed_kph = 0; int DAS_collision_warning = 0; int DAS_ldwStatus = 0; @@ -183,6 +206,7 @@ int DAS_inDrive_prev = 0; int DAS_present = 0; int tesla_radar_should_send = 0; int DAS_noEpasHarness = 0; +int DAS_usesApillarHarness=0; //fake DAS - last stalk data used to cancel uint32_t DAS_lastStalkL =0x00; @@ -209,6 +233,18 @@ int DAS_208_rackDetected = 0x00; int DAS_025_steeringOverride = 0x00; int DAS_221_lcAborting = 0x00; +//fake DAS - high beam request +int DAS_high_low_beam_request = 0x00; +int DAS_high_low_beam_reason = 0x00; +int DAS_ahb_is_enabled = 0; + +//fake DAS - plain CC condition +int DAS_plain_cc_enabled = 0x00; + +//fake DAS - emergency brakes use +int DAS_emergency_brake_request = 0x00; +int DAS_fleet_speed_state = 0x00; + static int add_tesla_crc(uint32_t MLB, uint32_t MHB , int msg_len) { //"""Calculate CRC8 using 1D poly, FF start, FF end""" @@ -300,20 +336,21 @@ static uint32_t bitShift(int value, int which_octet, int starting_bit_in_octet) return ( value << ((starting_bit_in_octet - 1) + (which_octet -1) * 8)); } -void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number); -static void send_fake_message(uint32_t RIR, uint32_t RDTR,int msg_len, int msg_addr, int bus_num, uint32_t data_lo, uint32_t data_hi) { + +static void send_fake_message(uint32_t RIR, uint32_t RDTR,int msg_len, int msg_addr, uint8_t bus_num, uint32_t data_lo, uint32_t data_hi) { CAN_FIFOMailBox_TypeDef to_send; uint32_t addr_mask = 0x001FFFFF; to_send.RIR = (msg_addr << 21) + (addr_mask & (RIR | 1)); to_send.RDTR = (RDTR & 0xFFFFFFF0) | msg_len; to_send.RDLR = data_lo; to_send.RDHR = data_hi; - can_send(&to_send, bus_num); + can_send(&to_send, bus_num, false); } static void reset_DAS_data(void) { //fake DAS variables + //DAS_gtwConfigReceived = 0; DAS_present = 0; DAS_longC_enabled = 0; DAS_speed_limit_kph = 0; @@ -325,12 +362,13 @@ static void reset_DAS_data(void) { DAS_jerk_max = 0x0F; DAS_gas_to_resume = 0; DAS_206_apUnavailable = 0; + DAS_haptic_request = 0; DAS_op_status = 1; //unavailable DAS_alca_state = 0x05; DAS_hands_on_state = 0; DAS_forward_collision_warning = 0; DAS_cc_state = 0; - DAS_acc_speed_limit_mph = 0; + DAS_acc_speed_limit = 0; DAS_acc_speed_kph = 0; DAS_collision_warning = 0; DAS_telLeftMarkerQuality = 3; //3-high, 2-medium, 1-low 0-lowest @@ -342,6 +380,8 @@ static void reset_DAS_data(void) { DAS_telLeftMarkerColor = 1; //0-unknown, 1-white, 2-yellow, 3-blue DAS_telRightMarkerColor = 1; //0-unknown, 1-white, 2-yellow, 3-blue DAS_turn_signal_request = 0; + DAS_high_low_beam_request = 0; + DAS_high_low_beam_reason = 0; DAS_steeringAngle = 0x4000; DAS_steeringEnabled = 0; DAS_usingPedal = 0; @@ -369,6 +409,9 @@ static void reset_DAS_data(void) { DAS_LEFT_OBJECT_MHB = 0x03FFFF83; DAS_RIGHT_OBJECT_MLB = 0xFFFFFF02; DAS_RIGHT_OBJECT_MHB = 0x03FFFF83; + DAS_plain_cc_enabled = 0x00; + DAS_emergency_brake_request = 0x00; + DAS_fleet_speed_state = 0x00; } @@ -382,19 +425,35 @@ static void do_fake_DAS(uint32_t RIR, uint32_t RDTR) { //check if we got data from OP in the last two seconds if (current_car_time - time_last_DAS_data > 2) { //no message in the last 2 seconds, reset all variables - reset_DAS_data(); + //BB_no_harness: why are we resetting here.... maybe it should be only when disconnecting or not at all + //reset_DAS_data(); if (EON_is_connected == 1) { - //reset_DAS_data(); + reset_DAS_data(); EON_is_connected = 0; } } else { EON_is_connected = 1; } + //ldw type of warning... use haptic if we manually steer + if (DAS_ldwStatus > 0) { + DAS_haptic_request = 1; + //if OP not enabled or manual steering, only use haptic + if (((DAS_219_lcTempUnavailableSpeed == 1) || (DAS_op_status < 5)) && (DAS_ldwStatus > 2)) { + DAS_ldwStatus -= 2; + } + //if OP enabled and no manual steering, always force audible alert + if ((DAS_219_lcTempUnavailableSpeed == 0) && (DAS_op_status == 5) && (DAS_ldwStatus > 0) && (DAS_ldwStatus < 3)) { + DAS_ldwStatus += 2; + } + } else { + DAS_haptic_request = 0; + } + if (fake_DAS_counter % 2 == 0) { //send DAS_steeringControl - 0x488 MHB = 0x00; - MLB = ((DAS_steeringAngle >> 8) & 0x7F) + + MLB = ((DAS_steeringAngle >> 8) & 0x7F) + (DAS_haptic_request << 7) + ((DAS_steeringAngle & 0xFF) << 8) + (((((DAS_steeringEnabled & controls_allowed & DAS_inDrive) )<< 6) + DAS_steeringControl_idx) << 16); int cksm = add_tesla_cksm2(MLB, MHB, 0x488, 3); @@ -496,7 +555,11 @@ static void do_fake_DAS(uint32_t RIR, uint32_t RDTR) { jerk_min = 0x000; jerk_max = 0x0F; acc_state = 0x04;//bb send HOLD? - acc_speed_kph = (int)(DAS_acc_speed_limit_mph * 1.609 * 10.0); + float uom = 1; + if ((DAS_uom == 0) && (DAS_units_included == 0)) { + uom = 1.609; + } + acc_speed_kph = (int)(DAS_acc_speed_limit * uom * 10.0); accel_max = 0x1FE; //(int)((DAS_accel_max + 15 ) / 0.04); accel_min = 0x001; //(int)((DAS_accel_min + 15 ) / 0.04); } @@ -553,7 +616,13 @@ static void do_fake_DAS(uint32_t RIR, uint32_t RDTR) { if (fake_DAS_counter % 4 == 2) { //send DAS_pscControl - 0x219 // 0x90 + DAS_pscControl_idx,0x00,0x00,0x00,0x00,0x00,0x00,0x00 - MLB = 0x90 + DAS_pscControl_idx; + uint8_t eacStatus = 1; + if ((DAS_steeringEnabled & controls_allowed & DAS_inDrive) == 1) { + eacStatus = 2; + } + //BB disabling to see if this is the issue + eacStatus = 0; + MLB = 0x90 + DAS_pscControl_idx + (eacStatus << 8); MHB = 0x00; int cksm = add_tesla_cksm2(MLB, MHB, 0x219, 2); MLB = MLB + (cksm << 16); @@ -749,10 +818,9 @@ static void do_fake_DAS(uint32_t RIR, uint32_t RDTR) { if (fake_DAS_counter % 50 == 0) { //send DAS_status - 0x399 - int sl = (int)(DAS_speed_limit_kph / 5); - MLB = DAS_op_status + 0xF0 + (sl << 8) + (((DAS_collision_warning << 6) + sl) << 16); - MHB = ((DAS_cc_state & 0x03) << 3) + (DAS_ldwStatus << 5) + - (((DAS_hands_on_state << 2) + ((DAS_alca_state & 0x03) << 6)) << 8) + + MLB = DAS_op_status + 0xF0 + (DAS_speed_limit_kph << 8) + (((DAS_collision_warning << 6) + DAS_speed_limit_kph) << 16); + MHB = ((DAS_fleet_speed_state & 0x03) << 3) + (DAS_ldwStatus << 5) + + (((DAS_hands_on_state << 2) + ((DAS_alca_state & 0x03) << 6) + DAS_fleet_speed_state) << 8) + ((( DAS_status_idx << 4) + (DAS_alca_state >> 2)) << 16); int cksm = add_tesla_cksm2(MLB, MHB, 0x399, 7); MHB = MHB + (cksm << 24); @@ -761,7 +829,11 @@ static void do_fake_DAS(uint32_t RIR, uint32_t RDTR) { DAS_status_idx = DAS_status_idx % 16; //send DAS_status2 - 0x389 - int sl2 = ((int)(DAS_acc_speed_limit_mph / 0.2)) & 0x3FF; + float uom = 1.0; + if ((DAS_uom == 1) && (DAS_units_included == 1)){ + uom = 1.0/1.609; + } + int sl2 = ((int)(DAS_acc_speed_limit * uom / 0.2)) & 0x3FF; if (sl2 == 0) { sl2 = 0x3FF; } @@ -771,10 +843,19 @@ static void do_fake_DAS(uint32_t RIR, uint32_t RDTR) { lcw = 0x01; } int b4 = 0x80; - int b5 = 0x13; + int b5 = 0x13; if (DAS_cc_state > 1) { //enabled or hold - b4 = 0x60; - b5 = 0x12; + b4 = 0x84; + b5 = 0x25; //BB lssState 0x 0x03 should be LSS_STATE_ELK enhanced LK + int _DAS_RobState = 0x02; //active + int _DAS_radarTelemetry = 0x01; // normal + int _DAS_lssState = 0x03; + int _DAS_acc_report = 0x01; //ACC_report_target_CIPV + if (DAS_fleet_speed_state == 2) { + _DAS_acc_report = 0x12; //ACC_report_fleet_speed + } + b4 = (_DAS_acc_report << 2) + ((_DAS_lssState & 0x01) << 7); + b5 =((_DAS_lssState >> 1) & 0x01) + (_DAS_radarTelemetry << 2) + (_DAS_RobState <<4); } MLB = MLB + (b4 << 24); MHB = 0x8000 + b5 + (DAS_status2_idx << 20) + (lcw << 16); @@ -787,7 +868,7 @@ static void do_fake_DAS(uint32_t RIR, uint32_t RDTR) { if (fake_DAS_counter % 50 == 9) { //send DAS_bodyControls - 0x3E9 //0xf1,0x0c + turn_signal_request,0x00,0x00,0x00,0x00,(idx << 4) - MLB = 0x00000CF1 + (DAS_turn_signal_request << 8); + MLB = 0x000000F1 + (DAS_turn_signal_request << 8) + (DAS_high_low_beam_request << 10) + (DAS_high_low_beam_reason << 12); MHB = 0x00 + (DAS_bodyControls_idx << 20); int cksm = add_tesla_cksm2(MLB, MHB, 0x3E9, 7); MHB = MHB + (cksm << 24); @@ -802,17 +883,17 @@ static void do_fake_DAS(uint32_t RIR, uint32_t RDTR) { //send DAS_info - 0x539 switch (DAS_info_idx) { - case 0: + case 0: //changed MLB = 0x0003010a; - MHB = 0x004e0000; + MHB = 0x78000000; break; case 1: MLB = 0x0102000b; MHB = 0x00000001; break; - case 2: + case 2: //changed MLB = 0x0000000d; - MHB = 0x3eac8e5b; + MHB = 0x9c20c11e; break; case 3: MLB = 0xc9060010; @@ -890,15 +971,13 @@ static void do_fake_DAS(uint32_t RIR, uint32_t RDTR) { static void do_EPB_epasControl(uint32_t RIR, uint32_t RDTR) { uint32_t MLB; uint32_t MHB; - MLB = 0x01 + (EPB_epasControl_idx << 8); + MLB = 0x01 + (EPB_epasControl_idx << 8); MHB = 0x00; int cksm = add_tesla_cksm2(MLB, MHB, 0x214, 2); MLB = MLB + (cksm << 16); if (DAS_noEpasHarness == 0) { send_fake_message(RIR,RDTR,3,0x214,2,MLB,MHB); - } else { - send_fake_message(RIR,RDTR,3,0x214,0,MLB,MHB); - } + } EPB_epasControl_idx++; EPB_epasControl_idx = EPB_epasControl_idx % 16; } @@ -922,13 +1001,19 @@ static void do_fake_stalk_cancel(uint32_t RIR, uint32_t RDTR) { -static void tesla_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) +static int tesla_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { - set_gmlan_digital_output(GMLAN_HIGH); - reset_gmlan_switch_timeout(); //we're still in tesla safety mode, reset the timeout counter and make sure our output is enabled + bool valid = false; + //not much to check yet on these, each tesla messaage has checksum in a different place + + + if (DAS_noEpasHarness == 0) { + set_gmlan_digital_output(GMLAN_HIGH); + reset_gmlan_switch_timeout(); //we're still in tesla safety mode, reset the timeout counter and make sure our output is enabled + } uint32_t ts = TIM2->CNT; - int bus_number = (to_push->RDTR >> 4) & 0xFF; + uint8_t bus_number = (to_push->RDTR >> 4) & 0xFF; uint32_t addr; if (to_push->RIR & 4) @@ -943,9 +1028,39 @@ static void tesla_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) // Normal addr = to_push->RIR >> 21; } + if (bus_number == 1) { + //radar is always accepted + valid = true; + } else + if ((bus_number == 0) || (bus_number == 2)) { + if ((addr == 0x00E ) || (addr == 0x045 ) || (addr == 0x108 ) || + (addr == 0x118 ) || (addr == 0x318 ) || (addr == 0x348 ) || (addr == 0x368)) + { + valid = addr_safety_check(to_push, tesla_rx_checks, TESLA_RX_CHECK_LEN, + NULL, NULL, NULL); + } else { + valid = true; + } + + } + + if ((addr == 0x398) && (bus_number == 0)) { + if (DAS_gtwConfigReceived == 0) { + DAS_gtwConfigReceived = 1; + int dashw = ((to_push->RDLR >> 6) & 0x03); + int radhw = ((to_push->RDLR >> 10) & 0x03); + if (dashw == 1) { + DAS_noEpasHarness = 1; + enable_das_emulation = 1; + } + if (radhw > 0) { + enable_radar_emulation = 1; + } + } + } //let's see if the pedal was pressed - if ((addr == 0x552) && (bus_number == 2)) { + if ((addr == 0x552) && (bus_number == tesla_epas_can)) { //m1 = 0.050796813 //m2 = 0.101593626 //d = -22.85856576 @@ -953,17 +1068,18 @@ static void tesla_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) } //we use 0x108 at 100Hz to detect timing of messages sent by our fake DAS and EPB - if (addr == 0x108) { - if (fake_DAS_counter % 10 == 5) { - do_EPB_epasControl(to_push->RIR,to_push->RDTR); + if ((addr == 0x108) && (bus_number == 0)) { + if (DAS_gtwConfigReceived == 1) { + if ((fake_DAS_counter % 10 == 5) && (DAS_noEpasHarness == 0)) { + do_EPB_epasControl(to_push->RIR,to_push->RDTR); + } + do_fake_DAS(to_push->RIR,to_push->RDTR); } - do_fake_DAS(to_push->RIR,to_push->RDTR); - return; + return valid; } // Record the current car time in current_car_time (for use with double-pulling cruise stalk) - if (addr == 0x318) - { + if ((addr == 0x318) && (bus_number == 0)) { int hour = (to_push->RDLR & 0x1F000000) >> 24; int minute = (to_push->RDHR & 0x3F00) >> 8; int second = (to_push->RDLR & 0x3F0000) >> 16; @@ -971,7 +1087,7 @@ static void tesla_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) } //we use EPAS_sysStatus 0x370 to determine if the car is off or on - if (addr == 0x370) { + if ((addr == 0x370) && (bus_number != 1)) { time_last_EPAS_data = current_car_time; } @@ -979,27 +1095,36 @@ static void tesla_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) if (current_car_time - time_last_EPAS_data > 2) { //no message in the last 2 seconds, car is off // GTW_status - tesla_ignition_started = 0; time_last_EPAS_data = -10; } else { - tesla_ignition_started = 1; + } //see if cruise is enabled [Enabled, standstill or Override] and cancel if using pedal - if (addr == 0x368) { + if ((addr == 0x368) && (bus_number == 0)) { //first save values for spamming DAS_diStateL = to_push->RDLR; DAS_diStateH = to_push->RDHR; DAS_diState_idx = (DAS_diStateH & 0xF000 ) >> 12; int acc_state = ((to_push->RDLR & 0xF000) >> 12); + DAS_uom = (to_push->RDLR >> 31) & 1; + //if pedal and CC looks enabled, disable if ((DAS_usingPedal == 1) && ( acc_state >= 2) && ( acc_state <= 4)) { do_fake_stalk_cancel(to_push->RIR, to_push->RDTR); } - + //if ACC not enabled but CC is enabled, disable if more than 2 seconds since last pull + if ((EON_is_connected == 1) && (DAS_usingPedal == 0) && (DAS_cc_state != 2) && ( acc_state >= 2) && ( acc_state <= 4)) { + //disable if more than two seconds since last pull, or there was never a stalk pull + if (((current_car_time >= time_at_last_stalk_pull + 2) && (current_car_time != -1) && (time_at_last_stalk_pull != -1)) || (time_at_last_stalk_pull == -1)) { + if (DAS_plain_cc_enabled == 0) { + do_fake_stalk_cancel(to_push->RIR, to_push->RDTR); + } + } + } } //looking for radar messages; - if ((addr == 0x300) && (bus_number ==1)) + if ((addr == 0x300) && (bus_number == tesla_radar_can)) { uint32_t ts = TIM2->CNT; uint32_t ts_elapsed = get_ts_elapsed(ts, tesla_last_radar_signal); @@ -1018,7 +1143,7 @@ static void tesla_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) } //0x631 is sent by radar to initiate the sync - if ((addr == 0x631) && (bus_number == 1)) + if ((addr == 0x631) && (bus_number == tesla_radar_can)) { uint32_t ts = TIM2->CNT; uint32_t ts_elapsed = get_ts_elapsed(ts, tesla_last_radar_signal); @@ -1036,8 +1161,7 @@ static void tesla_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) } } - if (addr == 0x45) - { + if ((addr == 0x45) && (bus_number == 0)) { //first save for future use DAS_lastStalkL = to_push->RDLR; DAS_lastStalkH = to_push->RDHR; @@ -1062,6 +1186,7 @@ static void tesla_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) do_fake_stalk_cancel(to_push->RIR, to_push->RDTR); } /* <-- revB giraffe GPIO */ + /* int turn_signal_lever = (to_push->RDLR >> 16) & 0x3; //TurnIndLvr_Stat : 16|2@1+ int stw_menu_button = (to_push->RDHR >> 5) & 0x1; //StW_Sw05_Psd : 37|1@1+ high_beam_lever_state = (to_push->RDLR >> 18) & 0x3; //SG_ HiBmLvr_Stat : 18|2@1+ @@ -1124,18 +1249,13 @@ static void tesla_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) stw_menu_output_flag = 0; stw_menu_btn_state_last = 0; } + */ /* revB giraffe GPIO --> */ } // Detect drive rail on (ignition) (start recording) if ((addr == 0x348) && (bus_number == 0)) { - - if ((tesla_ignition_started * DAS_present * tesla_radar_should_send ) == 1) { - //set_uja1023_output_bits(1 << 7); - } else { - //clear_uja1023_output_bits(1 << 7); - } //ALSO use this for radar timeout, this message is always on uint32_t ts = TIM2->CNT; uint32_t ts_elapsed = get_ts_elapsed(ts, tesla_last_radar_signal); @@ -1145,10 +1265,12 @@ static void tesla_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) } } + // exit controls on brake press // DI_torque2::DI_brakePedal 0x118 /* revB giraffe GPIO --> */ + /* if ((addr == 0x118) && (bus_number == 0)) { int drive_state = (to_push->RDLR >> 12) & 0x7; //DI_gear : 12|3@1+ @@ -1156,8 +1278,6 @@ static void tesla_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) int tesla_speed_mph = (((((GET_BYTE(to_push, 3) & 0xF) << 8) + GET_BYTE(to_push, 2)) * 0.05) - 25); - //for fake messages for radar we need also in kph - //actual_speed_kph = (int)(tesla_speed_mph * 1.609); //if the car goes into reverse, set UJA1023 output pin 5 to high. If Drive, set pin 1 high //DI_gear 7 "DI_GEAR_SNA" 4 "DI_GEAR_D" 3 "DI_GEAR_N" 2 "DI_GEAR_R" 1 "DI_GEAR_P" 0 "DI_GEAR_INVALID" ; @@ -1219,7 +1339,13 @@ static void tesla_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) //puts(" Brakelight off!\n"); } } + } + */ /* revB giraffe GPIO --> */ + if ((addr == 0x118) && (bus_number == 0)) + { + int tesla_speed_mph = (((((GET_BYTE(to_push, 3) & 0xF) << 8) + GET_BYTE(to_push, 2)) * 0.05) - 25); + //get vehicle speed in m/2. Tesla gives MPH tesla_speed = (tesla_speed_mph*1.609/3.6); @@ -1234,13 +1360,15 @@ static void tesla_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) DAS_inDrive = 0; } if ((DAS_inDrive == 0) && (DAS_inDrive_prev == 1)) { - reset_DAS_data(); + //BB_no_harness: why are we resetting here? + //reset_DAS_data(); } } // exit controls on EPAS error // EPAS_sysStatus::EPAS_eacStatus 0x370 - if ((addr == 0x370) && (bus_number == 1)) + //BB this was on bus_number 1 which is wrong, but not tested on 2 yet + if ((addr == 0x370) && (bus_number == tesla_epas_can)) { // if EPAS_eacStatus is not 1 or 2, disable control eac_status = (GET_BYTE(to_push, 6) >> 5) & 0x7; @@ -1256,7 +1384,7 @@ static void tesla_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) if ((addr == 0x00E) && (bus_number == 0)) { int angle_meas_now = (int)(((((GET_BYTE(to_push, 0) & 0x3F) << 8) + GET_BYTE(to_push, 1)) * 0.1) - 819.2); - uint32_t ts = TIM2->CNT; + //uint32_t ts = TIM2->CNT; uint32_t ts_elapsed = get_ts_elapsed(ts, tesla_ts_angle_last); // *** angle real time check @@ -1292,9 +1420,9 @@ static void tesla_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) } /* <-- revB giraffe GPIO */ + /* //BO_ 1001 DAS_bodyControls: 8 XXX - if (addr == 0x3e9) - { + if ((addr == 0x3e9) && (bus_number == 0)) { int high_beam_decision = (to_push->RDLR >> 10) & 0x3; //DAS_highLowBeamDecision : 10|2@1+ // highLowBeamDecision: //0: Undecided (Car off) @@ -1320,8 +1448,7 @@ static void tesla_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) } //DAS_bodyControls //BO_ 872 DI_state: 8 DI - if (addr == 0x368) - { + if ((addr == 0x368) && (bus_number == 0)) { int regen_brake_light = (to_push->RDLR >> 8) & 0x1; //DI_regenLight : 8|1@1+ //if the car's brake lights are on, set pin 2 to high if (regen_brake_light == 1) @@ -1339,8 +1466,9 @@ static void tesla_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) //puts(" Brakelight off!\n"); } } - } + }*/ /* revB giraffe GPIO --> */ + return valid; } // all commands: gas/regen, friction brake and steering @@ -1500,6 +1628,25 @@ static int tesla_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) DAS_ldwStatus = (b2 & 0x07); //FLAG NOT USED = ((b2 >> 3) & 0x01); DAS_noEpasHarness = ((b2 >> 4) & 0x01); + DAS_usesApillarHarness = ((b2 >> 5) & 0x01); + if (DAS_noEpasHarness == 1) { + tesla_epas_can = 0; + } else { + tesla_epas_can = 2; + } + return false; + } + + //capture message for AHB and parse + if (addr == 0x65A) { + int b0 = (to_send->RDLR & 0xFF); + int b1 = ((to_send->RDLR >> 8) & 0xFF); + int b2 = ((to_send->RDLR >> 16) & 0xFF); + DAS_high_low_beam_request = b0; + DAS_high_low_beam_reason = b1; + DAS_ahb_is_enabled = b2 & 0x01; + DAS_fleet_speed_state = (b2 >> 1) & 0x03; + //intercept and do not forward return false; } @@ -1515,19 +1662,26 @@ static int tesla_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) int b7 = ((to_send->RDHR >> 24) & 0xFF); DAS_acc_speed_kph = b1; - DAS_acc_speed_limit_mph = b4; + DAS_acc_speed_limit = b4; DAS_longC_enabled = ((b0 & 0x80) >> 7); DAS_gas_to_resume = ((b0 & 0x40) >> 6); DAS_206_apUnavailable = ((b0 & 0x20) >> 5); DAS_collision_warning = ((b0 & 0x10) >> 4); DAS_op_status = (b0 & 0x0F); DAS_turn_signal_request = ((b2 & 0xC0) >> 6); - DAS_forward_collision_warning = ((b2 & 0x30) >> 4); - DAS_hands_on_state = (b2 & 0x0F); + DAS_forward_collision_warning = ((b2 & 0x10) >> 4); + DAS_units_included = ((b2 & 0x20) >> 5); + if (((b2 >> 3) & 0x01) == 0) { + DAS_plain_cc_enabled = 1; + } else { + DAS_plain_cc_enabled = 0; + } + DAS_hands_on_state = (b2 & 0x07); DAS_cc_state = ((b3 & 0xC0)>>6); DAS_usingPedal = ((b3 & 0x20) >> 5); DAS_alca_state = (b3 & 0x1F); - DAS_speed_limit_kph = b5; + DAS_speed_limit_kph = (b5 & 0x1F); + DAS_emergency_brake_request = ((b5 & 0x20) >> 5); time_last_DAS_data = current_car_time; DAS_present = 1; DAS_steeringAngle = ((b7 << 8) + b6) & 0x7FFF; @@ -1573,18 +1727,14 @@ static int tesla_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) static void tesla_init(int16_t param) { UNUSED(param); - controls_allowed = 0; - tesla_ignition_started = 0; - gmlan_switch_init(1); //init the gmlan switch with 1s timeout enabled + if (DAS_noEpasHarness == 0) { + gmlan_switch_init(1); //init the gmlan switch with 1s timeout enabled + } //uja1023_init(); } -static int tesla_ign_hook(void) -{ - return tesla_ignition_started; -} -static void tesla_fwd_to_radar_as_is(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { +static void tesla_fwd_to_radar_as_is(uint8_t bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { if ((enable_radar_emulation == 0) || (tesla_radar_vin_complete !=7) || (tesla_radar_should_send==0) ) { return; } @@ -1593,7 +1743,7 @@ static void tesla_fwd_to_radar_as_is(int bus_num, CAN_FIFOMailBox_TypeDef *to_fw to_send.RDTR = to_fwd->RDTR; to_send.RDLR = to_fwd->RDLR; to_send.RDHR = to_fwd->RDHR; - can_send(&to_send, bus_num); + can_send(&to_send, bus_num, true); } @@ -1602,7 +1752,7 @@ static uint32_t radar_VIN_char(int pos, int shift) { } -static void tesla_fwd_to_radar_modded(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { +static void tesla_fwd_to_radar_modded(uint8_t bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { if ((enable_radar_emulation == 0) || (tesla_radar_vin_complete !=7) || (tesla_radar_should_send==0) ) { return; } @@ -1613,11 +1763,12 @@ static void tesla_fwd_to_radar_modded(int bus_num, CAN_FIFOMailBox_TypeDef *to_f to_send.RDLR = to_fwd->RDLR; to_send.RDHR = to_fwd->RDHR; uint32_t addr_mask = 0x001FFFFF; - //now modd + //now modd messages as needed + // if DAS_noEpasHarness == 1, only modify IDs because we have iBooster and thus everything else is correct if (addr == 0x405 ) { to_send.RIR = (0x2B9 << 21) + (addr_mask & (to_fwd->RIR | 1)); - if (((to_send.RDLR & 0x10) == 0x10) && (sizeof(radar_VIN) >= 4)) + if (((to_send.RDLR & 0x10) == 0x10) && (sizeof(radar_VIN) >= 4) && (DAS_noEpasHarness == 0)) { int rec = to_send.RDLR & 0xFF; if (rec == 0x10) { @@ -1633,64 +1784,78 @@ static void tesla_fwd_to_radar_modded(int bus_num, CAN_FIFOMailBox_TypeDef *to_f to_send.RDHR = radar_VIN_char(13,0) | radar_VIN_char(14,1) | radar_VIN_char(15,2) | radar_VIN_char(16,3); } } - can_send(&to_send, bus_num); + can_send(&to_send, bus_num, true); return; } if (addr == 0x398 ) { - //change frontradarHW = 1 and dashw = 1 - //SG_ GTW_dasHw : 7|2@0+ (1,0) [0|0] "" NEO - //SG_ GTW_parkAssistInstalled : 11|2@0+ (1,0) [0|0] "" NEO - to_send.RDHR = to_send.RDHR | 0x100; - //resend on CAN 0 first - to_send.RIR = (to_fwd->RIR | 1); - can_send(&to_send,0); - - to_send.RDLR = to_send.RDLR & 0xFFFFF33F; - to_send.RDLR = to_send.RDLR | 0x440; - // change the autopilot to 1 - to_send.RDHR = to_fwd->RDHR & 0xCFFF0F0F; - to_send.RDHR = to_send.RDHR | 0x10000000 | (radarPosition << 4) | (radarEpasType << 12); - - if ((sizeof(radar_VIN) >= 4) && ((int)(radar_VIN[7]) == 0x32)) { - //also change to AWD if needed (most likely) if manual VIN and if position 8 of VIN is a 2 (dual motor) - to_send.RDLR = to_send.RDLR | 0x08; + if (DAS_noEpasHarness == 0) { + //change frontradarHW = 1 and dashw = 1 + //SG_ GTW_dasHw : 7|2@0+ (1,0) [0|0] "" NEO + //SG_ GTW_parkAssistInstalled : 11|2@0+ (1,0) [0|0] "" NEO + + to_send.RDHR = to_send.RDHR | 0x100; //TODO if this is Park Assist, it should be RDLR not RDHR + //resend on CAN 0 first + to_send.RIR = (to_fwd->RIR | 1); + //can_send(&to_send,0, true); + + + to_send.RDLR = to_send.RDLR & 0xFFFFF33F; + to_send.RDLR = to_send.RDLR | 0x440; + // change the autopilot to 1 + to_send.RDHR = to_fwd->RDHR & 0xCFFF0F0F; + to_send.RDHR = to_send.RDHR | 0x10000000 | (radarPosition << 4) | (radarEpasType << 12); + + if ((sizeof(radar_VIN) >= 4) && (((int)(radar_VIN[7]) == 0x32) || ((int)(radar_VIN[7]) == 0x34))) { + //also change to AWD if needed (most likely) if manual VIN and if position 8 of VIN is a 2 (dual motor) + to_send.RDLR = to_send.RDLR | 0x08; + } } //now change address and send to radar to_send.RIR = (0x2A9 << 21) + (addr_mask & (to_fwd->RIR | 1)); - can_send(&to_send, bus_num); + can_send(&to_send, bus_num, true); return; } if (addr == 0x00E ) { to_send.RIR = (0x199 << 21) + (addr_mask & (to_fwd->RIR | 1)); - //check if angular speed sends SNA (0x3FFF) - if (((to_send.RDLR >> 16) & 0xFF3F) == 0xFF3F) { - //if yes replace 0x3FFFF with 0x2000 which is 0 angular change - to_send.RDLR = (to_send.RDLR & 0x00C0FFFF) | (0x0020 << 16); - //if this is the case, most likely we need to change the model too - //so remove CRC and StW_AnglHP_Sens_Id (1st octet of RDHR) - to_send.RDHR = to_send.RDHR & 0x00FFFFF0; - //force StW_AnglHP_Sens_Id to DELPHI (0x04 1st octet of RDHR) - to_send.RDHR = to_send.RDHR | 0x00000004; - //compute new CRC - int crc = add_tesla_crc(to_send.RDLR, to_send.RDHR,7); - //Add new CRC - to_send.RDHR = to_send.RDHR | (crc << 24); - } - can_send(&to_send, bus_num); + if (DAS_noEpasHarness == 0) { + //check if angular speed sends SNA (0x3FFF) + if (((to_send.RDLR >> 16) & 0xFF3F) == 0xFF3F) { + //if yes replace 0x3FFFF with 0x2000 which is 0 angular change + to_send.RDLR = (to_send.RDLR & 0x00C0FFFF) | (0x0020 << 16); + //if this is the case, most likely we need to change the model too + //so remove CRC and StW_AnglHP_Sens_Id (1st octet of RDHR) + to_send.RDHR = to_send.RDHR & 0x00FFFFF0; + //force StW_AnglHP_Sens_Id to DELPHI (0x04 1st octet of RDHR) + to_send.RDHR = to_send.RDHR | 0x00000004; + //compute new CRC + int crc = add_tesla_crc(to_send.RDLR, to_send.RDHR,7); + //Add new CRC + to_send.RDHR = to_send.RDHR | (crc << 24); + } + } + can_send(&to_send, bus_num, true); return; } if (addr == 0x20A ) { to_send.RIR = (0x159 << 21) + (addr_mask & (to_fwd->RIR | 1)); - can_send(&to_send, bus_num); + can_send(&to_send, bus_num, true); return; } + + if ((addr == 0x148) && (DAS_noEpasHarness == 1)) + { + to_send.RIR = (0x1A9 << 21) + (addr_mask & (to_fwd->RIR | 1)); + can_send(&to_send, bus_num, true); + return; + } + if (addr == 0x115 ) { @@ -1698,18 +1863,20 @@ static void tesla_fwd_to_radar_modded(int bus_num, CAN_FIFOMailBox_TypeDef *to_f to_send.RIR = (0x129 << 21) + (addr_mask & (to_fwd->RIR | 1)); int cksm = (0x16 + (counter << 4)) & 0xFF; - can_send(&to_send, bus_num); + can_send(&to_send, bus_num, true); - //we don't get 0x148 DI_espControl so send as 0x1A9 on CAN1 and also as 0x148 on CAN0 - to_send.RDTR = (to_fwd->RDTR & 0xFFFFFFF0) | 0x05; - to_send.RIR = (0x148 << 21) + (addr_mask & (to_fwd->RIR | 1)); - to_send.RDLR = 0x000C0000 | (counter << 28); - cksm = (0x38 + 0x0C + (counter << 4)) & 0xFF; - to_send.RDHR = cksm; - //can_send(&to_send, 0); + if (DAS_noEpasHarness == 0) { + //we don't get 0x148 DI_espControl so send as 0x1A9 on CAN1 and also as 0x148 on CAN0 + to_send.RDTR = (to_fwd->RDTR & 0xFFFFFFF0) | 0x05; + to_send.RIR = (0x148 << 21) + (addr_mask & (to_fwd->RIR | 1)); + to_send.RDLR = 0x000C0000 | (counter << 28); + cksm = (0x38 + 0x0C + (counter << 4)) & 0xFF; + to_send.RDHR = cksm; + //can_send(&to_send, 0, true); - to_send.RIR = (0x1A9 << 21) + (addr_mask & (to_fwd->RIR | 1)); - can_send(&to_send, bus_num); + to_send.RIR = (0x1A9 << 21) + (addr_mask & (to_fwd->RIR | 1)); + can_send(&to_send, bus_num, true); + } return; } @@ -1717,81 +1884,84 @@ static void tesla_fwd_to_radar_modded(int bus_num, CAN_FIFOMailBox_TypeDef *to_f if (addr == 0x145) { to_send.RIR = (0x149 << 21) + (addr_mask & (to_fwd->RIR | 1)); - can_send(&to_send, bus_num); + can_send(&to_send, bus_num, true); return; } - /*if (addr == 0x175) + if ((addr == 0x175) && (DAS_noEpasHarness == 1)) { to_send.RIR = (0x169 << 21) + (addr_mask & (to_fwd->RIR | 1)); - can_send(&to_send, bus_num); + can_send(&to_send, bus_num, true); return; - }*/ + } if (addr == 0x118 ) { to_send.RIR = (0x119 << 21) + (addr_mask & (to_fwd->RIR | 1)); - can_send(&to_send, bus_num); + can_send(&to_send, bus_num, true); - //we don't get 0x175 ESP_wheelSpeeds so send as 0x169 on CAN1 and also as 0x175 on CAN0 - int counter = to_fwd->RDHR & 0x0F; - to_send.RIR = (0x169 << 21) + (addr_mask & (to_fwd->RIR | 1)); - to_send.RDTR = (to_fwd->RDTR & 0xFFFFFFF0) | 0x08; - int32_t speed_kph = (((0xFFF0000 & to_send.RDLR) >> 16) * 0.05 -25) * 1.609; - if (speed_kph < 0) { - speed_kph = 0; + if (DAS_noEpasHarness == 0) { + //we don't get 0x175 ESP_wheelSpeeds so send as 0x169 on CAN1 and also as 0x175 on CAN0 + int counter = to_fwd->RDHR & 0x0F; + to_send.RIR = (0x169 << 21) + (addr_mask & (to_fwd->RIR | 1)); + to_send.RDTR = (to_fwd->RDTR & 0xFFFFFFF0) | 0x08; + int32_t speed_kph = (((0xFFF0000 & to_send.RDLR) >> 16) * 0.05 -25) * 1.609; + if (speed_kph < 0) { + speed_kph = 0; + } + // is AHB is enabled, use low apeed to spread radar angle + if ((speed_kph > 2 ) && (DAS_ahb_is_enabled == 1)) { + // speed_kph = 2; + } + if (((0xFFF0000 & to_send.RDLR) >> 16) == 0xFFF) { + speed_kph = 0x1FFF; //0xFFF is signal not available for DI_Torque2 speed 0x118; should be SNA or 0x1FFF for 0x169 + } else { + speed_kph = (int)(speed_kph/0.04) & 0x1FFF; + } + to_send.RDLR = (speed_kph | (speed_kph << 13) | (speed_kph << 26)) & 0xFFFFFFFF; + to_send.RDHR = ((speed_kph >> 6) | (speed_kph << 7) | (counter << 20)) & 0x00FFFFFF; + int cksm = 0x76; + cksm = (cksm + (to_send.RDLR & 0xFF) + ((to_send.RDLR >> 8) & 0xFF) + ((to_send.RDLR >> 16) & 0xFF) + ((to_send.RDLR >> 24) & 0xFF)) & 0xFF; + cksm = (cksm + (to_send.RDHR & 0xFF) + ((to_send.RDHR >> 8) & 0xFF) + ((to_send.RDHR >> 16) & 0xFF) + ((to_send.RDHR >> 24) & 0xFF)) & 0xFF; + to_send.RDHR = to_send.RDHR | (cksm << 24); + can_send(&to_send, bus_num, true); } - if (((0xFFF0000 & to_send.RDLR) >> 16) == 0xFFF) { - speed_kph = 0x1FFF; //0xFFF is signal not available for DI_Torque2 speed 0x118; should be SNA or 0x1FFF for 0x169 - } else { - speed_kph = (int)(speed_kph/0.04) & 0x1FFF; - } - to_send.RDLR = (speed_kph | (speed_kph << 13) | (speed_kph << 26)) & 0xFFFFFFFF; - to_send.RDHR = ((speed_kph >> 6) | (speed_kph << 7) | (counter << 20)) & 0x00FFFFFF; - int cksm = 0x76; - cksm = (cksm + (to_send.RDLR & 0xFF) + ((to_send.RDLR >> 8) & 0xFF) + ((to_send.RDLR >> 16) & 0xFF) + ((to_send.RDLR >> 24) & 0xFF)) & 0xFF; - cksm = (cksm + (to_send.RDHR & 0xFF) + ((to_send.RDHR >> 8) & 0xFF) + ((to_send.RDHR >> 16) & 0xFF) + ((to_send.RDHR >> 24) & 0xFF)) & 0xFF; - to_send.RDHR = to_send.RDHR | (cksm << 24); - can_send(&to_send, bus_num); - - //to_send.RIR = (0x175 << 21) + (addr_mask & (to_fwd->RIR | 1)); - //can_send(&to_send, 0); return; } if (addr == 0x108 ) { to_send.RIR = (0x109 << 21) + (addr_mask & (to_fwd->RIR | 1)); - can_send(&to_send, bus_num); + can_send(&to_send, bus_num, true); return; } if (addr == 0x308 ) { to_send.RIR = (0x209 << 21) + (addr_mask & (to_fwd->RIR | 1)); - can_send(&to_send, bus_num); + can_send(&to_send, bus_num, true); return; } if (addr == 0x45 ) { to_send.RIR = (0x219 << 21) + (addr_mask & (to_fwd->RIR | 1)); - can_send(&to_send, bus_num); + can_send(&to_send, bus_num, true); return; } if (addr == 0x148 ) { to_send.RIR = (0x1A9 << 21) + (addr_mask & (to_fwd->RIR | 1)); - can_send(&to_send, bus_num); + can_send(&to_send, bus_num,true); return; } if (addr == 0x30A) { to_send.RIR = (0x2D9 << 21) + (addr_mask & (to_fwd->RIR | 1)); - can_send(&to_send, bus_num); + can_send(&to_send, bus_num, true); return; } @@ -1802,9 +1972,31 @@ static int tesla_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { int32_t addr = to_fwd->RIR >> 21; + int ret_val = -1; + + //if we never got the config from gtw, don't forward anything anywhere + if (DAS_gtwConfigReceived == 0) { + return -1; + } - if (bus_num == 0) + //first let's deal with the messages we need to send to radar + if ((bus_num == 0) || ((bus_num == 2 ) && (DAS_usesApillarHarness == 1))) { + + //compute return value; do not forward 0->2 and 2->0 if no epas harness + if (bus_num == 0) { + if (DAS_noEpasHarness == 0) { + ret_val=2; + } else { + ret_val=-1; + } + } else if (bus_num == 2) { + if (DAS_noEpasHarness == 0) { + ret_val=0; + } else { + ret_val=-1; + } + } //check all messages we need to also send to radar, moddified, after we receive 0x631 from radar //148 does not exist, we use 115 at the same frequency to trigger and pass static vals @@ -1813,46 +2005,54 @@ static int tesla_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) (addr == 0x115 ) || (addr == 0x148 ) || (addr == 0x145))) { tesla_fwd_to_radar_modded(tesla_radar_can, to_fwd); + return ret_val; } //check all messages we need to also send to radar, moddified, all the time if (((addr == 0xE ) || (addr == 0x308 ) || (addr == 0x45 ) || (addr == 0x398 ) || (addr == 0x405 ) || (addr == 0x30A)) && (enable_radar_emulation == 1)) { tesla_fwd_to_radar_modded(tesla_radar_can, to_fwd); + return ret_val; } //forward to radar unmodded the UDS messages 0x641 if (addr == 0x641 ) { tesla_fwd_to_radar_as_is(tesla_radar_can, to_fwd); + return ret_val; } + + } + //now let's deal with CAN0 alone + if (bus_num == 0) { - // change inhibit of GTW_epasControl + if (DAS_noEpasHarness == 0) { + ret_val=2; + } else { + ret_val=-1; + } + + // change inhibit of GTW_epasControl and enabled haptic for LDW if (addr == 0x101) { - to_fwd->RDLR = GET_BYTES_04(to_fwd) | 0x4000; // 0x4000: WITH_ANGLE, 0xC000: WITH_BOTH (angle and torque) + to_fwd->RDLR = GET_BYTES_04(to_fwd) | 0x4000 | 0x1000; + // 0x4000: WITH_ANGLE, 0xC000: WITH_BOTH (angle and torque) + // 0x1000: enabled LDW for haptic int checksum = (GET_BYTE(to_fwd, 1) + GET_BYTE(to_fwd, 0) + 2) & 0xFF; to_fwd->RDLR = GET_BYTES_04(to_fwd) & 0xFFFF; to_fwd->RDLR = GET_BYTES_04(to_fwd) + (checksum << 16); - if (DAS_noEpasHarness == 0) { - return 2; - } else { - return -1; - } + return ret_val; } - // remove EPB_epasControl - if (addr == 0x214) - { + if (addr == 0x214) { + //inhibit ibooster epas kill signal return -1; } - if (DAS_noEpasHarness == 0) { - return 2; - } else { - return -1; - } + //forward everything else to CAN 2 unless claiming no harness + return ret_val; } + //now let's deal with CAN1 - Radar if (bus_num == tesla_radar_can) { //send radar 0x531 and 0x651 from Radar CAN to CAN0 if ((addr == 0x531) || (addr == 0x651)){ @@ -1863,25 +2063,17 @@ static int tesla_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) return -1; } - if (bus_num == 2) + //now let's deal with CAN2 + if ((bus_num == tesla_epas_can) && (bus_num > 0)) { - // remove GTW_epasControl in forwards - if (addr == 0x101) - { - return -1; - } - // remove Pedal in forwards if ((addr == 0x551) || (addr == 0x552)) { return -1; } - if (DAS_noEpasHarness == 0) { - return 0; - } else { - return -1; - } + //forward everything else to CAN 0 unless claiming no harness + return 0; } return -1; } @@ -1891,6 +2083,7 @@ const safety_hooks tesla_hooks = { .rx = tesla_rx_hook, .tx = tesla_tx_hook, .tx_lin = nooutput_tx_lin_hook, - .ignition = tesla_ign_hook, .fwd = tesla_fwd_hook, -}; \ No newline at end of file + .addr_check = tesla_rx_checks, + .addr_check_len = sizeof(tesla_rx_checks) / sizeof(tesla_rx_checks[0]), +}; diff --git a/panda/board/safety/safety_toyota.h b/panda/board/safety/safety_toyota.h index c1ce996058611b..2ffe58b5f46c6f 100644 --- a/panda/board/safety/safety_toyota.h +++ b/panda/board/safety/safety_toyota.h @@ -14,88 +14,126 @@ const uint32_t TOYOTA_RT_INTERVAL = 250000; // 250ms between real time checks // longitudinal limits const int TOYOTA_MAX_ACCEL = 1500; // 1.5 m/s2 -const int TOYOTA_MIN_ACCEL = -3000; // 3.0 m/s2 - -const int TOYOTA_GAS_INTERCEPTOR_THRESHOLD = 475; // ratio between offset and gain from dbc file +const int TOYOTA_MIN_ACCEL = -3000; // -3.0 m/s2 + +const int TOYOTA_ISO_MAX_ACCEL = 2000; // 2.0 m/s2 +const int TOYOTA_ISO_MIN_ACCEL = -3500; // -3.5 m/s2 + +const int TOYOTA_STANDSTILL_THRSLD = 100; // 1kph + +// Roughly calculated using the offsets in openpilot +5%: +// In openpilot: ((gas1_norm + gas2_norm)/2) > 15 +// gas_norm1 = ((gain_dbc*gas1) + offset1_dbc) +// gas_norm2 = ((gain_dbc*gas2) + offset2_dbc) +// In this safety: ((gas1 + gas2)/2) > THRESHOLD +const int TOYOTA_GAS_INTERCEPTOR_THRSLD = 845; +#define TOYOTA_GET_INTERCEPTOR(msg) (((GET_BYTE((msg), 0) << 8) + GET_BYTE((msg), 1) + (GET_BYTE((msg), 2) << 8) + GET_BYTE((msg), 3)) / 2) // avg between 2 tracks + +const CanMsg TOYOTA_TX_MSGS[] = {{0x283, 0, 7}, {0x2E6, 0, 8}, {0x2E7, 0, 8}, {0x33E, 0, 7}, {0x344, 0, 8}, {0x365, 0, 7}, {0x366, 0, 7}, {0x4CB, 0, 8}, // DSU bus 0 + {0x128, 1, 6}, {0x141, 1, 4}, {0x160, 1, 8}, {0x161, 1, 7}, {0x470, 1, 4}, // DSU bus 1 + {0x2E4, 0, 5}, {0x411, 0, 8}, {0x412, 0, 8}, {0x343, 0, 8}, {0x1D2, 0, 8}, // LKAS + ACC + {0x200, 0, 6}}; // interceptor + +AddrCheckStruct toyota_rx_checks[] = { + {.msg = {{ 0xaa, 0, 8, .check_checksum = false, .expected_timestep = 12000U}}}, + {.msg = {{0x260, 0, 8, .check_checksum = true, .expected_timestep = 20000U}}}, + {.msg = {{0x1D2, 0, 8, .check_checksum = true, .expected_timestep = 30000U}}}, + {.msg = {{0x224, 0, 8, .check_checksum = false, .expected_timestep = 25000U}, + {0x226, 0, 8, .check_checksum = false, .expected_timestep = 25000U}}}, +}; +const int TOYOTA_RX_CHECKS_LEN = sizeof(toyota_rx_checks) / sizeof(toyota_rx_checks[0]); // global actuation limit states int toyota_dbc_eps_torque_factor = 100; // conversion factor for STEER_TORQUE_EPS in %: see dbc file -// states -int toyota_giraffe_switch_1 = 0; // is giraffe switch 1 high? -int toyota_camera_forwarded = 0; // should we forward the camera bus? -int toyota_desired_torque_last = 0; // last desired steer torque -int toyota_rt_torque_last = 0; // last desired torque for real time check -uint32_t toyota_ts_last = 0; -int toyota_cruise_engaged_last = 0; // cruise state -int toyota_gas_prev = 0; -struct sample_t toyota_torque_meas; // last 3 motor torques produced by the eps +static uint8_t toyota_compute_checksum(CAN_FIFOMailBox_TypeDef *to_push) { + int addr = GET_ADDR(to_push); + int len = GET_LEN(to_push); + uint8_t checksum = (uint8_t)(addr) + (uint8_t)((unsigned int)(addr) >> 8U) + (uint8_t)(len); + for (int i = 0; i < (len - 1); i++) { + checksum += (uint8_t)GET_BYTE(to_push, i); + } + return checksum; +} +static uint8_t toyota_get_checksum(CAN_FIFOMailBox_TypeDef *to_push) { + int checksum_byte = GET_LEN(to_push) - 1; + return (uint8_t)(GET_BYTE(to_push, checksum_byte)); +} -static void toyota_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { +static int toyota_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { - int bus = GET_BUS(to_push); - int addr = GET_ADDR(to_push); + bool valid = addr_safety_check(to_push, toyota_rx_checks, TOYOTA_RX_CHECKS_LEN, + toyota_get_checksum, toyota_compute_checksum, NULL); - // get eps motor torque (0.66 factor in dbc) - if (addr == 0x260) { - int torque_meas_new = (GET_BYTE(to_push, 5) << 8) | GET_BYTE(to_push, 6); - torque_meas_new = to_signed(torque_meas_new, 16); + if (valid && (GET_BUS(to_push) == 0)) { + int addr = GET_ADDR(to_push); - // scale by dbc_factor - torque_meas_new = (torque_meas_new * toyota_dbc_eps_torque_factor) / 100; + // get eps motor torque (0.66 factor in dbc) + if (addr == 0x260) { + int torque_meas_new = (GET_BYTE(to_push, 5) << 8) | GET_BYTE(to_push, 6); + torque_meas_new = to_signed(torque_meas_new, 16); - // update array of sample - update_sample(&toyota_torque_meas, torque_meas_new); + // scale by dbc_factor + torque_meas_new = (torque_meas_new * toyota_dbc_eps_torque_factor) / 100; - // increase torque_meas by 1 to be conservative on rounding - toyota_torque_meas.min--; - toyota_torque_meas.max++; - } + // update array of sample + update_sample(&torque_meas, torque_meas_new); - // enter controls on rising edge of ACC, exit controls on ACC off - if (addr == 0x1D2) { - // 5th bit is CRUISE_ACTIVE - int cruise_engaged = GET_BYTE(to_push, 0) & 0x20; - if (!cruise_engaged) { - controls_allowed = 0; + // increase torque_meas by 1 to be conservative on rounding + torque_meas.min--; + torque_meas.max++; } - if (cruise_engaged && !toyota_cruise_engaged_last) { - controls_allowed = 1; + + // enter controls on rising edge of ACC, exit controls on ACC off + // exit controls on rising edge of gas press + if (addr == 0x1D2) { + // 5th bit is CRUISE_ACTIVE + int cruise_engaged = GET_BYTE(to_push, 0) & 0x20; + if (!cruise_engaged) { + controls_allowed = 0; + } + if (cruise_engaged && !cruise_engaged_prev) { + controls_allowed = 1; + } + cruise_engaged_prev = cruise_engaged; + + // sample gas pedal + if (!gas_interceptor_detected) { + gas_pressed = ((GET_BYTE(to_push, 0) >> 4) & 1) == 0; + } } - toyota_cruise_engaged_last = cruise_engaged; - } - // exit controls on rising edge of interceptor gas press - if (addr == 0x201) { - gas_interceptor_detected = 1; - int gas_interceptor = GET_INTERCEPTOR(to_push); - if ((gas_interceptor > TOYOTA_GAS_INTERCEPTOR_THRESHOLD) && - (gas_interceptor_prev <= TOYOTA_GAS_INTERCEPTOR_THRESHOLD) && - long_controls_allowed) { - controls_allowed = 0; + // sample speed + if (addr == 0xaa) { + int speed = 0; + // sum 4 wheel speeds + for (int i=0; i<8; i+=2) { + int next_byte = i + 1; // hack to deal with misra 10.8 + speed += (GET_BYTE(to_push, i) << 8) + GET_BYTE(to_push, next_byte) - 0x1a6f; + } + vehicle_moving = ABS(speed / 4) > TOYOTA_STANDSTILL_THRSLD; } - gas_interceptor_prev = gas_interceptor; - } - // exit controls on rising edge of gas press - if (addr == 0x2C1) { - int gas = GET_BYTE(to_push, 6) & 0xFF; - if ((gas > 0) && (toyota_gas_prev == 0) && !gas_interceptor_detected && long_controls_allowed) { - controls_allowed = 0; + // most cars have brake_pressed on 0x226, corolla and rav4 on 0x224 + if ((addr == 0x224) || (addr == 0x226)) { + int byte = (addr == 0x224) ? 0 : 4; + brake_pressed = ((GET_BYTE(to_push, byte) >> 5) & 1) != 0; } - toyota_gas_prev = gas; - } - // msgs are only on bus 2 if panda is connected to frc - if (bus == 2) { - toyota_camera_forwarded = 1; - } + // sample gas interceptor + if (addr == 0x201) { + gas_interceptor_detected = 1; + int gas_interceptor = TOYOTA_GET_INTERCEPTOR(to_push); + gas_pressed = gas_interceptor > TOYOTA_GAS_INTERCEPTOR_THRSLD; - // 0x2E4 is lkas cmd. If it is on bus 0, then giraffe switch 1 is high - if ((addr == 0x2E4) && (bus == 0)) { - toyota_giraffe_switch_1 = 1; + // TODO: remove this, only left in for gas_interceptor_prev test + gas_interceptor_prev = gas_interceptor; + } + + generic_rx_checks((addr == 0x2E4)); } + return valid; } static int toyota_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { @@ -104,17 +142,20 @@ static int toyota_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int addr = GET_ADDR(to_send); int bus = GET_BUS(to_send); + if (!msg_allowed(to_send, TOYOTA_TX_MSGS, sizeof(TOYOTA_TX_MSGS)/sizeof(TOYOTA_TX_MSGS[0]))) { + tx = 0; + } + + if (relay_malfunction) { + tx = 0; + } + // Check if msg is sent on BUS 0 if (bus == 0) { - // no IPAS in non IPAS mode - if ((addr == 0x266) || (addr == 0x167)) { - tx = 0; - } - // GAS PEDAL: safety check if (addr == 0x200) { - if (!controls_allowed || !long_controls_allowed) { + if (!controls_allowed) { if (GET_BYTE(to_send, 0) || GET_BYTE(to_send, 1)) { tx = 0; } @@ -125,12 +166,15 @@ static int toyota_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { if (addr == 0x343) { int desired_accel = (GET_BYTE(to_send, 0) << 8) | GET_BYTE(to_send, 1); desired_accel = to_signed(desired_accel, 16); - if (!controls_allowed || !long_controls_allowed) { + if (!controls_allowed) { if (desired_accel != 0) { tx = 0; } } - bool violation = max_limit_check(desired_accel, TOYOTA_MAX_ACCEL, TOYOTA_MIN_ACCEL); + bool violation = (unsafe_mode & UNSAFE_RAISE_LONGITUDINAL_LIMITS_TO_ISO_MAX)? + max_limit_check(desired_accel, TOYOTA_ISO_MAX_ACCEL, TOYOTA_ISO_MIN_ACCEL) : + max_limit_check(desired_accel, TOYOTA_MAX_ACCEL, TOYOTA_MIN_ACCEL); + if (violation) { tx = 0; } @@ -150,20 +194,20 @@ static int toyota_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { violation |= max_limit_check(desired_torque, TOYOTA_MAX_TORQUE, -TOYOTA_MAX_TORQUE); // *** torque rate limit check *** - violation |= dist_to_meas_check(desired_torque, toyota_desired_torque_last, - &toyota_torque_meas, TOYOTA_MAX_RATE_UP, TOYOTA_MAX_RATE_DOWN, TOYOTA_MAX_TORQUE_ERROR); + violation |= dist_to_meas_check(desired_torque, desired_torque_last, + &torque_meas, TOYOTA_MAX_RATE_UP, TOYOTA_MAX_RATE_DOWN, TOYOTA_MAX_TORQUE_ERROR); // used next time - toyota_desired_torque_last = desired_torque; + desired_torque_last = desired_torque; // *** torque real time rate limit check *** - violation |= rt_rate_limit_check(desired_torque, toyota_rt_torque_last, TOYOTA_MAX_RT_DELTA); + violation |= rt_rate_limit_check(desired_torque, rt_torque_last, TOYOTA_MAX_RT_DELTA); // every RT_INTERVAL set the new limits - uint32_t ts_elapsed = get_ts_elapsed(ts, toyota_ts_last); + uint32_t ts_elapsed = get_ts_elapsed(ts, ts_last); if (ts_elapsed > TOYOTA_RT_INTERVAL) { - toyota_rt_torque_last = desired_torque; - toyota_ts_last = ts; + rt_torque_last = desired_torque; + ts_last = ts; } } @@ -174,9 +218,9 @@ static int toyota_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { // reset to 0 if either controls is not allowed or there's a violation if (violation || !controls_allowed) { - toyota_desired_torque_last = 0; - toyota_rt_torque_last = 0; - toyota_ts_last = ts; + desired_torque_last = 0; + rt_torque_last = 0; + ts_last = ts; } if (violation) { @@ -185,32 +229,31 @@ static int toyota_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { } } - // 1 allows the message through return tx; } static void toyota_init(int16_t param) { controls_allowed = 0; - toyota_giraffe_switch_1 = 0; - toyota_camera_forwarded = 0; + relay_malfunction_reset(); + gas_interceptor_detected = 0; toyota_dbc_eps_torque_factor = param; } static int toyota_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { int bus_fwd = -1; - if (toyota_camera_forwarded && !toyota_giraffe_switch_1) { + if (!relay_malfunction) { if (bus_num == 0) { bus_fwd = 2; } if (bus_num == 2) { int addr = GET_ADDR(to_fwd); // block stock lkas messages and stock acc messages (if OP is doing ACC) - // in TSS2, 0.191 is LTA which we need to block to avoid controls collision + // in TSS2, 0x191 is LTA which we need to block to avoid controls collision int is_lkas_msg = ((addr == 0x2E4) || (addr == 0x412) || (addr == 0x191)); // in TSS2 the camera does ACC as well, so filter 0x343 int is_acc_msg = (addr == 0x343); - int block_msg = is_lkas_msg || (is_acc_msg && long_controls_allowed); + int block_msg = is_lkas_msg || is_acc_msg; if (!block_msg) { bus_fwd = 0; } @@ -224,6 +267,7 @@ const safety_hooks toyota_hooks = { .rx = toyota_rx_hook, .tx = toyota_tx_hook, .tx_lin = nooutput_tx_lin_hook, - .ignition = default_ign_hook, .fwd = toyota_fwd_hook, + .addr_check = toyota_rx_checks, + .addr_check_len = sizeof(toyota_rx_checks)/sizeof(toyota_rx_checks[0]), }; diff --git a/panda/board/safety/safety_toyota_ipas.h b/panda/board/safety/safety_toyota_ipas.h deleted file mode 100644 index 3e3a3b3a24134f..00000000000000 --- a/panda/board/safety/safety_toyota_ipas.h +++ /dev/null @@ -1,169 +0,0 @@ -// uses tons from safety_toyota -// TODO: refactor to repeat less code - -// IPAS override -const int32_t TOYOTA_IPAS_OVERRIDE_THRESHOLD = 200; // disallow controls when user torque exceeds this value - -// 2m/s are added to be less restrictive -const struct lookup_t LOOKUP_ANGLE_RATE_UP = { - {2., 7., 17.}, - {5., .8, .15}}; - -const struct lookup_t LOOKUP_ANGLE_RATE_DOWN = { - {2., 7., 17.}, - {5., 3.5, .4}}; - -const float RT_ANGLE_FUDGE = 1.5; // for RT checks allow 50% more angle change -const float CAN_TO_DEG = 2. / 3.; // convert angles from CAN unit to degrees - -int ipas_state = 1; // 1 disabled, 3 executing angle control, 5 override -int angle_control = 0; // 1 if direct angle control packets are seen -float speed = 0.; - -struct sample_t angle_meas; // last 3 steer angles -struct sample_t torque_driver; // last 3 driver steering torque - -// state of angle limits -int16_t desired_angle_last = 0; // last desired steer angle -int16_t rt_angle_last = 0; // last desired torque for real time check -uint32_t ts_angle_last = 0; - -int controls_allowed_last = 0; - - -static void toyota_ipas_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { - // check standard toyota stuff as well - toyota_rx_hook(to_push); - - int addr = GET_ADDR(to_push); - - if (addr == 0x260) { - // get driver steering torque - int16_t torque_driver_new = (GET_BYTE(to_push, 1) << 8) | GET_BYTE(to_push, 2); - - // update array of samples - update_sample(&torque_driver, torque_driver_new); - } - - // get steer angle - if (addr == 0x25) { - int angle_meas_new = ((GET_BYTE(to_push, 0) & 0xF) << 8) | GET_BYTE(to_push, 1); - uint32_t ts = TIM2->CNT; - - angle_meas_new = to_signed(angle_meas_new, 12); - - // update array of samples - update_sample(&angle_meas, angle_meas_new); - - // *** angle real time check - // add 1 to not false trigger the violation and multiply by 20 since the check is done every 250ms and steer angle is updated at 80Hz - int rt_delta_angle_up = ((int)(RT_ANGLE_FUDGE * ((interpolate(LOOKUP_ANGLE_RATE_UP, speed) * 20. * CAN_TO_DEG) + 1.))); - int rt_delta_angle_down = ((int)(RT_ANGLE_FUDGE * ((interpolate(LOOKUP_ANGLE_RATE_DOWN, speed) * 20. * CAN_TO_DEG) + 1.))); - int highest_rt_angle = rt_angle_last + ((rt_angle_last > 0) ? rt_delta_angle_up : rt_delta_angle_down); - int lowest_rt_angle = rt_angle_last - ((rt_angle_last > 0) ? rt_delta_angle_down : rt_delta_angle_up); - - // every RT_INTERVAL or when controls are turned on, set the new limits - uint32_t ts_elapsed = get_ts_elapsed(ts, ts_angle_last); - if ((ts_elapsed > TOYOTA_RT_INTERVAL) || (controls_allowed && !controls_allowed_last)) { - rt_angle_last = angle_meas_new; - ts_angle_last = ts; - } - - // check for violation - if (angle_control && - ((angle_meas_new < lowest_rt_angle) || - (angle_meas_new > highest_rt_angle))) { - controls_allowed = 0; - } - - controls_allowed_last = controls_allowed; - } - - // get speed - if (addr == 0xb4) { - speed = ((float)((GET_BYTE(to_push, 5) << 8) | GET_BYTE(to_push, 6))) * 0.01 / 3.6; - } - - // get ipas state - if (addr == 0x262) { - ipas_state = GET_BYTE(to_push, 0) & 0xf; - } - - // exit controls on high steering override - if (angle_control && ((torque_driver.min > TOYOTA_IPAS_OVERRIDE_THRESHOLD) || - (torque_driver.max < -TOYOTA_IPAS_OVERRIDE_THRESHOLD) || - (ipas_state==5))) { - controls_allowed = 0; - } -} - -static int toyota_ipas_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { - - int tx = 1; - int bypass_standard_tx_hook = 0; - int bus = GET_BUS(to_send); - int addr = GET_ADDR(to_send); - - // Check if msg is sent on BUS 0 - if (bus == 0) { - - // STEER ANGLE - if ((addr == 0x266) || (addr == 0x167)) { - - angle_control = 1; // we are in angle control mode - int desired_angle = ((GET_BYTE(to_send, 0) & 0xF) << 8) | GET_BYTE(to_send, 1); - int ipas_state_cmd = GET_BYTE(to_send, 0) >> 4; - bool violation = 0; - - desired_angle = to_signed(desired_angle, 12); - - if (controls_allowed) { - // add 1 to not false trigger the violation - float delta_angle_float; - delta_angle_float = (interpolate(LOOKUP_ANGLE_RATE_UP, speed) * CAN_TO_DEG) + 1.; - int delta_angle_up = (int) (delta_angle_float); - delta_angle_float = (interpolate(LOOKUP_ANGLE_RATE_DOWN, speed) * CAN_TO_DEG) + 1.; - int delta_angle_down = (int) (delta_angle_float); - - int highest_desired_angle = desired_angle_last + ((desired_angle_last > 0) ? delta_angle_up : delta_angle_down); - int lowest_desired_angle = desired_angle_last - ((desired_angle_last > 0) ? delta_angle_down : delta_angle_up); - if ((desired_angle > highest_desired_angle) || - (desired_angle < lowest_desired_angle)){ - violation = 1; - controls_allowed = 0; - } - } - - // desired steer angle should be the same as steer angle measured when controls are off - if ((!controls_allowed) && - ((desired_angle < (angle_meas.min - 1)) || - (desired_angle > (angle_meas.max + 1)) || - (ipas_state_cmd != 1))) { - violation = 1; - } - - desired_angle_last = desired_angle; - - if (violation) { - tx = 0; - } - bypass_standard_tx_hook = 1; - } - } - - // check standard toyota stuff as well if addr isn't IPAS related - if (!bypass_standard_tx_hook) { - tx &= toyota_tx_hook(to_send); - } - - return tx; -} - -const safety_hooks toyota_ipas_hooks = { - .init = toyota_init, - .rx = toyota_ipas_rx_hook, - .tx = toyota_ipas_tx_hook, - .tx_lin = nooutput_tx_lin_hook, - .ignition = default_ign_hook, - .fwd = toyota_fwd_hook, -}; diff --git a/panda/board/safety/safety_volkswagen.h b/panda/board/safety/safety_volkswagen.h new file mode 100644 index 00000000000000..2a2c4474558346 --- /dev/null +++ b/panda/board/safety/safety_volkswagen.h @@ -0,0 +1,406 @@ +// Safety-relevant steering constants for Volkswagen +const int VOLKSWAGEN_MAX_STEER = 300; // 3.0 Nm (EPS side max of 3.0Nm with fault if violated) +const int VOLKSWAGEN_MAX_RT_DELTA = 75; // 4 max rate up * 50Hz send rate * 250000 RT interval / 1000000 = 50 ; 50 * 1.5 for safety pad = 75 +const uint32_t VOLKSWAGEN_RT_INTERVAL = 250000; // 250ms between real time checks +const int VOLKSWAGEN_MAX_RATE_UP = 4; // 2.0 Nm/s RoC limit (EPS rack has own soft-limit of 5.0 Nm/s) +const int VOLKSWAGEN_MAX_RATE_DOWN = 10; // 5.0 Nm/s RoC limit (EPS rack has own soft-limit of 5.0 Nm/s) +const int VOLKSWAGEN_DRIVER_TORQUE_ALLOWANCE = 80; +const int VOLKSWAGEN_DRIVER_TORQUE_FACTOR = 3; + +// Safety-relevant CAN messages for the Volkswagen MQB platform +#define MSG_ESP_19 0x0B2 // RX from ABS, for wheel speeds +#define MSG_EPS_01 0x09F // RX from EPS, for driver steering torque +#define MSG_ESP_05 0x106 // RX from ABS, for brake switch state +#define MSG_TSK_06 0x120 // RX from ECU, for ACC status from drivetrain coordinator +#define MSG_MOTOR_20 0x121 // RX from ECU, for driver throttle input +#define MSG_HCA_01 0x126 // TX by OP, Heading Control Assist steering torque +#define MSG_GRA_ACC_01 0x12B // TX by OP, ACC control buttons for cancel/resume +#define MSG_LDW_02 0x397 // TX by OP, Lane line recognition and text alerts + +// Transmit of GRA_ACC_01 is allowed on bus 0 and 2 to keep compatibility with gateway and camera integration +const CanMsg VOLKSWAGEN_MQB_TX_MSGS[] = {{MSG_HCA_01, 0, 8}, {MSG_GRA_ACC_01, 0, 8}, {MSG_GRA_ACC_01, 2, 8}, {MSG_LDW_02, 0, 8}}; +const int VOLKSWAGEN_MQB_TX_MSGS_LEN = sizeof(VOLKSWAGEN_MQB_TX_MSGS) / sizeof(VOLKSWAGEN_MQB_TX_MSGS[0]); + +AddrCheckStruct volkswagen_mqb_rx_checks[] = { + {.msg = {{MSG_ESP_19, 0, 8, .check_checksum = false, .max_counter = 0U, .expected_timestep = 10000U}}}, + {.msg = {{MSG_EPS_01, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}}}, + {.msg = {{MSG_ESP_05, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}}}, + {.msg = {{MSG_TSK_06, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}}}, + {.msg = {{MSG_MOTOR_20, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}}}, +}; +const int VOLKSWAGEN_MQB_RX_CHECKS_LEN = sizeof(volkswagen_mqb_rx_checks) / sizeof(volkswagen_mqb_rx_checks[0]); + +// Safety-relevant CAN messages for the Volkswagen PQ35/PQ46/NMS platforms +#define MSG_LENKHILFE_3 0x0D0 // RX from EPS, for steering angle and driver steering torque +#define MSG_HCA_1 0x0D2 // TX by OP, Heading Control Assist steering torque +#define MSG_MOTOR_2 0x288 // RX from ECU, for CC state and brake switch state +#define MSG_MOTOR_3 0x380 // RX from ECU, for driver throttle input +#define MSG_GRA_NEU 0x38A // TX by OP, ACC control buttons for cancel/resume +#define MSG_BREMSE_3 0x4A0 // RX from ABS, for wheel speeds +#define MSG_LDW_1 0x5BE // TX by OP, Lane line recognition and text alerts + +// Transmit of GRA_Neu is allowed on bus 0 and 2 to keep compatibility with gateway and camera integration +const CanMsg VOLKSWAGEN_PQ_TX_MSGS[] = {{MSG_HCA_1, 0, 5}, {MSG_GRA_NEU, 0, 4}, {MSG_GRA_NEU, 2, 4}, {MSG_LDW_1, 0, 8}}; +const int VOLKSWAGEN_PQ_TX_MSGS_LEN = sizeof(VOLKSWAGEN_PQ_TX_MSGS) / sizeof(VOLKSWAGEN_PQ_TX_MSGS[0]); + +AddrCheckStruct volkswagen_pq_rx_checks[] = { + {.msg = {{MSG_LENKHILFE_3, 0, 6, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}}}, + {.msg = {{MSG_MOTOR_2, 0, 8, .check_checksum = false, .max_counter = 0U, .expected_timestep = 20000U}}}, + {.msg = {{MSG_MOTOR_3, 0, 8, .check_checksum = false, .max_counter = 0U, .expected_timestep = 10000U}}}, + {.msg = {{MSG_BREMSE_3, 0, 8, .check_checksum = false, .max_counter = 0U, .expected_timestep = 10000U}}}, +}; +const int VOLKSWAGEN_PQ_RX_CHECKS_LEN = sizeof(volkswagen_pq_rx_checks) / sizeof(volkswagen_pq_rx_checks[0]); + +int volkswagen_torque_msg = 0; +int volkswagen_lane_msg = 0; +uint8_t volkswagen_crc8_lut_8h2f[256]; // Static lookup table for CRC8 poly 0x2F, aka 8H2F/AUTOSAR + + +static uint8_t volkswagen_get_checksum(CAN_FIFOMailBox_TypeDef *to_push) { + return (uint8_t)GET_BYTE(to_push, 0); +} + +static uint8_t volkswagen_mqb_get_counter(CAN_FIFOMailBox_TypeDef *to_push) { + // MQB message counters are consistently found at LSB 8. + return (uint8_t)GET_BYTE(to_push, 1) & 0xFU; +} + +static uint8_t volkswagen_pq_get_counter(CAN_FIFOMailBox_TypeDef *to_push) { + // Few PQ messages have counters, and their offsets are inconsistent. This + // function works only for Lenkhilfe_3 at this time. + return (uint8_t)(GET_BYTE(to_push, 1) & 0xF0U) >> 4; +} + +static uint8_t volkswagen_mqb_compute_crc(CAN_FIFOMailBox_TypeDef *to_push) { + int addr = GET_ADDR(to_push); + int len = GET_LEN(to_push); + + // This is CRC-8H2F/AUTOSAR with a twist. See the OpenDBC implementation + // of this algorithm for a version with explanatory comments. + + uint8_t crc = 0xFFU; + for (int i = 1; i < len; i++) { + crc ^= (uint8_t)GET_BYTE(to_push, i); + crc = volkswagen_crc8_lut_8h2f[crc]; + } + + uint8_t counter = volkswagen_mqb_get_counter(to_push); + switch(addr) { + case MSG_EPS_01: + crc ^= (uint8_t[]){0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5}[counter]; + break; + case MSG_ESP_05: + crc ^= (uint8_t[]){0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07}[counter]; + break; + case MSG_TSK_06: + crc ^= (uint8_t[]){0xC4,0xE2,0x4F,0xE4,0xF8,0x2F,0x56,0x81,0x9F,0xE5,0x83,0x44,0x05,0x3F,0x97,0xDF}[counter]; + break; + case MSG_MOTOR_20: + crc ^= (uint8_t[]){0xE9,0x65,0xAE,0x6B,0x7B,0x35,0xE5,0x5F,0x4E,0xC7,0x86,0xA2,0xBB,0xDD,0xEB,0xB4}[counter]; + break; + default: // Undefined CAN message, CRC check expected to fail + break; + } + crc = volkswagen_crc8_lut_8h2f[crc]; + + return crc ^ 0xFFU; +} + +static uint8_t volkswagen_pq_compute_checksum(CAN_FIFOMailBox_TypeDef *to_push) { + int len = GET_LEN(to_push); + uint8_t checksum = 0U; + + for (int i = 1; i < len; i++) { + checksum ^= (uint8_t)GET_BYTE(to_push, i); + } + + return checksum; +} + +static void volkswagen_mqb_init(int16_t param) { + UNUSED(param); + + controls_allowed = false; + relay_malfunction_reset(); + volkswagen_torque_msg = MSG_HCA_01; + volkswagen_lane_msg = MSG_LDW_02; + gen_crc_lookup_table(0x2F, volkswagen_crc8_lut_8h2f); +} + +static void volkswagen_pq_init(int16_t param) { + UNUSED(param); + + controls_allowed = false; + relay_malfunction_reset(); + volkswagen_torque_msg = MSG_HCA_1; + volkswagen_lane_msg = MSG_LDW_1; +} + +static int volkswagen_mqb_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { + + bool valid = addr_safety_check(to_push, volkswagen_mqb_rx_checks, VOLKSWAGEN_MQB_RX_CHECKS_LEN, + volkswagen_get_checksum, volkswagen_mqb_compute_crc, volkswagen_mqb_get_counter); + + if (valid && (GET_BUS(to_push) == 0)) { + int addr = GET_ADDR(to_push); + + // Update in-motion state by sampling front wheel speeds + // Signal: ESP_19.ESP_VL_Radgeschw_02 (front left) in scaled km/h + // Signal: ESP_19.ESP_VR_Radgeschw_02 (front right) in scaled km/h + if (addr == MSG_ESP_19) { + int wheel_speed_fl = GET_BYTE(to_push, 4) | (GET_BYTE(to_push, 5) << 8); + int wheel_speed_fr = GET_BYTE(to_push, 6) | (GET_BYTE(to_push, 7) << 8); + // Check for average front speed in excess of 0.3m/s, 1.08km/h + // DBC speed scale 0.0075: 0.3m/s = 144, sum both wheels to compare + vehicle_moving = (wheel_speed_fl + wheel_speed_fr) > 288; + } + + // Update driver input torque samples + // Signal: EPS_01.Driver_Strain (absolute torque) + // Signal: EPS_01.Driver_Strain_VZ (direction) + if (addr == MSG_EPS_01) { + int torque_driver_new = GET_BYTE(to_push, 5) | ((GET_BYTE(to_push, 6) & 0x1F) << 8); + int sign = (GET_BYTE(to_push, 6) & 0x80) >> 7; + if (sign == 1) { + torque_driver_new *= -1; + } + update_sample(&torque_driver, torque_driver_new); + } + + // Update ACC status from drivetrain coordinator for controls-allowed state + // Signal: TSK_06.TSK_Status + if (addr == MSG_TSK_06) { + int acc_status = (GET_BYTE(to_push, 3) & 0x7); + controls_allowed = ((acc_status == 3) || (acc_status == 4) || (acc_status == 5)) ? 1 : 0; + } + + // Signal: Motor_20.MO_Fahrpedalrohwert_01 + if (addr == MSG_MOTOR_20) { + gas_pressed = ((GET_BYTES_04(to_push) >> 12) & 0xFF) != 0; + } + + // Signal: ESP_05.ESP_Fahrer_bremst + if (addr == MSG_ESP_05) { + brake_pressed = (GET_BYTE(to_push, 3) & 0x4) >> 2; + } + + generic_rx_checks((addr == MSG_HCA_01)); + } + return valid; +} + +static int volkswagen_pq_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { + + bool valid = addr_safety_check(to_push, volkswagen_pq_rx_checks, VOLKSWAGEN_PQ_RX_CHECKS_LEN, + volkswagen_get_checksum, volkswagen_pq_compute_checksum, volkswagen_pq_get_counter); + + if (valid && (GET_BUS(to_push) == 0)) { + int addr = GET_ADDR(to_push); + + // Update in-motion state by sampling front wheel speeds + // Signal: Bremse_3.Radgeschw__VL_4_1 (front left) + // Signal: Bremse_3.Radgeschw__VR_4_1 (front right) + if (addr == MSG_BREMSE_3) { + int wheel_speed_fl = (GET_BYTE(to_push, 0) | (GET_BYTE(to_push, 1) << 8)) >> 1; + int wheel_speed_fr = (GET_BYTE(to_push, 2) | (GET_BYTE(to_push, 3) << 8)) >> 1; + // Check for average front speed in excess of 0.3m/s, 1.08km/h + // DBC speed scale 0.01: 0.3m/s = 108, sum both wheels to compare + vehicle_moving = (wheel_speed_fl + wheel_speed_fr) > 216; + } + + // Update driver input torque samples + // Signal: Lenkhilfe_3.LH3_LM (absolute torque) + // Signal: Lenkhilfe_3.LH3_LMSign (direction) + if (addr == MSG_LENKHILFE_3) { + int torque_driver_new = GET_BYTE(to_push, 2) | ((GET_BYTE(to_push, 3) & 0x3) << 8); + int sign = (GET_BYTE(to_push, 3) & 0x4) >> 2; + if (sign == 1) { + torque_driver_new *= -1; + } + update_sample(&torque_driver, torque_driver_new); + } + + // Update ACC status from ECU for controls-allowed state + // Signal: Motor_2.GRA_Status + if (addr == MSG_MOTOR_2) { + int acc_status = (GET_BYTE(to_push, 2) & 0xC0) >> 6; + controls_allowed = ((acc_status == 1) || (acc_status == 2)) ? 1 : 0; + } + + // Signal: Motor_3.Fahrpedal_Rohsignal + if (addr == MSG_MOTOR_3) { + gas_pressed = (GET_BYTE(to_push, 2)); + } + + // Signal: Motor_2.Bremslichtschalter + if (addr == MSG_MOTOR_2) { + brake_pressed = (GET_BYTE(to_push, 2) & 0x1); + } + + generic_rx_checks((addr == MSG_HCA_1)); + } + return valid; +} + +static bool volkswagen_steering_check(int desired_torque) { + bool violation = false; + uint32_t ts = TIM2->CNT; + + if (controls_allowed) { + // *** global torque limit check *** + violation |= max_limit_check(desired_torque, VOLKSWAGEN_MAX_STEER, -VOLKSWAGEN_MAX_STEER); + + // *** torque rate limit check *** + violation |= driver_limit_check(desired_torque, desired_torque_last, &torque_driver, + VOLKSWAGEN_MAX_STEER, VOLKSWAGEN_MAX_RATE_UP, VOLKSWAGEN_MAX_RATE_DOWN, + VOLKSWAGEN_DRIVER_TORQUE_ALLOWANCE, VOLKSWAGEN_DRIVER_TORQUE_FACTOR); + desired_torque_last = desired_torque; + + // *** torque real time rate limit check *** + violation |= rt_rate_limit_check(desired_torque, rt_torque_last, VOLKSWAGEN_MAX_RT_DELTA); + + // every RT_INTERVAL set the new limits + uint32_t ts_elapsed = get_ts_elapsed(ts, ts_last); + if (ts_elapsed > VOLKSWAGEN_RT_INTERVAL) { + rt_torque_last = desired_torque; + ts_last = ts; + } + } + + // no torque if controls is not allowed + if (!controls_allowed && (desired_torque != 0)) { + violation = true; + } + + // reset to 0 if either controls is not allowed or there's a violation + if (violation || !controls_allowed) { + desired_torque_last = 0; + rt_torque_last = 0; + ts_last = ts; + } + + return violation; +} + +static int volkswagen_mqb_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { + int addr = GET_ADDR(to_send); + int tx = 1; + + if (!msg_allowed(to_send, VOLKSWAGEN_MQB_TX_MSGS, VOLKSWAGEN_MQB_TX_MSGS_LEN) || relay_malfunction) { + tx = 0; + } + + // Safety check for HCA_01 Heading Control Assist torque + // Signal: HCA_01.Assist_Torque (absolute torque) + // Signal: HCA_01.Assist_VZ (direction) + if (addr == MSG_HCA_01) { + int desired_torque = GET_BYTE(to_send, 2) | ((GET_BYTE(to_send, 3) & 0x3F) << 8); + int sign = (GET_BYTE(to_send, 3) & 0x80) >> 7; + if (sign == 1) { + desired_torque *= -1; + } + + if (volkswagen_steering_check(desired_torque)) { + tx = 0; + } + } + + // FORCE CANCEL: ensuring that only the cancel button press is sent when controls are off. + // This avoids unintended engagements while still allowing resume spam + if ((addr == MSG_GRA_ACC_01) && !controls_allowed) { + // disallow resume and set: bits 16 and 19 + if ((GET_BYTE(to_send, 2) & 0x9) != 0) { + tx = 0; + } + } + + // 1 allows the message through + return tx; +} + +static int volkswagen_pq_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { + int addr = GET_ADDR(to_send); + int tx = 1; + + if (!msg_allowed(to_send, VOLKSWAGEN_PQ_TX_MSGS, VOLKSWAGEN_PQ_TX_MSGS_LEN) || relay_malfunction) { + tx = 0; + } + + // Safety check for HCA_1 Heading Control Assist torque + // Signal: HCA_1.LM_Offset (absolute torque) + // Signal: HCA_1.LM_Offsign (direction) + if (addr == MSG_HCA_1) { + int desired_torque = GET_BYTE(to_send, 2) | ((GET_BYTE(to_send, 3) & 0x7F) << 8); + desired_torque = desired_torque / 32; // DBC scale from PQ network to centi-Nm + int sign = (GET_BYTE(to_send, 3) & 0x80) >> 7; + if (sign == 1) { + desired_torque *= -1; + } + + if (volkswagen_steering_check(desired_torque)) { + tx = 0; + } + } + + // FORCE CANCEL: ensuring that only the cancel button press is sent when controls are off. + // This avoids unintended engagements while still allowing resume spam + if ((addr == MSG_GRA_NEU) && !controls_allowed) { + // disallow resume and set: bits 16 and 17 + if ((GET_BYTE(to_send, 2) & 0x3) != 0) { + tx = 0; + } + } + + // 1 allows the message through + return tx; +} + +static int volkswagen_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { + int addr = GET_ADDR(to_fwd); + int bus_fwd = -1; + + if (!relay_malfunction) { + switch (bus_num) { + case 0: + // Forward all traffic from the Extended CAN onward + bus_fwd = 2; + break; + case 2: + if ((addr == volkswagen_torque_msg) || (addr == volkswagen_lane_msg)) { + // OP takes control of the Heading Control Assist and Lane Departure Warning messages from the camera + bus_fwd = -1; + } else { + // Forward all remaining traffic from Extended CAN devices to J533 gateway + bus_fwd = 0; + } + break; + default: + // No other buses should be in use; fallback to do-not-forward + bus_fwd = -1; + break; + } + } + return bus_fwd; +} + +// Volkswagen MQB platform +const safety_hooks volkswagen_mqb_hooks = { + .init = volkswagen_mqb_init, + .rx = volkswagen_mqb_rx_hook, + .tx = volkswagen_mqb_tx_hook, + .tx_lin = nooutput_tx_lin_hook, + .fwd = volkswagen_fwd_hook, + .addr_check = volkswagen_mqb_rx_checks, + .addr_check_len = sizeof(volkswagen_mqb_rx_checks) / sizeof(volkswagen_mqb_rx_checks[0]), +}; + +// Volkswagen PQ35/PQ46/NMS platforms +const safety_hooks volkswagen_pq_hooks = { + .init = volkswagen_pq_init, + .rx = volkswagen_pq_rx_hook, + .tx = volkswagen_pq_tx_hook, + .tx_lin = nooutput_tx_lin_hook, + .fwd = volkswagen_fwd_hook, + .addr_check = volkswagen_pq_rx_checks, + .addr_check_len = sizeof(volkswagen_pq_rx_checks) / sizeof(volkswagen_pq_rx_checks[0]), +}; diff --git a/panda/board/safety_declarations.h b/panda/board/safety_declarations.h index 7e0a54d73e8231..3f8221c9727445 100644 --- a/panda/board/safety_declarations.h +++ b/panda/board/safety_declarations.h @@ -1,3 +1,6 @@ +const int MAX_WRONG_COUNTERS = 5; +const uint8_t MAX_MISSED_MSGS = 10U; + // sample struct that keeps 3 samples in memory struct sample_t { int values[6]; @@ -11,10 +14,38 @@ struct lookup_t { float y[3]; }; -void safety_rx_hook(CAN_FIFOMailBox_TypeDef *to_push); +typedef struct { + int addr; + int bus; + int len; +} CanMsg; + +typedef struct { + const int addr; + const int bus; + const int len; + const bool check_checksum; // true is checksum check is performed + const uint8_t max_counter; // maximum value of the counter. 0 means that the counter check is skipped + const uint32_t expected_timestep; // expected time between message updates [us] +} CanMsgCheck; + +// params and flags about checksum, counter and frequency checks for each monitored address +typedef struct { + // const params + const CanMsgCheck msg[3]; // check either messages (e.g. honda steer). Array MUST terminate with an empty struct to know its length. + // dynamic flags + bool msg_seen; + int index; // if multiple messages are allowed to be checked, this stores the index of the first one seen. only msg[msg_index] will be used + bool valid_checksum; // true if and only if checksum check is passed + int wrong_counters; // counter of wrong counters, saturated between 0 and MAX_WRONG_COUNTERS + uint8_t last_counter; // last counter value + uint32_t last_timestamp; // micro-s + bool lagging; // true if and only if the time between updates is excessive +} AddrCheckStruct; + +int safety_rx_hook(CAN_FIFOMailBox_TypeDef *to_push); int safety_tx_hook(CAN_FIFOMailBox_TypeDef *to_send); int safety_tx_lin_hook(int lin_num, uint8_t *data, int len); -int safety_ignition_hook(void); uint32_t get_ts_elapsed(uint32_t ts, uint32_t ts_last); int to_signed(int d, int bits); void update_sample(struct sample_t *sample, int sample_new); @@ -26,30 +57,84 @@ bool driver_limit_check(int val, int val_last, struct sample_t *val_driver, const int MAX_ALLOWANCE, const int DRIVER_FACTOR); bool rt_rate_limit_check(int val, int val_last, const int MAX_RT_DELTA); float interpolate(struct lookup_t xy, float x); +void gen_crc_lookup_table(uint8_t poly, uint8_t crc_lut[]); +bool msg_allowed(CAN_FIFOMailBox_TypeDef *to_send, const CanMsg msg_list[], int len); +int get_addr_check_index(CAN_FIFOMailBox_TypeDef *to_push, AddrCheckStruct addr_list[], const int len); +void update_counter(AddrCheckStruct addr_list[], int index, uint8_t counter); +void update_addr_timestamp(AddrCheckStruct addr_list[], int index); +bool is_msg_valid(AddrCheckStruct addr_list[], int index); +bool addr_safety_check(CAN_FIFOMailBox_TypeDef *to_push, + AddrCheckStruct *addr_check, + const int addr_check_len, + uint8_t (*get_checksum)(CAN_FIFOMailBox_TypeDef *to_push), + uint8_t (*compute_checksum)(CAN_FIFOMailBox_TypeDef *to_push), + uint8_t (*get_counter)(CAN_FIFOMailBox_TypeDef *to_push)); +void generic_rx_checks(bool stock_ecu_detected); +void relay_malfunction_set(void); +void relay_malfunction_reset(void); typedef void (*safety_hook_init)(int16_t param); -typedef void (*rx_hook)(CAN_FIFOMailBox_TypeDef *to_push); +typedef int (*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)(void); typedef int (*fwd_hook)(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd); typedef struct { safety_hook_init init; - ign_hook ignition; rx_hook rx; tx_hook tx; tx_lin_hook tx_lin; fwd_hook fwd; + AddrCheckStruct *addr_check; + const int addr_check_len; } safety_hooks; -// This can be set by the safety hooks. -bool controls_allowed = 0; -bool gas_interceptor_detected = 0; +void safety_tick(const safety_hooks *hooks); + +// This can be set by the safety hooks +bool controls_allowed = false; +bool relay_malfunction = false; +bool gas_interceptor_detected = false; int gas_interceptor_prev = 0; +bool gas_pressed = false; +bool gas_pressed_prev = false; +bool brake_pressed = false; +bool brake_pressed_prev = false; +bool cruise_engaged_prev = false; +float vehicle_speed = 0; +bool vehicle_moving = false; + +// for safety modes with torque steering control +int desired_torque_last = 0; // last desired steer torque +int rt_torque_last = 0; // last desired torque for real time check +struct sample_t torque_meas; // last 3 motor torques produced by the eps +struct sample_t torque_driver; // last 3 driver torques measured +uint32_t ts_last = 0; + +// for safety modes with angle steering control +uint32_t ts_angle_last = 0; +int desired_angle_last = 0; +struct sample_t angle_meas; // last 3 steer angles + +// This can be set with a USB command +// It enables features we consider to be unsafe, but understand others may have different opinions +// It is always 0 on mainline comma.ai openpilot + +// If using this flag, be very careful about what happens if your fork wants to brake while the +// user is pressing the gas. Tesla is careful with this. +#define UNSAFE_DISABLE_DISENGAGE_ON_GAS 1 + +// If using this flag, make sure to communicate to your users that a stock safety feature is now disabled. +#define UNSAFE_DISABLE_STOCK_AEB 2 + +// If using this flag, be aware that harder braking is more likely to lead to rear endings, +// and that alone this flag doesn't make braking compliant because there's also a time element. +// See ISO 15622:2018 for more information. +#define UNSAFE_RAISE_LONGITUDINAL_LIMITS_TO_ISO_MAX 8 -// This is set by USB command 0xdf -bool long_controls_allowed = 1; +int unsafe_mode = 0; -// avg between 2 tracks -#define GET_INTERCEPTOR(msg) (((GET_BYTE((msg), 0) << 8) + GET_BYTE((msg), 1) + ((GET_BYTE((msg), 2) << 8) + GET_BYTE((msg), 3)) / 2 ) / 2) +// time since safety mode has been changed +uint32_t safety_mode_cnt = 0U; +// allow 1s of transition timeout after relay changes state before assessing malfunctioning +const uint32_t RELAY_TRNS_TIMEOUT = 1U; diff --git a/panda/board/spi_flasher.h b/panda/board/spi_flasher.h index 4eab35671cae10..2636bf535a40d8 100644 --- a/panda/board/spi_flasher.h +++ b/panda/board/spi_flasher.h @@ -65,7 +65,14 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) // so it's blocked over wifi switch (setup->b.wValue.w) { case 0: + // TODO: put this back when it's no longer a "devkit" + //#ifdef ALLOW_DEBUG + #if 1 if (hardwired) { + #else + // no more bootstub on UNO once OTP block is flashed + if (hardwired && ((hw_type != HW_TYPE_UNO) || (!is_provisioned()))) { + #endif puts("-> entering bootloader\n"); enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC; NVIC_SystemReset(); @@ -103,6 +110,7 @@ void usb_cb_ep3_out(void *usbdata, int len, bool hardwired) { UNUSED(len); UNUSED(hardwired); } +void usb_cb_ep3_out_complete(void) {} int is_enumerated = 0; void usb_cb_enumeration_complete(void) { @@ -151,7 +159,7 @@ int spi_cb_rx(uint8_t *data, int len, uint8_t *data_out) { #define CAN_BL_INPUT 0x1 #define CAN_BL_OUTPUT 0x2 -void CAN1_TX_IRQHandler(void) { +void CAN1_TX_IRQ_Handler(void) { // clear interrupt CAN->TSR |= CAN_TSR_RQCP0; } @@ -178,12 +186,12 @@ void bl_can_send(uint8_t *odat) { CAN->sTxMailBox[0].TIR = (CAN_BL_OUTPUT << 21) | 1; } -void CAN1_RX0_IRQHandler(void) { +void CAN1_RX0_IRQ_Handler(void) { while (CAN->RF0R & CAN_RF0R_FMP0) { if ((CAN->sFIFOMailBox[0].RIR>>21) == CAN_BL_INPUT) { uint8_t dat[8]; for (int i = 0; i < 8; i++) { - dat[0] = GET_BYTE(&CAN->sFIFOMailBox[0], i); + dat[i] = GET_BYTE(&CAN->sFIFOMailBox[0], i); } uint8_t odat[8]; uint8_t type = dat[0] & 0xF0; @@ -253,13 +261,19 @@ void CAN1_RX0_IRQHandler(void) { } } -void CAN1_SCE_IRQHandler(void) { +void CAN1_SCE_IRQ_Handler(void) { llcan_clear_send(CAN); } #endif void soft_flasher_start(void) { + #ifdef PEDAL + REGISTER_INTERRUPT(CAN1_TX_IRQn, CAN1_TX_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) + REGISTER_INTERRUPT(CAN1_RX0_IRQn, CAN1_RX0_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) + REGISTER_INTERRUPT(CAN1_SCE_IRQn, CAN1_SCE_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) + #endif + puts("\n\n\n************************ FLASHER START ************************\n"); enter_bootloader_mode = 0; @@ -276,7 +290,7 @@ void soft_flasher_start(void) { // B8,B9: CAN 1 set_gpio_alternate(GPIOB, 8, GPIO_AF9_CAN1); set_gpio_alternate(GPIOB, 9, GPIO_AF9_CAN1); - current_board->enable_can_transciever(1, true); + current_board->enable_can_transceiver(1, true); // init can llcan_set_speed(CAN1, 5000, false, false); @@ -307,7 +321,7 @@ void soft_flasher_start(void) { // green LED on for flashing current_board->set_led(LED_GREEN, 1); - __enable_irq(); + enable_interrupts(); uint64_t cnt = 0; diff --git a/panda/board/tools/enter_download_mode.py b/panda/board/tools/enter_download_mode.py index ff3cf84ca97aa3..4e6a2b4cc71d6f 100755 --- a/panda/board/tools/enter_download_mode.py +++ b/panda/board/tools/enter_download_mode.py @@ -1,5 +1,5 @@ -#!/usr/bin/env python -from __future__ import print_function +#!/usr/bin/env python3 + import sys import time @@ -11,7 +11,7 @@ def enter_download_mode(device): try: handle.controlWrite(usb1.TYPE_VENDOR | usb1.RECIPIENT_DEVICE, 0xd1, 0, 0, b'') - except (usb1.USBErrorIO, usb1.USBErrorPipe) as e: + except (usb1.USBErrorIO, usb1.USBErrorPipe): print("Device download mode enabled.") time.sleep(1) else: @@ -21,12 +21,12 @@ def enter_download_mode(device): def find_first_panda(context=None): context = context or usb1.USBContext() for device in context.getDeviceList(skip_on_error=True): - if device.getVendorID() == 0xbbaa and device.getProductID()&0xFF00 == 0xdd00: + if device.getVendorID() == 0xbbaa and device.getProductID() & 0xFF00 == 0xdd00: return device if __name__ == "__main__": panda_dev = find_first_panda() - if panda_dev == None: + if panda_dev is None: print("no device found") sys.exit(0) print("found device") diff --git a/panda/boardesp/.gitignore b/panda/boardesp/.gitignore deleted file mode 100644 index 75255a58518e15..00000000000000 --- a/panda/boardesp/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -proxy -*.bin -esp-open-sdk -a.out -cert.h -gitversion.h -esp-open-sdk.dmg -obj/* diff --git a/panda/boardesp/ELM327.md b/panda/boardesp/ELM327.md deleted file mode 100644 index 6453b35ca41119..00000000000000 --- a/panda/boardesp/ELM327.md +++ /dev/null @@ -1,101 +0,0 @@ -ELM327 support for panda -====== -The panda now has basic ELM327 support. - -### What is ELM327? - -ELM327 is a command protocol for interfacing with cars using an OBD-II -port to read [list](standard vehicle diagnostic codes). ELM327 -originally referred to a line of programmable microcontrollers that -implemented the ELM327 command protocol, and are still being -developed. - -ELM327 devices present a shell and commands are sent via a UART. The -official ELM327 chips only support raw UART communication, but most -devices built with the ELM327 devices (official or clones) expose the -UART in a more modern way (Wifi, USB, etc). - -Mechanics use ELM to diagnose vehicles, and reset fault codes in the -car's computer after fixing the issue (turning off the dreaded check -engine light). Car owners can use ELM devices to perform the same -diagnostics in their garage using either a raw terminal to send -commands to the ELM device directly, or using a GUI (like one of -several popular smart phone apps) to translate the OBD error codes -into readable messages. These GUIs also often allow monitoring of the -performance of the car's speed, engine rpm, etc. - -The panda natively supports sending all the important OBD diagnostic -messages, but ELM327 support removes the need for the user to manually -craft CAN or LIN packets using the native panda API, and grants -compatibility with many existing tools. - -[Wikipedia](https://en.wikipedia.org/wiki/ELM327) can provide -additional information. - -### OBD Protocols? - -While the commands that the OBD standard describe are in fact -standard, there are several different protocols that those messages -can be sent and received with. All cars after 1991 support one of -these protocols. Which one depends on the car's year and country, as -legal requirements change over the years. - -The panda supports the most popular/modern of these protocols, and all -but two can be added as needed. Below is a chart of the OBD-II -protocols supported by the panda. - -| Protocol | Support Status | -| --- | --- | -| SAE J1850 PWM (41.6 kbit/s) | Never/Obsolete | -| SAE J1850 VPW (10.4 kbit/s) | Never/Obsolete | -| ISO 9141-2 (5 baud init, 10.4 kbit/s) | Unsupported | -| ISO 14230-4 KWP (5 baud init, 10.4 kbit/s) | Unsupported | -| ISO 14230-4 KWP (fast init, 10.4 kbit/s) | Supported | -| ISO 15765-4 CAN (11 bit ID, 500 kbit/s) | Supported | -| ISO 15765-4 CAN (29 bit ID, 500 kbit/s) | Supported | -| ISO 15765-4 CAN (11 bit ID, 250 kbit/s) | Supported | -| ISO 15765-4 CAN (29 bit ID, 250 kbit/s) | Supported | -| SAE J1939 (250kbps) | Unsupported | - -### The Implementation - -The panda ELM327 implementation is not a full implementation of all -the features of the official ELM327 microcontroller. Like most ELM327 -clones, the panda reports its ELM version as the unreleased version -1.5, despite only implementing commands from protocol version 1.0. - - -### Testing - -These tests require two pandas. One to be tested, and the second to -simulate the vehicle. - -The panda used to simulate the vehicle must be plugged into a USB port -of the testing computer. - -The computer running the tests must be connected to the panda being -tested's wifi network. - -The following command will run the tests (nosetest should work fine -instead of pytest if you still prefer using that). The CANSIMSERIAL -environment variable will force the car simulator to use the correct -panda as the simulator if multiple pandas are attached via usb to the -host computer. - -``` -CANSIMSERIAL=car_sim_panda_serial pytest tests/automated/elm_wifi.py -``` - -A single test can be run by putting the test name after the file name -and two colons, like so: - -``` -CANSIMSERIAL=car_sim_panda_serial pytest tests/automated/elm_wifi.py::test_important_thing -``` - -For more detail, provide the -s (show output) and the -vv (very -verbose) flags. - -``` -CANSIMSERIAL=car_sim_panda_serial pytest -s -vv tests/automated/elm_wifi.py -``` diff --git a/panda/boardesp/Makefile b/panda/boardesp/Makefile deleted file mode 100644 index 0b8fe32b693ff5..00000000000000 --- a/panda/boardesp/Makefile +++ /dev/null @@ -1,74 +0,0 @@ -PATH := esp-open-sdk/xtensa-lx106-elf/bin:$(PATH) -CC = esp-open-sdk/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc -CFLAGS = -Iinclude/ -I. -I../ -mlongcalls -Iesp-open-sdk/ESP8266_NONOS_SDK_V1.5.4_16_05_20/driver_lib/include -std=c99 -DICACHE_FLASH -LDLIBS = -nostdlib -Wl,--start-group -lmain -lnet80211 -lwpa -llwip -lpp -lphy -Wl,--end-group -lgcc -ldriver -Wl,--gc-sections -LDFLAGS = -Teagle.app.v6.ld -OBJCP = esp-open-sdk/xtensa-lx106-elf/bin/xtensa-lx106-elf-objcopy -SDK_BASE = esp-open-sdk/ESP8266_NONOS_SDK_V1.5.4_16_05_20 - -ifeq ($(RELEASE),1) - CERT = ../../pandaextra/certs/releaseesp -else - CERT = ../certs/debugesp - CFLAGS += "-DALLOW_DEBUG" -endif - -flashall: user1.bin user2.bin - ../python/esptool.py write_flash 0 $(SDK_BASE)/bin/boot_v1.5.bin 0x01000 user1.bin 0x81000 user2.bin 0x3FE000 $(SDK_BASE)/bin/blank.bin - -proxy-0x00000.bin: proxy - ../python/esptool.py elf2image $^ - -proxy: proxy.o elm327.o webserver.o sha.o - -obj/proxy.o: proxy.c - $(CC) $(CFLAGS) -c $^ -o $@ - -obj/elm327.o: elm327.c - $(CC) $(CFLAGS) -c $^ -o $@ - -obj/webserver.o: webserver.c obj/cert.h obj/gitversion.h - $(CC) $(CFLAGS) -c $< -o $@ - -obj/cert.h: ../crypto/getcertheader.py - ../crypto/getcertheader.py ../certs/debugesp.pub ../certs/releaseesp.pub > obj/cert.h - -include ../common/version.mk - -obj/sha.o: ../crypto/sha.c - $(CC) $(CFLAGS) -c $^ -o $@ - -obj/rsa.o: ../crypto/rsa.c - $(CC) $(CFLAGS) -c $^ -o $@ - -oldflash: proxy-0x00000.bin - ../python/esptool.py write_flash 0 proxy-0x00000.bin 0x40000 proxy-0x40000.bin - -user1.bin: obj/proxy.o obj/elm327.o obj/webserver.o obj/sha.o obj/rsa.o - $(CC) $(CFLAGS) $^ -o a.out -L$(SDK_BASE)/ld -T$(SDK_BASE)/ld/eagle.app.v6.new.1024.app1.ld $(LDLIBS) - $(OBJCP) --only-section .text -O binary a.out eagle.app.v6.text.bin - $(OBJCP) --only-section .data -O binary a.out eagle.app.v6.data.bin - $(OBJCP) --only-section .rodata -O binary a.out eagle.app.v6.rodata.bin - $(OBJCP) --only-section .irom0.text -O binary a.out eagle.app.v6.irom0text.bin - COMPILE=gcc python ./esp-open-sdk/ESP8266_NONOS_SDK_V1.5.4_16_05_20/tools/gen_appbin.py a.out 2 0 32 4 0 - rm -f eagle.app.v6.*.bin - mv eagle.app.flash.bin $@ - ../crypto/sign.py $@ $@ $(CERT) - -user2.bin: obj/proxy.o obj/elm327.o obj/webserver.o obj/sha.o obj/rsa.o - $(CC) $(CFLAGS) $^ -o a.out -L$(SDK_BASE)/ld -T$(SDK_BASE)/ld/eagle.app.v6.new.1024.app2.ld $(LDLIBS) - $(OBJCP) --only-section .text -O binary a.out eagle.app.v6.text.bin - $(OBJCP) --only-section .data -O binary a.out eagle.app.v6.data.bin - $(OBJCP) --only-section .rodata -O binary a.out eagle.app.v6.rodata.bin - $(OBJCP) --only-section .irom0.text -O binary a.out eagle.app.v6.irom0text.bin - COMPILE=gcc python ./esp-open-sdk/ESP8266_NONOS_SDK_V1.5.4_16_05_20/tools/gen_appbin.py a.out 2 0 32 4 0 - rm -f eagle.app.v6.*.bin - mv eagle.app.flash.bin $@ - ../crypto/sign.py $@ $@ $(CERT) - -ota: user1.bin user2.bin - curl http://192.168.0.10/espupdate1 --upload-file user1.bin - curl http://192.168.0.10/espupdate2 --upload-file user2.bin - -clean: - rm -f proxy proxy.o proxy-0x00000.bin proxy-0x40000.bin eagle.app.* user1.bin user2.bin a.out obj/* diff --git a/panda/boardesp/README.md b/panda/boardesp/README.md deleted file mode 100644 index 5a8fab14777fee..00000000000000 --- a/panda/boardesp/README.md +++ /dev/null @@ -1,22 +0,0 @@ - -Dependencies ------ - -**Debian / Ubuntu** - -``` -./get_sdk.sh -``` - -**Mac** - -``` -./get_sdk_mac.sh -``` - -Programming ------ - -``` -make -``` diff --git a/panda/boardesp/elm327.c b/panda/boardesp/elm327.c deleted file mode 100644 index 58ac4c86386aa1..00000000000000 --- a/panda/boardesp/elm327.c +++ /dev/null @@ -1,1576 +0,0 @@ -#include "ets_sys.h" -#include "osapi.h" -#include "gpio.h" -#include "os_type.h" -#include "user_interface.h" -#include "espconn.h" -#include "mem.h" - -#include "driver/uart.h" - -//#define ELM_DEBUG - -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -int ICACHE_FLASH_ATTR spi_comm(char *dat, int len, uint32_t *recvData, int recvDataLen); - -#define ELM_PORT 35000 - -//Version 1.5 is an invalid version used by many pirate clones -//that only partially support 1.0. -#define IDENT_MSG "ELM327 v1.5\r\r" -#define DEVICE_DESC "Panda\n\n" - -#define SHOW_CONNECTION(msg, p_conn) os_printf("%s %p, proto %p, %d.%d.%d.%d:%d disconnect\r\n", \ - msg, p_conn, (p_conn)->proto.tcp, (p_conn)->proto.tcp->remote_ip[0], \ - (p_conn)->proto.tcp->remote_ip[1], (p_conn)->proto.tcp->remote_ip[2], \ - (p_conn)->proto.tcp->remote_ip[3], (p_conn)->proto.tcp->remote_port) - -const static char hex_lookup[] = {'0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; - -typedef struct __attribute__((packed)) { - bool tx : 1; - bool : 1; - bool ext : 1; - uint32_t addr : 29; - - uint8_t len : 4; - uint8_t bus : 8; - uint8_t : 4; //unused - uint16_t ts : 16; - uint8_t data[8]; -} panda_can_msg_t; - -//TODO: Masking is likely unnecessary for these bit fields. Check. -#define panda_get_can_addr(recv) (((recv)->ext) ? ((recv)->addr & 0x1FFFFFFF) :\ - (((recv)->addr >> 18) & 0x7FF)) - -#define PANDA_CAN_FLAG_TRANSMIT 1 -#define PANDA_CAN_FLAG_EXTENDED 4 - -#define PANDA_USB_CAN_WRITE_BUS_NUM 3 -#define PANDA_USB_LIN_WRITE_BUS_NUM 2 - -typedef struct _elm_tcp_conn { - struct espconn *conn; - struct _elm_tcp_conn *next; -} elm_tcp_conn_t; - -typedef struct __attribute__((packed)) { - uint8_t len; - uint8_t dat[7]; //mode and data -} elm_can_obd_msg; - -typedef struct __attribute__((packed)) { - uint8_t priority; - uint8_t receiver; - uint8_t sender; - - uint8_t dat[8]; //mode, data, and checksum -} elm_lin_obd_msg; - -typedef struct __attribute__((packed)) { - uint16_t usb_ep_num; - uint16_t payload_len; - - uint8_t serial_port; - //uint8_t msg[8+3]; - elm_lin_obd_msg msg; -} elm_lin_usb_msg; - -static struct espconn elm_conn; -static esp_tcp elm_proto; -static elm_tcp_conn_t *connection_list = NULL; - -static char stripped_msg[0x100]; -static uint16 stripped_msg_len = 0; - -static char in_msg[0x100]; -static uint16 in_msg_len = 0; - -static char rsp_buff[536]; //TCP min MTU -static uint16 rsp_buff_len = 0; - -static uint8_t pandaSendData[0x14] = {0}; -static uint32_t pandaRecvData[0x40] = {0}; -static uint32_t pandaRecvDataDummy[0x40] = {0}; // Used for CAN write operations (no received data) - -#define ELM_MODE_SELECTED_PROTOCOL_DEFAULT 6 -#define ELM_MODE_TIMEOUT_DEFAULT 20; -#define ELM_MODE_KEEPALIVE_PERIOD_DEFAULT (0x92*20) - -static bool elm_mode_echo = true; -static bool elm_mode_linefeed = false; -static bool elm_mode_additional_headers = false; -static bool elm_mode_auto_protocol = true; -static uint8_t elm_selected_protocol = ELM_MODE_SELECTED_PROTOCOL_DEFAULT; -static bool elm_mode_print_spaces = true; -static uint8_t elm_mode_adaptive_timing = 1; -static bool elm_mode_allow_long = false; -static uint16_t elm_mode_timeout = ELM_MODE_TIMEOUT_DEFAULT; -static uint16_t elm_mode_keepalive_period = ELM_MODE_KEEPALIVE_PERIOD_DEFAULT; - -bool lin_bus_initialized = false; - -/*********************************************** - *** ELM CLI response functions *** - *** (for sending data back to the terminal) *** - ***********************************************/ - -// All ELM operations are global, so send data out to all connections -void ICACHE_FLASH_ATTR elm_tcp_tx_flush() { - if(!rsp_buff_len) return; // Was causing small error messages - - for(elm_tcp_conn_t *iter = connection_list; iter != NULL; iter = iter->next){ - int8_t err = espconn_send(iter->conn, rsp_buff, rsp_buff_len); - if(err){ - os_printf(" Wifi %p TX error code %d\n", iter->conn, err); - if(err == ESPCONN_ARG) { - if(iter == connection_list) { - connection_list = iter->next; - } else { - for(elm_tcp_conn_t *iter2 = connection_list; iter2 != NULL; iter2 = iter2->next) - if(iter2->next == iter) { - iter2->next = iter->next; - break; - } - } - os_printf(" deleting orphaned connection. iter: %p; conn: %p\n", iter, iter->conn); - os_free(iter); - } - } - } - rsp_buff_len = 0; -} - -static void ICACHE_FLASH_ATTR elm_append_rsp(const char *data, uint16_t len) { - uint16_t overflow_len = 0; - if(rsp_buff_len + len > sizeof(rsp_buff)) { - overflow_len = rsp_buff_len + len - sizeof(rsp_buff); - len = sizeof(rsp_buff) - rsp_buff_len; - } - if(!elm_mode_linefeed) { - memcpy(rsp_buff + rsp_buff_len, data, len); - rsp_buff_len += len; - } else { - for(int i=0; i < len && rsp_buff_len < sizeof(rsp_buff); i++){ - rsp_buff[rsp_buff_len++] = data[i]; - if(data[i] == '\r' && rsp_buff_len < sizeof(rsp_buff)) - rsp_buff[rsp_buff_len++] = '\n'; - } - } - if(overflow_len) { - os_printf("Packet full, sending\n"); - elm_tcp_tx_flush(); - elm_append_rsp(data + len, overflow_len); - } -} - -#define elm_append_rsp_const(str) elm_append_rsp(str, sizeof(str)-1) - -static void ICACHE_FLASH_ATTR elm_append_rsp_hex_byte(uint8_t num) { - elm_append_rsp(&hex_lookup[num >> 4], 1); - elm_append_rsp(&hex_lookup[num & 0xF], 1); - if(elm_mode_print_spaces) elm_append_rsp_const(" "); -} - -void ICACHE_FLASH_ATTR elm_append_rsp_can_msg_addr(const panda_can_msg_t *recv) { - //Show address - uint32_t addr = panda_get_can_addr(recv); - if(recv->ext){ - elm_append_rsp_hex_byte(addr>>24); - elm_append_rsp_hex_byte(addr>>16); - elm_append_rsp_hex_byte(addr>>8); - elm_append_rsp_hex_byte(addr); - } else { - elm_append_rsp(&hex_lookup[addr>>8], 1); - elm_append_rsp_hex_byte(addr); - } -} - -/*************************************** - *** Panda communication functions *** - *** (for controlling the Panda MCU) *** - ***************************************/ - -static int ICACHE_FLASH_ATTR panda_usbemu_ctrl_write(uint8_t request_type, uint8_t request, - uint16_t value, uint16_t index, uint16_t length) { - //self.sock.send(struct.pack("HHBBHHH", 0, 0, request_type, request, value, index, length)); - *(uint16_t*)(pandaSendData) = 0; - *(uint16_t*)(pandaSendData+2) = 0; - pandaSendData[4] = request_type; - pandaSendData[5] = request; - *(uint16_t*)(pandaSendData+6) = value; - *(uint16_t*)(pandaSendData+8) = index; - *(uint16_t*)(pandaSendData+10) = length; - - int returned_count = spi_comm(pandaSendData, 0x10, pandaRecvData, 0x40); - if(returned_count > 0x40 || returned_count < 0) - return -1; - return returned_count; -} - -#define panda_set_can0_cbaud(cbps) panda_usbemu_ctrl_write(0x40, 0xde, 0, cbps, 0) -#define panda_set_can0_kbaud(kbps) panda_usbemu_ctrl_write(0x40, 0xde, 0, kbps*10, 0) -#define panda_set_safety_mode(mode) panda_usbemu_ctrl_write(0x40, 0xdc, mode, 0, 0) -#define panda_kline_wakeup_pulse() panda_usbemu_ctrl_write(0x40, 0xf0, 0, 0, 0) -#define panda_clear_can_rx() panda_usbemu_ctrl_write(0x40, 0xf1, 0xFFFF, 0, 0) -#define panda_clear_lin_txrx() panda_usbemu_ctrl_write(0x40, 0xf2, 2, 0, 0) - -static int ICACHE_FLASH_ATTR panda_usbemu_can_read(panda_can_msg_t** can_msgs) { - int returned_count = spi_comm((uint8_t *)((const uint16 []){1,0}), 4, pandaRecvData, 0x40); - if(returned_count > 0x40 || returned_count < 0){ - os_printf("CAN read got invalid length\n"); - return -1; - } - *can_msgs = (panda_can_msg_t*)(pandaRecvData+1); - return returned_count/sizeof(panda_can_msg_t); -} - -static int ICACHE_FLASH_ATTR panda_usbemu_can_write(bool ext, uint32_t addr, - char *candata, uint8_t canlen) { - uint32_t rir; - - if(canlen > 8) return 0; - - if(ext || addr >= 0x800){ - rir = (addr << 3) | PANDA_CAN_FLAG_TRANSMIT | PANDA_CAN_FLAG_EXTENDED; - }else{ - rir = (addr << 21) | PANDA_CAN_FLAG_TRANSMIT; - } - - #define MAX_CAN_LEN 8 - - //Wifi USB Wrapper - *(uint16_t*)(pandaSendData) = PANDA_USB_CAN_WRITE_BUS_NUM; //USB Bulk Endpoint ID. - *(uint16_t*)(pandaSendData+2) = MAX_CAN_LEN; - //BULK MESSAGE - *(uint32_t*)(pandaSendData+4) = rir; - *(uint32_t*)(pandaSendData+8) = MAX_CAN_LEN | (0 << 4); //0 is CAN bus number. - //CAN DATA - memcpy(pandaSendData+12, candata, canlen); - memset(pandaSendData+12+canlen, 0, MAX_CAN_LEN-canlen); - for(int i = 12+canlen; i < 20; i++) pandaSendData[i] = 0; //Zero the rest - - /* spi_comm will erase data in the recv buffer even if you are only - * interested in sending data that gets no response (like writing - * can data). This behavior becomes problematic when trying to send - * a can message while processsing received can messages. A dummy - * recv buffer is used here so received data is not overwritten. */ - int returned_count = spi_comm(pandaSendData, 0x14, pandaRecvDataDummy, 0x40); - if(returned_count) - os_printf("ELM Can send expected 0 bytes back from panda. Got %d bytes instead\n", returned_count); - if(returned_count > 0x40) return 0; - return returned_count; -} - -elm_lin_obd_msg lin_last_sent_msg; -uint16_t lin_last_sent_msg_len = 0; -bool lin_await_msg_echo = false; - -static int ICACHE_FLASH_ATTR panda_usbemu_kline_read(uint16_t len) { - int returned_count = panda_usbemu_ctrl_write(0xC0, 0xE0, 2, 0, len); - if(returned_count > len || returned_count < 0){ - os_printf("LIN read got invalid length\n"); - return -1; - } - - #ifdef ELM_DEBUG - if(returned_count) { - os_printf("LIN Received %d bytes\n", returned_count); - os_printf(" Data: "); - for(int i = 0; i < returned_count; i++) - os_printf("%02x ", ((char*)(pandaRecvData+1))[i]); - os_printf("\n"); - } - #endif - return returned_count; -} - -static int ICACHE_FLASH_ATTR panda_usbemu_kline_write(elm_lin_obd_msg *msg) { - elm_lin_usb_msg usb_msg = {}; - - usb_msg.usb_ep_num = PANDA_USB_LIN_WRITE_BUS_NUM; //USB Bulk Endpoint ID. - usb_msg.payload_len = (msg->priority & 0x07) + 4 + 1; //The +1 is for serial_port - usb_msg.serial_port = 2; - memcpy(&usb_msg.msg, msg, sizeof(elm_lin_obd_msg)); - - /* spi_comm will erase data in the recv buffer even if you are only - * interested in sending data that gets no response (like writing - * can data). This behavior becomes problematic when trying to send - * a can message while processsing received can messages. A dummy - * recv buffer is used here so received data is not overwritten. */ - int returned_count = spi_comm((char*)&usb_msg, sizeof(elm_lin_usb_msg), pandaRecvDataDummy, 0x40); - - if(returned_count) - os_printf("ELM LIN send expected 0 bytes back from panda. Got %d bytes instead\n", returned_count); - if(returned_count > 0x40) return 0; - - return returned_count; -} - -/**************************************** - *** Ringbuffer *** - ****************************************/ - -//LIN data is delivered in chunks of arbitrary size. Using a -//ringbuffer to handle it. -uint8_t lin_ringbuff[0x20]; -uint8_t lin_ringbuff_start = 0; -uint8_t lin_ringbuff_end = 0; -#define lin_ringbuff_len \ - (((sizeof(lin_ringbuff) + lin_ringbuff_end) - lin_ringbuff_start)% sizeof(lin_ringbuff)) -#define lin_ringbuff_get(index) (lin_ringbuff[(lin_ringbuff_start + index) % sizeof(lin_ringbuff)]) -#define lin_ringbuff_consume(len) lin_ringbuff_start = ((lin_ringbuff_start + len) % sizeof(lin_ringbuff)) -#define lin_ringbuff_clear()\ - {lin_ringbuff_start = 0; \ - lin_ringbuff_end = 0;} - -int ICACHE_FLASH_ATTR elm_LIN_ringbuff_memcmp(uint8_t *data, uint16_t len) { - if(len > lin_ringbuff_len) return 1; - for(int i = 0; i < len; i++) - if(lin_ringbuff_get(i) != data[i]) return 1; - return 0; // Going with memcpy ret format where 0 means 'equal' -} - -uint16_t ICACHE_FLASH_ATTR elm_LIN_read_into_ringbuff() { - int bytelen = panda_usbemu_kline_read((sizeof(lin_ringbuff) - lin_ringbuff_len) - 1); - if(bytelen < 0) return 0; - for(int j = 0; j < bytelen; j++) { - lin_ringbuff[lin_ringbuff_end % sizeof(lin_ringbuff)] = ((char*)(pandaRecvData+1))[j]; - lin_ringbuff_end = (lin_ringbuff_end + 1) % sizeof(lin_ringbuff); - if(lin_ringbuff_start == lin_ringbuff_end) lin_ringbuff_start++; - } - - #ifdef ELM_DEBUG - if(bytelen){ - os_printf(" RB Data (%d %d %d): ", lin_ringbuff_start, lin_ringbuff_end, lin_ringbuff_len); - for(int i = 0; i < sizeof(lin_ringbuff); i++) - os_printf("%02x ", lin_ringbuff[i]); - os_printf("\n"); - } - #endif - - return bytelen; -} - -/**************************************** - *** String parsing utility functions *** - ****************************************/ - -static int8_t ICACHE_FLASH_ATTR elm_decode_hex_char(char b){ - if(b >= '0' && b <= '9') return b - '0'; - if(b >= 'A' && b <= 'F') return (b - 'A') + 10; - if(b >= 'a' && b <= 'f') return (b - 'a') + 10; - return -1; -} - -static uint8_t ICACHE_FLASH_ATTR elm_decode_hex_byte(const char* data) { - return (elm_decode_hex_char(data[0]) << 4) | elm_decode_hex_char(data[1]); -} - -static bool ICACHE_FLASH_ATTR elm_check_valid_hex_chars(const char* data, uint8_t len) { - for(int i = 0; i < len; i++){ - char b = data[i]; - if(!((b >= '0' && b <= '9') || (b >= 'A' && b <= 'F') || (b >= 'a' && b <= 'f'))) - return 0; - } - return 1; -} - -static uint16_t ICACHE_FLASH_ATTR elm_strip(const char *data, uint16_t lenin, - char *outbuff, uint16_t outbufflen) { - uint16_t count = 0; - for(uint16_t i = 0; i < lenin; i++) { - if(count >= outbufflen) break; - if(data[i] == ' ') continue; - if(data[i] >= 'a' && data[i] <= 'z'){ - outbuff[count++] = data[i] - ('a' - 'A'); - } else { - outbuff[count++] = data[i]; - } - if(data[i] == '\r') break; - } - return count; -} - -static int ICACHE_FLASH_ATTR elm_msg_find_cr_or_eos(char *data, uint16_t len){ - uint16_t i; - for(i = 0; i < len; i++) - if(data[i] == '\r') { - i++; - break; - } - return i; -} - -/***************************************************** - *** ELM protocol specification and implementation *** - *****************************************************/ - -typedef enum { - AUTO, LIN, CAN11, CAN29, NA -} elm_proto_type_t; - -typedef struct elm_protocol { - bool supported; - elm_proto_type_t type; - uint16_t cbaud; //Centibaud (cbaud * 10 = kbaud) - void (*process_obd)(const struct elm_protocol*, const char*, uint16_t); - //init is used to init and de-init a protocol. Init functions should - //not do things that would leave a new protocol in an invalid state - //after the new protocol's init is called (e.g. No arming timers). - void (*init)(const struct elm_protocol*); - char* name; -} elm_protocol_t; - -static const elm_protocol_t* ICACHE_FLASH_ATTR elm_current_proto(); -void ICACHE_FLASH_ATTR elm_reset_aux_timer(); -static void ICACHE_FLASH_ATTR elm_autodetect_cb(bool); - -static const elm_protocol_t elm_protocols[]; -//(sizeof(elm_protocols)/sizeof(elm_protocol_t)) -#define ELM_PROTOCOL_COUNT 13 - -#define LOOPCOUNT_FULL 4 -static int loopcount = 0; -static volatile os_timer_t elm_timeout; -static volatile os_timer_t elm_proto_aux_timeout; - -static bool is_auto_detecting = false; - -// Used only by elm_timer_cb, so not volatile -static bool did_multimessage = false; -static bool got_msg_this_run = false; -static bool can_tx_worked = false; -static uint8_t elm_msg_mode_ret_filter; -static uint8_t elm_msg_pid_ret_filter; - -/***************************************************** - *** ELM protocol specification and implementation *** - *** -> SAE J1850 implementation (Unsupported) *** - *****************************************************/ - -static void ICACHE_FLASH_ATTR elm_process_obd_cmd_J1850(const elm_protocol_t* proto, - const char *cmd, uint16_t len) { - elm_append_rsp_const("NO DATA\r\r>"); -} - -/***************************************************** - *** ELM protocol specification and implementation *** - *** -> ISO 14230-4 implementation *** - *****************************************************/ - -const char *lin_cmd_backup = NULL; //Holds msg while bus init is done -uint16_t lin_cmd_backup_len = 0; -bool lin_waiting_keepalive_echo = false; - -static void ICACHE_FLASH_ATTR elm_process_obd_cmd_LIN5baud(const elm_protocol_t* proto, - const char *cmd, uint16_t len) { - elm_append_rsp_const("BUS INIT: ...ERROR\r\r>"); -} - -bool ICACHE_FLASH_ATTR elm_lin_keepalive_echo() { - if(lin_waiting_keepalive_echo) { - for(int pass = 0; pass < 4 && lin_ringbuff_len < 5; pass++) { - elm_LIN_read_into_ringbuff(); - } - - lin_waiting_keepalive_echo = false; - //keepalive Echo should always come before other message echo. - if(lin_ringbuff_len >= 5 && !elm_LIN_ringbuff_memcmp("\xc1\x33\xf1\x3e\x23", 5)){ - lin_ringbuff_consume(5); - return true; - } else { - os_printf("Keep alive echo failed\n"); - return false; - } - } - return true; -} - -void ICACHE_FLASH_ATTR elm_LINFast_keepalive_timer_cb(void *arg) { - if(!lin_bus_initialized) { - os_printf("WARNING! Elm LIN keepalive timer running while bus is not initialized\n"); - return; - } - if(loopcount) { - os_printf("WARNING! Elm LIN keepalive timer during a tx/rx loop!\n"); - return; - } - if(lin_ringbuff_len) { - os_printf("WARNING! lin_ringbuff_len should be 0 when a keepalive echo is processed.\n"); - return; - } - - if(!elm_lin_keepalive_echo()) { - lin_bus_initialized = false; - return; - } - - elm_lin_obd_msg msg = {}; - - msg.priority = 0xC0 | 1; - msg.receiver = 0x33; - msg.sender = 0xF1; - msg.dat[0] = 0x3E; - msg.dat[1] = msg.dat[0] + msg.priority + msg.receiver + msg.sender; // checksum - - #ifdef ELM_DEBUG - os_printf("Sending LIN KEEPALIVE: Priority: %02x; RecvAddr: %02x; SendAddr: %02x; (%02x); ", - msg.priority, msg.receiver, msg.sender, 1); - for(int i = 0; i < 2; i++) os_printf("%02x ", msg.dat[i]); - os_printf("\n"); - #endif - - lin_waiting_keepalive_echo = true; - - panda_usbemu_kline_write(&msg); - elm_reset_aux_timer(); -} - -static void ICACHE_FLASH_ATTR elm_init_LINFast(const elm_protocol_t* proto){ - os_timer_disarm(&elm_proto_aux_timeout); - os_timer_setfn(&elm_proto_aux_timeout, (os_timer_func_t *)elm_LINFast_keepalive_timer_cb, proto); - - lin_bus_initialized = false; - lin_await_msg_echo = false; - lin_waiting_keepalive_echo = false; - - lin_cmd_backup = NULL; - lin_cmd_backup_len = 0; - - lin_ringbuff_clear(); - panda_clear_lin_txrx(); -} - -int ICACHE_FLASH_ATTR elm_LINFast_process_echo() { - if(!elm_lin_keepalive_echo()) { - os_printf("Keepalive echo not detected.\n"); - lin_ringbuff_clear(); - return -1; - } - - if(!lin_await_msg_echo) { - os_printf("Echo abort. Nothing waiting echo\n"); - return 1; - } - - for(int i = 0; i < 4; i++){ - if(lin_ringbuff_len < lin_last_sent_msg_len) elm_LIN_read_into_ringbuff(); - - if(lin_ringbuff_len >= lin_last_sent_msg_len){ - #ifdef ELM_DEBUG - os_printf("Got enough data %d\n", lin_last_sent_msg_len); - #endif - if(!elm_LIN_ringbuff_memcmp((uint8_t*)&lin_last_sent_msg, lin_last_sent_msg_len)) { - #ifdef ELM_DEBUG - os_printf("LIN data was sent successfully.\n"); - #endif - lin_ringbuff_consume(lin_last_sent_msg_len); - lin_await_msg_echo = false; - return 1; - } else { - #ifdef ELM_DEBUG - os_printf("Echo not correct.\n"); - os_printf(" RB Data (%d %d %d): ", lin_ringbuff_start, lin_ringbuff_end, lin_ringbuff_len); - for(int i = 0; i < sizeof(lin_ringbuff); i++) - os_printf("%02x ", lin_ringbuff[i]); - os_printf("\n"); - os_printf(" MSG Data (%d): ", lin_last_sent_msg_len); - for(int i = 0; i < lin_last_sent_msg_len; i++) - os_printf("%02x ", ((uint8_t*)&lin_last_sent_msg)[i]); - os_printf("\n"); - #endif - - if(lin_bus_initialized || loopcount == 0 && i == 4) { - lin_ringbuff_clear(); - return -1; - } else { - os_printf("Lin init echo misaligned? Consuming byte (%02x). Retry.\n", lin_ringbuff_get(0)); - lin_ringbuff_consume(1); - continue; - } - } - } - } - - return !lin_await_msg_echo; //true if echo handled -} - -void ICACHE_FLASH_ATTR elm_LINFast_timer_cb(void *arg){ - const elm_protocol_t* proto = (const elm_protocol_t*) arg; - loopcount--; - #ifdef ELM_DEBUG - os_printf("LIN CB call\n"); - #endif - - if(!lin_bus_initialized) { - os_printf("WARNING: LIN CB called without bus initialized!"); - return; // TODO: shoulnd't ever happen. Handle? - } - - int echo_result = elm_LINFast_process_echo(); - - if(echo_result == -1 || (echo_result == 0 && loopcount == 0)) { - if(!is_auto_detecting){ - elm_append_rsp_const("BUS ERROR\r\r>"); - elm_tcp_tx_flush(); - } - loopcount = 0; - lin_bus_initialized = false; - return; - } - - if(echo_result == 0) { - #ifdef ELM_DEBUG - os_printf("Not ready to process\n"); - #endif - os_timer_arm(&elm_timeout, 30, 0); - return; // Not ready to go on - } - - #ifdef ELM_DEBUG - os_printf("Processing ELM %d\n", lin_ringbuff_len); - #endif - - if(loopcount>0) { - for(int pass = 0; pass < 16 && loopcount; pass++){ - elm_LIN_read_into_ringbuff(); - - while(lin_ringbuff_len > 0){ - //if(lin_ringbuff_len > 0){ - if(lin_ringbuff_get(0) & 0x80 != 0x80){ - os_printf("Resetting LIN bus due to bad first byte.\n"); - loopcount = 0; - lin_bus_initialized = false; - lin_ringbuff_clear(); - - if(!is_auto_detecting){ - elm_append_rsp_const("ERROR\r\r>"); - elm_tcp_tx_flush(); - } - return; - } - - uint8_t newmsg_len = 4 + (lin_ringbuff_get(0) & 0x7); - if(lin_ringbuff_len >= newmsg_len) { - #ifdef ELM_DEBUG - os_printf("Processing LIN MSG. BuffLen %d; expect %d. Dat: ", lin_ringbuff_len, newmsg_len); - for(int i = 0; i < newmsg_len; i++) os_printf("%02x ", lin_ringbuff_get(i)); - os_printf("\n"); - #endif - got_msg_this_run = true; - loopcount = LOOPCOUNT_FULL; - - if(!is_auto_detecting){ - if(elm_mode_additional_headers){ - for(int i = 0; i < newmsg_len; i++) elm_append_rsp_hex_byte(lin_ringbuff_get(i)); - } else { - for(int i = 3; i < newmsg_len - 1; i++) elm_append_rsp_hex_byte(lin_ringbuff_get(i)); - } - elm_append_rsp_const("\r"); - } - - lin_ringbuff_consume(newmsg_len); - //elm_reset_aux_timer(); - } else { - break; //Stop consuming data if there is not enough data for the next msg. - } - } - } - os_timer_arm(&elm_timeout, 50, 0); - } else { - bool got_msg_this_run_backup = got_msg_this_run; - if(!got_msg_this_run) { - #ifdef ELM_DEBUG - os_printf(" No data collected\n"); - #endif - if(!is_auto_detecting) { - elm_append_rsp_const("NO DATA\r"); - } - } - got_msg_this_run = false; - - if(!is_auto_detecting) { - elm_append_rsp_const("\r>"); - elm_tcp_tx_flush(); - } else { - elm_autodetect_cb(got_msg_this_run_backup); - } - - //TX RX over, resume Keepalive timer - elm_reset_aux_timer(); - } -} - -void ICACHE_FLASH_ATTR elm_LINFast_businit_timer_cb(void *arg){ - const elm_protocol_t* proto = (const elm_protocol_t*) arg; - loopcount--; - #ifdef ELM_DEBUG - os_printf("LIN INIT CB call\n"); - #endif - - int echo_result = elm_LINFast_process_echo(); - - if(echo_result == -1 || (echo_result == 0 && loopcount == 0)) { - #ifdef ELM_DEBUG - os_printf("Init failed with echo test\n"); - #endif - - loopcount = 0; - lin_bus_initialized = 0; - - if(!is_auto_detecting){ - if(echo_result == -1) - elm_append_rsp_const("BUS ERROR\r\r>"); - else - elm_append_rsp_const("ERROR\r\r>"); - elm_tcp_tx_flush(); - } else { - elm_autodetect_cb(false); - } - return; - } - - if(echo_result == 0) { - #ifdef ELM_DEBUG - os_printf("Not ready to process\n"); - #endif - os_timer_arm(&elm_timeout, elm_mode_timeout, 0); - return; // Not ready to go on - } - - #ifdef ELM_DEBUG - os_printf("Bus init ready to process %d bytes\n", lin_ringbuff_len); - #endif - - if(lin_bus_initialized) return; // TODO: shoulnd't ever happen. Handle? - - if(loopcount>0) { - //Keep waiting for response - for(int i = 0; i < 4; i++){ - elm_LIN_read_into_ringbuff(); - - if(lin_ringbuff_len > 0){ - if(lin_ringbuff_get(0) & 0x80 != 0x80){ - os_printf("Resetting LIN bus due to bad first byte.\n"); - loopcount = 0; - lin_ringbuff_clear(); - - if(!is_auto_detecting){ - elm_append_rsp_const("ERROR\r\r>"); - elm_tcp_tx_flush(); - } else { - elm_autodetect_cb(false); - } - return; - } - - uint8_t newmsg_len = 4 + (lin_ringbuff_get(0) & 0x7); - if(lin_ringbuff_len < newmsg_len) { - os_printf("Resetting LIN because returned init data was wrong.\n"); - loopcount = 0; - lin_ringbuff_clear(); - - if(!is_auto_detecting){ - elm_append_rsp_const("ERROR\r\r>"); - elm_tcp_tx_flush(); - } else { - elm_autodetect_cb(false); - } - return; - } - - if(!elm_LIN_ringbuff_memcmp("\x83\xF1\x10\xC1\x8F\xE9\xBD", 7)) { - lin_ringbuff_consume(7); - lin_bus_initialized = true; - //lin_ringbuff_clear(); - - os_printf("BUS INITIALIZED\n"); - - elm_reset_aux_timer(); - - if(!is_auto_detecting) { - elm_append_rsp_const("OK\r"); - - //Do the send that was delayed - if(lin_cmd_backup_len) { - elm_tcp_tx_flush(); - proto->process_obd(proto, lin_cmd_backup, lin_cmd_backup_len); - } else { - elm_append_rsp_const("\r>"); - elm_tcp_tx_flush(); - } - } else { - #ifdef ELM_DEBUG - os_printf("LIN success. Silent because in autodetect.\n"); - #endif - elm_autodetect_cb(true); - // TODO: Since bus init is good, is it ok to skip sending the '0100' msg? - } - return; - } - } - } - os_timer_arm(&elm_timeout, elm_mode_timeout, 0); - } else { - #ifdef ELM_DEBUG - os_printf("Fall through on bus init\n"); - #endif - if(!is_auto_detecting){ - elm_append_rsp_const("ERROR\r\r>"); - elm_tcp_tx_flush(); - } else { - elm_autodetect_cb(false); - } - elm_reset_aux_timer(); - } -} - -static void ICACHE_FLASH_ATTR elm_process_obd_cmd_LINFast(const elm_protocol_t* proto, - const char *cmd, uint16_t len) { - elm_lin_obd_msg msg = {}; - uint8_t bytelen = (len-1)/2; - if((bytelen > 7 && !elm_mode_allow_long) || bytelen > 8) { - elm_append_rsp_const("?\r\r>"); - return; - } - - os_timer_disarm(&elm_proto_aux_timeout); - - if(!lin_bus_initialized) { - panda_clear_lin_txrx(); - - if(!is_auto_detecting) - elm_append_rsp_const("BUS INIT: "); - - lin_cmd_backup = cmd; - lin_cmd_backup_len = len; - - bytelen = 1; - msg.dat[0] = 0x81; - msg.dat[1] = 0x81; // checksum - - panda_kline_wakeup_pulse(); - } else { - bytelen = MIN(bytelen, 7); - for(int i = 0; i < bytelen; i++){ - msg.dat[i] = elm_decode_hex_byte(&cmd[i*2]); - msg.dat[bytelen] += msg.dat[i]; - } - - elm_msg_mode_ret_filter = msg.dat[0]; - elm_msg_pid_ret_filter = msg.dat[1]; - } - - msg.priority = 0xC0 | bytelen; - msg.receiver = 0x33; - msg.sender = 0xF1; - msg.dat[bytelen] += msg.priority + msg.receiver + msg.sender; // checksum - - #ifdef ELM_DEBUG - os_printf("Sending LIN OBD: Priority: %02x; RecvAddr: %02x; SendAddr: %02x; (%02x); ", - msg.priority, msg.receiver, msg.sender, bytelen); - for(int i = 0; i < 8; i++) os_printf("%02x ", msg.dat[i]); - os_printf("\n"); - #endif - - lin_last_sent_msg_len = (msg.priority & 0x07) + 4; - memcpy(&lin_last_sent_msg, &msg, lin_last_sent_msg_len); - lin_await_msg_echo = true; - panda_usbemu_kline_write(&msg); - - loopcount = LOOPCOUNT_FULL + 1; - os_timer_disarm(&elm_timeout); - - if(lin_bus_initialized) { - os_timer_setfn(&elm_timeout, (os_timer_func_t *)elm_LINFast_timer_cb, proto); - elm_LINFast_timer_cb((void*)proto); - } else { - os_timer_setfn(&elm_timeout, (os_timer_func_t *)elm_LINFast_businit_timer_cb, proto); - elm_LINFast_businit_timer_cb((void*)proto); - } -} - -/***************************************************** - *** ELM protocol specification and implementation *** - *** -> ISO 15765-4 implementation *** - *****************************************************/ - -void ICACHE_FLASH_ATTR elm_ISO15765_timer_cb(void *arg){ - const elm_protocol_t* proto = (const elm_protocol_t*) arg; - loopcount--; - if(loopcount>0) { - for(int pass = 0; pass < 16 && loopcount; pass++){ - panda_can_msg_t *can_msgs; - int num_can_msgs = panda_usbemu_can_read(&can_msgs); - - #ifdef ELM_DEBUG - if(num_can_msgs) os_printf(" Received %d can messages\n", num_can_msgs); - #endif - - if(num_can_msgs < 0) continue; - if(!num_can_msgs) break; - - for(int i = 0; i < num_can_msgs; i++){ - - panda_can_msg_t *recv = &can_msgs[i]; - - #ifdef ELM_DEBUG - os_printf(" RECV: Bus: %d; Addr: %08x; ext: %d; tx: %d; Len: %d; ", - recv->bus, panda_get_can_addr(recv), recv->ext, recv->tx, recv->len); - for(int j = 0; j < recv->len; j++) os_printf("%02x ", recv->data[j]); - os_printf("Ts: %d\n", recv->ts); - #endif - - if (recv->bus==0 && recv->len == 8 && - ( - (proto->type == CAN11 && !recv->ext && (panda_get_can_addr(recv) & 0x7F8) == 0x7E8) || - (proto->type == CAN29 && recv->ext && (panda_get_can_addr(recv) & 0x1FFFFF00) == 0x18DAF100) - ) - ) { - if(recv->data[0] <= 7 && - recv->data[1] == (0x40|elm_msg_mode_ret_filter) && - recv->data[2] == elm_msg_pid_ret_filter) { - got_msg_this_run = true; - loopcount = LOOPCOUNT_FULL; - - #ifdef ELM_DEBUG - os_printf(" CAN msg response, index: %d\n", i); - #endif - - if(!is_auto_detecting){ - if(elm_mode_additional_headers){ - elm_append_rsp_can_msg_addr(recv); - for(int j = 0; j < recv->data[0]+1; j++) elm_append_rsp_hex_byte(recv->data[j]); - } else { - for(int j = 1; j < recv->data[0]+1; j++) elm_append_rsp_hex_byte(recv->data[j]); - } - - elm_append_rsp_const("\r"); - elm_tcp_tx_flush(); - } - - } else if((recv->data[0] & 0xF0) == 0x10 && - recv->data[2] == (0x40|elm_msg_mode_ret_filter) && - recv->data[3] == elm_msg_pid_ret_filter) { - got_msg_this_run = true; - loopcount = LOOPCOUNT_FULL; - panda_usbemu_can_write(0, - (proto->type==CAN11) ? - 0x7E0 | (panda_get_can_addr(recv)&0x7) : - (0x18DA00F1 | (((panda_get_can_addr(recv))&0xFF)<<8)), - "\x30\x00\x00", 3); - - did_multimessage = true; - - #ifdef ELM_DEBUG - os_printf(" CAN multimsg start response, index: %d, len %d\n", i, - ((recv->data[0]&0xF)<<8) | recv->data[1]); - #endif - - if(!is_auto_detecting){ - if(!elm_mode_additional_headers) { - elm_append_rsp(&hex_lookup[recv->data[0]&0xF], 1); - elm_append_rsp_hex_byte(recv->data[1]); - elm_append_rsp_const("\r0:"); - if(elm_mode_print_spaces) elm_append_rsp_const(" "); - for(int j = 2; j < 8; j++) elm_append_rsp_hex_byte(recv->data[j]); - } else { - elm_append_rsp_can_msg_addr(recv); - for(int j = 0; j < 8; j++) elm_append_rsp_hex_byte(recv->data[j]); - } - - elm_append_rsp_const("\r"); - elm_tcp_tx_flush(); - } - - } else if (did_multimessage && (recv->data[0] & 0xF0) == 0x20) { - got_msg_this_run = true; - loopcount = LOOPCOUNT_FULL; - #ifdef ELM_DEBUG - os_printf(" CAN multimsg data response, index: %d\n", i); - #endif - - if(!is_auto_detecting){ - if(!elm_mode_additional_headers) { - elm_append_rsp(&hex_lookup[recv->data[0] & 0xF], 1); - elm_append_rsp_const(":"); - if(elm_mode_print_spaces) elm_append_rsp_const(" "); - for(int j = 1; j < 8; j++) elm_append_rsp_hex_byte(recv->data[j]); - } else { - elm_append_rsp_can_msg_addr(recv); - for(int j = 0; j < 8; j++) elm_append_rsp_hex_byte(recv->data[j]); - } - elm_append_rsp_const("\r"); - } - } - } else if (recv->bus == 0x80 && recv->len == 8 && - (panda_get_can_addr(recv) == ((proto->type==CAN11) ? 0x7DF : 0x18DB33F1)) - ) { - //Can send receipt - #ifdef ELM_DEBUG - os_printf(" Got CAN tx receipt\n"); - #endif - can_tx_worked = true; - } - } - } - os_timer_arm(&elm_timeout, elm_mode_timeout, 0); - } else { - bool got_msg_this_run_backup = got_msg_this_run; - if(did_multimessage) { - os_printf(" End of multi message\n"); - } else if(!got_msg_this_run) { - os_printf(" No data collected\n"); - if(!is_auto_detecting) { - if(can_tx_worked) { - elm_append_rsp_const("NO DATA\r"); - } else { - elm_append_rsp_const("CAN ERROR\r"); - } - } - } - did_multimessage = false; - got_msg_this_run = false; - can_tx_worked = false; - - if(!is_auto_detecting) { - elm_append_rsp_const("\r>"); - elm_tcp_tx_flush(); - } else { - elm_autodetect_cb(got_msg_this_run_backup); - } - } -} - -static void ICACHE_FLASH_ATTR elm_init_ISO15765(const elm_protocol_t* proto){ - panda_set_can0_cbaud(proto->cbaud); -} - -static void ICACHE_FLASH_ATTR elm_process_obd_cmd_ISO15765(const elm_protocol_t* proto, - const char *cmd, uint16_t len) { - elm_can_obd_msg msg = {}; - msg.len = (len-1)/2; - if((msg.len > 7 && !elm_mode_allow_long) || msg.len > 8) { - elm_append_rsp_const("?\r\r>"); - return; - } - - msg.len = MIN(msg.len, 7); - - for(int i = 0; i < msg.len; i++) - msg.dat[i] = elm_decode_hex_byte(&cmd[i*2]); - - elm_msg_mode_ret_filter = msg.dat[0]; - elm_msg_pid_ret_filter = msg.dat[1]; - - #ifdef ELM_DEBUG - os_printf("Sending CAN OBD: %02x; ", msg.len); - for(int i = 0; i < 7; i++) - os_printf("%02x ", msg.dat[i]); - os_printf("\n"); - #endif - - panda_clear_can_rx(); - - panda_usbemu_can_write(0, (proto->type==CAN11) ? 0x7DF : 0x18DB33F1, - (uint8_t*)&msg, msg.len+1); - - #ifdef ELM_DEBUG - os_printf("Starting up timer\n"); - #endif - - loopcount = LOOPCOUNT_FULL; - os_timer_disarm(&elm_timeout); - os_timer_setfn(&elm_timeout, (os_timer_func_t *)elm_ISO15765_timer_cb, proto); - os_timer_arm(&elm_timeout, elm_mode_timeout, 0); -} - -/***************************************************** - *** ELM protocol specification and implementation *** - *** -> Stuf for unsupported CAN protocols *** - *****************************************************/ - -static void ICACHE_FLASH_ATTR elm_process_obd_cmd_CANGen(const elm_protocol_t* proto, - const char *cmd, uint16_t len) { - elm_append_rsp_const("NO DATA\r\r>"); -} - -/***************************************************** - *** ELM protocol specification and implementation *** - *** -> AUTO Detect implementation *** - *****************************************************/ - -static int elm_autodetect_proto_iter; -static uint16_t elm_staged_auto_msg_len; -static const char* elm_staged_auto_msg; - -static void ICACHE_FLASH_ATTR elm_autodetect_cb(bool proto_worked){ - if(proto_worked) { - os_printf("Autodetect proto success\n"); - is_auto_detecting = false; - elm_selected_protocol = elm_autodetect_proto_iter; - elm_current_proto()->process_obd(elm_current_proto(), - elm_staged_auto_msg, elm_staged_auto_msg_len); - } else { - for(elm_autodetect_proto_iter++; elm_autodetect_proto_iter < ELM_PROTOCOL_COUNT; - elm_autodetect_proto_iter++){ - const elm_protocol_t *proto = &elm_protocols[elm_autodetect_proto_iter]; - if(proto->supported && proto->type != AUTO) { - os_printf("*** AUTO trying '%s'\n", proto->name); - proto->init(proto); - proto->process_obd(proto, "0100\r", 5); // Try sending on the bus - return; - } - } - - //if(elm_autodetect_main()) return; - is_auto_detecting = false; - os_printf("Autodetect failed\n"); - elm_append_rsp_const("UNABLE TO CONNECT\r\r>"); - elm_tcp_tx_flush(); - } -} - -static void ICACHE_FLASH_ATTR elm_process_obd_cmd_AUTO(const elm_protocol_t* proto, - const char *cmd, uint16_t len) { - elm_append_rsp_const("SEARCHING...\r"); - elm_staged_auto_msg_len = len; - elm_staged_auto_msg = cmd; - is_auto_detecting = true; - - elm_autodetect_proto_iter = 0; - elm_autodetect_cb(false); -} - -/***************************************************** - *** ELM protocol specification and implementation *** - *** -> Protocol Registry and related functions. *** - *****************************************************/ - -static const elm_protocol_t elm_protocols[] = { - {true, AUTO, 0, elm_process_obd_cmd_AUTO, NULL, "AUTO", }, - {false, NA, 416, elm_process_obd_cmd_J1850, NULL, "SAE J1850 PWM", }, - {false, NA, 104, elm_process_obd_cmd_J1850, NULL, "SAE J1850 VPW", }, - {false, LIN, 104, elm_process_obd_cmd_LIN5baud, NULL, "ISO 9141-2", }, - {false, LIN, 104, elm_process_obd_cmd_LIN5baud, NULL, "ISO 14230-4 (KWP 5BAUD)", }, - {true, LIN, 104, elm_process_obd_cmd_LINFast, NULL, "ISO 14230-4 (KWP FAST)", }, - {true, CAN11, 5000, elm_process_obd_cmd_ISO15765, elm_init_ISO15765, "ISO 15765-4 (CAN 11/500)",}, - {true, CAN29, 5000, elm_process_obd_cmd_ISO15765, elm_init_ISO15765, "ISO 15765-4 (CAN 29/500)",}, - {true, CAN11, 2500, elm_process_obd_cmd_ISO15765, elm_init_ISO15765, "ISO 15765-4 (CAN 11/250)",}, - {true, CAN29, 2500, elm_process_obd_cmd_ISO15765, elm_init_ISO15765, "ISO 15765-4 (CAN 29/250)",}, - {false, CAN29, 2500, elm_process_obd_cmd_CANGen, NULL, "SAE J1939 (CAN 29/250)", }, - {false, CAN11, 1250, elm_process_obd_cmd_CANGen, NULL, "USER1 (CAN 11/125)", }, - {false, CAN11, 500, elm_process_obd_cmd_CANGen, NULL, "USER2 (CAN 11/50)", }, -}; - -static const elm_protocol_t* ICACHE_FLASH_ATTR elm_current_proto() { - return &elm_protocols[elm_selected_protocol]; -} - -void ICACHE_FLASH_ATTR elm_reset_aux_timer() { - os_timer_disarm(&elm_proto_aux_timeout); - if(elm_mode_keepalive_period) - os_timer_arm(&elm_proto_aux_timeout, elm_mode_keepalive_period, 0); -} - -void ICACHE_FLASH_ATTR elm_proto_reinit(const elm_protocol_t *proto) { - if(proto->init) proto->init(proto); -} - -/******************************************* - *** ELM AT command parsing and handling *** - *******************************************/ - -enum at_cmd_ids_t { // FULL ELM 1.0 list - AT_INVALID, //Fake - - AT_AMP1, - AT_AL, - AT_AT0, AT_AT1, AT_AT2, // Added ELM 1.2, expected by Torque - AT_BD, - AT_BI, - AT_CAF0, AT_CAF1, - AT_CF_8, AT_CF_3, - AT_CFC0, AT_CFC1, - AT_CM_8, AT_CM_3, - AT_CP, - AT_CS, - AT_CV, - AT_D, - AT_DP, AT_DPN, - AT_E0, AT_E1, - AT_H0, AT_H1, - AT_I, - AT_IB10, - AT_IB96, - AT_L0, AT_L1, - AT_M0, AT_M1, AT_MA, - AT_MR, - AT_MT, - AT_NL, - AT_PC, - AT_R0, AT_R1, - AT_RV, - AT_S0, AT_S1, // Added ELM 1.3, expected by Torque - AT_SH_6, AT_SH_3, - AT_SPA, AT_SP, - AT_ST, - AT_SW, - AT_TPA, AT_TP, - AT_WM_XYZA, AT_WM_XYZAB, AT_WM_XYZABC, - AT_WS, - AT_Z, -}; - -typedef struct { - char* name; - uint8_t name_len; - uint8_t cmd_len; - enum at_cmd_ids_t id; -} at_cmd_reg_t; - -static const at_cmd_reg_t at_cmd_reg[] = { - {"@1", 2, 2, AT_AMP1}, - {"AL", 2, 2, AT_AL}, - {"AT0", 3, 3, AT_AT0}, // Added ELM 1.2, expected by Torque - {"AT1", 3, 3, AT_AT1}, // Added ELM 1.2, expected by Torque - {"AT2", 3, 3, AT_AT2}, // Added ELM 1.2, expected by Torque - {"DP", 2, 2, AT_DP}, - {"DPN", 3, 3, AT_DPN}, - {"E0", 2, 2, AT_E0}, - {"E1", 2, 2, AT_E1}, - {"H0", 2, 2, AT_H0}, - {"H1", 2, 2, AT_H1}, - {"I", 1, 1, AT_I}, - {"L0", 2, 2, AT_L0}, - {"L1", 2, 2, AT_L1}, - {"M0", 2, 2, AT_M0}, - //{"M1", 2, 2, AT_M1}, - {"NL", 2, 2, AT_NL}, - {"PC", 2, 2, AT_PC}, - {"S0", 2, 2, AT_S0}, // Added ELM 1.3, expected by Torque - {"S1", 2, 2, AT_S1}, // Added ELM 1.3, expected by Torque - {"SP", 2, 3, AT_SP}, - {"SPA", 3, 4, AT_SPA}, - {"ST", 2, 4, AT_ST}, - {"SW", 2, 4, AT_SW}, - {"Z", 1, 1, AT_Z}, -}; -#define AT_CMD_REG_LEN (sizeof(at_cmd_reg)/sizeof(at_cmd_reg_t)) - -static enum at_cmd_ids_t ICACHE_FLASH_ATTR elm_parse_at_cmd(char *cmd, uint16_t len){ - int i; - for(i=0; i7 BYTES) - elm_mode_allow_long = true; - break; - case AT_AT0: //DISABLE ADAPTIVE TIMING - elm_mode_adaptive_timing = 0; - break; - case AT_AT1: //SET ADAPTIVE TIMING TO AUTO1 - elm_mode_adaptive_timing = 1; - break; - case AT_AT2: //SET ADAPTIVE TIMING TO AUTO2 - elm_mode_adaptive_timing = 2; - break; - case AT_DP: //DESCRIBE THE PROTOCOL BY NAME - if(elm_mode_auto_protocol && elm_selected_protocol != 0) - elm_append_rsp_const("AUTO, "); - elm_append_rsp(elm_current_proto()->name, - strlen(elm_current_proto()->name)); - elm_append_rsp_const("\r\r"); - return; - case AT_DPN: //DESCRIBE THE PROTOCOL BY NUMBER - //TODO: Required. Report currently selected protocol - if(elm_mode_auto_protocol) - elm_append_rsp_const("A"); - elm_append_rsp(&hex_lookup[elm_selected_protocol], 1); - elm_append_rsp_const("\r\r"); - return; // Don't display 'OK' - case AT_E0: //ECHO OFF - elm_mode_echo = false; - break; - case AT_E1: //ECHO ON - elm_mode_echo = true; - break; - case AT_H0: //SHOW FULL CAN HEADERS OFF - elm_mode_additional_headers = false; - break; - case AT_H1: //SHOW FULL CAN HEADERS ON - elm_mode_additional_headers = true; - break; - case AT_I: //IDENTIFY SELF - elm_append_rsp_const(IDENT_MSG); - return; - case AT_L0: //LINEFEED OFF - elm_mode_linefeed = false; - break; - case AT_L1: //LINEFEED ON - elm_mode_linefeed = true; - break; - case AT_M0: //DISABLE NONVOLATILE STORAGE - //Memory storage is likely unnecessary - break; - case AT_NL: //DISABLE LONG MESSAGE SUPPORT (>7 BYTES) - elm_mode_allow_long = false; - break; - case AT_PC: //PROTOCOL CANCEL (Stop timers and stuff) - { - //Init functions should idenpotently prepare the protocol to be used. - //Thus, the init function can be used as a protocol cancel function - elm_proto_reinit(elm_current_proto()); - break; - } - case AT_S0: //DISABLE PRINTING SPACES IN ECU RESPONSES - elm_mode_print_spaces = false; - break; - case AT_S1: //ENABLE PRINTING SPACES IN ECU RESPONSES - elm_mode_print_spaces = true; - break; - case AT_SP: //SET PROTOCOL - tmp = elm_decode_hex_char(cmd[2]); - if(tmp == -1 || tmp >= ELM_PROTOCOL_COUNT) { - elm_append_rsp_const("?\r\r"); - return; - } - - //De-Init previous protocol - elm_proto_reinit(elm_current_proto()); - - elm_selected_protocol = tmp; - elm_mode_auto_protocol = (tmp == 0); - - //Init new protocol - elm_proto_reinit(elm_current_proto()); - break; - case AT_SPA: //SET PROTOCOL WITH AUTO FALLBACK - tmp = elm_decode_hex_char(cmd[3]); - if(tmp == -1 || tmp >= ELM_PROTOCOL_COUNT) { - elm_append_rsp_const("?\r\r"); - return; - } - - //De-Init previous protocol - elm_proto_reinit(elm_current_proto()); - - elm_selected_protocol = tmp; - elm_mode_auto_protocol = true; - - //Init new protocol - elm_proto_reinit(elm_current_proto()); - break; - case AT_ST: //SET TIMEOUT - if(!elm_check_valid_hex_chars(&cmd[2], 2)) { - elm_append_rsp_const("?\r\r"); - return; - } - - tmp = elm_decode_hex_byte(&cmd[2]); - //20 for CAN, 4 for LIN - elm_mode_timeout = tmp ? tmp*20 : ELM_MODE_TIMEOUT_DEFAULT; - break; - case AT_SW: //SET WAKEUP TIME INTERVAL - if(!elm_check_valid_hex_chars(&cmd[2], 2)) { - elm_append_rsp_const("?\r\r"); - return; - } - - tmp = elm_decode_hex_byte(&cmd[2]); - elm_mode_keepalive_period = tmp ? MAX(tmp, 0x20) * 20 : 0; - - if(lin_bus_initialized){ - os_timer_disarm(&elm_proto_aux_timeout); - if(elm_mode_keepalive_period) - os_timer_arm(&elm_proto_aux_timeout, elm_mode_keepalive_period, 0); - } - break; - case AT_Z: //RESET - elm_mode_echo = true; - elm_mode_linefeed = false; - elm_mode_additional_headers = false; - elm_mode_auto_protocol = true; - elm_selected_protocol = ELM_MODE_SELECTED_PROTOCOL_DEFAULT; - elm_mode_print_spaces = true; - elm_mode_adaptive_timing = 1; - elm_mode_allow_long = false; - elm_mode_timeout = ELM_MODE_TIMEOUT_DEFAULT; - elm_mode_keepalive_period = ELM_MODE_KEEPALIVE_PERIOD_DEFAULT; - - elm_append_rsp_const("\r\r"); - elm_append_rsp_const(IDENT_MSG); - panda_set_safety_mode(0xE327); - - elm_proto_reinit(elm_current_proto()); - return; - default: - elm_append_rsp_const("?\r\r"); - return; - } - - elm_append_rsp_const("OK\r\r"); -} - -/************************************* - *** Connection and cli management *** - *************************************/ - -static void ICACHE_FLASH_ATTR elm_append_in_msg(char *data, uint16_t len) { - if(in_msg_len + len > sizeof(in_msg)) - len = sizeof(in_msg) - in_msg_len; - memcpy(in_msg + in_msg_len, data, len); - in_msg_len += len; -} - -static int ICACHE_FLASH_ATTR elm_msg_is_at_cmd(char *data, uint16_t len){ - return len >= 4 && data[0] == 'A' && data[1] == 'T'; -} - -static void ICACHE_FLASH_ATTR elm_rx_cb(void *arg, char *data, uint16_t len) { - #ifdef ELM_DEBUG - //os_printf("\nGot ELM Data In: '%s'\n", data); - #endif - - rsp_buff_len = 0; - len = elm_msg_find_cr_or_eos(data, len); - - if(loopcount){ - os_timer_disarm(&elm_timeout); - loopcount = 0; - got_msg_this_run = false; - can_tx_worked = false; - did_multimessage = false; - - os_printf("Interrupting operation, stopping timer. msg len: %d\n", len); - elm_append_rsp_const("STOPPED\r\r>"); - if(len == 1 && data[0] == '\r') { - os_printf("Empty msg source of interrupt.\n"); - elm_tcp_tx_flush(); - return; - } - } - - if(!(len == 1 && data[0] == '\r') && in_msg_len && in_msg[in_msg_len-1] == '\r'){ - in_msg_len = 0; - } - - if(!(len == 1 && data[0] == '\r' && in_msg_len && in_msg[in_msg_len-1] == '\r')) { - // Not Repeating last message - elm_append_in_msg(data, len); //Aim to remove this memcpy - } - if(elm_mode_echo) - elm_append_rsp(in_msg, in_msg_len); - - if(in_msg_len > 0 && in_msg[in_msg_len-1] == '\r') { //Got a full line - stripped_msg_len = elm_strip(in_msg, in_msg_len, stripped_msg, sizeof(stripped_msg)); - - if(elm_msg_is_at_cmd(stripped_msg, stripped_msg_len)) { - elm_process_at_cmd(stripped_msg+2, stripped_msg_len-2); - elm_append_rsp_const(">"); - } else if(elm_check_valid_hex_chars(stripped_msg, stripped_msg_len - 1)) { - elm_current_proto()->process_obd(elm_current_proto(), stripped_msg, stripped_msg_len); - } else { - elm_append_rsp_const("?\r\r>"); - } - } - - elm_tcp_tx_flush(); - - //Just clear the buffer if full with no termination - if(in_msg_len == sizeof(in_msg) && in_msg[in_msg_len-1] != '\r') - in_msg_len = 0; -} - -void ICACHE_FLASH_ATTR elm_tcp_disconnect_cb(void *arg){ - struct espconn *pesp_conn = (struct espconn *)arg; - - elm_tcp_conn_t * prev = NULL; - for(elm_tcp_conn_t *iter = connection_list; iter != NULL; iter=iter->next){ - struct espconn *conn = iter->conn; - //SHOW_CONNECTION("Considering Disconnecting", conn); - if(!memcmp(pesp_conn->proto.tcp->remote_ip, conn->proto.tcp->remote_ip, 4) && - pesp_conn->proto.tcp->remote_port == conn->proto.tcp->remote_port){ - os_printf("Deleting ELM Connection!\n"); - if(prev){ - prev->next = iter->next; - } else { - connection_list = iter->next; - } - os_free(iter); - break; - } - - prev = iter; - } - - if(connection_list == NULL) { - //If all clients are disconnected, reset the protocol (cancels - //keep alive timers). This will not detect inproperly killed - //connections. In this case, periodic events associated with the - //current protocol will continue until a new client attaches, a - //command is sent generating a response (ELM will try to responde - //to the dead connection, and remove it upon error), and finally, - //the new client disconnects. OFC a power cycle is also an option. - elm_proto_reinit(elm_current_proto()); - } -} - -void ICACHE_FLASH_ATTR elm_tcp_connect_cb(void *arg) { - struct espconn *pesp_conn = (struct espconn *)arg; - //SHOW_CONNECTION("New connection", pesp_conn); - espconn_set_opt(&elm_conn, ESPCONN_NODELAY); - espconn_regist_recvcb(pesp_conn, elm_rx_cb); - //Allow several sends to be queued at a time. - espconn_tcp_set_buf_count(pesp_conn, 3); - - bool connection_address_already_there = false; - for(elm_tcp_conn_t *iter2 = connection_list; iter2 != NULL; iter2 = iter2->next) - if(iter2->conn == pesp_conn){connection_address_already_there = true; break;} - - if(connection_address_already_there) { - os_printf("ELM WIFI: Memory reuse of recently killed connection\n"); - } else { - os_printf("ELM WIFI: Adding connection\n"); - elm_tcp_conn_t *newconn = os_malloc(sizeof(elm_tcp_conn_t)); - if(!newconn) { - os_printf("Failed to allocate place for connection\n"); - } else { - newconn->next = connection_list; - newconn->conn = pesp_conn; - connection_list = newconn; - } - } -} - -void ICACHE_FLASH_ATTR elm327_init() { - // control listener - elm_proto.local_port = ELM_PORT; - elm_conn.type = ESPCONN_TCP; - elm_conn.state = ESPCONN_NONE; - elm_conn.proto.tcp = &elm_proto; - espconn_regist_connectcb(&elm_conn, elm_tcp_connect_cb); - espconn_regist_disconcb(&elm_conn, elm_tcp_disconnect_cb); - espconn_accept(&elm_conn); - espconn_regist_time(&elm_conn, 0, 0); // 60s timeout for all connections -} diff --git a/panda/boardesp/get_sdk.sh b/panda/boardesp/get_sdk.sh deleted file mode 100755 index adccf678f9c6a9..00000000000000 --- a/panda/boardesp/get_sdk.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -sudo apt-get install make unrar-free autoconf automake libtool gcc g++ gperf \ - flex bison texinfo gawk ncurses-dev libexpat-dev python-dev python python-serial \ - sed git unzip bash help2man wget bzip2 -# huh? -sudo apt-get install libtool -sudo apt-get install libtool-bin -git clone --recursive https://github.com/pfalcon/esp-open-sdk.git -cd esp-open-sdk -git checkout 03f5e898a059451ec5f3de30e7feff30455f7cec -LD_LIBRARY_PATH="" make STANDALONE=y - diff --git a/panda/boardesp/get_sdk_ci.sh b/panda/boardesp/get_sdk_ci.sh deleted file mode 100755 index b11cb099a6eb5c..00000000000000 --- a/panda/boardesp/get_sdk_ci.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -git clone --recursive https://github.com/pfalcon/esp-open-sdk.git -cd esp-open-sdk -git checkout 03f5e898a059451ec5f3de30e7feff30455f7cec -LD_LIBRARY_PATH="" make STANDALONE=y diff --git a/panda/boardesp/get_sdk_mac.sh b/panda/boardesp/get_sdk_mac.sh deleted file mode 100755 index a8c2d709d45811..00000000000000 --- a/panda/boardesp/get_sdk_mac.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -# from http://www.esp8266.com/wiki/doku.php?id=setup-osx-compiler-esp8266 - -brew install gnu-sed --with-default-names -brew tap homebrew/dupes -brew install gperf -brew install grep -brew install autoconf -brew install binutils -brew install gawk -brew install wget -brew install automake -brew install libtool -brew install help2man - -brew uninstall gperf - -hdiutil create esp-open-sdk.dmg -volname "esp-open-sdk" -size 10g -fs "Case-sensitive HFS+" -hdiutil mount esp-open-sdk.dmg -ln -s /Volumes/esp-open-sdk esp-open-sdk -cd esp-open-sdk - -git init -git remote add origin https://github.com/pfalcon/esp-open-sdk.git -git fetch origin -git checkout 03f5e898a059451ec5f3de30e7feff30455f7cec -git submodule init -git submodule update --recursive - -make STANDALONE=y - diff --git a/panda/boardesp/include/espmissingincludes.h b/panda/boardesp/include/espmissingincludes.h deleted file mode 100644 index 51672d3f50c54c..00000000000000 --- a/panda/boardesp/include/espmissingincludes.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef ESPMISSINGINCLUDES_H -#define ESPMISSINGINCLUDES_H - -#include -#include -#include - - -int strcasecmp(const char *a, const char *b); -#ifndef FREERTOS -#include -#include -//Missing function prototypes in include folders. Gcc will warn on these if we don't define 'em anywhere. -//MOST OF THESE ARE GUESSED! but they seem to swork and shut up the compiler. -typedef struct espconn espconn; - -int atoi(const char *nptr); -void ets_install_putc1(void *routine); -void ets_isr_attach(int intr, void *handler, void *arg); -void ets_isr_mask(unsigned intr); -void ets_isr_unmask(unsigned intr); -int ets_memcmp(const void *s1, const void *s2, size_t n); -void *ets_memcpy(void *dest, const void *src, size_t n); -void *ets_memset(void *s, int c, size_t n); -int ets_sprintf(char *str, const char *format, ...) __attribute__ ((format (printf, 2, 3))); -int ets_str2macaddr(void *, void *); -int ets_strcmp(const char *s1, const char *s2); -char *ets_strcpy(char *dest, const char *src); -size_t ets_strlen(const char *s); -int ets_strncmp(const char *s1, const char *s2, int len); -char *ets_strncpy(char *dest, const char *src, size_t n); -char *ets_strstr(const char *haystack, const char *needle); -void ets_timer_arm_new(os_timer_t *a, int b, int c, int isMstimer); -void ets_timer_disarm(os_timer_t *a); -void ets_timer_setfn(os_timer_t *t, ETSTimerFunc *fn, void *parg); -void ets_update_cpu_frequency(int freqmhz); -void *os_memmove(void *dest, const void *src, size_t n); -int os_printf(const char *format, ...) __attribute__ ((format (printf, 1, 2))); -int os_snprintf(char *str, size_t size, const char *format, ...) __attribute__ ((format (printf, 3, 4))); -int os_printf_plus(const char *format, ...) __attribute__ ((format (printf, 1, 2))); -void uart_div_modify(int no, unsigned int freq); -uint8 wifi_get_opmode(void); -uint32 system_get_time(); -int rand(void); -void ets_bzero(void *s, size_t n); -void ets_delay_us(int ms); - -//Hack: this is defined in SDK 1.4.0 and undefined in 1.3.0. It's only used for this, the symbol itself -//has no meaning here. -#ifndef RC_LIMIT_P2P_11N -//Defs for SDK <1.4.0 -void *pvPortMalloc(size_t xWantedSize); -void *pvPortZalloc(size_t); -void vPortFree(void *ptr); -void *vPortMalloc(size_t xWantedSize); -void pvPortFree(void *ptr); -#else -void *pvPortMalloc(size_t xWantedSize, const char *file, int line); -void *pvPortZalloc(size_t, const char *file, int line); -void vPortFree(void *ptr, const char *file, int line); -void *vPortMalloc(size_t xWantedSize, const char *file, int line); -void pvPortFree(void *ptr, const char *file, int line); -#endif - -//Standard PIN_FUNC_SELECT gives a warning. Replace by a non-warning one. -#ifdef PIN_FUNC_SELECT -#undef PIN_FUNC_SELECT -#define PIN_FUNC_SELECT(PIN_NAME, FUNC) do { \ - WRITE_PERI_REG(PIN_NAME, \ - (READ_PERI_REG(PIN_NAME) \ - & (~(PERIPHS_IO_MUX_FUNC< _b ? _a : _b; }) - -char ssid[32]; -char password[] = "testing123"; -int wifi_secure_mode = 0; - -static const int pin = 2; - -// Structure holding the TCP connection information. -struct espconn tcp_conn; -// TCP specific protocol structure. -esp_tcp tcp_proto; - -// interrupt communication on port 1338, UDP! -struct espconn inter_conn; -esp_udp inter_proto; - -uint32_t sendData[0x14] = {0}; -uint32_t recvData[0x40] = {0}; - -static int ICACHE_FLASH_ATTR __spi_comm(char *dat, int len, uint32_t *recvData, int recvDataLen) { - unsigned int length = 0; - - SpiData spiData; - - spiData.cmd = 2; - spiData.cmdLen = 0; - spiData.addr = NULL; - spiData.addrLen = 0; - - // float boot pin - gpio_output_set(0, 0, 0, (1 << 4)); - - // manual CS pin - gpio_output_set(0, (1 << 5), 0, 0); - memset(sendData, 0xCC, 0x14); - - // wait for ST to respond to CS interrupt - os_delay_us(50); - - // send request - memcpy(((void*)sendData), dat, len); - spiData.data = sendData; - spiData.dataLen = 0x14; - SPIMasterSendData(SpiNum_HSPI, &spiData); - - #define SPI_TIMEOUT 50000 - // give the ST time to be ready, up to 500ms - int i; - for (i = 0; (gpio_input_get() & (1 << 4)) && i < SPI_TIMEOUT; i++) { - os_delay_us(10); - system_soft_wdt_feed(); - } - - // TODO: handle this better - if (i == SPI_TIMEOUT) { - os_printf("ERROR: SPI receive failed\n"); - goto fail; - } - - // blank out recvData - memset(recvData, 0x00, 0x44); - - // receive the length - spiData.data = recvData; - spiData.dataLen = 4; - if(SPIMasterRecvData(SpiNum_HSPI, &spiData) == -1) { - // TODO: Handle gracefully. Maybe fail if len read fails? - os_printf("SPI: Failed to recv length\n"); - goto fail; - } - - length = recvData[0]; - if (length > 0x40) { - os_printf("SPI: BAD LENGTH RECEIVED %x\n", length); - length = 0; - goto fail; - } - - // got response, 0x40 works, 0x44 does not - spiData.data = recvData+1; - spiData.dataLen = (length+3)&(~3); // recvDataLen; - if(SPIMasterRecvData(SpiNum_HSPI, &spiData) == -1) { - // TODO: Handle gracefully. Maybe retry if payload failed. - os_printf("SPI: Failed to recv payload\n"); - length = 0; - goto fail; - } - -fail: - // clear CS - gpio_output_set((1 << 5), 0, 0, 0); - - // set boot pin back - gpio_output_set((1 << 4), 0, (1 << 4), 0); - - return length; -} - -int ICACHE_FLASH_ATTR spi_comm(char *dat, int len, uint32_t *recvData, int recvDataLen) { - // blink the led during SPI comm - if (GPIO_REG_READ(GPIO_OUT_ADDRESS) & (1 << pin)) { - // set gpio low - gpio_output_set(0, (1 << pin), 0, 0); - } else { - // set gpio high - gpio_output_set((1 << pin), 0, 0, 0); - } - - return __spi_comm(dat, len, recvData, recvDataLen); -} - -static void ICACHE_FLASH_ATTR tcp_rx_cb(void *arg, char *data, uint16_t len) { - // nothing too big - if (len > 0x14) return; - - // do the SPI comm - spi_comm(data, len, recvData, 0x40); - - espconn_send(&tcp_conn, recvData, 0x44); -} - -void ICACHE_FLASH_ATTR tcp_connect_cb(void *arg) { - struct espconn *conn = (struct espconn *)arg; - espconn_set_opt(&tcp_conn, ESPCONN_NODELAY); - espconn_regist_recvcb(conn, tcp_rx_cb); -} - -// must be 0x44, because we can fit 4 more -uint8_t buf[0x44*0x10]; -int queue_send_len = -1; - -void ICACHE_FLASH_ATTR poll_can(void *arg) { - uint8_t timerRecvData[0x44] = {0}; - int i = 0; - int j; - - while (i < 0x40) { - int len = spi_comm("\x01\x00\x00\x00", 4, timerRecvData, 0x40); - if (len == 0) break; - if (len > 0x40) { os_printf("SPI LENGTH ERROR!"); break; } - - // if it sends it, assume it's valid CAN - for (j = 0; j < len; j += 0x10) { - memcpy(buf + i*0x10, (timerRecvData+4)+j, 0x10); - i++; - } - } - - if (i != 0) { - int ret = espconn_sendto(&inter_conn, buf, i*0x10); - if (ret != 0) { - os_printf("send failed: %d\n", ret); - queue_send_len = i*0x10; - } else { - queue_send_len = -1; - } - } -} - -int udp_countdown = 0; - -static volatile os_timer_t udp_callback; -void ICACHE_FLASH_ATTR udp_callback_func(void *arg) { - if (queue_send_len == -1) { - poll_can(NULL); - } else { - int ret = espconn_sendto(&inter_conn, buf, queue_send_len); - if (ret == 0) { - queue_send_len = -1; - } - } - if (udp_countdown > 0) { - os_timer_arm(&udp_callback, 5, 0); - udp_countdown--; - } else { - os_printf("UDP timeout\n"); - } -} - -void ICACHE_FLASH_ATTR inter_recv_cb(void *arg, char *pusrdata, unsigned short length) { - remot_info *premot = NULL; - if (espconn_get_connection_info(&inter_conn,&premot,0) == ESPCONN_OK) { - inter_conn.proto.udp->remote_port = premot->remote_port; - inter_conn.proto.udp->remote_ip[0] = premot->remote_ip[0]; - inter_conn.proto.udp->remote_ip[1] = premot->remote_ip[1]; - inter_conn.proto.udp->remote_ip[2] = premot->remote_ip[2]; - inter_conn.proto.udp->remote_ip[3] = premot->remote_ip[3]; - - - if (udp_countdown == 0) { - os_printf("UDP recv\n"); - udp_countdown = 200*5; - - // start 5 second timer - os_timer_disarm(&udp_callback); - os_timer_setfn(&udp_callback, (os_timer_func_t *)udp_callback_func, NULL); - os_timer_arm(&udp_callback, 5, 0); - } else { - udp_countdown = 200*5; - } - } -} - -void ICACHE_FLASH_ATTR wifi_configure(int secure) { - wifi_secure_mode = secure; - - // start wifi AP - wifi_set_opmode(SOFTAP_MODE); - struct softap_config config = {0}; - wifi_softap_get_config(&config); - strcpy(config.ssid, ssid); - if (wifi_secure_mode == 0) strcat(config.ssid, "-pair"); - strcpy(config.password, password); - config.ssid_len = strlen(config.ssid); - config.authmode = wifi_secure_mode ? AUTH_WPA2_PSK : AUTH_OPEN; - config.beacon_interval = 100; - config.max_connection = 4; - wifi_softap_set_config(&config); - - if (wifi_secure_mode) { - // setup tcp server - tcp_proto.local_port = 1337; - tcp_conn.type = ESPCONN_TCP; - tcp_conn.state = ESPCONN_NONE; - tcp_conn.proto.tcp = &tcp_proto; - espconn_regist_connectcb(&tcp_conn, tcp_connect_cb); - espconn_accept(&tcp_conn); - espconn_regist_time(&tcp_conn, 60, 0); // 60s timeout for all connections - - // setup inter server - inter_proto.local_port = 1338; - const char udp_remote_ip[4] = {255, 255, 255, 255}; - os_memcpy(inter_proto.remote_ip, udp_remote_ip, 4); - inter_proto.remote_port = 1338; - - inter_conn.type = ESPCONN_UDP; - inter_conn.proto.udp = &inter_proto; - - espconn_regist_recvcb(&inter_conn, inter_recv_cb); - espconn_create(&inter_conn); - } -} - -void ICACHE_FLASH_ATTR wifi_init() { - // default ssid and password - memset(ssid, 0, 32); - os_sprintf(ssid, "panda-%08x-BROKEN", system_get_chip_id()); - - // fetch secure ssid and password - // update, try 20 times, for 1 second - for (int i = 0; i < 20; i++) { - uint8_t digest[SHA_DIGEST_SIZE]; - char resp[0x20]; - __spi_comm("\x00\x00\x00\x00\x40\xD0\x00\x00\x00\x00\x20\x00", 0xC, recvData, 0x40); - memcpy(resp, recvData+1, 0x20); - - SHA_hash(resp, 0x1C, digest); - if (memcmp(digest, resp+0x1C, 4) == 0) { - // OTP is valid - memcpy(ssid+6, resp, 0x10); - memcpy(password, resp+0x10, 10); - break; - } - os_delay_us(50000); - } - os_printf("Finished getting SID\n"); - os_printf(ssid); - os_printf("\n"); - - // set IP - wifi_softap_dhcps_stop(); //stop DHCP before setting static IP - struct ip_info ip_config; - IP4_ADDR(&ip_config.ip, 192, 168, 0, 10); - IP4_ADDR(&ip_config.gw, 0, 0, 0, 0); - IP4_ADDR(&ip_config.netmask, 255, 255, 255, 0); - wifi_set_ip_info(SOFTAP_IF, &ip_config); - int stupid_gateway = 0; - wifi_softap_set_dhcps_offer_option(OFFER_ROUTER, &stupid_gateway); - wifi_softap_dhcps_start(); - - wifi_configure(0); -} - -#define LOOP_PRIO 2 -#define QUEUE_SIZE 1 -static os_event_t my_queue[QUEUE_SIZE]; -void loop(); - -void ICACHE_FLASH_ATTR web_init(); -void ICACHE_FLASH_ATTR elm327_init(); - -void ICACHE_FLASH_ATTR user_init() { - // init gpio subsystem - gpio_init(); - - // configure UART TXD to be GPIO1, set as output - PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_GPIO1); - gpio_output_set(0, 0, (1 << pin), 0); - - // configure SPI - SpiAttr hSpiAttr; - hSpiAttr.bitOrder = SpiBitOrder_MSBFirst; - hSpiAttr.speed = SpiSpeed_10MHz; - hSpiAttr.mode = SpiMode_Master; - hSpiAttr.subMode = SpiSubMode_0; - - // TODO: is one of these CS? - WRITE_PERI_REG(PERIPHS_IO_MUX, 0x105); - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, 2); // configure io to spi mode - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, 2); // configure io to spi mode - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, 2); // configure io to spi mode - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, 2); // configure io to spi mode - SPIInit(SpiNum_HSPI, &hSpiAttr); - //SPICsPinSelect(SpiNum_HSPI, SpiPinCS_1); - - // configure UART TXD to be GPIO1, set as output - PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO5_U, FUNC_GPIO5); - gpio_output_set(0, 0, (1 << 5), 0); - gpio_output_set((1 << 5), 0, 0, 0); - - // uart init - uart_init(BIT_RATE_115200, BIT_RATE_115200); - - // led init - PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2); - gpio_output_set(0, (1 << pin), (1 << pin), 0); - - os_printf("hello\n"); - - // needs SPI - wifi_init(); - - // support ota upgrades - elm327_init(); - web_init(); - - // set gpio high, so LED is off by default - for (int i = 0; i < 5; i++) { - gpio_output_set(0, (1 << pin), 0, 0); - os_delay_us(50000); - gpio_output_set((1 << pin), 0, 0, 0); - os_delay_us(50000); - } - - // jump to OS - system_os_task(loop, LOOP_PRIO, my_queue, QUEUE_SIZE); - system_os_post(LOOP_PRIO, 0, 0); -} - -void ICACHE_FLASH_ATTR loop(os_event_t *events) { - system_os_post(LOOP_PRIO, 0, 0); -} - diff --git a/panda/boardesp/user_config.h b/panda/boardesp/user_config.h deleted file mode 100644 index e69de29bb2d1d6..00000000000000 diff --git a/panda/boardesp/webserver.c b/panda/boardesp/webserver.c deleted file mode 100644 index b1a514626f6a6e..00000000000000 --- a/panda/boardesp/webserver.c +++ /dev/null @@ -1,380 +0,0 @@ -#include "stdlib.h" -#include "ets_sys.h" -#include "osapi.h" -#include "gpio.h" -#include "mem.h" -#include "os_type.h" -#include "user_interface.h" -#include "espconn.h" -#include "upgrade.h" - -#include "crypto/rsa.h" -#include "crypto/sha.h" - -#include "obj/gitversion.h" -#include "obj/cert.h" - -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#define espconn_send_string(conn, x) espconn_send(conn, x, strlen(x)) - -#define MAX_RESP 0x800 -char resp[MAX_RESP]; -char pageheader[] = "HTTP/1.0 200 OK\nContent-Type: text/html\n\n" -"\n" -"\n" -"\n" -"Panda\n" -"\n" -"\n" -"
This is your comma.ai panda\n\n"
-"It's open source. Find the code here\n";
-
-char pagefooter[] = "
\n" -"\n" -"\n"; - -char OK_header[] = "HTTP/1.0 200 OK\nContent-Type: text/html\n\n"; - -static struct espconn web_conn; -static esp_tcp web_proto; -extern char ssid[]; -extern int wifi_secure_mode; - -char *st_firmware; -int real_content_length, content_length = 0; -char *st_firmware_ptr; -LOCAL os_timer_t ota_reboot_timer; - -#define FIRMWARE_SIZE 503808 - -typedef struct { - uint16_t ep; - uint16_t extra_len; - union { - struct { - uint8_t request_type; - uint8_t request; - uint16_t value; - uint16_t index; - uint16_t length; - } control; - uint8_t data[0x10]; - } u; -} usb_msg; - -int ICACHE_FLASH_ATTR usb_cmd(int ep, int len, int request, - int value, int index, char *data) { - usb_msg usb = {0}; - - usb.ep = ep; - usb.extra_len = (ep == 0) ? 0 : len; - if (ep == 0) { - usb.u.control.request_type = 0xc0; - usb.u.control.request = request; - usb.u.control.value = value; - usb.u.control.index = index; - } else { - memcpy(&usb.u.data, data, usb.extra_len); - } - - uint32_t recv[0x44/4]; - spi_comm(&usb, sizeof(usb), recv, 0x40); - - return recv[0]; -} - - -void ICACHE_FLASH_ATTR st_flash() { - if (st_firmware != NULL) { - // boot mode - os_printf("st_flash: enter boot mode\n"); - st_set_boot_mode(1); - - // echo - os_printf("st_flash: wait for echo\n"); - for (int i = 0; i < 10; i++) { - os_printf(" attempt: %d\n", i); - if (usb_cmd(0, 0, 0xb0, 0, 0, NULL) > 0) break; - } - - // unlock flash - os_printf("st_flash: unlock flash\n"); - usb_cmd(0, 0, 0xb1, 0, 0, NULL); - - // erase sector 1 - os_printf("st_flash: erase sector 1\n"); - usb_cmd(0, 0, 0xb2, 1, 0, NULL); - - if (real_content_length >= 16384) { - // erase sector 2 - os_printf("st_flash: erase sector 2\n"); - usb_cmd(0, 0, 0xb2, 2, 0, NULL); - } - - // real content length will always be 0x10 aligned - os_printf("st_flash: flashing\n"); - for (int i = 0; i < real_content_length; i += 0x10) { - int rl = MIN(0x10, real_content_length-i); - usb_cmd(2, rl, 0, 0, 0, &st_firmware[i]); - system_soft_wdt_feed(); - } - - // reboot into normal mode - os_printf("st_flash: rebooting\n"); - usb_cmd(0, 0, 0xd8, 0, 0, NULL); - - // done with this - os_free(st_firmware); - st_firmware = NULL; - } -} - -typedef enum { - NOT_STARTED, - CONNECTION_ESTABLISHED, - RECEIVING_HEADER, - RECEIVING_ST_FIRMWARE, - RECEIVING_ESP_FIRMWARE, - REBOOTING, - ERROR -} web_state_t; - -web_state_t state = NOT_STARTED; -int esp_address, esp_address_erase_limit, start_address; - -void ICACHE_FLASH_ATTR hexdump(char *data, int len) { - int i; - for (i=0;isecure it"); - } - - ets_strcat(resp,"\nSet USB Mode:" - "" - "" - "\n"); - - ets_strcat(resp, pagefooter); - - espconn_send_string(&web_conn, resp); - espconn_disconnect(conn); - } else if (memcmp(data, "GET /secure", 11) == 0 && !wifi_secure_mode) { - wifi_configure(1); - } else if (memcmp(data, "GET /set_property?usb_mode=", 27) == 0 && wifi_secure_mode) { - char mode_value = data[27] - '0'; - if (mode_value >= '\x00' && mode_value <= '\x02') { - memset(resp, 0, MAX_RESP); - char set_usb_mode_packet[] = "\x00\x00\x00\x00\x40\xE6\x00\x00\x00\x00\x40\x00"; - set_usb_mode_packet[6] = mode_value; - uint32_t recvData[1]; - spi_comm(set_usb_mode_packet, 0xC, recvData, 0); - os_sprintf(resp, "%sUSB Mode set to %02x\n\n", OK_header, mode_value); - espconn_send_string(&web_conn, resp); - espconn_disconnect(conn); - } - } else if (memcmp(data, "PUT /stupdate ", 14) == 0 && wifi_secure_mode) { - os_printf("init st firmware\n"); - char *cl = strstr(data, "Content-Length: "); - if (cl != NULL) { - // get content length - cl += strlen("Content-Length: "); - content_length = skip_atoi(&cl); - os_printf("with content length %d\n", content_length); - - // should be small enough to fit in RAM - real_content_length = (content_length+0xF)&(~0xF); - st_firmware_ptr = st_firmware = os_malloc(real_content_length); - memset(st_firmware, 0, real_content_length); - state = RECEIVING_ST_FIRMWARE; - } - - } else if (((memcmp(data, "PUT /espupdate1 ", 16) == 0) || - (memcmp(data, "PUT /espupdate2 ", 16) == 0)) && wifi_secure_mode) { - // 0x1000 = user1.bin - // 0x81000 = user2.bin - // 0x3FE000 = blank.bin - os_printf("init esp firmware\n"); - char *cl = strstr(data, "Content-Length: "); - if (cl != NULL) { - // get content length - cl += strlen("Content-Length: "); - content_length = skip_atoi(&cl); - os_printf("with content length %d\n", content_length); - - // setup flashing - uint8_t current = system_upgrade_userbin_check(); - if (data[14] == '2' && current == UPGRADE_FW_BIN1) { - os_printf("flashing boot2.bin\n"); - state = RECEIVING_ESP_FIRMWARE; - esp_address = 4*1024 + FIRMWARE_SIZE + 16*1024 + 4*1024; - } else if (data[14] == '1' && current == UPGRADE_FW_BIN2) { - os_printf("flashing boot1.bin\n"); - state = RECEIVING_ESP_FIRMWARE; - esp_address = 4*1024; - } else { - espconn_send_string(&web_conn, "HTTP/1.0 404 Not Found\nContent-Type: text/html\n\nwrong!\n"); - espconn_disconnect(conn); - } - esp_address_erase_limit = esp_address; - start_address = esp_address; - } - } else { - espconn_send_string(&web_conn, "HTTP/1.0 404 Not Found\nContent-Type: text/html\n\n404 Not Found!\n"); - espconn_disconnect(conn); - } - } else if (state == RECEIVING_ST_FIRMWARE) { - os_printf("receiving st firmware: %d/%d\n", len, content_length); - memcpy(st_firmware_ptr, data, MIN(content_length, len)); - st_firmware_ptr += len; - content_length -= len; - - if (content_length <= 0 && real_content_length > 1000) { - state = NOT_STARTED; - os_printf("done!\n"); - espconn_send_string(&web_conn, "HTTP/1.0 200 OK\nContent-Type: text/html\n\nsuccess!\n"); - espconn_disconnect(conn); - - // reboot - os_printf("Scheduling st_flash in 100ms.\n"); - os_timer_disarm(&ota_reboot_timer); - os_timer_setfn(&ota_reboot_timer, (os_timer_func_t *)st_flash, NULL); - os_timer_arm(&ota_reboot_timer, 100, 0); - } - } else if (state == RECEIVING_ESP_FIRMWARE) { - if ((esp_address+len) < (start_address + FIRMWARE_SIZE)) { - os_printf("receiving esp firmware: %d/%d -- 0x%x - 0x%x\n", len, content_length, - esp_address, esp_address_erase_limit); - content_length -= len; - while (esp_address_erase_limit < (esp_address + len)) { - os_printf("erasing 0x%X\n", esp_address_erase_limit); - spi_flash_erase_sector(esp_address_erase_limit / SPI_FLASH_SEC_SIZE); - esp_address_erase_limit += SPI_FLASH_SEC_SIZE; - } - SpiFlashOpResult res = spi_flash_write(esp_address, data, len); - if (res != SPI_FLASH_RESULT_OK) { - os_printf("flash fail @ 0x%x\n", esp_address); - } - esp_address += len; - - if (content_length == 0) { - - char digest[SHA_DIGEST_SIZE]; - uint32_t rsa[RSANUMBYTES/4]; - uint32_t dat[0x80/4]; - int ll; - spi_flash_read(esp_address-RSANUMBYTES, rsa, RSANUMBYTES); - - // 32-bit aligned accesses only - SHA_CTX ctx; - SHA_init(&ctx); - for (ll = start_address; ll < esp_address-RSANUMBYTES; ll += 0x80) { - spi_flash_read(ll, dat, 0x80); - SHA_update(&ctx, dat, MIN((esp_address-RSANUMBYTES)-ll, 0x80)); - } - memcpy(digest, SHA_final(&ctx), SHA_DIGEST_SIZE); - - if (RSA_verify(&releaseesp_rsa_key, rsa, RSANUMBYTES, digest, SHA_DIGEST_SIZE) || - #ifdef ALLOW_DEBUG - RSA_verify(&debugesp_rsa_key, rsa, RSANUMBYTES, digest, SHA_DIGEST_SIZE) - #else - false - #endif - ) { - os_printf("RSA verify success!\n"); - espconn_send_string(&web_conn, "HTTP/1.0 200 OK\nContent-Type: text/html\n\nsuccess!\n"); - system_upgrade_flag_set(UPGRADE_FLAG_FINISH); - - // reboot - os_printf("Scheduling reboot.\n"); - os_timer_disarm(&ota_reboot_timer); - os_timer_setfn(&ota_reboot_timer, (os_timer_func_t *)system_upgrade_reboot, NULL); - os_timer_arm(&ota_reboot_timer, 2000, 0); - } else { - os_printf("RSA verify FAILURE\n"); - espconn_send_string(&web_conn, "HTTP/1.0 500 Internal Server Error\nContent-Type: text/html\n\nrsa verify fail\n"); - } - espconn_disconnect(conn); - } - } - } -} - -void ICACHE_FLASH_ATTR web_tcp_connect_cb(void *arg) { - state = CONNECTION_ESTABLISHED; - struct espconn *conn = (struct espconn *)arg; - espconn_set_opt(&web_conn, ESPCONN_NODELAY); - espconn_regist_recvcb(conn, web_rx_cb); -} - -void ICACHE_FLASH_ATTR web_init() { - web_proto.local_port = 80; - web_conn.type = ESPCONN_TCP; - web_conn.state = ESPCONN_NONE; - web_conn.proto.tcp = &web_proto; - espconn_regist_connectcb(&web_conn, web_tcp_connect_cb); - espconn_accept(&web_conn); -} - diff --git a/panda/buy.png b/panda/buy.png deleted file mode 100644 index a4a9e0fd40a426..00000000000000 Binary files a/panda/buy.png and /dev/null differ diff --git a/panda/certs/debugesp b/panda/certs/debugesp deleted file mode 100644 index 789beaac195639..00000000000000 --- a/panda/certs/debugesp +++ /dev/null @@ -1,15 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIICXAIBAAKBgQCjIHvrSCWN0Nec6ozbImYik30PIF7JSWgdwDKTxSJ05RM3pj5E -LQEGt3qcaVrTokO68tpt5Gu1p6ZsNqWg7iVTW9M7Qj7IH45YDzQP/PSRjgSosQA6 -6f5Gokba5QrW38myqimvj+0p+YH+CNGCBRlTUQGCO8uLCspMZneRSLPW9QIDAQAB -AoGADaUn+HRef9BaWMvd4G6uMHI54cwJYbj8NpDfKjExQqnuw5bqWnWRQmiSnwbJ -DC7kj3zE/LBAuj890ot3q1CAWqh47ZICZfoX9Qbi5TpvIHFCGy6YkOliF6iIQhR2 -4+zNKTAA0zNKskOM25PdI+grK1Ni/bEofSA6TrqvEwsmxnkCQQDVp9FUUor2Bo/h -/3oAIP51LTw7vfpztYbJr+BDV63czV2DLXzSwzeNrwH4sA3oy1mjUgMBBgAarNGE -DYlc4H5jAkEAw3UCHzzXPlxkw2QGp7nBly5y3p80Uqc31NuYz8rdX/U8KTngi2No -Ft/SGCEXNpeYbToj+WK3RJJ2Ey0mK8+IxwJAcpGd/5CPsaQNLcw4WK9Yo+8Q2Jxk -G/4gfDCSmqn+smNxnLEcuUwzkwdgkEGgA9BfjeOhdsAH+EXpx90WZrZ/LwJBAK0k -jq+rTqUQZbZsejTEKYjJ/bnV4BzDwoKN0Q1pkLc7X4LJoW74rTFuLgdv8MdMfRtt -IIb/eoeFEpGkMicnHesCQHgR7BTUGBM6Uxam7RCdsgVsxoHBma21E/44ivWUMZzN -3oVt0mPnjS4speOlqwED5pCJ7yw7jwLPFMs8kNxuIKU= ------END RSA PRIVATE KEY----- diff --git a/panda/certs/debugesp.pub b/panda/certs/debugesp.pub deleted file mode 100644 index 3afcf3988ea651..00000000000000 --- a/panda/certs/debugesp.pub +++ /dev/null @@ -1 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCjIHvrSCWN0Nec6ozbImYik30PIF7JSWgdwDKTxSJ05RM3pj5ELQEGt3qcaVrTokO68tpt5Gu1p6ZsNqWg7iVTW9M7Qj7IH45YDzQP/PSRjgSosQA66f5Gokba5QrW38myqimvj+0p+YH+CNGCBRlTUQGCO8uLCspMZneRSLPW9Q== batman@y840 diff --git a/panda/certs/releaseesp.pub b/panda/certs/releaseesp.pub deleted file mode 100644 index 1d1d54bb7e73f4..00000000000000 --- a/panda/certs/releaseesp.pub +++ /dev/null @@ -1 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDN4pVyGuJJSde1l3Fjay8qPxog09DsAJZtYPk+armoYO1L6YKReUTcMNyHQYZZMZFmhCdgjCgTIF2QYWMoP4KSe8l6JF04YPP51dIgefc6UXjtlSI8Pyutr0v9xXjSfsVm3RAJxDSHgzs9AoMsluKCL+LhAR1nd7cuHXITJ80O4w== batman@y840 diff --git a/panda/crypto/getcertheader.py b/panda/crypto/getcertheader.py index 75d04e977ad8c1..a43bc02ebac908 100755 --- a/panda/crypto/getcertheader.py +++ b/panda/crypto/getcertheader.py @@ -1,6 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys -import struct from Crypto.PublicKey import RSA def egcd(a, b): @@ -11,7 +10,7 @@ def egcd(a, b): return (g, x - (b // a) * y, y) def modinv(a, m): - g, x, y = egcd(a, m) + g, x, _ = egcd(a, m) if g != 1: raise Exception('modular inverse does not exist') else: @@ -19,15 +18,15 @@ def modinv(a, m): def to_c_string(x): mod = (hex(x)[2:-1].rjust(0x100, '0')) - hh = ''.join('\\x'+mod[i:i+2] for i in range(0, 0x100, 2)) + hh = ''.join('\\x' + mod[i:i + 2] for i in range(0, 0x100, 2)) return hh def to_c_uint32(x): nums = [] - for i in range(0x20): - nums.append(x%(2**32)) - x /= (2**32) - return "{"+'U,'.join(map(str, nums))+"U}" + for _ in range(0x20): + nums.append(x % (2**32)) + x //= (2**32) + return "{" + 'U,'.join(map(str, nums)) + "U}" for fn in sys.argv[1:]: rsa = RSA.importKey(open(fn).read()) @@ -36,11 +35,9 @@ def to_c_uint32(x): cname = fn.split("/")[-1].split(".")[0] + "_rsa_key" - print 'RSAPublicKey '+cname+' = {.len = 0x20,' - print ' .n0inv = %dU,' % n0inv - print ' .n = %s,' % to_c_uint32(rsa.n) - print ' .rr = %s,' % to_c_uint32(rr) - print ' .exponent = %d,' % rsa.e - print '};' - - + print('RSAPublicKey ' + cname + ' = {.len = 0x20,') + print(' .n0inv = %dU,' % n0inv) + print(' .n = %s,' % to_c_uint32(rsa.n)) + print(' .rr = %s,' % to_c_uint32(rr)) + print(' .exponent = %d,' % rsa.e) + print('};') diff --git a/panda/crypto/sign.py b/panda/crypto/sign.py index 159299271e91e0..e199a6b148137c 100755 --- a/panda/crypto/sign.py +++ b/panda/crypto/sign.py @@ -1,29 +1,36 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import os import sys import struct import hashlib from Crypto.PublicKey import RSA +import binascii + +# increment this to make new hardware not run old versions +VERSION = 2 rsa = RSA.importKey(open(sys.argv[3]).read()) -with open(sys.argv[1]) as f: +with open(sys.argv[1], "rb") as f: dat = f.read() -print "signing", len(dat), "bytes" +print("signing", len(dat), "bytes") with open(sys.argv[2], "wb") as f: if os.getenv("SETLEN") is not None: + # add the version at the end + dat += b"VERS" + struct.pack("I", VERSION) + # add the length at the beginning x = struct.pack("I", len(dat)) + dat[4:] # mock signature of dat[4:] dd = hashlib.sha1(dat[4:]).digest() else: x = dat dd = hashlib.sha1(dat).digest() - print "hash:",dd.encode("hex") - dd = "\x00\x01" + "\xff"*0x69 + "\x00" + dd - rsa_out = pow(int(dd.encode("hex"), 16), rsa.d, rsa.n) - sig = (hex(rsa_out)[2:-1].rjust(0x100, '0')).decode("hex") - x += sig - f.write(x) + print("hash:", str(binascii.hexlify(dd), "utf-8")) + dd = b"\x00\x01" + b"\xff" * 0x69 + b"\x00" + dd + rsa_out = pow(int.from_bytes(dd, byteorder='big', signed=False), rsa.d, rsa.n) + sig = (hex(rsa_out)[2:].rjust(0x100, '0')) + x += binascii.unhexlify(sig) + f.write(x) diff --git a/panda/docs/guide.pdf b/panda/docs/guide.pdf deleted file mode 100644 index 5dbc95680aa4f7..00000000000000 Binary files a/panda/docs/guide.pdf and /dev/null differ diff --git a/panda/drivers/linux/.gitignore b/panda/drivers/linux/.gitignore deleted file mode 100644 index 93a6cde7630501..00000000000000 --- a/panda/drivers/linux/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -.*.cmd -*.ko -.tmp_versions -Module.symvers -modules.order -*.mod.c diff --git a/panda/drivers/linux/Makefile b/panda/drivers/linux/Makefile deleted file mode 100644 index e5b1ec4219ea92..00000000000000 --- a/panda/drivers/linux/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -VERSION=0.0.1 -obj-m+=panda.o - -link: - sudo dkms add `pwd` - -build: - sudo dkms build panda/$(VERSION) - -install: - sudo dkms install panda/$(VERSION) - -all: build install - -uninstall: - sudo dkms uninstall panda/$(VERSION) - sudo dkms remove panda/$(VERSION) --all - diff --git a/panda/drivers/linux/README.md b/panda/drivers/linux/README.md deleted file mode 100644 index 81e95523acaca1..00000000000000 --- a/panda/drivers/linux/README.md +++ /dev/null @@ -1,19 +0,0 @@ -Installs the panda linux kernel driver using DKMS. - -This will allow the panda to work with tools such as `can-utils` - -prerequisites: - - `apt-get install dkms gcc linux-headers-$(uname -r) make sudo` - -installation: - - `make link` (only needed the first time. It will report an error on subsequent attempts to link) - - `make all` - - `make install` - -uninstall: - - `make uninstall` - -usage: - -You will need to bring it up using `sudo ifconfig can0 up` or -`sudo ip link set dev can0 up`, depending on your platform. diff --git a/panda/drivers/linux/dkms.conf b/panda/drivers/linux/dkms.conf deleted file mode 100644 index da9cba04a28bb7..00000000000000 --- a/panda/drivers/linux/dkms.conf +++ /dev/null @@ -1,6 +0,0 @@ -PACKAGE_NAME="panda" -PACKAGE_VERSION="0.0.1" -BUILT_MODULE_NAME[0]="panda" -DEST_MODULE_LOCATION[0]="/kernel/drivers/net/panda/" -AUTOINSTALL="yes" - diff --git a/panda/drivers/linux/panda.c b/panda/drivers/linux/panda.c deleted file mode 100644 index 4c5980a9d2ff3c..00000000000000 --- a/panda/drivers/linux/panda.c +++ /dev/null @@ -1,613 +0,0 @@ -/** - * @file panda.c - * @author Jessy Diamond Exum - * @date 16 June 2017 - * @version 0.1 - * @brief Driver for the Comma.ai Panda CAN adapter to allow it to be controlled via - * the Linux SocketCAN interface. - * @see https://github.com/commaai/panda for the full project. - * @see Inspired by net/can/usb/mcba_usb.c from Linux Kernel 4.12-rc4. - */ - -#include -#include -#include -#include // Macros used to mark up functions e.g., __init __exit -#include // Contains types, macros, functions for the kernel -#include // Core header for loading LKMs into the kernel -#include -#include - -/* vendor and product id */ -#define PANDA_MODULE_NAME "panda" -#define PANDA_VENDOR_ID 0XBBAA -#define PANDA_PRODUCT_ID 0XDDCC - -#define PANDA_MAX_TX_URBS 20 -#define PANDA_CTX_FREE PANDA_MAX_TX_URBS - -#define PANDA_USB_RX_BUFF_SIZE 0x40 -#define PANDA_USB_TX_BUFF_SIZE (sizeof(struct panda_usb_can_msg)) - -#define PANDA_NUM_CAN_INTERFACES 3 - -#define PANDA_CAN_TRANSMIT 1 -#define PANDA_CAN_EXTENDED 4 - -#define PANDA_BITRATE 500000 - -#define PANDA_DLC_MASK 0x0F - -struct panda_usb_ctx { - struct panda_inf_priv *priv; - u32 ndx; - u8 dlc; -}; - -struct panda_dev_priv; - -struct panda_inf_priv { - struct can_priv can; - struct panda_usb_ctx tx_context[PANDA_MAX_TX_URBS]; - struct net_device *netdev; - struct usb_anchor tx_submitted; - atomic_t free_ctx_cnt; - u8 interface_num; - u8 mcu_can_ifnum; - struct panda_dev_priv *priv_dev; -}; - -struct panda_dev_priv { - struct usb_device *udev; - struct device *dev; - struct usb_anchor rx_submitted; - struct panda_inf_priv *interfaces[PANDA_NUM_CAN_INTERFACES]; -}; - -struct __packed panda_usb_can_msg { - u32 rir; - u32 bus_dat_len; - u8 data[8]; -}; - -static const struct usb_device_id panda_usb_table[] = { - { USB_DEVICE(PANDA_VENDOR_ID, PANDA_PRODUCT_ID) }, - {} /* Terminating entry */ -}; - -MODULE_DEVICE_TABLE(usb, panda_usb_table); - - -// panda: CAN1 = 0 CAN2 = 1 CAN3 = 4 -const int can_numbering[] = {0,1,4}; - -struct panda_inf_priv * -panda_get_inf_from_bus_id(struct panda_dev_priv *priv_dev, int bus_id){ - int inf_num; - for(inf_num = 0; inf_num < PANDA_NUM_CAN_INTERFACES; inf_num++) - if(can_numbering[inf_num] == bus_id) - return priv_dev->interfaces[inf_num]; - return NULL; -} - -// CTX handling shamlessly ripped from mcba_usb.c linux driver -static inline void panda_init_ctx(struct panda_inf_priv *priv) -{ - int i = 0; - - for (i = 0; i < PANDA_MAX_TX_URBS; i++) { - priv->tx_context[i].ndx = PANDA_CTX_FREE; - priv->tx_context[i].priv = priv; - } - - atomic_set(&priv->free_ctx_cnt, ARRAY_SIZE(priv->tx_context)); -} - -static inline struct panda_usb_ctx *panda_usb_get_free_ctx(struct panda_inf_priv *priv, - struct can_frame *cf) -{ - int i = 0; - struct panda_usb_ctx *ctx = NULL; - - for (i = 0; i < PANDA_MAX_TX_URBS; i++) { - if (priv->tx_context[i].ndx == PANDA_CTX_FREE) { - ctx = &priv->tx_context[i]; - ctx->ndx = i; - ctx->dlc = cf->can_dlc; - - atomic_dec(&priv->free_ctx_cnt); - break; - } - } - - printk("CTX num %d\n", atomic_read(&priv->free_ctx_cnt)); - if (!atomic_read(&priv->free_ctx_cnt)){ - /* That was the last free ctx. Slow down tx path */ - printk("SENDING TOO FAST\n"); - netif_stop_queue(priv->netdev); - } - - return ctx; -} - -/* panda_usb_free_ctx and panda_usb_get_free_ctx are executed by different - * threads. The order of execution in below function is important. - */ -static inline void panda_usb_free_ctx(struct panda_usb_ctx *ctx) -{ - /* Increase number of free ctxs before freeing ctx */ - atomic_inc(&ctx->priv->free_ctx_cnt); - - ctx->ndx = PANDA_CTX_FREE; - - /* Wake up the queue once ctx is marked free */ - netif_wake_queue(ctx->priv->netdev); -} - - - -static void panda_urb_unlink(struct panda_inf_priv *priv) -{ - usb_kill_anchored_urbs(&priv->priv_dev->rx_submitted); - usb_kill_anchored_urbs(&priv->tx_submitted); -} - -static int panda_set_output_enable(struct panda_inf_priv* priv, bool enable){ - return usb_control_msg(priv->priv_dev->udev, - usb_sndctrlpipe(priv->priv_dev->udev, 0), - 0xDC, USB_TYPE_VENDOR | USB_RECIP_DEVICE, - enable ? 0x1337 : 0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); -} - -static void panda_usb_write_bulk_callback(struct urb *urb) -{ - struct panda_usb_ctx *ctx = urb->context; - struct net_device *netdev; - - WARN_ON(!ctx); - - netdev = ctx->priv->netdev; - - /* free up our allocated buffer */ - usb_free_coherent(urb->dev, urb->transfer_buffer_length, - urb->transfer_buffer, urb->transfer_dma); - - if (!netif_device_present(netdev)) - return; - - netdev->stats.tx_packets++; - netdev->stats.tx_bytes += ctx->dlc; - - can_get_echo_skb(netdev, ctx->ndx); - - if (urb->status) - netdev_info(netdev, "Tx URB aborted (%d)\n", urb->status); - - /* Release the context */ - panda_usb_free_ctx(ctx); -} - - -static netdev_tx_t panda_usb_xmit(struct panda_inf_priv *priv, - struct panda_usb_can_msg *usb_msg, - struct panda_usb_ctx *ctx) -{ - struct urb *urb; - u8 *buf; - int err; - - /* create a URB, and a buffer for it, and copy the data to the URB */ - urb = usb_alloc_urb(0, GFP_ATOMIC); - if (!urb) - return -ENOMEM; - - buf = usb_alloc_coherent(priv->priv_dev->udev, - PANDA_USB_TX_BUFF_SIZE, GFP_ATOMIC, - &urb->transfer_dma); - if (!buf) { - err = -ENOMEM; - goto nomembuf; - } - - memcpy(buf, usb_msg, PANDA_USB_TX_BUFF_SIZE); - - usb_fill_bulk_urb(urb, priv->priv_dev->udev, - usb_sndbulkpipe(priv->priv_dev->udev, 3), buf, - PANDA_USB_TX_BUFF_SIZE, panda_usb_write_bulk_callback, - ctx); - - urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; - usb_anchor_urb(urb, &priv->tx_submitted); - - err = usb_submit_urb(urb, GFP_ATOMIC); - if (unlikely(err)) - goto failed; - - /* Release our reference to this URB, the USB core will eventually free it entirely. */ - usb_free_urb(urb); - - return 0; - - failed: - usb_unanchor_urb(urb); - usb_free_coherent(priv->priv_dev->udev, PANDA_USB_TX_BUFF_SIZE, buf, urb->transfer_dma); - - if (err == -ENODEV) - netif_device_detach(priv->netdev); - else - netdev_warn(priv->netdev, "failed tx_urb %d\n", err); - - nomembuf: - usb_free_urb(urb); - - return err; -} - -static void panda_usb_process_can_rx(struct panda_dev_priv *priv_dev, - struct panda_usb_can_msg *msg) -{ - struct can_frame *cf; - struct sk_buff *skb; - int bus_num; - struct panda_inf_priv *priv_inf; - struct net_device_stats *stats; - - bus_num = (msg->bus_dat_len >> 4) & 0xf; - priv_inf = panda_get_inf_from_bus_id(priv_dev, bus_num); - if(!priv_inf){ - printk("Got something on an unused interface %d\n", bus_num); - return; - } - printk("Recv bus %d\n", bus_num); - - stats = &priv_inf->netdev->stats; - //u16 sid; - - if (!netif_device_present(priv_inf->netdev)) - return; - - skb = alloc_can_skb(priv_inf->netdev, &cf); - if (!skb) - return; - - if(msg->rir & PANDA_CAN_EXTENDED){ - cf->can_id = (msg->rir >> 3) | CAN_EFF_FLAG; - }else{ - cf->can_id = (msg->rir >> 21); - } - - // TODO: Handle Remote Frames - //if (msg->dlc & MCBA_DLC_RTR_MASK) - // cf->can_id |= CAN_RTR_FLAG; - - cf->can_dlc = get_can_dlc(msg->bus_dat_len & PANDA_DLC_MASK); - - memcpy(cf->data, msg->data, cf->can_dlc); - - stats->rx_packets++; - stats->rx_bytes += cf->can_dlc; - - netif_rx(skb); -} - -static void panda_usb_read_int_callback(struct urb *urb) -{ - struct panda_dev_priv *priv_dev = urb->context; - int retval; - int pos = 0; - int inf_num; - - switch (urb->status) { - case 0: /* success */ - break; - case -ENOENT: - case -ESHUTDOWN: - return; - default: - dev_info(priv_dev->dev, "Rx URB aborted (%d)\n", urb->status); - goto resubmit_urb; - } - - while (pos < urb->actual_length) { - struct panda_usb_can_msg *msg; - - if (pos + sizeof(struct panda_usb_can_msg) > urb->actual_length) { - dev_err(priv_dev->dev, "format error\n"); - break; - } - - msg = (struct panda_usb_can_msg *)(urb->transfer_buffer + pos); - - panda_usb_process_can_rx(priv_dev, msg); - - pos += sizeof(struct panda_usb_can_msg); - } - - resubmit_urb: - usb_fill_int_urb(urb, priv_dev->udev, - usb_rcvintpipe(priv_dev->udev, 1), - urb->transfer_buffer, PANDA_USB_RX_BUFF_SIZE, - panda_usb_read_int_callback, priv_dev, 5); - - retval = usb_submit_urb(urb, GFP_ATOMIC); - - if (retval == -ENODEV){ - for(inf_num = 0; inf_num < PANDA_NUM_CAN_INTERFACES; inf_num++) - if(priv_dev->interfaces[inf_num]) - netif_device_detach(priv_dev->interfaces[inf_num]->netdev); - }else if (retval) - dev_err(priv_dev->dev, "failed resubmitting read bulk urb: %d\n", retval); -} - - -static int panda_usb_start(struct panda_dev_priv *priv_dev) -{ - int err; - struct urb *urb = NULL; - u8 *buf; - int inf_num; - - for(inf_num = 0; inf_num < PANDA_NUM_CAN_INTERFACES; inf_num++) - panda_init_ctx(priv_dev->interfaces[inf_num]); - - err = usb_set_interface(priv_dev->udev, 0, 1); - if (err) { - dev_err(priv_dev->dev, "Can not set alternate setting to 1, error: %i", err); - return err; - } - - /* create a URB, and a buffer for it */ - urb = usb_alloc_urb(0, GFP_KERNEL); - if (!urb) { - return -ENOMEM; - } - - buf = usb_alloc_coherent(priv_dev->udev, PANDA_USB_RX_BUFF_SIZE, - GFP_KERNEL, &urb->transfer_dma); - if (!buf) { - dev_err(priv_dev->dev, "No memory left for USB buffer\n"); - usb_free_urb(urb); - return -ENOMEM; - } - - usb_fill_int_urb(urb, priv_dev->udev, - usb_rcvintpipe(priv_dev->udev, 1), - buf, PANDA_USB_RX_BUFF_SIZE, - panda_usb_read_int_callback, priv_dev, 5); - urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; - - usb_anchor_urb(urb, &priv_dev->rx_submitted); - - err = usb_submit_urb(urb, GFP_KERNEL); - if (err) { - usb_unanchor_urb(urb); - usb_free_coherent(priv_dev->udev, PANDA_USB_RX_BUFF_SIZE, - buf, urb->transfer_dma); - usb_free_urb(urb); - dev_err(priv_dev->dev, "Failed in start, while submitting urb.\n"); - return err; - } - - /* Drop reference, USB core will take care of freeing it */ - usb_free_urb(urb); - - - return 0; -} - -/* Open USB device */ -static int panda_usb_open(struct net_device *netdev) -{ - struct panda_inf_priv *priv = netdev_priv(netdev); - int err; - - /* common open */ - err = open_candev(netdev); - if (err) - return err; - - //priv->can_speed_check = true; - priv->can.state = CAN_STATE_ERROR_ACTIVE; - - netif_start_queue(netdev); - - return 0; -} - -/* Close USB device */ -static int panda_usb_close(struct net_device *netdev) -{ - struct panda_inf_priv *priv = netdev_priv(netdev); - - priv->can.state = CAN_STATE_STOPPED; - - netif_stop_queue(netdev); - - /* Stop polling */ - panda_urb_unlink(priv); - - close_candev(netdev); - - return 0; -} - -static netdev_tx_t panda_usb_start_xmit(struct sk_buff *skb, - struct net_device *netdev) -{ - struct panda_inf_priv *priv_inf = netdev_priv(netdev); - struct can_frame *cf = (struct can_frame *)skb->data; - struct panda_usb_ctx *ctx = NULL; - struct net_device_stats *stats = &priv_inf->netdev->stats; - int err; - struct panda_usb_can_msg usb_msg = {}; - int bus = priv_inf->mcu_can_ifnum; - - if (can_dropped_invalid_skb(netdev, skb)){ - printk("Invalid CAN packet"); - return NETDEV_TX_OK; - } - - ctx = panda_usb_get_free_ctx(priv_inf, cf); - - //Warning: cargo cult. Can't tell what this is for, but it is - //everywhere and encouraged in the documentation. - can_put_echo_skb(skb, priv_inf->netdev, ctx->ndx); - - if(cf->can_id & CAN_EFF_FLAG){ - usb_msg.rir = cpu_to_le32(((cf->can_id & 0x1FFFFFFF) << 3) | - PANDA_CAN_TRANSMIT | PANDA_CAN_EXTENDED); - }else{ - usb_msg.rir = cpu_to_le32(((cf->can_id & 0x7FF) << 21) | PANDA_CAN_TRANSMIT); - } - usb_msg.bus_dat_len = cpu_to_le32((cf->can_dlc & 0x0F) | (bus << 4)); - - memcpy(usb_msg.data, cf->data, cf->can_dlc); - - //TODO Handle Remote Frames - //if (cf->can_id & CAN_RTR_FLAG) - // usb_msg.dlc |= PANDA_DLC_RTR_MASK; - - netdev_err(netdev, "Received data from socket. canid: %x; len: %d\n", cf->can_id, cf->can_dlc); - - err = panda_usb_xmit(priv_inf, &usb_msg, ctx); - if (err) - goto xmit_failed; - - return NETDEV_TX_OK; - - xmit_failed: - can_free_echo_skb(priv_inf->netdev, ctx->ndx); - panda_usb_free_ctx(ctx); - dev_kfree_skb(skb); - stats->tx_dropped++; - - return NETDEV_TX_OK; -} - -static const struct net_device_ops panda_netdev_ops = { - .ndo_open = panda_usb_open, - .ndo_stop = panda_usb_close, - .ndo_start_xmit = panda_usb_start_xmit, -}; - -static int panda_usb_probe(struct usb_interface *intf, - const struct usb_device_id *id) -{ - struct net_device *netdev; - struct panda_inf_priv *priv_inf; - int err = -ENOMEM; - int inf_num; - struct panda_dev_priv *priv_dev; - struct usb_device *usbdev = interface_to_usbdev(intf); - - priv_dev = kzalloc(sizeof(struct panda_dev_priv), GFP_KERNEL); - if (!priv_dev) { - dev_err(&intf->dev, "Couldn't alloc priv_dev\n"); - return -ENOMEM; - } - priv_dev->udev = usbdev; - priv_dev->dev = &intf->dev; - usb_set_intfdata(intf, priv_dev); - - ////// Interface privs - for(inf_num = 0; inf_num < PANDA_NUM_CAN_INTERFACES; inf_num++){ - netdev = alloc_candev(sizeof(struct panda_inf_priv), PANDA_MAX_TX_URBS); - if (!netdev) { - dev_err(&intf->dev, "Couldn't alloc candev\n"); - goto cleanup_candev; - } - netdev->netdev_ops = &panda_netdev_ops; - netdev->flags |= IFF_ECHO; /* we support local echo */ - - priv_inf = netdev_priv(netdev); - priv_inf->netdev = netdev; - priv_inf->priv_dev = priv_dev; - priv_inf->interface_num = inf_num; - priv_inf->mcu_can_ifnum = can_numbering[inf_num]; - - init_usb_anchor(&priv_dev->rx_submitted); - init_usb_anchor(&priv_inf->tx_submitted); - - /* Init CAN device */ - priv_inf->can.state = CAN_STATE_STOPPED; - priv_inf->can.bittiming.bitrate = PANDA_BITRATE; - - SET_NETDEV_DEV(netdev, &intf->dev); - - err = register_candev(netdev); - if (err) { - netdev_err(netdev, "couldn't register PANDA CAN device: %d\n", err); - free_candev(priv_inf->netdev); - goto cleanup_candev; - } - - priv_dev->interfaces[inf_num] = priv_inf; - } - - err = panda_usb_start(priv_dev); - if (err) { - dev_err(&intf->dev, "Failed to initialize Comma.ai Panda CAN controller\n"); - goto cleanup_candev; - } - - err = panda_set_output_enable(priv_inf, true); - if (err) { - dev_info(&intf->dev, "Failed to initialize send enable message to Panda.\n"); - goto cleanup_candev; - } - - dev_info(&intf->dev, "Comma.ai Panda CAN controller connected\n"); - - return 0; - - cleanup_candev: - for(inf_num = 0; inf_num < PANDA_NUM_CAN_INTERFACES; inf_num++){ - priv_inf = priv_dev->interfaces[inf_num]; - if(priv_inf){ - unregister_candev(priv_inf->netdev); - free_candev(priv_inf->netdev); - }else - break; - } - - kfree(priv_dev); - - return err; -} - -/* Called by the usb core when driver is unloaded or device is removed */ -static void panda_usb_disconnect(struct usb_interface *intf) -{ - struct panda_dev_priv *priv_dev = usb_get_intfdata(intf); - struct panda_inf_priv *priv_inf; - int inf_num; - - usb_set_intfdata(intf, NULL); - - for(inf_num = 0; inf_num < PANDA_NUM_CAN_INTERFACES; inf_num++){ - priv_inf = priv_dev->interfaces[inf_num]; - if(priv_inf){ - netdev_info(priv_inf->netdev, "device disconnected\n"); - unregister_candev(priv_inf->netdev); - free_candev(priv_inf->netdev); - }else - break; - } - - panda_urb_unlink(priv_inf); - kfree(priv_dev); -} - -static struct usb_driver panda_usb_driver = { - .name = PANDA_MODULE_NAME, - .probe = panda_usb_probe, - .disconnect = panda_usb_disconnect, - .id_table = panda_usb_table, -}; - -module_usb_driver(panda_usb_driver); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Jessy Diamond Exum "); -MODULE_DESCRIPTION("SocketCAN driver for Comma.ai's Panda Adapter."); -MODULE_VERSION("0.1"); diff --git a/panda/drivers/linux/test/Makefile b/panda/drivers/linux/test/Makefile deleted file mode 100644 index c73945e4cd0702..00000000000000 --- a/panda/drivers/linux/test/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -all: - gcc main.c -o cantest -pthread -lpthread diff --git a/panda/drivers/linux/test/main.c b/panda/drivers/linux/test/main.c deleted file mode 100644 index 1f44efc76e20a7..00000000000000 --- a/panda/drivers/linux/test/main.c +++ /dev/null @@ -1,120 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -const char *ifname = "can0"; - -static unsigned char payload[] = {0xAA, 0xAA, 0xAA, 0xAA, 0x07, 0x00, 0x00, 0x00}; -int packet_len = 8; -int dir = 0; - -void *write_thread( void *dat ){ - int nbytes; - struct can_frame frame; - int s = *((int*) dat); - - while(1){ - for(int i = 0; i < 1; i ++){ - if(packet_len % 2){ - frame.can_id = 0x8AA | CAN_EFF_FLAG; - }else{ - frame.can_id = 0xAA; - } - - frame.can_dlc = packet_len; - memcpy(frame.data, payload, frame.can_dlc); - - nbytes = write(s, &frame, sizeof(struct can_frame)); - - printf("Wrote %d bytes; addr: %lx; datlen: %d\n", nbytes, frame.can_id, frame.can_dlc); - - if(dir){ - packet_len++; - if(packet_len >= 8) - dir = 0; - }else{ - packet_len--; - if(packet_len <= 0) - dir = 1; - } - } - sleep(2); - } -} - - -int main(void) -{ - pthread_t sndthread; - int err, s, nbytes; - struct sockaddr_can addr; - struct can_frame frame; - struct ifreq ifr; - - if((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) { - perror("Error while opening socket"); - return -1; - } - - strcpy(ifr.ifr_name, ifname); - ioctl(s, SIOCGIFINDEX, &ifr); - - addr.can_family = AF_CAN; - addr.can_ifindex = ifr.ifr_ifindex; - - printf("%s at index %d\n", ifname, ifr.ifr_ifindex); - - if(bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) { - perror("Error in socket bind"); - return -2; - } - - /////// Create Write Thread - - err = pthread_create( &sndthread, NULL, write_thread, (void*) &s); - if(err){ - fprintf(stderr,"Error - pthread_create() return code: %d\n", err); - exit(EXIT_FAILURE); - } - - /////// Listen to socket - while (1) { - struct can_frame framein; - - // Read in a CAN frame - int numBytes = read(s, &framein, CANFD_MTU); - switch (numBytes) { - case CAN_MTU: - if(framein.can_id & 0x80000000) - printf("Received %u byte payload; canid 0x%lx (EXT)\n", - framein.can_dlc, framein.can_id & 0x7FFFFFFF); - else - printf("Received %u byte payload; canid 0x%lx\n", framein.can_dlc, framein.can_id); - break; - case CANFD_MTU: - // TODO: Should make an example for CAN FD - break; - case -1: - // Check the signal value on interrupt - //if (EINTR == errno) - // continue; - - // Delay before continuing - sleep(1); - default: - continue; - } - } - - return 0; -} diff --git a/panda/drivers/linux/test/run.sh b/panda/drivers/linux/test/run.sh deleted file mode 100755 index 5301719b497982..00000000000000 --- a/panda/drivers/linux/test/run.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -sudo ifconfig can0 up -make -./cantest diff --git a/panda/drivers/windows/.gitignore b/panda/drivers/windows/.gitignore deleted file mode 100644 index dbe7ad5a91a227..00000000000000 --- a/panda/drivers/windows/.gitignore +++ /dev/null @@ -1,306 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -Debug_x86/ -Debug_x64/ -Release_x86/ -Release_x64/ -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio 2015 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ -**/Properties/launchSettings.json - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Typescript v1 declaration files -typings/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# JetBrains Rider -.idea/ -*.sln.iml - -# CodeRush -.cr/ - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# installer -*.exe diff --git a/panda/drivers/windows/ECUsim CLI/ECUsim CLI.cpp b/panda/drivers/windows/ECUsim CLI/ECUsim CLI.cpp deleted file mode 100644 index 6c8a469acc8566..00000000000000 --- a/panda/drivers/windows/ECUsim CLI/ECUsim CLI.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// ECUsim CLI.cpp : Defines the entry point for the console application. -// - -#include "stdafx.h" -#include "ECUsim DLL\ECUsim.h" - -std::unique_ptr sim; - -BOOL CtrlHandler(DWORD fdwCtrlType) -{ - if (fdwCtrlType != CTRL_C_EVENT) return FALSE; - - sim->stop(); - sim->join(); - - return(TRUE); -} - -int main(int argc, // Number of strings in array argv - char *argv[], // Array of command-line argument strings - char *envp[]) // Array of environment variable strings -{ - - int count; - - // Display each command-line argument. - std::cout << "\nCommand-line arguments:\n"; - for (count = 0; count < argc; count++) - std::cout << " argv[" << count << "] " << argv[count] << "\n"; - - SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE); - - sim.reset(new ECUsim("", 500000)); - sim->join(); - - return 0; -} - diff --git a/panda/drivers/windows/ECUsim CLI/ECUsim CLI.vcxproj b/panda/drivers/windows/ECUsim CLI/ECUsim CLI.vcxproj deleted file mode 100644 index 4b9de8c442828a..00000000000000 --- a/panda/drivers/windows/ECUsim CLI/ECUsim CLI.vcxproj +++ /dev/null @@ -1,178 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {D99E2FCD-21A4-4065-949A-31E34E0E69D1} - Win32Proj - ECUsimCLI - 10.0.16299.0 - - - - Application - true - v141 - Unicode - - - Application - false - v141 - true - Unicode - - - Application - true - v141 - Unicode - - - Application - false - v141 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - true - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - false - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - false - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories);$(SolutionDir) - - - Console - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)ecusim.lib - - - - - Use - Level3 - Disabled - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories);$(SolutionDir) - - - Console - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)ecusim.lib - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories);$(SolutionDir) - - - Console - true - true - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)ecusim.lib - - - - - Level3 - Use - MaxSpeed - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories);$(SolutionDir) - - - Console - true - true - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)ecusim.lib - - - - - - - - - - - Create - Create - Create - Create - - - - - {96e0e646-ee76-444d-9a77-a0cd7f781deb} - - - - - - \ No newline at end of file diff --git a/panda/drivers/windows/ECUsim CLI/ECUsim CLI.vcxproj.filters b/panda/drivers/windows/ECUsim CLI/ECUsim CLI.vcxproj.filters deleted file mode 100644 index ea223e30b23b71..00000000000000 --- a/panda/drivers/windows/ECUsim CLI/ECUsim CLI.vcxproj.filters +++ /dev/null @@ -1,36 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/panda/drivers/windows/ECUsim CLI/stdafx.cpp b/panda/drivers/windows/ECUsim CLI/stdafx.cpp deleted file mode 100644 index d4a23c3cf7b90a..00000000000000 --- a/panda/drivers/windows/ECUsim CLI/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// ECUsim CLI.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/panda/drivers/windows/ECUsim CLI/stdafx.h b/panda/drivers/windows/ECUsim CLI/stdafx.h deleted file mode 100644 index b005a839def248..00000000000000 --- a/panda/drivers/windows/ECUsim CLI/stdafx.h +++ /dev/null @@ -1,15 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#include -#include - - - -// TODO: reference additional headers your program requires here diff --git a/panda/drivers/windows/ECUsim CLI/targetver.h b/panda/drivers/windows/ECUsim CLI/targetver.h deleted file mode 100644 index 87c0086de751ba..00000000000000 --- a/panda/drivers/windows/ECUsim CLI/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/panda/drivers/windows/ECUsim DLL/ECUsim DLL.vcxproj b/panda/drivers/windows/ECUsim DLL/ECUsim DLL.vcxproj deleted file mode 100644 index 93d75c14be1c7a..00000000000000 --- a/panda/drivers/windows/ECUsim DLL/ECUsim DLL.vcxproj +++ /dev/null @@ -1,197 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {96E0E646-EE76-444D-9A77-A0CD7F781DEB} - Win32Proj - ECUsimDLL - 10.0.16299.0 - - - - DynamicLibrary - true - v141 - Unicode - - - DynamicLibrary - false - v141 - true - Unicode - - - DynamicLibrary - true - v141 - Unicode - - - DynamicLibrary - false - v141 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - ecusim - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - true - ecusim - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - false - ecusim - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - false - ecusim - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;ECUSIMDLL_EXPORTS;%(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories);$(SolutionDir) - - - Windows - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib - - - - - Use - Level3 - Disabled - _DEBUG;_WINDOWS;_USRDLL;ECUSIMDLL_EXPORTS;%(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories);$(SolutionDir) - - - Windows - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;ECUSIMDLL_EXPORTS;%(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories);$(SolutionDir) - - - Windows - true - true - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib - - - - - Level3 - Use - MaxSpeed - true - true - NDEBUG;_WINDOWS;_USRDLL;ECUSIMDLL_EXPORTS;%(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories);$(SolutionDir) - - - Windows - true - true - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib - - - - - - - - - - - false - - - false - - - false - - - false - - - - - - Create - Create - Create - Create - - - - - {5528aefb-638d-49af-b9d4-965154e7d531} - - - - - - \ No newline at end of file diff --git a/panda/drivers/windows/ECUsim DLL/ECUsim DLL.vcxproj.filters b/panda/drivers/windows/ECUsim DLL/ECUsim DLL.vcxproj.filters deleted file mode 100644 index 299d654451e182..00000000000000 --- a/panda/drivers/windows/ECUsim DLL/ECUsim DLL.vcxproj.filters +++ /dev/null @@ -1,42 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/panda/drivers/windows/ECUsim DLL/ECUsim.cpp b/panda/drivers/windows/ECUsim DLL/ECUsim.cpp deleted file mode 100644 index 19f2bf360ead9d..00000000000000 --- a/panda/drivers/windows/ECUsim DLL/ECUsim.cpp +++ /dev/null @@ -1,261 +0,0 @@ -#include "stdafx.h" -#include "ECUsim.h" - -ECUsim::ECUsim(std::string sn, unsigned long can_baud, bool ext_addr) : - doloop(TRUE), verbose(TRUE), can11b_enabled(TRUE), can29b_enabled(TRUE), ext_addr(ext_addr){ - this->panda = panda::Panda::openPanda(sn); - this->panda->set_can_speed_cbps(panda::PANDA_CAN1, can_baud / 100); //Don't pass in baud where baud%100 != 0 - this->panda->set_safety_mode(panda::SAFETY_ALLOUTPUT); - this->panda->set_can_loopback(FALSE); - this->panda->can_clear(panda::PANDA_CAN_RX); - - DWORD threadid; - this->thread_can = CreateThread(NULL, 0, _canthreadBootstrap, (LPVOID)this, 0, &threadid); -} - -ECUsim::~ECUsim() { - this->stop(); - this->join(); -} - -void ECUsim::stop() { - this->doloop = FALSE; -} - -void ECUsim::join() { - WaitForSingleObject(this->thread_can, INFINITE); -} - -DWORD WINAPI ECUsim::_canthreadBootstrap(LPVOID This) { - return ((ECUsim*)This)->can_recv_thread_function(); -} - -DWORD ECUsim::can_recv_thread_function() { - while (this->doloop) { - auto msgs = this->panda->can_recv(); - for (auto& msg : msgs) { - if (msg.is_receipt) continue; - if (msg.bus == 0 && !msg.is_receipt /*&& msg.len == 8*/ && msg.dat[0] >= 2) { - if (this->verbose) { - printf("Processing message (bus: %d; addr: %X; 29b: %d):\n ", msg.bus, msg.addr, msg.addr_29b); - for (int i = 0; i < msg.len; i++) printf("%02X ", msg.dat[i]); - printf("\n"); - } - this->_CAN_process_msg(msg); - } else { - if (this->verbose) { - printf("Rejecting message (bus: %d; addr: %X; 29b: %d):\n ", msg.bus, msg.addr, msg.addr_29b); - for (int i = 0; i < msg.len; i++) printf("%02X ", msg.dat[i]); - printf("\n"); - } - } - } - } - - return 0; -} - -BOOL ECUsim::_can_addr_matches(panda::PANDA_CAN_MSG& msg) { - if (this->can11b_enabled && !msg.addr_29b && (msg.addr == 0x7DF || (msg.addr & 0x7F8) == 0x7E0)) { - if (!this->ext_addr) { - return TRUE; - } else { - return msg.len >= 1 && msg.dat[0] == 0x13;//13 is an arbitrary address picked to test ext addresses - } - } - if (this->can29b_enabled && msg.addr_29b && ((msg.addr & 0x1FFF00FF) == 0x18DB00F1 || (msg.addr & 0x1FFF00FF) == 0x18da00f1)) { - if (!this->ext_addr) { - return TRUE; - } else { - return msg.len >= 1 && msg.dat[0] == 0x13;//13 is an arbitrary address picked to test ext addresses - } - } - return FALSE; -} - -void ECUsim::_CAN_process_msg(panda::PANDA_CAN_MSG& msg) { - std::string outmsg; - uint32_t outaddr; - uint8_t formatted_msg_buff[8]; - bool doreply = FALSE; - - if (this->_can_addr_matches(msg)) {// && msg.len == 8) { - uint8_t *dat = (this->ext_addr) ? &msg.dat[1] : &msg.dat[0]; - if ((dat[0] & 0xF0) == 0x10) { - printf("Got a multiframe write request\n"); - outaddr = (msg.addr_29b) ? 0x18DAF1EF : 0x7E8; - this->panda->can_send(outaddr, msg.addr_29b, (const uint8_t*)"\x30\x00\x00", 3, panda::PANDA_CAN1); - return; - } - - /////////// Check if Flow Control Msg - if ((dat[0] & 0xF0) == 0x30 && msg.len >= 3 && this->can_multipart_data.size() > 0) { - if (this->verbose) printf("More data requested\n"); - uint8_t block_size = dat[1], sep_time_min = dat[2]; - outaddr = (msg.addr == 0x7DF || msg.addr == 0x7E0) ? 0x7E8 : 0x18DAF1EF; //ext addr 5th byte is just always 0x13 for simplicity - - unsigned int msgnum = 1; - while (this->can_multipart_data.size()) { - unsigned int datalen = this->ext_addr ? - min(6, this->can_multipart_data.size()): //EXT ADDR VALUE - min(7, this->can_multipart_data.size()); //NORMAL ADDR VALUE - - unsigned int idx = 0; - if (this->ext_addr) - formatted_msg_buff[idx++] = 0x13; //EXT ADDR - formatted_msg_buff[idx++] = 0x20 | msgnum; - for (int i = 0; i < datalen; i++) { - formatted_msg_buff[i + idx] = this->can_multipart_data.front(); - this->can_multipart_data.pop(); - } - for (int i = datalen + idx; i < sizeof(formatted_msg_buff); i++) - formatted_msg_buff[i] = 0; - - if (this->verbose) { - printf("Multipart reply to %X.\n ", outaddr); - for (int i = 0; i < datalen + idx; i++) printf("%02X ", formatted_msg_buff[i]); - printf("\n"); - } - - this->panda->can_send(outaddr, msg.addr_29b, formatted_msg_buff, datalen + idx, panda::PANDA_CAN1); - msgnum = (msgnum + 1) % 0x10; - Sleep(10); - } - return; - } - - /////////// Normal message in - outmsg = this->process_obd_msg(dat[1], dat[2], doreply); - if (doreply) { - outaddr = (msg.addr_29b) ? 0x18DAF1EF : 0x7E8; - - if (outmsg.size() <= (this->ext_addr ? 4 : 5)) { - unsigned int idx = 0; - if(this->ext_addr) - formatted_msg_buff[idx++] = 0x13; //EXT ADDR - formatted_msg_buff[idx++] = outmsg.size() + 2; - formatted_msg_buff[idx++] = 0x40 | dat[1]; - formatted_msg_buff[idx++] = dat[2]; //PID - memcpy_s(&formatted_msg_buff[idx], sizeof(formatted_msg_buff) - idx, outmsg.c_str(), outmsg.size()); - for (int i = idx + outmsg.size(); i < 8; i++) - formatted_msg_buff[i] = 0; - - if (this->verbose) { - printf("Replying to %X.\n ", outaddr); - for (int i = 0; i < 8; i++) printf("%02X ", formatted_msg_buff[i]); - printf("\n"); - } - - this->panda->can_send(outaddr, msg.addr_29b, formatted_msg_buff, 8, panda::PANDA_CAN1); //outmsg.size() + 3 - } else { - uint8_t first_msg_len = this->ext_addr ? - min(2, outmsg.size() % 7) : //EXT ADDR VALUES - min(3, outmsg.size() % 7); //NORMAL ADDR VALUES - uint8_t payload_len = outmsg.size() + 3; - - unsigned int idx = 0; - if (this->ext_addr) - formatted_msg_buff[idx++] = 0x13; //EXT ADDR - formatted_msg_buff[idx++] = 0x10 | ((payload_len >> 8) & 0xF); - formatted_msg_buff[idx++] = payload_len & 0xFF; - formatted_msg_buff[idx++] = 0x40 | dat[1]; - formatted_msg_buff[idx++] = dat[2]; //PID - formatted_msg_buff[idx++] = 1; - memcpy_s(&formatted_msg_buff[idx], sizeof(formatted_msg_buff) - idx, outmsg.c_str(), first_msg_len); - - if (this->verbose) { - printf("Replying FIRST FRAME to %X.\n ", outaddr); - for (int i = 0; i < 8; i++) printf("%02X ", formatted_msg_buff[i]); - printf("\n"); - } - - this->panda->can_send(outaddr, msg.addr_29b, formatted_msg_buff, 8, panda::PANDA_CAN1); - for (int i = first_msg_len; i < outmsg.size(); i++) - this->can_multipart_data.push(outmsg[i]); - } - } - } -} - -std::string ECUsim::process_obd_msg(UCHAR mode, UCHAR pid, bool& return_data) { - std::string tmp; - return_data = TRUE; - - switch (mode) { - case 0x01: // Mode : Show current data - switch (pid) { - case 0x00: //List supported things - return "\xff\xff\xff\xfe"; //b"\xBE\x1F\xB8\x10" #Bitfield, random features - case 0x01: // Monitor Status since DTC cleared - return std::string("\x00\x00\x00\x00", 4); //Bitfield, random features - case 0x04: // Calculated engine load - return "\x2f"; - case 0x05: // Engine coolant temperature - return "\x3c"; - case 0x0B: // Intake manifold absolute pressure - return "\x90"; - case 0x0C: // Engine RPM - return "\x1A\xF8"; - case 0x0D: // Vehicle Speed - return "\x53"; - case 0x10: // MAF air flow rate - return "\x01\xA0"; - case 0x11: // Throttle Position - return "\x90"; - case 0x33: // Absolute Barometric Pressure - return "\x90"; - default: - return_data = FALSE; - return ""; - } - case 0x09: // Mode : Request vehicle information - switch (pid) { - case 0x02: // Show VIN - return "1D4GP00R55B123456"; - case 0xFC: // test long multi message.Ligned up for LIN responses - for (int i = 0; i < 80; i++) { - tmp += "\xAA\xAA"; - } - return tmp;//">BBH", 0xAA, 0xAA, num + 1) - case 0xFD: // test long multi message - for (int i = 0; i < 80; i++) { - tmp += "\xAA\xAA\xAA"; - tmp.push_back(i >> 24); - tmp.push_back((i >> 16) & 0xFF); - tmp.push_back((i >> 8) & 0xFF); - tmp.push_back(i & 0xFF); - } - return "\xAA\xAA\xAA" + tmp; - case 0xFE: // test very long multi message - tmp = "\xAA\xAA\xAA"; - for (int i = 0; i < 584; i++) { - tmp += "\xAA\xAA\xAA"; - tmp.push_back(i >> 24); - tmp.push_back((i >> 16) & 0xFF); - tmp.push_back((i >> 8) & 0xFF); - tmp.push_back(i & 0xFF); - } - return tmp + "\xAA"; - case 0xFF: - for (int i = 0; i < 584; i++) { - tmp += "\xAA\xAA\xAA\xAA\xAA"; - tmp.push_back(((i + 1) >> 8) & 0xFF); - tmp.push_back((i + 1) & 0xFF); - } - return std::string("\xAA\x00\x00", 3) + tmp; - default: - return_data = FALSE; - return ""; - } - case 0x3E: - if (pid == 0) { - return_data = TRUE; - return ""; - } - return_data = FALSE; - return ""; - default: - return_data = FALSE; - return ""; - } -} diff --git a/panda/drivers/windows/ECUsim DLL/ECUsim.h b/panda/drivers/windows/ECUsim DLL/ECUsim.h deleted file mode 100644 index 2f5fe0f7ad4865..00000000000000 --- a/panda/drivers/windows/ECUsim DLL/ECUsim.h +++ /dev/null @@ -1,50 +0,0 @@ -#pragma once - -#include -#include "panda_shared/panda.h" -#include - -// The following ifdef block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the ECUSIMDLL_EXPORTS -// symbol defined on the command line. This symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// ECUSIMDLL_API functions as being imported from a DLL, whereas this DLL sees symbols -// defined with this macro as being exported. -#ifdef ECUSIMDLL_EXPORTS -#define ECUSIMDLL_API __declspec(dllexport) -#else -#define ECUSIMDLL_API __declspec(dllimport) -#endif - -// This class is exported from the ECUsim DLL.dll -class ECUSIMDLL_API ECUsim { -public: - ECUsim(std::string sn, unsigned long can_baud, bool ext_addr = FALSE); - ECUsim(panda::Panda && p, unsigned long can_baud, bool ext_addr = FALSE); - ~ECUsim(); - - void stop(); - void join(); - - // Flag determines if verbose output is enabled - volatile bool verbose; - BOOL ext_addr; -private: - std::unique_ptr panda; - - static DWORD WINAPI _canthreadBootstrap(LPVOID This); - DWORD can_recv_thread_function(); - - BOOL _can_addr_matches(panda::PANDA_CAN_MSG & msg); - - void _CAN_process_msg(panda::PANDA_CAN_MSG & msg); - - std::string process_obd_msg(UCHAR mode, UCHAR pid, bool& return_data); - - HANDLE thread_can; - volatile bool doloop; - std::queue can_multipart_data; - - BOOL can11b_enabled; - BOOL can29b_enabled; -}; diff --git a/panda/drivers/windows/ECUsim DLL/dllmain.cpp b/panda/drivers/windows/ECUsim DLL/dllmain.cpp deleted file mode 100644 index 69b58914b3572b..00000000000000 --- a/panda/drivers/windows/ECUsim DLL/dllmain.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// dllmain.cpp : Defines the entry point for the DLL application. -#include "stdafx.h" - -BOOL APIENTRY DllMain( HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} - diff --git a/panda/drivers/windows/ECUsim DLL/stdafx.cpp b/panda/drivers/windows/ECUsim DLL/stdafx.cpp deleted file mode 100644 index b4056ecd062c0d..00000000000000 --- a/panda/drivers/windows/ECUsim DLL/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// ECUsim DLL.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/panda/drivers/windows/ECUsim DLL/stdafx.h b/panda/drivers/windows/ECUsim DLL/stdafx.h deleted file mode 100644 index f3a07375c76623..00000000000000 --- a/panda/drivers/windows/ECUsim DLL/stdafx.h +++ /dev/null @@ -1,16 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files: -#include - - - -// TODO: reference additional headers your program requires here diff --git a/panda/drivers/windows/ECUsim DLL/targetver.h b/panda/drivers/windows/ECUsim DLL/targetver.h deleted file mode 100644 index 87c0086de751ba..00000000000000 --- a/panda/drivers/windows/ECUsim DLL/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/panda/drivers/windows/README.md b/panda/drivers/windows/README.md deleted file mode 100644 index 06c7a51101914d..00000000000000 --- a/panda/drivers/windows/README.md +++ /dev/null @@ -1,144 +0,0 @@ -``` - ;" ^; ;' ", -______/\\\\\\\\\\\____/\\\\\\\\\_______/\\\\\\\\\\\\\\\______/\\\\\\\\\\_____________/\\\____ ; s$$$$$$$s ; - _____\/////\\\///___/\\\///////\\\____\/\\\///////////_____/\\\///////\\\__________/\\\\\____ , ss$$$$$$$$$$s ,' - _________\/\\\_____\///______\//\\\___\/\\\_______________\///______/\\\_________/\\\/\\\____ ;s$$$$$$$$$$$$$$$ - _________\/\\\_______________/\\\/____\/\\\\\\\\\\\\_____________/\\\//________/\\\/\/\\\____ $$$$$$$$$$$$$$$$$$ - _________\/\\\____________/\\\//______\////////////\\\__________\////\\\_____/\\\/__\/\\\____ $$$$P""Y$$$Y""W$$$$$ - _________\/\\\_________/\\\//____________________\//\\\____________\//\\\__/\\\\\\\\\\\\\\\\_ $$$$ p"$$$"q $$$$$ - __/\\\___\/\\\_______/\\\/____________/\\\________\/\\\___/\\\______/\\\__\///////////\\\//__ $$$$ .$$$$$. $$$$ - _\//\\\\\\\\\_______/\\\\\\\\\\\\\\\_\//\\\\\\\\\\\\\/___\///\\\\\\\\\/_____________\/\\\____ _ $$$$$$$$$$$$$$$$ - __\/////////_______\///////////////___\/////////////_______\/////////_______________\///_____| | "Y$$$"*"$$$Y" - _ __ __ _ _ __ __| | __ _"$b.$$" - | '_ \ / _` | '_ \ / _` |/ _` | - | |_) | (_| | | | | (_| | (_| | - | .__/ \__,_|_| |_|\__,_|\__,_| - | | A comma.ai product. - |_| (Code by Jessy Diamond Exum) -``` - - -# Installing J2534 driver: - -[Download](https://github.com/commaai/panda/files/1742802/panda.J2534.driver.install.zip) - -Depending on what version of windows you are on, you may need to separately install the WinUSB driver (see next section). - -# Installing WinUSB driver: - -Installation automatically happens for Windows 8 and Windows 10 because the panda -firmware contains the USB descriptors necessary to auto-install the WinUSB driver. - -Windows 7 will not auto-install the WinUSB driver. You can use Zadig to install -the WinUSB driver. This software is not tested on anything before 7. - -More details here: -[WinUSB (Winusb.sys) Installation](https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/winusb-installation) -[WCID Devices](https://github.com/pbatard/libwdi/wiki/WCID-Devices) -[Zadig for installing libusb compatible driver](https://github.com/pbatard/libwdi/wiki/Zadig) - -# Using J2534: - -After installing the J2534 drivers for the panda, you can do... nothing. -You first need to get a J2534 client that can load the drivers and talk to -the panda for you. - -A simple tool for testing J2534 drivers is DrewTech's 'J2534-1 Bus Analysis -Tool' available in the 'Other Support Applications' section of their -[Download Page](http://www.drewtech.com/downloads/). - -# What is J2534? - -J2534 is an API that tries to provide a consistent way to send/receive -messages over the many different protocols supported by the OBD II -port. The place this is perhaps most obvious, is sending data over -different protocols (each using unique packetizing methods) using the -same data format. - -For each PassThru Device that should be used with J2534 (in this case, -the panda), a 'driver' has to be written that can be loaded by a -client application wanting to send/receive data. - -A lot of J2534 has good ideas behind it, but the standard has some odd choices: - -* Platform Locked: Requires using the Windows Registry to find installed J2534 libraries/drivers. Drivers have to be DLLs. -* Architecture Locked: So far there is only support for x86. -* No device autodetect, and poor support for selecting from multiple devices. -* Constant vague language about important behavior (small differences between vendors). -* Most common differences become standard in later revisions. - -# Why use J2534 with the panda? - -J2534 is the only interface supported by most professional grade -vehicle diagnostics systems (such as HDS). These tools are useful for -diagnosing vehicles, as well as reverse engineering some lesser known -features. - -# What parts are supported with panda? - -- [ ] **J1850VPW** *(Outdated, and not physically supported by the panda)* -- [ ] **J1850PWM** *(Outdated, and not physically supported by the panda)* -- [X] **CAN** -- [X] **ISO15765** -- [ ] **ISO9141** *(This protocol could be implemented if 5 BAUD init support is added to the panda.)* -- [ ] **ISO14230/KWP2000** *(Could be supported with FAST init, 5baud init if panda adds support for 5bps serial)* - -# Building the Project: - -This project is developed with Visual Studio 2017, the Windows SDK, -and the Windows Driver Kit (WDK). - -The WDK is only required for creating the signed WinUSB inf file. The -WDK may also provide the headers for WinUSB. - -To build all the projects required for the installer, in Visual -Studio, select **Build->Batch Build.** In the project list select: - -- **"panda"** *Release|x86* -- **"panda"** *Release|x64* -- **"panda Driver Package"** Debug|x86 (Note this inf file works with x86/amd64). -- **"pandaJ2534DLL"** *Release|x86* - -The installer is generated with [NullSoft NSIS](http://nsis.sourceforge.net/Main_Page). -Use NSIS to run panda_install.nsi after building all the required projects. - -Before generating the installer, you must go to copy vscruntimeinfo.nsh.sample to -vscruntimeinfo.nsh and follow the instructions to bundle in the Visual Studio C -Runtime required by your version of Visual Studio. Without this runtime, the panda -code will not work, so without this file, the installer will refuse to build. - -# Developing: - -- Edit and merge pandaJ2534DLL\J2534register_x64.reg to register your development J2534 DLL. -- Add your output directory (panda\drivers\windows\Debug_x86) to your system PATH to avoid insanity. - -# ToDo Items: - -- Apply a style-guide and consistent naming convention for Classes/Functions/Variables. -- Send multiple messages (each with a different address) from a given connection at the same time. -- Implement ISO14230/KWP2000 FAST (LIN communication is already supported with the raw panda USB driver). -- Find more documentation about SW_CAN_PS (Single Wire CAN, aka GMLAN). -- Find example of client using a _PS version of a protocol (PS is pin select, and may support using different CAN buses). - - -# Known Issues: - -- ISO15765 Multi-frame TX: Hardware delays make transmission overshoot - STMIN by several milliseconds. This does not violate the requirements - of STMIN, it just means it is a little slower than it could be. - -- All Tx messages from a single Connection are serialized. This can be - relaxed to allow serialization of messages based on their address - (making multiple queues, effectively one queue per address). - -# Troubleshooting: -troubleshooting: -1. Install DrewTech J2534-1 Bus Analysis Tool -http://www.drewtech.com/downloads/tools/Drew%20Technologies%20Tool%20for%20J2534-1%20API%20v1.07.msi -2. Open DrewTech tool and make sure it shows "panda" as a device listed (this means registry settings are correct) -3. When DrewTech tool attempts to load the driver it will show an error if it fails -4. To figure out why the driver fails to load install Process Monitor and filter by the appropriate process name -https://docs.microsoft.com/en-us/sysinternals/downloads/procmon - -# Other: -Panda head ASCII art by dcau \ No newline at end of file diff --git a/panda/drivers/windows/docs/Message_Size.png b/panda/drivers/windows/docs/Message_Size.png deleted file mode 100644 index 3a20a2ef39fbdf..00000000000000 Binary files a/panda/drivers/windows/docs/Message_Size.png and /dev/null differ diff --git a/panda/drivers/windows/docs/RxBits_defs.jpg b/panda/drivers/windows/docs/RxBits_defs.jpg deleted file mode 100644 index db01f62c95dba3..00000000000000 Binary files a/panda/drivers/windows/docs/RxBits_defs.jpg and /dev/null differ diff --git a/panda/drivers/windows/docs/RxBits_valid.png b/panda/drivers/windows/docs/RxBits_valid.png deleted file mode 100644 index 6f7c4c326d9e0b..00000000000000 Binary files a/panda/drivers/windows/docs/RxBits_valid.png and /dev/null differ diff --git a/panda/drivers/windows/docs/bus_init_signla.png b/panda/drivers/windows/docs/bus_init_signla.png deleted file mode 100644 index 9aa71faa274151..00000000000000 Binary files a/panda/drivers/windows/docs/bus_init_signla.png and /dev/null differ diff --git a/panda/drivers/windows/docs/connection_flags.png b/panda/drivers/windows/docs/connection_flags.png deleted file mode 100644 index dd578a2cb9d7b3..00000000000000 Binary files a/panda/drivers/windows/docs/connection_flags.png and /dev/null differ diff --git a/panda/drivers/windows/docs/iso15765_ioctls.png b/panda/drivers/windows/docs/iso15765_ioctls.png deleted file mode 100644 index 7de4a118e0d11c..00000000000000 Binary files a/panda/drivers/windows/docs/iso15765_ioctls.png and /dev/null differ diff --git a/panda/drivers/windows/docs/message_send.png b/panda/drivers/windows/docs/message_send.png deleted file mode 100644 index 112aab14cb060f..00000000000000 Binary files a/panda/drivers/windows/docs/message_send.png and /dev/null differ diff --git a/panda/drivers/windows/docs/msg_filter_passfail.png b/panda/drivers/windows/docs/msg_filter_passfail.png deleted file mode 100644 index 4a91facb4538fb..00000000000000 Binary files a/panda/drivers/windows/docs/msg_filter_passfail.png and /dev/null differ diff --git a/panda/drivers/windows/docs/other notes.txt b/panda/drivers/windows/docs/other notes.txt deleted file mode 100644 index a066d2646557b1..00000000000000 --- a/panda/drivers/windows/docs/other notes.txt +++ /dev/null @@ -1,347 +0,0 @@ -When using the ISO 15765-4 protocol, only SingleFrame messages can be transmitted without a matching -flow control filter. Also, PCI bytes are transparently added by the API. See PassThruStartMsgFilter -and Appendix A for a discussion of flow control filters. - - - -PassThruReadMsgs -This function reads messages and indications from the receive buffer. All messages and indications shall -be read in the order that they occurred on the bus. If a transmit message generated a loopback message -and TxDone indication, the TxDone indication shall always be queued first. Except for loopback messages -and indications, no messages shall be queued for reception without matching a PASS_FILTER -(for non-ISO 15765) or FLOW_CONTROL filter (for ISO 15765). On ISO 15765, PCI bytes are transparently -removed by the API. If the function is successful, a value of STATUS_NOERROR is returned. - - -PassThruWriteMsgs -Write timeout (in milliseconds). When a value of 0 is specified, the function queues as -many of the specified messages as possible and returns immediately. When a value -greater than 0 is specified, the function will block until the Timeout has expired, an error -has occurred, or the desired number of messages have been transmitted on the vehicle -network. Even if the device can buffer only one packet at a time, this function shall be -able to send an arbitrary number of packets if a Timeout value is supplied. Since the -function returns early if all the messages have been sent, there is normally no penalty for -having a large timeout (several seconds). If the number of messages requested have -been written, the function shall not return ERR_TIMEOUT, even if the timeout value is -zero. - -When an ERR_TIMEOUT is returned, only the number of messages that were sent on -the vehicle network is known. The number of messages queued is unknown. Application -writers should avoid this ambiguity by using a Timeout value large enough to work on -slow devices and networks with arbitration delays. - - - -PassThruStartPeriodicMsg -This function will immediately queue the specified message for transmission, and repeat at the specified -interval. Periodic messages are limited in length to a single frame message of 12 bytes or less, including -header or CAN ID. Periodic messages shall have priority over messages queued with -PassThruWriteMsgs, but periodic messages must not violate bus idle timing parameters (e.g. P3_MIN). -Periodic messages shall generate TxDone indications (ISO 15765) and loopback messages (on any -protocol, if enabled). On ISO 15765, periodic messages can be sent during a multi-frame transmission or -reception. If the function is successful, a value of STATUS_NOERROR is returned. The Pass-Thru -device must support a minimum of ten periodic messages. - -PassThruDisconnect shall delete all periodic messages on that channel. PassThruClose shall delete all -periodic messages on all channels for the device. All periodic messages will be stopped on a -PassThruDisconnect for the associated protocol or a PassThruClose for the device. - - - -PASSTHRUSTARTMSGFILTER -This function starts filtering of incoming messages. If the function is successful, a value of -STATUS_NOERROR is returned. A minimum of ten message filters shall be supported by the interface -for each supported protocol. PassThruDisconnect shall delete all message filters on that channel. - -PassThruClose shall delete all filters on all channels for the device. Pattern and Mask messages shall -follow the protocol formats specified in Section 8. However, only the first twelve (12) bytes, including -header or CAN ID, are used by the filter. ERR_INVALID_MSG shall be returned if the filter length -exceeds 12. Note that this function does not clear any messages that may have been received and -queued before the filter was set. Users are cautioned to consider performing a CLEAR_RX_BUFFER -after starting a message filter to be sure that unwanted frames are purged from any receive buffers. - - - - - - - - -FILTER RELATED STUFF -For all protocols except ISO 15765: -• PASS_FILTERs and BLOCK_FILTERs will be applied to all received messages. They shall not be -applied to indications or loopback messages - -• FLOW_CONTROL_FILTERs must not be used and shall cause the interface to return -ERR_INVALID_FILTER_ID - -• Both pMaskMsg and pPatternMsg must have the same DataSize and TxFlags. Otherwise, the -interface shall return ERR_INVALID_MSG - -• The default filter behavior after PassThruConnect is to block all messages, which means no messages -will be placed in the receive queue until a PASS_FILTER has been set. Messages that match a -PASS_FILTER can still be blocked by a BLOCK_FILTER - -• Figure 16 and Figure 17 show how the message filtering mechanism operates - -For ISO 15765: -• PASS_FILTERs and BLOCK_FILTERs must not be used and shall cause the interface to return -ERR_INVALID_FILTER_ID - -• Filters shall not be applied to indications or loopback messages. When loopback is on, the original -message shall be copied to the receive queue upon the last segment being transmitted on the bus. - -• Non-segmented messages do not need to match a FLOW_CONTROL_FILTER. - -• No segmented messages can be transmitted without matching an appropriate FLOW_CONTROL_FILTER. -An appropriate filter is one in which the pFlowControlMsg CAN ID matches the messages to be -transmitted. Also, the ISO 15765_ADDR_TYPE (reference TxFlags in Section 8.7.3) bits must match. -If that bit is set, the first byte after the CAN IDs (the extended address) -must match too. - -• No message (segmented or unsegmented) shall be received without matching an appropriate -FLOW_CONTROL_FILTER. An appropriate filter is one in which the pPatternMsg CAN ID matches -the incoming message ID. If the ISO 15765_ADDR_TYPE (reference TxFlags in Section 8.7.3) bit is -set in the filter, the first byte after the CAN IDs (the extended address) must match too. - -• All 3 message pointers must have the same DataSize and TxFlags. Otherwise, the interface shall -return ERR_INVALID_MSG. - -• Both the pFlowControlMsg ID and the pPatternMsg ID must be unique (not match any IDs in any other -filters). The only exception is that pPatternMsg can equal pFlowControlMsg to allow for receiving -functionally addressed messages. In this case, only non-segmented messages can be received. - -• See Appendix A for a detailed description of flow control filter usage. - - - - -8.4 Format Checks for Messages Passed to the API -The vendor DLL shall validate all PASSTHRU_MSG structures, and return an ERR_INVALID_MSG in the following cases: -• DataSize violates Min Tx or Max Tx columns in Figure 42 - -• Source address (Data[3]) is different from the Node ID (Ioctl SET_CONFIG, Parameter NODE_ADDRESS) on J1850PWM - -• The header length field is incorrect for the number of bytes in the message on ISO14230 - -• The CAN_29_BIT flag of the message does not match the CAN_29_BIT flag passed to -PassThruConnect, unless the CAN_ID_BOTH bit was set on connect - -The vendor DLL shall return ERR_MSG_PROTOCOL_ID when the ProtocolID field in the message does -not match the Protocol ID specified when opening the channel. - - - -8.5 Conventions for Returning Messages from the API -When returning a message in PassThruReadMsg: -– DataSize shall tell the application how many bytes in the Data array are valid. ExtraDataIndex will be -the (non-zero) index of the last byte of the message. If ExtraDataIndex is not equal to DataSize there -are extra data bytes after the message. If loopback is on, RxStatus must be consulted to tell if the -message came via loopback. - -– DataSize will be in the range shown in the Min Rx and Max Rx columns of Figure 42. If the device -receives a message from the vehicle bus that is too long or too short, the message shall be discarded -with no error. - -– For received messages, ExtraDataIndex shall be equal to DataSize, except when the interface is -returning SAE J1850 PWM IFR bytes. In no case shall ExtraDataIndex be larger than DataSize. - -– When receiving a message on an SAE J1850 PWM channel, the message shall have any IFR bytes -appended. In this case, ExtraDataIndex shall be the index of the first IFR byte, and DataSize shall be -the total length of the original message plus all IFR bytes. For example, if there are two IFR bytes, -DataSize will be incremented by two, and ExtraDataIndex will be DataSize - 2. When loopback is on, -the loopback message shall contain any IFR bytes. - - - -8.6 Conventions for Retuning Indications from the API -When returning an indication in PassThruReadMsg: -– ExtraDataIndex must be zero - -– DataSize shall tell the application how many bytes in the Data array are valid - -– RxStatus must be consulted to determine the indication type (See Section 8.4). - -– A TxDone indication (ISO 15765 only) is generated by the DLL after a SingleFrame message is sent, -or the last frame of a multi-segment transmission is sent. DataSize shall be 4 (or 5 when the message -was using Extended Addressing). Data shall contain the CAN ID (and possible Extended Address) of -the message just sent. If loopback is on, the TxDone indication shall precede the loopback message in -the receive queue. - -– An RxBreak indication (SAE J2610/SCI and SAE J1850VPW only) is generated by the DLL if a break -is received. - -– An RxStart indication is generated by the DLL when starting to receive a message on ISO9141 or -ISO14230, or when receiving the FirstFrame signal of a multi-segment ISO 15765 message. - - - -9.1 Naming of Files -Each vendor will provide a different name implementation of the API DLL and a number of these -implementations could simultaneously reside on the same PC. No vendor shall name its implementation -“J2534.DLL”. All implementations shall have the string “32” suffixed to end of the name of the API DLL to -indicate 32-bit. For example, if the company name is “Vendor X” the name could be VENDRX32.DLL. - -For simplicity, an API DLL shall be named in accordance with the file allocation table (FAT) file system -naming convention (which allows up to eight characters for the file name and three characters for the -extension with no spaces anywhere). Note that, given this criteria, the major name of an API DLL can be -no greater than six characters. The OEM application can determine the name of the appropriate vendor’s -DLL using the Win32 Registry mechanism described in this section. - - - - -A.1 Flow Control Overview -ISO 15765-2 was designed to send blocks of up to 4095 bytes on top of the limited 8-byte payload of raw -CAN frames. If the data is small enough, it can fit in a single frame and be transmitted like a raw CAN -message with additional headers. Otherwise, the block is broken up into segments and becomes a -segmented transmission, generating CAN frames in both directions. For flexibility, the receiver of the -segments can control the rate at which the segments are sent. - -Each transmission is actually part of a conversation between two nodes. There is no discovery -mechanism for conversation partners. Therefore, each desired conversation must be pre-defined on each -side before the conversation can start. Conversations are symmetric, meaning that either side can send a -block of data to the other. A conversation can only have one transfer (in one direction) in progress at a -time. One transfer must complete before the next transfer (in the same or in a different direction) can -start. The device must support multiple transfers at once, as long as each one is part of a different -conversation. Raw CAN frames are not allowed when using ISO15765-2. - -A key feature of a conversation is that each side has a unique CAN ID, and each side uses their unique -CAN ID for all transmissions during the conversation. No other CAN IDs are part of the conversation. -Even though the useful data is only flowing in one direction, both sides are transmitting. One side is -sending the flow control message to pace the segments of data coming from the other side. - -For example, during OBD communication, a pass-thru device and an ECU might have a conversation. -The pass-thru device will use the "Tester1" physical CAN ID ($241), and the first ECU will use the -"ECU1" physical CAN ID ($641). During a multi-segment transfer, both sides will be transmitting using -only their respective IDs. It does not matter if the data is being sent by the ECU or by the Tester, the IDs -remain the same. - -It is important to understand the difference between OBD Requests/Responses and ISO 15765-2 -transfers. The OBD Request is transmitted from the Tester to the ECU using functional addressing. -Because segmented transfer is not possible on functional addresses, the message must fit in a single -frame. The OBD Response is a message from the ECU to the Tester using physical addressing. Unlike -other protocols, the responses are not sequential. In fact, the responses can overlap, as if each ECU -were having a private conversation with the Tester. Some of the responses may fit in a single frame, -while others will require a segmented transfer from the ECU to the tester. - - -A.2 Transmitting a Segmented Message -When PassThruWrite is called, the API will search the list of flow control filters, looking for a -pFlowControlMsg that matches the CAN ID (and possible extended address) of the message being sent. -Upon matching a filter, the pass-thru device will: - -• Start the ISO 15765 transfer by sending a FirstFrame on the bus. The CAN ID of this segment was -specified in both the message and the matching pFlowControlMsg. In our example, this is $241. - -• Wait for a FlowControl frame from the conversation partner. The CAN ID to look for is specified in the -corresponding pPatternMsg. In our example, this is $641. - -• Transmit the message data in ConsecutiveFrames according to the FlowControl frame’s instructions -for BS (BlockSize) and STmin (SeparationTime minimum). Again, the pass-thru device transmits using -CAN ID specified in pFlowControlMsg. In our example, this is $241. - -• Repeat the previous two steps as required. - -• When finished, the pass-thru device will place a TxDone indication in the API receive queue. The data -will contain the CAN ID specified in pFlowControlMsg. In our example, this is $241. - -• If loopback is on, the entire message sent will appear in the API receive queue with the -TX_MSG_TYPE bit set to 1 in RxStatus. The loopback shall not precede the TxDone indication. - -Before any multi-segment transfer can take place, the conversation must be set up on both sides. It’s -assumed that the ECU is already setup. The application is responsible for setting up the pass-thru device. -This setup must be done once (and only once) per conversation. The setup involves a single call to -PassThruStartMsgFilter, with the following parameters: - -A.2.2 Data Transmission -Once the conversation is set up, any number of messages (to the conversation partner) can be -transmitted using PassThruWriteMsg. The interface shall handle all aspects of the transfer, including -pacing (slowing) the transmission to the requirements of the receiver. - -When there are multiple conversations setup, the pass-thru device will search all of the flow control filters -for a matching pFlowControlMsg. If there is no match, the message cannot be sent because the pass- -thru device doesn’t know which partner will be pacing the conversation. - -When doing blocking writes, it is important to pick a timeout long enough to cover entire transfer, even if -the ECU is pacing things slowly. Otherwise PassThruWriteMsg will return with a timeout, even though the -transmission is proceeding normally. - - -A.3 Transmitting an Unsegmented Message -As a special case, transfers that fit in a single frame can be transmitted without setting up a conversation. -This is useful during an OBD Request, which is a functionally addressed message that is broadcast to all -ECUs. This message must be small enough to fit into a single frame (including headers) because it is not -possible to do one segmented transfer to multiple ECUs. - -When using functional addressing for an OBD Request, it is important to remember that there can be no -direct reply. Instead, each ECU will send their OBD Response using physical addressing to their -conversation partner (e.g. ECU1 to Tester1, ECU2 to Tester2) as defined by ISO 15765-4. The OBD -Response may be a segmented transfer, or it may be a single frame. - -In this case, no conversation setup is necessary. The call to PassThruWriteMsg is the same as above, -except that the DataSize must be 7 bytes or less (6 bytes or less if extended addressing is turned on). -The pass-thru device will automatically insert a PCI byte before transmission. - - -A.4 Receiving a Segmented Message -Message reception is asynchronous to the application. When a FirstFrame is seen on the bus, the pass- -thru device will search the list of flow control filters, looking for a pPatternMsg message with the same -CAN ID (and possible extended address) as the FirstFrame. Upon matching a filter, the pass-thru device will: - -• Place an RxStart indication in the API receive queue. This indication has the START_OF_MESSAGE -bit set in RxFlags. The message data will contain the CAN ID of the sender. In our example, this is -$641. DataSize will be 4 bytes (5 with extended addressing), and ExtraDataIndex will be zero. - -• Send a FlowControl frame to the conversation partner. The FlowStatus field shall be set to -ontinueToSend. The CAN ID of this segment comes from the filter’s corresponding -pFlowControlMsg. In our example, this CAN ID is $241. The BS (BlockSize) and STmin -(SeparationTime minimum) parameters default to zero, but can be changed with the SET_CONFIGIoctl. - -• Wait for the conversation partner to send C -onsecutiveFrames containing the actual data. The -partner’s CAN ID is specified in pPatternMsg. In our example, this CAN ID is $641. - -• Repeat as necessary until the entire block has been received. When finished, the pass-thru device will -put the assembled message into the API receive queue. The CAN ID of the assembled message will -be the CAN ID of the sender. In our example, this CAN ID is $641. - -If the FirstFrame does not match any flow control filters, then the message must be ignored by the -device. - -Segmented messages cause the API to generate an RxStart indication. This lets the application know -that the device has started message reception. It may take a while before message reception is -complete, especially if the application has increased BS and STmin. - -Once the transfer is complete, the entire message can be read like on any other protocol. Usually, -applications will call PassThruReadMsg again immediately after getting an RxStart indication. Application -writers should not assume that the complete message will always follow the RxStart indication. If multiple -conversations are setup, indications and messages from other conversations can be received in between -the RxStart indication and the actual message. The parameters for PassThruReadMsg are exactly the -same as in the previous section. The only difference is that the DataSize will be larger and -ExtraDataIndex will be non-zero. - - - -A.5 Receiving an Unsegmented Message -No messages can be received until a conversation is setup. Each conversation setup will receive -messages from exactly one CAN ID (and extended address if present). Because setup is bi-directional, -the same PassThruStartMsgFilter call used for transmission will allow for message reception. - -When a SingleFrame is seen on the bus, the pass-thru device will search the list of flow control filters, -looking for a pPatternMsg message with the same C -AN ID (and possible extended address) as the -SingleFrame. Upon matching a filter, the pass-thru device will strip the PCI byte and queue the packet for -reception. If the SingleFrame does not match a flow control filter, it must be discarded. - -The only difference between the previous cases is that single-frame messages do not generate an -RxStart indication. - - - - - - - - - diff --git a/panda/drivers/windows/docs/read_msg_flags.png b/panda/drivers/windows/docs/read_msg_flags.png deleted file mode 100644 index 6d0a1f87422713..00000000000000 Binary files a/panda/drivers/windows/docs/read_msg_flags.png and /dev/null differ diff --git a/panda/drivers/windows/docs/reginfo.txt b/panda/drivers/windows/docs/reginfo.txt deleted file mode 100644 index 03182832b21fa9..00000000000000 --- a/panda/drivers/windows/docs/reginfo.txt +++ /dev/null @@ -1,2 +0,0 @@ -#32 bit: HKEY_LOCAL_MACHINE\SOFTWARE\PassThruSupport -#64 bit: HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\PassThruSupport diff --git a/panda/drivers/windows/docs/start_msg_filter.png b/panda/drivers/windows/docs/start_msg_filter.png deleted file mode 100644 index 7cb1a7a4c8e742..00000000000000 Binary files a/panda/drivers/windows/docs/start_msg_filter.png and /dev/null differ diff --git a/panda/drivers/windows/docs/start_msg_filter2.png b/panda/drivers/windows/docs/start_msg_filter2.png deleted file mode 100644 index 54063a507427bc..00000000000000 Binary files a/panda/drivers/windows/docs/start_msg_filter2.png and /dev/null differ diff --git a/panda/drivers/windows/docs/start_msg_filter3.png b/panda/drivers/windows/docs/start_msg_filter3.png deleted file mode 100644 index ffc8e34820eec5..00000000000000 Binary files a/panda/drivers/windows/docs/start_msg_filter3.png and /dev/null differ diff --git a/panda/drivers/windows/docs/start_msg_filter4.png b/panda/drivers/windows/docs/start_msg_filter4.png deleted file mode 100644 index 9c21fb014d2349..00000000000000 Binary files a/panda/drivers/windows/docs/start_msg_filter4.png and /dev/null differ diff --git a/panda/drivers/windows/docs/timeout_info.txt b/panda/drivers/windows/docs/timeout_info.txt deleted file mode 100644 index 22cfa2c5d5c8e5..00000000000000 --- a/panda/drivers/windows/docs/timeout_info.txt +++ /dev/null @@ -1,42 +0,0 @@ -From focum information on NI hardware: https://forums.ni.com/t5/Automotive-and-Embedded-Networks/15765-2-with-NI-products/td-p/1454256 - -///////////////////////////////////////////////////////////////////// -Timeout Diag Command is the timeout in milliseconds the master -waits for the response to a diagnostic request message. The default is -1000 ms. - -Timeout FC (Bs) is the timeout in milliseconds the master waits -for a Flow Control frame after sending a First Frame or the last -Consecutive Frame of a block. The default is 250 ms. - -Timeout CF (Cr) is the timeout in milliseconds the master waits -for a Consecutive Frame in a multiframe response. The default is -250 ms. - -Receive Block Size (BS) is the number of Consecutive Frames the -slave sends in one block before waiting for the next Flow Control -frame. A value of 0 (default) means all Consecutive Frames are sent -in one run without interruption. - -Wait Time CF (STmin) defines the minimum time for the slave to -wait between sending two Consecutive Frames of a block. Values -from 0 to 127 are wait times in milliseconds. Values 241 to 249 -(Hex F1 to F9) mean wait times of 100 μs to 900 μs, respectively. -All other values are reserved. The default is 5 ms. - -Max Wait Frames (N_WFTmax) is the maximum number of WAIT -frames the master accepts before terminating the connection. The -default is 10. - - -There are no defined lower limits for these values; you can specify any -value down to 0. However, as you correctly pointed out, the timing is -done by Windows, and will be subject to the jitter introduced by the OS -which can easily be in the order of 10s of milliseconds. It is however -hard to give more accurate numbers as the actual jitter is dependent on -the workload of the computer -///////////////////////////////////////////////////////////////////// - -J2534 04.04 does not appear to have default adjustable parameters for -the timeout related fields. For now, these default values shall be used -in the Panda J2534 implementation. diff --git a/panda/drivers/windows/panda Driver Package/panda Driver Package.vcxproj b/panda/drivers/windows/panda Driver Package/panda Driver Package.vcxproj deleted file mode 100644 index 5b448e96a850f4..00000000000000 --- a/panda/drivers/windows/panda Driver Package/panda Driver Package.vcxproj +++ /dev/null @@ -1,99 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {BD34DB24-F5DC-4992-A74F-05FAF731ABED} - {a1357fe7-03e0-4d61-85f4-09c7ed38c0c1} - v4.5 - 12.0 - $driverCurrentWindowsConfigurationName$ Debug - Win32 - panda_Driver_Package - $(LatestTargetPlatformVersion) - - - - Windows10 - true - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - false - WindowsKernelModeDriver10.0 - Utility - Package - true - - - - - - - - - - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - - - - - - - - - - - - $(KMDF_VERSION_MAJOR).$(KMDF_VERSION_MINOR) - - - - - - - $(KMDF_VERSION_MAJOR).$(KMDF_VERSION_MINOR) - - - - - - \ No newline at end of file diff --git a/panda/drivers/windows/panda Driver Package/panda Driver Package.vcxproj.filters b/panda/drivers/windows/panda Driver Package/panda Driver Package.vcxproj.filters deleted file mode 100644 index b4cf07798166cf..00000000000000 --- a/panda/drivers/windows/panda Driver Package/panda Driver Package.vcxproj.filters +++ /dev/null @@ -1,14 +0,0 @@ - - - - - {8E41214B-6785-4CFE-B992-037D68949A14} - inf;inv;inx;mof;mc; - - - - - Driver Files - - - \ No newline at end of file diff --git a/panda/drivers/windows/panda Driver Package/panda.inf b/panda/drivers/windows/panda Driver Package/panda.inf deleted file mode 100644 index 69390dcbc0616f..00000000000000 Binary files a/panda/drivers/windows/panda Driver Package/panda.inf and /dev/null differ diff --git a/panda/drivers/windows/panda.ico b/panda/drivers/windows/panda.ico deleted file mode 100644 index 593a5cd33cb220..00000000000000 Binary files a/panda/drivers/windows/panda.ico and /dev/null differ diff --git a/panda/drivers/windows/panda.sln b/panda/drivers/windows/panda.sln deleted file mode 100644 index 39c8a63e28d23f..00000000000000 --- a/panda/drivers/windows/panda.sln +++ /dev/null @@ -1,92 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27130.2027 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pandaJ2534DLL", "pandaJ2534DLL\pandaJ2534DLL.vcxproj", "{A2BB18A5-F26B-48D6-BBB5-B83D64473C77}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "panda", "panda\panda.vcxproj", "{5528AEFB-638D-49AF-B9D4-965154E7D531}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "panda_playground", "panda_playground\panda_playground.vcxproj", "{691DB635-C272-4B98-897E-0505B970DCA9}" - ProjectSection(ProjectDependencies) = postProject - {5528AEFB-638D-49AF-B9D4-965154E7D531} = {5528AEFB-638D-49AF-B9D4-965154E7D531} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "panda Driver Package", "panda Driver Package\panda Driver Package.vcxproj", "{BD34DB24-F5DC-4992-A74F-05FAF731ABED}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tests", "pandaJ2534DLL Test\pandaJ2534DLL Test.vcxproj", "{7912F978-B48C-4C5D-8BFD-5D1E22158E47}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ECUsim DLL", "ECUsim DLL\ECUsim DLL.vcxproj", "{96E0E646-EE76-444D-9A77-A0CD7F781DEB}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ECUsim CLI", "ECUsim CLI\ECUsim CLI.vcxproj", "{D99E2FCD-21A4-4065-949A-31E34E0E69D1}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "panda_shared", "panda_shared\panda_shared.vcxitems", "{0C843279-68C7-4679-AE51-9BC463D50D1C}" -EndProject -Global - GlobalSection(SharedMSBuildProjectFiles) = preSolution - panda_shared\panda_shared.vcxitems*{0c843279-68c7-4679-ae51-9bc463d50d1c}*SharedItemsImports = 9 - panda_shared\panda_shared.vcxitems*{5528aefb-638d-49af-b9d4-965154e7d531}*SharedItemsImports = 4 - panda_shared\panda_shared.vcxitems*{a2bb18a5-f26b-48d6-bbb5-b83d64473c77}*SharedItemsImports = 4 - EndGlobalSection - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A2BB18A5-F26B-48D6-BBB5-B83D64473C77}.Debug|x64.ActiveCfg = Debug|Win32 - {A2BB18A5-F26B-48D6-BBB5-B83D64473C77}.Debug|x86.ActiveCfg = Debug|Win32 - {A2BB18A5-F26B-48D6-BBB5-B83D64473C77}.Debug|x86.Build.0 = Debug|Win32 - {A2BB18A5-F26B-48D6-BBB5-B83D64473C77}.Release|x64.ActiveCfg = Release|Win32 - {A2BB18A5-F26B-48D6-BBB5-B83D64473C77}.Release|x86.ActiveCfg = Release|Win32 - {A2BB18A5-F26B-48D6-BBB5-B83D64473C77}.Release|x86.Build.0 = Release|Win32 - {5528AEFB-638D-49AF-B9D4-965154E7D531}.Debug|x64.ActiveCfg = Debug|x64 - {5528AEFB-638D-49AF-B9D4-965154E7D531}.Debug|x64.Build.0 = Debug|x64 - {5528AEFB-638D-49AF-B9D4-965154E7D531}.Debug|x86.ActiveCfg = Debug|Win32 - {5528AEFB-638D-49AF-B9D4-965154E7D531}.Debug|x86.Build.0 = Debug|Win32 - {5528AEFB-638D-49AF-B9D4-965154E7D531}.Release|x64.ActiveCfg = Release|x64 - {5528AEFB-638D-49AF-B9D4-965154E7D531}.Release|x64.Build.0 = Release|x64 - {5528AEFB-638D-49AF-B9D4-965154E7D531}.Release|x86.ActiveCfg = Release|Win32 - {5528AEFB-638D-49AF-B9D4-965154E7D531}.Release|x86.Build.0 = Release|Win32 - {691DB635-C272-4B98-897E-0505B970DCA9}.Debug|x64.ActiveCfg = Debug|x64 - {691DB635-C272-4B98-897E-0505B970DCA9}.Debug|x64.Build.0 = Debug|x64 - {691DB635-C272-4B98-897E-0505B970DCA9}.Debug|x86.ActiveCfg = Debug|Win32 - {691DB635-C272-4B98-897E-0505B970DCA9}.Debug|x86.Build.0 = Debug|Win32 - {691DB635-C272-4B98-897E-0505B970DCA9}.Release|x64.ActiveCfg = Release|x64 - {691DB635-C272-4B98-897E-0505B970DCA9}.Release|x64.Build.0 = Release|x64 - {691DB635-C272-4B98-897E-0505B970DCA9}.Release|x86.ActiveCfg = Release|Win32 - {BD34DB24-F5DC-4992-A74F-05FAF731ABED}.Debug|x64.ActiveCfg = Debug|Win32 - {BD34DB24-F5DC-4992-A74F-05FAF731ABED}.Debug|x86.ActiveCfg = Debug|Win32 - {BD34DB24-F5DC-4992-A74F-05FAF731ABED}.Release|x64.ActiveCfg = Release|Win32 - {BD34DB24-F5DC-4992-A74F-05FAF731ABED}.Release|x86.ActiveCfg = Release|Win32 - {7912F978-B48C-4C5D-8BFD-5D1E22158E47}.Debug|x64.ActiveCfg = Debug|Win32 - {7912F978-B48C-4C5D-8BFD-5D1E22158E47}.Debug|x86.ActiveCfg = Debug|Win32 - {7912F978-B48C-4C5D-8BFD-5D1E22158E47}.Debug|x86.Build.0 = Debug|Win32 - {7912F978-B48C-4C5D-8BFD-5D1E22158E47}.Release|x64.ActiveCfg = Release|Win32 - {7912F978-B48C-4C5D-8BFD-5D1E22158E47}.Release|x86.ActiveCfg = Release|Win32 - {96E0E646-EE76-444D-9A77-A0CD7F781DEB}.Debug|x64.ActiveCfg = Debug|x64 - {96E0E646-EE76-444D-9A77-A0CD7F781DEB}.Debug|x64.Build.0 = Debug|x64 - {96E0E646-EE76-444D-9A77-A0CD7F781DEB}.Debug|x86.ActiveCfg = Debug|Win32 - {96E0E646-EE76-444D-9A77-A0CD7F781DEB}.Debug|x86.Build.0 = Debug|Win32 - {96E0E646-EE76-444D-9A77-A0CD7F781DEB}.Release|x64.ActiveCfg = Release|x64 - {96E0E646-EE76-444D-9A77-A0CD7F781DEB}.Release|x64.Build.0 = Release|x64 - {96E0E646-EE76-444D-9A77-A0CD7F781DEB}.Release|x86.ActiveCfg = Release|Win32 - {D99E2FCD-21A4-4065-949A-31E34E0E69D1}.Debug|x64.ActiveCfg = Debug|x64 - {D99E2FCD-21A4-4065-949A-31E34E0E69D1}.Debug|x64.Build.0 = Debug|x64 - {D99E2FCD-21A4-4065-949A-31E34E0E69D1}.Debug|x86.ActiveCfg = Debug|Win32 - {D99E2FCD-21A4-4065-949A-31E34E0E69D1}.Debug|x86.Build.0 = Debug|Win32 - {D99E2FCD-21A4-4065-949A-31E34E0E69D1}.Release|x64.ActiveCfg = Release|x64 - {D99E2FCD-21A4-4065-949A-31E34E0E69D1}.Release|x64.Build.0 = Release|x64 - {D99E2FCD-21A4-4065-949A-31E34E0E69D1}.Release|x86.ActiveCfg = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {8AF3826E-406A-4F1C-BA80-B4D7FD4B52E1} - EndGlobalSection - GlobalSection(Performance) = preSolution - HasPerformanceSessions = true - EndGlobalSection -EndGlobal diff --git a/panda/drivers/windows/panda/dllmain.cpp b/panda/drivers/windows/panda/dllmain.cpp deleted file mode 100644 index 69b58914b3572b..00000000000000 --- a/panda/drivers/windows/panda/dllmain.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// dllmain.cpp : Defines the entry point for the DLL application. -#include "stdafx.h" - -BOOL APIENTRY DllMain( HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} - diff --git a/panda/drivers/windows/panda/main.cpp b/panda/drivers/windows/panda/main.cpp deleted file mode 100644 index 621c600b8238ae..00000000000000 --- a/panda/drivers/windows/panda/main.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "stdafx.h" - -#include - -LONG __cdecl -_tmain( - LONG Argc, - LPTSTR * Argv - ) -/*++ - -Routine description: - - Sample program that communicates with a USB device using WinUSB - ---*/ -{ - DEVICE_DATA deviceData; - HRESULT hr; - USB_DEVICE_DESCRIPTOR deviceDesc; - BOOL bResult; - BOOL noDevice; - ULONG lengthReceived; - - UNREFERENCED_PARAMETER(Argc); - UNREFERENCED_PARAMETER(Argv); - - // - // Find a device connected to the system that has WinUSB installed using our - // INF - // - hr = OpenDevice(&deviceData, &noDevice); - - if (FAILED(hr)) { - - if (noDevice) { - - printf(_T("Device not connected or driver not installed\n")); - - } else { - - printf(_T("Failed looking for device, HRESULT 0x%x\n"), hr); - } - - return 0; - } - - // - // Get device descriptor - // - bResult = WinUsb_GetDescriptor(deviceData.WinusbHandle, - USB_DEVICE_DESCRIPTOR_TYPE, - 0, - 0, - (PBYTE) &deviceDesc, - sizeof(deviceDesc), - &lengthReceived); - - if (FALSE == bResult || lengthReceived != sizeof(deviceDesc)) { - - printf(_T("Error among LastError %d or lengthReceived %d\n"), - FALSE == bResult ? GetLastError() : 0, - lengthReceived); - CloseDevice(&deviceData); - return 0; - } - - // - // Print a few parts of the device descriptor - // - printf(_T("Device found: VID_%04X&PID_%04X; bcdUsb %04X; path: %s\n"), - deviceDesc.idVendor, - deviceDesc.idProduct, - deviceDesc.bcdUSB, - deviceData.DevicePath); - - CloseDevice(&deviceData); - return 0; -} diff --git a/panda/drivers/windows/panda/panda.ico b/panda/drivers/windows/panda/panda.ico deleted file mode 100644 index ff0e071f54f12f..00000000000000 Binary files a/panda/drivers/windows/panda/panda.ico and /dev/null differ diff --git a/panda/drivers/windows/panda/panda.rc b/panda/drivers/windows/panda/panda.rc deleted file mode 100644 index 88cf9f76780799..00000000000000 Binary files a/panda/drivers/windows/panda/panda.rc and /dev/null differ diff --git a/panda/drivers/windows/panda/panda.vcxproj b/panda/drivers/windows/panda/panda.vcxproj deleted file mode 100644 index 22879c7cae8e2c..00000000000000 --- a/panda/drivers/windows/panda/panda.vcxproj +++ /dev/null @@ -1,189 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {5528AEFB-638D-49AF-B9D4-965154E7D531} - Win32Proj - panda - 10.0.16299.0 - - - - DynamicLibrary - true - v141 - Unicode - - - DynamicLibrary - false - v141 - true - Unicode - - - DynamicLibrary - true - v141 - Unicode - - - DynamicLibrary - false - v141 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - true - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - true - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - false - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - false - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;PANDA_EXPORTS;%(PreprocessorDefinitions) - true - false - - - Windows - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);winusb.lib;setupapi.lib - - - - - Use - Level3 - Disabled - _DEBUG;_WINDOWS;_USRDLL;PANDA_EXPORTS;%(PreprocessorDefinitions) - true - - - Windows - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);winusb.lib;setupapi.lib - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;PANDA_EXPORTS;%(PreprocessorDefinitions) - true - - - Windows - true - true - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);winusb.lib;setupapi.lib - - - - - Level3 - Use - MaxSpeed - true - true - NDEBUG;_WINDOWS;_USRDLL;PANDA_EXPORTS;%(PreprocessorDefinitions) - true - - - Windows - true - true - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);winusb.lib;setupapi.lib - - - - - - - - - false - - - false - - - false - - - false - - - - - Create - Create - Create - Create - - - - - - - - - - - - \ No newline at end of file diff --git a/panda/drivers/windows/panda/panda.vcxproj.filters b/panda/drivers/windows/panda/panda.vcxproj.filters deleted file mode 100644 index afddad6e8b7f97..00000000000000 --- a/panda/drivers/windows/panda/panda.vcxproj.filters +++ /dev/null @@ -1,43 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - - - Resource Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/panda/drivers/windows/panda/resource.h b/panda/drivers/windows/panda/resource.h deleted file mode 100644 index bf006ff4b39308..00000000000000 Binary files a/panda/drivers/windows/panda/resource.h and /dev/null differ diff --git a/panda/drivers/windows/panda/stdafx.cpp b/panda/drivers/windows/panda/stdafx.cpp deleted file mode 100644 index 8793e09b40dfb5..00000000000000 --- a/panda/drivers/windows/panda/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// panda.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/panda/drivers/windows/panda/stdafx.h b/panda/drivers/windows/panda/stdafx.h deleted file mode 100644 index cc3d3b96672b27..00000000000000 --- a/panda/drivers/windows/panda/stdafx.h +++ /dev/null @@ -1,19 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#endif -// Windows Header Files: -#include - -#include -#include -#include -#include diff --git a/panda/drivers/windows/pandaJ2534DLL Test/ECUsim_tests.cpp b/panda/drivers/windows/pandaJ2534DLL Test/ECUsim_tests.cpp deleted file mode 100644 index 8a9161475c90bd..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL Test/ECUsim_tests.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include "stdafx.h" -#include "Loader4.h" -#include "pandaJ2534DLL/J2534_v0404.h" -#include "panda_shared/panda.h" -#include "Timer.h" -#include "ECUsim DLL\ECUsim.h" -#include "TestHelpers.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -namespace pandaWCUsimTest -{ - - TEST_CLASS(ECUsimTests) - { - public: - - TEST_METHOD(ECUsim_ISO15765_SingleFrameTx_29bStandardAddrPad500k) - { - ECUsim sim("", 500000); - auto p = getPanda(500); - - p->can_send(0x18daeff1, TRUE, (const uint8_t*)"\x02\x01\x00", 3, panda::PANDA_CAN1); - auto msg_recv = panda_recv_loop(p, 2); - check_panda_can_msg(msg_recv[0], 0, 0x18daeff1, TRUE, TRUE, std::string("\x02\x01\x00", 3), LINE_INFO()); - check_panda_can_msg(msg_recv[1], 0, 0x18daf1ef, TRUE, FALSE, std::string("\x06\x41\x00\xff\xff\xff\xfe\x00", 8), LINE_INFO()); - } - - TEST_METHOD(ECUsim_ISO15765_SingleFrameTx_29bStandardAddrPad250k) - { - ECUsim sim("", 250000); - auto p = getPanda(250); - - p->can_send(0x18daeff1, TRUE, (const uint8_t*)"\x02\x01\x00", 3, panda::PANDA_CAN1); - auto msg_recv = panda_recv_loop(p, 2); - check_panda_can_msg(msg_recv[0], 0, 0x18daeff1, TRUE, TRUE, std::string("\x02\x01\x00", 3), LINE_INFO()); - check_panda_can_msg(msg_recv[1], 0, 0x18daf1ef, TRUE, FALSE, std::string("\x06""\x41\x00""\xff\xff\xff\xfe""\x00", 8), LINE_INFO()); - } - - TEST_METHOD(ECUsim_ISO15765_SingleFrameTx_29bExtAddrPad500k) - { - ECUsim sim("", 500000, TRUE); - auto p = getPanda(500); - - p->can_send(0x18daeff1, TRUE, (const uint8_t*)"\x13""\x02\x01\x00", 4, panda::PANDA_CAN1); - auto msg_recv = panda_recv_loop(p, 2); - check_panda_can_msg(msg_recv[0], 0, 0x18daeff1, TRUE, TRUE, std::string("\x13""\x02\x01\x00", 4), LINE_INFO()); - check_panda_can_msg(msg_recv[1], 0, 0x18daf1ef, TRUE, FALSE, std::string("\x13""\x06""\x41\x00""\xff\xff\xff\xfe", 8), LINE_INFO()); - } - - TEST_METHOD(ECUsim_ISO15765_MultiFrameTx_29bStandardAddrPad500k) - { - ECUsim sim("", 500000); - auto p = getPanda(500); - - p->can_send(0x18daeff1, TRUE, (const uint8_t*)"\x02\x09\x02", 3, panda::PANDA_CAN1); - auto msg_recv = panda_recv_loop(p, 2); - check_panda_can_msg(msg_recv[0], 0, 0x18daeff1, TRUE, TRUE, std::string("\x02\x09\x02", 3), LINE_INFO()); - check_panda_can_msg(msg_recv[1], 0, 0x18daf1ef, TRUE, FALSE, std::string("\x10\x14""\x49\x02\x01""1D4", 8), LINE_INFO()); - - p->can_send(0x18daeff1, TRUE, (const uint8_t*)"\x30\x00\x00", 3, panda::PANDA_CAN1); - msg_recv = panda_recv_loop(p, 3); - check_panda_can_msg(msg_recv[0], 0, 0x18daeff1, TRUE, TRUE, std::string("\x30\x0\x0", 3), LINE_INFO()); - check_panda_can_msg(msg_recv[1], 0, 0x18daf1ef, TRUE, FALSE, std::string("\x21""GP00R55", 8), LINE_INFO()); - check_panda_can_msg(msg_recv[2], 0, 0x18daf1ef, TRUE, FALSE, std::string("\x22""B123456", 8), LINE_INFO()); - } - - TEST_METHOD(ECUsim_ISO15765_MultiFrameTx_29bExtAddrPad500k) - { - ECUsim sim("", 500000, TRUE); - auto p = getPanda(500); - - p->can_send(0x18daeff1, TRUE, (const uint8_t*)"\x13""\x02\x09\x02", 4, panda::PANDA_CAN1); - auto msg_recv = panda_recv_loop(p, 2); - check_panda_can_msg(msg_recv[0], 0, 0x18daeff1, TRUE, TRUE, std::string("\x13""\x02\x09\x02", 4), LINE_INFO()); - check_panda_can_msg(msg_recv[1], 0, 0x18daf1ef, TRUE, FALSE, std::string("\x13""\x10\x14""\x49\x02\x01""1D", 8), LINE_INFO()); - - p->can_send(0x18daeff1, TRUE, (const uint8_t*)"\x13""\x30\x00\x00", 4, panda::PANDA_CAN1); - msg_recv = panda_recv_loop(p, 4); - check_panda_can_msg(msg_recv[0], 0, 0x18daeff1, TRUE, TRUE, std::string("\x13""\x30\x0\x0", 4), LINE_INFO()); - check_panda_can_msg(msg_recv[1], 0, 0x18daf1ef, TRUE, FALSE, std::string("\x13""\x21""4GP00R", 8), LINE_INFO()); - check_panda_can_msg(msg_recv[2], 0, 0x18daf1ef, TRUE, FALSE, std::string("\x13""\x22""55B123", 8), LINE_INFO()); - check_panda_can_msg(msg_recv[3], 0, 0x18daf1ef, TRUE, FALSE, std::string("\x13""\x23""456", 5), LINE_INFO()); - } - }; - -} \ No newline at end of file diff --git a/panda/drivers/windows/pandaJ2534DLL Test/Loader4.cpp b/panda/drivers/windows/pandaJ2534DLL Test/Loader4.cpp deleted file mode 100644 index f4a0b70fa596c2..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL Test/Loader4.cpp +++ /dev/null @@ -1,240 +0,0 @@ -// Loader4.cpp -// (c) 2005 National Control Systems, Inc. -// Portions (c) 2004 Drew Technologies, Inc. -// Dynamic J2534 v04.04 dll loader for VB - -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to: -// the Free Software Foundation, Inc. -// 51 Franklin Street, Fifth Floor -// Boston, MA 02110-1301, USA - -// National Control Systems, Inc. -// 10737 Hamburg Rd -// Hamburg, MI 48139 -// 810-231-2901 - -// Drew Technologies, Inc. -// 7012 E.M -36, Suite 3B -// Whitmore Lake, MI 48189 -// 810-231-3171 - -#define STRICT -#include "stdafx.h" -#include -#include "Loader4.h" - -PTOPEN LocalOpen; -PTCLOSE LocalClose; -PTCONNECT LocalConnect; -PTDISCONNECT LocalDisconnect; -PTREADMSGS LocalReadMsgs; -PTWRITEMSGS LocalWriteMsgs; -PTSTARTPERIODICMSG LocalStartPeriodicMsg; -PTSTOPPERIODICMSG LocalStopPeriodicMsg; -PTSTARTMSGFILTER LocalStartMsgFilter; -PTSTOPMSGFILTER LocalStopMsgFilter; -PTSETPROGRAMMINGVOLTAGE LocalSetProgrammingVoltage; -PTREADVERSION LocalReadVersion; -PTGETLASTERROR LocalGetLastError; -PTIOCTL LocalIoctl; - -HINSTANCE hDLL = NULL; -//BOOL bIsCorrectVersion = FALSE; - -BOOL WINAPI DllMain(HINSTANCE hInstA, DWORD dwReason, LPVOID lpvReserved) -{ - switch (dwReason) { - case DLL_PROCESS_ATTACH: - // The DLL is being mapped into the process's address space - - case DLL_THREAD_ATTACH: - // A thread is being created - break; - - case DLL_THREAD_DETACH: - // A thread is exiting cleanly - break; - - case DLL_PROCESS_DETACH: - // The DLL is being unmapped from the process's address space - break; - } - - return TRUE; -} - - -long WINAPI LoadJ2534Dll(char *sLib) -{ - long lFuncList = 0; - - if (hDLL != NULL) UnloadJ2534Dll(); - hDLL = LoadLibraryA (sLib); - if (hDLL == NULL) return ERR_NO_DLL; - - LocalOpen = (PTOPEN)(GetProcAddress(hDLL, "PassThruOpen")); - if (LocalOpen == NULL) lFuncList = lFuncList | ERR_NO_PTOPEN; - - LocalClose = (PTCLOSE)(GetProcAddress(hDLL, "PassThruClose")); - if (LocalClose == NULL) lFuncList = lFuncList | ERR_NO_PTCLOSE; - - LocalConnect = (PTCONNECT)(GetProcAddress(hDLL,"PassThruConnect")); - if (LocalConnect == NULL) lFuncList = lFuncList | ERR_NO_PTCONNECT; - - LocalDisconnect = (PTDISCONNECT)(GetProcAddress(hDLL,"PassThruDisconnect")); - if (LocalDisconnect == NULL) lFuncList = lFuncList | ERR_NO_PTDISCONNECT; - - LocalReadMsgs = (PTREADMSGS)(GetProcAddress(hDLL,"PassThruReadMsgs")); - if (LocalReadMsgs == NULL) lFuncList = lFuncList | ERR_NO_PTREADMSGS; - - LocalWriteMsgs = (PTWRITEMSGS)(GetProcAddress(hDLL,"PassThruWriteMsgs")); - if (LocalWriteMsgs == NULL) lFuncList = lFuncList | ERR_NO_PTWRITEMSGS; - - LocalStartPeriodicMsg = (PTSTARTPERIODICMSG)(GetProcAddress(hDLL,"PassThruStartPeriodicMsg")); - if (LocalStartPeriodicMsg == NULL) lFuncList = lFuncList | ERR_NO_PTSTARTPERIODICMSG; - - LocalStopPeriodicMsg = (PTSTOPPERIODICMSG)(GetProcAddress(hDLL,"PassThruStopPeriodicMsg")); - if (LocalStopPeriodicMsg == NULL) lFuncList = lFuncList | ERR_NO_PTSTOPPERIODICMSG; - - LocalStartMsgFilter = (PTSTARTMSGFILTER)(GetProcAddress(hDLL,"PassThruStartMsgFilter")); - if (LocalStartPeriodicMsg == NULL) lFuncList = lFuncList | ERR_NO_PTSTARTMSGFILTER; - - LocalStopMsgFilter = (PTSTOPMSGFILTER)(GetProcAddress(hDLL,"PassThruStopMsgFilter")); - if (LocalStopMsgFilter == NULL) lFuncList = lFuncList | ERR_NO_PTSTOPMSGFILTER; - - LocalSetProgrammingVoltage = (PTSETPROGRAMMINGVOLTAGE)(GetProcAddress(hDLL,"PassThruSetProgrammingVoltage")); - if (LocalSetProgrammingVoltage == NULL) lFuncList = lFuncList | ERR_NO_PTSETPROGRAMMINGVOLTAGE; - - LocalReadVersion = (PTREADVERSION)(GetProcAddress(hDLL,"PassThruReadVersion")); - if (LocalReadVersion == NULL) lFuncList = lFuncList | ERR_NO_PTREADVERSION; - - LocalGetLastError = (PTGETLASTERROR)(GetProcAddress(hDLL,"PassThruGetLastError")); - if (LocalGetLastError == NULL) lFuncList = lFuncList | ERR_NO_PTGETLASTERROR; - - LocalIoctl = (PTIOCTL)(GetProcAddress(hDLL,"PassThruIoctl")); - if (LocalIoctl == NULL) lFuncList = lFuncList | ERR_NO_PTIOCTL; - - if (lFuncList == ERR_NO_FUNCTIONS) return ERR_WRONG_DLL_VER; - - return lFuncList; -} - -long WINAPI UnloadJ2534Dll() -{ - if (FreeLibrary(hDLL)) - { - hDLL = NULL; - LocalOpen = NULL; - LocalClose = NULL; - LocalConnect = NULL; - LocalDisconnect = NULL; - LocalReadMsgs = NULL; - LocalWriteMsgs = NULL; - LocalStartPeriodicMsg = NULL; - LocalStopPeriodicMsg = NULL; - LocalStartMsgFilter = NULL; - LocalStopMsgFilter = NULL; - LocalSetProgrammingVoltage = NULL; - LocalReadVersion = NULL; - LocalGetLastError = NULL; - LocalIoctl = NULL; - return 0; - } - return ERR_NO_DLL; -} - -long WINAPI PassThruOpen(void *pName, unsigned long *pDeviceID) -{ - if (LocalOpen == NULL) return ERR_FUNC_MISSING; - return LocalOpen(pName, pDeviceID); -} - -long WINAPI PassThruClose(unsigned long DeviceID) -{ - if (LocalOpen == NULL) return ERR_FUNC_MISSING; - return LocalClose(DeviceID); -} - -long WINAPI PassThruConnect(unsigned long DeviceID, unsigned long ProtocolID, unsigned long Flags, unsigned long Baudrate, unsigned long *pChannelID) -{ - if (LocalConnect == NULL) return ERR_FUNC_MISSING; - return LocalConnect(DeviceID, ProtocolID, Flags, Baudrate, pChannelID); -} - -long WINAPI PassThruDisconnect(unsigned long ChannelID) -{ - if (LocalDisconnect == NULL) return ERR_FUNC_MISSING; - return LocalDisconnect(ChannelID); -} - -long WINAPI PassThruReadMsgs(unsigned long ChannelID, PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout) -{ - if (LocalReadMsgs == NULL) return ERR_FUNC_MISSING; - return LocalReadMsgs(ChannelID, pMsg, pNumMsgs, Timeout); -} - -long WINAPI PassThruWriteMsgs(unsigned long ChannelID, PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout) -{ - if (LocalWriteMsgs == NULL) return ERR_FUNC_MISSING; - return LocalWriteMsgs(ChannelID, pMsg, pNumMsgs, Timeout); -} - -long WINAPI PassThruStartPeriodicMsg(unsigned long ChannelID, PASSTHRU_MSG *pMsg, unsigned long *pMsgID, unsigned long TimeInterval) -{ - if (LocalStartPeriodicMsg == NULL) return ERR_FUNC_MISSING; - return LocalStartPeriodicMsg(ChannelID, pMsg, pMsgID, TimeInterval); -} - -long WINAPI PassThruStopPeriodicMsg(unsigned long ChannelID, unsigned long MsgID) -{ - if (LocalStopPeriodicMsg == NULL) return ERR_FUNC_MISSING; - return LocalStopPeriodicMsg(ChannelID, MsgID); -} - -long WINAPI PassThruStartMsgFilter(unsigned long ChannelID, unsigned long FilterType, - PASSTHRU_MSG *pMaskMsg, PASSTHRU_MSG *pPatternMsg, PASSTHRU_MSG *pFlowControlMsg, unsigned long *pFilterID) -{ - if (LocalStartMsgFilter == NULL) return ERR_FUNC_MISSING; - return LocalStartMsgFilter(ChannelID, FilterType, pMaskMsg, pPatternMsg, pFlowControlMsg, pFilterID); -} - -long WINAPI PassThruStopMsgFilter(unsigned long ChannelID, unsigned long FilterID) -{ - if (LocalStopMsgFilter == NULL) return ERR_FUNC_MISSING; - return LocalStopMsgFilter(ChannelID, FilterID); -} - -long WINAPI PassThruSetProgrammingVoltage(unsigned long DeviceID, unsigned long PinNumber, unsigned long Voltage) -{ - if (LocalSetProgrammingVoltage == NULL) return ERR_FUNC_MISSING; - return LocalSetProgrammingVoltage(DeviceID, PinNumber, Voltage); -} - -long WINAPI PassThruReadVersion(unsigned long DeviceID, char *pFirmwareVersion, char *pDllVersion, char *pApiVersion) -{ - if (LocalReadVersion == NULL) return ERR_FUNC_MISSING; - return LocalReadVersion(DeviceID, pFirmwareVersion, pDllVersion, pApiVersion); -} - -long WINAPI PassThruGetLastError(char *pErrorDescription) -{ - if (LocalGetLastError == NULL) return ERR_FUNC_MISSING; - return LocalGetLastError(pErrorDescription); -} - -long WINAPI PassThruIoctl(unsigned long ChannelID, unsigned long IoctlID, void *pInput, void *pOutput) -{ - if (LocalIoctl == NULL) return ERR_FUNC_MISSING; - return LocalIoctl(ChannelID, IoctlID, pInput, pOutput); -} \ No newline at end of file diff --git a/panda/drivers/windows/pandaJ2534DLL Test/Loader4.h b/panda/drivers/windows/pandaJ2534DLL Test/Loader4.h deleted file mode 100644 index 9710144141e881..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL Test/Loader4.h +++ /dev/null @@ -1,55 +0,0 @@ -// Loader4.h -// (c) 2005 National Control Systems, Inc. -// Portions (c) 2004 Drew Technologies, Inc. - -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to: -// the Free Software Foundation, Inc. -// 51 Franklin Street, Fifth Floor -// Boston, MA 02110-1301, USA - -// National Control Systems, Inc. -// 10737 Hamburg Rd -// Hamburg, MI 48139 -// 810-231-2901 - -// Drew Technologies, Inc. -// 7012 E.M -36, Suite 3B -// Whitmore Lake, MI 48189 -// 810-231-3171 - -#include "pandaJ2534DLL/J2534_v0404.h" - -//Other Functions -long WINAPI LoadJ2534Dll(char *); -long WINAPI UnloadJ2534Dll(); - -// NCS Returns of any functions not found -#define ERR_NO_PTOPEN 0x0001 -#define ERR_NO_PTCLOSE 0x0002 -#define ERR_NO_PTCONNECT 0x0004 -#define ERR_NO_PTDISCONNECT 0x0008 -#define ERR_NO_PTREADMSGS 0x0010 -#define ERR_NO_PTWRITEMSGS 0x0020 -#define ERR_NO_PTSTARTPERIODICMSG 0x0040 -#define ERR_NO_PTSTOPPERIODICMSG 0x0080 -#define ERR_NO_PTSTARTMSGFILTER 0x0100 -#define ERR_NO_PTSTOPMSGFILTER 0x0200 -#define ERR_NO_PTSETPROGRAMMINGVOLTAGE 0x0400 -#define ERR_NO_PTREADVERSION 0x0800 -#define ERR_NO_PTGETLASTERROR 0x1000 -#define ERR_NO_PTIOCTL 0x2000 -#define ERR_NO_FUNCTIONS 0x3fff -#define ERR_NO_DLL -1 -#define ERR_WRONG_DLL_VER -2 -#define ERR_FUNC_MISSING -3 diff --git a/panda/drivers/windows/pandaJ2534DLL Test/TestHelpers.cpp b/panda/drivers/windows/pandaJ2534DLL Test/TestHelpers.cpp deleted file mode 100644 index 1281eb9d616c43..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL Test/TestHelpers.cpp +++ /dev/null @@ -1,254 +0,0 @@ -#include "stdafx.h" -#include "TestHelpers.h" -#include "Loader4.h" -#include "pandaJ2534DLL/J2534_v0404.h" -#include "panda_shared/panda.h" -#include "Timer.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -void write_ioctl(unsigned int chanid, unsigned int param, unsigned int val, const __LineInfo* pLineInfo) { - SCONFIG config = { param, val }; - SCONFIG_LIST inconfig = { 1, &config }; - - Assert::AreEqual(STATUS_NOERROR, PassThruIoctl(chanid, SET_CONFIG, &inconfig, NULL), _T("Failed to set IOCTL."), pLineInfo); -} - -std::vector panda_recv_loop_loose(std::unique_ptr& p, unsigned int min_num, unsigned long timeout_ms) { - std::vector ret_messages; - Timer t = Timer(); - - while (t.getTimePassed() < timeout_ms) { - Sleep(10); - std::vectormsg_recv = p->can_recv(); - if (msg_recv.size() > 0) { - ret_messages.insert(std::end(ret_messages), std::begin(msg_recv), std::end(msg_recv)); - } - } - - Assert::IsTrue(min_num <= ret_messages.size(), _T("Received too few messages.")); - return ret_messages; -} - -std::vector panda_recv_loop(std::unique_ptr& p, unsigned int num_expected, unsigned long timeout_ms) { - std::vector ret_messages; - Timer t = Timer(); - - while (t.getTimePassed() < timeout_ms) { - Sleep(10); - std::vectormsg_recv = p->can_recv(); - if (msg_recv.size() > 0) { - ret_messages.insert(std::end(ret_messages), std::begin(msg_recv), std::end(msg_recv)); - } - if (ret_messages.size() >= num_expected) break; - } - - std::ostringstream stringStream; - - stringStream << "j2534_recv_loop Broke at " << t.getTimePassed() << " ms size is " << ret_messages.size() << std::endl; - - if (num_expected != ret_messages.size()) { - stringStream << "Incorrect number of messages received. Displaying the messages:" << std::endl; - for (auto msg : ret_messages) { - stringStream << " TS: " << msg.recv_time << "; Dat: "; - for (int i = 0; i < msg.len; i++) stringStream << std::hex << std::setw(2) << std::setfill('0') << int(msg.dat[i] & 0xFF) << " "; - stringStream << std::endl; - } - } - - Logger::WriteMessage(stringStream.str().c_str()); - - Assert::AreEqual(num_expected, ret_messages.size(), _T("Received wrong number of messages.")); - return ret_messages; -} - -void check_panda_can_msg(panda::PANDA_CAN_MSG& msgin, uint8_t bus, unsigned long addr, bool addr_29b, - bool is_receipt, std::string dat, const __LineInfo* pLineInfo) { - Assert::AreEqual(bus, msgin.bus, _T("Wrong msg bus"), pLineInfo); - Assert::AreEqual(addr, msgin.addr, _T("Wrong msg addr"), pLineInfo); - Assert::AreEqual(addr_29b, msgin.addr_29b, _T("Wrong msg 29b flag"), pLineInfo); - Assert::AreEqual(is_receipt, msgin.is_receipt, _T("Wrong msg receipt flag"), pLineInfo); - - std::ostringstream logmsg; - logmsg << "Expected Hex ("; - for (int i = 0; i < dat.size(); i++) logmsg << std::hex << std::setw(2) << std::setfill('0') << int(dat[i] & 0xFF) << " "; - logmsg << "); Actual Hex ("; - for (int i = 0; i < msgin.len; i++) logmsg << std::hex << std::setw(2) << std::setfill('0') << int(((char*)msgin.dat)[i] & 0xFF) << " "; - logmsg << ")"; - Logger::WriteMessage(logmsg.str().c_str()); - - Assert::AreEqual(dat.size(), msgin.len, _T("Wrong msg len"), pLineInfo); - Assert::AreEqual(dat, std::string((char*)msgin.dat, msgin.len), _T("Wrong msg payload"), pLineInfo); -} - -unsigned long J2534_start_periodic_msg_checked(unsigned long chanid, unsigned long ProtocolID, unsigned long TxFlags, unsigned long DataSize, - unsigned long ExtraDataIndex, const char * Data, unsigned long TimeInterval, const __LineInfo * pLineInfo) { - PASSTHRU_MSG msg = { ProtocolID, 0, TxFlags, 0, DataSize, ExtraDataIndex }; - memcpy_s(msg.Data, 4128, Data, DataSize); - unsigned long msgID; - Assert::AreEqual(STATUS_NOERROR, J2534_start_periodic_msg(chanid, ProtocolID, TxFlags, DataSize, - ExtraDataIndex, Data, TimeInterval, &msgID, pLineInfo), _T("Failed to start Periodic Message."), pLineInfo); - return msgID; -} - -unsigned long J2534_start_periodic_msg(unsigned long chanid, unsigned long ProtocolID, unsigned long TxFlags, unsigned long DataSize, - unsigned long ExtraDataIndex, const char * Data, unsigned long TimeInterval, unsigned long* msgID, const __LineInfo * pLineInfo) { - PASSTHRU_MSG msg = { ProtocolID, 0, TxFlags, 0, DataSize, ExtraDataIndex }; - memcpy_s(msg.Data, 4128, Data, DataSize); - return PassThruStartPeriodicMsg(chanid, &msg, msgID, TimeInterval); -} - -void J2534_send_msg_checked(unsigned long chanid, unsigned long ProtocolID, unsigned long RxStatus, unsigned long TxFlags, - unsigned long Timestamp, unsigned long DataSize, unsigned long ExtraDataIndex, const char* Data, const __LineInfo* pLineInfo) { - - PASSTHRU_MSG msg = { ProtocolID, RxStatus, TxFlags, Timestamp, DataSize, ExtraDataIndex }; - memcpy_s(msg.Data, 4128, Data, DataSize); - unsigned long msgcount = 1; - Assert::AreEqual(STATUS_NOERROR, PassThruWriteMsgs(chanid, &msg, &msgcount, 0), _T("Failed to write message."), pLineInfo); - Assert::AreEqual(1, msgcount, _T("Wrong message count after tx."), pLineInfo); -} - -long J2534_send_msg(unsigned long chanid, unsigned long ProtocolID, unsigned long RxStatus, unsigned long TxFlags, - unsigned long Timestamp, unsigned long DataSize, unsigned long ExtraDataIndex, const char* Data) { - - PASSTHRU_MSG msg = { ProtocolID, RxStatus, TxFlags, Timestamp, DataSize, ExtraDataIndex }; - memcpy_s(msg.Data, 4128, Data, DataSize); - unsigned long msgcount = 1; - return PassThruWriteMsgs(chanid, &msg, &msgcount, 0); -} - -//Allow more messages to come in than the min. -std::vector j2534_recv_loop_loose(unsigned int chanid, unsigned int min_num, unsigned long timeout_ms) { - std::vector ret_messages; - PASSTHRU_MSG recvbuff[4] = {}; - Timer t = Timer(); - - while (t.getTimePassed() < timeout_ms) { - unsigned long msgcount = 4; - unsigned int res = PassThruReadMsgs(chanid, recvbuff, &msgcount, 0); - if (res == ERR_BUFFER_EMPTY) continue; - Assert::IsFalse(msgcount > 4, _T("PassThruReadMsgs returned more data than the buffer could hold.")); - Assert::AreEqual(STATUS_NOERROR, res, _T("Failed to read message.")); - if (msgcount > 0) { - for (unsigned int i = 0; i < msgcount; i++) { - ret_messages.push_back(recvbuff[i]); - } - } - } - - Assert::IsTrue(min_num <= ret_messages.size(), _T("Received too few messages.")); - return ret_messages; -} - -std::vector j2534_recv_loop(unsigned int chanid, unsigned int num_expected, unsigned long timeout_ms) { - std::vector ret_messages; - PASSTHRU_MSG recvbuff[4] = {}; - Timer t = Timer(); - - while (t.getTimePassed() < timeout_ms) { - unsigned long msgcount = 4; - unsigned int res = PassThruReadMsgs(chanid, recvbuff, &msgcount, 0); - if (res == ERR_BUFFER_EMPTY) continue; - Assert::IsFalse(msgcount > 4, _T("PassThruReadMsgs returned more data than the buffer could hold.")); - Assert::AreEqual(STATUS_NOERROR, res, _T("Failed to read message.")); - if (msgcount > 0) { - for (unsigned int i = 0; i < msgcount; i++) { - ret_messages.push_back(recvbuff[i]); - } - } - if (ret_messages.size() >= num_expected) break; - } - - std::ostringstream stringStream; - stringStream << "j2534_recv_loop Broke at " << t.getTimePassed() << " ms size is " << ret_messages.size() << std::endl; - - if (num_expected != ret_messages.size()) { - stringStream << "Incorrect number of messages received. Displaying the messages:" << std::endl; - for (auto msg : ret_messages) { - stringStream << " TS: " << msg.Timestamp << "; Dat: "; - for (int i = 0; i < msg.DataSize; i++) stringStream << std::hex << std::setw(2) << std::setfill('0') << int(msg.Data[i] & 0xFF) << " "; - stringStream << std::endl; - } - } - - Logger::WriteMessage(stringStream.str().c_str()); - - Assert::AreEqual(num_expected, ret_messages.size(), _T("Received wrong number of messages.")); - return ret_messages; -} - -void check_J2534_can_msg(PASSTHRU_MSG& msgin, unsigned long ProtocolID, unsigned long RxStatus, unsigned long TxFlags, - unsigned long DataSize, unsigned long ExtraDataIndex, const char* Data, const __LineInfo* pLineInfo) { - Assert::AreEqual(DataSize, msgin.DataSize, _T("Wrong msg len"), pLineInfo); - - std::ostringstream logmsg; - logmsg << "Expected Hex ("; - for (int i = 0; i < DataSize; i++) logmsg << std::hex << std::setw(2) << std::setfill('0') << int(Data[i] & 0xFF) << " "; - logmsg << "); Actual Hex ("; - for (int i = 0; i < msgin.DataSize; i++) logmsg << std::hex << std::setw(2) << std::setfill('0') << int(((char*)msgin.Data)[i] & 0xFF) << " "; - logmsg << ")"; - Logger::WriteMessage(logmsg.str().c_str()); - Assert::AreEqual(std::string(Data, DataSize), std::string((char*)msgin.Data, msgin.DataSize), _T("Wrong msg payload"), pLineInfo); - - Assert::AreEqual(ProtocolID, msgin.ProtocolID, _T("Wrong msg protocol"), pLineInfo); - Assert::AreEqual(RxStatus, msgin.RxStatus, _T("Wrong msg receipt rxstatus"), pLineInfo); - Assert::AreEqual(TxFlags, msgin.TxFlags, _T("Wrong msg receipt txflag"), pLineInfo); - Assert::AreEqual(ExtraDataIndex, msgin.ExtraDataIndex, _T("Wrong msg ExtraDataIndex"), pLineInfo); -} - -unsigned long J2534_set_PASS_filter(unsigned long chanid, unsigned long ProtocolID, unsigned long tx, - unsigned long len, char* mask, char* pattern, const __LineInfo* pLineInfo) { - unsigned long filterid; - PASSTHRU_MSG mask_msg = { ProtocolID, 0, tx, 0, len, 0, 0 }; - PASSTHRU_MSG pattern_msg = { ProtocolID, 0, tx, 0, len, 0, 0 }; - memcpy(mask_msg.Data, mask, len); - memcpy(pattern_msg.Data, pattern, len); - Assert::AreEqual(STATUS_NOERROR, PassThruStartMsgFilter(chanid, PASS_FILTER, &mask_msg, &pattern_msg, NULL, &filterid), - _T("Failed to create filter."), pLineInfo); - return filterid; -} - -unsigned long J2534_set_BLOCK_filter(unsigned long chanid, unsigned long ProtocolID, unsigned long tx, - unsigned long len, char* mask, char* pattern, const __LineInfo* pLineInfo) { - unsigned long filterid; - PASSTHRU_MSG mask_msg = { ProtocolID, 0, tx, 0, len, 0, 0 }; - PASSTHRU_MSG pattern_msg = { ProtocolID, 0, tx, 0, len, 0, 0 }; - memcpy(mask_msg.Data, mask, len); - memcpy(pattern_msg.Data, pattern, len); - Assert::AreEqual(STATUS_NOERROR, PassThruStartMsgFilter(chanid, BLOCK_FILTER, &mask_msg, &pattern_msg, NULL, &filterid), - _T("Failed to create filter."), pLineInfo); - return filterid; -} - -unsigned long J2534_set_flowctrl_filter(unsigned long chanid, unsigned long tx, - unsigned long len, char* mask, char* pattern, char* flow, const __LineInfo* pLineInfo) { - unsigned long filterid; - PASSTHRU_MSG mask_msg = { ISO15765, 0, tx, 0, len, 0, 0 }; - PASSTHRU_MSG pattern_msg = { ISO15765, 0, tx, 0, len, 0, 0 }; - PASSTHRU_MSG flow_msg = { ISO15765, 0, tx, 0, len, 0, 0 }; - memcpy(mask_msg.Data, mask, len); - memcpy(pattern_msg.Data, pattern, len); - memcpy(flow_msg.Data, flow, len); - Assert::AreEqual(STATUS_NOERROR, PassThruStartMsgFilter(chanid, FLOW_CONTROL_FILTER, &mask_msg, &pattern_msg, &flow_msg, &filterid), - _T("Failed to create filter."), pLineInfo); - return filterid; -} - -std::unique_ptr getPanda(unsigned long kbaud, BOOL loopback) { - auto p = panda::Panda::openPanda(""); - Assert::IsTrue(p != nullptr, _T("Could not open raw panda device to test communication.")); - p->set_can_speed_kbps(panda::PANDA_CAN1, kbaud); - p->set_safety_mode(panda::SAFETY_ALLOUTPUT); - p->set_can_loopback(loopback); - p->can_clear(panda::PANDA_CAN_RX); - return p; -} - -std::vector checked_panda_send(std::unique_ptr& p, uint32_t addr, bool is_29b, - char* msg, uint8_t len, unsigned int num_expected, const __LineInfo* pLineInfo, unsigned long timeout_ms) { - Assert::IsTrue(p->can_send(addr, is_29b, (const uint8_t*)msg, len, panda::PANDA_CAN1), _T("Panda send says it failed."), pLineInfo); - auto panda_msg_recv = panda_recv_loop(p, 1 + num_expected, timeout_ms); - check_panda_can_msg(panda_msg_recv[0], 0, addr, is_29b, TRUE, std::string(msg, len), pLineInfo); - panda_msg_recv.erase(panda_msg_recv.begin()); - return panda_msg_recv; -} diff --git a/panda/drivers/windows/pandaJ2534DLL Test/TestHelpers.h b/panda/drivers/windows/pandaJ2534DLL Test/TestHelpers.h deleted file mode 100644 index 9df59d7b5e1ac0..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL Test/TestHelpers.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once -#include "stdafx.h" -#include "pandaJ2534DLL/J2534_v0404.h" -#include "panda_shared/panda.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -extern void write_ioctl(unsigned int chanid, unsigned int param, unsigned int val, const __LineInfo* pLineInfo = NULL); - -extern std::vector panda_recv_loop_loose(std::unique_ptr& p, unsigned int min_num, unsigned long timeout_ms = 100); - -extern std::vector panda_recv_loop(std::unique_ptr& p, unsigned int num_expected, unsigned long timeout_ms = 100); - -extern void check_panda_can_msg(panda::PANDA_CAN_MSG& msgin, uint8_t bus, unsigned long addr, bool addr_29b, - bool is_receipt, std::string dat, const __LineInfo* pLineInfo = NULL); - -extern unsigned long J2534_start_periodic_msg_checked(unsigned long chanid, unsigned long ProtocolID, unsigned long TxFlags, unsigned long DataSize, - unsigned long ExtraDataIndex, const char * Data, unsigned long TimeInterval, const __LineInfo * pLineInfo); - -extern unsigned long J2534_start_periodic_msg(unsigned long chanid, unsigned long ProtocolID, unsigned long TxFlags, unsigned long DataSize, - unsigned long ExtraDataIndex, const char* Data, unsigned long TimeInterval, unsigned long* msgID, const __LineInfo* pLineInfo = NULL); - -extern void J2534_send_msg_checked(unsigned long chanid, unsigned long ProtocolID, unsigned long RxStatus, unsigned long TxFlags, - unsigned long Timestamp, unsigned long DataSize, unsigned long ExtraDataIndex, const char* Data, const __LineInfo* pLineInfo = NULL); - -extern long J2534_send_msg(unsigned long chanid, unsigned long ProtocolID, unsigned long RxStatus, unsigned long TxFlags, - unsigned long Timestamp, unsigned long DataSize, unsigned long ExtraDataIndex, const char* Data); - -extern std::vector j2534_recv_loop_loose(unsigned int chanid, unsigned int min_num, unsigned long timeout_ms = 100); - -extern std::vector j2534_recv_loop(unsigned int chanid, unsigned int num_expected, unsigned long timeout_ms = 100); - -extern void check_J2534_can_msg(PASSTHRU_MSG& msgin, unsigned long ProtocolID, unsigned long RxStatus, unsigned long TxFlags, - unsigned long DataSize, unsigned long ExtraDataIndex, const char* Data, const __LineInfo* pLineInfo = NULL); - -extern unsigned long J2534_set_PASS_filter(unsigned long chanid, unsigned long ProtocolID, unsigned long tx, - unsigned long len, char* mask, char* pattern, const __LineInfo* pLineInfo = NULL); - -extern unsigned long J2534_set_BLOCK_filter(unsigned long chanid, unsigned long ProtocolID, unsigned long tx, - unsigned long len, char* mask, char* pattern, const __LineInfo* pLineInfo = NULL); - -extern unsigned long J2534_set_flowctrl_filter(unsigned long chanid, unsigned long tx, - unsigned long len, char* mask, char* pattern, char* flow, const __LineInfo* pLineInfo = NULL); - -extern std::unique_ptr getPanda(unsigned long kbaud = 500, BOOL loopback = FALSE); - -extern std::vector checked_panda_send(std::unique_ptr& p, uint32_t addr, bool is_29b, - char* msg, uint8_t len, unsigned int num_expected=0, const __LineInfo* pLineInfo = NULL, unsigned long timeout_ms = 100); diff --git a/panda/drivers/windows/pandaJ2534DLL Test/Timer.cpp b/panda/drivers/windows/pandaJ2534DLL Test/Timer.cpp deleted file mode 100644 index 33d029e844a7a5..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL Test/Timer.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "stdafx.h" -#include "Timer.h" - - -Timer::Timer() -{ - reset(); -} - -// gets the time elapsed from construction. -unsigned long long /*milliseconds*/ Timer::getTimePassed(){ - // get the new time - auto end = std::chrono::time_point_cast(clock::now()); - - // return the difference of the times - return (end - start).count(); -} - -void Timer::reset() { - start = std::chrono::time_point_cast(clock::now()); -} \ No newline at end of file diff --git a/panda/drivers/windows/pandaJ2534DLL Test/Timer.h b/panda/drivers/windows/pandaJ2534DLL Test/Timer.h deleted file mode 100644 index cbf5579a5cfa4b..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL Test/Timer.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include - -//Copied from https://stackoverflow.com/a/31488113 - -class Timer -{ - using clock = std::chrono::steady_clock; - using time_point_type = std::chrono::time_point < clock, std::chrono::milliseconds >; -public: - Timer(); - - // gets the time elapsed from construction. - unsigned long long /*milliseconds*/ getTimePassed(); - - void reset(); - -private: - time_point_type start; -}; \ No newline at end of file diff --git a/panda/drivers/windows/pandaJ2534DLL Test/j2534_tests.cpp b/panda/drivers/windows/pandaJ2534DLL Test/j2534_tests.cpp deleted file mode 100644 index 674569acccafd3..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL Test/j2534_tests.cpp +++ /dev/null @@ -1,1602 +0,0 @@ -#include "stdafx.h" -#include "Loader4.h" -#include "pandaJ2534DLL/J2534_v0404.h" -#include "panda_shared/panda.h" -#include "Timer.h" -#include "ECUsim DLL\ECUsim.h" -#include "TestHelpers.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -namespace pandaJ2534DLLTest -{ - TEST_CLASS(J2534DLLInitialization) - { - public: - - TEST_CLASS_CLEANUP(deinit) { - UnloadJ2534Dll(); - } - - TEST_METHOD(J2534_Driver_Init) - { - long err = LoadJ2534Dll("pandaJ2534_0404_32.dll"); - Assert::IsTrue(err == 0, _T("Library failed to load properly. Check the export names and library location.")); - } - - }; - - TEST_CLASS(J2534DeviceInitialization) - { - public: - - TEST_METHOD_INITIALIZE(init) { - LoadJ2534Dll("pandaJ2534_0404_32.dll"); - } - - TEST_METHOD_CLEANUP(deinit) { - if (didopen) { - PassThruClose(devid); - didopen = FALSE; - } - UnloadJ2534Dll(); - } - - TEST_METHOD(J2534_Device_OpenDevice__Empty) - { - Assert::AreEqual(STATUS_NOERROR, open_dev(""), _T("Failed to open device."), LINE_INFO()); - } - - TEST_METHOD(J2534_Device_OpenDevice__J2534_2) - { - Assert::AreEqual(STATUS_NOERROR, open_dev("J2534-2:"), _T("Failed to open device."), LINE_INFO()); - } - - TEST_METHOD(J2534_Device_OpenDevice__SN) - { - auto pandas_available = panda::Panda::listAvailablePandas(); - Assert::IsTrue(pandas_available.size() > 0, _T("No pandas detected.")); - - Assert::AreEqual(STATUS_NOERROR, open_dev(pandas_available[0].c_str()), _T("Failed to open device."), LINE_INFO()); - - auto pandas_available_2 = panda::Panda::listAvailablePandas(); - for (auto panda_sn : pandas_available_2) - Assert::AreNotEqual(panda_sn, pandas_available[0]); - } - - TEST_METHOD(J2534_Device_CloseDevice) - { - Assert::AreEqual(STATUS_NOERROR, open_dev(""), _T("Failed to open device."), LINE_INFO()); - Assert::AreEqual(STATUS_NOERROR, close_dev(devid), _T("Failed to close device."), LINE_INFO()); - Assert::AreEqual(ERR_INVALID_DEVICE_ID, PassThruClose(devid), _T("The 2nd close should have failed with ERR_INVALID_DEVICE_ID."), LINE_INFO()); - } - - TEST_METHOD(J2534_Device_ConnectDisconnect) - { - unsigned long chanid; - Assert::AreEqual(STATUS_NOERROR, open_dev(""), _T("Failed to open device."), LINE_INFO()); - Assert::AreEqual(STATUS_NOERROR, PassThruConnect(devid, CAN, 0, 500000, &chanid), _T("Failed to open channel."), LINE_INFO()); - - Assert::AreEqual(STATUS_NOERROR, PassThruDisconnect(chanid), _T("Failed to close channel."), LINE_INFO()); - Assert::AreEqual(ERR_INVALID_CHANNEL_ID, PassThruDisconnect(chanid), _T("The 2nd disconnect should have failed with ERR_INVALID_CHANNEL_ID."), LINE_INFO()); - } - - TEST_METHOD(J2534_Device_ConnectInvalidProtocol) - { - unsigned long chanid; - Assert::AreEqual(STATUS_NOERROR, open_dev(""), _T("Failed to open device."), LINE_INFO()); - Assert::AreEqual(ERR_INVALID_PROTOCOL_ID, PassThruConnect(devid, 999, 0, 500000, &chanid), - _T("Did not report ERR_INVALID_PROTOCOL_ID."), LINE_INFO()); - Assert::AreEqual(ERR_INVALID_CHANNEL_ID, PassThruDisconnect(chanid), _T("The channel should not have been created."), LINE_INFO()); - } - - bool didopen = FALSE; - unsigned long devid; - - unsigned long open_dev(const char* name, long assert_err = STATUS_NOERROR, TCHAR* failmsg = _T("Failed to open device.")) { - unsigned int res = PassThruOpen((void*)name, &devid); - if (res == STATUS_NOERROR) didopen = TRUE; - return res; - } - - unsigned long close_dev(unsigned long devid) { - unsigned long res = PassThruClose(devid); - if (res == STATUS_NOERROR) didopen = FALSE; - return res; - } - - }; - - TEST_CLASS(J2534DeviceCAN) - { - public: - - TEST_METHOD_INITIALIZE(init) { - LoadJ2534Dll("pandaJ2534_0404_32.dll"); - } - - TEST_METHOD_CLEANUP(deinit) { - if (didopen) { - PassThruClose(devid); - didopen = FALSE; - } - UnloadJ2534Dll(); - } - - //Test that the BAUD rate of a CAN connection can be changed. - TEST_METHOD(J2534_CAN_SetBaud) - { - auto chanid = J2534_open_and_connect("", CAN, 0, 500000, LINE_INFO()); - write_ioctl(chanid, LOOPBACK, TRUE, LINE_INFO()); // ENABLE J2534 ECHO/LOOPBACK - auto p = getPanda(250); - - J2534_send_msg_checked(chanid, CAN, 0, 0, 0, 4 + 2, 0, "\x0\x0\x3\xAB""HI", LINE_INFO()); - j2534_recv_loop(chanid, 0); - panda_recv_loop(p, 0); - - write_ioctl(chanid, DATA_RATE, 250000, LINE_INFO()); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], CAN, TX_MSG_TYPE, 0, 4 + 2, 0, "\x0\x0\x3\xAB""HI", LINE_INFO()); - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x3AB, FALSE, FALSE, "HI", LINE_INFO()); - } - - TEST_METHOD(J2534_CAN_11b_Tx) - { - auto chanid = J2534_open_and_connect("", CAN, 0, 500000, LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, CAN, 0, 0, 0, 6, 6, "\x0\x0\x3\xAB""HI", LINE_INFO()); - - std::vector msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(msg_recv[0], 0, 0x3AB, FALSE, FALSE, "HI", LINE_INFO()); - - j2534_recv_loop(chanid, 0, 50); // Check no message is returned (since loopback is off) - } - - TEST_METHOD(J2534_CAN_29b_Tx) - { - auto chanid = J2534_open_and_connect("", CAN, CAN_29BIT_ID, 500000, LINE_INFO()); - auto p = getPanda(500); - - Assert::AreEqual(ERR_INVALID_MSG, J2534_send_msg(chanid, CAN, 0, 0, 0, 6, 6, "\x0\x0\x3\xAB""HI"), _T("11b address should fail to tx."), LINE_INFO()); - J2534_send_msg_checked(chanid, CAN, 0, CAN_29BIT_ID, 0, 6, 6, "\x0\x0\x3\xAB""YO", LINE_INFO()); - - std::vector msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(msg_recv[0], 0, 0x3AB, TRUE, FALSE, "YO", LINE_INFO()); - } - - TEST_METHOD(J2534_CAN_11b29b_Tx) - { - auto chanid = J2534_open_and_connect("", CAN, CAN_ID_BOTH, 500000, LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, CAN, 0, 0, 0, 6, 6, "\x0\x0\x3\xAB""HI", LINE_INFO()); - J2534_send_msg_checked(chanid, CAN, 0, CAN_29BIT_ID, 0, 6, 6, "\x0\x0\x3\xAB""YO", LINE_INFO()); - - std::vector msg_recv = panda_recv_loop(p, 2); - check_panda_can_msg(msg_recv[0], 0, 0x3AB, FALSE, FALSE, "HI", LINE_INFO()); - check_panda_can_msg(msg_recv[1], 0, 0x3AB, TRUE, FALSE, "YO", LINE_INFO()); - } - - TEST_METHOD(J2534_CAN_TxEcho) - { - auto chanid = J2534_open_and_connect("", CAN, 0, 500000, LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, CAN, 0, 0, 0, 9, 9, "\x0\x0\x3\xAB""HIDOG", LINE_INFO()); - - auto msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(msg_recv[0], 0, 0x3AB, FALSE, FALSE, "HIDOG", LINE_INFO()); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 0); - - ///////////////////////////////// - write_ioctl(chanid, LOOPBACK, TRUE, LINE_INFO()); // ENABLE J2534 ECHO/LOOPBACK - - J2534_send_msg_checked(chanid, CAN, 0, 0, 0, 7, 7, "\x0\x0\x3\xAB""SUP", LINE_INFO()); - - msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(msg_recv[0], 0, 0x3AB, FALSE, FALSE, "SUP", LINE_INFO()); - - j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], CAN, TX_MSG_TYPE, 0, 3 + 4, 0, "\x0\x0\x3\xAB""SUP", LINE_INFO()); - } - - TEST_METHOD(J2534_CAN_RxAndPassAllFilters) - { - auto chanid = J2534_open_and_connect("", CAN, 0, 500000, LINE_INFO()); - J2534_set_PASS_filter(chanid, CAN, 0, 4, "\x0\x0\x0\x0", "\x0\x0\x0\x0", LINE_INFO()); - auto p = getPanda(500); - - p->can_send(0x1FA, FALSE, (const uint8_t*)"ABCDE", 5, panda::PANDA_CAN1); - p->can_send(0x2AC, FALSE, (const uint8_t*)"HIJKL", 5, panda::PANDA_CAN1); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 2); - check_J2534_can_msg(j2534_msg_recv[0], CAN, 0, 0, 5 + 4, 0, "\x0\x0\x1\xFA""ABCDE", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[1], CAN, 0, 0, 5 + 4, 0, "\x0\x0\x2\xAC""HIJKL", LINE_INFO()); - } - - TEST_METHOD(J2534_CAN_RxAndLimitedPassFilter) - { - auto chanid = J2534_open_and_connect("", CAN, 0, 500000, LINE_INFO()); - J2534_set_PASS_filter(chanid, CAN, 0, 4, "\xFF\xFF\xFF\xFF", "\x0\x0\x02\xAC", LINE_INFO()); - auto p = getPanda(500); - - p->can_send(0x1FA, FALSE, (const uint8_t*)"ABCDE", 5, panda::PANDA_CAN1); - p->can_send(0x2AC, FALSE, (const uint8_t*)"HIJKL", 5, panda::PANDA_CAN1); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], CAN, 0, 0, 5 + 4, 0, "\x0\x0\x2\xAC""HIJKL", LINE_INFO()); - } - - TEST_METHOD(J2534_CAN_RxAndPassBlockFilter) - { - auto chanid = J2534_open_and_connect("", CAN, 0, 500000, LINE_INFO()); - J2534_set_PASS_filter(chanid, CAN, 0, 4, "\x0\x0\x0\x0", "\x0\x0\x0\x0", LINE_INFO()); - J2534_set_BLOCK_filter(chanid, CAN, 0, 4, "\xFF\xFF\xFF\xFF", "\x0\x0\x02\xAC", LINE_INFO()); - auto p = getPanda(500); - - p->can_send(0x1FA, FALSE, (const uint8_t*)"ABCDE", 5, panda::PANDA_CAN1); - p->can_send(0x2AC, FALSE, (const uint8_t*)"HIJKL", 5, panda::PANDA_CAN1); - p->can_send(0x3FA, FALSE, (const uint8_t*)"MNOPQ", 5, panda::PANDA_CAN1); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 2, 1000); - check_J2534_can_msg(j2534_msg_recv[0], CAN, 0, 0, 5 + 4, 0, "\x0\x0\x1\xFA""ABCDE", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[1], CAN, 0, 0, 5 + 4, 0, "\x0\x0\x3\xFA""MNOPQ", LINE_INFO()); - } - - //Check that the order of the pass and block filter do not matter - TEST_METHOD(J2534_CAN_RxAndFilterBlockPass) - { - auto chanid = J2534_open_and_connect("", CAN, 0, 500000, LINE_INFO()); - J2534_set_BLOCK_filter(chanid, CAN, 0, 4, "\xFF\xFF\xFF\xFF", "\x0\x0\x02\xAC", LINE_INFO()); - J2534_set_PASS_filter(chanid, CAN, 0, 4, "\x0\x0\x0\x0", "\x0\x0\x0\x0", LINE_INFO()); - auto p = getPanda(500); - - p->can_send(0x1FA, FALSE, (const uint8_t*)"ABCDE", 5, panda::PANDA_CAN1); - p->can_send(0x2AC, FALSE, (const uint8_t*)"HIJKL", 5, panda::PANDA_CAN1); // Should not pass filter - p->can_send(0x3FA, FALSE, (const uint8_t*)"MNOPQ", 5, panda::PANDA_CAN1); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 2, 2000); - check_J2534_can_msg(j2534_msg_recv[0], CAN, 0, 0, 5 + 4, 0, "\x0\x0\x1\xFA""ABCDE", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[1], CAN, 0, 0, 5 + 4, 0, "\x0\x0\x3\xFA""MNOPQ", LINE_INFO()); - } - - //Check that the order of the pass and block filter do not matter - TEST_METHOD(J2534_CAN_RxAndFilterRemoval) - { - auto chanid = J2534_open_and_connect("", CAN, 0, 500000, LINE_INFO()); - auto filterid0 = J2534_set_BLOCK_filter(chanid, CAN, 0, 4, "\xFF\xFF\xFF\xFF", "\x0\x0\x02\xAC", LINE_INFO()); - auto filterid1 = J2534_set_PASS_filter(chanid, CAN, 0, 4, "\x0\x0\x0\x0", "\x0\x0\x0\x0", LINE_INFO()); - - Assert::AreEqual(STATUS_NOERROR, PassThruStopMsgFilter(chanid, filterid0), _T("Failed to delete filter."), LINE_INFO()); - - auto p = getPanda(500); - - p->can_send(0x1FA, FALSE, (const uint8_t*)"ABCDE", 5, panda::PANDA_CAN1); - p->can_send(0x2AC, FALSE, (const uint8_t*)"HIJKL", 5, panda::PANDA_CAN1); - p->can_send(0x3FA, FALSE, (const uint8_t*)"MNOPQ", 5, panda::PANDA_CAN1); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 3, 1000); - check_J2534_can_msg(j2534_msg_recv[0], CAN, 0, 0, 5 + 4, 0, "\x0\x0\x1\xFA""ABCDE", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[1], CAN, 0, 0, 5 + 4, 0, "\x0\x0\x2\xAC""HIJKL", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[2], CAN, 0, 0, 5 + 4, 0, "\x0\x0\x3\xFA""MNOPQ", LINE_INFO()); - } - - //Check that the order of the pass and block filter do not matter - TEST_METHOD(J2534_CAN_RxWithTimeout) - { - auto chanid = J2534_open_and_connect("", CAN, 0, 500000, LINE_INFO()); - J2534_set_PASS_filter(chanid, CAN, 0, 4, "\x0\x0\x0\x0", "\x0\x0\x0\x0", LINE_INFO()); - auto p = getPanda(500); - - PASSTHRU_MSG recvbuff; - unsigned long msgcount = 1; - unsigned int res = PassThruReadMsgs(chanid, &recvbuff, &msgcount, 100); // Here is where we test the timeout - Assert::AreEqual(ERR_BUFFER_EMPTY, res, _T("No message should be found"), LINE_INFO()); - Assert::AreEqual(0, msgcount, _T("Received wrong number of messages.")); - - //TODO Test that the timings work right instead of just testing it doesn't crash. - } - - TEST_METHOD(J2534_CAN_Baud) - { - auto chanid = J2534_open_and_connect("", CAN, 0, 250000, LINE_INFO()); - auto p = getPanda(250); - - J2534_send_msg_checked(chanid, CAN, 0, 0, 0, 6, 6, "\x0\x0\x3\xAB""HI", LINE_INFO()); - - std::vector msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(msg_recv[0], 0, 0x3AB, FALSE, FALSE, "HI", LINE_INFO()); - } - - TEST_METHOD(J2534_CAN_PeriodicMessageStartStop) - { - auto chanid = J2534_open_and_connect("", CAN, 0, 500000, LINE_INFO()); - auto p = getPanda(500); - - auto msgid = J2534_start_periodic_msg_checked(chanid, CAN, 0, 6, 0, "\x0\x0\x3\xAB""HI", 100, LINE_INFO()); - - std::vector msg_recv = panda_recv_loop(p, 3, 250); - Assert::AreEqual(STATUS_NOERROR, PassThruStopPeriodicMsg(chanid, msgid), _T("Failed to delete filter."), LINE_INFO()); - check_panda_can_msg(msg_recv[0], 0, 0x3AB, FALSE, FALSE, "HI", LINE_INFO()); - check_panda_can_msg(msg_recv[1], 0, 0x3AB, FALSE, FALSE, "HI", LINE_INFO()); - check_panda_can_msg(msg_recv[2], 0, 0x3AB, FALSE, FALSE, "HI", LINE_INFO()); - - auto timediff_1_0 = msg_recv[1].recv_time - msg_recv[0].recv_time; - auto timediff_2_1 = msg_recv[2].recv_time - msg_recv[1].recv_time; - - std::ostringstream stringStream1; - stringStream1 << "times1: " << timediff_1_0 << ", " << timediff_2_1 << std::endl; - Logger::WriteMessage(stringStream1.str().c_str()); - - Assert::IsTrue(timediff_1_0 > 90000); - Assert::IsTrue(timediff_1_0 < 110000); - Assert::IsTrue(timediff_2_1 > 90000); - Assert::IsTrue(timediff_2_1 < 110000); - - msg_recv = panda_recv_loop(p, 0, 300); - } - - TEST_METHOD(J2534_CAN_PeriodicMessageMultipleStartStop) - { - auto chanid = J2534_open_and_connect("", CAN, 0, 500000, LINE_INFO()); - auto p = getPanda(500); - - auto msgid0 = J2534_start_periodic_msg_checked(chanid, CAN, 0, 6, 0, "\x0\x0\x3\xAB""HI", 100, LINE_INFO()); - auto msgid1 = J2534_start_periodic_msg_checked(chanid, CAN, 0, 6, 0, "\x0\x0\x1\x23""YO", 80, LINE_INFO()); - - std::vector msg_recv = panda_recv_loop(p, 9, 370); - Assert::AreEqual(STATUS_NOERROR, PassThruStopPeriodicMsg(chanid, msgid0), _T("Failed to delete filter."), LINE_INFO()); - Assert::AreEqual(STATUS_NOERROR, PassThruStopPeriodicMsg(chanid, msgid1), _T("Failed to delete filter."), LINE_INFO()); - //time diagram. 10 ms per character. * is send event. : is termination of periodic messages. - //*---------*---------*---------*-----:----* HI - //*-------*-------*-------*-------*---:----* YO - check_panda_can_msg(msg_recv[0], 0, 0x3AB, FALSE, FALSE, "HI", LINE_INFO()); - check_panda_can_msg(msg_recv[1], 0, 0x123, FALSE, FALSE, "YO", LINE_INFO()); - check_panda_can_msg(msg_recv[2], 0, 0x123, FALSE, FALSE, "YO", LINE_INFO()); - check_panda_can_msg(msg_recv[3], 0, 0x3AB, FALSE, FALSE, "HI", LINE_INFO()); - check_panda_can_msg(msg_recv[4], 0, 0x123, FALSE, FALSE, "YO", LINE_INFO()); - check_panda_can_msg(msg_recv[5], 0, 0x3AB, FALSE, FALSE, "HI", LINE_INFO()); - check_panda_can_msg(msg_recv[6], 0, 0x123, FALSE, FALSE, "YO", LINE_INFO()); - check_panda_can_msg(msg_recv[7], 0, 0x3AB, FALSE, FALSE, "HI", LINE_INFO()); - check_panda_can_msg(msg_recv[8], 0, 0x123, FALSE, FALSE, "YO", LINE_INFO()); - - auto timediff_HI_3_0 = msg_recv[3].recv_time - msg_recv[0].recv_time; - auto timediff_HI_5_3 = msg_recv[5].recv_time - msg_recv[3].recv_time; - auto timediff_HI_7_5 = msg_recv[7].recv_time - msg_recv[5].recv_time; - - auto timediff_YO_2_1 = msg_recv[2].recv_time - msg_recv[1].recv_time; - auto timediff_YO_4_2 = msg_recv[4].recv_time - msg_recv[2].recv_time; - auto timediff_YO_6_4 = msg_recv[6].recv_time - msg_recv[4].recv_time; - auto timediff_YO_8_6 = msg_recv[8].recv_time - msg_recv[6].recv_time; - - std::ostringstream stringStreamHi; - stringStreamHi << "HiTimes: " << timediff_HI_3_0 << ", " << timediff_HI_5_3 << ", " << timediff_HI_7_5 << std::endl; - Logger::WriteMessage(stringStreamHi.str().c_str()); - - std::ostringstream stringStreamYo; - stringStreamYo << "HiTimes: " << timediff_YO_2_1 << ", " << timediff_YO_4_2 << ", " << timediff_YO_6_4 << ", " << timediff_YO_8_6 << std::endl; - Logger::WriteMessage(stringStreamYo.str().c_str()); - - Assert::IsTrue(timediff_HI_3_0 > 90000); - Assert::IsTrue(timediff_HI_3_0 < 110000); - Assert::IsTrue(timediff_HI_5_3 > 90000); - Assert::IsTrue(timediff_HI_5_3 < 110000); - Assert::IsTrue(timediff_HI_7_5 > 90000); - Assert::IsTrue(timediff_HI_7_5 < 110000); - - Assert::IsTrue(timediff_YO_2_1 > 80000-10000); - Assert::IsTrue(timediff_YO_2_1 < 80000+1000); - Assert::IsTrue(timediff_YO_4_2 > 80000 - 10000); - Assert::IsTrue(timediff_YO_4_2 < 80000 + 10000); - Assert::IsTrue(timediff_YO_6_4 > 80000 - 10000); - Assert::IsTrue(timediff_YO_6_4 < 80000 + 10000); - Assert::IsTrue(timediff_YO_8_6 > 80000 - 10000); - Assert::IsTrue(timediff_YO_8_6 < 80000 + 10000); - - msg_recv = panda_recv_loop(p, 0, 300); - } - - TEST_METHOD(J2534_CAN_PeriodicMessageStartStop_Loopback) - { - auto chanid = J2534_open_and_connect("", CAN, 0, 500000, LINE_INFO()); - write_ioctl(chanid, LOOPBACK, TRUE, LINE_INFO()); // ENABLE J2534 ECHO/LOOPBACK - auto p = getPanda(500); - auto msgid = J2534_start_periodic_msg_checked(chanid, CAN, 0, 6, 0, "\x0\x0\x3\xAB""HI", 100, LINE_INFO()); - - std::vector msg_recv = panda_recv_loop(p, 3, 250); - Assert::AreEqual(STATUS_NOERROR, PassThruStopPeriodicMsg(chanid, msgid), _T("Failed to delete filter."), LINE_INFO()); - check_panda_can_msg(msg_recv[0], 0, 0x3AB, FALSE, FALSE, "HI", LINE_INFO()); - check_panda_can_msg(msg_recv[1], 0, 0x3AB, FALSE, FALSE, "HI", LINE_INFO()); - check_panda_can_msg(msg_recv[2], 0, 0x3AB, FALSE, FALSE, "HI", LINE_INFO()); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 3); - check_J2534_can_msg(j2534_msg_recv[0], CAN, TX_MSG_TYPE, 0, 6, 0, "\x0\x0\x3\xAB""HI", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[1], CAN, TX_MSG_TYPE, 0, 6, 0, "\x0\x0\x3\xAB""HI", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[2], CAN, TX_MSG_TYPE, 0, 6, 0, "\x0\x0\x3\xAB""HI", LINE_INFO()); - - auto timediff_1_0 = j2534_msg_recv[1].Timestamp - j2534_msg_recv[0].Timestamp; - auto timediff_2_1 = j2534_msg_recv[2].Timestamp - j2534_msg_recv[1].Timestamp; - - std::ostringstream stringStream1; - stringStream1 << "times1: " << timediff_1_0 << ", " << timediff_2_1 << std::endl; - Logger::WriteMessage(stringStream1.str().c_str()); - - Assert::IsTrue(timediff_1_0 > 90000); - Assert::IsTrue(timediff_1_0 < 110000); - Assert::IsTrue(timediff_2_1 > 90000); - Assert::IsTrue(timediff_2_1 < 110000); - - msg_recv = panda_recv_loop(p, 0, 300); - } - - TEST_METHOD(J2534_CAN_PeriodicMessageWithTx) - { - auto chanid = J2534_open_and_connect("", CAN, 0, 500000, LINE_INFO()); - auto p = getPanda(500); - auto msgid = J2534_start_periodic_msg_checked(chanid, CAN, 0, 6, 0, "\x0\x0\x3\xAB""HI", 100, LINE_INFO()); - - J2534_send_msg(chanid, CAN, 0, 0, 0, 7, 0, "\x0\x0\x3\xAB""LOL"); - - std::vector msg_recv = panda_recv_loop(p, 4, 250); - Assert::AreEqual(STATUS_NOERROR, PassThruStopPeriodicMsg(chanid, msgid), _T("Failed to delete filter."), LINE_INFO()); - check_panda_can_msg(msg_recv[0], 0, 0x3AB, FALSE, FALSE, "HI", LINE_INFO()); - check_panda_can_msg(msg_recv[1], 0, 0x3AB, FALSE, FALSE, "LOL", LINE_INFO());//Staggered write inbetween multiple scheduled TXs - check_panda_can_msg(msg_recv[2], 0, 0x3AB, FALSE, FALSE, "HI", LINE_INFO()); - check_panda_can_msg(msg_recv[3], 0, 0x3AB, FALSE, FALSE, "HI", LINE_INFO()); - - auto timediff_2_0 = msg_recv[2].recv_time - msg_recv[0].recv_time; - auto timediff_3_2 = msg_recv[3].recv_time - msg_recv[2].recv_time; - - std::ostringstream stringStream1; - stringStream1 << "times1: " << timediff_2_0 << ", " << timediff_3_2 << std::endl; - Logger::WriteMessage(stringStream1.str().c_str()); - - Assert::IsTrue(timediff_2_0 > 90000); - Assert::IsTrue(timediff_2_0 < 110000); - Assert::IsTrue(timediff_3_2 > 90000); - Assert::IsTrue(timediff_3_2 < 110000); - - msg_recv = panda_recv_loop(p, 0, 300); - } - - TEST_METHOD(J2534_CAN_BaudInvalid) - { - unsigned long chanid; - Assert::AreEqual(STATUS_NOERROR, open_dev(""), _T("Failed to open device."), LINE_INFO()); - Assert::AreEqual(ERR_INVALID_BAUDRATE, PassThruConnect(devid, CAN, 0, 6000000, &chanid), _T("Baudrate should have been invalid."), LINE_INFO()); - Assert::AreEqual(ERR_INVALID_BAUDRATE, PassThruConnect(devid, CAN, 0, 200, &chanid), _T("Baudrate should have been invalid."), LINE_INFO()); - Assert::AreEqual(ERR_INVALID_BAUDRATE, PassThruConnect(devid, CAN, 0, 250010, &chanid), _T("Baudrate should have been invalid."), LINE_INFO()); - } - - bool didopen = FALSE; - unsigned long devid; - - unsigned long open_dev(const char* name, long assert_err = STATUS_NOERROR, TCHAR* failmsg = _T("Failed to open device.")) { - unsigned int res = PassThruOpen((void*)name, &devid); - if (res == STATUS_NOERROR) didopen = TRUE; - return res; - } - - unsigned long J2534_open_and_connect(const char* name, unsigned long ProtocolID, unsigned long Flags, unsigned long bps, const __LineInfo* pLineInfo = NULL) { - unsigned long chanid; - Assert::AreEqual(STATUS_NOERROR, open_dev(name), _T("Failed to open device."), pLineInfo); - Assert::AreEqual(STATUS_NOERROR, PassThruConnect(devid, ProtocolID, Flags, bps, &chanid), _T("Failed to open channel."), pLineInfo); - write_ioctl(chanid, LOOPBACK, FALSE, LINE_INFO()); // DISABLE J2534 ECHO/LOOPBACK - return chanid; - } - - }; - - TEST_CLASS(J2534DeviceISO15765) - { - public: - - TEST_METHOD_INITIALIZE(init) { - LoadJ2534Dll("pandaJ2534_0404_32.dll"); - } - - TEST_METHOD_CLEANUP(deinit) { - if (didopen) { - PassThruClose(devid); - didopen = FALSE; - } - UnloadJ2534Dll(); - } - - //Test that the BAUD rate of a ISO15765 connection can be changed. - TEST_METHOD(J2534_ISO15765_SetBaud) - { - auto chanid = J2534_open_and_connect("", ISO15765, 0, 500000, LINE_INFO()); - write_ioctl(chanid, LOOPBACK, TRUE, LINE_INFO()); // ENABLE J2534 ECHO/LOOPBACK - auto p = getPanda(250); - - J2534_send_msg_checked(chanid, ISO15765, 0, 0, 0, 4 + 2, 0, "\x0\x0\x3\xAB""HI", LINE_INFO()); - j2534_recv_loop(chanid, 0); - panda_recv_loop(p, 0); - - write_ioctl(chanid, DATA_RATE, 250000, LINE_INFO()); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 2); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, TX_INDICATION, 0, 4, 0, "\x0\x0\x3\xAB", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[1], ISO15765, TX_MSG_TYPE, 0, 4 + 2, 0, "\x0\x0\x3\xAB""HI", LINE_INFO()); - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x3AB, FALSE, FALSE, "\x2""HI", LINE_INFO()); - } - - ///////////////////// Tests checking things don't send/receive ///////////////////// - - //Check tx PASSES and rx FAIL WITHOUT a filter. 29 bit. NO Filter. NoPadding. STD address. Single Frame. - TEST_METHOD(J2534_ISO15765_PassTxFailRx_29b_NoFilter_NoPad_STD_SF) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - auto p = getPanda(500); - - //TX: works because all single frame writes should work (with or without a flow contorl filter) - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 11, 0, "\x18\xda\xef\xf1""TX_TEST", LINE_INFO()); - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x07""TX_TEST", LINE_INFO()); - - //RX: Reads require a flow control filter, and should fail without one. - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x06\x41\x00\xff\xff\xff\xfe", 7, 0, LINE_INFO()); - j2534_recv_loop(chanid, 0); - } - - //Check tx and rx FAIL WITHOUT a filter. 29 bit. NO Filter. NoPadding. STD address. First Frame. - TEST_METHOD(J2534_ISO15765_FailTxRx_29b_NoFilter_NoPad_STD_FF) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - auto p = getPanda(500); - - //TX - Assert::AreEqual(ERR_NO_FLOW_CONTROL, J2534_send_msg(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 12, 0, "\x18\xda\xef\xf1\xA1\xB2\xC3\xD4\xE5\xF6\x09\x1A"), - _T("Should fail to tx without a filter."), LINE_INFO()); - j2534_recv_loop(chanid, 0); - panda_recv_loop(p, 0); - - //RX; Send full response and check didn't receive flow control from J2534 device - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x10\x14\x49\x02\x01""1D4", 8, 0, LINE_INFO()); - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x21""GP00R55", 8, 0, LINE_INFO()); - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x22""B123456", 8, 0, LINE_INFO()); - j2534_recv_loop(chanid, 0);//Check a full message is not accepted. - } - - //Check tx PASSES and rx FAIL with a MISMATCHED filter. 29 bit. Mismatch Filter. NoPadding. STD address. Single Frame. - TEST_METHOD(J2534_ISO15765_PassTxFailRx_29b_MismatchFilter_NoPad_STD_SF) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - auto p = getPanda(500); - - //TX: works because all single frame writes should work (with or without a flow contorl filter) - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 6, 0, "\x18\xda\xe0\xf1""\x11\x22", LINE_INFO()); - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xe0\xf1", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAE0F1, TRUE, FALSE, "\x02""\x11\x22", LINE_INFO()); - - //RX. Send ISO15765 single frame to device. Address still doesn't match filter, so should not be received. - checked_panda_send(p, 0x18DAF1E0, TRUE, "\x06\x41\x00\xff\xff\xff\xfe", 7, 0, LINE_INFO()); - j2534_recv_loop(chanid, 0); - } - - //Check tx and rx FAIL with a MISMATCHED filter. 29 bit. Mismatch Filter. NoPadding. STD address. First Frame. - TEST_METHOD(J2534_ISO15765_FailTxRx_29b_MismatchFilter_NoPad_STD_FF) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - auto p = getPanda(500); - - //TX - Assert::AreEqual(ERR_NO_FLOW_CONTROL, J2534_send_msg(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 12, 0, "\x18\xda\xe0\xf1""USELESS STUFF"), - _T("Should fail to tx without a filter."), LINE_INFO()); - j2534_recv_loop(chanid, 0); - panda_recv_loop(p, 0); - - //RX; Send a full response and check didn't receive flow control from J2534 device - checked_panda_send(p, 0x18DAF1E0, TRUE, "\x10\x14\x49\x02\x01""1D4", 8, 0, LINE_INFO()); - checked_panda_send(p, 0x18DAF1E0, TRUE, "\x21""GP00R55", 8, 0, LINE_INFO()); - checked_panda_send(p, 0x18DAF1E0, TRUE, "\x22""B123456", 8, 0, LINE_INFO()); - j2534_recv_loop(chanid, 0);//Check a full message is not accepted. - } - - //Check tx FAILS with a MISMATCHED filter 29bit flag. 29 bit. Mismatch Filter. NoPadding. STD address. Single Frame. - TEST_METHOD(J2534_ISO15765_FailTxRx_29b_MismatchFilterFlag29b_NoPad_STD_SF) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x0\x0\x1\xab", "\x0\x0\x1\xcd", LINE_INFO()); - auto p = getPanda(500); - - //TX - Assert::AreEqual(ERR_INVALID_MSG, J2534_send_msg(chanid, ISO15765, 0, 0, 0, 6, 0, "\x0/x0/x1/xcd\x01\x00"), - _T("mismatched address should fail to tx."), LINE_INFO()); - j2534_recv_loop(chanid, 0); - panda_recv_loop(p, 0); - - //RX. Send ISO15765 single frame to device. Address still doesn't match filter, so should not be received. - checked_panda_send(p, 0x1ab, FALSE, "\x06\x41\x00\xff\xff\xff\xfe", 7, 0, LINE_INFO()); - j2534_recv_loop(chanid, 0); - } - - ///////////////////// Tests checking things actually send/receive. Standard Addressing ///////////////////// - - //Check rx passes with filter. 29 bit. Good Filter. NoPadding. STD address. Single Frame. - TEST_METHOD(J2534_ISO15765_SuccessRx_29b_Filter_NoPad_STD_SF) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - auto p = getPanda(500); - - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x07""ABCD123", 8, 0, LINE_INFO()); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID, 0, 11, 11, "\x18\xda\xf1\xef""ABCD123", LINE_INFO()); - } - - //Check tx passes with filter. 29 bit. Good Filter. NoPadding. STD address. Single Frame. - TEST_METHOD(J2534_ISO15765_SuccessTx_29b_Filter_NoPad_STD_SF) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 11, 0, "\x18\xda\xef\xf1""TX_TEST", LINE_INFO()); - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x07""TX_TEST", LINE_INFO()); - } - - //Check tx passes with filter. 29 bit. Good Filter. NoPadding. STD address. Single Frame. Loopback. - TEST_METHOD(J2534_ISO15765_SuccessTx_29b_Filter_NoPad_STD_SF_LOOPBACK) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - write_ioctl(chanid, LOOPBACK, TRUE, LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 11, 0, "\x18\xda\xef\xf1""TX_TEST", LINE_INFO()); - auto j2534_msg_recv = j2534_recv_loop(chanid, 2); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[1], ISO15765, CAN_29BIT_ID | TX_MSG_TYPE, 0, 11, 0, "\x18\xda\xef\xf1""TX_TEST", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x07""TX_TEST", LINE_INFO()); - } - - //Check rx passes with filter. 29 bit. Good Filter. NoPadding. STD address. Multi Frame. - TEST_METHOD(J2534_ISO15765_SuccessRx_29b_Filter_NoPad_STD_FFCF) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - auto p = getPanda(500); - - //Send first frame, then check we get a flow control frame - auto panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x10\x13""ninete", 8, 1, LINE_INFO()); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, std::string("\x30\x00\x00", 3), LINE_INFO()); - - //Check first frame is registered with J2534 - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | START_OF_MESSAGE, 0, 4, 0, "\x18\xda\xf1\xef", LINE_INFO()); - - //Send the rest of the message - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x21""en byte", 8, 0, LINE_INFO()); - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x22""s here", 7, 0, LINE_INFO()); - - //Check J2534 constructed the whole message - j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID, 0, 4 + 0x13, 4 + 0x13, "\x18\xda\xf1\xef""nineteen bytes here", LINE_INFO()); - } - - //Check multi frame tx passes with filter. 29 bit. Good Filter. NoPadding. STD address. Multi Frame. - TEST_METHOD(J2534_ISO15765_SuccessTx_29b_Filter_NoPad_STD_FFCF) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 14, 0, "\x18\xda\xef\xf1""\xAA\xBB\xCC\xDD\xEE\xFF\x11\x22\x33\x44", LINE_INFO()); - auto j2534_msg_recv = j2534_recv_loop(chanid, 0); // No TxDone msg until after the final tx frame is sent - - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x10\x0A""\xAA\xBB\xCC\xDD\xEE\xFF", LINE_INFO()); - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x0\x0", 3, 1, LINE_INFO()); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x21""\x11\x22\x33\x44", LINE_INFO()); - - j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - } - - //Check rx passes with filter. 11 bit. Good Filter. NoPadding. STD address. Single Frame. - TEST_METHOD(J2534_ISO15765_SuccessRx_11b_Filter_NoPad_STD_SF) - { - auto chanid = J2534_open_and_connect("", ISO15765, 0, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, 0, 4, "\xff\xff\xff\xff", "\x0\x0\x1\xab", "\x0\x0\x1\xcd", LINE_INFO()); - auto p = getPanda(500); - - checked_panda_send(p, 0x1ab, FALSE, "\x07""ABCD123", 8, 0, LINE_INFO()); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, 0, 0, 11, 11, "\x0\x0\x1\xab""ABCD123", LINE_INFO()); - } - - //Check tx passes with filter. 11 bit. Good Filter. NoPadding. STD address. Single Frame. - TEST_METHOD(J2534_ISO15765_SuccessTx_11b_Filter_NoPad_STD_SF) - { - auto chanid = J2534_open_and_connect("", ISO15765, 0, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, 0, 4, "\xff\xff\xff\xff", "\x0\x0\x1\xab", "\x0\x0\x1\xcd", LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, ISO15765, 0, 0, 0, 11, 0, "\x0\x0\x1\xcd""TX_TEST", LINE_INFO()); - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, TX_INDICATION, 0, 4, 0, "\x0\x0\x1\xcd", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x1CD, FALSE, FALSE, "\x07""TX_TEST", LINE_INFO()); - } - - //Check tx passes with filter multiple times. 29 bit. Good Filter. NoPadding. STD address. Multiple Single Frames. - TEST_METHOD(J2534_ISO15765_SuccessTx_29b_Filter_NoPad_STD_MultipleSF) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - write_ioctl(chanid, LOOPBACK, TRUE, LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 11, 0, "\x18\xda\xef\xf1""TX_TEST", LINE_INFO()); - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 9, 0, "\x18\xda\xef\xf1""HELLO", LINE_INFO()); - auto j2534_msg_recv = j2534_recv_loop(chanid, 4); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[1], ISO15765, CAN_29BIT_ID | TX_MSG_TYPE, 0, 11, 0, "\x18\xda\xef\xf1""TX_TEST", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[2], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[3], ISO15765, CAN_29BIT_ID | TX_MSG_TYPE, 0, 9, 0, "\x18\xda\xef\xf1""HELLO", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 2); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x07""TX_TEST", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[1], 0, 0x18DAEFF1, TRUE, FALSE, "\x05""HELLO", LINE_INFO()); - } - - //Check that receiver's flow control block size requests are respected. 29 bit. Good Filter. NoPadding. STD address. Multiple Frames with multiple flow control. - TEST_METHOD(J2534_ISO15765_SuccessTx_29b_Filter_NoPad_STD_MF_FLOWCONTROLBlockSize) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 4 + 52, 0, "\x18\xda\xef\xf1""AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x10\x34""AABBCC", LINE_INFO()); - - // [flow_status, block_size, st_min] - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x01\x00", 3, 1, LINE_INFO()); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x21""DDEEFFG", LINE_INFO()); - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x02\x00", 3, 2, LINE_INFO()); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x22""GHHIIJJ", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[1], 0, 0x18DAEFF1, TRUE, FALSE, "\x23""KKLLMMN", LINE_INFO()); - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x01\x00", 3, 1, LINE_INFO()); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x24""NOOPPQQ", LINE_INFO()); - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x00\x00", 3, 3, LINE_INFO()); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x25""RRSSTTU", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[1], 0, 0x18DAEFF1, TRUE, FALSE, "\x26""UVVWWXX", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[2], 0, 0x18DAEFF1, TRUE, FALSE, "\x27""YYZZ", LINE_INFO()); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - } - - //Check that receiver's flow control separation time requests are respected. 29 bit. Good Filter. NoPadding. STD address. Multiple Frames with multiple flow control. - TEST_METHOD(J2534_ISO15765_SuccessTx_29b_Filter_NoPad_STD_MF_FLOWCONTROLSTMinMultiFc) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 4 + 52, 0, "\x18\xda\xef\xf1""AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x10\x34""AABBCC", LINE_INFO()); - - // [flow_status, block_size, st_min] - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x03\x0A", 3, 3, LINE_INFO()); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x21""DDEEFFG", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[1], 0, 0x18DAEFF1, TRUE, FALSE, "\x22""GHHIIJJ", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[2], 0, 0x18DAEFF1, TRUE, FALSE, "\x23""KKLLMMN", LINE_INFO()); - auto timediff0_1_0 = panda_msg_recv[1].recv_time - panda_msg_recv[0].recv_time; - auto timediff0_2_1 = panda_msg_recv[2].recv_time - panda_msg_recv[1].recv_time; - - std::ostringstream stringStream0; - stringStream0 << "times0: " << timediff0_1_0 << ", " << timediff0_2_1 << std::endl; - Logger::WriteMessage(stringStream0.str().c_str()); - - Assert::IsTrue(timediff0_1_0 > 10000); - Assert::IsTrue(timediff0_1_0 < 32000);//Flexible, but trying to make sure things don't just all lag for a second or something - Assert::IsTrue(timediff0_2_1 > 10000); - Assert::IsTrue(timediff0_2_1 < 32000); - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x04\x20", 3, 4, LINE_INFO(), 500); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x24""NOOPPQQ", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[1], 0, 0x18DAEFF1, TRUE, FALSE, "\x25""RRSSTTU", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[2], 0, 0x18DAEFF1, TRUE, FALSE, "\x26""UVVWWXX", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[3], 0, 0x18DAEFF1, TRUE, FALSE, "\x27""YYZZ", LINE_INFO()); - auto timediff1_1_0 = panda_msg_recv[1].recv_time - panda_msg_recv[0].recv_time; - auto timediff1_2_1 = panda_msg_recv[2].recv_time - panda_msg_recv[1].recv_time; - auto timediff1_3_2 = panda_msg_recv[3].recv_time - panda_msg_recv[2].recv_time; - - std::ostringstream stringStream1; - stringStream1 << "times1: " << timediff1_1_0 << ", " << timediff1_2_1 << ", " << timediff1_3_2 << std::endl; - Logger::WriteMessage(stringStream1.str().c_str()); - - Assert::IsTrue(timediff1_1_0 > 32000); - Assert::IsTrue(timediff1_2_1 > 32000); - Assert::IsTrue(timediff1_3_2 > 32000); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - } - - //Check that receiver's flow control separation time requests are respected 2. 29 bit. Good Filter. NoPadding. STD address. Multiple Frames with one flow control. - TEST_METHOD(J2534_ISO15765_SuccessTx_29b_Filter_NoPad_STD_MF_FLOWCONTROLSTMinSingleFc) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 4 + 52, 0, "\x18\xda\xef\xf1""AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x10\x34""AABBCC", LINE_INFO()); - - // [flow_status, block_size, st_min] - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x07\x0A", 3, 7, LINE_INFO(), 500); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x21""DDEEFFG", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[1], 0, 0x18DAEFF1, TRUE, FALSE, "\x22""GHHIIJJ", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[2], 0, 0x18DAEFF1, TRUE, FALSE, "\x23""KKLLMMN", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[3], 0, 0x18DAEFF1, TRUE, FALSE, "\x24""NOOPPQQ", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[4], 0, 0x18DAEFF1, TRUE, FALSE, "\x25""RRSSTTU", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[5], 0, 0x18DAEFF1, TRUE, FALSE, "\x26""UVVWWXX", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[6], 0, 0x18DAEFF1, TRUE, FALSE, "\x27""YYZZ", LINE_INFO()); - - auto timediff_1_0 = panda_msg_recv[1].recv_time - panda_msg_recv[0].recv_time; - auto timediff_2_1 = panda_msg_recv[2].recv_time - panda_msg_recv[1].recv_time; - auto timediff_3_2 = panda_msg_recv[3].recv_time - panda_msg_recv[2].recv_time; - auto timediff_4_3 = panda_msg_recv[4].recv_time - panda_msg_recv[3].recv_time; - auto timediff_5_4 = panda_msg_recv[5].recv_time - panda_msg_recv[4].recv_time; - auto timediff_6_5 = panda_msg_recv[6].recv_time - panda_msg_recv[5].recv_time; - - std::ostringstream stringStream1; - stringStream1 << "times1: " << timediff_1_0 << ", " << timediff_2_1 << ", " << timediff_3_2 << - ", " << timediff_4_3 << ", " << timediff_5_4 << ", " << timediff_6_5 << std::endl; - Logger::WriteMessage(stringStream1.str().c_str()); - - Assert::IsTrue(timediff_1_0 > 10000); - Assert::IsTrue(timediff_2_1 > 10000); - Assert::IsTrue(timediff_3_2 > 10000); - Assert::IsTrue(timediff_4_3 > 10000); - Assert::IsTrue(timediff_5_4 > 10000); - Assert::IsTrue(timediff_6_5 > 10000); - } - - //Check that tx works for messages with more than 16 frames. 29 bit. Good Filter. NoPadding. STD address. Large multiframe message. - TEST_METHOD(J2534_ISO15765_SuccessTx_29b_Filter_NoPad_STD_MF_LotsOfFrames) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 4 + 125, 0, - "\x18\xda\xef\xf1" - "AABBCC""DDEEFFG""GHHIIJJ""KKLLMMN""NOOPPQQ""RRSSTTU""UVVWWXX""YYZZ112""2334455""6677889" - "900abcd""efghijk""lmnopqr""stuvwxy""z!@#$%^""&*()_+-""=`~ABCD""EFGHIJK", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x10\x7D""AABBCC", LINE_INFO()); - - // [flow_status, block_size, st_min] - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x00\x00", 3, 17, LINE_INFO(), 1000); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x21""DDEEFFG", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[1], 0, 0x18DAEFF1, TRUE, FALSE, "\x22""GHHIIJJ", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[2], 0, 0x18DAEFF1, TRUE, FALSE, "\x23""KKLLMMN", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[3], 0, 0x18DAEFF1, TRUE, FALSE, "\x24""NOOPPQQ", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[4], 0, 0x18DAEFF1, TRUE, FALSE, "\x25""RRSSTTU", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[5], 0, 0x18DAEFF1, TRUE, FALSE, "\x26""UVVWWXX", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[6], 0, 0x18DAEFF1, TRUE, FALSE, "\x27""YYZZ112", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[7], 0, 0x18DAEFF1, TRUE, FALSE, "\x28""2334455", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[8], 0, 0x18DAEFF1, TRUE, FALSE, "\x29""6677889", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[9], 0, 0x18DAEFF1, TRUE, FALSE, "\x2A""900abcd", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[10], 0, 0x18DAEFF1, TRUE, FALSE, "\x2B""efghijk", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[11], 0, 0x18DAEFF1, TRUE, FALSE, "\x2C""lmnopqr", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[12], 0, 0x18DAEFF1, TRUE, FALSE, "\x2D""stuvwxy", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[13], 0, 0x18DAEFF1, TRUE, FALSE, "\x2E""z!@#$%^", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[14], 0, 0x18DAEFF1, TRUE, FALSE, "\x2F""&*()_+-", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[15], 0, 0x18DAEFF1, TRUE, FALSE, "\x20""=`~ABCD", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[16], 0, 0x18DAEFF1, TRUE, FALSE, "\x21""EFGHIJK", LINE_INFO()); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - } - - //Check tx passes with filter multiple times. 29 bit. Good Filter. NoPadding. STD address. Multiple Single Frames. - TEST_METHOD(J2534_ISO15765_SuccessTx_29b_Filter_NoPad_STD_MultipleMFSF) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - write_ioctl(chanid, LOOPBACK, TRUE, LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 4 + 23, 0, "\x18\xda\xef\xf1""Long data because I can", LINE_INFO()); - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 9, 0, "\x18\xda\xef\xf1""HELLO", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x10\x17""Long d", LINE_INFO()); - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x00\x00", 3, 4, LINE_INFO()); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x21""ata bec", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[1], 0, 0x18DAEFF1, TRUE, FALSE, "\x22""ause I ", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[2], 0, 0x18DAEFF1, TRUE, FALSE, "\x23""can", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[3], 0, 0x18DAEFF1, TRUE, FALSE, "\x05""HELLO", LINE_INFO()); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 4); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[1], ISO15765, CAN_29BIT_ID | TX_MSG_TYPE, 0, 4 + 23, 0, "\x18\xda\xef\xf1""Long data because I can", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[2], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[3], ISO15765, CAN_29BIT_ID | TX_MSG_TYPE, 0, 4 + 5, 0, "\x18\xda\xef\xf1""HELLO", LINE_INFO()); - } - - //Check tx passes after message timeout. 29 bit. Good Filter. NoPadding. STD address. Multiple Frame timeout then Single Frame. - TEST_METHOD(J2534_ISO15765_SuccessTx_29b_Filter_NoPad_STD_MFTimeoutSFSuccess) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - write_ioctl(chanid, LOOPBACK, TRUE, LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 4 + 23, 0, "\x18\xda\xef\xf1""Long data because I can", LINE_INFO()); - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 9, 0, "\x18\xda\xef\xf1""HELLO", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 2, 1000); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x10\x17""Long d", LINE_INFO()); //First Frame. Not replying so it needs to time out. - check_panda_can_msg(panda_msg_recv[1], 0, 0x18DAEFF1, TRUE, FALSE, "\x05""HELLO", LINE_INFO()); //Reply to the next message. - - auto j2534_msg_recv = j2534_recv_loop(chanid, 2); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[1], ISO15765, CAN_29BIT_ID | TX_MSG_TYPE, 0, 4 + 5, 0, "\x18\xda\xef\xf1""HELLO", LINE_INFO()); - } - - //Check tx passes after mid-message timeout. 29 bit. Good Filter. NoPadding. STD address. Multiple Frame mid-timeout then Single Frame. - TEST_METHOD(J2534_ISO15765_SuccessTx_29b_Filter_NoPad_STD_MFMidTimeoutSFSuccess) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - write_ioctl(chanid, LOOPBACK, TRUE, LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 4 + 23, 0, "\x18\xda\xef\xf1""Long data because I can", LINE_INFO()); - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 9, 0, "\x18\xda\xef\xf1""HELLO", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x10\x17""Long d", LINE_INFO()); //First Frame. Not replying so it needs to time out. - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x01\x00", 3, 2, LINE_INFO(), 1000);//Start a conversation - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x21""ata bec", LINE_INFO());//Check passthru device sent more data, but don't reply to it - check_panda_can_msg(panda_msg_recv[1], 0, 0x18DAEFF1, TRUE, FALSE, "\x05""HELLO", LINE_INFO()); //Reply to the next message. - - auto j2534_msg_recv = j2534_recv_loop(chanid, 2); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[1], ISO15765, CAN_29BIT_ID | TX_MSG_TYPE, 0, 4 + 5, 0, "\x18\xda\xef\xf1""HELLO", LINE_INFO()); - } - - //Check slow tx passes without hitting FC timeout. 29 bit. Good Filter. NoPadding. STD address. Long STmin, catches if FC timeout applies before needed. - TEST_METHOD(J2534_ISO15765_SuccessTx_29b_Filter_NoPad_STD_SLOWMF) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - write_ioctl(chanid, LOOPBACK, TRUE, LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 4 + 48, 0, "\x18\xda\xef\xf1""AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXX", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x10\x30""AABBCC", LINE_INFO()); - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x06\x7F", 3, 6, LINE_INFO(), 3000);//Start a conversation... but slow. FC timeout is 250 ms. - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x21""DDEEFFG", LINE_INFO());//Check this convo doesn't trigger that timeout. - check_panda_can_msg(panda_msg_recv[1], 0, 0x18DAEFF1, TRUE, FALSE, "\x22""GHHIIJJ", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[2], 0, 0x18DAEFF1, TRUE, FALSE, "\x23""KKLLMMN", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[3], 0, 0x18DAEFF1, TRUE, FALSE, "\x24""NOOPPQQ", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[4], 0, 0x18DAEFF1, TRUE, FALSE, "\x25""RRSSTTU", LINE_INFO());//Some of these should fail to recv if there is an issue. - check_panda_can_msg(panda_msg_recv[5], 0, 0x18DAEFF1, TRUE, FALSE, "\x26""UVVWWXX", LINE_INFO()); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 2); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[1], ISO15765, CAN_29BIT_ID | TX_MSG_TYPE, 0, 4 + 48, 0, "\x18\xda\xef\xf1""AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXX", LINE_INFO()); - } - - //Check MF tx can be sent along side of a periodic message. 29 bit. Good Filter. NoPadding. STD address. Long STmin, checks that MF tx and periodic TX don't break each other. - TEST_METHOD(J2534_ISO15765_SuccessTx_29b_Filter_NoPad_STD_SLOWMF_WithPeriodicMsg) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - write_ioctl(chanid, LOOPBACK, TRUE, LINE_INFO()); - auto p = getPanda(500); - - //Timing diagram of this test. - //* is a periodic msg transfer; F is first frame, L is Flow control, C is Consecutive Frame. - // *~~~~~~~*~~~~~~~*~~~~~~~* (The alignment here is unimportant. The exact order is not checked. - //F C----C----C----C----C----C (100 ms between Cs) - // L - - auto msgid = J2534_start_periodic_msg_checked(chanid, ISO15765, CAN_29BIT_ID, 6, 0, "\x18\xda\xef\xf1""HI", 130, LINE_INFO()); - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 4 + 48, 0, "\x18\xda\xef\xf1""AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXX", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 2); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x02""HI", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[1], 0, 0x18DAEFF1, TRUE, FALSE, "\x10\x30""AABBCC", LINE_INFO()); - - Assert::IsTrue(p->can_send(0x18DAF1EF, TRUE, (const uint8_t*)"\x30\x06\x64", 3, panda::PANDA_CAN1), _T("Panda send says it failed."), LINE_INFO()); - - Timer t_permsg = Timer(); - Timer t_MFmsg = Timer(); - unsigned int MFframesReceived = 0; - unsigned int PeriodicMsgReceived = 1; //Because of the first panda_recv_loop above. - std::array const mfMsgExpectedParts{ "\x21""DDEEFFG", "\x22""GHHIIJJ", "\x23""KKLLMMN", "\x24""NOOPPQQ", "\x25""RRSSTTU", "\x26""UVVWWXX" }; - - while (TRUE) { - std::vectormsg_recv = p->can_recv(); - for (auto msg : msg_recv) { - if (msg.is_receipt) continue; - if ((msg.dat[0] & 0xf0) == 0x20) { - Assert::AreEqual(mfMsgExpectedParts[MFframesReceived], std::string((const char*)msg.dat, msg.len), _T("Got wrong part of MF msg."), LINE_INFO()); - MFframesReceived++; - t_MFmsg.reset(); - } else if (std::string((const char*)msg.dat, msg.len) == "\x02HI") { - PeriodicMsgReceived++; - t_permsg.reset(); - } else { - Assert::IsTrue(FALSE, _T("Got impossible message. Something is very wrong. Check other tests."), LINE_INFO()); - } - } - - if (MFframesReceived >= 6) break; - Assert::IsTrue(300 > t_permsg.getTimePassed(), _T("Timed out waiting for periodic msessage frame."), LINE_INFO()); - Assert::IsTrue(300 > t_MFmsg.getTimePassed(), _T("Timed out waiting for multiframe msessage frame."), LINE_INFO()); - - if (msg_recv.size() == 0) - Sleep(10); - } - - //Stop the periodic message and grab any data it may have sent since we last checked. - //Not sure if this is needed. - Assert::AreEqual(STATUS_NOERROR, PassThruStopPeriodicMsg(chanid, msgid), _T("Failed to delete filter."), LINE_INFO()); - auto extra_panda_msg = panda_recv_loop_loose(p, 0, 200); - for (auto msg : extra_panda_msg) { - if (std::string((const char*)msg.dat, msg.len) == "\x02HI") { - PeriodicMsgReceived++; - Logger::WriteMessage("Received extra periodic message."); - } else { - Assert::IsTrue(FALSE, _T("Got impossible message. Something is very wrong. Check other tests."), LINE_INFO()); - } - } - - Assert::IsTrue(PeriodicMsgReceived > 3, _T("Did not receive enough periodic messages. Likely canceled or delayed."), LINE_INFO()); - - std::ostringstream stringStream; - stringStream << "PeriodicMsgReceived = " << PeriodicMsgReceived << std::endl; - Logger::WriteMessage(stringStream.str().c_str()); - - unsigned int periodicTxIndicationCount = 0; - unsigned int TxIndicationCount = 0; - auto j2534_msg_recv = j2534_recv_loop(chanid, 2 + (PeriodicMsgReceived * 2)); - for (int i = 0; i < PeriodicMsgReceived + 1; i++) { - check_J2534_can_msg(j2534_msg_recv[(i * 2) + 0], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - switch (j2534_msg_recv[(i * 2) + 1].DataSize) { - case 4 + 2: - check_J2534_can_msg(j2534_msg_recv[(i * 2) + 1], ISO15765, CAN_29BIT_ID | TX_MSG_TYPE, 0, 4 + 2, 0, "\x18\xda\xef\xf1""HI", LINE_INFO()); - break; - case 4 + 48: - check_J2534_can_msg(j2534_msg_recv[(i * 2) + 1], ISO15765, CAN_29BIT_ID | TX_MSG_TYPE, 0, 4 + 48, 0, "\x18\xda\xef\xf1""AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXX", LINE_INFO()); - break; - default: - Assert::IsTrue(FALSE, _T("Got unexpected data!"), LINE_INFO()); - } - } - - Assert::AreNotEqual(PeriodicMsgReceived, periodicTxIndicationCount, _T("Wrong number of periodic msgs reported by passthru device."), LINE_INFO()); - Assert::AreNotEqual(1, TxIndicationCount, _T("Wrong number of TX msgs reported by passthru device."), LINE_INFO()); - } - - ///////////////////// Tests checking things break or recover during send/receive ///////////////////// - - //Check rx FAILS when frame is dropped. 29 bit. Good Filter. NoPadding. STD address. Multi Frame. - TEST_METHOD(J2534_ISO15765_FailRx_29b_Filter_NoPad_STD_FFCF_DropFrame) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - auto p = getPanda(500); - - //Send first frame, then check we get a flow control frame - auto panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x10\x13""ninete", 8, 1, LINE_INFO()); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, std::string("\x30\x00\x00", 3), LINE_INFO()); - - //Check first frame is registered with J2534 - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | START_OF_MESSAGE, 0, 4, 0, "\x18\xda\xf1\xef", LINE_INFO()); - - //Send the rest of the message - //Missing the 2nd frame "\x21""en byte" - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x22""s here", 7, 0, LINE_INFO()); - - //Check J2534 DOES NOT construct the incomplete message - j2534_recv_loop(chanid, 0); - } - - //Check rx ignores frames that arrive out of order. 29 bit. Good Filter. NoPadding. STD address. Multi Frame. - TEST_METHOD(J2534_ISO15765_PassRx_29b_Filter_NoPad_STD_FFCF_FrameNumSkip) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - auto p = getPanda(500); - - //Send first frame, then check we get a flow control frame - auto panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x10\x13""ABCDEF", 8, 1, LINE_INFO()); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, std::string("\x30\x00\x00", 3), LINE_INFO()); - - //Check first frame is registered with J2534 - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | START_OF_MESSAGE, 0, 4, 0, "\x18\xda\xf1\xef", LINE_INFO()); - - //Send the rest of the message - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x22""XXXXXX", 7, 0, LINE_INFO()); - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x21""GHIJKLM", 8, 0, LINE_INFO()); - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x23""ZZZZZZ", 7, 0, LINE_INFO()); - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x22""NOPQRS", 7, 0, LINE_INFO()); - - //Check J2534 constructa the complete message from the correctly numbered frames. - j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID, 0, 4 + 0x13, 4 + 0x13, "\x18\xda\xf1\xef""ABCDEFGHIJKLMNOPQRS", LINE_INFO()); - } - - //Check Single Frame rx RESETS ongoing multiframe transmission. 29 bit. Good Filter. NoPadding. STD address. Multi Frame. - TEST_METHOD(J2534_ISO15765_PassRx_29b_Filter_NoPad_STD_SFRxResetsMFRx) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - auto p = getPanda(500); - - //Send first frame, then check we get a flow control frame - auto panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x10\x13""ABCDEF", 8, 1, LINE_INFO()); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, std::string("\x30\x00\x00", 3), LINE_INFO()); - - //Check first frame is registered with J2534 - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | START_OF_MESSAGE, 0, 4, 0, "\x18\xda\xf1\xef", LINE_INFO()); - - //Send the next part of the message multi message - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x21""GHIJKLM", 8, 0, LINE_INFO()); - - //ABORTING MESSAGE - //Send a NEW single frame message and check the J2534 device gets it (but not the original message it was receiving. - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x06""ABC123", 7, 0, LINE_INFO()); - j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID, 0, 10, 10, "\x18\xda\xf1\xef""ABC123", LINE_INFO()); - - //Resume sending the old message, and check th eJ2534 device didn't get a message. - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x22""NOPQRS", 7, 0, LINE_INFO()); - j2534_recv_loop(chanid, 0); - } - - //The documentation says that a s ingle channel can not send and receive messages trhough a - //single conversation (flow control filter) at the same time. However, the required behavior - //when this is detected is not described. This test was my best understanding of how it was - //wanted, but I no longer see the point. For now I am disabling it. - /*//Check Single Frame tx RESETS ongoing multiframe rx transmission. 29 bit. Good Filter. NoPadding. STD address. Multi Frame. - TEST_METHOD(J2534_ISO15765_PassRx_29b_Filter_NoPad_STD_SFTxResetsMFRx) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - auto p = getPanda(500); - - //Send first frame, then check we get a flow control frame - auto panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x10\x13""ABCDEF", 8, 1, LINE_INFO()); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, std::string("\x30\x00\x00", 3), LINE_INFO()); - - //Check first frame is registered with J2534 - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | START_OF_MESSAGE, 0, 4, 0, "\x18\xda\xf1\xef", LINE_INFO()); - - //Send the next part of the message multi message - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x21""GHIJKLM", 8, 0, LINE_INFO()); - j2534_recv_loop(chanid, 0); - - //ABORTING MESSAGE - //Send a NEW single frame message and check the J2534 device gets it (but not the original message it was receiving. - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 11, 0, "\x18\xda\xef\xf1""TX_TEST", LINE_INFO()); - j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - - panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x07""TX_TEST", LINE_INFO()); - /////////////////////////// - - //Resume sending the old message, and check th eJ2534 device didn't get a message. - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x22""NOPQRS", 7, 0, LINE_INFO()); - j2534_recv_loop(chanid, 0); - }*/ - - //TODO check rx is cleared by tx (multi). Or not.... read above note. - - //Check multiframe rx RESETS ongoing multiframe transmission. 29 bit. Good Filter. NoPadding. STD address. Multi Frame. - TEST_METHOD(J2534_ISO15765_PassRx_29b_Filter_NoPad_STD_FFCF_MFRxResetsMFRx) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - auto p = getPanda(500); - - //Send first frame, then check we get a flow control frame - auto panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x10\x13""ABCDEF", 8, 1, LINE_INFO()); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, std::string("\x30\x00\x00", 3), LINE_INFO()); - - //Check first frame is registered with J2534 - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | START_OF_MESSAGE, 0, 4, 0, "\x18\xda\xf1\xef", LINE_INFO()); - - //Send the next part of the multi message A - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x21""GHIJKLM", 8, 0, LINE_INFO()); - - //ABORTING MESSAGE A - //Send a NEW multi frame message (B) and check the J2534 device gets it (but not the original message it was receiving. - //Send first frame, then check we get a flow control frame - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x10\x13""ninete", 8, 1, LINE_INFO()); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, std::string("\x30\x00\x00", 3), LINE_INFO()); - - //Check first frame is registered with J2534 - j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | START_OF_MESSAGE, 0, 4, 0, "\x18\xda\xf1\xef", LINE_INFO()); - - //Send the rest of the message - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x21""en byte", 8, 0, LINE_INFO()); - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x22""s here", 7, 0, LINE_INFO()); - - //Check J2534 constructed the whole message - j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID, 0, 4 + 0x13, 4 + 0x13, "\x18\xda\xf1\xef""nineteen bytes here", LINE_INFO()); - //////////////////////// End sending B - - //Resume sending the multi message A, and check th eJ2534 device didn't get a message. - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x22""NOPQRS", 7, 0, LINE_INFO()); - j2534_recv_loop(chanid, 0); - } - - //Check rx fails gracefully if final CF of MF rx is too short. 29 bit. Good Filter. NoPadding. STD address. Multi Frame. - TEST_METHOD(J2534_ISO15765_FailRxFinalCFTooShort_29b_Filter_NoPad_STD_FFCF) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - auto p = getPanda(500); - - //Send first frame, then check we get a flow control frame - auto panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x10\x13""ninete", 8, 1, LINE_INFO()); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, std::string("\x30\x00\x00", 3), LINE_INFO()); - - //Check first frame is registered with J2534 - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | START_OF_MESSAGE, 0, 4, 0, "\x18\xda\xf1\xef", LINE_INFO()); - - //Send the rest of the message - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x21""en byte", 8, 0, LINE_INFO()); - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x22""s her", 6, 0, LINE_INFO()); //The transaction should reset here because more data could have been sent. - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x23""e", 2, 0, LINE_INFO()); - - //Check J2534 constructed the whole message - j2534_msg_recv = j2534_recv_loop(chanid, 0); - } - - //Check rx fails gracefully if first frame is too short. 29 bit. Good Filter. NoPadding. STD address. Multi Frame. - TEST_METHOD(J2534_ISO15765_FailRxFFTooShort_29b_Filter_NoPad_STD_FFCF) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - auto p = getPanda(500); - - //Send first frame, then check we get a flow control frame. The transaction should reset immediately because more data could have been sent in this frame. - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x10\x13""ninet", 7, 0, LINE_INFO()); - j2534_recv_loop(chanid, 0); - - //Send the rest of the message - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x21""een byt", 8, 0, LINE_INFO()); - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x22""es here", 8, 0, LINE_INFO()); - - //Check J2534 constructed the whole message - j2534_recv_loop(chanid, 0); - } - - //Check MF tx will stop upon receiving a flow control ABORT. 29 bit. Good Filter. NoPadding. STD address. Large STmin, then abort, then send SF. - TEST_METHOD(J2534_ISO15765_SuccessTx_29b_Filter_NoPad_STD__MF_FCAbort_SF) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - write_ioctl(chanid, LOOPBACK, TRUE, LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 4 + 48, 0, "\x18\xda\xef\xf1""AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXX", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x10\x30""AABBCC", LINE_INFO()); - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x02\x20", 3, 2, LINE_INFO());//Start a conversation. FC timeout is 32 ms. - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x21""DDEEFFG", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[1], 0, 0x18DAEFF1, TRUE, FALSE, "\x22""GHHIIJJ", LINE_INFO()); - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x32\x0\x0", 3, 0, LINE_INFO());//Abort the conversation - - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 4 + 4, 0, "\x18\xda\xef\xf1""SUP!", LINE_INFO()); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 2); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[1], ISO15765, CAN_29BIT_ID | TX_MSG_TYPE, 0, 4 + 4, 0, "\x18\xda\xef\xf1""SUP!", LINE_INFO()); - } - - //Check MF tx will stop upon receiving a flow control ABORT during valid blocksize. 29 bit. Good Filter. NoPadding. STD address. Large STmin, then mid tx abort, then send SF. - TEST_METHOD(J2534_ISO15765_SuccessTx_29b_Filter_NoPad_STD__MF_FCMixTXAbort_SF) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - write_ioctl(chanid, LOOPBACK, TRUE, LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 4 + 48, 0, "\x18\xda\xef\xf1""AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXX", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x10\x30""AABBCC", LINE_INFO()); - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x06\x7F", 3, 1, LINE_INFO(), 200);//Start a conversation. FC timeout is 127 ms. - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x21""DDEEFFG", LINE_INFO()); - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x32\x0\x0", 3, 0, LINE_INFO());//Abort the conversation - panda_recv_loop(p, 0, 200); - - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 4 + 4, 0, "\x18\xda\xef\xf1""SUP!", LINE_INFO()); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 2); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[1], ISO15765, CAN_29BIT_ID | TX_MSG_TYPE, 0, 4 + 4, 0, "\x18\xda\xef\xf1""SUP!", LINE_INFO()); - } - - //Check slow tx can be stalled past timeout with CF WAIT frames. 29 bit. Good Filter. NoPadding. STD address. MF tx that would timeout without WAIT frames. - TEST_METHOD(J2534_ISO15765_SuccessTx_29b_Filter_NoPad_STD_MFWithWaitFrames) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - write_ioctl(chanid, LOOPBACK, TRUE, LINE_INFO()); - write_ioctl(chanid, ISO15765_WFT_MAX, 10, LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 4 + 48, 0, "\x18\xda\xef\xf1""AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXX", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x10\x30""AABBCC", LINE_INFO()); - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x02\x40", 3, 2, LINE_INFO(), 3000);//Start a conversation. FC timeout is 250 ms. - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x21""DDEEFFG", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[1], 0, 0x18DAEFF1, TRUE, FALSE, "\x22""GHHIIJJ", LINE_INFO()); - - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x31\x0\x0", 3, 0, LINE_INFO(), 100);//Delay the conversation. - Sleep(100); - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x31\x0\x0", 3, 0, LINE_INFO(), 100);//Delay the conversation. - Sleep(100); - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x31\x0\x0", 3, 0, LINE_INFO(), 100);//Delay the conversation. - Sleep(100); - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x31\x0\x0", 3, 0, LINE_INFO(), 100);//Delay the conversation. - Sleep(100); - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x0\x0", 3, 4, LINE_INFO(), 3000);//Start a conversation. FC timeout is 250 ms. - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x23""KKLLMMN", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[1], 0, 0x18DAEFF1, TRUE, FALSE, "\x24""NOOPPQQ", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[2], 0, 0x18DAEFF1, TRUE, FALSE, "\x25""RRSSTTU", LINE_INFO());//Some of these should fail to recv if there is an issue. - check_panda_can_msg(panda_msg_recv[3], 0, 0x18DAEFF1, TRUE, FALSE, "\x26""UVVWWXX", LINE_INFO()); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 2); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[1], ISO15765, CAN_29BIT_ID | TX_MSG_TYPE, 0, 4 + 48, 0, "\x18\xda\xef\xf1""AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXX", LINE_INFO()); - } - - //Check slow tx can be stalled past timeout with CF WAIT frames during normal TX. 29 bit. Good Filter. NoPadding. STD address. Stalling working MF tx. - TEST_METHOD(J2534_ISO15765_SuccessTx_29b_Filter_NoPad_STD_MFWithMidTXWaitFrames) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - write_ioctl(chanid, LOOPBACK, TRUE, LINE_INFO()); - write_ioctl(chanid, ISO15765_WFT_MAX, 10, LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 4 + 48, 0, "\x18\xda\xef\xf1""AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXX", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x10\x30""AABBCC", LINE_INFO()); - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x06\x64", 3, 2, LINE_INFO(), 120);//Start a conversation. STmin 100. FC timeout is 250 ms. - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x21""DDEEFFG", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[1], 0, 0x18DAEFF1, TRUE, FALSE, "\x22""GHHIIJJ", LINE_INFO()); - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x31\x0\x0", 3, 0, LINE_INFO(), 100);//Delay the conversation. - Sleep(100); - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x31\x0\x0", 3, 0, LINE_INFO(), 100);//Delay the conversation. - Sleep(100); - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x31\x0\x0", 3, 0, LINE_INFO(), 100);//Delay the conversation. - Sleep(100); - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x31\x0\x0", 3, 0, LINE_INFO(), 100);//Delay the conversation. - Sleep(100); - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x0\x0", 3, 4, LINE_INFO(), 3000);//Start a conversation. FC timeout is 250 ms. - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x23""KKLLMMN", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[1], 0, 0x18DAEFF1, TRUE, FALSE, "\x24""NOOPPQQ", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[2], 0, 0x18DAEFF1, TRUE, FALSE, "\x25""RRSSTTU", LINE_INFO());//Some of these should fail to recv if there is an issue. - check_panda_can_msg(panda_msg_recv[3], 0, 0x18DAEFF1, TRUE, FALSE, "\x26""UVVWWXX", LINE_INFO()); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 2); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[1], ISO15765, CAN_29BIT_ID | TX_MSG_TYPE, 0, 4 + 48, 0, "\x18\xda\xef\xf1""AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXX", LINE_INFO()); - } - - //Check that too many WAIT frames will abort the transfer. 29 bit. Good Filter. NoPadding. STD address. Too much stalling causes abort. - TEST_METHOD(J2534_ISO15765_SuccessTx_29b_Filter_NoPad_STD_MFTooManyWaitFrames) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID, 4, "\xff\xff\xff\xff", "\x18\xda\xf1\xef", "\x18\xda\xef\xf1", LINE_INFO()); - write_ioctl(chanid, LOOPBACK, TRUE, LINE_INFO()); - write_ioctl(chanid, ISO15765_WFT_MAX, 2, LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 4 + 48, 0, "\x18\xda\xef\xf1""AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXX", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x10\x30""AABBCC", LINE_INFO()); - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x02\x64", 3, 2, LINE_INFO(), 120);//Start a conversation. STmin 100. FC timeout is 250 ms. - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x21""DDEEFFG", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[1], 0, 0x18DAEFF1, TRUE, FALSE, "\x22""GHHIIJJ", LINE_INFO()); - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x31\x0\x0", 3, 0, LINE_INFO(), 100);//Delay the conversation. - Sleep(100); - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x31\x0\x0", 3, 0, LINE_INFO(), 100);//Delay the conversation. - Sleep(100); - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x02\x64", 3, 2, LINE_INFO(), 120);//Resume the conversation. - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x23""KKLLMMN", LINE_INFO()); - check_panda_can_msg(panda_msg_recv[1], 0, 0x18DAEFF1, TRUE, FALSE, "\x24""NOOPPQQ", LINE_INFO()); - - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x31\x0\x0", 3, 0, LINE_INFO(), 100);//Delay the conversation. - Sleep(100); - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x31\x0\x0", 3, 0, LINE_INFO(), 100);//Delay the conversation. - Sleep(100); - - //Should not resume because the conversation has been delayed too long. - panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x30\x0\x0", 3, 0, LINE_INFO(), 300); - - //Send a SF message to check the tubes are not clogged. - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID, 0, 4 + 4, 0, "\x18\xda\xef\xf1""SUP!", LINE_INFO()); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 2); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | TX_INDICATION, 0, 4, 0, "\x18\xda\xef\xf1", LINE_INFO()); - check_J2534_can_msg(j2534_msg_recv[1], ISO15765, CAN_29BIT_ID | TX_MSG_TYPE, 0, 4 + 4, 0, "\x18\xda\xef\xf1""SUP!", LINE_INFO()); - } - - ///////////////////// Tests checking things actually send/receive. Ext 5 byte Addressing ///////////////////// - - //Check rx passes with filter. 29 bit. Good Filter. NoPadding. EXT address. Single Frame. - TEST_METHOD(J2534_ISO15765_SuccessRx_29b_Filter_NoPad_EXT_SF) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID | ISO15765_ADDR_TYPE, 5, "\xff\xff\xff\xff\xff", "\x18\xda\xf1\xef\x13", "\x18\xda\xef\xf1\x13", LINE_INFO()); - auto p = getPanda(500); - - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x13""\x06""ABC123", 8, 0, LINE_INFO()); - - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | ISO15765_ADDR_TYPE, 0, 11, 11, "\x18\xda\xf1\xef\x13""ABC123", LINE_INFO()); - } - - //Check tx passes with filter. 29 bit. Good Filter. NoPadding. EXT address. Single Frame. - TEST_METHOD(J2534_ISO15765_SuccessTx_29b_Filter_NoPad_EXT_SF) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID | ISO15765_ADDR_TYPE, 5, "\xff\xff\xff\xff\xff", "\x18\xda\xf1\xef\x13", "\x18\xda\xef\xf1\x13", LINE_INFO()); - auto p = getPanda(500); - - J2534_send_msg_checked(chanid, ISO15765, 0, CAN_29BIT_ID | ISO15765_ADDR_TYPE, 0, 11, 0, "\x18\xda\xef\xf1\x13""DERP!!", LINE_INFO()); - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | TX_INDICATION | ISO15765_ADDR_TYPE, 0, 5, 0, "\x18\xda\xef\xf1\x13", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, "\x13""\x06""DERP!!", LINE_INFO()); - } - - //Check rx passes with filter. 29 bit. Good Filter. NoPadding. EXT address. Multi Frame. - TEST_METHOD(J2534_ISO15765_SuccessRx_29b_Filter_NoPad_EXT_FFCF) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID | ISO15765_ADDR_TYPE, 5, "\xff\xff\xff\xff\xff", "\x18\xda\xf1\xef\x13", "\x18\xda\xef\xf1\x13", LINE_INFO()); - auto p = getPanda(500); - - //Send first frame, then check we get a flow control frame - Assert::IsTrue(p->can_send(0x18DAF1EF, TRUE, (const uint8_t*)"\x13""\x10\x13""ninet", 8, panda::PANDA_CAN1), _T("Panda send says it failed."), LINE_INFO()); - - //Check first frame is registered with J2534 - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | START_OF_MESSAGE | ISO15765_ADDR_TYPE, 0, 5, 0, "\x18\xda\xf1\xef\x13", LINE_INFO()); - - auto panda_msg_recv = panda_recv_loop(p, 2); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAF1EF, TRUE, TRUE, std::string("\x13""\x10\x13""ninet", 8), LINE_INFO()); - check_panda_can_msg(panda_msg_recv[1], 0, 0x18DAEFF1, TRUE, FALSE, std::string("\x13""\x30\x00\x00", 4), LINE_INFO()); - - //Send the rest of the message - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x13""\x21""een by", 8, 0, LINE_INFO()); - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x13""\x22""tes he", 8, 0, LINE_INFO()); - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x13""\x23""re", 8, 0, LINE_INFO()); - - //Check J2534 constructed the whole message - j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | ISO15765_ADDR_TYPE, 0, 5 + 0x13, 5 + 0x13, "\x18\xda\xf1\xef\x13""nineteen bytes here", LINE_INFO()); - } - - //Check tx passes with filter. 29 bit. Good Filter. NoPadding. EXT address. Multi Frame. - /*TEST_METHOD(J2534_ISO15765_SuccessTx_29b_Filter_NoPad_EXT_FFCF) - { //TODO when TX works with flow control}*/ - - ///////////////////// Tests checking things break or recover during send/receive. Ext 5 byte Addressing ///////////////////// - - //Check rx FAILS when frame is dropped. 29 bit. Good Filter. NoPadding. STD address. Multi Frame. - TEST_METHOD(J2534_ISO15765_FailRx_29b_Filter_NoPad_EXT_FFCF_DropFrame) - { - auto chanid = J2534_open_and_connect("", ISO15765, CAN_29BIT_ID, 500000, LINE_INFO()); - J2534_set_flowctrl_filter(chanid, CAN_29BIT_ID | ISO15765_ADDR_TYPE, 5, "\xff\xff\xff\xff\xff", "\x18\xda\xf1\xef\x13", "\x18\xda\xef\xf1\x13", LINE_INFO()); - auto p = getPanda(500); - - //Send first frame, then check we get a flow control frame - auto panda_msg_recv = checked_panda_send(p, 0x18DAF1EF, TRUE, "\x13\x10\x13""ninet", 8, 1, LINE_INFO()); - check_panda_can_msg(panda_msg_recv[0], 0, 0x18DAEFF1, TRUE, FALSE, std::string("\x13\x30\x00\x00", 4), LINE_INFO()); - - //Check first frame is registered with J2534 - auto j2534_msg_recv = j2534_recv_loop(chanid, 1); - check_J2534_can_msg(j2534_msg_recv[0], ISO15765, CAN_29BIT_ID | START_OF_MESSAGE | ISO15765_ADDR_TYPE, 0, 5, 0, "\x18\xda\xf1\xef\x13", LINE_INFO()); - - //Send the rest of the message - //Missing the 2nd frame "\x13""\x21""een by" - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x13""\x22""tes he", 8, 0, LINE_INFO()); - checked_panda_send(p, 0x18DAF1EF, TRUE, "\x13""\x23""re", 8, 0, LINE_INFO()); - - //Check J2534 DOES NOT construct the incomplete message - j2534_recv_loop(chanid, 0); - } - - bool didopen = FALSE; - unsigned long devid; - - unsigned long open_dev(const char* name, long assert_err = STATUS_NOERROR, TCHAR* failmsg = _T("Failed to open device.")) { - unsigned int res = PassThruOpen((void*)name, &devid); - if (res == STATUS_NOERROR) didopen = TRUE; - return res; - } - - unsigned long J2534_open_and_connect(const char* name, unsigned long ProtocolID, unsigned long Flags, unsigned long bps, const __LineInfo* pLineInfo = NULL) { - unsigned long chanid; - Assert::AreEqual(STATUS_NOERROR, open_dev(name), _T("Failed to open device."), pLineInfo); - Assert::AreEqual(STATUS_NOERROR, PassThruConnect(devid, ProtocolID, Flags, bps, &chanid), _T("Failed to open channel."), pLineInfo); - write_ioctl(chanid, LOOPBACK, FALSE, LINE_INFO()); // DISABLE J2534 ECHO/LOOPBACK - return chanid; - } - - }; -} diff --git a/panda/drivers/windows/pandaJ2534DLL Test/pandaJ2534DLL Test.vcxproj b/panda/drivers/windows/pandaJ2534DLL Test/pandaJ2534DLL Test.vcxproj deleted file mode 100644 index f19c743461d661..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL Test/pandaJ2534DLL Test.vcxproj +++ /dev/null @@ -1,122 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {7912F978-B48C-4C5D-8BFD-5D1E22158E47} - Win32Proj - pandaJ2534DLLTest - 10.0.16299.0 - Tests - - - - DynamicLibrary - true - v141 - Unicode - false - - - DynamicLibrary - false - v141 - true - Unicode - false - - - - - - - - - - - - - - - true - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - true - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - - Use - Level3 - Disabled - $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);$(SolutionDir) - WIN32;_DEBUG;%(PreprocessorDefinitions) - true - - - Windows - $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib - - - - - Level3 - Use - MaxSpeed - true - true - $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);$(SolutionDir) - WIN32;NDEBUG;%(PreprocessorDefinitions) - true - - - Windows - true - true - $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib - - - - - - - - - - - - - - - - - Create - Create - - - - - - - - {96e0e646-ee76-444d-9a77-a0cd7f781deb} - - - {a2bb18a5-f26b-48d6-bbb5-b83d64473c77} - - - - - - \ No newline at end of file diff --git a/panda/drivers/windows/pandaJ2534DLL Test/pandaJ2534DLL Test.vcxproj.filters b/panda/drivers/windows/pandaJ2534DLL Test/pandaJ2534DLL Test.vcxproj.filters deleted file mode 100644 index 476ce458d35534..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL Test/pandaJ2534DLL Test.vcxproj.filters +++ /dev/null @@ -1,63 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/panda/drivers/windows/pandaJ2534DLL Test/panda_tests.cpp b/panda/drivers/windows/pandaJ2534DLL Test/panda_tests.cpp deleted file mode 100644 index 51b0bfcf2f60b5..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL Test/panda_tests.cpp +++ /dev/null @@ -1,187 +0,0 @@ -#include "stdafx.h" -#include "panda_shared/panda.h" -#include "TestHelpers.h" - -#include - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; -using namespace panda; - -namespace pandaTestNative -{ - TEST_CLASS(DeviceDiscovery) - { - public: - - TEST_METHOD(Panda_DevDiscover_ListDevices) - { - auto pandas_available = Panda::listAvailablePandas(); - Assert::IsTrue(pandas_available.size() > 0, _T("No pandas were found.")); - for (auto sn : pandas_available) { - Assert::IsTrue(sn.size() == 24, _T("panda Serial Number not 24 characters long.")); - } - } - - TEST_METHOD(Panda_DevDiscover_OpenFirstDevice) - { - auto pandas_available = Panda::listAvailablePandas(); - Assert::IsTrue(pandas_available.size() > 0, _T("No pandas were found.")); - - auto p1 = Panda::openPanda(pandas_available[0]); - Assert::IsFalse(p1 == nullptr, _T("Could not open panda.")); - } - - TEST_METHOD(Panda_DevDiscover_OpenDeviceNoName) - { - auto pandas_available = Panda::listAvailablePandas(); - Assert::IsTrue(pandas_available.size() > 0, _T("No pandas were found.")); - - auto p1 = Panda::openPanda(""); - Assert::IsFalse(p1 == nullptr, _T("Could not open panda.")); - Assert::IsTrue(p1->get_usb_sn() == pandas_available[0], _T("Could not open panda.")); - } - - TEST_METHOD(Panda_DevDiscover_OpenDeviceUnavailable) - { - auto p1 = Panda::openPanda("ZZZZZZZZZZZZZZZZZZZZZZZZ"); - Assert::IsTrue(p1 == nullptr, _T("Invalid sn still worked.")); - } - - TEST_METHOD(Panda_DevDiscover_WillNotOpenAlreadyOpenedDevice) - { - auto pandas_available = Panda::listAvailablePandas(); - Assert::IsTrue(pandas_available.size() > 0, _T("No pandas were found.")); - - auto p1 = Panda::openPanda(pandas_available[0]); - Assert::IsFalse(p1 == nullptr, _T("Could not open panda.")); - - auto p2 = Panda::openPanda(pandas_available[0]); - Assert::IsTrue(p2 == nullptr, _T("Opened an already open panda.")); - } - - TEST_METHOD(Panda_DevDiscover_OpenedDeviceNotListed) - { - auto pandas_available = Panda::listAvailablePandas(); - Assert::IsTrue(pandas_available.size() > 0, _T("No pandas were found.")); - - auto p1 = Panda::openPanda(pandas_available[0]); - Assert::IsFalse(p1 == nullptr, _T("Could not open panda.")); - - auto pandas_available2 = Panda::listAvailablePandas(); - for (auto sn : pandas_available2) { - Assert::IsFalse(p1->get_usb_sn() == sn, _T("Opened panda appears in list of available pandas.")); - } - - } - }; - - TEST_CLASS(CANOperations) - { - public: - - TEST_METHOD(Panda_CAN_Echo) - { - auto p0 = getPanda(500, TRUE); - - uint32_t addr = 0xAA; - bool is_29b = FALSE; - uint8_t candata[8]; - - for (auto canbus : { PANDA_CAN1, PANDA_CAN2, PANDA_CAN3 }) { - uint8_t len = (rand() % 8) + 1; - for (size_t i = 0; i < len; i++) - candata[i] = rand() % 256; - - p0->can_send(addr, is_29b, candata, len, canbus); - Sleep(10); - - auto can_msgs = p0->can_recv(); - - Assert::AreEqual(2, can_msgs.size(), _T("Received the wrong number of CAN messages."), LINE_INFO()); - - for (auto msg : can_msgs) { - Assert::IsTrue(msg.addr == addr, _T("Wrong addr.")); - Assert::IsTrue(msg.bus == canbus, _T("Wrong bus.")); - Assert::IsTrue(msg.len == len, _T("Wrong len.")); - Assert::AreEqual(memcmp(msg.dat, candata, msg.len), 0, _T("Received CAN data not equal")); - for (int i = msg.len; i < 8; i++) - Assert::IsTrue(msg.dat[i] == 0, _T("Received CAN data not trailed by 0s")); - } - - Assert::IsTrue(can_msgs[0].is_receipt, _T("Didn't get receipt.")); - Assert::IsFalse(can_msgs[1].is_receipt, _T("Didn't get echo.")); - } - } - - TEST_METHOD(Panda_CAN_ChangeBaud) - { - auto p0 = getPanda(250); - auto p1 = getPanda(500); - - p0->can_send(0xAA, FALSE, (const uint8_t*)"\x1\x2\x3\x4\x5\x6\x7\x8", 8, panda::PANDA_CAN1); - panda_recv_loop(p0, 0); - panda_recv_loop(p1, 0); - - p0->set_can_speed_kbps(panda::PANDA_CAN1, 500); - - auto panda_msg_recv = panda_recv_loop(p0, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0xAA, FALSE, TRUE, "\x1\x2\x3\x4\x5\x6\x7\x8", LINE_INFO()); - panda_msg_recv = panda_recv_loop(p1, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0xAA, FALSE, FALSE, "\x1\x2\x3\x4\x5\x6\x7\x8", LINE_INFO()); - - ////////////////// - - p0->set_can_speed_kbps(panda::PANDA_CAN1, 250); - p0->can_send(0xC4, FALSE, (const uint8_t*)"\xA\B\xC\xD\xE\xF\x10\x11", 8, panda::PANDA_CAN1); - panda_recv_loop(p0, 0); - panda_recv_loop(p1, 0); - - p1->set_can_speed_kbps(panda::PANDA_CAN1, 250); - - panda_msg_recv = panda_recv_loop(p0, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0xC4, FALSE, TRUE, "\xA\B\xC\xD\xE\xF\x10\x11", LINE_INFO()); - panda_msg_recv = panda_recv_loop(p1, 1); - check_panda_can_msg(panda_msg_recv[0], 0, 0xC4, FALSE, FALSE, "\xA\B\xC\xD\xE\xF\x10\x11", LINE_INFO()); - } - - TEST_METHOD(Panda_CAN_ClearClears) - { - auto p0 = getPanda(500, TRUE); - p0->can_send(0xAA, FALSE, (const uint8_t*)"\x0\x1\x2\x3\x4\x5\x6\x7", 8, panda::PANDA_CAN1); - Sleep(100); - p0->can_clear(PANDA_CAN_RX); - - auto can_msgs = p0->can_recv(); - Assert::IsTrue(can_msgs.size() == 0, _T("Received messages after a clear.")); - } - }; - - TEST_CLASS(SerialOperations) - { - public: - - TEST_METHOD(Panda_LIN_Echo) - { - auto p0 = getPanda(500); - - for (auto lin_port : { SERIAL_LIN1, SERIAL_LIN2 }) { - p0->serial_clear(lin_port); - - for (int i = 0; i < 10; i++) { - uint8_t len = (rand() % LIN_MSG_MAX_LEN) + 1; - std::string lindata; - lindata.reserve(len); - - for (size_t j = 0; j < len; j++) - lindata += (const char)(rand() % 256); - - p0->serial_write(lin_port, lindata.c_str(), len); - Sleep(10); - - auto retdata = p0->serial_read(lin_port); - Assert::AreEqual(retdata, lindata); - } - } - } - }; -} \ No newline at end of file diff --git a/panda/drivers/windows/pandaJ2534DLL Test/stdafx.cpp b/panda/drivers/windows/pandaJ2534DLL Test/stdafx.cpp deleted file mode 100644 index 84a1f0aaf34351..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL Test/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// pandaJ2534DLL Test.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/panda/drivers/windows/pandaJ2534DLL Test/stdafx.h b/panda/drivers/windows/pandaJ2534DLL Test/stdafx.h deleted file mode 100644 index 1ac8bd8dcc42c9..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL Test/stdafx.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "targetver.h" - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files: -#include -#include - -// Headers for CppUnitTest -#include "CppUnitTest.h" -#include //Used for formatting in TestHelpers.cpp -#include -#include diff --git a/panda/drivers/windows/pandaJ2534DLL Test/targetver.h b/panda/drivers/windows/pandaJ2534DLL Test/targetver.h deleted file mode 100644 index 87c0086de751ba..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL Test/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/panda/drivers/windows/pandaJ2534DLL/Action.h b/panda/drivers/windows/pandaJ2534DLL/Action.h deleted file mode 100644 index e9721c2eda9f29..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/Action.h +++ /dev/null @@ -1,57 +0,0 @@ -#pragma once -#include - -#include "J2534Frame.h" - -class J2534Connection; - -/** -An Action represents a unit of work that can be scheduled for execution at a later time. -Actions are not guaranteed to be run at their specified time, but a best effort is made. -An Action will never execute early, but can execute later depending on what is in the -queus. -Many different operations are based on this base class. Instead of making a thread, -consider if the work can be offloaded to the Task Queue. -*/ -class Action -{ -public: - Action( - std::weak_ptr connection, - std::chrono::microseconds delay - ) : connection(connection), delay(delay) { }; - - Action( - std::weak_ptr connection - ) : connection(connection), delay(std::chrono::microseconds(0)) { }; - - //The function called by the task runner when this action is to be invoked. - virtual void execute() = 0; - - //Reschedule this Action for now(). - void scheduleImmediate() { - expire = std::chrono::steady_clock::now(); - } - - //Reschedule this Action relative to its last expiration time. - void scheduleDelay() { - expire += this->delay; - } - - //Reschedule this action {delay} after now(). - void scheduleImmediateDelay() { - expire = std::chrono::steady_clock::now() + this->delay; - } - - //Reschedule this Action based on a specific base time. - void schedule(std::chrono::time_point starttine, BOOL adddelayed) { - this->expire = starttine; - if (adddelayed) - expire += this->delay; - } - - std::weak_ptr connection; - std::chrono::microseconds delay; - //The timestamp at which point this Action is ready to be executed. - std::chrono::time_point expire; -}; diff --git a/panda/drivers/windows/pandaJ2534DLL/J2534Connection.cpp b/panda/drivers/windows/pandaJ2534DLL/J2534Connection.cpp deleted file mode 100644 index aa364b0f8a323c..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/J2534Connection.cpp +++ /dev/null @@ -1,283 +0,0 @@ -#include "stdafx.h" -#include "J2534Connection.h" -#include "Timer.h" - -J2534Connection::J2534Connection( - std::shared_ptr panda_dev, - unsigned long ProtocolID, - unsigned long Flags, - unsigned long BaudRate -) : panda_dev(panda_dev), ProtocolID(ProtocolID), Flags(Flags), BaudRate(BaudRate), port(0) { } - -unsigned long J2534Connection::validateTxMsg(PASSTHRU_MSG* msg) { - if (msg->DataSize < this->getMinMsgLen() || msg->DataSize > this->getMaxMsgLen()) - return ERR_INVALID_MSG; - return STATUS_NOERROR; -} - -long J2534Connection::PassThruReadMsgs(PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout) { - //Timeout of 0 means return immediately. Non zero means WAIT for that time then return. Dafuk. - long err_code = STATUS_NOERROR; - Timer t = Timer(); - - unsigned long msgnum = 0; - while (msgnum < *pNumMsgs) { - if (Timeout > 0 && t.getTimePassed() >= Timeout) { - err_code = ERR_TIMEOUT; - break; - } - - //Synchronized won't work where we have to break out of a loop - messageRxBuff_mutex.lock(); - if (this->messageRxBuff.empty()) { - messageRxBuff_mutex.unlock(); - if (Timeout == 0) - break; - Sleep(2); - continue; - } - - auto msg_in = this->messageRxBuff.front(); - this->messageRxBuff.pop(); - messageRxBuff_mutex.unlock(); - - PASSTHRU_MSG *msg_out = &pMsg[msgnum++]; - msg_out->ProtocolID = this->ProtocolID; - msg_out->DataSize = msg_in.Data.size(); - memcpy(msg_out->Data, msg_in.Data.c_str(), msg_in.Data.size()); - msg_out->Timestamp = msg_in.Timestamp; - msg_out->RxStatus = msg_in.RxStatus; - msg_out->ExtraDataIndex = msg_in.ExtraDataIndex; - msg_out->TxFlags = 0; - if (msgnum == *pNumMsgs) break; - } - - if (msgnum == 0) - err_code = ERR_BUFFER_EMPTY; - *pNumMsgs = msgnum; - return err_code; -} - -long J2534Connection::PassThruWriteMsgs(PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout) { - //There doesn't seem to be much reason to implement the timeout here. - for (int msgnum = 0; msgnum < *pNumMsgs; msgnum++) { - PASSTHRU_MSG* msg = &pMsg[msgnum]; - if (msg->ProtocolID != this->ProtocolID) { - *pNumMsgs = msgnum; - return ERR_MSG_PROTOCOL_ID; - } - - auto retcode = this->validateTxMsg(msg); - if (retcode != STATUS_NOERROR) { - *pNumMsgs = msgnum; - return retcode; - } - - auto msgtx = this->parseMessageTx(*pMsg); - if (msgtx != nullptr) //Nullptr is supported for unimplemented connection types. - this->schedultMsgTx(std::dynamic_pointer_cast(msgtx)); - } - return STATUS_NOERROR; -} - -//The docs say that a device has to support 10 periodic messages, though more is ok. -//It is easier to store them on the connection, so 10 per connection it is. -long J2534Connection::PassThruStartPeriodicMsg(PASSTHRU_MSG *pMsg, unsigned long *pMsgID, unsigned long TimeInterval) { - if (pMsg->DataSize < getMinMsgLen() || pMsg->DataSize > getMaxMsgSingleFrameLen()) return ERR_INVALID_MSG; - if (pMsg->ProtocolID != this->ProtocolID) return ERR_MSG_PROTOCOL_ID; - if (TimeInterval < 5 || TimeInterval > 65535) return ERR_INVALID_TIME_INTERVAL; - - for (int i = 0; i < this->periodicMessages.size(); i++) { - if (periodicMessages[i] != nullptr) continue; - - *pMsgID = i; - auto msgtx = this->parseMessageTx(*pMsg); - if (msgtx != nullptr) { - periodicMessages[i] = std::make_shared(std::chrono::microseconds(TimeInterval*1000), msgtx); - periodicMessages[i]->scheduleImmediate(); - if (auto panda_dev = this->getPandaDev()) { - panda_dev->insertActionIntoTaskList(periodicMessages[i]); - } - } - return STATUS_NOERROR; - } - return ERR_EXCEEDED_LIMIT; -} - -long J2534Connection::PassThruStopPeriodicMsg(unsigned long MsgID) { - if (MsgID >= this->periodicMessages.size() || this->periodicMessages[MsgID] == nullptr) - return ERR_INVALID_MSG_ID; - this->periodicMessages[MsgID]->cancel(); - this->periodicMessages[MsgID] = nullptr; - return STATUS_NOERROR; -} - -long J2534Connection::PassThruStartMsgFilter(unsigned long FilterType, PASSTHRU_MSG *pMaskMsg, PASSTHRU_MSG *pPatternMsg, - PASSTHRU_MSG *pFlowControlMsg, unsigned long *pFilterID) { - for (int i = 0; i < this->filters.size(); i++) { - if (filters[i] == nullptr) { - try { - auto newfilter = std::make_shared(this, FilterType, pMaskMsg, pPatternMsg, pFlowControlMsg); - for (int check_idx = 0; check_idx < filters.size(); check_idx++) { - if (filters[check_idx] == nullptr) continue; - if (filters[check_idx] == newfilter) { - filters[i] = nullptr; - return ERR_NOT_UNIQUE; - } - } - *pFilterID = i; - filters[i] = newfilter; - return STATUS_NOERROR; - } catch (int e) { - return e; - } - } - } - return ERR_EXCEEDED_LIMIT; -} - -long J2534Connection::PassThruStopMsgFilter(unsigned long FilterID) { - if (FilterID >= this->filters.size() || this->filters[FilterID] == nullptr) - return ERR_INVALID_FILTER_ID; - this->filters[FilterID] = nullptr; - return STATUS_NOERROR; -} - -long J2534Connection::PassThruIoctl(unsigned long IoctlID, void *pInput, void *pOutput) { - return STATUS_NOERROR; -} - -long J2534Connection::init5b(SBYTE_ARRAY* pInput, SBYTE_ARRAY* pOutput) { return ERR_FAILED; } -long J2534Connection::initFast(PASSTHRU_MSG* pInput, PASSTHRU_MSG* pOutput) { return ERR_FAILED; } -long J2534Connection::clearTXBuff() { - if (auto panda_ps = this->panda_dev.lock()) { - synchronized(staged_writes_lock) { - this->txbuff = {}; - panda_ps->panda->can_clear(panda::PANDA_CAN1_TX); - } - } - return STATUS_NOERROR; -} -long J2534Connection::clearRXBuff() { - if (auto panda_ps = this->panda_dev.lock()) { - synchronized(messageRxBuff_mutex) { - this->messageRxBuff = {}; - panda_ps->panda->can_clear(panda::PANDA_CAN_RX); - } - } - return STATUS_NOERROR; -} -long J2534Connection::clearPeriodicMsgs() { - for (int i = 0; i < this->periodicMessages.size(); i++) { - if (periodicMessages[i] == nullptr) continue; - this->periodicMessages[i]->cancel(); - this->periodicMessages[i] = nullptr; - } - - return STATUS_NOERROR; -} -long J2534Connection::clearMsgFilters() { - for (auto& filter : this->filters) filter = nullptr; - return STATUS_NOERROR; -} - -void J2534Connection::setBaud(unsigned long baud) { - this->BaudRate = baud; -} - -void J2534Connection::schedultMsgTx(std::shared_ptr msgout) { - if (auto panda_ps = this->panda_dev.lock()) { - synchronized(staged_writes_lock) { - this->txbuff.push(msgout); - panda_ps->registerConnectionTx(shared_from_this()); - } - } -} - -void J2534Connection::rescheduleExistingTxMsgs() { - if (auto panda_ps = this->panda_dev.lock()) { - synchronized(staged_writes_lock) { - panda_ps->unstallConnectionTx(shared_from_this()); - } - } -} - -//Works well as long as the protocol doesn't support flow control. -void J2534Connection::processMessage(const J2534Frame& msg) { - FILTER_RESULT filter_res = FILTER_RESULT_NEUTRAL; - - for (auto filter : this->filters) { - if (filter == nullptr) continue; - FILTER_RESULT current_check_res = filter->check(msg); - if (current_check_res == FILTER_RESULT_BLOCK) return; - if (current_check_res == FILTER_RESULT_PASS) filter_res = FILTER_RESULT_PASS; - } - - if (filter_res == FILTER_RESULT_PASS) { - addMsgToRxQueue(msg); - } -} - -void J2534Connection::processIOCTLSetConfig(unsigned long Parameter, unsigned long Value) { - switch (Parameter) { - case DATA_RATE: // 5-500000 - this->setBaud(Value); - break; - case LOOPBACK: // 0 (OFF), 1 (ON) [0] - this->loopback = (Value != 0); - break; - case ISO15765_WFT_MAX: - break; - case NODE_ADDRESS: // J1850PWM Related (Not supported by panda). HDS requires these to 'work'. - case NETWORK_LINE: - case P1_MIN: // A bunch of stuff relating to ISO9141 and ISO14230 that the panda - case P1_MAX: // currently doesn't support. Don't let HDS know we can't use these. - case P2_MIN: - case P2_MAX: - case P3_MIN: - case P3_MAX: - case P4_MIN: - case P4_MAX: - case W0: - case W1: - case W2: - case W3: - case W4: - case W5: - case TIDLE: - case TINIL: - case TWUP: - case PARITY: - case T1_MAX: // SCI related options. The panda does not appear to support this - case T2_MAX: - case T3_MAX: - case T4_MAX: - case T5_MAX: - break; // Just smile and nod. - default: - printf("Got unknown SET code %X\n", Parameter); - } - - // reserved parameters usually mean special equiptment is required - if (Parameter >= 0x20) { - throw ERR_NOT_SUPPORTED; - } -} - -unsigned long J2534Connection::processIOCTLGetConfig(unsigned long Parameter) { - switch (Parameter) { - case DATA_RATE: - return this->getBaud(); - case LOOPBACK: - return this->loopback; - break; - case BIT_SAMPLE_POINT: - return 80; - case SYNC_JUMP_WIDTH: - return 15; - default: - // HDS rarely reads off values through ioctl GET_CONFIG, but it often - // just wants the call to pass without erroring, so just don't do anything. - printf("Got unknown code %X\n", Parameter); - } -} diff --git a/panda/drivers/windows/pandaJ2534DLL/J2534Connection.h b/panda/drivers/windows/pandaJ2534DLL/J2534Connection.h deleted file mode 100644 index 70f25a1063f09f..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/J2534Connection.h +++ /dev/null @@ -1,141 +0,0 @@ -#pragma once -#include "panda_shared/panda.h" -#include "J2534_v0404.h" -#include "synchronize.h" -#include "J2534Frame.h" -#include "PandaJ2534Device.h" -#include "J2534MessageFilter.h" -#include "MessagePeriodic.h" - -class J2534Frame; -class Action; -class PandaJ2534Device; -class J2534MessageFilter; - -#define check_bmask(num, mask)(((num) & mask) == mask) - -/** -Class representing a generic J2534 Connection created by PassThruConnect, -and is associated with a channelID given to the J2534 API user. -Subclasses implement specific J2534 supported protocols. -*/ -class J2534Connection : public std::enable_shared_from_this { - friend class PandaJ2534Device; - -public: - J2534Connection( - std::shared_ptr panda_dev, - unsigned long ProtocolID, - unsigned long Flags, - unsigned long BaudRate - ); - virtual ~J2534Connection() {}; - - //J2534 API functions - - virtual long PassThruReadMsgs(PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout); - long PassThruWriteMsgs(PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout); - virtual long PassThruStartPeriodicMsg(PASSTHRU_MSG *pMsg, unsigned long *pMsgID, unsigned long TimeInterval); - virtual long PassThruStopPeriodicMsg(unsigned long MsgID); - - virtual long PassThruStartMsgFilter(unsigned long FilterType, PASSTHRU_MSG *pMaskMsg, PASSTHRU_MSG *pPatternMsg, - PASSTHRU_MSG *pFlowControlMsg, unsigned long *pFilterID); - - virtual long PassThruStopMsgFilter(unsigned long FilterID); - virtual long PassThruIoctl(unsigned long IoctlID, void *pInput, void *pOutput); - - //Functions for parsing messages to be send with PassThruWriteMsgs. - - virtual unsigned long validateTxMsg(PASSTHRU_MSG* msg); - virtual std::shared_ptr parseMessageTx(PASSTHRU_MSG& msg) { return nullptr; }; - - //IOCTL functions - - long init5b(SBYTE_ARRAY* pInput, SBYTE_ARRAY* pOutput); - long initFast(PASSTHRU_MSG* pInput, PASSTHRU_MSG* pOutput); - long clearTXBuff(); - long clearRXBuff(); - long clearPeriodicMsgs(); - long clearMsgFilters(); - - virtual void setBaud(unsigned long baud); - - unsigned long getBaud() { - return this->BaudRate; - } - - unsigned long getProtocol() { - return this->ProtocolID; - }; - - virtual bool isProtoCan() { - return FALSE; - } - - //Port is used in a protocol specific way to differentiate tranceivers. - unsigned long getPort() { - return this->port; - } - - virtual void processIOCTLSetConfig(unsigned long Parameter, unsigned long Value); - - virtual unsigned long processIOCTLGetConfig(unsigned long Parameter); - - //Called when the passthru device has received a message for this connection - //Loopback messages are processed separately. - virtual void processMessage(const J2534Frame& msg); - - //Limitations on message size. Override in every subclass. - - virtual unsigned long getMinMsgLen() { - return 1; - } - - virtual unsigned long getMaxMsgLen() { - return 4128; - } - - virtual unsigned long getMaxMsgSingleFrameLen() { - return 12; - } - - //Add an Action to the Task Queue for future processing. - //The task should be set its expire time before being submitted. - void schedultMsgTx(std::shared_ptr msgout); - - void rescheduleExistingTxMsgs(); - - std::shared_ptr getPandaDev() { - if (auto panda_dev_sp = this->panda_dev.lock()) - return panda_dev_sp; - return nullptr; - } - - //Add a message to the queue read by PassThruReadMsgs(). - void addMsgToRxQueue(const J2534Frame& frame) { - synchronized(messageRxBuff_mutex) { - messageRxBuff.push(frame); - } - } - - bool loopback = FALSE; - -protected: - unsigned long ProtocolID; - unsigned long Flags; - unsigned long BaudRate; - unsigned long port; - - std::weak_ptr panda_dev; - - Mutex messageRxBuff_mutex; - std::queue messageRxBuff; - - std::array, 10> filters; - std::queue> txbuff; - - std::array, 10> periodicMessages; - -private: - Mutex staged_writes_lock; -}; diff --git a/panda/drivers/windows/pandaJ2534DLL/J2534Connection_CAN.cpp b/panda/drivers/windows/pandaJ2534DLL/J2534Connection_CAN.cpp deleted file mode 100644 index 342616900d0e39..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/J2534Connection_CAN.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "stdafx.h" -#include "J2534Connection_CAN.h" -#include "MessageTx_CAN.h" -#include "Timer.h" - -J2534Connection_CAN::J2534Connection_CAN( - std::shared_ptr panda_dev, - unsigned long ProtocolID, - unsigned long Flags, - unsigned long BaudRate - ) : J2534Connection(panda_dev, ProtocolID, Flags, BaudRate) { - this->port = 0; - - if (BaudRate % 100 || BaudRate < 10000 || BaudRate > 5000000) - throw ERR_INVALID_BAUDRATE; - - panda_dev->panda->set_can_speed_cbps(panda::PANDA_CAN1, BaudRate/100); -}; - -unsigned long J2534Connection_CAN::validateTxMsg(PASSTHRU_MSG* msg) { - if ((msg->DataSize < this->getMinMsgLen() || msg->DataSize > this->getMaxMsgLen() || - (val_is_29bit(msg->TxFlags) != this->_is_29bit() && !check_bmask(this->Flags, CAN_ID_BOTH)))) - return ERR_INVALID_MSG; - return STATUS_NOERROR; -} - -std::shared_ptr J2534Connection_CAN::parseMessageTx(PASSTHRU_MSG& msg) { - return std::dynamic_pointer_cast(std::make_shared(shared_from_this(), msg)); -} - -void J2534Connection_CAN::setBaud(unsigned long BaudRate) { - if (auto panda_dev = this->getPandaDev()) { - if (BaudRate % 100 || BaudRate < 10000 || BaudRate > 5000000) - throw ERR_NOT_SUPPORTED; - - panda_dev->panda->set_can_speed_cbps(panda::PANDA_CAN1, (uint16_t)(BaudRate / 100)); - return J2534Connection::setBaud(BaudRate); - } else { - throw ERR_DEVICE_NOT_CONNECTED; - } -} diff --git a/panda/drivers/windows/pandaJ2534DLL/J2534Connection_CAN.h b/panda/drivers/windows/pandaJ2534DLL/J2534Connection_CAN.h deleted file mode 100644 index 3971351eea369a..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/J2534Connection_CAN.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#include "J2534Connection.h" -#include "panda_shared/panda.h" - -#define val_is_29bit(num) check_bmask(num, CAN_29BIT_ID) - -class J2534Connection_CAN : public J2534Connection { -public: - J2534Connection_CAN( - std::shared_ptr panda_dev, - unsigned long ProtocolID, - unsigned long Flags, - unsigned long BaudRate - ); - - virtual unsigned long validateTxMsg(PASSTHRU_MSG* msg); - - virtual std::shared_ptr parseMessageTx(PASSTHRU_MSG& pMsg); - - virtual void setBaud(unsigned long baud); - - virtual unsigned long getMinMsgLen() { - return 4; - } - - virtual unsigned long getMaxMsgLen() { - return 12; - } - - virtual unsigned long getMaxMsgSingleFrameLen() { - return 12; - } - - virtual bool isProtoCan() { - return TRUE; - } - - bool _is_29bit() { - return (this->Flags & CAN_29BIT_ID) == CAN_29BIT_ID; - } - -}; \ No newline at end of file diff --git a/panda/drivers/windows/pandaJ2534DLL/J2534Connection_ISO15765.cpp b/panda/drivers/windows/pandaJ2534DLL/J2534Connection_ISO15765.cpp deleted file mode 100644 index a83f6f433135f2..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/J2534Connection_ISO15765.cpp +++ /dev/null @@ -1,232 +0,0 @@ -#include "stdafx.h" -#include "J2534Connection_ISO15765.h" -#include "Timer.h" -#include "constants_ISO15765.h" -#include - -J2534Connection_ISO15765::J2534Connection_ISO15765( - std::shared_ptr panda_dev, - unsigned long ProtocolID, - unsigned long Flags, - unsigned long BaudRate -) : J2534Connection(panda_dev, ProtocolID, Flags, BaudRate), wftMax(0) { - this->port = 0; - - if (BaudRate % 100 || BaudRate < 10000 || BaudRate > 5000000) - throw ERR_INVALID_BAUDRATE; - - panda_dev->panda->set_can_speed_cbps(panda::PANDA_CAN1, (uint16_t)(BaudRate / 100)); -} - -unsigned long J2534Connection_ISO15765::validateTxMsg(PASSTHRU_MSG* msg) { - if ((msg->DataSize < this->getMinMsgLen() + (msg_is_extaddr(msg) ? 1 : 0) || - msg->DataSize > this->getMaxMsgLen() + (msg_is_extaddr(msg) ? 1 : 0) || - (val_is_29bit(msg->TxFlags) != this->_is_29bit() && !check_bmask(this->Flags, CAN_ID_BOTH)))) - return ERR_INVALID_MSG; - - int fid = get_matching_out_fc_filter_id(std::string((const char*)msg->Data, msg->DataSize), msg->TxFlags, 0xFFFFFFFF); - if (msg->DataSize > getMaxMsgSingleFrameLen() && fid == -1) return ERR_NO_FLOW_CONTROL; //11 bytes (4 for CANid, 7 payload) is max length of input frame. - - return STATUS_NOERROR; -} - -std::shared_ptr J2534Connection_ISO15765::parseMessageTx(PASSTHRU_MSG& msg) { - int fid = get_matching_out_fc_filter_id(std::string((const char*)msg.Data, msg.DataSize), msg.TxFlags, 0xFFFFFFFF); - if (msg.DataSize > getMaxMsgSingleFrameLen() && fid == -1) 1; - - return std::dynamic_pointer_cast( - std::make_shared(shared_from_this(), msg, (fid == -1) ? nullptr : this->filters[fid]) - ); -} - -//https://happilyembedded.wordpress.com/2016/02/15/can-multiple-frame-transmission/ -void J2534Connection_ISO15765::processMessage(const J2534Frame& msg) { - if (msg.ProtocolID != CAN) return; - - int fid = get_matching_in_fc_filter_id(msg, this->Flags); - if (fid == -1) return; - - auto filter = this->filters[fid]; - bool is_ext_addr = check_bmask(filter->flags, ISO15765_ADDR_TYPE); - uint8_t addrlen = is_ext_addr ? 5 : 4; - - switch (msg_get_type(msg, addrlen)) { - case FRAME_FLOWCTRL: - { - if (this->txbuff.size() == 0) - return; - if (msg.Data.size() < addrlen + 3) return; - uint8_t flow_status = msg.Data[addrlen] & 0x0F; - uint8_t block_size = msg.Data[addrlen + 1]; - uint8_t st_min = msg.Data[addrlen + 2]; - - auto txConvo = std::static_pointer_cast(this->txbuff.front()); - switch (flow_status) { - case FLOWCTRL_CONTINUE: { - if (st_min > 0xF9) break; - if (st_min >= 0xf1 && st_min <= 0xf9) { - txConvo->flowControlContinue(block_size, std::chrono::microseconds((st_min & 0x0F) * 100)); - } else if(st_min <= 0x7f) { - txConvo->flowControlContinue(block_size, std::chrono::microseconds(st_min * 1000)); - } else { - break; - } - txConvo->scheduleImmediate(); - this->rescheduleExistingTxMsgs(); - break; - } - case FLOWCTRL_WAIT: - txConvo->flowControlWait(this->wftMax); - break; - case FLOWCTRL_ABORT: - txConvo->flowControlAbort(); - break; - } - break; - } - case FRAME_SINGLE: - { - this->rxConversations[fid] = nullptr; //Reset any current transaction. - - if (is_ext_addr) { - if ((msg.Data[5] & 0x0F) > 6) return; - } else { - if ((msg.Data[4] & 0x0F) > 7) return; - } - - J2534Frame outframe(ISO15765, msg.RxStatus, 0, msg.Timestamp); - if (msg.Data.size() != 8 && check_bmask(this->Flags, ISO15765_FRAME_PAD)) - outframe.RxStatus |= ISO15765_PADDING_ERROR; - if (is_ext_addr) - outframe.RxStatus |= ISO15765_ADDR_TYPE; - outframe.Data = msg.Data.substr(0, addrlen) + msg.Data.substr(addrlen + 1, msg.Data[addrlen]); - outframe.ExtraDataIndex = outframe.Data.size(); - - addMsgToRxQueue(outframe); - break; - } - case FRAME_FIRST: - { - if (msg.Data.size() < 12) { - //A frame was received that could have held more data. - //No examples of this protocol show that happening, so - //it will be assumed that it is grounds to reset rx. - this->rxConversations[fid] = nullptr; - return; - } - - J2534Frame outframe(ISO15765, msg.RxStatus | START_OF_MESSAGE, 0, msg.Timestamp); - if (is_ext_addr) - outframe.RxStatus |= ISO15765_ADDR_TYPE; - outframe.Data = msg.Data.substr(0, addrlen); - - addMsgToRxQueue(outframe); - - this->rxConversations[fid] = std::make_shared( - ((msg.Data[addrlen] & 0x0F) << 8) | msg.Data[addrlen + 1], - msg.Data.substr(addrlen + 2, 12 - (addrlen + 2)), - msg.RxStatus, filter); - - //TODO maybe the flow control should also be scheduled in the TX list. - //Doing it this way because the filter can be 5 bytes in ext address mode. - std::string flowfilter = filter->get_flowctrl(); - uint32_t flow_addr = (((uint8_t)flowfilter[0]) << 24) | ((uint8_t)(flowfilter[1]) << 16) | ((uint8_t)(flowfilter[2]) << 8) | ((uint8_t)flowfilter[3]); - - std::string flowstrlresp; - if (flowfilter.size() > 4) - flowstrlresp += flowfilter[4]; - flowstrlresp += std::string("\x30\x00\x00", 3); - if (check_bmask(filter->flags, ISO15765_FRAME_PAD)) { - flowstrlresp += std::string(8 - flowstrlresp.size(), '\x00'); - } - - if (auto panda_dev_sp = this->panda_dev.lock()) { - panda_dev_sp->panda->can_send(flow_addr, val_is_29bit(msg.RxStatus), (const uint8_t *)flowstrlresp.c_str(), (uint8_t)flowstrlresp.size(), panda::PANDA_CAN1); - } - break; - } - case FRAME_CONSEC: - { - auto& convo = this->rxConversations[fid]; - if (convo == nullptr) return; - - if (!convo->rx_add_frame(msg.Data[addrlen], (is_ext_addr ? 6 : 7), msg.Data.substr(addrlen + 1))) { - //Delete this conversation. - convo = nullptr; - return; - } - - std::string final_msg; - if (convo->flush_result(final_msg)) { - convo = nullptr; - J2534Frame outframe(ISO15765, msg.RxStatus, 0, msg.Timestamp); - if (is_ext_addr) - outframe.RxStatus |= ISO15765_ADDR_TYPE; - outframe.Data = msg.Data.substr(0, addrlen) + final_msg; - outframe.ExtraDataIndex = outframe.Data.size(); - - addMsgToRxQueue(outframe); - } - break; - } - } -} - -void J2534Connection_ISO15765::setBaud(unsigned long BaudRate) { - if (auto panda_dev = this->getPandaDev()) { - if (BaudRate % 100 || BaudRate < 10000 || BaudRate > 5000000) - throw ERR_NOT_SUPPORTED; - - panda_dev->panda->set_can_speed_cbps(panda::PANDA_CAN1, (uint16_t)(BaudRate / 100)); - return J2534Connection::setBaud(BaudRate); - } else { - throw ERR_DEVICE_NOT_CONNECTED; - } -} - -long J2534Connection_ISO15765::PassThruStartMsgFilter(unsigned long FilterType, PASSTHRU_MSG *pMaskMsg, PASSTHRU_MSG *pPatternMsg, - PASSTHRU_MSG *pFlowControlMsg, unsigned long *pFilterID) { - - if (FilterType != FLOW_CONTROL_FILTER) return ERR_INVALID_FILTER_ID; - return J2534Connection::PassThruStartMsgFilter(FilterType, pMaskMsg, pPatternMsg, pFlowControlMsg, pFilterID); -} - -int J2534Connection_ISO15765::get_matching_out_fc_filter_id(const std::string& msgdata, unsigned long flags, unsigned long flagmask) { - for (unsigned int i = 0; i < this->filters.size(); i++) { - if (this->filters[i] == nullptr) continue; - auto filter = this->filters[i]->get_flowctrl(); - if (filter == msgdata.substr(0, filter.size()) && - (this->filters[i]->flags & flagmask) == (flags & flagmask)) - return i; - } - return -1; -} - -int J2534Connection_ISO15765::get_matching_in_fc_filter_id(const J2534Frame& msg, unsigned long flagmask) { - for (unsigned int i = 0; i < this->filters.size(); i++) { - if (this->filters[i] == nullptr) continue; - if (this->filters[i]->check(msg) == FILTER_RESULT_MATCH && - (this->filters[i]->flags & flagmask) == (msg.RxStatus & flagmask)) - return i; - } - return -1; -} - -void J2534Connection_ISO15765::processIOCTLSetConfig(unsigned long Parameter, unsigned long Value) { - switch (Parameter) { - case ISO15765_WFT_MAX: - this->wftMax = Value; - break; - default: - J2534Connection::processIOCTLSetConfig(Parameter, Value); - } -} - -unsigned long J2534Connection_ISO15765::processIOCTLGetConfig(unsigned long Parameter) { - switch (Parameter) { - case ISO15765_WFT_MAX: - return this->wftMax; - default: - return J2534Connection::processIOCTLGetConfig(Parameter); - } -} diff --git a/panda/drivers/windows/pandaJ2534DLL/J2534Connection_ISO15765.h b/panda/drivers/windows/pandaJ2534DLL/J2534Connection_ISO15765.h deleted file mode 100644 index beb9f012e09976..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/J2534Connection_ISO15765.h +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once -#include -#include "J2534Connection.h" -#include "J2534Connection_CAN.h" -#include "MessageTx_ISO15765.h" -#include "MessageRx.h" - -class MessageTx_ISO15765; - -typedef struct { - std::string dispatched_msg; - std::string remaining_payload; -} PRESTAGED_WRITE; - -class J2534Connection_ISO15765 : public J2534Connection { -public: - J2534Connection_ISO15765( - std::shared_ptr panda_dev, - unsigned long ProtocolID, - unsigned long Flags, - unsigned long BaudRate - ); - - virtual long PassThruStartMsgFilter(unsigned long FilterType, PASSTHRU_MSG * pMaskMsg, PASSTHRU_MSG * pPatternMsg, PASSTHRU_MSG * pFlowControlMsg, unsigned long * pFilterID); - - int get_matching_out_fc_filter_id(const std::string & msgdata, unsigned long flags, unsigned long flagmask); - - int get_matching_in_fc_filter_id(const J2534Frame& msg, unsigned long flagmask); - - virtual unsigned long validateTxMsg(PASSTHRU_MSG* msg); - - virtual std::shared_ptr parseMessageTx(PASSTHRU_MSG& msg); - - virtual void processMessage(const J2534Frame& msg); - - virtual void setBaud(unsigned long baud); - - virtual void processIOCTLSetConfig(unsigned long Parameter, unsigned long Value); - - virtual unsigned long processIOCTLGetConfig(unsigned long Parameter); - - virtual unsigned long getMinMsgLen() { - return 4; - } - - virtual unsigned long getMaxMsgLen() { - return 4099; - }; - - virtual unsigned long getMaxMsgSingleFrameLen() { - return 11; - } - - virtual bool _is_29bit() { - return (this->Flags & CAN_29BIT_ID) == CAN_29BIT_ID; - } - - virtual bool isProtoCan() { - return TRUE; - } - -private: - std::array, 10> rxConversations; - unsigned int wftMax; -}; diff --git a/panda/drivers/windows/pandaJ2534DLL/J2534Frame.h b/panda/drivers/windows/pandaJ2534DLL/J2534Frame.h deleted file mode 100644 index 2549216b6f1fac..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/J2534Frame.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once -#include "J2534_v0404.h" -#include "panda_shared/panda.h" - -/*A move convenient container for J2534 Messages than the static buffer provided by default.*/ -class J2534Frame { -public: - J2534Frame(unsigned long ProtocolID, unsigned long RxStatus=0, unsigned long TxFlags=0, unsigned long Timestamp=0) : - ProtocolID(ProtocolID), RxStatus(RxStatus), TxFlags(TxFlags), Timestamp(Timestamp), ExtraDataIndex(0), Data("") { }; - - J2534Frame(const panda::PANDA_CAN_MSG& msg_in) { - ProtocolID = CAN; - ExtraDataIndex = msg_in.len + 4; - Data.reserve(msg_in.len + 4); - Data += msg_in.addr >> 24; - Data += (msg_in.addr >> 16) & 0xFF; - Data += (msg_in.addr >> 8) & 0xFF; - Data += msg_in.addr & 0xFF; - Data += std::string((char*)&msg_in.dat, msg_in.len); - Timestamp = msg_in.recv_time; - RxStatus = (msg_in.addr_29b ? CAN_29BIT_ID : 0) | - (msg_in.is_receipt ? TX_MSG_TYPE : 0); - } - - J2534Frame(const PASSTHRU_MSG& msg) { - this->ProtocolID = msg.ProtocolID; - this->RxStatus = msg.RxStatus; - this->TxFlags = msg.TxFlags; - this->Timestamp = msg.Timestamp; - this->ExtraDataIndex = msg.ExtraDataIndex; - this->Data = std::string((const char*)msg.Data, msg.DataSize); - } - - J2534Frame() { - this->ProtocolID = 0; - this->RxStatus = 0; - this->TxFlags = 0; - this->Timestamp = 0; - this->ExtraDataIndex = 0; - } - - unsigned long ProtocolID; - unsigned long RxStatus; - unsigned long TxFlags; - unsigned long Timestamp; - unsigned long ExtraDataIndex; - std::string Data; -}; \ No newline at end of file diff --git a/panda/drivers/windows/pandaJ2534DLL/J2534MessageFilter.cpp b/panda/drivers/windows/pandaJ2534DLL/J2534MessageFilter.cpp deleted file mode 100644 index 2d19e1f4e5a63a..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/J2534MessageFilter.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include "stdafx.h" -#include "J2534MessageFilter.h" -#include "J2534Frame.h" - -J2534MessageFilter::J2534MessageFilter( - J2534Connection *const conn, - unsigned int filtertype, - PASSTHRU_MSG *pMaskMsg, - PASSTHRU_MSG *pPatternMsg, - PASSTHRU_MSG *pFlowControlMsg -) : filtertype(filtertype), flags(0), conn(conn) { - switch (filtertype) { - case PASS_FILTER: - case BLOCK_FILTER: - if (pMaskMsg == NULL || pPatternMsg == NULL) - throw ERR_NULL_PARAMETER; - if (pFlowControlMsg != NULL) - throw ERR_INVALID_FILTER_ID; - if (pMaskMsg->DataSize != pPatternMsg->DataSize) - throw ERR_INVALID_MSG; - break; - case FLOW_CONTROL_FILTER: - if (conn->getProtocol() != ISO15765) throw ERR_MSG_PROTOCOL_ID; //CHECK - if (pFlowControlMsg == NULL || pMaskMsg == NULL || pPatternMsg == NULL) - throw ERR_NULL_PARAMETER; - break; - default: - throw ERR_INVALID_MSG; - } - - if (!(conn->getMinMsgLen() < pMaskMsg->DataSize || pMaskMsg->DataSize < conn->getMaxMsgLen())) - throw ERR_INVALID_MSG; - if (conn->getProtocol() != pMaskMsg->ProtocolID) - throw ERR_MSG_PROTOCOL_ID; - this->maskMsg = std::string((char*)pMaskMsg->Data, pMaskMsg->DataSize); - - if (!(conn->getMinMsgLen() < pPatternMsg->DataSize || pPatternMsg->DataSize < conn->getMaxMsgLen())) - throw ERR_INVALID_MSG; - if (conn->getProtocol() != pPatternMsg->ProtocolID) - throw ERR_MSG_PROTOCOL_ID; - this->patternMsg = std::string((char*)pPatternMsg->Data, pPatternMsg->DataSize); - if (this->maskMsg.size() != this->patternMsg.size()) - throw ERR_INVALID_MSG; - - if (pFlowControlMsg) { - if (!(conn->getMinMsgLen() < pFlowControlMsg->DataSize || pFlowControlMsg->DataSize < conn->getMaxMsgLen())) - throw ERR_INVALID_MSG; - if (conn->getProtocol() != pFlowControlMsg->ProtocolID) - throw ERR_MSG_PROTOCOL_ID; - if (pMaskMsg->TxFlags != pPatternMsg->TxFlags || pMaskMsg->TxFlags != pFlowControlMsg->TxFlags) - throw ERR_INVALID_MSG; - if(pFlowControlMsg->TxFlags & ~(ISO15765_FRAME_PAD | CAN_29BIT_ID | ISO15765_ADDR_TYPE)) - throw ERR_INVALID_MSG; - if ((pFlowControlMsg->TxFlags & ISO15765_ADDR_TYPE) == ISO15765_ADDR_TYPE) { - if(pFlowControlMsg->DataSize != 5) - throw ERR_INVALID_MSG; - } else { - if (pFlowControlMsg->DataSize != 4) - throw ERR_INVALID_MSG; - } - this->flowCtrlMsg = std::string((char*)pFlowControlMsg->Data, pFlowControlMsg->DataSize); - if (this->flowCtrlMsg.size() != this->patternMsg.size()) - throw ERR_INVALID_MSG; - this->flags = pFlowControlMsg->TxFlags; - } -} - -bool J2534MessageFilter::operator ==(const J2534MessageFilter &b) const { - if (this->filtertype != b.filtertype) return FALSE; - if (this->maskMsg != b.maskMsg) return FALSE; - if (this->patternMsg != b.patternMsg) return FALSE; - if (this->flowCtrlMsg != b.flowCtrlMsg) return FALSE; - if (this->flags != b.flags) return FALSE; - return TRUE; -} - -FILTER_RESULT J2534MessageFilter::check(const J2534Frame& msg) { - bool matches = TRUE; - if (msg.Data.size() < this->maskMsg.size()) { - matches = FALSE; - } else { - for (int i = 0; i < this->maskMsg.size(); i++) { - if (this->patternMsg[i] != (msg.Data[i] & this->maskMsg[i])) { - matches = FALSE; - break; - } - } - } - - switch (this->filtertype) { - case PASS_FILTER: - return matches ? FILTER_RESULT_PASS : FILTER_RESULT_NEUTRAL; - case BLOCK_FILTER: - return matches ? FILTER_RESULT_BLOCK: FILTER_RESULT_NEUTRAL; - case FLOW_CONTROL_FILTER: - return matches ? FILTER_RESULT_MATCH : FILTER_RESULT_NOMATCH; - default: - throw std::out_of_range("Filtertype should not be able to be anything but PASS, BLOCK, or FLOW_CONTROL"); - } -} - -std::string J2534MessageFilter::get_flowctrl() { - return std::string(this->flowCtrlMsg); -} diff --git a/panda/drivers/windows/pandaJ2534DLL/J2534MessageFilter.h b/panda/drivers/windows/pandaJ2534DLL/J2534MessageFilter.h deleted file mode 100644 index c5e9a68390b1bf..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/J2534MessageFilter.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once -#include "J2534_v0404.h" -#include "J2534Connection.h" -#include "J2534Frame.h" - -typedef enum { - FILTER_RESULT_BLOCK, - FILTER_RESULT_NEUTRAL, - FILTER_RESULT_PASS, - FILTER_RESULT_NOMATCH = FILTER_RESULT_BLOCK, - FILTER_RESULT_MATCH = FILTER_RESULT_PASS, -} FILTER_RESULT; - -//Forward declare -class J2534Connection; - -/* Represents a J2534 Message Filter created by PassThruStartMsgFilter. - -J2534 uses filters to sort out messages in a simple and sane way. Except for -flow control filters. J2534 v04.04 uses filters to manage 'conversations' in -protocols that support flow control like ISO15765. The whole solution is a -hack, and J2534 v05.00 greatly simplifies this concept. But we are using -v04.04 so, here we are. -*/ -class J2534MessageFilter { -public: - J2534MessageFilter( - J2534Connection *const conn, - unsigned int filtertype, - PASSTHRU_MSG *pMaskMsg, - PASSTHRU_MSG *pPatternMsg, - PASSTHRU_MSG *pFlowControlMsg - ); - - bool J2534MessageFilter::operator ==(const J2534MessageFilter &b) const; - - FILTER_RESULT check(const J2534Frame& msg); - std::string get_flowctrl(); - - unsigned long flags; - J2534Connection *const conn; -private: - unsigned int filtertype; - std::string maskMsg; - std::string patternMsg; - std::string flowCtrlMsg; -}; \ No newline at end of file diff --git a/panda/drivers/windows/pandaJ2534DLL/J2534_v0404.h b/panda/drivers/windows/pandaJ2534DLL/J2534_v0404.h deleted file mode 100644 index 7cccf6b429a515..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/J2534_v0404.h +++ /dev/null @@ -1,428 +0,0 @@ -// -// Copyright (c) 2015-2016 DashLogic, Inc. -// All Rights Reserved. -// -// http://www.dashlogic.com -// sales@dashlogic.com -// -// Redistribution and use in source and binary forms, with or without -// modification, including use for commercial purposes, are permitted -// provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in -// the documentation and/or other materials provided with the -// distribution. -// -// 3. Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// 4. Redistributions of any form whatsoever must retain the following -// acknowledgment: 'This product includes software developed by -// "DashLogic, Inc." (http://www.dashlogic.com/).' -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// - - -// -// Formatting: -// Indents: Use tabs only (1 tab per indent) -// Tab Size: 4 spaces -// -// File Revision: -// $Rev: 5216 $ -// $Date: 2016-03-15 09:32:34 -0600 (Tue, 15 Mar 2016) $ -// - -#pragma once - -#ifdef PANDAJ2534DLL_EXPORTS -#define PANDAJ2534DLL_API extern "C" __declspec(dllexport) -#else -#define PANDAJ2534DLL_API -//__declspec(dllimport) -#endif - -// -// Platform-specific Defines: -// -// PTAPI: Define this yourself if you want a specific calling -// convention or other modifiers on the Pass-Thru API -// functions. Typically, on Windows, PTAPI will be defined -// as WINAPI, which enables the __stdcall convention. -// -#define PTAPI __stdcall //WINAPI - -// -// J2534-1 v04.04 ProtocolID Values -// -#define J1850VPW 0x01 -#define J1850PWM 0x02 -#define ISO9141 0x03 -#define ISO14230 0x04 -#define CAN 0x05 -#define ISO15765 0x06 -#define SCI_A_ENGINE 0x07 -#define SCI_A_TRANS 0x08 -#define SCI_B_ENGINE 0x09 -#define SCI_B_TRANS 0x0A - - -// -// J2534-2 ProtocolID Values -// -#define J1850VPW_PS 0x00008000 -#define J1850PWM_PS 0x00008001 -#define ISO9141_PS 0x00008002 -#define ISO14230_PS 0x00008003 -#define CAN_PS 0x00008004 -#define ISO15765_PS 0x00008005 -#define J2610_PS 0x00008006 -#define SW_ISO15765_PS 0x00008007 -#define SW_CAN_PS 0x00008008 -#define GM_UART_PS 0x00008009 -#define CAN_CH1 0x00009000 -#define CAN_CH2 (CAN_CH1 + 1) -#define CAN_CH128 (CAN_CH1 + 127) -#define J1850VPW_CH1 0x00009080 -#define J1850VPW_CH2 (J1850VPW_CH1 + 1) -#define J1850VPW_CH128 (J1850VPW_CH1 + 127) -#define J1850PWM_CH1 0x00009160 -#define J1850PWM_CH2 (J1850PWM_CH1 + 1) -#define J1850PWM_CH128 (J1850PWM_CH1 + 127) -#define ISO9141_CH1 0x00009240 -#define ISO9141_CH2 (ISO9141_CH1 + 1) -#define ISO9141_CH128 (ISO9141_CH1 + 127) -#define ISO14230_CH1 0x00009320 -#define ISO14230_CH2 (ISO14230_CH1 + 1) -#define ISO14230_CH128 (ISO14230_CH1 + 127) -#define ISO15765_CH1 0x00009400 -#define ISO15765_CH2 (ISO15765_CH1 + 1) -#define ISO15765_CH128 (ISO15765_CH1 + 127) -#define SW_CAN_CAN_CH1 0x00009480 -#define SW_CAN_CAN_CH2 (SW_CAN_CAN_CH1 + 1) -#define SW_CAN_CAN_CH128 (SW_CAN_CAN_CH1 + 127) -#define SW_CAN_ISO15765_CH1 0x00009560 -#define SW_CAN_ISO15765_CH2 (SW_CAN_ISO15765_CH1 + 1) -#define SW_CAN_ISO15765_CH128 (SW_CAN_ISO15765_CH1 + 127) -#define J2610_CH1 0x00009640 -#define J2610_CH2 (J2610_CH1 + 1) -#define J2610_CH128 (J2610_CH1 + 127) -#define ANALOG_IN_CH1 0x0000C000 -#define ANALOG_IN_CH2 0x0000C001 -#define ANALOG_IN_CH32 0x0000C01F - - -// -// J2534-1 v04.04 Error Values -// -#define STATUS_NOERROR 0x00 // Function call successful. -#define ERR_NOT_SUPPORTED 0x01 // Device cannot support requested functionality mandated in J2534. Device is not fully SAE J2534 compliant. -#define ERR_INVALID_CHANNEL_ID 0x02 // Invalid ChannelID value. -#define ERR_INVALID_PROTOCOL_ID 0x03 // Invalid or unsupported ProtocolID, or there is a resource conflict (i.e. trying to connect to multiple mutually exclusive protocols such as J1850PWM and J1850VPW, or CAN and SCI, etc.). -#define ERR_NULL_PARAMETER 0x04 // NULL pointer supplied where a valid pointer is required. -#define ERR_INVALID_IOCTL_VALUE 0x05 // Invalid value for Ioctl parameter. -#define ERR_INVALID_FLAGS 0x06 // Invalid flag values. -#define ERR_FAILED 0x07 // Undefined error, use PassThruGetLastError() for text description. -#define ERR_DEVICE_NOT_CONNECTED 0x08 // Unable to communicate with device. -#define ERR_TIMEOUT 0x09 // Read or write timeout: - // PassThruReadMsgs() - No message available to read or could not read the specified number of messages. The actual number of messages read is placed in . - // PassThruWriteMsgs() - Device could not write the specified number of messages. The actual number of messages sent on the vehicle network is placed in . -#define ERR_INVALID_MSG 0x0A // Invalid message structure pointed to by pMsg. -#define ERR_INVALID_TIME_INTERVAL 0x0B // Invalid TimeInterval value. -#define ERR_EXCEEDED_LIMIT 0x0C // Exceeded maximum number of message IDs or allocated space. -#define ERR_INVALID_MSG_ID 0x0D // Invalid MsgID value. -#define ERR_DEVICE_IN_USE 0x0E // Device is currently open. -#define ERR_INVALID_IOCTL_ID 0x0F // Invalid IoctlID value. -#define ERR_BUFFER_EMPTY 0x10 // Protocol message buffer empty, no messages available to read. -#define ERR_BUFFER_FULL 0x11 // Protocol message buffer full. All the messages specified may not have been transmitted. -#define ERR_BUFFER_OVERFLOW 0x12 // Indicates a buffer overflow occurred and messages were lost. -#define ERR_PIN_INVALID 0x13 // Invalid pin number, pin number already in use, or voltage already applied to a different pin. -#define ERR_CHANNEL_IN_USE 0x14 // Channel number is currently connected. -#define ERR_MSG_PROTOCOL_ID 0x15 // Protocol type in the message does not match the protocol associated with the Channel ID -#define ERR_INVALID_FILTER_ID 0x16 // Invalid Filter ID value. -#define ERR_NO_FLOW_CONTROL 0x17 // No flow control filter set or matched (for ProtocolID ISO15765 only). -#define ERR_NOT_UNIQUE 0x18 // A CAN ID in pPatternMsg or pFlowControlMsg matches either ID in an existing FLOW_CONTROL_FILTER -#define ERR_INVALID_BAUDRATE 0x19 // The desired baud rate cannot be achieved within the tolerance specified in SAE J2534-1 Section 6.5 -#define ERR_INVALID_DEVICE_ID 0x1A // Device ID invalid. - - -// -// J2534-1 v04.04 Connect Flags -// -#define CAN_29BIT_ID 0x0100 -#define ISO9141_NO_CHECKSUM 0x0200 -#define CAN_ID_BOTH 0x0800 -#define ISO9141_K_LINE_ONLY 0x1000 - - -// -// J2534-1 v04.04 Filter Type Values -// -#define PASS_FILTER 0x00000001 -#define BLOCK_FILTER 0x00000002 -#define FLOW_CONTROL_FILTER 0x00000003 - - -// -// J2534-1 v04.04 Programming Voltage Pin Numbers -// -#define AUXILIARY_OUTPUT_PIN 0 -#define SAE_J1962_CONNECTOR_PIN_6 6 -#define SAE_J1962_CONNECTOR_PIN_9 9 -#define SAE_J1962_CONNECTOR_PIN_11 11 -#define SAE_J1962_CONNECTOR_PIN_12 12 -#define SAE_J1962_CONNECTOR_PIN_13 13 -#define SAE_J1962_CONNECTOR_PIN_14 14 -#define SAE_J1962_CONNECTOR_PIN_15 15 // Short to ground only - - -// -// J2534-1 v04.04 Programming Voltage Values -// -#define SHORT_TO_GROUND 0xFFFFFFFE -#define VOLTAGE_OFF 0xFFFFFFFF - - -// -// J2534-1 v04.04 API Version Values -// -#define J2534_APIVER_FEBRUARY_2002 "02.02" -#define J2534_APIVER_NOVEMBER_2004 "04.04" - - -// -// J2534-1 v04.04 IOCTL ID Values -// -#define GET_CONFIG 0x01 // pInput = SCONFIG_LIST, pOutput = NULL -#define SET_CONFIG 0x02 // pInput = SCONFIG_LIST, pOutput = NULL -#define READ_VBATT 0x03 // pInput = NULL, pOutput = unsigned long -#define FIVE_BAUD_INIT 0x04 // pInput = SBYTE_ARRAY, pOutput = SBYTE_ARRAY -#define FAST_INIT 0x05 // pInput = PASSTHRU_MSG, pOutput = PASSTHRU_MSG -#define CLEAR_TX_BUFFER 0x07 // pInput = NULL, pOutput = NULL -#define CLEAR_RX_BUFFER 0x08 // pInput = NULL, pOutput = NULL -#define CLEAR_PERIODIC_MSGS 0x09 // pInput = NULL, pOutput = NULL -#define CLEAR_MSG_FILTERS 0x0A // pInput = NULL, pOutput = NULL -#define CLEAR_FUNCT_MSG_LOOKUP_TABLE 0x0B // pInput = NULL, pOutput = NULL -#define ADD_TO_FUNCT_MSG_LOOKUP_TABLE 0x0C // pInput = SBYTE_ARRAY, pOutput = NULL -#define DELETE_FROM_FUNCT_MSG_LOOKUP_TABLE 0x0D // pInput = SBYTE_ARRAY, pOutput = NULL -#define READ_PROG_VOLTAGE 0x0E // pInput = NULL, pOutput = unsigned long - - -// -// J2534-2 IOCTL ID Values -// -#define SW_CAN_HS 0x00008000 // pInput = NULL, pOutput = NULL -#define SW_CAN_NS 0x00008001 // pInput = NULL, pOutput = NULL -#define SET_POLL_RESPONSE 0x00008002 // pInput = SBYTE_ARRAY, pOutput = NULL -#define BECOME_MASTER 0x00008003 // pInput = unsigned char, pOutput = NULL - - -// -// J2534-1 v04.04 Configuration Parameter Values -// Default value is enclosed in square brackets "[" and "]" -// -#define DATA_RATE 0x01 // 5-500000 -#define LOOPBACK 0x03 // 0 (OFF), 1 (ON) [0] -#define NODE_ADDRESS 0x04 // J1850PWM: 0x00-0xFF -#define NETWORK_LINE 0x05 // J1850PWM: 0 (BUS_NORMAL), 1 (BUS_PLUS), 2 (BUS_MINUS) [0] -#define P1_MIN 0x06 // ISO9141 or ISO14230: Not used by interface -#define P1_MAX 0x07 // ISO9141 or ISO14230: 0x1-0xFFFF (.5 ms per bit) [40 (20ms)] -#define P2_MIN 0x08 // ISO9141 or ISO14230: Not used by interface -#define P2_MAX 0x09 // ISO9141 or ISO14230: Not used by interface -#define P3_MIN 0x0A // ISO9141 or ISO14230: 0x0-0xFFFF (.5 ms per bit) [110 (55ms)] -#define P3_MAX 0x0B // ISO9141 or ISO14230: Not used by interface -#define P4_MIN 0x0C // ISO9141 or ISO14230: 0x0-0xFFFF (.5 ms per bit) [10 (5ms)] -#define P4_MAX 0x0D // ISO9141 or ISO14230: Not used by interface -#define W0 0x19 // ISO9141: 0x0-0xFFFF (1 ms per bit) [300] -#define W1 0x0E // ISO9141 or ISO14230: 0x0-0xFFFF (1 ms per bit) [300] -#define W2 0x0F // ISO9141 or ISO14230: 0x0-0xFFFF (1 ms per bit) [20] -#define W3 0x10 // ISO9141 or ISO14230: 0x0-0xFFFF (1 ms per bit) [20] -#define W4 0x11 // ISO9141 or ISO14230: 0x0-0xFFFF (1 ms per bit) [50] -#define W5 0x12 // ISO9141 or ISO14230: 0x0-0xFFFF (1 ms per bit) [300] -#define TIDLE 0x13 // ISO9141 or ISO14230: 0x0-0xFFFF (1 ms per bit) [300] -#define TINIL 0x14 // ISO9141 or ISO14230: 0x0-0xFFFF (1 ms per bit) [25] -#define TWUP 0x15 // ISO9141 or ISO14230: 0x0-0xFFFF (1 ms per bit) [50] -#define PARITY 0x16 // ISO9141 or ISO14230: 0 (NO_PARITY), 1 (ODD_PARITY), 2 (EVEN_PARITY) [0] -#define BIT_SAMPLE_POINT 0x17 // CAN: 0-100 (1% per bit) [80] -#define SYNC_JUMP_WIDTH 0x18 // CAN: 0-100 (1% per bit) [15] -#define T1_MAX 0x1A // SCI: 0x0-0xFFFF (1 ms per bit) [20] -#define T2_MAX 0x1B // SCI: 0x0-0xFFFF (1 ms per bit) [100] -#define T3_MAX 0x24 // SCI: 0x0-0xFFFF (1 ms per bit) [50] -#define T4_MAX 0x1C // SCI: 0x0-0xFFFF (1 ms per bit) [20] -#define T5_MAX 0x1D // SCI: 0x0-0xFFFF (1 ms per bit) [100] -#define ISO15765_BS 0x1E // ISO15765: 0x0-0xFF [0] -#define ISO15765_STMIN 0x1F // ISO15765: 0x0-0xFF [0] -#define ISO15765_BS_TX 0x22 // ISO15765: 0x0-0xFF,0xFFFF [0xFFFF] -#define ISO15765_STMIN_TX 0x23 // ISO15765: 0x0-0xFF,0xFFFF [0xFFFF] -#define DATA_BITS 0x20 // ISO9141 or ISO14230: 0 (8 data bits), 1 (7 data bits) [0] -#define FIVE_BAUD_MOD 0x21 // ISO9141 or ISO14230: 0 (ISO 9141-2/14230-4), 1 (Inv KB2), 2 (Inv Addr), 3 (ISO 9141) [0] -#define ISO15765_WFT_MAX 0x25 // ISO15765: 0x0-0xFF [0] - - -// -// J2534-2 Configuration Parameter Values -// Default value is enclosed in square brackets "[" and "]" -// -#define CAN_MIXED_FORMAT 0x00008000 // See #defines below. [0] -#define J1962_PINS 0x00008001 // 0xPPSS PP: 0x00-0x10 SS: 0x00-0x10 PP!=SS, except 0x0000. Exclude pins 4, 5, and 16. [0] -#define SW_CAN_HS_DATA_RATE 0x00008010 // SWCAN: 5-500000 [83333] -#define SW_CAN_SPEEDCHANGE_ENABLE 0x00008011 // SWCAN: 0 (DISABLE_SPDCHANGE), 1 (ENABLE_SPDCHANGE) [0] -#define SW_CAN_RES_SWITCH 0x00008012 // SWCAN: 0 (DISCONNECT_RESISTOR), 1 (CONNECT_RESISTOR), 2 (AUTO_ RESISTOR) [0] -#define ACTIVE_CHANNELS 0x00008020 // ANALOG: 0-0xFFFFFFFF -#define SAMPLE_RATE 0x00008021 // ANALOG: 0-0xFFFFFFFF [0] (high bit changes meaning from samples/sec to seconds/sample) -#define SAMPLES_PER_READING 0x00008022 // ANALOG: 1-0xFFFFFFFF [1] -#define READINGS_PER_MSG 0x00008023 // ANALOG: 1-0x00000408 (1 - 1032) [1] -#define AVERAGING_METHOD 0x00008024 // ANALOG: 0-0xFFFFFFFF [0] -#define SAMPLE_RESOLUTION 0x00008025 // ANALOG READ-ONLY: 0x1-0x20 (1 - 32) -#define INPUT_RANGE_LOW 0x00008026 // ANALOG READ-ONLY: 0x80000000-0x7FFFFFFF (-2147483648-2147483647) -#define INPUT_RANGE_HIGH 0x00008027 // ANALOG READ-ONLY: 0x80000000-0x7FFFFFFF (-2147483648-2147483647) - - -// -// J2534-2 Mixed-Mode/Format CAN Definitions -// -#define CAN_MIXED_FORMAT_OFF 0 // Messages will be treated as ISO 15765 ONLY. -#define CAN_MIXED_FORMAT_ON 1 // Messages will be treated as either ISO 15765 or an unformatted CAN frame. -#define CAN_MIXED_FORMAT_ALL_FRAMES 2 // Messages will be treated as ISO 15765, an unformatted CAN frame, or both. - - -// -// J2534-2 Analog Channel Averaging Method Definitions -// -#define SIMPLE_AVERAGE 0x00000000 // Simple arithmetic mean -#define MAX_LIMIT_AVERAGE 0x00000001 // Choose the biggest value -#define MIN_LIMIT_AVERAGE 0x00000002 // Choose the lowest value -#define MEDIAN_AVERAGE 0x00000003 // Choose arithmetic median - - -// -// J2534-1 v04.04 RxStatus Definitions -// -#define TX_MSG_TYPE 0x0001 -#define START_OF_MESSAGE 0x0002 -#define RX_BREAK 0x0004 -#define TX_INDICATION 0x0008 -#define ISO15765_PADDING_ERROR 0x0010 -#define ISO15765_ADDR_TYPE 0x0080 -//#define CAN_29BIT_ID 0x0100 // Defined above - - -// -// J2534-2 RxStatus Definitions -// -#define SW_CAN_HV_RX 0x00010000 // SWCAN Channels Only -#define SW_CAN_HS_RX 0x00020000 // SWCAN Channels Only -#define SW_CAN_NS_RX 0x00040000 // SWCAN Channels Only -#define OVERFLOW_ 0x00010000 // Analog Input Channels Only - - -// -// J2534-1 v04.04 TxFlags Definitions -// -#define ISO15765_FRAME_PAD 0x0040 -//#define ISO15765_ADDR_TYPE 0x0080 // Defined above -//#define CAN_29BIT_ID 0x0100 // Defined above -#define WAIT_P3_MIN_ONLY 0x0200 -#define SCI_MODE 0x400000 -#define SCI_TX_VOLTAGE 0x800000 - - -// -// J2534-2 TxFlags Definitions -// -#define SW_CAN_HV_TX 0x00000400 - - -// -// J2534-1 v04.04 Structure Definitions -// -typedef struct -{ - unsigned long Parameter; // Name of parameter - unsigned long Value; // Value of the parameter -} SCONFIG; - - -typedef struct -{ - unsigned long NumOfParams; // Number of SCONFIG elements - SCONFIG* ConfigPtr; // Array of SCONFIG -} SCONFIG_LIST; - - -typedef struct -{ - unsigned long NumOfBytes; // Number of bytes in the array - unsigned char* BytePtr; // Array of bytes -} SBYTE_ARRAY; - - -typedef struct -{ - unsigned long ProtocolID; - unsigned long RxStatus; - unsigned long TxFlags; - unsigned long Timestamp; - unsigned long DataSize; - unsigned long ExtraDataIndex; - unsigned char Data[4128]; -} PASSTHRU_MSG; - -// -// J2534-1 v04.04 Function Prototypes -// -PANDAJ2534DLL_API long PTAPI PassThruOpen(void *pName, unsigned long *pDeviceID); -PANDAJ2534DLL_API long PTAPI PassThruClose(unsigned long DeviceID); -PANDAJ2534DLL_API long PTAPI PassThruConnect(unsigned long DeviceID, unsigned long ProtocolID, unsigned long Flags, unsigned long BaudRate, unsigned long *pChannelID); -PANDAJ2534DLL_API long PTAPI PassThruDisconnect(unsigned long ChannelID); -PANDAJ2534DLL_API long PTAPI PassThruReadMsgs(unsigned long ChannelID, PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout); -PANDAJ2534DLL_API long PTAPI PassThruWriteMsgs(unsigned long ChannelID, PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout); -PANDAJ2534DLL_API long PTAPI PassThruStartPeriodicMsg(unsigned long ChannelID, PASSTHRU_MSG *pMsg, unsigned long *pMsgID, unsigned long TimeInterval); -PANDAJ2534DLL_API long PTAPI PassThruStopPeriodicMsg(unsigned long ChannelID, unsigned long MsgID); -PANDAJ2534DLL_API long PTAPI PassThruStartMsgFilter(unsigned long ChannelID, unsigned long FilterType, PASSTHRU_MSG *pMaskMsg, PASSTHRU_MSG *pPatternMsg, PASSTHRU_MSG *pFlowControlMsg, unsigned long *pFilterID); -PANDAJ2534DLL_API long PTAPI PassThruStopMsgFilter(unsigned long ChannelID, unsigned long FilterID); -PANDAJ2534DLL_API long PTAPI PassThruSetProgrammingVoltage(unsigned long DeviceID, unsigned long PinNumber, unsigned long Voltage); -PANDAJ2534DLL_API long PTAPI PassThruReadVersion(unsigned long DeviceID, char *pFirmwareVersion, char *pDllVersion, char *pApiVersion); -PANDAJ2534DLL_API long PTAPI PassThruGetLastError(char *pErrorDescription); -PANDAJ2534DLL_API long PTAPI PassThruIoctl(unsigned long ChannelID, unsigned long IoctlID, void *pInput, void *pOutput); - - -// -// J2534-1 v04.04 Function Typedefs -// These function typedefs allow simpler use of the J2534 API by -// allowing you to do things like this: -// PTCONNECT pPassThruConnectFunc = GetProcAddress(hModule, "PassThruConnect"); -// if (pPassThruConnectFunc == NULL) -// return FALSE; -// pPassThruConnectFunc(DeviceID, CAN, CAN_29BIT_ID, 500000, &ChannelID); -// -typedef long (PTAPI *PTOPEN)(void *pName, unsigned long *pDeviceID); -typedef long (PTAPI *PTCLOSE)(unsigned long DeviceID); -typedef long (PTAPI *PTCONNECT)(unsigned long DeviceID, unsigned long ProtocolID, unsigned long Flags, unsigned long BaudRate, unsigned long *pChannelID); -typedef long (PTAPI *PTDISCONNECT)(unsigned long ChannelID); -typedef long (PTAPI *PTREADMSGS)(unsigned long ChannelID, PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout); -typedef long (PTAPI *PTWRITEMSGS)(unsigned long ChannelID, PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout); -typedef long (PTAPI *PTSTARTPERIODICMSG)(unsigned long ChannelID, PASSTHRU_MSG *pMsg, unsigned long *pMsgID, unsigned long TimeInterval); -typedef long (PTAPI *PTSTOPPERIODICMSG)(unsigned long ChannelID, unsigned long MsgID); -typedef long (PTAPI *PTSTARTMSGFILTER)(unsigned long ChannelID, unsigned long FilterType, PASSTHRU_MSG *pMaskMsg, PASSTHRU_MSG *pPatternMsg, PASSTHRU_MSG *pFlowControlMsg, unsigned long *pFilterID); -typedef long (PTAPI *PTSTOPMSGFILTER)(unsigned long ChannelID, unsigned long FilterID); -typedef long (PTAPI *PTSETPROGRAMMINGVOLTAGE)(unsigned long DeviceID, unsigned long PinNumber, unsigned long Voltage); -typedef long (PTAPI *PTREADVERSION)(unsigned long DeviceID, char *pFirmwareVersion, char *pDllVersion, char *pApiVersion); -typedef long (PTAPI *PTGETLASTERROR)(char *pErrorDescription); -typedef long (PTAPI *PTIOCTL)(unsigned long ChannelID, unsigned long IoctlID, void *pInput, void *pOutput); diff --git a/panda/drivers/windows/pandaJ2534DLL/J2534register_x64.reg b/panda/drivers/windows/pandaJ2534DLL/J2534register_x64.reg deleted file mode 100644 index 120ab391c7bb4d..00000000000000 Binary files a/panda/drivers/windows/pandaJ2534DLL/J2534register_x64.reg and /dev/null differ diff --git a/panda/drivers/windows/pandaJ2534DLL/MessagePeriodic.cpp b/panda/drivers/windows/pandaJ2534DLL/MessagePeriodic.cpp deleted file mode 100644 index 0c3416e0daf09f..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/MessagePeriodic.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "stdafx.h" -#include "MessagePeriodic.h" -#include "J2534Connection.h" - -MessagePeriodic::MessagePeriodic( - std::chrono::microseconds delay, - std::shared_ptr msg -) : Action(msg->connection, delay), msg(msg), runyet(FALSE), active(TRUE) { }; - -void MessagePeriodic::execute() { - if (!this->active) return; - if (this->runyet) { - if (msg->isFinished()) { - msg->reset(); - msg->execute(); - } - } else { - this->runyet = TRUE; - msg->execute(); - } - - if (auto conn_sp = this->connection.lock()) { - if (auto panda_dev_sp = conn_sp->getPandaDev()) { - //Scheduling must be relative to now incase there was a long stall that - //would case it to be super far behind and try to catch up forever. - this->scheduleImmediateDelay(); - panda_dev_sp->insertActionIntoTaskList(shared_from_this()); - } - } -} diff --git a/panda/drivers/windows/pandaJ2534DLL/MessagePeriodic.h b/panda/drivers/windows/pandaJ2534DLL/MessagePeriodic.h deleted file mode 100644 index 40132565c11fc0..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/MessagePeriodic.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -#include "Action.h" -#include "MessageTx.h" - -class J2534Connection; - -/* A message that is resent on a given period. Created with calls to PassThruStartPeriodicMessage. - -Instead of making each J2534 protocol implementation have to implement periodic message -functionality, this class takes a message to be sent, and passes along the execute call -to the message, then reschedules itself. -*/ -class MessagePeriodic : public Action, public std::enable_shared_from_this -{ -public: - MessagePeriodic( - std::chrono::microseconds delay, - std::shared_ptr msg - ); - - virtual void execute(); - - void cancel() { - this->active = FALSE; - } - -protected: - std::shared_ptr msg; - -private: - BOOL runyet; - BOOL active; -}; diff --git a/panda/drivers/windows/pandaJ2534DLL/MessageRx.h b/panda/drivers/windows/pandaJ2534DLL/MessageRx.h deleted file mode 100644 index 2af24364ff3a36..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/MessageRx.h +++ /dev/null @@ -1,61 +0,0 @@ -#pragma once - -class MessageRx -{ -public: - MessageRx( - unsigned long size, - std::string piece, - unsigned long rxFlags, - std::shared_ptr filter - ) : expected_size(size & 0xFFF), flags(rxFlags) { - msg.reserve(expected_size); - msg = piece; - next_part = 1; - }; - - bool rx_add_frame(uint8_t pci_byte, unsigned int max_packet_size, const std::string piece) { - if ((pci_byte & 0x0F) != this->next_part) { - //TODO: Maybe this should instantly fail the transaction. - return TRUE; - } - - this->next_part = (this->next_part + 1) % 0x10; - unsigned int payload_len = MIN(expected_size - msg.size(), max_packet_size); - if (piece.size() < payload_len) { - //A frame was received that could have held more data. - //No examples of this protocol show that happening, so - //it will be assumed that it is grounds to reset rx. - return FALSE; - } - msg += piece.substr(0, payload_len); - - return TRUE; - } - - unsigned int bytes_remaining() { - return this->expected_size - this->msg.size(); - } - - bool is_ready() { - return this->msg.size() == this->expected_size; - } - - bool flush_result(std::string& final_msg) { - if (this->msg.size() == this->expected_size) { - final_msg = this->msg; - return TRUE; - } - return FALSE; - } - - uint8_t getNextConsecutiveFrameId() { - return this->next_part++; - } - - std::weak_ptr filter; - unsigned long flags; - unsigned long expected_size; - std::string msg; - unsigned char next_part; -}; diff --git a/panda/drivers/windows/pandaJ2534DLL/MessageTx.h b/panda/drivers/windows/pandaJ2534DLL/MessageTx.h deleted file mode 100644 index 5315fa058faf60..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/MessageTx.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -#include "Action.h" -#include "J2534Frame.h" - -class J2534Connection; - -class MessageTx : public Action, public std::enable_shared_from_this -{ -public: - MessageTx( - std::weak_ptr connection_in, - PASSTHRU_MSG& to_send - ) : Action(connection_in), fullmsg(to_send) { }; - - virtual BOOL checkTxReceipt(J2534Frame frame) = 0; - - virtual BOOL isFinished() = 0; - - virtual BOOL txReady() = 0; - - virtual void reset() = 0; - -protected: - J2534Frame fullmsg; -}; \ No newline at end of file diff --git a/panda/drivers/windows/pandaJ2534DLL/MessageTxTimeout.cpp b/panda/drivers/windows/pandaJ2534DLL/MessageTxTimeout.cpp deleted file mode 100644 index 2e21ba3ce121cd..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/MessageTxTimeout.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "stdafx.h" -#include "J2534Connection.h" -#include "MessageTxTimeout.h" - -MessageTxTimeoutable::MessageTxTimeoutable( - std::weak_ptr connection, - PASSTHRU_MSG& to_send -) : MessageTx(connection, to_send), recvCount(0) { }; - -void MessageTxTimeoutable::scheduleTimeout(std::chrono::microseconds timeoutus) { - if (auto conn_sp = this->connection.lock()) { - if (auto panda_dev_sp = conn_sp->getPandaDev()) { - auto timeoutobj = std::make_shared(std::static_pointer_cast(shared_from_this()), timeoutus); - panda_dev_sp->scheduleAction(std::static_pointer_cast(timeoutobj), TRUE); - } - } -} - -void MessageTxTimeoutable::scheduleTimeout(unsigned long timeoutus) { - scheduleTimeout(std::chrono::microseconds(timeoutus)); -} - - - -MessageTxTimeout::MessageTxTimeout( - std::shared_ptr msg, - std::chrono::microseconds timeout -) : Action(msg->connection), msg(msg), lastRecvCount(msg->getRecvCount()) { - delay = timeout; -}; - -MessageTxTimeout::MessageTxTimeout( - std::shared_ptr msg, - unsigned long timeout -) : MessageTxTimeout(msg, std::chrono::microseconds(timeout * 1000)) { }; - -void MessageTxTimeout::execute() { - if (auto msg_sp = this->msg.lock()) { - if (msg_sp->getRecvCount() == this->lastRecvCount) { - msg_sp->onTimeout(); - } - } -} diff --git a/panda/drivers/windows/pandaJ2534DLL/MessageTxTimeout.h b/panda/drivers/windows/pandaJ2534DLL/MessageTxTimeout.h deleted file mode 100644 index a9c878468cfd6e..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/MessageTxTimeout.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once -#include "Action.h" -#include "MessageTx.h" - -class MessageTxTimeout; - -/* A special type of MessageTx for multipart messages that supports being canceled with a timeout.*/ -class MessageTxTimeoutable : public MessageTx -{ -public: - MessageTxTimeoutable( - std::weak_ptr connection, - PASSTHRU_MSG& to_send - ); - - unsigned long getRecvCount() { - return recvCount; - } - - virtual void onTimeout() = 0; - -protected: - unsigned long recvCount; - - void scheduleTimeout(std::chrono::microseconds timeoutus); - - void scheduleTimeout(unsigned long timeoutus); -}; - - -/* An Action that cancels MessageTxTimeoutableif the Timeout Actoin executes -before the MessageTxTimeoutableif renews its timeout. -*/ -class MessageTxTimeout : public Action -{ -public: - MessageTxTimeout( - std::shared_ptr msg, - std::chrono::microseconds timeout - ); - - MessageTxTimeout( - std::shared_ptr msg, - unsigned long timeout - ); - - virtual void execute(); - -private: - std::weak_ptr msg; - unsigned long lastRecvCount; -}; diff --git a/panda/drivers/windows/pandaJ2534DLL/MessageTx_CAN.cpp b/panda/drivers/windows/pandaJ2534DLL/MessageTx_CAN.cpp deleted file mode 100644 index 8217ce539a1a54..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/MessageTx_CAN.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "stdafx.h" -#include "MessageTx_CAN.h" -#include "J2534Connection_CAN.h" - -MessageTx_CAN::MessageTx_CAN( - std::shared_ptr connection_in, - PASSTHRU_MSG& to_send -) : MessageTx(connection_in, to_send), sentyet(FALSE), txInFlight(FALSE) {}; - -void MessageTx_CAN::execute() { - uint32_t addr = ((uint8_t)fullmsg.Data[0]) << 24 | ((uint8_t)fullmsg.Data[1]) << 16 | - ((uint8_t)fullmsg.Data[2]) << 8 | ((uint8_t)fullmsg.Data[3]); - - if (auto conn_sp = std::static_pointer_cast(this->connection.lock())) { - if (auto panda_dev_sp = conn_sp->getPandaDev()) { - auto payload = fullmsg.Data.substr(4); - if (panda_dev_sp->panda->can_send(addr, check_bmask(this->fullmsg.TxFlags, CAN_29BIT_ID), - (const uint8_t*)payload.c_str(), (uint8_t)payload.size(), panda::PANDA_CAN1) == FALSE) { - return; - } - this->txInFlight = TRUE; - this->sentyet = TRUE; - panda_dev_sp->txMsgsAwaitingEcho.push(shared_from_this()); - } - } -} - -//Returns TRUE if receipt is consumed by the msg, FALSE otherwise. -BOOL MessageTx_CAN::checkTxReceipt(J2534Frame frame) { - if (txReady()) return FALSE; - if (frame.Data == fullmsg.Data && ((this->fullmsg.TxFlags & CAN_29BIT_ID) == (frame.RxStatus & CAN_29BIT_ID))) { - txInFlight = FALSE; - if (auto conn_sp = std::static_pointer_cast(this->connection.lock())) - if (conn_sp->loopback) - conn_sp->addMsgToRxQueue(frame); - return TRUE; - } - return FALSE; -} - -void MessageTx_CAN::reset() { - sentyet = FALSE; - txInFlight = FALSE; -} diff --git a/panda/drivers/windows/pandaJ2534DLL/MessageTx_CAN.h b/panda/drivers/windows/pandaJ2534DLL/MessageTx_CAN.h deleted file mode 100644 index afac75ef8116c2..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/MessageTx_CAN.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -#include -#include "MessageTx.h" - -class J2534Connection; - -class MessageTx_CAN : public MessageTx -{ -public: - MessageTx_CAN( - std::shared_ptr connection_in, - PASSTHRU_MSG& to_send - ); - - virtual void execute(); - - //Returns TRUE if receipt is consumed by the msg, FALSE otherwise. - virtual BOOL checkTxReceipt(J2534Frame frame); - - virtual BOOL isFinished() { - return !txInFlight && sentyet; - }; - - virtual BOOL txReady() { - return !sentyet; - }; - - virtual void reset(); - -private: - BOOL sentyet; - BOOL txInFlight; -}; diff --git a/panda/drivers/windows/pandaJ2534DLL/MessageTx_ISO15765.cpp b/panda/drivers/windows/pandaJ2534DLL/MessageTx_ISO15765.cpp deleted file mode 100644 index 023088d3c61ea6..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/MessageTx_ISO15765.cpp +++ /dev/null @@ -1,180 +0,0 @@ -#include "stdafx.h" -#include "MessageTx_ISO15765.h" -#include "constants_ISO15765.h" - -//in microseconsa -#define TIMEOUT_FC 250000 //Flow Control -#define TIMEOUT_CF 250000 //Consecutive Frames - -MessageTx_ISO15765::MessageTx_ISO15765( - std::shared_ptr connection_in, - PASSTHRU_MSG& to_send, - std::shared_ptr filter -) : MessageTxTimeoutable(connection_in, to_send), filter(filter), frames_sent(0), -consumed_count(0), txInFlight(FALSE), sendAll(FALSE), block_size(0), numWaitFrames(0), didtimeout(FALSE), issuspended(FALSE){ - - CANid = ((uint8_t)fullmsg.Data[0]) << 24 | ((uint8_t)fullmsg.Data[1]) << 16 | - ((uint8_t)fullmsg.Data[2]) << 8 | ((uint8_t)fullmsg.Data[3]); - - payload = fullmsg.Data.substr(addressLength()); - - if (check_bmask(fullmsg.TxFlags, ISO15765_ADDR_TYPE)) - data_prefix = fullmsg.Data[4]; - - if (payload.size() <= (7 - data_prefix.size())) { - isMultipart = FALSE; - auto framepayload = data_prefix + std::string(1, (char)payload.size()) + payload; - if (check_bmask(this->fullmsg.TxFlags, ISO15765_FRAME_PAD)) - framepayload += std::string(8 - framepayload.size(), '\x00'); - framePayloads.push_back(framepayload); - } else { - isMultipart = TRUE; - unsigned long first_payload_len = 6 - data_prefix.size(); // 5 or 6 - std::string framepayload = data_prefix + - (char)(0x10 | ((payload.size() >> 8) & 0xF)) + - (char)(payload.size() & 0xFF) + - payload.substr(0, first_payload_len); - framePayloads.push_back(framepayload); - - unsigned int pktnum = 1; - uint8_t CFDatSize = 7 - data_prefix.size(); - while (TRUE) { - framepayload = data_prefix + (char)(0x20 | (pktnum % 0x10)) + - payload.substr(first_payload_len + (CFDatSize * (pktnum-1)), CFDatSize); - - if (check_bmask(this->fullmsg.TxFlags, ISO15765_FRAME_PAD)) - framepayload += std::string(8 - framepayload.size(), '\x00'); - framePayloads.push_back(framepayload); - if (first_payload_len + (CFDatSize * pktnum) >= payload.size()) break; - pktnum++; - } - - } -}; - -unsigned int MessageTx_ISO15765::addressLength() { - return check_bmask(fullmsg.TxFlags, ISO15765_ADDR_TYPE) ? 5 : 4; -} - -void MessageTx_ISO15765::execute() { - if (didtimeout || issuspended) return; - if (this->frames_sent >= this->framePayloads.size()) return; - if (block_size == 0 && !sendAll && this->frames_sent > 0) return; - if (block_size > 0 && !sendAll) block_size--; - - if (auto conn_sp = this->connection.lock()) { - if (auto panda_dev_sp = conn_sp->getPandaDev()) { - auto& outFramePayload = this->framePayloads[this->frames_sent]; - if (panda_dev_sp->panda->can_send(this->CANid, check_bmask(this->fullmsg.TxFlags, CAN_29BIT_ID), - (const uint8_t*)outFramePayload.c_str(), (uint8_t)outFramePayload.size(), panda::PANDA_CAN1) == FALSE) { - return; - } - - this->txInFlight = TRUE; - this->frames_sent++; - panda_dev_sp->txMsgsAwaitingEcho.push(shared_from_this()); - } - } -} - -//Returns TRUE if receipt is consumed by the msg, FALSE otherwise. -BOOL MessageTx_ISO15765::checkTxReceipt(J2534Frame frame) { - if (!txInFlight) return FALSE; - if (frame.Data.size() >= addressLength() + 1 && (frame.Data[addressLength()] & 0xF0) == FRAME_FLOWCTRL) return FALSE; - - if (frame.Data == fullmsg.Data.substr(0, 4) + framePayloads[frames_sent - 1] && - ((this->fullmsg.TxFlags & CAN_29BIT_ID) == (frame.RxStatus & CAN_29BIT_ID))) { //Check receipt is expected - txInFlight = FALSE; //Received the expected receipt. Allow another msg to be sent. - - if (this->recvCount == 0 && this->framePayloads.size() > 1) - scheduleTimeout(TIMEOUT_FC); - - if (frames_sent == framePayloads.size()) { //Check message done - if (auto conn_sp = std::static_pointer_cast(this->connection.lock())) { - unsigned long flags = (filter == nullptr) ? fullmsg.TxFlags : this->filter->flags; - - J2534Frame outframe(ISO15765); - outframe.Timestamp = frame.Timestamp; - outframe.RxStatus = TX_MSG_TYPE | TX_INDICATION | (flags & (ISO15765_ADDR_TYPE | CAN_29BIT_ID)); - outframe.Data = frame.Data.substr(0, addressLength()); - conn_sp->addMsgToRxQueue(outframe); - - if (conn_sp->loopback) { - J2534Frame outframe(ISO15765); - outframe.Timestamp = frame.Timestamp; - outframe.RxStatus = TX_MSG_TYPE | (flags & (ISO15765_ADDR_TYPE | CAN_29BIT_ID)); - outframe.Data = this->fullmsg.Data; - conn_sp->addMsgToRxQueue(outframe); - } - - } //TODO what if fails - } else { - //Restart timeout if we are waiting for a flow control frame. - //FC frames are required when we are not sending all, the - //current block_size batch has not been sent, a FC message has - //already been received (differentiating from first frame), the - //message is not finished, and there is more than one frame in - //the message. - if (block_size == 0 && recvCount != 0 && !sendAll && !this->isFinished() && this->framePayloads.size() > 1) - scheduleTimeout(TIMEOUT_CF); - } - return TRUE; - } - return FALSE; -} - -BOOL MessageTx_ISO15765::isFinished() { - return this->frames_sent == this->framePayloads.size() && !txInFlight; -} - -BOOL MessageTx_ISO15765::txReady() { - return block_size > 0 || sendAll || this->frames_sent == 0; -} - -void MessageTx_ISO15765::reset() { - frames_sent = 0; - consumed_count = 0; - block_size = 0; - txInFlight = FALSE; - sendAll = FALSE; - numWaitFrames = 0; - didtimeout = FALSE; -} - -void MessageTx_ISO15765::onTimeout() { - didtimeout = TRUE; - if (auto conn_sp = std::static_pointer_cast(this->connection.lock())) { - if (auto panda_dev_sp = conn_sp->getPandaDev()) { - panda_dev_sp->removeConnectionTopAction(conn_sp, shared_from_this()); - } - } -} - -void MessageTx_ISO15765::flowControlContinue(uint8_t block_size, std::chrono::microseconds separation_time) { - this->issuspended = FALSE; - this->block_size = block_size; - this->delay = separation_time; - this->sendAll = block_size == 0; - this->recvCount++; -} - -void MessageTx_ISO15765::flowControlWait(unsigned long N_WFTmax) { - this->issuspended = TRUE; - this->recvCount++; - this->numWaitFrames++; - this->sendAll = FALSE; - this->block_size = block_size; - this->delay = std::chrono::microseconds(0); - //Docs are vague on if 0 means NO WAITS ALLOWED or NO LIMIT TO WAITS. - //It is less likely to cause issue if NO LIMIT is assumed. - if (N_WFTmax > 0 && this->numWaitFrames > N_WFTmax) { - this->onTimeout(); //Trigger self destruction of message. - } else { - scheduleTimeout(TIMEOUT_FC); - } -} - -void MessageTx_ISO15765::flowControlAbort() { - this->recvCount++; //Invalidate future timeout actions. - this->onTimeout(); //Trigger self destruction of message. -} diff --git a/panda/drivers/windows/pandaJ2534DLL/MessageTx_ISO15765.h b/panda/drivers/windows/pandaJ2534DLL/MessageTx_ISO15765.h deleted file mode 100644 index 0113edb8f96fd3..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/MessageTx_ISO15765.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once -#include "MessageTxTimeout.h" -#include "J2534Connection_ISO15765.h" - -class J2534Connection_ISO15765; - -/** -A specialized message type that can handle J2534 single and multi -frame (with flow control) writes. -*/ -class MessageTx_ISO15765 : public MessageTxTimeoutable -{ -public: - MessageTx_ISO15765( - std::shared_ptr connection, - PASSTHRU_MSG& to_send, - std::shared_ptr filter - ); - - unsigned int addressLength(); - - virtual void execute(); - - virtual BOOL checkTxReceipt(J2534Frame frame); - - virtual BOOL isFinished(); - - virtual BOOL txReady(); - - virtual void reset(); - - virtual void onTimeout(); - - //Functions for ISO15765 flow control - - void MessageTx_ISO15765::flowControlContinue(uint8_t block_size, std::chrono::microseconds separation_time); - void MessageTx_ISO15765::flowControlWait(unsigned long N_WFTmax); - void MessageTx_ISO15765::flowControlAbort(); - - std::shared_ptr filter; - unsigned long frames_sent; - unsigned long consumed_count; - uint8_t block_size; - unsigned long CANid; - std::string data_prefix; - std::string payload; - BOOL isMultipart; - std::vector framePayloads; - BOOL txInFlight; - BOOL sendAll; - unsigned int numWaitFrames; - BOOL didtimeout; - BOOL issuspended; -}; diff --git a/panda/drivers/windows/pandaJ2534DLL/PandaJ2534Device.cpp b/panda/drivers/windows/pandaJ2534DLL/PandaJ2534Device.cpp deleted file mode 100644 index 19ae43b0d70d08..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/PandaJ2534Device.cpp +++ /dev/null @@ -1,238 +0,0 @@ -#include "stdafx.h" -#include "PandaJ2534Device.h" -#include "J2534Frame.h" - -PandaJ2534Device::PandaJ2534Device(std::unique_ptr new_panda) : txInProgress(FALSE) { - this->panda = std::move(new_panda); - - this->panda->set_esp_power(FALSE); - this->panda->set_safety_mode(panda::SAFETY_ALLOUTPUT); - this->panda->set_can_loopback(FALSE); - this->panda->set_alt_setting(0); - - this->thread_kill_event = CreateEvent(NULL, TRUE, FALSE, NULL); - - DWORD canListenThreadID; - this->can_recv_handle = CreateThread(NULL, 0, _can_recv_threadBootstrap, (LPVOID)this, 0, &canListenThreadID); - - DWORD canProcessThreadID; - this->can_process_handle = CreateThread(NULL, 0, _can_process_threadBootstrap, (LPVOID)this, 0, &canProcessThreadID); - - DWORD flowControlSendThreadID; - this->flow_control_wakeup_event = CreateEvent(NULL, TRUE, FALSE, NULL); - this->flow_control_thread_handle = CreateThread(NULL, 0, _msg_tx_threadBootstrap, (LPVOID)this, 0, &flowControlSendThreadID); -}; - -PandaJ2534Device::~PandaJ2534Device() { - SetEvent(this->thread_kill_event); - DWORD res = WaitForSingleObject(this->can_recv_handle, INFINITE); - CloseHandle(this->can_recv_handle); - - res = WaitForSingleObject(this->can_process_handle, INFINITE); - CloseHandle(this->can_process_handle); - - res = WaitForSingleObject(this->flow_control_thread_handle, INFINITE); - CloseHandle(this->flow_control_thread_handle); - - CloseHandle(this->flow_control_wakeup_event); - CloseHandle(this->thread_kill_event); -} - -std::shared_ptr PandaJ2534Device::openByName(std::string sn) { - auto p = panda::Panda::openPanda(""); - if (p == nullptr) - return nullptr; - return std::unique_ptr(new PandaJ2534Device(std::move(p))); -} - -DWORD PandaJ2534Device::closeChannel(unsigned long ChannelID) { - if (this->connections.size() <= ChannelID) return ERR_INVALID_CHANNEL_ID; - if (this->connections[ChannelID] == nullptr) return ERR_INVALID_CHANNEL_ID; - this->connections[ChannelID] = nullptr; - return STATUS_NOERROR; -} - -DWORD PandaJ2534Device::addChannel(std::shared_ptr& conn, unsigned long* channel_id) { - int channel_index = -1; - for (unsigned int i = 0; i < this->connections.size(); i++) - if (this->connections[i] == nullptr) { - channel_index = i; - break; - } - - if (channel_index == -1) { - if (this->connections.size() == 0xFFFF) //channelid max 16 bits - return ERR_FAILED; //Too many channels - this->connections.push_back(nullptr); - channel_index = this->connections.size() - 1; - } - - this->connections[channel_index] = conn; - - *channel_id = channel_index; - return STATUS_NOERROR; -} - -DWORD PandaJ2534Device::can_recv_thread() { - this->panda->can_clear(panda::PANDA_CAN_RX); - this->panda->can_rx_q_push(this->thread_kill_event); - - return 0; -} - -DWORD PandaJ2534Device::can_process_thread() { - panda::PANDA_CAN_MSG msg_recv[CAN_RX_MSG_LEN]; - - while (true) { - if (!WaitForSingleObject(this->thread_kill_event, 0)) { - break; - } - - int count = 0; - this->panda->can_rx_q_pop(msg_recv, count); - if (count == 0) { - continue; - } - - for (int i = 0; i < count; i++) { - auto msg_in = msg_recv[i]; - J2534Frame msg_out(msg_in); - - if (msg_in.is_receipt) { - synchronized(task_queue_mutex) { - if (txMsgsAwaitingEcho.size() > 0) { - auto msgtx = txMsgsAwaitingEcho.front(); - if (auto conn = msgtx->connection.lock()) { - if (conn->isProtoCan() && conn->getPort() == msg_in.bus) { - if (msgtx->checkTxReceipt(msg_out)) { - //Things to check: - // Frame not for this msg: Drop frame and alert. Error? - // Frame is for this msg, more tx frames required after a FC frame: Wait for FC frame to come and trigger next tx. - // Frame is for this msg, more tx frames required: Schedule next tx frame. - // Frame is for this msg, and is the final frame of the msg: Let conn process full msg, If another msg from this conn is available, register it. - txMsgsAwaitingEcho.pop(); //Remove the TX object and schedule record. - - if (msgtx->isFinished()) { - this->removeConnectionTopAction(conn, msgtx); - } else { - if (msgtx->txReady()) { //Not finished, ready to send next frame. - msgtx->schedule(msg_in.recv_time_point, TRUE); - this->insertActionIntoTaskList(msgtx); - } else { - //Not finished, but next frame not ready (maybe waiting for flow control). - //Do not schedule more messages from this connection. - //this->ConnTxSet.erase(conn); - //Removing this means new messages queued can kickstart the queue and overstep the current message. - } - } - } - } - } else { - //Connection has died. Clear out the tx entry from device records. - txMsgsAwaitingEcho.pop(); - this->ConnTxSet.erase(conn); //connection is already dead, no need to schedule future tx msgs. - } - } - } - } else { - for (auto& conn : this->connections) - if (conn != nullptr && conn->isProtoCan() && conn->getPort() == msg_in.bus) - conn->processMessage(msg_out); - } - } - } - - return 0; -} - -DWORD PandaJ2534Device::msg_tx_thread() { - const HANDLE subscriptions[] = { this->flow_control_wakeup_event, this->thread_kill_event }; - DWORD sleepDuration = INFINITE; - while (TRUE) { - DWORD res = WaitForMultipleObjects(2, subscriptions, FALSE, sleepDuration); - if (res == WAIT_OBJECT_0 + 1) return 0; - if (res != WAIT_OBJECT_0 && res != WAIT_TIMEOUT) { - printf("Got an unexpected wait result in flow_control_write_thread. Res: %d; GetLastError: %d\n. Terminating thread.", res, GetLastError()); - return 0; - } - ResetEvent(this->flow_control_wakeup_event); - - while (TRUE) { - synchronized(task_queue_mutex) { //implemented with for loop. Consumes breaks. - if (this->task_queue.size() == 0) { - sleepDuration = INFINITE; - goto break_flow_ctrl_loop; - } - if (std::chrono::steady_clock::now() >= this->task_queue.front()->expire) { - auto task = this->task_queue.front(); //Get the scheduled tx record. - this->task_queue.pop_front(); - task->execute(); - } else { //Ran out of things that need to be sent now. Sleep! - auto time_diff = std::chrono::duration_cast - (this->task_queue.front()->expire - std::chrono::steady_clock::now()); - sleepDuration = MAX(1, time_diff.count()); - goto break_flow_ctrl_loop; - } - } - } - break_flow_ctrl_loop: - continue; - } - return 0; -} - -//Place the Action in the task queue based on the Action's expiration time, -//then signal the thread that processes actions. -void PandaJ2534Device::insertActionIntoTaskList(std::shared_ptr action) { - synchronized(task_queue_mutex) { - auto iter = this->task_queue.begin(); - for (; iter != this->task_queue.end(); iter++) { - if (action->expire < (*iter)->expire) break; - } - this->task_queue.insert(iter, action); - } - SetEvent(this->flow_control_wakeup_event); -} - -void PandaJ2534Device::scheduleAction(std::shared_ptr msg, BOOL startdelayed) { - if(startdelayed) - msg->scheduleImmediateDelay(); - else - msg->scheduleImmediate(); - this->insertActionIntoTaskList(msg); -} - -void PandaJ2534Device::registerConnectionTx(std::shared_ptr conn) { - synchronized(connTXSet_mutex) { - auto ret = this->ConnTxSet.insert(conn); - if (ret.second == FALSE) return; //Conn already exists. - this->scheduleAction(conn->txbuff.front()); - } -} - -void PandaJ2534Device::unstallConnectionTx(std::shared_ptr conn) { - synchronized(connTXSet_mutex) { - auto ret = this->ConnTxSet.insert(conn); - if (ret.second == TRUE) return; //Conn already exists. - this->insertActionIntoTaskList(conn->txbuff.front()); - } -} - -void PandaJ2534Device::removeConnectionTopAction(std::shared_ptr conn, std::shared_ptr msg) { - synchronized(task_queue_mutex) { - if (conn->txbuff.size() == 0) - return; - if (conn->txbuff.front() != msg) - return; - conn->txbuff.pop(); //Remove the top TX message from the connection tx queue. - - //Remove the connection from the active connection list if no more messages are scheduled with this connection. - if (conn->txbuff.size() == 0) { - //Update records showing the connection no longer has a tx record scheduled. - this->ConnTxSet.erase(conn); - } else { - //Add the next scheduled tx from this conn - this->scheduleAction(conn->txbuff.front()); - } - } -} diff --git a/panda/drivers/windows/pandaJ2534DLL/PandaJ2534Device.h b/panda/drivers/windows/pandaJ2534DLL/PandaJ2534Device.h deleted file mode 100644 index 32004ffba5ea14..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/PandaJ2534Device.h +++ /dev/null @@ -1,83 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -#include "J2534_v0404.h" -#include "panda_shared/panda.h" -#include "synchronize.h" -#include "Action.h" -#include "MessageTx.h" -#include "J2534Connection.h" - -class J2534Connection; -class Action; -class MessageTx; - -/** -Class representing a physical panda adapter. Instances are created by -PassThruOpen in the J2534 API. A Device can create one or more -J2534Connections. -*/ -class PandaJ2534Device { -public: - PandaJ2534Device(std::unique_ptr new_panda); - - ~PandaJ2534Device(); - - static std::shared_ptr openByName(std::string sn); - - DWORD closeChannel(unsigned long ChannelID); - DWORD addChannel(std::shared_ptr& conn, unsigned long* channel_id); - - std::unique_ptr panda; - std::vector> connections; - - //Place the Action in the task queue based on the Action's expiration time, - //then signal the thread that processes actions. - void insertActionIntoTaskList(std::shared_ptr action); - - void scheduleAction(std::shared_ptr msg, BOOL startdelayed=FALSE); - - void registerConnectionTx(std::shared_ptr conn); - - //Resume sending messages from the provided Connection's TX queue. - void unstallConnectionTx(std::shared_ptr conn); - - //Cleans up several queues after a message completes, is canceled, or otherwise goes away. - void removeConnectionTopAction(std::shared_ptr conn, std::shared_ptr msg); - - //Messages that have been sent on the wire will be echoed by the panda when - //transmission is complete. This tracks what is still waiting to hear an echo. - std::queue> txMsgsAwaitingEcho; - -private: - HANDLE thread_kill_event; - - HANDLE can_recv_handle; - static DWORD WINAPI _can_recv_threadBootstrap(LPVOID This) { - return ((PandaJ2534Device*)This)->can_recv_thread(); - } - DWORD can_recv_thread(); - - HANDLE can_process_handle; - static DWORD WINAPI _can_process_threadBootstrap(LPVOID This) { - return ((PandaJ2534Device*)This)->can_process_thread(); - } - DWORD can_process_thread(); - - HANDLE flow_control_wakeup_event; - HANDLE flow_control_thread_handle; - static DWORD WINAPI _msg_tx_threadBootstrap(LPVOID This) { - return ((PandaJ2534Device*)This)->msg_tx_thread(); - } - DWORD msg_tx_thread(); - std::list> task_queue; - Mutex task_queue_mutex; - - std::queue> ConnTxQueue; - std::set> ConnTxSet; - Mutex connTXSet_mutex; - BOOL txInProgress; -}; diff --git a/panda/drivers/windows/pandaJ2534DLL/Timer.cpp b/panda/drivers/windows/pandaJ2534DLL/Timer.cpp deleted file mode 100644 index 2f20f888eeef83..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/Timer.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "stdafx.h" -#include "Timer.h" - - -Timer::Timer() -{ - start = std::chrono::time_point_cast(clock::now()); -} - -// gets the time elapsed from construction. -unsigned long long /*milliseconds*/ Timer::getTimePassed(){ - // get the new time - auto end = std::chrono::time_point_cast(clock::now()); - - // return the difference of the times - return (end - start).count(); -} \ No newline at end of file diff --git a/panda/drivers/windows/pandaJ2534DLL/Timer.h b/panda/drivers/windows/pandaJ2534DLL/Timer.h deleted file mode 100644 index d4888fc5e6dd55..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/Timer.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include - -//Copied from https://stackoverflow.com/a/31488113 - -class Timer -{ - using clock = std::chrono::steady_clock; - using time_point_type = std::chrono::time_point < clock, std::chrono::milliseconds >; -public: - Timer(); - - // gets the time elapsed from construction. - unsigned long long /*milliseconds*/ getTimePassed(); - -private: - time_point_type start; -}; \ No newline at end of file diff --git a/panda/drivers/windows/pandaJ2534DLL/constants_ISO15765.h b/panda/drivers/windows/pandaJ2534DLL/constants_ISO15765.h deleted file mode 100644 index 86928f1436c996..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/constants_ISO15765.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#define msg_is_extaddr(msg) check_bmask(msg->TxFlags, ISO15765_ADDR_TYPE) -#define msg_is_padded(msg) check_bmask(msg->TxFlags, ISO15765_FRAME_PAD) - -#define FRAME_SINGLE 0x00 -#define FRAME_FIRST 0x10 -#define FRAME_CONSEC 0x20 -#define FRAME_FLOWCTRL 0x30 - -#define FLOWCTRL_CONTINUE 0 -#define FLOWCTRL_WAIT 1 -#define FLOWCTRL_ABORT 2 - -#define msg_get_type(msg, addrlen) ((msg).Data[addrlen] & 0xF0) - -#define is_single(msg, addrlen) (msg_get_type(msg, addrlen) == FRAME_SINGLE) -#define is_first(msg, addrlen) (msg_get_type(msg, addrlen) == FRAME_FIRST) -#define is_consecutive(msg, addrlen) (msg_get_type(msg, addrlen) == FRAME_CONSEC) -#define is_flowctrl(msg, addrlen) (msg_get_type(msg, addrlen) == FRAME_FLOWCTRL) \ No newline at end of file diff --git a/panda/drivers/windows/pandaJ2534DLL/dllmain.cpp b/panda/drivers/windows/pandaJ2534DLL/dllmain.cpp deleted file mode 100644 index d4122e0b1dda9c..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/dllmain.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// dllmain.cpp : Defines the entry point for the DLL application. -#include "dllmain.h" - -HMODULE thisdll; - -BOOL APIENTRY DllMain( HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) -{ - thisdll = hModule; - - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} diff --git a/panda/drivers/windows/pandaJ2534DLL/dllmain.h b/panda/drivers/windows/pandaJ2534DLL/dllmain.h deleted file mode 100644 index f49819e2c40aa1..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/dllmain.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once -#include "stdafx.h" - -extern HMODULE thisdll; diff --git a/panda/drivers/windows/pandaJ2534DLL/pandaJ2534DLL.cpp b/panda/drivers/windows/pandaJ2534DLL/pandaJ2534DLL.cpp deleted file mode 100644 index 096e4419883928..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/pandaJ2534DLL.cpp +++ /dev/null @@ -1,430 +0,0 @@ -// pandaJ2534DLL.cpp : Defines the exported functions for the DLL application. -// Protocol derived from the following sites (which shall be referred to as The Protocol Reference #). -// https://web.archive.org/web/20130805013326/https://tunertools.com/prodimages/DrewTech/Manuals/PassThru_API-1.pdf -// http://web.archive.org/web/20170910063536/http://www.tiecar.net/downloads/SAE_J2534_2002.pdf - -#include "stdafx.h" -#include "J2534_v0404.h" -#include "panda_shared/panda.h" -#include "J2534Connection.h" -#include "J2534Connection_CAN.h" -#include "J2534Connection_ISO15765.h" -#include "PandaJ2534Device.h" -#include "dllmain.h" - -// A quick way to avoid the name mangling that __stdcall liked to do -#define EXPORT comment(linker, "/EXPORT:" __FUNCTION__ "=" __FUNCDNAME__) - -std::vector> pandas; - -int J25334LastError = 0; - -std::string GetProductAndVersion(TCHAR* szFilename)//std::string & strProductName, std::string & strProductVersion) -{ - // allocate a block of memory for the version info - DWORD dummy; - DWORD dwSize = GetFileVersionInfoSize(szFilename, &dummy); - if (dwSize == 0) { - return "error"; - } - std::vector data(dwSize); - - // load the version info - if (!GetFileVersionInfo(szFilename, NULL, dwSize, &data[0])) { - return "error"; - } - - // get the name and version strings - LPVOID pvProductName = NULL; - unsigned int iProductNameLen = 0; - LPVOID pvProductVersion = NULL; - unsigned int iProductVersionLen = 0; - - // 040904b0 is a language id. - if (!VerQueryValueA(&data[0], "\\StringFileInfo\\040904b0\\ProductName", &pvProductName, &iProductNameLen) || - !VerQueryValueA(&data[0], "\\StringFileInfo\\040904b0\\ProductVersion", &pvProductVersion, &iProductVersionLen)) { - return "error"; - } - - std::string ver_str = std::string((char*)pvProductVersion, iProductVersionLen-1); - std::string prod_str = std::string((char*)pvProductName, iProductNameLen-1); - std::string full_ver = prod_str + std::string(": ") + ver_str; - return full_ver; -} - -long ret_code(long code) { - J25334LastError = code; - return code; -} - -#define EXTRACT_DID(CID) ((CID & 0xFFFF) - 1) -#define EXTRACT_CID(CID) ((CID >> 16) & 0xFFFF) - -long check_valid_DeviceID(unsigned long DeviceID) { - uint16_t dev_id = EXTRACT_DID(DeviceID); - if (pandas.size() <= dev_id || pandas[dev_id] == nullptr) - return ret_code(ERR_INVALID_DEVICE_ID); - return ret_code(STATUS_NOERROR); -} - -long check_valid_ChannelID(unsigned long ChannelID) { - uint16_t dev_id = EXTRACT_DID(ChannelID); - uint16_t con_id = EXTRACT_CID(ChannelID); - - if (pandas.size() <= dev_id || pandas[dev_id] == nullptr) - return ret_code(ERR_INVALID_CHANNEL_ID); - - if (pandas[dev_id]->connections.size() <= con_id) return ret_code(ERR_INVALID_CHANNEL_ID); - if (pandas[dev_id]->connections[con_id] == nullptr) return ret_code(ERR_DEVICE_NOT_CONNECTED); - - return ret_code(STATUS_NOERROR); -} - -//Do not call without checking if the device/channel id exists first. -#define get_device(DeviceID) (pandas[EXTRACT_DID(DeviceID)]) -#define get_channel(ChannelID) (get_device(ChannelID)->connections[EXTRACT_CID(ChannelID)]) - -PANDAJ2534DLL_API long PTAPI PassThruOpen(void *pName, unsigned long *pDeviceID) { - #pragma EXPORT - if (pDeviceID == NULL) return ret_code(ERR_NULL_PARAMETER); - std::string sn = (pName == NULL) ? "" : std::string((char*)pName); - if (sn == "J2534-2:") - sn = ""; - - auto new_panda = PandaJ2534Device::openByName(sn); - if (new_panda == nullptr) { - if(sn == "" && pandas.size() == 1) - return ret_code(ERR_DEVICE_IN_USE); - for (auto& pn : pandas) { - if (pn->panda->get_usb_sn() == sn) - return ret_code(ERR_DEVICE_IN_USE); - } - return ret_code(ERR_DEVICE_NOT_CONNECTED); - } - - int panda_index = -1; - for (unsigned int i = 0; i < pandas.size(); i++) - if (pandas[i] == nullptr) { - panda_index = i; - pandas[panda_index] = std::move(new_panda); - break; - } - - if (panda_index == -1) { - if(pandas.size() == 0xFFFF) //device id will be 16 bit to fit channel next to it. - return ret_code(ERR_FAILED); //Too many pandas. Off the endangered species list. - pandas.push_back(std::move(new_panda)); - panda_index = pandas.size()-1; - } - - *pDeviceID = panda_index + 1; // TIS doesn't like it when ID == 0 - return ret_code(STATUS_NOERROR); -} -PANDAJ2534DLL_API long PTAPI PassThruClose(unsigned long DeviceID) { - #pragma EXPORT - if (check_valid_DeviceID(DeviceID) != STATUS_NOERROR) return J25334LastError; - get_device(DeviceID) = nullptr; - return ret_code(STATUS_NOERROR); -} -PANDAJ2534DLL_API long PTAPI PassThruConnect(unsigned long DeviceID, unsigned long ProtocolID, - unsigned long Flags, unsigned long BaudRate, unsigned long *pChannelID) { - #pragma EXPORT - if (pChannelID == NULL) return ret_code(ERR_NULL_PARAMETER); - if (check_valid_DeviceID(DeviceID) != STATUS_NOERROR) return J25334LastError; - auto& panda = get_device(DeviceID); - - std::shared_ptr conn; - - //TODO check if channel can be made - try { - switch (ProtocolID) { - //SW seems to refer to Single Wire. https://www.nxp.com/files-static/training_pdf/20451_BUS_COMM_WBT.pdf - //SW_ protocols may be touched on here: https://www.iso.org/obp/ui/#iso:std:iso:22900:-2:ed-1:v1:en - //case J1850VPW: // These protocols are outdated and will not be supported. HDS wants them to not fail to open. - //case J1850PWM: // ^-- it appears HDS no longer needs this, and TIS needs it disabled --^ - //case J1850VPW_PS: - //case J1850PWM_PS: - case ISO9141: //This protocol could be implemented if 5 BAUD init support is added to the panda. - case ISO9141_PS: - case ISO14230: //Only supporting Fast init until panda adds support for 5 BAUD init. - case ISO14230_PS: - conn = std::make_shared(panda, ProtocolID, Flags, BaudRate); - break; - case CAN: - case CAN_PS: - //case SW_CAN_PS: - conn = std::make_shared(panda, ProtocolID, Flags, BaudRate); - break; - case ISO15765: - case ISO15765_PS: - conn = std::make_shared(panda, ProtocolID, Flags, BaudRate); - break; - //case SW_ISO15765_PS: // SW = Single Wire. GMLAN is a SW CAN protocol - //case GM_UART_PS: // PS = Pin Select. Handles different ports. - //Looks like SCI based protocols may not be compatible with the panda: - //http://mdhmotors.com/can-communications-vehicle-network-protocols/3/ - //case SCI_A_ENGINE: - //case SCI_A_TRANS: - //case SCI_B_ENGINE: - //case SCI_B_TRANS: - //case J2610_PS: - default: - return ret_code(ERR_INVALID_PROTOCOL_ID); - } - } catch (int e) { - return ret_code(e); - } - - unsigned long channel_index; - unsigned long err = panda->addChannel(conn, &channel_index); - if (err == STATUS_NOERROR) - *pChannelID = (channel_index << 16) | DeviceID; - - return ret_code(err); -} -PANDAJ2534DLL_API long PTAPI PassThruDisconnect(unsigned long ChannelID) { - #pragma EXPORT - unsigned long res = check_valid_DeviceID(ChannelID); - if (res == ERR_INVALID_DEVICE_ID) return ret_code(ERR_INVALID_CHANNEL_ID); - if (res != STATUS_NOERROR) return J25334LastError; - return ret_code(get_device(ChannelID)->closeChannel(EXTRACT_CID(ChannelID))); -} -PANDAJ2534DLL_API long PTAPI PassThruReadMsgs(unsigned long ChannelID, PASSTHRU_MSG *pMsg, - unsigned long *pNumMsgs, unsigned long Timeout) { - #pragma EXPORT - if (pMsg == NULL || pNumMsgs == NULL) return ret_code(ERR_NULL_PARAMETER); - if (check_valid_ChannelID(ChannelID) != STATUS_NOERROR) return J25334LastError; - return ret_code(get_channel(ChannelID)->PassThruReadMsgs(pMsg, pNumMsgs, Timeout)); -} -PANDAJ2534DLL_API long PTAPI PassThruWriteMsgs(unsigned long ChannelID, PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout) { - #pragma EXPORT - if (pMsg == NULL || pNumMsgs == NULL) return ret_code(ERR_NULL_PARAMETER); - if (check_valid_ChannelID(ChannelID) != STATUS_NOERROR) return J25334LastError; - return ret_code(get_channel(ChannelID)->PassThruWriteMsgs(pMsg, pNumMsgs, Timeout)); -} -PANDAJ2534DLL_API long PTAPI PassThruStartPeriodicMsg(unsigned long ChannelID, PASSTHRU_MSG *pMsg, unsigned long *pMsgID, unsigned long TimeInterval) { - #pragma EXPORT - if (pMsg == NULL || pMsgID == NULL) return ret_code(ERR_NULL_PARAMETER); - if (check_valid_ChannelID(ChannelID) != STATUS_NOERROR) return J25334LastError; - return ret_code(get_channel(ChannelID)->PassThruStartPeriodicMsg(pMsg, pMsgID, TimeInterval)); -} -PANDAJ2534DLL_API long PTAPI PassThruStopPeriodicMsg(unsigned long ChannelID, unsigned long MsgID) { - #pragma EXPORT - if (check_valid_ChannelID(ChannelID) != STATUS_NOERROR) return J25334LastError; - return ret_code(get_channel(ChannelID)->PassThruStopPeriodicMsg(MsgID)); -} -PANDAJ2534DLL_API long PTAPI PassThruStartMsgFilter(unsigned long ChannelID, unsigned long FilterType, PASSTHRU_MSG *pMaskMsg, - PASSTHRU_MSG *pPatternMsg, PASSTHRU_MSG *pFlowControlMsg, unsigned long *pFilterID) { - #pragma EXPORT - if (FilterType != PASS_FILTER && FilterType != BLOCK_FILTER && FilterType != FLOW_CONTROL_FILTER) return ret_code(ERR_NULL_PARAMETER); - if (!pFilterID || (!pMaskMsg && !pPatternMsg && !pFlowControlMsg)) return ret_code(ERR_NULL_PARAMETER); - if (check_valid_ChannelID(ChannelID) != STATUS_NOERROR) return J25334LastError; - return ret_code(get_channel(ChannelID)->PassThruStartMsgFilter(FilterType, pMaskMsg, pPatternMsg, pFlowControlMsg, pFilterID)); -} -PANDAJ2534DLL_API long PTAPI PassThruStopMsgFilter(unsigned long ChannelID, unsigned long FilterID) { - #pragma EXPORT - if (check_valid_ChannelID(ChannelID) != STATUS_NOERROR) return J25334LastError; - return ret_code(get_channel(ChannelID)->PassThruStopMsgFilter(FilterID)); -} -PANDAJ2534DLL_API long PTAPI PassThruSetProgrammingVoltage(unsigned long DeviceID, unsigned long PinNumber, unsigned long Voltage) { - #pragma EXPORT - //Unused - if (check_valid_DeviceID(DeviceID) != STATUS_NOERROR) return J25334LastError; - auto& panda = get_device(DeviceID); - - switch (Voltage) { - case SHORT_TO_GROUND: - break; - case VOLTAGE_OFF: - break; - default: - if (!(5000 <= Voltage && Voltage <= 20000)) - return ret_code(ERR_NOT_SUPPORTED); - break; - } - - return ret_code(STATUS_NOERROR); -} -PANDAJ2534DLL_API long PTAPI PassThruReadVersion(unsigned long DeviceID, char *pFirmwareVersion, char *pDllVersion, char *pApiVersion) { - #pragma EXPORT - if (!pFirmwareVersion || !pDllVersion || !pApiVersion) return ret_code(ERR_NULL_PARAMETER); - if (check_valid_DeviceID(DeviceID) != STATUS_NOERROR) return J25334LastError; - - auto& panda = get_device(DeviceID); - auto fw_version = panda->panda->get_version(); - strcpy_s(pFirmwareVersion, 80, fw_version.c_str()); - - std::string j2534dll_ver; - TCHAR pandalib_filename[MAX_PATH + 1] = { 0 }; - if (GetModuleFileName(thisdll, pandalib_filename, MAX_PATH) == 0) { - j2534dll_ver = "error"; - } else { - j2534dll_ver = GetProductAndVersion(pandalib_filename); - } - std::string fullver = "(" + j2534dll_ver + ")"; - strcpy_s(pDllVersion, 80, fullver.c_str()); - - strcpy_s(pApiVersion, 80, J2534_APIVER_NOVEMBER_2004); - return ret_code(STATUS_NOERROR); -} -PANDAJ2534DLL_API long PTAPI PassThruGetLastError(char *pErrorDescription) { - #pragma EXPORT - if (pErrorDescription == NULL) return ret_code(ERR_NULL_PARAMETER); - switch (J25334LastError) { - case STATUS_NOERROR: - strcpy_s(pErrorDescription, 80, "Function call successful."); - break; - case ERR_NOT_SUPPORTED: - strcpy_s(pErrorDescription, 80, "Device cannot support requested functionality mandated in J2534."); - break; - case ERR_INVALID_CHANNEL_ID: - strcpy_s(pErrorDescription, 80, "Invalid ChannelID value."); - break; - case ERR_INVALID_PROTOCOL_ID: - strcpy_s(pErrorDescription, 80, "Invalid or unsupported ProtocolID, or resource conflict."); - break; - case ERR_NULL_PARAMETER: - strcpy_s(pErrorDescription, 80, "NULL pointer supplied where a valid pointer is required."); - break; - case ERR_INVALID_IOCTL_VALUE: - strcpy_s(pErrorDescription, 80, "Invalid value for Ioctl parameter."); - break; - case ERR_INVALID_FLAGS: - strcpy_s(pErrorDescription, 80, "Invalid flag values."); - break; - case ERR_FAILED: - strcpy_s(pErrorDescription, 80, "Undefined error."); - break; - case ERR_DEVICE_NOT_CONNECTED: - strcpy_s(pErrorDescription, 80, "Unable to communicate with device."); - break; - case ERR_TIMEOUT: - strcpy_s(pErrorDescription, 80, "Read or write timeout:"); - // PassThruReadMsgs() - No message available to read or could not read the specified number of messages. The actual number of messages read is placed in . - // PassThruWriteMsgs() - Device could not write the specified number of messages. The actual number of messages sent on the vehicle network is placed in . - break; - case ERR_INVALID_MSG: - strcpy_s(pErrorDescription, 80, "Invalid message structure pointed to by pMsg."); - break; - case ERR_INVALID_TIME_INTERVAL: - strcpy_s(pErrorDescription, 80, "Invalid TimeInterval value."); - break; - case ERR_EXCEEDED_LIMIT: - strcpy_s(pErrorDescription, 80, "Exceeded maximum number of message IDs or allocated space."); - break; - case ERR_INVALID_MSG_ID: - strcpy_s(pErrorDescription, 80, "Invalid MsgID value."); - break; - case ERR_DEVICE_IN_USE: - strcpy_s(pErrorDescription, 80, "Device is currently open."); - break; - case ERR_INVALID_IOCTL_ID: - strcpy_s(pErrorDescription, 80, "Invalid IoctlID value."); - break; - case ERR_BUFFER_EMPTY: - strcpy_s(pErrorDescription, 80, "Protocol message buffer empty."); - break; - case ERR_BUFFER_FULL: - strcpy_s(pErrorDescription, 80, "Protocol message buffer full. Messages may have been lost."); - break; - case ERR_BUFFER_OVERFLOW: - strcpy_s(pErrorDescription, 80, "A buffer overflow occurred and messages were lost."); - break; - case ERR_PIN_INVALID: - strcpy_s(pErrorDescription, 80, "Invalid pin number, or pin number already in use."); - break; - case ERR_CHANNEL_IN_USE: - strcpy_s(pErrorDescription, 80, "Channel number is currently connected."); - break; - case ERR_MSG_PROTOCOL_ID: - strcpy_s(pErrorDescription, 80, "The Message's Protocol does not match the Channel's protocol."); - break; - case ERR_INVALID_FILTER_ID: - strcpy_s(pErrorDescription, 80, "Invalid Filter ID value."); - break; - case ERR_NO_FLOW_CONTROL: - strcpy_s(pErrorDescription, 80, "No flow control filter set or matched."); - break; - case ERR_NOT_UNIQUE: - strcpy_s(pErrorDescription, 80, "This filter already exists."); - break; - case ERR_INVALID_BAUDRATE: - strcpy_s(pErrorDescription, 80, "The desired baud rate cannot be achieved within SAE tolerance."); - break; - case ERR_INVALID_DEVICE_ID: - strcpy_s(pErrorDescription, 80, "Device ID invalid."); - break; - } - return ret_code(STATUS_NOERROR); -} -PANDAJ2534DLL_API long PTAPI PassThruIoctl(unsigned long ChannelID, unsigned long IoctlID, - void *pInput, void *pOutput) { - #pragma EXPORT - if (check_valid_ChannelID(ChannelID) != STATUS_NOERROR) return J25334LastError; - auto& dev_entry = get_device(ChannelID); - //get_channel(ChannelID) - - switch (IoctlID) { - case GET_CONFIG: - { - SCONFIG_LIST *inconfig = (SCONFIG_LIST*)pInput; - if (inconfig == NULL) - return ret_code(ERR_NULL_PARAMETER); - for (unsigned int i = 0; i < inconfig->NumOfParams; i++) { - try { - inconfig->ConfigPtr[i].Value = get_channel(ChannelID)->processIOCTLGetConfig(inconfig->ConfigPtr[i].Parameter); - } catch (int e) { - return ret_code(e); - } - } - break; - } - case SET_CONFIG: - { - SCONFIG_LIST *inconfig = (SCONFIG_LIST*)pInput; - if (inconfig == NULL) - return ret_code(ERR_NULL_PARAMETER); - for (unsigned int i = 0; i < inconfig->NumOfParams; i++) { - try { - get_channel(ChannelID)->processIOCTLSetConfig(inconfig->ConfigPtr[i].Parameter, inconfig->ConfigPtr[i].Value); - } catch (int e) { - return ret_code(e); - } - } - break; - } - case READ_VBATT: - panda::PANDA_HEALTH health = dev_entry->panda->get_health(); - *(unsigned long*)pOutput = health.voltage; - break; - case FIVE_BAUD_INIT: - if (!pInput || !pOutput) return ret_code(ERR_NULL_PARAMETER); - return ret_code(get_channel(ChannelID)->init5b((SBYTE_ARRAY*)pInput, (SBYTE_ARRAY*)pOutput)); - case FAST_INIT: - if (!pInput || !pOutput) return ret_code(ERR_NULL_PARAMETER); - return ret_code(get_channel(ChannelID)->initFast((PASSTHRU_MSG*)pInput, (PASSTHRU_MSG*)pOutput)); - case CLEAR_TX_BUFFER: - return ret_code(get_channel(ChannelID)->clearTXBuff()); - case CLEAR_RX_BUFFER: - return ret_code(get_channel(ChannelID)->clearRXBuff()); - case CLEAR_PERIODIC_MSGS: - return ret_code(get_channel(ChannelID)->clearPeriodicMsgs()); - case CLEAR_MSG_FILTERS: - return ret_code(get_channel(ChannelID)->clearMsgFilters()); - case CLEAR_FUNCT_MSG_LOOKUP_TABLE: // LOOKUP TABLE IS RELATED TO J1850 PWM. Unsupported. - if (!pInput) return ret_code(ERR_NULL_PARAMETER); - return ret_code(STATUS_NOERROR); - case ADD_TO_FUNCT_MSG_LOOKUP_TABLE: // LOOKUP TABLE IS RELATED TO J1850 PWM. Unsupported. - if (!pInput) return ret_code(ERR_NULL_PARAMETER); - return ret_code(STATUS_NOERROR); - case DELETE_FROM_FUNCT_MSG_LOOKUP_TABLE: // LOOKUP TABLE IS RELATED TO J1850 PWM. Unsupported. - return ret_code(STATUS_NOERROR); - case READ_PROG_VOLTAGE: - *(unsigned long*)pOutput = 0; - break; - default: - printf("Got unknown IIOCTL %X\n", IoctlID); - } - - return ret_code(STATUS_NOERROR); -} diff --git a/panda/drivers/windows/pandaJ2534DLL/pandaJ2534DLL.rc b/panda/drivers/windows/pandaJ2534DLL/pandaJ2534DLL.rc deleted file mode 100644 index e359044825257c..00000000000000 Binary files a/panda/drivers/windows/pandaJ2534DLL/pandaJ2534DLL.rc and /dev/null differ diff --git a/panda/drivers/windows/pandaJ2534DLL/pandaJ2534DLL.vcxproj b/panda/drivers/windows/pandaJ2534DLL/pandaJ2534DLL.vcxproj deleted file mode 100644 index fd5eac56dd4d4a..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/pandaJ2534DLL.vcxproj +++ /dev/null @@ -1,148 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {A2BB18A5-F26B-48D6-BBB5-B83D64473C77} - Win32Proj - pandaJ2534DLL - 10.0.16299.0 - - - - DynamicLibrary - true - v141 - Unicode - - - DynamicLibrary - false - v141 - true - Unicode - - - - - - - - - - - - - - - - true - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - pandaJ2534_0404_32 - - - false - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - pandaJ2534_0404_32 - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;PANDAJ2534DLL_EXPORTS;%(PreprocessorDefinitions) - true - $(SolutionDir); - - - Windows - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);version.lib;winusb.lib;setupapi.lib - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;PANDAJ2534DLL_EXPORTS;%(PreprocessorDefinitions) - true - $(SolutionDir); - - - Windows - true - true - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);version.lib;winusb.lib;setupapi.lib - - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - false - - - - - - - - - - - - - - - Create - Create - - - - - - - - - - - - - \ No newline at end of file diff --git a/panda/drivers/windows/pandaJ2534DLL/pandaJ2534DLL.vcxproj.filters b/panda/drivers/windows/pandaJ2534DLL/pandaJ2534DLL.vcxproj.filters deleted file mode 100644 index 57f7cefb081e74..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/pandaJ2534DLL.vcxproj.filters +++ /dev/null @@ -1,155 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {a4cd0bce-0a2a-43d9-9c9f-b21a3b607e90} - - - {a85ee263-380d-4d37-b167-6629cfd5177f} - - - {010a0176-a146-4d3a-824a-fd683904774d} - - - {71c9502a-ee59-4d5e-873f-c9cc792e7c76} - - - {4fd3183a-c457-430c-b762-f767a5788bca} - - - {53cd179e-22d8-43e2-bc61-516d3861fae6} - - - {08d548b5-4d0b-4ce4-85e6-5ff3fc987758} - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files\J2534_CAN - - - Header Files\J2534_ISO15765 - - - Header Files\depends - - - Header Files\depends - - - Header Files\boilerplate - - - Header Files\boilerplate - - - Header Files\boilerplate - - - Header Files\boilerplate - - - Header Files - - - Header Files\J2534_ISO15765 - - - Header Files - - - Header Files\J2534_ISO15765 - - - Header Files\J2534_CAN - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files\J2534_CAN - - - Source Files\J2534_ISO15765 - - - Source Files\boilerplate - - - Source Files\boilerplate - - - Source Files\J2534_ISO15765 - - - Source Files - - - Source Files\J2534_CAN - - - Source Files - - - - - Resource Files - - - - - - \ No newline at end of file diff --git a/panda/drivers/windows/pandaJ2534DLL/resource.h b/panda/drivers/windows/pandaJ2534DLL/resource.h deleted file mode 100644 index af0e13cc04d638..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/resource.h +++ /dev/null @@ -1,14 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by pandaJ2534DLL.rc - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/panda/drivers/windows/pandaJ2534DLL/stdafx.cpp b/panda/drivers/windows/pandaJ2534DLL/stdafx.cpp deleted file mode 100644 index c27db9ee2d9eb4..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// pandaJ2534DLL.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/panda/drivers/windows/pandaJ2534DLL/stdafx.h b/panda/drivers/windows/pandaJ2534DLL/stdafx.h deleted file mode 100644 index bd4a4b6f78fef9..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/stdafx.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "targetver.h" - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files: -#include - -#include -#include -#include -#include -#include -#include \ No newline at end of file diff --git a/panda/drivers/windows/pandaJ2534DLL/synchronize.h b/panda/drivers/windows/pandaJ2534DLL/synchronize.h deleted file mode 100644 index 446dfc19e3f08b..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/synchronize.h +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once -#define WIN32_LEAN_AND_MEAN -#include - -//Inspired/directly copied from https://www.codeproject.com/Articles/12362/A-quot-synchronized-quot-statement-for-C-like-in-J -//Enables easier synchronization -class Mutex { -public: - Mutex() { - InitializeCriticalSectionAndSpinCount(&critSection, 0x00000400); - //InitializeCriticalSection(&critSection); - } - - ~Mutex() { - DeleteCriticalSection(&critSection); - } - - void lock() { - EnterCriticalSection(&critSection); - } - - void unlock() { - LeaveCriticalSection(&critSection); - } - -private: - CRITICAL_SECTION critSection; -}; - -//Synchronization Controller Object -class Lock { -public: - Lock(Mutex &m) : mutex(m), locked(TRUE) { - m.lock(); - } - - ~Lock() { - mutex.unlock(); - } - - operator bool() const { - return locked; - } - - void setUnlock() { - locked = FALSE; - } - -private: - Mutex& mutex; - bool locked; -}; - -//A useful shorthand for locking and unlocking a mutex over a scope. -//CAUTION, implemented with a for loop, so break/continue are consumed. -#define synchronized(M) for(Lock M##_lock = M; M##_lock; M##_lock.setUnlock()) diff --git a/panda/drivers/windows/pandaJ2534DLL/targetver.h b/panda/drivers/windows/pandaJ2534DLL/targetver.h deleted file mode 100644 index 1bf4ee6fee02e7..00000000000000 --- a/panda/drivers/windows/pandaJ2534DLL/targetver.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include - -#define WINVER _WIN32_WINNT_WIN7 -#define _WIN32_WINNT _WIN32_WINNT_WIN7 - -#include diff --git a/panda/drivers/windows/panda_install.nsi b/panda/drivers/windows/panda_install.nsi deleted file mode 100644 index 47a4423f91b940..00000000000000 --- a/panda/drivers/windows/panda_install.nsi +++ /dev/null @@ -1,214 +0,0 @@ -!define J2534_Reg_Path "Software\PassThruSupport.04.04\comma.ai - panda" -!define Install_Name "panda J2534 driver" - -;NOTE! The panda software requires a VC runtime to be installed in order to work. -;This installer must be bundled with the appropriate runtime installer, and have -;the installation registry key set so the installer can tell if the runtime is -;already installed. Copy vscruntimeinfo.nsh.sample to vscruntimeinfo.nsh and edit -;it for your version of Visual Studio. -!include "redist\vscruntimeinfo.nsh" - -;-------------------------------- -;Include Modern UI -!include "MUI2.nsh" -!include "x64.nsh" - -!define MUI_ICON "panda.ico" -;NSIS is ignoring the unicon unless it is the same as the normal icon -;!define MUI_UNICON "panda_remove.ico" - -;Properly display all languages (Installer will not work on Windows 95, 98 or ME!) -Unicode true - -# Set the installer display name -Name "${Install_Name}" - -# set the name of the installer -Outfile "${Install_Name} install.exe" - -; The default installation directory -InstallDir $PROGRAMFILES\comma.ai\panda - -; Request application privileges for UAC -RequestExecutionLevel admin - -; Registry key to check for directory (so if you install again, it will -; overwrite the old one automatically) -InstallDirRegKey HKLM "SOFTWARE\${Install_Name}" "Install_Dir" - -;-------------------------------- -; Pages -!insertmacro MUI_PAGE_WELCOME -!insertmacro MUI_PAGE_LICENSE "..\..\LICENSE" -!insertmacro MUI_PAGE_COMPONENTS -!insertmacro MUI_PAGE_DIRECTORY -!insertmacro MUI_PAGE_INSTFILES - -!insertmacro MUI_UNPAGE_CONFIRM -!insertmacro MUI_UNPAGE_INSTFILES - -!insertmacro MUI_LANGUAGE "English" ;first language is the default language - -; ------------------------------------------------------------------------------------------------- -; Additional info (will appear in the "details" tab of the properties window for the installer) - -VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "panda OBD-II adapter" -VIAddVersionKey /LANG=${LANG_ENGLISH} "Comments" "" -VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "comma.ai" -VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "Application released under the MIT license" -;VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "© ${PRODUCT_NAME} Team" -;VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Jessy Exum" -;VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${PRODUCT_VERSION}" -VIProductVersion "1.0.0.0" - -;-------------------------------- -; Install Sections -Section "prerequisites" - - SectionIn RO - - SetOutPath "$INSTDIR" - - File "panda.ico" - - ;If the visual studio version this project is compiled with changes, this section - ;must be revisited. The registry key must be changed, and the VS redistributable - ;binary must be updated to the VS version used. - ClearErrors - ReadRegStr $0 HKCR ${VCRuntimeRegKey} "Version" - ${If} ${Errors} - DetailPrint "Installing Visual Studio C Runtime..." - File "${VCRuntimeSetupPath}\${VCRuntimeSetupFile}" - ExecWait '"$INSTDIR\${VCRuntimeSetupFile}" /passive /norestart' - ${Else} - DetailPrint "Visual Studio C Runtime already installed." - ${EndIf} - - ;Remove the now unnecessary runtime installer. - Delete "$INSTDIR\${VCRuntimeSetupFile}" - - ;Do the rest of the install - ; SetOutPath "$INSTDIR\driver" - - ; The inf file works for both 32 and 64 bit. - ; File "Debug_x86\panda Driver Package\panda.inf" - ; File "Debug_x86\panda Driver Package\panda.cat" - ; ${DisableX64FSRedirection} - ; nsExec::ExecToLog '"$SYSDIR\PnPutil.exe" /a "$INSTDIR\driver\panda.inf"' - ; ${EnableX64FSRedirection} - - ; Write the installation path into the registry - WriteRegStr HKLM "SOFTWARE\${Install_Name}" "Install_Dir" "$INSTDIR" - - ; Write the uninstall keys for Windows - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "DisplayVersion" "" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "DisplayIcon" '"$INSTDIR\panda.ico",0' - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "DisplayName" "${Install_Name}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "Publisher" "comma.ai" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "UninstallString" '"$INSTDIR\uninstall.exe"' - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "URLInfoAbout" "https://github.com/commaai/panda/" - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "NoModify" 1 - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "NoRepair" 1 - - SetOutPath $INSTDIR - WriteUninstaller "uninstall.exe" - -SectionEnd - -Section "J2534 Driver" - - SetOutPath $INSTDIR - - File Release_x86\pandaJ2534_0404_32.dll - - SetRegView 32 - WriteRegDWORD HKLM "${J2534_Reg_Path}" "CAN" 00000001 - WriteRegStr HKLM "${J2534_Reg_Path}" "FunctionLibrary" "$INSTDIR\pandaJ2534_0404_32.dll" - WriteRegDWORD HKLM "${J2534_Reg_Path}" "ISO15765" 00000001 - WriteRegDWORD HKLM "${J2534_Reg_Path}" "J1850VPW" 00000000 - WriteRegDWORD HKLM "${J2534_Reg_Path}" "SCI_A_ENGINE" 00000000 - WriteRegDWORD HKLM "${J2534_Reg_Path}" "SCI_A_TRANS" 00000000 - WriteRegDWORD HKLM "${J2534_Reg_Path}" "SCI_B_ENGINE" 00000000 - WriteRegDWORD HKLM "${J2534_Reg_Path}" "SCI_B_TRANS" 00000000 - WriteRegDWORD HKLM "${J2534_Reg_Path}" "J1850PWM" 00000000 - WriteRegDWORD HKLM "${J2534_Reg_Path}" "ISO9141" 00000000 - WriteRegDWORD HKLM "${J2534_Reg_Path}" "ISO14230" 00000001 - WriteRegStr HKLM "${J2534_Reg_Path}" "Name" "panda" - WriteRegStr HKLM "${J2534_Reg_Path}" "Vendor" "comma.ai" - WriteRegStr HKLM "${J2534_Reg_Path}" "ConfigApplication" "" - DetailPrint "Registered J2534 Driver" - -SectionEnd - -Section /o "Development lib/header" - - SetOutPath $SYSDIR - - File Release_x86\panda.dll - - ${If} ${RunningX64} - ${DisableX64FSRedirection} - ;Note that the x64 VS redistributable is not installed to prevent bloat. - ;If you are the rare person who uses the 64 bit raw panda driver, please - ;install the correct x64 VS runtime manually. - File Release_x64\panda.dll - ${EnableX64FSRedirection} - ${EndIf} - - SetOutPath "$INSTDIR\devel" - File panda_shared\panda.h - - SetOutPath "$INSTDIR\devel\x86" - File Release_x86\panda.lib - - SetOutPath "$INSTDIR\devel\x64" - File Release_x64\panda.lib - -SectionEnd - -;-------------------------------- -; Uninstaller -Section "Uninstall" - - ; Removing the inf file for winusb is not easy to do. - ; The best solution I can find is parsing the output - ; of the pnputil.exe /e command to find the oem#.inf - ; file that lists comma.ai as the provider. Not sure - ; if Microsoft wants these inf files to be removed. - ; Consider https://blog.sverrirs.com/2015/12/creating-windows-installer-and.html - ; These lines just remove the inf backups. - ; Delete "$INSTDIR\driver\panda.inf" - ; Delete "$INSTDIR\driver\panda.cat" - ; RMDir "$INSTDIR\driver" - - ; Remove WinUSB driver library - Delete $SYSDIR\panda.dll - ${If} ${RunningX64} - ${DisableX64FSRedirection} - Delete $SYSDIR\panda.dll - ${EnableX64FSRedirection} - ${EndIf} - - ; Remove devel files - Delete "$INSTDIR\devel\x86\panda.lib" - RMDir "$INSTDIR\devel\x86" - Delete "$INSTDIR\devel\x64\panda.lib" - RMDir "$INSTDIR\devel\x64" - Delete "$INSTDIR\devel\panda.h" - RMDir "$INSTDIR\devel" - - ; Remove registry keys - DeleteRegKey HKLM "${J2534_Reg_Path}" - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" - DeleteRegKey HKLM "SOFTWARE\${Install_Name}" - - ; Remove files and uninstaller - Delete "$INSTDIR\uninstall.exe" - Delete "$INSTDIR\pandaJ2534_0404_32.dll" - Delete "$INSTDIR\panda.ico" - - ; Remove directories used - RMDir "$INSTDIR" - RMDir "$PROGRAMFILES\comma.ai" - -SectionEnd diff --git a/panda/drivers/windows/panda_playground/ReadMe.txt b/panda/drivers/windows/panda_playground/ReadMe.txt deleted file mode 100644 index 37dba5d8775a99..00000000000000 --- a/panda/drivers/windows/panda_playground/ReadMe.txt +++ /dev/null @@ -1,40 +0,0 @@ -======================================================================== - CONSOLE APPLICATION : panda_playground Project Overview -======================================================================== - -AppWizard has created this panda_playground application for you. - -This file contains a summary of what you will find in each of the files that -make up your panda_playground application. - - -panda_playground.vcxproj - This is the main project file for VC++ projects generated using an Application Wizard. - It contains information about the version of Visual C++ that generated the file, and - information about the platforms, configurations, and project features selected with the - Application Wizard. - -panda_playground.vcxproj.filters - This is the filters file for VC++ projects generated using an Application Wizard. - It contains information about the association between the files in your project - and the filters. This association is used in the IDE to show grouping of files with - similar extensions under a specific node (for e.g. ".cpp" files are associated with the - "Source Files" filter). - -panda_playground.cpp - This is the main application source file. - -///////////////////////////////////////////////////////////////////////////// -Other standard files: - -StdAfx.h, StdAfx.cpp - These files are used to build a precompiled header (PCH) file - named panda_playground.pch and a precompiled types file named StdAfx.obj. - -///////////////////////////////////////////////////////////////////////////// -Other notes: - -AppWizard uses "TODO:" comments to indicate parts of the source code you -should add to or customize. - -///////////////////////////////////////////////////////////////////////////// diff --git a/panda/drivers/windows/panda_playground/panda_playground.cpp b/panda/drivers/windows/panda_playground/panda_playground.cpp deleted file mode 100644 index 0f51924dbcbd2d..00000000000000 --- a/panda/drivers/windows/panda_playground/panda_playground.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// panda_playground.cpp : Defines the entry point for the console application. -// - -#include "stdafx.h" -#include "pandaJ2534DLL Test\Loader4.h" -#include "ECUsim DLL\ECUsim.h" -#include - - -int _tmain(int Argc, _TCHAR *Argv) { - UNREFERENCED_PARAMETER(Argc); - UNREFERENCED_PARAMETER(Argv); - - ECUsim sim("", 500000); - - //if (LoadJ2534Dll("C:\\WINDOWS\\SysWOW64\\op20pt32.dll") != 0) { - if (LoadJ2534Dll("pandaJ2534.dll") != 0) { - auto err = GetLastError(); - return 1; - } - unsigned long did, cid, fid; - PassThruOpen("", &did); - PassThruConnect(did, ISO15765, CAN_29BIT_ID, 500000, &cid); - - PASSTHRU_MSG mask, pattern, flow; - - memcpy(mask.Data, "\xff\xff\xff\xff", 4); - mask.DataSize = 4; - mask.ProtocolID = ISO15765; - mask.TxFlags = CAN_29BIT_ID; - mask.ExtraDataIndex = 0; - mask.RxStatus = 0; - - ////////////////////////18//DA//F1//EF - memcpy(pattern.Data, "\x18\xda\xf1\xef", 4); - pattern.DataSize = 4; - pattern.ProtocolID = ISO15765; - pattern.TxFlags = CAN_29BIT_ID; - pattern.ExtraDataIndex = 0; - pattern.RxStatus = 0; - - memcpy(flow.Data, "\x18\xda\xef\xf1", 4); - flow.DataSize = 4; - flow.ProtocolID = ISO15765; - flow.TxFlags = CAN_29BIT_ID; - flow.ExtraDataIndex = 0; - flow.RxStatus = 0; - - auto res = PassThruStartMsgFilter(cid, FLOW_CONTROL_FILTER, &mask, &pattern, &flow, &fid); - if (res != STATUS_NOERROR) - return 1; - - SCONFIG_LIST list; - SCONFIG config; - config.Parameter = LOOPBACK; - config.Value = 0; - list.ConfigPtr = &config; - list.NumOfParams = 1; - - res = PassThruIoctl(cid, SET_CONFIG, &list, NULL); - if (res != STATUS_NOERROR) - return 1; - - PASSTHRU_MSG outmsg; - memcpy(outmsg.Data, "\x18\xda\xef\xf1""\xAA\xBB\xCC\xDD\xEE\xFF\x11\x22\x33\x44", 4 + 10); - outmsg.DataSize = 4 + 10; - outmsg.ProtocolID = ISO15765; - outmsg.TxFlags = CAN_29BIT_ID; - outmsg.ExtraDataIndex = 0; - outmsg.RxStatus = 0; - - unsigned long msgoutcount = 1; - - res = PassThruWriteMsgs(cid, &outmsg, &msgoutcount, 0); - if (res != STATUS_NOERROR) - return 1; - - PASSTHRU_MSG inmsg[8]; - unsigned long msgincount = 8; - - res = PassThruReadMsgs(cid, inmsg, &msgincount, 1000); - if (res != STATUS_NOERROR) - return 1; - - return 0; -} diff --git a/panda/drivers/windows/panda_playground/panda_playground.vcxproj b/panda/drivers/windows/panda_playground/panda_playground.vcxproj deleted file mode 100644 index 2b5f3120c34721..00000000000000 --- a/panda/drivers/windows/panda_playground/panda_playground.vcxproj +++ /dev/null @@ -1,191 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {691DB635-C272-4B98-897E-0505B970DCA9} - Win32Proj - panda_playground - 10.0.16299.0 - - - - Application - true - v141 - Unicode - - - Application - false - v141 - true - Unicode - - - Application - true - v141 - Unicode - - - Application - false - v141 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - $(ProjectName)2 - - - true - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - $(ProjectName) - - - false - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - false - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories);$(SolutionDir) - - - Console - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib;$(OutDir)ecusim.lib - - - - - Use - Level3 - Disabled - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories);$(SolutionDir) - - - Console - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib;$(OutDir)ecusim.lib - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories);$(SolutionDir) - - - Console - true - true - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib;$(OutDir)ecusim.lib - - - - - Level3 - Use - MaxSpeed - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories);$(SolutionDir) - - - Console - true - true - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib;$(OutDir)ecusim.lib - - - - - - - - - - - - - - - - Create - Create - Create - Create - - - - - {96e0e646-ee76-444d-9a77-a0cd7f781deb} - - - {a2bb18a5-f26b-48d6-bbb5-b83d64473c77} - - - {5528aefb-638d-49af-b9d4-965154e7d531} - - - - - - \ No newline at end of file diff --git a/panda/drivers/windows/panda_playground/panda_playground.vcxproj.filters b/panda/drivers/windows/panda_playground/panda_playground.vcxproj.filters deleted file mode 100644 index b84fc23184e2c9..00000000000000 --- a/panda/drivers/windows/panda_playground/panda_playground.vcxproj.filters +++ /dev/null @@ -1,45 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/panda/drivers/windows/panda_playground/stdafx.cpp b/panda/drivers/windows/panda_playground/stdafx.cpp deleted file mode 100644 index fefa8d7ec924ca..00000000000000 --- a/panda/drivers/windows/panda_playground/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// panda_playground.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/panda/drivers/windows/panda_playground/stdafx.h b/panda/drivers/windows/panda_playground/stdafx.h deleted file mode 100644 index f22759b0866ee2..00000000000000 --- a/panda/drivers/windows/panda_playground/stdafx.h +++ /dev/null @@ -1,17 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files: -#include - -#include -#include -#include -#include diff --git a/panda/drivers/windows/panda_playground/targetver.h b/panda/drivers/windows/panda_playground/targetver.h deleted file mode 100644 index 87c0086de751ba..00000000000000 --- a/panda/drivers/windows/panda_playground/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/panda/drivers/windows/panda_remove.ico b/panda/drivers/windows/panda_remove.ico deleted file mode 100644 index 74602e03e913d3..00000000000000 Binary files a/panda/drivers/windows/panda_remove.ico and /dev/null differ diff --git a/panda/drivers/windows/panda_shared/device.cpp b/panda/drivers/windows/panda_shared/device.cpp deleted file mode 100644 index 83e021b7994ad4..00000000000000 --- a/panda/drivers/windows/panda_shared/device.cpp +++ /dev/null @@ -1,169 +0,0 @@ -#include "stdafx.h" - -#include -#include - -#include -#include - -#include - -#include "device.h" - -using namespace panda; - -//Returns the last Win32 error, in string format. Returns an empty string if there is no error. -tstring GetLastErrorAsString(){ - //Get the error message, if any. - DWORD errorMessageID = ::GetLastError(); - if (errorMessageID == 0) - return tstring(); //No error message has been recorded - - _TCHAR *messageBuffer = nullptr; - size_t size = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, errorMessageID, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (_TCHAR*)&messageBuffer, 0, NULL); - - tstring message(messageBuffer, size); - - //Free the buffer. - LocalFree(messageBuffer); - - return message; -} - -std::unordered_map panda::detect_pandas() { - HDEVINFO deviceInfo; - HRESULT hr; - SP_DEVINFO_DATA deviceInfoData; - SP_DEVICE_INTERFACE_DATA interfaceData; - unsigned int deviceIndex; - - std::unordered_map map_sn_to_devpath; - - deviceInfo = SetupDiGetClassDevs(&GUID_DEVINTERFACE_panda, - NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); //DIGCF_ALLCLASSES - - if (deviceInfo == INVALID_HANDLE_VALUE) { - hr = HRESULT_FROM_WIN32(GetLastError()); - _tprintf(_T("Failed to get dev handle. HR: %d\n"), hr); - return map_sn_to_devpath; - } - - ZeroMemory(&deviceInfoData, sizeof(SP_DEVINFO_DATA)); - deviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); - deviceIndex = 0; - - while (SetupDiEnumDeviceInfo(deviceInfo, deviceIndex, &deviceInfoData)) { - deviceIndex++; - _tprintf(_T("Device info index %d\n"), deviceIndex); - - interfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); - if (SetupDiEnumDeviceInterfaces(deviceInfo, &deviceInfoData, - &GUID_DEVINTERFACE_panda, 0, &interfaceData) == FALSE) { - _tprintf(_T(" Got unexpected error while accessing interface %d\n"), GetLastError()); - continue; - } - - DWORD requiredLength; - if (SetupDiGetDeviceInterfaceDetail(deviceInfo, &interfaceData, NULL, 0, &requiredLength, NULL) == FALSE - && ERROR_INSUFFICIENT_BUFFER != GetLastError()) { - _tprintf(_T(" Got unexpected error while reading interface details %d\n"), GetLastError()); - continue; - } - - PSP_DEVICE_INTERFACE_DETAIL_DATA detailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)LocalAlloc(LMEM_FIXED, requiredLength); - if (NULL == detailData) { - _tprintf(_T(" Failed to allocate %d bytes for interface data\n"), requiredLength); - continue; - } - detailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); - - DWORD length = requiredLength; - if (SetupDiGetDeviceInterfaceDetail(deviceInfo, &interfaceData, detailData, length, &requiredLength, NULL) == FALSE) { - _tprintf(_T(" Got unexpected error while reading interface details (2nd time) %d. Msg: '%s'\n"), - GetLastError(), GetLastErrorAsString().c_str()); - LocalFree(detailData); - continue; - } - - //_tprintf(_T(" Path: '%s'\n"), detailData->DevicePath); - HANDLE deviceHandle = CreateFile(detailData->DevicePath, - GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ, - NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL); - - if (INVALID_HANDLE_VALUE == deviceHandle) { - _tprintf(_T(" Error opening Device Handle %d. Msg: '%s'\n"), - GetLastError(), GetLastErrorAsString().c_str()); - LocalFree(detailData); - continue; - } - - WINUSB_INTERFACE_HANDLE winusbHandle; - if (WinUsb_Initialize(deviceHandle, &winusbHandle) == FALSE) { - _tprintf(_T(" Error initializing WinUSB %d. Msg: '%s'\n"), - GetLastError(), GetLastErrorAsString().c_str()); - CloseHandle(deviceHandle); - LocalFree(detailData); - continue; - } - - USB_DEVICE_DESCRIPTOR deviceDesc; - unsigned long lengthReceived; - if (WinUsb_GetDescriptor(winusbHandle, USB_DEVICE_DESCRIPTOR_TYPE, 0, 0, - (PBYTE)&deviceDesc, sizeof(deviceDesc), &lengthReceived) == FALSE - || lengthReceived != sizeof(deviceDesc)) { - _tprintf(_T(" Error getting device descriptor %d. Msg: '%s'\n"), - GetLastError(), GetLastErrorAsString().c_str()); - WinUsb_Free(winusbHandle); - CloseHandle(deviceHandle); - LocalFree(detailData); - continue; - } - - #define SNDESCLEN 64 - PUSB_STRING_DESCRIPTOR psnDesc = (PUSB_STRING_DESCRIPTOR)LocalAlloc(LMEM_FIXED, SNDESCLEN); - if (NULL == psnDesc) { - _tprintf(_T(" Failed to allocate %d bytes for sn data\n"), SNDESCLEN); - continue; - } - - if (WinUsb_GetDescriptor(winusbHandle, USB_STRING_DESCRIPTOR_TYPE, deviceDesc.iSerialNumber, - 0x0409 /*Eng*/, (PBYTE)psnDesc, SNDESCLEN, &lengthReceived) == FALSE || lengthReceived == 0) { - _tprintf(_T(" Error getting serial number %d. Msg: '%s'\n"), - GetLastError(), GetLastErrorAsString().c_str()); - LocalFree(psnDesc); - WinUsb_Free(winusbHandle); - CloseHandle(deviceHandle); - LocalFree(detailData); - continue; - } - //The minus 2 is for the two numbers, not the null term. - psnDesc->bString[(psnDesc->bLength - 2) / sizeof(_TCHAR)] = 0; - - char w_to_m_buff[256]; - size_t mbuff_len; - if (wcstombs_s(&mbuff_len, w_to_m_buff, sizeof(w_to_m_buff), psnDesc->bString, 24) != 0) { - _tprintf(_T(" Error generating mb SN string %d. Msg: '%s'\n"), - GetLastError(), GetLastErrorAsString().c_str()); - LocalFree(psnDesc); - WinUsb_Free(winusbHandle); - CloseHandle(deviceHandle); - LocalFree(detailData); - continue; - } - std::string serialnum(w_to_m_buff, mbuff_len-1); - printf(" Device found: seriallen: %d; serial: %s\n", lengthReceived, serialnum.c_str()); - - map_sn_to_devpath[serialnum] = tstring(detailData->DevicePath); - - LocalFree(psnDesc); - WinUsb_Free(winusbHandle); - CloseHandle(deviceHandle); - LocalFree(detailData); - } - - if(deviceInfo) - SetupDiDestroyDeviceInfoList(deviceInfo); - - return map_sn_to_devpath; -} diff --git a/panda/drivers/windows/panda_shared/device.h b/panda/drivers/windows/panda_shared/device.h deleted file mode 100644 index f11baa1c67c887..00000000000000 --- a/panda/drivers/windows/panda_shared/device.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __PANDA_DEVICE -#define __PANDA_DEVICE - -// -// Define below GUIDs -// -#include -#include - -#if defined(UNICODE) -#define _tcout std::wcout -#define tstring std::wstring -#else -#define _tcout std::cout -#define tstring std::string -#endif - -// -// Device Interface GUID. -// Used by all WinUsb devices that this application talks to. -// Must match "DeviceInterfaceGUIDs" registry value specified in the INF file. -// cce5291c-a69f-4995-a4c2-2ae57a51ade9 -// -DEFINE_GUID(GUID_DEVINTERFACE_panda, - 0xcce5291c,0xa69f,0x4995,0xa4,0xc2,0x2a,0xe5,0x7a,0x51,0xad,0xe9); - -tstring GetLastErrorAsString(); - -namespace panda { - std::unordered_map __declspec(dllexport) detect_pandas(); -} -#endif diff --git a/panda/drivers/windows/panda_shared/panda.cpp b/panda/drivers/windows/panda_shared/panda.cpp deleted file mode 100644 index 5f711b02aa28a1..00000000000000 --- a/panda/drivers/windows/panda_shared/panda.cpp +++ /dev/null @@ -1,522 +0,0 @@ -// panda.cpp : Defines the exported functions for the DLL application. -// -#include "stdafx.h" - -#include "device.h" -#include "panda.h" - -#define REQUEST_IN 0xC0 -#define REQUEST_OUT 0x40 - -#define CAN_TRANSMIT 1 -#define CAN_EXTENDED 4 - -using namespace panda; - -Panda::Panda( - WINUSB_INTERFACE_HANDLE WinusbHandle, - HANDLE DeviceHandle, - tstring devPath_, - std::string sn_ -) : usbh(WinusbHandle), devh(DeviceHandle), devPath(devPath_), sn(sn_) { - printf("CREATED A PANDA %s\n", this->sn.c_str()); - this->set_can_loopback(FALSE); - this->set_raw_io(TRUE); - this->set_alt_setting(0); -} - -Panda::~Panda() { - WinUsb_Free(this->usbh); - CloseHandle(this->devh); - printf("Cleanup Panda %s\n", this->sn.c_str()); -} - -std::vector Panda::listAvailablePandas() { - std::vector ret; - auto map_sn_to_devpath = detect_pandas(); - - for (auto kv : map_sn_to_devpath) { - ret.push_back(std::string(kv.first)); - } - - return ret; -} - -std::unique_ptr Panda::openPanda(std::string sn) -{ - auto map_sn_to_devpath = detect_pandas(); - - if (map_sn_to_devpath.empty()) return nullptr; - if (map_sn_to_devpath.find(sn) == map_sn_to_devpath.end() && sn != "") return nullptr; - - tstring devpath; - if (sn.empty()) { - sn = map_sn_to_devpath.begin()->first; - devpath = map_sn_to_devpath.begin()->second; - } else { - devpath = map_sn_to_devpath[sn]; - } - - HANDLE deviceHandle = CreateFile(devpath.c_str(), - GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ, - NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL); - - if (INVALID_HANDLE_VALUE == deviceHandle) { - _tprintf(_T(" Error opening Device Handle %d.\n"),// Msg: '%s'\n"), - GetLastError());// , GetLastErrorAsString().c_str()); - return nullptr; - } - - WINUSB_INTERFACE_HANDLE winusbHandle; - if (WinUsb_Initialize(deviceHandle, &winusbHandle) == FALSE) { - _tprintf(_T(" Error initializing WinUSB %d.\n"),// Msg: '%s'\n"), - GetLastError());// , GetLastErrorAsString().c_str()); - CloseHandle(deviceHandle); - return nullptr; - } - - return std::unique_ptr(new Panda(winusbHandle, deviceHandle, map_sn_to_devpath[sn], sn)); -} - -std::string Panda::get_usb_sn() { - return std::string(this->sn); -} - -int Panda::control_transfer( - uint8_t bmRequestType, - uint8_t bRequest, - uint16_t wValue, - uint16_t wIndex, - void * data, - uint16_t wLength, - unsigned int timeout -) { - UNREFERENCED_PARAMETER(timeout); - - WINUSB_SETUP_PACKET SetupPacket; - ZeroMemory(&SetupPacket, sizeof(WINUSB_SETUP_PACKET)); - ULONG cbSent = 0; - - //Create the setup packet - SetupPacket.RequestType = bmRequestType; - SetupPacket.Request = bRequest; - SetupPacket.Value = wValue; - SetupPacket.Index = wIndex; - SetupPacket.Length = wLength; - - //ULONG timeout = 10; // ms - //WinUsb_SetPipePolicy(interfaceHandle, pipeID, PIPE_TRANSFER_TIMEOUT, sizeof(ULONG), &timeout); - - if (WinUsb_ControlTransfer(this->usbh, SetupPacket, (PUCHAR)data, wLength, &cbSent, 0) == FALSE) { - return -1; - } - - return cbSent; -} - -int Panda::bulk_write(UCHAR endpoint, const void * buff, ULONG length, PULONG transferred, ULONG timeout) { - if (this->usbh == INVALID_HANDLE_VALUE || !buff || !length || !transferred) return FALSE; - - if (WinUsb_WritePipe(this->usbh, endpoint, (PUCHAR)buff, length, transferred, NULL) == FALSE) { - _tprintf(_T(" Got error during bulk xfer: %d. Msg: '%s'\n"), - GetLastError(), GetLastErrorAsString().c_str()); - return FALSE; - } - return TRUE; -} - -int Panda::bulk_read(UCHAR endpoint, void * buff, ULONG buff_size, PULONG transferred, ULONG timeout) { - if (this->usbh == INVALID_HANDLE_VALUE || !buff || !buff_size || !transferred) return FALSE; - - if (WinUsb_ReadPipe(this->usbh, endpoint, (PUCHAR)buff, buff_size, transferred, NULL) == FALSE) { - _tprintf(_T(" Got error during bulk xfer: %d. Msg: '%s'\n"), - GetLastError(), GetLastErrorAsString().c_str()); - return FALSE; - } - return TRUE; -} - -bool Panda::set_alt_setting(UCHAR alt_setting) { - if (WinUsb_AbortPipe(this->usbh, 0x81) == FALSE) { - _tprintf(_T(" Error abobrting pipe before setting altsetting. continue. %d, Msg: '%s'\n"), - GetLastError(), GetLastErrorAsString().c_str()); - } - if (WinUsb_SetCurrentAlternateSetting(this->usbh, alt_setting) == FALSE) { - _tprintf(_T(" Error setting usb altsetting %d, Msg: '%s'\n"), - GetLastError(), GetLastErrorAsString().c_str()); - return FALSE; - } - - // Either the panda or the windows usb stack can drop messages - // if an odd number of messages are sent before an interrupt IN - // message is canceled. There are some other odd behaviors, but - // the best solution so far has been to send a few messages - // before using the device to clear out the pipe. No, the windows - // functions for clearing/resetting/etc the pipe did not work. - // This took way too to figure out a workaround. - // New info. The most repeatable behavior is losing the first - // message sent after setting alt setting to 1 (even without - // receiving). Something like this happened on linux sometimes. - bool loopback_backup = this->loopback; - this->set_can_loopback(TRUE); - Sleep(20); // Give time for any sent messages to appear in the RX buffer. - this->can_clear(PANDA_CAN_RX); - // send 4 messages becaus can_recv reads 4 messages at a time - for (int i = 0; i < 4; i++) { - printf("Sending PAD %d\n", i); - if (this->can_send(0x7FF, FALSE, {}, 0, PANDA_CAN1) == FALSE) { - auto err = GetLastError(); - printf("Got err on first send: %d\n", err); - } - } - Sleep(10); - //this->can_clear(PANDA_CAN_RX); - - //Read the messages so they do not contaimnate the real message stream. - this->can_recv(); - - //this->set_can_loopback(FALSE); - this->set_can_loopback(loopback_backup); - - return TRUE; -} - -UCHAR Panda::get_current_alt_setting() { - UCHAR alt_setting; - if (WinUsb_GetCurrentAlternateSetting(this->usbh, &alt_setting) == FALSE) { - _tprintf(_T(" Error getting usb altsetting %d, Msg: '%s'\n"), - GetLastError(), GetLastErrorAsString().c_str()); - return FALSE; - } - - return alt_setting; -} - -bool Panda::set_raw_io(bool val) { - UCHAR raw_io = val; - if (!WinUsb_SetPipePolicy(this->usbh, 0x81, RAW_IO, sizeof(raw_io), &raw_io)) { - _tprintf(_T(" Error setting usb raw I/O pipe policy %d, Msg: '%s'\n"), - GetLastError(), GetLastErrorAsString().c_str()); - return FALSE; - } - - return TRUE; -} - -PANDA_HEALTH Panda::get_health() -{ - WINUSB_SETUP_PACKET SetupPacket; - ZeroMemory(&SetupPacket, sizeof(WINUSB_SETUP_PACKET)); - ULONG cbSent = 0; - - //Create the setup packet - SetupPacket.RequestType = REQUEST_IN; - SetupPacket.Request = 0xD2; - SetupPacket.Value = 0; - SetupPacket.Index = 0; - SetupPacket.Length = sizeof(UCHAR); - - //uint8_t health[13]; - PANDA_HEALTH health; - - if (WinUsb_ControlTransfer(this->usbh, SetupPacket, (PUCHAR)&health, sizeof(health), &cbSent, 0) == FALSE) { - _tprintf(_T(" Got unexpected error while reading panda health (2nd time) %d. Msg: '%s'\n"), - GetLastError(), GetLastErrorAsString().c_str()); - } - - return health; -} - -bool Panda::enter_bootloader() { - return this->control_transfer(REQUEST_OUT, 0xd1, 0, 0, NULL, 0, 0) != -1; -} - -std::string Panda::get_version() { - char buff[0x40]; - ZeroMemory(&buff, sizeof(buff)); - - int xferCount = this->control_transfer(REQUEST_IN, 0xd6, 0, 0, buff, 0x40, 0); - if (xferCount == -1) return std::string(); - return std::string(buff); -} - -//TODO: Do hash stuff for calculating the serial. -std::string Panda::get_serial() { - char buff[0x20]; - ZeroMemory(&buff, sizeof(buff)); - - int xferCount = this->control_transfer(REQUEST_IN, 0xD0, 0, 0, buff, 0x20, 0); - if (xferCount == -1) return std::string(); - return std::string(buff); - - //dat = self._handle.controlRead(REQUEST_IN, 0xd0, 0, 0, 0x20); - //hashsig, calc_hash = dat[0x1c:], hashlib.sha1(dat[0:0x1c]).digest()[0:4] - // assert(hashsig == calc_hash) - // return[dat[0:0x10], dat[0x10:0x10 + 10]] -} - -//Secret appears to by raw bytes, not a string. TODO: Change returned type. -std::string Panda::get_secret() { - char buff[0x10]; - ZeroMemory(&buff, sizeof(buff)); - - int xferCount = this->control_transfer(REQUEST_IN, 0xd0, 1, 0, buff, 0x10, 0); - if (xferCount == -1) return std::string(); - return std::string(buff); -} - -bool Panda::set_usb_power(bool on) { - return this->control_transfer(REQUEST_OUT, 0xe6, (int)on, 0, NULL, 0, 0) != -1; -} - -bool Panda::set_esp_power(bool on) { - return this->control_transfer(REQUEST_OUT, 0xd9, (int)on, 0, NULL, 0, 0) != -1; -} - -bool Panda::esp_reset(uint16_t bootmode = 0) { - return this->control_transfer(REQUEST_OUT, 0xda, bootmode, 0, NULL, 0, 0) != -1; -} - -bool Panda::set_safety_mode(PANDA_SAFETY_MODE mode = SAFETY_NOOUTPUT) { - return this->control_transfer(REQUEST_OUT, 0xdc, mode, 0, NULL, 0, 0) != -1; -} - -bool Panda::set_can_forwarding(PANDA_CAN_PORT from_bus, PANDA_CAN_PORT to_bus) { - if (from_bus == PANDA_CAN_UNK) return FALSE; - return this->control_transfer(REQUEST_OUT, 0xdd, from_bus, to_bus, NULL, 0, 0) != -1; -} - -bool Panda::set_gmlan(PANDA_GMLAN_HOST_PORT bus = PANDA_GMLAN_CAN3) { - return this->control_transfer(REQUEST_OUT, 0xdb, 1, (bus == PANDA_GMLAN_CLEAR) ? 0 : bus, NULL, 0, 0) != -1; -} - -bool Panda::set_can_loopback(bool enable) { - this->loopback = enable; - return this->control_transfer(REQUEST_OUT, 0xe5, enable, 0, NULL, 0, 0) != -1; -} - -//Can not use the full range of 16 bit speed. -//cbps means centa bits per second (tento of kbps) -bool Panda::set_can_speed_cbps(PANDA_CAN_PORT bus, uint16_t speed) { - if (bus == PANDA_CAN_UNK) return FALSE; - return this->control_transfer(REQUEST_OUT, 0xde, bus, speed, NULL, 0, 0) != -1; -} - -//Can not use the full range of 16 bit speed. -bool Panda::set_can_speed_kbps(PANDA_CAN_PORT bus, uint16_t speed) { - return set_can_speed_cbps(bus, speed * 10); -} - -//Can not use full 32 bit range of rate -bool Panda::set_uart_baud(PANDA_SERIAL_PORT uart, uint32_t rate) { - return this->control_transfer(REQUEST_OUT, 0xe4, uart, rate / 300, NULL, 0, 0) != -1; -} - -bool Panda::set_uart_parity(PANDA_SERIAL_PORT uart, PANDA_SERIAL_PORT_PARITY parity) { - return this->control_transfer(REQUEST_OUT, 0xe2, uart, parity, NULL, 0, 0) != -1; -} - -bool Panda::can_send_many(const std::vector& can_msgs) { - std::vector formatted_msgs; - formatted_msgs.reserve(can_msgs.size()); - - for (auto msg : can_msgs) { - if (msg.bus == PANDA_CAN_UNK) continue; - if (msg.len > 8) continue; - PANDA_CAN_MSG_INTERNAL tmpmsg = {}; - tmpmsg.rir = (msg.addr_29b) ? - ((msg.addr << 3) | CAN_TRANSMIT | CAN_EXTENDED) : - (((msg.addr & 0x7FF) << 21) | CAN_TRANSMIT); - tmpmsg.f2 = msg.len | (msg.bus << 4); - memcpy(tmpmsg.dat, msg.dat, msg.len); - formatted_msgs.push_back(tmpmsg); - } - - if (formatted_msgs.size() == 0) return FALSE; - - unsigned int retcount; - return this->bulk_write(3, formatted_msgs.data(), - sizeof(PANDA_CAN_MSG_INTERNAL)*formatted_msgs.size(), (PULONG)&retcount, 0); -} - -bool Panda::can_send(uint32_t addr, bool addr_29b, const uint8_t *dat, uint8_t len, PANDA_CAN_PORT bus) { - if (bus == PANDA_CAN_UNK) return FALSE; - if (len > 8) return FALSE; - PANDA_CAN_MSG msg; - msg.addr_29b = addr_29b; - msg.addr = addr; - msg.len = len; - memcpy(msg.dat, dat, msg.len); - msg.bus = bus; - return this->can_send_many(std::vector{msg}); -} - -PANDA_CAN_MSG Panda::parse_can_recv(PANDA_CAN_MSG_INTERNAL *in_msg_raw) { - PANDA_CAN_MSG in_msg; - - in_msg.addr_29b = (bool)(in_msg_raw->rir & CAN_EXTENDED); - in_msg.addr = (in_msg.addr_29b) ? (in_msg_raw->rir >> 3) : (in_msg_raw->rir >> 21); - in_msg.recv_time = this->runningTime.getTimePassedUS(); - in_msg.recv_time_point = std::chrono::steady_clock::now(); - //The timestamp from the device is (in_msg_raw->f2 >> 16), - //but this 16 bit value is a little hard to use. Using a - //timer since the initialization of this device. - in_msg.len = in_msg_raw->f2 & 0xF; - memcpy(in_msg.dat, in_msg_raw->dat, 8); - - in_msg.is_receipt = ((in_msg_raw->f2 >> 4) & 0x80) == 0x80; - switch ((in_msg_raw->f2 >> 4) & 0x7F) { - case PANDA_CAN1: - in_msg.bus = PANDA_CAN1; - break; - case PANDA_CAN2: - in_msg.bus = PANDA_CAN2; - break; - case PANDA_CAN3: - in_msg.bus = PANDA_CAN3; - break; - default: - in_msg.bus = PANDA_CAN_UNK; - } - return in_msg; -} - -bool Panda::can_rx_q_push(HANDLE kill_event, DWORD timeoutms) { - while (1) { - auto w_ptr = this->w_ptr; - auto n_ptr = w_ptr + 1; - if (n_ptr == CAN_RX_QUEUE_LEN) { - n_ptr = 0; - } - - // Pause if there is not a slot available in the queue - if (n_ptr == this->r_ptr) { - printf("RX queue full!\n"); - Sleep(1); - continue; - } - - if (this->can_rx_q[n_ptr].complete) { - // TODO: is ResetEvent() faster? - CloseHandle(this->can_rx_q[n_ptr].complete); - } - - // Overlapped structure required for async read. - this->can_rx_q[n_ptr].complete = CreateEvent(NULL, TRUE, TRUE, NULL); - memset(&this->can_rx_q[n_ptr].overlapped, sizeof(OVERLAPPED), 0); - this->can_rx_q[n_ptr].overlapped.hEvent = this->can_rx_q[n_ptr].complete; - this->can_rx_q[n_ptr].error = 0; - - if (!WinUsb_ReadPipe(this->usbh, 0x81, this->can_rx_q[n_ptr].data, sizeof(this->can_rx_q[n_ptr].data), &this->can_rx_q[n_ptr].count, &this->can_rx_q[n_ptr].overlapped)) { - // An overlapped read will return true if done, or false with an - // error of ERROR_IO_PENDING if the transfer is still in process. - this->can_rx_q[n_ptr].error = GetLastError(); - } - - // Process the pipe read call from the previous invocation of this function - if (this->can_rx_q[w_ptr].error == ERROR_IO_PENDING) { - HANDLE phSignals[2] = { this->can_rx_q[w_ptr].complete, kill_event }; - auto dwError = WaitForMultipleObjects(kill_event ? 2 : 1, phSignals, FALSE, timeoutms); - - // Check if packet, timeout (nope), or break - if (dwError == WAIT_OBJECT_0) { - // Signal came from our usb object. Read the returned data. - if (!GetOverlappedResult(this->usbh, &this->can_rx_q[w_ptr].overlapped, &this->can_rx_q[w_ptr].count, TRUE)) { - // TODO: handle other error cases better. - dwError = GetLastError(); - printf("Got overlap error %d\n", dwError); - - continue; - } - } - else { - WinUsb_AbortPipe(this->usbh, 0x81); - - // Return FALSE to show that the optional signal - // was set instead of the wait breaking from a - // message or recoverable error. - if (dwError == (WAIT_OBJECT_0 + 1)) { - return FALSE; - } - continue; - } - } - else if (this->can_rx_q[w_ptr].error != 0) { // ERROR_BAD_COMMAND happens when device is unplugged. - return FALSE; - } - - this->w_ptr = n_ptr; - } - - return TRUE; -} - -void Panda::can_rx_q_pop(PANDA_CAN_MSG msg_out[], int &count) { - count = 0; - - // No data left in queue - if (this->r_ptr == this->w_ptr) { - Sleep(1); - return; - } - - auto r_ptr = this->r_ptr; - for (int i = 0; i < this->can_rx_q[r_ptr].count; i += sizeof(PANDA_CAN_MSG_INTERNAL)) { - auto in_msg_raw = (PANDA_CAN_MSG_INTERNAL *)(this->can_rx_q[r_ptr].data + i); - msg_out[count] = parse_can_recv(in_msg_raw); - ++count; - } - - // Advance read pointer (wrap around if needed) - ++r_ptr; - this->r_ptr = (r_ptr == CAN_RX_QUEUE_LEN ? 0 : r_ptr); -} - -std::vector Panda::can_recv() { - std::vector msg_recv; - int retcount; - char buff[sizeof(PANDA_CAN_MSG_INTERNAL) * 4]; - - if (this->bulk_read(0x81, buff, sizeof(buff), (PULONG)&retcount, 0) == FALSE) - return msg_recv; - - for (int i = 0; i < retcount; i += sizeof(PANDA_CAN_MSG_INTERNAL)) { - PANDA_CAN_MSG_INTERNAL *in_msg_raw = (PANDA_CAN_MSG_INTERNAL *)(buff + i); - auto in_msg = parse_can_recv(in_msg_raw); - msg_recv.push_back(in_msg); - } - - return msg_recv; -} - -bool Panda::can_clear(PANDA_CAN_PORT_CLEAR bus) { - /*Clears all messages from the specified internal CAN ringbuffer as though it were drained. - bus(int) : can bus number to clear a tx queue, or 0xFFFF to clear the global can rx queue.*/ - return this->control_transfer(REQUEST_OUT, 0xf1, bus, 0, NULL, 0, 0) != -1; -} - -std::string Panda::serial_read(PANDA_SERIAL_PORT port_number) { - std::string result; - char buff[0x40]; - while (TRUE) { - int retlen = this->control_transfer(REQUEST_IN, 0xe0, port_number, 0, &buff, 0x40, 0); - if (retlen <= 0) - break; - result += std::string(buff, retlen); - if (retlen < 0x40) break; - } - return result; -} - -int Panda::serial_write(PANDA_SERIAL_PORT port_number, const void* buff, uint16_t len) { - std::string dat; - dat += port_number; - dat += std::string((char*)buff, len); - int retcount; - if (this->bulk_write(2, dat.c_str(), len+1, (PULONG)&retcount, 0) == FALSE) return -1; - return retcount; -} - -bool Panda::serial_clear(PANDA_SERIAL_PORT port_number) { - return this->control_transfer(REQUEST_OUT, 0xf2, port_number, 0, NULL, 0, 0) != -1; -} diff --git a/panda/drivers/windows/panda_shared/panda.h b/panda/drivers/windows/panda_shared/panda.h deleted file mode 100644 index ade8fa36a8601e..00000000000000 --- a/panda/drivers/windows/panda_shared/panda.h +++ /dev/null @@ -1,237 +0,0 @@ -#pragma once - -// The following ifdef block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the PANDA_EXPORTS -// symbol defined on the command line. This symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// PANDA_API functions as being imported from a DLL, whereas this DLL sees symbols -// defined with this macro as being exported. -#ifdef PANDA_EXPORTS -#define PANDA_API __declspec(dllexport) -#else -#define PANDA_API -#endif - -#include -#include -#include -#include -#include -#include - -#include -#include - -#if defined(UNICODE) -#define _tcout std::wcout -#define tstring std::wstring -#else -#define _tcout std::cout -#define tstring std::string -#endif - -#define LIN_MSG_MAX_LEN 10 -#define CAN_RX_QUEUE_LEN 10000 -#define CAN_RX_MSG_LEN 1000 - -//template class __declspec(dllexport) std::basic_string; - -namespace panda { - typedef enum _PANDA_SAFETY_MODE : uint16_t { - SAFETY_NOOUTPUT = 0, - SAFETY_HONDA = 1, - SAFETY_ALLOUTPUT = 0x1337, - } PANDA_SAFETY_MODE; - - typedef enum _PANDA_SERIAL_PORT : uint8_t { - SERIAL_DEBUG = 0, - SERIAL_ESP = 1, - SERIAL_LIN1 = 2, - SERIAL_LIN2 = 3, - } PANDA_SERIAL_PORT; - - typedef enum _PANDA_SERIAL_PORT_PARITY : uint8_t { - PANDA_PARITY_OFF = 0, - PANDA_PARITY_EVEN = 1, - PANDA_PARITY_ODD = 2, - } PANDA_SERIAL_PORT_PARITY; - - typedef enum _PANDA_CAN_PORT : uint8_t { - PANDA_CAN1 = 0, - PANDA_CAN2 = 1, - PANDA_CAN3 = 2, - PANDA_CAN_UNK = 0xFF, - } PANDA_CAN_PORT; - - typedef enum _PANDA_CAN_PORT_CLEAR : uint16_t { - PANDA_CAN1_TX = 0, - PANDA_CAN2_TX = 1, - PANDA_CAN3_TX = 2, - PANDA_CAN_RX = 0xFFFF, - } PANDA_CAN_PORT_CLEAR; - - typedef enum _PANDA_GMLAN_HOST_PORT : uint8_t { - PANDA_GMLAN_CLEAR = 0, - PANDA_GMLAN_CAN2 = 1, - PANDA_GMLAN_CAN3 = 2, - } PANDA_GMLAN_HOST_PORT; - - #pragma pack(1) - typedef struct _PANDA_HEALTH { - uint32_t voltage; - uint32_t current; - uint8_t started; - uint8_t controls_allowed; - uint8_t gas_interceptor_detected; - uint8_t started_signal_detected; - uint8_t started_alt; - } PANDA_HEALTH, *PPANDA_HEALTH; - - typedef struct _PANDA_CAN_MSG { - uint32_t addr; - unsigned long long recv_time; //In microseconds since device initialization - std::chrono::time_point recv_time_point; - uint8_t dat[8]; - uint8_t len; - PANDA_CAN_PORT bus; - bool is_receipt; - bool addr_29b; - } PANDA_CAN_MSG; - - //Copied from https://stackoverflow.com/a/31488113 - class Timer - { - using clock = std::chrono::steady_clock; - using time_point_type = std::chrono::time_point < clock, std::chrono::microseconds >; - public: - Timer() { - start = std::chrono::time_point_cast(clock::now()); - } - - // gets the time elapsed from construction. - unsigned long long /*microseconds*/ Timer::getTimePassedUS() { - // get the new time - auto end = std::chrono::time_point_cast(clock::now()); - - // return the difference of the times - return (end - start).count(); - } - - // gets the time elapsed from construction. - unsigned long long /*milliseconds*/ Timer::getTimePassedMS() { - // get the new time - auto end = std::chrono::time_point_cast(clock::now()); - - // return the difference of the times - auto startms = std::chrono::time_point_cast(start); - return (end - startms).count(); - } - private: - time_point_type start; - }; - - // This class is exported from the panda.dll - class PANDA_API Panda { - public: - static std::vector listAvailablePandas(); - static std::unique_ptr openPanda(std::string sn); - - ~Panda(); - - std::string get_usb_sn(); - bool set_alt_setting(UCHAR alt_setting); - UCHAR get_current_alt_setting(); - bool Panda::set_raw_io(bool val); - - PANDA_HEALTH get_health(); - bool enter_bootloader(); - std::string get_version(); - std::string get_serial(); - std::string get_secret(); - - bool set_usb_power(bool on); - bool set_esp_power(bool on); - bool esp_reset(uint16_t bootmode); - bool set_safety_mode(PANDA_SAFETY_MODE mode); - bool set_can_forwarding(PANDA_CAN_PORT from_bus, PANDA_CAN_PORT to_bus); - bool set_gmlan(PANDA_GMLAN_HOST_PORT bus); - bool set_can_loopback(bool enable); - bool set_can_speed_cbps(PANDA_CAN_PORT bus, uint16_t speed); - bool set_can_speed_kbps(PANDA_CAN_PORT bus, uint16_t speed); - bool set_uart_baud(PANDA_SERIAL_PORT uart, uint32_t rate); - bool set_uart_parity(PANDA_SERIAL_PORT uart, PANDA_SERIAL_PORT_PARITY parity); - - bool can_send_many(const std::vector& can_msgs); - bool can_send(uint32_t addr, bool addr_29b, const uint8_t *dat, uint8_t len, PANDA_CAN_PORT bus); - std::vector can_recv(); - bool can_rx_q_push(HANDLE kill_event, DWORD timeoutms = INFINITE); - void can_rx_q_pop(PANDA_CAN_MSG msg_out[], int &count); - bool can_clear(PANDA_CAN_PORT_CLEAR bus); - - std::string serial_read(PANDA_SERIAL_PORT port_number); - int serial_write(PANDA_SERIAL_PORT port_number, const void* buff, uint16_t len); - bool serial_clear(PANDA_SERIAL_PORT port_number); - private: - Panda( - WINUSB_INTERFACE_HANDLE WinusbHandle, - HANDLE DeviceHandle, - tstring devPath_, - std::string sn_ - ); - - int control_transfer( - uint8_t bmRequestType, - uint8_t bRequest, - uint16_t wValue, - uint16_t wIndex, - void * data, - uint16_t wLength, - unsigned int timeout - ); - - int bulk_write( - UCHAR endpoint, - const void * buff, - ULONG length, - PULONG transferred, - ULONG timeout - ); - - int Panda::bulk_read( - UCHAR endpoint, - void * buff, - ULONG buff_size, - PULONG transferred, - ULONG timeout - ); - - #pragma pack(1) - typedef struct _PANDA_CAN_MSG_INTERNAL { - uint32_t rir; - uint32_t f2; - uint8_t dat[8]; - } PANDA_CAN_MSG_INTERNAL; - - typedef struct _CAN_RX_PIPE_READ { - unsigned char data[sizeof(PANDA_CAN_MSG_INTERNAL) * CAN_RX_MSG_LEN]; - unsigned long count; - OVERLAPPED overlapped; - HANDLE complete; - DWORD error; - } CAN_RX_PIPE_READ; - - PANDA_CAN_MSG parse_can_recv(PANDA_CAN_MSG_INTERNAL *in_msg_raw); - - WINUSB_INTERFACE_HANDLE usbh; - HANDLE devh; - tstring devPath; - std::string sn; - bool loopback; - - Timer runningTime; - CAN_RX_PIPE_READ can_rx_q[CAN_RX_QUEUE_LEN]; - unsigned long w_ptr = 0; - unsigned long r_ptr = 0; - }; - -} diff --git a/panda/drivers/windows/panda_shared/panda_shared.vcxitems b/panda/drivers/windows/panda_shared/panda_shared.vcxitems deleted file mode 100644 index 3f3b4765c0225c..00000000000000 --- a/panda/drivers/windows/panda_shared/panda_shared.vcxitems +++ /dev/null @@ -1,25 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - {0c843279-68c7-4679-ae51-9bc463d50d1c} - - - - %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/panda/drivers/windows/panda_shared/targetver.h b/panda/drivers/windows/panda_shared/targetver.h deleted file mode 100644 index 1bf4ee6fee02e7..00000000000000 --- a/panda/drivers/windows/panda_shared/targetver.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include - -#define WINVER _WIN32_WINNT_WIN7 -#define _WIN32_WINNT _WIN32_WINNT_WIN7 - -#include diff --git a/panda/drivers/windows/redist/.gitignore b/panda/drivers/windows/redist/.gitignore deleted file mode 100644 index 90d431bfbaed71..00000000000000 --- a/panda/drivers/windows/redist/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.exe -vscruntimeinfo.nsh diff --git a/panda/drivers/windows/redist/README.md b/panda/drivers/windows/redist/README.md deleted file mode 100644 index 69565f11c6cd1b..00000000000000 --- a/panda/drivers/windows/redist/README.md +++ /dev/null @@ -1,7 +0,0 @@ -When building the installer, please put the relevant vc_redist.x86.exe file into this folder. -Make sure that the uninstall registry key is correct in the panda_install.nsi file. - -Here is a list of the VC runtime downloads: https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads -An list of the registry keys has been maintained here: https://stackoverflow.com/a/34209692/627525 - -Copy vscruntimeinfo.nsh.sample to vscruntimeinfo.nsh and edit it for your version of Visual Studio. \ No newline at end of file diff --git a/panda/drivers/windows/redist/vscruntimeinfo.nsh.sample b/panda/drivers/windows/redist/vscruntimeinfo.nsh.sample deleted file mode 100644 index 3e74ab1d9c5b33..00000000000000 --- a/panda/drivers/windows/redist/vscruntimeinfo.nsh.sample +++ /dev/null @@ -1,13 +0,0 @@ -;NOTE! The panda software requires a VC runtime to be installed in order to work. -;This installer must be bundled with the appropriate runtime installer, and have -;the installation registry key set so the installer can tell if the runtime is -;already installed. - -;Here is a list of the VC runtime downloads: https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads -;An list of the registry keys has been maintained here: https://stackoverflow.com/a/34209692/627525 - - -;Microsoft Visual C++ 2015 Redistributable (x86) - 14.0.24123 -!define VCRuntimeRegKey "SOFTWARE\Classes\Installer\Dependencies\{206898cc-4b41-4d98-ac28-9f9ae57f91fe}" -!define VCRuntimeSetupPath "redist\" -!define VCRuntimeSetupFile "vc_redist.x86.exe" \ No newline at end of file diff --git a/panda/drivers/windows/test certs/commaaiCertStore.pvk b/panda/drivers/windows/test certs/commaaiCertStore.pvk deleted file mode 100644 index 6db0a7885d2ff4..00000000000000 Binary files a/panda/drivers/windows/test certs/commaaiCertStore.pvk and /dev/null differ diff --git a/panda/drivers/windows/test certs/commaaicert.cer b/panda/drivers/windows/test certs/commaaicert.cer deleted file mode 100644 index 8d0a38a7c00f37..00000000000000 Binary files a/panda/drivers/windows/test certs/commaaicert.cer and /dev/null differ diff --git a/panda/examples/can_bit_transition.md b/panda/examples/can_bit_transition.md deleted file mode 100644 index fa0a6c6bb354fd..00000000000000 --- a/panda/examples/can_bit_transition.md +++ /dev/null @@ -1,25 +0,0 @@ -# How to use can_bit_transition.py to reverse engineer a single bit field - -Let's say our goal is to find a brake pedal signal (caused by your foot pressing the brake pedal vs adaptive cruise control braking). - -The following process will allow you to quickly find bits that are always 0 during a period of time (when you know you were not pressing the brake with your foot) and always 1 in a different period of time (when you know you were pressing the brake with your foot). - -Open up a drive in cabana where you can find a place you used the brake pedal and another place where you did not use the brake pedal (and you can identify when you were on the brake pedal and when you were not). You may want to go out for a drive and put something in front of the camera after you put your foot on the brake and take it away before you take your foot off the brake so you can easily identify exactly when you had your foot on the brake based on the video in cabana. This is critical because this script needs the brake signal to always be high the entire time for one of the time frames. A 10 second time frame worked well for me. - -I found a drive where I knew I was not pressing the brake between timestamp 50.0 thru 65.0 and I was pressing the brake between timestamp 69.0 thru 79.0. Determine what the timestamps are in cabana by plotting any message and putting your mouse over the plot at the location you want to discover the timestamp. The tool tip on mouse hover has the format: timestamp: value - -Now download the log from cabana (Save Log button) and run the script passing in the timestamps -(replace csv file name with cabana log you downloaded and time ranges with your own) -``` -./can_bit_transition.py ./honda_crv_ex_2017_can-1520354796875.csv 50.0-65.0 69.0-79.0 -``` - -The script will output bits that were always low in the first time range and always high in the second time range (and vice versa) -``` -id 17c 0 -> 1 at byte 4 bitmask 1 -id 17c 0 -> 1 at byte 6 bitmask 32 -id 221 1 -> 0 at byte 0 bitmask 4 -id 1be 0 -> 1 at byte 0 bitmask 16 -``` - -Now I go back to cabana and graph the above bits by searching for the message by id, double clicking on the appropriate bit, and then selecting "show plot". I already knew that message id 0x17c is both user brake and adaptive cruise control braking combined, so I plotted one of those signals along side 0x221 and 0x1be. By replaying a drive I could see that 0x221 was not a brake signal (when high at random times that did not correspond to braking). Next I looked at 0x1be and I found it was the brake pedal signal I was looking for (went high whenever I pressed the brake pedal and did not go high when adaptive cruise control was braking). \ No newline at end of file diff --git a/panda/examples/can_bit_transition.py b/panda/examples/can_bit_transition.py deleted file mode 100755 index 5c15e4bbc26eed..00000000000000 --- a/panda/examples/can_bit_transition.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env python - -import binascii -import csv -import sys - -class Message(): - """Details about a specific message ID.""" - def __init__(self, message_id): - self.message_id = message_id - self.ones = [0] * 8 # bit set if 1 is always seen - self.zeros = [0] * 8 # bit set if 0 is always seen - - def printBitDiff(self, other): - """Prints bits that transition from always zero to always 1 and vice versa.""" - for i in xrange(len(self.ones)): - zero_to_one = other.zeros[i] & self.ones[i] - if zero_to_one: - print 'id %s 0 -> 1 at byte %d bitmask %d' % (self.message_id, i, zero_to_one) - one_to_zero = other.ones[i] & self.zeros[i] - if one_to_zero: - print 'id %s 1 -> 0 at byte %d bitmask %d' % (self.message_id, i, one_to_zero) - - -class Info(): - """A collection of Messages.""" - - def __init__(self): - self.messages = {} # keyed by MessageID - - def load(self, filename, start, end): - """Given a CSV file, adds information about message IDs and their values.""" - with open(filename, 'rb') as input: - reader = csv.reader(input) - next(reader, None) # skip the CSV header - for row in reader: - if not len(row): continue - time = float(row[0]) - bus = int(row[2]) - if time < start or bus > 127: - continue - elif time > end: - break - if row[1].startswith('0x'): - message_id = row[1][2:] # remove leading '0x' - else: - message_id = hex(int(row[1]))[2:] # old message IDs are in decimal - message_id = '%s:%s' % (bus, message_id) - if row[3].startswith('0x'): - data = row[3][2:] # remove leading '0x' - else: - data = row[3] - new_message = False - if message_id not in self.messages: - self.messages[message_id] = Message(message_id) - new_message = True - message = self.messages[message_id] - bytes = bytearray.fromhex(data) - for i in xrange(len(bytes)): - ones = int(bytes[i]) - message.ones[i] = ones if new_message else message.ones[i] & ones - # Inverts the data and masks it to a byte to get the zeros as ones. - zeros = (~int(bytes[i])) & 0xff - message.zeros[i] = zeros if new_message else message.zeros[i] & zeros - -def PrintUnique(log_file, low_range, high_range): - # find messages with bits that are always low - start, end = map(float, low_range.split('-')) - low = Info() - low.load(log_file, start, end) - # find messages with bits that are always high - start, end = map(float, high_range.split('-')) - high = Info() - high.load(log_file, start, end) - # print messages that go from low to high - found = False - for message_id in sorted(high.messages): - if message_id in low.messages: - high.messages[message_id].printBitDiff(low.messages[message_id]) - found = True - if not found: print 'No messages that transition from always low to always high found!' - -if __name__ == "__main__": - if len(sys.argv) < 4: - print 'Usage:\n%s log.csv - -' % sys.argv[0] - sys.exit(0) - PrintUnique(sys.argv[1], sys.argv[2], sys.argv[3]) diff --git a/panda/examples/can_logger.py b/panda/examples/can_logger.py deleted file mode 100755 index 05c28a26df1228..00000000000000 --- a/panda/examples/can_logger.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python -from __future__ import print_function -import binascii -import csv -import sys -from panda import Panda - -def can_logger(): - - try: - print("Trying to connect to Panda over USB...") - p = Panda() - - except AssertionError: - print("USB connection failed. Trying WiFi...") - - try: - p = Panda("WIFI") - except: - print("WiFi connection timed out. Please make sure your Panda is connected and try again.") - sys.exit(0) - - try: - outputfile = open('output.csv', 'wb') - csvwriter = csv.writer(outputfile) - #Write Header - csvwriter.writerow(['Bus', 'MessageID', 'Message', 'MessageLength']) - print("Writing csv file output.csv. Press Ctrl-C to exit...\n") - - bus0_msg_cnt = 0 - bus1_msg_cnt = 0 - bus2_msg_cnt = 0 - - while True: - can_recv = p.can_recv() - - for address, _, dat, src in can_recv: - csvwriter.writerow([str(src), str(hex(address)), "0x" + binascii.hexlify(dat), len(dat)]) - - if src == 0: - bus0_msg_cnt += 1 - elif src == 1: - bus1_msg_cnt += 1 - elif src == 2: - bus2_msg_cnt += 1 - - print("Message Counts... Bus 0: " + str(bus0_msg_cnt) + " Bus 1: " + str(bus1_msg_cnt) + " Bus 2: " + str(bus2_msg_cnt), end='\r') - - except KeyboardInterrupt: - print("\nNow exiting. Final message Counts... Bus 0: " + str(bus0_msg_cnt) + " Bus 1: " + str(bus1_msg_cnt) + " Bus 2: " + str(bus2_msg_cnt)) - outputfile.close() - -if __name__ == "__main__": - can_logger() diff --git a/panda/examples/can_unique.md b/panda/examples/can_unique.md deleted file mode 100644 index 4d8ac460e4d6c3..00000000000000 --- a/panda/examples/can_unique.md +++ /dev/null @@ -1,103 +0,0 @@ -# How to use can_unique.py to reverse engineer a single bit field - -Let's say our goal is to find the CAN message indicating that the driver's door is either open or closed. -The following process is great for simple single-bit messages. -However for frequently changing values, such as RPM or speed, Cabana's graphical plots are probably better to use. - - -First record a few minutes of background CAN messages with all the doors closed and save it in background.csv: -``` -./can_logger.py -mv output.csv background.csv -``` -Then run can_logger.py for a few seconds while performing the action you're interested, such as opening and then closing the -front-left door and save it as door-fl-1.csv -Repeat the process and save it as door-f1-2.csv to have an easy way to confirm any suspicions. - -Now we'll use can_unique.py to look for unique bits: -``` -$ ./can_unique.py door-fl-1.csv background* -id 820 new one at byte 2 bitmask 2 -id 520 new one at byte 3 bitmask 7 -id 520 new zero at byte 3 bitmask 8 -id 520 new one at byte 5 bitmask 6 -id 520 new zero at byte 5 bitmask 9 -id 559 new zero at byte 6 bitmask 4 -id 804 new one at byte 5 bitmask 2 -id 804 new zero at byte 5 bitmask 1 - -$ ./can_unique.py door-fl-2.csv background* -id 672 new one at byte 3 bitmask 3 -id 820 new one at byte 2 bitmask 2 -id 520 new one at byte 3 bitmask 7 -id 520 new zero at byte 3 bitmask 8 -id 520 new one at byte 5 bitmask 6 -id 520 new zero at byte 5 bitmask 9 -id 559 new zero at byte 6 bitmask 4 -``` - -One of these bits hopefully indicates that the driver's door is open. -Let's go through each message ID to figure out which one is correct. -We expect any correct bits to have changed in both runs. -We can rule out 804 because it only occurred in the first run. -We can rule out 672 because it only occurred in the second run. -That leaves us with these message IDs: 820, 520, 559. Let's take a closer look at each one. - -``` -$ fgrep ,559, door-fl-1.csv |head -0,559,00ff0000000024f0 -0,559,00ff000000004464 -0,559,00ff0000000054a9 -0,559,00ff0000000064e3 -0,559,00ff00000000742e -0,559,00ff000000008451 -0,559,00ff00000000949c -0,559,00ff00000000a4d6 -0,559,00ff00000000b41b -0,559,00ff00000000c442 -``` -Message ID 559 looks like an incrementing value, so it's not what we're looking for. - -``` -$ fgrep ,520, door-fl-2.csv -0,520,26ff00f8a1890000 -0,520,26ff00f8a2890000 -0,520,26ff00f8a2890000 -0,520,26ff00f8a1890000 -0,520,26ff00f8a2890000 -0,520,26ff00f8a1890000 -0,520,26ff00f8a2890000 -0,520,26ff00f8a1890000 -0,520,26ff00f8a2890000 -0,520,26ff00f8a1890000 -0,520,26ff00f8a2890000 -0,520,26ff00f8a1890000 -``` -Message ID 520 oscillates between two values. However I only opened and closed the door once, so this is probably not it. - -``` -$ fgrep ,820, door-fl-1.csv -0,820,44000100a500c802 -0,820,44000100a500c803 -0,820,44000300a500c803 -0,820,44000300a500c802 -0,820,44000300a500c802 -0,820,44000300a500c802 -0,820,44000100a500c802 -0,820,44000100a500c802 -0,820,44000100a500c802 -``` -Message ID 820 looks promising! It starts off at 44000100a500c802 when the door is closed. -When the door is open it goes to 44000300a500c802. -Then when the door is closed again, it goes back to 44000100a500c802. -Let's confirm by looking at the data from our other run: -``` -$ fgrep ,820, door-fl-2.csv -0,820,44000100a500c802 -0,820,44000300a500c802 -0,820,44000100a500c802 -``` -Perfect! We now know that message id 820 at byte 2 bitmask 2 is set if the driver's door is open. -If we repeat the process with the front passenger's door, -then we'll find that message id 820 at byte 2 bitmask 4 is set if the front-right door is open. -This confirms our finding because it's common for similar signals to be near each other. diff --git a/panda/examples/can_unique.py b/panda/examples/can_unique.py deleted file mode 100755 index ad6de296ee4174..00000000000000 --- a/panda/examples/can_unique.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env python - -# Given an interesting CSV file of CAN messages and a list of background CAN -# messages, print which bits in the interesting file have never appeared -# in the background files. - -# Expects the CSV file to be in the format from can_logger.py -# Bus,MessageID,Message,MessageLength -# 0,0x292,0x040000001068,6 - -# The old can_logger.py format is also supported: -# Bus,MessageID,Message -# 0,344,c000c00000000000 - - -import binascii -import csv -import sys -from panda import Panda - -class Message(): - """Details about a specific message ID.""" - def __init__(self, message_id): - self.message_id = message_id - self.data = {} # keyed by hex string encoded message data - self.ones = [0] * 8 # bit set if 1 is seen - self.zeros = [0] * 8 # bit set if 0 has been seen - - def printBitDiff(self, other): - """Prints bits that are set or cleared compared to other background.""" - for i in xrange(len(self.ones)): - new_ones = ((~other.ones[i]) & 0xff) & self.ones[i] - if new_ones: - print 'id %s new one at byte %d bitmask %d' % ( - self.message_id, i, new_ones) - new_zeros = ((~other.zeros[i]) & 0xff) & self.zeros[i] - if new_zeros: - print 'id %s new zero at byte %d bitmask %d' % ( - self.message_id, i, new_zeros) - - -class Info(): - """A collection of Messages.""" - - def __init__(self): - self.messages = {} # keyed by MessageID - - def load(self, filename): - """Given a CSV file, adds information about message IDs and their values.""" - with open(filename, 'rb') as input: - reader = csv.reader(input) - next(reader, None) # skip the CSV header - for row in reader: - bus = row[0] - if row[1].startswith('0x'): - message_id = row[1][2:] # remove leading '0x' - else: - message_id = hex(int(row[1]))[2:] # old message IDs are in decimal - message_id = '%s:%s' % (bus, message_id) - if row[1].startswith('0x'): - data = row[2][2:] # remove leading '0x' - else: - data = row[2] - if message_id not in self.messages: - self.messages[message_id] = Message(message_id) - message = self.messages[message_id] - if data not in self.messages[message_id].data: - message.data[data] = True - bytes = bytearray.fromhex(data) - for i in xrange(len(bytes)): - message.ones[i] = message.ones[i] | int(bytes[i]) - # Inverts the data and masks it to a byte to get the zeros as ones. - message.zeros[i] = message.zeros[i] | ( (~int(bytes[i])) & 0xff) - -def PrintUnique(interesting_file, background_files): - background = Info() - for background_file in background_files: - background.load(background_file) - interesting = Info() - interesting.load(interesting_file) - for message_id in sorted(interesting.messages): - if message_id not in background.messages: - print 'New message_id: %s' % message_id - else: - interesting.messages[message_id].printBitDiff( - background.messages[message_id]) - - -if __name__ == "__main__": - if len(sys.argv) < 3: - print 'Usage:\n%s interesting.csv background*.csv' % sys.argv[0] - sys.exit(0) - PrintUnique(sys.argv[1], sys.argv[2:]) diff --git a/panda/examples/get_panda_password.py b/panda/examples/get_panda_password.py deleted file mode 100644 index 575cbb0795b6c4..00000000000000 --- a/panda/examples/get_panda_password.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -from panda import Panda - -def get_panda_password(): - - try: - print("Trying to connect to Panda over USB...") - p = Panda() - - except AssertionError: - print("USB connection failed") - sys.exit(0) - - wifi = p.get_serial() - #print('[%s]' % ', '.join(map(str, wifi))) - print("SSID: " + wifi[0]) - print("Password: " + wifi[1]) - -if __name__ == "__main__": - get_panda_password() \ No newline at end of file diff --git a/panda/examples/query_vin_and_stats.py b/panda/examples/query_vin_and_stats.py deleted file mode 100755 index f3d6c198aff9f1..00000000000000 --- a/panda/examples/query_vin_and_stats.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python -import time -import struct -from panda import Panda -from hexdump import hexdump -from panda.python.isotp import isotp_send, isotp_recv - -# 0x7e0 = Toyota -# 0x18DB33F1 for Honda? - -def get_current_data_for_pid(pid): - # 01 xx = Show current data - isotp_send(panda, "\x01"+chr(pid), 0x7e0) - return isotp_recv(panda, 0x7e8) - -def get_supported_pids(): - ret = [] - pid = 0 - while 1: - supported = struct.unpack(">I", get_current_data_for_pid(pid)[2:])[0] - for i in range(1+pid, 0x21+pid): - if supported & 0x80000000: - ret.append(i) - supported <<= 1 - pid += 0x20 - if pid not in ret: - break - return ret - -if __name__ == "__main__": - panda = Panda() - panda.set_safety_mode(Panda.SAFETY_ELM327) - panda.can_clear(0) - - # 09 02 = Get VIN - isotp_send(panda, "\x09\x02", 0x7df) - ret = isotp_recv(panda, 0x7e8) - hexdump(ret) - print "VIN: %s" % ret[2:] - - # 03 = get DTCS - isotp_send(panda, "\x03", 0x7e0) - dtcs = isotp_recv(panda, 0x7e8) - print "DTCs:", dtcs[2:].encode("hex") - - supported_pids = get_supported_pids() - print "Supported PIDs:",supported_pids - - while 1: - speed = struct.unpack(">B", get_current_data_for_pid(13)[2:])[0] # kph - rpm = struct.unpack(">H", get_current_data_for_pid(12)[2:])[0]/4.0 # revs - throttle = struct.unpack(">B", get_current_data_for_pid(17)[2:])[0]/255.0 * 100 # percent - temp = struct.unpack(">B", get_current_data_for_pid(5)[2:])[0] - 40 # degrees C - load = struct.unpack(">B", get_current_data_for_pid(4)[2:])[0]/255.0 * 100 # percent - print "%d KPH, %d RPM, %.1f%% Throttle, %d deg C, %.1f%% load" % (speed, rpm, throttle, temp, load) - time.sleep(0.2) - - - diff --git a/panda/examples/tesla_tester.py b/panda/examples/tesla_tester.py deleted file mode 100644 index 4365e424bb9911..00000000000000 --- a/panda/examples/tesla_tester.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python -import sys -import binascii -from panda import Panda - -def tesla_tester(): - - try: - print("Trying to connect to Panda over USB...") - p = Panda() - - except AssertionError: - print("USB connection failed. Trying WiFi...") - - try: - p = Panda("WIFI") - except: - print("WiFi connection timed out. Please make sure your Panda is connected and try again.") - sys.exit(0) - - body_bus_speed = 125 # Tesla Body busses (B, BF) are 125kbps, rest are 500kbps - body_bus_num = 1 # My TDC to OBD adapter has PT on bus0 BDY on bus1 and CH on bus2 - p.set_can_speed_kbps(body_bus_num, body_bus_speed) - - # Now set the panda from its default of SAFETY_NOOUTPUT (read only) to SAFETY_ALLOUTPUT - # Careful, as this will let us send any CAN messages we want (which could be very bad!) - print("Setting Panda to output mode...") - p.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - - # BDY 0x248 is the MCU_commands message, which includes folding mirrors, opening the trunk, frunk, setting the cars lock state and more. For our test, we will edit the 3rd byte, which is MCU_lockRequest. 0x01 will lock, 0x02 will unlock: - print("Unlocking Tesla...") - p.can_send(0x248, "\x00\x00\x02\x00\x00\x00\x00\x00", body_bus_num) - - #Or, we can set the first byte, MCU_frontHoodCommand + MCU_liftgateSwitch, to 0x01 to pop the frunk, or 0x04 to open/close the trunk (0x05 should open both) - print("Opening Frunk...") - p.can_send(0x248, "\x01\x00\x00\x00\x00\x00\x00\x00", body_bus_num) - - #Back to safety... - print("Disabling output on Panda...") - p.set_safety_mode(Panda.SAFETY_NOOUTPUT) - - print("Reading VIN from 0x568. This is painfully slow and can take up to 3 minutes (1 minute per message; 3 messages needed for full VIN)...") - - vin = {} - while True: - #Read the VIN - can_recv = p.can_recv() - for address, _, dat, src in can_recv: - if src == body_bus_num: - if address == 1384: #0x568 is VIN - vin_index = int(binascii.hexlify(dat)[:2]) #first byte is the index, 00, 01, 02 - vin_string = binascii.hexlify(dat)[2:] #rest of the string is the actual VIN data - vin[vin_index] = vin_string.decode("hex") - print("Got VIN index " + str(vin_index) + " data " + vin[vin_index]) - #if we have all 3 parts of the VIN, print it and break out of our while loop - if 0 in vin and 1 in vin and 2 in vin: - print("VIN: " + vin[0] + vin[1] + vin[2][:3]) - break - -if __name__ == "__main__": - tesla_tester() diff --git a/panda/panda.png b/panda/panda.png deleted file mode 100644 index e18137d8727c0f..00000000000000 Binary files a/panda/panda.png and /dev/null differ diff --git a/panda/python/__init__.py b/panda/python/__init__.py index e83a4a16947366..936c975f07a4c5 100644 --- a/panda/python/__init__.py +++ b/panda/python/__init__.py @@ -1,6 +1,5 @@ # python library to interface with panda -from __future__ import print_function -import binascii +import datetime import struct import hashlib import socket @@ -9,12 +8,13 @@ import time import traceback import subprocess -from dfu import PandaDFU -from esptool import ESPROM, CesantaFlasher -from flash_release import flash_release -from update import ensure_st_up_to_date -from serial import PandaSerial -from isotp import isotp_send, isotp_recv +import sys +from .dfu import PandaDFU # pylint: disable=import-error +from .flash_release import flash_release # noqa pylint: disable=import-error +from .update import ensure_st_up_to_date # noqa pylint: disable=import-error +from .serial import PandaSerial # noqa pylint: disable=import-error +from .isotp import isotp_send, isotp_recv # pylint: disable=import-error + __version__ = '0.0.9' @@ -23,31 +23,27 @@ DEBUG = os.getenv("PANDADEBUG") is not None # *** wifi mode *** - -def build_st(target, mkfile="Makefile"): +def build_st(target, mkfile="Makefile", clean=True): from panda import BASEDIR - cmd = 'cd %s && make -f %s clean && make -f %s %s >/dev/null' % (os.path.join(BASEDIR, "board"), mkfile, mkfile, target) - try: - output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) - except subprocess.CalledProcessError as exception: - output = exception.output - returncode = exception.returncode - raise + + clean_cmd = "make -f %s clean" % mkfile if clean else ":" + cmd = 'cd %s && %s && make -f %s %s' % (os.path.join(BASEDIR, "board"), clean_cmd, mkfile, target) + _ = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) def parse_can_buffer(dat): ret = [] for j in range(0, len(dat), 0x10): - ddat = dat[j:j+0x10] + ddat = dat[j:j + 0x10] f1, f2 = struct.unpack("II", ddat[0:8]) extended = 4 if f1 & extended: address = f1 >> 3 else: address = f1 >> 21 - dddat = ddat[8:8+(f2&0xF)] + dddat = ddat[8:8 + (f2 & 0xF)] if DEBUG: - print(" R %x: %s" % (address, str(dddat).encode("hex"))) - ret.append((address, f2>>16, dddat, (f2>>4)&0xFF)) + print(f" R 0x{address:x}: 0x{dddat.hex()}") + ret.append((address, f2 >> 16, dddat, (f2 >> 4) & 0xFF)) return ret class PandaWifiStreaming(object): @@ -66,7 +62,7 @@ def can_recv(self): ret = [] while True: try: - dat, addr = self.sock.recvfrom(0x200*0x10) + dat, addr = self.sock.recvfrom(0x200 * 0x10) if addr == (self.ip, self.port): ret += parse_can_buffer(dat) except socket.error as e: @@ -83,7 +79,7 @@ def __init__(self, ip="192.168.0.10", port=1337): def __recv(self): ret = self.sock.recv(0x44) length = struct.unpack("I", ret[0:4])[0] - return ret[4:4+length] + return ret[4:4 + length] def controlWrite(self, request_type, request, value, index, data, timeout=0): # ignore data in reply, panda doesn't use it @@ -96,7 +92,7 @@ def controlRead(self, request_type, request, value, index, length, timeout=0): def bulkWrite(self, endpoint, data, timeout=0): if len(data) > 0x10: raise ValueError("Data must not be longer than 0x10") - self.sock.send(struct.pack("HH", endpoint, len(data))+data) + self.sock.send(struct.pack("HH", endpoint, len(data)) + data) self.__recv() # to /dev/null def bulkRead(self, endpoint, length, timeout=0): @@ -109,20 +105,29 @@ def close(self): # *** normal mode *** class Panda(object): - SAFETY_NOOUTPUT = 0 - SAFETY_HONDA = 1 + + # matches cereal.car.CarParams.SafetyModel + SAFETY_SILENT = 0 + SAFETY_HONDA_NIDEC = 1 SAFETY_TOYOTA = 2 - SAFETY_GM = 3 - SAFETY_HONDA_BOSCH = 4 - SAFETY_FORD = 5 - SAFETY_CADILLAC = 6 - SAFETY_HYUNDAI = 7 - SAFETY_TESLA = 8 + SAFETY_ELM327 = 3 + SAFETY_GM = 4 + SAFETY_HONDA_BOSCH_GIRAFFE = 5 + SAFETY_FORD = 6 + SAFETY_HYUNDAI = 8 SAFETY_CHRYSLER = 9 - SAFETY_TOYOTA_IPAS = 0x1335 - SAFETY_TOYOTA_NOLIMITS = 0x1336 - SAFETY_ALLOUTPUT = 0x1337 - SAFETY_ELM327 = 0xE327 + SAFETY_TESLA = 10 + SAFETY_SUBARU = 11 + SAFETY_MAZDA = 13 + SAFETY_NISSAN = 14 + SAFETY_VOLKSWAGEN_MQB = 15 + SAFETY_ALLOUTPUT = 17 + SAFETY_GM_ASCM = 18 + SAFETY_NOOUTPUT = 19 + SAFETY_HONDA_BOSCH_HARNESS = 20 + SAFETY_VOLKSWAGEN_PQ = 21 + SAFETY_SUBARU_LEGACY = 22 + SAFETY_HYUNDAI_LEGACY = 23 SERIAL_DEBUG = 0 SERIAL_ESP = 1 @@ -135,6 +140,17 @@ class Panda(object): REQUEST_IN = usb1.ENDPOINT_IN | usb1.TYPE_VENDOR | usb1.RECIPIENT_DEVICE REQUEST_OUT = usb1.ENDPOINT_OUT | usb1.TYPE_VENDOR | usb1.RECIPIENT_DEVICE + HW_TYPE_UNKNOWN = b'\x00' + HW_TYPE_WHITE_PANDA = b'\x01' + HW_TYPE_GREY_PANDA = b'\x02' + HW_TYPE_BLACK_PANDA = b'\x03' + HW_TYPE_PEDAL = b'\x04' + HW_TYPE_UNO = b'\x05' + + CLOCK_SOURCE_MODE_DISABLED = 0 + CLOCK_SOURCE_MODE_FREE_RUNNING = 1 + CLOCK_SOURCE_MODE_EXTERNAL_SYNC = 2 + def __init__(self, serial=None, claim=True): self._serial = serial self._handle = None @@ -145,7 +161,7 @@ def close(self): self._handle = None def connect(self, claim=True, wait=False): - if self._handle != None: + if self._handle is not None: self.close() if self._serial == "WIFI": @@ -160,7 +176,6 @@ def connect(self, claim=True, wait=False): while 1: try: for device in context.getDeviceList(skip_on_error=True): - #print(device) if device.getVendorID() == 0xbbaa and device.getProductID() in [0xddcc, 0xddee]: try: this_serial = device.getSerialNumber() @@ -173,17 +188,19 @@ def connect(self, claim=True, wait=False): self.bootstub = device.getProductID() == 0xddee self.legacy = (device.getbcdDevice() != 0x2300) self._handle = device.open() + if sys.platform not in ["win32", "cygwin", "msys"]: + self._handle.setAutoDetachKernelDriver(True) if claim: self._handle.claimInterface(0) - #self._handle.setInterfaceAltSetting(0, 0) #Issue in USB stack + # self._handle.setInterfaceAltSetting(0, 0) # Issue in USB stack break except Exception as e: print("exception", e) traceback.print_exc() - if wait == False or self._handle != None: + if not wait or self._handle is not None: break - context = usb1.USBContext() #New context needed so new devices show up - assert(self._handle != None) + context = usb1.USBContext() # New context needed so new devices show up + assert(self._handle is not None) print("connected") def reset(self, enter_bootstub=False, enter_bootloader=False): @@ -212,7 +229,7 @@ def reconnect(self): success = True break except Exception: - print("reconnecting is taking %d seconds..." % (i+1)) + print("reconnecting is taking %d seconds..." % (i + 1)) try: dfu = PandaDFU(PandaDFU.st_serial_to_dfu_serial(self._serial)) dfu.recover() @@ -226,7 +243,7 @@ def reconnect(self): def flash_static(handle, code): # confirm flasher is present fr = handle.controlRead(Panda.REQUEST_IN, 0xb0, 0, 0, 0xc) - assert fr[4:8] == "\xde\xad\xd0\x0d" + assert fr[4:8] == b"\xde\xad\xd0\x0d" # unlock flash print("flash: unlocking") @@ -241,7 +258,7 @@ def flash_static(handle, code): STEP = 0x10 print("flash: flashing") for i in range(0, len(code), STEP): - handle.bulkWrite(2, code[i:i+STEP]) + handle.bulkWrite(2, code[i:i + STEP]) # reset print("flash: resetting") @@ -268,7 +285,7 @@ def flash(self, fn=None, code=None, reconnect=True): fn = os.path.join(BASEDIR, "board", fn) if code is None: - with open(fn) as f: + with open(fn, "rb") as f: code = f.read() # get version @@ -282,6 +299,7 @@ def flash(self, fn=None, code=None, reconnect=True): self.reconnect() def recover(self, timeout=None): + self.reset(enter_bootstub=True) self.reset(enter_bootloader=True) t_start = time.time() while len(PandaDFU.list()) == 0: @@ -302,14 +320,14 @@ def recover(self, timeout=None): def flash_ota_st(): ret = os.system("cd %s && make clean && make ota" % (os.path.join(BASEDIR, "board"))) time.sleep(1) - return ret==0 + return ret == 0 @staticmethod def flash_ota_wifi(release=False): release_str = "RELEASE=1" if release else "" - ret = os.system("cd {} && make clean && {} make ota".format(os.path.join(BASEDIR, "boardesp"),release_str)) + ret = os.system("cd {} && make clean && {} make ota".format(os.path.join(BASEDIR, "boardesp"), release_str)) time.sleep(1) - return ret==0 + return ret == 0 @staticmethod def list(): @@ -325,7 +343,7 @@ def list(): except Exception: pass # TODO: detect if this is real - #ret += ["WIFI"] + # ret += ["WIFI"] return ret def call_control_api(self, msg): @@ -334,18 +352,26 @@ def call_control_api(self, msg): # ******************* health ******************* def health(self): - dat = self._handle.controlRead(Panda.REQUEST_IN, 0xd2, 0, 0, 24) - a = struct.unpack("IIIIIBBBB", dat) + dat = self._handle.controlRead(Panda.REQUEST_IN, 0xd2, 0, 0, 41) + a = struct.unpack("IIIIIIIIBBBBBBBBB", dat) return { - "voltage": a[0], - "current": a[1], - "can_send_errs": a[2], - "can_fwd_errs": a[3], - "gmlan_send_errs": a[4], - "started": a[5], - "controls_allowed": a[6], - "gas_interceptor_detected": a[7], - "car_harness_status": a[8] + "uptime": a[0], + "voltage": a[1], + "current": a[2], + "can_rx_errs": a[3], + "can_send_errs": a[4], + "can_fwd_errs": a[5], + "gmlan_send_errs": a[6], + "faults": a[7], + "ignition_line": a[8], + "ignition_can": a[9], + "controls_allowed": a[10], + "gas_interceptor_detected": a[11], + "car_harness_status": a[12], + "usb_power_mode": a[13], + "safety_mode": a[14], + "fault_status": a[15], + "power_save_enabled": a[16] } # ******************* control ******************* @@ -355,25 +381,44 @@ def enter_bootloader(self): self._handle.controlWrite(Panda.REQUEST_OUT, 0xd1, 0, 0, b'') except Exception as e: print(e) - pass def get_version(self): - return self._handle.controlRead(Panda.REQUEST_IN, 0xd6, 0, 0, 0x40) + return self._handle.controlRead(Panda.REQUEST_IN, 0xd6, 0, 0, 0x40).decode('utf8') + + @staticmethod + def get_signature_from_firmware(fn): + f = open(fn, 'rb') + f.seek(-128, 2) # Seek from end of file + return f.read(128) + + def get_signature(self): + part_1 = self._handle.controlRead(Panda.REQUEST_IN, 0xd3, 0, 0, 0x40) + part_2 = self._handle.controlRead(Panda.REQUEST_IN, 0xd4, 0, 0, 0x40) + return bytes(part_1 + part_2) def get_type(self): return self._handle.controlRead(Panda.REQUEST_IN, 0xc1, 0, 0, 0x40) + def is_white(self): + return self.get_type() == Panda.HW_TYPE_WHITE_PANDA + def is_grey(self): - return self.get_type() == "\x02" + return self.get_type() == Panda.HW_TYPE_GREY_PANDA def is_black(self): - return self.get_type() == "\x03" + return self.get_type() == Panda.HW_TYPE_BLACK_PANDA + + def is_uno(self): + return self.get_type() == Panda.HW_TYPE_UNO + + def has_obd(self): + return (self.is_uno() or self.is_black()) def get_serial(self): dat = self._handle.controlRead(Panda.REQUEST_IN, 0xd0, 0, 0, 0x20) hashsig, calc_hash = dat[0x1c:], hashlib.sha1(dat[0:0x1c]).digest()[0:4] assert(hashsig == calc_hash) - return [dat[0:0x10], dat[0x10:0x10+10]] + return [dat[0:0x10].decode("utf8"), dat[0x10:0x10 + 10].decode("utf8")] def get_secret(self): return self._handle.controlRead(Panda.REQUEST_IN, 0xd0, 1, 0, 0x10) @@ -383,6 +428,9 @@ def get_secret(self): def set_usb_power(self, on): self._handle.controlWrite(Panda.REQUEST_OUT, 0xe6, int(on), 0, b'') + def set_power_save(self, power_save_enabled=0): + self._handle.controlWrite(Panda.REQUEST_OUT, 0xe7, int(power_save_enabled), 0, b'') + def set_esp_power(self, on): self._handle.controlWrite(Panda.REQUEST_OUT, 0xd9, int(on), 0, b'') @@ -390,7 +438,7 @@ def esp_reset(self, bootmode=0): self._handle.controlWrite(Panda.REQUEST_OUT, 0xda, int(bootmode), 0, b'') time.sleep(0.2) - def set_safety_mode(self, mode=SAFETY_NOOUTPUT): + def set_safety_mode(self, mode=SAFETY_SILENT): self._handle.controlWrite(Panda.REQUEST_OUT, 0xdc, mode, 0, b'') def set_can_forwarding(self, from_bus, to_bus): @@ -413,14 +461,14 @@ def set_can_loopback(self, enable): self._handle.controlWrite(Panda.REQUEST_OUT, 0xe5, int(enable), 0, b'') def set_can_enable(self, bus_num, enable): - # sets the can transciever enable pin + # sets the can transceiver enable pin self._handle.controlWrite(Panda.REQUEST_OUT, 0xf4, int(bus_num), int(enable), b'') def set_can_speed_kbps(self, bus, speed): - self._handle.controlWrite(Panda.REQUEST_OUT, 0xde, bus, int(speed*10), b'') + self._handle.controlWrite(Panda.REQUEST_OUT, 0xde, bus, int(speed * 10), b'') def set_uart_baud(self, uart, rate): - self._handle.controlWrite(Panda.REQUEST_OUT, 0xe4, uart, rate/300, b'') + self._handle.controlWrite(Panda.REQUEST_OUT, 0xe4, uart, int(rate / 300), b'') def set_uart_parity(self, uart, parity): # parity, 0=off, 1=even, 2=odd @@ -431,14 +479,19 @@ def set_uart_callback(self, uart, install): # ******************* can ******************* - def can_send_many(self, arr): + # The panda will NAK CAN writes when there is CAN congestion. + # libusb will try to send it again, with a max timeout. + # Timeout is in ms. If set to 0, the timeout is infinite. + CAN_SEND_TIMEOUT_MS = 10 + + def can_send_many(self, arr, timeout=CAN_SEND_TIMEOUT_MS): snds = [] transmit = 1 extended = 4 for addr, _, dat, bus in arr: assert len(dat) <= 8 if DEBUG: - print(" W %x: %s" % (addr, dat.encode("hex"))) + print(f" W 0x{addr:x}: 0x{dat.hex()}") if addr >= 0x800: rir = (addr << 3) | transmit | extended else: @@ -449,27 +502,27 @@ def can_send_many(self, arr): while True: try: - #print("DAT: %s"%b''.join(snds).__repr__()) if self.wifi: for s in snds: self._handle.bulkWrite(3, s) else: - self._handle.bulkWrite(3, b''.join(snds)) + self._handle.bulkWrite(3, b''.join(snds), timeout=timeout) break except (usb1.USBErrorIO, usb1.USBErrorOverflow): print("CAN: BAD SEND MANY, RETRYING") - def can_send(self, addr, dat, bus): - self.can_send_many([[addr, None, dat, bus]]) + def can_send(self, addr, dat, bus, timeout=CAN_SEND_TIMEOUT_MS): + self.can_send_many([[addr, None, dat, bus]], timeout=timeout) def can_recv(self): dat = bytearray() while True: try: - dat = self._handle.bulkRead(1, 0x10*256) + dat = self._handle.bulkRead(1, 0x10 * 256) break except (usb1.USBErrorIO, usb1.USBErrorOverflow): print("CAN: BAD RECV, RETRYING") + time.sleep(0.1) return parse_can_buffer(dat) def can_clear(self, bus): @@ -505,7 +558,7 @@ def serial_read(self, port_number): def serial_write(self, port_number, ln): ret = 0 for i in range(0, len(ln), 0x20): - ret += self._handle.bulkWrite(2, struct.pack("B", port_number) + ln[i:i+0x20]) + ret += self._handle.bulkWrite(2, struct.pack("B", port_number) + ln[i:i + 0x20]) return ret def serial_clear(self, port_number): @@ -521,13 +574,22 @@ def serial_clear(self, port_number): # ******************* kline ******************* # pulse low for wakeup - def kline_wakeup(self): + def kline_wakeup(self, k=True, l=True): + assert k or l, "must specify k-line, l-line, or both" if DEBUG: print("kline wakeup...") - self._handle.controlWrite(Panda.REQUEST_OUT, 0xf0, 0, 0, b'') + self._handle.controlWrite(Panda.REQUEST_OUT, 0xf0, 2 if k and l else int(l), 0, b'') if DEBUG: print("kline wakeup done") + def kline_5baud(self, addr, k=True, l=True): + assert k or l, "must specify k-line, l-line, or both" + if DEBUG: + print("kline 5 baud...") + self._handle.controlWrite(Panda.REQUEST_OUT, 0xf4, 2 if k and l else int(l), addr, b'') + if DEBUG: + print("kline 5 baud done") + def kline_drain(self, bus=2): # drain buffer bret = bytearray() @@ -536,45 +598,81 @@ def kline_drain(self, bus=2): if len(ret) == 0: break elif DEBUG: - print("kline drain: "+str(ret).encode("hex")) + print(f"kline drain: 0x{ret.hex()}") bret += ret return bytes(bret) def kline_ll_recv(self, cnt, bus=2): echo = bytearray() while len(echo) != cnt: - ret = str(self._handle.controlRead(Panda.REQUEST_OUT, 0xe0, bus, 0, cnt-len(echo))) + ret = self._handle.controlRead(Panda.REQUEST_OUT, 0xe0, bus, 0, cnt - len(echo)) if DEBUG and len(ret) > 0: - print("kline recv: "+ret.encode("hex")) + print(f"kline recv: 0x{ret.hex()}") echo += ret - return str(echo) + return bytes(echo) def kline_send(self, x, bus=2, checksum=True): - def get_checksum(dat): - result = 0 - result += sum(map(ord, dat)) if isinstance(b'dat', str) else sum(dat) - result = -result - return struct.pack("B", result % 0x100) - self.kline_drain(bus=bus) if checksum: - x += get_checksum(x) + x += bytes([sum(x) % 0x100]) for i in range(0, len(x), 0xf): - ts = x[i:i+0xf] + ts = x[i:i + 0xf] if DEBUG: - print("kline send: "+ts.encode("hex")) - self._handle.bulkWrite(2, chr(bus).encode()+ts) + print(f"kline send: 0x{ts.hex()}") + self._handle.bulkWrite(2, bytes([bus]) + ts) echo = self.kline_ll_recv(len(ts), bus=bus) if echo != ts: - print("**** ECHO ERROR %d ****" % i) - print(binascii.hexlify(echo)) - print(binascii.hexlify(ts)) + print(f"**** ECHO ERROR {i} ****") + print(f"0x{echo.hex()}") + print(f"0x{ts.hex()}") assert echo == ts - def kline_recv(self, bus=2): - msg = self.kline_ll_recv(2, bus=bus) - msg += self.kline_ll_recv(ord(msg[1])-2, bus=bus) + def kline_recv(self, bus=2, header_len=4): + # read header (last byte is length) + msg = self.kline_ll_recv(header_len, bus=bus) + # read data (add one byte to length for checksum) + msg += self.kline_ll_recv(msg[-1]+1, bus=bus) return msg def send_heartbeat(self): self._handle.controlWrite(Panda.REQUEST_OUT, 0xf3, 0, 0, b'') + + # ******************* RTC ******************* + def set_datetime(self, dt): + self._handle.controlWrite(Panda.REQUEST_OUT, 0xa1, int(dt.year), 0, b'') + self._handle.controlWrite(Panda.REQUEST_OUT, 0xa2, int(dt.month), 0, b'') + self._handle.controlWrite(Panda.REQUEST_OUT, 0xa3, int(dt.day), 0, b'') + self._handle.controlWrite(Panda.REQUEST_OUT, 0xa4, int(dt.isoweekday()), 0, b'') + self._handle.controlWrite(Panda.REQUEST_OUT, 0xa5, int(dt.hour), 0, b'') + self._handle.controlWrite(Panda.REQUEST_OUT, 0xa6, int(dt.minute), 0, b'') + self._handle.controlWrite(Panda.REQUEST_OUT, 0xa7, int(dt.second), 0, b'') + + def get_datetime(self): + dat = self._handle.controlRead(Panda.REQUEST_IN, 0xa0, 0, 0, 8) + a = struct.unpack("HBBBBBB", dat) + return datetime.datetime(a[0], a[1], a[2], a[4], a[5], a[6]) + + # ******************* IR ******************* + def set_ir_power(self, percentage): + self._handle.controlWrite(Panda.REQUEST_OUT, 0xb0, int(percentage), 0, b'') + + # ******************* Fan ****************** + def set_fan_power(self, percentage): + self._handle.controlWrite(Panda.REQUEST_OUT, 0xb1, int(percentage), 0, b'') + + def get_fan_rpm(self): + dat = self._handle.controlRead(Panda.REQUEST_IN, 0xb2, 0, 0, 2) + a = struct.unpack("H", dat) + return a[0] + + # ****************** Phone ***************** + def set_phone_power(self, enabled): + self._handle.controlWrite(Panda.REQUEST_OUT, 0xb3, int(enabled), 0, b'') + + # ************** Clock Source ************** + def set_clock_source_mode(self, mode): + self._handle.controlWrite(Panda.REQUEST_OUT, 0xf5, int(mode), 0, b'') + + # ****************** Siren ***************** + def set_siren(self, enabled): + self._handle.controlWrite(Panda.REQUEST_OUT, 0xf6, int(enabled), 0, b'') diff --git a/panda/python/dfu.py b/panda/python/dfu.py index 02deed47bbe2ec..a7f51ecdad6afe 100644 --- a/panda/python/dfu.py +++ b/panda/python/dfu.py @@ -1,8 +1,7 @@ -from __future__ import print_function import os import usb1 import struct -import time +import binascii # *** DFU mode *** @@ -25,7 +24,7 @@ def __init__(self, dfu_serial): self._handle = device.open() self.legacy = "07*128Kg" in self._handle.getASCIIStringDescriptor(4) return - raise Exception("failed to open "+dfu_serial) + raise Exception("failed to open " + dfu_serial if dfu_serial is not None else "DFU device") @staticmethod def list(): @@ -44,46 +43,45 @@ def list(): @staticmethod def st_serial_to_dfu_serial(st): - if st == None or st == "none": + if st is None or st == "none": return None - uid_base = struct.unpack("H"*6, st.decode("hex")) - return struct.pack("!HHH", uid_base[1] + uid_base[5], uid_base[0] + uid_base[4] + 0xA, uid_base[3]).encode("hex").upper() - + uid_base = struct.unpack("H" * 6, bytes.fromhex(st)) + return binascii.hexlify(struct.pack("!HHH", uid_base[1] + uid_base[5], uid_base[0] + uid_base[4] + 0xA, uid_base[3])).upper().decode("utf-8") def status(self): while 1: - dat = str(self._handle.controlRead(0x21, DFU_GETSTATUS, 0, 0, 6)) - if dat[1] == "\x00": + dat = self._handle.controlRead(0x21, DFU_GETSTATUS, 0, 0, 6) + if dat[1] == 0: break def clear_status(self): # Clear status - stat = str(self._handle.controlRead(0x21, DFU_GETSTATUS, 0, 0, 6)) - if stat[4] == "\x0a": + stat = self._handle.controlRead(0x21, DFU_GETSTATUS, 0, 0, 6) + if stat[4] == 0xa: self._handle.controlRead(0x21, DFU_CLRSTATUS, 0, 0, 0) - elif stat[4] == "\x09": - self._handle.controlWrite(0x21, DFU_ABORT, 0, 0, "") + elif stat[4] == 0x9: + self._handle.controlWrite(0x21, DFU_ABORT, 0, 0, b"") self.status() stat = str(self._handle.controlRead(0x21, DFU_GETSTATUS, 0, 0, 6)) def erase(self, address): - self._handle.controlWrite(0x21, DFU_DNLOAD, 0, 0, "\x41" + struct.pack("I", address)) + self._handle.controlWrite(0x21, DFU_DNLOAD, 0, 0, b"\x41" + struct.pack("I", address)) self.status() def program(self, address, dat, block_size=None): - if block_size == None: + if block_size is None: block_size = len(dat) # Set Address Pointer - self._handle.controlWrite(0x21, DFU_DNLOAD, 0, 0, "\x21" + struct.pack("I", address)) + self._handle.controlWrite(0x21, DFU_DNLOAD, 0, 0, b"\x21" + struct.pack("I", address)) self.status() # Program - dat += "\xFF"*((block_size-len(dat)) % block_size) - for i in range(0, len(dat)/block_size): - ldat = dat[i*block_size:(i+1)*block_size] + dat += b"\xFF" * ((block_size - len(dat)) % block_size) + for i in range(0, len(dat) // block_size): + ldat = dat[i * block_size:(i + 1) * block_size] print("programming %d with length %d" % (i, len(ldat))) - self._handle.controlWrite(0x21, DFU_DNLOAD, 2+i, 0, ldat) + self._handle.controlWrite(0x21, DFU_DNLOAD, 2 + i, 0, ldat) self.status() def program_bootstub(self, code_bootstub): @@ -105,17 +103,17 @@ def recover(self): build_st(fn) fn = os.path.join(BASEDIR, "board", fn) - with open(fn) as f: + with open(fn, "rb") as f: code = f.read() self.program_bootstub(code) def reset(self): # **** Reset **** - self._handle.controlWrite(0x21, DFU_DNLOAD, 0, 0, "\x21" + struct.pack("I", 0x8000000)) + self._handle.controlWrite(0x21, DFU_DNLOAD, 0, 0, b"\x21" + struct.pack("I", 0x8000000)) self.status() try: - self._handle.controlWrite(0x21, DFU_DNLOAD, 2, 0, "") - stat = str(self._handle.controlRead(0x21, DFU_GETSTATUS, 0, 0, 6)) + self._handle.controlWrite(0x21, DFU_DNLOAD, 2, 0, b"") + _ = str(self._handle.controlRead(0x21, DFU_GETSTATUS, 0, 0, 6)) except Exception: pass diff --git a/panda/python/esptool.py b/panda/python/esptool.py deleted file mode 100755 index 970aa3d4d83fd5..00000000000000 --- a/panda/python/esptool.py +++ /dev/null @@ -1,1314 +0,0 @@ -#!/usr/bin/env python -# NB: Before sending a PR to change the above line to '#!/usr/bin/env python2', please read https://github.com/themadinventor/esptool/issues/21 -# -# ESP8266 ROM Bootloader Utility -# https://github.com/themadinventor/esptool -# -# Copyright (C) 2014-2016 Fredrik Ahlberg, Angus Gratton, other contributors as noted. -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin -# Street, Fifth Floor, Boston, MA 02110-1301 USA. - -import argparse -import hashlib -import inspect -import json -import os -#import serial -import struct -import subprocess -import sys -import tempfile -import time -import traceback -import usb1 - -__version__ = "1.2" - -class FakePort(object): - def __init__(self, serial=None): - from panda import Panda - self.panda = Panda(serial) - - # will only work on new st, old ones will stay @ 921600 - self.baudrate = 230400 - - @property - def baudrate(self): - return self._baudrate - - @baudrate.setter - def baudrate(self, x): - print "set baud to", x - self.panda.set_uart_baud(1, x) - - def write(self, buf): - SEND_STEP = 0x20 - for i in range(0, len(buf), SEND_STEP): - self.panda.serial_write(1, buf[i:i+SEND_STEP]) - - def flushInput(self): - self.panda.serial_clear(1) - - def flushOutput(self): - self.panda.serial_clear(1) - - def read(self, llen): - ret = self.panda._handle.controlRead(usb1.TYPE_VENDOR | usb1.RECIPIENT_DEVICE, 0xe0, 1, 0, 1) - if ret == '': - time.sleep(0.1) - ret = self.panda._handle.controlRead(usb1.TYPE_VENDOR | usb1.RECIPIENT_DEVICE, 0xe0, 1, 0, 1) - return str(ret) - - def reset(self): - self.panda.esp_reset(1) - - def inWaiting(self): - return False - -class ESPROM(object): - # These are the currently known commands supported by the ROM - ESP_FLASH_BEGIN = 0x02 - ESP_FLASH_DATA = 0x03 - ESP_FLASH_END = 0x04 - ESP_MEM_BEGIN = 0x05 - ESP_MEM_END = 0x06 - ESP_MEM_DATA = 0x07 - ESP_SYNC = 0x08 - ESP_WRITE_REG = 0x09 - ESP_READ_REG = 0x0a - - # Maximum block sized for RAM and Flash writes, respectively. - ESP_RAM_BLOCK = 0x1800 - ESP_FLASH_BLOCK = 0x400 - - # Default baudrate. The ROM auto-bauds, so we can use more or less whatever we want. - ESP_ROM_BAUD = 115200 - - # First byte of the application image - ESP_IMAGE_MAGIC = 0xe9 - - # Initial state for the checksum routine - ESP_CHECKSUM_MAGIC = 0xef - - # OTP ROM addresses - ESP_OTP_MAC0 = 0x3ff00050 - ESP_OTP_MAC1 = 0x3ff00054 - ESP_OTP_MAC3 = 0x3ff0005c - - # Flash sector size, minimum unit of erase. - ESP_FLASH_SECTOR = 0x1000 - - def __init__(self, port=None, baud=ESP_ROM_BAUD): - self._port = FakePort(port) - self._slip_reader = slip_reader(self._port) - - """ Read a SLIP packet from the serial port """ - def read(self): - return self._slip_reader.next() - - """ Write bytes to the serial port while performing SLIP escaping """ - def write(self, packet): - buf = '\xc0' \ - + (packet.replace('\xdb','\xdb\xdd').replace('\xc0','\xdb\xdc')) \ - + '\xc0' - self._port.write(buf) - - """ Calculate checksum of a blob, as it is defined by the ROM """ - @staticmethod - def checksum(data, state=ESP_CHECKSUM_MAGIC): - for b in data: - state ^= ord(b) - return state - - """ Send a request and read the response """ - def command(self, op=None, data=None, chk=0): - if op is not None: - pkt = struct.pack('> 16) & 0xff, (mac3 >> 8) & 0xff, mac3 & 0xff) - elif ((mac1 >> 16) & 0xff) == 0: - oui = (0x18, 0xfe, 0x34) - elif ((mac1 >> 16) & 0xff) == 1: - oui = (0xac, 0xd0, 0x74) - else: - raise FatalError("Unknown OUI") - return oui + ((mac1 >> 8) & 0xff, mac1 & 0xff, (mac0 >> 24) & 0xff) - - """ Read Chip ID from OTP ROM - see http://esp8266-re.foogod.com/wiki/System_get_chip_id_%28IoT_RTOS_SDK_0.9.9%29 """ - def chip_id(self): - id0 = self.read_reg(self.ESP_OTP_MAC0) - id1 = self.read_reg(self.ESP_OTP_MAC1) - return (id0 >> 24) | ((id1 & 0xffffff) << 8) - - """ Read SPI flash manufacturer and device id """ - def flash_id(self): - self.flash_begin(0, 0) - self.write_reg(0x60000240, 0x0, 0xffffffff) - self.write_reg(0x60000200, 0x10000000, 0xffffffff) - flash_id = self.read_reg(0x60000240) - return flash_id - - """ Abuse the loader protocol to force flash to be left in write mode """ - def flash_unlock_dio(self): - # Enable flash write mode - self.flash_begin(0, 0) - # Reset the chip rather than call flash_finish(), which would have - # write protected the chip again (why oh why does it do that?!) - self.mem_begin(0,0,0,0x40100000) - self.mem_finish(0x40000080) - - """ Perform a chip erase of SPI flash """ - def flash_erase(self): - # Trick ROM to initialize SFlash - self.flash_begin(0, 0) - - # This is hacky: we don't have a custom stub, instead we trick - # the bootloader to jump to the SPIEraseChip() routine and then halt/crash - # when it tries to boot an unconfigured system. - self.mem_begin(0,0,0,0x40100000) - self.mem_finish(0x40004984) - - # Yup - there's no good way to detect if we succeeded. - # It it on the other hand unlikely to fail. - - def run_stub(self, stub, params, read_output=True): - stub = dict(stub) - stub['code'] = unhexify(stub['code']) - if 'data' in stub: - stub['data'] = unhexify(stub['data']) - - if stub['num_params'] != len(params): - raise FatalError('Stub requires %d params, %d provided' - % (stub['num_params'], len(params))) - - params = struct.pack('<' + ('I' * stub['num_params']), *params) - pc = params + stub['code'] - - # Upload - self.mem_begin(len(pc), 1, len(pc), stub['params_start']) - self.mem_block(pc, 0) - if 'data' in stub: - self.mem_begin(len(stub['data']), 1, len(stub['data']), stub['data_start']) - self.mem_block(stub['data'], 0) - self.mem_finish(stub['entry']) - - if read_output: - print 'Stub executed, reading response:' - while True: - p = self.read() - print hexify(p) - if p == '': - return - - -class ESPBOOTLOADER(object): - """ These are constants related to software ESP bootloader, working with 'v2' image files """ - - # First byte of the "v2" application image - IMAGE_V2_MAGIC = 0xea - - # First 'segment' value in a "v2" application image, appears to be a constant version value? - IMAGE_V2_SEGMENT = 4 - - -def LoadFirmwareImage(filename): - """ Load a firmware image, without knowing what kind of file (v1 or v2) it is. - - Returns a BaseFirmwareImage subclass, either ESPFirmwareImage (v1) or OTAFirmwareImage (v2). - """ - with open(filename, 'rb') as f: - magic = ord(f.read(1)) - f.seek(0) - if magic == ESPROM.ESP_IMAGE_MAGIC: - return ESPFirmwareImage(f) - elif magic == ESPBOOTLOADER.IMAGE_V2_MAGIC: - return OTAFirmwareImage(f) - else: - raise FatalError("Invalid image magic number: %d" % magic) - - -class BaseFirmwareImage(object): - """ Base class with common firmware image functions """ - def __init__(self): - self.segments = [] - self.entrypoint = 0 - - def add_segment(self, addr, data, pad_to=4): - """ Add a segment to the image, with specified address & data - (padded to a boundary of pad_to size) """ - # Data should be aligned on word boundary - l = len(data) - if l % pad_to: - data += b"\x00" * (pad_to - l % pad_to) - if l > 0: - self.segments.append((addr, len(data), data)) - - def load_segment(self, f, is_irom_segment=False): - """ Load the next segment from the image file """ - (offset, size) = struct.unpack(' 0x40200000 or offset < 0x3ffe0000 or size > 65536: - raise FatalError('Suspicious segment 0x%x, length %d' % (offset, size)) - segment_data = f.read(size) - if len(segment_data) < size: - raise FatalError('End of file reading segment 0x%x, length %d (actual length %d)' % (offset, size, len(segment_data))) - segment = (offset, size, segment_data) - self.segments.append(segment) - return segment - - def save_segment(self, f, segment, checksum=None): - """ Save the next segment to the image file, return next checksum value if provided """ - (offset, size, data) = segment - f.write(struct.pack(' 16: - raise FatalError('Invalid firmware image magic=%d segments=%d' % (magic, segments)) - - for i in xrange(segments): - self.load_segment(load_file) - self.checksum = self.read_checksum(load_file) - - def save(self, filename): - with open(filename, 'wb') as f: - self.write_v1_header(f, self.segments) - checksum = ESPROM.ESP_CHECKSUM_MAGIC - for segment in self.segments: - checksum = self.save_segment(f, segment, checksum) - self.append_checksum(f, checksum) - - -class OTAFirmwareImage(BaseFirmwareImage): - """ 'Version 2' firmware image, segments loaded by software bootloader stub - (ie Espressif bootloader or rboot) - """ - def __init__(self, load_file=None): - super(OTAFirmwareImage, self).__init__() - self.version = 2 - if load_file is not None: - (magic, segments, first_flash_mode, first_flash_size_freq, first_entrypoint) = struct.unpack(' 16: - raise FatalError('Invalid V2 second header magic=%d segments=%d' % (magic, segments)) - - # load all the usual segments - for _ in xrange(segments): - self.load_segment(load_file) - self.checksum = self.read_checksum(load_file) - - def save(self, filename): - with open(filename, 'wb') as f: - # Save first header for irom0 segment - f.write(struct.pack(' 0: - esp._port.baudrate = baud_rate - # Read the greeting. - p = esp.read() - if p != 'OHAI': - raise FatalError('Failed to connect to the flasher (got %s)' % hexify(p)) - - def flash_write(self, addr, data, show_progress=False): - assert addr % self._esp.ESP_FLASH_SECTOR == 0, 'Address must be sector-aligned' - assert len(data) % self._esp.ESP_FLASH_SECTOR == 0, 'Length must be sector-aligned' - sys.stdout.write('Writing %d @ 0x%x... ' % (len(data), addr)) - sys.stdout.flush() - self._esp.write(struct.pack(' length: - raise FatalError('Read more than expected') - p = self._esp.read() - if len(p) != 16: - raise FatalError('Expected digest, got: %s' % hexify(p)) - expected_digest = hexify(p).upper() - digest = hashlib.md5(data).hexdigest().upper() - print - if digest != expected_digest: - raise FatalError('Digest mismatch: expected %s, got %s' % (expected_digest, digest)) - p = self._esp.read() - if len(p) != 1: - raise FatalError('Expected status, got: %s' % hexify(p)) - status_code = struct.unpack(', ) or a single -# argument. - -def load_ram(esp, args): - image = LoadFirmwareImage(args.filename) - - print 'RAM boot...' - for (offset, size, data) in image.segments: - print 'Downloading %d bytes at %08x...' % (size, offset), - sys.stdout.flush() - esp.mem_begin(size, div_roundup(size, esp.ESP_RAM_BLOCK), esp.ESP_RAM_BLOCK, offset) - - seq = 0 - while len(data) > 0: - esp.mem_block(data[0:esp.ESP_RAM_BLOCK], seq) - data = data[esp.ESP_RAM_BLOCK:] - seq += 1 - print 'done!' - - print 'All segments done, executing at %08x' % image.entrypoint - esp.mem_finish(image.entrypoint) - - -def read_mem(esp, args): - print '0x%08x = 0x%08x' % (args.address, esp.read_reg(args.address)) - - -def write_mem(esp, args): - esp.write_reg(args.address, args.value, args.mask, 0) - print 'Wrote %08x, mask %08x to %08x' % (args.value, args.mask, args.address) - - -def dump_mem(esp, args): - f = file(args.filename, 'wb') - for i in xrange(args.size / 4): - d = esp.read_reg(args.address + (i * 4)) - f.write(struct.pack('> 16 - args.flash_size = {18: '2m', 19: '4m', 20: '8m', 21: '16m', 22: '32m'}.get(size_id) - if args.flash_size is None: - print 'Warning: Could not auto-detect Flash size (FlashID=0x%x, SizeID=0x%x), defaulting to 4m' % (flash_id, size_id) - args.flash_size = '4m' - else: - print 'Auto-detected Flash size:', args.flash_size - - -def write_flash(esp, args): - detect_flash_size(esp, args) - flash_mode = {'qio':0, 'qout':1, 'dio':2, 'dout': 3}[args.flash_mode] - flash_size_freq = {'4m':0x00, '2m':0x10, '8m':0x20, '16m':0x30, '32m':0x40, '16m-c1': 0x50, '32m-c1':0x60, '32m-c2':0x70}[args.flash_size] - flash_size_freq += {'40m':0, '26m':1, '20m':2, '80m': 0xf}[args.flash_freq] - flash_params = struct.pack('BB', flash_mode, flash_size_freq) - - flasher = CesantaFlasher(esp, args.baud) - - for address, argfile in args.addr_filename: - image = argfile.read() - argfile.seek(0) # rewind in case we need it again - if address + len(image) > int(args.flash_size.split('m')[0]) * (1 << 17): - print 'WARNING: Unlikely to work as data goes beyond end of flash. Hint: Use --flash_size' - # Fix sflash config data. - if address == 0 and image[0] == '\xe9': - print 'Flash params set to 0x%02x%02x' % (flash_mode, flash_size_freq) - image = image[0:2] + flash_params + image[4:] - # Pad to sector size, which is the minimum unit of writing (erasing really). - if len(image) % esp.ESP_FLASH_SECTOR != 0: - image += '\xff' * (esp.ESP_FLASH_SECTOR - (len(image) % esp.ESP_FLASH_SECTOR)) - t = time.time() - flasher.flash_write(address, image, not args.no_progress) - t = time.time() - t - print ('\rWrote %d bytes at 0x%x in %.1f seconds (%.1f kbit/s)...' - % (len(image), address, t, len(image) / t * 8 / 1000)) - print 'Leaving...' - if args.verify: - print 'Verifying just-written flash...' - _verify_flash(flasher, args, flash_params) - flasher.boot_fw() - - -def image_info(args): - image = LoadFirmwareImage(args.filename) - print('Image version: %d' % image.version) - print('Entry point: %08x' % image.entrypoint) if image.entrypoint != 0 else 'Entry point not set' - print '%d segments' % len(image.segments) - print - checksum = ESPROM.ESP_CHECKSUM_MAGIC - for (idx, (offset, size, data)) in enumerate(image.segments): - if image.version == 2 and idx == 0: - print 'Segment 1: %d bytes IROM0 (no load address)' % size - else: - print 'Segment %d: %5d bytes at %08x' % (idx + 1, size, offset) - checksum = ESPROM.checksum(data, checksum) - print - print 'Checksum: %02x (%s)' % (image.checksum, 'valid' if image.checksum == checksum else 'invalid!') - - -def make_image(args): - image = ESPFirmwareImage() - if len(args.segfile) == 0: - raise FatalError('No segments specified') - if len(args.segfile) != len(args.segaddr): - raise FatalError('Number of specified files does not match number of specified addresses') - for (seg, addr) in zip(args.segfile, args.segaddr): - data = file(seg, 'rb').read() - image.add_segment(addr, data) - image.entrypoint = args.entrypoint - image.save(args.output) - - -def elf2image(args): - e = ELFFile(args.input) - if args.version == '1': - image = ESPFirmwareImage() - else: - image = OTAFirmwareImage() - irom_data = e.load_section('.irom0.text') - if len(irom_data) == 0: - raise FatalError(".irom0.text section not found in ELF file - can't create V2 image.") - image.add_segment(0, irom_data, 16) - image.entrypoint = e.get_entry_point() - for section, start in ((".text", "_text_start"), (".data", "_data_start"), (".rodata", "_rodata_start")): - data = e.load_section(section) - image.add_segment(e.get_symbol_addr(start), data) - - image.flash_mode = {'qio':0, 'qout':1, 'dio':2, 'dout': 3}[args.flash_mode] - image.flash_size_freq = {'4m':0x00, '2m':0x10, '8m':0x20, '16m':0x30, '32m':0x40, '16m-c1': 0x50, '32m-c1':0x60, '32m-c2':0x70}[args.flash_size] - image.flash_size_freq += {'40m':0, '26m':1, '20m':2, '80m': 0xf}[args.flash_freq] - - irom_offs = e.get_symbol_addr("_irom0_text_start") - 0x40200000 - - if args.version == '1': - if args.output is None: - args.output = args.input + '-' - image.save(args.output + "0x00000.bin") - data = e.load_section(".irom0.text") - if irom_offs < 0: - raise FatalError('Address of symbol _irom0_text_start in ELF is located before flash mapping address. Bad linker script?') - if (irom_offs & 0xFFF) != 0: # irom0 isn't flash sector aligned - print "WARNING: irom0 section offset is 0x%08x. ELF is probably linked for 'elf2image --version=2'" % irom_offs - with open(args.output + "0x%05x.bin" % irom_offs, "wb") as f: - f.write(data) - f.close() - else: # V2 OTA image - if args.output is None: - args.output = "%s-0x%05x.bin" % (os.path.splitext(args.input)[0], irom_offs & ~(ESPROM.ESP_FLASH_SECTOR - 1)) - image.save(args.output) - - -def read_mac(esp, args): - mac = esp.read_mac() - print 'MAC: %s' % ':'.join(map(lambda x: '%02x' % x, mac)) - - -def chip_id(esp, args): - chipid = esp.chip_id() - print 'Chip ID: 0x%08x' % chipid - - -def erase_flash(esp, args): - flasher = CesantaFlasher(esp, args.baud) - print 'Erasing flash (this may take a while)...' - t = time.time() - flasher.flash_erase_chip() - t = time.time() - t - print 'Erase took %.1f seconds' % t - - -def run(esp, args): - esp.run() - - -def flash_id(esp, args): - flash_id = esp.flash_id() - esp.flash_finish(False) - print 'Manufacturer: %02x' % (flash_id & 0xff) - print 'Device: %02x%02x' % ((flash_id >> 8) & 0xff, (flash_id >> 16) & 0xff) - - -def read_flash(esp, args): - flasher = CesantaFlasher(esp, args.baud) - t = time.time() - data = flasher.flash_read(args.address, args.size, not args.no_progress) - t = time.time() - t - print ('\rRead %d bytes at 0x%x in %.1f seconds (%.1f kbit/s)...' - % (len(data), args.address, t, len(data) / t * 8 / 1000)) - file(args.filename, 'wb').write(data) - - -def _verify_flash(flasher, args, flash_params=None): - differences = False - for address, argfile in args.addr_filename: - image = argfile.read() - argfile.seek(0) # rewind in case we need it again - if address == 0 and image[0] == '\xe9' and flash_params is not None: - image = image[0:2] + flash_params + image[4:] - image_size = len(image) - print 'Verifying 0x%x (%d) bytes @ 0x%08x in flash against %s...' % (image_size, image_size, address, argfile.name) - # Try digest first, only read if there are differences. - digest, _ = flasher.flash_digest(address, image_size) - digest = hexify(digest).upper() - expected_digest = hashlib.md5(image).hexdigest().upper() - if digest == expected_digest: - print '-- verify OK (digest matched)' - continue - else: - differences = True - if getattr(args, 'diff', 'no') != 'yes': - print '-- verify FAILED (digest mismatch)' - continue - - flash = flasher.flash_read(address, image_size) - assert flash != image - diff = [i for i in xrange(image_size) if flash[i] != image[i]] - print '-- verify FAILED: %d differences, first @ 0x%08x' % (len(diff), address + diff[0]) - for d in diff: - print ' %08x %02x %02x' % (address + d, ord(flash[d]), ord(image[d])) - if differences: - raise FatalError("Verify failed.") - - -def verify_flash(esp, args, flash_params=None): - flasher = CesantaFlasher(esp) - _verify_flash(flasher, args, flash_params) - - -def version(args): - print __version__ - -# -# End of operations functions -# - - -def main(): - parser = argparse.ArgumentParser(description='esptool.py v%s - ESP8266 ROM Bootloader Utility' % __version__, prog='esptool') - - parser.add_argument( - '--port', '-p', - help='Serial port device', - default=os.environ.get('ESPTOOL_PORT', None)) - - parser.add_argument( - '--baud', '-b', - help='Serial port baud rate used when flashing/reading', - type=arg_auto_int, - default=os.environ.get('ESPTOOL_BAUD', ESPROM.ESP_ROM_BAUD)) - - subparsers = parser.add_subparsers( - dest='operation', - help='Run esptool {command} -h for additional help') - - parser_load_ram = subparsers.add_parser( - 'load_ram', - help='Download an image to RAM and execute') - parser_load_ram.add_argument('filename', help='Firmware image') - - parser_dump_mem = subparsers.add_parser( - 'dump_mem', - help='Dump arbitrary memory to disk') - parser_dump_mem.add_argument('address', help='Base address', type=arg_auto_int) - parser_dump_mem.add_argument('size', help='Size of region to dump', type=arg_auto_int) - parser_dump_mem.add_argument('filename', help='Name of binary dump') - - parser_read_mem = subparsers.add_parser( - 'read_mem', - help='Read arbitrary memory location') - parser_read_mem.add_argument('address', help='Address to read', type=arg_auto_int) - - parser_write_mem = subparsers.add_parser( - 'write_mem', - help='Read-modify-write to arbitrary memory location') - parser_write_mem.add_argument('address', help='Address to write', type=arg_auto_int) - parser_write_mem.add_argument('value', help='Value', type=arg_auto_int) - parser_write_mem.add_argument('mask', help='Mask of bits to write', type=arg_auto_int) - - def add_spi_flash_subparsers(parent, auto_detect=False): - """ Add common parser arguments for SPI flash properties """ - parent.add_argument('--flash_freq', '-ff', help='SPI Flash frequency', - choices=['40m', '26m', '20m', '80m'], - default=os.environ.get('ESPTOOL_FF', '40m')) - parent.add_argument('--flash_mode', '-fm', help='SPI Flash mode', - choices=['qio', 'qout', 'dio', 'dout'], - default=os.environ.get('ESPTOOL_FM', 'qio')) - choices = ['4m', '2m', '8m', '16m', '32m', '16m-c1', '32m-c1', '32m-c2'] - default = '4m' - if auto_detect: - default = 'detect' - choices.insert(0, 'detect') - parent.add_argument('--flash_size', '-fs', help='SPI Flash size in Mbit', type=str.lower, - choices=choices, - default=os.environ.get('ESPTOOL_FS', default)) - - parser_write_flash = subparsers.add_parser( - 'write_flash', - help='Write a binary blob to flash') - parser_write_flash.add_argument('addr_filename', metavar='
', help='Address followed by binary filename, separated by space', - action=AddrFilenamePairAction) - add_spi_flash_subparsers(parser_write_flash, auto_detect=True) - parser_write_flash.add_argument('--no-progress', '-p', help='Suppress progress output', action="store_true") - parser_write_flash.add_argument('--verify', help='Verify just-written data (only necessary if very cautious, data is already CRCed', action='store_true') - - subparsers.add_parser( - 'run', - help='Run application code in flash') - - parser_image_info = subparsers.add_parser( - 'image_info', - help='Dump headers from an application image') - parser_image_info.add_argument('filename', help='Image file to parse') - - parser_make_image = subparsers.add_parser( - 'make_image', - help='Create an application image from binary files') - parser_make_image.add_argument('output', help='Output image file') - parser_make_image.add_argument('--segfile', '-f', action='append', help='Segment input file') - parser_make_image.add_argument('--segaddr', '-a', action='append', help='Segment base address', type=arg_auto_int) - parser_make_image.add_argument('--entrypoint', '-e', help='Address of entry point', type=arg_auto_int, default=0) - - parser_elf2image = subparsers.add_parser( - 'elf2image', - help='Create an application image from ELF file') - parser_elf2image.add_argument('input', help='Input ELF file') - parser_elf2image.add_argument('--output', '-o', help='Output filename prefix (for version 1 image), or filename (for version 2 single image)', type=str) - parser_elf2image.add_argument('--version', '-e', help='Output image version', choices=['1','2'], default='1') - add_spi_flash_subparsers(parser_elf2image) - - subparsers.add_parser( - 'read_mac', - help='Read MAC address from OTP ROM') - - subparsers.add_parser( - 'chip_id', - help='Read Chip ID from OTP ROM') - - subparsers.add_parser( - 'flash_id', - help='Read SPI flash manufacturer and device ID') - - parser_read_flash = subparsers.add_parser( - 'read_flash', - help='Read SPI flash content') - parser_read_flash.add_argument('address', help='Start address', type=arg_auto_int) - parser_read_flash.add_argument('size', help='Size of region to dump', type=arg_auto_int) - parser_read_flash.add_argument('filename', help='Name of binary dump') - parser_read_flash.add_argument('--no-progress', '-p', help='Suppress progress output', action="store_true") - - parser_verify_flash = subparsers.add_parser( - 'verify_flash', - help='Verify a binary blob against flash') - parser_verify_flash.add_argument('addr_filename', help='Address and binary file to verify there, separated by space', - action=AddrFilenamePairAction) - parser_verify_flash.add_argument('--diff', '-d', help='Show differences', - choices=['no', 'yes'], default='no') - - subparsers.add_parser( - 'erase_flash', - help='Perform Chip Erase on SPI flash') - - subparsers.add_parser( - 'version', help='Print esptool version') - - # internal sanity check - every operation matches a module function of the same name - for operation in subparsers.choices.keys(): - assert operation in globals(), "%s should be a module function" % operation - - args = parser.parse_args() - - print 'esptool.py v%s' % __version__ - - # operation function can take 1 arg (args), 2 args (esp, arg) - # or be a member function of the ESPROM class. - - operation_func = globals()[args.operation] - operation_args,_,_,_ = inspect.getargspec(operation_func) - if operation_args[0] == 'esp': # operation function takes an ESPROM connection object - initial_baud = min(ESPROM.ESP_ROM_BAUD, args.baud) # don't sync faster than the default baud rate - esp = ESPROM(args.port, initial_baud) - esp.connect() - operation_func(esp, args) - else: - operation_func(args) - - -class AddrFilenamePairAction(argparse.Action): - """ Custom parser class for the address/filename pairs passed as arguments """ - def __init__(self, option_strings, dest, nargs='+', **kwargs): - super(AddrFilenamePairAction, self).__init__(option_strings, dest, nargs, **kwargs) - - def __call__(self, parser, namespace, values, option_string=None): - # validate pair arguments - pairs = [] - for i in range(0,len(values),2): - try: - address = int(values[i],0) - except ValueError as e: - raise argparse.ArgumentError(self,'Address "%s" must be a number' % values[i]) - try: - argfile = open(values[i + 1], 'rb') - except IOError as e: - raise argparse.ArgumentError(self, e) - except IndexError: - raise argparse.ArgumentError(self,'Must be pairs of an address and the binary filename to write there') - pairs.append((address, argfile)) - setattr(namespace, self.dest, pairs) - -# This is "wrapped" stub_flasher.c, to be loaded using run_stub. -_CESANTA_FLASHER_STUB = """\ -{"code_start": 1074790404, "code": "080000601C000060000000601000006031FCFF71FCFF\ -81FCFFC02000680332D218C020004807404074DCC48608005823C0200098081BA5A9239245005803\ -1B555903582337350129230B446604DFC6F3FF21EEFFC0200069020DF0000000010078480040004A\ -0040B449004012C1F0C921D911E901DD0209312020B4ED033C2C56C2073020B43C3C56420701F5FF\ -C000003C4C569206CD0EEADD860300202C4101F1FFC0000056A204C2DCF0C02DC0CC6CCAE2D1EAFF\ -0606002030F456D3FD86FBFF00002020F501E8FFC00000EC82D0CCC0C02EC0C73DEB2ADC46030020\ -2C4101E1FFC00000DC42C2DCF0C02DC056BCFEC602003C5C8601003C6C4600003C7C08312D0CD811\ -C821E80112C1100DF0000C180000140010400C0000607418000064180000801800008C1800008418\ -0000881800009018000018980040880F0040A80F0040349800404C4A0040740F0040800F0040980F\ -00400099004012C1E091F5FFC961CD0221EFFFE941F9310971D9519011C01A223902E2D1180C0222\ -6E1D21E4FF31E9FF2AF11A332D0F42630001EAFFC00000C030B43C2256A31621E1FF1A2228022030\ -B43C3256B31501ADFFC00000DD023C4256ED1431D6FF4D010C52D90E192E126E0101DDFFC0000021\ -D2FF32A101C020004802303420C0200039022C0201D7FFC00000463300000031CDFF1A333803D023\ -C03199FF27B31ADC7F31CBFF1A3328030198FFC0000056C20E2193FF2ADD060E000031C6FF1A3328\ -030191FFC0000056820DD2DD10460800000021BEFF1A2228029CE231BCFFC020F51A33290331BBFF\ -C02C411A332903C0F0F4222E1D22D204273D9332A3FFC02000280E27B3F721ABFF381E1A2242A400\ -01B5FFC00000381E2D0C42A40001B3FFC0000056120801B2FFC00000C02000280EC2DC0422D2FCC0\ -2000290E01ADFFC00000222E1D22D204226E1D281E22D204E7B204291E860000126E012198FF32A0\ -042A21C54C003198FF222E1D1A33380337B202C6D6FF2C02019FFFC000002191FF318CFF1A223A31\ -019CFFC00000218DFF1C031A22C549000C02060300003C528601003C624600003C72918BFF9A1108\ -71C861D851E841F83112C1200DF00010000068100000581000007010000074100000781000007C10\ -0000801000001C4B0040803C004091FDFF12C1E061F7FFC961E941F9310971D9519011C01A662906\ -21F3FFC2D1101A22390231F2FF0C0F1A33590331EAFFF26C1AED045C2247B3028636002D0C016DFF\ -C0000021E5FF41EAFF2A611A4469040622000021E4FF1A222802F0D2C0D7BE01DD0E31E0FF4D0D1A\ -3328033D0101E2FFC00000561209D03D2010212001DFFFC000004D0D2D0C3D01015DFFC0000041D5\ -FFDAFF1A444804D0648041D2FF1A4462640061D1FF106680622600673F1331D0FF10338028030C43\ -853A002642164613000041CAFF222C1A1A444804202FC047328006F6FF222C1A273F3861C2FF222C\ -1A1A6668066732B921BDFF3D0C1022800148FFC0000021BAFF1C031A2201BFFFC000000C02460300\ -5C3206020000005C424600005C5291B7FF9A110871C861D851E841F83112C1200DF0B0100000C010\ -0000D010000012C1E091FEFFC961D951E9410971F931CD039011C0ED02DD0431A1FF9C1422A06247\ -B302062D0021F4FF1A22490286010021F1FF1A223902219CFF2AF12D0F011FFFC00000461C0022D1\ -10011CFFC0000021E9FFFD0C1A222802C7B20621E6FF1A22F8022D0E3D014D0F0195FFC000008C52\ -22A063C6180000218BFF3D01102280F04F200111FFC00000AC7D22D1103D014D0F010DFFC0000021\ -D6FF32D110102280010EFFC0000021D3FF1C031A220185FFC00000FAEEF0CCC056ACF821CDFF317A\ -FF1A223A310105FFC0000021C9FF1C031A22017CFFC000002D0C91C8FF9A110871C861D851E841F8\ -3112C1200DF0000200600000001040020060FFFFFF0012C1E00C02290131FAFF21FAFF026107C961\ -C02000226300C02000C80320CC10564CFF21F5FFC02000380221F4FF20231029010C432D010163FF\ -C0000008712D0CC86112C1200DF00080FE3F8449004012C1D0C9A109B17CFC22C1110C13C51C0026\ -1202463000220111C24110B68202462B0031F5FF3022A02802A002002D011C03851A0066820A2801\ -32210105A6FF0607003C12C60500000010212032A01085180066A20F2221003811482105B3FF2241\ -10861A004C1206FDFF2D011C03C5160066B20E280138114821583185CFFF06F7FF005C1286F5FF00\ -10212032A01085140066A20D2221003811482105E1FF06EFFF0022A06146EDFF45F0FFC6EBFF0000\ -01D2FFC0000006E9FF000C022241100C1322C110C50F00220111060600000022C1100C13C50E0022\ -011132C2FA303074B6230206C8FF08B1C8A112C1300DF0000000000010404F484149007519031027\ -000000110040A8100040BC0F0040583F0040CC2E00401CE20040D83900408000004021F4FF12C1E0\ -C961C80221F2FF097129010C02D951C91101F4FFC0000001F3FFC00000AC2C22A3E801F2FFC00000\ -21EAFFC031412A233D0C01EFFFC000003D0222A00001EDFFC00000C1E4FF2D0C01E8FFC000002D01\ -32A004450400C5E7FFDD022D0C01E3FFC00000666D1F4B2131DCFF4600004B22C0200048023794F5\ -31D9FFC0200039023DF08601000001DCFFC000000871C861D85112C1200DF000000012C1F0026103\ -01EAFEC00000083112C1100DF000643B004012C1D0E98109B1C9A1D991F97129013911E2A0C001FA\ -FFC00000CD02E792F40C0DE2A0C0F2A0DB860D00000001F4FFC00000204220E71240F7921C226102\ -01EFFFC0000052A0DC482157120952A0DD571205460500004D0C3801DA234242001BDD3811379DC5\ -C6000000000C0DC2A0C001E3FFC00000C792F608B12D0DC8A1D891E881F87112C1300DF00000", "\ -entry": 1074792180, "num_params": 1, "params_start": 1074790400, "data": "FE0510\ -401A0610403B0610405A0610407A061040820610408C0610408C061040", "data_start": 10736\ -43520} -""" - -if __name__ == '__main__': - try: - main() - except FatalError as e: - print '\nA fatal error occurred: %s' % e - sys.exit(2) diff --git a/panda/python/flash_release.py b/panda/python/flash_release.py index 0f407ff22f05a0..6e77d6a7f61a6d 100755 --- a/panda/python/flash_release.py +++ b/panda/python/flash_release.py @@ -1,19 +1,19 @@ -#!/usr/bin/env python -from __future__ import print_function +#!/usr/bin/env python3 + import sys import time import requests import json -import StringIO +import io def flash_release(path=None, st_serial=None): - from panda import Panda, PandaDFU, ESPROM, CesantaFlasher + from panda import Panda, PandaDFU from zipfile import ZipFile def status(x): - print("\033[1;32;40m"+x+"\033[00m") + print("\033[1;32;40m" + x + "\033[00m") - if st_serial == None: + if st_serial is not None: # look for Panda panda_list = Panda.list() if len(panda_list) == 0: @@ -23,33 +23,28 @@ def status(x): st_serial = panda_list[0] print("Using panda with serial %s" % st_serial) - if path == None: + if path is None: print("Fetching latest firmware from github.com/commaai/panda-artifacts") r = requests.get("https://raw.githubusercontent.com/commaai/panda-artifacts/master/latest.json") url = json.loads(r.text)['url'] r = requests.get(url) print("Fetching firmware from %s" % url) - path = StringIO.StringIO(r.content) + path = io.BytesIO(r.content) zf = ZipFile(path) zf.printdir() - version = zf.read("version") - status("0. Preparing to flash "+version) + version = zf.read("version").decode() + status("0. Preparing to flash " + str(version)) code_bootstub = zf.read("bootstub.panda.bin") code_panda = zf.read("panda.bin") - code_boot_15 = zf.read("boot_v1.5.bin") - code_boot_15 = code_boot_15[0:2] + "\x00\x30" + code_boot_15[4:] - - code_user1 = zf.read("user1.bin") - code_user2 = zf.read("user2.bin") - # enter DFU mode status("1. Entering DFU mode") panda = Panda(st_serial) - panda.enter_bootloader() + panda.reset(enter_bootstub=True) + panda.reset(enter_bootloader=True) time.sleep(1) # program bootstub @@ -64,23 +59,8 @@ def status(x): panda.flash(code=code_panda) panda.close() - # flashing ESP - status("4. Flashing ESP (slow!)") - align = lambda x, sz=0x1000: x+"\xFF"*((sz-len(x)) % sz) - esp = ESPROM(st_serial) - esp.connect() - flasher = CesantaFlasher(esp, 230400) - flasher.flash_write(0x0, align(code_boot_15), True) - flasher.flash_write(0x1000, align(code_user1), True) - flasher.flash_write(0x81000, align(code_user2), True) - flasher.flash_write(0x3FE000, "\xFF"*0x1000) - flasher.boot_fw() - del flasher - del esp - time.sleep(1) - # check for connection - status("5. Verifying version") + status("4. Verifying version") panda = Panda(st_serial) my_version = panda.get_version() print("dongle id: %s" % panda.get_serial()[0]) @@ -92,4 +72,3 @@ def status(x): if __name__ == "__main__": flash_release(*sys.argv[1:]) - diff --git a/panda/python/isotp.py b/panda/python/isotp.py index 971827007a6f26..45acb6abae7d70 100644 --- a/panda/python/isotp.py +++ b/panda/python/isotp.py @@ -1,13 +1,16 @@ +import binascii +import time + DEBUG = False def msg(x): if DEBUG: - print "S:",x.encode("hex") + print("S:", binascii.hexlify(x)) if len(x) <= 7: - ret = chr(len(x)) + x + ret = bytes([len(x)]) + x else: assert False - return ret.ljust(8, "\x00") + return ret.ljust(8, b"\x00") kmsgs = [] def recv(panda, cnt, addr, nbus): @@ -24,112 +27,116 @@ def recv(panda, cnt, addr, nbus): # leave around nmsgs.append((ids, ts, dat, bus)) kmsgs = nmsgs[-256:] - return map(str, ret) + return ret def isotp_recv_subaddr(panda, addr, bus, sendaddr, subaddr): msg = recv(panda, 1, addr, bus)[0] # TODO: handle other subaddr also communicating - assert ord(msg[0]) == subaddr + assert msg[0] == subaddr - if ord(msg[1])&0xf0 == 0x10: + if msg[1] & 0xf0 == 0x10: # first - tlen = ((ord(msg[1]) & 0xf) << 8) | ord(msg[2]) + tlen = ((msg[1] & 0xf) << 8) | msg[2] dat = msg[3:] # 0 block size? - CONTINUE = chr(subaddr) + "\x30" + "\x00"*6 + CONTINUE = bytes([subaddr]) + b"\x30" + b"\x00" * 6 panda.can_send(sendaddr, CONTINUE, bus) idx = 1 - for mm in recv(panda, (tlen-len(dat) + 5)/6, addr, bus): - assert ord(mm[0]) == subaddr - assert ord(mm[1]) == (0x20 | (idx&0xF)) + for mm in recv(panda, (tlen - len(dat) + 5) // 6, addr, bus): + assert mm[0] == subaddr + assert mm[1] == (0x20 | (idx & 0xF)) dat += mm[2:] idx += 1 - elif ord(msg[1])&0xf0 == 0x00: + elif msg[1] & 0xf0 == 0x00: # single - tlen = ord(msg[1]) & 0xf + tlen = msg[1] & 0xf dat = msg[2:] else: - print msg.encode("hex") + print(binascii.hexlify(msg)) assert False return dat[0:tlen] # **** import below this line **** -def isotp_send(panda, x, addr, bus=0, recvaddr=None, subaddr=None): +def isotp_send(panda, x, addr, bus=0, recvaddr=None, subaddr=None, rate=None): if recvaddr is None: - recvaddr = addr+8 + recvaddr = addr + 8 if len(x) <= 7 and subaddr is None: panda.can_send(addr, msg(x), bus) elif len(x) <= 6 and subaddr is not None: - panda.can_send(addr, chr(subaddr)+msg(x)[0:7], bus) + panda.can_send(addr, bytes([subaddr]) + msg(x)[0:7], bus) else: if subaddr: - ss = chr(subaddr) + chr(0x10 + (len(x)>>8)) + chr(len(x)&0xFF) + x[0:5] + ss = bytes([subaddr, 0x10 + (len(x) >> 8), len(x) & 0xFF]) + x[0:5] x = x[5:] else: - ss = chr(0x10 + (len(x)>>8)) + chr(len(x)&0xFF) + x[0:6] + ss = bytes([0x10 + (len(x) >> 8), len(x) & 0xFF]) + x[0:6] x = x[6:] idx = 1 sends = [] while len(x) > 0: if subaddr: - sends.append(((chr(subaddr) + chr(0x20 + (idx&0xF)) + x[0:6]).ljust(8, "\x00"))) + sends.append(((bytes([subaddr, 0x20 + (idx & 0xF)]) + x[0:6]).ljust(8, b"\x00"))) x = x[6:] else: - sends.append(((chr(0x20 + (idx&0xF)) + x[0:7]).ljust(8, "\x00"))) + sends.append(((bytes([0x20 + (idx & 0xF)]) + x[0:7]).ljust(8, b"\x00"))) x = x[7:] idx += 1 # actually send panda.can_send(addr, ss, bus) rr = recv(panda, 1, recvaddr, bus)[0] - if rr.find("\x30\x01") != -1: + if rr.find(b"\x30\x01") != -1: for s in sends[:-1]: panda.can_send(addr, s, 0) rr = recv(panda, 1, recvaddr, bus)[0] panda.can_send(addr, sends[-1], 0) else: - panda.can_send_many([(addr, None, s, 0) for s in sends]) + if rate is None: + panda.can_send_many([(addr, None, s, bus) for s in sends]) + else: + for dat in sends: + panda.can_send(addr, dat, bus) + time.sleep(rate) def isotp_recv(panda, addr, bus=0, sendaddr=None, subaddr=None): if sendaddr is None: - sendaddr = addr-8 + sendaddr = addr - 8 if subaddr is not None: dat = isotp_recv_subaddr(panda, addr, bus, sendaddr, subaddr) else: msg = recv(panda, 1, addr, bus)[0] - if ord(msg[0])&0xf0 == 0x10: + if msg[0] & 0xf0 == 0x10: # first - tlen = ((ord(msg[0]) & 0xf) << 8) | ord(msg[1]) + tlen = ((msg[0] & 0xf) << 8) | msg[1] dat = msg[2:] # 0 block size? - CONTINUE = "\x30" + "\x00"*7 + CONTINUE = b"\x30" + b"\x00" * 7 panda.can_send(sendaddr, CONTINUE, bus) idx = 1 - for mm in recv(panda, (tlen-len(dat) + 6)/7, addr, bus): - assert ord(mm[0]) == (0x20 | (idx&0xF)) + for mm in recv(panda, (tlen - len(dat) + 6) // 7, addr, bus): + assert mm[0] == (0x20 | (idx & 0xF)) dat += mm[1:] idx += 1 - elif ord(msg[0])&0xf0 == 0x00: + elif msg[0] & 0xf0 == 0x00: # single - tlen = ord(msg[0]) & 0xf + tlen = msg[0] & 0xf dat = msg[1:] else: assert False dat = dat[0:tlen] if DEBUG: - print "R:",dat.encode("hex") + print("R:", binascii.hexlify(dat)) return dat - diff --git a/panda/python/serial.py b/panda/python/serial.py index 1bcfebb32eabd0..93ed2dfe4d897a 100644 --- a/panda/python/serial.py +++ b/panda/python/serial.py @@ -5,23 +5,18 @@ def __init__(self, panda, port, baud): self.port = port self.panda.set_uart_parity(self.port, 0) self.panda.set_uart_baud(self.port, baud) - self.buf = "" + self.buf = b"" - def read(self, l=1): + def read(self, l=1): # noqa: E741 tt = self.panda.serial_read(self.port) if len(tt) > 0: - #print "R: ", tt.encode("hex") self.buf += tt ret = self.buf[0:l] self.buf = self.buf[l:] return ret def write(self, dat): - #print "W: ", dat.encode("hex") - #print ' pigeon_send("' + ''.join(map(lambda x: "\\x%02X" % ord(x), dat)) + '");' return self.panda.serial_write(self.port, dat) def close(self): pass - - diff --git a/panda/python/uds.py b/panda/python/uds.py new file mode 100644 index 00000000000000..f83c11fc383e68 --- /dev/null +++ b/panda/python/uds.py @@ -0,0 +1,857 @@ +#!/usr/bin/env python3 +import time +import struct +from collections import deque +from typing import Callable, NamedTuple, Tuple, List, Deque, Generator, Optional, cast +from enum import IntEnum + +class SERVICE_TYPE(IntEnum): + DIAGNOSTIC_SESSION_CONTROL = 0x10 + ECU_RESET = 0x11 + SECURITY_ACCESS = 0x27 + COMMUNICATION_CONTROL = 0x28 + TESTER_PRESENT = 0x3E + ACCESS_TIMING_PARAMETER = 0x83 + SECURED_DATA_TRANSMISSION = 0x84 + CONTROL_DTC_SETTING = 0x85 + RESPONSE_ON_EVENT = 0x86 + LINK_CONTROL = 0x87 + READ_DATA_BY_IDENTIFIER = 0x22 + READ_MEMORY_BY_ADDRESS = 0x23 + READ_SCALING_DATA_BY_IDENTIFIER = 0x24 + READ_DATA_BY_PERIODIC_IDENTIFIER = 0x2A + DYNAMICALLY_DEFINE_DATA_IDENTIFIER = 0x2C + WRITE_DATA_BY_IDENTIFIER = 0x2E + WRITE_MEMORY_BY_ADDRESS = 0x3D + CLEAR_DIAGNOSTIC_INFORMATION = 0x14 + READ_DTC_INFORMATION = 0x19 + INPUT_OUTPUT_CONTROL_BY_IDENTIFIER = 0x2F + ROUTINE_CONTROL = 0x31 + REQUEST_DOWNLOAD = 0x34 + REQUEST_UPLOAD = 0x35 + TRANSFER_DATA = 0x36 + REQUEST_TRANSFER_EXIT = 0x37 + +class SESSION_TYPE(IntEnum): + DEFAULT = 1 + PROGRAMMING = 2 + EXTENDED_DIAGNOSTIC = 3 + SAFETY_SYSTEM_DIAGNOSTIC = 4 + +class RESET_TYPE(IntEnum): + HARD = 1 + KEY_OFF_ON = 2 + SOFT = 3 + ENABLE_RAPID_POWER_SHUTDOWN = 4 + DISABLE_RAPID_POWER_SHUTDOWN = 5 + +class ACCESS_TYPE(IntEnum): + REQUEST_SEED = 1 + SEND_KEY = 2 + +class CONTROL_TYPE(IntEnum): + ENABLE_RX_ENABLE_TX = 0 + ENABLE_RX_DISABLE_TX = 1 + DISABLE_RX_ENABLE_TX = 2 + DISABLE_RX_DISABLE_TX = 3 + +class MESSAGE_TYPE(IntEnum): + NORMAL = 1 + NETWORK_MANAGEMENT = 2 + NORMAL_AND_NETWORK_MANAGEMENT = 3 + +class TIMING_PARAMETER_TYPE(IntEnum): + READ_EXTENDED_SET = 1 + SET_TO_DEFAULT_VALUES = 2 + READ_CURRENTLY_ACTIVE = 3 + SET_TO_GIVEN_VALUES = 4 + +class DTC_SETTING_TYPE(IntEnum): + ON = 1 + OFF = 2 + +class RESPONSE_EVENT_TYPE(IntEnum): + STOP_RESPONSE_ON_EVENT = 0 + ON_DTC_STATUS_CHANGE = 1 + ON_TIMER_INTERRUPT = 2 + ON_CHANGE_OF_DATA_IDENTIFIER = 3 + REPORT_ACTIVATED_EVENTS = 4 + START_RESPONSE_ON_EVENT = 5 + CLEAR_RESPONSE_ON_EVENT = 6 + ON_COMPARISON_OF_VALUES = 7 + +class LINK_CONTROL_TYPE(IntEnum): + VERIFY_BAUDRATE_TRANSITION_WITH_FIXED_BAUDRATE = 1 + VERIFY_BAUDRATE_TRANSITION_WITH_SPECIFIC_BAUDRATE = 2 + TRANSITION_BAUDRATE = 3 + +class BAUD_RATE_TYPE(IntEnum): + PC9600 = 1 + PC19200 = 2 + PC38400 = 3 + PC57600 = 4 + PC115200 = 5 + CAN125000 = 16 + CAN250000 = 17 + CAN500000 = 18 + CAN1000000 = 19 + +class DATA_IDENTIFIER_TYPE(IntEnum): + BOOT_SOFTWARE_IDENTIFICATION = 0xF180 + APPLICATION_SOFTWARE_IDENTIFICATION = 0xF181 + APPLICATION_DATA_IDENTIFICATION = 0xF182 + BOOT_SOFTWARE_FINGERPRINT = 0xF183 + APPLICATION_SOFTWARE_FINGERPRINT = 0xF184 + APPLICATION_DATA_FINGERPRINT = 0xF185 + ACTIVE_DIAGNOSTIC_SESSION = 0xF186 + VEHICLE_MANUFACTURER_SPARE_PART_NUMBER = 0xF187 + VEHICLE_MANUFACTURER_ECU_SOFTWARE_NUMBER = 0xF188 + VEHICLE_MANUFACTURER_ECU_SOFTWARE_VERSION_NUMBER = 0xF189 + SYSTEM_SUPPLIER_IDENTIFIER = 0xF18A + ECU_MANUFACTURING_DATE = 0xF18B + ECU_SERIAL_NUMBER = 0xF18C + SUPPORTED_FUNCTIONAL_UNITS = 0xF18D + VEHICLE_MANUFACTURER_KIT_ASSEMBLY_PART_NUMBER = 0xF18E + VIN = 0xF190 + VEHICLE_MANUFACTURER_ECU_HARDWARE_NUMBER = 0xF191 + SYSTEM_SUPPLIER_ECU_HARDWARE_NUMBER = 0xF192 + SYSTEM_SUPPLIER_ECU_HARDWARE_VERSION_NUMBER = 0xF193 + SYSTEM_SUPPLIER_ECU_SOFTWARE_NUMBER = 0xF194 + SYSTEM_SUPPLIER_ECU_SOFTWARE_VERSION_NUMBER = 0xF195 + EXHAUST_REGULATION_OR_TYPE_APPROVAL_NUMBER = 0xF196 + SYSTEM_NAME_OR_ENGINE_TYPE = 0xF197 + REPAIR_SHOP_CODE_OR_TESTER_SERIAL_NUMBER = 0xF198 + PROGRAMMING_DATE = 0xF199 + CALIBRATION_REPAIR_SHOP_CODE_OR_CALIBRATION_EQUIPMENT_SERIAL_NUMBER = 0xF19A + CALIBRATION_DATE = 0xF19B + CALIBRATION_EQUIPMENT_SOFTWARE_NUMBER = 0xF19C + ECU_INSTALLATION_DATE = 0xF19D + ODX_FILE = 0xF19E + ENTITY = 0xF19F + +class TRANSMISSION_MODE_TYPE(IntEnum): + SEND_AT_SLOW_RATE = 1 + SEND_AT_MEDIUM_RATE = 2 + SEND_AT_FAST_RATE = 3 + STOP_SENDING = 4 + +class DYNAMIC_DEFINITION_TYPE(IntEnum): + DEFINE_BY_IDENTIFIER = 1 + DEFINE_BY_MEMORY_ADDRESS = 2 + CLEAR_DYNAMICALLY_DEFINED_DATA_IDENTIFIER = 3 + +class DynamicSourceDefinition(NamedTuple): + data_identifier: int + position: int + memory_size: int + memory_address: int + +class DTC_GROUP_TYPE(IntEnum): + EMISSIONS = 0x000000 + ALL = 0xFFFFFF + +class DTC_REPORT_TYPE(IntEnum): + NUMBER_OF_DTC_BY_STATUS_MASK = 0x01 + DTC_BY_STATUS_MASK = 0x02 + DTC_SNAPSHOT_IDENTIFICATION = 0x03 + DTC_SNAPSHOT_RECORD_BY_DTC_NUMBER = 0x04 + DTC_SNAPSHOT_RECORD_BY_RECORD_NUMBER = 0x05 + DTC_EXTENDED_DATA_RECORD_BY_DTC_NUMBER = 0x06 + NUMBER_OF_DTC_BY_SEVERITY_MASK_RECORD = 0x07 + DTC_BY_SEVERITY_MASK_RECORD = 0x08 + SEVERITY_INFORMATION_OF_DTC = 0x09 + SUPPORTED_DTC = 0x0A + FIRST_TEST_FAILED_DTC = 0x0B + FIRST_CONFIRMED_DTC = 0x0C + MOST_RECENT_TEST_FAILED_DTC = 0x0D + MOST_RECENT_CONFIRMED_DTC = 0x0E + MIRROR_MEMORY_DTC_BY_STATUS_MASK = 0x0F + MIRROR_MEMORY_DTC_EXTENDED_DATA_RECORD_BY_DTC_NUMBER = 0x10 + NUMBER_OF_MIRROR_MEMORY_DTC_BY_STATUS_MASK = 0x11 + NUMBER_OF_EMISSIONS_RELATED_OBD_DTC_BY_STATUS_MASK = 0x12 + EMISSIONS_RELATED_OBD_DTC_BY_STATUS_MASK = 0x13 + DTC_FAULT_DETECTION_COUNTER = 0x14 + DTC_WITH_PERMANENT_STATUS = 0x15 + +class DTC_STATUS_MASK_TYPE(IntEnum): + TEST_FAILED = 0x01 + TEST_FAILED_THIS_OPERATION_CYCLE = 0x02 + PENDING_DTC = 0x04 + CONFIRMED_DTC = 0x08 + TEST_NOT_COMPLETED_SINCE_LAST_CLEAR = 0x10 + TEST_FAILED_SINCE_LAST_CLEAR = 0x20 + TEST_NOT_COMPLETED_THIS_OPERATION_CYCLE = 0x40 + WARNING_INDICATOR_REQUESTED = 0x80 + ALL = 0xFF + +class DTC_SEVERITY_MASK_TYPE(IntEnum): + MAINTENANCE_ONLY = 0x20 + CHECK_AT_NEXT_HALT = 0x40 + CHECK_IMMEDIATELY = 0x80 + ALL = 0xE0 + +class CONTROL_PARAMETER_TYPE(IntEnum): + RETURN_CONTROL_TO_ECU = 0 + RESET_TO_DEFAULT = 1 + FREEZE_CURRENT_STATE = 2 + SHORT_TERM_ADJUSTMENT = 3 + +class ROUTINE_CONTROL_TYPE(IntEnum): + START = 1 + STOP = 2 + REQUEST_RESULTS = 3 + +class ROUTINE_IDENTIFIER_TYPE(IntEnum): + ERASE_MEMORY = 0xFF00 + CHECK_PROGRAMMING_DEPENDENCIES = 0xFF01 + ERASE_MIRROR_MEMORY_DTCS = 0xFF02 + +class MessageTimeoutError(Exception): + pass + +class NegativeResponseError(Exception): + def __init__(self, message, service_id, error_code): + super().__init__() + self.message = message + self.service_id = service_id + self.error_code = error_code + + def __str__(self): + return self.message + +class InvalidServiceIdError(Exception): + pass + +class InvalidSubFunctioneError(Exception): + pass + +_negative_response_codes = { + 0x00: 'positive response', + 0x10: 'general reject', + 0x11: 'service not supported', + 0x12: 'sub-function not supported', + 0x13: 'incorrect message length or invalid format', + 0x14: 'response too long', + 0x21: 'busy repeat request', + 0x22: 'conditions not correct', + 0x24: 'request sequence error', + 0x25: 'no response from subnet component', + 0x26: 'failure prevents execution of requested action', + 0x31: 'request out of range', + 0x33: 'security access denied', + 0x35: 'invalid key', + 0x36: 'exceed numebr of attempts', + 0x37: 'required time delay not expired', + 0x70: 'upload download not accepted', + 0x71: 'transfer data suspended', + 0x72: 'general programming failure', + 0x73: 'wrong block sequence counter', + 0x78: 'request correctly received - response pending', + 0x7e: 'sub-function not supported in active session', + 0x7f: 'service not supported in active session', + 0x81: 'rpm too high', + 0x82: 'rpm too low', + 0x83: 'engine is running', + 0x84: 'engine is not running', + 0x85: 'engine run time too low', + 0x86: 'temperature too high', + 0x87: 'temperature too low', + 0x88: 'vehicle speed too high', + 0x89: 'vehicle speed too low', + 0x8a: 'throttle/pedal too high', + 0x8b: 'throttle/pedal too low', + 0x8c: 'transmission not in neutral', + 0x8d: 'transmission not in gear', + 0x8f: 'brake switch(es) not closed', + 0x90: 'shifter lever not in park', + 0x91: 'torque converter clutch locked', + 0x92: 'voltage too high', + 0x93: 'voltage too low', +} + + +class CanClient(): + def __init__(self, can_send: Callable[[int, bytes, int], None], can_recv: Callable[[], List[Tuple[int, int, bytes, int]]], + tx_addr: int, rx_addr: int, bus: int, sub_addr: int = None, debug: bool = False): + self.tx = can_send + self.rx = can_recv + self.tx_addr = tx_addr + self.rx_addr = rx_addr + self.rx_buff = deque() # type: Deque[bytes] + self.sub_addr = sub_addr + self.bus = bus + self.debug = debug + + def _recv_filter(self, bus: int, addr: int) -> bool: + # handle functional addresses (switch to first addr to respond) + if self.tx_addr == 0x7DF: + is_response = addr >= 0x7E8 and addr <= 0x7EF + if is_response: + if self.debug: + print(f"switch to physical addr {hex(addr)}") + self.tx_addr = addr - 8 + self.rx_addr = addr + return is_response + if self.tx_addr == 0x18DB33F1: + is_response = addr >= 0x18DAF100 and addr <= 0x18DAF1FF + if is_response: + if self.debug: + print(f"switch to physical addr {hex(addr)}") + self.tx_addr = 0x18DA00F1 + (addr << 8 & 0xFF00) + self.rx_addr = addr + return bus == self.bus and addr == self.rx_addr + + def _recv_buffer(self, drain: bool = False) -> None: + while True: + msgs = self.rx() + if drain: + if self.debug: + print("CAN-RX: drain - {}".format(len(msgs))) + self.rx_buff.clear() + else: + for rx_addr, _, rx_data, rx_bus in msgs or []: + if self._recv_filter(rx_bus, rx_addr) and len(rx_data) > 0: + rx_data = bytes(rx_data) # convert bytearray to bytes + + if self.debug: + print(f"CAN-RX: {hex(rx_addr)} - 0x{bytes.hex(rx_data)}") + + # Cut off sub addr in first byte + if self.sub_addr is not None: + rx_data = rx_data[1:] + + self.rx_buff.append(rx_data) + # break when non-full buffer is processed + if len(msgs) < 254: + return + + def recv(self, drain: bool = False) -> Generator[bytes, None, None]: + # buffer rx messages in case two response messages are received at once + # (e.g. response pending and success/failure response) + self._recv_buffer(drain) + try: + while True: + yield self.rx_buff.popleft() + except IndexError: + pass # empty + + def send(self, msgs: List[bytes], delay: float = 0) -> None: + for i, msg in enumerate(msgs): + if delay and i != 0: + if self.debug: + print(f"CAN-TX: delay - {delay}") + time.sleep(delay) + + if self.sub_addr is not None: + msg = bytes([self.sub_addr]) + msg + + if self.debug: + print(f"CAN-TX: {hex(self.tx_addr)} - 0x{bytes.hex(msg)}") + assert len(msg) <= 8 + + self.tx(self.tx_addr, msg, self.bus) + # prevent rx buffer from overflowing on large tx + if i % 10 == 9: + self._recv_buffer() + +class IsoTpMessage(): + def __init__(self, can_client: CanClient, timeout: float = 1, debug: bool = False, max_len: int = 8): + self._can_client = can_client + self.timeout = timeout + self.debug = debug + self.max_len = max_len + + def send(self, dat: bytes) -> None: + # throw away any stale data + self._can_client.recv(drain=True) + + self.tx_dat = dat + self.tx_len = len(dat) + self.tx_idx = 0 + self.tx_done = False + + self.rx_dat = b"" + self.rx_len = 0 + self.rx_idx = 0 + self.rx_done = False + + if self.debug: + print(f"ISO-TP: REQUEST - 0x{bytes.hex(self.tx_dat)}") + self._tx_first_frame() + + def _tx_first_frame(self) -> None: + if self.tx_len < self.max_len: + # single frame (send all bytes) + if self.debug: + print("ISO-TP: TX - single frame") + msg = (bytes([self.tx_len]) + self.tx_dat).ljust(self.max_len, b"\x00") + self.tx_done = True + else: + # first frame (send first 6 bytes) + if self.debug: + print("ISO-TP: TX - first frame") + msg = (struct.pack("!H", 0x1000 | self.tx_len) + self.tx_dat[:self.max_len - 2]).ljust(self.max_len - 2, b"\x00") + self._can_client.send([msg]) + + def recv(self) -> Optional[bytes]: + start_time = time.time() + try: + while True: + for msg in self._can_client.recv(): + self._isotp_rx_next(msg) + if self.tx_done and self.rx_done: + return self.rx_dat + # no timeout indicates non-blocking + if self.timeout == 0: + return None + if time.time() - start_time > self.timeout: + raise MessageTimeoutError("timeout waiting for response") + finally: + if self.debug and self.rx_dat: + print(f"ISO-TP: RESPONSE - 0x{bytes.hex(self.rx_dat)}") + + def _isotp_rx_next(self, rx_data: bytes) -> None: + # single rx_frame + if rx_data[0] >> 4 == 0x0: + self.rx_len = rx_data[0] & 0xFF + self.rx_dat = rx_data[1:1 + self.rx_len] + self.rx_idx = 0 + self.rx_done = True + if self.debug: + print(f"ISO-TP: RX - single frame - idx={self.rx_idx} done={self.rx_done}") + return + + # first rx_frame + if rx_data[0] >> 4 == 0x1: + self.rx_len = ((rx_data[0] & 0x0F) << 8) + rx_data[1] + self.rx_dat = rx_data[2:] + self.rx_idx = 0 + self.rx_done = False + if self.debug: + print(f"ISO-TP: RX - first frame - idx={self.rx_idx} done={self.rx_done}") + if self.debug: + print("ISO-TP: TX - flow control continue") + # send flow control message (send all bytes) + msg = b"\x30\x00\x00".ljust(self.max_len, b"\x00") + self._can_client.send([msg]) + return + + # consecutive rx frame + if rx_data[0] >> 4 == 0x2: + assert not self.rx_done, "isotp - rx: consecutive frame with no active frame" + self.rx_idx += 1 + assert self.rx_idx & 0xF == rx_data[0] & 0xF, "isotp - rx: invalid consecutive frame index" + rx_size = self.rx_len - len(self.rx_dat) + self.rx_dat += rx_data[1:1 + rx_size] + if self.rx_len == len(self.rx_dat): + self.rx_done = True + if self.debug: + print(f"ISO-TP: RX - consecutive frame - idx={self.rx_idx} done={self.rx_done}") + return + + # flow control + if rx_data[0] >> 4 == 0x3: + assert not self.tx_done, "isotp - rx: flow control with no active frame" + assert rx_data[0] != 0x32, "isotp - rx: flow-control overflow/abort" + assert rx_data[0] == 0x30 or rx_data[0] == 0x31, "isotp - rx: flow-control transfer state indicator invalid" + if rx_data[0] == 0x30: + if self.debug: + print("ISO-TP: RX - flow control continue") + delay_ts = rx_data[2] & 0x7F + # scale is 1 milliseconds if first bit == 0, 100 micro seconds if first bit == 1 + delay_div = 1000. if rx_data[2] & 0x80 == 0 else 10000. + delay_sec = delay_ts / delay_div + + # first frame = 6 bytes, each consecutive frame = 7 bytes + num_bytes = self.max_len - 1 + start = 6 + self.tx_idx * num_bytes + count = rx_data[1] + end = start + count * num_bytes if count > 0 else self.tx_len + tx_msgs = [] + for i in range(start, end, num_bytes): + self.tx_idx += 1 + # consecutive tx messages + msg = (bytes([0x20 | (self.tx_idx & 0xF)]) + self.tx_dat[i:i + num_bytes]).ljust(self.max_len, b"\x00") + tx_msgs.append(msg) + # send consecutive tx messages + self._can_client.send(tx_msgs, delay=delay_sec) + if end >= self.tx_len: + self.tx_done = True + if self.debug: + print(f"ISO-TP: TX - consecutive frame - idx={self.tx_idx} done={self.tx_done}") + elif rx_data[0] == 0x31: + # wait (do nothing until next flow control message) + if self.debug: + print("ISO-TP: TX - flow control wait") + +FUNCTIONAL_ADDRS = [0x7DF, 0x18DB33F1] + +def get_rx_addr_for_tx_addr(tx_addr): + if tx_addr in FUNCTIONAL_ADDRS: + return None + + if tx_addr < 0xFFF8: + # standard 11 bit response addr (add 8) + return tx_addr + 8 + + if tx_addr > 0x10000000 and tx_addr < 0xFFFFFFFF: + # standard 29 bit response addr (flip last two bytes) + return (tx_addr & 0xFFFF0000) + (tx_addr << 8 & 0xFF00) + (tx_addr >> 8 & 0xFF) + + raise ValueError("invalid tx_addr: {}".format(tx_addr)) + + +class UdsClient(): + def __init__(self, panda, tx_addr: int, rx_addr: int = None, bus: int = 0, timeout: float = 1, debug: bool = False): + self.bus = bus + self.tx_addr = tx_addr + self.rx_addr = rx_addr if rx_addr is not None else get_rx_addr_for_tx_addr(tx_addr) + self.timeout = timeout + self.debug = debug + self._can_client = CanClient(panda.can_send, panda.can_recv, self.tx_addr, self.rx_addr, self.bus, debug=self.debug) + + # generic uds request + def _uds_request(self, service_type: SERVICE_TYPE, subfunction: int = None, data: bytes = None) -> bytes: + req = bytes([service_type]) + if subfunction is not None: + req += bytes([subfunction]) + if data is not None: + req += data + + # send request, wait for response + isotp_msg = IsoTpMessage(self._can_client, self.timeout, self.debug) + isotp_msg.send(req) + while True: + resp = isotp_msg.recv() + + if resp is None: + continue + + resp_sid = resp[0] if len(resp) > 0 else None + + # negative response + if resp_sid == 0x7F: + service_id = resp[1] if len(resp) > 1 else -1 + try: + service_desc = SERVICE_TYPE(service_id).name + except BaseException: + service_desc = 'NON_STANDARD_SERVICE' + error_code = resp[2] if len(resp) > 2 else -1 + try: + error_desc = _negative_response_codes[error_code] + except BaseException: + error_desc = resp[3:].hex() + # wait for another message if response pending + if error_code == 0x78: + if self.debug: + print("UDS-RX: response pending") + continue + raise NegativeResponseError('{} - {}'.format(service_desc, error_desc), service_id, error_code) + + # positive response + if service_type + 0x40 != resp_sid: + resp_sid_hex = hex(resp_sid) if resp_sid is not None else None + raise InvalidServiceIdError('invalid response service id: {}'.format(resp_sid_hex)) + + if subfunction is not None: + resp_sfn = resp[1] if len(resp) > 1 else None + if subfunction != resp_sfn: + resp_sfn_hex = hex(resp_sfn) if resp_sfn is not None else None + raise InvalidSubFunctioneError(f'invalid response subfunction: {resp_sfn_hex:x}') + + # return data (exclude service id and sub-function id) + return resp[(1 if subfunction is None else 2):] + + # services + def diagnostic_session_control(self, session_type: SESSION_TYPE): + self._uds_request(SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL, subfunction=session_type) + + def ecu_reset(self, reset_type: RESET_TYPE): + resp = self._uds_request(SERVICE_TYPE.ECU_RESET, subfunction=reset_type) + power_down_time = None + if reset_type == RESET_TYPE.ENABLE_RAPID_POWER_SHUTDOWN: + power_down_time = resp[0] + return power_down_time + + def security_access(self, access_type: ACCESS_TYPE, security_key: bytes = None): + request_seed = access_type % 2 != 0 + if request_seed and security_key is not None: + raise ValueError('security_key not allowed') + if not request_seed and security_key is None: + raise ValueError('security_key is missing') + resp = self._uds_request(SERVICE_TYPE.SECURITY_ACCESS, subfunction=access_type, data=security_key) + if request_seed: + security_seed = resp + return security_seed + + def communication_control(self, control_type: CONTROL_TYPE, message_type: MESSAGE_TYPE): + data = bytes([message_type]) + self._uds_request(SERVICE_TYPE.COMMUNICATION_CONTROL, subfunction=control_type, data=data) + + def tester_present(self, ): + self._uds_request(SERVICE_TYPE.TESTER_PRESENT, subfunction=0x00) + + def access_timing_parameter(self, timing_parameter_type: TIMING_PARAMETER_TYPE, parameter_values: bytes = None): + write_custom_values = timing_parameter_type == TIMING_PARAMETER_TYPE.SET_TO_GIVEN_VALUES + read_values = (timing_parameter_type == TIMING_PARAMETER_TYPE.READ_CURRENTLY_ACTIVE or + timing_parameter_type == TIMING_PARAMETER_TYPE.READ_EXTENDED_SET) + if not write_custom_values and parameter_values is not None: + raise ValueError('parameter_values not allowed') + if write_custom_values and parameter_values is None: + raise ValueError('parameter_values is missing') + resp = self._uds_request(SERVICE_TYPE.ACCESS_TIMING_PARAMETER, subfunction=timing_parameter_type, data=parameter_values) + if read_values: + # TODO: parse response into values? + parameter_values = resp + return parameter_values + + def secured_data_transmission(self, data: bytes): + # TODO: split data into multiple input parameters? + resp = self._uds_request(SERVICE_TYPE.SECURED_DATA_TRANSMISSION, subfunction=None, data=data) + # TODO: parse response into multiple output values? + return resp + + def control_dtc_setting(self, dtc_setting_type: DTC_SETTING_TYPE): + self._uds_request(SERVICE_TYPE.CONTROL_DTC_SETTING, subfunction=dtc_setting_type) + + def response_on_event(self, response_event_type: RESPONSE_EVENT_TYPE, store_event: bool, window_time: int, + event_type_record: int, service_response_record: int): + if store_event: + response_event_type |= 0x20 # type: ignore + # TODO: split record parameters into arrays + data = bytes([window_time, event_type_record, service_response_record]) + resp = self._uds_request(SERVICE_TYPE.RESPONSE_ON_EVENT, subfunction=response_event_type, data=data) + + if response_event_type == RESPONSE_EVENT_TYPE.REPORT_ACTIVATED_EVENTS: + return { + "num_of_activated_events": resp[0], + "data": resp[1:], # TODO: parse the reset of response + } + + return { + "num_of_identified_events": resp[0], + "event_window_time": resp[1], + "data": resp[2:], # TODO: parse the reset of response + } + + def link_control(self, link_control_type: LINK_CONTROL_TYPE, baud_rate_type: BAUD_RATE_TYPE = None): + data: Optional[bytes] + + if link_control_type == LINK_CONTROL_TYPE.VERIFY_BAUDRATE_TRANSITION_WITH_FIXED_BAUDRATE: + # baud_rate_type = BAUD_RATE_TYPE + data = bytes([cast(int, baud_rate_type)]) + elif link_control_type == LINK_CONTROL_TYPE.VERIFY_BAUDRATE_TRANSITION_WITH_SPECIFIC_BAUDRATE: + # baud_rate_type = custom value (3 bytes big-endian) + data = struct.pack('!I', baud_rate_type)[1:] + else: + data = None + self._uds_request(SERVICE_TYPE.LINK_CONTROL, subfunction=link_control_type, data=data) + + def read_data_by_identifier(self, data_identifier_type: DATA_IDENTIFIER_TYPE): + # TODO: support list of identifiers + data = struct.pack('!H', data_identifier_type) + resp = self._uds_request(SERVICE_TYPE.READ_DATA_BY_IDENTIFIER, subfunction=None, data=data) + resp_id = struct.unpack('!H', resp[0:2])[0] if len(resp) >= 2 else None + if resp_id != data_identifier_type: + raise ValueError('invalid response data identifier: {}'.format(hex(resp_id))) + return resp[2:] + + def read_memory_by_address(self, memory_address: int, memory_size: int, memory_address_bytes: int = 4, memory_size_bytes: int = 1): + if memory_address_bytes < 1 or memory_address_bytes > 4: + raise ValueError('invalid memory_address_bytes: {}'.format(memory_address_bytes)) + if memory_size_bytes < 1 or memory_size_bytes > 4: + raise ValueError('invalid memory_size_bytes: {}'.format(memory_size_bytes)) + data = bytes([memory_size_bytes << 4 | memory_address_bytes]) + + if memory_address >= 1 << (memory_address_bytes * 8): + raise ValueError('invalid memory_address: {}'.format(memory_address)) + data += struct.pack('!I', memory_address)[4 - memory_address_bytes:] + if memory_size >= 1 << (memory_size_bytes * 8): + raise ValueError('invalid memory_size: {}'.format(memory_size)) + data += struct.pack('!I', memory_size)[4 - memory_size_bytes:] + + resp = self._uds_request(SERVICE_TYPE.READ_MEMORY_BY_ADDRESS, subfunction=None, data=data) + return resp + + def read_scaling_data_by_identifier(self, data_identifier_type: DATA_IDENTIFIER_TYPE): + data = struct.pack('!H', data_identifier_type) + resp = self._uds_request(SERVICE_TYPE.READ_SCALING_DATA_BY_IDENTIFIER, subfunction=None, data=data) + resp_id = struct.unpack('!H', resp[0:2])[0] if len(resp) >= 2 else None + if resp_id != data_identifier_type: + raise ValueError('invalid response data identifier: {}'.format(hex(resp_id))) + return resp[2:] # TODO: parse the response + + def read_data_by_periodic_identifier(self, transmission_mode_type: TRANSMISSION_MODE_TYPE, periodic_data_identifier: int): + # TODO: support list of identifiers + data = bytes([transmission_mode_type, periodic_data_identifier]) + self._uds_request(SERVICE_TYPE.READ_DATA_BY_PERIODIC_IDENTIFIER, subfunction=None, data=data) + + def dynamically_define_data_identifier(self, dynamic_definition_type: DYNAMIC_DEFINITION_TYPE, dynamic_data_identifier: int, + source_definitions: List[DynamicSourceDefinition], memory_address_bytes: int = 4, memory_size_bytes: int = 1): + if memory_address_bytes < 1 or memory_address_bytes > 4: + raise ValueError('invalid memory_address_bytes: {}'.format(memory_address_bytes)) + if memory_size_bytes < 1 or memory_size_bytes > 4: + raise ValueError('invalid memory_size_bytes: {}'.format(memory_size_bytes)) + + data = struct.pack('!H', dynamic_data_identifier) + if dynamic_definition_type == DYNAMIC_DEFINITION_TYPE.DEFINE_BY_IDENTIFIER: + for s in source_definitions: + data += struct.pack('!H', s.data_identifier) + bytes([s.position, s.memory_size]) + elif dynamic_definition_type == DYNAMIC_DEFINITION_TYPE.DEFINE_BY_MEMORY_ADDRESS: + data += bytes([memory_size_bytes << 4 | memory_address_bytes]) + for s in source_definitions: + if s.memory_address >= 1 << (memory_address_bytes * 8): + raise ValueError('invalid memory_address: {}'.format(s.memory_address)) + data += struct.pack('!I', s.memory_address)[4 - memory_address_bytes:] + if s.memory_size >= 1 << (memory_size_bytes * 8): + raise ValueError('invalid memory_size: {}'.format(s.memory_size)) + data += struct.pack('!I', s.memory_size)[4 - memory_size_bytes:] + elif dynamic_definition_type == DYNAMIC_DEFINITION_TYPE.CLEAR_DYNAMICALLY_DEFINED_DATA_IDENTIFIER: + pass + else: + raise ValueError('invalid dynamic identifier type: {}'.format(hex(dynamic_definition_type))) + self._uds_request(SERVICE_TYPE.DYNAMICALLY_DEFINE_DATA_IDENTIFIER, subfunction=dynamic_definition_type, data=data) + + def write_data_by_identifier(self, data_identifier_type: DATA_IDENTIFIER_TYPE, data_record: bytes): + data = struct.pack('!H', data_identifier_type) + data_record + resp = self._uds_request(SERVICE_TYPE.WRITE_DATA_BY_IDENTIFIER, subfunction=None, data=data) + resp_id = struct.unpack('!H', resp[0:2])[0] if len(resp) >= 2 else None + if resp_id != data_identifier_type: + raise ValueError('invalid response data identifier: {}'.format(hex(resp_id))) + + def write_memory_by_address(self, memory_address: int, memory_size: int, data_record: bytes, memory_address_bytes: int = 4, memory_size_bytes: int = 1): + if memory_address_bytes < 1 or memory_address_bytes > 4: + raise ValueError('invalid memory_address_bytes: {}'.format(memory_address_bytes)) + if memory_size_bytes < 1 or memory_size_bytes > 4: + raise ValueError('invalid memory_size_bytes: {}'.format(memory_size_bytes)) + data = bytes([memory_size_bytes << 4 | memory_address_bytes]) + + if memory_address >= 1 << (memory_address_bytes * 8): + raise ValueError('invalid memory_address: {}'.format(memory_address)) + data += struct.pack('!I', memory_address)[4 - memory_address_bytes:] + if memory_size >= 1 << (memory_size_bytes * 8): + raise ValueError('invalid memory_size: {}'.format(memory_size)) + data += struct.pack('!I', memory_size)[4 - memory_size_bytes:] + + data += data_record + self._uds_request(SERVICE_TYPE.WRITE_MEMORY_BY_ADDRESS, subfunction=0x00, data=data) + + def clear_diagnostic_information(self, dtc_group_type: DTC_GROUP_TYPE): + data = struct.pack('!I', dtc_group_type)[1:] # 3 bytes + self._uds_request(SERVICE_TYPE.CLEAR_DIAGNOSTIC_INFORMATION, subfunction=None, data=data) + + def read_dtc_information(self, dtc_report_type: DTC_REPORT_TYPE, dtc_status_mask_type: DTC_STATUS_MASK_TYPE = DTC_STATUS_MASK_TYPE.ALL, + dtc_severity_mask_type: DTC_SEVERITY_MASK_TYPE = DTC_SEVERITY_MASK_TYPE.ALL, dtc_mask_record: int = 0xFFFFFF, + dtc_snapshot_record_num: int = 0xFF, dtc_extended_record_num: int = 0xFF): + data = b'' + # dtc_status_mask_type + if dtc_report_type == DTC_REPORT_TYPE.NUMBER_OF_DTC_BY_STATUS_MASK or \ + dtc_report_type == DTC_REPORT_TYPE.DTC_BY_STATUS_MASK or \ + dtc_report_type == DTC_REPORT_TYPE.MIRROR_MEMORY_DTC_BY_STATUS_MASK or \ + dtc_report_type == DTC_REPORT_TYPE.NUMBER_OF_MIRROR_MEMORY_DTC_BY_STATUS_MASK or \ + dtc_report_type == DTC_REPORT_TYPE.NUMBER_OF_EMISSIONS_RELATED_OBD_DTC_BY_STATUS_MASK or \ + dtc_report_type == DTC_REPORT_TYPE.EMISSIONS_RELATED_OBD_DTC_BY_STATUS_MASK: + data += bytes([dtc_status_mask_type]) + # dtc_mask_record + if dtc_report_type == DTC_REPORT_TYPE.DTC_SNAPSHOT_IDENTIFICATION or \ + dtc_report_type == DTC_REPORT_TYPE.DTC_SNAPSHOT_RECORD_BY_DTC_NUMBER or \ + dtc_report_type == DTC_REPORT_TYPE.DTC_EXTENDED_DATA_RECORD_BY_DTC_NUMBER or \ + dtc_report_type == DTC_REPORT_TYPE.MIRROR_MEMORY_DTC_EXTENDED_DATA_RECORD_BY_DTC_NUMBER or \ + dtc_report_type == DTC_REPORT_TYPE.SEVERITY_INFORMATION_OF_DTC: + data += struct.pack('!I', dtc_mask_record)[1:] # 3 bytes + # dtc_snapshot_record_num + if dtc_report_type == DTC_REPORT_TYPE.DTC_SNAPSHOT_IDENTIFICATION or \ + dtc_report_type == DTC_REPORT_TYPE.DTC_SNAPSHOT_RECORD_BY_DTC_NUMBER or \ + dtc_report_type == DTC_REPORT_TYPE.DTC_SNAPSHOT_RECORD_BY_RECORD_NUMBER: + data += bytes([dtc_snapshot_record_num]) + # dtc_extended_record_num + if dtc_report_type == DTC_REPORT_TYPE.DTC_EXTENDED_DATA_RECORD_BY_DTC_NUMBER or \ + dtc_report_type == DTC_REPORT_TYPE.MIRROR_MEMORY_DTC_EXTENDED_DATA_RECORD_BY_DTC_NUMBER: + data += bytes([dtc_extended_record_num]) + # dtc_severity_mask_type + if dtc_report_type == DTC_REPORT_TYPE.NUMBER_OF_DTC_BY_SEVERITY_MASK_RECORD or \ + dtc_report_type == DTC_REPORT_TYPE.DTC_BY_SEVERITY_MASK_RECORD: + data += bytes([dtc_severity_mask_type, dtc_status_mask_type]) + + resp = self._uds_request(SERVICE_TYPE.READ_DTC_INFORMATION, subfunction=dtc_report_type, data=data) + + # TODO: parse response + return resp + + def input_output_control_by_identifier(self, data_identifier_type: DATA_IDENTIFIER_TYPE, control_parameter_type: CONTROL_PARAMETER_TYPE, + control_option_record: bytes, control_enable_mask_record: bytes = b''): + data = struct.pack('!H', data_identifier_type) + bytes([control_parameter_type]) + control_option_record + control_enable_mask_record + resp = self._uds_request(SERVICE_TYPE.INPUT_OUTPUT_CONTROL_BY_IDENTIFIER, subfunction=None, data=data) + resp_id = struct.unpack('!H', resp[0:2])[0] if len(resp) >= 2 else None + if resp_id != data_identifier_type: + raise ValueError('invalid response data identifier: {}'.format(hex(resp_id))) + return resp[2:] + + def routine_control(self, routine_control_type: ROUTINE_CONTROL_TYPE, routine_identifier_type: ROUTINE_IDENTIFIER_TYPE, routine_option_record: bytes = b''): + data = struct.pack('!H', routine_identifier_type) + routine_option_record + resp = self._uds_request(SERVICE_TYPE.ROUTINE_CONTROL, subfunction=routine_control_type, data=data) + resp_id = struct.unpack('!H', resp[0:2])[0] if len(resp) >= 2 else None + if resp_id != routine_identifier_type: + raise ValueError('invalid response routine identifier: {}'.format(hex(resp_id))) + return resp[2:] + + def request_download(self, memory_address: int, memory_size: int, memory_address_bytes: int = 4, memory_size_bytes: int = 4, data_format: int = 0x00): + data = bytes([data_format]) + + if memory_address_bytes < 1 or memory_address_bytes > 4: + raise ValueError('invalid memory_address_bytes: {}'.format(memory_address_bytes)) + if memory_size_bytes < 1 or memory_size_bytes > 4: + raise ValueError('invalid memory_size_bytes: {}'.format(memory_size_bytes)) + data += bytes([memory_size_bytes << 4 | memory_address_bytes]) + + if memory_address >= 1 << (memory_address_bytes * 8): + raise ValueError('invalid memory_address: {}'.format(memory_address)) + data += struct.pack('!I', memory_address)[4 - memory_address_bytes:] + if memory_size >= 1 << (memory_size_bytes * 8): + raise ValueError('invalid memory_size: {}'.format(memory_size)) + data += struct.pack('!I', memory_size)[4 - memory_size_bytes:] + + resp = self._uds_request(SERVICE_TYPE.REQUEST_DOWNLOAD, subfunction=None, data=data) + max_num_bytes_len = resp[0] >> 4 if len(resp) > 0 else 0 + if max_num_bytes_len >= 1 and max_num_bytes_len <= 4: + max_num_bytes = struct.unpack('!I', (b"\x00" * (4 - max_num_bytes_len)) + resp[1:max_num_bytes_len + 1])[0] + else: + raise ValueError('invalid max_num_bytes_len: {}'.format(max_num_bytes_len)) + + return max_num_bytes # max number of bytes per transfer data request + + def request_upload(self, memory_address: int, memory_size: int, memory_address_bytes: int = 4, memory_size_bytes: int = 4, data_format: int = 0x00): + data = bytes([data_format]) + + if memory_address_bytes < 1 or memory_address_bytes > 4: + raise ValueError('invalid memory_address_bytes: {}'.format(memory_address_bytes)) + if memory_size_bytes < 1 or memory_size_bytes > 4: + raise ValueError('invalid memory_size_bytes: {}'.format(memory_size_bytes)) + data += bytes([memory_size_bytes << 4 | memory_address_bytes]) + + if memory_address >= 1 << (memory_address_bytes * 8): + raise ValueError('invalid memory_address: {}'.format(memory_address)) + data += struct.pack('!I', memory_address)[4 - memory_address_bytes:] + if memory_size >= 1 << (memory_size_bytes * 8): + raise ValueError('invalid memory_size: {}'.format(memory_size)) + data += struct.pack('!I', memory_size)[4 - memory_size_bytes:] + + resp = self._uds_request(SERVICE_TYPE.REQUEST_UPLOAD, subfunction=None, data=data) + max_num_bytes_len = resp[0] >> 4 if len(resp) > 0 else 0 + if max_num_bytes_len >= 1 and max_num_bytes_len <= 4: + max_num_bytes = struct.unpack('!I', (b"\x00" * (4 - max_num_bytes_len)) + resp[1:max_num_bytes_len + 1])[0] + else: + raise ValueError('invalid max_num_bytes_len: {}'.format(max_num_bytes_len)) + + return max_num_bytes # max number of bytes per transfer data request + + def transfer_data(self, block_sequence_count: int, data: bytes = b''): + data = bytes([block_sequence_count]) + data + resp = self._uds_request(SERVICE_TYPE.TRANSFER_DATA, subfunction=None, data=data) + resp_id = resp[0] if len(resp) > 0 else None + if resp_id != block_sequence_count: + raise ValueError('invalid block_sequence_count: {}'.format(resp_id)) + return resp[1:] + + def request_transfer_exit(self): + self._uds_request(SERVICE_TYPE.REQUEST_TRANSFER_EXIT, subfunction=None) diff --git a/panda/python/update.py b/panda/python/update.py index ce730e4919119e..f8e32804449272 100755 --- a/panda/python/update.py +++ b/panda/python/update.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import os import time @@ -12,7 +12,6 @@ def ensure_st_up_to_date(): panda = None panda_dfu = None - should_flash_recover = False while 1: # break on normal mode Panda @@ -27,7 +26,7 @@ def ensure_st_up_to_date(): panda_dfu = PandaDFU(panda_dfu[0]) panda_dfu.recover() - print "waiting for board..." + print("waiting for board...") time.sleep(1) if panda.bootstub or not panda.get_version().startswith(repo_version): @@ -43,4 +42,3 @@ def ensure_st_up_to_date(): if __name__ == "__main__": ensure_st_up_to_date() - diff --git a/panda/release/.gitignore b/panda/release/.gitignore deleted file mode 100644 index c4c4ffc6aa41a8..00000000000000 --- a/panda/release/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.zip diff --git a/panda/release/make_release.sh b/panda/release/make_release.sh deleted file mode 100755 index 7be994c82c8813..00000000000000 --- a/panda/release/make_release.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -if [ ! -d "../../pandaextra" ]; then - echo "No release cert found, cannot build release." - echo "You probably aren't looking to do this anyway." - exit -fi - -export RELEASE=1 - -# make ST + bootstub -pushd . -cd ../board -make clean -make obj/panda.bin -make obj/bootstub.panda.bin -popd - -# make ESP -pushd . -cd ../boardesp -make clean -make user1.bin -make user2.bin -popd - -# make release -mkdir obj -make -f ../common/version.mk -make obj/gitversion.h -RELEASE_NAME=$(python -c "import sys;sys.stdout.write(open('obj/gitversion.h').read().split('\"')[1])") -echo -en $RELEASE_NAME > /tmp/version -rm -rf obj - -# make zip file -pushd . -cd .. -zip -j release/panda-$RELEASE_NAME.zip ~/one/panda/board/obj/bootstub.panda.bin ~/one/panda/board/obj/panda.bin ~/one/panda/boardesp/user?.bin ~/one/panda/boardesp/esp-open-sdk/ESP8266_NONOS_SDK_V1.5.4_16_05_20/bin/boot_v1.5.bin /tmp/version -popd - diff --git a/panda/release/ota_release.sh b/panda/release/ota_release.sh deleted file mode 100755 index 541a196ba7e408..00000000000000 --- a/panda/release/ota_release.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -mkdir -p /tmp/panda_firmware -unzip -o $1 -d /tmp/panda_firmware - -curl http://192.168.0.10/ - -echo "flashing user1" -curl http://192.168.0.10/espupdate1 --upload-file /tmp/panda_firmware/user1.bin -echo "flashing user2" -curl http://192.168.0.10/espupdate2 --upload-file /tmp/panda_firmware/user2.bin -echo "waiting 10s for reboot" -sleep 10 -echo "flashing st" -curl http://192.168.0.10/stupdate --upload-file /tmp/panda_firmware/panda.bin -sleep 2 -curl http://192.168.0.10/ -echo "done" - diff --git a/panda/requirements.txt b/panda/requirements.txt deleted file mode 100644 index ad6b4c76e054f3..00000000000000 --- a/panda/requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -libusb1 == 1.6.6 -hexdump -pycrypto -tqdm -nose -parameterized -requests diff --git a/panda/run_automated_tests.sh b/panda/run_automated_tests.sh deleted file mode 100755 index 583d6c1ed7599a..00000000000000 --- a/panda/run_automated_tests.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -e -TEST_FILENAME=${TEST_FILENAME:-nosetests.xml} -if [ -f "/EON" ]; then - TESTSUITE_NAME="Panda_Test-EON" -else - TESTSUITE_NAME="Panda_Test-DEV" -fi - -if [ ! -z "${SKIPWIFI}" ] || [ -f "/EON" ]; then - TEST_SCRIPTS=$(ls tests/automated/$1*.py | grep -v wifi) -else - TEST_SCRIPTS=$(ls tests/automated/$1*.py) -fi - -IFS=$'\n' -for NAME in $(nmcli --fields NAME con show | grep panda | awk '{$1=$1};1') -do - nmcli connection delete "$NAME" -done - -PYTHONPATH="." python $(which nosetests) -v --with-xunit --xunit-file=./$TEST_FILENAME --xunit-testsuite-name=$TESTSUITE_NAME -s $TEST_SCRIPTS diff --git a/panda/setup.cfg b/panda/setup.cfg deleted file mode 100644 index 3480374bc2f25b..00000000000000 --- a/panda/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[bdist_wheel] -universal=1 \ No newline at end of file diff --git a/panda/setup.py b/panda/setup.py deleted file mode 100644 index 2acd9b9e1654df..00000000000000 --- a/panda/setup.py +++ /dev/null @@ -1,65 +0,0 @@ -#-*- coding: utf-8 -*- - -""" - Panda CAN Controller Dongle - ~~~~~ - - Setup - ````` - - $ pip install . # or python setup.py install -""" - -import codecs -import os -import re -from setuptools import setup, Extension - -here = os.path.abspath(os.path.dirname(__file__)) - -def read(*parts): - """Taken from pypa pip setup.py: - intentionally *not* adding an encoding option to open, See: - https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690 - """ - return codecs.open(os.path.join(here, *parts), 'r').read() - - -def find_version(*file_paths): - version_file = read(*file_paths) - version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", - version_file, re.M) - if version_match: - return version_match.group(1) - raise RuntimeError("Unable to find version string.") - -setup( - name='pandacan', - version=find_version("python", "__init__.py"), - url='https://github.com/commaai/panda', - author='comma.ai', - author_email='', - packages=[ - 'panda', - ], - package_dir = {'panda': 'python'}, - platforms='any', - license='MIT', - install_requires=[ - 'libusb1 == 1.6.6', - 'hexdump >= 3.3', - 'pycrypto >= 2.6.1', - 'tqdm >= 4.14.0', - 'requests' - ], - ext_modules = [], - description="Code powering the comma.ai panda", - long_description='See https://github.com/commaai/panda', - classifiers=[ - 'Development Status :: 2 - Pre-Alpha', - "Natural Language :: English", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 3", - "Topic :: System :: Hardware", - ], -) diff --git a/panda/tests/all_wifi_test.py b/panda/tests/all_wifi_test.py deleted file mode 100755 index 4e9d3a5318a16c..00000000000000 --- a/panda/tests/all_wifi_test.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/python -import requests -import json -from automated.helpers import _connect_wifi -from panda import Panda -from nose.tools import assert_equal - -if __name__ == "__main__": - print("Fetching latest firmware from github.com/commaai/panda-artifacts") - r = requests.get("https://raw.githubusercontent.com/commaai/panda-artifacts/master/latest.json") - latest_version = json.loads(r.text)['version'] - - for p in Panda.list(): - dongle_id, pw = Panda(p).get_serial() - print dongle_id, pw - assert(dongle_id.isalnum()) - _connect_wifi(dongle_id, pw) - - r = requests.get("http://192.168.0.10/") - print r.text - wifi_dongle_id = r.text.split("ssid: panda-")[1].split("
")[0] - st_version = r.text.split("st version:")[1].strip().split("
")[0] - esp_version = r.text.split("esp version:")[1].strip().split("
")[0] - - assert_equal(str(dongle_id), wifi_dongle_id) - assert_equal(latest_version, st_version) - assert_equal(latest_version, esp_version) - - diff --git a/panda/tests/automated/0_builds.py b/panda/tests/automated/0_builds.py deleted file mode 100644 index df4186cce4e6f6..00000000000000 --- a/panda/tests/automated/0_builds.py +++ /dev/null @@ -1,9 +0,0 @@ -import os -from panda import build_st - -def test_build_panda(): - build_st("obj/panda.bin") - -def test_build_bootstub_panda(): - build_st("obj/bootstub.panda.bin") - diff --git a/panda/tests/automated/1_program.py b/panda/tests/automated/1_program.py deleted file mode 100644 index 1e0beb8ae52425..00000000000000 --- a/panda/tests/automated/1_program.py +++ /dev/null @@ -1,15 +0,0 @@ -import os -from panda import Panda -from helpers import panda_color_to_serial, test_white_and_grey - -@test_white_and_grey -@panda_color_to_serial -def test_recover(serial=None): - p = Panda(serial=serial) - assert p.recover(timeout=30) - -@test_white_and_grey -@panda_color_to_serial -def test_flash(serial=None): - p = Panda(serial=serial) - p.flash() diff --git a/panda/tests/automated/2_usb_to_can.py b/panda/tests/automated/2_usb_to_can.py deleted file mode 100644 index 9e3e07aa490daa..00000000000000 --- a/panda/tests/automated/2_usb_to_can.py +++ /dev/null @@ -1,232 +0,0 @@ -from __future__ import print_function -import os -import sys -import time -from panda import Panda -from nose.tools import assert_equal, assert_less, assert_greater -from helpers import time_many_sends, connect_wo_esp, test_white_and_grey, panda_color_to_serial - -SPEED_NORMAL = 500 -SPEED_GMLAN = 33.3 - -@test_white_and_grey -@panda_color_to_serial -def test_can_loopback(serial=None): - p = connect_wo_esp(serial) - - # enable output mode - p.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - - # enable CAN loopback mode - p.set_can_loopback(True) - - if p.legacy: - busses = [0,1] - else: - busses = [0,1,2] - - for bus in busses: - # send heartbeat - p.send_heartbeat() - - # set bus 0 speed to 250 - p.set_can_speed_kbps(bus, 250) - - # send a message on bus 0 - p.can_send(0x1aa, "message", bus) - - # confirm receive both on loopback and send receipt - time.sleep(0.05) - r = p.can_recv() - sr = filter(lambda x: x[3] == 0x80 | bus, r) - lb = filter(lambda x: x[3] == bus, r) - assert len(sr) == 1 - assert len(lb) == 1 - - # confirm data is correct - assert 0x1aa == sr[0][0] == lb[0][0] - assert "message" == sr[0][2] == lb[0][2] - -@test_white_and_grey -@panda_color_to_serial -def test_safety_nooutput(serial=None): - p = connect_wo_esp(serial) - - # enable output mode - p.set_safety_mode(Panda.SAFETY_NOOUTPUT) - - # send heartbeat - p.send_heartbeat() - - # enable CAN loopback mode - p.set_can_loopback(True) - - # send a message on bus 0 - p.can_send(0x1aa, "message", 0) - - # confirm receive nothing - time.sleep(0.05) - r = p.can_recv() - assert len(r) == 0 - -@test_white_and_grey -@panda_color_to_serial -def test_reliability(serial=None): - p = connect_wo_esp(serial) - - LOOP_COUNT = 100 - MSG_COUNT = 100 - - # enable output mode - p.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - p.set_can_loopback(True) - p.set_can_speed_kbps(0, 1000) - - # send heartbeat - p.send_heartbeat() - - addrs = range(100, 100+MSG_COUNT) - ts = [(j, 0, "\xaa"*8, 0) for j in addrs] - - # 100 loops - for i in range(LOOP_COUNT): - # send heartbeat - p.send_heartbeat() - - st = time.time() - - p.can_send_many(ts) - - r = [] - while len(r) < 200 and (time.time() - st) < 0.5: - r.extend(p.can_recv()) - - sent_echo = filter(lambda x: x[3] == 0x80, r) - loopback_resp = filter(lambda x: x[3] == 0, r) - - assert_equal(sorted(map(lambda x: x[0], loopback_resp)), addrs) - assert_equal(sorted(map(lambda x: x[0], sent_echo)), addrs) - assert_equal(len(r), 200) - - # take sub 20ms - et = (time.time()-st)*1000.0 - assert_less(et, 20) - - sys.stdout.write("P") - sys.stdout.flush() - -@test_white_and_grey -@panda_color_to_serial -def test_throughput(serial=None): - p = connect_wo_esp(serial) - - # enable output mode - p.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - - # send heartbeat - p.send_heartbeat() - - # enable CAN loopback mode - p.set_can_loopback(True) - - for speed in [100,250,500,750,1000]: - # set bus 0 speed to speed - p.set_can_speed_kbps(0, speed) - time.sleep(0.05) - - # send heartbeat - p.send_heartbeat() - - comp_kbps = time_many_sends(p, 0) - - # bit count from https://en.wikipedia.org/wiki/CAN_bus - saturation_pct = (comp_kbps/speed) * 100.0 - assert_greater(saturation_pct, 80) - assert_less(saturation_pct, 100) - - print("loopback 100 messages at speed %d, comp speed is %.2f, percent %.2f" % (speed, comp_kbps, saturation_pct)) - -@test_white_and_grey -@panda_color_to_serial -def test_gmlan(serial=None): - p = connect_wo_esp(serial) - - if p.legacy: - return - - # enable output mode - p.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - - # send heartbeat - p.send_heartbeat() - - # enable CAN loopback mode - p.set_can_loopback(True) - - p.set_can_speed_kbps(1, SPEED_NORMAL) - p.set_can_speed_kbps(2, SPEED_NORMAL) - p.set_can_speed_kbps(3, SPEED_GMLAN) - - # set gmlan on CAN2 - for bus in [Panda.GMLAN_CAN2, Panda.GMLAN_CAN3, Panda.GMLAN_CAN2, Panda.GMLAN_CAN3]: - # send heartbeat - p.send_heartbeat() - - p.set_gmlan(bus) - comp_kbps_gmlan = time_many_sends(p, 3) - assert_greater(comp_kbps_gmlan, 0.8 * SPEED_GMLAN) - assert_less(comp_kbps_gmlan, 1.0 * SPEED_GMLAN) - - p.set_gmlan(None) - comp_kbps_normal = time_many_sends(p, bus) - assert_greater(comp_kbps_normal, 0.8 * SPEED_NORMAL) - assert_less(comp_kbps_normal, 1.0 * SPEED_NORMAL) - - print("%d: %.2f kbps vs %.2f kbps" % (bus, comp_kbps_gmlan, comp_kbps_normal)) - -@test_white_and_grey -@panda_color_to_serial -def test_gmlan_bad_toggle(serial=None): - p = connect_wo_esp(serial) - - if p.legacy: - return - - # enable output mode - p.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - - # send heartbeat - p.send_heartbeat() - - # enable CAN loopback mode - p.set_can_loopback(True) - - # GMLAN_CAN2 - for bus in [Panda.GMLAN_CAN2, Panda.GMLAN_CAN3]: - # send heartbeat - p.send_heartbeat() - - p.set_gmlan(bus) - comp_kbps_gmlan = time_many_sends(p, 3) - assert_greater(comp_kbps_gmlan, 0.6 * SPEED_GMLAN) - assert_less(comp_kbps_gmlan, 1.0 * SPEED_GMLAN) - - # normal - for bus in [Panda.GMLAN_CAN2, Panda.GMLAN_CAN3]: - # send heartbeat - p.send_heartbeat() - - p.set_gmlan(None) - comp_kbps_normal = time_many_sends(p, bus) - assert_greater(comp_kbps_normal, 0.6 * SPEED_NORMAL) - assert_less(comp_kbps_normal, 1.0 * SPEED_NORMAL) - - -# this will fail if you have hardware serial connected -@test_white_and_grey -@panda_color_to_serial -def test_serial_debug(serial=None): - p = connect_wo_esp(serial) - junk = p.serial_read(Panda.SERIAL_DEBUG) - p.call_control_api(0xc0) - assert(p.serial_read(Panda.SERIAL_DEBUG).startswith("can ")) diff --git a/panda/tests/automated/3_wifi.py b/panda/tests/automated/3_wifi.py deleted file mode 100644 index 1251663ba5838d..00000000000000 --- a/panda/tests/automated/3_wifi.py +++ /dev/null @@ -1,60 +0,0 @@ -from __future__ import print_function -import os -import time -from panda import Panda -from helpers import connect_wifi, test_white, test_white_and_grey, panda_color_to_serial -import requests - -@test_white_and_grey -@panda_color_to_serial -def test_get_serial(serial=None): - p = Panda(serial) - print(p.get_serial()) - -@test_white_and_grey -@panda_color_to_serial -def test_get_serial_in_flash_mode(serial=None): - p = Panda(serial) - p.reset(enter_bootstub=True) - assert(p.bootstub) - print(p.get_serial()) - p.reset() - -@test_white -@panda_color_to_serial -def test_connect_wifi(serial=None): - connect_wifi(serial) - -@test_white -@panda_color_to_serial -def test_flash_wifi(serial=None): - connect_wifi(serial) - assert Panda.flash_ota_wifi(release=False), "OTA Wifi Flash Failed" - connect_wifi(serial) - -@test_white -@panda_color_to_serial -def test_wifi_flash_st(serial=None): - connect_wifi(serial) - assert Panda.flash_ota_st(), "OTA ST Flash Failed" - connected = False - st = time.time() - while not connected and (time.time() - st) < 20: - try: - p = Panda(serial=serial) - p.get_serial() - connected = True - except: - time.sleep(1) - - if not connected: - assert False, "Panda failed to connect on USB after flashing" - -@test_white -@panda_color_to_serial -def test_webpage_fetch(serial=None): - connect_wifi(serial) - r = requests.get("http://192.168.0.10/") - print(r.text) - - assert "This is your comma.ai panda" in r.text diff --git a/panda/tests/automated/4_wifi_functionality.py b/panda/tests/automated/4_wifi_functionality.py deleted file mode 100644 index ab9bed70052e41..00000000000000 --- a/panda/tests/automated/4_wifi_functionality.py +++ /dev/null @@ -1,72 +0,0 @@ -from __future__ import print_function -import time -from panda import Panda -from helpers import time_many_sends, connect_wifi, test_white, panda_color_to_serial -from nose.tools import timed, assert_equal, assert_less, assert_greater - -@test_white -@panda_color_to_serial -def test_get_serial_wifi(serial=None): - connect_wifi(serial) - - p = Panda("WIFI") - print(p.get_serial()) - -@test_white -@panda_color_to_serial -def test_throughput(serial=None): - connect_wifi(serial) - p = Panda(serial) - - # enable output mode - p.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - - # send heartbeat - p.send_heartbeat() - - # enable CAN loopback mode - p.set_can_loopback(True) - - p = Panda("WIFI") - - for speed in [100,250,500,750,1000]: - # send heartbeat - p.send_heartbeat() - - # set bus 0 speed to speed - p.set_can_speed_kbps(0, speed) - time.sleep(0.1) - - comp_kbps = time_many_sends(p, 0) - - # bit count from https://en.wikipedia.org/wiki/CAN_bus - saturation_pct = (comp_kbps/speed) * 100.0 - #assert_greater(saturation_pct, 80) - #assert_less(saturation_pct, 100) - - print("WIFI loopback 100 messages at speed %d, comp speed is %.2f, percent %.2f" % (speed, comp_kbps, saturation_pct)) - -@test_white -@panda_color_to_serial -def test_recv_only(serial=None): - connect_wifi(serial) - p = Panda(serial) - p.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - - # send heartbeat - p.send_heartbeat() - - p.set_can_loopback(True) - pwifi = Panda("WIFI") - - # TODO: msg_count=1000 drops packets, is this fixable? - for msg_count in [10,100,200]: - # send heartbeat - p.send_heartbeat() - - speed = 500 - p.set_can_speed_kbps(0, speed) - comp_kbps = time_many_sends(p, 0, pwifi, msg_count) - saturation_pct = (comp_kbps/speed) * 100.0 - - print("HT WIFI loopback %d messages at speed %d, comp speed is %.2f, percent %.2f" % (msg_count, speed, comp_kbps, saturation_pct)) diff --git a/panda/tests/automated/5_wifi_udp.py b/panda/tests/automated/5_wifi_udp.py deleted file mode 100644 index d55baa659aa162..00000000000000 --- a/panda/tests/automated/5_wifi_udp.py +++ /dev/null @@ -1,66 +0,0 @@ -from __future__ import print_function -import sys -import time -from helpers import time_many_sends, connect_wifi, test_white, panda_color_to_serial -from panda import Panda, PandaWifiStreaming -from nose.tools import timed, assert_equal, assert_less, assert_greater - -@test_white -@panda_color_to_serial -def test_udp_doesnt_drop(serial=None): - connect_wifi(serial) - - p = Panda(serial) - p.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - p.set_can_loopback(True) - - pwifi = PandaWifiStreaming() - while 1: - if len(pwifi.can_recv()) == 0: - break - - for msg_count in [1, 100]: - saturation_pcts = [] - for i in range({1: 0x80, 100: 0x20}[msg_count]): - pwifi.kick() - - speed = 500 - p.set_can_speed_kbps(0, speed) - comp_kbps = time_many_sends(p, 0, pwifi, msg_count=msg_count, msg_id=0x100+i) - saturation_pct = (comp_kbps/speed) * 100.0 - - if msg_count == 1: - sys.stdout.write(".") - sys.stdout.flush() - else: - print("UDP WIFI loopback %d messages at speed %d, comp speed is %.2f, percent %.2f" % (msg_count, speed, comp_kbps, saturation_pct)) - assert_greater(saturation_pct, 20) #sometimes the wifi can be slow... - assert_less(saturation_pct, 100) - saturation_pcts.append(saturation_pct) - if len(saturation_pcts) > 0: - assert_greater(sum(saturation_pcts)/len(saturation_pcts), 60) - - time.sleep(5) - usb_ok_cnt = 0 - REQ_USB_OK_CNT = 500 - st = time.time() - msg_id = 0x1bb - bus = 0 - last_missing_msg = 0 - while usb_ok_cnt < REQ_USB_OK_CNT and (time.time() - st) < 40: - p.can_send(msg_id, "message", bus) - time.sleep(0.01) - r = [1] - missing = True - while len(r) > 0: - r = p.can_recv() - r = filter(lambda x: x[3] == bus and x[0] == msg_id, r) - if len(r) > 0: - missing = False - usb_ok_cnt += len(r) - if missing: - last_missing_msg = time.time() - et = time.time() - st - last_missing_msg = last_missing_msg - st - print("waited {} for panda to recv can on usb, {} msgs, last missing at {}".format(et, usb_ok_cnt, last_missing_msg)) - assert usb_ok_cnt >= REQ_USB_OK_CNT, "Unable to recv can on USB after UDP" diff --git a/panda/tests/automated/6_two_panda.py b/panda/tests/automated/6_two_panda.py deleted file mode 100644 index 09cf1861f34d95..00000000000000 --- a/panda/tests/automated/6_two_panda.py +++ /dev/null @@ -1,139 +0,0 @@ -from __future__ import print_function -import time -from panda import Panda -from nose.tools import assert_equal, assert_less, assert_greater -from helpers import time_many_sends, test_two_panda, panda_color_to_serial - -@test_two_panda -@panda_color_to_serial -def test_send_recv(serial_sender=None, serial_reciever=None): - p_send = Panda(serial_sender) - p_recv = Panda(serial_reciever) - - p_send.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - p_send.set_can_loopback(False) - - # send heartbeat - p_send.send_heartbeat() - - p_recv.set_can_loopback(False) - - assert not p_send.legacy - assert not p_recv.legacy - - p_send.can_send_many([(0x1ba, 0, "message", 0)]*2) - time.sleep(0.05) - p_recv.can_recv() - p_send.can_recv() - - busses = [0,1,2] - - for bus in busses: - for speed in [100, 250, 500, 750, 1000]: - # send heartbeat - p_send.send_heartbeat() - - p_send.set_can_speed_kbps(bus, speed) - p_recv.set_can_speed_kbps(bus, speed) - time.sleep(0.05) - - comp_kbps = time_many_sends(p_send, bus, p_recv, two_pandas=True) - - saturation_pct = (comp_kbps/speed) * 100.0 - assert_greater(saturation_pct, 80) - assert_less(saturation_pct, 100) - - print("two pandas bus {}, 100 messages at speed {:4d}, comp speed is {:7.2f}, percent {:6.2f}".format(bus, speed, comp_kbps, saturation_pct)) - -@test_two_panda -@panda_color_to_serial -def test_latency(serial_sender=None, serial_reciever=None): - p_send = Panda(serial_sender) - p_recv = Panda(serial_reciever) - - # send heartbeat - p_send.send_heartbeat() - p_recv.send_heartbeat() - - p_send.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - p_send.set_can_loopback(False) - - p_recv.set_can_loopback(False) - - assert not p_send.legacy - assert not p_recv.legacy - - p_send.set_can_speed_kbps(0, 100) - p_recv.set_can_speed_kbps(0, 100) - time.sleep(0.05) - - p_send.can_send_many([(0x1ba, 0, "testmsg", 0)]*10) - time.sleep(0.05) - p_recv.can_recv() - p_send.can_recv() - - # send heartbeat - p_send.send_heartbeat() - p_recv.send_heartbeat() - - busses = [0,1,2] - - for bus in busses: - for speed in [100, 250, 500, 750, 1000]: - # send heartbeat - p_send.send_heartbeat() - p_recv.send_heartbeat() - - p_send.set_can_speed_kbps(bus, speed) - p_recv.set_can_speed_kbps(bus, speed) - time.sleep(0.1) - #clear can buffers - r = [1] - while len(r) > 0: - r = p_send.can_recv() - r = [1] - while len(r) > 0: - r = p_recv.can_recv() - time.sleep(0.05) - - latencies = [] - comp_kbps_list = [] - saturation_pcts = [] - - num_messages = 100 - - for i in range(num_messages): - st = time.time() - p_send.can_send(0x1ab, "message", bus) - r = [] - while len(r) < 1 and (time.time() - st) < 5: - r = p_recv.can_recv() - et = time.time() - r_echo = [] - while len(r_echo) < 1 and (time.time() - st) < 10: - r_echo = p_send.can_recv() - - if len(r) == 0 or len(r_echo) == 0: - print("r: {}, r_echo: {}".format(r, r_echo)) - - assert_equal(len(r),1) - assert_equal(len(r_echo),1) - - et = (et - st)*1000.0 - comp_kbps = (1+11+1+1+1+4+8*8+15+1+1+1+7) / et - latency = et - ((1+11+1+1+1+4+8*8+15+1+1+1+7) / speed) - - assert_less(latency, 5.0) - - saturation_pct = (comp_kbps/speed) * 100.0 - latencies.append(latency) - comp_kbps_list.append(comp_kbps) - saturation_pcts.append(saturation_pct) - - average_latency = sum(latencies)/num_messages - assert_less(average_latency, 1.0) - average_comp_kbps = sum(comp_kbps_list)/num_messages - average_saturation_pct = sum(saturation_pcts)/num_messages - - print("two pandas bus {}, {} message average at speed {:4d}, latency is {:5.3f}ms, comp speed is {:7.2f}, percent {:6.2f}"\ - .format(bus, num_messages, speed, average_latency, average_comp_kbps, average_saturation_pct)) diff --git a/panda/tests/automated/helpers.py b/panda/tests/automated/helpers.py deleted file mode 100644 index 9e92f56bfe4bcd..00000000000000 --- a/panda/tests/automated/helpers.py +++ /dev/null @@ -1,192 +0,0 @@ -import os -import sys -import time -import random -import subprocess -import requests -from functools import wraps -from panda import Panda -from nose.tools import timed, assert_equal, assert_less, assert_greater -from parameterized import parameterized, param - -test_white_and_grey = parameterized([param(panda_color="White"), - param(panda_color="Grey")]) -test_white = parameterized([param(panda_color="White")]) -test_grey = parameterized([param(panda_color="Grey")]) -test_two_panda = parameterized([param(panda_color=["Grey", "White"]), - param(panda_color=["White", "Grey"])]) - -_serials = {} -def get_panda_serial(is_grey=None): - global _serials - if is_grey not in _serials: - for serial in Panda.list(): - p = Panda(serial=serial) - if is_grey is None or p.is_grey() == is_grey: - _serials[is_grey] = serial - return serial - raise IOError("Panda not found. is_grey: {}".format(is_grey)) - else: - return _serials[is_grey] - -def connect_wo_esp(serial=None): - # connect to the panda - p = Panda(serial=serial) - - # power down the ESP - p.set_esp_power(False) - - # clear old junk - while len(p.can_recv()) > 0: - pass - - return p - -def connect_wifi(serial=None): - p = Panda(serial=serial) - p.set_esp_power(True) - dongle_id, pw = p.get_serial() - assert(dongle_id.isalnum()) - _connect_wifi(dongle_id, pw) - -FNULL = open(os.devnull, 'w') -def _connect_wifi(dongle_id, pw, insecure_okay=False): - ssid = str("panda-" + dongle_id) - - r = subprocess.call(["ping", "-W", "4", "-c", "1", "192.168.0.10"], stdout=FNULL, stderr=subprocess.STDOUT) - if not r: - #Can already ping, try connecting on wifi - try: - p = Panda("WIFI") - p.get_serial() - print("Already connected") - return - except: - pass - - print("WIFI: connecting to %s" % ssid) - - while 1: - if sys.platform == "darwin": - os.system("networksetup -setairportnetwork en0 %s %s" % (ssid, pw)) - else: - wlan_interface = subprocess.check_output(["sh", "-c", "iw dev | awk '/Interface/ {print $2}'"]).strip() - cnt = 0 - MAX_TRIES = 10 - while cnt < MAX_TRIES: - print("WIFI: scanning %d" % cnt) - os.system("iwlist %s scanning > /dev/null" % wlan_interface) - os.system("nmcli device wifi rescan") - wifi_scan = filter(lambda x: ssid in x, subprocess.check_output(["nmcli","dev", "wifi", "list"]).split("\n")) - if len(wifi_scan) != 0: - break - time.sleep(0.1) - # MAX_TRIES tries, ~10 seconds max - cnt += 1 - assert cnt < MAX_TRIES - if "-pair" in wifi_scan[0]: - os.system("nmcli d wifi connect %s-pair" % (ssid)) - connect_cnt = 0 - MAX_TRIES = 20 - while connect_cnt < MAX_TRIES: - connect_cnt += 1 - r = subprocess.call(["ping", "-W", "4", "-c", "1", "192.168.0.10"], stdout=FNULL, stderr=subprocess.STDOUT) - if r: - print("Waiting for panda to ping...") - time.sleep(0.1) - else: - break - if insecure_okay: - break - # fetch webpage - print("connecting to insecure network to secure") - try: - r = requests.get("http://192.168.0.10/") - except requests.ConnectionError: - r = requests.get("http://192.168.0.10/") - assert r.status_code==200 - - print("securing") - try: - r = requests.get("http://192.168.0.10/secure", timeout=0.01) - except requests.exceptions.Timeout: - print("timeout http request to secure") - pass - else: - ret = os.system("nmcli d wifi connect %s password %s" % (ssid, pw)) - if os.WEXITSTATUS(ret) == 0: - #check ping too - ping_ok = False - connect_cnt = 0 - MAX_TRIES = 10 - while connect_cnt < MAX_TRIES: - connect_cnt += 1 - r = subprocess.call(["ping", "-W", "4", "-c", "1", "192.168.0.10"], stdout=FNULL, stderr=subprocess.STDOUT) - if r: - print("Waiting for panda to ping...") - time.sleep(0.1) - else: - ping_ok = True - break - if ping_ok: - break - - # TODO: confirm that it's connected to the right panda - -def time_many_sends(p, bus, precv=None, msg_count=100, msg_id=None, two_pandas=False): - if precv == None: - precv = p - if msg_id == None: - msg_id = random.randint(0x100, 0x200) - if p == precv and two_pandas: - raise ValueError("Cannot have two pandas that are the same panda") - - st = time.time() - p.can_send_many([(msg_id, 0, "\xaa"*8, bus)]*msg_count) - r = [] - r_echo = [] - r_len_expected = msg_count if two_pandas else msg_count*2 - r_echo_len_exected = msg_count if two_pandas else 0 - - while len(r) < r_len_expected and (time.time() - st) < 5: - r.extend(precv.can_recv()) - et = time.time() - if two_pandas: - while len(r_echo) < r_echo_len_exected and (time.time() - st) < 10: - r_echo.extend(p.can_recv()) - - sent_echo = filter(lambda x: x[3] == 0x80 | bus and x[0] == msg_id, r) - sent_echo.extend(filter(lambda x: x[3] == 0x80 | bus and x[0] == msg_id, r_echo)) - resp = filter(lambda x: x[3] == bus and x[0] == msg_id, r) - - leftovers = filter(lambda x: (x[3] != 0x80 | bus and x[3] != bus) or x[0] != msg_id, r) - assert_equal(len(leftovers), 0) - - assert_equal(len(resp), msg_count) - assert_equal(len(sent_echo), msg_count) - - et = (et-st)*1000.0 - comp_kbps = (1+11+1+1+1+4+8*8+15+1+1+1+7)*msg_count / et - - return comp_kbps - - -def panda_color_to_serial(fn): - @wraps(fn) - def wrapper(panda_color=None, **kwargs): - pandas_is_grey = [] - if panda_color is not None: - if not isinstance(panda_color, list): - panda_color = [panda_color] - panda_color = [s.lower() for s in panda_color] - for p in panda_color: - if p is None: - pandas_is_grey.append(None) - elif p in ["grey", "gray"]: - pandas_is_grey.append(True) - elif p in ["white"]: - pandas_is_grey.append(False) - else: - raise ValueError("Invalid Panda Color {}".format(p)) - return fn(*[get_panda_serial(is_grey) for is_grey in pandas_is_grey], **kwargs) - return wrapper diff --git a/panda/tests/black_loopback_test.py b/panda/tests/black_loopback_test.py deleted file mode 100755 index 8683561a4da839..00000000000000 --- a/panda/tests/black_loopback_test.py +++ /dev/null @@ -1,139 +0,0 @@ -#!/usr/bin/env python - -# Loopback test between black panda (+ harness and power) and white/grey panda -# Tests all buses, including OBD CAN, which is on the same bus as CAN0 in this test. -# To be sure, the test should be run with both harness orientations - -from __future__ import print_function -import os -import sys -import time -import random -import argparse - -from hexdump import hexdump -from itertools import permutations - -sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")) -from panda import Panda - -def get_test_string(): - return b"test"+os.urandom(10) - -def run_test(sleep_duration): - pandas = Panda.list() - print(pandas) - - # make sure two pandas are connected - if len(pandas) != 2: - print("Connect white/grey and black panda to run this test!") - assert False - - # connect - pandas[0] = Panda(pandas[0]) - pandas[1] = Panda(pandas[1]) - - # find out which one is black - type0 = pandas[0].get_type() - type1 = pandas[1].get_type() - - black_panda = None - other_panda = None - - if type0 == "\x03" and type1 != "\x03": - black_panda = pandas[0] - other_panda = pandas[1] - elif type0 != "\x03" and type1 == "\x03": - black_panda = pandas[1] - other_panda = pandas[0] - else: - print("Connect white/grey and black panda to run this test!") - assert False - - # disable safety modes - black_panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - other_panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - - # test health packet - print("black panda health", black_panda.health()) - print("other panda health", other_panda.health()) - - # test black -> other - test_buses(black_panda, other_panda, True, [(0, False, [0]), (1, False, [1]), (2, False, [2]), (1, True, [0])], sleep_duration) - test_buses(black_panda, other_panda, False, [(0, False, [0]), (1, False, [1]), (2, False, [2]), (0, True, [0, 1])], sleep_duration) - - -def test_buses(black_panda, other_panda, direction, test_array, sleep_duration): - if direction: - print("***************** TESTING (BLACK --> OTHER) *****************") - else: - print("***************** TESTING (OTHER --> BLACK) *****************") - - for send_bus, obd, recv_buses in test_array: - black_panda.send_heartbeat() - other_panda.send_heartbeat() - print("\ntest can: ", send_bus, " OBD: ", obd) - - # set OBD on black panda - black_panda.set_gmlan(True if obd else None) - - # clear and flush - if direction: - black_panda.can_clear(send_bus) - else: - other_panda.can_clear(send_bus) - - for recv_bus in recv_buses: - if direction: - other_panda.can_clear(recv_bus) - else: - black_panda.can_clear(recv_bus) - - black_panda.can_recv() - other_panda.can_recv() - - # send the characters - at = random.randint(1, 2000) - st = get_test_string()[0:8] - if direction: - black_panda.can_send(at, st, send_bus) - else: - other_panda.can_send(at, st, send_bus) - time.sleep(0.1) - - # check for receive - if direction: - cans_echo = black_panda.can_recv() - cans_loop = other_panda.can_recv() - else: - cans_echo = other_panda.can_recv() - cans_loop = black_panda.can_recv() - - loop_buses = [] - for loop in cans_loop: - print(" Loop on bus", str(loop[3])) - loop_buses.append(loop[3]) - if len(cans_loop) == 0: - print(" No loop") - - # test loop buses - recv_buses.sort() - loop_buses.sort() - assert recv_buses == loop_buses - print(" TEST PASSED") - - time.sleep(sleep_duration) - print("\n") - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument("-n", type=int, help="Number of test iterations to run") - parser.add_argument("-sleep", type=int, help="Sleep time between tests", default=0) - args = parser.parse_args() - - if args.n is None: - while True: - run_test(sleep_duration=args.sleep) - else: - for i in range(args.n): - run_test(sleep_duration=args.sleep) diff --git a/panda/tests/build/Dockerfile b/panda/tests/build/Dockerfile deleted file mode 100644 index 276a25ed0b9495..00000000000000 --- a/panda/tests/build/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM ubuntu:16.04 - -RUN apt-get update && apt-get install -y gcc-arm-none-eabi libnewlib-arm-none-eabi python python-pip gcc g++ git autoconf gperf bison flex automake texinfo wget help2man gawk libtool libtool-bin ncurses-dev unzip unrar-free libexpat-dev sed bzip2 - -RUN pip install pycrypto==2.6.1 - -# Build esp toolchain -RUN mkdir -p /panda/boardesp -WORKDIR /panda/boardesp -RUN git clone --recursive https://github.com/pfalcon/esp-open-sdk.git -WORKDIR /panda/boardesp/esp-open-sdk -RUN git checkout 03f5e898a059451ec5f3de30e7feff30455f7ce -RUN CT_ALLOW_BUILD_AS_ROOT_SURE=1 make STANDALONE=y - -COPY . /panda - -WORKDIR /panda diff --git a/panda/tests/can_printer.py b/panda/tests/can_printer.py deleted file mode 100755 index e863889c16424b..00000000000000 --- a/panda/tests/can_printer.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env python -from __future__ import print_function -import os -import sys -import time -from collections import defaultdict -import binascii - -sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")) -from panda import Panda - -# fake -def sec_since_boot(): - return time.time() - -def can_printer(): - p = Panda() - p.set_safety_mode(0x1337) - - start = sec_since_boot() - lp = sec_since_boot() - msgs = defaultdict(list) - canbus = int(os.getenv("CAN", 0)) - while True: - can_recv = p.can_recv() - for address, _, dat, src in can_recv: - if src == canbus: - msgs[address].append(dat) - - if sec_since_boot() - lp > 0.1: - dd = chr(27) + "[2J" - dd += "%5.2f\n" % (sec_since_boot() - start) - for k,v in sorted(zip(msgs.keys(), map(lambda x: binascii.hexlify(x[-1]), msgs.values()))): - dd += "%s(%6d) %s\n" % ("%04X(%4d)" % (k,k),len(msgs[k]), v) - print(dd) - lp = sec_since_boot() - -if __name__ == "__main__": - can_printer() diff --git a/panda/tests/debug_console.py b/panda/tests/debug_console.py deleted file mode 100755 index 0238ed789783e4..00000000000000 --- a/panda/tests/debug_console.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python -from __future__ import print_function -import os -import sys -import time -import select - -sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")) -from panda import Panda - -setcolor = ["\033[1;32;40m", "\033[1;31;40m"] -unsetcolor = "\033[00m" - -if __name__ == "__main__": - port_number = int(os.getenv("PORT", 0)) - claim = os.getenv("CLAIM") is not None - - serials = Panda.list() - if os.getenv("SERIAL"): - serials = filter(lambda x: x==os.getenv("SERIAL"), serials) - - pandas = list(map(lambda x: Panda(x, claim=claim), serials)) - - if not len(pandas): - sys.exit("no pandas found") - - if os.getenv("BAUD") is not None: - for panda in pandas: - panda.set_uart_baud(port_number, int(os.getenv("BAUD"))) - - while True: - for i, panda in enumerate(pandas): - while True: - ret = panda.serial_read(port_number) - if len(ret) > 0: - sys.stdout.write(setcolor[i] + str(ret) + unsetcolor) - sys.stdout.flush() - else: - break - if select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], []): - ln = sys.stdin.readline() - if claim: - panda.serial_write(port_number, ln) - time.sleep(0.01) diff --git a/panda/tests/disable_esp.py b/panda/tests/disable_esp.py deleted file mode 100755 index abebd9c17b8a5d..00000000000000 --- a/panda/tests/disable_esp.py +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env python -from panda import Panda -Panda().set_esp_power(False) - diff --git a/panda/tests/elm_car_simulator.py b/panda/tests/elm_car_simulator.py deleted file mode 100755 index f931e66ff40999..00000000000000 --- a/panda/tests/elm_car_simulator.py +++ /dev/null @@ -1,325 +0,0 @@ -#!/usr/bin/env python -"""Used to Reverse/Test ELM protocol auto detect and OBD message response without a car.""" -from __future__ import print_function -import sys -import os -import struct -import binascii -import time -import threading -from collections import deque - -sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")) -from panda import Panda - -def lin_checksum(dat): - return sum(dat) % 0x100 - -class ELMCarSimulator(): - def __init__(self, sn, silent=False, can_kbaud=500, - can=True, can11b=True, can29b=True, - lin=True): - self.__p = Panda(sn if sn else Panda.list()[0]) - self.__on = True - self.__stop = False - self.__silent = silent - - self.__lin_timer = None - self.__lin_active = False - self.__lin_enable = lin - self.__lin_monitor_thread = threading.Thread(target=self.__lin_monitor) - - self.__can_multipart_data = None - self.__can_kbaud = can_kbaud - self.__can_extra_noise_msgs = deque() - self.__can_enable = can - self.__can11b = can11b - self.__can29b = can29b - self.__can_monitor_thread = threading.Thread(target=self.__can_monitor) - - @property - def panda(self): - return self.__p - - def stop(self): - if self.__lin_timer: - self.__lin_timer.cancel() - self.__lin_timeout_handler() - - self.__stop = True - - def join(self): - if self.__lin_monitor_thread.is_alive(): - self.__lin_monitor_thread.join() - if self.__can_monitor_thread.is_alive(): - self.__can_monitor_thread.join() - if self.__p: - print("closing handle") - self.__p.close() - - def set_enable(self, on): - self.__on = on - - def start(self): - self.panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - if self.__lin_enable: - self.__lin_monitor_thread.start() - if self.__can_enable: - self.__can_monitor_thread.start() - - ######################### - # LIN related functions # - ######################### - - def __lin_monitor(self): - print("STARTING LIN THREAD") - self.panda.set_uart_baud(2, 10400) - self.panda.kline_drain() # Toss whatever was already there - - lin_buff = bytearray() - - while not self.__stop: - lin_msg = self.panda.serial_read(2) - if not lin_msg: - continue - - lin_buff += lin_msg - #print(" ** Buff", lin_buff) - if lin_buff.endswith(b'\x00\xc1\x33\xf1\x81\x66'): # Leading 0 is wakeup - lin_buff = bytearray() - self.__lin_active = True - print("GOT LIN (KWP FAST) WAKEUP SIGNAL") - self._lin_send(0x10, b'\xC1\x8F\xE9') - self.__reset_lin_timeout() - continue - if self.__lin_active: - msglen = lin_buff[0] & 0x7 - if lin_buff[0] & 0xF8 not in (0x80, 0xC0): - print("Invalid bytes at start of message") - print(" BUFF", lin_buff) - continue - if len(lin_buff) < msglen + 4: continue - if lin_checksum(lin_buff[:-1]) != lin_buff[-1]: continue - self.__lin_process_msg(lin_buff[0] & 0xF8, #Priority - lin_buff[1], lin_buff[2], lin_buff[3:-1]) - lin_buff = bytearray() - - def _lin_send(self, to_addr, msg): - if not self.__silent: - print(" LIN Reply (%x)" % to_addr, binascii.hexlify(msg)) - - PHYS_ADDR = 0x80 - FUNC_ADDR = 0xC0 - RECV = 0xF1 - SEND = 0x33 # Car OBD Functional Address - headers = struct.pack("BBB", PHYS_ADDR | len(msg), RECV, to_addr) - if not self.__silent: - print(" Sending LIN", binascii.hexlify(headers+msg), - hex(sum(bytearray(headers+msg))%0x100)) - self.panda.kline_send(headers + msg) - - def __reset_lin_timeout(self): - if self.__lin_timer: - self.__lin_timer.cancel() - self.__lin_timer = threading.Timer(5, self.__lin_timeout_handler) - self.__lin_timer.start() - - def __lin_timeout_handler(self): - print("LIN TIMEOUT") - self.__lin_timer = None - self.__lin_active = False - - @property - def lin_active(self): - return self.__lin_active - - def __lin_process_msg(self, priority, toaddr, fromaddr, data): - self.__reset_lin_timeout() - - if not self.__silent and data != b'\x3E': - print("LIN MSG", "Addr:", hex(toaddr), "obdLen:", len(data), - binascii.hexlify(data)) - - outmsg = None - #if data == b'\x3E': - # print("KEEP ALIVE") - #el - if len(data) > 1: - outmsg = self._process_obd(data[0], data[1]) - - if outmsg: - obd_header = struct.pack("BB", 0x40 | data[0], data[1]) - if len(outmsg) <= 5: - self._lin_send(0x10, obd_header + outmsg) - else: - first_msg_len = min(4, len(outmsg)%4) or 4 - self._lin_send(0x10, obd_header + b'\x01' + - b'\x00'*(4-first_msg_len) + - outmsg[:first_msg_len]) - - for num, i in enumerate(range(first_msg_len, len(outmsg), 4)): - self._lin_send(0x10, obd_header + - struct.pack('B', (num+2)%0x100) + outmsg[i:i+4]) - - ######################### - # CAN related functions # - ######################### - - def __can_monitor(self): - print("STARTING CAN THREAD") - self.panda.set_can_speed_kbps(0, self.__can_kbaud) - self.panda.can_recv() # Toss whatever was already there - - while not self.__stop: - for address, ts, data, src in self.panda.can_recv(): - if self.__on and src is 0 and len(data) == 8 and data[0] >= 2: - if not self.__silent: - print("Processing CAN message", src, hex(address), binascii.hexlify(data)) - self.__can_process_msg(data[1], data[2], address, ts, data, src) - elif not self.__silent: - print("Rejecting CAN message", src, hex(address), binascii.hexlify(data)) - - def can_mode_11b(self): - self.__can11b = True - self.__can29b = False - - def can_mode_29b(self): - self.__can11b = False - self.__can29b = True - - def can_mode_11b_29b(self): - self.__can11b = True - self.__can29b = True - - def change_can_baud(self, kbaud): - self.__can_kbaud = kbaud - self.panda.set_can_speed_kbps(0, self.__can_kbaud) - - def can_add_extra_noise(self, noise_msg, addr=None): - self.__can_extra_noise_msgs.append((addr, noise_msg)) - - def _can_send(self, addr, msg): - if not self.__silent: - print(" CAN Reply (%x)" % addr, binascii.hexlify(msg)) - self.panda.can_send(addr, msg + b'\x00'*(8-len(msg)), 0) - if self.__can_extra_noise_msgs: - noise = self.__can_extra_noise_msgs.popleft() - self.panda.can_send(noise[0] if noise[0] is not None else addr, - noise[1] + b'\x00'*(8-len(noise[1])), 0) - - def _can_addr_matches(self, addr): - if self.__can11b and (addr == 0x7DF or (addr & 0x7F8) == 0x7E0): - return True - if self.__can29b and (addr == 0x18db33f1 or (addr & 0x1FFF00FF) == 0x18da00f1): - return True - return False - - def __can_process_msg(self, mode, pid, address, ts, data, src): - if not self.__silent: - print("CAN MSG", binascii.hexlify(data[1:1+data[0]]), - "Addr:", hex(address), "Mode:", hex(mode)[2:].zfill(2), - "PID:", hex(pid)[2:].zfill(2), "canLen:", len(data), - binascii.hexlify(data)) - - if self._can_addr_matches(address) and len(data) == 8: - outmsg = None - if data[:3] == b'\x30\x00\x00' and len(self.__can_multipart_data): - if not self.__silent: - print("Request for more data"); - outaddr = 0x7E8 if address == 0x7DF or address == 0x7E0 else 0x18DAF110 - msgnum = 1 - while(self.__can_multipart_data): - datalen = min(7, len(self.__can_multipart_data)) - msgpiece = struct.pack("B", 0x20 | msgnum) + self.__can_multipart_data[:datalen] - self._can_send(outaddr, msgpiece) - self.__can_multipart_data = self.__can_multipart_data[7:] - msgnum = (msgnum+1)%0x10 - time.sleep(0.01) - - else: - outmsg = self._process_obd(mode, pid) - - if outmsg: - outaddr = 0x7E8 if address == 0x7DF or address == 0x7E0 else 0x18DAF110 - - if len(outmsg) <= 5: - self._can_send(outaddr, - struct.pack("BBB", len(outmsg)+2, 0x40|data[1], pid) + outmsg) - else: - first_msg_len = min(3, len(outmsg)%7) - payload_len = len(outmsg)+3 - msgpiece = struct.pack("BBBBB", 0x10 | ((payload_len>>8)&0xF), - payload_len&0xFF, - 0x40|data[1], pid, 1) + outmsg[:first_msg_len] - self._can_send(outaddr, msgpiece) - self.__can_multipart_data = outmsg[first_msg_len:] - - ######################### - # General OBD functions # - ######################### - - def _process_obd(self, mode, pid): - if mode == 0x01: # Mode: Show current data - if pid == 0x00: #List supported things - return b"\xff\xff\xff\xfe"#b"\xBE\x1F\xB8\x10" #Bitfield, random features - elif pid == 0x01: # Monitor Status since DTC cleared - return b"\x00\x00\x00\x00" #Bitfield, random features - elif pid == 0x04: # Calculated engine load - return b"\x2f" - elif pid == 0x05: # Engine coolant temperature - return b"\x3c" - elif pid == 0x0B: # Intake manifold absolute pressure - return b"\x90" - elif pid == 0x0C: # Engine RPM - return b"\x1A\xF8" - elif pid == 0x0D: # Vehicle Speed - return b"\x53" - elif pid == 0x10: # MAF air flow rate - return b"\x01\xA0" - elif pid == 0x11: # Throttle Position - return b"\x90" - elif pid == 0x33: # Absolute Barometric Pressure - return b"\x90" - elif mode == 0x09: # Mode: Request vehicle information - if pid == 0x02: # Show VIN - return b"1D4GP00R55B123456" - if pid == 0xFC: # test long multi message. Ligned up for LIN responses - return b''.join((struct.pack(">BBH", 0xAA, 0xAA, num+1) for num in range(80))) - if pid == 0xFD: # test long multi message - parts = (b'\xAA\xAA\xAA' + struct.pack(">I", num) for num in range(80)) - return b'\xAA\xAA\xAA' + b''.join(parts) - if pid == 0xFE: # test very long multi message - parts = (b'\xAA\xAA\xAA' + struct.pack(">I", num) for num in range(584)) - return b'\xAA\xAA\xAA' + b''.join(parts) + b'\xAA' - if pid == 0xFF: - return b'\xAA\x00\x00' +\ - b"".join(((b'\xAA'*5)+struct.pack(">H", num+1) for num in range(584))) - #return b"\xAA"*100#(0xFFF-3) - - -if __name__ == "__main__": - serial = os.getenv("SERIAL") if os.getenv("SERIAL") else None - kbaud = int(os.getenv("CANKBAUD")) if os.getenv("CANKBAUD") else 500 - bitwidth = int(os.getenv("CANBITWIDTH")) if os.getenv("CANBITWIDTH") else 0 - canenable = bool(int(os.getenv("CANENABLE"))) if os.getenv("CANENABLE") else True - linenable = bool(int(os.getenv("LINENABLE"))) if os.getenv("LINENABLE") else True - sim = ELMCarSimulator(serial, can_kbaud=kbaud, can=canenable, lin=linenable) - if(bitwidth == 0): - sim.can_mode_11b_29b() - if(bitwidth == 11): - sim.can_mode_11b() - if(bitwidth == 29): - sim.can_mode_29b() - - import signal - def signal_handler(signal, frame): - print('\nShutting down simulator') - sim.stop() - sim.join() - sys.exit(0) - - signal.signal(signal.SIGINT, signal_handler) - - sim.start() - - signal.pause() diff --git a/panda/tests/elm_throughput.py b/panda/tests/elm_throughput.py deleted file mode 100755 index 39625728899a74..00000000000000 --- a/panda/tests/elm_throughput.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python -from __future__ import print_function -import socket -import threading -import select - -class Reader(threading.Thread): - def __init__(self, s, *args, **kwargs): - super(Reader, self).__init__(*args, **kwargs) - self._s = s - self.__stop = False - - def stop(self): - self.__stop = True - - def run(self): - while not self.__stop: - s.recv(1000) - -def read_or_fail(s): - ready = select.select([s], [], [], 4) - assert ready[0], "Socket did not receive data within the timeout duration." - return s.recv(1000) - -def send_msg(s, msg): - s.send(msg) - res = b'' - while not res.endswith(">"): - res += read_or_fail(s) - return res - -if __name__ == "__main__": - s = socket.create_connection(("192.168.0.10", 35000)) - #t1 = Reader(s) - #t1.start() - send_msg(s, b"ATZ\r") - send_msg(s, b"ATL1\r") - print(send_msg(s, b"ATE0\r")) - print(send_msg(s, b"ATS0\r")) - print(send_msg(s, b"ATSP6\r")) - - print("\nLOOP\n") - - while True: - print(send_msg(s, b"0100\r")) - print(send_msg(s, b"010d\r")) diff --git a/panda/tests/elm_wifi.py b/panda/tests/elm_wifi.py deleted file mode 100644 index f5a8849833df60..00000000000000 --- a/panda/tests/elm_wifi.py +++ /dev/null @@ -1,669 +0,0 @@ -from __future__ import print_function -import os -import sys -import time -import socket -import select -import pytest -import struct - -sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")) -import elm_car_simulator -sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..")) -from panda import Panda - -def elm_connect(): - s = socket.create_connection(("192.168.0.10", 35000)) - s.setblocking(0) - return s - -def read_or_fail(s): - ready = select.select([s], [], [], 4) - assert ready[0], "Socket did not receive data within the timeout duration." - return s.recv(1000) - -def sendrecv(s, dat): - s.send(dat) - return read_or_fail(s) - -def send_compare(s, dat, ret, timeout=4): - s.send(dat) - res = b'' - while ret.startswith(res) and ret != res: - print("Waiting") - ready = select.select([s], [], [], timeout) - if not ready[0]: - print("current recv data:", repr(res)) - break; - res += s.recv(1000) - #print("final recv data: '%s'" % repr(res)) - assert ret == res#, "Data does not agree (%s) (%s)"%(repr(ret), repr(res)) - -def sync_reset(s): - s.send("ATZ\r") - res = b'' - while not res.endswith("ELM327 v1.5\r\r>"): - res += read_or_fail(s) - print("Reset response is '%s'" % repr(res)) - -def test_reset(): - s = socket.create_connection(("192.168.0.10", 35000)) - s.setblocking(0) - - try: - sync_reset(s) - finally: - s.close() - -def test_elm_cli(): - s = elm_connect() - - try: - sync_reset(s) - - send_compare(s, b'ATI\r', b'ATI\rELM327 v1.5\r\r>') - - #Test Echo Off - #Expected to be misimplimentation, but this is how the reference device behaved. - send_compare(s, b'ATE0\r', b'ATE0\rOK\r\r>') #Here is the odd part - send_compare(s, b'ATE0\r', b'OK\r\r>') #Should prob show this immediately - send_compare(s, b'ATI\r', b'ELM327 v1.5\r\r>') - - #Test Newline On - send_compare(s, b'ATL1\r', b'OK\r\n\r\n>') - send_compare(s, b'ATI\r', b'ELM327 v1.5\r\n\r\n>') - send_compare(s, b'ATL0\r', b'OK\r\r>') - send_compare(s, b'ATI\r', b'ELM327 v1.5\r\r>') - - send_compare(s, b'ATI\r', b'ELM327 v1.5\r\r>') #Test repeat command no echo - send_compare(s, b'\r', b'ELM327 v1.5\r\r>') - - send_compare(s, b'aTi\r', b'ELM327 v1.5\r\r>') #Test different case - - send_compare(s, b' a T i\r', b'ELM327 v1.5\r\r>') #Test with white space - - send_compare(s, b'ATCATHAT\r', b'?\r\r>') #Test Invalid AT command - - send_compare(s, b'01 00 00 00 00 00 00 00\r', b'?\r\r>') #Test Invalid (too long) OBD command - send_compare(s, b'01 GZ\r', b'?\r\r>') #Test Invalid (Non hex chars) OBD command - finally: - s.close() - -def test_elm_setget_protocol(): - s = elm_connect() - - try: - sync_reset(s) - send_compare(s, b'ATE0\r', b'ATE0\rOK\r\r>') # Echo OFF - - send_compare(s, b'ATSP0\r', b"OK\r\r>") # Set auto - send_compare(s, b'ATDP\r', b"AUTO\r\r>") - send_compare(s, b'ATDPN\r', b"A0\r\r>") - - send_compare(s, b'ATSP6\r', b"OK\r\r>") # Set protocol - send_compare(s, b'ATDP\r', b"ISO 15765-4 (CAN 11/500)\r\r>") - send_compare(s, b'ATDPN\r', b"6\r\r>") - - send_compare(s, b'ATSPA6\r', b"OK\r\r>") # Set auto with protocol default - send_compare(s, b'ATDP\r', b"AUTO, ISO 15765-4 (CAN 11/500)\r\r>") - send_compare(s, b'ATDPN\r', b"A6\r\r>") - - send_compare(s, b'ATSP7\r', b"OK\r\r>") - send_compare(s, b'ATDP\r', b"ISO 15765-4 (CAN 29/500)\r\r>") - send_compare(s, b'ATDPN\r', b"7\r\r>") #Test Does not accept invalid protocols - send_compare(s, b'ATSPD\r', b"?\r\r>") - send_compare(s, b'ATDP\r', b"ISO 15765-4 (CAN 29/500)\r\r>") - send_compare(s, b'ATDPN\r', b"7\r\r>") - finally: - s.close() - -def test_elm_protocol_failure(): - s = elm_connect() - - try: - sync_reset(s) - send_compare(s, b'ATE0\r', b'ATE0\rOK\r\r>') # Echo OFF - - send_compare(s, b'ATSP0\r', b"OK\r\r>") - send_compare(s, b'0100\r', b"SEARCHING...\rUNABLE TO CONNECT\r\r>", timeout=10) - - send_compare(s, b'ATSP1\r', b"OK\r\r>") - send_compare(s, b'0100\r', b"NO DATA\r\r>") - - send_compare(s, b'ATSP2\r', b"OK\r\r>") - send_compare(s, b'0100\r', b"NO DATA\r\r>") - - send_compare(s, b'ATSP3\r', b"OK\r\r>") - send_compare(s, b'0100\r', b"BUS INIT: ...ERROR\r\r>") - - send_compare(s, b'ATSP4\r', b"OK\r\r>") - send_compare(s, b'0100\r', b"BUS INIT: ...ERROR\r\r>") - - send_compare(s, b'ATSP5\r', b"OK\r\r>") - send_compare(s, b'0100\r', b"BUS INIT: ERROR\r\r>") - - #send_compare(s, b'ATSP6\r', b"OK\r\r>") - #send_compare(s, b'0100\r', b"NO DATA\r\r>") - # - #send_compare(s, b'ATSP7\r', b"OK\r\r>") - #send_compare(s, b'0100\r', b"NO DATA\r\r>") - # - #send_compare(s, b'ATSP8\r', b"OK\r\r>") - #send_compare(s, b'0100\r', b"NO DATA\r\r>") - # - #send_compare(s, b'ATSP9\r', b"OK\r\r>") - #send_compare(s, b'0100\r', b"NO DATA\r\r>") - # - #send_compare(s, b'ATSPA\r', b"OK\r\r>") - #send_compare(s, b'0100\r', b"NO DATA\r\r>") - # - #send_compare(s, b'ATSPB\r', b"OK\r\r>") - #send_compare(s, b'0100\r', b"NO DATA\r\r>") - # - #send_compare(s, b'ATSPC\r', b"OK\r\r>") - #send_compare(s, b'0100\r', b"NO DATA\r\r>") - finally: - s.close() - -def test_elm_protocol_autodetect_ISO14230_KWP_FAST(): - s = elm_connect() - serial = os.getenv("CANSIMSERIAL") if os.getenv("CANSIMSERIAL") else None - sim = elm_car_simulator.ELMCarSimulator(serial, can=False)#, silent=True) - sim.start() - - try: - sync_reset(s) - send_compare(s, b'ATE0\r', b'ATE0\rOK\r\r>') # Echo OFF - send_compare(s, b'ATH0\r', b'OK\r\r>') # Headers ON - send_compare(s, b'ATS0\r', b"OK\r\r>") - - send_compare(s, b'ATSP0\r', b"OK\r\r>") - send_compare(s, b'010D\r', b"SEARCHING...\r410D53\r\r>", timeout=10) - send_compare(s, b'ATDPN\r', b"A5\r\r>") - finally: - sim.stop() - sim.join() - s.close() - -def test_elm_basic_send_lin(): - s = elm_connect() - serial = os.getenv("CANSIMSERIAL") if os.getenv("CANSIMSERIAL") else None - sim = elm_car_simulator.ELMCarSimulator(serial, can=False)#, silent=True) - sim.start() - - try: - sync_reset(s) - send_compare(s, b'ATSP5\r', b"ATSP5\rOK\r\r>") # Set Proto - - send_compare(s, b'ATE0\r', b'ATE0\rOK\r\r>') # Echo OFF - send_compare(s, b'0100\r', b"BUS INIT: OK\r41 00 FF FF FF FE \r\r>") - send_compare(s, b'010D\r', b"41 0D 53 \r\r>") - - send_compare(s, b'ATS0\r', b'OK\r\r>') # Spaces Off - send_compare(s, b'0100\r', b"4100FFFFFFFE\r\r>") - send_compare(s, b'010D\r', b"410D53\r\r>") - - send_compare(s, b'ATH1\r', b'OK\r\r>') # Spaces Off Headers On - send_compare(s, b'0100\r', b"86F1104100FFFFFFFEC3\r\r>") - send_compare(s, b'010D\r', b"83F110410D5325\r\r>") - - send_compare(s, b'ATS1\r', b'OK\r\r>') # Spaces On Headers On - send_compare(s, b'0100\r', b"86 F1 10 41 00 FF FF FF FE C3 \r\r>") - send_compare(s, b'010D\r', b"83 F1 10 41 0D 53 25 \r\r>") - - send_compare(s, b'1F00\r', b"NO DATA\r\r>") # Unhandled msg, no response. - - # Repeat last check to see if it still works after NO DATA was received - send_compare(s, b'0100\r', b"86 F1 10 41 00 FF FF FF FE C3 \r\r>") - send_compare(s, b'010D\r', b"83 F1 10 41 0D 53 25 \r\r>") - finally: - sim.stop() - sim.join() - s.close() - -def test_elm_send_lin_multiline_msg(): - s = elm_connect() - serial = os.getenv("CANSIMSERIAL") if os.getenv("CANSIMSERIAL") else None - sim = elm_car_simulator.ELMCarSimulator(serial, can=False) - sim.start() - - try: - sync_reset(s) - send_compare(s, b'ATE0\r', b'ATE0\rOK\r\r>') # Echo OFF - send_compare(s, b'ATSP5\r', b"OK\r\r>") # Set Proto - - send_compare(s, b'0902\r', # headers OFF, Spaces ON - b"BUS INIT: OK\r" - "49 02 01 00 00 00 31 \r" - "49 02 02 44 34 47 50 \r" - "49 02 03 30 30 52 35 \r" - "49 02 04 35 42 31 32 \r" - "49 02 05 33 34 35 36 \r\r>") - - send_compare(s, b'ATS0\r', b'OK\r\r>') # Spaces OFF - send_compare(s, b'0902\r', # Headers OFF, Spaces OFF - b"49020100000031\r" - "49020244344750\r" - "49020330305235\r" - "49020435423132\r" - "49020533343536\r\r>") - - send_compare(s, b'ATH1\r', b'OK\r\r>') # Headers ON - send_compare(s, b'0902\r', # Headers ON, Spaces OFF - b"87F1104902010000003105\r" - "87F11049020244344750E4\r" - "87F11049020330305235BD\r" - "87F11049020435423132B1\r" - "87F11049020533343536AA\r\r>") - - send_compare(s, b'ATS1\r', b'OK\r\r>') # Spaces ON - send_compare(s, b'0902\r', # Headers ON, Spaces ON - b"87 F1 10 49 02 01 00 00 00 31 05 \r" - "87 F1 10 49 02 02 44 34 47 50 E4 \r" - "87 F1 10 49 02 03 30 30 52 35 BD \r" - "87 F1 10 49 02 04 35 42 31 32 B1 \r" - "87 F1 10 49 02 05 33 34 35 36 AA \r\r>") - finally: - sim.stop() - sim.join() - s.close() - -def test_elm_send_lin_multiline_msg_throughput(): - s = elm_connect() - serial = os.getenv("CANSIMSERIAL") if os.getenv("CANSIMSERIAL") else None - sim = elm_car_simulator.ELMCarSimulator(serial, can=False, silent=True) - sim.start() - - try: - sync_reset(s) - send_compare(s, b'ATSP5\r', b"ATSP5\rOK\r\r>") # Set Proto - send_compare(s, b'ATE0\r', b'ATE0\rOK\r\r>') # Echo OFF - send_compare(s, b'ATS0\r', b'OK\r\r>') # Spaces OFF - send_compare(s, b'ATH0\r', b'OK\r\r>') # Headers OFF - - send_compare(s, b'09fc\r', # headers OFF, Spaces OFF - b"BUS INIT: OK\r" + - b''.join((b'49FC' + hex(num+1)[2:].upper().zfill(2) + - b'AAAA' + hex(num+1)[2:].upper().zfill(4) + b'\r' - for num in range(80))) + - b"\r>", - timeout=10 - ) - finally: - sim.stop() - sim.join() - s.close() - -def test_elm_panda_safety_mode_KWPFast(): - serial = os.getenv("CANSIMSERIAL") if os.getenv("CANSIMSERIAL") else None - p_car = Panda(serial) # Configure this so the messages will send - p_car.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - p_car.kline_drain() - - p_elm = Panda("WIFI") - p_elm.set_safety_mode(0xE327); - - def get_checksum(dat): - result = 0 - result += sum(map(ord, dat)) if isinstance(b'dat', str) else sum(dat) - return struct.pack("B", result % 0x100) - - def timed_recv_check(p, bus, goodmsg): - t = time.time() - msg = bytearray() - - while time.time()-t < 0.5 and len(msg) != len(goodmsg): - msg += p._handle.controlRead(Panda.REQUEST_OUT, 0xe0, bus, 0, len(goodmsg)-len(msg)) - #print("Received", repr(msg)) - if msg == goodmsg: - return True - time.sleep(0.01) - return False - - def kline_send(p, x, bus=2): - p.kline_drain(bus=bus) - p._handle.bulkWrite(2, chr(bus).encode()+x) - return timed_recv_check(p, bus, x) - - def did_send(priority, toaddr, fromaddr, dat, bus=2, checkbyte=None): - msgout = struct.pack("BBB", priority | len(dat), toaddr, fromaddr) + dat - msgout += get_checksum(msgout) if checkbyte is None else checkbyte - print("Sending", hex(priority), hex(toaddr), hex(fromaddr), repr(msgout)) - - if not kline_send(p_elm, msgout, bus=bus): - return False - return timed_recv_check(p_car, bus, msgout) - - assert not did_send(0xC0, 0x33, 0xF1, b'\x01\x0F', bus=3) #wrong bus - assert not did_send(0xC0, 0x33, 0xF1, b'') #wrong length - assert not did_send(0xB0, 0x33, 0xF1, b'\x01\x0E') #bad priority - assert not did_send(0xC0, 0x00, 0xF1, b'\x01\x0D') #bad addr - assert not did_send(0xC0, 0x33, 0x00, b'\x01\x0C') #bad addr - - assert did_send(0xC0, 0x33, 0xF1, b'\x01\x0B') #good! (obd func req) - -def test_elm_lin_keepalive(): - s = elm_connect() - serial = os.getenv("CANSIMSERIAL") if os.getenv("CANSIMSERIAL") else None - sim = elm_car_simulator.ELMCarSimulator(serial, can=False, silent=True) - sim.start() - - try: - sync_reset(s) - send_compare(s, b'ATSP5\r', b"ATSP5\rOK\r\r>") # Set Proto - send_compare(s, b'ATE0\r', b'ATE0\rOK\r\r>') # Echo OFF - send_compare(s, b'ATS0\r', b'OK\r\r>') # Spaces OFF - send_compare(s, b'ATH0\r', b'OK\r\r>') # Headers OFF - - send_compare(s, b'0100\r', b"BUS INIT: OK\r4100FFFFFFFE\r\r>") - assert sim.lin_active - time.sleep(6) - assert sim.lin_active - - send_compare(s, b'ATPC\r', b"OK\r\r>") #STOP KEEPALIVE - assert sim.lin_active - time.sleep(6) - assert not sim.lin_active - - finally: - sim.stop() - sim.join() - s.close() - -#//////////// -def test_elm_protocol_autodetect_ISO15765(): - s = elm_connect() - serial = os.getenv("CANSIMSERIAL") if os.getenv("CANSIMSERIAL") else None - sim = elm_car_simulator.ELMCarSimulator(serial, lin=False, silent=True) - sim.start() - - try: - sync_reset(s) - send_compare(s, b'ATE0\r', b'ATE0\rOK\r\r>') # Echo OFF - send_compare(s, b'ATH1\r', b'OK\r\r>') # Headers ON - send_compare(s, b'ATS0\r', b"OK\r\r>") - - sim.can_mode_11b() - send_compare(s, b'ATSP0\r', b"OK\r\r>") - send_compare(s, b'010D\r', b"SEARCHING...\r7E803410D53\r\r>", timeout=10) - send_compare(s, b'ATDPN\r', b"A6\r\r>") - - sim.can_mode_29b() - send_compare(s, b'ATSP0\r', b"OK\r\r>") - send_compare(s, b'010D\r', b"SEARCHING...\r18DAF11003410D53\r\r>", timeout=10) - send_compare(s, b'ATDPN\r', b"A7\r\r>") - - sim.change_can_baud(250) - - sim.can_mode_11b() - send_compare(s, b'ATSP0\r', b"OK\r\r>") - send_compare(s, b'010D\r', b"SEARCHING...\r7E803410D53\r\r>", timeout=10) - send_compare(s, b'ATDPN\r', b"A8\r\r>") - - sim.can_mode_29b() - send_compare(s, b'ATSP0\r', b"OK\r\r>") - send_compare(s, b'010D\r', b"SEARCHING...\r18DAF11003410D53\r\r>", timeout=10) - send_compare(s, b'ATDPN\r', b"A9\r\r>") - finally: - sim.stop() - sim.join() - s.close() - -def test_elm_basic_send_can(): - s = elm_connect() - serial = os.getenv("CANSIMSERIAL") if os.getenv("CANSIMSERIAL") else None - sim = elm_car_simulator.ELMCarSimulator(serial, lin=False, silent=True) - sim.start() - - try: - sync_reset(s) - send_compare(s, b'ATSP6\r', b"ATSP6\rOK\r\r>") # Set Proto - - send_compare(s, b'ATE0\r', b'ATE0\rOK\r\r>') # Echo OFF - send_compare(s, b'0100\r', b"41 00 FF FF FF FE \r\r>") - send_compare(s, b'010D\r', b"41 0D 53 \r\r>") - - send_compare(s, b'ATS0\r', b'OK\r\r>') # Spaces Off - send_compare(s, b'0100\r', b"4100FFFFFFFE\r\r>") - send_compare(s, b'010D\r', b"410D53\r\r>") - - send_compare(s, b'ATH1\r', b'OK\r\r>') # Spaces Off Headers On - send_compare(s, b'0100\r', b"7E8064100FFFFFFFE\r\r>") - send_compare(s, b'010D\r', b"7E803410D53\r\r>") - - send_compare(s, b'ATS1\r', b'OK\r\r>') # Spaces On Headers On - send_compare(s, b'0100\r', b"7E8 06 41 00 FF FF FF FE \r\r>") - send_compare(s, b'010D\r', b"7E8 03 41 0D 53 \r\r>") - - send_compare(s, b'1F00\r', b"NO DATA\r\r>") # Unhandled msg, no response. - - # Repeat last check to see if it still works after NO DATA was received - send_compare(s, b'0100\r', b"7E8 06 41 00 FF FF FF FE \r\r>") - send_compare(s, b'010D\r', b"7E8 03 41 0D 53 \r\r>") - finally: - sim.stop() - sim.join() - s.close() - -def test_elm_send_can_multimsg(): - s = elm_connect() - serial = os.getenv("CANSIMSERIAL") if os.getenv("CANSIMSERIAL") else None - sim = elm_car_simulator.ELMCarSimulator(serial, lin=False) - sim.start() - - try: - sync_reset(s) - send_compare(s, b'ATE0\r', b'ATE0\rOK\r\r>') # Echo OFF - send_compare(s, b'ATS1\r', b'OK\r\r>') # Spaces OFF - send_compare(s, b'ATH1\r', b'OK\r\r>') # Headers ON - - send_compare(s, b'ATSP6\r', b"OK\r\r>") # Set Proto ISO 15765-4 (CAN 11/500) - sim.can_add_extra_noise(b'\x03\x41\x0D\xFA', addr=0x7E9)# Inject message into the stream - send_compare(s, b'010D\r', - b"7E8 03 41 0D 53 \r" - "7E9 03 41 0D FA \r\r>") # Check it was ignored. - finally: - sim.stop() - sim.join() - s.close() - -"""The ability to correctly filter out messages with the wrong PID is not -implemented correctly in the reference device.""" -def test_elm_can_check_mode_pid(): - s = elm_connect() - serial = os.getenv("CANSIMSERIAL") if os.getenv("CANSIMSERIAL") else None - sim = elm_car_simulator.ELMCarSimulator(serial, lin=False) - sim.start() - - try: - sync_reset(s) - send_compare(s, b'ATE0\r', b'ATE0\rOK\r\r>') # Echo OFF - send_compare(s, b'ATS0\r', b'OK\r\r>') # Spaces OFF - send_compare(s, b'ATH0\r', b'OK\r\r>') # Headers OFF - - send_compare(s, b'ATSP6\r', b"OK\r\r>") # Set Proto ISO 15765-4 (CAN 11/500) - sim.can_add_extra_noise(b'\x03\x41\x0E\xFA')# Inject message into the stream - send_compare(s, b'010D\r', b"410D53\r\r>") # Check it was ignored. - send_compare(s, b'0100\r', b"4100FFFFFFFE\r\r>") # Check it was ignored again. - finally: - sim.stop() - sim.join() - s.close() - -def test_elm_send_can_multiline_msg(): - s = elm_connect() - serial = os.getenv("CANSIMSERIAL") if os.getenv("CANSIMSERIAL") else None - sim = elm_car_simulator.ELMCarSimulator(serial, lin=False) - sim.start() - - try: - sync_reset(s) - send_compare(s, b'ATSP6\r', b"ATSP6\rOK\r\r>") # Set Proto - send_compare(s, b'ATE0\r', b'ATE0\rOK\r\r>') # Echo OFF - - send_compare(s, b'0902\r', # headers OFF, Spaces ON - b"014 \r" - "0: 49 02 01 31 44 34 \r" - "1: 47 50 30 30 52 35 35 \r" - "2: 42 31 32 33 34 35 36 \r\r>") - - send_compare(s, b'ATS0\r', b'OK\r\r>') # Spaces OFF - send_compare(s, b'0902\r', # Headers OFF, Spaces OFF - b"014\r" - "0:490201314434\r" - "1:47503030523535\r" - "2:42313233343536\r\r>") - - send_compare(s, b'ATH1\r', b'OK\r\r>') # Headers ON - send_compare(s, b'0902\r', # Headers ON, Spaces OFF - b"7E81014490201314434\r" - "7E82147503030523535\r" - "7E82242313233343536\r\r>") - - send_compare(s, b'ATS1\r', b'OK\r\r>') # Spaces ON - send_compare(s, b'0902\r', # Headers ON, Spaces ON - b"7E8 10 14 49 02 01 31 44 34 \r" - "7E8 21 47 50 30 30 52 35 35 \r" - "7E8 22 42 31 32 33 34 35 36 \r\r>") - finally: - sim.stop() - sim.join() - s.close() - -def test_elm_send_can_multiline_msg_throughput(): - s = elm_connect() - serial = os.getenv("CANSIMSERIAL") if os.getenv("CANSIMSERIAL") else None - sim = elm_car_simulator.ELMCarSimulator(serial, lin=False, silent=True) - sim.start() - - try: - sync_reset(s) - send_compare(s, b'ATSP6\r', b"ATSP6\rOK\r\r>") # Set Proto - send_compare(s, b'ATE0\r', b'ATE0\rOK\r\r>') # Echo OFF - send_compare(s, b'ATS0\r', b'OK\r\r>') # Spaces OFF - send_compare(s, b'ATH1\r', b'OK\r\r>') # Headers ON - - rows = 584 - send_compare(s, b'09ff\r', # headers ON, Spaces OFF - ("7E8" + "1" + hex((rows*7)+6)[2:].upper().zfill(3) + "49FF01"+"AA0000\r" + - "".join( - ("7E82"+hex((num+1)%0x10)[2:].upper()+("AA"*5) + - hex(num+1)[2:].upper().zfill(4) + "\r" for num in range(rows)) - ) + "\r>").encode(), - timeout=10 - ) - finally: - sim.stop() - sim.join() - s.close() - -def test_elm_interrupted_obd_cmd_resets_state(): - s = elm_connect() - serial = os.getenv("CANSIMSERIAL") if os.getenv("CANSIMSERIAL") else None - sim = elm_car_simulator.ELMCarSimulator(serial, lin=False, silent=True) - sim.start() - - try: - sync_reset(s) - send_compare(s, b'ATE0\r', b'ATE0\rOK\r\r>') # Echo OFF - send_compare(s, b'ATS0\r', b'OK\r\r>') # Spaces OFF - s.send(b"09fd\r") - ready = select.select([s], [], [], 4) - assert ready[0], "Socket did not receive data within the timeout duration." - s.send(b"ATI\r") - - assert b"236\r0:49FD01AAAAAA\r" in s.recv(10000) - - #Will likely have to be improved to scan for STOPPED if the FW gets more responsive. - ready = select.select([s], [], [], 4) - assert ready[0], "Socket did not receive data within the timeout duration." - - assert b"STOPPED" in s.recv(10000) - - sim.set_enable(False) - send_compare(s, b'09fd\r', b"NO DATA\r\r>") - finally: - sim.stop() - sim.join() - s.close() - -def test_elm_can_baud(): - s = elm_connect() - serial = os.getenv("CANSIMSERIAL") if os.getenv("CANSIMSERIAL") else None - sim = elm_car_simulator.ELMCarSimulator(serial, lin=False) - sim.start() - - try: - sync_reset(s) - send_compare(s, b'ATE0\r', b'ATE0\rOK\r\r>') # Echo OFF - send_compare(s, b'ATS0\r', b'OK\r\r>') # Spaces OFF - send_compare(s, b'ATH1\r', b'OK\r\r>') # Headers ON - - send_compare(s, b'ATSP6\r', b"OK\r\r>") # Set Proto ISO 15765-4 (CAN 11/500) - send_compare(s, b'0100\r', b"7E8064100FFFFFFFE\r\r>") - - send_compare(s, b'ATSP8\r', b"OK\r\r>") # Set Proto ISO 15765-4 (CAN 11/250) - send_compare(s, b'0100\r', b"CAN ERROR\r\r>") - - sim.change_can_baud(250) - - send_compare(s, b'ATSP6\r', b"OK\r\r>") # Set Proto ISO 15765-4 (CAN 11/500) - send_compare(s, b'0100\r', b"CAN ERROR\r\r>") - - send_compare(s, b'ATSP8\r', b"OK\r\r>") # Set Proto ISO 15765-4 (CAN 11/250) - send_compare(s, b'0100\r', b"7E8064100FFFFFFFE\r\r>") - finally: - sim.stop() - sim.join() - s.close() - -def test_elm_panda_safety_mode_ISO15765(): - s = elm_connect() - serial = os.getenv("CANSIMSERIAL") if os.getenv("CANSIMSERIAL") else None - p_car = Panda(serial) # Configure this so the messages will send - p_car.set_can_speed_kbps(0, 500) - p_car.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - - p_elm = Panda("WIFI") - p_elm.set_safety_mode(0xE327); - - #sim = elm_car_simulator.ELMCarSimulator(serial, lin=False) - #sim.start() - - def did_send(p, addr, dat, bus): - p.can_send(addr, dat, bus) - t = time.time() - while time.time()-t < 0.5: - msg = p.can_recv() - for addrin, _, datin, busin in msg: - if (0x80 | bus) == busin and addr == addrin and datin == dat: - return True - time.sleep(0.01) - return False - - try: - sync_reset(s) # Reset elm (which requests the ELM327 safety mode) - - #29 bit - assert not did_send(p_elm, 0x18DB33F1, b'\x02\x01\x00\x00\x00\x00\x00\x00', 1) #wrong canid - assert not did_send(p_elm, 0x18DB33F1, b'\x02\x01\x00', 0) #wrong length - assert not did_send(p_elm, 0x10000000, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #bad addr - assert not did_send(p_elm, 0x18DAF133, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #bad addr (phy addr) - assert not did_send(p_elm, 0x18DAF000, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #bad addr - assert not did_send(p_elm, 0x18DAF1F3, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #bad addr! (phys rsp to elm) - - assert did_send(p_elm, 0x18DB33F1, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #good! (obd func req) - assert did_send(p_elm, 0x18DA10F1, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #good! (phys response) - - #11 bit - assert not did_send(p_elm, 0X7DF, b'\x02\x01\x00\x00\x00\x00\x00\x00', 1) #wrong canid - assert not did_send(p_elm, 0X7DF, b'\x02\x01\x00', 0) #wrong length - assert not did_send(p_elm, 0xAA, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #bad addr - assert not did_send(p_elm, 0x7DA, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #bad addr (phy addr) - assert not did_send(p_elm, 0x7E8, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #bad addr (sending 'response') - - assert did_send(p_elm, 0x7DF, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #good! (obd func req) - assert did_send(p_elm, 0x7E1, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #good! (phys response) - - finally: - s.close() diff --git a/panda/tests/flashing_loop.sh b/panda/tests/flashing_loop.sh deleted file mode 100755 index 2eaf850c835c92..00000000000000 --- a/panda/tests/flashing_loop.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -cd ../board -make clean - -while true; do - make ota - sleep 10 -done - diff --git a/panda/tests/get_version.py b/panda/tests/get_version.py deleted file mode 100755 index 0cd7795fdcc71d..00000000000000 --- a/panda/tests/get_version.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python -from panda import Panda - -if __name__ == "__main__": - for p in Panda.list(): - pp = Panda(p) - print("%s: %s" % (pp.get_serial()[0], pp.get_version())) - - diff --git a/panda/tests/gmbitbang/recv.py b/panda/tests/gmbitbang/recv.py deleted file mode 100755 index 6eb70aa4ad3abb..00000000000000 --- a/panda/tests/gmbitbang/recv.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python -import time -from panda import Panda - -p = Panda() -p.set_safety_mode(Panda.SAFETY_ALLOUTPUT) -p.set_gmlan(bus=2) -#p.can_send(0xaaa, "\x00\x00", bus=3) -last_add = None -while 1: - ret = p.can_recv() - if len(ret) > 0: - add = ret[0][0] - if last_add is not None and add != last_add+1: - print "MISS %d %d" % (last_add, add) - last_add = add - print ret diff --git a/panda/tests/gmbitbang/rigol.py b/panda/tests/gmbitbang/rigol.py deleted file mode 100755 index 3d690fdd84c725..00000000000000 --- a/panda/tests/gmbitbang/rigol.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python -import numpy as np -import visa -import matplotlib.pyplot as plt - -resources = visa.ResourceManager() -print resources.list_resources() - -scope = resources.open_resource('USB0::0x1AB1::0x04CE::DS1ZA184652242::INSTR', timeout=2000, chunk_size=1024000) -print(scope.query('*IDN?').strip()) - -#voltscale = scope.ask_for_values(':CHAN1:SCAL?')[0] -#voltoffset = scope.ask_for_values(":CHAN1:OFFS?")[0] - -#scope.write(":STOP") -scope.write(":WAV:POIN:MODE RAW") -scope.write(":WAV:DATA? CHAN1")[10:] -rawdata = scope.read_raw() -data = np.frombuffer(rawdata, 'B') -print data.shape - -s1 = data[0:650] -s2 = data[650:] -s1i = np.argmax(s1 > 100) -s2i = np.argmax(s2 > 100) -s1 = s1[s1i:] -s2 = s2[s2i:] - -plt.plot(s1) -plt.plot(s2) -plt.show() -#data = (data - 130.0 - voltoffset/voltscale*25) / 25 * voltscale - -print data - diff --git a/panda/tests/gmbitbang/test.py b/panda/tests/gmbitbang/test.py deleted file mode 100755 index 652ac1ddd8ad24..00000000000000 --- a/panda/tests/gmbitbang/test.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python -import time -from panda import Panda - -p1 = Panda('380016000551363338383037') -p2 = Panda('430026000951363338383037') - -# this is a test, no safety -p1.set_safety_mode(Panda.SAFETY_ALLOUTPUT) -p2.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - -# get versions -print(p1.get_version()) -print(p2.get_version()) - -# this sets bus 2 to actually be GMLAN -p2.set_gmlan(bus=2) - -# send w bitbang then without -#iden = 123 -iden = 18000 -#dat = "\x01\x02" -dat = "\x01\x02\x03\x04\x05\x06\x07\x08" -while 1: - iden += 1 - p1.set_gmlan(bus=None) - p1.can_send(iden, dat, bus=3) - #p1.set_gmlan(bus=2) - #p1.can_send(iden, dat, bus=3) - time.sleep(0.01) - print p2.can_recv() - #exit(0) - diff --git a/panda/tests/gmbitbang/test_one.py b/panda/tests/gmbitbang/test_one.py deleted file mode 100755 index d7d430437dcabb..00000000000000 --- a/panda/tests/gmbitbang/test_one.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python -import time -from panda import Panda - -p = Panda() -p.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - -# hack anything on bus -p.set_gmlan(bus=2) -time.sleep(0.1) -while len(p.can_recv()) > 0: - print "clearing" - time.sleep(0.1) -print "cleared" -p.set_gmlan(bus=None) - -iden = 18000 -dat = "\x01\x02\x03\x04\x05\x06\x07\x08" -while 1: - iden += 1 - p.can_send(iden, dat, bus=3) - time.sleep(0.01) - diff --git a/panda/tests/gmbitbang/test_packer.c b/panda/tests/gmbitbang/test_packer.c deleted file mode 100644 index f056dd48125d34..00000000000000 --- a/panda/tests/gmbitbang/test_packer.c +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include - -typedef struct { - uint32_t RIR; /*!< CAN receive FIFO mailbox identifier register */ - uint32_t RDTR; /*!< CAN receive FIFO mailbox data length control and time stamp register */ - uint32_t RDLR; /*!< CAN receive FIFO mailbox data low register */ - uint32_t RDHR; /*!< CAN receive FIFO mailbox data high register */ -} CAN_FIFOMailBox_TypeDef; - -#include "../../board/drivers/canbitbang.h" - -int main() { - char out[300]; - CAN_FIFOMailBox_TypeDef to_bang = {0}; - to_bang.RIR = 20 << 21; - to_bang.RDTR = 1; - to_bang.RDLR = 1; - - int len = get_bit_message(out, &to_bang); - printf("T:"); - for (int i = 0; i < len; i++) { - printf("%d", out[i]); - } - printf("\n"); - printf("R:0000010010100000100010000010011110111010100111111111111111"); - printf("\n"); - return 0; -} - - - diff --git a/panda/tests/language/Dockerfile b/panda/tests/language/Dockerfile deleted file mode 100644 index 068847145e4b0f..00000000000000 --- a/panda/tests/language/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM ubuntu:16.04 - -RUN apt-get update && apt-get install -y make python python-pip -COPY tests/safety/requirements.txt /panda/tests/safety/requirements.txt -RUN pip install -r /panda/tests/safety/requirements.txt -COPY . /panda diff --git a/panda/tests/language/LICENSE b/panda/tests/language/LICENSE deleted file mode 100644 index 8dada3edaf50db..00000000000000 --- a/panda/tests/language/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/panda/tests/language/list.txt b/panda/tests/language/list.txt deleted file mode 100644 index cfd25897d8dc55..00000000000000 --- a/panda/tests/language/list.txt +++ /dev/null @@ -1,451 +0,0 @@ -4r5e -5h1t -5hit -a55 -anal -anus -ar5e -arrse -arse -ass -ass-fucker -asses -assfucker -assfukka -asshole -assholes -asswhole -a_s_s -b!tch -b00bs -b17ch -b1tch -ballbag -balls -ballsack -bastard -beastial -beastiality -bellend -bestial -bestiality -bi+ch -biatch -bitch -bitcher -bitchers -bitches -bitchin -bitching -bloody -blow job -blowjob -blowjobs -boiolas -bollock -bollok -boner -boob -boobs -booobs -boooobs -booooobs -booooooobs -breasts -buceta -bugger -bum -bunny fucker -bullshit -butt -butthole -buttmuch -buttplug -c0ck -c0cksucker -carpet muncher -cawk -chink -cipa -cl1t -clit -clitoris -clits -cnut -cock -cock-sucker -cockface -cockhead -cockmunch -cockmuncher -cocks -cocksuck -cocksucked -cocksucker -cocksucking -cocksucks -cocksuka -cocksukka -cok -cokmuncher -coksucka -coon -cox -crap -cum -cummer -cumming -cums -cumshot -cunilingus -cunillingus -cunnilingus -cunt -cuntlick -cuntlicker -cuntlicking -cunts -cyalis -cyberfuc -cyberfuck -cyberfucked -cyberfucker -cyberfuckers -cyberfucking -d1ck -damn -dick -dickhead -dildo -dildos -dink -dinks -dirsa -dlck -dog-fucker -doggin -dogging -donkeyribber -doosh -duche -dyke -ejaculate -ejaculated -ejaculates -ejaculating -ejaculatings -ejaculation -ejakulate -f u c k -f u c k e r -f4nny -fag -fagging -faggitt -faggot -faggs -fagot -fagots -fags -fanny -fannyflaps -fannyfucker -fanyy -fatass -fcuk -fcuker -fcuking -feck -fecker -felching -fellate -fellatio -fingerfuck -fingerfucked -fingerfucker -fingerfuckers -fingerfucking -fingerfucks -fistfuck -fistfucked -fistfucker -fistfuckers -fistfucking -fistfuckings -fistfucks -flange -fook -fooker -fuck -fucka -fucked -fucker -fuckers -fuckhead -fuckheads -fuckin -fucking -fuckings -fuckingshitmotherfucker -fuckme -fucks -fuckwhit -fuckwit -fudge packer -fudgepacker -fuk -fuker -fukker -fukkin -fuks -fukwhit -fukwit -fux -fux0r -f_u_c_k -gangbang -gangbanged -gangbangs -gaylord -gaysex -goatse -God -god-dam -god-damned -goddamn -goddamned -hardcoresex -hell -heshe -hoar -hoare -hoer -homo -hore -horniest -horny -hotsex -jack-off -jackoff -jap -jerk-off -jism -jiz -jizm -jizz -kawk -knob -knobead -knobed -knobend -knobhead -knobjocky -knobjokey -kock -kondum -kondums -kum -kummer -kumming -kums -kunilingus -l3i+ch -l3itch -labia -lmfao -lust -lusting -m0f0 -m0fo -m45terbate -ma5terb8 -ma5terbate -masochist -master-bate -masterb8 -masterbat* -masterbat3 -masterbate -masterbation -masterbations -masturbate -mo-fo -mof0 -mofo -mothafuck -mothafucka -mothafuckas -mothafuckaz -mothafucked -mothafucker -mothafuckers -mothafuckin -mothafucking -mothafuckings -mothafucks -mother fucker -motherfuck -motherfucked -motherfucker -motherfuckers -motherfuckin -motherfucking -motherfuckings -motherfuckka -motherfucks -muff -mutha -muthafecker -muthafuckker -muther -mutherfucker -n1gga -n1gger -nazi -nigg3r -nigg4h -nigga -niggah -niggas -niggaz -nigger -niggers -nob -nob jokey -nobhead -nobjocky -nobjokey -numbnuts -nutsack -orgasim -orgasims -orgasm -orgasms -p0rn -pawn -pecker -penis -penisfucker -phonesex -phuck -phuk -phuked -phuking -phukked -phukking -phuks -phuq -pigfucker -pimpis -piss -pissed -pisser -pissers -pisses -pissflaps -pissin -pissing -pissoff -poop -porn -porno -pornography -pornos -prick -pricks -pron -pube -pusse -pussi -pussies -pussy -pussys -rectum -retard -rimjaw -rimming -s hit -s.o.b. -sadist -schlong -screwing -scroat -scrote -scrotum -semen -sex -sh!+ -sh!t -sh1t -shag -shagger -shaggin -shagging -shemale -shi+ -shit -shitdick -shite -shited -shitey -shitfuck -shitfull -shithead -shiting -shitings -shits -shitted -shitter -shitters -shitting -shittings -shitty -skank -slut -sluts -smegma -smut -snatch -son-of-a-bitch -spac -spunk -s_h_i_t -t1tt1e5 -t1tties -teets -teez -testical -testicle -tit -titfuck -tits -titt -tittie5 -tittiefucker -titties -tittyfuck -tittywank -titwank -tosser -turd -tw4t -twat -twathead -twatty -twunt -twunter -v14gra -v1gra -vagina -viagra -vulva -w00se -wang -wank -wanker -wanky -whoar -whore -willies -willy -xrated diff --git a/panda/tests/language/test_language.py b/panda/tests/language/test_language.py deleted file mode 100755 index 3afb34619aa19f..00000000000000 --- a/panda/tests/language/test_language.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python - -import subprocess -import sys - -checked_ext = ["h", "c", "py", "pyx", "cpp", "hpp", "md", "mk"] - -if __name__ == "__main__": - with open("list.txt", 'r') as handle: - - suffix_cmd = " " - for i in checked_ext: - suffix_cmd += "--include \*." + i + " " - - found_bad_language = False - for line in handle: - line = line.rstrip('\n').rstrip(" ") - try: - cmd = "cd ../../; grep -R -i -w " + suffix_cmd + " '" + line + "'" - res = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) - print res - found_bad_language = True - except subprocess.CalledProcessError as e: - pass - if found_bad_language: - sys.exit("Failed: found bad language") - else: - print "Success" diff --git a/panda/tests/location_listener.py b/panda/tests/location_listener.py deleted file mode 100755 index cbbb00d794f5e3..00000000000000 --- a/panda/tests/location_listener.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python -import os -import time -import sys - -sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")) -from panda import Panda, PandaSerial - -def add_nmea_checksum(msg): - d = msg[1:] - cs = 0 - for i in d: - cs ^= ord(i) - return msg + "*%02X" % cs - -if __name__ == "__main__": - panda = Panda() - ser = PandaSerial(panda, 1, 9600) - - # power cycle by toggling reset - print "resetting" - panda.set_esp_power(0) - time.sleep(0.5) - panda.set_esp_power(1) - time.sleep(0.5) - print "done" - print ser.read(1024) - - # upping baud rate - baudrate = 460800 - - print "upping baud rate" - msg = add_nmea_checksum("$PUBX,41,1,0007,0003,%d,0" % baudrate)+"\r\n" - print msg - ser.write(msg) - time.sleep(0.1) # needs a wait for it to actually send - - # new panda serial - ser = PandaSerial(panda, 1, baudrate) - - while True: - ret = ser.read(1024) - if len(ret) > 0: - sys.stdout.write(ret) - sys.stdout.flush() - #print str(ret).encode("hex") - diff --git a/panda/tests/loopback_test.py b/panda/tests/loopback_test.py deleted file mode 100755 index a871295ad6fd83..00000000000000 --- a/panda/tests/loopback_test.py +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/env python -from __future__ import print_function -import os -import sys -import time -import random -import argparse - -from hexdump import hexdump -from itertools import permutations - -sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")) -from panda import Panda - -def get_test_string(): - return b"test"+os.urandom(10) - -def run_test(sleep_duration): - pandas = Panda.list() - print(pandas) - - if len(pandas) == 0: - print("NO PANDAS") - assert False - - if len(pandas) == 1: - # if we only have one on USB, assume the other is on wifi - pandas.append("WIFI") - run_test_w_pandas(pandas, sleep_duration) - -def run_test_w_pandas(pandas, sleep_duration): - h = list(map(lambda x: Panda(x), pandas)) - print("H", h) - - for hh in h: - hh.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - - # test both directions - for ho in permutations(range(len(h)), r=2): - print("***************** TESTING", ho) - - panda0, panda1 = h[ho[0]], h[ho[1]] - - if(panda0._serial == "WIFI"): - print(" *** Can not send can data over wifi panda. Skipping! ***") - continue - - # **** test health packet **** - print("health", ho[0], h[ho[0]].health()) - - # **** test K/L line loopback **** - for bus in [2,3]: - # flush the output - h[ho[1]].kline_drain(bus=bus) - - # send the characters - st = get_test_string() - st = b"\xaa"+chr(len(st)+3).encode()+st - h[ho[0]].kline_send(st, bus=bus, checksum=False) - - # check for receive - ret = h[ho[1]].kline_drain(bus=bus) - - print("ST Data:") - hexdump(st) - print("RET Data:") - hexdump(ret) - assert st == ret - print("K/L pass", bus, ho, "\n") - time.sleep(sleep_duration) - - # **** test can line loopback **** - for bus, gmlan in [(0, False), (1, False), (2, False), (1, True), (2, True)]: - print("\ntest can", bus) - # flush - cans_echo = panda0.can_recv() - cans_loop = panda1.can_recv() - - panda0.set_gmlan(None) - panda1.set_gmlan(None) - - if gmlan is True: - panda0.set_gmlan(bus) - panda1.set_gmlan(bus) - bus = 3 - - # send the characters - at = random.randint(1, 2000) - st = get_test_string()[0:8] - panda0.can_send(at, st, bus) - time.sleep(0.1) - - # check for receive - cans_echo = panda0.can_recv() - cans_loop = panda1.can_recv() - - print("Bus", bus, "echo", cans_echo, "loop", cans_loop) - - assert len(cans_echo) == 1 - assert len(cans_loop) == 1 - - assert cans_echo[0][0] == at - assert cans_loop[0][0] == at - - assert cans_echo[0][2] == st - assert cans_loop[0][2] == st - - assert cans_echo[0][3] == 0x80 | bus - if cans_loop[0][3] != bus: - print("EXPECTED %d GOT %d" % (bus, cans_loop[0][3])) - assert cans_loop[0][3] == bus - - print("CAN pass", bus, ho) - time.sleep(sleep_duration) - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument("-n", type=int, help="Number of test iterations to run") - parser.add_argument("-sleep", type=int, help="Sleep time between tests", default=0) - args = parser.parse_args() - - if args.n is None: - while True: - run_test(sleep_duration=args.sleep) - else: - for i in range(args.n): - run_test(sleep_duration=args.sleep) diff --git a/panda/tests/misra/Dockerfile b/panda/tests/misra/Dockerfile deleted file mode 100644 index e63cc7e9e151ed..00000000000000 --- a/panda/tests/misra/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM ubuntu:16.04 - -RUN apt-get update && apt-get install -y make python python-pip git -COPY tests/safety/requirements.txt /panda/tests/safety/requirements.txt -RUN pip install -r /panda/tests/safety/requirements.txt -COPY . /panda diff --git a/panda/tests/misra/suppressions.txt b/panda/tests/misra/suppressions.txt deleted file mode 100644 index 8e58b6e34024a4..00000000000000 --- a/panda/tests/misra/suppressions.txt +++ /dev/null @@ -1,8 +0,0 @@ -# Advisory: union types can be used -misra.19.2 -# FIXME: add it back when fixed in cppcheck. Macro identifiers are unique but it false triggers on defines in #ifdef..#else conditions -misra.5.4 -# Advisory: casting from void pointer to type pointer is ok. Done by STM libraries as well -misra.11.4 -# Advisory: casting from void pointer to type pointer is ok. Done by STM libraries as well -misra.11.5 diff --git a/panda/tests/misra/test_misra.sh b/panda/tests/misra/test_misra.sh deleted file mode 100755 index 6338009120b055..00000000000000 --- a/panda/tests/misra/test_misra.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -e - -mkdir /tmp/misra || true -git clone https://github.com/danmar/cppcheck.git || true -cd cppcheck -git fetch -git checkout 862c4ef87b109ae86c2d5f12769b7c8d199f35c5 -make -j4 -cd ../../../ - - -printf "\nPANDA CODE\n" -tests/misra/cppcheck/cppcheck -DPANDA -UPEDAL -DCAN3 -DUID_BASE -DEON \ - --suppressions-list=tests/misra/suppressions.txt \ - --dump --enable=all --inline-suppr --force \ - board/main.c 2>/tmp/misra/cppcheck_output.txt - -python tests/misra/cppcheck/addons/misra.py board/main.c.dump 2> /tmp/misra/misra_output.txt || true - -# strip (information) lines -cppcheck_output=$( cat /tmp/misra/cppcheck_output.txt | grep -v "(information) " ) || true -misra_output=$( cat /tmp/misra/misra_output.txt | grep -v "(information) " ) || true - - -printf "\nPEDAL CODE\n" -tests/misra/cppcheck/cppcheck -UPANDA -DPEDAL -UCAN3 \ - --suppressions-list=tests/misra/suppressions.txt \ - -I board/ --dump --enable=all --inline-suppr --force \ - board/pedal/main.c 2>/tmp/misra/cppcheck_pedal_output.txt - -python tests/misra/cppcheck/addons/misra.py board/pedal/main.c.dump 2> /tmp/misra/misra_pedal_output.txt || true - -# strip (information) lines -cppcheck_pedal_output=$( cat /tmp/misra/cppcheck_pedal_output.txt | grep -v "(information) " ) || true -misra_pedal_output=$( cat /tmp/misra/misra_pedal_output.txt | grep -v "(information) " ) || true - -if [[ -n "$misra_output" ]] || [[ -n "$cppcheck_output" ]] -then - echo "Failed! found Misra violations in panda code:" - echo "$misra_output" - echo "$cppcheck_output" - exit 1 -fi - -if [[ -n "$misra_pedal_output" ]] || [[ -n "$cppcheck_pedal_output" ]] -then - echo "Failed! found Misra violations in pedal code:" - echo "$misra_pedal_output" - echo "$cppcheck_pedal_output" - exit 1 -fi - -echo "Success" diff --git a/panda/tests/pedal/enter_canloader.py b/panda/tests/pedal/enter_canloader.py deleted file mode 100755 index c6f06ca35499a0..00000000000000 --- a/panda/tests/pedal/enter_canloader.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python -import sys -import time -import struct -import argparse -import signal -from panda import Panda - -class CanHandle(object): - def __init__(self, p): - self.p = p - - def transact(self, dat): - #print "W:",dat.encode("hex") - self.p.isotp_send(1, dat, 0, recvaddr=2) - - def _handle_timeout(signum, frame): - # will happen on reset - raise Exception("timeout") - - signal.signal(signal.SIGALRM, _handle_timeout) - signal.alarm(1) - try: - ret = self.p.isotp_recv(2, 0, sendaddr=1) - finally: - signal.alarm(0) - - #print "R:",ret.encode("hex") - return ret - - def controlWrite(self, request_type, request, value, index, data, timeout=0): - # ignore data in reply, panda doesn't use it - return self.controlRead(request_type, request, value, index, 0, timeout) - - def controlRead(self, request_type, request, value, index, length, timeout=0): - dat = struct.pack("HHBBHHH", 0, 0, request_type, request, value, index, length) - return self.transact(dat) - - def bulkWrite(self, endpoint, data, timeout=0): - if len(data) > 0x10: - raise ValueError("Data must not be longer than 0x10") - dat = struct.pack("HH", endpoint, len(data))+data - return self.transact(dat) - - def bulkRead(self, endpoint, length, timeout=0): - dat = struct.pack("HH", endpoint, 0) - return self.transact(dat) - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description='Flash pedal over can') - parser.add_argument('--recover', action='store_true') - parser.add_argument("fn", type=str, nargs='?', help="flash file") - args = parser.parse_args() - - p = Panda() - p.set_safety_mode(0x1337) - - while 1: - if len(p.can_recv()) == 0: - break - - if args.recover: - p.can_send(0x200, "\xce\xfa\xad\xde\x1e\x0b\xb0\x02", 0) - exit(0) - else: - p.can_send(0x200, "\xce\xfa\xad\xde\x1e\x0b\xb0\x0a", 0) - - if args.fn: - time.sleep(0.1) - print "flashing", args.fn - code = open(args.fn).read() - Panda.flash_static(CanHandle(p), code) - - print "can flash done" - - diff --git a/panda/tests/pedal/enter_canloader_tesla.py b/panda/tests/pedal/enter_canloader_tesla.py deleted file mode 100755 index b293b3fb23e4b3..00000000000000 --- a/panda/tests/pedal/enter_canloader_tesla.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python -import sys -import time -import struct -import argparse -import signal -from panda import Panda - -class CanHandle(object): - def __init__(self, p): - self.p = p - - def transact(self, dat): - #print "W:",dat.encode("hex") - self.p.isotp_send(1, dat, 2, recvaddr=2) - - def _handle_timeout(signum, frame): - # will happen on reset - raise Exception("timeout") - - signal.signal(signal.SIGALRM, _handle_timeout) - signal.alarm(1) - try: - ret = self.p.isotp_recv(2, 2, sendaddr=1) - finally: - signal.alarm(0) - - #print "R:",ret.encode("hex") - return ret - - def controlWrite(self, request_type, request, value, index, data, timeout=0): - # ignore data in reply, panda doesn't use it - return self.controlRead(request_type, request, value, index, 0, timeout) - - def controlRead(self, request_type, request, value, index, length, timeout=0): - dat = struct.pack("HHBBHHH", 0, 0, request_type, request, value, index, length) - return self.transact(dat) - - def bulkWrite(self, endpoint, data, timeout=0): - if len(data) > 0x10: - raise ValueError("Data must not be longer than 0x10") - dat = struct.pack("HH", endpoint, len(data))+data - return self.transact(dat) - - def bulkRead(self, endpoint, length, timeout=0): - dat = struct.pack("HH", endpoint, 0) - return self.transact(dat) - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description='Flash pedal over can') - parser.add_argument('--recover', action='store_true') - parser.add_argument("fn", type=str, nargs='?', help="flash file") - args = parser.parse_args() - - p = Panda() - p.set_safety_mode(0x1337) - - while 1: - if len(p.can_recv()) == 0: - break - - if args.recover: - p.can_send(0x551, "\xce\xfa\xad\xde\x1e\x0b\xb0\x02", 2) - exit(0) - else: - p.can_send(0x551, "\xce\xfa\xad\xde\x1e\x0b\xb0\x0a", 2) - - if args.fn: - time.sleep(0.1) - print "flashing", args.fn - code = open(args.fn).read() - Panda.flash_static(CanHandle(p), code) - - print "can flash done" - - diff --git a/panda/tests/read_st_flash.sh b/panda/tests/read_st_flash.sh deleted file mode 100755 index ffcfd7bbfe725b..00000000000000 --- a/panda/tests/read_st_flash.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -rm -f /tmp/dump_bootstub -rm -f /tmp/dump_main -dfu-util -a 0 -s 0x08000000 -U /tmp/dump_bootstub -dfu-util -a 0 -s 0x08004000 -U /tmp/dump_main - diff --git a/panda/tests/read_winusb_descriptors.py b/panda/tests/read_winusb_descriptors.py deleted file mode 100644 index e38df8d1caa9c3..00000000000000 --- a/panda/tests/read_winusb_descriptors.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python -from panda import Panda -from hexdump import hexdump - -DEBUG = False - -if __name__ == "__main__": - p = Panda() - - len = p._handle.controlRead(Panda.REQUEST_IN, 0x06, 3 << 8 | 238, 0, 1) - print 'Microsoft OS String Descriptor' - dat = p._handle.controlRead(Panda.REQUEST_IN, 0x06, 3 << 8 | 238, 0, len[0]) - if DEBUG: print 'LEN: {}'.format(hex(len[0])) - hexdump("".join(map(chr, dat))) - - ms_vendor_code = dat[16] - if DEBUG: print 'MS_VENDOR_CODE: {}'.format(hex(len[0])) - - print '\nMicrosoft Compatible ID Feature Descriptor' - len = p._handle.controlRead(Panda.REQUEST_IN, ms_vendor_code, 0, 4, 1) - if DEBUG: print 'LEN: {}'.format(hex(len[0])) - dat = p._handle.controlRead(Panda.REQUEST_IN, ms_vendor_code, 0, 4, len[0]) - hexdump("".join(map(chr, dat))) - - print '\nMicrosoft Extended Properties Feature Descriptor' - len = p._handle.controlRead(Panda.REQUEST_IN, ms_vendor_code, 0, 5, 1) - if DEBUG: print 'LEN: {}'.format(hex(len[0])) - dat = p._handle.controlRead(Panda.REQUEST_IN, ms_vendor_code, 0, 5, len[0]) - hexdump("".join(map(chr, dat))) diff --git a/panda/tests/safety/Dockerfile b/panda/tests/safety/Dockerfile deleted file mode 100644 index 9381fdc4085759..00000000000000 --- a/panda/tests/safety/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM ubuntu:16.04 - -RUN apt-get update && apt-get install -y clang make python python-pip -COPY tests/safety/requirements.txt /panda/tests/safety/requirements.txt -RUN pip install -r /panda/tests/safety/requirements.txt -COPY . /panda diff --git a/panda/tests/safety/Makefile b/panda/tests/safety/Makefile deleted file mode 100644 index 334a29427d7d29..00000000000000 --- a/panda/tests/safety/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -CC = clang -CCFLAGS = -O3 -fPIC -DPANDA -I. - -.PHONY: all -all: libpandasafety.so - -libpandasafety.so: test.o - $(CC) -shared -o '$@' $^ -lm - -test.o: test.c - @echo "[ CC ] $@" - $(CC) $(CCFLAGS) -MMD -c -I../../board -o '$@' '$<' - -.PHONY: clean -clean: - rm -f libpandasafety.so test.o test.d - --include test.d diff --git a/panda/tests/safety/libpandasafety_py.py b/panda/tests/safety/libpandasafety_py.py deleted file mode 100644 index 888bd36e948758..00000000000000 --- a/panda/tests/safety/libpandasafety_py.py +++ /dev/null @@ -1,99 +0,0 @@ -import os -import subprocess - -from cffi import FFI - -can_dir = os.path.dirname(os.path.abspath(__file__)) -libpandasafety_fn = os.path.join(can_dir, "libpandasafety.so") -subprocess.check_call(["make"], cwd=can_dir) - -ffi = FFI() -ffi.cdef(""" -typedef struct -{ - uint32_t TIR; /*!< CAN TX mailbox identifier register */ - uint32_t TDTR; /*!< CAN mailbox data length control and time stamp register */ - uint32_t TDLR; /*!< CAN mailbox data low register */ - uint32_t TDHR; /*!< CAN mailbox data high register */ -} CAN_TxMailBox_TypeDef; - -typedef struct -{ - uint32_t RIR; /*!< CAN receive FIFO mailbox identifier register */ - uint32_t RDTR; /*!< CAN receive FIFO mailbox data length control and time stamp register */ - uint32_t RDLR; /*!< CAN receive FIFO mailbox data low register */ - uint32_t RDHR; /*!< CAN receive FIFO mailbox data high register */ -} CAN_FIFOMailBox_TypeDef; - -typedef struct -{ - uint32_t CNT; -} TIM_TypeDef; - -void set_controls_allowed(bool c); -bool get_controls_allowed(void); -void set_long_controls_allowed(bool c); -bool get_long_controls_allowed(void); -void set_gas_interceptor_detected(bool c); -bool get_gas_interceptor_detetcted(void); -int get_gas_interceptor_prev(void); -int get_hw_type(void); -void set_timer(uint32_t t); -void reset_angle_control(void); - -void safety_rx_hook(CAN_FIFOMailBox_TypeDef *to_send); -int safety_tx_hook(CAN_FIFOMailBox_TypeDef *to_push); -int safety_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd); -int safety_set_mode(uint16_t mode, int16_t param); - -void init_tests_toyota(void); -int get_toyota_torque_meas_min(void); -int get_toyota_torque_meas_max(void); -int get_toyota_gas_prev(void); -void set_toyota_torque_meas(int min, int max); -void set_toyota_desired_torque_last(int t); -void set_toyota_camera_forwarded(int t); -void set_toyota_rt_torque_last(int t); - -void init_tests_honda(void); -bool get_honda_moving(void); -int get_honda_brake_prev(void); -int get_honda_gas_prev(void); -void set_honda_alt_brake_msg(bool); -void set_honda_bosch_hardware(bool); -int get_honda_bosch_hardware(void); - -void init_tests_cadillac(void); -void set_cadillac_desired_torque_last(int t); -void set_cadillac_rt_torque_last(int t); -void set_cadillac_torque_driver(int min, int max); - -void init_tests_gm(void); -void set_gm_desired_torque_last(int t); -void set_gm_rt_torque_last(int t); -void set_gm_torque_driver(int min, int max); - -void init_tests_hyundai(void); -void set_hyundai_desired_torque_last(int t); -void set_hyundai_rt_torque_last(int t); -void set_hyundai_torque_driver(int min, int max); -void set_hyundai_giraffe_switch_2(int t); -void set_hyundai_camera_bus(int t); - -void init_tests_chrysler(void); -void set_chrysler_desired_torque_last(int t); -void set_chrysler_rt_torque_last(int t); -void set_chrysler_camera_detected(int t); -int get_chrysler_torque_meas_min(void); -int get_chrysler_torque_meas_max(void); -void set_chrysler_torque_meas(int min, int max); - -void init_tests_subaru(void); -void set_subaru_desired_torque_last(int t); -void set_subaru_rt_torque_last(int t); -void set_subaru_torque_driver(int min, int max); - - -""") - -libpandasafety = ffi.dlopen(libpandasafety_fn) diff --git a/panda/tests/safety/requirements.txt b/panda/tests/safety/requirements.txt deleted file mode 100644 index 8bbfb1d7df38a2..00000000000000 --- a/panda/tests/safety/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -cffi==1.11.4 -numpy==1.14.1 diff --git a/panda/tests/safety/test.c b/panda/tests/safety/test.c deleted file mode 100644 index 7cd9b86d86f9a0..00000000000000 --- a/panda/tests/safety/test.c +++ /dev/null @@ -1,330 +0,0 @@ -#include -#include -#include - -typedef struct -{ - uint32_t TIR; /*!< CAN TX mailbox identifier register */ - uint32_t TDTR; /*!< CAN mailbox data length control and time stamp register */ - uint32_t TDLR; /*!< CAN mailbox data low register */ - uint32_t TDHR; /*!< CAN mailbox data high register */ -} CAN_TxMailBox_TypeDef; - -typedef struct -{ - uint32_t RIR; /*!< CAN receive FIFO mailbox identifier register */ - uint32_t RDTR; /*!< CAN receive FIFO mailbox data length control and time stamp register */ - uint32_t RDLR; /*!< CAN receive FIFO mailbox data low register */ - uint32_t RDHR; /*!< CAN receive FIFO mailbox data high register */ -} CAN_FIFOMailBox_TypeDef; - -typedef struct -{ - uint32_t CNT; -} TIM_TypeDef; - -struct sample_t toyota_torque_meas; -struct sample_t cadillac_torque_driver; -struct sample_t gm_torque_driver; -struct sample_t hyundai_torque_driver; -struct sample_t chrysler_torque_meas; -struct sample_t subaru_torque_driver; - -TIM_TypeDef timer; -TIM_TypeDef *TIM2 = &timer; - -// from config.h -#define MIN(a,b) \ - ({ __typeof__ (a) _a = (a); \ - __typeof__ (b) _b = (b); \ - _a < _b ? _a : _b; }) - -#define MAX(a,b) \ - ({ __typeof__ (a) _a = (a); \ - __typeof__ (b) _b = (b); \ - _a > _b ? _a : _b; }) - -// from llcan.h -#define GET_BUS(msg) (((msg)->RDTR >> 4) & 0xFF) -#define GET_LEN(msg) ((msg)->RDTR & 0xf) -#define GET_ADDR(msg) ((((msg)->RIR & 4) != 0) ? ((msg)->RIR >> 3) : ((msg)->RIR >> 21)) -#define GET_BYTE(msg, b) (((int)(b) > 3) ? (((msg)->RDHR >> (8U * ((unsigned int)(b) % 4U))) & 0XFFU) : (((msg)->RDLR >> (8U * (unsigned int)(b))) & 0xFFU)) -#define GET_BYTES_04(msg) ((msg)->RDLR) -#define GET_BYTES_48(msg) ((msg)->RDHR) - -// from board_declarations.h -#define HW_TYPE_UNKNOWN 0U -#define HW_TYPE_WHITE_PANDA 1U -#define HW_TYPE_GREY_PANDA 2U -#define HW_TYPE_BLACK_PANDA 3U -#define HW_TYPE_PEDAL 4U - -// from main_declarations.h -uint8_t hw_type = 0U; - -#define UNUSED(x) (void)(x) - -#define PANDA -#define NULL ((void*)0) -#define static -#include "safety.h" - -void set_controls_allowed(bool c){ - controls_allowed = c; -} - -void set_long_controls_allowed(bool c){ - long_controls_allowed = c; -} - -void set_gas_interceptor_detected(bool c){ - gas_interceptor_detected = c; -} - -void reset_angle_control(void){ - angle_control = 0; -} - -bool get_controls_allowed(void){ - return controls_allowed; -} - -bool get_long_controls_allowed(void){ - return long_controls_allowed; -} - -bool get_gas_interceptor_detected(void){ - return gas_interceptor_detected; -} - -int get_gas_interceptor_prev(void){ - return gas_interceptor_prev; -} - -int get_hw_type(void){ - return hw_type; -} - -void set_timer(uint32_t t){ - timer.CNT = t; -} - -void set_toyota_camera_forwarded(int t){ - toyota_camera_forwarded = t; -} - -void set_toyota_torque_meas(int min, int max){ - toyota_torque_meas.min = min; - toyota_torque_meas.max = max; -} - -void set_cadillac_torque_driver(int min, int max){ - cadillac_torque_driver.min = min; - cadillac_torque_driver.max = max; -} - -void set_gm_torque_driver(int min, int max){ - gm_torque_driver.min = min; - gm_torque_driver.max = max; -} - -void set_hyundai_torque_driver(int min, int max){ - hyundai_torque_driver.min = min; - hyundai_torque_driver.max = max; -} - -void set_hyundai_camera_bus(int t){ - hyundai_camera_bus = t; -} - -void set_hyundai_giraffe_switch_2(int t){ - hyundai_giraffe_switch_2 = t; -} - -void set_chrysler_camera_detected(int t){ - chrysler_camera_detected = t; -} - -void set_chrysler_torque_meas(int min, int max){ - chrysler_torque_meas.min = min; - chrysler_torque_meas.max = max; -} - -void set_subaru_torque_driver(int min, int max){ - subaru_torque_driver.min = min; - subaru_torque_driver.max = max; -} - -int get_chrysler_torque_meas_min(void){ - return chrysler_torque_meas.min; -} - -int get_chrysler_torque_meas_max(void){ - return chrysler_torque_meas.max; -} - -int get_toyota_gas_prev(void){ - return toyota_gas_prev; -} - -int get_toyota_torque_meas_min(void){ - return toyota_torque_meas.min; -} - -int get_toyota_torque_meas_max(void){ - return toyota_torque_meas.max; -} - -void set_toyota_rt_torque_last(int t){ - toyota_rt_torque_last = t; -} - -void set_cadillac_rt_torque_last(int t){ - cadillac_rt_torque_last = t; -} - -void set_gm_rt_torque_last(int t){ - gm_rt_torque_last = t; -} - -void set_hyundai_rt_torque_last(int t){ - hyundai_rt_torque_last = t; -} - -void set_chrysler_rt_torque_last(int t){ - chrysler_rt_torque_last = t; -} - -void set_subaru_rt_torque_last(int t){ - subaru_rt_torque_last = t; -} - -void set_toyota_desired_torque_last(int t){ - toyota_desired_torque_last = t; -} - -void set_cadillac_desired_torque_last(int t){ - for (int i = 0; i < 4; i++) cadillac_desired_torque_last[i] = t; -} - -void set_gm_desired_torque_last(int t){ - gm_desired_torque_last = t; -} - -void set_hyundai_desired_torque_last(int t){ - hyundai_desired_torque_last = t; -} - -void set_chrysler_desired_torque_last(int t){ - chrysler_desired_torque_last = t; -} - -void set_subaru_desired_torque_last(int t){ - subaru_desired_torque_last = t; -} - -bool get_honda_moving(void){ - return honda_moving; -} - -int get_honda_brake_prev(void){ - return honda_brake_prev; -} - -int get_honda_gas_prev(void){ - return honda_gas_prev; -} - -void set_honda_alt_brake_msg(bool c){ - honda_alt_brake_msg = c; -} - -void set_honda_bosch_hardware(bool c){ - honda_bosch_hardware = c; -} - -int get_honda_bosch_hardware(void) { - return honda_bosch_hardware; -} - -void init_tests(void){ - // get HW_TYPE from env variable set in test.sh - hw_type = atoi(getenv("HW_TYPE")); -} - -void init_tests_toyota(void){ - init_tests(); - toyota_torque_meas.min = 0; - toyota_torque_meas.max = 0; - toyota_desired_torque_last = 0; - toyota_rt_torque_last = 0; - toyota_ts_last = 0; - set_timer(0); -} - -void init_tests_cadillac(void){ - init_tests(); - cadillac_torque_driver.min = 0; - cadillac_torque_driver.max = 0; - for (int i = 0; i < 4; i++) cadillac_desired_torque_last[i] = 0; - cadillac_rt_torque_last = 0; - cadillac_ts_last = 0; - set_timer(0); -} - -void init_tests_gm(void){ - init_tests(); - gm_torque_driver.min = 0; - gm_torque_driver.max = 0; - gm_desired_torque_last = 0; - gm_rt_torque_last = 0; - gm_ts_last = 0; - set_timer(0); -} - -void init_tests_hyundai(void){ - init_tests(); - hyundai_torque_driver.min = 0; - hyundai_torque_driver.max = 0; - hyundai_desired_torque_last = 0; - hyundai_rt_torque_last = 0; - hyundai_ts_last = 0; - set_timer(0); -} - -void init_tests_chrysler(void){ - init_tests(); - chrysler_torque_meas.min = 0; - chrysler_torque_meas.max = 0; - chrysler_desired_torque_last = 0; - chrysler_rt_torque_last = 0; - chrysler_ts_last = 0; - set_timer(0); -} - -void init_tests_subaru(void){ - init_tests(); - subaru_torque_driver.min = 0; - subaru_torque_driver.max = 0; - subaru_desired_torque_last = 0; - subaru_rt_torque_last = 0; - subaru_ts_last = 0; - set_timer(0); -} - -void init_tests_honda(void){ - init_tests(); - honda_moving = false; - honda_brake_prev = 0; - honda_gas_prev = 0; -} - -void set_gmlan_digital_output(int to_set){ -} - -void reset_gmlan_switch_timeout(void){ -} - -void gmlan_switch_init(int timeout_enable){ -} - diff --git a/panda/tests/safety/test.sh b/panda/tests/safety/test.sh deleted file mode 100755 index 2674281addd9f4..00000000000000 --- a/panda/tests/safety/test.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env sh - -# Loop over all hardware types: -# HW_TYPE_UNKNOWN 0U -# HW_TYPE_WHITE_PANDA 1U -# HW_TYPE_GREY_PANDA 2U -# HW_TYPE_BLACK_PANDA 3U -# HW_TYPE_PEDAL 4U - -# Make sure test fails if one HW_TYPE fails -set -e - -for hw_type in 0 1 2 3 4 -do - echo "Testing HW_TYPE: $hw_type" - HW_TYPE=$hw_type python -m unittest discover . -done diff --git a/panda/tests/safety/test_cadillac.py b/panda/tests/safety/test_cadillac.py deleted file mode 100644 index af89e69cc7710e..00000000000000 --- a/panda/tests/safety/test_cadillac.py +++ /dev/null @@ -1,196 +0,0 @@ -#!/usr/bin/env python2 -import unittest -import numpy as np -import libpandasafety_py - -MAX_RATE_UP = 2 -MAX_RATE_DOWN = 5 -MAX_TORQUE = 150 - -MAX_RT_DELTA = 75 -RT_INTERVAL = 250000 - -DRIVER_TORQUE_ALLOWANCE = 50; -DRIVER_TORQUE_FACTOR = 4; - -IPAS_OVERRIDE_THRESHOLD = 200 - -def twos_comp(val, bits): - if val >= 0: - return val - else: - return (2**bits) + val - -def sign(a): - if a > 0: - return 1 - else: - return -1 - -class TestCadillacSafety(unittest.TestCase): - @classmethod - def setUp(cls): - cls.safety = libpandasafety_py.libpandasafety - cls.safety.safety_set_mode(6, 0) - cls.safety.init_tests_cadillac() - - def _send_msg(self, bus, addr, length): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = addr << 21 - to_send[0].RDTR = length - to_send[0].RDTR = bus << 4 - return to_send - - def _set_prev_torque(self, t): - self.safety.set_cadillac_desired_torque_last(t) - self.safety.set_cadillac_rt_torque_last(t) - - def _torque_driver_msg(self, torque): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0x164 << 21 - - t = twos_comp(torque, 11) - to_send[0].RDLR = ((t >> 8) & 0x7) | ((t & 0xFF) << 8) - return to_send - - def _torque_msg(self, torque): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0x151 << 21 - - t = twos_comp(torque, 14) - to_send[0].RDLR = ((t >> 8) & 0x3F) | ((t & 0xFF) << 8) - return to_send - - def test_default_controls_not_allowed(self): - self.assertFalse(self.safety.get_controls_allowed()) - - def test_manually_enable_controls_allowed(self): - self.safety.set_controls_allowed(1) - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.set_controls_allowed(0) - - def test_enable_control_allowed_from_cruise(self): - to_push = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_push[0].RIR = 0x370 << 21 - to_push[0].RDLR = 0x800000 - to_push[0].RDTR = 0 - - self.safety.safety_rx_hook(to_push) - self.assertTrue(self.safety.get_controls_allowed()) - - def test_disable_control_allowed_from_cruise(self): - to_push = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_push[0].RIR = 0x370 << 21 - to_push[0].RDLR = 0 - to_push[0].RDTR = 0 - - self.safety.set_controls_allowed(1) - self.safety.safety_rx_hook(to_push) - self.assertFalse(self.safety.get_controls_allowed()) - - def test_torque_absolute_limits(self): - for controls_allowed in [True, False]: - for torque in np.arange(-MAX_TORQUE - 1000, MAX_TORQUE + 1000, MAX_RATE_UP): - self.safety.set_controls_allowed(controls_allowed) - self.safety.set_cadillac_rt_torque_last(torque) - self.safety.set_cadillac_torque_driver(0, 0) - self.safety.set_cadillac_desired_torque_last(torque - MAX_RATE_UP) - - if controls_allowed: - send = (-MAX_TORQUE <= torque <= MAX_TORQUE) - else: - send = torque == 0 - - self.assertEqual(send, self.safety.safety_tx_hook(self._torque_msg(torque))) - - def test_non_realtime_limit_up(self): - self.safety.set_cadillac_torque_driver(0, 0) - self.safety.set_controls_allowed(True) - - self._set_prev_torque(0) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(MAX_RATE_UP))) - self._set_prev_torque(0) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(-MAX_RATE_UP))) - - self._set_prev_torque(0) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(MAX_RATE_UP + 1))) - self.safety.set_controls_allowed(True) - self._set_prev_torque(0) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(-MAX_RATE_UP - 1))) - - def test_non_realtime_limit_down(self): - self.safety.set_cadillac_torque_driver(0, 0) - self.safety.set_controls_allowed(True) - - def test_exceed_torque_sensor(self): - self.safety.set_controls_allowed(True) - - for sign in [-1, 1]: - for t in np.arange(0, DRIVER_TORQUE_ALLOWANCE + 1, 1): - t *= -sign - self.safety.set_cadillac_torque_driver(t, t) - self._set_prev_torque(MAX_TORQUE * sign) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(MAX_TORQUE * sign))) - - self.safety.set_cadillac_torque_driver(DRIVER_TORQUE_ALLOWANCE + 1, DRIVER_TORQUE_ALLOWANCE + 1) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(-MAX_TORQUE))) - - # spot check some individual cases - for sign in [-1, 1]: - driver_torque = (DRIVER_TORQUE_ALLOWANCE + 10) * sign - torque_desired = (MAX_TORQUE - 10 * DRIVER_TORQUE_FACTOR) * sign - delta = 1 * sign - self._set_prev_torque(torque_desired) - self.safety.set_cadillac_torque_driver(-driver_torque, -driver_torque) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(torque_desired))) - self._set_prev_torque(torque_desired + delta) - self.safety.set_cadillac_torque_driver(-driver_torque, -driver_torque) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(torque_desired + delta))) - - self._set_prev_torque(MAX_TORQUE * sign) - self.safety.set_cadillac_torque_driver(-MAX_TORQUE * sign, -MAX_TORQUE * sign) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg((MAX_TORQUE - MAX_RATE_DOWN) * sign))) - self._set_prev_torque(MAX_TORQUE * sign) - self.safety.set_cadillac_torque_driver(-MAX_TORQUE * sign, -MAX_TORQUE * sign) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(0))) - self._set_prev_torque(MAX_TORQUE * sign) - self.safety.set_cadillac_torque_driver(-MAX_TORQUE * sign, -MAX_TORQUE * sign) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg((MAX_TORQUE - MAX_RATE_DOWN + 1) * sign))) - - - def test_realtime_limits(self): - self.safety.set_controls_allowed(True) - - for sign in [-1, 1]: - self.safety.init_tests_cadillac() - self._set_prev_torque(0) - self.safety.set_cadillac_torque_driver(0, 0) - for t in np.arange(0, MAX_RT_DELTA, 1): - t *= sign - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(sign * (MAX_RT_DELTA + 1)))) - - self._set_prev_torque(0) - for t in np.arange(0, MAX_RT_DELTA, 1): - t *= sign - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) - - # Increase timer to update rt_torque_last - self.safety.set_timer(RT_INTERVAL + 1) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(sign * (MAX_RT_DELTA - 1)))) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(sign * (MAX_RT_DELTA + 1)))) - - - def test_fwd_hook(self): - # nothing allowed - buss = range(0x0, 0x3) - msgs = range(0x1, 0x800) - - for b in buss: - for m in msgs: - # assume len 8 - self.assertEqual(-1, self.safety.safety_fwd_hook(b, self._send_msg(b, m, 8))) - - -if __name__ == "__main__": - unittest.main() diff --git a/panda/tests/safety/test_chrysler.py b/panda/tests/safety/test_chrysler.py deleted file mode 100755 index 09aa424dd99b28..00000000000000 --- a/panda/tests/safety/test_chrysler.py +++ /dev/null @@ -1,208 +0,0 @@ -#!/usr/bin/env python2 -import csv -import glob -import unittest -import numpy as np -import libpandasafety_py - -MAX_RATE_UP = 3 -MAX_RATE_DOWN = 3 -MAX_STEER = 261 - -MAX_RT_DELTA = 112 -RT_INTERVAL = 250000 - -MAX_TORQUE_ERROR = 80 - -def twos_comp(val, bits): - if val >= 0: - return val - else: - return (2**bits) + val - -def sign(a): - if a > 0: - return 1 - else: - return -1 - -def swap_bytes(data_str): - """Accepts string with hex, returns integer with order swapped for CAN.""" - a = int(data_str, 16) - return ((a & 0xff) << 24) + ((a & 0xff00) << 8) + ((a & 0x00ff0000) >> 8) + ((a & 0xff000000) >> 24) - -class TestChryslerSafety(unittest.TestCase): - @classmethod - def setUp(cls): - cls.safety = libpandasafety_py.libpandasafety - cls.safety.safety_set_mode(9, 0) - cls.safety.init_tests_chrysler() - - def _send_msg(self, bus, addr, length): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = addr << 21 - to_send[0].RDTR = length - to_send[0].RDTR = bus << 4 - return to_send - - def _button_msg(self, buttons): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 1265 << 21 - to_send[0].RDLR = buttons - return to_send - - def _set_prev_torque(self, t): - self.safety.set_chrysler_desired_torque_last(t) - self.safety.set_chrysler_rt_torque_last(t) - self.safety.set_chrysler_torque_meas(t, t) - - def _torque_meas_msg(self, torque): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 544 << 21 - to_send[0].RDHR = ((torque + 1024) >> 8) + (((torque + 1024) & 0xff) << 8) - return to_send - - def _torque_msg(self, torque): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0x292 << 21 - to_send[0].RDLR = ((torque + 1024) >> 8) + (((torque + 1024) & 0xff) << 8) - return to_send - - def test_default_controls_not_allowed(self): - self.assertFalse(self.safety.get_controls_allowed()) - - def test_steer_safety_check(self): - for enabled in [0, 1]: - for t in range(-MAX_STEER*2, MAX_STEER*2): - self.safety.set_controls_allowed(enabled) - self._set_prev_torque(t) - if abs(t) > MAX_STEER or (not enabled and abs(t) > 0): - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(t))) - else: - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) - - def test_manually_enable_controls_allowed(self): - self.safety.set_controls_allowed(1) - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.set_controls_allowed(0) - self.assertFalse(self.safety.get_controls_allowed()) - - def test_enable_control_allowed_from_cruise(self): - to_push = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_push[0].RIR = 0x1f4 << 21 - to_push[0].RDLR = 0x380000 - - self.safety.safety_rx_hook(to_push) - self.assertTrue(self.safety.get_controls_allowed()) - - def test_disable_control_allowed_from_cruise(self): - to_push = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_push[0].RIR = 0x1f4 << 21 - to_push[0].RDLR = 0 - - self.safety.set_controls_allowed(1) - self.safety.safety_rx_hook(to_push) - self.assertFalse(self.safety.get_controls_allowed()) - - def test_non_realtime_limit_up(self): - self.safety.set_controls_allowed(True) - - self._set_prev_torque(0) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(MAX_RATE_UP))) - - self._set_prev_torque(0) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(MAX_RATE_UP + 1))) - - def test_non_realtime_limit_down(self): - self.safety.set_controls_allowed(True) - - self.safety.set_chrysler_rt_torque_last(MAX_STEER) - torque_meas = MAX_STEER - MAX_TORQUE_ERROR - 20 - self.safety.set_chrysler_torque_meas(torque_meas, torque_meas) - self.safety.set_chrysler_desired_torque_last(MAX_STEER) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(MAX_STEER - MAX_RATE_DOWN))) - - self.safety.set_chrysler_rt_torque_last(MAX_STEER) - self.safety.set_chrysler_torque_meas(torque_meas, torque_meas) - self.safety.set_chrysler_desired_torque_last(MAX_STEER) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(MAX_STEER - MAX_RATE_DOWN + 1))) - - def test_exceed_torque_sensor(self): - self.safety.set_controls_allowed(True) - - for sign in [-1, 1]: - self._set_prev_torque(0) - for t in np.arange(0, MAX_TORQUE_ERROR + 2, 2): # step needs to be smaller than MAX_TORQUE_ERROR - t *= sign - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) - - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(sign * (MAX_TORQUE_ERROR + 2)))) - - def test_realtime_limit_up(self): - self.safety.set_controls_allowed(True) - - for sign in [-1, 1]: - self.safety.init_tests_chrysler() - self._set_prev_torque(0) - for t in np.arange(0, MAX_RT_DELTA+1, 1): - t *= sign - self.safety.set_chrysler_torque_meas(t, t) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(sign * (MAX_RT_DELTA + 1)))) - - self._set_prev_torque(0) - for t in np.arange(0, MAX_RT_DELTA+1, 1): - t *= sign - self.safety.set_chrysler_torque_meas(t, t) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) - - # Increase timer to update rt_torque_last - self.safety.set_timer(RT_INTERVAL + 1) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(sign * MAX_RT_DELTA))) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(sign * (MAX_RT_DELTA + 1)))) - - def test_torque_measurements(self): - self.safety.safety_rx_hook(self._torque_meas_msg(50)) - self.safety.safety_rx_hook(self._torque_meas_msg(-50)) - self.safety.safety_rx_hook(self._torque_meas_msg(0)) - self.safety.safety_rx_hook(self._torque_meas_msg(0)) - self.safety.safety_rx_hook(self._torque_meas_msg(0)) - self.safety.safety_rx_hook(self._torque_meas_msg(0)) - - self.assertEqual(-50, self.safety.get_chrysler_torque_meas_min()) - self.assertEqual(50, self.safety.get_chrysler_torque_meas_max()) - - self.safety.safety_rx_hook(self._torque_meas_msg(0)) - self.assertEqual(0, self.safety.get_chrysler_torque_meas_max()) - self.assertEqual(-50, self.safety.get_chrysler_torque_meas_min()) - - self.safety.safety_rx_hook(self._torque_meas_msg(0)) - self.assertEqual(0, self.safety.get_chrysler_torque_meas_max()) - self.assertEqual(0, self.safety.get_chrysler_torque_meas_min()) - - def test_fwd_hook(self): - buss = range(0x0, 0x3) - msgs = range(0x1, 0x800) - chrysler_camera_detected = [0, 1] - - for ccd in chrysler_camera_detected: - self.safety.set_chrysler_camera_detected(ccd) - blocked_msgs = [658, 678] - for b in buss: - for m in msgs: - if not ccd: - if b == 0: - fwd_bus = 2 - elif b == 1: - fwd_bus = -1 - elif b == 2: - fwd_bus = -1 if m in blocked_msgs else 0 - else: - fwd_bus = -1 - - # assume len 8 - self.assertEqual(fwd_bus, self.safety.safety_fwd_hook(b, self._send_msg(b, m, 8))) - - -if __name__ == "__main__": - unittest.main() diff --git a/panda/tests/safety/test_gm.py b/panda/tests/safety/test_gm.py deleted file mode 100644 index d9a1d39ec76dd3..00000000000000 --- a/panda/tests/safety/test_gm.py +++ /dev/null @@ -1,295 +0,0 @@ -#!/usr/bin/env python2 -import unittest -import numpy as np -import libpandasafety_py - -MAX_RATE_UP = 7 -MAX_RATE_DOWN = 17 -MAX_STEER = 300 -MAX_BRAKE = 350 -MAX_GAS = 3072 -MAX_REGEN = 1404 - -MAX_RT_DELTA = 128 -RT_INTERVAL = 250000 - -DRIVER_TORQUE_ALLOWANCE = 50; -DRIVER_TORQUE_FACTOR = 4; - -def twos_comp(val, bits): - if val >= 0: - return val - else: - return (2**bits) + val - -def sign(a): - if a > 0: - return 1 - else: - return -1 - -class TestGmSafety(unittest.TestCase): - @classmethod - def setUp(cls): - cls.safety = libpandasafety_py.libpandasafety - cls.safety.safety_set_mode(3, 0) - cls.safety.init_tests_gm() - - def _send_msg(self, bus, addr, length): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = addr << 21 - to_send[0].RDTR = length - to_send[0].RDTR = bus << 4 - return to_send - - def _speed_msg(self, speed): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 842 << 21 - to_send[0].RDLR = speed - return to_send - - def _button_msg(self, buttons): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 481 << 21 - to_send[0].RDHR = buttons << 12 - return to_send - - def _brake_msg(self, brake): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 241 << 21 - to_send[0].RDLR = 0xa00 if brake else 0x900 - return to_send - - def _gas_msg(self, gas): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 417 << 21 - to_send[0].RDHR = (1 << 16) if gas else 0 - return to_send - - def _send_brake_msg(self, brake): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 789 << 21 - brake = (-brake) & 0xfff - to_send[0].RDLR = (brake >> 8) | ((brake &0xff) << 8) - return to_send - - def _send_gas_msg(self, gas): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 715 << 21 - to_send[0].RDLR = ((gas & 0x1f) << 27) | ((gas & 0xfe0) << 11) - return to_send - - def _set_prev_torque(self, t): - self.safety.set_gm_desired_torque_last(t) - self.safety.set_gm_rt_torque_last(t) - - def _torque_driver_msg(self, torque): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 388 << 21 - - t = twos_comp(torque, 11) - to_send[0].RDHR = (((t >> 8) & 0x7) << 16) | ((t & 0xFF) << 24) - return to_send - - def _torque_msg(self, torque): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 384 << 21 - - t = twos_comp(torque, 11) - to_send[0].RDLR = ((t >> 8) & 0x7) | ((t & 0xFF) << 8) - return to_send - - def test_default_controls_not_allowed(self): - self.assertFalse(self.safety.get_controls_allowed()) - - def test_resume_button(self): - RESUME_BTN = 2 - self.safety.set_controls_allowed(0) - self.safety.safety_rx_hook(self._button_msg(RESUME_BTN)) - self.assertTrue(self.safety.get_controls_allowed()) - - def test_set_button(self): - SET_BTN = 3 - self.safety.set_controls_allowed(0) - self.safety.safety_rx_hook(self._button_msg(SET_BTN)) - self.assertTrue(self.safety.get_controls_allowed()) - - def test_cancel_button(self): - CANCEL_BTN = 6 - self.safety.set_controls_allowed(1) - self.safety.safety_rx_hook(self._button_msg(CANCEL_BTN)) - self.assertFalse(self.safety.get_controls_allowed()) - - def test_disengage_on_brake(self): - self.safety.set_controls_allowed(1) - self.safety.safety_rx_hook(self._brake_msg(True)) - self.assertFalse(self.safety.get_controls_allowed()) - - def test_allow_brake_at_zero_speed(self): - # Brake was already pressed - self.safety.safety_rx_hook(self._brake_msg(True)) - self.safety.set_controls_allowed(1) - - self.safety.safety_rx_hook(self._brake_msg(True)) - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.safety_rx_hook(self._brake_msg(False)) - - def test_not_allow_brake_when_moving(self): - # Brake was already pressed - self.safety.safety_rx_hook(self._brake_msg(True)) - self.safety.safety_rx_hook(self._speed_msg(100)) - self.safety.set_controls_allowed(1) - - self.safety.safety_rx_hook(self._brake_msg(True)) - self.assertFalse(self.safety.get_controls_allowed()) - self.safety.safety_rx_hook(self._brake_msg(False)) - - def test_disengage_on_gas(self): - for long_controls_allowed in [0, 1]: - self.safety.set_long_controls_allowed(long_controls_allowed) - self.safety.set_controls_allowed(1) - self.safety.safety_rx_hook(self._gas_msg(True)) - if long_controls_allowed: - self.assertFalse(self.safety.get_controls_allowed()) - else: - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.safety_rx_hook(self._gas_msg(False)) - - def test_allow_engage_with_gas_pressed(self): - self.safety.safety_rx_hook(self._gas_msg(True)) - self.safety.set_controls_allowed(1) - self.safety.safety_rx_hook(self._gas_msg(True)) - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.safety_rx_hook(self._gas_msg(False)) - - def test_brake_safety_check(self): - for long_controls_allowed in [0, 1]: - self.safety.set_long_controls_allowed(long_controls_allowed) - for enabled in [0, 1]: - for b in range(0, 500): - self.safety.set_controls_allowed(enabled) - if abs(b) > MAX_BRAKE or ((not enabled or not long_controls_allowed) and b != 0): - self.assertFalse(self.safety.safety_tx_hook(self._send_brake_msg(b))) - else: - self.assertTrue(self.safety.safety_tx_hook(self._send_brake_msg(b))) - self.safety.set_long_controls_allowed(True) - - def test_gas_safety_check(self): - for long_controls_allowed in [0, 1]: - self.safety.set_long_controls_allowed(long_controls_allowed) - for enabled in [0, 1]: - for g in range(0, 2**12-1): - self.safety.set_controls_allowed(enabled) - if abs(g) > MAX_GAS or ((not enabled or not long_controls_allowed) and g != MAX_REGEN): - self.assertFalse(self.safety.safety_tx_hook(self._send_gas_msg(g))) - else: - self.assertTrue(self.safety.safety_tx_hook(self._send_gas_msg(g))) - self.safety.set_long_controls_allowed(True) - - def test_steer_safety_check(self): - for enabled in [0, 1]: - for t in range(-0x200, 0x200): - self.safety.set_controls_allowed(enabled) - self._set_prev_torque(t) - if abs(t) > MAX_STEER or (not enabled and abs(t) > 0): - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(t))) - else: - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) - - def test_manually_enable_controls_allowed(self): - self.safety.set_controls_allowed(1) - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.set_controls_allowed(0) - self.assertFalse(self.safety.get_controls_allowed()) - - def test_non_realtime_limit_up(self): - self.safety.set_gm_torque_driver(0, 0) - self.safety.set_controls_allowed(True) - - self._set_prev_torque(0) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(MAX_RATE_UP))) - self._set_prev_torque(0) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(-MAX_RATE_UP))) - - self._set_prev_torque(0) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(MAX_RATE_UP + 1))) - self.safety.set_controls_allowed(True) - self._set_prev_torque(0) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(-MAX_RATE_UP - 1))) - - def test_non_realtime_limit_down(self): - self.safety.set_gm_torque_driver(0, 0) - self.safety.set_controls_allowed(True) - - def test_against_torque_driver(self): - self.safety.set_controls_allowed(True) - - for sign in [-1, 1]: - for t in np.arange(0, DRIVER_TORQUE_ALLOWANCE + 1, 1): - t *= -sign - self.safety.set_gm_torque_driver(t, t) - self._set_prev_torque(MAX_STEER * sign) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(MAX_STEER * sign))) - - self.safety.set_gm_torque_driver(DRIVER_TORQUE_ALLOWANCE + 1, DRIVER_TORQUE_ALLOWANCE + 1) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(-MAX_STEER))) - - # spot check some individual cases - for sign in [-1, 1]: - driver_torque = (DRIVER_TORQUE_ALLOWANCE + 10) * sign - torque_desired = (MAX_STEER - 10 * DRIVER_TORQUE_FACTOR) * sign - delta = 1 * sign - self._set_prev_torque(torque_desired) - self.safety.set_gm_torque_driver(-driver_torque, -driver_torque) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(torque_desired))) - self._set_prev_torque(torque_desired + delta) - self.safety.set_gm_torque_driver(-driver_torque, -driver_torque) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(torque_desired + delta))) - - self._set_prev_torque(MAX_STEER * sign) - self.safety.set_gm_torque_driver(-MAX_STEER * sign, -MAX_STEER * sign) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg((MAX_STEER - MAX_RATE_DOWN) * sign))) - self._set_prev_torque(MAX_STEER * sign) - self.safety.set_gm_torque_driver(-MAX_STEER * sign, -MAX_STEER * sign) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(0))) - self._set_prev_torque(MAX_STEER * sign) - self.safety.set_gm_torque_driver(-MAX_STEER * sign, -MAX_STEER * sign) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg((MAX_STEER - MAX_RATE_DOWN + 1) * sign))) - - - def test_realtime_limits(self): - self.safety.set_controls_allowed(True) - - for sign in [-1, 1]: - self.safety.init_tests_gm() - self._set_prev_torque(0) - self.safety.set_gm_torque_driver(0, 0) - for t in np.arange(0, MAX_RT_DELTA, 1): - t *= sign - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(sign * (MAX_RT_DELTA + 1)))) - - self._set_prev_torque(0) - for t in np.arange(0, MAX_RT_DELTA, 1): - t *= sign - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) - - # Increase timer to update rt_torque_last - self.safety.set_timer(RT_INTERVAL + 1) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(sign * (MAX_RT_DELTA - 1)))) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(sign * (MAX_RT_DELTA + 1)))) - - - def test_fwd_hook(self): - # nothing allowed - buss = range(0x0, 0x3) - msgs = range(0x1, 0x800) - - for b in buss: - for m in msgs: - # assume len 8 - self.assertEqual(-1, self.safety.safety_fwd_hook(b, self._send_msg(b, m, 8))) - - -if __name__ == "__main__": - unittest.main() diff --git a/panda/tests/safety/test_honda.py b/panda/tests/safety/test_honda.py deleted file mode 100755 index f16030843c2a35..00000000000000 --- a/panda/tests/safety/test_honda.py +++ /dev/null @@ -1,280 +0,0 @@ -#!/usr/bin/env python2 -import unittest -import numpy as np -import libpandasafety_py - -MAX_BRAKE = 255 - -INTERCEPTOR_THRESHOLD = 328 - -class TestHondaSafety(unittest.TestCase): - @classmethod - def setUp(cls): - cls.safety = libpandasafety_py.libpandasafety - cls.safety.safety_set_mode(1, 0) - cls.safety.init_tests_honda() - - def _send_msg(self, bus, addr, length): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = addr << 21 - to_send[0].RDTR = length - to_send[0].RDTR = bus << 4 - - return to_send - - def _speed_msg(self, speed): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0x158 << 21 - to_send[0].RDLR = speed - - return to_send - - def _button_msg(self, buttons, msg): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = msg << 21 - to_send[0].RDLR = buttons << 5 - is_panda_black = self.safety.get_hw_type() == 3 # black_panda - honda_bosch_hardware = self.safety.get_honda_bosch_hardware() - bus = 1 if is_panda_black and honda_bosch_hardware else 0 - to_send[0].RDTR = bus << 4 - - return to_send - - def _brake_msg(self, brake): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0x17C << 21 - to_send[0].RDHR = 0x200000 if brake else 0 - - return to_send - - def _alt_brake_msg(self, brake): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0x1BE << 21 - to_send[0].RDLR = 0x10 if brake else 0 - - return to_send - - def _gas_msg(self, gas): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0x17C << 21 - to_send[0].RDLR = 1 if gas else 0 - - return to_send - - def _send_brake_msg(self, brake): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0x1FA << 21 - to_send[0].RDLR = ((brake & 0x3) << 8) | ((brake & 0x3FF) >> 2) - - return to_send - - def _send_interceptor_msg(self, gas, addr): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = addr << 21 - to_send[0].RDTR = 6 - gas2 = gas * 2 - to_send[0].RDLR = ((gas & 0xff) << 8) | ((gas & 0xff00) >> 8) | \ - ((gas2 & 0xff) << 24) | ((gas2 & 0xff00) << 8) - - return to_send - - def _send_steer_msg(self, steer): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0xE4 << 21 - to_send[0].RDLR = steer - - return to_send - - def test_default_controls_not_allowed(self): - self.assertFalse(self.safety.get_controls_allowed()) - - def test_resume_button(self): - RESUME_BTN = 4 - self.safety.set_controls_allowed(0) - self.safety.safety_rx_hook(self._button_msg(RESUME_BTN, 0x1A6)) - self.assertTrue(self.safety.get_controls_allowed()) - - def test_set_button(self): - SET_BTN = 3 - self.safety.set_controls_allowed(0) - self.safety.safety_rx_hook(self._button_msg(SET_BTN, 0x1A6)) - self.assertTrue(self.safety.get_controls_allowed()) - - def test_cancel_button(self): - CANCEL_BTN = 2 - self.safety.set_controls_allowed(1) - self.safety.safety_rx_hook(self._button_msg(CANCEL_BTN, 0x1A6)) - self.assertFalse(self.safety.get_controls_allowed()) - - def test_sample_speed(self): - self.assertEqual(0, self.safety.get_honda_moving()) - self.safety.safety_rx_hook(self._speed_msg(100)) - self.assertEqual(1, self.safety.get_honda_moving()) - - def test_prev_brake(self): - self.assertFalse(self.safety.get_honda_brake_prev()) - self.safety.safety_rx_hook(self._brake_msg(True)) - self.assertTrue(self.safety.get_honda_brake_prev()) - - def test_disengage_on_brake(self): - self.safety.set_controls_allowed(1) - self.safety.safety_rx_hook(self._brake_msg(1)) - self.assertFalse(self.safety.get_controls_allowed()) - - def test_alt_disengage_on_brake(self): - self.safety.set_honda_alt_brake_msg(1) - self.safety.set_controls_allowed(1) - self.safety.safety_rx_hook(self._alt_brake_msg(1)) - self.assertFalse(self.safety.get_controls_allowed()) - - self.safety.set_honda_alt_brake_msg(0) - self.safety.set_controls_allowed(1) - self.safety.safety_rx_hook(self._alt_brake_msg(1)) - self.assertTrue(self.safety.get_controls_allowed()) - - def test_allow_brake_at_zero_speed(self): - # Brake was already pressed - self.safety.safety_rx_hook(self._brake_msg(True)) - self.safety.set_controls_allowed(1) - - self.safety.safety_rx_hook(self._brake_msg(True)) - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.safety_rx_hook(self._brake_msg(False)) # reset no brakes - - def test_not_allow_brake_when_moving(self): - # Brake was already pressed - self.safety.safety_rx_hook(self._brake_msg(True)) - self.safety.safety_rx_hook(self._speed_msg(100)) - self.safety.set_controls_allowed(1) - - self.safety.safety_rx_hook(self._brake_msg(True)) - self.assertFalse(self.safety.get_controls_allowed()) - - def test_prev_gas(self): - self.safety.safety_rx_hook(self._gas_msg(False)) - self.assertFalse(self.safety.get_honda_gas_prev()) - self.safety.safety_rx_hook(self._gas_msg(True)) - self.assertTrue(self.safety.get_honda_gas_prev()) - - def test_prev_gas_interceptor(self): - self.safety.safety_rx_hook(self._send_interceptor_msg(0x0, 0x201)) - self.assertFalse(self.safety.get_gas_interceptor_prev()) - self.safety.safety_rx_hook(self._send_interceptor_msg(0x1000, 0x201)) - self.assertTrue(self.safety.get_gas_interceptor_prev()) - self.safety.safety_rx_hook(self._send_interceptor_msg(0x0, 0x201)) - self.safety.set_gas_interceptor_detected(False) - - def test_disengage_on_gas(self): - for long_controls_allowed in [0, 1]: - self.safety.set_long_controls_allowed(long_controls_allowed) - self.safety.safety_rx_hook(self._gas_msg(0)) - self.safety.set_controls_allowed(1) - self.safety.safety_rx_hook(self._gas_msg(1)) - if long_controls_allowed: - self.assertFalse(self.safety.get_controls_allowed()) - else: - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.set_long_controls_allowed(True) - - def test_allow_engage_with_gas_pressed(self): - self.safety.safety_rx_hook(self._gas_msg(1)) - self.safety.set_controls_allowed(1) - self.safety.safety_rx_hook(self._gas_msg(1)) - self.assertTrue(self.safety.get_controls_allowed()) - - def test_disengage_on_gas_interceptor(self): - for long_controls_allowed in [0, 1]: - for g in range(0, 0x1000): - self.safety.set_long_controls_allowed(long_controls_allowed) - self.safety.safety_rx_hook(self._send_interceptor_msg(0, 0x201)) - self.safety.set_controls_allowed(True) - self.safety.safety_rx_hook(self._send_interceptor_msg(g, 0x201)) - remain_enabled = (not long_controls_allowed or g <= INTERCEPTOR_THRESHOLD) - self.assertEqual(remain_enabled, self.safety.get_controls_allowed()) - self.safety.safety_rx_hook(self._send_interceptor_msg(0, 0x201)) - self.safety.set_gas_interceptor_detected(False) - self.safety.set_long_controls_allowed(True) - - def test_allow_engage_with_gas_interceptor_pressed(self): - self.safety.safety_rx_hook(self._send_interceptor_msg(0x1000, 0x201)) - self.safety.set_controls_allowed(1) - self.safety.safety_rx_hook(self._send_interceptor_msg(0x1000, 0x201)) - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.safety_rx_hook(self._send_interceptor_msg(0, 0x201)) - self.safety.set_gas_interceptor_detected(False) - - def test_brake_safety_check(self): - for long_controls_allowed in [0, 1]: - self.safety.set_long_controls_allowed(long_controls_allowed) - for brake in np.arange(0, MAX_BRAKE + 10, 1): - for controls_allowed in [True, False]: - self.safety.set_controls_allowed(controls_allowed) - if controls_allowed and long_controls_allowed: - send = MAX_BRAKE >= brake >= 0 - else: - send = brake == 0 - self.assertEqual(send, self.safety.safety_tx_hook(self._send_brake_msg(brake))) - self.safety.set_long_controls_allowed(True) - - def test_gas_interceptor_safety_check(self): - for long_controls_allowed in [0, 1]: - self.safety.set_long_controls_allowed(long_controls_allowed) - for gas in np.arange(0, 4000, 100): - for controls_allowed in [True, False]: - self.safety.set_controls_allowed(controls_allowed) - if controls_allowed and long_controls_allowed: - send = True - else: - send = gas == 0 - self.assertEqual(send, self.safety.safety_tx_hook(self._send_interceptor_msg(gas, 0x200))) - self.safety.set_long_controls_allowed(True) - - def test_steer_safety_check(self): - self.safety.set_controls_allowed(0) - self.assertTrue(self.safety.safety_tx_hook(self._send_steer_msg(0x0000))) - self.assertFalse(self.safety.safety_tx_hook(self._send_steer_msg(0x1000))) - - def test_spam_cancel_safety_check(self): - RESUME_BTN = 4 - SET_BTN = 3 - CANCEL_BTN = 2 - BUTTON_MSG = 0x296 - self.safety.set_honda_bosch_hardware(1) - self.safety.set_controls_allowed(0) - self.assertTrue(self.safety.safety_tx_hook(self._button_msg(CANCEL_BTN, BUTTON_MSG))) - self.assertFalse(self.safety.safety_tx_hook(self._button_msg(RESUME_BTN, BUTTON_MSG))) - self.assertFalse(self.safety.safety_tx_hook(self._button_msg(SET_BTN, BUTTON_MSG))) - # do not block resume if we are engaged already - self.safety.set_controls_allowed(1) - self.assertTrue(self.safety.safety_tx_hook(self._button_msg(RESUME_BTN, BUTTON_MSG))) - - def test_fwd_hook(self): - buss = range(0x0, 0x3) - msgs = range(0x1, 0x800) - long_controls_allowed = [0, 1] - - self.safety.set_honda_bosch_hardware(0) - - for l in long_controls_allowed: - self.safety.set_long_controls_allowed(l) - blocked_msgs = [0xE4, 0x194, 0x33D] - if l: - blocked_msgs += [0x1FA ,0x30C, 0x39F] - for b in buss: - for m in msgs: - if b == 0: - fwd_bus = 2 - elif b == 1: - fwd_bus = -1 - elif b == 2: - fwd_bus = -1 if m in blocked_msgs else 0 - - # assume len 8 - self.assertEqual(fwd_bus, self.safety.safety_fwd_hook(b, self._send_msg(b, m, 8))) - - self.safety.set_long_controls_allowed(True) - - - -if __name__ == "__main__": - unittest.main() diff --git a/panda/tests/safety/test_honda_bosch.py b/panda/tests/safety/test_honda_bosch.py deleted file mode 100755 index 0d37cbe8072a0b..00000000000000 --- a/panda/tests/safety/test_honda_bosch.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python2 -import unittest -import numpy as np -import libpandasafety_py - -MAX_BRAKE = 255 - -class TestHondaSafety(unittest.TestCase): - @classmethod - def setUp(cls): - cls.safety = libpandasafety_py.libpandasafety - cls.safety.safety_set_mode(4, 0) - cls.safety.init_tests_honda() - - def _send_msg(self, bus, addr, length): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = addr << 21 - to_send[0].RDTR = length - to_send[0].RDTR = bus << 4 - - return to_send - - def test_fwd_hook(self): - buss = range(0x0, 0x3) - msgs = range(0x1, 0x800) - is_panda_black = self.safety.get_hw_type() == 3 # black panda - bus_rdr_cam = 2 if is_panda_black else 1 - bus_rdr_car = 0 if is_panda_black else 2 - bus_pt = 1 if is_panda_black else 0 - - blocked_msgs = [0xE4, 0x33D] - for b in buss: - for m in msgs: - if b == bus_pt: - fwd_bus = -1 - elif b == bus_rdr_cam: - fwd_bus = -1 if m in blocked_msgs else bus_rdr_car - elif b == bus_rdr_car: - fwd_bus = bus_rdr_cam - - # assume len 8 - self.assertEqual(fwd_bus, self.safety.safety_fwd_hook(b, self._send_msg(b, m, 8))) - - -if __name__ == "__main__": - unittest.main() diff --git a/panda/tests/safety/test_hyundai.py b/panda/tests/safety/test_hyundai.py deleted file mode 100644 index 539982fab92a26..00000000000000 --- a/panda/tests/safety/test_hyundai.py +++ /dev/null @@ -1,218 +0,0 @@ -#!/usr/bin/env python2 -import unittest -import numpy as np -import libpandasafety_py - -MAX_RATE_UP = 3 -MAX_RATE_DOWN = 7 -MAX_STEER = 255 - -MAX_RT_DELTA = 112 -RT_INTERVAL = 250000 - -DRIVER_TORQUE_ALLOWANCE = 50; -DRIVER_TORQUE_FACTOR = 2; - -def twos_comp(val, bits): - if val >= 0: - return val - else: - return (2**bits) + val - -def sign(a): - if a > 0: - return 1 - else: - return -1 - -class TestHyundaiSafety(unittest.TestCase): - @classmethod - def setUp(cls): - cls.safety = libpandasafety_py.libpandasafety - cls.safety.safety_set_mode(7, 0) - cls.safety.init_tests_hyundai() - - def _send_msg(self, bus, addr, length): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = addr << 21 - to_send[0].RDTR = length - to_send[0].RDTR = bus << 4 - return to_send - - def _button_msg(self, buttons): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 1265 << 21 - to_send[0].RDLR = buttons - return to_send - - def _set_prev_torque(self, t): - self.safety.set_hyundai_desired_torque_last(t) - self.safety.set_hyundai_rt_torque_last(t) - - def _torque_driver_msg(self, torque): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 897 << 21 - to_send[0].RDLR = (torque + 2048) << 11 - return to_send - - def _torque_msg(self, torque): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 832 << 21 - to_send[0].RDLR = (torque + 1024) << 16 - return to_send - - def test_default_controls_not_allowed(self): - self.assertFalse(self.safety.get_controls_allowed()) - - def test_steer_safety_check(self): - for enabled in [0, 1]: - for t in range(-0x200, 0x200): - self.safety.set_controls_allowed(enabled) - self._set_prev_torque(t) - if abs(t) > MAX_STEER or (not enabled and abs(t) > 0): - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(t))) - else: - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) - - def test_manually_enable_controls_allowed(self): - self.safety.set_controls_allowed(1) - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.set_controls_allowed(0) - self.assertFalse(self.safety.get_controls_allowed()) - - def test_enable_control_allowed_from_cruise(self): - to_push = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_push[0].RIR = 1057 << 21 - to_push[0].RDLR = 1 << 13 - - self.safety.safety_rx_hook(to_push) - self.assertTrue(self.safety.get_controls_allowed()) - - def test_disable_control_allowed_from_cruise(self): - to_push = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_push[0].RIR = 1057 << 21 - to_push[0].RDLR = 0 - - self.safety.set_controls_allowed(1) - self.safety.safety_rx_hook(to_push) - self.assertFalse(self.safety.get_controls_allowed()) - - def test_non_realtime_limit_up(self): - self.safety.set_hyundai_torque_driver(0, 0) - self.safety.set_controls_allowed(True) - - self._set_prev_torque(0) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(MAX_RATE_UP))) - self._set_prev_torque(0) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(-MAX_RATE_UP))) - - self._set_prev_torque(0) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(MAX_RATE_UP + 1))) - self.safety.set_controls_allowed(True) - self._set_prev_torque(0) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(-MAX_RATE_UP - 1))) - - def test_non_realtime_limit_down(self): - self.safety.set_hyundai_torque_driver(0, 0) - self.safety.set_controls_allowed(True) - - def test_against_torque_driver(self): - self.safety.set_controls_allowed(True) - - for sign in [-1, 1]: - for t in np.arange(0, DRIVER_TORQUE_ALLOWANCE + 1, 1): - t *= -sign - self.safety.set_hyundai_torque_driver(t, t) - self._set_prev_torque(MAX_STEER * sign) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(MAX_STEER * sign))) - - self.safety.set_hyundai_torque_driver(DRIVER_TORQUE_ALLOWANCE + 1, DRIVER_TORQUE_ALLOWANCE + 1) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(-MAX_STEER))) - - # spot check some individual cases - for sign in [-1, 1]: - driver_torque = (DRIVER_TORQUE_ALLOWANCE + 10) * sign - torque_desired = (MAX_STEER - 10 * DRIVER_TORQUE_FACTOR) * sign - delta = 1 * sign - self._set_prev_torque(torque_desired) - self.safety.set_hyundai_torque_driver(-driver_torque, -driver_torque) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(torque_desired))) - self._set_prev_torque(torque_desired + delta) - self.safety.set_hyundai_torque_driver(-driver_torque, -driver_torque) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(torque_desired + delta))) - - self._set_prev_torque(MAX_STEER * sign) - self.safety.set_hyundai_torque_driver(-MAX_STEER * sign, -MAX_STEER * sign) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg((MAX_STEER - MAX_RATE_DOWN) * sign))) - self._set_prev_torque(MAX_STEER * sign) - self.safety.set_hyundai_torque_driver(-MAX_STEER * sign, -MAX_STEER * sign) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(0))) - self._set_prev_torque(MAX_STEER * sign) - self.safety.set_hyundai_torque_driver(-MAX_STEER * sign, -MAX_STEER * sign) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg((MAX_STEER - MAX_RATE_DOWN + 1) * sign))) - - - def test_realtime_limits(self): - self.safety.set_controls_allowed(True) - - for sign in [-1, 1]: - self.safety.init_tests_hyundai() - self._set_prev_torque(0) - self.safety.set_hyundai_torque_driver(0, 0) - for t in np.arange(0, MAX_RT_DELTA, 1): - t *= sign - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(sign * (MAX_RT_DELTA + 1)))) - - self._set_prev_torque(0) - for t in np.arange(0, MAX_RT_DELTA, 1): - t *= sign - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) - - # Increase timer to update rt_torque_last - self.safety.set_timer(RT_INTERVAL + 1) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(sign * (MAX_RT_DELTA - 1)))) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(sign * (MAX_RT_DELTA + 1)))) - - - #def test_spam_cancel_safety_check(self): - # RESUME_BTN = 1 - # SET_BTN = 2 - # CANCEL_BTN = 4 - # BUTTON_MSG = 1265 - # self.safety.set_controls_allowed(0) - # self.assertTrue(self.safety.safety_tx_hook(self._button_msg(CANCEL_BTN))) - # self.assertFalse(self.safety.safety_tx_hook(self._button_msg(RESUME_BTN))) - # self.assertFalse(self.safety.safety_tx_hook(self._button_msg(SET_BTN))) - # # do not block resume if we are engaged already - # self.safety.set_controls_allowed(1) - # self.assertTrue(self.safety.safety_tx_hook(self._button_msg(RESUME_BTN))) - - def test_fwd_hook(self): - - buss = range(0x0, 0x3) - msgs = range(0x1, 0x800) - hyundai_giraffe_switch_2 = [0, 1] - - self.safety.set_hyundai_camera_bus(2) - for hgs in hyundai_giraffe_switch_2: - self.safety.set_hyundai_giraffe_switch_2(hgs) - blocked_msgs = [832] - for b in buss: - for m in msgs: - if hgs: - if b == 0: - fwd_bus = 2 - elif b == 1: - fwd_bus = -1 - elif b == 2: - fwd_bus = -1 if m in blocked_msgs else 0 - else: - fwd_bus = -1 - - # assume len 8 - self.assertEqual(fwd_bus, self.safety.safety_fwd_hook(b, self._send_msg(b, m, 8))) - - -if __name__ == "__main__": - unittest.main() diff --git a/panda/tests/safety/test_subaru.py b/panda/tests/safety/test_subaru.py deleted file mode 100644 index 13fe1fb14f2b91..00000000000000 --- a/panda/tests/safety/test_subaru.py +++ /dev/null @@ -1,194 +0,0 @@ -#!/usr/bin/env python2 -import unittest -import numpy as np -import libpandasafety_py - -MAX_RATE_UP = 50 -MAX_RATE_DOWN = 70 -MAX_STEER = 2047 - -MAX_RT_DELTA = 940 -RT_INTERVAL = 250000 - -DRIVER_TORQUE_ALLOWANCE = 60; -DRIVER_TORQUE_FACTOR = 10; - -def twos_comp(val, bits): - if val >= 0: - return val - else: - return (2**bits) + val - -def sign(a): - if a > 0: - return 1 - else: - return -1 - -class TestSubaruSafety(unittest.TestCase): - @classmethod - def setUp(cls): - cls.safety = libpandasafety_py.libpandasafety - cls.safety.safety_set_mode(10, 0) - cls.safety.init_tests_subaru() - - def _send_msg(self, bus, addr, length): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = addr << 21 - to_send[0].RDTR = length - to_send[0].RDTR = bus << 4 - return to_send - - def _set_prev_torque(self, t): - self.safety.set_subaru_desired_torque_last(t) - self.safety.set_subaru_rt_torque_last(t) - - def _torque_driver_msg(self, torque): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0x119 << 21 - - t = twos_comp(torque, 11) - to_send[0].RDLR = ((t & 0x7FF) << 16) - return to_send - - def _torque_msg(self, torque): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0x122 << 21 - - t = twos_comp(torque, 13) - to_send[0].RDLR = (t << 16) - return to_send - - def test_default_controls_not_allowed(self): - self.assertFalse(self.safety.get_controls_allowed()) - - def test_enable_control_allowed_from_cruise(self): - to_push = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_push[0].RIR = 0x240 << 21 - to_push[0].RDHR = 1 << 9 - - self.safety.safety_rx_hook(to_push) - self.assertTrue(self.safety.get_controls_allowed()) - - def test_disable_control_allowed_from_cruise(self): - to_push = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_push[0].RIR = 0x240 << 21 - to_push[0].RDHR = 0 - - self.safety.set_controls_allowed(1) - self.safety.safety_rx_hook(to_push) - self.assertFalse(self.safety.get_controls_allowed()) - - def test_steer_safety_check(self): - for enabled in [0, 1]: - for t in range(-3000, 3000): - self.safety.set_controls_allowed(enabled) - self._set_prev_torque(t) - if abs(t) > MAX_STEER or (not enabled and abs(t) > 0): - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(t))) - else: - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) - - def test_manually_enable_controls_allowed(self): - self.safety.set_controls_allowed(1) - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.set_controls_allowed(0) - self.assertFalse(self.safety.get_controls_allowed()) - - def test_non_realtime_limit_up(self): - self.safety.set_subaru_torque_driver(0, 0) - self.safety.set_controls_allowed(True) - - self._set_prev_torque(0) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(MAX_RATE_UP))) - self._set_prev_torque(0) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(-MAX_RATE_UP))) - - self._set_prev_torque(0) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(MAX_RATE_UP + 1))) - self.safety.set_controls_allowed(True) - self._set_prev_torque(0) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(-MAX_RATE_UP - 1))) - - def test_non_realtime_limit_down(self): - self.safety.set_subaru_torque_driver(0, 0) - self.safety.set_controls_allowed(True) - - def test_against_torque_driver(self): - self.safety.set_controls_allowed(True) - - for sign in [-1, 1]: - for t in np.arange(0, DRIVER_TORQUE_ALLOWANCE + 1, 1): - t *= -sign - self.safety.set_subaru_torque_driver(t, t) - self._set_prev_torque(MAX_STEER * sign) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(MAX_STEER * sign))) - - self.safety.set_subaru_torque_driver(DRIVER_TORQUE_ALLOWANCE + 1, DRIVER_TORQUE_ALLOWANCE + 1) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(-MAX_STEER))) - - # spot check some individual cases - for sign in [-1, 1]: - driver_torque = (DRIVER_TORQUE_ALLOWANCE + 10) * sign - torque_desired = (MAX_STEER - 10 * DRIVER_TORQUE_FACTOR) * sign - delta = 1 * sign - self._set_prev_torque(torque_desired) - self.safety.set_subaru_torque_driver(-driver_torque, -driver_torque) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(torque_desired))) - self._set_prev_torque(torque_desired + delta) - self.safety.set_subaru_torque_driver(-driver_torque, -driver_torque) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(torque_desired + delta))) - - self._set_prev_torque(MAX_STEER * sign) - self.safety.set_subaru_torque_driver(-MAX_STEER * sign, -MAX_STEER * sign) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg((MAX_STEER - MAX_RATE_DOWN) * sign))) - self._set_prev_torque(MAX_STEER * sign) - self.safety.set_subaru_torque_driver(-MAX_STEER * sign, -MAX_STEER * sign) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(0))) - self._set_prev_torque(MAX_STEER * sign) - self.safety.set_subaru_torque_driver(-MAX_STEER * sign, -MAX_STEER * sign) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg((MAX_STEER - MAX_RATE_DOWN + 1) * sign))) - - - def test_realtime_limits(self): - self.safety.set_controls_allowed(True) - - for sign in [-1, 1]: - self.safety.init_tests_subaru() - self._set_prev_torque(0) - self.safety.set_subaru_torque_driver(0, 0) - for t in np.arange(0, MAX_RT_DELTA, 1): - t *= sign - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(sign * (MAX_RT_DELTA + 1)))) - - self._set_prev_torque(0) - for t in np.arange(0, MAX_RT_DELTA, 1): - t *= sign - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) - - # Increase timer to update rt_torque_last - self.safety.set_timer(RT_INTERVAL + 1) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(sign * (MAX_RT_DELTA - 1)))) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(sign * (MAX_RT_DELTA + 1)))) - - - def test_fwd_hook(self): - buss = range(0x0, 0x3) - msgs = range(0x1, 0x800) - blocked_msgs = [290, 356, 545, 802] - for b in buss: - for m in msgs: - if b == 0: - fwd_bus = 2 - elif b == 1: - fwd_bus = -1 - elif b == 2: - fwd_bus = -1 if m in blocked_msgs else 0 - - # assume len 8 - self.assertEqual(fwd_bus, self.safety.safety_fwd_hook(b, self._send_msg(b, m, 8))) - - -if __name__ == "__main__": - unittest.main() diff --git a/panda/tests/safety/test_toyota.py b/panda/tests/safety/test_toyota.py deleted file mode 100644 index dc5b21ac8f7b42..00000000000000 --- a/panda/tests/safety/test_toyota.py +++ /dev/null @@ -1,315 +0,0 @@ -#!/usr/bin/env python2 -import unittest -import numpy as np -import libpandasafety_py - -MAX_RATE_UP = 10 -MAX_RATE_DOWN = 25 -MAX_TORQUE = 1500 - -MAX_ACCEL = 1500 -MIN_ACCEL = -3000 - -MAX_RT_DELTA = 375 -RT_INTERVAL = 250000 - -MAX_TORQUE_ERROR = 350 - -INTERCEPTOR_THRESHOLD = 475 - -def twos_comp(val, bits): - if val >= 0: - return val - else: - return (2**bits) + val - -def sign(a): - if a > 0: - return 1 - else: - return -1 - -class TestToyotaSafety(unittest.TestCase): - @classmethod - def setUp(cls): - cls.safety = libpandasafety_py.libpandasafety - cls.safety.safety_set_mode(2, 100) - cls.safety.init_tests_toyota() - - def _send_msg(self, bus, addr, length): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = addr << 21 - to_send[0].RDTR = length - to_send[0].RDTR = bus << 4 - return to_send - - def _set_prev_torque(self, t): - self.safety.set_toyota_desired_torque_last(t) - self.safety.set_toyota_rt_torque_last(t) - self.safety.set_toyota_torque_meas(t, t) - - def _torque_meas_msg(self, torque): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0x260 << 21 - - t = twos_comp(torque, 16) - to_send[0].RDHR = t | ((t & 0xFF) << 16) - return to_send - - def _torque_msg(self, torque): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0x2E4 << 21 - - t = twos_comp(torque, 16) - to_send[0].RDLR = t | ((t & 0xFF) << 16) - return to_send - - def _accel_msg(self, accel): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0x343 << 21 - - a = twos_comp(accel, 16) - to_send[0].RDLR = (a & 0xFF) << 8 | (a >> 8) - return to_send - - def _send_gas_msg(self, gas): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0x2C1 << 21 - to_send[0].RDHR = (gas & 0xFF) << 16 - - return to_send - - def _send_interceptor_msg(self, gas, addr): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = addr << 21 - to_send[0].RDTR = 6 - gas2 = gas * 2 - to_send[0].RDLR = ((gas & 0xff) << 8) | ((gas & 0xff00) >> 8) | \ - ((gas2 & 0xff) << 24) | ((gas2 & 0xff00) << 8) - - return to_send - - def _pcm_cruise_msg(self, cruise_on): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0x1D2 << 21 - to_send[0].RDLR = cruise_on << 5 - - return to_send - - def test_default_controls_not_allowed(self): - self.assertFalse(self.safety.get_controls_allowed()) - - def test_manually_enable_controls_allowed(self): - self.safety.set_controls_allowed(1) - self.assertTrue(self.safety.get_controls_allowed()) - - def test_enable_control_allowed_from_cruise(self): - self.safety.safety_rx_hook(self._pcm_cruise_msg(False)) - self.assertFalse(self.safety.get_controls_allowed()) - self.safety.safety_rx_hook(self._pcm_cruise_msg(True)) - self.assertTrue(self.safety.get_controls_allowed()) - - def test_disable_control_allowed_from_cruise(self): - self.safety.set_controls_allowed(1) - self.safety.safety_rx_hook(self._pcm_cruise_msg(False)) - self.assertFalse(self.safety.get_controls_allowed()) - - def test_prev_gas(self): - for g in range(0, 256): - self.safety.safety_rx_hook(self._send_gas_msg(g)) - self.assertEqual(g, self.safety.get_toyota_gas_prev()) - - def test_prev_gas_interceptor(self): - self.safety.safety_rx_hook(self._send_interceptor_msg(0x0, 0x201)) - self.assertFalse(self.safety.get_gas_interceptor_prev()) - self.safety.safety_rx_hook(self._send_interceptor_msg(0x1000, 0x201)) - self.assertTrue(self.safety.get_gas_interceptor_prev()) - self.safety.safety_rx_hook(self._send_interceptor_msg(0x0, 0x201)) - self.safety.set_gas_interceptor_detected(False) - - def test_disengage_on_gas(self): - for long_controls_allowed in [0, 1]: - self.safety.set_long_controls_allowed(long_controls_allowed) - self.safety.safety_rx_hook(self._send_gas_msg(0)) - self.safety.set_controls_allowed(True) - self.safety.safety_rx_hook(self._send_gas_msg(1)) - if long_controls_allowed: - self.assertFalse(self.safety.get_controls_allowed()) - else: - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.set_long_controls_allowed(True) - - def test_allow_engage_with_gas_pressed(self): - self.safety.safety_rx_hook(self._send_gas_msg(1)) - self.safety.set_controls_allowed(True) - self.safety.safety_rx_hook(self._send_gas_msg(1)) - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.safety_rx_hook(self._send_gas_msg(1)) - self.assertTrue(self.safety.get_controls_allowed()) - - def test_disengage_on_gas_interceptor(self): - for long_controls_allowed in [0, 1]: - for g in range(0, 0x1000): - self.safety.set_long_controls_allowed(long_controls_allowed) - self.safety.safety_rx_hook(self._send_interceptor_msg(0, 0x201)) - self.safety.set_controls_allowed(True) - self.safety.safety_rx_hook(self._send_interceptor_msg(g, 0x201)) - remain_enabled = (not long_controls_allowed or g <= INTERCEPTOR_THRESHOLD) - self.assertEqual(remain_enabled, self.safety.get_controls_allowed()) - self.safety.safety_rx_hook(self._send_interceptor_msg(0, 0x201)) - self.safety.set_gas_interceptor_detected(False) - self.safety.set_long_controls_allowed(True) - - def test_allow_engage_with_gas_interceptor_pressed(self): - self.safety.safety_rx_hook(self._send_interceptor_msg(0x1000, 0x201)) - self.safety.set_controls_allowed(1) - self.safety.safety_rx_hook(self._send_interceptor_msg(0x1000, 0x201)) - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.safety_rx_hook(self._send_interceptor_msg(0, 0x201)) - self.safety.set_gas_interceptor_detected(False) - - def test_accel_actuation_limits(self): - for long_controls_allowed in [0, 1]: - self.safety.set_long_controls_allowed(long_controls_allowed) - for accel in np.arange(MIN_ACCEL - 1000, MAX_ACCEL + 1000, 100): - for controls_allowed in [True, False]: - self.safety.set_controls_allowed(controls_allowed) - if controls_allowed and long_controls_allowed: - send = MIN_ACCEL <= accel <= MAX_ACCEL - else: - send = accel == 0 - self.assertEqual(send, self.safety.safety_tx_hook(self._accel_msg(accel))) - self.safety.set_long_controls_allowed(True) - - def test_torque_absolute_limits(self): - for controls_allowed in [True, False]: - for torque in np.arange(-MAX_TORQUE - 1000, MAX_TORQUE + 1000, MAX_RATE_UP): - self.safety.set_controls_allowed(controls_allowed) - self.safety.set_toyota_rt_torque_last(torque) - self.safety.set_toyota_torque_meas(torque, torque) - self.safety.set_toyota_desired_torque_last(torque - MAX_RATE_UP) - - if controls_allowed: - send = (-MAX_TORQUE <= torque <= MAX_TORQUE) - else: - send = torque == 0 - - self.assertEqual(send, self.safety.safety_tx_hook(self._torque_msg(torque))) - - def test_non_realtime_limit_up(self): - self.safety.set_controls_allowed(True) - - self._set_prev_torque(0) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(MAX_RATE_UP))) - - self._set_prev_torque(0) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(MAX_RATE_UP + 1))) - - def test_non_realtime_limit_down(self): - self.safety.set_controls_allowed(True) - - self.safety.set_toyota_rt_torque_last(1000) - self.safety.set_toyota_torque_meas(500, 500) - self.safety.set_toyota_desired_torque_last(1000) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(1000 - MAX_RATE_DOWN))) - - self.safety.set_toyota_rt_torque_last(1000) - self.safety.set_toyota_torque_meas(500, 500) - self.safety.set_toyota_desired_torque_last(1000) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(1000 - MAX_RATE_DOWN + 1))) - - def test_exceed_torque_sensor(self): - self.safety.set_controls_allowed(True) - - for sign in [-1, 1]: - self._set_prev_torque(0) - for t in np.arange(0, MAX_TORQUE_ERROR + 10, 10): - t *= sign - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) - - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(sign * (MAX_TORQUE_ERROR + 10)))) - - def test_realtime_limit_up(self): - self.safety.set_controls_allowed(True) - - for sign in [-1, 1]: - self.safety.init_tests_toyota() - self._set_prev_torque(0) - for t in np.arange(0, 380, 10): - t *= sign - self.safety.set_toyota_torque_meas(t, t) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) - self.assertFalse(self.safety.safety_tx_hook(self._torque_msg(sign * 380))) - - self._set_prev_torque(0) - for t in np.arange(0, 370, 10): - t *= sign - self.safety.set_toyota_torque_meas(t, t) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) - - # Increase timer to update rt_torque_last - self.safety.set_timer(RT_INTERVAL + 1) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(sign * 370))) - self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(sign * 380))) - - def test_torque_measurements(self): - self.safety.safety_rx_hook(self._torque_meas_msg(50)) - self.safety.safety_rx_hook(self._torque_meas_msg(-50)) - self.safety.safety_rx_hook(self._torque_meas_msg(0)) - self.safety.safety_rx_hook(self._torque_meas_msg(0)) - self.safety.safety_rx_hook(self._torque_meas_msg(0)) - self.safety.safety_rx_hook(self._torque_meas_msg(0)) - - self.assertEqual(-51, self.safety.get_toyota_torque_meas_min()) - self.assertEqual(51, self.safety.get_toyota_torque_meas_max()) - - self.safety.safety_rx_hook(self._torque_meas_msg(0)) - self.assertEqual(1, self.safety.get_toyota_torque_meas_max()) - self.assertEqual(-51, self.safety.get_toyota_torque_meas_min()) - - self.safety.safety_rx_hook(self._torque_meas_msg(0)) - self.assertEqual(1, self.safety.get_toyota_torque_meas_max()) - self.assertEqual(-1, self.safety.get_toyota_torque_meas_min()) - - def test_gas_interceptor_safety_check(self): - - self.safety.set_controls_allowed(0) - self.assertTrue(self.safety.safety_tx_hook(self._send_interceptor_msg(0, 0x200))) - self.assertFalse(self.safety.safety_tx_hook(self._send_interceptor_msg(0x1000, 0x200))) - self.safety.set_controls_allowed(1) - self.assertTrue(self.safety.safety_tx_hook(self._send_interceptor_msg(0x1000, 0x200))) - - def test_fwd_hook(self): - - buss = range(0x0, 0x3) - msgs = range(0x1, 0x800) - long_controls_allowed = [0, 1] - toyota_camera_forwarded = [0, 1] - - for tcf in toyota_camera_forwarded: - self.safety.set_toyota_camera_forwarded(tcf) - for lca in long_controls_allowed: - self.safety.set_long_controls_allowed(lca) - blocked_msgs = [0x2E4, 0x412, 0x191] - if lca: - blocked_msgs += [0x343] - for b in buss: - for m in msgs: - if tcf: - if b == 0: - fwd_bus = 2 - elif b == 1: - fwd_bus = -1 - elif b == 2: - fwd_bus = -1 if m in blocked_msgs else 0 - else: - fwd_bus = -1 - - # assume len 8 - self.assertEqual(fwd_bus, self.safety.safety_fwd_hook(b, self._send_msg(b, m, 8))) - - self.safety.set_long_controls_allowed(True) - - -if __name__ == "__main__": - unittest.main() diff --git a/panda/tests/safety/test_toyota_ipas.py b/panda/tests/safety/test_toyota_ipas.py deleted file mode 100644 index 7a382093e0b45b..00000000000000 --- a/panda/tests/safety/test_toyota_ipas.py +++ /dev/null @@ -1,247 +0,0 @@ -#!/usr/bin/env python2 -import unittest -import numpy as np -import libpandasafety_py - -IPAS_OVERRIDE_THRESHOLD = 200 - -ANGLE_DELTA_BP = [0., 5., 15.] -ANGLE_DELTA_V = [5., .8, .15] # windup limit -ANGLE_DELTA_VU = [5., 3.5, 0.4] # unwind limit - -def twos_comp(val, bits): - if val >= 0: - return val - else: - return (2**bits) + val - -def sign(a): - if a > 0: - return 1 - else: - return -1 - -class TestToyotaSafety(unittest.TestCase): - @classmethod - def setUp(cls): - cls.safety = libpandasafety_py.libpandasafety - cls.safety.safety_set_mode(0x1335, 66) - cls.safety.init_tests_toyota() - - def _torque_driver_msg(self, torque): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0x260 << 21 - - t = twos_comp(torque, 16) - to_send[0].RDLR = t | ((t & 0xFF) << 16) - return to_send - - def _torque_driver_msg_array(self, torque): - for i in range(6): - self.safety.safety_rx_hook(self._torque_driver_msg(torque)) - - def _angle_meas_msg(self, angle): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0x25 << 21 - - t = twos_comp(angle, 12) - to_send[0].RDLR = ((t & 0xF00) >> 8) | ((t & 0xFF) << 8) - return to_send - - def _angle_meas_msg_array(self, angle): - for i in range(6): - self.safety.safety_rx_hook(self._angle_meas_msg(angle)) - - def _ipas_state_msg(self, state): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0x262 << 21 - - to_send[0].RDLR = state & 0xF - return to_send - - def _ipas_control_msg(self, angle, state): - # note: we command 2/3 of the angle due to CAN conversion - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0x266 << 21 - - t = twos_comp(angle, 12) - to_send[0].RDLR = ((t & 0xF00) >> 8) | ((t & 0xFF) << 8) - to_send[0].RDLR |= ((state & 0xf) << 4) - - return to_send - - def _speed_msg(self, speed): - to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - to_send[0].RIR = 0xb4 << 21 - speed = int(speed * 100 * 3.6) - - to_send[0].RDHR = ((speed & 0xFF) << 16) | (speed & 0xFF00) - return to_send - - def test_ipas_override(self): - - ## angle control is not active - self.safety.set_controls_allowed(1) - - # 3 consecutive msgs where driver exceeds threshold but angle_control isn't active - self.safety.set_controls_allowed(1) - self._torque_driver_msg_array(IPAS_OVERRIDE_THRESHOLD + 1) - self.assertTrue(self.safety.get_controls_allowed()) - - self._torque_driver_msg_array(-IPAS_OVERRIDE_THRESHOLD - 1) - self.assertTrue(self.safety.get_controls_allowed()) - - # ipas state is override - self.safety.safety_rx_hook(self._ipas_state_msg(5)) - self.assertTrue(self.safety.get_controls_allowed()) - - ## now angle control is active - self.safety.safety_tx_hook(self._ipas_control_msg(0, 0)) - self.safety.safety_rx_hook(self._ipas_state_msg(0)) - - # 3 consecutive msgs where driver does exceed threshold - self.safety.set_controls_allowed(1) - self._torque_driver_msg_array(IPAS_OVERRIDE_THRESHOLD + 1) - self.assertFalse(self.safety.get_controls_allowed()) - - self.safety.set_controls_allowed(1) - self._torque_driver_msg_array(-IPAS_OVERRIDE_THRESHOLD - 1) - self.assertFalse(self.safety.get_controls_allowed()) - - # ipas state is override and torque isn't overriding any more - self.safety.set_controls_allowed(1) - self._torque_driver_msg_array(0) - self.safety.safety_rx_hook(self._ipas_state_msg(5)) - self.assertFalse(self.safety.get_controls_allowed()) - - # 3 consecutive msgs where driver does not exceed threshold and - # ipas state is not override - self.safety.set_controls_allowed(1) - self.safety.safety_rx_hook(self._ipas_state_msg(0)) - self.assertTrue(self.safety.get_controls_allowed()) - - self._torque_driver_msg_array(IPAS_OVERRIDE_THRESHOLD) - self.assertTrue(self.safety.get_controls_allowed()) - - self._torque_driver_msg_array(-IPAS_OVERRIDE_THRESHOLD) - self.assertTrue(self.safety.get_controls_allowed()) - - # reset no angle control at the end of the test - self.safety.reset_angle_control() - - def test_angle_cmd_when_disabled(self): - - self.safety.set_controls_allowed(0) - - # test angle cmd too far from actual - angle_refs = [-10, 10] - deltas = range(-2, 3) - expected_results = [False, True, True, True, False] - - for a in angle_refs: - self._angle_meas_msg_array(a) - for i, d in enumerate(deltas): - self.assertEqual(expected_results[i], self.safety.safety_tx_hook(self._ipas_control_msg(a + d, 1))) - - # test ipas state cmd enabled - self._angle_meas_msg_array(0) - self.assertEqual(0, self.safety.safety_tx_hook(self._ipas_control_msg(0, 3))) - - # reset no angle control at the end of the test - self.safety.reset_angle_control() - - def test_angle_cmd_when_enabled(self): - - # ipas angle cmd should pass through when controls are enabled - - self.safety.set_controls_allowed(1) - self._angle_meas_msg_array(0) - self.safety.safety_rx_hook(self._speed_msg(0.1)) - - self.assertEqual(1, self.safety.safety_tx_hook(self._ipas_control_msg(0, 1))) - self.assertEqual(1, self.safety.safety_tx_hook(self._ipas_control_msg(4, 1))) - self.assertEqual(1, self.safety.safety_tx_hook(self._ipas_control_msg(0, 3))) - self.assertEqual(1, self.safety.safety_tx_hook(self._ipas_control_msg(-4, 3))) - self.assertEqual(1, self.safety.safety_tx_hook(self._ipas_control_msg(-8, 3))) - - # reset no angle control at the end of the test - self.safety.reset_angle_control() - - def test_angle_cmd_rate_when_disabled(self): - - # as long as the command is close to the measured, no rate limit is enforced when - # controls are disabled - self.safety.set_controls_allowed(0) - self.safety.safety_rx_hook(self._angle_meas_msg(0)) - self.assertEqual(1, self.safety.safety_tx_hook(self._ipas_control_msg(0, 1))) - self.safety.safety_rx_hook(self._angle_meas_msg(100)) - self.assertEqual(1, self.safety.safety_tx_hook(self._ipas_control_msg(100, 1))) - self.safety.safety_rx_hook(self._angle_meas_msg(-100)) - self.assertEqual(1, self.safety.safety_tx_hook(self._ipas_control_msg(-100, 1))) - - # reset no angle control at the end of the test - self.safety.reset_angle_control() - - def test_angle_cmd_rate_when_enabled(self): - - # when controls are allowed, angle cmd rate limit is enforced - # test 1: no limitations if we stay within limits - speeds = [0., 1., 5., 10., 15., 100.] - angles = [-300, -100, -10, 0, 10, 100, 300] - for a in angles: - for s in speeds: - - # first test against false positives - self._angle_meas_msg_array(a) - self.safety.safety_tx_hook(self._ipas_control_msg(a, 1)) - self.safety.set_controls_allowed(1) - self.safety.safety_rx_hook(self._speed_msg(s)) - max_delta_up = int(np.interp(s, ANGLE_DELTA_BP, ANGLE_DELTA_V) * 2 / 3. + 1.) - max_delta_down = int(np.interp(s, ANGLE_DELTA_BP, ANGLE_DELTA_VU) * 2 / 3. + 1.) - self.assertEqual(True, self.safety.safety_tx_hook(self._ipas_control_msg(a + sign(a) * max_delta_up, 1))) - self.assertTrue(self.safety.get_controls_allowed()) - self.assertEqual(True, self.safety.safety_tx_hook(self._ipas_control_msg(a, 1))) - self.assertTrue(self.safety.get_controls_allowed()) - self.assertEqual(True, self.safety.safety_tx_hook(self._ipas_control_msg(a - sign(a) * max_delta_down, 1))) - self.assertTrue(self.safety.get_controls_allowed()) - - # now inject too high rates - self.assertEqual(False, self.safety.safety_tx_hook(self._ipas_control_msg(a + sign(a) * - (max_delta_up + 1), 1))) - self.assertFalse(self.safety.get_controls_allowed()) - self.safety.set_controls_allowed(1) - self.assertEqual(True, self.safety.safety_tx_hook(self._ipas_control_msg(a + sign(a) * max_delta_up, 1))) - self.assertTrue(self.safety.get_controls_allowed()) - self.assertEqual(True, self.safety.safety_tx_hook(self._ipas_control_msg(a, 1))) - self.assertTrue(self.safety.get_controls_allowed()) - self.assertEqual(False, self.safety.safety_tx_hook(self._ipas_control_msg(a - sign(a) * - (max_delta_down + 1), 1))) - self.assertFalse(self.safety.get_controls_allowed()) - - # reset no angle control at the end of the test - self.safety.reset_angle_control() - - def test_angle_measured_rate(self): - - speeds = [0., 1., 5., 10., 15., 100.] - angles = [-300, -100, -10, 0, 10, 100, 300] - angles = [10] - for a in angles: - for s in speeds: - self._angle_meas_msg_array(a) - self.safety.safety_tx_hook(self._ipas_control_msg(a, 1)) - self.safety.set_controls_allowed(1) - self.safety.safety_rx_hook(self._speed_msg(s)) - max_delta_up = int(np.interp(s, ANGLE_DELTA_BP, ANGLE_DELTA_V) * 2 / 3. + 1.) - max_delta_down = int(np.interp(s, ANGLE_DELTA_BP, ANGLE_DELTA_VU) * 2 / 3. + 1.) - self.safety.safety_rx_hook(self._angle_meas_msg(a)) - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.safety_rx_hook(self._angle_meas_msg(a + 150)) - self.assertFalse(self.safety.get_controls_allowed()) - - # reset no angle control at the end of the test - self.safety.reset_angle_control() - - -if __name__ == "__main__": - unittest.main() diff --git a/panda/tests/safety_replay/Dockerfile b/panda/tests/safety_replay/Dockerfile deleted file mode 100644 index 5d59ca38d51960..00000000000000 --- a/panda/tests/safety_replay/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM ubuntu:16.04 - -RUN apt-get update && apt-get install -y make clang python python-pip git libarchive-dev libusb-1.0-0 - -COPY tests/safety_replay/requirements.txt requirements.txt -RUN pip install -r requirements.txt -COPY tests/safety_replay/install_capnp.sh install_capnp.sh -RUN ./install_capnp.sh - -RUN mkdir /openpilot -WORKDIR /openpilot -RUN git clone https://github.com/commaai/cereal.git || true -WORKDIR /openpilot/cereal -RUN git checkout f7043fde062cbfd49ec90af669901a9caba52de9 -COPY . /openpilot/panda - -WORKDIR /openpilot/panda/tests/safety_replay -RUN git clone https://github.com/commaai/openpilot-tools.git tools || true -WORKDIR tools -RUN git checkout feb724a14f0f5223c700c94317efaf46923fd48a diff --git a/panda/tests/safety_replay/helpers.py b/panda/tests/safety_replay/helpers.py deleted file mode 100644 index 05bbe08930ac7b..00000000000000 --- a/panda/tests/safety_replay/helpers.py +++ /dev/null @@ -1,104 +0,0 @@ -import struct -import panda.tests.safety.libpandasafety_py as libpandasafety_py - -safety_modes = { - "NOOUTPUT": 0, - "HONDA": 1, - "TOYOTA": 2, - "GM": 3, - "HONDA_BOSCH": 4, - "FORD": 5, - "CADILLAC": 6, - "HYUNDAI": 7, - "TESLA": 8, - "CHRYSLER": 9, - "SUBARU": 10, - "GM_ASCM": 0x1334, - "TOYOTA_IPAS": 0x1335, - "ALLOUTPUT": 0x1337, - "ELM327": 0xE327 -} - -def to_signed(d, bits): - ret = d - if d >= (1 << (bits - 1)): - ret = d - (1 << bits) - return ret - -def is_steering_msg(mode, addr): - ret = False - if mode == safety_modes["HONDA"] or mode == safety_modes["HONDA_BOSCH"]: - ret = (addr == 0xE4) or (addr == 0x194) or (addr == 0x33D) - elif mode == safety_modes["TOYOTA"]: - ret = addr == 0x2E4 - elif mode == safety_modes["GM"]: - ret = addr == 384 - elif mode == safety_modes["HYUNDAI"]: - ret = addr == 832 - elif mode == safety_modes["CHRYSLER"]: - ret = addr == 0x292 - elif mode == safety_modes["SUBARU"]: - ret = addr == 0x122 - return ret - -def get_steer_torque(mode, to_send): - ret = 0 - if mode == safety_modes["HONDA"] or mode == safety_modes["HONDA_BOSCH"]: - ret = to_send.RDLR & 0xFFFF0000 - elif mode == safety_modes["TOYOTA"]: - ret = (to_send.RDLR & 0xFF00) | ((to_send.RDLR >> 16) & 0xFF) - ret = to_signed(ret, 16) - elif mode == safety_modes["GM"]: - ret = ((to_send.RDLR & 0x7) << 8) + ((to_send.RDLR & 0xFF00) >> 8) - ret = to_signed(ret, 11) - elif mode == safety_modes["HYUNDAI"]: - ret = ((to_send.RDLR >> 16) & 0x7ff) - 1024 - elif mode == safety_modes["CHRYSLER"]: - ret = ((to_send.RDLR & 0x7) << 8) + ((to_send.RDLR & 0xFF00) >> 8) - 1024 - elif mode == safety_modes["SUBARU"]: - ret = ((to_send.RDLR >> 16) & 0x1FFF) - ret = to_signed(ret, 13) - return ret - -def set_desired_torque_last(safety, mode, torque): - if mode == safety_modes["HONDA"] or mode == safety_modes["HONDA_BOSCH"]: - pass # honda safety mode doesn't enforce a rate on steering msgs - elif mode == safety_modes["TOYOTA"]: - safety.set_toyota_desired_torque_last(torque) - elif mode == safety_modes["GM"]: - safety.set_gm_desired_torque_last(torque) - elif mode == safety_modes["HYUNDAI"]: - safety.set_hyundai_desired_torque_last(torque) - elif mode == safety_modes["CHRYSLER"]: - safety.set_chrysler_desired_torque_last(torque) - elif mode == safety_modes["SUBARU"]: - safety.set_subaru_desired_torque_last(torque) - -def package_can_msg(msg): - addr_shift = 3 if msg.address >= 0x800 else 21 - rdlr, rdhr = struct.unpack('II', msg.dat.ljust(8, b'\x00')) - - ret = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') - ret[0].RIR = msg.address << addr_shift - ret[0].RDTR = len(msg.dat) | ((msg.src & 0xF) << 4) - ret[0].RDHR = rdhr - ret[0].RDLR = rdlr - - return ret - -def init_segment(safety, lr, mode): - sendcan = (msg for msg in lr if msg.which() == 'sendcan') - steering_msgs = (can for msg in sendcan for can in msg.sendcan if is_steering_msg(mode, can.address)) - - msg = next(steering_msgs, None) - if msg is None: - # no steering msgs - return - - to_send = package_can_msg(msg) - torque = get_steer_torque(mode, to_send) - if torque != 0: - safety.set_controls_allowed(1) - set_desired_torque_last(safety, mode, torque) - assert safety.safety_tx_hook(to_send), "failed to initialize panda safety for segment" - diff --git a/panda/tests/safety_replay/install_capnp.sh b/panda/tests/safety_replay/install_capnp.sh deleted file mode 100755 index 51559d3991b0a9..00000000000000 --- a/panda/tests/safety_replay/install_capnp.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -e - -apt-get install -y autoconf curl libtool -curl -O https://capnproto.org/capnproto-c++-0.6.1.tar.gz -tar xvf capnproto-c++-0.6.1.tar.gz -cd capnproto-c++-0.6.1 -./configure --prefix=/usr/local CPPFLAGS=-DPIC CFLAGS=-fPIC CXXFLAGS=-fPIC LDFLAGS=-fPIC --disable-shared --enable-static -make -j4 -make install - diff --git a/panda/tests/safety_replay/replay_drive.py b/panda/tests/safety_replay/replay_drive.py deleted file mode 100755 index 1b2ba082ac9821..00000000000000 --- a/panda/tests/safety_replay/replay_drive.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python2 - -import os -import sys -import panda.tests.safety.libpandasafety_py as libpandasafety_py -from panda.tests.safety_replay.helpers import is_steering_msg, get_steer_torque, \ - set_desired_torque_last, package_can_msg, \ - init_segment, safety_modes -from tools.lib.logreader import LogReader - -# replay a drive to check for safety violations -def replay_drive(lr, safety_mode, param): - safety = libpandasafety_py.libpandasafety - - err = safety.safety_set_mode(safety_mode, param) - assert err == 0, "invalid safety mode: %d" % safety_mode - - if "SEGMENT" in os.environ: - init_segment(safety, lr, mode) - - tx_tot, tx_blocked, tx_controls, tx_controls_blocked = 0, 0, 0, 0 - blocked_addrs = set() - start_t = None - - for msg in lr: - if start_t is None: - start_t = msg.logMonoTime - safety.set_timer(((msg.logMonoTime / 1000)) % 0xFFFFFFFF) - - if msg.which() == 'sendcan': - for canmsg in msg.sendcan: - to_send = package_can_msg(canmsg) - sent = safety.safety_tx_hook(to_send) - if not sent: - tx_blocked += 1 - tx_controls_blocked += safety.get_controls_allowed() - blocked_addrs.add(canmsg.address) - - if "DEBUG" in os.environ: - print "blocked %d at %f" % (canmsg.address, (msg.logMonoTime - start_t)/(1e9)) - tx_controls += safety.get_controls_allowed() - tx_tot += 1 - elif msg.which() == 'can': - for canmsg in msg.can: - # ignore msgs we sent - if canmsg.src >= 128: - continue - to_push = package_can_msg(canmsg) - safety.safety_rx_hook(to_push) - - print "total openpilot msgs:", tx_tot - print "total msgs with controls allowed:", tx_controls - print "blocked msgs:", tx_blocked - print "blocked with controls allowed:", tx_controls_blocked - print "blocked addrs:", blocked_addrs - - return tx_controls_blocked == 0 - -if __name__ == "__main__": - if sys.argv[2] in safety_modes: - mode = safety_modes[sys.argv[2]] - else: - mode = int(sys.argv[2]) - param = 0 if len(sys.argv) < 4 else int(sys.argv[3]) - lr = LogReader(sys.argv[1]) - - print "replaying drive %s with safety mode %d and param %d" % (sys.argv[1], mode, param) - - replay_drive(lr, mode, param) - diff --git a/panda/tests/safety_replay/requirements.txt b/panda/tests/safety_replay/requirements.txt deleted file mode 100644 index 4c9d301dce0b4d..00000000000000 --- a/panda/tests/safety_replay/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -aenum -cffi==1.11.4 -libusb1==1.6.6 -numpy==1.14.5 -requests -subprocess32 -libarchive -pycapnp diff --git a/panda/tests/safety_replay/test_safety_replay.py b/panda/tests/safety_replay/test_safety_replay.py deleted file mode 100755 index ecc34161f2d868..00000000000000 --- a/panda/tests/safety_replay/test_safety_replay.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python2 - -import os -import requests - -from helpers import safety_modes -from replay_drive import replay_drive -from tools.lib.logreader import LogReader - -BASE_URL = "https://commadataci.blob.core.windows.net/openpilotci/" - -# (route, safety mode, param) -logs = [ - ("b0c9d2329ad1606b|2019-05-30--20-23-57.bz2", "HONDA", 0), # HONDA.CIVIC - ("38bfd238edecbcd7|2019-06-07--10-15-25.bz2", "TOYOTA", 66), # TOYOTA.PRIUS - ("f89c604cf653e2bf|2018-09-29--13-46-50.bz2", "GM", 0), # GM.VOLT - ("0375fdf7b1ce594d|2019-05-21--20-10-33.bz2", "HONDA_BOSCH", 1), # HONDA.ACCORD - ("02ec6bea180a4d36|2019-04-17--11-21-35.bz2", "HYUNDAI", 0), # HYUNDAI.SANTA_FE - ("03efb1fda29e30fe|2019-02-21--18-03-45.bz2", "CHRYSLER", 0), # CHRYSLER.PACIFICA_2018_HYBRID - ("791340bc01ed993d|2019-04-08--10-26-00.bz2", "SUBARU", 0), # SUBARU.IMPREZA -] - -if __name__ == "__main__": - for route, _, _ in logs: - if not os.path.isfile(route): - with open(route, "w") as f: - f.write(requests.get(BASE_URL + route).content) - - failed = [] - for route, mode, param in logs: - lr = LogReader(route) - m = safety_modes.get(mode, mode) - - print "\nreplaying %s with safety mode %d and param %s" % (route, m, param) - if not replay_drive(lr, m, int(param)): - failed.append(route) - - for f in failed: - print "\n**** failed on %s ****" % f - assert len(failed) == 0, "\nfailed on %d logs" % len(failed) - diff --git a/panda/tests/standalone_test.py b/panda/tests/standalone_test.py deleted file mode 100755 index ca6ea49f1056de..00000000000000 --- a/panda/tests/standalone_test.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python -import os -import sys -import struct -import time - -sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")) -from panda import Panda - -if __name__ == "__main__": - if os.getenv("WIFI") is not None: - p = Panda("WIFI") - else: - p = Panda() - print(p.get_serial()) - print(p.health()) - - t1 = time.time() - for i in range(100): - p.get_serial() - t2 = time.time() - print("100 requests took %.2f ms" % ((t2-t1)*1000)) - - p.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - - a = 0 - while True: - # flood - msg = b"\xaa"*4 + struct.pack("I", a) - p.can_send(0xaa, msg, 0) - p.can_send(0xaa, msg, 1) - p.can_send(0xaa, msg, 4) - time.sleep(0.01) - - dat = p.can_recv() - if len(dat) > 0: - print(dat) - a += 1 diff --git a/panda/tests/throughput_test.py b/panda/tests/throughput_test.py deleted file mode 100755 index 5812ce42c2aa1c..00000000000000 --- a/panda/tests/throughput_test.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -from __future__ import print_function -import os -import sys -import struct -import time -from tqdm import tqdm - -sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")) -from panda import Panda, PandaWifiStreaming - -# test throughput between USB and wifi - -if __name__ == "__main__": - print(Panda.list()) - p_out = Panda("108018800f51363038363036") - print(p_out.get_serial()) - #p_in = Panda("02001b000f51363038363036") - p_in = Panda("WIFI") - print(p_in.get_serial()) - - p_in = PandaWifiStreaming() - - #while True: - # p_in.can_recv() - #sys.exit(0) - - p_out.set_controls_allowed(True) - - set_out, set_in = set(), set() - - # drain - p_out.can_recv() - p_in.can_recv() - - BATCH_SIZE = 16 - for a in tqdm(range(0, 10000, BATCH_SIZE)): - for b in range(0, BATCH_SIZE): - msg = b"\xaa"*4 + struct.pack("I", a+b) - if a%1 == 0: - p_out.can_send(0xaa, msg, 0) - - dat_out, dat_in = p_out.can_recv(), p_in.can_recv() - if len(dat_in) != 0: - print(len(dat_in)) - - num_out = [struct.unpack("I", i[4:])[0] for _, _, i, _ in dat_out] - num_in = [struct.unpack("I", i[4:])[0] for _, _, i, _ in dat_in] - - set_in.update(num_in) - set_out.update(num_out) - - # swag - print("waiting for packets") - time.sleep(2.0) - dat_in = p_in.can_recv() - print(len(dat_in)) - num_in = [struct.unpack("I", i[4:])[0] for _, _, i, _ in dat_in] - set_in.update(num_in) - - if len(set_out - set_in): - print("MISSING %d" % len(set_out - set_in)) - if len(set_out - set_in) < 256: - print(map(hex, sorted(list(set_out - set_in)))) diff --git a/panda/tests/tucan_loopback.py b/panda/tests/tucan_loopback.py deleted file mode 100755 index a3f3e6e2d7cbad..00000000000000 --- a/panda/tests/tucan_loopback.py +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/env python -from __future__ import print_function -import os -import sys -import time -import random -import argparse - -from hexdump import hexdump -from itertools import permutations - -sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")) -from panda import Panda - -def get_test_string(): - return b"test"+os.urandom(10) - -def run_test(sleep_duration): - pandas = Panda.list() - print(pandas) - - if len(pandas) == 0: - print("NO PANDAS") - assert False - - if len(pandas) == 1: - # if we only have one on USB, assume the other is on wifi - pandas.append("WIFI") - run_test_w_pandas(pandas, sleep_duration) - -def run_test_w_pandas(pandas, sleep_duration): - h = list(map(lambda x: Panda(x), pandas)) - print("H", h) - - for hh in h: - hh.set_controls_allowed(True) - - # test both directions - for ho in permutations(range(len(h)), r=2): - print("***************** TESTING", ho) - - panda0, panda1 = h[ho[0]], h[ho[1]] - - if(panda0._serial == "WIFI"): - print(" *** Can not send can data over wifi panda. Skipping! ***") - continue - - # **** test health packet **** - print("health", ho[0], h[ho[0]].health()) - - # **** test K/L line loopback **** - for bus in [2,3]: - # flush the output - h[ho[1]].kline_drain(bus=bus) - - # send the characters - st = get_test_string() - st = b"\xaa"+chr(len(st)+3).encode()+st - h[ho[0]].kline_send(st, bus=bus, checksum=False) - - # check for receive - ret = h[ho[1]].kline_drain(bus=bus) - - print("ST Data:") - hexdump(st) - print("RET Data:") - hexdump(ret) - assert st == ret - print("K/L pass", bus, ho, "\n") - time.sleep(sleep_duration) - - # **** test can line loopback **** -# for bus, gmlan in [(0, None), (1, False), (2, False), (1, True), (2, True)]: -for bus, gmlan in [(0, None), (1, None)]: - print("\ntest can", bus) - # flush - cans_echo = panda0.can_recv() - cans_loop = panda1.can_recv() - - if gmlan is not None: - panda0.set_gmlan(gmlan, bus) - panda1.set_gmlan(gmlan, bus) - - # send the characters - # pick addresses high enough to not conflict with honda code - at = random.randint(1024, 2000) - st = get_test_string()[0:8] - panda0.can_send(at, st, bus) - time.sleep(0.1) - - # check for receive - cans_echo = panda0.can_recv() - cans_loop = panda1.can_recv() - - print("Bus", bus, "echo", cans_echo, "loop", cans_loop) - - assert len(cans_echo) == 1 - assert len(cans_loop) == 1 - - assert cans_echo[0][0] == at - assert cans_loop[0][0] == at - - assert cans_echo[0][2] == st - assert cans_loop[0][2] == st - - assert cans_echo[0][3] == 0x80 | bus - if cans_loop[0][3] != bus: - print("EXPECTED %d GOT %d" % (bus, cans_loop[0][3])) - assert cans_loop[0][3] == bus - - print("CAN pass", bus, ho) - time.sleep(sleep_duration) - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument("-n", type=int, help="Number of test iterations to run") - parser.add_argument("-sleep", type=int, help="Sleep time between tests", default=0) - args = parser.parse_args() - - if args.n is None: - while True: - run_test(sleep_duration=args.sleep) - else: - for i in range(args.n): - run_test(sleep_duration=args.sleep) diff --git a/phonelibs/SConscript b/phonelibs/SConscript new file mode 100644 index 00000000000000..a23b02a8e92226 --- /dev/null +++ b/phonelibs/SConscript @@ -0,0 +1,4 @@ +Import('env') + +env.Library('json11', ['json11/json11.cpp']) +env.Append(CPPPATH=[Dir('json11')]) diff --git a/phonelibs/boringssl/build.txt b/phonelibs/boringssl/build.txt deleted file mode 100644 index 0c9cd0d31d244e..00000000000000 --- a/phonelibs/boringssl/build.txt +++ /dev/null @@ -1,7 +0,0 @@ -# with neos tree -cd ~/android/system -mka libcrypt_static libssl_static - -cp ~/android/system/out/target/product/oneplus3/obj/STATIC_LIBRARIES/libcrypto_static_intermediates/libcrypto_static.a lib/ -cp ~/android/system/out/target/product/oneplus3/obj/STATIC_LIBRARIES/libssl_static_intermediates/libssl_static.a lib/ - diff --git a/phonelibs/boringssl/include/openssl/aead.h b/phonelibs/boringssl/include/openssl/aead.h deleted file mode 100644 index dc453e342d204c..00000000000000 --- a/phonelibs/boringssl/include/openssl/aead.h +++ /dev/null @@ -1,315 +0,0 @@ -/* Copyright (c) 2014, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -#ifndef OPENSSL_HEADER_AEAD_H -#define OPENSSL_HEADER_AEAD_H - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* Authenticated Encryption with Additional Data. - * - * AEAD couples confidentiality and integrity in a single primtive. AEAD - * algorithms take a key and then can seal and open individual messages. Each - * message has a unique, per-message nonce and, optionally, additional data - * which is authenticated but not included in the ciphertext. - * - * The |EVP_AEAD_CTX_init| function initialises an |EVP_AEAD_CTX| structure and - * performs any precomputation needed to use |aead| with |key|. The length of - * the key, |key_len|, is given in bytes. - * - * The |tag_len| argument contains the length of the tags, in bytes, and allows - * for the processing of truncated authenticators. A zero value indicates that - * the default tag length should be used and this is defined as - * |EVP_AEAD_DEFAULT_TAG_LENGTH| in order to make the code clear. Using - * truncated tags increases an attacker's chance of creating a valid forgery. - * Be aware that the attacker's chance may increase more than exponentially as - * would naively be expected. - * - * When no longer needed, the initialised |EVP_AEAD_CTX| structure must be - * passed to |EVP_AEAD_CTX_cleanup|, which will deallocate any memory used. - * - * With an |EVP_AEAD_CTX| in hand, one can seal and open messages. These - * operations are intended to meet the standard notions of privacy and - * authenticity for authenticated encryption. For formal definitions see - * Bellare and Namprempre, "Authenticated encryption: relations among notions - * and analysis of the generic composition paradigm," Lecture Notes in Computer - * Science B<1976> (2000), 531–545, - * http://www-cse.ucsd.edu/~mihir/papers/oem.html. - * - * When sealing messages, a nonce must be given. The length of the nonce is - * fixed by the AEAD in use and is returned by |EVP_AEAD_nonce_length|. *The - * nonce must be unique for all messages with the same key*. This is critically - * important - nonce reuse may completely undermine the security of the AEAD. - * Nonces may be predictable and public, so long as they are unique. Uniqueness - * may be achieved with a simple counter or, if large enough, may be generated - * randomly. The nonce must be passed into the "open" operation by the receiver - * so must either be implicit (e.g. a counter), or must be transmitted along - * with the sealed message. - * - * The "seal" and "open" operations are atomic - an entire message must be - * encrypted or decrypted in a single call. Large messages may have to be split - * up in order to accomodate this. When doing so, be mindful of the need not to - * repeat nonces and the possibility that an attacker could duplicate, reorder - * or drop message chunks. For example, using a single key for a given (large) - * message and sealing chunks with nonces counting from zero would be secure as - * long as the number of chunks was securely transmitted. (Otherwise an - * attacker could truncate the message by dropping chunks from the end.) - * - * The number of chunks could be transmitted by prefixing it to the plaintext, - * for example. This also assumes that no other message would ever use the same - * key otherwise the rule that nonces must be unique for a given key would be - * violated. - * - * The "seal" and "open" operations also permit additional data to be - * authenticated via the |ad| parameter. This data is not included in the - * ciphertext and must be identical for both the "seal" and "open" call. This - * permits implicit context to be authenticated but may be empty if not needed. - * - * The "seal" and "open" operations may work in-place if the |out| and |in| - * arguments are equal. They may also be used to shift the data left inside the - * same buffer if |out| is less than |in|. However, |out| may not point inside - * the input data otherwise the input may be overwritten before it has been - * read. This situation will cause an error. - * - * The "seal" and "open" operations return one on success and zero on error. */ - - -/* AEAD algorithms. */ - -/* EVP_aead_aes_128_gcm is AES-128 in Galois Counter Mode. */ -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_128_gcm(void); - -/* EVP_aead_aes_256_gcm is AES-256 in Galois Counter Mode. */ -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_256_gcm(void); - -/* EVP_aead_chacha20_poly1305 is an AEAD built from ChaCha20 and Poly1305. */ -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_chacha20_poly1305(void); - -/* EVP_aead_aes_128_key_wrap is AES-128 Key Wrap mode. This should never be - * used except to interoperate with existing systems that use this mode. - * - * If the nonce is empty then the default nonce will be used, otherwise it must - * be eight bytes long. The input must be a multiple of eight bytes long. No - * additional data can be given to this mode. */ -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_128_key_wrap(void); - -/* EVP_aead_aes_256_key_wrap is AES-256 in Key Wrap mode. This should never be - * used except to interoperate with existing systems that use this mode. - * - * See |EVP_aead_aes_128_key_wrap| for details. */ -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_256_key_wrap(void); - -/* EVP_aead_aes_128_ctr_hmac_sha256 is AES-128 in CTR mode with HMAC-SHA256 for - * authentication. The nonce is 12 bytes; the bottom 32-bits are used as the - * block counter, thus the maximum plaintext size is 64GB. */ -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_128_ctr_hmac_sha256(void); - -/* EVP_aead_aes_128_ctr_hmac_sha256 is AES-256 in CTR mode with HMAC-SHA256 for - * authentication. See |EVP_aead_aes_128_ctr_hmac_sha256| for details. */ -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_256_ctr_hmac_sha256(void); - -/* EVP_has_aes_hardware returns one if we enable hardware support for fast and - * constant-time AES-GCM. */ -OPENSSL_EXPORT int EVP_has_aes_hardware(void); - - -/* TLS-specific AEAD algorithms. - * - * These AEAD primitives do not meet the definition of generic AEADs. They are - * all specific to TLS and should not be used outside of that context. They must - * be initialized with |EVP_AEAD_CTX_init_with_direction|, are stateful, and may - * not be used concurrently. Any nonces are used as IVs, so they must be - * unpredictable. They only accept an |ad| parameter of length 11 (the standard - * TLS one with length omitted). */ - -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_rc4_md5_tls(void); -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_rc4_sha1_tls(void); - -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_128_cbc_sha1_tls(void); -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_128_cbc_sha1_tls_implicit_iv(void); -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_128_cbc_sha256_tls(void); - -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_256_cbc_sha1_tls(void); -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_256_cbc_sha1_tls_implicit_iv(void); -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_256_cbc_sha256_tls(void); -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_256_cbc_sha384_tls(void); - -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_des_ede3_cbc_sha1_tls(void); -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_des_ede3_cbc_sha1_tls_implicit_iv(void); - - -/* SSLv3-specific AEAD algorithms. - * - * These AEAD primitives do not meet the definition of generic AEADs. They are - * all specific to SSLv3 and should not be used outside of that context. They - * must be initialized with |EVP_AEAD_CTX_init_with_direction|, are stateful, - * and may not be used concurrently. They only accept an |ad| parameter of - * length 9 (the standard TLS one with length and version omitted). */ - -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_rc4_md5_ssl3(void); -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_rc4_sha1_ssl3(void); -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_128_cbc_sha1_ssl3(void); -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_256_cbc_sha1_ssl3(void); -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_des_ede3_cbc_sha1_ssl3(void); - - -/* Utility functions. */ - -/* EVP_AEAD_key_length returns the length, in bytes, of the keys used by - * |aead|. */ -OPENSSL_EXPORT size_t EVP_AEAD_key_length(const EVP_AEAD *aead); - -/* EVP_AEAD_nonce_length returns the length, in bytes, of the per-message nonce - * for |aead|. */ -OPENSSL_EXPORT size_t EVP_AEAD_nonce_length(const EVP_AEAD *aead); - -/* EVP_AEAD_max_overhead returns the maximum number of additional bytes added - * by the act of sealing data with |aead|. */ -OPENSSL_EXPORT size_t EVP_AEAD_max_overhead(const EVP_AEAD *aead); - -/* EVP_AEAD_max_tag_len returns the maximum tag length when using |aead|. This - * is the largest value that can be passed as |tag_len| to - * |EVP_AEAD_CTX_init|. */ -OPENSSL_EXPORT size_t EVP_AEAD_max_tag_len(const EVP_AEAD *aead); - - -/* AEAD operations. */ - -/* An EVP_AEAD_CTX represents an AEAD algorithm configured with a specific key - * and message-independent IV. */ -typedef struct evp_aead_ctx_st { - const EVP_AEAD *aead; - /* aead_state is an opaque pointer to whatever state the AEAD needs to - * maintain. */ - void *aead_state; -} EVP_AEAD_CTX; - -/* EVP_AEAD_MAX_KEY_LENGTH contains the maximum key length used by - * any AEAD defined in this header. */ -#define EVP_AEAD_MAX_KEY_LENGTH 80 - -/* EVP_AEAD_MAX_NONCE_LENGTH contains the maximum nonce length used by - * any AEAD defined in this header. */ -#define EVP_AEAD_MAX_NONCE_LENGTH 16 - -/* EVP_AEAD_MAX_OVERHEAD contains the maximum overhead used by any AEAD - * defined in this header. */ -#define EVP_AEAD_MAX_OVERHEAD 64 - -/* EVP_AEAD_DEFAULT_TAG_LENGTH is a magic value that can be passed to - * EVP_AEAD_CTX_init to indicate that the default tag length for an AEAD should - * be used. */ -#define EVP_AEAD_DEFAULT_TAG_LENGTH 0 - -/* evp_aead_direction_t denotes the direction of an AEAD operation. */ -enum evp_aead_direction_t { - evp_aead_open, - evp_aead_seal, -}; - -/* EVP_AEAD_CTX_init initializes |ctx| for the given AEAD algorithm from |impl|. - * The |impl| argument may be NULL to choose the default implementation. - * Authentication tags may be truncated by passing a size as |tag_len|. A - * |tag_len| of zero indicates the default tag length and this is defined as - * EVP_AEAD_DEFAULT_TAG_LENGTH for readability. - * - * Returns 1 on success. Otherwise returns 0 and pushes to the error stack. In - * the error case, you do not need to call |EVP_AEAD_CTX_cleanup|, but it's - * harmless to do so. */ -OPENSSL_EXPORT int EVP_AEAD_CTX_init(EVP_AEAD_CTX *ctx, const EVP_AEAD *aead, - const uint8_t *key, size_t key_len, - size_t tag_len, ENGINE *impl); - -/* EVP_AEAD_CTX_init_with_direction calls |EVP_AEAD_CTX_init| for normal - * AEADs. For TLS-specific and SSL3-specific AEADs, it initializes |ctx| for a - * given direction. */ -OPENSSL_EXPORT int EVP_AEAD_CTX_init_with_direction( - EVP_AEAD_CTX *ctx, const EVP_AEAD *aead, const uint8_t *key, size_t key_len, - size_t tag_len, enum evp_aead_direction_t dir); - -/* EVP_AEAD_CTX_cleanup frees any data allocated by |ctx|. It is a no-op to - * call |EVP_AEAD_CTX_cleanup| on a |EVP_AEAD_CTX| that has been |memset| to - * all zeros. */ -OPENSSL_EXPORT void EVP_AEAD_CTX_cleanup(EVP_AEAD_CTX *ctx); - -/* EVP_AEAD_CTX_seal encrypts and authenticates |in_len| bytes from |in| and - * authenticates |ad_len| bytes from |ad| and writes the result to |out|. It - * returns one on success and zero otherwise. - * - * This function may be called (with the same |EVP_AEAD_CTX|) concurrently with - * itself or |EVP_AEAD_CTX_open|. - * - * At most |max_out_len| bytes are written to |out| and, in order to ensure - * success, |max_out_len| should be |in_len| plus the result of - * |EVP_AEAD_max_overhead|. On successful return, |*out_len| is set to the - * actual number of bytes written. - * - * The length of |nonce|, |nonce_len|, must be equal to the result of - * |EVP_AEAD_nonce_length| for this AEAD. - * - * |EVP_AEAD_CTX_seal| never results in a partial output. If |max_out_len| is - * insufficient, zero will be returned. (In this case, |*out_len| is set to - * zero.) - * - * If |in| and |out| alias then |out| must be <= |in|. */ -OPENSSL_EXPORT int EVP_AEAD_CTX_seal(const EVP_AEAD_CTX *ctx, uint8_t *out, - size_t *out_len, size_t max_out_len, - const uint8_t *nonce, size_t nonce_len, - const uint8_t *in, size_t in_len, - const uint8_t *ad, size_t ad_len); - -/* EVP_AEAD_CTX_open authenticates |in_len| bytes from |in| and |ad_len| bytes - * from |ad| and decrypts at most |in_len| bytes into |out|. It returns one on - * success and zero otherwise. - * - * This function may be called (with the same |EVP_AEAD_CTX|) concurrently with - * itself or |EVP_AEAD_CTX_seal|. - * - * At most |in_len| bytes are written to |out|. In order to ensure success, - * |max_out_len| should be at least |in_len|. On successful return, |*out_len| - * is set to the the actual number of bytes written. - * - * The length of |nonce|, |nonce_len|, must be equal to the result of - * |EVP_AEAD_nonce_length| for this AEAD. - * - * |EVP_AEAD_CTX_open| never results in a partial output. If |max_out_len| is - * insufficient, zero will be returned. (In this case, |*out_len| is set to - * zero.) - * - * If |in| and |out| alias then |out| must be <= |in|. */ -OPENSSL_EXPORT int EVP_AEAD_CTX_open(const EVP_AEAD_CTX *ctx, uint8_t *out, - size_t *out_len, size_t max_out_len, - const uint8_t *nonce, size_t nonce_len, - const uint8_t *in, size_t in_len, - const uint8_t *ad, size_t ad_len); - - -/* Obscure functions. */ - -/* EVP_AEAD_CTX_get_rc4_state sets |*out_key| to point to an RC4 key structure. - * It returns one on success or zero if |ctx| doesn't have an RC4 key. */ -OPENSSL_EXPORT int EVP_AEAD_CTX_get_rc4_state(const EVP_AEAD_CTX *ctx, - const RC4_KEY **out_key); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_AEAD_H */ diff --git a/phonelibs/boringssl/include/openssl/aes.h b/phonelibs/boringssl/include/openssl/aes.h deleted file mode 100644 index 84cde416e64432..00000000000000 --- a/phonelibs/boringssl/include/openssl/aes.h +++ /dev/null @@ -1,158 +0,0 @@ -/* ==================================================================== - * Copyright (c) 2002-2006 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== */ - -#ifndef OPENSSL_HEADER_AES_H -#define OPENSSL_HEADER_AES_H - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* Raw AES functions. */ - - -#define AES_ENCRYPT 1 -#define AES_DECRYPT 0 - -/* AES_MAXNR is the maximum number of AES rounds. */ -#define AES_MAXNR 14 - -#define AES_BLOCK_SIZE 16 - -/* aes_key_st should be an opaque type, but EVP requires that the size be - * known. */ -struct aes_key_st { - uint32_t rd_key[4 * (AES_MAXNR + 1)]; - unsigned rounds; -}; -typedef struct aes_key_st AES_KEY; - -/* AES_set_encrypt_key configures |aeskey| to encrypt with the |bits|-bit key, - * |key|. - * - * WARNING: unlike other OpenSSL functions, this returns zero on success and a - * negative number on error. */ -OPENSSL_EXPORT int AES_set_encrypt_key(const uint8_t *key, unsigned bits, - AES_KEY *aeskey); - -/* AES_set_decrypt_key configures |aeskey| to decrypt with the |bits|-bit key, - * |key|. - * - * WARNING: unlike other OpenSSL functions, this returns zero on success and a - * negative number on error. */ -OPENSSL_EXPORT int AES_set_decrypt_key(const uint8_t *key, unsigned bits, - AES_KEY *aeskey); - -/* AES_encrypt encrypts a single block from |in| to |out| with |key|. The |in| - * and |out| pointers may overlap. */ -OPENSSL_EXPORT void AES_encrypt(const uint8_t *in, uint8_t *out, - const AES_KEY *key); - -/* AES_decrypt decrypts a single block from |in| to |out| with |key|. The |in| - * and |out| pointers may overlap. */ -OPENSSL_EXPORT void AES_decrypt(const uint8_t *in, uint8_t *out, - const AES_KEY *key); - - -/* Block cipher modes. */ - -/* AES_ctr128_encrypt encrypts (or decrypts, it's the same in CTR mode) |len| - * bytes from |in| to |out|. The |num| parameter must be set to zero on the - * first call and |ivec| will be incremented. */ -OPENSSL_EXPORT void AES_ctr128_encrypt(const uint8_t *in, uint8_t *out, - size_t len, const AES_KEY *key, - uint8_t ivec[AES_BLOCK_SIZE], - uint8_t ecount_buf[AES_BLOCK_SIZE], - unsigned int *num); - -/* AES_ecb_encrypt encrypts (or decrypts, if |enc| == |AES_DECRYPT|) a single, - * 16 byte block from |in| to |out|. */ -OPENSSL_EXPORT void AES_ecb_encrypt(const uint8_t *in, uint8_t *out, - const AES_KEY *key, const int enc); - -/* AES_cbc_encrypt encrypts (or decrypts, if |enc| == |AES_DECRYPT|) |len| - * bytes from |in| to |out|. The length must be a multiple of the block size. */ -OPENSSL_EXPORT void AES_cbc_encrypt(const uint8_t *in, uint8_t *out, size_t len, - const AES_KEY *key, uint8_t *ivec, - const int enc); - -/* AES_ofb128_encrypt encrypts (or decrypts, it's the same in CTR mode) |len| - * bytes from |in| to |out|. The |num| parameter must be set to zero on the - * first call. */ -OPENSSL_EXPORT void AES_ofb128_encrypt(const uint8_t *in, uint8_t *out, - size_t len, const AES_KEY *key, - uint8_t *ivec, int *num); - -/* AES_cfb128_encrypt encrypts (or decrypts, if |enc| == |AES_DECRYPT|) |len| - * bytes from |in| to |out|. The |num| parameter must be set to zero on the - * first call. */ -OPENSSL_EXPORT void AES_cfb128_encrypt(const uint8_t *in, uint8_t *out, - size_t len, const AES_KEY *key, - uint8_t *ivec, int *num, int enc); - - -/* Android compatibility section. - * - * These functions are declared, temporarily, for Android because - * wpa_supplicant will take a little time to sync with upstream. Outside of - * Android they'll have no definition. */ - -OPENSSL_EXPORT int AES_wrap_key(AES_KEY *key, const uint8_t *iv, uint8_t *out, - const uint8_t *in, unsigned in_len); -OPENSSL_EXPORT int AES_unwrap_key(AES_KEY *key, const uint8_t *iv, uint8_t *out, - const uint8_t *in, unsigned in_len); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_AES_H */ diff --git a/phonelibs/boringssl/include/openssl/asn1.h b/phonelibs/boringssl/include/openssl/asn1.h deleted file mode 100644 index 4baf81c6bdc442..00000000000000 --- a/phonelibs/boringssl/include/openssl/asn1.h +++ /dev/null @@ -1,1234 +0,0 @@ -/* crypto/asn1/asn1.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_ASN1_H -#define HEADER_ASN1_H - -#include - -#include - -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define V_ASN1_UNIVERSAL 0x00 -#define V_ASN1_APPLICATION 0x40 -#define V_ASN1_CONTEXT_SPECIFIC 0x80 -#define V_ASN1_PRIVATE 0xc0 - -#define V_ASN1_CONSTRUCTED 0x20 -#define V_ASN1_PRIMITIVE_TAG 0x1f -#define V_ASN1_PRIMATIVE_TAG 0x1f - -#define V_ASN1_APP_CHOOSE -2 /* let the recipient choose */ -#define V_ASN1_OTHER -3 /* used in ASN1_TYPE */ -#define V_ASN1_ANY -4 /* used in ASN1 template code */ - -#define V_ASN1_NEG 0x100 /* negative flag */ - -#define V_ASN1_UNDEF -1 -#define V_ASN1_EOC 0 -#define V_ASN1_BOOLEAN 1 /**/ -#define V_ASN1_INTEGER 2 -#define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG) -#define V_ASN1_BIT_STRING 3 -#define V_ASN1_OCTET_STRING 4 -#define V_ASN1_NULL 5 -#define V_ASN1_OBJECT 6 -#define V_ASN1_OBJECT_DESCRIPTOR 7 -#define V_ASN1_EXTERNAL 8 -#define V_ASN1_REAL 9 -#define V_ASN1_ENUMERATED 10 -#define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG) -#define V_ASN1_UTF8STRING 12 -#define V_ASN1_SEQUENCE 16 -#define V_ASN1_SET 17 -#define V_ASN1_NUMERICSTRING 18 /**/ -#define V_ASN1_PRINTABLESTRING 19 -#define V_ASN1_T61STRING 20 -#define V_ASN1_TELETEXSTRING 20 /* alias */ -#define V_ASN1_VIDEOTEXSTRING 21 /**/ -#define V_ASN1_IA5STRING 22 -#define V_ASN1_UTCTIME 23 -#define V_ASN1_GENERALIZEDTIME 24 /**/ -#define V_ASN1_GRAPHICSTRING 25 /**/ -#define V_ASN1_ISO64STRING 26 /**/ -#define V_ASN1_VISIBLESTRING 26 /* alias */ -#define V_ASN1_GENERALSTRING 27 /**/ -#define V_ASN1_UNIVERSALSTRING 28 /**/ -#define V_ASN1_BMPSTRING 30 - -/* For use with d2i_ASN1_type_bytes() */ -#define B_ASN1_NUMERICSTRING 0x0001 -#define B_ASN1_PRINTABLESTRING 0x0002 -#define B_ASN1_T61STRING 0x0004 -#define B_ASN1_TELETEXSTRING 0x0004 -#define B_ASN1_VIDEOTEXSTRING 0x0008 -#define B_ASN1_IA5STRING 0x0010 -#define B_ASN1_GRAPHICSTRING 0x0020 -#define B_ASN1_ISO64STRING 0x0040 -#define B_ASN1_VISIBLESTRING 0x0040 -#define B_ASN1_GENERALSTRING 0x0080 -#define B_ASN1_UNIVERSALSTRING 0x0100 -#define B_ASN1_OCTET_STRING 0x0200 -#define B_ASN1_BIT_STRING 0x0400 -#define B_ASN1_BMPSTRING 0x0800 -#define B_ASN1_UNKNOWN 0x1000 -#define B_ASN1_UTF8STRING 0x2000 -#define B_ASN1_UTCTIME 0x4000 -#define B_ASN1_GENERALIZEDTIME 0x8000 -#define B_ASN1_SEQUENCE 0x10000 - -/* For use with ASN1_mbstring_copy() */ -#define MBSTRING_FLAG 0x1000 -#define MBSTRING_UTF8 (MBSTRING_FLAG) -#define MBSTRING_ASC (MBSTRING_FLAG|1) -#define MBSTRING_BMP (MBSTRING_FLAG|2) -#define MBSTRING_UNIV (MBSTRING_FLAG|4) - -#define SMIME_OLDMIME 0x400 -#define SMIME_CRLFEOL 0x800 -#define SMIME_STREAM 0x1000 - -#define DECLARE_ASN1_SET_OF(type) /* filled in by mkstack.pl */ -#define IMPLEMENT_ASN1_SET_OF(type) /* nothing, no longer needed */ - -/* We MUST make sure that, except for constness, asn1_ctx_st and - asn1_const_ctx are exactly the same. Fortunately, as soon as - the old ASN1 parsing macros are gone, we can throw this away - as well... */ -typedef struct asn1_ctx_st - { - unsigned char *p;/* work char pointer */ - int eos; /* end of sequence read for indefinite encoding */ - int error; /* error code to use when returning an error */ - int inf; /* constructed if 0x20, indefinite is 0x21 */ - int tag; /* tag from last 'get object' */ - int xclass; /* class from last 'get object' */ - long slen; /* length of last 'get object' */ - unsigned char *max; /* largest value of p allowed */ - unsigned char *q;/* temporary variable */ - unsigned char **pp;/* variable */ - int line; /* used in error processing */ - } ASN1_CTX; - -typedef struct asn1_const_ctx_st - { - const unsigned char *p;/* work char pointer */ - int eos; /* end of sequence read for indefinite encoding */ - int error; /* error code to use when returning an error */ - int inf; /* constructed if 0x20, indefinite is 0x21 */ - int tag; /* tag from last 'get object' */ - int xclass; /* class from last 'get object' */ - long slen; /* length of last 'get object' */ - const unsigned char *max; /* largest value of p allowed */ - const unsigned char *q;/* temporary variable */ - const unsigned char **pp;/* variable */ - int line; /* used in error processing */ - } ASN1_const_CTX; - -/* These are used internally in the ASN1_OBJECT to keep track of - * whether the names and data need to be free()ed */ -#define ASN1_OBJECT_FLAG_DYNAMIC 0x01 /* internal use */ -#define ASN1_OBJECT_FLAG_CRITICAL 0x02 /* critical x509v3 object id */ -#define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04 /* internal use */ -#define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08 /* internal use */ -struct asn1_object_st - { - const char *sn,*ln; - int nid; - int length; - const unsigned char *data; /* data remains const after init */ - int flags; /* Should we free this one */ - }; - -#define ASN1_STRING_FLAG_BITS_LEFT 0x08 /* Set if 0x07 has bits left value */ -/* This indicates that the ASN1_STRING is not a real value but just a place - * holder for the location where indefinite length constructed data should - * be inserted in the memory buffer - */ -#define ASN1_STRING_FLAG_NDEF 0x010 - -/* This flag is used by the CMS code to indicate that a string is not - * complete and is a place holder for content when it had all been - * accessed. The flag will be reset when content has been written to it. - */ - -#define ASN1_STRING_FLAG_CONT 0x020 -/* This flag is used by ASN1 code to indicate an ASN1_STRING is an MSTRING - * type. - */ -#define ASN1_STRING_FLAG_MSTRING 0x040 -/* This is the base type that holds just about everything :-) */ -struct asn1_string_st - { - int length; - int type; - unsigned char *data; - /* The value of the following field depends on the type being - * held. It is mostly being used for BIT_STRING so if the - * input data has a non-zero 'unused bits' value, it will be - * handled correctly */ - long flags; - }; - -/* ASN1_ENCODING structure: this is used to save the received - * encoding of an ASN1 type. This is useful to get round - * problems with invalid encodings which can break signatures. - */ - -typedef struct ASN1_ENCODING_st - { - unsigned char *enc; /* DER encoding */ - long len; /* Length of encoding */ - int modified; /* set to 1 if 'enc' is invalid */ - } ASN1_ENCODING; - -/* Used with ASN1 LONG type: if a long is set to this it is omitted */ -#define ASN1_LONG_UNDEF 0x7fffffffL - -#define STABLE_FLAGS_MALLOC 0x01 -#define STABLE_NO_MASK 0x02 -#define DIRSTRING_TYPE \ - (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING) -#define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING) - -typedef struct asn1_string_table_st { - int nid; - long minsize; - long maxsize; - unsigned long mask; - unsigned long flags; -} ASN1_STRING_TABLE; - -/* size limits: this stuff is taken straight from RFC2459 */ - -#define ub_name 32768 -#define ub_common_name 64 -#define ub_locality_name 128 -#define ub_state_name 128 -#define ub_organization_name 64 -#define ub_organization_unit_name 64 -#define ub_title 64 -#define ub_email_address 128 - -/* Declarations for template structures: for full definitions - * see asn1t.h - */ -typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE; -typedef struct ASN1_TLC_st ASN1_TLC; -/* This is just an opaque pointer */ -typedef struct ASN1_VALUE_st ASN1_VALUE; - -/* Declare ASN1 functions: the implement macro in in asn1t.h */ - -#define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type) - -#define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \ - DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type) - -#define DECLARE_ASN1_FUNCTIONS_name(type, name) \ - DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ - DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) - -#define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \ - DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ - DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) - -#define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \ - OPENSSL_EXPORT type *d2i_##name(type **a, const unsigned char **in, long len); \ - OPENSSL_EXPORT int i2d_##name(type *a, unsigned char **out); \ - DECLARE_ASN1_ITEM(itname) - -#define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \ - OPENSSL_EXPORT type *d2i_##name(type **a, const unsigned char **in, long len); \ - OPENSSL_EXPORT int i2d_##name(const type *a, unsigned char **out); \ - DECLARE_ASN1_ITEM(name) - -#define DECLARE_ASN1_NDEF_FUNCTION(name) \ - OPENSSL_EXPORT int i2d_##name##_NDEF(name *a, unsigned char **out); - -#define DECLARE_ASN1_FUNCTIONS_const(name) \ - DECLARE_ASN1_ALLOC_FUNCTIONS(name) \ - DECLARE_ASN1_ENCODE_FUNCTIONS_const(name, name) - -#define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ - OPENSSL_EXPORT type *name##_new(void); \ - OPENSSL_EXPORT void name##_free(type *a); - -#define DECLARE_ASN1_PRINT_FUNCTION(stname) \ - DECLARE_ASN1_PRINT_FUNCTION_fname(stname, stname) - -#define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \ - OPENSSL_EXPORT int fname##_print_ctx(BIO *out, stname *x, int indent, \ - const ASN1_PCTX *pctx); - -#define D2I_OF(type) type *(*)(type **,const unsigned char **,long) -#define I2D_OF(type) int (*)(type *,unsigned char **) -#define I2D_OF_const(type) int (*)(const type *,unsigned char **) - -#define CHECKED_D2I_OF(type, d2i) \ - ((d2i_of_void*) (1 ? d2i : ((D2I_OF(type))0))) -#define CHECKED_I2D_OF(type, i2d) \ - ((i2d_of_void*) (1 ? i2d : ((I2D_OF(type))0))) -#define CHECKED_NEW_OF(type, xnew) \ - ((void *(*)(void)) (1 ? xnew : ((type *(*)(void))0))) -#define CHECKED_PPTR_OF(type, p) \ - ((void**) (1 ? p : (type**)0)) - -#define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long) -#define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(const type *,unsigned char **) -#define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type) - -TYPEDEF_D2I2D_OF(void); - -/* The following macros and typedefs allow an ASN1_ITEM - * to be embedded in a structure and referenced. Since - * the ASN1_ITEM pointers need to be globally accessible - * (possibly from shared libraries) they may exist in - * different forms. On platforms that support it the - * ASN1_ITEM structure itself will be globally exported. - * Other platforms will export a function that returns - * an ASN1_ITEM pointer. - * - * To handle both cases transparently the macros below - * should be used instead of hard coding an ASN1_ITEM - * pointer in a structure. - * - * The structure will look like this: - * - * typedef struct SOMETHING_st { - * ... - * ASN1_ITEM_EXP *iptr; - * ... - * } SOMETHING; - * - * It would be initialised as e.g.: - * - * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...}; - * - * and the actual pointer extracted with: - * - * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr); - * - * Finally an ASN1_ITEM pointer can be extracted from an - * appropriate reference with: ASN1_ITEM_rptr(X509). This - * would be used when a function takes an ASN1_ITEM * argument. - * - */ - -/* ASN1_ITEM pointer exported type */ -typedef const ASN1_ITEM ASN1_ITEM_EXP; - -/* Macro to obtain ASN1_ITEM pointer from exported type */ -#define ASN1_ITEM_ptr(iptr) (iptr) - -/* Macro to include ASN1_ITEM pointer from base type */ -#define ASN1_ITEM_ref(iptr) (&(iptr##_it)) - -#define ASN1_ITEM_rptr(ref) (&(ref##_it)) - -#define DECLARE_ASN1_ITEM(name) \ - extern OPENSSL_EXPORT const ASN1_ITEM name##_it; - -/* Parameters used by ASN1_STRING_print_ex() */ - -/* These determine which characters to escape: - * RFC2253 special characters, control characters and - * MSB set characters - */ - -#define ASN1_STRFLGS_ESC_2253 1 -#define ASN1_STRFLGS_ESC_CTRL 2 -#define ASN1_STRFLGS_ESC_MSB 4 - - -/* This flag determines how we do escaping: normally - * RC2253 backslash only, set this to use backslash and - * quote. - */ - -#define ASN1_STRFLGS_ESC_QUOTE 8 - - -/* These three flags are internal use only. */ - -/* Character is a valid PrintableString character */ -#define CHARTYPE_PRINTABLESTRING 0x10 -/* Character needs escaping if it is the first character */ -#define CHARTYPE_FIRST_ESC_2253 0x20 -/* Character needs escaping if it is the last character */ -#define CHARTYPE_LAST_ESC_2253 0x40 - -/* NB the internal flags are safely reused below by flags - * handled at the top level. - */ - -/* If this is set we convert all character strings - * to UTF8 first - */ - -#define ASN1_STRFLGS_UTF8_CONVERT 0x10 - -/* If this is set we don't attempt to interpret content: - * just assume all strings are 1 byte per character. This - * will produce some pretty odd looking output! - */ - -#define ASN1_STRFLGS_IGNORE_TYPE 0x20 - -/* If this is set we include the string type in the output */ -#define ASN1_STRFLGS_SHOW_TYPE 0x40 - -/* This determines which strings to display and which to - * 'dump' (hex dump of content octets or DER encoding). We can - * only dump non character strings or everything. If we - * don't dump 'unknown' they are interpreted as character - * strings with 1 octet per character and are subject to - * the usual escaping options. - */ - -#define ASN1_STRFLGS_DUMP_ALL 0x80 -#define ASN1_STRFLGS_DUMP_UNKNOWN 0x100 - -/* These determine what 'dumping' does, we can dump the - * content octets or the DER encoding: both use the - * RFC2253 #XXXXX notation. - */ - -#define ASN1_STRFLGS_DUMP_DER 0x200 - -/* All the string flags consistent with RFC2253, - * escaping control characters isn't essential in - * RFC2253 but it is advisable anyway. - */ - -#define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | \ - ASN1_STRFLGS_ESC_CTRL | \ - ASN1_STRFLGS_ESC_MSB | \ - ASN1_STRFLGS_UTF8_CONVERT | \ - ASN1_STRFLGS_DUMP_UNKNOWN | \ - ASN1_STRFLGS_DUMP_DER) - -DECLARE_ASN1_SET_OF(ASN1_INTEGER) - -typedef struct asn1_type_st - { - int type; - union { - char *ptr; - ASN1_BOOLEAN boolean; - ASN1_STRING * asn1_string; - ASN1_OBJECT * object; - ASN1_INTEGER * integer; - ASN1_ENUMERATED * enumerated; - ASN1_BIT_STRING * bit_string; - ASN1_OCTET_STRING * octet_string; - ASN1_PRINTABLESTRING * printablestring; - ASN1_T61STRING * t61string; - ASN1_IA5STRING * ia5string; - ASN1_GENERALSTRING * generalstring; - ASN1_BMPSTRING * bmpstring; - ASN1_UNIVERSALSTRING * universalstring; - ASN1_UTCTIME * utctime; - ASN1_GENERALIZEDTIME * generalizedtime; - ASN1_VISIBLESTRING * visiblestring; - ASN1_UTF8STRING * utf8string; - /* set and sequence are left complete and still - * contain the set or sequence bytes */ - ASN1_STRING * set; - ASN1_STRING * sequence; - ASN1_VALUE * asn1_value; - } value; - } ASN1_TYPE; - -DECLARE_ASN1_SET_OF(ASN1_TYPE) - -typedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY; - -DECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY) -DECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SET_ANY) - -struct X509_algor_st - { - ASN1_OBJECT *algorithm; - ASN1_TYPE *parameter; - } /* X509_ALGOR */; -DEFINE_STACK_OF(X509_ALGOR); - -DECLARE_ASN1_FUNCTIONS(X509_ALGOR) - -typedef struct NETSCAPE_X509_st - { - ASN1_OCTET_STRING *header; - X509 *cert; - } NETSCAPE_X509; - -/* This is used to contain a list of bit names */ -typedef struct BIT_STRING_BITNAME_st { - int bitnum; - const char *lname; - const char *sname; -} BIT_STRING_BITNAME; - - -#define M_ASN1_STRING_length(x) ((x)->length) -#define M_ASN1_STRING_length_set(x, n) ((x)->length = (n)) -#define M_ASN1_STRING_type(x) ((x)->type) -#define M_ASN1_STRING_data(x) ((x)->data) - -/* Macros for string operations */ -#define M_ASN1_BIT_STRING_new() (ASN1_BIT_STRING *)\ - ASN1_STRING_type_new(V_ASN1_BIT_STRING) -#define M_ASN1_BIT_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\ - ASN1_STRING_dup((const ASN1_STRING *)a) -#define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\ - (const ASN1_STRING *)a,(const ASN1_STRING *)b) -#define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) - -#define M_ASN1_INTEGER_new() (ASN1_INTEGER *)\ - ASN1_STRING_type_new(V_ASN1_INTEGER) -#define M_ASN1_INTEGER_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)\ - ASN1_STRING_dup((const ASN1_STRING *)a) -#define M_ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\ - (const ASN1_STRING *)a,(const ASN1_STRING *)b) - -#define M_ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\ - ASN1_STRING_type_new(V_ASN1_ENUMERATED) -#define M_ASN1_ENUMERATED_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)\ - ASN1_STRING_dup((const ASN1_STRING *)a) -#define M_ASN1_ENUMERATED_cmp(a,b) ASN1_STRING_cmp(\ - (const ASN1_STRING *)a,(const ASN1_STRING *)b) - -#define M_ASN1_OCTET_STRING_new() (ASN1_OCTET_STRING *)\ - ASN1_STRING_type_new(V_ASN1_OCTET_STRING) -#define M_ASN1_OCTET_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\ - ASN1_STRING_dup((const ASN1_STRING *)a) -#define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\ - (const ASN1_STRING *)a,(const ASN1_STRING *)b) -#define M_ASN1_OCTET_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) -#define M_ASN1_OCTET_STRING_print(a,b) ASN1_STRING_print(a,(ASN1_STRING *)b) -#define M_i2d_ASN1_OCTET_STRING(a,pp) \ - i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\ - V_ASN1_UNIVERSAL) - -#define B_ASN1_TIME \ - B_ASN1_UTCTIME | \ - B_ASN1_GENERALIZEDTIME - -#define B_ASN1_PRINTABLE \ - B_ASN1_NUMERICSTRING| \ - B_ASN1_PRINTABLESTRING| \ - B_ASN1_T61STRING| \ - B_ASN1_IA5STRING| \ - B_ASN1_BIT_STRING| \ - B_ASN1_UNIVERSALSTRING|\ - B_ASN1_BMPSTRING|\ - B_ASN1_UTF8STRING|\ - B_ASN1_SEQUENCE|\ - B_ASN1_UNKNOWN - -#define B_ASN1_DIRECTORYSTRING \ - B_ASN1_PRINTABLESTRING| \ - B_ASN1_TELETEXSTRING|\ - B_ASN1_BMPSTRING|\ - B_ASN1_UNIVERSALSTRING|\ - B_ASN1_UTF8STRING - -#define B_ASN1_DISPLAYTEXT \ - B_ASN1_IA5STRING| \ - B_ASN1_VISIBLESTRING| \ - B_ASN1_BMPSTRING|\ - B_ASN1_UTF8STRING - -#define M_ASN1_PRINTABLE_new() ASN1_STRING_type_new(V_ASN1_T61STRING) -#define M_ASN1_PRINTABLE_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ - pp,a->type,V_ASN1_UNIVERSAL) -#define M_d2i_ASN1_PRINTABLE(a,pp,l) \ - d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ - B_ASN1_PRINTABLE) - -#define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) -#define M_DIRECTORYSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ - pp,a->type,V_ASN1_UNIVERSAL) -#define M_d2i_DIRECTORYSTRING(a,pp,l) \ - d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ - B_ASN1_DIRECTORYSTRING) - -#define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) -#define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ - pp,a->type,V_ASN1_UNIVERSAL) -#define M_d2i_DISPLAYTEXT(a,pp,l) \ - d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ - B_ASN1_DISPLAYTEXT) - -#define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\ - ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) -#define M_ASN1_PRINTABLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_i2d_ASN1_PRINTABLESTRING(a,pp) \ - i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\ - V_ASN1_UNIVERSAL) -#define M_d2i_ASN1_PRINTABLESTRING(a,pp,l) \ - (ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\ - ((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING) - -#define M_ASN1_T61STRING_new() (ASN1_T61STRING *)\ - ASN1_STRING_type_new(V_ASN1_T61STRING) -#define M_ASN1_T61STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_i2d_ASN1_T61STRING(a,pp) \ - i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\ - V_ASN1_UNIVERSAL) -#define M_d2i_ASN1_T61STRING(a,pp,l) \ - (ASN1_T61STRING *)d2i_ASN1_type_bytes\ - ((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING) - -#define M_ASN1_IA5STRING_new() (ASN1_IA5STRING *)\ - ASN1_STRING_type_new(V_ASN1_IA5STRING) -#define M_ASN1_IA5STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_ASN1_IA5STRING_dup(a) \ - (ASN1_IA5STRING *)ASN1_STRING_dup((const ASN1_STRING *)a) -#define M_i2d_ASN1_IA5STRING(a,pp) \ - i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\ - V_ASN1_UNIVERSAL) -#define M_d2i_ASN1_IA5STRING(a,pp,l) \ - (ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\ - B_ASN1_IA5STRING) - -#define M_ASN1_UTCTIME_new() (ASN1_UTCTIME *)\ - ASN1_STRING_type_new(V_ASN1_UTCTIME) -#define M_ASN1_UTCTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)\ - ASN1_STRING_dup((const ASN1_STRING *)a) - -#define M_ASN1_GENERALIZEDTIME_new() (ASN1_GENERALIZEDTIME *)\ - ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME) -#define M_ASN1_GENERALIZEDTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\ - (const ASN1_STRING *)a) - -#define M_ASN1_TIME_new() (ASN1_TIME *)\ - ASN1_STRING_type_new(V_ASN1_UTCTIME) -#define M_ASN1_TIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_ASN1_TIME_dup(a) (ASN1_TIME *)\ - ASN1_STRING_dup((const ASN1_STRING *)a) - -#define M_ASN1_GENERALSTRING_new() (ASN1_GENERALSTRING *)\ - ASN1_STRING_type_new(V_ASN1_GENERALSTRING) -#define M_ASN1_GENERALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_i2d_ASN1_GENERALSTRING(a,pp) \ - i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\ - V_ASN1_UNIVERSAL) -#define M_d2i_ASN1_GENERALSTRING(a,pp,l) \ - (ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\ - ((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING) - -#define M_ASN1_UNIVERSALSTRING_new() (ASN1_UNIVERSALSTRING *)\ - ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING) -#define M_ASN1_UNIVERSALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \ - i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\ - V_ASN1_UNIVERSAL) -#define M_d2i_ASN1_UNIVERSALSTRING(a,pp,l) \ - (ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\ - ((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING) - -#define M_ASN1_BMPSTRING_new() (ASN1_BMPSTRING *)\ - ASN1_STRING_type_new(V_ASN1_BMPSTRING) -#define M_ASN1_BMPSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_i2d_ASN1_BMPSTRING(a,pp) \ - i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\ - V_ASN1_UNIVERSAL) -#define M_d2i_ASN1_BMPSTRING(a,pp,l) \ - (ASN1_BMPSTRING *)d2i_ASN1_type_bytes\ - ((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING) - -#define M_ASN1_VISIBLESTRING_new() (ASN1_VISIBLESTRING *)\ - ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) -#define M_ASN1_VISIBLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_i2d_ASN1_VISIBLESTRING(a,pp) \ - i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\ - V_ASN1_UNIVERSAL) -#define M_d2i_ASN1_VISIBLESTRING(a,pp,l) \ - (ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\ - ((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING) - -#define M_ASN1_UTF8STRING_new() (ASN1_UTF8STRING *)\ - ASN1_STRING_type_new(V_ASN1_UTF8STRING) -#define M_ASN1_UTF8STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) -#define M_i2d_ASN1_UTF8STRING(a,pp) \ - i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\ - V_ASN1_UNIVERSAL) -#define M_d2i_ASN1_UTF8STRING(a,pp,l) \ - (ASN1_UTF8STRING *)d2i_ASN1_type_bytes\ - ((ASN1_STRING **)a,pp,l,B_ASN1_UTF8STRING) - - /* for the is_set parameter to i2d_ASN1_SET */ -#define IS_SEQUENCE 0 -#define IS_SET 1 - -DECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE) - -OPENSSL_EXPORT int ASN1_TYPE_get(ASN1_TYPE *a); -OPENSSL_EXPORT void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value); -OPENSSL_EXPORT int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value); -OPENSSL_EXPORT int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b); - -OPENSSL_EXPORT ASN1_OBJECT * ASN1_OBJECT_new(void ); -OPENSSL_EXPORT void ASN1_OBJECT_free(ASN1_OBJECT *a); -OPENSSL_EXPORT int i2d_ASN1_OBJECT(ASN1_OBJECT *a,unsigned char **pp); -OPENSSL_EXPORT ASN1_OBJECT * c2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp, - long length); -OPENSSL_EXPORT ASN1_OBJECT * d2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp, - long length); - -DECLARE_ASN1_ITEM(ASN1_OBJECT) - -DECLARE_ASN1_SET_OF(ASN1_OBJECT) - -OPENSSL_EXPORT ASN1_STRING * ASN1_STRING_new(void); -OPENSSL_EXPORT void ASN1_STRING_free(ASN1_STRING *a); -OPENSSL_EXPORT int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str); -OPENSSL_EXPORT ASN1_STRING * ASN1_STRING_dup(const ASN1_STRING *a); -OPENSSL_EXPORT ASN1_STRING * ASN1_STRING_type_new(int type ); -OPENSSL_EXPORT int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b); - /* Since this is used to store all sorts of things, via macros, for now, make - its data void * */ -OPENSSL_EXPORT int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); -OPENSSL_EXPORT void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len); -OPENSSL_EXPORT int ASN1_STRING_length(const ASN1_STRING *x); -OPENSSL_EXPORT void ASN1_STRING_length_set(ASN1_STRING *x, int n); -OPENSSL_EXPORT int ASN1_STRING_type(ASN1_STRING *x); -OPENSSL_EXPORT unsigned char * ASN1_STRING_data(ASN1_STRING *x); - -DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING) -OPENSSL_EXPORT int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp); -OPENSSL_EXPORT ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,const unsigned char **pp, long length); -OPENSSL_EXPORT int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length ); -OPENSSL_EXPORT int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); -OPENSSL_EXPORT int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n); -OPENSSL_EXPORT int ASN1_BIT_STRING_check(ASN1_BIT_STRING *a, unsigned char *flags, int flags_len); - -OPENSSL_EXPORT int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, BIT_STRING_BITNAME *tbl, int indent); -OPENSSL_EXPORT int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl); -OPENSSL_EXPORT int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value, BIT_STRING_BITNAME *tbl); - -OPENSSL_EXPORT int i2d_ASN1_BOOLEAN(int a,unsigned char **pp); -OPENSSL_EXPORT int d2i_ASN1_BOOLEAN(int *a,const unsigned char **pp,long length); - -DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER) -OPENSSL_EXPORT int i2c_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp); -OPENSSL_EXPORT ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a,const unsigned char **pp, long length); -OPENSSL_EXPORT ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,const unsigned char **pp, long length); -OPENSSL_EXPORT ASN1_INTEGER * ASN1_INTEGER_dup(const ASN1_INTEGER *x); -OPENSSL_EXPORT int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y); - -DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED) - -OPENSSL_EXPORT int ASN1_UTCTIME_check(const ASN1_UTCTIME *a); -OPENSSL_EXPORT ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t); -OPENSSL_EXPORT ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, int offset_day, long offset_sec); -OPENSSL_EXPORT int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str); -OPENSSL_EXPORT int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t); -#if 0 -time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s); -#endif - -OPENSSL_EXPORT int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a); -OPENSSL_EXPORT ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t); -OPENSSL_EXPORT ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, time_t t, int offset_day, long offset_sec); -OPENSSL_EXPORT int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str); -OPENSSL_EXPORT int ASN1_TIME_diff(int *pday, int *psec, const ASN1_TIME *from, const ASN1_TIME *to); - -DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING) -OPENSSL_EXPORT ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a); -OPENSSL_EXPORT int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a, const ASN1_OCTET_STRING *b); -OPENSSL_EXPORT int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, int len); - -DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING) -DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING) -DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING) -DECLARE_ASN1_FUNCTIONS(ASN1_NULL) -DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING) - -OPENSSL_EXPORT int UTF8_getc(const unsigned char *str, int len, unsigned long *val); -OPENSSL_EXPORT int UTF8_putc(unsigned char *str, int len, unsigned long value); - -DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE) - -DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING) -DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT) -DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING) -DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING) -DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING) -DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING) -DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME) -DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME) -DECLARE_ASN1_FUNCTIONS(ASN1_TIME) - -DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF) - -OPENSSL_EXPORT ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t); -OPENSSL_EXPORT ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s,time_t t, int offset_day, long offset_sec); -OPENSSL_EXPORT int ASN1_TIME_check(ASN1_TIME *t); -OPENSSL_EXPORT ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out); -OPENSSL_EXPORT int ASN1_TIME_set_string(ASN1_TIME *s, const char *str); - -OPENSSL_EXPORT int i2d_ASN1_SET(STACK_OF(OPENSSL_BLOCK) *a, unsigned char **pp, i2d_of_void *i2d, int ex_tag, int ex_class, int is_set); -OPENSSL_EXPORT STACK_OF(OPENSSL_BLOCK) *d2i_ASN1_SET(STACK_OF(OPENSSL_BLOCK) **a, - const unsigned char **pp, - long length, d2i_of_void *d2i, - void (*free_func)(OPENSSL_BLOCK), int ex_tag, - int ex_class); - -OPENSSL_EXPORT int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a); -OPENSSL_EXPORT int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size); -OPENSSL_EXPORT int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a); -OPENSSL_EXPORT int a2i_ASN1_ENUMERATED(BIO *bp,ASN1_ENUMERATED *bs,char *buf,int size); -OPENSSL_EXPORT int i2a_ASN1_OBJECT(BIO *bp,ASN1_OBJECT *a); -OPENSSL_EXPORT int a2i_ASN1_STRING(BIO *bp,ASN1_STRING *bs,char *buf,int size); -OPENSSL_EXPORT int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type); -OPENSSL_EXPORT int i2t_ASN1_OBJECT(char *buf,int buf_len,ASN1_OBJECT *a); - -OPENSSL_EXPORT int a2d_ASN1_OBJECT(unsigned char *out,int olen, const char *buf, int num); -OPENSSL_EXPORT ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data,int len, const char *sn, const char *ln); - -OPENSSL_EXPORT int ASN1_INTEGER_set(ASN1_INTEGER *a, long v); -OPENSSL_EXPORT long ASN1_INTEGER_get(const ASN1_INTEGER *a); -OPENSSL_EXPORT ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai); -OPENSSL_EXPORT BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai,BIGNUM *bn); - -OPENSSL_EXPORT int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v); -OPENSSL_EXPORT long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a); -OPENSSL_EXPORT ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai); -OPENSSL_EXPORT BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai,BIGNUM *bn); - -/* General */ -/* given a string, return the correct type, max is the maximum length */ -OPENSSL_EXPORT int ASN1_PRINTABLE_type(const unsigned char *s, int max); - -OPENSSL_EXPORT int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass); -OPENSSL_EXPORT ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp, long length, int Ptag, int Pclass); -OPENSSL_EXPORT unsigned long ASN1_tag2bit(int tag); -/* type is one or more of the B_ASN1_ values. */ -OPENSSL_EXPORT ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a,const unsigned char **pp, long length,int type); - -/* PARSING */ -OPENSSL_EXPORT int asn1_Finish(ASN1_CTX *c); -OPENSSL_EXPORT int asn1_const_Finish(ASN1_const_CTX *c); - -/* SPECIALS */ -OPENSSL_EXPORT int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, int *pclass, long omax); -OPENSSL_EXPORT int ASN1_check_infinite_end(unsigned char **p,long len); -OPENSSL_EXPORT int ASN1_const_check_infinite_end(const unsigned char **p,long len); -OPENSSL_EXPORT void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag, int xclass); -OPENSSL_EXPORT int ASN1_put_eoc(unsigned char **pp); -OPENSSL_EXPORT int ASN1_object_size(int constructed, int length, int tag); - -/* Used to implement other functions */ -OPENSSL_EXPORT void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x); - -#define ASN1_dup_of(type,i2d,d2i,x) \ - ((type*)ASN1_dup(CHECKED_I2D_OF(type, i2d), \ - CHECKED_D2I_OF(type, d2i), \ - CHECKED_PTR_OF(type, x))) - -#define ASN1_dup_of_const(type,i2d,d2i,x) \ - ((type*)ASN1_dup(CHECKED_I2D_OF(const type, i2d), \ - CHECKED_D2I_OF(type, d2i), \ - CHECKED_PTR_OF(const type, x))) - -OPENSSL_EXPORT void *ASN1_item_dup(const ASN1_ITEM *it, void *x); - -/* ASN1 alloc/free macros for when a type is only used internally */ - -#define M_ASN1_new_of(type) (type *)ASN1_item_new(ASN1_ITEM_rptr(type)) -#define M_ASN1_free_of(x, type) \ - ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type)) - -#ifndef OPENSSL_NO_FP_API -OPENSSL_EXPORT void *ASN1_d2i_fp(void *(*xnew)(void), d2i_of_void *d2i, FILE *in, void **x); - -#define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \ - ((type*)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), \ - CHECKED_D2I_OF(type, d2i), \ - in, \ - CHECKED_PPTR_OF(type, x))) - -OPENSSL_EXPORT void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x); -OPENSSL_EXPORT int ASN1_i2d_fp(i2d_of_void *i2d,FILE *out,void *x); - -#define ASN1_i2d_fp_of(type,i2d,out,x) \ - (ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), \ - out, \ - CHECKED_PTR_OF(type, x))) - -#define ASN1_i2d_fp_of_const(type,i2d,out,x) \ - (ASN1_i2d_fp(CHECKED_I2D_OF(const type, i2d), \ - out, \ - CHECKED_PTR_OF(const type, x))) - -OPENSSL_EXPORT int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x); -OPENSSL_EXPORT int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags); -#endif - -OPENSSL_EXPORT int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in); - -OPENSSL_EXPORT void *ASN1_d2i_bio(void *(*xnew)(void), d2i_of_void *d2i, BIO *in, void **x); - -#define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \ - ((type*)ASN1_d2i_bio( CHECKED_NEW_OF(type, xnew), \ - CHECKED_D2I_OF(type, d2i), \ - in, \ - CHECKED_PPTR_OF(type, x))) - -OPENSSL_EXPORT void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x); -OPENSSL_EXPORT int ASN1_i2d_bio(i2d_of_void *i2d,BIO *out, unsigned char *x); - -#define ASN1_i2d_bio_of(type,i2d,out,x) \ - (ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), \ - out, \ - CHECKED_PTR_OF(type, x))) - -#define ASN1_i2d_bio_of_const(type,i2d,out,x) \ - (ASN1_i2d_bio(CHECKED_I2D_OF(const type, i2d), \ - out, \ - CHECKED_PTR_OF(const type, x))) - -OPENSSL_EXPORT int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x); -OPENSSL_EXPORT int ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a); -OPENSSL_EXPORT int ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a); -OPENSSL_EXPORT int ASN1_TIME_print(BIO *fp, const ASN1_TIME *a); -OPENSSL_EXPORT int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v); -OPENSSL_EXPORT int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags); -OPENSSL_EXPORT int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, unsigned char *buf, int off); -OPENSSL_EXPORT int ASN1_parse(BIO *bp,const unsigned char *pp,long len,int indent); -OPENSSL_EXPORT int ASN1_parse_dump(BIO *bp,const unsigned char *pp,long len,int indent,int dump); -OPENSSL_EXPORT const char *ASN1_tag2str(int tag); - -/* Used to load and write netscape format cert */ - -DECLARE_ASN1_FUNCTIONS(NETSCAPE_X509) - -int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s); - -OPENSSL_EXPORT STACK_OF(OPENSSL_BLOCK) *ASN1_seq_unpack(const unsigned char *buf, int len, d2i_of_void *d2i, void (*free_func)(OPENSSL_BLOCK)); -OPENSSL_EXPORT unsigned char *ASN1_seq_pack(STACK_OF(OPENSSL_BLOCK) *safes, i2d_of_void *i2d, unsigned char **buf, int *len ); -OPENSSL_EXPORT void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i); -OPENSSL_EXPORT void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it); -OPENSSL_EXPORT ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d, ASN1_OCTET_STRING **oct); - -#define ASN1_pack_string_of(type,obj,i2d,oct) \ - (ASN1_pack_string(CHECKED_PTR_OF(type, obj), \ - CHECKED_I2D_OF(type, i2d), \ - oct)) - -OPENSSL_EXPORT ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_OCTET_STRING **oct); - -OPENSSL_EXPORT void ASN1_STRING_set_default_mask(unsigned long mask); -OPENSSL_EXPORT int ASN1_STRING_set_default_mask_asc(const char *p); -OPENSSL_EXPORT unsigned long ASN1_STRING_get_default_mask(void); -OPENSSL_EXPORT int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len, int inform, unsigned long mask); -OPENSSL_EXPORT int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, int inform, unsigned long mask, long minsize, long maxsize); - -OPENSSL_EXPORT ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, const unsigned char *in, int inlen, int inform, int nid); -OPENSSL_EXPORT ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid); -OPENSSL_EXPORT int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long); -OPENSSL_EXPORT void ASN1_STRING_TABLE_cleanup(void); - -/* ASN1 template functions */ - -/* Old API compatible functions */ -OPENSSL_EXPORT ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it); -OPENSSL_EXPORT void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it); -OPENSSL_EXPORT ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_ITEM *it); -OPENSSL_EXPORT int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); -OPENSSL_EXPORT int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); - -OPENSSL_EXPORT void ASN1_add_oid_module(void); - -OPENSSL_EXPORT ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf); -OPENSSL_EXPORT ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf); - -/* ASN1 Print flags */ - -/* Indicate missing OPTIONAL fields */ -#define ASN1_PCTX_FLAGS_SHOW_ABSENT 0x001 -/* Mark start and end of SEQUENCE */ -#define ASN1_PCTX_FLAGS_SHOW_SEQUENCE 0x002 -/* Mark start and end of SEQUENCE/SET OF */ -#define ASN1_PCTX_FLAGS_SHOW_SSOF 0x004 -/* Show the ASN1 type of primitives */ -#define ASN1_PCTX_FLAGS_SHOW_TYPE 0x008 -/* Don't show ASN1 type of ANY */ -#define ASN1_PCTX_FLAGS_NO_ANY_TYPE 0x010 -/* Don't show ASN1 type of MSTRINGs */ -#define ASN1_PCTX_FLAGS_NO_MSTRING_TYPE 0x020 -/* Don't show field names in SEQUENCE */ -#define ASN1_PCTX_FLAGS_NO_FIELD_NAME 0x040 -/* Show structure names of each SEQUENCE field */ -#define ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME 0x080 -/* Don't show structure name even at top level */ -#define ASN1_PCTX_FLAGS_NO_STRUCT_NAME 0x100 - -OPENSSL_EXPORT int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent, const ASN1_ITEM *it, const ASN1_PCTX *pctx); -OPENSSL_EXPORT ASN1_PCTX *ASN1_PCTX_new(void); -OPENSSL_EXPORT void ASN1_PCTX_free(ASN1_PCTX *p); -OPENSSL_EXPORT unsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p); -OPENSSL_EXPORT void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags); -OPENSSL_EXPORT unsigned long ASN1_PCTX_get_nm_flags(ASN1_PCTX *p); -OPENSSL_EXPORT void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags); -OPENSSL_EXPORT unsigned long ASN1_PCTX_get_cert_flags(ASN1_PCTX *p); -OPENSSL_EXPORT void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags); -OPENSSL_EXPORT unsigned long ASN1_PCTX_get_oid_flags(ASN1_PCTX *p); -OPENSSL_EXPORT void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags); -OPENSSL_EXPORT unsigned long ASN1_PCTX_get_str_flags(ASN1_PCTX *p); -OPENSSL_EXPORT void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags); - -OPENSSL_EXPORT const BIO_METHOD *BIO_f_asn1(void); - -OPENSSL_EXPORT BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it); - -OPENSSL_EXPORT int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, const ASN1_ITEM *it); -OPENSSL_EXPORT int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, const char *hdr, const ASN1_ITEM *it); -OPENSSL_EXPORT ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it); -OPENSSL_EXPORT int SMIME_crlf_copy(BIO *in, BIO *out, int flags); -OPENSSL_EXPORT int SMIME_text(BIO *in, BIO *out); - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_ASN1_strings(void); - -typedef int asn1_ps_func(BIO *b, unsigned char **pbuf, int *plen, void *parg); -OPENSSL_EXPORT int BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix, asn1_ps_func *prefix_free); -OPENSSL_EXPORT int BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix, asn1_ps_func **pprefix_free); -OPENSSL_EXPORT int BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix, asn1_ps_func *suffix_free); -OPENSSL_EXPORT int BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix, asn1_ps_func **psuffix_free); - -#ifdef __cplusplus -} -#endif - -#define ASN1_F_ASN1_BIT_STRING_set_bit 100 -#define ASN1_F_ASN1_ENUMERATED_set 101 -#define ASN1_F_ASN1_ENUMERATED_to_BN 102 -#define ASN1_F_ASN1_GENERALIZEDTIME_adj 103 -#define ASN1_F_ASN1_INTEGER_set 104 -#define ASN1_F_ASN1_INTEGER_to_BN 105 -#define ASN1_F_ASN1_OBJECT_new 106 -#define ASN1_F_ASN1_PCTX_new 107 -#define ASN1_F_ASN1_STRING_TABLE_add 108 -#define ASN1_F_ASN1_STRING_set 109 -#define ASN1_F_ASN1_STRING_type_new 110 -#define ASN1_F_ASN1_TIME_adj 111 -#define ASN1_F_ASN1_UTCTIME_adj 112 -#define ASN1_F_ASN1_d2i_fp 113 -#define ASN1_F_ASN1_dup 114 -#define ASN1_F_ASN1_generate_v3 115 -#define ASN1_F_ASN1_get_object 116 -#define ASN1_F_ASN1_i2d_bio 117 -#define ASN1_F_ASN1_i2d_fp 118 -#define ASN1_F_ASN1_item_d2i_fp 119 -#define ASN1_F_ASN1_item_dup 120 -#define ASN1_F_ASN1_item_ex_d2i 121 -#define ASN1_F_ASN1_item_i2d_bio 122 -#define ASN1_F_ASN1_item_i2d_fp 123 -#define ASN1_F_ASN1_item_pack 124 -#define ASN1_F_ASN1_item_unpack 125 -#define ASN1_F_ASN1_mbstring_ncopy 126 -#define ASN1_F_ASN1_template_new 127 -#define ASN1_F_BIO_new_NDEF 128 -#define ASN1_F_BN_to_ASN1_ENUMERATED 129 -#define ASN1_F_BN_to_ASN1_INTEGER 130 -#define ASN1_F_a2d_ASN1_OBJECT 131 -#define ASN1_F_a2i_ASN1_ENUMERATED 132 -#define ASN1_F_a2i_ASN1_INTEGER 133 -#define ASN1_F_a2i_ASN1_STRING 134 -#define ASN1_F_append_exp 135 -#define ASN1_F_asn1_cb 136 -#define ASN1_F_asn1_check_tlen 137 -#define ASN1_F_asn1_collate_primitive 138 -#define ASN1_F_asn1_collect 139 -#define ASN1_F_asn1_d2i_ex_primitive 140 -#define ASN1_F_asn1_d2i_read_bio 141 -#define ASN1_F_asn1_do_adb 142 -#define ASN1_F_asn1_ex_c2i 143 -#define ASN1_F_asn1_find_end 144 -#define ASN1_F_asn1_item_ex_combine_new 145 -#define ASN1_F_asn1_str2type 146 -#define ASN1_F_asn1_template_ex_d2i 147 -#define ASN1_F_asn1_template_noexp_d2i 148 -#define ASN1_F_bitstr_cb 149 -#define ASN1_F_c2i_ASN1_BIT_STRING 150 -#define ASN1_F_c2i_ASN1_INTEGER 151 -#define ASN1_F_c2i_ASN1_OBJECT 152 -#define ASN1_F_collect_data 153 -#define ASN1_F_d2i_ASN1_BOOLEAN 154 -#define ASN1_F_d2i_ASN1_OBJECT 155 -#define ASN1_F_d2i_ASN1_UINTEGER 156 -#define ASN1_F_d2i_ASN1_UTCTIME 157 -#define ASN1_F_d2i_ASN1_bytes 158 -#define ASN1_F_d2i_ASN1_type_bytes 159 -#define ASN1_F_i2d_ASN1_TIME 160 -#define ASN1_F_i2d_PrivateKey 161 -#define ASN1_F_long_c2i 162 -#define ASN1_F_parse_tagging 163 -#define ASN1_R_ASN1_LENGTH_MISMATCH 100 -#define ASN1_R_AUX_ERROR 101 -#define ASN1_R_BAD_GET_ASN1_OBJECT_CALL 102 -#define ASN1_R_BAD_OBJECT_HEADER 103 -#define ASN1_R_BMPSTRING_IS_WRONG_LENGTH 104 -#define ASN1_R_BN_LIB 105 -#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 106 -#define ASN1_R_BUFFER_TOO_SMALL 107 -#define ASN1_R_DECODE_ERROR 108 -#define ASN1_R_DEPTH_EXCEEDED 109 -#define ASN1_R_ENCODE_ERROR 110 -#define ASN1_R_ERROR_GETTING_TIME 111 -#define ASN1_R_EXPECTING_AN_ASN1_SEQUENCE 112 -#define ASN1_R_EXPECTING_AN_INTEGER 113 -#define ASN1_R_EXPECTING_AN_OBJECT 114 -#define ASN1_R_EXPECTING_A_BOOLEAN 115 -#define ASN1_R_EXPECTING_A_TIME 116 -#define ASN1_R_EXPLICIT_LENGTH_MISMATCH 117 -#define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED 118 -#define ASN1_R_FIELD_MISSING 119 -#define ASN1_R_FIRST_NUM_TOO_LARGE 120 -#define ASN1_R_HEADER_TOO_LONG 121 -#define ASN1_R_ILLEGAL_BITSTRING_FORMAT 122 -#define ASN1_R_ILLEGAL_BOOLEAN 123 -#define ASN1_R_ILLEGAL_CHARACTERS 124 -#define ASN1_R_ILLEGAL_FORMAT 125 -#define ASN1_R_ILLEGAL_HEX 126 -#define ASN1_R_ILLEGAL_IMPLICIT_TAG 127 -#define ASN1_R_ILLEGAL_INTEGER 128 -#define ASN1_R_ILLEGAL_NESTED_TAGGING 129 -#define ASN1_R_ILLEGAL_NULL 130 -#define ASN1_R_ILLEGAL_NULL_VALUE 131 -#define ASN1_R_ILLEGAL_OBJECT 132 -#define ASN1_R_ILLEGAL_OPTIONAL_ANY 133 -#define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE 134 -#define ASN1_R_ILLEGAL_TAGGED_ANY 135 -#define ASN1_R_ILLEGAL_TIME_VALUE 136 -#define ASN1_R_INTEGER_NOT_ASCII_FORMAT 137 -#define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 138 -#define ASN1_R_INVALID_BIT_STRING_BITS_LEFT 139 -#define ASN1_R_INVALID_BMPSTRING_LENGTH 140 -#define ASN1_R_INVALID_DIGIT 141 -#define ASN1_R_INVALID_MODIFIER 142 -#define ASN1_R_INVALID_NUMBER 143 -#define ASN1_R_INVALID_OBJECT_ENCODING 144 -#define ASN1_R_INVALID_SEPARATOR 145 -#define ASN1_R_INVALID_TIME_FORMAT 146 -#define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 147 -#define ASN1_R_INVALID_UTF8STRING 148 -#define ASN1_R_LIST_ERROR 149 -#define ASN1_R_MALLOC_FAILURE 150 -#define ASN1_R_MISSING_ASN1_EOS 151 -#define ASN1_R_MISSING_EOC 152 -#define ASN1_R_MISSING_SECOND_NUMBER 153 -#define ASN1_R_MISSING_VALUE 154 -#define ASN1_R_MSTRING_NOT_UNIVERSAL 155 -#define ASN1_R_MSTRING_WRONG_TAG 156 -#define ASN1_R_NESTED_ASN1_ERROR 157 -#define ASN1_R_NESTED_ASN1_STRING 158 -#define ASN1_R_NON_HEX_CHARACTERS 159 -#define ASN1_R_NOT_ASCII_FORMAT 160 -#define ASN1_R_NOT_ENOUGH_DATA 161 -#define ASN1_R_NO_MATCHING_CHOICE_TYPE 162 -#define ASN1_R_NULL_IS_WRONG_LENGTH 163 -#define ASN1_R_OBJECT_NOT_ASCII_FORMAT 164 -#define ASN1_R_ODD_NUMBER_OF_CHARS 165 -#define ASN1_R_SECOND_NUMBER_TOO_LARGE 166 -#define ASN1_R_SEQUENCE_LENGTH_MISMATCH 167 -#define ASN1_R_SEQUENCE_NOT_CONSTRUCTED 168 -#define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG 169 -#define ASN1_R_SHORT_LINE 170 -#define ASN1_R_STREAMING_NOT_SUPPORTED 171 -#define ASN1_R_STRING_TOO_LONG 172 -#define ASN1_R_STRING_TOO_SHORT 173 -#define ASN1_R_TAG_VALUE_TOO_HIGH 174 -#define ASN1_R_TIME_NOT_ASCII_FORMAT 175 -#define ASN1_R_TOO_LONG 176 -#define ASN1_R_TYPE_NOT_CONSTRUCTED 177 -#define ASN1_R_TYPE_NOT_PRIMITIVE 178 -#define ASN1_R_UNEXPECTED_EOC 179 -#define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH 180 -#define ASN1_R_UNKNOWN_FORMAT 181 -#define ASN1_R_UNKNOWN_TAG 182 -#define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 183 -#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 184 -#define ASN1_R_UNSUPPORTED_TYPE 185 -#define ASN1_R_WRONG_TAG 186 -#define ASN1_R_WRONG_TYPE 187 - -#endif diff --git a/phonelibs/boringssl/include/openssl/asn1_mac.h b/phonelibs/boringssl/include/openssl/asn1_mac.h deleted file mode 100644 index 49b2a286b77020..00000000000000 --- a/phonelibs/boringssl/include/openssl/asn1_mac.h +++ /dev/null @@ -1,76 +0,0 @@ -/* crypto/asn1/asn1_mac.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_ASN1_MAC_H -#define HEADER_ASN1_MAC_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -OPENSSL_EXPORT int asn1_GetSequence(ASN1_const_CTX *c, long *length); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/boringssl/include/openssl/asn1t.h b/phonelibs/boringssl/include/openssl/asn1t.h deleted file mode 100644 index 0f2560b7156396..00000000000000 --- a/phonelibs/boringssl/include/openssl/asn1t.h +++ /dev/null @@ -1,907 +0,0 @@ -/* asn1t.h */ -/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL - * project 2000. - */ -/* ==================================================================== - * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ -#ifndef HEADER_ASN1T_H -#define HEADER_ASN1T_H - -#include -#include - -#ifdef OPENSSL_BUILD_SHLIBCRYPTO -# undef OPENSSL_EXTERN -# define OPENSSL_EXTERN OPENSSL_EXPORT -#endif - -/* ASN1 template defines, structures and functions */ - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */ -#define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr)) - - -/* Macros for start and end of ASN1_ITEM definition */ - -#define ASN1_ITEM_start(itname) \ - const ASN1_ITEM itname##_it = { - -#define ASN1_ITEM_end(itname) \ - }; - -/* Macros to aid ASN1 template writing */ - -#define ASN1_ITEM_TEMPLATE(tname) \ - static const ASN1_TEMPLATE tname##_item_tt - -#define ASN1_ITEM_TEMPLATE_END(tname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_PRIMITIVE,\ - -1,\ - &tname##_item_tt,\ - 0,\ - NULL,\ - 0,\ - #tname \ - ASN1_ITEM_end(tname) - - -/* This is a ASN1 type which just embeds a template */ - -/* This pair helps declare a SEQUENCE. We can do: - * - * ASN1_SEQUENCE(stname) = { - * ... SEQUENCE components ... - * } ASN1_SEQUENCE_END(stname) - * - * This will produce an ASN1_ITEM called stname_it - * for a structure called stname. - * - * If you want the same structure but a different - * name then use: - * - * ASN1_SEQUENCE(itname) = { - * ... SEQUENCE components ... - * } ASN1_SEQUENCE_END_name(stname, itname) - * - * This will create an item called itname_it using - * a structure called stname. - */ - -#define ASN1_SEQUENCE(tname) \ - static const ASN1_TEMPLATE tname##_seq_tt[] - -#define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname) - -#define ASN1_SEQUENCE_END_name(stname, tname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - NULL,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - -#define ASN1_NDEF_SEQUENCE(tname) \ - ASN1_SEQUENCE(tname) - -#define ASN1_NDEF_SEQUENCE_cb(tname, cb) \ - ASN1_SEQUENCE_cb(tname, cb) - -#define ASN1_SEQUENCE_cb(tname, cb) \ - static const ASN1_AUX tname##_aux = {NULL, 0, 0, cb, 0}; \ - ASN1_SEQUENCE(tname) - -#define ASN1_BROKEN_SEQUENCE(tname) \ - static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0}; \ - ASN1_SEQUENCE(tname) - -#define ASN1_SEQUENCE_ref(tname, cb) \ - static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), cb, 0}; \ - ASN1_SEQUENCE(tname) - -#define ASN1_SEQUENCE_enc(tname, enc, cb) \ - static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, cb, offsetof(tname, enc)}; \ - ASN1_SEQUENCE(tname) - -#define ASN1_NDEF_SEQUENCE_END(tname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_NDEF_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - NULL,\ - sizeof(tname),\ - #tname \ - ASN1_ITEM_end(tname) - -#define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname) - -#define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) - -#define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) - -#define ASN1_SEQUENCE_END_ref(stname, tname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - &tname##_aux,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - -#define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_NDEF_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - &tname##_aux,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - - -/* This pair helps declare a CHOICE type. We can do: - * - * ASN1_CHOICE(chname) = { - * ... CHOICE options ... - * ASN1_CHOICE_END(chname) - * - * This will produce an ASN1_ITEM called chname_it - * for a structure called chname. The structure - * definition must look like this: - * typedef struct { - * int type; - * union { - * ASN1_SOMETHING *opt1; - * ASN1_SOMEOTHER *opt2; - * } value; - * } chname; - * - * the name of the selector must be 'type'. - * to use an alternative selector name use the - * ASN1_CHOICE_END_selector() version. - */ - -#define ASN1_CHOICE(tname) \ - static const ASN1_TEMPLATE tname##_ch_tt[] - -#define ASN1_CHOICE_cb(tname, cb) \ - static const ASN1_AUX tname##_aux = {NULL, 0, 0, cb, 0}; \ - ASN1_CHOICE(tname) - -#define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname) - -#define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type) - -#define ASN1_CHOICE_END_selector(stname, tname, selname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_CHOICE,\ - offsetof(stname,selname) ,\ - tname##_ch_tt,\ - sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ - NULL,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - -#define ASN1_CHOICE_END_cb(stname, tname, selname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_CHOICE,\ - offsetof(stname,selname) ,\ - tname##_ch_tt,\ - sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ - &tname##_aux,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - -/* This helps with the template wrapper form of ASN1_ITEM */ - -#define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \ - (flags), (tag), 0,\ - #name, ASN1_ITEM_ref(type) } - -/* These help with SEQUENCE or CHOICE components */ - -/* used to declare other types */ - -#define ASN1_EX_TYPE(flags, tag, stname, field, type) { \ - (flags), (tag), offsetof(stname, field),\ - #field, ASN1_ITEM_ref(type) } - -/* used when the structure is combined with the parent */ - -#define ASN1_EX_COMBINE(flags, tag, type) { \ - (flags)|ASN1_TFLG_COMBINE, (tag), 0, NULL, ASN1_ITEM_ref(type) } - -/* implicit and explicit helper macros */ - -#define ASN1_IMP_EX(stname, field, type, tag, ex) \ - ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type) - -#define ASN1_EXP_EX(stname, field, type, tag, ex) \ - ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type) - -/* Any defined by macros: the field used is in the table itself */ - -#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } -#define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } -/* Plain simple type */ -#define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type) - -/* OPTIONAL simple type */ -#define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type) - -/* IMPLICIT tagged simple type */ -#define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0) - -/* IMPLICIT tagged OPTIONAL simple type */ -#define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) - -/* Same as above but EXPLICIT */ - -#define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0) -#define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) - -/* SEQUENCE OF type */ -#define ASN1_SEQUENCE_OF(stname, field, type) \ - ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type) - -/* OPTIONAL SEQUENCE OF */ -#define ASN1_SEQUENCE_OF_OPT(stname, field, type) \ - ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) - -/* Same as above but for SET OF */ - -#define ASN1_SET_OF(stname, field, type) \ - ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type) - -#define ASN1_SET_OF_OPT(stname, field, type) \ - ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) - -/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */ - -#define ASN1_IMP_SET_OF(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) - -#define ASN1_EXP_SET_OF(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) - -#define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) - -#define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) - -#define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) - -#define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) - -#define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) - -#define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) - -/* EXPLICIT using indefinite length constructed form */ -#define ASN1_NDEF_EXP(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF) - -/* EXPLICIT OPTIONAL using indefinite length constructed form */ -#define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF) - -/* Macros for the ASN1_ADB structure */ - -#define ASN1_ADB(name) \ - static const ASN1_ADB_TABLE name##_adbtbl[] - -#define ASN1_ADB_END(name, flags, field, app_table, def, none) \ - ;\ - static const ASN1_ADB name##_adb = {\ - flags,\ - offsetof(name, field),\ - app_table,\ - name##_adbtbl,\ - sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ - def,\ - none\ - } - -#define ADB_ENTRY(val, template) {val, template} - -#define ASN1_ADB_TEMPLATE(name) \ - static const ASN1_TEMPLATE name##_tt - -/* This is the ASN1 template structure that defines - * a wrapper round the actual type. It determines the - * actual position of the field in the value structure, - * various flags such as OPTIONAL and the field name. - */ - -struct ASN1_TEMPLATE_st { -unsigned long flags; /* Various flags */ -long tag; /* tag, not used if no tagging */ -unsigned long offset; /* Offset of this field in structure */ -#ifndef NO_ASN1_FIELD_NAMES -const char *field_name; /* Field name */ -#endif -ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */ -}; - -/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */ - -#define ASN1_TEMPLATE_item(t) (t->item_ptr) -#define ASN1_TEMPLATE_adb(t) (t->item_ptr) - -typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE; -typedef struct ASN1_ADB_st ASN1_ADB; - -struct ASN1_ADB_st { - unsigned long flags; /* Various flags */ - unsigned long offset; /* Offset of selector field */ - STACK_OF(ASN1_ADB_TABLE) **app_items; /* Application defined items */ - const ASN1_ADB_TABLE *tbl; /* Table of possible types */ - long tblcount; /* Number of entries in tbl */ - const ASN1_TEMPLATE *default_tt; /* Type to use if no match */ - const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */ -}; - -struct ASN1_ADB_TABLE_st { - long value; /* NID for an object or value for an int */ - const ASN1_TEMPLATE tt; /* item for this value */ -}; - -/* template flags */ - -/* Field is optional */ -#define ASN1_TFLG_OPTIONAL (0x1) - -/* Field is a SET OF */ -#define ASN1_TFLG_SET_OF (0x1 << 1) - -/* Field is a SEQUENCE OF */ -#define ASN1_TFLG_SEQUENCE_OF (0x2 << 1) - -/* Special case: this refers to a SET OF that - * will be sorted into DER order when encoded *and* - * the corresponding STACK will be modified to match - * the new order. - */ -#define ASN1_TFLG_SET_ORDER (0x3 << 1) - -/* Mask for SET OF or SEQUENCE OF */ -#define ASN1_TFLG_SK_MASK (0x3 << 1) - -/* These flags mean the tag should be taken from the - * tag field. If EXPLICIT then the underlying type - * is used for the inner tag. - */ - -/* IMPLICIT tagging */ -#define ASN1_TFLG_IMPTAG (0x1 << 3) - - -/* EXPLICIT tagging, inner tag from underlying type */ -#define ASN1_TFLG_EXPTAG (0x2 << 3) - -#define ASN1_TFLG_TAG_MASK (0x3 << 3) - -/* context specific IMPLICIT */ -#define ASN1_TFLG_IMPLICIT ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT - -/* context specific EXPLICIT */ -#define ASN1_TFLG_EXPLICIT ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT - -/* If tagging is in force these determine the - * type of tag to use. Otherwise the tag is - * determined by the underlying type. These - * values reflect the actual octet format. - */ - -/* Universal tag */ -#define ASN1_TFLG_UNIVERSAL (0x0<<6) -/* Application tag */ -#define ASN1_TFLG_APPLICATION (0x1<<6) -/* Context specific tag */ -#define ASN1_TFLG_CONTEXT (0x2<<6) -/* Private tag */ -#define ASN1_TFLG_PRIVATE (0x3<<6) - -#define ASN1_TFLG_TAG_CLASS (0x3<<6) - -/* These are for ANY DEFINED BY type. In this case - * the 'item' field points to an ASN1_ADB structure - * which contains a table of values to decode the - * relevant type - */ - -#define ASN1_TFLG_ADB_MASK (0x3<<8) - -#define ASN1_TFLG_ADB_OID (0x1<<8) - -#define ASN1_TFLG_ADB_INT (0x1<<9) - -/* This flag means a parent structure is passed - * instead of the field: this is useful is a - * SEQUENCE is being combined with a CHOICE for - * example. Since this means the structure and - * item name will differ we need to use the - * ASN1_CHOICE_END_name() macro for example. - */ - -#define ASN1_TFLG_COMBINE (0x1<<10) - -/* This flag when present in a SEQUENCE OF, SET OF - * or EXPLICIT causes indefinite length constructed - * encoding to be used if required. - */ - -#define ASN1_TFLG_NDEF (0x1<<11) - -/* This is the actual ASN1 item itself */ - -struct ASN1_ITEM_st { -char itype; /* The item type, primitive, SEQUENCE, CHOICE or extern */ -long utype; /* underlying type */ -const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains the contents */ -long tcount; /* Number of templates if SEQUENCE or CHOICE */ -const void *funcs; /* functions that handle this type */ -long size; /* Structure size (usually)*/ -#ifndef NO_ASN1_FIELD_NAMES -const char *sname; /* Structure name */ -#endif -}; - -/* These are values for the itype field and - * determine how the type is interpreted. - * - * For PRIMITIVE types the underlying type - * determines the behaviour if items is NULL. - * - * Otherwise templates must contain a single - * template and the type is treated in the - * same way as the type specified in the template. - * - * For SEQUENCE types the templates field points - * to the members, the size field is the - * structure size. - * - * For CHOICE types the templates field points - * to each possible member (typically a union) - * and the 'size' field is the offset of the - * selector. - * - * The 'funcs' field is used for application - * specific functions. - * - * For COMPAT types the funcs field gives a - * set of functions that handle this type, this - * supports the old d2i, i2d convention. - * - * The EXTERN type uses a new style d2i/i2d. - * The new style should be used where possible - * because it avoids things like the d2i IMPLICIT - * hack. - * - * MSTRING is a multiple string type, it is used - * for a CHOICE of character strings where the - * actual strings all occupy an ASN1_STRING - * structure. In this case the 'utype' field - * has a special meaning, it is used as a mask - * of acceptable types using the B_ASN1 constants. - * - * NDEF_SEQUENCE is the same as SEQUENCE except - * that it will use indefinite length constructed - * encoding if requested. - * - */ - -#define ASN1_ITYPE_PRIMITIVE 0x0 - -#define ASN1_ITYPE_SEQUENCE 0x1 - -#define ASN1_ITYPE_CHOICE 0x2 - -#define ASN1_ITYPE_COMPAT 0x3 - -#define ASN1_ITYPE_EXTERN 0x4 - -#define ASN1_ITYPE_MSTRING 0x5 - -#define ASN1_ITYPE_NDEF_SEQUENCE 0x6 - -/* Cache for ASN1 tag and length, so we - * don't keep re-reading it for things - * like CHOICE - */ - -struct ASN1_TLC_st{ - char valid; /* Values below are valid */ - int ret; /* return value */ - long plen; /* length */ - int ptag; /* class value */ - int pclass; /* class value */ - int hdrlen; /* header length */ -}; - -/* Typedefs for ASN1 function pointers */ - -typedef ASN1_VALUE * ASN1_new_func(void); -typedef void ASN1_free_func(ASN1_VALUE *a); -typedef ASN1_VALUE * ASN1_d2i_func(ASN1_VALUE **a, const unsigned char ** in, long length); -typedef int ASN1_i2d_func(ASN1_VALUE * a, unsigned char **in); - -typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, - int tag, int aclass, char opt, ASN1_TLC *ctx); - -typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass); -typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it); -typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it); - -typedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval, - int indent, const char *fname, - const ASN1_PCTX *pctx); - -typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); -typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); -typedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, const ASN1_PCTX *pctx); - -typedef struct ASN1_COMPAT_FUNCS_st { - ASN1_new_func *asn1_new; - ASN1_free_func *asn1_free; - ASN1_d2i_func *asn1_d2i; - ASN1_i2d_func *asn1_i2d; -} ASN1_COMPAT_FUNCS; - -typedef struct ASN1_EXTERN_FUNCS_st { - void *app_data; - ASN1_ex_new_func *asn1_ex_new; - ASN1_ex_free_func *asn1_ex_free; - ASN1_ex_free_func *asn1_ex_clear; - ASN1_ex_d2i *asn1_ex_d2i; - ASN1_ex_i2d *asn1_ex_i2d; - ASN1_ex_print_func *asn1_ex_print; -} ASN1_EXTERN_FUNCS; - -typedef struct ASN1_PRIMITIVE_FUNCS_st { - void *app_data; - unsigned long flags; - ASN1_ex_new_func *prim_new; - ASN1_ex_free_func *prim_free; - ASN1_ex_free_func *prim_clear; - ASN1_primitive_c2i *prim_c2i; - ASN1_primitive_i2c *prim_i2c; - ASN1_primitive_print *prim_print; -} ASN1_PRIMITIVE_FUNCS; - -/* This is the ASN1_AUX structure: it handles various - * miscellaneous requirements. For example the use of - * reference counts and an informational callback. - * - * The "informational callback" is called at various - * points during the ASN1 encoding and decoding. It can - * be used to provide minor customisation of the structures - * used. This is most useful where the supplied routines - * *almost* do the right thing but need some extra help - * at a few points. If the callback returns zero then - * it is assumed a fatal error has occurred and the - * main operation should be abandoned. - * - * If major changes in the default behaviour are required - * then an external type is more appropriate. - */ - -typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it, - void *exarg); - -typedef struct ASN1_AUX_st { - void *app_data; - int flags; - int ref_offset; /* Offset of reference value */ - ASN1_aux_cb *asn1_cb; - int enc_offset; /* Offset of ASN1_ENCODING structure */ -} ASN1_AUX; - -/* For print related callbacks exarg points to this structure */ -typedef struct ASN1_PRINT_ARG_st { - BIO *out; - int indent; - const ASN1_PCTX *pctx; -} ASN1_PRINT_ARG; - -/* For streaming related callbacks exarg points to this structure */ -typedef struct ASN1_STREAM_ARG_st { - /* BIO to stream through */ - BIO *out; - /* BIO with filters appended */ - BIO *ndef_bio; - /* Streaming I/O boundary */ - unsigned char **boundary; -} ASN1_STREAM_ARG; - -/* Flags in ASN1_AUX */ - -/* Use a reference count */ -#define ASN1_AFLG_REFCOUNT 1 -/* Save the encoding of structure (useful for signatures) */ -#define ASN1_AFLG_ENCODING 2 -/* The Sequence length is invalid */ -#define ASN1_AFLG_BROKEN 4 - -/* operation values for asn1_cb */ - -#define ASN1_OP_NEW_PRE 0 -#define ASN1_OP_NEW_POST 1 -#define ASN1_OP_FREE_PRE 2 -#define ASN1_OP_FREE_POST 3 -#define ASN1_OP_D2I_PRE 4 -#define ASN1_OP_D2I_POST 5 -#define ASN1_OP_I2D_PRE 6 -#define ASN1_OP_I2D_POST 7 -#define ASN1_OP_PRINT_PRE 8 -#define ASN1_OP_PRINT_POST 9 -#define ASN1_OP_STREAM_PRE 10 -#define ASN1_OP_STREAM_POST 11 -#define ASN1_OP_DETACHED_PRE 12 -#define ASN1_OP_DETACHED_POST 13 - -/* Macro to implement a primitive type */ -#define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0) -#define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \ - ASN1_ITEM_start(itname) \ - ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \ - ASN1_ITEM_end(itname) - -/* Macro to implement a multi string type */ -#define IMPLEMENT_ASN1_MSTRING(itname, mask) \ - ASN1_ITEM_start(itname) \ - ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \ - ASN1_ITEM_end(itname) - -/* Macro to implement an ASN1_ITEM in terms of old style funcs */ - -#define IMPLEMENT_COMPAT_ASN1(sname) IMPLEMENT_COMPAT_ASN1_type(sname, V_ASN1_SEQUENCE) - -#define IMPLEMENT_COMPAT_ASN1_type(sname, tag) \ - static const ASN1_COMPAT_FUNCS sname##_ff = { \ - (ASN1_new_func *)sname##_new, \ - (ASN1_free_func *)sname##_free, \ - (ASN1_d2i_func *)d2i_##sname, \ - (ASN1_i2d_func *)i2d_##sname, \ - }; \ - ASN1_ITEM_start(sname) \ - ASN1_ITYPE_COMPAT, \ - tag, \ - NULL, \ - 0, \ - &sname##_ff, \ - 0, \ - #sname \ - ASN1_ITEM_end(sname) - -#define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \ - ASN1_ITEM_start(sname) \ - ASN1_ITYPE_EXTERN, \ - tag, \ - NULL, \ - 0, \ - &fptrs, \ - 0, \ - #sname \ - ASN1_ITEM_end(sname) - -/* Macro to implement standard functions in terms of ASN1_ITEM structures */ - -#define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname) - -#define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname) - -#define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \ - IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname) - -#define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \ - IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname) - -#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \ - IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname) - -#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \ - pre stname *fname##_new(void) \ - { \ - return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ - } \ - pre void fname##_free(stname *a) \ - { \ - ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ - } - -#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \ - stname *fname##_new(void) \ - { \ - return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ - } \ - void fname##_free(stname *a) \ - { \ - ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ - } - -#define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \ - IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ - IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) - -#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ - stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ - { \ - return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ - } \ - int i2d_##fname(stname *a, unsigned char **out) \ - { \ - return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ - } - -#define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \ - int i2d_##stname##_NDEF(stname *a, unsigned char **out) \ - { \ - return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\ - } - -/* This includes evil casts to remove const: they will go away when full - * ASN1 constification is done. - */ -#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ - stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ - { \ - return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ - } \ - int i2d_##fname(const stname *a, unsigned char **out) \ - { \ - return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ - } - -#define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \ - stname * stname##_dup(stname *x) \ - { \ - return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \ - } - -#define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \ - IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname) - -#define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \ - int fname##_print_ctx(BIO *out, stname *x, int indent, \ - const ASN1_PCTX *pctx) \ - { \ - return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \ - ASN1_ITEM_rptr(itname), pctx); \ - } - -#define IMPLEMENT_ASN1_FUNCTIONS_const(name) \ - IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name) - -#define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \ - IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ - IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) - -/* external definitions for primitive types */ - -DECLARE_ASN1_ITEM(ASN1_BOOLEAN) -DECLARE_ASN1_ITEM(ASN1_TBOOLEAN) -DECLARE_ASN1_ITEM(ASN1_FBOOLEAN) -DECLARE_ASN1_ITEM(ASN1_SEQUENCE) -DECLARE_ASN1_ITEM(CBIGNUM) -DECLARE_ASN1_ITEM(BIGNUM) -DECLARE_ASN1_ITEM(LONG) -DECLARE_ASN1_ITEM(ZLONG) - -DECLARE_STACK_OF(ASN1_VALUE) - -/* Functions used internally by the ASN1 code */ - -int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it); -void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it); -int ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); -int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it); - -void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); -int ASN1_template_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_TEMPLATE *tt); -int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, - int tag, int aclass, char opt, ASN1_TLC *ctx); - -int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass); -int ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_TEMPLATE *tt); -void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it); - -int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); -int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); - -int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it); -int asn1_set_choice_selector(ASN1_VALUE **pval, int value, const ASN1_ITEM *it); - -ASN1_VALUE ** asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); - -const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt, int nullerr); - -void asn1_refcount_set_one(ASN1_VALUE **pval, const ASN1_ITEM *it); -int asn1_refcount_dec_and_test_zero(ASN1_VALUE **pval, const ASN1_ITEM *it); - -void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it); -void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it); -int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval, const ASN1_ITEM *it); -int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, const ASN1_ITEM *it); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/phonelibs/boringssl/include/openssl/base.h b/phonelibs/boringssl/include/openssl/base.h deleted file mode 100644 index b769ad5348c08a..00000000000000 --- a/phonelibs/boringssl/include/openssl/base.h +++ /dev/null @@ -1,233 +0,0 @@ -/* ==================================================================== - * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). */ - -#ifndef OPENSSL_HEADER_BASE_H -#define OPENSSL_HEADER_BASE_H - - -/* This file should be the first included by all BoringSSL headers. */ - -#include -#include -#include - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -#if defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) -#define OPENSSL_64_BIT -#define OPENSSL_X86_64 -#elif defined(__x86) || defined(__i386) || defined(__i386__) || defined(_M_IX86) -#define OPENSSL_32_BIT -#define OPENSSL_X86 -#elif defined(__aarch64__) -#define OPENSSL_64_BIT -#define OPENSSL_AARCH64 -#elif defined(__arm) || defined(__arm__) || defined(_M_ARM) -#define OPENSSL_32_BIT -#define OPENSSL_ARM -#elif defined(__aarch64__) -#define OPENSSL_64_BIT -#define OPENSSL_AARCH64 -#elif defined(__mips__) && !defined(__LP64__) -#define OPENSSL_32_BIT -#define OPENSSL_MIPS -#elif defined(__mips__) && defined(__LP64__) -#define OPENSSL_64_BIT -#define OPENSSL_MIPS64 -#elif defined(__pnacl__) -#define OPENSSL_32_BIT -#define OPENSSL_PNACL -#else -#error "Unknown target CPU" -#endif - -#if defined(__APPLE__) -#define OPENSSL_APPLE -#endif - -#if defined(WIN32) || defined(_WIN32) -#define OPENSSL_WINDOWS -#endif - -#if defined(TRUSTY) -#define OPENSSL_TRUSTY -#define OPENSSL_NO_THREADS -#endif - -#define OPENSSL_IS_BORINGSSL -#define OPENSSL_VERSION_NUMBER 0x10002000 - -#if defined(BORINGSSL_SHARED_LIBRARY) - -#if defined(OPENSSL_WINDOWS) - -#if defined(BORINGSSL_IMPLEMENTATION) -#define OPENSSL_EXPORT __declspec(dllexport) -#else -#define OPENSSL_EXPORT __declspec(dllimport) -#endif - -#else /* defined(OPENSSL_WINDOWS) */ - -#if defined(BORINGSSL_IMPLEMENTATION) -#define OPENSSL_EXPORT __attribute__((visibility("default"))) -#else -#define OPENSSL_EXPORT -#endif - -#endif /* defined(OPENSSL_WINDOWS) */ - -#else /* defined(BORINGSSL_SHARED_LIBRARY) */ - -#define OPENSSL_EXPORT - -#endif /* defined(BORINGSSL_SHARED_LIBRARY) */ - -/* CRYPTO_THREADID is a dummy value. */ -typedef int CRYPTO_THREADID; - -typedef int ASN1_BOOLEAN; -typedef int ASN1_NULL; -typedef struct ASN1_ITEM_st ASN1_ITEM; -typedef struct asn1_object_st ASN1_OBJECT; -typedef struct asn1_pctx_st ASN1_PCTX; -typedef struct asn1_string_st ASN1_BIT_STRING; -typedef struct asn1_string_st ASN1_BMPSTRING; -typedef struct asn1_string_st ASN1_ENUMERATED; -typedef struct asn1_string_st ASN1_GENERALIZEDTIME; -typedef struct asn1_string_st ASN1_GENERALSTRING; -typedef struct asn1_string_st ASN1_IA5STRING; -typedef struct asn1_string_st ASN1_INTEGER; -typedef struct asn1_string_st ASN1_OCTET_STRING; -typedef struct asn1_string_st ASN1_PRINTABLESTRING; -typedef struct asn1_string_st ASN1_STRING; -typedef struct asn1_string_st ASN1_T61STRING; -typedef struct asn1_string_st ASN1_TIME; -typedef struct asn1_string_st ASN1_UNIVERSALSTRING; -typedef struct asn1_string_st ASN1_UTCTIME; -typedef struct asn1_string_st ASN1_UTF8STRING; -typedef struct asn1_string_st ASN1_VISIBLESTRING; - -typedef struct AUTHORITY_KEYID_st AUTHORITY_KEYID; -typedef struct DIST_POINT_st DIST_POINT; -typedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT; -typedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS; -typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE; -typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL; -typedef struct X509_POLICY_NODE_st X509_POLICY_NODE; -typedef struct X509_POLICY_TREE_st X509_POLICY_TREE; -typedef struct X509_algor_st X509_ALGOR; -typedef struct X509_crl_st X509_CRL; -typedef struct X509_pubkey_st X509_PUBKEY; -typedef struct bignum_ctx BN_CTX; -typedef struct bignum_st BIGNUM; -typedef struct bio_method_st BIO_METHOD; -typedef struct bio_st BIO; -typedef struct bn_gencb_st BN_GENCB; -typedef struct bn_mont_ctx_st BN_MONT_CTX; -typedef struct buf_mem_st BUF_MEM; -typedef struct cbb_st CBB; -typedef struct cbs_st CBS; -typedef struct cmac_ctx_st CMAC_CTX; -typedef struct conf_st CONF; -typedef struct conf_value_st CONF_VALUE; -typedef struct dh_method DH_METHOD; -typedef struct dh_st DH; -typedef struct dsa_method DSA_METHOD; -typedef struct dsa_st DSA; -typedef struct ec_key_st EC_KEY; -typedef struct ecdsa_method_st ECDSA_METHOD; -typedef struct ecdsa_sig_st ECDSA_SIG; -typedef struct engine_st ENGINE; -typedef struct env_md_ctx_st EVP_MD_CTX; -typedef struct env_md_st EVP_MD; -typedef struct evp_aead_st EVP_AEAD; -typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX; -typedef struct evp_cipher_st EVP_CIPHER; -typedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD; -typedef struct evp_pkey_ctx_st EVP_PKEY_CTX; -typedef struct evp_pkey_method_st EVP_PKEY_METHOD; -typedef struct evp_pkey_st EVP_PKEY; -typedef struct hmac_ctx_st HMAC_CTX; -typedef struct md4_state_st MD4_CTX; -typedef struct md5_state_st MD5_CTX; -typedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO; -typedef struct pkcs12_st PKCS12; -typedef struct rand_meth_st RAND_METHOD; -typedef struct rc4_key_st RC4_KEY; -typedef struct rsa_meth_st RSA_METHOD; -typedef struct rsa_st RSA; -typedef struct sha256_state_st SHA256_CTX; -typedef struct sha512_state_st SHA512_CTX; -typedef struct sha_state_st SHA_CTX; -typedef struct ssl_ctx_st SSL_CTX; -typedef struct ssl_st SSL; -typedef struct st_ERR_FNS ERR_FNS; -typedef struct v3_ext_ctx X509V3_CTX; -typedef struct x509_crl_method_st X509_CRL_METHOD; -typedef struct x509_revoked_st X509_REVOKED; -typedef struct x509_st X509; -typedef struct x509_store_ctx_st X509_STORE_CTX; -typedef struct x509_store_st X509_STORE; -typedef void *OPENSSL_BLOCK; - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_BASE_H */ diff --git a/phonelibs/boringssl/include/openssl/base64.h b/phonelibs/boringssl/include/openssl/base64.h deleted file mode 100644 index 7aee9907f9239b..00000000000000 --- a/phonelibs/boringssl/include/openssl/base64.h +++ /dev/null @@ -1,179 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_BASE64_H -#define OPENSSL_HEADER_BASE64_H - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* base64 functions. - * - * For historical reasons, these functions have the EVP_ prefix but just do - * base64 encoding and decoding. */ - - -typedef struct evp_encode_ctx_st EVP_ENCODE_CTX; - - -/* Encoding */ - -/* EVP_EncodeInit initialises |*ctx|, which is typically stack - * allocated, for an encoding operation. - * - * NOTE: The encoding operation breaks its output with newlines every - * 64 characters of output (48 characters of input). Use - * EVP_EncodeBlock to encode raw base64. */ -OPENSSL_EXPORT void EVP_EncodeInit(EVP_ENCODE_CTX *ctx); - -/* EVP_EncodeUpdate encodes |in_len| bytes from |in| and writes an encoded - * version of them to |out| and sets |*out_len| to the number of bytes written. - * Some state may be contained in |ctx| so |EVP_EncodeFinal| must be used to - * flush it before using the encoded data. */ -OPENSSL_EXPORT void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, uint8_t *out, - int *out_len, const uint8_t *in, - size_t in_len); - -/* EVP_EncodeFinal flushes any remaining output bytes from |ctx| to |out| and - * sets |*out_len| to the number of bytes written. */ -OPENSSL_EXPORT void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, uint8_t *out, - int *out_len); - -/* EVP_EncodeBlock encodes |src_len| bytes from |src| and writes the - * result to |dst| with a trailing NUL. It returns the number of bytes - * written, not including this trailing NUL. */ -OPENSSL_EXPORT size_t EVP_EncodeBlock(uint8_t *dst, const uint8_t *src, - size_t src_len); - -/* EVP_EncodedLength sets |*out_len| to the number of bytes that will be needed - * to call |EVP_EncodeBlock| on an input of length |len|. This includes the - * final NUL that |EVP_EncodeBlock| writes. It returns one on success or zero - * on error. */ -OPENSSL_EXPORT int EVP_EncodedLength(size_t *out_len, size_t len); - - -/* Decoding */ - -/* EVP_DecodedLength sets |*out_len| to the maximum number of bytes - * that will be needed to call |EVP_DecodeBase64| on an input of - * length |len|. */ -OPENSSL_EXPORT int EVP_DecodedLength(size_t *out_len, size_t len); - -/* EVP_DecodeBase64 decodes |in_len| bytes from base64 and writes - * |*out_len| bytes to |out|. |max_out| is the size of the output - * buffer. If it is not enough for the maximum output size, the - * operation fails. */ -OPENSSL_EXPORT int EVP_DecodeBase64(uint8_t *out, size_t *out_len, - size_t max_out, const uint8_t *in, - size_t in_len); - -/* EVP_DecodeInit initialises |*ctx|, which is typically stack allocated, for - * a decoding operation. - * - * TODO(davidben): This isn't a straight-up base64 decode either. Document - * and/or fix exactly what's going on here; maximum line length and such. */ -OPENSSL_EXPORT void EVP_DecodeInit(EVP_ENCODE_CTX *ctx); - -/* EVP_DecodeUpdate decodes |in_len| bytes from |in| and writes the decoded - * data to |out| and sets |*out_len| to the number of bytes written. Some state - * may be contained in |ctx| so |EVP_DecodeFinal| must be used to flush it - * before using the encoded data. - * - * It returns -1 on error, one if a full line of input was processed and zero - * if the line was short (i.e. it was the last line). */ -OPENSSL_EXPORT int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, uint8_t *out, - int *out_len, const uint8_t *in, - size_t in_len); - -/* EVP_DecodeFinal flushes any remaining output bytes from |ctx| to |out| and - * sets |*out_len| to the number of bytes written. It returns one on success - * and minus one on error. */ -OPENSSL_EXPORT int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, uint8_t *out, - int *out_len); - -/* Deprecated: EVP_DecodeBlock encodes |src_len| bytes from |src| and - * writes the result to |dst|. It returns the number of bytes written - * or -1 on error. - * - * WARNING: EVP_DecodeBlock's return value does not take padding into - * account. It also strips leading whitespace and trailing - * whitespace. */ -OPENSSL_EXPORT int EVP_DecodeBlock(uint8_t *dst, const uint8_t *src, - size_t src_len); - - -struct evp_encode_ctx_st { - unsigned num; /* number saved in a partial encode/decode */ - unsigned length; /* The length is either the output line length - * (in input bytes) or the shortest input line - * length that is ok. Once decoding begins, - * the length is adjusted up each time a longer - * line is decoded */ - uint8_t enc_data[80]; /* data to encode */ - unsigned line_num; /* number read on current line */ - int expect_nl; -}; - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_BASE64_H */ diff --git a/phonelibs/boringssl/include/openssl/bio.h b/phonelibs/boringssl/include/openssl/bio.h deleted file mode 100644 index 872465750b5aa7..00000000000000 --- a/phonelibs/boringssl/include/openssl/bio.h +++ /dev/null @@ -1,910 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_BIO_H -#define OPENSSL_HEADER_BIO_H - -#include - -#include /* For FILE */ - -#include /* for ERR_print_errors_fp */ -#include -#include -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* BIO abstracts over a file-descriptor like interface. */ - - -/* Allocation and freeing. */ - -DEFINE_STACK_OF(BIO); - -/* BIO_new creates a new BIO with the given type and a reference count of one. - * It returns the fresh |BIO|, or NULL on error. */ -OPENSSL_EXPORT BIO *BIO_new(const BIO_METHOD *type); - -/* BIO_free decrements the reference count of |bio|. If the reference count - * drops to zero, it (optionally) calls the BIO's callback with |BIO_CB_FREE|, - * frees the ex_data and then, if the BIO has a destroy callback for the - * method, calls it. Finally it frees |bio| itself. It then repeats that for - * the next BIO in the chain, if any. - * - * It returns one on success or zero otherwise. */ -OPENSSL_EXPORT int BIO_free(BIO *bio); - -/* BIO_vfree performs the same actions as |BIO_free|, but has a void return - * value. This is provided for API-compat. - * - * TODO(fork): remove. */ -OPENSSL_EXPORT void BIO_vfree(BIO *bio); - -/* BIO_up_ref increments the reference count of |bio| and returns it. */ -OPENSSL_EXPORT BIO *BIO_up_ref(BIO *bio); - - -/* Basic I/O. */ - -/* BIO_read attempts to read |len| bytes into |data|. It returns the number of - * bytes read, zero on EOF, or a negative number on error. */ -OPENSSL_EXPORT int BIO_read(BIO *bio, void *data, int len); - -/* BIO_gets "reads a line" from |bio| and puts at most |size| bytes into |buf|. - * It returns the number of bytes read or a negative number on error. The - * phrase "reads a line" is in quotes in the previous sentence because the - * exact operation depends on the BIO's method. For example, a digest BIO will - * return the digest in response to a |BIO_gets| call. - * - * TODO(fork): audit the set of BIOs that we end up needing. If all actually - * return a line for this call, remove the warning above. */ -OPENSSL_EXPORT int BIO_gets(BIO *bio, char *buf, int size); - -/* BIO_write writes |len| bytes from |data| to BIO. It returns the number of - * bytes written or a negative number on error. */ -OPENSSL_EXPORT int BIO_write(BIO *bio, const void *data, int len); - -/* BIO_puts writes a NUL terminated string from |buf| to |bio|. It returns the - * number of bytes written or a negative number on error. */ -OPENSSL_EXPORT int BIO_puts(BIO *bio, const char *buf); - -/* BIO_flush flushes any buffered output. It returns one on success and zero - * otherwise. */ -OPENSSL_EXPORT int BIO_flush(BIO *bio); - - -/* Low-level control functions. - * - * These are generic functions for sending control requests to a BIO. In - * general one should use the wrapper functions like |BIO_get_close|. */ - -/* BIO_ctrl sends the control request |cmd| to |bio|. The |cmd| argument should - * be one of the |BIO_C_*| values. */ -OPENSSL_EXPORT long BIO_ctrl(BIO *bio, int cmd, long larg, void *parg); - -/* BIO_ptr_ctrl acts like |BIO_ctrl| but passes the address of a |void*| - * pointer as |parg| and returns the value that is written to it, or NULL if - * the control request returns <= 0. */ -OPENSSL_EXPORT char *BIO_ptr_ctrl(BIO *bp, int cmd, long larg); - -/* BIO_int_ctrl acts like |BIO_ctrl| but passes the address of a copy of |iarg| - * as |parg|. */ -OPENSSL_EXPORT long BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg); - -/* BIO_reset resets |bio| to its initial state, the precise meaning of which - * depends on the concrete type of |bio|. It returns one on success and zero - * otherwise. */ -OPENSSL_EXPORT int BIO_reset(BIO *bio); - -/* BIO_set_flags ORs |flags| with |bio->flags|. */ -OPENSSL_EXPORT void BIO_set_flags(BIO *bio, int flags); - -/* BIO_test_flags returns |bio->flags| AND |flags|. */ -OPENSSL_EXPORT int BIO_test_flags(const BIO *bio, int flags); - -/* BIO_should_read returns non-zero if |bio| encountered a temporary error - * while reading (i.e. EAGAIN), indicating that the caller should retry the - * read. */ -OPENSSL_EXPORT int BIO_should_read(const BIO *bio); - -/* BIO_should_write returns non-zero if |bio| encountered a temporary error - * while writing (i.e. EAGAIN), indicating that the caller should retry the - * write. */ -OPENSSL_EXPORT int BIO_should_write(const BIO *bio); - -/* BIO_should_retry returns non-zero if the reason that caused a failed I/O - * operation is temporary and thus the operation should be retried. Otherwise, - * it was a permanent error and it returns zero. */ -OPENSSL_EXPORT int BIO_should_retry(const BIO *bio); - -/* BIO_should_io_special returns non-zero if |bio| encountered a temporary - * error while performing a special I/O operation, indicating that the caller - * should retry. The operation that caused the error is returned by - * |BIO_get_retry_reason|. */ -OPENSSL_EXPORT int BIO_should_io_special(const BIO *bio); - -/* BIO_RR_SSL_X509_LOOKUP indicates that an SSL BIO blocked because the SSL - * library returned with SSL_ERROR_WANT_X509_LOOKUP. - * - * TODO(fork): remove. */ -#define BIO_RR_SSL_X509_LOOKUP 0x01 - -/* BIO_RR_CONNECT indicates that a connect would have blocked */ -#define BIO_RR_CONNECT 0x02 - -/* BIO_RR_ACCEPT indicates that an accept would have blocked */ -#define BIO_RR_ACCEPT 0x03 - -/* BIO_RR_SSL_CHANNEL_ID_LOOKUP indicates that the ChannelID code cannot find - * a private key for a TLS connection. */ -#define BIO_RR_SSL_CHANNEL_ID_LOOKUP 0x04 - -/* BIO_get_retry_reason returns the special I/O operation that needs to be - * retried. The return value is one of the |BIO_RR_*| values. */ -OPENSSL_EXPORT int BIO_get_retry_reason(const BIO *bio); - -/* BIO_clear_flags ANDs |bio->flags| with the bitwise-complement of |flags|. */ -OPENSSL_EXPORT void BIO_clear_flags(BIO *bio, int flags); - -/* BIO_set_retry_read sets the |BIO_FLAGS_READ| and |BIO_FLAGS_SHOULD_RETRY| - * flags on |bio|. */ -OPENSSL_EXPORT void BIO_set_retry_read(BIO *bio); - -/* BIO_set_retry_read sets the |BIO_FLAGS_WRITE| and |BIO_FLAGS_SHOULD_RETRY| - * flags on |bio|. */ -OPENSSL_EXPORT void BIO_set_retry_write(BIO *bio); - -/* BIO_get_retry_flags gets the |BIO_FLAGS_READ|, |BIO_FLAGS_WRITE|, - * |BIO_FLAGS_IO_SPECIAL| and |BIO_FLAGS_SHOULD_RETRY| flags from |bio|. */ -OPENSSL_EXPORT int BIO_get_retry_flags(BIO *bio); - -/* BIO_clear_retry_flags clears the |BIO_FLAGS_READ|, |BIO_FLAGS_WRITE|, - * |BIO_FLAGS_IO_SPECIAL| and |BIO_FLAGS_SHOULD_RETRY| flags from |bio|. */ -OPENSSL_EXPORT void BIO_clear_retry_flags(BIO *bio); - -/* BIO_method_type returns the type of |bio|, which is one of the |BIO_TYPE_*| - * values. */ -OPENSSL_EXPORT int BIO_method_type(const BIO *bio); - -/* bio_info_cb is the type of a callback function that can be called for most - * BIO operations. The |event| argument is one of |BIO_CB_*| and can be ORed - * with |BIO_CB_RETURN| if the callback is being made after the operation in - * question. In that case, |return_value| will contain the return value from - * the operation. */ -typedef long (*bio_info_cb)(BIO *bio, int event, const char *parg, int cmd, - long larg, long return_value); - -/* BIO_callback_ctrl allows the callback function to be manipulated. The |cmd| - * arg will generally be |BIO_CTRL_SET_CALLBACK| but arbitary command values - * can be interpreted by the |BIO|. */ -OPENSSL_EXPORT long BIO_callback_ctrl(BIO *bio, int cmd, bio_info_cb fp); - -/* BIO_pending returns the number of bytes pending to be read. */ -OPENSSL_EXPORT size_t BIO_pending(const BIO *bio); - -/* BIO_ctrl_pending calls |BIO_pending| and exists only for compatibility with - * OpenSSL. */ -OPENSSL_EXPORT size_t BIO_ctrl_pending(const BIO *bio); - -/* BIO_wpending returns the number of bytes pending to be written. */ -OPENSSL_EXPORT size_t BIO_wpending(const BIO *bio); - -/* BIO_set_close sets the close flag for |bio|. The meaning of which depends on - * the type of |bio| but, for example, a memory BIO interprets the close flag - * as meaning that it owns its buffer. It returns one on success and zero - * otherwise. */ -OPENSSL_EXPORT int BIO_set_close(BIO *bio, int close_flag); - -/* BIO_set_callback sets a callback function that will be called before and - * after most operations. See the comment above |bio_info_cb|. */ -OPENSSL_EXPORT void BIO_set_callback(BIO *bio, bio_info_cb callback_func); - -/* BIO_set_callback_arg sets the opaque pointer value that can be read within a - * callback with |BIO_get_callback_arg|. */ -OPENSSL_EXPORT void BIO_set_callback_arg(BIO *bio, char *arg); - -/* BIO_get_callback_arg returns the last value of the opaque callback pointer - * set by |BIO_set_callback_arg|. */ -OPENSSL_EXPORT char *BIO_get_callback_arg(const BIO *bio); - -/* BIO_number_read returns the number of bytes that have been read from - * |bio|. */ -OPENSSL_EXPORT size_t BIO_number_read(const BIO *bio); - -/* BIO_number_written returns the number of bytes that have been written to - * |bio|. */ -OPENSSL_EXPORT size_t BIO_number_written(const BIO *bio); - - -/* Managing chains of BIOs. - * - * BIOs can be put into chains where the output of one is used as the input of - * the next etc. The most common case is a buffering BIO, which accepts and - * buffers writes until flushed into the next BIO in the chain. */ - -/* BIO_push adds |appended_bio| to the end of the chain with |bio| at the head. - * It returns |bio|. Note that |appended_bio| may be the head of a chain itself - * and thus this function can be used to join two chains. - * - * BIO_push takes ownership of the caller's reference to |appended_bio|. */ -OPENSSL_EXPORT BIO *BIO_push(BIO *bio, BIO *appended_bio); - -/* BIO_pop removes |bio| from the head of a chain and returns the next BIO in - * the chain, or NULL if there is no next BIO. - * - * The caller takes ownership of the chain's reference to |bio|. */ -OPENSSL_EXPORT BIO *BIO_pop(BIO *bio); - -/* BIO_next returns the next BIO in the chain after |bio|, or NULL if there is - * no such BIO. */ -OPENSSL_EXPORT BIO *BIO_next(BIO *bio); - -/* BIO_free_all calls |BIO_free|. - * - * TODO(fork): update callers and remove. */ -OPENSSL_EXPORT void BIO_free_all(BIO *bio); - -/* BIO_find_type walks a chain of BIOs and returns the first that matches - * |type|, which is one of the |BIO_TYPE_*| values. */ -OPENSSL_EXPORT BIO *BIO_find_type(BIO *bio, int type); - -/* BIO_copy_next_retry sets the retry flags and |retry_reason| of |bio| from - * the next BIO in the chain. */ -OPENSSL_EXPORT void BIO_copy_next_retry(BIO *bio); - - -/* Printf functions. - * - * These functions are versions of printf functions that output to a BIO rather - * than a FILE. */ -#ifdef __GNUC__ -#define __bio_h__attr__ __attribute__ -#else -#define __bio_h__attr__(x) -#endif -OPENSSL_EXPORT int BIO_printf(BIO *bio, const char *format, ...) - __bio_h__attr__((__format__(__printf__, 2, 3))); -#undef __bio_h__attr__ - - -/* Utility functions. */ - -/* BIO_indent prints min(|indent|, |max_indent|) spaces. It returns one on - * success and zero otherwise. */ -OPENSSL_EXPORT int BIO_indent(BIO *bio, unsigned indent, unsigned max_indent); - -/* BIO_hexdump writes a hex dump of |data| to |bio|. Each line will be indented - * by |indent| spaces. */ -OPENSSL_EXPORT int BIO_hexdump(BIO *bio, const uint8_t *data, size_t len, - unsigned indent); - -/* BIO_print_errors prints the current contents of the error stack to |bio| - * using human readable strings where possible. */ -OPENSSL_EXPORT void BIO_print_errors(BIO *bio); - -/* BIO_read_asn1 reads a single ASN.1 object from |bio|. If successful it sets - * |*out| to be an allocated buffer (that should be freed with |OPENSSL_free|), - * |*out_size| to the length, in bytes, of that buffer and returns one. - * Otherwise it returns zero. - * - * If the length of the object is greater than |max_len| or 2^32 then the - * function will fail. Long-form tags are not supported. If the length of the - * object is indefinite the full contents of |bio| are read, unless it would be - * greater than |max_len|, in which case the function fails. - * - * If the function fails then some unknown amount of data may have been read - * from |bio|. */ -OPENSSL_EXPORT int BIO_read_asn1(BIO *bio, uint8_t **out, size_t *out_len, - size_t max_len); - - -/* Memory BIOs. - * - * Memory BIOs can be used as a read-only source (with |BIO_new_mem_buf|) or a - * writable sink (with |BIO_new|, |BIO_s_mem| and |BIO_get_mem_buf|). Data - * written to a writable, memory BIO can be recalled by reading from it. - * - * Calling |BIO_reset| on a read-only BIO resets it to the original contents. - * On a writable BIO, it clears any data. - * - * If the close flag is set to |BIO_NOCLOSE| (not the default) then the - * underlying |BUF_MEM| will not be freed when the |BIO| is freed. - * - * Memory BIOs support |BIO_gets| and |BIO_puts|. - * - * |BIO_eof| is true if no data is in the BIO. - * - * |BIO_ctrl_pending| returns the number of bytes currently stored. */ - -/* BIO_s_mem returns a |BIO_METHOD| that uses a in-memory buffer. */ -OPENSSL_EXPORT const BIO_METHOD *BIO_s_mem(void); - -/* BIO_new_mem_buf creates BIO that reads and writes from |len| bytes at |buf|. - * It does not take ownership of |buf|. It returns the BIO or NULL on error. - * - * If |len| is negative, then |buf| is treated as a NUL-terminated string, but - * don't depend on this in new code. */ -OPENSSL_EXPORT BIO *BIO_new_mem_buf(void *buf, int len); - -/* BIO_mem_contents sets |*out_contents| to point to the current contents of - * |bio| and |*out_len| to contain the length of that data. It returns one on - * success and zero otherwise. */ -OPENSSL_EXPORT int BIO_mem_contents(const BIO *bio, - const uint8_t **out_contents, - size_t *out_len); - -/* BIO_get_mem_data sets |*contents| to point to the current contents of |bio| - * and returns the length of the data. - * - * WARNING: don't use this, use |BIO_mem_contents|. A return value of zero from - * this function can mean either that it failed or that the memory buffer is - * empty. */ -OPENSSL_EXPORT long BIO_get_mem_data(BIO *bio, char **contents); - -/* BIO_get_mem_ptr sets |*out| to a BUF_MEM containing the current contents of - * |bio|. It returns one on success or zero on error. */ -OPENSSL_EXPORT int BIO_get_mem_ptr(BIO *bio, BUF_MEM **out); - -/* BIO_set_mem_buf sets |b| as the contents of |bio|. If |take_ownership| is - * non-zero, then |b| will be freed when |bio| is closed. Returns one on - * success or zero otherwise. */ -OPENSSL_EXPORT int BIO_set_mem_buf(BIO *bio, BUF_MEM *b, int take_ownership); - -/* BIO_set_mem_eof_return sets the value that will be returned from reading - * |bio| when empty. If |eof_value| is zero then an empty memory BIO will - * return EOF (that is it will return zero and |BIO_should_retry| will be - * false). If |eof_value| is non zero then it will return |eof_value| when it - * is empty and it will set the read retry flag (that is |BIO_read_retry| is - * true). To avoid ambiguity with a normal positive return value, |eof_value| - * should be set to a negative value, typically -1. - * - * For a read-only BIO, the default is zero (EOF). For a writable BIO, the - * default is -1 so that additional data can be written once exhausted. */ -OPENSSL_EXPORT int BIO_set_mem_eof_return(BIO *bio, int eof_value); - - -/* File descriptor BIOs. - * - * File descriptor BIOs are wrappers around the system's |read| and |write| - * functions. If the close flag is set then then |close| is called on the - * underlying file descriptor when the BIO is freed. - * - * |BIO_reset| attempts to seek the file pointer to the start of file using - * |lseek|. - * - * |BIO_seek| sets the file pointer to position |off| from start of file using - * |lseek|. - * - * |BIO_tell| returns the current file position. */ - -/* BIO_s_fd returns a |BIO_METHOD| for file descriptor fds. */ -OPENSSL_EXPORT const BIO_METHOD *BIO_s_fd(void); - -/* BIO_new_fd creates a new file descriptor BIO wrapping |fd|. If |close_flag| - * is non-zero, then |fd| will be closed when the BIO is. */ -OPENSSL_EXPORT BIO *BIO_new_fd(int fd, int close_flag); - -/* BIO_set_fd sets the file descriptor of |bio| to |fd|. If |close_flag| is - * non-zero then |fd| will be closed when |bio| is. It returns one on success - * or zero on error. */ -OPENSSL_EXPORT int BIO_set_fd(BIO *bio, int fd, int close_flag); - -/* BIO_get_fd sets |*out_fd| to the file descriptor currently in use by |bio|. - * It returns one on success and zero on error. */ -OPENSSL_EXPORT int BIO_get_fd(BIO *bio, int *out_fd); - - -/* File BIOs. - * - * File BIOs are wrappers around a C |FILE| object. - * - * |BIO_flush| on a file BIO calls |fflush| on the wrapped stream. - * - * |BIO_reset| attempts to seek the file pointer to the start of file using - * |fseek|. - * - * |BIO_seek| sets the file pointer to the given position from the start of - * file using |fseek|. - * - * |BIO_eof| calls |feof|. - * - * Setting the close flag causes |fclose| to be called on the stream when the - * BIO is freed. */ - -/* BIO_s_file returns a BIO_METHOD that wraps a |FILE|. */ -OPENSSL_EXPORT const BIO_METHOD *BIO_s_file(void); - -/* BIO_new_file creates a file BIO by opening |filename| with the given mode. - * See the |fopen| manual page for details of the mode argument. */ -OPENSSL_EXPORT BIO *BIO_new_file(const char *filename, const char *mode); - -/* BIO_new_fp creates a new file BIO that wraps the given |FILE|. If - * |close_flag| is |BIO_CLOSE|, then |fclose| will be called on |stream| when - * the BIO is closed. */ -OPENSSL_EXPORT BIO *BIO_new_fp(FILE *stream, int close_flag); - -/* BIO_get_fp sets |*out_file| to the current |FILE| for |bio|. It returns one - * on success and zero otherwise. */ -OPENSSL_EXPORT int BIO_get_fp(BIO *bio, FILE **out_file); - -/* BIO_set_fp sets the |FILE| for |bio|. If |close_flag| is |BIO_CLOSE| then - * |fclose| will be called on |file| when |bio| is closed. It returns one on - * sucess and zero otherwise. */ -OPENSSL_EXPORT int BIO_set_fp(BIO *bio, FILE *file, int close_flag); - -/* BIO_read_filename opens |filename| for reading and sets the result as the - * |FILE| for |bio|. It returns one on success and zero otherwise. The |FILE| - * will be closed when |bio| is freed. */ -OPENSSL_EXPORT int BIO_read_filename(BIO *bio, const char *filename); - -/* BIO_write_filename opens |filename| for writing and sets the result as the - * |FILE| for |bio|. It returns one on success and zero otherwise. The |FILE| - * will be closed when |bio| is freed. */ -OPENSSL_EXPORT int BIO_write_filename(BIO *bio, const char *filename); - -/* BIO_append_filename opens |filename| for appending and sets the result as - * the |FILE| for |bio|. It returns one on success and zero otherwise. The - * |FILE| will be closed when |bio| is freed. */ -OPENSSL_EXPORT int BIO_append_filename(BIO *bio, const char *filename); - -/* BIO_rw_filename opens |filename| for reading and writing and sets the result - * as the |FILE| for |bio|. It returns one on success and zero otherwise. The - * |FILE| will be closed when |bio| is freed. */ -OPENSSL_EXPORT int BIO_rw_filename(BIO *bio, const char *filename); - - -/* Buffer BIOs. - * - * Buffer BIOs are a filter-type BIO, i.e. they are designed to be used in a - * chain of BIOs. They provide buffering to reduce the number of operations on - * the underlying BIOs. */ - -OPENSSL_EXPORT const BIO_METHOD *BIO_f_buffer(void); - -/* BIO_set_read_buffer_size sets the size, in bytes, of the read buffer and - * clears it. It returns one on success and zero on failure. */ -OPENSSL_EXPORT int BIO_set_read_buffer_size(BIO *bio, int buffer_size); - -/* BIO_set_write_buffer_size sets the size, in bytes, of the write buffer and - * clears it. It returns one on success and zero on failure. */ -OPENSSL_EXPORT int BIO_set_write_buffer_size(BIO *bio, int buffer_size); - - -/* Socket BIOs. */ - -OPENSSL_EXPORT const BIO_METHOD *BIO_s_socket(void); - -/* BIO_new_socket allocates and initialises a fresh BIO which will read and - * write to the socket |fd|. If |close_flag| is |BIO_CLOSE| then closing the - * BIO will close |fd|. It returns the fresh |BIO| or NULL on error. */ -OPENSSL_EXPORT BIO *BIO_new_socket(int fd, int close_flag); - - -/* Connect BIOs. - * - * A connection BIO creates a network connection and transfers data over the - * resulting socket. */ - -OPENSSL_EXPORT const BIO_METHOD *BIO_s_connect(void); - -/* BIO_new_connect returns a BIO that connects to the given hostname and port. - * The |host_and_optional_port| argument should be of the form - * "www.example.com" or "www.example.com:443". If the port is omitted, it must - * be provided with |BIO_set_conn_port|. - * - * It returns the new BIO on success, or NULL on error. */ -OPENSSL_EXPORT BIO *BIO_new_connect(const char *host_and_optional_port); - -/* BIO_set_conn_hostname sets |host_and_optional_port| as the hostname and - * optional port that |bio| will connect to. If the port is omitted, it must be - * provided with |BIO_set_conn_port|. - * - * It returns one on success and zero otherwise. */ -OPENSSL_EXPORT int BIO_set_conn_hostname(BIO *bio, - const char *host_and_optional_port); - -/* BIO_set_conn_port sets |port_str| as the port or service name that |bio| - * will connect to. It returns one on success and zero otherwise. */ -OPENSSL_EXPORT int BIO_set_conn_port(BIO *bio, const char *port_str); - -/* BIO_set_nbio sets whether |bio| will use non-blocking I/O operations. It - * returns one on success and zero otherwise. */ -OPENSSL_EXPORT int BIO_set_nbio(BIO *bio, int on); - - -/* Datagram BIOs. - * - * TODO(fork): not implemented. */ - -#define BIO_CTRL_DGRAM_QUERY_MTU 40 /* as kernel for current MTU */ - -#define BIO_CTRL_DGRAM_SET_MTU 42 /* set cached value for MTU. want to use - this if asking the kernel fails */ - -#define BIO_CTRL_DGRAM_MTU_EXCEEDED 43 /* check whether the MTU was exceed in - the previous write operation. */ - -#define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT \ - 45 /* Next DTLS handshake timeout to adjust socket timeouts */ - -#define BIO_CTRL_DGRAM_GET_PEER 46 - -#define BIO_CTRL_DGRAM_GET_FALLBACK_MTU 47 - - -/* BIO Pairs. - * - * BIO pairs provide a "loopback" like system: a pair of BIOs where data - * written to one can be read from the other and vice versa. */ - -/* BIO_new_bio_pair sets |*out1| and |*out2| to two freshly created BIOs where - * data written to one can be read from the other and vice versa. The - * |writebuf1| argument gives the size of the buffer used in |*out1| and - * |writebuf2| for |*out2|. It returns one on success and zero on error. */ -OPENSSL_EXPORT int BIO_new_bio_pair(BIO **out1, size_t writebuf1, BIO **out2, - size_t writebuf2); - -/* BIO_new_bio_pair_external_buf is the same as |BIO_new_bio_pair| with the - * difference that the caller keeps ownership of the write buffers - * |ext_writebuf1_len| and |ext_writebuf2_len|. This is useful when using zero - * copy API for read and write operations, in cases where the buffers need to - * outlive the BIO pairs. It returns one on success and zero on error. */ -OPENSSL_EXPORT int BIO_new_bio_pair_external_buf(BIO** bio1_p, - size_t writebuf1_len, - uint8_t* ext_writebuf1, - BIO** bio2_p, - size_t writebuf2_len, - uint8_t* ext_writebuf2); - -/* BIO_ctrl_get_read_request returns the number of bytes that the other side of - * |bio| tried (unsuccessfully) to read. */ -OPENSSL_EXPORT size_t BIO_ctrl_get_read_request(BIO *bio); - -/* BIO_ctrl_get_write_guarantee returns the number of bytes that |bio| (which - * must have been returned by |BIO_new_bio_pair|) will accept on the next - * |BIO_write| call. */ -OPENSSL_EXPORT size_t BIO_ctrl_get_write_guarantee(BIO *bio); - -/* BIO_shutdown_wr marks |bio| as closed, from the point of view of the other - * side of the pair. Future |BIO_write| calls on |bio| will fail. It returns - * one on success and zero otherwise. */ -OPENSSL_EXPORT int BIO_shutdown_wr(BIO *bio); - - -/* Zero copy versions of BIO_read and BIO_write for BIO pairs. */ - -/* BIO_zero_copy_get_read_buf initiates a zero copy read operation. - * |out_read_buf| is set to the internal read buffer, and |out_buf_offset| is - * set to the current read position of |out_read_buf|. The number of bytes - * available for read from |out_read_buf| + |out_buf_offset| is returned in - * |out_available_bytes|. Note that this function might report fewer bytes - * available than |BIO_pending|, if the internal ring buffer is wrapped. It - * returns one on success. In case of error it returns zero and pushes to the - * error stack. - * - * The zero copy read operation is completed by calling - * |BIO_zero_copy_get_read_buf_done|. Neither |BIO_zero_copy_get_read_buf| nor - * any other I/O read operation may be called while a zero copy read operation - * is active. */ -OPENSSL_EXPORT int BIO_zero_copy_get_read_buf(BIO* bio, - uint8_t** out_read_buf, - size_t* out_buf_offset, - size_t* out_available_bytes); - -/* BIO_zero_copy_get_read_buf_done must be called after reading from a BIO using - * |BIO_zero_copy_get_read_buf| to finish the read operation. The |bytes_read| - * argument is the number of bytes read. - * - * It returns one on success. In case of error it returns zero and pushes to the - * error stack. */ -OPENSSL_EXPORT int BIO_zero_copy_get_read_buf_done(BIO* bio, size_t bytes_read); - -/* BIO_zero_copy_get_write_buf_done initiates a zero copy write operation. - * |out_write_buf| is set to to the internal write buffer, and |out_buf_offset| - * is set to the current write position of |out_write_buf|. - * The number of bytes available for write from |out_write_buf| + - * |out_buf_offset| is returned in |out_available_bytes|. Note that this - * function might report fewer bytes available than - * |BIO_ctrl_get_write_guarantee|, if the internal buffer is wrapped. It returns - * one on success. In case of error it returns zero and pushes to the error - * stack. - * - * The zero copy write operation is completed by calling - * |BIO_zero_copy_write_buf_done|. Neither |BIO_zero_copy_get_write_buf| - * nor any other I/O write operation may be called while a zero copy write - * operation is active. */ -OPENSSL_EXPORT int BIO_zero_copy_get_write_buf(BIO* bio, - uint8_t** out_write_buf, - size_t* out_buf_offset, - size_t* out_available_bytes); - -/* BIO_zero_copy_write_buf_done must be called after writing to a BIO using - * |BIO_zero_copy_get_write_buf_done| to finish the write operation. The - * |bytes_written| argument gives the number of bytes written. - * - * It returns one on success. In case of error it returns zero and pushes to the - * error stack. */ -OPENSSL_EXPORT int BIO_zero_copy_get_write_buf_done(BIO* bio, - size_t bytes_written); - - -/* BIO_NOCLOSE and |BIO_CLOSE| can be used as symbolic arguments when a "close - * flag" is passed to a BIO function. */ -#define BIO_NOCLOSE 0 -#define BIO_CLOSE 1 - -/* These are passed to the BIO callback */ -#define BIO_CB_FREE 0x01 -#define BIO_CB_READ 0x02 -#define BIO_CB_WRITE 0x03 -#define BIO_CB_PUTS 0x04 -#define BIO_CB_GETS 0x05 -#define BIO_CB_CTRL 0x06 - -/* The callback is called before and after the underling operation, - * The BIO_CB_RETURN flag indicates if it is after the call */ -#define BIO_CB_RETURN 0x80 - -/* These are values of the |cmd| argument to |BIO_ctrl|. */ -#define BIO_CTRL_RESET 1 /* opt - rewind/zero etc */ -#define BIO_CTRL_EOF 2 /* opt - are we at the eof */ -#define BIO_CTRL_INFO 3 /* opt - extra tit-bits */ -#define BIO_CTRL_SET 4 /* man - set the 'IO' type */ -#define BIO_CTRL_GET 5 /* man - get the 'IO' type */ -#define BIO_CTRL_GET_CLOSE 8 /* man - set the 'close' on free */ -#define BIO_CTRL_SET_CLOSE 9 /* man - set the 'close' on free */ -#define BIO_CTRL_PENDING 10 /* opt - is their more data buffered */ -#define BIO_CTRL_FLUSH 11 /* opt - 'flush' buffered output */ -#define BIO_CTRL_WPENDING 13 /* opt - number of bytes still to write */ -/* callback is int cb(BIO *bio,state,ret); */ -#define BIO_CTRL_SET_CALLBACK 14 /* opt - set callback function */ -#define BIO_CTRL_GET_CALLBACK 15 /* opt - set callback function */ -#define BIO_CTRL_SET_FILENAME 30 /* BIO_s_file special */ - - -/* Android compatibility section. - * - * A previous version of BoringSSL used in Android renamed ERR_print_errors_fp - * to BIO_print_errors_fp. It has subsequently been renamed back to - * ERR_print_errors_fp. */ -#define BIO_print_errors_fp ERR_print_errors_fp - - -/* Private functions */ - -#define BIO_FLAGS_READ 0x01 -#define BIO_FLAGS_WRITE 0x02 -#define BIO_FLAGS_IO_SPECIAL 0x04 -#define BIO_FLAGS_RWS (BIO_FLAGS_READ | BIO_FLAGS_WRITE | BIO_FLAGS_IO_SPECIAL) -#define BIO_FLAGS_SHOULD_RETRY 0x08 -#define BIO_FLAGS_BASE64_NO_NL 0x100 -/* This is used with memory BIOs: it means we shouldn't free up or change the - * data in any way. */ -#define BIO_FLAGS_MEM_RDONLY 0x200 - -/* These are the 'types' of BIOs */ -#define BIO_TYPE_NONE 0 -#define BIO_TYPE_MEM (1 | 0x0400) -#define BIO_TYPE_FILE (2 | 0x0400) -#define BIO_TYPE_FD (4 | 0x0400 | 0x0100) -#define BIO_TYPE_SOCKET (5 | 0x0400 | 0x0100) -#define BIO_TYPE_NULL (6 | 0x0400) -#define BIO_TYPE_SSL (7 | 0x0200) -#define BIO_TYPE_MD (8 | 0x0200) /* passive filter */ -#define BIO_TYPE_BUFFER (9 | 0x0200) /* filter */ -#define BIO_TYPE_CIPHER (10 | 0x0200) /* filter */ -#define BIO_TYPE_BASE64 (11 | 0x0200) /* filter */ -#define BIO_TYPE_CONNECT (12 | 0x0400 | 0x0100) /* socket - connect */ -#define BIO_TYPE_ACCEPT (13 | 0x0400 | 0x0100) /* socket for accept */ -#define BIO_TYPE_PROXY_CLIENT (14 | 0x0200) /* client proxy BIO */ -#define BIO_TYPE_PROXY_SERVER (15 | 0x0200) /* server proxy BIO */ -#define BIO_TYPE_NBIO_TEST (16 | 0x0200) /* server proxy BIO */ -#define BIO_TYPE_NULL_FILTER (17 | 0x0200) -#define BIO_TYPE_BER (18 | 0x0200) /* BER -> bin filter */ -#define BIO_TYPE_BIO (19 | 0x0400) /* (half a) BIO pair */ -#define BIO_TYPE_LINEBUFFER (20 | 0x0200) /* filter */ -#define BIO_TYPE_DGRAM (21 | 0x0400 | 0x0100) -#define BIO_TYPE_ASN1 (22 | 0x0200) /* filter */ -#define BIO_TYPE_COMP (23 | 0x0200) /* filter */ - -#define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */ -#define BIO_TYPE_FILTER 0x0200 -#define BIO_TYPE_SOURCE_SINK 0x0400 - -struct bio_method_st { - int type; - const char *name; - int (*bwrite)(BIO *, const char *, int); - int (*bread)(BIO *, char *, int); - /* TODO(fork): remove bputs. */ - int (*bputs)(BIO *, const char *); - int (*bgets)(BIO *, char *, int); - long (*ctrl)(BIO *, int, long, void *); - int (*create)(BIO *); - int (*destroy)(BIO *); - long (*callback_ctrl)(BIO *, int, bio_info_cb); -}; - -struct bio_st { - const BIO_METHOD *method; - /* bio, mode, argp, argi, argl, ret */ - long (*callback)(struct bio_st *, int, const char *, int, long, long); - char *cb_arg; /* first argument for the callback */ - - /* init is non-zero if this |BIO| has been initialised. */ - int init; - /* shutdown is often used by specific |BIO_METHOD|s to determine whether - * they own some underlying resource. This flag can often by controlled by - * |BIO_set_close|. For example, whether an fd BIO closes the underlying fd - * when it, itself, is closed. */ - int shutdown; - int flags; - int retry_reason; - /* num is a BIO-specific value. For example, in fd BIOs it's used to store a - * file descriptor. */ - int num; - CRYPTO_refcount_t references; - void *ptr; - /* next_bio points to the next |BIO| in a chain. This |BIO| owns a reference - * to |next_bio|. */ - struct bio_st *next_bio; /* used by filter BIOs */ - size_t num_read, num_write; -}; - -#define BIO_C_SET_CONNECT 100 -#define BIO_C_DO_STATE_MACHINE 101 -#define BIO_C_SET_NBIO 102 -#define BIO_C_SET_PROXY_PARAM 103 -#define BIO_C_SET_FD 104 -#define BIO_C_GET_FD 105 -#define BIO_C_SET_FILE_PTR 106 -#define BIO_C_GET_FILE_PTR 107 -#define BIO_C_SET_FILENAME 108 -#define BIO_C_SET_SSL 109 -#define BIO_C_GET_SSL 110 -#define BIO_C_SET_MD 111 -#define BIO_C_GET_MD 112 -#define BIO_C_GET_CIPHER_STATUS 113 -#define BIO_C_SET_BUF_MEM 114 -#define BIO_C_GET_BUF_MEM_PTR 115 -#define BIO_C_GET_BUFF_NUM_LINES 116 -#define BIO_C_SET_BUFF_SIZE 117 -#define BIO_C_SET_ACCEPT 118 -#define BIO_C_SSL_MODE 119 -#define BIO_C_GET_MD_CTX 120 -#define BIO_C_GET_PROXY_PARAM 121 -#define BIO_C_SET_BUFF_READ_DATA 122 /* data to read first */ -#define BIO_C_GET_CONNECT 123 -#define BIO_C_GET_ACCEPT 124 -#define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125 -#define BIO_C_GET_SSL_NUM_RENEGOTIATES 126 -#define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127 -#define BIO_C_FILE_SEEK 128 -#define BIO_C_GET_CIPHER_CTX 129 -#define BIO_C_SET_BUF_MEM_EOF_RETURN 130/*return end of input value*/ -#define BIO_C_SET_BIND_MODE 131 -#define BIO_C_GET_BIND_MODE 132 -#define BIO_C_FILE_TELL 133 -#define BIO_C_GET_SOCKS 134 -#define BIO_C_SET_SOCKS 135 - -#define BIO_C_SET_WRITE_BUF_SIZE 136/* for BIO_s_bio */ -#define BIO_C_GET_WRITE_BUF_SIZE 137 -#define BIO_C_GET_WRITE_GUARANTEE 140 -#define BIO_C_GET_READ_REQUEST 141 -#define BIO_C_SHUTDOWN_WR 142 -#define BIO_C_NREAD0 143 -#define BIO_C_NREAD 144 -#define BIO_C_NWRITE0 145 -#define BIO_C_NWRITE 146 -#define BIO_C_RESET_READ_REQUEST 147 -#define BIO_C_SET_MD_CTX 148 - -#define BIO_C_SET_PREFIX 149 -#define BIO_C_GET_PREFIX 150 -#define BIO_C_SET_SUFFIX 151 -#define BIO_C_GET_SUFFIX 152 - -#define BIO_C_SET_EX_ARG 153 -#define BIO_C_GET_EX_ARG 154 - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#define BIO_F_BIO_callback_ctrl 100 -#define BIO_F_BIO_ctrl 101 -#define BIO_F_BIO_new 102 -#define BIO_F_BIO_new_file 103 -#define BIO_F_BIO_new_mem_buf 104 -#define BIO_F_BIO_zero_copy_get_read_buf 105 -#define BIO_F_BIO_zero_copy_get_read_buf_done 106 -#define BIO_F_BIO_zero_copy_get_write_buf 107 -#define BIO_F_BIO_zero_copy_get_write_buf_done 108 -#define BIO_F_bio_io 109 -#define BIO_F_bio_make_pair 110 -#define BIO_F_bio_write 111 -#define BIO_F_buffer_ctrl 112 -#define BIO_F_conn_ctrl 113 -#define BIO_F_conn_state 114 -#define BIO_F_file_ctrl 115 -#define BIO_F_file_read 116 -#define BIO_F_mem_write 117 -#define BIO_F_BIO_printf 118 -#define BIO_R_BAD_FOPEN_MODE 100 -#define BIO_R_BROKEN_PIPE 101 -#define BIO_R_CONNECT_ERROR 102 -#define BIO_R_ERROR_SETTING_NBIO 103 -#define BIO_R_INVALID_ARGUMENT 104 -#define BIO_R_IN_USE 105 -#define BIO_R_KEEPALIVE 106 -#define BIO_R_NBIO_CONNECT_ERROR 107 -#define BIO_R_NO_HOSTNAME_SPECIFIED 108 -#define BIO_R_NO_PORT_SPECIFIED 109 -#define BIO_R_NO_SUCH_FILE 110 -#define BIO_R_NULL_PARAMETER 111 -#define BIO_R_SYS_LIB 112 -#define BIO_R_UNABLE_TO_CREATE_SOCKET 113 -#define BIO_R_UNINITIALIZED 114 -#define BIO_R_UNSUPPORTED_METHOD 115 -#define BIO_R_WRITE_TO_READ_ONLY_BIO 116 - -#endif /* OPENSSL_HEADER_BIO_H */ diff --git a/phonelibs/boringssl/include/openssl/blowfish.h b/phonelibs/boringssl/include/openssl/blowfish.h deleted file mode 100644 index fa60d5336fcb07..00000000000000 --- a/phonelibs/boringssl/include/openssl/blowfish.h +++ /dev/null @@ -1,93 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_BLOWFISH_H -#define OPENSSL_HEADER_BLOWFISH_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -#define BF_ENCRYPT 1 -#define BF_DECRYPT 0 - -#define BF_ROUNDS 16 -#define BF_BLOCK 8 - -typedef struct bf_key_st { - uint32_t P[BF_ROUNDS + 2]; - uint32_t S[4 * 256]; -} BF_KEY; - -OPENSSL_EXPORT void BF_set_key(BF_KEY *key, size_t len, const uint8_t *data); -OPENSSL_EXPORT void BF_encrypt(uint32_t *data, const BF_KEY *key); -OPENSSL_EXPORT void BF_decrypt(uint32_t *data, const BF_KEY *key); - -OPENSSL_EXPORT void BF_ecb_encrypt(const uint8_t *in, uint8_t *out, - const BF_KEY *key, int enc); -OPENSSL_EXPORT void BF_cbc_encrypt(const uint8_t *in, uint8_t *out, long length, - const BF_KEY *schedule, uint8_t *ivec, - int enc); - - -#ifdef __cplusplus -} -#endif - -#endif /* OPENSSL_HEADER_BLOWFISH_H */ diff --git a/phonelibs/boringssl/include/openssl/bn.h b/phonelibs/boringssl/include/openssl/bn.h deleted file mode 100644 index ec1c8ff5c32d1f..00000000000000 --- a/phonelibs/boringssl/include/openssl/bn.h +++ /dev/null @@ -1,875 +0,0 @@ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ -/* ==================================================================== - * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * - * Portions of the attached software ("Contribution") are developed by - * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. - * - * The Contribution is licensed pursuant to the Eric Young open source - * license provided above. - * - * The binary polynomial arithmetic software is originally written by - * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems - * Laboratories. */ - -#ifndef OPENSSL_HEADER_BN_H -#define OPENSSL_HEADER_BN_H - -#include -#include - -#include /* for PRIu64 and friends */ -#include /* for FILE* */ - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* BN provides support for working with arbitary sized integers. For example, - * although the largest integer supported by the compiler might be 64 bits, BN - * will allow you to work with numbers until you run out of memory. */ - - -/* BN_ULONG is the native word size when working with big integers. - * - * Note: on some platforms, inttypes.h does not define print format macros in - * C++ unless |__STDC_FORMAT_MACROS| defined. As this is a public header, bn.h - * does not define |__STDC_FORMAT_MACROS| itself. C++ source files which use the - * FMT macros must define it externally. */ -#if defined(OPENSSL_64_BIT) -#define BN_ULONG uint64_t -#define BN_BITS2 64 -#define BN_DEC_FMT1 "%" PRIu64 -#define BN_DEC_FMT2 "%019" PRIu64 -#define BN_HEX_FMT1 "%" PRIx64 -#elif defined(OPENSSL_32_BIT) -#define BN_ULONG uint32_t -#define BN_BITS2 32 -#define BN_DEC_FMT1 "%" PRIu32 -#define BN_DEC_FMT2 "%09" PRIu32 -#define BN_HEX_FMT1 "%" PRIx32 -#else -#error "Must define either OPENSSL_32_BIT or OPENSSL_64_BIT" -#endif - - -/* Allocation and freeing. */ - -/* BN_new creates a new, allocated BIGNUM and initialises it. */ -OPENSSL_EXPORT BIGNUM *BN_new(void); - -/* BN_init initialises a stack allocated |BIGNUM|. */ -OPENSSL_EXPORT void BN_init(BIGNUM *bn); - -/* BN_free frees the data referenced by |bn| and, if |bn| was originally - * allocated on the heap, frees |bn| also. */ -OPENSSL_EXPORT void BN_free(BIGNUM *bn); - -/* BN_clear_free erases and frees the data referenced by |bn| and, if |bn| was - * originally allocated on the heap, frees |bn| also. */ -OPENSSL_EXPORT void BN_clear_free(BIGNUM *bn); - -/* BN_dup allocates a new BIGNUM and sets it equal to |src|. It returns the - * allocated BIGNUM on success or NULL otherwise. */ -OPENSSL_EXPORT BIGNUM *BN_dup(const BIGNUM *src); - -/* BN_copy sets |dest| equal to |src| and returns |dest|. */ -OPENSSL_EXPORT BIGNUM *BN_copy(BIGNUM *dest, const BIGNUM *src); - -/* BN_clear sets |bn| to zero and erases the old data. */ -OPENSSL_EXPORT void BN_clear(BIGNUM *bn); - -/* BN_value_one returns a static BIGNUM with value 1. */ -OPENSSL_EXPORT const BIGNUM *BN_value_one(void); - -/* BN_with_flags initialises a stack allocated |BIGNUM| with pointers to the - * contents of |in| but with |flags| ORed into the flags field. - * - * Note: the two BIGNUMs share state and so |out| should /not/ be passed to - * |BN_free|. */ -OPENSSL_EXPORT void BN_with_flags(BIGNUM *out, const BIGNUM *in, int flags); - - -/* Basic functions. */ - -/* BN_num_bits returns the minimum number of bits needed to represent the - * absolute value of |bn|. */ -OPENSSL_EXPORT unsigned BN_num_bits(const BIGNUM *bn); - -/* BN_num_bytes returns the minimum number of bytes needed to represent the - * absolute value of |bn|. */ -OPENSSL_EXPORT unsigned BN_num_bytes(const BIGNUM *bn); - -/* BN_zero sets |bn| to zero. */ -OPENSSL_EXPORT void BN_zero(BIGNUM *bn); - -/* BN_one sets |bn| to one. It returns one on success or zero on allocation - * failure. */ -OPENSSL_EXPORT int BN_one(BIGNUM *bn); - -/* BN_set_word sets |bn| to |value|. It returns one on success or zero on - * allocation failure. */ -OPENSSL_EXPORT int BN_set_word(BIGNUM *bn, BN_ULONG value); - -/* BN_set_negative sets the sign of |bn|. */ -OPENSSL_EXPORT void BN_set_negative(BIGNUM *bn, int sign); - -/* BN_is_negative returns one if |bn| is negative and zero otherwise. */ -OPENSSL_EXPORT int BN_is_negative(const BIGNUM *bn); - -/* BN_get_flags returns |bn->flags| & |flags|. */ -OPENSSL_EXPORT int BN_get_flags(const BIGNUM *bn, int flags); - -/* BN_set_flags sets |flags| on |bn|. */ -OPENSSL_EXPORT void BN_set_flags(BIGNUM *bn, int flags); - - -/* Conversion functions. */ - -/* BN_bin2bn sets |*ret| to the value of |len| bytes from |in|, interpreted as - * a big-endian number, and returns |ret|. If |ret| is NULL then a fresh - * |BIGNUM| is allocated and returned. It returns NULL on allocation - * failure. */ -OPENSSL_EXPORT BIGNUM *BN_bin2bn(const uint8_t *in, size_t len, BIGNUM *ret); - -/* BN_bn2bin serialises the absolute value of |in| to |out| as a big-endian - * integer, which must have |BN_num_bytes| of space available. It returns the - * number of bytes written. */ -OPENSSL_EXPORT size_t BN_bn2bin(const BIGNUM *in, uint8_t *out); - -/* BN_bn2bin_padded serialises the absolute value of |in| to |out| as a - * big-endian integer. The integer is padded with leading zeros up to size - * |len|. If |len| is smaller than |BN_num_bytes|, the function fails and - * returns 0. Otherwise, it returns 1. */ -OPENSSL_EXPORT int BN_bn2bin_padded(uint8_t *out, size_t len, const BIGNUM *in); - -/* BN_bn2hex returns an allocated string that contains a NUL-terminated, hex - * representation of |bn|. If |bn| is negative, the first char in the resulting - * string will be '-'. Returns NULL on allocation failure. */ -OPENSSL_EXPORT char *BN_bn2hex(const BIGNUM *bn); - -/* BN_hex2bn parses the leading hex number from |in|, which may be proceeded by - * a '-' to indicate a negative number and may contain trailing, non-hex data. - * If |outp| is not NULL, it constructs a BIGNUM equal to the hex number and - * stores it in |*outp|. If |*outp| is NULL then it allocates a new BIGNUM and - * updates |*outp|. It returns the number of bytes of |in| processed or zero on - * error. */ -OPENSSL_EXPORT int BN_hex2bn(BIGNUM **outp, const char *in); - -/* BN_bn2dec returns an allocated string that contains a NUL-terminated, - * decimal representation of |bn|. If |bn| is negative, the first char in the - * resulting string will be '-'. Returns NULL on allocation failure. */ -OPENSSL_EXPORT char *BN_bn2dec(const BIGNUM *a); - -/* BN_dec2bn parses the leading decimal number from |in|, which may be - * proceeded by a '-' to indicate a negative number and may contain trailing, - * non-decimal data. If |outp| is not NULL, it constructs a BIGNUM equal to the - * decimal number and stores it in |*outp|. If |*outp| is NULL then it - * allocates a new BIGNUM and updates |*outp|. It returns the number of bytes - * of |in| processed or zero on error. */ -OPENSSL_EXPORT int BN_dec2bn(BIGNUM **outp, const char *in); - -/* BN_asc2bn acts like |BN_dec2bn| or |BN_hex2bn| depending on whether |in| - * begins with "0X" or "0x" (indicating hex) or not (indicating decimal). A - * leading '-' is still permitted and comes before the optional 0X/0x. It - * returns one on success or zero on error. */ -OPENSSL_EXPORT int BN_asc2bn(BIGNUM **outp, const char *in); - -/* BN_print writes a hex encoding of |a| to |bio|. It returns one on success - * and zero on error. */ -OPENSSL_EXPORT int BN_print(BIO *bio, const BIGNUM *a); - -/* BN_print_fp acts like |BIO_print|, but wraps |fp| in a |BIO| first. */ -OPENSSL_EXPORT int BN_print_fp(FILE *fp, const BIGNUM *a); - -/* BN_get_word returns the absolute value of |bn| as a single word. If |bn| is - * too large to be represented as a single word, the maximum possible value - * will be returned. */ -OPENSSL_EXPORT BN_ULONG BN_get_word(const BIGNUM *bn); - - -/* Internal functions. - * - * These functions are useful for code that is doing low-level manipulations of - * BIGNUM values. However, be sure that no other function in this file does - * what you want before turning to these. */ - -/* bn_correct_top decrements |bn->top| until |bn->d[top-1]| is non-zero or - * until |top| is zero. */ -OPENSSL_EXPORT void bn_correct_top(BIGNUM *bn); - -/* bn_wexpand ensures that |bn| has at least |words| works of space without - * altering its value. It returns one on success or zero on allocation - * failure. */ -OPENSSL_EXPORT BIGNUM *bn_wexpand(BIGNUM *bn, unsigned words); - - -/* BIGNUM pools. - * - * Certain BIGNUM operations need to use many temporary variables and - * allocating and freeing them can be quite slow. Thus such opertions typically - * take a |BN_CTX| parameter, which contains a pool of |BIGNUMs|. The |ctx| - * argument to a public function may be NULL, in which case a local |BN_CTX| - * will be created just for the lifetime of that call. - * - * A function must call |BN_CTX_start| first. Then, |BN_CTX_get| may be called - * repeatedly to obtain temporary |BIGNUM|s. All |BN_CTX_get| calls must be made - * before calling any other functions that use the |ctx| as an argument. - * - * Finally, |BN_CTX_end| must be called before returning from the function. - * When |BN_CTX_end| is called, the |BIGNUM| pointers obtained from - * |BN_CTX_get| become invalid. */ - -/* BN_CTX_new returns a new, empty BN_CTX or NULL on allocation failure. */ -OPENSSL_EXPORT BN_CTX *BN_CTX_new(void); - -/* BN_CTX_free frees all BIGNUMs contained in |ctx| and then frees |ctx| - * itself. */ -OPENSSL_EXPORT void BN_CTX_free(BN_CTX *ctx); - -/* BN_CTX_start "pushes" a new entry onto the |ctx| stack and allows future - * calls to |BN_CTX_get|. */ -OPENSSL_EXPORT void BN_CTX_start(BN_CTX *ctx); - -/* BN_CTX_get returns a new |BIGNUM|, or NULL on allocation failure. Once - * |BN_CTX_get| has returned NULL, all future calls will also return NULL until - * |BN_CTX_end| is called. */ -OPENSSL_EXPORT BIGNUM *BN_CTX_get(BN_CTX *ctx); - -/* BN_CTX_end invalidates all |BIGNUM|s returned from |BN_CTX_get| since the - * matching |BN_CTX_start| call. */ -OPENSSL_EXPORT void BN_CTX_end(BN_CTX *ctx); - - -/* Simple arithmetic */ - -/* BN_add sets |r| = |a| + |b|, where |r| may be the same pointer as either |a| - * or |b|. It returns one on success and zero on allocation failure. */ -OPENSSL_EXPORT int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); - -/* BN_uadd sets |r| = |a| + |b|, where |a| and |b| are non-negative and |r| may - * be the same pointer as either |a| or |b|. It returns one on success and zero - * on allocation failure. */ -OPENSSL_EXPORT int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); - -/* BN_add_word adds |w| to |a|. It returns one on success and zero otherwise. */ -OPENSSL_EXPORT int BN_add_word(BIGNUM *a, BN_ULONG w); - -/* BN_sub sets |r| = |a| - |b|, where |r| must be a distinct pointer from |a| - * and |b|. It returns one on success and zero on allocation failure. */ -OPENSSL_EXPORT int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); - -/* BN_usub sets |r| = |a| - |b|, where |a| and |b| are non-negative integers, - * |b| < |a| and |r| must be a distinct pointer from |a| and |b|. It returns - * one on success and zero on allocation failure. */ -OPENSSL_EXPORT int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); - -/* BN_sub_word subtracts |w| from |a|. It returns one on success and zero on - * allocation failure. */ -OPENSSL_EXPORT int BN_sub_word(BIGNUM *a, BN_ULONG w); - -/* BN_mul sets |r| = |a| * |b|, where |r| may be the same pointer as |a| or - * |b|. Returns one on success and zero otherwise. */ -OPENSSL_EXPORT int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - BN_CTX *ctx); - -/* BN_mul_word sets |bn| = |bn| * |w|. It returns one on success or zero on - * allocation failure. */ -OPENSSL_EXPORT int BN_mul_word(BIGNUM *bn, BN_ULONG w); - -/* BN_sqr sets |r| = |a|^2 (i.e. squares), where |r| may be the same pointer as - * |a|. Returns one on success and zero otherwise. This is more efficient than - * BN_mul(r, a, a, ctx). */ -OPENSSL_EXPORT int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx); - -/* BN_div divides |numerator| by |divisor| and places the result in |quotient| - * and the remainder in |rem|. Either of |quotient| or |rem| may be NULL, in - * which case the respective value is not returned. The result is rounded - * towards zero; thus if |numerator| is negative, the remainder will be zero or - * negative. It returns one on success or zero on error. */ -OPENSSL_EXPORT int BN_div(BIGNUM *quotient, BIGNUM *rem, - const BIGNUM *numerator, const BIGNUM *divisor, - BN_CTX *ctx); - -/* BN_div_word sets |numerator| = |numerator|/|divisor| and returns the - * remainder or (BN_ULONG)-1 on error. */ -OPENSSL_EXPORT BN_ULONG BN_div_word(BIGNUM *numerator, BN_ULONG divisor); - -/* BN_sqrt sets |*out_sqrt| (which may be the same |BIGNUM| as |in|) to the - * square root of |in|, using |ctx|. It returns one on success or zero on - * error. Negative numbers and non-square numbers will result in an error with - * appropriate errors on the error queue. */ -OPENSSL_EXPORT int BN_sqrt(BIGNUM *out_sqrt, const BIGNUM *in, BN_CTX *ctx); - - -/* Comparison functions */ - -/* BN_cmp returns a value less than, equal to or greater than zero if |a| is - * less than, equal to or greater than |b|, respectively. */ -OPENSSL_EXPORT int BN_cmp(const BIGNUM *a, const BIGNUM *b); - -/* BN_ucmp returns a value less than, equal to or greater than zero if the - * absolute value of |a| is less than, equal to or greater than the absolute - * value of |b|, respectively. */ -OPENSSL_EXPORT int BN_ucmp(const BIGNUM *a, const BIGNUM *b); - -/* BN_abs_is_word returns one if the absolute value of |bn| equals |w| and zero - * otherwise. */ -OPENSSL_EXPORT int BN_abs_is_word(const BIGNUM *bn, BN_ULONG w); - -/* BN_is_zero returns one if |bn| is zero and zero otherwise. */ -OPENSSL_EXPORT int BN_is_zero(const BIGNUM *bn); - -/* BN_is_one returns one if |bn| equals one and zero otherwise. */ -OPENSSL_EXPORT int BN_is_one(const BIGNUM *bn); - -/* BN_is_word returns one if |bn| is exactly |w| and zero otherwise. */ -OPENSSL_EXPORT int BN_is_word(const BIGNUM *bn, BN_ULONG w); - -/* BN_is_odd returns one if |bn| is odd and zero otherwise. */ -OPENSSL_EXPORT int BN_is_odd(const BIGNUM *bn); - - -/* Bitwise operations. */ - -/* BN_lshift sets |r| equal to |a| << n. The |a| and |r| arguments may be the - * same |BIGNUM|. It returns one on success and zero on allocation failure. */ -OPENSSL_EXPORT int BN_lshift(BIGNUM *r, const BIGNUM *a, int n); - -/* BN_lshift1 sets |r| equal to |a| << 1, where |r| and |a| may be the same - * pointer. It returns one on success and zero on allocation failure. */ -OPENSSL_EXPORT int BN_lshift1(BIGNUM *r, const BIGNUM *a); - -/* BN_rshift sets |r| equal to |a| >> n, where |r| and |a| may be the same - * pointer. It returns one on success and zero on allocation failure. */ -OPENSSL_EXPORT int BN_rshift(BIGNUM *r, const BIGNUM *a, int n); - -/* BN_rshift1 sets |r| equal to |a| >> 1, where |r| and |a| may be the same - * pointer. It returns one on success and zero on allocation failure. */ -OPENSSL_EXPORT int BN_rshift1(BIGNUM *r, const BIGNUM *a); - -/* BN_set_bit sets the |n|th, least-significant bit in |a|. For example, if |a| - * is 2 then setting bit zero will make it 3. It returns one on success or zero - * on allocation failure. */ -OPENSSL_EXPORT int BN_set_bit(BIGNUM *a, int n); - -/* BN_clear_bit clears the |n|th, least-significant bit in |a|. For example, if - * |a| is 3, clearing bit zero will make it two. It returns one on success or - * zero on allocation failure. */ -OPENSSL_EXPORT int BN_clear_bit(BIGNUM *a, int n); - -/* BN_is_bit_set returns the value of the |n|th, least-significant bit in |a|, - * or zero if the bit doesn't exist. */ -OPENSSL_EXPORT int BN_is_bit_set(const BIGNUM *a, int n); - -/* BN_mask_bits truncates |a| so that it is only |n| bits long. It returns one - * on success or zero if |n| is greater than the length of |a| already. */ -OPENSSL_EXPORT int BN_mask_bits(BIGNUM *a, int n); - - -/* Modulo arithmetic. */ - -/* BN_mod_word returns |a| mod |w|. */ -OPENSSL_EXPORT BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w); - -/* BN_mod is a helper macro that calls |BN_div| and discards the quotient. */ -#define BN_mod(rem, numerator, divisor, ctx) \ - BN_div(NULL, (rem), (numerator), (divisor), (ctx)) - -/* BN_nnmod is a non-negative modulo function. It acts like |BN_mod|, but 0 <= - * |rem| < |divisor| is always true. It returns one on success and zero on - * error. */ -OPENSSL_EXPORT int BN_nnmod(BIGNUM *rem, const BIGNUM *numerator, - const BIGNUM *divisor, BN_CTX *ctx); - -/* BN_mod_add sets |r| = |a| + |b| mod |m|. It returns one on success and zero - * on error. */ -OPENSSL_EXPORT int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *m, BN_CTX *ctx); - -/* BN_mod_add_quick acts like |BN_mod_add| but requires that |a| and |b| be - * non-negative and less than |m|. */ -OPENSSL_EXPORT int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *m); - -/* BN_mod_sub sets |r| = |a| - |b| mod |m|. It returns one on success and zero - * on error. */ -OPENSSL_EXPORT int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *m, BN_CTX *ctx); - -/* BN_mod_sub_quick acts like |BN_mod_sub| but requires that |a| and |b| be - * non-negative and less than |m|. */ -OPENSSL_EXPORT int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *m); - -/* BN_mod_mul sets |r| = |a|*|b| mod |m|. It returns one on success and zero - * on error. */ -OPENSSL_EXPORT int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *m, BN_CTX *ctx); - -/* BN_mod_mul sets |r| = |a|^2 mod |m|. It returns one on success and zero - * on error. */ -OPENSSL_EXPORT int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, - BN_CTX *ctx); - -/* BN_mod_lshift sets |r| = (|a| << n) mod |m|, where |r| and |a| may be the - * same pointer. It returns one on success and zero on error. */ -OPENSSL_EXPORT int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, - const BIGNUM *m, BN_CTX *ctx); - -/* BN_mod_lshift_quick acts like |BN_mod_lshift| but requires that |a| be - * non-negative and less than |m|. */ -OPENSSL_EXPORT int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, - const BIGNUM *m); - -/* BN_mod_lshift1 sets |r| = (|a| << 1) mod |m|, where |r| and |a| may be the - * same pointer. It returns one on success and zero on error. */ -OPENSSL_EXPORT int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, - BN_CTX *ctx); - -/* BN_mod_lshift1_quick acts like |BN_mod_lshift1| but requires that |a| be - * non-negative and less than |m|. */ -OPENSSL_EXPORT int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, - const BIGNUM *m); - -/* BN_mod_sqrt returns a |BIGNUM|, r, such that r^2 == a (mod p). */ -OPENSSL_EXPORT BIGNUM *BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, - BN_CTX *ctx); - - -/* Random and prime number generation. */ - -/* BN_rand sets |rnd| to a random number of length |bits|. If |top| is zero, the - * most-significant bit, if any, will be set. If |top| is one, the two most - * significant bits, if any, will be set. - * - * If |top| is -1 then no extra action will be taken and |BN_num_bits(rnd)| may - * not equal |bits| if the most significant bits randomly ended up as zeros. - * - * If |bottom| is non-zero, the least-significant bit, if any, will be set. The - * function returns one on success or zero otherwise. */ -OPENSSL_EXPORT int BN_rand(BIGNUM *rnd, int bits, int top, int bottom); - -/* BN_pseudo_rand is an alias for |BN_rand|. */ -OPENSSL_EXPORT int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom); - -/* BN_rand_range sets |rnd| to a random value [0..range). It returns one on - * success and zero otherwise. */ -OPENSSL_EXPORT int BN_rand_range(BIGNUM *rnd, const BIGNUM *range); - -/* BN_pseudo_rand_range is an alias for BN_rand_range. */ -OPENSSL_EXPORT int BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range); - -/* BN_generate_dsa_nonce generates a random number 0 <= out < range. Unlike - * BN_rand_range, it also includes the contents of |priv| and |message| in the - * generation so that an RNG failure isn't fatal as long as |priv| remains - * secret. This is intended for use in DSA and ECDSA where an RNG weakness - * leads directly to private key exposure unless this function is used. - * It returns one on success and zero on error. */ -OPENSSL_EXPORT int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range, - const BIGNUM *priv, - const uint8_t *message, - size_t message_len, BN_CTX *ctx); - -/* BN_GENCB holds a callback function that is used by generation functions that - * can take a very long time to complete. Use |BN_GENCB_set| to initialise a - * |BN_GENCB| structure. - * - * The callback receives the address of that |BN_GENCB| structure as its last - * argument and the user is free to put an arbitary pointer in |arg|. The other - * arguments are set as follows: - * event=BN_GENCB_GENERATED, n=i: after generating the i'th possible prime - * number. - * event=BN_GENCB_PRIME_TEST, n=-1: when finished trial division primality - * checks. - * event=BN_GENCB_PRIME_TEST, n=i: when the i'th primality test has finished. - * - * The callback can return zero to abort the generation progress or one to - * allow it to continue. - * - * When other code needs to call a BN generation function it will often take a - * BN_GENCB argument and may call the function with other argument values. */ -#define BN_GENCB_GENERATED 0 -#define BN_GENCB_PRIME_TEST 1 - -struct bn_gencb_st { - void *arg; /* callback-specific data */ - int (*callback)(int event, int n, struct bn_gencb_st *); -}; - -/* BN_GENCB_set configures |callback| to call |f| and sets |callout->arg| to - * |arg|. */ -OPENSSL_EXPORT void BN_GENCB_set(BN_GENCB *callback, - int (*f)(int event, int n, - struct bn_gencb_st *), - void *arg); - -/* BN_GENCB_call calls |callback|, if not NULL, and returns the return value of - * the callback, or 1 if |callback| is NULL. */ -OPENSSL_EXPORT int BN_GENCB_call(BN_GENCB *callback, int event, int n); - -/* BN_generate_prime_ex sets |ret| to a prime number of |bits| length. If safe - * is non-zero then the prime will be such that (ret-1)/2 is also a prime. - * (This is needed for Diffie-Hellman groups to ensure that the only subgroups - * are of size 2 and (p-1)/2.). - * - * If |add| is not NULL, the prime will fulfill the condition |ret| % |add| == - * |rem| in order to suit a given generator. (If |rem| is NULL then |ret| % - * |add| == 1.) - * - * If |cb| is not NULL, it will be called during processing to give an - * indication of progress. See the comments for |BN_GENCB|. It returns one on - * success and zero otherwise. */ -OPENSSL_EXPORT int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, - const BIGNUM *add, const BIGNUM *rem, - BN_GENCB *cb); - -/* BN_prime_checks is magic value that can be used as the |checks| argument to - * the primality testing functions in order to automatically select a number of - * Miller-Rabin checks that gives a false positive rate of ~2^{-80}. */ -#define BN_prime_checks 0 - -/* BN_primality_test sets |*is_probably_prime| to one if |candidate| is - * probably a prime number by the Miller-Rabin test or zero if it's certainly - * not. - * - * If |do_trial_division| is non-zero then |candidate| will be tested against a - * list of small primes before Miller-Rabin tests. The probability of this - * function returning a false positive is 2^{2*checks}. If |checks| is - * |BN_prime_checks| then a value that results in approximately 2^{-80} false - * positive probability is used. If |cb| is not NULL then it is called during - * the checking process. See the comment above |BN_GENCB|. - * - * The function returns one on success and zero on error. - * - * (If you are unsure whether you want |do_trial_division|, don't set it.) */ -OPENSSL_EXPORT int BN_primality_test(int *is_probably_prime, - const BIGNUM *candidate, int checks, - BN_CTX *ctx, int do_trial_division, - BN_GENCB *cb); - -/* BN_is_prime_fasttest_ex returns one if |candidate| is probably a prime - * number by the Miller-Rabin test, zero if it's certainly not and -1 on error. - * - * If |do_trial_division| is non-zero then |candidate| will be tested against a - * list of small primes before Miller-Rabin tests. The probability of this - * function returning one when |candidate| is composite is 2^{2*checks}. If - * |checks| is |BN_prime_checks| then a value that results in approximately - * 2^{-80} false positive probability is used. If |cb| is not NULL then it is - * called during the checking process. See the comment above |BN_GENCB|. - * - * WARNING: deprecated. Use |BN_primality_test|. */ -OPENSSL_EXPORT int BN_is_prime_fasttest_ex(const BIGNUM *candidate, int checks, - BN_CTX *ctx, int do_trial_division, - BN_GENCB *cb); - -/* BN_is_prime_ex acts the same as |BN_is_prime_fasttest_ex| with - * |do_trial_division| set to zero. - * - * WARNING: deprecated: Use |BN_primality_test|. */ -OPENSSL_EXPORT int BN_is_prime_ex(const BIGNUM *candidate, int checks, - BN_CTX *ctx, BN_GENCB *cb); - - -/* Number theory functions */ - -/* BN_gcd sets |r| = gcd(|a|, |b|). It returns one on success and zero - * otherwise. */ -OPENSSL_EXPORT int BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - BN_CTX *ctx); - -/* BN_mod_inverse sets |out| equal to |a|^-1, mod |n|. If either of |a| or |n| - * have |BN_FLG_CONSTTIME| set then the operation is performed in constant - * time. If |out| is NULL, a fresh BIGNUM is allocated. It returns the result - * or NULL on error. */ -OPENSSL_EXPORT BIGNUM *BN_mod_inverse(BIGNUM *out, const BIGNUM *a, - const BIGNUM *n, BN_CTX *ctx); - -/* BN_kronecker returns the Kronecker symbol of |a| and |b| (which is -1, 0 or - * 1), or -2 on error. */ -OPENSSL_EXPORT int BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); - - -/* Montgomery arithmetic. */ - -/* BN_MONT_CTX contains the precomputed values needed to work in a specific - * Montgomery domain. */ - -/* BN_MONT_CTX_new returns a fresh BN_MONT_CTX or NULL on allocation failure. */ -OPENSSL_EXPORT BN_MONT_CTX *BN_MONT_CTX_new(void); - -/* BN_MONT_CTX_init initialises a stack allocated |BN_MONT_CTX|. */ -OPENSSL_EXPORT void BN_MONT_CTX_init(BN_MONT_CTX *mont); - -/* BN_MONT_CTX_free frees the contexts of |mont| and, if it was originally - * allocated with |BN_MONT_CTX_new|, |mont| itself. */ -OPENSSL_EXPORT void BN_MONT_CTX_free(BN_MONT_CTX *mont); - -/* BN_MONT_CTX_copy sets |to| equal to |from|. It returns |to| on success or - * NULL on error. */ -OPENSSL_EXPORT BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, - BN_MONT_CTX *from); - -/* BN_MONT_CTX_set sets up a Montgomery context given the modulus, |mod|. It - * returns one on success and zero on error. */ -OPENSSL_EXPORT int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, - BN_CTX *ctx); - -/* BN_MONT_CTX_set_locked takes |lock| and checks whether |*pmont| is NULL. If - * so, it creates a new |BN_MONT_CTX| and sets the modulus for it to |mod|. It - * then stores it as |*pmont| and returns it, or NULL on error. - * - * If |*pmont| is already non-NULL then the existing value is returned. */ -BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, CRYPTO_MUTEX *lock, - const BIGNUM *mod, BN_CTX *bn_ctx); - -/* BN_to_montgomery sets |ret| equal to |a| in the Montgomery domain. It - * returns one on success and zero on error. */ -OPENSSL_EXPORT int BN_to_montgomery(BIGNUM *ret, const BIGNUM *a, - const BN_MONT_CTX *mont, BN_CTX *ctx); - -/* BN_from_montgomery sets |ret| equal to |a| * R^-1, i.e. translates values - * out of the Montgomery domain. It returns one on success or zero on error. */ -OPENSSL_EXPORT int BN_from_montgomery(BIGNUM *ret, const BIGNUM *a, - const BN_MONT_CTX *mont, BN_CTX *ctx); - -/* BN_mod_mul_montgomery set |r| equal to |a| * |b|, in the Montgomery domain. - * Both |a| and |b| must already be in the Montgomery domain (by - * |BN_to_montgomery|). It returns one on success or zero on error. */ -OPENSSL_EXPORT int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, - const BIGNUM *b, - const BN_MONT_CTX *mont, BN_CTX *ctx); - - -/* Exponentiation. */ - -/* BN_exp sets |r| equal to |a|^{|p|}. It does so with a square-and-multiply - * algorithm that leaks side-channel information. It returns one on success or - * zero otherwise. */ -OPENSSL_EXPORT int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - BN_CTX *ctx); - -/* BN_mod_exp sets |r| equal to |a|^{|p|} mod |m|. It does so with the best - * algorithm for the values provided and can run in constant time if - * |BN_FLG_CONSTTIME| is set for |p|. It returns one on success or zero - * otherwise. */ -OPENSSL_EXPORT int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx); - -OPENSSL_EXPORT int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx); - -OPENSSL_EXPORT int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, - const BIGNUM *p, const BIGNUM *m, - BN_CTX *ctx, BN_MONT_CTX *in_mont); - -OPENSSL_EXPORT int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx); -OPENSSL_EXPORT int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, - const BIGNUM *p1, const BIGNUM *a2, - const BIGNUM *p2, const BIGNUM *m, - BN_CTX *ctx, BN_MONT_CTX *m_ctx); - - -/* Private functions */ - -struct bignum_st { - BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks in little-endian - order. */ - int top; /* Index of last used element in |d|, plus one. */ - int dmax; /* Size of |d|, in words. */ - int neg; /* one if the number is negative */ - int flags; /* bitmask of BN_FLG_* values */ -}; - -struct bn_mont_ctx_st { - BIGNUM RR; /* used to convert to montgomery form */ - BIGNUM N; /* The modulus */ - BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1 - * (Ni is only stored for bignum algorithm) */ - BN_ULONG n0[2]; /* least significant word(s) of Ni; - (type changed with 0.9.9, was "BN_ULONG n0;" before) */ - int flags; - int ri; /* number of bits in R */ -}; - -OPENSSL_EXPORT unsigned BN_num_bits_word(BN_ULONG l); - -#define BN_FLG_MALLOCED 0x01 -#define BN_FLG_STATIC_DATA 0x02 -/* avoid leaking exponent information through timing, BN_mod_exp_mont() will - * call BN_mod_exp_mont_consttime, BN_div() will call BN_div_no_branch, - * BN_mod_inverse() will call BN_mod_inverse_no_branch. */ -#define BN_FLG_CONSTTIME 0x04 - - -/* Android compatibility section. - * - * These functions are declared, temporarily, for Android because - * wpa_supplicant will take a little time to sync with upstream. Outside of - * Android they'll have no definition. */ - -OPENSSL_EXPORT BIGNUM *get_rfc3526_prime_1536(BIGNUM *bn); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#define BN_F_BN_CTX_get 100 -#define BN_F_BN_CTX_new 101 -#define BN_F_BN_CTX_start 102 -#define BN_F_BN_bn2dec 103 -#define BN_F_BN_bn2hex 104 -#define BN_F_BN_div 105 -#define BN_F_BN_div_recp 106 -#define BN_F_BN_exp 107 -#define BN_F_BN_generate_dsa_nonce 108 -#define BN_F_BN_generate_prime_ex 109 -#define BN_F_BN_mod_exp2_mont 110 -#define BN_F_BN_mod_exp_mont 111 -#define BN_F_BN_mod_exp_mont_consttime 112 -#define BN_F_BN_mod_exp_mont_word 113 -#define BN_F_BN_mod_inverse 114 -#define BN_F_BN_mod_inverse_no_branch 115 -#define BN_F_BN_mod_lshift_quick 116 -#define BN_F_BN_mod_sqrt 117 -#define BN_F_BN_new 118 -#define BN_F_BN_rand 119 -#define BN_F_BN_rand_range 120 -#define BN_F_BN_sqrt 121 -#define BN_F_BN_usub 122 -#define BN_F_bn_wexpand 123 -#define BN_F_mod_exp_recp 124 -#define BN_F_BN_lshift 125 -#define BN_F_BN_rshift 126 -#define BN_R_ARG2_LT_ARG3 100 -#define BN_R_BAD_RECIPROCAL 101 -#define BN_R_BIGNUM_TOO_LONG 102 -#define BN_R_BITS_TOO_SMALL 103 -#define BN_R_CALLED_WITH_EVEN_MODULUS 104 -#define BN_R_DIV_BY_ZERO 105 -#define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 106 -#define BN_R_INPUT_NOT_REDUCED 107 -#define BN_R_INVALID_RANGE 108 -#define BN_R_NEGATIVE_NUMBER 109 -#define BN_R_NOT_A_SQUARE 110 -#define BN_R_NOT_INITIALIZED 111 -#define BN_R_NO_INVERSE 112 -#define BN_R_PRIVATE_KEY_TOO_LARGE 113 -#define BN_R_P_IS_NOT_PRIME 114 -#define BN_R_TOO_MANY_ITERATIONS 115 -#define BN_R_TOO_MANY_TEMPORARY_VARIABLES 116 - -#endif /* OPENSSL_HEADER_BN_H */ diff --git a/phonelibs/boringssl/include/openssl/buf.h b/phonelibs/boringssl/include/openssl/buf.h deleted file mode 100644 index 2b36ce40585c33..00000000000000 --- a/phonelibs/boringssl/include/openssl/buf.h +++ /dev/null @@ -1,123 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_BUFFER_H -#define OPENSSL_HEADER_BUFFER_H - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* Memory and string functions, see also mem.h. */ - - -/* BUF_MEM is a generic buffer object used by OpenSSL. */ -struct buf_mem_st { - size_t length; /* current number of bytes */ - char *data; - size_t max; /* size of buffer */ -}; - -/* BUF_MEM_new creates a new BUF_MEM which has no allocated data buffer. */ -OPENSSL_EXPORT BUF_MEM *BUF_MEM_new(void); - -/* BUF_MEM_free frees |buf->data| if needed and then frees |buf| itself. */ -OPENSSL_EXPORT void BUF_MEM_free(BUF_MEM *buf); - -/* BUF_MEM_grow ensures that |buf| has length |len| and allocates memory if - * needed. If the length of |buf| increased, the new bytes are filled with - * zeros. It returns the length of |buf|, or zero if there's an error. */ -OPENSSL_EXPORT size_t BUF_MEM_grow(BUF_MEM *buf, size_t len); - -/* BUF_MEM_grow_clean acts the same as |BUF_MEM_grow|, but clears the previous - * contents of memory if reallocing. */ -OPENSSL_EXPORT size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len); - -/* BUF_strdup returns an allocated, duplicate of |str|. */ -OPENSSL_EXPORT char *BUF_strdup(const char *str); - -/* BUF_strnlen returns the number of characters in |str|, excluding the NUL - * byte, but at most |max_len|. This function never reads more than |max_len| - * bytes from |str|. */ -OPENSSL_EXPORT size_t BUF_strnlen(const char *str, size_t max_len); - -/* BUF_strndup returns an allocated, duplicate of |str|, which is, at most, - * |size| bytes. The result is always NUL terminated. */ -OPENSSL_EXPORT char *BUF_strndup(const char *str, size_t size); - -/* BUF_memdup returns an allocated, duplicate of |size| bytes from |data|. */ -OPENSSL_EXPORT void *BUF_memdup(const void *data, size_t size); - -/* BUF_strlcpy acts like strlcpy(3). */ -OPENSSL_EXPORT size_t BUF_strlcpy(char *dst, const char *src, size_t dst_size); - -/* BUF_strlcat acts like strlcat(3). */ -OPENSSL_EXPORT size_t BUF_strlcat(char *dst, const char *src, size_t size); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#define BUF_F_BUF_MEM_new 100 -#define BUF_F_BUF_memdup 101 -#define BUF_F_BUF_strndup 102 -#define BUF_F_buf_mem_grow 103 - -#endif /* OPENSSL_HEADER_BUFFER_H */ diff --git a/phonelibs/boringssl/include/openssl/buffer.h b/phonelibs/boringssl/include/openssl/buffer.h deleted file mode 100644 index c6b721c277b4a9..00000000000000 --- a/phonelibs/boringssl/include/openssl/buffer.h +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright (c) 2015, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -/* This header is provided in order to make compiling against code that expects - OpenSSL easier. */ - -#include "buf.h" diff --git a/phonelibs/boringssl/include/openssl/bytestring.h b/phonelibs/boringssl/include/openssl/bytestring.h deleted file mode 100644 index 9963426ca3f1db..00000000000000 --- a/phonelibs/boringssl/include/openssl/bytestring.h +++ /dev/null @@ -1,325 +0,0 @@ -/* Copyright (c) 2014, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -#ifndef OPENSSL_HEADER_BYTESTRING_H -#define OPENSSL_HEADER_BYTESTRING_H - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* Bytestrings are used for parsing and building TLS and ASN.1 messages. - * - * A "CBS" (CRYPTO ByteString) represents a string of bytes in memory and - * provides utility functions for safely parsing length-prefixed structures - * like TLS and ASN.1 from it. - * - * A "CBB" (CRYPTO ByteBuilder) is a memory buffer that grows as needed and - * provides utility functions for building length-prefixed messages. */ - - -/* CRYPTO ByteString */ - -struct cbs_st { - const uint8_t *data; - size_t len; -}; - -/* CBS_init sets |cbs| to point to |data|. It does not take ownership of - * |data|. */ -OPENSSL_EXPORT void CBS_init(CBS *cbs, const uint8_t *data, size_t len); - -/* CBS_skip advances |cbs| by |len| bytes. It returns one on success and zero - * otherwise. */ -OPENSSL_EXPORT int CBS_skip(CBS *cbs, size_t len); - -/* CBS_data returns a pointer to the contents of |cbs|. */ -OPENSSL_EXPORT const uint8_t *CBS_data(const CBS *cbs); - -/* CBS_len returns the number of bytes remaining in |cbs|. */ -OPENSSL_EXPORT size_t CBS_len(const CBS *cbs); - -/* CBS_stow copies the current contents of |cbs| into |*out_ptr| and - * |*out_len|. If |*out_ptr| is not NULL, the contents are freed with - * OPENSSL_free. It returns one on success and zero on allocation failure. On - * success, |*out_ptr| should be freed with OPENSSL_free. If |cbs| is empty, - * |*out_ptr| will be NULL. */ -OPENSSL_EXPORT int CBS_stow(const CBS *cbs, uint8_t **out_ptr, size_t *out_len); - -/* CBS_strdup copies the current contents of |cbs| into |*out_ptr| as a - * NUL-terminated C string. If |*out_ptr| is not NULL, the contents are freed - * with OPENSSL_free. It returns one on success and zero on allocation - * failure. On success, |*out_ptr| should be freed with OPENSSL_free. - * - * NOTE: If |cbs| contains NUL bytes, the string will be truncated. Call - * |CBS_contains_zero_byte(cbs)| to check for NUL bytes. */ -OPENSSL_EXPORT int CBS_strdup(const CBS *cbs, char **out_ptr); - -/* CBS_contains_zero_byte returns one if the current contents of |cbs| contains - * a NUL byte and zero otherwise. */ -OPENSSL_EXPORT int CBS_contains_zero_byte(const CBS *cbs); - -/* CBS_mem_equal compares the current contents of |cbs| with the |len| bytes - * starting at |data|. If they're equal, it returns one, otherwise zero. If the - * lengths match, it uses a constant-time comparison. */ -OPENSSL_EXPORT int CBS_mem_equal(const CBS *cbs, const uint8_t *data, - size_t len); - -/* CBS_get_u8 sets |*out| to the next uint8_t from |cbs| and advances |cbs|. It - * returns one on success and zero on error. */ -OPENSSL_EXPORT int CBS_get_u8(CBS *cbs, uint8_t *out); - -/* CBS_get_u16 sets |*out| to the next, big-endian uint16_t from |cbs| and - * advances |cbs|. It returns one on success and zero on error. */ -OPENSSL_EXPORT int CBS_get_u16(CBS *cbs, uint16_t *out); - -/* CBS_get_u24 sets |*out| to the next, big-endian 24-bit value from |cbs| and - * advances |cbs|. It returns one on success and zero on error. */ -OPENSSL_EXPORT int CBS_get_u24(CBS *cbs, uint32_t *out); - -/* CBS_get_u32 sets |*out| to the next, big-endian uint32_t value from |cbs| - * and advances |cbs|. It returns one on success and zero on error. */ -OPENSSL_EXPORT int CBS_get_u32(CBS *cbs, uint32_t *out); - -/* CBS_get_bytes sets |*out| to the next |len| bytes from |cbs| and advances - * |cbs|. It returns one on success and zero on error. */ -OPENSSL_EXPORT int CBS_get_bytes(CBS *cbs, CBS *out, size_t len); - -/* CBS_get_u8_length_prefixed sets |*out| to the contents of an 8-bit, - * length-prefixed value from |cbs| and advances |cbs| over it. It returns one - * on success and zero on error. */ -OPENSSL_EXPORT int CBS_get_u8_length_prefixed(CBS *cbs, CBS *out); - -/* CBS_get_u16_length_prefixed sets |*out| to the contents of a 16-bit, - * big-endian, length-prefixed value from |cbs| and advances |cbs| over it. It - * returns one on success and zero on error. */ -OPENSSL_EXPORT int CBS_get_u16_length_prefixed(CBS *cbs, CBS *out); - -/* CBS_get_u24_length_prefixed sets |*out| to the contents of a 24-bit, - * big-endian, length-prefixed value from |cbs| and advances |cbs| over it. It - * returns one on success and zero on error. */ -OPENSSL_EXPORT int CBS_get_u24_length_prefixed(CBS *cbs, CBS *out); - - -/* Parsing ASN.1 */ - -#define CBS_ASN1_BOOLEAN 0x1 -#define CBS_ASN1_INTEGER 0x2 -#define CBS_ASN1_BITSTRING 0x3 -#define CBS_ASN1_OCTETSTRING 0x4 -#define CBS_ASN1_OBJECT 0x6 -#define CBS_ASN1_ENUMERATED 0xa -#define CBS_ASN1_SEQUENCE (0x10 | CBS_ASN1_CONSTRUCTED) -#define CBS_ASN1_SET (0x11 | CBS_ASN1_CONSTRUCTED) - -#define CBS_ASN1_CONSTRUCTED 0x20 -#define CBS_ASN1_CONTEXT_SPECIFIC 0x80 - -/* CBS_get_asn1 sets |*out| to the contents of DER-encoded, ASN.1 element (not - * including tag and length bytes) and advances |cbs| over it. The ASN.1 - * element must match |tag_value|. It returns one on success and zero - * on error. - * - * Tag numbers greater than 30 are not supported (i.e. short form only). */ -OPENSSL_EXPORT int CBS_get_asn1(CBS *cbs, CBS *out, unsigned tag_value); - -/* CBS_get_asn1_element acts like |CBS_get_asn1| but |out| will include the - * ASN.1 header bytes too. */ -OPENSSL_EXPORT int CBS_get_asn1_element(CBS *cbs, CBS *out, unsigned tag_value); - -/* CBS_peek_asn1_tag looks ahead at the next ASN.1 tag and returns one - * if the next ASN.1 element on |cbs| would have tag |tag_value|. If - * |cbs| is empty or the tag does not match, it returns zero. Note: if - * it returns one, CBS_get_asn1 may still fail if the rest of the - * element is malformed. */ -OPENSSL_EXPORT int CBS_peek_asn1_tag(const CBS *cbs, unsigned tag_value); - -/* CBS_get_any_asn1_element sets |*out| to contain the next ASN.1 element from - * |*cbs| (including header bytes) and advances |*cbs|. It sets |*out_tag| to - * the tag number and |*out_header_len| to the length of the ASN.1 header. Each - * of |out|, |out_tag|, and |out_header_len| may be NULL to ignore the value. - * - * Tag numbers greater than 30 are not supported (i.e. short form only). */ -OPENSSL_EXPORT int CBS_get_any_asn1_element(CBS *cbs, CBS *out, - unsigned *out_tag, - size_t *out_header_len); - -/* CBS_get_asn1_uint64 gets an ASN.1 INTEGER from |cbs| using |CBS_get_asn1| - * and sets |*out| to its value. It returns one on success and zero on error, - * where error includes the integer being negative, or too large to represent - * in 64 bits. */ -OPENSSL_EXPORT int CBS_get_asn1_uint64(CBS *cbs, uint64_t *out); - -/* CBS_get_optional_asn1 gets an optional explicitly-tagged element - * from |cbs| tagged with |tag| and sets |*out| to its contents. If - * present, it sets |*out_present| to one, otherwise zero. It returns - * one on success, whether or not the element was present, and zero on - * decode failure. */ -OPENSSL_EXPORT int CBS_get_optional_asn1(CBS *cbs, CBS *out, int *out_present, - unsigned tag); - -/* CBS_get_optional_asn1_octet_string gets an optional - * explicitly-tagged OCTET STRING from |cbs|. If present, it sets - * |*out| to the string and |*out_present| to one. Otherwise, it sets - * |*out| to empty and |*out_present| to zero. |out_present| may be - * NULL. It returns one on success, whether or not the element was - * present, and zero on decode failure. */ -OPENSSL_EXPORT int CBS_get_optional_asn1_octet_string(CBS *cbs, CBS *out, - int *out_present, - unsigned tag); - -/* CBS_get_optional_asn1_uint64 gets an optional explicitly-tagged - * INTEGER from |cbs|. If present, it sets |*out| to the - * value. Otherwise, it sets |*out| to |default_value|. It returns one - * on success, whether or not the element was present, and zero on - * decode failure. */ -OPENSSL_EXPORT int CBS_get_optional_asn1_uint64(CBS *cbs, uint64_t *out, - unsigned tag, - uint64_t default_value); - -/* CBS_get_optional_asn1_bool gets an optional, explicitly-tagged BOOLEAN from - * |cbs|. If present, it sets |*out| to either zero or one, based on the - * boolean. Otherwise, it sets |*out| to |default_value|. It returns one on - * success, whether or not the element was present, and zero on decode - * failure. */ -OPENSSL_EXPORT int CBS_get_optional_asn1_bool(CBS *cbs, int *out, unsigned tag, - int default_value); - - -/* CRYPTO ByteBuilder. - * - * |CBB| objects allow one to build length-prefixed serialisations. A |CBB| - * object is associated with a buffer and new buffers are created with - * |CBB_init|. Several |CBB| objects can point at the same buffer when a - * length-prefix is pending, however only a single |CBB| can be 'current' at - * any one time. For example, if one calls |CBB_add_u8_length_prefixed| then - * the new |CBB| points at the same buffer as the original. But if the original - * |CBB| is used then the length prefix is written out and the new |CBB| must - * not be used again. - * - * If one needs to force a length prefix to be written out because a |CBB| is - * going out of scope, use |CBB_flush|. */ - -struct cbb_buffer_st { - uint8_t *buf; - size_t len; /* The number of valid bytes. */ - size_t cap; /* The size of buf. */ - char can_resize; /* One iff |buf| is owned by this object. If not then |buf| - cannot be resized. */ -}; - -struct cbb_st { - struct cbb_buffer_st *base; - /* offset is the offset from the start of |base->buf| to the position of any - * pending length-prefix. */ - size_t offset; - /* child points to a child CBB if a length-prefix is pending. */ - struct cbb_st *child; - /* pending_len_len contains the number of bytes in a pending length-prefix, - * or zero if no length-prefix is pending. */ - uint8_t pending_len_len; - char pending_is_asn1; - /* is_top_level is true iff this is a top-level |CBB| (as opposed to a child - * |CBB|). Top-level objects are valid arguments for |CBB_finish|. */ - char is_top_level; -}; - -/* CBB_init initialises |cbb| with |initial_capacity|. Since a |CBB| grows as - * needed, the |initial_capacity| is just a hint. It returns one on success or - * zero on error. */ -OPENSSL_EXPORT int CBB_init(CBB *cbb, size_t initial_capacity); - -/* CBB_init_fixed initialises |cbb| to write to |len| bytes at |buf|. Since - * |buf| cannot grow, trying to write more than |len| bytes will cause CBB - * functions to fail. It returns one on success or zero on error. */ -OPENSSL_EXPORT int CBB_init_fixed(CBB *cbb, uint8_t *buf, size_t len); - -/* CBB_cleanup frees all resources owned by |cbb| and other |CBB| objects - * writing to the same buffer. This should be used in an error case where a - * serialisation is abandoned. */ -OPENSSL_EXPORT void CBB_cleanup(CBB *cbb); - -/* CBB_finish completes any pending length prefix and sets |*out_data| to a - * malloced buffer and |*out_len| to the length of that buffer. The caller - * takes ownership of the buffer and, unless the buffer was fixed with - * |CBB_init_fixed|, must call |OPENSSL_free| when done. - * - * It can only be called on a "top level" |CBB|, i.e. one initialised with - * |CBB_init| or |CBB_init_fixed|. It returns one on success and zero on - * error. */ -OPENSSL_EXPORT int CBB_finish(CBB *cbb, uint8_t **out_data, size_t *out_len); - -/* CBB_flush causes any pending length prefixes to be written out and any child - * |CBB| objects of |cbb| to be invalidated. It returns one on success or zero - * on error. */ -OPENSSL_EXPORT int CBB_flush(CBB *cbb); - -/* CBB_add_u8_length_prefixed sets |*out_contents| to a new child of |cbb|. The - * data written to |*out_contents| will be prefixed in |cbb| with an 8-bit - * length. It returns one on success or zero on error. */ -OPENSSL_EXPORT int CBB_add_u8_length_prefixed(CBB *cbb, CBB *out_contents); - -/* CBB_add_u16_length_prefixed sets |*out_contents| to a new child of |cbb|. - * The data written to |*out_contents| will be prefixed in |cbb| with a 16-bit, - * big-endian length. It returns one on success or zero on error. */ -OPENSSL_EXPORT int CBB_add_u16_length_prefixed(CBB *cbb, CBB *out_contents); - -/* CBB_add_u24_length_prefixed sets |*out_contents| to a new child of |cbb|. - * The data written to |*out_contents| will be prefixed in |cbb| with a 24-bit, - * big-endian length. It returns one on success or zero on error. */ -OPENSSL_EXPORT int CBB_add_u24_length_prefixed(CBB *cbb, CBB *out_contents); - -/* CBB_add_asn sets |*out_contents| to a |CBB| into which the contents of an - * ASN.1 object can be written. The |tag| argument will be used as the tag for - * the object. Passing in |tag| number 31 will return in an error since only - * single octet identifiers are supported. It returns one on success or zero - * on error. */ -OPENSSL_EXPORT int CBB_add_asn1(CBB *cbb, CBB *out_contents, uint8_t tag); - -/* CBB_add_bytes appends |len| bytes from |data| to |cbb|. It returns one on - * success and zero otherwise. */ -OPENSSL_EXPORT int CBB_add_bytes(CBB *cbb, const uint8_t *data, size_t len); - -/* CBB_add_space appends |len| bytes to |cbb| and sets |*out_data| to point to - * the beginning of that space. The caller must then write |len| bytes of - * actual contents to |*out_data|. It returns one on success and zero - * otherwise. */ -OPENSSL_EXPORT int CBB_add_space(CBB *cbb, uint8_t **out_data, size_t len); - -/* CBB_add_u8 appends an 8-bit number from |value| to |cbb|. It returns one on - * success and zero otherwise. */ -OPENSSL_EXPORT int CBB_add_u8(CBB *cbb, uint8_t value); - -/* CBB_add_u8 appends a 16-bit, big-endian number from |value| to |cbb|. It - * returns one on success and zero otherwise. */ -OPENSSL_EXPORT int CBB_add_u16(CBB *cbb, uint16_t value); - -/* CBB_add_u24 appends a 24-bit, big-endian number from |value| to |cbb|. It - * returns one on success and zero otherwise. */ -OPENSSL_EXPORT int CBB_add_u24(CBB *cbb, uint32_t value); - -/* CBB_add_asn1_uint64 writes an ASN.1 INTEGER into |cbb| using |CBB_add_asn1| - * and writes |value| in its contents. It returns one on success and zero on - * error. */ -OPENSSL_EXPORT int CBB_add_asn1_uint64(CBB *cbb, uint64_t value); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_BYTESTRING_H */ diff --git a/phonelibs/boringssl/include/openssl/cast.h b/phonelibs/boringssl/include/openssl/cast.h deleted file mode 100644 index 802172394e5b12..00000000000000 --- a/phonelibs/boringssl/include/openssl/cast.h +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_CAST_H -#define OPENSSL_HEADER_CAST_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -#define CAST_ENCRYPT 1 -#define CAST_DECRYPT 0 - -#define CAST_BLOCK 8 -#define CAST_KEY_LENGTH 16 - -typedef struct cast_key_st { - uint32_t data[32]; - int short_key; /* Use reduced rounds for short key */ -} CAST_KEY; - -OPENSSL_EXPORT void CAST_set_key(CAST_KEY *key, size_t len, - const uint8_t *data); -OPENSSL_EXPORT void CAST_ecb_encrypt(const uint8_t *in, uint8_t *out, - const CAST_KEY *key, int enc); -OPENSSL_EXPORT void CAST_encrypt(uint32_t *data, const CAST_KEY *key); -OPENSSL_EXPORT void CAST_decrypt(uint32_t *data, const CAST_KEY *key); -OPENSSL_EXPORT void CAST_cbc_encrypt(const uint8_t *in, uint8_t *out, - long length, const CAST_KEY *ks, - uint8_t *iv, int enc); - -OPENSSL_EXPORT void CAST_cfb64_encrypt(const uint8_t *in, uint8_t *out, - long length, const CAST_KEY *schedule, - uint8_t *ivec, int *num, int enc); - -#ifdef __cplusplus -} -#endif - -#endif /* OPENSSL_HEADER_CAST_H */ diff --git a/phonelibs/boringssl/include/openssl/chacha.h b/phonelibs/boringssl/include/openssl/chacha.h deleted file mode 100644 index ce53d49fdaefed..00000000000000 --- a/phonelibs/boringssl/include/openssl/chacha.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (c) 2014, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -#ifndef OPENSSL_HEADER_CHACHA_H -#define OPENSSL_HEADER_CHACHA_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/* CRYPTO_chacha_20 encrypts |in_len| bytes from |in| with the given key and - * nonce and writes the result to |out|, which may be equal to |in|. The - * initial block counter is specified by |counter|. */ -void CRYPTO_chacha_20(uint8_t *out, const uint8_t *in, - size_t in_len, const uint8_t key[32], - const uint8_t nonce[8], size_t counter); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_CHACHA_H */ diff --git a/phonelibs/boringssl/include/openssl/cipher.h b/phonelibs/boringssl/include/openssl/cipher.h deleted file mode 100644 index 3e496f15b50e9a..00000000000000 --- a/phonelibs/boringssl/include/openssl/cipher.h +++ /dev/null @@ -1,598 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_CIPHER_H -#define OPENSSL_HEADER_CIPHER_H - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* Ciphers. */ - - -/* Cipher primitives. - * - * The following functions return |EVP_CIPHER| objects that implement the named - * cipher algorithm. */ - -OPENSSL_EXPORT const EVP_CIPHER *EVP_rc4(void); - -OPENSSL_EXPORT const EVP_CIPHER *EVP_des_cbc(void); -OPENSSL_EXPORT const EVP_CIPHER *EVP_des_ecb(void); -OPENSSL_EXPORT const EVP_CIPHER *EVP_des_ede3_cbc(void); - -OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_128_ecb(void); -OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_128_cbc(void); -OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_128_ctr(void); -OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_128_ofb(void); - -OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_256_ecb(void); -OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_256_cbc(void); -OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_256_ctr(void); -OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_256_ofb(void); - -/* Deprecated AES-GCM implementations that set |EVP_CIPH_FLAG_CUSTOM_CIPHER|. - * Use |EVP_aead_aes_128_gcm| and |EVP_aead_aes_256_gcm| instead. */ -OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_128_gcm(void); -OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_256_gcm(void); - -/* Deprecated 192-bit version of AES. */ -OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_192_ecb(void); -OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_192_cbc(void); -OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_192_ctr(void); -OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_192_gcm(void); - -/* EVP_enc_null returns a 'cipher' that passes plaintext through as - * ciphertext. */ -OPENSSL_EXPORT const EVP_CIPHER *EVP_enc_null(void); - -/* EVP_rc2_40_cbc returns a cipher that implements 40-bit RC2 in CBC mode. This - * is obviously very, very weak and is included only in order to read PKCS#12 - * files, which often encrypt the certificate chain using this cipher. It is - * deliberately not exported. */ -const EVP_CIPHER *EVP_rc2_40_cbc(void); - -/* EVP_get_cipherbynid returns the cipher corresponding to the given NID, or - * NULL if no such cipher is known. */ -OPENSSL_EXPORT const EVP_CIPHER *EVP_get_cipherbynid(int nid); - - -/* Cipher context allocation. - * - * An |EVP_CIPHER_CTX| represents the state of an encryption or decryption in - * progress. */ - -/* EVP_CIPHER_CTX_init initialises an, already allocated, |EVP_CIPHER_CTX|. */ -OPENSSL_EXPORT void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx); - -/* EVP_CIPHER_CTX_new allocates a fresh |EVP_CIPHER_CTX|, calls - * |EVP_CIPHER_CTX_init| and returns it, or NULL on allocation failure. */ -OPENSSL_EXPORT EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void); - -/* EVP_CIPHER_CTX_cleanup frees any memory referenced by |ctx|. It returns - * one. */ -OPENSSL_EXPORT int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *ctx); - -/* EVP_CIPHER_CTX_free calls |EVP_CIPHER_CTX_cleanup| on |ctx| and then frees - * |ctx| itself. */ -OPENSSL_EXPORT void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx); - -/* EVP_CIPHER_CTX_copy sets |out| to be a duplicate of the current state of - * |in|. The |out| argument must have been previously initialised. */ -OPENSSL_EXPORT int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, - const EVP_CIPHER_CTX *in); - - -/* Cipher context configuration. */ - -/* EVP_CipherInit_ex configures |ctx| for a fresh encryption (or decryption, if - * |enc| is zero) operation using |cipher|. If |ctx| has been previously - * configured with a cipher then |cipher|, |key| and |iv| may be |NULL| and - * |enc| may be -1 to reuse the previous values. The operation will use |key| - * as the key and |iv| as the IV (if any). These should have the correct - * lengths given by |EVP_CIPHER_key_length| and |EVP_CIPHER_iv_length|. It - * returns one on success and zero on error. */ -OPENSSL_EXPORT int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, - const EVP_CIPHER *cipher, ENGINE *engine, - const uint8_t *key, const uint8_t *iv, - int enc); - -/* EVP_EncryptInit_ex calls |EVP_CipherInit_ex| with |enc| equal to one. */ -OPENSSL_EXPORT int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, - const EVP_CIPHER *cipher, ENGINE *impl, - const uint8_t *key, const uint8_t *iv); - -/* EVP_DecryptInit_ex calls |EVP_CipherInit_ex| with |enc| equal to zero. */ -OPENSSL_EXPORT int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, - const EVP_CIPHER *cipher, ENGINE *impl, - const uint8_t *key, const uint8_t *iv); - - -/* Cipher operations. */ - -/* EVP_EncryptUpdate encrypts |in_len| bytes from |in| to |out|. The number - * of output bytes may be up to |in_len| plus the block length minus one and - * |out| must have sufficient space. The number of bytes actually output is - * written to |*out_len|. It returns one on success and zero otherwise. */ -OPENSSL_EXPORT int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out, - int *out_len, const uint8_t *in, - int in_len); - -/* EVP_EncryptFinal_ex writes at most a block of ciphertext to |out| and sets - * |*out_len| to the number of bytes written. If padding is enabled (the - * default) then standard padding is applied to create the final block. If - * padding is disabled (with |EVP_CIPHER_CTX_set_padding|) then any partial - * block remaining will cause an error. The function returns one on success and - * zero otherwise. */ -OPENSSL_EXPORT int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, uint8_t *out, - int *out_len); - -/* EVP_DecryptUpdate decrypts |in_len| bytes from |in| to |out|. The number of - * output bytes may be up to |in_len| plus the block length minus one and |out| - * must have sufficient space. The number of bytes actually output is written - * to |*out_len|. It returns one on success and zero otherwise. */ -OPENSSL_EXPORT int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out, - int *out_len, const uint8_t *in, - int in_len); - -/* EVP_DecryptFinal_ex writes at most a block of ciphertext to |out| and sets - * |*out_len| to the number of bytes written. If padding is enabled (the - * default) then padding is removed from the final block. - * - * WARNING: it is unsafe to call this function with unauthenticted - * ciphertext if padding is enabled. */ -OPENSSL_EXPORT int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, - int *out_len); - -/* EVP_Cipher performs a one-shot encryption/decryption operation. No partial - * blocks are maintained between calls. However, any internal cipher state is - * still updated. For CBC-mode ciphers, the IV is updated to the final - * ciphertext block. For stream ciphers, the stream is advanced past the bytes - * used. It returns one on success and zero otherwise, unless |EVP_CIPHER_flags| - * has |EVP_CIPH_FLAG_CUSTOM_CIPHER| set. Then it returns the number of bytes - * written or -1 on error. - * - * WARNING: this differs from the usual return value convention when using - * |EVP_CIPH_FLAG_CUSTOM_CIPHER|. - * - * TODO(davidben): The normal ciphers currently never fail, even if, e.g., - * |in_len| is not a multiple of the block size for CBC-mode decryption. The - * input just gets rounded up while the output gets truncated. This should - * either be officially documented or fail. */ -OPENSSL_EXPORT int EVP_Cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, - const uint8_t *in, size_t in_len); - -/* EVP_CipherUpdate calls either |EVP_EncryptUpdate| or |EVP_DecryptUpdate| - * depending on how |ctx| has been setup. */ -OPENSSL_EXPORT int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out, - int *out_len, const uint8_t *in, - int in_len); - -/* EVP_CipherFinal_ex calls either |EVP_EncryptFinal_ex| or - * |EVP_DecryptFinal_ex| depending on how |ctx| has been setup. */ -OPENSSL_EXPORT int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, uint8_t *out, - int *out_len); - - -/* Cipher context accessors. */ - -/* EVP_CIPHER_CTX_cipher returns the |EVP_CIPHER| underlying |ctx|, or NULL if - * none has been set. */ -OPENSSL_EXPORT const EVP_CIPHER *EVP_CIPHER_CTX_cipher( - const EVP_CIPHER_CTX *ctx); - -/* EVP_CIPHER_CTX_nid returns a NID identifying the |EVP_CIPHER| underlying - * |ctx| (e.g. |NID_aes_128_gcm|). It will crash if no cipher has been - * configured. */ -OPENSSL_EXPORT int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx); - -/* EVP_CIPHER_CTX_block_size returns the block size, in bytes, of the cipher - * underlying |ctx|, or one if the cipher is a stream cipher. It will crash if - * no cipher has been configured. */ -OPENSSL_EXPORT unsigned EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx); - -/* EVP_CIPHER_CTX_key_length returns the key size, in bytes, of the cipher - * underlying |ctx| or zero if no cipher has been configured. */ -OPENSSL_EXPORT unsigned EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx); - -/* EVP_CIPHER_CTX_iv_length returns the IV size, in bytes, of the cipher - * underlying |ctx|. It will crash if no cipher has been configured. */ -OPENSSL_EXPORT unsigned EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx); - -/* EVP_CIPHER_CTX_get_app_data returns the opaque, application data pointer for - * |ctx|, or NULL if none has been set. */ -OPENSSL_EXPORT void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx); - -/* EVP_CIPHER_CTX_set_app_data sets the opaque, application data pointer for - * |ctx| to |data|. */ -OPENSSL_EXPORT void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, - void *data); - -/* EVP_CIPHER_CTX_flags returns a value which is the OR of zero or more - * |EVP_CIPH_*| flags. It will crash if no cipher has been configured. */ -OPENSSL_EXPORT uint32_t EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx); - -/* EVP_CIPHER_CTX_mode returns one of the |EVP_CIPH_*| cipher mode values - * enumerated below. It will crash if no cipher has been configured. */ -OPENSSL_EXPORT uint32_t EVP_CIPHER_CTX_mode(const EVP_CIPHER_CTX *ctx); - -/* EVP_CIPHER_CTX_ctrl is an |ioctl| like function. The |command| argument - * should be one of the |EVP_CTRL_*| values. The |arg| and |ptr| arguments are - * specific to the command in question. */ -OPENSSL_EXPORT int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int command, - int arg, void *ptr); - -/* EVP_CIPHER_CTX_set_padding sets whether padding is enabled for |ctx| and - * returns one. Pass a non-zero |pad| to enable padding (the default) or zero - * to disable. */ -OPENSSL_EXPORT int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *ctx, int pad); - -/* EVP_CIPHER_CTX_set_key_length sets the key length for |ctx|. This is only - * valid for ciphers that can take a variable length key. It returns one on - * success and zero on error. */ -OPENSSL_EXPORT int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *ctx, unsigned key_len); - - -/* Cipher accessors. */ - -/* EVP_CIPHER_nid returns a NID identifing |cipher|. (For example, - * |NID_aes_128_gcm|.) */ -OPENSSL_EXPORT int EVP_CIPHER_nid(const EVP_CIPHER *cipher); - -/* EVP_CIPHER_block_size returns the block size, in bytes, for |cipher|, or one - * if |cipher| is a stream cipher. */ -OPENSSL_EXPORT unsigned EVP_CIPHER_block_size(const EVP_CIPHER *cipher); - -/* EVP_CIPHER_key_length returns the key size, in bytes, for |cipher|. If - * |cipher| can take a variable key length then this function returns the - * default key length and |EVP_CIPHER_flags| will return a value with - * |EVP_CIPH_VARIABLE_LENGTH| set. */ -OPENSSL_EXPORT unsigned EVP_CIPHER_key_length(const EVP_CIPHER *cipher); - -/* EVP_CIPHER_iv_length returns the IV size, in bytes, of |cipher|, or zero if - * |cipher| doesn't take an IV. */ -OPENSSL_EXPORT unsigned EVP_CIPHER_iv_length(const EVP_CIPHER *cipher); - -/* EVP_CIPHER_flags returns a value which is the OR of zero or more - * |EVP_CIPH_*| flags. */ -OPENSSL_EXPORT uint32_t EVP_CIPHER_flags(const EVP_CIPHER *cipher); - -/* EVP_CIPHER_mode returns one of the cipher mode values enumerated below. */ -OPENSSL_EXPORT uint32_t EVP_CIPHER_mode(const EVP_CIPHER *cipher); - - -/* Key derivation. */ - -/* EVP_BytesToKey generates a key and IV for the cipher |type| by iterating - * |md| |count| times using |data| and |salt|. On entry, the |key| and |iv| - * buffers must have enough space to hold a key and IV for |type|. It returns - * the length of the key on success or zero on error. */ -OPENSSL_EXPORT int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, - const uint8_t *salt, const uint8_t *data, - size_t data_len, unsigned count, uint8_t *key, - uint8_t *iv); - - -/* Cipher modes (for |EVP_CIPHER_mode|). */ - -#define EVP_CIPH_STREAM_CIPHER 0x0 -#define EVP_CIPH_ECB_MODE 0x1 -#define EVP_CIPH_CBC_MODE 0x2 -#define EVP_CIPH_CFB_MODE 0x3 -#define EVP_CIPH_OFB_MODE 0x4 -#define EVP_CIPH_CTR_MODE 0x5 -#define EVP_CIPH_GCM_MODE 0x6 - - -/* Cipher flags (for |EVP_CIPHER_flags|). */ - -/* EVP_CIPH_VARIABLE_LENGTH indicates that the cipher takes a variable length - * key. */ -#define EVP_CIPH_VARIABLE_LENGTH 0x40 - -/* EVP_CIPH_ALWAYS_CALL_INIT indicates that the |init| function for the cipher - * should always be called when initialising a new operation, even if the key - * is NULL to indicate that the same key is being used. */ -#define EVP_CIPH_ALWAYS_CALL_INIT 0x80 - -/* EVP_CIPH_CUSTOM_IV indicates that the cipher manages the IV itself rather - * than keeping it in the |iv| member of |EVP_CIPHER_CTX|. */ -#define EVP_CIPH_CUSTOM_IV 0x100 - -/* EVP_CIPH_CTRL_INIT indicates that EVP_CTRL_INIT should be used when - * initialising an |EVP_CIPHER_CTX|. */ -#define EVP_CIPH_CTRL_INIT 0x200 - -/* EVP_CIPH_FLAG_CUSTOM_CIPHER indicates that the cipher manages blocking - * itself. This causes EVP_(En|De)crypt_ex to be simple wrapper functions. */ -#define EVP_CIPH_FLAG_CUSTOM_CIPHER 0x400 - -/* EVP_CIPH_FLAG_AEAD_CIPHER specifies that the cipher is an AEAD. This is an - * older version of the proper AEAD interface. See aead.h for the current - * one. */ -#define EVP_CIPH_FLAG_AEAD_CIPHER 0x800 - -/* EVP_CIPH_CUSTOM_COPY indicates that the |ctrl| callback should be called - * with |EVP_CTRL_COPY| at the end of normal |EVP_CIPHER_CTX_copy| - * processing. */ -#define EVP_CIPH_CUSTOM_COPY 0x1000 - - -/* Deprecated functions */ - -/* EVP_CipherInit acts like EVP_CipherInit_ex except that |EVP_CIPHER_CTX_init| - * is called on |cipher| first, if |cipher| is not NULL. */ -OPENSSL_EXPORT int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - const uint8_t *key, const uint8_t *iv, - int enc); - -/* EVP_EncryptInit calls |EVP_CipherInit| with |enc| equal to one. */ -OPENSSL_EXPORT int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, - const EVP_CIPHER *cipher, const uint8_t *key, - const uint8_t *iv); - -/* EVP_DecryptInit calls |EVP_CipherInit| with |enc| equal to zero. */ -OPENSSL_EXPORT int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, - const EVP_CIPHER *cipher, const uint8_t *key, - const uint8_t *iv); - -/* EVP_add_cipher_alias does nothing and returns one. */ -OPENSSL_EXPORT int EVP_add_cipher_alias(const char *a, const char *b); - -/* EVP_get_cipherbyname returns an |EVP_CIPHER| given a human readable name in - * |name|, or NULL if the name is unknown. */ -OPENSSL_EXPORT const EVP_CIPHER *EVP_get_cipherbyname(const char *name); - - -/* Private functions. */ - -/* EVP_CIPH_NO_PADDING disables padding in block ciphers. */ -#define EVP_CIPH_NO_PADDING 0x800 - -/* EVP_CIPHER_CTX_ctrl commands. */ -#define EVP_CTRL_INIT 0x0 -#define EVP_CTRL_SET_KEY_LENGTH 0x1 -#define EVP_CTRL_GET_RC2_KEY_BITS 0x2 -#define EVP_CTRL_SET_RC2_KEY_BITS 0x3 -#define EVP_CTRL_GET_RC5_ROUNDS 0x4 -#define EVP_CTRL_SET_RC5_ROUNDS 0x5 -#define EVP_CTRL_RAND_KEY 0x6 -#define EVP_CTRL_PBE_PRF_NID 0x7 -#define EVP_CTRL_COPY 0x8 -#define EVP_CTRL_GCM_SET_IVLEN 0x9 -#define EVP_CTRL_GCM_GET_TAG 0x10 -#define EVP_CTRL_GCM_SET_TAG 0x11 -#define EVP_CTRL_GCM_SET_IV_FIXED 0x12 -#define EVP_CTRL_GCM_IV_GEN 0x13 -#define EVP_CTRL_AEAD_SET_MAC_KEY 0x17 -/* Set the GCM invocation field, decrypt only */ -#define EVP_CTRL_GCM_SET_IV_INV 0x18 - -/* GCM TLS constants */ -/* Length of fixed part of IV derived from PRF */ -#define EVP_GCM_TLS_FIXED_IV_LEN 4 -/* Length of explicit part of IV part of TLS records */ -#define EVP_GCM_TLS_EXPLICIT_IV_LEN 8 -/* Length of tag for TLS */ -#define EVP_GCM_TLS_TAG_LEN 16 - -#define EVP_MAX_KEY_LENGTH 64 -#define EVP_MAX_IV_LENGTH 16 -#define EVP_MAX_BLOCK_LENGTH 32 - -struct evp_cipher_ctx_st { - /* cipher contains the underlying cipher for this context. */ - const EVP_CIPHER *cipher; - - /* app_data is a pointer to opaque, user data. */ - void *app_data; /* application stuff */ - - /* cipher_data points to the |cipher| specific state. */ - void *cipher_data; - - /* key_len contains the length of the key, which may differ from - * |cipher->key_len| if the cipher can take a variable key length. */ - unsigned key_len; - - /* encrypt is one if encrypting and zero if decrypting. */ - int encrypt; - - /* flags contains the OR of zero or more |EVP_CIPH_*| flags, above. */ - uint32_t flags; - - /* oiv contains the original IV value. */ - uint8_t oiv[EVP_MAX_IV_LENGTH]; - - /* iv contains the current IV value, which may have been updated. */ - uint8_t iv[EVP_MAX_IV_LENGTH]; - - /* buf contains a partial block which is used by, for example, CTR mode to - * store unused keystream bytes. */ - uint8_t buf[EVP_MAX_BLOCK_LENGTH]; - - /* buf_len contains the number of bytes of a partial block contained in - * |buf|. */ - int buf_len; - - /* num contains the number of bytes of |iv| which are valid for modes that - * manage partial blocks themselves. */ - int num; - - /* final_used is non-zero if the |final| buffer contains plaintext. */ - int final_used; - - /* block_mask contains |cipher->block_size| minus one. (The block size - * assumed to be a power of two.) */ - int block_mask; - - uint8_t final[EVP_MAX_BLOCK_LENGTH]; /* possible final block */ -} /* EVP_CIPHER_CTX */; - -typedef struct evp_cipher_info_st { - const EVP_CIPHER *cipher; - unsigned char iv[EVP_MAX_IV_LENGTH]; -} EVP_CIPHER_INFO; - -struct evp_cipher_st { - /* type contains a NID identifing the cipher. (e.g. NID_aes_128_gcm.) */ - int nid; - - /* block_size contains the block size, in bytes, of the cipher, or 1 for a - * stream cipher. */ - unsigned block_size; - - /* key_len contains the key size, in bytes, for the cipher. If the cipher - * takes a variable key size then this contains the default size. */ - unsigned key_len; - - /* iv_len contains the IV size, in bytes, or zero if inapplicable. */ - unsigned iv_len; - - /* ctx_size contains the size, in bytes, of the per-key context for this - * cipher. */ - unsigned ctx_size; - - /* flags contains the OR of a number of flags. See |EVP_CIPH_*|. */ - uint32_t flags; - - /* app_data is a pointer to opaque, user data. */ - void *app_data; - - int (*init)(EVP_CIPHER_CTX *ctx, const uint8_t *key, const uint8_t *iv, - int enc); - - int (*cipher)(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in, - size_t inl); - - /* cleanup, if non-NULL, releases memory associated with the context. It is - * called if |EVP_CTRL_INIT| succeeds. Note that |init| may not have been - * called at this point. */ - void (*cleanup)(EVP_CIPHER_CTX *); - - int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr); -}; - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#define CIPHER_F_EVP_AEAD_CTX_init 100 -#define CIPHER_F_EVP_AEAD_CTX_open 101 -#define CIPHER_F_EVP_AEAD_CTX_seal 102 -#define CIPHER_F_EVP_CIPHER_CTX_copy 103 -#define CIPHER_F_EVP_CIPHER_CTX_ctrl 104 -#define CIPHER_F_EVP_CIPHER_CTX_set_key_length 105 -#define CIPHER_F_EVP_CipherInit_ex 106 -#define CIPHER_F_EVP_DecryptFinal_ex 107 -#define CIPHER_F_EVP_EncryptFinal_ex 108 -#define CIPHER_F_aead_aes_gcm_init 109 -#define CIPHER_F_aead_aes_gcm_open 110 -#define CIPHER_F_aead_aes_gcm_seal 111 -#define CIPHER_F_aead_aes_key_wrap_init 112 -#define CIPHER_F_aead_aes_key_wrap_open 113 -#define CIPHER_F_aead_aes_key_wrap_seal 114 -#define CIPHER_F_aead_chacha20_poly1305_init 115 -#define CIPHER_F_aead_chacha20_poly1305_open 116 -#define CIPHER_F_aead_chacha20_poly1305_seal 117 -#define CIPHER_F_aead_rc4_md5_tls_init 118 -#define CIPHER_F_aead_rc4_md5_tls_open 119 -#define CIPHER_F_aead_rc4_md5_tls_seal 120 -#define CIPHER_F_aead_ssl3_ensure_cipher_init 121 -#define CIPHER_F_aead_ssl3_init 122 -#define CIPHER_F_aead_ssl3_open 123 -#define CIPHER_F_aead_ssl3_seal 124 -#define CIPHER_F_aead_tls_ensure_cipher_init 125 -#define CIPHER_F_aead_tls_init 126 -#define CIPHER_F_aead_tls_open 127 -#define CIPHER_F_aead_tls_seal 128 -#define CIPHER_F_aes_init_key 129 -#define CIPHER_F_aesni_init_key 130 -#define CIPHER_F_EVP_AEAD_CTX_init_with_direction 131 -#define CIPHER_F_aead_aes_ctr_hmac_sha256_init 132 -#define CIPHER_F_aead_aes_ctr_hmac_sha256_open 133 -#define CIPHER_F_aead_aes_ctr_hmac_sha256_seal 134 -#define CIPHER_R_AES_KEY_SETUP_FAILED 100 -#define CIPHER_R_BAD_DECRYPT 101 -#define CIPHER_R_BAD_KEY_LENGTH 102 -#define CIPHER_R_BUFFER_TOO_SMALL 103 -#define CIPHER_R_CTRL_NOT_IMPLEMENTED 104 -#define CIPHER_R_CTRL_OPERATION_NOT_IMPLEMENTED 105 -#define CIPHER_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 106 -#define CIPHER_R_INITIALIZATION_ERROR 107 -#define CIPHER_R_INPUT_NOT_INITIALIZED 108 -#define CIPHER_R_INVALID_AD_SIZE 109 -#define CIPHER_R_INVALID_KEY_LENGTH 110 -#define CIPHER_R_INVALID_NONCE_SIZE 111 -#define CIPHER_R_INVALID_OPERATION 112 -#define CIPHER_R_IV_TOO_LARGE 113 -#define CIPHER_R_NO_CIPHER_SET 114 -#define CIPHER_R_OUTPUT_ALIASES_INPUT 115 -#define CIPHER_R_TAG_TOO_LARGE 116 -#define CIPHER_R_TOO_LARGE 117 -#define CIPHER_R_UNSUPPORTED_AD_SIZE 118 -#define CIPHER_R_UNSUPPORTED_INPUT_SIZE 119 -#define CIPHER_R_UNSUPPORTED_KEY_SIZE 120 -#define CIPHER_R_UNSUPPORTED_NONCE_SIZE 121 -#define CIPHER_R_UNSUPPORTED_TAG_SIZE 122 -#define CIPHER_R_WRONG_FINAL_BLOCK_LENGTH 123 -#define CIPHER_R_NO_DIRECTION_SET 124 - -#endif /* OPENSSL_HEADER_CIPHER_H */ diff --git a/phonelibs/boringssl/include/openssl/cmac.h b/phonelibs/boringssl/include/openssl/cmac.h deleted file mode 100644 index 183f41bca05630..00000000000000 --- a/phonelibs/boringssl/include/openssl/cmac.h +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (c) 2015, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -#ifndef OPENSSL_HEADER_CMAC_H -#define OPENSSL_HEADER_CMAC_H - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* CMAC. - * - * CMAC is a MAC based on AES-CBC and defined in - * https://tools.ietf.org/html/rfc4493#section-2.3. */ - - -/* One-shot functions. */ - -/* AES_CMAC calculates the 16-byte, CMAC authenticator of |in_len| bytes of - * |in| and writes it to |out|. The |key_len| may be 16 or 32 bytes to select - * between AES-128 and AES-256. It returns one on success or zero on error. */ -OPENSSL_EXPORT int AES_CMAC(uint8_t out[16], const uint8_t *key, size_t key_len, - const uint8_t *in, size_t in_len); - - -/* Incremental interface. */ - -/* CMAC_CTX_new allocates a fresh |CMAC_CTX| and returns it, or NULL on - * error. */ -OPENSSL_EXPORT CMAC_CTX *CMAC_CTX_new(void); - -/* CMAC_CTX_free frees a |CMAC_CTX|. */ -OPENSSL_EXPORT void CMAC_CTX_free(CMAC_CTX *ctx); - -/* CMAC_Init configures |ctx| to use the given |key| and |cipher|. The CMAC RFC - * only specifies the use of AES-128 thus |key_len| should be 16 and |cipher| - * should be |EVP_aes_128_cbc()|. However, this implementation also supports - * AES-256 by setting |key_len| to 32 and |cipher| to |EVP_aes_256_cbc()|. The - * |engine| argument is ignored. - * - * It returns one on success or zero on error. */ -OPENSSL_EXPORT int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t key_len, - const EVP_CIPHER *cipher, ENGINE *engine); - - -/* CMAC_Reset resets |ctx| so that a fresh message can be authenticated. */ -OPENSSL_EXPORT int CMAC_Reset(CMAC_CTX *ctx); - -/* CMAC_Update processes |in_len| bytes of message from |in|. It returns one on - * success or zero on error. */ -OPENSSL_EXPORT int CMAC_Update(CMAC_CTX *ctx, const uint8_t *in, size_t in_len); - -/* CMAC_Final sets |*out_len| to 16 and, if |out| is not NULL, writes 16 bytes - * of authenticator to it. It returns one on success or zero on error. */ -OPENSSL_EXPORT int CMAC_Final(CMAC_CTX *ctx, uint8_t *out, size_t *out_len); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_CBC_H */ diff --git a/phonelibs/boringssl/include/openssl/conf.h b/phonelibs/boringssl/include/openssl/conf.h deleted file mode 100644 index 84fc94f99e5b63..00000000000000 --- a/phonelibs/boringssl/include/openssl/conf.h +++ /dev/null @@ -1,149 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_CONF_H -#define OPENSSL_HEADER_CONF_H - -#include - -#include -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* Config files look like: - * - * # Comment - * - * # This key is in the default section. - * key=value - * - * [section_name] - * key2=value2 - * - * Config files are representated by a |CONF|. */ - -struct conf_value_st { - char *section; - char *name; - char *value; -}; - -struct conf_st { - LHASH_OF(CONF_VALUE) *data; -}; - - -/* NCONF_new returns a fresh, empty |CONF|, or NULL on error. The |method| - * argument must be NULL. */ -CONF *NCONF_new(void *method); - -/* NCONF_free frees all the data owned by |conf| and then |conf| itself. */ -void NCONF_free(CONF *conf); - -/* NCONF_load parses the file named |filename| and adds the values found to - * |conf|. It returns one on success and zero on error. In the event of an - * error, if |out_error_line| is not NULL, |*out_error_line| is set to the - * number of the line that contained the error. */ -int NCONF_load(CONF *conf, const char *filename, long *out_error_line); - -/* NCONF_load_bio acts like |NCONF_load| but reads from |bio| rather than from - * a named file. */ -int NCONF_load_bio(CONF *conf, BIO *bio, long *out_error_line); - -/* NCONF_get_section returns a stack of values for a given section in |conf|. - * If |section| is NULL, the default section is returned. It returns NULL on - * error. */ -STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf, const char *section); - -/* NCONF_get_string returns the value of the key |name|, in section |section|. - * The |section| argument may be NULL to indicate the default section. It - * returns the value or NULL on error. */ -const char *NCONF_get_string(const CONF *conf, const char *section, - const char *name); - - -/* Utility functions */ - -/* CONF_parse_list takes a list separated by 'sep' and calls |list_cb| giving - * the start and length of each member, optionally stripping leading and - * trailing whitespace. This can be used to parse comma separated lists for - * example. If |list_cb| returns <= 0, then the iteration is halted and that - * value is returned immediately. Otherwise it returns one. Note that |list_cb| - * may be called on an empty member. */ -int CONF_parse_list(const char *list, char sep, int remove_whitespace, - int (*list_cb)(const char *elem, int len, void *usr), - void *arg); - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#define CONF_F_CONF_parse_list 100 -#define CONF_F_NCONF_load 101 -#define CONF_F_def_load_bio 102 -#define CONF_F_str_copy 103 -#define CONF_R_LIST_CANNOT_BE_NULL 100 -#define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 101 -#define CONF_R_MISSING_EQUAL_SIGN 102 -#define CONF_R_NO_CLOSE_BRACE 103 -#define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 104 -#define CONF_R_VARIABLE_HAS_NO_VALUE 105 - -#endif /* OPENSSL_HEADER_THREAD_H */ diff --git a/phonelibs/boringssl/include/openssl/cpu.h b/phonelibs/boringssl/include/openssl/cpu.h deleted file mode 100644 index 83ec473fabcb8f..00000000000000 --- a/phonelibs/boringssl/include/openssl/cpu.h +++ /dev/null @@ -1,121 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). */ - -#ifndef OPENSSL_HEADER_CPU_H -#define OPENSSL_HEADER_CPU_H - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* Runtime CPU feature support */ - - -#if defined(OPENSSL_X86) || defined(OPENSSL_X86_64) -/* OPENSSL_ia32cap_P contains the Intel CPUID bits when running on an x86 or - * x86-64 system. - * - * Index 0: - * EDX for CPUID where EAX = 1 - * Bit 30 is used to indicate an Intel CPU - * Index 1: - * ECX for CPUID where EAX = 1 - * Index 2: - * EBX for CPUID where EAX = 7 - * - * Note: the CPUID bits are pre-adjusted for the OSXSAVE bit and the YMM and XMM - * bits in XCR0, so it is not necessary to check those. */ -extern uint32_t OPENSSL_ia32cap_P[4]; -#endif - -#if defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64) -/* CRYPTO_is_NEON_capable returns true if the current CPU has a NEON unit. Note - * that |OPENSSL_armcap_P| also exists and contains the same information in a - * form that's easier for assembly to use. */ -OPENSSL_EXPORT char CRYPTO_is_NEON_capable(void); - -/* CRYPTO_set_NEON_capable sets the return value of |CRYPTO_is_NEON_capable|. - * By default, unless the code was compiled with |-mfpu=neon|, NEON is assumed - * not to be present. It is not autodetected. Calling this with a zero - * argument also causes |CRYPTO_is_NEON_functional| to return false. */ -OPENSSL_EXPORT void CRYPTO_set_NEON_capable(char neon_capable); - -/* CRYPTO_is_NEON_functional returns true if the current CPU has a /working/ - * NEON unit. Some phones have a NEON unit, but the Poly1305 NEON code causes - * it to fail. See https://code.google.com/p/chromium/issues/detail?id=341598 */ -OPENSSL_EXPORT char CRYPTO_is_NEON_functional(void); - -/* CRYPTO_set_NEON_functional sets the "NEON functional" flag. For - * |CRYPTO_is_NEON_functional| to return true, both this flag and the NEON flag - * must be true. By default NEON is assumed to be functional if the code was - * compiled with |-mfpu=neon| or if |CRYPTO_set_NEON_capable| has been called - * with a non-zero argument. */ -OPENSSL_EXPORT void CRYPTO_set_NEON_functional(char neon_functional); -#endif /* OPENSSL_ARM */ - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_CPU_H */ diff --git a/phonelibs/boringssl/include/openssl/crypto.h b/phonelibs/boringssl/include/openssl/crypto.h deleted file mode 100644 index 3af1547d87ebbc..00000000000000 --- a/phonelibs/boringssl/include/openssl/crypto.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (c) 2014, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -#ifndef OPENSSL_HEADER_CRYPTO_H -#define OPENSSL_HEADER_CRYPTO_H - -#include - -/* Upstream OpenSSL defines |OPENSSL_malloc|, etc., in crypto.h rather than - * mem.h. */ -#include - - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* crypto.h contains functions for initializing the crypto library. */ - - -/* CRYPTO_library_init initializes the crypto library. It must be called if the - * library is built with BORINGSSL_NO_STATIC_INITIALIZER. Otherwise, it does - * nothing and a static initializer is used instead. */ -OPENSSL_EXPORT void CRYPTO_library_init(void); - - -/* Deprecated functions. */ - -#define OPENSSL_VERSION_TEXT "BoringSSL" - -#define SSLEAY_VERSION 0 - -/* SSLeay_version is a compatibility function that returns the string - * "BoringSSL". */ -OPENSSL_EXPORT const char *SSLeay_version(int unused); - -/* SSLeay is a compatibility function that returns OPENSSL_VERSION_NUMBER from - * base.h. */ -OPENSSL_EXPORT unsigned long SSLeay(void); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#define CRYPTO_F_CRYPTO_get_ex_new_index 100 -#define CRYPTO_F_CRYPTO_set_ex_data 101 -#define CRYPTO_F_get_class 102 -#define CRYPTO_F_get_func_pointers 103 - -#endif /* OPENSSL_HEADER_CRYPTO_H */ diff --git a/phonelibs/boringssl/include/openssl/des.h b/phonelibs/boringssl/include/openssl/des.h deleted file mode 100644 index 6e1b0cfe5f76da..00000000000000 --- a/phonelibs/boringssl/include/openssl/des.h +++ /dev/null @@ -1,149 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_DES_H -#define OPENSSL_HEADER_DES_H - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* DES. */ - - -typedef struct DES_cblock_st { - uint8_t bytes[8]; -} DES_cblock; - -typedef struct DES_ks { - union { - DES_cblock cblock; - /* make sure things are correct size on machines with - * 8 byte longs */ - uint32_t deslong[2]; - } ks[16]; -} DES_key_schedule; - - -#define DES_KEY_SZ (sizeof(DES_cblock)) -#define DES_SCHEDULE_SZ (sizeof(DES_key_schedule)) - -#define DES_ENCRYPT 1 -#define DES_DECRYPT 0 - -#define DES_CBC_MODE 0 -#define DES_PCBC_MODE 1 - -/* DES_set_key performs a key schedule and initialises |schedule| with |key|. */ -OPENSSL_EXPORT void DES_set_key(const DES_cblock *key, - DES_key_schedule *schedule); - -/* DES_set_odd_parity sets the parity bits (the least-significant bits in each - * byte) of |key| given the other bits in each byte. */ -OPENSSL_EXPORT void DES_set_odd_parity(DES_cblock *key); - -/* DES_ecb_encrypt encrypts (or decrypts, if |is_encrypt| is |DES_DECRYPT|) a - * single DES block (8 bytes) from in to out, using the key configured in - * |schedule|. */ -OPENSSL_EXPORT void DES_ecb_encrypt(const DES_cblock *in, DES_cblock *out, - const DES_key_schedule *schedule, - int is_encrypt); - -/* DES_ncbc_encrypt encrypts (or decrypts, if |enc| is |DES_DECRYPT|) |len| - * bytes from |in| to |out| with DES in CBC mode. */ -OPENSSL_EXPORT void DES_ncbc_encrypt(const uint8_t *in, uint8_t *out, - size_t len, - const DES_key_schedule *schedule, - DES_cblock *ivec, int enc); - -/* DES_ecb3_encrypt encrypts (or decrypts, if |enc| is |DES_DECRYPT|) a single - * block (8 bytes) of data from |input| to |output| using 3DES. */ -OPENSSL_EXPORT void DES_ecb3_encrypt(const DES_cblock *input, - DES_cblock *output, - const DES_key_schedule *ks1, - const DES_key_schedule *ks2, - const DES_key_schedule *ks3, - int enc); - -/* DES_ede3_cbc_encrypt encrypts (or decrypts, if |enc| is |DES_DECRYPT|) |len| - * bytes from |in| to |out| with 3DES in CBC mode. 3DES uses three keys, thus - * the function takes three different |DES_key_schedule|s. */ -OPENSSL_EXPORT void DES_ede3_cbc_encrypt(const uint8_t *in, uint8_t *out, - size_t len, - const DES_key_schedule *ks1, - const DES_key_schedule *ks2, - const DES_key_schedule *ks3, - DES_cblock *ivec, int enc); - -/* DES_ede2_cbc_encrypt encrypts (or decrypts, if |enc| is |DES_DECRYPT|) |len| - * bytes from |in| to |out| with 3DES in CBC mode. With this keying option, the - * first and third 3DES keys are identical. Thus, this function takes only two - * different |DES_key_schedule|s. */ -OPENSSL_EXPORT void DES_ede2_cbc_encrypt(const uint8_t *in, uint8_t *out, - size_t len, - const DES_key_schedule *ks1, - const DES_key_schedule *ks2, - DES_cblock *ivec, int enc); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_DES_H */ diff --git a/phonelibs/boringssl/include/openssl/dh.h b/phonelibs/boringssl/include/openssl/dh.h deleted file mode 100644 index 17574d51edf5b1..00000000000000 --- a/phonelibs/boringssl/include/openssl/dh.h +++ /dev/null @@ -1,274 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_DH_H -#define OPENSSL_HEADER_DH_H - -#include - -#include -#include -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* DH contains functions for performing Diffie-Hellman key agreement in - * multiplicative groups. */ - - -/* Allocation and destruction. */ - -/* DH_new returns a new, empty DH object or NULL on error. */ -OPENSSL_EXPORT DH *DH_new(void); - -/* DH_new_method acts the same as |DH_new| but takes an explicit |ENGINE|. */ -OPENSSL_EXPORT DH *DH_new_method(const ENGINE *engine); - -/* DH_free decrements the reference count of |dh| and frees it if the reference - * count drops to zero. */ -OPENSSL_EXPORT void DH_free(DH *dh); - -/* DH_up_ref increments the reference count of |dh|. */ -OPENSSL_EXPORT int DH_up_ref(DH *dh); - - -/* Standard parameters. - * - * These functions return new DH objects with standard parameters configured - * that use the given ENGINE, which may be NULL. They return NULL on allocation - * failure. */ - -/* These parameters are taken from RFC 5114. */ - -OPENSSL_EXPORT DH *DH_get_1024_160(const ENGINE *engine); -OPENSSL_EXPORT DH *DH_get_2048_224(const ENGINE *engine); -OPENSSL_EXPORT DH *DH_get_2048_256(const ENGINE *engine); - - -/* Parameter generation. */ - -#define DH_GENERATOR_2 2 -#define DH_GENERATOR_5 5 - -/* DH_generate_parameters_ex generates a suitable Diffie-Hellman group with a - * prime that is |prime_bits| long and stores it in |dh|. The generator of the - * group will be |generator|, which should be |DH_GENERATOR_2| unless there's a - * good reason to use a different value. The |cb| argument contains a callback - * function that will be called during the generation. See the documentation in - * |bn.h| about this. In addition to the callback invocations from |BN|, |cb| - * will also be called with |event| equal to three when the generation is - * complete. */ -OPENSSL_EXPORT int DH_generate_parameters_ex(DH *dh, int prime_bits, - int generator, BN_GENCB *cb); - - -/* Diffie-Hellman operations. */ - -/* DH_generate_key generates a new, random, private key and stores it in - * |dh|. It returns one on success and zero on error. */ -OPENSSL_EXPORT int DH_generate_key(DH *dh); - -/* DH_compute_key calculates the shared key between |dh| and |peers_key| and - * writes it as a big-endian integer into |out|, which must have |DH_size| - * bytes of space. It returns the number of bytes written, or a negative number - * on error. */ -OPENSSL_EXPORT int DH_compute_key(uint8_t *out, const BIGNUM *peers_key, - DH *dh); - - -/* Utility functions. */ - -/* DH_size returns the number of bytes in the DH group's prime. */ -OPENSSL_EXPORT int DH_size(const DH *dh); - -/* DH_num_bits returns the minimum number of bits needed to represent the - * absolute value of the DH group's prime. */ -OPENSSL_EXPORT unsigned DH_num_bits(const DH *dh); - -#define DH_CHECK_P_NOT_PRIME 0x01 -#define DH_CHECK_P_NOT_SAFE_PRIME 0x02 -#define DH_CHECK_UNABLE_TO_CHECK_GENERATOR 0x04 -#define DH_CHECK_NOT_SUITABLE_GENERATOR 0x08 -#define DH_CHECK_Q_NOT_PRIME 0x10 -#define DH_CHECK_INVALID_Q_VALUE 0x20 -#define DH_CHECK_INVALID_J_VALUE 0x40 - -/* These are compatibility defines. */ -#define DH_NOT_SUITABLE_GENERATOR DH_CHECK_NOT_SUITABLE_GENERATOR -#define DH_UNABLE_TO_CHECK_GENERATOR DH_CHECK_UNABLE_TO_CHECK_GENERATOR - -/* DH_check checks the suitability of |dh| as a Diffie-Hellman group. and sets - * |DH_CHECK_*| flags in |*out_flags| if it finds any errors. It returns one if - * |*out_flags| was successfully set and zero on error. - * - * Note: these checks may be quite computationally expensive. */ -OPENSSL_EXPORT int DH_check(const DH *dh, int *out_flags); - -#define DH_CHECK_PUBKEY_TOO_SMALL 1 -#define DH_CHECK_PUBKEY_TOO_LARGE 2 - -/* DH_check_pub_key checks the suitability of |pub_key| as a public key for the - * DH group in |dh| and sets |DH_CHECK_PUBKEY_*| flags in |*out_flags| if it - * finds any errors. It returns one if |*out_flags| was successfully set and - * zero on error. */ -OPENSSL_EXPORT int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, - int *out_flags); - -/* DHparams_dup allocates a fresh |DH| and copies the parameters from |dh| into - * it. It returns the new |DH| or NULL on error. */ -OPENSSL_EXPORT DH *DHparams_dup(const DH *dh); - - -/* ASN.1 functions. */ - -/* d2i_DHparams parses an ASN.1, DER encoded Diffie-Hellman parameters - * structure from |len| bytes at |*inp|. If |ret| is not NULL then, on exit, a - * pointer to the result is in |*ret|. If |*ret| is already non-NULL on entry - * then the result is written directly into |*ret|, otherwise a fresh |DH| is - * allocated. On successful exit, |*inp| is advanced past the DER structure. It - * returns the result or NULL on error. */ -OPENSSL_EXPORT DH *d2i_DHparams(DH **ret, const unsigned char **inp, long len); - -/* i2d_DHparams marshals |in| to an ASN.1, DER structure. If |outp| is not NULL - * then the result is written to |*outp| and |*outp| is advanced just past the - * output. It returns the number of bytes in the result, whether written or - * not, or a negative value on error. */ -OPENSSL_EXPORT int i2d_DHparams(const DH *in, unsigned char **outp); - - -/* ex_data functions. - * - * See |ex_data.h| for details. */ - -OPENSSL_EXPORT int DH_get_ex_new_index(long argl, void *argp, - CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, - CRYPTO_EX_free *free_func); -OPENSSL_EXPORT int DH_set_ex_data(DH *d, int idx, void *arg); -OPENSSL_EXPORT void *DH_get_ex_data(DH *d, int idx); - - -/* dh_method contains function pointers to override the implementation of DH. - * See |engine.h| for details. */ -struct dh_method { - struct openssl_method_common_st common; - - /* app_data is an opaque pointer for the method to use. */ - void *app_data; - - /* init is called just before the return of |DH_new_method|. It returns one - * on success or zero on error. */ - int (*init)(DH *dh); - - /* finish is called before |dh| is destructed. */ - void (*finish)(DH *dh); - - /* generate_parameters is called by |DH_generate_parameters_ex|. */ - int (*generate_parameters)(DH *dh, int prime_bits, int generator, - BN_GENCB *cb); - - /* generate_parameters is called by |DH_generate_key|. */ - int (*generate_key)(DH *dh); - - /* compute_key is called by |DH_compute_key|. */ - int (*compute_key)(DH *dh, uint8_t *out, const BIGNUM *pub_key); -}; - -struct dh_st { - DH_METHOD *meth; - - BIGNUM *p; - BIGNUM *g; - BIGNUM *pub_key; /* g^x */ - BIGNUM *priv_key; /* x */ - - /* priv_length contains the length, in bits, of the private value. If zero, - * the private value will be the same length as |p|. */ - unsigned priv_length; - - CRYPTO_MUTEX method_mont_p_lock; - BN_MONT_CTX *method_mont_p; - - /* Place holders if we want to do X9.42 DH */ - BIGNUM *q; - BIGNUM *j; - unsigned char *seed; - int seedlen; - BIGNUM *counter; - - int flags; - CRYPTO_refcount_t references; - CRYPTO_EX_DATA ex_data; -}; - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#define DH_F_DH_new_method 100 -#define DH_F_compute_key 101 -#define DH_F_generate_key 102 -#define DH_F_generate_parameters 103 -#define DH_R_BAD_GENERATOR 100 -#define DH_R_INVALID_PUBKEY 101 -#define DH_R_MODULUS_TOO_LARGE 102 -#define DH_R_NO_PRIVATE_VALUE 103 - -#endif /* OPENSSL_HEADER_DH_H */ diff --git a/phonelibs/boringssl/include/openssl/digest.h b/phonelibs/boringssl/include/openssl/digest.h deleted file mode 100644 index 2ea4ec4d7d3dda..00000000000000 --- a/phonelibs/boringssl/include/openssl/digest.h +++ /dev/null @@ -1,265 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_DIGEST_H -#define OPENSSL_HEADER_DIGEST_H - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* Digest functions. - * - * An EVP_MD abstracts the details of a specific hash function allowing code to - * deal with the concept of a "hash function" without needing to know exactly - * which hash function it is. */ - - -/* Hash algorithms. - * - * The following functions return |EVP_MD| objects that implement the named hash - * function. */ - -OPENSSL_EXPORT const EVP_MD *EVP_md4(void); -OPENSSL_EXPORT const EVP_MD *EVP_md5(void); -OPENSSL_EXPORT const EVP_MD *EVP_sha1(void); -OPENSSL_EXPORT const EVP_MD *EVP_sha224(void); -OPENSSL_EXPORT const EVP_MD *EVP_sha256(void); -OPENSSL_EXPORT const EVP_MD *EVP_sha384(void); -OPENSSL_EXPORT const EVP_MD *EVP_sha512(void); - -/* EVP_md5_sha1 is a TLS-specific |EVP_MD| which computes the concatenation of - * MD5 and SHA-1, as used in TLS 1.1 and below. */ -OPENSSL_EXPORT const EVP_MD *EVP_md5_sha1(void); - -/* EVP_get_digestbynid returns an |EVP_MD| for the given NID, or NULL if no - * such digest is known. */ -OPENSSL_EXPORT const EVP_MD *EVP_get_digestbynid(int nid); - -/* EVP_get_digestbyobj returns an |EVP_MD| for the given |ASN1_OBJECT|, or NULL - * if no such digest is known. */ -OPENSSL_EXPORT const EVP_MD *EVP_get_digestbyobj(const ASN1_OBJECT *obj); - - -/* Digest contexts. - * - * An EVP_MD_CTX represents the state of a specific digest operation in - * progress. */ - -/* EVP_MD_CTX_init initialises an, already allocated, |EVP_MD_CTX|. */ -OPENSSL_EXPORT void EVP_MD_CTX_init(EVP_MD_CTX *ctx); - -/* EVP_MD_CTX_create allocates and initialises a fresh |EVP_MD_CTX| and returns - * it, or NULL on allocation failure. */ -OPENSSL_EXPORT EVP_MD_CTX *EVP_MD_CTX_create(void); - -/* EVP_MD_CTX_cleanup frees any resources owned by |ctx| and resets it to a - * freshly initialised state. It does not free |ctx| itself. It returns one. */ -OPENSSL_EXPORT int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx); - -/* EVP_MD_CTX_destroy calls |EVP_MD_CTX_cleanup| and then frees |ctx| itself. */ -OPENSSL_EXPORT void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx); - -/* EVP_MD_CTX_copy_ex sets |out|, which must already be initialised, to be a - * copy of |in|. It returns one on success and zero on error. */ -OPENSSL_EXPORT int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in); - - -/* Digest operations. */ - -/* EVP_DigestInit_ex configures |ctx|, which must already have been - * initialised, for a fresh hashing operation using |type|. It returns one on - * success and zero otherwise. */ -OPENSSL_EXPORT int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, - ENGINE *engine); - -/* EVP_DigestInit acts like |EVP_DigestInit_ex| except that |ctx| is - * initialised before use. */ -OPENSSL_EXPORT int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); - -/* EVP_DigestUpdate hashes |len| bytes from |data| into the hashing operation - * in |ctx|. It returns one. */ -OPENSSL_EXPORT int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, - size_t len); - -/* EVP_MAX_MD_SIZE is the largest digest size supported. Functions that output - * a digest generally require the buffer have at least this much space. */ -#define EVP_MAX_MD_SIZE 64 /* SHA-512 is the longest so far. */ - -/* EVP_DigestFinal_ex finishes the digest in |ctx| and writes the output to - * |md_out|. At most |EVP_MAX_MD_SIZE| bytes are written. If |out_size| is not - * NULL then |*out_size| is set to the number of bytes written. It returns one. - * After this call, the hash cannot be updated or finished again until - * |EVP_DigestInit_ex| is called to start another hashing operation. */ -OPENSSL_EXPORT int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, uint8_t *md_out, - unsigned int *out_size); - -/* EVP_DigestFinal acts like |EVP_DigestFinal_ex| except that - * |EVP_MD_CTX_cleanup| is called on |ctx| before returning. */ -OPENSSL_EXPORT int EVP_DigestFinal(EVP_MD_CTX *ctx, uint8_t *md_out, - unsigned int *out_size); - -/* EVP_Digest performs a complete hashing operation in one call. It hashes - * |len| bytes from |data| and writes the digest to |md_out|. At most - * |EVP_MAX_MD_SIZE| bytes are written. If |out_size| is not NULL then - * |*out_size| is set to the number of bytes written. It returns one on success - * and zero otherwise. */ -OPENSSL_EXPORT int EVP_Digest(const void *data, size_t len, uint8_t *md_out, - unsigned int *md_out_size, const EVP_MD *type, - ENGINE *impl); - - -/* Digest function accessors. - * - * These functions allow code to learn details about an abstract hash - * function. */ - -/* EVP_MD_type returns a NID identifing |md|. (For example, |NID_sha256|.) */ -OPENSSL_EXPORT int EVP_MD_type(const EVP_MD *md); - -/* EVP_MD_flags returns the flags for |md|, which is a set of |EVP_MD_FLAG_*| - * values, ORed together. */ -OPENSSL_EXPORT uint32_t EVP_MD_flags(const EVP_MD *md); - -/* EVP_MD_size returns the digest size of |md|, in bytes. */ -OPENSSL_EXPORT size_t EVP_MD_size(const EVP_MD *md); - -/* EVP_MD_block_size returns the native block-size of |md|. */ -OPENSSL_EXPORT size_t EVP_MD_block_size(const EVP_MD *md); - -/* EVP_MD_FLAG_PKEY_DIGEST indicates the the digest function is used with a - * specific public key in order to verify signatures. (For example, - * EVP_dss1.) */ -#define EVP_MD_FLAG_PKEY_DIGEST 1 - -/* EVP_MD_FLAG_DIGALGID_ABSENT indicates that the parameter type in an X.509 - * DigestAlgorithmIdentifier representing this digest function should be - * undefined rather than NULL. */ -#define EVP_MD_FLAG_DIGALGID_ABSENT 2 - - -/* Deprecated functions. */ - -/* EVP_MD_CTX_copy sets |out|, which must /not/ be initialised, to be a copy of - * |in|. It returns one on success and zero on error. */ -OPENSSL_EXPORT int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in); - -/* EVP_add_digest does nothing and returns one. It exists only for - * compatibility with OpenSSL. */ -OPENSSL_EXPORT int EVP_add_digest(const EVP_MD *digest); - -/* EVP_get_cipherbyname returns an |EVP_MD| given a human readable name in - * |name|, or NULL if the name is unknown. */ -OPENSSL_EXPORT const EVP_MD *EVP_get_digestbyname(const char *); - - -/* Digest operation accessors. */ - -/* EVP_MD_CTX_md returns the underlying digest function, or NULL if one has not - * been set. */ -OPENSSL_EXPORT const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx); - -/* EVP_MD_CTX_size returns the digest size of |ctx|. It will crash if a digest - * hasn't been set on |ctx|. */ -OPENSSL_EXPORT unsigned EVP_MD_CTX_size(const EVP_MD_CTX *ctx); - -/* EVP_MD_CTX_block_size returns the block size of the digest function used by - * |ctx|. It will crash if a digest hasn't been set on |ctx|. */ -OPENSSL_EXPORT unsigned EVP_MD_CTX_block_size(const EVP_MD_CTX *ctx); - -/* EVP_MD_CTX_type returns a NID describing the digest function used by |ctx|. - * (For example, |NID_sha256|.) It will crash if a digest hasn't been set on - * |ctx|. */ -OPENSSL_EXPORT int EVP_MD_CTX_type(const EVP_MD_CTX *ctx); - - -struct evp_md_pctx_ops; - -struct env_md_ctx_st { - /* digest is the underlying digest function, or NULL if not set. */ - const EVP_MD *digest; - /* flags is the OR of a number of |EVP_MD_CTX_FLAG_*| values. */ - uint32_t flags; - /* md_data points to a block of memory that contains the hash-specific - * context. */ - void *md_data; - /* update is usually copied from |digest->update| but can differ in some - * cases, i.e. HMAC. - * TODO(davidben): Remove this hook once |EVP_PKEY_HMAC| is gone. */ - void (*update)(EVP_MD_CTX *ctx, const void *data, size_t count); - - /* pctx is an opaque (at this layer) pointer to additional context that - * EVP_PKEY functions may store in this object. */ - EVP_PKEY_CTX *pctx; - - /* pctx_ops, if not NULL, points to a vtable that contains functions to - * manipulate |pctx|. */ - const struct evp_md_pctx_ops *pctx_ops; -} /* EVP_MD_CTX */; - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#define DIGEST_F_EVP_DigestInit_ex 100 -#define DIGEST_F_EVP_MD_CTX_copy_ex 101 -#define DIGEST_R_INPUT_NOT_INITIALIZED 100 - -#endif /* OPENSSL_HEADER_DIGEST_H */ diff --git a/phonelibs/boringssl/include/openssl/dsa.h b/phonelibs/boringssl/include/openssl/dsa.h deleted file mode 100644 index 7274e4c8c90d29..00000000000000 --- a/phonelibs/boringssl/include/openssl/dsa.h +++ /dev/null @@ -1,379 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - * - * The DSS routines are based on patches supplied by - * Steven Schoch . */ - -#ifndef OPENSSL_HEADER_DSA_H -#define OPENSSL_HEADER_DSA_H - -#include - -#include -#include -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* DSA contains functions for signing and verifing with the Digital Signature - * Algorithm. */ - - -/* Allocation and destruction. */ - -/* DSA_new returns a new, empty DSA object or NULL on error. */ -OPENSSL_EXPORT DSA *DSA_new(void); - -/* DSA_new_method acts the same as |DH_new| but takes an explicit |ENGINE|. */ -OPENSSL_EXPORT DSA *DSA_new_method(const ENGINE *engine); - -/* DSA_free decrements the reference count of |dsa| and frees it if the - * reference count drops to zero. */ -OPENSSL_EXPORT void DSA_free(DSA *dsa); - -/* DSA_up_ref increments the reference count of |dsa|. */ -OPENSSL_EXPORT int DSA_up_ref(DSA *dsa); - - -/* Parameter generation. */ - -/* DSA_generate_parameters_ex generates a set of DSA parameters by following - * the procedure given in FIPS 186-4, appendix A. - * (http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf) - * - * The larger prime will have a length of |bits| (e.g. 2048). The |seed| value - * allows others to generate and verify the same parameters and should be - * random input which is kept for reference. If |out_counter| or |out_h| are - * not NULL then the counter and h value used in the generation are written to - * them. - * - * The |cb| argument is passed to |BN_generate_prime_ex| and is thus called - * during the generation process in order to indicate progress. See the - * comments for that function for details. In addition to the calls made by - * |BN_generate_prime_ex|, |DSA_generate_parameters_ex| will call it with - * |event| equal to 2 and 3 at different stages of the process. - * - * It returns one on success and zero otherwise. */ -OPENSSL_EXPORT int DSA_generate_parameters_ex(DSA *dsa, unsigned bits, - const uint8_t *seed, - size_t seed_len, int *out_counter, - unsigned long *out_h, - BN_GENCB *cb); - -/* DSAparams_dup returns a freshly allocated |DSA| that contains a copy of the - * parameters from |dsa|. It returns NULL on error. */ -OPENSSL_EXPORT DSA *DSAparams_dup(const DSA *dsa); - - -/* Key generation. */ - -/* DSA_generate_key generates a public/private key pair in |dsa|, which must - * already have parameters setup. It returns one on success and zero on - * error. */ -OPENSSL_EXPORT int DSA_generate_key(DSA *dsa); - - -/* Signatures. */ - -/* DSA_SIG contains a DSA signature as a pair of integers. */ -typedef struct DSA_SIG_st { - BIGNUM *r, *s; -} DSA_SIG; - -/* DSA_SIG_new returns a freshly allocated, DIG_SIG structure or NULL on error. - * Both |r| and |s| in the signature will be NULL. */ -OPENSSL_EXPORT DSA_SIG *DSA_SIG_new(void); - -/* DSA_SIG_free frees the contents of |sig| and then frees |sig| itself. */ -OPENSSL_EXPORT void DSA_SIG_free(DSA_SIG *sig); - -/* DSA_do_sign returns a signature of the hash in |digest| by the key in |dsa| - * and returns an allocated, DSA_SIG structure, or NULL on error. */ -OPENSSL_EXPORT DSA_SIG *DSA_do_sign(const uint8_t *digest, size_t digest_len, - DSA *dsa); - -/* DSA_do_verify verifies that |sig| is a valid signature, by the public key in - * |dsa|, of the hash in |digest|. It returns one if so, zero if invalid and -1 - * on error. - * - * WARNING: do not use. This function returns -1 for error, 0 for invalid and 1 - * for valid. However, this is dangerously different to the usual OpenSSL - * convention and could be a disaster if a user did |if (DSA_do_verify(...))|. - * Because of this, |DSA_check_signature| is a safer version of this. - * - * TODO(fork): deprecate. */ -OPENSSL_EXPORT int DSA_do_verify(const uint8_t *digest, size_t digest_len, - DSA_SIG *sig, const DSA *dsa); - -/* DSA_do_check_signature sets |*out_valid| to zero. Then it verifies that |sig| - * is a valid signature, by the public key in |dsa| of the hash in |digest| - * and, if so, it sets |*out_valid| to one. - * - * It returns one if it was able to verify the signature as valid or invalid, - * and zero on error. */ -OPENSSL_EXPORT int DSA_do_check_signature(int *out_valid, const uint8_t *digest, - size_t digest_len, DSA_SIG *sig, - const DSA *dsa); - - -/* ASN.1 signatures. - * - * These functions also perform DSA signature operations, but deal with ASN.1 - * encoded signatures as opposed to raw |BIGNUM|s. If you don't know what - * encoding a DSA signature is in, it's probably ASN.1. */ - -/* DSA_sign signs |digest| with the key in |dsa| and writes the resulting - * signature, in ASN.1 form, to |out_sig| and the length of the signature to - * |*out_siglen|. There must be, at least, |DSA_size(dsa)| bytes of space in - * |out_sig|. It returns one on success and zero otherwise. - * - * (The |type| argument is ignored.) */ -OPENSSL_EXPORT int DSA_sign(int type, const uint8_t *digest, size_t digest_len, - uint8_t *out_sig, unsigned int *out_siglen, - DSA *dsa); - -/* DSA_verify verifies that |sig| is a valid, ASN.1 signature, by the public - * key in |dsa|, of the hash in |digest|. It returns one if so, zero if invalid - * and -1 on error. - * - * (The |type| argument is ignored.) - * - * WARNING: do not use. This function returns -1 for error, 0 for invalid and 1 - * for valid. However, this is dangerously different to the usual OpenSSL - * convention and could be a disaster if a user did |if (DSA_do_verify(...))|. - * Because of this, |DSA_check_signature| is a safer version of this. - * - * TODO(fork): deprecate. */ -OPENSSL_EXPORT int DSA_verify(int type, const uint8_t *digest, - size_t digest_len, const uint8_t *sig, - size_t sig_len, const DSA *dsa); - -/* DSA_check_signature sets |*out_valid| to zero. Then it verifies that |sig| - * is a valid, ASN.1 signature, by the public key in |dsa|, of the hash in - * |digest|. If so, it sets |*out_valid| to one. - * - * It returns one if it was able to verify the signature as valid or invalid, - * and zero on error. */ -OPENSSL_EXPORT int DSA_check_signature(int *out_valid, const uint8_t *digest, - size_t digest_len, const uint8_t *sig, - size_t sig_len, const DSA *dsa); - -/* DSA_size returns the size, in bytes, of an ASN.1 encoded, DSA signature - * generated by |dsa|. Parameters must already have been setup in |dsa|. */ -OPENSSL_EXPORT int DSA_size(const DSA *dsa); - - -/* ASN.1 encoding. */ - -/* d2i_DSA_SIG parses an ASN.1, DER-encoded, DSA signature from |len| bytes at - * |*inp|. If |out_sig| is not NULL then, on exit, a pointer to the result is - * in |*out_sig|. If |*out_sig| is already non-NULL on entry then the result is - * written directly into |*out_sig|, otherwise a fresh |DSA_SIG| is allocated. - * On successful exit, |*inp| is advanced past the DER structure. It returns - * the result or NULL on error. */ -OPENSSL_EXPORT DSA_SIG *d2i_DSA_SIG(DSA_SIG **out_sig, const uint8_t **inp, - long len); - -/* i2d_DSA_SIG marshals |in| to an ASN.1, DER structure. If |outp| is not NULL - * then the result is written to |*outp| and |*outp| is advanced just past the - * output. It returns the number of bytes in the result, whether written or not, - * or a negative value on error. */ -OPENSSL_EXPORT int i2d_DSA_SIG(const DSA_SIG *in, uint8_t **outp); - -/* d2i_DSAPublicKey parses an ASN.1, DER-encoded, DSA public key from |len| - * bytes at |*inp|. If |out| is not NULL then, on exit, a pointer to the result - * is in |*out|. If |*out| is already non-NULL on entry then the result is - * written directly into |*out|, otherwise a fresh |DSA| is allocated. On - * successful exit, |*inp| is advanced past the DER structure. It returns the - * result or NULL on error. */ -OPENSSL_EXPORT DSA *d2i_DSAPublicKey(DSA **out, const uint8_t **inp, long len); - -/* i2d_DSAPublicKey marshals a public key from |in| to an ASN.1, DER structure. - * If |outp| is not NULL then the result is written to |*outp| and |*outp| is - * advanced just past the output. It returns the number of bytes in the result, - * whether written or not, or a negative value on error. */ -OPENSSL_EXPORT int i2d_DSAPublicKey(const DSA *in, unsigned char **outp); - -/* d2i_DSAPrivateKey parses an ASN.1, DER-encoded, DSA private key from |len| - * bytes at |*inp|. If |out| is not NULL then, on exit, a pointer to the result - * is in |*out|. If |*out| is already non-NULL on entry then the result is - * written directly into |*out|, otherwise a fresh |DSA| is allocated. On - * successful exit, |*inp| is advanced past the DER structure. It returns the - * result or NULL on error. */ -OPENSSL_EXPORT DSA *d2i_DSAPrivateKey(DSA **out, const uint8_t **inp, long len); - -/* i2d_DSAPrivateKey marshals a private key from |in| to an ASN.1, DER structure. - * If |outp| is not NULL then the result is written to |*outp| and |*outp| is - * advanced just past the output. It returns the number of bytes in the result, - * whether written or not, or a negative value on error. */ -OPENSSL_EXPORT int i2d_DSAPrivateKey(const DSA *in, unsigned char **outp); - -/* d2i_DSAparams parses ASN.1, DER-encoded, DSA parameters from |len| bytes at - * |*inp|. If |out| is not NULL then, on exit, a pointer to the result is in - * |*out|. If |*out| is already non-NULL on entry then the result is written - * directly into |*out|, otherwise a fresh |DSA| is allocated. On successful - * exit, |*inp| is advanced past the DER structure. It returns the result or - * NULL on error. */ -OPENSSL_EXPORT DSA *d2i_DSAparams(DSA **out, const uint8_t **inp, long len); - -/* i2d_DSAparams marshals DSA parameters from |in| to an ASN.1, DER structure. - * If |outp| is not NULL then the result is written to |*outp| and |*outp| is - * advanced just past the output. It returns the number of bytes in the result, - * whether written or not, or a negative value on error. */ -OPENSSL_EXPORT int i2d_DSAparams(const DSA *in, unsigned char **outp); - - -/* Precomputation. */ - -/* DSA_sign_setup precomputes the message independent part of the DSA signature - * and writes them to |*out_kinv| and |*out_r|. Returns one on success, zero on - * error. - * - * TODO(fork): decide what to do with this. Since making DSA* opaque there's no - * way for the user to install them. Also, it forces the DSA* not to be const - * when passing to the signing function. */ -OPENSSL_EXPORT int DSA_sign_setup(const DSA *dsa, BN_CTX *ctx, - BIGNUM **out_kinv, BIGNUM **out_r); - - -/* Conversion. */ - -/* DSA_dup_DH returns a |DH| constructed from the parameters of |dsa|. This is - * sometimes needed when Diffie-Hellman parameters are stored in the form of - * DSA parameters. It returns an allocated |DH| on success or NULL on error. */ -OPENSSL_EXPORT DH *DSA_dup_DH(const DSA *dsa); - - -/* ex_data functions. - * - * See |ex_data.h| for details. */ - -OPENSSL_EXPORT int DSA_get_ex_new_index(long argl, void *argp, - CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, - CRYPTO_EX_free *free_func); -OPENSSL_EXPORT int DSA_set_ex_data(DSA *d, int idx, void *arg); -OPENSSL_EXPORT void *DSA_get_ex_data(const DSA *d, int idx); - - -struct dsa_method { - struct openssl_method_common_st common; - - void *app_data; - - int (*init)(DSA *dsa); - int (*finish)(DSA *dsa); - - DSA_SIG *(*sign)(const uint8_t *digest, size_t digest_len, DSA *dsa); - - int (*sign_setup)(const DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp, - const uint8_t *digest, size_t digest_len); - - int (*verify)(int *out_valid, const uint8_t *digest, size_t digest_len, - DSA_SIG *sig, const DSA *dsa); - - /* generate_parameters, if non-NULL, is used to generate DSA parameters. */ - int (*generate_parameters)(DSA *dsa, unsigned bits, const uint8_t *seed, - size_t seed_len, int *counter_ret, - unsigned long *h_ret, BN_GENCB *cb); - - /* keygen, if non-NULL, is used to generate DSA keys. */ - int (*keygen)(DSA *dsa); -}; - -struct dsa_st { - long version; - int write_params; - BIGNUM *p; - BIGNUM *q; /* == 20 */ - BIGNUM *g; - - BIGNUM *pub_key; /* y public key */ - BIGNUM *priv_key; /* x private key */ - - BIGNUM *kinv; /* Signing pre-calc */ - BIGNUM *r; /* Signing pre-calc */ - - int flags; - /* Normally used to cache montgomery values */ - CRYPTO_MUTEX method_mont_p_lock; - BN_MONT_CTX *method_mont_p; - CRYPTO_refcount_t references; - CRYPTO_EX_DATA ex_data; - DSA_METHOD *meth; - /* functional reference if 'meth' is ENGINE-provided */ - ENGINE *engine; -}; - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#define DSA_F_DSA_new_method 100 -#define DSA_F_dsa_sig_cb 101 -#define DSA_F_sign 102 -#define DSA_F_sign_setup 103 -#define DSA_F_verify 104 -#define DSA_R_BAD_Q_VALUE 100 -#define DSA_R_MISSING_PARAMETERS 101 -#define DSA_R_MODULUS_TOO_LARGE 102 -#define DSA_R_NEED_NEW_SETUP_VALUES 103 - -#endif /* OPENSSL_HEADER_DSA_H */ diff --git a/phonelibs/boringssl/include/openssl/dtls1.h b/phonelibs/boringssl/include/openssl/dtls1.h deleted file mode 100644 index 38ca801cb1044e..00000000000000 --- a/phonelibs/boringssl/include/openssl/dtls1.h +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright (c) 2015, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -/* This header is provided in order to make compiling against code that expects - OpenSSL easier. */ diff --git a/phonelibs/boringssl/include/openssl/ec.h b/phonelibs/boringssl/include/openssl/ec.h deleted file mode 100644 index 25b455185e7503..00000000000000 --- a/phonelibs/boringssl/include/openssl/ec.h +++ /dev/null @@ -1,433 +0,0 @@ -/* Originally written by Bodo Moeller for the OpenSSL project. - * ==================================================================== - * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * - * Portions of the attached software ("Contribution") are developed by - * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. - * - * The Contribution is licensed pursuant to the OpenSSL open source - * license provided above. - * - * The elliptic curve binary polynomial software is originally written by - * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems - * Laboratories. */ - -#ifndef OPENSSL_HEADER_EC_H -#define OPENSSL_HEADER_EC_H - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* Low-level operations on elliptic curves. */ - - -typedef struct ec_group_st EC_GROUP; -typedef struct ec_point_st EC_POINT; - -/** Enum for the point conversion form as defined in X9.62 (ECDSA) - * for the encoding of a elliptic curve point (x,y) */ -typedef enum { - /** the point is encoded as z||x, where the octet z specifies - * which solution of the quadratic equation y is */ - POINT_CONVERSION_COMPRESSED = 2, - /** the point is encoded as z||x||y, where z is the octet 0x02 */ - POINT_CONVERSION_UNCOMPRESSED = 4 -} point_conversion_form_t; - - -/* Elliptic curve groups. */ - -/* EC_GROUP_new_by_curve_name returns a fresh EC_GROUP object for the elliptic - * curve specified by |nid|, or NULL on error. - * - * The supported NIDs are: - * NID_secp224r1, - * NID_X9_62_prime256v1, - * NID_secp384r1, - * NID_secp521r1 */ -OPENSSL_EXPORT EC_GROUP *EC_GROUP_new_by_curve_name(int nid); - -/* EC_GROUP_free frees |group| and the data that it points to. */ -OPENSSL_EXPORT void EC_GROUP_free(EC_GROUP *group); - -/* EC_GROUP_dup returns a fresh |EC_GROUP| which is equal to |a| or NULL on - * error. */ -OPENSSL_EXPORT EC_GROUP *EC_GROUP_dup(const EC_GROUP *a); - -/* EC_GROUP_cmp returns zero if |a| and |b| are the same group and non-zero - * otherwise. */ -OPENSSL_EXPORT int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, - BN_CTX *ignored); - -/* EC_GROUP_get0_generator returns a pointer to the internal |EC_POINT| object - * in |group| that specifies the generator for the group. */ -OPENSSL_EXPORT const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group); - -/* EC_GROUP_get_order sets |*order| to the order of |group|, if it's not - * NULL. It returns one on success and zero otherwise. |ctx| is ignored. */ -OPENSSL_EXPORT int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, - BN_CTX *ctx); - -/* EC_GROUP_get_cofactor sets |*cofactor| to the cofactor of |group| using - * |ctx|, if it's not NULL. It returns one on success and zero otherwise. */ -OPENSSL_EXPORT int EC_GROUP_get_cofactor(const EC_GROUP *group, - BIGNUM *cofactor, BN_CTX *ctx); - -/* EC_GROUP_get_curve_GFp gets various parameters about a group. It sets - * |*out_p| to the order of the coordinate field and |*out_a| and |*out_b| to - * the parameters of the curve when expressed as y² = x³ + ax + b. Any of the - * output parameters can be NULL. It returns one on success and zero on - * error. */ -OPENSSL_EXPORT int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *out_p, - BIGNUM *out_a, BIGNUM *out_b, - BN_CTX *ctx); - -/* EC_GROUP_get_curve_name returns a NID that identifies |group|. */ -OPENSSL_EXPORT int EC_GROUP_get_curve_name(const EC_GROUP *group); - -/* EC_GROUP_get_degree returns the number of bits needed to represent an - * element of the field underlying |group|. */ -OPENSSL_EXPORT int EC_GROUP_get_degree(const EC_GROUP *group); - -/* EC_GROUP_precompute_mult precomputes multiplies of the generator in order to - * speed up operations that involve calculating generator multiples. It returns - * one on sucess and zero otherwise. If |ctx| is not NULL, it may be used. */ -OPENSSL_EXPORT int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx); - -/* EC_GROUP_have_precompute_mult returns one if |group| contains precomputed - * generator multiples. */ -OPENSSL_EXPORT int EC_GROUP_have_precompute_mult(const EC_GROUP *group); - - -/* Points on elliptic curves. */ - -/* EC_POINT_new returns a fresh |EC_POINT| object in the given group, or NULL - * on error. */ -OPENSSL_EXPORT EC_POINT *EC_POINT_new(const EC_GROUP *group); - -/* EC_POINT_free frees |point| and the data that it points to. */ -OPENSSL_EXPORT void EC_POINT_free(EC_POINT *point); - -/* EC_POINT_clear_free clears the data that |point| points to, frees it and - * then frees |point| itself. */ -OPENSSL_EXPORT void EC_POINT_clear_free(EC_POINT *point); - -/* EC_POINT_copy sets |*dest| equal to |*src|. It returns one on success and - * zero otherwise. */ -OPENSSL_EXPORT int EC_POINT_copy(EC_POINT *dest, const EC_POINT *src); - -/* EC_POINT_dup returns a fresh |EC_POINT| that contains the same values as - * |src|, or NULL on error. */ -OPENSSL_EXPORT EC_POINT *EC_POINT_dup(const EC_POINT *src, - const EC_GROUP *group); - -/* EC_POINT_set_to_infinity sets |point| to be the "point at infinity" for the - * given group. */ -OPENSSL_EXPORT int EC_POINT_set_to_infinity(const EC_GROUP *group, - EC_POINT *point); - -/* EC_POINT_is_at_infinity returns one iff |point| is the point at infinity and - * zero otherwise. */ -OPENSSL_EXPORT int EC_POINT_is_at_infinity(const EC_GROUP *group, - const EC_POINT *point); - -/* EC_POINT_is_on_curve returns one if |point| is an element of |group| and - * zero otheriwse. If |ctx| is non-NULL, it may be used. */ -OPENSSL_EXPORT int EC_POINT_is_on_curve(const EC_GROUP *group, - const EC_POINT *point, BN_CTX *ctx); - -/* EC_POINT_cmp returns zero if |a| is equal to |b|, greater than zero is - * non-equal and -1 on error. If |ctx| is not NULL, it may be used. */ -OPENSSL_EXPORT int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, - const EC_POINT *b, BN_CTX *ctx); - -/* EC_POINT_make_affine converts |point| to affine form, internally. It returns - * one on success and zero otherwise. If |ctx| is not NULL, it may be used. */ -OPENSSL_EXPORT int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, - BN_CTX *ctx); - -/* EC_POINTs_make_affine converts |num| points from |points| to affine form, - * internally. It returns one on success and zero otherwise. If |ctx| is not - * NULL, it may be used. */ -OPENSSL_EXPORT int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, - EC_POINT *points[], BN_CTX *ctx); - - -/* Point conversion. */ - -/* EC_POINT_get_affine_coordinates_GFp sets |x| and |y| to the affine value of - * |point| using |ctx|, if it's not NULL. It returns one on success and zero - * otherwise. */ -OPENSSL_EXPORT int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, - const EC_POINT *point, - BIGNUM *x, BIGNUM *y, - BN_CTX *ctx); - -/* EC_POINT_set_affine_coordinates sets the value of |p| to be (|x|, |y|). The - * |ctx| argument may be used if not NULL. */ -OPENSSL_EXPORT int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, - EC_POINT *point, - const BIGNUM *x, - const BIGNUM *y, - BN_CTX *ctx); - -/* EC_POINT_point2oct serialises |point| into the X9.62 form given by |form| - * into, at most, |len| bytes at |buf|. It returns the number of bytes written - * or zero on error if |buf| is non-NULL, else the number of bytes needed. The - * |ctx| argument may be used if not NULL. */ -OPENSSL_EXPORT size_t EC_POINT_point2oct(const EC_GROUP *group, - const EC_POINT *point, - point_conversion_form_t form, - uint8_t *buf, size_t len, BN_CTX *ctx); - -/* EC_POINT_oct2point sets |point| from |len| bytes of X9.62 format - * serialisation in |buf|. It returns one on success and zero otherwise. The - * |ctx| argument may be used if not NULL. */ -OPENSSL_EXPORT int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point, - const uint8_t *buf, size_t len, - BN_CTX *ctx); - -/* EC_POINT_set_compressed_coordinates_GFp sets |point| to equal the point with - * the given |x| coordinate and the y coordinate specified by |y_bit| (see - * X9.62). It returns one on success and zero otherwise. */ -OPENSSL_EXPORT int EC_POINT_set_compressed_coordinates_GFp( - const EC_GROUP *group, EC_POINT *point, const BIGNUM *x, int y_bit, - BN_CTX *ctx); - - -/* Group operations. */ - -/* EC_POINT_add sets |r| equal to |a| plus |b|. It returns one on success and - * zero otherwise. If |ctx| is not NULL, it may be used. */ -OPENSSL_EXPORT int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, - const EC_POINT *a, const EC_POINT *b, - BN_CTX *ctx); - -/* EC_POINT_dbl sets |r| equal to |a| plus |a|. It returns one on success and - * zero otherwise. If |ctx| is not NULL, it may be used. */ -OPENSSL_EXPORT int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, - const EC_POINT *a, BN_CTX *ctx); - -/* EC_POINT_dbl sets |a| equal to minus |a|. It returns one on success and zero - * otherwise. If |ctx| is not NULL, it may be used. */ -OPENSSL_EXPORT int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, - BN_CTX *ctx); - -/* EC_POINT_mul sets r = generator*n + q*m. It returns one on success and zero - * otherwise. If |ctx| is not NULL, it may be used. */ -OPENSSL_EXPORT int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, - const BIGNUM *n, const EC_POINT *q, - const BIGNUM *m, BN_CTX *ctx); - -/* EC_POINTs_mul sets r = generator*n + sum(p[i]*m[i]). It returns one on - * success and zero otherwise. If |ctx| is not NULL, it may be used. */ -OPENSSL_EXPORT int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, - const BIGNUM *n, size_t num, - const EC_POINT *p[], const BIGNUM *m[], - BN_CTX *ctx); - - -/* Deprecated functions. */ - -/* EC_GROUP_new_curve_GFp creates a new, arbitrary elliptic curve group based - * on the equation y² = x³ + a·x + b. It returns the new group or NULL on - * error. - * - * |EC_GROUP|s returned by this function will always compare as unequal via - * |EC_GROUP_cmp| (even to themselves). |EC_GROUP_get_curve_name| will always - * return |NID_undef|. */ -OPENSSL_EXPORT EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, - const BIGNUM *a, - const BIGNUM *b, BN_CTX *ctx); - -/* EC_GROUP_set_generator sets the generator for |group| to |generator|, which - * must have the given order and cofactor. This should only be used with - * |EC_GROUP| objects returned by |EC_GROUP_new_curve_GFp|. */ -OPENSSL_EXPORT int EC_GROUP_set_generator(EC_GROUP *group, - const EC_POINT *generator, - const BIGNUM *order, - const BIGNUM *cofactor); - -/* EC_GROUP_set_asn1_flag does nothing. */ -OPENSSL_EXPORT void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag); - -#define OPENSSL_EC_NAMED_CURVE 0 - -typedef struct ec_method_st EC_METHOD; - -/* EC_GROUP_method_of returns NULL. */ -OPENSSL_EXPORT const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group); - -/* EC_METHOD_get_field_type returns NID_X9_62_prime_field. */ -OPENSSL_EXPORT int EC_METHOD_get_field_type(const EC_METHOD *meth); - -/* EC_GROUP_set_point_conversion_form aborts the process if |form| is not - * |POINT_CONVERSION_UNCOMPRESSED| and otherwise does nothing. */ -OPENSSL_EXPORT void EC_GROUP_set_point_conversion_form( - EC_GROUP *group, point_conversion_form_t form); - - -/* Old code expects to get EC_KEY from ec.h. */ -#if !defined(OPENSSL_HEADER_EC_KEY_H) -#include -#endif - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#define EC_F_EC_GROUP_copy 100 -#define EC_F_EC_GROUP_get_curve_GFp 101 -#define EC_F_EC_GROUP_get_degree 102 -#define EC_F_EC_GROUP_new_by_curve_name 103 -#define EC_F_EC_KEY_check_key 104 -#define EC_F_EC_KEY_copy 105 -#define EC_F_EC_KEY_generate_key 106 -#define EC_F_EC_KEY_new_method 107 -#define EC_F_EC_KEY_set_public_key_affine_coordinates 108 -#define EC_F_EC_POINT_add 109 -#define EC_F_EC_POINT_cmp 110 -#define EC_F_EC_POINT_copy 111 -#define EC_F_EC_POINT_dbl 112 -#define EC_F_EC_POINT_dup 113 -#define EC_F_EC_POINT_get_affine_coordinates_GFp 114 -#define EC_F_EC_POINT_invert 115 -#define EC_F_EC_POINT_is_at_infinity 116 -#define EC_F_EC_POINT_is_on_curve 117 -#define EC_F_EC_POINT_make_affine 118 -#define EC_F_EC_POINT_new 119 -#define EC_F_EC_POINT_oct2point 120 -#define EC_F_EC_POINT_point2oct 121 -#define EC_F_EC_POINT_set_affine_coordinates_GFp 122 -#define EC_F_EC_POINT_set_compressed_coordinates_GFp 123 -#define EC_F_EC_POINT_set_to_infinity 124 -#define EC_F_EC_POINTs_make_affine 125 -#define EC_F_compute_wNAF 126 -#define EC_F_d2i_ECPKParameters 127 -#define EC_F_d2i_ECParameters 128 -#define EC_F_d2i_ECPrivateKey 129 -#define EC_F_ec_GFp_mont_field_decode 130 -#define EC_F_ec_GFp_mont_field_encode 131 -#define EC_F_ec_GFp_mont_field_mul 132 -#define EC_F_ec_GFp_mont_field_set_to_one 133 -#define EC_F_ec_GFp_mont_field_sqr 134 -#define EC_F_ec_GFp_mont_group_set_curve 135 -#define EC_F_ec_GFp_simple_group_check_discriminant 136 -#define EC_F_ec_GFp_simple_group_set_curve 137 -#define EC_F_ec_GFp_simple_make_affine 138 -#define EC_F_ec_GFp_simple_oct2point 139 -#define EC_F_ec_GFp_simple_point2oct 140 -#define EC_F_ec_GFp_simple_point_get_affine_coordinates 141 -#define EC_F_ec_GFp_simple_point_set_affine_coordinates 142 -#define EC_F_ec_GFp_simple_points_make_affine 143 -#define EC_F_ec_GFp_simple_set_compressed_coordinates 144 -#define EC_F_ec_asn1_group2pkparameters 145 -#define EC_F_ec_asn1_pkparameters2group 146 -#define EC_F_ec_group_new 147 -#define EC_F_ec_group_new_curve_GFp 148 -#define EC_F_ec_group_new_from_data 149 -#define EC_F_ec_point_set_Jprojective_coordinates_GFp 150 -#define EC_F_ec_pre_comp_new 151 -#define EC_F_ec_wNAF_mul 152 -#define EC_F_ec_wNAF_precompute_mult 153 -#define EC_F_i2d_ECPKParameters 154 -#define EC_F_i2d_ECParameters 155 -#define EC_F_i2d_ECPrivateKey 156 -#define EC_F_i2o_ECPublicKey 157 -#define EC_F_o2i_ECPublicKey 158 -#define EC_F_BN_to_felem 159 -#define EC_F_ec_GFp_nistp256_group_set_curve 160 -#define EC_F_ec_GFp_nistp256_point_get_affine_coordinates 161 -#define EC_F_ec_GFp_nistp256_points_mul 162 -#define EC_F_ec_group_copy 163 -#define EC_F_nistp256_pre_comp_new 164 -#define EC_F_EC_KEY_new_by_curve_name 165 -#define EC_F_EC_GROUP_new_curve_GFp 166 -#define EC_R_BUFFER_TOO_SMALL 100 -#define EC_R_COORDINATES_OUT_OF_RANGE 101 -#define EC_R_D2I_ECPKPARAMETERS_FAILURE 102 -#define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 103 -#define EC_R_GROUP2PKPARAMETERS_FAILURE 104 -#define EC_R_I2D_ECPKPARAMETERS_FAILURE 105 -#define EC_R_INCOMPATIBLE_OBJECTS 106 -#define EC_R_INVALID_COMPRESSED_POINT 107 -#define EC_R_INVALID_COMPRESSION_BIT 108 -#define EC_R_INVALID_ENCODING 109 -#define EC_R_INVALID_FIELD 110 -#define EC_R_INVALID_FORM 111 -#define EC_R_INVALID_GROUP_ORDER 112 -#define EC_R_INVALID_PRIVATE_KEY 113 -#define EC_R_MISSING_PARAMETERS 114 -#define EC_R_MISSING_PRIVATE_KEY 115 -#define EC_R_NON_NAMED_CURVE 116 -#define EC_R_NOT_INITIALIZED 117 -#define EC_R_PKPARAMETERS2GROUP_FAILURE 118 -#define EC_R_POINT_AT_INFINITY 119 -#define EC_R_POINT_IS_NOT_ON_CURVE 120 -#define EC_R_SLOT_FULL 121 -#define EC_R_UNDEFINED_GENERATOR 122 -#define EC_R_UNKNOWN_GROUP 123 -#define EC_R_UNKNOWN_ORDER 124 -#define EC_R_WRONG_ORDER 125 -#define EC_R_BIGNUM_OUT_OF_RANGE 126 -#define EC_R_WRONG_CURVE_PARAMETERS 127 - -#endif /* OPENSSL_HEADER_EC_H */ diff --git a/phonelibs/boringssl/include/openssl/ec_key.h b/phonelibs/boringssl/include/openssl/ec_key.h deleted file mode 100644 index ee64030b8efca9..00000000000000 --- a/phonelibs/boringssl/include/openssl/ec_key.h +++ /dev/null @@ -1,286 +0,0 @@ -/* Originally written by Bodo Moeller for the OpenSSL project. - * ==================================================================== - * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * - * Portions of the attached software ("Contribution") are developed by - * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. - * - * The Contribution is licensed pursuant to the OpenSSL open source - * license provided above. - * - * The elliptic curve binary polynomial software is originally written by - * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems - * Laboratories. */ - -#ifndef OPENSSL_HEADER_EC_KEY_H -#define OPENSSL_HEADER_EC_KEY_H - -#include - -#include -#include -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* ec_key.h contains functions that handle elliptic-curve points that are - * public/private keys. */ - - -/* EC key objects. */ - -/* EC_KEY_new returns a fresh |EC_KEY| object or NULL on error. */ -OPENSSL_EXPORT EC_KEY *EC_KEY_new(void); - -/* EC_KEY_new_method acts the same as |EC_KEY_new|, but takes an explicit - * |ENGINE|. */ -OPENSSL_EXPORT EC_KEY *EC_KEY_new_method(const ENGINE *engine); - -/* EC_KEY_new_by_curve_name returns a fresh EC_KEY for group specified by |nid| - * or NULL on error. */ -OPENSSL_EXPORT EC_KEY *EC_KEY_new_by_curve_name(int nid); - -/* EC_KEY_free frees all the data owned by |key| and |key| itself. */ -OPENSSL_EXPORT void EC_KEY_free(EC_KEY *key); - -/* EC_KEY_copy sets |dst| equal to |src| and returns |dst| or NULL on error. */ -OPENSSL_EXPORT EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src); - -/* EC_KEY_dup returns a fresh copy of |src| or NULL on error. */ -OPENSSL_EXPORT EC_KEY *EC_KEY_dup(const EC_KEY *src); - -/* EC_KEY_up_ref increases the reference count of |key|. It returns one on - * success and zero otherwise. */ -OPENSSL_EXPORT int EC_KEY_up_ref(EC_KEY *key); - -/* EC_KEY_is_opaque returns one if |key| is opaque and doesn't expose its key - * material. Otherwise it return zero. */ -OPENSSL_EXPORT int EC_KEY_is_opaque(const EC_KEY *key); - -/* EC_KEY_get0_group returns a pointer to the |EC_GROUP| object inside |key|. */ -OPENSSL_EXPORT const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key); - -/* EC_KEY_set_group sets the |EC_GROUP| object that |key| will use to |group|. - * It returns one on success and zero otherwise. */ -OPENSSL_EXPORT int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group); - -/* EC_KEY_get0_private_key returns a pointer to the private key inside |key|. */ -OPENSSL_EXPORT const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key); - -/* EC_KEY_set_private_key sets the private key of |key| to |priv|. It returns - * one on success and zero otherwise. */ -OPENSSL_EXPORT int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv); - -/* EC_KEY_get0_public_key returns a pointer to the public key point inside - * |key|. */ -OPENSSL_EXPORT const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key); - -/* EC_KEY_set_public_key sets the public key of |key| to |pub|, by copying it. - * It returns one on success and zero otherwise. */ -OPENSSL_EXPORT int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub); - -#define EC_PKEY_NO_PARAMETERS 0x001 -#define EC_PKEY_NO_PUBKEY 0x002 - -/* EC_KEY_get_enc_flags returns the encoding flags for |key|, which is a - * bitwise-OR of |EC_PKEY_*| values. */ -OPENSSL_EXPORT unsigned EC_KEY_get_enc_flags(const EC_KEY *key); - -/* EC_KEY_set_enc_flags sets the encoding flags for |key|, which is a - * bitwise-OR of |EC_PKEY_*| values. */ -OPENSSL_EXPORT void EC_KEY_set_enc_flags(EC_KEY *key, unsigned flags); - -/* EC_KEY_get_conv_form returns the conversation form that will be used by - * |key|. */ -OPENSSL_EXPORT point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key); - -/* EC_KEY_set_conv_form sets the conversion form to be used by |key|. */ -OPENSSL_EXPORT void EC_KEY_set_conv_form(EC_KEY *key, - point_conversion_form_t cform); - -/* EC_KEY_precompute_mult precomputes multiplies of the generator of the - * underlying group in order to speed up operations that calculate generator - * multiples. If |ctx| is not NULL, it may be used. It returns one on success - * and zero otherwise. */ -OPENSSL_EXPORT int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx); - -/* EC_KEY_check_key performs several checks on |key| (possibly including an - * expensive check that the public key is in the primary subgroup). It returns - * one if all checks pass and zero otherwise. If it returns zero then detail - * about the problem can be found on the error stack. */ -OPENSSL_EXPORT int EC_KEY_check_key(const EC_KEY *key); - -/* EC_KEY_set_public_key_affine_coordinates sets the public key in |key| to - * (|x|, |y|). It returns one on success and zero otherwise. */ -OPENSSL_EXPORT int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, - BIGNUM *x, - BIGNUM *y); - - -/* Key generation. */ - -/* EC_KEY_generate_key generates a random, private key, calculates the - * corresponding public key and stores both in |key|. It returns one on success - * or zero otherwise. */ -OPENSSL_EXPORT int EC_KEY_generate_key(EC_KEY *key); - - -/* Serialisation. */ - -/* d2i_ECPrivateKey parses an ASN.1, DER-encoded, private key from |len| bytes - * at |*inp|. If |out_key| is not NULL then, on exit, a pointer to the result - * is in |*out_key|. If |*out_key| is already non-NULL on entry then the result - * is written directly into |*out_key|, otherwise a fresh |EC_KEY| is - * allocated. On successful exit, |*inp| is advanced past the DER structure. It - * returns the result or NULL on error. */ -OPENSSL_EXPORT EC_KEY *d2i_ECPrivateKey(EC_KEY **out_key, const uint8_t **inp, - long len); - -/* i2d_ECParameters marshals an EC private key from |key| to an ASN.1, DER - * structure. If |outp| is not NULL then the result is written to |*outp| and - * |*outp| is advanced just past the output. It returns the number of bytes in - * the result, whether written or not, or a negative value on error. */ -OPENSSL_EXPORT int i2d_ECPrivateKey(const EC_KEY *key, uint8_t **outp); - -/* d2i_ECParameters parses an ASN.1, DER-encoded, set of EC parameters from - * |len| bytes at |*inp|. If |out_key| is not NULL then, on exit, a pointer to - * the result is in |*out_key|. If |*out_key| is already non-NULL on entry then - * the result is written directly into |*out_key|, otherwise a fresh |EC_KEY| - * is allocated. On successful exit, |*inp| is advanced past the DER structure. - * It returns the result or NULL on error. */ -OPENSSL_EXPORT EC_KEY *d2i_ECParameters(EC_KEY **out_key, const uint8_t **inp, - long len); - -/* i2d_ECParameters marshals EC parameters from |key| to an ASN.1, DER - * structure. If |outp| is not NULL then the result is written to |*outp| and - * |*outp| is advanced just past the output. It returns the number of bytes in - * the result, whether written or not, or a negative value on error. */ -OPENSSL_EXPORT int i2d_ECParameters(const EC_KEY *key, uint8_t **outp); - -/* o2i_ECPublicKey parses an EC point from |len| bytes at |*inp| into - * |*out_key|. Note that this differs from the d2i format in that |*out_key| - * must be non-NULL. On successful exit, |*inp| is advanced past the DER - * structure. It returns |*out_key| or NULL on error. */ -OPENSSL_EXPORT EC_KEY *o2i_ECPublicKey(EC_KEY **out_key, const uint8_t **inp, - long len); - -/* i2o_ECPublicKey marshals an EC point from |key|. If |outp| is not NULL then - * the result is written to |*outp| and |*outp| is advanced just past the - * output. It returns the number of bytes in the result, whether written or - * not, or a negative value on error. */ -OPENSSL_EXPORT int i2o_ECPublicKey(const EC_KEY *key, unsigned char **outp); - - -/* ex_data functions. - * - * These functions are wrappers. See |ex_data.h| for details. */ - -OPENSSL_EXPORT int EC_KEY_get_ex_new_index(long argl, void *argp, - CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, - CRYPTO_EX_free *free_func); -OPENSSL_EXPORT int EC_KEY_set_ex_data(EC_KEY *r, int idx, void *arg); -OPENSSL_EXPORT void *EC_KEY_get_ex_data(const EC_KEY *r, int idx); - - -/* ECDSA method. */ - -/* ECDSA_FLAG_OPAQUE specifies that this ECDSA_METHOD does not expose its key - * material. This may be set if, for instance, it is wrapping some other crypto - * API, like a platform key store. */ -#define ECDSA_FLAG_OPAQUE 1 - -/* ecdsa_method_st is a structure of function pointers for implementing ECDSA. - * See engine.h. */ -struct ecdsa_method_st { - struct openssl_method_common_st common; - - void *app_data; - - int (*init)(EC_KEY *key); - int (*finish)(EC_KEY *key); - - /* group_order_size returns the number of bytes needed to represent the order - * of the group. This is used to calculate the maximum size of an ECDSA - * signature in |ECDSA_size|. */ - size_t (*group_order_size)(const EC_KEY *key); - - /* sign matches the arguments and behaviour of |ECDSA_sign|. */ - int (*sign)(const uint8_t *digest, size_t digest_len, uint8_t *sig, - unsigned int *sig_len, EC_KEY *eckey); - - /* verify matches the arguments and behaviour of |ECDSA_verify|. */ - int (*verify)(const uint8_t *digest, size_t digest_len, const uint8_t *sig, - size_t sig_len, EC_KEY *eckey); - - int flags; -}; - - -/* Deprecated functions. */ - -/* EC_KEY_set_asn1_flag does nothing. */ -OPENSSL_EXPORT void EC_KEY_set_asn1_flag(EC_KEY *key, int flag); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_EC_KEY_H */ diff --git a/phonelibs/boringssl/include/openssl/ecdh.h b/phonelibs/boringssl/include/openssl/ecdh.h deleted file mode 100644 index 27a85781275ddf..00000000000000 --- a/phonelibs/boringssl/include/openssl/ecdh.h +++ /dev/null @@ -1,103 +0,0 @@ -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * - * The Elliptic Curve Public-Key Crypto Library (ECC Code) included - * herein is developed by SUN MICROSYSTEMS, INC., and is contributed - * to the OpenSSL project. - * - * The ECC Code is licensed pursuant to the OpenSSL open source - * license provided below. - * - * The ECDH software is originally written by Douglas Stebila of - * Sun Microsystems Laboratories. - * - */ -/* ==================================================================== - * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). */ - -#ifndef OPENSSL_HEADER_ECDH_H -#define OPENSSL_HEADER_ECDH_H - -#include - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* Elliptic curve Diffie-Hellman. */ - - -/* ECDH_compute_key calculates the shared key between |pub_key| and |priv_key|. - * If |KDF| is not NULL, then it is called with the bytes of the shared key and - * the parameter |out|. When |KDF| returns, the value of |*outlen| becomes the - * return value. Otherwise, as many bytes of the shared key as will fit are - * copied directly to, at most, |outlen| bytes at |out|. It returns the number - * of bytes written to |out|, or -1 on error. */ -OPENSSL_EXPORT int ECDH_compute_key(void *out, size_t outlen, - const EC_POINT *pub_key, EC_KEY *priv_key, - void *(*KDF)(const void *in, size_t inlen, - void *out, size_t *outlen)); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#define ECDH_F_ECDH_compute_key 100 -#define ECDH_R_KDF_FAILED 100 -#define ECDH_R_NO_PRIVATE_VALUE 101 -#define ECDH_R_POINT_ARITHMETIC_FAILURE 102 - -#endif /* OPENSSL_HEADER_ECDH_H */ diff --git a/phonelibs/boringssl/include/openssl/ecdsa.h b/phonelibs/boringssl/include/openssl/ecdsa.h deleted file mode 100644 index e04546345660c3..00000000000000 --- a/phonelibs/boringssl/include/openssl/ecdsa.h +++ /dev/null @@ -1,182 +0,0 @@ -/* ==================================================================== - * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). */ - -#ifndef OPENSSL_HEADER_ECDSA_H -#define OPENSSL_HEADER_ECDSA_H - -#include - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* ECDSA contains functions for signing and verifying with the Digital Signature - * Algorithm over elliptic curves. */ - - -/* Signing and verifing. */ - -/* ECDSA_sign signs |digest_len| bytes from |digest| with |key| and writes the - * resulting signature to |sig|, which must have |ECDSA_size(key)| bytes of - * space. On successful exit, |*sig_len| is set to the actual number of bytes - * written. The |type| argument should be zero. It returns one on success and - * zero otherwise. */ -OPENSSL_EXPORT int ECDSA_sign(int type, const uint8_t *digest, - size_t digest_len, uint8_t *sig, - unsigned int *sig_len, EC_KEY *key); - -/* ECDSA_verify verifies that |sig_len| bytes from |sig| constitute a valid - * signature by |key| of |digest|. (The |type| argument should be zero.) It - * returns one on success or zero if the signature is invalid or an error - * occured. */ -OPENSSL_EXPORT int ECDSA_verify(int type, const uint8_t *digest, - size_t digest_len, const uint8_t *sig, - size_t sig_len, EC_KEY *key); - -/* ECDSA_size returns the maximum size of an ECDSA signature using |key|. It - * returns zero on error. */ -OPENSSL_EXPORT size_t ECDSA_size(const EC_KEY *key); - - -/* Low-level signing and verification. - * - * Low-level functions handle signatures as |ECDSA_SIG| structures which allow - * the two values in an ECDSA signature to be handled separately. */ - -struct ecdsa_sig_st { - BIGNUM *r; - BIGNUM *s; -}; - -/* ECDSA_SIG_new returns a fresh |ECDSA_SIG| structure or NULL on error. */ -OPENSSL_EXPORT ECDSA_SIG *ECDSA_SIG_new(void); - -/* ECDSA_SIG_free frees |sig| its member |BIGNUM|s. */ -OPENSSL_EXPORT void ECDSA_SIG_free(ECDSA_SIG *sig); - -/* ECDSA_sign signs |digest_len| bytes from |digest| with |key| and returns the - * resulting signature structure, or NULL on error. */ -OPENSSL_EXPORT ECDSA_SIG *ECDSA_do_sign(const uint8_t *digest, - size_t digest_len, EC_KEY *key); - -/* ECDSA_verify verifies that |sig| constitutes a valid signature by |key| of - * |digest|. It returns one on success or zero if the signature is invalid or - * on error. */ -OPENSSL_EXPORT int ECDSA_do_verify(const uint8_t *digest, size_t digest_len, - const ECDSA_SIG *sig, EC_KEY *key); - - -/* Signing with precomputation. - * - * Parts of the ECDSA signature can be independent of the message to be signed - * thus it's possible to precompute them and reduce the signing latency. - * - * TODO(fork): remove support for this as it cannot support safe-randomness. */ - -/* ECDSA_sign_setup precomputes parts of an ECDSA signing operation. It sets - * |*kinv| and |*rp| to the precomputed values and uses the |ctx| argument, if - * not NULL. It returns one on success and zero otherwise. */ -OPENSSL_EXPORT int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, - BIGNUM **rp); - -/* ECDSA_do_sign_ex is the same as |ECDSA_do_sign| but takes precomputed values - * as generated by |ECDSA_sign_setup|. */ -OPENSSL_EXPORT ECDSA_SIG *ECDSA_do_sign_ex(const uint8_t *digest, - size_t digest_len, - const BIGNUM *kinv, const BIGNUM *rp, - EC_KEY *eckey); - -/* ECDSA_sign_ex is the same as |ECDSA_sign| but takes precomputed values as - * generated by |ECDSA_sign_setup|. */ -OPENSSL_EXPORT int ECDSA_sign_ex(int type, const uint8_t *digest, - size_t digest_len, uint8_t *sig, - unsigned int *sig_len, const BIGNUM *kinv, - const BIGNUM *rp, EC_KEY *eckey); - - -/* ASN.1 functions. */ - -/* d2i_ECDSA_SIG parses an ASN.1, DER-encoded, signature from |len| bytes at - * |*inp|. If |out| is not NULL then, on exit, a pointer to the result is in - * |*out|. If |*out| is already non-NULL on entry then the result is written - * directly into |*out|, otherwise a fresh |ECDSA_SIG| is allocated. On - * successful exit, |*inp| is advanced past the DER structure. It returns the - * result or NULL on error. */ -OPENSSL_EXPORT ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **out, const uint8_t **inp, - long len); - -/* i2d_ECDSA_SIG marshals a signature from |sig| to an ASN.1, DER - * structure. If |outp| is not NULL then the result is written to |*outp| and - * |*outp| is advanced just past the output. It returns the number of bytes in - * the result, whether written or not, or a negative value on error. */ -OPENSSL_EXPORT int i2d_ECDSA_SIG(const ECDSA_SIG *sig, uint8_t **outp); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#define ECDSA_F_ECDSA_do_sign_ex 100 -#define ECDSA_F_ECDSA_do_verify 101 -#define ECDSA_F_ECDSA_sign_ex 102 -#define ECDSA_F_digest_to_bn 103 -#define ECDSA_F_ecdsa_sign_setup 104 -#define ECDSA_R_BAD_SIGNATURE 100 -#define ECDSA_R_MISSING_PARAMETERS 101 -#define ECDSA_R_NEED_NEW_SETUP_VALUES 102 -#define ECDSA_R_NOT_IMPLEMENTED 103 -#define ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED 104 - -#endif /* OPENSSL_HEADER_ECDSA_H */ diff --git a/phonelibs/boringssl/include/openssl/engine.h b/phonelibs/boringssl/include/openssl/engine.h deleted file mode 100644 index d3d278a69b77a4..00000000000000 --- a/phonelibs/boringssl/include/openssl/engine.h +++ /dev/null @@ -1,107 +0,0 @@ -/* Copyright (c) 2014, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -#ifndef OPENSSL_HEADER_ENGINE_H -#define OPENSSL_HEADER_ENGINE_H - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* Engines are collections of methods. Methods are tables of function pointers, - * defined for certain algorithms, that allow operations on those algorithms to - * be overridden via a callback. This can be used, for example, to implement an - * RSA* that forwards operations to a hardware module. - * - * Methods are reference counted but |ENGINE|s are not. When creating a method, - * you should zero the whole structure and fill in the function pointers that - * you wish before setting it on an |ENGINE|. Any functions pointers that - * are NULL indicate that the default behaviour should be used. */ - - -/* Allocation and destruction. */ - -/* ENGINE_new returns an empty ENGINE that uses the default method for all - * algorithms. */ -OPENSSL_EXPORT ENGINE *ENGINE_new(void); - -/* ENGINE_free decrements the reference counts for all methods linked from - * |engine| and frees |engine| itself. */ -OPENSSL_EXPORT void ENGINE_free(ENGINE *engine); - - -/* Method accessors. - * - * Method accessors take a method pointer and the size of the structure. The - * size allows for ABI compatibility in the case that the method structure is - * extended with extra elements at the end. Methods are always copied by the - * set functions. - * - * Set functions return one on success and zero on allocation failure. */ - -OPENSSL_EXPORT int ENGINE_set_DH_method(ENGINE *engine, const DH_METHOD *method, - size_t method_size); -OPENSSL_EXPORT DH_METHOD *ENGINE_get_DH_method(const ENGINE *engine); - -OPENSSL_EXPORT int ENGINE_set_DSA_method(ENGINE *engine, - const DSA_METHOD *method, - size_t method_size); -OPENSSL_EXPORT DSA_METHOD *ENGINE_get_DSA_method(const ENGINE *engine); - -OPENSSL_EXPORT int ENGINE_set_RSA_method(ENGINE *engine, - const RSA_METHOD *method, - size_t method_size); -OPENSSL_EXPORT RSA_METHOD *ENGINE_get_RSA_method(const ENGINE *engine); - -OPENSSL_EXPORT int ENGINE_set_ECDSA_method(ENGINE *engine, - const ECDSA_METHOD *method, - size_t method_size); -OPENSSL_EXPORT ECDSA_METHOD *ENGINE_get_ECDSA_method(const ENGINE *engine); - - -/* Generic method functions. - * - * These functions take a void* type but actually operate on all method - * structures. */ - -/* METHOD_ref increments the reference count of |method|. This is a no-op for - * now because all methods are currently static. */ -void METHOD_ref(void *method); - -/* METHOD_unref decrements the reference count of |method| and frees it if the - * reference count drops to zero. This is a no-op for now because all methods - * are currently static. */ -void METHOD_unref(void *method); - - -/* Private functions. */ - -/* openssl_method_common_st contains the common part of all method structures. - * This must be the first member of all method structures. */ -struct openssl_method_common_st { - int references; /* dummy – not used. */ - char is_static; -}; - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#define ENGINE_R_OPERATION_NOT_SUPPORTED 100 - -#endif /* OPENSSL_HEADER_ENGINE_H */ diff --git a/phonelibs/boringssl/include/openssl/err.h b/phonelibs/boringssl/include/openssl/err.h deleted file mode 100644 index 30dc4afe9b9a54..00000000000000 --- a/phonelibs/boringssl/include/openssl/err.h +++ /dev/null @@ -1,509 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ -/* ==================================================================== - * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). */ - -#ifndef OPENSSL_HEADER_ERR_H -#define OPENSSL_HEADER_ERR_H - -#include - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* Error queue handling functions. - * - * Errors in OpenSSL are generally signalled by the return value of a function. - * When a function fails it may add an entry to a per-thread error queue, - * which is managed by the functions in this header. - * - * Each error contains: - * 1) The library (i.e. ec, pem, rsa) which created it. - * 2) A function identifier and reason code. - * 3) The file and line number of the call that added the error. - * 4) A pointer to some error specific data, which may be NULL. - * - * The library identifier, function identifier and reason code are packed in a - * uint32_t and there exist various functions for unpacking it. - * - * The typical behaviour is that an error will occur deep in a call queue and - * that code will push an error onto the error queue. As the error queue - * unwinds, other functions will push their own errors. Thus, the "least - * recent" error is the most specific and the other errors will provide a - * backtrace of sorts. */ - - -/* Startup and shutdown. */ - -/* ERR_load_BIO_strings does nothing. - * - * TODO(fork): remove. libjingle calls this. */ -OPENSSL_EXPORT void ERR_load_BIO_strings(void); - -/* ERR_load_ERR_strings does nothing. */ -OPENSSL_EXPORT void ERR_load_ERR_strings(void); - -/* ERR_load_crypto_strings does nothing. */ -OPENSSL_EXPORT void ERR_load_crypto_strings(void); - -/* ERR_free_strings does nothing. */ -OPENSSL_EXPORT void ERR_free_strings(void); - - -/* Reading and formatting errors. */ - -/* ERR_get_error gets the packed error code for the least recent error and - * removes that error from the queue. If there are no errors in the queue then - * it returns zero. */ -OPENSSL_EXPORT uint32_t ERR_get_error(void); - -/* ERR_get_error_line acts like |ERR_get_error|, except that the file and line - * number of the call that added the error are also returned. */ -OPENSSL_EXPORT uint32_t ERR_get_error_line(const char **file, int *line); - -/* ERR_get_error_line_data acts like |ERR_get_error_line|, but also returns the - * error-specific data pointer and flags. The flags are a bitwise-OR of - * |ERR_FLAG_*| values. The error-specific data is owned by the error queue - * and the pointer becomes invalid after the next call that affects the same - * thread's error queue. If |*flags| contains |ERR_FLAG_STRING| then |*data| is - * human-readable. */ -OPENSSL_EXPORT uint32_t ERR_get_error_line_data(const char **file, int *line, - const char **data, int *flags); - -/* The "peek" functions act like the |ERR_get_error| functions, above, but they - * do not remove the error from the queue. */ -OPENSSL_EXPORT uint32_t ERR_peek_error(void); -OPENSSL_EXPORT uint32_t ERR_peek_error_line(const char **file, int *line); -OPENSSL_EXPORT uint32_t ERR_peek_error_line_data(const char **file, int *line, - const char **data, int *flags); - -/* The "peek last" functions act like the "peek" functions, above, except that - * they return the most recent error. */ -OPENSSL_EXPORT uint32_t ERR_peek_last_error(void); -OPENSSL_EXPORT uint32_t ERR_peek_last_error_line(const char **file, int *line); -OPENSSL_EXPORT uint32_t ERR_peek_last_error_line_data(const char **file, - int *line, - const char **data, - int *flags); - -/* ERR_error_string generates a human-readable string representing - * |packed_error|, places it at |buf| (which must be at least - * ERR_ERROR_STRING_BUF_LEN bytes long) and returns |buf|. If |buf| is NULL, - * the error string is placed in a static buffer which is returned. (The static - * buffer may be overridden by concurrent calls in other threads so this form - * is deprecated.) - * - * The string will have the following format: - * - * error:[error code]:[library name]:[function name]:[reason string] - * - * error code is an 8 digit hexadecimal number; library name, function name - * and reason string are ASCII text. - * - * TODO(fork): remove in favour of |ERR_error_string_n|. */ -OPENSSL_EXPORT char *ERR_error_string(uint32_t packed_error, char *buf); -#define ERR_ERROR_STRING_BUF_LEN 256 - -/* ERR_error_string_n is a variant of |ERR_error_string| that writes at most - * len characters (including the terminating NUL) and truncates the string if - * necessary. If |len| is greater than zero then |buf| is always NUL - * terminated. */ -OPENSSL_EXPORT void ERR_error_string_n(uint32_t packed_error, char *buf, - size_t len); - -/* ERR_lib_error_string returns a string representation of the library that - * generated |packed_error|. */ -OPENSSL_EXPORT const char *ERR_lib_error_string(uint32_t packed_error); - -/* ERR_func_error_string returns a string representation of the function that - * generated |packed_error|. */ -OPENSSL_EXPORT const char *ERR_func_error_string(uint32_t packed_error); - -/* ERR_reason_error_string returns a string representation of the reason for - * |packed_error|. */ -OPENSSL_EXPORT const char *ERR_reason_error_string(uint32_t packed_error); - -/* ERR_print_errors_callback_t is the type of a function used by - * |ERR_print_errors_cb|. It takes a pointer to a human readable string (and - * its length) that describes an entry in the error queue. The |ctx| argument - * is an opaque pointer given to |ERR_print_errors_cb|. - * - * It should return one on success or zero on error, which will stop the - * iteration over the error queue. */ -typedef int (*ERR_print_errors_callback_t)(const char *str, size_t len, - void *ctx); - -/* ERR_print_errors_cb calls |callback| with a string representation of each - * error in the current thread's error queue, from the least recent to the most - * recent error. - * - * The string will have the following format (which differs from - * |ERR_error_string|): - * - * [thread id]:error:[error code]:[library name]:[function name]: - * [reason string]:[file]:[line number]:[optional string data] - * - * (All in one line.) - * - * The callback can return one to continue the iteration or zero to stop it. - * The |ctx| argument is an opaque value that is passed through to the - * callback. */ -OPENSSL_EXPORT void ERR_print_errors_cb(ERR_print_errors_callback_t callback, - void *ctx); - - -/* ERR_print_errors_fp prints the current contents of the error stack to |file| - * using human readable strings where possible. */ -OPENSSL_EXPORT void ERR_print_errors_fp(FILE *file); - -/* Clearing errors. */ - -/* ERR_clear_error clears the error queue for the current thread. */ -OPENSSL_EXPORT void ERR_clear_error(void); - -/* ERR_remove_thread_state clears the error queue for the current thread if - * |tid| is NULL. Otherwise it calls |assert(0)|, because it's no longer - * possible to delete the error queue for other threads. - * - * Error queues are thread-local data and are deleted automatically. You do not - * need to call this function. Use |ERR_clear_error|. */ -OPENSSL_EXPORT void ERR_remove_thread_state(const CRYPTO_THREADID *tid); - - -/* Custom errors. */ - -/* ERR_get_next_error_library returns a value suitable for passing as the - * |library| argument to |ERR_put_error|. This is intended for code that wishes - * to push its own, non-standard errors to the error queue. */ -OPENSSL_EXPORT int ERR_get_next_error_library(void); - - -/* Deprecated functions. */ - -/* |ERR_remove_state| calls |ERR_clear_error|. */ -OPENSSL_EXPORT void ERR_remove_state(unsigned long pid); - - -/* Private functions. */ - -/* ERR_clear_system_error clears the system's error value (i.e. errno). */ -OPENSSL_EXPORT void ERR_clear_system_error(void); - -/* OPENSSL_PUT_ERROR is used by OpenSSL code to add an error to the error - * queue. */ -#define OPENSSL_PUT_ERROR(library, func, reason) \ - ERR_put_error(ERR_LIB_##library, library##_F_##func, reason, __FILE__, \ - __LINE__) - -/* OPENSSL_PUT_SYSTEM_ERROR is used by OpenSSL code to add an error from the - * operating system to the error queue. */ -/* TODO(fork): include errno. */ -#define OPENSSL_PUT_SYSTEM_ERROR(func) \ - ERR_put_error(ERR_LIB_SYS, SYS_F_##func, 0, __FILE__, __LINE__); - -/* ERR_put_error adds an error to the error queue, dropping the least recent - * error if neccessary for space reasons. */ -OPENSSL_EXPORT void ERR_put_error(int library, int func, int reason, - const char *file, unsigned line); - -/* ERR_add_error_data takes a variable number (|count|) of const char* - * pointers, concatenates them and sets the result as the data on the most - * recent error. */ -OPENSSL_EXPORT void ERR_add_error_data(unsigned count, ...); - -/* ERR_add_error_dataf takes a printf-style format and arguments, and sets the - * result as the data on the most recent error. */ -OPENSSL_EXPORT void ERR_add_error_dataf(const char *format, ...); - -/* ERR_set_mark "marks" the most recent error for use with |ERR_pop_to_mark|. - * It returns one if an error was marked and zero if there are no errors. */ -OPENSSL_EXPORT int ERR_set_mark(void); - -/* ERR_pop_to_mark removes errors from the most recent to the least recent - * until (and not including) a "marked" error. It returns zero if no marked - * error was found (and thus all errors were removed) and one otherwise. Errors - * are marked using |ERR_set_mark|. */ -OPENSSL_EXPORT int ERR_pop_to_mark(void); - -struct err_error_st { - /* file contains the filename where the error occured. */ - const char *file; - /* data contains optional data. It must be freed with |OPENSSL_free| if - * |flags&ERR_FLAG_MALLOCED|. */ - char *data; - /* packed contains the error library, function and reason, as packed by - * ERR_PACK. */ - uint32_t packed; - /* line contains the line number where the error occured. */ - uint16_t line; - /* flags contains a bitwise-OR of ERR_FLAG_* values. */ - uint8_t flags; -}; - -/* ERR_FLAG_STRING means that the |data| member is a NUL-terminated string that - * can be printed. */ -#define ERR_FLAG_STRING 1 -/* ERR_TXT_STRING is provided for compatibility with code that assumes that - * it's using OpenSSL. */ -#define ERR_TXT_STRING ERR_FLAG_STRING - -/* ERR_FLAG_PUBLIC_MASK is applied to the flags field before it is returned - * from functions like |ERR_get_error_line_data|. */ -#define ERR_FLAG_PUBLIC_MASK 0xf - -/* The following flag values are internal and are masked when flags are - * returned from functions like |ERR_get_error_line_data|. */ - -/* ERR_FLAG_MALLOCED means the the |data| member must be freed when no longer - * needed. */ -#define ERR_FLAG_MALLOCED 16 -/* ERR_FLAG_MARK is used to indicate a reversion point in the queue. See - * |ERR_pop_to_mark|. */ -#define ERR_FLAG_MARK 32 - -/* ERR_NUM_ERRORS is the limit of the number of errors in the queue. */ -#define ERR_NUM_ERRORS 16 - -/* ERR_STATE contains the per-thread, error queue. */ -typedef struct err_state_st { - /* errors contains the ERR_NUM_ERRORS most recent errors, organised as a ring - * buffer. */ - struct err_error_st errors[ERR_NUM_ERRORS]; - /* top contains the index one past the most recent error. If |top| equals - * |bottom| then the queue is empty. */ - unsigned top; - /* bottom contains the index of the last error in the queue. */ - unsigned bottom; - - /* to_free, if not NULL, contains a pointer owned by this structure that was - * previously a |data| pointer of one of the elements of |errors|. */ - void *to_free; -} ERR_STATE; - -enum { - ERR_LIB_NONE = 1, - ERR_LIB_SYS, - ERR_LIB_BN, - ERR_LIB_RSA, - ERR_LIB_DH, - ERR_LIB_EVP, - ERR_LIB_BUF, - ERR_LIB_OBJ, - ERR_LIB_PEM, - ERR_LIB_DSA, - ERR_LIB_X509, - ERR_LIB_ASN1, - ERR_LIB_CONF, - ERR_LIB_CRYPTO, - ERR_LIB_EC, - ERR_LIB_SSL, - ERR_LIB_BIO, - ERR_LIB_PKCS7, - ERR_LIB_PKCS8, - ERR_LIB_X509V3, - ERR_LIB_RAND, - ERR_LIB_ENGINE, - ERR_LIB_OCSP, - ERR_LIB_UI, - ERR_LIB_COMP, - ERR_LIB_ECDSA, - ERR_LIB_ECDH, - ERR_LIB_HMAC, - ERR_LIB_DIGEST, - ERR_LIB_CIPHER, - ERR_LIB_USER, - ERR_LIB_HKDF, - ERR_NUM_LIBS -}; - -#define ERR_R_SYS_LIB ERR_LIB_SYS -#define ERR_R_BN_LIB ERR_LIB_BN -#define ERR_R_RSA_LIB ERR_LIB_RSA -#define ERR_R_DH_LIB ERR_LIB_DH -#define ERR_R_EVP_LIB ERR_LIB_EVP -#define ERR_R_BUF_LIB ERR_LIB_BUF -#define ERR_R_OBJ_LIB ERR_LIB_OBJ -#define ERR_R_PEM_LIB ERR_LIB_PEM -#define ERR_R_DSA_LIB ERR_LIB_DSA -#define ERR_R_X509_LIB ERR_LIB_X509 -#define ERR_R_ASN1_LIB ERR_LIB_ASN1 -#define ERR_R_CONF_LIB ERR_LIB_CONF -#define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO -#define ERR_R_EC_LIB ERR_LIB_EC -#define ERR_R_SSL_LIB ERR_LIB_SSL -#define ERR_R_BIO_LIB ERR_LIB_BIO -#define ERR_R_PKCS7_LIB ERR_LIB_PKCS7 -#define ERR_R_PKCS8_LIB ERR_LIB_PKCS8 -#define ERR_R_X509V3_LIB ERR_LIB_X509V3 -#define ERR_R_RAND_LIB ERR_LIB_RAND -#define ERR_R_DSO_LIB ERR_LIB_DSO -#define ERR_R_ENGINE_LIB ERR_LIB_ENGINE -#define ERR_R_OCSP_LIB ERR_LIB_OCSP -#define ERR_R_UI_LIB ERR_LIB_UI -#define ERR_R_COMP_LIB ERR_LIB_COMP -#define ERR_R_ECDSA_LIB ERR_LIB_ECDSA -#define ERR_R_ECDH_LIB ERR_LIB_ECDH -#define ERR_R_STORE_LIB ERR_LIB_STORE -#define ERR_R_FIPS_LIB ERR_LIB_FIPS -#define ERR_R_CMS_LIB ERR_LIB_CMS -#define ERR_R_TS_LIB ERR_LIB_TS -#define ERR_R_HMAC_LIB ERR_LIB_HMAC -#define ERR_R_JPAKE_LIB ERR_LIB_JPAKE -#define ERR_R_USER_LIB ERR_LIB_USER -#define ERR_R_DIGEST_LIB ERR_LIB_DIGEST -#define ERR_R_CIPHER_LIB ERR_LIB_CIPHER -#define ERR_R_HKDF_LIB ERR_LIB_HKDF - -/* Global reasons. */ -#define ERR_R_FATAL 64 -#define ERR_R_MALLOC_FAILURE (1 | ERR_R_FATAL) -#define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2 | ERR_R_FATAL) -#define ERR_R_PASSED_NULL_PARAMETER (3 | ERR_R_FATAL) -#define ERR_R_INTERNAL_ERROR (4 | ERR_R_FATAL) -#define ERR_R_OVERFLOW (5 | ERR_R_FATAL) - -/* System error functions */ -#define SYS_F_fopen 100 -#define SYS_F_fclose 101 -#define SYS_F_fread 102 -#define SYS_F_fwrite 103 -#define SYS_F_socket 104 -#define SYS_F_setsockopt 105 -#define SYS_F_connect 106 -#define SYS_F_getaddrinfo 107 - -#define ERR_PACK(lib, func, reason) \ - (((((uint32_t)lib) & 0xff) << 24) | ((((uint32_t)func) & 0xfff) << 12) | \ - ((((uint32_t)reason) & 0xfff))) - -#define ERR_GET_LIB(packed_error) ((int)(((packed_error) >> 24) & 0xff)) -#define ERR_GET_FUNC(packed_error) ((int)(((packed_error) >> 12) & 0xfff)) -#define ERR_GET_REASON(packed_error) ((int)((packed_error) & 0xfff)) - -/* OPENSSL_DECLARE_ERROR_REASON is used by util/make_errors.h (which generates - * the error defines) to recognise that an additional reason value is needed. - * This is needed when the reason value is used outside of an - * |OPENSSL_PUT_ERROR| macro. The resulting define will be - * ${lib}_R_${reason}. */ -#define OPENSSL_DECLARE_ERROR_REASON(lib, reason) - -/* OPENSSL_DECLARE_ERROR_FUNCTION is used by util/make_errors.h (which - * generates the error * defines to recognise that an additional function value - * is needed. This is * needed when the function value is used outside of an - * |OPENSSL_PUT_ERROR| * macro. The resulting define will be - * ${lib}_F_${reason}. */ -#define OPENSSL_DECLARE_ERROR_FUNCTION(lib, function_name) - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_ERR_H */ diff --git a/phonelibs/boringssl/include/openssl/evp.h b/phonelibs/boringssl/include/openssl/evp.h deleted file mode 100644 index 490a9514c33281..00000000000000 --- a/phonelibs/boringssl/include/openssl/evp.h +++ /dev/null @@ -1,826 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_EVP_H -#define OPENSSL_HEADER_EVP_H - -#include - -#include - -/* OpenSSL included digest and cipher functions in this header so we include - * them for users that still expect that. - * - * TODO(fork): clean up callers so that they include what they use. */ -#include -#include -#include -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* EVP abstracts over public/private key algorithms. */ - - -/* Public key objects. */ - -/* EVP_PKEY_new creates a new, empty public-key object and returns it or NULL - * on allocation failure. */ -OPENSSL_EXPORT EVP_PKEY *EVP_PKEY_new(void); - -/* EVP_PKEY_free frees all data referenced by |pkey| and then frees |pkey| - * itself. */ -OPENSSL_EXPORT void EVP_PKEY_free(EVP_PKEY *pkey); - -/* EVP_PKEY_up_ref increments the reference count of |pkey| and returns it. */ -OPENSSL_EXPORT EVP_PKEY *EVP_PKEY_up_ref(EVP_PKEY *pkey); - -/* EVP_PKEY_is_opaque returns one if |pkey| is opaque. Opaque keys are backed by - * custom implementations which do not expose key material and parameters. It is - * an error to attempt to duplicate, export, or compare an opaque key. */ -OPENSSL_EXPORT int EVP_PKEY_is_opaque(const EVP_PKEY *pkey); - -/* EVP_PKEY_supports_digest returns one if |pkey| supports digests of - * type |md|. This is intended for use with EVP_PKEYs backing custom - * implementations which can't sign all digests. */ -OPENSSL_EXPORT int EVP_PKEY_supports_digest(const EVP_PKEY *pkey, - const EVP_MD *md); - -/* EVP_PKEY_cmp compares |a| and |b| and returns one if they are equal, zero if - * not and a negative number on error. - * - * WARNING: this differs from the traditional return value of a "cmp" - * function. */ -OPENSSL_EXPORT int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b); - -/* EVP_PKEY_copy_parameters sets the parameters of |to| to equal the parameters - * of |from|. It returns one on success and zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from); - -/* EVP_PKEY_missing_parameters returns one if |pkey| is missing needed - * parameters or zero if not, or if the algorithm doesn't take parameters. */ -OPENSSL_EXPORT int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey); - -/* EVP_PKEY_size returns the maximum size, in bytes, of a signature signed by - * |pkey|. For an RSA key, this returns the number of bytes needed to represent - * the modulus. For an EC key, this returns the maximum size of a DER-encoded - * ECDSA signature. */ -OPENSSL_EXPORT int EVP_PKEY_size(const EVP_PKEY *pkey); - -/* EVP_PKEY_bits returns the "size", in bits, of |pkey|. For an RSA key, this - * returns the bit length of the modulus. For an EC key, this returns the bit - * length of the group order. */ -OPENSSL_EXPORT int EVP_PKEY_bits(EVP_PKEY *pkey); - -/* EVP_PKEY_id returns the type of |pkey|, which is one of the |EVP_PKEY_*| - * values. */ -OPENSSL_EXPORT int EVP_PKEY_id(const EVP_PKEY *pkey); - -/* EVP_PKEY_type returns a canonicalised form of |NID|. For example, - * |EVP_PKEY_RSA2| will be turned into |EVP_PKEY_RSA|. */ -OPENSSL_EXPORT int EVP_PKEY_type(int nid); - -/* Deprecated: EVP_PKEY_new_mac_key allocates a fresh |EVP_PKEY| of the given - * type (e.g. |EVP_PKEY_HMAC|), sets |mac_key| as the MAC key and "generates" a - * new key, suitable for signing. It returns the fresh |EVP_PKEY|, or NULL on - * error. Use |HMAC_CTX| directly instead. */ -OPENSSL_EXPORT EVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *engine, - const uint8_t *mac_key, - size_t mac_key_len); - - -/* Getting and setting concrete public key types. - * - * The following functions get and set the underlying public key in an - * |EVP_PKEY| object. The |set1| functions take an additional reference to the - * underlying key and return one on success or zero on error. The |assign| - * functions adopt the caller's reference. The getters return a fresh reference - * to the underlying object. */ - -OPENSSL_EXPORT int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key); -OPENSSL_EXPORT int EVP_PKEY_assign_RSA(EVP_PKEY *pkey, RSA *key); -OPENSSL_EXPORT RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey); - -OPENSSL_EXPORT int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, struct dsa_st *key); -OPENSSL_EXPORT int EVP_PKEY_assign_DSA(EVP_PKEY *pkey, DSA *key); -OPENSSL_EXPORT struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey); - -OPENSSL_EXPORT int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key); -OPENSSL_EXPORT int EVP_PKEY_assign_EC_KEY(EVP_PKEY *pkey, EC_KEY *key); -OPENSSL_EXPORT struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey); - -OPENSSL_EXPORT int EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key); -OPENSSL_EXPORT int EVP_PKEY_assign_DH(EVP_PKEY *pkey, DH *key); -OPENSSL_EXPORT struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey); - -#define EVP_PKEY_NONE NID_undef -#define EVP_PKEY_RSA NID_rsaEncryption -#define EVP_PKEY_RSA2 NID_rsa -#define EVP_PKEY_DSA NID_dsa -#define EVP_PKEY_DH NID_dhKeyAgreement -#define EVP_PKEY_DHX NID_dhpublicnumber -#define EVP_PKEY_EC NID_X9_62_id_ecPublicKey - -/* Deprecated: Use |HMAC_CTX| directly instead. */ -#define EVP_PKEY_HMAC NID_hmac - -/* EVP_PKEY_assign sets the underlying key of |pkey| to |key|, which must be of - * the given type. The |type| argument should be one of the |EVP_PKEY_*| - * values. */ -OPENSSL_EXPORT int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key); - -/* EVP_PKEY_set_type sets the type of |pkey| to |type|, which should be one of - * the |EVP_PKEY_*| values. It returns one if sucessful or zero otherwise. If - * |pkey| is NULL, it simply reports whether the type is known. */ -OPENSSL_EXPORT int EVP_PKEY_set_type(EVP_PKEY *pkey, int type); - -/* EVP_PKEY_cmp_parameters compares the parameters of |a| and |b|. It returns - * one if they match, zero if not, or a negative number of on error. - * - * WARNING: the return value differs from the usual return value convention. */ -OPENSSL_EXPORT int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, - const EVP_PKEY *b); - - -/* ASN.1 functions */ - -/* d2i_PrivateKey parses an ASN.1, DER-encoded, private key from |len| bytes at - * |*inp|. If |out| is not NULL then, on exit, a pointer to the result is in - * |*out|. If |*out| is already non-NULL on entry then the result is written - * directly into |*out|, otherwise a fresh |EVP_PKEY| is allocated. On - * successful exit, |*inp| is advanced past the DER structure. It returns the - * result or NULL on error. */ -OPENSSL_EXPORT EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **out, - const uint8_t **inp, long len); - -/* d2i_AutoPrivateKey acts the same as |d2i_PrivateKey|, but detects the type - * of the private key. */ -OPENSSL_EXPORT EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **out, const uint8_t **inp, - long len); - -/* i2d_PrivateKey marshals a private key from |key| to an ASN.1, DER - * structure. If |outp| is not NULL then the result is written to |*outp| and - * |*outp| is advanced just past the output. It returns the number of bytes in - * the result, whether written or not, or a negative value on error. */ -OPENSSL_EXPORT int i2d_PrivateKey(const EVP_PKEY *key, uint8_t **outp); - -/* i2d_PublicKey marshals a public key from |key| to an ASN.1, DER - * structure. If |outp| is not NULL then the result is written to |*outp| and - * |*outp| is advanced just past the output. It returns the number of bytes in - * the result, whether written or not, or a negative value on error. */ -OPENSSL_EXPORT int i2d_PublicKey(EVP_PKEY *key, uint8_t **outp); - - -/* Signing */ - -/* EVP_DigestSignInit sets up |ctx| for a signing operation with |type| and - * |pkey|. The |ctx| argument must have been initialised with - * |EVP_MD_CTX_init|. If |pctx| is not NULL, the |EVP_PKEY_CTX| of the signing - * operation will be written to |*pctx|; this can be used to set alternative - * signing options. - * - * It returns one on success, or zero on error. */ -OPENSSL_EXPORT int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, - const EVP_MD *type, ENGINE *e, - EVP_PKEY *pkey); - -/* EVP_DigestSignUpdate appends |len| bytes from |data| to the data which will - * be signed in |EVP_DigestSignFinal|. It returns one. */ -OPENSSL_EXPORT int EVP_DigestSignUpdate(EVP_MD_CTX *ctx, const void *data, - size_t len); - -/* EVP_DigestSignFinal signs the data that has been included by one or more - * calls to |EVP_DigestSignUpdate|. If |out_sig| is NULL then |*out_sig_len| is - * set to the maximum number of output bytes. Otherwise, on entry, - * |*out_sig_len| must contain the length of the |out_sig| buffer. If the call - * is successful, the signature is written to |out_sig| and |*out_sig_len| is - * set to its length. - * - * It returns one on success, or zero on error. */ -OPENSSL_EXPORT int EVP_DigestSignFinal(EVP_MD_CTX *ctx, uint8_t *out_sig, - size_t *out_sig_len); - -/* EVP_DigestSignAlgorithm encodes the signing parameters of |ctx| as an - * AlgorithmIdentifer and saves the result in |algor|. - * - * It returns one on success, or zero on error. - * - * TODO(davidben): This API should eventually lose the dependency on - * crypto/asn1/. */ -OPENSSL_EXPORT int EVP_DigestSignAlgorithm(EVP_MD_CTX *ctx, X509_ALGOR *algor); - - -/* Verifying */ - -/* EVP_DigestVerifyInit sets up |ctx| for a signature verification operation - * with |type| and |pkey|. The |ctx| argument must have been initialised with - * |EVP_MD_CTX_init|. If |pctx| is not NULL, the |EVP_PKEY_CTX| of the signing - * operation will be written to |*pctx|; this can be used to set alternative - * signing options. - * - * It returns one on success, or zero on error. */ -OPENSSL_EXPORT int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, - const EVP_MD *type, ENGINE *e, - EVP_PKEY *pkey); - -/* EVP_DigestVerifyInitFromAlgorithm sets up |ctx| for a signature verification - * operation with public key |pkey| and parameters from |algor|. The |ctx| - * argument must have been initialised with |EVP_MD_CTX_init|. - * - * It returns one on success, or zero on error. - * - * TODO(davidben): This API should eventually lose the dependency on - * crypto/asn1/. */ -OPENSSL_EXPORT int EVP_DigestVerifyInitFromAlgorithm(EVP_MD_CTX *ctx, - X509_ALGOR *algor, - EVP_PKEY *pkey); - -/* EVP_DigestVerifyUpdate appends |len| bytes from |data| to the data which - * will be verified by |EVP_DigestVerifyFinal|. It returns one. */ -OPENSSL_EXPORT int EVP_DigestVerifyUpdate(EVP_MD_CTX *ctx, const void *data, - size_t len); - -/* EVP_DigestVerifyFinal verifies that |sig_len| bytes of |sig| are a valid - * signature for the data that has been included by one or more calls to - * |EVP_DigestVerifyUpdate|. It returns one on success and zero otherwise. */ -OPENSSL_EXPORT int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const uint8_t *sig, - size_t sig_len); - - -/* Signing (old functions) */ - -/* EVP_SignInit_ex configures |ctx|, which must already have been initialised, - * for a fresh signing operation using the hash function |type|. It returns one - * on success and zero otherwise. - * - * (In order to initialise |ctx|, either obtain it initialised with - * |EVP_MD_CTX_create|, or use |EVP_MD_CTX_init|.) */ -OPENSSL_EXPORT int EVP_SignInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, - ENGINE *impl); - -/* EVP_SignInit is a deprecated version of |EVP_SignInit_ex|. - * - * TODO(fork): remove. */ -OPENSSL_EXPORT int EVP_SignInit(EVP_MD_CTX *ctx, const EVP_MD *type); - -/* EVP_SignUpdate appends |len| bytes from |data| to the data which will be - * signed in |EVP_SignFinal|. */ -OPENSSL_EXPORT int EVP_SignUpdate(EVP_MD_CTX *ctx, const void *data, - size_t len); - -/* EVP_SignFinal signs the data that has been included by one or more calls to - * |EVP_SignUpdate|, using the key |pkey|, and writes it to |sig|. On entry, - * |sig| must point to at least |EVP_PKEY_size(pkey)| bytes of space. The - * actual size of the signature is written to |*out_sig_len|. - * - * It returns one on success and zero otherwise. - * - * It does not modify |ctx|, thus it's possible to continue to use |ctx| in - * order to sign a longer message. */ -OPENSSL_EXPORT int EVP_SignFinal(const EVP_MD_CTX *ctx, uint8_t *sig, - unsigned int *out_sig_len, EVP_PKEY *pkey); - - -/* Verifying (old functions) */ - -/* EVP_VerifyInit_ex configures |ctx|, which must already have been - * initialised, for a fresh signature verification operation using the hash - * function |type|. It returns one on success and zero otherwise. - * - * (In order to initialise |ctx|, either obtain it initialised with - * |EVP_MD_CTX_create|, or use |EVP_MD_CTX_init|.) */ -OPENSSL_EXPORT int EVP_VerifyInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, - ENGINE *impl); - -/* EVP_VerifyInit is a deprecated version of |EVP_VerifyInit_ex|. - * - * TODO(fork): remove. */ -OPENSSL_EXPORT int EVP_VerifyInit(EVP_MD_CTX *ctx, const EVP_MD *type); - -/* EVP_VerifyUpdate appends |len| bytes from |data| to the data which will be - * signed in |EVP_VerifyFinal|. */ -OPENSSL_EXPORT int EVP_VerifyUpdate(EVP_MD_CTX *ctx, const void *data, - size_t len); - -/* EVP_VerifyFinal verifies that |sig_len| bytes of |sig| are a valid - * signature, by |pkey|, for the data that has been included by one or more - * calls to |EVP_VerifyUpdate|. - * - * It returns one on success and zero otherwise. - * - * It does not modify |ctx|, thus it's possible to continue to use |ctx| in - * order to sign a longer message. */ -OPENSSL_EXPORT int EVP_VerifyFinal(EVP_MD_CTX *ctx, const uint8_t *sig, - size_t sig_len, EVP_PKEY *pkey); - - -/* Printing */ - -/* EVP_PKEY_print_public prints a textual representation of the public key in - * |pkey| to |out|. Returns one on success or zero otherwise. */ -OPENSSL_EXPORT int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey, - int indent, ASN1_PCTX *pctx); - -/* EVP_PKEY_print_public prints a textual representation of the private key in - * |pkey| to |out|. Returns one on success or zero otherwise. */ -OPENSSL_EXPORT int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey, - int indent, ASN1_PCTX *pctx); - -/* EVP_PKEY_print_public prints a textual representation of the parameters in - * |pkey| to |out|. Returns one on success or zero otherwise. */ -OPENSSL_EXPORT int EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey, - int indent, ASN1_PCTX *pctx); - - -/* Password stretching. - * - * Password stretching functions take a low-entropy password and apply a slow - * function that results in a key suitable for use in symmetric - * cryptography. */ - -/* PKCS5_PBKDF2_HMAC computes |iterations| iterations of PBKDF2 of |password| - * and |salt|, using |digest|, and outputs |key_len| bytes to |out_key|. It - * returns one on success and zero on error. */ -OPENSSL_EXPORT int PKCS5_PBKDF2_HMAC(const char *password, size_t password_len, - const uint8_t *salt, size_t salt_len, - unsigned iterations, const EVP_MD *digest, - size_t key_len, uint8_t *out_key); - -/* PKCS5_PBKDF2_HMAC_SHA1 is the same as PKCS5_PBKDF2_HMAC, but with |digest| - * fixed to |EVP_sha1|. */ -OPENSSL_EXPORT int PKCS5_PBKDF2_HMAC_SHA1(const char *password, - size_t password_len, const uint8_t *salt, - size_t salt_len, unsigned iterations, - size_t key_len, uint8_t *out_key); - - -/* Public key contexts. - * - * |EVP_PKEY_CTX| objects hold the context of an operation (e.g. signing or - * encrypting) that uses a public key. */ - -/* EVP_PKEY_CTX_new allocates a fresh |EVP_PKEY_CTX| for use with |pkey|. It - * returns the context or NULL on error. */ -OPENSSL_EXPORT EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e); - -/* EVP_PKEY_CTX_new allocates a fresh |EVP_PKEY_CTX| for a key of type |id| - * (e.g. |EVP_PKEY_HMAC|). This can be used for key generation where - * |EVP_PKEY_CTX_new| can't be used because there isn't an |EVP_PKEY| to pass - * it. It returns the context or NULL on error. */ -OPENSSL_EXPORT EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e); - -/* EVP_KEY_CTX_free frees |ctx| and the data it owns. */ -OPENSSL_EXPORT void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx); - -/* EVP_PKEY_CTX_dup allocates a fresh |EVP_PKEY_CTX| and sets it equal to the - * state of |ctx|. It returns the fresh |EVP_PKEY_CTX| or NULL on error. */ -OPENSSL_EXPORT EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *ctx); - -/* EVP_PKEY_CTX_get0_pkey returns the |EVP_PKEY| associated with |ctx|. */ -OPENSSL_EXPORT EVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx); - -/* EVP_PKEY_CTX_set_app_data sets an opaque pointer on |ctx|. */ -OPENSSL_EXPORT void EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data); - -/* EVP_PKEY_CTX_get_app_data returns the opaque pointer from |ctx| that was - * previously set with |EVP_PKEY_CTX_set_app_data|, or NULL if none has been - * set. */ -OPENSSL_EXPORT void *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx); - -/* EVP_PKEY_sign_init initialises an |EVP_PKEY_CTX| for a signing operation. It - * should be called before |EVP_PKEY_sign|. - * - * It returns one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx); - -/* EVP_PKEY_sign signs |data_len| bytes from |data| using |ctx|. If |sig| is - * NULL, the maximum size of the signature is written to - * |out_sig_len|. Otherwise, |*sig_len| must contain the number of bytes of - * space available at |sig|. If sufficient, the signature will be written to - * |sig| and |*sig_len| updated with the true length. - * - * WARNING: Setting |sig| to NULL only gives the maximum size of the - * signature. The actual signature may be smaller. - * - * It returns one on success or zero on error. (Note: this differs from - * OpenSSL, which can also return negative values to indicate an error. ) */ -OPENSSL_EXPORT int EVP_PKEY_sign(EVP_PKEY_CTX *ctx, uint8_t *sig, - size_t *sig_len, const uint8_t *data, - size_t data_len); - -/* EVP_PKEY_verify_init initialises an |EVP_PKEY_CTX| for a signature - * verification operation. It should be called before |EVP_PKEY_verify|. - * - * It returns one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx); - -/* EVP_PKEY_verify verifies that |sig_len| bytes from |sig| are a valid signature - * for |data|. - * - * It returns one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_verify(EVP_PKEY_CTX *ctx, const uint8_t *sig, - size_t sig_len, const uint8_t *data, - size_t data_len); - -/* EVP_PKEY_encrypt_init initialises an |EVP_PKEY_CTX| for an encryption - * operation. It should be called before |EVP_PKEY_encrypt|. - * - * It returns one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx); - -/* EVP_PKEY_encrypt encrypts |in_len| bytes from |in|. If |out| is NULL, the - * maximum size of the ciphertext is written to |out_len|. Otherwise, |*out_len| - * must contain the number of bytes of space available at |out|. If sufficient, - * the ciphertext will be written to |out| and |*out_len| updated with the true - * length. - * - * WARNING: Setting |out| to NULL only gives the maximum size of the - * ciphertext. The actual ciphertext may be smaller. - * - * It returns one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx, uint8_t *out, - size_t *out_len, const uint8_t *in, - size_t in_len); - -/* EVP_PKEY_decrypt_init initialises an |EVP_PKEY_CTX| for a decryption - * operation. It should be called before |EVP_PKEY_decrypt|. - * - * It returns one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx); - -/* EVP_PKEY_decrypt decrypts |in_len| bytes from |in|. If |out| is NULL, the - * maximum size of the plaintext is written to |out_len|. Otherwise, |*out_len| - * must contain the number of bytes of space available at |out|. If sufficient, - * the ciphertext will be written to |out| and |*out_len| updated with the true - * length. - * - * WARNING: Setting |out| to NULL only gives the maximum size of the - * plaintext. The actual plaintext may be smaller. - * - * It returns one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx, uint8_t *out, - size_t *out_len, const uint8_t *in, - size_t in_len); - -/* EVP_PKEY_derive_init initialises an |EVP_PKEY_CTX| for a key derivation - * operation. It should be called before |EVP_PKEY_derive_set_peer| and - * |EVP_PKEY_derive|. - * - * It returns one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx); - -/* EVP_PKEY_derive_set_peer sets the peer's key to be used for key derivation - * by |ctx| to |peer|. It should be called after |EVP_PKEY_derive_init|. (For - * example, this is used to set the peer's key in (EC)DH.) It returns one on - * success and zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer); - -/* EVP_PKEY_derive derives a shared key between the two keys configured in - * |ctx|. If |key| is non-NULL then, on entry, |out_key_len| must contain the - * amount of space at |key|. If sufficient then the shared key will be written - * to |key| and |*out_key_len| will be set to the length. If |key| is NULL then - * |out_key_len| will be set to the maximum length. - * - * WARNING: Setting |out| to NULL only gives the maximum size of the key. The - * actual key may be smaller. - * - * It returns one on success and zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_derive(EVP_PKEY_CTX *ctx, uint8_t *key, - size_t *out_key_len); - -/* EVP_PKEY_keygen_init initialises an |EVP_PKEY_CTX| for a key generation - * operation. It should be called before |EVP_PKEY_keygen|. - * - * It returns one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx); - -/* EVP_PKEY_keygen performs a key generation operation using the values from - * |ctx| and sets |*ppkey| to a fresh |EVP_PKEY| containing the resulting key. - * It returns one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey); - - -/* Generic control functions. */ - -/* EVP_PKEY_CTX_set_signature_md sets |md| as the digest to be used in a - * signature operation. It returns one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_CTX_set_signature_md(EVP_PKEY_CTX *ctx, - const EVP_MD *md); - -/* EVP_PKEY_CTX_get_signature_md sets |*out_md| to the digest to be used in a - * signature operation. It returns one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_CTX_get_signature_md(EVP_PKEY_CTX *ctx, - const EVP_MD **out_md); - - -/* RSA specific control functions. */ - -/* EVP_PKEY_CTX_set_rsa_padding sets the padding type to use. It should be one - * of the |RSA_*_PADDING| values. Returns one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_CTX_set_rsa_padding(EVP_PKEY_CTX *ctx, int padding); - -/* EVP_PKEY_CTX_get_rsa_padding sets |*out_padding| to the current padding - * value, which is one of the |RSA_*_PADDING| values. Returns one on success or - * zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_CTX_get_rsa_padding(EVP_PKEY_CTX *ctx, - int *out_padding); - -/* EVP_PKEY_CTX_set_rsa_pss_saltlen sets the length of the salt in a PSS-padded - * signature. A value of -1 cause the salt to be the same length as the digest - * in the signature. A value of -2 causes the salt to be the maximum length - * that will fit. Otherwise the value gives the size of the salt in bytes. - * - * Returns one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_CTX_set_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, - int salt_len); - -/* EVP_PKEY_CTX_get_rsa_pss_saltlen sets |*out_salt_len| to the salt length of - * a PSS-padded signature. See the documentation for - * |EVP_PKEY_CTX_set_rsa_pss_saltlen| for details of the special values that it - * can take. - * - * Returns one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_CTX_get_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, - int *out_salt_len); - -/* EVP_PKEY_CTX_set_rsa_keygen_bits sets the size of the desired RSA modulus, - * in bits, for key generation. Returns one on success or zero on - * error. */ -OPENSSL_EXPORT int EVP_PKEY_CTX_set_rsa_keygen_bits(EVP_PKEY_CTX *ctx, - int bits); - -/* EVP_PKEY_CTX_set_rsa_keygen_pubexp sets |e| as the public exponent for key - * generation. Returns one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_CTX_set_rsa_keygen_pubexp(EVP_PKEY_CTX *ctx, - BIGNUM *e); - -/* EVP_PKEY_CTX_set_rsa_oaep_md sets |md| as the digest used in OAEP padding. - * Returns one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_CTX_set_rsa_oaep_md(EVP_PKEY_CTX *ctx, - const EVP_MD *md); - -/* EVP_PKEY_CTX_get_rsa_oaep_md sets |*out_md| to the digest function used in - * OAEP padding. Returns one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_CTX_get_rsa_oaep_md(EVP_PKEY_CTX *ctx, - const EVP_MD **out_md); - -/* EVP_PKEY_CTX_set_rsa_mgf1_md sets |md| as the digest used in MGF1. Returns - * one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_CTX_set_rsa_mgf1_md(EVP_PKEY_CTX *ctx, - const EVP_MD *md); - -/* EVP_PKEY_CTX_get_rsa_mgf1_md sets |*out_md| to the digest function used in - * MGF1. Returns one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_CTX_get_rsa_mgf1_md(EVP_PKEY_CTX *ctx, - const EVP_MD **out_md); - -/* EVP_PKEY_CTX_set0_rsa_oaep_label sets |label_len| bytes from |label| as the - * label used in OAEP. DANGER: On success, this call takes ownership of |label| - * and will call |OPENSSL_free| on it when |ctx| is destroyed. - * - * Returns one on success or zero on error. */ -OPENSSL_EXPORT int EVP_PKEY_CTX_set0_rsa_oaep_label(EVP_PKEY_CTX *ctx, - const uint8_t *label, - size_t label_len); - -/* EVP_PKEY_CTX_get0_rsa_oaep_label sets |*out_label| to point to the internal - * buffer containing the OAEP label (which may be NULL) and returns the length - * of the label or a negative value on error. - * - * WARNING: the return value differs from the usual return value convention. */ -OPENSSL_EXPORT int EVP_PKEY_CTX_get0_rsa_oaep_label(EVP_PKEY_CTX *ctx, - const uint8_t **out_label); - - -/* Deprecated functions. */ - -/* EVP_PKEY_dup adds one to the reference count of |pkey| and returns - * |pkey|. - * - * WARNING: this is a |_dup| function that doesn't actually duplicate! Use - * |EVP_PKEY_up_ref| if you want to increment the reference count without - * confusion. */ -OPENSSL_EXPORT EVP_PKEY *EVP_PKEY_dup(EVP_PKEY *pkey); - - -/* Private functions */ - -/* OpenSSL_add_all_algorithms does nothing. */ -OPENSSL_EXPORT void OpenSSL_add_all_algorithms(void); - -/* OpenSSL_add_all_ciphers does nothing. */ -OPENSSL_EXPORT void OpenSSL_add_all_ciphers(void); - -/* OpenSSL_add_all_digests does nothing. */ -OPENSSL_EXPORT void OpenSSL_add_all_digests(void); - -/* EVP_cleanup does nothing. */ -OPENSSL_EXPORT void EVP_cleanup(void); - -/* EVP_PKEY_asn1_find returns the ASN.1 method table for the given |nid|, which - * should be one of the |EVP_PKEY_*| values. It returns NULL if |nid| is - * unknown. */ -OPENSSL_EXPORT const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pengine, - int nid); - -/* TODO(fork): move to PEM? */ -OPENSSL_EXPORT const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str( - ENGINE **pengine, const char *name, size_t len); - -struct evp_pkey_st { - CRYPTO_refcount_t references; - - /* type contains one of the EVP_PKEY_* values or NID_undef and determines - * which element (if any) of the |pkey| union is valid. */ - int type; - - union { - char *ptr; - struct rsa_st *rsa; /* RSA */ - struct dsa_st *dsa; /* DSA */ - struct dh_st *dh; /* DH */ - struct ec_key_st *ec; /* ECC */ - } pkey; - - /* ameth contains a pointer to a method table that contains many ASN.1 - * methods for the key type. */ - const EVP_PKEY_ASN1_METHOD *ameth; -} /* EVP_PKEY */; - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#define EVP_F_EVP_PKEY_derive_init 108 -#define EVP_F_EVP_PKEY_encrypt 110 -#define EVP_F_EVP_PKEY_encrypt_init 111 -#define EVP_F_EVP_PKEY_get1_DH 112 -#define EVP_F_EVP_PKEY_get1_EC_KEY 114 -#define EVP_F_EVP_PKEY_get1_RSA 115 -#define EVP_F_EVP_PKEY_keygen 116 -#define EVP_F_EVP_PKEY_sign 120 -#define EVP_F_EVP_PKEY_sign_init 121 -#define EVP_F_EVP_PKEY_verify 122 -#define EVP_F_EVP_PKEY_verify_init 123 -#define EVP_F_d2i_AutoPrivateKey 125 -#define EVP_F_d2i_PrivateKey 126 -#define EVP_F_do_EC_KEY_print 127 -#define EVP_F_do_sigver_init 129 -#define EVP_F_eckey_param2type 130 -#define EVP_F_eckey_param_decode 131 -#define EVP_F_eckey_priv_decode 132 -#define EVP_F_eckey_priv_encode 133 -#define EVP_F_eckey_pub_decode 134 -#define EVP_F_eckey_pub_encode 135 -#define EVP_F_eckey_type2param 136 -#define EVP_F_evp_pkey_ctx_new 137 -#define EVP_F_hmac_signctx 138 -#define EVP_F_i2d_PublicKey 139 -#define EVP_F_old_ec_priv_decode 140 -#define EVP_F_old_rsa_priv_decode 141 -#define EVP_F_pkey_ec_ctrl 142 -#define EVP_F_pkey_ec_derive 143 -#define EVP_F_pkey_ec_keygen 144 -#define EVP_F_pkey_ec_paramgen 145 -#define EVP_F_pkey_ec_sign 146 -#define EVP_F_pkey_rsa_ctrl 147 -#define EVP_F_pkey_rsa_decrypt 148 -#define EVP_F_pkey_rsa_encrypt 149 -#define EVP_F_pkey_rsa_sign 150 -#define EVP_F_rsa_algor_to_md 151 -#define EVP_F_rsa_digest_verify_init_from_algorithm 152 -#define EVP_F_rsa_mgf1_to_md 153 -#define EVP_F_rsa_priv_decode 154 -#define EVP_F_rsa_priv_encode 155 -#define EVP_F_rsa_pss_to_ctx 156 -#define EVP_F_rsa_pub_decode 157 -#define EVP_F_pkey_hmac_ctrl 158 -#define EVP_F_EVP_PKEY_CTX_get0_rsa_oaep_label 159 -#define EVP_F_EVP_DigestSignAlgorithm 160 -#define EVP_F_EVP_DigestVerifyInitFromAlgorithm 161 -#define EVP_F_EVP_PKEY_CTX_ctrl 162 -#define EVP_F_EVP_PKEY_CTX_dup 163 -#define EVP_F_EVP_PKEY_copy_parameters 164 -#define EVP_F_EVP_PKEY_decrypt 165 -#define EVP_F_EVP_PKEY_decrypt_init 166 -#define EVP_F_EVP_PKEY_derive 167 -#define EVP_F_EVP_PKEY_derive_set_peer 168 -#define EVP_F_EVP_PKEY_get1_DSA 169 -#define EVP_F_EVP_PKEY_keygen_init 170 -#define EVP_F_EVP_PKEY_new 171 -#define EVP_F_EVP_PKEY_set_type 172 -#define EVP_F_check_padding_md 173 -#define EVP_F_do_dsa_print 174 -#define EVP_F_do_rsa_print 175 -#define EVP_F_dsa_param_decode 176 -#define EVP_F_dsa_priv_decode 177 -#define EVP_F_dsa_priv_encode 178 -#define EVP_F_dsa_pub_decode 179 -#define EVP_F_dsa_pub_encode 180 -#define EVP_F_dsa_sig_print 181 -#define EVP_F_old_dsa_priv_decode 182 -#define EVP_R_BUFFER_TOO_SMALL 100 -#define EVP_R_COMMAND_NOT_SUPPORTED 101 -#define EVP_R_DIFFERENT_KEY_TYPES 104 -#define EVP_R_DIFFERENT_PARAMETERS 105 -#define EVP_R_EXPECTING_AN_EC_KEY_KEY 107 -#define EVP_R_EXPECTING_A_DH_KEY 109 -#define EVP_R_EXPECTING_A_DSA_KEY 110 -#define EVP_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE 111 -#define EVP_R_INVALID_CURVE 112 -#define EVP_R_INVALID_DIGEST_LENGTH 113 -#define EVP_R_INVALID_DIGEST_TYPE 114 -#define EVP_R_INVALID_KEYBITS 115 -#define EVP_R_INVALID_MGF1_MD 116 -#define EVP_R_INVALID_PADDING_MODE 118 -#define EVP_R_INVALID_PSS_PARAMETERS 119 -#define EVP_R_INVALID_SALT_LENGTH 121 -#define EVP_R_INVALID_TRAILER 122 -#define EVP_R_KEYS_NOT_SET 123 -#define EVP_R_MISSING_PARAMETERS 124 -#define EVP_R_NO_DEFAULT_DIGEST 125 -#define EVP_R_NO_KEY_SET 126 -#define EVP_R_NO_MDC2_SUPPORT 127 -#define EVP_R_NO_NID_FOR_CURVE 128 -#define EVP_R_NO_OPERATION_SET 129 -#define EVP_R_NO_PARAMETERS_SET 130 -#define EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 131 -#define EVP_R_OPERATON_NOT_INITIALIZED 132 -#define EVP_R_UNKNOWN_DIGEST 133 -#define EVP_R_UNKNOWN_MASK_DIGEST 134 -#define EVP_R_UNSUPPORTED_ALGORITHM 138 -#define EVP_R_UNSUPPORTED_MASK_ALGORITHM 139 -#define EVP_R_UNSUPPORTED_MASK_PARAMETER 140 -#define EVP_R_EXPECTING_AN_RSA_KEY 141 -#define EVP_R_INVALID_OPERATION 142 -#define EVP_R_DECODE_ERROR 143 -#define EVP_R_INVALID_PSS_SALTLEN 144 -#define EVP_R_UNKNOWN_PUBLIC_KEY_TYPE 145 -#define EVP_R_CONTEXT_NOT_INITIALISED 146 -#define EVP_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED 147 -#define EVP_R_WRONG_PUBLIC_KEY_TYPE 148 -#define EVP_R_UNKNOWN_SIGNATURE_ALGORITHM 149 -#define EVP_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 150 -#define EVP_R_BN_DECODE_ERROR 151 -#define EVP_R_PARAMETER_ENCODING_ERROR 152 -#define EVP_R_UNSUPPORTED_PUBLIC_KEY_TYPE 153 -#define EVP_R_UNSUPPORTED_SIGNATURE_TYPE 154 - -#endif /* OPENSSL_HEADER_EVP_H */ diff --git a/phonelibs/boringssl/include/openssl/ex_data.h b/phonelibs/boringssl/include/openssl/ex_data.h deleted file mode 100644 index 2303eb425014e2..00000000000000 --- a/phonelibs/boringssl/include/openssl/ex_data.h +++ /dev/null @@ -1,214 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ -/* ==================================================================== - * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). */ - -#ifndef OPENSSL_HEADER_EX_DATA_H -#define OPENSSL_HEADER_EX_DATA_H - -#include - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* ex_data is a mechanism for associating arbitrary extra data with objects. - * For each type of object that supports ex_data, different users can be - * assigned indexes in which to store their data. Each index has callback - * functions that are called when a new object of that type is created, freed - * and duplicated. */ - - -typedef struct crypto_ex_data_st CRYPTO_EX_DATA; - - -/* Type-specific functions. - * - * Each type that supports ex_data provides three functions: */ - -#if 0 /* Sample */ - -/* |TYPE_get_ex_new_index| allocates a new index for |TYPE|. See the - * descriptions of the callback typedefs for details of when they are - * called. Any of the callback arguments may be NULL. The |argl| and |argp| - * arguments are opaque values that are passed to the callbacks. It returns the - * new index or a negative number on error. - * - * TODO(fork): this should follow the standard calling convention. */ -OPENSSL_EXPORT int TYPE_get_ex_new_index(long argl, void *argp, - CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, - CRYPTO_EX_free *free_func); - -/* |TYPE_set_ex_data| sets an extra data pointer on |t|. The |index| argument - * should have been returned from a previous call to |TYPE_get_ex_new_index|. */ -OPENSSL_EXPORT int TYPE_set_ex_data(TYPE *t, int index, void *arg); - -/* |TYPE_get_ex_data| returns an extra data pointer for |t|, or NULL if no such - * pointer exists. The |index| argument should have been returned from a - * previous call to |TYPE_get_ex_new_index|. */ -OPENSSL_EXPORT void *TYPE_get_ex_data(const TYPE *t, int index); - -#endif /* Sample */ - - -/* Callback types. */ - -/* CRYPTO_EX_new is the type of a callback function that is called whenever a - * new object of a given class is created. For example, if this callback has - * been passed to |SSL_get_ex_new_index| then it'll be called each time an SSL* - * is created. - * - * The callback is passed the new object (i.e. the SSL*) in |parent|. The - * arguments |argl| and |argp| contain opaque values that were given to - * |CRYPTO_get_ex_new_index|. The callback should return one on success, but - * the value is ignored. - * - * TODO(fork): the |ptr| argument is always NULL, no? */ -typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, - int index, long argl, void *argp); - -/* CRYPTO_EX_free is a callback function that is called when an object of the - * class is being destroyed. See |CRYPTO_EX_new| for a discussion of the - * arguments. - * - * If |CRYPTO_get_ex_new_index| was called after the creation of objects of the - * class that this applies to then, when those those objects are destroyed, - * this callback will be called with a NULL value for |ptr|. */ -typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, - int index, long argl, void *argp); - -/* CRYPTO_EX_dup is a callback function that is called when an object of the - * class is being copied and thus the ex_data linked to it also needs to be - * copied. On entry, |*from_d| points to the data for this index from the - * original object. When the callback returns, |*from_d| will be set as the - * data for this index in |to|. - * - * If |CRYPTO_get_ex_new_index| was called after the creation of objects of the - * class that this applies to then, when those those objects are copies, this - * callback will be called with a NULL value for |*from_d|. */ -typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from, - void **from_d, int index, long argl, void *argp); - - -/* Deprecated functions. */ - -/* CRYPTO_cleanup_all_ex_data does nothing. */ -OPENSSL_EXPORT void CRYPTO_cleanup_all_ex_data(void); - -struct crypto_ex_data_st { - STACK_OF(void) *sk; -}; - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_EX_DATA_H */ diff --git a/phonelibs/boringssl/include/openssl/hkdf.h b/phonelibs/boringssl/include/openssl/hkdf.h deleted file mode 100644 index 4091b84beb8eff..00000000000000 --- a/phonelibs/boringssl/include/openssl/hkdf.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (c) 2014, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -#ifndef OPENSSL_HEADER_HKDF_H -#define OPENSSL_HEADER_HKDF_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Computes HKDF (as specified by RFC 5869) of initial keying material |secret| - * with |salt| and |info| using |digest|, and outputs |out_len| bytes to - * |out_key|. It returns one on success and zero on error. - * - * HKDF is an Extract-and-Expand algorithm. It does not do any key stretching, - * and as such, is not suited to be used alone to generate a key from a - * password. */ -OPENSSL_EXPORT int HKDF(uint8_t *out_key, size_t out_len, const EVP_MD *digest, - const uint8_t *secret, size_t secret_len, - const uint8_t *salt, size_t salt_len, - const uint8_t *info, size_t info_len); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#define HKDF_F_HKDF 100 -#define HKDF_R_OUTPUT_TOO_LARGE 100 - -#endif /* OPENSSL_HEADER_HKDF_H */ diff --git a/phonelibs/boringssl/include/openssl/hmac.h b/phonelibs/boringssl/include/openssl/hmac.h deleted file mode 100644 index e521212d4cd254..00000000000000 --- a/phonelibs/boringssl/include/openssl/hmac.h +++ /dev/null @@ -1,160 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_HMAC_H -#define OPENSSL_HEADER_HMAC_H - -#include - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* HMAC contains functions for constructing PRFs from Merkle–Damgård hash - * functions using HMAC. */ - - -/* One-shot operation. */ - -/* HMAC calculates the HMAC of |data_len| bytes of |data|, using the given key - * and hash function, and writes the result to |out|. On entry, |out| must - * contain |EVP_MAX_MD_SIZE| bytes of space. The actual length of the result is - * written to |*out_len|. It returns |out| or NULL on error. */ -OPENSSL_EXPORT uint8_t *HMAC(const EVP_MD *evp_md, const void *key, - size_t key_len, const uint8_t *data, - size_t data_len, uint8_t *out, - unsigned int *out_len); - - -/* Incremental operation. */ - -/* HMAC_CTX_init initialises |ctx| for use in an HMAC operation. It's assumed - * that HMAC_CTX objects will be allocated on the stack thus no allocation - * function is provided. If needed, allocate |sizeof(HMAC_CTX)| and call - * |HMAC_CTX_init| on it. */ -OPENSSL_EXPORT void HMAC_CTX_init(HMAC_CTX *ctx); - -/* HMAC_CTX_cleanup frees data owned by |ctx|. */ -OPENSSL_EXPORT void HMAC_CTX_cleanup(HMAC_CTX *ctx); - -/* HMAC_Init_ex sets up an initialised |HMAC_CTX| to use |md| as the hash - * function and |key| as the key. For a non-initial call, |md| may be NULL, in - * which case the previous hash function will be used. If the hash function has - * not changed and |key| is NULL, |ctx| reuses the previous key. It returns one - * on success or zero otherwise. - * - * WARNING: NULL and empty keys are ambiguous on non-initial calls. Passing NULL - * |key| but repeating the previous |md| reuses the previous key rather than the - * empty key. */ -OPENSSL_EXPORT int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, size_t key_len, - const EVP_MD *md, ENGINE *impl); - -/* HMAC_Update hashes |data_len| bytes from |data| into the current HMAC - * operation in |ctx|. It returns one. */ -OPENSSL_EXPORT int HMAC_Update(HMAC_CTX *ctx, const uint8_t *data, - size_t data_len); - -/* HMAC_Final completes the HMAC operation in |ctx| and writes the result to - * |out| and the sets |*out_len| to the length of the result. On entry, |out| - * must contain at least |EVP_MAX_MD_SIZE| bytes of space. It returns one on - * success or zero on error. */ -OPENSSL_EXPORT int HMAC_Final(HMAC_CTX *ctx, uint8_t *out, - unsigned int *out_len); - - -/* Utility functions. */ - -/* HMAC_size returns the size, in bytes, of the HMAC that will be produced by - * |ctx|. On entry, |ctx| must have been setup with |HMAC_Init_ex|. */ -OPENSSL_EXPORT size_t HMAC_size(const HMAC_CTX *ctx); - -/* HMAC_CTX_copy_ex sets |dest| equal to |src|. On entry, |dest| must have been - * initialised by calling |HMAC_CTX_init|. It returns one on success and zero - * on error. */ -OPENSSL_EXPORT int HMAC_CTX_copy_ex(HMAC_CTX *dest, const HMAC_CTX *src); - - -/* Deprecated functions. */ - -OPENSSL_EXPORT int HMAC_Init(HMAC_CTX *ctx, const void *key, int key_len, - const EVP_MD *md); - -/* HMAC_CTX_copy calls |HMAC_CTX_init| on |dest| and then sets it equal to - * |src|. On entry, |dest| must /not/ be initialised for an operation with - * |HMAC_Init_ex|. It returns one on success and zero on error. */ -OPENSSL_EXPORT int HMAC_CTX_copy(HMAC_CTX *dest, const HMAC_CTX *src); - - -/* Private functions */ - -#define HMAC_MAX_MD_CBLOCK 128 /* largest known is SHA512 */ - -struct hmac_ctx_st { - const EVP_MD *md; - EVP_MD_CTX md_ctx; - EVP_MD_CTX i_ctx; - EVP_MD_CTX o_ctx; -} /* HMAC_CTX */; - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_HMAC_H */ diff --git a/phonelibs/boringssl/include/openssl/lhash.h b/phonelibs/boringssl/include/openssl/lhash.h deleted file mode 100644 index d2ee982ebccb4e..00000000000000 --- a/phonelibs/boringssl/include/openssl/lhash.h +++ /dev/null @@ -1,191 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_LHASH_H -#define OPENSSL_HEADER_LHASH_H - -#include -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* lhash is a traditional, chaining hash table that automatically expands and - * contracts as needed. One should not use the lh_* functions directly, rather - * use the type-safe macro wrappers: - * - * A hash table of a specific type of object has type |LHASH_OF(type)|. This - * can be defined (once) with |DEFINE_LHASH_OF(type)| and declared where needed - * with |DECLARE_LHASH_OF(type)|. For example: - * - * struct foo { - * int bar; - * }; - * - * DEFINE_LHASH_OF(struct foo); - * - * Although note that the hash table will contain /pointers/ to |foo|. - * - * A macro will be defined for each of the lh_* functions below. For - * LHASH_OF(foo), the macros would be lh_foo_new, lh_foo_num_items etc. */ - - -#define LHASH_OF(type) struct lhash_st_##type - -#define DEFINE_LHASH_OF(type) LHASH_OF(type) { int dummy; } - -#define DECLARE_LHASH_OF(type) LHASH_OF(type); - -/* The make_macros.sh script in this directory parses the following lines and - * generates the lhash_macros.h file that contains macros for the following - * types of stacks: - * - * LHASH_OF:ASN1_OBJECT - * LHASH_OF:CONF_VALUE - * LHASH_OF:SSL_SESSION */ - -#define IN_LHASH_H -#include -#undef IN_LHASH_H - - -/* lhash_item_st is an element of a hash chain. It points to the opaque data - * for this element and to the next item in the chain. The linked-list is NULL - * terminated. */ -typedef struct lhash_item_st { - void *data; - struct lhash_item_st *next; - /* hash contains the cached, hash value of |data|. */ - uint32_t hash; -} LHASH_ITEM; - -/* lhash_cmp_func is a comparison function that returns a value equal, or not - * equal, to zero depending on whether |*a| is equal, or not equal to |*b|, - * respectively. Note the difference between this and |stack_cmp_func| in that - * this takes pointers to the objects directly. */ -typedef int (*lhash_cmp_func)(const void *a, const void *b); - -/* lhash_hash_func is a function that maps an object to a uniformly distributed - * uint32_t. */ -typedef uint32_t (*lhash_hash_func)(const void *a); - -typedef struct lhash_st { - /* num_items contains the total number of items in the hash table. */ - size_t num_items; - /* buckets is an array of |num_buckets| pointers. Each points to the head of - * a chain of LHASH_ITEM objects that have the same hash value, mod - * |num_buckets|. */ - LHASH_ITEM **buckets; - /* num_buckets contains the length of |buckets|. This value is always >= - * kMinNumBuckets. */ - size_t num_buckets; - /* callback_depth contains the current depth of |lh_doall| or |lh_doall_arg| - * calls. If non-zero then this suppresses resizing of the |buckets| array, - * which would otherwise disrupt the iteration. */ - unsigned callback_depth; - - lhash_cmp_func comp; - lhash_hash_func hash; -} _LHASH; - -/* lh_new returns a new, empty hash table or NULL on error. If |comp| is NULL, - * |strcmp| will be used. If |hash| is NULL, a generic hash function will be - * used. */ -OPENSSL_EXPORT _LHASH *lh_new(lhash_hash_func hash, lhash_cmp_func comp); - -/* lh_free frees the hash table itself but none of the elements. See - * |lh_doall|. */ -OPENSSL_EXPORT void lh_free(_LHASH *lh); - -/* lh_num_items returns the number of items in |lh|. */ -OPENSSL_EXPORT size_t lh_num_items(const _LHASH *lh); - -/* lh_retrieve finds an element equal to |data| in the hash table and returns - * it. If no such element exists, it returns NULL. */ -OPENSSL_EXPORT void *lh_retrieve(const _LHASH *lh, const void *data); - -/* lh_insert inserts |data| into the hash table. If an existing element is - * equal to |data| (with respect to the comparison function) then |*old_data| - * will be set to that value and it will be replaced. Otherwise, or in the - * event of an error, |*old_data| will be set to NULL. It returns one on - * success or zero in the case of an allocation error. */ -OPENSSL_EXPORT int lh_insert(_LHASH *lh, void **old_data, void *data); - -/* lh_delete removes an element equal to |data| from the hash table and returns - * it. If no such element is found, it returns NULL. */ -OPENSSL_EXPORT void *lh_delete(_LHASH *lh, const void *data); - -/* lh_doall calls |func| on each element of the hash table. - * TODO(fork): rename this */ -OPENSSL_EXPORT void lh_doall(_LHASH *lh, void (*func)(void *)); - -/* lh_doall_arg calls |func| on each element of the hash table and also passes - * |arg| as the second argument. - * TODO(fork): rename this */ -OPENSSL_EXPORT void lh_doall_arg(_LHASH *lh, void (*func)(void *, void *), - void *arg); - -/* lh_strhash is the default hash function which processes NUL-terminated - * strings. */ -OPENSSL_EXPORT uint32_t lh_strhash(const char *c); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_STACK_H */ diff --git a/phonelibs/boringssl/include/openssl/lhash_macros.h b/phonelibs/boringssl/include/openssl/lhash_macros.h deleted file mode 100644 index 1d981073ea9e7c..00000000000000 --- a/phonelibs/boringssl/include/openssl/lhash_macros.h +++ /dev/null @@ -1,132 +0,0 @@ -/* Copyright (c) 2014, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -#if !defined(IN_LHASH_H) -#error "Don't include this file directly. Include lhash.h" -#endif - -/* ASN1_OBJECT */ -#define lh_ASN1_OBJECT_new(hash, comp) \ - ((LHASH_OF(ASN1_OBJECT) *)lh_new( \ - CHECKED_CAST(lhash_hash_func, uint32_t (*)(const ASN1_OBJECT *), hash), \ - CHECKED_CAST(lhash_cmp_func, \ - int (*)(const ASN1_OBJECT *a, const ASN1_OBJECT *b), \ - comp))) - -#define lh_ASN1_OBJECT_free(lh) \ - lh_free(CHECKED_CAST(_LHASH *, LHASH_OF(ASN1_OBJECT) *, lh)); - -#define lh_ASN1_OBJECT_num_items(lh) \ - lh_num_items(CHECKED_CAST(_LHASH *, LHASH_OF(ASN1_OBJECT) *, lh)) - -#define lh_ASN1_OBJECT_retrieve(lh, data) \ - ((ASN1_OBJECT *)lh_retrieve( \ - CHECKED_CAST(_LHASH *, LHASH_OF(ASN1_OBJECT) *, lh), \ - CHECKED_CAST(void *, ASN1_OBJECT *, data))) - -#define lh_ASN1_OBJECT_insert(lh, old_data, data) \ - lh_insert(CHECKED_CAST(_LHASH *, LHASH_OF(ASN1_OBJECT) *, lh), \ - CHECKED_CAST(void **, ASN1_OBJECT **, old_data), \ - CHECKED_CAST(void *, ASN1_OBJECT *, data)) - -#define lh_ASN1_OBJECT_delete(lh, data) \ - ((ASN1_OBJECT *)lh_delete( \ - CHECKED_CAST(_LHASH *, LHASH_OF(ASN1_OBJECT) *, lh), \ - CHECKED_CAST(void *, ASN1_OBJECT *, data))) - -#define lh_ASN1_OBJECT_doall(lh, func) \ - lh_doall(CHECKED_CAST(_LHASH *, LHASH_OF(ASN1_OBJECT) *, lh), \ - CHECKED_CAST(void (*)(void *), void (*)(ASN1_OBJECT *), func)); - -#define lh_ASN1_OBJECT_doall_arg(lh, func, arg) \ - lh_doall_arg(CHECKED_CAST(_LHASH *, LHASH_OF(ASN1_OBJECT) *, lh), \ - CHECKED_CAST(void (*)(void *, void *), \ - void (*)(ASN1_OBJECT *, void *), func), \ - arg); - -/* CONF_VALUE */ -#define lh_CONF_VALUE_new(hash, comp) \ - ((LHASH_OF(CONF_VALUE) *)lh_new( \ - CHECKED_CAST(lhash_hash_func, uint32_t (*)(const CONF_VALUE *), hash), \ - CHECKED_CAST(lhash_cmp_func, \ - int (*)(const CONF_VALUE *a, const CONF_VALUE *b), comp))) - -#define lh_CONF_VALUE_free(lh) \ - lh_free(CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh)); - -#define lh_CONF_VALUE_num_items(lh) \ - lh_num_items(CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh)) - -#define lh_CONF_VALUE_retrieve(lh, data) \ - ((CONF_VALUE *)lh_retrieve( \ - CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh), \ - CHECKED_CAST(void *, CONF_VALUE *, data))) - -#define lh_CONF_VALUE_insert(lh, old_data, data) \ - lh_insert(CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh), \ - CHECKED_CAST(void **, CONF_VALUE **, old_data), \ - CHECKED_CAST(void *, CONF_VALUE *, data)) - -#define lh_CONF_VALUE_delete(lh, data) \ - ((CONF_VALUE *)lh_delete(CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh), \ - CHECKED_CAST(void *, CONF_VALUE *, data))) - -#define lh_CONF_VALUE_doall(lh, func) \ - lh_doall(CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh), \ - CHECKED_CAST(void (*)(void *), void (*)(CONF_VALUE *), func)); - -#define lh_CONF_VALUE_doall_arg(lh, func, arg) \ - lh_doall_arg(CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh), \ - CHECKED_CAST(void (*)(void *, void *), \ - void (*)(CONF_VALUE *, void *), func), \ - arg); - -/* SSL_SESSION */ -#define lh_SSL_SESSION_new(hash, comp) \ - ((LHASH_OF(SSL_SESSION) *)lh_new( \ - CHECKED_CAST(lhash_hash_func, uint32_t (*)(const SSL_SESSION *), hash), \ - CHECKED_CAST(lhash_cmp_func, \ - int (*)(const SSL_SESSION *a, const SSL_SESSION *b), \ - comp))) - -#define lh_SSL_SESSION_free(lh) \ - lh_free(CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh)); - -#define lh_SSL_SESSION_num_items(lh) \ - lh_num_items(CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh)) - -#define lh_SSL_SESSION_retrieve(lh, data) \ - ((SSL_SESSION *)lh_retrieve( \ - CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh), \ - CHECKED_CAST(void *, SSL_SESSION *, data))) - -#define lh_SSL_SESSION_insert(lh, old_data, data) \ - lh_insert(CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh), \ - CHECKED_CAST(void **, SSL_SESSION **, old_data), \ - CHECKED_CAST(void *, SSL_SESSION *, data)) - -#define lh_SSL_SESSION_delete(lh, data) \ - ((SSL_SESSION *)lh_delete( \ - CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh), \ - CHECKED_CAST(void *, SSL_SESSION *, data))) - -#define lh_SSL_SESSION_doall(lh, func) \ - lh_doall(CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh), \ - CHECKED_CAST(void (*)(void *), void (*)(SSL_SESSION *), func)); - -#define lh_SSL_SESSION_doall_arg(lh, func, arg) \ - lh_doall_arg(CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh), \ - CHECKED_CAST(void (*)(void *, void *), \ - void (*)(SSL_SESSION *, void *), func), \ - arg); diff --git a/phonelibs/boringssl/include/openssl/md4.h b/phonelibs/boringssl/include/openssl/md4.h deleted file mode 100644 index ce4fa99bb8c010..00000000000000 --- a/phonelibs/boringssl/include/openssl/md4.h +++ /dev/null @@ -1,101 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_MD4_H -#define OPENSSL_HEADER_MD4_H - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* MD4. */ - -/* MD4_CBLOCK is the block size of MD4. */ -#define MD4_CBLOCK 64 - -/* MD4_DIGEST_LENGTH is the length of an MD4 digest. */ -#define MD4_DIGEST_LENGTH 16 - -/* MD41_Init initialises |md4| and returns one. */ -OPENSSL_EXPORT int MD4_Init(MD4_CTX *md4); - -/* MD4_Update adds |len| bytes from |data| to |md4| and returns one. */ -OPENSSL_EXPORT int MD4_Update(MD4_CTX *md4, const void *data, size_t len); - -/* MD4_Final adds the final padding to |md4| and writes the resulting digest to - * |md|, which must have at least |MD4_DIGEST_LENGTH| bytes of space. It - * returns one. */ -OPENSSL_EXPORT int MD4_Final(uint8_t *md, MD4_CTX *md4); - -/* MD4_Transform is a low-level function that performs a single, MD4 block - * transformation using the state from |md4| and 64 bytes from |block|. */ -OPENSSL_EXPORT void MD4_Transform(MD4_CTX *md4, const uint8_t *block); - -struct md4_state_st { - uint32_t A, B, C, D; - uint32_t Nl, Nh; - uint32_t data[16]; - unsigned int num; -}; - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_MD4_H */ diff --git a/phonelibs/boringssl/include/openssl/md5.h b/phonelibs/boringssl/include/openssl/md5.h deleted file mode 100644 index efedc983debdcd..00000000000000 --- a/phonelibs/boringssl/include/openssl/md5.h +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_MD5_H -#define OPENSSL_HEADER_MD5_H - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* MD5. */ - - -/* MD5_CBLOCK is the block size of MD5. */ -#define MD5_CBLOCK 64 - -/* MD5_DIGEST_LENGTH is the length of an MD5 digest. */ -#define MD5_DIGEST_LENGTH 16 - -/* MD51_Init initialises |md5| and returns one. */ -OPENSSL_EXPORT int MD5_Init(MD5_CTX *md5); - -/* MD5_Update adds |len| bytes from |data| to |md5| and returns one. */ -OPENSSL_EXPORT int MD5_Update(MD5_CTX *md5, const void *data, size_t len); - -/* MD5_Final adds the final padding to |md5| and writes the resulting digest to - * |md|, which must have at least |MD5_DIGEST_LENGTH| bytes of space. It - * returns one. */ -OPENSSL_EXPORT int MD5_Final(uint8_t *md, MD5_CTX *md5); - -/* MD5 writes the digest of |len| bytes from |data| to |out| and returns |out|. - * There must be at least |MD5_DIGEST_LENGTH| bytes of space in |out|. */ -OPENSSL_EXPORT uint8_t *MD5(const uint8_t *data, size_t len, uint8_t *out); - -/* MD5_Transform is a low-level function that performs a single, MD5 block - * transformation using the state from |md5| and 64 bytes from |block|. */ -OPENSSL_EXPORT void MD5_Transform(MD5_CTX *md5, const uint8_t *block); - -struct md5_state_st { - uint32_t A, B, C, D; - uint32_t Nl, Nh; - uint32_t data[16]; - unsigned int num; -}; - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_MD5_H */ diff --git a/phonelibs/boringssl/include/openssl/mem.h b/phonelibs/boringssl/include/openssl/mem.h deleted file mode 100644 index 42ec46a073e19f..00000000000000 --- a/phonelibs/boringssl/include/openssl/mem.h +++ /dev/null @@ -1,139 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_MEM_H -#define OPENSSL_HEADER_MEM_H - -#include - -#include -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* Memory and string functions, see also buf.h. - * - * OpenSSL has, historically, had a complex set of malloc debugging options. - * However, that was written in a time before Valgrind and ASAN. Since we now - * have those tools, the OpenSSL allocation functions are simply macros around - * the standard memory functions. */ - - -#define OPENSSL_malloc malloc -#define OPENSSL_realloc realloc -#define OPENSSL_free free - -/* OPENSSL_realloc_clean acts like |realloc|, but clears the previous memory - * buffer. Because this is implemented as a wrapper around |malloc|, it needs - * to be given the size of the buffer pointed to by |ptr|. */ -void *OPENSSL_realloc_clean(void *ptr, size_t old_size, size_t new_size); - -/* OPENSSL_cleanse zeros out |len| bytes of memory at |ptr|. This is similar to - * |memset_s| from C11. */ -OPENSSL_EXPORT void OPENSSL_cleanse(void *ptr, size_t len); - -/* CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal. It - * takes an amount of time dependent on |len|, but independent of the contents - * of |a| and |b|. Unlike memcmp, it cannot be used to put elements into a - * defined order as the return value when a != b is undefined, other than to be - * non-zero. */ -OPENSSL_EXPORT int CRYPTO_memcmp(const void *a, const void *b, size_t len); - -/* OPENSSL_hash32 implements the 32 bit, FNV-1a hash. */ -OPENSSL_EXPORT uint32_t OPENSSL_hash32(const void *ptr, size_t len); - -/* OPENSSL_strdup has the same behaviour as strdup(3). */ -OPENSSL_EXPORT char *OPENSSL_strdup(const char *s); - -/* OPENSSL_strnlen has the same behaviour as strnlen(3). */ -OPENSSL_EXPORT size_t OPENSSL_strnlen(const char *s, size_t len); - -/* OPENSSL_strcasecmp has the same behaviour as strcasecmp(3). */ -OPENSSL_EXPORT int OPENSSL_strcasecmp(const char *a, const char *b); - -/* OPENSSL_strncasecmp has the same behaviour as strncasecmp(3). */ -OPENSSL_EXPORT int OPENSSL_strncasecmp(const char *a, const char *b, size_t n); - -/* DECIMAL_SIZE returns an upper bound for the length of the decimal - * representation of the given type. */ -#define DECIMAL_SIZE(type) ((sizeof(type)*8+2)/3+1) - -/* Printf functions. - * - * These functions are either OpenSSL wrappers for standard functions (i.e. - * |BIO_snprintf| and |BIO_vsnprintf|) which don't exist in C89, or are - * versions of printf functions that output to a BIO rather than a FILE. */ -#ifdef __GNUC__ -#define __bio_h__attr__ __attribute__ -#else -#define __bio_h__attr__(x) -#endif -OPENSSL_EXPORT int BIO_snprintf(char *buf, size_t n, const char *format, ...) - __bio_h__attr__((__format__(__printf__, 3, 4))); - -OPENSSL_EXPORT int BIO_vsnprintf(char *buf, size_t n, const char *format, - va_list args) - __bio_h__attr__((__format__(__printf__, 3, 0))); -#undef __bio_h__attr__ - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_MEM_H */ diff --git a/phonelibs/boringssl/include/openssl/modes.h b/phonelibs/boringssl/include/openssl/modes.h deleted file mode 100644 index 220adec552d8be..00000000000000 --- a/phonelibs/boringssl/include/openssl/modes.h +++ /dev/null @@ -1,223 +0,0 @@ -/* ==================================================================== - * Copyright (c) 2008 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== */ - -#ifndef OPENSSL_HEADER_MODES_H -#define OPENSSL_HEADER_MODES_H - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* modes.h contains functions that implement various block-cipher modes. */ - - -/* block128_f is the type of a 128-bit, block cipher. */ -typedef void (*block128_f)(const uint8_t in[16], uint8_t out[16], - const void *key); - - -/* CTR. */ - -/* ctr128_f is the type of a function that performs CTR-mode encryption. */ -typedef void (*ctr128_f)(const uint8_t *in, uint8_t *out, size_t blocks, - const void *key, const uint8_t ivec[16]); - -/* CRYPTO_ctr128_encrypt encrypts (or decrypts, it's the same in CTR mode) - * |len| bytes from |in| to |out| using |block| in counter mode. There's no - * requirement that |len| be a multiple of any value and any partial blocks are - * stored in |ecount_buf| and |*num|, which must be zeroed before the initial - * call. The counter is a 128-bit, big-endian value in |ivec| and is - * incremented by this function. */ -OPENSSL_EXPORT void CRYPTO_ctr128_encrypt(const uint8_t *in, uint8_t *out, - size_t len, const void *key, - uint8_t ivec[16], - uint8_t ecount_buf[16], - unsigned int *num, block128_f block); - -/* CRYPTO_ctr128_encrypt_ctr32 acts like |CRYPTO_ctr128_encrypt| but takes - * |ctr|, a function that performs CTR mode but only deals with the lower 32 - * bits of the counter. This is useful when |ctr| can be an optimised - * function. */ -OPENSSL_EXPORT void CRYPTO_ctr128_encrypt_ctr32( - const uint8_t *in, uint8_t *out, size_t len, const void *key, - uint8_t ivec[16], uint8_t ecount_buf[16], unsigned int *num, ctr128_f ctr); - - -/* GCM. */ - -typedef struct gcm128_context GCM128_CONTEXT; - -/* CRYPTO_gcm128_new allocates a fresh |GCM128_CONTEXT| and calls - * |CRYPTO_gcm128_init|. It returns the new context, or NULL on error. */ -OPENSSL_EXPORT GCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block); - -/* CRYPTO_gcm128_init initialises |ctx| to use |block| (typically AES) with the - * given key. */ -OPENSSL_EXPORT void CRYPTO_gcm128_init(GCM128_CONTEXT *ctx, void *key, - block128_f block); - -/* CRYPTO_gcm128_setiv sets the IV (nonce) for |ctx|. */ -OPENSSL_EXPORT void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const uint8_t *iv, - size_t len); - -/* CRYPTO_gcm128_aad sets the authenticated data for an instance of GCM. This - * must be called before and data is encrypted. It returns one on success and - * zero otherwise. */ -OPENSSL_EXPORT int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const uint8_t *aad, - size_t len); - -/* CRYPTO_gcm128_encrypt encrypts |len| bytes from |in| to |out|. It returns - * one on success and zero otherwise. */ -OPENSSL_EXPORT int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, const uint8_t *in, - uint8_t *out, size_t len); - -/* CRYPTO_gcm128_decrypt decrypts |len| bytes from |in| to |out|. It returns - * one on success and zero otherwise. */ -OPENSSL_EXPORT int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, const uint8_t *in, - uint8_t *out, size_t len); - -/* CRYPTO_gcm128_encrypt_ctr32 encrypts |len| bytes from |in| to |out| using a - * CTR function that only handles the bottom 32 bits of the nonce, like - * |CRYPTO_ctr128_encrypt_ctr32|. It returns one on success and zero - * otherwise. */ -OPENSSL_EXPORT int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, - const uint8_t *in, uint8_t *out, - size_t len, ctr128_f stream); - -/* CRYPTO_gcm128_decrypt_ctr32 decrypts |len| bytes from |in| to |out| using a - * CTR function that only handles the bottom 32 bits of the nonce, like - * |CRYPTO_ctr128_encrypt_ctr32|. It returns one on success and zero - * otherwise. */ -OPENSSL_EXPORT int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, - const uint8_t *in, uint8_t *out, - size_t len, ctr128_f stream); - -/* CRYPTO_gcm128_finish calculates the authenticator and compares it against - * |len| bytes of |tag|. It returns one on success and zero otherwise. */ -OPENSSL_EXPORT int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const uint8_t *tag, - size_t len); - -/* CRYPTO_gcm128_tag calculates the authenticator and copies it into |tag|. The - * minimum of |len| and 16 bytes are copied into |tag|. */ -OPENSSL_EXPORT void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, uint8_t *tag, - size_t len); - -/* CRYPTO_gcm128_release clears and frees |ctx|. */ -OPENSSL_EXPORT void CRYPTO_gcm128_release(GCM128_CONTEXT *ctx); - - -/* CBC. */ - -/* cbc128_f is the type of a function that performs CBC-mode encryption. */ -typedef void (*cbc128_f)(const uint8_t *in, uint8_t *out, size_t len, - const void *key, uint8_t ivec[16], int enc); - -/* CRYPTO_cbc128_encrypt encrypts |len| bytes from |in| to |out| using the - * given IV and block cipher in CBC mode. The input need not be a multiple of - * 128 bits long, but the output will round up to the nearest 128 bit multiple, - * zero padding the input if needed. The IV will be updated on return. */ -void CRYPTO_cbc128_encrypt(const uint8_t *in, uint8_t *out, size_t len, - const void *key, uint8_t ivec[16], block128_f block); - -/* CRYPTO_cbc128_decrypt decrypts |len| bytes from |in| to |out| using the - * given IV and block cipher in CBC mode. If |len| is not a multiple of 128 - * bits then only that many bytes will be written, but a multiple of 128 bits - * is always read from |in|. The IV will be updated on return. */ -void CRYPTO_cbc128_decrypt(const uint8_t *in, uint8_t *out, size_t len, - const void *key, uint8_t ivec[16], block128_f block); - - -/* OFB. */ - -/* CRYPTO_ofb128_encrypt encrypts (or decrypts, it's the same with OFB mode) - * |len| bytes from |in| to |out| using |block| in OFB mode. There's no - * requirement that |len| be a multiple of any value and any partial blocks are - * stored in |ivec| and |*num|, the latter must be zero before the initial - * call. */ -void CRYPTO_ofb128_encrypt(const uint8_t *in, uint8_t *out, - size_t len, const void *key, uint8_t ivec[16], - int *num, block128_f block); - - -/* CFB. */ - -/* CRYPTO_cfb128_encrypt encrypts (or decrypts, if |enc| is zero) |len| bytes - * from |in| to |out| using |block| in CFB mode. There's no requirement that - * |len| be a multiple of any value and any partial blocks are stored in |ivec| - * and |*num|, the latter must be zero before the initial call. */ -void CRYPTO_cfb128_encrypt(const uint8_t *in, uint8_t *out, size_t len, - const void *key, uint8_t ivec[16], int *num, int enc, - block128_f block); - -/* CRYPTO_cfb128_8_encrypt encrypts (or decrypts, if |enc| is zero) |len| bytes - * from |in| to |out| using |block| in CFB-8 mode. Prior to the first call - * |num| should be set to zero. */ -void CRYPTO_cfb128_8_encrypt(const uint8_t *in, uint8_t *out, size_t len, - const void *key, uint8_t ivec[16], int *num, - int enc, block128_f block); - -/* CRYPTO_cfb128_1_encrypt encrypts (or decrypts, if |enc| is zero) |len| bytes - * from |in| to |out| using |block| in CFB-1 mode. Prior to the first call - * |num| should be set to zero. */ -void CRYPTO_cfb128_1_encrypt(const uint8_t *in, uint8_t *out, size_t bits, - const void *key, uint8_t ivec[16], int *num, - int enc, block128_f block); - -size_t CRYPTO_cts128_encrypt_block(const uint8_t *in, uint8_t *out, size_t len, - const void *key, uint8_t ivec[16], - block128_f block); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_MODES_H */ diff --git a/phonelibs/boringssl/include/openssl/obj.h b/phonelibs/boringssl/include/openssl/obj.h deleted file mode 100644 index f476617e18e427..00000000000000 --- a/phonelibs/boringssl/include/openssl/obj.h +++ /dev/null @@ -1,202 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_OBJECTS_H -#define OPENSSL_HEADER_OBJECTS_H - -#include - -#include -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* The objects library deals with the registration and indexing of ASN.1 object - * identifiers. These values are often written as a dotted sequence of numbers, - * e.g. 1.2.840.113549.1.9.16.3.9. - * - * Internally, OpenSSL likes to deal with these values by numbering them with - * numbers called "nids". OpenSSL has a large, built-in database of common - * object identifiers and also has both short and long names for them. - * - * This library provides functions for translating between object identifiers, - * nids, short names and long names. - * - * The nid values should not be used outside of a single process: they are not - * stable identifiers. */ - - -/* Basic operations. */ - -/* OBJ_dup returns a duplicate copy of |obj| or NULL on allocation failure. */ -OPENSSL_EXPORT ASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *obj); - -/* OBJ_cmp returns a value less than, equal to or greater than zero if |a| is - * less than, equal to or greater than |b|, respectively. */ -OPENSSL_EXPORT int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b); - - -/* Looking up nids. */ - -/* OBJ_obj2nid returns the nid corresponding to |obj|, or |NID_undef| if no - * such object is known. */ -OPENSSL_EXPORT int OBJ_obj2nid(const ASN1_OBJECT *obj); - -/* OBJ_cbs2nid returns the nid corresponding to the DER data in |cbs|, or - * |NID_undef| if no such object is known. */ -OPENSSL_EXPORT int OBJ_cbs2nid(const CBS *cbs); - -/* OBJ_sn2nid returns the nid corresponding to |short_name|, or |NID_undef| if - * no such short name is known. */ -OPENSSL_EXPORT int OBJ_sn2nid(const char *short_name); - -/* OBJ_ln2nid returns the nid corresponding to |long_name|, or |NID_undef| if - * no such long name is known. */ -OPENSSL_EXPORT int OBJ_ln2nid(const char *long_name); - -/* OBJ_txt2nid returns the nid corresponding to |s|, which may be a short name, - * long name, or an ASCII string containing a dotted sequence of numbers. It - * returns the nid or NID_undef if unknown. */ -OPENSSL_EXPORT int OBJ_txt2nid(const char *s); - - -/* Getting information about nids. */ - -/* OBJ_nid2obj returns the ASN1_OBJECT corresponding to |nid|, or NULL if |nid| - * is unknown. */ -OPENSSL_EXPORT const ASN1_OBJECT *OBJ_nid2obj(int nid); - -/* OBJ_nid2sn returns the short name for |nid|, or NULL if |nid| is unknown. */ -OPENSSL_EXPORT const char *OBJ_nid2sn(int nid); - -/* OBJ_nid2sn returns the long name for |nid|, or NULL if |nid| is unknown. */ -OPENSSL_EXPORT const char *OBJ_nid2ln(int nid); - -/* OBJ_nid2cbs writes |nid| as an ASN.1 OBJECT IDENTIFIER to |out|. It returns - * one on success or zero otherwise. */ -OPENSSL_EXPORT int OBJ_nid2cbb(CBB *out, int nid); - - -/* Dealing with textual representations of object identifiers. */ - -/* OBJ_txt2obj returns an ASN1_OBJECT for the textual respresentation in |s|. - * If |dont_search_names| is zero, then |s| will be matched against the long - * and short names of a known objects to find a match. Otherwise |s| must - * contain an ASCII string with a dotted sequence of numbers. The resulting - * object need not be previously known. It returns a freshly allocated - * |ASN1_OBJECT| or NULL on error. */ -OPENSSL_EXPORT ASN1_OBJECT *OBJ_txt2obj(const char *s, int dont_search_names); - -/* OBJ_obj2txt converts |obj| to a textual representation. If - * |dont_return_name| is zero then |obj| will be matched against known objects - * and the long (preferably) or short name will be used if found. Otherwise - * |obj| will be converted into a dotted sequence of integers. If |out| is not - * NULL, then at most |out_len| bytes of the textual form will be written - * there. If |out_len| is at least one, then string written to |out| will - * always be NUL terminated. It returns the number of characters that could - * have been written, not including the final NUL, or -1 on error. */ -OPENSSL_EXPORT int OBJ_obj2txt(char *out, int out_len, const ASN1_OBJECT *obj, - int dont_return_name); - - -/* Adding objects at runtime. */ - -/* OBJ_create adds a known object and returns the nid of the new object, or - * NID_undef on error. */ -OPENSSL_EXPORT int OBJ_create(const char *oid, const char *short_name, - const char *long_name); - - -/* Handling signature algorithm identifiers. - * - * Some NIDs (e.g. sha256WithRSAEncryption) specify both a digest algorithm and - * a public key algorithm. The following functions map between pairs of digest - * and public-key algorithms and the NIDs that specify their combination. - * - * Sometimes the combination NID leaves the digest unspecified (e.g. - * rsassaPss). In these cases, the digest NID is |NID_undef|. */ - -/* OBJ_find_sigid_algs finds the digest and public-key NIDs that correspond to - * the signing algorithm |sign_nid|. If successful, it sets |*out_digest_nid| - * and |*out_pkey_nid| and returns one. Otherwise it returns zero. Any of - * |out_digest_nid| or |out_pkey_nid| can be NULL if the caller doesn't need - * that output value. */ -OPENSSL_EXPORT int OBJ_find_sigid_algs(int sign_nid, int *out_digest_nid, - int *out_pkey_nid); - -/* OBJ_find_sigid_by_algs finds the signature NID that corresponds to the - * combination of |digest_nid| and |pkey_nid|. If success, it sets - * |*out_sign_nid| and returns one. Otherwise it returns zero. The - * |out_sign_nid| argument can be NULL if the caller only wishes to learn - * whether the combination is valid. */ -OPENSSL_EXPORT int OBJ_find_sigid_by_algs(int *out_sign_nid, int digest_nid, - int pkey_nid); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#define OBJ_F_OBJ_create 100 -#define OBJ_F_OBJ_dup 101 -#define OBJ_F_OBJ_nid2obj 102 -#define OBJ_F_OBJ_txt2obj 103 -#define OBJ_R_UNKNOWN_NID 100 - -#endif /* OPENSSL_HEADER_OBJECTS_H */ diff --git a/phonelibs/boringssl/include/openssl/obj_mac.h b/phonelibs/boringssl/include/openssl/obj_mac.h deleted file mode 100644 index 55e1cba2fee7bc..00000000000000 --- a/phonelibs/boringssl/include/openssl/obj_mac.h +++ /dev/null @@ -1,4140 +0,0 @@ -/* THIS FILE IS GENERATED FROM objects.txt by objects.pl via the - * following command: - * perl objects.pl objects.txt obj_mac.num ../../include/openssl/obj_mac.h */ - -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#define SN_undef "UNDEF" -#define LN_undef "undefined" -#define NID_undef 0 -#define OBJ_undef 0L - -#define SN_itu_t "ITU-T" -#define LN_itu_t "itu-t" -#define NID_itu_t 645 -#define OBJ_itu_t 0L - -#define NID_ccitt 404 -#define OBJ_ccitt OBJ_itu_t - -#define SN_iso "ISO" -#define LN_iso "iso" -#define NID_iso 181 -#define OBJ_iso 1L - -#define SN_joint_iso_itu_t "JOINT-ISO-ITU-T" -#define LN_joint_iso_itu_t "joint-iso-itu-t" -#define NID_joint_iso_itu_t 646 -#define OBJ_joint_iso_itu_t 2L - -#define NID_joint_iso_ccitt 393 -#define OBJ_joint_iso_ccitt OBJ_joint_iso_itu_t - -#define SN_member_body "member-body" -#define LN_member_body "ISO Member Body" -#define NID_member_body 182 -#define OBJ_member_body OBJ_iso,2L - -#define SN_identified_organization "identified-organization" -#define NID_identified_organization 676 -#define OBJ_identified_organization OBJ_iso,3L - -#define SN_hmac_md5 "HMAC-MD5" -#define LN_hmac_md5 "hmac-md5" -#define NID_hmac_md5 780 -#define OBJ_hmac_md5 OBJ_identified_organization,6L,1L,5L,5L,8L,1L,1L - -#define SN_hmac_sha1 "HMAC-SHA1" -#define LN_hmac_sha1 "hmac-sha1" -#define NID_hmac_sha1 781 -#define OBJ_hmac_sha1 OBJ_identified_organization,6L,1L,5L,5L,8L,1L,2L - -#define SN_certicom_arc "certicom-arc" -#define NID_certicom_arc 677 -#define OBJ_certicom_arc OBJ_identified_organization,132L - -#define SN_international_organizations "international-organizations" -#define LN_international_organizations "International Organizations" -#define NID_international_organizations 647 -#define OBJ_international_organizations OBJ_joint_iso_itu_t,23L - -#define SN_wap "wap" -#define NID_wap 678 -#define OBJ_wap OBJ_international_organizations,43L - -#define SN_wap_wsg "wap-wsg" -#define NID_wap_wsg 679 -#define OBJ_wap_wsg OBJ_wap,1L - -#define SN_selected_attribute_types "selected-attribute-types" -#define LN_selected_attribute_types "Selected Attribute Types" -#define NID_selected_attribute_types 394 -#define OBJ_selected_attribute_types OBJ_joint_iso_itu_t,5L,1L,5L - -#define SN_clearance "clearance" -#define NID_clearance 395 -#define OBJ_clearance OBJ_selected_attribute_types,55L - -#define SN_ISO_US "ISO-US" -#define LN_ISO_US "ISO US Member Body" -#define NID_ISO_US 183 -#define OBJ_ISO_US OBJ_member_body,840L - -#define SN_X9_57 "X9-57" -#define LN_X9_57 "X9.57" -#define NID_X9_57 184 -#define OBJ_X9_57 OBJ_ISO_US,10040L - -#define SN_X9cm "X9cm" -#define LN_X9cm "X9.57 CM ?" -#define NID_X9cm 185 -#define OBJ_X9cm OBJ_X9_57,4L - -#define SN_dsa "DSA" -#define LN_dsa "dsaEncryption" -#define NID_dsa 116 -#define OBJ_dsa OBJ_X9cm,1L - -#define SN_dsaWithSHA1 "DSA-SHA1" -#define LN_dsaWithSHA1 "dsaWithSHA1" -#define NID_dsaWithSHA1 113 -#define OBJ_dsaWithSHA1 OBJ_X9cm,3L - -#define SN_ansi_X9_62 "ansi-X9-62" -#define LN_ansi_X9_62 "ANSI X9.62" -#define NID_ansi_X9_62 405 -#define OBJ_ansi_X9_62 OBJ_ISO_US,10045L - -#define OBJ_X9_62_id_fieldType OBJ_ansi_X9_62,1L - -#define SN_X9_62_prime_field "prime-field" -#define NID_X9_62_prime_field 406 -#define OBJ_X9_62_prime_field OBJ_X9_62_id_fieldType,1L - -#define SN_X9_62_characteristic_two_field "characteristic-two-field" -#define NID_X9_62_characteristic_two_field 407 -#define OBJ_X9_62_characteristic_two_field OBJ_X9_62_id_fieldType,2L - -#define SN_X9_62_id_characteristic_two_basis "id-characteristic-two-basis" -#define NID_X9_62_id_characteristic_two_basis 680 -#define OBJ_X9_62_id_characteristic_two_basis OBJ_X9_62_characteristic_two_field,3L - -#define SN_X9_62_onBasis "onBasis" -#define NID_X9_62_onBasis 681 -#define OBJ_X9_62_onBasis OBJ_X9_62_id_characteristic_two_basis,1L - -#define SN_X9_62_tpBasis "tpBasis" -#define NID_X9_62_tpBasis 682 -#define OBJ_X9_62_tpBasis OBJ_X9_62_id_characteristic_two_basis,2L - -#define SN_X9_62_ppBasis "ppBasis" -#define NID_X9_62_ppBasis 683 -#define OBJ_X9_62_ppBasis OBJ_X9_62_id_characteristic_two_basis,3L - -#define OBJ_X9_62_id_publicKeyType OBJ_ansi_X9_62,2L - -#define SN_X9_62_id_ecPublicKey "id-ecPublicKey" -#define NID_X9_62_id_ecPublicKey 408 -#define OBJ_X9_62_id_ecPublicKey OBJ_X9_62_id_publicKeyType,1L - -#define OBJ_X9_62_ellipticCurve OBJ_ansi_X9_62,3L - -#define OBJ_X9_62_c_TwoCurve OBJ_X9_62_ellipticCurve,0L - -#define SN_X9_62_c2pnb163v1 "c2pnb163v1" -#define NID_X9_62_c2pnb163v1 684 -#define OBJ_X9_62_c2pnb163v1 OBJ_X9_62_c_TwoCurve,1L - -#define SN_X9_62_c2pnb163v2 "c2pnb163v2" -#define NID_X9_62_c2pnb163v2 685 -#define OBJ_X9_62_c2pnb163v2 OBJ_X9_62_c_TwoCurve,2L - -#define SN_X9_62_c2pnb163v3 "c2pnb163v3" -#define NID_X9_62_c2pnb163v3 686 -#define OBJ_X9_62_c2pnb163v3 OBJ_X9_62_c_TwoCurve,3L - -#define SN_X9_62_c2pnb176v1 "c2pnb176v1" -#define NID_X9_62_c2pnb176v1 687 -#define OBJ_X9_62_c2pnb176v1 OBJ_X9_62_c_TwoCurve,4L - -#define SN_X9_62_c2tnb191v1 "c2tnb191v1" -#define NID_X9_62_c2tnb191v1 688 -#define OBJ_X9_62_c2tnb191v1 OBJ_X9_62_c_TwoCurve,5L - -#define SN_X9_62_c2tnb191v2 "c2tnb191v2" -#define NID_X9_62_c2tnb191v2 689 -#define OBJ_X9_62_c2tnb191v2 OBJ_X9_62_c_TwoCurve,6L - -#define SN_X9_62_c2tnb191v3 "c2tnb191v3" -#define NID_X9_62_c2tnb191v3 690 -#define OBJ_X9_62_c2tnb191v3 OBJ_X9_62_c_TwoCurve,7L - -#define SN_X9_62_c2onb191v4 "c2onb191v4" -#define NID_X9_62_c2onb191v4 691 -#define OBJ_X9_62_c2onb191v4 OBJ_X9_62_c_TwoCurve,8L - -#define SN_X9_62_c2onb191v5 "c2onb191v5" -#define NID_X9_62_c2onb191v5 692 -#define OBJ_X9_62_c2onb191v5 OBJ_X9_62_c_TwoCurve,9L - -#define SN_X9_62_c2pnb208w1 "c2pnb208w1" -#define NID_X9_62_c2pnb208w1 693 -#define OBJ_X9_62_c2pnb208w1 OBJ_X9_62_c_TwoCurve,10L - -#define SN_X9_62_c2tnb239v1 "c2tnb239v1" -#define NID_X9_62_c2tnb239v1 694 -#define OBJ_X9_62_c2tnb239v1 OBJ_X9_62_c_TwoCurve,11L - -#define SN_X9_62_c2tnb239v2 "c2tnb239v2" -#define NID_X9_62_c2tnb239v2 695 -#define OBJ_X9_62_c2tnb239v2 OBJ_X9_62_c_TwoCurve,12L - -#define SN_X9_62_c2tnb239v3 "c2tnb239v3" -#define NID_X9_62_c2tnb239v3 696 -#define OBJ_X9_62_c2tnb239v3 OBJ_X9_62_c_TwoCurve,13L - -#define SN_X9_62_c2onb239v4 "c2onb239v4" -#define NID_X9_62_c2onb239v4 697 -#define OBJ_X9_62_c2onb239v4 OBJ_X9_62_c_TwoCurve,14L - -#define SN_X9_62_c2onb239v5 "c2onb239v5" -#define NID_X9_62_c2onb239v5 698 -#define OBJ_X9_62_c2onb239v5 OBJ_X9_62_c_TwoCurve,15L - -#define SN_X9_62_c2pnb272w1 "c2pnb272w1" -#define NID_X9_62_c2pnb272w1 699 -#define OBJ_X9_62_c2pnb272w1 OBJ_X9_62_c_TwoCurve,16L - -#define SN_X9_62_c2pnb304w1 "c2pnb304w1" -#define NID_X9_62_c2pnb304w1 700 -#define OBJ_X9_62_c2pnb304w1 OBJ_X9_62_c_TwoCurve,17L - -#define SN_X9_62_c2tnb359v1 "c2tnb359v1" -#define NID_X9_62_c2tnb359v1 701 -#define OBJ_X9_62_c2tnb359v1 OBJ_X9_62_c_TwoCurve,18L - -#define SN_X9_62_c2pnb368w1 "c2pnb368w1" -#define NID_X9_62_c2pnb368w1 702 -#define OBJ_X9_62_c2pnb368w1 OBJ_X9_62_c_TwoCurve,19L - -#define SN_X9_62_c2tnb431r1 "c2tnb431r1" -#define NID_X9_62_c2tnb431r1 703 -#define OBJ_X9_62_c2tnb431r1 OBJ_X9_62_c_TwoCurve,20L - -#define OBJ_X9_62_primeCurve OBJ_X9_62_ellipticCurve,1L - -#define SN_X9_62_prime192v1 "prime192v1" -#define NID_X9_62_prime192v1 409 -#define OBJ_X9_62_prime192v1 OBJ_X9_62_primeCurve,1L - -#define SN_X9_62_prime192v2 "prime192v2" -#define NID_X9_62_prime192v2 410 -#define OBJ_X9_62_prime192v2 OBJ_X9_62_primeCurve,2L - -#define SN_X9_62_prime192v3 "prime192v3" -#define NID_X9_62_prime192v3 411 -#define OBJ_X9_62_prime192v3 OBJ_X9_62_primeCurve,3L - -#define SN_X9_62_prime239v1 "prime239v1" -#define NID_X9_62_prime239v1 412 -#define OBJ_X9_62_prime239v1 OBJ_X9_62_primeCurve,4L - -#define SN_X9_62_prime239v2 "prime239v2" -#define NID_X9_62_prime239v2 413 -#define OBJ_X9_62_prime239v2 OBJ_X9_62_primeCurve,5L - -#define SN_X9_62_prime239v3 "prime239v3" -#define NID_X9_62_prime239v3 414 -#define OBJ_X9_62_prime239v3 OBJ_X9_62_primeCurve,6L - -#define SN_X9_62_prime256v1 "prime256v1" -#define NID_X9_62_prime256v1 415 -#define OBJ_X9_62_prime256v1 OBJ_X9_62_primeCurve,7L - -#define OBJ_X9_62_id_ecSigType OBJ_ansi_X9_62,4L - -#define SN_ecdsa_with_SHA1 "ecdsa-with-SHA1" -#define NID_ecdsa_with_SHA1 416 -#define OBJ_ecdsa_with_SHA1 OBJ_X9_62_id_ecSigType,1L - -#define SN_ecdsa_with_Recommended "ecdsa-with-Recommended" -#define NID_ecdsa_with_Recommended 791 -#define OBJ_ecdsa_with_Recommended OBJ_X9_62_id_ecSigType,2L - -#define SN_ecdsa_with_Specified "ecdsa-with-Specified" -#define NID_ecdsa_with_Specified 792 -#define OBJ_ecdsa_with_Specified OBJ_X9_62_id_ecSigType,3L - -#define SN_ecdsa_with_SHA224 "ecdsa-with-SHA224" -#define NID_ecdsa_with_SHA224 793 -#define OBJ_ecdsa_with_SHA224 OBJ_ecdsa_with_Specified,1L - -#define SN_ecdsa_with_SHA256 "ecdsa-with-SHA256" -#define NID_ecdsa_with_SHA256 794 -#define OBJ_ecdsa_with_SHA256 OBJ_ecdsa_with_Specified,2L - -#define SN_ecdsa_with_SHA384 "ecdsa-with-SHA384" -#define NID_ecdsa_with_SHA384 795 -#define OBJ_ecdsa_with_SHA384 OBJ_ecdsa_with_Specified,3L - -#define SN_ecdsa_with_SHA512 "ecdsa-with-SHA512" -#define NID_ecdsa_with_SHA512 796 -#define OBJ_ecdsa_with_SHA512 OBJ_ecdsa_with_Specified,4L - -#define OBJ_secg_ellipticCurve OBJ_certicom_arc,0L - -#define SN_secp112r1 "secp112r1" -#define NID_secp112r1 704 -#define OBJ_secp112r1 OBJ_secg_ellipticCurve,6L - -#define SN_secp112r2 "secp112r2" -#define NID_secp112r2 705 -#define OBJ_secp112r2 OBJ_secg_ellipticCurve,7L - -#define SN_secp128r1 "secp128r1" -#define NID_secp128r1 706 -#define OBJ_secp128r1 OBJ_secg_ellipticCurve,28L - -#define SN_secp128r2 "secp128r2" -#define NID_secp128r2 707 -#define OBJ_secp128r2 OBJ_secg_ellipticCurve,29L - -#define SN_secp160k1 "secp160k1" -#define NID_secp160k1 708 -#define OBJ_secp160k1 OBJ_secg_ellipticCurve,9L - -#define SN_secp160r1 "secp160r1" -#define NID_secp160r1 709 -#define OBJ_secp160r1 OBJ_secg_ellipticCurve,8L - -#define SN_secp160r2 "secp160r2" -#define NID_secp160r2 710 -#define OBJ_secp160r2 OBJ_secg_ellipticCurve,30L - -#define SN_secp192k1 "secp192k1" -#define NID_secp192k1 711 -#define OBJ_secp192k1 OBJ_secg_ellipticCurve,31L - -#define SN_secp224k1 "secp224k1" -#define NID_secp224k1 712 -#define OBJ_secp224k1 OBJ_secg_ellipticCurve,32L - -#define SN_secp224r1 "secp224r1" -#define NID_secp224r1 713 -#define OBJ_secp224r1 OBJ_secg_ellipticCurve,33L - -#define SN_secp256k1 "secp256k1" -#define NID_secp256k1 714 -#define OBJ_secp256k1 OBJ_secg_ellipticCurve,10L - -#define SN_secp384r1 "secp384r1" -#define NID_secp384r1 715 -#define OBJ_secp384r1 OBJ_secg_ellipticCurve,34L - -#define SN_secp521r1 "secp521r1" -#define NID_secp521r1 716 -#define OBJ_secp521r1 OBJ_secg_ellipticCurve,35L - -#define SN_sect113r1 "sect113r1" -#define NID_sect113r1 717 -#define OBJ_sect113r1 OBJ_secg_ellipticCurve,4L - -#define SN_sect113r2 "sect113r2" -#define NID_sect113r2 718 -#define OBJ_sect113r2 OBJ_secg_ellipticCurve,5L - -#define SN_sect131r1 "sect131r1" -#define NID_sect131r1 719 -#define OBJ_sect131r1 OBJ_secg_ellipticCurve,22L - -#define SN_sect131r2 "sect131r2" -#define NID_sect131r2 720 -#define OBJ_sect131r2 OBJ_secg_ellipticCurve,23L - -#define SN_sect163k1 "sect163k1" -#define NID_sect163k1 721 -#define OBJ_sect163k1 OBJ_secg_ellipticCurve,1L - -#define SN_sect163r1 "sect163r1" -#define NID_sect163r1 722 -#define OBJ_sect163r1 OBJ_secg_ellipticCurve,2L - -#define SN_sect163r2 "sect163r2" -#define NID_sect163r2 723 -#define OBJ_sect163r2 OBJ_secg_ellipticCurve,15L - -#define SN_sect193r1 "sect193r1" -#define NID_sect193r1 724 -#define OBJ_sect193r1 OBJ_secg_ellipticCurve,24L - -#define SN_sect193r2 "sect193r2" -#define NID_sect193r2 725 -#define OBJ_sect193r2 OBJ_secg_ellipticCurve,25L - -#define SN_sect233k1 "sect233k1" -#define NID_sect233k1 726 -#define OBJ_sect233k1 OBJ_secg_ellipticCurve,26L - -#define SN_sect233r1 "sect233r1" -#define NID_sect233r1 727 -#define OBJ_sect233r1 OBJ_secg_ellipticCurve,27L - -#define SN_sect239k1 "sect239k1" -#define NID_sect239k1 728 -#define OBJ_sect239k1 OBJ_secg_ellipticCurve,3L - -#define SN_sect283k1 "sect283k1" -#define NID_sect283k1 729 -#define OBJ_sect283k1 OBJ_secg_ellipticCurve,16L - -#define SN_sect283r1 "sect283r1" -#define NID_sect283r1 730 -#define OBJ_sect283r1 OBJ_secg_ellipticCurve,17L - -#define SN_sect409k1 "sect409k1" -#define NID_sect409k1 731 -#define OBJ_sect409k1 OBJ_secg_ellipticCurve,36L - -#define SN_sect409r1 "sect409r1" -#define NID_sect409r1 732 -#define OBJ_sect409r1 OBJ_secg_ellipticCurve,37L - -#define SN_sect571k1 "sect571k1" -#define NID_sect571k1 733 -#define OBJ_sect571k1 OBJ_secg_ellipticCurve,38L - -#define SN_sect571r1 "sect571r1" -#define NID_sect571r1 734 -#define OBJ_sect571r1 OBJ_secg_ellipticCurve,39L - -#define OBJ_wap_wsg_idm_ecid OBJ_wap_wsg,4L - -#define SN_wap_wsg_idm_ecid_wtls1 "wap-wsg-idm-ecid-wtls1" -#define NID_wap_wsg_idm_ecid_wtls1 735 -#define OBJ_wap_wsg_idm_ecid_wtls1 OBJ_wap_wsg_idm_ecid,1L - -#define SN_wap_wsg_idm_ecid_wtls3 "wap-wsg-idm-ecid-wtls3" -#define NID_wap_wsg_idm_ecid_wtls3 736 -#define OBJ_wap_wsg_idm_ecid_wtls3 OBJ_wap_wsg_idm_ecid,3L - -#define SN_wap_wsg_idm_ecid_wtls4 "wap-wsg-idm-ecid-wtls4" -#define NID_wap_wsg_idm_ecid_wtls4 737 -#define OBJ_wap_wsg_idm_ecid_wtls4 OBJ_wap_wsg_idm_ecid,4L - -#define SN_wap_wsg_idm_ecid_wtls5 "wap-wsg-idm-ecid-wtls5" -#define NID_wap_wsg_idm_ecid_wtls5 738 -#define OBJ_wap_wsg_idm_ecid_wtls5 OBJ_wap_wsg_idm_ecid,5L - -#define SN_wap_wsg_idm_ecid_wtls6 "wap-wsg-idm-ecid-wtls6" -#define NID_wap_wsg_idm_ecid_wtls6 739 -#define OBJ_wap_wsg_idm_ecid_wtls6 OBJ_wap_wsg_idm_ecid,6L - -#define SN_wap_wsg_idm_ecid_wtls7 "wap-wsg-idm-ecid-wtls7" -#define NID_wap_wsg_idm_ecid_wtls7 740 -#define OBJ_wap_wsg_idm_ecid_wtls7 OBJ_wap_wsg_idm_ecid,7L - -#define SN_wap_wsg_idm_ecid_wtls8 "wap-wsg-idm-ecid-wtls8" -#define NID_wap_wsg_idm_ecid_wtls8 741 -#define OBJ_wap_wsg_idm_ecid_wtls8 OBJ_wap_wsg_idm_ecid,8L - -#define SN_wap_wsg_idm_ecid_wtls9 "wap-wsg-idm-ecid-wtls9" -#define NID_wap_wsg_idm_ecid_wtls9 742 -#define OBJ_wap_wsg_idm_ecid_wtls9 OBJ_wap_wsg_idm_ecid,9L - -#define SN_wap_wsg_idm_ecid_wtls10 "wap-wsg-idm-ecid-wtls10" -#define NID_wap_wsg_idm_ecid_wtls10 743 -#define OBJ_wap_wsg_idm_ecid_wtls10 OBJ_wap_wsg_idm_ecid,10L - -#define SN_wap_wsg_idm_ecid_wtls11 "wap-wsg-idm-ecid-wtls11" -#define NID_wap_wsg_idm_ecid_wtls11 744 -#define OBJ_wap_wsg_idm_ecid_wtls11 OBJ_wap_wsg_idm_ecid,11L - -#define SN_wap_wsg_idm_ecid_wtls12 "wap-wsg-idm-ecid-wtls12" -#define NID_wap_wsg_idm_ecid_wtls12 745 -#define OBJ_wap_wsg_idm_ecid_wtls12 OBJ_wap_wsg_idm_ecid,12L - -#define SN_cast5_cbc "CAST5-CBC" -#define LN_cast5_cbc "cast5-cbc" -#define NID_cast5_cbc 108 -#define OBJ_cast5_cbc OBJ_ISO_US,113533L,7L,66L,10L - -#define SN_cast5_ecb "CAST5-ECB" -#define LN_cast5_ecb "cast5-ecb" -#define NID_cast5_ecb 109 - -#define SN_cast5_cfb64 "CAST5-CFB" -#define LN_cast5_cfb64 "cast5-cfb" -#define NID_cast5_cfb64 110 - -#define SN_cast5_ofb64 "CAST5-OFB" -#define LN_cast5_ofb64 "cast5-ofb" -#define NID_cast5_ofb64 111 - -#define LN_pbeWithMD5AndCast5_CBC "pbeWithMD5AndCast5CBC" -#define NID_pbeWithMD5AndCast5_CBC 112 -#define OBJ_pbeWithMD5AndCast5_CBC OBJ_ISO_US,113533L,7L,66L,12L - -#define SN_id_PasswordBasedMAC "id-PasswordBasedMAC" -#define LN_id_PasswordBasedMAC "password based MAC" -#define NID_id_PasswordBasedMAC 782 -#define OBJ_id_PasswordBasedMAC OBJ_ISO_US,113533L,7L,66L,13L - -#define SN_id_DHBasedMac "id-DHBasedMac" -#define LN_id_DHBasedMac "Diffie-Hellman based MAC" -#define NID_id_DHBasedMac 783 -#define OBJ_id_DHBasedMac OBJ_ISO_US,113533L,7L,66L,30L - -#define SN_rsadsi "rsadsi" -#define LN_rsadsi "RSA Data Security, Inc." -#define NID_rsadsi 1 -#define OBJ_rsadsi OBJ_ISO_US,113549L - -#define SN_pkcs "pkcs" -#define LN_pkcs "RSA Data Security, Inc. PKCS" -#define NID_pkcs 2 -#define OBJ_pkcs OBJ_rsadsi,1L - -#define SN_pkcs1 "pkcs1" -#define NID_pkcs1 186 -#define OBJ_pkcs1 OBJ_pkcs,1L - -#define LN_rsaEncryption "rsaEncryption" -#define NID_rsaEncryption 6 -#define OBJ_rsaEncryption OBJ_pkcs1,1L - -#define SN_md2WithRSAEncryption "RSA-MD2" -#define LN_md2WithRSAEncryption "md2WithRSAEncryption" -#define NID_md2WithRSAEncryption 7 -#define OBJ_md2WithRSAEncryption OBJ_pkcs1,2L - -#define SN_md4WithRSAEncryption "RSA-MD4" -#define LN_md4WithRSAEncryption "md4WithRSAEncryption" -#define NID_md4WithRSAEncryption 396 -#define OBJ_md4WithRSAEncryption OBJ_pkcs1,3L - -#define SN_md5WithRSAEncryption "RSA-MD5" -#define LN_md5WithRSAEncryption "md5WithRSAEncryption" -#define NID_md5WithRSAEncryption 8 -#define OBJ_md5WithRSAEncryption OBJ_pkcs1,4L - -#define SN_sha1WithRSAEncryption "RSA-SHA1" -#define LN_sha1WithRSAEncryption "sha1WithRSAEncryption" -#define NID_sha1WithRSAEncryption 65 -#define OBJ_sha1WithRSAEncryption OBJ_pkcs1,5L - -#define SN_rsaesOaep "RSAES-OAEP" -#define LN_rsaesOaep "rsaesOaep" -#define NID_rsaesOaep 919 -#define OBJ_rsaesOaep OBJ_pkcs1,7L - -#define SN_mgf1 "MGF1" -#define LN_mgf1 "mgf1" -#define NID_mgf1 911 -#define OBJ_mgf1 OBJ_pkcs1,8L - -#define SN_pSpecified "PSPECIFIED" -#define LN_pSpecified "pSpecified" -#define NID_pSpecified 935 -#define OBJ_pSpecified OBJ_pkcs1,9L - -#define SN_rsassaPss "RSASSA-PSS" -#define LN_rsassaPss "rsassaPss" -#define NID_rsassaPss 912 -#define OBJ_rsassaPss OBJ_pkcs1,10L - -#define SN_sha256WithRSAEncryption "RSA-SHA256" -#define LN_sha256WithRSAEncryption "sha256WithRSAEncryption" -#define NID_sha256WithRSAEncryption 668 -#define OBJ_sha256WithRSAEncryption OBJ_pkcs1,11L - -#define SN_sha384WithRSAEncryption "RSA-SHA384" -#define LN_sha384WithRSAEncryption "sha384WithRSAEncryption" -#define NID_sha384WithRSAEncryption 669 -#define OBJ_sha384WithRSAEncryption OBJ_pkcs1,12L - -#define SN_sha512WithRSAEncryption "RSA-SHA512" -#define LN_sha512WithRSAEncryption "sha512WithRSAEncryption" -#define NID_sha512WithRSAEncryption 670 -#define OBJ_sha512WithRSAEncryption OBJ_pkcs1,13L - -#define SN_sha224WithRSAEncryption "RSA-SHA224" -#define LN_sha224WithRSAEncryption "sha224WithRSAEncryption" -#define NID_sha224WithRSAEncryption 671 -#define OBJ_sha224WithRSAEncryption OBJ_pkcs1,14L - -#define SN_pkcs3 "pkcs3" -#define NID_pkcs3 27 -#define OBJ_pkcs3 OBJ_pkcs,3L - -#define LN_dhKeyAgreement "dhKeyAgreement" -#define NID_dhKeyAgreement 28 -#define OBJ_dhKeyAgreement OBJ_pkcs3,1L - -#define SN_pkcs5 "pkcs5" -#define NID_pkcs5 187 -#define OBJ_pkcs5 OBJ_pkcs,5L - -#define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES" -#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC" -#define NID_pbeWithMD2AndDES_CBC 9 -#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs5,1L - -#define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES" -#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC" -#define NID_pbeWithMD5AndDES_CBC 10 -#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs5,3L - -#define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64" -#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC" -#define NID_pbeWithMD2AndRC2_CBC 168 -#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs5,4L - -#define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64" -#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC" -#define NID_pbeWithMD5AndRC2_CBC 169 -#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs5,6L - -#define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES" -#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC" -#define NID_pbeWithSHA1AndDES_CBC 170 -#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs5,10L - -#define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64" -#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC" -#define NID_pbeWithSHA1AndRC2_CBC 68 -#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs5,11L - -#define LN_id_pbkdf2 "PBKDF2" -#define NID_id_pbkdf2 69 -#define OBJ_id_pbkdf2 OBJ_pkcs5,12L - -#define LN_pbes2 "PBES2" -#define NID_pbes2 161 -#define OBJ_pbes2 OBJ_pkcs5,13L - -#define LN_pbmac1 "PBMAC1" -#define NID_pbmac1 162 -#define OBJ_pbmac1 OBJ_pkcs5,14L - -#define SN_pkcs7 "pkcs7" -#define NID_pkcs7 20 -#define OBJ_pkcs7 OBJ_pkcs,7L - -#define LN_pkcs7_data "pkcs7-data" -#define NID_pkcs7_data 21 -#define OBJ_pkcs7_data OBJ_pkcs7,1L - -#define LN_pkcs7_signed "pkcs7-signedData" -#define NID_pkcs7_signed 22 -#define OBJ_pkcs7_signed OBJ_pkcs7,2L - -#define LN_pkcs7_enveloped "pkcs7-envelopedData" -#define NID_pkcs7_enveloped 23 -#define OBJ_pkcs7_enveloped OBJ_pkcs7,3L - -#define LN_pkcs7_signedAndEnveloped "pkcs7-signedAndEnvelopedData" -#define NID_pkcs7_signedAndEnveloped 24 -#define OBJ_pkcs7_signedAndEnveloped OBJ_pkcs7,4L - -#define LN_pkcs7_digest "pkcs7-digestData" -#define NID_pkcs7_digest 25 -#define OBJ_pkcs7_digest OBJ_pkcs7,5L - -#define LN_pkcs7_encrypted "pkcs7-encryptedData" -#define NID_pkcs7_encrypted 26 -#define OBJ_pkcs7_encrypted OBJ_pkcs7,6L - -#define SN_pkcs9 "pkcs9" -#define NID_pkcs9 47 -#define OBJ_pkcs9 OBJ_pkcs,9L - -#define LN_pkcs9_emailAddress "emailAddress" -#define NID_pkcs9_emailAddress 48 -#define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L - -#define LN_pkcs9_unstructuredName "unstructuredName" -#define NID_pkcs9_unstructuredName 49 -#define OBJ_pkcs9_unstructuredName OBJ_pkcs9,2L - -#define LN_pkcs9_contentType "contentType" -#define NID_pkcs9_contentType 50 -#define OBJ_pkcs9_contentType OBJ_pkcs9,3L - -#define LN_pkcs9_messageDigest "messageDigest" -#define NID_pkcs9_messageDigest 51 -#define OBJ_pkcs9_messageDigest OBJ_pkcs9,4L - -#define LN_pkcs9_signingTime "signingTime" -#define NID_pkcs9_signingTime 52 -#define OBJ_pkcs9_signingTime OBJ_pkcs9,5L - -#define LN_pkcs9_countersignature "countersignature" -#define NID_pkcs9_countersignature 53 -#define OBJ_pkcs9_countersignature OBJ_pkcs9,6L - -#define LN_pkcs9_challengePassword "challengePassword" -#define NID_pkcs9_challengePassword 54 -#define OBJ_pkcs9_challengePassword OBJ_pkcs9,7L - -#define LN_pkcs9_unstructuredAddress "unstructuredAddress" -#define NID_pkcs9_unstructuredAddress 55 -#define OBJ_pkcs9_unstructuredAddress OBJ_pkcs9,8L - -#define LN_pkcs9_extCertAttributes "extendedCertificateAttributes" -#define NID_pkcs9_extCertAttributes 56 -#define OBJ_pkcs9_extCertAttributes OBJ_pkcs9,9L - -#define SN_ext_req "extReq" -#define LN_ext_req "Extension Request" -#define NID_ext_req 172 -#define OBJ_ext_req OBJ_pkcs9,14L - -#define SN_SMIMECapabilities "SMIME-CAPS" -#define LN_SMIMECapabilities "S/MIME Capabilities" -#define NID_SMIMECapabilities 167 -#define OBJ_SMIMECapabilities OBJ_pkcs9,15L - -#define SN_SMIME "SMIME" -#define LN_SMIME "S/MIME" -#define NID_SMIME 188 -#define OBJ_SMIME OBJ_pkcs9,16L - -#define SN_id_smime_mod "id-smime-mod" -#define NID_id_smime_mod 189 -#define OBJ_id_smime_mod OBJ_SMIME,0L - -#define SN_id_smime_ct "id-smime-ct" -#define NID_id_smime_ct 190 -#define OBJ_id_smime_ct OBJ_SMIME,1L - -#define SN_id_smime_aa "id-smime-aa" -#define NID_id_smime_aa 191 -#define OBJ_id_smime_aa OBJ_SMIME,2L - -#define SN_id_smime_alg "id-smime-alg" -#define NID_id_smime_alg 192 -#define OBJ_id_smime_alg OBJ_SMIME,3L - -#define SN_id_smime_cd "id-smime-cd" -#define NID_id_smime_cd 193 -#define OBJ_id_smime_cd OBJ_SMIME,4L - -#define SN_id_smime_spq "id-smime-spq" -#define NID_id_smime_spq 194 -#define OBJ_id_smime_spq OBJ_SMIME,5L - -#define SN_id_smime_cti "id-smime-cti" -#define NID_id_smime_cti 195 -#define OBJ_id_smime_cti OBJ_SMIME,6L - -#define SN_id_smime_mod_cms "id-smime-mod-cms" -#define NID_id_smime_mod_cms 196 -#define OBJ_id_smime_mod_cms OBJ_id_smime_mod,1L - -#define SN_id_smime_mod_ess "id-smime-mod-ess" -#define NID_id_smime_mod_ess 197 -#define OBJ_id_smime_mod_ess OBJ_id_smime_mod,2L - -#define SN_id_smime_mod_oid "id-smime-mod-oid" -#define NID_id_smime_mod_oid 198 -#define OBJ_id_smime_mod_oid OBJ_id_smime_mod,3L - -#define SN_id_smime_mod_msg_v3 "id-smime-mod-msg-v3" -#define NID_id_smime_mod_msg_v3 199 -#define OBJ_id_smime_mod_msg_v3 OBJ_id_smime_mod,4L - -#define SN_id_smime_mod_ets_eSignature_88 "id-smime-mod-ets-eSignature-88" -#define NID_id_smime_mod_ets_eSignature_88 200 -#define OBJ_id_smime_mod_ets_eSignature_88 OBJ_id_smime_mod,5L - -#define SN_id_smime_mod_ets_eSignature_97 "id-smime-mod-ets-eSignature-97" -#define NID_id_smime_mod_ets_eSignature_97 201 -#define OBJ_id_smime_mod_ets_eSignature_97 OBJ_id_smime_mod,6L - -#define SN_id_smime_mod_ets_eSigPolicy_88 "id-smime-mod-ets-eSigPolicy-88" -#define NID_id_smime_mod_ets_eSigPolicy_88 202 -#define OBJ_id_smime_mod_ets_eSigPolicy_88 OBJ_id_smime_mod,7L - -#define SN_id_smime_mod_ets_eSigPolicy_97 "id-smime-mod-ets-eSigPolicy-97" -#define NID_id_smime_mod_ets_eSigPolicy_97 203 -#define OBJ_id_smime_mod_ets_eSigPolicy_97 OBJ_id_smime_mod,8L - -#define SN_id_smime_ct_receipt "id-smime-ct-receipt" -#define NID_id_smime_ct_receipt 204 -#define OBJ_id_smime_ct_receipt OBJ_id_smime_ct,1L - -#define SN_id_smime_ct_authData "id-smime-ct-authData" -#define NID_id_smime_ct_authData 205 -#define OBJ_id_smime_ct_authData OBJ_id_smime_ct,2L - -#define SN_id_smime_ct_publishCert "id-smime-ct-publishCert" -#define NID_id_smime_ct_publishCert 206 -#define OBJ_id_smime_ct_publishCert OBJ_id_smime_ct,3L - -#define SN_id_smime_ct_TSTInfo "id-smime-ct-TSTInfo" -#define NID_id_smime_ct_TSTInfo 207 -#define OBJ_id_smime_ct_TSTInfo OBJ_id_smime_ct,4L - -#define SN_id_smime_ct_TDTInfo "id-smime-ct-TDTInfo" -#define NID_id_smime_ct_TDTInfo 208 -#define OBJ_id_smime_ct_TDTInfo OBJ_id_smime_ct,5L - -#define SN_id_smime_ct_contentInfo "id-smime-ct-contentInfo" -#define NID_id_smime_ct_contentInfo 209 -#define OBJ_id_smime_ct_contentInfo OBJ_id_smime_ct,6L - -#define SN_id_smime_ct_DVCSRequestData "id-smime-ct-DVCSRequestData" -#define NID_id_smime_ct_DVCSRequestData 210 -#define OBJ_id_smime_ct_DVCSRequestData OBJ_id_smime_ct,7L - -#define SN_id_smime_ct_DVCSResponseData "id-smime-ct-DVCSResponseData" -#define NID_id_smime_ct_DVCSResponseData 211 -#define OBJ_id_smime_ct_DVCSResponseData OBJ_id_smime_ct,8L - -#define SN_id_smime_ct_compressedData "id-smime-ct-compressedData" -#define NID_id_smime_ct_compressedData 786 -#define OBJ_id_smime_ct_compressedData OBJ_id_smime_ct,9L - -#define SN_id_ct_asciiTextWithCRLF "id-ct-asciiTextWithCRLF" -#define NID_id_ct_asciiTextWithCRLF 787 -#define OBJ_id_ct_asciiTextWithCRLF OBJ_id_smime_ct,27L - -#define SN_id_smime_aa_receiptRequest "id-smime-aa-receiptRequest" -#define NID_id_smime_aa_receiptRequest 212 -#define OBJ_id_smime_aa_receiptRequest OBJ_id_smime_aa,1L - -#define SN_id_smime_aa_securityLabel "id-smime-aa-securityLabel" -#define NID_id_smime_aa_securityLabel 213 -#define OBJ_id_smime_aa_securityLabel OBJ_id_smime_aa,2L - -#define SN_id_smime_aa_mlExpandHistory "id-smime-aa-mlExpandHistory" -#define NID_id_smime_aa_mlExpandHistory 214 -#define OBJ_id_smime_aa_mlExpandHistory OBJ_id_smime_aa,3L - -#define SN_id_smime_aa_contentHint "id-smime-aa-contentHint" -#define NID_id_smime_aa_contentHint 215 -#define OBJ_id_smime_aa_contentHint OBJ_id_smime_aa,4L - -#define SN_id_smime_aa_msgSigDigest "id-smime-aa-msgSigDigest" -#define NID_id_smime_aa_msgSigDigest 216 -#define OBJ_id_smime_aa_msgSigDigest OBJ_id_smime_aa,5L - -#define SN_id_smime_aa_encapContentType "id-smime-aa-encapContentType" -#define NID_id_smime_aa_encapContentType 217 -#define OBJ_id_smime_aa_encapContentType OBJ_id_smime_aa,6L - -#define SN_id_smime_aa_contentIdentifier "id-smime-aa-contentIdentifier" -#define NID_id_smime_aa_contentIdentifier 218 -#define OBJ_id_smime_aa_contentIdentifier OBJ_id_smime_aa,7L - -#define SN_id_smime_aa_macValue "id-smime-aa-macValue" -#define NID_id_smime_aa_macValue 219 -#define OBJ_id_smime_aa_macValue OBJ_id_smime_aa,8L - -#define SN_id_smime_aa_equivalentLabels "id-smime-aa-equivalentLabels" -#define NID_id_smime_aa_equivalentLabels 220 -#define OBJ_id_smime_aa_equivalentLabels OBJ_id_smime_aa,9L - -#define SN_id_smime_aa_contentReference "id-smime-aa-contentReference" -#define NID_id_smime_aa_contentReference 221 -#define OBJ_id_smime_aa_contentReference OBJ_id_smime_aa,10L - -#define SN_id_smime_aa_encrypKeyPref "id-smime-aa-encrypKeyPref" -#define NID_id_smime_aa_encrypKeyPref 222 -#define OBJ_id_smime_aa_encrypKeyPref OBJ_id_smime_aa,11L - -#define SN_id_smime_aa_signingCertificate "id-smime-aa-signingCertificate" -#define NID_id_smime_aa_signingCertificate 223 -#define OBJ_id_smime_aa_signingCertificate OBJ_id_smime_aa,12L - -#define SN_id_smime_aa_smimeEncryptCerts "id-smime-aa-smimeEncryptCerts" -#define NID_id_smime_aa_smimeEncryptCerts 224 -#define OBJ_id_smime_aa_smimeEncryptCerts OBJ_id_smime_aa,13L - -#define SN_id_smime_aa_timeStampToken "id-smime-aa-timeStampToken" -#define NID_id_smime_aa_timeStampToken 225 -#define OBJ_id_smime_aa_timeStampToken OBJ_id_smime_aa,14L - -#define SN_id_smime_aa_ets_sigPolicyId "id-smime-aa-ets-sigPolicyId" -#define NID_id_smime_aa_ets_sigPolicyId 226 -#define OBJ_id_smime_aa_ets_sigPolicyId OBJ_id_smime_aa,15L - -#define SN_id_smime_aa_ets_commitmentType "id-smime-aa-ets-commitmentType" -#define NID_id_smime_aa_ets_commitmentType 227 -#define OBJ_id_smime_aa_ets_commitmentType OBJ_id_smime_aa,16L - -#define SN_id_smime_aa_ets_signerLocation "id-smime-aa-ets-signerLocation" -#define NID_id_smime_aa_ets_signerLocation 228 -#define OBJ_id_smime_aa_ets_signerLocation OBJ_id_smime_aa,17L - -#define SN_id_smime_aa_ets_signerAttr "id-smime-aa-ets-signerAttr" -#define NID_id_smime_aa_ets_signerAttr 229 -#define OBJ_id_smime_aa_ets_signerAttr OBJ_id_smime_aa,18L - -#define SN_id_smime_aa_ets_otherSigCert "id-smime-aa-ets-otherSigCert" -#define NID_id_smime_aa_ets_otherSigCert 230 -#define OBJ_id_smime_aa_ets_otherSigCert OBJ_id_smime_aa,19L - -#define SN_id_smime_aa_ets_contentTimestamp "id-smime-aa-ets-contentTimestamp" -#define NID_id_smime_aa_ets_contentTimestamp 231 -#define OBJ_id_smime_aa_ets_contentTimestamp OBJ_id_smime_aa,20L - -#define SN_id_smime_aa_ets_CertificateRefs "id-smime-aa-ets-CertificateRefs" -#define NID_id_smime_aa_ets_CertificateRefs 232 -#define OBJ_id_smime_aa_ets_CertificateRefs OBJ_id_smime_aa,21L - -#define SN_id_smime_aa_ets_RevocationRefs "id-smime-aa-ets-RevocationRefs" -#define NID_id_smime_aa_ets_RevocationRefs 233 -#define OBJ_id_smime_aa_ets_RevocationRefs OBJ_id_smime_aa,22L - -#define SN_id_smime_aa_ets_certValues "id-smime-aa-ets-certValues" -#define NID_id_smime_aa_ets_certValues 234 -#define OBJ_id_smime_aa_ets_certValues OBJ_id_smime_aa,23L - -#define SN_id_smime_aa_ets_revocationValues "id-smime-aa-ets-revocationValues" -#define NID_id_smime_aa_ets_revocationValues 235 -#define OBJ_id_smime_aa_ets_revocationValues OBJ_id_smime_aa,24L - -#define SN_id_smime_aa_ets_escTimeStamp "id-smime-aa-ets-escTimeStamp" -#define NID_id_smime_aa_ets_escTimeStamp 236 -#define OBJ_id_smime_aa_ets_escTimeStamp OBJ_id_smime_aa,25L - -#define SN_id_smime_aa_ets_certCRLTimestamp "id-smime-aa-ets-certCRLTimestamp" -#define NID_id_smime_aa_ets_certCRLTimestamp 237 -#define OBJ_id_smime_aa_ets_certCRLTimestamp OBJ_id_smime_aa,26L - -#define SN_id_smime_aa_ets_archiveTimeStamp "id-smime-aa-ets-archiveTimeStamp" -#define NID_id_smime_aa_ets_archiveTimeStamp 238 -#define OBJ_id_smime_aa_ets_archiveTimeStamp OBJ_id_smime_aa,27L - -#define SN_id_smime_aa_signatureType "id-smime-aa-signatureType" -#define NID_id_smime_aa_signatureType 239 -#define OBJ_id_smime_aa_signatureType OBJ_id_smime_aa,28L - -#define SN_id_smime_aa_dvcs_dvc "id-smime-aa-dvcs-dvc" -#define NID_id_smime_aa_dvcs_dvc 240 -#define OBJ_id_smime_aa_dvcs_dvc OBJ_id_smime_aa,29L - -#define SN_id_smime_alg_ESDHwith3DES "id-smime-alg-ESDHwith3DES" -#define NID_id_smime_alg_ESDHwith3DES 241 -#define OBJ_id_smime_alg_ESDHwith3DES OBJ_id_smime_alg,1L - -#define SN_id_smime_alg_ESDHwithRC2 "id-smime-alg-ESDHwithRC2" -#define NID_id_smime_alg_ESDHwithRC2 242 -#define OBJ_id_smime_alg_ESDHwithRC2 OBJ_id_smime_alg,2L - -#define SN_id_smime_alg_3DESwrap "id-smime-alg-3DESwrap" -#define NID_id_smime_alg_3DESwrap 243 -#define OBJ_id_smime_alg_3DESwrap OBJ_id_smime_alg,3L - -#define SN_id_smime_alg_RC2wrap "id-smime-alg-RC2wrap" -#define NID_id_smime_alg_RC2wrap 244 -#define OBJ_id_smime_alg_RC2wrap OBJ_id_smime_alg,4L - -#define SN_id_smime_alg_ESDH "id-smime-alg-ESDH" -#define NID_id_smime_alg_ESDH 245 -#define OBJ_id_smime_alg_ESDH OBJ_id_smime_alg,5L - -#define SN_id_smime_alg_CMS3DESwrap "id-smime-alg-CMS3DESwrap" -#define NID_id_smime_alg_CMS3DESwrap 246 -#define OBJ_id_smime_alg_CMS3DESwrap OBJ_id_smime_alg,6L - -#define SN_id_smime_alg_CMSRC2wrap "id-smime-alg-CMSRC2wrap" -#define NID_id_smime_alg_CMSRC2wrap 247 -#define OBJ_id_smime_alg_CMSRC2wrap OBJ_id_smime_alg,7L - -#define SN_id_alg_PWRI_KEK "id-alg-PWRI-KEK" -#define NID_id_alg_PWRI_KEK 893 -#define OBJ_id_alg_PWRI_KEK OBJ_id_smime_alg,9L - -#define SN_id_smime_cd_ldap "id-smime-cd-ldap" -#define NID_id_smime_cd_ldap 248 -#define OBJ_id_smime_cd_ldap OBJ_id_smime_cd,1L - -#define SN_id_smime_spq_ets_sqt_uri "id-smime-spq-ets-sqt-uri" -#define NID_id_smime_spq_ets_sqt_uri 249 -#define OBJ_id_smime_spq_ets_sqt_uri OBJ_id_smime_spq,1L - -#define SN_id_smime_spq_ets_sqt_unotice "id-smime-spq-ets-sqt-unotice" -#define NID_id_smime_spq_ets_sqt_unotice 250 -#define OBJ_id_smime_spq_ets_sqt_unotice OBJ_id_smime_spq,2L - -#define SN_id_smime_cti_ets_proofOfOrigin "id-smime-cti-ets-proofOfOrigin" -#define NID_id_smime_cti_ets_proofOfOrigin 251 -#define OBJ_id_smime_cti_ets_proofOfOrigin OBJ_id_smime_cti,1L - -#define SN_id_smime_cti_ets_proofOfReceipt "id-smime-cti-ets-proofOfReceipt" -#define NID_id_smime_cti_ets_proofOfReceipt 252 -#define OBJ_id_smime_cti_ets_proofOfReceipt OBJ_id_smime_cti,2L - -#define SN_id_smime_cti_ets_proofOfDelivery "id-smime-cti-ets-proofOfDelivery" -#define NID_id_smime_cti_ets_proofOfDelivery 253 -#define OBJ_id_smime_cti_ets_proofOfDelivery OBJ_id_smime_cti,3L - -#define SN_id_smime_cti_ets_proofOfSender "id-smime-cti-ets-proofOfSender" -#define NID_id_smime_cti_ets_proofOfSender 254 -#define OBJ_id_smime_cti_ets_proofOfSender OBJ_id_smime_cti,4L - -#define SN_id_smime_cti_ets_proofOfApproval "id-smime-cti-ets-proofOfApproval" -#define NID_id_smime_cti_ets_proofOfApproval 255 -#define OBJ_id_smime_cti_ets_proofOfApproval OBJ_id_smime_cti,5L - -#define SN_id_smime_cti_ets_proofOfCreation "id-smime-cti-ets-proofOfCreation" -#define NID_id_smime_cti_ets_proofOfCreation 256 -#define OBJ_id_smime_cti_ets_proofOfCreation OBJ_id_smime_cti,6L - -#define LN_friendlyName "friendlyName" -#define NID_friendlyName 156 -#define OBJ_friendlyName OBJ_pkcs9,20L - -#define LN_localKeyID "localKeyID" -#define NID_localKeyID 157 -#define OBJ_localKeyID OBJ_pkcs9,21L - -#define SN_ms_csp_name "CSPName" -#define LN_ms_csp_name "Microsoft CSP Name" -#define NID_ms_csp_name 417 -#define OBJ_ms_csp_name 1L,3L,6L,1L,4L,1L,311L,17L,1L - -#define SN_LocalKeySet "LocalKeySet" -#define LN_LocalKeySet "Microsoft Local Key set" -#define NID_LocalKeySet 856 -#define OBJ_LocalKeySet 1L,3L,6L,1L,4L,1L,311L,17L,2L - -#define OBJ_certTypes OBJ_pkcs9,22L - -#define LN_x509Certificate "x509Certificate" -#define NID_x509Certificate 158 -#define OBJ_x509Certificate OBJ_certTypes,1L - -#define LN_sdsiCertificate "sdsiCertificate" -#define NID_sdsiCertificate 159 -#define OBJ_sdsiCertificate OBJ_certTypes,2L - -#define OBJ_crlTypes OBJ_pkcs9,23L - -#define LN_x509Crl "x509Crl" -#define NID_x509Crl 160 -#define OBJ_x509Crl OBJ_crlTypes,1L - -#define OBJ_pkcs12 OBJ_pkcs,12L - -#define OBJ_pkcs12_pbeids OBJ_pkcs12,1L - -#define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128" -#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4" -#define NID_pbe_WithSHA1And128BitRC4 144 -#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids,1L - -#define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40" -#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4" -#define NID_pbe_WithSHA1And40BitRC4 145 -#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids,2L - -#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES" -#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC" -#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146 -#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids,3L - -#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES" -#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC" -#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147 -#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids,4L - -#define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128" -#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC" -#define NID_pbe_WithSHA1And128BitRC2_CBC 148 -#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids,5L - -#define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40" -#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC" -#define NID_pbe_WithSHA1And40BitRC2_CBC 149 -#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids,6L - -#define OBJ_pkcs12_Version1 OBJ_pkcs12,10L - -#define OBJ_pkcs12_BagIds OBJ_pkcs12_Version1,1L - -#define LN_keyBag "keyBag" -#define NID_keyBag 150 -#define OBJ_keyBag OBJ_pkcs12_BagIds,1L - -#define LN_pkcs8ShroudedKeyBag "pkcs8ShroudedKeyBag" -#define NID_pkcs8ShroudedKeyBag 151 -#define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds,2L - -#define LN_certBag "certBag" -#define NID_certBag 152 -#define OBJ_certBag OBJ_pkcs12_BagIds,3L - -#define LN_crlBag "crlBag" -#define NID_crlBag 153 -#define OBJ_crlBag OBJ_pkcs12_BagIds,4L - -#define LN_secretBag "secretBag" -#define NID_secretBag 154 -#define OBJ_secretBag OBJ_pkcs12_BagIds,5L - -#define LN_safeContentsBag "safeContentsBag" -#define NID_safeContentsBag 155 -#define OBJ_safeContentsBag OBJ_pkcs12_BagIds,6L - -#define SN_md2 "MD2" -#define LN_md2 "md2" -#define NID_md2 3 -#define OBJ_md2 OBJ_rsadsi,2L,2L - -#define SN_md4 "MD4" -#define LN_md4 "md4" -#define NID_md4 257 -#define OBJ_md4 OBJ_rsadsi,2L,4L - -#define SN_md5 "MD5" -#define LN_md5 "md5" -#define NID_md5 4 -#define OBJ_md5 OBJ_rsadsi,2L,5L - -#define SN_md5_sha1 "MD5-SHA1" -#define LN_md5_sha1 "md5-sha1" -#define NID_md5_sha1 114 - -#define LN_hmacWithMD5 "hmacWithMD5" -#define NID_hmacWithMD5 797 -#define OBJ_hmacWithMD5 OBJ_rsadsi,2L,6L - -#define LN_hmacWithSHA1 "hmacWithSHA1" -#define NID_hmacWithSHA1 163 -#define OBJ_hmacWithSHA1 OBJ_rsadsi,2L,7L - -#define LN_hmacWithSHA224 "hmacWithSHA224" -#define NID_hmacWithSHA224 798 -#define OBJ_hmacWithSHA224 OBJ_rsadsi,2L,8L - -#define LN_hmacWithSHA256 "hmacWithSHA256" -#define NID_hmacWithSHA256 799 -#define OBJ_hmacWithSHA256 OBJ_rsadsi,2L,9L - -#define LN_hmacWithSHA384 "hmacWithSHA384" -#define NID_hmacWithSHA384 800 -#define OBJ_hmacWithSHA384 OBJ_rsadsi,2L,10L - -#define LN_hmacWithSHA512 "hmacWithSHA512" -#define NID_hmacWithSHA512 801 -#define OBJ_hmacWithSHA512 OBJ_rsadsi,2L,11L - -#define SN_rc2_cbc "RC2-CBC" -#define LN_rc2_cbc "rc2-cbc" -#define NID_rc2_cbc 37 -#define OBJ_rc2_cbc OBJ_rsadsi,3L,2L - -#define SN_rc2_ecb "RC2-ECB" -#define LN_rc2_ecb "rc2-ecb" -#define NID_rc2_ecb 38 - -#define SN_rc2_cfb64 "RC2-CFB" -#define LN_rc2_cfb64 "rc2-cfb" -#define NID_rc2_cfb64 39 - -#define SN_rc2_ofb64 "RC2-OFB" -#define LN_rc2_ofb64 "rc2-ofb" -#define NID_rc2_ofb64 40 - -#define SN_rc2_40_cbc "RC2-40-CBC" -#define LN_rc2_40_cbc "rc2-40-cbc" -#define NID_rc2_40_cbc 98 - -#define SN_rc2_64_cbc "RC2-64-CBC" -#define LN_rc2_64_cbc "rc2-64-cbc" -#define NID_rc2_64_cbc 166 - -#define SN_rc4 "RC4" -#define LN_rc4 "rc4" -#define NID_rc4 5 -#define OBJ_rc4 OBJ_rsadsi,3L,4L - -#define SN_rc4_40 "RC4-40" -#define LN_rc4_40 "rc4-40" -#define NID_rc4_40 97 - -#define SN_des_ede3_cbc "DES-EDE3-CBC" -#define LN_des_ede3_cbc "des-ede3-cbc" -#define NID_des_ede3_cbc 44 -#define OBJ_des_ede3_cbc OBJ_rsadsi,3L,7L - -#define SN_rc5_cbc "RC5-CBC" -#define LN_rc5_cbc "rc5-cbc" -#define NID_rc5_cbc 120 -#define OBJ_rc5_cbc OBJ_rsadsi,3L,8L - -#define SN_rc5_ecb "RC5-ECB" -#define LN_rc5_ecb "rc5-ecb" -#define NID_rc5_ecb 121 - -#define SN_rc5_cfb64 "RC5-CFB" -#define LN_rc5_cfb64 "rc5-cfb" -#define NID_rc5_cfb64 122 - -#define SN_rc5_ofb64 "RC5-OFB" -#define LN_rc5_ofb64 "rc5-ofb" -#define NID_rc5_ofb64 123 - -#define SN_ms_ext_req "msExtReq" -#define LN_ms_ext_req "Microsoft Extension Request" -#define NID_ms_ext_req 171 -#define OBJ_ms_ext_req 1L,3L,6L,1L,4L,1L,311L,2L,1L,14L - -#define SN_ms_code_ind "msCodeInd" -#define LN_ms_code_ind "Microsoft Individual Code Signing" -#define NID_ms_code_ind 134 -#define OBJ_ms_code_ind 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L - -#define SN_ms_code_com "msCodeCom" -#define LN_ms_code_com "Microsoft Commercial Code Signing" -#define NID_ms_code_com 135 -#define OBJ_ms_code_com 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L - -#define SN_ms_ctl_sign "msCTLSign" -#define LN_ms_ctl_sign "Microsoft Trust List Signing" -#define NID_ms_ctl_sign 136 -#define OBJ_ms_ctl_sign 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L - -#define SN_ms_sgc "msSGC" -#define LN_ms_sgc "Microsoft Server Gated Crypto" -#define NID_ms_sgc 137 -#define OBJ_ms_sgc 1L,3L,6L,1L,4L,1L,311L,10L,3L,3L - -#define SN_ms_efs "msEFS" -#define LN_ms_efs "Microsoft Encrypted File System" -#define NID_ms_efs 138 -#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L - -#define SN_ms_smartcard_login "msSmartcardLogin" -#define LN_ms_smartcard_login "Microsoft Smartcardlogin" -#define NID_ms_smartcard_login 648 -#define OBJ_ms_smartcard_login 1L,3L,6L,1L,4L,1L,311L,20L,2L,2L - -#define SN_ms_upn "msUPN" -#define LN_ms_upn "Microsoft Universal Principal Name" -#define NID_ms_upn 649 -#define OBJ_ms_upn 1L,3L,6L,1L,4L,1L,311L,20L,2L,3L - -#define SN_idea_cbc "IDEA-CBC" -#define LN_idea_cbc "idea-cbc" -#define NID_idea_cbc 34 -#define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L - -#define SN_idea_ecb "IDEA-ECB" -#define LN_idea_ecb "idea-ecb" -#define NID_idea_ecb 36 - -#define SN_idea_cfb64 "IDEA-CFB" -#define LN_idea_cfb64 "idea-cfb" -#define NID_idea_cfb64 35 - -#define SN_idea_ofb64 "IDEA-OFB" -#define LN_idea_ofb64 "idea-ofb" -#define NID_idea_ofb64 46 - -#define SN_bf_cbc "BF-CBC" -#define LN_bf_cbc "bf-cbc" -#define NID_bf_cbc 91 -#define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L - -#define SN_bf_ecb "BF-ECB" -#define LN_bf_ecb "bf-ecb" -#define NID_bf_ecb 92 - -#define SN_bf_cfb64 "BF-CFB" -#define LN_bf_cfb64 "bf-cfb" -#define NID_bf_cfb64 93 - -#define SN_bf_ofb64 "BF-OFB" -#define LN_bf_ofb64 "bf-ofb" -#define NID_bf_ofb64 94 - -#define SN_id_pkix "PKIX" -#define NID_id_pkix 127 -#define OBJ_id_pkix 1L,3L,6L,1L,5L,5L,7L - -#define SN_id_pkix_mod "id-pkix-mod" -#define NID_id_pkix_mod 258 -#define OBJ_id_pkix_mod OBJ_id_pkix,0L - -#define SN_id_pe "id-pe" -#define NID_id_pe 175 -#define OBJ_id_pe OBJ_id_pkix,1L - -#define SN_id_qt "id-qt" -#define NID_id_qt 259 -#define OBJ_id_qt OBJ_id_pkix,2L - -#define SN_id_kp "id-kp" -#define NID_id_kp 128 -#define OBJ_id_kp OBJ_id_pkix,3L - -#define SN_id_it "id-it" -#define NID_id_it 260 -#define OBJ_id_it OBJ_id_pkix,4L - -#define SN_id_pkip "id-pkip" -#define NID_id_pkip 261 -#define OBJ_id_pkip OBJ_id_pkix,5L - -#define SN_id_alg "id-alg" -#define NID_id_alg 262 -#define OBJ_id_alg OBJ_id_pkix,6L - -#define SN_id_cmc "id-cmc" -#define NID_id_cmc 263 -#define OBJ_id_cmc OBJ_id_pkix,7L - -#define SN_id_on "id-on" -#define NID_id_on 264 -#define OBJ_id_on OBJ_id_pkix,8L - -#define SN_id_pda "id-pda" -#define NID_id_pda 265 -#define OBJ_id_pda OBJ_id_pkix,9L - -#define SN_id_aca "id-aca" -#define NID_id_aca 266 -#define OBJ_id_aca OBJ_id_pkix,10L - -#define SN_id_qcs "id-qcs" -#define NID_id_qcs 267 -#define OBJ_id_qcs OBJ_id_pkix,11L - -#define SN_id_cct "id-cct" -#define NID_id_cct 268 -#define OBJ_id_cct OBJ_id_pkix,12L - -#define SN_id_ppl "id-ppl" -#define NID_id_ppl 662 -#define OBJ_id_ppl OBJ_id_pkix,21L - -#define SN_id_ad "id-ad" -#define NID_id_ad 176 -#define OBJ_id_ad OBJ_id_pkix,48L - -#define SN_id_pkix1_explicit_88 "id-pkix1-explicit-88" -#define NID_id_pkix1_explicit_88 269 -#define OBJ_id_pkix1_explicit_88 OBJ_id_pkix_mod,1L - -#define SN_id_pkix1_implicit_88 "id-pkix1-implicit-88" -#define NID_id_pkix1_implicit_88 270 -#define OBJ_id_pkix1_implicit_88 OBJ_id_pkix_mod,2L - -#define SN_id_pkix1_explicit_93 "id-pkix1-explicit-93" -#define NID_id_pkix1_explicit_93 271 -#define OBJ_id_pkix1_explicit_93 OBJ_id_pkix_mod,3L - -#define SN_id_pkix1_implicit_93 "id-pkix1-implicit-93" -#define NID_id_pkix1_implicit_93 272 -#define OBJ_id_pkix1_implicit_93 OBJ_id_pkix_mod,4L - -#define SN_id_mod_crmf "id-mod-crmf" -#define NID_id_mod_crmf 273 -#define OBJ_id_mod_crmf OBJ_id_pkix_mod,5L - -#define SN_id_mod_cmc "id-mod-cmc" -#define NID_id_mod_cmc 274 -#define OBJ_id_mod_cmc OBJ_id_pkix_mod,6L - -#define SN_id_mod_kea_profile_88 "id-mod-kea-profile-88" -#define NID_id_mod_kea_profile_88 275 -#define OBJ_id_mod_kea_profile_88 OBJ_id_pkix_mod,7L - -#define SN_id_mod_kea_profile_93 "id-mod-kea-profile-93" -#define NID_id_mod_kea_profile_93 276 -#define OBJ_id_mod_kea_profile_93 OBJ_id_pkix_mod,8L - -#define SN_id_mod_cmp "id-mod-cmp" -#define NID_id_mod_cmp 277 -#define OBJ_id_mod_cmp OBJ_id_pkix_mod,9L - -#define SN_id_mod_qualified_cert_88 "id-mod-qualified-cert-88" -#define NID_id_mod_qualified_cert_88 278 -#define OBJ_id_mod_qualified_cert_88 OBJ_id_pkix_mod,10L - -#define SN_id_mod_qualified_cert_93 "id-mod-qualified-cert-93" -#define NID_id_mod_qualified_cert_93 279 -#define OBJ_id_mod_qualified_cert_93 OBJ_id_pkix_mod,11L - -#define SN_id_mod_attribute_cert "id-mod-attribute-cert" -#define NID_id_mod_attribute_cert 280 -#define OBJ_id_mod_attribute_cert OBJ_id_pkix_mod,12L - -#define SN_id_mod_timestamp_protocol "id-mod-timestamp-protocol" -#define NID_id_mod_timestamp_protocol 281 -#define OBJ_id_mod_timestamp_protocol OBJ_id_pkix_mod,13L - -#define SN_id_mod_ocsp "id-mod-ocsp" -#define NID_id_mod_ocsp 282 -#define OBJ_id_mod_ocsp OBJ_id_pkix_mod,14L - -#define SN_id_mod_dvcs "id-mod-dvcs" -#define NID_id_mod_dvcs 283 -#define OBJ_id_mod_dvcs OBJ_id_pkix_mod,15L - -#define SN_id_mod_cmp2000 "id-mod-cmp2000" -#define NID_id_mod_cmp2000 284 -#define OBJ_id_mod_cmp2000 OBJ_id_pkix_mod,16L - -#define SN_info_access "authorityInfoAccess" -#define LN_info_access "Authority Information Access" -#define NID_info_access 177 -#define OBJ_info_access OBJ_id_pe,1L - -#define SN_biometricInfo "biometricInfo" -#define LN_biometricInfo "Biometric Info" -#define NID_biometricInfo 285 -#define OBJ_biometricInfo OBJ_id_pe,2L - -#define SN_qcStatements "qcStatements" -#define NID_qcStatements 286 -#define OBJ_qcStatements OBJ_id_pe,3L - -#define SN_ac_auditEntity "ac-auditEntity" -#define NID_ac_auditEntity 287 -#define OBJ_ac_auditEntity OBJ_id_pe,4L - -#define SN_ac_targeting "ac-targeting" -#define NID_ac_targeting 288 -#define OBJ_ac_targeting OBJ_id_pe,5L - -#define SN_aaControls "aaControls" -#define NID_aaControls 289 -#define OBJ_aaControls OBJ_id_pe,6L - -#define SN_sbgp_ipAddrBlock "sbgp-ipAddrBlock" -#define NID_sbgp_ipAddrBlock 290 -#define OBJ_sbgp_ipAddrBlock OBJ_id_pe,7L - -#define SN_sbgp_autonomousSysNum "sbgp-autonomousSysNum" -#define NID_sbgp_autonomousSysNum 291 -#define OBJ_sbgp_autonomousSysNum OBJ_id_pe,8L - -#define SN_sbgp_routerIdentifier "sbgp-routerIdentifier" -#define NID_sbgp_routerIdentifier 292 -#define OBJ_sbgp_routerIdentifier OBJ_id_pe,9L - -#define SN_ac_proxying "ac-proxying" -#define NID_ac_proxying 397 -#define OBJ_ac_proxying OBJ_id_pe,10L - -#define SN_sinfo_access "subjectInfoAccess" -#define LN_sinfo_access "Subject Information Access" -#define NID_sinfo_access 398 -#define OBJ_sinfo_access OBJ_id_pe,11L - -#define SN_proxyCertInfo "proxyCertInfo" -#define LN_proxyCertInfo "Proxy Certificate Information" -#define NID_proxyCertInfo 663 -#define OBJ_proxyCertInfo OBJ_id_pe,14L - -#define SN_id_qt_cps "id-qt-cps" -#define LN_id_qt_cps "Policy Qualifier CPS" -#define NID_id_qt_cps 164 -#define OBJ_id_qt_cps OBJ_id_qt,1L - -#define SN_id_qt_unotice "id-qt-unotice" -#define LN_id_qt_unotice "Policy Qualifier User Notice" -#define NID_id_qt_unotice 165 -#define OBJ_id_qt_unotice OBJ_id_qt,2L - -#define SN_textNotice "textNotice" -#define NID_textNotice 293 -#define OBJ_textNotice OBJ_id_qt,3L - -#define SN_server_auth "serverAuth" -#define LN_server_auth "TLS Web Server Authentication" -#define NID_server_auth 129 -#define OBJ_server_auth OBJ_id_kp,1L - -#define SN_client_auth "clientAuth" -#define LN_client_auth "TLS Web Client Authentication" -#define NID_client_auth 130 -#define OBJ_client_auth OBJ_id_kp,2L - -#define SN_code_sign "codeSigning" -#define LN_code_sign "Code Signing" -#define NID_code_sign 131 -#define OBJ_code_sign OBJ_id_kp,3L - -#define SN_email_protect "emailProtection" -#define LN_email_protect "E-mail Protection" -#define NID_email_protect 132 -#define OBJ_email_protect OBJ_id_kp,4L - -#define SN_ipsecEndSystem "ipsecEndSystem" -#define LN_ipsecEndSystem "IPSec End System" -#define NID_ipsecEndSystem 294 -#define OBJ_ipsecEndSystem OBJ_id_kp,5L - -#define SN_ipsecTunnel "ipsecTunnel" -#define LN_ipsecTunnel "IPSec Tunnel" -#define NID_ipsecTunnel 295 -#define OBJ_ipsecTunnel OBJ_id_kp,6L - -#define SN_ipsecUser "ipsecUser" -#define LN_ipsecUser "IPSec User" -#define NID_ipsecUser 296 -#define OBJ_ipsecUser OBJ_id_kp,7L - -#define SN_time_stamp "timeStamping" -#define LN_time_stamp "Time Stamping" -#define NID_time_stamp 133 -#define OBJ_time_stamp OBJ_id_kp,8L - -#define SN_OCSP_sign "OCSPSigning" -#define LN_OCSP_sign "OCSP Signing" -#define NID_OCSP_sign 180 -#define OBJ_OCSP_sign OBJ_id_kp,9L - -#define SN_dvcs "DVCS" -#define LN_dvcs "dvcs" -#define NID_dvcs 297 -#define OBJ_dvcs OBJ_id_kp,10L - -#define SN_id_it_caProtEncCert "id-it-caProtEncCert" -#define NID_id_it_caProtEncCert 298 -#define OBJ_id_it_caProtEncCert OBJ_id_it,1L - -#define SN_id_it_signKeyPairTypes "id-it-signKeyPairTypes" -#define NID_id_it_signKeyPairTypes 299 -#define OBJ_id_it_signKeyPairTypes OBJ_id_it,2L - -#define SN_id_it_encKeyPairTypes "id-it-encKeyPairTypes" -#define NID_id_it_encKeyPairTypes 300 -#define OBJ_id_it_encKeyPairTypes OBJ_id_it,3L - -#define SN_id_it_preferredSymmAlg "id-it-preferredSymmAlg" -#define NID_id_it_preferredSymmAlg 301 -#define OBJ_id_it_preferredSymmAlg OBJ_id_it,4L - -#define SN_id_it_caKeyUpdateInfo "id-it-caKeyUpdateInfo" -#define NID_id_it_caKeyUpdateInfo 302 -#define OBJ_id_it_caKeyUpdateInfo OBJ_id_it,5L - -#define SN_id_it_currentCRL "id-it-currentCRL" -#define NID_id_it_currentCRL 303 -#define OBJ_id_it_currentCRL OBJ_id_it,6L - -#define SN_id_it_unsupportedOIDs "id-it-unsupportedOIDs" -#define NID_id_it_unsupportedOIDs 304 -#define OBJ_id_it_unsupportedOIDs OBJ_id_it,7L - -#define SN_id_it_subscriptionRequest "id-it-subscriptionRequest" -#define NID_id_it_subscriptionRequest 305 -#define OBJ_id_it_subscriptionRequest OBJ_id_it,8L - -#define SN_id_it_subscriptionResponse "id-it-subscriptionResponse" -#define NID_id_it_subscriptionResponse 306 -#define OBJ_id_it_subscriptionResponse OBJ_id_it,9L - -#define SN_id_it_keyPairParamReq "id-it-keyPairParamReq" -#define NID_id_it_keyPairParamReq 307 -#define OBJ_id_it_keyPairParamReq OBJ_id_it,10L - -#define SN_id_it_keyPairParamRep "id-it-keyPairParamRep" -#define NID_id_it_keyPairParamRep 308 -#define OBJ_id_it_keyPairParamRep OBJ_id_it,11L - -#define SN_id_it_revPassphrase "id-it-revPassphrase" -#define NID_id_it_revPassphrase 309 -#define OBJ_id_it_revPassphrase OBJ_id_it,12L - -#define SN_id_it_implicitConfirm "id-it-implicitConfirm" -#define NID_id_it_implicitConfirm 310 -#define OBJ_id_it_implicitConfirm OBJ_id_it,13L - -#define SN_id_it_confirmWaitTime "id-it-confirmWaitTime" -#define NID_id_it_confirmWaitTime 311 -#define OBJ_id_it_confirmWaitTime OBJ_id_it,14L - -#define SN_id_it_origPKIMessage "id-it-origPKIMessage" -#define NID_id_it_origPKIMessage 312 -#define OBJ_id_it_origPKIMessage OBJ_id_it,15L - -#define SN_id_it_suppLangTags "id-it-suppLangTags" -#define NID_id_it_suppLangTags 784 -#define OBJ_id_it_suppLangTags OBJ_id_it,16L - -#define SN_id_regCtrl "id-regCtrl" -#define NID_id_regCtrl 313 -#define OBJ_id_regCtrl OBJ_id_pkip,1L - -#define SN_id_regInfo "id-regInfo" -#define NID_id_regInfo 314 -#define OBJ_id_regInfo OBJ_id_pkip,2L - -#define SN_id_regCtrl_regToken "id-regCtrl-regToken" -#define NID_id_regCtrl_regToken 315 -#define OBJ_id_regCtrl_regToken OBJ_id_regCtrl,1L - -#define SN_id_regCtrl_authenticator "id-regCtrl-authenticator" -#define NID_id_regCtrl_authenticator 316 -#define OBJ_id_regCtrl_authenticator OBJ_id_regCtrl,2L - -#define SN_id_regCtrl_pkiPublicationInfo "id-regCtrl-pkiPublicationInfo" -#define NID_id_regCtrl_pkiPublicationInfo 317 -#define OBJ_id_regCtrl_pkiPublicationInfo OBJ_id_regCtrl,3L - -#define SN_id_regCtrl_pkiArchiveOptions "id-regCtrl-pkiArchiveOptions" -#define NID_id_regCtrl_pkiArchiveOptions 318 -#define OBJ_id_regCtrl_pkiArchiveOptions OBJ_id_regCtrl,4L - -#define SN_id_regCtrl_oldCertID "id-regCtrl-oldCertID" -#define NID_id_regCtrl_oldCertID 319 -#define OBJ_id_regCtrl_oldCertID OBJ_id_regCtrl,5L - -#define SN_id_regCtrl_protocolEncrKey "id-regCtrl-protocolEncrKey" -#define NID_id_regCtrl_protocolEncrKey 320 -#define OBJ_id_regCtrl_protocolEncrKey OBJ_id_regCtrl,6L - -#define SN_id_regInfo_utf8Pairs "id-regInfo-utf8Pairs" -#define NID_id_regInfo_utf8Pairs 321 -#define OBJ_id_regInfo_utf8Pairs OBJ_id_regInfo,1L - -#define SN_id_regInfo_certReq "id-regInfo-certReq" -#define NID_id_regInfo_certReq 322 -#define OBJ_id_regInfo_certReq OBJ_id_regInfo,2L - -#define SN_id_alg_des40 "id-alg-des40" -#define NID_id_alg_des40 323 -#define OBJ_id_alg_des40 OBJ_id_alg,1L - -#define SN_id_alg_noSignature "id-alg-noSignature" -#define NID_id_alg_noSignature 324 -#define OBJ_id_alg_noSignature OBJ_id_alg,2L - -#define SN_id_alg_dh_sig_hmac_sha1 "id-alg-dh-sig-hmac-sha1" -#define NID_id_alg_dh_sig_hmac_sha1 325 -#define OBJ_id_alg_dh_sig_hmac_sha1 OBJ_id_alg,3L - -#define SN_id_alg_dh_pop "id-alg-dh-pop" -#define NID_id_alg_dh_pop 326 -#define OBJ_id_alg_dh_pop OBJ_id_alg,4L - -#define SN_id_cmc_statusInfo "id-cmc-statusInfo" -#define NID_id_cmc_statusInfo 327 -#define OBJ_id_cmc_statusInfo OBJ_id_cmc,1L - -#define SN_id_cmc_identification "id-cmc-identification" -#define NID_id_cmc_identification 328 -#define OBJ_id_cmc_identification OBJ_id_cmc,2L - -#define SN_id_cmc_identityProof "id-cmc-identityProof" -#define NID_id_cmc_identityProof 329 -#define OBJ_id_cmc_identityProof OBJ_id_cmc,3L - -#define SN_id_cmc_dataReturn "id-cmc-dataReturn" -#define NID_id_cmc_dataReturn 330 -#define OBJ_id_cmc_dataReturn OBJ_id_cmc,4L - -#define SN_id_cmc_transactionId "id-cmc-transactionId" -#define NID_id_cmc_transactionId 331 -#define OBJ_id_cmc_transactionId OBJ_id_cmc,5L - -#define SN_id_cmc_senderNonce "id-cmc-senderNonce" -#define NID_id_cmc_senderNonce 332 -#define OBJ_id_cmc_senderNonce OBJ_id_cmc,6L - -#define SN_id_cmc_recipientNonce "id-cmc-recipientNonce" -#define NID_id_cmc_recipientNonce 333 -#define OBJ_id_cmc_recipientNonce OBJ_id_cmc,7L - -#define SN_id_cmc_addExtensions "id-cmc-addExtensions" -#define NID_id_cmc_addExtensions 334 -#define OBJ_id_cmc_addExtensions OBJ_id_cmc,8L - -#define SN_id_cmc_encryptedPOP "id-cmc-encryptedPOP" -#define NID_id_cmc_encryptedPOP 335 -#define OBJ_id_cmc_encryptedPOP OBJ_id_cmc,9L - -#define SN_id_cmc_decryptedPOP "id-cmc-decryptedPOP" -#define NID_id_cmc_decryptedPOP 336 -#define OBJ_id_cmc_decryptedPOP OBJ_id_cmc,10L - -#define SN_id_cmc_lraPOPWitness "id-cmc-lraPOPWitness" -#define NID_id_cmc_lraPOPWitness 337 -#define OBJ_id_cmc_lraPOPWitness OBJ_id_cmc,11L - -#define SN_id_cmc_getCert "id-cmc-getCert" -#define NID_id_cmc_getCert 338 -#define OBJ_id_cmc_getCert OBJ_id_cmc,15L - -#define SN_id_cmc_getCRL "id-cmc-getCRL" -#define NID_id_cmc_getCRL 339 -#define OBJ_id_cmc_getCRL OBJ_id_cmc,16L - -#define SN_id_cmc_revokeRequest "id-cmc-revokeRequest" -#define NID_id_cmc_revokeRequest 340 -#define OBJ_id_cmc_revokeRequest OBJ_id_cmc,17L - -#define SN_id_cmc_regInfo "id-cmc-regInfo" -#define NID_id_cmc_regInfo 341 -#define OBJ_id_cmc_regInfo OBJ_id_cmc,18L - -#define SN_id_cmc_responseInfo "id-cmc-responseInfo" -#define NID_id_cmc_responseInfo 342 -#define OBJ_id_cmc_responseInfo OBJ_id_cmc,19L - -#define SN_id_cmc_queryPending "id-cmc-queryPending" -#define NID_id_cmc_queryPending 343 -#define OBJ_id_cmc_queryPending OBJ_id_cmc,21L - -#define SN_id_cmc_popLinkRandom "id-cmc-popLinkRandom" -#define NID_id_cmc_popLinkRandom 344 -#define OBJ_id_cmc_popLinkRandom OBJ_id_cmc,22L - -#define SN_id_cmc_popLinkWitness "id-cmc-popLinkWitness" -#define NID_id_cmc_popLinkWitness 345 -#define OBJ_id_cmc_popLinkWitness OBJ_id_cmc,23L - -#define SN_id_cmc_confirmCertAcceptance "id-cmc-confirmCertAcceptance" -#define NID_id_cmc_confirmCertAcceptance 346 -#define OBJ_id_cmc_confirmCertAcceptance OBJ_id_cmc,24L - -#define SN_id_on_personalData "id-on-personalData" -#define NID_id_on_personalData 347 -#define OBJ_id_on_personalData OBJ_id_on,1L - -#define SN_id_on_permanentIdentifier "id-on-permanentIdentifier" -#define LN_id_on_permanentIdentifier "Permanent Identifier" -#define NID_id_on_permanentIdentifier 858 -#define OBJ_id_on_permanentIdentifier OBJ_id_on,3L - -#define SN_id_pda_dateOfBirth "id-pda-dateOfBirth" -#define NID_id_pda_dateOfBirth 348 -#define OBJ_id_pda_dateOfBirth OBJ_id_pda,1L - -#define SN_id_pda_placeOfBirth "id-pda-placeOfBirth" -#define NID_id_pda_placeOfBirth 349 -#define OBJ_id_pda_placeOfBirth OBJ_id_pda,2L - -#define SN_id_pda_gender "id-pda-gender" -#define NID_id_pda_gender 351 -#define OBJ_id_pda_gender OBJ_id_pda,3L - -#define SN_id_pda_countryOfCitizenship "id-pda-countryOfCitizenship" -#define NID_id_pda_countryOfCitizenship 352 -#define OBJ_id_pda_countryOfCitizenship OBJ_id_pda,4L - -#define SN_id_pda_countryOfResidence "id-pda-countryOfResidence" -#define NID_id_pda_countryOfResidence 353 -#define OBJ_id_pda_countryOfResidence OBJ_id_pda,5L - -#define SN_id_aca_authenticationInfo "id-aca-authenticationInfo" -#define NID_id_aca_authenticationInfo 354 -#define OBJ_id_aca_authenticationInfo OBJ_id_aca,1L - -#define SN_id_aca_accessIdentity "id-aca-accessIdentity" -#define NID_id_aca_accessIdentity 355 -#define OBJ_id_aca_accessIdentity OBJ_id_aca,2L - -#define SN_id_aca_chargingIdentity "id-aca-chargingIdentity" -#define NID_id_aca_chargingIdentity 356 -#define OBJ_id_aca_chargingIdentity OBJ_id_aca,3L - -#define SN_id_aca_group "id-aca-group" -#define NID_id_aca_group 357 -#define OBJ_id_aca_group OBJ_id_aca,4L - -#define SN_id_aca_role "id-aca-role" -#define NID_id_aca_role 358 -#define OBJ_id_aca_role OBJ_id_aca,5L - -#define SN_id_aca_encAttrs "id-aca-encAttrs" -#define NID_id_aca_encAttrs 399 -#define OBJ_id_aca_encAttrs OBJ_id_aca,6L - -#define SN_id_qcs_pkixQCSyntax_v1 "id-qcs-pkixQCSyntax-v1" -#define NID_id_qcs_pkixQCSyntax_v1 359 -#define OBJ_id_qcs_pkixQCSyntax_v1 OBJ_id_qcs,1L - -#define SN_id_cct_crs "id-cct-crs" -#define NID_id_cct_crs 360 -#define OBJ_id_cct_crs OBJ_id_cct,1L - -#define SN_id_cct_PKIData "id-cct-PKIData" -#define NID_id_cct_PKIData 361 -#define OBJ_id_cct_PKIData OBJ_id_cct,2L - -#define SN_id_cct_PKIResponse "id-cct-PKIResponse" -#define NID_id_cct_PKIResponse 362 -#define OBJ_id_cct_PKIResponse OBJ_id_cct,3L - -#define SN_id_ppl_anyLanguage "id-ppl-anyLanguage" -#define LN_id_ppl_anyLanguage "Any language" -#define NID_id_ppl_anyLanguage 664 -#define OBJ_id_ppl_anyLanguage OBJ_id_ppl,0L - -#define SN_id_ppl_inheritAll "id-ppl-inheritAll" -#define LN_id_ppl_inheritAll "Inherit all" -#define NID_id_ppl_inheritAll 665 -#define OBJ_id_ppl_inheritAll OBJ_id_ppl,1L - -#define SN_Independent "id-ppl-independent" -#define LN_Independent "Independent" -#define NID_Independent 667 -#define OBJ_Independent OBJ_id_ppl,2L - -#define SN_ad_OCSP "OCSP" -#define LN_ad_OCSP "OCSP" -#define NID_ad_OCSP 178 -#define OBJ_ad_OCSP OBJ_id_ad,1L - -#define SN_ad_ca_issuers "caIssuers" -#define LN_ad_ca_issuers "CA Issuers" -#define NID_ad_ca_issuers 179 -#define OBJ_ad_ca_issuers OBJ_id_ad,2L - -#define SN_ad_timeStamping "ad_timestamping" -#define LN_ad_timeStamping "AD Time Stamping" -#define NID_ad_timeStamping 363 -#define OBJ_ad_timeStamping OBJ_id_ad,3L - -#define SN_ad_dvcs "AD_DVCS" -#define LN_ad_dvcs "ad dvcs" -#define NID_ad_dvcs 364 -#define OBJ_ad_dvcs OBJ_id_ad,4L - -#define SN_caRepository "caRepository" -#define LN_caRepository "CA Repository" -#define NID_caRepository 785 -#define OBJ_caRepository OBJ_id_ad,5L - -#define OBJ_id_pkix_OCSP OBJ_ad_OCSP - -#define SN_id_pkix_OCSP_basic "basicOCSPResponse" -#define LN_id_pkix_OCSP_basic "Basic OCSP Response" -#define NID_id_pkix_OCSP_basic 365 -#define OBJ_id_pkix_OCSP_basic OBJ_id_pkix_OCSP,1L - -#define SN_id_pkix_OCSP_Nonce "Nonce" -#define LN_id_pkix_OCSP_Nonce "OCSP Nonce" -#define NID_id_pkix_OCSP_Nonce 366 -#define OBJ_id_pkix_OCSP_Nonce OBJ_id_pkix_OCSP,2L - -#define SN_id_pkix_OCSP_CrlID "CrlID" -#define LN_id_pkix_OCSP_CrlID "OCSP CRL ID" -#define NID_id_pkix_OCSP_CrlID 367 -#define OBJ_id_pkix_OCSP_CrlID OBJ_id_pkix_OCSP,3L - -#define SN_id_pkix_OCSP_acceptableResponses "acceptableResponses" -#define LN_id_pkix_OCSP_acceptableResponses "Acceptable OCSP Responses" -#define NID_id_pkix_OCSP_acceptableResponses 368 -#define OBJ_id_pkix_OCSP_acceptableResponses OBJ_id_pkix_OCSP,4L - -#define SN_id_pkix_OCSP_noCheck "noCheck" -#define LN_id_pkix_OCSP_noCheck "OCSP No Check" -#define NID_id_pkix_OCSP_noCheck 369 -#define OBJ_id_pkix_OCSP_noCheck OBJ_id_pkix_OCSP,5L - -#define SN_id_pkix_OCSP_archiveCutoff "archiveCutoff" -#define LN_id_pkix_OCSP_archiveCutoff "OCSP Archive Cutoff" -#define NID_id_pkix_OCSP_archiveCutoff 370 -#define OBJ_id_pkix_OCSP_archiveCutoff OBJ_id_pkix_OCSP,6L - -#define SN_id_pkix_OCSP_serviceLocator "serviceLocator" -#define LN_id_pkix_OCSP_serviceLocator "OCSP Service Locator" -#define NID_id_pkix_OCSP_serviceLocator 371 -#define OBJ_id_pkix_OCSP_serviceLocator OBJ_id_pkix_OCSP,7L - -#define SN_id_pkix_OCSP_extendedStatus "extendedStatus" -#define LN_id_pkix_OCSP_extendedStatus "Extended OCSP Status" -#define NID_id_pkix_OCSP_extendedStatus 372 -#define OBJ_id_pkix_OCSP_extendedStatus OBJ_id_pkix_OCSP,8L - -#define SN_id_pkix_OCSP_valid "valid" -#define NID_id_pkix_OCSP_valid 373 -#define OBJ_id_pkix_OCSP_valid OBJ_id_pkix_OCSP,9L - -#define SN_id_pkix_OCSP_path "path" -#define NID_id_pkix_OCSP_path 374 -#define OBJ_id_pkix_OCSP_path OBJ_id_pkix_OCSP,10L - -#define SN_id_pkix_OCSP_trustRoot "trustRoot" -#define LN_id_pkix_OCSP_trustRoot "Trust Root" -#define NID_id_pkix_OCSP_trustRoot 375 -#define OBJ_id_pkix_OCSP_trustRoot OBJ_id_pkix_OCSP,11L - -#define SN_algorithm "algorithm" -#define LN_algorithm "algorithm" -#define NID_algorithm 376 -#define OBJ_algorithm 1L,3L,14L,3L,2L - -#define SN_md5WithRSA "RSA-NP-MD5" -#define LN_md5WithRSA "md5WithRSA" -#define NID_md5WithRSA 104 -#define OBJ_md5WithRSA OBJ_algorithm,3L - -#define SN_des_ecb "DES-ECB" -#define LN_des_ecb "des-ecb" -#define NID_des_ecb 29 -#define OBJ_des_ecb OBJ_algorithm,6L - -#define SN_des_cbc "DES-CBC" -#define LN_des_cbc "des-cbc" -#define NID_des_cbc 31 -#define OBJ_des_cbc OBJ_algorithm,7L - -#define SN_des_ofb64 "DES-OFB" -#define LN_des_ofb64 "des-ofb" -#define NID_des_ofb64 45 -#define OBJ_des_ofb64 OBJ_algorithm,8L - -#define SN_des_cfb64 "DES-CFB" -#define LN_des_cfb64 "des-cfb" -#define NID_des_cfb64 30 -#define OBJ_des_cfb64 OBJ_algorithm,9L - -#define SN_rsaSignature "rsaSignature" -#define NID_rsaSignature 377 -#define OBJ_rsaSignature OBJ_algorithm,11L - -#define SN_dsa_2 "DSA-old" -#define LN_dsa_2 "dsaEncryption-old" -#define NID_dsa_2 67 -#define OBJ_dsa_2 OBJ_algorithm,12L - -#define SN_dsaWithSHA "DSA-SHA" -#define LN_dsaWithSHA "dsaWithSHA" -#define NID_dsaWithSHA 66 -#define OBJ_dsaWithSHA OBJ_algorithm,13L - -#define SN_shaWithRSAEncryption "RSA-SHA" -#define LN_shaWithRSAEncryption "shaWithRSAEncryption" -#define NID_shaWithRSAEncryption 42 -#define OBJ_shaWithRSAEncryption OBJ_algorithm,15L - -#define SN_des_ede_ecb "DES-EDE" -#define LN_des_ede_ecb "des-ede" -#define NID_des_ede_ecb 32 -#define OBJ_des_ede_ecb OBJ_algorithm,17L - -#define SN_des_ede3_ecb "DES-EDE3" -#define LN_des_ede3_ecb "des-ede3" -#define NID_des_ede3_ecb 33 - -#define SN_des_ede_cbc "DES-EDE-CBC" -#define LN_des_ede_cbc "des-ede-cbc" -#define NID_des_ede_cbc 43 - -#define SN_des_ede_cfb64 "DES-EDE-CFB" -#define LN_des_ede_cfb64 "des-ede-cfb" -#define NID_des_ede_cfb64 60 - -#define SN_des_ede3_cfb64 "DES-EDE3-CFB" -#define LN_des_ede3_cfb64 "des-ede3-cfb" -#define NID_des_ede3_cfb64 61 - -#define SN_des_ede_ofb64 "DES-EDE-OFB" -#define LN_des_ede_ofb64 "des-ede-ofb" -#define NID_des_ede_ofb64 62 - -#define SN_des_ede3_ofb64 "DES-EDE3-OFB" -#define LN_des_ede3_ofb64 "des-ede3-ofb" -#define NID_des_ede3_ofb64 63 - -#define SN_desx_cbc "DESX-CBC" -#define LN_desx_cbc "desx-cbc" -#define NID_desx_cbc 80 - -#define SN_sha "SHA" -#define LN_sha "sha" -#define NID_sha 41 -#define OBJ_sha OBJ_algorithm,18L - -#define SN_sha1 "SHA1" -#define LN_sha1 "sha1" -#define NID_sha1 64 -#define OBJ_sha1 OBJ_algorithm,26L - -#define SN_dsaWithSHA1_2 "DSA-SHA1-old" -#define LN_dsaWithSHA1_2 "dsaWithSHA1-old" -#define NID_dsaWithSHA1_2 70 -#define OBJ_dsaWithSHA1_2 OBJ_algorithm,27L - -#define SN_sha1WithRSA "RSA-SHA1-2" -#define LN_sha1WithRSA "sha1WithRSA" -#define NID_sha1WithRSA 115 -#define OBJ_sha1WithRSA OBJ_algorithm,29L - -#define SN_ripemd160 "RIPEMD160" -#define LN_ripemd160 "ripemd160" -#define NID_ripemd160 117 -#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L - -#define SN_ripemd160WithRSA "RSA-RIPEMD160" -#define LN_ripemd160WithRSA "ripemd160WithRSA" -#define NID_ripemd160WithRSA 119 -#define OBJ_ripemd160WithRSA 1L,3L,36L,3L,3L,1L,2L - -#define SN_sxnet "SXNetID" -#define LN_sxnet "Strong Extranet ID" -#define NID_sxnet 143 -#define OBJ_sxnet 1L,3L,101L,1L,4L,1L - -#define SN_X500 "X500" -#define LN_X500 "directory services (X.500)" -#define NID_X500 11 -#define OBJ_X500 2L,5L - -#define SN_X509 "X509" -#define NID_X509 12 -#define OBJ_X509 OBJ_X500,4L - -#define SN_commonName "CN" -#define LN_commonName "commonName" -#define NID_commonName 13 -#define OBJ_commonName OBJ_X509,3L - -#define SN_surname "SN" -#define LN_surname "surname" -#define NID_surname 100 -#define OBJ_surname OBJ_X509,4L - -#define LN_serialNumber "serialNumber" -#define NID_serialNumber 105 -#define OBJ_serialNumber OBJ_X509,5L - -#define SN_countryName "C" -#define LN_countryName "countryName" -#define NID_countryName 14 -#define OBJ_countryName OBJ_X509,6L - -#define SN_localityName "L" -#define LN_localityName "localityName" -#define NID_localityName 15 -#define OBJ_localityName OBJ_X509,7L - -#define SN_stateOrProvinceName "ST" -#define LN_stateOrProvinceName "stateOrProvinceName" -#define NID_stateOrProvinceName 16 -#define OBJ_stateOrProvinceName OBJ_X509,8L - -#define SN_streetAddress "street" -#define LN_streetAddress "streetAddress" -#define NID_streetAddress 660 -#define OBJ_streetAddress OBJ_X509,9L - -#define SN_organizationName "O" -#define LN_organizationName "organizationName" -#define NID_organizationName 17 -#define OBJ_organizationName OBJ_X509,10L - -#define SN_organizationalUnitName "OU" -#define LN_organizationalUnitName "organizationalUnitName" -#define NID_organizationalUnitName 18 -#define OBJ_organizationalUnitName OBJ_X509,11L - -#define SN_title "title" -#define LN_title "title" -#define NID_title 106 -#define OBJ_title OBJ_X509,12L - -#define LN_description "description" -#define NID_description 107 -#define OBJ_description OBJ_X509,13L - -#define LN_searchGuide "searchGuide" -#define NID_searchGuide 859 -#define OBJ_searchGuide OBJ_X509,14L - -#define LN_businessCategory "businessCategory" -#define NID_businessCategory 860 -#define OBJ_businessCategory OBJ_X509,15L - -#define LN_postalAddress "postalAddress" -#define NID_postalAddress 861 -#define OBJ_postalAddress OBJ_X509,16L - -#define LN_postalCode "postalCode" -#define NID_postalCode 661 -#define OBJ_postalCode OBJ_X509,17L - -#define LN_postOfficeBox "postOfficeBox" -#define NID_postOfficeBox 862 -#define OBJ_postOfficeBox OBJ_X509,18L - -#define LN_physicalDeliveryOfficeName "physicalDeliveryOfficeName" -#define NID_physicalDeliveryOfficeName 863 -#define OBJ_physicalDeliveryOfficeName OBJ_X509,19L - -#define LN_telephoneNumber "telephoneNumber" -#define NID_telephoneNumber 864 -#define OBJ_telephoneNumber OBJ_X509,20L - -#define LN_telexNumber "telexNumber" -#define NID_telexNumber 865 -#define OBJ_telexNumber OBJ_X509,21L - -#define LN_teletexTerminalIdentifier "teletexTerminalIdentifier" -#define NID_teletexTerminalIdentifier 866 -#define OBJ_teletexTerminalIdentifier OBJ_X509,22L - -#define LN_facsimileTelephoneNumber "facsimileTelephoneNumber" -#define NID_facsimileTelephoneNumber 867 -#define OBJ_facsimileTelephoneNumber OBJ_X509,23L - -#define LN_x121Address "x121Address" -#define NID_x121Address 868 -#define OBJ_x121Address OBJ_X509,24L - -#define LN_internationaliSDNNumber "internationaliSDNNumber" -#define NID_internationaliSDNNumber 869 -#define OBJ_internationaliSDNNumber OBJ_X509,25L - -#define LN_registeredAddress "registeredAddress" -#define NID_registeredAddress 870 -#define OBJ_registeredAddress OBJ_X509,26L - -#define LN_destinationIndicator "destinationIndicator" -#define NID_destinationIndicator 871 -#define OBJ_destinationIndicator OBJ_X509,27L - -#define LN_preferredDeliveryMethod "preferredDeliveryMethod" -#define NID_preferredDeliveryMethod 872 -#define OBJ_preferredDeliveryMethod OBJ_X509,28L - -#define LN_presentationAddress "presentationAddress" -#define NID_presentationAddress 873 -#define OBJ_presentationAddress OBJ_X509,29L - -#define LN_supportedApplicationContext "supportedApplicationContext" -#define NID_supportedApplicationContext 874 -#define OBJ_supportedApplicationContext OBJ_X509,30L - -#define SN_member "member" -#define NID_member 875 -#define OBJ_member OBJ_X509,31L - -#define SN_owner "owner" -#define NID_owner 876 -#define OBJ_owner OBJ_X509,32L - -#define LN_roleOccupant "roleOccupant" -#define NID_roleOccupant 877 -#define OBJ_roleOccupant OBJ_X509,33L - -#define SN_seeAlso "seeAlso" -#define NID_seeAlso 878 -#define OBJ_seeAlso OBJ_X509,34L - -#define LN_userPassword "userPassword" -#define NID_userPassword 879 -#define OBJ_userPassword OBJ_X509,35L - -#define LN_userCertificate "userCertificate" -#define NID_userCertificate 880 -#define OBJ_userCertificate OBJ_X509,36L - -#define LN_cACertificate "cACertificate" -#define NID_cACertificate 881 -#define OBJ_cACertificate OBJ_X509,37L - -#define LN_authorityRevocationList "authorityRevocationList" -#define NID_authorityRevocationList 882 -#define OBJ_authorityRevocationList OBJ_X509,38L - -#define LN_certificateRevocationList "certificateRevocationList" -#define NID_certificateRevocationList 883 -#define OBJ_certificateRevocationList OBJ_X509,39L - -#define LN_crossCertificatePair "crossCertificatePair" -#define NID_crossCertificatePair 884 -#define OBJ_crossCertificatePair OBJ_X509,40L - -#define SN_name "name" -#define LN_name "name" -#define NID_name 173 -#define OBJ_name OBJ_X509,41L - -#define SN_givenName "GN" -#define LN_givenName "givenName" -#define NID_givenName 99 -#define OBJ_givenName OBJ_X509,42L - -#define SN_initials "initials" -#define LN_initials "initials" -#define NID_initials 101 -#define OBJ_initials OBJ_X509,43L - -#define LN_generationQualifier "generationQualifier" -#define NID_generationQualifier 509 -#define OBJ_generationQualifier OBJ_X509,44L - -#define LN_x500UniqueIdentifier "x500UniqueIdentifier" -#define NID_x500UniqueIdentifier 503 -#define OBJ_x500UniqueIdentifier OBJ_X509,45L - -#define SN_dnQualifier "dnQualifier" -#define LN_dnQualifier "dnQualifier" -#define NID_dnQualifier 174 -#define OBJ_dnQualifier OBJ_X509,46L - -#define LN_enhancedSearchGuide "enhancedSearchGuide" -#define NID_enhancedSearchGuide 885 -#define OBJ_enhancedSearchGuide OBJ_X509,47L - -#define LN_protocolInformation "protocolInformation" -#define NID_protocolInformation 886 -#define OBJ_protocolInformation OBJ_X509,48L - -#define LN_distinguishedName "distinguishedName" -#define NID_distinguishedName 887 -#define OBJ_distinguishedName OBJ_X509,49L - -#define LN_uniqueMember "uniqueMember" -#define NID_uniqueMember 888 -#define OBJ_uniqueMember OBJ_X509,50L - -#define LN_houseIdentifier "houseIdentifier" -#define NID_houseIdentifier 889 -#define OBJ_houseIdentifier OBJ_X509,51L - -#define LN_supportedAlgorithms "supportedAlgorithms" -#define NID_supportedAlgorithms 890 -#define OBJ_supportedAlgorithms OBJ_X509,52L - -#define LN_deltaRevocationList "deltaRevocationList" -#define NID_deltaRevocationList 891 -#define OBJ_deltaRevocationList OBJ_X509,53L - -#define SN_dmdName "dmdName" -#define NID_dmdName 892 -#define OBJ_dmdName OBJ_X509,54L - -#define LN_pseudonym "pseudonym" -#define NID_pseudonym 510 -#define OBJ_pseudonym OBJ_X509,65L - -#define SN_role "role" -#define LN_role "role" -#define NID_role 400 -#define OBJ_role OBJ_X509,72L - -#define SN_X500algorithms "X500algorithms" -#define LN_X500algorithms "directory services - algorithms" -#define NID_X500algorithms 378 -#define OBJ_X500algorithms OBJ_X500,8L - -#define SN_rsa "RSA" -#define LN_rsa "rsa" -#define NID_rsa 19 -#define OBJ_rsa OBJ_X500algorithms,1L,1L - -#define SN_mdc2WithRSA "RSA-MDC2" -#define LN_mdc2WithRSA "mdc2WithRSA" -#define NID_mdc2WithRSA 96 -#define OBJ_mdc2WithRSA OBJ_X500algorithms,3L,100L - -#define SN_mdc2 "MDC2" -#define LN_mdc2 "mdc2" -#define NID_mdc2 95 -#define OBJ_mdc2 OBJ_X500algorithms,3L,101L - -#define SN_id_ce "id-ce" -#define NID_id_ce 81 -#define OBJ_id_ce OBJ_X500,29L - -#define SN_subject_directory_attributes "subjectDirectoryAttributes" -#define LN_subject_directory_attributes "X509v3 Subject Directory Attributes" -#define NID_subject_directory_attributes 769 -#define OBJ_subject_directory_attributes OBJ_id_ce,9L - -#define SN_subject_key_identifier "subjectKeyIdentifier" -#define LN_subject_key_identifier "X509v3 Subject Key Identifier" -#define NID_subject_key_identifier 82 -#define OBJ_subject_key_identifier OBJ_id_ce,14L - -#define SN_key_usage "keyUsage" -#define LN_key_usage "X509v3 Key Usage" -#define NID_key_usage 83 -#define OBJ_key_usage OBJ_id_ce,15L - -#define SN_private_key_usage_period "privateKeyUsagePeriod" -#define LN_private_key_usage_period "X509v3 Private Key Usage Period" -#define NID_private_key_usage_period 84 -#define OBJ_private_key_usage_period OBJ_id_ce,16L - -#define SN_subject_alt_name "subjectAltName" -#define LN_subject_alt_name "X509v3 Subject Alternative Name" -#define NID_subject_alt_name 85 -#define OBJ_subject_alt_name OBJ_id_ce,17L - -#define SN_issuer_alt_name "issuerAltName" -#define LN_issuer_alt_name "X509v3 Issuer Alternative Name" -#define NID_issuer_alt_name 86 -#define OBJ_issuer_alt_name OBJ_id_ce,18L - -#define SN_basic_constraints "basicConstraints" -#define LN_basic_constraints "X509v3 Basic Constraints" -#define NID_basic_constraints 87 -#define OBJ_basic_constraints OBJ_id_ce,19L - -#define SN_crl_number "crlNumber" -#define LN_crl_number "X509v3 CRL Number" -#define NID_crl_number 88 -#define OBJ_crl_number OBJ_id_ce,20L - -#define SN_crl_reason "CRLReason" -#define LN_crl_reason "X509v3 CRL Reason Code" -#define NID_crl_reason 141 -#define OBJ_crl_reason OBJ_id_ce,21L - -#define SN_invalidity_date "invalidityDate" -#define LN_invalidity_date "Invalidity Date" -#define NID_invalidity_date 142 -#define OBJ_invalidity_date OBJ_id_ce,24L - -#define SN_delta_crl "deltaCRL" -#define LN_delta_crl "X509v3 Delta CRL Indicator" -#define NID_delta_crl 140 -#define OBJ_delta_crl OBJ_id_ce,27L - -#define SN_issuing_distribution_point "issuingDistributionPoint" -#define LN_issuing_distribution_point "X509v3 Issuing Distribution Point" -#define NID_issuing_distribution_point 770 -#define OBJ_issuing_distribution_point OBJ_id_ce,28L - -#define SN_certificate_issuer "certificateIssuer" -#define LN_certificate_issuer "X509v3 Certificate Issuer" -#define NID_certificate_issuer 771 -#define OBJ_certificate_issuer OBJ_id_ce,29L - -#define SN_name_constraints "nameConstraints" -#define LN_name_constraints "X509v3 Name Constraints" -#define NID_name_constraints 666 -#define OBJ_name_constraints OBJ_id_ce,30L - -#define SN_crl_distribution_points "crlDistributionPoints" -#define LN_crl_distribution_points "X509v3 CRL Distribution Points" -#define NID_crl_distribution_points 103 -#define OBJ_crl_distribution_points OBJ_id_ce,31L - -#define SN_certificate_policies "certificatePolicies" -#define LN_certificate_policies "X509v3 Certificate Policies" -#define NID_certificate_policies 89 -#define OBJ_certificate_policies OBJ_id_ce,32L - -#define SN_any_policy "anyPolicy" -#define LN_any_policy "X509v3 Any Policy" -#define NID_any_policy 746 -#define OBJ_any_policy OBJ_certificate_policies,0L - -#define SN_policy_mappings "policyMappings" -#define LN_policy_mappings "X509v3 Policy Mappings" -#define NID_policy_mappings 747 -#define OBJ_policy_mappings OBJ_id_ce,33L - -#define SN_authority_key_identifier "authorityKeyIdentifier" -#define LN_authority_key_identifier "X509v3 Authority Key Identifier" -#define NID_authority_key_identifier 90 -#define OBJ_authority_key_identifier OBJ_id_ce,35L - -#define SN_policy_constraints "policyConstraints" -#define LN_policy_constraints "X509v3 Policy Constraints" -#define NID_policy_constraints 401 -#define OBJ_policy_constraints OBJ_id_ce,36L - -#define SN_ext_key_usage "extendedKeyUsage" -#define LN_ext_key_usage "X509v3 Extended Key Usage" -#define NID_ext_key_usage 126 -#define OBJ_ext_key_usage OBJ_id_ce,37L - -#define SN_freshest_crl "freshestCRL" -#define LN_freshest_crl "X509v3 Freshest CRL" -#define NID_freshest_crl 857 -#define OBJ_freshest_crl OBJ_id_ce,46L - -#define SN_inhibit_any_policy "inhibitAnyPolicy" -#define LN_inhibit_any_policy "X509v3 Inhibit Any Policy" -#define NID_inhibit_any_policy 748 -#define OBJ_inhibit_any_policy OBJ_id_ce,54L - -#define SN_target_information "targetInformation" -#define LN_target_information "X509v3 AC Targeting" -#define NID_target_information 402 -#define OBJ_target_information OBJ_id_ce,55L - -#define SN_no_rev_avail "noRevAvail" -#define LN_no_rev_avail "X509v3 No Revocation Available" -#define NID_no_rev_avail 403 -#define OBJ_no_rev_avail OBJ_id_ce,56L - -#define SN_anyExtendedKeyUsage "anyExtendedKeyUsage" -#define LN_anyExtendedKeyUsage "Any Extended Key Usage" -#define NID_anyExtendedKeyUsage 910 -#define OBJ_anyExtendedKeyUsage OBJ_ext_key_usage,0L - -#define SN_netscape "Netscape" -#define LN_netscape "Netscape Communications Corp." -#define NID_netscape 57 -#define OBJ_netscape 2L,16L,840L,1L,113730L - -#define SN_netscape_cert_extension "nsCertExt" -#define LN_netscape_cert_extension "Netscape Certificate Extension" -#define NID_netscape_cert_extension 58 -#define OBJ_netscape_cert_extension OBJ_netscape,1L - -#define SN_netscape_data_type "nsDataType" -#define LN_netscape_data_type "Netscape Data Type" -#define NID_netscape_data_type 59 -#define OBJ_netscape_data_type OBJ_netscape,2L - -#define SN_netscape_cert_type "nsCertType" -#define LN_netscape_cert_type "Netscape Cert Type" -#define NID_netscape_cert_type 71 -#define OBJ_netscape_cert_type OBJ_netscape_cert_extension,1L - -#define SN_netscape_base_url "nsBaseUrl" -#define LN_netscape_base_url "Netscape Base Url" -#define NID_netscape_base_url 72 -#define OBJ_netscape_base_url OBJ_netscape_cert_extension,2L - -#define SN_netscape_revocation_url "nsRevocationUrl" -#define LN_netscape_revocation_url "Netscape Revocation Url" -#define NID_netscape_revocation_url 73 -#define OBJ_netscape_revocation_url OBJ_netscape_cert_extension,3L - -#define SN_netscape_ca_revocation_url "nsCaRevocationUrl" -#define LN_netscape_ca_revocation_url "Netscape CA Revocation Url" -#define NID_netscape_ca_revocation_url 74 -#define OBJ_netscape_ca_revocation_url OBJ_netscape_cert_extension,4L - -#define SN_netscape_renewal_url "nsRenewalUrl" -#define LN_netscape_renewal_url "Netscape Renewal Url" -#define NID_netscape_renewal_url 75 -#define OBJ_netscape_renewal_url OBJ_netscape_cert_extension,7L - -#define SN_netscape_ca_policy_url "nsCaPolicyUrl" -#define LN_netscape_ca_policy_url "Netscape CA Policy Url" -#define NID_netscape_ca_policy_url 76 -#define OBJ_netscape_ca_policy_url OBJ_netscape_cert_extension,8L - -#define SN_netscape_ssl_server_name "nsSslServerName" -#define LN_netscape_ssl_server_name "Netscape SSL Server Name" -#define NID_netscape_ssl_server_name 77 -#define OBJ_netscape_ssl_server_name OBJ_netscape_cert_extension,12L - -#define SN_netscape_comment "nsComment" -#define LN_netscape_comment "Netscape Comment" -#define NID_netscape_comment 78 -#define OBJ_netscape_comment OBJ_netscape_cert_extension,13L - -#define SN_netscape_cert_sequence "nsCertSequence" -#define LN_netscape_cert_sequence "Netscape Certificate Sequence" -#define NID_netscape_cert_sequence 79 -#define OBJ_netscape_cert_sequence OBJ_netscape_data_type,5L - -#define SN_ns_sgc "nsSGC" -#define LN_ns_sgc "Netscape Server Gated Crypto" -#define NID_ns_sgc 139 -#define OBJ_ns_sgc OBJ_netscape,4L,1L - -#define SN_org "ORG" -#define LN_org "org" -#define NID_org 379 -#define OBJ_org OBJ_iso,3L - -#define SN_dod "DOD" -#define LN_dod "dod" -#define NID_dod 380 -#define OBJ_dod OBJ_org,6L - -#define SN_iana "IANA" -#define LN_iana "iana" -#define NID_iana 381 -#define OBJ_iana OBJ_dod,1L - -#define OBJ_internet OBJ_iana - -#define SN_Directory "directory" -#define LN_Directory "Directory" -#define NID_Directory 382 -#define OBJ_Directory OBJ_internet,1L - -#define SN_Management "mgmt" -#define LN_Management "Management" -#define NID_Management 383 -#define OBJ_Management OBJ_internet,2L - -#define SN_Experimental "experimental" -#define LN_Experimental "Experimental" -#define NID_Experimental 384 -#define OBJ_Experimental OBJ_internet,3L - -#define SN_Private "private" -#define LN_Private "Private" -#define NID_Private 385 -#define OBJ_Private OBJ_internet,4L - -#define SN_Security "security" -#define LN_Security "Security" -#define NID_Security 386 -#define OBJ_Security OBJ_internet,5L - -#define SN_SNMPv2 "snmpv2" -#define LN_SNMPv2 "SNMPv2" -#define NID_SNMPv2 387 -#define OBJ_SNMPv2 OBJ_internet,6L - -#define LN_Mail "Mail" -#define NID_Mail 388 -#define OBJ_Mail OBJ_internet,7L - -#define SN_Enterprises "enterprises" -#define LN_Enterprises "Enterprises" -#define NID_Enterprises 389 -#define OBJ_Enterprises OBJ_Private,1L - -#define SN_dcObject "dcobject" -#define LN_dcObject "dcObject" -#define NID_dcObject 390 -#define OBJ_dcObject OBJ_Enterprises,1466L,344L - -#define SN_mime_mhs "mime-mhs" -#define LN_mime_mhs "MIME MHS" -#define NID_mime_mhs 504 -#define OBJ_mime_mhs OBJ_Mail,1L - -#define SN_mime_mhs_headings "mime-mhs-headings" -#define LN_mime_mhs_headings "mime-mhs-headings" -#define NID_mime_mhs_headings 505 -#define OBJ_mime_mhs_headings OBJ_mime_mhs,1L - -#define SN_mime_mhs_bodies "mime-mhs-bodies" -#define LN_mime_mhs_bodies "mime-mhs-bodies" -#define NID_mime_mhs_bodies 506 -#define OBJ_mime_mhs_bodies OBJ_mime_mhs,2L - -#define SN_id_hex_partial_message "id-hex-partial-message" -#define LN_id_hex_partial_message "id-hex-partial-message" -#define NID_id_hex_partial_message 507 -#define OBJ_id_hex_partial_message OBJ_mime_mhs_headings,1L - -#define SN_id_hex_multipart_message "id-hex-multipart-message" -#define LN_id_hex_multipart_message "id-hex-multipart-message" -#define NID_id_hex_multipart_message 508 -#define OBJ_id_hex_multipart_message OBJ_mime_mhs_headings,2L - -#define SN_zlib_compression "ZLIB" -#define LN_zlib_compression "zlib compression" -#define NID_zlib_compression 125 -#define OBJ_zlib_compression OBJ_id_smime_alg,8L - -#define OBJ_csor 2L,16L,840L,1L,101L,3L - -#define OBJ_nistAlgorithms OBJ_csor,4L - -#define OBJ_aes OBJ_nistAlgorithms,1L - -#define SN_aes_128_ecb "AES-128-ECB" -#define LN_aes_128_ecb "aes-128-ecb" -#define NID_aes_128_ecb 418 -#define OBJ_aes_128_ecb OBJ_aes,1L - -#define SN_aes_128_cbc "AES-128-CBC" -#define LN_aes_128_cbc "aes-128-cbc" -#define NID_aes_128_cbc 419 -#define OBJ_aes_128_cbc OBJ_aes,2L - -#define SN_aes_128_ofb128 "AES-128-OFB" -#define LN_aes_128_ofb128 "aes-128-ofb" -#define NID_aes_128_ofb128 420 -#define OBJ_aes_128_ofb128 OBJ_aes,3L - -#define SN_aes_128_cfb128 "AES-128-CFB" -#define LN_aes_128_cfb128 "aes-128-cfb" -#define NID_aes_128_cfb128 421 -#define OBJ_aes_128_cfb128 OBJ_aes,4L - -#define SN_id_aes128_wrap "id-aes128-wrap" -#define NID_id_aes128_wrap 788 -#define OBJ_id_aes128_wrap OBJ_aes,5L - -#define SN_aes_128_gcm "id-aes128-GCM" -#define LN_aes_128_gcm "aes-128-gcm" -#define NID_aes_128_gcm 895 -#define OBJ_aes_128_gcm OBJ_aes,6L - -#define SN_aes_128_ccm "id-aes128-CCM" -#define LN_aes_128_ccm "aes-128-ccm" -#define NID_aes_128_ccm 896 -#define OBJ_aes_128_ccm OBJ_aes,7L - -#define SN_id_aes128_wrap_pad "id-aes128-wrap-pad" -#define NID_id_aes128_wrap_pad 897 -#define OBJ_id_aes128_wrap_pad OBJ_aes,8L - -#define SN_aes_192_ecb "AES-192-ECB" -#define LN_aes_192_ecb "aes-192-ecb" -#define NID_aes_192_ecb 422 -#define OBJ_aes_192_ecb OBJ_aes,21L - -#define SN_aes_192_cbc "AES-192-CBC" -#define LN_aes_192_cbc "aes-192-cbc" -#define NID_aes_192_cbc 423 -#define OBJ_aes_192_cbc OBJ_aes,22L - -#define SN_aes_192_ofb128 "AES-192-OFB" -#define LN_aes_192_ofb128 "aes-192-ofb" -#define NID_aes_192_ofb128 424 -#define OBJ_aes_192_ofb128 OBJ_aes,23L - -#define SN_aes_192_cfb128 "AES-192-CFB" -#define LN_aes_192_cfb128 "aes-192-cfb" -#define NID_aes_192_cfb128 425 -#define OBJ_aes_192_cfb128 OBJ_aes,24L - -#define SN_id_aes192_wrap "id-aes192-wrap" -#define NID_id_aes192_wrap 789 -#define OBJ_id_aes192_wrap OBJ_aes,25L - -#define SN_aes_192_gcm "id-aes192-GCM" -#define LN_aes_192_gcm "aes-192-gcm" -#define NID_aes_192_gcm 898 -#define OBJ_aes_192_gcm OBJ_aes,26L - -#define SN_aes_192_ccm "id-aes192-CCM" -#define LN_aes_192_ccm "aes-192-ccm" -#define NID_aes_192_ccm 899 -#define OBJ_aes_192_ccm OBJ_aes,27L - -#define SN_id_aes192_wrap_pad "id-aes192-wrap-pad" -#define NID_id_aes192_wrap_pad 900 -#define OBJ_id_aes192_wrap_pad OBJ_aes,28L - -#define SN_aes_256_ecb "AES-256-ECB" -#define LN_aes_256_ecb "aes-256-ecb" -#define NID_aes_256_ecb 426 -#define OBJ_aes_256_ecb OBJ_aes,41L - -#define SN_aes_256_cbc "AES-256-CBC" -#define LN_aes_256_cbc "aes-256-cbc" -#define NID_aes_256_cbc 427 -#define OBJ_aes_256_cbc OBJ_aes,42L - -#define SN_aes_256_ofb128 "AES-256-OFB" -#define LN_aes_256_ofb128 "aes-256-ofb" -#define NID_aes_256_ofb128 428 -#define OBJ_aes_256_ofb128 OBJ_aes,43L - -#define SN_aes_256_cfb128 "AES-256-CFB" -#define LN_aes_256_cfb128 "aes-256-cfb" -#define NID_aes_256_cfb128 429 -#define OBJ_aes_256_cfb128 OBJ_aes,44L - -#define SN_id_aes256_wrap "id-aes256-wrap" -#define NID_id_aes256_wrap 790 -#define OBJ_id_aes256_wrap OBJ_aes,45L - -#define SN_aes_256_gcm "id-aes256-GCM" -#define LN_aes_256_gcm "aes-256-gcm" -#define NID_aes_256_gcm 901 -#define OBJ_aes_256_gcm OBJ_aes,46L - -#define SN_aes_256_ccm "id-aes256-CCM" -#define LN_aes_256_ccm "aes-256-ccm" -#define NID_aes_256_ccm 902 -#define OBJ_aes_256_ccm OBJ_aes,47L - -#define SN_id_aes256_wrap_pad "id-aes256-wrap-pad" -#define NID_id_aes256_wrap_pad 903 -#define OBJ_id_aes256_wrap_pad OBJ_aes,48L - -#define SN_aes_128_cfb1 "AES-128-CFB1" -#define LN_aes_128_cfb1 "aes-128-cfb1" -#define NID_aes_128_cfb1 650 - -#define SN_aes_192_cfb1 "AES-192-CFB1" -#define LN_aes_192_cfb1 "aes-192-cfb1" -#define NID_aes_192_cfb1 651 - -#define SN_aes_256_cfb1 "AES-256-CFB1" -#define LN_aes_256_cfb1 "aes-256-cfb1" -#define NID_aes_256_cfb1 652 - -#define SN_aes_128_cfb8 "AES-128-CFB8" -#define LN_aes_128_cfb8 "aes-128-cfb8" -#define NID_aes_128_cfb8 653 - -#define SN_aes_192_cfb8 "AES-192-CFB8" -#define LN_aes_192_cfb8 "aes-192-cfb8" -#define NID_aes_192_cfb8 654 - -#define SN_aes_256_cfb8 "AES-256-CFB8" -#define LN_aes_256_cfb8 "aes-256-cfb8" -#define NID_aes_256_cfb8 655 - -#define SN_aes_128_ctr "AES-128-CTR" -#define LN_aes_128_ctr "aes-128-ctr" -#define NID_aes_128_ctr 904 - -#define SN_aes_192_ctr "AES-192-CTR" -#define LN_aes_192_ctr "aes-192-ctr" -#define NID_aes_192_ctr 905 - -#define SN_aes_256_ctr "AES-256-CTR" -#define LN_aes_256_ctr "aes-256-ctr" -#define NID_aes_256_ctr 906 - -#define SN_aes_128_xts "AES-128-XTS" -#define LN_aes_128_xts "aes-128-xts" -#define NID_aes_128_xts 913 - -#define SN_aes_256_xts "AES-256-XTS" -#define LN_aes_256_xts "aes-256-xts" -#define NID_aes_256_xts 914 - -#define SN_des_cfb1 "DES-CFB1" -#define LN_des_cfb1 "des-cfb1" -#define NID_des_cfb1 656 - -#define SN_des_cfb8 "DES-CFB8" -#define LN_des_cfb8 "des-cfb8" -#define NID_des_cfb8 657 - -#define SN_des_ede3_cfb1 "DES-EDE3-CFB1" -#define LN_des_ede3_cfb1 "des-ede3-cfb1" -#define NID_des_ede3_cfb1 658 - -#define SN_des_ede3_cfb8 "DES-EDE3-CFB8" -#define LN_des_ede3_cfb8 "des-ede3-cfb8" -#define NID_des_ede3_cfb8 659 - -#define OBJ_nist_hashalgs OBJ_nistAlgorithms,2L - -#define SN_sha256 "SHA256" -#define LN_sha256 "sha256" -#define NID_sha256 672 -#define OBJ_sha256 OBJ_nist_hashalgs,1L - -#define SN_sha384 "SHA384" -#define LN_sha384 "sha384" -#define NID_sha384 673 -#define OBJ_sha384 OBJ_nist_hashalgs,2L - -#define SN_sha512 "SHA512" -#define LN_sha512 "sha512" -#define NID_sha512 674 -#define OBJ_sha512 OBJ_nist_hashalgs,3L - -#define SN_sha224 "SHA224" -#define LN_sha224 "sha224" -#define NID_sha224 675 -#define OBJ_sha224 OBJ_nist_hashalgs,4L - -#define OBJ_dsa_with_sha2 OBJ_nistAlgorithms,3L - -#define SN_dsa_with_SHA224 "dsa_with_SHA224" -#define NID_dsa_with_SHA224 802 -#define OBJ_dsa_with_SHA224 OBJ_dsa_with_sha2,1L - -#define SN_dsa_with_SHA256 "dsa_with_SHA256" -#define NID_dsa_with_SHA256 803 -#define OBJ_dsa_with_SHA256 OBJ_dsa_with_sha2,2L - -#define SN_hold_instruction_code "holdInstructionCode" -#define LN_hold_instruction_code "Hold Instruction Code" -#define NID_hold_instruction_code 430 -#define OBJ_hold_instruction_code OBJ_id_ce,23L - -#define OBJ_holdInstruction OBJ_X9_57,2L - -#define SN_hold_instruction_none "holdInstructionNone" -#define LN_hold_instruction_none "Hold Instruction None" -#define NID_hold_instruction_none 431 -#define OBJ_hold_instruction_none OBJ_holdInstruction,1L - -#define SN_hold_instruction_call_issuer "holdInstructionCallIssuer" -#define LN_hold_instruction_call_issuer "Hold Instruction Call Issuer" -#define NID_hold_instruction_call_issuer 432 -#define OBJ_hold_instruction_call_issuer OBJ_holdInstruction,2L - -#define SN_hold_instruction_reject "holdInstructionReject" -#define LN_hold_instruction_reject "Hold Instruction Reject" -#define NID_hold_instruction_reject 433 -#define OBJ_hold_instruction_reject OBJ_holdInstruction,3L - -#define SN_data "data" -#define NID_data 434 -#define OBJ_data OBJ_itu_t,9L - -#define SN_pss "pss" -#define NID_pss 435 -#define OBJ_pss OBJ_data,2342L - -#define SN_ucl "ucl" -#define NID_ucl 436 -#define OBJ_ucl OBJ_pss,19200300L - -#define SN_pilot "pilot" -#define NID_pilot 437 -#define OBJ_pilot OBJ_ucl,100L - -#define LN_pilotAttributeType "pilotAttributeType" -#define NID_pilotAttributeType 438 -#define OBJ_pilotAttributeType OBJ_pilot,1L - -#define LN_pilotAttributeSyntax "pilotAttributeSyntax" -#define NID_pilotAttributeSyntax 439 -#define OBJ_pilotAttributeSyntax OBJ_pilot,3L - -#define LN_pilotObjectClass "pilotObjectClass" -#define NID_pilotObjectClass 440 -#define OBJ_pilotObjectClass OBJ_pilot,4L - -#define LN_pilotGroups "pilotGroups" -#define NID_pilotGroups 441 -#define OBJ_pilotGroups OBJ_pilot,10L - -#define LN_iA5StringSyntax "iA5StringSyntax" -#define NID_iA5StringSyntax 442 -#define OBJ_iA5StringSyntax OBJ_pilotAttributeSyntax,4L - -#define LN_caseIgnoreIA5StringSyntax "caseIgnoreIA5StringSyntax" -#define NID_caseIgnoreIA5StringSyntax 443 -#define OBJ_caseIgnoreIA5StringSyntax OBJ_pilotAttributeSyntax,5L - -#define LN_pilotObject "pilotObject" -#define NID_pilotObject 444 -#define OBJ_pilotObject OBJ_pilotObjectClass,3L - -#define LN_pilotPerson "pilotPerson" -#define NID_pilotPerson 445 -#define OBJ_pilotPerson OBJ_pilotObjectClass,4L - -#define SN_account "account" -#define NID_account 446 -#define OBJ_account OBJ_pilotObjectClass,5L - -#define SN_document "document" -#define NID_document 447 -#define OBJ_document OBJ_pilotObjectClass,6L - -#define SN_room "room" -#define NID_room 448 -#define OBJ_room OBJ_pilotObjectClass,7L - -#define LN_documentSeries "documentSeries" -#define NID_documentSeries 449 -#define OBJ_documentSeries OBJ_pilotObjectClass,9L - -#define SN_Domain "domain" -#define LN_Domain "Domain" -#define NID_Domain 392 -#define OBJ_Domain OBJ_pilotObjectClass,13L - -#define LN_rFC822localPart "rFC822localPart" -#define NID_rFC822localPart 450 -#define OBJ_rFC822localPart OBJ_pilotObjectClass,14L - -#define LN_dNSDomain "dNSDomain" -#define NID_dNSDomain 451 -#define OBJ_dNSDomain OBJ_pilotObjectClass,15L - -#define LN_domainRelatedObject "domainRelatedObject" -#define NID_domainRelatedObject 452 -#define OBJ_domainRelatedObject OBJ_pilotObjectClass,17L - -#define LN_friendlyCountry "friendlyCountry" -#define NID_friendlyCountry 453 -#define OBJ_friendlyCountry OBJ_pilotObjectClass,18L - -#define LN_simpleSecurityObject "simpleSecurityObject" -#define NID_simpleSecurityObject 454 -#define OBJ_simpleSecurityObject OBJ_pilotObjectClass,19L - -#define LN_pilotOrganization "pilotOrganization" -#define NID_pilotOrganization 455 -#define OBJ_pilotOrganization OBJ_pilotObjectClass,20L - -#define LN_pilotDSA "pilotDSA" -#define NID_pilotDSA 456 -#define OBJ_pilotDSA OBJ_pilotObjectClass,21L - -#define LN_qualityLabelledData "qualityLabelledData" -#define NID_qualityLabelledData 457 -#define OBJ_qualityLabelledData OBJ_pilotObjectClass,22L - -#define SN_userId "UID" -#define LN_userId "userId" -#define NID_userId 458 -#define OBJ_userId OBJ_pilotAttributeType,1L - -#define LN_textEncodedORAddress "textEncodedORAddress" -#define NID_textEncodedORAddress 459 -#define OBJ_textEncodedORAddress OBJ_pilotAttributeType,2L - -#define SN_rfc822Mailbox "mail" -#define LN_rfc822Mailbox "rfc822Mailbox" -#define NID_rfc822Mailbox 460 -#define OBJ_rfc822Mailbox OBJ_pilotAttributeType,3L - -#define SN_info "info" -#define NID_info 461 -#define OBJ_info OBJ_pilotAttributeType,4L - -#define LN_favouriteDrink "favouriteDrink" -#define NID_favouriteDrink 462 -#define OBJ_favouriteDrink OBJ_pilotAttributeType,5L - -#define LN_roomNumber "roomNumber" -#define NID_roomNumber 463 -#define OBJ_roomNumber OBJ_pilotAttributeType,6L - -#define SN_photo "photo" -#define NID_photo 464 -#define OBJ_photo OBJ_pilotAttributeType,7L - -#define LN_userClass "userClass" -#define NID_userClass 465 -#define OBJ_userClass OBJ_pilotAttributeType,8L - -#define SN_host "host" -#define NID_host 466 -#define OBJ_host OBJ_pilotAttributeType,9L - -#define SN_manager "manager" -#define NID_manager 467 -#define OBJ_manager OBJ_pilotAttributeType,10L - -#define LN_documentIdentifier "documentIdentifier" -#define NID_documentIdentifier 468 -#define OBJ_documentIdentifier OBJ_pilotAttributeType,11L - -#define LN_documentTitle "documentTitle" -#define NID_documentTitle 469 -#define OBJ_documentTitle OBJ_pilotAttributeType,12L - -#define LN_documentVersion "documentVersion" -#define NID_documentVersion 470 -#define OBJ_documentVersion OBJ_pilotAttributeType,13L - -#define LN_documentAuthor "documentAuthor" -#define NID_documentAuthor 471 -#define OBJ_documentAuthor OBJ_pilotAttributeType,14L - -#define LN_documentLocation "documentLocation" -#define NID_documentLocation 472 -#define OBJ_documentLocation OBJ_pilotAttributeType,15L - -#define LN_homeTelephoneNumber "homeTelephoneNumber" -#define NID_homeTelephoneNumber 473 -#define OBJ_homeTelephoneNumber OBJ_pilotAttributeType,20L - -#define SN_secretary "secretary" -#define NID_secretary 474 -#define OBJ_secretary OBJ_pilotAttributeType,21L - -#define LN_otherMailbox "otherMailbox" -#define NID_otherMailbox 475 -#define OBJ_otherMailbox OBJ_pilotAttributeType,22L - -#define LN_lastModifiedTime "lastModifiedTime" -#define NID_lastModifiedTime 476 -#define OBJ_lastModifiedTime OBJ_pilotAttributeType,23L - -#define LN_lastModifiedBy "lastModifiedBy" -#define NID_lastModifiedBy 477 -#define OBJ_lastModifiedBy OBJ_pilotAttributeType,24L - -#define SN_domainComponent "DC" -#define LN_domainComponent "domainComponent" -#define NID_domainComponent 391 -#define OBJ_domainComponent OBJ_pilotAttributeType,25L - -#define LN_aRecord "aRecord" -#define NID_aRecord 478 -#define OBJ_aRecord OBJ_pilotAttributeType,26L - -#define LN_pilotAttributeType27 "pilotAttributeType27" -#define NID_pilotAttributeType27 479 -#define OBJ_pilotAttributeType27 OBJ_pilotAttributeType,27L - -#define LN_mXRecord "mXRecord" -#define NID_mXRecord 480 -#define OBJ_mXRecord OBJ_pilotAttributeType,28L - -#define LN_nSRecord "nSRecord" -#define NID_nSRecord 481 -#define OBJ_nSRecord OBJ_pilotAttributeType,29L - -#define LN_sOARecord "sOARecord" -#define NID_sOARecord 482 -#define OBJ_sOARecord OBJ_pilotAttributeType,30L - -#define LN_cNAMERecord "cNAMERecord" -#define NID_cNAMERecord 483 -#define OBJ_cNAMERecord OBJ_pilotAttributeType,31L - -#define LN_associatedDomain "associatedDomain" -#define NID_associatedDomain 484 -#define OBJ_associatedDomain OBJ_pilotAttributeType,37L - -#define LN_associatedName "associatedName" -#define NID_associatedName 485 -#define OBJ_associatedName OBJ_pilotAttributeType,38L - -#define LN_homePostalAddress "homePostalAddress" -#define NID_homePostalAddress 486 -#define OBJ_homePostalAddress OBJ_pilotAttributeType,39L - -#define LN_personalTitle "personalTitle" -#define NID_personalTitle 487 -#define OBJ_personalTitle OBJ_pilotAttributeType,40L - -#define LN_mobileTelephoneNumber "mobileTelephoneNumber" -#define NID_mobileTelephoneNumber 488 -#define OBJ_mobileTelephoneNumber OBJ_pilotAttributeType,41L - -#define LN_pagerTelephoneNumber "pagerTelephoneNumber" -#define NID_pagerTelephoneNumber 489 -#define OBJ_pagerTelephoneNumber OBJ_pilotAttributeType,42L - -#define LN_friendlyCountryName "friendlyCountryName" -#define NID_friendlyCountryName 490 -#define OBJ_friendlyCountryName OBJ_pilotAttributeType,43L - -#define LN_organizationalStatus "organizationalStatus" -#define NID_organizationalStatus 491 -#define OBJ_organizationalStatus OBJ_pilotAttributeType,45L - -#define LN_janetMailbox "janetMailbox" -#define NID_janetMailbox 492 -#define OBJ_janetMailbox OBJ_pilotAttributeType,46L - -#define LN_mailPreferenceOption "mailPreferenceOption" -#define NID_mailPreferenceOption 493 -#define OBJ_mailPreferenceOption OBJ_pilotAttributeType,47L - -#define LN_buildingName "buildingName" -#define NID_buildingName 494 -#define OBJ_buildingName OBJ_pilotAttributeType,48L - -#define LN_dSAQuality "dSAQuality" -#define NID_dSAQuality 495 -#define OBJ_dSAQuality OBJ_pilotAttributeType,49L - -#define LN_singleLevelQuality "singleLevelQuality" -#define NID_singleLevelQuality 496 -#define OBJ_singleLevelQuality OBJ_pilotAttributeType,50L - -#define LN_subtreeMinimumQuality "subtreeMinimumQuality" -#define NID_subtreeMinimumQuality 497 -#define OBJ_subtreeMinimumQuality OBJ_pilotAttributeType,51L - -#define LN_subtreeMaximumQuality "subtreeMaximumQuality" -#define NID_subtreeMaximumQuality 498 -#define OBJ_subtreeMaximumQuality OBJ_pilotAttributeType,52L - -#define LN_personalSignature "personalSignature" -#define NID_personalSignature 499 -#define OBJ_personalSignature OBJ_pilotAttributeType,53L - -#define LN_dITRedirect "dITRedirect" -#define NID_dITRedirect 500 -#define OBJ_dITRedirect OBJ_pilotAttributeType,54L - -#define SN_audio "audio" -#define NID_audio 501 -#define OBJ_audio OBJ_pilotAttributeType,55L - -#define LN_documentPublisher "documentPublisher" -#define NID_documentPublisher 502 -#define OBJ_documentPublisher OBJ_pilotAttributeType,56L - -#define SN_id_set "id-set" -#define LN_id_set "Secure Electronic Transactions" -#define NID_id_set 512 -#define OBJ_id_set OBJ_international_organizations,42L - -#define SN_set_ctype "set-ctype" -#define LN_set_ctype "content types" -#define NID_set_ctype 513 -#define OBJ_set_ctype OBJ_id_set,0L - -#define SN_set_msgExt "set-msgExt" -#define LN_set_msgExt "message extensions" -#define NID_set_msgExt 514 -#define OBJ_set_msgExt OBJ_id_set,1L - -#define SN_set_attr "set-attr" -#define NID_set_attr 515 -#define OBJ_set_attr OBJ_id_set,3L - -#define SN_set_policy "set-policy" -#define NID_set_policy 516 -#define OBJ_set_policy OBJ_id_set,5L - -#define SN_set_certExt "set-certExt" -#define LN_set_certExt "certificate extensions" -#define NID_set_certExt 517 -#define OBJ_set_certExt OBJ_id_set,7L - -#define SN_set_brand "set-brand" -#define NID_set_brand 518 -#define OBJ_set_brand OBJ_id_set,8L - -#define SN_setct_PANData "setct-PANData" -#define NID_setct_PANData 519 -#define OBJ_setct_PANData OBJ_set_ctype,0L - -#define SN_setct_PANToken "setct-PANToken" -#define NID_setct_PANToken 520 -#define OBJ_setct_PANToken OBJ_set_ctype,1L - -#define SN_setct_PANOnly "setct-PANOnly" -#define NID_setct_PANOnly 521 -#define OBJ_setct_PANOnly OBJ_set_ctype,2L - -#define SN_setct_OIData "setct-OIData" -#define NID_setct_OIData 522 -#define OBJ_setct_OIData OBJ_set_ctype,3L - -#define SN_setct_PI "setct-PI" -#define NID_setct_PI 523 -#define OBJ_setct_PI OBJ_set_ctype,4L - -#define SN_setct_PIData "setct-PIData" -#define NID_setct_PIData 524 -#define OBJ_setct_PIData OBJ_set_ctype,5L - -#define SN_setct_PIDataUnsigned "setct-PIDataUnsigned" -#define NID_setct_PIDataUnsigned 525 -#define OBJ_setct_PIDataUnsigned OBJ_set_ctype,6L - -#define SN_setct_HODInput "setct-HODInput" -#define NID_setct_HODInput 526 -#define OBJ_setct_HODInput OBJ_set_ctype,7L - -#define SN_setct_AuthResBaggage "setct-AuthResBaggage" -#define NID_setct_AuthResBaggage 527 -#define OBJ_setct_AuthResBaggage OBJ_set_ctype,8L - -#define SN_setct_AuthRevReqBaggage "setct-AuthRevReqBaggage" -#define NID_setct_AuthRevReqBaggage 528 -#define OBJ_setct_AuthRevReqBaggage OBJ_set_ctype,9L - -#define SN_setct_AuthRevResBaggage "setct-AuthRevResBaggage" -#define NID_setct_AuthRevResBaggage 529 -#define OBJ_setct_AuthRevResBaggage OBJ_set_ctype,10L - -#define SN_setct_CapTokenSeq "setct-CapTokenSeq" -#define NID_setct_CapTokenSeq 530 -#define OBJ_setct_CapTokenSeq OBJ_set_ctype,11L - -#define SN_setct_PInitResData "setct-PInitResData" -#define NID_setct_PInitResData 531 -#define OBJ_setct_PInitResData OBJ_set_ctype,12L - -#define SN_setct_PI_TBS "setct-PI-TBS" -#define NID_setct_PI_TBS 532 -#define OBJ_setct_PI_TBS OBJ_set_ctype,13L - -#define SN_setct_PResData "setct-PResData" -#define NID_setct_PResData 533 -#define OBJ_setct_PResData OBJ_set_ctype,14L - -#define SN_setct_AuthReqTBS "setct-AuthReqTBS" -#define NID_setct_AuthReqTBS 534 -#define OBJ_setct_AuthReqTBS OBJ_set_ctype,16L - -#define SN_setct_AuthResTBS "setct-AuthResTBS" -#define NID_setct_AuthResTBS 535 -#define OBJ_setct_AuthResTBS OBJ_set_ctype,17L - -#define SN_setct_AuthResTBSX "setct-AuthResTBSX" -#define NID_setct_AuthResTBSX 536 -#define OBJ_setct_AuthResTBSX OBJ_set_ctype,18L - -#define SN_setct_AuthTokenTBS "setct-AuthTokenTBS" -#define NID_setct_AuthTokenTBS 537 -#define OBJ_setct_AuthTokenTBS OBJ_set_ctype,19L - -#define SN_setct_CapTokenData "setct-CapTokenData" -#define NID_setct_CapTokenData 538 -#define OBJ_setct_CapTokenData OBJ_set_ctype,20L - -#define SN_setct_CapTokenTBS "setct-CapTokenTBS" -#define NID_setct_CapTokenTBS 539 -#define OBJ_setct_CapTokenTBS OBJ_set_ctype,21L - -#define SN_setct_AcqCardCodeMsg "setct-AcqCardCodeMsg" -#define NID_setct_AcqCardCodeMsg 540 -#define OBJ_setct_AcqCardCodeMsg OBJ_set_ctype,22L - -#define SN_setct_AuthRevReqTBS "setct-AuthRevReqTBS" -#define NID_setct_AuthRevReqTBS 541 -#define OBJ_setct_AuthRevReqTBS OBJ_set_ctype,23L - -#define SN_setct_AuthRevResData "setct-AuthRevResData" -#define NID_setct_AuthRevResData 542 -#define OBJ_setct_AuthRevResData OBJ_set_ctype,24L - -#define SN_setct_AuthRevResTBS "setct-AuthRevResTBS" -#define NID_setct_AuthRevResTBS 543 -#define OBJ_setct_AuthRevResTBS OBJ_set_ctype,25L - -#define SN_setct_CapReqTBS "setct-CapReqTBS" -#define NID_setct_CapReqTBS 544 -#define OBJ_setct_CapReqTBS OBJ_set_ctype,26L - -#define SN_setct_CapReqTBSX "setct-CapReqTBSX" -#define NID_setct_CapReqTBSX 545 -#define OBJ_setct_CapReqTBSX OBJ_set_ctype,27L - -#define SN_setct_CapResData "setct-CapResData" -#define NID_setct_CapResData 546 -#define OBJ_setct_CapResData OBJ_set_ctype,28L - -#define SN_setct_CapRevReqTBS "setct-CapRevReqTBS" -#define NID_setct_CapRevReqTBS 547 -#define OBJ_setct_CapRevReqTBS OBJ_set_ctype,29L - -#define SN_setct_CapRevReqTBSX "setct-CapRevReqTBSX" -#define NID_setct_CapRevReqTBSX 548 -#define OBJ_setct_CapRevReqTBSX OBJ_set_ctype,30L - -#define SN_setct_CapRevResData "setct-CapRevResData" -#define NID_setct_CapRevResData 549 -#define OBJ_setct_CapRevResData OBJ_set_ctype,31L - -#define SN_setct_CredReqTBS "setct-CredReqTBS" -#define NID_setct_CredReqTBS 550 -#define OBJ_setct_CredReqTBS OBJ_set_ctype,32L - -#define SN_setct_CredReqTBSX "setct-CredReqTBSX" -#define NID_setct_CredReqTBSX 551 -#define OBJ_setct_CredReqTBSX OBJ_set_ctype,33L - -#define SN_setct_CredResData "setct-CredResData" -#define NID_setct_CredResData 552 -#define OBJ_setct_CredResData OBJ_set_ctype,34L - -#define SN_setct_CredRevReqTBS "setct-CredRevReqTBS" -#define NID_setct_CredRevReqTBS 553 -#define OBJ_setct_CredRevReqTBS OBJ_set_ctype,35L - -#define SN_setct_CredRevReqTBSX "setct-CredRevReqTBSX" -#define NID_setct_CredRevReqTBSX 554 -#define OBJ_setct_CredRevReqTBSX OBJ_set_ctype,36L - -#define SN_setct_CredRevResData "setct-CredRevResData" -#define NID_setct_CredRevResData 555 -#define OBJ_setct_CredRevResData OBJ_set_ctype,37L - -#define SN_setct_PCertReqData "setct-PCertReqData" -#define NID_setct_PCertReqData 556 -#define OBJ_setct_PCertReqData OBJ_set_ctype,38L - -#define SN_setct_PCertResTBS "setct-PCertResTBS" -#define NID_setct_PCertResTBS 557 -#define OBJ_setct_PCertResTBS OBJ_set_ctype,39L - -#define SN_setct_BatchAdminReqData "setct-BatchAdminReqData" -#define NID_setct_BatchAdminReqData 558 -#define OBJ_setct_BatchAdminReqData OBJ_set_ctype,40L - -#define SN_setct_BatchAdminResData "setct-BatchAdminResData" -#define NID_setct_BatchAdminResData 559 -#define OBJ_setct_BatchAdminResData OBJ_set_ctype,41L - -#define SN_setct_CardCInitResTBS "setct-CardCInitResTBS" -#define NID_setct_CardCInitResTBS 560 -#define OBJ_setct_CardCInitResTBS OBJ_set_ctype,42L - -#define SN_setct_MeAqCInitResTBS "setct-MeAqCInitResTBS" -#define NID_setct_MeAqCInitResTBS 561 -#define OBJ_setct_MeAqCInitResTBS OBJ_set_ctype,43L - -#define SN_setct_RegFormResTBS "setct-RegFormResTBS" -#define NID_setct_RegFormResTBS 562 -#define OBJ_setct_RegFormResTBS OBJ_set_ctype,44L - -#define SN_setct_CertReqData "setct-CertReqData" -#define NID_setct_CertReqData 563 -#define OBJ_setct_CertReqData OBJ_set_ctype,45L - -#define SN_setct_CertReqTBS "setct-CertReqTBS" -#define NID_setct_CertReqTBS 564 -#define OBJ_setct_CertReqTBS OBJ_set_ctype,46L - -#define SN_setct_CertResData "setct-CertResData" -#define NID_setct_CertResData 565 -#define OBJ_setct_CertResData OBJ_set_ctype,47L - -#define SN_setct_CertInqReqTBS "setct-CertInqReqTBS" -#define NID_setct_CertInqReqTBS 566 -#define OBJ_setct_CertInqReqTBS OBJ_set_ctype,48L - -#define SN_setct_ErrorTBS "setct-ErrorTBS" -#define NID_setct_ErrorTBS 567 -#define OBJ_setct_ErrorTBS OBJ_set_ctype,49L - -#define SN_setct_PIDualSignedTBE "setct-PIDualSignedTBE" -#define NID_setct_PIDualSignedTBE 568 -#define OBJ_setct_PIDualSignedTBE OBJ_set_ctype,50L - -#define SN_setct_PIUnsignedTBE "setct-PIUnsignedTBE" -#define NID_setct_PIUnsignedTBE 569 -#define OBJ_setct_PIUnsignedTBE OBJ_set_ctype,51L - -#define SN_setct_AuthReqTBE "setct-AuthReqTBE" -#define NID_setct_AuthReqTBE 570 -#define OBJ_setct_AuthReqTBE OBJ_set_ctype,52L - -#define SN_setct_AuthResTBE "setct-AuthResTBE" -#define NID_setct_AuthResTBE 571 -#define OBJ_setct_AuthResTBE OBJ_set_ctype,53L - -#define SN_setct_AuthResTBEX "setct-AuthResTBEX" -#define NID_setct_AuthResTBEX 572 -#define OBJ_setct_AuthResTBEX OBJ_set_ctype,54L - -#define SN_setct_AuthTokenTBE "setct-AuthTokenTBE" -#define NID_setct_AuthTokenTBE 573 -#define OBJ_setct_AuthTokenTBE OBJ_set_ctype,55L - -#define SN_setct_CapTokenTBE "setct-CapTokenTBE" -#define NID_setct_CapTokenTBE 574 -#define OBJ_setct_CapTokenTBE OBJ_set_ctype,56L - -#define SN_setct_CapTokenTBEX "setct-CapTokenTBEX" -#define NID_setct_CapTokenTBEX 575 -#define OBJ_setct_CapTokenTBEX OBJ_set_ctype,57L - -#define SN_setct_AcqCardCodeMsgTBE "setct-AcqCardCodeMsgTBE" -#define NID_setct_AcqCardCodeMsgTBE 576 -#define OBJ_setct_AcqCardCodeMsgTBE OBJ_set_ctype,58L - -#define SN_setct_AuthRevReqTBE "setct-AuthRevReqTBE" -#define NID_setct_AuthRevReqTBE 577 -#define OBJ_setct_AuthRevReqTBE OBJ_set_ctype,59L - -#define SN_setct_AuthRevResTBE "setct-AuthRevResTBE" -#define NID_setct_AuthRevResTBE 578 -#define OBJ_setct_AuthRevResTBE OBJ_set_ctype,60L - -#define SN_setct_AuthRevResTBEB "setct-AuthRevResTBEB" -#define NID_setct_AuthRevResTBEB 579 -#define OBJ_setct_AuthRevResTBEB OBJ_set_ctype,61L - -#define SN_setct_CapReqTBE "setct-CapReqTBE" -#define NID_setct_CapReqTBE 580 -#define OBJ_setct_CapReqTBE OBJ_set_ctype,62L - -#define SN_setct_CapReqTBEX "setct-CapReqTBEX" -#define NID_setct_CapReqTBEX 581 -#define OBJ_setct_CapReqTBEX OBJ_set_ctype,63L - -#define SN_setct_CapResTBE "setct-CapResTBE" -#define NID_setct_CapResTBE 582 -#define OBJ_setct_CapResTBE OBJ_set_ctype,64L - -#define SN_setct_CapRevReqTBE "setct-CapRevReqTBE" -#define NID_setct_CapRevReqTBE 583 -#define OBJ_setct_CapRevReqTBE OBJ_set_ctype,65L - -#define SN_setct_CapRevReqTBEX "setct-CapRevReqTBEX" -#define NID_setct_CapRevReqTBEX 584 -#define OBJ_setct_CapRevReqTBEX OBJ_set_ctype,66L - -#define SN_setct_CapRevResTBE "setct-CapRevResTBE" -#define NID_setct_CapRevResTBE 585 -#define OBJ_setct_CapRevResTBE OBJ_set_ctype,67L - -#define SN_setct_CredReqTBE "setct-CredReqTBE" -#define NID_setct_CredReqTBE 586 -#define OBJ_setct_CredReqTBE OBJ_set_ctype,68L - -#define SN_setct_CredReqTBEX "setct-CredReqTBEX" -#define NID_setct_CredReqTBEX 587 -#define OBJ_setct_CredReqTBEX OBJ_set_ctype,69L - -#define SN_setct_CredResTBE "setct-CredResTBE" -#define NID_setct_CredResTBE 588 -#define OBJ_setct_CredResTBE OBJ_set_ctype,70L - -#define SN_setct_CredRevReqTBE "setct-CredRevReqTBE" -#define NID_setct_CredRevReqTBE 589 -#define OBJ_setct_CredRevReqTBE OBJ_set_ctype,71L - -#define SN_setct_CredRevReqTBEX "setct-CredRevReqTBEX" -#define NID_setct_CredRevReqTBEX 590 -#define OBJ_setct_CredRevReqTBEX OBJ_set_ctype,72L - -#define SN_setct_CredRevResTBE "setct-CredRevResTBE" -#define NID_setct_CredRevResTBE 591 -#define OBJ_setct_CredRevResTBE OBJ_set_ctype,73L - -#define SN_setct_BatchAdminReqTBE "setct-BatchAdminReqTBE" -#define NID_setct_BatchAdminReqTBE 592 -#define OBJ_setct_BatchAdminReqTBE OBJ_set_ctype,74L - -#define SN_setct_BatchAdminResTBE "setct-BatchAdminResTBE" -#define NID_setct_BatchAdminResTBE 593 -#define OBJ_setct_BatchAdminResTBE OBJ_set_ctype,75L - -#define SN_setct_RegFormReqTBE "setct-RegFormReqTBE" -#define NID_setct_RegFormReqTBE 594 -#define OBJ_setct_RegFormReqTBE OBJ_set_ctype,76L - -#define SN_setct_CertReqTBE "setct-CertReqTBE" -#define NID_setct_CertReqTBE 595 -#define OBJ_setct_CertReqTBE OBJ_set_ctype,77L - -#define SN_setct_CertReqTBEX "setct-CertReqTBEX" -#define NID_setct_CertReqTBEX 596 -#define OBJ_setct_CertReqTBEX OBJ_set_ctype,78L - -#define SN_setct_CertResTBE "setct-CertResTBE" -#define NID_setct_CertResTBE 597 -#define OBJ_setct_CertResTBE OBJ_set_ctype,79L - -#define SN_setct_CRLNotificationTBS "setct-CRLNotificationTBS" -#define NID_setct_CRLNotificationTBS 598 -#define OBJ_setct_CRLNotificationTBS OBJ_set_ctype,80L - -#define SN_setct_CRLNotificationResTBS "setct-CRLNotificationResTBS" -#define NID_setct_CRLNotificationResTBS 599 -#define OBJ_setct_CRLNotificationResTBS OBJ_set_ctype,81L - -#define SN_setct_BCIDistributionTBS "setct-BCIDistributionTBS" -#define NID_setct_BCIDistributionTBS 600 -#define OBJ_setct_BCIDistributionTBS OBJ_set_ctype,82L - -#define SN_setext_genCrypt "setext-genCrypt" -#define LN_setext_genCrypt "generic cryptogram" -#define NID_setext_genCrypt 601 -#define OBJ_setext_genCrypt OBJ_set_msgExt,1L - -#define SN_setext_miAuth "setext-miAuth" -#define LN_setext_miAuth "merchant initiated auth" -#define NID_setext_miAuth 602 -#define OBJ_setext_miAuth OBJ_set_msgExt,3L - -#define SN_setext_pinSecure "setext-pinSecure" -#define NID_setext_pinSecure 603 -#define OBJ_setext_pinSecure OBJ_set_msgExt,4L - -#define SN_setext_pinAny "setext-pinAny" -#define NID_setext_pinAny 604 -#define OBJ_setext_pinAny OBJ_set_msgExt,5L - -#define SN_setext_track2 "setext-track2" -#define NID_setext_track2 605 -#define OBJ_setext_track2 OBJ_set_msgExt,7L - -#define SN_setext_cv "setext-cv" -#define LN_setext_cv "additional verification" -#define NID_setext_cv 606 -#define OBJ_setext_cv OBJ_set_msgExt,8L - -#define SN_set_policy_root "set-policy-root" -#define NID_set_policy_root 607 -#define OBJ_set_policy_root OBJ_set_policy,0L - -#define SN_setCext_hashedRoot "setCext-hashedRoot" -#define NID_setCext_hashedRoot 608 -#define OBJ_setCext_hashedRoot OBJ_set_certExt,0L - -#define SN_setCext_certType "setCext-certType" -#define NID_setCext_certType 609 -#define OBJ_setCext_certType OBJ_set_certExt,1L - -#define SN_setCext_merchData "setCext-merchData" -#define NID_setCext_merchData 610 -#define OBJ_setCext_merchData OBJ_set_certExt,2L - -#define SN_setCext_cCertRequired "setCext-cCertRequired" -#define NID_setCext_cCertRequired 611 -#define OBJ_setCext_cCertRequired OBJ_set_certExt,3L - -#define SN_setCext_tunneling "setCext-tunneling" -#define NID_setCext_tunneling 612 -#define OBJ_setCext_tunneling OBJ_set_certExt,4L - -#define SN_setCext_setExt "setCext-setExt" -#define NID_setCext_setExt 613 -#define OBJ_setCext_setExt OBJ_set_certExt,5L - -#define SN_setCext_setQualf "setCext-setQualf" -#define NID_setCext_setQualf 614 -#define OBJ_setCext_setQualf OBJ_set_certExt,6L - -#define SN_setCext_PGWYcapabilities "setCext-PGWYcapabilities" -#define NID_setCext_PGWYcapabilities 615 -#define OBJ_setCext_PGWYcapabilities OBJ_set_certExt,7L - -#define SN_setCext_TokenIdentifier "setCext-TokenIdentifier" -#define NID_setCext_TokenIdentifier 616 -#define OBJ_setCext_TokenIdentifier OBJ_set_certExt,8L - -#define SN_setCext_Track2Data "setCext-Track2Data" -#define NID_setCext_Track2Data 617 -#define OBJ_setCext_Track2Data OBJ_set_certExt,9L - -#define SN_setCext_TokenType "setCext-TokenType" -#define NID_setCext_TokenType 618 -#define OBJ_setCext_TokenType OBJ_set_certExt,10L - -#define SN_setCext_IssuerCapabilities "setCext-IssuerCapabilities" -#define NID_setCext_IssuerCapabilities 619 -#define OBJ_setCext_IssuerCapabilities OBJ_set_certExt,11L - -#define SN_setAttr_Cert "setAttr-Cert" -#define NID_setAttr_Cert 620 -#define OBJ_setAttr_Cert OBJ_set_attr,0L - -#define SN_setAttr_PGWYcap "setAttr-PGWYcap" -#define LN_setAttr_PGWYcap "payment gateway capabilities" -#define NID_setAttr_PGWYcap 621 -#define OBJ_setAttr_PGWYcap OBJ_set_attr,1L - -#define SN_setAttr_TokenType "setAttr-TokenType" -#define NID_setAttr_TokenType 622 -#define OBJ_setAttr_TokenType OBJ_set_attr,2L - -#define SN_setAttr_IssCap "setAttr-IssCap" -#define LN_setAttr_IssCap "issuer capabilities" -#define NID_setAttr_IssCap 623 -#define OBJ_setAttr_IssCap OBJ_set_attr,3L - -#define SN_set_rootKeyThumb "set-rootKeyThumb" -#define NID_set_rootKeyThumb 624 -#define OBJ_set_rootKeyThumb OBJ_setAttr_Cert,0L - -#define SN_set_addPolicy "set-addPolicy" -#define NID_set_addPolicy 625 -#define OBJ_set_addPolicy OBJ_setAttr_Cert,1L - -#define SN_setAttr_Token_EMV "setAttr-Token-EMV" -#define NID_setAttr_Token_EMV 626 -#define OBJ_setAttr_Token_EMV OBJ_setAttr_TokenType,1L - -#define SN_setAttr_Token_B0Prime "setAttr-Token-B0Prime" -#define NID_setAttr_Token_B0Prime 627 -#define OBJ_setAttr_Token_B0Prime OBJ_setAttr_TokenType,2L - -#define SN_setAttr_IssCap_CVM "setAttr-IssCap-CVM" -#define NID_setAttr_IssCap_CVM 628 -#define OBJ_setAttr_IssCap_CVM OBJ_setAttr_IssCap,3L - -#define SN_setAttr_IssCap_T2 "setAttr-IssCap-T2" -#define NID_setAttr_IssCap_T2 629 -#define OBJ_setAttr_IssCap_T2 OBJ_setAttr_IssCap,4L - -#define SN_setAttr_IssCap_Sig "setAttr-IssCap-Sig" -#define NID_setAttr_IssCap_Sig 630 -#define OBJ_setAttr_IssCap_Sig OBJ_setAttr_IssCap,5L - -#define SN_setAttr_GenCryptgrm "setAttr-GenCryptgrm" -#define LN_setAttr_GenCryptgrm "generate cryptogram" -#define NID_setAttr_GenCryptgrm 631 -#define OBJ_setAttr_GenCryptgrm OBJ_setAttr_IssCap_CVM,1L - -#define SN_setAttr_T2Enc "setAttr-T2Enc" -#define LN_setAttr_T2Enc "encrypted track 2" -#define NID_setAttr_T2Enc 632 -#define OBJ_setAttr_T2Enc OBJ_setAttr_IssCap_T2,1L - -#define SN_setAttr_T2cleartxt "setAttr-T2cleartxt" -#define LN_setAttr_T2cleartxt "cleartext track 2" -#define NID_setAttr_T2cleartxt 633 -#define OBJ_setAttr_T2cleartxt OBJ_setAttr_IssCap_T2,2L - -#define SN_setAttr_TokICCsig "setAttr-TokICCsig" -#define LN_setAttr_TokICCsig "ICC or token signature" -#define NID_setAttr_TokICCsig 634 -#define OBJ_setAttr_TokICCsig OBJ_setAttr_IssCap_Sig,1L - -#define SN_setAttr_SecDevSig "setAttr-SecDevSig" -#define LN_setAttr_SecDevSig "secure device signature" -#define NID_setAttr_SecDevSig 635 -#define OBJ_setAttr_SecDevSig OBJ_setAttr_IssCap_Sig,2L - -#define SN_set_brand_IATA_ATA "set-brand-IATA-ATA" -#define NID_set_brand_IATA_ATA 636 -#define OBJ_set_brand_IATA_ATA OBJ_set_brand,1L - -#define SN_set_brand_Diners "set-brand-Diners" -#define NID_set_brand_Diners 637 -#define OBJ_set_brand_Diners OBJ_set_brand,30L - -#define SN_set_brand_AmericanExpress "set-brand-AmericanExpress" -#define NID_set_brand_AmericanExpress 638 -#define OBJ_set_brand_AmericanExpress OBJ_set_brand,34L - -#define SN_set_brand_JCB "set-brand-JCB" -#define NID_set_brand_JCB 639 -#define OBJ_set_brand_JCB OBJ_set_brand,35L - -#define SN_set_brand_Visa "set-brand-Visa" -#define NID_set_brand_Visa 640 -#define OBJ_set_brand_Visa OBJ_set_brand,4L - -#define SN_set_brand_MasterCard "set-brand-MasterCard" -#define NID_set_brand_MasterCard 641 -#define OBJ_set_brand_MasterCard OBJ_set_brand,5L - -#define SN_set_brand_Novus "set-brand-Novus" -#define NID_set_brand_Novus 642 -#define OBJ_set_brand_Novus OBJ_set_brand,6011L - -#define SN_des_cdmf "DES-CDMF" -#define LN_des_cdmf "des-cdmf" -#define NID_des_cdmf 643 -#define OBJ_des_cdmf OBJ_rsadsi,3L,10L - -#define SN_rsaOAEPEncryptionSET "rsaOAEPEncryptionSET" -#define NID_rsaOAEPEncryptionSET 644 -#define OBJ_rsaOAEPEncryptionSET OBJ_rsadsi,1L,1L,6L - -#define SN_ipsec3 "Oakley-EC2N-3" -#define LN_ipsec3 "ipsec3" -#define NID_ipsec3 749 - -#define SN_ipsec4 "Oakley-EC2N-4" -#define LN_ipsec4 "ipsec4" -#define NID_ipsec4 750 - -#define SN_whirlpool "whirlpool" -#define NID_whirlpool 804 -#define OBJ_whirlpool OBJ_iso,0L,10118L,3L,0L,55L - -#define SN_cryptopro "cryptopro" -#define NID_cryptopro 805 -#define OBJ_cryptopro OBJ_member_body,643L,2L,2L - -#define SN_cryptocom "cryptocom" -#define NID_cryptocom 806 -#define OBJ_cryptocom OBJ_member_body,643L,2L,9L - -#define SN_id_GostR3411_94_with_GostR3410_2001 "id-GostR3411-94-with-GostR3410-2001" -#define LN_id_GostR3411_94_with_GostR3410_2001 "GOST R 34.11-94 with GOST R 34.10-2001" -#define NID_id_GostR3411_94_with_GostR3410_2001 807 -#define OBJ_id_GostR3411_94_with_GostR3410_2001 OBJ_cryptopro,3L - -#define SN_id_GostR3411_94_with_GostR3410_94 "id-GostR3411-94-with-GostR3410-94" -#define LN_id_GostR3411_94_with_GostR3410_94 "GOST R 34.11-94 with GOST R 34.10-94" -#define NID_id_GostR3411_94_with_GostR3410_94 808 -#define OBJ_id_GostR3411_94_with_GostR3410_94 OBJ_cryptopro,4L - -#define SN_id_GostR3411_94 "md_gost94" -#define LN_id_GostR3411_94 "GOST R 34.11-94" -#define NID_id_GostR3411_94 809 -#define OBJ_id_GostR3411_94 OBJ_cryptopro,9L - -#define SN_id_HMACGostR3411_94 "id-HMACGostR3411-94" -#define LN_id_HMACGostR3411_94 "HMAC GOST 34.11-94" -#define NID_id_HMACGostR3411_94 810 -#define OBJ_id_HMACGostR3411_94 OBJ_cryptopro,10L - -#define SN_id_GostR3410_2001 "gost2001" -#define LN_id_GostR3410_2001 "GOST R 34.10-2001" -#define NID_id_GostR3410_2001 811 -#define OBJ_id_GostR3410_2001 OBJ_cryptopro,19L - -#define SN_id_GostR3410_94 "gost94" -#define LN_id_GostR3410_94 "GOST R 34.10-94" -#define NID_id_GostR3410_94 812 -#define OBJ_id_GostR3410_94 OBJ_cryptopro,20L - -#define SN_id_Gost28147_89 "gost89" -#define LN_id_Gost28147_89 "GOST 28147-89" -#define NID_id_Gost28147_89 813 -#define OBJ_id_Gost28147_89 OBJ_cryptopro,21L - -#define SN_gost89_cnt "gost89-cnt" -#define NID_gost89_cnt 814 - -#define SN_id_Gost28147_89_MAC "gost-mac" -#define LN_id_Gost28147_89_MAC "GOST 28147-89 MAC" -#define NID_id_Gost28147_89_MAC 815 -#define OBJ_id_Gost28147_89_MAC OBJ_cryptopro,22L - -#define SN_id_GostR3411_94_prf "prf-gostr3411-94" -#define LN_id_GostR3411_94_prf "GOST R 34.11-94 PRF" -#define NID_id_GostR3411_94_prf 816 -#define OBJ_id_GostR3411_94_prf OBJ_cryptopro,23L - -#define SN_id_GostR3410_2001DH "id-GostR3410-2001DH" -#define LN_id_GostR3410_2001DH "GOST R 34.10-2001 DH" -#define NID_id_GostR3410_2001DH 817 -#define OBJ_id_GostR3410_2001DH OBJ_cryptopro,98L - -#define SN_id_GostR3410_94DH "id-GostR3410-94DH" -#define LN_id_GostR3410_94DH "GOST R 34.10-94 DH" -#define NID_id_GostR3410_94DH 818 -#define OBJ_id_GostR3410_94DH OBJ_cryptopro,99L - -#define SN_id_Gost28147_89_CryptoPro_KeyMeshing "id-Gost28147-89-CryptoPro-KeyMeshing" -#define NID_id_Gost28147_89_CryptoPro_KeyMeshing 819 -#define OBJ_id_Gost28147_89_CryptoPro_KeyMeshing OBJ_cryptopro,14L,1L - -#define SN_id_Gost28147_89_None_KeyMeshing "id-Gost28147-89-None-KeyMeshing" -#define NID_id_Gost28147_89_None_KeyMeshing 820 -#define OBJ_id_Gost28147_89_None_KeyMeshing OBJ_cryptopro,14L,0L - -#define SN_id_GostR3411_94_TestParamSet "id-GostR3411-94-TestParamSet" -#define NID_id_GostR3411_94_TestParamSet 821 -#define OBJ_id_GostR3411_94_TestParamSet OBJ_cryptopro,30L,0L - -#define SN_id_GostR3411_94_CryptoProParamSet "id-GostR3411-94-CryptoProParamSet" -#define NID_id_GostR3411_94_CryptoProParamSet 822 -#define OBJ_id_GostR3411_94_CryptoProParamSet OBJ_cryptopro,30L,1L - -#define SN_id_Gost28147_89_TestParamSet "id-Gost28147-89-TestParamSet" -#define NID_id_Gost28147_89_TestParamSet 823 -#define OBJ_id_Gost28147_89_TestParamSet OBJ_cryptopro,31L,0L - -#define SN_id_Gost28147_89_CryptoPro_A_ParamSet "id-Gost28147-89-CryptoPro-A-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_A_ParamSet 824 -#define OBJ_id_Gost28147_89_CryptoPro_A_ParamSet OBJ_cryptopro,31L,1L - -#define SN_id_Gost28147_89_CryptoPro_B_ParamSet "id-Gost28147-89-CryptoPro-B-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_B_ParamSet 825 -#define OBJ_id_Gost28147_89_CryptoPro_B_ParamSet OBJ_cryptopro,31L,2L - -#define SN_id_Gost28147_89_CryptoPro_C_ParamSet "id-Gost28147-89-CryptoPro-C-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_C_ParamSet 826 -#define OBJ_id_Gost28147_89_CryptoPro_C_ParamSet OBJ_cryptopro,31L,3L - -#define SN_id_Gost28147_89_CryptoPro_D_ParamSet "id-Gost28147-89-CryptoPro-D-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_D_ParamSet 827 -#define OBJ_id_Gost28147_89_CryptoPro_D_ParamSet OBJ_cryptopro,31L,4L - -#define SN_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet "id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet 828 -#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet OBJ_cryptopro,31L,5L - -#define SN_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet "id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet 829 -#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet OBJ_cryptopro,31L,6L - -#define SN_id_Gost28147_89_CryptoPro_RIC_1_ParamSet "id-Gost28147-89-CryptoPro-RIC-1-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_RIC_1_ParamSet 830 -#define OBJ_id_Gost28147_89_CryptoPro_RIC_1_ParamSet OBJ_cryptopro,31L,7L - -#define SN_id_GostR3410_94_TestParamSet "id-GostR3410-94-TestParamSet" -#define NID_id_GostR3410_94_TestParamSet 831 -#define OBJ_id_GostR3410_94_TestParamSet OBJ_cryptopro,32L,0L - -#define SN_id_GostR3410_94_CryptoPro_A_ParamSet "id-GostR3410-94-CryptoPro-A-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_A_ParamSet 832 -#define OBJ_id_GostR3410_94_CryptoPro_A_ParamSet OBJ_cryptopro,32L,2L - -#define SN_id_GostR3410_94_CryptoPro_B_ParamSet "id-GostR3410-94-CryptoPro-B-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_B_ParamSet 833 -#define OBJ_id_GostR3410_94_CryptoPro_B_ParamSet OBJ_cryptopro,32L,3L - -#define SN_id_GostR3410_94_CryptoPro_C_ParamSet "id-GostR3410-94-CryptoPro-C-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_C_ParamSet 834 -#define OBJ_id_GostR3410_94_CryptoPro_C_ParamSet OBJ_cryptopro,32L,4L - -#define SN_id_GostR3410_94_CryptoPro_D_ParamSet "id-GostR3410-94-CryptoPro-D-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_D_ParamSet 835 -#define OBJ_id_GostR3410_94_CryptoPro_D_ParamSet OBJ_cryptopro,32L,5L - -#define SN_id_GostR3410_94_CryptoPro_XchA_ParamSet "id-GostR3410-94-CryptoPro-XchA-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_XchA_ParamSet 836 -#define OBJ_id_GostR3410_94_CryptoPro_XchA_ParamSet OBJ_cryptopro,33L,1L - -#define SN_id_GostR3410_94_CryptoPro_XchB_ParamSet "id-GostR3410-94-CryptoPro-XchB-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_XchB_ParamSet 837 -#define OBJ_id_GostR3410_94_CryptoPro_XchB_ParamSet OBJ_cryptopro,33L,2L - -#define SN_id_GostR3410_94_CryptoPro_XchC_ParamSet "id-GostR3410-94-CryptoPro-XchC-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_XchC_ParamSet 838 -#define OBJ_id_GostR3410_94_CryptoPro_XchC_ParamSet OBJ_cryptopro,33L,3L - -#define SN_id_GostR3410_2001_TestParamSet "id-GostR3410-2001-TestParamSet" -#define NID_id_GostR3410_2001_TestParamSet 839 -#define OBJ_id_GostR3410_2001_TestParamSet OBJ_cryptopro,35L,0L - -#define SN_id_GostR3410_2001_CryptoPro_A_ParamSet "id-GostR3410-2001-CryptoPro-A-ParamSet" -#define NID_id_GostR3410_2001_CryptoPro_A_ParamSet 840 -#define OBJ_id_GostR3410_2001_CryptoPro_A_ParamSet OBJ_cryptopro,35L,1L - -#define SN_id_GostR3410_2001_CryptoPro_B_ParamSet "id-GostR3410-2001-CryptoPro-B-ParamSet" -#define NID_id_GostR3410_2001_CryptoPro_B_ParamSet 841 -#define OBJ_id_GostR3410_2001_CryptoPro_B_ParamSet OBJ_cryptopro,35L,2L - -#define SN_id_GostR3410_2001_CryptoPro_C_ParamSet "id-GostR3410-2001-CryptoPro-C-ParamSet" -#define NID_id_GostR3410_2001_CryptoPro_C_ParamSet 842 -#define OBJ_id_GostR3410_2001_CryptoPro_C_ParamSet OBJ_cryptopro,35L,3L - -#define SN_id_GostR3410_2001_CryptoPro_XchA_ParamSet "id-GostR3410-2001-CryptoPro-XchA-ParamSet" -#define NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet 843 -#define OBJ_id_GostR3410_2001_CryptoPro_XchA_ParamSet OBJ_cryptopro,36L,0L - -#define SN_id_GostR3410_2001_CryptoPro_XchB_ParamSet "id-GostR3410-2001-CryptoPro-XchB-ParamSet" -#define NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet 844 -#define OBJ_id_GostR3410_2001_CryptoPro_XchB_ParamSet OBJ_cryptopro,36L,1L - -#define SN_id_GostR3410_94_a "id-GostR3410-94-a" -#define NID_id_GostR3410_94_a 845 -#define OBJ_id_GostR3410_94_a OBJ_id_GostR3410_94,1L - -#define SN_id_GostR3410_94_aBis "id-GostR3410-94-aBis" -#define NID_id_GostR3410_94_aBis 846 -#define OBJ_id_GostR3410_94_aBis OBJ_id_GostR3410_94,2L - -#define SN_id_GostR3410_94_b "id-GostR3410-94-b" -#define NID_id_GostR3410_94_b 847 -#define OBJ_id_GostR3410_94_b OBJ_id_GostR3410_94,3L - -#define SN_id_GostR3410_94_bBis "id-GostR3410-94-bBis" -#define NID_id_GostR3410_94_bBis 848 -#define OBJ_id_GostR3410_94_bBis OBJ_id_GostR3410_94,4L - -#define SN_id_Gost28147_89_cc "id-Gost28147-89-cc" -#define LN_id_Gost28147_89_cc "GOST 28147-89 Cryptocom ParamSet" -#define NID_id_Gost28147_89_cc 849 -#define OBJ_id_Gost28147_89_cc OBJ_cryptocom,1L,6L,1L - -#define SN_id_GostR3410_94_cc "gost94cc" -#define LN_id_GostR3410_94_cc "GOST 34.10-94 Cryptocom" -#define NID_id_GostR3410_94_cc 850 -#define OBJ_id_GostR3410_94_cc OBJ_cryptocom,1L,5L,3L - -#define SN_id_GostR3410_2001_cc "gost2001cc" -#define LN_id_GostR3410_2001_cc "GOST 34.10-2001 Cryptocom" -#define NID_id_GostR3410_2001_cc 851 -#define OBJ_id_GostR3410_2001_cc OBJ_cryptocom,1L,5L,4L - -#define SN_id_GostR3411_94_with_GostR3410_94_cc "id-GostR3411-94-with-GostR3410-94-cc" -#define LN_id_GostR3411_94_with_GostR3410_94_cc "GOST R 34.11-94 with GOST R 34.10-94 Cryptocom" -#define NID_id_GostR3411_94_with_GostR3410_94_cc 852 -#define OBJ_id_GostR3411_94_with_GostR3410_94_cc OBJ_cryptocom,1L,3L,3L - -#define SN_id_GostR3411_94_with_GostR3410_2001_cc "id-GostR3411-94-with-GostR3410-2001-cc" -#define LN_id_GostR3411_94_with_GostR3410_2001_cc "GOST R 34.11-94 with GOST R 34.10-2001 Cryptocom" -#define NID_id_GostR3411_94_with_GostR3410_2001_cc 853 -#define OBJ_id_GostR3411_94_with_GostR3410_2001_cc OBJ_cryptocom,1L,3L,4L - -#define SN_id_GostR3410_2001_ParamSet_cc "id-GostR3410-2001-ParamSet-cc" -#define LN_id_GostR3410_2001_ParamSet_cc "GOST R 3410-2001 Parameter Set Cryptocom" -#define NID_id_GostR3410_2001_ParamSet_cc 854 -#define OBJ_id_GostR3410_2001_ParamSet_cc OBJ_cryptocom,1L,8L,1L - -#define SN_camellia_128_cbc "CAMELLIA-128-CBC" -#define LN_camellia_128_cbc "camellia-128-cbc" -#define NID_camellia_128_cbc 751 -#define OBJ_camellia_128_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,2L - -#define SN_camellia_192_cbc "CAMELLIA-192-CBC" -#define LN_camellia_192_cbc "camellia-192-cbc" -#define NID_camellia_192_cbc 752 -#define OBJ_camellia_192_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,3L - -#define SN_camellia_256_cbc "CAMELLIA-256-CBC" -#define LN_camellia_256_cbc "camellia-256-cbc" -#define NID_camellia_256_cbc 753 -#define OBJ_camellia_256_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,4L - -#define SN_id_camellia128_wrap "id-camellia128-wrap" -#define NID_id_camellia128_wrap 907 -#define OBJ_id_camellia128_wrap 1L,2L,392L,200011L,61L,1L,1L,3L,2L - -#define SN_id_camellia192_wrap "id-camellia192-wrap" -#define NID_id_camellia192_wrap 908 -#define OBJ_id_camellia192_wrap 1L,2L,392L,200011L,61L,1L,1L,3L,3L - -#define SN_id_camellia256_wrap "id-camellia256-wrap" -#define NID_id_camellia256_wrap 909 -#define OBJ_id_camellia256_wrap 1L,2L,392L,200011L,61L,1L,1L,3L,4L - -#define OBJ_ntt_ds 0L,3L,4401L,5L - -#define OBJ_camellia OBJ_ntt_ds,3L,1L,9L - -#define SN_camellia_128_ecb "CAMELLIA-128-ECB" -#define LN_camellia_128_ecb "camellia-128-ecb" -#define NID_camellia_128_ecb 754 -#define OBJ_camellia_128_ecb OBJ_camellia,1L - -#define SN_camellia_128_ofb128 "CAMELLIA-128-OFB" -#define LN_camellia_128_ofb128 "camellia-128-ofb" -#define NID_camellia_128_ofb128 766 -#define OBJ_camellia_128_ofb128 OBJ_camellia,3L - -#define SN_camellia_128_cfb128 "CAMELLIA-128-CFB" -#define LN_camellia_128_cfb128 "camellia-128-cfb" -#define NID_camellia_128_cfb128 757 -#define OBJ_camellia_128_cfb128 OBJ_camellia,4L - -#define SN_camellia_192_ecb "CAMELLIA-192-ECB" -#define LN_camellia_192_ecb "camellia-192-ecb" -#define NID_camellia_192_ecb 755 -#define OBJ_camellia_192_ecb OBJ_camellia,21L - -#define SN_camellia_192_ofb128 "CAMELLIA-192-OFB" -#define LN_camellia_192_ofb128 "camellia-192-ofb" -#define NID_camellia_192_ofb128 767 -#define OBJ_camellia_192_ofb128 OBJ_camellia,23L - -#define SN_camellia_192_cfb128 "CAMELLIA-192-CFB" -#define LN_camellia_192_cfb128 "camellia-192-cfb" -#define NID_camellia_192_cfb128 758 -#define OBJ_camellia_192_cfb128 OBJ_camellia,24L - -#define SN_camellia_256_ecb "CAMELLIA-256-ECB" -#define LN_camellia_256_ecb "camellia-256-ecb" -#define NID_camellia_256_ecb 756 -#define OBJ_camellia_256_ecb OBJ_camellia,41L - -#define SN_camellia_256_ofb128 "CAMELLIA-256-OFB" -#define LN_camellia_256_ofb128 "camellia-256-ofb" -#define NID_camellia_256_ofb128 768 -#define OBJ_camellia_256_ofb128 OBJ_camellia,43L - -#define SN_camellia_256_cfb128 "CAMELLIA-256-CFB" -#define LN_camellia_256_cfb128 "camellia-256-cfb" -#define NID_camellia_256_cfb128 759 -#define OBJ_camellia_256_cfb128 OBJ_camellia,44L - -#define SN_camellia_128_cfb1 "CAMELLIA-128-CFB1" -#define LN_camellia_128_cfb1 "camellia-128-cfb1" -#define NID_camellia_128_cfb1 760 - -#define SN_camellia_192_cfb1 "CAMELLIA-192-CFB1" -#define LN_camellia_192_cfb1 "camellia-192-cfb1" -#define NID_camellia_192_cfb1 761 - -#define SN_camellia_256_cfb1 "CAMELLIA-256-CFB1" -#define LN_camellia_256_cfb1 "camellia-256-cfb1" -#define NID_camellia_256_cfb1 762 - -#define SN_camellia_128_cfb8 "CAMELLIA-128-CFB8" -#define LN_camellia_128_cfb8 "camellia-128-cfb8" -#define NID_camellia_128_cfb8 763 - -#define SN_camellia_192_cfb8 "CAMELLIA-192-CFB8" -#define LN_camellia_192_cfb8 "camellia-192-cfb8" -#define NID_camellia_192_cfb8 764 - -#define SN_camellia_256_cfb8 "CAMELLIA-256-CFB8" -#define LN_camellia_256_cfb8 "camellia-256-cfb8" -#define NID_camellia_256_cfb8 765 - -#define SN_kisa "KISA" -#define LN_kisa "kisa" -#define NID_kisa 773 -#define OBJ_kisa OBJ_member_body,410L,200004L - -#define SN_seed_ecb "SEED-ECB" -#define LN_seed_ecb "seed-ecb" -#define NID_seed_ecb 776 -#define OBJ_seed_ecb OBJ_kisa,1L,3L - -#define SN_seed_cbc "SEED-CBC" -#define LN_seed_cbc "seed-cbc" -#define NID_seed_cbc 777 -#define OBJ_seed_cbc OBJ_kisa,1L,4L - -#define SN_seed_cfb128 "SEED-CFB" -#define LN_seed_cfb128 "seed-cfb" -#define NID_seed_cfb128 779 -#define OBJ_seed_cfb128 OBJ_kisa,1L,5L - -#define SN_seed_ofb128 "SEED-OFB" -#define LN_seed_ofb128 "seed-ofb" -#define NID_seed_ofb128 778 -#define OBJ_seed_ofb128 OBJ_kisa,1L,6L - -#define SN_hmac "HMAC" -#define LN_hmac "hmac" -#define NID_hmac 855 - -#define SN_cmac "CMAC" -#define LN_cmac "cmac" -#define NID_cmac 894 - -#define SN_rc4_hmac_md5 "RC4-HMAC-MD5" -#define LN_rc4_hmac_md5 "rc4-hmac-md5" -#define NID_rc4_hmac_md5 915 - -#define SN_aes_128_cbc_hmac_sha1 "AES-128-CBC-HMAC-SHA1" -#define LN_aes_128_cbc_hmac_sha1 "aes-128-cbc-hmac-sha1" -#define NID_aes_128_cbc_hmac_sha1 916 - -#define SN_aes_192_cbc_hmac_sha1 "AES-192-CBC-HMAC-SHA1" -#define LN_aes_192_cbc_hmac_sha1 "aes-192-cbc-hmac-sha1" -#define NID_aes_192_cbc_hmac_sha1 917 - -#define SN_aes_256_cbc_hmac_sha1 "AES-256-CBC-HMAC-SHA1" -#define LN_aes_256_cbc_hmac_sha1 "aes-256-cbc-hmac-sha1" -#define NID_aes_256_cbc_hmac_sha1 918 - -#define SN_dhpublicnumber "dhpublicnumber" -#define LN_dhpublicnumber "X9.42 DH" -#define NID_dhpublicnumber 920 -#define OBJ_dhpublicnumber OBJ_ISO_US,10046L,2L,1L - -#define SN_brainpoolP160r1 "brainpoolP160r1" -#define NID_brainpoolP160r1 921 -#define OBJ_brainpoolP160r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,1L - -#define SN_brainpoolP160t1 "brainpoolP160t1" -#define NID_brainpoolP160t1 922 -#define OBJ_brainpoolP160t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,2L - -#define SN_brainpoolP192r1 "brainpoolP192r1" -#define NID_brainpoolP192r1 923 -#define OBJ_brainpoolP192r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,3L - -#define SN_brainpoolP192t1 "brainpoolP192t1" -#define NID_brainpoolP192t1 924 -#define OBJ_brainpoolP192t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,4L - -#define SN_brainpoolP224r1 "brainpoolP224r1" -#define NID_brainpoolP224r1 925 -#define OBJ_brainpoolP224r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,5L - -#define SN_brainpoolP224t1 "brainpoolP224t1" -#define NID_brainpoolP224t1 926 -#define OBJ_brainpoolP224t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,6L - -#define SN_brainpoolP256r1 "brainpoolP256r1" -#define NID_brainpoolP256r1 927 -#define OBJ_brainpoolP256r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,7L - -#define SN_brainpoolP256t1 "brainpoolP256t1" -#define NID_brainpoolP256t1 928 -#define OBJ_brainpoolP256t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,8L - -#define SN_brainpoolP320r1 "brainpoolP320r1" -#define NID_brainpoolP320r1 929 -#define OBJ_brainpoolP320r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,9L - -#define SN_brainpoolP320t1 "brainpoolP320t1" -#define NID_brainpoolP320t1 930 -#define OBJ_brainpoolP320t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,10L - -#define SN_brainpoolP384r1 "brainpoolP384r1" -#define NID_brainpoolP384r1 931 -#define OBJ_brainpoolP384r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,11L - -#define SN_brainpoolP384t1 "brainpoolP384t1" -#define NID_brainpoolP384t1 932 -#define OBJ_brainpoolP384t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,12L - -#define SN_brainpoolP512r1 "brainpoolP512r1" -#define NID_brainpoolP512r1 933 -#define OBJ_brainpoolP512r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,13L - -#define SN_brainpoolP512t1 "brainpoolP512t1" -#define NID_brainpoolP512t1 934 -#define OBJ_brainpoolP512t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,14L - -#define OBJ_x9_63_scheme 1L,3L,133L,16L,840L,63L,0L - -#define OBJ_secg_scheme OBJ_certicom_arc,1L - -#define SN_dhSinglePass_stdDH_sha1kdf_scheme "dhSinglePass-stdDH-sha1kdf-scheme" -#define NID_dhSinglePass_stdDH_sha1kdf_scheme 936 -#define OBJ_dhSinglePass_stdDH_sha1kdf_scheme OBJ_x9_63_scheme,2L - -#define SN_dhSinglePass_stdDH_sha224kdf_scheme "dhSinglePass-stdDH-sha224kdf-scheme" -#define NID_dhSinglePass_stdDH_sha224kdf_scheme 937 -#define OBJ_dhSinglePass_stdDH_sha224kdf_scheme OBJ_secg_scheme,11L,0L - -#define SN_dhSinglePass_stdDH_sha256kdf_scheme "dhSinglePass-stdDH-sha256kdf-scheme" -#define NID_dhSinglePass_stdDH_sha256kdf_scheme 938 -#define OBJ_dhSinglePass_stdDH_sha256kdf_scheme OBJ_secg_scheme,11L,1L - -#define SN_dhSinglePass_stdDH_sha384kdf_scheme "dhSinglePass-stdDH-sha384kdf-scheme" -#define NID_dhSinglePass_stdDH_sha384kdf_scheme 939 -#define OBJ_dhSinglePass_stdDH_sha384kdf_scheme OBJ_secg_scheme,11L,2L - -#define SN_dhSinglePass_stdDH_sha512kdf_scheme "dhSinglePass-stdDH-sha512kdf-scheme" -#define NID_dhSinglePass_stdDH_sha512kdf_scheme 940 -#define OBJ_dhSinglePass_stdDH_sha512kdf_scheme OBJ_secg_scheme,11L,3L - -#define SN_dhSinglePass_cofactorDH_sha1kdf_scheme "dhSinglePass-cofactorDH-sha1kdf-scheme" -#define NID_dhSinglePass_cofactorDH_sha1kdf_scheme 941 -#define OBJ_dhSinglePass_cofactorDH_sha1kdf_scheme OBJ_x9_63_scheme,3L - -#define SN_dhSinglePass_cofactorDH_sha224kdf_scheme "dhSinglePass-cofactorDH-sha224kdf-scheme" -#define NID_dhSinglePass_cofactorDH_sha224kdf_scheme 942 -#define OBJ_dhSinglePass_cofactorDH_sha224kdf_scheme OBJ_secg_scheme,14L,0L - -#define SN_dhSinglePass_cofactorDH_sha256kdf_scheme "dhSinglePass-cofactorDH-sha256kdf-scheme" -#define NID_dhSinglePass_cofactorDH_sha256kdf_scheme 943 -#define OBJ_dhSinglePass_cofactorDH_sha256kdf_scheme OBJ_secg_scheme,14L,1L - -#define SN_dhSinglePass_cofactorDH_sha384kdf_scheme "dhSinglePass-cofactorDH-sha384kdf-scheme" -#define NID_dhSinglePass_cofactorDH_sha384kdf_scheme 944 -#define OBJ_dhSinglePass_cofactorDH_sha384kdf_scheme OBJ_secg_scheme,14L,2L - -#define SN_dhSinglePass_cofactorDH_sha512kdf_scheme "dhSinglePass-cofactorDH-sha512kdf-scheme" -#define NID_dhSinglePass_cofactorDH_sha512kdf_scheme 945 -#define OBJ_dhSinglePass_cofactorDH_sha512kdf_scheme OBJ_secg_scheme,14L,3L - -#define SN_dh_std_kdf "dh-std-kdf" -#define NID_dh_std_kdf 946 - -#define SN_dh_cofactor_kdf "dh-cofactor-kdf" -#define NID_dh_cofactor_kdf 947 - diff --git a/phonelibs/boringssl/include/openssl/objects.h b/phonelibs/boringssl/include/openssl/objects.h deleted file mode 100644 index dd6556f26489c5..00000000000000 --- a/phonelibs/boringssl/include/openssl/objects.h +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright (c) 2014, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -/* This header is provided in order to make compiling against code that expects - OpenSSL easier. */ - -#include "obj.h" diff --git a/phonelibs/boringssl/include/openssl/opensslfeatures.h b/phonelibs/boringssl/include/openssl/opensslfeatures.h deleted file mode 100644 index c3f97d5a48e620..00000000000000 --- a/phonelibs/boringssl/include/openssl/opensslfeatures.h +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (c) 2014, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -/* This header is provided in order to make compiling against code that expects - OpenSSL easier. */ - -#ifndef OPENSSL_HEADER_OPENSSLFEATURES_H -#define OPENSSL_HEADER_OPENSSLFEATURES_H - - -#define OPENSSL_NO_BF -#define OPENSSL_NO_BUF_FREELISTS -#define OPENSSL_NO_CAMELLIA -#define OPENSSL_NO_CAPIENG -#define OPENSSL_NO_CAST -#define OPENSSL_NO_CMS -#define OPENSSL_NO_COMP -#define OPENSSL_NO_DANE -#define OPENSSL_NO_DEPRECATED -#define OPENSSL_NO_DYNAMIC_ENGINE -#define OPENSSL_NO_EC_NISTP_64_GCC_128 -#define OPENSSL_NO_EC2M -#define OPENSSL_NO_ENGINE -#define OPENSSL_NO_GMP -#define OPENSSL_NO_GOST -#define OPENSSL_NO_HEARTBEATS -#define OPENSSL_NO_HW -#define OPENSSL_NO_IDEA -#define OPENSSL_NO_JPAKE -#define OPENSSL_NO_KRB5 -#define OPENSSL_NO_MD2 -#define OPENSSL_NO_MDC2 -#define OPENSSL_NO_OCB -#define OPENSSL_NO_OCSP -#define OPENSSL_NO_RC2 -#define OPENSSL_NO_RC5 -#define OPENSSL_NO_RFC3779 -#define OPENSSL_NO_RIPEMD -#define OPENSSL_NO_RMD160 -#define OPENSSL_NO_SCTP -#define OPENSSL_NO_SEED -#define OPENSSL_NO_SRP -#define OPENSSL_NO_SSL2 -#define OPENSSL_NO_STATIC_ENGINE -#define OPENSSL_NO_STORE -#define OPENSSL_NO_WHIRLPOOL - - -#endif /* OPENSSL_HEADER_OPENSSLFEATURES_H */ diff --git a/phonelibs/boringssl/include/openssl/opensslv.h b/phonelibs/boringssl/include/openssl/opensslv.h deleted file mode 100644 index a3555d4f8b0027..00000000000000 --- a/phonelibs/boringssl/include/openssl/opensslv.h +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright (c) 2014, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -/* This header is provided in order to make compiling against code that expects - OpenSSL easier. */ - -#include "crypto.h" diff --git a/phonelibs/boringssl/include/openssl/ossl_typ.h b/phonelibs/boringssl/include/openssl/ossl_typ.h deleted file mode 100644 index c2b3fe7c500965..00000000000000 --- a/phonelibs/boringssl/include/openssl/ossl_typ.h +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright (c) 2014, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -/* This header is provided in order to make compiling against code that expects - OpenSSL easier. */ - -#include "base.h" diff --git a/phonelibs/boringssl/include/openssl/pem.h b/phonelibs/boringssl/include/openssl/pem.h deleted file mode 100644 index 7756e45ed3e73c..00000000000000 --- a/phonelibs/boringssl/include/openssl/pem.h +++ /dev/null @@ -1,545 +0,0 @@ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_PEM_H -#define OPENSSL_HEADER_PEM_H - -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -#define PEM_BUFSIZE 1024 - -#define PEM_OBJ_UNDEF 0 -#define PEM_OBJ_X509 1 -#define PEM_OBJ_X509_REQ 2 -#define PEM_OBJ_CRL 3 -#define PEM_OBJ_SSL_SESSION 4 -#define PEM_OBJ_PRIV_KEY 10 -#define PEM_OBJ_PRIV_RSA 11 -#define PEM_OBJ_PRIV_DSA 12 -#define PEM_OBJ_PRIV_DH 13 -#define PEM_OBJ_PUB_RSA 14 -#define PEM_OBJ_PUB_DSA 15 -#define PEM_OBJ_PUB_DH 16 -#define PEM_OBJ_DHPARAMS 17 -#define PEM_OBJ_DSAPARAMS 18 -#define PEM_OBJ_PRIV_RSA_PUBLIC 19 -#define PEM_OBJ_PRIV_ECDSA 20 -#define PEM_OBJ_PUB_ECDSA 21 -#define PEM_OBJ_ECPARAMETERS 22 - -#define PEM_ERROR 30 -#define PEM_DEK_DES_CBC 40 -#define PEM_DEK_IDEA_CBC 45 -#define PEM_DEK_DES_EDE 50 -#define PEM_DEK_DES_ECB 60 -#define PEM_DEK_RSA 70 -#define PEM_DEK_RSA_MD2 80 -#define PEM_DEK_RSA_MD5 90 - -#define PEM_MD_MD2 NID_md2 -#define PEM_MD_MD5 NID_md5 -#define PEM_MD_SHA NID_sha -#define PEM_MD_MD2_RSA NID_md2WithRSAEncryption -#define PEM_MD_MD5_RSA NID_md5WithRSAEncryption -#define PEM_MD_SHA_RSA NID_sha1WithRSAEncryption - -#define PEM_STRING_X509_OLD "X509 CERTIFICATE" -#define PEM_STRING_X509 "CERTIFICATE" -#define PEM_STRING_X509_PAIR "CERTIFICATE PAIR" -#define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE" -#define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST" -#define PEM_STRING_X509_REQ "CERTIFICATE REQUEST" -#define PEM_STRING_X509_CRL "X509 CRL" -#define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY" -#define PEM_STRING_PUBLIC "PUBLIC KEY" -#define PEM_STRING_RSA "RSA PRIVATE KEY" -#define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY" -#define PEM_STRING_DSA "DSA PRIVATE KEY" -#define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY" -#define PEM_STRING_PKCS7 "PKCS7" -#define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA" -#define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY" -#define PEM_STRING_PKCS8INF "PRIVATE KEY" -#define PEM_STRING_DHPARAMS "DH PARAMETERS" -#define PEM_STRING_DHXPARAMS "X9.42 DH PARAMETERS" -#define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS" -#define PEM_STRING_DSAPARAMS "DSA PARAMETERS" -#define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY" -#define PEM_STRING_ECPARAMETERS "EC PARAMETERS" -#define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY" -#define PEM_STRING_PARAMETERS "PARAMETERS" -#define PEM_STRING_CMS "CMS" - - /* Note that this structure is initialised by PEM_SealInit and cleaned up - by PEM_SealFinal (at least for now) */ -typedef struct PEM_Encode_Seal_st - { - EVP_ENCODE_CTX encode; - EVP_MD_CTX md; - EVP_CIPHER_CTX cipher; - } PEM_ENCODE_SEAL_CTX; - -/* enc_type is one off */ -#define PEM_TYPE_ENCRYPTED 10 -#define PEM_TYPE_MIC_ONLY 20 -#define PEM_TYPE_MIC_CLEAR 30 -#define PEM_TYPE_CLEAR 40 - -typedef struct pem_recip_st - { - char *name; - X509_NAME *dn; - - int cipher; - int key_enc; - /* char iv[8]; unused and wrong size */ - } PEM_USER; - -typedef struct pem_ctx_st - { - int type; /* what type of object */ - - struct { - int version; - int mode; - } proc_type; - - char *domain; - - struct { - int cipher; - /* unused, and wrong size - unsigned char iv[8]; */ - } DEK_info; - - PEM_USER *originator; - - int num_recipient; - PEM_USER **recipient; - - EVP_MD *md; /* signature type */ - - int md_enc; /* is the md encrypted or not? */ - int md_len; /* length of md_data */ - char *md_data; /* message digest, could be pkey encrypted */ - - EVP_CIPHER *dec; /* date encryption cipher */ - int key_len; /* key length */ - unsigned char *key; /* key */ - /* unused, and wrong size - unsigned char iv[8]; */ - - - int data_enc; /* is the data encrypted */ - int data_len; - unsigned char *data; - } PEM_CTX; - -/* These macros make the PEM_read/PEM_write functions easier to maintain and - * write. Now they are all implemented with either: - * IMPLEMENT_PEM_rw(...) or IMPLEMENT_PEM_rw_cb(...) - */ - -#ifdef OPENSSL_NO_FP_API - -#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/ -#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/ -#define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/ -#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/ -#define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/ - -#else - -#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \ -OPENSSL_EXPORT type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\ -{ \ -return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \ -} - -#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \ -OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x) \ -{ \ -return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \ -} - -#define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \ -OPENSSL_EXPORT int PEM_write_##name(FILE *fp, const type *x) \ -{ \ -return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \ -} - -#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \ -OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, \ - void *u) \ - { \ - return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \ - } - -#define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \ -OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, \ - void *u) \ - { \ - return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \ - } - -#endif - -#define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ -OPENSSL_EXPORT type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\ -{ \ -return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \ -} - -#define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ -OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x) \ -{ \ -return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \ -} - -#define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ -OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, const type *x) \ -{ \ -return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \ -} - -#define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ -OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ - { \ - return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \ - } - -#define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ -OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ - { \ - return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \ - } - -#define IMPLEMENT_PEM_write(name, type, str, asn1) \ - IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ - IMPLEMENT_PEM_write_fp(name, type, str, asn1) - -#define IMPLEMENT_PEM_write_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) - -#define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) - -#define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) - -#define IMPLEMENT_PEM_read(name, type, str, asn1) \ - IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ - IMPLEMENT_PEM_read_fp(name, type, str, asn1) - -#define IMPLEMENT_PEM_rw(name, type, str, asn1) \ - IMPLEMENT_PEM_read(name, type, str, asn1) \ - IMPLEMENT_PEM_write(name, type, str, asn1) - -#define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \ - IMPLEMENT_PEM_read(name, type, str, asn1) \ - IMPLEMENT_PEM_write_const(name, type, str, asn1) - -#define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \ - IMPLEMENT_PEM_read(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb(name, type, str, asn1) - -/* These are the same except they are for the declarations */ - -#if defined(OPENSSL_NO_FP_API) - -#define DECLARE_PEM_read_fp(name, type) /**/ -#define DECLARE_PEM_write_fp(name, type) /**/ -#define DECLARE_PEM_write_cb_fp(name, type) /**/ - -#else - -#define DECLARE_PEM_read_fp(name, type) \ - OPENSSL_EXPORT type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u); - -#define DECLARE_PEM_write_fp(name, type) \ - OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x); - -#define DECLARE_PEM_write_fp_const(name, type) \ - OPENSSL_EXPORT int PEM_write_##name(FILE *fp, const type *x); - -#define DECLARE_PEM_write_cb_fp(name, type) \ - OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, void *u); - -#endif - -#define DECLARE_PEM_read_bio(name, type) \ - OPENSSL_EXPORT type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u); - -#define DECLARE_PEM_write_bio(name, type) \ - OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x); - -#define DECLARE_PEM_write_bio_const(name, type) \ - OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, const type *x); - -#define DECLARE_PEM_write_cb_bio(name, type) \ - OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, void *u); - - -#define DECLARE_PEM_write(name, type) \ - DECLARE_PEM_write_bio(name, type) \ - DECLARE_PEM_write_fp(name, type) - -#define DECLARE_PEM_write_const(name, type) \ - DECLARE_PEM_write_bio_const(name, type) \ - DECLARE_PEM_write_fp_const(name, type) - -#define DECLARE_PEM_write_cb(name, type) \ - DECLARE_PEM_write_cb_bio(name, type) \ - DECLARE_PEM_write_cb_fp(name, type) - -#define DECLARE_PEM_read(name, type) \ - DECLARE_PEM_read_bio(name, type) \ - DECLARE_PEM_read_fp(name, type) - -#define DECLARE_PEM_rw(name, type) \ - DECLARE_PEM_read(name, type) \ - DECLARE_PEM_write(name, type) - -#define DECLARE_PEM_rw_const(name, type) \ - DECLARE_PEM_read(name, type) \ - DECLARE_PEM_write_const(name, type) - -#define DECLARE_PEM_rw_cb(name, type) \ - DECLARE_PEM_read(name, type) \ - DECLARE_PEM_write_cb(name, type) - -/* "userdata": new with OpenSSL 0.9.4 */ -typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata); - -OPENSSL_EXPORT int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher); -OPENSSL_EXPORT int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len, pem_password_cb *callback,void *u); - -OPENSSL_EXPORT int PEM_read_bio(BIO *bp, char **name, char **header, unsigned char **data,long *len); -OPENSSL_EXPORT int PEM_write_bio(BIO *bp,const char *name, const char *hdr, const unsigned char *data, long len); -OPENSSL_EXPORT int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp, pem_password_cb *cb, void *u); -OPENSSL_EXPORT void * PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x, pem_password_cb *cb, void *u); -OPENSSL_EXPORT int PEM_ASN1_write_bio(i2d_of_void *i2d,const char *name,BIO *bp, void *x, const EVP_CIPHER *enc,unsigned char *kstr,int klen, pem_password_cb *cb, void *u); - -OPENSSL_EXPORT STACK_OF(X509_INFO) * PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u); -OPENSSL_EXPORT int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cd, void *u); - -OPENSSL_EXPORT int PEM_read(FILE *fp, char **name, char **header, unsigned char **data,long *len); -OPENSSL_EXPORT int PEM_write(FILE *fp, const char *name, const char *hdr, const unsigned char *data, long len); -OPENSSL_EXPORT void * PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, pem_password_cb *cb, void *u); -OPENSSL_EXPORT int PEM_ASN1_write(i2d_of_void *i2d,const char *name,FILE *fp, void *x,const EVP_CIPHER *enc,unsigned char *kstr, int klen,pem_password_cb *callback, void *u); -OPENSSL_EXPORT STACK_OF(X509_INFO) * PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u); - -OPENSSL_EXPORT int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, EVP_MD *md_type, unsigned char **ek, int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk); -OPENSSL_EXPORT void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl, unsigned char *in, int inl); -OPENSSL_EXPORT int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl, unsigned char *out, int *outl, EVP_PKEY *priv); - -OPENSSL_EXPORT void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type); -OPENSSL_EXPORT void PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt); -OPENSSL_EXPORT int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen, EVP_PKEY *pkey); - -/* |PEM_def_callback| treats |userdata| as a string and copies it into |buf|, - * assuming its |size| is sufficient. Returns the length of the string, or 0 - * if there is not enough room. If either |buf| or |userdata| is NULL, 0 is - * returned. Note that this is different from OpenSSL, which prompts for a - * password. */ -OPENSSL_EXPORT int PEM_def_callback(char *buf, int size, int rwflag, void *userdata); -OPENSSL_EXPORT void PEM_proc_type(char *buf, int type); -OPENSSL_EXPORT void PEM_dek_info(char *buf, const char *type, int len, char *str); - - -DECLARE_PEM_rw(X509, X509) - -DECLARE_PEM_rw(X509_AUX, X509) - -DECLARE_PEM_rw(X509_CERT_PAIR, X509_CERT_PAIR) - -DECLARE_PEM_rw(X509_REQ, X509_REQ) -DECLARE_PEM_write(X509_REQ_NEW, X509_REQ) - -DECLARE_PEM_rw(X509_CRL, X509_CRL) - -/* DECLARE_PEM_rw(PKCS7, PKCS7) */ - -DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE) - -DECLARE_PEM_rw(PKCS8, X509_SIG) - -DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO) - -DECLARE_PEM_rw_cb(RSAPrivateKey, RSA) - -DECLARE_PEM_rw_const(RSAPublicKey, RSA) -DECLARE_PEM_rw(RSA_PUBKEY, RSA) - -#ifndef OPENSSL_NO_DSA - -DECLARE_PEM_rw_cb(DSAPrivateKey, DSA) - -DECLARE_PEM_rw(DSA_PUBKEY, DSA) - -DECLARE_PEM_rw_const(DSAparams, DSA) - -#endif - -DECLARE_PEM_rw_const(ECPKParameters, EC_GROUP) -DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY) -DECLARE_PEM_rw(EC_PUBKEY, EC_KEY) - - -DECLARE_PEM_rw_const(DHparams, DH) -DECLARE_PEM_write_const(DHxparams, DH) - - -DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY) - -DECLARE_PEM_rw(PUBKEY, EVP_PKEY) - -OPENSSL_EXPORT int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u); -OPENSSL_EXPORT int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *, char *, int, pem_password_cb *, void *); -OPENSSL_EXPORT int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u); -OPENSSL_EXPORT int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u); -OPENSSL_EXPORT EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u); - -OPENSSL_EXPORT int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u); -OPENSSL_EXPORT int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u); -OPENSSL_EXPORT int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u); - -OPENSSL_EXPORT EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u); - -OPENSSL_EXPORT int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc, char *kstr,int klen, pem_password_cb *cd, void *u); - -OPENSSL_EXPORT EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x); -OPENSSL_EXPORT int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x); - - -OPENSSL_EXPORT EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length); -OPENSSL_EXPORT EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length); -OPENSSL_EXPORT EVP_PKEY *b2i_PrivateKey_bio(BIO *in); -OPENSSL_EXPORT EVP_PKEY *b2i_PublicKey_bio(BIO *in); -OPENSSL_EXPORT int i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk); -OPENSSL_EXPORT int i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk); -OPENSSL_EXPORT EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u); -OPENSSL_EXPORT int i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel, pem_password_cb *cb, void *u); - - -void ERR_load_PEM_strings(void); - - -#ifdef __cplusplus -} -#endif - -#define PEM_F_PEM_ASN1_read 100 -#define PEM_F_PEM_ASN1_read_bio 101 -#define PEM_F_PEM_ASN1_write 102 -#define PEM_F_PEM_ASN1_write_bio 103 -#define PEM_F_PEM_X509_INFO_read 104 -#define PEM_F_PEM_X509_INFO_read_bio 105 -#define PEM_F_PEM_X509_INFO_write_bio 106 -#define PEM_F_PEM_do_header 107 -#define PEM_F_PEM_get_EVP_CIPHER_INFO 108 -#define PEM_F_PEM_read 109 -#define PEM_F_PEM_read_DHparams 110 -#define PEM_F_PEM_read_PrivateKey 111 -#define PEM_F_PEM_read_bio 112 -#define PEM_F_PEM_read_bio_DHparams 113 -#define PEM_F_PEM_read_bio_Parameters 114 -#define PEM_F_PEM_read_bio_PrivateKey 115 -#define PEM_F_PEM_write 116 -#define PEM_F_PEM_write_PrivateKey 117 -#define PEM_F_PEM_write_bio 118 -#define PEM_F_d2i_PKCS8PrivateKey_bio 119 -#define PEM_F_d2i_PKCS8PrivateKey_fp 120 -#define PEM_F_do_pk8pkey 121 -#define PEM_F_do_pk8pkey_fp 122 -#define PEM_F_load_iv 123 -#define PEM_R_BAD_BASE64_DECODE 100 -#define PEM_R_BAD_DECRYPT 101 -#define PEM_R_BAD_END_LINE 102 -#define PEM_R_BAD_IV_CHARS 103 -#define PEM_R_BAD_PASSWORD_READ 104 -#define PEM_R_CIPHER_IS_NULL 105 -#define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 106 -#define PEM_R_NOT_DEK_INFO 107 -#define PEM_R_NOT_ENCRYPTED 108 -#define PEM_R_NOT_PROC_TYPE 109 -#define PEM_R_NO_START_LINE 110 -#define PEM_R_READ_KEY 111 -#define PEM_R_SHORT_HEADER 112 -#define PEM_R_UNSUPPORTED_CIPHER 113 -#define PEM_R_UNSUPPORTED_ENCRYPTION 114 - -#endif /* OPENSSL_HEADER_PEM_H */ diff --git a/phonelibs/boringssl/include/openssl/pkcs12.h b/phonelibs/boringssl/include/openssl/pkcs12.h deleted file mode 100644 index b5e951638275f8..00000000000000 --- a/phonelibs/boringssl/include/openssl/pkcs12.h +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright (c) 2014, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -/* This header is provided in order to make compiling against code that expects - OpenSSL easier. */ - -#include "pkcs8.h" diff --git a/phonelibs/boringssl/include/openssl/pkcs7.h b/phonelibs/boringssl/include/openssl/pkcs7.h deleted file mode 100644 index 6e5e433074f867..00000000000000 --- a/phonelibs/boringssl/include/openssl/pkcs7.h +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright (c) 2014, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -/* This header is provided in order to make compiling against code that expects - OpenSSL easier. */ diff --git a/phonelibs/boringssl/include/openssl/pkcs8.h b/phonelibs/boringssl/include/openssl/pkcs8.h deleted file mode 100644 index 8dc7731bf5f349..00000000000000 --- a/phonelibs/boringssl/include/openssl/pkcs8.h +++ /dev/null @@ -1,217 +0,0 @@ -/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL - * project 1999. - */ -/* ==================================================================== - * Copyright (c) 1999 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). */ - - -#ifndef OPENSSL_HEADER_PKCS8_H -#define OPENSSL_HEADER_PKCS8_H - -#include -#include - - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* PKCS8_encrypt_pbe serializes and encrypts a PKCS8_PRIV_KEY_INFO with PBES1 as - * defined in PKCS #5. Only pbeWithSHAAnd128BitRC4, - * pbeWithSHAAnd3-KeyTripleDES-CBC and pbeWithSHA1And40BitRC2, defined in PKCS - * #12, are supported. The |pass_raw_len| bytes pointed to by |pass_raw| are - * used as the password. Note that any conversions from the password as - * supplied in a text string (such as those specified in B.1 of PKCS #12) must - * be performed by the caller. - * - * If |salt| is NULL, a random salt of |salt_len| bytes is generated. If - * |salt_len| is zero, a default salt length is used instead. - * - * The resulting structure is stored in an X509_SIG which must be freed by the - * caller. - * - * TODO(davidben): Really? An X509_SIG? OpenSSL probably did that because it has - * the same structure as EncryptedPrivateKeyInfo. */ -OPENSSL_EXPORT X509_SIG *PKCS8_encrypt_pbe(int pbe_nid, - const uint8_t *pass_raw, - size_t pass_raw_len, - uint8_t *salt, size_t salt_len, - int iterations, - PKCS8_PRIV_KEY_INFO *p8inf); - -/* PKCS8_decrypt_pbe decrypts and decodes a PKCS8_PRIV_KEY_INFO with PBES1 as - * defined in PKCS #5. Only pbeWithSHAAnd128BitRC4, - * pbeWithSHAAnd3-KeyTripleDES-CBC and pbeWithSHA1And40BitRC2, defined in PKCS - * #12, are supported. The |pass_raw_len| bytes pointed to by |pass_raw| are - * used as the password. Note that any conversions from the password as - * supplied in a text string (such as those specified in B.1 of PKCS #12) must - * be performed by the caller. - * - * The resulting structure must be freed by the caller. */ -OPENSSL_EXPORT PKCS8_PRIV_KEY_INFO *PKCS8_decrypt_pbe(X509_SIG *pkcs8, - const uint8_t *pass_raw, - size_t pass_raw_len); - - -/* Deprecated functions. */ - -/* PKCS8_encrypt calls PKCS8_encrypt_pbe after treating |pass| as an ASCII - * string, appending U+0000, and converting to UCS-2. (So the empty password - * encodes as two NUL bytes.) The |cipher| argument is ignored. */ -OPENSSL_EXPORT X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, - const char *pass, int pass_len, - uint8_t *salt, size_t salt_len, - int iterations, - PKCS8_PRIV_KEY_INFO *p8inf); - -/* PKCS8_decrypt calls PKCS8_decrypt_pbe after treating |pass| as an ASCII - * string, appending U+0000, and converting to UCS-2. (So the empty password - * encodes as two NUL bytes.) */ -OPENSSL_EXPORT PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(X509_SIG *pkcs8, - const char *pass, - int pass_len); - -/* PKCS12_get_key_and_certs parses a PKCS#12 structure from |in|, authenticates - * and decrypts it using |password|, sets |*out_key| to the included private - * key and appends the included certificates to |out_certs|. It returns one on - * success and zero on error. The caller takes ownership of the outputs. */ -OPENSSL_EXPORT int PKCS12_get_key_and_certs(EVP_PKEY **out_key, - STACK_OF(X509) *out_certs, - CBS *in, const char *password); - - -/* Deprecated functions. */ - -/* PKCS12_PBE_add does nothing. It exists for compatibility with OpenSSL. */ -OPENSSL_EXPORT void PKCS12_PBE_add(void); - -/* d2i_PKCS12 is a dummy function that copies |*ber_bytes| into a - * |PKCS12| structure. The |out_p12| argument must be NULL. On exit, - * |*ber_bytes| will be advanced by |ber_len|. It returns a fresh |PKCS12| - * structure or NULL on error. - * - * Note: unlike other d2i functions, |d2i_PKCS12| will always consume |ber_len| - * bytes.*/ -OPENSSL_EXPORT PKCS12 *d2i_PKCS12(PKCS12 **out_p12, const uint8_t **ber_bytes, - size_t ber_len); - -/* d2i_PKCS12_bio acts like |d2i_PKCS12| but reads from a |BIO|. */ -OPENSSL_EXPORT PKCS12* d2i_PKCS12_bio(BIO *bio, PKCS12 **out_p12); - -/* d2i_PKCS12_fp acts like |d2i_PKCS12| but reads from a |FILE|. */ -OPENSSL_EXPORT PKCS12* d2i_PKCS12_fp(FILE *fp, PKCS12 **out_p12); - -/* PKCS12_parse calls |PKCS12_get_key_and_certs| on the ASN.1 data stored in - * |p12|. The |out_pkey| and |out_cert| arguments must not be NULL and, on - * successful exit, the private key and first certificate will be stored in - * them. The |out_ca_certs| argument may be NULL but, if not, then any extra - * certificates will be appended to |*out_ca_certs|. If |*out_ca_certs| is NULL - * then it will be set to a freshly allocated stack containing the extra certs. - * - * It returns one on success and zero on error. */ -OPENSSL_EXPORT int PKCS12_parse(const PKCS12 *p12, const char *password, - EVP_PKEY **out_pkey, X509 **out_cert, - STACK_OF(X509) **out_ca_certs); - -/* PKCS12_free frees |p12| and its contents. */ -OPENSSL_EXPORT void PKCS12_free(PKCS12 *p12); - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#define PKCS8_F_EVP_PKCS82PKEY 100 -#define PKCS8_F_EVP_PKEY2PKCS8 101 -#define PKCS8_F_PKCS12_get_key_and_certs 102 -#define PKCS8_F_PKCS12_handle_content_info 103 -#define PKCS8_F_PKCS12_handle_content_infos 104 -#define PKCS8_F_PKCS5_pbe2_set_iv 105 -#define PKCS8_F_PKCS5_pbe_set 106 -#define PKCS8_F_PKCS5_pbe_set0_algor 107 -#define PKCS8_F_PKCS5_pbkdf2_set 108 -#define PKCS8_F_PKCS8_decrypt 109 -#define PKCS8_F_PKCS8_encrypt 110 -#define PKCS8_F_PKCS8_encrypt_pbe 111 -#define PKCS8_F_pbe_cipher_init 112 -#define PKCS8_F_pbe_crypt 113 -#define PKCS8_F_pkcs12_item_decrypt_d2i 114 -#define PKCS8_F_pkcs12_item_i2d_encrypt 115 -#define PKCS8_F_pkcs12_key_gen_raw 116 -#define PKCS8_F_pkcs12_pbe_keyivgen 117 -#define PKCS8_R_BAD_PKCS12_DATA 100 -#define PKCS8_R_BAD_PKCS12_VERSION 101 -#define PKCS8_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 102 -#define PKCS8_R_CRYPT_ERROR 103 -#define PKCS8_R_DECODE_ERROR 104 -#define PKCS8_R_ENCODE_ERROR 105 -#define PKCS8_R_ENCRYPT_ERROR 106 -#define PKCS8_R_ERROR_SETTING_CIPHER_PARAMS 107 -#define PKCS8_R_INCORRECT_PASSWORD 108 -#define PKCS8_R_KEYGEN_FAILURE 109 -#define PKCS8_R_KEY_GEN_ERROR 110 -#define PKCS8_R_METHOD_NOT_SUPPORTED 111 -#define PKCS8_R_MISSING_MAC 112 -#define PKCS8_R_MULTIPLE_PRIVATE_KEYS_IN_PKCS12 113 -#define PKCS8_R_PKCS12_PUBLIC_KEY_INTEGRITY_NOT_SUPPORTED 114 -#define PKCS8_R_PKCS12_TOO_DEEPLY_NESTED 115 -#define PKCS8_R_PRIVATE_KEY_DECODE_ERROR 116 -#define PKCS8_R_PRIVATE_KEY_ENCODE_ERROR 117 -#define PKCS8_R_TOO_LONG 118 -#define PKCS8_R_UNKNOWN_ALGORITHM 119 -#define PKCS8_R_UNKNOWN_CIPHER 120 -#define PKCS8_R_UNKNOWN_CIPHER_ALGORITHM 121 -#define PKCS8_R_UNKNOWN_DIGEST 122 -#define PKCS8_R_UNKNOWN_HASH 123 -#define PKCS8_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 124 - -#endif /* OPENSSL_HEADER_PKCS8_H */ diff --git a/phonelibs/boringssl/include/openssl/poly1305.h b/phonelibs/boringssl/include/openssl/poly1305.h deleted file mode 100644 index aa904869ce5f17..00000000000000 --- a/phonelibs/boringssl/include/openssl/poly1305.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (c) 2014, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -#ifndef OPENSSL_HEADER_POLY1305_H -#define OPENSSL_HEADER_POLY1305_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef unsigned char poly1305_state[512]; - -/* poly1305_init sets up |state| so that it can be used to calculate an - * authentication tag with the one-time key |key|. Note that |key| is a - * one-time key and therefore there is no `reset' method because that would - * enable several messages to be authenticated with the same key. */ -extern void CRYPTO_poly1305_init(poly1305_state* state, const uint8_t key[32]); - -/* poly1305_update processes |in_len| bytes from |in|. It can be called zero or - * more times after poly1305_init. */ -extern void CRYPTO_poly1305_update(poly1305_state* state, const uint8_t* in, - size_t in_len); - -/* poly1305_finish completes the poly1305 calculation and writes a 16 byte - * authentication tag to |mac|. The |mac| address must be 16-byte aligned. */ -extern void CRYPTO_poly1305_finish(poly1305_state* state, uint8_t mac[16]); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_POLY1305_H */ diff --git a/phonelibs/boringssl/include/openssl/pqueue.h b/phonelibs/boringssl/include/openssl/pqueue.h deleted file mode 100644 index ceb1fa2a749757..00000000000000 --- a/phonelibs/boringssl/include/openssl/pqueue.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * DTLS implementation written by Nagendra Modadugu - * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. - */ -/* ==================================================================== - * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). */ - -#ifndef OPENSSL_HEADER_PQUEUE_H -#define OPENSSL_HEADER_PQUEUE_H - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* Priority queue. - * - * The priority queue maintains a linked-list of nodes, each with a unique, - * 64-bit priority, in ascending priority order. */ - -typedef struct _pqueue *pqueue; - -typedef struct _pitem { - uint8_t priority[8]; /* 64-bit value in big-endian encoding */ - void *data; - struct _pitem *next; -} pitem; - -typedef struct _pitem *piterator; - - -/* Creating and freeing queues. */ - -/* pqueue_new allocates a fresh, empty priority queue object and returns it, or - * NULL on error. */ -OPENSSL_EXPORT pqueue pqueue_new(void); - -/* pqueue_free frees |pq| but not any of the items it points to. Thus |pq| must - * be empty or a memory leak will occur. */ -OPENSSL_EXPORT void pqueue_free(pqueue pq); - - -/* Creating and freeing items. */ - -/* pitem_new allocates a fresh priority queue item that points at |data| and - * has a priority given by |prio64be|, which is a 64-bit, unsigned number - * expressed in big-endian form. It returns the fresh item, or NULL on - * error. */ -OPENSSL_EXPORT pitem *pitem_new(uint8_t prio64be[8], void *data); - -/* pitem_free frees |item|, but not any data that it points to. */ -OPENSSL_EXPORT void pitem_free(pitem *item); - - -/* Queue accessor functions */ - -/* pqueue_peek returns the item with the smallest priority from |pq|, or NULL - * if empty. */ -OPENSSL_EXPORT pitem *pqueue_peek(pqueue pq); - -/* pqueue_find returns the item whose priority matches |prio64be| or NULL if no - * such item exists. */ -OPENSSL_EXPORT pitem *pqueue_find(pqueue pq, uint8_t *prio64be); - - -/* Queue mutation functions */ - -/* pqueue_insert inserts |item| into |pq| and returns item. */ -OPENSSL_EXPORT pitem *pqueue_insert(pqueue pq, pitem *item); - -/* pqueue_pop takes the item with the least priority from |pq| and returns it, - * or NULL if |pq| is empty. */ -OPENSSL_EXPORT pitem *pqueue_pop(pqueue pq); - -/* pqueue_size returns the number of items in |pq|. */ -OPENSSL_EXPORT size_t pqueue_size(pqueue pq); - - -/* Iterating */ - -/* pqueue_iterator returns an iterator that can be used to iterate over the - * contents of the queue. */ -OPENSSL_EXPORT piterator pqueue_iterator(pqueue pq); - -/* pqueue_next returns the current value of |iter| and advances it to the next - * position. If the iterator has advanced over all the elements, it returns - * NULL. */ -OPENSSL_EXPORT pitem *pqueue_next(piterator *iter); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_PQUEUE_H */ diff --git a/phonelibs/boringssl/include/openssl/rand.h b/phonelibs/boringssl/include/openssl/rand.h deleted file mode 100644 index 300bf422877c6a..00000000000000 --- a/phonelibs/boringssl/include/openssl/rand.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (c) 2014, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -#ifndef OPENSSL_HEADER_RAND_H -#define OPENSSL_HEADER_RAND_H - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* Random number generation. */ - - -/* RAND_bytes writes |len| bytes of random data to |buf| and returns one. */ -OPENSSL_EXPORT int RAND_bytes(uint8_t *buf, size_t len); - -/* RAND_cleanup frees any resources used by the RNG. This is not safe if other - * threads might still be calling |RAND_bytes|. */ -OPENSSL_EXPORT void RAND_cleanup(void); - - -/* Deprecated functions */ - -/* RAND_pseudo_bytes is a wrapper around |RAND_bytes|. */ -OPENSSL_EXPORT int RAND_pseudo_bytes(uint8_t *buf, size_t len); - -/* RAND_seed does nothing. */ -OPENSSL_EXPORT void RAND_seed(const void *buf, int num); - -/* RAND_load_file returns a nonnegative number. */ -OPENSSL_EXPORT int RAND_load_file(const char *path, long num); - -/* RAND_add does nothing. */ -OPENSSL_EXPORT void RAND_add(const void *buf, int num, double entropy); - -/* RAND_poll returns one. */ -OPENSSL_EXPORT int RAND_poll(void); - -/* RAND_status returns one. */ -OPENSSL_EXPORT int RAND_status(void); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_RAND_H */ diff --git a/phonelibs/boringssl/include/openssl/rc4.h b/phonelibs/boringssl/include/openssl/rc4.h deleted file mode 100644 index 0619cac35507fc..00000000000000 --- a/phonelibs/boringssl/include/openssl/rc4.h +++ /dev/null @@ -1,90 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_RC4_H -#define OPENSSL_HEADER_RC4_H - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* RC4. */ - - -struct rc4_key_st { - uint32_t x, y; - uint32_t data[256]; -} /* RC4_KEY */; - -/* RC4_set_key performs an RC4 key schedule and initialises |rc4key| with |len| - * bytes of key material from |key|. */ -OPENSSL_EXPORT void RC4_set_key(RC4_KEY *rc4key, unsigned len, - const uint8_t *key); - -/* RC4 encrypts (or decrypts, it's the same with RC4) |len| bytes from |in| to - * |out|. */ -OPENSSL_EXPORT void RC4(RC4_KEY *key, size_t len, const uint8_t *in, - uint8_t *out); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_RC4_H */ diff --git a/phonelibs/boringssl/include/openssl/rsa.h b/phonelibs/boringssl/include/openssl/rsa.h deleted file mode 100644 index 9b415d75e1b141..00000000000000 --- a/phonelibs/boringssl/include/openssl/rsa.h +++ /dev/null @@ -1,575 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_RSA_H -#define OPENSSL_HEADER_RSA_H - -#include - -#include -#include -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* rsa.h contains functions for handling encryption and signature using RSA. */ - - -/* Allocation and destruction. */ - -/* RSA_new returns a new, empty RSA object or NULL on error. */ -OPENSSL_EXPORT RSA *RSA_new(void); - -/* RSA_new_method acts the same as |RSA_new| but takes an explicit |ENGINE|. */ -OPENSSL_EXPORT RSA *RSA_new_method(const ENGINE *engine); - -/* RSA_free decrements the reference count of |rsa| and frees it if the - * reference count drops to zero. */ -OPENSSL_EXPORT void RSA_free(RSA *rsa); - -/* RSA_up_ref increments the reference count of |rsa|. */ -OPENSSL_EXPORT int RSA_up_ref(RSA *rsa); - - -/* Key generation. */ - -/* RSA_generate_key_ex generates a new RSA key where the modulus has size - * |bits| and the public exponent is |e|. If unsure, |RSA_F4| is a good value - * for |e|. If |cb| is not NULL then it is called during the key generation - * process. In addition to the calls documented for |BN_generate_prime_ex|, it - * is called with event=2 when the n'th prime is rejected as unsuitable and - * with event=3 when a suitable value for |p| is found. - * - * It returns one on success or zero on error. */ -OPENSSL_EXPORT int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, - BN_GENCB *cb); - - -/* Encryption / Decryption */ - -/* Padding types for encryption. */ -#define RSA_PKCS1_PADDING 1 -#define RSA_NO_PADDING 3 -#define RSA_PKCS1_OAEP_PADDING 4 -/* RSA_PKCS1_PSS_PADDING can only be used via the EVP interface. */ -#define RSA_PKCS1_PSS_PADDING 6 - -/* RSA_encrypt encrypts |in_len| bytes from |in| to the public key from |rsa| - * and writes, at most, |max_out| bytes of encrypted data to |out|. The - * |max_out| argument must be, at least, |RSA_size| in order to ensure success. - * - * It returns 1 on success or zero on error. - * - * The |padding| argument must be one of the |RSA_*_PADDING| values. If in - * doubt, |RSA_PKCS1_PADDING| is the most common but |RSA_PKCS1_OAEP_PADDING| - * is the most secure. */ -OPENSSL_EXPORT int RSA_encrypt(RSA *rsa, size_t *out_len, uint8_t *out, - size_t max_out, const uint8_t *in, size_t in_len, - int padding); - -/* RSA_decrypt decrypts |in_len| bytes from |in| with the private key from - * |rsa| and writes, at most, |max_out| bytes of plaintext to |out|. The - * |max_out| argument must be, at least, |RSA_size| in order to ensure success. - * - * It returns 1 on success or zero on error. - * - * The |padding| argument must be one of the |RSA_*_PADDING| values. If in - * doubt, |RSA_PKCS1_PADDING| is the most common but |RSA_PKCS1_OAEP_PADDING| - * is the most secure. */ -OPENSSL_EXPORT int RSA_decrypt(RSA *rsa, size_t *out_len, uint8_t *out, - size_t max_out, const uint8_t *in, size_t in_len, - int padding); - -/* RSA_public_encrypt encrypts |flen| bytes from |from| to the public key in - * |rsa| and writes the encrypted data to |to|. The |to| buffer must have at - * least |RSA_size| bytes of space. It returns the number of bytes written, or - * -1 on error. The |padding| argument must be one of the |RSA_*_PADDING| - * values. If in doubt, |RSA_PKCS1_PADDING| is the most common but - * |RSA_PKCS1_OAEP_PADDING| is the most secure. - * - * WARNING: this function is dangerous because it breaks the usual return value - * convention. Use |RSA_encrypt| instead. */ -OPENSSL_EXPORT int RSA_public_encrypt(int flen, const uint8_t *from, - uint8_t *to, RSA *rsa, int padding); - -/* RSA_private_decrypt decrypts |flen| bytes from |from| with the public key in - * |rsa| and writes the plaintext to |to|. The |to| buffer must have at - * least |RSA_size| bytes of space. It returns the number of bytes written, or - * -1 on error. The |padding| argument must be one of the |RSA_*_PADDING| - * values. If in doubt, |RSA_PKCS1_PADDING| is the most common but - * |RSA_PKCS1_OAEP_PADDING| is the most secure. - * - * WARNING: this function is dangerous because it breaks the usual return value - * convention. Use |RSA_decrypt| instead. */ -OPENSSL_EXPORT int RSA_private_decrypt(int flen, const uint8_t *from, - uint8_t *to, RSA *rsa, int padding); - -/* RSA_message_index_PKCS1_type_2 performs the first step of a PKCS #1 padding - * check for decryption. If the |from_len| bytes pointed to at |from| are a - * valid PKCS #1 message, it returns one and sets |*out_index| to the start of - * the unpadded message. The unpadded message is a suffix of the input and has - * length |from_len - *out_index|. Otherwise, it returns zero and sets - * |*out_index| to zero. This function runs in time independent of the input - * data and is intended to be used directly to avoid Bleichenbacher's attack. - * - * WARNING: This function behaves differently from the usual OpenSSL convention - * in that it does NOT put an error on the queue in the error case. */ -OPENSSL_EXPORT int RSA_message_index_PKCS1_type_2(const uint8_t *from, - size_t from_len, - size_t *out_index); - - -/* Signing / Verification */ - -/* RSA_sign signs |in_len| bytes of digest from |in| with |rsa| and writes, at - * most, |RSA_size(rsa)| bytes to |out|. On successful return, the actual - * number of bytes written is written to |*out_len|. - * - * The |hash_nid| argument identifies the hash function used to calculate |in| - * and is embedded in the resulting signature. For example, it might be - * |NID_sha256|. - * - * It returns 1 on success and zero on error. */ -OPENSSL_EXPORT int RSA_sign(int hash_nid, const uint8_t *in, - unsigned int in_len, uint8_t *out, - unsigned int *out_len, RSA *rsa); - -/* RSA_sign_raw signs |in_len| bytes from |in| with the public key from |rsa| - * and writes, at most, |max_out| bytes of signature data to |out|. The - * |max_out| argument must be, at least, |RSA_size| in order to ensure success. - * - * It returns 1 on success or zero on error. - * - * The |padding| argument must be one of the |RSA_*_PADDING| values. If in - * doubt, |RSA_PKCS1_PADDING| is the most common. */ -OPENSSL_EXPORT int RSA_sign_raw(RSA *rsa, size_t *out_len, uint8_t *out, - size_t max_out, const uint8_t *in, - size_t in_len, int padding); - -/* RSA_verify verifies that |sig_len| bytes from |sig| are a valid, PKCS#1 - * signature of |msg_len| bytes at |msg| by |rsa|. - * - * The |hash_nid| argument identifies the hash function used to calculate |in| - * and is embedded in the resulting signature in order to prevent hash - * confusion attacks. For example, it might be |NID_sha256|. - * - * It returns one if the signature is valid and zero otherwise. - * - * WARNING: this differs from the original, OpenSSL function which additionally - * returned -1 on error. */ -OPENSSL_EXPORT int RSA_verify(int hash_nid, const uint8_t *msg, size_t msg_len, - const uint8_t *sig, size_t sig_len, RSA *rsa); - -/* RSA_verify_raw verifies |in_len| bytes of signature from |in| using the - * public key from |rsa| and writes, at most, |max_out| bytes of plaintext to - * |out|. The |max_out| argument must be, at least, |RSA_size| in order to - * ensure success. - * - * It returns 1 on success or zero on error. - * - * The |padding| argument must be one of the |RSA_*_PADDING| values. If in - * doubt, |RSA_PKCS1_PADDING| is the most common. */ -OPENSSL_EXPORT int RSA_verify_raw(RSA *rsa, size_t *out_len, uint8_t *out, - size_t max_out, const uint8_t *in, - size_t in_len, int padding); - -/* RSA_private_encrypt encrypts |flen| bytes from |from| with the private key in - * |rsa| and writes the encrypted data to |to|. The |to| buffer must have at - * least |RSA_size| bytes of space. It returns the number of bytes written, or - * -1 on error. The |padding| argument must be one of the |RSA_*_PADDING| - * values. If in doubt, |RSA_PKCS1_PADDING| is the most common. - * - * WARNING: this function is dangerous because it breaks the usual return value - * convention. Use |RSA_sign_raw| instead. */ -OPENSSL_EXPORT int RSA_private_encrypt(int flen, const uint8_t *from, - uint8_t *to, RSA *rsa, int padding); - -/* RSA_private_encrypt verifies |flen| bytes of signature from |from| using the - * public key in |rsa| and writes the plaintext to |to|. The |to| buffer must - * have at least |RSA_size| bytes of space. It returns the number of bytes - * written, or -1 on error. The |padding| argument must be one of the - * |RSA_*_PADDING| values. If in doubt, |RSA_PKCS1_PADDING| is the most common. - * - * WARNING: this function is dangerous because it breaks the usual return value - * convention. Use |RSA_verify_raw| instead. */ -OPENSSL_EXPORT int RSA_public_decrypt(int flen, const uint8_t *from, - uint8_t *to, RSA *rsa, int padding); - - -/* Utility functions. */ - -/* RSA_size returns the number of bytes in the modulus, which is also the size - * of a signature or encrypted value using |rsa|. */ -OPENSSL_EXPORT unsigned RSA_size(const RSA *rsa); - -/* RSA_is_opaque returns one if |rsa| is opaque and doesn't expose its key - * material. Otherwise it returns zero. */ -OPENSSL_EXPORT int RSA_is_opaque(const RSA *rsa); - -/* RSA_supports_digest returns one if |rsa| supports signing digests - * of type |md|. Otherwise it returns zero. */ -OPENSSL_EXPORT int RSA_supports_digest(const RSA *rsa, const EVP_MD *md); - -/* RSAPublicKey_dup allocates a fresh |RSA| and copies the private key from - * |rsa| into it. It returns the fresh |RSA| object, or NULL on error. */ -OPENSSL_EXPORT RSA *RSAPublicKey_dup(const RSA *rsa); - -/* RSAPrivateKey_dup allocates a fresh |RSA| and copies the private key from - * |rsa| into it. It returns the fresh |RSA| object, or NULL on error. */ -OPENSSL_EXPORT RSA *RSAPrivateKey_dup(const RSA *rsa); - -/* RSA_check_key performs basic validatity tests on |rsa|. It returns one if - * they pass and zero otherwise. Opaque keys and public keys always pass. If it - * returns zero then a more detailed error is available on the error queue. */ -OPENSSL_EXPORT int RSA_check_key(const RSA *rsa); - -/* RSA_recover_crt_params uses |rsa->n|, |rsa->d| and |rsa->e| in order to - * calculate the two primes used and thus the precomputed, CRT values. These - * values are set in the |p|, |q|, |dmp1|, |dmq1| and |iqmp| members of |rsa|, - * which must be |NULL| on entry. It returns one on success and zero - * otherwise. */ -OPENSSL_EXPORT int RSA_recover_crt_params(RSA *rsa); - -/* RSA_verify_PKCS1_PSS_mgf1 verifies that |EM| is a correct PSS padding of - * |mHash|, where |mHash| is a digest produced by |Hash|. |EM| must point to - * exactly |RSA_size(rsa)| bytes of data. The |mgf1Hash| argument specifies the - * hash function for generating the mask. If NULL, |Hash| is used. The |sLen| - * argument specifies the expected salt length in bytes. If |sLen| is -1 then - * the salt length is the same as the hash length. If -2, then the salt length - * is maximal and is taken from the size of |EM|. - * - * It returns one on success or zero on error. */ -OPENSSL_EXPORT int RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const uint8_t *mHash, - const EVP_MD *Hash, - const EVP_MD *mgf1Hash, - const uint8_t *EM, int sLen); - -/* RSA_padding_add_PKCS1_PSS_mgf1 writes a PSS padding of |mHash| to |EM|, - * where |mHash| is a digest produced by |Hash|. |RSA_size(rsa)| bytes of - * output will be written to |EM|. The |mgf1Hash| argument specifies the hash - * function for generating the mask. If NULL, |Hash| is used. The |sLen| - * argument specifies the expected salt length in bytes. If |sLen| is -1 then - * the salt length is the same as the hash length. If -2, then the salt length - * is maximal given the space in |EM|. - * - * It returns one on success or zero on error. */ -OPENSSL_EXPORT int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, uint8_t *EM, - const uint8_t *mHash, - const EVP_MD *Hash, - const EVP_MD *mgf1Hash, - int sLen); - - -/* ASN.1 functions. */ - -/* d2i_RSAPublicKey parses an ASN.1, DER-encoded, RSA public key from |len| - * bytes at |*inp|. If |out| is not NULL then, on exit, a pointer to the result - * is in |*out|. If |*out| is already non-NULL on entry then the result is - * written directly into |*out|, otherwise a fresh |RSA| is allocated. On - * successful exit, |*inp| is advanced past the DER structure. It returns the - * result or NULL on error. */ -OPENSSL_EXPORT RSA *d2i_RSAPublicKey(RSA **out, const uint8_t **inp, long len); - -/* i2d_RSAPublicKey marshals |in| to an ASN.1, DER structure. If |outp| is not - * NULL then the result is written to |*outp| and |*outp| is advanced just past - * the output. It returns the number of bytes in the result, whether written or - * not, or a negative value on error. */ -OPENSSL_EXPORT int i2d_RSAPublicKey(const RSA *in, uint8_t **outp); - -/* d2i_RSAPrivateKey parses an ASN.1, DER-encoded, RSA private key from |len| - * bytes at |*inp|. If |out| is not NULL then, on exit, a pointer to the result - * is in |*out|. If |*out| is already non-NULL on entry then the result is - * written directly into |*out|, otherwise a fresh |RSA| is allocated. On - * successful exit, |*inp| is advanced past the DER structure. It returns the - * result or NULL on error. */ -OPENSSL_EXPORT RSA *d2i_RSAPrivateKey(RSA **out, const uint8_t **inp, long len); - -/* i2d_RSAPrivateKey marshals |in| to an ASN.1, DER structure. If |outp| is not - * NULL then the result is written to |*outp| and |*outp| is advanced just past - * the output. It returns the number of bytes in the result, whether written or - * not, or a negative value on error. */ -OPENSSL_EXPORT int i2d_RSAPrivateKey(const RSA *in, uint8_t **outp); - - -/* ex_data functions. - * - * See |ex_data.h| for details. */ - -OPENSSL_EXPORT int RSA_get_ex_new_index(long argl, void *argp, - CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, - CRYPTO_EX_free *free_func); -OPENSSL_EXPORT int RSA_set_ex_data(RSA *r, int idx, void *arg); -OPENSSL_EXPORT void *RSA_get_ex_data(const RSA *r, int idx); - -/* RSA_FLAG_OPAQUE specifies that this RSA_METHOD does not expose its key - * material. This may be set if, for instance, it is wrapping some other crypto - * API, like a platform key store. */ -#define RSA_FLAG_OPAQUE 1 - -/* RSA_FLAG_CACHE_PUBLIC causes a precomputed Montgomery context to be created, - * on demand, for the public key operations. */ -#define RSA_FLAG_CACHE_PUBLIC 2 - -/* RSA_FLAG_CACHE_PRIVATE causes a precomputed Montgomery context to be - * created, on demand, for the private key operations. */ -#define RSA_FLAG_CACHE_PRIVATE 4 - -/* RSA_FLAG_NO_BLINDING disables blinding of private operations. */ -#define RSA_FLAG_NO_BLINDING 8 - -/* RSA_FLAG_EXT_PKEY means that private key operations will be handled by - * |mod_exp| and that they do not depend on the private key components being - * present: for example a key stored in external hardware. */ -#define RSA_FLAG_EXT_PKEY 0x20 - -/* RSA_FLAG_SIGN_VER causes the |sign| and |verify| functions of |rsa_meth_st| - * to be called when set. */ -#define RSA_FLAG_SIGN_VER 0x40 - - -/* RSA public exponent values. */ - -#define RSA_3 0x3 -#define RSA_F4 0x10001 - - -/* Deprecated functions. */ - -/* RSA_blinding_on returns one. */ -OPENSSL_EXPORT int RSA_blinding_on(RSA *rsa, BN_CTX *ctx); - - -struct rsa_meth_st { - struct openssl_method_common_st common; - - void *app_data; - - int (*init)(RSA *rsa); - int (*finish)(RSA *rsa); - - /* size returns the size of the RSA modulus in bytes. */ - size_t (*size)(const RSA *rsa); - - int (*sign)(int type, const uint8_t *m, unsigned int m_length, - uint8_t *sigret, unsigned int *siglen, const RSA *rsa); - - int (*verify)(int dtype, const uint8_t *m, unsigned int m_length, - const uint8_t *sigbuf, unsigned int siglen, const RSA *rsa); - - - /* These functions mirror the |RSA_*| functions of the same name. */ - int (*encrypt)(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, - const uint8_t *in, size_t in_len, int padding); - int (*sign_raw)(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, - const uint8_t *in, size_t in_len, int padding); - - int (*decrypt)(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, - const uint8_t *in, size_t in_len, int padding); - int (*verify_raw)(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, - const uint8_t *in, size_t in_len, int padding); - - /* private_transform takes a big-endian integer from |in|, calculates the - * d'th power of it, modulo the RSA modulus and writes the result as a - * big-endian integer to |out|. Both |in| and |out| are |len| bytes long and - * |len| is always equal to |RSA_size(rsa)|. If the result of the transform - * can be represented in fewer than |len| bytes, then |out| must be zero - * padded on the left. - * - * It returns one on success and zero otherwise. - * - * RSA decrypt and sign operations will call this, thus an ENGINE might wish - * to override it in order to avoid having to implement the padding - * functionality demanded by those, higher level, operations. */ - int (*private_transform)(RSA *rsa, uint8_t *out, const uint8_t *in, - size_t len); - - int (*mod_exp)(BIGNUM *r0, const BIGNUM *I, RSA *rsa, - BN_CTX *ctx); /* Can be null */ - int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx); - - int flags; - - int (*keygen)(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); - - /* supports_digest returns one if |rsa| supports digests of type - * |md|. If null, it is assumed that all digests are supported. */ - int (*supports_digest)(const RSA *rsa, const EVP_MD *md); -}; - - -/* Private functions. */ - -typedef struct bn_blinding_st BN_BLINDING; - -struct rsa_st { - /* version is only used during ASN.1 (de)serialisation. */ - long version; - RSA_METHOD *meth; - - BIGNUM *n; - BIGNUM *e; - BIGNUM *d; - BIGNUM *p; - BIGNUM *q; - BIGNUM *dmp1; - BIGNUM *dmq1; - BIGNUM *iqmp; - /* be careful using this if the RSA structure is shared */ - CRYPTO_EX_DATA ex_data; - CRYPTO_refcount_t references; - int flags; - - CRYPTO_MUTEX lock; - - /* Used to cache montgomery values. The creation of these values is protected - * by |lock|. */ - BN_MONT_CTX *_method_mod_n; - BN_MONT_CTX *_method_mod_p; - BN_MONT_CTX *_method_mod_q; - - /* num_blindings contains the size of the |blindings| and |blindings_inuse| - * arrays. This member and the |blindings_inuse| array are protected by - * |lock|. */ - unsigned num_blindings; - /* blindings is an array of BN_BLINDING structures that can be reserved by a - * thread by locking |lock| and changing the corresponding element in - * |blindings_inuse| from 0 to 1. */ - BN_BLINDING **blindings; - unsigned char *blindings_inuse; -}; - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#define RSA_F_BN_BLINDING_convert_ex 100 -#define RSA_F_BN_BLINDING_create_param 101 -#define RSA_F_BN_BLINDING_invert_ex 102 -#define RSA_F_BN_BLINDING_new 103 -#define RSA_F_BN_BLINDING_update 104 -#define RSA_F_RSA_check_key 105 -#define RSA_F_RSA_new_method 106 -#define RSA_F_RSA_padding_add_PKCS1_OAEP_mgf1 107 -#define RSA_F_RSA_padding_add_PKCS1_PSS_mgf1 108 -#define RSA_F_RSA_padding_add_PKCS1_type_1 109 -#define RSA_F_RSA_padding_add_PKCS1_type_2 110 -#define RSA_F_RSA_padding_add_none 111 -#define RSA_F_RSA_padding_check_PKCS1_OAEP_mgf1 112 -#define RSA_F_RSA_padding_check_PKCS1_type_1 113 -#define RSA_F_RSA_padding_check_PKCS1_type_2 114 -#define RSA_F_RSA_padding_check_none 115 -#define RSA_F_RSA_recover_crt_params 116 -#define RSA_F_RSA_sign 117 -#define RSA_F_RSA_verify 118 -#define RSA_F_RSA_verify_PKCS1_PSS_mgf1 119 -#define RSA_F_decrypt 120 -#define RSA_F_encrypt 121 -#define RSA_F_keygen 122 -#define RSA_F_pkcs1_prefixed_msg 123 -#define RSA_F_private_transform 124 -#define RSA_F_rsa_setup_blinding 125 -#define RSA_F_sign_raw 126 -#define RSA_F_verify_raw 127 -#define RSA_R_BAD_E_VALUE 100 -#define RSA_R_BAD_FIXED_HEADER_DECRYPT 101 -#define RSA_R_BAD_PAD_BYTE_COUNT 102 -#define RSA_R_BAD_RSA_PARAMETERS 103 -#define RSA_R_BAD_SIGNATURE 104 -#define RSA_R_BLOCK_TYPE_IS_NOT_01 105 -#define RSA_R_BN_NOT_INITIALIZED 106 -#define RSA_R_CRT_PARAMS_ALREADY_GIVEN 107 -#define RSA_R_CRT_VALUES_INCORRECT 108 -#define RSA_R_DATA_LEN_NOT_EQUAL_TO_MOD_LEN 109 -#define RSA_R_DATA_TOO_LARGE 110 -#define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 111 -#define RSA_R_DATA_TOO_LARGE_FOR_MODULUS 112 -#define RSA_R_DATA_TOO_SMALL 113 -#define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 114 -#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 115 -#define RSA_R_D_E_NOT_CONGRUENT_TO_1 116 -#define RSA_R_EMPTY_PUBLIC_KEY 117 -#define RSA_R_FIRST_OCTET_INVALID 118 -#define RSA_R_INCONSISTENT_SET_OF_CRT_VALUES 119 -#define RSA_R_INTERNAL_ERROR 120 -#define RSA_R_INVALID_MESSAGE_LENGTH 121 -#define RSA_R_KEY_SIZE_TOO_SMALL 122 -#define RSA_R_LAST_OCTET_INVALID 123 -#define RSA_R_MODULUS_TOO_LARGE 124 -#define RSA_R_NO_PUBLIC_EXPONENT 125 -#define RSA_R_NULL_BEFORE_BLOCK_MISSING 126 -#define RSA_R_N_NOT_EQUAL_P_Q 127 -#define RSA_R_OAEP_DECODING_ERROR 128 -#define RSA_R_ONLY_ONE_OF_P_Q_GIVEN 129 -#define RSA_R_OUTPUT_BUFFER_TOO_SMALL 130 -#define RSA_R_PADDING_CHECK_FAILED 131 -#define RSA_R_PKCS_DECODING_ERROR 132 -#define RSA_R_SLEN_CHECK_FAILED 133 -#define RSA_R_SLEN_RECOVERY_FAILED 134 -#define RSA_R_TOO_LONG 135 -#define RSA_R_TOO_MANY_ITERATIONS 136 -#define RSA_R_UNKNOWN_ALGORITHM_TYPE 137 -#define RSA_R_UNKNOWN_PADDING_TYPE 138 -#define RSA_R_VALUE_MISSING 139 -#define RSA_R_WRONG_SIGNATURE_LENGTH 140 - -#endif /* OPENSSL_HEADER_RSA_H */ diff --git a/phonelibs/boringssl/include/openssl/safestack.h b/phonelibs/boringssl/include/openssl/safestack.h deleted file mode 100644 index 6e5e433074f867..00000000000000 --- a/phonelibs/boringssl/include/openssl/safestack.h +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright (c) 2014, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -/* This header is provided in order to make compiling against code that expects - OpenSSL easier. */ diff --git a/phonelibs/boringssl/include/openssl/sha.h b/phonelibs/boringssl/include/openssl/sha.h deleted file mode 100644 index ac2ab758b41a85..00000000000000 --- a/phonelibs/boringssl/include/openssl/sha.h +++ /dev/null @@ -1,241 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_SHA_H -#define OPENSSL_HEADER_SHA_H - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* The SHA family of hash functions (SHA-1 and SHA-2). */ - - -/* SHA_CBLOCK is the block size of SHA-1. */ -#define SHA_CBLOCK 64 - -/* SHA_DIGEST_LENGTH is the length of a SHA-1 digest. */ -#define SHA_DIGEST_LENGTH 20 - -/* TODO(fork): remove */ -#define SHA_LBLOCK 16 -#define SHA_LONG uint32_t - -/* SHA1_Init initialises |sha| and returns one. */ -OPENSSL_EXPORT int SHA1_Init(SHA_CTX *sha); - -/* SHA1_Update adds |len| bytes from |data| to |sha| and returns one. */ -OPENSSL_EXPORT int SHA1_Update(SHA_CTX *sha, const void *data, size_t len); - -/* SHA1_Final adds the final padding to |sha| and writes the resulting digest - * to |md|, which must have at least |SHA_DIGEST_LENGTH| bytes of space. It - * returns one. */ -OPENSSL_EXPORT int SHA1_Final(uint8_t *md, SHA_CTX *sha); - -/* SHA1 writes the digest of |len| bytes from |data| to |out| and returns - * |out|. There must be at least |SHA_DIGEST_LENGTH| bytes of space in - * |out|. */ -OPENSSL_EXPORT uint8_t *SHA1(const uint8_t *data, size_t len, uint8_t *out); - -/* SHA1_Transform is a low-level function that performs a single, SHA-1 block - * transformation using the state from |sha| and 64 bytes from |block|. */ -OPENSSL_EXPORT void SHA1_Transform(SHA_CTX *sha, const uint8_t *block); - -struct sha_state_st { - uint32_t h0, h1, h2, h3, h4; - uint32_t Nl, Nh; - uint32_t data[16]; - unsigned int num; -}; - - -/* SHA-224. */ - -/* SHA224_CBLOCK is the block size of SHA-224. */ -#define SHA224_CBLOCK 64 - -/* SHA224_DIGEST_LENGTH is the length of a SHA-224 digest. */ -#define SHA224_DIGEST_LENGTH 28 - -/* SHA224_Init initialises |sha| and returns 1. */ -OPENSSL_EXPORT int SHA224_Init(SHA256_CTX *sha); - -/* SHA224_Update adds |len| bytes from |data| to |sha| and returns 1. */ -OPENSSL_EXPORT int SHA224_Update(SHA256_CTX *sha, const void *data, size_t len); - -/* SHA224_Final adds the final padding to |sha| and writes the resulting digest - * to |md|, which must have at least |SHA224_DIGEST_LENGTH| bytes of space. It - * returns one on success and zero on programmer error. */ -OPENSSL_EXPORT int SHA224_Final(uint8_t *md, SHA256_CTX *sha); - -/* SHA224 writes the digest of |len| bytes from |data| to |out| and returns - * |out|. There must be at least |SHA224_DIGEST_LENGTH| bytes of space in - * |out|. */ -OPENSSL_EXPORT uint8_t *SHA224(const uint8_t *data, size_t len, uint8_t *out); - - -/* SHA-256. */ - -/* SHA256_CBLOCK is the block size of SHA-256. */ -#define SHA256_CBLOCK 64 - -/* SHA256_DIGEST_LENGTH is the length of a SHA-256 digest. */ -#define SHA256_DIGEST_LENGTH 32 - -/* SHA256_Init initialises |sha| and returns 1. */ -OPENSSL_EXPORT int SHA256_Init(SHA256_CTX *sha); - -/* SHA256_Update adds |len| bytes from |data| to |sha| and returns 1. */ -OPENSSL_EXPORT int SHA256_Update(SHA256_CTX *sha, const void *data, size_t len); - -/* SHA256_Final adds the final padding to |sha| and writes the resulting digest - * to |md|, which must have at least |SHA256_DIGEST_LENGTH| bytes of space. It - * returns one on success and zero on programmer error. */ -OPENSSL_EXPORT int SHA256_Final(uint8_t *md, SHA256_CTX *sha); - -/* SHA256 writes the digest of |len| bytes from |data| to |out| and returns - * |out|. There must be at least |SHA256_DIGEST_LENGTH| bytes of space in - * |out|. */ -OPENSSL_EXPORT uint8_t *SHA256(const uint8_t *data, size_t len, uint8_t *out); - -/* SHA256_Transform is a low-level function that performs a single, SHA-1 block - * transformation using the state from |sha| and 64 bytes from |block|. */ -OPENSSL_EXPORT void SHA256_Transform(SHA256_CTX *sha, const uint8_t *data); - -struct sha256_state_st { - uint32_t h[8]; - uint32_t Nl, Nh; - uint32_t data[16]; - unsigned int num, md_len; -}; - - -/* SHA-384. */ - -/* SHA384_CBLOCK is the block size of SHA-384. */ -#define SHA384_CBLOCK 128 - -/* SHA384_DIGEST_LENGTH is the length of a SHA-384 digest. */ -#define SHA384_DIGEST_LENGTH 48 - -/* SHA384_Init initialises |sha| and returns 1. */ -OPENSSL_EXPORT int SHA384_Init(SHA512_CTX *sha); - -/* SHA384_Update adds |len| bytes from |data| to |sha| and returns 1. */ -OPENSSL_EXPORT int SHA384_Update(SHA512_CTX *sha, const void *data, size_t len); - -/* SHA384_Final adds the final padding to |sha| and writes the resulting digest - * to |md|, which must have at least |SHA384_DIGEST_LENGTH| bytes of space. It - * returns one on success and zero on programmer error. */ -OPENSSL_EXPORT int SHA384_Final(uint8_t *md, SHA512_CTX *sha); - -/* SHA384 writes the digest of |len| bytes from |data| to |out| and returns - * |out|. There must be at least |SHA384_DIGEST_LENGTH| bytes of space in - * |out|. */ -OPENSSL_EXPORT uint8_t *SHA384(const uint8_t *data, size_t len, uint8_t *out); - -/* SHA384_Transform is a low-level function that performs a single, SHA-1 block - * transformation using the state from |sha| and 64 bytes from |block|. */ -OPENSSL_EXPORT void SHA384_Transform(SHA512_CTX *sha, const uint8_t *data); - - -/* SHA-512. */ - -/* SHA512_CBLOCK is the block size of SHA-512. */ -#define SHA512_CBLOCK 128 - -/* SHA512_DIGEST_LENGTH is the length of a SHA-512 digest. */ -#define SHA512_DIGEST_LENGTH 64 - -/* SHA512_Init initialises |sha| and returns 1. */ -OPENSSL_EXPORT int SHA512_Init(SHA512_CTX *sha); - -/* SHA512_Update adds |len| bytes from |data| to |sha| and returns 1. */ -OPENSSL_EXPORT int SHA512_Update(SHA512_CTX *sha, const void *data, size_t len); - -/* SHA512_Final adds the final padding to |sha| and writes the resulting digest - * to |md|, which must have at least |SHA512_DIGEST_LENGTH| bytes of space. It - * returns one on success and zero on programmer error. */ -OPENSSL_EXPORT int SHA512_Final(uint8_t *md, SHA512_CTX *sha); - -/* SHA512 writes the digest of |len| bytes from |data| to |out| and returns - * |out|. There must be at least |SHA512_DIGEST_LENGTH| bytes of space in - * |out|. */ -OPENSSL_EXPORT uint8_t *SHA512(const uint8_t *data, size_t len, uint8_t *out); - -/* SHA512_Transform is a low-level function that performs a single, SHA-1 block - * transformation using the state from |sha| and 64 bytes from |block|. */ -OPENSSL_EXPORT void SHA512_Transform(SHA512_CTX *sha, const uint8_t *data); - -struct sha512_state_st { - uint64_t h[8]; - uint64_t Nl, Nh; - union { - uint64_t d[16]; - uint8_t p[128]; - } u; - unsigned int num, md_len; -}; - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_SHA_H */ diff --git a/phonelibs/boringssl/include/openssl/srtp.h b/phonelibs/boringssl/include/openssl/srtp.h deleted file mode 100644 index 3f5a53e2c1e1de..00000000000000 --- a/phonelibs/boringssl/include/openssl/srtp.h +++ /dev/null @@ -1,178 +0,0 @@ -/* ssl/tls1.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ -/* ==================================================================== - * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ -/* - DTLS code by Eric Rescorla - - Copyright (C) 2006, Network Resonance, Inc. - Copyright (C) 2011, RTFM, Inc. -*/ - -#ifndef OPENSSL_HEADER_SRTP_H -#define OPENSSL_HEADER_SRTP_H - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Constants for SRTP profiles */ -#define SRTP_AES128_CM_SHA1_80 0x0001 -#define SRTP_AES128_CM_SHA1_32 0x0002 -#define SRTP_AES128_F8_SHA1_80 0x0003 -#define SRTP_AES128_F8_SHA1_32 0x0004 -#define SRTP_NULL_SHA1_80 0x0005 -#define SRTP_NULL_SHA1_32 0x0006 - -/* SSL_CTX_set_srtp_profiles enables SRTP for all SSL objects created from - * |ctx|. |profile| contains a colon-separated list of profile names. It returns - * one on success and zero on failure. */ -OPENSSL_EXPORT int SSL_CTX_set_srtp_profiles(SSL_CTX *ctx, - const char *profiles); - -/* SSL_set_srtp_profiles enables SRTP for |ssl|. |profile| contains a - * colon-separated list of profile names. It returns one on success and zero on - * failure. */ -OPENSSL_EXPORT int SSL_set_srtp_profiles(SSL *ctx, const char *profiles); - -/* SSL_get_srtp_profiles returns the SRTP profiles supported by |ssl|. */ -OPENSSL_EXPORT STACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles( - SSL *ssl); - -/* SSL_get_selected_srtp_profile returns the selected SRTP profile, or NULL if - * SRTP was not negotiated. */ -OPENSSL_EXPORT const SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile( - SSL *s); - - -/* Deprecated functions */ - -/* SSL_CTX_set_tlsext_use_srtp calls SSL_CTX_set_srtp_profiles. It returns zero - * on success and one on failure. - * - * WARNING: this function is dangerous because it breaks the usual return value - * convention. Use SSL_CTX_set_srtp_profiles instead. */ -OPENSSL_EXPORT int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, - const char *profiles); - -/* SSL_set_tlsext_use_srtp calls SSL_set_srtp_profiles. It returns zero on - * success and one on failure. - * - * WARNING: this function is dangerous because it breaks the usual return value - * convention. Use SSL_set_srtp_profiles instead. */ -OPENSSL_EXPORT int SSL_set_tlsext_use_srtp(SSL *ctx, const char *profiles); - - -#ifdef __cplusplus -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_SRTP_H */ - diff --git a/phonelibs/boringssl/include/openssl/ssl.h b/phonelibs/boringssl/include/openssl/ssl.h deleted file mode 100644 index 217dbaf2f45173..00000000000000 --- a/phonelibs/boringssl/include/openssl/ssl.h +++ /dev/null @@ -1,2959 +0,0 @@ -/* ssl/ssl.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ -/* ==================================================================== - * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * ECC cipher suite support in OpenSSL originally developed by - * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. - */ -/* ==================================================================== - * Copyright 2005 Nokia. All rights reserved. - * - * The portions of the attached software ("Contribution") is developed by - * Nokia Corporation and is licensed pursuant to the OpenSSL open source - * license. - * - * The Contribution, originally written by Mika Kousa and Pasi Eronen of - * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites - * support (see RFC 4279) to OpenSSL. - * - * No patent licenses or other rights except those expressly stated in - * the OpenSSL open source license shall be deemed granted or received - * expressly, by implication, estoppel, or otherwise. - * - * No assurances are provided by Nokia that the Contribution does not - * infringe the patent or other intellectual property rights of any third - * party or that the license provides you with all the necessary rights - * to make use of the Contribution. - * - * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN - * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA - * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY - * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR - * OTHERWISE. - */ - -#ifndef OPENSSL_HEADER_SSL_H -#define OPENSSL_HEADER_SSL_H - -#include - -#include -#include -#include -#include -#include -#include -#include - -#if !defined(OPENSSL_WINDOWS) -#include -#endif - -/* wpa_supplicant expects to get the version functions from ssl.h */ -#include - -/* Forward-declare struct timeval. On Windows, it is defined in winsock2.h and - * Windows headers define too many macros to be included in public headers. - * However, only a forward declaration is needed. */ -struct timeval; - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* SSL implementation. */ - - -/* Initialization. */ - -/* SSL_library_init initializes the crypto and SSL libraries and returns one. */ -OPENSSL_EXPORT int SSL_library_init(void); - - -/* Cipher suites. */ - -/* An SSL_CIPHER represents a cipher suite. */ -typedef struct ssl_cipher_st { - /* name is the OpenSSL name for the cipher. */ - const char *name; - /* id is the cipher suite value bitwise OR-d with 0x03000000. */ - uint32_t id; - - /* The following are internal fields. See ssl/internal.h for their values. */ - - uint32_t algorithm_mkey; - uint32_t algorithm_auth; - uint32_t algorithm_enc; - uint32_t algorithm_mac; - uint32_t algorithm_ssl; - uint32_t algo_strength; - - /* algorithm2 contains extra flags. See ssl/internal.h. */ - uint32_t algorithm2; - - /* strength_bits is the strength of the cipher in bits. */ - int strength_bits; - /* alg_bits is the number of bits of key material used by the algorithm. */ - int alg_bits; -} SSL_CIPHER; - -DECLARE_STACK_OF(SSL_CIPHER) - -/* SSL_get_cipher_by_value returns the structure representing a TLS cipher - * suite based on its assigned number, or NULL if unknown. See - * https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4. */ -OPENSSL_EXPORT const SSL_CIPHER *SSL_get_cipher_by_value(uint16_t value); - -/* SSL_CIPHER_get_id returns |cipher|'s id. It may be cast to a |uint16_t| to - * get the cipher suite value. */ -OPENSSL_EXPORT uint32_t SSL_CIPHER_get_id(const SSL_CIPHER *cipher); - -/* SSL_CIPHER_is_AES returns one if |cipher| uses AES (either GCM or CBC - * mode). */ -OPENSSL_EXPORT int SSL_CIPHER_is_AES(const SSL_CIPHER *cipher); - -/* SSL_CIPHER_has_MD5_HMAC returns one if |cipher| uses HMAC-MD5. */ -OPENSSL_EXPORT int SSL_CIPHER_has_MD5_HMAC(const SSL_CIPHER *cipher); - -/* SSL_CIPHER_is_AESGCM returns one if |cipher| uses AES-GCM. */ -OPENSSL_EXPORT int SSL_CIPHER_is_AESGCM(const SSL_CIPHER *cipher); - -/* SSL_CIPHER_is_CHACHA20POLY1305 returns one if |cipher| uses - * CHACHA20_POLY1305. */ -OPENSSL_EXPORT int SSL_CIPHER_is_CHACHA20POLY1305(const SSL_CIPHER *cipher); - -/* SSL_CIPHER_get_name returns the OpenSSL name of |cipher|. */ -OPENSSL_EXPORT const char *SSL_CIPHER_get_name(const SSL_CIPHER *cipher); - -/* SSL_CIPHER_get_kx_name returns a string that describes the key-exchange - * method used by |cipher|. For example, "ECDHE_ECDSA". */ -OPENSSL_EXPORT const char *SSL_CIPHER_get_kx_name(const SSL_CIPHER *cipher); - -/* SSL_CIPHER_get_rfc_name returns a newly-allocated string with the standard - * name for |cipher| or NULL on error. For example, - * "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256". The caller is responsible for - * calling |OPENSSL_free| on the result. */ -OPENSSL_EXPORT char *SSL_CIPHER_get_rfc_name(const SSL_CIPHER *cipher); - -/* SSL_CIPHER_get_bits returns the strength, in bits, of |cipher|. If - * |out_alg_bits| is not NULL, it writes the number of bits consumed by the - * symmetric algorithm to |*out_alg_bits|. */ -OPENSSL_EXPORT int SSL_CIPHER_get_bits(const SSL_CIPHER *cipher, - int *out_alg_bits); - - -/* SSL contexts. */ - -/* An SSL_METHOD selects whether to use TLS or DTLS. */ -typedef struct ssl_method_st SSL_METHOD; - -/* TLS_method is the |SSL_METHOD| used for TLS (and SSLv3) connections. */ -OPENSSL_EXPORT const SSL_METHOD *TLS_method(void); - -/* DTLS_method is the |SSL_METHOD| used for DTLS connections. */ -OPENSSL_EXPORT const SSL_METHOD *DTLS_method(void); - -/* SSL_CTX_new returns a newly-allocated |SSL_CTX| with default settings or NULL - * on error. An |SSL_CTX| manages shared state and configuration between - * multiple TLS or DTLS connections. */ -OPENSSL_EXPORT SSL_CTX *SSL_CTX_new(const SSL_METHOD *method); - -/* SSL_CTX_free releases memory associated with |ctx|. */ -OPENSSL_EXPORT void SSL_CTX_free(SSL_CTX *ctx); - - -/* SSL connections. */ - -/* SSL_new returns a newly-allocated |SSL| using |ctx| or NULL on error. An - * |SSL| object represents a single TLS or DTLS connection. It inherits settings - * from |ctx| at the time of creation. Settings may also be individually - * configured on the connection. - * - * On creation, an |SSL| is not configured to be either a client or server. Call - * |SSL_set_connect_state| or |SSL_set_accept_state| to set this. */ -OPENSSL_EXPORT SSL *SSL_new(SSL_CTX *ctx); - -/* SSL_free releases memory associated with |ssl|. */ -OPENSSL_EXPORT void SSL_free(SSL *ssl); - -/* SSL_set_connect_state configures |ssl| to be a client. */ -OPENSSL_EXPORT void SSL_set_connect_state(SSL *ssl); - -/* SSL_set_accept_state configures |ssl| to be a server. */ -OPENSSL_EXPORT void SSL_set_accept_state(SSL *ssl); - - -/* Protocol versions. */ - -#define SSL3_VERSION_MAJOR 0x03 - -#define SSL3_VERSION 0x0300 -#define TLS1_VERSION 0x0301 -#define TLS1_1_VERSION 0x0302 -#define TLS1_2_VERSION 0x0303 - -#define DTLS1_VERSION 0xfeff -#define DTLS1_2_VERSION 0xfefd - -/* SSL_CTX_set_min_version sets the minimum protocol version for |ctx| to - * |version|. */ -OPENSSL_EXPORT void SSL_CTX_set_min_version(SSL_CTX *ctx, uint16_t version); - -/* SSL_CTX_set_max_version sets the maximum protocol version for |ctx| to - * |version|. */ -OPENSSL_EXPORT void SSL_CTX_set_max_version(SSL_CTX *ctx, uint16_t version); - -/* SSL_set_min_version sets the minimum protocol version for |ssl| to - * |version|. */ -OPENSSL_EXPORT void SSL_set_min_version(SSL *ssl, uint16_t version); - -/* SSL_set_max_version sets the maximum protocol version for |ssl| to - * |version|. */ -OPENSSL_EXPORT void SSL_set_max_version(SSL *ssl, uint16_t version); - - -/* Options. - * - * Options configure protocol behavior. */ - -/* SSL_OP_LEGACY_SERVER_CONNECT allows initial connections to servers that don't - * support the renegotiation_info extension (RFC 5746). It is on by default. */ -#define SSL_OP_LEGACY_SERVER_CONNECT 0x00000004L - -/* SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER allows for record sizes |SSL3_RT_MAX_EXTRA| - * bytes above the maximum record size. */ -#define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER 0x00000020L - -/* SSL_OP_TLS_D5_BUG accepts an RSAClientKeyExchange in TLS encoded as in SSL3 - * (i.e. without a length prefix). */ -#define SSL_OP_TLS_D5_BUG 0x00000100L - -/* SSL_OP_ALL enables the above bug workarounds that are enabled by many - * consumers. - * TODO(davidben): Determine which of the remaining may be removed now. */ -#define SSL_OP_ALL 0x00000BFFL - -/* SSL_OP_NO_QUERY_MTU, in DTLS, disables querying the MTU from the underlying - * |BIO|. Instead, the MTU is configured with |SSL_set_mtu|. */ -#define SSL_OP_NO_QUERY_MTU 0x00001000L - -/* SSL_OP_NO_TICKET disables session ticket support (RFC 4507). */ -#define SSL_OP_NO_TICKET 0x00004000L - -/* SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION permits unsafe legacy renegotiation - * without renegotiation_info (RFC 5746) support. */ -#define SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION 0x00040000L - -/* SSL_OP_CIPHER_SERVER_PREFERENCE configures servers to select ciphers and - * ECDHE curves according to the server's preferences instead of the - * client's. */ -#define SSL_OP_CIPHER_SERVER_PREFERENCE 0x00400000L - -/* The following flags toggle individual protocol versions. This is deprecated. - * Use |SSL_CTX_set_min_version| and |SSL_CTX_set_max_version| instead. */ -#define SSL_OP_NO_SSLv3 0x02000000L -#define SSL_OP_NO_TLSv1 0x04000000L -#define SSL_OP_NO_TLSv1_2 0x08000000L -#define SSL_OP_NO_TLSv1_1 0x10000000L -#define SSL_OP_NO_DTLSv1 SSL_OP_NO_TLSv1 -#define SSL_OP_NO_DTLSv1_2 SSL_OP_NO_TLSv1_2 - -/* The following flags do nothing and are included only to make it easier to - * compile code with BoringSSL. */ -#define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS 0 -#define SSL_OP_MICROSOFT_SESS_ID_BUG 0 -#define SSL_OP_NETSCAPE_CHALLENGE_BUG 0 -#define SSL_OP_NO_COMPRESSION 0 -#define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION 0 -#define SSL_OP_NO_SSLv2 0 -#define SSL_OP_SINGLE_DH_USE 0 -#define SSL_OP_SINGLE_ECDH_USE 0 -#define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG 0 -#define SSL_OP_TLS_BLOCK_PADDING_BUG 0 -#define SSL_OP_TLS_ROLLBACK_BUG 0 - -/* SSL_CTX_set_options enables all options set in |options| (which should be one - * or more of the |SSL_OP_*| values, ORed together) in |ctx|. It returns a - * bitmask representing the resulting enabled options. */ -OPENSSL_EXPORT uint32_t SSL_CTX_set_options(SSL_CTX *ctx, uint32_t options); - -/* SSL_CTX_clear_options disables all options set in |options| (which should be - * one or more of the |SSL_OP_*| values, ORed together) in |ctx|. It returns a - * bitmask representing the resulting enabled options. */ -OPENSSL_EXPORT uint32_t SSL_CTX_clear_options(SSL_CTX *ctx, uint32_t options); - -/* SSL_CTX_get_options returns a bitmask of |SSL_OP_*| values that represent all - * the options enabled for |ctx|. */ -OPENSSL_EXPORT uint32_t SSL_CTX_get_options(const SSL_CTX *ctx); - -/* SSL_set_options enables all options set in |options| (which should be one or - * more of the |SSL_OP_*| values, ORed together) in |ssl|. It returns a bitmask - * representing the resulting enabled options. */ -OPENSSL_EXPORT uint32_t SSL_set_options(SSL *ssl, uint32_t options); - -/* SSL_clear_options disables all options set in |options| (which should be one - * or more of the |SSL_OP_*| values, ORed together) in |ssl|. It returns a - * bitmask representing the resulting enabled options. */ -OPENSSL_EXPORT uint32_t SSL_clear_options(SSL *ssl, uint32_t options); - -/* SSL_get_options returns a bitmask of |SSL_OP_*| values that represent all the - * options enabled for |ssl|. */ -OPENSSL_EXPORT uint32_t SSL_get_options(const SSL *ssl); - - -/* Modes. - * - * Modes configure API behavior. */ - -/* SSL_MODE_ENABLE_PARTIAL_WRITE allows |SSL_write| to complete with a partial - * result when the only part of the input was written in a single record. */ -#define SSL_MODE_ENABLE_PARTIAL_WRITE 0x00000001L - -/* SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER allows retrying an incomplete |SSL_write| - * with a different buffer. However, |SSL_write| still assumes the buffer - * contents are unchanged. This is not the default to avoid the misconception - * that non-blocking |SSL_write| behaves like non-blocking |write|. */ -#define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002L - -/* SSL_MODE_NO_AUTO_CHAIN disables automatically building a certificate chain - * before sending certificates to the peer. - * TODO(davidben): Remove this behavior. https://crbug.com/486295. */ -#define SSL_MODE_NO_AUTO_CHAIN 0x00000008L - -/* SSL_MODE_ENABLE_FALSE_START allows clients to send application data before - * receipt of CCS and Finished. This mode enables full-handshakes to 'complete' - * in one RTT. See draft-bmoeller-tls-falsestart-01. */ -#define SSL_MODE_ENABLE_FALSE_START 0x00000080L - -/* Deprecated: SSL_MODE_HANDSHAKE_CUTTHROUGH is the same as - * SSL_MODE_ENABLE_FALSE_START. */ -#define SSL_MODE_HANDSHAKE_CUTTHROUGH SSL_MODE_ENABLE_FALSE_START - -/* SSL_MODE_CBC_RECORD_SPLITTING causes multi-byte CBC records in SSL 3.0 and - * TLS 1.0 to be split in two: the first record will contain a single byte and - * the second will contain the remainder. This effectively randomises the IV and - * prevents BEAST attacks. */ -#define SSL_MODE_CBC_RECORD_SPLITTING 0x00000100L - -/* SSL_MODE_NO_SESSION_CREATION will cause any attempts to create a session to - * fail with SSL_R_SESSION_MAY_NOT_BE_CREATED. This can be used to enforce that - * session resumption is used for a given SSL*. */ -#define SSL_MODE_NO_SESSION_CREATION 0x00000200L - -/* SSL_MODE_SEND_FALLBACK_SCSV sends TLS_FALLBACK_SCSV in the ClientHello. - * To be set only by applications that reconnect with a downgraded protocol - * version; see https://tools.ietf.org/html/draft-ietf-tls-downgrade-scsv-05 - * for details. - * - * DO NOT ENABLE THIS if your application attempts a normal handshake. Only use - * this in explicit fallback retries, following the guidance in - * draft-ietf-tls-downgrade-scsv-05. */ -#define SSL_MODE_SEND_FALLBACK_SCSV 0x00000400L - -/* The following flags do nothing and are included only to make it easier to - * compile code with BoringSSL. */ -#define SSL_MODE_AUTO_RETRY 0 -#define SSL_MODE_RELEASE_BUFFERS 0 -#define SSL_MODE_SEND_CLIENTHELLO_TIME 0 -#define SSL_MODE_SEND_SERVERHELLO_TIME 0 - -/* SSL_CTX_set_mode enables all modes set in |mode| (which should be one or more - * of the |SSL_MODE_*| values, ORed together) in |ctx|. It returns a bitmask - * representing the resulting enabled modes. */ -OPENSSL_EXPORT uint32_t SSL_CTX_set_mode(SSL_CTX *ctx, uint32_t mode); - -/* SSL_CTX_clear_mode disables all modes set in |mode| (which should be one or - * more of the |SSL_MODE_*| values, ORed together) in |ctx|. It returns a - * bitmask representing the resulting enabled modes. */ -OPENSSL_EXPORT uint32_t SSL_CTX_clear_mode(SSL_CTX *ctx, uint32_t mode); - -/* SSL_CTX_get_mode returns a bitmask of |SSL_MODE_*| values that represent all - * the modes enabled for |ssl|. */ -OPENSSL_EXPORT uint32_t SSL_CTX_get_mode(const SSL_CTX *ctx); - -/* SSL_set_mode enables all modes set in |mode| (which should be one or more of - * the |SSL_MODE_*| values, ORed together) in |ssl|. It returns a bitmask - * representing the resulting enabled modes. */ -OPENSSL_EXPORT uint32_t SSL_set_mode(SSL *ssl, uint32_t mode); - -/* SSL_clear_mode disables all modes set in |mode| (which should be one or more - * of the |SSL_MODE_*| values, ORed together) in |ssl|. It returns a bitmask - * representing the resulting enabled modes. */ -OPENSSL_EXPORT uint32_t SSL_clear_mode(SSL *ssl, uint32_t mode); - -/* SSL_get_mode returns a bitmask of |SSL_MODE_*| values that represent all the - * modes enabled for |ssl|. */ -OPENSSL_EXPORT uint32_t SSL_get_mode(const SSL *ssl); - - -/* Connection information. */ - -/* SSL_get_tls_unique writes at most |max_out| bytes of the tls-unique value - * for |ssl| to |out| and sets |*out_len| to the number of bytes written. It - * returns one on success or zero on error. In general |max_out| should be at - * least 12. - * - * This function will always fail if the initial handshake has not completed. - * The tls-unique value will change after a renegotiation but, since - * renegotiations can be initiated by the server at any point, the higher-level - * protocol must either leave them disabled or define states in which the - * tls-unique value can be read. - * - * The tls-unique value is defined by - * https://tools.ietf.org/html/rfc5929#section-3.1. Due to a weakness in the - * TLS protocol, tls-unique is broken for resumed connections unless the - * Extended Master Secret extension is negotiated. Thus this function will - * return zero if |ssl| performed session resumption unless EMS was used when - * negotiating the original session. */ -OPENSSL_EXPORT int SSL_get_tls_unique(const SSL *ssl, uint8_t *out, - size_t *out_len, size_t max_out); - - -/* Underdocumented functions. - * - * Functions below here haven't been touched up and may be underdocumented. */ - -/* SSLeay version number for ASN.1 encoding of the session information */ -/* Version 0 - initial version - * Version 1 - added the optional peer certificate. */ -#define SSL_SESSION_ASN1_VERSION 0x0001 - -#define SSL_MAX_SSL_SESSION_ID_LENGTH 32 -#define SSL_MAX_SID_CTX_LENGTH 32 -#define SSL_MAX_MASTER_KEY_LENGTH 48 - -/* These are used to specify which ciphers to use and not to use */ - -#define SSL_TXT_MEDIUM "MEDIUM" -#define SSL_TXT_HIGH "HIGH" -#define SSL_TXT_FIPS "FIPS" - -#define SSL_TXT_kRSA "kRSA" -#define SSL_TXT_kDHE "kDHE" -#define SSL_TXT_kEDH "kEDH" /* same as "kDHE" */ -#define SSL_TXT_kECDHE "kECDHE" -#define SSL_TXT_kEECDH "kEECDH" /* same as "kECDHE" */ -#define SSL_TXT_kPSK "kPSK" - -#define SSL_TXT_aRSA "aRSA" -#define SSL_TXT_aECDSA "aECDSA" -#define SSL_TXT_aPSK "aPSK" - -#define SSL_TXT_DH "DH" -#define SSL_TXT_DHE "DHE" /* same as "kDHE" */ -#define SSL_TXT_EDH "EDH" /* same as "DHE" */ -#define SSL_TXT_RSA "RSA" -#define SSL_TXT_ECDH "ECDH" -#define SSL_TXT_ECDHE "ECDHE" /* same as "kECDHE" */ -#define SSL_TXT_EECDH "EECDH" /* same as "ECDHE" */ -#define SSL_TXT_ECDSA "ECDSA" -#define SSL_TXT_PSK "PSK" - -#define SSL_TXT_3DES "3DES" -#define SSL_TXT_RC4 "RC4" -#define SSL_TXT_AES128 "AES128" -#define SSL_TXT_AES256 "AES256" -#define SSL_TXT_AES "AES" -#define SSL_TXT_AES_GCM "AESGCM" -#define SSL_TXT_CHACHA20 "CHACHA20" - -#define SSL_TXT_MD5 "MD5" -#define SSL_TXT_SHA1 "SHA1" -#define SSL_TXT_SHA "SHA" /* same as "SHA1" */ -#define SSL_TXT_SHA256 "SHA256" -#define SSL_TXT_SHA384 "SHA384" - -#define SSL_TXT_SSLV3 "SSLv3" -#define SSL_TXT_TLSV1 "TLSv1" -#define SSL_TXT_TLSV1_1 "TLSv1.1" -#define SSL_TXT_TLSV1_2 "TLSv1.2" - -#define SSL_TXT_ALL "ALL" - -/* COMPLEMENTOF* definitions. These identifiers are used to (de-select) ciphers - * normally not being used. - * - * Example: "RC4" will activate all ciphers using RC4 including ciphers without - * authentication, which would normally disabled by DEFAULT (due the "!ADH" - * being part of default). Therefore "RC4:!COMPLEMENTOFDEFAULT" will make sure - * that it is also disabled in the specific selection. COMPLEMENTOF* - * identifiers are portable between version, as adjustments to the default - * cipher setup will also be included here. - * - * COMPLEMENTOFDEFAULT does not experience the same special treatment that - * DEFAULT gets, as only selection is being done and no sorting as needed for - * DEFAULT. */ -#define SSL_TXT_CMPDEF "COMPLEMENTOFDEFAULT" - -/* The following cipher list is used by default. It also is substituted when an - * application-defined cipher list string starts with 'DEFAULT'. */ -#define SSL_DEFAULT_CIPHER_LIST "ALL" - -/* As of OpenSSL 1.0.0, ssl_create_cipher_list() in ssl/ssl_ciph.c always - * starts with a reasonable order, and all we have to do for DEFAULT is - * throwing out anonymous and unencrypted ciphersuites! (The latter are not - * actually enabled by ALL, but "ALL:RSA" would enable some of them.) */ - -/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */ -#define SSL_SENT_SHUTDOWN 1 -#define SSL_RECEIVED_SHUTDOWN 2 - -#define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1 -#define SSL_FILETYPE_PEM X509_FILETYPE_PEM - -typedef struct ssl_protocol_method_st SSL_PROTOCOL_METHOD; -typedef struct ssl_session_st SSL_SESSION; -typedef struct tls_sigalgs_st TLS_SIGALGS; -typedef struct ssl_conf_ctx_st SSL_CONF_CTX; -typedef struct ssl3_enc_method SSL3_ENC_METHOD; - -/* SRTP protection profiles for use with the use_srtp extension (RFC 5764). */ -typedef struct srtp_protection_profile_st { - const char *name; - unsigned long id; -} SRTP_PROTECTION_PROFILE; - -DECLARE_STACK_OF(SRTP_PROTECTION_PROFILE) - -/* An SSL_SESSION represents an SSL session that may be resumed in an - * abbreviated handshake. */ -struct ssl_session_st { - int ssl_version; /* what ssl version session info is being kept in here? */ - - int master_key_length; - uint8_t master_key[SSL_MAX_MASTER_KEY_LENGTH]; - /* session_id - valid? */ - unsigned int session_id_length; - uint8_t session_id[SSL_MAX_SSL_SESSION_ID_LENGTH]; - /* this is used to determine whether the session is being reused in - * the appropriate context. It is up to the application to set this, - * via SSL_new */ - unsigned int sid_ctx_length; - uint8_t sid_ctx[SSL_MAX_SID_CTX_LENGTH]; - - char *psk_identity; - /* Used to indicate that session resumption is not allowed. Applications can - * also set this bit for a new session via not_resumable_session_cb to - * disable session caching and tickets. */ - int not_resumable; - - /* The cert is the certificate used to establish this connection */ - struct sess_cert_st /* SESS_CERT */ *sess_cert; - - /* This is the cert for the other end. On clients, it will be the same as - * sess_cert->peer_key->x509 (the latter is not enough as sess_cert is not - * retained in the external representation of sessions, see ssl_asn1.c). */ - X509 *peer; - /* when app_verify_callback accepts a session where the peer's certificate is - * not ok, we must remember the error for session reuse: */ - long verify_result; /* only for servers */ - - CRYPTO_refcount_t references; - long timeout; - long time; - - const SSL_CIPHER *cipher; - - CRYPTO_EX_DATA ex_data; /* application specific data */ - - /* These are used to make removal of session-ids more efficient and to - * implement a maximum cache size. */ - SSL_SESSION *prev, *next; - char *tlsext_hostname; - /* RFC4507 info */ - uint8_t *tlsext_tick; /* Session ticket */ - size_t tlsext_ticklen; /* Session ticket length */ - uint32_t tlsext_tick_lifetime_hint; /* Session lifetime hint in seconds */ - - size_t tlsext_signed_cert_timestamp_list_length; - uint8_t *tlsext_signed_cert_timestamp_list; /* Server's list. */ - - /* The OCSP response that came with the session. */ - size_t ocsp_response_length; - uint8_t *ocsp_response; - - char peer_sha256_valid; /* Non-zero if peer_sha256 is valid */ - uint8_t - peer_sha256[SHA256_DIGEST_LENGTH]; /* SHA256 of peer certificate */ - - /* original_handshake_hash contains the handshake hash (either SHA-1+MD5 or - * SHA-2, depending on TLS version) for the original, full handshake that - * created a session. This is used by Channel IDs during resumption. */ - uint8_t original_handshake_hash[EVP_MAX_MD_SIZE]; - unsigned int original_handshake_hash_len; - - /* extended_master_secret is true if the master secret in this session was - * generated using EMS and thus isn't vulnerable to the Triple Handshake - * attack. */ - char extended_master_secret; -}; - - -/* Cert related flags */ -/* Many implementations ignore some aspects of the TLS standards such as - * enforcing certifcate chain algorithms. When this is set we enforce them. */ -#define SSL_CERT_FLAG_TLS_STRICT 0x00000001L - -/* Flags for building certificate chains */ -/* Treat any existing certificates as untrusted CAs */ -#define SSL_BUILD_CHAIN_FLAG_UNTRUSTED 0x1 -/* Don't include root CA in chain */ -#define SSL_BUILD_CHAIN_FLAG_NO_ROOT 0x2 -/* Just check certificates already there */ -#define SSL_BUILD_CHAIN_FLAG_CHECK 0x4 -/* Ignore verification errors */ -#define SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR 0x8 -/* Clear verification errors from queue */ -#define SSL_BUILD_CHAIN_FLAG_CLEAR_ERROR 0x10 - -/* SSL_set_mtu sets the |ssl|'s MTU in DTLS to |mtu|. It returns one on success - * and zero on failure. */ -OPENSSL_EXPORT int SSL_set_mtu(SSL *ssl, unsigned mtu); - -/* SSL_get_secure_renegotiation_support returns one if the peer supports secure - * renegotiation (RFC 5746) and zero otherwise. */ -OPENSSL_EXPORT int SSL_get_secure_renegotiation_support(const SSL *ssl); - -/* SSL_CTX_set_msg_callback installs |cb| as the message callback for |ctx|. - * This callback will be called when sending or receiving low-level record - * headers, complete handshake messages, ChangeCipherSpec, and alerts. - * |write_p| is one for outgoing messages and zero for incoming messages. - * - * For each record header, |cb| is called with |version| = 0 and |content_type| - * = |SSL3_RT_HEADER|. The |len| bytes from |buf| contain the header. Note that - * this does not include the record body. If the record is sealed, the length - * in the header is the length of the ciphertext. - * - * For each handshake message, ChangeCipherSpec, and alert, |version| is the - * protocol version and |content_type| is the corresponding record type. The - * |len| bytes from |buf| contain the handshake message, one-byte - * ChangeCipherSpec body, and two-byte alert, respectively. */ -OPENSSL_EXPORT void SSL_CTX_set_msg_callback( - SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, - const void *buf, size_t len, SSL *ssl, void *arg)); - -/* SSL_CTX_set_msg_callback_arg sets the |arg| parameter of the message - * callback. */ -OPENSSL_EXPORT void SSL_CTX_set_msg_callback_arg(SSL_CTX *ctx, void *arg); - -/* SSL_set_msg_callback installs |cb| as the message callback of |ssl|. See - * |SSL_CTX_set_msg_callback| for when this callback is called. */ -OPENSSL_EXPORT void SSL_set_msg_callback( - SSL *ssl, void (*cb)(int write_p, int version, int content_type, - const void *buf, size_t len, SSL *ssl, void *arg)); - -/* SSL_set_msg_callback_arg sets the |arg| parameter of the message callback. */ -OPENSSL_EXPORT void SSL_set_msg_callback_arg(SSL *ssl, void *arg); - -/* SSL_CTX_set_keylog_bio sets configures all SSL objects attached to |ctx| to - * log session material to |keylog_bio|. This is intended for debugging use - * with tools like Wireshark. |ctx| takes ownership of |keylog_bio|. - * - * The format is described in - * https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Key_Log_Format. */ -OPENSSL_EXPORT void SSL_CTX_set_keylog_bio(SSL_CTX *ctx, BIO *keylog_bio); - - -struct ssl_aead_ctx_st; -typedef struct ssl_aead_ctx_st SSL_AEAD_CTX; - -#define SSL_MAX_CERT_LIST_DEFAULT 1024 * 100 /* 100k max cert list */ - -#define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024 * 20) - -#define SSL_DEFAULT_SESSION_TIMEOUT (2 * 60 * 60) - -/* This callback type is used inside SSL_CTX, SSL, and in the functions that - * set them. It is used to override the generation of SSL/TLS session IDs in a - * server. Return value should be zero on an error, non-zero to proceed. Also, - * callbacks should themselves check if the id they generate is unique - * otherwise the SSL handshake will fail with an error - callbacks can do this - * using the 'ssl' value they're passed by; - * SSL_has_matching_session_id(ssl, id, *id_len) - * The length value passed in is set at the maximum size the session ID can be. - * In SSLv2 this is 16 bytes, whereas SSLv3/TLSv1 it is 32 bytes. The callback - * can alter this length to be less if desired, but under SSLv2 session IDs are - * supposed to be fixed at 16 bytes so the id will be padded after the callback - * returns in this case. It is also an error for the callback to set the size - * to zero. */ -typedef int (*GEN_SESSION_CB)(const SSL *ssl, uint8_t *id, - unsigned int *id_len); - -/* ssl_early_callback_ctx is passed to certain callbacks that are called very - * early on during the server handshake. At this point, much of the SSL* hasn't - * been filled out and only the ClientHello can be depended on. */ -struct ssl_early_callback_ctx { - SSL *ssl; - const uint8_t *client_hello; - size_t client_hello_len; - const uint8_t *session_id; - size_t session_id_len; - const uint8_t *cipher_suites; - size_t cipher_suites_len; - const uint8_t *compression_methods; - size_t compression_methods_len; - const uint8_t *extensions; - size_t extensions_len; -}; - -/* SSL_early_callback_ctx_extension_get searches the extensions in |ctx| for an - * extension of the given type. If not found, it returns zero. Otherwise it - * sets |out_data| to point to the extension contents (not including the type - * and length bytes), sets |out_len| to the length of the extension contents - * and returns one. */ -OPENSSL_EXPORT char SSL_early_callback_ctx_extension_get( - const struct ssl_early_callback_ctx *ctx, uint16_t extension_type, - const uint8_t **out_data, size_t *out_len); - -typedef struct ssl_comp_st SSL_COMP; - -struct ssl_comp_st { - int id; - const char *name; - char *method; -}; - -DECLARE_STACK_OF(SSL_COMP) -DECLARE_LHASH_OF(SSL_SESSION) - -/* ssl_cipher_preference_list_st contains a list of SSL_CIPHERs with - * equal-preference groups. For TLS clients, the groups are moot because the - * server picks the cipher and groups cannot be expressed on the wire. However, - * for servers, the equal-preference groups allow the client's preferences to - * be partially respected. (This only has an effect with - * SSL_OP_CIPHER_SERVER_PREFERENCE). - * - * The equal-preference groups are expressed by grouping SSL_CIPHERs together. - * All elements of a group have the same priority: no ordering is expressed - * within a group. - * - * The values in |ciphers| are in one-to-one correspondence with - * |in_group_flags|. (That is, sk_SSL_CIPHER_num(ciphers) is the number of - * bytes in |in_group_flags|.) The bytes in |in_group_flags| are either 1, to - * indicate that the corresponding SSL_CIPHER is not the last element of a - * group, or 0 to indicate that it is. - * - * For example, if |in_group_flags| contains all zeros then that indicates a - * traditional, fully-ordered preference. Every SSL_CIPHER is the last element - * of the group (i.e. they are all in a one-element group). - * - * For a more complex example, consider: - * ciphers: A B C D E F - * in_group_flags: 1 1 0 0 1 0 - * - * That would express the following, order: - * - * A E - * B -> D -> F - * C - */ -struct ssl_cipher_preference_list_st { - STACK_OF(SSL_CIPHER) *ciphers; - uint8_t *in_group_flags; -}; - -struct ssl_ctx_st { - const SSL_PROTOCOL_METHOD *method; - - /* lock is used to protect various operations on this object. */ - CRYPTO_MUTEX lock; - - /* max_version is the maximum acceptable protocol version. If zero, the - * maximum supported version, currently (D)TLS 1.2, is used. */ - uint16_t max_version; - - /* min_version is the minimum acceptable protocl version. If zero, the - * minimum supported version, currently SSL 3.0 and DTLS 1.0, is used */ - uint16_t min_version; - - struct ssl_cipher_preference_list_st *cipher_list; - /* same as above but sorted for lookup */ - STACK_OF(SSL_CIPHER) *cipher_list_by_id; - /* cipher_list_tls11 is the list of ciphers when TLS 1.1 or greater is in - * use. This only applies to server connections as, for clients, the version - * number is known at connect time and so the cipher list can be set then. */ - struct ssl_cipher_preference_list_st *cipher_list_tls11; - - X509_STORE *cert_store; - LHASH_OF(SSL_SESSION) *sessions; - /* Most session-ids that will be cached, default is - * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited. */ - unsigned long session_cache_size; - SSL_SESSION *session_cache_head; - SSL_SESSION *session_cache_tail; - - /* handshakes_since_cache_flush is the number of successful handshakes since - * the last cache flush. */ - int handshakes_since_cache_flush; - - /* This can have one of 2 values, ored together, - * SSL_SESS_CACHE_CLIENT, - * SSL_SESS_CACHE_SERVER, - * Default is SSL_SESSION_CACHE_SERVER, which means only - * SSL_accept which cache SSL_SESSIONS. */ - int session_cache_mode; - - /* If timeout is not 0, it is the default timeout value set when SSL_new() is - * called. This has been put in to make life easier to set things up */ - long session_timeout; - - /* If this callback is not null, it will be called each time a session id is - * added to the cache. If this function returns 1, it means that the - * callback will do a SSL_SESSION_free() when it has finished using it. - * Otherwise, on 0, it means the callback has finished with it. If - * remove_session_cb is not null, it will be called when a session-id is - * removed from the cache. After the call, OpenSSL will SSL_SESSION_free() - * it. */ - int (*new_session_cb)(SSL *ssl, SSL_SESSION *sess); - void (*remove_session_cb)(SSL_CTX *ctx, SSL_SESSION *sess); - SSL_SESSION *(*get_session_cb)(SSL *ssl, uint8_t *data, int len, - int *copy); - - CRYPTO_refcount_t references; - - /* if defined, these override the X509_verify_cert() calls */ - int (*app_verify_callback)(X509_STORE_CTX *, void *); - void *app_verify_arg; - /* before OpenSSL 0.9.7, 'app_verify_arg' was ignored ('app_verify_callback' - * was called with just one argument) */ - - /* Default password callback. */ - pem_password_cb *default_passwd_callback; - - /* Default password callback user data. */ - void *default_passwd_callback_userdata; - - /* get client cert callback */ - int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey); - - /* get channel id callback */ - void (*channel_id_cb)(SSL *ssl, EVP_PKEY **pkey); - - CRYPTO_EX_DATA ex_data; - - STACK_OF(X509) *extra_certs; - - - /* Default values used when no per-SSL value is defined follow */ - - void (*info_callback)(const SSL *ssl, int type, - int val); /* used if SSL's info_callback is NULL */ - - /* what we put in client cert requests */ - STACK_OF(X509_NAME) *client_CA; - - - /* Default values to use in SSL structures follow (these are copied by - * SSL_new) */ - - uint32_t options; - uint32_t mode; - uint32_t max_cert_list; - - struct cert_st /* CERT */ *cert; - - /* callback that allows applications to peek at protocol messages */ - void (*msg_callback)(int write_p, int version, int content_type, - const void *buf, size_t len, SSL *ssl, void *arg); - void *msg_callback_arg; - - int verify_mode; - unsigned int sid_ctx_length; - uint8_t sid_ctx[SSL_MAX_SID_CTX_LENGTH]; - int (*default_verify_callback)( - int ok, X509_STORE_CTX *ctx); /* called 'verify_callback' in the SSL */ - - /* Default generate session ID callback. */ - GEN_SESSION_CB generate_session_id; - - X509_VERIFY_PARAM *param; - - /* select_certificate_cb is called before most ClientHello processing and - * before the decision whether to resume a session is made. It may return one - * to continue the handshake or zero to cause the handshake loop to return - * with an error and cause SSL_get_error to return - * SSL_ERROR_PENDING_CERTIFICATE. Note: when the handshake loop is resumed, it - * will not call the callback a second time. */ - int (*select_certificate_cb)(const struct ssl_early_callback_ctx *); - - /* dos_protection_cb is called once the resumption decision for a ClientHello - * has been made. It returns one to continue the handshake or zero to - * abort. */ - int (*dos_protection_cb) (const struct ssl_early_callback_ctx *); - - /* quiet_shutdown is true if the connection should not send a close_notify on - * shutdown. */ - int quiet_shutdown; - - /* Maximum amount of data to send in one fragment. actual record size can be - * more than this due to padding and MAC overheads. */ - uint16_t max_send_fragment; - - /* TLS extensions servername callback */ - int (*tlsext_servername_callback)(SSL *, int *, void *); - void *tlsext_servername_arg; - /* RFC 4507 session ticket keys */ - uint8_t tlsext_tick_key_name[16]; - uint8_t tlsext_tick_hmac_key[16]; - uint8_t tlsext_tick_aes_key[16]; - /* Callback to support customisation of ticket key setting */ - int (*tlsext_ticket_key_cb)(SSL *ssl, uint8_t *name, uint8_t *iv, - EVP_CIPHER_CTX *ectx, HMAC_CTX *hctx, int enc); - - /* Server-only: psk_identity_hint is the default identity hint to send in - * PSK-based key exchanges. */ - char *psk_identity_hint; - - unsigned int (*psk_client_callback)(SSL *ssl, const char *hint, - char *identity, - unsigned int max_identity_len, - uint8_t *psk, unsigned int max_psk_len); - unsigned int (*psk_server_callback)(SSL *ssl, const char *identity, - uint8_t *psk, unsigned int max_psk_len); - - - /* retain_only_sha256_of_client_certs is true if we should compute the SHA256 - * hash of the peer's certifiate and then discard it to save memory and - * session space. Only effective on the server side. */ - char retain_only_sha256_of_client_certs; - - /* Next protocol negotiation information */ - /* (for experimental NPN extension). */ - - /* For a server, this contains a callback function by which the set of - * advertised protocols can be provided. */ - int (*next_protos_advertised_cb)(SSL *s, const uint8_t **buf, - unsigned int *len, void *arg); - void *next_protos_advertised_cb_arg; - /* For a client, this contains a callback function that selects the - * next protocol from the list provided by the server. */ - int (*next_proto_select_cb)(SSL *s, uint8_t **out, uint8_t *outlen, - const uint8_t *in, unsigned int inlen, void *arg); - void *next_proto_select_cb_arg; - - /* ALPN information - * (we are in the process of transitioning from NPN to ALPN.) */ - - /* For a server, this contains a callback function that allows the - * server to select the protocol for the connection. - * out: on successful return, this must point to the raw protocol - * name (without the length prefix). - * outlen: on successful return, this contains the length of |*out|. - * in: points to the client's list of supported protocols in - * wire-format. - * inlen: the length of |in|. */ - int (*alpn_select_cb)(SSL *s, const uint8_t **out, uint8_t *outlen, - const uint8_t *in, unsigned int inlen, void *arg); - void *alpn_select_cb_arg; - - /* For a client, this contains the list of supported protocols in wire - * format. */ - uint8_t *alpn_client_proto_list; - unsigned alpn_client_proto_list_len; - - /* SRTP profiles we are willing to do from RFC 5764 */ - STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles; - - /* EC extension values inherited by SSL structure */ - size_t tlsext_ecpointformatlist_length; - uint8_t *tlsext_ecpointformatlist; - size_t tlsext_ellipticcurvelist_length; - uint16_t *tlsext_ellipticcurvelist; - - /* If true, a client will advertise the Channel ID extension and a server - * will echo it. */ - char tlsext_channel_id_enabled; - /* tlsext_channel_id_enabled_new is a hack to support both old and new - * ChannelID signatures. It indicates that a client should advertise the new - * ChannelID extension number. */ - char tlsext_channel_id_enabled_new; - /* The client's Channel ID private key. */ - EVP_PKEY *tlsext_channel_id_private; - - /* If true, a client will request certificate timestamps. */ - char signed_cert_timestamps_enabled; - - /* If true, a client will request a stapled OCSP response. */ - char ocsp_stapling_enabled; - - /* If not NULL, session key material will be logged to this BIO for debugging - * purposes. The format matches NSS's and is readable by Wireshark. */ - BIO *keylog_bio; - - /* current_time_cb, if not NULL, is the function to use to get the current - * time. It sets |*out_clock| to the current time. */ - void (*current_time_cb)(const SSL *ssl, struct timeval *out_clock); -}; - -OPENSSL_EXPORT LHASH_OF(SSL_SESSION) *SSL_CTX_sessions(SSL_CTX *ctx); - -/* SSL_CTX_sess_number returns the number of sessions in |ctx|'s internal - * session cache. */ -OPENSSL_EXPORT size_t SSL_CTX_sess_number(const SSL_CTX *ctx); - -OPENSSL_EXPORT void SSL_CTX_sess_set_new_cb( - SSL_CTX *ctx, int (*new_session_cb)(SSL *ssl, SSL_SESSION *sess)); -OPENSSL_EXPORT int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))(SSL *ssl, - SSL_SESSION *sess); -OPENSSL_EXPORT void SSL_CTX_sess_set_remove_cb( - SSL_CTX *ctx, - void (*remove_session_cb)(SSL_CTX *ctx, SSL_SESSION *sess)); -OPENSSL_EXPORT void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))( - SSL_CTX *ctx, SSL_SESSION *sess); -OPENSSL_EXPORT void SSL_CTX_sess_set_get_cb( - SSL_CTX *ctx, - SSL_SESSION *(*get_session_cb)(SSL *ssl, uint8_t *data, int len, - int *copy)); -OPENSSL_EXPORT SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))( - SSL *ssl, uint8_t *data, int len, int *copy); -/* SSL_magic_pending_session_ptr returns a magic SSL_SESSION* which indicates - * that the session isn't currently unavailable. SSL_get_error will then return - * SSL_ERROR_PENDING_SESSION and the handshake can be retried later when the - * lookup has completed. */ -OPENSSL_EXPORT SSL_SESSION *SSL_magic_pending_session_ptr(void); -OPENSSL_EXPORT void SSL_CTX_set_info_callback(SSL_CTX *ctx, - void (*cb)(const SSL *ssl, - int type, int val)); -OPENSSL_EXPORT void (*SSL_CTX_get_info_callback(SSL_CTX *ctx))(const SSL *ssl, - int type, - int val); -OPENSSL_EXPORT void SSL_CTX_set_client_cert_cb( - SSL_CTX *ctx, - int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey)); -OPENSSL_EXPORT int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))(SSL *ssl, - X509 **x509, - EVP_PKEY **pkey); -OPENSSL_EXPORT void SSL_CTX_set_channel_id_cb( - SSL_CTX *ctx, void (*channel_id_cb)(SSL *ssl, EVP_PKEY **pkey)); -OPENSSL_EXPORT void (*SSL_CTX_get_channel_id_cb(SSL_CTX *ctx))(SSL *ssl, - EVP_PKEY **pkey); - -/* SSL_enable_signed_cert_timestamps causes |ssl| (which must be the client end - * of a connection) to request SCTs from the server. See - * https://tools.ietf.org/html/rfc6962. It returns one. */ -OPENSSL_EXPORT int SSL_enable_signed_cert_timestamps(SSL *ssl); - -/* SSL_CTX_enable_signed_cert_timestamps enables SCT requests on all client SSL - * objects created from |ctx|. */ -OPENSSL_EXPORT void SSL_CTX_enable_signed_cert_timestamps(SSL_CTX *ctx); - -/* SSL_enable_ocsp_stapling causes |ssl| (which must be the client end of a - * connection) to request a stapled OCSP response from the server. It returns - * one. */ -OPENSSL_EXPORT int SSL_enable_ocsp_stapling(SSL *ssl); - -/* SSL_CTX_enable_ocsp_stapling enables OCSP stapling on all client SSL objects - * created from |ctx|. */ -OPENSSL_EXPORT void SSL_CTX_enable_ocsp_stapling(SSL_CTX *ctx); - -/* SSL_get0_signed_cert_timestamp_list sets |*out| and |*out_len| to point to - * |*out_len| bytes of SCT information from the server. This is only valid if - * |ssl| is a client. The SCT information is a SignedCertificateTimestampList - * (including the two leading length bytes). - * See https://tools.ietf.org/html/rfc6962#section-3.3 - * If no SCT was received then |*out_len| will be zero on return. - * - * WARNING: the returned data is not guaranteed to be well formed. */ -OPENSSL_EXPORT void SSL_get0_signed_cert_timestamp_list(const SSL *ssl, - const uint8_t **out, - size_t *out_len); - -/* SSL_get0_ocsp_response sets |*out| and |*out_len| to point to |*out_len| - * bytes of an OCSP response from the server. This is the DER encoding of an - * OCSPResponse type as defined in RFC 2560. - * - * WARNING: the returned data is not guaranteed to be well formed. */ -OPENSSL_EXPORT void SSL_get0_ocsp_response(const SSL *ssl, const uint8_t **out, - size_t *out_len); - -OPENSSL_EXPORT void SSL_CTX_set_next_protos_advertised_cb( - SSL_CTX *s, - int (*cb)(SSL *ssl, const uint8_t **out, unsigned int *outlen, void *arg), - void *arg); -OPENSSL_EXPORT void SSL_CTX_set_next_proto_select_cb( - SSL_CTX *s, int (*cb)(SSL *ssl, uint8_t **out, uint8_t *outlen, - const uint8_t *in, unsigned int inlen, void *arg), - void *arg); -OPENSSL_EXPORT void SSL_get0_next_proto_negotiated(const SSL *s, - const uint8_t **data, - unsigned *len); - -OPENSSL_EXPORT int SSL_select_next_proto(uint8_t **out, uint8_t *outlen, - const uint8_t *in, unsigned int inlen, - const uint8_t *client, - unsigned int client_len); - -#define OPENSSL_NPN_UNSUPPORTED 0 -#define OPENSSL_NPN_NEGOTIATED 1 -#define OPENSSL_NPN_NO_OVERLAP 2 - -/* SSL_CTX_set_alpn_protos sets the ALPN protocol list on |ctx| to |protos|. - * |protos| must be in wire-format (i.e. a series of non-empty, 8-bit - * length-prefixed strings). It returns zero on success and one on failure. - * - * WARNING: this function is dangerous because it breaks the usual return value - * convention. */ -OPENSSL_EXPORT int SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const uint8_t *protos, - unsigned protos_len); - -/* SSL_set_alpn_protos sets the ALPN protocol list on |ssl| to |protos|. - * |protos| must be in wire-format (i.e. a series of non-empty, 8-bit - * length-prefixed strings). It returns zero on success and one on failure. - * - * WARNING: this function is dangerous because it breaks the usual return value - * convention. */ -OPENSSL_EXPORT int SSL_set_alpn_protos(SSL *ssl, const uint8_t *protos, - unsigned protos_len); - -OPENSSL_EXPORT void SSL_CTX_set_alpn_select_cb( - SSL_CTX *ctx, int (*cb)(SSL *ssl, const uint8_t **out, uint8_t *outlen, - const uint8_t *in, unsigned int inlen, void *arg), - void *arg); -OPENSSL_EXPORT void SSL_get0_alpn_selected(const SSL *ssl, const uint8_t **data, - unsigned *len); - -/* SSL_enable_fastradio_padding controls whether fastradio padding is enabled - * on |ssl|. If it is, ClientHello messages are padded to 1024 bytes. This - * causes 3G radios to switch to DCH mode (high data rate). */ -OPENSSL_EXPORT void SSL_enable_fastradio_padding(SSL *ssl, char on_off); - -/* SSL_set_reject_peer_renegotiations controls whether renegotiation attempts by - * the peer are rejected. It may be set at any point in a connection's lifetime - * to control future renegotiations programmatically. By default, renegotiations - * are rejected. (Renegotiations requested by a client are always rejected.) */ -OPENSSL_EXPORT void SSL_set_reject_peer_renegotiations(SSL *ssl, int reject); - -/* the maximum length of the buffer given to callbacks containing the resulting - * identity/psk */ -#define PSK_MAX_IDENTITY_LEN 128 -#define PSK_MAX_PSK_LEN 256 -OPENSSL_EXPORT void SSL_CTX_set_psk_client_callback( - SSL_CTX *ctx, - unsigned int (*psk_client_callback)( - SSL *ssl, const char *hint, char *identity, - unsigned int max_identity_len, uint8_t *psk, unsigned int max_psk_len)); -OPENSSL_EXPORT void SSL_set_psk_client_callback( - SSL *ssl, unsigned int (*psk_client_callback)(SSL *ssl, const char *hint, - char *identity, - unsigned int max_identity_len, - uint8_t *psk, - unsigned int max_psk_len)); -OPENSSL_EXPORT void SSL_CTX_set_psk_server_callback( - SSL_CTX *ctx, - unsigned int (*psk_server_callback)(SSL *ssl, const char *identity, - uint8_t *psk, - unsigned int max_psk_len)); -OPENSSL_EXPORT void SSL_set_psk_server_callback( - SSL *ssl, - unsigned int (*psk_server_callback)(SSL *ssl, const char *identity, - uint8_t *psk, - unsigned int max_psk_len)); -OPENSSL_EXPORT int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, - const char *identity_hint); -OPENSSL_EXPORT int SSL_use_psk_identity_hint(SSL *s, const char *identity_hint); -OPENSSL_EXPORT const char *SSL_get_psk_identity_hint(const SSL *s); -OPENSSL_EXPORT const char *SSL_get_psk_identity(const SSL *s); - -#define SSL_NOTHING 1 -#define SSL_WRITING 2 -#define SSL_READING 3 -#define SSL_X509_LOOKUP 4 -#define SSL_CHANNEL_ID_LOOKUP 5 -#define SSL_PENDING_SESSION 7 -#define SSL_CERTIFICATE_SELECTION_PENDING 8 - -/* These will only be used when doing non-blocking IO */ -#define SSL_want_nothing(s) (SSL_want(s) == SSL_NOTHING) -#define SSL_want_read(s) (SSL_want(s) == SSL_READING) -#define SSL_want_write(s) (SSL_want(s) == SSL_WRITING) -#define SSL_want_x509_lookup(s) (SSL_want(s) == SSL_X509_LOOKUP) -#define SSL_want_channel_id_lookup(s) (SSL_want(s) == SSL_CHANNEL_ID_LOOKUP) -#define SSL_want_session(s) (SSL_want(s) == SSL_PENDING_SESSION) -#define SSL_want_certificate(s) \ - (SSL_want(s) == SSL_CERTIFICATE_SELECTION_PENDING) - -struct ssl_st { - /* version is the protocol version. */ - int version; - - /* method is the method table corresponding to the current protocol (DTLS or - * TLS). */ - const SSL_PROTOCOL_METHOD *method; - - /* enc_method is the method table corresponding to the current protocol - * version. */ - const SSL3_ENC_METHOD *enc_method; - - /* max_version is the maximum acceptable protocol version. If zero, the - * maximum supported version, currently (D)TLS 1.2, is used. */ - uint16_t max_version; - - /* min_version is the minimum acceptable protocl version. If zero, the - * minimum supported version, currently SSL 3.0 and DTLS 1.0, is used */ - uint16_t min_version; - - /* There are 2 BIO's even though they are normally both the same. This is so - * data can be read and written to different handlers */ - - BIO *rbio; /* used by SSL_read */ - BIO *wbio; /* used by SSL_write */ - BIO *bbio; /* used during session-id reuse to concatenate - * messages */ - - /* This holds a variable that indicates what we were doing when a 0 or -1 is - * returned. This is needed for non-blocking IO so we know what request - * needs re-doing when in SSL_accept or SSL_connect */ - int rwstate; - - /* true when we are actually in SSL_accept() or SSL_connect() */ - int in_handshake; - int (*handshake_func)(SSL *); - - /* Imagine that here's a boolean member "init" that is switched as soon as - * SSL_set_{accept/connect}_state is called for the first time, so that - * "state" and "handshake_func" are properly initialized. But as - * handshake_func is == 0 until then, we use this test instead of an "init" - * member. */ - - /* server is true iff the this SSL* is the server half. Note: before the SSL* - * is initialized by either SSL_set_accept_state or SSL_set_connect_state, - * the side is not determined. In this state, server is always false. */ - int server; - - /* quiet_shutdown is true if the connection should not send a close_notify on - * shutdown. */ - int quiet_shutdown; - - int shutdown; /* we have shut things down, 0x01 sent, 0x02 - * for received */ - int state; /* where we are */ - int rstate; /* where we are when reading */ - - BUF_MEM *init_buf; /* buffer used during init */ - uint8_t *init_msg; /* pointer to handshake message body, set by - ssl3_get_message() */ - int init_num; /* amount read/written */ - int init_off; /* amount read/written */ - - /* used internally to point at a raw packet */ - uint8_t *packet; - unsigned int packet_length; - - struct ssl3_state_st *s3; /* SSLv3 variables */ - struct dtls1_state_st *d1; /* DTLSv1 variables */ - - /* callback that allows applications to peek at protocol messages */ - void (*msg_callback)(int write_p, int version, int content_type, - const void *buf, size_t len, SSL *ssl, void *arg); - void *msg_callback_arg; - - int hit; /* reusing a previous session */ - - X509_VERIFY_PARAM *param; - - /* crypto */ - struct ssl_cipher_preference_list_st *cipher_list; - STACK_OF(SSL_CIPHER) *cipher_list_by_id; - - SSL_AEAD_CTX *aead_read_ctx; - SSL_AEAD_CTX *aead_write_ctx; - - /* session info */ - - /* client cert? */ - /* This is used to hold the server certificate used */ - struct cert_st /* CERT */ *cert; - - /* the session_id_context is used to ensure sessions are only reused - * in the appropriate context */ - unsigned int sid_ctx_length; - uint8_t sid_ctx[SSL_MAX_SID_CTX_LENGTH]; - - /* This can also be in the session once a session is established */ - SSL_SESSION *session; - - /* Default generate session ID callback. */ - GEN_SESSION_CB generate_session_id; - - /* Used in SSL2 and SSL3 */ - int verify_mode; /* 0 don't care about verify failure. - * 1 fail if verify fails */ - int (*verify_callback)(int ok, - X509_STORE_CTX *ctx); /* fail if callback returns 0 */ - - void (*info_callback)(const SSL *ssl, int type, - int val); /* optional informational callback */ - - /* Server-only: psk_identity_hint is the identity hint to send in - * PSK-based key exchanges. */ - char *psk_identity_hint; - - unsigned int (*psk_client_callback)(SSL *ssl, const char *hint, - char *identity, - unsigned int max_identity_len, - uint8_t *psk, unsigned int max_psk_len); - unsigned int (*psk_server_callback)(SSL *ssl, const char *identity, - uint8_t *psk, unsigned int max_psk_len); - - SSL_CTX *ctx; - - /* extra application data */ - long verify_result; - CRYPTO_EX_DATA ex_data; - - /* for server side, keep the list of CA_dn we can use */ - STACK_OF(X509_NAME) *client_CA; - - uint32_t options; /* protocol behaviour */ - uint32_t mode; /* API behaviour */ - uint32_t max_cert_list; - int client_version; /* what was passed, used for - * SSLv3/TLS rollback check */ - uint16_t max_send_fragment; - char *tlsext_hostname; - /* should_ack_sni is true if the SNI extension should be acked. This is - * only used by a server. */ - char should_ack_sni; - /* RFC4507 session ticket expected to be received or sent */ - int tlsext_ticket_expected; - size_t tlsext_ecpointformatlist_length; - uint8_t *tlsext_ecpointformatlist; /* our list */ - size_t tlsext_ellipticcurvelist_length; - uint16_t *tlsext_ellipticcurvelist; /* our list */ - - SSL_CTX *initial_ctx; /* initial ctx, used to store sessions */ - - /* Next protocol negotiation. For the client, this is the protocol that we - * sent in NextProtocol and is set when handling ServerHello extensions. - * - * For a server, this is the client's selected_protocol from NextProtocol and - * is set when handling the NextProtocol message, before the Finished - * message. */ - uint8_t *next_proto_negotiated; - size_t next_proto_negotiated_len; - - /* srtp_profiles is the list of configured SRTP protection profiles for - * DTLS-SRTP. */ - STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles; - - /* srtp_profile is the selected SRTP protection profile for - * DTLS-SRTP. */ - const SRTP_PROTECTION_PROFILE *srtp_profile; - - /* Copied from the SSL_CTX. For a server, means that we'll accept Channel IDs - * from clients. For a client, means that we'll advertise support. */ - char tlsext_channel_id_enabled; - /* The client's Channel ID private key. */ - EVP_PKEY *tlsext_channel_id_private; - - /* Enable signed certificate time stamps. Currently client only. */ - char signed_cert_timestamps_enabled; - - /* Enable OCSP stapling. Currently client only. - * TODO(davidben): Add a server-side implementation when it becomes - * necesary. */ - char ocsp_stapling_enabled; - - /* For a client, this contains the list of supported protocols in wire - * format. */ - uint8_t *alpn_client_proto_list; - unsigned alpn_client_proto_list_len; - - /* fastradio_padding, if true, causes ClientHellos to be padded to 1024 - * bytes. This ensures that the cellular radio is fast forwarded to DCH (high - * data rate) state in 3G networks. */ - char fastradio_padding; - - /* accept_peer_renegotiations, if one, accepts renegotiation attempts from the - * peer. Otherwise, they will be rejected with a fatal error. */ - char accept_peer_renegotiations; - - /* These fields are always NULL and exist only to keep wpa_supplicant happy - * about the change to EVP_AEAD. They are only needed for EAP-FAST, which we - * don't support. */ - EVP_CIPHER_CTX *enc_read_ctx; - EVP_MD_CTX *read_hash; -}; - -/* compatibility */ -#define SSL_set_app_data(s, arg) (SSL_set_ex_data(s, 0, (char *)arg)) -#define SSL_get_app_data(s) (SSL_get_ex_data(s, 0)) -#define SSL_SESSION_set_app_data(s, a) \ - (SSL_SESSION_set_ex_data(s, 0, (char *)a)) -#define SSL_SESSION_get_app_data(s) (SSL_SESSION_get_ex_data(s, 0)) -#define SSL_CTX_get_app_data(ctx) (SSL_CTX_get_ex_data(ctx, 0)) -#define SSL_CTX_set_app_data(ctx, arg) \ - (SSL_CTX_set_ex_data(ctx, 0, (char *)arg)) - -/* The following are the possible values for ssl->state are are used to - * indicate where we are up to in the SSL connection establishment. The macros - * that follow are about the only things you should need to use and even then, - * only when using non-blocking IO. It can also be useful to work out where you - * were when the connection failed */ - -#define SSL_ST_CONNECT 0x1000 -#define SSL_ST_ACCEPT 0x2000 -#define SSL_ST_MASK 0x0FFF -#define SSL_ST_INIT (SSL_ST_CONNECT | SSL_ST_ACCEPT) -#define SSL_ST_OK 0x03 -#define SSL_ST_RENEGOTIATE (0x04 | SSL_ST_INIT) - -#define SSL_CB_LOOP 0x01 -#define SSL_CB_EXIT 0x02 -#define SSL_CB_READ 0x04 -#define SSL_CB_WRITE 0x08 -#define SSL_CB_ALERT 0x4000 /* used in callback */ -#define SSL_CB_READ_ALERT (SSL_CB_ALERT | SSL_CB_READ) -#define SSL_CB_WRITE_ALERT (SSL_CB_ALERT | SSL_CB_WRITE) -#define SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT | SSL_CB_LOOP) -#define SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT | SSL_CB_EXIT) -#define SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT | SSL_CB_LOOP) -#define SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT | SSL_CB_EXIT) -#define SSL_CB_HANDSHAKE_START 0x10 -#define SSL_CB_HANDSHAKE_DONE 0x20 - -/* Is the SSL_connection established? */ -#define SSL_get_state(a) SSL_state(a) -#define SSL_is_init_finished(a) (SSL_state(a) == SSL_ST_OK) -#define SSL_in_init(a) (SSL_state(a) & SSL_ST_INIT) -#define SSL_in_connect_init(a) (SSL_state(a) & SSL_ST_CONNECT) -#define SSL_in_accept_init(a) (SSL_state(a) & SSL_ST_ACCEPT) - -/* SSL_in_false_start returns one if |s| has a pending unfinished handshake that - * is in False Start. |SSL_write| may be called at this point without waiting - * for the peer, but |SSL_read| will require the handshake to be completed. */ -OPENSSL_EXPORT int SSL_in_false_start(const SSL *s); - -/* The following 2 states are kept in ssl->rstate when reads fail, - * you should not need these */ -#define SSL_ST_READ_HEADER 0xF0 -#define SSL_ST_READ_BODY 0xF1 -#define SSL_ST_READ_DONE 0xF2 - -/* Obtain latest Finished message - * -- that we sent (SSL_get_finished) - * -- that we expected from peer (SSL_get_peer_finished). - * Returns length (0 == no Finished so far), copies up to 'count' bytes. */ -OPENSSL_EXPORT size_t SSL_get_finished(const SSL *s, void *buf, size_t count); -OPENSSL_EXPORT size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count); - -/* use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 3 options - * are 'ored' with SSL_VERIFY_PEER if they are desired */ -#define SSL_VERIFY_NONE 0x00 -#define SSL_VERIFY_PEER 0x01 -#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02 -/* SSL_VERIFY_CLIENT_ONCE does nothing. */ -#define SSL_VERIFY_CLIENT_ONCE 0x04 -#define SSL_VERIFY_PEER_IF_NO_OBC 0x08 - -#define OpenSSL_add_ssl_algorithms() SSL_library_init() -#define SSLeay_add_ssl_algorithms() SSL_library_init() - -/* For backward compatibility */ -#define SSL_get_cipher(s) SSL_CIPHER_get_name(SSL_get_current_cipher(s)) -#define SSL_get_cipher_bits(s, np) \ - SSL_CIPHER_get_bits(SSL_get_current_cipher(s), np) -#define SSL_get_cipher_version(s) \ - SSL_CIPHER_get_version(SSL_get_current_cipher(s)) -#define SSL_get_cipher_name(s) SSL_CIPHER_get_name(SSL_get_current_cipher(s)) -#define SSL_get_time(a) SSL_SESSION_get_time(a) -#define SSL_set_time(a, b) SSL_SESSION_set_time((a), (b)) -#define SSL_get_timeout(a) SSL_SESSION_get_timeout(a) -#define SSL_set_timeout(a, b) SSL_SESSION_set_timeout((a), (b)) - -#define d2i_SSL_SESSION_bio(bp, s_id) \ - ASN1_d2i_bio_of(SSL_SESSION, SSL_SESSION_new, d2i_SSL_SESSION, bp, s_id) -#define i2d_SSL_SESSION_bio(bp, s_id) \ - ASN1_i2d_bio_of(SSL_SESSION, i2d_SSL_SESSION, bp, s_id) - -DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION) - -/* make_errors.go reserves error codes above 1000 for manually-assigned errors. - * This value must be kept in sync with reservedReasonCode in make_errors.h */ -#define SSL_AD_REASON_OFFSET \ - 1000 /* offset to get SSL_R_... value from SSL_AD_... */ - -/* These alert types are for SSLv3 and TLSv1 */ -#define SSL_AD_CLOSE_NOTIFY SSL3_AD_CLOSE_NOTIFY -#define SSL_AD_UNEXPECTED_MESSAGE SSL3_AD_UNEXPECTED_MESSAGE /* fatal */ -#define SSL_AD_BAD_RECORD_MAC SSL3_AD_BAD_RECORD_MAC /* fatal */ -#define SSL_AD_DECRYPTION_FAILED TLS1_AD_DECRYPTION_FAILED -#define SSL_AD_RECORD_OVERFLOW TLS1_AD_RECORD_OVERFLOW -#define SSL_AD_DECOMPRESSION_FAILURE SSL3_AD_DECOMPRESSION_FAILURE /* fatal */ -#define SSL_AD_HANDSHAKE_FAILURE SSL3_AD_HANDSHAKE_FAILURE /* fatal */ -#define SSL_AD_NO_CERTIFICATE SSL3_AD_NO_CERTIFICATE /* Not for TLS */ -#define SSL_AD_BAD_CERTIFICATE SSL3_AD_BAD_CERTIFICATE -#define SSL_AD_UNSUPPORTED_CERTIFICATE SSL3_AD_UNSUPPORTED_CERTIFICATE -#define SSL_AD_CERTIFICATE_REVOKED SSL3_AD_CERTIFICATE_REVOKED -#define SSL_AD_CERTIFICATE_EXPIRED SSL3_AD_CERTIFICATE_EXPIRED -#define SSL_AD_CERTIFICATE_UNKNOWN SSL3_AD_CERTIFICATE_UNKNOWN -#define SSL_AD_ILLEGAL_PARAMETER SSL3_AD_ILLEGAL_PARAMETER /* fatal */ -#define SSL_AD_UNKNOWN_CA TLS1_AD_UNKNOWN_CA /* fatal */ -#define SSL_AD_ACCESS_DENIED TLS1_AD_ACCESS_DENIED /* fatal */ -#define SSL_AD_DECODE_ERROR TLS1_AD_DECODE_ERROR /* fatal */ -#define SSL_AD_DECRYPT_ERROR TLS1_AD_DECRYPT_ERROR -#define SSL_AD_EXPORT_RESTRICTION TLS1_AD_EXPORT_RESTRICTION /* fatal */ -#define SSL_AD_PROTOCOL_VERSION TLS1_AD_PROTOCOL_VERSION /* fatal */ -#define SSL_AD_INSUFFICIENT_SECURITY TLS1_AD_INSUFFICIENT_SECURITY /* fatal */ -#define SSL_AD_INTERNAL_ERROR TLS1_AD_INTERNAL_ERROR /* fatal */ -#define SSL_AD_USER_CANCELLED TLS1_AD_USER_CANCELLED -#define SSL_AD_NO_RENEGOTIATION TLS1_AD_NO_RENEGOTIATION -#define SSL_AD_UNSUPPORTED_EXTENSION TLS1_AD_UNSUPPORTED_EXTENSION -#define SSL_AD_CERTIFICATE_UNOBTAINABLE TLS1_AD_CERTIFICATE_UNOBTAINABLE -#define SSL_AD_UNRECOGNIZED_NAME TLS1_AD_UNRECOGNIZED_NAME -#define SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE \ - TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE -#define SSL_AD_BAD_CERTIFICATE_HASH_VALUE TLS1_AD_BAD_CERTIFICATE_HASH_VALUE -#define SSL_AD_UNKNOWN_PSK_IDENTITY TLS1_AD_UNKNOWN_PSK_IDENTITY /* fatal */ -#define SSL_AD_INAPPROPRIATE_FALLBACK SSL3_AD_INAPPROPRIATE_FALLBACK /* fatal */ - -#define SSL_ERROR_NONE 0 -#define SSL_ERROR_SSL 1 -#define SSL_ERROR_WANT_READ 2 -#define SSL_ERROR_WANT_WRITE 3 -#define SSL_ERROR_WANT_X509_LOOKUP 4 -#define SSL_ERROR_SYSCALL 5 /* look at error stack/return value/errno */ -#define SSL_ERROR_ZERO_RETURN 6 -#define SSL_ERROR_WANT_CONNECT 7 -#define SSL_ERROR_WANT_ACCEPT 8 -#define SSL_ERROR_WANT_CHANNEL_ID_LOOKUP 9 -#define SSL_ERROR_PENDING_SESSION 11 -#define SSL_ERROR_PENDING_CERTIFICATE 12 - -#define SSL_CTRL_EXTRA_CHAIN_CERT 14 - -/* see tls1.h for macros based on these */ -#define SSL_CTRL_GET_TLSEXT_TICKET_KEYS 58 -#define SSL_CTRL_SET_TLSEXT_TICKET_KEYS 59 - -#define SSL_CTRL_SET_SRP_ARG 78 -#define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME 79 -#define SSL_CTRL_SET_TLS_EXT_SRP_STRENGTH 80 -#define SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD 81 - -#define SSL_CTRL_GET_EXTRA_CHAIN_CERTS 82 -#define SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS 83 - -#define SSL_CTRL_CHAIN 88 -#define SSL_CTRL_CHAIN_CERT 89 - -#define SSL_CTRL_GET_CURVES 90 -#define SSL_CTRL_SET_CURVES 91 -#define SSL_CTRL_SET_CURVES_LIST 92 -#define SSL_CTRL_SET_SIGALGS 97 -#define SSL_CTRL_SET_SIGALGS_LIST 98 -#define SSL_CTRL_SET_CLIENT_SIGALGS 101 -#define SSL_CTRL_SET_CLIENT_SIGALGS_LIST 102 -#define SSL_CTRL_GET_CLIENT_CERT_TYPES 103 -#define SSL_CTRL_SET_CLIENT_CERT_TYPES 104 -#define SSL_CTRL_BUILD_CERT_CHAIN 105 -#define SSL_CTRL_SET_VERIFY_CERT_STORE 106 -#define SSL_CTRL_SET_CHAIN_CERT_STORE 107 -#define SSL_CTRL_GET_SERVER_TMP_KEY 109 -#define SSL_CTRL_GET_EC_POINT_FORMATS 111 - -#define SSL_CTRL_GET_CHAIN_CERTS 115 -#define SSL_CTRL_SELECT_CURRENT_CERT 116 - -/* DTLSv1_get_timeout queries the next DTLS handshake timeout. If there is a - * timeout in progress, it sets |*out| to the time remaining and returns one. - * Otherwise, it returns zero. - * - * When the timeout expires, call |DTLSv1_handle_timeout| to handle the - * retransmit behavior. - * - * NOTE: This function must be queried again whenever the handshake state - * machine changes, including when |DTLSv1_handle_timeout| is called. */ -OPENSSL_EXPORT int DTLSv1_get_timeout(const SSL *ssl, struct timeval *out); - -/* DTLSv1_handle_timeout is called when a DTLS handshake timeout expires. If no - * timeout had expired, it returns 0. Otherwise, it retransmits the previous - * flight of handshake messages and returns 1. If too many timeouts had expired - * without progress or an error occurs, it returns -1. - * - * NOTE: The caller's external timer should be compatible with the one |ssl| - * queries within some fudge factor. Otherwise, the call will be a no-op, but - * |DTLSv1_get_timeout| will return an updated timeout. - * - * WARNING: This function breaks the usual return value convention. */ -OPENSSL_EXPORT int DTLSv1_handle_timeout(SSL *ssl); - -/* SSL_session_reused returns one if |ssl| performed an abbreviated handshake - * and zero otherwise. - * - * TODO(davidben): Hammer down the semantics of this API while a handshake, - * initial or renego, is in progress. */ -OPENSSL_EXPORT int SSL_session_reused(const SSL *ssl); - -/* SSL_total_renegotiations returns the total number of renegotiation handshakes - * peformed by |ssl|. This includes the pending renegotiation, if any. */ -OPENSSL_EXPORT int SSL_total_renegotiations(const SSL *ssl); - -/* SSL_CTX_set_tmp_dh configures |ctx| to use the group from |dh| as the group - * for DHE. Only the group is used, so |dh| needn't have a keypair. It returns - * one on success and zero on error. */ -OPENSSL_EXPORT int SSL_CTX_set_tmp_dh(SSL_CTX *ctx, const DH *dh); - -/* SSL_set_tmp_dh configures |ssl| to use the group from |dh| as the group for - * DHE. Only the group is used, so |dh| needn't have a keypair. It returns one - * on success and zero on error. */ -OPENSSL_EXPORT int SSL_set_tmp_dh(SSL *ssl, const DH *dh); - -/* SSL_CTX_set_tmp_ecdh configures |ctx| to use the curve from |ecdh| as the - * curve for ephemeral ECDH keys. For historical reasons, this API expects an - * |EC_KEY|, but only the curve is used. It returns one on success and zero on - * error. If unset, an appropriate curve will be chosen automatically. (This is - * recommended.) */ -OPENSSL_EXPORT int SSL_CTX_set_tmp_ecdh(SSL_CTX *ctx, const EC_KEY *ec_key); - -/* SSL_set_tmp_ecdh configures |ssl| to use the curve from |ecdh| as the curve - * for ephemeral ECDH keys. For historical reasons, this API expects an - * |EC_KEY|, but only the curve is used. It returns one on success and zero on - * error. If unset, an appropriate curve will be chosen automatically. (This is - * recommended.) */ -OPENSSL_EXPORT int SSL_set_tmp_ecdh(SSL *ssl, const EC_KEY *ec_key); - -/* SSL_CTX_enable_tls_channel_id either configures a TLS server to accept TLS - * client IDs from clients, or configures a client to send TLS client IDs to - * a server. It returns one. */ -OPENSSL_EXPORT int SSL_CTX_enable_tls_channel_id(SSL_CTX *ctx); - -/* SSL_enable_tls_channel_id either configures a TLS server to accept TLS - * client IDs from clients, or configure a client to send TLS client IDs to - * server. It returns one. */ -OPENSSL_EXPORT int SSL_enable_tls_channel_id(SSL *ssl); - -/* SSL_CTX_set1_tls_channel_id configures a TLS client to send a TLS Channel ID - * to compatible servers. |private_key| must be a P-256 EC key. It returns one - * on success and zero on error. */ -OPENSSL_EXPORT int SSL_CTX_set1_tls_channel_id(SSL_CTX *ctx, - EVP_PKEY *private_key); - -/* SSL_set1_tls_channel_id configures a TLS client to send a TLS Channel ID to - * compatible servers. |private_key| must be a P-256 EC key. It returns one on - * success and zero on error. */ -OPENSSL_EXPORT int SSL_set1_tls_channel_id(SSL *ssl, EVP_PKEY *private_key); - -/* SSL_get_tls_channel_id gets the client's TLS Channel ID from a server SSL* - * and copies up to the first |max_out| bytes into |out|. The Channel ID - * consists of the client's P-256 public key as an (x,y) pair where each is a - * 32-byte, big-endian field element. It returns 0 if the client didn't offer a - * Channel ID and the length of the complete Channel ID otherwise. */ -OPENSSL_EXPORT size_t SSL_get_tls_channel_id(SSL *ssl, uint8_t *out, - size_t max_out); - -#define SSL_CTX_add_extra_chain_cert(ctx, x509) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_EXTRA_CHAIN_CERT, 0, (char *)x509) -#define SSL_CTX_get_extra_chain_certs(ctx, px509) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_GET_EXTRA_CHAIN_CERTS, 0, px509) -#define SSL_CTX_get_extra_chain_certs_only(ctx, px509) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_GET_EXTRA_CHAIN_CERTS, 1, px509) -#define SSL_CTX_clear_extra_chain_certs(ctx) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS, 0, NULL) - -#define SSL_CTX_set0_chain(ctx, sk) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_CHAIN, 0, (char *)sk) -#define SSL_CTX_set1_chain(ctx, sk) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_CHAIN, 1, (char *)sk) -#define SSL_CTX_add0_chain_cert(ctx, x509) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_CHAIN_CERT, 0, (char *)x509) -#define SSL_CTX_add1_chain_cert(ctx, x509) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_CHAIN_CERT, 1, (char *)x509) -#define SSL_CTX_get0_chain_certs(ctx, px509) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_GET_CHAIN_CERTS, 0, px509) -#define SSL_CTX_clear_chain_certs(ctx) SSL_CTX_set0_chain(ctx, NULL) -#define SSL_CTX_build_cert_chain(ctx, flags) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL) -#define SSL_CTX_select_current_cert(ctx, x509) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SELECT_CURRENT_CERT, 0, (char *)x509) - -#define SSL_CTX_set0_verify_cert_store(ctx, st) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_VERIFY_CERT_STORE, 0, (char *)st) -#define SSL_CTX_set1_verify_cert_store(ctx, st) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_VERIFY_CERT_STORE, 1, (char *)st) -#define SSL_CTX_set0_chain_cert_store(ctx, st) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_CHAIN_CERT_STORE, 0, (char *)st) -#define SSL_CTX_set1_chain_cert_store(ctx, st) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_CHAIN_CERT_STORE, 1, (char *)st) - -#define SSL_set0_chain(ctx, sk) SSL_ctrl(ctx, SSL_CTRL_CHAIN, 0, (char *)sk) -#define SSL_set1_chain(ctx, sk) SSL_ctrl(ctx, SSL_CTRL_CHAIN, 1, (char *)sk) -#define SSL_add0_chain_cert(ctx, x509) \ - SSL_ctrl(ctx, SSL_CTRL_CHAIN_CERT, 0, (char *)x509) -#define SSL_add1_chain_cert(ctx, x509) \ - SSL_ctrl(ctx, SSL_CTRL_CHAIN_CERT, 1, (char *)x509) -#define SSL_get0_chain_certs(ctx, px509) \ - SSL_ctrl(ctx, SSL_CTRL_GET_CHAIN_CERTS, 0, px509) -#define SSL_clear_chain_certs(ctx) SSL_set0_chain(ctx, NULL) -#define SSL_build_cert_chain(s, flags) \ - SSL_ctrl(s, SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL) -#define SSL_select_current_cert(ctx, x509) \ - SSL_ctrl(ctx, SSL_CTRL_SELECT_CURRENT_CERT, 0, (char *)x509) - -#define SSL_set0_verify_cert_store(s, st) \ - SSL_ctrl(s, SSL_CTRL_SET_VERIFY_CERT_STORE, 0, (char *)st) -#define SSL_set1_verify_cert_store(s, st) \ - SSL_ctrl(s, SSL_CTRL_SET_VERIFY_CERT_STORE, 1, (char *)st) -#define SSL_set0_chain_cert_store(s, st) \ - SSL_ctrl(s, SSL_CTRL_SET_CHAIN_CERT_STORE, 0, (char *)st) -#define SSL_set1_chain_cert_store(s, st) \ - SSL_ctrl(s, SSL_CTRL_SET_CHAIN_CERT_STORE, 1, (char *)st) - -#define SSL_get1_curves(ctx, s) SSL_ctrl(ctx, SSL_CTRL_GET_CURVES, 0, (char *)s) -#define SSL_CTX_set1_curves(ctx, clist, clistlen) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_CURVES, clistlen, (char *)clist) -#define SSL_CTX_set1_curves_list(ctx, s) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_CURVES_LIST, 0, (char *)s) -#define SSL_set1_curves(ctx, clist, clistlen) \ - SSL_ctrl(ctx, SSL_CTRL_SET_CURVES, clistlen, (char *)clist) -#define SSL_set1_curves_list(ctx, s) \ - SSL_ctrl(ctx, SSL_CTRL_SET_CURVES_LIST, 0, (char *)s) - -#define SSL_CTX_set1_sigalgs(ctx, slist, slistlen) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_SIGALGS, slistlen, (int *)slist) -#define SSL_CTX_set1_sigalgs_list(ctx, s) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_SIGALGS_LIST, 0, (char *)s) -#define SSL_set1_sigalgs(ctx, slist, slistlen) \ - SSL_ctrl(ctx, SSL_CTRL_SET_SIGALGS, clistlen, (int *)slist) -#define SSL_set1_sigalgs_list(ctx, s) \ - SSL_ctrl(ctx, SSL_CTRL_SET_SIGALGS_LIST, 0, (char *)s) - -#define SSL_CTX_set1_client_sigalgs(ctx, slist, slistlen) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_CLIENT_SIGALGS, slistlen, (int *)slist) -#define SSL_CTX_set1_client_sigalgs_list(ctx, s) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_CLIENT_SIGALGS_LIST, 0, (char *)s) -#define SSL_set1_client_sigalgs(ctx, slist, slistlen) \ - SSL_ctrl(ctx, SSL_CTRL_SET_CLIENT_SIGALGS, clistlen, (int *)slist) -#define SSL_set1_client_sigalgs_list(ctx, s) \ - SSL_ctrl(ctx, SSL_CTRL_SET_CLIENT_SIGALGS_LIST, 0, (char *)s) - -#define SSL_get0_certificate_types(s, clist) \ - SSL_ctrl(s, SSL_CTRL_GET_CLIENT_CERT_TYPES, 0, (char *)clist) - -#define SSL_CTX_set1_client_certificate_types(ctx, clist, clistlen) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_CLIENT_CERT_TYPES, clistlen, (char *)clist) -#define SSL_set1_client_certificate_types(s, clist, clistlen) \ - SSL_ctrl(s, SSL_CTRL_SET_CLIENT_CERT_TYPES, clistlen, (char *)clist) - -#define SSL_get_server_tmp_key(s, pk) \ - SSL_ctrl(s, SSL_CTRL_GET_SERVER_TMP_KEY, 0, pk) - -#define SSL_get0_ec_point_formats(s, plst) \ - SSL_ctrl(s, SSL_CTRL_GET_EC_POINT_FORMATS, 0, (char *)plst) - -OPENSSL_EXPORT int SSL_CTX_set_cipher_list(SSL_CTX *, const char *str); -OPENSSL_EXPORT int SSL_CTX_set_cipher_list_tls11(SSL_CTX *, const char *str); -OPENSSL_EXPORT long SSL_CTX_set_timeout(SSL_CTX *ctx, long t); -OPENSSL_EXPORT long SSL_CTX_get_timeout(const SSL_CTX *ctx); -OPENSSL_EXPORT X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *); -OPENSSL_EXPORT void SSL_CTX_set_cert_store(SSL_CTX *, X509_STORE *); -OPENSSL_EXPORT int SSL_want(const SSL *s); - -OPENSSL_EXPORT void SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm); - -/* SSL_get_current_cipher returns the cipher used in the current outgoing - * connection state, or NULL if the null cipher is active. */ -OPENSSL_EXPORT const SSL_CIPHER *SSL_get_current_cipher(const SSL *s); - -OPENSSL_EXPORT int SSL_get_fd(const SSL *s); -OPENSSL_EXPORT int SSL_get_rfd(const SSL *s); -OPENSSL_EXPORT int SSL_get_wfd(const SSL *s); -OPENSSL_EXPORT const char *SSL_get_cipher_list(const SSL *s, int n); -OPENSSL_EXPORT int SSL_pending(const SSL *s); -OPENSSL_EXPORT int SSL_set_fd(SSL *s, int fd); -OPENSSL_EXPORT int SSL_set_rfd(SSL *s, int fd); -OPENSSL_EXPORT int SSL_set_wfd(SSL *s, int fd); -OPENSSL_EXPORT void SSL_set_bio(SSL *s, BIO *rbio, BIO *wbio); -OPENSSL_EXPORT BIO *SSL_get_rbio(const SSL *s); -OPENSSL_EXPORT BIO *SSL_get_wbio(const SSL *s); -OPENSSL_EXPORT int SSL_set_cipher_list(SSL *s, const char *str); -OPENSSL_EXPORT int SSL_get_verify_mode(const SSL *s); -OPENSSL_EXPORT int SSL_get_verify_depth(const SSL *s); -OPENSSL_EXPORT int (*SSL_get_verify_callback(const SSL *s))(int, - X509_STORE_CTX *); -OPENSSL_EXPORT void SSL_set_verify(SSL *s, int mode, - int (*callback)(int ok, - X509_STORE_CTX *ctx)); -OPENSSL_EXPORT void SSL_set_verify_depth(SSL *s, int depth); -OPENSSL_EXPORT void SSL_set_cert_cb(SSL *s, int (*cb)(SSL *ssl, void *arg), - void *arg); -OPENSSL_EXPORT int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa); -OPENSSL_EXPORT int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, uint8_t *d, long len); -OPENSSL_EXPORT int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey); -OPENSSL_EXPORT int SSL_use_PrivateKey_ASN1(int pk, SSL *ssl, const uint8_t *d, - long len); -OPENSSL_EXPORT int SSL_use_certificate(SSL *ssl, X509 *x); -OPENSSL_EXPORT int SSL_use_certificate_ASN1(SSL *ssl, const uint8_t *d, - int len); - -OPENSSL_EXPORT int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, - int type); -OPENSSL_EXPORT int SSL_use_PrivateKey_file(SSL *ssl, const char *file, - int type); -OPENSSL_EXPORT int SSL_use_certificate_file(SSL *ssl, const char *file, - int type); -OPENSSL_EXPORT int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, - const char *file, int type); -OPENSSL_EXPORT int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, - int type); -OPENSSL_EXPORT int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, - int type); -OPENSSL_EXPORT int SSL_CTX_use_certificate_chain_file( - SSL_CTX *ctx, const char *file); /* PEM type */ -OPENSSL_EXPORT STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file); -OPENSSL_EXPORT int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) * - stackCAs, - const char *file); -OPENSSL_EXPORT int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) * - stackCAs, - const char *dir); - -/* SSL_load_error_strings does nothing. */ -OPENSSL_EXPORT void SSL_load_error_strings(void); - -OPENSSL_EXPORT const char *SSL_state_string(const SSL *s); -OPENSSL_EXPORT const char *SSL_rstate_string(const SSL *s); -OPENSSL_EXPORT const char *SSL_state_string_long(const SSL *s); -OPENSSL_EXPORT const char *SSL_rstate_string_long(const SSL *s); -OPENSSL_EXPORT long SSL_SESSION_get_time(const SSL_SESSION *s); -OPENSSL_EXPORT long SSL_SESSION_set_time(SSL_SESSION *s, long t); -OPENSSL_EXPORT long SSL_SESSION_get_timeout(const SSL_SESSION *s); -OPENSSL_EXPORT long SSL_SESSION_set_timeout(SSL_SESSION *s, long t); -OPENSSL_EXPORT X509 *SSL_SESSION_get0_peer(SSL_SESSION *s); -OPENSSL_EXPORT int SSL_SESSION_set1_id_context(SSL_SESSION *s, - const uint8_t *sid_ctx, - unsigned int sid_ctx_len); - -OPENSSL_EXPORT SSL_SESSION *SSL_SESSION_new(void); -OPENSSL_EXPORT const uint8_t *SSL_SESSION_get_id(const SSL_SESSION *s, - unsigned int *len); -OPENSSL_EXPORT int SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *ses); -OPENSSL_EXPORT int SSL_SESSION_print(BIO *fp, const SSL_SESSION *ses); - -/* SSL_SESSION_up_ref, if |session| is not NULL, increments the reference count - * of |session|. It then returns |session|. */ -OPENSSL_EXPORT SSL_SESSION *SSL_SESSION_up_ref(SSL_SESSION *session); - -/* SSL_SESSION_free decrements the reference count of |session|. If it reaches - * zero, all data referenced by |session| and |session| itself are released. */ -OPENSSL_EXPORT void SSL_SESSION_free(SSL_SESSION *session); - -OPENSSL_EXPORT int SSL_set_session(SSL *to, SSL_SESSION *session); -OPENSSL_EXPORT int SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c); -OPENSSL_EXPORT int SSL_CTX_remove_session(SSL_CTX *, SSL_SESSION *c); -OPENSSL_EXPORT int SSL_CTX_set_generate_session_id(SSL_CTX *, GEN_SESSION_CB); -OPENSSL_EXPORT int SSL_set_generate_session_id(SSL *, GEN_SESSION_CB); -OPENSSL_EXPORT int SSL_has_matching_session_id(const SSL *ssl, - const uint8_t *id, - unsigned int id_len); - -/* SSL_SESSION_to_bytes serializes |in| into a newly allocated buffer and sets - * |*out_data| to that buffer and |*out_len| to its length. The caller takes - * ownership of the buffer and must call |OPENSSL_free| when done. It returns - * one on success and zero on error. */ -OPENSSL_EXPORT int SSL_SESSION_to_bytes(SSL_SESSION *in, uint8_t **out_data, - size_t *out_len); - -/* SSL_SESSION_to_bytes_for_ticket serializes |in|, but excludes the session ID - * which is not necessary in a session ticket. */ -OPENSSL_EXPORT int SSL_SESSION_to_bytes_for_ticket(SSL_SESSION *in, - uint8_t **out_data, - size_t *out_len); - -/* Deprecated: i2d_SSL_SESSION serializes |in| to the bytes pointed to by - * |*pp|. On success, it returns the number of bytes written and advances |*pp| - * by that many bytes. On failure, it returns -1. If |pp| is NULL, no bytes are - * written and only the length is returned. - * - * Use SSL_SESSION_to_bytes instead. */ -OPENSSL_EXPORT int i2d_SSL_SESSION(SSL_SESSION *in, uint8_t **pp); - -/* d2i_SSL_SESSION deserializes a serialized buffer contained in the |length| - * bytes pointed to by |*pp|. It returns the new SSL_SESSION and advances |*pp| - * by the number of bytes consumed on success and NULL on failure. If |a| is - * NULL, the caller takes ownership of the new session and must call - * |SSL_SESSION_free| when done. - * - * If |a| and |*a| are not NULL, the SSL_SESSION at |*a| is overridden with the - * deserialized session rather than allocating a new one. In addition, |a| is - * not NULL, but |*a| is, |*a| is set to the new SSL_SESSION. - * - * Passing a value other than NULL to |a| is deprecated. */ -OPENSSL_EXPORT SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const uint8_t **pp, - long length); - -OPENSSL_EXPORT X509 *SSL_get_peer_certificate(const SSL *s); - -OPENSSL_EXPORT STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s); - -OPENSSL_EXPORT int SSL_CTX_get_verify_mode(const SSL_CTX *ctx); -OPENSSL_EXPORT int SSL_CTX_get_verify_depth(const SSL_CTX *ctx); -OPENSSL_EXPORT int (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))( - int, X509_STORE_CTX *); -OPENSSL_EXPORT void SSL_CTX_set_verify(SSL_CTX *ctx, int mode, - int (*callback)(int, X509_STORE_CTX *)); -OPENSSL_EXPORT void SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth); -OPENSSL_EXPORT void SSL_CTX_set_cert_verify_callback( - SSL_CTX *ctx, int (*cb)(X509_STORE_CTX *, void *), void *arg); -OPENSSL_EXPORT void SSL_CTX_set_cert_cb(SSL_CTX *c, - int (*cb)(SSL *ssl, void *arg), - void *arg); -OPENSSL_EXPORT int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa); -OPENSSL_EXPORT int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, - const uint8_t *d, long len); -OPENSSL_EXPORT int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey); -OPENSSL_EXPORT int SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx, - const uint8_t *d, long len); -OPENSSL_EXPORT int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x); -OPENSSL_EXPORT int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, - const uint8_t *d); - -OPENSSL_EXPORT void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, - pem_password_cb *cb); -OPENSSL_EXPORT void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, - void *u); - -OPENSSL_EXPORT int SSL_CTX_check_private_key(const SSL_CTX *ctx); -OPENSSL_EXPORT int SSL_check_private_key(const SSL *ctx); - -OPENSSL_EXPORT int SSL_CTX_set_session_id_context(SSL_CTX *ctx, - const uint8_t *sid_ctx, - unsigned int sid_ctx_len); - -OPENSSL_EXPORT int SSL_set_session_id_context(SSL *ssl, const uint8_t *sid_ctx, - unsigned int sid_ctx_len); - -OPENSSL_EXPORT int SSL_CTX_set_purpose(SSL_CTX *s, int purpose); -OPENSSL_EXPORT int SSL_set_purpose(SSL *s, int purpose); -OPENSSL_EXPORT int SSL_CTX_set_trust(SSL_CTX *s, int trust); -OPENSSL_EXPORT int SSL_set_trust(SSL *s, int trust); - -OPENSSL_EXPORT int SSL_CTX_set1_param(SSL_CTX *ctx, X509_VERIFY_PARAM *vpm); -OPENSSL_EXPORT int SSL_set1_param(SSL *ssl, X509_VERIFY_PARAM *vpm); - -OPENSSL_EXPORT X509_VERIFY_PARAM *SSL_CTX_get0_param(SSL_CTX *ctx); -OPENSSL_EXPORT X509_VERIFY_PARAM *SSL_get0_param(SSL *ssl); - -OPENSSL_EXPORT void SSL_certs_clear(SSL *s); -OPENSSL_EXPORT int SSL_accept(SSL *ssl); -OPENSSL_EXPORT int SSL_connect(SSL *ssl); -OPENSSL_EXPORT int SSL_read(SSL *ssl, void *buf, int num); -OPENSSL_EXPORT int SSL_peek(SSL *ssl, void *buf, int num); -OPENSSL_EXPORT int SSL_write(SSL *ssl, const void *buf, int num); -OPENSSL_EXPORT long SSL_ctrl(SSL *ssl, int cmd, long larg, void *parg); -OPENSSL_EXPORT long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg); - -OPENSSL_EXPORT int SSL_get_error(const SSL *s, int ret_code); -/* SSL_get_version returns a string describing the TLS version used by |s|. For - * example, "TLSv1.2" or "SSLv3". */ -OPENSSL_EXPORT const char *SSL_get_version(const SSL *s); -/* SSL_SESSION_get_version returns a string describing the TLS version used by - * |sess|. For example, "TLSv1.2" or "SSLv3". */ -OPENSSL_EXPORT const char *SSL_SESSION_get_version(const SSL_SESSION *sess); - -OPENSSL_EXPORT STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s); - -OPENSSL_EXPORT int SSL_do_handshake(SSL *s); - -/* SSL_renegotiate_pending returns one if |ssl| is in the middle of a - * renegotiation. */ -OPENSSL_EXPORT int SSL_renegotiate_pending(SSL *ssl); - -OPENSSL_EXPORT int SSL_shutdown(SSL *s); - -OPENSSL_EXPORT const char *SSL_alert_type_string_long(int value); -OPENSSL_EXPORT const char *SSL_alert_type_string(int value); -OPENSSL_EXPORT const char *SSL_alert_desc_string_long(int value); -OPENSSL_EXPORT const char *SSL_alert_desc_string(int value); - -OPENSSL_EXPORT void SSL_set_client_CA_list(SSL *s, - STACK_OF(X509_NAME) *name_list); -OPENSSL_EXPORT void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, - STACK_OF(X509_NAME) *name_list); -OPENSSL_EXPORT STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s); -OPENSSL_EXPORT STACK_OF(X509_NAME) * - SSL_CTX_get_client_CA_list(const SSL_CTX *s); -OPENSSL_EXPORT int SSL_add_client_CA(SSL *ssl, X509 *x); -OPENSSL_EXPORT int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x); - -OPENSSL_EXPORT long SSL_get_default_timeout(const SSL *s); - -OPENSSL_EXPORT STACK_OF(X509_NAME) *SSL_dup_CA_list(STACK_OF(X509_NAME) *sk); - -OPENSSL_EXPORT X509 *SSL_get_certificate(const SSL *ssl); -OPENSSL_EXPORT EVP_PKEY *SSL_get_privatekey(const SSL *ssl); - -OPENSSL_EXPORT X509 *SSL_CTX_get0_certificate(const SSL_CTX *ctx); -OPENSSL_EXPORT EVP_PKEY *SSL_CTX_get0_privatekey(const SSL_CTX *ctx); - -OPENSSL_EXPORT void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode); -OPENSSL_EXPORT int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx); -OPENSSL_EXPORT void SSL_set_quiet_shutdown(SSL *ssl, int mode); -OPENSSL_EXPORT int SSL_get_quiet_shutdown(const SSL *ssl); -OPENSSL_EXPORT void SSL_set_shutdown(SSL *ssl, int mode); -OPENSSL_EXPORT int SSL_get_shutdown(const SSL *ssl); -OPENSSL_EXPORT int SSL_version(const SSL *ssl); -OPENSSL_EXPORT int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx); -OPENSSL_EXPORT int SSL_CTX_load_verify_locations(SSL_CTX *ctx, - const char *CAfile, - const char *CApath); -#define SSL_get0_session SSL_get_session /* just peek at pointer */ -OPENSSL_EXPORT SSL_SESSION *SSL_get_session(const SSL *ssl); -OPENSSL_EXPORT SSL_SESSION *SSL_get1_session( - SSL *ssl); /* obtain a reference count */ -OPENSSL_EXPORT SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl); -OPENSSL_EXPORT SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx); -OPENSSL_EXPORT void SSL_set_info_callback(SSL *ssl, - void (*cb)(const SSL *ssl, int type, - int val)); -OPENSSL_EXPORT void (*SSL_get_info_callback(const SSL *ssl))(const SSL *ssl, - int type, int val); -OPENSSL_EXPORT int SSL_state(const SSL *ssl); - -OPENSSL_EXPORT void SSL_set_verify_result(SSL *ssl, long v); -OPENSSL_EXPORT long SSL_get_verify_result(const SSL *ssl); - -OPENSSL_EXPORT int SSL_set_ex_data(SSL *ssl, int idx, void *data); -OPENSSL_EXPORT void *SSL_get_ex_data(const SSL *ssl, int idx); -OPENSSL_EXPORT int SSL_get_ex_new_index(long argl, void *argp, - CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, - CRYPTO_EX_free *free_func); - -OPENSSL_EXPORT int SSL_SESSION_set_ex_data(SSL_SESSION *ss, int idx, - void *data); -OPENSSL_EXPORT void *SSL_SESSION_get_ex_data(const SSL_SESSION *ss, int idx); -OPENSSL_EXPORT int SSL_SESSION_get_ex_new_index(long argl, void *argp, - CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, - CRYPTO_EX_free *free_func); - -OPENSSL_EXPORT int SSL_CTX_set_ex_data(SSL_CTX *ssl, int idx, void *data); -OPENSSL_EXPORT void *SSL_CTX_get_ex_data(const SSL_CTX *ssl, int idx); -OPENSSL_EXPORT int SSL_CTX_get_ex_new_index(long argl, void *argp, - CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, - CRYPTO_EX_free *free_func); - -OPENSSL_EXPORT int SSL_get_ex_data_X509_STORE_CTX_idx(void); - -/* SSL_CTX_sess_set_cache_size sets the maximum size of |ctx|'s session cache to - * |size|. It returns the previous value. */ -OPENSSL_EXPORT unsigned long SSL_CTX_sess_set_cache_size(SSL_CTX *ctx, - unsigned long size); - -/* SSL_CTX_sess_get_cache_size returns the maximum size of |ctx|'s session - * cache. */ -OPENSSL_EXPORT unsigned long SSL_CTX_sess_get_cache_size(const SSL_CTX *ctx); - -/* SSL_SESS_CACHE_* are the possible session cache mode bits. - * TODO(davidben): Document. */ -#define SSL_SESS_CACHE_OFF 0x0000 -#define SSL_SESS_CACHE_CLIENT 0x0001 -#define SSL_SESS_CACHE_SERVER 0x0002 -#define SSL_SESS_CACHE_BOTH (SSL_SESS_CACHE_CLIENT | SSL_SESS_CACHE_SERVER) -#define SSL_SESS_CACHE_NO_AUTO_CLEAR 0x0080 -#define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100 -#define SSL_SESS_CACHE_NO_INTERNAL_STORE 0x0200 -#define SSL_SESS_CACHE_NO_INTERNAL \ - (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP | SSL_SESS_CACHE_NO_INTERNAL_STORE) - -/* SSL_CTX_set_session_cache_mode sets the session cache mode bits for |ctx| to - * |mode|. It returns the previous value. */ -OPENSSL_EXPORT int SSL_CTX_set_session_cache_mode(SSL_CTX *ctx, int mode); - -/* SSL_CTX_get_session_cache_mode returns the session cache mode bits for - * |ctx| */ -OPENSSL_EXPORT int SSL_CTX_get_session_cache_mode(const SSL_CTX *ctx); - -/* SSL_CTX_get_max_cert_list returns the maximum length, in bytes, of a peer - * certificate chain accepted by |ctx|. */ -OPENSSL_EXPORT size_t SSL_CTX_get_max_cert_list(const SSL_CTX *ctx); - -/* SSL_CTX_set_max_cert_list sets the maximum length, in bytes, of a peer - * certificate chain to |max_cert_list|. This affects how much memory may be - * consumed during the handshake. */ -OPENSSL_EXPORT void SSL_CTX_set_max_cert_list(SSL_CTX *ctx, - size_t max_cert_list); - -/* SSL_get_max_cert_list returns the maximum length, in bytes, of a peer - * certificate chain accepted by |ssl|. */ -OPENSSL_EXPORT size_t SSL_get_max_cert_list(const SSL *ssl); - -/* SSL_set_max_cert_list sets the maximum length, in bytes, of a peer - * certificate chain to |max_cert_list|. This affects how much memory may be - * consumed during the handshake. */ -OPENSSL_EXPORT void SSL_set_max_cert_list(SSL *ssl, size_t max_cert_list); - -/* SSL_CTX_set_max_send_fragment sets the maximum length, in bytes, of records - * sent by |ctx|. Beyond this length, handshake messages and application data - * will be split into multiple records. */ -OPENSSL_EXPORT void SSL_CTX_set_max_send_fragment(SSL_CTX *ctx, - size_t max_send_fragment); - -/* SSL_set_max_send_fragment sets the maximum length, in bytes, of records - * sent by |ssl|. Beyond this length, handshake messages and application data - * will be split into multiple records. */ -OPENSSL_EXPORT void SSL_set_max_send_fragment(SSL *ssl, - size_t max_send_fragment); - -/* SSL_CTX_set_tmp_dh_callback configures |ctx| to use |callback| to determine - * the group for DHE ciphers. |callback| should ignore |is_export| and - * |keylength| and return a |DH| of the selected group or NULL on error. Only - * the parameters are used, so the |DH| needn't have a generated keypair. - * - * WARNING: The caller does not take ownership of the resulting |DH|, so - * |callback| must save and release the object elsewhere. */ -OPENSSL_EXPORT void SSL_CTX_set_tmp_dh_callback( - SSL_CTX *ctx, DH *(*callback)(SSL *ssl, int is_export, int keylength)); - -/* SSL_set_tmp_dh_callback configures |ssl| to use |callback| to determine the - * group for DHE ciphers. |callback| should ignore |is_export| and |keylength| - * and return a |DH| of the selected group or NULL on error. Only the - * parameters are used, so the |DH| needn't have a generated keypair. - * - * WARNING: The caller does not take ownership of the resulting |DH|, so - * |callback| must save and release the object elsewhere. */ -OPENSSL_EXPORT void SSL_set_tmp_dh_callback(SSL *ssl, - DH *(*dh)(SSL *ssl, int is_export, - int keylength)); - -/* SSL_CTX_set_tmp_ecdh_callback configures |ctx| to use |callback| to determine - * the curve for ephemeral ECDH keys. |callback| should ignore |is_export| and - * |keylength| and return an |EC_KEY| of the selected curve or NULL on - * error. Only the curve is used, so the |EC_KEY| needn't have a generated - * keypair. - * - * If the callback is unset, an appropriate curve will be chosen automatically. - * (This is recommended.) - * - * WARNING: The caller does not take ownership of the resulting |EC_KEY|, so - * |callback| must save and release the object elsewhere. */ -OPENSSL_EXPORT void SSL_CTX_set_tmp_ecdh_callback( - SSL_CTX *ctx, EC_KEY *(*callback)(SSL *ssl, int is_export, int keylength)); - -/* SSL_set_tmp_ecdh_callback configures |ssl| to use |callback| to determine the - * curve for ephemeral ECDH keys. |callback| should ignore |is_export| and - * |keylength| and return an |EC_KEY| of the selected curve or NULL on - * error. Only the curve is used, so the |EC_KEY| needn't have a generated - * keypair. - * - * If the callback is unset, an appropriate curve will be chosen automatically. - * (This is recommended.) - * - * WARNING: The caller does not take ownership of the resulting |EC_KEY|, so - * |callback| must save and release the object elsewhere. */ -OPENSSL_EXPORT void SSL_set_tmp_ecdh_callback( - SSL *ssl, EC_KEY *(*callback)(SSL *ssl, int is_export, int keylength)); - -OPENSSL_EXPORT const void *SSL_get_current_compression(SSL *s); -OPENSSL_EXPORT const void *SSL_get_current_expansion(SSL *s); - -OPENSSL_EXPORT int SSL_cache_hit(SSL *s); -OPENSSL_EXPORT int SSL_is_server(SSL *s); - -/* SSL_CTX_set_dos_protection_cb sets a callback that is called once the - * resumption decision for a ClientHello has been made. It can return 1 to - * allow the handshake to continue or zero to cause the handshake to abort. */ -OPENSSL_EXPORT void SSL_CTX_set_dos_protection_cb( - SSL_CTX *ctx, int (*cb)(const struct ssl_early_callback_ctx *)); - -/* SSL_get_structure_sizes returns the sizes of the SSL, SSL_CTX and - * SSL_SESSION structures so that a test can ensure that outside code agrees on - * these values. */ -OPENSSL_EXPORT void SSL_get_structure_sizes(size_t *ssl_size, - size_t *ssl_ctx_size, - size_t *ssl_session_size); - -OPENSSL_EXPORT void ERR_load_SSL_strings(void); - -/* SSL_get_rc4_state sets |*read_key| and |*write_key| to the RC4 states for - * the read and write directions. It returns one on success or zero if |ssl| - * isn't using an RC4-based cipher suite. */ -OPENSSL_EXPORT int SSL_get_rc4_state(const SSL *ssl, const RC4_KEY **read_key, - const RC4_KEY **write_key); - - -/* Deprecated functions. */ - -/* SSL_CIPHER_description writes a description of |cipher| into |buf| and - * returns |buf|. If |buf| is NULL, it returns a newly allocated string, to be - * freed with |OPENSSL_free|, or NULL on error. - * - * The description includes a trailing newline and has the form: - * AES128-SHA SSLv3 Kx=RSA Au=RSA Enc=AES(128) Mac=SHA1 - * - * Consider |SSL_CIPHER_get_name| or |SSL_CIPHER_get_rfc_name| instead. */ -OPENSSL_EXPORT const char *SSL_CIPHER_description(const SSL_CIPHER *cipher, - char *buf, int len); - -/* SSL_CIPHER_get_version returns the string "TLSv1/SSLv3". */ -OPENSSL_EXPORT const char *SSL_CIPHER_get_version(const SSL_CIPHER *cipher); - -/* SSL_COMP_get_compression_methods returns NULL. */ -OPENSSL_EXPORT void *SSL_COMP_get_compression_methods(void); - -/* SSL_COMP_add_compression_method returns one. */ -OPENSSL_EXPORT int SSL_COMP_add_compression_method(int id, void *cm); - -/* SSL_COMP_get_name returns NULL. */ -OPENSSL_EXPORT const char *SSL_COMP_get_name(const void *comp); - -/* SSLv23_method calls |TLS_method|. */ -OPENSSL_EXPORT const SSL_METHOD *SSLv23_method(void); - -/* Version-specific methods behave exactly like |TLS_method| and |DTLS_method| - * except they also call |SSL_CTX_set_min_version| and |SSL_CTX_set_max_version| - * to lock connections to that protocol version. */ -OPENSSL_EXPORT const SSL_METHOD *SSLv3_method(void); -OPENSSL_EXPORT const SSL_METHOD *TLSv1_method(void); -OPENSSL_EXPORT const SSL_METHOD *TLSv1_1_method(void); -OPENSSL_EXPORT const SSL_METHOD *TLSv1_2_method(void); -OPENSSL_EXPORT const SSL_METHOD *DTLSv1_method(void); -OPENSSL_EXPORT const SSL_METHOD *DTLSv1_2_method(void); - -/* Client- and server-specific methods call their corresponding generic - * methods. */ -OPENSSL_EXPORT const SSL_METHOD *SSLv23_server_method(void); -OPENSSL_EXPORT const SSL_METHOD *SSLv23_client_method(void); -OPENSSL_EXPORT const SSL_METHOD *SSLv3_server_method(void); -OPENSSL_EXPORT const SSL_METHOD *SSLv3_client_method(void); -OPENSSL_EXPORT const SSL_METHOD *TLSv1_server_method(void); -OPENSSL_EXPORT const SSL_METHOD *TLSv1_client_method(void); -OPENSSL_EXPORT const SSL_METHOD *TLSv1_1_server_method(void); -OPENSSL_EXPORT const SSL_METHOD *TLSv1_1_client_method(void); -OPENSSL_EXPORT const SSL_METHOD *TLSv1_2_server_method(void); -OPENSSL_EXPORT const SSL_METHOD *TLSv1_2_client_method(void); -OPENSSL_EXPORT const SSL_METHOD *DTLS_server_method(void); -OPENSSL_EXPORT const SSL_METHOD *DTLS_client_method(void); -OPENSSL_EXPORT const SSL_METHOD *DTLSv1_server_method(void); -OPENSSL_EXPORT const SSL_METHOD *DTLSv1_client_method(void); -OPENSSL_EXPORT const SSL_METHOD *DTLSv1_2_server_method(void); -OPENSSL_EXPORT const SSL_METHOD *DTLSv1_2_client_method(void); - -/* SSL_clear resets |ssl| to allow another connection and returns one on success - * or zero on failure. It returns most configuration state but releases memory - * associated with the current connection. - * - * Free |ssl| and create a new one instead. */ -OPENSSL_EXPORT int SSL_clear(SSL *ssl); - -/* SSL_CTX_set_tmp_rsa_callback does nothing. */ -OPENSSL_EXPORT void SSL_CTX_set_tmp_rsa_callback( - SSL_CTX *ctx, RSA *(*cb)(SSL *ssl, int is_export, int keylength)); - -/* SSL_set_tmp_rsa_callback does nothing. */ -OPENSSL_EXPORT void SSL_set_tmp_rsa_callback(SSL *ssl, - RSA *(*cb)(SSL *ssl, int is_export, - int keylength)); - -/* SSL_CTX_sess_connect returns zero. */ -OPENSSL_EXPORT int SSL_CTX_sess_connect(const SSL_CTX *ctx); - -/* SSL_CTX_sess_connect_good returns zero. */ -OPENSSL_EXPORT int SSL_CTX_sess_connect_good(const SSL_CTX *ctx); - -/* SSL_CTX_sess_connect_renegotiate returns zero. */ -OPENSSL_EXPORT int SSL_CTX_sess_connect_renegotiate(const SSL_CTX *ctx); - -/* SSL_CTX_sess_accept returns zero. */ -OPENSSL_EXPORT int SSL_CTX_sess_accept(const SSL_CTX *ctx); - -/* SSL_CTX_sess_accept_renegotiate returns zero. */ -OPENSSL_EXPORT int SSL_CTX_sess_accept_renegotiate(const SSL_CTX *ctx); - -/* SSL_CTX_sess_accept_good returns zero. */ -OPENSSL_EXPORT int SSL_CTX_sess_accept_good(const SSL_CTX *ctx); - -/* SSL_CTX_sess_hits returns zero. */ -OPENSSL_EXPORT int SSL_CTX_sess_hits(const SSL_CTX *ctx); - -/* SSL_CTX_sess_cb_hits returns zero. */ -OPENSSL_EXPORT int SSL_CTX_sess_cb_hits(const SSL_CTX *ctx); - -/* SSL_CTX_sess_misses returns zero. */ -OPENSSL_EXPORT int SSL_CTX_sess_misses(const SSL_CTX *ctx); - -/* SSL_CTX_sess_timeouts returns zero. */ -OPENSSL_EXPORT int SSL_CTX_sess_timeouts(const SSL_CTX *ctx); - -/* SSL_CTX_sess_cache_full returns zero. */ -OPENSSL_EXPORT int SSL_CTX_sess_cache_full(const SSL_CTX *ctx); - -/* SSL_cutthrough_complete calls |SSL_in_false_start|. */ -OPENSSL_EXPORT int SSL_cutthrough_complete(const SSL *s); - -/* SSL_num_renegotiations calls |SSL_total_renegotiations|. */ -OPENSSL_EXPORT int SSL_num_renegotiations(const SSL *ssl); - -/* SSL_CTX_need_tmp_RSA returns zero. */ -OPENSSL_EXPORT int SSL_CTX_need_tmp_RSA(const SSL_CTX *ctx); - -/* SSL_need_tmp_RSA returns zero. */ -OPENSSL_EXPORT int SSL_need_tmp_RSA(const SSL *ssl); - -/* SSL_CTX_set_tmp_rsa returns one. */ -OPENSSL_EXPORT int SSL_CTX_set_tmp_rsa(SSL_CTX *ctx, const RSA *rsa); - -/* SSL_set_tmp_rsa returns one. */ -OPENSSL_EXPORT int SSL_set_tmp_rsa(SSL *ssl, const RSA *rsa); - -/* SSL_CTX_get_read_head returns zero. */ -OPENSSL_EXPORT int SSL_CTX_get_read_ahead(const SSL_CTX *ctx); - -/* SSL_CTX_set_read_ahead does nothing. */ -OPENSSL_EXPORT void SSL_CTX_set_read_ahead(SSL_CTX *ctx, int yes); - -/* SSL_get_read_head returns zero. */ -OPENSSL_EXPORT int SSL_get_read_ahead(const SSL *s); - -/* SSL_set_read_ahead does nothing. */ -OPENSSL_EXPORT void SSL_set_read_ahead(SSL *s, int yes); - -/* SSL_renegotiate put an error on the error queue and returns zero. */ -OPENSSL_EXPORT int SSL_renegotiate(SSL *ssl); - -/* SSL_set_state does nothing. */ -OPENSSL_EXPORT void SSL_set_state(SSL *ssl, int state); - - -/* Android compatibility section. - * - * These functions are declared, temporarily, for Android because - * wpa_supplicant will take a little time to sync with upstream. Outside of - * Android they'll have no definition. */ - -#define SSL_F_SSL_SET_SESSION_TICKET_EXT doesnt_exist - -OPENSSL_EXPORT int SSL_set_session_ticket_ext(SSL *s, void *ext_data, - int ext_len); -OPENSSL_EXPORT int SSL_set_session_secret_cb(SSL *s, void *cb, void *arg); -OPENSSL_EXPORT int SSL_set_session_ticket_ext_cb(SSL *s, void *cb, void *arg); -OPENSSL_EXPORT int SSL_set_ssl_method(SSL *s, const SSL_METHOD *method); - -#define OPENSSL_VERSION_TEXT "BoringSSL" - -#define SSLEAY_VERSION 0 - -/* SSLeay_version is a compatibility function that returns the string - * "BoringSSL". */ -OPENSSL_EXPORT const char *SSLeay_version(int unused); - - -/* Preprocessor compatibility section. - * - * Historically, a number of APIs were implemented in OpenSSL as macros and - * constants to 'ctrl' functions. To avoid breaking #ifdefs in consumers, this - * section defines a number of legacy macros. */ - -#define SSL_CTRL_NEED_TMP_RSA doesnt_exist -#define SSL_CTRL_SET_TMP_RSA doesnt_exist -#define SSL_CTRL_SET_TMP_DH doesnt_exist -#define SSL_CTRL_SET_TMP_ECDH doesnt_exist -#define SSL_CTRL_SET_TMP_RSA_CB doesnt_exist -#define SSL_CTRL_SET_TMP_DH_CB doesnt_exist -#define SSL_CTRL_SET_TMP_ECDH_CB doesnt_exist -#define SSL_CTRL_GET_SESSION_REUSED doesnt_exist -#define SSL_CTRL_GET_NUM_RENEGOTIATIONS doesnt_exist -#define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS doesnt_exist -#define SSL_CTRL_SET_MSG_CALLBACK doesnt_exist -#define SSL_CTRL_SET_MSG_CALLBACK_ARG doesnt_exist -#define SSL_CTRL_SET_MTU doesnt_exist -#define SSL_CTRL_SESS_NUMBER doesnt_exist -#define SSL_CTRL_OPTIONS doesnt_exist -#define SSL_CTRL_MODE doesnt_exist -#define SSL_CTRL_GET_READ_AHEAD doesnt_exist -#define SSL_CTRL_SET_READ_AHEAD doesnt_exist -#define SSL_CTRL_SET_SESS_CACHE_SIZE doesnt_exist -#define SSL_CTRL_GET_SESS_CACHE_SIZE doesnt_exist -#define SSL_CTRL_SET_SESS_CACHE_MODE doesnt_exist -#define SSL_CTRL_GET_SESS_CACHE_MODE doesnt_exist -#define SSL_CTRL_GET_MAX_CERT_LIST doesnt_exist -#define SSL_CTRL_SET_MAX_CERT_LIST doesnt_exist -#define SSL_CTRL_SET_MAX_SEND_FRAGMENT doesnt_exist -#define SSL_CTRL_SET_TLSEXT_SERVERNAME_CB doesnt_exist -#define SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG doesnt_exist -#define SSL_CTRL_SET_TLSEXT_HOSTNAME doesnt_exist -#define SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB doesnt_exist -#define DTLS_CTRL_GET_TIMEOUT doesnt_exist -#define DTLS_CTRL_HANDLE_TIMEOUT doesnt_exist -#define SSL_CTRL_GET_RI_SUPPORT doesnt_exist -#define SSL_CTRL_CLEAR_OPTIONS doesnt_exist -#define SSL_CTRL_CLEAR_MODE doesnt_exist -#define SSL_CTRL_CHANNEL_ID doesnt_exist -#define SSL_CTRL_GET_CHANNEL_ID doesnt_exist -#define SSL_CTRL_SET_CHANNEL_ID doesnt_exist - -#define SSL_CTX_need_tmp_RSA SSL_CTX_need_tmp_RSA -#define SSL_need_tmp_RSA SSL_need_tmp_RSA -#define SSL_CTX_set_tmp_rsa SSL_CTX_set_tmp_rsa -#define SSL_set_tmp_rsa SSL_set_tmp_rsa -#define SSL_CTX_set_tmp_dh SSL_CTX_set_tmp_dh -#define SSL_set_tmp_dh SSL_set_tmp_dh -#define SSL_CTX_set_tmp_ecdh SSL_CTX_set_tmp_ecdh -#define SSL_set_tmp_ecdh SSL_set_tmp_ecdh -#define SSL_session_reused SSL_session_reused -#define SSL_num_renegotiations SSL_num_renegotiations -#define SSL_total_renegotiations SSL_total_renegotiations -#define SSL_CTX_set_msg_callback_arg SSL_CTX_set_msg_callback_arg -#define SSL_set_msg_callback_arg SSL_set_msg_callback_arg -#define SSL_set_mtu SSL_set_mtu -#define SSL_CTX_sess_number SSL_CTX_sess_number -#define SSL_CTX_get_options SSL_CTX_get_options -#define SSL_CTX_set_options SSL_CTX_set_options -#define SSL_get_options SSL_get_options -#define SSL_set_options SSL_set_options -#define SSL_CTX_get_mode SSL_CTX_get_mode -#define SSL_CTX_set_mode SSL_CTX_set_mode -#define SSL_get_mode SSL_get_mode -#define SSL_set_mode SSL_set_mode -#define SSL_CTX_get_read_ahead SSL_CTX_get_read_ahead -#define SSL_CTX_set_read_ahead SSL_CTX_set_read_ahead -#define SSL_CTX_sess_set_cache_size SSL_CTX_sess_set_cache_size -#define SSL_CTX_sess_get_cache_size SSL_CTX_sess_get_cache_size -#define SSL_CTX_set_session_cache_mode SSL_CTX_set_session_cache_mode -#define SSL_CTX_get_session_cache_mode SSL_CTX_get_session_cache_mode -#define SSL_CTX_get_max_cert_list SSL_CTX_get_max_cert_list -#define SSL_get_max_cert_list SSL_get_max_cert_list -#define SSL_CTX_set_max_cert_list SSL_CTX_set_max_cert_list -#define SSL_set_max_cert_list SSL_set_max_cert_list -#define SSL_CTX_set_max_send_fragment SSL_CTX_set_max_send_fragment -#define SSL_set_max_send_fragment SSL_set_max_send_fragment -#define SSL_CTX_set_tlsext_servername_callback \ - SSL_CTX_set_tlsext_servername_callback -#define SSL_CTX_set_tlsext_servername_arg SSL_CTX_set_tlsext_servername_arg -#define SSL_set_tlsext_host_name SSL_set_tlsext_host_name -#define SSL_CTX_set_tlsext_ticket_key_cb SSL_CTX_set_tlsext_ticket_key_cb -#define DTLSv1_get_timeout DTLSv1_get_timeout -#define DTLSv1_handle_timeout DTLSv1_handle_timeout -#define SSL_get_secure_renegotiation_support \ - SSL_get_secure_renegotiation_support -#define SSL_CTX_clear_options SSL_CTX_clear_options -#define SSL_clear_options SSL_clear_options -#define SSL_CTX_clear_mode SSL_CTX_clear_mode -#define SSL_clear_mode SSL_clear_mode -#define SSL_CTX_enable_tls_channel_id SSL_CTX_enable_tls_channel_id -#define SSL_enable_tls_channel_id SSL_enable_tls_channel_id -#define SSL_set1_tls_channel_id SSL_set1_tls_channel_id -#define SSL_CTX_set1_tls_channel_id SSL_CTX_set1_tls_channel_id -#define SSL_get_tls_channel_id SSL_get_tls_channel_id - - -#if defined(__cplusplus) -} /* extern C */ -#endif - - -/* Library consumers assume these headers are included by ssl.h, but they depend - * on ssl.h, so include them after all declarations. - * - * TODO(davidben): The separation between ssl.h and these version-specific - * headers introduces circular dependencies and is inconsistent. The function - * declarations should move to ssl.h. Many of the constants can probably be - * pruned or unexported. */ -#include -#include -#include /* This is mostly sslv3 with a few tweaks */ -#include -#include /* Support for the use_srtp extension */ - - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script make_errors.go. Any - * changes made after this point may be overwritten when the script is next run. - */ -#define SSL_F_SSL_CTX_check_private_key 100 -#define SSL_F_SSL_CTX_new 101 -#define SSL_F_SSL_CTX_set_cipher_list 102 -#define SSL_F_SSL_CTX_set_cipher_list_tls11 103 -#define SSL_F_SSL_CTX_set_session_id_context 104 -#define SSL_F_SSL_CTX_use_PrivateKey 105 -#define SSL_F_SSL_CTX_use_PrivateKey_ASN1 106 -#define SSL_F_SSL_CTX_use_PrivateKey_file 107 -#define SSL_F_SSL_CTX_use_RSAPrivateKey 108 -#define SSL_F_SSL_CTX_use_RSAPrivateKey_ASN1 109 -#define SSL_F_SSL_CTX_use_RSAPrivateKey_file 110 -#define SSL_F_SSL_CTX_use_certificate 111 -#define SSL_F_SSL_CTX_use_certificate_ASN1 112 -#define SSL_F_SSL_CTX_use_certificate_chain_file 113 -#define SSL_F_SSL_CTX_use_certificate_file 114 -#define SSL_F_SSL_CTX_use_psk_identity_hint 115 -#define SSL_F_SSL_SESSION_new 116 -#define SSL_F_SSL_SESSION_print_fp 117 -#define SSL_F_SSL_SESSION_set1_id_context 118 -#define SSL_F_SSL_SESSION_to_bytes_full 119 -#define SSL_F_SSL_accept 120 -#define SSL_F_SSL_add_dir_cert_subjects_to_stack 121 -#define SSL_F_SSL_add_file_cert_subjects_to_stack 122 -#define SSL_F_SSL_check_private_key 123 -#define SSL_F_SSL_clear 124 -#define SSL_F_SSL_connect 125 -#define SSL_F_SSL_do_handshake 126 -#define SSL_F_SSL_load_client_CA_file 127 -#define SSL_F_SSL_new 128 -#define SSL_F_SSL_peek 129 -#define SSL_F_SSL_read 130 -#define SSL_F_SSL_renegotiate 131 -#define SSL_F_SSL_set_cipher_list 132 -#define SSL_F_SSL_set_fd 133 -#define SSL_F_SSL_set_rfd 134 -#define SSL_F_SSL_set_session_id_context 135 -#define SSL_F_SSL_set_wfd 136 -#define SSL_F_SSL_shutdown 137 -#define SSL_F_SSL_use_PrivateKey 138 -#define SSL_F_SSL_use_PrivateKey_ASN1 139 -#define SSL_F_SSL_use_PrivateKey_file 140 -#define SSL_F_SSL_use_RSAPrivateKey 141 -#define SSL_F_SSL_use_RSAPrivateKey_ASN1 142 -#define SSL_F_SSL_use_RSAPrivateKey_file 143 -#define SSL_F_SSL_use_certificate 144 -#define SSL_F_SSL_use_certificate_ASN1 145 -#define SSL_F_SSL_use_certificate_file 146 -#define SSL_F_SSL_use_psk_identity_hint 147 -#define SSL_F_SSL_write 148 -#define SSL_F_d2i_SSL_SESSION 149 -#define SSL_F_d2i_SSL_SESSION_get_octet_string 150 -#define SSL_F_d2i_SSL_SESSION_get_string 151 -#define SSL_F_do_ssl3_write 152 -#define SSL_F_dtls1_accept 153 -#define SSL_F_dtls1_buffer_record 154 -#define SSL_F_dtls1_check_timeout_num 155 -#define SSL_F_dtls1_connect 156 -#define SSL_F_dtls1_do_write 157 -#define SSL_F_dtls1_get_hello_verify 158 -#define SSL_F_dtls1_get_message 159 -#define SSL_F_dtls1_get_message_fragment 160 -#define SSL_F_dtls1_preprocess_fragment 161 -#define SSL_F_dtls1_process_record 162 -#define SSL_F_dtls1_read_bytes 163 -#define SSL_F_dtls1_send_hello_verify_request 164 -#define SSL_F_dtls1_write_app_data 165 -#define SSL_F_i2d_SSL_SESSION 166 -#define SSL_F_ssl3_accept 167 -#define SSL_F_ssl3_cert_verify_hash 169 -#define SSL_F_ssl3_check_cert_and_algorithm 170 -#define SSL_F_ssl3_connect 171 -#define SSL_F_ssl3_ctrl 172 -#define SSL_F_ssl3_ctx_ctrl 173 -#define SSL_F_ssl3_digest_cached_records 174 -#define SSL_F_ssl3_do_change_cipher_spec 175 -#define SSL_F_ssl3_expect_change_cipher_spec 176 -#define SSL_F_ssl3_get_cert_status 177 -#define SSL_F_ssl3_get_cert_verify 178 -#define SSL_F_ssl3_get_certificate_request 179 -#define SSL_F_ssl3_get_channel_id 180 -#define SSL_F_ssl3_get_client_certificate 181 -#define SSL_F_ssl3_get_client_hello 182 -#define SSL_F_ssl3_get_client_key_exchange 183 -#define SSL_F_ssl3_get_finished 184 -#define SSL_F_ssl3_get_initial_bytes 185 -#define SSL_F_ssl3_get_message 186 -#define SSL_F_ssl3_get_new_session_ticket 187 -#define SSL_F_ssl3_get_next_proto 188 -#define SSL_F_ssl3_get_record 189 -#define SSL_F_ssl3_get_server_certificate 190 -#define SSL_F_ssl3_get_server_done 191 -#define SSL_F_ssl3_get_server_hello 192 -#define SSL_F_ssl3_get_server_key_exchange 193 -#define SSL_F_ssl3_get_v2_client_hello 194 -#define SSL_F_ssl3_handshake_mac 195 -#define SSL_F_ssl3_prf 196 -#define SSL_F_ssl3_read_bytes 197 -#define SSL_F_ssl3_read_n 198 -#define SSL_F_ssl3_send_cert_verify 199 -#define SSL_F_ssl3_send_certificate_request 200 -#define SSL_F_ssl3_send_channel_id 201 -#define SSL_F_ssl3_send_client_certificate 202 -#define SSL_F_ssl3_send_client_hello 203 -#define SSL_F_ssl3_send_client_key_exchange 204 -#define SSL_F_ssl3_send_server_certificate 205 -#define SSL_F_ssl3_send_server_hello 206 -#define SSL_F_ssl3_send_server_key_exchange 207 -#define SSL_F_ssl3_setup_read_buffer 208 -#define SSL_F_ssl3_setup_write_buffer 209 -#define SSL_F_ssl3_write_bytes 210 -#define SSL_F_ssl3_write_pending 211 -#define SSL_F_ssl_add_cert_chain 212 -#define SSL_F_ssl_add_cert_to_buf 213 -#define SSL_F_ssl_add_clienthello_renegotiate_ext 214 -#define SSL_F_ssl_add_clienthello_tlsext 215 -#define SSL_F_ssl_add_clienthello_use_srtp_ext 216 -#define SSL_F_ssl_add_serverhello_renegotiate_ext 217 -#define SSL_F_ssl_add_serverhello_tlsext 218 -#define SSL_F_ssl_add_serverhello_use_srtp_ext 219 -#define SSL_F_ssl_build_cert_chain 220 -#define SSL_F_ssl_bytes_to_cipher_list 221 -#define SSL_F_ssl_cert_dup 222 -#define SSL_F_ssl_cert_inst 223 -#define SSL_F_ssl_cert_new 224 -#define SSL_F_ssl_check_serverhello_tlsext 225 -#define SSL_F_ssl_check_srvr_ecc_cert_and_alg 226 -#define SSL_F_ssl_cipher_process_rulestr 227 -#define SSL_F_ssl_cipher_strength_sort 228 -#define SSL_F_ssl_create_cipher_list 229 -#define SSL_F_ssl_ctx_log_master_secret 230 -#define SSL_F_ssl_ctx_log_rsa_client_key_exchange 231 -#define SSL_F_ssl_ctx_make_profiles 232 -#define SSL_F_ssl_get_new_session 233 -#define SSL_F_ssl_get_prev_session 234 -#define SSL_F_ssl_get_server_cert_index 235 -#define SSL_F_ssl_get_sign_pkey 236 -#define SSL_F_ssl_init_wbio_buffer 237 -#define SSL_F_ssl_parse_clienthello_renegotiate_ext 238 -#define SSL_F_ssl_parse_clienthello_tlsext 239 -#define SSL_F_ssl_parse_clienthello_use_srtp_ext 240 -#define SSL_F_ssl_parse_serverhello_renegotiate_ext 241 -#define SSL_F_ssl_parse_serverhello_tlsext 242 -#define SSL_F_ssl_parse_serverhello_use_srtp_ext 243 -#define SSL_F_ssl_scan_clienthello_tlsext 244 -#define SSL_F_ssl_scan_serverhello_tlsext 245 -#define SSL_F_ssl_sess_cert_new 246 -#define SSL_F_ssl_set_cert 247 -#define SSL_F_ssl_set_pkey 248 -#define SSL_F_ssl_verify_cert_chain 252 -#define SSL_F_tls12_check_peer_sigalg 253 -#define SSL_F_tls1_aead_ctx_init 254 -#define SSL_F_tls1_cert_verify_mac 255 -#define SSL_F_tls1_change_cipher_state 256 -#define SSL_F_tls1_change_cipher_state_aead 257 -#define SSL_F_tls1_check_duplicate_extensions 258 -#define SSL_F_tls1_enc 259 -#define SSL_F_tls1_export_keying_material 260 -#define SSL_F_tls1_prf 261 -#define SSL_F_tls1_setup_key_block 262 -#define SSL_F_dtls1_get_buffered_message 263 -#define SSL_F_dtls1_process_fragment 264 -#define SSL_F_dtls1_hm_fragment_new 265 -#define SSL_F_ssl3_seal_record 266 -#define SSL_F_ssl3_record_sequence_update 267 -#define SSL_F_SSL_CTX_set_tmp_dh 268 -#define SSL_F_SSL_CTX_set_tmp_ecdh 269 -#define SSL_F_SSL_set_tmp_dh 270 -#define SSL_F_SSL_set_tmp_ecdh 271 -#define SSL_F_SSL_CTX_set1_tls_channel_id 272 -#define SSL_F_SSL_set1_tls_channel_id 273 -#define SSL_F_SSL_set_tlsext_host_name 274 -#define SSL_F_ssl3_output_cert_chain 275 -#define SSL_F_SSL_AEAD_CTX_new 276 -#define SSL_F_SSL_AEAD_CTX_open 277 -#define SSL_F_SSL_AEAD_CTX_seal 278 -#define SSL_F_dtls1_seal_record 279 -#define SSL_R_APP_DATA_IN_HANDSHAKE 100 -#define SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT 101 -#define SSL_R_BAD_ALERT 102 -#define SSL_R_BAD_CHANGE_CIPHER_SPEC 103 -#define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK 104 -#define SSL_R_BAD_DH_P_LENGTH 105 -#define SSL_R_BAD_DIGEST_LENGTH 106 -#define SSL_R_BAD_ECC_CERT 107 -#define SSL_R_BAD_ECPOINT 108 -#define SSL_R_BAD_HANDSHAKE_LENGTH 109 -#define SSL_R_BAD_HANDSHAKE_RECORD 110 -#define SSL_R_BAD_HELLO_REQUEST 111 -#define SSL_R_BAD_LENGTH 112 -#define SSL_R_BAD_PACKET_LENGTH 113 -#define SSL_R_BAD_RSA_ENCRYPT 114 -#define SSL_R_BAD_SIGNATURE 115 -#define SSL_R_BAD_SRTP_MKI_VALUE 116 -#define SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST 117 -#define SSL_R_BAD_SSL_FILETYPE 118 -#define SSL_R_BAD_WRITE_RETRY 119 -#define SSL_R_BIO_NOT_SET 120 -#define SSL_R_BN_LIB 121 -#define SSL_R_CANNOT_SERIALIZE_PUBLIC_KEY 122 -#define SSL_R_CA_DN_LENGTH_MISMATCH 123 -#define SSL_R_CA_DN_TOO_LONG 124 -#define SSL_R_CCS_RECEIVED_EARLY 125 -#define SSL_R_CERTIFICATE_VERIFY_FAILED 126 -#define SSL_R_CERT_CB_ERROR 127 -#define SSL_R_CERT_LENGTH_MISMATCH 128 -#define SSL_R_CHANNEL_ID_NOT_P256 129 -#define SSL_R_CHANNEL_ID_SIGNATURE_INVALID 130 -#define SSL_R_CIPHER_CODE_WRONG_LENGTH 131 -#define SSL_R_CIPHER_OR_HASH_UNAVAILABLE 132 -#define SSL_R_CLIENTHELLO_PARSE_FAILED 133 -#define SSL_R_CLIENTHELLO_TLSEXT 134 -#define SSL_R_CONNECTION_REJECTED 135 -#define SSL_R_CONNECTION_TYPE_NOT_SET 136 -#define SSL_R_COOKIE_MISMATCH 137 -#define SSL_R_D2I_ECDSA_SIG 138 -#define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED 139 -#define SSL_R_DATA_LENGTH_TOO_LONG 140 -#define SSL_R_DECODE_ERROR 141 -#define SSL_R_DECRYPTION_FAILED 142 -#define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC 143 -#define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 144 -#define SSL_R_DIGEST_CHECK_FAILED 145 -#define SSL_R_DTLS_MESSAGE_TOO_BIG 146 -#define SSL_R_ECC_CERT_NOT_FOR_SIGNING 147 -#define SSL_R_EMPTY_SRTP_PROTECTION_PROFILE_LIST 148 -#define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 149 -#define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST 150 -#define SSL_R_EVP_DIGESTSIGNFINAL_FAILED 151 -#define SSL_R_EVP_DIGESTSIGNINIT_FAILED 152 -#define SSL_R_EXCESSIVE_MESSAGE_SIZE 153 -#define SSL_R_EXTRA_DATA_IN_MESSAGE 154 -#define SSL_R_GOT_A_FIN_BEFORE_A_CCS 155 -#define SSL_R_GOT_CHANNEL_ID_BEFORE_A_CCS 156 -#define SSL_R_GOT_NEXT_PROTO_BEFORE_A_CCS 157 -#define SSL_R_GOT_NEXT_PROTO_WITHOUT_EXTENSION 158 -#define SSL_R_HANDSHAKE_FAILURE_ON_CLIENT_HELLO 159 -#define SSL_R_HANDSHAKE_RECORD_BEFORE_CCS 160 -#define SSL_R_HTTPS_PROXY_REQUEST 161 -#define SSL_R_HTTP_REQUEST 162 -#define SSL_R_INAPPROPRIATE_FALLBACK 163 -#define SSL_R_INVALID_COMMAND 164 -#define SSL_R_INVALID_MESSAGE 165 -#define SSL_R_INVALID_SSL_SESSION 166 -#define SSL_R_INVALID_TICKET_KEYS_LENGTH 167 -#define SSL_R_LENGTH_MISMATCH 168 -#define SSL_R_LIBRARY_HAS_NO_CIPHERS 169 -#define SSL_R_MISSING_DH_KEY 170 -#define SSL_R_MISSING_ECDSA_SIGNING_CERT 171 -#define SSL_R_MISSING_RSA_CERTIFICATE 172 -#define SSL_R_MISSING_RSA_ENCRYPTING_CERT 173 -#define SSL_R_MISSING_RSA_SIGNING_CERT 174 -#define SSL_R_MISSING_TMP_DH_KEY 175 -#define SSL_R_MISSING_TMP_ECDH_KEY 176 -#define SSL_R_MIXED_SPECIAL_OPERATOR_WITH_GROUPS 177 -#define SSL_R_MTU_TOO_SMALL 178 -#define SSL_R_NESTED_GROUP 179 -#define SSL_R_NO_CERTIFICATES_RETURNED 180 -#define SSL_R_NO_CERTIFICATE_ASSIGNED 181 -#define SSL_R_NO_CERTIFICATE_SET 182 -#define SSL_R_NO_CIPHERS_AVAILABLE 183 -#define SSL_R_NO_CIPHERS_PASSED 184 -#define SSL_R_NO_CIPHERS_SPECIFIED 185 -#define SSL_R_NO_CIPHER_MATCH 186 -#define SSL_R_NO_COMPRESSION_SPECIFIED 187 -#define SSL_R_NO_METHOD_SPECIFIED 188 -#define SSL_R_NO_P256_SUPPORT 189 -#define SSL_R_NO_PRIVATE_KEY_ASSIGNED 190 -#define SSL_R_NO_RENEGOTIATION 191 -#define SSL_R_NO_REQUIRED_DIGEST 192 -#define SSL_R_NO_SHARED_CIPHER 193 -#define SSL_R_NO_SHARED_SIGATURE_ALGORITHMS 194 -#define SSL_R_NO_SRTP_PROFILES 195 -#define SSL_R_NULL_SSL_CTX 196 -#define SSL_R_NULL_SSL_METHOD_PASSED 197 -#define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED 198 -#define SSL_R_PACKET_LENGTH_TOO_LONG 199 -#define SSL_R_PARSE_TLSEXT 200 -#define SSL_R_PATH_TOO_LONG 201 -#define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE 202 -#define SSL_R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE 203 -#define SSL_R_PROTOCOL_IS_SHUTDOWN 204 -#define SSL_R_PSK_IDENTITY_NOT_FOUND 205 -#define SSL_R_PSK_NO_CLIENT_CB 206 -#define SSL_R_PSK_NO_SERVER_CB 207 -#define SSL_R_READ_BIO_NOT_SET 208 -#define SSL_R_READ_TIMEOUT_EXPIRED 209 -#define SSL_R_RECORD_LENGTH_MISMATCH 210 -#define SSL_R_RECORD_TOO_LARGE 211 -#define SSL_R_RENEGOTIATE_EXT_TOO_LONG 212 -#define SSL_R_RENEGOTIATION_ENCODING_ERR 213 -#define SSL_R_RENEGOTIATION_MISMATCH 214 -#define SSL_R_REQUIRED_CIPHER_MISSING 215 -#define SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING 216 -#define SSL_R_SERVERHELLO_TLSEXT 217 -#define SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED 218 -#define SSL_R_SESSION_MAY_NOT_BE_CREATED 219 -#define SSL_R_SIGNATURE_ALGORITHMS_ERROR 220 -#define SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES 221 -#define SSL_R_SRTP_PROTECTION_PROFILE_LIST_TOO_LONG 222 -#define SSL_R_SRTP_UNKNOWN_PROTECTION_PROFILE 223 -#define SSL_R_SSL3_EXT_INVALID_SERVERNAME 224 -#define SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE 225 -#define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION 226 -#define SSL_R_SSL_HANDSHAKE_FAILURE 227 -#define SSL_R_SSL_SESSION_ID_CALLBACK_FAILED 228 -#define SSL_R_SSL_SESSION_ID_CONFLICT 229 -#define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG 230 -#define SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH 231 -#define SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER 232 -#define SSL_R_TLS_ILLEGAL_EXPORTER_LABEL 233 -#define SSL_R_TLS_INVALID_ECPOINTFORMAT_LIST 234 -#define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 235 -#define SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG 236 -#define SSL_R_TOO_MANY_EMPTY_FRAGMENTS 237 -#define SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS 238 -#define SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS 239 -#define SSL_R_UNEXPECTED_GROUP_CLOSE 240 -#define SSL_R_UNEXPECTED_MESSAGE 241 -#define SSL_R_UNEXPECTED_OPERATOR_IN_GROUP 242 -#define SSL_R_UNEXPECTED_RECORD 243 -#define SSL_R_UNINITIALIZED 244 -#define SSL_R_UNKNOWN_ALERT_TYPE 245 -#define SSL_R_UNKNOWN_CERTIFICATE_TYPE 246 -#define SSL_R_UNKNOWN_CIPHER_RETURNED 247 -#define SSL_R_UNKNOWN_CIPHER_TYPE 248 -#define SSL_R_UNKNOWN_DIGEST 249 -#define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE 250 -#define SSL_R_UNKNOWN_PROTOCOL 251 -#define SSL_R_UNKNOWN_SSL_VERSION 252 -#define SSL_R_UNKNOWN_STATE 253 -#define SSL_R_UNPROCESSED_HANDSHAKE_DATA 254 -#define SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED 255 -#define SSL_R_UNSUPPORTED_CIPHER 256 -#define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM 257 -#define SSL_R_UNSUPPORTED_ELLIPTIC_CURVE 258 -#define SSL_R_UNSUPPORTED_PROTOCOL 259 -#define SSL_R_UNSUPPORTED_SSL_VERSION 260 -#define SSL_R_USE_SRTP_NOT_NEGOTIATED 261 -#define SSL_R_WRONG_CERTIFICATE_TYPE 262 -#define SSL_R_WRONG_CIPHER_RETURNED 263 -#define SSL_R_WRONG_CURVE 264 -#define SSL_R_WRONG_MESSAGE_TYPE 265 -#define SSL_R_WRONG_SIGNATURE_TYPE 266 -#define SSL_R_WRONG_SSL_VERSION 267 -#define SSL_R_WRONG_VERSION_NUMBER 268 -#define SSL_R_X509_LIB 269 -#define SSL_R_X509_VERIFICATION_SETUP_PROBLEMS 270 -#define SSL_R_FRAGMENT_MISMATCH 271 -#define SSL_R_BUFFER_TOO_SMALL 272 -#define SSL_R_OLD_SESSION_VERSION_NOT_RETURNED 273 -#define SSL_R_OUTPUT_ALIASES_INPUT 274 -#define SSL_R_RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION 275 -#define SSL_R_EMS_STATE_INCONSISTENT 276 -#define SSL_R_RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION 277 -#define SSL_R_SSLV3_ALERT_CLOSE_NOTIFY 1000 -#define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010 -#define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020 -#define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED 1021 -#define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW 1022 -#define SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE 1030 -#define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE 1040 -#define SSL_R_SSLV3_ALERT_NO_CERTIFICATE 1041 -#define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE 1042 -#define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE 1043 -#define SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED 1044 -#define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED 1045 -#define SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN 1046 -#define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER 1047 -#define SSL_R_TLSV1_ALERT_UNKNOWN_CA 1048 -#define SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049 -#define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050 -#define SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051 -#define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060 -#define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070 -#define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071 -#define SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080 -#define SSL_R_TLSV1_ALERT_INAPPROPRIATE_FALLBACK 1086 -#define SSL_R_TLSV1_ALERT_USER_CANCELLED 1090 -#define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100 -#define SSL_R_TLSV1_UNSUPPORTED_EXTENSION 1110 -#define SSL_R_TLSV1_CERTIFICATE_UNOBTAINABLE 1111 -#define SSL_R_TLSV1_UNRECOGNIZED_NAME 1112 -#define SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE 1113 -#define SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE 1114 - -#endif /* OPENSSL_HEADER_SSL_H */ diff --git a/phonelibs/boringssl/include/openssl/ssl2.h b/phonelibs/boringssl/include/openssl/ssl2.h deleted file mode 100644 index b8401faaf6684a..00000000000000 --- a/phonelibs/boringssl/include/openssl/ssl2.h +++ /dev/null @@ -1,268 +0,0 @@ -/* ssl/ssl2.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_SSL2_H -#define HEADER_SSL2_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Protocol Version Codes */ -#define SSL2_VERSION 0x0002 -#define SSL2_VERSION_MAJOR 0x00 -#define SSL2_VERSION_MINOR 0x02 -/* #define SSL2_CLIENT_VERSION 0x0002 */ -/* #define SSL2_SERVER_VERSION 0x0002 */ - -/* Protocol Message Codes */ -#define SSL2_MT_ERROR 0 -#define SSL2_MT_CLIENT_HELLO 1 -#define SSL2_MT_CLIENT_MASTER_KEY 2 -#define SSL2_MT_CLIENT_FINISHED 3 -#define SSL2_MT_SERVER_HELLO 4 -#define SSL2_MT_SERVER_VERIFY 5 -#define SSL2_MT_SERVER_FINISHED 6 -#define SSL2_MT_REQUEST_CERTIFICATE 7 -#define SSL2_MT_CLIENT_CERTIFICATE 8 - -/* Error Message Codes */ -#define SSL2_PE_UNDEFINED_ERROR 0x0000 -#define SSL2_PE_NO_CIPHER 0x0001 -#define SSL2_PE_NO_CERTIFICATE 0x0002 -#define SSL2_PE_BAD_CERTIFICATE 0x0004 -#define SSL2_PE_UNSUPPORTED_CERTIFICATE_TYPE 0x0006 - -/* Cipher Kind Values */ -#define SSL2_CK_NULL_WITH_MD5 0x02000000 /* v3 */ -#define SSL2_CK_RC4_128_WITH_MD5 0x02010080 -#define SSL2_CK_RC4_128_EXPORT40_WITH_MD5 0x02020080 -#define SSL2_CK_RC2_128_CBC_WITH_MD5 0x02030080 -#define SSL2_CK_RC2_128_CBC_EXPORT40_WITH_MD5 0x02040080 -#define SSL2_CK_IDEA_128_CBC_WITH_MD5 0x02050080 -#define SSL2_CK_DES_64_CBC_WITH_MD5 0x02060040 -#define SSL2_CK_DES_64_CBC_WITH_SHA 0x02060140 /* v3 */ -#define SSL2_CK_DES_192_EDE3_CBC_WITH_MD5 0x020700c0 -#define SSL2_CK_DES_192_EDE3_CBC_WITH_SHA 0x020701c0 /* v3 */ -#define SSL2_CK_RC4_64_WITH_MD5 0x02080080 /* MS hack */ - -#define SSL2_CK_DES_64_CFB64_WITH_MD5_1 0x02ff0800 /* SSLeay */ -#define SSL2_CK_NULL 0x02ff0810 /* SSLeay */ - -#define SSL2_TXT_DES_64_CFB64_WITH_MD5_1 "DES-CFB-M1" -#define SSL2_TXT_NULL_WITH_MD5 "NULL-MD5" -#define SSL2_TXT_RC4_128_WITH_MD5 "RC4-MD5" -#define SSL2_TXT_RC4_128_EXPORT40_WITH_MD5 "EXP-RC4-MD5" -#define SSL2_TXT_RC2_128_CBC_WITH_MD5 "RC2-CBC-MD5" -#define SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 "EXP-RC2-CBC-MD5" -#define SSL2_TXT_IDEA_128_CBC_WITH_MD5 "IDEA-CBC-MD5" -#define SSL2_TXT_DES_64_CBC_WITH_MD5 "DES-CBC-MD5" -#define SSL2_TXT_DES_64_CBC_WITH_SHA "DES-CBC-SHA" -#define SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5 "DES-CBC3-MD5" -#define SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA "DES-CBC3-SHA" -#define SSL2_TXT_RC4_64_WITH_MD5 "RC4-64-MD5" - -#define SSL2_TXT_NULL "NULL" - -/* Flags for the SSL_CIPHER.algorithm2 field */ -#define SSL2_CF_5_BYTE_ENC 0x01 -#define SSL2_CF_8_BYTE_ENC 0x02 - -/* Certificate Type Codes */ -#define SSL2_CT_X509_CERTIFICATE 0x01 - -/* Authentication Type Code */ -#define SSL2_AT_MD5_WITH_RSA_ENCRYPTION 0x01 - -#define SSL2_MAX_SSL_SESSION_ID_LENGTH 32 - -/* Upper/Lower Bounds */ -#define SSL2_MAX_MASTER_KEY_LENGTH_IN_BITS 256 -#ifdef OPENSSL_SYS_MPE -#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 29998u -#else -#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 32767u /* 2^15-1 */ -#endif -#define SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER 16383 /* 2^14-1 */ - -#define SSL2_CHALLENGE_LENGTH 16 -/*#define SSL2_CHALLENGE_LENGTH 32 */ -#define SSL2_MIN_CHALLENGE_LENGTH 16 -#define SSL2_MAX_CHALLENGE_LENGTH 32 -#define SSL2_CONNECTION_ID_LENGTH 16 -#define SSL2_MAX_CONNECTION_ID_LENGTH 16 -#define SSL2_SSL_SESSION_ID_LENGTH 16 -#define SSL2_MAX_CERT_CHALLENGE_LENGTH 32 -#define SSL2_MIN_CERT_CHALLENGE_LENGTH 16 -#define SSL2_MAX_KEY_MATERIAL_LENGTH 24 - -#ifndef OPENSSL_NO_SSL_INTERN - -typedef struct ssl2_state_st - { - int three_byte_header; - int clear_text; /* clear text */ - int escape; /* not used in SSLv2 */ - int ssl2_rollback; /* used if SSLv23 rolled back to SSLv2 */ - - /* non-blocking io info, used to make sure the same - * args were passwd */ - unsigned int wnum; /* number of bytes sent so far */ - int wpend_tot; - const unsigned char *wpend_buf; - - int wpend_off; /* offset to data to write */ - int wpend_len; /* number of bytes passwd to write */ - int wpend_ret; /* number of bytes to return to caller */ - - /* buffer raw data */ - int rbuf_left; - int rbuf_offs; - unsigned char *rbuf; - unsigned char *wbuf; - - unsigned char *write_ptr;/* used to point to the start due to - * 2/3 byte header. */ - - unsigned int padding; - unsigned int rlength; /* passed to ssl2_enc */ - int ract_data_length; /* Set when things are encrypted. */ - unsigned int wlength; /* passed to ssl2_enc */ - int wact_data_length; /* Set when things are decrypted. */ - unsigned char *ract_data; - unsigned char *wact_data; - unsigned char *mac_data; - - unsigned char *read_key; - unsigned char *write_key; - - /* Stuff specifically to do with this SSL session */ - unsigned int challenge_length; - unsigned char challenge[SSL2_MAX_CHALLENGE_LENGTH]; - unsigned int conn_id_length; - unsigned char conn_id[SSL2_MAX_CONNECTION_ID_LENGTH]; - unsigned int key_material_length; - unsigned char key_material[SSL2_MAX_KEY_MATERIAL_LENGTH*2]; - - unsigned long read_sequence; - unsigned long write_sequence; - - struct { - unsigned int conn_id_length; - unsigned int cert_type; - unsigned int cert_length; - unsigned int csl; - unsigned int clear; - unsigned int enc; - unsigned char ccl[SSL2_MAX_CERT_CHALLENGE_LENGTH]; - unsigned int cipher_spec_length; - unsigned int session_id_length; - unsigned int clen; - unsigned int rlen; - } tmp; - } SSL2_STATE; - -#endif - -/* SSLv2 */ -/* client */ -#define SSL2_ST_SEND_CLIENT_HELLO_A (0x10|SSL_ST_CONNECT) -#define SSL2_ST_SEND_CLIENT_HELLO_B (0x11|SSL_ST_CONNECT) -#define SSL2_ST_GET_SERVER_HELLO_A (0x20|SSL_ST_CONNECT) -#define SSL2_ST_GET_SERVER_HELLO_B (0x21|SSL_ST_CONNECT) -#define SSL2_ST_SEND_CLIENT_MASTER_KEY_A (0x30|SSL_ST_CONNECT) -#define SSL2_ST_SEND_CLIENT_MASTER_KEY_B (0x31|SSL_ST_CONNECT) -#define SSL2_ST_SEND_CLIENT_FINISHED_A (0x40|SSL_ST_CONNECT) -#define SSL2_ST_SEND_CLIENT_FINISHED_B (0x41|SSL_ST_CONNECT) -#define SSL2_ST_SEND_CLIENT_CERTIFICATE_A (0x50|SSL_ST_CONNECT) -#define SSL2_ST_SEND_CLIENT_CERTIFICATE_B (0x51|SSL_ST_CONNECT) -#define SSL2_ST_SEND_CLIENT_CERTIFICATE_C (0x52|SSL_ST_CONNECT) -#define SSL2_ST_SEND_CLIENT_CERTIFICATE_D (0x53|SSL_ST_CONNECT) -#define SSL2_ST_GET_SERVER_VERIFY_A (0x60|SSL_ST_CONNECT) -#define SSL2_ST_GET_SERVER_VERIFY_B (0x61|SSL_ST_CONNECT) -#define SSL2_ST_GET_SERVER_FINISHED_A (0x70|SSL_ST_CONNECT) -#define SSL2_ST_GET_SERVER_FINISHED_B (0x71|SSL_ST_CONNECT) -#define SSL2_ST_CLIENT_START_ENCRYPTION (0x80|SSL_ST_CONNECT) -#define SSL2_ST_X509_GET_CLIENT_CERTIFICATE (0x90|SSL_ST_CONNECT) -/* server */ -#define SSL2_ST_GET_CLIENT_HELLO_A (0x10|SSL_ST_ACCEPT) -#define SSL2_ST_GET_CLIENT_HELLO_B (0x11|SSL_ST_ACCEPT) -#define SSL2_ST_GET_CLIENT_HELLO_C (0x12|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_SERVER_HELLO_A (0x20|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_SERVER_HELLO_B (0x21|SSL_ST_ACCEPT) -#define SSL2_ST_GET_CLIENT_MASTER_KEY_A (0x30|SSL_ST_ACCEPT) -#define SSL2_ST_GET_CLIENT_MASTER_KEY_B (0x31|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_SERVER_VERIFY_A (0x40|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_SERVER_VERIFY_B (0x41|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_SERVER_VERIFY_C (0x42|SSL_ST_ACCEPT) -#define SSL2_ST_GET_CLIENT_FINISHED_A (0x50|SSL_ST_ACCEPT) -#define SSL2_ST_GET_CLIENT_FINISHED_B (0x51|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_SERVER_FINISHED_A (0x60|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_SERVER_FINISHED_B (0x61|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_REQUEST_CERTIFICATE_A (0x70|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_REQUEST_CERTIFICATE_B (0x71|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_REQUEST_CERTIFICATE_C (0x72|SSL_ST_ACCEPT) -#define SSL2_ST_SEND_REQUEST_CERTIFICATE_D (0x73|SSL_ST_ACCEPT) -#define SSL2_ST_SERVER_START_ENCRYPTION (0x80|SSL_ST_ACCEPT) -#define SSL2_ST_X509_GET_SERVER_CERTIFICATE (0x90|SSL_ST_ACCEPT) - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/phonelibs/boringssl/include/openssl/ssl23.h b/phonelibs/boringssl/include/openssl/ssl23.h deleted file mode 100644 index df395a8e978df7..00000000000000 --- a/phonelibs/boringssl/include/openssl/ssl23.h +++ /dev/null @@ -1,85 +0,0 @@ -/* ssl/ssl23.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_SSL23_H -#define HEADER_SSL23_H - -#ifdef __cplusplus -extern "C" { -#endif - - -/*client */ -/* write to server */ -#define SSL23_ST_CW_CLNT_HELLO_A (0x210 | SSL_ST_CONNECT) -#define SSL23_ST_CW_CLNT_HELLO_B (0x211 | SSL_ST_CONNECT) -/* read from server */ -#define SSL23_ST_CR_SRVR_HELLO_A (0x220 | SSL_ST_CONNECT) -#define SSL23_ST_CR_SRVR_HELLO_B (0x221 | SSL_ST_CONNECT) - -/* server */ -/* read from client */ -#define SSL23_ST_SR_CLNT_HELLO (0x210 | SSL_ST_ACCEPT) -#define SSL23_ST_SR_V2_CLNT_HELLO (0x220 | SSL_ST_ACCEPT) -#define SSL23_ST_SR_SWITCH_VERSION (0x230 | SSL_ST_ACCEPT) - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/phonelibs/boringssl/include/openssl/ssl3.h b/phonelibs/boringssl/include/openssl/ssl3.h deleted file mode 100644 index 640a22826ec1c1..00000000000000 --- a/phonelibs/boringssl/include/openssl/ssl3.h +++ /dev/null @@ -1,681 +0,0 @@ -/* ssl/ssl3.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ -/* ==================================================================== - * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * ECC cipher suite support in OpenSSL originally developed by - * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. - */ - -#ifndef HEADER_SSL3_H -#define HEADER_SSL3_H - -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Signalling cipher suite value: from RFC5746 */ -#define SSL3_CK_SCSV 0x030000FF -/* Fallback signalling cipher suite value: not IANA assigned. - * See https://tools.ietf.org/html/draft-bmoeller-tls-downgrade-scsv-01 */ -#define SSL3_CK_FALLBACK_SCSV 0x03005600 - -#define SSL3_CK_RSA_NULL_MD5 0x03000001 -#define SSL3_CK_RSA_NULL_SHA 0x03000002 -#define SSL3_CK_RSA_RC4_40_MD5 0x03000003 -#define SSL3_CK_RSA_RC4_128_MD5 0x03000004 -#define SSL3_CK_RSA_RC4_128_SHA 0x03000005 -#define SSL3_CK_RSA_RC2_40_MD5 0x03000006 -#define SSL3_CK_RSA_IDEA_128_SHA 0x03000007 -#define SSL3_CK_RSA_DES_40_CBC_SHA 0x03000008 -#define SSL3_CK_RSA_DES_64_CBC_SHA 0x03000009 -#define SSL3_CK_RSA_DES_192_CBC3_SHA 0x0300000A - -#define SSL3_CK_DH_DSS_DES_40_CBC_SHA 0x0300000B -#define SSL3_CK_DH_DSS_DES_64_CBC_SHA 0x0300000C -#define SSL3_CK_DH_DSS_DES_192_CBC3_SHA 0x0300000D -#define SSL3_CK_DH_RSA_DES_40_CBC_SHA 0x0300000E -#define SSL3_CK_DH_RSA_DES_64_CBC_SHA 0x0300000F -#define SSL3_CK_DH_RSA_DES_192_CBC3_SHA 0x03000010 - -#define SSL3_CK_EDH_DSS_DES_40_CBC_SHA 0x03000011 -#define SSL3_CK_EDH_DSS_DES_64_CBC_SHA 0x03000012 -#define SSL3_CK_EDH_DSS_DES_192_CBC3_SHA 0x03000013 -#define SSL3_CK_EDH_RSA_DES_40_CBC_SHA 0x03000014 -#define SSL3_CK_EDH_RSA_DES_64_CBC_SHA 0x03000015 -#define SSL3_CK_EDH_RSA_DES_192_CBC3_SHA 0x03000016 - -#define SSL3_CK_ADH_RC4_40_MD5 0x03000017 -#define SSL3_CK_ADH_RC4_128_MD5 0x03000018 -#define SSL3_CK_ADH_DES_40_CBC_SHA 0x03000019 -#define SSL3_CK_ADH_DES_64_CBC_SHA 0x0300001A -#define SSL3_CK_ADH_DES_192_CBC_SHA 0x0300001B - -#define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5" -#define SSL3_TXT_RSA_NULL_SHA "NULL-SHA" -#define SSL3_TXT_RSA_RC4_40_MD5 "EXP-RC4-MD5" -#define SSL3_TXT_RSA_RC4_128_MD5 "RC4-MD5" -#define SSL3_TXT_RSA_RC4_128_SHA "RC4-SHA" -#define SSL3_TXT_RSA_RC2_40_MD5 "EXP-RC2-CBC-MD5" -#define SSL3_TXT_RSA_IDEA_128_SHA "IDEA-CBC-SHA" -#define SSL3_TXT_RSA_DES_40_CBC_SHA "EXP-DES-CBC-SHA" -#define SSL3_TXT_RSA_DES_64_CBC_SHA "DES-CBC-SHA" -#define SSL3_TXT_RSA_DES_192_CBC3_SHA "DES-CBC3-SHA" - -#define SSL3_TXT_DH_DSS_DES_40_CBC_SHA "EXP-DH-DSS-DES-CBC-SHA" -#define SSL3_TXT_DH_DSS_DES_64_CBC_SHA "DH-DSS-DES-CBC-SHA" -#define SSL3_TXT_DH_DSS_DES_192_CBC3_SHA "DH-DSS-DES-CBC3-SHA" -#define SSL3_TXT_DH_RSA_DES_40_CBC_SHA "EXP-DH-RSA-DES-CBC-SHA" -#define SSL3_TXT_DH_RSA_DES_64_CBC_SHA "DH-RSA-DES-CBC-SHA" -#define SSL3_TXT_DH_RSA_DES_192_CBC3_SHA "DH-RSA-DES-CBC3-SHA" - -#define SSL3_TXT_EDH_DSS_DES_40_CBC_SHA "EXP-EDH-DSS-DES-CBC-SHA" -#define SSL3_TXT_EDH_DSS_DES_64_CBC_SHA "EDH-DSS-DES-CBC-SHA" -#define SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA "EDH-DSS-DES-CBC3-SHA" -#define SSL3_TXT_EDH_RSA_DES_40_CBC_SHA "EXP-EDH-RSA-DES-CBC-SHA" -#define SSL3_TXT_EDH_RSA_DES_64_CBC_SHA "EDH-RSA-DES-CBC-SHA" -#define SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA "EDH-RSA-DES-CBC3-SHA" - -#define SSL3_TXT_ADH_RC4_40_MD5 "EXP-ADH-RC4-MD5" -#define SSL3_TXT_ADH_RC4_128_MD5 "ADH-RC4-MD5" -#define SSL3_TXT_ADH_DES_40_CBC_SHA "EXP-ADH-DES-CBC-SHA" -#define SSL3_TXT_ADH_DES_64_CBC_SHA "ADH-DES-CBC-SHA" -#define SSL3_TXT_ADH_DES_192_CBC_SHA "ADH-DES-CBC3-SHA" - -#define SSL3_SSL_SESSION_ID_LENGTH 32 -#define SSL3_MAX_SSL_SESSION_ID_LENGTH 32 - -#define SSL3_MASTER_SECRET_SIZE 48 -#define SSL3_RANDOM_SIZE 32 -#define SSL3_SESSION_ID_SIZE 32 -#define SSL3_RT_HEADER_LENGTH 5 - -#define SSL3_HM_HEADER_LENGTH 4 - -#ifndef SSL3_ALIGN_PAYLOAD -/* Some will argue that this increases memory footprint, but it's not actually - * true. Point is that malloc has to return at least 64-bit aligned pointers, - * meaning that allocating 5 bytes wastes 3 bytes in either case. Suggested - * pre-gaping simply moves these wasted bytes from the end of allocated region - * to its front, but makes data payload aligned, which improves performance. */ -#define SSL3_ALIGN_PAYLOAD 8 -#else -#if (SSL3_ALIGN_PAYLOAD & (SSL3_ALIGN_PAYLOAD - 1)) != 0 -#error "insane SSL3_ALIGN_PAYLOAD" -#undef SSL3_ALIGN_PAYLOAD -#endif -#endif - -/* This is the maximum MAC (digest) size used by the SSL library. Currently - * maximum of 20 is used by SHA1, but we reserve for future extension for - * 512-bit hashes. */ - -#define SSL3_RT_MAX_MD_SIZE 64 - -/* Maximum block size used in all ciphersuites. Currently 16 for AES. */ - -#define SSL_RT_MAX_CIPHER_BLOCK_SIZE 16 - -#define SSL3_RT_MAX_EXTRA (16384) - -/* Maximum plaintext length: defined by SSL/TLS standards */ -#define SSL3_RT_MAX_PLAIN_LENGTH 16384 -/* Maximum compression overhead: defined by SSL/TLS standards */ -#define SSL3_RT_MAX_COMPRESSED_OVERHEAD 1024 - -/* The standards give a maximum encryption overhead of 1024 bytes. In practice - * the value is lower than this. The overhead is the maximum number of padding - * bytes (256) plus the mac size. - * - * TODO(davidben): This derivation doesn't take AEADs into account, or TLS 1.1 - * explicit nonces. It happens to work because |SSL3_RT_MAX_MD_SIZE| is larger - * than necessary and no true AEAD has variable overhead in TLS 1.2. */ -#define SSL3_RT_MAX_ENCRYPTED_OVERHEAD (256 + SSL3_RT_MAX_MD_SIZE) - -/* SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD is the maximum overhead in encrypting a - * record. This does not include the record header. Some ciphers use explicit - * nonces, so it includes both the AEAD overhead as well as the nonce. */ -#define SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD \ - (EVP_AEAD_MAX_OVERHEAD + EVP_AEAD_MAX_NONCE_LENGTH) - -OPENSSL_COMPILE_ASSERT( - SSL3_RT_MAX_ENCRYPTED_OVERHEAD >= SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD, - max_overheads_are_consistent); - -/* SSL3_RT_MAX_COMPRESSED_LENGTH is an alias for - * |SSL3_RT_MAX_PLAIN_LENGTH|. Compression is gone, so don't include the - * compression overhead. */ -#define SSL3_RT_MAX_COMPRESSED_LENGTH SSL3_RT_MAX_PLAIN_LENGTH - -#define SSL3_RT_MAX_ENCRYPTED_LENGTH \ - (SSL3_RT_MAX_ENCRYPTED_OVERHEAD + SSL3_RT_MAX_COMPRESSED_LENGTH) -#define SSL3_RT_MAX_PACKET_SIZE \ - (SSL3_RT_MAX_ENCRYPTED_LENGTH + SSL3_RT_HEADER_LENGTH) - -#define SSL3_MD_CLIENT_FINISHED_CONST "\x43\x4C\x4E\x54" -#define SSL3_MD_SERVER_FINISHED_CONST "\x53\x52\x56\x52" - -#define SSL3_VERSION 0x0300 -#define SSL3_VERSION_MAJOR 0x03 -#define SSL3_VERSION_MINOR 0x00 - -#define SSL3_RT_CHANGE_CIPHER_SPEC 20 -#define SSL3_RT_ALERT 21 -#define SSL3_RT_HANDSHAKE 22 -#define SSL3_RT_APPLICATION_DATA 23 - -/* Pseudo content types to indicate additional parameters */ -#define TLS1_RT_CRYPTO 0x1000 -#define TLS1_RT_CRYPTO_PREMASTER (TLS1_RT_CRYPTO | 0x1) -#define TLS1_RT_CRYPTO_CLIENT_RANDOM (TLS1_RT_CRYPTO | 0x2) -#define TLS1_RT_CRYPTO_SERVER_RANDOM (TLS1_RT_CRYPTO | 0x3) -#define TLS1_RT_CRYPTO_MASTER (TLS1_RT_CRYPTO | 0x4) - -#define TLS1_RT_CRYPTO_READ 0x0000 -#define TLS1_RT_CRYPTO_WRITE 0x0100 -#define TLS1_RT_CRYPTO_MAC (TLS1_RT_CRYPTO | 0x5) -#define TLS1_RT_CRYPTO_KEY (TLS1_RT_CRYPTO | 0x6) -#define TLS1_RT_CRYPTO_IV (TLS1_RT_CRYPTO | 0x7) -#define TLS1_RT_CRYPTO_FIXED_IV (TLS1_RT_CRYPTO | 0x8) - -/* Pseudo content type for SSL/TLS header info */ -#define SSL3_RT_HEADER 0x100 - -#define SSL3_AL_WARNING 1 -#define SSL3_AL_FATAL 2 - -#define SSL3_AD_CLOSE_NOTIFY 0 -#define SSL3_AD_UNEXPECTED_MESSAGE 10 /* fatal */ -#define SSL3_AD_BAD_RECORD_MAC 20 /* fatal */ -#define SSL3_AD_DECOMPRESSION_FAILURE 30 /* fatal */ -#define SSL3_AD_HANDSHAKE_FAILURE 40 /* fatal */ -#define SSL3_AD_NO_CERTIFICATE 41 -#define SSL3_AD_BAD_CERTIFICATE 42 -#define SSL3_AD_UNSUPPORTED_CERTIFICATE 43 -#define SSL3_AD_CERTIFICATE_REVOKED 44 -#define SSL3_AD_CERTIFICATE_EXPIRED 45 -#define SSL3_AD_CERTIFICATE_UNKNOWN 46 -#define SSL3_AD_ILLEGAL_PARAMETER 47 /* fatal */ -#define SSL3_AD_INAPPROPRIATE_FALLBACK 86 /* fatal */ - -typedef struct ssl3_record_st { - /* type is the record type. */ - uint8_t type; - /* length is the number of unconsumed bytes of |data|. */ - uint16_t length; - /* off is the number of consumed bytes of |data|. */ - uint16_t off; - /* data is a non-owning pointer to the record contents. The total length of - * the buffer is |off| + |length|. */ - uint8_t *data; - /* epoch, in DTLS, is the epoch number of the record. */ - uint16_t epoch; - /* seq_num, in DTLS, is the sequence number of the record. The top two bytes - * are always zero. - * - * TODO(davidben): This is confusing. They should include the epoch or the - * field should be six bytes. */ - uint8_t seq_num[8]; -} SSL3_RECORD; - -typedef struct ssl3_buffer_st { - uint8_t *buf; /* at least SSL3_RT_MAX_PACKET_SIZE bytes, see - ssl3_setup_buffers() */ - size_t len; /* buffer size */ - int offset; /* where to 'copy from' */ - int left; /* how many bytes left */ -} SSL3_BUFFER; - -#define SSL3_CT_RSA_SIGN 1 -#define SSL3_CT_DSS_SIGN 2 -#define SSL3_CT_RSA_FIXED_DH 3 -#define SSL3_CT_DSS_FIXED_DH 4 -#define SSL3_CT_RSA_EPHEMERAL_DH 5 -#define SSL3_CT_DSS_EPHEMERAL_DH 6 -#define SSL3_CT_FORTEZZA_DMS 20 - - -/* TODO(davidben): This flag can probably be merged into s3->change_cipher_spec - * to something tri-state. (Normal / Expect CCS / Between CCS and Finished). */ -#define SSL3_FLAGS_EXPECT_CCS 0x0080 - -typedef struct ssl3_state_st { - long flags; - - uint8_t read_sequence[8]; - int read_mac_secret_size; - uint8_t read_mac_secret[EVP_MAX_MD_SIZE]; - uint8_t write_sequence[8]; - int write_mac_secret_size; - uint8_t write_mac_secret[EVP_MAX_MD_SIZE]; - - uint8_t server_random[SSL3_RANDOM_SIZE]; - uint8_t client_random[SSL3_RANDOM_SIZE]; - - /* flags for countermeasure against known-IV weakness */ - int need_record_splitting; - - /* The value of 'extra' when the buffers were initialized */ - int init_extra; - - /* have_version is true if the connection's final version is known. Otherwise - * the version has not been negotiated yet. */ - char have_version; - - /* initial_handshake_complete is true if the initial handshake has - * completed. */ - char initial_handshake_complete; - - /* sniff_buffer is used by the server in the initial handshake to read a - * V2ClientHello before the record layer is initialized. */ - BUF_MEM *sniff_buffer; - size_t sniff_buffer_len; - - SSL3_BUFFER rbuf; /* read IO goes into here */ - SSL3_BUFFER wbuf; /* write IO goes into here */ - - SSL3_RECORD rrec; /* each decoded record goes in here */ - - /* storage for Handshake protocol data received but not yet processed by - * ssl3_read_bytes: */ - uint8_t handshake_fragment[4]; - unsigned int handshake_fragment_len; - - /* partial write - check the numbers match */ - unsigned int wnum; /* number of bytes sent so far */ - int wpend_tot; /* number bytes written */ - int wpend_type; - int wpend_ret; /* number of bytes submitted */ - const uint8_t *wpend_buf; - - /* used during startup, digest all incoming/outgoing packets */ - BIO *handshake_buffer; - /* When set of handshake digests is determined, buffer is hashed and freed - * and MD_CTX-es for all required digests are stored in this array */ - EVP_MD_CTX **handshake_dgst; - /* this is set whenerver we see a change_cipher_spec message come in when we - * are not looking for one */ - int change_cipher_spec; - - int warn_alert; - int fatal_alert; - /* we allow one fatal and one warning alert to be outstanding, send close - * alert via the warning alert */ - int alert_dispatch; - uint8_t send_alert[2]; - - int total_renegotiations; - - /* State pertaining to the pending handshake. - * - * TODO(davidben): State is current spread all over the place. Move - * pending handshake state here so it can be managed separately from - * established connection state in case of renegotiations. */ - struct { - /* actually only need to be 16+20 for SSLv3 and 12 for TLS */ - uint8_t finish_md[EVP_MAX_MD_SIZE * 2]; - int finish_md_len; - uint8_t peer_finish_md[EVP_MAX_MD_SIZE * 2]; - int peer_finish_md_len; - - unsigned long message_size; - int message_type; - - /* used to hold the new cipher we are going to use */ - const SSL_CIPHER *new_cipher; - DH *dh; - - EC_KEY *ecdh; /* holds short lived ECDH key */ - - /* used when SSL_ST_FLUSH_DATA is entered */ - int next_state; - - int reuse_message; - - /* Client-only: cert_req determines if a client certificate is to be sent. - * This is 0 if no client Certificate message is to be sent, 1 if there is - * a client certificate, and 2 to send an empty client Certificate - * message. */ - int cert_req; - - /* Client-only: ca_names contains the list of CAs received in a - * CertificateRequest message. */ - STACK_OF(X509_NAME) *ca_names; - - /* Client-only: certificate_types contains the set of certificate types - * received in a CertificateRequest message. */ - uint8_t *certificate_types; - size_t num_certificate_types; - - int key_block_length; - uint8_t *key_block; - - const EVP_AEAD *new_aead; - uint8_t new_mac_secret_len; - uint8_t new_fixed_iv_len; - uint8_t new_variable_iv_len; - - /* Server-only: cert_request is true if a client certificate was - * requested. */ - int cert_request; - - /* certificate_status_expected is true if OCSP stapling was negotiated and - * the server is expected to send a CertificateStatus message. */ - char certificate_status_expected; - - /* peer_ecpointformatlist contains the EC point formats advertised by the - * peer. */ - uint8_t *peer_ecpointformatlist; - size_t peer_ecpointformatlist_length; - - /* Server-only: peer_ellipticcurvelist contains the EC curve IDs advertised - * by the peer. This is only set on the server's end. The server does not - * advertise this extension to the client. */ - uint16_t *peer_ellipticcurvelist; - size_t peer_ellipticcurvelist_length; - - /* extended_master_secret indicates whether the extended master secret - * computation is used in this handshake. Note that this is different from - * whether it was used for the current session. If this is a resumption - * handshake then EMS might be negotiated in the client and server hello - * messages, but it doesn't matter if the session that's being resumed - * didn't use it to create the master secret initially. */ - char extended_master_secret; - - /* Client-only: peer_psk_identity_hint is the psk_identity_hint sent by the - * server when using a PSK key exchange. */ - char *peer_psk_identity_hint; - - /* new_mac_secret_size is unused and exists only until wpa_supplicant can - * be updated. It is only needed for EAP-FAST, which we don't support. */ - uint8_t new_mac_secret_size; - - /* Client-only: in_false_start is one if there is a pending handshake in - * False Start. The client may write data at this point. */ - char in_false_start; - } tmp; - - /* Connection binding to prevent renegotiation attacks */ - uint8_t previous_client_finished[EVP_MAX_MD_SIZE]; - uint8_t previous_client_finished_len; - uint8_t previous_server_finished[EVP_MAX_MD_SIZE]; - uint8_t previous_server_finished_len; - int send_connection_binding; /* TODOEKR */ - - /* Set if we saw the Next Protocol Negotiation extension from our peer. */ - int next_proto_neg_seen; - - /* ALPN information - * (we are in the process of transitioning from NPN to ALPN.) */ - - /* In a server these point to the selected ALPN protocol after the - * ClientHello has been processed. In a client these contain the protocol - * that the server selected once the ServerHello has been processed. */ - uint8_t *alpn_selected; - size_t alpn_selected_len; - - /* In a client, this means that the server supported Channel ID and that a - * Channel ID was sent. In a server it means that we echoed support for - * Channel IDs and that tlsext_channel_id will be valid after the - * handshake. */ - char tlsext_channel_id_valid; - /* tlsext_channel_id_new means that the updated Channel ID extension was - * negotiated. This is a temporary hack in the code to support both forms of - * Channel ID extension while we transition to the new format, which fixed a - * security issue. */ - char tlsext_channel_id_new; - /* For a server: - * If |tlsext_channel_id_valid| is true, then this contains the - * verified Channel ID from the client: a P256 point, (x,y), where - * each are big-endian values. */ - uint8_t tlsext_channel_id[64]; -} SSL3_STATE; - -/* SSLv3 */ -/* client */ -/* extra state */ -#define SSL3_ST_CW_FLUSH (0x100 | SSL_ST_CONNECT) -#define SSL3_ST_FALSE_START (0x101 | SSL_ST_CONNECT) -/* write to server */ -#define SSL3_ST_CW_CLNT_HELLO_A (0x110 | SSL_ST_CONNECT) -#define SSL3_ST_CW_CLNT_HELLO_B (0x111 | SSL_ST_CONNECT) -/* read from server */ -#define SSL3_ST_CR_SRVR_HELLO_A (0x120 | SSL_ST_CONNECT) -#define SSL3_ST_CR_SRVR_HELLO_B (0x121 | SSL_ST_CONNECT) -#define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A (0x126 | SSL_ST_CONNECT) -#define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B (0x127 | SSL_ST_CONNECT) -#define SSL3_ST_CR_CERT_A (0x130 | SSL_ST_CONNECT) -#define SSL3_ST_CR_CERT_B (0x131 | SSL_ST_CONNECT) -#define SSL3_ST_CR_KEY_EXCH_A (0x140 | SSL_ST_CONNECT) -#define SSL3_ST_CR_KEY_EXCH_B (0x141 | SSL_ST_CONNECT) -#define SSL3_ST_CR_CERT_REQ_A (0x150 | SSL_ST_CONNECT) -#define SSL3_ST_CR_CERT_REQ_B (0x151 | SSL_ST_CONNECT) -#define SSL3_ST_CR_SRVR_DONE_A (0x160 | SSL_ST_CONNECT) -#define SSL3_ST_CR_SRVR_DONE_B (0x161 | SSL_ST_CONNECT) -/* write to server */ -#define SSL3_ST_CW_CERT_A (0x170 | SSL_ST_CONNECT) -#define SSL3_ST_CW_CERT_B (0x171 | SSL_ST_CONNECT) -#define SSL3_ST_CW_CERT_C (0x172 | SSL_ST_CONNECT) -#define SSL3_ST_CW_CERT_D (0x173 | SSL_ST_CONNECT) -#define SSL3_ST_CW_KEY_EXCH_A (0x180 | SSL_ST_CONNECT) -#define SSL3_ST_CW_KEY_EXCH_B (0x181 | SSL_ST_CONNECT) -#define SSL3_ST_CW_CERT_VRFY_A (0x190 | SSL_ST_CONNECT) -#define SSL3_ST_CW_CERT_VRFY_B (0x191 | SSL_ST_CONNECT) -#define SSL3_ST_CW_CHANGE_A (0x1A0 | SSL_ST_CONNECT) -#define SSL3_ST_CW_CHANGE_B (0x1A1 | SSL_ST_CONNECT) -#define SSL3_ST_CW_NEXT_PROTO_A (0x200 | SSL_ST_CONNECT) -#define SSL3_ST_CW_NEXT_PROTO_B (0x201 | SSL_ST_CONNECT) -#define SSL3_ST_CW_CHANNEL_ID_A (0x220 | SSL_ST_CONNECT) -#define SSL3_ST_CW_CHANNEL_ID_B (0x221 | SSL_ST_CONNECT) -#define SSL3_ST_CW_FINISHED_A (0x1B0 | SSL_ST_CONNECT) -#define SSL3_ST_CW_FINISHED_B (0x1B1 | SSL_ST_CONNECT) -/* read from server */ -#define SSL3_ST_CR_CHANGE (0x1C0 | SSL_ST_CONNECT) -#define SSL3_ST_CR_FINISHED_A (0x1D0 | SSL_ST_CONNECT) -#define SSL3_ST_CR_FINISHED_B (0x1D1 | SSL_ST_CONNECT) -#define SSL3_ST_CR_SESSION_TICKET_A (0x1E0 | SSL_ST_CONNECT) -#define SSL3_ST_CR_SESSION_TICKET_B (0x1E1 | SSL_ST_CONNECT) -#define SSL3_ST_CR_CERT_STATUS_A (0x1F0 | SSL_ST_CONNECT) -#define SSL3_ST_CR_CERT_STATUS_B (0x1F1 | SSL_ST_CONNECT) - -/* server */ -/* extra state */ -#define SSL3_ST_SW_FLUSH (0x100 | SSL_ST_ACCEPT) -/* read from client */ -#define SSL3_ST_SR_INITIAL_BYTES (0x240 | SSL_ST_ACCEPT) -#define SSL3_ST_SR_V2_CLIENT_HELLO (0x241 | SSL_ST_ACCEPT) -/* Do not change the number values, they do matter */ -#define SSL3_ST_SR_CLNT_HELLO_A (0x110 | SSL_ST_ACCEPT) -#define SSL3_ST_SR_CLNT_HELLO_B (0x111 | SSL_ST_ACCEPT) -#define SSL3_ST_SR_CLNT_HELLO_C (0x112 | SSL_ST_ACCEPT) -#define SSL3_ST_SR_CLNT_HELLO_D (0x115 | SSL_ST_ACCEPT) -/* write to client */ -#define SSL3_ST_SW_HELLO_REQ_A (0x120 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_HELLO_REQ_B (0x121 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_HELLO_REQ_C (0x122 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_SRVR_HELLO_A (0x130 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_SRVR_HELLO_B (0x131 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_CERT_A (0x140 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_CERT_B (0x141 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_KEY_EXCH_A (0x150 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_KEY_EXCH_B (0x151 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_CERT_REQ_A (0x160 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_CERT_REQ_B (0x161 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_SRVR_DONE_A (0x170 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_SRVR_DONE_B (0x171 | SSL_ST_ACCEPT) -/* read from client */ -#define SSL3_ST_SR_CERT_A (0x180 | SSL_ST_ACCEPT) -#define SSL3_ST_SR_CERT_B (0x181 | SSL_ST_ACCEPT) -#define SSL3_ST_SR_KEY_EXCH_A (0x190 | SSL_ST_ACCEPT) -#define SSL3_ST_SR_KEY_EXCH_B (0x191 | SSL_ST_ACCEPT) -#define SSL3_ST_SR_CERT_VRFY_A (0x1A0 | SSL_ST_ACCEPT) -#define SSL3_ST_SR_CERT_VRFY_B (0x1A1 | SSL_ST_ACCEPT) -#define SSL3_ST_SR_CHANGE (0x1B0 | SSL_ST_ACCEPT) -#define SSL3_ST_SR_NEXT_PROTO_A (0x210 | SSL_ST_ACCEPT) -#define SSL3_ST_SR_NEXT_PROTO_B (0x211 | SSL_ST_ACCEPT) -#define SSL3_ST_SR_CHANNEL_ID_A (0x230 | SSL_ST_ACCEPT) -#define SSL3_ST_SR_CHANNEL_ID_B (0x231 | SSL_ST_ACCEPT) -#define SSL3_ST_SR_FINISHED_A (0x1C0 | SSL_ST_ACCEPT) -#define SSL3_ST_SR_FINISHED_B (0x1C1 | SSL_ST_ACCEPT) - -/* write to client */ -#define SSL3_ST_SW_CHANGE_A (0x1D0 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_CHANGE_B (0x1D1 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_FINISHED_A (0x1E0 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_FINISHED_B (0x1E1 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_SESSION_TICKET_A (0x1F0 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_SESSION_TICKET_B (0x1F1 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_CERT_STATUS_A (0x200 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_CERT_STATUS_B (0x201 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_SUPPLEMENTAL_DATA_A (0x220 | SSL_ST_ACCEPT) -#define SSL3_ST_SW_SUPPLEMENTAL_DATA_B (0x221 | SSL_ST_ACCEPT) - -#define SSL3_MT_HELLO_REQUEST 0 -#define SSL3_MT_CLIENT_HELLO 1 -#define SSL3_MT_SERVER_HELLO 2 -#define SSL3_MT_NEWSESSION_TICKET 4 -#define SSL3_MT_CERTIFICATE 11 -#define SSL3_MT_SERVER_KEY_EXCHANGE 12 -#define SSL3_MT_CERTIFICATE_REQUEST 13 -#define SSL3_MT_SERVER_DONE 14 -#define SSL3_MT_CERTIFICATE_VERIFY 15 -#define SSL3_MT_CLIENT_KEY_EXCHANGE 16 -#define SSL3_MT_FINISHED 20 -#define SSL3_MT_CERTIFICATE_STATUS 22 -#define SSL3_MT_SUPPLEMENTAL_DATA 23 -#define SSL3_MT_NEXT_PROTO 67 -#define SSL3_MT_ENCRYPTED_EXTENSIONS 203 -#define DTLS1_MT_HELLO_VERIFY_REQUEST 3 - - -#define SSL3_MT_CCS 1 - -/* These are used when changing over to a new cipher */ -#define SSL3_CC_READ 0x01 -#define SSL3_CC_WRITE 0x02 -#define SSL3_CC_CLIENT 0x10 -#define SSL3_CC_SERVER 0x20 -#define SSL3_CHANGE_CIPHER_CLIENT_WRITE (SSL3_CC_CLIENT | SSL3_CC_WRITE) -#define SSL3_CHANGE_CIPHER_SERVER_READ (SSL3_CC_SERVER | SSL3_CC_READ) -#define SSL3_CHANGE_CIPHER_CLIENT_READ (SSL3_CC_CLIENT | SSL3_CC_READ) -#define SSL3_CHANGE_CIPHER_SERVER_WRITE (SSL3_CC_SERVER | SSL3_CC_WRITE) - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/phonelibs/boringssl/include/openssl/stack.h b/phonelibs/boringssl/include/openssl/stack.h deleted file mode 100644 index 350fa145781ea4..00000000000000 --- a/phonelibs/boringssl/include/openssl/stack.h +++ /dev/null @@ -1,301 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_STACK_H -#define OPENSSL_HEADER_STACK_H - -#include - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* A stack, in OpenSSL, is an array of pointers. They are the most commonly - * used collection object. - * - * This file defines macros for type safe use of the stack functions. A stack - * of a specific type of object has type |STACK_OF(type)|. This can be defined - * (once) with |DEFINE_STACK_OF(type)| and declared where needed with - * |DECLARE_STACK_OF(type)|. For example: - * - * struct foo { - * int bar; - * }; - * - * DEFINE_STACK_OF(struct foo); - * - * Although note that the stack will contain /pointers/ to |foo|. - * - * A macro will be defined for each of the sk_* functions below. For - * STACK_OF(foo), the macros would be sk_foo_new, sk_foo_pop etc. */ - - -/* stack_cmp_func is a comparison function that returns a value < 0, 0 or > 0 - * if |*a| is less than, equal to or greater than |*b|, respectively. Note the - * extra indirection - the function is given a pointer to a pointer to the - * element. This differs from the usual qsort/bsearch comparison function. */ -typedef int (*stack_cmp_func)(const void **a, const void **b); - -/* stack_st contains an array of pointers. It is not designed to be used - * directly, rather the wrapper macros should be used. */ -typedef struct stack_st { - /* num contains the number of valid pointers in |data|. */ - size_t num; - void **data; - /* sorted is non-zero if the values pointed to by |data| are in ascending - * order, based on |comp|. */ - size_t sorted; - /* num_alloc contains the number of pointers allocated in the buffer pointed - * to by |data|, which may be larger than |num|. */ - size_t num_alloc; - /* comp is an optional comparison function. */ - stack_cmp_func comp; -} _STACK; - - -#define STACK_OF(type) struct stack_st_##type - -#define DEFINE_STACK_OF(type) \ -STACK_OF(type) {\ - _STACK stack; \ -} - -#define DECLARE_STACK_OF(type) STACK_OF(type); - -/* The make_macros.sh script in this directory parses the following lines and - * generates the stack_macros.h file that contains macros for the following - * types of stacks: - * - * STACK_OF:ACCESS_DESCRIPTION - * STACK_OF:ASN1_ADB_TABLE - * STACK_OF:ASN1_GENERALSTRING - * STACK_OF:ASN1_INTEGER - * STACK_OF:ASN1_OBJECT - * STACK_OF:ASN1_STRING_TABLE - * STACK_OF:ASN1_TYPE - * STACK_OF:ASN1_VALUE - * STACK_OF:BIO - * STACK_OF:BY_DIR_ENTRY - * STACK_OF:BY_DIR_HASH - * STACK_OF:CONF_VALUE - * STACK_OF:CRYPTO_EX_DATA_FUNCS - * STACK_OF:DIST_POINT - * STACK_OF:GENERAL_NAME - * STACK_OF:GENERAL_NAMES - * STACK_OF:GENERAL_SUBTREE - * STACK_OF:MIME_HEADER - * STACK_OF:PKCS7_SIGNER_INFO - * STACK_OF:PKCS7_RECIP_INFO - * STACK_OF:POLICYINFO - * STACK_OF:POLICYQUALINFO - * STACK_OF:POLICY_MAPPING - * STACK_OF:SSL_COMP - * STACK_OF:STACK_OF_X509_NAME_ENTRY - * STACK_OF:SXNETID - * STACK_OF:X509 - * STACK_OF:X509V3_EXT_METHOD - * STACK_OF:X509_ALGOR - * STACK_OF:X509_ATTRIBUTE - * STACK_OF:X509_CRL - * STACK_OF:X509_EXTENSION - * STACK_OF:X509_INFO - * STACK_OF:X509_LOOKUP - * STACK_OF:X509_NAME - * STACK_OF:X509_NAME_ENTRY - * STACK_OF:X509_OBJECT - * STACK_OF:X509_POLICY_DATA - * STACK_OF:X509_POLICY_NODE - * STACK_OF:X509_PURPOSE - * STACK_OF:X509_REVOKED - * STACK_OF:X509_TRUST - * STACK_OF:X509_VERIFY_PARAM - * STACK_OF:void - * - * Some stacks contain only const structures, so the stack should return const - * pointers to retain type-checking. - * - * CONST_STACK_OF:SRTP_PROTECTION_PROFILE - * CONST_STACK_OF:SSL_CIPHER */ - - -/* Some stacks are special because, although we would like STACK_OF(char *), - * that would actually be a stack of pointers to char*, but we just want to - * point to the string directly. In this case we call them "special" and use - * |DEFINE_SPECIAL_STACK_OF(type)| */ -#define DEFINE_SPECIAL_STACK_OF(type, inner) \ - STACK_OF(type) { _STACK special_stack; }; \ - OPENSSL_COMPILE_ASSERT(sizeof(type) == sizeof(void *), \ - special_stack_of_non_pointer_##type); - -typedef char *OPENSSL_STRING; - -DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char) -DEFINE_SPECIAL_STACK_OF(OPENSSL_BLOCK, uint8_t) - -/* The make_macros.sh script in this directory parses the following lines and - * generates the stack_macros.h file that contains macros for the following - * types of stacks: - * - * SPECIAL_STACK_OF:OPENSSL_STRING - * SPECIAL_STACK_OF:OPENSSL_BLOCK */ - -#define IN_STACK_H -#include -#undef IN_STACK_H - - -/* These are the raw stack functions, you shouldn't be using them. Rather you - * should be using the type stack macros implemented above. */ - -/* sk_new creates a new, empty stack with the given comparison function, which - * may be zero. It returns the new stack or NULL on allocation failure. */ -OPENSSL_EXPORT _STACK *sk_new(stack_cmp_func comp); - -/* sk_new_null creates a new, empty stack. It returns the new stack or NULL on - * allocation failure. */ -OPENSSL_EXPORT _STACK *sk_new_null(void); - -/* sk_num returns the number of elements in |s|. */ -OPENSSL_EXPORT size_t sk_num(const _STACK *sk); - -/* sk_zero resets |sk| to the empty state but does nothing to free the - * individual elements themselves. */ -OPENSSL_EXPORT void sk_zero(_STACK *sk); - -/* sk_value returns the |i|th pointer in |sk|, or NULL if |i| is out of - * range. */ -OPENSSL_EXPORT void *sk_value(const _STACK *sk, size_t i); - -/* sk_set sets the |i|th pointer in |sk| to |p| and returns |p|. If |i| is out - * of range, it returns NULL. */ -OPENSSL_EXPORT void *sk_set(_STACK *sk, size_t i, void *p); - -/* sk_free frees the given stack and array of pointers, but does nothing to - * free the individual elements. Also see |sk_pop_free|. */ -OPENSSL_EXPORT void sk_free(_STACK *sk); - -/* sk_pop_free calls |free_func| on each element in the stack and then frees - * the stack itself. */ -OPENSSL_EXPORT void sk_pop_free(_STACK *sk, void (*free_func)(void *)); - -/* sk_insert inserts |p| into the stack at index |where|, moving existing - * elements if needed. It returns the length of the new stack, or zero on - * error. */ -OPENSSL_EXPORT size_t sk_insert(_STACK *sk, void *p, size_t where); - -/* sk_delete removes the pointer at index |where|, moving other elements down - * if needed. It returns the removed pointer, or NULL if |where| is out of - * range. */ -OPENSSL_EXPORT void *sk_delete(_STACK *sk, size_t where); - -/* sk_delete_ptr removes, at most, one instance of |p| from the stack based on - * pointer equality. If an instance of |p| is found then |p| is returned, - * otherwise it returns NULL. */ -OPENSSL_EXPORT void *sk_delete_ptr(_STACK *sk, void *p); - -/* sk_find returns the first value in the stack equal to |p|. If a comparison - * function has been set on the stack, then equality is defined by it and the - * stack will be sorted if need be so that a binary search can be used. - * Otherwise pointer equality is used. If a matching element is found, its - * index is written to |*out_index| (if |out_index| is not NULL) and one is - * returned. Otherwise zero is returned. */ -OPENSSL_EXPORT int sk_find(_STACK *sk, size_t *out_index, void *p); - -/* sk_shift removes and returns the first element in the stack, or returns NULL - * if the stack is empty. */ -OPENSSL_EXPORT void *sk_shift(_STACK *sk); - -/* sk_push appends |p| to the stack and returns the length of the new stack, or - * 0 on allocation failure. */ -OPENSSL_EXPORT size_t sk_push(_STACK *sk, void *p); - -/* sk_pop returns and removes the last element on the stack, or NULL if the - * stack is empty. */ -OPENSSL_EXPORT void *sk_pop(_STACK *sk); - -/* sk_dup performs a shallow copy of a stack and returns the new stack, or NULL - * on error. */ -OPENSSL_EXPORT _STACK *sk_dup(const _STACK *sk); - -/* sk_sort sorts the elements of |sk| into ascending order based on the - * comparison function. The stack maintains a |sorted| flag and sorting an - * already sorted stack is a no-op. */ -OPENSSL_EXPORT void sk_sort(_STACK *sk); - -/* sk_is_sorted returns one if |sk| is known to be sorted and zero - * otherwise. */ -OPENSSL_EXPORT int sk_is_sorted(const _STACK *sk); - -/* sk_set_cmp_func sets the comparison function to be used by |sk| and returns - * the previous one. */ -OPENSSL_EXPORT stack_cmp_func sk_set_cmp_func(_STACK *sk, stack_cmp_func comp); - -/* sk_deep_copy performs a copy of |sk| and of each of the non-NULL elements in - * |sk| by using |copy_func|. If an error occurs, |free_func| is used to free - * any copies already made and NULL is returned. */ -OPENSSL_EXPORT _STACK *sk_deep_copy(const _STACK *sk, - void *(*copy_func)(void *), - void (*free_func)(void *)); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_STACK_H */ diff --git a/phonelibs/boringssl/include/openssl/stack_macros.h b/phonelibs/boringssl/include/openssl/stack_macros.h deleted file mode 100644 index dadcf6bec5d818..00000000000000 --- a/phonelibs/boringssl/include/openssl/stack_macros.h +++ /dev/null @@ -1,4004 +0,0 @@ -/* Copyright (c) 2014, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -#if !defined(IN_STACK_H) -#error "Don't include this file directly. Include stack.h." -#endif - -/* ACCESS_DESCRIPTION */ -#define sk_ACCESS_DESCRIPTION_new(comp) \ - ((STACK_OF(ACCESS_DESCRIPTION) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, \ - int (*)(const ACCESS_DESCRIPTION **a, const ACCESS_DESCRIPTION **b), \ - comp))) - -#define sk_ACCESS_DESCRIPTION_new_null() \ - ((STACK_OF(ACCESS_DESCRIPTION) *)sk_new_null()) - -#define sk_ACCESS_DESCRIPTION_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk)) - -#define sk_ACCESS_DESCRIPTION_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk)); - -#define sk_ACCESS_DESCRIPTION_value(sk, i) \ - ((ACCESS_DESCRIPTION *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(ACCESS_DESCRIPTION) *, sk), (i))) - -#define sk_ACCESS_DESCRIPTION_set(sk, i, p) \ - ((ACCESS_DESCRIPTION *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk), (i), \ - CHECKED_CAST(void *, ACCESS_DESCRIPTION *, p))) - -#define sk_ACCESS_DESCRIPTION_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk)) - -#define sk_ACCESS_DESCRIPTION_pop_free(sk, free_func) \ - sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(ACCESS_DESCRIPTION *), \ - free_func)) - -#define sk_ACCESS_DESCRIPTION_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk), \ - CHECKED_CAST(void *, ACCESS_DESCRIPTION *, p), (where)) - -#define sk_ACCESS_DESCRIPTION_delete(sk, where) \ - ((ACCESS_DESCRIPTION *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk), (where))) - -#define sk_ACCESS_DESCRIPTION_delete_ptr(sk, p) \ - ((ACCESS_DESCRIPTION *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk), \ - CHECKED_CAST(void *, ACCESS_DESCRIPTION *, p))) - -#define sk_ACCESS_DESCRIPTION_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk), \ - (out_index), CHECKED_CAST(void *, ACCESS_DESCRIPTION *, p)) - -#define sk_ACCESS_DESCRIPTION_shift(sk) \ - ((ACCESS_DESCRIPTION *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk))) - -#define sk_ACCESS_DESCRIPTION_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk), \ - CHECKED_CAST(void *, ACCESS_DESCRIPTION *, p)) - -#define sk_ACCESS_DESCRIPTION_pop(sk) \ - ((ACCESS_DESCRIPTION *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk))) - -#define sk_ACCESS_DESCRIPTION_dup(sk) \ - ((STACK_OF(ACCESS_DESCRIPTION) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(ACCESS_DESCRIPTION) *, sk))) - -#define sk_ACCESS_DESCRIPTION_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk)) - -#define sk_ACCESS_DESCRIPTION_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(ACCESS_DESCRIPTION) *, sk)) - -#define sk_ACCESS_DESCRIPTION_set_cmp_func(sk, comp) \ - ((int (*)(const ACCESS_DESCRIPTION **a, const ACCESS_DESCRIPTION **b)) \ - sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk), \ - CHECKED_CAST(stack_cmp_func, int (*)(const ACCESS_DESCRIPTION **a, \ - const ACCESS_DESCRIPTION **b), \ - comp))) - -#define sk_ACCESS_DESCRIPTION_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(ACCESS_DESCRIPTION) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(ACCESS_DESCRIPTION) *, sk), \ - CHECKED_CAST(void *(*)(void *), \ - ACCESS_DESCRIPTION *(*)(ACCESS_DESCRIPTION *), copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(ACCESS_DESCRIPTION *), \ - free_func))) - -/* ASN1_ADB_TABLE */ -#define sk_ASN1_ADB_TABLE_new(comp) \ - ((STACK_OF(ASN1_ADB_TABLE) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, \ - int (*)(const ASN1_ADB_TABLE **a, const ASN1_ADB_TABLE **b), comp))) - -#define sk_ASN1_ADB_TABLE_new_null() ((STACK_OF(ASN1_ADB_TABLE) *)sk_new_null()) - -#define sk_ASN1_ADB_TABLE_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk)) - -#define sk_ASN1_ADB_TABLE_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk)); - -#define sk_ASN1_ADB_TABLE_value(sk, i) \ - ((ASN1_ADB_TABLE *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(ASN1_ADB_TABLE) *, sk), (i))) - -#define sk_ASN1_ADB_TABLE_set(sk, i, p) \ - ((ASN1_ADB_TABLE *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk), (i), \ - CHECKED_CAST(void *, ASN1_ADB_TABLE *, p))) - -#define sk_ASN1_ADB_TABLE_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk)) - -#define sk_ASN1_ADB_TABLE_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(ASN1_ADB_TABLE *), free_func)) - -#define sk_ASN1_ADB_TABLE_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk), \ - CHECKED_CAST(void *, ASN1_ADB_TABLE *, p), (where)) - -#define sk_ASN1_ADB_TABLE_delete(sk, where) \ - ((ASN1_ADB_TABLE *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk), (where))) - -#define sk_ASN1_ADB_TABLE_delete_ptr(sk, p) \ - ((ASN1_ADB_TABLE *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk), \ - CHECKED_CAST(void *, ASN1_ADB_TABLE *, p))) - -#define sk_ASN1_ADB_TABLE_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk), (out_index), \ - CHECKED_CAST(void *, ASN1_ADB_TABLE *, p)) - -#define sk_ASN1_ADB_TABLE_shift(sk) \ - ((ASN1_ADB_TABLE *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk))) - -#define sk_ASN1_ADB_TABLE_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk), \ - CHECKED_CAST(void *, ASN1_ADB_TABLE *, p)) - -#define sk_ASN1_ADB_TABLE_pop(sk) \ - ((ASN1_ADB_TABLE *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk))) - -#define sk_ASN1_ADB_TABLE_dup(sk) \ - ((STACK_OF(ASN1_ADB_TABLE) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(ASN1_ADB_TABLE) *, sk))) - -#define sk_ASN1_ADB_TABLE_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk)) - -#define sk_ASN1_ADB_TABLE_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(ASN1_ADB_TABLE) *, sk)) - -#define sk_ASN1_ADB_TABLE_set_cmp_func(sk, comp) \ - ((int (*)(const ASN1_ADB_TABLE **a, const ASN1_ADB_TABLE **b)) \ - sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk), \ - CHECKED_CAST(stack_cmp_func, int (*)(const ASN1_ADB_TABLE **a, \ - const ASN1_ADB_TABLE **b), \ - comp))) - -#define sk_ASN1_ADB_TABLE_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(ASN1_ADB_TABLE) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_ADB_TABLE) *, sk), \ - CHECKED_CAST(void *(*)(void *), ASN1_ADB_TABLE *(*)(ASN1_ADB_TABLE *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(ASN1_ADB_TABLE *), free_func))) - -/* ASN1_GENERALSTRING */ -#define sk_ASN1_GENERALSTRING_new(comp) \ - ((STACK_OF(ASN1_GENERALSTRING) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, \ - int (*)(const ASN1_GENERALSTRING **a, const ASN1_GENERALSTRING **b), \ - comp))) - -#define sk_ASN1_GENERALSTRING_new_null() \ - ((STACK_OF(ASN1_GENERALSTRING) *)sk_new_null()) - -#define sk_ASN1_GENERALSTRING_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk)) - -#define sk_ASN1_GENERALSTRING_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk)); - -#define sk_ASN1_GENERALSTRING_value(sk, i) \ - ((ASN1_GENERALSTRING *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(ASN1_GENERALSTRING) *, sk), (i))) - -#define sk_ASN1_GENERALSTRING_set(sk, i, p) \ - ((ASN1_GENERALSTRING *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk), (i), \ - CHECKED_CAST(void *, ASN1_GENERALSTRING *, p))) - -#define sk_ASN1_GENERALSTRING_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk)) - -#define sk_ASN1_GENERALSTRING_pop_free(sk, free_func) \ - sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(ASN1_GENERALSTRING *), \ - free_func)) - -#define sk_ASN1_GENERALSTRING_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk), \ - CHECKED_CAST(void *, ASN1_GENERALSTRING *, p), (where)) - -#define sk_ASN1_GENERALSTRING_delete(sk, where) \ - ((ASN1_GENERALSTRING *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk), (where))) - -#define sk_ASN1_GENERALSTRING_delete_ptr(sk, p) \ - ((ASN1_GENERALSTRING *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk), \ - CHECKED_CAST(void *, ASN1_GENERALSTRING *, p))) - -#define sk_ASN1_GENERALSTRING_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk), \ - (out_index), CHECKED_CAST(void *, ASN1_GENERALSTRING *, p)) - -#define sk_ASN1_GENERALSTRING_shift(sk) \ - ((ASN1_GENERALSTRING *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk))) - -#define sk_ASN1_GENERALSTRING_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk), \ - CHECKED_CAST(void *, ASN1_GENERALSTRING *, p)) - -#define sk_ASN1_GENERALSTRING_pop(sk) \ - ((ASN1_GENERALSTRING *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk))) - -#define sk_ASN1_GENERALSTRING_dup(sk) \ - ((STACK_OF(ASN1_GENERALSTRING) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(ASN1_GENERALSTRING) *, sk))) - -#define sk_ASN1_GENERALSTRING_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk)) - -#define sk_ASN1_GENERALSTRING_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(ASN1_GENERALSTRING) *, sk)) - -#define sk_ASN1_GENERALSTRING_set_cmp_func(sk, comp) \ - ((int (*)(const ASN1_GENERALSTRING **a, const ASN1_GENERALSTRING **b)) \ - sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk), \ - CHECKED_CAST(stack_cmp_func, int (*)(const ASN1_GENERALSTRING **a, \ - const ASN1_GENERALSTRING **b), \ - comp))) - -#define sk_ASN1_GENERALSTRING_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(ASN1_GENERALSTRING) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_GENERALSTRING) *, sk), \ - CHECKED_CAST(void *(*)(void *), \ - ASN1_GENERALSTRING *(*)(ASN1_GENERALSTRING *), copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(ASN1_GENERALSTRING *), \ - free_func))) - -/* ASN1_INTEGER */ -#define sk_ASN1_INTEGER_new(comp) \ - ((STACK_OF(ASN1_INTEGER) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const ASN1_INTEGER **a, const ASN1_INTEGER **b), \ - comp))) - -#define sk_ASN1_INTEGER_new_null() ((STACK_OF(ASN1_INTEGER) *)sk_new_null()) - -#define sk_ASN1_INTEGER_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk)) - -#define sk_ASN1_INTEGER_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk)); - -#define sk_ASN1_INTEGER_value(sk, i) \ - ((ASN1_INTEGER *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(ASN1_INTEGER) *, sk), (i))) - -#define sk_ASN1_INTEGER_set(sk, i, p) \ - ((ASN1_INTEGER *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk), (i), \ - CHECKED_CAST(void *, ASN1_INTEGER *, p))) - -#define sk_ASN1_INTEGER_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk)) - -#define sk_ASN1_INTEGER_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(ASN1_INTEGER *), free_func)) - -#define sk_ASN1_INTEGER_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk), \ - CHECKED_CAST(void *, ASN1_INTEGER *, p), (where)) - -#define sk_ASN1_INTEGER_delete(sk, where) \ - ((ASN1_INTEGER *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk), (where))) - -#define sk_ASN1_INTEGER_delete_ptr(sk, p) \ - ((ASN1_INTEGER *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk), \ - CHECKED_CAST(void *, ASN1_INTEGER *, p))) - -#define sk_ASN1_INTEGER_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk), (out_index), \ - CHECKED_CAST(void *, ASN1_INTEGER *, p)) - -#define sk_ASN1_INTEGER_shift(sk) \ - ((ASN1_INTEGER *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk))) - -#define sk_ASN1_INTEGER_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk), \ - CHECKED_CAST(void *, ASN1_INTEGER *, p)) - -#define sk_ASN1_INTEGER_pop(sk) \ - ((ASN1_INTEGER *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk))) - -#define sk_ASN1_INTEGER_dup(sk) \ - ((STACK_OF(ASN1_INTEGER) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(ASN1_INTEGER) *, sk))) - -#define sk_ASN1_INTEGER_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk)) - -#define sk_ASN1_INTEGER_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(ASN1_INTEGER) *, sk)) - -#define sk_ASN1_INTEGER_set_cmp_func(sk, comp) \ - ((int (*)(const ASN1_INTEGER **a, const ASN1_INTEGER **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const ASN1_INTEGER **a, const ASN1_INTEGER **b), \ - comp))) - -#define sk_ASN1_INTEGER_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(ASN1_INTEGER) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_INTEGER) *, sk), \ - CHECKED_CAST(void *(*)(void *), ASN1_INTEGER *(*)(ASN1_INTEGER *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(ASN1_INTEGER *), free_func))) - -/* ASN1_OBJECT */ -#define sk_ASN1_OBJECT_new(comp) \ - ((STACK_OF(ASN1_OBJECT) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const ASN1_OBJECT **a, const ASN1_OBJECT **b), \ - comp))) - -#define sk_ASN1_OBJECT_new_null() ((STACK_OF(ASN1_OBJECT) *)sk_new_null()) - -#define sk_ASN1_OBJECT_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk)) - -#define sk_ASN1_OBJECT_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk)); - -#define sk_ASN1_OBJECT_value(sk, i) \ - ((ASN1_OBJECT *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(ASN1_OBJECT) *, sk), (i))) - -#define sk_ASN1_OBJECT_set(sk, i, p) \ - ((ASN1_OBJECT *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk), \ - (i), CHECKED_CAST(void *, ASN1_OBJECT *, p))) - -#define sk_ASN1_OBJECT_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk)) - -#define sk_ASN1_OBJECT_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(ASN1_OBJECT *), free_func)) - -#define sk_ASN1_OBJECT_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk), \ - CHECKED_CAST(void *, ASN1_OBJECT *, p), (where)) - -#define sk_ASN1_OBJECT_delete(sk, where) \ - ((ASN1_OBJECT *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk), (where))) - -#define sk_ASN1_OBJECT_delete_ptr(sk, p) \ - ((ASN1_OBJECT *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk), \ - CHECKED_CAST(void *, ASN1_OBJECT *, p))) - -#define sk_ASN1_OBJECT_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk), (out_index), \ - CHECKED_CAST(void *, ASN1_OBJECT *, p)) - -#define sk_ASN1_OBJECT_shift(sk) \ - ((ASN1_OBJECT *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk))) - -#define sk_ASN1_OBJECT_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk), \ - CHECKED_CAST(void *, ASN1_OBJECT *, p)) - -#define sk_ASN1_OBJECT_pop(sk) \ - ((ASN1_OBJECT *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk))) - -#define sk_ASN1_OBJECT_dup(sk) \ - ((STACK_OF(ASN1_OBJECT) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(ASN1_OBJECT) *, sk))) - -#define sk_ASN1_OBJECT_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk)) - -#define sk_ASN1_OBJECT_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(ASN1_OBJECT) *, sk)) - -#define sk_ASN1_OBJECT_set_cmp_func(sk, comp) \ - ((int (*)(const ASN1_OBJECT **a, const ASN1_OBJECT **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const ASN1_OBJECT **a, const ASN1_OBJECT **b), \ - comp))) - -#define sk_ASN1_OBJECT_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(ASN1_OBJECT) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_OBJECT) *, sk), \ - CHECKED_CAST(void *(*)(void *), ASN1_OBJECT *(*)(ASN1_OBJECT *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(ASN1_OBJECT *), free_func))) - -/* ASN1_STRING_TABLE */ -#define sk_ASN1_STRING_TABLE_new(comp) \ - ((STACK_OF(ASN1_STRING_TABLE) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, \ - int (*)(const ASN1_STRING_TABLE **a, const ASN1_STRING_TABLE **b), \ - comp))) - -#define sk_ASN1_STRING_TABLE_new_null() \ - ((STACK_OF(ASN1_STRING_TABLE) *)sk_new_null()) - -#define sk_ASN1_STRING_TABLE_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk)) - -#define sk_ASN1_STRING_TABLE_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk)); - -#define sk_ASN1_STRING_TABLE_value(sk, i) \ - ((ASN1_STRING_TABLE *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(ASN1_STRING_TABLE) *, sk), (i))) - -#define sk_ASN1_STRING_TABLE_set(sk, i, p) \ - ((ASN1_STRING_TABLE *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk), (i), \ - CHECKED_CAST(void *, ASN1_STRING_TABLE *, p))) - -#define sk_ASN1_STRING_TABLE_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk)) - -#define sk_ASN1_STRING_TABLE_pop_free(sk, free_func) \ - sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(ASN1_STRING_TABLE *), \ - free_func)) - -#define sk_ASN1_STRING_TABLE_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk), \ - CHECKED_CAST(void *, ASN1_STRING_TABLE *, p), (where)) - -#define sk_ASN1_STRING_TABLE_delete(sk, where) \ - ((ASN1_STRING_TABLE *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk), (where))) - -#define sk_ASN1_STRING_TABLE_delete_ptr(sk, p) \ - ((ASN1_STRING_TABLE *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk), \ - CHECKED_CAST(void *, ASN1_STRING_TABLE *, p))) - -#define sk_ASN1_STRING_TABLE_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk), \ - (out_index), CHECKED_CAST(void *, ASN1_STRING_TABLE *, p)) - -#define sk_ASN1_STRING_TABLE_shift(sk) \ - ((ASN1_STRING_TABLE *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk))) - -#define sk_ASN1_STRING_TABLE_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk), \ - CHECKED_CAST(void *, ASN1_STRING_TABLE *, p)) - -#define sk_ASN1_STRING_TABLE_pop(sk) \ - ((ASN1_STRING_TABLE *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk))) - -#define sk_ASN1_STRING_TABLE_dup(sk) \ - ((STACK_OF(ASN1_STRING_TABLE) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(ASN1_STRING_TABLE) *, sk))) - -#define sk_ASN1_STRING_TABLE_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk)) - -#define sk_ASN1_STRING_TABLE_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(ASN1_STRING_TABLE) *, sk)) - -#define sk_ASN1_STRING_TABLE_set_cmp_func(sk, comp) \ - ((int (*)(const ASN1_STRING_TABLE **a, const ASN1_STRING_TABLE **b)) \ - sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk), \ - CHECKED_CAST(stack_cmp_func, int (*)(const ASN1_STRING_TABLE **a, \ - const ASN1_STRING_TABLE **b), \ - comp))) - -#define sk_ASN1_STRING_TABLE_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(ASN1_STRING_TABLE) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_STRING_TABLE) *, sk), \ - CHECKED_CAST(void *(*)(void *), \ - ASN1_STRING_TABLE *(*)(ASN1_STRING_TABLE *), copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(ASN1_STRING_TABLE *), \ - free_func))) - -/* ASN1_TYPE */ -#define sk_ASN1_TYPE_new(comp) \ - ((STACK_OF(ASN1_TYPE) *)sk_new( \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const ASN1_TYPE **a, const ASN1_TYPE **b), comp))) - -#define sk_ASN1_TYPE_new_null() ((STACK_OF(ASN1_TYPE) *)sk_new_null()) - -#define sk_ASN1_TYPE_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk)) - -#define sk_ASN1_TYPE_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk)); - -#define sk_ASN1_TYPE_value(sk, i) \ - ((ASN1_TYPE *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(ASN1_TYPE) *, sk), (i))) - -#define sk_ASN1_TYPE_set(sk, i, p) \ - ((ASN1_TYPE *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk), (i), \ - CHECKED_CAST(void *, ASN1_TYPE *, p))) - -#define sk_ASN1_TYPE_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk)) - -#define sk_ASN1_TYPE_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(ASN1_TYPE *), free_func)) - -#define sk_ASN1_TYPE_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk), \ - CHECKED_CAST(void *, ASN1_TYPE *, p), (where)) - -#define sk_ASN1_TYPE_delete(sk, where) \ - ((ASN1_TYPE *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk), \ - (where))) - -#define sk_ASN1_TYPE_delete_ptr(sk, p) \ - ((ASN1_TYPE *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk), \ - CHECKED_CAST(void *, ASN1_TYPE *, p))) - -#define sk_ASN1_TYPE_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk), (out_index), \ - CHECKED_CAST(void *, ASN1_TYPE *, p)) - -#define sk_ASN1_TYPE_shift(sk) \ - ((ASN1_TYPE *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk))) - -#define sk_ASN1_TYPE_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk), \ - CHECKED_CAST(void *, ASN1_TYPE *, p)) - -#define sk_ASN1_TYPE_pop(sk) \ - ((ASN1_TYPE *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk))) - -#define sk_ASN1_TYPE_dup(sk) \ - ((STACK_OF(ASN1_TYPE) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(ASN1_TYPE) *, sk))) - -#define sk_ASN1_TYPE_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk)) - -#define sk_ASN1_TYPE_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(ASN1_TYPE) *, sk)) - -#define sk_ASN1_TYPE_set_cmp_func(sk, comp) \ - ((int (*)(const ASN1_TYPE **a, const ASN1_TYPE **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const ASN1_TYPE **a, const ASN1_TYPE **b), comp))) - -#define sk_ASN1_TYPE_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(ASN1_TYPE) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_TYPE) *, sk), \ - CHECKED_CAST(void *(*)(void *), ASN1_TYPE *(*)(ASN1_TYPE *), copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(ASN1_TYPE *), free_func))) - -/* ASN1_VALUE */ -#define sk_ASN1_VALUE_new(comp) \ - ((STACK_OF(ASN1_VALUE) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const ASN1_VALUE **a, const ASN1_VALUE **b), \ - comp))) - -#define sk_ASN1_VALUE_new_null() ((STACK_OF(ASN1_VALUE) *)sk_new_null()) - -#define sk_ASN1_VALUE_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk)) - -#define sk_ASN1_VALUE_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk)); - -#define sk_ASN1_VALUE_value(sk, i) \ - ((ASN1_VALUE *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(ASN1_VALUE) *, sk), (i))) - -#define sk_ASN1_VALUE_set(sk, i, p) \ - ((ASN1_VALUE *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk), \ - (i), CHECKED_CAST(void *, ASN1_VALUE *, p))) - -#define sk_ASN1_VALUE_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk)) - -#define sk_ASN1_VALUE_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(ASN1_VALUE *), free_func)) - -#define sk_ASN1_VALUE_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk), \ - CHECKED_CAST(void *, ASN1_VALUE *, p), (where)) - -#define sk_ASN1_VALUE_delete(sk, where) \ - ((ASN1_VALUE *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk), \ - (where))) - -#define sk_ASN1_VALUE_delete_ptr(sk, p) \ - ((ASN1_VALUE *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk), \ - CHECKED_CAST(void *, ASN1_VALUE *, p))) - -#define sk_ASN1_VALUE_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk), (out_index), \ - CHECKED_CAST(void *, ASN1_VALUE *, p)) - -#define sk_ASN1_VALUE_shift(sk) \ - ((ASN1_VALUE *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk))) - -#define sk_ASN1_VALUE_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk), \ - CHECKED_CAST(void *, ASN1_VALUE *, p)) - -#define sk_ASN1_VALUE_pop(sk) \ - ((ASN1_VALUE *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk))) - -#define sk_ASN1_VALUE_dup(sk) \ - ((STACK_OF(ASN1_VALUE) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(ASN1_VALUE) *, sk))) - -#define sk_ASN1_VALUE_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk)) - -#define sk_ASN1_VALUE_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(ASN1_VALUE) *, sk)) - -#define sk_ASN1_VALUE_set_cmp_func(sk, comp) \ - ((int (*)(const ASN1_VALUE **a, const ASN1_VALUE **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const ASN1_VALUE **a, const ASN1_VALUE **b), \ - comp))) - -#define sk_ASN1_VALUE_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(ASN1_VALUE) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_VALUE) *, sk), \ - CHECKED_CAST(void *(*)(void *), ASN1_VALUE *(*)(ASN1_VALUE *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(ASN1_VALUE *), free_func))) - -/* BIO */ -#define sk_BIO_new(comp) \ - ((STACK_OF(BIO) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const BIO **a, const BIO **b), comp))) - -#define sk_BIO_new_null() ((STACK_OF(BIO) *)sk_new_null()) - -#define sk_BIO_num(sk) sk_num(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk)) - -#define sk_BIO_zero(sk) sk_zero(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk)); - -#define sk_BIO_value(sk, i) \ - ((BIO *)sk_value(CHECKED_CAST(_STACK *, const STACK_OF(BIO) *, sk), (i))) - -#define sk_BIO_set(sk, i, p) \ - ((BIO *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk), (i), \ - CHECKED_CAST(void *, BIO *, p))) - -#define sk_BIO_free(sk) sk_free(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk)) - -#define sk_BIO_pop_free(sk, free_func) \ - sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(BIO *), free_func)) - -#define sk_BIO_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk), \ - CHECKED_CAST(void *, BIO *, p), (where)) - -#define sk_BIO_delete(sk, where) \ - ((BIO *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk), (where))) - -#define sk_BIO_delete_ptr(sk, p) \ - ((BIO *)sk_delete_ptr(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk), \ - CHECKED_CAST(void *, BIO *, p))) - -#define sk_BIO_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk), (out_index), \ - CHECKED_CAST(void *, BIO *, p)) - -#define sk_BIO_shift(sk) \ - ((BIO *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk))) - -#define sk_BIO_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk), \ - CHECKED_CAST(void *, BIO *, p)) - -#define sk_BIO_pop(sk) \ - ((BIO *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk))) - -#define sk_BIO_dup(sk) \ - ((STACK_OF(BIO) *)sk_dup(CHECKED_CAST(_STACK *, const STACK_OF(BIO) *, sk))) - -#define sk_BIO_sort(sk) sk_sort(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk)) - -#define sk_BIO_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(BIO) *, sk)) - -#define sk_BIO_set_cmp_func(sk, comp) \ - ((int (*)(const BIO **a, const BIO **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk), \ - CHECKED_CAST(stack_cmp_func, int (*)(const BIO **a, const BIO **b), \ - comp))) - -#define sk_BIO_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(BIO) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(BIO) *, sk), \ - CHECKED_CAST(void *(*)(void *), BIO *(*)(BIO *), copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(BIO *), free_func))) - -/* BY_DIR_ENTRY */ -#define sk_BY_DIR_ENTRY_new(comp) \ - ((STACK_OF(BY_DIR_ENTRY) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const BY_DIR_ENTRY **a, const BY_DIR_ENTRY **b), \ - comp))) - -#define sk_BY_DIR_ENTRY_new_null() ((STACK_OF(BY_DIR_ENTRY) *)sk_new_null()) - -#define sk_BY_DIR_ENTRY_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk)) - -#define sk_BY_DIR_ENTRY_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk)); - -#define sk_BY_DIR_ENTRY_value(sk, i) \ - ((BY_DIR_ENTRY *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(BY_DIR_ENTRY) *, sk), (i))) - -#define sk_BY_DIR_ENTRY_set(sk, i, p) \ - ((BY_DIR_ENTRY *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk), (i), \ - CHECKED_CAST(void *, BY_DIR_ENTRY *, p))) - -#define sk_BY_DIR_ENTRY_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk)) - -#define sk_BY_DIR_ENTRY_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(BY_DIR_ENTRY *), free_func)) - -#define sk_BY_DIR_ENTRY_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk), \ - CHECKED_CAST(void *, BY_DIR_ENTRY *, p), (where)) - -#define sk_BY_DIR_ENTRY_delete(sk, where) \ - ((BY_DIR_ENTRY *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk), (where))) - -#define sk_BY_DIR_ENTRY_delete_ptr(sk, p) \ - ((BY_DIR_ENTRY *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk), \ - CHECKED_CAST(void *, BY_DIR_ENTRY *, p))) - -#define sk_BY_DIR_ENTRY_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk), (out_index), \ - CHECKED_CAST(void *, BY_DIR_ENTRY *, p)) - -#define sk_BY_DIR_ENTRY_shift(sk) \ - ((BY_DIR_ENTRY *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk))) - -#define sk_BY_DIR_ENTRY_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk), \ - CHECKED_CAST(void *, BY_DIR_ENTRY *, p)) - -#define sk_BY_DIR_ENTRY_pop(sk) \ - ((BY_DIR_ENTRY *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk))) - -#define sk_BY_DIR_ENTRY_dup(sk) \ - ((STACK_OF(BY_DIR_ENTRY) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(BY_DIR_ENTRY) *, sk))) - -#define sk_BY_DIR_ENTRY_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk)) - -#define sk_BY_DIR_ENTRY_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(BY_DIR_ENTRY) *, sk)) - -#define sk_BY_DIR_ENTRY_set_cmp_func(sk, comp) \ - ((int (*)(const BY_DIR_ENTRY **a, const BY_DIR_ENTRY **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const BY_DIR_ENTRY **a, const BY_DIR_ENTRY **b), \ - comp))) - -#define sk_BY_DIR_ENTRY_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(BY_DIR_ENTRY) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(BY_DIR_ENTRY) *, sk), \ - CHECKED_CAST(void *(*)(void *), BY_DIR_ENTRY *(*)(BY_DIR_ENTRY *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(BY_DIR_ENTRY *), free_func))) - -/* BY_DIR_HASH */ -#define sk_BY_DIR_HASH_new(comp) \ - ((STACK_OF(BY_DIR_HASH) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const BY_DIR_HASH **a, const BY_DIR_HASH **b), \ - comp))) - -#define sk_BY_DIR_HASH_new_null() ((STACK_OF(BY_DIR_HASH) *)sk_new_null()) - -#define sk_BY_DIR_HASH_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk)) - -#define sk_BY_DIR_HASH_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk)); - -#define sk_BY_DIR_HASH_value(sk, i) \ - ((BY_DIR_HASH *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(BY_DIR_HASH) *, sk), (i))) - -#define sk_BY_DIR_HASH_set(sk, i, p) \ - ((BY_DIR_HASH *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk), \ - (i), CHECKED_CAST(void *, BY_DIR_HASH *, p))) - -#define sk_BY_DIR_HASH_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk)) - -#define sk_BY_DIR_HASH_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(BY_DIR_HASH *), free_func)) - -#define sk_BY_DIR_HASH_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk), \ - CHECKED_CAST(void *, BY_DIR_HASH *, p), (where)) - -#define sk_BY_DIR_HASH_delete(sk, where) \ - ((BY_DIR_HASH *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk), (where))) - -#define sk_BY_DIR_HASH_delete_ptr(sk, p) \ - ((BY_DIR_HASH *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk), \ - CHECKED_CAST(void *, BY_DIR_HASH *, p))) - -#define sk_BY_DIR_HASH_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk), (out_index), \ - CHECKED_CAST(void *, BY_DIR_HASH *, p)) - -#define sk_BY_DIR_HASH_shift(sk) \ - ((BY_DIR_HASH *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk))) - -#define sk_BY_DIR_HASH_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk), \ - CHECKED_CAST(void *, BY_DIR_HASH *, p)) - -#define sk_BY_DIR_HASH_pop(sk) \ - ((BY_DIR_HASH *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk))) - -#define sk_BY_DIR_HASH_dup(sk) \ - ((STACK_OF(BY_DIR_HASH) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(BY_DIR_HASH) *, sk))) - -#define sk_BY_DIR_HASH_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk)) - -#define sk_BY_DIR_HASH_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(BY_DIR_HASH) *, sk)) - -#define sk_BY_DIR_HASH_set_cmp_func(sk, comp) \ - ((int (*)(const BY_DIR_HASH **a, const BY_DIR_HASH **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const BY_DIR_HASH **a, const BY_DIR_HASH **b), \ - comp))) - -#define sk_BY_DIR_HASH_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(BY_DIR_HASH) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(BY_DIR_HASH) *, sk), \ - CHECKED_CAST(void *(*)(void *), BY_DIR_HASH *(*)(BY_DIR_HASH *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(BY_DIR_HASH *), free_func))) - -/* CONF_VALUE */ -#define sk_CONF_VALUE_new(comp) \ - ((STACK_OF(CONF_VALUE) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const CONF_VALUE **a, const CONF_VALUE **b), \ - comp))) - -#define sk_CONF_VALUE_new_null() ((STACK_OF(CONF_VALUE) *)sk_new_null()) - -#define sk_CONF_VALUE_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk)) - -#define sk_CONF_VALUE_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk)); - -#define sk_CONF_VALUE_value(sk, i) \ - ((CONF_VALUE *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(CONF_VALUE) *, sk), (i))) - -#define sk_CONF_VALUE_set(sk, i, p) \ - ((CONF_VALUE *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk), \ - (i), CHECKED_CAST(void *, CONF_VALUE *, p))) - -#define sk_CONF_VALUE_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk)) - -#define sk_CONF_VALUE_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(CONF_VALUE *), free_func)) - -#define sk_CONF_VALUE_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk), \ - CHECKED_CAST(void *, CONF_VALUE *, p), (where)) - -#define sk_CONF_VALUE_delete(sk, where) \ - ((CONF_VALUE *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk), \ - (where))) - -#define sk_CONF_VALUE_delete_ptr(sk, p) \ - ((CONF_VALUE *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk), \ - CHECKED_CAST(void *, CONF_VALUE *, p))) - -#define sk_CONF_VALUE_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk), (out_index), \ - CHECKED_CAST(void *, CONF_VALUE *, p)) - -#define sk_CONF_VALUE_shift(sk) \ - ((CONF_VALUE *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk))) - -#define sk_CONF_VALUE_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk), \ - CHECKED_CAST(void *, CONF_VALUE *, p)) - -#define sk_CONF_VALUE_pop(sk) \ - ((CONF_VALUE *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk))) - -#define sk_CONF_VALUE_dup(sk) \ - ((STACK_OF(CONF_VALUE) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(CONF_VALUE) *, sk))) - -#define sk_CONF_VALUE_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk)) - -#define sk_CONF_VALUE_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(CONF_VALUE) *, sk)) - -#define sk_CONF_VALUE_set_cmp_func(sk, comp) \ - ((int (*)(const CONF_VALUE **a, const CONF_VALUE **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const CONF_VALUE **a, const CONF_VALUE **b), \ - comp))) - -#define sk_CONF_VALUE_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(CONF_VALUE) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(CONF_VALUE) *, sk), \ - CHECKED_CAST(void *(*)(void *), CONF_VALUE *(*)(CONF_VALUE *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(CONF_VALUE *), free_func))) - -/* CRYPTO_EX_DATA_FUNCS */ -#define sk_CRYPTO_EX_DATA_FUNCS_new(comp) \ - ((STACK_OF(CRYPTO_EX_DATA_FUNCS) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, \ - int (*)(const CRYPTO_EX_DATA_FUNCS **a, const CRYPTO_EX_DATA_FUNCS **b), \ - comp))) - -#define sk_CRYPTO_EX_DATA_FUNCS_new_null() \ - ((STACK_OF(CRYPTO_EX_DATA_FUNCS) *)sk_new_null()) - -#define sk_CRYPTO_EX_DATA_FUNCS_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk)) - -#define sk_CRYPTO_EX_DATA_FUNCS_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk)); - -#define sk_CRYPTO_EX_DATA_FUNCS_value(sk, i) \ - ((CRYPTO_EX_DATA_FUNCS *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk), \ - (i))) - -#define sk_CRYPTO_EX_DATA_FUNCS_set(sk, i, p) \ - ((CRYPTO_EX_DATA_FUNCS *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk), (i), \ - CHECKED_CAST(void *, CRYPTO_EX_DATA_FUNCS *, p))) - -#define sk_CRYPTO_EX_DATA_FUNCS_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk)) - -#define sk_CRYPTO_EX_DATA_FUNCS_pop_free(sk, free_func) \ - sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(CRYPTO_EX_DATA_FUNCS *), \ - free_func)) - -#define sk_CRYPTO_EX_DATA_FUNCS_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk), \ - CHECKED_CAST(void *, CRYPTO_EX_DATA_FUNCS *, p), (where)) - -#define sk_CRYPTO_EX_DATA_FUNCS_delete(sk, where) \ - ((CRYPTO_EX_DATA_FUNCS *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk), (where))) - -#define sk_CRYPTO_EX_DATA_FUNCS_delete_ptr(sk, p) \ - ((CRYPTO_EX_DATA_FUNCS *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk), \ - CHECKED_CAST(void *, CRYPTO_EX_DATA_FUNCS *, p))) - -#define sk_CRYPTO_EX_DATA_FUNCS_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk), \ - (out_index), CHECKED_CAST(void *, CRYPTO_EX_DATA_FUNCS *, p)) - -#define sk_CRYPTO_EX_DATA_FUNCS_shift(sk) \ - ((CRYPTO_EX_DATA_FUNCS *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk))) - -#define sk_CRYPTO_EX_DATA_FUNCS_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk), \ - CHECKED_CAST(void *, CRYPTO_EX_DATA_FUNCS *, p)) - -#define sk_CRYPTO_EX_DATA_FUNCS_pop(sk) \ - ((CRYPTO_EX_DATA_FUNCS *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk))) - -#define sk_CRYPTO_EX_DATA_FUNCS_dup(sk) \ - ((STACK_OF(CRYPTO_EX_DATA_FUNCS) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk))) - -#define sk_CRYPTO_EX_DATA_FUNCS_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk)) - -#define sk_CRYPTO_EX_DATA_FUNCS_is_sorted(sk) \ - sk_is_sorted( \ - CHECKED_CAST(_STACK *, const STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk)) - -#define sk_CRYPTO_EX_DATA_FUNCS_set_cmp_func(sk, comp) \ - ((int (*)(const CRYPTO_EX_DATA_FUNCS **a, const CRYPTO_EX_DATA_FUNCS **b)) \ - sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const CRYPTO_EX_DATA_FUNCS **a, \ - const CRYPTO_EX_DATA_FUNCS **b), \ - comp))) - -#define sk_CRYPTO_EX_DATA_FUNCS_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(CRYPTO_EX_DATA_FUNCS) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(CRYPTO_EX_DATA_FUNCS) *, \ - sk), \ - CHECKED_CAST(void *(*)(void *), \ - CRYPTO_EX_DATA_FUNCS *(*)(CRYPTO_EX_DATA_FUNCS *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(CRYPTO_EX_DATA_FUNCS *), \ - free_func))) - -/* DIST_POINT */ -#define sk_DIST_POINT_new(comp) \ - ((STACK_OF(DIST_POINT) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const DIST_POINT **a, const DIST_POINT **b), \ - comp))) - -#define sk_DIST_POINT_new_null() ((STACK_OF(DIST_POINT) *)sk_new_null()) - -#define sk_DIST_POINT_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk)) - -#define sk_DIST_POINT_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk)); - -#define sk_DIST_POINT_value(sk, i) \ - ((DIST_POINT *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(DIST_POINT) *, sk), (i))) - -#define sk_DIST_POINT_set(sk, i, p) \ - ((DIST_POINT *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk), \ - (i), CHECKED_CAST(void *, DIST_POINT *, p))) - -#define sk_DIST_POINT_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk)) - -#define sk_DIST_POINT_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(DIST_POINT *), free_func)) - -#define sk_DIST_POINT_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk), \ - CHECKED_CAST(void *, DIST_POINT *, p), (where)) - -#define sk_DIST_POINT_delete(sk, where) \ - ((DIST_POINT *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk), \ - (where))) - -#define sk_DIST_POINT_delete_ptr(sk, p) \ - ((DIST_POINT *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk), \ - CHECKED_CAST(void *, DIST_POINT *, p))) - -#define sk_DIST_POINT_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk), (out_index), \ - CHECKED_CAST(void *, DIST_POINT *, p)) - -#define sk_DIST_POINT_shift(sk) \ - ((DIST_POINT *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk))) - -#define sk_DIST_POINT_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk), \ - CHECKED_CAST(void *, DIST_POINT *, p)) - -#define sk_DIST_POINT_pop(sk) \ - ((DIST_POINT *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk))) - -#define sk_DIST_POINT_dup(sk) \ - ((STACK_OF(DIST_POINT) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(DIST_POINT) *, sk))) - -#define sk_DIST_POINT_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk)) - -#define sk_DIST_POINT_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(DIST_POINT) *, sk)) - -#define sk_DIST_POINT_set_cmp_func(sk, comp) \ - ((int (*)(const DIST_POINT **a, const DIST_POINT **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const DIST_POINT **a, const DIST_POINT **b), \ - comp))) - -#define sk_DIST_POINT_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(DIST_POINT) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(DIST_POINT) *, sk), \ - CHECKED_CAST(void *(*)(void *), DIST_POINT *(*)(DIST_POINT *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(DIST_POINT *), free_func))) - -/* GENERAL_NAME */ -#define sk_GENERAL_NAME_new(comp) \ - ((STACK_OF(GENERAL_NAME) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const GENERAL_NAME **a, const GENERAL_NAME **b), \ - comp))) - -#define sk_GENERAL_NAME_new_null() ((STACK_OF(GENERAL_NAME) *)sk_new_null()) - -#define sk_GENERAL_NAME_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk)) - -#define sk_GENERAL_NAME_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk)); - -#define sk_GENERAL_NAME_value(sk, i) \ - ((GENERAL_NAME *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(GENERAL_NAME) *, sk), (i))) - -#define sk_GENERAL_NAME_set(sk, i, p) \ - ((GENERAL_NAME *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk), (i), \ - CHECKED_CAST(void *, GENERAL_NAME *, p))) - -#define sk_GENERAL_NAME_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk)) - -#define sk_GENERAL_NAME_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(GENERAL_NAME *), free_func)) - -#define sk_GENERAL_NAME_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk), \ - CHECKED_CAST(void *, GENERAL_NAME *, p), (where)) - -#define sk_GENERAL_NAME_delete(sk, where) \ - ((GENERAL_NAME *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk), (where))) - -#define sk_GENERAL_NAME_delete_ptr(sk, p) \ - ((GENERAL_NAME *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk), \ - CHECKED_CAST(void *, GENERAL_NAME *, p))) - -#define sk_GENERAL_NAME_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk), (out_index), \ - CHECKED_CAST(void *, GENERAL_NAME *, p)) - -#define sk_GENERAL_NAME_shift(sk) \ - ((GENERAL_NAME *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk))) - -#define sk_GENERAL_NAME_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk), \ - CHECKED_CAST(void *, GENERAL_NAME *, p)) - -#define sk_GENERAL_NAME_pop(sk) \ - ((GENERAL_NAME *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk))) - -#define sk_GENERAL_NAME_dup(sk) \ - ((STACK_OF(GENERAL_NAME) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(GENERAL_NAME) *, sk))) - -#define sk_GENERAL_NAME_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk)) - -#define sk_GENERAL_NAME_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(GENERAL_NAME) *, sk)) - -#define sk_GENERAL_NAME_set_cmp_func(sk, comp) \ - ((int (*)(const GENERAL_NAME **a, const GENERAL_NAME **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const GENERAL_NAME **a, const GENERAL_NAME **b), \ - comp))) - -#define sk_GENERAL_NAME_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(GENERAL_NAME) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(GENERAL_NAME) *, sk), \ - CHECKED_CAST(void *(*)(void *), GENERAL_NAME *(*)(GENERAL_NAME *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(GENERAL_NAME *), free_func))) - -/* GENERAL_NAMES */ -#define sk_GENERAL_NAMES_new(comp) \ - ((STACK_OF(GENERAL_NAMES) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, \ - int (*)(const GENERAL_NAMES **a, const GENERAL_NAMES **b), comp))) - -#define sk_GENERAL_NAMES_new_null() ((STACK_OF(GENERAL_NAMES) *)sk_new_null()) - -#define sk_GENERAL_NAMES_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk)) - -#define sk_GENERAL_NAMES_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk)); - -#define sk_GENERAL_NAMES_value(sk, i) \ - ((GENERAL_NAMES *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(GENERAL_NAMES) *, sk), (i))) - -#define sk_GENERAL_NAMES_set(sk, i, p) \ - ((GENERAL_NAMES *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk), (i), \ - CHECKED_CAST(void *, GENERAL_NAMES *, p))) - -#define sk_GENERAL_NAMES_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk)) - -#define sk_GENERAL_NAMES_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(GENERAL_NAMES *), free_func)) - -#define sk_GENERAL_NAMES_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk), \ - CHECKED_CAST(void *, GENERAL_NAMES *, p), (where)) - -#define sk_GENERAL_NAMES_delete(sk, where) \ - ((GENERAL_NAMES *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk), (where))) - -#define sk_GENERAL_NAMES_delete_ptr(sk, p) \ - ((GENERAL_NAMES *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk), \ - CHECKED_CAST(void *, GENERAL_NAMES *, p))) - -#define sk_GENERAL_NAMES_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk), (out_index), \ - CHECKED_CAST(void *, GENERAL_NAMES *, p)) - -#define sk_GENERAL_NAMES_shift(sk) \ - ((GENERAL_NAMES *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk))) - -#define sk_GENERAL_NAMES_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk), \ - CHECKED_CAST(void *, GENERAL_NAMES *, p)) - -#define sk_GENERAL_NAMES_pop(sk) \ - ((GENERAL_NAMES *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk))) - -#define sk_GENERAL_NAMES_dup(sk) \ - ((STACK_OF(GENERAL_NAMES) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(GENERAL_NAMES) *, sk))) - -#define sk_GENERAL_NAMES_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk)) - -#define sk_GENERAL_NAMES_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(GENERAL_NAMES) *, sk)) - -#define sk_GENERAL_NAMES_set_cmp_func(sk, comp) \ - ((int (*)(const GENERAL_NAMES **a, const GENERAL_NAMES **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const GENERAL_NAMES **a, const GENERAL_NAMES **b), \ - comp))) - -#define sk_GENERAL_NAMES_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(GENERAL_NAMES) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(GENERAL_NAMES) *, sk), \ - CHECKED_CAST(void *(*)(void *), GENERAL_NAMES *(*)(GENERAL_NAMES *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(GENERAL_NAMES *), free_func))) - -/* GENERAL_SUBTREE */ -#define sk_GENERAL_SUBTREE_new(comp) \ - ((STACK_OF(GENERAL_SUBTREE) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, \ - int (*)(const GENERAL_SUBTREE **a, const GENERAL_SUBTREE **b), comp))) - -#define sk_GENERAL_SUBTREE_new_null() \ - ((STACK_OF(GENERAL_SUBTREE) *)sk_new_null()) - -#define sk_GENERAL_SUBTREE_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk)) - -#define sk_GENERAL_SUBTREE_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk)); - -#define sk_GENERAL_SUBTREE_value(sk, i) \ - ((GENERAL_SUBTREE *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(GENERAL_SUBTREE) *, sk), (i))) - -#define sk_GENERAL_SUBTREE_set(sk, i, p) \ - ((GENERAL_SUBTREE *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk), (i), \ - CHECKED_CAST(void *, GENERAL_SUBTREE *, p))) - -#define sk_GENERAL_SUBTREE_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk)) - -#define sk_GENERAL_SUBTREE_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(GENERAL_SUBTREE *), free_func)) - -#define sk_GENERAL_SUBTREE_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk), \ - CHECKED_CAST(void *, GENERAL_SUBTREE *, p), (where)) - -#define sk_GENERAL_SUBTREE_delete(sk, where) \ - ((GENERAL_SUBTREE *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk), (where))) - -#define sk_GENERAL_SUBTREE_delete_ptr(sk, p) \ - ((GENERAL_SUBTREE *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk), \ - CHECKED_CAST(void *, GENERAL_SUBTREE *, p))) - -#define sk_GENERAL_SUBTREE_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk), \ - (out_index), CHECKED_CAST(void *, GENERAL_SUBTREE *, p)) - -#define sk_GENERAL_SUBTREE_shift(sk) \ - ((GENERAL_SUBTREE *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk))) - -#define sk_GENERAL_SUBTREE_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk), \ - CHECKED_CAST(void *, GENERAL_SUBTREE *, p)) - -#define sk_GENERAL_SUBTREE_pop(sk) \ - ((GENERAL_SUBTREE *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk))) - -#define sk_GENERAL_SUBTREE_dup(sk) \ - ((STACK_OF(GENERAL_SUBTREE) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(GENERAL_SUBTREE) *, sk))) - -#define sk_GENERAL_SUBTREE_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk)) - -#define sk_GENERAL_SUBTREE_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(GENERAL_SUBTREE) *, sk)) - -#define sk_GENERAL_SUBTREE_set_cmp_func(sk, comp) \ - ((int (*)(const GENERAL_SUBTREE **a, const GENERAL_SUBTREE **b)) \ - sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk), \ - CHECKED_CAST(stack_cmp_func, int (*)(const GENERAL_SUBTREE **a, \ - const GENERAL_SUBTREE **b), \ - comp))) - -#define sk_GENERAL_SUBTREE_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(GENERAL_SUBTREE) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(GENERAL_SUBTREE) *, sk), \ - CHECKED_CAST(void *(*)(void *), GENERAL_SUBTREE *(*)(GENERAL_SUBTREE *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(GENERAL_SUBTREE *), free_func))) - -/* MIME_HEADER */ -#define sk_MIME_HEADER_new(comp) \ - ((STACK_OF(MIME_HEADER) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const MIME_HEADER **a, const MIME_HEADER **b), \ - comp))) - -#define sk_MIME_HEADER_new_null() ((STACK_OF(MIME_HEADER) *)sk_new_null()) - -#define sk_MIME_HEADER_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(MIME_HEADER) *, sk)) - -#define sk_MIME_HEADER_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(MIME_HEADER) *, sk)); - -#define sk_MIME_HEADER_value(sk, i) \ - ((MIME_HEADER *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(MIME_HEADER) *, sk), (i))) - -#define sk_MIME_HEADER_set(sk, i, p) \ - ((MIME_HEADER *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(MIME_HEADER) *, sk), \ - (i), CHECKED_CAST(void *, MIME_HEADER *, p))) - -#define sk_MIME_HEADER_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(MIME_HEADER) *, sk)) - -#define sk_MIME_HEADER_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(MIME_HEADER) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(MIME_HEADER *), free_func)) - -#define sk_MIME_HEADER_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(MIME_HEADER) *, sk), \ - CHECKED_CAST(void *, MIME_HEADER *, p), (where)) - -#define sk_MIME_HEADER_delete(sk, where) \ - ((MIME_HEADER *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(MIME_HEADER) *, sk), (where))) - -#define sk_MIME_HEADER_delete_ptr(sk, p) \ - ((MIME_HEADER *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(MIME_HEADER) *, sk), \ - CHECKED_CAST(void *, MIME_HEADER *, p))) - -#define sk_MIME_HEADER_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(MIME_HEADER) *, sk), (out_index), \ - CHECKED_CAST(void *, MIME_HEADER *, p)) - -#define sk_MIME_HEADER_shift(sk) \ - ((MIME_HEADER *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(MIME_HEADER) *, sk))) - -#define sk_MIME_HEADER_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(MIME_HEADER) *, sk), \ - CHECKED_CAST(void *, MIME_HEADER *, p)) - -#define sk_MIME_HEADER_pop(sk) \ - ((MIME_HEADER *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(MIME_HEADER) *, sk))) - -#define sk_MIME_HEADER_dup(sk) \ - ((STACK_OF(MIME_HEADER) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(MIME_HEADER) *, sk))) - -#define sk_MIME_HEADER_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(MIME_HEADER) *, sk)) - -#define sk_MIME_HEADER_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(MIME_HEADER) *, sk)) - -#define sk_MIME_HEADER_set_cmp_func(sk, comp) \ - ((int (*)(const MIME_HEADER **a, const MIME_HEADER **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(MIME_HEADER) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const MIME_HEADER **a, const MIME_HEADER **b), \ - comp))) - -#define sk_MIME_HEADER_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(MIME_HEADER) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(MIME_HEADER) *, sk), \ - CHECKED_CAST(void *(*)(void *), MIME_HEADER *(*)(MIME_HEADER *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(MIME_HEADER *), free_func))) - -/* PKCS7_SIGNER_INFO */ -#define sk_PKCS7_SIGNER_INFO_new(comp) \ - ((STACK_OF(PKCS7_SIGNER_INFO) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, \ - int (*)(const PKCS7_SIGNER_INFO **a, const PKCS7_SIGNER_INFO **b), \ - comp))) - -#define sk_PKCS7_SIGNER_INFO_new_null() \ - ((STACK_OF(PKCS7_SIGNER_INFO) *)sk_new_null()) - -#define sk_PKCS7_SIGNER_INFO_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(PKCS7_SIGNER_INFO) *, sk)) - -#define sk_PKCS7_SIGNER_INFO_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(PKCS7_SIGNER_INFO) *, sk)); - -#define sk_PKCS7_SIGNER_INFO_value(sk, i) \ - ((PKCS7_SIGNER_INFO *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(PKCS7_SIGNER_INFO) *, sk), (i))) - -#define sk_PKCS7_SIGNER_INFO_set(sk, i, p) \ - ((PKCS7_SIGNER_INFO *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(PKCS7_SIGNER_INFO) *, sk), (i), \ - CHECKED_CAST(void *, PKCS7_SIGNER_INFO *, p))) - -#define sk_PKCS7_SIGNER_INFO_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(PKCS7_SIGNER_INFO) *, sk)) - -#define sk_PKCS7_SIGNER_INFO_pop_free(sk, free_func) \ - sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(PKCS7_SIGNER_INFO) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(PKCS7_SIGNER_INFO *), \ - free_func)) - -#define sk_PKCS7_SIGNER_INFO_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(PKCS7_SIGNER_INFO) *, sk), \ - CHECKED_CAST(void *, PKCS7_SIGNER_INFO *, p), (where)) - -#define sk_PKCS7_SIGNER_INFO_delete(sk, where) \ - ((PKCS7_SIGNER_INFO *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(PKCS7_SIGNER_INFO) *, sk), (where))) - -#define sk_PKCS7_SIGNER_INFO_delete_ptr(sk, p) \ - ((PKCS7_SIGNER_INFO *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(PKCS7_SIGNER_INFO) *, sk), \ - CHECKED_CAST(void *, PKCS7_SIGNER_INFO *, p))) - -#define sk_PKCS7_SIGNER_INFO_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(PKCS7_SIGNER_INFO) *, sk), \ - (out_index), CHECKED_CAST(void *, PKCS7_SIGNER_INFO *, p)) - -#define sk_PKCS7_SIGNER_INFO_shift(sk) \ - ((PKCS7_SIGNER_INFO *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(PKCS7_SIGNER_INFO) *, sk))) - -#define sk_PKCS7_SIGNER_INFO_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(PKCS7_SIGNER_INFO) *, sk), \ - CHECKED_CAST(void *, PKCS7_SIGNER_INFO *, p)) - -#define sk_PKCS7_SIGNER_INFO_pop(sk) \ - ((PKCS7_SIGNER_INFO *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(PKCS7_SIGNER_INFO) *, sk))) - -#define sk_PKCS7_SIGNER_INFO_dup(sk) \ - ((STACK_OF(PKCS7_SIGNER_INFO) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(PKCS7_SIGNER_INFO) *, sk))) - -#define sk_PKCS7_SIGNER_INFO_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(PKCS7_SIGNER_INFO) *, sk)) - -#define sk_PKCS7_SIGNER_INFO_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(PKCS7_SIGNER_INFO) *, sk)) - -#define sk_PKCS7_SIGNER_INFO_set_cmp_func(sk, comp) \ - ((int (*)(const PKCS7_SIGNER_INFO **a, const PKCS7_SIGNER_INFO **b)) \ - sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(PKCS7_SIGNER_INFO) *, sk), \ - CHECKED_CAST(stack_cmp_func, int (*)(const PKCS7_SIGNER_INFO **a, \ - const PKCS7_SIGNER_INFO **b), \ - comp))) - -#define sk_PKCS7_SIGNER_INFO_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(PKCS7_SIGNER_INFO) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(PKCS7_SIGNER_INFO) *, sk), \ - CHECKED_CAST(void *(*)(void *), \ - PKCS7_SIGNER_INFO *(*)(PKCS7_SIGNER_INFO *), copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(PKCS7_SIGNER_INFO *), \ - free_func))) - -/* PKCS7_RECIP_INFO */ -#define sk_PKCS7_RECIP_INFO_new(comp) \ - ((STACK_OF(PKCS7_RECIP_INFO) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, \ - int (*)(const PKCS7_RECIP_INFO **a, const PKCS7_RECIP_INFO **b), comp))) - -#define sk_PKCS7_RECIP_INFO_new_null() \ - ((STACK_OF(PKCS7_RECIP_INFO) *)sk_new_null()) - -#define sk_PKCS7_RECIP_INFO_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(PKCS7_RECIP_INFO) *, sk)) - -#define sk_PKCS7_RECIP_INFO_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(PKCS7_RECIP_INFO) *, sk)); - -#define sk_PKCS7_RECIP_INFO_value(sk, i) \ - ((PKCS7_RECIP_INFO *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(PKCS7_RECIP_INFO) *, sk), (i))) - -#define sk_PKCS7_RECIP_INFO_set(sk, i, p) \ - ((PKCS7_RECIP_INFO *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(PKCS7_RECIP_INFO) *, sk), (i), \ - CHECKED_CAST(void *, PKCS7_RECIP_INFO *, p))) - -#define sk_PKCS7_RECIP_INFO_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(PKCS7_RECIP_INFO) *, sk)) - -#define sk_PKCS7_RECIP_INFO_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(PKCS7_RECIP_INFO) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(PKCS7_RECIP_INFO *), free_func)) - -#define sk_PKCS7_RECIP_INFO_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(PKCS7_RECIP_INFO) *, sk), \ - CHECKED_CAST(void *, PKCS7_RECIP_INFO *, p), (where)) - -#define sk_PKCS7_RECIP_INFO_delete(sk, where) \ - ((PKCS7_RECIP_INFO *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(PKCS7_RECIP_INFO) *, sk), (where))) - -#define sk_PKCS7_RECIP_INFO_delete_ptr(sk, p) \ - ((PKCS7_RECIP_INFO *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(PKCS7_RECIP_INFO) *, sk), \ - CHECKED_CAST(void *, PKCS7_RECIP_INFO *, p))) - -#define sk_PKCS7_RECIP_INFO_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(PKCS7_RECIP_INFO) *, sk), \ - (out_index), CHECKED_CAST(void *, PKCS7_RECIP_INFO *, p)) - -#define sk_PKCS7_RECIP_INFO_shift(sk) \ - ((PKCS7_RECIP_INFO *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(PKCS7_RECIP_INFO) *, sk))) - -#define sk_PKCS7_RECIP_INFO_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(PKCS7_RECIP_INFO) *, sk), \ - CHECKED_CAST(void *, PKCS7_RECIP_INFO *, p)) - -#define sk_PKCS7_RECIP_INFO_pop(sk) \ - ((PKCS7_RECIP_INFO *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(PKCS7_RECIP_INFO) *, sk))) - -#define sk_PKCS7_RECIP_INFO_dup(sk) \ - ((STACK_OF(PKCS7_RECIP_INFO) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(PKCS7_RECIP_INFO) *, sk))) - -#define sk_PKCS7_RECIP_INFO_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(PKCS7_RECIP_INFO) *, sk)) - -#define sk_PKCS7_RECIP_INFO_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(PKCS7_RECIP_INFO) *, sk)) - -#define sk_PKCS7_RECIP_INFO_set_cmp_func(sk, comp) \ - ((int (*)(const PKCS7_RECIP_INFO **a, const PKCS7_RECIP_INFO **b)) \ - sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(PKCS7_RECIP_INFO) *, sk), \ - CHECKED_CAST(stack_cmp_func, int (*)(const PKCS7_RECIP_INFO **a, \ - const PKCS7_RECIP_INFO **b), \ - comp))) - -#define sk_PKCS7_RECIP_INFO_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(PKCS7_RECIP_INFO) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(PKCS7_RECIP_INFO) *, sk), \ - CHECKED_CAST(void *(*)(void *), \ - PKCS7_RECIP_INFO *(*)(PKCS7_RECIP_INFO *), copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(PKCS7_RECIP_INFO *), \ - free_func))) - -/* POLICYINFO */ -#define sk_POLICYINFO_new(comp) \ - ((STACK_OF(POLICYINFO) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const POLICYINFO **a, const POLICYINFO **b), \ - comp))) - -#define sk_POLICYINFO_new_null() ((STACK_OF(POLICYINFO) *)sk_new_null()) - -#define sk_POLICYINFO_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk)) - -#define sk_POLICYINFO_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk)); - -#define sk_POLICYINFO_value(sk, i) \ - ((POLICYINFO *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(POLICYINFO) *, sk), (i))) - -#define sk_POLICYINFO_set(sk, i, p) \ - ((POLICYINFO *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk), \ - (i), CHECKED_CAST(void *, POLICYINFO *, p))) - -#define sk_POLICYINFO_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk)) - -#define sk_POLICYINFO_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(POLICYINFO *), free_func)) - -#define sk_POLICYINFO_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk), \ - CHECKED_CAST(void *, POLICYINFO *, p), (where)) - -#define sk_POLICYINFO_delete(sk, where) \ - ((POLICYINFO *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk), \ - (where))) - -#define sk_POLICYINFO_delete_ptr(sk, p) \ - ((POLICYINFO *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk), \ - CHECKED_CAST(void *, POLICYINFO *, p))) - -#define sk_POLICYINFO_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk), (out_index), \ - CHECKED_CAST(void *, POLICYINFO *, p)) - -#define sk_POLICYINFO_shift(sk) \ - ((POLICYINFO *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk))) - -#define sk_POLICYINFO_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk), \ - CHECKED_CAST(void *, POLICYINFO *, p)) - -#define sk_POLICYINFO_pop(sk) \ - ((POLICYINFO *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk))) - -#define sk_POLICYINFO_dup(sk) \ - ((STACK_OF(POLICYINFO) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(POLICYINFO) *, sk))) - -#define sk_POLICYINFO_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk)) - -#define sk_POLICYINFO_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(POLICYINFO) *, sk)) - -#define sk_POLICYINFO_set_cmp_func(sk, comp) \ - ((int (*)(const POLICYINFO **a, const POLICYINFO **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const POLICYINFO **a, const POLICYINFO **b), \ - comp))) - -#define sk_POLICYINFO_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(POLICYINFO) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(POLICYINFO) *, sk), \ - CHECKED_CAST(void *(*)(void *), POLICYINFO *(*)(POLICYINFO *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(POLICYINFO *), free_func))) - -/* POLICYQUALINFO */ -#define sk_POLICYQUALINFO_new(comp) \ - ((STACK_OF(POLICYQUALINFO) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, \ - int (*)(const POLICYQUALINFO **a, const POLICYQUALINFO **b), comp))) - -#define sk_POLICYQUALINFO_new_null() ((STACK_OF(POLICYQUALINFO) *)sk_new_null()) - -#define sk_POLICYQUALINFO_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk)) - -#define sk_POLICYQUALINFO_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk)); - -#define sk_POLICYQUALINFO_value(sk, i) \ - ((POLICYQUALINFO *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(POLICYQUALINFO) *, sk), (i))) - -#define sk_POLICYQUALINFO_set(sk, i, p) \ - ((POLICYQUALINFO *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk), (i), \ - CHECKED_CAST(void *, POLICYQUALINFO *, p))) - -#define sk_POLICYQUALINFO_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk)) - -#define sk_POLICYQUALINFO_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(POLICYQUALINFO *), free_func)) - -#define sk_POLICYQUALINFO_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk), \ - CHECKED_CAST(void *, POLICYQUALINFO *, p), (where)) - -#define sk_POLICYQUALINFO_delete(sk, where) \ - ((POLICYQUALINFO *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk), (where))) - -#define sk_POLICYQUALINFO_delete_ptr(sk, p) \ - ((POLICYQUALINFO *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk), \ - CHECKED_CAST(void *, POLICYQUALINFO *, p))) - -#define sk_POLICYQUALINFO_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk), (out_index), \ - CHECKED_CAST(void *, POLICYQUALINFO *, p)) - -#define sk_POLICYQUALINFO_shift(sk) \ - ((POLICYQUALINFO *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk))) - -#define sk_POLICYQUALINFO_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk), \ - CHECKED_CAST(void *, POLICYQUALINFO *, p)) - -#define sk_POLICYQUALINFO_pop(sk) \ - ((POLICYQUALINFO *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk))) - -#define sk_POLICYQUALINFO_dup(sk) \ - ((STACK_OF(POLICYQUALINFO) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(POLICYQUALINFO) *, sk))) - -#define sk_POLICYQUALINFO_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk)) - -#define sk_POLICYQUALINFO_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(POLICYQUALINFO) *, sk)) - -#define sk_POLICYQUALINFO_set_cmp_func(sk, comp) \ - ((int (*)(const POLICYQUALINFO **a, const POLICYQUALINFO **b)) \ - sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk), \ - CHECKED_CAST(stack_cmp_func, int (*)(const POLICYQUALINFO **a, \ - const POLICYQUALINFO **b), \ - comp))) - -#define sk_POLICYQUALINFO_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(POLICYQUALINFO) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(POLICYQUALINFO) *, sk), \ - CHECKED_CAST(void *(*)(void *), POLICYQUALINFO *(*)(POLICYQUALINFO *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(POLICYQUALINFO *), free_func))) - -/* POLICY_MAPPING */ -#define sk_POLICY_MAPPING_new(comp) \ - ((STACK_OF(POLICY_MAPPING) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, \ - int (*)(const POLICY_MAPPING **a, const POLICY_MAPPING **b), comp))) - -#define sk_POLICY_MAPPING_new_null() ((STACK_OF(POLICY_MAPPING) *)sk_new_null()) - -#define sk_POLICY_MAPPING_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk)) - -#define sk_POLICY_MAPPING_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk)); - -#define sk_POLICY_MAPPING_value(sk, i) \ - ((POLICY_MAPPING *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(POLICY_MAPPING) *, sk), (i))) - -#define sk_POLICY_MAPPING_set(sk, i, p) \ - ((POLICY_MAPPING *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk), (i), \ - CHECKED_CAST(void *, POLICY_MAPPING *, p))) - -#define sk_POLICY_MAPPING_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk)) - -#define sk_POLICY_MAPPING_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(POLICY_MAPPING *), free_func)) - -#define sk_POLICY_MAPPING_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk), \ - CHECKED_CAST(void *, POLICY_MAPPING *, p), (where)) - -#define sk_POLICY_MAPPING_delete(sk, where) \ - ((POLICY_MAPPING *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk), (where))) - -#define sk_POLICY_MAPPING_delete_ptr(sk, p) \ - ((POLICY_MAPPING *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk), \ - CHECKED_CAST(void *, POLICY_MAPPING *, p))) - -#define sk_POLICY_MAPPING_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk), (out_index), \ - CHECKED_CAST(void *, POLICY_MAPPING *, p)) - -#define sk_POLICY_MAPPING_shift(sk) \ - ((POLICY_MAPPING *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk))) - -#define sk_POLICY_MAPPING_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk), \ - CHECKED_CAST(void *, POLICY_MAPPING *, p)) - -#define sk_POLICY_MAPPING_pop(sk) \ - ((POLICY_MAPPING *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk))) - -#define sk_POLICY_MAPPING_dup(sk) \ - ((STACK_OF(POLICY_MAPPING) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(POLICY_MAPPING) *, sk))) - -#define sk_POLICY_MAPPING_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk)) - -#define sk_POLICY_MAPPING_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(POLICY_MAPPING) *, sk)) - -#define sk_POLICY_MAPPING_set_cmp_func(sk, comp) \ - ((int (*)(const POLICY_MAPPING **a, const POLICY_MAPPING **b)) \ - sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk), \ - CHECKED_CAST(stack_cmp_func, int (*)(const POLICY_MAPPING **a, \ - const POLICY_MAPPING **b), \ - comp))) - -#define sk_POLICY_MAPPING_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(POLICY_MAPPING) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(POLICY_MAPPING) *, sk), \ - CHECKED_CAST(void *(*)(void *), POLICY_MAPPING *(*)(POLICY_MAPPING *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(POLICY_MAPPING *), free_func))) - -/* SSL_COMP */ -#define sk_SSL_COMP_new(comp) \ - ((STACK_OF(SSL_COMP) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const SSL_COMP **a, const SSL_COMP **b), comp))) - -#define sk_SSL_COMP_new_null() ((STACK_OF(SSL_COMP) *)sk_new_null()) - -#define sk_SSL_COMP_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk)) - -#define sk_SSL_COMP_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk)); - -#define sk_SSL_COMP_value(sk, i) \ - ((SSL_COMP *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(SSL_COMP) *, sk), (i))) - -#define sk_SSL_COMP_set(sk, i, p) \ - ((SSL_COMP *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk), (i), \ - CHECKED_CAST(void *, SSL_COMP *, p))) - -#define sk_SSL_COMP_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk)) - -#define sk_SSL_COMP_pop_free(sk, free_func) \ - sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(SSL_COMP *), free_func)) - -#define sk_SSL_COMP_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk), \ - CHECKED_CAST(void *, SSL_COMP *, p), (where)) - -#define sk_SSL_COMP_delete(sk, where) \ - ((SSL_COMP *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk), \ - (where))) - -#define sk_SSL_COMP_delete_ptr(sk, p) \ - ((SSL_COMP *)sk_delete_ptr(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk), \ - CHECKED_CAST(void *, SSL_COMP *, p))) - -#define sk_SSL_COMP_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk), (out_index), \ - CHECKED_CAST(void *, SSL_COMP *, p)) - -#define sk_SSL_COMP_shift(sk) \ - ((SSL_COMP *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk))) - -#define sk_SSL_COMP_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk), \ - CHECKED_CAST(void *, SSL_COMP *, p)) - -#define sk_SSL_COMP_pop(sk) \ - ((SSL_COMP *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk))) - -#define sk_SSL_COMP_dup(sk) \ - ((STACK_OF(SSL_COMP) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(SSL_COMP) *, sk))) - -#define sk_SSL_COMP_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk)) - -#define sk_SSL_COMP_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(SSL_COMP) *, sk)) - -#define sk_SSL_COMP_set_cmp_func(sk, comp) \ - ((int (*)(const SSL_COMP **a, const SSL_COMP **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const SSL_COMP **a, const SSL_COMP **b), comp))) - -#define sk_SSL_COMP_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(SSL_COMP) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(SSL_COMP) *, sk), \ - CHECKED_CAST(void *(*)(void *), SSL_COMP *(*)(SSL_COMP *), copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(SSL_COMP *), free_func))) - -/* STACK_OF_X509_NAME_ENTRY */ -#define sk_STACK_OF_X509_NAME_ENTRY_new(comp) \ - ((STACK_OF(STACK_OF_X509_NAME_ENTRY) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const STACK_OF_X509_NAME_ENTRY **a, \ - const STACK_OF_X509_NAME_ENTRY **b), \ - comp))) - -#define sk_STACK_OF_X509_NAME_ENTRY_new_null() \ - ((STACK_OF(STACK_OF_X509_NAME_ENTRY) *)sk_new_null()) - -#define sk_STACK_OF_X509_NAME_ENTRY_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk)) - -#define sk_STACK_OF_X509_NAME_ENTRY_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk)); - -#define sk_STACK_OF_X509_NAME_ENTRY_value(sk, i) \ - ((STACK_OF_X509_NAME_ENTRY *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk), \ - (i))) - -#define sk_STACK_OF_X509_NAME_ENTRY_set(sk, i, p) \ - ((STACK_OF_X509_NAME_ENTRY *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk), (i), \ - CHECKED_CAST(void *, STACK_OF_X509_NAME_ENTRY *, p))) - -#define sk_STACK_OF_X509_NAME_ENTRY_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk)) - -#define sk_STACK_OF_X509_NAME_ENTRY_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(STACK_OF_X509_NAME_ENTRY *), \ - free_func)) - -#define sk_STACK_OF_X509_NAME_ENTRY_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk), \ - CHECKED_CAST(void *, STACK_OF_X509_NAME_ENTRY *, p), (where)) - -#define sk_STACK_OF_X509_NAME_ENTRY_delete(sk, where) \ - ((STACK_OF_X509_NAME_ENTRY *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk), \ - (where))) - -#define sk_STACK_OF_X509_NAME_ENTRY_delete_ptr(sk, p) \ - ((STACK_OF_X509_NAME_ENTRY *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk), \ - CHECKED_CAST(void *, STACK_OF_X509_NAME_ENTRY *, p))) - -#define sk_STACK_OF_X509_NAME_ENTRY_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk), \ - (out_index), CHECKED_CAST(void *, STACK_OF_X509_NAME_ENTRY *, p)) - -#define sk_STACK_OF_X509_NAME_ENTRY_shift(sk) \ - ((STACK_OF_X509_NAME_ENTRY *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk))) - -#define sk_STACK_OF_X509_NAME_ENTRY_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk), \ - CHECKED_CAST(void *, STACK_OF_X509_NAME_ENTRY *, p)) - -#define sk_STACK_OF_X509_NAME_ENTRY_pop(sk) \ - ((STACK_OF_X509_NAME_ENTRY *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk))) - -#define sk_STACK_OF_X509_NAME_ENTRY_dup(sk) \ - ((STACK_OF(STACK_OF_X509_NAME_ENTRY) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk))) - -#define sk_STACK_OF_X509_NAME_ENTRY_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk)) - -#define sk_STACK_OF_X509_NAME_ENTRY_is_sorted(sk) \ - sk_is_sorted( \ - CHECKED_CAST(_STACK *, const STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk)) - -#define sk_STACK_OF_X509_NAME_ENTRY_set_cmp_func(sk, comp) \ - ((int (*)(const STACK_OF_X509_NAME_ENTRY **a, \ - const STACK_OF_X509_NAME_ENTRY **b)) \ - sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const STACK_OF_X509_NAME_ENTRY **a, \ - const STACK_OF_X509_NAME_ENTRY **b), \ - comp))) - -#define sk_STACK_OF_X509_NAME_ENTRY_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(STACK_OF_X509_NAME_ENTRY) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(STACK_OF_X509_NAME_ENTRY) *, \ - sk), \ - CHECKED_CAST(void *(*)(void *), \ - STACK_OF_X509_NAME_ENTRY *(*)(STACK_OF_X509_NAME_ENTRY *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(STACK_OF_X509_NAME_ENTRY *), \ - free_func))) - -/* SXNETID */ -#define sk_SXNETID_new(comp) \ - ((STACK_OF(SXNETID) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const SXNETID **a, const SXNETID **b), comp))) - -#define sk_SXNETID_new_null() ((STACK_OF(SXNETID) *)sk_new_null()) - -#define sk_SXNETID_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk)) - -#define sk_SXNETID_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk)); - -#define sk_SXNETID_value(sk, i) \ - ((SXNETID *)sk_value(CHECKED_CAST(_STACK *, const STACK_OF(SXNETID) *, sk), \ - (i))) - -#define sk_SXNETID_set(sk, i, p) \ - ((SXNETID *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk), (i), \ - CHECKED_CAST(void *, SXNETID *, p))) - -#define sk_SXNETID_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk)) - -#define sk_SXNETID_pop_free(sk, free_func) \ - sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(SXNETID *), free_func)) - -#define sk_SXNETID_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk), \ - CHECKED_CAST(void *, SXNETID *, p), (where)) - -#define sk_SXNETID_delete(sk, where) \ - ((SXNETID *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk), \ - (where))) - -#define sk_SXNETID_delete_ptr(sk, p) \ - ((SXNETID *)sk_delete_ptr(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk), \ - CHECKED_CAST(void *, SXNETID *, p))) - -#define sk_SXNETID_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk), (out_index), \ - CHECKED_CAST(void *, SXNETID *, p)) - -#define sk_SXNETID_shift(sk) \ - ((SXNETID *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk))) - -#define sk_SXNETID_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk), \ - CHECKED_CAST(void *, SXNETID *, p)) - -#define sk_SXNETID_pop(sk) \ - ((SXNETID *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk))) - -#define sk_SXNETID_dup(sk) \ - ((STACK_OF(SXNETID) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(SXNETID) *, sk))) - -#define sk_SXNETID_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk)) - -#define sk_SXNETID_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(SXNETID) *, sk)) - -#define sk_SXNETID_set_cmp_func(sk, comp) \ - ((int (*)(const SXNETID **a, const SXNETID **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const SXNETID **a, const SXNETID **b), comp))) - -#define sk_SXNETID_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(SXNETID) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(SXNETID) *, sk), \ - CHECKED_CAST(void *(*)(void *), SXNETID *(*)(SXNETID *), copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(SXNETID *), free_func))) - -/* X509 */ -#define sk_X509_new(comp) \ - ((STACK_OF(X509) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const X509 **a, const X509 **b), comp))) - -#define sk_X509_new_null() ((STACK_OF(X509) *)sk_new_null()) - -#define sk_X509_num(sk) sk_num(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk)) - -#define sk_X509_zero(sk) sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk)); - -#define sk_X509_value(sk, i) \ - ((X509 *)sk_value(CHECKED_CAST(_STACK *, const STACK_OF(X509) *, sk), (i))) - -#define sk_X509_set(sk, i, p) \ - ((X509 *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk), (i), \ - CHECKED_CAST(void *, X509 *, p))) - -#define sk_X509_free(sk) sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk)) - -#define sk_X509_pop_free(sk, free_func) \ - sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(X509 *), free_func)) - -#define sk_X509_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk), \ - CHECKED_CAST(void *, X509 *, p), (where)) - -#define sk_X509_delete(sk, where) \ - ((X509 *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk), (where))) - -#define sk_X509_delete_ptr(sk, p) \ - ((X509 *)sk_delete_ptr(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk), \ - CHECKED_CAST(void *, X509 *, p))) - -#define sk_X509_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk), (out_index), \ - CHECKED_CAST(void *, X509 *, p)) - -#define sk_X509_shift(sk) \ - ((X509 *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk))) - -#define sk_X509_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk), \ - CHECKED_CAST(void *, X509 *, p)) - -#define sk_X509_pop(sk) \ - ((X509 *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk))) - -#define sk_X509_dup(sk) \ - ((STACK_OF(X509) *)sk_dup(CHECKED_CAST(_STACK *, const STACK_OF(X509) *, sk))) - -#define sk_X509_sort(sk) sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk)) - -#define sk_X509_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(X509) *, sk)) - -#define sk_X509_set_cmp_func(sk, comp) \ - ((int (*)(const X509 **a, const X509 **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk), \ - CHECKED_CAST(stack_cmp_func, int (*)(const X509 **a, const X509 **b), \ - comp))) - -#define sk_X509_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(X509) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(X509) *, sk), \ - CHECKED_CAST(void *(*)(void *), X509 *(*)(X509 *), copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(X509 *), free_func))) - -/* X509V3_EXT_METHOD */ -#define sk_X509V3_EXT_METHOD_new(comp) \ - ((STACK_OF(X509V3_EXT_METHOD) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, \ - int (*)(const X509V3_EXT_METHOD **a, const X509V3_EXT_METHOD **b), \ - comp))) - -#define sk_X509V3_EXT_METHOD_new_null() \ - ((STACK_OF(X509V3_EXT_METHOD) *)sk_new_null()) - -#define sk_X509V3_EXT_METHOD_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk)) - -#define sk_X509V3_EXT_METHOD_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk)); - -#define sk_X509V3_EXT_METHOD_value(sk, i) \ - ((X509V3_EXT_METHOD *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509V3_EXT_METHOD) *, sk), (i))) - -#define sk_X509V3_EXT_METHOD_set(sk, i, p) \ - ((X509V3_EXT_METHOD *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk), (i), \ - CHECKED_CAST(void *, X509V3_EXT_METHOD *, p))) - -#define sk_X509V3_EXT_METHOD_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk)) - -#define sk_X509V3_EXT_METHOD_pop_free(sk, free_func) \ - sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(X509V3_EXT_METHOD *), \ - free_func)) - -#define sk_X509V3_EXT_METHOD_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk), \ - CHECKED_CAST(void *, X509V3_EXT_METHOD *, p), (where)) - -#define sk_X509V3_EXT_METHOD_delete(sk, where) \ - ((X509V3_EXT_METHOD *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk), (where))) - -#define sk_X509V3_EXT_METHOD_delete_ptr(sk, p) \ - ((X509V3_EXT_METHOD *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk), \ - CHECKED_CAST(void *, X509V3_EXT_METHOD *, p))) - -#define sk_X509V3_EXT_METHOD_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk), \ - (out_index), CHECKED_CAST(void *, X509V3_EXT_METHOD *, p)) - -#define sk_X509V3_EXT_METHOD_shift(sk) \ - ((X509V3_EXT_METHOD *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk))) - -#define sk_X509V3_EXT_METHOD_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk), \ - CHECKED_CAST(void *, X509V3_EXT_METHOD *, p)) - -#define sk_X509V3_EXT_METHOD_pop(sk) \ - ((X509V3_EXT_METHOD *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk))) - -#define sk_X509V3_EXT_METHOD_dup(sk) \ - ((STACK_OF(X509V3_EXT_METHOD) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509V3_EXT_METHOD) *, sk))) - -#define sk_X509V3_EXT_METHOD_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk)) - -#define sk_X509V3_EXT_METHOD_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(X509V3_EXT_METHOD) *, sk)) - -#define sk_X509V3_EXT_METHOD_set_cmp_func(sk, comp) \ - ((int (*)(const X509V3_EXT_METHOD **a, const X509V3_EXT_METHOD **b)) \ - sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk), \ - CHECKED_CAST(stack_cmp_func, int (*)(const X509V3_EXT_METHOD **a, \ - const X509V3_EXT_METHOD **b), \ - comp))) - -#define sk_X509V3_EXT_METHOD_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(X509V3_EXT_METHOD) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(X509V3_EXT_METHOD) *, sk), \ - CHECKED_CAST(void *(*)(void *), \ - X509V3_EXT_METHOD *(*)(X509V3_EXT_METHOD *), copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(X509V3_EXT_METHOD *), \ - free_func))) - -/* X509_ALGOR */ -#define sk_X509_ALGOR_new(comp) \ - ((STACK_OF(X509_ALGOR) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const X509_ALGOR **a, const X509_ALGOR **b), \ - comp))) - -#define sk_X509_ALGOR_new_null() ((STACK_OF(X509_ALGOR) *)sk_new_null()) - -#define sk_X509_ALGOR_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk)) - -#define sk_X509_ALGOR_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk)); - -#define sk_X509_ALGOR_value(sk, i) \ - ((X509_ALGOR *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_ALGOR) *, sk), (i))) - -#define sk_X509_ALGOR_set(sk, i, p) \ - ((X509_ALGOR *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk), \ - (i), CHECKED_CAST(void *, X509_ALGOR *, p))) - -#define sk_X509_ALGOR_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk)) - -#define sk_X509_ALGOR_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_ALGOR *), free_func)) - -#define sk_X509_ALGOR_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk), \ - CHECKED_CAST(void *, X509_ALGOR *, p), (where)) - -#define sk_X509_ALGOR_delete(sk, where) \ - ((X509_ALGOR *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk), \ - (where))) - -#define sk_X509_ALGOR_delete_ptr(sk, p) \ - ((X509_ALGOR *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk), \ - CHECKED_CAST(void *, X509_ALGOR *, p))) - -#define sk_X509_ALGOR_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk), (out_index), \ - CHECKED_CAST(void *, X509_ALGOR *, p)) - -#define sk_X509_ALGOR_shift(sk) \ - ((X509_ALGOR *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk))) - -#define sk_X509_ALGOR_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk), \ - CHECKED_CAST(void *, X509_ALGOR *, p)) - -#define sk_X509_ALGOR_pop(sk) \ - ((X509_ALGOR *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk))) - -#define sk_X509_ALGOR_dup(sk) \ - ((STACK_OF(X509_ALGOR) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_ALGOR) *, sk))) - -#define sk_X509_ALGOR_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk)) - -#define sk_X509_ALGOR_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(X509_ALGOR) *, sk)) - -#define sk_X509_ALGOR_set_cmp_func(sk, comp) \ - ((int (*)(const X509_ALGOR **a, const X509_ALGOR **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const X509_ALGOR **a, const X509_ALGOR **b), \ - comp))) - -#define sk_X509_ALGOR_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(X509_ALGOR) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(X509_ALGOR) *, sk), \ - CHECKED_CAST(void *(*)(void *), X509_ALGOR *(*)(X509_ALGOR *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_ALGOR *), free_func))) - -/* X509_ATTRIBUTE */ -#define sk_X509_ATTRIBUTE_new(comp) \ - ((STACK_OF(X509_ATTRIBUTE) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, \ - int (*)(const X509_ATTRIBUTE **a, const X509_ATTRIBUTE **b), comp))) - -#define sk_X509_ATTRIBUTE_new_null() ((STACK_OF(X509_ATTRIBUTE) *)sk_new_null()) - -#define sk_X509_ATTRIBUTE_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk)) - -#define sk_X509_ATTRIBUTE_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk)); - -#define sk_X509_ATTRIBUTE_value(sk, i) \ - ((X509_ATTRIBUTE *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_ATTRIBUTE) *, sk), (i))) - -#define sk_X509_ATTRIBUTE_set(sk, i, p) \ - ((X509_ATTRIBUTE *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk), (i), \ - CHECKED_CAST(void *, X509_ATTRIBUTE *, p))) - -#define sk_X509_ATTRIBUTE_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk)) - -#define sk_X509_ATTRIBUTE_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_ATTRIBUTE *), free_func)) - -#define sk_X509_ATTRIBUTE_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk), \ - CHECKED_CAST(void *, X509_ATTRIBUTE *, p), (where)) - -#define sk_X509_ATTRIBUTE_delete(sk, where) \ - ((X509_ATTRIBUTE *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk), (where))) - -#define sk_X509_ATTRIBUTE_delete_ptr(sk, p) \ - ((X509_ATTRIBUTE *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk), \ - CHECKED_CAST(void *, X509_ATTRIBUTE *, p))) - -#define sk_X509_ATTRIBUTE_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk), (out_index), \ - CHECKED_CAST(void *, X509_ATTRIBUTE *, p)) - -#define sk_X509_ATTRIBUTE_shift(sk) \ - ((X509_ATTRIBUTE *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk))) - -#define sk_X509_ATTRIBUTE_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk), \ - CHECKED_CAST(void *, X509_ATTRIBUTE *, p)) - -#define sk_X509_ATTRIBUTE_pop(sk) \ - ((X509_ATTRIBUTE *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk))) - -#define sk_X509_ATTRIBUTE_dup(sk) \ - ((STACK_OF(X509_ATTRIBUTE) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_ATTRIBUTE) *, sk))) - -#define sk_X509_ATTRIBUTE_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk)) - -#define sk_X509_ATTRIBUTE_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(X509_ATTRIBUTE) *, sk)) - -#define sk_X509_ATTRIBUTE_set_cmp_func(sk, comp) \ - ((int (*)(const X509_ATTRIBUTE **a, const X509_ATTRIBUTE **b)) \ - sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk), \ - CHECKED_CAST(stack_cmp_func, int (*)(const X509_ATTRIBUTE **a, \ - const X509_ATTRIBUTE **b), \ - comp))) - -#define sk_X509_ATTRIBUTE_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(X509_ATTRIBUTE) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(X509_ATTRIBUTE) *, sk), \ - CHECKED_CAST(void *(*)(void *), X509_ATTRIBUTE *(*)(X509_ATTRIBUTE *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_ATTRIBUTE *), free_func))) - -/* X509_CRL */ -#define sk_X509_CRL_new(comp) \ - ((STACK_OF(X509_CRL) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const X509_CRL **a, const X509_CRL **b), comp))) - -#define sk_X509_CRL_new_null() ((STACK_OF(X509_CRL) *)sk_new_null()) - -#define sk_X509_CRL_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk)) - -#define sk_X509_CRL_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk)); - -#define sk_X509_CRL_value(sk, i) \ - ((X509_CRL *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_CRL) *, sk), (i))) - -#define sk_X509_CRL_set(sk, i, p) \ - ((X509_CRL *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk), (i), \ - CHECKED_CAST(void *, X509_CRL *, p))) - -#define sk_X509_CRL_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk)) - -#define sk_X509_CRL_pop_free(sk, free_func) \ - sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_CRL *), free_func)) - -#define sk_X509_CRL_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk), \ - CHECKED_CAST(void *, X509_CRL *, p), (where)) - -#define sk_X509_CRL_delete(sk, where) \ - ((X509_CRL *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk), \ - (where))) - -#define sk_X509_CRL_delete_ptr(sk, p) \ - ((X509_CRL *)sk_delete_ptr(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk), \ - CHECKED_CAST(void *, X509_CRL *, p))) - -#define sk_X509_CRL_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk), (out_index), \ - CHECKED_CAST(void *, X509_CRL *, p)) - -#define sk_X509_CRL_shift(sk) \ - ((X509_CRL *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk))) - -#define sk_X509_CRL_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk), \ - CHECKED_CAST(void *, X509_CRL *, p)) - -#define sk_X509_CRL_pop(sk) \ - ((X509_CRL *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk))) - -#define sk_X509_CRL_dup(sk) \ - ((STACK_OF(X509_CRL) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_CRL) *, sk))) - -#define sk_X509_CRL_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk)) - -#define sk_X509_CRL_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(X509_CRL) *, sk)) - -#define sk_X509_CRL_set_cmp_func(sk, comp) \ - ((int (*)(const X509_CRL **a, const X509_CRL **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const X509_CRL **a, const X509_CRL **b), comp))) - -#define sk_X509_CRL_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(X509_CRL) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(X509_CRL) *, sk), \ - CHECKED_CAST(void *(*)(void *), X509_CRL *(*)(X509_CRL *), copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_CRL *), free_func))) - -/* X509_EXTENSION */ -#define sk_X509_EXTENSION_new(comp) \ - ((STACK_OF(X509_EXTENSION) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, \ - int (*)(const X509_EXTENSION **a, const X509_EXTENSION **b), comp))) - -#define sk_X509_EXTENSION_new_null() ((STACK_OF(X509_EXTENSION) *)sk_new_null()) - -#define sk_X509_EXTENSION_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk)) - -#define sk_X509_EXTENSION_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk)); - -#define sk_X509_EXTENSION_value(sk, i) \ - ((X509_EXTENSION *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_EXTENSION) *, sk), (i))) - -#define sk_X509_EXTENSION_set(sk, i, p) \ - ((X509_EXTENSION *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk), (i), \ - CHECKED_CAST(void *, X509_EXTENSION *, p))) - -#define sk_X509_EXTENSION_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk)) - -#define sk_X509_EXTENSION_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_EXTENSION *), free_func)) - -#define sk_X509_EXTENSION_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk), \ - CHECKED_CAST(void *, X509_EXTENSION *, p), (where)) - -#define sk_X509_EXTENSION_delete(sk, where) \ - ((X509_EXTENSION *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk), (where))) - -#define sk_X509_EXTENSION_delete_ptr(sk, p) \ - ((X509_EXTENSION *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk), \ - CHECKED_CAST(void *, X509_EXTENSION *, p))) - -#define sk_X509_EXTENSION_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk), (out_index), \ - CHECKED_CAST(void *, X509_EXTENSION *, p)) - -#define sk_X509_EXTENSION_shift(sk) \ - ((X509_EXTENSION *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk))) - -#define sk_X509_EXTENSION_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk), \ - CHECKED_CAST(void *, X509_EXTENSION *, p)) - -#define sk_X509_EXTENSION_pop(sk) \ - ((X509_EXTENSION *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk))) - -#define sk_X509_EXTENSION_dup(sk) \ - ((STACK_OF(X509_EXTENSION) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_EXTENSION) *, sk))) - -#define sk_X509_EXTENSION_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk)) - -#define sk_X509_EXTENSION_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(X509_EXTENSION) *, sk)) - -#define sk_X509_EXTENSION_set_cmp_func(sk, comp) \ - ((int (*)(const X509_EXTENSION **a, const X509_EXTENSION **b)) \ - sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk), \ - CHECKED_CAST(stack_cmp_func, int (*)(const X509_EXTENSION **a, \ - const X509_EXTENSION **b), \ - comp))) - -#define sk_X509_EXTENSION_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(X509_EXTENSION) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(X509_EXTENSION) *, sk), \ - CHECKED_CAST(void *(*)(void *), X509_EXTENSION *(*)(X509_EXTENSION *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_EXTENSION *), free_func))) - -/* X509_INFO */ -#define sk_X509_INFO_new(comp) \ - ((STACK_OF(X509_INFO) *)sk_new( \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const X509_INFO **a, const X509_INFO **b), comp))) - -#define sk_X509_INFO_new_null() ((STACK_OF(X509_INFO) *)sk_new_null()) - -#define sk_X509_INFO_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk)) - -#define sk_X509_INFO_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk)); - -#define sk_X509_INFO_value(sk, i) \ - ((X509_INFO *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_INFO) *, sk), (i))) - -#define sk_X509_INFO_set(sk, i, p) \ - ((X509_INFO *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk), (i), \ - CHECKED_CAST(void *, X509_INFO *, p))) - -#define sk_X509_INFO_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk)) - -#define sk_X509_INFO_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_INFO *), free_func)) - -#define sk_X509_INFO_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk), \ - CHECKED_CAST(void *, X509_INFO *, p), (where)) - -#define sk_X509_INFO_delete(sk, where) \ - ((X509_INFO *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk), \ - (where))) - -#define sk_X509_INFO_delete_ptr(sk, p) \ - ((X509_INFO *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk), \ - CHECKED_CAST(void *, X509_INFO *, p))) - -#define sk_X509_INFO_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk), (out_index), \ - CHECKED_CAST(void *, X509_INFO *, p)) - -#define sk_X509_INFO_shift(sk) \ - ((X509_INFO *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk))) - -#define sk_X509_INFO_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk), \ - CHECKED_CAST(void *, X509_INFO *, p)) - -#define sk_X509_INFO_pop(sk) \ - ((X509_INFO *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk))) - -#define sk_X509_INFO_dup(sk) \ - ((STACK_OF(X509_INFO) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_INFO) *, sk))) - -#define sk_X509_INFO_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk)) - -#define sk_X509_INFO_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(X509_INFO) *, sk)) - -#define sk_X509_INFO_set_cmp_func(sk, comp) \ - ((int (*)(const X509_INFO **a, const X509_INFO **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const X509_INFO **a, const X509_INFO **b), comp))) - -#define sk_X509_INFO_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(X509_INFO) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(X509_INFO) *, sk), \ - CHECKED_CAST(void *(*)(void *), X509_INFO *(*)(X509_INFO *), copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_INFO *), free_func))) - -/* X509_LOOKUP */ -#define sk_X509_LOOKUP_new(comp) \ - ((STACK_OF(X509_LOOKUP) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const X509_LOOKUP **a, const X509_LOOKUP **b), \ - comp))) - -#define sk_X509_LOOKUP_new_null() ((STACK_OF(X509_LOOKUP) *)sk_new_null()) - -#define sk_X509_LOOKUP_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk)) - -#define sk_X509_LOOKUP_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk)); - -#define sk_X509_LOOKUP_value(sk, i) \ - ((X509_LOOKUP *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_LOOKUP) *, sk), (i))) - -#define sk_X509_LOOKUP_set(sk, i, p) \ - ((X509_LOOKUP *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk), \ - (i), CHECKED_CAST(void *, X509_LOOKUP *, p))) - -#define sk_X509_LOOKUP_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk)) - -#define sk_X509_LOOKUP_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_LOOKUP *), free_func)) - -#define sk_X509_LOOKUP_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk), \ - CHECKED_CAST(void *, X509_LOOKUP *, p), (where)) - -#define sk_X509_LOOKUP_delete(sk, where) \ - ((X509_LOOKUP *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk), (where))) - -#define sk_X509_LOOKUP_delete_ptr(sk, p) \ - ((X509_LOOKUP *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk), \ - CHECKED_CAST(void *, X509_LOOKUP *, p))) - -#define sk_X509_LOOKUP_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk), (out_index), \ - CHECKED_CAST(void *, X509_LOOKUP *, p)) - -#define sk_X509_LOOKUP_shift(sk) \ - ((X509_LOOKUP *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk))) - -#define sk_X509_LOOKUP_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk), \ - CHECKED_CAST(void *, X509_LOOKUP *, p)) - -#define sk_X509_LOOKUP_pop(sk) \ - ((X509_LOOKUP *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk))) - -#define sk_X509_LOOKUP_dup(sk) \ - ((STACK_OF(X509_LOOKUP) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_LOOKUP) *, sk))) - -#define sk_X509_LOOKUP_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk)) - -#define sk_X509_LOOKUP_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(X509_LOOKUP) *, sk)) - -#define sk_X509_LOOKUP_set_cmp_func(sk, comp) \ - ((int (*)(const X509_LOOKUP **a, const X509_LOOKUP **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const X509_LOOKUP **a, const X509_LOOKUP **b), \ - comp))) - -#define sk_X509_LOOKUP_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(X509_LOOKUP) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(X509_LOOKUP) *, sk), \ - CHECKED_CAST(void *(*)(void *), X509_LOOKUP *(*)(X509_LOOKUP *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_LOOKUP *), free_func))) - -/* X509_NAME */ -#define sk_X509_NAME_new(comp) \ - ((STACK_OF(X509_NAME) *)sk_new( \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const X509_NAME **a, const X509_NAME **b), comp))) - -#define sk_X509_NAME_new_null() ((STACK_OF(X509_NAME) *)sk_new_null()) - -#define sk_X509_NAME_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk)) - -#define sk_X509_NAME_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk)); - -#define sk_X509_NAME_value(sk, i) \ - ((X509_NAME *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_NAME) *, sk), (i))) - -#define sk_X509_NAME_set(sk, i, p) \ - ((X509_NAME *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk), (i), \ - CHECKED_CAST(void *, X509_NAME *, p))) - -#define sk_X509_NAME_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk)) - -#define sk_X509_NAME_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_NAME *), free_func)) - -#define sk_X509_NAME_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk), \ - CHECKED_CAST(void *, X509_NAME *, p), (where)) - -#define sk_X509_NAME_delete(sk, where) \ - ((X509_NAME *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk), \ - (where))) - -#define sk_X509_NAME_delete_ptr(sk, p) \ - ((X509_NAME *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk), \ - CHECKED_CAST(void *, X509_NAME *, p))) - -#define sk_X509_NAME_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk), (out_index), \ - CHECKED_CAST(void *, X509_NAME *, p)) - -#define sk_X509_NAME_shift(sk) \ - ((X509_NAME *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk))) - -#define sk_X509_NAME_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk), \ - CHECKED_CAST(void *, X509_NAME *, p)) - -#define sk_X509_NAME_pop(sk) \ - ((X509_NAME *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk))) - -#define sk_X509_NAME_dup(sk) \ - ((STACK_OF(X509_NAME) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_NAME) *, sk))) - -#define sk_X509_NAME_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk)) - -#define sk_X509_NAME_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(X509_NAME) *, sk)) - -#define sk_X509_NAME_set_cmp_func(sk, comp) \ - ((int (*)(const X509_NAME **a, const X509_NAME **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const X509_NAME **a, const X509_NAME **b), comp))) - -#define sk_X509_NAME_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(X509_NAME) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(X509_NAME) *, sk), \ - CHECKED_CAST(void *(*)(void *), X509_NAME *(*)(X509_NAME *), copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_NAME *), free_func))) - -/* X509_NAME_ENTRY */ -#define sk_X509_NAME_ENTRY_new(comp) \ - ((STACK_OF(X509_NAME_ENTRY) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, \ - int (*)(const X509_NAME_ENTRY **a, const X509_NAME_ENTRY **b), comp))) - -#define sk_X509_NAME_ENTRY_new_null() \ - ((STACK_OF(X509_NAME_ENTRY) *)sk_new_null()) - -#define sk_X509_NAME_ENTRY_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk)) - -#define sk_X509_NAME_ENTRY_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk)); - -#define sk_X509_NAME_ENTRY_value(sk, i) \ - ((X509_NAME_ENTRY *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_NAME_ENTRY) *, sk), (i))) - -#define sk_X509_NAME_ENTRY_set(sk, i, p) \ - ((X509_NAME_ENTRY *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk), (i), \ - CHECKED_CAST(void *, X509_NAME_ENTRY *, p))) - -#define sk_X509_NAME_ENTRY_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk)) - -#define sk_X509_NAME_ENTRY_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_NAME_ENTRY *), free_func)) - -#define sk_X509_NAME_ENTRY_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk), \ - CHECKED_CAST(void *, X509_NAME_ENTRY *, p), (where)) - -#define sk_X509_NAME_ENTRY_delete(sk, where) \ - ((X509_NAME_ENTRY *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk), (where))) - -#define sk_X509_NAME_ENTRY_delete_ptr(sk, p) \ - ((X509_NAME_ENTRY *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk), \ - CHECKED_CAST(void *, X509_NAME_ENTRY *, p))) - -#define sk_X509_NAME_ENTRY_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk), \ - (out_index), CHECKED_CAST(void *, X509_NAME_ENTRY *, p)) - -#define sk_X509_NAME_ENTRY_shift(sk) \ - ((X509_NAME_ENTRY *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk))) - -#define sk_X509_NAME_ENTRY_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk), \ - CHECKED_CAST(void *, X509_NAME_ENTRY *, p)) - -#define sk_X509_NAME_ENTRY_pop(sk) \ - ((X509_NAME_ENTRY *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk))) - -#define sk_X509_NAME_ENTRY_dup(sk) \ - ((STACK_OF(X509_NAME_ENTRY) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_NAME_ENTRY) *, sk))) - -#define sk_X509_NAME_ENTRY_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk)) - -#define sk_X509_NAME_ENTRY_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(X509_NAME_ENTRY) *, sk)) - -#define sk_X509_NAME_ENTRY_set_cmp_func(sk, comp) \ - ((int (*)(const X509_NAME_ENTRY **a, const X509_NAME_ENTRY **b)) \ - sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk), \ - CHECKED_CAST(stack_cmp_func, int (*)(const X509_NAME_ENTRY **a, \ - const X509_NAME_ENTRY **b), \ - comp))) - -#define sk_X509_NAME_ENTRY_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(X509_NAME_ENTRY) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(X509_NAME_ENTRY) *, sk), \ - CHECKED_CAST(void *(*)(void *), X509_NAME_ENTRY *(*)(X509_NAME_ENTRY *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_NAME_ENTRY *), free_func))) - -/* X509_OBJECT */ -#define sk_X509_OBJECT_new(comp) \ - ((STACK_OF(X509_OBJECT) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const X509_OBJECT **a, const X509_OBJECT **b), \ - comp))) - -#define sk_X509_OBJECT_new_null() ((STACK_OF(X509_OBJECT) *)sk_new_null()) - -#define sk_X509_OBJECT_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk)) - -#define sk_X509_OBJECT_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk)); - -#define sk_X509_OBJECT_value(sk, i) \ - ((X509_OBJECT *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_OBJECT) *, sk), (i))) - -#define sk_X509_OBJECT_set(sk, i, p) \ - ((X509_OBJECT *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk), \ - (i), CHECKED_CAST(void *, X509_OBJECT *, p))) - -#define sk_X509_OBJECT_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk)) - -#define sk_X509_OBJECT_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_OBJECT *), free_func)) - -#define sk_X509_OBJECT_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk), \ - CHECKED_CAST(void *, X509_OBJECT *, p), (where)) - -#define sk_X509_OBJECT_delete(sk, where) \ - ((X509_OBJECT *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk), (where))) - -#define sk_X509_OBJECT_delete_ptr(sk, p) \ - ((X509_OBJECT *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk), \ - CHECKED_CAST(void *, X509_OBJECT *, p))) - -#define sk_X509_OBJECT_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk), (out_index), \ - CHECKED_CAST(void *, X509_OBJECT *, p)) - -#define sk_X509_OBJECT_shift(sk) \ - ((X509_OBJECT *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk))) - -#define sk_X509_OBJECT_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk), \ - CHECKED_CAST(void *, X509_OBJECT *, p)) - -#define sk_X509_OBJECT_pop(sk) \ - ((X509_OBJECT *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk))) - -#define sk_X509_OBJECT_dup(sk) \ - ((STACK_OF(X509_OBJECT) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_OBJECT) *, sk))) - -#define sk_X509_OBJECT_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk)) - -#define sk_X509_OBJECT_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(X509_OBJECT) *, sk)) - -#define sk_X509_OBJECT_set_cmp_func(sk, comp) \ - ((int (*)(const X509_OBJECT **a, const X509_OBJECT **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const X509_OBJECT **a, const X509_OBJECT **b), \ - comp))) - -#define sk_X509_OBJECT_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(X509_OBJECT) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(X509_OBJECT) *, sk), \ - CHECKED_CAST(void *(*)(void *), X509_OBJECT *(*)(X509_OBJECT *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_OBJECT *), free_func))) - -/* X509_POLICY_DATA */ -#define sk_X509_POLICY_DATA_new(comp) \ - ((STACK_OF(X509_POLICY_DATA) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, \ - int (*)(const X509_POLICY_DATA **a, const X509_POLICY_DATA **b), comp))) - -#define sk_X509_POLICY_DATA_new_null() \ - ((STACK_OF(X509_POLICY_DATA) *)sk_new_null()) - -#define sk_X509_POLICY_DATA_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk)) - -#define sk_X509_POLICY_DATA_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk)); - -#define sk_X509_POLICY_DATA_value(sk, i) \ - ((X509_POLICY_DATA *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_POLICY_DATA) *, sk), (i))) - -#define sk_X509_POLICY_DATA_set(sk, i, p) \ - ((X509_POLICY_DATA *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk), (i), \ - CHECKED_CAST(void *, X509_POLICY_DATA *, p))) - -#define sk_X509_POLICY_DATA_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk)) - -#define sk_X509_POLICY_DATA_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_POLICY_DATA *), free_func)) - -#define sk_X509_POLICY_DATA_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk), \ - CHECKED_CAST(void *, X509_POLICY_DATA *, p), (where)) - -#define sk_X509_POLICY_DATA_delete(sk, where) \ - ((X509_POLICY_DATA *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk), (where))) - -#define sk_X509_POLICY_DATA_delete_ptr(sk, p) \ - ((X509_POLICY_DATA *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk), \ - CHECKED_CAST(void *, X509_POLICY_DATA *, p))) - -#define sk_X509_POLICY_DATA_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk), \ - (out_index), CHECKED_CAST(void *, X509_POLICY_DATA *, p)) - -#define sk_X509_POLICY_DATA_shift(sk) \ - ((X509_POLICY_DATA *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk))) - -#define sk_X509_POLICY_DATA_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk), \ - CHECKED_CAST(void *, X509_POLICY_DATA *, p)) - -#define sk_X509_POLICY_DATA_pop(sk) \ - ((X509_POLICY_DATA *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk))) - -#define sk_X509_POLICY_DATA_dup(sk) \ - ((STACK_OF(X509_POLICY_DATA) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_POLICY_DATA) *, sk))) - -#define sk_X509_POLICY_DATA_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk)) - -#define sk_X509_POLICY_DATA_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(X509_POLICY_DATA) *, sk)) - -#define sk_X509_POLICY_DATA_set_cmp_func(sk, comp) \ - ((int (*)(const X509_POLICY_DATA **a, const X509_POLICY_DATA **b)) \ - sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk), \ - CHECKED_CAST(stack_cmp_func, int (*)(const X509_POLICY_DATA **a, \ - const X509_POLICY_DATA **b), \ - comp))) - -#define sk_X509_POLICY_DATA_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(X509_POLICY_DATA) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(X509_POLICY_DATA) *, sk), \ - CHECKED_CAST(void *(*)(void *), \ - X509_POLICY_DATA *(*)(X509_POLICY_DATA *), copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_POLICY_DATA *), \ - free_func))) - -/* X509_POLICY_NODE */ -#define sk_X509_POLICY_NODE_new(comp) \ - ((STACK_OF(X509_POLICY_NODE) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, \ - int (*)(const X509_POLICY_NODE **a, const X509_POLICY_NODE **b), comp))) - -#define sk_X509_POLICY_NODE_new_null() \ - ((STACK_OF(X509_POLICY_NODE) *)sk_new_null()) - -#define sk_X509_POLICY_NODE_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk)) - -#define sk_X509_POLICY_NODE_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk)); - -#define sk_X509_POLICY_NODE_value(sk, i) \ - ((X509_POLICY_NODE *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_POLICY_NODE) *, sk), (i))) - -#define sk_X509_POLICY_NODE_set(sk, i, p) \ - ((X509_POLICY_NODE *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk), (i), \ - CHECKED_CAST(void *, X509_POLICY_NODE *, p))) - -#define sk_X509_POLICY_NODE_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk)) - -#define sk_X509_POLICY_NODE_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_POLICY_NODE *), free_func)) - -#define sk_X509_POLICY_NODE_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk), \ - CHECKED_CAST(void *, X509_POLICY_NODE *, p), (where)) - -#define sk_X509_POLICY_NODE_delete(sk, where) \ - ((X509_POLICY_NODE *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk), (where))) - -#define sk_X509_POLICY_NODE_delete_ptr(sk, p) \ - ((X509_POLICY_NODE *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk), \ - CHECKED_CAST(void *, X509_POLICY_NODE *, p))) - -#define sk_X509_POLICY_NODE_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk), \ - (out_index), CHECKED_CAST(void *, X509_POLICY_NODE *, p)) - -#define sk_X509_POLICY_NODE_shift(sk) \ - ((X509_POLICY_NODE *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk))) - -#define sk_X509_POLICY_NODE_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk), \ - CHECKED_CAST(void *, X509_POLICY_NODE *, p)) - -#define sk_X509_POLICY_NODE_pop(sk) \ - ((X509_POLICY_NODE *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk))) - -#define sk_X509_POLICY_NODE_dup(sk) \ - ((STACK_OF(X509_POLICY_NODE) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_POLICY_NODE) *, sk))) - -#define sk_X509_POLICY_NODE_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk)) - -#define sk_X509_POLICY_NODE_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(X509_POLICY_NODE) *, sk)) - -#define sk_X509_POLICY_NODE_set_cmp_func(sk, comp) \ - ((int (*)(const X509_POLICY_NODE **a, const X509_POLICY_NODE **b)) \ - sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk), \ - CHECKED_CAST(stack_cmp_func, int (*)(const X509_POLICY_NODE **a, \ - const X509_POLICY_NODE **b), \ - comp))) - -#define sk_X509_POLICY_NODE_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(X509_POLICY_NODE) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(X509_POLICY_NODE) *, sk), \ - CHECKED_CAST(void *(*)(void *), \ - X509_POLICY_NODE *(*)(X509_POLICY_NODE *), copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_POLICY_NODE *), \ - free_func))) - -/* X509_PURPOSE */ -#define sk_X509_PURPOSE_new(comp) \ - ((STACK_OF(X509_PURPOSE) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const X509_PURPOSE **a, const X509_PURPOSE **b), \ - comp))) - -#define sk_X509_PURPOSE_new_null() ((STACK_OF(X509_PURPOSE) *)sk_new_null()) - -#define sk_X509_PURPOSE_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk)) - -#define sk_X509_PURPOSE_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk)); - -#define sk_X509_PURPOSE_value(sk, i) \ - ((X509_PURPOSE *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_PURPOSE) *, sk), (i))) - -#define sk_X509_PURPOSE_set(sk, i, p) \ - ((X509_PURPOSE *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk), (i), \ - CHECKED_CAST(void *, X509_PURPOSE *, p))) - -#define sk_X509_PURPOSE_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk)) - -#define sk_X509_PURPOSE_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_PURPOSE *), free_func)) - -#define sk_X509_PURPOSE_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk), \ - CHECKED_CAST(void *, X509_PURPOSE *, p), (where)) - -#define sk_X509_PURPOSE_delete(sk, where) \ - ((X509_PURPOSE *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk), (where))) - -#define sk_X509_PURPOSE_delete_ptr(sk, p) \ - ((X509_PURPOSE *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk), \ - CHECKED_CAST(void *, X509_PURPOSE *, p))) - -#define sk_X509_PURPOSE_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk), (out_index), \ - CHECKED_CAST(void *, X509_PURPOSE *, p)) - -#define sk_X509_PURPOSE_shift(sk) \ - ((X509_PURPOSE *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk))) - -#define sk_X509_PURPOSE_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk), \ - CHECKED_CAST(void *, X509_PURPOSE *, p)) - -#define sk_X509_PURPOSE_pop(sk) \ - ((X509_PURPOSE *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk))) - -#define sk_X509_PURPOSE_dup(sk) \ - ((STACK_OF(X509_PURPOSE) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_PURPOSE) *, sk))) - -#define sk_X509_PURPOSE_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk)) - -#define sk_X509_PURPOSE_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(X509_PURPOSE) *, sk)) - -#define sk_X509_PURPOSE_set_cmp_func(sk, comp) \ - ((int (*)(const X509_PURPOSE **a, const X509_PURPOSE **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const X509_PURPOSE **a, const X509_PURPOSE **b), \ - comp))) - -#define sk_X509_PURPOSE_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(X509_PURPOSE) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(X509_PURPOSE) *, sk), \ - CHECKED_CAST(void *(*)(void *), X509_PURPOSE *(*)(X509_PURPOSE *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_PURPOSE *), free_func))) - -/* X509_REVOKED */ -#define sk_X509_REVOKED_new(comp) \ - ((STACK_OF(X509_REVOKED) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const X509_REVOKED **a, const X509_REVOKED **b), \ - comp))) - -#define sk_X509_REVOKED_new_null() ((STACK_OF(X509_REVOKED) *)sk_new_null()) - -#define sk_X509_REVOKED_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk)) - -#define sk_X509_REVOKED_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk)); - -#define sk_X509_REVOKED_value(sk, i) \ - ((X509_REVOKED *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_REVOKED) *, sk), (i))) - -#define sk_X509_REVOKED_set(sk, i, p) \ - ((X509_REVOKED *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk), (i), \ - CHECKED_CAST(void *, X509_REVOKED *, p))) - -#define sk_X509_REVOKED_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk)) - -#define sk_X509_REVOKED_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_REVOKED *), free_func)) - -#define sk_X509_REVOKED_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk), \ - CHECKED_CAST(void *, X509_REVOKED *, p), (where)) - -#define sk_X509_REVOKED_delete(sk, where) \ - ((X509_REVOKED *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk), (where))) - -#define sk_X509_REVOKED_delete_ptr(sk, p) \ - ((X509_REVOKED *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk), \ - CHECKED_CAST(void *, X509_REVOKED *, p))) - -#define sk_X509_REVOKED_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk), (out_index), \ - CHECKED_CAST(void *, X509_REVOKED *, p)) - -#define sk_X509_REVOKED_shift(sk) \ - ((X509_REVOKED *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk))) - -#define sk_X509_REVOKED_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk), \ - CHECKED_CAST(void *, X509_REVOKED *, p)) - -#define sk_X509_REVOKED_pop(sk) \ - ((X509_REVOKED *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk))) - -#define sk_X509_REVOKED_dup(sk) \ - ((STACK_OF(X509_REVOKED) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_REVOKED) *, sk))) - -#define sk_X509_REVOKED_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk)) - -#define sk_X509_REVOKED_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(X509_REVOKED) *, sk)) - -#define sk_X509_REVOKED_set_cmp_func(sk, comp) \ - ((int (*)(const X509_REVOKED **a, const X509_REVOKED **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const X509_REVOKED **a, const X509_REVOKED **b), \ - comp))) - -#define sk_X509_REVOKED_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(X509_REVOKED) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(X509_REVOKED) *, sk), \ - CHECKED_CAST(void *(*)(void *), X509_REVOKED *(*)(X509_REVOKED *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_REVOKED *), free_func))) - -/* X509_TRUST */ -#define sk_X509_TRUST_new(comp) \ - ((STACK_OF(X509_TRUST) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const X509_TRUST **a, const X509_TRUST **b), \ - comp))) - -#define sk_X509_TRUST_new_null() ((STACK_OF(X509_TRUST) *)sk_new_null()) - -#define sk_X509_TRUST_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk)) - -#define sk_X509_TRUST_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk)); - -#define sk_X509_TRUST_value(sk, i) \ - ((X509_TRUST *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_TRUST) *, sk), (i))) - -#define sk_X509_TRUST_set(sk, i, p) \ - ((X509_TRUST *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk), \ - (i), CHECKED_CAST(void *, X509_TRUST *, p))) - -#define sk_X509_TRUST_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk)) - -#define sk_X509_TRUST_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_TRUST *), free_func)) - -#define sk_X509_TRUST_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk), \ - CHECKED_CAST(void *, X509_TRUST *, p), (where)) - -#define sk_X509_TRUST_delete(sk, where) \ - ((X509_TRUST *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk), \ - (where))) - -#define sk_X509_TRUST_delete_ptr(sk, p) \ - ((X509_TRUST *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk), \ - CHECKED_CAST(void *, X509_TRUST *, p))) - -#define sk_X509_TRUST_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk), (out_index), \ - CHECKED_CAST(void *, X509_TRUST *, p)) - -#define sk_X509_TRUST_shift(sk) \ - ((X509_TRUST *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk))) - -#define sk_X509_TRUST_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk), \ - CHECKED_CAST(void *, X509_TRUST *, p)) - -#define sk_X509_TRUST_pop(sk) \ - ((X509_TRUST *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk))) - -#define sk_X509_TRUST_dup(sk) \ - ((STACK_OF(X509_TRUST) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_TRUST) *, sk))) - -#define sk_X509_TRUST_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk)) - -#define sk_X509_TRUST_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(X509_TRUST) *, sk)) - -#define sk_X509_TRUST_set_cmp_func(sk, comp) \ - ((int (*)(const X509_TRUST **a, const X509_TRUST **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const X509_TRUST **a, const X509_TRUST **b), \ - comp))) - -#define sk_X509_TRUST_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(X509_TRUST) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(X509_TRUST) *, sk), \ - CHECKED_CAST(void *(*)(void *), X509_TRUST *(*)(X509_TRUST *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_TRUST *), free_func))) - -/* X509_VERIFY_PARAM */ -#define sk_X509_VERIFY_PARAM_new(comp) \ - ((STACK_OF(X509_VERIFY_PARAM) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, \ - int (*)(const X509_VERIFY_PARAM **a, const X509_VERIFY_PARAM **b), \ - comp))) - -#define sk_X509_VERIFY_PARAM_new_null() \ - ((STACK_OF(X509_VERIFY_PARAM) *)sk_new_null()) - -#define sk_X509_VERIFY_PARAM_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk)) - -#define sk_X509_VERIFY_PARAM_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk)); - -#define sk_X509_VERIFY_PARAM_value(sk, i) \ - ((X509_VERIFY_PARAM *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_VERIFY_PARAM) *, sk), (i))) - -#define sk_X509_VERIFY_PARAM_set(sk, i, p) \ - ((X509_VERIFY_PARAM *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk), (i), \ - CHECKED_CAST(void *, X509_VERIFY_PARAM *, p))) - -#define sk_X509_VERIFY_PARAM_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk)) - -#define sk_X509_VERIFY_PARAM_pop_free(sk, free_func) \ - sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_VERIFY_PARAM *), \ - free_func)) - -#define sk_X509_VERIFY_PARAM_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk), \ - CHECKED_CAST(void *, X509_VERIFY_PARAM *, p), (where)) - -#define sk_X509_VERIFY_PARAM_delete(sk, where) \ - ((X509_VERIFY_PARAM *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk), (where))) - -#define sk_X509_VERIFY_PARAM_delete_ptr(sk, p) \ - ((X509_VERIFY_PARAM *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk), \ - CHECKED_CAST(void *, X509_VERIFY_PARAM *, p))) - -#define sk_X509_VERIFY_PARAM_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk), \ - (out_index), CHECKED_CAST(void *, X509_VERIFY_PARAM *, p)) - -#define sk_X509_VERIFY_PARAM_shift(sk) \ - ((X509_VERIFY_PARAM *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk))) - -#define sk_X509_VERIFY_PARAM_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk), \ - CHECKED_CAST(void *, X509_VERIFY_PARAM *, p)) - -#define sk_X509_VERIFY_PARAM_pop(sk) \ - ((X509_VERIFY_PARAM *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk))) - -#define sk_X509_VERIFY_PARAM_dup(sk) \ - ((STACK_OF(X509_VERIFY_PARAM) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(X509_VERIFY_PARAM) *, sk))) - -#define sk_X509_VERIFY_PARAM_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk)) - -#define sk_X509_VERIFY_PARAM_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(X509_VERIFY_PARAM) *, sk)) - -#define sk_X509_VERIFY_PARAM_set_cmp_func(sk, comp) \ - ((int (*)(const X509_VERIFY_PARAM **a, const X509_VERIFY_PARAM **b)) \ - sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk), \ - CHECKED_CAST(stack_cmp_func, int (*)(const X509_VERIFY_PARAM **a, \ - const X509_VERIFY_PARAM **b), \ - comp))) - -#define sk_X509_VERIFY_PARAM_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(X509_VERIFY_PARAM) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(X509_VERIFY_PARAM) *, sk), \ - CHECKED_CAST(void *(*)(void *), \ - X509_VERIFY_PARAM *(*)(X509_VERIFY_PARAM *), copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(X509_VERIFY_PARAM *), \ - free_func))) - -/* void */ -#define sk_void_new(comp) \ - ((STACK_OF(void)*)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const void **a, const void **b), comp))) - -#define sk_void_new_null() ((STACK_OF(void)*)sk_new_null()) - -#define sk_void_num(sk) sk_num(CHECKED_CAST(_STACK *, STACK_OF(void)*, sk)) - -#define sk_void_zero(sk) sk_zero(CHECKED_CAST(_STACK *, STACK_OF(void)*, sk)); - -#define sk_void_value(sk, i) \ - ((void *)sk_value(CHECKED_CAST(_STACK *, const STACK_OF(void)*, sk), (i))) - -#define sk_void_set(sk, i, p) \ - ((void *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(void)*, sk), (i), \ - CHECKED_CAST(void *, void *, p))) - -#define sk_void_free(sk) sk_free(CHECKED_CAST(_STACK *, STACK_OF(void)*, sk)) - -#define sk_void_pop_free(sk, free_func) \ - sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(void)*, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(void *), free_func)) - -#define sk_void_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(void)*, sk), \ - CHECKED_CAST(void *, void *, p), (where)) - -#define sk_void_delete(sk, where) \ - ((void *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(void)*, sk), (where))) - -#define sk_void_delete_ptr(sk, p) \ - ((void *)sk_delete_ptr(CHECKED_CAST(_STACK *, STACK_OF(void)*, sk), \ - CHECKED_CAST(void *, void *, p))) - -#define sk_void_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(void)*, sk), (out_index), \ - CHECKED_CAST(void *, void *, p)) - -#define sk_void_shift(sk) \ - ((void *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(void)*, sk))) - -#define sk_void_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(void)*, sk), \ - CHECKED_CAST(void *, void *, p)) - -#define sk_void_pop(sk) \ - ((void *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(void)*, sk))) - -#define sk_void_dup(sk) \ - ((STACK_OF(void)*)sk_dup(CHECKED_CAST(_STACK *, const STACK_OF(void)*, sk))) - -#define sk_void_sort(sk) sk_sort(CHECKED_CAST(_STACK *, STACK_OF(void)*, sk)) - -#define sk_void_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(void)*, sk)) - -#define sk_void_set_cmp_func(sk, comp) \ - ((int (*)(const void **a, const void **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(void)*, sk), \ - CHECKED_CAST(stack_cmp_func, int (*)(const void **a, const void **b), \ - comp))) - -#define sk_void_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(void)*)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(void)*, sk), \ - CHECKED_CAST(void *(*)(void *), void *(*)(void *), copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(void *), free_func))) - -/* SRTP_PROTECTION_PROFILE */ -#define sk_SRTP_PROTECTION_PROFILE_new(comp) \ - ((STACK_OF(SRTP_PROTECTION_PROFILE) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const const SRTP_PROTECTION_PROFILE **a, \ - const const SRTP_PROTECTION_PROFILE **b), \ - comp))) - -#define sk_SRTP_PROTECTION_PROFILE_new_null() \ - ((STACK_OF(SRTP_PROTECTION_PROFILE) *)sk_new_null()) - -#define sk_SRTP_PROTECTION_PROFILE_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk)) - -#define sk_SRTP_PROTECTION_PROFILE_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk)); - -#define sk_SRTP_PROTECTION_PROFILE_value(sk, i) \ - ((const SRTP_PROTECTION_PROFILE *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(SRTP_PROTECTION_PROFILE) *, sk), \ - (i))) - -#define sk_SRTP_PROTECTION_PROFILE_set(sk, i, p) \ - ((const SRTP_PROTECTION_PROFILE *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk), (i), \ - CHECKED_CAST(void *, const SRTP_PROTECTION_PROFILE *, p))) - -#define sk_SRTP_PROTECTION_PROFILE_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk)) - -#define sk_SRTP_PROTECTION_PROFILE_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk), \ - CHECKED_CAST(void (*)(void *), \ - void (*)(const SRTP_PROTECTION_PROFILE *), free_func)) - -#define sk_SRTP_PROTECTION_PROFILE_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk), \ - CHECKED_CAST(void *, const SRTP_PROTECTION_PROFILE *, p), (where)) - -#define sk_SRTP_PROTECTION_PROFILE_delete(sk, where) \ - ((const SRTP_PROTECTION_PROFILE *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk), \ - (where))) - -#define sk_SRTP_PROTECTION_PROFILE_delete_ptr(sk, p) \ - ((const SRTP_PROTECTION_PROFILE *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk), \ - CHECKED_CAST(void *, const SRTP_PROTECTION_PROFILE *, p))) - -#define sk_SRTP_PROTECTION_PROFILE_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk), \ - (out_index), \ - CHECKED_CAST(void *, const SRTP_PROTECTION_PROFILE *, p)) - -#define sk_SRTP_PROTECTION_PROFILE_shift(sk) \ - ((const SRTP_PROTECTION_PROFILE *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk))) - -#define sk_SRTP_PROTECTION_PROFILE_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk), \ - CHECKED_CAST(void *, const SRTP_PROTECTION_PROFILE *, p)) - -#define sk_SRTP_PROTECTION_PROFILE_pop(sk) \ - ((const SRTP_PROTECTION_PROFILE *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk))) - -#define sk_SRTP_PROTECTION_PROFILE_dup(sk) \ - ((STACK_OF(SRTP_PROTECTION_PROFILE) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(SRTP_PROTECTION_PROFILE) *, sk))) - -#define sk_SRTP_PROTECTION_PROFILE_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk)) - -#define sk_SRTP_PROTECTION_PROFILE_is_sorted(sk) \ - sk_is_sorted( \ - CHECKED_CAST(_STACK *, const STACK_OF(SRTP_PROTECTION_PROFILE) *, sk)) - -#define sk_SRTP_PROTECTION_PROFILE_set_cmp_func(sk, comp) \ - ((int (*)(const SRTP_PROTECTION_PROFILE **a, \ - const SRTP_PROTECTION_PROFILE **b)) \ - sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const SRTP_PROTECTION_PROFILE **a, \ - const SRTP_PROTECTION_PROFILE **b), \ - comp))) - -#define sk_SRTP_PROTECTION_PROFILE_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(SRTP_PROTECTION_PROFILE) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(SRTP_PROTECTION_PROFILE) *, \ - sk), \ - CHECKED_CAST(void *(*)(void *), const SRTP_PROTECTION_PROFILE *(*)( \ - const SRTP_PROTECTION_PROFILE *), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), \ - void (*)(const SRTP_PROTECTION_PROFILE *), free_func))) - -/* SSL_CIPHER */ -#define sk_SSL_CIPHER_new(comp) \ - ((STACK_OF(SSL_CIPHER) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, \ - int (*)(const const SSL_CIPHER **a, const const SSL_CIPHER **b), comp))) - -#define sk_SSL_CIPHER_new_null() ((STACK_OF(SSL_CIPHER) *)sk_new_null()) - -#define sk_SSL_CIPHER_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk)) - -#define sk_SSL_CIPHER_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk)); - -#define sk_SSL_CIPHER_value(sk, i) \ - ((const SSL_CIPHER *)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(SSL_CIPHER) *, sk), (i))) - -#define sk_SSL_CIPHER_set(sk, i, p) \ - ((const SSL_CIPHER *)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk), (i), \ - CHECKED_CAST(void *, const SSL_CIPHER *, p))) - -#define sk_SSL_CIPHER_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk)) - -#define sk_SSL_CIPHER_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(const SSL_CIPHER *), free_func)) - -#define sk_SSL_CIPHER_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk), \ - CHECKED_CAST(void *, const SSL_CIPHER *, p), (where)) - -#define sk_SSL_CIPHER_delete(sk, where) \ - ((const SSL_CIPHER *)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk), (where))) - -#define sk_SSL_CIPHER_delete_ptr(sk, p) \ - ((const SSL_CIPHER *)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk), \ - CHECKED_CAST(void *, const SSL_CIPHER *, p))) - -#define sk_SSL_CIPHER_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk), (out_index), \ - CHECKED_CAST(void *, const SSL_CIPHER *, p)) - -#define sk_SSL_CIPHER_shift(sk) \ - ((const SSL_CIPHER *)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk))) - -#define sk_SSL_CIPHER_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk), \ - CHECKED_CAST(void *, const SSL_CIPHER *, p)) - -#define sk_SSL_CIPHER_pop(sk) \ - ((const SSL_CIPHER *)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk))) - -#define sk_SSL_CIPHER_dup(sk) \ - ((STACK_OF(SSL_CIPHER) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(SSL_CIPHER) *, sk))) - -#define sk_SSL_CIPHER_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk)) - -#define sk_SSL_CIPHER_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(SSL_CIPHER) *, sk)) - -#define sk_SSL_CIPHER_set_cmp_func(sk, comp) \ - ((int (*)(const SSL_CIPHER **a, const SSL_CIPHER **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const SSL_CIPHER **a, const SSL_CIPHER **b), \ - comp))) - -#define sk_SSL_CIPHER_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(SSL_CIPHER) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(SSL_CIPHER) *, sk), \ - CHECKED_CAST(void *(*)(void *), \ - const SSL_CIPHER *(*)(const SSL_CIPHER *), copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(const SSL_CIPHER *), \ - free_func))) - -/* OPENSSL_STRING */ -#define sk_OPENSSL_STRING_new(comp) \ - ((STACK_OF(OPENSSL_STRING) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, \ - int (*)(const OPENSSL_STRING *a, const OPENSSL_STRING *b), comp))) - -#define sk_OPENSSL_STRING_new_null() ((STACK_OF(OPENSSL_STRING) *)sk_new_null()) - -#define sk_OPENSSL_STRING_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk)) - -#define sk_OPENSSL_STRING_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk)); - -#define sk_OPENSSL_STRING_value(sk, i) \ - ((OPENSSL_STRING)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(OPENSSL_STRING) *, sk), (i))) - -#define sk_OPENSSL_STRING_set(sk, i, p) \ - ((OPENSSL_STRING)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk), (i), \ - CHECKED_CAST(void *, OPENSSL_STRING, p))) - -#define sk_OPENSSL_STRING_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk)) - -#define sk_OPENSSL_STRING_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(OPENSSL_STRING), free_func)) - -#define sk_OPENSSL_STRING_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk), \ - CHECKED_CAST(void *, OPENSSL_STRING, p), (where)) - -#define sk_OPENSSL_STRING_delete(sk, where) \ - ((OPENSSL_STRING)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk), (where))) - -#define sk_OPENSSL_STRING_delete_ptr(sk, p) \ - ((OPENSSL_STRING)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk), \ - CHECKED_CAST(void *, OPENSSL_STRING, p))) - -#define sk_OPENSSL_STRING_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk), (out_index), \ - CHECKED_CAST(void *, OPENSSL_STRING, p)) - -#define sk_OPENSSL_STRING_shift(sk) \ - ((OPENSSL_STRING)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk))) - -#define sk_OPENSSL_STRING_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk), \ - CHECKED_CAST(void *, OPENSSL_STRING, p)) - -#define sk_OPENSSL_STRING_pop(sk) \ - ((OPENSSL_STRING)sk_pop( \ - CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk))) - -#define sk_OPENSSL_STRING_dup(sk) \ - ((STACK_OF(OPENSSL_STRING) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(OPENSSL_STRING) *, sk))) - -#define sk_OPENSSL_STRING_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk)) - -#define sk_OPENSSL_STRING_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(OPENSSL_STRING) *, sk)) - -#define sk_OPENSSL_STRING_set_cmp_func(sk, comp) \ - ((int (*)(const OPENSSL_STRING **a, const OPENSSL_STRING **b)) \ - sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk), \ - CHECKED_CAST(stack_cmp_func, int (*)(const OPENSSL_STRING **a, \ - const OPENSSL_STRING **b), \ - comp))) - -#define sk_OPENSSL_STRING_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(OPENSSL_STRING) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(OPENSSL_STRING) *, sk), \ - CHECKED_CAST(void *(*)(void *), OPENSSL_STRING (*)(OPENSSL_STRING), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(OPENSSL_STRING), free_func))) - -/* OPENSSL_BLOCK */ -#define sk_OPENSSL_BLOCK_new(comp) \ - ((STACK_OF(OPENSSL_BLOCK) *)sk_new(CHECKED_CAST( \ - stack_cmp_func, int (*)(const OPENSSL_BLOCK *a, const OPENSSL_BLOCK *b), \ - comp))) - -#define sk_OPENSSL_BLOCK_new_null() ((STACK_OF(OPENSSL_BLOCK) *)sk_new_null()) - -#define sk_OPENSSL_BLOCK_num(sk) \ - sk_num(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_BLOCK) *, sk)) - -#define sk_OPENSSL_BLOCK_zero(sk) \ - sk_zero(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_BLOCK) *, sk)); - -#define sk_OPENSSL_BLOCK_value(sk, i) \ - ((OPENSSL_BLOCK)sk_value( \ - CHECKED_CAST(_STACK *, const STACK_OF(OPENSSL_BLOCK) *, sk), (i))) - -#define sk_OPENSSL_BLOCK_set(sk, i, p) \ - ((OPENSSL_BLOCK)sk_set( \ - CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_BLOCK) *, sk), (i), \ - CHECKED_CAST(void *, OPENSSL_BLOCK, p))) - -#define sk_OPENSSL_BLOCK_free(sk) \ - sk_free(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_BLOCK) *, sk)) - -#define sk_OPENSSL_BLOCK_pop_free(sk, free_func) \ - sk_pop_free( \ - CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_BLOCK) *, sk), \ - CHECKED_CAST(void (*)(void *), void (*)(OPENSSL_BLOCK), free_func)) - -#define sk_OPENSSL_BLOCK_insert(sk, p, where) \ - sk_insert(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_BLOCK) *, sk), \ - CHECKED_CAST(void *, OPENSSL_BLOCK, p), (where)) - -#define sk_OPENSSL_BLOCK_delete(sk, where) \ - ((OPENSSL_BLOCK)sk_delete( \ - CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_BLOCK) *, sk), (where))) - -#define sk_OPENSSL_BLOCK_delete_ptr(sk, p) \ - ((OPENSSL_BLOCK)sk_delete_ptr( \ - CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_BLOCK) *, sk), \ - CHECKED_CAST(void *, OPENSSL_BLOCK, p))) - -#define sk_OPENSSL_BLOCK_find(sk, out_index, p) \ - sk_find(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_BLOCK) *, sk), (out_index), \ - CHECKED_CAST(void *, OPENSSL_BLOCK, p)) - -#define sk_OPENSSL_BLOCK_shift(sk) \ - ((OPENSSL_BLOCK)sk_shift( \ - CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_BLOCK) *, sk))) - -#define sk_OPENSSL_BLOCK_push(sk, p) \ - sk_push(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_BLOCK) *, sk), \ - CHECKED_CAST(void *, OPENSSL_BLOCK, p)) - -#define sk_OPENSSL_BLOCK_pop(sk) \ - ((OPENSSL_BLOCK)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_BLOCK) *, sk))) - -#define sk_OPENSSL_BLOCK_dup(sk) \ - ((STACK_OF(OPENSSL_BLOCK) *)sk_dup( \ - CHECKED_CAST(_STACK *, const STACK_OF(OPENSSL_BLOCK) *, sk))) - -#define sk_OPENSSL_BLOCK_sort(sk) \ - sk_sort(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_BLOCK) *, sk)) - -#define sk_OPENSSL_BLOCK_is_sorted(sk) \ - sk_is_sorted(CHECKED_CAST(_STACK *, const STACK_OF(OPENSSL_BLOCK) *, sk)) - -#define sk_OPENSSL_BLOCK_set_cmp_func(sk, comp) \ - ((int (*)(const OPENSSL_BLOCK **a, const OPENSSL_BLOCK **b))sk_set_cmp_func( \ - CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_BLOCK) *, sk), \ - CHECKED_CAST(stack_cmp_func, \ - int (*)(const OPENSSL_BLOCK **a, const OPENSSL_BLOCK **b), \ - comp))) - -#define sk_OPENSSL_BLOCK_deep_copy(sk, copy_func, free_func) \ - ((STACK_OF(OPENSSL_BLOCK) *)sk_deep_copy( \ - CHECKED_CAST(const _STACK *, const STACK_OF(OPENSSL_BLOCK) *, sk), \ - CHECKED_CAST(void *(*)(void *), OPENSSL_BLOCK (*)(OPENSSL_BLOCK), \ - copy_func), \ - CHECKED_CAST(void (*)(void *), void (*)(OPENSSL_BLOCK), free_func))) diff --git a/phonelibs/boringssl/include/openssl/thread.h b/phonelibs/boringssl/include/openssl/thread.h deleted file mode 100644 index 568a858332ac8c..00000000000000 --- a/phonelibs/boringssl/include/openssl/thread.h +++ /dev/null @@ -1,173 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_THREAD_H -#define OPENSSL_HEADER_THREAD_H - -#include - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -#if defined(OPENSSL_NO_THREADS) -typedef struct crypto_mutex_st {} CRYPTO_MUTEX; -#elif defined(OPENSSL_WINDOWS) -/* CRYPTO_MUTEX can appear in public header files so we really don't want to - * pull in windows.h. It's statically asserted that this structure is large - * enough to contain a Windows CRITICAL_SECTION by thread_win.c. */ -typedef union crypto_mutex_st { - double alignment; - uint8_t padding[4*sizeof(void*) + 2*sizeof(int)]; -} CRYPTO_MUTEX; -#elif defined(__MACH__) && defined(__APPLE__) -typedef pthread_rwlock_t CRYPTO_MUTEX; -#else -/* It is reasonable to include pthread.h on non-Windows systems, however the - * |pthread_rwlock_t| that we need is hidden under feature flags, and we can't - * ensure that we'll be able to get it. It's statically asserted that this - * structure is large enough to contain a |pthread_rwlock_t| by - * thread_pthread.c. */ -typedef union crypto_mutex_st { - double alignment; - uint8_t padding[3*sizeof(int) + 5*sizeof(unsigned) + 16 + 8]; -} CRYPTO_MUTEX; -#endif - -/* CRYPTO_refcount_t is the type of a reference count. - * - * Since some platforms use C11 atomics to access this, it should have the - * _Atomic qualifier. However, this header is included by C++ programs as well - * as C code that might not set -std=c11. So, in practice, it's not possible to - * do that. Instead we statically assert that the size and native alignment of - * a plain uint32_t and an _Atomic uint32_t are equal in refcount_c11.c. */ -typedef uint32_t CRYPTO_refcount_t; - - -/* Deprecated functions */ - -/* These defines do nothing but are provided to make old code easier to - * compile. */ -#define CRYPTO_LOCK 1 -#define CRYPTO_UNLOCK 2 -#define CRYPTO_READ 4 -#define CRYPTO_WRITE 8 - -/* CRYPTO_num_locks returns one. (This is non-zero that callers who allocate - * sizeof(lock) times this value don't get zero and then fail because malloc(0) - * returned NULL.) */ -OPENSSL_EXPORT int CRYPTO_num_locks(void); - -/* CRYPTO_set_locking_callback does nothing. */ -OPENSSL_EXPORT void CRYPTO_set_locking_callback( - void (*func)(int mode, int lock_num, const char *file, int line)); - -/* CRYPTO_set_add_lock_callback does nothing. */ -OPENSSL_EXPORT void CRYPTO_set_add_lock_callback(int (*func)( - int *num, int amount, int lock_num, const char *file, int line)); - -/* CRYPTO_get_lock_name returns a fixed, dummy string. */ -OPENSSL_EXPORT const char *CRYPTO_get_lock_name(int lock_num); - -/* CRYPTO_THREADID_set_callback returns one. */ -OPENSSL_EXPORT int CRYPTO_THREADID_set_callback( - void (*threadid_func)(CRYPTO_THREADID *threadid)); - -/* CRYPTO_THREADID_set_numeric does nothing. */ -OPENSSL_EXPORT void CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, - unsigned long val); - -/* CRYPTO_THREADID_set_pointer does nothing. */ -OPENSSL_EXPORT void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr); - -/* CRYPTO_THREADID_current does nothing. */ -OPENSSL_EXPORT void CRYPTO_THREADID_current(CRYPTO_THREADID *id); - - -/* Private functions. - * - * Some old code calls these functions and so no-op implementations are - * provided. - * - * TODO(fork): cleanup callers and remove. */ - -OPENSSL_EXPORT void CRYPTO_set_id_callback(unsigned long (*func)(void)); - -typedef struct { - int references; - struct CRYPTO_dynlock_value *data; -} CRYPTO_dynlock; - -OPENSSL_EXPORT void CRYPTO_set_dynlock_create_callback( - struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, - int line)); - -OPENSSL_EXPORT void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)( - int mode, struct CRYPTO_dynlock_value *l, const char *file, int line)); - -OPENSSL_EXPORT void CRYPTO_set_dynlock_destroy_callback( - void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, - const char *file, int line)); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_THREAD_H */ diff --git a/phonelibs/boringssl/include/openssl/time_support.h b/phonelibs/boringssl/include/openssl/time_support.h deleted file mode 100644 index 912e6724152f7a..00000000000000 --- a/phonelibs/boringssl/include/openssl/time_support.h +++ /dev/null @@ -1,90 +0,0 @@ -/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL - * project 2001. - * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL - * project 2008. - */ -/* ==================================================================== - * Copyright (c) 2001 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). */ - -#ifndef OPENSSL_HEADER_TIME_H -#define OPENSSL_HEADER_TIME_H - -#include - - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* Wrapper functions for time functions. */ - - -/* OPENSSL_gmtime wraps |gmtime_r|. See the manual page for that function. */ -struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result); - -/* OPENSSL_gmtime_adj updates |tm| by adding |offset_day| days and |offset_sec| - * seconds. */ -int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec); - -/* OPENSSL_gmtime_diff calculates the difference between |from| and |to| and - * outputs the difference as a number of days and seconds in |*out_days| and - * |*out_secs|. */ -int OPENSSL_gmtime_diff(int *out_days, int *out_secs, const struct tm *from, - const struct tm *to); - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_TIME_H */ diff --git a/phonelibs/boringssl/include/openssl/tls1.h b/phonelibs/boringssl/include/openssl/tls1.h deleted file mode 100644 index f2bee2738f956e..00000000000000 --- a/phonelibs/boringssl/include/openssl/tls1.h +++ /dev/null @@ -1,714 +0,0 @@ -/* ssl/tls1.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ -/* ==================================================================== - * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * - * Portions of the attached software ("Contribution") are developed by - * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. - * - * The Contribution is licensed pursuant to the OpenSSL open source - * license provided above. - * - * ECC cipher suite support in OpenSSL originally written by - * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories. - * - */ -/* ==================================================================== - * Copyright 2005 Nokia. All rights reserved. - * - * The portions of the attached software ("Contribution") is developed by - * Nokia Corporation and is licensed pursuant to the OpenSSL open source - * license. - * - * The Contribution, originally written by Mika Kousa and Pasi Eronen of - * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites - * support (see RFC 4279) to OpenSSL. - * - * No patent licenses or other rights except those expressly stated in - * the OpenSSL open source license shall be deemed granted or received - * expressly, by implication, estoppel, or otherwise. - * - * No assurances are provided by Nokia that the Contribution does not - * infringe the patent or other intellectual property rights of any third - * party or that the license provides you with all the necessary rights - * to make use of the Contribution. - * - * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN - * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA - * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY - * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR - * OTHERWISE. - */ - -#ifndef HEADER_TLS1_H -#define HEADER_TLS1_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -#define TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES 0 - -#define TLS1_AD_DECRYPTION_FAILED 21 -#define TLS1_AD_RECORD_OVERFLOW 22 -#define TLS1_AD_UNKNOWN_CA 48 /* fatal */ -#define TLS1_AD_ACCESS_DENIED 49 /* fatal */ -#define TLS1_AD_DECODE_ERROR 50 /* fatal */ -#define TLS1_AD_DECRYPT_ERROR 51 -#define TLS1_AD_EXPORT_RESTRICTION 60 /* fatal */ -#define TLS1_AD_PROTOCOL_VERSION 70 /* fatal */ -#define TLS1_AD_INSUFFICIENT_SECURITY 71 /* fatal */ -#define TLS1_AD_INTERNAL_ERROR 80 /* fatal */ -#define TLS1_AD_USER_CANCELLED 90 -#define TLS1_AD_NO_RENEGOTIATION 100 -/* codes 110-114 are from RFC3546 */ -#define TLS1_AD_UNSUPPORTED_EXTENSION 110 -#define TLS1_AD_CERTIFICATE_UNOBTAINABLE 111 -#define TLS1_AD_UNRECOGNIZED_NAME 112 -#define TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE 113 -#define TLS1_AD_BAD_CERTIFICATE_HASH_VALUE 114 -#define TLS1_AD_UNKNOWN_PSK_IDENTITY 115 /* fatal */ - -/* ExtensionType values from RFC3546 / RFC4366 / RFC6066 */ -#define TLSEXT_TYPE_server_name 0 -#define TLSEXT_TYPE_max_fragment_length 1 -#define TLSEXT_TYPE_client_certificate_url 2 -#define TLSEXT_TYPE_trusted_ca_keys 3 -#define TLSEXT_TYPE_truncated_hmac 4 -#define TLSEXT_TYPE_status_request 5 -/* ExtensionType values from RFC4681 */ -#define TLSEXT_TYPE_user_mapping 6 - -/* ExtensionType values from RFC5878 */ -#define TLSEXT_TYPE_client_authz 7 -#define TLSEXT_TYPE_server_authz 8 - -/* ExtensionType values from RFC6091 */ -#define TLSEXT_TYPE_cert_type 9 - -/* ExtensionType values from RFC4492 */ -#define TLSEXT_TYPE_elliptic_curves 10 -#define TLSEXT_TYPE_ec_point_formats 11 - -/* ExtensionType value from RFC5054 */ -#define TLSEXT_TYPE_srp 12 - -/* ExtensionType values from RFC5246 */ -#define TLSEXT_TYPE_signature_algorithms 13 - -/* ExtensionType value from RFC5764 */ -#define TLSEXT_TYPE_use_srtp 14 - -/* ExtensionType value from RFC5620 */ -#define TLSEXT_TYPE_heartbeat 15 - -/* ExtensionType value from RFC7301 */ -#define TLSEXT_TYPE_application_layer_protocol_negotiation 16 - -/* ExtensionType value for TLS padding extension. - * http://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml - * http://tools.ietf.org/html/draft-agl-tls-padding-03 - */ -#define TLSEXT_TYPE_padding 21 - -/* https://tools.ietf.org/html/draft-ietf-tls-session-hash-01 */ -#define TLSEXT_TYPE_extended_master_secret 23 - -/* ExtensionType value from RFC4507 */ -#define TLSEXT_TYPE_session_ticket 35 - -/* ExtensionType value from RFC5746 */ -#define TLSEXT_TYPE_renegotiate 0xff01 - -/* ExtensionType value from RFC6962 */ -#define TLSEXT_TYPE_certificate_timestamp 18 - -/* This is not an IANA defined extension number */ -#define TLSEXT_TYPE_next_proto_neg 13172 - -/* This is not an IANA defined extension number */ -#define TLSEXT_TYPE_channel_id 30031 -#define TLSEXT_TYPE_channel_id_new 30032 - -/* NameType value from RFC 3546 */ -#define TLSEXT_NAMETYPE_host_name 0 -/* status request value from RFC 3546 */ -#define TLSEXT_STATUSTYPE_ocsp 1 - -/* ECPointFormat values from RFC 4492 */ -#define TLSEXT_ECPOINTFORMAT_uncompressed 0 -#define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime 1 -#define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2 2 - -/* Signature and hash algorithms from RFC 5246 */ - -#define TLSEXT_signature_anonymous 0 -#define TLSEXT_signature_rsa 1 -#define TLSEXT_signature_dsa 2 -#define TLSEXT_signature_ecdsa 3 - -#define TLSEXT_hash_none 0 -#define TLSEXT_hash_md5 1 -#define TLSEXT_hash_sha1 2 -#define TLSEXT_hash_sha224 3 -#define TLSEXT_hash_sha256 4 -#define TLSEXT_hash_sha384 5 -#define TLSEXT_hash_sha512 6 - -/* Flag set for unrecognised algorithms */ -#define TLSEXT_nid_unknown 0x1000000 - -/* ECC curves */ - -#define TLSEXT_curve_P_256 23 -#define TLSEXT_curve_P_384 24 - - -#define TLSEXT_MAXLEN_host_name 255 - -OPENSSL_EXPORT const char *SSL_get_servername(const SSL *s, const int type); -OPENSSL_EXPORT int SSL_get_servername_type(const SSL *s); - -/* SSL_export_keying_material exports a value derived from the master secret, as - * specified in RFC 5705. It writes |out_len| bytes to |out| given a label and - * optional context. (Since a zero length context is allowed, the |use_context| - * flag controls whether a context is included.) - * - * It returns one on success and zero otherwise. */ -OPENSSL_EXPORT int SSL_export_keying_material( - SSL *s, uint8_t *out, size_t out_len, const char *label, size_t label_len, - const uint8_t *context, size_t context_len, int use_context); - -OPENSSL_EXPORT int SSL_get_sigalgs(SSL *s, int idx, int *psign, int *phash, - int *psignandhash, uint8_t *rsig, - uint8_t *rhash); - -OPENSSL_EXPORT int SSL_get_shared_sigalgs(SSL *s, int idx, int *psign, - int *phash, int *psignandhash, - uint8_t *rsig, uint8_t *rhash); - -/* SSL_set_tlsext_host_name, for a client, configures |ssl| to advertise |name| - * in the server_name extension. It returns one on success and zero on error. */ -OPENSSL_EXPORT int SSL_set_tlsext_host_name(SSL *ssl, const char *name); - -/* SSL_CTX_set_tlsext_servername_callback configures |callback| to be called on - * the server after ClientHello extensions have been parsed and returns one. - * |callback| may use |SSL_get_servername| to examine the server_name extension - * and return a |SSL_TLSEXT_ERR_*| value. If it returns |SSL_TLSEXT_ERR_NOACK|, - * the server_name extension is not acknowledged in the ServerHello. If the - * return value signals an alert, |callback| should set |*out_alert| to the - * alert to send. */ -OPENSSL_EXPORT int SSL_CTX_set_tlsext_servername_callback( - SSL_CTX *ctx, int (*callback)(SSL *ssl, int *out_alert, void *arg)); - -#define SSL_TLSEXT_ERR_OK 0 -#define SSL_TLSEXT_ERR_ALERT_WARNING 1 -#define SSL_TLSEXT_ERR_ALERT_FATAL 2 -#define SSL_TLSEXT_ERR_NOACK 3 - -/* SSL_CTX_set_tlsext_servername_arg sets the argument to the servername - * callback and returns one. See |SSL_CTX_set_tlsext_servername_callback|. */ -OPENSSL_EXPORT int SSL_CTX_set_tlsext_servername_arg(SSL_CTX *ctx, void *arg); - -#define SSL_CTX_get_tlsext_ticket_keys(ctx, keys, keylen) \ - SSL_CTX_ctrl((ctx), SSL_CTRL_GET_TLSEXT_TICKET_KEYS, (keylen), (keys)) -#define SSL_CTX_set_tlsext_ticket_keys(ctx, keys, keylen) \ - SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TLSEXT_TICKET_KEYS, (keylen), (keys)) - -/* SSL_CTX_set_tlsext_ticket_key_cb sets the ticket callback to |callback| and - * returns one. |callback| will be called when encrypting a new ticket and when - * decrypting a ticket from the client. - * - * In both modes, |ctx| and |hmac_ctx| will already have been initialized with - * |EVP_CIPHER_CTX_init| and |HMAC_CTX_init|, respectively. |callback| - * configures |hmac_ctx| with an HMAC digest and key, and configures |ctx| - * for encryption or decryption, based on the mode. - * - * When encrypting a new ticket, |encrypt| will be one. It writes a public - * 16-byte key name to |key_name| and a fresh IV to |iv|. The output IV length - * must match |EVP_CIPHER_CTX_iv_length| of the cipher selected. In this mode, - * |callback| returns 1 on success and -1 on error. - * - * When decrypting a ticket, |encrypt| will be zero. |key_name| will point to a - * 16-byte key name and |iv| points to an IV. The length of the IV consumed must - * match |EVP_CIPHER_CTX_iv_length| of the cipher selected. In this mode, - * |callback| returns -1 to abort the handshake, 0 if decrypting the ticket - * failed, and 1 or 2 on success. If it returns 2, the ticket will be renewed. - * This may be used to re-key the ticket. - * - * WARNING: |callback| wildly breaks the usual return value convention and is - * called in two different modes. */ -OPENSSL_EXPORT int SSL_CTX_set_tlsext_ticket_key_cb( - SSL_CTX *ctx, int (*callback)(SSL *ssl, uint8_t *key_name, uint8_t *iv, - EVP_CIPHER_CTX *ctx, HMAC_CTX *hmac_ctx, - int encrypt)); - -/* PSK ciphersuites from 4279 */ -#define TLS1_CK_PSK_WITH_RC4_128_SHA 0x0300008A -#define TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA 0x0300008B -#define TLS1_CK_PSK_WITH_AES_128_CBC_SHA 0x0300008C -#define TLS1_CK_PSK_WITH_AES_256_CBC_SHA 0x0300008D - -/* PSK ciphersuites from RFC 5489 */ -#define TLS1_CK_ECDHE_PSK_WITH_AES_128_CBC_SHA 0x0300C035 -#define TLS1_CK_ECDHE_PSK_WITH_AES_256_CBC_SHA 0x0300C036 - -/* Additional TLS ciphersuites from expired Internet Draft - * draft-ietf-tls-56-bit-ciphersuites-01.txt - * (available if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES is defined, see - * s3_lib.c). We actually treat them like SSL 3.0 ciphers, which we probably - * shouldn't. Note that the first two are actually not in the IDs. */ -#define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5 0x03000060 /* not in ID */ -#define TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 0x03000061 /* not in ID */ -#define TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA 0x03000062 -#define TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA 0x03000063 -#define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA 0x03000064 -#define TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA 0x03000065 -#define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA 0x03000066 - -/* AES ciphersuites from RFC3268 */ - -#define TLS1_CK_RSA_WITH_AES_128_SHA 0x0300002F -#define TLS1_CK_DH_DSS_WITH_AES_128_SHA 0x03000030 -#define TLS1_CK_DH_RSA_WITH_AES_128_SHA 0x03000031 -#define TLS1_CK_DHE_DSS_WITH_AES_128_SHA 0x03000032 -#define TLS1_CK_DHE_RSA_WITH_AES_128_SHA 0x03000033 -#define TLS1_CK_ADH_WITH_AES_128_SHA 0x03000034 - -#define TLS1_CK_RSA_WITH_AES_256_SHA 0x03000035 -#define TLS1_CK_DH_DSS_WITH_AES_256_SHA 0x03000036 -#define TLS1_CK_DH_RSA_WITH_AES_256_SHA 0x03000037 -#define TLS1_CK_DHE_DSS_WITH_AES_256_SHA 0x03000038 -#define TLS1_CK_DHE_RSA_WITH_AES_256_SHA 0x03000039 -#define TLS1_CK_ADH_WITH_AES_256_SHA 0x0300003A - -/* TLS v1.2 ciphersuites */ -#define TLS1_CK_RSA_WITH_NULL_SHA256 0x0300003B -#define TLS1_CK_RSA_WITH_AES_128_SHA256 0x0300003C -#define TLS1_CK_RSA_WITH_AES_256_SHA256 0x0300003D -#define TLS1_CK_DH_DSS_WITH_AES_128_SHA256 0x0300003E -#define TLS1_CK_DH_RSA_WITH_AES_128_SHA256 0x0300003F -#define TLS1_CK_DHE_DSS_WITH_AES_128_SHA256 0x03000040 - -/* Camellia ciphersuites from RFC4132 */ -#define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000041 -#define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000042 -#define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000043 -#define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000044 -#define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000045 -#define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA 0x03000046 - -/* TLS v1.2 ciphersuites */ -#define TLS1_CK_DHE_RSA_WITH_AES_128_SHA256 0x03000067 -#define TLS1_CK_DH_DSS_WITH_AES_256_SHA256 0x03000068 -#define TLS1_CK_DH_RSA_WITH_AES_256_SHA256 0x03000069 -#define TLS1_CK_DHE_DSS_WITH_AES_256_SHA256 0x0300006A -#define TLS1_CK_DHE_RSA_WITH_AES_256_SHA256 0x0300006B -#define TLS1_CK_ADH_WITH_AES_128_SHA256 0x0300006C -#define TLS1_CK_ADH_WITH_AES_256_SHA256 0x0300006D - -/* Camellia ciphersuites from RFC4132 */ -#define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000084 -#define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000085 -#define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000086 -#define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000087 -#define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000088 -#define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA 0x03000089 - -/* SEED ciphersuites from RFC4162 */ -#define TLS1_CK_RSA_WITH_SEED_SHA 0x03000096 -#define TLS1_CK_DH_DSS_WITH_SEED_SHA 0x03000097 -#define TLS1_CK_DH_RSA_WITH_SEED_SHA 0x03000098 -#define TLS1_CK_DHE_DSS_WITH_SEED_SHA 0x03000099 -#define TLS1_CK_DHE_RSA_WITH_SEED_SHA 0x0300009A -#define TLS1_CK_ADH_WITH_SEED_SHA 0x0300009B - -/* TLS v1.2 GCM ciphersuites from RFC5288 */ -#define TLS1_CK_RSA_WITH_AES_128_GCM_SHA256 0x0300009C -#define TLS1_CK_RSA_WITH_AES_256_GCM_SHA384 0x0300009D -#define TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256 0x0300009E -#define TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384 0x0300009F -#define TLS1_CK_DH_RSA_WITH_AES_128_GCM_SHA256 0x030000A0 -#define TLS1_CK_DH_RSA_WITH_AES_256_GCM_SHA384 0x030000A1 -#define TLS1_CK_DHE_DSS_WITH_AES_128_GCM_SHA256 0x030000A2 -#define TLS1_CK_DHE_DSS_WITH_AES_256_GCM_SHA384 0x030000A3 -#define TLS1_CK_DH_DSS_WITH_AES_128_GCM_SHA256 0x030000A4 -#define TLS1_CK_DH_DSS_WITH_AES_256_GCM_SHA384 0x030000A5 -#define TLS1_CK_ADH_WITH_AES_128_GCM_SHA256 0x030000A6 -#define TLS1_CK_ADH_WITH_AES_256_GCM_SHA384 0x030000A7 - -/* ECC ciphersuites from RFC4492 */ -#define TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA 0x0300C001 -#define TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA 0x0300C002 -#define TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C003 -#define TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA 0x0300C004 -#define TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA 0x0300C005 - -#define TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA 0x0300C006 -#define TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA 0x0300C007 -#define TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C008 -#define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA 0x0300C009 -#define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA 0x0300C00A - -#define TLS1_CK_ECDH_RSA_WITH_NULL_SHA 0x0300C00B -#define TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA 0x0300C00C -#define TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA 0x0300C00D -#define TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA 0x0300C00E -#define TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA 0x0300C00F - -#define TLS1_CK_ECDHE_RSA_WITH_NULL_SHA 0x0300C010 -#define TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA 0x0300C011 -#define TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA 0x0300C012 -#define TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA 0x0300C013 -#define TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA 0x0300C014 - -#define TLS1_CK_ECDH_anon_WITH_NULL_SHA 0x0300C015 -#define TLS1_CK_ECDH_anon_WITH_RC4_128_SHA 0x0300C016 -#define TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA 0x0300C017 -#define TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA 0x0300C018 -#define TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA 0x0300C019 - -/* SRP ciphersuites from RFC 5054 */ -#define TLS1_CK_SRP_SHA_WITH_3DES_EDE_CBC_SHA 0x0300C01A -#define TLS1_CK_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA 0x0300C01B -#define TLS1_CK_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA 0x0300C01C -#define TLS1_CK_SRP_SHA_WITH_AES_128_CBC_SHA 0x0300C01D -#define TLS1_CK_SRP_SHA_RSA_WITH_AES_128_CBC_SHA 0x0300C01E -#define TLS1_CK_SRP_SHA_DSS_WITH_AES_128_CBC_SHA 0x0300C01F -#define TLS1_CK_SRP_SHA_WITH_AES_256_CBC_SHA 0x0300C020 -#define TLS1_CK_SRP_SHA_RSA_WITH_AES_256_CBC_SHA 0x0300C021 -#define TLS1_CK_SRP_SHA_DSS_WITH_AES_256_CBC_SHA 0x0300C022 - -/* ECDH HMAC based ciphersuites from RFC5289 */ - -#define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256 0x0300C023 -#define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384 0x0300C024 -#define TLS1_CK_ECDH_ECDSA_WITH_AES_128_SHA256 0x0300C025 -#define TLS1_CK_ECDH_ECDSA_WITH_AES_256_SHA384 0x0300C026 -#define TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256 0x0300C027 -#define TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384 0x0300C028 -#define TLS1_CK_ECDH_RSA_WITH_AES_128_SHA256 0x0300C029 -#define TLS1_CK_ECDH_RSA_WITH_AES_256_SHA384 0x0300C02A - -/* ECDH GCM based ciphersuites from RFC5289 */ -#define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 0x0300C02B -#define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 0x0300C02C -#define TLS1_CK_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 0x0300C02D -#define TLS1_CK_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 0x0300C02E -#define TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256 0x0300C02F -#define TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384 0x0300C030 -#define TLS1_CK_ECDH_RSA_WITH_AES_128_GCM_SHA256 0x0300C031 -#define TLS1_CK_ECDH_RSA_WITH_AES_256_GCM_SHA384 0x0300C032 - -#define TLS1_CK_ECDHE_RSA_CHACHA20_POLY1305 0x0300CC13 -#define TLS1_CK_ECDHE_ECDSA_CHACHA20_POLY1305 0x0300CC14 -#define TLS1_CK_DHE_RSA_CHACHA20_POLY1305 0x0300CC15 - -/* XXX - * Inconsistency alert: - * The OpenSSL names of ciphers with ephemeral DH here include the string - * "DHE", while elsewhere it has always been "EDH". - * (The alias for the list of all such ciphers also is "EDH".) - * The specifications speak of "EDH"; maybe we should allow both forms - * for everything. */ -#define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5 "EXP1024-RC4-MD5" -#define TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 "EXP1024-RC2-CBC-MD5" -#define TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA "EXP1024-DES-CBC-SHA" -#define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA \ - "EXP1024-DHE-DSS-DES-CBC-SHA" -#define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA "EXP1024-RC4-SHA" -#define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA "EXP1024-DHE-DSS-RC4-SHA" -#define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA "DHE-DSS-RC4-SHA" - -/* AES ciphersuites from RFC3268 */ -#define TLS1_TXT_RSA_WITH_AES_128_SHA "AES128-SHA" -#define TLS1_TXT_DH_DSS_WITH_AES_128_SHA "DH-DSS-AES128-SHA" -#define TLS1_TXT_DH_RSA_WITH_AES_128_SHA "DH-RSA-AES128-SHA" -#define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA "DHE-DSS-AES128-SHA" -#define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA "DHE-RSA-AES128-SHA" -#define TLS1_TXT_ADH_WITH_AES_128_SHA "ADH-AES128-SHA" - -#define TLS1_TXT_RSA_WITH_AES_256_SHA "AES256-SHA" -#define TLS1_TXT_DH_DSS_WITH_AES_256_SHA "DH-DSS-AES256-SHA" -#define TLS1_TXT_DH_RSA_WITH_AES_256_SHA "DH-RSA-AES256-SHA" -#define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA "DHE-DSS-AES256-SHA" -#define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA "DHE-RSA-AES256-SHA" -#define TLS1_TXT_ADH_WITH_AES_256_SHA "ADH-AES256-SHA" - -/* ECC ciphersuites from RFC4492 */ -#define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA "ECDH-ECDSA-NULL-SHA" -#define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA "ECDH-ECDSA-RC4-SHA" -#define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA "ECDH-ECDSA-DES-CBC3-SHA" -#define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA "ECDH-ECDSA-AES128-SHA" -#define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA "ECDH-ECDSA-AES256-SHA" - -#define TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA "ECDHE-ECDSA-NULL-SHA" -#define TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA "ECDHE-ECDSA-RC4-SHA" -#define TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA "ECDHE-ECDSA-DES-CBC3-SHA" -#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA "ECDHE-ECDSA-AES128-SHA" -#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA "ECDHE-ECDSA-AES256-SHA" - -#define TLS1_TXT_ECDH_RSA_WITH_NULL_SHA "ECDH-RSA-NULL-SHA" -#define TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA "ECDH-RSA-RC4-SHA" -#define TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA "ECDH-RSA-DES-CBC3-SHA" -#define TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA "ECDH-RSA-AES128-SHA" -#define TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA "ECDH-RSA-AES256-SHA" - -#define TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA "ECDHE-RSA-NULL-SHA" -#define TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA "ECDHE-RSA-RC4-SHA" -#define TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA "ECDHE-RSA-DES-CBC3-SHA" -#define TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA "ECDHE-RSA-AES128-SHA" -#define TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA "ECDHE-RSA-AES256-SHA" - -#define TLS1_TXT_ECDH_anon_WITH_NULL_SHA "AECDH-NULL-SHA" -#define TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA "AECDH-RC4-SHA" -#define TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA "AECDH-DES-CBC3-SHA" -#define TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA "AECDH-AES128-SHA" -#define TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA "AECDH-AES256-SHA" - -/* PSK ciphersuites from RFC 4279 */ -#define TLS1_TXT_PSK_WITH_RC4_128_SHA "PSK-RC4-SHA" -#define TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA "PSK-3DES-EDE-CBC-SHA" -#define TLS1_TXT_PSK_WITH_AES_128_CBC_SHA "PSK-AES128-CBC-SHA" -#define TLS1_TXT_PSK_WITH_AES_256_CBC_SHA "PSK-AES256-CBC-SHA" - -/* PSK ciphersuites from RFC 5489 */ -#define TLS1_TXT_ECDHE_PSK_WITH_AES_128_CBC_SHA "ECDHE-PSK-AES128-CBC-SHA" -#define TLS1_TXT_ECDHE_PSK_WITH_AES_256_CBC_SHA "ECDHE-PSK-AES256-CBC-SHA" - -/* SRP ciphersuite from RFC 5054 */ -#define TLS1_TXT_SRP_SHA_WITH_3DES_EDE_CBC_SHA "SRP-3DES-EDE-CBC-SHA" -#define TLS1_TXT_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA "SRP-RSA-3DES-EDE-CBC-SHA" -#define TLS1_TXT_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA "SRP-DSS-3DES-EDE-CBC-SHA" -#define TLS1_TXT_SRP_SHA_WITH_AES_128_CBC_SHA "SRP-AES-128-CBC-SHA" -#define TLS1_TXT_SRP_SHA_RSA_WITH_AES_128_CBC_SHA "SRP-RSA-AES-128-CBC-SHA" -#define TLS1_TXT_SRP_SHA_DSS_WITH_AES_128_CBC_SHA "SRP-DSS-AES-128-CBC-SHA" -#define TLS1_TXT_SRP_SHA_WITH_AES_256_CBC_SHA "SRP-AES-256-CBC-SHA" -#define TLS1_TXT_SRP_SHA_RSA_WITH_AES_256_CBC_SHA "SRP-RSA-AES-256-CBC-SHA" -#define TLS1_TXT_SRP_SHA_DSS_WITH_AES_256_CBC_SHA "SRP-DSS-AES-256-CBC-SHA" - -/* Camellia ciphersuites from RFC4132 */ -#define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA "CAMELLIA128-SHA" -#define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA "DH-DSS-CAMELLIA128-SHA" -#define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA "DH-RSA-CAMELLIA128-SHA" -#define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA "DHE-DSS-CAMELLIA128-SHA" -#define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA "DHE-RSA-CAMELLIA128-SHA" -#define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA "ADH-CAMELLIA128-SHA" - -#define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA "CAMELLIA256-SHA" -#define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA "DH-DSS-CAMELLIA256-SHA" -#define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA "DH-RSA-CAMELLIA256-SHA" -#define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA "DHE-DSS-CAMELLIA256-SHA" -#define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA "DHE-RSA-CAMELLIA256-SHA" -#define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA "ADH-CAMELLIA256-SHA" - -/* SEED ciphersuites from RFC4162 */ -#define TLS1_TXT_RSA_WITH_SEED_SHA "SEED-SHA" -#define TLS1_TXT_DH_DSS_WITH_SEED_SHA "DH-DSS-SEED-SHA" -#define TLS1_TXT_DH_RSA_WITH_SEED_SHA "DH-RSA-SEED-SHA" -#define TLS1_TXT_DHE_DSS_WITH_SEED_SHA "DHE-DSS-SEED-SHA" -#define TLS1_TXT_DHE_RSA_WITH_SEED_SHA "DHE-RSA-SEED-SHA" -#define TLS1_TXT_ADH_WITH_SEED_SHA "ADH-SEED-SHA" - -/* TLS v1.2 ciphersuites */ -#define TLS1_TXT_RSA_WITH_NULL_SHA256 "NULL-SHA256" -#define TLS1_TXT_RSA_WITH_AES_128_SHA256 "AES128-SHA256" -#define TLS1_TXT_RSA_WITH_AES_256_SHA256 "AES256-SHA256" -#define TLS1_TXT_DH_DSS_WITH_AES_128_SHA256 "DH-DSS-AES128-SHA256" -#define TLS1_TXT_DH_RSA_WITH_AES_128_SHA256 "DH-RSA-AES128-SHA256" -#define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256 "DHE-DSS-AES128-SHA256" -#define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256 "DHE-RSA-AES128-SHA256" -#define TLS1_TXT_DH_DSS_WITH_AES_256_SHA256 "DH-DSS-AES256-SHA256" -#define TLS1_TXT_DH_RSA_WITH_AES_256_SHA256 "DH-RSA-AES256-SHA256" -#define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256 "DHE-DSS-AES256-SHA256" -#define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256 "DHE-RSA-AES256-SHA256" -#define TLS1_TXT_ADH_WITH_AES_128_SHA256 "ADH-AES128-SHA256" -#define TLS1_TXT_ADH_WITH_AES_256_SHA256 "ADH-AES256-SHA256" - -/* TLS v1.2 GCM ciphersuites from RFC5288 */ -#define TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256 "AES128-GCM-SHA256" -#define TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384 "AES256-GCM-SHA384" -#define TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256 "DHE-RSA-AES128-GCM-SHA256" -#define TLS1_TXT_DHE_RSA_WITH_AES_256_GCM_SHA384 "DHE-RSA-AES256-GCM-SHA384" -#define TLS1_TXT_DH_RSA_WITH_AES_128_GCM_SHA256 "DH-RSA-AES128-GCM-SHA256" -#define TLS1_TXT_DH_RSA_WITH_AES_256_GCM_SHA384 "DH-RSA-AES256-GCM-SHA384" -#define TLS1_TXT_DHE_DSS_WITH_AES_128_GCM_SHA256 "DHE-DSS-AES128-GCM-SHA256" -#define TLS1_TXT_DHE_DSS_WITH_AES_256_GCM_SHA384 "DHE-DSS-AES256-GCM-SHA384" -#define TLS1_TXT_DH_DSS_WITH_AES_128_GCM_SHA256 "DH-DSS-AES128-GCM-SHA256" -#define TLS1_TXT_DH_DSS_WITH_AES_256_GCM_SHA384 "DH-DSS-AES256-GCM-SHA384" -#define TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256 "ADH-AES128-GCM-SHA256" -#define TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384 "ADH-AES256-GCM-SHA384" - -/* ECDH HMAC based ciphersuites from RFC5289 */ - -#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256 "ECDHE-ECDSA-AES128-SHA256" -#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384 "ECDHE-ECDSA-AES256-SHA384" -#define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_SHA256 "ECDH-ECDSA-AES128-SHA256" -#define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_SHA384 "ECDH-ECDSA-AES256-SHA384" -#define TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256 "ECDHE-RSA-AES128-SHA256" -#define TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384 "ECDHE-RSA-AES256-SHA384" -#define TLS1_TXT_ECDH_RSA_WITH_AES_128_SHA256 "ECDH-RSA-AES128-SHA256" -#define TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384 "ECDH-RSA-AES256-SHA384" - -/* ECDH GCM based ciphersuites from RFC5289 */ -#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 \ - "ECDHE-ECDSA-AES128-GCM-SHA256" -#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 \ - "ECDHE-ECDSA-AES256-GCM-SHA384" -#define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 \ - "ECDH-ECDSA-AES128-GCM-SHA256" -#define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 \ - "ECDH-ECDSA-AES256-GCM-SHA384" -#define TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256 "ECDHE-RSA-AES128-GCM-SHA256" -#define TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384 "ECDHE-RSA-AES256-GCM-SHA384" -#define TLS1_TXT_ECDH_RSA_WITH_AES_128_GCM_SHA256 "ECDH-RSA-AES128-GCM-SHA256" -#define TLS1_TXT_ECDH_RSA_WITH_AES_256_GCM_SHA384 "ECDH-RSA-AES256-GCM-SHA384" - -#define TLS1_TXT_ECDHE_RSA_WITH_CHACHA20_POLY1305 "ECDHE-RSA-CHACHA20-POLY1305" -#define TLS1_TXT_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 \ - "ECDHE-ECDSA-CHACHA20-POLY1305" -#define TLS1_TXT_DHE_RSA_WITH_CHACHA20_POLY1305 "DHE-RSA-CHACHA20-POLY1305" - -#define TLS_CT_RSA_SIGN 1 -#define TLS_CT_DSS_SIGN 2 -#define TLS_CT_RSA_FIXED_DH 3 -#define TLS_CT_DSS_FIXED_DH 4 -#define TLS_CT_ECDSA_SIGN 64 -#define TLS_CT_RSA_FIXED_ECDH 65 -#define TLS_CT_ECDSA_FIXED_ECDH 66 - -#define TLS_MD_MAX_CONST_SIZE 20 -#define TLS_MD_CLIENT_FINISH_CONST "client finished" -#define TLS_MD_CLIENT_FINISH_CONST_SIZE 15 -#define TLS_MD_SERVER_FINISH_CONST "server finished" -#define TLS_MD_SERVER_FINISH_CONST_SIZE 15 -#define TLS_MD_KEY_EXPANSION_CONST "key expansion" -#define TLS_MD_KEY_EXPANSION_CONST_SIZE 13 -#define TLS_MD_CLIENT_WRITE_KEY_CONST "client write key" -#define TLS_MD_CLIENT_WRITE_KEY_CONST_SIZE 16 -#define TLS_MD_SERVER_WRITE_KEY_CONST "server write key" -#define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16 -#define TLS_MD_IV_BLOCK_CONST "IV block" -#define TLS_MD_IV_BLOCK_CONST_SIZE 8 -#define TLS_MD_MASTER_SECRET_CONST "master secret" -#define TLS_MD_MASTER_SECRET_CONST_SIZE 13 -#define TLS_MD_EXTENDED_MASTER_SECRET_CONST "extended master secret" -#define TLS_MD_EXTENDED_MASTER_SECRET_CONST_SIZE 22 - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/phonelibs/boringssl/include/openssl/type_check.h b/phonelibs/boringssl/include/openssl/type_check.h deleted file mode 100644 index 674913a354a04c..00000000000000 --- a/phonelibs/boringssl/include/openssl/type_check.h +++ /dev/null @@ -1,91 +0,0 @@ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] */ - -#ifndef OPENSSL_HEADER_TYPE_CHECK_H -#define OPENSSL_HEADER_TYPE_CHECK_H - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -/* This header file contains some common macros for enforcing type checking. - * Several, common OpenSSL structures (i.e. stack and lhash) operate on void - * pointers, but we wish to have type checking when they are used with a - * specific type. */ - -/* CHECKED_CAST casts |p| from type |from| to type |to|. */ -#define CHECKED_CAST(to, from, p) ((to) (1 ? (p) : (from)0)) - -/* CHECKED_PTR_OF casts a given pointer to void* and statically checks that it - * was a pointer to |type|. */ -#define CHECKED_PTR_OF(type, p) CHECKED_CAST(void*, type*, (p)) - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L -#define OPENSSL_COMPILE_ASSERT(cond, msg) _Static_assert(cond, #msg) -#else -#define OPENSSL_COMPILE_ASSERT(cond, msg) \ - typedef char OPENSSL_COMPILE_ASSERT_##msg[((cond) ? 1 : -1)] -#endif - - -#if defined(__cplusplus) -} /* extern C */ -#endif - -#endif /* OPENSSL_HEADER_TYPE_CHECK_H */ diff --git a/phonelibs/boringssl/include/openssl/x509.h b/phonelibs/boringssl/include/openssl/x509.h deleted file mode 100644 index 69c7da64e840d7..00000000000000 --- a/phonelibs/boringssl/include/openssl/x509.h +++ /dev/null @@ -1,1317 +0,0 @@ -/* crypto/x509/x509.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * ECDH support in OpenSSL originally developed by - * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. - */ - -#ifndef HEADER_X509_H -#define HEADER_X509_H - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -#define X509_FILETYPE_PEM 1 -#define X509_FILETYPE_ASN1 2 -#define X509_FILETYPE_DEFAULT 3 - -#define X509v3_KU_DIGITAL_SIGNATURE 0x0080 -#define X509v3_KU_NON_REPUDIATION 0x0040 -#define X509v3_KU_KEY_ENCIPHERMENT 0x0020 -#define X509v3_KU_DATA_ENCIPHERMENT 0x0010 -#define X509v3_KU_KEY_AGREEMENT 0x0008 -#define X509v3_KU_KEY_CERT_SIGN 0x0004 -#define X509v3_KU_CRL_SIGN 0x0002 -#define X509v3_KU_ENCIPHER_ONLY 0x0001 -#define X509v3_KU_DECIPHER_ONLY 0x8000 -#define X509v3_KU_UNDEF 0xffff - -typedef struct X509_objects_st - { - int nid; - int (*a2i)(void); - int (*i2a)(void); - } X509_OBJECTS; - -DECLARE_ASN1_SET_OF(X509_ALGOR) - -typedef STACK_OF(X509_ALGOR) X509_ALGORS; - -typedef struct X509_val_st - { - ASN1_TIME *notBefore; - ASN1_TIME *notAfter; - } X509_VAL; - -struct X509_pubkey_st - { - X509_ALGOR *algor; - ASN1_BIT_STRING *public_key; - EVP_PKEY *pkey; - }; - -typedef struct X509_sig_st - { - X509_ALGOR *algor; - ASN1_OCTET_STRING *digest; - } X509_SIG; - -typedef struct X509_name_entry_st - { - ASN1_OBJECT *object; - ASN1_STRING *value; - int set; - int size; /* temp variable */ - } X509_NAME_ENTRY; - -DECLARE_STACK_OF(X509_NAME_ENTRY) -DECLARE_ASN1_SET_OF(X509_NAME_ENTRY) - -/* we always keep X509_NAMEs in 2 forms. */ -typedef struct X509_name_st - { - STACK_OF(X509_NAME_ENTRY) *entries; - int modified; /* true if 'bytes' needs to be built */ -#ifndef OPENSSL_NO_BUFFER - BUF_MEM *bytes; -#else - char *bytes; -#endif -/* unsigned long hash; Keep the hash around for lookups */ - unsigned char *canon_enc; - int canon_enclen; - } X509_NAME; - -DECLARE_STACK_OF(X509_NAME) - -#define X509_EX_V_NETSCAPE_HACK 0x8000 -#define X509_EX_V_INIT 0x0001 -typedef struct X509_extension_st - { - ASN1_OBJECT *object; - ASN1_BOOLEAN critical; - ASN1_OCTET_STRING *value; - } X509_EXTENSION; - -typedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS; - -DECLARE_STACK_OF(X509_EXTENSION) -DECLARE_ASN1_SET_OF(X509_EXTENSION) - -/* a sequence of these are used */ -typedef struct x509_attributes_st - { - ASN1_OBJECT *object; - int single; /* 0 for a set, 1 for a single item (which is wrong) */ - union { - char *ptr; -/* 0 */ STACK_OF(ASN1_TYPE) *set; -/* 1 */ ASN1_TYPE *single; - } value; - } X509_ATTRIBUTE; - -DECLARE_STACK_OF(X509_ATTRIBUTE) -DECLARE_ASN1_SET_OF(X509_ATTRIBUTE) - - -typedef struct X509_req_info_st - { - ASN1_ENCODING enc; - ASN1_INTEGER *version; - X509_NAME *subject; - X509_PUBKEY *pubkey; - /* d=2 hl=2 l= 0 cons: cont: 00 */ - STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ - } X509_REQ_INFO; - -typedef struct X509_req_st - { - X509_REQ_INFO *req_info; - X509_ALGOR *sig_alg; - ASN1_BIT_STRING *signature; - CRYPTO_refcount_t references; - } X509_REQ; - -typedef struct x509_cinf_st - { - ASN1_INTEGER *version; /* [ 0 ] default of v1 */ - ASN1_INTEGER *serialNumber; - X509_ALGOR *signature; - X509_NAME *issuer; - X509_VAL *validity; - X509_NAME *subject; - X509_PUBKEY *key; - ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */ - ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */ - STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */ - ASN1_ENCODING enc; - } X509_CINF; - -/* This stuff is certificate "auxiliary info" - * it contains details which are useful in certificate - * stores and databases. When used this is tagged onto - * the end of the certificate itself - */ - -typedef struct x509_cert_aux_st - { - STACK_OF(ASN1_OBJECT) *trust; /* trusted uses */ - STACK_OF(ASN1_OBJECT) *reject; /* rejected uses */ - ASN1_UTF8STRING *alias; /* "friendly name" */ - ASN1_OCTET_STRING *keyid; /* key id of private key */ - STACK_OF(X509_ALGOR) *other; /* other unspecified info */ - } X509_CERT_AUX; - -struct x509_st - { - X509_CINF *cert_info; - X509_ALGOR *sig_alg; - ASN1_BIT_STRING *signature; - int valid; - CRYPTO_refcount_t references; - char *name; - CRYPTO_EX_DATA ex_data; - /* These contain copies of various extension values */ - long ex_pathlen; - long ex_pcpathlen; - unsigned long ex_flags; - unsigned long ex_kusage; - unsigned long ex_xkusage; - unsigned long ex_nscert; - ASN1_OCTET_STRING *skid; - AUTHORITY_KEYID *akid; - X509_POLICY_CACHE *policy_cache; - STACK_OF(DIST_POINT) *crldp; - STACK_OF(GENERAL_NAME) *altname; - NAME_CONSTRAINTS *nc; - unsigned char sha1_hash[SHA_DIGEST_LENGTH]; - X509_CERT_AUX *aux; - } /* X509 */; - -DECLARE_STACK_OF(X509) -DECLARE_ASN1_SET_OF(X509) - -/* This is used for a table of trust checking functions */ - -typedef struct x509_trust_st { - int trust; - int flags; - int (*check_trust)(struct x509_trust_st *, X509 *, int); - char *name; - int arg1; - void *arg2; -} X509_TRUST; - -DECLARE_STACK_OF(X509_TRUST) - -typedef struct x509_cert_pair_st { - X509 *forward; - X509 *reverse; -} X509_CERT_PAIR; - -/* standard trust ids */ - -#define X509_TRUST_DEFAULT -1 /* Only valid in purpose settings */ - -#define X509_TRUST_COMPAT 1 -#define X509_TRUST_SSL_CLIENT 2 -#define X509_TRUST_SSL_SERVER 3 -#define X509_TRUST_EMAIL 4 -#define X509_TRUST_OBJECT_SIGN 5 -#define X509_TRUST_OCSP_SIGN 6 -#define X509_TRUST_OCSP_REQUEST 7 -#define X509_TRUST_TSA 8 - -/* Keep these up to date! */ -#define X509_TRUST_MIN 1 -#define X509_TRUST_MAX 8 - - -/* trust_flags values */ -#define X509_TRUST_DYNAMIC 1 -#define X509_TRUST_DYNAMIC_NAME 2 - -/* check_trust return codes */ - -#define X509_TRUST_TRUSTED 1 -#define X509_TRUST_REJECTED 2 -#define X509_TRUST_UNTRUSTED 3 - -/* Flags for X509_print_ex() */ - -#define X509_FLAG_COMPAT 0 -#define X509_FLAG_NO_HEADER 1L -#define X509_FLAG_NO_VERSION (1L << 1) -#define X509_FLAG_NO_SERIAL (1L << 2) -#define X509_FLAG_NO_SIGNAME (1L << 3) -#define X509_FLAG_NO_ISSUER (1L << 4) -#define X509_FLAG_NO_VALIDITY (1L << 5) -#define X509_FLAG_NO_SUBJECT (1L << 6) -#define X509_FLAG_NO_PUBKEY (1L << 7) -#define X509_FLAG_NO_EXTENSIONS (1L << 8) -#define X509_FLAG_NO_SIGDUMP (1L << 9) -#define X509_FLAG_NO_AUX (1L << 10) -#define X509_FLAG_NO_ATTRIBUTES (1L << 11) -#define X509_FLAG_NO_IDS (1L << 12) - -/* Flags specific to X509_NAME_print_ex() */ - -/* The field separator information */ - -#define XN_FLAG_SEP_MASK (0xf << 16) - -#define XN_FLAG_COMPAT 0 /* Traditional SSLeay: use old X509_NAME_print */ -#define XN_FLAG_SEP_COMMA_PLUS (1 << 16) /* RFC2253 ,+ */ -#define XN_FLAG_SEP_CPLUS_SPC (2 << 16) /* ,+ spaced: more readable */ -#define XN_FLAG_SEP_SPLUS_SPC (3 << 16) /* ;+ spaced */ -#define XN_FLAG_SEP_MULTILINE (4 << 16) /* One line per field */ - -#define XN_FLAG_DN_REV (1 << 20) /* Reverse DN order */ - -/* How the field name is shown */ - -#define XN_FLAG_FN_MASK (0x3 << 21) - -#define XN_FLAG_FN_SN 0 /* Object short name */ -#define XN_FLAG_FN_LN (1 << 21) /* Object long name */ -#define XN_FLAG_FN_OID (2 << 21) /* Always use OIDs */ -#define XN_FLAG_FN_NONE (3 << 21) /* No field names */ - -#define XN_FLAG_SPC_EQ (1 << 23) /* Put spaces round '=' */ - -/* This determines if we dump fields we don't recognise: - * RFC2253 requires this. - */ - -#define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24) - -#define XN_FLAG_FN_ALIGN (1 << 25) /* Align field names to 20 characters */ - -/* Complete set of RFC2253 flags */ - -#define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \ - XN_FLAG_SEP_COMMA_PLUS | \ - XN_FLAG_DN_REV | \ - XN_FLAG_FN_SN | \ - XN_FLAG_DUMP_UNKNOWN_FIELDS) - -/* readable oneline form */ - -#define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \ - ASN1_STRFLGS_ESC_QUOTE | \ - XN_FLAG_SEP_CPLUS_SPC | \ - XN_FLAG_SPC_EQ | \ - XN_FLAG_FN_SN) - -/* readable multiline form */ - -#define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \ - ASN1_STRFLGS_ESC_MSB | \ - XN_FLAG_SEP_MULTILINE | \ - XN_FLAG_SPC_EQ | \ - XN_FLAG_FN_LN | \ - XN_FLAG_FN_ALIGN) - -struct x509_revoked_st - { - ASN1_INTEGER *serialNumber; - ASN1_TIME *revocationDate; - STACK_OF(X509_EXTENSION) /* optional */ *extensions; - /* Set up if indirect CRL */ - STACK_OF(GENERAL_NAME) *issuer; - /* Revocation reason */ - int reason; - int sequence; /* load sequence */ - }; - -DECLARE_STACK_OF(X509_REVOKED) -DECLARE_ASN1_SET_OF(X509_REVOKED) - -typedef struct X509_crl_info_st - { - ASN1_INTEGER *version; - X509_ALGOR *sig_alg; - X509_NAME *issuer; - ASN1_TIME *lastUpdate; - ASN1_TIME *nextUpdate; - STACK_OF(X509_REVOKED) *revoked; - STACK_OF(X509_EXTENSION) /* [0] */ *extensions; - ASN1_ENCODING enc; - } X509_CRL_INFO; - -struct X509_crl_st - { - /* actual signature */ - X509_CRL_INFO *crl; - X509_ALGOR *sig_alg; - ASN1_BIT_STRING *signature; - CRYPTO_refcount_t references; - int flags; - /* Copies of various extensions */ - AUTHORITY_KEYID *akid; - ISSUING_DIST_POINT *idp; - /* Convenient breakdown of IDP */ - int idp_flags; - int idp_reasons; - /* CRL and base CRL numbers for delta processing */ - ASN1_INTEGER *crl_number; - ASN1_INTEGER *base_crl_number; - unsigned char sha1_hash[SHA_DIGEST_LENGTH]; - STACK_OF(GENERAL_NAMES) *issuers; - const X509_CRL_METHOD *meth; - void *meth_data; - } /* X509_CRL */; - -DECLARE_STACK_OF(X509_CRL) -DECLARE_ASN1_SET_OF(X509_CRL) - -typedef struct private_key_st - { - int version; - /* The PKCS#8 data types */ - X509_ALGOR *enc_algor; - ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */ - - /* When decrypted, the following will not be NULL */ - EVP_PKEY *dec_pkey; - - /* used to encrypt and decrypt */ - int key_length; - char *key_data; - int key_free; /* true if we should auto free key_data */ - - /* expanded version of 'enc_algor' */ - EVP_CIPHER_INFO cipher; - } X509_PKEY; - -#ifndef OPENSSL_NO_EVP -typedef struct X509_info_st - { - X509 *x509; - X509_CRL *crl; - X509_PKEY *x_pkey; - - EVP_CIPHER_INFO enc_cipher; - int enc_len; - char *enc_data; - - } X509_INFO; - -DECLARE_STACK_OF(X509_INFO) -#endif - -/* The next 2 structures and their 8 routines were sent to me by - * Pat Richard and are used to manipulate - * Netscapes spki structures - useful if you are writing a CA web page - */ -typedef struct Netscape_spkac_st - { - X509_PUBKEY *pubkey; - ASN1_IA5STRING *challenge; /* challenge sent in atlas >= PR2 */ - } NETSCAPE_SPKAC; - -typedef struct Netscape_spki_st - { - NETSCAPE_SPKAC *spkac; /* signed public key and challenge */ - X509_ALGOR *sig_algor; - ASN1_BIT_STRING *signature; - } NETSCAPE_SPKI; - -/* Netscape certificate sequence structure */ -typedef struct Netscape_certificate_sequence - { - ASN1_OBJECT *type; - STACK_OF(X509) *certs; - } NETSCAPE_CERT_SEQUENCE; - -/* Unused (and iv length is wrong) -typedef struct CBCParameter_st - { - unsigned char iv[8]; - } CBC_PARAM; -*/ - -/* Password based encryption structure */ - -typedef struct PBEPARAM_st { -ASN1_OCTET_STRING *salt; -ASN1_INTEGER *iter; -} PBEPARAM; - -/* Password based encryption V2 structures */ - -typedef struct PBE2PARAM_st { -X509_ALGOR *keyfunc; -X509_ALGOR *encryption; -} PBE2PARAM; - -typedef struct PBKDF2PARAM_st { -ASN1_TYPE *salt; /* Usually OCTET STRING but could be anything */ -ASN1_INTEGER *iter; -ASN1_INTEGER *keylength; -X509_ALGOR *prf; -} PBKDF2PARAM; - - -/* PKCS#8 private key info structure */ - -struct pkcs8_priv_key_info_st - { - int broken; /* Flag for various broken formats */ -#define PKCS8_OK 0 -#define PKCS8_NO_OCTET 1 -#define PKCS8_EMBEDDED_PARAM 2 -#define PKCS8_NS_DB 3 -#define PKCS8_NEG_PRIVKEY 4 - ASN1_INTEGER *version; - X509_ALGOR *pkeyalg; - ASN1_TYPE *pkey; /* Should be OCTET STRING but some are broken */ - STACK_OF(X509_ATTRIBUTE) *attributes; - }; - -#ifdef __cplusplus -} -#endif - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define X509_EXT_PACK_UNKNOWN 1 -#define X509_EXT_PACK_STRING 2 - -#define X509_get_version(x) ASN1_INTEGER_get((x)->cert_info->version) -/* #define X509_get_serialNumber(x) ((x)->cert_info->serialNumber) */ -#define X509_get_notBefore(x) ((x)->cert_info->validity->notBefore) -#define X509_get_notAfter(x) ((x)->cert_info->validity->notAfter) -#define X509_get_cert_info(x) ((x)->cert_info) -#define X509_extract_key(x) X509_get_pubkey(x) /*****/ -#define X509_REQ_get_version(x) ASN1_INTEGER_get((x)->req_info->version) -#define X509_REQ_get_subject_name(x) ((x)->req_info->subject) -#define X509_REQ_extract_key(a) X509_REQ_get_pubkey(a) -#define X509_name_cmp(a,b) X509_NAME_cmp((a),(b)) -#define X509_get_signature_type(x) EVP_PKEY_type(OBJ_obj2nid((x)->sig_alg->algorithm)) - -#define X509_CRL_get_version(x) ASN1_INTEGER_get((x)->crl->version) -#define X509_CRL_get_lastUpdate(x) ((x)->crl->lastUpdate) -#define X509_CRL_get_nextUpdate(x) ((x)->crl->nextUpdate) -#define X509_CRL_get_issuer(x) ((x)->crl->issuer) -#define X509_CRL_get_REVOKED(x) ((x)->crl->revoked) - -#define X509_CINF_set_modified(c) ((c)->enc.modified = 1) -#define X509_CINF_get_issuer(c) (&(c)->issuer) -#define X509_CINF_get_extensions(c) ((c)->extensions) -#define X509_CINF_get_signature(c) ((c)->signature) - -OPENSSL_EXPORT void X509_CRL_set_default_method(const X509_CRL_METHOD *meth); -OPENSSL_EXPORT X509_CRL_METHOD *X509_CRL_METHOD_new( - int (*crl_init)(X509_CRL *crl), - int (*crl_free)(X509_CRL *crl), - int (*crl_lookup)(X509_CRL *crl, X509_REVOKED **ret, - ASN1_INTEGER *ser, X509_NAME *issuer), - int (*crl_verify)(X509_CRL *crl, EVP_PKEY *pk)); -OPENSSL_EXPORT void X509_CRL_METHOD_free(X509_CRL_METHOD *m); - -OPENSSL_EXPORT void X509_CRL_set_meth_data(X509_CRL *crl, void *dat); -OPENSSL_EXPORT void *X509_CRL_get_meth_data(X509_CRL *crl); - -/* This one is only used so that a binary form can output, as in - * i2d_X509_NAME(X509_get_X509_PUBKEY(x),&buf) */ -#define X509_get_X509_PUBKEY(x) ((x)->cert_info->key) - - -OPENSSL_EXPORT const char *X509_verify_cert_error_string(long n); - -#ifndef OPENSSL_NO_EVP -OPENSSL_EXPORT int X509_verify(X509 *a, EVP_PKEY *r); - -OPENSSL_EXPORT int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r); -OPENSSL_EXPORT int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r); -OPENSSL_EXPORT int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r); - -OPENSSL_EXPORT NETSCAPE_SPKI * NETSCAPE_SPKI_b64_decode(const char *str, int len); -OPENSSL_EXPORT char * NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x); -OPENSSL_EXPORT EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x); -OPENSSL_EXPORT int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey); - -OPENSSL_EXPORT int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki); - -OPENSSL_EXPORT int X509_signature_dump(BIO *bp,const ASN1_STRING *sig, int indent); -OPENSSL_EXPORT int X509_signature_print(BIO *bp,X509_ALGOR *alg, ASN1_STRING *sig); - -OPENSSL_EXPORT int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); -OPENSSL_EXPORT int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx); -/* int X509_http_nbio(OCSP_REQ_CTX *rctx, X509 **pcert); */ -OPENSSL_EXPORT int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md); -OPENSSL_EXPORT int X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx); -OPENSSL_EXPORT int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md); -OPENSSL_EXPORT int X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx); -/* int X509_CRL_http_nbio(OCSP_REQ_CTX *rctx, X509_CRL **pcrl); */ -OPENSSL_EXPORT int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md); - -OPENSSL_EXPORT int X509_pubkey_digest(const X509 *data,const EVP_MD *type, - unsigned char *md, unsigned int *len); -OPENSSL_EXPORT int X509_digest(const X509 *data,const EVP_MD *type, - unsigned char *md, unsigned int *len); -OPENSSL_EXPORT int X509_CRL_digest(const X509_CRL *data,const EVP_MD *type, - unsigned char *md, unsigned int *len); -OPENSSL_EXPORT int X509_REQ_digest(const X509_REQ *data,const EVP_MD *type, - unsigned char *md, unsigned int *len); -OPENSSL_EXPORT int X509_NAME_digest(const X509_NAME *data,const EVP_MD *type, - unsigned char *md, unsigned int *len); -#endif - -#ifndef OPENSSL_NO_FP_API -OPENSSL_EXPORT X509 *d2i_X509_fp(FILE *fp, X509 **x509); -OPENSSL_EXPORT int i2d_X509_fp(FILE *fp,X509 *x509); -OPENSSL_EXPORT X509_CRL *d2i_X509_CRL_fp(FILE *fp,X509_CRL **crl); -OPENSSL_EXPORT int i2d_X509_CRL_fp(FILE *fp,X509_CRL *crl); -OPENSSL_EXPORT X509_REQ *d2i_X509_REQ_fp(FILE *fp,X509_REQ **req); -OPENSSL_EXPORT int i2d_X509_REQ_fp(FILE *fp,X509_REQ *req); -OPENSSL_EXPORT RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa); -OPENSSL_EXPORT int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa); -OPENSSL_EXPORT RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa); -OPENSSL_EXPORT int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa); -OPENSSL_EXPORT RSA *d2i_RSA_PUBKEY_fp(FILE *fp,RSA **rsa); -OPENSSL_EXPORT int i2d_RSA_PUBKEY_fp(FILE *fp,RSA *rsa); -#ifndef OPENSSL_NO_DSA -OPENSSL_EXPORT DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa); -OPENSSL_EXPORT int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa); -OPENSSL_EXPORT DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa); -OPENSSL_EXPORT int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa); -#endif -OPENSSL_EXPORT EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey); -OPENSSL_EXPORT int i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey); -OPENSSL_EXPORT EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey); -OPENSSL_EXPORT int i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey); -OPENSSL_EXPORT X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8); -OPENSSL_EXPORT int i2d_PKCS8_fp(FILE *fp,X509_SIG *p8); -OPENSSL_EXPORT PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, - PKCS8_PRIV_KEY_INFO **p8inf); -OPENSSL_EXPORT int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,PKCS8_PRIV_KEY_INFO *p8inf); -OPENSSL_EXPORT int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key); -OPENSSL_EXPORT int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey); -OPENSSL_EXPORT EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a); -OPENSSL_EXPORT int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey); -OPENSSL_EXPORT EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a); -#endif - -OPENSSL_EXPORT X509 *d2i_X509_bio(BIO *bp,X509 **x509); -OPENSSL_EXPORT int i2d_X509_bio(BIO *bp,X509 *x509); -OPENSSL_EXPORT X509_CRL *d2i_X509_CRL_bio(BIO *bp,X509_CRL **crl); -OPENSSL_EXPORT int i2d_X509_CRL_bio(BIO *bp,X509_CRL *crl); -OPENSSL_EXPORT X509_REQ *d2i_X509_REQ_bio(BIO *bp,X509_REQ **req); -OPENSSL_EXPORT int i2d_X509_REQ_bio(BIO *bp,X509_REQ *req); -OPENSSL_EXPORT RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa); -OPENSSL_EXPORT int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa); -OPENSSL_EXPORT RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa); -OPENSSL_EXPORT int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa); -OPENSSL_EXPORT RSA *d2i_RSA_PUBKEY_bio(BIO *bp,RSA **rsa); -OPENSSL_EXPORT int i2d_RSA_PUBKEY_bio(BIO *bp,RSA *rsa); -#ifndef OPENSSL_NO_DSA -OPENSSL_EXPORT DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa); -OPENSSL_EXPORT int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa); -OPENSSL_EXPORT DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa); -OPENSSL_EXPORT int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa); -#endif -OPENSSL_EXPORT EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey); -OPENSSL_EXPORT int i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey); -OPENSSL_EXPORT EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey); -OPENSSL_EXPORT int i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey); -OPENSSL_EXPORT X509_SIG *d2i_PKCS8_bio(BIO *bp,X509_SIG **p8); -OPENSSL_EXPORT int i2d_PKCS8_bio(BIO *bp,X509_SIG *p8); -OPENSSL_EXPORT PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, - PKCS8_PRIV_KEY_INFO **p8inf); -OPENSSL_EXPORT int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,PKCS8_PRIV_KEY_INFO *p8inf); -OPENSSL_EXPORT int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key); -OPENSSL_EXPORT int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey); -OPENSSL_EXPORT EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a); -OPENSSL_EXPORT int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey); -OPENSSL_EXPORT EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a); - -OPENSSL_EXPORT X509 *X509_dup(X509 *x509); -OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa); -OPENSSL_EXPORT X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex); -OPENSSL_EXPORT X509_CRL *X509_CRL_dup(X509_CRL *crl); -OPENSSL_EXPORT X509_REVOKED *X509_REVOKED_dup(X509_REVOKED *rev); -OPENSSL_EXPORT X509_REQ *X509_REQ_dup(X509_REQ *req); -OPENSSL_EXPORT X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn); -OPENSSL_EXPORT int X509_ALGOR_set0(X509_ALGOR *alg, const ASN1_OBJECT *aobj, int ptype, void *pval); -OPENSSL_EXPORT void X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, void **ppval, - X509_ALGOR *algor); -OPENSSL_EXPORT void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md); -OPENSSL_EXPORT int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b); - -OPENSSL_EXPORT X509_NAME *X509_NAME_dup(X509_NAME *xn); -OPENSSL_EXPORT X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne); - -OPENSSL_EXPORT int X509_cmp_time(const ASN1_TIME *s, time_t *t); -OPENSSL_EXPORT int X509_cmp_current_time(const ASN1_TIME *s); -OPENSSL_EXPORT ASN1_TIME * X509_time_adj(ASN1_TIME *s, long adj, time_t *t); -OPENSSL_EXPORT ASN1_TIME * X509_time_adj_ex(ASN1_TIME *s, int offset_day, long offset_sec, time_t *t); -OPENSSL_EXPORT ASN1_TIME * X509_gmtime_adj(ASN1_TIME *s, long adj); - -OPENSSL_EXPORT const char * X509_get_default_cert_area(void ); -OPENSSL_EXPORT const char * X509_get_default_cert_dir(void ); -OPENSSL_EXPORT const char * X509_get_default_cert_file(void ); -OPENSSL_EXPORT const char * X509_get_default_cert_dir_env(void ); -OPENSSL_EXPORT const char * X509_get_default_cert_file_env(void ); -OPENSSL_EXPORT const char * X509_get_default_private_dir(void ); - -OPENSSL_EXPORT X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); -OPENSSL_EXPORT X509 * X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey); - -DECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS) -DECLARE_ASN1_FUNCTIONS(X509_VAL) - -DECLARE_ASN1_FUNCTIONS(X509_PUBKEY) - -OPENSSL_EXPORT int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey); -OPENSSL_EXPORT EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key); -OPENSSL_EXPORT int i2d_PUBKEY(const EVP_PKEY *a,unsigned char **pp); -OPENSSL_EXPORT EVP_PKEY * d2i_PUBKEY(EVP_PKEY **a,const unsigned char **pp, - long length); -OPENSSL_EXPORT int i2d_RSA_PUBKEY(const RSA *a,unsigned char **pp); -OPENSSL_EXPORT RSA * d2i_RSA_PUBKEY(RSA **a,const unsigned char **pp, - long length); -#ifndef OPENSSL_NO_DSA -OPENSSL_EXPORT int i2d_DSA_PUBKEY(const DSA *a,unsigned char **pp); -OPENSSL_EXPORT DSA * d2i_DSA_PUBKEY(DSA **a,const unsigned char **pp, - long length); -#endif -OPENSSL_EXPORT int i2d_EC_PUBKEY(const EC_KEY *a, unsigned char **pp); -OPENSSL_EXPORT EC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, - long length); - -DECLARE_ASN1_FUNCTIONS(X509_SIG) -DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO) -DECLARE_ASN1_FUNCTIONS(X509_REQ) - -DECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE) -OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value); - -DECLARE_ASN1_FUNCTIONS(X509_EXTENSION) -DECLARE_ASN1_ENCODE_FUNCTIONS(X509_EXTENSIONS, X509_EXTENSIONS, X509_EXTENSIONS) - -DECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY) - -DECLARE_ASN1_FUNCTIONS(X509_NAME) - -OPENSSL_EXPORT int X509_NAME_set(X509_NAME **xn, X509_NAME *name); - -DECLARE_ASN1_FUNCTIONS(X509_CINF) - -DECLARE_ASN1_FUNCTIONS(X509) -DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX) - -DECLARE_ASN1_FUNCTIONS(X509_CERT_PAIR) - -/* X509_up_ref adds one to the reference count of |x| and returns - * |x|. */ -OPENSSL_EXPORT X509 *X509_up_ref(X509 *x); - -OPENSSL_EXPORT int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); -OPENSSL_EXPORT int X509_set_ex_data(X509 *r, int idx, void *arg); -OPENSSL_EXPORT void *X509_get_ex_data(X509 *r, int idx); -OPENSSL_EXPORT int i2d_X509_AUX(X509 *a,unsigned char **pp); -OPENSSL_EXPORT X509 * d2i_X509_AUX(X509 **a,const unsigned char **pp,long length); - -OPENSSL_EXPORT void X509_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg, - const X509 *x); -OPENSSL_EXPORT int X509_get_signature_nid(const X509 *x); - -OPENSSL_EXPORT int X509_alias_set1(X509 *x, unsigned char *name, int len); -OPENSSL_EXPORT int X509_keyid_set1(X509 *x, unsigned char *id, int len); -OPENSSL_EXPORT unsigned char * X509_alias_get0(X509 *x, int *len); -OPENSSL_EXPORT unsigned char * X509_keyid_get0(X509 *x, int *len); -OPENSSL_EXPORT int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int); -OPENSSL_EXPORT int X509_TRUST_set(int *t, int trust); -OPENSSL_EXPORT int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj); -OPENSSL_EXPORT int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj); -OPENSSL_EXPORT void X509_trust_clear(X509 *x); -OPENSSL_EXPORT void X509_reject_clear(X509 *x); - -DECLARE_ASN1_FUNCTIONS(X509_REVOKED) -DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO) -DECLARE_ASN1_FUNCTIONS(X509_CRL) - -OPENSSL_EXPORT int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev); -OPENSSL_EXPORT int X509_CRL_get0_by_serial(X509_CRL *crl, - X509_REVOKED **ret, ASN1_INTEGER *serial); -OPENSSL_EXPORT int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x); - -OPENSSL_EXPORT X509_PKEY * X509_PKEY_new(void ); -OPENSSL_EXPORT void X509_PKEY_free(X509_PKEY *a); - -DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI) -DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC) -DECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE) - -#ifndef OPENSSL_NO_EVP -OPENSSL_EXPORT X509_INFO * X509_INFO_new(void); -OPENSSL_EXPORT void X509_INFO_free(X509_INFO *a); -OPENSSL_EXPORT char * X509_NAME_oneline(X509_NAME *a,char *buf,int size); - -OPENSSL_EXPORT int ASN1_digest(i2d_of_void *i2d,const EVP_MD *type,char *data, - unsigned char *md,unsigned int *len); - -OPENSSL_EXPORT int ASN1_item_digest(const ASN1_ITEM *it,const EVP_MD *type,void *data, - unsigned char *md,unsigned int *len); - -OPENSSL_EXPORT int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1, - ASN1_BIT_STRING *signature,void *data,EVP_PKEY *pkey); - -OPENSSL_EXPORT int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, - ASN1_BIT_STRING *signature, - void *data, EVP_PKEY *pkey, const EVP_MD *type); -OPENSSL_EXPORT int ASN1_item_sign_ctx(const ASN1_ITEM *it, - X509_ALGOR *algor1, X509_ALGOR *algor2, - ASN1_BIT_STRING *signature, void *asn, EVP_MD_CTX *ctx); -#endif - -OPENSSL_EXPORT int X509_set_version(X509 *x,long version); -OPENSSL_EXPORT int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial); -OPENSSL_EXPORT ASN1_INTEGER * X509_get_serialNumber(X509 *x); -OPENSSL_EXPORT int X509_set_issuer_name(X509 *x, X509_NAME *name); -OPENSSL_EXPORT X509_NAME * X509_get_issuer_name(X509 *a); -OPENSSL_EXPORT int X509_set_subject_name(X509 *x, X509_NAME *name); -OPENSSL_EXPORT X509_NAME * X509_get_subject_name(X509 *a); -OPENSSL_EXPORT int X509_set_notBefore(X509 *x, const ASN1_TIME *tm); -OPENSSL_EXPORT int X509_set_notAfter(X509 *x, const ASN1_TIME *tm); -OPENSSL_EXPORT int X509_set_pubkey(X509 *x, EVP_PKEY *pkey); -OPENSSL_EXPORT EVP_PKEY * X509_get_pubkey(X509 *x); -OPENSSL_EXPORT ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x); -OPENSSL_EXPORT int X509_certificate_type(X509 *x,EVP_PKEY *pubkey /* optional */); - -OPENSSL_EXPORT int X509_REQ_set_version(X509_REQ *x,long version); -OPENSSL_EXPORT int X509_REQ_set_subject_name(X509_REQ *req,X509_NAME *name); -OPENSSL_EXPORT int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey); -OPENSSL_EXPORT EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req); -OPENSSL_EXPORT int X509_REQ_extension_nid(int nid); -OPENSSL_EXPORT const int * X509_REQ_get_extension_nids(void); -OPENSSL_EXPORT void X509_REQ_set_extension_nids(const int *nids); -OPENSSL_EXPORT STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req); -OPENSSL_EXPORT int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts, - int nid); -OPENSSL_EXPORT int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts); -OPENSSL_EXPORT int X509_REQ_get_attr_count(const X509_REQ *req); -OPENSSL_EXPORT int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, - int lastpos); -OPENSSL_EXPORT int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj, - int lastpos); -OPENSSL_EXPORT X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc); -OPENSSL_EXPORT X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc); -OPENSSL_EXPORT int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr); -OPENSSL_EXPORT int X509_REQ_add1_attr_by_OBJ(X509_REQ *req, - const ASN1_OBJECT *obj, int type, - const unsigned char *bytes, int len); -OPENSSL_EXPORT int X509_REQ_add1_attr_by_NID(X509_REQ *req, - int nid, int type, - const unsigned char *bytes, int len); -OPENSSL_EXPORT int X509_REQ_add1_attr_by_txt(X509_REQ *req, - const char *attrname, int type, - const unsigned char *bytes, int len); - -OPENSSL_EXPORT int X509_CRL_set_version(X509_CRL *x, long version); -OPENSSL_EXPORT int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name); -OPENSSL_EXPORT int X509_CRL_set_lastUpdate(X509_CRL *x, const ASN1_TIME *tm); -OPENSSL_EXPORT int X509_CRL_set_nextUpdate(X509_CRL *x, const ASN1_TIME *tm); -OPENSSL_EXPORT int X509_CRL_sort(X509_CRL *crl); - -OPENSSL_EXPORT int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial); -OPENSSL_EXPORT int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm); - -OPENSSL_EXPORT X509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer, - EVP_PKEY *skey, const EVP_MD *md, unsigned int flags); - -OPENSSL_EXPORT int X509_REQ_check_private_key(X509_REQ *x509,EVP_PKEY *pkey); - -OPENSSL_EXPORT int X509_check_private_key(X509 *x509,EVP_PKEY *pkey); -OPENSSL_EXPORT int X509_chain_check_suiteb(int *perror_depth, - X509 *x, STACK_OF(X509) *chain, - unsigned long flags); -OPENSSL_EXPORT int X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk, - unsigned long flags); -OPENSSL_EXPORT STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain); - -OPENSSL_EXPORT int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b); -OPENSSL_EXPORT unsigned long X509_issuer_and_serial_hash(X509 *a); - -OPENSSL_EXPORT int X509_issuer_name_cmp(const X509 *a, const X509 *b); -OPENSSL_EXPORT unsigned long X509_issuer_name_hash(X509 *a); - -OPENSSL_EXPORT int X509_subject_name_cmp(const X509 *a, const X509 *b); -OPENSSL_EXPORT unsigned long X509_subject_name_hash(X509 *x); - -OPENSSL_EXPORT unsigned long X509_issuer_name_hash_old(X509 *a); -OPENSSL_EXPORT unsigned long X509_subject_name_hash_old(X509 *x); - -OPENSSL_EXPORT int X509_cmp(const X509 *a, const X509 *b); -OPENSSL_EXPORT int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b); -OPENSSL_EXPORT unsigned long X509_NAME_hash(X509_NAME *x); -OPENSSL_EXPORT unsigned long X509_NAME_hash_old(X509_NAME *x); - -OPENSSL_EXPORT int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b); -OPENSSL_EXPORT int X509_CRL_match(const X509_CRL *a, const X509_CRL *b); -#ifndef OPENSSL_NO_FP_API -OPENSSL_EXPORT int X509_print_ex_fp(FILE *bp,X509 *x, unsigned long nmflag, unsigned long cflag); -OPENSSL_EXPORT int X509_print_fp(FILE *bp,X509 *x); -OPENSSL_EXPORT int X509_CRL_print_fp(FILE *bp,X509_CRL *x); -OPENSSL_EXPORT int X509_REQ_print_fp(FILE *bp,X509_REQ *req); -OPENSSL_EXPORT int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags); -#endif - -OPENSSL_EXPORT int X509_NAME_print(BIO *bp, X509_NAME *name, int obase); -OPENSSL_EXPORT int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags); -OPENSSL_EXPORT int X509_print_ex(BIO *bp,X509 *x, unsigned long nmflag, unsigned long cflag); -OPENSSL_EXPORT int X509_print(BIO *bp,X509 *x); -OPENSSL_EXPORT int X509_ocspid_print(BIO *bp,X509 *x); -OPENSSL_EXPORT int X509_CERT_AUX_print(BIO *bp,X509_CERT_AUX *x, int indent); -OPENSSL_EXPORT int X509_CRL_print(BIO *bp,X509_CRL *x); -OPENSSL_EXPORT int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, unsigned long cflag); -OPENSSL_EXPORT int X509_REQ_print(BIO *bp,X509_REQ *req); - -OPENSSL_EXPORT int X509_NAME_entry_count(X509_NAME *name); -OPENSSL_EXPORT int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, - char *buf,int len); -OPENSSL_EXPORT int X509_NAME_get_text_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, - char *buf,int len); - -/* NOTE: you should be passsing -1, not 0 as lastpos. The functions that use - * lastpos, search after that position on. */ -OPENSSL_EXPORT int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos); -OPENSSL_EXPORT int X509_NAME_get_index_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, - int lastpos); -OPENSSL_EXPORT X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc); -OPENSSL_EXPORT X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc); -OPENSSL_EXPORT int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne, - int loc, int set); -OPENSSL_EXPORT int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type, - unsigned char *bytes, int len, int loc, int set); -OPENSSL_EXPORT int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, - unsigned char *bytes, int len, int loc, int set); -OPENSSL_EXPORT X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, - const char *field, int type, const unsigned char *bytes, int len); -OPENSSL_EXPORT X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, - int type,unsigned char *bytes, int len); -OPENSSL_EXPORT int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, - const unsigned char *bytes, int len, int loc, int set); -OPENSSL_EXPORT X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, - const ASN1_OBJECT *obj, int type,const unsigned char *bytes, - int len); -OPENSSL_EXPORT int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, - const ASN1_OBJECT *obj); -OPENSSL_EXPORT int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, - const unsigned char *bytes, int len); -OPENSSL_EXPORT ASN1_OBJECT * X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne); -OPENSSL_EXPORT ASN1_STRING * X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne); - -OPENSSL_EXPORT int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x); -OPENSSL_EXPORT int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x, - int nid, int lastpos); -OPENSSL_EXPORT int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x, - const ASN1_OBJECT *obj,int lastpos); -OPENSSL_EXPORT int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x, - int crit, int lastpos); -OPENSSL_EXPORT X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc); -OPENSSL_EXPORT X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc); -OPENSSL_EXPORT STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, - X509_EXTENSION *ex, int loc); - -OPENSSL_EXPORT int X509_get_ext_count(X509 *x); -OPENSSL_EXPORT int X509_get_ext_by_NID(X509 *x, int nid, int lastpos); -OPENSSL_EXPORT int X509_get_ext_by_OBJ(X509 *x,ASN1_OBJECT *obj,int lastpos); -OPENSSL_EXPORT int X509_get_ext_by_critical(X509 *x, int crit, int lastpos); -OPENSSL_EXPORT X509_EXTENSION *X509_get_ext(X509 *x, int loc); -OPENSSL_EXPORT X509_EXTENSION *X509_delete_ext(X509 *x, int loc); -OPENSSL_EXPORT int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc); -OPENSSL_EXPORT void * X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx); -OPENSSL_EXPORT int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, - unsigned long flags); - -OPENSSL_EXPORT int X509_CRL_get_ext_count(X509_CRL *x); -OPENSSL_EXPORT int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos); -OPENSSL_EXPORT int X509_CRL_get_ext_by_OBJ(X509_CRL *x,ASN1_OBJECT *obj,int lastpos); -OPENSSL_EXPORT int X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos); -OPENSSL_EXPORT X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc); -OPENSSL_EXPORT X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc); -OPENSSL_EXPORT int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc); -OPENSSL_EXPORT void * X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx); -OPENSSL_EXPORT int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit, - unsigned long flags); - -OPENSSL_EXPORT int X509_REVOKED_get_ext_count(X509_REVOKED *x); -OPENSSL_EXPORT int X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos); -OPENSSL_EXPORT int X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x,ASN1_OBJECT *obj,int lastpos); -OPENSSL_EXPORT int X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos); -OPENSSL_EXPORT X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc); -OPENSSL_EXPORT X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc); -OPENSSL_EXPORT int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc); -OPENSSL_EXPORT void * X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx); -OPENSSL_EXPORT int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit, - unsigned long flags); - -OPENSSL_EXPORT X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, - int nid, int crit, ASN1_OCTET_STRING *data); -OPENSSL_EXPORT X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, - const ASN1_OBJECT *obj,int crit,ASN1_OCTET_STRING *data); -OPENSSL_EXPORT int X509_EXTENSION_set_object(X509_EXTENSION *ex,const ASN1_OBJECT *obj); -OPENSSL_EXPORT int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit); -OPENSSL_EXPORT int X509_EXTENSION_set_data(X509_EXTENSION *ex, - ASN1_OCTET_STRING *data); -OPENSSL_EXPORT ASN1_OBJECT * X509_EXTENSION_get_object(X509_EXTENSION *ex); -OPENSSL_EXPORT ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne); -OPENSSL_EXPORT int X509_EXTENSION_get_critical(X509_EXTENSION *ex); - -OPENSSL_EXPORT int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x); -OPENSSL_EXPORT int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid, - int lastpos); -OPENSSL_EXPORT int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, const ASN1_OBJECT *obj, - int lastpos); -OPENSSL_EXPORT X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc); -OPENSSL_EXPORT X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc); -OPENSSL_EXPORT STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x, - X509_ATTRIBUTE *attr); -OPENSSL_EXPORT STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x, - const ASN1_OBJECT *obj, int type, - const unsigned char *bytes, int len); -OPENSSL_EXPORT STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x, - int nid, int type, - const unsigned char *bytes, int len); -OPENSSL_EXPORT STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x, - const char *attrname, int type, - const unsigned char *bytes, int len); -OPENSSL_EXPORT void *X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x, - ASN1_OBJECT *obj, int lastpos, int type); -OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid, - int atrtype, const void *data, int len); -OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr, - const ASN1_OBJECT *obj, int atrtype, const void *data, int len); -OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr, - const char *atrname, int type, const unsigned char *bytes, int len); -OPENSSL_EXPORT int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj); -OPENSSL_EXPORT int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len); -OPENSSL_EXPORT void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, - int atrtype, void *data); -OPENSSL_EXPORT int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr); -OPENSSL_EXPORT ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr); -OPENSSL_EXPORT ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx); - -OPENSSL_EXPORT int EVP_PKEY_get_attr_count(const EVP_PKEY *key); -OPENSSL_EXPORT int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, - int lastpos); -OPENSSL_EXPORT int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, ASN1_OBJECT *obj, - int lastpos); -OPENSSL_EXPORT X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc); -OPENSSL_EXPORT X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc); -OPENSSL_EXPORT int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr); -OPENSSL_EXPORT int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key, - const ASN1_OBJECT *obj, int type, - const unsigned char *bytes, int len); -OPENSSL_EXPORT int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key, - int nid, int type, - const unsigned char *bytes, int len); -OPENSSL_EXPORT int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key, - const char *attrname, int type, - const unsigned char *bytes, int len); - -OPENSSL_EXPORT int X509_verify_cert(X509_STORE_CTX *ctx); - -/* lookup a cert from a X509 STACK */ -OPENSSL_EXPORT X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk,X509_NAME *name, - ASN1_INTEGER *serial); -OPENSSL_EXPORT X509 *X509_find_by_subject(STACK_OF(X509) *sk,X509_NAME *name); - -DECLARE_ASN1_FUNCTIONS(PBEPARAM) -DECLARE_ASN1_FUNCTIONS(PBE2PARAM) -DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM) - -OPENSSL_EXPORT int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter, - const unsigned char *salt, int saltlen); - -OPENSSL_EXPORT X509_ALGOR *PKCS5_pbe_set(int alg, int iter, - const unsigned char *salt, int saltlen); -OPENSSL_EXPORT X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, - unsigned char *salt, int saltlen); -OPENSSL_EXPORT X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter, - unsigned char *salt, int saltlen, - unsigned char *aiv, int prf_nid); - -OPENSSL_EXPORT X509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen, - int prf_nid, int keylen); - -/* PKCS#8 utilities */ - -DECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO) - -OPENSSL_EXPORT EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8); -OPENSSL_EXPORT PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey); -OPENSSL_EXPORT PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken); -OPENSSL_EXPORT PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken); - -OPENSSL_EXPORT int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj, - int version, int ptype, void *pval, - unsigned char *penc, int penclen); -OPENSSL_EXPORT int PKCS8_pkey_get0(ASN1_OBJECT **ppkalg, - const unsigned char **pk, int *ppklen, - X509_ALGOR **pa, - PKCS8_PRIV_KEY_INFO *p8); - -OPENSSL_EXPORT int X509_PUBKEY_set0_param(X509_PUBKEY *pub, const ASN1_OBJECT *aobj, - int ptype, void *pval, - unsigned char *penc, int penclen); -OPENSSL_EXPORT int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg, - const unsigned char **pk, int *ppklen, - X509_ALGOR **pa, - X509_PUBKEY *pub); - -OPENSSL_EXPORT int X509_check_trust(X509 *x, int id, int flags); -OPENSSL_EXPORT int X509_TRUST_get_count(void); -OPENSSL_EXPORT X509_TRUST * X509_TRUST_get0(int idx); -OPENSSL_EXPORT int X509_TRUST_get_by_id(int id); -OPENSSL_EXPORT int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int), - char *name, int arg1, void *arg2); -OPENSSL_EXPORT void X509_TRUST_cleanup(void); -OPENSSL_EXPORT int X509_TRUST_get_flags(X509_TRUST *xp); -OPENSSL_EXPORT char *X509_TRUST_get0_name(X509_TRUST *xp); -OPENSSL_EXPORT int X509_TRUST_get_trust(X509_TRUST *xp); - -/* PKCS7_get_certificates parses a PKCS#7, SignedData structure from |cbs| and - * appends the included certificates to |out_certs|. It returns one on success - * and zero on error. */ -OPENSSL_EXPORT int PKCS7_get_certificates(STACK_OF(X509) *out_certs, CBS *cbs); - -/* PKCS7_bundle_certificates appends a PKCS#7, SignedData structure containing - * |certs| to |out|. It returns one on success and zero on error. */ -OPENSSL_EXPORT int PKCS7_bundle_certificates( - CBB *out, const STACK_OF(X509) *certs); - -/* PKCS7_get_CRLs parses a PKCS#7, SignedData structure from |cbs| and appends - * the included CRLs to |out_crls|. It returns one on success and zero on - * error. */ -OPENSSL_EXPORT int PKCS7_get_CRLs(STACK_OF(X509_CRL) *out_crls, CBS *cbs); - -/* PKCS7_bundle_CRLs appends a PKCS#7, SignedData structure containing - * |crls| to |out|. It returns one on success and zero on error. */ -OPENSSL_EXPORT int PKCS7_bundle_CRLs(CBB *out, const STACK_OF(X509_CRL) *crls); - -/* PKCS7_get_PEM_certificates reads a PEM-encoded, PKCS#7, SignedData structure - * from |pem_bio| and appends the included certificates to |out_certs|. It - * returns one on success and zero on error. */ -OPENSSL_EXPORT int PKCS7_get_PEM_certificates(STACK_OF(X509) *out_certs, - BIO *pem_bio); - -/* PKCS7_get_PEM_CRLs reads a PEM-encoded, PKCS#7, SignedData structure from - * |pem_bio| and appends the included CRLs to |out_crls|. It returns one on - * success and zero on error. */ -OPENSSL_EXPORT int PKCS7_get_PEM_CRLs(STACK_OF(X509_CRL) *out_crls, - BIO *pem_bio); - -/* EVP_PK values indicate the algorithm of the public key in a certificate. */ - -#define EVP_PK_RSA 0x0001 -#define EVP_PK_DSA 0x0002 -#define EVP_PK_DH 0x0004 -#define EVP_PK_EC 0x0008 - -/* EVP_PKS values indicate the algorithm used to sign a certificate. */ - -#define EVP_PKS_RSA 0x0100 -#define EVP_PKS_DSA 0x0200 -#define EVP_PKS_EC 0x0400 - -/* EVP_PKT values are flags that define what public-key operations can be - * performed with the public key from a certificate. */ - -/* EVP_PKT_SIGN indicates that the public key can be used for signing. */ -#define EVP_PKT_SIGN 0x0010 -/* EVP_PKT_ENC indicates that a session key can be encrypted to the public - * key. */ -#define EVP_PKT_ENC 0x0020 -/* EVP_PKT_EXCH indicates that key-agreement can be performed. */ -#define EVP_PKT_EXCH 0x0040 -/* EVP_PKT_EXP indicates that key is weak (i.e. "export"). */ -#define EVP_PKT_EXP 0x1000 - - -#ifdef __cplusplus -} -#endif - -#define X509_F_ASN1_digest 100 -#define X509_F_ASN1_item_sign_ctx 101 -#define X509_F_ASN1_item_verify 102 -#define X509_F_NETSCAPE_SPKI_b64_decode 103 -#define X509_F_NETSCAPE_SPKI_b64_encode 104 -#define X509_F_PKCS7_get_certificates 105 -#define X509_F_X509_ATTRIBUTE_create_by_NID 106 -#define X509_F_X509_ATTRIBUTE_create_by_OBJ 107 -#define X509_F_X509_ATTRIBUTE_create_by_txt 108 -#define X509_F_X509_ATTRIBUTE_get0_data 109 -#define X509_F_X509_ATTRIBUTE_set1_data 110 -#define X509_F_X509_CRL_add0_revoked 111 -#define X509_F_X509_CRL_diff 112 -#define X509_F_X509_CRL_print_fp 113 -#define X509_F_X509_EXTENSION_create_by_NID 114 -#define X509_F_X509_EXTENSION_create_by_OBJ 115 -#define X509_F_X509_INFO_new 116 -#define X509_F_X509_NAME_ENTRY_create_by_NID 117 -#define X509_F_X509_NAME_ENTRY_create_by_txt 118 -#define X509_F_X509_NAME_ENTRY_set_object 119 -#define X509_F_X509_NAME_add_entry 120 -#define X509_F_X509_NAME_oneline 121 -#define X509_F_X509_NAME_print 122 -#define X509_F_X509_PKEY_new 123 -#define X509_F_X509_PUBKEY_get 124 -#define X509_F_X509_PUBKEY_set 125 -#define X509_F_X509_REQ_check_private_key 126 -#define X509_F_X509_REQ_to_X509 127 -#define X509_F_X509_STORE_CTX_get1_issuer 128 -#define X509_F_X509_STORE_CTX_init 129 -#define X509_F_X509_STORE_CTX_new 130 -#define X509_F_X509_STORE_CTX_purpose_inherit 131 -#define X509_F_X509_STORE_add_cert 132 -#define X509_F_X509_STORE_add_crl 133 -#define X509_F_X509_TRUST_add 134 -#define X509_F_X509_TRUST_set 135 -#define X509_F_X509_check_private_key 136 -#define X509_F_X509_get_pubkey_parameters 137 -#define X509_F_X509_load_cert_crl_file 138 -#define X509_F_X509_load_cert_file 139 -#define X509_F_X509_load_crl_file 140 -#define X509_F_X509_print_ex_fp 141 -#define X509_F_X509_to_X509_REQ 142 -#define X509_F_X509_verify_cert 143 -#define X509_F_X509at_add1_attr 144 -#define X509_F_X509v3_add_ext 145 -#define X509_F_add_cert_dir 146 -#define X509_F_by_file_ctrl 147 -#define X509_F_check_policy 148 -#define X509_F_dir_ctrl 149 -#define X509_F_get_cert_by_subject 150 -#define X509_F_i2d_DSA_PUBKEY 151 -#define X509_F_i2d_EC_PUBKEY 152 -#define X509_F_i2d_RSA_PUBKEY 153 -#define X509_F_x509_name_encode 154 -#define X509_F_x509_name_ex_d2i 155 -#define X509_F_x509_name_ex_new 156 -#define X509_F_pkcs7_parse_header 157 -#define X509_F_PKCS7_get_CRLs 158 -#define X509_R_AKID_MISMATCH 100 -#define X509_R_BAD_PKCS7_VERSION 101 -#define X509_R_BAD_X509_FILETYPE 102 -#define X509_R_BASE64_DECODE_ERROR 103 -#define X509_R_CANT_CHECK_DH_KEY 104 -#define X509_R_CERT_ALREADY_IN_HASH_TABLE 105 -#define X509_R_CRL_ALREADY_DELTA 106 -#define X509_R_CRL_VERIFY_FAILURE 107 -#define X509_R_IDP_MISMATCH 108 -#define X509_R_INVALID_BIT_STRING_BITS_LEFT 109 -#define X509_R_INVALID_DIRECTORY 110 -#define X509_R_INVALID_FIELD_NAME 111 -#define X509_R_INVALID_TRUST 112 -#define X509_R_ISSUER_MISMATCH 113 -#define X509_R_KEY_TYPE_MISMATCH 114 -#define X509_R_KEY_VALUES_MISMATCH 115 -#define X509_R_LOADING_CERT_DIR 116 -#define X509_R_LOADING_DEFAULTS 117 -#define X509_R_METHOD_NOT_SUPPORTED 118 -#define X509_R_NEWER_CRL_NOT_NEWER 119 -#define X509_R_NOT_PKCS7_SIGNED_DATA 120 -#define X509_R_NO_CERTIFICATES_INCLUDED 121 -#define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 122 -#define X509_R_NO_CRL_NUMBER 123 -#define X509_R_PUBLIC_KEY_DECODE_ERROR 124 -#define X509_R_PUBLIC_KEY_ENCODE_ERROR 125 -#define X509_R_SHOULD_RETRY 126 -#define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 127 -#define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 128 -#define X509_R_UNKNOWN_KEY_TYPE 129 -#define X509_R_UNKNOWN_NID 130 -#define X509_R_UNKNOWN_PURPOSE_ID 131 -#define X509_R_UNKNOWN_TRUST_ID 132 -#define X509_R_UNSUPPORTED_ALGORITHM 133 -#define X509_R_WRONG_LOOKUP_TYPE 134 -#define X509_R_WRONG_TYPE 135 -#define X509_R_NO_CRLS_INCLUDED 136 - -#endif diff --git a/phonelibs/boringssl/include/openssl/x509_vfy.h b/phonelibs/boringssl/include/openssl/x509_vfy.h deleted file mode 100644 index 146e047a6d7d4d..00000000000000 --- a/phonelibs/boringssl/include/openssl/x509_vfy.h +++ /dev/null @@ -1,612 +0,0 @@ -/* crypto/x509/x509_vfy.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_X509_H -#include -/* openssl/x509.h ends up #include-ing this file at about the only - * appropriate moment. */ -#endif - -#ifndef HEADER_X509_VFY_H -#define HEADER_X509_VFY_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#if 0 -/* Outer object */ -typedef struct x509_hash_dir_st - { - int num_dirs; - char **dirs; - int *dirs_type; - int num_dirs_alloced; - } X509_HASH_DIR_CTX; -#endif - -typedef struct x509_file_st - { - int num_paths; /* number of paths to files or directories */ - int num_alloced; - char **paths; /* the list of paths or directories */ - int *path_type; - } X509_CERT_FILE_CTX; - -/*******************************/ -/* -SSL_CTX -> X509_STORE - -> X509_LOOKUP - ->X509_LOOKUP_METHOD - -> X509_LOOKUP - ->X509_LOOKUP_METHOD - -SSL -> X509_STORE_CTX - ->X509_STORE - -The X509_STORE holds the tables etc for verification stuff. -A X509_STORE_CTX is used while validating a single certificate. -The X509_STORE has X509_LOOKUPs for looking up certs. -The X509_STORE then calls a function to actually verify the -certificate chain. -*/ - -#define X509_LU_RETRY -1 -#define X509_LU_FAIL 0 -#define X509_LU_X509 1 -#define X509_LU_CRL 2 -#define X509_LU_PKEY 3 - -typedef struct x509_object_st - { - /* one of the above types */ - int type; - union { - char *ptr; - X509 *x509; - X509_CRL *crl; - EVP_PKEY *pkey; - } data; - } X509_OBJECT; - -typedef struct x509_lookup_st X509_LOOKUP; - -DECLARE_STACK_OF(X509_LOOKUP) -DECLARE_STACK_OF(X509_OBJECT) - -/* This is a static that defines the function interface */ -typedef struct x509_lookup_method_st - { - const char *name; - int (*new_item)(X509_LOOKUP *ctx); - void (*free)(X509_LOOKUP *ctx); - int (*init)(X509_LOOKUP *ctx); - int (*shutdown)(X509_LOOKUP *ctx); - int (*ctrl)(X509_LOOKUP *ctx,int cmd,const char *argc,long argl, - char **ret); - int (*get_by_subject)(X509_LOOKUP *ctx,int type,X509_NAME *name, - X509_OBJECT *ret); - int (*get_by_issuer_serial)(X509_LOOKUP *ctx,int type,X509_NAME *name, - ASN1_INTEGER *serial,X509_OBJECT *ret); - int (*get_by_fingerprint)(X509_LOOKUP *ctx,int type, - unsigned char *bytes,int len, - X509_OBJECT *ret); - int (*get_by_alias)(X509_LOOKUP *ctx,int type,char *str,int len, - X509_OBJECT *ret); - } X509_LOOKUP_METHOD; - -typedef struct X509_VERIFY_PARAM_ID_st X509_VERIFY_PARAM_ID; - -/* This structure hold all parameters associated with a verify operation - * by including an X509_VERIFY_PARAM structure in related structures the - * parameters used can be customized - */ - -typedef struct X509_VERIFY_PARAM_st - { - char *name; - time_t check_time; /* Time to use */ - unsigned long inh_flags; /* Inheritance flags */ - unsigned long flags; /* Various verify flags */ - int purpose; /* purpose to check untrusted certificates */ - int trust; /* trust setting to check */ - int depth; /* Verify depth */ - STACK_OF(ASN1_OBJECT) *policies; /* Permissible policies */ - X509_VERIFY_PARAM_ID *id; /* opaque ID data */ - } X509_VERIFY_PARAM; - -DECLARE_STACK_OF(X509_VERIFY_PARAM) - -/* This is used to hold everything. It is used for all certificate - * validation. Once we have a certificate chain, the 'verify' - * function is then called to actually check the cert chain. */ -struct x509_store_st - { - /* The following is a cache of trusted certs */ - int cache; /* if true, stash any hits */ - STACK_OF(X509_OBJECT) *objs; /* Cache of all objects */ - CRYPTO_MUTEX objs_lock; - - /* These are external lookup methods */ - STACK_OF(X509_LOOKUP) *get_cert_methods; - - X509_VERIFY_PARAM *param; - - /* Callbacks for various operations */ - int (*verify)(X509_STORE_CTX *ctx); /* called to verify a certificate */ - int (*verify_cb)(int ok,X509_STORE_CTX *ctx); /* error callback */ - int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); /* get issuers cert from ctx */ - int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */ - int (*check_revocation)(X509_STORE_CTX *ctx); /* Check revocation status of chain */ - int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */ - int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */ - int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */ - STACK_OF(X509) * (*lookup_certs)(X509_STORE_CTX *ctx, X509_NAME *nm); - STACK_OF(X509_CRL) * (*lookup_crls)(X509_STORE_CTX *ctx, X509_NAME *nm); - int (*cleanup)(X509_STORE_CTX *ctx); - - CRYPTO_refcount_t references; - } /* X509_STORE */; - -OPENSSL_EXPORT int X509_STORE_set_depth(X509_STORE *store, int depth); - -#define X509_STORE_set_verify_cb_func(ctx,func) ((ctx)->verify_cb=(func)) -#define X509_STORE_set_verify_func(ctx,func) ((ctx)->verify=(func)) - -/* This is the functions plus an instance of the local variables. */ -struct x509_lookup_st - { - int init; /* have we been started */ - int skip; /* don't use us. */ - X509_LOOKUP_METHOD *method; /* the functions */ - char *method_data; /* method data */ - - X509_STORE *store_ctx; /* who owns us */ - } /* X509_LOOKUP */; - -/* This is a used when verifying cert chains. Since the - * gathering of the cert chain can take some time (and have to be - * 'retried', this needs to be kept and passed around. */ -struct x509_store_ctx_st /* X509_STORE_CTX */ - { - X509_STORE *ctx; - int current_method; /* used when looking up certs */ - - /* The following are set by the caller */ - X509 *cert; /* The cert to check */ - STACK_OF(X509) *untrusted; /* chain of X509s - untrusted - passed in */ - STACK_OF(X509_CRL) *crls; /* set of CRLs passed in */ - - X509_VERIFY_PARAM *param; - void *other_ctx; /* Other info for use with get_issuer() */ - - /* Callbacks for various operations */ - int (*verify)(X509_STORE_CTX *ctx); /* called to verify a certificate */ - int (*verify_cb)(int ok,X509_STORE_CTX *ctx); /* error callback */ - int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); /* get issuers cert from ctx */ - int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */ - int (*check_revocation)(X509_STORE_CTX *ctx); /* Check revocation status of chain */ - int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */ - int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */ - int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */ - int (*check_policy)(X509_STORE_CTX *ctx); - STACK_OF(X509) * (*lookup_certs)(X509_STORE_CTX *ctx, X509_NAME *nm); - STACK_OF(X509_CRL) * (*lookup_crls)(X509_STORE_CTX *ctx, X509_NAME *nm); - int (*cleanup)(X509_STORE_CTX *ctx); - - /* The following is built up */ - int valid; /* if 0, rebuild chain */ - int last_untrusted; /* index of last untrusted cert */ - STACK_OF(X509) *chain; /* chain of X509s - built up and trusted */ - X509_POLICY_TREE *tree; /* Valid policy tree */ - - int explicit_policy; /* Require explicit policy value */ - - /* When something goes wrong, this is why */ - int error_depth; - int error; - X509 *current_cert; - X509 *current_issuer; /* cert currently being tested as valid issuer */ - X509_CRL *current_crl; /* current CRL */ - - int current_crl_score; /* score of current CRL */ - unsigned int current_reasons; /* Reason mask */ - - X509_STORE_CTX *parent; /* For CRL path validation: parent context */ - - CRYPTO_EX_DATA ex_data; - } /* X509_STORE_CTX */; - -OPENSSL_EXPORT void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth); - -#define X509_STORE_CTX_set_app_data(ctx,data) \ - X509_STORE_CTX_set_ex_data(ctx,0,data) -#define X509_STORE_CTX_get_app_data(ctx) \ - X509_STORE_CTX_get_ex_data(ctx,0) - -#define X509_L_FILE_LOAD 1 -#define X509_L_ADD_DIR 2 - -#define X509_LOOKUP_load_file(x,name,type) \ - X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL) - -#define X509_LOOKUP_add_dir(x,name,type) \ - X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL) - -#define X509_V_OK 0 -/* illegal error (for uninitialized values, to avoid X509_V_OK): 1 */ - -#define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 2 -#define X509_V_ERR_UNABLE_TO_GET_CRL 3 -#define X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE 4 -#define X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE 5 -#define X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY 6 -#define X509_V_ERR_CERT_SIGNATURE_FAILURE 7 -#define X509_V_ERR_CRL_SIGNATURE_FAILURE 8 -#define X509_V_ERR_CERT_NOT_YET_VALID 9 -#define X509_V_ERR_CERT_HAS_EXPIRED 10 -#define X509_V_ERR_CRL_NOT_YET_VALID 11 -#define X509_V_ERR_CRL_HAS_EXPIRED 12 -#define X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD 13 -#define X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD 14 -#define X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD 15 -#define X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD 16 -#define X509_V_ERR_OUT_OF_MEM 17 -#define X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT 18 -#define X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN 19 -#define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY 20 -#define X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 21 -#define X509_V_ERR_CERT_CHAIN_TOO_LONG 22 -#define X509_V_ERR_CERT_REVOKED 23 -#define X509_V_ERR_INVALID_CA 24 -#define X509_V_ERR_PATH_LENGTH_EXCEEDED 25 -#define X509_V_ERR_INVALID_PURPOSE 26 -#define X509_V_ERR_CERT_UNTRUSTED 27 -#define X509_V_ERR_CERT_REJECTED 28 -/* These are 'informational' when looking for issuer cert */ -#define X509_V_ERR_SUBJECT_ISSUER_MISMATCH 29 -#define X509_V_ERR_AKID_SKID_MISMATCH 30 -#define X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH 31 -#define X509_V_ERR_KEYUSAGE_NO_CERTSIGN 32 - -#define X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER 33 -#define X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION 34 -#define X509_V_ERR_KEYUSAGE_NO_CRL_SIGN 35 -#define X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION 36 -#define X509_V_ERR_INVALID_NON_CA 37 -#define X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED 38 -#define X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE 39 -#define X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED 40 - -#define X509_V_ERR_INVALID_EXTENSION 41 -#define X509_V_ERR_INVALID_POLICY_EXTENSION 42 -#define X509_V_ERR_NO_EXPLICIT_POLICY 43 -#define X509_V_ERR_DIFFERENT_CRL_SCOPE 44 -#define X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE 45 - -#define X509_V_ERR_UNNESTED_RESOURCE 46 - -#define X509_V_ERR_PERMITTED_VIOLATION 47 -#define X509_V_ERR_EXCLUDED_VIOLATION 48 -#define X509_V_ERR_SUBTREE_MINMAX 49 -#define X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE 51 -#define X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX 52 -#define X509_V_ERR_UNSUPPORTED_NAME_SYNTAX 53 -#define X509_V_ERR_CRL_PATH_VALIDATION_ERROR 54 - -/* Suite B mode algorithm violation */ -#define X509_V_ERR_SUITE_B_INVALID_VERSION 56 -#define X509_V_ERR_SUITE_B_INVALID_ALGORITHM 57 -#define X509_V_ERR_SUITE_B_INVALID_CURVE 58 -#define X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM 59 -#define X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED 60 -#define X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256 61 - -/* Host, email and IP check errors */ -#define X509_V_ERR_HOSTNAME_MISMATCH 62 -#define X509_V_ERR_EMAIL_MISMATCH 63 -#define X509_V_ERR_IP_ADDRESS_MISMATCH 64 - -/* The application is not happy */ -#define X509_V_ERR_APPLICATION_VERIFICATION 50 - -/* Certificate verify flags */ - -/* Send issuer+subject checks to verify_cb */ -#define X509_V_FLAG_CB_ISSUER_CHECK 0x1 -/* Use check time instead of current time */ -#define X509_V_FLAG_USE_CHECK_TIME 0x2 -/* Lookup CRLs */ -#define X509_V_FLAG_CRL_CHECK 0x4 -/* Lookup CRLs for whole chain */ -#define X509_V_FLAG_CRL_CHECK_ALL 0x8 -/* Ignore unhandled critical extensions */ -#define X509_V_FLAG_IGNORE_CRITICAL 0x10 -/* Disable workarounds for broken certificates */ -#define X509_V_FLAG_X509_STRICT 0x20 -/* Enable proxy certificate validation */ -#define X509_V_FLAG_ALLOW_PROXY_CERTS 0x40 -/* Enable policy checking */ -#define X509_V_FLAG_POLICY_CHECK 0x80 -/* Policy variable require-explicit-policy */ -#define X509_V_FLAG_EXPLICIT_POLICY 0x100 -/* Policy variable inhibit-any-policy */ -#define X509_V_FLAG_INHIBIT_ANY 0x200 -/* Policy variable inhibit-policy-mapping */ -#define X509_V_FLAG_INHIBIT_MAP 0x400 -/* Notify callback that policy is OK */ -#define X509_V_FLAG_NOTIFY_POLICY 0x800 -/* Extended CRL features such as indirect CRLs, alternate CRL signing keys */ -#define X509_V_FLAG_EXTENDED_CRL_SUPPORT 0x1000 -/* Delta CRL support */ -#define X509_V_FLAG_USE_DELTAS 0x2000 -/* Check selfsigned CA signature */ -#define X509_V_FLAG_CHECK_SS_SIGNATURE 0x4000 -/* Use trusted store first */ -#define X509_V_FLAG_TRUSTED_FIRST 0x8000 -/* Suite B 128 bit only mode: not normally used */ -#define X509_V_FLAG_SUITEB_128_LOS_ONLY 0x10000 -/* Suite B 192 bit only mode */ -#define X509_V_FLAG_SUITEB_192_LOS 0x20000 -/* Suite B 128 bit mode allowing 192 bit algorithms */ -#define X509_V_FLAG_SUITEB_128_LOS 0x30000 - -/* Allow partial chains if at least one certificate is in trusted store */ -#define X509_V_FLAG_PARTIAL_CHAIN 0x80000 - -#define X509_VP_FLAG_DEFAULT 0x1 -#define X509_VP_FLAG_OVERWRITE 0x2 -#define X509_VP_FLAG_RESET_FLAGS 0x4 -#define X509_VP_FLAG_LOCKED 0x8 -#define X509_VP_FLAG_ONCE 0x10 - -/* Internal use: mask of policy related options */ -#define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \ - | X509_V_FLAG_EXPLICIT_POLICY \ - | X509_V_FLAG_INHIBIT_ANY \ - | X509_V_FLAG_INHIBIT_MAP) - -OPENSSL_EXPORT int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type, - X509_NAME *name); -OPENSSL_EXPORT X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,int type,X509_NAME *name); -OPENSSL_EXPORT X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x); -OPENSSL_EXPORT void X509_OBJECT_up_ref_count(X509_OBJECT *a); -OPENSSL_EXPORT void X509_OBJECT_free_contents(X509_OBJECT *a); -OPENSSL_EXPORT X509_STORE *X509_STORE_new(void ); -OPENSSL_EXPORT void X509_STORE_free(X509_STORE *v); - -OPENSSL_EXPORT STACK_OF(X509)* X509_STORE_get1_certs(X509_STORE_CTX *st, X509_NAME *nm); -OPENSSL_EXPORT STACK_OF(X509_CRL)* X509_STORE_get1_crls(X509_STORE_CTX *st, X509_NAME *nm); -OPENSSL_EXPORT int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags); -OPENSSL_EXPORT int X509_STORE_set_purpose(X509_STORE *ctx, int purpose); -OPENSSL_EXPORT int X509_STORE_set_trust(X509_STORE *ctx, int trust); -OPENSSL_EXPORT int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm); - -OPENSSL_EXPORT void X509_STORE_set_verify_cb(X509_STORE *ctx, - int (*verify_cb)(int, X509_STORE_CTX *)); - -OPENSSL_EXPORT void X509_STORE_set_lookup_crls_cb(X509_STORE *ctx, - STACK_OF(X509_CRL)* (*cb)(X509_STORE_CTX *ctx, X509_NAME *nm)); - -OPENSSL_EXPORT X509_STORE_CTX *X509_STORE_CTX_new(void); - -OPENSSL_EXPORT int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); - -OPENSSL_EXPORT void X509_STORE_CTX_free(X509_STORE_CTX *ctx); -OPENSSL_EXPORT int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, - X509 *x509, STACK_OF(X509) *chain); -OPENSSL_EXPORT void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk); -OPENSSL_EXPORT void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx); - -OPENSSL_EXPORT X509_STORE *X509_STORE_CTX_get0_store(X509_STORE_CTX *ctx); - -OPENSSL_EXPORT X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m); - -OPENSSL_EXPORT X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void); -OPENSSL_EXPORT X509_LOOKUP_METHOD *X509_LOOKUP_file(void); - -OPENSSL_EXPORT int X509_STORE_add_cert(X509_STORE *ctx, X509 *x); -OPENSSL_EXPORT int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x); - -OPENSSL_EXPORT int X509_STORE_get_by_subject(X509_STORE_CTX *vs,int type,X509_NAME *name, - X509_OBJECT *ret); - -OPENSSL_EXPORT int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, - long argl, char **ret); - -#ifndef OPENSSL_NO_STDIO -OPENSSL_EXPORT int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type); -OPENSSL_EXPORT int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type); -OPENSSL_EXPORT int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type); -#endif - - -OPENSSL_EXPORT X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method); -OPENSSL_EXPORT void X509_LOOKUP_free(X509_LOOKUP *ctx); -OPENSSL_EXPORT int X509_LOOKUP_init(X509_LOOKUP *ctx); -OPENSSL_EXPORT int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name, - X509_OBJECT *ret); -OPENSSL_EXPORT int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name, - ASN1_INTEGER *serial, X509_OBJECT *ret); -OPENSSL_EXPORT int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type, - unsigned char *bytes, int len, X509_OBJECT *ret); -OPENSSL_EXPORT int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str, - int len, X509_OBJECT *ret); -OPENSSL_EXPORT int X509_LOOKUP_shutdown(X509_LOOKUP *ctx); - -#ifndef OPENSSL_NO_STDIO -OPENSSL_EXPORT int X509_STORE_load_locations (X509_STORE *ctx, - const char *file, const char *dir); -OPENSSL_EXPORT int X509_STORE_set_default_paths(X509_STORE *ctx); -#endif - -OPENSSL_EXPORT int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); -OPENSSL_EXPORT int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx,int idx,void *data); -OPENSSL_EXPORT void * X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx,int idx); -OPENSSL_EXPORT int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx); -OPENSSL_EXPORT void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx,int s); -OPENSSL_EXPORT int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx); -OPENSSL_EXPORT X509 * X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx); -OPENSSL_EXPORT X509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx); -OPENSSL_EXPORT X509_CRL *X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx); -OPENSSL_EXPORT X509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx); -OPENSSL_EXPORT STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx); -OPENSSL_EXPORT STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx); -OPENSSL_EXPORT void X509_STORE_CTX_set_cert(X509_STORE_CTX *c,X509 *x); -OPENSSL_EXPORT void X509_STORE_CTX_set_chain(X509_STORE_CTX *c,STACK_OF(X509) *sk); -OPENSSL_EXPORT void X509_STORE_CTX_set0_crls(X509_STORE_CTX *c,STACK_OF(X509_CRL) *sk); -OPENSSL_EXPORT int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose); -OPENSSL_EXPORT int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust); -OPENSSL_EXPORT int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose, - int purpose, int trust); -OPENSSL_EXPORT void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags); -OPENSSL_EXPORT void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags, - time_t t); -OPENSSL_EXPORT void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx, - int (*verify_cb)(int, X509_STORE_CTX *)); - -OPENSSL_EXPORT X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx); -OPENSSL_EXPORT int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx); - -OPENSSL_EXPORT X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx); -OPENSSL_EXPORT void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param); -OPENSSL_EXPORT int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name); - -/* X509_VERIFY_PARAM functions */ - -OPENSSL_EXPORT X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void); -OPENSSL_EXPORT void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param); -OPENSSL_EXPORT int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to, - const X509_VERIFY_PARAM *from); -OPENSSL_EXPORT int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, - const X509_VERIFY_PARAM *from); -OPENSSL_EXPORT int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name); -OPENSSL_EXPORT int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags); -OPENSSL_EXPORT int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param, - unsigned long flags); -OPENSSL_EXPORT unsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param); -OPENSSL_EXPORT int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose); -OPENSSL_EXPORT int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust); -OPENSSL_EXPORT void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth); -OPENSSL_EXPORT void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t); -OPENSSL_EXPORT int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, - ASN1_OBJECT *policy); -OPENSSL_EXPORT int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, - STACK_OF(ASN1_OBJECT) *policies); - -OPENSSL_EXPORT int X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param, - const char *name, size_t namelen); -OPENSSL_EXPORT int X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param, - const char *name, - size_t namelen); -OPENSSL_EXPORT void X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param, - unsigned int flags); -OPENSSL_EXPORT char *X509_VERIFY_PARAM_get0_peername(X509_VERIFY_PARAM *); -OPENSSL_EXPORT int X509_VERIFY_PARAM_set1_email(X509_VERIFY_PARAM *param, - const char *email, size_t emaillen); -OPENSSL_EXPORT int X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param, - const unsigned char *ip, size_t iplen); -OPENSSL_EXPORT int X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM *param, const char *ipasc); - -OPENSSL_EXPORT int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param); -OPENSSL_EXPORT const char *X509_VERIFY_PARAM_get0_name(const X509_VERIFY_PARAM *param); - -OPENSSL_EXPORT int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param); -OPENSSL_EXPORT int X509_VERIFY_PARAM_get_count(void); -OPENSSL_EXPORT const X509_VERIFY_PARAM *X509_VERIFY_PARAM_get0(int id); -OPENSSL_EXPORT const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name); -OPENSSL_EXPORT void X509_VERIFY_PARAM_table_cleanup(void); - -OPENSSL_EXPORT int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy, - STACK_OF(X509) *certs, - STACK_OF(ASN1_OBJECT) *policy_oids, - unsigned int flags); - -OPENSSL_EXPORT void X509_policy_tree_free(X509_POLICY_TREE *tree); - -OPENSSL_EXPORT int X509_policy_tree_level_count(const X509_POLICY_TREE *tree); -OPENSSL_EXPORT X509_POLICY_LEVEL * - X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, int i); - -OPENSSL_EXPORT STACK_OF(X509_POLICY_NODE) * - X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree); - -OPENSSL_EXPORT STACK_OF(X509_POLICY_NODE) * - X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree); - -OPENSSL_EXPORT int X509_policy_level_node_count(X509_POLICY_LEVEL *level); - -OPENSSL_EXPORT X509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level, int i); - -OPENSSL_EXPORT const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node); - -OPENSSL_EXPORT STACK_OF(POLICYQUALINFO) * - X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node); -OPENSSL_EXPORT const X509_POLICY_NODE * - X509_policy_node_get0_parent(const X509_POLICY_NODE *node); - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/phonelibs/boringssl/include/openssl/x509v3.h b/phonelibs/boringssl/include/openssl/x509v3.h deleted file mode 100644 index 5caa5c1f4e348b..00000000000000 --- a/phonelibs/boringssl/include/openssl/x509v3.h +++ /dev/null @@ -1,855 +0,0 @@ -/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL - * project 1999. */ -/* ==================================================================== - * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). */ - -#ifndef HEADER_X509V3_H -#define HEADER_X509V3_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Forward reference */ -struct v3_ext_method; -struct v3_ext_ctx; - -/* Useful typedefs */ - -typedef void * (*X509V3_EXT_NEW)(void); -typedef void (*X509V3_EXT_FREE)(void *); -typedef void * (*X509V3_EXT_D2I)(void *, const unsigned char ** , long); -typedef int (*X509V3_EXT_I2D)(void *, unsigned char **); -typedef STACK_OF(CONF_VALUE) * - (*X509V3_EXT_I2V)(const struct v3_ext_method *method, void *ext, - STACK_OF(CONF_VALUE) *extlist); -typedef void * (*X509V3_EXT_V2I)(const struct v3_ext_method *method, - struct v3_ext_ctx *ctx, - STACK_OF(CONF_VALUE) *values); -typedef char * (*X509V3_EXT_I2S)(const struct v3_ext_method *method, void *ext); -typedef void * (*X509V3_EXT_S2I)(const struct v3_ext_method *method, - struct v3_ext_ctx *ctx, const char *str); -typedef int (*X509V3_EXT_I2R)(const struct v3_ext_method *method, void *ext, - BIO *out, int indent); -typedef void * (*X509V3_EXT_R2I)(const struct v3_ext_method *method, - struct v3_ext_ctx *ctx, const char *str); - -/* V3 extension structure */ - -struct v3_ext_method { -int ext_nid; -int ext_flags; -/* If this is set the following four fields are ignored */ -ASN1_ITEM_EXP *it; -/* Old style ASN1 calls */ -X509V3_EXT_NEW ext_new; -X509V3_EXT_FREE ext_free; -X509V3_EXT_D2I d2i; -X509V3_EXT_I2D i2d; - -/* The following pair is used for string extensions */ -X509V3_EXT_I2S i2s; -X509V3_EXT_S2I s2i; - -/* The following pair is used for multi-valued extensions */ -X509V3_EXT_I2V i2v; -X509V3_EXT_V2I v2i; - -/* The following are used for raw extensions */ -X509V3_EXT_I2R i2r; -X509V3_EXT_R2I r2i; - -void *usr_data; /* Any extension specific data */ -}; - -typedef struct X509V3_CONF_METHOD_st { -char * (*get_string)(void *db, char *section, char *value); -STACK_OF(CONF_VALUE) * (*get_section)(void *db, char *section); -void (*free_string)(void *db, char * string); -void (*free_section)(void *db, STACK_OF(CONF_VALUE) *section); -} X509V3_CONF_METHOD; - -/* Context specific info */ -struct v3_ext_ctx { -#define CTX_TEST 0x1 -int flags; -X509 *issuer_cert; -X509 *subject_cert; -X509_REQ *subject_req; -X509_CRL *crl; -const X509V3_CONF_METHOD *db_meth; -void *db; -/* Maybe more here */ -}; - -typedef struct v3_ext_method X509V3_EXT_METHOD; - -DECLARE_STACK_OF(X509V3_EXT_METHOD) - -/* ext_flags values */ -#define X509V3_EXT_DYNAMIC 0x1 -#define X509V3_EXT_CTX_DEP 0x2 -#define X509V3_EXT_MULTILINE 0x4 - -typedef BIT_STRING_BITNAME ENUMERATED_NAMES; - -typedef struct BASIC_CONSTRAINTS_st { -int ca; -ASN1_INTEGER *pathlen; -} BASIC_CONSTRAINTS; - - -typedef struct PKEY_USAGE_PERIOD_st { -ASN1_GENERALIZEDTIME *notBefore; -ASN1_GENERALIZEDTIME *notAfter; -} PKEY_USAGE_PERIOD; - -typedef struct otherName_st { -ASN1_OBJECT *type_id; -ASN1_TYPE *value; -} OTHERNAME; - -typedef struct EDIPartyName_st { - ASN1_STRING *nameAssigner; - ASN1_STRING *partyName; -} EDIPARTYNAME; - -typedef struct GENERAL_NAME_st { - -#define GEN_OTHERNAME 0 -#define GEN_EMAIL 1 -#define GEN_DNS 2 -#define GEN_X400 3 -#define GEN_DIRNAME 4 -#define GEN_EDIPARTY 5 -#define GEN_URI 6 -#define GEN_IPADD 7 -#define GEN_RID 8 - -int type; -union { - char *ptr; - OTHERNAME *otherName; /* otherName */ - ASN1_IA5STRING *rfc822Name; - ASN1_IA5STRING *dNSName; - ASN1_TYPE *x400Address; - X509_NAME *directoryName; - EDIPARTYNAME *ediPartyName; - ASN1_IA5STRING *uniformResourceIdentifier; - ASN1_OCTET_STRING *iPAddress; - ASN1_OBJECT *registeredID; - - /* Old names */ - ASN1_OCTET_STRING *ip; /* iPAddress */ - X509_NAME *dirn; /* dirn */ - ASN1_IA5STRING *ia5;/* rfc822Name, dNSName, uniformResourceIdentifier */ - ASN1_OBJECT *rid; /* registeredID */ - ASN1_TYPE *other; /* x400Address */ -} d; -} GENERAL_NAME; - -typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES; - -typedef struct ACCESS_DESCRIPTION_st { - ASN1_OBJECT *method; - GENERAL_NAME *location; -} ACCESS_DESCRIPTION; - -typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS; - -typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE; - -DECLARE_STACK_OF(GENERAL_NAME) -DECLARE_ASN1_SET_OF(GENERAL_NAME) - -DECLARE_STACK_OF(ACCESS_DESCRIPTION) -DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) - -typedef struct DIST_POINT_NAME_st { -int type; -union { - GENERAL_NAMES *fullname; - STACK_OF(X509_NAME_ENTRY) *relativename; -} name; -/* If relativename then this contains the full distribution point name */ -X509_NAME *dpname; -} DIST_POINT_NAME; -/* All existing reasons */ -#define CRLDP_ALL_REASONS 0x807f - -#define CRL_REASON_NONE -1 -#define CRL_REASON_UNSPECIFIED 0 -#define CRL_REASON_KEY_COMPROMISE 1 -#define CRL_REASON_CA_COMPROMISE 2 -#define CRL_REASON_AFFILIATION_CHANGED 3 -#define CRL_REASON_SUPERSEDED 4 -#define CRL_REASON_CESSATION_OF_OPERATION 5 -#define CRL_REASON_CERTIFICATE_HOLD 6 -#define CRL_REASON_REMOVE_FROM_CRL 8 -#define CRL_REASON_PRIVILEGE_WITHDRAWN 9 -#define CRL_REASON_AA_COMPROMISE 10 - -struct DIST_POINT_st { -DIST_POINT_NAME *distpoint; -ASN1_BIT_STRING *reasons; -GENERAL_NAMES *CRLissuer; -int dp_reasons; -}; - -typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS; - -DECLARE_STACK_OF(DIST_POINT) -DECLARE_ASN1_SET_OF(DIST_POINT) - -struct AUTHORITY_KEYID_st { -ASN1_OCTET_STRING *keyid; -GENERAL_NAMES *issuer; -ASN1_INTEGER *serial; -}; - -/* Strong extranet structures */ - -typedef struct SXNET_ID_st { - ASN1_INTEGER *zone; - ASN1_OCTET_STRING *user; -} SXNETID; - -DECLARE_STACK_OF(SXNETID) -DECLARE_ASN1_SET_OF(SXNETID) - -typedef struct SXNET_st { - ASN1_INTEGER *version; - STACK_OF(SXNETID) *ids; -} SXNET; - -typedef struct NOTICEREF_st { - ASN1_STRING *organization; - STACK_OF(ASN1_INTEGER) *noticenos; -} NOTICEREF; - -typedef struct USERNOTICE_st { - NOTICEREF *noticeref; - ASN1_STRING *exptext; -} USERNOTICE; - -typedef struct POLICYQUALINFO_st { - ASN1_OBJECT *pqualid; - union { - ASN1_IA5STRING *cpsuri; - USERNOTICE *usernotice; - ASN1_TYPE *other; - } d; -} POLICYQUALINFO; - -DECLARE_STACK_OF(POLICYQUALINFO) -DECLARE_ASN1_SET_OF(POLICYQUALINFO) - -typedef struct POLICYINFO_st { - ASN1_OBJECT *policyid; - STACK_OF(POLICYQUALINFO) *qualifiers; -} POLICYINFO; - -typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES; - -DECLARE_STACK_OF(POLICYINFO) -DECLARE_ASN1_SET_OF(POLICYINFO) - -typedef struct POLICY_MAPPING_st { - ASN1_OBJECT *issuerDomainPolicy; - ASN1_OBJECT *subjectDomainPolicy; -} POLICY_MAPPING; - -DECLARE_STACK_OF(POLICY_MAPPING) - -typedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS; - -typedef struct GENERAL_SUBTREE_st { - GENERAL_NAME *base; - ASN1_INTEGER *minimum; - ASN1_INTEGER *maximum; -} GENERAL_SUBTREE; - -DECLARE_STACK_OF(GENERAL_SUBTREE) - -struct NAME_CONSTRAINTS_st { - STACK_OF(GENERAL_SUBTREE) *permittedSubtrees; - STACK_OF(GENERAL_SUBTREE) *excludedSubtrees; -}; - -typedef struct POLICY_CONSTRAINTS_st { - ASN1_INTEGER *requireExplicitPolicy; - ASN1_INTEGER *inhibitPolicyMapping; -} POLICY_CONSTRAINTS; - -/* Proxy certificate structures, see RFC 3820 */ -typedef struct PROXY_POLICY_st - { - ASN1_OBJECT *policyLanguage; - ASN1_OCTET_STRING *policy; - } PROXY_POLICY; - -typedef struct PROXY_CERT_INFO_EXTENSION_st - { - ASN1_INTEGER *pcPathLengthConstraint; - PROXY_POLICY *proxyPolicy; - } PROXY_CERT_INFO_EXTENSION; - -DECLARE_ASN1_FUNCTIONS(PROXY_POLICY) -DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION) - -struct ISSUING_DIST_POINT_st - { - DIST_POINT_NAME *distpoint; - int onlyuser; - int onlyCA; - ASN1_BIT_STRING *onlysomereasons; - int indirectCRL; - int onlyattr; - }; - -/* Values in idp_flags field */ -/* IDP present */ -#define IDP_PRESENT 0x1 -/* IDP values inconsistent */ -#define IDP_INVALID 0x2 -/* onlyuser true */ -#define IDP_ONLYUSER 0x4 -/* onlyCA true */ -#define IDP_ONLYCA 0x8 -/* onlyattr true */ -#define IDP_ONLYATTR 0x10 -/* indirectCRL true */ -#define IDP_INDIRECT 0x20 -/* onlysomereasons present */ -#define IDP_REASONS 0x40 - -#define X509V3_conf_err(val) ERR_add_error_data(6, "section:", val->section, \ -",name:", val->name, ",value:", val->value); - -#define X509V3_set_ctx_test(ctx) \ - X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST) -#define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL; - -#define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \ - 0,0,0,0, \ - 0,0, \ - (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \ - (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \ - NULL, NULL, \ - (void *)table} - -#define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \ - 0,0,0,0, \ - (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \ - (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \ - 0,0,0,0, \ - NULL} - -#define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - - -/* X509_PURPOSE stuff */ - -#define EXFLAG_BCONS 0x1 -#define EXFLAG_KUSAGE 0x2 -#define EXFLAG_XKUSAGE 0x4 -#define EXFLAG_NSCERT 0x8 - -#define EXFLAG_CA 0x10 -/* Really self issued not necessarily self signed */ -#define EXFLAG_SI 0x20 -#define EXFLAG_V1 0x40 -#define EXFLAG_INVALID 0x80 -#define EXFLAG_SET 0x100 -#define EXFLAG_CRITICAL 0x200 -#define EXFLAG_PROXY 0x400 - -#define EXFLAG_INVALID_POLICY 0x800 -#define EXFLAG_FRESHEST 0x1000 -/* Self signed */ -#define EXFLAG_SS 0x2000 - -#define KU_DIGITAL_SIGNATURE 0x0080 -#define KU_NON_REPUDIATION 0x0040 -#define KU_KEY_ENCIPHERMENT 0x0020 -#define KU_DATA_ENCIPHERMENT 0x0010 -#define KU_KEY_AGREEMENT 0x0008 -#define KU_KEY_CERT_SIGN 0x0004 -#define KU_CRL_SIGN 0x0002 -#define KU_ENCIPHER_ONLY 0x0001 -#define KU_DECIPHER_ONLY 0x8000 - -#define NS_SSL_CLIENT 0x80 -#define NS_SSL_SERVER 0x40 -#define NS_SMIME 0x20 -#define NS_OBJSIGN 0x10 -#define NS_SSL_CA 0x04 -#define NS_SMIME_CA 0x02 -#define NS_OBJSIGN_CA 0x01 -#define NS_ANY_CA (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA) - -#define XKU_SSL_SERVER 0x1 -#define XKU_SSL_CLIENT 0x2 -#define XKU_SMIME 0x4 -#define XKU_CODE_SIGN 0x8 -#define XKU_SGC 0x10 -#define XKU_OCSP_SIGN 0x20 -#define XKU_TIMESTAMP 0x40 -#define XKU_DVCS 0x80 -#define XKU_ANYEKU 0x100 - -#define X509_PURPOSE_DYNAMIC 0x1 -#define X509_PURPOSE_DYNAMIC_NAME 0x2 - -typedef struct x509_purpose_st { - int purpose; - int trust; /* Default trust ID */ - int flags; - int (*check_purpose)(const struct x509_purpose_st *, - const X509 *, int); - char *name; - char *sname; - void *usr_data; -} X509_PURPOSE; - -#define X509_PURPOSE_SSL_CLIENT 1 -#define X509_PURPOSE_SSL_SERVER 2 -#define X509_PURPOSE_NS_SSL_SERVER 3 -#define X509_PURPOSE_SMIME_SIGN 4 -#define X509_PURPOSE_SMIME_ENCRYPT 5 -#define X509_PURPOSE_CRL_SIGN 6 -#define X509_PURPOSE_ANY 7 -#define X509_PURPOSE_OCSP_HELPER 8 -#define X509_PURPOSE_TIMESTAMP_SIGN 9 - -#define X509_PURPOSE_MIN 1 -#define X509_PURPOSE_MAX 9 - -/* Flags for X509V3_EXT_print() */ - -#define X509V3_EXT_UNKNOWN_MASK (0xfL << 16) -/* Return error for unknown extensions */ -#define X509V3_EXT_DEFAULT 0 -/* Print error for unknown extensions */ -#define X509V3_EXT_ERROR_UNKNOWN (1L << 16) -/* ASN1 parse unknown extensions */ -#define X509V3_EXT_PARSE_UNKNOWN (2L << 16) -/* BIO_dump unknown extensions */ -#define X509V3_EXT_DUMP_UNKNOWN (3L << 16) - -/* Flags for X509V3_add1_i2d */ - -#define X509V3_ADD_OP_MASK 0xfL -#define X509V3_ADD_DEFAULT 0L -#define X509V3_ADD_APPEND 1L -#define X509V3_ADD_REPLACE 2L -#define X509V3_ADD_REPLACE_EXISTING 3L -#define X509V3_ADD_KEEP_EXISTING 4L -#define X509V3_ADD_DELETE 5L -#define X509V3_ADD_SILENT 0x10 - -DECLARE_STACK_OF(X509_PURPOSE) - -DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS) - -DECLARE_ASN1_FUNCTIONS(SXNET) -DECLARE_ASN1_FUNCTIONS(SXNETID) - -int SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen); -int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user, int userlen); -int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, char *user, int userlen); - -ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone); -ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone); -ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone); - -DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID) - -DECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD) - -DECLARE_ASN1_FUNCTIONS(GENERAL_NAME) -OPENSSL_EXPORT GENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a); -OPENSSL_EXPORT int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b); - - - -OPENSSL_EXPORT ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); -OPENSSL_EXPORT STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, - ASN1_BIT_STRING *bits, - STACK_OF(CONF_VALUE) *extlist); - -OPENSSL_EXPORT STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, GENERAL_NAME *gen, STACK_OF(CONF_VALUE) *ret); -OPENSSL_EXPORT int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen); - -DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES) - -OPENSSL_EXPORT STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, - GENERAL_NAMES *gen, STACK_OF(CONF_VALUE) *extlist); -OPENSSL_EXPORT GENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); - -DECLARE_ASN1_FUNCTIONS(OTHERNAME) -DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME) -OPENSSL_EXPORT int OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b); -OPENSSL_EXPORT void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value); -OPENSSL_EXPORT void *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype); -OPENSSL_EXPORT int GENERAL_NAME_set0_othername(GENERAL_NAME *gen, - ASN1_OBJECT *oid, ASN1_TYPE *value); -OPENSSL_EXPORT int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, - ASN1_OBJECT **poid, ASN1_TYPE **pvalue); - -OPENSSL_EXPORT char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5); -OPENSSL_EXPORT ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); - -DECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE) -OPENSSL_EXPORT int i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION* a); - -DECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES) -DECLARE_ASN1_FUNCTIONS(POLICYINFO) -DECLARE_ASN1_FUNCTIONS(POLICYQUALINFO) -DECLARE_ASN1_FUNCTIONS(USERNOTICE) -DECLARE_ASN1_FUNCTIONS(NOTICEREF) - -DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS) -DECLARE_ASN1_FUNCTIONS(DIST_POINT) -DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME) -DECLARE_ASN1_FUNCTIONS(ISSUING_DIST_POINT) - -OPENSSL_EXPORT int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname); - -OPENSSL_EXPORT int NAME_CONSTRAINTS_check(X509 *x, NAME_CONSTRAINTS *nc); - -DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION) -DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS) - -DECLARE_ASN1_ITEM(POLICY_MAPPING) -DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING) -DECLARE_ASN1_ITEM(POLICY_MAPPINGS) - -DECLARE_ASN1_ITEM(GENERAL_SUBTREE) -DECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE) - -DECLARE_ASN1_ITEM(NAME_CONSTRAINTS) -DECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS) - -DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS) -DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS) - -OPENSSL_EXPORT GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out, - const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, - int gen_type, char *value, int is_nc); - -OPENSSL_EXPORT GENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, - CONF_VALUE *cnf); -OPENSSL_EXPORT GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, - const X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, CONF_VALUE *cnf, int is_nc); -OPENSSL_EXPORT void X509V3_conf_free(CONF_VALUE *val); - -OPENSSL_EXPORT X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, char *value); -OPENSSL_EXPORT X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name, char *value); -OPENSSL_EXPORT int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, STACK_OF(X509_EXTENSION) **sk); -OPENSSL_EXPORT int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509 *cert); -OPENSSL_EXPORT int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_REQ *req); -OPENSSL_EXPORT int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl); - -OPENSSL_EXPORT int X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, - char *section, X509_CRL *crl); - -OPENSSL_EXPORT int X509V3_add_value_bool_nf(char *name, int asn1_bool, - STACK_OF(CONF_VALUE) **extlist); -OPENSSL_EXPORT int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool); -OPENSSL_EXPORT int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint); -OPENSSL_EXPORT void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf); - -OPENSSL_EXPORT char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section); -OPENSSL_EXPORT STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section); -OPENSSL_EXPORT void X509V3_string_free(X509V3_CTX *ctx, char *str); -OPENSSL_EXPORT void X509V3_section_free( X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section); -OPENSSL_EXPORT void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject, - X509_REQ *req, X509_CRL *crl, int flags); - -OPENSSL_EXPORT int X509V3_add_value(const char *name, const char *value, - STACK_OF(CONF_VALUE) **extlist); -OPENSSL_EXPORT int X509V3_add_value_uchar(const char *name, const unsigned char *value, - STACK_OF(CONF_VALUE) **extlist); -OPENSSL_EXPORT int X509V3_add_value_bool(const char *name, int asn1_bool, - STACK_OF(CONF_VALUE) **extlist); -OPENSSL_EXPORT int X509V3_add_value_int(const char *name, ASN1_INTEGER *aint, - STACK_OF(CONF_VALUE) **extlist); -OPENSSL_EXPORT char * i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, ASN1_INTEGER *aint); -OPENSSL_EXPORT ASN1_INTEGER * s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, char *value); -OPENSSL_EXPORT char * i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint); -OPENSSL_EXPORT char * i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint); -OPENSSL_EXPORT int X509V3_EXT_add(X509V3_EXT_METHOD *ext); -OPENSSL_EXPORT int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist); -OPENSSL_EXPORT int X509V3_EXT_add_alias(int nid_to, int nid_from); -OPENSSL_EXPORT void X509V3_EXT_cleanup(void); - -OPENSSL_EXPORT const X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext); -OPENSSL_EXPORT const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid); -OPENSSL_EXPORT int X509V3_add_standard_extensions(void); -OPENSSL_EXPORT STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line); -OPENSSL_EXPORT void *X509V3_EXT_d2i(X509_EXTENSION *ext); -OPENSSL_EXPORT void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx); - - -OPENSSL_EXPORT X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); -OPENSSL_EXPORT int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, int crit, unsigned long flags); - -char *hex_to_string(const unsigned char *buffer, long len); -unsigned char *string_to_hex(const char *str, long *len); -int name_cmp(const char *name, const char *cmp); - -OPENSSL_EXPORT void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, - int ml); -OPENSSL_EXPORT int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent); -OPENSSL_EXPORT int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent); - -OPENSSL_EXPORT int X509V3_extensions_print(BIO *out, const char *title, STACK_OF(X509_EXTENSION) *exts, unsigned long flag, int indent); - -OPENSSL_EXPORT int X509_check_ca(X509 *x); -OPENSSL_EXPORT int X509_check_purpose(X509 *x, int id, int ca); -OPENSSL_EXPORT int X509_supported_extension(X509_EXTENSION *ex); -OPENSSL_EXPORT int X509_PURPOSE_set(int *p, int purpose); -OPENSSL_EXPORT int X509_check_issued(X509 *issuer, X509 *subject); -OPENSSL_EXPORT int X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid); -OPENSSL_EXPORT int X509_PURPOSE_get_count(void); -OPENSSL_EXPORT X509_PURPOSE * X509_PURPOSE_get0(int idx); -OPENSSL_EXPORT int X509_PURPOSE_get_by_sname(char *sname); -OPENSSL_EXPORT int X509_PURPOSE_get_by_id(int id); -OPENSSL_EXPORT int X509_PURPOSE_add(int id, int trust, int flags, - int (*ck)(const X509_PURPOSE *, const X509 *, int), - char *name, char *sname, void *arg); -OPENSSL_EXPORT char *X509_PURPOSE_get0_name(X509_PURPOSE *xp); -OPENSSL_EXPORT char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp); -OPENSSL_EXPORT int X509_PURPOSE_get_trust(X509_PURPOSE *xp); -OPENSSL_EXPORT void X509_PURPOSE_cleanup(void); -OPENSSL_EXPORT int X509_PURPOSE_get_id(X509_PURPOSE *); - -OPENSSL_EXPORT STACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x); -OPENSSL_EXPORT STACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x); -OPENSSL_EXPORT void X509_email_free(STACK_OF(OPENSSL_STRING) *sk); -OPENSSL_EXPORT STACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x); -/* Flags for X509_check_* functions */ - -/* Always check subject name for host match even if subject alt names present */ -#define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT 0x1 -/* Disable wildcard matching for dnsName fields and common name. */ -#define X509_CHECK_FLAG_NO_WILDCARDS 0x2 -/* Wildcards must not match a partial label. */ -#define X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS 0x4 -/* Allow (non-partial) wildcards to match multiple labels. */ -#define X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS 0x8 -/* Constraint verifier subdomain patterns to match a single labels. */ -#define X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS 0x10 -/* - * Match reference identifiers starting with "." to any sub-domain. - * This is a non-public flag, turned on implicitly when the subject - * reference identity is a DNS name. - */ -#define _X509_CHECK_FLAG_DOT_SUBDOMAINS 0x8000 - -OPENSSL_EXPORT int X509_check_host(X509 *x, const char *chk, size_t chklen, - unsigned int flags, char **peername); -OPENSSL_EXPORT int X509_check_email(X509 *x, const char *chk, size_t chklen, - unsigned int flags); -OPENSSL_EXPORT int X509_check_ip(X509 *x, const unsigned char *chk, size_t chklen, - unsigned int flags); -OPENSSL_EXPORT int X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags); - -OPENSSL_EXPORT ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc); -OPENSSL_EXPORT ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc); -OPENSSL_EXPORT int a2i_ipadd(unsigned char *ipout, const char *ipasc); -OPENSSL_EXPORT int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE)*dn_sk, - unsigned long chtype); - -OPENSSL_EXPORT void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent); -DECLARE_STACK_OF(X509_POLICY_NODE) - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_X509V3_strings(void); - - -#ifdef __cplusplus -} -#endif -#define X509V3_F_SXNET_add_id_INTEGER 100 -#define X509V3_F_SXNET_add_id_asc 101 -#define X509V3_F_SXNET_add_id_ulong 102 -#define X509V3_F_SXNET_get_id_asc 103 -#define X509V3_F_SXNET_get_id_ulong 104 -#define X509V3_F_X509V3_EXT_add 105 -#define X509V3_F_X509V3_EXT_add_alias 106 -#define X509V3_F_X509V3_EXT_free 107 -#define X509V3_F_X509V3_EXT_i2d 108 -#define X509V3_F_X509V3_EXT_nconf 109 -#define X509V3_F_X509V3_add1_i2d 110 -#define X509V3_F_X509V3_add_value 111 -#define X509V3_F_X509V3_get_section 112 -#define X509V3_F_X509V3_get_string 113 -#define X509V3_F_X509V3_get_value_bool 114 -#define X509V3_F_X509V3_parse_list 115 -#define X509V3_F_X509_PURPOSE_add 116 -#define X509V3_F_X509_PURPOSE_set 117 -#define X509V3_F_a2i_GENERAL_NAME 118 -#define X509V3_F_copy_email 119 -#define X509V3_F_copy_issuer 120 -#define X509V3_F_do_dirname 121 -#define X509V3_F_do_ext_i2d 122 -#define X509V3_F_do_ext_nconf 123 -#define X509V3_F_gnames_from_sectname 124 -#define X509V3_F_hex_to_string 125 -#define X509V3_F_i2s_ASN1_ENUMERATED 126 -#define X509V3_F_i2s_ASN1_IA5STRING 127 -#define X509V3_F_i2s_ASN1_INTEGER 128 -#define X509V3_F_i2v_AUTHORITY_INFO_ACCESS 129 -#define X509V3_F_notice_section 130 -#define X509V3_F_nref_nos 131 -#define X509V3_F_policy_section 132 -#define X509V3_F_process_pci_value 133 -#define X509V3_F_r2i_certpol 134 -#define X509V3_F_r2i_pci 135 -#define X509V3_F_s2i_ASN1_IA5STRING 136 -#define X509V3_F_s2i_ASN1_INTEGER 137 -#define X509V3_F_s2i_ASN1_OCTET_STRING 138 -#define X509V3_F_s2i_skey_id 139 -#define X509V3_F_set_dist_point_name 140 -#define X509V3_F_string_to_hex 141 -#define X509V3_F_v2i_ASN1_BIT_STRING 142 -#define X509V3_F_v2i_AUTHORITY_INFO_ACCESS 143 -#define X509V3_F_v2i_AUTHORITY_KEYID 144 -#define X509V3_F_v2i_BASIC_CONSTRAINTS 145 -#define X509V3_F_v2i_EXTENDED_KEY_USAGE 146 -#define X509V3_F_v2i_GENERAL_NAMES 147 -#define X509V3_F_v2i_GENERAL_NAME_ex 148 -#define X509V3_F_v2i_NAME_CONSTRAINTS 149 -#define X509V3_F_v2i_POLICY_CONSTRAINTS 150 -#define X509V3_F_v2i_POLICY_MAPPINGS 151 -#define X509V3_F_v2i_crld 152 -#define X509V3_F_v2i_idp 153 -#define X509V3_F_v2i_issuer_alt 154 -#define X509V3_F_v2i_subject_alt 155 -#define X509V3_F_v3_generic_extension 156 -#define X509V3_R_BAD_IP_ADDRESS 100 -#define X509V3_R_BAD_OBJECT 101 -#define X509V3_R_BN_DEC2BN_ERROR 102 -#define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 103 -#define X509V3_R_CANNOT_FIND_FREE_FUNCTION 104 -#define X509V3_R_DIRNAME_ERROR 105 -#define X509V3_R_DISTPOINT_ALREADY_SET 106 -#define X509V3_R_DUPLICATE_ZONE_ID 107 -#define X509V3_R_ERROR_CONVERTING_ZONE 108 -#define X509V3_R_ERROR_CREATING_EXTENSION 109 -#define X509V3_R_ERROR_IN_EXTENSION 110 -#define X509V3_R_EXPECTED_A_SECTION_NAME 111 -#define X509V3_R_EXTENSION_EXISTS 112 -#define X509V3_R_EXTENSION_NAME_ERROR 113 -#define X509V3_R_EXTENSION_NOT_FOUND 114 -#define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED 115 -#define X509V3_R_EXTENSION_VALUE_ERROR 116 -#define X509V3_R_ILLEGAL_EMPTY_EXTENSION 117 -#define X509V3_R_ILLEGAL_HEX_DIGIT 118 -#define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG 119 -#define X509V3_R_INVALID_BOOLEAN_STRING 120 -#define X509V3_R_INVALID_EXTENSION_STRING 121 -#define X509V3_R_INVALID_MULTIPLE_RDNS 122 -#define X509V3_R_INVALID_NAME 123 -#define X509V3_R_INVALID_NULL_ARGUMENT 124 -#define X509V3_R_INVALID_NULL_NAME 125 -#define X509V3_R_INVALID_NULL_VALUE 126 -#define X509V3_R_INVALID_NUMBER 127 -#define X509V3_R_INVALID_NUMBERS 128 -#define X509V3_R_INVALID_OBJECT_IDENTIFIER 129 -#define X509V3_R_INVALID_OPTION 130 -#define X509V3_R_INVALID_POLICY_IDENTIFIER 131 -#define X509V3_R_INVALID_PROXY_POLICY_SETTING 132 -#define X509V3_R_INVALID_PURPOSE 133 -#define X509V3_R_INVALID_SECTION 134 -#define X509V3_R_INVALID_SYNTAX 135 -#define X509V3_R_ISSUER_DECODE_ERROR 136 -#define X509V3_R_MISSING_VALUE 137 -#define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS 138 -#define X509V3_R_NO_CONFIG_DATABASE 139 -#define X509V3_R_NO_ISSUER_CERTIFICATE 140 -#define X509V3_R_NO_ISSUER_DETAILS 141 -#define X509V3_R_NO_POLICY_IDENTIFIER 142 -#define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED 143 -#define X509V3_R_NO_PUBLIC_KEY 144 -#define X509V3_R_NO_SUBJECT_DETAILS 145 -#define X509V3_R_ODD_NUMBER_OF_DIGITS 146 -#define X509V3_R_OPERATION_NOT_DEFINED 147 -#define X509V3_R_OTHERNAME_ERROR 148 -#define X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED 149 -#define X509V3_R_POLICY_PATH_LENGTH 150 -#define X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED 151 -#define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 152 -#define X509V3_R_SECTION_NOT_FOUND 153 -#define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS 154 -#define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID 155 -#define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT 156 -#define X509V3_R_UNKNOWN_EXTENSION 157 -#define X509V3_R_UNKNOWN_EXTENSION_NAME 158 -#define X509V3_R_UNKNOWN_OPTION 159 -#define X509V3_R_UNSUPPORTED_OPTION 160 -#define X509V3_R_UNSUPPORTED_TYPE 161 -#define X509V3_R_USER_TOO_LONG 162 - -#endif diff --git a/phonelibs/boringssl/lib/libcrypto_static.a b/phonelibs/boringssl/lib/libcrypto_static.a deleted file mode 100644 index f683cb11d42ead..00000000000000 Binary files a/phonelibs/boringssl/lib/libcrypto_static.a and /dev/null differ diff --git a/phonelibs/boringssl/lib/libssl_static.a b/phonelibs/boringssl/lib/libssl_static.a deleted file mode 100644 index b6c52d03a04e8c..00000000000000 Binary files a/phonelibs/boringssl/lib/libssl_static.a and /dev/null differ diff --git a/phonelibs/bzip2/LICENSE b/phonelibs/bzip2/LICENSE new file mode 100644 index 00000000000000..cc614178cf7958 --- /dev/null +++ b/phonelibs/bzip2/LICENSE @@ -0,0 +1,42 @@ + +-------------------------------------------------------------------------- + +This program, "bzip2", the associated library "libbzip2", and all +documentation, are copyright (C) 1996-2010 Julian R Seward. All +rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + +3. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + +4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Julian Seward, jseward@bzip.org +bzip2/libbzip2 version 1.0.6 of 6 September 2010 + +-------------------------------------------------------------------------- diff --git a/phonelibs/capnp-c/build.txt b/phonelibs/capnp-c/build.txt new file mode 100755 index 00000000000000..a2d55c7cba6ed2 --- /dev/null +++ b/phonelibs/capnp-c/build.txt @@ -0,0 +1,16 @@ +#!/bin/bash -e + +# on host + +HOSTARCH="$(uname -s | tr '[:upper:]' '[:lower:]')" + +AR="/opt/android-ndk/toolchains/aarch64-linux-android-4.9/prebuilt/$HOSTARCH-x86_64/bin/aarch64-linux-android-ar" +CC="/opt/android-ndk/toolchains/aarch64-linux-android-4.9/prebuilt/$HOSTARCH-x86_64/bin/aarch64-linux-android-gcc --sysroot=/opt/android-ndk/platforms/android-21/arch-arm64" + +git clone git@github.com:commaai/c-capnproto.git +cd c-capnproto + +$CC -c lib/capn-malloc.c +$CC -c lib/capn-stream.c +$CC -c lib/capn.c +$AR rcs libcapn.a capn-malloc.o capn-stream.o capn.o diff --git a/phonelibs/curl/build.txt b/phonelibs/curl/build.txt deleted file mode 100644 index def0763b46f828..00000000000000 --- a/phonelibs/curl/build.txt +++ /dev/null @@ -1,5 +0,0 @@ -# with neos tree -cd ~/android/system -mka libcurl - -cp ~/android/system/out/target/product/oneplus3/obj/STATIC_LIBRARIES/libcurl_intermediates/libcurl.a lib/ diff --git a/phonelibs/curl/include/Makefile.am b/phonelibs/curl/include/Makefile.am deleted file mode 100644 index 3b24860299525e..00000000000000 --- a/phonelibs/curl/include/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -SUBDIRS = curl - -EXTRA_DIST = README - -AUTOMAKE_OPTIONS = foreign no-dependencies diff --git a/phonelibs/curl/include/README b/phonelibs/curl/include/README deleted file mode 100644 index 3e52a1d0a6cb13..00000000000000 --- a/phonelibs/curl/include/README +++ /dev/null @@ -1,55 +0,0 @@ - _ _ ____ _ - ___| | | | _ \| | - / __| | | | |_) | | - | (__| |_| | _ <| |___ - \___|\___/|_| \_\_____| - -Include files for libcurl, external users. - -They're all placed in the curl subdirectory here for better fit in any kind -of environment. You must include files from here using... - - #include - -... style and point the compiler's include path to the directory holding the -curl subdirectory. It makes it more likely to survive future modifications. - -NOTE FOR LIBCURL HACKERS - -The following notes apply to libcurl version 7.19.0 and later. - -* The distributed curl/curlbuild.h file is only intended to be used on systems - which can not run the also distributed configure script. - -* The distributed curlbuild.h file is generated as a copy of curlbuild.h.dist - when the libcurl source code distribution archive file is originally created. - -* If you check out from git on a non-configure platform, you must run the - appropriate buildconf* script to set up curlbuild.h and other local files - before being able of compiling the library. - -* On systems capable of running the configure script, the configure process - will overwrite the distributed include/curl/curlbuild.h file with one that - is suitable and specific to the library being configured and built, which - is generated from the include/curl/curlbuild.h.in template file. - -* If you intend to distribute an already compiled libcurl library you _MUST_ - also distribute along with it the generated curl/curlbuild.h which has been - used to compile it. Otherwise the library will be of no use for the users of - the library that you have built. It is _your_ responsibility to provide this - file. No one at the cURL project can know how you have built the library. - -* File curl/curlbuild.h includes platform and configuration dependent info, - and must not be modified by anyone. Configure script generates it for you. - -* We cannot assume anything else but very basic compiler features being - present. While libcurl requires an ANSI C compiler to build, some of the - earlier ANSI compilers clearly can't deal with some preprocessor operators. - -* Newlines must remain unix-style for older compilers' sake. - -* Comments must be written in the old-style /* unnested C-fashion */ - -To figure out how to do good and portable checks for features, operating -systems or specific hardwarare, a very good resource is Bjorn Reese's -collection at http://predef.sf.net/ diff --git a/phonelibs/curl/include/curl/.gitignore b/phonelibs/curl/include/curl/.gitignore deleted file mode 100644 index 5f3bc3ce01b9a6..00000000000000 --- a/phonelibs/curl/include/curl/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -stamp-h2 -stamp-h3 -curlver.h.dist diff --git a/phonelibs/curl/include/curl/Makefile.am b/phonelibs/curl/include/curl/Makefile.am deleted file mode 100644 index 86e8b78344de31..00000000000000 --- a/phonelibs/curl/include/curl/Makefile.am +++ /dev/null @@ -1,53 +0,0 @@ -#*************************************************************************** -# _ _ ____ _ -# Project ___| | | | _ \| | -# / __| | | | |_) | | -# | (__| |_| | _ <| |___ -# \___|\___/|_| \_\_____| -# -# Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. -# -# This software is licensed as described in the file COPYING, which -# you should have received as part of this distribution. The terms -# are also available at http://curl.haxx.se/docs/copyright.html. -# -# You may opt to use, copy, modify, merge, publish, distribute and/or sell -# copies of the Software, and permit persons to whom the Software is -# furnished to do so, under the terms of the COPYING file. -# -# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY -# KIND, either express or implied. -# -########################################################################### -pkginclude_HEADERS = \ - curl.h curlver.h easy.h mprintf.h stdcheaders.h multi.h \ - typecheck-gcc.h curlbuild.h curlrules.h - -pkgincludedir= $(includedir)/curl - -# curlbuild.h does not exist in the git tree. When the original libcurl -# source code distribution archive file is created, curlbuild.h.dist is -# renamed to curlbuild.h and included in the tarball so that it can be -# used directly on non-configure systems. -# -# The distributed curlbuild.h will be overwritten on configure systems -# when the configure script runs, with one that is suitable and specific -# to the library being configured and built. -# -# curlbuild.h.in is the distributed template file from which the configure -# script creates curlbuild.h at library configuration time, overwiting the -# one included in the distribution archive. -# -# curlbuild.h.dist is not included in the source code distribution archive. - -EXTRA_DIST = curlbuild.h.in - -DISTCLEANFILES = curlbuild.h - -checksrc: - @@PERL@ $(top_srcdir)/lib/checksrc.pl -Wcurlbuild.h -D$(top_srcdir)/include/curl $(pkginclude_HEADERS) $(EXTRA_DIST) - -if CURLDEBUG -# for debug builds, we scan the sources on all regular make invokes -all-local: checksrc -endif diff --git a/phonelibs/curl/include/curl/curl.h b/phonelibs/curl/include/curl/curl.h deleted file mode 100644 index eab2f6e99a541c..00000000000000 --- a/phonelibs/curl/include/curl/curl.h +++ /dev/null @@ -1,2376 +0,0 @@ -#ifndef __CURL_CURL_H -#define __CURL_CURL_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -/* - * If you have libcurl problems, all docs and details are found here: - * http://curl.haxx.se/libcurl/ - * - * curl-library mailing list subscription and unsubscription web interface: - * http://cool.haxx.se/mailman/listinfo/curl-library/ - */ - -#include "curlver.h" /* libcurl version defines */ -#include "curlbuild.h" /* libcurl build definitions */ -#include "curlrules.h" /* libcurl rules enforcement */ - -/* - * Define WIN32 when build target is Win32 API - */ - -#if (defined(_WIN32) || defined(__WIN32__)) && \ - !defined(WIN32) && !defined(__SYMBIAN32__) -#define WIN32 -#endif - -#include -#include - -#if defined(__FreeBSD__) && (__FreeBSD__ >= 2) -/* Needed for __FreeBSD_version symbol definition */ -#include -#endif - -/* The include stuff here below is mainly for time_t! */ -#include -#include - -#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__CYGWIN__) -#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H) || defined(__LWIP_OPT_H__)) -/* The check above prevents the winsock2 inclusion if winsock.h already was - included, since they can't co-exist without problems */ -#include -#include -#endif -#endif - -/* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish - libc5-based Linux systems. Only include it on systems that are known to - require it! */ -#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \ - defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \ - defined(ANDROID) || defined(__ANDROID__) || defined(__OpenBSD__) || \ - (defined(__FreeBSD_version) && (__FreeBSD_version < 800000)) -#include -#endif - -#if !defined(WIN32) && !defined(_WIN32_WCE) -#include -#endif - -#if !defined(WIN32) && !defined(__WATCOMC__) && !defined(__VXWORKS__) -#include -#endif - -#ifdef __BEOS__ -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void CURL; - -/* - * libcurl external API function linkage decorations. - */ - -#ifdef CURL_STATICLIB -# define CURL_EXTERN -#elif defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__) -# if defined(BUILDING_LIBCURL) -# define CURL_EXTERN __declspec(dllexport) -# else -# define CURL_EXTERN __declspec(dllimport) -# endif -#elif defined(BUILDING_LIBCURL) && defined(CURL_HIDDEN_SYMBOLS) -# define CURL_EXTERN CURL_EXTERN_SYMBOL -#else -# define CURL_EXTERN -#endif - -#ifndef curl_socket_typedef -/* socket typedef */ -#if defined(WIN32) && !defined(__LWIP_OPT_H__) -typedef SOCKET curl_socket_t; -#define CURL_SOCKET_BAD INVALID_SOCKET -#else -typedef int curl_socket_t; -#define CURL_SOCKET_BAD -1 -#endif -#define curl_socket_typedef -#endif /* curl_socket_typedef */ - -struct curl_httppost { - struct curl_httppost *next; /* next entry in the list */ - char *name; /* pointer to allocated name */ - long namelength; /* length of name length */ - char *contents; /* pointer to allocated data contents */ - long contentslength; /* length of contents field */ - char *buffer; /* pointer to allocated buffer contents */ - long bufferlength; /* length of buffer field */ - char *contenttype; /* Content-Type */ - struct curl_slist* contentheader; /* list of extra headers for this form */ - struct curl_httppost *more; /* if one field name has more than one - file, this link should link to following - files */ - long flags; /* as defined below */ -#define HTTPPOST_FILENAME (1<<0) /* specified content is a file name */ -#define HTTPPOST_READFILE (1<<1) /* specified content is a file name */ -#define HTTPPOST_PTRNAME (1<<2) /* name is only stored pointer - do not free in formfree */ -#define HTTPPOST_PTRCONTENTS (1<<3) /* contents is only stored pointer - do not free in formfree */ -#define HTTPPOST_BUFFER (1<<4) /* upload file from buffer */ -#define HTTPPOST_PTRBUFFER (1<<5) /* upload file from pointer contents */ -#define HTTPPOST_CALLBACK (1<<6) /* upload file contents by using the - regular read callback to get the data - and pass the given pointer as custom - pointer */ - - char *showfilename; /* The file name to show. If not set, the - actual file name will be used (if this - is a file part) */ - void *userp; /* custom pointer used for - HTTPPOST_CALLBACK posts */ -}; - -/* This is the CURLOPT_PROGRESSFUNCTION callback proto. It is now considered - deprecated but was the only choice up until 7.31.0 */ -typedef int (*curl_progress_callback)(void *clientp, - double dltotal, - double dlnow, - double ultotal, - double ulnow); - -/* This is the CURLOPT_XFERINFOFUNCTION callback proto. It was introduced in - 7.32.0, it avoids floating point and provides more detailed information. */ -typedef int (*curl_xferinfo_callback)(void *clientp, - curl_off_t dltotal, - curl_off_t dlnow, - curl_off_t ultotal, - curl_off_t ulnow); - -#ifndef CURL_MAX_WRITE_SIZE - /* Tests have proven that 20K is a very bad buffer size for uploads on - Windows, while 16K for some odd reason performed a lot better. - We do the ifndef check to allow this value to easier be changed at build - time for those who feel adventurous. The practical minimum is about - 400 bytes since libcurl uses a buffer of this size as a scratch area - (unrelated to network send operations). */ -#define CURL_MAX_WRITE_SIZE 16384 -#endif - -#ifndef CURL_MAX_HTTP_HEADER -/* The only reason to have a max limit for this is to avoid the risk of a bad - server feeding libcurl with a never-ending header that will cause reallocs - infinitely */ -#define CURL_MAX_HTTP_HEADER (100*1024) -#endif - -/* This is a magic return code for the write callback that, when returned, - will signal libcurl to pause receiving on the current transfer. */ -#define CURL_WRITEFUNC_PAUSE 0x10000001 - -typedef size_t (*curl_write_callback)(char *buffer, - size_t size, - size_t nitems, - void *outstream); - - - -/* enumeration of file types */ -typedef enum { - CURLFILETYPE_FILE = 0, - CURLFILETYPE_DIRECTORY, - CURLFILETYPE_SYMLINK, - CURLFILETYPE_DEVICE_BLOCK, - CURLFILETYPE_DEVICE_CHAR, - CURLFILETYPE_NAMEDPIPE, - CURLFILETYPE_SOCKET, - CURLFILETYPE_DOOR, /* is possible only on Sun Solaris now */ - - CURLFILETYPE_UNKNOWN /* should never occur */ -} curlfiletype; - -#define CURLFINFOFLAG_KNOWN_FILENAME (1<<0) -#define CURLFINFOFLAG_KNOWN_FILETYPE (1<<1) -#define CURLFINFOFLAG_KNOWN_TIME (1<<2) -#define CURLFINFOFLAG_KNOWN_PERM (1<<3) -#define CURLFINFOFLAG_KNOWN_UID (1<<4) -#define CURLFINFOFLAG_KNOWN_GID (1<<5) -#define CURLFINFOFLAG_KNOWN_SIZE (1<<6) -#define CURLFINFOFLAG_KNOWN_HLINKCOUNT (1<<7) - -/* Content of this structure depends on information which is known and is - achievable (e.g. by FTP LIST parsing). Please see the url_easy_setopt(3) man - page for callbacks returning this structure -- some fields are mandatory, - some others are optional. The FLAG field has special meaning. */ -struct curl_fileinfo { - char *filename; - curlfiletype filetype; - time_t time; - unsigned int perm; - int uid; - int gid; - curl_off_t size; - long int hardlinks; - - struct { - /* If some of these fields is not NULL, it is a pointer to b_data. */ - char *time; - char *perm; - char *user; - char *group; - char *target; /* pointer to the target filename of a symlink */ - } strings; - - unsigned int flags; - - /* used internally */ - char * b_data; - size_t b_size; - size_t b_used; -}; - -/* return codes for CURLOPT_CHUNK_BGN_FUNCTION */ -#define CURL_CHUNK_BGN_FUNC_OK 0 -#define CURL_CHUNK_BGN_FUNC_FAIL 1 /* tell the lib to end the task */ -#define CURL_CHUNK_BGN_FUNC_SKIP 2 /* skip this chunk over */ - -/* if splitting of data transfer is enabled, this callback is called before - download of an individual chunk started. Note that parameter "remains" works - only for FTP wildcard downloading (for now), otherwise is not used */ -typedef long (*curl_chunk_bgn_callback)(const void *transfer_info, - void *ptr, - int remains); - -/* return codes for CURLOPT_CHUNK_END_FUNCTION */ -#define CURL_CHUNK_END_FUNC_OK 0 -#define CURL_CHUNK_END_FUNC_FAIL 1 /* tell the lib to end the task */ - -/* If splitting of data transfer is enabled this callback is called after - download of an individual chunk finished. - Note! After this callback was set then it have to be called FOR ALL chunks. - Even if downloading of this chunk was skipped in CHUNK_BGN_FUNC. - This is the reason why we don't need "transfer_info" parameter in this - callback and we are not interested in "remains" parameter too. */ -typedef long (*curl_chunk_end_callback)(void *ptr); - -/* return codes for FNMATCHFUNCTION */ -#define CURL_FNMATCHFUNC_MATCH 0 /* string corresponds to the pattern */ -#define CURL_FNMATCHFUNC_NOMATCH 1 /* pattern doesn't match the string */ -#define CURL_FNMATCHFUNC_FAIL 2 /* an error occurred */ - -/* callback type for wildcard downloading pattern matching. If the - string matches the pattern, return CURL_FNMATCHFUNC_MATCH value, etc. */ -typedef int (*curl_fnmatch_callback)(void *ptr, - const char *pattern, - const char *string); - -/* These are the return codes for the seek callbacks */ -#define CURL_SEEKFUNC_OK 0 -#define CURL_SEEKFUNC_FAIL 1 /* fail the entire transfer */ -#define CURL_SEEKFUNC_CANTSEEK 2 /* tell libcurl seeking can't be done, so - libcurl might try other means instead */ -typedef int (*curl_seek_callback)(void *instream, - curl_off_t offset, - int origin); /* 'whence' */ - -/* This is a return code for the read callback that, when returned, will - signal libcurl to immediately abort the current transfer. */ -#define CURL_READFUNC_ABORT 0x10000000 -/* This is a return code for the read callback that, when returned, will - signal libcurl to pause sending data on the current transfer. */ -#define CURL_READFUNC_PAUSE 0x10000001 - -typedef size_t (*curl_read_callback)(char *buffer, - size_t size, - size_t nitems, - void *instream); - -typedef enum { - CURLSOCKTYPE_IPCXN, /* socket created for a specific IP connection */ - CURLSOCKTYPE_ACCEPT, /* socket created by accept() call */ - CURLSOCKTYPE_LAST /* never use */ -} curlsocktype; - -/* The return code from the sockopt_callback can signal information back - to libcurl: */ -#define CURL_SOCKOPT_OK 0 -#define CURL_SOCKOPT_ERROR 1 /* causes libcurl to abort and return - CURLE_ABORTED_BY_CALLBACK */ -#define CURL_SOCKOPT_ALREADY_CONNECTED 2 - -typedef int (*curl_sockopt_callback)(void *clientp, - curl_socket_t curlfd, - curlsocktype purpose); - -struct curl_sockaddr { - int family; - int socktype; - int protocol; - unsigned int addrlen; /* addrlen was a socklen_t type before 7.18.0 but it - turned really ugly and painful on the systems that - lack this type */ - struct sockaddr addr; -}; - -typedef curl_socket_t -(*curl_opensocket_callback)(void *clientp, - curlsocktype purpose, - struct curl_sockaddr *address); - -typedef int -(*curl_closesocket_callback)(void *clientp, curl_socket_t item); - -typedef enum { - CURLIOE_OK, /* I/O operation successful */ - CURLIOE_UNKNOWNCMD, /* command was unknown to callback */ - CURLIOE_FAILRESTART, /* failed to restart the read */ - CURLIOE_LAST /* never use */ -} curlioerr; - -typedef enum { - CURLIOCMD_NOP, /* no operation */ - CURLIOCMD_RESTARTREAD, /* restart the read stream from start */ - CURLIOCMD_LAST /* never use */ -} curliocmd; - -typedef curlioerr (*curl_ioctl_callback)(CURL *handle, - int cmd, - void *clientp); - -/* - * The following typedef's are signatures of malloc, free, realloc, strdup and - * calloc respectively. Function pointers of these types can be passed to the - * curl_global_init_mem() function to set user defined memory management - * callback routines. - */ -typedef void *(*curl_malloc_callback)(size_t size); -typedef void (*curl_free_callback)(void *ptr); -typedef void *(*curl_realloc_callback)(void *ptr, size_t size); -typedef char *(*curl_strdup_callback)(const char *str); -typedef void *(*curl_calloc_callback)(size_t nmemb, size_t size); - -/* the kind of data that is passed to information_callback*/ -typedef enum { - CURLINFO_TEXT = 0, - CURLINFO_HEADER_IN, /* 1 */ - CURLINFO_HEADER_OUT, /* 2 */ - CURLINFO_DATA_IN, /* 3 */ - CURLINFO_DATA_OUT, /* 4 */ - CURLINFO_SSL_DATA_IN, /* 5 */ - CURLINFO_SSL_DATA_OUT, /* 6 */ - CURLINFO_END -} curl_infotype; - -typedef int (*curl_debug_callback) - (CURL *handle, /* the handle/transfer this concerns */ - curl_infotype type, /* what kind of data */ - char *data, /* points to the data */ - size_t size, /* size of the data pointed to */ - void *userptr); /* whatever the user please */ - -/* All possible error codes from all sorts of curl functions. Future versions - may return other values, stay prepared. - - Always add new return codes last. Never *EVER* remove any. The return - codes must remain the same! - */ - -typedef enum { - CURLE_OK = 0, - CURLE_UNSUPPORTED_PROTOCOL, /* 1 */ - CURLE_FAILED_INIT, /* 2 */ - CURLE_URL_MALFORMAT, /* 3 */ - CURLE_NOT_BUILT_IN, /* 4 - [was obsoleted in August 2007 for - 7.17.0, reused in April 2011 for 7.21.5] */ - CURLE_COULDNT_RESOLVE_PROXY, /* 5 */ - CURLE_COULDNT_RESOLVE_HOST, /* 6 */ - CURLE_COULDNT_CONNECT, /* 7 */ - CURLE_FTP_WEIRD_SERVER_REPLY, /* 8 */ - CURLE_REMOTE_ACCESS_DENIED, /* 9 a service was denied by the server - due to lack of access - when login fails - this is not returned. */ - CURLE_FTP_ACCEPT_FAILED, /* 10 - [was obsoleted in April 2006 for - 7.15.4, reused in Dec 2011 for 7.24.0]*/ - CURLE_FTP_WEIRD_PASS_REPLY, /* 11 */ - CURLE_FTP_ACCEPT_TIMEOUT, /* 12 - timeout occurred accepting server - [was obsoleted in August 2007 for 7.17.0, - reused in Dec 2011 for 7.24.0]*/ - CURLE_FTP_WEIRD_PASV_REPLY, /* 13 */ - CURLE_FTP_WEIRD_227_FORMAT, /* 14 */ - CURLE_FTP_CANT_GET_HOST, /* 15 */ - CURLE_HTTP2, /* 16 - A problem in the http2 framing layer. - [was obsoleted in August 2007 for 7.17.0, - reused in July 2014 for 7.38.0] */ - CURLE_FTP_COULDNT_SET_TYPE, /* 17 */ - CURLE_PARTIAL_FILE, /* 18 */ - CURLE_FTP_COULDNT_RETR_FILE, /* 19 */ - CURLE_OBSOLETE20, /* 20 - NOT USED */ - CURLE_QUOTE_ERROR, /* 21 - quote command failure */ - CURLE_HTTP_RETURNED_ERROR, /* 22 */ - CURLE_WRITE_ERROR, /* 23 */ - CURLE_OBSOLETE24, /* 24 - NOT USED */ - CURLE_UPLOAD_FAILED, /* 25 - failed upload "command" */ - CURLE_READ_ERROR, /* 26 - couldn't open/read from file */ - CURLE_OUT_OF_MEMORY, /* 27 */ - /* Note: CURLE_OUT_OF_MEMORY may sometimes indicate a conversion error - instead of a memory allocation error if CURL_DOES_CONVERSIONS - is defined - */ - CURLE_OPERATION_TIMEDOUT, /* 28 - the timeout time was reached */ - CURLE_OBSOLETE29, /* 29 - NOT USED */ - CURLE_FTP_PORT_FAILED, /* 30 - FTP PORT operation failed */ - CURLE_FTP_COULDNT_USE_REST, /* 31 - the REST command failed */ - CURLE_OBSOLETE32, /* 32 - NOT USED */ - CURLE_RANGE_ERROR, /* 33 - RANGE "command" didn't work */ - CURLE_HTTP_POST_ERROR, /* 34 */ - CURLE_SSL_CONNECT_ERROR, /* 35 - wrong when connecting with SSL */ - CURLE_BAD_DOWNLOAD_RESUME, /* 36 - couldn't resume download */ - CURLE_FILE_COULDNT_READ_FILE, /* 37 */ - CURLE_LDAP_CANNOT_BIND, /* 38 */ - CURLE_LDAP_SEARCH_FAILED, /* 39 */ - CURLE_OBSOLETE40, /* 40 - NOT USED */ - CURLE_FUNCTION_NOT_FOUND, /* 41 */ - CURLE_ABORTED_BY_CALLBACK, /* 42 */ - CURLE_BAD_FUNCTION_ARGUMENT, /* 43 */ - CURLE_OBSOLETE44, /* 44 - NOT USED */ - CURLE_INTERFACE_FAILED, /* 45 - CURLOPT_INTERFACE failed */ - CURLE_OBSOLETE46, /* 46 - NOT USED */ - CURLE_TOO_MANY_REDIRECTS , /* 47 - catch endless re-direct loops */ - CURLE_UNKNOWN_OPTION, /* 48 - User specified an unknown option */ - CURLE_TELNET_OPTION_SYNTAX , /* 49 - Malformed telnet option */ - CURLE_OBSOLETE50, /* 50 - NOT USED */ - CURLE_PEER_FAILED_VERIFICATION, /* 51 - peer's certificate or fingerprint - wasn't verified fine */ - CURLE_GOT_NOTHING, /* 52 - when this is a specific error */ - CURLE_SSL_ENGINE_NOTFOUND, /* 53 - SSL crypto engine not found */ - CURLE_SSL_ENGINE_SETFAILED, /* 54 - can not set SSL crypto engine as - default */ - CURLE_SEND_ERROR, /* 55 - failed sending network data */ - CURLE_RECV_ERROR, /* 56 - failure in receiving network data */ - CURLE_OBSOLETE57, /* 57 - NOT IN USE */ - CURLE_SSL_CERTPROBLEM, /* 58 - problem with the local certificate */ - CURLE_SSL_CIPHER, /* 59 - couldn't use specified cipher */ - CURLE_SSL_CACERT, /* 60 - problem with the CA cert (path?) */ - CURLE_BAD_CONTENT_ENCODING, /* 61 - Unrecognized/bad encoding */ - CURLE_LDAP_INVALID_URL, /* 62 - Invalid LDAP URL */ - CURLE_FILESIZE_EXCEEDED, /* 63 - Maximum file size exceeded */ - CURLE_USE_SSL_FAILED, /* 64 - Requested FTP SSL level failed */ - CURLE_SEND_FAIL_REWIND, /* 65 - Sending the data requires a rewind - that failed */ - CURLE_SSL_ENGINE_INITFAILED, /* 66 - failed to initialise ENGINE */ - CURLE_LOGIN_DENIED, /* 67 - user, password or similar was not - accepted and we failed to login */ - CURLE_TFTP_NOTFOUND, /* 68 - file not found on server */ - CURLE_TFTP_PERM, /* 69 - permission problem on server */ - CURLE_REMOTE_DISK_FULL, /* 70 - out of disk space on server */ - CURLE_TFTP_ILLEGAL, /* 71 - Illegal TFTP operation */ - CURLE_TFTP_UNKNOWNID, /* 72 - Unknown transfer ID */ - CURLE_REMOTE_FILE_EXISTS, /* 73 - File already exists */ - CURLE_TFTP_NOSUCHUSER, /* 74 - No such user */ - CURLE_CONV_FAILED, /* 75 - conversion failed */ - CURLE_CONV_REQD, /* 76 - caller must register conversion - callbacks using curl_easy_setopt options - CURLOPT_CONV_FROM_NETWORK_FUNCTION, - CURLOPT_CONV_TO_NETWORK_FUNCTION, and - CURLOPT_CONV_FROM_UTF8_FUNCTION */ - CURLE_SSL_CACERT_BADFILE, /* 77 - could not load CACERT file, missing - or wrong format */ - CURLE_REMOTE_FILE_NOT_FOUND, /* 78 - remote file not found */ - CURLE_SSH, /* 79 - error from the SSH layer, somewhat - generic so the error message will be of - interest when this has happened */ - - CURLE_SSL_SHUTDOWN_FAILED, /* 80 - Failed to shut down the SSL - connection */ - CURLE_AGAIN, /* 81 - socket is not ready for send/recv, - wait till it's ready and try again (Added - in 7.18.2) */ - CURLE_SSL_CRL_BADFILE, /* 82 - could not load CRL file, missing or - wrong format (Added in 7.19.0) */ - CURLE_SSL_ISSUER_ERROR, /* 83 - Issuer check failed. (Added in - 7.19.0) */ - CURLE_FTP_PRET_FAILED, /* 84 - a PRET command failed */ - CURLE_RTSP_CSEQ_ERROR, /* 85 - mismatch of RTSP CSeq numbers */ - CURLE_RTSP_SESSION_ERROR, /* 86 - mismatch of RTSP Session Ids */ - CURLE_FTP_BAD_FILE_LIST, /* 87 - unable to parse FTP file list */ - CURLE_CHUNK_FAILED, /* 88 - chunk callback reported error */ - CURLE_NO_CONNECTION_AVAILABLE, /* 89 - No connection available, the - session will be queued */ - CURLE_SSL_PINNEDPUBKEYNOTMATCH, /* 90 - specified pinned public key did not - match */ - CURLE_SSL_INVALIDCERTSTATUS, /* 91 - invalid certificate status */ - CURL_LAST /* never use! */ -} CURLcode; - -#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all - the obsolete stuff removed! */ - -/* Previously obsolete error code re-used in 7.38.0 */ -#define CURLE_OBSOLETE16 CURLE_HTTP2 - -/* Previously obsolete error codes re-used in 7.24.0 */ -#define CURLE_OBSOLETE10 CURLE_FTP_ACCEPT_FAILED -#define CURLE_OBSOLETE12 CURLE_FTP_ACCEPT_TIMEOUT - -/* compatibility with older names */ -#define CURLOPT_ENCODING CURLOPT_ACCEPT_ENCODING - -/* The following were added in 7.21.5, April 2011 */ -#define CURLE_UNKNOWN_TELNET_OPTION CURLE_UNKNOWN_OPTION - -/* The following were added in 7.17.1 */ -/* These are scheduled to disappear by 2009 */ -#define CURLE_SSL_PEER_CERTIFICATE CURLE_PEER_FAILED_VERIFICATION - -/* The following were added in 7.17.0 */ -/* These are scheduled to disappear by 2009 */ -#define CURLE_OBSOLETE CURLE_OBSOLETE50 /* no one should be using this! */ -#define CURLE_BAD_PASSWORD_ENTERED CURLE_OBSOLETE46 -#define CURLE_BAD_CALLING_ORDER CURLE_OBSOLETE44 -#define CURLE_FTP_USER_PASSWORD_INCORRECT CURLE_OBSOLETE10 -#define CURLE_FTP_CANT_RECONNECT CURLE_OBSOLETE16 -#define CURLE_FTP_COULDNT_GET_SIZE CURLE_OBSOLETE32 -#define CURLE_FTP_COULDNT_SET_ASCII CURLE_OBSOLETE29 -#define CURLE_FTP_WEIRD_USER_REPLY CURLE_OBSOLETE12 -#define CURLE_FTP_WRITE_ERROR CURLE_OBSOLETE20 -#define CURLE_LIBRARY_NOT_FOUND CURLE_OBSOLETE40 -#define CURLE_MALFORMAT_USER CURLE_OBSOLETE24 -#define CURLE_SHARE_IN_USE CURLE_OBSOLETE57 -#define CURLE_URL_MALFORMAT_USER CURLE_NOT_BUILT_IN - -#define CURLE_FTP_ACCESS_DENIED CURLE_REMOTE_ACCESS_DENIED -#define CURLE_FTP_COULDNT_SET_BINARY CURLE_FTP_COULDNT_SET_TYPE -#define CURLE_FTP_QUOTE_ERROR CURLE_QUOTE_ERROR -#define CURLE_TFTP_DISKFULL CURLE_REMOTE_DISK_FULL -#define CURLE_TFTP_EXISTS CURLE_REMOTE_FILE_EXISTS -#define CURLE_HTTP_RANGE_ERROR CURLE_RANGE_ERROR -#define CURLE_FTP_SSL_FAILED CURLE_USE_SSL_FAILED - -/* The following were added earlier */ - -#define CURLE_OPERATION_TIMEOUTED CURLE_OPERATION_TIMEDOUT - -#define CURLE_HTTP_NOT_FOUND CURLE_HTTP_RETURNED_ERROR -#define CURLE_HTTP_PORT_FAILED CURLE_INTERFACE_FAILED -#define CURLE_FTP_COULDNT_STOR_FILE CURLE_UPLOAD_FAILED - -#define CURLE_FTP_PARTIAL_FILE CURLE_PARTIAL_FILE -#define CURLE_FTP_BAD_DOWNLOAD_RESUME CURLE_BAD_DOWNLOAD_RESUME - -/* This was the error code 50 in 7.7.3 and a few earlier versions, this - is no longer used by libcurl but is instead #defined here only to not - make programs break */ -#define CURLE_ALREADY_COMPLETE 99999 - -/* Provide defines for really old option names */ -#define CURLOPT_FILE CURLOPT_WRITEDATA /* name changed in 7.9.7 */ -#define CURLOPT_INFILE CURLOPT_READDATA /* name changed in 7.9.7 */ -#define CURLOPT_WRITEHEADER CURLOPT_HEADERDATA - -/* Since long deprecated options with no code in the lib that does anything - with them. */ -#define CURLOPT_WRITEINFO CURLOPT_OBSOLETE40 -#define CURLOPT_CLOSEPOLICY CURLOPT_OBSOLETE72 - -#endif /*!CURL_NO_OLDIES*/ - -/* This prototype applies to all conversion callbacks */ -typedef CURLcode (*curl_conv_callback)(char *buffer, size_t length); - -typedef CURLcode (*curl_ssl_ctx_callback)(CURL *curl, /* easy handle */ - void *ssl_ctx, /* actually an - OpenSSL SSL_CTX */ - void *userptr); - -typedef enum { - CURLPROXY_HTTP = 0, /* added in 7.10, new in 7.19.4 default is to use - CONNECT HTTP/1.1 */ - CURLPROXY_HTTP_1_0 = 1, /* added in 7.19.4, force to use CONNECT - HTTP/1.0 */ - CURLPROXY_SOCKS4 = 4, /* support added in 7.15.2, enum existed already - in 7.10 */ - CURLPROXY_SOCKS5 = 5, /* added in 7.10 */ - CURLPROXY_SOCKS4A = 6, /* added in 7.18.0 */ - CURLPROXY_SOCKS5_HOSTNAME = 7 /* Use the SOCKS5 protocol but pass along the - host name rather than the IP address. added - in 7.18.0 */ -} curl_proxytype; /* this enum was added in 7.10 */ - -/* - * Bitmasks for CURLOPT_HTTPAUTH and CURLOPT_PROXYAUTH options: - * - * CURLAUTH_NONE - No HTTP authentication - * CURLAUTH_BASIC - HTTP Basic authentication (default) - * CURLAUTH_DIGEST - HTTP Digest authentication - * CURLAUTH_NEGOTIATE - HTTP Negotiate (SPNEGO) authentication - * CURLAUTH_GSSNEGOTIATE - Alias for CURLAUTH_NEGOTIATE (deprecated) - * CURLAUTH_NTLM - HTTP NTLM authentication - * CURLAUTH_DIGEST_IE - HTTP Digest authentication with IE flavour - * CURLAUTH_NTLM_WB - HTTP NTLM authentication delegated to winbind helper - * CURLAUTH_ONLY - Use together with a single other type to force no - * authentication or just that single type - * CURLAUTH_ANY - All fine types set - * CURLAUTH_ANYSAFE - All fine types except Basic - */ - -#define CURLAUTH_NONE ((unsigned long)0) -#define CURLAUTH_BASIC (((unsigned long)1)<<0) -#define CURLAUTH_DIGEST (((unsigned long)1)<<1) -#define CURLAUTH_NEGOTIATE (((unsigned long)1)<<2) -/* Deprecated since the advent of CURLAUTH_NEGOTIATE */ -#define CURLAUTH_GSSNEGOTIATE CURLAUTH_NEGOTIATE -#define CURLAUTH_NTLM (((unsigned long)1)<<3) -#define CURLAUTH_DIGEST_IE (((unsigned long)1)<<4) -#define CURLAUTH_NTLM_WB (((unsigned long)1)<<5) -#define CURLAUTH_ONLY (((unsigned long)1)<<31) -#define CURLAUTH_ANY (~CURLAUTH_DIGEST_IE) -#define CURLAUTH_ANYSAFE (~(CURLAUTH_BASIC|CURLAUTH_DIGEST_IE)) - -#define CURLSSH_AUTH_ANY ~0 /* all types supported by the server */ -#define CURLSSH_AUTH_NONE 0 /* none allowed, silly but complete */ -#define CURLSSH_AUTH_PUBLICKEY (1<<0) /* public/private key files */ -#define CURLSSH_AUTH_PASSWORD (1<<1) /* password */ -#define CURLSSH_AUTH_HOST (1<<2) /* host key files */ -#define CURLSSH_AUTH_KEYBOARD (1<<3) /* keyboard interactive */ -#define CURLSSH_AUTH_AGENT (1<<4) /* agent (ssh-agent, pageant...) */ -#define CURLSSH_AUTH_DEFAULT CURLSSH_AUTH_ANY - -#define CURLGSSAPI_DELEGATION_NONE 0 /* no delegation (default) */ -#define CURLGSSAPI_DELEGATION_POLICY_FLAG (1<<0) /* if permitted by policy */ -#define CURLGSSAPI_DELEGATION_FLAG (1<<1) /* delegate always */ - -#define CURL_ERROR_SIZE 256 - -enum curl_khtype { - CURLKHTYPE_UNKNOWN, - CURLKHTYPE_RSA1, - CURLKHTYPE_RSA, - CURLKHTYPE_DSS -}; - -struct curl_khkey { - const char *key; /* points to a zero-terminated string encoded with base64 - if len is zero, otherwise to the "raw" data */ - size_t len; - enum curl_khtype keytype; -}; - -/* this is the set of return values expected from the curl_sshkeycallback - callback */ -enum curl_khstat { - CURLKHSTAT_FINE_ADD_TO_FILE, - CURLKHSTAT_FINE, - CURLKHSTAT_REJECT, /* reject the connection, return an error */ - CURLKHSTAT_DEFER, /* do not accept it, but we can't answer right now so - this causes a CURLE_DEFER error but otherwise the - connection will be left intact etc */ - CURLKHSTAT_LAST /* not for use, only a marker for last-in-list */ -}; - -/* this is the set of status codes pass in to the callback */ -enum curl_khmatch { - CURLKHMATCH_OK, /* match */ - CURLKHMATCH_MISMATCH, /* host found, key mismatch! */ - CURLKHMATCH_MISSING, /* no matching host/key found */ - CURLKHMATCH_LAST /* not for use, only a marker for last-in-list */ -}; - -typedef int - (*curl_sshkeycallback) (CURL *easy, /* easy handle */ - const struct curl_khkey *knownkey, /* known */ - const struct curl_khkey *foundkey, /* found */ - enum curl_khmatch, /* libcurl's view on the keys */ - void *clientp); /* custom pointer passed from app */ - -/* parameter for the CURLOPT_USE_SSL option */ -typedef enum { - CURLUSESSL_NONE, /* do not attempt to use SSL */ - CURLUSESSL_TRY, /* try using SSL, proceed anyway otherwise */ - CURLUSESSL_CONTROL, /* SSL for the control connection or fail */ - CURLUSESSL_ALL, /* SSL for all communication or fail */ - CURLUSESSL_LAST /* not an option, never use */ -} curl_usessl; - -/* Definition of bits for the CURLOPT_SSL_OPTIONS argument: */ - -/* - ALLOW_BEAST tells libcurl to allow the BEAST SSL vulnerability in the - name of improving interoperability with older servers. Some SSL libraries - have introduced work-arounds for this flaw but those work-arounds sometimes - make the SSL communication fail. To regain functionality with those broken - servers, a user can this way allow the vulnerability back. */ -#define CURLSSLOPT_ALLOW_BEAST (1<<0) - -#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all - the obsolete stuff removed! */ - -/* Backwards compatibility with older names */ -/* These are scheduled to disappear by 2009 */ - -#define CURLFTPSSL_NONE CURLUSESSL_NONE -#define CURLFTPSSL_TRY CURLUSESSL_TRY -#define CURLFTPSSL_CONTROL CURLUSESSL_CONTROL -#define CURLFTPSSL_ALL CURLUSESSL_ALL -#define CURLFTPSSL_LAST CURLUSESSL_LAST -#define curl_ftpssl curl_usessl -#endif /*!CURL_NO_OLDIES*/ - -/* parameter for the CURLOPT_FTP_SSL_CCC option */ -typedef enum { - CURLFTPSSL_CCC_NONE, /* do not send CCC */ - CURLFTPSSL_CCC_PASSIVE, /* Let the server initiate the shutdown */ - CURLFTPSSL_CCC_ACTIVE, /* Initiate the shutdown */ - CURLFTPSSL_CCC_LAST /* not an option, never use */ -} curl_ftpccc; - -/* parameter for the CURLOPT_FTPSSLAUTH option */ -typedef enum { - CURLFTPAUTH_DEFAULT, /* let libcurl decide */ - CURLFTPAUTH_SSL, /* use "AUTH SSL" */ - CURLFTPAUTH_TLS, /* use "AUTH TLS" */ - CURLFTPAUTH_LAST /* not an option, never use */ -} curl_ftpauth; - -/* parameter for the CURLOPT_FTP_CREATE_MISSING_DIRS option */ -typedef enum { - CURLFTP_CREATE_DIR_NONE, /* do NOT create missing dirs! */ - CURLFTP_CREATE_DIR, /* (FTP/SFTP) if CWD fails, try MKD and then CWD - again if MKD succeeded, for SFTP this does - similar magic */ - CURLFTP_CREATE_DIR_RETRY, /* (FTP only) if CWD fails, try MKD and then CWD - again even if MKD failed! */ - CURLFTP_CREATE_DIR_LAST /* not an option, never use */ -} curl_ftpcreatedir; - -/* parameter for the CURLOPT_FTP_FILEMETHOD option */ -typedef enum { - CURLFTPMETHOD_DEFAULT, /* let libcurl pick */ - CURLFTPMETHOD_MULTICWD, /* single CWD operation for each path part */ - CURLFTPMETHOD_NOCWD, /* no CWD at all */ - CURLFTPMETHOD_SINGLECWD, /* one CWD to full dir, then work on file */ - CURLFTPMETHOD_LAST /* not an option, never use */ -} curl_ftpmethod; - -/* bitmask defines for CURLOPT_HEADEROPT */ -#define CURLHEADER_UNIFIED 0 -#define CURLHEADER_SEPARATE (1<<0) - -/* CURLPROTO_ defines are for the CURLOPT_*PROTOCOLS options */ -#define CURLPROTO_HTTP (1<<0) -#define CURLPROTO_HTTPS (1<<1) -#define CURLPROTO_FTP (1<<2) -#define CURLPROTO_FTPS (1<<3) -#define CURLPROTO_SCP (1<<4) -#define CURLPROTO_SFTP (1<<5) -#define CURLPROTO_TELNET (1<<6) -#define CURLPROTO_LDAP (1<<7) -#define CURLPROTO_LDAPS (1<<8) -#define CURLPROTO_DICT (1<<9) -#define CURLPROTO_FILE (1<<10) -#define CURLPROTO_TFTP (1<<11) -#define CURLPROTO_IMAP (1<<12) -#define CURLPROTO_IMAPS (1<<13) -#define CURLPROTO_POP3 (1<<14) -#define CURLPROTO_POP3S (1<<15) -#define CURLPROTO_SMTP (1<<16) -#define CURLPROTO_SMTPS (1<<17) -#define CURLPROTO_RTSP (1<<18) -#define CURLPROTO_RTMP (1<<19) -#define CURLPROTO_RTMPT (1<<20) -#define CURLPROTO_RTMPE (1<<21) -#define CURLPROTO_RTMPTE (1<<22) -#define CURLPROTO_RTMPS (1<<23) -#define CURLPROTO_RTMPTS (1<<24) -#define CURLPROTO_GOPHER (1<<25) -#define CURLPROTO_SMB (1<<26) -#define CURLPROTO_SMBS (1<<27) -#define CURLPROTO_ALL (~0) /* enable everything */ - -/* long may be 32 or 64 bits, but we should never depend on anything else - but 32 */ -#define CURLOPTTYPE_LONG 0 -#define CURLOPTTYPE_OBJECTPOINT 10000 -#define CURLOPTTYPE_FUNCTIONPOINT 20000 -#define CURLOPTTYPE_OFF_T 30000 - -/* name is uppercase CURLOPT_, - type is one of the defined CURLOPTTYPE_ - number is unique identifier */ -#ifdef CINIT -#undef CINIT -#endif - -#ifdef CURL_ISOCPP -#define CINIT(na,t,nu) CURLOPT_ ## na = CURLOPTTYPE_ ## t + nu -#else -/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */ -#define LONG CURLOPTTYPE_LONG -#define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT -#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT -#define OFF_T CURLOPTTYPE_OFF_T -#define CINIT(name,type,number) CURLOPT_/**/name = type + number -#endif - -/* - * This macro-mania below setups the CURLOPT_[what] enum, to be used with - * curl_easy_setopt(). The first argument in the CINIT() macro is the [what] - * word. - */ - -typedef enum { - /* This is the FILE * or void * the regular output should be written to. */ - CINIT(WRITEDATA, OBJECTPOINT, 1), - - /* The full URL to get/put */ - CINIT(URL, OBJECTPOINT, 2), - - /* Port number to connect to, if other than default. */ - CINIT(PORT, LONG, 3), - - /* Name of proxy to use. */ - CINIT(PROXY, OBJECTPOINT, 4), - - /* "user:password;options" to use when fetching. */ - CINIT(USERPWD, OBJECTPOINT, 5), - - /* "user:password" to use with proxy. */ - CINIT(PROXYUSERPWD, OBJECTPOINT, 6), - - /* Range to get, specified as an ASCII string. */ - CINIT(RANGE, OBJECTPOINT, 7), - - /* not used */ - - /* Specified file stream to upload from (use as input): */ - CINIT(READDATA, OBJECTPOINT, 9), - - /* Buffer to receive error messages in, must be at least CURL_ERROR_SIZE - * bytes big. If this is not used, error messages go to stderr instead: */ - CINIT(ERRORBUFFER, OBJECTPOINT, 10), - - /* Function that will be called to store the output (instead of fwrite). The - * parameters will use fwrite() syntax, make sure to follow them. */ - CINIT(WRITEFUNCTION, FUNCTIONPOINT, 11), - - /* Function that will be called to read the input (instead of fread). The - * parameters will use fread() syntax, make sure to follow them. */ - CINIT(READFUNCTION, FUNCTIONPOINT, 12), - - /* Time-out the read operation after this amount of seconds */ - CINIT(TIMEOUT, LONG, 13), - - /* If the CURLOPT_INFILE is used, this can be used to inform libcurl about - * how large the file being sent really is. That allows better error - * checking and better verifies that the upload was successful. -1 means - * unknown size. - * - * For large file support, there is also a _LARGE version of the key - * which takes an off_t type, allowing platforms with larger off_t - * sizes to handle larger files. See below for INFILESIZE_LARGE. - */ - CINIT(INFILESIZE, LONG, 14), - - /* POST static input fields. */ - CINIT(POSTFIELDS, OBJECTPOINT, 15), - - /* Set the referrer page (needed by some CGIs) */ - CINIT(REFERER, OBJECTPOINT, 16), - - /* Set the FTP PORT string (interface name, named or numerical IP address) - Use i.e '-' to use default address. */ - CINIT(FTPPORT, OBJECTPOINT, 17), - - /* Set the User-Agent string (examined by some CGIs) */ - CINIT(USERAGENT, OBJECTPOINT, 18), - - /* If the download receives less than "low speed limit" bytes/second - * during "low speed time" seconds, the operations is aborted. - * You could i.e if you have a pretty high speed connection, abort if - * it is less than 2000 bytes/sec during 20 seconds. - */ - - /* Set the "low speed limit" */ - CINIT(LOW_SPEED_LIMIT, LONG, 19), - - /* Set the "low speed time" */ - CINIT(LOW_SPEED_TIME, LONG, 20), - - /* Set the continuation offset. - * - * Note there is also a _LARGE version of this key which uses - * off_t types, allowing for large file offsets on platforms which - * use larger-than-32-bit off_t's. Look below for RESUME_FROM_LARGE. - */ - CINIT(RESUME_FROM, LONG, 21), - - /* Set cookie in request: */ - CINIT(COOKIE, OBJECTPOINT, 22), - - /* This points to a linked list of headers, struct curl_slist kind. This - list is also used for RTSP (in spite of its name) */ - CINIT(HTTPHEADER, OBJECTPOINT, 23), - - /* This points to a linked list of post entries, struct curl_httppost */ - CINIT(HTTPPOST, OBJECTPOINT, 24), - - /* name of the file keeping your private SSL-certificate */ - CINIT(SSLCERT, OBJECTPOINT, 25), - - /* password for the SSL or SSH private key */ - CINIT(KEYPASSWD, OBJECTPOINT, 26), - - /* send TYPE parameter? */ - CINIT(CRLF, LONG, 27), - - /* send linked-list of QUOTE commands */ - CINIT(QUOTE, OBJECTPOINT, 28), - - /* send FILE * or void * to store headers to, if you use a callback it - is simply passed to the callback unmodified */ - CINIT(HEADERDATA, OBJECTPOINT, 29), - - /* point to a file to read the initial cookies from, also enables - "cookie awareness" */ - CINIT(COOKIEFILE, OBJECTPOINT, 31), - - /* What version to specifically try to use. - See CURL_SSLVERSION defines below. */ - CINIT(SSLVERSION, LONG, 32), - - /* What kind of HTTP time condition to use, see defines */ - CINIT(TIMECONDITION, LONG, 33), - - /* Time to use with the above condition. Specified in number of seconds - since 1 Jan 1970 */ - CINIT(TIMEVALUE, LONG, 34), - - /* 35 = OBSOLETE */ - - /* Custom request, for customizing the get command like - HTTP: DELETE, TRACE and others - FTP: to use a different list command - */ - CINIT(CUSTOMREQUEST, OBJECTPOINT, 36), - - /* HTTP request, for odd commands like DELETE, TRACE and others */ - CINIT(STDERR, OBJECTPOINT, 37), - - /* 38 is not used */ - - /* send linked-list of post-transfer QUOTE commands */ - CINIT(POSTQUOTE, OBJECTPOINT, 39), - - CINIT(OBSOLETE40, OBJECTPOINT, 40), /* OBSOLETE, do not use! */ - - CINIT(VERBOSE, LONG, 41), /* talk a lot */ - CINIT(HEADER, LONG, 42), /* throw the header out too */ - CINIT(NOPROGRESS, LONG, 43), /* shut off the progress meter */ - CINIT(NOBODY, LONG, 44), /* use HEAD to get http document */ - CINIT(FAILONERROR, LONG, 45), /* no output on http error codes >= 400 */ - CINIT(UPLOAD, LONG, 46), /* this is an upload */ - CINIT(POST, LONG, 47), /* HTTP POST method */ - CINIT(DIRLISTONLY, LONG, 48), /* bare names when listing directories */ - - CINIT(APPEND, LONG, 50), /* Append instead of overwrite on upload! */ - - /* Specify whether to read the user+password from the .netrc or the URL. - * This must be one of the CURL_NETRC_* enums below. */ - CINIT(NETRC, LONG, 51), - - CINIT(FOLLOWLOCATION, LONG, 52), /* use Location: Luke! */ - - CINIT(TRANSFERTEXT, LONG, 53), /* transfer data in text/ASCII format */ - CINIT(PUT, LONG, 54), /* HTTP PUT */ - - /* 55 = OBSOLETE */ - - /* DEPRECATED - * Function that will be called instead of the internal progress display - * function. This function should be defined as the curl_progress_callback - * prototype defines. */ - CINIT(PROGRESSFUNCTION, FUNCTIONPOINT, 56), - - /* Data passed to the CURLOPT_PROGRESSFUNCTION and CURLOPT_XFERINFOFUNCTION - callbacks */ - CINIT(PROGRESSDATA, OBJECTPOINT, 57), -#define CURLOPT_XFERINFODATA CURLOPT_PROGRESSDATA - - /* We want the referrer field set automatically when following locations */ - CINIT(AUTOREFERER, LONG, 58), - - /* Port of the proxy, can be set in the proxy string as well with: - "[host]:[port]" */ - CINIT(PROXYPORT, LONG, 59), - - /* size of the POST input data, if strlen() is not good to use */ - CINIT(POSTFIELDSIZE, LONG, 60), - - /* tunnel non-http operations through a HTTP proxy */ - CINIT(HTTPPROXYTUNNEL, LONG, 61), - - /* Set the interface string to use as outgoing network interface */ - CINIT(INTERFACE, OBJECTPOINT, 62), - - /* Set the krb4/5 security level, this also enables krb4/5 awareness. This - * is a string, 'clear', 'safe', 'confidential' or 'private'. If the string - * is set but doesn't match one of these, 'private' will be used. */ - CINIT(KRBLEVEL, OBJECTPOINT, 63), - - /* Set if we should verify the peer in ssl handshake, set 1 to verify. */ - CINIT(SSL_VERIFYPEER, LONG, 64), - - /* The CApath or CAfile used to validate the peer certificate - this option is used only if SSL_VERIFYPEER is true */ - CINIT(CAINFO, OBJECTPOINT, 65), - - /* 66 = OBSOLETE */ - /* 67 = OBSOLETE */ - - /* Maximum number of http redirects to follow */ - CINIT(MAXREDIRS, LONG, 68), - - /* Pass a long set to 1 to get the date of the requested document (if - possible)! Pass a zero to shut it off. */ - CINIT(FILETIME, LONG, 69), - - /* This points to a linked list of telnet options */ - CINIT(TELNETOPTIONS, OBJECTPOINT, 70), - - /* Max amount of cached alive connections */ - CINIT(MAXCONNECTS, LONG, 71), - - CINIT(OBSOLETE72, LONG, 72), /* OBSOLETE, do not use! */ - - /* 73 = OBSOLETE */ - - /* Set to explicitly use a new connection for the upcoming transfer. - Do not use this unless you're absolutely sure of this, as it makes the - operation slower and is less friendly for the network. */ - CINIT(FRESH_CONNECT, LONG, 74), - - /* Set to explicitly forbid the upcoming transfer's connection to be re-used - when done. Do not use this unless you're absolutely sure of this, as it - makes the operation slower and is less friendly for the network. */ - CINIT(FORBID_REUSE, LONG, 75), - - /* Set to a file name that contains random data for libcurl to use to - seed the random engine when doing SSL connects. */ - CINIT(RANDOM_FILE, OBJECTPOINT, 76), - - /* Set to the Entropy Gathering Daemon socket pathname */ - CINIT(EGDSOCKET, OBJECTPOINT, 77), - - /* Time-out connect operations after this amount of seconds, if connects are - OK within this time, then fine... This only aborts the connect phase. */ - CINIT(CONNECTTIMEOUT, LONG, 78), - - /* Function that will be called to store headers (instead of fwrite). The - * parameters will use fwrite() syntax, make sure to follow them. */ - CINIT(HEADERFUNCTION, FUNCTIONPOINT, 79), - - /* Set this to force the HTTP request to get back to GET. Only really usable - if POST, PUT or a custom request have been used first. - */ - CINIT(HTTPGET, LONG, 80), - - /* Set if we should verify the Common name from the peer certificate in ssl - * handshake, set 1 to check existence, 2 to ensure that it matches the - * provided hostname. */ - CINIT(SSL_VERIFYHOST, LONG, 81), - - /* Specify which file name to write all known cookies in after completed - operation. Set file name to "-" (dash) to make it go to stdout. */ - CINIT(COOKIEJAR, OBJECTPOINT, 82), - - /* Specify which SSL ciphers to use */ - CINIT(SSL_CIPHER_LIST, OBJECTPOINT, 83), - - /* Specify which HTTP version to use! This must be set to one of the - CURL_HTTP_VERSION* enums set below. */ - CINIT(HTTP_VERSION, LONG, 84), - - /* Specifically switch on or off the FTP engine's use of the EPSV command. By - default, that one will always be attempted before the more traditional - PASV command. */ - CINIT(FTP_USE_EPSV, LONG, 85), - - /* type of the file keeping your SSL-certificate ("DER", "PEM", "ENG") */ - CINIT(SSLCERTTYPE, OBJECTPOINT, 86), - - /* name of the file keeping your private SSL-key */ - CINIT(SSLKEY, OBJECTPOINT, 87), - - /* type of the file keeping your private SSL-key ("DER", "PEM", "ENG") */ - CINIT(SSLKEYTYPE, OBJECTPOINT, 88), - - /* crypto engine for the SSL-sub system */ - CINIT(SSLENGINE, OBJECTPOINT, 89), - - /* set the crypto engine for the SSL-sub system as default - the param has no meaning... - */ - CINIT(SSLENGINE_DEFAULT, LONG, 90), - - /* Non-zero value means to use the global dns cache */ - CINIT(DNS_USE_GLOBAL_CACHE, LONG, 91), /* DEPRECATED, do not use! */ - - /* DNS cache timeout */ - CINIT(DNS_CACHE_TIMEOUT, LONG, 92), - - /* send linked-list of pre-transfer QUOTE commands */ - CINIT(PREQUOTE, OBJECTPOINT, 93), - - /* set the debug function */ - CINIT(DEBUGFUNCTION, FUNCTIONPOINT, 94), - - /* set the data for the debug function */ - CINIT(DEBUGDATA, OBJECTPOINT, 95), - - /* mark this as start of a cookie session */ - CINIT(COOKIESESSION, LONG, 96), - - /* The CApath directory used to validate the peer certificate - this option is used only if SSL_VERIFYPEER is true */ - CINIT(CAPATH, OBJECTPOINT, 97), - - /* Instruct libcurl to use a smaller receive buffer */ - CINIT(BUFFERSIZE, LONG, 98), - - /* Instruct libcurl to not use any signal/alarm handlers, even when using - timeouts. This option is useful for multi-threaded applications. - See libcurl-the-guide for more background information. */ - CINIT(NOSIGNAL, LONG, 99), - - /* Provide a CURLShare for mutexing non-ts data */ - CINIT(SHARE, OBJECTPOINT, 100), - - /* indicates type of proxy. accepted values are CURLPROXY_HTTP (default), - CURLPROXY_SOCKS4, CURLPROXY_SOCKS4A and CURLPROXY_SOCKS5. */ - CINIT(PROXYTYPE, LONG, 101), - - /* Set the Accept-Encoding string. Use this to tell a server you would like - the response to be compressed. Before 7.21.6, this was known as - CURLOPT_ENCODING */ - CINIT(ACCEPT_ENCODING, OBJECTPOINT, 102), - - /* Set pointer to private data */ - CINIT(PRIVATE, OBJECTPOINT, 103), - - /* Set aliases for HTTP 200 in the HTTP Response header */ - CINIT(HTTP200ALIASES, OBJECTPOINT, 104), - - /* Continue to send authentication (user+password) when following locations, - even when hostname changed. This can potentially send off the name - and password to whatever host the server decides. */ - CINIT(UNRESTRICTED_AUTH, LONG, 105), - - /* Specifically switch on or off the FTP engine's use of the EPRT command ( - it also disables the LPRT attempt). By default, those ones will always be - attempted before the good old traditional PORT command. */ - CINIT(FTP_USE_EPRT, LONG, 106), - - /* Set this to a bitmask value to enable the particular authentications - methods you like. Use this in combination with CURLOPT_USERPWD. - Note that setting multiple bits may cause extra network round-trips. */ - CINIT(HTTPAUTH, LONG, 107), - - /* Set the ssl context callback function, currently only for OpenSSL ssl_ctx - in second argument. The function must be matching the - curl_ssl_ctx_callback proto. */ - CINIT(SSL_CTX_FUNCTION, FUNCTIONPOINT, 108), - - /* Set the userdata for the ssl context callback function's third - argument */ - CINIT(SSL_CTX_DATA, OBJECTPOINT, 109), - - /* FTP Option that causes missing dirs to be created on the remote server. - In 7.19.4 we introduced the convenience enums for this option using the - CURLFTP_CREATE_DIR prefix. - */ - CINIT(FTP_CREATE_MISSING_DIRS, LONG, 110), - - /* Set this to a bitmask value to enable the particular authentications - methods you like. Use this in combination with CURLOPT_PROXYUSERPWD. - Note that setting multiple bits may cause extra network round-trips. */ - CINIT(PROXYAUTH, LONG, 111), - - /* FTP option that changes the timeout, in seconds, associated with - getting a response. This is different from transfer timeout time and - essentially places a demand on the FTP server to acknowledge commands - in a timely manner. */ - CINIT(FTP_RESPONSE_TIMEOUT, LONG, 112), -#define CURLOPT_SERVER_RESPONSE_TIMEOUT CURLOPT_FTP_RESPONSE_TIMEOUT - - /* Set this option to one of the CURL_IPRESOLVE_* defines (see below) to - tell libcurl to resolve names to those IP versions only. This only has - affect on systems with support for more than one, i.e IPv4 _and_ IPv6. */ - CINIT(IPRESOLVE, LONG, 113), - - /* Set this option to limit the size of a file that will be downloaded from - an HTTP or FTP server. - - Note there is also _LARGE version which adds large file support for - platforms which have larger off_t sizes. See MAXFILESIZE_LARGE below. */ - CINIT(MAXFILESIZE, LONG, 114), - - /* See the comment for INFILESIZE above, but in short, specifies - * the size of the file being uploaded. -1 means unknown. - */ - CINIT(INFILESIZE_LARGE, OFF_T, 115), - - /* Sets the continuation offset. There is also a LONG version of this; - * look above for RESUME_FROM. - */ - CINIT(RESUME_FROM_LARGE, OFF_T, 116), - - /* Sets the maximum size of data that will be downloaded from - * an HTTP or FTP server. See MAXFILESIZE above for the LONG version. - */ - CINIT(MAXFILESIZE_LARGE, OFF_T, 117), - - /* Set this option to the file name of your .netrc file you want libcurl - to parse (using the CURLOPT_NETRC option). If not set, libcurl will do - a poor attempt to find the user's home directory and check for a .netrc - file in there. */ - CINIT(NETRC_FILE, OBJECTPOINT, 118), - - /* Enable SSL/TLS for FTP, pick one of: - CURLUSESSL_TRY - try using SSL, proceed anyway otherwise - CURLUSESSL_CONTROL - SSL for the control connection or fail - CURLUSESSL_ALL - SSL for all communication or fail - */ - CINIT(USE_SSL, LONG, 119), - - /* The _LARGE version of the standard POSTFIELDSIZE option */ - CINIT(POSTFIELDSIZE_LARGE, OFF_T, 120), - - /* Enable/disable the TCP Nagle algorithm */ - CINIT(TCP_NODELAY, LONG, 121), - - /* 122 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ - /* 123 OBSOLETE. Gone in 7.16.0 */ - /* 124 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ - /* 125 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ - /* 126 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ - /* 127 OBSOLETE. Gone in 7.16.0 */ - /* 128 OBSOLETE. Gone in 7.16.0 */ - - /* When FTP over SSL/TLS is selected (with CURLOPT_USE_SSL), this option - can be used to change libcurl's default action which is to first try - "AUTH SSL" and then "AUTH TLS" in this order, and proceed when a OK - response has been received. - - Available parameters are: - CURLFTPAUTH_DEFAULT - let libcurl decide - CURLFTPAUTH_SSL - try "AUTH SSL" first, then TLS - CURLFTPAUTH_TLS - try "AUTH TLS" first, then SSL - */ - CINIT(FTPSSLAUTH, LONG, 129), - - CINIT(IOCTLFUNCTION, FUNCTIONPOINT, 130), - CINIT(IOCTLDATA, OBJECTPOINT, 131), - - /* 132 OBSOLETE. Gone in 7.16.0 */ - /* 133 OBSOLETE. Gone in 7.16.0 */ - - /* zero terminated string for pass on to the FTP server when asked for - "account" info */ - CINIT(FTP_ACCOUNT, OBJECTPOINT, 134), - - /* feed cookies into cookie engine */ - CINIT(COOKIELIST, OBJECTPOINT, 135), - - /* ignore Content-Length */ - CINIT(IGNORE_CONTENT_LENGTH, LONG, 136), - - /* Set to non-zero to skip the IP address received in a 227 PASV FTP server - response. Typically used for FTP-SSL purposes but is not restricted to - that. libcurl will then instead use the same IP address it used for the - control connection. */ - CINIT(FTP_SKIP_PASV_IP, LONG, 137), - - /* Select "file method" to use when doing FTP, see the curl_ftpmethod - above. */ - CINIT(FTP_FILEMETHOD, LONG, 138), - - /* Local port number to bind the socket to */ - CINIT(LOCALPORT, LONG, 139), - - /* Number of ports to try, including the first one set with LOCALPORT. - Thus, setting it to 1 will make no additional attempts but the first. - */ - CINIT(LOCALPORTRANGE, LONG, 140), - - /* no transfer, set up connection and let application use the socket by - extracting it with CURLINFO_LASTSOCKET */ - CINIT(CONNECT_ONLY, LONG, 141), - - /* Function that will be called to convert from the - network encoding (instead of using the iconv calls in libcurl) */ - CINIT(CONV_FROM_NETWORK_FUNCTION, FUNCTIONPOINT, 142), - - /* Function that will be called to convert to the - network encoding (instead of using the iconv calls in libcurl) */ - CINIT(CONV_TO_NETWORK_FUNCTION, FUNCTIONPOINT, 143), - - /* Function that will be called to convert from UTF8 - (instead of using the iconv calls in libcurl) - Note that this is used only for SSL certificate processing */ - CINIT(CONV_FROM_UTF8_FUNCTION, FUNCTIONPOINT, 144), - - /* if the connection proceeds too quickly then need to slow it down */ - /* limit-rate: maximum number of bytes per second to send or receive */ - CINIT(MAX_SEND_SPEED_LARGE, OFF_T, 145), - CINIT(MAX_RECV_SPEED_LARGE, OFF_T, 146), - - /* Pointer to command string to send if USER/PASS fails. */ - CINIT(FTP_ALTERNATIVE_TO_USER, OBJECTPOINT, 147), - - /* callback function for setting socket options */ - CINIT(SOCKOPTFUNCTION, FUNCTIONPOINT, 148), - CINIT(SOCKOPTDATA, OBJECTPOINT, 149), - - /* set to 0 to disable session ID re-use for this transfer, default is - enabled (== 1) */ - CINIT(SSL_SESSIONID_CACHE, LONG, 150), - - /* allowed SSH authentication methods */ - CINIT(SSH_AUTH_TYPES, LONG, 151), - - /* Used by scp/sftp to do public/private key authentication */ - CINIT(SSH_PUBLIC_KEYFILE, OBJECTPOINT, 152), - CINIT(SSH_PRIVATE_KEYFILE, OBJECTPOINT, 153), - - /* Send CCC (Clear Command Channel) after authentication */ - CINIT(FTP_SSL_CCC, LONG, 154), - - /* Same as TIMEOUT and CONNECTTIMEOUT, but with ms resolution */ - CINIT(TIMEOUT_MS, LONG, 155), - CINIT(CONNECTTIMEOUT_MS, LONG, 156), - - /* set to zero to disable the libcurl's decoding and thus pass the raw body - data to the application even when it is encoded/compressed */ - CINIT(HTTP_TRANSFER_DECODING, LONG, 157), - CINIT(HTTP_CONTENT_DECODING, LONG, 158), - - /* Permission used when creating new files and directories on the remote - server for protocols that support it, SFTP/SCP/FILE */ - CINIT(NEW_FILE_PERMS, LONG, 159), - CINIT(NEW_DIRECTORY_PERMS, LONG, 160), - - /* Set the behaviour of POST when redirecting. Values must be set to one - of CURL_REDIR* defines below. This used to be called CURLOPT_POST301 */ - CINIT(POSTREDIR, LONG, 161), - - /* used by scp/sftp to verify the host's public key */ - CINIT(SSH_HOST_PUBLIC_KEY_MD5, OBJECTPOINT, 162), - - /* Callback function for opening socket (instead of socket(2)). Optionally, - callback is able change the address or refuse to connect returning - CURL_SOCKET_BAD. The callback should have type - curl_opensocket_callback */ - CINIT(OPENSOCKETFUNCTION, FUNCTIONPOINT, 163), - CINIT(OPENSOCKETDATA, OBJECTPOINT, 164), - - /* POST volatile input fields. */ - CINIT(COPYPOSTFIELDS, OBJECTPOINT, 165), - - /* set transfer mode (;type=) when doing FTP via an HTTP proxy */ - CINIT(PROXY_TRANSFER_MODE, LONG, 166), - - /* Callback function for seeking in the input stream */ - CINIT(SEEKFUNCTION, FUNCTIONPOINT, 167), - CINIT(SEEKDATA, OBJECTPOINT, 168), - - /* CRL file */ - CINIT(CRLFILE, OBJECTPOINT, 169), - - /* Issuer certificate */ - CINIT(ISSUERCERT, OBJECTPOINT, 170), - - /* (IPv6) Address scope */ - CINIT(ADDRESS_SCOPE, LONG, 171), - - /* Collect certificate chain info and allow it to get retrievable with - CURLINFO_CERTINFO after the transfer is complete. */ - CINIT(CERTINFO, LONG, 172), - - /* "name" and "pwd" to use when fetching. */ - CINIT(USERNAME, OBJECTPOINT, 173), - CINIT(PASSWORD, OBJECTPOINT, 174), - - /* "name" and "pwd" to use with Proxy when fetching. */ - CINIT(PROXYUSERNAME, OBJECTPOINT, 175), - CINIT(PROXYPASSWORD, OBJECTPOINT, 176), - - /* Comma separated list of hostnames defining no-proxy zones. These should - match both hostnames directly, and hostnames within a domain. For - example, local.com will match local.com and www.local.com, but NOT - notlocal.com or www.notlocal.com. For compatibility with other - implementations of this, .local.com will be considered to be the same as - local.com. A single * is the only valid wildcard, and effectively - disables the use of proxy. */ - CINIT(NOPROXY, OBJECTPOINT, 177), - - /* block size for TFTP transfers */ - CINIT(TFTP_BLKSIZE, LONG, 178), - - /* Socks Service */ - CINIT(SOCKS5_GSSAPI_SERVICE, OBJECTPOINT, 179), - - /* Socks Service */ - CINIT(SOCKS5_GSSAPI_NEC, LONG, 180), - - /* set the bitmask for the protocols that are allowed to be used for the - transfer, which thus helps the app which takes URLs from users or other - external inputs and want to restrict what protocol(s) to deal - with. Defaults to CURLPROTO_ALL. */ - CINIT(PROTOCOLS, LONG, 181), - - /* set the bitmask for the protocols that libcurl is allowed to follow to, - as a subset of the CURLOPT_PROTOCOLS ones. That means the protocol needs - to be set in both bitmasks to be allowed to get redirected to. Defaults - to all protocols except FILE and SCP. */ - CINIT(REDIR_PROTOCOLS, LONG, 182), - - /* set the SSH knownhost file name to use */ - CINIT(SSH_KNOWNHOSTS, OBJECTPOINT, 183), - - /* set the SSH host key callback, must point to a curl_sshkeycallback - function */ - CINIT(SSH_KEYFUNCTION, FUNCTIONPOINT, 184), - - /* set the SSH host key callback custom pointer */ - CINIT(SSH_KEYDATA, OBJECTPOINT, 185), - - /* set the SMTP mail originator */ - CINIT(MAIL_FROM, OBJECTPOINT, 186), - - /* set the SMTP mail receiver(s) */ - CINIT(MAIL_RCPT, OBJECTPOINT, 187), - - /* FTP: send PRET before PASV */ - CINIT(FTP_USE_PRET, LONG, 188), - - /* RTSP request method (OPTIONS, SETUP, PLAY, etc...) */ - CINIT(RTSP_REQUEST, LONG, 189), - - /* The RTSP session identifier */ - CINIT(RTSP_SESSION_ID, OBJECTPOINT, 190), - - /* The RTSP stream URI */ - CINIT(RTSP_STREAM_URI, OBJECTPOINT, 191), - - /* The Transport: header to use in RTSP requests */ - CINIT(RTSP_TRANSPORT, OBJECTPOINT, 192), - - /* Manually initialize the client RTSP CSeq for this handle */ - CINIT(RTSP_CLIENT_CSEQ, LONG, 193), - - /* Manually initialize the server RTSP CSeq for this handle */ - CINIT(RTSP_SERVER_CSEQ, LONG, 194), - - /* The stream to pass to INTERLEAVEFUNCTION. */ - CINIT(INTERLEAVEDATA, OBJECTPOINT, 195), - - /* Let the application define a custom write method for RTP data */ - CINIT(INTERLEAVEFUNCTION, FUNCTIONPOINT, 196), - - /* Turn on wildcard matching */ - CINIT(WILDCARDMATCH, LONG, 197), - - /* Directory matching callback called before downloading of an - individual file (chunk) started */ - CINIT(CHUNK_BGN_FUNCTION, FUNCTIONPOINT, 198), - - /* Directory matching callback called after the file (chunk) - was downloaded, or skipped */ - CINIT(CHUNK_END_FUNCTION, FUNCTIONPOINT, 199), - - /* Change match (fnmatch-like) callback for wildcard matching */ - CINIT(FNMATCH_FUNCTION, FUNCTIONPOINT, 200), - - /* Let the application define custom chunk data pointer */ - CINIT(CHUNK_DATA, OBJECTPOINT, 201), - - /* FNMATCH_FUNCTION user pointer */ - CINIT(FNMATCH_DATA, OBJECTPOINT, 202), - - /* send linked-list of name:port:address sets */ - CINIT(RESOLVE, OBJECTPOINT, 203), - - /* Set a username for authenticated TLS */ - CINIT(TLSAUTH_USERNAME, OBJECTPOINT, 204), - - /* Set a password for authenticated TLS */ - CINIT(TLSAUTH_PASSWORD, OBJECTPOINT, 205), - - /* Set authentication type for authenticated TLS */ - CINIT(TLSAUTH_TYPE, OBJECTPOINT, 206), - - /* Set to 1 to enable the "TE:" header in HTTP requests to ask for - compressed transfer-encoded responses. Set to 0 to disable the use of TE: - in outgoing requests. The current default is 0, but it might change in a - future libcurl release. - - libcurl will ask for the compressed methods it knows of, and if that - isn't any, it will not ask for transfer-encoding at all even if this - option is set to 1. - - */ - CINIT(TRANSFER_ENCODING, LONG, 207), - - /* Callback function for closing socket (instead of close(2)). The callback - should have type curl_closesocket_callback */ - CINIT(CLOSESOCKETFUNCTION, FUNCTIONPOINT, 208), - CINIT(CLOSESOCKETDATA, OBJECTPOINT, 209), - - /* allow GSSAPI credential delegation */ - CINIT(GSSAPI_DELEGATION, LONG, 210), - - /* Set the name servers to use for DNS resolution */ - CINIT(DNS_SERVERS, OBJECTPOINT, 211), - - /* Time-out accept operations (currently for FTP only) after this amount - of miliseconds. */ - CINIT(ACCEPTTIMEOUT_MS, LONG, 212), - - /* Set TCP keepalive */ - CINIT(TCP_KEEPALIVE, LONG, 213), - - /* non-universal keepalive knobs (Linux, AIX, HP-UX, more) */ - CINIT(TCP_KEEPIDLE, LONG, 214), - CINIT(TCP_KEEPINTVL, LONG, 215), - - /* Enable/disable specific SSL features with a bitmask, see CURLSSLOPT_* */ - CINIT(SSL_OPTIONS, LONG, 216), - - /* Set the SMTP auth originator */ - CINIT(MAIL_AUTH, OBJECTPOINT, 217), - - /* Enable/disable SASL initial response */ - CINIT(SASL_IR, LONG, 218), - - /* Function that will be called instead of the internal progress display - * function. This function should be defined as the curl_xferinfo_callback - * prototype defines. (Deprecates CURLOPT_PROGRESSFUNCTION) */ - CINIT(XFERINFOFUNCTION, FUNCTIONPOINT, 219), - - /* The XOAUTH2 bearer token */ - CINIT(XOAUTH2_BEARER, OBJECTPOINT, 220), - - /* Set the interface string to use as outgoing network - * interface for DNS requests. - * Only supported by the c-ares DNS backend */ - CINIT(DNS_INTERFACE, OBJECTPOINT, 221), - - /* Set the local IPv4 address to use for outgoing DNS requests. - * Only supported by the c-ares DNS backend */ - CINIT(DNS_LOCAL_IP4, OBJECTPOINT, 222), - - /* Set the local IPv4 address to use for outgoing DNS requests. - * Only supported by the c-ares DNS backend */ - CINIT(DNS_LOCAL_IP6, OBJECTPOINT, 223), - - /* Set authentication options directly */ - CINIT(LOGIN_OPTIONS, OBJECTPOINT, 224), - - /* Enable/disable TLS NPN extension (http2 over ssl might fail without) */ - CINIT(SSL_ENABLE_NPN, LONG, 225), - - /* Enable/disable TLS ALPN extension (http2 over ssl might fail without) */ - CINIT(SSL_ENABLE_ALPN, LONG, 226), - - /* Time to wait for a response to a HTTP request containing an - * Expect: 100-continue header before sending the data anyway. */ - CINIT(EXPECT_100_TIMEOUT_MS, LONG, 227), - - /* This points to a linked list of headers used for proxy requests only, - struct curl_slist kind */ - CINIT(PROXYHEADER, OBJECTPOINT, 228), - - /* Pass in a bitmask of "header options" */ - CINIT(HEADEROPT, LONG, 229), - - /* The public key in DER form used to validate the peer public key - this option is used only if SSL_VERIFYPEER is true */ - CINIT(PINNEDPUBLICKEY, OBJECTPOINT, 230), - - /* Path to Unix domain socket */ - CINIT(UNIX_SOCKET_PATH, OBJECTPOINT, 231), - - /* Set if we should verify the certificate status. */ - CINIT(SSL_VERIFYSTATUS, LONG, 232), - - /* Set if we should enable TLS false start. */ - CINIT(SSL_FALSESTART, LONG, 233), - - /* Do not squash dot-dot sequences */ - CINIT(PATH_AS_IS, LONG, 234), - - /* Proxy Service Name */ - CINIT(PROXY_SERVICE_NAME, OBJECTPOINT, 235), - - /* Service Name */ - CINIT(SERVICE_NAME, OBJECTPOINT, 236), - - /* Wait/don't wait for pipe/mutex to clarify */ - CINIT(PIPEWAIT, LONG, 237), - - CURLOPT_LASTENTRY /* the last unused */ -} CURLoption; - -#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all - the obsolete stuff removed! */ - -/* Backwards compatibility with older names */ -/* These are scheduled to disappear by 2011 */ - -/* This was added in version 7.19.1 */ -#define CURLOPT_POST301 CURLOPT_POSTREDIR - -/* These are scheduled to disappear by 2009 */ - -/* The following were added in 7.17.0 */ -#define CURLOPT_SSLKEYPASSWD CURLOPT_KEYPASSWD -#define CURLOPT_FTPAPPEND CURLOPT_APPEND -#define CURLOPT_FTPLISTONLY CURLOPT_DIRLISTONLY -#define CURLOPT_FTP_SSL CURLOPT_USE_SSL - -/* The following were added earlier */ - -#define CURLOPT_SSLCERTPASSWD CURLOPT_KEYPASSWD -#define CURLOPT_KRB4LEVEL CURLOPT_KRBLEVEL - -#else -/* This is set if CURL_NO_OLDIES is defined at compile-time */ -#undef CURLOPT_DNS_USE_GLOBAL_CACHE /* soon obsolete */ -#endif - - - /* Below here follows defines for the CURLOPT_IPRESOLVE option. If a host - name resolves addresses using more than one IP protocol version, this - option might be handy to force libcurl to use a specific IP version. */ -#define CURL_IPRESOLVE_WHATEVER 0 /* default, resolves addresses to all IP - versions that your system allows */ -#define CURL_IPRESOLVE_V4 1 /* resolve to IPv4 addresses */ -#define CURL_IPRESOLVE_V6 2 /* resolve to IPv6 addresses */ - - /* three convenient "aliases" that follow the name scheme better */ -#define CURLOPT_RTSPHEADER CURLOPT_HTTPHEADER - - /* These enums are for use with the CURLOPT_HTTP_VERSION option. */ -enum { - CURL_HTTP_VERSION_NONE, /* setting this means we don't care, and that we'd - like the library to choose the best possible - for us! */ - CURL_HTTP_VERSION_1_0, /* please use HTTP 1.0 in the request */ - CURL_HTTP_VERSION_1_1, /* please use HTTP 1.1 in the request */ - CURL_HTTP_VERSION_2_0, /* please use HTTP 2.0 in the request */ - - CURL_HTTP_VERSION_LAST /* *ILLEGAL* http version */ -}; - -/* Convenience definition simple because the name of the version is HTTP/2 and - not 2.0. The 2_0 version of the enum name was set while the version was - still planned to be 2.0 and we stick to it for compatibility. */ -#define CURL_HTTP_VERSION_2 CURL_HTTP_VERSION_2_0 - -/* - * Public API enums for RTSP requests - */ -enum { - CURL_RTSPREQ_NONE, /* first in list */ - CURL_RTSPREQ_OPTIONS, - CURL_RTSPREQ_DESCRIBE, - CURL_RTSPREQ_ANNOUNCE, - CURL_RTSPREQ_SETUP, - CURL_RTSPREQ_PLAY, - CURL_RTSPREQ_PAUSE, - CURL_RTSPREQ_TEARDOWN, - CURL_RTSPREQ_GET_PARAMETER, - CURL_RTSPREQ_SET_PARAMETER, - CURL_RTSPREQ_RECORD, - CURL_RTSPREQ_RECEIVE, - CURL_RTSPREQ_LAST /* last in list */ -}; - - /* These enums are for use with the CURLOPT_NETRC option. */ -enum CURL_NETRC_OPTION { - CURL_NETRC_IGNORED, /* The .netrc will never be read. - * This is the default. */ - CURL_NETRC_OPTIONAL, /* A user:password in the URL will be preferred - * to one in the .netrc. */ - CURL_NETRC_REQUIRED, /* A user:password in the URL will be ignored. - * Unless one is set programmatically, the .netrc - * will be queried. */ - CURL_NETRC_LAST -}; - -enum { - CURL_SSLVERSION_DEFAULT, - CURL_SSLVERSION_TLSv1, /* TLS 1.x */ - CURL_SSLVERSION_SSLv2, - CURL_SSLVERSION_SSLv3, - CURL_SSLVERSION_TLSv1_0, - CURL_SSLVERSION_TLSv1_1, - CURL_SSLVERSION_TLSv1_2, - - CURL_SSLVERSION_LAST /* never use, keep last */ -}; - -enum CURL_TLSAUTH { - CURL_TLSAUTH_NONE, - CURL_TLSAUTH_SRP, - CURL_TLSAUTH_LAST /* never use, keep last */ -}; - -/* symbols to use with CURLOPT_POSTREDIR. - CURL_REDIR_POST_301, CURL_REDIR_POST_302 and CURL_REDIR_POST_303 - can be bitwise ORed so that CURL_REDIR_POST_301 | CURL_REDIR_POST_302 - | CURL_REDIR_POST_303 == CURL_REDIR_POST_ALL */ - -#define CURL_REDIR_GET_ALL 0 -#define CURL_REDIR_POST_301 1 -#define CURL_REDIR_POST_302 2 -#define CURL_REDIR_POST_303 4 -#define CURL_REDIR_POST_ALL \ - (CURL_REDIR_POST_301|CURL_REDIR_POST_302|CURL_REDIR_POST_303) - -typedef enum { - CURL_TIMECOND_NONE, - - CURL_TIMECOND_IFMODSINCE, - CURL_TIMECOND_IFUNMODSINCE, - CURL_TIMECOND_LASTMOD, - - CURL_TIMECOND_LAST -} curl_TimeCond; - - -/* curl_strequal() and curl_strnequal() are subject for removal in a future - libcurl, see lib/README.curlx for details */ -CURL_EXTERN int (curl_strequal)(const char *s1, const char *s2); -CURL_EXTERN int (curl_strnequal)(const char *s1, const char *s2, size_t n); - -/* name is uppercase CURLFORM_ */ -#ifdef CFINIT -#undef CFINIT -#endif - -#ifdef CURL_ISOCPP -#define CFINIT(name) CURLFORM_ ## name -#else -/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */ -#define CFINIT(name) CURLFORM_/**/name -#endif - -typedef enum { - CFINIT(NOTHING), /********* the first one is unused ************/ - - /* */ - CFINIT(COPYNAME), - CFINIT(PTRNAME), - CFINIT(NAMELENGTH), - CFINIT(COPYCONTENTS), - CFINIT(PTRCONTENTS), - CFINIT(CONTENTSLENGTH), - CFINIT(FILECONTENT), - CFINIT(ARRAY), - CFINIT(OBSOLETE), - CFINIT(FILE), - - CFINIT(BUFFER), - CFINIT(BUFFERPTR), - CFINIT(BUFFERLENGTH), - - CFINIT(CONTENTTYPE), - CFINIT(CONTENTHEADER), - CFINIT(FILENAME), - CFINIT(END), - CFINIT(OBSOLETE2), - - CFINIT(STREAM), - - CURLFORM_LASTENTRY /* the last unused */ -} CURLformoption; - -#undef CFINIT /* done */ - -/* structure to be used as parameter for CURLFORM_ARRAY */ -struct curl_forms { - CURLformoption option; - const char *value; -}; - -/* use this for multipart formpost building */ -/* Returns code for curl_formadd() - * - * Returns: - * CURL_FORMADD_OK on success - * CURL_FORMADD_MEMORY if the FormInfo allocation fails - * CURL_FORMADD_OPTION_TWICE if one option is given twice for one Form - * CURL_FORMADD_NULL if a null pointer was given for a char - * CURL_FORMADD_MEMORY if the allocation of a FormInfo struct failed - * CURL_FORMADD_UNKNOWN_OPTION if an unknown option was used - * CURL_FORMADD_INCOMPLETE if the some FormInfo is not complete (or error) - * CURL_FORMADD_MEMORY if a curl_httppost struct cannot be allocated - * CURL_FORMADD_MEMORY if some allocation for string copying failed. - * CURL_FORMADD_ILLEGAL_ARRAY if an illegal option is used in an array - * - ***************************************************************************/ -typedef enum { - CURL_FORMADD_OK, /* first, no error */ - - CURL_FORMADD_MEMORY, - CURL_FORMADD_OPTION_TWICE, - CURL_FORMADD_NULL, - CURL_FORMADD_UNKNOWN_OPTION, - CURL_FORMADD_INCOMPLETE, - CURL_FORMADD_ILLEGAL_ARRAY, - CURL_FORMADD_DISABLED, /* libcurl was built with this disabled */ - - CURL_FORMADD_LAST /* last */ -} CURLFORMcode; - -/* - * NAME curl_formadd() - * - * DESCRIPTION - * - * Pretty advanced function for building multi-part formposts. Each invoke - * adds one part that together construct a full post. Then use - * CURLOPT_HTTPPOST to send it off to libcurl. - */ -CURL_EXTERN CURLFORMcode curl_formadd(struct curl_httppost **httppost, - struct curl_httppost **last_post, - ...); - -/* - * callback function for curl_formget() - * The void *arg pointer will be the one passed as second argument to - * curl_formget(). - * The character buffer passed to it must not be freed. - * Should return the buffer length passed to it as the argument "len" on - * success. - */ -typedef size_t (*curl_formget_callback)(void *arg, const char *buf, - size_t len); - -/* - * NAME curl_formget() - * - * DESCRIPTION - * - * Serialize a curl_httppost struct built with curl_formadd(). - * Accepts a void pointer as second argument which will be passed to - * the curl_formget_callback function. - * Returns 0 on success. - */ -CURL_EXTERN int curl_formget(struct curl_httppost *form, void *arg, - curl_formget_callback append); -/* - * NAME curl_formfree() - * - * DESCRIPTION - * - * Free a multipart formpost previously built with curl_formadd(). - */ -CURL_EXTERN void curl_formfree(struct curl_httppost *form); - -/* - * NAME curl_getenv() - * - * DESCRIPTION - * - * Returns a malloc()'ed string that MUST be curl_free()ed after usage is - * complete. DEPRECATED - see lib/README.curlx - */ -CURL_EXTERN char *curl_getenv(const char *variable); - -/* - * NAME curl_version() - * - * DESCRIPTION - * - * Returns a static ascii string of the libcurl version. - */ -CURL_EXTERN char *curl_version(void); - -/* - * NAME curl_easy_escape() - * - * DESCRIPTION - * - * Escapes URL strings (converts all letters consider illegal in URLs to their - * %XX versions). This function returns a new allocated string or NULL if an - * error occurred. - */ -CURL_EXTERN char *curl_easy_escape(CURL *handle, - const char *string, - int length); - -/* the previous version: */ -CURL_EXTERN char *curl_escape(const char *string, - int length); - - -/* - * NAME curl_easy_unescape() - * - * DESCRIPTION - * - * Unescapes URL encoding in strings (converts all %XX codes to their 8bit - * versions). This function returns a new allocated string or NULL if an error - * occurred. - * Conversion Note: On non-ASCII platforms the ASCII %XX codes are - * converted into the host encoding. - */ -CURL_EXTERN char *curl_easy_unescape(CURL *handle, - const char *string, - int length, - int *outlength); - -/* the previous version */ -CURL_EXTERN char *curl_unescape(const char *string, - int length); - -/* - * NAME curl_free() - * - * DESCRIPTION - * - * Provided for de-allocation in the same translation unit that did the - * allocation. Added in libcurl 7.10 - */ -CURL_EXTERN void curl_free(void *p); - -/* - * NAME curl_global_init() - * - * DESCRIPTION - * - * curl_global_init() should be invoked exactly once for each application that - * uses libcurl and before any call of other libcurl functions. - * - * This function is not thread-safe! - */ -CURL_EXTERN CURLcode curl_global_init(long flags); - -/* - * NAME curl_global_init_mem() - * - * DESCRIPTION - * - * curl_global_init() or curl_global_init_mem() should be invoked exactly once - * for each application that uses libcurl. This function can be used to - * initialize libcurl and set user defined memory management callback - * functions. Users can implement memory management routines to check for - * memory leaks, check for mis-use of the curl library etc. User registered - * callback routines with be invoked by this library instead of the system - * memory management routines like malloc, free etc. - */ -CURL_EXTERN CURLcode curl_global_init_mem(long flags, - curl_malloc_callback m, - curl_free_callback f, - curl_realloc_callback r, - curl_strdup_callback s, - curl_calloc_callback c); - -/* - * NAME curl_global_cleanup() - * - * DESCRIPTION - * - * curl_global_cleanup() should be invoked exactly once for each application - * that uses libcurl - */ -CURL_EXTERN void curl_global_cleanup(void); - -/* linked-list structure for the CURLOPT_QUOTE option (and other) */ -struct curl_slist { - char *data; - struct curl_slist *next; -}; - -/* - * NAME curl_slist_append() - * - * DESCRIPTION - * - * Appends a string to a linked list. If no list exists, it will be created - * first. Returns the new list, after appending. - */ -CURL_EXTERN struct curl_slist *curl_slist_append(struct curl_slist *, - const char *); - -/* - * NAME curl_slist_free_all() - * - * DESCRIPTION - * - * free a previously built curl_slist. - */ -CURL_EXTERN void curl_slist_free_all(struct curl_slist *); - -/* - * NAME curl_getdate() - * - * DESCRIPTION - * - * Returns the time, in seconds since 1 Jan 1970 of the time string given in - * the first argument. The time argument in the second parameter is unused - * and should be set to NULL. - */ -CURL_EXTERN time_t curl_getdate(const char *p, const time_t *unused); - -/* info about the certificate chain, only for OpenSSL builds. Asked - for with CURLOPT_CERTINFO / CURLINFO_CERTINFO */ -struct curl_certinfo { - int num_of_certs; /* number of certificates with information */ - struct curl_slist **certinfo; /* for each index in this array, there's a - linked list with textual information in the - format "name: value" */ -}; - -/* enum for the different supported SSL backends */ -typedef enum { - CURLSSLBACKEND_NONE = 0, - CURLSSLBACKEND_OPENSSL = 1, - CURLSSLBACKEND_GNUTLS = 2, - CURLSSLBACKEND_NSS = 3, - CURLSSLBACKEND_OBSOLETE4 = 4, /* Was QSOSSL. */ - CURLSSLBACKEND_GSKIT = 5, - CURLSSLBACKEND_POLARSSL = 6, - CURLSSLBACKEND_CYASSL = 7, - CURLSSLBACKEND_SCHANNEL = 8, - CURLSSLBACKEND_DARWINSSL = 9, - CURLSSLBACKEND_AXTLS = 10 -} curl_sslbackend; - -/* Information about the SSL library used and the respective internal SSL - handle, which can be used to obtain further information regarding the - connection. Asked for with CURLINFO_TLS_SESSION. */ -struct curl_tlssessioninfo { - curl_sslbackend backend; - void *internals; -}; - -#define CURLINFO_STRING 0x100000 -#define CURLINFO_LONG 0x200000 -#define CURLINFO_DOUBLE 0x300000 -#define CURLINFO_SLIST 0x400000 -#define CURLINFO_MASK 0x0fffff -#define CURLINFO_TYPEMASK 0xf00000 - -typedef enum { - CURLINFO_NONE, /* first, never use this */ - CURLINFO_EFFECTIVE_URL = CURLINFO_STRING + 1, - CURLINFO_RESPONSE_CODE = CURLINFO_LONG + 2, - CURLINFO_TOTAL_TIME = CURLINFO_DOUBLE + 3, - CURLINFO_NAMELOOKUP_TIME = CURLINFO_DOUBLE + 4, - CURLINFO_CONNECT_TIME = CURLINFO_DOUBLE + 5, - CURLINFO_PRETRANSFER_TIME = CURLINFO_DOUBLE + 6, - CURLINFO_SIZE_UPLOAD = CURLINFO_DOUBLE + 7, - CURLINFO_SIZE_DOWNLOAD = CURLINFO_DOUBLE + 8, - CURLINFO_SPEED_DOWNLOAD = CURLINFO_DOUBLE + 9, - CURLINFO_SPEED_UPLOAD = CURLINFO_DOUBLE + 10, - CURLINFO_HEADER_SIZE = CURLINFO_LONG + 11, - CURLINFO_REQUEST_SIZE = CURLINFO_LONG + 12, - CURLINFO_SSL_VERIFYRESULT = CURLINFO_LONG + 13, - CURLINFO_FILETIME = CURLINFO_LONG + 14, - CURLINFO_CONTENT_LENGTH_DOWNLOAD = CURLINFO_DOUBLE + 15, - CURLINFO_CONTENT_LENGTH_UPLOAD = CURLINFO_DOUBLE + 16, - CURLINFO_STARTTRANSFER_TIME = CURLINFO_DOUBLE + 17, - CURLINFO_CONTENT_TYPE = CURLINFO_STRING + 18, - CURLINFO_REDIRECT_TIME = CURLINFO_DOUBLE + 19, - CURLINFO_REDIRECT_COUNT = CURLINFO_LONG + 20, - CURLINFO_PRIVATE = CURLINFO_STRING + 21, - CURLINFO_HTTP_CONNECTCODE = CURLINFO_LONG + 22, - CURLINFO_HTTPAUTH_AVAIL = CURLINFO_LONG + 23, - CURLINFO_PROXYAUTH_AVAIL = CURLINFO_LONG + 24, - CURLINFO_OS_ERRNO = CURLINFO_LONG + 25, - CURLINFO_NUM_CONNECTS = CURLINFO_LONG + 26, - CURLINFO_SSL_ENGINES = CURLINFO_SLIST + 27, - CURLINFO_COOKIELIST = CURLINFO_SLIST + 28, - CURLINFO_LASTSOCKET = CURLINFO_LONG + 29, - CURLINFO_FTP_ENTRY_PATH = CURLINFO_STRING + 30, - CURLINFO_REDIRECT_URL = CURLINFO_STRING + 31, - CURLINFO_PRIMARY_IP = CURLINFO_STRING + 32, - CURLINFO_APPCONNECT_TIME = CURLINFO_DOUBLE + 33, - CURLINFO_CERTINFO = CURLINFO_SLIST + 34, - CURLINFO_CONDITION_UNMET = CURLINFO_LONG + 35, - CURLINFO_RTSP_SESSION_ID = CURLINFO_STRING + 36, - CURLINFO_RTSP_CLIENT_CSEQ = CURLINFO_LONG + 37, - CURLINFO_RTSP_SERVER_CSEQ = CURLINFO_LONG + 38, - CURLINFO_RTSP_CSEQ_RECV = CURLINFO_LONG + 39, - CURLINFO_PRIMARY_PORT = CURLINFO_LONG + 40, - CURLINFO_LOCAL_IP = CURLINFO_STRING + 41, - CURLINFO_LOCAL_PORT = CURLINFO_LONG + 42, - CURLINFO_TLS_SESSION = CURLINFO_SLIST + 43, - /* Fill in new entries below here! */ - - CURLINFO_LASTONE = 43 -} CURLINFO; - -/* CURLINFO_RESPONSE_CODE is the new name for the option previously known as - CURLINFO_HTTP_CODE */ -#define CURLINFO_HTTP_CODE CURLINFO_RESPONSE_CODE - -typedef enum { - CURLCLOSEPOLICY_NONE, /* first, never use this */ - - CURLCLOSEPOLICY_OLDEST, - CURLCLOSEPOLICY_LEAST_RECENTLY_USED, - CURLCLOSEPOLICY_LEAST_TRAFFIC, - CURLCLOSEPOLICY_SLOWEST, - CURLCLOSEPOLICY_CALLBACK, - - CURLCLOSEPOLICY_LAST /* last, never use this */ -} curl_closepolicy; - -#define CURL_GLOBAL_SSL (1<<0) -#define CURL_GLOBAL_WIN32 (1<<1) -#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32) -#define CURL_GLOBAL_NOTHING 0 -#define CURL_GLOBAL_DEFAULT CURL_GLOBAL_ALL -#define CURL_GLOBAL_ACK_EINTR (1<<2) - - -/***************************************************************************** - * Setup defines, protos etc for the sharing stuff. - */ - -/* Different data locks for a single share */ -typedef enum { - CURL_LOCK_DATA_NONE = 0, - /* CURL_LOCK_DATA_SHARE is used internally to say that - * the locking is just made to change the internal state of the share - * itself. - */ - CURL_LOCK_DATA_SHARE, - CURL_LOCK_DATA_COOKIE, - CURL_LOCK_DATA_DNS, - CURL_LOCK_DATA_SSL_SESSION, - CURL_LOCK_DATA_CONNECT, - CURL_LOCK_DATA_LAST -} curl_lock_data; - -/* Different lock access types */ -typedef enum { - CURL_LOCK_ACCESS_NONE = 0, /* unspecified action */ - CURL_LOCK_ACCESS_SHARED = 1, /* for read perhaps */ - CURL_LOCK_ACCESS_SINGLE = 2, /* for write perhaps */ - CURL_LOCK_ACCESS_LAST /* never use */ -} curl_lock_access; - -typedef void (*curl_lock_function)(CURL *handle, - curl_lock_data data, - curl_lock_access locktype, - void *userptr); -typedef void (*curl_unlock_function)(CURL *handle, - curl_lock_data data, - void *userptr); - -typedef void CURLSH; - -typedef enum { - CURLSHE_OK, /* all is fine */ - CURLSHE_BAD_OPTION, /* 1 */ - CURLSHE_IN_USE, /* 2 */ - CURLSHE_INVALID, /* 3 */ - CURLSHE_NOMEM, /* 4 out of memory */ - CURLSHE_NOT_BUILT_IN, /* 5 feature not present in lib */ - CURLSHE_LAST /* never use */ -} CURLSHcode; - -typedef enum { - CURLSHOPT_NONE, /* don't use */ - CURLSHOPT_SHARE, /* specify a data type to share */ - CURLSHOPT_UNSHARE, /* specify which data type to stop sharing */ - CURLSHOPT_LOCKFUNC, /* pass in a 'curl_lock_function' pointer */ - CURLSHOPT_UNLOCKFUNC, /* pass in a 'curl_unlock_function' pointer */ - CURLSHOPT_USERDATA, /* pass in a user data pointer used in the lock/unlock - callback functions */ - CURLSHOPT_LAST /* never use */ -} CURLSHoption; - -CURL_EXTERN CURLSH *curl_share_init(void); -CURL_EXTERN CURLSHcode curl_share_setopt(CURLSH *, CURLSHoption option, ...); -CURL_EXTERN CURLSHcode curl_share_cleanup(CURLSH *); - -/**************************************************************************** - * Structures for querying information about the curl library at runtime. - */ - -typedef enum { - CURLVERSION_FIRST, - CURLVERSION_SECOND, - CURLVERSION_THIRD, - CURLVERSION_FOURTH, - CURLVERSION_LAST /* never actually use this */ -} CURLversion; - -/* The 'CURLVERSION_NOW' is the symbolic name meant to be used by - basically all programs ever that want to get version information. It is - meant to be a built-in version number for what kind of struct the caller - expects. If the struct ever changes, we redefine the NOW to another enum - from above. */ -#define CURLVERSION_NOW CURLVERSION_FOURTH - -typedef struct { - CURLversion age; /* age of the returned struct */ - const char *version; /* LIBCURL_VERSION */ - unsigned int version_num; /* LIBCURL_VERSION_NUM */ - const char *host; /* OS/host/cpu/machine when configured */ - int features; /* bitmask, see defines below */ - const char *ssl_version; /* human readable string */ - long ssl_version_num; /* not used anymore, always 0 */ - const char *libz_version; /* human readable string */ - /* protocols is terminated by an entry with a NULL protoname */ - const char * const *protocols; - - /* The fields below this were added in CURLVERSION_SECOND */ - const char *ares; - int ares_num; - - /* This field was added in CURLVERSION_THIRD */ - const char *libidn; - - /* These field were added in CURLVERSION_FOURTH */ - - /* Same as '_libiconv_version' if built with HAVE_ICONV */ - int iconv_ver_num; - - const char *libssh_version; /* human readable string */ - -} curl_version_info_data; - -#define CURL_VERSION_IPV6 (1<<0) /* IPv6-enabled */ -#define CURL_VERSION_KERBEROS4 (1<<1) /* Kerberos V4 auth is supported - (deprecated) */ -#define CURL_VERSION_SSL (1<<2) /* SSL options are present */ -#define CURL_VERSION_LIBZ (1<<3) /* libz features are present */ -#define CURL_VERSION_NTLM (1<<4) /* NTLM auth is supported */ -#define CURL_VERSION_GSSNEGOTIATE (1<<5) /* Negotiate auth is supported - (deprecated) */ -#define CURL_VERSION_DEBUG (1<<6) /* Built with debug capabilities */ -#define CURL_VERSION_ASYNCHDNS (1<<7) /* Asynchronous DNS resolves */ -#define CURL_VERSION_SPNEGO (1<<8) /* SPNEGO auth is supported */ -#define CURL_VERSION_LARGEFILE (1<<9) /* Supports files larger than 2GB */ -#define CURL_VERSION_IDN (1<<10) /* Internationized Domain Names are - supported */ -#define CURL_VERSION_SSPI (1<<11) /* Built against Windows SSPI */ -#define CURL_VERSION_CONV (1<<12) /* Character conversions supported */ -#define CURL_VERSION_CURLDEBUG (1<<13) /* Debug memory tracking supported */ -#define CURL_VERSION_TLSAUTH_SRP (1<<14) /* TLS-SRP auth is supported */ -#define CURL_VERSION_NTLM_WB (1<<15) /* NTLM delegation to winbind helper - is suported */ -#define CURL_VERSION_HTTP2 (1<<16) /* HTTP2 support built-in */ -#define CURL_VERSION_GSSAPI (1<<17) /* Built against a GSS-API library */ -#define CURL_VERSION_KERBEROS5 (1<<18) /* Kerberos V5 auth is supported */ -#define CURL_VERSION_UNIX_SOCKETS (1<<19) /* Unix domain sockets support */ - - /* - * NAME curl_version_info() - * - * DESCRIPTION - * - * This function returns a pointer to a static copy of the version info - * struct. See above. - */ -CURL_EXTERN curl_version_info_data *curl_version_info(CURLversion); - -/* - * NAME curl_easy_strerror() - * - * DESCRIPTION - * - * The curl_easy_strerror function may be used to turn a CURLcode value - * into the equivalent human readable error string. This is useful - * for printing meaningful error messages. - */ -CURL_EXTERN const char *curl_easy_strerror(CURLcode); - -/* - * NAME curl_share_strerror() - * - * DESCRIPTION - * - * The curl_share_strerror function may be used to turn a CURLSHcode value - * into the equivalent human readable error string. This is useful - * for printing meaningful error messages. - */ -CURL_EXTERN const char *curl_share_strerror(CURLSHcode); - -/* - * NAME curl_easy_pause() - * - * DESCRIPTION - * - * The curl_easy_pause function pauses or unpauses transfers. Select the new - * state by setting the bitmask, use the convenience defines below. - * - */ -CURL_EXTERN CURLcode curl_easy_pause(CURL *handle, int bitmask); - -#define CURLPAUSE_RECV (1<<0) -#define CURLPAUSE_RECV_CONT (0) - -#define CURLPAUSE_SEND (1<<2) -#define CURLPAUSE_SEND_CONT (0) - -#define CURLPAUSE_ALL (CURLPAUSE_RECV|CURLPAUSE_SEND) -#define CURLPAUSE_CONT (CURLPAUSE_RECV_CONT|CURLPAUSE_SEND_CONT) - -#ifdef __cplusplus -} -#endif - -/* unfortunately, the easy.h and multi.h include files need options and info - stuff before they can be included! */ -#include "easy.h" /* nothing in curl is fun without the easy stuff */ -#include "multi.h" - -/* the typechecker doesn't work in C++ (yet) */ -#if defined(__GNUC__) && defined(__GNUC_MINOR__) && \ - ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) && \ - !defined(__cplusplus) && !defined(CURL_DISABLE_TYPECHECK) -#include "typecheck-gcc.h" -#else -#if defined(__STDC__) && (__STDC__ >= 1) -/* This preprocessor magic that replaces a call with the exact same call is - only done to make sure application authors pass exactly three arguments - to these functions. */ -#define curl_easy_setopt(handle,opt,param) curl_easy_setopt(handle,opt,param) -#define curl_easy_getinfo(handle,info,arg) curl_easy_getinfo(handle,info,arg) -#define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param) -#define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param) -#endif /* __STDC__ >= 1 */ -#endif /* gcc >= 4.3 && !__cplusplus */ - -#endif /* __CURL_CURL_H */ diff --git a/phonelibs/curl/include/curl/curlbuild.h b/phonelibs/curl/include/curl/curlbuild.h deleted file mode 100644 index 2bf01cf37c520d..00000000000000 --- a/phonelibs/curl/include/curl/curlbuild.h +++ /dev/null @@ -1,195 +0,0 @@ -/* include/curl/curlbuild.h. Generated from curlbuild.h.in by configure. */ -#ifndef __CURL_CURLBUILD_H -#define __CURL_CURLBUILD_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -/* ================================================================ */ -/* NOTES FOR CONFIGURE CAPABLE SYSTEMS */ -/* ================================================================ */ - -/* - * NOTE 1: - * ------- - * - * Nothing in this file is intended to be modified or adjusted by the - * curl library user nor by the curl library builder. - * - * If you think that something actually needs to be changed, adjusted - * or fixed in this file, then, report it on the libcurl development - * mailing list: http://cool.haxx.se/mailman/listinfo/curl-library/ - * - * This header file shall only export symbols which are 'curl' or 'CURL' - * prefixed, otherwise public name space would be polluted. - * - * NOTE 2: - * ------- - * - * Right now you might be staring at file include/curl/curlbuild.h.in or - * at file include/curl/curlbuild.h, this is due to the following reason: - * - * On systems capable of running the configure script, the configure process - * will overwrite the distributed include/curl/curlbuild.h file with one that - * is suitable and specific to the library being configured and built, which - * is generated from the include/curl/curlbuild.h.in template file. - * - */ - -/* ================================================================ */ -/* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */ -/* ================================================================ */ - -#ifdef CURL_SIZEOF_LONG -#error "CURL_SIZEOF_LONG shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_LONG_already_defined -#endif - -#ifdef CURL_TYPEOF_CURL_SOCKLEN_T -#error "CURL_TYPEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_already_defined -#endif - -#ifdef CURL_SIZEOF_CURL_SOCKLEN_T -#error "CURL_SIZEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_already_defined -#endif - -#ifdef CURL_TYPEOF_CURL_OFF_T -#error "CURL_TYPEOF_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_FORMAT_CURL_OFF_T -#error "CURL_FORMAT_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_FORMAT_CURL_OFF_TU -#error "CURL_FORMAT_CURL_OFF_TU shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_already_defined -#endif - -#ifdef CURL_FORMAT_OFF_T -#error "CURL_FORMAT_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_OFF_T_already_defined -#endif - -#ifdef CURL_SIZEOF_CURL_OFF_T -#error "CURL_SIZEOF_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_SUFFIX_CURL_OFF_T -#error "CURL_SUFFIX_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_SUFFIX_CURL_OFF_TU -#error "CURL_SUFFIX_CURL_OFF_TU shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_already_defined -#endif - -/* ================================================================ */ -/* EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY */ -/* ================================================================ */ - -/* Configure process defines this to 1 when it finds out that system */ -/* header file ws2tcpip.h must be included by the external interface. */ -/* #undef CURL_PULL_WS2TCPIP_H */ -#ifdef CURL_PULL_WS2TCPIP_H -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif -# include -# include -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file sys/types.h must be included by the external interface. */ -#define CURL_PULL_SYS_TYPES_H 1 -#ifdef CURL_PULL_SYS_TYPES_H -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file stdint.h must be included by the external interface. */ -#define CURL_PULL_STDINT_H 1 -#ifdef CURL_PULL_STDINT_H -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file inttypes.h must be included by the external interface. */ -#define CURL_PULL_INTTYPES_H 1 -#ifdef CURL_PULL_INTTYPES_H -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file sys/socket.h must be included by the external interface. */ -#define CURL_PULL_SYS_SOCKET_H 1 -#ifdef CURL_PULL_SYS_SOCKET_H -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file sys/poll.h must be included by the external interface. */ -/* #undef CURL_PULL_SYS_POLL_H */ -#ifdef CURL_PULL_SYS_POLL_H -# include -#endif - -/* Integral data type used for curl_socklen_t. */ -#define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t - -/* The size of `curl_socklen_t', as computed by sizeof. */ -#define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -/* Data type definition of curl_socklen_t. */ -typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t; - -/* Signed integral data type used for curl_off_t. */ -#define CURL_TYPEOF_CURL_OFF_T int64_t - -/* Data type definition of curl_off_t. */ -typedef CURL_TYPEOF_CURL_OFF_T curl_off_t; - -/* curl_off_t formatting string directive without "%" conversion specifier. */ -#define CURL_FORMAT_CURL_OFF_T "lld" - -/* unsigned curl_off_t formatting string without "%" conversion specifier. */ -#define CURL_FORMAT_CURL_OFF_TU "llu" - -/* curl_off_t formatting string directive with "%" conversion specifier. */ -#define CURL_FORMAT_OFF_T "%lld" - -/* The size of `curl_off_t', as computed by sizeof. */ -#define CURL_SIZEOF_CURL_OFF_T 8 - -/* curl_off_t constant suffix. */ -#define CURL_SUFFIX_CURL_OFF_T LL - -/* unsigned curl_off_t constant suffix. */ -#define CURL_SUFFIX_CURL_OFF_TU ULL - -#endif /* __CURL_CURLBUILD_H */ diff --git a/phonelibs/curl/include/curl/curlbuild.h.cmake b/phonelibs/curl/include/curl/curlbuild.h.cmake deleted file mode 100644 index 60bc7a70ec547e..00000000000000 --- a/phonelibs/curl/include/curl/curlbuild.h.cmake +++ /dev/null @@ -1,197 +0,0 @@ -#ifndef __CURL_CURLBUILD_H -#define __CURL_CURLBUILD_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -/* ================================================================ */ -/* NOTES FOR CONFIGURE CAPABLE SYSTEMS */ -/* ================================================================ */ - -/* - * NOTE 1: - * ------- - * - * Nothing in this file is intended to be modified or adjusted by the - * curl library user nor by the curl library builder. - * - * If you think that something actually needs to be changed, adjusted - * or fixed in this file, then, report it on the libcurl development - * mailing list: http://cool.haxx.se/mailman/listinfo/curl-library/ - * - * This header file shall only export symbols which are 'curl' or 'CURL' - * prefixed, otherwise public name space would be polluted. - * - * NOTE 2: - * ------- - * - * Right now you might be staring at file include/curl/curlbuild.h.in or - * at file include/curl/curlbuild.h, this is due to the following reason: - * - * On systems capable of running the configure script, the configure process - * will overwrite the distributed include/curl/curlbuild.h file with one that - * is suitable and specific to the library being configured and built, which - * is generated from the include/curl/curlbuild.h.in template file. - * - */ - -/* ================================================================ */ -/* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */ -/* ================================================================ */ - -#ifdef CURL_SIZEOF_LONG -#error "CURL_SIZEOF_LONG shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_LONG_already_defined -#endif - -#ifdef CURL_TYPEOF_CURL_SOCKLEN_T -#error "CURL_TYPEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_already_defined -#endif - -#ifdef CURL_SIZEOF_CURL_SOCKLEN_T -#error "CURL_SIZEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_already_defined -#endif - -#ifdef CURL_TYPEOF_CURL_OFF_T -#error "CURL_TYPEOF_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_FORMAT_CURL_OFF_T -#error "CURL_FORMAT_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_FORMAT_CURL_OFF_TU -#error "CURL_FORMAT_CURL_OFF_TU shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_already_defined -#endif - -#ifdef CURL_FORMAT_OFF_T -#error "CURL_FORMAT_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_OFF_T_already_defined -#endif - -#ifdef CURL_SIZEOF_CURL_OFF_T -#error "CURL_SIZEOF_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_SUFFIX_CURL_OFF_T -#error "CURL_SUFFIX_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_SUFFIX_CURL_OFF_TU -#error "CURL_SUFFIX_CURL_OFF_TU shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_already_defined -#endif - -/* ================================================================ */ -/* EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY */ -/* ================================================================ */ - -/* Configure process defines this to 1 when it finds out that system */ -/* header file ws2tcpip.h must be included by the external interface. */ -#cmakedefine CURL_PULL_WS2TCPIP_H -#ifdef CURL_PULL_WS2TCPIP_H -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif -# include -# include -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file sys/types.h must be included by the external interface. */ -#cmakedefine CURL_PULL_SYS_TYPES_H -#ifdef CURL_PULL_SYS_TYPES_H -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file stdint.h must be included by the external interface. */ -#cmakedefine CURL_PULL_STDINT_H -#ifdef CURL_PULL_STDINT_H -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file inttypes.h must be included by the external interface. */ -#cmakedefine CURL_PULL_INTTYPES_H -#ifdef CURL_PULL_INTTYPES_H -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file sys/socket.h must be included by the external interface. */ -#cmakedefine CURL_PULL_SYS_SOCKET_H -#ifdef CURL_PULL_SYS_SOCKET_H -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file sys/poll.h must be included by the external interface. */ -#cmakedefine CURL_PULL_SYS_POLL_H -#ifdef CURL_PULL_SYS_POLL_H -# include -#endif - -/* The size of `long', as computed by sizeof. */ -#define CURL_SIZEOF_LONG ${CURL_SIZEOF_LONG} - -/* Integral data type used for curl_socklen_t. */ -#define CURL_TYPEOF_CURL_SOCKLEN_T ${CURL_TYPEOF_CURL_SOCKLEN_T} - -/* The size of `curl_socklen_t', as computed by sizeof. */ -#define CURL_SIZEOF_CURL_SOCKLEN_T ${CURL_SIZEOF_CURL_SOCKLEN_T} - -/* Data type definition of curl_socklen_t. */ -typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t; - -/* Signed integral data type used for curl_off_t. */ -#define CURL_TYPEOF_CURL_OFF_T ${CURL_TYPEOF_CURL_OFF_T} - -/* Data type definition of curl_off_t. */ -typedef CURL_TYPEOF_CURL_OFF_T curl_off_t; - -/* curl_off_t formatting string directive without "%" conversion specifier. */ -#define CURL_FORMAT_CURL_OFF_T "${CURL_FORMAT_CURL_OFF_T}" - -/* unsigned curl_off_t formatting string without "%" conversion specifier. */ -#define CURL_FORMAT_CURL_OFF_TU "${CURL_FORMAT_CURL_OFF_TU}" - -/* curl_off_t formatting string directive with "%" conversion specifier. */ -#define CURL_FORMAT_OFF_T "${CURL_FORMAT_OFF_T}" - -/* The size of `curl_off_t', as computed by sizeof. */ -#define CURL_SIZEOF_CURL_OFF_T ${CURL_SIZEOF_CURL_OFF_T} - -/* curl_off_t constant suffix. */ -#define CURL_SUFFIX_CURL_OFF_T ${CURL_SUFFIX_CURL_OFF_T} - -/* unsigned curl_off_t constant suffix. */ -#define CURL_SUFFIX_CURL_OFF_TU ${CURL_SUFFIX_CURL_OFF_TU} - -#endif /* __CURL_CURLBUILD_H */ diff --git a/phonelibs/curl/include/curl/curlbuild.h.dist b/phonelibs/curl/include/curl/curlbuild.h.dist deleted file mode 100644 index f09419a8439151..00000000000000 --- a/phonelibs/curl/include/curl/curlbuild.h.dist +++ /dev/null @@ -1,585 +0,0 @@ -#ifndef __CURL_CURLBUILD_H -#define __CURL_CURLBUILD_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -/* ================================================================ */ -/* NOTES FOR CONFIGURE CAPABLE SYSTEMS */ -/* ================================================================ */ - -/* - * NOTE 1: - * ------- - * - * See file include/curl/curlbuild.h.in, run configure, and forget - * that this file exists it is only used for non-configure systems. - * But you can keep reading if you want ;-) - * - */ - -/* ================================================================ */ -/* NOTES FOR NON-CONFIGURE SYSTEMS */ -/* ================================================================ */ - -/* - * NOTE 1: - * ------- - * - * Nothing in this file is intended to be modified or adjusted by the - * curl library user nor by the curl library builder. - * - * If you think that something actually needs to be changed, adjusted - * or fixed in this file, then, report it on the libcurl development - * mailing list: http://cool.haxx.se/mailman/listinfo/curl-library/ - * - * Try to keep one section per platform, compiler and architecture, - * otherwise, if an existing section is reused for a different one and - * later on the original is adjusted, probably the piggybacking one can - * be adversely changed. - * - * In order to differentiate between platforms/compilers/architectures - * use only compiler built in predefined preprocessor symbols. - * - * This header file shall only export symbols which are 'curl' or 'CURL' - * prefixed, otherwise public name space would be polluted. - * - * NOTE 2: - * ------- - * - * For any given platform/compiler curl_off_t must be typedef'ed to a - * 64-bit wide signed integral data type. The width of this data type - * must remain constant and independent of any possible large file - * support settings. - * - * As an exception to the above, curl_off_t shall be typedef'ed to a - * 32-bit wide signed integral data type if there is no 64-bit type. - * - * As a general rule, curl_off_t shall not be mapped to off_t. This - * rule shall only be violated if off_t is the only 64-bit data type - * available and the size of off_t is independent of large file support - * settings. Keep your build on the safe side avoiding an off_t gating. - * If you have a 64-bit off_t then take for sure that another 64-bit - * data type exists, dig deeper and you will find it. - * - * NOTE 3: - * ------- - * - * Right now you might be staring at file include/curl/curlbuild.h.dist or - * at file include/curl/curlbuild.h, this is due to the following reason: - * file include/curl/curlbuild.h.dist is renamed to include/curl/curlbuild.h - * when the libcurl source code distribution archive file is created. - * - * File include/curl/curlbuild.h.dist is not included in the distribution - * archive. File include/curl/curlbuild.h is not present in the git tree. - * - * The distributed include/curl/curlbuild.h file is only intended to be used - * on systems which can not run the also distributed configure script. - * - * On systems capable of running the configure script, the configure process - * will overwrite the distributed include/curl/curlbuild.h file with one that - * is suitable and specific to the library being configured and built, which - * is generated from the include/curl/curlbuild.h.in template file. - * - * If you check out from git on a non-configure platform, you must run the - * appropriate buildconf* script to set up curlbuild.h and other local files. - * - */ - -/* ================================================================ */ -/* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */ -/* ================================================================ */ - -#ifdef CURL_SIZEOF_LONG -# error "CURL_SIZEOF_LONG shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_LONG_already_defined -#endif - -#ifdef CURL_TYPEOF_CURL_SOCKLEN_T -# error "CURL_TYPEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_already_defined -#endif - -#ifdef CURL_SIZEOF_CURL_SOCKLEN_T -# error "CURL_SIZEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_already_defined -#endif - -#ifdef CURL_TYPEOF_CURL_OFF_T -# error "CURL_TYPEOF_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_FORMAT_CURL_OFF_T -# error "CURL_FORMAT_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_FORMAT_CURL_OFF_TU -# error "CURL_FORMAT_CURL_OFF_TU shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_already_defined -#endif - -#ifdef CURL_FORMAT_OFF_T -# error "CURL_FORMAT_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_OFF_T_already_defined -#endif - -#ifdef CURL_SIZEOF_CURL_OFF_T -# error "CURL_SIZEOF_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_SUFFIX_CURL_OFF_T -# error "CURL_SUFFIX_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_SUFFIX_CURL_OFF_TU -# error "CURL_SUFFIX_CURL_OFF_TU shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_already_defined -#endif - -/* ================================================================ */ -/* EXTERNAL INTERFACE SETTINGS FOR NON-CONFIGURE SYSTEMS ONLY */ -/* ================================================================ */ - -#if defined(__DJGPP__) || defined(__GO32__) -# if defined(__DJGPP__) && (__DJGPP__ > 1) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# else -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# endif -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__SALFORDC__) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__BORLANDC__) -# if (__BORLANDC__ < 0x520) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# else -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T __int64 -# define CURL_FORMAT_CURL_OFF_T "I64d" -# define CURL_FORMAT_CURL_OFF_TU "I64u" -# define CURL_FORMAT_OFF_T "%I64d" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T i64 -# define CURL_SUFFIX_CURL_OFF_TU ui64 -# endif -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__TURBOC__) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__WATCOMC__) -# if defined(__386__) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T __int64 -# define CURL_FORMAT_CURL_OFF_T "I64d" -# define CURL_FORMAT_CURL_OFF_TU "I64u" -# define CURL_FORMAT_OFF_T "%I64d" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T i64 -# define CURL_SUFFIX_CURL_OFF_TU ui64 -# else -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# endif -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__POCC__) -# if (__POCC__ < 280) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# elif defined(_MSC_VER) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T __int64 -# define CURL_FORMAT_CURL_OFF_T "I64d" -# define CURL_FORMAT_CURL_OFF_TU "I64u" -# define CURL_FORMAT_OFF_T "%I64d" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T i64 -# define CURL_SUFFIX_CURL_OFF_TU ui64 -# else -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# endif -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__LCC__) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__SYMBIAN32__) -# if defined(__EABI__) /* Treat all ARM compilers equally */ -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# elif defined(__CW32__) -# pragma longlong on -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# elif defined(__VC32__) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T __int64 -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# endif -# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__MWERKS__) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(_WIN32_WCE) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T __int64 -# define CURL_FORMAT_CURL_OFF_T "I64d" -# define CURL_FORMAT_CURL_OFF_TU "I64u" -# define CURL_FORMAT_OFF_T "%I64d" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T i64 -# define CURL_SUFFIX_CURL_OFF_TU ui64 -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__MINGW32__) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "I64d" -# define CURL_FORMAT_CURL_OFF_TU "I64u" -# define CURL_FORMAT_OFF_T "%I64d" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__VMS) -# if defined(__VAX) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# else -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# endif -# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__OS400__) -# if defined(__ILEC400__) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 -# define CURL_PULL_SYS_TYPES_H 1 -# define CURL_PULL_SYS_SOCKET_H 1 -# endif - -#elif defined(__MVS__) -# if defined(__IBMC__) || defined(__IBMCPP__) -# if defined(_ILP32) -# define CURL_SIZEOF_LONG 4 -# elif defined(_LP64) -# define CURL_SIZEOF_LONG 8 -# endif -# if defined(_LONG_LONG) -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# elif defined(_LP64) -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# else -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# endif -# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 -# define CURL_PULL_SYS_TYPES_H 1 -# define CURL_PULL_SYS_SOCKET_H 1 -# endif - -#elif defined(__370__) -# if defined(__IBMC__) || defined(__IBMCPP__) -# if defined(_ILP32) -# define CURL_SIZEOF_LONG 4 -# elif defined(_LP64) -# define CURL_SIZEOF_LONG 8 -# endif -# if defined(_LONG_LONG) -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# elif defined(_LP64) -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# else -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# endif -# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 -# define CURL_PULL_SYS_TYPES_H 1 -# define CURL_PULL_SYS_SOCKET_H 1 -# endif - -#elif defined(TPF) -# define CURL_SIZEOF_LONG 8 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -/* ===================================== */ -/* KEEP MSVC THE PENULTIMATE ENTRY */ -/* ===================================== */ - -#elif defined(_MSC_VER) -# if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T __int64 -# define CURL_FORMAT_CURL_OFF_T "I64d" -# define CURL_FORMAT_CURL_OFF_TU "I64u" -# define CURL_FORMAT_OFF_T "%I64d" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T i64 -# define CURL_SUFFIX_CURL_OFF_TU ui64 -# else -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# endif -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -/* ===================================== */ -/* KEEP GENERIC GCC THE LAST ENTRY */ -/* ===================================== */ - -#elif defined(__GNUC__) -# if defined(__ILP32__) || \ - defined(__i386__) || defined(__ppc__) || defined(__arm__) || defined(__sparc__) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# elif defined(__LP64__) || \ - defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) -# define CURL_SIZEOF_LONG 8 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# endif -# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 -# define CURL_PULL_SYS_TYPES_H 1 -# define CURL_PULL_SYS_SOCKET_H 1 - -#else -# error "Unknown non-configure build target!" - Error Compilation_aborted_Unknown_non_configure_build_target -#endif - -/* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */ -/* sys/types.h is required here to properly make type definitions below. */ -#ifdef CURL_PULL_SYS_TYPES_H -# include -#endif - -/* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */ -/* sys/socket.h is required here to properly make type definitions below. */ -#ifdef CURL_PULL_SYS_SOCKET_H -# include -#endif - -/* Data type definition of curl_socklen_t. */ - -#ifdef CURL_TYPEOF_CURL_SOCKLEN_T - typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t; -#endif - -/* Data type definition of curl_off_t. */ - -#ifdef CURL_TYPEOF_CURL_OFF_T - typedef CURL_TYPEOF_CURL_OFF_T curl_off_t; -#endif - -#endif /* __CURL_CURLBUILD_H */ diff --git a/phonelibs/curl/include/curl/curlbuild.h.in b/phonelibs/curl/include/curl/curlbuild.h.in deleted file mode 100644 index 7cb2b6ef7eb1c7..00000000000000 --- a/phonelibs/curl/include/curl/curlbuild.h.in +++ /dev/null @@ -1,194 +0,0 @@ -#ifndef __CURL_CURLBUILD_H -#define __CURL_CURLBUILD_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -/* ================================================================ */ -/* NOTES FOR CONFIGURE CAPABLE SYSTEMS */ -/* ================================================================ */ - -/* - * NOTE 1: - * ------- - * - * Nothing in this file is intended to be modified or adjusted by the - * curl library user nor by the curl library builder. - * - * If you think that something actually needs to be changed, adjusted - * or fixed in this file, then, report it on the libcurl development - * mailing list: http://cool.haxx.se/mailman/listinfo/curl-library/ - * - * This header file shall only export symbols which are 'curl' or 'CURL' - * prefixed, otherwise public name space would be polluted. - * - * NOTE 2: - * ------- - * - * Right now you might be staring at file include/curl/curlbuild.h.in or - * at file include/curl/curlbuild.h, this is due to the following reason: - * - * On systems capable of running the configure script, the configure process - * will overwrite the distributed include/curl/curlbuild.h file with one that - * is suitable and specific to the library being configured and built, which - * is generated from the include/curl/curlbuild.h.in template file. - * - */ - -/* ================================================================ */ -/* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */ -/* ================================================================ */ - -#ifdef CURL_SIZEOF_LONG -#error "CURL_SIZEOF_LONG shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_LONG_already_defined -#endif - -#ifdef CURL_TYPEOF_CURL_SOCKLEN_T -#error "CURL_TYPEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_already_defined -#endif - -#ifdef CURL_SIZEOF_CURL_SOCKLEN_T -#error "CURL_SIZEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_already_defined -#endif - -#ifdef CURL_TYPEOF_CURL_OFF_T -#error "CURL_TYPEOF_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_FORMAT_CURL_OFF_T -#error "CURL_FORMAT_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_FORMAT_CURL_OFF_TU -#error "CURL_FORMAT_CURL_OFF_TU shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_already_defined -#endif - -#ifdef CURL_FORMAT_OFF_T -#error "CURL_FORMAT_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_OFF_T_already_defined -#endif - -#ifdef CURL_SIZEOF_CURL_OFF_T -#error "CURL_SIZEOF_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_SUFFIX_CURL_OFF_T -#error "CURL_SUFFIX_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_SUFFIX_CURL_OFF_TU -#error "CURL_SUFFIX_CURL_OFF_TU shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_already_defined -#endif - -/* ================================================================ */ -/* EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY */ -/* ================================================================ */ - -/* Configure process defines this to 1 when it finds out that system */ -/* header file ws2tcpip.h must be included by the external interface. */ -#undef CURL_PULL_WS2TCPIP_H -#ifdef CURL_PULL_WS2TCPIP_H -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif -# include -# include -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file sys/types.h must be included by the external interface. */ -#undef CURL_PULL_SYS_TYPES_H -#ifdef CURL_PULL_SYS_TYPES_H -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file stdint.h must be included by the external interface. */ -#undef CURL_PULL_STDINT_H -#ifdef CURL_PULL_STDINT_H -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file inttypes.h must be included by the external interface. */ -#undef CURL_PULL_INTTYPES_H -#ifdef CURL_PULL_INTTYPES_H -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file sys/socket.h must be included by the external interface. */ -#undef CURL_PULL_SYS_SOCKET_H -#ifdef CURL_PULL_SYS_SOCKET_H -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file sys/poll.h must be included by the external interface. */ -#undef CURL_PULL_SYS_POLL_H -#ifdef CURL_PULL_SYS_POLL_H -# include -#endif - -/* Integral data type used for curl_socklen_t. */ -#undef CURL_TYPEOF_CURL_SOCKLEN_T - -/* The size of `curl_socklen_t', as computed by sizeof. */ -#undef CURL_SIZEOF_CURL_SOCKLEN_T - -/* Data type definition of curl_socklen_t. */ -typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t; - -/* Signed integral data type used for curl_off_t. */ -#undef CURL_TYPEOF_CURL_OFF_T - -/* Data type definition of curl_off_t. */ -typedef CURL_TYPEOF_CURL_OFF_T curl_off_t; - -/* curl_off_t formatting string directive without "%" conversion specifier. */ -#undef CURL_FORMAT_CURL_OFF_T - -/* unsigned curl_off_t formatting string without "%" conversion specifier. */ -#undef CURL_FORMAT_CURL_OFF_TU - -/* curl_off_t formatting string directive with "%" conversion specifier. */ -#undef CURL_FORMAT_OFF_T - -/* The size of `curl_off_t', as computed by sizeof. */ -#undef CURL_SIZEOF_CURL_OFF_T - -/* curl_off_t constant suffix. */ -#undef CURL_SUFFIX_CURL_OFF_T - -/* unsigned curl_off_t constant suffix. */ -#undef CURL_SUFFIX_CURL_OFF_TU - -#endif /* __CURL_CURLBUILD_H */ diff --git a/phonelibs/curl/include/curl/curlrules.h b/phonelibs/curl/include/curl/curlrules.h deleted file mode 100644 index 1163e95f48ac87..00000000000000 --- a/phonelibs/curl/include/curl/curlrules.h +++ /dev/null @@ -1,248 +0,0 @@ -#ifndef __CURL_CURLRULES_H -#define __CURL_CURLRULES_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -/* ================================================================ */ -/* COMPILE TIME SANITY CHECKS */ -/* ================================================================ */ - -/* - * NOTE 1: - * ------- - * - * All checks done in this file are intentionally placed in a public - * header file which is pulled by curl/curl.h when an application is - * being built using an already built libcurl library. Additionally - * this file is also included and used when building the library. - * - * If compilation fails on this file it is certainly sure that the - * problem is elsewhere. It could be a problem in the curlbuild.h - * header file, or simply that you are using different compilation - * settings than those used to build the library. - * - * Nothing in this file is intended to be modified or adjusted by the - * curl library user nor by the curl library builder. - * - * Do not deactivate any check, these are done to make sure that the - * library is properly built and used. - * - * You can find further help on the libcurl development mailing list: - * http://cool.haxx.se/mailman/listinfo/curl-library/ - * - * NOTE 2 - * ------ - * - * Some of the following compile time checks are based on the fact - * that the dimension of a constant array can not be a negative one. - * In this way if the compile time verification fails, the compilation - * will fail issuing an error. The error description wording is compiler - * dependent but it will be quite similar to one of the following: - * - * "negative subscript or subscript is too large" - * "array must have at least one element" - * "-1 is an illegal array size" - * "size of array is negative" - * - * If you are building an application which tries to use an already - * built libcurl library and you are getting this kind of errors on - * this file, it is a clear indication that there is a mismatch between - * how the library was built and how you are trying to use it for your - * application. Your already compiled or binary library provider is the - * only one who can give you the details you need to properly use it. - */ - -/* - * Verify that some macros are actually defined. - */ - -#ifndef CURL_TYPEOF_CURL_SOCKLEN_T -# error "CURL_TYPEOF_CURL_SOCKLEN_T definition is missing!" - Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_is_missing -#endif - -#ifndef CURL_SIZEOF_CURL_SOCKLEN_T -# error "CURL_SIZEOF_CURL_SOCKLEN_T definition is missing!" - Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_is_missing -#endif - -#ifndef CURL_TYPEOF_CURL_OFF_T -# error "CURL_TYPEOF_CURL_OFF_T definition is missing!" - Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_is_missing -#endif - -#ifndef CURL_FORMAT_CURL_OFF_T -# error "CURL_FORMAT_CURL_OFF_T definition is missing!" - Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_is_missing -#endif - -#ifndef CURL_FORMAT_CURL_OFF_TU -# error "CURL_FORMAT_CURL_OFF_TU definition is missing!" - Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_is_missing -#endif - -#ifndef CURL_FORMAT_OFF_T -# error "CURL_FORMAT_OFF_T definition is missing!" - Error Compilation_aborted_CURL_FORMAT_OFF_T_is_missing -#endif - -#ifndef CURL_SIZEOF_CURL_OFF_T -# error "CURL_SIZEOF_CURL_OFF_T definition is missing!" - Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_is_missing -#endif - -#ifndef CURL_SUFFIX_CURL_OFF_T -# error "CURL_SUFFIX_CURL_OFF_T definition is missing!" - Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_is_missing -#endif - -#ifndef CURL_SUFFIX_CURL_OFF_TU -# error "CURL_SUFFIX_CURL_OFF_TU definition is missing!" - Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_is_missing -#endif - -/* - * Macros private to this header file. - */ - -#define CurlchkszEQ(t, s) sizeof(t) == s ? 1 : -1 - -#define CurlchkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1 - -/* - * Verify that the size previously defined and expected for - * curl_off_t is actually the the same as the one reported - * by sizeof() at compile time. - */ - -typedef char - __curl_rule_02__ - [CurlchkszEQ(curl_off_t, CURL_SIZEOF_CURL_OFF_T)]; - -/* - * Verify at compile time that the size of curl_off_t as reported - * by sizeof() is greater or equal than the one reported for long - * for the current compilation. - */ - -typedef char - __curl_rule_03__ - [CurlchkszGE(curl_off_t, long)]; - -/* - * Verify that the size previously defined and expected for - * curl_socklen_t is actually the the same as the one reported - * by sizeof() at compile time. - */ - -typedef char - __curl_rule_04__ - [CurlchkszEQ(curl_socklen_t, CURL_SIZEOF_CURL_SOCKLEN_T)]; - -/* - * Verify at compile time that the size of curl_socklen_t as reported - * by sizeof() is greater or equal than the one reported for int for - * the current compilation. - */ - -typedef char - __curl_rule_05__ - [CurlchkszGE(curl_socklen_t, int)]; - -/* ================================================================ */ -/* EXTERNALLY AND INTERNALLY VISIBLE DEFINITIONS */ -/* ================================================================ */ - -/* - * CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow - * these to be visible and exported by the external libcurl interface API, - * while also making them visible to the library internals, simply including - * curl_setup.h, without actually needing to include curl.h internally. - * If some day this section would grow big enough, all this should be moved - * to its own header file. - */ - -/* - * Figure out if we can use the ## preprocessor operator, which is supported - * by ISO/ANSI C and C++. Some compilers support it without setting __STDC__ - * or __cplusplus so we need to carefully check for them too. - */ - -#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \ - defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \ - defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \ - defined(__ILEC400__) - /* This compiler is believed to have an ISO compatible preprocessor */ -#define CURL_ISOCPP -#else - /* This compiler is believed NOT to have an ISO compatible preprocessor */ -#undef CURL_ISOCPP -#endif - -/* - * Macros for minimum-width signed and unsigned curl_off_t integer constants. - */ - -#if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551) -# define __CURL_OFF_T_C_HLPR2(x) x -# define __CURL_OFF_T_C_HLPR1(x) __CURL_OFF_T_C_HLPR2(x) -# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \ - __CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T) -# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \ - __CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU) -#else -# ifdef CURL_ISOCPP -# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix -# else -# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix -# endif -# define __CURL_OFF_T_C_HLPR1(Val,Suffix) __CURL_OFF_T_C_HLPR2(Val,Suffix) -# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T) -# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU) -#endif - -/* - * Get rid of macros private to this header file. - */ - -#undef CurlchkszEQ -#undef CurlchkszGE - -/* - * Get rid of macros not intended to exist beyond this point. - */ - -#undef CURL_PULL_WS2TCPIP_H -#undef CURL_PULL_SYS_TYPES_H -#undef CURL_PULL_SYS_SOCKET_H -#undef CURL_PULL_SYS_POLL_H -#undef CURL_PULL_STDINT_H -#undef CURL_PULL_INTTYPES_H - -#undef CURL_TYPEOF_CURL_SOCKLEN_T -#undef CURL_TYPEOF_CURL_OFF_T - -#ifdef CURL_NO_OLDIES -#undef CURL_FORMAT_OFF_T /* not required since 7.19.0 - obsoleted in 7.20.0 */ -#endif - -#endif /* __CURL_CURLRULES_H */ diff --git a/phonelibs/curl/include/curl/curlver.h b/phonelibs/curl/include/curl/curlver.h deleted file mode 100644 index be442eff8f6441..00000000000000 --- a/phonelibs/curl/include/curl/curlver.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef __CURL_CURLVER_H -#define __CURL_CURLVER_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -/* This header file contains nothing but libcurl version info, generated by - a script at release-time. This was made its own header file in 7.11.2 */ - -/* This is the global package copyright */ -#define LIBCURL_COPYRIGHT "1996 - 2015 Daniel Stenberg, ." - -/* This is the version number of the libcurl package from which this header - file origins: */ -#define LIBCURL_VERSION "7.43.0-DEV" - -/* The numeric version number is also available "in parts" by using these - defines: */ -#define LIBCURL_VERSION_MAJOR 7 -#define LIBCURL_VERSION_MINOR 43 -#define LIBCURL_VERSION_PATCH 0 - -/* This is the numeric version of the libcurl version number, meant for easier - parsing and comparions by programs. The LIBCURL_VERSION_NUM define will - always follow this syntax: - - 0xXXYYZZ - - Where XX, YY and ZZ are the main version, release and patch numbers in - hexadecimal (using 8 bits each). All three numbers are always represented - using two digits. 1.2 would appear as "0x010200" while version 9.11.7 - appears as "0x090b07". - - This 6-digit (24 bits) hexadecimal number does not show pre-release number, - and it is always a greater number in a more recent release. It makes - comparisons with greater than and less than work. - - Note: This define is the full hex number and _does not_ use the - CURL_VERSION_BITS() macro since curl's own configure script greps for it - and needs it to contain the full number. -*/ -#define LIBCURL_VERSION_NUM 0x072B00 - -/* - * This is the date and time when the full source package was created. The - * timestamp is not stored in git, as the timestamp is properly set in the - * tarballs by the maketgz script. - * - * The format of the date should follow this template: - * - * "Mon Feb 12 11:35:33 UTC 2007" - */ -#define LIBCURL_TIMESTAMP "DEV" - -#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|z) -#define CURL_AT_LEAST_VERSION(x,y,z) \ - (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z)) - -#endif /* __CURL_CURLVER_H */ diff --git a/phonelibs/curl/include/curl/easy.h b/phonelibs/curl/include/curl/easy.h deleted file mode 100644 index c1e3e76096e392..00000000000000 --- a/phonelibs/curl/include/curl/easy.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef __CURL_EASY_H -#define __CURL_EASY_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ -#ifdef __cplusplus -extern "C" { -#endif - -CURL_EXTERN CURL *curl_easy_init(void); -CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...); -CURL_EXTERN CURLcode curl_easy_perform(CURL *curl); -CURL_EXTERN void curl_easy_cleanup(CURL *curl); - -/* - * NAME curl_easy_getinfo() - * - * DESCRIPTION - * - * Request internal information from the curl session with this function. The - * third argument MUST be a pointer to a long, a pointer to a char * or a - * pointer to a double (as the documentation describes elsewhere). The data - * pointed to will be filled in accordingly and can be relied upon only if the - * function returns CURLE_OK. This function is intended to get used *AFTER* a - * performed transfer, all results from this function are undefined until the - * transfer is completed. - */ -CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...); - - -/* - * NAME curl_easy_duphandle() - * - * DESCRIPTION - * - * Creates a new curl session handle with the same options set for the handle - * passed in. Duplicating a handle could only be a matter of cloning data and - * options, internal state info and things like persistent connections cannot - * be transferred. It is useful in multithreaded applications when you can run - * curl_easy_duphandle() for each new thread to avoid a series of identical - * curl_easy_setopt() invokes in every thread. - */ -CURL_EXTERN CURL* curl_easy_duphandle(CURL *curl); - -/* - * NAME curl_easy_reset() - * - * DESCRIPTION - * - * Re-initializes a CURL handle to the default values. This puts back the - * handle to the same state as it was in when it was just created. - * - * It does keep: live connections, the Session ID cache, the DNS cache and the - * cookies. - */ -CURL_EXTERN void curl_easy_reset(CURL *curl); - -/* - * NAME curl_easy_recv() - * - * DESCRIPTION - * - * Receives data from the connected socket. Use after successful - * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. - */ -CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen, - size_t *n); - -/* - * NAME curl_easy_send() - * - * DESCRIPTION - * - * Sends data over the connected socket. Use after successful - * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. - */ -CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer, - size_t buflen, size_t *n); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/curl/include/curl/mprintf.h b/phonelibs/curl/include/curl/mprintf.h deleted file mode 100644 index c6b0d7679a6cf9..00000000000000 --- a/phonelibs/curl/include/curl/mprintf.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef __CURL_MPRINTF_H -#define __CURL_MPRINTF_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -#include -#include /* needed for FILE */ - -#include "curl.h" - -#ifdef __cplusplus -extern "C" { -#endif - -CURL_EXTERN int curl_mprintf(const char *format, ...); -CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...); -CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...); -CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength, - const char *format, ...); -CURL_EXTERN int curl_mvprintf(const char *format, va_list args); -CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args); -CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args); -CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength, - const char *format, va_list args); -CURL_EXTERN char *curl_maprintf(const char *format, ...); -CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args); - -#ifdef _MPRINTF_REPLACE -# undef printf -# undef fprintf -# undef sprintf -# undef vsprintf -# undef snprintf -# undef vprintf -# undef vfprintf -# undef vsnprintf -# undef aprintf -# undef vaprintf -# define printf curl_mprintf -# define fprintf curl_mfprintf -# define sprintf curl_msprintf -# define vsprintf curl_mvsprintf -# define snprintf curl_msnprintf -# define vprintf curl_mvprintf -# define vfprintf curl_mvfprintf -# define vsnprintf curl_mvsnprintf -# define aprintf curl_maprintf -# define vaprintf curl_mvaprintf -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __CURL_MPRINTF_H */ diff --git a/phonelibs/curl/include/curl/multi.h b/phonelibs/curl/include/curl/multi.h deleted file mode 100644 index 0d859f8fd98c50..00000000000000 --- a/phonelibs/curl/include/curl/multi.h +++ /dev/null @@ -1,404 +0,0 @@ -#ifndef __CURL_MULTI_H -#define __CURL_MULTI_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ -/* - This is an "external" header file. Don't give away any internals here! - - GOALS - - o Enable a "pull" interface. The application that uses libcurl decides where - and when to ask libcurl to get/send data. - - o Enable multiple simultaneous transfers in the same thread without making it - complicated for the application. - - o Enable the application to select() on its own file descriptors and curl's - file descriptors simultaneous easily. - -*/ - -/* - * This header file should not really need to include "curl.h" since curl.h - * itself includes this file and we expect user applications to do #include - * without the need for especially including multi.h. - * - * For some reason we added this include here at one point, and rather than to - * break existing (wrongly written) libcurl applications, we leave it as-is - * but with this warning attached. - */ -#include "curl.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void CURLM; - -typedef enum { - CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or - curl_multi_socket*() soon */ - CURLM_OK, - CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */ - CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */ - CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */ - CURLM_INTERNAL_ERROR, /* this is a libcurl bug */ - CURLM_BAD_SOCKET, /* the passed in socket argument did not match */ - CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */ - CURLM_ADDED_ALREADY, /* an easy handle already added to a multi handle was - attempted to get added - again */ - CURLM_LAST -} CURLMcode; - -/* just to make code nicer when using curl_multi_socket() you can now check - for CURLM_CALL_MULTI_SOCKET too in the same style it works for - curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */ -#define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM - -/* bitmask bits for CURLMOPT_PIPELINING */ -#define CURLPIPE_NOTHING 0L -#define CURLPIPE_HTTP1 1L -#define CURLPIPE_MULTIPLEX 2L - -typedef enum { - CURLMSG_NONE, /* first, not used */ - CURLMSG_DONE, /* This easy handle has completed. 'result' contains - the CURLcode of the transfer */ - CURLMSG_LAST /* last, not used */ -} CURLMSG; - -struct CURLMsg { - CURLMSG msg; /* what this message means */ - CURL *easy_handle; /* the handle it concerns */ - union { - void *whatever; /* message-specific data */ - CURLcode result; /* return code for transfer */ - } data; -}; -typedef struct CURLMsg CURLMsg; - -/* Based on poll(2) structure and values. - * We don't use pollfd and POLL* constants explicitly - * to cover platforms without poll(). */ -#define CURL_WAIT_POLLIN 0x0001 -#define CURL_WAIT_POLLPRI 0x0002 -#define CURL_WAIT_POLLOUT 0x0004 - -struct curl_waitfd { - curl_socket_t fd; - short events; - short revents; /* not supported yet */ -}; - -/* - * Name: curl_multi_init() - * - * Desc: inititalize multi-style curl usage - * - * Returns: a new CURLM handle to use in all 'curl_multi' functions. - */ -CURL_EXTERN CURLM *curl_multi_init(void); - -/* - * Name: curl_multi_add_handle() - * - * Desc: add a standard curl handle to the multi stack - * - * Returns: CURLMcode type, general multi error code. - */ -CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle, - CURL *curl_handle); - - /* - * Name: curl_multi_remove_handle() - * - * Desc: removes a curl handle from the multi stack again - * - * Returns: CURLMcode type, general multi error code. - */ -CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle, - CURL *curl_handle); - - /* - * Name: curl_multi_fdset() - * - * Desc: Ask curl for its fd_set sets. The app can use these to select() or - * poll() on. We want curl_multi_perform() called as soon as one of - * them are ready. - * - * Returns: CURLMcode type, general multi error code. - */ -CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle, - fd_set *read_fd_set, - fd_set *write_fd_set, - fd_set *exc_fd_set, - int *max_fd); - -/* - * Name: curl_multi_wait() - * - * Desc: Poll on all fds within a CURLM set as well as any - * additional fds passed to the function. - * - * Returns: CURLMcode type, general multi error code. - */ -CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle, - struct curl_waitfd extra_fds[], - unsigned int extra_nfds, - int timeout_ms, - int *ret); - - /* - * Name: curl_multi_perform() - * - * Desc: When the app thinks there's data available for curl it calls this - * function to read/write whatever there is right now. This returns - * as soon as the reads and writes are done. This function does not - * require that there actually is data available for reading or that - * data can be written, it can be called just in case. It returns - * the number of handles that still transfer data in the second - * argument's integer-pointer. - * - * Returns: CURLMcode type, general multi error code. *NOTE* that this only - * returns errors etc regarding the whole multi stack. There might - * still have occurred problems on invidual transfers even when this - * returns OK. - */ -CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle, - int *running_handles); - - /* - * Name: curl_multi_cleanup() - * - * Desc: Cleans up and removes a whole multi stack. It does not free or - * touch any individual easy handles in any way. We need to define - * in what state those handles will be if this function is called - * in the middle of a transfer. - * - * Returns: CURLMcode type, general multi error code. - */ -CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle); - -/* - * Name: curl_multi_info_read() - * - * Desc: Ask the multi handle if there's any messages/informationals from - * the individual transfers. Messages include informationals such as - * error code from the transfer or just the fact that a transfer is - * completed. More details on these should be written down as well. - * - * Repeated calls to this function will return a new struct each - * time, until a special "end of msgs" struct is returned as a signal - * that there is no more to get at this point. - * - * The data the returned pointer points to will not survive calling - * curl_multi_cleanup(). - * - * The 'CURLMsg' struct is meant to be very simple and only contain - * very basic informations. If more involved information is wanted, - * we will provide the particular "transfer handle" in that struct - * and that should/could/would be used in subsequent - * curl_easy_getinfo() calls (or similar). The point being that we - * must never expose complex structs to applications, as then we'll - * undoubtably get backwards compatibility problems in the future. - * - * Returns: A pointer to a filled-in struct, or NULL if it failed or ran out - * of structs. It also writes the number of messages left in the - * queue (after this read) in the integer the second argument points - * to. - */ -CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle, - int *msgs_in_queue); - -/* - * Name: curl_multi_strerror() - * - * Desc: The curl_multi_strerror function may be used to turn a CURLMcode - * value into the equivalent human readable error string. This is - * useful for printing meaningful error messages. - * - * Returns: A pointer to a zero-terminated error message. - */ -CURL_EXTERN const char *curl_multi_strerror(CURLMcode); - -/* - * Name: curl_multi_socket() and - * curl_multi_socket_all() - * - * Desc: An alternative version of curl_multi_perform() that allows the - * application to pass in one of the file descriptors that have been - * detected to have "action" on them and let libcurl perform. - * See man page for details. - */ -#define CURL_POLL_NONE 0 -#define CURL_POLL_IN 1 -#define CURL_POLL_OUT 2 -#define CURL_POLL_INOUT 3 -#define CURL_POLL_REMOVE 4 - -#define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD - -#define CURL_CSELECT_IN 0x01 -#define CURL_CSELECT_OUT 0x02 -#define CURL_CSELECT_ERR 0x04 - -typedef int (*curl_socket_callback)(CURL *easy, /* easy handle */ - curl_socket_t s, /* socket */ - int what, /* see above */ - void *userp, /* private callback - pointer */ - void *socketp); /* private socket - pointer */ -/* - * Name: curl_multi_timer_callback - * - * Desc: Called by libcurl whenever the library detects a change in the - * maximum number of milliseconds the app is allowed to wait before - * curl_multi_socket() or curl_multi_perform() must be called - * (to allow libcurl's timed events to take place). - * - * Returns: The callback should return zero. - */ -typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */ - long timeout_ms, /* see above */ - void *userp); /* private callback - pointer */ - -CURL_EXTERN CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s, - int *running_handles); - -CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle, - curl_socket_t s, - int ev_bitmask, - int *running_handles); - -CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle, - int *running_handles); - -#ifndef CURL_ALLOW_OLD_MULTI_SOCKET -/* This macro below was added in 7.16.3 to push users who recompile to use - the new curl_multi_socket_action() instead of the old curl_multi_socket() -*/ -#define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z) -#endif - -/* - * Name: curl_multi_timeout() - * - * Desc: Returns the maximum number of milliseconds the app is allowed to - * wait before curl_multi_socket() or curl_multi_perform() must be - * called (to allow libcurl's timed events to take place). - * - * Returns: CURLM error code. - */ -CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle, - long *milliseconds); - -#undef CINIT /* re-using the same name as in curl.h */ - -#ifdef CURL_ISOCPP -#define CINIT(name,type,num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num -#else -/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */ -#define LONG CURLOPTTYPE_LONG -#define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT -#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT -#define OFF_T CURLOPTTYPE_OFF_T -#define CINIT(name,type,number) CURLMOPT_/**/name = type + number -#endif - -typedef enum { - /* This is the socket callback function pointer */ - CINIT(SOCKETFUNCTION, FUNCTIONPOINT, 1), - - /* This is the argument passed to the socket callback */ - CINIT(SOCKETDATA, OBJECTPOINT, 2), - - /* set to 1 to enable pipelining for this multi handle */ - CINIT(PIPELINING, LONG, 3), - - /* This is the timer callback function pointer */ - CINIT(TIMERFUNCTION, FUNCTIONPOINT, 4), - - /* This is the argument passed to the timer callback */ - CINIT(TIMERDATA, OBJECTPOINT, 5), - - /* maximum number of entries in the connection cache */ - CINIT(MAXCONNECTS, LONG, 6), - - /* maximum number of (pipelining) connections to one host */ - CINIT(MAX_HOST_CONNECTIONS, LONG, 7), - - /* maximum number of requests in a pipeline */ - CINIT(MAX_PIPELINE_LENGTH, LONG, 8), - - /* a connection with a content-length longer than this - will not be considered for pipelining */ - CINIT(CONTENT_LENGTH_PENALTY_SIZE, OFF_T, 9), - - /* a connection with a chunk length longer than this - will not be considered for pipelining */ - CINIT(CHUNK_LENGTH_PENALTY_SIZE, OFF_T, 10), - - /* a list of site names(+port) that are blacklisted from - pipelining */ - CINIT(PIPELINING_SITE_BL, OBJECTPOINT, 11), - - /* a list of server types that are blacklisted from - pipelining */ - CINIT(PIPELINING_SERVER_BL, OBJECTPOINT, 12), - - /* maximum number of open connections in total */ - CINIT(MAX_TOTAL_CONNECTIONS, LONG, 13), - - CURLMOPT_LASTENTRY /* the last unused */ -} CURLMoption; - - -/* - * Name: curl_multi_setopt() - * - * Desc: Sets options for the multi handle. - * - * Returns: CURLM error code. - */ -CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle, - CURLMoption option, ...); - - -/* - * Name: curl_multi_assign() - * - * Desc: This function sets an association in the multi handle between the - * given socket and a private pointer of the application. This is - * (only) useful for curl_multi_socket uses. - * - * Returns: CURLM error code. - */ -CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle, - curl_socket_t sockfd, void *sockp); - -#ifdef __cplusplus -} /* end of extern "C" */ -#endif - -#endif diff --git a/phonelibs/curl/include/curl/stdcheaders.h b/phonelibs/curl/include/curl/stdcheaders.h deleted file mode 100644 index ad82ef6335d616..00000000000000 --- a/phonelibs/curl/include/curl/stdcheaders.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef __STDC_HEADERS_H -#define __STDC_HEADERS_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -#include - -size_t fread (void *, size_t, size_t, FILE *); -size_t fwrite (const void *, size_t, size_t, FILE *); - -int strcasecmp(const char *, const char *); -int strncasecmp(const char *, const char *, size_t); - -#endif /* __STDC_HEADERS_H */ diff --git a/phonelibs/curl/include/curl/typecheck-gcc.h b/phonelibs/curl/include/curl/typecheck-gcc.h deleted file mode 100644 index 13fb0fa9ee3d21..00000000000000 --- a/phonelibs/curl/include/curl/typecheck-gcc.h +++ /dev/null @@ -1,612 +0,0 @@ -#ifndef __CURL_TYPECHECK_GCC_H -#define __CURL_TYPECHECK_GCC_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -/* wraps curl_easy_setopt() with typechecking */ - -/* To add a new kind of warning, add an - * if(_curl_is_sometype_option(_curl_opt)) - * if(!_curl_is_sometype(value)) - * _curl_easy_setopt_err_sometype(); - * block and define _curl_is_sometype_option, _curl_is_sometype and - * _curl_easy_setopt_err_sometype below - * - * NOTE: We use two nested 'if' statements here instead of the && operator, in - * order to work around gcc bug #32061. It affects only gcc 4.3.x/4.4.x - * when compiling with -Wlogical-op. - * - * To add an option that uses the same type as an existing option, you'll just - * need to extend the appropriate _curl_*_option macro - */ -#define curl_easy_setopt(handle, option, value) \ -__extension__ ({ \ - __typeof__ (option) _curl_opt = option; \ - if(__builtin_constant_p(_curl_opt)) { \ - if(_curl_is_long_option(_curl_opt)) \ - if(!_curl_is_long(value)) \ - _curl_easy_setopt_err_long(); \ - if(_curl_is_off_t_option(_curl_opt)) \ - if(!_curl_is_off_t(value)) \ - _curl_easy_setopt_err_curl_off_t(); \ - if(_curl_is_string_option(_curl_opt)) \ - if(!_curl_is_string(value)) \ - _curl_easy_setopt_err_string(); \ - if(_curl_is_write_cb_option(_curl_opt)) \ - if(!_curl_is_write_cb(value)) \ - _curl_easy_setopt_err_write_callback(); \ - if((_curl_opt) == CURLOPT_READFUNCTION) \ - if(!_curl_is_read_cb(value)) \ - _curl_easy_setopt_err_read_cb(); \ - if((_curl_opt) == CURLOPT_IOCTLFUNCTION) \ - if(!_curl_is_ioctl_cb(value)) \ - _curl_easy_setopt_err_ioctl_cb(); \ - if((_curl_opt) == CURLOPT_SOCKOPTFUNCTION) \ - if(!_curl_is_sockopt_cb(value)) \ - _curl_easy_setopt_err_sockopt_cb(); \ - if((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION) \ - if(!_curl_is_opensocket_cb(value)) \ - _curl_easy_setopt_err_opensocket_cb(); \ - if((_curl_opt) == CURLOPT_PROGRESSFUNCTION) \ - if(!_curl_is_progress_cb(value)) \ - _curl_easy_setopt_err_progress_cb(); \ - if((_curl_opt) == CURLOPT_DEBUGFUNCTION) \ - if(!_curl_is_debug_cb(value)) \ - _curl_easy_setopt_err_debug_cb(); \ - if((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION) \ - if(!_curl_is_ssl_ctx_cb(value)) \ - _curl_easy_setopt_err_ssl_ctx_cb(); \ - if(_curl_is_conv_cb_option(_curl_opt)) \ - if(!_curl_is_conv_cb(value)) \ - _curl_easy_setopt_err_conv_cb(); \ - if((_curl_opt) == CURLOPT_SEEKFUNCTION) \ - if(!_curl_is_seek_cb(value)) \ - _curl_easy_setopt_err_seek_cb(); \ - if(_curl_is_cb_data_option(_curl_opt)) \ - if(!_curl_is_cb_data(value)) \ - _curl_easy_setopt_err_cb_data(); \ - if((_curl_opt) == CURLOPT_ERRORBUFFER) \ - if(!_curl_is_error_buffer(value)) \ - _curl_easy_setopt_err_error_buffer(); \ - if((_curl_opt) == CURLOPT_STDERR) \ - if(!_curl_is_FILE(value)) \ - _curl_easy_setopt_err_FILE(); \ - if(_curl_is_postfields_option(_curl_opt)) \ - if(!_curl_is_postfields(value)) \ - _curl_easy_setopt_err_postfields(); \ - if((_curl_opt) == CURLOPT_HTTPPOST) \ - if(!_curl_is_arr((value), struct curl_httppost)) \ - _curl_easy_setopt_err_curl_httpost(); \ - if(_curl_is_slist_option(_curl_opt)) \ - if(!_curl_is_arr((value), struct curl_slist)) \ - _curl_easy_setopt_err_curl_slist(); \ - if((_curl_opt) == CURLOPT_SHARE) \ - if(!_curl_is_ptr((value), CURLSH)) \ - _curl_easy_setopt_err_CURLSH(); \ - } \ - curl_easy_setopt(handle, _curl_opt, value); \ -}) - -/* wraps curl_easy_getinfo() with typechecking */ -/* FIXME: don't allow const pointers */ -#define curl_easy_getinfo(handle, info, arg) \ -__extension__ ({ \ - __typeof__ (info) _curl_info = info; \ - if(__builtin_constant_p(_curl_info)) { \ - if(_curl_is_string_info(_curl_info)) \ - if(!_curl_is_arr((arg), char *)) \ - _curl_easy_getinfo_err_string(); \ - if(_curl_is_long_info(_curl_info)) \ - if(!_curl_is_arr((arg), long)) \ - _curl_easy_getinfo_err_long(); \ - if(_curl_is_double_info(_curl_info)) \ - if(!_curl_is_arr((arg), double)) \ - _curl_easy_getinfo_err_double(); \ - if(_curl_is_slist_info(_curl_info)) \ - if(!_curl_is_arr((arg), struct curl_slist *)) \ - _curl_easy_getinfo_err_curl_slist(); \ - } \ - curl_easy_getinfo(handle, _curl_info, arg); \ -}) - -/* TODO: typechecking for curl_share_setopt() and curl_multi_setopt(), - * for now just make sure that the functions are called with three - * arguments - */ -#define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param) -#define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param) - - -/* the actual warnings, triggered by calling the _curl_easy_setopt_err* - * functions */ - -/* To define a new warning, use _CURL_WARNING(identifier, "message") */ -#define _CURL_WARNING(id, message) \ - static void __attribute__((__warning__(message))) \ - __attribute__((__unused__)) __attribute__((__noinline__)) \ - id(void) { __asm__(""); } - -_CURL_WARNING(_curl_easy_setopt_err_long, - "curl_easy_setopt expects a long argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_curl_off_t, - "curl_easy_setopt expects a curl_off_t argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_string, - "curl_easy_setopt expects a " - "string (char* or char[]) argument for this option" - ) -_CURL_WARNING(_curl_easy_setopt_err_write_callback, - "curl_easy_setopt expects a curl_write_callback argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_read_cb, - "curl_easy_setopt expects a curl_read_callback argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_ioctl_cb, - "curl_easy_setopt expects a curl_ioctl_callback argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_sockopt_cb, - "curl_easy_setopt expects a curl_sockopt_callback argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_opensocket_cb, - "curl_easy_setopt expects a " - "curl_opensocket_callback argument for this option" - ) -_CURL_WARNING(_curl_easy_setopt_err_progress_cb, - "curl_easy_setopt expects a curl_progress_callback argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_debug_cb, - "curl_easy_setopt expects a curl_debug_callback argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_ssl_ctx_cb, - "curl_easy_setopt expects a curl_ssl_ctx_callback argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_conv_cb, - "curl_easy_setopt expects a curl_conv_callback argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_seek_cb, - "curl_easy_setopt expects a curl_seek_callback argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_cb_data, - "curl_easy_setopt expects a " - "private data pointer as argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_error_buffer, - "curl_easy_setopt expects a " - "char buffer of CURL_ERROR_SIZE as argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_FILE, - "curl_easy_setopt expects a FILE* argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_postfields, - "curl_easy_setopt expects a void* or char* argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_curl_httpost, - "curl_easy_setopt expects a struct curl_httppost* argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_curl_slist, - "curl_easy_setopt expects a struct curl_slist* argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_CURLSH, - "curl_easy_setopt expects a CURLSH* argument for this option") - -_CURL_WARNING(_curl_easy_getinfo_err_string, - "curl_easy_getinfo expects a pointer to char * for this info") -_CURL_WARNING(_curl_easy_getinfo_err_long, - "curl_easy_getinfo expects a pointer to long for this info") -_CURL_WARNING(_curl_easy_getinfo_err_double, - "curl_easy_getinfo expects a pointer to double for this info") -_CURL_WARNING(_curl_easy_getinfo_err_curl_slist, - "curl_easy_getinfo expects a pointer to struct curl_slist * for this info") - -/* groups of curl_easy_setops options that take the same type of argument */ - -/* To add a new option to one of the groups, just add - * (option) == CURLOPT_SOMETHING - * to the or-expression. If the option takes a long or curl_off_t, you don't - * have to do anything - */ - -/* evaluates to true if option takes a long argument */ -#define _curl_is_long_option(option) \ - (0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT) - -#define _curl_is_off_t_option(option) \ - ((option) > CURLOPTTYPE_OFF_T) - -/* evaluates to true if option takes a char* argument */ -#define _curl_is_string_option(option) \ - ((option) == CURLOPT_URL || \ - (option) == CURLOPT_PROXY || \ - (option) == CURLOPT_INTERFACE || \ - (option) == CURLOPT_NETRC_FILE || \ - (option) == CURLOPT_USERPWD || \ - (option) == CURLOPT_USERNAME || \ - (option) == CURLOPT_PASSWORD || \ - (option) == CURLOPT_PROXYUSERPWD || \ - (option) == CURLOPT_PROXYUSERNAME || \ - (option) == CURLOPT_PROXYPASSWORD || \ - (option) == CURLOPT_NOPROXY || \ - (option) == CURLOPT_ACCEPT_ENCODING || \ - (option) == CURLOPT_REFERER || \ - (option) == CURLOPT_USERAGENT || \ - (option) == CURLOPT_COOKIE || \ - (option) == CURLOPT_COOKIEFILE || \ - (option) == CURLOPT_COOKIEJAR || \ - (option) == CURLOPT_COOKIELIST || \ - (option) == CURLOPT_FTPPORT || \ - (option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \ - (option) == CURLOPT_FTP_ACCOUNT || \ - (option) == CURLOPT_RANGE || \ - (option) == CURLOPT_CUSTOMREQUEST || \ - (option) == CURLOPT_SSLCERT || \ - (option) == CURLOPT_SSLCERTTYPE || \ - (option) == CURLOPT_SSLKEY || \ - (option) == CURLOPT_SSLKEYTYPE || \ - (option) == CURLOPT_KEYPASSWD || \ - (option) == CURLOPT_SSLENGINE || \ - (option) == CURLOPT_CAINFO || \ - (option) == CURLOPT_CAPATH || \ - (option) == CURLOPT_RANDOM_FILE || \ - (option) == CURLOPT_EGDSOCKET || \ - (option) == CURLOPT_SSL_CIPHER_LIST || \ - (option) == CURLOPT_KRBLEVEL || \ - (option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \ - (option) == CURLOPT_SSH_PUBLIC_KEYFILE || \ - (option) == CURLOPT_SSH_PRIVATE_KEYFILE || \ - (option) == CURLOPT_CRLFILE || \ - (option) == CURLOPT_ISSUERCERT || \ - (option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \ - (option) == CURLOPT_SSH_KNOWNHOSTS || \ - (option) == CURLOPT_MAIL_FROM || \ - (option) == CURLOPT_RTSP_SESSION_ID || \ - (option) == CURLOPT_RTSP_STREAM_URI || \ - (option) == CURLOPT_RTSP_TRANSPORT || \ - (option) == CURLOPT_XOAUTH2_BEARER || \ - (option) == CURLOPT_DNS_SERVERS || \ - (option) == CURLOPT_DNS_INTERFACE || \ - (option) == CURLOPT_DNS_LOCAL_IP4 || \ - (option) == CURLOPT_DNS_LOCAL_IP6 || \ - (option) == CURLOPT_LOGIN_OPTIONS || \ - (option) == CURLOPT_PROXY_SERVICE_NAME || \ - (option) == CURLOPT_SERVICE_NAME || \ - 0) - -/* evaluates to true if option takes a curl_write_callback argument */ -#define _curl_is_write_cb_option(option) \ - ((option) == CURLOPT_HEADERFUNCTION || \ - (option) == CURLOPT_WRITEFUNCTION) - -/* evaluates to true if option takes a curl_conv_callback argument */ -#define _curl_is_conv_cb_option(option) \ - ((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \ - (option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \ - (option) == CURLOPT_CONV_FROM_UTF8_FUNCTION) - -/* evaluates to true if option takes a data argument to pass to a callback */ -#define _curl_is_cb_data_option(option) \ - ((option) == CURLOPT_WRITEDATA || \ - (option) == CURLOPT_READDATA || \ - (option) == CURLOPT_IOCTLDATA || \ - (option) == CURLOPT_SOCKOPTDATA || \ - (option) == CURLOPT_OPENSOCKETDATA || \ - (option) == CURLOPT_PROGRESSDATA || \ - (option) == CURLOPT_HEADERDATA || \ - (option) == CURLOPT_DEBUGDATA || \ - (option) == CURLOPT_SSL_CTX_DATA || \ - (option) == CURLOPT_SEEKDATA || \ - (option) == CURLOPT_PRIVATE || \ - (option) == CURLOPT_SSH_KEYDATA || \ - (option) == CURLOPT_INTERLEAVEDATA || \ - (option) == CURLOPT_CHUNK_DATA || \ - (option) == CURLOPT_FNMATCH_DATA || \ - 0) - -/* evaluates to true if option takes a POST data argument (void* or char*) */ -#define _curl_is_postfields_option(option) \ - ((option) == CURLOPT_POSTFIELDS || \ - (option) == CURLOPT_COPYPOSTFIELDS || \ - 0) - -/* evaluates to true if option takes a struct curl_slist * argument */ -#define _curl_is_slist_option(option) \ - ((option) == CURLOPT_HTTPHEADER || \ - (option) == CURLOPT_HTTP200ALIASES || \ - (option) == CURLOPT_QUOTE || \ - (option) == CURLOPT_POSTQUOTE || \ - (option) == CURLOPT_PREQUOTE || \ - (option) == CURLOPT_TELNETOPTIONS || \ - (option) == CURLOPT_MAIL_RCPT || \ - 0) - -/* groups of curl_easy_getinfo infos that take the same type of argument */ - -/* evaluates to true if info expects a pointer to char * argument */ -#define _curl_is_string_info(info) \ - (CURLINFO_STRING < (info) && (info) < CURLINFO_LONG) - -/* evaluates to true if info expects a pointer to long argument */ -#define _curl_is_long_info(info) \ - (CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE) - -/* evaluates to true if info expects a pointer to double argument */ -#define _curl_is_double_info(info) \ - (CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST) - -/* true if info expects a pointer to struct curl_slist * argument */ -#define _curl_is_slist_info(info) \ - (CURLINFO_SLIST < (info)) - - -/* typecheck helpers -- check whether given expression has requested type*/ - -/* For pointers, you can use the _curl_is_ptr/_curl_is_arr macros, - * otherwise define a new macro. Search for __builtin_types_compatible_p - * in the GCC manual. - * NOTE: these macros MUST NOT EVALUATE their arguments! The argument is - * the actual expression passed to the curl_easy_setopt macro. This - * means that you can only apply the sizeof and __typeof__ operators, no - * == or whatsoever. - */ - -/* XXX: should evaluate to true iff expr is a pointer */ -#define _curl_is_any_ptr(expr) \ - (sizeof(expr) == sizeof(void*)) - -/* evaluates to true if expr is NULL */ -/* XXX: must not evaluate expr, so this check is not accurate */ -#define _curl_is_NULL(expr) \ - (__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL))) - -/* evaluates to true if expr is type*, const type* or NULL */ -#define _curl_is_ptr(expr, type) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), type *) || \ - __builtin_types_compatible_p(__typeof__(expr), const type *)) - -/* evaluates to true if expr is one of type[], type*, NULL or const type* */ -#define _curl_is_arr(expr, type) \ - (_curl_is_ptr((expr), type) || \ - __builtin_types_compatible_p(__typeof__(expr), type [])) - -/* evaluates to true if expr is a string */ -#define _curl_is_string(expr) \ - (_curl_is_arr((expr), char) || \ - _curl_is_arr((expr), signed char) || \ - _curl_is_arr((expr), unsigned char)) - -/* evaluates to true if expr is a long (no matter the signedness) - * XXX: for now, int is also accepted (and therefore short and char, which - * are promoted to int when passed to a variadic function) */ -#define _curl_is_long(expr) \ - (__builtin_types_compatible_p(__typeof__(expr), long) || \ - __builtin_types_compatible_p(__typeof__(expr), signed long) || \ - __builtin_types_compatible_p(__typeof__(expr), unsigned long) || \ - __builtin_types_compatible_p(__typeof__(expr), int) || \ - __builtin_types_compatible_p(__typeof__(expr), signed int) || \ - __builtin_types_compatible_p(__typeof__(expr), unsigned int) || \ - __builtin_types_compatible_p(__typeof__(expr), short) || \ - __builtin_types_compatible_p(__typeof__(expr), signed short) || \ - __builtin_types_compatible_p(__typeof__(expr), unsigned short) || \ - __builtin_types_compatible_p(__typeof__(expr), char) || \ - __builtin_types_compatible_p(__typeof__(expr), signed char) || \ - __builtin_types_compatible_p(__typeof__(expr), unsigned char)) - -/* evaluates to true if expr is of type curl_off_t */ -#define _curl_is_off_t(expr) \ - (__builtin_types_compatible_p(__typeof__(expr), curl_off_t)) - -/* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */ -/* XXX: also check size of an char[] array? */ -#define _curl_is_error_buffer(expr) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), char *) || \ - __builtin_types_compatible_p(__typeof__(expr), char[])) - -/* evaluates to true if expr is of type (const) void* or (const) FILE* */ -#if 0 -#define _curl_is_cb_data(expr) \ - (_curl_is_ptr((expr), void) || \ - _curl_is_ptr((expr), FILE)) -#else /* be less strict */ -#define _curl_is_cb_data(expr) \ - _curl_is_any_ptr(expr) -#endif - -/* evaluates to true if expr is of type FILE* */ -#define _curl_is_FILE(expr) \ - (__builtin_types_compatible_p(__typeof__(expr), FILE *)) - -/* evaluates to true if expr can be passed as POST data (void* or char*) */ -#define _curl_is_postfields(expr) \ - (_curl_is_ptr((expr), void) || \ - _curl_is_arr((expr), char)) - -/* FIXME: the whole callback checking is messy... - * The idea is to tolerate char vs. void and const vs. not const - * pointers in arguments at least - */ -/* helper: __builtin_types_compatible_p distinguishes between functions and - * function pointers, hide it */ -#define _curl_callback_compatible(func, type) \ - (__builtin_types_compatible_p(__typeof__(func), type) || \ - __builtin_types_compatible_p(__typeof__(func), type*)) - -/* evaluates to true if expr is of type curl_read_callback or "similar" */ -#define _curl_is_read_cb(expr) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), __typeof__(fread)) || \ - __builtin_types_compatible_p(__typeof__(expr), curl_read_callback) || \ - _curl_callback_compatible((expr), _curl_read_callback1) || \ - _curl_callback_compatible((expr), _curl_read_callback2) || \ - _curl_callback_compatible((expr), _curl_read_callback3) || \ - _curl_callback_compatible((expr), _curl_read_callback4) || \ - _curl_callback_compatible((expr), _curl_read_callback5) || \ - _curl_callback_compatible((expr), _curl_read_callback6)) -typedef size_t (_curl_read_callback1)(char *, size_t, size_t, void*); -typedef size_t (_curl_read_callback2)(char *, size_t, size_t, const void*); -typedef size_t (_curl_read_callback3)(char *, size_t, size_t, FILE*); -typedef size_t (_curl_read_callback4)(void *, size_t, size_t, void*); -typedef size_t (_curl_read_callback5)(void *, size_t, size_t, const void*); -typedef size_t (_curl_read_callback6)(void *, size_t, size_t, FILE*); - -/* evaluates to true if expr is of type curl_write_callback or "similar" */ -#define _curl_is_write_cb(expr) \ - (_curl_is_read_cb(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), __typeof__(fwrite)) || \ - __builtin_types_compatible_p(__typeof__(expr), curl_write_callback) || \ - _curl_callback_compatible((expr), _curl_write_callback1) || \ - _curl_callback_compatible((expr), _curl_write_callback2) || \ - _curl_callback_compatible((expr), _curl_write_callback3) || \ - _curl_callback_compatible((expr), _curl_write_callback4) || \ - _curl_callback_compatible((expr), _curl_write_callback5) || \ - _curl_callback_compatible((expr), _curl_write_callback6)) -typedef size_t (_curl_write_callback1)(const char *, size_t, size_t, void*); -typedef size_t (_curl_write_callback2)(const char *, size_t, size_t, - const void*); -typedef size_t (_curl_write_callback3)(const char *, size_t, size_t, FILE*); -typedef size_t (_curl_write_callback4)(const void *, size_t, size_t, void*); -typedef size_t (_curl_write_callback5)(const void *, size_t, size_t, - const void*); -typedef size_t (_curl_write_callback6)(const void *, size_t, size_t, FILE*); - -/* evaluates to true if expr is of type curl_ioctl_callback or "similar" */ -#define _curl_is_ioctl_cb(expr) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), curl_ioctl_callback) || \ - _curl_callback_compatible((expr), _curl_ioctl_callback1) || \ - _curl_callback_compatible((expr), _curl_ioctl_callback2) || \ - _curl_callback_compatible((expr), _curl_ioctl_callback3) || \ - _curl_callback_compatible((expr), _curl_ioctl_callback4)) -typedef curlioerr (_curl_ioctl_callback1)(CURL *, int, void*); -typedef curlioerr (_curl_ioctl_callback2)(CURL *, int, const void*); -typedef curlioerr (_curl_ioctl_callback3)(CURL *, curliocmd, void*); -typedef curlioerr (_curl_ioctl_callback4)(CURL *, curliocmd, const void*); - -/* evaluates to true if expr is of type curl_sockopt_callback or "similar" */ -#define _curl_is_sockopt_cb(expr) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), curl_sockopt_callback) || \ - _curl_callback_compatible((expr), _curl_sockopt_callback1) || \ - _curl_callback_compatible((expr), _curl_sockopt_callback2)) -typedef int (_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype); -typedef int (_curl_sockopt_callback2)(const void *, curl_socket_t, - curlsocktype); - -/* evaluates to true if expr is of type curl_opensocket_callback or - "similar" */ -#define _curl_is_opensocket_cb(expr) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), curl_opensocket_callback) ||\ - _curl_callback_compatible((expr), _curl_opensocket_callback1) || \ - _curl_callback_compatible((expr), _curl_opensocket_callback2) || \ - _curl_callback_compatible((expr), _curl_opensocket_callback3) || \ - _curl_callback_compatible((expr), _curl_opensocket_callback4)) -typedef curl_socket_t (_curl_opensocket_callback1) - (void *, curlsocktype, struct curl_sockaddr *); -typedef curl_socket_t (_curl_opensocket_callback2) - (void *, curlsocktype, const struct curl_sockaddr *); -typedef curl_socket_t (_curl_opensocket_callback3) - (const void *, curlsocktype, struct curl_sockaddr *); -typedef curl_socket_t (_curl_opensocket_callback4) - (const void *, curlsocktype, const struct curl_sockaddr *); - -/* evaluates to true if expr is of type curl_progress_callback or "similar" */ -#define _curl_is_progress_cb(expr) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), curl_progress_callback) || \ - _curl_callback_compatible((expr), _curl_progress_callback1) || \ - _curl_callback_compatible((expr), _curl_progress_callback2)) -typedef int (_curl_progress_callback1)(void *, - double, double, double, double); -typedef int (_curl_progress_callback2)(const void *, - double, double, double, double); - -/* evaluates to true if expr is of type curl_debug_callback or "similar" */ -#define _curl_is_debug_cb(expr) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), curl_debug_callback) || \ - _curl_callback_compatible((expr), _curl_debug_callback1) || \ - _curl_callback_compatible((expr), _curl_debug_callback2) || \ - _curl_callback_compatible((expr), _curl_debug_callback3) || \ - _curl_callback_compatible((expr), _curl_debug_callback4) || \ - _curl_callback_compatible((expr), _curl_debug_callback5) || \ - _curl_callback_compatible((expr), _curl_debug_callback6) || \ - _curl_callback_compatible((expr), _curl_debug_callback7) || \ - _curl_callback_compatible((expr), _curl_debug_callback8)) -typedef int (_curl_debug_callback1) (CURL *, - curl_infotype, char *, size_t, void *); -typedef int (_curl_debug_callback2) (CURL *, - curl_infotype, char *, size_t, const void *); -typedef int (_curl_debug_callback3) (CURL *, - curl_infotype, const char *, size_t, void *); -typedef int (_curl_debug_callback4) (CURL *, - curl_infotype, const char *, size_t, const void *); -typedef int (_curl_debug_callback5) (CURL *, - curl_infotype, unsigned char *, size_t, void *); -typedef int (_curl_debug_callback6) (CURL *, - curl_infotype, unsigned char *, size_t, const void *); -typedef int (_curl_debug_callback7) (CURL *, - curl_infotype, const unsigned char *, size_t, void *); -typedef int (_curl_debug_callback8) (CURL *, - curl_infotype, const unsigned char *, size_t, const void *); - -/* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */ -/* this is getting even messier... */ -#define _curl_is_ssl_ctx_cb(expr) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), curl_ssl_ctx_callback) || \ - _curl_callback_compatible((expr), _curl_ssl_ctx_callback1) || \ - _curl_callback_compatible((expr), _curl_ssl_ctx_callback2) || \ - _curl_callback_compatible((expr), _curl_ssl_ctx_callback3) || \ - _curl_callback_compatible((expr), _curl_ssl_ctx_callback4) || \ - _curl_callback_compatible((expr), _curl_ssl_ctx_callback5) || \ - _curl_callback_compatible((expr), _curl_ssl_ctx_callback6) || \ - _curl_callback_compatible((expr), _curl_ssl_ctx_callback7) || \ - _curl_callback_compatible((expr), _curl_ssl_ctx_callback8)) -typedef CURLcode (_curl_ssl_ctx_callback1)(CURL *, void *, void *); -typedef CURLcode (_curl_ssl_ctx_callback2)(CURL *, void *, const void *); -typedef CURLcode (_curl_ssl_ctx_callback3)(CURL *, const void *, void *); -typedef CURLcode (_curl_ssl_ctx_callback4)(CURL *, const void *, const void *); -#ifdef HEADER_SSL_H -/* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX - * this will of course break if we're included before OpenSSL headers... - */ -typedef CURLcode (_curl_ssl_ctx_callback5)(CURL *, SSL_CTX, void *); -typedef CURLcode (_curl_ssl_ctx_callback6)(CURL *, SSL_CTX, const void *); -typedef CURLcode (_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX, void *); -typedef CURLcode (_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX, - const void *); -#else -typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5; -typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6; -typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback7; -typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback8; -#endif - -/* evaluates to true if expr is of type curl_conv_callback or "similar" */ -#define _curl_is_conv_cb(expr) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), curl_conv_callback) || \ - _curl_callback_compatible((expr), _curl_conv_callback1) || \ - _curl_callback_compatible((expr), _curl_conv_callback2) || \ - _curl_callback_compatible((expr), _curl_conv_callback3) || \ - _curl_callback_compatible((expr), _curl_conv_callback4)) -typedef CURLcode (*_curl_conv_callback1)(char *, size_t length); -typedef CURLcode (*_curl_conv_callback2)(const char *, size_t length); -typedef CURLcode (*_curl_conv_callback3)(void *, size_t length); -typedef CURLcode (*_curl_conv_callback4)(const void *, size_t length); - -/* evaluates to true if expr is of type curl_seek_callback or "similar" */ -#define _curl_is_seek_cb(expr) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), curl_seek_callback) || \ - _curl_callback_compatible((expr), _curl_seek_callback1) || \ - _curl_callback_compatible((expr), _curl_seek_callback2)) -typedef CURLcode (*_curl_seek_callback1)(void *, curl_off_t, int); -typedef CURLcode (*_curl_seek_callback2)(const void *, curl_off_t, int); - - -#endif /* __CURL_TYPECHECK_GCC_H */ diff --git a/phonelibs/curl/lib/libcurl.a b/phonelibs/curl/lib/libcurl.a deleted file mode 100644 index 494ac6c043c192..00000000000000 Binary files a/phonelibs/curl/lib/libcurl.a and /dev/null differ diff --git a/phonelibs/hierarchy/lib/_hierarchy.so b/phonelibs/hierarchy/lib/_hierarchy.so deleted file mode 100755 index 367b717758b2c8..00000000000000 Binary files a/phonelibs/hierarchy/lib/_hierarchy.so and /dev/null differ diff --git a/phonelibs/install_capnp.sh b/phonelibs/install_capnp.sh deleted file mode 100755 index b1ea7602f1d4f0..00000000000000 --- a/phonelibs/install_capnp.sh +++ /dev/null @@ -1,42 +0,0 @@ -set -e -echo "Installing capnp" - -cd /tmp -VERSION=0.6.1 -wget https://capnproto.org/capnproto-c++-${VERSION}.tar.gz -tar xvf capnproto-c++-${VERSION}.tar.gz -cd capnproto-c++-${VERSION} -CXXFLAGS="-fPIC" ./configure - -make -j4 -make install - -# manually build binaries statically -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 - -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 - -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 - -cp .libs/capnp /usr/local/bin/ -rm /usr/local/bin/capnpc -ln -s /usr/local/bin/capnp /usr/local/bin/capnpc -cp .libs/capnpc-c++ /usr/local/bin/ -cp .libs/capnpc-capnp /usr/local/bin/ -cp .libs/*.a /usr/local/lib - -cd /tmp -echo "Installing c-capnp" -git clone https://github.com/commaai/c-capnproto.git -cd c-capnproto -git submodule update --init --recursive -autoreconf -f -i -s -CXXFLAGS="-fPIC" ./configure -make -j4 -make install - -# manually build binaries statically -gcc -fPIC -o .libs/capnpc-c compiler/capnpc-c.o compiler/schema.capnp.o compiler/str.o ./.libs/libcapnp_c.a - -cp .libs/capnpc-c /usr/local/bin/ -cp .libs/*.a /usr/local/lib diff --git a/phonelibs/json/src/json.c b/phonelibs/json/src/json.c deleted file mode 100644 index 2f0452aebe5682..00000000000000 --- a/phonelibs/json/src/json.c +++ /dev/null @@ -1,1381 +0,0 @@ -/* - Copyright (C) 2011 Joseph A. Adams (joeyadams3.14159@gmail.com) - All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -#include "json.h" - -#include -#include -#include -#include -#include - -#define out_of_memory() do { \ - fprintf(stderr, "Out of memory.\n"); \ - exit(EXIT_FAILURE); \ - } while (0) - -/* Sadly, strdup is not portable. */ -static char *json_strdup(const char *str) -{ - char *ret = (char*) malloc(strlen(str) + 1); - if (ret == NULL) - out_of_memory(); - strcpy(ret, str); - return ret; -} - -/* String buffer */ - -typedef struct -{ - char *cur; - char *end; - char *start; -} SB; - -static void sb_init(SB *sb) -{ - sb->start = (char*) malloc(17); - if (sb->start == NULL) - out_of_memory(); - sb->cur = sb->start; - sb->end = sb->start + 16; -} - -/* sb and need may be evaluated multiple times. */ -#define sb_need(sb, need) do { \ - if ((sb)->end - (sb)->cur < (need)) \ - sb_grow(sb, need); \ - } while (0) - -static void sb_grow(SB *sb, int need) -{ - size_t length = sb->cur - sb->start; - size_t alloc = sb->end - sb->start; - - do { - alloc *= 2; - } while (alloc < length + need); - - sb->start = (char*) realloc(sb->start, alloc + 1); - if (sb->start == NULL) - out_of_memory(); - sb->cur = sb->start + length; - sb->end = sb->start + alloc; -} - -static void sb_put(SB *sb, const char *bytes, int count) -{ - sb_need(sb, count); - memcpy(sb->cur, bytes, count); - sb->cur += count; -} - -#define sb_putc(sb, c) do { \ - if ((sb)->cur >= (sb)->end) \ - sb_grow(sb, 1); \ - *(sb)->cur++ = (c); \ - } while (0) - -static void sb_puts(SB *sb, const char *str) -{ - sb_put(sb, str, strlen(str)); -} - -static char *sb_finish(SB *sb) -{ - *sb->cur = 0; - assert(sb->start <= sb->cur && strlen(sb->start) == (size_t)(sb->cur - sb->start)); - return sb->start; -} - -static void sb_free(SB *sb) -{ - free(sb->start); -} - -/* - * Unicode helper functions - * - * These are taken from the ccan/charset module and customized a bit. - * Putting them here means the compiler can (choose to) inline them, - * and it keeps ccan/json from having a dependency. - */ - -/* - * Type for Unicode codepoints. - * We need our own because wchar_t might be 16 bits. - */ -typedef uint32_t uchar_t; - -/* - * Validate a single UTF-8 character starting at @s. - * The string must be null-terminated. - * - * If it's valid, return its length (1 thru 4). - * If it's invalid or clipped, return 0. - * - * This function implements the syntax given in RFC3629, which is - * the same as that given in The Unicode Standard, Version 6.0. - * - * It has the following properties: - * - * * All codepoints U+0000..U+10FFFF may be encoded, - * except for U+D800..U+DFFF, which are reserved - * for UTF-16 surrogate pair encoding. - * * UTF-8 byte sequences longer than 4 bytes are not permitted, - * as they exceed the range of Unicode. - * * The sixty-six Unicode "non-characters" are permitted - * (namely, U+FDD0..U+FDEF, U+xxFFFE, and U+xxFFFF). - */ -static int utf8_validate_cz(const char *s) -{ - unsigned char c = *s++; - - if (c <= 0x7F) { /* 00..7F */ - return 1; - } else if (c <= 0xC1) { /* 80..C1 */ - /* Disallow overlong 2-byte sequence. */ - return 0; - } else if (c <= 0xDF) { /* C2..DF */ - /* Make sure subsequent byte is in the range 0x80..0xBF. */ - if (((unsigned char)*s++ & 0xC0) != 0x80) - return 0; - - return 2; - } else if (c <= 0xEF) { /* E0..EF */ - /* Disallow overlong 3-byte sequence. */ - if (c == 0xE0 && (unsigned char)*s < 0xA0) - return 0; - - /* Disallow U+D800..U+DFFF. */ - if (c == 0xED && (unsigned char)*s > 0x9F) - return 0; - - /* Make sure subsequent bytes are in the range 0x80..0xBF. */ - if (((unsigned char)*s++ & 0xC0) != 0x80) - return 0; - if (((unsigned char)*s++ & 0xC0) != 0x80) - return 0; - - return 3; - } else if (c <= 0xF4) { /* F0..F4 */ - /* Disallow overlong 4-byte sequence. */ - if (c == 0xF0 && (unsigned char)*s < 0x90) - return 0; - - /* Disallow codepoints beyond U+10FFFF. */ - if (c == 0xF4 && (unsigned char)*s > 0x8F) - return 0; - - /* Make sure subsequent bytes are in the range 0x80..0xBF. */ - if (((unsigned char)*s++ & 0xC0) != 0x80) - return 0; - if (((unsigned char)*s++ & 0xC0) != 0x80) - return 0; - if (((unsigned char)*s++ & 0xC0) != 0x80) - return 0; - - return 4; - } else { /* F5..FF */ - return 0; - } -} - -/* Validate a null-terminated UTF-8 string. */ -static bool utf8_validate(const char *s) -{ - int len; - - for (; *s != 0; s += len) { - len = utf8_validate_cz(s); - if (len == 0) - return false; - } - - return true; -} - -/* - * Read a single UTF-8 character starting at @s, - * returning the length, in bytes, of the character read. - * - * This function assumes input is valid UTF-8, - * and that there are enough characters in front of @s. - */ -static int utf8_read_char(const char *s, uchar_t *out) -{ - const unsigned char *c = (const unsigned char*) s; - - assert(utf8_validate_cz(s)); - - if (c[0] <= 0x7F) { - /* 00..7F */ - *out = c[0]; - return 1; - } else if (c[0] <= 0xDF) { - /* C2..DF (unless input is invalid) */ - *out = ((uchar_t)c[0] & 0x1F) << 6 | - ((uchar_t)c[1] & 0x3F); - return 2; - } else if (c[0] <= 0xEF) { - /* E0..EF */ - *out = ((uchar_t)c[0] & 0xF) << 12 | - ((uchar_t)c[1] & 0x3F) << 6 | - ((uchar_t)c[2] & 0x3F); - return 3; - } else { - /* F0..F4 (unless input is invalid) */ - *out = ((uchar_t)c[0] & 0x7) << 18 | - ((uchar_t)c[1] & 0x3F) << 12 | - ((uchar_t)c[2] & 0x3F) << 6 | - ((uchar_t)c[3] & 0x3F); - return 4; - } -} - -/* - * Write a single UTF-8 character to @s, - * returning the length, in bytes, of the character written. - * - * @unicode must be U+0000..U+10FFFF, but not U+D800..U+DFFF. - * - * This function will write up to 4 bytes to @out. - */ -static int utf8_write_char(uchar_t unicode, char *out) -{ - unsigned char *o = (unsigned char*) out; - - assert(unicode <= 0x10FFFF && !(unicode >= 0xD800 && unicode <= 0xDFFF)); - - if (unicode <= 0x7F) { - /* U+0000..U+007F */ - *o++ = unicode; - return 1; - } else if (unicode <= 0x7FF) { - /* U+0080..U+07FF */ - *o++ = 0xC0 | unicode >> 6; - *o++ = 0x80 | (unicode & 0x3F); - return 2; - } else if (unicode <= 0xFFFF) { - /* U+0800..U+FFFF */ - *o++ = 0xE0 | unicode >> 12; - *o++ = 0x80 | (unicode >> 6 & 0x3F); - *o++ = 0x80 | (unicode & 0x3F); - return 3; - } else { - /* U+10000..U+10FFFF */ - *o++ = 0xF0 | unicode >> 18; - *o++ = 0x80 | (unicode >> 12 & 0x3F); - *o++ = 0x80 | (unicode >> 6 & 0x3F); - *o++ = 0x80 | (unicode & 0x3F); - return 4; - } -} - -/* - * Compute the Unicode codepoint of a UTF-16 surrogate pair. - * - * @uc should be 0xD800..0xDBFF, and @lc should be 0xDC00..0xDFFF. - * If they aren't, this function returns false. - */ -static bool from_surrogate_pair(uint16_t uc, uint16_t lc, uchar_t *unicode) -{ - if (uc >= 0xD800 && uc <= 0xDBFF && lc >= 0xDC00 && lc <= 0xDFFF) { - *unicode = 0x10000 + ((((uchar_t)uc & 0x3FF) << 10) | (lc & 0x3FF)); - return true; - } else { - return false; - } -} - -/* - * Construct a UTF-16 surrogate pair given a Unicode codepoint. - * - * @unicode must be U+10000..U+10FFFF. - */ -static void to_surrogate_pair(uchar_t unicode, uint16_t *uc, uint16_t *lc) -{ - uchar_t n; - - assert(unicode >= 0x10000 && unicode <= 0x10FFFF); - - n = unicode - 0x10000; - *uc = ((n >> 10) & 0x3FF) | 0xD800; - *lc = (n & 0x3FF) | 0xDC00; -} - -#define is_space(c) ((c) == '\t' || (c) == '\n' || (c) == '\r' || (c) == ' ') -#define is_digit(c) ((c) >= '0' && (c) <= '9') - -static bool parse_value (const char **sp, JsonNode **out); -static bool parse_string (const char **sp, char **out); -static bool parse_number (const char **sp, double *out); -static bool parse_array (const char **sp, JsonNode **out); -static bool parse_object (const char **sp, JsonNode **out); -static bool parse_hex16 (const char **sp, uint16_t *out); - -static bool expect_literal (const char **sp, const char *str); -static void skip_space (const char **sp); - -static void emit_value (SB *out, const JsonNode *node); -static void emit_value_indented (SB *out, const JsonNode *node, const char *space, int indent_level); -static void emit_string (SB *out, const char *str); -static void emit_number (SB *out, double num); -static void emit_array (SB *out, const JsonNode *array); -static void emit_array_indented (SB *out, const JsonNode *array, const char *space, int indent_level); -static void emit_object (SB *out, const JsonNode *object); -static void emit_object_indented (SB *out, const JsonNode *object, const char *space, int indent_level); - -static int write_hex16(char *out, uint16_t val); - -static JsonNode *mknode(JsonTag tag); -static void append_node(JsonNode *parent, JsonNode *child); -static void prepend_node(JsonNode *parent, JsonNode *child); -static void append_member(JsonNode *object, char *key, JsonNode *value); - -/* Assertion-friendly validity checks */ -static bool tag_is_valid(unsigned int tag); -static bool number_is_valid(const char *num); - -JsonNode *json_decode(const char *json) -{ - const char *s = json; - JsonNode *ret; - - skip_space(&s); - if (!parse_value(&s, &ret)) - return NULL; - - skip_space(&s); - if (*s != 0) { - json_delete(ret); - return NULL; - } - - return ret; -} - -char *json_encode(const JsonNode *node) -{ - return json_stringify(node, NULL); -} - -char *json_encode_string(const char *str) -{ - SB sb; - sb_init(&sb); - - emit_string(&sb, str); - - return sb_finish(&sb); -} - -char *json_stringify(const JsonNode *node, const char *space) -{ - SB sb; - sb_init(&sb); - - if (space != NULL) - emit_value_indented(&sb, node, space, 0); - else - emit_value(&sb, node); - - return sb_finish(&sb); -} - -void json_delete(JsonNode *node) -{ - if (node != NULL) { - json_remove_from_parent(node); - - switch (node->tag) { - case JSON_STRING: - free(node->string_); - break; - case JSON_ARRAY: - case JSON_OBJECT: - { - JsonNode *child, *next; - for (child = node->children.head; child != NULL; child = next) { - next = child->next; - json_delete(child); - } - break; - } - default:; - } - - free(node); - } -} - -bool json_validate(const char *json) -{ - const char *s = json; - - skip_space(&s); - if (!parse_value(&s, NULL)) - return false; - - skip_space(&s); - if (*s != 0) - return false; - - return true; -} - -JsonNode *json_find_element(JsonNode *array, int index) -{ - JsonNode *element; - int i = 0; - - if (array == NULL || array->tag != JSON_ARRAY) - return NULL; - - json_foreach(element, array) { - if (i == index) - return element; - i++; - } - - return NULL; -} - -JsonNode *json_find_member(JsonNode *object, const char *name) -{ - JsonNode *member; - - if (object == NULL || object->tag != JSON_OBJECT) - return NULL; - - json_foreach(member, object) - if (strcmp(member->key, name) == 0) - return member; - - return NULL; -} - -JsonNode *json_first_child(const JsonNode *node) -{ - if (node != NULL && (node->tag == JSON_ARRAY || node->tag == JSON_OBJECT)) - return node->children.head; - return NULL; -} - -static JsonNode *mknode(JsonTag tag) -{ - JsonNode *ret = (JsonNode*) calloc(1, sizeof(JsonNode)); - if (ret == NULL) - out_of_memory(); - ret->tag = tag; - return ret; -} - -JsonNode *json_mknull(void) -{ - return mknode(JSON_NULL); -} - -JsonNode *json_mkbool(bool b) -{ - JsonNode *ret = mknode(JSON_BOOL); - ret->bool_ = b; - return ret; -} - -static JsonNode *mkstring(char *s) -{ - JsonNode *ret = mknode(JSON_STRING); - ret->string_ = s; - return ret; -} - -JsonNode *json_mkstring(const char *s) -{ - return mkstring(json_strdup(s)); -} - -JsonNode *json_mknumber(double n) -{ - JsonNode *node = mknode(JSON_NUMBER); - node->number_ = n; - return node; -} - -JsonNode *json_mkarray(void) -{ - return mknode(JSON_ARRAY); -} - -JsonNode *json_mkobject(void) -{ - return mknode(JSON_OBJECT); -} - -static void append_node(JsonNode *parent, JsonNode *child) -{ - child->parent = parent; - child->prev = parent->children.tail; - child->next = NULL; - - if (parent->children.tail != NULL) - parent->children.tail->next = child; - else - parent->children.head = child; - parent->children.tail = child; -} - -static void prepend_node(JsonNode *parent, JsonNode *child) -{ - child->parent = parent; - child->prev = NULL; - child->next = parent->children.head; - - if (parent->children.head != NULL) - parent->children.head->prev = child; - else - parent->children.tail = child; - parent->children.head = child; -} - -static void append_member(JsonNode *object, char *key, JsonNode *value) -{ - value->key = key; - append_node(object, value); -} - -void json_append_element(JsonNode *array, JsonNode *element) -{ - assert(array->tag == JSON_ARRAY); - assert(element->parent == NULL); - - append_node(array, element); -} - -void json_prepend_element(JsonNode *array, JsonNode *element) -{ - assert(array->tag == JSON_ARRAY); - assert(element->parent == NULL); - - prepend_node(array, element); -} - -void json_append_member(JsonNode *object, const char *key, JsonNode *value) -{ - assert(object->tag == JSON_OBJECT); - assert(value->parent == NULL); - - append_member(object, json_strdup(key), value); -} - -void json_prepend_member(JsonNode *object, const char *key, JsonNode *value) -{ - assert(object->tag == JSON_OBJECT); - assert(value->parent == NULL); - - value->key = json_strdup(key); - prepend_node(object, value); -} - -void json_remove_from_parent(JsonNode *node) -{ - JsonNode *parent = node->parent; - - if (parent != NULL) { - if (node->prev != NULL) - node->prev->next = node->next; - else - parent->children.head = node->next; - if (node->next != NULL) - node->next->prev = node->prev; - else - parent->children.tail = node->prev; - - free(node->key); - - node->parent = NULL; - node->prev = node->next = NULL; - node->key = NULL; - } -} - -static bool parse_value(const char **sp, JsonNode **out) -{ - const char *s = *sp; - - switch (*s) { - case 'n': - if (expect_literal(&s, "null")) { - if (out) - *out = json_mknull(); - *sp = s; - return true; - } - return false; - - case 'f': - if (expect_literal(&s, "false")) { - if (out) - *out = json_mkbool(false); - *sp = s; - return true; - } - return false; - - case 't': - if (expect_literal(&s, "true")) { - if (out) - *out = json_mkbool(true); - *sp = s; - return true; - } - return false; - - case '"': { - char *str; - if (parse_string(&s, out ? &str : NULL)) { - if (out) - *out = mkstring(str); - *sp = s; - return true; - } - return false; - } - - case '[': - if (parse_array(&s, out)) { - *sp = s; - return true; - } - return false; - - case '{': - if (parse_object(&s, out)) { - *sp = s; - return true; - } - return false; - - default: { - double num; - if (parse_number(&s, out ? &num : NULL)) { - if (out) - *out = json_mknumber(num); - *sp = s; - return true; - } - return false; - } - } -} - -static bool parse_array(const char **sp, JsonNode **out) -{ - const char *s = *sp; - JsonNode *ret = out ? json_mkarray() : NULL; - JsonNode *element; - - if (*s++ != '[') - goto failure; - skip_space(&s); - - if (*s == ']') { - s++; - goto success; - } - - for (;;) { - if (!parse_value(&s, out ? &element : NULL)) - goto failure; - skip_space(&s); - - if (out) - json_append_element(ret, element); - - if (*s == ']') { - s++; - goto success; - } - - if (*s++ != ',') - goto failure; - skip_space(&s); - } - -success: - *sp = s; - if (out) - *out = ret; - return true; - -failure: - json_delete(ret); - return false; -} - -static bool parse_object(const char **sp, JsonNode **out) -{ - const char *s = *sp; - JsonNode *ret = out ? json_mkobject() : NULL; - char *key; - JsonNode *value; - - if (*s++ != '{') - goto failure; - skip_space(&s); - - if (*s == '}') { - s++; - goto success; - } - - for (;;) { - if (!parse_string(&s, out ? &key : NULL)) - goto failure; - skip_space(&s); - - if (*s++ != ':') - goto failure_free_key; - skip_space(&s); - - if (!parse_value(&s, out ? &value : NULL)) - goto failure_free_key; - skip_space(&s); - - if (out) - append_member(ret, key, value); - - if (*s == '}') { - s++; - goto success; - } - - if (*s++ != ',') - goto failure; - skip_space(&s); - } - -success: - *sp = s; - if (out) - *out = ret; - return true; - -failure_free_key: - if (out) - free(key); -failure: - json_delete(ret); - return false; -} - -bool parse_string(const char **sp, char **out) -{ - const char *s = *sp; - SB sb; - char throwaway_buffer[4]; - /* enough space for a UTF-8 character */ - char *b; - - if (*s++ != '"') - return false; - - if (out) { - sb_init(&sb); - sb_need(&sb, 4); - b = sb.cur; - } else { - b = throwaway_buffer; - } - - while (*s != '"') { - unsigned char c = *s++; - - /* Parse next character, and write it to b. */ - if (c == '\\') { - c = *s++; - switch (c) { - case '"': - case '\\': - case '/': - *b++ = c; - break; - case 'b': - *b++ = '\b'; - break; - case 'f': - *b++ = '\f'; - break; - case 'n': - *b++ = '\n'; - break; - case 'r': - *b++ = '\r'; - break; - case 't': - *b++ = '\t'; - break; - case 'u': - { - uint16_t uc, lc; - uchar_t unicode; - - if (!parse_hex16(&s, &uc)) - goto failed; - - if (uc >= 0xD800 && uc <= 0xDFFF) { - /* Handle UTF-16 surrogate pair. */ - if (*s++ != '\\' || *s++ != 'u' || !parse_hex16(&s, &lc)) - goto failed; /* Incomplete surrogate pair. */ - if (!from_surrogate_pair(uc, lc, &unicode)) - goto failed; /* Invalid surrogate pair. */ - } else if (uc == 0) { - /* Disallow "\u0000". */ - goto failed; - } else { - unicode = uc; - } - - b += utf8_write_char(unicode, b); - break; - } - default: - /* Invalid escape */ - goto failed; - } - } else if (c <= 0x1F) { - /* Control characters are not allowed in string literals. */ - goto failed; - } else { - /* Validate and echo a UTF-8 character. */ - int len; - - s--; - len = utf8_validate_cz(s); - if (len == 0) - goto failed; /* Invalid UTF-8 character. */ - - while (len--) - *b++ = *s++; - } - - /* - * Update sb to know about the new bytes, - * and set up b to write another character. - */ - if (out) { - sb.cur = b; - sb_need(&sb, 4); - b = sb.cur; - } else { - b = throwaway_buffer; - } - } - s++; - - if (out) - *out = sb_finish(&sb); - *sp = s; - return true; - -failed: - if (out) - sb_free(&sb); - return false; -} - -/* - * The JSON spec says that a number shall follow this precise pattern - * (spaces and quotes added for readability): - * '-'? (0 | [1-9][0-9]*) ('.' [0-9]+)? ([Ee] [+-]? [0-9]+)? - * - * However, some JSON parsers are more liberal. For instance, PHP accepts - * '.5' and '1.'. JSON.parse accepts '+3'. - * - * This function takes the strict approach. - */ -bool parse_number(const char **sp, double *out) -{ - const char *s = *sp; - - /* '-'? */ - if (*s == '-') - s++; - - /* (0 | [1-9][0-9]*) */ - if (*s == '0') { - s++; - } else { - if (!is_digit(*s)) - return false; - do { - s++; - } while (is_digit(*s)); - } - - /* ('.' [0-9]+)? */ - if (*s == '.') { - s++; - if (!is_digit(*s)) - return false; - do { - s++; - } while (is_digit(*s)); - } - - /* ([Ee] [+-]? [0-9]+)? */ - if (*s == 'E' || *s == 'e') { - s++; - if (*s == '+' || *s == '-') - s++; - if (!is_digit(*s)) - return false; - do { - s++; - } while (is_digit(*s)); - } - - if (out) - *out = strtod(*sp, NULL); - - *sp = s; - return true; -} - -static void skip_space(const char **sp) -{ - const char *s = *sp; - while (is_space(*s)) - s++; - *sp = s; -} - -static void emit_value(SB *out, const JsonNode *node) -{ - assert(tag_is_valid(node->tag)); - switch (node->tag) { - case JSON_NULL: - sb_puts(out, "null"); - break; - case JSON_BOOL: - sb_puts(out, node->bool_ ? "true" : "false"); - break; - case JSON_STRING: - emit_string(out, node->string_); - break; - case JSON_NUMBER: - emit_number(out, node->number_); - break; - case JSON_ARRAY: - emit_array(out, node); - break; - case JSON_OBJECT: - emit_object(out, node); - break; - default: - assert(false); - } -} - -void emit_value_indented(SB *out, const JsonNode *node, const char *space, int indent_level) -{ - assert(tag_is_valid(node->tag)); - switch (node->tag) { - case JSON_NULL: - sb_puts(out, "null"); - break; - case JSON_BOOL: - sb_puts(out, node->bool_ ? "true" : "false"); - break; - case JSON_STRING: - emit_string(out, node->string_); - break; - case JSON_NUMBER: - emit_number(out, node->number_); - break; - case JSON_ARRAY: - emit_array_indented(out, node, space, indent_level); - break; - case JSON_OBJECT: - emit_object_indented(out, node, space, indent_level); - break; - default: - assert(false); - } -} - -static void emit_array(SB *out, const JsonNode *array) -{ - const JsonNode *element; - - sb_putc(out, '['); - json_foreach(element, array) { - emit_value(out, element); - if (element->next != NULL) - sb_putc(out, ','); - } - sb_putc(out, ']'); -} - -static void emit_array_indented(SB *out, const JsonNode *array, const char *space, int indent_level) -{ - const JsonNode *element = array->children.head; - int i; - - if (element == NULL) { - sb_puts(out, "[]"); - return; - } - - sb_puts(out, "[\n"); - while (element != NULL) { - for (i = 0; i < indent_level + 1; i++) - sb_puts(out, space); - emit_value_indented(out, element, space, indent_level + 1); - - element = element->next; - sb_puts(out, element != NULL ? ",\n" : "\n"); - } - for (i = 0; i < indent_level; i++) - sb_puts(out, space); - sb_putc(out, ']'); -} - -static void emit_object(SB *out, const JsonNode *object) -{ - const JsonNode *member; - - sb_putc(out, '{'); - json_foreach(member, object) { - emit_string(out, member->key); - sb_putc(out, ':'); - emit_value(out, member); - if (member->next != NULL) - sb_putc(out, ','); - } - sb_putc(out, '}'); -} - -static void emit_object_indented(SB *out, const JsonNode *object, const char *space, int indent_level) -{ - const JsonNode *member = object->children.head; - int i; - - if (member == NULL) { - sb_puts(out, "{}"); - return; - } - - sb_puts(out, "{\n"); - while (member != NULL) { - for (i = 0; i < indent_level + 1; i++) - sb_puts(out, space); - emit_string(out, member->key); - sb_puts(out, ": "); - emit_value_indented(out, member, space, indent_level + 1); - - member = member->next; - sb_puts(out, member != NULL ? ",\n" : "\n"); - } - for (i = 0; i < indent_level; i++) - sb_puts(out, space); - sb_putc(out, '}'); -} - -void emit_string(SB *out, const char *str) -{ - bool escape_unicode = false; - const char *s = str; - char *b; - - assert(utf8_validate(str)); - - /* - * 14 bytes is enough space to write up to two - * \uXXXX escapes and two quotation marks. - */ - sb_need(out, 14); - b = out->cur; - - *b++ = '"'; - while (*s != 0) { - unsigned char c = *s++; - - /* Encode the next character, and write it to b. */ - switch (c) { - case '"': - *b++ = '\\'; - *b++ = '"'; - break; - case '\\': - *b++ = '\\'; - *b++ = '\\'; - break; - case '\b': - *b++ = '\\'; - *b++ = 'b'; - break; - case '\f': - *b++ = '\\'; - *b++ = 'f'; - break; - case '\n': - *b++ = '\\'; - *b++ = 'n'; - break; - case '\r': - *b++ = '\\'; - *b++ = 'r'; - break; - case '\t': - *b++ = '\\'; - *b++ = 't'; - break; - default: { - int len; - - s--; - len = utf8_validate_cz(s); - - if (len == 0) { - /* - * Handle invalid UTF-8 character gracefully in production - * by writing a replacement character (U+FFFD) - * and skipping a single byte. - * - * This should never happen when assertions are enabled - * due to the assertion at the beginning of this function. - */ - assert(false); - if (escape_unicode) { - strcpy(b, "\\uFFFD"); - b += 6; - } else { - *b++ = 0xEF; - *b++ = 0xBF; - *b++ = 0xBD; - } - s++; - } else if (c < 0x1F || (c >= 0x80 && escape_unicode)) { - /* Encode using \u.... */ - uint32_t unicode; - - s += utf8_read_char(s, &unicode); - - if (unicode <= 0xFFFF) { - *b++ = '\\'; - *b++ = 'u'; - b += write_hex16(b, unicode); - } else { - /* Produce a surrogate pair. */ - uint16_t uc, lc; - assert(unicode <= 0x10FFFF); - to_surrogate_pair(unicode, &uc, &lc); - *b++ = '\\'; - *b++ = 'u'; - b += write_hex16(b, uc); - *b++ = '\\'; - *b++ = 'u'; - b += write_hex16(b, lc); - } - } else { - /* Write the character directly. */ - while (len--) - *b++ = *s++; - } - - break; - } - } - - /* - * Update *out to know about the new bytes, - * and set up b to write another encoded character. - */ - out->cur = b; - sb_need(out, 14); - b = out->cur; - } - *b++ = '"'; - - out->cur = b; -} - -static void emit_number(SB *out, double num) -{ - /* - * This isn't exactly how JavaScript renders numbers, - * but it should produce valid JSON for reasonable numbers - * preserve precision well enough, and avoid some oddities - * like 0.3 -> 0.299999999999999988898 . - */ - char buf[64]; - sprintf(buf, "%.16g", num); - - if (number_is_valid(buf)) - sb_puts(out, buf); - else - sb_puts(out, "null"); -} - -static bool tag_is_valid(unsigned int tag) -{ - return (/* tag >= JSON_NULL && */ tag <= JSON_OBJECT); -} - -static bool number_is_valid(const char *num) -{ - return (parse_number(&num, NULL) && *num == '\0'); -} - -static bool expect_literal(const char **sp, const char *str) -{ - const char *s = *sp; - - while (*str != '\0') - if (*s++ != *str++) - return false; - - *sp = s; - return true; -} - -/* - * Parses exactly 4 hex characters (capital or lowercase). - * Fails if any input chars are not [0-9A-Fa-f]. - */ -static bool parse_hex16(const char **sp, uint16_t *out) -{ - const char *s = *sp; - uint16_t ret = 0; - uint16_t i; - uint16_t tmp; - char c; - - for (i = 0; i < 4; i++) { - c = *s++; - if (c >= '0' && c <= '9') - tmp = c - '0'; - else if (c >= 'A' && c <= 'F') - tmp = c - 'A' + 10; - else if (c >= 'a' && c <= 'f') - tmp = c - 'a' + 10; - else - return false; - - ret <<= 4; - ret += tmp; - } - - if (out) - *out = ret; - *sp = s; - return true; -} - -/* - * Encodes a 16-bit number into hexadecimal, - * writing exactly 4 hex chars. - */ -static int write_hex16(char *out, uint16_t val) -{ - const char *hex = "0123456789ABCDEF"; - - *out++ = hex[(val >> 12) & 0xF]; - *out++ = hex[(val >> 8) & 0xF]; - *out++ = hex[(val >> 4) & 0xF]; - *out++ = hex[ val & 0xF]; - - return 4; -} - -bool json_check(const JsonNode *node, char errmsg[256]) -{ - #define problem(...) do { \ - if (errmsg != NULL) \ - snprintf(errmsg, 256, __VA_ARGS__); \ - return false; \ - } while (0) - - if (node->key != NULL && !utf8_validate(node->key)) - problem("key contains invalid UTF-8"); - - if (!tag_is_valid(node->tag)) - problem("tag is invalid (%u)", node->tag); - - if (node->tag == JSON_BOOL) { - if (node->bool_ != false && node->bool_ != true) - problem("bool_ is neither false (%d) nor true (%d)", (int)false, (int)true); - } else if (node->tag == JSON_STRING) { - if (node->string_ == NULL) - problem("string_ is NULL"); - if (!utf8_validate(node->string_)) - problem("string_ contains invalid UTF-8"); - } else if (node->tag == JSON_ARRAY || node->tag == JSON_OBJECT) { - JsonNode *head = node->children.head; - JsonNode *tail = node->children.tail; - - if (head == NULL || tail == NULL) { - if (head != NULL) - problem("tail is NULL, but head is not"); - if (tail != NULL) - problem("head is NULL, but tail is not"); - } else { - JsonNode *child; - JsonNode *last = NULL; - - if (head->prev != NULL) - problem("First child's prev pointer is not NULL"); - - for (child = head; child != NULL; last = child, child = child->next) { - if (child == node) - problem("node is its own child"); - if (child->next == child) - problem("child->next == child (cycle)"); - if (child->next == head) - problem("child->next == head (cycle)"); - - if (child->parent != node) - problem("child does not point back to parent"); - if (child->next != NULL && child->next->prev != child) - problem("child->next does not point back to child"); - - if (node->tag == JSON_ARRAY && child->key != NULL) - problem("Array element's key is not NULL"); - if (node->tag == JSON_OBJECT && child->key == NULL) - problem("Object member's key is NULL"); - - if (!json_check(child, errmsg)) - return false; - } - - if (last != tail) - problem("tail does not match pointer found by starting at head and following next links"); - } - } - - return true; - - #undef problem -} diff --git a/phonelibs/json/src/json.h b/phonelibs/json/src/json.h deleted file mode 100644 index ed5255e682dae1..00000000000000 --- a/phonelibs/json/src/json.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - Copyright (C) 2011 Joseph A. Adams (joeyadams3.14159@gmail.com) - All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -#ifndef CCAN_JSON_H -#define CCAN_JSON_H - -#include -#include - -typedef enum { - JSON_NULL, - JSON_BOOL, - JSON_STRING, - JSON_NUMBER, - JSON_ARRAY, - JSON_OBJECT, -} JsonTag; - -typedef struct JsonNode JsonNode; - -struct JsonNode -{ - /* only if parent is an object or array (NULL otherwise) */ - JsonNode *parent; - JsonNode *prev, *next; - - /* only if parent is an object (NULL otherwise) */ - char *key; /* Must be valid UTF-8. */ - - JsonTag tag; - union { - /* JSON_BOOL */ - bool bool_; - - /* JSON_STRING */ - char *string_; /* Must be valid UTF-8. */ - - /* JSON_NUMBER */ - double number_; - - /* JSON_ARRAY */ - /* JSON_OBJECT */ - struct { - JsonNode *head, *tail; - } children; - }; -}; - -/*** Encoding, decoding, and validation ***/ - -JsonNode *json_decode (const char *json); -char *json_encode (const JsonNode *node); -char *json_encode_string (const char *str); -char *json_stringify (const JsonNode *node, const char *space); -void json_delete (JsonNode *node); - -bool json_validate (const char *json); - -/*** Lookup and traversal ***/ - -JsonNode *json_find_element (JsonNode *array, int index); -JsonNode *json_find_member (JsonNode *object, const char *key); - -JsonNode *json_first_child (const JsonNode *node); - -#define json_foreach(i, object_or_array) \ - for ((i) = json_first_child(object_or_array); \ - (i) != NULL; \ - (i) = (i)->next) - -/*** Construction and manipulation ***/ - -JsonNode *json_mknull(void); -JsonNode *json_mkbool(bool b); -JsonNode *json_mkstring(const char *s); -JsonNode *json_mknumber(double n); -JsonNode *json_mkarray(void); -JsonNode *json_mkobject(void); - -void json_append_element(JsonNode *array, JsonNode *element); -void json_prepend_element(JsonNode *array, JsonNode *element); -void json_append_member(JsonNode *object, const char *key, JsonNode *value); -void json_prepend_member(JsonNode *object, const char *key, JsonNode *value); - -void json_remove_from_parent(JsonNode *node); - -/*** Debugging ***/ - -/* - * Look for structure and encoding problems in a JsonNode or its descendents. - * - * If a problem is detected, return false, writing a description of the problem - * to errmsg (unless errmsg is NULL). - */ -bool json_check(const JsonNode *node, char errmsg[256]); - -#endif diff --git a/phonelibs/json11/json11.o b/phonelibs/json11/json11.o deleted file mode 100644 index 160a552565d48b..00000000000000 Binary files a/phonelibs/json11/json11.o and /dev/null differ diff --git a/phonelibs/libyuv/build.txt b/phonelibs/libyuv/build.txt deleted file mode 100644 index 376e981ec723c5..00000000000000 --- a/phonelibs/libyuv/build.txt +++ /dev/null @@ -1,4 +0,0 @@ -git clone https://chromium.googlesource.com/libyuv/libyuv -cd libyuv -git reset --hard 4a14cb2e81235ecd656e799aecaaf139db8ce4a2 -cmake . diff --git a/phonelibs/libyuv/mac/lib/libyuv.a b/phonelibs/libyuv/mac/lib/libyuv.a deleted file mode 100644 index 4a1609ca7a6754..00000000000000 Binary files a/phonelibs/libyuv/mac/lib/libyuv.a and /dev/null differ diff --git a/phonelibs/libyuv/tx2/libyuv.a b/phonelibs/libyuv/tx2/libyuv.a deleted file mode 100644 index bfe5b5b378a5e4..00000000000000 Binary files a/phonelibs/libyuv/tx2/libyuv.a and /dev/null differ diff --git a/phonelibs/libyuv/x64/include b/phonelibs/libyuv/x64/include deleted file mode 120000 index f5030fe8899824..00000000000000 --- a/phonelibs/libyuv/x64/include +++ /dev/null @@ -1 +0,0 @@ -../include \ No newline at end of file diff --git a/phonelibs/libyuv/x64/lib/libyuv.a b/phonelibs/libyuv/x64/lib/libyuv.a deleted file mode 100644 index c6afc56433cdce..00000000000000 Binary files a/phonelibs/libyuv/x64/lib/libyuv.a and /dev/null differ diff --git a/phonelibs/linux/include/msm_ion.h b/phonelibs/linux/include/msm_ion.h index e41b3170fd438e..d5caed5eb36e1b 100644 --- a/phonelibs/linux/include/msm_ion.h +++ b/phonelibs/linux/include/msm_ion.h @@ -166,7 +166,7 @@ struct ion_flush_data { struct ion_prefetch_regions { unsigned int vmid; - size_t __user *sizes; + size_t *sizes; unsigned int nr_sizes; }; @@ -174,7 +174,7 @@ struct ion_prefetch_data { int heap_id; unsigned long len; /* Is unsigned long bad? 32bit compiler vs 64 bit compiler*/ - struct ion_prefetch_regions __user *regions; + struct ion_prefetch_regions *regions; unsigned int nr_regions; }; diff --git a/phonelibs/nanovg/stb_truetype.h b/phonelibs/nanovg/stb_truetype.h index bfb1841f6989ce..62595a15fdf6b2 100644 --- a/phonelibs/nanovg/stb_truetype.h +++ b/phonelibs/nanovg/stb_truetype.h @@ -1,11 +1,21 @@ -// stb_truetype.h - v1.09 - public domain -// authored from 2009-2015 by Sean Barrett / RAD Game Tools +// stb_truetype.h - v1.24 - public domain +// authored from 2009-2020 by Sean Barrett / RAD Game Tools +// +// ======================================================================= +// +// NO SECURITY GUARANTEE -- DO NOT USE THIS ON UNTRUSTED FONT FILES +// +// This library does no range checking of the offsets found in the file, +// meaning an attacker can use it to read arbitrary memory. +// +// ======================================================================= // // This library processes TrueType files: // parse files // extract glyph metrics // extract glyph shapes // render glyphs to one-channel bitmaps with antialiasing (box filter) +// render glyphs to one-channel SDF bitmaps (signed-distance field/function) // // Todo: // non-MS cmaps @@ -20,36 +30,49 @@ // // Mikko Mononen: compound shape support, more cmap formats // Tor Andersson: kerning, subpixel rendering -// -// Bug/warning reports/fixes: -// "Zer" on mollyrocket (with fix) -// Cass Everitt -// stoiko (Haemimont Games) -// Brian Hook -// Walter van Niftrik -// David Gow -// David Given -// Ivan-Assen Ivanov -// Anthony Pesch -// Johan Duparc -// Hou Qiming -// Fabian "ryg" Giesen -// Martins Mozeiko -// Cap Petschulat -// Omar Cornut -// github:aloucks -// Peter LaValle -// Sergey Popov -// Giumo X. Clanjor -// Higor Euripedes -// Thomas Fields -// Derek Vinyard +// Dougall Johnson: OpenType / Type 2 font handling +// Daniel Ribeiro Maciel: basic GPOS-based kerning // // Misc other: // Ryan Gordon +// Simon Glass +// github:IntellectualKitty +// Imanol Celaya +// Daniel Ribeiro Maciel +// +// Bug/warning reports/fixes: +// "Zer" on mollyrocket Fabian "ryg" Giesen github:NiLuJe +// Cass Everitt Martins Mozeiko github:aloucks +// stoiko (Haemimont Games) Cap Petschulat github:oyvindjam +// Brian Hook Omar Cornut github:vassvik +// Walter van Niftrik Ryan Griege +// David Gow Peter LaValle +// David Given Sergey Popov +// Ivan-Assen Ivanov Giumo X. Clanjor +// Anthony Pesch Higor Euripedes +// Johan Duparc Thomas Fields +// Hou Qiming Derek Vinyard +// Rob Loach Cort Stratton +// Kenney Phillis Jr. Brian Costabile +// Ken Voskuil (kaesve) // // VERSION HISTORY // +// 1.24 (2020-02-05) fix warning +// 1.23 (2020-02-02) query SVG data for glyphs; query whole kerning table (but only kern not GPOS) +// 1.22 (2019-08-11) minimize missing-glyph duplication; fix kerning if both 'GPOS' and 'kern' are defined +// 1.21 (2019-02-25) fix warning +// 1.20 (2019-02-07) PackFontRange skips missing codepoints; GetScaleFontVMetrics() +// 1.19 (2018-02-11) GPOS kerning, STBTT_fmod +// 1.18 (2018-01-29) add missing function +// 1.17 (2017-07-23) make more arguments const; doc fix +// 1.16 (2017-07-12) SDF support +// 1.15 (2017-03-03) make more arguments const +// 1.14 (2017-01-16) num-fonts-in-TTC function +// 1.13 (2017-01-02) support OpenType fonts, certain Apple fonts +// 1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual +// 1.11 (2016-04-02) fix unused-variable warning +// 1.10 (2016-04-02) user-defined fabs(); rare memory leak; remove duplicate typedef // 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use allocation userdata properly // 1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges // 1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints; @@ -57,24 +80,16 @@ // fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?); // fixed an assert() bug in the new rasterizer // replace assert() with STBTT_assert() in new rasterizer -// 1.06 (2015-07-14) performance improvements (~35% faster on x86 and x64 on test machine) -// also more precise AA rasterizer, except if shapes overlap -// remove need for STBTT_sort -// 1.05 (2015-04-15) fix misplaced definitions for STBTT_STATIC -// 1.04 (2015-04-15) typo in example -// 1.03 (2015-04-12) STBTT_STATIC, fix memory leak in new packing, various fixes // // Full history can be found at the end of this file. // // LICENSE // -// This software is in the public domain. Where that dedication is not -// recognized, you are granted a perpetual, irrevocable license to copy, -// distribute, and modify this file as you see fit. +// See end of file for license information. // // USAGE // -// Include this file in whatever places neeed to refer to it. In ONE C/C++ +// Include this file in whatever places need to refer to it. In ONE C/C++ // file, write: // #define STB_TRUETYPE_IMPLEMENTATION // before the #include of this file. This expands out the actual @@ -90,14 +105,15 @@ // Improved 3D API (more shippable): // #include "stb_rect_pack.h" -- optional, but you really want it // stbtt_PackBegin() -// stbtt_PackSetOversample() -- for improved quality on small fonts +// stbtt_PackSetOversampling() -- for improved quality on small fonts // stbtt_PackFontRanges() -- pack and renders // stbtt_PackEnd() // stbtt_GetPackedQuad() // // "Load" a font file from a memory buffer (you have to keep the buffer loaded) // stbtt_InitFont() -// stbtt_GetFontOffsetForIndex() -- use for TTC font collections +// stbtt_GetFontOffsetForIndex() -- indexing for TTC font collections +// stbtt_GetNumberOfFonts() -- number of fonts for TTC font collections // // Render a unicode codepoint to a bitmap // stbtt_GetCodepointBitmap() -- allocates and returns a bitmap @@ -107,6 +123,7 @@ // Character advance/positioning // stbtt_GetCodepointHMetrics() // stbtt_GetFontVMetrics() +// stbtt_GetFontVMetricsOS2() // stbtt_GetCodepointKernAdvance() // // Starting with version 1.06, the rasterizer was replaced with a new, @@ -162,7 +179,7 @@ // measurement for describing font size, defined as 72 points per inch. // stb_truetype provides a point API for compatibility. However, true // "per inch" conventions don't make much sense on computer displays -// since they different monitors have different number of pixels per +// since different monitors have different number of pixels per // inch. For example, Windows traditionally uses a convention that // there are 96 pixels per inch, thus making 'inch' measurements have // nothing to do with inches, and thus effectively defining a point to @@ -172,6 +189,39 @@ // for non-commercial fonts, thus making fonts scaled in points // according to the TrueType spec incoherently sized in practice. // +// DETAILED USAGE: +// +// Scale: +// Select how high you want the font to be, in points or pixels. +// Call ScaleForPixelHeight or ScaleForMappingEmToPixels to compute +// a scale factor SF that will be used by all other functions. +// +// Baseline: +// You need to select a y-coordinate that is the baseline of where +// your text will appear. Call GetFontBoundingBox to get the baseline-relative +// bounding box for all characters. SF*-y0 will be the distance in pixels +// that the worst-case character could extend above the baseline, so if +// you want the top edge of characters to appear at the top of the +// screen where y=0, then you would set the baseline to SF*-y0. +// +// Current point: +// Set the current point where the first character will appear. The +// first character could extend left of the current point; this is font +// dependent. You can either choose a current point that is the leftmost +// point and hope, or add some padding, or check the bounding box or +// left-side-bearing of the first character to be displayed and set +// the current point based on that. +// +// Displaying a character: +// Compute the bounding box of the character. It will contain signed values +// relative to . I.e. if it returns x0,y0,x1,y1, +// then the character should be displayed in the rectangle from +// to #define STBTT_ifloor(x) ((int) floor(x)) @@ -404,6 +442,23 @@ int main(int arg, char **argv) #ifndef STBTT_sqrt #include #define STBTT_sqrt(x) sqrt(x) + #define STBTT_pow(x,y) pow(x,y) + #endif + + #ifndef STBTT_fmod + #include + #define STBTT_fmod(x,y) fmod(x,y) + #endif + + #ifndef STBTT_cos + #include + #define STBTT_cos(x) cos(x) + #define STBTT_acos(x) acos(x) + #endif + + #ifndef STBTT_fabs + #include + #define STBTT_fabs(x) fabs(x) #endif // #define your own functions "STBTT_malloc" / "STBTT_free" to avoid malloc.h @@ -424,7 +479,7 @@ int main(int arg, char **argv) #endif #ifndef STBTT_memcpy - #include + #include #define STBTT_memcpy memcpy #define STBTT_memset memset #endif @@ -450,6 +505,14 @@ int main(int arg, char **argv) extern "C" { #endif +// private structure +typedef struct +{ + unsigned char *data; + int cursor; + int size; +} stbtt__buf; + ////////////////////////////////////////////////////////////////////////////// // // TEXTURE BAKING API @@ -479,7 +542,7 @@ typedef struct float x1,y1,s1,t1; // bottom-right } stbtt_aligned_quad; -STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, // same data as above +STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, // same data as above int char_index, // character to display float *xpos, float *ypos, // pointers to current position in screen pixel space stbtt_aligned_quad *q, // output: quad to draw @@ -494,6 +557,8 @@ STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, // // // It's inefficient; you might want to c&p it and optimize it. +STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap); +// Query the font vertical metrics without having to create a font first. ////////////////////////////////////////////////////////////////////////////// @@ -519,7 +584,7 @@ typedef struct stbrp_rect stbrp_rect; STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_bytes, int padding, void *alloc_context); // Initializes a packing context stored in the passed-in stbtt_pack_context. // Future calls using this context will pack characters into the bitmap passed -// in here: a 1-channel bitmap that is weight x height. stride_in_bytes is +// in here: a 1-channel bitmap that is width * height. stride_in_bytes is // the distance from one row to the next (or 0 to mean they are packed tightly // together). "padding" is the amount of padding to leave between each // character (normally you want '1' for bitmaps you'll use as textures with @@ -532,7 +597,7 @@ STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc); #define STBTT_POINT_SIZE(x) (-(x)) -STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, float font_size, +STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size, int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range); // Creates character bitmaps from the font_index'th font found in fontdata (use // font_index=0 if you don't know what that is). It creates num_chars_in_range @@ -557,7 +622,7 @@ typedef struct unsigned char h_oversample, v_oversample; // don't set these, they're used internally } stbtt_pack_range; -STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges); +STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges); // Creates character bitmaps from multiple ranges of characters stored in // ranges. This will usually create a better-packed bitmap than multiple // calls to stbtt_PackFontRange. Note that you can call this multiple @@ -579,19 +644,25 @@ STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h // To use with PackFontRangesGather etc., you must set it before calls // call to PackFontRangesGatherRects. -STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, // same data as above +STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip); +// If skip != 0, this tells stb_truetype to skip any codepoints for which +// there is no corresponding glyph. If skip=0, which is the default, then +// codepoints without a glyph recived the font's "missing character" glyph, +// typically an empty box by convention. + +STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, // same data as above int char_index, // character to display float *xpos, float *ypos, // pointers to current position in screen pixel space stbtt_aligned_quad *q, // output: quad to draw int align_to_integer); -STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); +STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects); -STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); +STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); // Calling these functions in sequence is roughly equivalent to calling // stbtt_PackFontRanges(). If you more control over the packing of multiple // fonts, or if you want to pack custom data into a font texture, take a look -// at the source to of stbtt_PackFontRanges() and create a custom version +// at the source to of stbtt_PackFontRanges() and create a custom version // using these functions, e.g. call GatherRects multiple times, // building up a single array of rects, then call PackRects once, // then call RenderIntoRects repeatedly. This may result in a @@ -607,6 +678,7 @@ struct stbtt_pack_context { int height; int stride_in_bytes; int padding; + int skip_missing; unsigned int h_oversample, v_oversample; unsigned char *pixels; void *nodes; @@ -618,18 +690,23 @@ struct stbtt_pack_context { // // +STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data); +// This function will determine the number of fonts in a font file. TrueType +// collection (.ttc) files may contain multiple fonts, while TrueType font +// (.ttf) files only contain one font. The number of fonts can be used for +// indexing with the previous function where the index is between zero and one +// less than the total fonts. If an error occurs, -1 is returned. + STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index); // Each .ttf/.ttc file may have more than one font. Each font has a sequential // index number starting from 0. Call this function to get the font offset for // a given index; it returns -1 if the index is out of range. A regular .ttf // file will only define one font and it always be at offset 0, so it will -// return '0' for index 0, and -1 for all other indices. You can just skip -// this step if you know it's that kind of font. +// return '0' for index 0, and -1 for all other indices. - -// The following structure is defined publically so you can declare one on +// The following structure is defined publicly so you can declare one on // the stack or as a global or etc, but you should treat it as opaque. -typedef struct stbtt_fontinfo +struct stbtt_fontinfo { void * userdata; unsigned char * data; // pointer to .ttf file @@ -637,10 +714,17 @@ typedef struct stbtt_fontinfo int numGlyphs; // number of glyphs, needed for range checking - int loca,head,glyf,hhea,hmtx,kern; // table locations as offset from start of .ttf + int loca,head,glyf,hhea,hmtx,kern,gpos,svg; // table locations as offset from start of .ttf int index_map; // a cmap mapping for our chosen character encoding int indexToLocFormat; // format needed to map from glyph index to glyph -} stbtt_fontinfo; + + stbtt__buf cff; // cff font data + stbtt__buf charstrings; // the charstring index + stbtt__buf gsubrs; // global charstring subroutines index + stbtt__buf subrs; // private charstring subroutines index + stbtt__buf fontdicts; // array of font dicts + stbtt__buf fdselect; // map from glyph to fontdict +}; STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset); // Given an offset into the file that defines a font, this function builds @@ -659,6 +743,7 @@ STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codep // and you want a speed-up, call this function with the character you're // going to process, then use glyph-based functions instead of the // codepoint-based functions. +// Returns 0 if the character codepoint is not defined in the font. ////////////////////////////////////////////////////////////////////////////// @@ -687,6 +772,12 @@ STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, in // these are expressed in unscaled coordinates, so you must multiply by // the scale factor for a given size +STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap); +// analogous to GetFontVMetrics, but returns the "typographic" values from the OS/2 +// table (specific to MS/Windows TTF files). +// +// Returns 1 on success (table present), 0 on failure. + STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1); // the bounding box around all possible characters @@ -706,6 +797,18 @@ STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); // as above, but takes one or more glyph indices for greater efficiency +typedef struct stbtt_kerningentry +{ + int glyph1; // use stbtt_FindGlyphIndex + int glyph2; + int advance; +} stbtt_kerningentry; + +STBTT_DEF int stbtt_GetKerningTableLength(const stbtt_fontinfo *info); +STBTT_DEF int stbtt_GetKerningTable(const stbtt_fontinfo *info, stbtt_kerningentry* table, int table_length); +// Retrieves a complete list of all of the kerning pairs provided by the font +// stbtt_GetKerningTable never writes more than table_length entries and returns how many entries it did write. +// The table will be sorted by (a.glyph1 == b.glyph1)?(a.glyph2 < b.glyph2):(a.glyph1 < b.glyph1) ////////////////////////////////////////////////////////////////////////////// // @@ -717,7 +820,8 @@ STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, in enum { STBTT_vmove=1, STBTT_vline, - STBTT_vcurve + STBTT_vcurve, + STBTT_vcubic }; #endif @@ -726,7 +830,7 @@ STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, in #define stbtt_vertex_type short // can't use stbtt_int16 because that's not visible in the header file typedef struct { - stbtt_vertex_type x,y,cx,cy; + stbtt_vertex_type x,y,cx,cy,cx1,cy1; unsigned char type,padding; } stbtt_vertex; #endif @@ -739,7 +843,7 @@ STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, s // returns # of vertices and fills *vertices with the pointer to them // these are expressed in "unscaled" coordinates // -// The shape is a series of countours. Each one starts with +// The shape is a series of contours. Each one starts with // a STBTT_moveto, then consists of a series of mixed // STBTT_lineto and STBTT_curveto segments. A lineto // draws a line from previous endpoint to its x,y; a curveto @@ -749,6 +853,11 @@ STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, s STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices); // frees the data allocated above +STBTT_DEF int stbtt_GetCodepointSVG(const stbtt_fontinfo *info, int unicode_codepoint, const char **svg); +STBTT_DEF int stbtt_GetGlyphSVG(const stbtt_fontinfo *info, int gl, const char **svg); +// fills svg with the character's SVG data. +// returns data size or 0 if SVG not found. + ////////////////////////////////////////////////////////////////////////////// // // BITMAP RENDERING @@ -780,6 +889,10 @@ STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, uns // same as stbtt_MakeCodepointBitmap, but you can specify a subpixel // shift for the character +STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint); +// same as stbtt_MakeCodepointBitmapSubpixel, but prefiltering +// is performed (see stbtt_PackSetOversampling) + STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); // get the bbox of the bitmap centered around the glyph origin; so the // bitmap width is ix1-ix0, height is iy1-iy0, and location to place @@ -797,6 +910,7 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff); STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph); STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph); +STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int glyph); STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); @@ -819,6 +933,64 @@ STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, // 1-channel bitmap int invert, // if non-zero, vertically flip shape void *userdata); // context for to STBTT_MALLOC +////////////////////////////////////////////////////////////////////////////// +// +// Signed Distance Function (or Field) rendering + +STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata); +// frees the SDF bitmap allocated below + +STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff); +STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff); +// These functions compute a discretized SDF field for a single character, suitable for storing +// in a single-channel texture, sampling with bilinear filtering, and testing against +// larger than some threshold to produce scalable fonts. +// info -- the font +// scale -- controls the size of the resulting SDF bitmap, same as it would be creating a regular bitmap +// glyph/codepoint -- the character to generate the SDF for +// padding -- extra "pixels" around the character which are filled with the distance to the character (not 0), +// which allows effects like bit outlines +// onedge_value -- value 0-255 to test the SDF against to reconstruct the character (i.e. the isocontour of the character) +// pixel_dist_scale -- what value the SDF should increase by when moving one SDF "pixel" away from the edge (on the 0..255 scale) +// if positive, > onedge_value is inside; if negative, < onedge_value is inside +// width,height -- output height & width of the SDF bitmap (including padding) +// xoff,yoff -- output origin of the character +// return value -- a 2D array of bytes 0..255, width*height in size +// +// pixel_dist_scale & onedge_value are a scale & bias that allows you to make +// optimal use of the limited 0..255 for your application, trading off precision +// and special effects. SDF values outside the range 0..255 are clamped to 0..255. +// +// Example: +// scale = stbtt_ScaleForPixelHeight(22) +// padding = 5 +// onedge_value = 180 +// pixel_dist_scale = 180/5.0 = 36.0 +// +// This will create an SDF bitmap in which the character is about 22 pixels +// high but the whole bitmap is about 22+5+5=32 pixels high. To produce a filled +// shape, sample the SDF at each pixel and fill the pixel if the SDF value +// is greater than or equal to 180/255. (You'll actually want to antialias, +// which is beyond the scope of this example.) Additionally, you can compute +// offset outlines (e.g. to stroke the character border inside & outside, +// or only outside). For example, to fill outside the character up to 3 SDF +// pixels, you would compare against (180-36.0*3)/255 = 72/255. The above +// choice of variables maps a range from 5 pixels outside the shape to +// 2 pixels inside the shape to 0..255; this is intended primarily for apply +// outside effects only (the interior range is needed to allow proper +// antialiasing of the font at *smaller* sizes) +// +// The function computes the SDF analytically at each SDF pixel, not by e.g. +// building a higher-res bitmap and approximating it. In theory the quality +// should be as high as possible for an SDF of this size & representation, but +// unclear if this is true in practice (perhaps building a higher-res bitmap +// and computing from that can allow drop-out prevention). +// +// The algorithm has not been optimized at all, so expect it to be slow +// if computing lots of characters or very large sizes. + + + ////////////////////////////////////////////////////////////////////////////// // // Finding the right font... @@ -942,6 +1114,158 @@ typedef int stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERS #define STBTT_RASTERIZER_VERSION 2 #endif +#ifdef _MSC_VER +#define STBTT__NOTUSED(v) (void)(v) +#else +#define STBTT__NOTUSED(v) (void)sizeof(v) +#endif + +////////////////////////////////////////////////////////////////////////// +// +// stbtt__buf helpers to parse data from file +// + +static stbtt_uint8 stbtt__buf_get8(stbtt__buf *b) +{ + if (b->cursor >= b->size) + return 0; + return b->data[b->cursor++]; +} + +static stbtt_uint8 stbtt__buf_peek8(stbtt__buf *b) +{ + if (b->cursor >= b->size) + return 0; + return b->data[b->cursor]; +} + +static void stbtt__buf_seek(stbtt__buf *b, int o) +{ + STBTT_assert(!(o > b->size || o < 0)); + b->cursor = (o > b->size || o < 0) ? b->size : o; +} + +static void stbtt__buf_skip(stbtt__buf *b, int o) +{ + stbtt__buf_seek(b, b->cursor + o); +} + +static stbtt_uint32 stbtt__buf_get(stbtt__buf *b, int n) +{ + stbtt_uint32 v = 0; + int i; + STBTT_assert(n >= 1 && n <= 4); + for (i = 0; i < n; i++) + v = (v << 8) | stbtt__buf_get8(b); + return v; +} + +static stbtt__buf stbtt__new_buf(const void *p, size_t size) +{ + stbtt__buf r; + STBTT_assert(size < 0x40000000); + r.data = (stbtt_uint8*) p; + r.size = (int) size; + r.cursor = 0; + return r; +} + +#define stbtt__buf_get16(b) stbtt__buf_get((b), 2) +#define stbtt__buf_get32(b) stbtt__buf_get((b), 4) + +static stbtt__buf stbtt__buf_range(const stbtt__buf *b, int o, int s) +{ + stbtt__buf r = stbtt__new_buf(NULL, 0); + if (o < 0 || s < 0 || o > b->size || s > b->size - o) return r; + r.data = b->data + o; + r.size = s; + return r; +} + +static stbtt__buf stbtt__cff_get_index(stbtt__buf *b) +{ + int count, start, offsize; + start = b->cursor; + count = stbtt__buf_get16(b); + if (count) { + offsize = stbtt__buf_get8(b); + STBTT_assert(offsize >= 1 && offsize <= 4); + stbtt__buf_skip(b, offsize * count); + stbtt__buf_skip(b, stbtt__buf_get(b, offsize) - 1); + } + return stbtt__buf_range(b, start, b->cursor - start); +} + +static stbtt_uint32 stbtt__cff_int(stbtt__buf *b) +{ + int b0 = stbtt__buf_get8(b); + if (b0 >= 32 && b0 <= 246) return b0 - 139; + else if (b0 >= 247 && b0 <= 250) return (b0 - 247)*256 + stbtt__buf_get8(b) + 108; + else if (b0 >= 251 && b0 <= 254) return -(b0 - 251)*256 - stbtt__buf_get8(b) - 108; + else if (b0 == 28) return stbtt__buf_get16(b); + else if (b0 == 29) return stbtt__buf_get32(b); + STBTT_assert(0); + return 0; +} + +static void stbtt__cff_skip_operand(stbtt__buf *b) { + int v, b0 = stbtt__buf_peek8(b); + STBTT_assert(b0 >= 28); + if (b0 == 30) { + stbtt__buf_skip(b, 1); + while (b->cursor < b->size) { + v = stbtt__buf_get8(b); + if ((v & 0xF) == 0xF || (v >> 4) == 0xF) + break; + } + } else { + stbtt__cff_int(b); + } +} + +static stbtt__buf stbtt__dict_get(stbtt__buf *b, int key) +{ + stbtt__buf_seek(b, 0); + while (b->cursor < b->size) { + int start = b->cursor, end, op; + while (stbtt__buf_peek8(b) >= 28) + stbtt__cff_skip_operand(b); + end = b->cursor; + op = stbtt__buf_get8(b); + if (op == 12) op = stbtt__buf_get8(b) | 0x100; + if (op == key) return stbtt__buf_range(b, start, end-start); + } + return stbtt__buf_range(b, 0, 0); +} + +static void stbtt__dict_get_ints(stbtt__buf *b, int key, int outcount, stbtt_uint32 *out) +{ + int i; + stbtt__buf operands = stbtt__dict_get(b, key); + for (i = 0; i < outcount && operands.cursor < operands.size; i++) + out[i] = stbtt__cff_int(&operands); +} + +static int stbtt__cff_index_count(stbtt__buf *b) +{ + stbtt__buf_seek(b, 0); + return stbtt__buf_get16(b); +} + +static stbtt__buf stbtt__cff_index_get(stbtt__buf b, int i) +{ + int count, offsize, start, end; + stbtt__buf_seek(&b, 0); + count = stbtt__buf_get16(&b); + offsize = stbtt__buf_get8(&b); + STBTT_assert(i >= 0 && i < count); + STBTT_assert(offsize >= 1 && offsize <= 4); + stbtt__buf_skip(&b, i*offsize); + start = stbtt__buf_get(&b, offsize); + end = stbtt__buf_get(&b, offsize); + return stbtt__buf_range(&b, 2+(count+1)*offsize+start, end - start); +} + ////////////////////////////////////////////////////////////////////////// // // accessors to parse data from file @@ -954,32 +1278,22 @@ typedef int stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERS #define ttCHAR(p) (* (stbtt_int8 *) (p)) #define ttFixed(p) ttLONG(p) -#if defined(STB_TRUETYPE_BIGENDIAN) && !defined(ALLOW_UNALIGNED_TRUETYPE) - - #define ttUSHORT(p) (* (stbtt_uint16 *) (p)) - #define ttSHORT(p) (* (stbtt_int16 *) (p)) - #define ttULONG(p) (* (stbtt_uint32 *) (p)) - #define ttLONG(p) (* (stbtt_int32 *) (p)) - -#else - - static stbtt_uint16 ttUSHORT(const stbtt_uint8 *p) { return p[0]*256 + p[1]; } - static stbtt_int16 ttSHORT(const stbtt_uint8 *p) { return p[0]*256 + p[1]; } - static stbtt_uint32 ttULONG(const stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } - static stbtt_int32 ttLONG(const stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } - -#endif +static stbtt_uint16 ttUSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; } +static stbtt_int16 ttSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; } +static stbtt_uint32 ttULONG(stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } +static stbtt_int32 ttLONG(stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } #define stbtt_tag4(p,c0,c1,c2,c3) ((p)[0] == (c0) && (p)[1] == (c1) && (p)[2] == (c2) && (p)[3] == (c3)) #define stbtt_tag(p,str) stbtt_tag4(p,str[0],str[1],str[2],str[3]) -static int stbtt__isfont(const stbtt_uint8 *font) +static int stbtt__isfont(stbtt_uint8 *font) { // check the version number if (stbtt_tag4(font, '1',0,0,0)) return 1; // TrueType 1 if (stbtt_tag(font, "typ1")) return 1; // TrueType with type 1 font -- we don't support this! if (stbtt_tag(font, "OTTO")) return 1; // OpenType with CFF if (stbtt_tag4(font, 0,1,0,0)) return 1; // OpenType 1.0 + if (stbtt_tag(font, "true")) return 1; // Apple specification for TrueType fonts return 0; } @@ -997,7 +1311,7 @@ static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart, return 0; } -STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *font_collection, int index) +static int stbtt_GetFontOffsetForIndex_internal(unsigned char *font_collection, int index) { // if it's just a font, there's only one valid index if (stbtt__isfont(font_collection)) @@ -1016,14 +1330,59 @@ STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *font_collection, return -1; } -STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data2, int fontstart) +static int stbtt_GetNumberOfFonts_internal(unsigned char *font_collection) +{ + // if it's just a font, there's only one valid font + if (stbtt__isfont(font_collection)) + return 1; + + // check if it's a TTC + if (stbtt_tag(font_collection, "ttcf")) { + // version 1? + if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { + return ttLONG(font_collection+8); + } + } + return 0; +} + +static stbtt__buf stbtt__get_subrs(stbtt__buf cff, stbtt__buf fontdict) +{ + stbtt_uint32 subrsoff = 0, private_loc[2] = { 0, 0 }; + stbtt__buf pdict; + stbtt__dict_get_ints(&fontdict, 18, 2, private_loc); + if (!private_loc[1] || !private_loc[0]) return stbtt__new_buf(NULL, 0); + pdict = stbtt__buf_range(&cff, private_loc[1], private_loc[0]); + stbtt__dict_get_ints(&pdict, 19, 1, &subrsoff); + if (!subrsoff) return stbtt__new_buf(NULL, 0); + stbtt__buf_seek(&cff, private_loc[1]+subrsoff); + return stbtt__cff_get_index(&cff); +} + +// since most people won't use this, find this table the first time it's needed +static int stbtt__get_svg(stbtt_fontinfo *info) +{ + stbtt_uint32 t; + if (info->svg < 0) { + t = stbtt__find_table(info->data, info->fontstart, "SVG "); + if (t) { + stbtt_uint32 offset = ttULONG(info->data + t + 2); + info->svg = t + offset; + } else { + info->svg = 0; + } + } + return info->svg; +} + +static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, int fontstart) { - stbtt_uint8 *data = (stbtt_uint8 *) data2; stbtt_uint32 cmap, t; stbtt_int32 i,numTables; info->data = data; info->fontstart = fontstart; + info->cff = stbtt__new_buf(NULL, 0); cmap = stbtt__find_table(data, fontstart, "cmap"); // required info->loca = stbtt__find_table(data, fontstart, "loca"); // required @@ -1032,8 +1391,62 @@ STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data2, i info->hhea = stbtt__find_table(data, fontstart, "hhea"); // required info->hmtx = stbtt__find_table(data, fontstart, "hmtx"); // required info->kern = stbtt__find_table(data, fontstart, "kern"); // not required - if (!cmap || !info->loca || !info->head || !info->glyf || !info->hhea || !info->hmtx) + info->gpos = stbtt__find_table(data, fontstart, "GPOS"); // not required + + if (!cmap || !info->head || !info->hhea || !info->hmtx) return 0; + if (info->glyf) { + // required for truetype + if (!info->loca) return 0; + } else { + // initialization for CFF / Type2 fonts (OTF) + stbtt__buf b, topdict, topdictidx; + stbtt_uint32 cstype = 2, charstrings = 0, fdarrayoff = 0, fdselectoff = 0; + stbtt_uint32 cff; + + cff = stbtt__find_table(data, fontstart, "CFF "); + if (!cff) return 0; + + info->fontdicts = stbtt__new_buf(NULL, 0); + info->fdselect = stbtt__new_buf(NULL, 0); + + // @TODO this should use size from table (not 512MB) + info->cff = stbtt__new_buf(data+cff, 512*1024*1024); + b = info->cff; + + // read the header + stbtt__buf_skip(&b, 2); + stbtt__buf_seek(&b, stbtt__buf_get8(&b)); // hdrsize + + // @TODO the name INDEX could list multiple fonts, + // but we just use the first one. + stbtt__cff_get_index(&b); // name INDEX + topdictidx = stbtt__cff_get_index(&b); + topdict = stbtt__cff_index_get(topdictidx, 0); + stbtt__cff_get_index(&b); // string INDEX + info->gsubrs = stbtt__cff_get_index(&b); + + stbtt__dict_get_ints(&topdict, 17, 1, &charstrings); + stbtt__dict_get_ints(&topdict, 0x100 | 6, 1, &cstype); + stbtt__dict_get_ints(&topdict, 0x100 | 36, 1, &fdarrayoff); + stbtt__dict_get_ints(&topdict, 0x100 | 37, 1, &fdselectoff); + info->subrs = stbtt__get_subrs(b, topdict); + + // we only support Type 2 charstrings + if (cstype != 2) return 0; + if (charstrings == 0) return 0; + + if (fdarrayoff) { + // looks like a CID font + if (!fdselectoff) return 0; + stbtt__buf_seek(&b, fdarrayoff); + info->fontdicts = stbtt__cff_get_index(&b); + info->fdselect = stbtt__buf_range(&b, fdselectoff, b.size-fdselectoff); + } + + stbtt__buf_seek(&b, charstrings); + info->charstrings = stbtt__cff_get_index(&b); + } t = stbtt__find_table(data, fontstart, "maxp"); if (t) @@ -1041,6 +1454,8 @@ STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data2, i else info->numGlyphs = 0xffff; + info->svg = -1; + // find a cmap encoding table we understand *now* to avoid searching // later. (todo: could make this installable) // the same regardless of glyph. @@ -1184,6 +1599,8 @@ static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index) { int g1,g2; + STBTT_assert(!info->cff.size); + if (glyph_index >= info->numGlyphs) return -1; // glyph index out of range if (info->indexToLocFormat >= 2) return -1; // unknown index->glyph map format @@ -1198,15 +1615,21 @@ static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index) return g1==g2 ? -1 : g1; // if length is 0, return -1 } +static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); + STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) { - int g = stbtt__GetGlyfOffset(info, glyph_index); - if (g < 0) return 0; + if (info->cff.size) { + stbtt__GetGlyphInfoT2(info, glyph_index, x0, y0, x1, y1); + } else { + int g = stbtt__GetGlyfOffset(info, glyph_index); + if (g < 0) return 0; - if (x0) *x0 = ttSHORT(info->data + g + 2); - if (y0) *y0 = ttSHORT(info->data + g + 4); - if (x1) *x1 = ttSHORT(info->data + g + 6); - if (y1) *y1 = ttSHORT(info->data + g + 8); + if (x0) *x0 = ttSHORT(info->data + g + 2); + if (y0) *y0 = ttSHORT(info->data + g + 4); + if (x1) *x1 = ttSHORT(info->data + g + 6); + if (y1) *y1 = ttSHORT(info->data + g + 8); + } return 1; } @@ -1218,7 +1641,10 @@ STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, i STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index) { stbtt_int16 numberOfContours; - int g = stbtt__GetGlyfOffset(info, glyph_index); + int g; + if (info->cff.size) + return stbtt__GetGlyphInfoT2(info, glyph_index, NULL, NULL, NULL, NULL) == 0; + g = stbtt__GetGlyfOffset(info, glyph_index); if (g < 0) return 1; numberOfContours = ttSHORT(info->data + g); return numberOfContours == 0; @@ -1240,7 +1666,7 @@ static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, int was_ return num_vertices; } -STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) +static int stbtt__GetGlyphShapeTT(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) { stbtt_int16 numberOfContours; stbtt_uint8 *endPtsOfContours; @@ -1336,7 +1762,7 @@ STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, s if (i != 0) num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); - // now start the new one + // now start the new one start_off = !(flags & 1); if (start_off) { // if we start off with an off-curve point, then when we need to find a point on the curve @@ -1378,7 +1804,7 @@ STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, s } } num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); - } else if (numberOfContours == -1) { + } else if (numberOfContours < 0) { // Compound shapes. int more = 1; stbtt_uint8 *comp = data + g + 10; @@ -1389,7 +1815,7 @@ STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, s int comp_num_verts = 0, i; stbtt_vertex *comp_verts = 0, *tmp = 0; float mtx[6] = {1,0,0,1,0,0}, m, n; - + flags = ttSHORT(comp); comp+=2; gidx = ttSHORT(comp); comp+=2; @@ -1419,7 +1845,7 @@ STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, s mtx[2] = ttSHORT(comp)/16384.0f; comp+=2; mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; } - + // Find transformation scales. m = (float) STBTT_sqrt(mtx[0]*mtx[0] + mtx[1]*mtx[1]); n = (float) STBTT_sqrt(mtx[2]*mtx[2] + mtx[3]*mtx[3]); @@ -1455,9 +1881,6 @@ STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, s // More components ? more = flags & (1<<5); } - } else if (numberOfContours < 0) { - // @TODO other compound variations? - STBTT_assert(0); } else { // numberOfCounters == 0, do nothing } @@ -1466,6 +1889,414 @@ STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, s return num_vertices; } +typedef struct +{ + int bounds; + int started; + float first_x, first_y; + float x, y; + stbtt_int32 min_x, max_x, min_y, max_y; + + stbtt_vertex *pvertices; + int num_vertices; +} stbtt__csctx; + +#define STBTT__CSCTX_INIT(bounds) {bounds,0, 0,0, 0,0, 0,0,0,0, NULL, 0} + +static void stbtt__track_vertex(stbtt__csctx *c, stbtt_int32 x, stbtt_int32 y) +{ + if (x > c->max_x || !c->started) c->max_x = x; + if (y > c->max_y || !c->started) c->max_y = y; + if (x < c->min_x || !c->started) c->min_x = x; + if (y < c->min_y || !c->started) c->min_y = y; + c->started = 1; +} + +static void stbtt__csctx_v(stbtt__csctx *c, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy, stbtt_int32 cx1, stbtt_int32 cy1) +{ + if (c->bounds) { + stbtt__track_vertex(c, x, y); + if (type == STBTT_vcubic) { + stbtt__track_vertex(c, cx, cy); + stbtt__track_vertex(c, cx1, cy1); + } + } else { + stbtt_setvertex(&c->pvertices[c->num_vertices], type, x, y, cx, cy); + c->pvertices[c->num_vertices].cx1 = (stbtt_int16) cx1; + c->pvertices[c->num_vertices].cy1 = (stbtt_int16) cy1; + } + c->num_vertices++; +} + +static void stbtt__csctx_close_shape(stbtt__csctx *ctx) +{ + if (ctx->first_x != ctx->x || ctx->first_y != ctx->y) + stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->first_x, (int)ctx->first_y, 0, 0, 0, 0); +} + +static void stbtt__csctx_rmove_to(stbtt__csctx *ctx, float dx, float dy) +{ + stbtt__csctx_close_shape(ctx); + ctx->first_x = ctx->x = ctx->x + dx; + ctx->first_y = ctx->y = ctx->y + dy; + stbtt__csctx_v(ctx, STBTT_vmove, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0); +} + +static void stbtt__csctx_rline_to(stbtt__csctx *ctx, float dx, float dy) +{ + ctx->x += dx; + ctx->y += dy; + stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0); +} + +static void stbtt__csctx_rccurve_to(stbtt__csctx *ctx, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3) +{ + float cx1 = ctx->x + dx1; + float cy1 = ctx->y + dy1; + float cx2 = cx1 + dx2; + float cy2 = cy1 + dy2; + ctx->x = cx2 + dx3; + ctx->y = cy2 + dy3; + stbtt__csctx_v(ctx, STBTT_vcubic, (int)ctx->x, (int)ctx->y, (int)cx1, (int)cy1, (int)cx2, (int)cy2); +} + +static stbtt__buf stbtt__get_subr(stbtt__buf idx, int n) +{ + int count = stbtt__cff_index_count(&idx); + int bias = 107; + if (count >= 33900) + bias = 32768; + else if (count >= 1240) + bias = 1131; + n += bias; + if (n < 0 || n >= count) + return stbtt__new_buf(NULL, 0); + return stbtt__cff_index_get(idx, n); +} + +static stbtt__buf stbtt__cid_get_glyph_subrs(const stbtt_fontinfo *info, int glyph_index) +{ + stbtt__buf fdselect = info->fdselect; + int nranges, start, end, v, fmt, fdselector = -1, i; + + stbtt__buf_seek(&fdselect, 0); + fmt = stbtt__buf_get8(&fdselect); + if (fmt == 0) { + // untested + stbtt__buf_skip(&fdselect, glyph_index); + fdselector = stbtt__buf_get8(&fdselect); + } else if (fmt == 3) { + nranges = stbtt__buf_get16(&fdselect); + start = stbtt__buf_get16(&fdselect); + for (i = 0; i < nranges; i++) { + v = stbtt__buf_get8(&fdselect); + end = stbtt__buf_get16(&fdselect); + if (glyph_index >= start && glyph_index < end) { + fdselector = v; + break; + } + start = end; + } + } + if (fdselector == -1) stbtt__new_buf(NULL, 0); + return stbtt__get_subrs(info->cff, stbtt__cff_index_get(info->fontdicts, fdselector)); +} + +static int stbtt__run_charstring(const stbtt_fontinfo *info, int glyph_index, stbtt__csctx *c) +{ + int in_header = 1, maskbits = 0, subr_stack_height = 0, sp = 0, v, i, b0; + int has_subrs = 0, clear_stack; + float s[48]; + stbtt__buf subr_stack[10], subrs = info->subrs, b; + float f; + +#define STBTT__CSERR(s) (0) + + // this currently ignores the initial width value, which isn't needed if we have hmtx + b = stbtt__cff_index_get(info->charstrings, glyph_index); + while (b.cursor < b.size) { + i = 0; + clear_stack = 1; + b0 = stbtt__buf_get8(&b); + switch (b0) { + // @TODO implement hinting + case 0x13: // hintmask + case 0x14: // cntrmask + if (in_header) + maskbits += (sp / 2); // implicit "vstem" + in_header = 0; + stbtt__buf_skip(&b, (maskbits + 7) / 8); + break; + + case 0x01: // hstem + case 0x03: // vstem + case 0x12: // hstemhm + case 0x17: // vstemhm + maskbits += (sp / 2); + break; + + case 0x15: // rmoveto + in_header = 0; + if (sp < 2) return STBTT__CSERR("rmoveto stack"); + stbtt__csctx_rmove_to(c, s[sp-2], s[sp-1]); + break; + case 0x04: // vmoveto + in_header = 0; + if (sp < 1) return STBTT__CSERR("vmoveto stack"); + stbtt__csctx_rmove_to(c, 0, s[sp-1]); + break; + case 0x16: // hmoveto + in_header = 0; + if (sp < 1) return STBTT__CSERR("hmoveto stack"); + stbtt__csctx_rmove_to(c, s[sp-1], 0); + break; + + case 0x05: // rlineto + if (sp < 2) return STBTT__CSERR("rlineto stack"); + for (; i + 1 < sp; i += 2) + stbtt__csctx_rline_to(c, s[i], s[i+1]); + break; + + // hlineto/vlineto and vhcurveto/hvcurveto alternate horizontal and vertical + // starting from a different place. + + case 0x07: // vlineto + if (sp < 1) return STBTT__CSERR("vlineto stack"); + goto vlineto; + case 0x06: // hlineto + if (sp < 1) return STBTT__CSERR("hlineto stack"); + for (;;) { + if (i >= sp) break; + stbtt__csctx_rline_to(c, s[i], 0); + i++; + vlineto: + if (i >= sp) break; + stbtt__csctx_rline_to(c, 0, s[i]); + i++; + } + break; + + case 0x1F: // hvcurveto + if (sp < 4) return STBTT__CSERR("hvcurveto stack"); + goto hvcurveto; + case 0x1E: // vhcurveto + if (sp < 4) return STBTT__CSERR("vhcurveto stack"); + for (;;) { + if (i + 3 >= sp) break; + stbtt__csctx_rccurve_to(c, 0, s[i], s[i+1], s[i+2], s[i+3], (sp - i == 5) ? s[i + 4] : 0.0f); + i += 4; + hvcurveto: + if (i + 3 >= sp) break; + stbtt__csctx_rccurve_to(c, s[i], 0, s[i+1], s[i+2], (sp - i == 5) ? s[i+4] : 0.0f, s[i+3]); + i += 4; + } + break; + + case 0x08: // rrcurveto + if (sp < 6) return STBTT__CSERR("rcurveline stack"); + for (; i + 5 < sp; i += 6) + stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); + break; + + case 0x18: // rcurveline + if (sp < 8) return STBTT__CSERR("rcurveline stack"); + for (; i + 5 < sp - 2; i += 6) + stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); + if (i + 1 >= sp) return STBTT__CSERR("rcurveline stack"); + stbtt__csctx_rline_to(c, s[i], s[i+1]); + break; + + case 0x19: // rlinecurve + if (sp < 8) return STBTT__CSERR("rlinecurve stack"); + for (; i + 1 < sp - 6; i += 2) + stbtt__csctx_rline_to(c, s[i], s[i+1]); + if (i + 5 >= sp) return STBTT__CSERR("rlinecurve stack"); + stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); + break; + + case 0x1A: // vvcurveto + case 0x1B: // hhcurveto + if (sp < 4) return STBTT__CSERR("(vv|hh)curveto stack"); + f = 0.0; + if (sp & 1) { f = s[i]; i++; } + for (; i + 3 < sp; i += 4) { + if (b0 == 0x1B) + stbtt__csctx_rccurve_to(c, s[i], f, s[i+1], s[i+2], s[i+3], 0.0); + else + stbtt__csctx_rccurve_to(c, f, s[i], s[i+1], s[i+2], 0.0, s[i+3]); + f = 0.0; + } + break; + + case 0x0A: // callsubr + if (!has_subrs) { + if (info->fdselect.size) + subrs = stbtt__cid_get_glyph_subrs(info, glyph_index); + has_subrs = 1; + } + // fallthrough + case 0x1D: // callgsubr + if (sp < 1) return STBTT__CSERR("call(g|)subr stack"); + v = (int) s[--sp]; + if (subr_stack_height >= 10) return STBTT__CSERR("recursion limit"); + subr_stack[subr_stack_height++] = b; + b = stbtt__get_subr(b0 == 0x0A ? subrs : info->gsubrs, v); + if (b.size == 0) return STBTT__CSERR("subr not found"); + b.cursor = 0; + clear_stack = 0; + break; + + case 0x0B: // return + if (subr_stack_height <= 0) return STBTT__CSERR("return outside subr"); + b = subr_stack[--subr_stack_height]; + clear_stack = 0; + break; + + case 0x0E: // endchar + stbtt__csctx_close_shape(c); + return 1; + + case 0x0C: { // two-byte escape + float dx1, dx2, dx3, dx4, dx5, dx6, dy1, dy2, dy3, dy4, dy5, dy6; + float dx, dy; + int b1 = stbtt__buf_get8(&b); + switch (b1) { + // @TODO These "flex" implementations ignore the flex-depth and resolution, + // and always draw beziers. + case 0x22: // hflex + if (sp < 7) return STBTT__CSERR("hflex stack"); + dx1 = s[0]; + dx2 = s[1]; + dy2 = s[2]; + dx3 = s[3]; + dx4 = s[4]; + dx5 = s[5]; + dx6 = s[6]; + stbtt__csctx_rccurve_to(c, dx1, 0, dx2, dy2, dx3, 0); + stbtt__csctx_rccurve_to(c, dx4, 0, dx5, -dy2, dx6, 0); + break; + + case 0x23: // flex + if (sp < 13) return STBTT__CSERR("flex stack"); + dx1 = s[0]; + dy1 = s[1]; + dx2 = s[2]; + dy2 = s[3]; + dx3 = s[4]; + dy3 = s[5]; + dx4 = s[6]; + dy4 = s[7]; + dx5 = s[8]; + dy5 = s[9]; + dx6 = s[10]; + dy6 = s[11]; + //fd is s[12] + stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); + stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); + break; + + case 0x24: // hflex1 + if (sp < 9) return STBTT__CSERR("hflex1 stack"); + dx1 = s[0]; + dy1 = s[1]; + dx2 = s[2]; + dy2 = s[3]; + dx3 = s[4]; + dx4 = s[5]; + dx5 = s[6]; + dy5 = s[7]; + dx6 = s[8]; + stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, 0); + stbtt__csctx_rccurve_to(c, dx4, 0, dx5, dy5, dx6, -(dy1+dy2+dy5)); + break; + + case 0x25: // flex1 + if (sp < 11) return STBTT__CSERR("flex1 stack"); + dx1 = s[0]; + dy1 = s[1]; + dx2 = s[2]; + dy2 = s[3]; + dx3 = s[4]; + dy3 = s[5]; + dx4 = s[6]; + dy4 = s[7]; + dx5 = s[8]; + dy5 = s[9]; + dx6 = dy6 = s[10]; + dx = dx1+dx2+dx3+dx4+dx5; + dy = dy1+dy2+dy3+dy4+dy5; + if (STBTT_fabs(dx) > STBTT_fabs(dy)) + dy6 = -dy; + else + dx6 = -dx; + stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); + stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); + break; + + default: + return STBTT__CSERR("unimplemented"); + } + } break; + + default: + if (b0 != 255 && b0 != 28 && (b0 < 32 || b0 > 254)) + return STBTT__CSERR("reserved operator"); + + // push immediate + if (b0 == 255) { + f = (float)(stbtt_int32)stbtt__buf_get32(&b) / 0x10000; + } else { + stbtt__buf_skip(&b, -1); + f = (float)(stbtt_int16)stbtt__cff_int(&b); + } + if (sp >= 48) return STBTT__CSERR("push stack overflow"); + s[sp++] = f; + clear_stack = 0; + break; + } + if (clear_stack) sp = 0; + } + return STBTT__CSERR("no endchar"); + +#undef STBTT__CSERR +} + +static int stbtt__GetGlyphShapeT2(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) +{ + // runs the charstring twice, once to count and once to output (to avoid realloc) + stbtt__csctx count_ctx = STBTT__CSCTX_INIT(1); + stbtt__csctx output_ctx = STBTT__CSCTX_INIT(0); + if (stbtt__run_charstring(info, glyph_index, &count_ctx)) { + *pvertices = (stbtt_vertex*)STBTT_malloc(count_ctx.num_vertices*sizeof(stbtt_vertex), info->userdata); + output_ctx.pvertices = *pvertices; + if (stbtt__run_charstring(info, glyph_index, &output_ctx)) { + STBTT_assert(output_ctx.num_vertices == count_ctx.num_vertices); + return output_ctx.num_vertices; + } + } + *pvertices = NULL; + return 0; +} + +static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) +{ + stbtt__csctx c = STBTT__CSCTX_INIT(1); + int r = stbtt__run_charstring(info, glyph_index, &c); + if (x0) *x0 = r ? c.min_x : 0; + if (y0) *y0 = r ? c.min_y : 0; + if (x1) *x1 = r ? c.max_x : 0; + if (y1) *y1 = r ? c.max_y : 0; + return r ? c.num_vertices : 0; +} + +STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) +{ + if (!info->cff.size) + return stbtt__GetGlyphShapeTT(info, glyph_index, pvertices); + else + return stbtt__GetGlyphShapeT2(info, glyph_index, pvertices); +} + STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing) { stbtt_uint16 numOfLongHorMetrics = ttUSHORT(info->data+info->hhea + 34); @@ -1478,7 +2309,49 @@ STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_inde } } -STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2) +STBTT_DEF int stbtt_GetKerningTableLength(const stbtt_fontinfo *info) +{ + stbtt_uint8 *data = info->data + info->kern; + + // we only look at the first table. it must be 'horizontal' and format 0. + if (!info->kern) + return 0; + if (ttUSHORT(data+2) < 1) // number of tables, need at least 1 + return 0; + if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format + return 0; + + return ttUSHORT(data+10); +} + +STBTT_DEF int stbtt_GetKerningTable(const stbtt_fontinfo *info, stbtt_kerningentry* table, int table_length) +{ + stbtt_uint8 *data = info->data + info->kern; + int k, length; + + // we only look at the first table. it must be 'horizontal' and format 0. + if (!info->kern) + return 0; + if (ttUSHORT(data+2) < 1) // number of tables, need at least 1 + return 0; + if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format + return 0; + + length = ttUSHORT(data+10); + if (table_length < length) + length = table_length; + + for (k = 0; k < length; k++) + { + table[k].glyph1 = ttUSHORT(data+18+(k*6)); + table[k].glyph2 = ttUSHORT(data+20+(k*6)); + table[k].advance = ttSHORT(data+22+(k*6)); + } + + return length; +} + +static int stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2) { stbtt_uint8 *data = info->data + info->kern; stbtt_uint32 needle, straw; @@ -1508,9 +2381,260 @@ STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, return 0; } +static stbtt_int32 stbtt__GetCoverageIndex(stbtt_uint8 *coverageTable, int glyph) +{ + stbtt_uint16 coverageFormat = ttUSHORT(coverageTable); + switch(coverageFormat) { + case 1: { + stbtt_uint16 glyphCount = ttUSHORT(coverageTable + 2); + + // Binary search. + stbtt_int32 l=0, r=glyphCount-1, m; + int straw, needle=glyph; + while (l <= r) { + stbtt_uint8 *glyphArray = coverageTable + 4; + stbtt_uint16 glyphID; + m = (l + r) >> 1; + glyphID = ttUSHORT(glyphArray + 2 * m); + straw = glyphID; + if (needle < straw) + r = m - 1; + else if (needle > straw) + l = m + 1; + else { + return m; + } + } + } break; + + case 2: { + stbtt_uint16 rangeCount = ttUSHORT(coverageTable + 2); + stbtt_uint8 *rangeArray = coverageTable + 4; + + // Binary search. + stbtt_int32 l=0, r=rangeCount-1, m; + int strawStart, strawEnd, needle=glyph; + while (l <= r) { + stbtt_uint8 *rangeRecord; + m = (l + r) >> 1; + rangeRecord = rangeArray + 6 * m; + strawStart = ttUSHORT(rangeRecord); + strawEnd = ttUSHORT(rangeRecord + 2); + if (needle < strawStart) + r = m - 1; + else if (needle > strawEnd) + l = m + 1; + else { + stbtt_uint16 startCoverageIndex = ttUSHORT(rangeRecord + 4); + return startCoverageIndex + glyph - strawStart; + } + } + } break; + + default: { + // There are no other cases. + STBTT_assert(0); + } break; + } + + return -1; +} + +static stbtt_int32 stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, int glyph) +{ + stbtt_uint16 classDefFormat = ttUSHORT(classDefTable); + switch(classDefFormat) + { + case 1: { + stbtt_uint16 startGlyphID = ttUSHORT(classDefTable + 2); + stbtt_uint16 glyphCount = ttUSHORT(classDefTable + 4); + stbtt_uint8 *classDef1ValueArray = classDefTable + 6; + + if (glyph >= startGlyphID && glyph < startGlyphID + glyphCount) + return (stbtt_int32)ttUSHORT(classDef1ValueArray + 2 * (glyph - startGlyphID)); + + classDefTable = classDef1ValueArray + 2 * glyphCount; + } break; + + case 2: { + stbtt_uint16 classRangeCount = ttUSHORT(classDefTable + 2); + stbtt_uint8 *classRangeRecords = classDefTable + 4; + + // Binary search. + stbtt_int32 l=0, r=classRangeCount-1, m; + int strawStart, strawEnd, needle=glyph; + while (l <= r) { + stbtt_uint8 *classRangeRecord; + m = (l + r) >> 1; + classRangeRecord = classRangeRecords + 6 * m; + strawStart = ttUSHORT(classRangeRecord); + strawEnd = ttUSHORT(classRangeRecord + 2); + if (needle < strawStart) + r = m - 1; + else if (needle > strawEnd) + l = m + 1; + else + return (stbtt_int32)ttUSHORT(classRangeRecord + 4); + } + + classDefTable = classRangeRecords + 6 * classRangeCount; + } break; + + default: { + // There are no other cases. + STBTT_assert(0); + } break; + } + + return -1; +} + +// Define to STBTT_assert(x) if you want to break on unimplemented formats. +#define STBTT_GPOS_TODO_assert(x) + +static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2) +{ + stbtt_uint16 lookupListOffset; + stbtt_uint8 *lookupList; + stbtt_uint16 lookupCount; + stbtt_uint8 *data; + stbtt_int32 i; + + if (!info->gpos) return 0; + + data = info->data + info->gpos; + + if (ttUSHORT(data+0) != 1) return 0; // Major version 1 + if (ttUSHORT(data+2) != 0) return 0; // Minor version 0 + + lookupListOffset = ttUSHORT(data+8); + lookupList = data + lookupListOffset; + lookupCount = ttUSHORT(lookupList); + + for (i=0; i> 1; + pairValue = pairValueArray + (2 + valueRecordPairSizeInBytes) * m; + secondGlyph = ttUSHORT(pairValue); + straw = secondGlyph; + if (needle < straw) + r = m - 1; + else if (needle > straw) + l = m + 1; + else { + stbtt_int16 xAdvance = ttSHORT(pairValue + 2); + return xAdvance; + } + } + } break; + + case 2: { + stbtt_uint16 valueFormat1 = ttUSHORT(table + 4); + stbtt_uint16 valueFormat2 = ttUSHORT(table + 6); + + stbtt_uint16 classDef1Offset = ttUSHORT(table + 8); + stbtt_uint16 classDef2Offset = ttUSHORT(table + 10); + int glyph1class = stbtt__GetGlyphClass(table + classDef1Offset, glyph1); + int glyph2class = stbtt__GetGlyphClass(table + classDef2Offset, glyph2); + + stbtt_uint16 class1Count = ttUSHORT(table + 12); + stbtt_uint16 class2Count = ttUSHORT(table + 14); + STBTT_assert(glyph1class < class1Count); + STBTT_assert(glyph2class < class2Count); + + // TODO: Support more formats. + STBTT_GPOS_TODO_assert(valueFormat1 == 4); + if (valueFormat1 != 4) return 0; + STBTT_GPOS_TODO_assert(valueFormat2 == 0); + if (valueFormat2 != 0) return 0; + + if (glyph1class >= 0 && glyph1class < class1Count && glyph2class >= 0 && glyph2class < class2Count) { + stbtt_uint8 *class1Records = table + 16; + stbtt_uint8 *class2Records = class1Records + 2 * (glyph1class * class2Count); + stbtt_int16 xAdvance = ttSHORT(class2Records + 2 * glyph2class); + return xAdvance; + } + } break; + + default: { + // There are no other cases. + STBTT_assert(0); + break; + }; + } + } + break; + }; + + default: + // TODO: Implement other stuff. + break; + } + } + + return 0; +} + +STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int g1, int g2) +{ + int xAdvance = 0; + + if (info->gpos) + xAdvance += stbtt__GetGlyphGPOSInfoAdvance(info, g1, g2); + else if (info->kern) + xAdvance += stbtt__GetGlyphKernInfoAdvance(info, g1, g2); + + return xAdvance; +} + STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2) { - if (!info->kern) // if no kerning table, don't waste time looking up both codepoint->glyphs + if (!info->kern && !info->gpos) // if no kerning table, don't waste time looking up both codepoint->glyphs return 0; return stbtt_GetGlyphKernAdvance(info, stbtt_FindGlyphIndex(info,ch1), stbtt_FindGlyphIndex(info,ch2)); } @@ -1527,6 +2651,17 @@ STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, in if (lineGap) *lineGap = ttSHORT(info->data+info->hhea + 8); } +STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap) +{ + int tab = stbtt__find_table(info->data, info->fontstart, "OS/2"); + if (!tab) + return 0; + if (typoAscent ) *typoAscent = ttSHORT(info->data+tab + 68); + if (typoDescent) *typoDescent = ttSHORT(info->data+tab + 70); + if (typoLineGap) *typoLineGap = ttSHORT(info->data+tab + 72); + return 1; +} + STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1) { *x0 = ttSHORT(info->data + info->head + 36); @@ -1552,6 +2687,45 @@ STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v) STBTT_free(v, info->userdata); } +STBTT_DEF stbtt_uint8 *stbtt_FindSVGDoc(const stbtt_fontinfo *info, int gl) +{ + int i; + stbtt_uint8 *data = info->data; + stbtt_uint8 *svg_doc_list = data + stbtt__get_svg((stbtt_fontinfo *) info); + + int numEntries = ttUSHORT(svg_doc_list); + stbtt_uint8 *svg_docs = svg_doc_list + 2; + + for(i=0; i= ttUSHORT(svg_doc)) && (gl <= ttUSHORT(svg_doc + 2))) + return svg_doc; + } + return 0; +} + +STBTT_DEF int stbtt_GetGlyphSVG(const stbtt_fontinfo *info, int gl, const char **svg) +{ + stbtt_uint8 *data = info->data; + stbtt_uint8 *svg_doc; + + if (info->svg == 0) + return 0; + + svg_doc = stbtt_FindSVGDoc(info, gl); + if (svg_doc != NULL) { + *svg = (char *) data + info->svg + ttULONG(svg_doc + 4); + return ttULONG(svg_doc + 8); + } else { + return 0; + } +} + +STBTT_DEF int stbtt_GetCodepointSVG(const stbtt_fontinfo *info, int unicode_codepoint, const char **svg) +{ + return stbtt_GetGlyphSVG(info, stbtt_FindGlyphIndex(info, unicode_codepoint), svg); +} + ////////////////////////////////////////////////////////////////////////////// // // antialiasing software rasterizer @@ -1623,7 +2797,7 @@ static void *stbtt__hheap_alloc(stbtt__hheap *hh, size_t size, void *userdata) hh->num_remaining_in_head_chunk = count; } --hh->num_remaining_in_head_chunk; - return (char *) (hh->head) + size * hh->num_remaining_in_head_chunk; + return (char *) (hh->head) + sizeof(stbtt__hheap_chunk) + size * hh->num_remaining_in_head_chunk; } } @@ -1677,7 +2851,7 @@ static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, i float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); STBTT_assert(z != NULL); if (!z) return z; - + // round dx down to avoid overshooting if (dxdy < 0) z->dx = -STBTT_ifloor(STBTT_FIX * -dxdy); @@ -1755,7 +2929,7 @@ static void stbtt__fill_active_edges(unsigned char *scanline, int len, stbtt__ac } } } - + e = e->next; } } @@ -1993,7 +3167,7 @@ static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, } y_crossing += dy * (x2 - (x1+1)); - STBTT_assert(fabs(area) <= 1.01f); + STBTT_assert(STBTT_fabs(area) <= 1.01f); scanline[x2] += area + sign * (1-((x2-x2)+(x_bottom-x2))/2) * (sy1-y_crossing); @@ -2019,19 +3193,18 @@ static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, // from the other y segment, and it might ignored as an empty segment. to avoid // that, we need to explicitly produce segments based on x positions. - // rename variables to clear pairs + // rename variables to clearly-defined pairs float y0 = y_top; float x1 = (float) (x); float x2 = (float) (x+1); float x3 = xb; float y3 = y_bottom; - float y1,y2; // x = e->x + e->dx * (y-y_top) // (y-y_top) = (x - e->x) / e->dx // y = (x - e->x) / e->dx + y_top - y1 = (x - x0) / dx + y_top; - y2 = (x+1 - x0) / dx + y_top; + float y1 = (x - x0) / dx + y_top; + float y2 = (x+1 - x0) / dx + y_top; if (x0 < x1 && x3 > x2) { // three segments descending down-right stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); @@ -2071,6 +3244,8 @@ static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int y,j=0, i; float scanline_data[129], *scanline, *scanline2; + STBTT__NOTUSED(vsubsample); + if (result->w > 64) scanline = (float *) STBTT_malloc((result->w*2+1) * sizeof(float), userdata); else @@ -2109,7 +3284,13 @@ static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, if (e->y0 != e->y1) { stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y_top, userdata); if (z != NULL) { - STBTT_assert(z->ey >= scan_y_top); + if (j == 0 && off_y != 0) { + if (z->ey < scan_y_top) { + // this can happen due to subpixel positioning and some kind of fp rounding error i think + z->ey = scan_y_top; + } + } + STBTT_assert(z->ey >= scan_y_top); // if we get really unlucky a tiny bit of an edge can be out of bounds // insert at front z->next = active; active = z; @@ -2129,7 +3310,7 @@ static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int m; sum += scanline2[i]; k = scanline[i] + sum; - k = (float) fabs(k)*255 + 0.5f; + k = (float) STBTT_fabs(k)*255 + 0.5f; m = (int) k; if (m > 255) m = 255; result->pixels[j*result->stride + i] = (unsigned char) m; @@ -2178,7 +3359,7 @@ static void stbtt__sort_edges_ins_sort(stbtt__edge *p, int n) static void stbtt__sort_edges_quicksort(stbtt__edge *p, int n) { - /* threshhold for transitioning to insertion sort */ + /* threshold for transitioning to insertion sort */ while (n > 12) { stbtt__edge t; int c01,c12,c,m,i,j; @@ -2313,7 +3494,7 @@ static void stbtt__add_point(stbtt__point *points, int n, float x, float y) points[n].y = y; } -// tesselate until threshhold p is happy... @TODO warped to compensate for non-linear stretching +// tessellate until threshold p is happy... @TODO warped to compensate for non-linear stretching static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float objspace_flatness_squared, int n) { // midpoint @@ -2334,6 +3515,48 @@ static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x return 1; } +static void stbtt__tesselate_cubic(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float objspace_flatness_squared, int n) +{ + // @TODO this "flatness" calculation is just made-up nonsense that seems to work well enough + float dx0 = x1-x0; + float dy0 = y1-y0; + float dx1 = x2-x1; + float dy1 = y2-y1; + float dx2 = x3-x2; + float dy2 = y3-y2; + float dx = x3-x0; + float dy = y3-y0; + float longlen = (float) (STBTT_sqrt(dx0*dx0+dy0*dy0)+STBTT_sqrt(dx1*dx1+dy1*dy1)+STBTT_sqrt(dx2*dx2+dy2*dy2)); + float shortlen = (float) STBTT_sqrt(dx*dx+dy*dy); + float flatness_squared = longlen*longlen-shortlen*shortlen; + + if (n > 16) // 65536 segments on one curve better be enough! + return; + + if (flatness_squared > objspace_flatness_squared) { + float x01 = (x0+x1)/2; + float y01 = (y0+y1)/2; + float x12 = (x1+x2)/2; + float y12 = (y1+y2)/2; + float x23 = (x2+x3)/2; + float y23 = (y2+y3)/2; + + float xa = (x01+x12)/2; + float ya = (y01+y12)/2; + float xb = (x12+x23)/2; + float yb = (y12+y23)/2; + + float mx = (xa+xb)/2; + float my = (ya+yb)/2; + + stbtt__tesselate_cubic(points, num_points, x0,y0, x01,y01, xa,ya, mx,my, objspace_flatness_squared,n+1); + stbtt__tesselate_cubic(points, num_points, mx,my, xb,yb, x23,y23, x3,y3, objspace_flatness_squared,n+1); + } else { + stbtt__add_point(points, *num_points,x3,y3); + *num_points = *num_points+1; + } +} + // returns number of contours static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata) { @@ -2390,6 +3613,14 @@ static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, objspace_flatness_squared, 0); x = vertices[i].x, y = vertices[i].y; break; + case STBTT_vcubic: + stbtt__tesselate_cubic(points, &num_points, x,y, + vertices[i].cx, vertices[i].cy, + vertices[i].cx1, vertices[i].cy1, + vertices[i].x, vertices[i].y, + objspace_flatness_squared, 0); + x = vertices[i].x, y = vertices[i].y; + break; } } (*contour_lengths)[n] = num_points - start; @@ -2406,8 +3637,9 @@ static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata) { - float scale = scale_x > scale_y ? scale_y : scale_x; - int winding_count, *winding_lengths; + float scale = scale_x > scale_y ? scale_y : scale_x; + int winding_count = 0; + int *winding_lengths = NULL; stbtt__point *windings = stbtt_FlattenCurves(vertices, num_verts, flatness_in_pixels / scale, &winding_lengths, &winding_count, userdata); if (windings) { stbtt__rasterize(result, windings, winding_lengths, winding_count, scale_x, scale_y, shift_x, shift_y, x_off, y_off, invert, userdata); @@ -2425,12 +3657,15 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info { int ix0,iy0,ix1,iy1; stbtt__bitmap gbm; - stbtt_vertex *vertices; + stbtt_vertex *vertices; int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); if (scale_x == 0) scale_x = scale_y; if (scale_y == 0) { - if (scale_x == 0) return NULL; + if (scale_x == 0) { + STBTT_free(vertices, info->userdata); + return NULL; + } scale_y = scale_x; } @@ -2445,7 +3680,7 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info if (height) *height = gbm.h; if (xoff ) *xoff = ix0; if (yoff ) *yoff = iy0; - + if (gbm.w && gbm.h) { gbm.pixels = (unsigned char *) STBTT_malloc(gbm.w * gbm.h, info->userdata); if (gbm.pixels) { @@ -2456,7 +3691,7 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info } STBTT_free(vertices, info->userdata); return gbm.pixels; -} +} STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff) { @@ -2468,7 +3703,7 @@ STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigne int ix0,iy0; stbtt_vertex *vertices; int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); - stbtt__bitmap gbm; + stbtt__bitmap gbm; stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,0,0); gbm.pixels = output; @@ -2490,7 +3725,12 @@ STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char * STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff); -} +} + +STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint) +{ + stbtt_MakeGlyphBitmapSubpixelPrefilter(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, oversample_x, oversample_y, sub_x, sub_y, stbtt_FindGlyphIndex(info,codepoint)); +} STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint) { @@ -2500,7 +3740,7 @@ STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, uns STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff); -} +} STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint) { @@ -2513,7 +3753,7 @@ STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned ch // // This is SUPER-CRAPPY packing to keep source code small -STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) +static int stbtt_BakeFontBitmap_internal(unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) float pixel_height, // height of font in pixels unsigned char *pixels, int pw, int ph, // bitmap to be filled in int first_char, int num_chars, // characters to bake @@ -2559,11 +3799,11 @@ STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // fo return bottom_y; } -STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule) +STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule) { float d3d_bias = opengl_fillrule ? 0 : -0.5f; float ipw = 1.0f / pw, iph = 1.0f / ph; - stbtt_bakedchar *b = chardata + char_index; + const stbtt_bakedchar *b = chardata + char_index; int round_x = STBTT_ifloor((*xpos + b->xoff) + 0.5f); int round_y = STBTT_ifloor((*ypos + b->yoff) + 0.5f); @@ -2586,11 +3826,6 @@ STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, int // #ifndef STB_RECT_PACK_VERSION -#ifdef _MSC_VER -#define STBTT__NOTUSED(v) (void)(v) -#else -#define STBTT__NOTUSED(v) (void)sizeof(v) -#endif typedef int stbrp_coord; @@ -2630,7 +3865,7 @@ static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *no con->y = 0; con->bottom_y = 0; STBTT__NOTUSED(nodes); - STBTT__NOTUSED(num_nodes); + STBTT__NOTUSED(num_nodes); } static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rects) @@ -2684,6 +3919,7 @@ STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, in spc->stride_in_bytes = stride_in_bytes != 0 ? stride_in_bytes : pw; spc->h_oversample = 1; spc->v_oversample = 1; + spc->skip_missing = 0; stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes); @@ -2709,6 +3945,11 @@ STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h spc->v_oversample = v_oversample; } +STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip) +{ + spc->skip_missing = skip; +} + #define STBTT__OVER_MASK (STBTT_MAX_OVERSAMPLE-1) static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width) @@ -2848,9 +4089,10 @@ static float stbtt__oversample_shift(int oversample) } // rects array must be big enough to accommodate all characters in the given ranges -STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) +STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) { int i,j,k; + int missing_glyph_added = 0; k=0; for (i=0; i < num_ranges; ++i) { @@ -2862,13 +4104,19 @@ STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fon int x0,y0,x1,y1; int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j]; int glyph = stbtt_FindGlyphIndex(info, codepoint); - stbtt_GetGlyphBitmapBoxSubpixel(info,glyph, - scale * spc->h_oversample, - scale * spc->v_oversample, - 0,0, - &x0,&y0,&x1,&y1); - rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1); - rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1); + if (glyph == 0 && (spc->skip_missing || missing_glyph_added)) { + rects[k].w = rects[k].h = 0; + } else { + stbtt_GetGlyphBitmapBoxSubpixel(info,glyph, + scale * spc->h_oversample, + scale * spc->v_oversample, + 0,0, + &x0,&y0,&x1,&y1); + rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1); + rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1); + if (glyph == 0) + missing_glyph_added = 1; + } ++k; } } @@ -2876,10 +4124,33 @@ STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fon return k; } +STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int prefilter_x, int prefilter_y, float *sub_x, float *sub_y, int glyph) +{ + stbtt_MakeGlyphBitmapSubpixel(info, + output, + out_w - (prefilter_x - 1), + out_h - (prefilter_y - 1), + out_stride, + scale_x, + scale_y, + shift_x, + shift_y, + glyph); + + if (prefilter_x > 1) + stbtt__h_prefilter(output, out_w, out_h, out_stride, prefilter_x); + + if (prefilter_y > 1) + stbtt__v_prefilter(output, out_w, out_h, out_stride, prefilter_y); + + *sub_x = stbtt__oversample_shift(prefilter_x); + *sub_y = stbtt__oversample_shift(prefilter_y); +} + // rects array must be big enough to accommodate all characters in the given ranges -STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) +STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) { - int i,j,k, return_value = 1; + int i,j,k, missing_glyph = -1, return_value = 1; // save current values int old_h_over = spc->h_oversample; @@ -2898,7 +4169,7 @@ STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, stbtt sub_y = stbtt__oversample_shift(spc->v_oversample); for (j=0; j < ranges[i].num_chars; ++j) { stbrp_rect *r = &rects[k]; - if (r->was_packed) { + if (r->was_packed && r->w != 0 && r->h != 0) { stbtt_packedchar *bc = &ranges[i].chardata_for_range[j]; int advance, lsb, x0,y0,x1,y1; int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j]; @@ -2944,6 +4215,13 @@ STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, stbtt bc->yoff = (float) y0 * recip_v + sub_y; bc->xoff2 = (x0 + r->w) * recip_h + sub_x; bc->yoff2 = (y0 + r->h) * recip_v + sub_y; + + if (glyph == 0) + missing_glyph = j; + } else if (spc->skip_missing) { + return_value = 0; + } else if (r->was_packed && r->w == 0 && r->h == 0 && missing_glyph >= 0) { + ranges[i].chardata_for_range[j] = ranges[i].chardata_for_range[missing_glyph]; } else { return_value = 0; // if any fail, report failure } @@ -2964,7 +4242,7 @@ STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect stbrp_pack_rects((stbrp_context *) spc->pack_info, rects, num_rects); } -STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges) +STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges) { stbtt_fontinfo info; int i,j,n, return_value = 1; @@ -2982,7 +4260,7 @@ STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontd n = 0; for (i=0; i < num_ranges; ++i) n += ranges[i].num_chars; - + rects = (stbrp_rect *) STBTT_malloc(sizeof(*rects) * n, spc->user_allocator_context); if (rects == NULL) return 0; @@ -2993,14 +4271,14 @@ STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontd n = stbtt_PackFontRangesGatherRects(spc, &info, ranges, num_ranges, rects); stbtt_PackFontRangesPackRects(spc, rects, n); - + return_value = stbtt_PackFontRangesRenderIntoRects(spc, &info, ranges, num_ranges, rects); STBTT_free(rects, spc->user_allocator_context); return return_value; } -STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, float font_size, +STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size, int first_unicode_codepoint_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range) { stbtt_pack_range range; @@ -3012,10 +4290,23 @@ STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontda return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1); } -STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer) +STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap) +{ + int i_ascent, i_descent, i_lineGap; + float scale; + stbtt_fontinfo info; + stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata, index)); + scale = size > 0 ? stbtt_ScaleForPixelHeight(&info, size) : stbtt_ScaleForMappingEmToPixels(&info, -size); + stbtt_GetFontVMetrics(&info, &i_ascent, &i_descent, &i_lineGap); + *ascent = (float) i_ascent * scale; + *descent = (float) i_descent * scale; + *lineGap = (float) i_lineGap * scale; +} + +STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer) { float ipw = 1.0f / pw, iph = 1.0f / ph; - stbtt_packedchar *b = chardata + char_index; + const stbtt_packedchar *b = chardata + char_index; if (align_to_integer) { float x = (float) STBTT_ifloor((*xpos + b->xoff) + 0.5f); @@ -3039,6 +4330,382 @@ STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, i *xpos += b->xadvance; } +////////////////////////////////////////////////////////////////////////////// +// +// sdf computation +// + +#define STBTT_min(a,b) ((a) < (b) ? (a) : (b)) +#define STBTT_max(a,b) ((a) < (b) ? (b) : (a)) + +static int stbtt__ray_intersect_bezier(float orig[2], float ray[2], float q0[2], float q1[2], float q2[2], float hits[2][2]) +{ + float q0perp = q0[1]*ray[0] - q0[0]*ray[1]; + float q1perp = q1[1]*ray[0] - q1[0]*ray[1]; + float q2perp = q2[1]*ray[0] - q2[0]*ray[1]; + float roperp = orig[1]*ray[0] - orig[0]*ray[1]; + + float a = q0perp - 2*q1perp + q2perp; + float b = q1perp - q0perp; + float c = q0perp - roperp; + + float s0 = 0., s1 = 0.; + int num_s = 0; + + if (a != 0.0) { + float discr = b*b - a*c; + if (discr > 0.0) { + float rcpna = -1 / a; + float d = (float) STBTT_sqrt(discr); + s0 = (b+d) * rcpna; + s1 = (b-d) * rcpna; + if (s0 >= 0.0 && s0 <= 1.0) + num_s = 1; + if (d > 0.0 && s1 >= 0.0 && s1 <= 1.0) { + if (num_s == 0) s0 = s1; + ++num_s; + } + } + } else { + // 2*b*s + c = 0 + // s = -c / (2*b) + s0 = c / (-2 * b); + if (s0 >= 0.0 && s0 <= 1.0) + num_s = 1; + } + + if (num_s == 0) + return 0; + else { + float rcp_len2 = 1 / (ray[0]*ray[0] + ray[1]*ray[1]); + float rayn_x = ray[0] * rcp_len2, rayn_y = ray[1] * rcp_len2; + + float q0d = q0[0]*rayn_x + q0[1]*rayn_y; + float q1d = q1[0]*rayn_x + q1[1]*rayn_y; + float q2d = q2[0]*rayn_x + q2[1]*rayn_y; + float rod = orig[0]*rayn_x + orig[1]*rayn_y; + + float q10d = q1d - q0d; + float q20d = q2d - q0d; + float q0rd = q0d - rod; + + hits[0][0] = q0rd + s0*(2.0f - 2.0f*s0)*q10d + s0*s0*q20d; + hits[0][1] = a*s0+b; + + if (num_s > 1) { + hits[1][0] = q0rd + s1*(2.0f - 2.0f*s1)*q10d + s1*s1*q20d; + hits[1][1] = a*s1+b; + return 2; + } else { + return 1; + } + } +} + +static int equal(float *a, float *b) +{ + return (a[0] == b[0] && a[1] == b[1]); +} + +static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex *verts) +{ + int i; + float orig[2], ray[2] = { 1, 0 }; + float y_frac; + int winding = 0; + + orig[0] = x; + orig[1] = y; + + // make sure y never passes through a vertex of the shape + y_frac = (float) STBTT_fmod(y, 1.0f); + if (y_frac < 0.01f) + y += 0.01f; + else if (y_frac > 0.99f) + y -= 0.01f; + orig[1] = y; + + // test a ray from (-infinity,y) to (x,y) + for (i=0; i < nverts; ++i) { + if (verts[i].type == STBTT_vline) { + int x0 = (int) verts[i-1].x, y0 = (int) verts[i-1].y; + int x1 = (int) verts[i ].x, y1 = (int) verts[i ].y; + if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) { + float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0; + if (x_inter < x) + winding += (y0 < y1) ? 1 : -1; + } + } + if (verts[i].type == STBTT_vcurve) { + int x0 = (int) verts[i-1].x , y0 = (int) verts[i-1].y ; + int x1 = (int) verts[i ].cx, y1 = (int) verts[i ].cy; + int x2 = (int) verts[i ].x , y2 = (int) verts[i ].y ; + int ax = STBTT_min(x0,STBTT_min(x1,x2)), ay = STBTT_min(y0,STBTT_min(y1,y2)); + int by = STBTT_max(y0,STBTT_max(y1,y2)); + if (y > ay && y < by && x > ax) { + float q0[2],q1[2],q2[2]; + float hits[2][2]; + q0[0] = (float)x0; + q0[1] = (float)y0; + q1[0] = (float)x1; + q1[1] = (float)y1; + q2[0] = (float)x2; + q2[1] = (float)y2; + if (equal(q0,q1) || equal(q1,q2)) { + x0 = (int)verts[i-1].x; + y0 = (int)verts[i-1].y; + x1 = (int)verts[i ].x; + y1 = (int)verts[i ].y; + if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) { + float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0; + if (x_inter < x) + winding += (y0 < y1) ? 1 : -1; + } + } else { + int num_hits = stbtt__ray_intersect_bezier(orig, ray, q0, q1, q2, hits); + if (num_hits >= 1) + if (hits[0][0] < 0) + winding += (hits[0][1] < 0 ? -1 : 1); + if (num_hits >= 2) + if (hits[1][0] < 0) + winding += (hits[1][1] < 0 ? -1 : 1); + } + } + } + } + return winding; +} + +static float stbtt__cuberoot( float x ) +{ + if (x<0) + return -(float) STBTT_pow(-x,1.0f/3.0f); + else + return (float) STBTT_pow( x,1.0f/3.0f); +} + +// x^3 + c*x^2 + b*x + a = 0 +static int stbtt__solve_cubic(float a, float b, float c, float* r) +{ + float s = -a / 3; + float p = b - a*a / 3; + float q = a * (2*a*a - 9*b) / 27 + c; + float p3 = p*p*p; + float d = q*q + 4*p3 / 27; + if (d >= 0) { + float z = (float) STBTT_sqrt(d); + float u = (-q + z) / 2; + float v = (-q - z) / 2; + u = stbtt__cuberoot(u); + v = stbtt__cuberoot(v); + r[0] = s + u + v; + return 1; + } else { + float u = (float) STBTT_sqrt(-p/3); + float v = (float) STBTT_acos(-STBTT_sqrt(-27/p3) * q / 2) / 3; // p3 must be negative, since d is negative + float m = (float) STBTT_cos(v); + float n = (float) STBTT_cos(v-3.141592/2)*1.732050808f; + r[0] = s + u * 2 * m; + r[1] = s - u * (m + n); + r[2] = s - u * (m - n); + + //STBTT_assert( STBTT_fabs(((r[0]+a)*r[0]+b)*r[0]+c) < 0.05f); // these asserts may not be safe at all scales, though they're in bezier t parameter units so maybe? + //STBTT_assert( STBTT_fabs(((r[1]+a)*r[1]+b)*r[1]+c) < 0.05f); + //STBTT_assert( STBTT_fabs(((r[2]+a)*r[2]+b)*r[2]+c) < 0.05f); + return 3; + } +} + +STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff) +{ + float scale_x = scale, scale_y = scale; + int ix0,iy0,ix1,iy1; + int w,h; + unsigned char *data; + + if (scale == 0) return NULL; + + stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale, scale, 0.0f,0.0f, &ix0,&iy0,&ix1,&iy1); + + // if empty, return NULL + if (ix0 == ix1 || iy0 == iy1) + return NULL; + + ix0 -= padding; + iy0 -= padding; + ix1 += padding; + iy1 += padding; + + w = (ix1 - ix0); + h = (iy1 - iy0); + + if (width ) *width = w; + if (height) *height = h; + if (xoff ) *xoff = ix0; + if (yoff ) *yoff = iy0; + + // invert for y-downwards bitmaps + scale_y = -scale_y; + + { + int x,y,i,j; + float *precompute; + stbtt_vertex *verts; + int num_verts = stbtt_GetGlyphShape(info, glyph, &verts); + data = (unsigned char *) STBTT_malloc(w * h, info->userdata); + precompute = (float *) STBTT_malloc(num_verts * sizeof(float), info->userdata); + + for (i=0,j=num_verts-1; i < num_verts; j=i++) { + if (verts[i].type == STBTT_vline) { + float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y; + float x1 = verts[j].x*scale_x, y1 = verts[j].y*scale_y; + float dist = (float) STBTT_sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0)); + precompute[i] = (dist == 0) ? 0.0f : 1.0f / dist; + } else if (verts[i].type == STBTT_vcurve) { + float x2 = verts[j].x *scale_x, y2 = verts[j].y *scale_y; + float x1 = verts[i].cx*scale_x, y1 = verts[i].cy*scale_y; + float x0 = verts[i].x *scale_x, y0 = verts[i].y *scale_y; + float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; + float len2 = bx*bx + by*by; + if (len2 != 0.0f) + precompute[i] = 1.0f / (bx*bx + by*by); + else + precompute[i] = 0.0f; + } else + precompute[i] = 0.0f; + } + + for (y=iy0; y < iy1; ++y) { + for (x=ix0; x < ix1; ++x) { + float val; + float min_dist = 999999.0f; + float sx = (float) x + 0.5f; + float sy = (float) y + 0.5f; + float x_gspace = (sx / scale_x); + float y_gspace = (sy / scale_y); + + int winding = stbtt__compute_crossings_x(x_gspace, y_gspace, num_verts, verts); // @OPTIMIZE: this could just be a rasterization, but needs to be line vs. non-tesselated curves so a new path + + for (i=0; i < num_verts; ++i) { + float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y; + + // check against every point here rather than inside line/curve primitives -- @TODO: wrong if multiple 'moves' in a row produce a garbage point, and given culling, probably more efficient to do within line/curve + float dist2 = (x0-sx)*(x0-sx) + (y0-sy)*(y0-sy); + if (dist2 < min_dist*min_dist) + min_dist = (float) STBTT_sqrt(dist2); + + if (verts[i].type == STBTT_vline) { + float x1 = verts[i-1].x*scale_x, y1 = verts[i-1].y*scale_y; + + // coarse culling against bbox + //if (sx > STBTT_min(x0,x1)-min_dist && sx < STBTT_max(x0,x1)+min_dist && + // sy > STBTT_min(y0,y1)-min_dist && sy < STBTT_max(y0,y1)+min_dist) + float dist = (float) STBTT_fabs((x1-x0)*(y0-sy) - (y1-y0)*(x0-sx)) * precompute[i]; + STBTT_assert(i != 0); + if (dist < min_dist) { + // check position along line + // x' = x0 + t*(x1-x0), y' = y0 + t*(y1-y0) + // minimize (x'-sx)*(x'-sx)+(y'-sy)*(y'-sy) + float dx = x1-x0, dy = y1-y0; + float px = x0-sx, py = y0-sy; + // minimize (px+t*dx)^2 + (py+t*dy)^2 = px*px + 2*px*dx*t + t^2*dx*dx + py*py + 2*py*dy*t + t^2*dy*dy + // derivative: 2*px*dx + 2*py*dy + (2*dx*dx+2*dy*dy)*t, set to 0 and solve + float t = -(px*dx + py*dy) / (dx*dx + dy*dy); + if (t >= 0.0f && t <= 1.0f) + min_dist = dist; + } + } else if (verts[i].type == STBTT_vcurve) { + float x2 = verts[i-1].x *scale_x, y2 = verts[i-1].y *scale_y; + float x1 = verts[i ].cx*scale_x, y1 = verts[i ].cy*scale_y; + float box_x0 = STBTT_min(STBTT_min(x0,x1),x2); + float box_y0 = STBTT_min(STBTT_min(y0,y1),y2); + float box_x1 = STBTT_max(STBTT_max(x0,x1),x2); + float box_y1 = STBTT_max(STBTT_max(y0,y1),y2); + // coarse culling against bbox to avoid computing cubic unnecessarily + if (sx > box_x0-min_dist && sx < box_x1+min_dist && sy > box_y0-min_dist && sy < box_y1+min_dist) { + int num=0; + float ax = x1-x0, ay = y1-y0; + float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; + float mx = x0 - sx, my = y0 - sy; + float res[3],px,py,t,it; + float a_inv = precompute[i]; + if (a_inv == 0.0) { // if a_inv is 0, it's 2nd degree so use quadratic formula + float a = 3*(ax*bx + ay*by); + float b = 2*(ax*ax + ay*ay) + (mx*bx+my*by); + float c = mx*ax+my*ay; + if (a == 0.0) { // if a is 0, it's linear + if (b != 0.0) { + res[num++] = -c/b; + } + } else { + float discriminant = b*b - 4*a*c; + if (discriminant < 0) + num = 0; + else { + float root = (float) STBTT_sqrt(discriminant); + res[0] = (-b - root)/(2*a); + res[1] = (-b + root)/(2*a); + num = 2; // don't bother distinguishing 1-solution case, as code below will still work + } + } + } else { + float b = 3*(ax*bx + ay*by) * a_inv; // could precompute this as it doesn't depend on sample point + float c = (2*(ax*ax + ay*ay) + (mx*bx+my*by)) * a_inv; + float d = (mx*ax+my*ay) * a_inv; + num = stbtt__solve_cubic(b, c, d, res); + } + if (num >= 1 && res[0] >= 0.0f && res[0] <= 1.0f) { + t = res[0], it = 1.0f - t; + px = it*it*x0 + 2*t*it*x1 + t*t*x2; + py = it*it*y0 + 2*t*it*y1 + t*t*y2; + dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); + if (dist2 < min_dist * min_dist) + min_dist = (float) STBTT_sqrt(dist2); + } + if (num >= 2 && res[1] >= 0.0f && res[1] <= 1.0f) { + t = res[1], it = 1.0f - t; + px = it*it*x0 + 2*t*it*x1 + t*t*x2; + py = it*it*y0 + 2*t*it*y1 + t*t*y2; + dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); + if (dist2 < min_dist * min_dist) + min_dist = (float) STBTT_sqrt(dist2); + } + if (num >= 3 && res[2] >= 0.0f && res[2] <= 1.0f) { + t = res[2], it = 1.0f - t; + px = it*it*x0 + 2*t*it*x1 + t*t*x2; + py = it*it*y0 + 2*t*it*y1 + t*t*y2; + dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); + if (dist2 < min_dist * min_dist) + min_dist = (float) STBTT_sqrt(dist2); + } + } + } + } + if (winding == 0) + min_dist = -min_dist; // if outside the shape, value is negative + val = onedge_value + pixel_dist_scale * min_dist; + if (val < 0) + val = 0; + else if (val > 255) + val = 255; + data[(y-iy0)*w+(x-ix0)] = (unsigned char) val; + } + } + STBTT_free(precompute, info->userdata); + STBTT_free(verts, info->userdata); + } + return data; +} + +STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff) +{ + return stbtt_GetGlyphSDF(info, scale, stbtt_FindGlyphIndex(info, codepoint), padding, onedge_value, pixel_dist_scale, width, height, xoff, yoff); +} + +STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata) +{ + STBTT_free(bitmap, userdata); +} ////////////////////////////////////////////////////////////////////////////// // @@ -3046,7 +4713,7 @@ STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, i // // check if a utf8 string contains a prefix which is the utf16 string; if so return length of matching utf8 string -static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(const stbtt_uint8 *s1, stbtt_int32 len1, const stbtt_uint8 *s2, stbtt_int32 len2) +static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, stbtt_int32 len1, stbtt_uint8 *s2, stbtt_int32 len2) { stbtt_int32 i=0; @@ -3085,9 +4752,9 @@ static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(const stbtt_uint8 return i; } -STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) +static int stbtt_CompareUTF8toUTF16_bigendian_internal(char *s1, int len1, char *s2, int len2) { - return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((const stbtt_uint8*) s1, len1, (const stbtt_uint8*) s2, len2); + return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((stbtt_uint8*) s1, len1, (stbtt_uint8*) s2, len2); } // returns results in whatever encoding you request... but note that 2-byte encodings @@ -3143,7 +4810,7 @@ static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, return 1; } else if (matchlen < nlen && name[matchlen] == ' ') { ++matchlen; - if (stbtt_CompareUTF8toUTF16_bigendian((char*) (name+matchlen), nlen-matchlen, (char*)(fc+stringOffset+off),slen)) + if (stbtt_CompareUTF8toUTF16_bigendian_internal((char*) (name+matchlen), nlen-matchlen, (char*)(fc+stringOffset+off),slen)) return 1; } } else { @@ -3189,7 +4856,7 @@ static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *nam return 0; } -STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *font_collection, const char *name_utf8, stbtt_int32 flags) +static int stbtt_FindMatchingFont_internal(unsigned char *font_collection, char *name_utf8, stbtt_int32 flags) { stbtt_int32 i; for (i=0;;++i) { @@ -3200,11 +4867,64 @@ STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *font_collection, const } } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-qual" +#endif + +STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, + float pixel_height, unsigned char *pixels, int pw, int ph, + int first_char, int num_chars, stbtt_bakedchar *chardata) +{ + return stbtt_BakeFontBitmap_internal((unsigned char *) data, offset, pixel_height, pixels, pw, ph, first_char, num_chars, chardata); +} + +STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index) +{ + return stbtt_GetFontOffsetForIndex_internal((unsigned char *) data, index); +} + +STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data) +{ + return stbtt_GetNumberOfFonts_internal((unsigned char *) data); +} + +STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset) +{ + return stbtt_InitFont_internal(info, (unsigned char *) data, offset); +} + +STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags) +{ + return stbtt_FindMatchingFont_internal((unsigned char *) fontdata, (char *) name, flags); +} + +STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) +{ + return stbtt_CompareUTF8toUTF16_bigendian_internal((char *) s1, len1, (char *) s2, len2); +} + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + #endif // STB_TRUETYPE_IMPLEMENTATION // FULL VERSION HISTORY // +// 1.19 (2018-02-11) OpenType GPOS kerning (horizontal only), STBTT_fmod +// 1.18 (2018-01-29) add missing function +// 1.17 (2017-07-23) make more arguments const; doc fix +// 1.16 (2017-07-12) SDF support +// 1.15 (2017-03-03) make more arguments const +// 1.14 (2017-01-16) num-fonts-in-TTC function +// 1.13 (2017-01-02) support OpenType fonts, certain Apple fonts +// 1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual +// 1.11 (2016-04-02) fix unused-variable warning +// 1.10 (2016-04-02) allow user-defined fabs() replacement +// fix memory leak if fontsize=0.0 +// fix warning from duplicate typedef // 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use alloc userdata for PackFontRanges // 1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges // 1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints; @@ -3247,3 +4967,45 @@ STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *font_collection, const // 0.2 (2009-03-11) Fix unsigned/signed char warnings // 0.1 (2009-03-09) First public release // + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ +*/ diff --git a/phonelibs/openblas/libopenblas.so b/phonelibs/openblas/libopenblas.so deleted file mode 120000 index 7a792bc9071885..00000000000000 --- a/phonelibs/openblas/libopenblas.so +++ /dev/null @@ -1 +0,0 @@ -libopenblas_armv8p-r0.2.19.so \ No newline at end of file diff --git a/phonelibs/openblas/libopenblas_armv8p-r0.2.19.so b/phonelibs/openblas/libopenblas_armv8p-r0.2.19.so deleted file mode 100755 index ace58c8a13122f..00000000000000 Binary files a/phonelibs/openblas/libopenblas_armv8p-r0.2.19.so and /dev/null differ diff --git a/phonelibs/opencl/include/CL/cl_ext_qcom.h b/phonelibs/opencl/include/CL/cl_ext_qcom.h new file mode 100644 index 00000000000000..6328a1cd93a10e --- /dev/null +++ b/phonelibs/opencl/include/CL/cl_ext_qcom.h @@ -0,0 +1,255 @@ +/* Copyright (c) 2009-2017 Qualcomm Technologies, Inc. All Rights Reserved. + * Qualcomm Technologies Proprietary and Confidential. + */ + +#ifndef __OPENCL_CL_EXT_QCOM_H +#define __OPENCL_CL_EXT_QCOM_H + +// Needed by cl_khr_egl_event extension +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/************************************ + * cl_qcom_create_buffer_from_image * + ************************************/ + +#define CL_BUFFER_FROM_IMAGE_ROW_PITCH_QCOM 0x40C0 +#define CL_BUFFER_FROM_IMAGE_SLICE_PITCH_QCOM 0x40C1 + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateBufferFromImageQCOM(cl_mem image, + cl_mem_flags flags, + cl_int *errcode_ret); + + +/************************************ + * cl_qcom_limited_printf extension * + ************************************/ + +/* Builtin printf function buffer size in bytes. */ +#define CL_DEVICE_PRINTF_BUFFER_SIZE_QCOM 0x1049 + + +/************************************* + * cl_qcom_extended_images extension * + *************************************/ + +#define CL_CONTEXT_ENABLE_EXTENDED_IMAGES_QCOM 0x40AA +#define CL_DEVICE_EXTENDED_IMAGE2D_MAX_WIDTH_QCOM 0x40AB +#define CL_DEVICE_EXTENDED_IMAGE2D_MAX_HEIGHT_QCOM 0x40AC +#define CL_DEVICE_EXTENDED_IMAGE3D_MAX_WIDTH_QCOM 0x40AD +#define CL_DEVICE_EXTENDED_IMAGE3D_MAX_HEIGHT_QCOM 0x40AE +#define CL_DEVICE_EXTENDED_IMAGE3D_MAX_DEPTH_QCOM 0x40AF + +/************************************* + * cl_qcom_perf_hint extension * + *************************************/ + +typedef cl_uint cl_perf_hint; + +#define CL_CONTEXT_PERF_HINT_QCOM 0x40C2 + +/*cl_perf_hint*/ +#define CL_PERF_HINT_HIGH_QCOM 0x40C3 +#define CL_PERF_HINT_NORMAL_QCOM 0x40C4 +#define CL_PERF_HINT_LOW_QCOM 0x40C5 + +extern CL_API_ENTRY cl_int CL_API_CALL +clSetPerfHintQCOM(cl_context context, + cl_perf_hint perf_hint); + +// This extension is published at Khronos, so its definitions are made in cl_ext.h. +// This duplication is for backward compatibility. + +#ifndef CL_MEM_ANDROID_NATIVE_BUFFER_HOST_PTR_QCOM + +/********************************* +* cl_qcom_android_native_buffer_host_ptr extension +*********************************/ + +#define CL_MEM_ANDROID_NATIVE_BUFFER_HOST_PTR_QCOM 0x40C6 + + +typedef struct _cl_mem_android_native_buffer_host_ptr +{ + // Type of external memory allocation. + // Must be CL_MEM_ANDROID_NATIVE_BUFFER_HOST_PTR_QCOM for Android native buffers. + cl_mem_ext_host_ptr ext_host_ptr; + + // Virtual pointer to the android native buffer + void* anb_ptr; + +} cl_mem_android_native_buffer_host_ptr; + +#endif //#ifndef CL_MEM_ANDROID_NATIVE_BUFFER_HOST_PTR_QCOM + +/*********************************** +* cl_img_egl_image extension * +************************************/ +typedef void* CLeglImageIMG; +typedef void* CLeglDisplayIMG; + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromEGLImageIMG(cl_context context, + cl_mem_flags flags, + CLeglImageIMG image, + CLeglDisplayIMG display, + cl_int *errcode_ret); + + +/********************************* +* cl_qcom_other_image extension +*********************************/ + +// Extended flag for creating/querying QCOM non-standard images +#define CL_MEM_OTHER_IMAGE_QCOM (1<<25) + +// cl_channel_type +#define CL_QCOM_UNORM_MIPI10 0x4159 +#define CL_QCOM_UNORM_MIPI12 0x415A +#define CL_QCOM_UNSIGNED_MIPI10 0x415B +#define CL_QCOM_UNSIGNED_MIPI12 0x415C +#define CL_QCOM_UNORM_INT10 0x415D +#define CL_QCOM_UNORM_INT12 0x415E +#define CL_QCOM_UNSIGNED_INT16 0x415F + +// cl_channel_order +// Dedicate 0x4130-0x415F range for QCOM extended image formats +// 0x4130 - 0x4132 range is assigned to pixel-oriented compressed format +#define CL_QCOM_BAYER 0x414E + +#define CL_QCOM_NV12 0x4133 +#define CL_QCOM_NV12_Y 0x4134 +#define CL_QCOM_NV12_UV 0x4135 + +#define CL_QCOM_TILED_NV12 0x4136 +#define CL_QCOM_TILED_NV12_Y 0x4137 +#define CL_QCOM_TILED_NV12_UV 0x4138 + +#define CL_QCOM_P010 0x413C +#define CL_QCOM_P010_Y 0x413D +#define CL_QCOM_P010_UV 0x413E + +#define CL_QCOM_TILED_P010 0x413F +#define CL_QCOM_TILED_P010_Y 0x4140 +#define CL_QCOM_TILED_P010_UV 0x4141 + + +#define CL_QCOM_TP10 0x4145 +#define CL_QCOM_TP10_Y 0x4146 +#define CL_QCOM_TP10_UV 0x4147 + +#define CL_QCOM_TILED_TP10 0x4148 +#define CL_QCOM_TILED_TP10_Y 0x4149 +#define CL_QCOM_TILED_TP10_UV 0x414A + +/********************************* +* cl_qcom_compressed_image extension +*********************************/ + +// Extended flag for creating/querying QCOM non-planar compressed images +#define CL_MEM_COMPRESSED_IMAGE_QCOM (1<<27) + +// Extended image format +// cl_channel_order +#define CL_QCOM_COMPRESSED_RGBA 0x4130 +#define CL_QCOM_COMPRESSED_RGBx 0x4131 + +#define CL_QCOM_COMPRESSED_NV12_Y 0x413A +#define CL_QCOM_COMPRESSED_NV12_UV 0x413B + +#define CL_QCOM_COMPRESSED_P010 0x4142 +#define CL_QCOM_COMPRESSED_P010_Y 0x4143 +#define CL_QCOM_COMPRESSED_P010_UV 0x4144 + +#define CL_QCOM_COMPRESSED_TP10 0x414B +#define CL_QCOM_COMPRESSED_TP10_Y 0x414C +#define CL_QCOM_COMPRESSED_TP10_UV 0x414D + +#define CL_QCOM_COMPRESSED_NV12_4R 0x414F +#define CL_QCOM_COMPRESSED_NV12_4R_Y 0x4150 +#define CL_QCOM_COMPRESSED_NV12_4R_UV 0x4151 +/********************************* +* cl_qcom_compressed_yuv_image_read extension +*********************************/ + +// Extended flag for creating/querying QCOM compressed images +#define CL_MEM_COMPRESSED_YUV_IMAGE_QCOM (1<<28) + +// Extended image format +#define CL_QCOM_COMPRESSED_NV12 0x10C4 + +// Extended flag for setting ION buffer allocation type +#define CL_MEM_ION_HOST_PTR_COMPRESSED_YUV_QCOM 0x40CD +#define CL_MEM_ION_HOST_PTR_PROTECTED_COMPRESSED_YUV_QCOM 0x40CE + +/********************************* +* cl_qcom_accelerated_image_ops +*********************************/ +#define CL_MEM_OBJECT_WEIGHT_IMAGE_QCOM 0x4110 +#define CL_DEVICE_HOF_MAX_NUM_PHASES_QCOM 0x4111 +#define CL_DEVICE_HOF_MAX_FILTER_SIZE_X_QCOM 0x4112 +#define CL_DEVICE_HOF_MAX_FILTER_SIZE_Y_QCOM 0x4113 +#define CL_DEVICE_BLOCK_MATCHING_MAX_REGION_SIZE_X_QCOM 0x4114 +#define CL_DEVICE_BLOCK_MATCHING_MAX_REGION_SIZE_Y_QCOM 0x4115 + +//Extended flag for specifying weight image type +#define CL_WEIGHT_IMAGE_SEPARABLE_QCOM (1<<0) + +// Box Filter +typedef struct _cl_box_filter_size_qcom +{ + // Width of box filter on X direction. + float box_filter_width; + + // Height of box filter on Y direction. + float box_filter_height; +} cl_box_filter_size_qcom; + +// HOF Weight Image Desc +typedef struct _cl_weight_desc_qcom +{ + /** Coordinate of the "center" point of the weight image, + based on the weight image's top-left corner as the origin. */ + size_t center_coord_x; + size_t center_coord_y; + cl_bitfield flags; +} cl_weight_desc_qcom; + +typedef struct _cl_weight_image_desc_qcom +{ + cl_image_desc image_desc; + cl_weight_desc_qcom weight_desc; +} cl_weight_image_desc_qcom; + +/************************************* + * cl_qcom_protected_context extension * + *************************************/ + +#define CL_CONTEXT_PROTECTED_QCOM 0x40C7 +#define CL_MEM_ION_HOST_PTR_PROTECTED_QCOM 0x40C8 + +/************************************* + * cl_qcom_priority_hint extension * + *************************************/ +#define CL_PRIORITY_HINT_NONE_QCOM 0 +typedef cl_uint cl_priority_hint; + +#define CL_CONTEXT_PRIORITY_HINT_QCOM 0x40C9 + +/*cl_priority_hint*/ +#define CL_PRIORITY_HINT_HIGH_QCOM 0x40CA +#define CL_PRIORITY_HINT_NORMAL_QCOM 0x40CB +#define CL_PRIORITY_HINT_LOW_QCOM 0x40CC + +#ifdef __cplusplus +} +#endif + +#endif /* __OPENCL_CL_EXT_QCOM_H */ diff --git a/phonelibs/qpoases/INCLUDE/Bounds.hpp b/phonelibs/qpoases/INCLUDE/Bounds.hpp index 1fbd28ab38d342..7260756da07b5b 100644 --- a/phonelibs/qpoases/INCLUDE/Bounds.hpp +++ b/phonelibs/qpoases/INCLUDE/Bounds.hpp @@ -1,189 +1,189 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/Bounds.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Declaration of the Bounds class designed to manage working sets of - * bounds within a QProblem. - */ - - -#ifndef QPOASES_BOUNDS_HPP -#define QPOASES_BOUNDS_HPP - - -#include - - - -/** This class manages working sets of bounds by storing - * index sets and other status information. - * - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - */ -class Bounds : public SubjectTo -{ - /* - * PUBLIC MEMBER FUNCTIONS - */ - public: - /** Default constructor. */ - Bounds( ); - - /** Copy constructor (deep copy). */ - Bounds( const Bounds& rhs /**< Rhs object. */ - ); - - /** Destructor. */ - ~Bounds( ); - - /** Assignment operator (deep copy). */ - Bounds& operator=( const Bounds& rhs /**< Rhs object. */ - ); - - - /** Pseudo-constructor takes the number of bounds. - * \return SUCCESSFUL_RETURN */ - returnValue init( int n /**< Number of bounds. */ - ); - - - /** Initially adds number of a new (i.e. not yet in the list) bound to - * given index set. - * \return SUCCESSFUL_RETURN \n - RET_SETUP_BOUND_FAILED \n - RET_INDEX_OUT_OF_BOUNDS \n - RET_INVALID_ARGUMENTS */ - returnValue setupBound( int _number, /**< Number of new bound. */ - SubjectToStatus _status /**< Status of new bound. */ - ); - - /** Initially adds all numbers of new (i.e. not yet in the list) bounds to - * to the index set of free bounds; the order depends on the SujectToType - * of each index. - * \return SUCCESSFUL_RETURN \n - RET_SETUP_BOUND_FAILED */ - returnValue setupAllFree( ); - - - /** Moves index of a bound from index list of fixed to that of free bounds. - * \return SUCCESSFUL_RETURN \n - RET_MOVING_BOUND_FAILED \n - RET_INDEX_OUT_OF_BOUNDS */ - returnValue moveFixedToFree( int _number /**< Number of bound to be freed. */ - ); - - /** Moves index of a bound from index list of free to that of fixed bounds. - * \return SUCCESSFUL_RETURN \n - RET_MOVING_BOUND_FAILED \n - RET_INDEX_OUT_OF_BOUNDS */ - returnValue moveFreeToFixed( int _number, /**< Number of bound to be fixed. */ - SubjectToStatus _status /**< Status of bound to be fixed. */ - ); - - /** Swaps the indices of two free bounds within the index set. - * \return SUCCESSFUL_RETURN \n - RET_SWAPINDEX_FAILED */ - returnValue swapFree( int number1, /**< Number of first constraint or bound. */ - int number2 /**< Number of second constraint or bound. */ - ); - - - /** Returns number of variables. - * \return Number of variables. */ - inline int getNV( ) const; - - /** Returns number of implicitly fixed variables. - * \return Number of implicitly fixed variables. */ - inline int getNFV( ) const; - - /** Returns number of bounded (but possibly free) variables. - * \return Number of bounded (but possibly free) variables. */ - inline int getNBV( ) const; - - /** Returns number of unbounded variables. - * \return Number of unbounded variables. */ - inline int getNUV( ) const; - - - /** Sets number of implicitly fixed variables. - * \return SUCCESSFUL_RETURN */ - inline returnValue setNFV( int n /**< Number of implicitly fixed variables. */ - ); - - /** Sets number of bounded (but possibly free) variables. - * \return SUCCESSFUL_RETURN */ - inline returnValue setNBV( int n /**< Number of bounded (but possibly free) variables. */ - ); - - /** Sets number of unbounded variables. - * \return SUCCESSFUL_RETURN */ - inline returnValue setNUV( int n /**< Number of unbounded variables */ - ); - - - /** Returns number of free variables. - * \return Number of free variables. */ - inline int getNFR( ); - - /** Returns number of fixed variables. - * \return Number of fixed variables. */ - inline int getNFX( ); - - - /** Returns a pointer to free variables index list. - * \return Pointer to free variables index list. */ - inline Indexlist* getFree( ); - - /** Returns a pointer to fixed variables index list. - * \return Pointer to fixed variables index list. */ - inline Indexlist* getFixed( ); - - - /* - * PROTECTED MEMBER VARIABLES - */ - protected: - int nV; /**< Number of variables (nV = nFV + nBV + nUV). */ - int nFV; /**< Number of implicitly fixed variables. */ - int nBV; /**< Number of bounded (but possibly free) variables. */ - int nUV; /**< Number of unbounded variables. */ - - Indexlist free; /**< Index list of free variables. */ - Indexlist fixed; /**< Index list of fixed variables. */ -}; - -#include - -#endif /* QPOASES_BOUNDS_HPP */ - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file INCLUDE/Bounds.hpp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Declaration of the Bounds class designed to manage working sets of + * bounds within a QProblem. + */ + + +#ifndef QPOASES_BOUNDS_HPP +#define QPOASES_BOUNDS_HPP + + +#include + + + +/** This class manages working sets of bounds by storing + * index sets and other status information. + * + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + */ +class Bounds : public SubjectTo +{ + /* + * PUBLIC MEMBER FUNCTIONS + */ + public: + /** Default constructor. */ + Bounds( ); + + /** Copy constructor (deep copy). */ + Bounds( const Bounds& rhs /**< Rhs object. */ + ); + + /** Destructor. */ + ~Bounds( ); + + /** Assignment operator (deep copy). */ + Bounds& operator=( const Bounds& rhs /**< Rhs object. */ + ); + + + /** Pseudo-constructor takes the number of bounds. + * \return SUCCESSFUL_RETURN */ + returnValue init( int n /**< Number of bounds. */ + ); + + + /** Initially adds number of a new (i.e. not yet in the list) bound to + * given index set. + * \return SUCCESSFUL_RETURN \n + RET_SETUP_BOUND_FAILED \n + RET_INDEX_OUT_OF_BOUNDS \n + RET_INVALID_ARGUMENTS */ + returnValue setupBound( int _number, /**< Number of new bound. */ + SubjectToStatus _status /**< Status of new bound. */ + ); + + /** Initially adds all numbers of new (i.e. not yet in the list) bounds to + * to the index set of free bounds; the order depends on the SujectToType + * of each index. + * \return SUCCESSFUL_RETURN \n + RET_SETUP_BOUND_FAILED */ + returnValue setupAllFree( ); + + + /** Moves index of a bound from index list of fixed to that of free bounds. + * \return SUCCESSFUL_RETURN \n + RET_MOVING_BOUND_FAILED \n + RET_INDEX_OUT_OF_BOUNDS */ + returnValue moveFixedToFree( int _number /**< Number of bound to be freed. */ + ); + + /** Moves index of a bound from index list of free to that of fixed bounds. + * \return SUCCESSFUL_RETURN \n + RET_MOVING_BOUND_FAILED \n + RET_INDEX_OUT_OF_BOUNDS */ + returnValue moveFreeToFixed( int _number, /**< Number of bound to be fixed. */ + SubjectToStatus _status /**< Status of bound to be fixed. */ + ); + + /** Swaps the indices of two free bounds within the index set. + * \return SUCCESSFUL_RETURN \n + RET_SWAPINDEX_FAILED */ + returnValue swapFree( int number1, /**< Number of first constraint or bound. */ + int number2 /**< Number of second constraint or bound. */ + ); + + + /** Returns number of variables. + * \return Number of variables. */ + inline int getNV( ) const; + + /** Returns number of implicitly fixed variables. + * \return Number of implicitly fixed variables. */ + inline int getNFV( ) const; + + /** Returns number of bounded (but possibly free) variables. + * \return Number of bounded (but possibly free) variables. */ + inline int getNBV( ) const; + + /** Returns number of unbounded variables. + * \return Number of unbounded variables. */ + inline int getNUV( ) const; + + + /** Sets number of implicitly fixed variables. + * \return SUCCESSFUL_RETURN */ + inline returnValue setNFV( int n /**< Number of implicitly fixed variables. */ + ); + + /** Sets number of bounded (but possibly free) variables. + * \return SUCCESSFUL_RETURN */ + inline returnValue setNBV( int n /**< Number of bounded (but possibly free) variables. */ + ); + + /** Sets number of unbounded variables. + * \return SUCCESSFUL_RETURN */ + inline returnValue setNUV( int n /**< Number of unbounded variables */ + ); + + + /** Returns number of free variables. + * \return Number of free variables. */ + inline int getNFR( ); + + /** Returns number of fixed variables. + * \return Number of fixed variables. */ + inline int getNFX( ); + + + /** Returns a pointer to free variables index list. + * \return Pointer to free variables index list. */ + inline Indexlist* getFree( ); + + /** Returns a pointer to fixed variables index list. + * \return Pointer to fixed variables index list. */ + inline Indexlist* getFixed( ); + + + /* + * PROTECTED MEMBER VARIABLES + */ + protected: + int nV; /**< Number of variables (nV = nFV + nBV + nUV). */ + int nFV; /**< Number of implicitly fixed variables. */ + int nBV; /**< Number of bounded (but possibly free) variables. */ + int nUV; /**< Number of unbounded variables. */ + + Indexlist free; /**< Index list of free variables. */ + Indexlist fixed; /**< Index list of fixed variables. */ +}; + +#include + +#endif /* QPOASES_BOUNDS_HPP */ + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/INCLUDE/Constants.hpp b/phonelibs/qpoases/INCLUDE/Constants.hpp index 8293fa514c6a9c..92ee812295bf37 100644 --- a/phonelibs/qpoases/INCLUDE/Constants.hpp +++ b/phonelibs/qpoases/INCLUDE/Constants.hpp @@ -1,108 +1,108 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/Constants.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2008 - * - * Definition of all global constants. - */ - - -#ifndef QPOASES_CONSTANTS_HPP -#define QPOASES_CONSTANTS_HPP - -#ifndef QPOASES_CUSTOM_INTERFACE -#include "acado_qpoases_interface.hpp" -#else - #define XSTR(x) #x - #define STR(x) XSTR(x) - #include STR(QPOASES_CUSTOM_INTERFACE) -#endif - -/** Maximum number of variables within a QP formulation. - Note: this value has to be positive! */ -const int NVMAX = QPOASES_NVMAX; - -/** Maximum number of constraints within a QP formulation. - Note: this value has to be positive! */ -const int NCMAX = QPOASES_NCMAX; - -/** Redefinition of NCMAX used for memory allocation, to avoid zero sized arrays - and compiler errors. */ -const int NCMAX_ALLOC = (NCMAX == 0) ? 1 : NCMAX; - -/**< Maximum number of working set recalculations. - Note: this value has to be positive! */ -const int NWSRMAX = QPOASES_NWSRMAX; - -/** Desired KKT tolerance of QP solution; a warning RET_INACCURATE_SOLUTION is - * issued if this tolerance is not met. - * Note: this value has to be positive! */ -const real_t DESIREDACCURACY = (real_t) 1.0e-3; - -/** Critical KKT tolerance of QP solution; an error is issued if this - * tolerance is not met. - * Note: this value has to be positive! */ -const real_t CRITICALACCURACY = (real_t) 1.0e-2; - - - -/** Numerical value of machine precision (min eps, s.t. 1+eps > 1). - Note: this value has to be positive! */ -const real_t EPS = (real_t) QPOASES_EPS; - -/** Numerical value of zero (for situations in which it would be - * unreasonable to compare with 0.0). - * Note: this value has to be positive! */ -const real_t ZERO = (real_t) 1.0e-50; - -/** Numerical value of infinity (e.g. for non-existing bounds). - * Note: this value has to be positive! */ -const real_t INFTY = (real_t) 1.0e12; - - -/** Lower/upper (constraints') bound tolerance (an inequality constraint - * whose lower and upper bound differ by less than BOUNDTOL is regarded - * to be an equality constraint). - * Note: this value has to be positive! */ -const real_t BOUNDTOL = (real_t) 1.0e-10; - -/** Offset for relaxing (constraints') bounds at beginning of an initial homotopy. - * Note: this value has to be positive! */ -const real_t BOUNDRELAXATION = (real_t) 1.0e3; - - -/** Factor that determines physical lengths of index lists. - * Note: this value has to be greater than 1! */ -const int INDEXLISTFACTOR = 5; - - -#endif /* QPOASES_CONSTANTS_HPP */ - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file INCLUDE/Constants.hpp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2008 + * + * Definition of all global constants. + */ + + +#ifndef QPOASES_CONSTANTS_HPP +#define QPOASES_CONSTANTS_HPP + +#ifndef QPOASES_CUSTOM_INTERFACE +#include "acado_qpoases_interface.hpp" +#else + #define XSTR(x) #x + #define STR(x) XSTR(x) + #include STR(QPOASES_CUSTOM_INTERFACE) +#endif + +/** Maximum number of variables within a QP formulation. + Note: this value has to be positive! */ +const int NVMAX = QPOASES_NVMAX; + +/** Maximum number of constraints within a QP formulation. + Note: this value has to be positive! */ +const int NCMAX = QPOASES_NCMAX; + +/** Redefinition of NCMAX used for memory allocation, to avoid zero sized arrays + and compiler errors. */ +const int NCMAX_ALLOC = (NCMAX == 0) ? 1 : NCMAX; + +/**< Maximum number of working set recalculations. + Note: this value has to be positive! */ +const int NWSRMAX = QPOASES_NWSRMAX; + +/** Desired KKT tolerance of QP solution; a warning RET_INACCURATE_SOLUTION is + * issued if this tolerance is not met. + * Note: this value has to be positive! */ +const real_t DESIREDACCURACY = (real_t) 1.0e-3; + +/** Critical KKT tolerance of QP solution; an error is issued if this + * tolerance is not met. + * Note: this value has to be positive! */ +const real_t CRITICALACCURACY = (real_t) 1.0e-2; + + + +/** Numerical value of machine precision (min eps, s.t. 1+eps > 1). + Note: this value has to be positive! */ +const real_t EPS = (real_t) QPOASES_EPS; + +/** Numerical value of zero (for situations in which it would be + * unreasonable to compare with 0.0). + * Note: this value has to be positive! */ +const real_t ZERO = (real_t) 1.0e-50; + +/** Numerical value of infinity (e.g. for non-existing bounds). + * Note: this value has to be positive! */ +const real_t INFTY = (real_t) 1.0e12; + + +/** Lower/upper (constraints') bound tolerance (an inequality constraint + * whose lower and upper bound differ by less than BOUNDTOL is regarded + * to be an equality constraint). + * Note: this value has to be positive! */ +const real_t BOUNDTOL = (real_t) 1.0e-10; + +/** Offset for relaxing (constraints') bounds at beginning of an initial homotopy. + * Note: this value has to be positive! */ +const real_t BOUNDRELAXATION = (real_t) 1.0e3; + + +/** Factor that determines physical lengths of index lists. + * Note: this value has to be greater than 1! */ +const int INDEXLISTFACTOR = 5; + + +#endif /* QPOASES_CONSTANTS_HPP */ + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/INCLUDE/Constraints.hpp b/phonelibs/qpoases/INCLUDE/Constraints.hpp index 0b78747e29afeb..899167942a7dd3 100644 --- a/phonelibs/qpoases/INCLUDE/Constraints.hpp +++ b/phonelibs/qpoases/INCLUDE/Constraints.hpp @@ -1,181 +1,181 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/Constraints.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Declaration of the Constraints class designed to manage working sets of - * constraints within a QProblem. - */ - - -#ifndef QPOASES_CONSTRAINTS_HPP -#define QPOASES_CONSTRAINTS_HPP - - -#include - - - -/** This class manages working sets of constraints by storing - * index sets and other status information. - * - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - */ -class Constraints : public SubjectTo -{ - /* - * PUBLIC MEMBER FUNCTIONS - */ - public: - /** Default constructor. */ - Constraints( ); - - /** Copy constructor (deep copy). */ - Constraints( const Constraints& rhs /**< Rhs object. */ - ); - - /** Destructor. */ - ~Constraints( ); - - /** Assignment operator (deep copy). */ - Constraints& operator=( const Constraints& rhs /**< Rhs object. */ - ); - - - /** Pseudo-constructor takes the number of constraints. - * \return SUCCESSFUL_RETURN */ - returnValue init( int n /**< Number of constraints. */ - ); - - - /** Initially adds number of a new (i.e. not yet in the list) constraint to - * a given index set. - * \return SUCCESSFUL_RETURN \n - RET_SETUP_CONSTRAINT_FAILED \n - RET_INDEX_OUT_OF_BOUNDS \n - RET_INVALID_ARGUMENTS */ - returnValue setupConstraint( int _number, /**< Number of new constraint. */ - SubjectToStatus _status /**< Status of new constraint. */ - ); - - /** Initially adds all enabled numbers of new (i.e. not yet in the list) constraints to - * to the index set of inactive constraints; the order depends on the SujectToType - * of each index. Only disabled constraints are added to index set of disabled constraints! - * \return SUCCESSFUL_RETURN \n - RET_SETUP_CONSTRAINT_FAILED */ - returnValue setupAllInactive( ); - - - /** Moves index of a constraint from index list of active to that of inactive constraints. - * \return SUCCESSFUL_RETURN \n - RET_MOVING_CONSTRAINT_FAILED */ - returnValue moveActiveToInactive( int _number /**< Number of constraint to become inactive. */ - ); - - /** Moves index of a constraint from index list of inactive to that of active constraints. - * \return SUCCESSFUL_RETURN \n - RET_MOVING_CONSTRAINT_FAILED */ - returnValue moveInactiveToActive( int _number, /**< Number of constraint to become active. */ - SubjectToStatus _status /**< Status of constraint to become active. */ - ); - - - /** Returns the number of constraints. - * \return Number of constraints. */ - inline int getNC( ) const; - - /** Returns the number of implicit equality constraints. - * \return Number of implicit equality constraints. */ - inline int getNEC( ) const; - - /** Returns the number of "real" inequality constraints. - * \return Number of "real" inequality constraints. */ - inline int getNIC( ) const; - - /** Returns the number of unbounded constraints (i.e. without any bounds). - * \return Number of unbounded constraints (i.e. without any bounds). */ - inline int getNUC( ) const; - - - /** Sets number of implicit equality constraints. - * \return SUCCESSFUL_RETURN */ - inline returnValue setNEC( int n /**< Number of implicit equality constraints. */ - ); - - /** Sets number of "real" inequality constraints. - * \return SUCCESSFUL_RETURN */ - inline returnValue setNIC( int n /**< Number of "real" inequality constraints. */ - ); - - /** Sets number of unbounded constraints (i.e. without any bounds). - * \return SUCCESSFUL_RETURN */ - inline returnValue setNUC( int n /**< Number of unbounded constraints (i.e. without any bounds). */ - ); - - - /** Returns the number of active constraints. - * \return Number of constraints. */ - inline int getNAC( ); - - /** Returns the number of inactive constraints. - * \return Number of constraints. */ - inline int getNIAC( ); - - - /** Returns a pointer to active constraints index list. - * \return Pointer to active constraints index list. */ - inline Indexlist* getActive( ); - - /** Returns a pointer to inactive constraints index list. - * \return Pointer to inactive constraints index list. */ - inline Indexlist* getInactive( ); - - - /* - * PROTECTED MEMBER VARIABLES - */ - protected: - int nC; /**< Number of constraints (nC = nEC + nIC + nUC). */ - int nEC; /**< Number of implicit equality constraints. */ - int nIC; /**< Number of "real" inequality constraints. */ - int nUC; /**< Number of unbounded constraints (i.e. without any bounds). */ - - Indexlist active; /**< Index list of active constraints. */ - Indexlist inactive; /**< Index list of inactive constraints. */ -}; - - -#include - -#endif /* QPOASES_CONSTRAINTS_HPP */ - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file INCLUDE/Constraints.hpp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Declaration of the Constraints class designed to manage working sets of + * constraints within a QProblem. + */ + + +#ifndef QPOASES_CONSTRAINTS_HPP +#define QPOASES_CONSTRAINTS_HPP + + +#include + + + +/** This class manages working sets of constraints by storing + * index sets and other status information. + * + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + */ +class Constraints : public SubjectTo +{ + /* + * PUBLIC MEMBER FUNCTIONS + */ + public: + /** Default constructor. */ + Constraints( ); + + /** Copy constructor (deep copy). */ + Constraints( const Constraints& rhs /**< Rhs object. */ + ); + + /** Destructor. */ + ~Constraints( ); + + /** Assignment operator (deep copy). */ + Constraints& operator=( const Constraints& rhs /**< Rhs object. */ + ); + + + /** Pseudo-constructor takes the number of constraints. + * \return SUCCESSFUL_RETURN */ + returnValue init( int n /**< Number of constraints. */ + ); + + + /** Initially adds number of a new (i.e. not yet in the list) constraint to + * a given index set. + * \return SUCCESSFUL_RETURN \n + RET_SETUP_CONSTRAINT_FAILED \n + RET_INDEX_OUT_OF_BOUNDS \n + RET_INVALID_ARGUMENTS */ + returnValue setupConstraint( int _number, /**< Number of new constraint. */ + SubjectToStatus _status /**< Status of new constraint. */ + ); + + /** Initially adds all enabled numbers of new (i.e. not yet in the list) constraints to + * to the index set of inactive constraints; the order depends on the SujectToType + * of each index. Only disabled constraints are added to index set of disabled constraints! + * \return SUCCESSFUL_RETURN \n + RET_SETUP_CONSTRAINT_FAILED */ + returnValue setupAllInactive( ); + + + /** Moves index of a constraint from index list of active to that of inactive constraints. + * \return SUCCESSFUL_RETURN \n + RET_MOVING_CONSTRAINT_FAILED */ + returnValue moveActiveToInactive( int _number /**< Number of constraint to become inactive. */ + ); + + /** Moves index of a constraint from index list of inactive to that of active constraints. + * \return SUCCESSFUL_RETURN \n + RET_MOVING_CONSTRAINT_FAILED */ + returnValue moveInactiveToActive( int _number, /**< Number of constraint to become active. */ + SubjectToStatus _status /**< Status of constraint to become active. */ + ); + + + /** Returns the number of constraints. + * \return Number of constraints. */ + inline int getNC( ) const; + + /** Returns the number of implicit equality constraints. + * \return Number of implicit equality constraints. */ + inline int getNEC( ) const; + + /** Returns the number of "real" inequality constraints. + * \return Number of "real" inequality constraints. */ + inline int getNIC( ) const; + + /** Returns the number of unbounded constraints (i.e. without any bounds). + * \return Number of unbounded constraints (i.e. without any bounds). */ + inline int getNUC( ) const; + + + /** Sets number of implicit equality constraints. + * \return SUCCESSFUL_RETURN */ + inline returnValue setNEC( int n /**< Number of implicit equality constraints. */ + ); + + /** Sets number of "real" inequality constraints. + * \return SUCCESSFUL_RETURN */ + inline returnValue setNIC( int n /**< Number of "real" inequality constraints. */ + ); + + /** Sets number of unbounded constraints (i.e. without any bounds). + * \return SUCCESSFUL_RETURN */ + inline returnValue setNUC( int n /**< Number of unbounded constraints (i.e. without any bounds). */ + ); + + + /** Returns the number of active constraints. + * \return Number of constraints. */ + inline int getNAC( ); + + /** Returns the number of inactive constraints. + * \return Number of constraints. */ + inline int getNIAC( ); + + + /** Returns a pointer to active constraints index list. + * \return Pointer to active constraints index list. */ + inline Indexlist* getActive( ); + + /** Returns a pointer to inactive constraints index list. + * \return Pointer to inactive constraints index list. */ + inline Indexlist* getInactive( ); + + + /* + * PROTECTED MEMBER VARIABLES + */ + protected: + int nC; /**< Number of constraints (nC = nEC + nIC + nUC). */ + int nEC; /**< Number of implicit equality constraints. */ + int nIC; /**< Number of "real" inequality constraints. */ + int nUC; /**< Number of unbounded constraints (i.e. without any bounds). */ + + Indexlist active; /**< Index list of active constraints. */ + Indexlist inactive; /**< Index list of inactive constraints. */ +}; + + +#include + +#endif /* QPOASES_CONSTRAINTS_HPP */ + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/INCLUDE/CyclingManager.hpp b/phonelibs/qpoases/INCLUDE/CyclingManager.hpp index 9b5c064a0bd7a4..b4410b106e61ea 100644 --- a/phonelibs/qpoases/INCLUDE/CyclingManager.hpp +++ b/phonelibs/qpoases/INCLUDE/CyclingManager.hpp @@ -1,126 +1,126 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/CyclingManager.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Declaration of the CyclingManager class designed to detect - * and handle possible cycling during QP iterations. - */ - - -#ifndef QPOASES_CYCLINGMANAGER_HPP -#define QPOASES_CYCLINGMANAGER_HPP - - -#include - - - -/** This class is intended to detect and handle possible cycling during QP iterations. - * As cycling seems to occur quite rarely, this class is NOT FULLY IMPLEMENTED YET! - * - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - */ -class CyclingManager -{ - /* - * PUBLIC MEMBER FUNCTIONS - */ - public: - /** Default constructor. */ - CyclingManager( ); - - /** Copy constructor (deep copy). */ - CyclingManager( const CyclingManager& rhs /**< Rhs object. */ - ); - - /** Destructor. */ - ~CyclingManager( ); - - /** Copy asingment operator (deep copy). */ - CyclingManager& operator=( const CyclingManager& rhs /**< Rhs object. */ - ); - - - /** Pseudo-constructor which takes the number of bounds/constraints. - * \return SUCCESSFUL_RETURN */ - returnValue init( int _nV, /**< Number of bounds to be managed. */ - int _nC /**< Number of constraints to be managed. */ - ); - - - /** Stores index of a bound/constraint that might cause cycling. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - returnValue setCyclingStatus( int number, /**< Number of bound/constraint. */ - BooleanType isBound, /**< Flag that indicates if given number corresponds to a - * bound (BT_TRUE) or a constraint (BT_FALSE). */ - CyclingStatus _status /**< Cycling status of bound/constraint. */ - ); - - /** Returns if bound/constraint might cause cycling. - * \return BT_TRUE: bound/constraint might cause cycling \n - BT_FALSE: otherwise */ - CyclingStatus getCyclingStatus( int number, /**< Number of bound/constraint. */ - BooleanType isBound /**< Flag that indicates if given number corresponds to - * a bound (BT_TRUE) or a constraint (BT_FALSE). */ - ) const; - - - /** Clears all previous cycling information. - * \return SUCCESSFUL_RETURN */ - returnValue clearCyclingData( ); - - - /** Returns if cycling was detected. - * \return BT_TRUE iff cycling was detected. */ - inline BooleanType isCyclingDetected( ) const; - - - /* - * PROTECTED MEMBER VARIABLES - */ - protected: - int nV; /**< Number of managed bounds. */ - int nC; /**< Number of managed constraints. */ - - CyclingStatus status[NVMAX+NCMAX]; /**< Array to store cycling status of all bounds/constraints. */ - - BooleanType cyclingDetected; /**< Flag if cycling was detected. */ -}; - - -#include - -#endif /* QPOASES_CYCLINGMANAGER_HPP */ - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file INCLUDE/CyclingManager.hpp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Declaration of the CyclingManager class designed to detect + * and handle possible cycling during QP iterations. + */ + + +#ifndef QPOASES_CYCLINGMANAGER_HPP +#define QPOASES_CYCLINGMANAGER_HPP + + +#include + + + +/** This class is intended to detect and handle possible cycling during QP iterations. + * As cycling seems to occur quite rarely, this class is NOT FULLY IMPLEMENTED YET! + * + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + */ +class CyclingManager +{ + /* + * PUBLIC MEMBER FUNCTIONS + */ + public: + /** Default constructor. */ + CyclingManager( ); + + /** Copy constructor (deep copy). */ + CyclingManager( const CyclingManager& rhs /**< Rhs object. */ + ); + + /** Destructor. */ + ~CyclingManager( ); + + /** Copy asingment operator (deep copy). */ + CyclingManager& operator=( const CyclingManager& rhs /**< Rhs object. */ + ); + + + /** Pseudo-constructor which takes the number of bounds/constraints. + * \return SUCCESSFUL_RETURN */ + returnValue init( int _nV, /**< Number of bounds to be managed. */ + int _nC /**< Number of constraints to be managed. */ + ); + + + /** Stores index of a bound/constraint that might cause cycling. + * \return SUCCESSFUL_RETURN \n + RET_INDEX_OUT_OF_BOUNDS */ + returnValue setCyclingStatus( int number, /**< Number of bound/constraint. */ + BooleanType isBound, /**< Flag that indicates if given number corresponds to a + * bound (BT_TRUE) or a constraint (BT_FALSE). */ + CyclingStatus _status /**< Cycling status of bound/constraint. */ + ); + + /** Returns if bound/constraint might cause cycling. + * \return BT_TRUE: bound/constraint might cause cycling \n + BT_FALSE: otherwise */ + CyclingStatus getCyclingStatus( int number, /**< Number of bound/constraint. */ + BooleanType isBound /**< Flag that indicates if given number corresponds to + * a bound (BT_TRUE) or a constraint (BT_FALSE). */ + ) const; + + + /** Clears all previous cycling information. + * \return SUCCESSFUL_RETURN */ + returnValue clearCyclingData( ); + + + /** Returns if cycling was detected. + * \return BT_TRUE iff cycling was detected. */ + inline BooleanType isCyclingDetected( ) const; + + + /* + * PROTECTED MEMBER VARIABLES + */ + protected: + int nV; /**< Number of managed bounds. */ + int nC; /**< Number of managed constraints. */ + + CyclingStatus status[NVMAX+NCMAX]; /**< Array to store cycling status of all bounds/constraints. */ + + BooleanType cyclingDetected; /**< Flag if cycling was detected. */ +}; + + +#include + +#endif /* QPOASES_CYCLINGMANAGER_HPP */ + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/INCLUDE/Indexlist.hpp b/phonelibs/qpoases/INCLUDE/Indexlist.hpp index 18e3494e3f656c..21c31ddb9215bb 100644 --- a/phonelibs/qpoases/INCLUDE/Indexlist.hpp +++ b/phonelibs/qpoases/INCLUDE/Indexlist.hpp @@ -1,154 +1,154 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/Indexlist.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Declaration of the Indexlist class designed to manage index lists of - * constraints and bounds within a SubjectTo object. - */ - - -#ifndef QPOASES_INDEXLIST_HPP -#define QPOASES_INDEXLIST_HPP - - -#include - - -/** This class manages index lists. - * - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - */ -class Indexlist -{ - /* - * PUBLIC MEMBER FUNCTIONS - */ - public: - /** Default constructor. */ - Indexlist( ); - - /** Copy constructor (deep copy). */ - Indexlist( const Indexlist& rhs /**< Rhs object. */ - ); - - /** Destructor. */ - ~Indexlist( ); - - /** Assingment operator (deep copy). */ - Indexlist& operator=( const Indexlist& rhs /**< Rhs object. */ - ); - - /** Pseudo-constructor. - * \return SUCCESSFUL_RETURN */ - returnValue init( ); - - - /** Creates an array of all numbers within the index set in correct order. - * \return SUCCESSFUL_RETURN \n - RET_INDEXLIST_CORRUPTED */ - returnValue getNumberArray( int* const numberarray /**< Output: Array of numbers (NULL on error). */ - ) const; - - - /** Determines the index within the index list at with a given number is stored. - * \return >= 0: Index of given number. \n - -1: Number not found. */ - int getIndex( int givennumber /**< Number whose index shall be determined. */ - ) const; - - /** Determines the physical index within the index list at with a given number is stored. - * \return >= 0: Index of given number. \n - -1: Number not found. */ - int getPhysicalIndex( int givennumber /**< Number whose physical index shall be determined. */ - ) const; - - /** Returns the number stored at a given physical index. - * \return >= 0: Number stored at given physical index. \n - -RET_INDEXLIST_OUTOFBOUNDS */ - int getNumber( int physicalindex /**< Physical index of the number to be returned. */ - ) const; - - - /** Returns the current length of the index list. - * \return Current length of the index list. */ - inline int getLength( ); - - /** Returns last number within the index list. - * \return Last number within the index list. */ - inline int getLastNumber( ) const; - - - /** Adds number to index list. - * \return SUCCESSFUL_RETURN \n - RET_INDEXLIST_MUST_BE_REORDERD \n - RET_INDEXLIST_EXCEEDS_MAX_LENGTH */ - returnValue addNumber( int addnumber /**< Number to be added. */ - ); - - /** Removes number from index list. - * \return SUCCESSFUL_RETURN */ - returnValue removeNumber( int removenumber /**< Number to be removed. */ - ); - - /** Swaps two numbers within index list. - * \return SUCCESSFUL_RETURN */ - returnValue swapNumbers( int number1,/**< First number for swapping. */ - int number2 /**< Second number for swapping. */ - ); - - /** Determines if a given number is contained in the index set. - * \return BT_TRUE iff number is contain in the index set */ - inline BooleanType isMember( int _number /**< Number to be tested for membership. */ - ) const; - - - /* - * PROTECTED MEMBER VARIABLES - */ - protected: - int number[INDEXLISTFACTOR*(NVMAX+NCMAX)]; /**< Array to store numbers of constraints or bounds. */ - int next[INDEXLISTFACTOR*(NVMAX+NCMAX)]; /**< Array to store physical index of successor. */ - int previous[INDEXLISTFACTOR*(NVMAX+NCMAX)]; /**< Array to store physical index of predecossor. */ - int length; /**< Length of index list. */ - int first; /**< Physical index of first element. */ - int last; /**< Physical index of last element. */ - int lastusedindex; /**< Physical index of last entry in index list. */ - int physicallength; /**< Physical length of index list. */ -}; - - -#include - -#endif /* QPOASES_INDEXLIST_HPP */ - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file INCLUDE/Indexlist.hpp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Declaration of the Indexlist class designed to manage index lists of + * constraints and bounds within a SubjectTo object. + */ + + +#ifndef QPOASES_INDEXLIST_HPP +#define QPOASES_INDEXLIST_HPP + + +#include + + +/** This class manages index lists. + * + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + */ +class Indexlist +{ + /* + * PUBLIC MEMBER FUNCTIONS + */ + public: + /** Default constructor. */ + Indexlist( ); + + /** Copy constructor (deep copy). */ + Indexlist( const Indexlist& rhs /**< Rhs object. */ + ); + + /** Destructor. */ + ~Indexlist( ); + + /** Assingment operator (deep copy). */ + Indexlist& operator=( const Indexlist& rhs /**< Rhs object. */ + ); + + /** Pseudo-constructor. + * \return SUCCESSFUL_RETURN */ + returnValue init( ); + + + /** Creates an array of all numbers within the index set in correct order. + * \return SUCCESSFUL_RETURN \n + RET_INDEXLIST_CORRUPTED */ + returnValue getNumberArray( int* const numberarray /**< Output: Array of numbers (NULL on error). */ + ) const; + + + /** Determines the index within the index list at with a given number is stored. + * \return >= 0: Index of given number. \n + -1: Number not found. */ + int getIndex( int givennumber /**< Number whose index shall be determined. */ + ) const; + + /** Determines the physical index within the index list at with a given number is stored. + * \return >= 0: Index of given number. \n + -1: Number not found. */ + int getPhysicalIndex( int givennumber /**< Number whose physical index shall be determined. */ + ) const; + + /** Returns the number stored at a given physical index. + * \return >= 0: Number stored at given physical index. \n + -RET_INDEXLIST_OUTOFBOUNDS */ + int getNumber( int physicalindex /**< Physical index of the number to be returned. */ + ) const; + + + /** Returns the current length of the index list. + * \return Current length of the index list. */ + inline int getLength( ); + + /** Returns last number within the index list. + * \return Last number within the index list. */ + inline int getLastNumber( ) const; + + + /** Adds number to index list. + * \return SUCCESSFUL_RETURN \n + RET_INDEXLIST_MUST_BE_REORDERD \n + RET_INDEXLIST_EXCEEDS_MAX_LENGTH */ + returnValue addNumber( int addnumber /**< Number to be added. */ + ); + + /** Removes number from index list. + * \return SUCCESSFUL_RETURN */ + returnValue removeNumber( int removenumber /**< Number to be removed. */ + ); + + /** Swaps two numbers within index list. + * \return SUCCESSFUL_RETURN */ + returnValue swapNumbers( int number1,/**< First number for swapping. */ + int number2 /**< Second number for swapping. */ + ); + + /** Determines if a given number is contained in the index set. + * \return BT_TRUE iff number is contain in the index set */ + inline BooleanType isMember( int _number /**< Number to be tested for membership. */ + ) const; + + + /* + * PROTECTED MEMBER VARIABLES + */ + protected: + int number[INDEXLISTFACTOR*(NVMAX+NCMAX)]; /**< Array to store numbers of constraints or bounds. */ + int next[INDEXLISTFACTOR*(NVMAX+NCMAX)]; /**< Array to store physical index of successor. */ + int previous[INDEXLISTFACTOR*(NVMAX+NCMAX)]; /**< Array to store physical index of predecossor. */ + int length; /**< Length of index list. */ + int first; /**< Physical index of first element. */ + int last; /**< Physical index of last element. */ + int lastusedindex; /**< Physical index of last entry in index list. */ + int physicallength; /**< Physical length of index list. */ +}; + + +#include + +#endif /* QPOASES_INDEXLIST_HPP */ + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/INCLUDE/MessageHandling.hpp b/phonelibs/qpoases/INCLUDE/MessageHandling.hpp index f0b0c79a473b85..3d17498ade0738 100644 --- a/phonelibs/qpoases/INCLUDE/MessageHandling.hpp +++ b/phonelibs/qpoases/INCLUDE/MessageHandling.hpp @@ -1,415 +1,415 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/MessageHandling.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Declaration of the MessageHandling class including global return values. - */ - - -#ifndef QPOASES_MESSAGEHANDLING_HPP -#define QPOASES_MESSAGEHANDLING_HPP - -// #define PC_DEBUG - -#ifdef PC_DEBUG - #include - - /** Defines an alias for FILE from stdio.h. */ - #define myFILE FILE - /** Defines an alias for stderr from stdio.h. */ - #define myStderr stderr - /** Defines an alias for stdout from stdio.h. */ - #define myStdout stdout -#else - /** Defines an alias for FILE from stdio.h. */ - #define myFILE int - /** Defines an alias for stderr from stdio.h. */ - #define myStderr 0 - /** Defines an alias for stdout from stdio.h. */ - #define myStdout 0 -#endif - - -#include -#include - - -/** Defines symbols for global return values. \n - * Important: All return values are assumed to be nonnegative! */ -enum returnValue -{ -TERMINAL_LIST_ELEMENT = -1, /**< Terminal list element, internal usage only! */ -/* miscellaneous */ -SUCCESSFUL_RETURN = 0, /**< Successful return. */ -RET_DIV_BY_ZERO, /**< Division by zero. */ -RET_INDEX_OUT_OF_BOUNDS, /**< Index out of bounds. */ -RET_INVALID_ARGUMENTS, /**< At least one of the arguments is invalid. */ -RET_ERROR_UNDEFINED, /**< Error number undefined. */ -RET_WARNING_UNDEFINED, /**< Warning number undefined. */ -RET_INFO_UNDEFINED, /**< Info number undefined. */ -RET_EWI_UNDEFINED, /**< Error/warning/info number undefined. */ -RET_AVAILABLE_WITH_LINUX_ONLY, /**< This function is available under Linux only. */ -RET_UNKNOWN_BUG, /**< The error occured is not yet known. */ -RET_PRINTLEVEL_CHANGED, /**< 10 Print level changed. */ -RET_NOT_YET_IMPLEMENTED, /**< Requested function is not yet implemented in this version of qpOASES. */ -/* Indexlist */ -RET_INDEXLIST_MUST_BE_REORDERD, /**< Index list has to be reordered. */ -RET_INDEXLIST_EXCEEDS_MAX_LENGTH, /**< Index list exceeds its maximal physical length. */ -RET_INDEXLIST_CORRUPTED, /**< Index list corrupted. */ -RET_INDEXLIST_OUTOFBOUNDS, /**< Physical index is out of bounds. */ -RET_INDEXLIST_ADD_FAILED, /**< Adding indices from another index set failed. */ -RET_INDEXLIST_INTERSECT_FAILED, /**< Intersection with another index set failed. */ -/* SubjectTo / Bounds / Constraints */ -RET_INDEX_ALREADY_OF_DESIRED_STATUS, /**< Index is already of desired status. */ -RET_ADDINDEX_FAILED, /**< Cannot swap between different indexsets. */ -RET_SWAPINDEX_FAILED, /**< 20 Adding index to index set failed. */ -RET_NOTHING_TO_DO, /**< Nothing to do. */ -RET_SETUP_BOUND_FAILED, /**< Setting up bound index failed. */ -RET_SETUP_CONSTRAINT_FAILED, /**< Setting up constraint index failed. */ -RET_MOVING_BOUND_FAILED, /**< Moving bound between index sets failed. */ -RET_MOVING_CONSTRAINT_FAILED, /**< Moving constraint between index sets failed. */ -/* QProblem */ -RET_QP_ALREADY_INITIALISED, /**< QProblem has already been initialised. */ -RET_NO_INIT_WITH_STANDARD_SOLVER, /**< Initialisation via extern QP solver is not yet implemented. */ -RET_RESET_FAILED, /**< Reset failed. */ -RET_INIT_FAILED, /**< Initialisation failed. */ -RET_INIT_FAILED_TQ, /**< 30 Initialisation failed due to TQ factorisation. */ -RET_INIT_FAILED_CHOLESKY, /**< Initialisation failed due to Cholesky decomposition. */ -RET_INIT_FAILED_HOTSTART, /**< Initialisation failed! QP could not be solved! */ -RET_INIT_FAILED_INFEASIBILITY, /**< Initial QP could not be solved due to infeasibility! */ -RET_INIT_FAILED_UNBOUNDEDNESS, /**< Initial QP could not be solved due to unboundedness! */ -RET_INIT_SUCCESSFUL, /**< Initialisation done. */ -RET_OBTAINING_WORKINGSET_FAILED, /**< Failed to obtain working set for auxiliary QP. */ -RET_SETUP_WORKINGSET_FAILED, /**< Failed to setup working set for auxiliary QP. */ -RET_SETUP_AUXILIARYQP_FAILED, /**< Failed to setup auxiliary QP for initialised homotopy. */ -RET_NO_EXTERN_SOLVER, /**< No extern QP solver available. */ -RET_QP_UNBOUNDED, /**< 40 QP is unbounded. */ -RET_QP_INFEASIBLE, /**< QP is infeasible. */ -RET_QP_NOT_SOLVED, /**< Problems occured while solving QP with standard solver. */ -RET_QP_SOLVED, /**< QP successfully solved. */ -RET_UNABLE_TO_SOLVE_QP, /**< Problems occured while solving QP. */ -RET_INITIALISATION_STARTED, /**< Starting problem initialisation. */ -RET_HOTSTART_FAILED, /**< Unable to perform homotopy due to internal error. */ -RET_HOTSTART_FAILED_TO_INIT, /**< Unable to initialise problem. */ -RET_HOTSTART_FAILED_AS_QP_NOT_INITIALISED, /**< Unable to perform homotopy as previous QP is not solved. */ -RET_ITERATION_STARTED, /**< Iteration... */ -RET_SHIFT_DETERMINATION_FAILED, /**< 50 Determination of shift of the QP data failed. */ -RET_STEPDIRECTION_DETERMINATION_FAILED, /**< Determination of step direction failed. */ -RET_STEPLENGTH_DETERMINATION_FAILED, /**< Determination of step direction failed. */ -RET_OPTIMAL_SOLUTION_FOUND, /**< Optimal solution of neighbouring QP found. */ -RET_HOMOTOPY_STEP_FAILED, /**< Unable to perform homotopy step. */ -RET_HOTSTART_STOPPED_INFEASIBILITY, /**< Premature homotopy termination because QP is infeasible. */ -RET_HOTSTART_STOPPED_UNBOUNDEDNESS, /**< Premature homotopy termination because QP is unbounded. */ -RET_WORKINGSET_UPDATE_FAILED, /**< Unable to update working sets according to initial guesses. */ -RET_MAX_NWSR_REACHED, /**< Maximum number of working set recalculations performed. */ -RET_CONSTRAINTS_NOT_SPECIFIED, /**< Problem does comprise constraints! You also have to specify new constraints' bounds. */ -RET_INVALID_FACTORISATION_FLAG, /**< 60 Invalid factorisation flag. */ -RET_UNABLE_TO_SAVE_QPDATA, /**< Unable to save QP data. */ -RET_STEPDIRECTION_FAILED_TQ, /**< Abnormal termination due to TQ factorisation. */ -RET_STEPDIRECTION_FAILED_CHOLESKY, /**< Abnormal termination due to Cholesky factorisation. */ -RET_CYCLING_DETECTED, /**< Cycling detected. */ -RET_CYCLING_NOT_RESOLVED, /**< Cycling cannot be resolved, QP probably infeasible. */ -RET_CYCLING_RESOLVED, /**< Cycling probably resolved. */ -RET_STEPSIZE, /**< For displaying performed stepsize. */ -RET_STEPSIZE_NONPOSITIVE, /**< For displaying non-positive stepsize. */ -RET_SETUPSUBJECTTOTYPE_FAILED, /**< Setup of SubjectToTypes failed. */ -RET_ADDCONSTRAINT_FAILED, /**< 70 Addition of constraint to working set failed. */ -RET_ADDCONSTRAINT_FAILED_INFEASIBILITY, /**< Addition of constraint to working set failed (due to QP infeasibility). */ -RET_ADDBOUND_FAILED, /**< Addition of bound to working set failed. */ -RET_ADDBOUND_FAILED_INFEASIBILITY, /**< Addition of bound to working set failed (due to QP infeasibility). */ -RET_REMOVECONSTRAINT_FAILED, /**< Removal of constraint from working set failed. */ -RET_REMOVEBOUND_FAILED, /**< Removal of bound from working set failed. */ -RET_REMOVE_FROM_ACTIVESET, /**< Removing from active set... */ -RET_ADD_TO_ACTIVESET, /**< Adding to active set... */ -RET_REMOVE_FROM_ACTIVESET_FAILED, /**< Removing from active set failed. */ -RET_ADD_TO_ACTIVESET_FAILED, /**< Adding to active set failed. */ -RET_CONSTRAINT_ALREADY_ACTIVE, /**< 80 Constraint is already active. */ -RET_ALL_CONSTRAINTS_ACTIVE, /**< All constraints are active, no further constraint can be added. */ -RET_LINEARLY_DEPENDENT, /**< New bound/constraint is linearly dependent. */ -RET_LINEARLY_INDEPENDENT, /**< New bound/constraint is linearly independent. */ -RET_LI_RESOLVED, /**< Linear independence of active contraint matrix successfully resolved. */ -RET_ENSURELI_FAILED, /**< Failed to ensure linear indepence of active contraint matrix. */ -RET_ENSURELI_FAILED_TQ, /**< Abnormal termination due to TQ factorisation. */ -RET_ENSURELI_FAILED_NOINDEX, /**< No index found, QP probably infeasible. */ -RET_ENSURELI_FAILED_CYCLING, /**< Cycling detected, QP probably infeasible. */ -RET_BOUND_ALREADY_ACTIVE, /**< Bound is already active. */ -RET_ALL_BOUNDS_ACTIVE, /**< 90 All bounds are active, no further bound can be added. */ -RET_CONSTRAINT_NOT_ACTIVE, /**< Constraint is not active. */ -RET_BOUND_NOT_ACTIVE, /**< Bound is not active. */ -RET_HESSIAN_NOT_SPD, /**< Projected Hessian matrix not positive definite. */ -RET_MATRIX_SHIFT_FAILED, /**< Unable to update matrices or to transform vectors. */ -RET_MATRIX_FACTORISATION_FAILED, /**< Unable to calculate new matrix factorisations. */ -RET_PRINT_ITERATION_FAILED, /**< Unable to print information on current iteration. */ -RET_NO_GLOBAL_MESSAGE_OUTPUTFILE, /**< No global message output file initialised. */ -/* Utils */ -RET_UNABLE_TO_OPEN_FILE, /**< Unable to open file. */ -RET_UNABLE_TO_WRITE_FILE, /**< Unable to write into file. */ -RET_UNABLE_TO_READ_FILE, /**< 100 Unable to read from file. */ -RET_FILEDATA_INCONSISTENT, /**< File contains inconsistent data. */ -/* SolutionAnalysis */ -RET_NO_SOLUTION, /**< QP solution does not satisfy KKT optimality conditions. */ -RET_INACCURATE_SOLUTION /**< KKT optimality conditions not satisfied to sufficient accuracy. */ -}; - - - -/** This class handles all kinds of messages (errors, warnings, infos) initiated - * by qpOASES modules and stores the correspoding global preferences. - * - * \author Hans Joachim Ferreau (special thanks to Leonard Wirsching) - * \version 1.3embedded - * \date 2007-2008 - */ -class MessageHandling -{ - /* - * INTERNAL DATA STRUCTURES - */ - public: - /** Data structure for entries in global message list. */ - typedef struct { - returnValue key; /**< Global return value. */ - const char* data; /**< Corresponding message. */ - VisibilityStatus globalVisibilityStatus; /**< Determines if message can be printed. - * If this value is set to VS_HIDDEN, no message is printed! */ - } ReturnValueList; - - - /* - * PUBLIC MEMBER FUNCTIONS - */ - public: - /** Default constructor. */ - MessageHandling( ); - - /** Constructor which takes the desired output file. */ - MessageHandling( myFILE* _outputFile /**< Output file. */ - ); - - /** Constructor which takes the desired visibility states. */ - MessageHandling( VisibilityStatus _errorVisibility, /**< Visibility status for error messages. */ - VisibilityStatus _warningVisibility,/**< Visibility status for warning messages. */ - VisibilityStatus _infoVisibility /**< Visibility status for info messages. */ - ); - - /** Constructor which takes the desired output file and desired visibility states. */ - MessageHandling( myFILE* _outputFile, /**< Output file. */ - VisibilityStatus _errorVisibility, /**< Visibility status for error messages. */ - VisibilityStatus _warningVisibility,/**< Visibility status for warning messages. */ - VisibilityStatus _infoVisibility /**< Visibility status for info messages. */ - ); - - /** Copy constructor (deep copy). */ - MessageHandling( const MessageHandling& rhs /**< Rhs object. */ - ); - - /** Destructor. */ - ~MessageHandling( ); - - /** Assignment operator (deep copy). */ - MessageHandling& operator=( const MessageHandling& rhs /**< Rhs object. */ - ); - - - /** Prints an error message(a simplified macro THROWERROR is also provided). \n - * Errors are definied as abnormal events which cause an immediate termination of the current (sub) function. - * Errors of a sub function should be commented by the calling function by means of a warning message - * (if this error does not cause an error of the calling function, either)! - * \return Error number returned by sub function call - */ - returnValue throwError( - returnValue Enumber, /**< Error number returned by sub function call. */ - const char* additionaltext, /**< Additional error text (0, if none). */ - const char* functionname, /**< Name of function which caused the error. */ - const char* filename, /**< Name of file which caused the error. */ - const unsigned long linenumber, /**< Number of line which caused the error.incompatible binary file */ - VisibilityStatus localVisibilityStatus /**< Determines (locally) if error message can be printed to myStderr. - * If GLOBAL visibility status of the message is set to VS_HIDDEN, - * no message is printed, anyway! */ - ); - - /** Prints a warning message (a simplified macro THROWWARNING is also provided). - * Warnings are definied as abnormal events which does NOT cause an immediate termination of the current (sub) function. - * \return Warning number returned by sub function call - */ - returnValue throwWarning( - returnValue Wnumber, /**< Warning number returned by sub function call. */ - const char* additionaltext, /**< Additional warning text (0, if none). */ - const char* functionname, /**< Name of function which caused the warning. */ - const char* filename, /**< Name of file which caused the warning. */ - const unsigned long linenumber, /**< Number of line which caused the warning. */ - VisibilityStatus localVisibilityStatus /**< Determines (locally) if warning message can be printed to myStderr. - * If GLOBAL visibility status of the message is set to VS_HIDDEN, - * no message is printed, anyway! */ - ); - - /** Prints a info message (a simplified macro THROWINFO is also provided). - * \return Info number returned by sub function call - */ - returnValue throwInfo( - returnValue Inumber, /**< Info number returned by sub function call. */ - const char* additionaltext, /**< Additional warning text (0, if none). */ - const char* functionname, /**< Name of function which submitted the info. */ - const char* filename, /**< Name of file which submitted the info. */ - const unsigned long linenumber, /**< Number of line which submitted the info. */ - VisibilityStatus localVisibilityStatus /**< Determines (locally) if info message can be printed to myStderr. - * If GLOBAL visibility status of the message is set to VS_HIDDEN, - * no message is printed, anyway! */ - ); - - - /** Resets all preferences to default values. - * \return SUCCESSFUL_RETURN */ - returnValue reset( ); - - - /** Prints a complete list of all messages to output file. - * \return SUCCESSFUL_RETURN */ - returnValue listAllMessages( ); - - - /** Returns visibility status for error messages. - * \return Visibility status for error messages. */ - inline VisibilityStatus getErrorVisibilityStatus( ) const; - - /** Returns visibility status for warning messages. - * \return Visibility status for warning messages. */ - inline VisibilityStatus getWarningVisibilityStatus( ) const; - - /** Returns visibility status for info messages. - * \return Visibility status for info messages. */ - inline VisibilityStatus getInfoVisibilityStatus( ) const; - - /** Returns pointer to output file. - * \return Pointer to output file. */ - inline myFILE* getOutputFile( ) const; - - /** Returns error count value. - * \return Error count value. */ - inline int getErrorCount( ) const; - - - /** Changes visibility status for error messages. */ - inline void setErrorVisibilityStatus( VisibilityStatus _errorVisibility /**< New visibility status for error messages. */ - ); - - /** Changes visibility status for warning messages. */ - inline void setWarningVisibilityStatus( VisibilityStatus _warningVisibility /**< New visibility status for warning messages. */ - ); - - /** Changes visibility status for info messages. */ - inline void setInfoVisibilityStatus( VisibilityStatus _infoVisibility /**< New visibility status for info messages. */ - ); - - /** Changes output file for messages. */ - inline void setOutputFile( myFILE* _outputFile /**< New output file for messages. */ - ); - - /** Changes error count. - * \return SUCCESSFUL_RETURN \n - * RET_INVALID_ARGUMENT */ - inline returnValue setErrorCount( int _errorCount /**< New error count value. */ - ); - - /** Return the error code string. */ - static const char* getErrorString(int error); - - /* - * PROTECTED MEMBER FUNCTIONS - */ - protected: - /** Prints a info message to myStderr (auxiliary function). - * \return Error/warning/info number returned by sub function call - */ - returnValue throwMessage( - returnValue RETnumber, /**< Error/warning/info number returned by sub function call. */ - const char* additionaltext, /**< Additional warning text (0, if none). */ - const char* functionname, /**< Name of function which caused the error/warning/info. */ - const char* filename, /**< Name of file which caused the error/warning/info. */ - const unsigned long linenumber, /**< Number of line which caused the error/warning/info. */ - VisibilityStatus localVisibilityStatus, /**< Determines (locally) if info message can be printed to myStderr. - * If GLOBAL visibility status of the message is set to VS_HIDDEN, - * no message is printed, anyway! */ - const char* RETstring /**< Leading string of error/warning/info message. */ - ); - - - /* - * PROTECTED MEMBER VARIABLES - */ - protected: - VisibilityStatus errorVisibility; /**< Error messages visible? */ - VisibilityStatus warningVisibility; /**< Warning messages visible? */ - VisibilityStatus infoVisibility; /**< Info messages visible? */ - - myFILE* outputFile; /**< Output file for messages. */ - - int errorCount; /**< Counts number of errors (for nicer output only). */ -}; - - -#ifndef __FUNCTION__ - /** Ensures that __FUNCTION__ macro is defined. */ - #define __FUNCTION__ 0 -#endif - -#ifndef __FILE__ - /** Ensures that __FILE__ macro is defined. */ - #define __FILE__ 0 -#endif - -#ifndef __LINE__ - /** Ensures that __LINE__ macro is defined. */ - #define __LINE__ 0 -#endif - - -/** Short version of throwError with default values, only returnValue is needed */ -#define THROWERROR(retval) ( getGlobalMessageHandler( )->throwError((retval),0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE) ) - -/** Short version of throwWarning with default values, only returnValue is needed */ -#define THROWWARNING(retval) ( getGlobalMessageHandler( )->throwWarning((retval),0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE) ) - -/** Short version of throwInfo with default values, only returnValue is needed */ -#define THROWINFO(retval) ( getGlobalMessageHandler( )->throwInfo((retval),0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE) ) - - -/** Returns a pointer to global message handler. - * \return Pointer to global message handler. - */ -MessageHandling* getGlobalMessageHandler( ); - - -#include - -#endif /* QPOASES_MESSAGEHANDLING_HPP */ - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file INCLUDE/MessageHandling.hpp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Declaration of the MessageHandling class including global return values. + */ + + +#ifndef QPOASES_MESSAGEHANDLING_HPP +#define QPOASES_MESSAGEHANDLING_HPP + +// #define PC_DEBUG + +#ifdef PC_DEBUG + #include + + /** Defines an alias for FILE from stdio.h. */ + #define myFILE FILE + /** Defines an alias for stderr from stdio.h. */ + #define myStderr stderr + /** Defines an alias for stdout from stdio.h. */ + #define myStdout stdout +#else + /** Defines an alias for FILE from stdio.h. */ + #define myFILE int + /** Defines an alias for stderr from stdio.h. */ + #define myStderr 0 + /** Defines an alias for stdout from stdio.h. */ + #define myStdout 0 +#endif + + +#include +#include + + +/** Defines symbols for global return values. \n + * Important: All return values are assumed to be nonnegative! */ +enum returnValue +{ +TERMINAL_LIST_ELEMENT = -1, /**< Terminal list element, internal usage only! */ +/* miscellaneous */ +SUCCESSFUL_RETURN = 0, /**< Successful return. */ +RET_DIV_BY_ZERO, /**< Division by zero. */ +RET_INDEX_OUT_OF_BOUNDS, /**< Index out of bounds. */ +RET_INVALID_ARGUMENTS, /**< At least one of the arguments is invalid. */ +RET_ERROR_UNDEFINED, /**< Error number undefined. */ +RET_WARNING_UNDEFINED, /**< Warning number undefined. */ +RET_INFO_UNDEFINED, /**< Info number undefined. */ +RET_EWI_UNDEFINED, /**< Error/warning/info number undefined. */ +RET_AVAILABLE_WITH_LINUX_ONLY, /**< This function is available under Linux only. */ +RET_UNKNOWN_BUG, /**< The error occured is not yet known. */ +RET_PRINTLEVEL_CHANGED, /**< 10 Print level changed. */ +RET_NOT_YET_IMPLEMENTED, /**< Requested function is not yet implemented in this version of qpOASES. */ +/* Indexlist */ +RET_INDEXLIST_MUST_BE_REORDERD, /**< Index list has to be reordered. */ +RET_INDEXLIST_EXCEEDS_MAX_LENGTH, /**< Index list exceeds its maximal physical length. */ +RET_INDEXLIST_CORRUPTED, /**< Index list corrupted. */ +RET_INDEXLIST_OUTOFBOUNDS, /**< Physical index is out of bounds. */ +RET_INDEXLIST_ADD_FAILED, /**< Adding indices from another index set failed. */ +RET_INDEXLIST_INTERSECT_FAILED, /**< Intersection with another index set failed. */ +/* SubjectTo / Bounds / Constraints */ +RET_INDEX_ALREADY_OF_DESIRED_STATUS, /**< Index is already of desired status. */ +RET_ADDINDEX_FAILED, /**< Cannot swap between different indexsets. */ +RET_SWAPINDEX_FAILED, /**< 20 Adding index to index set failed. */ +RET_NOTHING_TO_DO, /**< Nothing to do. */ +RET_SETUP_BOUND_FAILED, /**< Setting up bound index failed. */ +RET_SETUP_CONSTRAINT_FAILED, /**< Setting up constraint index failed. */ +RET_MOVING_BOUND_FAILED, /**< Moving bound between index sets failed. */ +RET_MOVING_CONSTRAINT_FAILED, /**< Moving constraint between index sets failed. */ +/* QProblem */ +RET_QP_ALREADY_INITIALISED, /**< QProblem has already been initialised. */ +RET_NO_INIT_WITH_STANDARD_SOLVER, /**< Initialisation via extern QP solver is not yet implemented. */ +RET_RESET_FAILED, /**< Reset failed. */ +RET_INIT_FAILED, /**< Initialisation failed. */ +RET_INIT_FAILED_TQ, /**< 30 Initialisation failed due to TQ factorisation. */ +RET_INIT_FAILED_CHOLESKY, /**< Initialisation failed due to Cholesky decomposition. */ +RET_INIT_FAILED_HOTSTART, /**< Initialisation failed! QP could not be solved! */ +RET_INIT_FAILED_INFEASIBILITY, /**< Initial QP could not be solved due to infeasibility! */ +RET_INIT_FAILED_UNBOUNDEDNESS, /**< Initial QP could not be solved due to unboundedness! */ +RET_INIT_SUCCESSFUL, /**< Initialisation done. */ +RET_OBTAINING_WORKINGSET_FAILED, /**< Failed to obtain working set for auxiliary QP. */ +RET_SETUP_WORKINGSET_FAILED, /**< Failed to setup working set for auxiliary QP. */ +RET_SETUP_AUXILIARYQP_FAILED, /**< Failed to setup auxiliary QP for initialised homotopy. */ +RET_NO_EXTERN_SOLVER, /**< No extern QP solver available. */ +RET_QP_UNBOUNDED, /**< 40 QP is unbounded. */ +RET_QP_INFEASIBLE, /**< QP is infeasible. */ +RET_QP_NOT_SOLVED, /**< Problems occured while solving QP with standard solver. */ +RET_QP_SOLVED, /**< QP successfully solved. */ +RET_UNABLE_TO_SOLVE_QP, /**< Problems occured while solving QP. */ +RET_INITIALISATION_STARTED, /**< Starting problem initialisation. */ +RET_HOTSTART_FAILED, /**< Unable to perform homotopy due to internal error. */ +RET_HOTSTART_FAILED_TO_INIT, /**< Unable to initialise problem. */ +RET_HOTSTART_FAILED_AS_QP_NOT_INITIALISED, /**< Unable to perform homotopy as previous QP is not solved. */ +RET_ITERATION_STARTED, /**< Iteration... */ +RET_SHIFT_DETERMINATION_FAILED, /**< 50 Determination of shift of the QP data failed. */ +RET_STEPDIRECTION_DETERMINATION_FAILED, /**< Determination of step direction failed. */ +RET_STEPLENGTH_DETERMINATION_FAILED, /**< Determination of step direction failed. */ +RET_OPTIMAL_SOLUTION_FOUND, /**< Optimal solution of neighbouring QP found. */ +RET_HOMOTOPY_STEP_FAILED, /**< Unable to perform homotopy step. */ +RET_HOTSTART_STOPPED_INFEASIBILITY, /**< Premature homotopy termination because QP is infeasible. */ +RET_HOTSTART_STOPPED_UNBOUNDEDNESS, /**< Premature homotopy termination because QP is unbounded. */ +RET_WORKINGSET_UPDATE_FAILED, /**< Unable to update working sets according to initial guesses. */ +RET_MAX_NWSR_REACHED, /**< Maximum number of working set recalculations performed. */ +RET_CONSTRAINTS_NOT_SPECIFIED, /**< Problem does comprise constraints! You also have to specify new constraints' bounds. */ +RET_INVALID_FACTORISATION_FLAG, /**< 60 Invalid factorisation flag. */ +RET_UNABLE_TO_SAVE_QPDATA, /**< Unable to save QP data. */ +RET_STEPDIRECTION_FAILED_TQ, /**< Abnormal termination due to TQ factorisation. */ +RET_STEPDIRECTION_FAILED_CHOLESKY, /**< Abnormal termination due to Cholesky factorisation. */ +RET_CYCLING_DETECTED, /**< Cycling detected. */ +RET_CYCLING_NOT_RESOLVED, /**< Cycling cannot be resolved, QP probably infeasible. */ +RET_CYCLING_RESOLVED, /**< Cycling probably resolved. */ +RET_STEPSIZE, /**< For displaying performed stepsize. */ +RET_STEPSIZE_NONPOSITIVE, /**< For displaying non-positive stepsize. */ +RET_SETUPSUBJECTTOTYPE_FAILED, /**< Setup of SubjectToTypes failed. */ +RET_ADDCONSTRAINT_FAILED, /**< 70 Addition of constraint to working set failed. */ +RET_ADDCONSTRAINT_FAILED_INFEASIBILITY, /**< Addition of constraint to working set failed (due to QP infeasibility). */ +RET_ADDBOUND_FAILED, /**< Addition of bound to working set failed. */ +RET_ADDBOUND_FAILED_INFEASIBILITY, /**< Addition of bound to working set failed (due to QP infeasibility). */ +RET_REMOVECONSTRAINT_FAILED, /**< Removal of constraint from working set failed. */ +RET_REMOVEBOUND_FAILED, /**< Removal of bound from working set failed. */ +RET_REMOVE_FROM_ACTIVESET, /**< Removing from active set... */ +RET_ADD_TO_ACTIVESET, /**< Adding to active set... */ +RET_REMOVE_FROM_ACTIVESET_FAILED, /**< Removing from active set failed. */ +RET_ADD_TO_ACTIVESET_FAILED, /**< Adding to active set failed. */ +RET_CONSTRAINT_ALREADY_ACTIVE, /**< 80 Constraint is already active. */ +RET_ALL_CONSTRAINTS_ACTIVE, /**< All constraints are active, no further constraint can be added. */ +RET_LINEARLY_DEPENDENT, /**< New bound/constraint is linearly dependent. */ +RET_LINEARLY_INDEPENDENT, /**< New bound/constraint is linearly independent. */ +RET_LI_RESOLVED, /**< Linear independence of active contraint matrix successfully resolved. */ +RET_ENSURELI_FAILED, /**< Failed to ensure linear indepence of active contraint matrix. */ +RET_ENSURELI_FAILED_TQ, /**< Abnormal termination due to TQ factorisation. */ +RET_ENSURELI_FAILED_NOINDEX, /**< No index found, QP probably infeasible. */ +RET_ENSURELI_FAILED_CYCLING, /**< Cycling detected, QP probably infeasible. */ +RET_BOUND_ALREADY_ACTIVE, /**< Bound is already active. */ +RET_ALL_BOUNDS_ACTIVE, /**< 90 All bounds are active, no further bound can be added. */ +RET_CONSTRAINT_NOT_ACTIVE, /**< Constraint is not active. */ +RET_BOUND_NOT_ACTIVE, /**< Bound is not active. */ +RET_HESSIAN_NOT_SPD, /**< Projected Hessian matrix not positive definite. */ +RET_MATRIX_SHIFT_FAILED, /**< Unable to update matrices or to transform vectors. */ +RET_MATRIX_FACTORISATION_FAILED, /**< Unable to calculate new matrix factorisations. */ +RET_PRINT_ITERATION_FAILED, /**< Unable to print information on current iteration. */ +RET_NO_GLOBAL_MESSAGE_OUTPUTFILE, /**< No global message output file initialised. */ +/* Utils */ +RET_UNABLE_TO_OPEN_FILE, /**< Unable to open file. */ +RET_UNABLE_TO_WRITE_FILE, /**< Unable to write into file. */ +RET_UNABLE_TO_READ_FILE, /**< 100 Unable to read from file. */ +RET_FILEDATA_INCONSISTENT, /**< File contains inconsistent data. */ +/* SolutionAnalysis */ +RET_NO_SOLUTION, /**< QP solution does not satisfy KKT optimality conditions. */ +RET_INACCURATE_SOLUTION /**< KKT optimality conditions not satisfied to sufficient accuracy. */ +}; + + + +/** This class handles all kinds of messages (errors, warnings, infos) initiated + * by qpOASES modules and stores the correspoding global preferences. + * + * \author Hans Joachim Ferreau (special thanks to Leonard Wirsching) + * \version 1.3embedded + * \date 2007-2008 + */ +class MessageHandling +{ + /* + * INTERNAL DATA STRUCTURES + */ + public: + /** Data structure for entries in global message list. */ + typedef struct { + returnValue key; /**< Global return value. */ + const char* data; /**< Corresponding message. */ + VisibilityStatus globalVisibilityStatus; /**< Determines if message can be printed. + * If this value is set to VS_HIDDEN, no message is printed! */ + } ReturnValueList; + + + /* + * PUBLIC MEMBER FUNCTIONS + */ + public: + /** Default constructor. */ + MessageHandling( ); + + /** Constructor which takes the desired output file. */ + MessageHandling( myFILE* _outputFile /**< Output file. */ + ); + + /** Constructor which takes the desired visibility states. */ + MessageHandling( VisibilityStatus _errorVisibility, /**< Visibility status for error messages. */ + VisibilityStatus _warningVisibility,/**< Visibility status for warning messages. */ + VisibilityStatus _infoVisibility /**< Visibility status for info messages. */ + ); + + /** Constructor which takes the desired output file and desired visibility states. */ + MessageHandling( myFILE* _outputFile, /**< Output file. */ + VisibilityStatus _errorVisibility, /**< Visibility status for error messages. */ + VisibilityStatus _warningVisibility,/**< Visibility status for warning messages. */ + VisibilityStatus _infoVisibility /**< Visibility status for info messages. */ + ); + + /** Copy constructor (deep copy). */ + MessageHandling( const MessageHandling& rhs /**< Rhs object. */ + ); + + /** Destructor. */ + ~MessageHandling( ); + + /** Assignment operator (deep copy). */ + MessageHandling& operator=( const MessageHandling& rhs /**< Rhs object. */ + ); + + + /** Prints an error message(a simplified macro THROWERROR is also provided). \n + * Errors are definied as abnormal events which cause an immediate termination of the current (sub) function. + * Errors of a sub function should be commented by the calling function by means of a warning message + * (if this error does not cause an error of the calling function, either)! + * \return Error number returned by sub function call + */ + returnValue throwError( + returnValue Enumber, /**< Error number returned by sub function call. */ + const char* additionaltext, /**< Additional error text (0, if none). */ + const char* functionname, /**< Name of function which caused the error. */ + const char* filename, /**< Name of file which caused the error. */ + const unsigned long linenumber, /**< Number of line which caused the error.incompatible binary file */ + VisibilityStatus localVisibilityStatus /**< Determines (locally) if error message can be printed to myStderr. + * If GLOBAL visibility status of the message is set to VS_HIDDEN, + * no message is printed, anyway! */ + ); + + /** Prints a warning message (a simplified macro THROWWARNING is also provided). + * Warnings are definied as abnormal events which does NOT cause an immediate termination of the current (sub) function. + * \return Warning number returned by sub function call + */ + returnValue throwWarning( + returnValue Wnumber, /**< Warning number returned by sub function call. */ + const char* additionaltext, /**< Additional warning text (0, if none). */ + const char* functionname, /**< Name of function which caused the warning. */ + const char* filename, /**< Name of file which caused the warning. */ + const unsigned long linenumber, /**< Number of line which caused the warning. */ + VisibilityStatus localVisibilityStatus /**< Determines (locally) if warning message can be printed to myStderr. + * If GLOBAL visibility status of the message is set to VS_HIDDEN, + * no message is printed, anyway! */ + ); + + /** Prints a info message (a simplified macro THROWINFO is also provided). + * \return Info number returned by sub function call + */ + returnValue throwInfo( + returnValue Inumber, /**< Info number returned by sub function call. */ + const char* additionaltext, /**< Additional warning text (0, if none). */ + const char* functionname, /**< Name of function which submitted the info. */ + const char* filename, /**< Name of file which submitted the info. */ + const unsigned long linenumber, /**< Number of line which submitted the info. */ + VisibilityStatus localVisibilityStatus /**< Determines (locally) if info message can be printed to myStderr. + * If GLOBAL visibility status of the message is set to VS_HIDDEN, + * no message is printed, anyway! */ + ); + + + /** Resets all preferences to default values. + * \return SUCCESSFUL_RETURN */ + returnValue reset( ); + + + /** Prints a complete list of all messages to output file. + * \return SUCCESSFUL_RETURN */ + returnValue listAllMessages( ); + + + /** Returns visibility status for error messages. + * \return Visibility status for error messages. */ + inline VisibilityStatus getErrorVisibilityStatus( ) const; + + /** Returns visibility status for warning messages. + * \return Visibility status for warning messages. */ + inline VisibilityStatus getWarningVisibilityStatus( ) const; + + /** Returns visibility status for info messages. + * \return Visibility status for info messages. */ + inline VisibilityStatus getInfoVisibilityStatus( ) const; + + /** Returns pointer to output file. + * \return Pointer to output file. */ + inline myFILE* getOutputFile( ) const; + + /** Returns error count value. + * \return Error count value. */ + inline int getErrorCount( ) const; + + + /** Changes visibility status for error messages. */ + inline void setErrorVisibilityStatus( VisibilityStatus _errorVisibility /**< New visibility status for error messages. */ + ); + + /** Changes visibility status for warning messages. */ + inline void setWarningVisibilityStatus( VisibilityStatus _warningVisibility /**< New visibility status for warning messages. */ + ); + + /** Changes visibility status for info messages. */ + inline void setInfoVisibilityStatus( VisibilityStatus _infoVisibility /**< New visibility status for info messages. */ + ); + + /** Changes output file for messages. */ + inline void setOutputFile( myFILE* _outputFile /**< New output file for messages. */ + ); + + /** Changes error count. + * \return SUCCESSFUL_RETURN \n + * RET_INVALID_ARGUMENT */ + inline returnValue setErrorCount( int _errorCount /**< New error count value. */ + ); + + /** Return the error code string. */ + static const char* getErrorString(int error); + + /* + * PROTECTED MEMBER FUNCTIONS + */ + protected: + /** Prints a info message to myStderr (auxiliary function). + * \return Error/warning/info number returned by sub function call + */ + returnValue throwMessage( + returnValue RETnumber, /**< Error/warning/info number returned by sub function call. */ + const char* additionaltext, /**< Additional warning text (0, if none). */ + const char* functionname, /**< Name of function which caused the error/warning/info. */ + const char* filename, /**< Name of file which caused the error/warning/info. */ + const unsigned long linenumber, /**< Number of line which caused the error/warning/info. */ + VisibilityStatus localVisibilityStatus, /**< Determines (locally) if info message can be printed to myStderr. + * If GLOBAL visibility status of the message is set to VS_HIDDEN, + * no message is printed, anyway! */ + const char* RETstring /**< Leading string of error/warning/info message. */ + ); + + + /* + * PROTECTED MEMBER VARIABLES + */ + protected: + VisibilityStatus errorVisibility; /**< Error messages visible? */ + VisibilityStatus warningVisibility; /**< Warning messages visible? */ + VisibilityStatus infoVisibility; /**< Info messages visible? */ + + myFILE* outputFile; /**< Output file for messages. */ + + int errorCount; /**< Counts number of errors (for nicer output only). */ +}; + + +#ifndef __FUNCTION__ + /** Ensures that __FUNCTION__ macro is defined. */ + #define __FUNCTION__ 0 +#endif + +#ifndef __FILE__ + /** Ensures that __FILE__ macro is defined. */ + #define __FILE__ 0 +#endif + +#ifndef __LINE__ + /** Ensures that __LINE__ macro is defined. */ + #define __LINE__ 0 +#endif + + +/** Short version of throwError with default values, only returnValue is needed */ +#define THROWERROR(retval) ( getGlobalMessageHandler( )->throwError((retval),0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE) ) + +/** Short version of throwWarning with default values, only returnValue is needed */ +#define THROWWARNING(retval) ( getGlobalMessageHandler( )->throwWarning((retval),0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE) ) + +/** Short version of throwInfo with default values, only returnValue is needed */ +#define THROWINFO(retval) ( getGlobalMessageHandler( )->throwInfo((retval),0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE) ) + + +/** Returns a pointer to global message handler. + * \return Pointer to global message handler. + */ +MessageHandling* getGlobalMessageHandler( ); + + +#include + +#endif /* QPOASES_MESSAGEHANDLING_HPP */ + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/INCLUDE/QProblem.hpp b/phonelibs/qpoases/INCLUDE/QProblem.hpp index 68fc1af9c53a79..91dc43417542a5 100644 --- a/phonelibs/qpoases/INCLUDE/QProblem.hpp +++ b/phonelibs/qpoases/INCLUDE/QProblem.hpp @@ -1,666 +1,666 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/QProblem.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Declaration of the QProblem class which is able to use the newly - * developed online active set strategy for parametric quadratic programming. - */ - - - -#ifndef QPOASES_QPROBLEM_HPP -#define QPOASES_QPROBLEM_HPP - - -#include -#include -#include - - -/** A class for setting up and solving quadratic programs. The main feature is - * the possibily to use the newly developed online active set strategy for - * parametric quadratic programming. - * - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - */ -class QProblem : public QProblemB -{ - /* allow SolutionAnalysis class to access private members */ - friend class SolutionAnalysis; - - /* - * PUBLIC MEMBER FUNCTIONS - */ - public: - /** Default constructor. */ - QProblem( ); - - /** Constructor which takes the QP dimensions only. */ - QProblem( int _nV, /**< Number of variables. */ - int _nC /**< Number of constraints. */ - ); - - /** Copy constructor (deep copy). */ - QProblem( const QProblem& rhs /**< Rhs object. */ - ); - - /** Destructor. */ - ~QProblem( ); - - /** Assignment operator (deep copy). */ - QProblem& operator=( const QProblem& rhs /**< Rhs object. */ - ); - - - /** Clears all data structures of QProblemB except for QP data. - * \return SUCCESSFUL_RETURN \n - RET_RESET_FAILED */ - returnValue reset( ); - - - /** Initialises a QProblem with given QP data and solves it - * using an initial homotopy with empty working set (at most nWSR iterations). - * \return SUCCESSFUL_RETURN \n - RET_INIT_FAILED \n - RET_INIT_FAILED_CHOLESKY \n - RET_INIT_FAILED_TQ \n - RET_INIT_FAILED_HOTSTART \n - RET_INIT_FAILED_INFEASIBILITY \n - RET_INIT_FAILED_UNBOUNDEDNESS \n - RET_MAX_NWSR_REACHED \n - RET_INVALID_ARGUMENTS \n - RET_INACCURATE_SOLUTION \n - RET_NO_SOLUTION */ - returnValue init( const real_t* const _H, /**< Hessian matrix. */ - const real_t* const _g, /**< Gradient vector. */ - const real_t* const _A, /**< Constraint matrix. */ - const real_t* const _lb, /**< Lower bound vector (on variables). \n - If no lower bounds exist, a NULL pointer can be passed. */ - const real_t* const _ub, /**< Upper bound vector (on variables). \n - If no upper bounds exist, a NULL pointer can be passed. */ - const real_t* const _lbA, /**< Lower constraints' bound vector. \n - If no lower constraints' bounds exist, a NULL pointer can be passed. */ - const real_t* const _ubA, /**< Upper constraints' bound vector. \n - If no lower constraints' bounds exist, a NULL pointer can be passed. */ - int& nWSR, /**< Input: Maximum number of working set recalculations when using initial homotopy. - Output: Number of performed working set recalculations. */ - const real_t* const yOpt = 0, /**< Initial guess for dual solution vector. */ - real_t* const cputime = 0 /**< Output: CPU time required to initialise QP. */ - ); - - - /** Initialises a QProblem with given QP data and solves it - * using an initial homotopy with empty working set (at most nWSR iterations). - * \return SUCCESSFUL_RETURN \n - RET_INIT_FAILED \n - RET_INIT_FAILED_CHOLESKY \n - RET_INIT_FAILED_TQ \n - RET_INIT_FAILED_HOTSTART \n - RET_INIT_FAILED_INFEASIBILITY \n - RET_INIT_FAILED_UNBOUNDEDNESS \n - RET_MAX_NWSR_REACHED \n - RET_INVALID_ARGUMENTS \n - RET_INACCURATE_SOLUTION \n - RET_NO_SOLUTION */ - returnValue init( const real_t* const _H, /**< Hessian matrix. */ - const real_t* const _R, /**< Cholesky factorization of the Hessian matrix. */ - const real_t* const _g, /**< Gradient vector. */ - const real_t* const _A, /**< Constraint matrix. */ - const real_t* const _lb, /**< Lower bound vector (on variables). \n - If no lower bounds exist, a NULL pointer can be passed. */ - const real_t* const _ub, /**< Upper bound vector (on variables). \n - If no upper bounds exist, a NULL pointer can be passed. */ - const real_t* const _lbA, /**< Lower constraints' bound vector. \n - If no lower constraints' bounds exist, a NULL pointer can be passed. */ - const real_t* const _ubA, /**< Upper constraints' bound vector. \n - If no lower constraints' bounds exist, a NULL pointer can be passed. */ - int& nWSR, /**< Input: Maximum number of working set recalculations when using initial homotopy. - Output: Number of performed working set recalculations. */ - const real_t* const yOpt = 0, /**< Initial guess for dual solution vector. */ - real_t* const cputime = 0 /**< Output: CPU time required to initialise QP. */ - ); - - - /** Solves QProblem using online active set strategy. - * \return SUCCESSFUL_RETURN \n - RET_MAX_NWSR_REACHED \n - RET_HOTSTART_FAILED_AS_QP_NOT_INITIALISED \n - RET_HOTSTART_FAILED \n - RET_SHIFT_DETERMINATION_FAILED \n - RET_STEPDIRECTION_DETERMINATION_FAILED \n - RET_STEPLENGTH_DETERMINATION_FAILED \n - RET_HOMOTOPY_STEP_FAILED \n - RET_HOTSTART_STOPPED_INFEASIBILITY \n - RET_HOTSTART_STOPPED_UNBOUNDEDNESS \n - RET_INACCURATE_SOLUTION \n - RET_NO_SOLUTION */ - returnValue hotstart( const real_t* const g_new, /**< Gradient of neighbouring QP to be solved. */ - const real_t* const lb_new, /**< Lower bounds of neighbouring QP to be solved. \n - If no lower bounds exist, a NULL pointer can be passed. */ - const real_t* const ub_new, /**< Upper bounds of neighbouring QP to be solved. \n - If no upper bounds exist, a NULL pointer can be passed. */ - const real_t* const lbA_new, /**< Lower constraints' bounds of neighbouring QP to be solved. \n - If no lower constraints' bounds exist, a NULL pointer can be passed. */ - const real_t* const ubA_new, /**< Upper constraints' bounds of neighbouring QP to be solved. \n - If no upper constraints' bounds exist, a NULL pointer can be passed. */ - int& nWSR, /**< Input: Maximum number of working set recalculations; \n - Output: Number of performed working set recalculations. */ - real_t* const cputime /**< Output: CPU time required to solve QP (or to perform nWSR iterations). */ - ); - - - /** Returns constraint matrix of the QP (deep copy). - * \return SUCCESSFUL_RETURN */ - inline returnValue getA( real_t* const _A /**< Array of appropriate dimension for copying constraint matrix.*/ - ) const; - - /** Returns a single row of constraint matrix of the QP (deep copy). - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue getA( int number, /**< Number of entry to be returned. */ - real_t* const row /**< Array of appropriate dimension for copying (number)th constraint. */ - ) const; - - /** Returns lower constraints' bound vector of the QP (deep copy). - * \return SUCCESSFUL_RETURN */ - inline returnValue getLBA( real_t* const _lbA /**< Array of appropriate dimension for copying lower constraints' bound vector.*/ - ) const; - - /** Returns single entry of lower constraints' bound vector of the QP. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue getLBA( int number, /**< Number of entry to be returned. */ - real_t& value /**< Output: lbA[number].*/ - ) const; - - /** Returns upper constraints' bound vector of the QP (deep copy). - * \return SUCCESSFUL_RETURN */ - inline returnValue getUBA( real_t* const _ubA /**< Array of appropriate dimension for copying upper constraints' bound vector.*/ - ) const; - - /** Returns single entry of upper constraints' bound vector of the QP. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue getUBA( int number, /**< Number of entry to be returned. */ - real_t& value /**< Output: ubA[number].*/ - ) const; - - - /** Returns current constraints object of the QP (deep copy). - * \return SUCCESSFUL_RETURN */ - inline returnValue getConstraints( Constraints* const _constraints /** Output: Constraints object. */ - ) const; - - - /** Returns the number of constraints. - * \return Number of constraints. */ - inline int getNC( ) const; - - /** Returns the number of (implicitly defined) equality constraints. - * \return Number of (implicitly defined) equality constraints. */ - inline int getNEC( ) const; - - /** Returns the number of active constraints. - * \return Number of active constraints. */ - inline int getNAC( ); - - /** Returns the number of inactive constraints. - * \return Number of inactive constraints. */ - inline int getNIAC( ); - - /** Returns the dimension of null space. - * \return Dimension of null space. */ - int getNZ( ); - - - /** Returns the dual solution vector (deep copy). - * \return SUCCESSFUL_RETURN \n - RET_QP_NOT_SOLVED */ - returnValue getDualSolution( real_t* const yOpt /**< Output: Dual solution vector (if QP has been solved). */ - ) const; - - - /* - * PROTECTED MEMBER FUNCTIONS - */ - protected: - /** Determines type of constraints and bounds (i.e. implicitly fixed, unbounded etc.). - * \return SUCCESSFUL_RETURN \n - RET_SETUPSUBJECTTOTYPE_FAILED */ - returnValue setupSubjectToType( ); - - /** Computes the Cholesky decomposition R of the projected Hessian (i.e. R^T*R = Z^T*H*Z). - * \return SUCCESSFUL_RETURN \n - * RET_INDEXLIST_CORRUPTED */ - returnValue setupCholeskyDecompositionProjected( ); - - /** Initialises TQ factorisation of A (i.e. A*Q = [0 T]) if NO constraint is active. - * \return SUCCESSFUL_RETURN \n - RET_INDEXLIST_CORRUPTED */ - returnValue setupTQfactorisation( ); - - - /** Solves a QProblem whose QP data is assumed to be stored in the member variables. - * A guess for its primal/dual optimal solution vectors and the corresponding - * working sets of bounds and constraints can be provided. - * \return SUCCESSFUL_RETURN \n - RET_INIT_FAILED \n - RET_INIT_FAILED_CHOLESKY \n - RET_INIT_FAILED_TQ \n - RET_INIT_FAILED_HOTSTART \n - RET_INIT_FAILED_INFEASIBILITY \n - RET_INIT_FAILED_UNBOUNDEDNESS \n - RET_MAX_NWSR_REACHED */ - returnValue solveInitialQP( const real_t* const xOpt, /**< Optimal primal solution vector. - * A NULL pointer can be passed. */ - const real_t* const yOpt, /**< Optimal dual solution vector. - * A NULL pointer can be passed. */ - const Bounds* const guessedBounds, /**< Guessed working set of bounds for solution (xOpt,yOpt). - * A NULL pointer can be passed. */ - const Constraints* const guessedConstraints, /**< Optimal working set of constraints for solution (xOpt,yOpt). - * A NULL pointer can be passed. */ - int& nWSR, /**< Input: Maximum number of working set recalculations; \n - * Output: Number of performed working set recalculations. */ - real_t* const cputime /**< Output: CPU time required to solve QP (or to perform nWSR iterations). */ - ); - - /** Obtains the desired working set for the auxiliary initial QP in - * accordance with the user specifications - * (assumes that member AX has already been initialised!) - * \return SUCCESSFUL_RETURN \n - RET_OBTAINING_WORKINGSET_FAILED \n - RET_INVALID_ARGUMENTS */ - returnValue obtainAuxiliaryWorkingSet( const real_t* const xOpt, /**< Optimal primal solution vector. - * If a NULL pointer is passed, all entries are assumed to be zero. */ - const real_t* const yOpt, /**< Optimal dual solution vector. - * If a NULL pointer is passed, all entries are assumed to be zero. */ - const Bounds* const guessedBounds, /**< Guessed working set of bounds for solution (xOpt,yOpt). */ - const Constraints* const guessedConstraints, /**< Guessed working set for solution (xOpt,yOpt). */ - Bounds* auxiliaryBounds, /**< Input: Allocated bound object. \n - * Ouput: Working set of constraints for auxiliary QP. */ - Constraints* auxiliaryConstraints /**< Input: Allocated bound object. \n - * Ouput: Working set for auxiliary QP. */ - ) const; - - /** Setups bound and constraints data structures according to auxiliaryBounds/Constraints. - * (If the working set shall be setup afresh, make sure that - * bounds and constraints data structure have been resetted - * and the TQ factorisation has been initialised!) - * \return SUCCESSFUL_RETURN \n - RET_SETUP_WORKINGSET_FAILED \n - RET_INVALID_ARGUMENTS \n - RET_UNKNOWN BUG */ - returnValue setupAuxiliaryWorkingSet( const Bounds* const auxiliaryBounds, /**< Working set of bounds for auxiliary QP. */ - const Constraints* const auxiliaryConstraints, /**< Working set of constraints for auxiliary QP. */ - BooleanType setupAfresh /**< Flag indicating if given working set shall be - * setup afresh or by updating the current one. */ - ); - - /** Setups the optimal primal/dual solution of the auxiliary initial QP. - * \return SUCCESSFUL_RETURN */ - returnValue setupAuxiliaryQPsolution( const real_t* const xOpt, /**< Optimal primal solution vector. - * If a NULL pointer is passed, all entries are set to zero. */ - const real_t* const yOpt /**< Optimal dual solution vector. - * If a NULL pointer is passed, all entries are set to zero. */ - ); - - /** Setups gradient of the auxiliary initial QP for given - * optimal primal/dual solution and given initial working set - * (assumes that members X, Y and BOUNDS, CONSTRAINTS have already been initialised!). - * \return SUCCESSFUL_RETURN */ - returnValue setupAuxiliaryQPgradient( ); - - /** Setups (constraints') bounds of the auxiliary initial QP for given - * optimal primal/dual solution and given initial working set - * (assumes that members X, Y and BOUNDS, CONSTRAINTS have already been initialised!). - * \return SUCCESSFUL_RETURN \n - RET_UNKNOWN BUG */ - returnValue setupAuxiliaryQPbounds( const Bounds* const auxiliaryBounds, /**< Working set of bounds for auxiliary QP. */ - const Constraints* const auxiliaryConstraints, /**< Working set of constraints for auxiliary QP. */ - BooleanType useRelaxation /**< Flag indicating if inactive (constraints') bounds shall be relaxed. */ - ); - - - /** Adds a constraint to active set. - * \return SUCCESSFUL_RETURN \n - RET_ADDCONSTRAINT_FAILED \n - RET_ADDCONSTRAINT_FAILED_INFEASIBILITY \n - RET_ENSURELI_FAILED */ - returnValue addConstraint( int number, /**< Number of constraint to be added to active set. */ - SubjectToStatus C_status, /**< Status of new active constraint. */ - BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ - ); - - /** Checks if new active constraint to be added is linearly dependent from - * from row of the active constraints matrix. - * \return RET_LINEARLY_DEPENDENT \n - RET_LINEARLY_INDEPENDENT \n - RET_INDEXLIST_CORRUPTED */ - returnValue addConstraint_checkLI( int number /**< Number of constraint to be added to active set. */ - ); - - /** Ensures linear independence of constraint matrix when a new constraint is added. - * To this end a bound or constraint is removed simultaneously if necessary. - * \return SUCCESSFUL_RETURN \n - RET_LI_RESOLVED \n - RET_ENSURELI_FAILED \n - RET_ENSURELI_FAILED_TQ \n - RET_ENSURELI_FAILED_NOINDEX \n - RET_REMOVE_FROM_ACTIVESET */ - returnValue addConstraint_ensureLI( int number, /**< Number of constraint to be added to active set. */ - SubjectToStatus C_status /**< Status of new active bound. */ - ); - - /** Adds a bound to active set. - * \return SUCCESSFUL_RETURN \n - RET_ADDBOUND_FAILED \n - RET_ADDBOUND_FAILED_INFEASIBILITY \n - RET_ENSURELI_FAILED */ - returnValue addBound( int number, /**< Number of bound to be added to active set. */ - SubjectToStatus B_status, /**< Status of new active bound. */ - BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ - ); - - /** Checks if new active bound to be added is linearly dependent from - * from row of the active constraints matrix. - * \return RET_LINEARLY_DEPENDENT \n - RET_LINEARLY_INDEPENDENT */ - returnValue addBound_checkLI( int number /**< Number of bound to be added to active set. */ - ); - - /** Ensures linear independence of constraint matrix when a new bound is added. - * To this end a bound or constraint is removed simultaneously if necessary. - * \return SUCCESSFUL_RETURN \n - RET_LI_RESOLVED \n - RET_ENSURELI_FAILED \n - RET_ENSURELI_FAILED_TQ \n - RET_ENSURELI_FAILED_NOINDEX \n - RET_REMOVE_FROM_ACTIVESET */ - returnValue addBound_ensureLI( int number, /**< Number of bound to be added to active set. */ - SubjectToStatus B_status /**< Status of new active bound. */ - ); - - /** Removes a constraint from active set. - * \return SUCCESSFUL_RETURN \n - RET_CONSTRAINT_NOT_ACTIVE \n - RET_REMOVECONSTRAINT_FAILED \n - RET_HESSIAN_NOT_SPD */ - returnValue removeConstraint( int number, /**< Number of constraint to be removed from active set. */ - BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ - ); - - /** Removes a bounds from active set. - * \return SUCCESSFUL_RETURN \n - RET_BOUND_NOT_ACTIVE \n - RET_HESSIAN_NOT_SPD \n - RET_REMOVEBOUND_FAILED */ - returnValue removeBound( int number, /**< Number of bound to be removed from active set. */ - BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ - ); - - - /** Solves the system Ra = b or R^Ta = b where R is an upper triangular matrix. - * \return SUCCESSFUL_RETURN \n - RET_DIV_BY_ZERO */ - returnValue backsolveR( const real_t* const b, /**< Right hand side vector. */ - BooleanType transposed, /**< Indicates if the transposed system shall be solved. */ - real_t* const a /**< Output: Solution vector */ - ); - - /** Solves the system Ra = b or R^Ta = b where R is an upper triangular matrix. \n - * Special variant for the case that this function is called from within "removeBound()". - * \return SUCCESSFUL_RETURN \n - RET_DIV_BY_ZERO */ - returnValue backsolveR( const real_t* const b, /**< Right hand side vector. */ - BooleanType transposed, /**< Indicates if the transposed system shall be solved. */ - BooleanType removingBound, /**< Indicates if function is called from "removeBound()". */ - real_t* const a /**< Output: Solution vector */ - ); - - - /** Solves the system Ta = b or T^Ta = b where T is a reverse upper triangular matrix. - * \return SUCCESSFUL_RETURN \n - RET_DIV_BY_ZERO */ - returnValue backsolveT( const real_t* const b, /**< Right hand side vector. */ - BooleanType transposed, /**< Indicates if the transposed system shall be solved. */ - real_t* const a /**< Output: Solution vector */ - ); - - - /** Determines step direction of the shift of the QP data. - * \return SUCCESSFUL_RETURN */ - returnValue hotstart_determineDataShift(const int* const FX_idx, /**< Index array of fixed variables. */ - const int* const AC_idx, /**< Index array of active constraints. */ - const real_t* const g_new, /**< New gradient vector. */ - const real_t* const lbA_new,/**< New lower constraints' bounds. */ - const real_t* const ubA_new,/**< New upper constraints' bounds. */ - const real_t* const lb_new, /**< New lower bounds. */ - const real_t* const ub_new, /**< New upper bounds. */ - real_t* const delta_g, /**< Output: Step direction of gradient vector. */ - real_t* const delta_lbA, /**< Output: Step direction of lower constraints' bounds. */ - real_t* const delta_ubA, /**< Output: Step direction of upper constraints' bounds. */ - real_t* const delta_lb, /**< Output: Step direction of lower bounds. */ - real_t* const delta_ub, /**< Output: Step direction of upper bounds. */ - BooleanType& Delta_bC_isZero,/**< Output: Indicates if active constraints' bounds are to be shifted. */ - BooleanType& Delta_bB_isZero/**< Output: Indicates if active bounds are to be shifted. */ - ); - - /** Determines step direction of the homotopy path. - * \return SUCCESSFUL_RETURN \n - RET_STEPDIRECTION_FAILED_TQ \n - RET_STEPDIRECTION_FAILED_CHOLESKY */ - returnValue hotstart_determineStepDirection(const int* const FR_idx, /**< Index array of free variables. */ - const int* const FX_idx, /**< Index array of fixed variables. */ - const int* const AC_idx, /**< Index array of active constraints. */ - const real_t* const delta_g, /**< Step direction of gradient vector. */ - const real_t* const delta_lbA, /**< Step direction of lower constraints' bounds. */ - const real_t* const delta_ubA, /**< Step direction of upper constraints' bounds. */ - const real_t* const delta_lb, /**< Step direction of lower bounds. */ - const real_t* const delta_ub, /**< Step direction of upper bounds. */ - BooleanType Delta_bC_isZero, /**< Indicates if active constraints' bounds are to be shifted. */ - BooleanType Delta_bB_isZero, /**< Indicates if active bounds are to be shifted. */ - real_t* const delta_xFX, /**< Output: Primal homotopy step direction of fixed variables. */ - real_t* const delta_xFR, /**< Output: Primal homotopy step direction of free variables. */ - real_t* const delta_yAC, /**< Output: Dual homotopy step direction of active constraints' multiplier. */ - real_t* const delta_yFX /**< Output: Dual homotopy step direction of fixed variables' multiplier. */ - ); - - /** Determines the maximum possible step length along the homotopy path. - * \return SUCCESSFUL_RETURN */ - returnValue hotstart_determineStepLength( const int* const FR_idx, /**< Index array of free variables. */ - const int* const FX_idx, /**< Index array of fixed variables. */ - const int* const AC_idx, /**< Index array of active constraints. */ - const int* const IAC_idx, /**< Index array of inactive constraints. */ - const real_t* const delta_lbA, /**< Step direction of lower constraints' bounds. */ - const real_t* const delta_ubA, /**< Step direction of upper constraints' bounds. */ - const real_t* const delta_lb, /**< Step direction of lower bounds. */ - const real_t* const delta_ub, /**< Step direction of upper bounds. */ - const real_t* const delta_xFX, /**< Primal homotopy step direction of fixed variables. */ - const real_t* const delta_xFR, /**< Primal homotopy step direction of free variables. */ - const real_t* const delta_yAC, /**< Dual homotopy step direction of active constraints' multiplier. */ - const real_t* const delta_yFX, /**< Dual homotopy step direction of fixed variables' multiplier. */ - real_t* const delta_Ax, /**< Output: Step in vector Ax. */ - int& BC_idx, /**< Output: Index of blocking constraint. */ - SubjectToStatus& BC_status, /**< Output: Status of blocking constraint. */ - BooleanType& BC_isBound /**< Output: Indicates if blocking constraint is a bound. */ - ); - - /** Performs a step along the homotopy path (and updates active set). - * \return SUCCESSFUL_RETURN \n - RET_OPTIMAL_SOLUTION_FOUND \n - RET_REMOVE_FROM_ACTIVESET_FAILED \n - RET_ADD_TO_ACTIVESET_FAILED \n - RET_QP_INFEASIBLE */ - returnValue hotstart_performStep( const int* const FR_idx, /**< Index array of free variables. */ - const int* const FX_idx, /**< Index array of fixed variables. */ - const int* const AC_idx, /**< Index array of active constraints. */ - const int* const IAC_idx, /**< Index array of inactive constraints. */ - const real_t* const delta_g, /**< Step direction of gradient vector. */ - const real_t* const delta_lbA, /**< Step direction of lower constraints' bounds. */ - const real_t* const delta_ubA, /**< Step direction of upper constraints' bounds. */ - const real_t* const delta_lb, /**< Step direction of lower bounds. */ - const real_t* const delta_ub, /**< Step direction of upper bounds. */ - const real_t* const delta_xFX, /**< Primal homotopy step direction of fixed variables. */ - const real_t* const delta_xFR, /**< Primal homotopy step direction of free variables. */ - const real_t* const delta_yAC, /**< Dual homotopy step direction of active constraints' multiplier. */ - const real_t* const delta_yFX, /**< Dual homotopy step direction of fixed variables' multiplier. */ - const real_t* const delta_Ax, /**< Step in vector Ax. */ - int BC_idx, /**< Index of blocking constraint. */ - SubjectToStatus BC_status, /**< Status of blocking constraint. */ - BooleanType BC_isBound /**< Indicates if blocking constraint is a bound. */ - ); - - - /** Checks if lower/upper (constraints') bounds remain consistent - * (i.e. if lb <= ub and lbA <= ubA ) during the current step. - * \return BT_TRUE iff (constraints") bounds remain consistent - */ - BooleanType areBoundsConsistent( const real_t* const delta_lb, /**< Step direction of lower bounds. */ - const real_t* const delta_ub, /**< Step direction of upper bounds. */ - const real_t* const delta_lbA, /**< Step direction of lower constraints' bounds. */ - const real_t* const delta_ubA /**< Step direction of upper constraints' bounds. */ - ) const; - - - /** Setups internal QP data. - * \return SUCCESSFUL_RETURN \n - RET_INVALID_ARGUMENTS */ - returnValue setupQPdata( const real_t* const _H, /**< Hessian matrix. */ - const real_t* const _R, /**< Cholesky factorization of the Hessian matrix. */ - const real_t* const _g, /**< Gradient vector. */ - const real_t* const _A, /**< Constraint matrix. */ - const real_t* const _lb, /**< Lower bound vector (on variables). \n - If no lower bounds exist, a NULL pointer can be passed. */ - const real_t* const _ub, /**< Upper bound vector (on variables). \n - If no upper bounds exist, a NULL pointer can be passed. */ - const real_t* const _lbA, /**< Lower constraints' bound vector. \n - If no lower constraints' bounds exist, a NULL pointer can be passed. */ - const real_t* const _ubA /**< Upper constraints' bound vector. \n - If no lower constraints' bounds exist, a NULL pointer can be passed. */ - ); - - - #ifdef PC_DEBUG /* Define print functions only for debugging! */ - - /** Prints concise information on the current iteration. - * \return SUCCESSFUL_RETURN \n */ - returnValue printIteration( int iteration, /**< Number of current iteration. */ - int BC_idx, /**< Index of blocking constraint. */ - SubjectToStatus BC_status, /**< Status of blocking constraint. */ - BooleanType BC_isBound /**< Indicates if blocking constraint is a bound. */ - ); - - /** Prints concise information on the current iteration. - * NOTE: ONLY DEFINED FOR SUPPRESSING A COMPILER WARNING!! - * \return SUCCESSFUL_RETURN \n */ - returnValue printIteration( int iteration, /**< Number of current iteration. */ - int BC_idx, /**< Index of blocking bound. */ - SubjectToStatus BC_status /**< Status of blocking bound. */ - ); - - #endif /* PC_DEBUG */ - - - /** Determines the maximum violation of the KKT optimality conditions - * of the current iterate within the QProblem object. - * \return SUCCESSFUL_RETURN \n - * RET_INACCURATE_SOLUTION \n - * RET_NO_SOLUTION */ - returnValue checkKKTconditions( ); - - - /** Sets constraint matrix of the QP. \n - (Remark: Also internal vector Ax is recomputed!) - * \return SUCCESSFUL_RETURN */ - inline returnValue setA( const real_t* const A_new /**< New constraint matrix (with correct dimension!). */ - ); - - /** Changes single row of constraint matrix of the QP. \n - (Remark: Also correponding component of internal vector Ax is recomputed!) - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue setA( int number, /**< Number of row to be changed. */ - const real_t* const value /**< New (number)th constraint (with correct dimension!). */ - ); - - - /** Sets constraints' lower bound vector of the QP. - * \return SUCCESSFUL_RETURN */ - inline returnValue setLBA( const real_t* const lbA_new /**< New constraints' lower bound vector (with correct dimension!). */ - ); - - /** Changes single entry of lower constraints' bound vector of the QP. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue setLBA( int number, /**< Number of entry to be changed. */ - real_t value /**< New value for entry of lower constraints' bound vector (with correct dimension!). */ - ); - - /** Sets constraints' upper bound vector of the QP. - * \return SUCCESSFUL_RETURN */ - inline returnValue setUBA( const real_t* const ubA_new /**< New constraints' upper bound vector (with correct dimension!). */ - ); - - /** Changes single entry of upper constraints' bound vector of the QP. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue setUBA( int number, /**< Number of entry to be changed. */ - real_t value /**< New value for entry of upper constraints' bound vector (with correct dimension!). */ - ); - - - /* - * PROTECTED MEMBER VARIABLES - */ - protected: - real_t A[NCMAX_ALLOC*NVMAX]; /**< Constraint matrix. */ - real_t lbA[NCMAX_ALLOC]; /**< Lower constraints' bound vector. */ - real_t ubA[NCMAX_ALLOC]; /**< Upper constraints' bound vector. */ - - Constraints constraints; /**< Data structure for problem's constraints. */ - - real_t T[NVMAX*NVMAX]; /**< Reverse triangular matrix, A = [0 T]*Q'. */ - real_t Q[NVMAX*NVMAX]; /**< Orthonormal quadratic matrix, A = [0 T]*Q'. */ - int sizeT; /**< Matrix T is stored in a (sizeT x sizeT) array. */ - - real_t Ax[NCMAX_ALLOC]; /**< Stores the current product A*x (for increased efficiency only). */ - - CyclingManager cyclingManager; /**< Data structure for storing (possible) cycling information (NOT YET IMPLEMENTED!). */ -}; - - -#include - -#endif /* QPOASES_QPROBLEM_HPP */ - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file INCLUDE/QProblem.hpp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Declaration of the QProblem class which is able to use the newly + * developed online active set strategy for parametric quadratic programming. + */ + + + +#ifndef QPOASES_QPROBLEM_HPP +#define QPOASES_QPROBLEM_HPP + + +#include +#include +#include + + +/** A class for setting up and solving quadratic programs. The main feature is + * the possibily to use the newly developed online active set strategy for + * parametric quadratic programming. + * + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + */ +class QProblem : public QProblemB +{ + /* allow SolutionAnalysis class to access private members */ + friend class SolutionAnalysis; + + /* + * PUBLIC MEMBER FUNCTIONS + */ + public: + /** Default constructor. */ + QProblem( ); + + /** Constructor which takes the QP dimensions only. */ + QProblem( int _nV, /**< Number of variables. */ + int _nC /**< Number of constraints. */ + ); + + /** Copy constructor (deep copy). */ + QProblem( const QProblem& rhs /**< Rhs object. */ + ); + + /** Destructor. */ + ~QProblem( ); + + /** Assignment operator (deep copy). */ + QProblem& operator=( const QProblem& rhs /**< Rhs object. */ + ); + + + /** Clears all data structures of QProblemB except for QP data. + * \return SUCCESSFUL_RETURN \n + RET_RESET_FAILED */ + returnValue reset( ); + + + /** Initialises a QProblem with given QP data and solves it + * using an initial homotopy with empty working set (at most nWSR iterations). + * \return SUCCESSFUL_RETURN \n + RET_INIT_FAILED \n + RET_INIT_FAILED_CHOLESKY \n + RET_INIT_FAILED_TQ \n + RET_INIT_FAILED_HOTSTART \n + RET_INIT_FAILED_INFEASIBILITY \n + RET_INIT_FAILED_UNBOUNDEDNESS \n + RET_MAX_NWSR_REACHED \n + RET_INVALID_ARGUMENTS \n + RET_INACCURATE_SOLUTION \n + RET_NO_SOLUTION */ + returnValue init( const real_t* const _H, /**< Hessian matrix. */ + const real_t* const _g, /**< Gradient vector. */ + const real_t* const _A, /**< Constraint matrix. */ + const real_t* const _lb, /**< Lower bound vector (on variables). \n + If no lower bounds exist, a NULL pointer can be passed. */ + const real_t* const _ub, /**< Upper bound vector (on variables). \n + If no upper bounds exist, a NULL pointer can be passed. */ + const real_t* const _lbA, /**< Lower constraints' bound vector. \n + If no lower constraints' bounds exist, a NULL pointer can be passed. */ + const real_t* const _ubA, /**< Upper constraints' bound vector. \n + If no lower constraints' bounds exist, a NULL pointer can be passed. */ + int& nWSR, /**< Input: Maximum number of working set recalculations when using initial homotopy. + Output: Number of performed working set recalculations. */ + const real_t* const yOpt = 0, /**< Initial guess for dual solution vector. */ + real_t* const cputime = 0 /**< Output: CPU time required to initialise QP. */ + ); + + + /** Initialises a QProblem with given QP data and solves it + * using an initial homotopy with empty working set (at most nWSR iterations). + * \return SUCCESSFUL_RETURN \n + RET_INIT_FAILED \n + RET_INIT_FAILED_CHOLESKY \n + RET_INIT_FAILED_TQ \n + RET_INIT_FAILED_HOTSTART \n + RET_INIT_FAILED_INFEASIBILITY \n + RET_INIT_FAILED_UNBOUNDEDNESS \n + RET_MAX_NWSR_REACHED \n + RET_INVALID_ARGUMENTS \n + RET_INACCURATE_SOLUTION \n + RET_NO_SOLUTION */ + returnValue init( const real_t* const _H, /**< Hessian matrix. */ + const real_t* const _R, /**< Cholesky factorization of the Hessian matrix. */ + const real_t* const _g, /**< Gradient vector. */ + const real_t* const _A, /**< Constraint matrix. */ + const real_t* const _lb, /**< Lower bound vector (on variables). \n + If no lower bounds exist, a NULL pointer can be passed. */ + const real_t* const _ub, /**< Upper bound vector (on variables). \n + If no upper bounds exist, a NULL pointer can be passed. */ + const real_t* const _lbA, /**< Lower constraints' bound vector. \n + If no lower constraints' bounds exist, a NULL pointer can be passed. */ + const real_t* const _ubA, /**< Upper constraints' bound vector. \n + If no lower constraints' bounds exist, a NULL pointer can be passed. */ + int& nWSR, /**< Input: Maximum number of working set recalculations when using initial homotopy. + Output: Number of performed working set recalculations. */ + const real_t* const yOpt = 0, /**< Initial guess for dual solution vector. */ + real_t* const cputime = 0 /**< Output: CPU time required to initialise QP. */ + ); + + + /** Solves QProblem using online active set strategy. + * \return SUCCESSFUL_RETURN \n + RET_MAX_NWSR_REACHED \n + RET_HOTSTART_FAILED_AS_QP_NOT_INITIALISED \n + RET_HOTSTART_FAILED \n + RET_SHIFT_DETERMINATION_FAILED \n + RET_STEPDIRECTION_DETERMINATION_FAILED \n + RET_STEPLENGTH_DETERMINATION_FAILED \n + RET_HOMOTOPY_STEP_FAILED \n + RET_HOTSTART_STOPPED_INFEASIBILITY \n + RET_HOTSTART_STOPPED_UNBOUNDEDNESS \n + RET_INACCURATE_SOLUTION \n + RET_NO_SOLUTION */ + returnValue hotstart( const real_t* const g_new, /**< Gradient of neighbouring QP to be solved. */ + const real_t* const lb_new, /**< Lower bounds of neighbouring QP to be solved. \n + If no lower bounds exist, a NULL pointer can be passed. */ + const real_t* const ub_new, /**< Upper bounds of neighbouring QP to be solved. \n + If no upper bounds exist, a NULL pointer can be passed. */ + const real_t* const lbA_new, /**< Lower constraints' bounds of neighbouring QP to be solved. \n + If no lower constraints' bounds exist, a NULL pointer can be passed. */ + const real_t* const ubA_new, /**< Upper constraints' bounds of neighbouring QP to be solved. \n + If no upper constraints' bounds exist, a NULL pointer can be passed. */ + int& nWSR, /**< Input: Maximum number of working set recalculations; \n + Output: Number of performed working set recalculations. */ + real_t* const cputime /**< Output: CPU time required to solve QP (or to perform nWSR iterations). */ + ); + + + /** Returns constraint matrix of the QP (deep copy). + * \return SUCCESSFUL_RETURN */ + inline returnValue getA( real_t* const _A /**< Array of appropriate dimension for copying constraint matrix.*/ + ) const; + + /** Returns a single row of constraint matrix of the QP (deep copy). + * \return SUCCESSFUL_RETURN \n + RET_INDEX_OUT_OF_BOUNDS */ + inline returnValue getA( int number, /**< Number of entry to be returned. */ + real_t* const row /**< Array of appropriate dimension for copying (number)th constraint. */ + ) const; + + /** Returns lower constraints' bound vector of the QP (deep copy). + * \return SUCCESSFUL_RETURN */ + inline returnValue getLBA( real_t* const _lbA /**< Array of appropriate dimension for copying lower constraints' bound vector.*/ + ) const; + + /** Returns single entry of lower constraints' bound vector of the QP. + * \return SUCCESSFUL_RETURN \n + RET_INDEX_OUT_OF_BOUNDS */ + inline returnValue getLBA( int number, /**< Number of entry to be returned. */ + real_t& value /**< Output: lbA[number].*/ + ) const; + + /** Returns upper constraints' bound vector of the QP (deep copy). + * \return SUCCESSFUL_RETURN */ + inline returnValue getUBA( real_t* const _ubA /**< Array of appropriate dimension for copying upper constraints' bound vector.*/ + ) const; + + /** Returns single entry of upper constraints' bound vector of the QP. + * \return SUCCESSFUL_RETURN \n + RET_INDEX_OUT_OF_BOUNDS */ + inline returnValue getUBA( int number, /**< Number of entry to be returned. */ + real_t& value /**< Output: ubA[number].*/ + ) const; + + + /** Returns current constraints object of the QP (deep copy). + * \return SUCCESSFUL_RETURN */ + inline returnValue getConstraints( Constraints* const _constraints /** Output: Constraints object. */ + ) const; + + + /** Returns the number of constraints. + * \return Number of constraints. */ + inline int getNC( ) const; + + /** Returns the number of (implicitly defined) equality constraints. + * \return Number of (implicitly defined) equality constraints. */ + inline int getNEC( ) const; + + /** Returns the number of active constraints. + * \return Number of active constraints. */ + inline int getNAC( ); + + /** Returns the number of inactive constraints. + * \return Number of inactive constraints. */ + inline int getNIAC( ); + + /** Returns the dimension of null space. + * \return Dimension of null space. */ + int getNZ( ); + + + /** Returns the dual solution vector (deep copy). + * \return SUCCESSFUL_RETURN \n + RET_QP_NOT_SOLVED */ + returnValue getDualSolution( real_t* const yOpt /**< Output: Dual solution vector (if QP has been solved). */ + ) const; + + + /* + * PROTECTED MEMBER FUNCTIONS + */ + protected: + /** Determines type of constraints and bounds (i.e. implicitly fixed, unbounded etc.). + * \return SUCCESSFUL_RETURN \n + RET_SETUPSUBJECTTOTYPE_FAILED */ + returnValue setupSubjectToType( ); + + /** Computes the Cholesky decomposition R of the projected Hessian (i.e. R^T*R = Z^T*H*Z). + * \return SUCCESSFUL_RETURN \n + * RET_INDEXLIST_CORRUPTED */ + returnValue setupCholeskyDecompositionProjected( ); + + /** Initialises TQ factorisation of A (i.e. A*Q = [0 T]) if NO constraint is active. + * \return SUCCESSFUL_RETURN \n + RET_INDEXLIST_CORRUPTED */ + returnValue setupTQfactorisation( ); + + + /** Solves a QProblem whose QP data is assumed to be stored in the member variables. + * A guess for its primal/dual optimal solution vectors and the corresponding + * working sets of bounds and constraints can be provided. + * \return SUCCESSFUL_RETURN \n + RET_INIT_FAILED \n + RET_INIT_FAILED_CHOLESKY \n + RET_INIT_FAILED_TQ \n + RET_INIT_FAILED_HOTSTART \n + RET_INIT_FAILED_INFEASIBILITY \n + RET_INIT_FAILED_UNBOUNDEDNESS \n + RET_MAX_NWSR_REACHED */ + returnValue solveInitialQP( const real_t* const xOpt, /**< Optimal primal solution vector. + * A NULL pointer can be passed. */ + const real_t* const yOpt, /**< Optimal dual solution vector. + * A NULL pointer can be passed. */ + const Bounds* const guessedBounds, /**< Guessed working set of bounds for solution (xOpt,yOpt). + * A NULL pointer can be passed. */ + const Constraints* const guessedConstraints, /**< Optimal working set of constraints for solution (xOpt,yOpt). + * A NULL pointer can be passed. */ + int& nWSR, /**< Input: Maximum number of working set recalculations; \n + * Output: Number of performed working set recalculations. */ + real_t* const cputime /**< Output: CPU time required to solve QP (or to perform nWSR iterations). */ + ); + + /** Obtains the desired working set for the auxiliary initial QP in + * accordance with the user specifications + * (assumes that member AX has already been initialised!) + * \return SUCCESSFUL_RETURN \n + RET_OBTAINING_WORKINGSET_FAILED \n + RET_INVALID_ARGUMENTS */ + returnValue obtainAuxiliaryWorkingSet( const real_t* const xOpt, /**< Optimal primal solution vector. + * If a NULL pointer is passed, all entries are assumed to be zero. */ + const real_t* const yOpt, /**< Optimal dual solution vector. + * If a NULL pointer is passed, all entries are assumed to be zero. */ + const Bounds* const guessedBounds, /**< Guessed working set of bounds for solution (xOpt,yOpt). */ + const Constraints* const guessedConstraints, /**< Guessed working set for solution (xOpt,yOpt). */ + Bounds* auxiliaryBounds, /**< Input: Allocated bound object. \n + * Ouput: Working set of constraints for auxiliary QP. */ + Constraints* auxiliaryConstraints /**< Input: Allocated bound object. \n + * Ouput: Working set for auxiliary QP. */ + ) const; + + /** Setups bound and constraints data structures according to auxiliaryBounds/Constraints. + * (If the working set shall be setup afresh, make sure that + * bounds and constraints data structure have been resetted + * and the TQ factorisation has been initialised!) + * \return SUCCESSFUL_RETURN \n + RET_SETUP_WORKINGSET_FAILED \n + RET_INVALID_ARGUMENTS \n + RET_UNKNOWN BUG */ + returnValue setupAuxiliaryWorkingSet( const Bounds* const auxiliaryBounds, /**< Working set of bounds for auxiliary QP. */ + const Constraints* const auxiliaryConstraints, /**< Working set of constraints for auxiliary QP. */ + BooleanType setupAfresh /**< Flag indicating if given working set shall be + * setup afresh or by updating the current one. */ + ); + + /** Setups the optimal primal/dual solution of the auxiliary initial QP. + * \return SUCCESSFUL_RETURN */ + returnValue setupAuxiliaryQPsolution( const real_t* const xOpt, /**< Optimal primal solution vector. + * If a NULL pointer is passed, all entries are set to zero. */ + const real_t* const yOpt /**< Optimal dual solution vector. + * If a NULL pointer is passed, all entries are set to zero. */ + ); + + /** Setups gradient of the auxiliary initial QP for given + * optimal primal/dual solution and given initial working set + * (assumes that members X, Y and BOUNDS, CONSTRAINTS have already been initialised!). + * \return SUCCESSFUL_RETURN */ + returnValue setupAuxiliaryQPgradient( ); + + /** Setups (constraints') bounds of the auxiliary initial QP for given + * optimal primal/dual solution and given initial working set + * (assumes that members X, Y and BOUNDS, CONSTRAINTS have already been initialised!). + * \return SUCCESSFUL_RETURN \n + RET_UNKNOWN BUG */ + returnValue setupAuxiliaryQPbounds( const Bounds* const auxiliaryBounds, /**< Working set of bounds for auxiliary QP. */ + const Constraints* const auxiliaryConstraints, /**< Working set of constraints for auxiliary QP. */ + BooleanType useRelaxation /**< Flag indicating if inactive (constraints') bounds shall be relaxed. */ + ); + + + /** Adds a constraint to active set. + * \return SUCCESSFUL_RETURN \n + RET_ADDCONSTRAINT_FAILED \n + RET_ADDCONSTRAINT_FAILED_INFEASIBILITY \n + RET_ENSURELI_FAILED */ + returnValue addConstraint( int number, /**< Number of constraint to be added to active set. */ + SubjectToStatus C_status, /**< Status of new active constraint. */ + BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ + ); + + /** Checks if new active constraint to be added is linearly dependent from + * from row of the active constraints matrix. + * \return RET_LINEARLY_DEPENDENT \n + RET_LINEARLY_INDEPENDENT \n + RET_INDEXLIST_CORRUPTED */ + returnValue addConstraint_checkLI( int number /**< Number of constraint to be added to active set. */ + ); + + /** Ensures linear independence of constraint matrix when a new constraint is added. + * To this end a bound or constraint is removed simultaneously if necessary. + * \return SUCCESSFUL_RETURN \n + RET_LI_RESOLVED \n + RET_ENSURELI_FAILED \n + RET_ENSURELI_FAILED_TQ \n + RET_ENSURELI_FAILED_NOINDEX \n + RET_REMOVE_FROM_ACTIVESET */ + returnValue addConstraint_ensureLI( int number, /**< Number of constraint to be added to active set. */ + SubjectToStatus C_status /**< Status of new active bound. */ + ); + + /** Adds a bound to active set. + * \return SUCCESSFUL_RETURN \n + RET_ADDBOUND_FAILED \n + RET_ADDBOUND_FAILED_INFEASIBILITY \n + RET_ENSURELI_FAILED */ + returnValue addBound( int number, /**< Number of bound to be added to active set. */ + SubjectToStatus B_status, /**< Status of new active bound. */ + BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ + ); + + /** Checks if new active bound to be added is linearly dependent from + * from row of the active constraints matrix. + * \return RET_LINEARLY_DEPENDENT \n + RET_LINEARLY_INDEPENDENT */ + returnValue addBound_checkLI( int number /**< Number of bound to be added to active set. */ + ); + + /** Ensures linear independence of constraint matrix when a new bound is added. + * To this end a bound or constraint is removed simultaneously if necessary. + * \return SUCCESSFUL_RETURN \n + RET_LI_RESOLVED \n + RET_ENSURELI_FAILED \n + RET_ENSURELI_FAILED_TQ \n + RET_ENSURELI_FAILED_NOINDEX \n + RET_REMOVE_FROM_ACTIVESET */ + returnValue addBound_ensureLI( int number, /**< Number of bound to be added to active set. */ + SubjectToStatus B_status /**< Status of new active bound. */ + ); + + /** Removes a constraint from active set. + * \return SUCCESSFUL_RETURN \n + RET_CONSTRAINT_NOT_ACTIVE \n + RET_REMOVECONSTRAINT_FAILED \n + RET_HESSIAN_NOT_SPD */ + returnValue removeConstraint( int number, /**< Number of constraint to be removed from active set. */ + BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ + ); + + /** Removes a bounds from active set. + * \return SUCCESSFUL_RETURN \n + RET_BOUND_NOT_ACTIVE \n + RET_HESSIAN_NOT_SPD \n + RET_REMOVEBOUND_FAILED */ + returnValue removeBound( int number, /**< Number of bound to be removed from active set. */ + BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ + ); + + + /** Solves the system Ra = b or R^Ta = b where R is an upper triangular matrix. + * \return SUCCESSFUL_RETURN \n + RET_DIV_BY_ZERO */ + returnValue backsolveR( const real_t* const b, /**< Right hand side vector. */ + BooleanType transposed, /**< Indicates if the transposed system shall be solved. */ + real_t* const a /**< Output: Solution vector */ + ); + + /** Solves the system Ra = b or R^Ta = b where R is an upper triangular matrix. \n + * Special variant for the case that this function is called from within "removeBound()". + * \return SUCCESSFUL_RETURN \n + RET_DIV_BY_ZERO */ + returnValue backsolveR( const real_t* const b, /**< Right hand side vector. */ + BooleanType transposed, /**< Indicates if the transposed system shall be solved. */ + BooleanType removingBound, /**< Indicates if function is called from "removeBound()". */ + real_t* const a /**< Output: Solution vector */ + ); + + + /** Solves the system Ta = b or T^Ta = b where T is a reverse upper triangular matrix. + * \return SUCCESSFUL_RETURN \n + RET_DIV_BY_ZERO */ + returnValue backsolveT( const real_t* const b, /**< Right hand side vector. */ + BooleanType transposed, /**< Indicates if the transposed system shall be solved. */ + real_t* const a /**< Output: Solution vector */ + ); + + + /** Determines step direction of the shift of the QP data. + * \return SUCCESSFUL_RETURN */ + returnValue hotstart_determineDataShift(const int* const FX_idx, /**< Index array of fixed variables. */ + const int* const AC_idx, /**< Index array of active constraints. */ + const real_t* const g_new, /**< New gradient vector. */ + const real_t* const lbA_new,/**< New lower constraints' bounds. */ + const real_t* const ubA_new,/**< New upper constraints' bounds. */ + const real_t* const lb_new, /**< New lower bounds. */ + const real_t* const ub_new, /**< New upper bounds. */ + real_t* const delta_g, /**< Output: Step direction of gradient vector. */ + real_t* const delta_lbA, /**< Output: Step direction of lower constraints' bounds. */ + real_t* const delta_ubA, /**< Output: Step direction of upper constraints' bounds. */ + real_t* const delta_lb, /**< Output: Step direction of lower bounds. */ + real_t* const delta_ub, /**< Output: Step direction of upper bounds. */ + BooleanType& Delta_bC_isZero,/**< Output: Indicates if active constraints' bounds are to be shifted. */ + BooleanType& Delta_bB_isZero/**< Output: Indicates if active bounds are to be shifted. */ + ); + + /** Determines step direction of the homotopy path. + * \return SUCCESSFUL_RETURN \n + RET_STEPDIRECTION_FAILED_TQ \n + RET_STEPDIRECTION_FAILED_CHOLESKY */ + returnValue hotstart_determineStepDirection(const int* const FR_idx, /**< Index array of free variables. */ + const int* const FX_idx, /**< Index array of fixed variables. */ + const int* const AC_idx, /**< Index array of active constraints. */ + const real_t* const delta_g, /**< Step direction of gradient vector. */ + const real_t* const delta_lbA, /**< Step direction of lower constraints' bounds. */ + const real_t* const delta_ubA, /**< Step direction of upper constraints' bounds. */ + const real_t* const delta_lb, /**< Step direction of lower bounds. */ + const real_t* const delta_ub, /**< Step direction of upper bounds. */ + BooleanType Delta_bC_isZero, /**< Indicates if active constraints' bounds are to be shifted. */ + BooleanType Delta_bB_isZero, /**< Indicates if active bounds are to be shifted. */ + real_t* const delta_xFX, /**< Output: Primal homotopy step direction of fixed variables. */ + real_t* const delta_xFR, /**< Output: Primal homotopy step direction of free variables. */ + real_t* const delta_yAC, /**< Output: Dual homotopy step direction of active constraints' multiplier. */ + real_t* const delta_yFX /**< Output: Dual homotopy step direction of fixed variables' multiplier. */ + ); + + /** Determines the maximum possible step length along the homotopy path. + * \return SUCCESSFUL_RETURN */ + returnValue hotstart_determineStepLength( const int* const FR_idx, /**< Index array of free variables. */ + const int* const FX_idx, /**< Index array of fixed variables. */ + const int* const AC_idx, /**< Index array of active constraints. */ + const int* const IAC_idx, /**< Index array of inactive constraints. */ + const real_t* const delta_lbA, /**< Step direction of lower constraints' bounds. */ + const real_t* const delta_ubA, /**< Step direction of upper constraints' bounds. */ + const real_t* const delta_lb, /**< Step direction of lower bounds. */ + const real_t* const delta_ub, /**< Step direction of upper bounds. */ + const real_t* const delta_xFX, /**< Primal homotopy step direction of fixed variables. */ + const real_t* const delta_xFR, /**< Primal homotopy step direction of free variables. */ + const real_t* const delta_yAC, /**< Dual homotopy step direction of active constraints' multiplier. */ + const real_t* const delta_yFX, /**< Dual homotopy step direction of fixed variables' multiplier. */ + real_t* const delta_Ax, /**< Output: Step in vector Ax. */ + int& BC_idx, /**< Output: Index of blocking constraint. */ + SubjectToStatus& BC_status, /**< Output: Status of blocking constraint. */ + BooleanType& BC_isBound /**< Output: Indicates if blocking constraint is a bound. */ + ); + + /** Performs a step along the homotopy path (and updates active set). + * \return SUCCESSFUL_RETURN \n + RET_OPTIMAL_SOLUTION_FOUND \n + RET_REMOVE_FROM_ACTIVESET_FAILED \n + RET_ADD_TO_ACTIVESET_FAILED \n + RET_QP_INFEASIBLE */ + returnValue hotstart_performStep( const int* const FR_idx, /**< Index array of free variables. */ + const int* const FX_idx, /**< Index array of fixed variables. */ + const int* const AC_idx, /**< Index array of active constraints. */ + const int* const IAC_idx, /**< Index array of inactive constraints. */ + const real_t* const delta_g, /**< Step direction of gradient vector. */ + const real_t* const delta_lbA, /**< Step direction of lower constraints' bounds. */ + const real_t* const delta_ubA, /**< Step direction of upper constraints' bounds. */ + const real_t* const delta_lb, /**< Step direction of lower bounds. */ + const real_t* const delta_ub, /**< Step direction of upper bounds. */ + const real_t* const delta_xFX, /**< Primal homotopy step direction of fixed variables. */ + const real_t* const delta_xFR, /**< Primal homotopy step direction of free variables. */ + const real_t* const delta_yAC, /**< Dual homotopy step direction of active constraints' multiplier. */ + const real_t* const delta_yFX, /**< Dual homotopy step direction of fixed variables' multiplier. */ + const real_t* const delta_Ax, /**< Step in vector Ax. */ + int BC_idx, /**< Index of blocking constraint. */ + SubjectToStatus BC_status, /**< Status of blocking constraint. */ + BooleanType BC_isBound /**< Indicates if blocking constraint is a bound. */ + ); + + + /** Checks if lower/upper (constraints') bounds remain consistent + * (i.e. if lb <= ub and lbA <= ubA ) during the current step. + * \return BT_TRUE iff (constraints") bounds remain consistent + */ + BooleanType areBoundsConsistent( const real_t* const delta_lb, /**< Step direction of lower bounds. */ + const real_t* const delta_ub, /**< Step direction of upper bounds. */ + const real_t* const delta_lbA, /**< Step direction of lower constraints' bounds. */ + const real_t* const delta_ubA /**< Step direction of upper constraints' bounds. */ + ) const; + + + /** Setups internal QP data. + * \return SUCCESSFUL_RETURN \n + RET_INVALID_ARGUMENTS */ + returnValue setupQPdata( const real_t* const _H, /**< Hessian matrix. */ + const real_t* const _R, /**< Cholesky factorization of the Hessian matrix. */ + const real_t* const _g, /**< Gradient vector. */ + const real_t* const _A, /**< Constraint matrix. */ + const real_t* const _lb, /**< Lower bound vector (on variables). \n + If no lower bounds exist, a NULL pointer can be passed. */ + const real_t* const _ub, /**< Upper bound vector (on variables). \n + If no upper bounds exist, a NULL pointer can be passed. */ + const real_t* const _lbA, /**< Lower constraints' bound vector. \n + If no lower constraints' bounds exist, a NULL pointer can be passed. */ + const real_t* const _ubA /**< Upper constraints' bound vector. \n + If no lower constraints' bounds exist, a NULL pointer can be passed. */ + ); + + + #ifdef PC_DEBUG /* Define print functions only for debugging! */ + + /** Prints concise information on the current iteration. + * \return SUCCESSFUL_RETURN \n */ + returnValue printIteration( int iteration, /**< Number of current iteration. */ + int BC_idx, /**< Index of blocking constraint. */ + SubjectToStatus BC_status, /**< Status of blocking constraint. */ + BooleanType BC_isBound /**< Indicates if blocking constraint is a bound. */ + ); + + /** Prints concise information on the current iteration. + * NOTE: ONLY DEFINED FOR SUPPRESSING A COMPILER WARNING!! + * \return SUCCESSFUL_RETURN \n */ + returnValue printIteration( int iteration, /**< Number of current iteration. */ + int BC_idx, /**< Index of blocking bound. */ + SubjectToStatus BC_status /**< Status of blocking bound. */ + ); + + #endif /* PC_DEBUG */ + + + /** Determines the maximum violation of the KKT optimality conditions + * of the current iterate within the QProblem object. + * \return SUCCESSFUL_RETURN \n + * RET_INACCURATE_SOLUTION \n + * RET_NO_SOLUTION */ + returnValue checkKKTconditions( ); + + + /** Sets constraint matrix of the QP. \n + (Remark: Also internal vector Ax is recomputed!) + * \return SUCCESSFUL_RETURN */ + inline returnValue setA( const real_t* const A_new /**< New constraint matrix (with correct dimension!). */ + ); + + /** Changes single row of constraint matrix of the QP. \n + (Remark: Also correponding component of internal vector Ax is recomputed!) + * \return SUCCESSFUL_RETURN \n + RET_INDEX_OUT_OF_BOUNDS */ + inline returnValue setA( int number, /**< Number of row to be changed. */ + const real_t* const value /**< New (number)th constraint (with correct dimension!). */ + ); + + + /** Sets constraints' lower bound vector of the QP. + * \return SUCCESSFUL_RETURN */ + inline returnValue setLBA( const real_t* const lbA_new /**< New constraints' lower bound vector (with correct dimension!). */ + ); + + /** Changes single entry of lower constraints' bound vector of the QP. + * \return SUCCESSFUL_RETURN \n + RET_INDEX_OUT_OF_BOUNDS */ + inline returnValue setLBA( int number, /**< Number of entry to be changed. */ + real_t value /**< New value for entry of lower constraints' bound vector (with correct dimension!). */ + ); + + /** Sets constraints' upper bound vector of the QP. + * \return SUCCESSFUL_RETURN */ + inline returnValue setUBA( const real_t* const ubA_new /**< New constraints' upper bound vector (with correct dimension!). */ + ); + + /** Changes single entry of upper constraints' bound vector of the QP. + * \return SUCCESSFUL_RETURN \n + RET_INDEX_OUT_OF_BOUNDS */ + inline returnValue setUBA( int number, /**< Number of entry to be changed. */ + real_t value /**< New value for entry of upper constraints' bound vector (with correct dimension!). */ + ); + + + /* + * PROTECTED MEMBER VARIABLES + */ + protected: + real_t A[NCMAX_ALLOC*NVMAX]; /**< Constraint matrix. */ + real_t lbA[NCMAX_ALLOC]; /**< Lower constraints' bound vector. */ + real_t ubA[NCMAX_ALLOC]; /**< Upper constraints' bound vector. */ + + Constraints constraints; /**< Data structure for problem's constraints. */ + + real_t T[NVMAX*NVMAX]; /**< Reverse triangular matrix, A = [0 T]*Q'. */ + real_t Q[NVMAX*NVMAX]; /**< Orthonormal quadratic matrix, A = [0 T]*Q'. */ + int sizeT; /**< Matrix T is stored in a (sizeT x sizeT) array. */ + + real_t Ax[NCMAX_ALLOC]; /**< Stores the current product A*x (for increased efficiency only). */ + + CyclingManager cyclingManager; /**< Data structure for storing (possible) cycling information (NOT YET IMPLEMENTED!). */ +}; + + +#include + +#endif /* QPOASES_QPROBLEM_HPP */ + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/INCLUDE/QProblemB.hpp b/phonelibs/qpoases/INCLUDE/QProblemB.hpp index 8b3acb82bddab4..49ace9ef9d0047 100644 --- a/phonelibs/qpoases/INCLUDE/QProblemB.hpp +++ b/phonelibs/qpoases/INCLUDE/QProblemB.hpp @@ -1,628 +1,628 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/QProblemB.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Declaration of the QProblemB class which is able to use the newly - * developed online active set strategy for parametric quadratic programming - * for problems with (simple) bounds only. - */ - - - -#ifndef QPOASES_QPROBLEMB_HPP -#define QPOASES_QPROBLEMB_HPP - - -#include - - - -class SolutionAnalysis; - -/** Class for setting up and solving quadratic programs with (simple) bounds only. - * The main feature is the possibily to use the newly developed online active set strategy - * for parametric quadratic programming. - * - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - */ -class QProblemB -{ - /* allow SolutionAnalysis class to access private members */ - friend class SolutionAnalysis; - - /* - * PUBLIC MEMBER FUNCTIONS - */ - public: - /** Default constructor. */ - QProblemB( ); - - /** Constructor which takes the QP dimension only. */ - QProblemB( int _nV /**< Number of variables. */ - ); - - /** Copy constructor (deep copy). */ - QProblemB( const QProblemB& rhs /**< Rhs object. */ - ); - - /** Destructor. */ - ~QProblemB( ); - - /** Assignment operator (deep copy). */ - QProblemB& operator=( const QProblemB& rhs /**< Rhs object. */ - ); - - - /** Clears all data structures of QProblemB except for QP data. - * \return SUCCESSFUL_RETURN \n - RET_RESET_FAILED */ - returnValue reset( ); - - - /** Initialises a QProblemB with given QP data and solves it - * using an initial homotopy with empty working set (at most nWSR iterations). - * \return SUCCESSFUL_RETURN \n - RET_INIT_FAILED \n - RET_INIT_FAILED_CHOLESKY \n - RET_INIT_FAILED_HOTSTART \n - RET_INIT_FAILED_INFEASIBILITY \n - RET_INIT_FAILED_UNBOUNDEDNESS \n - RET_MAX_NWSR_REACHED \n - RET_INVALID_ARGUMENTS \n - RET_INACCURATE_SOLUTION \n - RET_NO_SOLUTION */ - returnValue init( const real_t* const _H, /**< Hessian matrix. */ - const real_t* const _g, /**< Gradient vector. */ - const real_t* const _lb, /**< Lower bounds (on variables). \n - If no lower bounds exist, a NULL pointer can be passed. */ - const real_t* const _ub, /**< Upper bounds (on variables). \n - If no upper bounds exist, a NULL pointer can be passed. */ - int& nWSR, /**< Input: Maximum number of working set recalculations when using initial homotopy. \n - Output: Number of performed working set recalculations. */ - const real_t* const yOpt = 0, /**< Initial guess for dual solution vector. */ - real_t* const cputime = 0 /**< Output: CPU time required to initialise QP. */ - ); - - - /** Initialises a QProblemB with given QP data and solves it - * using an initial homotopy with empty working set (at most nWSR iterations). - * \return SUCCESSFUL_RETURN \n - RET_INIT_FAILED \n - RET_INIT_FAILED_CHOLESKY \n - RET_INIT_FAILED_HOTSTART \n - RET_INIT_FAILED_INFEASIBILITY \n - RET_INIT_FAILED_UNBOUNDEDNESS \n - RET_MAX_NWSR_REACHED \n - RET_INVALID_ARGUMENTS \n - RET_INACCURATE_SOLUTION \n - RET_NO_SOLUTION */ - returnValue init( const real_t* const _H, /**< Hessian matrix. */ - const real_t* const _R, /**< Cholesky factorization of the Hessian matrix. */ - const real_t* const _g, /**< Gradient vector. */ - const real_t* const _lb, /**< Lower bounds (on variables). \n - If no lower bounds exist, a NULL pointer can be passed. */ - const real_t* const _ub, /**< Upper bounds (on variables). \n - If no upper bounds exist, a NULL pointer can be passed. */ - int& nWSR, /**< Input: Maximum number of working set recalculations when using initial homotopy. \n - Output: Number of performed working set recalculations. */ - const real_t* const yOpt = 0, /**< Initial guess for dual solution vector. */ - real_t* const cputime = 0 /**< Output: CPU time required to initialise QP. */ - ); - - - /** Solves an initialised QProblemB using online active set strategy. - * \return SUCCESSFUL_RETURN \n - RET_MAX_NWSR_REACHED \n - RET_HOTSTART_FAILED_AS_QP_NOT_INITIALISED \n - RET_HOTSTART_FAILED \n - RET_SHIFT_DETERMINATION_FAILED \n - RET_STEPDIRECTION_DETERMINATION_FAILED \n - RET_STEPLENGTH_DETERMINATION_FAILED \n - RET_HOMOTOPY_STEP_FAILED \n - RET_HOTSTART_STOPPED_INFEASIBILITY \n - RET_HOTSTART_STOPPED_UNBOUNDEDNESS \n - RET_INACCURATE_SOLUTION \n - RET_NO_SOLUTION */ - returnValue hotstart( const real_t* const g_new, /**< Gradient of neighbouring QP to be solved. */ - const real_t* const lb_new, /**< Lower bounds of neighbouring QP to be solved. \n - If no lower bounds exist, a NULL pointer can be passed. */ - const real_t* const ub_new, /**< Upper bounds of neighbouring QP to be solved. \n - If no upper bounds exist, a NULL pointer can be passed. */ - int& nWSR, /**< Input: Maximum number of working set recalculations; \n - Output: Number of performed working set recalculations. */ - real_t* const cputime /**< Output: CPU time required to solve QP (or to perform nWSR iterations). */ - ); - - - /** Returns Hessian matrix of the QP (deep copy). - * \return SUCCESSFUL_RETURN */ - inline returnValue getH( real_t* const _H /**< Array of appropriate dimension for copying Hessian matrix.*/ - ) const; - - /** Returns gradient vector of the QP (deep copy). - * \return SUCCESSFUL_RETURN */ - inline returnValue getG( real_t* const _g /**< Array of appropriate dimension for copying gradient vector.*/ - ) const; - - /** Returns lower bound vector of the QP (deep copy). - * \return SUCCESSFUL_RETURN */ - inline returnValue getLB( real_t* const _lb /**< Array of appropriate dimension for copying lower bound vector.*/ - ) const; - - /** Returns single entry of lower bound vector of the QP. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue getLB( int number, /**< Number of entry to be returned. */ - real_t& value /**< Output: lb[number].*/ - ) const; - - /** Returns upper bound vector of the QP (deep copy). - * \return SUCCESSFUL_RETURN */ - inline returnValue getUB( real_t* const _ub /**< Array of appropriate dimension for copying upper bound vector.*/ - ) const; - - /** Returns single entry of upper bound vector of the QP. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue getUB( int number, /**< Number of entry to be returned. */ - real_t& value /**< Output: ub[number].*/ - ) const; - - - /** Returns current bounds object of the QP (deep copy). - * \return SUCCESSFUL_RETURN */ - inline returnValue getBounds( Bounds* const _bounds /** Output: Bounds object. */ - ) const; - - - /** Returns the number of variables. - * \return Number of variables. */ - inline int getNV( ) const; - - /** Returns the number of free variables. - * \return Number of free variables. */ - inline int getNFR( ); - - /** Returns the number of fixed variables. - * \return Number of fixed variables. */ - inline int getNFX( ); - - /** Returns the number of implicitly fixed variables. - * \return Number of implicitly fixed variables. */ - inline int getNFV( ) const; - - /** Returns the dimension of null space. - * \return Dimension of null space. */ - int getNZ( ); - - - /** Returns the optimal objective function value. - * \return finite value: Optimal objective function value (QP was solved) \n - +infinity: QP was not yet solved */ - real_t getObjVal( ) const; - - /** Returns the objective function value at an arbitrary point x. - * \return Objective function value at point x */ - real_t getObjVal( const real_t* const _x /**< Point at which the objective function shall be evaluated. */ - ) const; - - /** Returns the primal solution vector. - * \return SUCCESSFUL_RETURN \n - RET_QP_NOT_SOLVED */ - returnValue getPrimalSolution( real_t* const xOpt /**< Output: Primal solution vector (if QP has been solved). */ - ) const; - - /** Returns the dual solution vector. - * \return SUCCESSFUL_RETURN \n - RET_QP_NOT_SOLVED */ - returnValue getDualSolution( real_t* const yOpt /**< Output: Dual solution vector (if QP has been solved). */ - ) const; - - - /** Returns status of the solution process. - * \return Status of solution process. */ - inline QProblemStatus getStatus( ) const; - - - /** Returns if the QProblem object is initialised. - * \return BT_TRUE: QProblemB initialised \n - BT_FALSE: QProblemB not initialised */ - inline BooleanType isInitialised( ) const; - - /** Returns if the QP has been solved. - * \return BT_TRUE: QProblemB solved \n - BT_FALSE: QProblemB not solved */ - inline BooleanType isSolved( ) const; - - /** Returns if the QP is infeasible. - * \return BT_TRUE: QP infeasible \n - BT_FALSE: QP feasible (or not known to be infeasible!) */ - inline BooleanType isInfeasible( ) const; - - /** Returns if the QP is unbounded. - * \return BT_TRUE: QP unbounded \n - BT_FALSE: QP unbounded (or not known to be unbounded!) */ - inline BooleanType isUnbounded( ) const; - - - /** Returns the print level. - * \return Print level. */ - inline PrintLevel getPrintLevel( ) const; - - /** Changes the print level. - * \return SUCCESSFUL_RETURN */ - returnValue setPrintLevel( PrintLevel _printlevel /**< New print level. */ - ); - - - /** Returns Hessian type flag (type is not determined due to this call!). - * \return Hessian type. */ - inline HessianType getHessianType( ) const; - - /** Changes the print level. - * \return SUCCESSFUL_RETURN */ - inline returnValue setHessianType( HessianType _hessianType /**< New Hessian type. */ - ); - - - /* - * PROTECTED MEMBER FUNCTIONS - */ - protected: - /** Checks if Hessian happens to be the identity matrix, - * and sets corresponding status flag (otherwise the flag remains unaltered!). - * \return SUCCESSFUL_RETURN */ - returnValue checkForIdentityHessian( ); - - /** Determines type of constraints and bounds (i.e. implicitly fixed, unbounded etc.). - * \return SUCCESSFUL_RETURN \n - RET_SETUPSUBJECTTOTYPE_FAILED */ - returnValue setupSubjectToType( ); - - /** Computes the Cholesky decomposition R of the (simply projected) Hessian (i.e. R^T*R = Z^T*H*Z). - * It only works in the case where Z is a simple projection matrix! - * \return SUCCESSFUL_RETURN \n - * RET_INDEXLIST_CORRUPTED */ - returnValue setupCholeskyDecomposition( ); - - - /** Solves a QProblemB whose QP data is assumed to be stored in the member variables. - * A guess for its primal/dual optimal solution vectors and the corresponding - * optimal working set can be provided. - * \return SUCCESSFUL_RETURN \n - RET_INIT_FAILED \n - RET_INIT_FAILED_CHOLESKY \n - RET_INIT_FAILED_HOTSTART \n - RET_INIT_FAILED_INFEASIBILITY \n - RET_INIT_FAILED_UNBOUNDEDNESS \n - RET_MAX_NWSR_REACHED */ - returnValue solveInitialQP( const real_t* const xOpt, /**< Optimal primal solution vector. - * A NULL pointer can be passed. */ - const real_t* const yOpt, /**< Optimal dual solution vector. - * A NULL pointer can be passed. */ - const Bounds* const guessedBounds, /**< Guessed working set for solution (xOpt,yOpt). - * A NULL pointer can be passed. */ - int& nWSR, /**< Input: Maximum number of working set recalculations; \n - * Output: Number of performed working set recalculations. */ - real_t* const cputime /**< Output: CPU time required to solve QP (or to perform nWSR iterations). */ - ); - - - /** Obtains the desired working set for the auxiliary initial QP in - * accordance with the user specifications - * \return SUCCESSFUL_RETURN \n - RET_OBTAINING_WORKINGSET_FAILED \n - RET_INVALID_ARGUMENTS */ - returnValue obtainAuxiliaryWorkingSet( const real_t* const xOpt, /**< Optimal primal solution vector. - * If a NULL pointer is passed, all entries are assumed to be zero. */ - const real_t* const yOpt, /**< Optimal dual solution vector. - * If a NULL pointer is passed, all entries are assumed to be zero. */ - const Bounds* const guessedBounds, /**< Guessed working set for solution (xOpt,yOpt). */ - Bounds* auxiliaryBounds /**< Input: Allocated bound object. \n - * Ouput: Working set for auxiliary QP. */ - ) const; - - /** Setups bound data structure according to auxiliaryBounds. - * (If the working set shall be setup afresh, make sure that - * bounds data structure has been resetted!) - * \return SUCCESSFUL_RETURN \n - RET_SETUP_WORKINGSET_FAILED \n - RET_INVALID_ARGUMENTS \n - RET_UNKNOWN BUG */ - returnValue setupAuxiliaryWorkingSet( const Bounds* const auxiliaryBounds, /**< Working set for auxiliary QP. */ - BooleanType setupAfresh /**< Flag indicating if given working set shall be - * setup afresh or by updating the current one. */ - ); - - /** Setups the optimal primal/dual solution of the auxiliary initial QP. - * \return SUCCESSFUL_RETURN */ - returnValue setupAuxiliaryQPsolution( const real_t* const xOpt, /**< Optimal primal solution vector. - * If a NULL pointer is passed, all entries are set to zero. */ - const real_t* const yOpt /**< Optimal dual solution vector. - * If a NULL pointer is passed, all entries are set to zero. */ - ); - - /** Setups gradient of the auxiliary initial QP for given - * optimal primal/dual solution and given initial working set - * (assumes that members X, Y and BOUNDS have already been initialised!). - * \return SUCCESSFUL_RETURN */ - returnValue setupAuxiliaryQPgradient( ); - - /** Setups bounds of the auxiliary initial QP for given - * optimal primal/dual solution and given initial working set - * (assumes that members X, Y and BOUNDS have already been initialised!). - * \return SUCCESSFUL_RETURN \n - RET_UNKNOWN BUG */ - returnValue setupAuxiliaryQPbounds( BooleanType useRelaxation /**< Flag indicating if inactive bounds shall be relaxed. */ - ); - - - /** Adds a bound to active set (specialised version for the case where no constraints exist). - * \return SUCCESSFUL_RETURN \n - RET_ADDBOUND_FAILED */ - returnValue addBound( int number, /**< Number of bound to be added to active set. */ - SubjectToStatus B_status, /**< Status of new active bound. */ - BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ - ); - - /** Removes a bounds from active set (specialised version for the case where no constraints exist). - * \return SUCCESSFUL_RETURN \n - RET_HESSIAN_NOT_SPD \n - RET_REMOVEBOUND_FAILED */ - returnValue removeBound( int number, /**< Number of bound to be removed from active set. */ - BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ - ); - - - /** Solves the system Ra = b or R^Ta = b where R is an upper triangular matrix. - * \return SUCCESSFUL_RETURN \n - RET_DIV_BY_ZERO */ - returnValue backsolveR( const real_t* const b, /**< Right hand side vector. */ - BooleanType transposed, /**< Indicates if the transposed system shall be solved. */ - real_t* const a /**< Output: Solution vector */ - ); - - /** Solves the system Ra = b or R^Ta = b where R is an upper triangular matrix. \n - * Special variant for the case that this function is called from within "removeBound()". - * \return SUCCESSFUL_RETURN \n - RET_DIV_BY_ZERO */ - returnValue backsolveR( const real_t* const b, /**< Right hand side vector. */ - BooleanType transposed, /**< Indicates if the transposed system shall be solved. */ - BooleanType removingBound, /**< Indicates if function is called from "removeBound()". */ - real_t* const a /**< Output: Solution vector */ - ); - - - /** Determines step direction of the shift of the QP data. - * \return SUCCESSFUL_RETURN */ - returnValue hotstart_determineDataShift(const int* const FX_idx, /**< Index array of fixed variables. */ - const real_t* const g_new, /**< New gradient vector. */ - const real_t* const lb_new, /**< New lower bounds. */ - const real_t* const ub_new, /**< New upper bounds. */ - real_t* const delta_g, /**< Output: Step direction of gradient vector. */ - real_t* const delta_lb, /**< Output: Step direction of lower bounds. */ - real_t* const delta_ub, /**< Output: Step direction of upper bounds. */ - BooleanType& Delta_bB_isZero/**< Output: Indicates if active bounds are to be shifted. */ - ); - - - /** Checks if lower/upper bounds remain consistent - * (i.e. if lb <= ub) during the current step. - * \return BT_TRUE iff bounds remain consistent - */ - BooleanType areBoundsConsistent( const real_t* const delta_lb, /**< Step direction of lower bounds. */ - const real_t* const delta_ub /**< Step direction of upper bounds. */ - ) const; - - - /** Setups internal QP data. - * \return SUCCESSFUL_RETURN \n - RET_INVALID_ARGUMENTS */ - returnValue setupQPdata( const real_t* const _H, /**< Hessian matrix. */ - const real_t* const _R, /**< Cholesky factorization of the Hessian matrix. */ - const real_t* const _g, /**< Gradient vector. */ - const real_t* const _lb, /**< Lower bounds (on variables). \n - If no lower bounds exist, a NULL pointer can be passed. */ - const real_t* const _ub /**< Upper bounds (on variables). \n - If no upper bounds exist, a NULL pointer can be passed. */ - ); - - - /** Sets Hessian matrix of the QP. - * \return SUCCESSFUL_RETURN */ - inline returnValue setH( const real_t* const H_new /**< New Hessian matrix (with correct dimension!). */ - ); - - /** Changes gradient vector of the QP. - * \return SUCCESSFUL_RETURN */ - inline returnValue setG( const real_t* const g_new /**< New gradient vector (with correct dimension!). */ - ); - - /** Changes lower bound vector of the QP. - * \return SUCCESSFUL_RETURN */ - inline returnValue setLB( const real_t* const lb_new /**< New lower bound vector (with correct dimension!). */ - ); - - /** Changes single entry of lower bound vector of the QP. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue setLB( int number, /**< Number of entry to be changed. */ - real_t value /**< New value for entry of lower bound vector. */ - ); - - /** Changes upper bound vector of the QP. - * \return SUCCESSFUL_RETURN */ - inline returnValue setUB( const real_t* const ub_new /**< New upper bound vector (with correct dimension!). */ - ); - - /** Changes single entry of upper bound vector of the QP. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue setUB( int number, /**< Number of entry to be changed. */ - real_t value /**< New value for entry of upper bound vector. */ - ); - - - /** Computes parameters for the Givens matrix G for which [x,y]*G = [z,0] - * \return SUCCESSFUL_RETURN */ - inline void computeGivens( real_t xold, /**< Matrix entry to be normalised. */ - real_t yold, /**< Matrix entry to be annihilated. */ - real_t& xnew, /**< Output: Normalised matrix entry. */ - real_t& ynew, /**< Output: Annihilated matrix entry. */ - real_t& c, /**< Output: Cosine entry of Givens matrix. */ - real_t& s /**< Output: Sine entry of Givens matrix. */ - ) const; - - /** Applies Givens matrix determined by c and s (cf. computeGivens). - * \return SUCCESSFUL_RETURN */ - inline void applyGivens( real_t c, /**< Cosine entry of Givens matrix. */ - real_t s, /**< Sine entry of Givens matrix. */ - real_t xold, /**< Matrix entry to be transformed corresponding to - * the normalised entry of the original matrix. */ - real_t yold, /**< Matrix entry to be transformed corresponding to - * the annihilated entry of the original matrix. */ - real_t& xnew, /**< Output: Transformed matrix entry corresponding to - * the normalised entry of the original matrix. */ - real_t& ynew /**< Output: Transformed matrix entry corresponding to - * the annihilated entry of the original matrix. */ - ) const; - - - /* - * PRIVATE MEMBER FUNCTIONS - */ - private: - /** Determines step direction of the homotopy path. - * \return SUCCESSFUL_RETURN \n - RET_STEPDIRECTION_FAILED_CHOLESKY */ - returnValue hotstart_determineStepDirection(const int* const FR_idx, /**< Index array of free variables. */ - const int* const FX_idx, /**< Index array of fixed variables. */ - const real_t* const delta_g, /**< Step direction of gradient vector. */ - const real_t* const delta_lb, /**< Step direction of lower bounds. */ - const real_t* const delta_ub, /**< Step direction of upper bounds. */ - BooleanType Delta_bB_isZero, /**< Indicates if active bounds are to be shifted. */ - real_t* const delta_xFX, /**< Output: Primal homotopy step direction of fixed variables. */ - real_t* const delta_xFR, /**< Output: Primal homotopy step direction of free variables. */ - real_t* const delta_yFX /**< Output: Dual homotopy step direction of fixed variables' multiplier. */ - ); - - /** Determines the maximum possible step length along the homotopy path. - * \return SUCCESSFUL_RETURN */ - returnValue hotstart_determineStepLength( const int* const FR_idx, /**< Index array of free variables. */ - const int* const FX_idx, /**< Index array of fixed variables. */ - const real_t* const delta_lb, /**< Step direction of lower bounds. */ - const real_t* const delta_ub, /**< Step direction of upper bounds. */ - const real_t* const delta_xFR, /**< Primal homotopy step direction of free variables. */ - const real_t* const delta_yFX, /**< Dual homotopy step direction of fixed variables' multiplier. */ - int& BC_idx, /**< Output: Index of blocking constraint. */ - SubjectToStatus& BC_status /**< Output: Status of blocking constraint. */ - ); - - /** Performs a step along the homotopy path (and updates active set). - * \return SUCCESSFUL_RETURN \n - RET_OPTIMAL_SOLUTION_FOUND \n - RET_REMOVE_FROM_ACTIVESET_FAILED \n - RET_ADD_TO_ACTIVESET_FAILED \n - RET_QP_INFEASIBLE */ - returnValue hotstart_performStep( const int* const FR_idx, /**< Index array of free variables. */ - const int* const FX_idx, /**< Index array of fixed variables. */ - const real_t* const delta_g, /**< Step direction of gradient vector. */ - const real_t* const delta_lb, /**< Step direction of lower bounds. */ - const real_t* const delta_ub, /**< Step direction of upper bounds. */ - const real_t* const delta_xFX, /**< Primal homotopy step direction of fixed variables. */ - const real_t* const delta_xFR, /**< Primal homotopy step direction of free variables. */ - const real_t* const delta_yFX, /**< Dual homotopy step direction of fixed variables' multiplier. */ - int BC_idx, /**< Index of blocking constraint. */ - SubjectToStatus BC_status /**< Status of blocking constraint. */ - ); - - - #ifdef PC_DEBUG /* Define print functions only for debugging! */ - - /** Prints concise information on the current iteration. - * \return SUCCESSFUL_RETURN \n */ - returnValue printIteration( int iteration, /**< Number of current iteration. */ - int BC_idx, /**< Index of blocking bound. */ - SubjectToStatus BC_status /**< Status of blocking bound. */ - ); - - #endif /* PC_DEBUG */ - - - /** Determines the maximum violation of the KKT optimality conditions - * of the current iterate within the QProblemB object. - * \return SUCCESSFUL_RETURN \n - * RET_INACCURATE_SOLUTION \n - * RET_NO_SOLUTION */ - returnValue checkKKTconditions( ); - - - /* - * PROTECTED MEMBER VARIABLES - */ - protected: - real_t H[NVMAX*NVMAX]; /**< Hessian matrix. */ - BooleanType hasHessian; /**< Flag indicating whether H contains Hessian or corresponding Cholesky factor R; \sa init. */ - - real_t g[NVMAX]; /**< Gradient. */ - real_t lb[NVMAX]; /**< Lower bound vector (on variables). */ - real_t ub[NVMAX]; /**< Upper bound vector (on variables). */ - - Bounds bounds; /**< Data structure for problem's bounds. */ - - real_t R[NVMAX*NVMAX]; /**< Cholesky decomposition of H (i.e. H = R^T*R). */ - BooleanType hasCholesky; /**< Flag indicating whether Cholesky decomposition has already been setup. */ - - real_t x[NVMAX]; /**< Primal solution vector. */ - real_t y[NVMAX+NCMAX]; /**< Dual solution vector. */ - - real_t tau; /**< Last homotopy step length. */ - - QProblemStatus status; /**< Current status of the solution process. */ - - BooleanType infeasible; /**< QP infeasible? */ - BooleanType unbounded; /**< QP unbounded? */ - - HessianType hessianType; /**< Type of Hessian matrix. */ - - PrintLevel printlevel; /**< Print level. */ - - int count; /**< Counts the number of hotstart function calls (internal usage only!). */ -}; - - -#include - -#endif /* QPOASES_QPROBLEMB_HPP */ - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file INCLUDE/QProblemB.hpp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Declaration of the QProblemB class which is able to use the newly + * developed online active set strategy for parametric quadratic programming + * for problems with (simple) bounds only. + */ + + + +#ifndef QPOASES_QPROBLEMB_HPP +#define QPOASES_QPROBLEMB_HPP + + +#include + + + +class SolutionAnalysis; + +/** Class for setting up and solving quadratic programs with (simple) bounds only. + * The main feature is the possibily to use the newly developed online active set strategy + * for parametric quadratic programming. + * + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + */ +class QProblemB +{ + /* allow SolutionAnalysis class to access private members */ + friend class SolutionAnalysis; + + /* + * PUBLIC MEMBER FUNCTIONS + */ + public: + /** Default constructor. */ + QProblemB( ); + + /** Constructor which takes the QP dimension only. */ + QProblemB( int _nV /**< Number of variables. */ + ); + + /** Copy constructor (deep copy). */ + QProblemB( const QProblemB& rhs /**< Rhs object. */ + ); + + /** Destructor. */ + ~QProblemB( ); + + /** Assignment operator (deep copy). */ + QProblemB& operator=( const QProblemB& rhs /**< Rhs object. */ + ); + + + /** Clears all data structures of QProblemB except for QP data. + * \return SUCCESSFUL_RETURN \n + RET_RESET_FAILED */ + returnValue reset( ); + + + /** Initialises a QProblemB with given QP data and solves it + * using an initial homotopy with empty working set (at most nWSR iterations). + * \return SUCCESSFUL_RETURN \n + RET_INIT_FAILED \n + RET_INIT_FAILED_CHOLESKY \n + RET_INIT_FAILED_HOTSTART \n + RET_INIT_FAILED_INFEASIBILITY \n + RET_INIT_FAILED_UNBOUNDEDNESS \n + RET_MAX_NWSR_REACHED \n + RET_INVALID_ARGUMENTS \n + RET_INACCURATE_SOLUTION \n + RET_NO_SOLUTION */ + returnValue init( const real_t* const _H, /**< Hessian matrix. */ + const real_t* const _g, /**< Gradient vector. */ + const real_t* const _lb, /**< Lower bounds (on variables). \n + If no lower bounds exist, a NULL pointer can be passed. */ + const real_t* const _ub, /**< Upper bounds (on variables). \n + If no upper bounds exist, a NULL pointer can be passed. */ + int& nWSR, /**< Input: Maximum number of working set recalculations when using initial homotopy. \n + Output: Number of performed working set recalculations. */ + const real_t* const yOpt = 0, /**< Initial guess for dual solution vector. */ + real_t* const cputime = 0 /**< Output: CPU time required to initialise QP. */ + ); + + + /** Initialises a QProblemB with given QP data and solves it + * using an initial homotopy with empty working set (at most nWSR iterations). + * \return SUCCESSFUL_RETURN \n + RET_INIT_FAILED \n + RET_INIT_FAILED_CHOLESKY \n + RET_INIT_FAILED_HOTSTART \n + RET_INIT_FAILED_INFEASIBILITY \n + RET_INIT_FAILED_UNBOUNDEDNESS \n + RET_MAX_NWSR_REACHED \n + RET_INVALID_ARGUMENTS \n + RET_INACCURATE_SOLUTION \n + RET_NO_SOLUTION */ + returnValue init( const real_t* const _H, /**< Hessian matrix. */ + const real_t* const _R, /**< Cholesky factorization of the Hessian matrix. */ + const real_t* const _g, /**< Gradient vector. */ + const real_t* const _lb, /**< Lower bounds (on variables). \n + If no lower bounds exist, a NULL pointer can be passed. */ + const real_t* const _ub, /**< Upper bounds (on variables). \n + If no upper bounds exist, a NULL pointer can be passed. */ + int& nWSR, /**< Input: Maximum number of working set recalculations when using initial homotopy. \n + Output: Number of performed working set recalculations. */ + const real_t* const yOpt = 0, /**< Initial guess for dual solution vector. */ + real_t* const cputime = 0 /**< Output: CPU time required to initialise QP. */ + ); + + + /** Solves an initialised QProblemB using online active set strategy. + * \return SUCCESSFUL_RETURN \n + RET_MAX_NWSR_REACHED \n + RET_HOTSTART_FAILED_AS_QP_NOT_INITIALISED \n + RET_HOTSTART_FAILED \n + RET_SHIFT_DETERMINATION_FAILED \n + RET_STEPDIRECTION_DETERMINATION_FAILED \n + RET_STEPLENGTH_DETERMINATION_FAILED \n + RET_HOMOTOPY_STEP_FAILED \n + RET_HOTSTART_STOPPED_INFEASIBILITY \n + RET_HOTSTART_STOPPED_UNBOUNDEDNESS \n + RET_INACCURATE_SOLUTION \n + RET_NO_SOLUTION */ + returnValue hotstart( const real_t* const g_new, /**< Gradient of neighbouring QP to be solved. */ + const real_t* const lb_new, /**< Lower bounds of neighbouring QP to be solved. \n + If no lower bounds exist, a NULL pointer can be passed. */ + const real_t* const ub_new, /**< Upper bounds of neighbouring QP to be solved. \n + If no upper bounds exist, a NULL pointer can be passed. */ + int& nWSR, /**< Input: Maximum number of working set recalculations; \n + Output: Number of performed working set recalculations. */ + real_t* const cputime /**< Output: CPU time required to solve QP (or to perform nWSR iterations). */ + ); + + + /** Returns Hessian matrix of the QP (deep copy). + * \return SUCCESSFUL_RETURN */ + inline returnValue getH( real_t* const _H /**< Array of appropriate dimension for copying Hessian matrix.*/ + ) const; + + /** Returns gradient vector of the QP (deep copy). + * \return SUCCESSFUL_RETURN */ + inline returnValue getG( real_t* const _g /**< Array of appropriate dimension for copying gradient vector.*/ + ) const; + + /** Returns lower bound vector of the QP (deep copy). + * \return SUCCESSFUL_RETURN */ + inline returnValue getLB( real_t* const _lb /**< Array of appropriate dimension for copying lower bound vector.*/ + ) const; + + /** Returns single entry of lower bound vector of the QP. + * \return SUCCESSFUL_RETURN \n + RET_INDEX_OUT_OF_BOUNDS */ + inline returnValue getLB( int number, /**< Number of entry to be returned. */ + real_t& value /**< Output: lb[number].*/ + ) const; + + /** Returns upper bound vector of the QP (deep copy). + * \return SUCCESSFUL_RETURN */ + inline returnValue getUB( real_t* const _ub /**< Array of appropriate dimension for copying upper bound vector.*/ + ) const; + + /** Returns single entry of upper bound vector of the QP. + * \return SUCCESSFUL_RETURN \n + RET_INDEX_OUT_OF_BOUNDS */ + inline returnValue getUB( int number, /**< Number of entry to be returned. */ + real_t& value /**< Output: ub[number].*/ + ) const; + + + /** Returns current bounds object of the QP (deep copy). + * \return SUCCESSFUL_RETURN */ + inline returnValue getBounds( Bounds* const _bounds /** Output: Bounds object. */ + ) const; + + + /** Returns the number of variables. + * \return Number of variables. */ + inline int getNV( ) const; + + /** Returns the number of free variables. + * \return Number of free variables. */ + inline int getNFR( ); + + /** Returns the number of fixed variables. + * \return Number of fixed variables. */ + inline int getNFX( ); + + /** Returns the number of implicitly fixed variables. + * \return Number of implicitly fixed variables. */ + inline int getNFV( ) const; + + /** Returns the dimension of null space. + * \return Dimension of null space. */ + int getNZ( ); + + + /** Returns the optimal objective function value. + * \return finite value: Optimal objective function value (QP was solved) \n + +infinity: QP was not yet solved */ + real_t getObjVal( ) const; + + /** Returns the objective function value at an arbitrary point x. + * \return Objective function value at point x */ + real_t getObjVal( const real_t* const _x /**< Point at which the objective function shall be evaluated. */ + ) const; + + /** Returns the primal solution vector. + * \return SUCCESSFUL_RETURN \n + RET_QP_NOT_SOLVED */ + returnValue getPrimalSolution( real_t* const xOpt /**< Output: Primal solution vector (if QP has been solved). */ + ) const; + + /** Returns the dual solution vector. + * \return SUCCESSFUL_RETURN \n + RET_QP_NOT_SOLVED */ + returnValue getDualSolution( real_t* const yOpt /**< Output: Dual solution vector (if QP has been solved). */ + ) const; + + + /** Returns status of the solution process. + * \return Status of solution process. */ + inline QProblemStatus getStatus( ) const; + + + /** Returns if the QProblem object is initialised. + * \return BT_TRUE: QProblemB initialised \n + BT_FALSE: QProblemB not initialised */ + inline BooleanType isInitialised( ) const; + + /** Returns if the QP has been solved. + * \return BT_TRUE: QProblemB solved \n + BT_FALSE: QProblemB not solved */ + inline BooleanType isSolved( ) const; + + /** Returns if the QP is infeasible. + * \return BT_TRUE: QP infeasible \n + BT_FALSE: QP feasible (or not known to be infeasible!) */ + inline BooleanType isInfeasible( ) const; + + /** Returns if the QP is unbounded. + * \return BT_TRUE: QP unbounded \n + BT_FALSE: QP unbounded (or not known to be unbounded!) */ + inline BooleanType isUnbounded( ) const; + + + /** Returns the print level. + * \return Print level. */ + inline PrintLevel getPrintLevel( ) const; + + /** Changes the print level. + * \return SUCCESSFUL_RETURN */ + returnValue setPrintLevel( PrintLevel _printlevel /**< New print level. */ + ); + + + /** Returns Hessian type flag (type is not determined due to this call!). + * \return Hessian type. */ + inline HessianType getHessianType( ) const; + + /** Changes the print level. + * \return SUCCESSFUL_RETURN */ + inline returnValue setHessianType( HessianType _hessianType /**< New Hessian type. */ + ); + + + /* + * PROTECTED MEMBER FUNCTIONS + */ + protected: + /** Checks if Hessian happens to be the identity matrix, + * and sets corresponding status flag (otherwise the flag remains unaltered!). + * \return SUCCESSFUL_RETURN */ + returnValue checkForIdentityHessian( ); + + /** Determines type of constraints and bounds (i.e. implicitly fixed, unbounded etc.). + * \return SUCCESSFUL_RETURN \n + RET_SETUPSUBJECTTOTYPE_FAILED */ + returnValue setupSubjectToType( ); + + /** Computes the Cholesky decomposition R of the (simply projected) Hessian (i.e. R^T*R = Z^T*H*Z). + * It only works in the case where Z is a simple projection matrix! + * \return SUCCESSFUL_RETURN \n + * RET_INDEXLIST_CORRUPTED */ + returnValue setupCholeskyDecomposition( ); + + + /** Solves a QProblemB whose QP data is assumed to be stored in the member variables. + * A guess for its primal/dual optimal solution vectors and the corresponding + * optimal working set can be provided. + * \return SUCCESSFUL_RETURN \n + RET_INIT_FAILED \n + RET_INIT_FAILED_CHOLESKY \n + RET_INIT_FAILED_HOTSTART \n + RET_INIT_FAILED_INFEASIBILITY \n + RET_INIT_FAILED_UNBOUNDEDNESS \n + RET_MAX_NWSR_REACHED */ + returnValue solveInitialQP( const real_t* const xOpt, /**< Optimal primal solution vector. + * A NULL pointer can be passed. */ + const real_t* const yOpt, /**< Optimal dual solution vector. + * A NULL pointer can be passed. */ + const Bounds* const guessedBounds, /**< Guessed working set for solution (xOpt,yOpt). + * A NULL pointer can be passed. */ + int& nWSR, /**< Input: Maximum number of working set recalculations; \n + * Output: Number of performed working set recalculations. */ + real_t* const cputime /**< Output: CPU time required to solve QP (or to perform nWSR iterations). */ + ); + + + /** Obtains the desired working set for the auxiliary initial QP in + * accordance with the user specifications + * \return SUCCESSFUL_RETURN \n + RET_OBTAINING_WORKINGSET_FAILED \n + RET_INVALID_ARGUMENTS */ + returnValue obtainAuxiliaryWorkingSet( const real_t* const xOpt, /**< Optimal primal solution vector. + * If a NULL pointer is passed, all entries are assumed to be zero. */ + const real_t* const yOpt, /**< Optimal dual solution vector. + * If a NULL pointer is passed, all entries are assumed to be zero. */ + const Bounds* const guessedBounds, /**< Guessed working set for solution (xOpt,yOpt). */ + Bounds* auxiliaryBounds /**< Input: Allocated bound object. \n + * Ouput: Working set for auxiliary QP. */ + ) const; + + /** Setups bound data structure according to auxiliaryBounds. + * (If the working set shall be setup afresh, make sure that + * bounds data structure has been resetted!) + * \return SUCCESSFUL_RETURN \n + RET_SETUP_WORKINGSET_FAILED \n + RET_INVALID_ARGUMENTS \n + RET_UNKNOWN BUG */ + returnValue setupAuxiliaryWorkingSet( const Bounds* const auxiliaryBounds, /**< Working set for auxiliary QP. */ + BooleanType setupAfresh /**< Flag indicating if given working set shall be + * setup afresh or by updating the current one. */ + ); + + /** Setups the optimal primal/dual solution of the auxiliary initial QP. + * \return SUCCESSFUL_RETURN */ + returnValue setupAuxiliaryQPsolution( const real_t* const xOpt, /**< Optimal primal solution vector. + * If a NULL pointer is passed, all entries are set to zero. */ + const real_t* const yOpt /**< Optimal dual solution vector. + * If a NULL pointer is passed, all entries are set to zero. */ + ); + + /** Setups gradient of the auxiliary initial QP for given + * optimal primal/dual solution and given initial working set + * (assumes that members X, Y and BOUNDS have already been initialised!). + * \return SUCCESSFUL_RETURN */ + returnValue setupAuxiliaryQPgradient( ); + + /** Setups bounds of the auxiliary initial QP for given + * optimal primal/dual solution and given initial working set + * (assumes that members X, Y and BOUNDS have already been initialised!). + * \return SUCCESSFUL_RETURN \n + RET_UNKNOWN BUG */ + returnValue setupAuxiliaryQPbounds( BooleanType useRelaxation /**< Flag indicating if inactive bounds shall be relaxed. */ + ); + + + /** Adds a bound to active set (specialised version for the case where no constraints exist). + * \return SUCCESSFUL_RETURN \n + RET_ADDBOUND_FAILED */ + returnValue addBound( int number, /**< Number of bound to be added to active set. */ + SubjectToStatus B_status, /**< Status of new active bound. */ + BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ + ); + + /** Removes a bounds from active set (specialised version for the case where no constraints exist). + * \return SUCCESSFUL_RETURN \n + RET_HESSIAN_NOT_SPD \n + RET_REMOVEBOUND_FAILED */ + returnValue removeBound( int number, /**< Number of bound to be removed from active set. */ + BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ + ); + + + /** Solves the system Ra = b or R^Ta = b where R is an upper triangular matrix. + * \return SUCCESSFUL_RETURN \n + RET_DIV_BY_ZERO */ + returnValue backsolveR( const real_t* const b, /**< Right hand side vector. */ + BooleanType transposed, /**< Indicates if the transposed system shall be solved. */ + real_t* const a /**< Output: Solution vector */ + ); + + /** Solves the system Ra = b or R^Ta = b where R is an upper triangular matrix. \n + * Special variant for the case that this function is called from within "removeBound()". + * \return SUCCESSFUL_RETURN \n + RET_DIV_BY_ZERO */ + returnValue backsolveR( const real_t* const b, /**< Right hand side vector. */ + BooleanType transposed, /**< Indicates if the transposed system shall be solved. */ + BooleanType removingBound, /**< Indicates if function is called from "removeBound()". */ + real_t* const a /**< Output: Solution vector */ + ); + + + /** Determines step direction of the shift of the QP data. + * \return SUCCESSFUL_RETURN */ + returnValue hotstart_determineDataShift(const int* const FX_idx, /**< Index array of fixed variables. */ + const real_t* const g_new, /**< New gradient vector. */ + const real_t* const lb_new, /**< New lower bounds. */ + const real_t* const ub_new, /**< New upper bounds. */ + real_t* const delta_g, /**< Output: Step direction of gradient vector. */ + real_t* const delta_lb, /**< Output: Step direction of lower bounds. */ + real_t* const delta_ub, /**< Output: Step direction of upper bounds. */ + BooleanType& Delta_bB_isZero/**< Output: Indicates if active bounds are to be shifted. */ + ); + + + /** Checks if lower/upper bounds remain consistent + * (i.e. if lb <= ub) during the current step. + * \return BT_TRUE iff bounds remain consistent + */ + BooleanType areBoundsConsistent( const real_t* const delta_lb, /**< Step direction of lower bounds. */ + const real_t* const delta_ub /**< Step direction of upper bounds. */ + ) const; + + + /** Setups internal QP data. + * \return SUCCESSFUL_RETURN \n + RET_INVALID_ARGUMENTS */ + returnValue setupQPdata( const real_t* const _H, /**< Hessian matrix. */ + const real_t* const _R, /**< Cholesky factorization of the Hessian matrix. */ + const real_t* const _g, /**< Gradient vector. */ + const real_t* const _lb, /**< Lower bounds (on variables). \n + If no lower bounds exist, a NULL pointer can be passed. */ + const real_t* const _ub /**< Upper bounds (on variables). \n + If no upper bounds exist, a NULL pointer can be passed. */ + ); + + + /** Sets Hessian matrix of the QP. + * \return SUCCESSFUL_RETURN */ + inline returnValue setH( const real_t* const H_new /**< New Hessian matrix (with correct dimension!). */ + ); + + /** Changes gradient vector of the QP. + * \return SUCCESSFUL_RETURN */ + inline returnValue setG( const real_t* const g_new /**< New gradient vector (with correct dimension!). */ + ); + + /** Changes lower bound vector of the QP. + * \return SUCCESSFUL_RETURN */ + inline returnValue setLB( const real_t* const lb_new /**< New lower bound vector (with correct dimension!). */ + ); + + /** Changes single entry of lower bound vector of the QP. + * \return SUCCESSFUL_RETURN \n + RET_INDEX_OUT_OF_BOUNDS */ + inline returnValue setLB( int number, /**< Number of entry to be changed. */ + real_t value /**< New value for entry of lower bound vector. */ + ); + + /** Changes upper bound vector of the QP. + * \return SUCCESSFUL_RETURN */ + inline returnValue setUB( const real_t* const ub_new /**< New upper bound vector (with correct dimension!). */ + ); + + /** Changes single entry of upper bound vector of the QP. + * \return SUCCESSFUL_RETURN \n + RET_INDEX_OUT_OF_BOUNDS */ + inline returnValue setUB( int number, /**< Number of entry to be changed. */ + real_t value /**< New value for entry of upper bound vector. */ + ); + + + /** Computes parameters for the Givens matrix G for which [x,y]*G = [z,0] + * \return SUCCESSFUL_RETURN */ + inline void computeGivens( real_t xold, /**< Matrix entry to be normalised. */ + real_t yold, /**< Matrix entry to be annihilated. */ + real_t& xnew, /**< Output: Normalised matrix entry. */ + real_t& ynew, /**< Output: Annihilated matrix entry. */ + real_t& c, /**< Output: Cosine entry of Givens matrix. */ + real_t& s /**< Output: Sine entry of Givens matrix. */ + ) const; + + /** Applies Givens matrix determined by c and s (cf. computeGivens). + * \return SUCCESSFUL_RETURN */ + inline void applyGivens( real_t c, /**< Cosine entry of Givens matrix. */ + real_t s, /**< Sine entry of Givens matrix. */ + real_t xold, /**< Matrix entry to be transformed corresponding to + * the normalised entry of the original matrix. */ + real_t yold, /**< Matrix entry to be transformed corresponding to + * the annihilated entry of the original matrix. */ + real_t& xnew, /**< Output: Transformed matrix entry corresponding to + * the normalised entry of the original matrix. */ + real_t& ynew /**< Output: Transformed matrix entry corresponding to + * the annihilated entry of the original matrix. */ + ) const; + + + /* + * PRIVATE MEMBER FUNCTIONS + */ + private: + /** Determines step direction of the homotopy path. + * \return SUCCESSFUL_RETURN \n + RET_STEPDIRECTION_FAILED_CHOLESKY */ + returnValue hotstart_determineStepDirection(const int* const FR_idx, /**< Index array of free variables. */ + const int* const FX_idx, /**< Index array of fixed variables. */ + const real_t* const delta_g, /**< Step direction of gradient vector. */ + const real_t* const delta_lb, /**< Step direction of lower bounds. */ + const real_t* const delta_ub, /**< Step direction of upper bounds. */ + BooleanType Delta_bB_isZero, /**< Indicates if active bounds are to be shifted. */ + real_t* const delta_xFX, /**< Output: Primal homotopy step direction of fixed variables. */ + real_t* const delta_xFR, /**< Output: Primal homotopy step direction of free variables. */ + real_t* const delta_yFX /**< Output: Dual homotopy step direction of fixed variables' multiplier. */ + ); + + /** Determines the maximum possible step length along the homotopy path. + * \return SUCCESSFUL_RETURN */ + returnValue hotstart_determineStepLength( const int* const FR_idx, /**< Index array of free variables. */ + const int* const FX_idx, /**< Index array of fixed variables. */ + const real_t* const delta_lb, /**< Step direction of lower bounds. */ + const real_t* const delta_ub, /**< Step direction of upper bounds. */ + const real_t* const delta_xFR, /**< Primal homotopy step direction of free variables. */ + const real_t* const delta_yFX, /**< Dual homotopy step direction of fixed variables' multiplier. */ + int& BC_idx, /**< Output: Index of blocking constraint. */ + SubjectToStatus& BC_status /**< Output: Status of blocking constraint. */ + ); + + /** Performs a step along the homotopy path (and updates active set). + * \return SUCCESSFUL_RETURN \n + RET_OPTIMAL_SOLUTION_FOUND \n + RET_REMOVE_FROM_ACTIVESET_FAILED \n + RET_ADD_TO_ACTIVESET_FAILED \n + RET_QP_INFEASIBLE */ + returnValue hotstart_performStep( const int* const FR_idx, /**< Index array of free variables. */ + const int* const FX_idx, /**< Index array of fixed variables. */ + const real_t* const delta_g, /**< Step direction of gradient vector. */ + const real_t* const delta_lb, /**< Step direction of lower bounds. */ + const real_t* const delta_ub, /**< Step direction of upper bounds. */ + const real_t* const delta_xFX, /**< Primal homotopy step direction of fixed variables. */ + const real_t* const delta_xFR, /**< Primal homotopy step direction of free variables. */ + const real_t* const delta_yFX, /**< Dual homotopy step direction of fixed variables' multiplier. */ + int BC_idx, /**< Index of blocking constraint. */ + SubjectToStatus BC_status /**< Status of blocking constraint. */ + ); + + + #ifdef PC_DEBUG /* Define print functions only for debugging! */ + + /** Prints concise information on the current iteration. + * \return SUCCESSFUL_RETURN \n */ + returnValue printIteration( int iteration, /**< Number of current iteration. */ + int BC_idx, /**< Index of blocking bound. */ + SubjectToStatus BC_status /**< Status of blocking bound. */ + ); + + #endif /* PC_DEBUG */ + + + /** Determines the maximum violation of the KKT optimality conditions + * of the current iterate within the QProblemB object. + * \return SUCCESSFUL_RETURN \n + * RET_INACCURATE_SOLUTION \n + * RET_NO_SOLUTION */ + returnValue checkKKTconditions( ); + + + /* + * PROTECTED MEMBER VARIABLES + */ + protected: + real_t H[NVMAX*NVMAX]; /**< Hessian matrix. */ + BooleanType hasHessian; /**< Flag indicating whether H contains Hessian or corresponding Cholesky factor R; \sa init. */ + + real_t g[NVMAX]; /**< Gradient. */ + real_t lb[NVMAX]; /**< Lower bound vector (on variables). */ + real_t ub[NVMAX]; /**< Upper bound vector (on variables). */ + + Bounds bounds; /**< Data structure for problem's bounds. */ + + real_t R[NVMAX*NVMAX]; /**< Cholesky decomposition of H (i.e. H = R^T*R). */ + BooleanType hasCholesky; /**< Flag indicating whether Cholesky decomposition has already been setup. */ + + real_t x[NVMAX]; /**< Primal solution vector. */ + real_t y[NVMAX+NCMAX]; /**< Dual solution vector. */ + + real_t tau; /**< Last homotopy step length. */ + + QProblemStatus status; /**< Current status of the solution process. */ + + BooleanType infeasible; /**< QP infeasible? */ + BooleanType unbounded; /**< QP unbounded? */ + + HessianType hessianType; /**< Type of Hessian matrix. */ + + PrintLevel printlevel; /**< Print level. */ + + int count; /**< Counts the number of hotstart function calls (internal usage only!). */ +}; + + +#include + +#endif /* QPOASES_QPROBLEMB_HPP */ + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/INCLUDE/SubjectTo.hpp b/phonelibs/qpoases/INCLUDE/SubjectTo.hpp index a014843ceabb24..e07bf0421ec799 100644 --- a/phonelibs/qpoases/INCLUDE/SubjectTo.hpp +++ b/phonelibs/qpoases/INCLUDE/SubjectTo.hpp @@ -1,178 +1,178 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/SubjectTo.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Declaration of the SubjectTo class designed to manage working sets of - * constraints and bounds within a QProblem. - */ - - -#ifndef QPOASES_SUBJECTTO_HPP -#define QPOASES_SUBJECTTO_HPP - - -#include - - - -/** This class manages working sets of constraints and bounds by storing - * index sets and other status information. - * - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - */ -class SubjectTo -{ - /* - * PUBLIC MEMBER FUNCTIONS - */ - public: - /** Default constructor. */ - SubjectTo( ); - - /** Copy constructor (deep copy). */ - SubjectTo( const SubjectTo& rhs /**< Rhs object. */ - ); - - /** Destructor. */ - ~SubjectTo( ); - - /** Assignment operator (deep copy). */ - SubjectTo& operator=( const SubjectTo& rhs /**< Rhs object. */ - ); - - - /** Pseudo-constructor takes the number of constraints or bounds. - * \return SUCCESSFUL_RETURN */ - returnValue init( int n /**< Number of constraints or bounds. */ - ); - - - /** Returns type of (constraints') bound. - * \return Type of (constraints') bound \n - RET_INDEX_OUT_OF_BOUNDS */ - inline SubjectToType getType( int i /**< Number of (constraints') bound. */ - ) const ; - - /** Returns status of (constraints') bound. - * \return Status of (constraints') bound \n - ST_UNDEFINED */ - inline SubjectToStatus getStatus( int i /**< Number of (constraints') bound. */ - ) const; - - - /** Sets type of (constraints') bound. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue setType( int i, /**< Number of (constraints') bound. */ - SubjectToType value /**< Type of (constraints') bound. */ - ); - - /** Sets status of (constraints') bound. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue setStatus( int i, /**< Number of (constraints') bound. */ - SubjectToStatus value /**< Status of (constraints') bound. */ - ); - - - /** Sets status of lower (constraints') bounds. */ - inline void setNoLower( BooleanType _status /**< Status of lower (constraints') bounds. */ - ); - - /** Sets status of upper (constraints') bounds. */ - inline void setNoUpper( BooleanType _status /**< Status of upper (constraints') bounds. */ - ); - - - /** Returns status of lower (constraints') bounds. - * \return BT_TRUE if there is no lower (constraints') bound on any variable. */ - inline BooleanType isNoLower( ) const; - - /** Returns status of upper bounds. - * \return BT_TRUE if there is no upper (constraints') bound on any variable. */ - inline BooleanType isNoUpper( ) const; - - - /* - * PROTECTED MEMBER FUNCTIONS - */ - protected: - /** Adds the index of a new constraint or bound to index set. - * \return SUCCESSFUL_RETURN \n - RET_ADDINDEX_FAILED */ - returnValue addIndex( Indexlist* const indexlist, /**< Index list to which the new index shall be added. */ - int newnumber, /**< Number of new constraint or bound. */ - SubjectToStatus newstatus /**< Status of new constraint or bound. */ - ); - - /** Removes the index of a constraint or bound from index set. - * \return SUCCESSFUL_RETURN \n - RET_UNKNOWN_BUG */ - returnValue removeIndex( Indexlist* const indexlist, /**< Index list from which the new index shall be removed. */ - int removenumber /**< Number of constraint or bound to be removed. */ - ); - - /** Swaps the indices of two constraints or bounds within the index set. - * \return SUCCESSFUL_RETURN \n - RET_SWAPINDEX_FAILED */ - returnValue swapIndex( Indexlist* const indexlist, /**< Index list in which the indices shold be swapped. */ - int number1, /**< Number of first constraint or bound. */ - int number2 /**< Number of second constraint or bound. */ - ); - - - /* - * PROTECTED MEMBER VARIABLES - */ - protected: - SubjectToType type[NVMAX+NCMAX]; /**< Type of constraints/bounds. */ - SubjectToStatus status[NVMAX+NCMAX]; /**< Status of constraints/bounds. */ - - BooleanType noLower; /**< This flag indicates if there is no lower bound on any variable. */ - BooleanType noUpper; /**< This flag indicates if there is no upper bound on any variable. */ - - - /* - * PRIVATE MEMBER VARIABLES - */ - private: - int size; -}; - - - -#include - -#endif /* QPOASES_SUBJECTTO_HPP */ - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file INCLUDE/SubjectTo.hpp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Declaration of the SubjectTo class designed to manage working sets of + * constraints and bounds within a QProblem. + */ + + +#ifndef QPOASES_SUBJECTTO_HPP +#define QPOASES_SUBJECTTO_HPP + + +#include + + + +/** This class manages working sets of constraints and bounds by storing + * index sets and other status information. + * + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + */ +class SubjectTo +{ + /* + * PUBLIC MEMBER FUNCTIONS + */ + public: + /** Default constructor. */ + SubjectTo( ); + + /** Copy constructor (deep copy). */ + SubjectTo( const SubjectTo& rhs /**< Rhs object. */ + ); + + /** Destructor. */ + ~SubjectTo( ); + + /** Assignment operator (deep copy). */ + SubjectTo& operator=( const SubjectTo& rhs /**< Rhs object. */ + ); + + + /** Pseudo-constructor takes the number of constraints or bounds. + * \return SUCCESSFUL_RETURN */ + returnValue init( int n /**< Number of constraints or bounds. */ + ); + + + /** Returns type of (constraints') bound. + * \return Type of (constraints') bound \n + RET_INDEX_OUT_OF_BOUNDS */ + inline SubjectToType getType( int i /**< Number of (constraints') bound. */ + ) const ; + + /** Returns status of (constraints') bound. + * \return Status of (constraints') bound \n + ST_UNDEFINED */ + inline SubjectToStatus getStatus( int i /**< Number of (constraints') bound. */ + ) const; + + + /** Sets type of (constraints') bound. + * \return SUCCESSFUL_RETURN \n + RET_INDEX_OUT_OF_BOUNDS */ + inline returnValue setType( int i, /**< Number of (constraints') bound. */ + SubjectToType value /**< Type of (constraints') bound. */ + ); + + /** Sets status of (constraints') bound. + * \return SUCCESSFUL_RETURN \n + RET_INDEX_OUT_OF_BOUNDS */ + inline returnValue setStatus( int i, /**< Number of (constraints') bound. */ + SubjectToStatus value /**< Status of (constraints') bound. */ + ); + + + /** Sets status of lower (constraints') bounds. */ + inline void setNoLower( BooleanType _status /**< Status of lower (constraints') bounds. */ + ); + + /** Sets status of upper (constraints') bounds. */ + inline void setNoUpper( BooleanType _status /**< Status of upper (constraints') bounds. */ + ); + + + /** Returns status of lower (constraints') bounds. + * \return BT_TRUE if there is no lower (constraints') bound on any variable. */ + inline BooleanType isNoLower( ) const; + + /** Returns status of upper bounds. + * \return BT_TRUE if there is no upper (constraints') bound on any variable. */ + inline BooleanType isNoUpper( ) const; + + + /* + * PROTECTED MEMBER FUNCTIONS + */ + protected: + /** Adds the index of a new constraint or bound to index set. + * \return SUCCESSFUL_RETURN \n + RET_ADDINDEX_FAILED */ + returnValue addIndex( Indexlist* const indexlist, /**< Index list to which the new index shall be added. */ + int newnumber, /**< Number of new constraint or bound. */ + SubjectToStatus newstatus /**< Status of new constraint or bound. */ + ); + + /** Removes the index of a constraint or bound from index set. + * \return SUCCESSFUL_RETURN \n + RET_UNKNOWN_BUG */ + returnValue removeIndex( Indexlist* const indexlist, /**< Index list from which the new index shall be removed. */ + int removenumber /**< Number of constraint or bound to be removed. */ + ); + + /** Swaps the indices of two constraints or bounds within the index set. + * \return SUCCESSFUL_RETURN \n + RET_SWAPINDEX_FAILED */ + returnValue swapIndex( Indexlist* const indexlist, /**< Index list in which the indices shold be swapped. */ + int number1, /**< Number of first constraint or bound. */ + int number2 /**< Number of second constraint or bound. */ + ); + + + /* + * PROTECTED MEMBER VARIABLES + */ + protected: + SubjectToType type[NVMAX+NCMAX]; /**< Type of constraints/bounds. */ + SubjectToStatus status[NVMAX+NCMAX]; /**< Status of constraints/bounds. */ + + BooleanType noLower; /**< This flag indicates if there is no lower bound on any variable. */ + BooleanType noUpper; /**< This flag indicates if there is no upper bound on any variable. */ + + + /* + * PRIVATE MEMBER VARIABLES + */ + private: + int size; +}; + + + +#include + +#endif /* QPOASES_SUBJECTTO_HPP */ + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/INCLUDE/Types.hpp b/phonelibs/qpoases/INCLUDE/Types.hpp index 330f187c1e3d47..5b873ad070a875 100644 --- a/phonelibs/qpoases/INCLUDE/Types.hpp +++ b/phonelibs/qpoases/INCLUDE/Types.hpp @@ -1,131 +1,131 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/Types.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2008 - * - * Declaration of all non-built-in types (except for classes). - */ - - -#ifndef QPOASES_TYPES_HPP -#define QPOASES_TYPES_HPP - - - -/** Define real_t for facilitating switching between double and float. */ -// typedef double real_t; - - -/** Summarises all possible logical values. */ -enum BooleanType -{ - BT_FALSE, /**< Logical value for "false". */ - BT_TRUE /**< Logical value for "true". */ -}; - - -/** Summarises all possible print levels. Print levels are used to describe - * the desired amount of output during runtime of qpOASES. */ -enum PrintLevel -{ - PL_NONE, /**< No output. */ - PL_LOW, /**< Print error messages only. */ - PL_MEDIUM, /**< Print error and warning messages as well as concise info messages. */ - PL_HIGH /**< Print all messages with full details. */ -}; - - -/** Defines visibility status of a message. */ -enum VisibilityStatus -{ - VS_VISIBLE, /**< Message visible. */ - VS_HIDDEN /**< Message not visible. */ -}; - - -/** Summarises all possible states of the (S)QProblem(B) object during the -solution process of a QP sequence. */ -enum QProblemStatus -{ - QPS_NOTINITIALISED, /**< QProblem object is freshly instantiated or reset. */ - QPS_PREPARINGAUXILIARYQP, /**< An auxiliary problem is currently setup, either at the very beginning - * via an initial homotopy or after changing the QP matrices. */ - QPS_AUXILIARYQPSOLVED, /**< An auxilary problem was solved, either at the very beginning - * via an initial homotopy or after changing the QP matrices. */ - QPS_PERFORMINGHOMOTOPY, /**< A homotopy according to the main idea of the online active - * set strategy is performed. */ - QPS_HOMOTOPYQPSOLVED, /**< An intermediate QP along the homotopy path was solved. */ - QPS_SOLVED /**< The solution of the actual QP was found. */ -}; - - -/** Summarises all possible types of bounds and constraints. */ -enum SubjectToType -{ - ST_UNBOUNDED, /**< Bound/constraint is unbounded. */ - ST_BOUNDED, /**< Bound/constraint is bounded but not fixed. */ - ST_EQUALITY, /**< Bound/constraint is fixed (implicit equality bound/constraint). */ - ST_UNKNOWN /**< Type of bound/constraint unknown. */ -}; - - -/** Summarises all possible states of bounds and constraints. */ -enum SubjectToStatus -{ - ST_INACTIVE, /**< Bound/constraint is inactive. */ - ST_LOWER, /**< Bound/constraint is at its lower bound. */ - ST_UPPER, /**< Bound/constraint is at its upper bound. */ - ST_UNDEFINED /**< Status of bound/constraint undefined. */ -}; - - -/** Summarises all possible cycling states of bounds and constraints. */ -enum CyclingStatus -{ - CYC_NOT_INVOLVED, /**< Bound/constraint is not involved in current cycling. */ - CYC_PREV_ADDED, /**< Bound/constraint has previously been added during the current cycling. */ - CYC_PREV_REMOVED /**< Bound/constraint has previously been removed during the current cycling. */ -}; - - -/** Summarises all possible types of the QP's Hessian matrix. */ -enum HessianType -{ - HST_SEMIDEF, /**< Hessian is positive semi-definite. */ - HST_POSDEF_NULLSPACE, /**< Hessian is positive definite on null space of active bounds/constraints. */ - HST_POSDEF, /**< Hessian is (strictly) positive definite. */ - HST_IDENTITY /**< Hessian is identity matrix. */ -}; - - - -#endif /* QPOASES_TYPES_HPP */ - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file INCLUDE/Types.hpp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2008 + * + * Declaration of all non-built-in types (except for classes). + */ + + +#ifndef QPOASES_TYPES_HPP +#define QPOASES_TYPES_HPP + + + +/** Define real_t for facilitating switching between double and float. */ +// typedef double real_t; + + +/** Summarises all possible logical values. */ +enum BooleanType +{ + BT_FALSE, /**< Logical value for "false". */ + BT_TRUE /**< Logical value for "true". */ +}; + + +/** Summarises all possible print levels. Print levels are used to describe + * the desired amount of output during runtime of qpOASES. */ +enum PrintLevel +{ + PL_NONE, /**< No output. */ + PL_LOW, /**< Print error messages only. */ + PL_MEDIUM, /**< Print error and warning messages as well as concise info messages. */ + PL_HIGH /**< Print all messages with full details. */ +}; + + +/** Defines visibility status of a message. */ +enum VisibilityStatus +{ + VS_VISIBLE, /**< Message visible. */ + VS_HIDDEN /**< Message not visible. */ +}; + + +/** Summarises all possible states of the (S)QProblem(B) object during the +solution process of a QP sequence. */ +enum QProblemStatus +{ + QPS_NOTINITIALISED, /**< QProblem object is freshly instantiated or reset. */ + QPS_PREPARINGAUXILIARYQP, /**< An auxiliary problem is currently setup, either at the very beginning + * via an initial homotopy or after changing the QP matrices. */ + QPS_AUXILIARYQPSOLVED, /**< An auxilary problem was solved, either at the very beginning + * via an initial homotopy or after changing the QP matrices. */ + QPS_PERFORMINGHOMOTOPY, /**< A homotopy according to the main idea of the online active + * set strategy is performed. */ + QPS_HOMOTOPYQPSOLVED, /**< An intermediate QP along the homotopy path was solved. */ + QPS_SOLVED /**< The solution of the actual QP was found. */ +}; + + +/** Summarises all possible types of bounds and constraints. */ +enum SubjectToType +{ + ST_UNBOUNDED, /**< Bound/constraint is unbounded. */ + ST_BOUNDED, /**< Bound/constraint is bounded but not fixed. */ + ST_EQUALITY, /**< Bound/constraint is fixed (implicit equality bound/constraint). */ + ST_UNKNOWN /**< Type of bound/constraint unknown. */ +}; + + +/** Summarises all possible states of bounds and constraints. */ +enum SubjectToStatus +{ + ST_INACTIVE, /**< Bound/constraint is inactive. */ + ST_LOWER, /**< Bound/constraint is at its lower bound. */ + ST_UPPER, /**< Bound/constraint is at its upper bound. */ + ST_UNDEFINED /**< Status of bound/constraint undefined. */ +}; + + +/** Summarises all possible cycling states of bounds and constraints. */ +enum CyclingStatus +{ + CYC_NOT_INVOLVED, /**< Bound/constraint is not involved in current cycling. */ + CYC_PREV_ADDED, /**< Bound/constraint has previously been added during the current cycling. */ + CYC_PREV_REMOVED /**< Bound/constraint has previously been removed during the current cycling. */ +}; + + +/** Summarises all possible types of the QP's Hessian matrix. */ +enum HessianType +{ + HST_SEMIDEF, /**< Hessian is positive semi-definite. */ + HST_POSDEF_NULLSPACE, /**< Hessian is positive definite on null space of active bounds/constraints. */ + HST_POSDEF, /**< Hessian is (strictly) positive definite. */ + HST_IDENTITY /**< Hessian is identity matrix. */ +}; + + + +#endif /* QPOASES_TYPES_HPP */ + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/INCLUDE/Utils.hpp b/phonelibs/qpoases/INCLUDE/Utils.hpp index 16546a991b1945..a91ee78ccb5cd7 100644 --- a/phonelibs/qpoases/INCLUDE/Utils.hpp +++ b/phonelibs/qpoases/INCLUDE/Utils.hpp @@ -1,197 +1,197 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/Utils.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Declaration of global utility functions for working with qpOASES. - */ - - -#ifndef QPOASES_UTILS_HPP -#define QPOASES_UTILS_HPP - - -#include - - -#ifdef PC_DEBUG /* Define print functions only for debugging! */ - -/** Prints a vector. - * \return SUCCESSFUL_RETURN */ -returnValue print( const real_t* const v, /**< Vector to be printed. */ - int n /**< Length of vector. */ - ); - -/** Prints a permuted vector. - * \return SUCCESSFUL_RETURN */ -returnValue print( const real_t* const v, /**< Vector to be printed. */ - int n, /**< Length of vector. */ - const int* const V_idx /**< Pemutation vector. */ - ); - -/** Prints a named vector. - * \return SUCCESSFUL_RETURN */ -returnValue print( const real_t* const v, /**< Vector to be printed. */ - int n, /**< Length of vector. */ - const char* name /** Name of vector. */ - ); - -/** Prints a matrix. - * \return SUCCESSFUL_RETURN */ -returnValue print( const real_t* const M, /**< Matrix to be printed. */ - int nrow, /**< Row number of matrix. */ - int ncol /**< Column number of matrix. */ - ); - -/** Prints a permuted matrix. - * \return SUCCESSFUL_RETURN */ -returnValue print( const real_t* const M, /**< Matrix to be printed. */ - int nrow, /**< Row number of matrix. */ - int ncol , /**< Column number of matrix. */ - const int* const ROW_idx, /**< Row pemutation vector. */ - const int* const COL_idx /**< Column pemutation vector. */ - ); - -/** Prints a named matrix. - * \return SUCCESSFUL_RETURN */ -returnValue print( const real_t* const M, /**< Matrix to be printed. */ - int nrow, /**< Row number of matrix. */ - int ncol, /**< Column number of matrix. */ - const char* name /** Name of matrix. */ - ); - -/** Prints an index array. - * \return SUCCESSFUL_RETURN */ -returnValue print( const int* const index, /**< Index array to be printed. */ - int n /**< Length of index array. */ - ); - -/** Prints a named index array. - * \return SUCCESSFUL_RETURN */ -returnValue print( const int* const index, /**< Index array to be printed. */ - int n, /**< Length of index array. */ - const char* name /**< Name of index array. */ - ); - - -/** Prints a string to desired output target (useful also for MATLAB output!). - * \return SUCCESSFUL_RETURN */ -returnValue myPrintf( const char* s /**< String to be written. */ - ); - - -/** Prints qpOASES copyright notice. - * \return SUCCESSFUL_RETURN */ -returnValue printCopyrightNotice( ); - - -/** Reads a real_t matrix from file. - * \return SUCCESSFUL_RETURN \n - RET_UNABLE_TO_OPEN_FILE \n - RET_UNABLE_TO_READ_FILE */ -returnValue readFromFile( real_t* data, /**< Matrix to be read from file. */ - int nrow, /**< Row number of matrix. */ - int ncol, /**< Column number of matrix. */ - const char* datafilename /**< Data file name. */ - ); - -/** Reads a real_t vector from file. - * \return SUCCESSFUL_RETURN \n - RET_UNABLE_TO_OPEN_FILE \n - RET_UNABLE_TO_READ_FILE */ -returnValue readFromFile( real_t* data, /**< Vector to be read from file. */ - int n, /**< Length of vector. */ - const char* datafilename /**< Data file name. */ - ); - -/** Reads an integer (column) vector from file. - * \return SUCCESSFUL_RETURN \n - RET_UNABLE_TO_OPEN_FILE \n - RET_UNABLE_TO_READ_FILE */ -returnValue readFromFile( int* data, /**< Vector to be read from file. */ - int n, /**< Length of vector. */ - const char* datafilename /**< Data file name. */ - ); - - -/** Writes a real_t matrix into a file. - * \return SUCCESSFUL_RETURN \n - RET_UNABLE_TO_OPEN_FILE */ -returnValue writeIntoFile( const real_t* const data, /**< Matrix to be written into file. */ - int nrow, /**< Row number of matrix. */ - int ncol, /**< Column number of matrix. */ - const char* datafilename, /**< Data file name. */ - BooleanType append /**< Indicates if data shall be appended if the file already exists (otherwise it is overwritten). */ - ); - -/** Writes a real_t vector into a file. - * \return SUCCESSFUL_RETURN \n - RET_UNABLE_TO_OPEN_FILE */ -returnValue writeIntoFile( const real_t* const data, /**< Vector to be written into file. */ - int n, /**< Length of vector. */ - const char* datafilename, /**< Data file name. */ - BooleanType append /**< Indicates if data shall be appended if the file already exists (otherwise it is overwritten). */ - ); - -/** Writes an integer (column) vector into a file. - * \return SUCCESSFUL_RETURN \n - RET_UNABLE_TO_OPEN_FILE */ -returnValue writeIntoFile( const int* const integer, /**< Integer vector to be written into file. */ - int n, /**< Length of vector. */ - const char* datafilename, /**< Data file name. */ - BooleanType append /**< Indicates if integer shall be appended if the file already exists (otherwise it is overwritten). */ - ); - -#endif /* PC_DEBUG */ - - -/** Returns the current system time. - * \return current system time */ -real_t getCPUtime( ); - - -/** Returns the Euclidean norm of a vector. - * \return 0: successful */ -real_t getNorm( const real_t* const v, /**< Vector. */ - int n /**< Vector's dimension. */ - ); - -/** Returns the absolute value of a real_t. - * \return Absolute value of a real_t */ -inline real_t getAbs( real_t x /**< Input argument. */ - ); - - - -#include - -#endif /* QPOASES_UTILS_HPP */ - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file INCLUDE/Utils.hpp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Declaration of global utility functions for working with qpOASES. + */ + + +#ifndef QPOASES_UTILS_HPP +#define QPOASES_UTILS_HPP + + +#include + + +#ifdef PC_DEBUG /* Define print functions only for debugging! */ + +/** Prints a vector. + * \return SUCCESSFUL_RETURN */ +returnValue print( const real_t* const v, /**< Vector to be printed. */ + int n /**< Length of vector. */ + ); + +/** Prints a permuted vector. + * \return SUCCESSFUL_RETURN */ +returnValue print( const real_t* const v, /**< Vector to be printed. */ + int n, /**< Length of vector. */ + const int* const V_idx /**< Pemutation vector. */ + ); + +/** Prints a named vector. + * \return SUCCESSFUL_RETURN */ +returnValue print( const real_t* const v, /**< Vector to be printed. */ + int n, /**< Length of vector. */ + const char* name /** Name of vector. */ + ); + +/** Prints a matrix. + * \return SUCCESSFUL_RETURN */ +returnValue print( const real_t* const M, /**< Matrix to be printed. */ + int nrow, /**< Row number of matrix. */ + int ncol /**< Column number of matrix. */ + ); + +/** Prints a permuted matrix. + * \return SUCCESSFUL_RETURN */ +returnValue print( const real_t* const M, /**< Matrix to be printed. */ + int nrow, /**< Row number of matrix. */ + int ncol , /**< Column number of matrix. */ + const int* const ROW_idx, /**< Row pemutation vector. */ + const int* const COL_idx /**< Column pemutation vector. */ + ); + +/** Prints a named matrix. + * \return SUCCESSFUL_RETURN */ +returnValue print( const real_t* const M, /**< Matrix to be printed. */ + int nrow, /**< Row number of matrix. */ + int ncol, /**< Column number of matrix. */ + const char* name /** Name of matrix. */ + ); + +/** Prints an index array. + * \return SUCCESSFUL_RETURN */ +returnValue print( const int* const index, /**< Index array to be printed. */ + int n /**< Length of index array. */ + ); + +/** Prints a named index array. + * \return SUCCESSFUL_RETURN */ +returnValue print( const int* const index, /**< Index array to be printed. */ + int n, /**< Length of index array. */ + const char* name /**< Name of index array. */ + ); + + +/** Prints a string to desired output target (useful also for MATLAB output!). + * \return SUCCESSFUL_RETURN */ +returnValue myPrintf( const char* s /**< String to be written. */ + ); + + +/** Prints qpOASES copyright notice. + * \return SUCCESSFUL_RETURN */ +returnValue printCopyrightNotice( ); + + +/** Reads a real_t matrix from file. + * \return SUCCESSFUL_RETURN \n + RET_UNABLE_TO_OPEN_FILE \n + RET_UNABLE_TO_READ_FILE */ +returnValue readFromFile( real_t* data, /**< Matrix to be read from file. */ + int nrow, /**< Row number of matrix. */ + int ncol, /**< Column number of matrix. */ + const char* datafilename /**< Data file name. */ + ); + +/** Reads a real_t vector from file. + * \return SUCCESSFUL_RETURN \n + RET_UNABLE_TO_OPEN_FILE \n + RET_UNABLE_TO_READ_FILE */ +returnValue readFromFile( real_t* data, /**< Vector to be read from file. */ + int n, /**< Length of vector. */ + const char* datafilename /**< Data file name. */ + ); + +/** Reads an integer (column) vector from file. + * \return SUCCESSFUL_RETURN \n + RET_UNABLE_TO_OPEN_FILE \n + RET_UNABLE_TO_READ_FILE */ +returnValue readFromFile( int* data, /**< Vector to be read from file. */ + int n, /**< Length of vector. */ + const char* datafilename /**< Data file name. */ + ); + + +/** Writes a real_t matrix into a file. + * \return SUCCESSFUL_RETURN \n + RET_UNABLE_TO_OPEN_FILE */ +returnValue writeIntoFile( const real_t* const data, /**< Matrix to be written into file. */ + int nrow, /**< Row number of matrix. */ + int ncol, /**< Column number of matrix. */ + const char* datafilename, /**< Data file name. */ + BooleanType append /**< Indicates if data shall be appended if the file already exists (otherwise it is overwritten). */ + ); + +/** Writes a real_t vector into a file. + * \return SUCCESSFUL_RETURN \n + RET_UNABLE_TO_OPEN_FILE */ +returnValue writeIntoFile( const real_t* const data, /**< Vector to be written into file. */ + int n, /**< Length of vector. */ + const char* datafilename, /**< Data file name. */ + BooleanType append /**< Indicates if data shall be appended if the file already exists (otherwise it is overwritten). */ + ); + +/** Writes an integer (column) vector into a file. + * \return SUCCESSFUL_RETURN \n + RET_UNABLE_TO_OPEN_FILE */ +returnValue writeIntoFile( const int* const integer, /**< Integer vector to be written into file. */ + int n, /**< Length of vector. */ + const char* datafilename, /**< Data file name. */ + BooleanType append /**< Indicates if integer shall be appended if the file already exists (otherwise it is overwritten). */ + ); + +#endif /* PC_DEBUG */ + + +/** Returns the current system time. + * \return current system time */ +real_t getCPUtime( ); + + +/** Returns the Euclidean norm of a vector. + * \return 0: successful */ +real_t getNorm( const real_t* const v, /**< Vector. */ + int n /**< Vector's dimension. */ + ); + +/** Returns the absolute value of a real_t. + * \return Absolute value of a real_t */ +inline real_t getAbs( real_t x /**< Input argument. */ + ); + + + +#include + +#endif /* QPOASES_UTILS_HPP */ + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/LICENSE.txt b/phonelibs/qpoases/LICENSE.txt index 5faba9d48ce750..5ab7695ab8cabe 100644 --- a/phonelibs/qpoases/LICENSE.txt +++ b/phonelibs/qpoases/LICENSE.txt @@ -1,504 +1,504 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/phonelibs/qpoases/README.txt b/phonelibs/qpoases/README.txt index 37175d9192bdbe..53fc2ab4f86279 100644 --- a/phonelibs/qpoases/README.txt +++ b/phonelibs/qpoases/README.txt @@ -1,92 +1,92 @@ -## -## qpOASES -- An Implementation of the Online Active Set Strategy. -## Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. -## -## qpOASES is free software; you can redistribute it and/or -## modify it under the terms of the GNU Lesser General Public -## License as published by the Free Software Foundation; either -## version 2.1 of the License, or (at your option) any later version. -## -## qpOASES is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## Lesser General Public License for more details. -## -## You should have received a copy of the GNU Lesser General Public -## License along with qpOASES; if not, write to the Free Software -## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -## - - - -INTRODUCTION -============= - -qpOASES is an open-source C++ implementation of the recently proposed -online active set strategy (see [1], [2]), which was inspired by important -observations from the field of parametric quadratic programming. It has -several theoretical features that make it particularly suited for model -predictive control (MPC) applications. - -The software package qpOASES implements these ideas and has already been -successfully used for closed-loop control of a real-world Diesel engine [3]. - - -References: - -[1] H.J. Ferreau. An Online Active Set Strategy for Fast Solution of -Parametric Quadratic Programs with Applications to Predictive Engine Control. -Diplom thesis, University of Heidelberg, 2006. - -[2] H.J. Ferreau, H.G. Bock, M. Diehl. An online active set strategy to -overcome the limitations of explicit MPC. International Journal of Robust -and Nonlinear Control, 18 (8), pp. 816-830, 2008. - -[3] H.J. Ferreau, P. Ortner, P. Langthaler, L. del Re, M. Diehl. Predictive -Control of a Real-World Diesel Engine using an Extended Online Active Set -Strategy. Annual Reviews in Control, 31 (2), pp. 293-301, 2007. - - - -GETTING STARTED -================ - -1. For installation, usage and additional information on this software package - see the qpOASES User's Manual located at ./DOC/manual.pdf! - - -2. The file ./LICENSE.txt contains a copy of the GNU Lesser General Public - License. Please read it carefully before using qpOASES! - - -3. The whole software package can be downloaded from - - http://homes.esat.kuleuven.be/~optec/software/qpOASES/ - - On this webpage you will also find a list of frequently asked questions. - - - -CONTACT THE AUTHORS -==================== - -If you have got questions, remarks or comments on qpOASES -please contact the main author: - - Hans Joachim Ferreau - Katholieke Universiteit Leuven - Department of Electrical Engineering (ESAT) - Kasteelpark Arenberg 10, bus 2446 - B-3001 Leuven-Heverlee, Belgium - - Phone: +32 16 32 03 63 - E-mail: joachim.ferreau@esat.kuleuven.be - qpOASES@esat.kuleuven.be - -Also bug reports and source code extensions are most welcome! - - - -## -## end of file -## +## +## qpOASES -- An Implementation of the Online Active Set Strategy. +## Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. +## +## qpOASES is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## qpOASES is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with qpOASES; if not, write to the Free Software +## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +## + + + +INTRODUCTION +============= + +qpOASES is an open-source C++ implementation of the recently proposed +online active set strategy (see [1], [2]), which was inspired by important +observations from the field of parametric quadratic programming. It has +several theoretical features that make it particularly suited for model +predictive control (MPC) applications. + +The software package qpOASES implements these ideas and has already been +successfully used for closed-loop control of a real-world Diesel engine [3]. + + +References: + +[1] H.J. Ferreau. An Online Active Set Strategy for Fast Solution of +Parametric Quadratic Programs with Applications to Predictive Engine Control. +Diplom thesis, University of Heidelberg, 2006. + +[2] H.J. Ferreau, H.G. Bock, M. Diehl. An online active set strategy to +overcome the limitations of explicit MPC. International Journal of Robust +and Nonlinear Control, 18 (8), pp. 816-830, 2008. + +[3] H.J. Ferreau, P. Ortner, P. Langthaler, L. del Re, M. Diehl. Predictive +Control of a Real-World Diesel Engine using an Extended Online Active Set +Strategy. Annual Reviews in Control, 31 (2), pp. 293-301, 2007. + + + +GETTING STARTED +================ + +1. For installation, usage and additional information on this software package + see the qpOASES User's Manual located at ./DOC/manual.pdf! + + +2. The file ./LICENSE.txt contains a copy of the GNU Lesser General Public + License. Please read it carefully before using qpOASES! + + +3. The whole software package can be downloaded from + + http://homes.esat.kuleuven.be/~optec/software/qpOASES/ + + On this webpage you will also find a list of frequently asked questions. + + + +CONTACT THE AUTHORS +==================== + +If you have got questions, remarks or comments on qpOASES +please contact the main author: + + Hans Joachim Ferreau + Katholieke Universiteit Leuven + Department of Electrical Engineering (ESAT) + Kasteelpark Arenberg 10, bus 2446 + B-3001 Leuven-Heverlee, Belgium + + Phone: +32 16 32 03 63 + E-mail: joachim.ferreau@esat.kuleuven.be + qpOASES@esat.kuleuven.be + +Also bug reports and source code extensions are most welcome! + + + +## +## end of file +## diff --git a/phonelibs/qpoases/SConscript b/phonelibs/qpoases/SConscript new file mode 100644 index 00000000000000..932dbc700acdb1 --- /dev/null +++ b/phonelibs/qpoases/SConscript @@ -0,0 +1,16 @@ +Import('env', 'interface_dir') + +qp_files = [ + Glob("SRC/*.cpp"), + Glob("SRC/EXTRAS/*.cpp"), +] + +cpp_path = [ + ".", + "INCLUDE", + "INCLUDE/EXTRAS", + "SRC/", + interface_dir, +] + +env.Library('qpoases', qp_files, CPPPATH=cpp_path) diff --git a/phonelibs/qpoases/SRC/Bounds.cpp b/phonelibs/qpoases/SRC/Bounds.cpp index 236ab2f62d284b..cf8ed69890623f 100644 --- a/phonelibs/qpoases/SRC/Bounds.cpp +++ b/phonelibs/qpoases/SRC/Bounds.cpp @@ -1,252 +1,252 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/Bounds.cpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of the Bounds class designed to manage working sets of - * bounds within a QProblem. - */ - - -#include - - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - - -/* - * B o u n d s - */ -Bounds::Bounds( ) : SubjectTo( ), - nV( 0 ), - nFV( 0 ), - nBV( 0 ), - nUV( 0 ) -{ -} - - -/* - * B o u n d s - */ -Bounds::Bounds( const Bounds& rhs ) : SubjectTo( rhs ), - nV( rhs.nV ), - nFV( rhs.nFV ), - nBV( rhs.nBV ), - nUV( rhs.nUV ) -{ - free = rhs.free; - fixed = rhs.fixed; -} - - -/* - * ~ B o u n d s - */ -Bounds::~Bounds( ) -{ -} - - -/* - * o p e r a t o r = - */ -Bounds& Bounds::operator=( const Bounds& rhs ) -{ - if ( this != &rhs ) - { - SubjectTo::operator=( rhs ); - - nV = rhs.nV; - nFV = rhs.nFV; - nBV = rhs.nBV; - nUV = rhs.nUV; - - free = rhs.free; - fixed = rhs.fixed; - } - - return *this; -} - - -/* - * i n i t - */ -returnValue Bounds::init( int n ) -{ - nV = n; - nFV = 0; - nBV = 0; - nUV = 0; - - free.init( ); - fixed.init( ); - - return SubjectTo::init( n ); -} - - -/* - * s e t u p B o u n d - */ -returnValue Bounds::setupBound( int _number, SubjectToStatus _status - ) -{ - /* consistency check */ - if ( ( _number < 0 ) || ( _number >= getNV( ) ) ) - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - - /* Add bound index to respective index list. */ - switch ( _status ) - { - case ST_INACTIVE: - if ( this->addIndex( this->getFree( ),_number,_status ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_BOUND_FAILED ); - break; - - case ST_LOWER: - if ( this->addIndex( this->getFixed( ),_number,_status ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_BOUND_FAILED ); - break; - - case ST_UPPER: - if ( this->addIndex( this->getFixed( ),_number,_status ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_BOUND_FAILED ); - break; - - default: - return THROWERROR( RET_INVALID_ARGUMENTS ); - } - - return SUCCESSFUL_RETURN; -} - - -/* - * s e t u p A l l F r e e - */ -returnValue Bounds::setupAllFree( ) -{ - int i; - - /* 1) Place unbounded variables at the beginning of the index list of free variables. */ - for( i=0; i= getNV( ) ) ) - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - - /* Move index from indexlist of fixed variables to that of free ones. */ - if ( this->removeIndex( this->getFixed( ),_number ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_MOVING_BOUND_FAILED ); - - if ( this->addIndex( this->getFree( ),_number,ST_INACTIVE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_MOVING_BOUND_FAILED ); - - return SUCCESSFUL_RETURN; -} - - -/* - * m o v e F r e e T o F i x e d - */ -returnValue Bounds::moveFreeToFixed( int _number, SubjectToStatus _status - ) -{ - /* consistency check */ - if ( ( _number < 0 ) || ( _number >= getNV( ) ) ) - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - - /* Move index from indexlist of free variables to that of fixed ones. */ - if ( this->removeIndex( this->getFree( ),_number ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_MOVING_BOUND_FAILED ); - - if ( this->addIndex( this->getFixed( ),_number,_status ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_MOVING_BOUND_FAILED ); - - return SUCCESSFUL_RETURN; -} - - -/* - * s w a p F r e e - */ -returnValue Bounds::swapFree( int number1, int number2 - ) -{ - /* consistency check */ - if ( ( number1 < 0 ) || ( number1 >= getNV( ) ) || ( number2 < 0 ) || ( number2 >= getNV( ) ) ) - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - - /* Swap index within indexlist of free variables. */ - return this->swapIndex( this->getFree( ),number1,number2 ); -} - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file SRC/Bounds.cpp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Implementation of the Bounds class designed to manage working sets of + * bounds within a QProblem. + */ + + +#include + + + +/***************************************************************************** + * P U B L I C * + *****************************************************************************/ + + +/* + * B o u n d s + */ +Bounds::Bounds( ) : SubjectTo( ), + nV( 0 ), + nFV( 0 ), + nBV( 0 ), + nUV( 0 ) +{ +} + + +/* + * B o u n d s + */ +Bounds::Bounds( const Bounds& rhs ) : SubjectTo( rhs ), + nV( rhs.nV ), + nFV( rhs.nFV ), + nBV( rhs.nBV ), + nUV( rhs.nUV ) +{ + free = rhs.free; + fixed = rhs.fixed; +} + + +/* + * ~ B o u n d s + */ +Bounds::~Bounds( ) +{ +} + + +/* + * o p e r a t o r = + */ +Bounds& Bounds::operator=( const Bounds& rhs ) +{ + if ( this != &rhs ) + { + SubjectTo::operator=( rhs ); + + nV = rhs.nV; + nFV = rhs.nFV; + nBV = rhs.nBV; + nUV = rhs.nUV; + + free = rhs.free; + fixed = rhs.fixed; + } + + return *this; +} + + +/* + * i n i t + */ +returnValue Bounds::init( int n ) +{ + nV = n; + nFV = 0; + nBV = 0; + nUV = 0; + + free.init( ); + fixed.init( ); + + return SubjectTo::init( n ); +} + + +/* + * s e t u p B o u n d + */ +returnValue Bounds::setupBound( int _number, SubjectToStatus _status + ) +{ + /* consistency check */ + if ( ( _number < 0 ) || ( _number >= getNV( ) ) ) + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); + + /* Add bound index to respective index list. */ + switch ( _status ) + { + case ST_INACTIVE: + if ( this->addIndex( this->getFree( ),_number,_status ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_SETUP_BOUND_FAILED ); + break; + + case ST_LOWER: + if ( this->addIndex( this->getFixed( ),_number,_status ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_SETUP_BOUND_FAILED ); + break; + + case ST_UPPER: + if ( this->addIndex( this->getFixed( ),_number,_status ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_SETUP_BOUND_FAILED ); + break; + + default: + return THROWERROR( RET_INVALID_ARGUMENTS ); + } + + return SUCCESSFUL_RETURN; +} + + +/* + * s e t u p A l l F r e e + */ +returnValue Bounds::setupAllFree( ) +{ + int i; + + /* 1) Place unbounded variables at the beginning of the index list of free variables. */ + for( i=0; i= getNV( ) ) ) + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); + + /* Move index from indexlist of fixed variables to that of free ones. */ + if ( this->removeIndex( this->getFixed( ),_number ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_MOVING_BOUND_FAILED ); + + if ( this->addIndex( this->getFree( ),_number,ST_INACTIVE ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_MOVING_BOUND_FAILED ); + + return SUCCESSFUL_RETURN; +} + + +/* + * m o v e F r e e T o F i x e d + */ +returnValue Bounds::moveFreeToFixed( int _number, SubjectToStatus _status + ) +{ + /* consistency check */ + if ( ( _number < 0 ) || ( _number >= getNV( ) ) ) + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); + + /* Move index from indexlist of free variables to that of fixed ones. */ + if ( this->removeIndex( this->getFree( ),_number ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_MOVING_BOUND_FAILED ); + + if ( this->addIndex( this->getFixed( ),_number,_status ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_MOVING_BOUND_FAILED ); + + return SUCCESSFUL_RETURN; +} + + +/* + * s w a p F r e e + */ +returnValue Bounds::swapFree( int number1, int number2 + ) +{ + /* consistency check */ + if ( ( number1 < 0 ) || ( number1 >= getNV( ) ) || ( number2 < 0 ) || ( number2 >= getNV( ) ) ) + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); + + /* Swap index within indexlist of free variables. */ + return this->swapIndex( this->getFree( ),number1,number2 ); +} + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/SRC/Bounds.ipp b/phonelibs/qpoases/SRC/Bounds.ipp index d0e7dbbf0904f7..d2ab1ba2d89835 100644 --- a/phonelibs/qpoases/SRC/Bounds.ipp +++ b/phonelibs/qpoases/SRC/Bounds.ipp @@ -1,144 +1,144 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/Bounds.ipp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of inlined member functions of the Bounds class designed - * to manage working sets of bounds within a QProblem. - */ - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - -/* - * g e t N V - */ -inline int Bounds::getNV( ) const -{ - return nV; -} - - -/* - * g e t N F X - */ -inline int Bounds::getNFV( ) const -{ - return nFV; -} - - -/* - * g e t N B V - */ -inline int Bounds::getNBV( ) const -{ - return nBV; -} - - -/* - * g e t N U V - */ -inline int Bounds::getNUV( ) const -{ - return nUV; -} - - - -/* - * s e t N F X - */ -inline returnValue Bounds::setNFV( int n ) -{ - nFV = n; - return SUCCESSFUL_RETURN; -} - - -/* - * s e t N B V - */ -inline returnValue Bounds::setNBV( int n ) -{ - nBV = n; - return SUCCESSFUL_RETURN; -} - - -/* - * s e t N U V - */ -inline returnValue Bounds::setNUV( int n ) -{ - nUV = n; - return SUCCESSFUL_RETURN; -} - - -/* - * g e t N F R - */ -inline int Bounds::getNFR( ) -{ - return free.getLength( ); -} - - -/* - * g e t N F X - */ -inline int Bounds::getNFX( ) -{ - return fixed.getLength( ); -} - - -/* - * g e t F r e e - */ -inline Indexlist* Bounds::getFree( ) -{ - return &free; -} - - -/* - * g e t F i x e d - */ -inline Indexlist* Bounds::getFixed( ) -{ - return &fixed; -} - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file SRC/Bounds.ipp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Implementation of inlined member functions of the Bounds class designed + * to manage working sets of bounds within a QProblem. + */ + + +/***************************************************************************** + * P U B L I C * + *****************************************************************************/ + +/* + * g e t N V + */ +inline int Bounds::getNV( ) const +{ + return nV; +} + + +/* + * g e t N F X + */ +inline int Bounds::getNFV( ) const +{ + return nFV; +} + + +/* + * g e t N B V + */ +inline int Bounds::getNBV( ) const +{ + return nBV; +} + + +/* + * g e t N U V + */ +inline int Bounds::getNUV( ) const +{ + return nUV; +} + + + +/* + * s e t N F X + */ +inline returnValue Bounds::setNFV( int n ) +{ + nFV = n; + return SUCCESSFUL_RETURN; +} + + +/* + * s e t N B V + */ +inline returnValue Bounds::setNBV( int n ) +{ + nBV = n; + return SUCCESSFUL_RETURN; +} + + +/* + * s e t N U V + */ +inline returnValue Bounds::setNUV( int n ) +{ + nUV = n; + return SUCCESSFUL_RETURN; +} + + +/* + * g e t N F R + */ +inline int Bounds::getNFR( ) +{ + return free.getLength( ); +} + + +/* + * g e t N F X + */ +inline int Bounds::getNFX( ) +{ + return fixed.getLength( ); +} + + +/* + * g e t F r e e + */ +inline Indexlist* Bounds::getFree( ) +{ + return &free; +} + + +/* + * g e t F i x e d + */ +inline Indexlist* Bounds::getFixed( ) +{ + return &fixed; +} + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/SRC/Constraints.cpp b/phonelibs/qpoases/SRC/Constraints.cpp index 81fc6ce8679d23..b2ad5bd111547e 100644 --- a/phonelibs/qpoases/SRC/Constraints.cpp +++ b/phonelibs/qpoases/SRC/Constraints.cpp @@ -1,248 +1,248 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/Constraints.cpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of the Constraints class designed to manage working sets of - * constraints within a QProblem. - */ - - -#include - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - - -/* - * C o n s t r a i n t s - */ -Constraints::Constraints( ) : SubjectTo( ), - nC( 0 ), - nEC( 0 ), - nIC( 0 ), - nUC( 0 ) -{ -} - - -/* - * C o n s t r a i n t s - */ -Constraints::Constraints( const Constraints& rhs ) : SubjectTo( rhs ), - nC( rhs.nC ), - nEC( rhs.nEC ), - nIC( rhs.nIC ), - nUC( rhs.nUC ) -{ - active = rhs.active; - inactive = rhs.inactive; -} - - -/* - * ~ C o n s t r a i n t s - */ -Constraints::~Constraints( ) -{ -} - - -/* - * o p e r a t o r = - */ -Constraints& Constraints::operator=( const Constraints& rhs ) -{ - if ( this != &rhs ) - { - SubjectTo::operator=( rhs ); - - nC = rhs.nC; - nEC = rhs.nEC; - nIC = rhs.nIC; - nUC = rhs.nUC; - - active = rhs.active; - inactive = rhs.inactive; - } - - return *this; -} - - -/* - * i n i t - */ -returnValue Constraints::init( int n ) -{ - nC = n; - nEC = 0; - nIC = 0; - nUC = 0; - - active.init( ); - inactive.init( ); - - return SubjectTo::init( n ); -} - - -/* - * s e t u p C o n s t r a i n t - */ -returnValue Constraints::setupConstraint( int _number, SubjectToStatus _status - ) -{ - /* consistency check */ - if ( ( _number < 0 ) || ( _number >= getNC( ) ) ) - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - - /* Add constraint index to respective index list. */ - switch ( _status ) - { - case ST_INACTIVE: - if ( this->addIndex( this->getInactive( ),_number,_status ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_CONSTRAINT_FAILED ); - break; - - case ST_LOWER: - if ( this->addIndex( this->getActive( ),_number,_status ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_CONSTRAINT_FAILED ); - break; - - case ST_UPPER: - if ( this->addIndex( this->getActive( ),_number,_status ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_CONSTRAINT_FAILED ); - break; - - default: - return THROWERROR( RET_INVALID_ARGUMENTS ); - } - - return SUCCESSFUL_RETURN; -} - - -/* - * s e t u p A l l I n a c t i v e - */ -returnValue Constraints::setupAllInactive( ) -{ - int i; - - - /* 1) Place unbounded constraints at the beginning of the index list of inactive constraints. */ - for( i=0; i= getNC( ) ) ) - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - - /* Move index from indexlist of active constraints to that of inactive ones. */ - if ( this->removeIndex( this->getActive( ),_number ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_MOVING_BOUND_FAILED ); - - if ( this->addIndex( this->getInactive( ),_number,ST_INACTIVE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_MOVING_BOUND_FAILED ); - - return SUCCESSFUL_RETURN; -} - - -/* - * m o v e I n a c t i v e T o A c t i v e - */ -returnValue Constraints::moveInactiveToActive( int _number, SubjectToStatus _status - ) -{ - /* consistency check */ - if ( ( _number < 0 ) || ( _number >= getNC( ) ) ) - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - - /* Move index from indexlist of inactive constraints to that of active ones. */ - if ( this->removeIndex( this->getInactive( ),_number ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_MOVING_BOUND_FAILED ); - - if ( this->addIndex( this->getActive( ),_number,_status ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_MOVING_BOUND_FAILED ); - - return SUCCESSFUL_RETURN; -} - - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file SRC/Constraints.cpp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Implementation of the Constraints class designed to manage working sets of + * constraints within a QProblem. + */ + + +#include + + +/***************************************************************************** + * P U B L I C * + *****************************************************************************/ + + +/* + * C o n s t r a i n t s + */ +Constraints::Constraints( ) : SubjectTo( ), + nC( 0 ), + nEC( 0 ), + nIC( 0 ), + nUC( 0 ) +{ +} + + +/* + * C o n s t r a i n t s + */ +Constraints::Constraints( const Constraints& rhs ) : SubjectTo( rhs ), + nC( rhs.nC ), + nEC( rhs.nEC ), + nIC( rhs.nIC ), + nUC( rhs.nUC ) +{ + active = rhs.active; + inactive = rhs.inactive; +} + + +/* + * ~ C o n s t r a i n t s + */ +Constraints::~Constraints( ) +{ +} + + +/* + * o p e r a t o r = + */ +Constraints& Constraints::operator=( const Constraints& rhs ) +{ + if ( this != &rhs ) + { + SubjectTo::operator=( rhs ); + + nC = rhs.nC; + nEC = rhs.nEC; + nIC = rhs.nIC; + nUC = rhs.nUC; + + active = rhs.active; + inactive = rhs.inactive; + } + + return *this; +} + + +/* + * i n i t + */ +returnValue Constraints::init( int n ) +{ + nC = n; + nEC = 0; + nIC = 0; + nUC = 0; + + active.init( ); + inactive.init( ); + + return SubjectTo::init( n ); +} + + +/* + * s e t u p C o n s t r a i n t + */ +returnValue Constraints::setupConstraint( int _number, SubjectToStatus _status + ) +{ + /* consistency check */ + if ( ( _number < 0 ) || ( _number >= getNC( ) ) ) + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); + + /* Add constraint index to respective index list. */ + switch ( _status ) + { + case ST_INACTIVE: + if ( this->addIndex( this->getInactive( ),_number,_status ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_SETUP_CONSTRAINT_FAILED ); + break; + + case ST_LOWER: + if ( this->addIndex( this->getActive( ),_number,_status ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_SETUP_CONSTRAINT_FAILED ); + break; + + case ST_UPPER: + if ( this->addIndex( this->getActive( ),_number,_status ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_SETUP_CONSTRAINT_FAILED ); + break; + + default: + return THROWERROR( RET_INVALID_ARGUMENTS ); + } + + return SUCCESSFUL_RETURN; +} + + +/* + * s e t u p A l l I n a c t i v e + */ +returnValue Constraints::setupAllInactive( ) +{ + int i; + + + /* 1) Place unbounded constraints at the beginning of the index list of inactive constraints. */ + for( i=0; i= getNC( ) ) ) + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); + + /* Move index from indexlist of active constraints to that of inactive ones. */ + if ( this->removeIndex( this->getActive( ),_number ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_MOVING_BOUND_FAILED ); + + if ( this->addIndex( this->getInactive( ),_number,ST_INACTIVE ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_MOVING_BOUND_FAILED ); + + return SUCCESSFUL_RETURN; +} + + +/* + * m o v e I n a c t i v e T o A c t i v e + */ +returnValue Constraints::moveInactiveToActive( int _number, SubjectToStatus _status + ) +{ + /* consistency check */ + if ( ( _number < 0 ) || ( _number >= getNC( ) ) ) + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); + + /* Move index from indexlist of inactive constraints to that of active ones. */ + if ( this->removeIndex( this->getInactive( ),_number ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_MOVING_BOUND_FAILED ); + + if ( this->addIndex( this->getActive( ),_number,_status ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_MOVING_BOUND_FAILED ); + + return SUCCESSFUL_RETURN; +} + + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/SRC/Constraints.ipp b/phonelibs/qpoases/SRC/Constraints.ipp index 67add20434a1e4..1b874ef3c6596b 100644 --- a/phonelibs/qpoases/SRC/Constraints.ipp +++ b/phonelibs/qpoases/SRC/Constraints.ipp @@ -1,144 +1,144 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/Constraints.ipp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Declaration of inlined member functions of the Constraints class designed - * to manage working sets of constraints within a QProblem. - */ - - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - -/* - * g e t N C - */ -inline int Constraints::getNC( ) const -{ - return nC; -} - - -/* - * g e t N E C - */ -inline int Constraints::getNEC( ) const -{ - return nEC; -} - - -/* - * g e t N I C - */ -inline int Constraints::getNIC( ) const -{ - return nIC; -} - - -/* - * g e t N U C - */ -inline int Constraints::getNUC( ) const -{ - return nUC; -} - - -/* - * s e t N E C - */ -inline returnValue Constraints::setNEC( int n ) -{ - nEC = n; - return SUCCESSFUL_RETURN; -} - - -/* - * s e t N I C - */ -inline returnValue Constraints::setNIC( int n ) -{ - nIC = n; - return SUCCESSFUL_RETURN; -} - - -/* - * s e t N U C - */ -inline returnValue Constraints::setNUC( int n ) -{ - nUC = n; - return SUCCESSFUL_RETURN; -} - - -/* - * g e t N A C - */ -inline int Constraints::getNAC( ) -{ - return active.getLength( ); -} - - -/* - * g e t N I A C - */ -inline int Constraints::getNIAC( ) -{ - return inactive.getLength( ); -} - - -/* - * g e t A c t i v e - */ -inline Indexlist* Constraints::getActive( ) -{ - return &active; -} - - -/* - * g e t I n a c t i v e - */ -inline Indexlist* Constraints::getInactive( ) -{ - return &inactive; -} - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file SRC/Constraints.ipp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Declaration of inlined member functions of the Constraints class designed + * to manage working sets of constraints within a QProblem. + */ + + + +/***************************************************************************** + * P U B L I C * + *****************************************************************************/ + +/* + * g e t N C + */ +inline int Constraints::getNC( ) const +{ + return nC; +} + + +/* + * g e t N E C + */ +inline int Constraints::getNEC( ) const +{ + return nEC; +} + + +/* + * g e t N I C + */ +inline int Constraints::getNIC( ) const +{ + return nIC; +} + + +/* + * g e t N U C + */ +inline int Constraints::getNUC( ) const +{ + return nUC; +} + + +/* + * s e t N E C + */ +inline returnValue Constraints::setNEC( int n ) +{ + nEC = n; + return SUCCESSFUL_RETURN; +} + + +/* + * s e t N I C + */ +inline returnValue Constraints::setNIC( int n ) +{ + nIC = n; + return SUCCESSFUL_RETURN; +} + + +/* + * s e t N U C + */ +inline returnValue Constraints::setNUC( int n ) +{ + nUC = n; + return SUCCESSFUL_RETURN; +} + + +/* + * g e t N A C + */ +inline int Constraints::getNAC( ) +{ + return active.getLength( ); +} + + +/* + * g e t N I A C + */ +inline int Constraints::getNIAC( ) +{ + return inactive.getLength( ); +} + + +/* + * g e t A c t i v e + */ +inline Indexlist* Constraints::getActive( ) +{ + return &active; +} + + +/* + * g e t I n a c t i v e + */ +inline Indexlist* Constraints::getInactive( ) +{ + return &inactive; +} + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/SRC/CyclingManager.cpp b/phonelibs/qpoases/SRC/CyclingManager.cpp index 7bbccdac228460..27c2996ef3fff2 100644 --- a/phonelibs/qpoases/SRC/CyclingManager.cpp +++ b/phonelibs/qpoases/SRC/CyclingManager.cpp @@ -1,188 +1,188 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/CyclingManager.cpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of the CyclingManager class designed to detect - * and handle possible cycling during QP iterations. - * - */ - - -#include - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - - -/* - * C y c l i n g M a n a g e r - */ -CyclingManager::CyclingManager( ) : nV( 0 ), - nC( 0 ) -{ - cyclingDetected = BT_FALSE; -} - - -/* - * C y c l i n g M a n a g e r - */ -CyclingManager::CyclingManager( const CyclingManager& rhs ) : nV( rhs.nV ), - nC( rhs.nC ), - cyclingDetected( rhs.cyclingDetected ) -{ - int i; - - for( i=0; i= 0 ) && ( number < nV ) ) - { - status[number] = _status; - return SUCCESSFUL_RETURN; - } - else - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - } - else - { - /* Set cycling status of a constraint. */ - if ( ( number >= 0 ) && ( number < nC ) ) - { - status[nV+number] = _status; - return SUCCESSFUL_RETURN; - } - else - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - } -} - - -/* - * g e t C y c l i n g S t a t u s - */ -CyclingStatus CyclingManager::getCyclingStatus( int number, BooleanType isBound ) const -{ - if ( isBound == BT_TRUE ) - { - /* Return cycling status of a bound. */ - if ( ( number >= 0 ) && ( number < nV ) ) - return status[number]; - } - else - { - /* Return cycling status of a constraint. */ - if ( ( number >= 0 ) && ( number < nC ) ) - return status[nV+number]; - } - - return CYC_NOT_INVOLVED; -} - - -/* - * c l e a r C y c l i n g D a t a - */ -returnValue CyclingManager::clearCyclingData( ) -{ - int i; - - /* Reset all status values ... */ - for( i=0; i + + +/***************************************************************************** + * P U B L I C * + *****************************************************************************/ + + +/* + * C y c l i n g M a n a g e r + */ +CyclingManager::CyclingManager( ) : nV( 0 ), + nC( 0 ) +{ + cyclingDetected = BT_FALSE; +} + + +/* + * C y c l i n g M a n a g e r + */ +CyclingManager::CyclingManager( const CyclingManager& rhs ) : nV( rhs.nV ), + nC( rhs.nC ), + cyclingDetected( rhs.cyclingDetected ) +{ + int i; + + for( i=0; i= 0 ) && ( number < nV ) ) + { + status[number] = _status; + return SUCCESSFUL_RETURN; + } + else + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); + } + else + { + /* Set cycling status of a constraint. */ + if ( ( number >= 0 ) && ( number < nC ) ) + { + status[nV+number] = _status; + return SUCCESSFUL_RETURN; + } + else + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); + } +} + + +/* + * g e t C y c l i n g S t a t u s + */ +CyclingStatus CyclingManager::getCyclingStatus( int number, BooleanType isBound ) const +{ + if ( isBound == BT_TRUE ) + { + /* Return cycling status of a bound. */ + if ( ( number >= 0 ) && ( number < nV ) ) + return status[number]; + } + else + { + /* Return cycling status of a constraint. */ + if ( ( number >= 0 ) && ( number < nC ) ) + return status[nV+number]; + } + + return CYC_NOT_INVOLVED; +} + + +/* + * c l e a r C y c l i n g D a t a + */ +returnValue CyclingManager::clearCyclingData( ) +{ + int i; + + /* Reset all status values ... */ + for( i=0; i - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - - -/* - * I n d e x l i s t - */ -Indexlist::Indexlist( ) : length( 0 ), - first( -1 ), - last( -1 ), - lastusedindex( -1 ), - physicallength( INDEXLISTFACTOR*(NVMAX+NCMAX) ) -{ - int i; - - for( i=0; i= 0 ) && ( number[n] >= 0 ) ) - numberarray[i] = number[n]; - else - return THROWERROR( RET_INDEXLIST_CORRUPTED ); - - n = next[n]; - } - - return SUCCESSFUL_RETURN; -} - - -/* - * g e t I n d e x - */ -int Indexlist::getIndex( int givennumber ) const -{ - int i; - int n = first; - int index = -1; /* return -1 by default */ - - /* Run trough indexlist until number is found, if so return it index. */ - for ( i=0; i + + +/***************************************************************************** + * P U B L I C * + *****************************************************************************/ + + +/* + * I n d e x l i s t + */ +Indexlist::Indexlist( ) : length( 0 ), + first( -1 ), + last( -1 ), + lastusedindex( -1 ), + physicallength( INDEXLISTFACTOR*(NVMAX+NCMAX) ) +{ + int i; + + for( i=0; i= 0 ) && ( number[n] >= 0 ) ) + numberarray[i] = number[n]; + else + return THROWERROR( RET_INDEXLIST_CORRUPTED ); + + n = next[n]; + } + + return SUCCESSFUL_RETURN; +} + + +/* + * g e t I n d e x + */ +int Indexlist::getIndex( int givennumber ) const +{ + int i; + int n = first; + int index = -1; /* return -1 by default */ + + /* Run trough indexlist until number is found, if so return it index. */ + for ( i=0; i length ) ) - return -RET_INDEXLIST_OUTOFBOUNDS; - - return number[physicalindex]; -} - - -/* - * g e t L e n g t h - */ -inline int Indexlist::getLength( ) -{ - return length; -} - - -/* - * g e t L a s t N u m b e r - */ -inline int Indexlist::getLastNumber( ) const -{ - return number[last]; -} - - -/* - * g e t L a s t N u m b e r - */ -inline BooleanType Indexlist::isMember( int _number ) const -{ - if ( getIndex( _number ) >= 0 ) - return BT_TRUE; - else - return BT_FALSE; -} - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file SRC/Indexlist.ipp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Implementation of inlined member functions of the Indexlist class designed + * to manage index lists of constraints and bounds within a QProblem_SubjectTo. + */ + + + +/***************************************************************************** + * P U B L I C * + *****************************************************************************/ + +/* + * g e t N u m b e r + */ +inline int Indexlist::getNumber( int physicalindex ) const +{ + /* consistency check */ + if ( ( physicalindex < 0 ) || ( physicalindex > length ) ) + return -RET_INDEXLIST_OUTOFBOUNDS; + + return number[physicalindex]; +} + + +/* + * g e t L e n g t h + */ +inline int Indexlist::getLength( ) +{ + return length; +} + + +/* + * g e t L a s t N u m b e r + */ +inline int Indexlist::getLastNumber( ) const +{ + return number[last]; +} + + +/* + * g e t L a s t N u m b e r + */ +inline BooleanType Indexlist::isMember( int _number ) const +{ + if ( getIndex( _number ) >= 0 ) + return BT_TRUE; + else + return BT_FALSE; +} + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/SRC/MessageHandling.cpp b/phonelibs/qpoases/SRC/MessageHandling.cpp index 6e68cd8552449e..18a7654a104afa 100644 --- a/phonelibs/qpoases/SRC/MessageHandling.cpp +++ b/phonelibs/qpoases/SRC/MessageHandling.cpp @@ -1,529 +1,529 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/MessageHandling.cpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of the MessageHandling class including global return values. - * - */ - - - -#include -#include - - - - -/** Defines pairs of global return values and messages. */ -MessageHandling::ReturnValueList returnValueList[] = -{ -/* miscellaneous */ -{ SUCCESSFUL_RETURN, "Successful return", VS_VISIBLE }, -{ RET_DIV_BY_ZERO, "Division by zero", VS_VISIBLE }, -{ RET_INDEX_OUT_OF_BOUNDS, "Index out of bounds", VS_VISIBLE }, -{ RET_INVALID_ARGUMENTS, "At least one of the arguments is invalid", VS_VISIBLE }, -{ RET_ERROR_UNDEFINED, "Error number undefined", VS_VISIBLE }, -{ RET_WARNING_UNDEFINED, "Warning number undefined", VS_VISIBLE }, -{ RET_INFO_UNDEFINED, "Info number undefined", VS_VISIBLE }, -{ RET_EWI_UNDEFINED, "Error/warning/info number undefined", VS_VISIBLE }, -{ RET_AVAILABLE_WITH_LINUX_ONLY, "This function is available under Linux only", VS_HIDDEN }, -{ RET_UNKNOWN_BUG, "The error occured is not yet known", VS_VISIBLE }, -{ RET_PRINTLEVEL_CHANGED, "Print level changed", VS_VISIBLE }, -{ RET_NOT_YET_IMPLEMENTED, "Requested function is not yet implemented.", VS_VISIBLE }, -/* Indexlist */ -{ RET_INDEXLIST_MUST_BE_REORDERD, "Index list has to be reordered", VS_VISIBLE }, -{ RET_INDEXLIST_EXCEEDS_MAX_LENGTH, "Index list exceeds its maximal physical length", VS_VISIBLE }, -{ RET_INDEXLIST_CORRUPTED, "Index list corrupted", VS_VISIBLE }, -{ RET_INDEXLIST_OUTOFBOUNDS, "Physical index is out of bounds", VS_VISIBLE }, -{ RET_INDEXLIST_ADD_FAILED, "Adding indices from another index set failed", VS_VISIBLE }, -{ RET_INDEXLIST_INTERSECT_FAILED, "Intersection with another index set failed", VS_VISIBLE }, -/* SubjectTo / Bounds / Constraints */ -{ RET_INDEX_ALREADY_OF_DESIRED_STATUS, "Index is already of desired status", VS_VISIBLE }, -{ RET_SWAPINDEX_FAILED, "Cannot swap between different indexsets", VS_VISIBLE }, -{ RET_ADDINDEX_FAILED, "Adding index to index set failed", VS_VISIBLE }, -{ RET_NOTHING_TO_DO, "Nothing to do", VS_VISIBLE }, -{ RET_SETUP_BOUND_FAILED, "Setting up bound index failed", VS_VISIBLE }, -{ RET_SETUP_CONSTRAINT_FAILED, "Setting up constraint index failed", VS_VISIBLE }, -{ RET_MOVING_BOUND_FAILED, "Moving bound between index sets failed", VS_VISIBLE }, -{ RET_MOVING_CONSTRAINT_FAILED, "Moving constraint between index sets failed", VS_VISIBLE }, -/* QProblem */ -{ RET_QP_ALREADY_INITIALISED, "QProblem has already been initialised", VS_VISIBLE }, -{ RET_NO_INIT_WITH_STANDARD_SOLVER, "Initialisation via extern QP solver is not yet implemented", VS_VISIBLE }, -{ RET_RESET_FAILED, "Reset failed", VS_VISIBLE }, -{ RET_INIT_FAILED, "Initialisation failed", VS_VISIBLE }, -{ RET_INIT_FAILED_TQ, "Initialisation failed due to TQ factorisation", VS_VISIBLE }, -{ RET_INIT_FAILED_CHOLESKY, "Initialisation failed due to Cholesky decomposition", VS_VISIBLE }, -{ RET_INIT_FAILED_HOTSTART, "Initialisation failed! QP could not be solved!", VS_VISIBLE }, -{ RET_INIT_FAILED_INFEASIBILITY, "Initial QP could not be solved due to infeasibility!", VS_VISIBLE }, -{ RET_INIT_FAILED_UNBOUNDEDNESS, "Initial QP could not be solved due to unboundedness!", VS_VISIBLE }, -{ RET_INIT_SUCCESSFUL, "Initialisation done", VS_VISIBLE }, -{ RET_OBTAINING_WORKINGSET_FAILED, "Failed to obtain working set for auxiliary QP", VS_VISIBLE }, -{ RET_SETUP_WORKINGSET_FAILED, "Failed to setup working set for auxiliary QP", VS_VISIBLE }, -{ RET_SETUP_AUXILIARYQP_FAILED, "Failed to setup auxiliary QP for initialised homotopy", VS_VISIBLE }, -{ RET_NO_EXTERN_SOLVER, "No extern QP solver available", VS_VISIBLE }, -{ RET_QP_UNBOUNDED, "QP is unbounded", VS_VISIBLE }, -{ RET_QP_INFEASIBLE, "QP is infeasible", VS_VISIBLE }, -{ RET_QP_NOT_SOLVED, "Problems occured while solving QP with standard solver", VS_VISIBLE }, -{ RET_QP_SOLVED, "QP successfully solved", VS_VISIBLE }, -{ RET_UNABLE_TO_SOLVE_QP, "Problems occured while solving QP", VS_VISIBLE }, -{ RET_INITIALISATION_STARTED, "Starting problem initialisation...", VS_VISIBLE }, -{ RET_HOTSTART_FAILED, "Unable to perform homotopy due to internal error", VS_VISIBLE }, -{ RET_HOTSTART_FAILED_TO_INIT, "Unable to initialise problem", VS_VISIBLE }, -{ RET_HOTSTART_FAILED_AS_QP_NOT_INITIALISED, "Unable to perform homotopy as previous QP is not solved", VS_VISIBLE }, -{ RET_ITERATION_STARTED, "Iteration", VS_VISIBLE }, -{ RET_SHIFT_DETERMINATION_FAILED, "Determination of shift of the QP data failed", VS_VISIBLE }, -{ RET_STEPDIRECTION_DETERMINATION_FAILED, "Determination of step direction failed", VS_VISIBLE }, -{ RET_STEPLENGTH_DETERMINATION_FAILED, "Determination of step direction failed", VS_VISIBLE }, -{ RET_OPTIMAL_SOLUTION_FOUND, "Optimal solution of neighbouring QP found", VS_VISIBLE }, -{ RET_HOMOTOPY_STEP_FAILED, "Unable to perform homotopy step", VS_VISIBLE }, -{ RET_HOTSTART_STOPPED_INFEASIBILITY, "Premature homotopy termination because QP is infeasible", VS_VISIBLE }, -{ RET_HOTSTART_STOPPED_UNBOUNDEDNESS, "Premature homotopy termination because QP is unbounded", VS_VISIBLE }, -{ RET_WORKINGSET_UPDATE_FAILED, "Unable to update working sets according to initial guesses", VS_VISIBLE }, -{ RET_MAX_NWSR_REACHED, "Maximum number of working set recalculations performed", VS_VISIBLE }, -{ RET_CONSTRAINTS_NOT_SPECIFIED, "Problem does comprise constraints! You have to specify new constraints' bounds", VS_VISIBLE }, -{ RET_INVALID_FACTORISATION_FLAG, "Invalid factorisation flag", VS_VISIBLE }, -{ RET_UNABLE_TO_SAVE_QPDATA, "Unable to save QP data", VS_VISIBLE }, -{ RET_STEPDIRECTION_FAILED_TQ, "Abnormal termination due to TQ factorisation", VS_VISIBLE }, -{ RET_STEPDIRECTION_FAILED_CHOLESKY, "Abnormal termination due to Cholesky factorisation", VS_VISIBLE }, -{ RET_CYCLING_DETECTED, "Cycling detected", VS_VISIBLE }, -{ RET_CYCLING_NOT_RESOLVED, "Cycling cannot be resolved, QP is probably infeasible", VS_VISIBLE }, -{ RET_CYCLING_RESOLVED, "Cycling probably resolved", VS_VISIBLE }, -{ RET_STEPSIZE, "", VS_VISIBLE }, -{ RET_STEPSIZE_NONPOSITIVE, "", VS_VISIBLE }, -{ RET_SETUPSUBJECTTOTYPE_FAILED, "Setup of SubjectToTypes failed", VS_VISIBLE }, -{ RET_ADDCONSTRAINT_FAILED, "Addition of constraint to working set failed", VS_VISIBLE }, -{ RET_ADDCONSTRAINT_FAILED_INFEASIBILITY, "Addition of constraint to working set failed", VS_VISIBLE }, -{ RET_ADDBOUND_FAILED, "Addition of bound to working set failed", VS_VISIBLE }, -{ RET_ADDBOUND_FAILED_INFEASIBILITY, "Addition of bound to working set failed", VS_VISIBLE }, -{ RET_REMOVECONSTRAINT_FAILED, "Removal of constraint from working set failed", VS_VISIBLE }, -{ RET_REMOVEBOUND_FAILED, "Removal of bound from working set failed", VS_VISIBLE }, -{ RET_REMOVE_FROM_ACTIVESET, "Removing from active set:", VS_VISIBLE }, -{ RET_ADD_TO_ACTIVESET, "Adding to active set:", VS_VISIBLE }, -{ RET_REMOVE_FROM_ACTIVESET_FAILED, "Removing from active set failed", VS_VISIBLE }, -{ RET_ADD_TO_ACTIVESET_FAILED, "Adding to active set failed", VS_VISIBLE }, -{ RET_CONSTRAINT_ALREADY_ACTIVE, "Constraint is already active", VS_VISIBLE }, -{ RET_ALL_CONSTRAINTS_ACTIVE, "All constraints are active, no further constraint can be added", VS_VISIBLE }, -{ RET_LINEARLY_DEPENDENT, "New bound/constraint is linearly dependent", VS_VISIBLE }, -{ RET_LINEARLY_INDEPENDENT, "New bound/constraint is linearly independent", VS_VISIBLE }, -{ RET_LI_RESOLVED, "Linear independence of active contraint matrix successfully resolved", VS_VISIBLE }, -{ RET_ENSURELI_FAILED, "Failed to ensure linear indepence of active contraint matrix", VS_VISIBLE }, -{ RET_ENSURELI_FAILED_TQ, "Abnormal termination due to TQ factorisation", VS_VISIBLE }, -{ RET_ENSURELI_FAILED_NOINDEX, "No index found, QP is probably infeasible", VS_VISIBLE }, -{ RET_ENSURELI_FAILED_CYCLING, "Cycling detected, QP is probably infeasible", VS_VISIBLE }, -{ RET_BOUND_ALREADY_ACTIVE, "Bound is already active", VS_VISIBLE }, -{ RET_ALL_BOUNDS_ACTIVE, "All bounds are active, no further bound can be added", VS_VISIBLE }, -{ RET_CONSTRAINT_NOT_ACTIVE, "Constraint is not active", VS_VISIBLE }, -{ RET_BOUND_NOT_ACTIVE, "Bound is not active", VS_VISIBLE }, -{ RET_HESSIAN_NOT_SPD, "Projected Hessian matrix not positive definite", VS_VISIBLE }, -{ RET_MATRIX_SHIFT_FAILED, "Unable to update matrices or to transform vectors", VS_VISIBLE }, -{ RET_MATRIX_FACTORISATION_FAILED, "Unable to calculate new matrix factorisations", VS_VISIBLE }, -{ RET_PRINT_ITERATION_FAILED, "Unable to print information on current iteration", VS_VISIBLE }, -{ RET_NO_GLOBAL_MESSAGE_OUTPUTFILE, "No global message output file initialised", VS_VISIBLE }, -/* Utils */ -{ RET_UNABLE_TO_OPEN_FILE, "Unable to open file", VS_VISIBLE }, -{ RET_UNABLE_TO_WRITE_FILE, "Unable to write into file", VS_VISIBLE }, -{ RET_UNABLE_TO_READ_FILE, "Unable to read from file", VS_VISIBLE }, -{ RET_FILEDATA_INCONSISTENT, "File contains inconsistent data", VS_VISIBLE }, -/* SolutionAnalysis */ -{ RET_NO_SOLUTION, "QP solution does not satisfy KKT optimality conditions", VS_VISIBLE }, -{ RET_INACCURATE_SOLUTION, "KKT optimality conditions not satisfied to sufficient accuracy", VS_VISIBLE }, -{ TERMINAL_LIST_ELEMENT, "", VS_HIDDEN } /* IMPORTANT: Terminal list element! */ -}; - - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - - -/* - * M e s s a g e H a n d l i n g - */ -MessageHandling::MessageHandling( ) : errorVisibility( VS_VISIBLE ), - warningVisibility( VS_VISIBLE ), - infoVisibility( VS_VISIBLE ), - outputFile( myStdout ), - errorCount( 0 ) -{ -} - -/* - * M e s s a g e H a n d l i n g - */ -MessageHandling::MessageHandling( myFILE* _outputFile ) : - errorVisibility( VS_VISIBLE ), - warningVisibility( VS_VISIBLE ), - infoVisibility( VS_VISIBLE ), - outputFile( _outputFile ), - errorCount( 0 ) -{ -} - -/* - * M e s s a g e H a n d l i n g - */ -MessageHandling::MessageHandling( VisibilityStatus _errorVisibility, - VisibilityStatus _warningVisibility, - VisibilityStatus _infoVisibility - ) : - errorVisibility( _errorVisibility ), - warningVisibility( _warningVisibility ), - infoVisibility( _infoVisibility ), - outputFile( myStderr ), - errorCount( 0 ) -{ -} - -/* - * M e s s a g e H a n d l i n g - */ -MessageHandling::MessageHandling( myFILE* _outputFile, - VisibilityStatus _errorVisibility, - VisibilityStatus _warningVisibility, - VisibilityStatus _infoVisibility - ) : - errorVisibility( _errorVisibility ), - warningVisibility( _warningVisibility ), - infoVisibility( _infoVisibility ), - outputFile( _outputFile ), - errorCount( 0 ) -{ -} - - - -/* - * M e s s a g e H a n d l i n g - */ -MessageHandling::MessageHandling( const MessageHandling& rhs ) : - errorVisibility( rhs.errorVisibility ), - warningVisibility( rhs.warningVisibility ), - infoVisibility( rhs.infoVisibility ), - outputFile( rhs.outputFile ), - errorCount( rhs.errorCount ) -{ -} - - -/* - * ~ M e s s a g e H a n d l i n g - */ -MessageHandling::~MessageHandling( ) -{ - #ifdef PC_DEBUG - if ( outputFile != 0 ) - fclose( outputFile ); - #endif -} - - -/* - * o p e r a t o r = - */ -MessageHandling& MessageHandling::operator=( const MessageHandling& rhs ) -{ - if ( this != &rhs ) - { - errorVisibility = rhs.errorVisibility; - warningVisibility = rhs.warningVisibility; - infoVisibility = rhs.infoVisibility; - outputFile = rhs.outputFile; - errorCount = rhs.errorCount; - } - - return *this; -} - - -/* - * t h r o w E r r o r - */ -returnValue MessageHandling::throwError( - returnValue Enumber, - const char* additionaltext, - const char* functionname, - const char* filename, - const unsigned long linenumber, - VisibilityStatus localVisibilityStatus - ) -{ - /* consistency check */ - if ( Enumber <= SUCCESSFUL_RETURN ) - return throwError( RET_ERROR_UNDEFINED,0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - - /* Call to common throwMessage function if error shall be displayed. */ - if ( errorVisibility == VS_VISIBLE ) - return throwMessage( Enumber,additionaltext,functionname,filename,linenumber,localVisibilityStatus,"ERROR" ); - else - return Enumber; -} - - -/* - * t h r o w W a r n i n g - */ -returnValue MessageHandling::throwWarning( - returnValue Wnumber, - const char* additionaltext, - const char* functionname, - const char* filename, - const unsigned long linenumber, - VisibilityStatus localVisibilityStatus - ) -{ - /* consistency check */ - if ( Wnumber <= SUCCESSFUL_RETURN ) - return throwError( RET_WARNING_UNDEFINED,0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - - /* Call to common throwMessage function if warning shall be displayed. */ - if ( warningVisibility == VS_VISIBLE ) - return throwMessage( Wnumber,additionaltext,functionname,filename,linenumber,localVisibilityStatus,"WARNING" ); - else - return Wnumber; -} - - -/* - * t h r o w I n f o - */ -returnValue MessageHandling::throwInfo( - returnValue Inumber, - const char* additionaltext, - const char* functionname, - const char* filename, - const unsigned long linenumber, - VisibilityStatus localVisibilityStatus - ) -{ - /* consistency check */ - if ( Inumber < SUCCESSFUL_RETURN ) - return throwError( RET_INFO_UNDEFINED,0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - - /* Call to common throwMessage function if info shall be displayed. */ - if ( infoVisibility == VS_VISIBLE ) - return throwMessage( Inumber,additionaltext,functionname,filename,linenumber,localVisibilityStatus,"INFO" ); - else - return Inumber; -} - - -/* - * r e s e t - */ -returnValue MessageHandling::reset( ) -{ - setErrorVisibilityStatus( VS_VISIBLE ); - setWarningVisibilityStatus( VS_VISIBLE ); - setInfoVisibilityStatus( VS_VISIBLE ); - - setOutputFile( myStderr ); - setErrorCount( 0 ); - - return SUCCESSFUL_RETURN; -} - - -/* - * l i s t A l l M e s s a g e s - */ -returnValue MessageHandling::listAllMessages( ) -{ - #ifdef PC_DEBUG - int keypos = 0; - char myPrintfString[160]; - - /* Run through whole returnValueList and print each item. */ - while ( returnValueList[keypos].key != TERMINAL_LIST_ELEMENT ) - { - sprintf( myPrintfString," %d - %s \n",keypos,returnValueList[keypos].data ); - myPrintf( myPrintfString ); - - ++keypos; - } - #endif - - return SUCCESSFUL_RETURN; -} - - - -/***************************************************************************** - * P R O T E C T E D * - *****************************************************************************/ - - -#ifdef PC_DEBUG /* Re-define throwMessage function for embedded code! */ - -/* - * t h r o w M e s s a g e - */ -returnValue MessageHandling::throwMessage( - returnValue RETnumber, - const char* additionaltext, - const char* functionname, - const char* filename, - const unsigned long linenumber, - VisibilityStatus localVisibilityStatus, - const char* RETstring - ) -{ - int i; - - int keypos = 0; - char myPrintfString[160]; - - /* 1) Determine number of whitespace for output. */ - char whitespaces[41]; - int numberOfWhitespaces = (errorCount-1)*2; - - if ( numberOfWhitespaces < 0 ) - numberOfWhitespaces = 0; - - if ( numberOfWhitespaces > 40 ) - numberOfWhitespaces = 40; - - for( i=0; i 0 ) - { - sprintf( myPrintfString,"%s->", whitespaces ); - myPrintf( myPrintfString ); - } - - if ( additionaltext == 0 ) - { - sprintf( myPrintfString,"%s (%s, %s:%d): \t%s\n", - RETstring,functionname,filename,(int)linenumber,returnValueList[keypos].data - ); - myPrintf( myPrintfString ); - } - else - { - sprintf( myPrintfString,"%s (%s, %s:%d): \t%s %s\n", - RETstring,functionname,filename,(int)linenumber,returnValueList[keypos].data,additionaltext - ); - myPrintf( myPrintfString ); - } - - /* take care of proper indention for subsequent error messages */ - if ( RETstring[0] == 'E' ) - { - ++errorCount; - } - else - { - if ( errorCount > 0 ) - myPrintf( "\n" ); - errorCount = 0; - } - } - - return RETnumber; -} - -#else /* = PC_DEBUG not defined */ - -/* - * t h r o w M e s s a g e - */ -returnValue MessageHandling::throwMessage( - returnValue RETnumber, - const char* additionaltext, - const char* functionname, - const char* filename, - const unsigned long linenumber, - VisibilityStatus localVisibilityStatus, - const char* RETstring - ) -{ - /* DUMMY CODE FOR PRETENDING USE OF ARGUMENTS - * FOR SUPPRESSING COMPILER WARNINGS! */ - int i = 0; - if ( additionaltext == 0 ) i++; - if ( functionname == 0 ) i++; - if ( filename == 0 ) i++; - if ( linenumber == 0 ) i++; - if ( localVisibilityStatus == VS_VISIBLE ) i++; - if ( RETstring == 0 ) i++; - /* END OF DUMMY CODE */ - - return RETnumber; -} - -#endif /* PC_DEBUG */ - - - -/***************************************************************************** - * G L O B A L M E S S A G E H A N D L E R * - *****************************************************************************/ - - -/** Global message handler for all qpOASES modules.*/ -MessageHandling globalMessageHandler( myStderr,VS_VISIBLE,VS_VISIBLE,VS_VISIBLE ); - - -/* - * g e t G l o b a l M e s s a g e H a n d l e r - */ -MessageHandling* getGlobalMessageHandler( ) -{ - return &globalMessageHandler; -} - -const char* MessageHandling::getErrorString(int error) -{ - return returnValueList[ error ].data; -} - - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file SRC/MessageHandling.cpp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Implementation of the MessageHandling class including global return values. + * + */ + + + +#include +#include + + + + +/** Defines pairs of global return values and messages. */ +MessageHandling::ReturnValueList returnValueList[] = +{ +/* miscellaneous */ +{ SUCCESSFUL_RETURN, "Successful return", VS_VISIBLE }, +{ RET_DIV_BY_ZERO, "Division by zero", VS_VISIBLE }, +{ RET_INDEX_OUT_OF_BOUNDS, "Index out of bounds", VS_VISIBLE }, +{ RET_INVALID_ARGUMENTS, "At least one of the arguments is invalid", VS_VISIBLE }, +{ RET_ERROR_UNDEFINED, "Error number undefined", VS_VISIBLE }, +{ RET_WARNING_UNDEFINED, "Warning number undefined", VS_VISIBLE }, +{ RET_INFO_UNDEFINED, "Info number undefined", VS_VISIBLE }, +{ RET_EWI_UNDEFINED, "Error/warning/info number undefined", VS_VISIBLE }, +{ RET_AVAILABLE_WITH_LINUX_ONLY, "This function is available under Linux only", VS_HIDDEN }, +{ RET_UNKNOWN_BUG, "The error occured is not yet known", VS_VISIBLE }, +{ RET_PRINTLEVEL_CHANGED, "Print level changed", VS_VISIBLE }, +{ RET_NOT_YET_IMPLEMENTED, "Requested function is not yet implemented.", VS_VISIBLE }, +/* Indexlist */ +{ RET_INDEXLIST_MUST_BE_REORDERD, "Index list has to be reordered", VS_VISIBLE }, +{ RET_INDEXLIST_EXCEEDS_MAX_LENGTH, "Index list exceeds its maximal physical length", VS_VISIBLE }, +{ RET_INDEXLIST_CORRUPTED, "Index list corrupted", VS_VISIBLE }, +{ RET_INDEXLIST_OUTOFBOUNDS, "Physical index is out of bounds", VS_VISIBLE }, +{ RET_INDEXLIST_ADD_FAILED, "Adding indices from another index set failed", VS_VISIBLE }, +{ RET_INDEXLIST_INTERSECT_FAILED, "Intersection with another index set failed", VS_VISIBLE }, +/* SubjectTo / Bounds / Constraints */ +{ RET_INDEX_ALREADY_OF_DESIRED_STATUS, "Index is already of desired status", VS_VISIBLE }, +{ RET_SWAPINDEX_FAILED, "Cannot swap between different indexsets", VS_VISIBLE }, +{ RET_ADDINDEX_FAILED, "Adding index to index set failed", VS_VISIBLE }, +{ RET_NOTHING_TO_DO, "Nothing to do", VS_VISIBLE }, +{ RET_SETUP_BOUND_FAILED, "Setting up bound index failed", VS_VISIBLE }, +{ RET_SETUP_CONSTRAINT_FAILED, "Setting up constraint index failed", VS_VISIBLE }, +{ RET_MOVING_BOUND_FAILED, "Moving bound between index sets failed", VS_VISIBLE }, +{ RET_MOVING_CONSTRAINT_FAILED, "Moving constraint between index sets failed", VS_VISIBLE }, +/* QProblem */ +{ RET_QP_ALREADY_INITIALISED, "QProblem has already been initialised", VS_VISIBLE }, +{ RET_NO_INIT_WITH_STANDARD_SOLVER, "Initialisation via extern QP solver is not yet implemented", VS_VISIBLE }, +{ RET_RESET_FAILED, "Reset failed", VS_VISIBLE }, +{ RET_INIT_FAILED, "Initialisation failed", VS_VISIBLE }, +{ RET_INIT_FAILED_TQ, "Initialisation failed due to TQ factorisation", VS_VISIBLE }, +{ RET_INIT_FAILED_CHOLESKY, "Initialisation failed due to Cholesky decomposition", VS_VISIBLE }, +{ RET_INIT_FAILED_HOTSTART, "Initialisation failed! QP could not be solved!", VS_VISIBLE }, +{ RET_INIT_FAILED_INFEASIBILITY, "Initial QP could not be solved due to infeasibility!", VS_VISIBLE }, +{ RET_INIT_FAILED_UNBOUNDEDNESS, "Initial QP could not be solved due to unboundedness!", VS_VISIBLE }, +{ RET_INIT_SUCCESSFUL, "Initialisation done", VS_VISIBLE }, +{ RET_OBTAINING_WORKINGSET_FAILED, "Failed to obtain working set for auxiliary QP", VS_VISIBLE }, +{ RET_SETUP_WORKINGSET_FAILED, "Failed to setup working set for auxiliary QP", VS_VISIBLE }, +{ RET_SETUP_AUXILIARYQP_FAILED, "Failed to setup auxiliary QP for initialised homotopy", VS_VISIBLE }, +{ RET_NO_EXTERN_SOLVER, "No extern QP solver available", VS_VISIBLE }, +{ RET_QP_UNBOUNDED, "QP is unbounded", VS_VISIBLE }, +{ RET_QP_INFEASIBLE, "QP is infeasible", VS_VISIBLE }, +{ RET_QP_NOT_SOLVED, "Problems occured while solving QP with standard solver", VS_VISIBLE }, +{ RET_QP_SOLVED, "QP successfully solved", VS_VISIBLE }, +{ RET_UNABLE_TO_SOLVE_QP, "Problems occured while solving QP", VS_VISIBLE }, +{ RET_INITIALISATION_STARTED, "Starting problem initialisation...", VS_VISIBLE }, +{ RET_HOTSTART_FAILED, "Unable to perform homotopy due to internal error", VS_VISIBLE }, +{ RET_HOTSTART_FAILED_TO_INIT, "Unable to initialise problem", VS_VISIBLE }, +{ RET_HOTSTART_FAILED_AS_QP_NOT_INITIALISED, "Unable to perform homotopy as previous QP is not solved", VS_VISIBLE }, +{ RET_ITERATION_STARTED, "Iteration", VS_VISIBLE }, +{ RET_SHIFT_DETERMINATION_FAILED, "Determination of shift of the QP data failed", VS_VISIBLE }, +{ RET_STEPDIRECTION_DETERMINATION_FAILED, "Determination of step direction failed", VS_VISIBLE }, +{ RET_STEPLENGTH_DETERMINATION_FAILED, "Determination of step direction failed", VS_VISIBLE }, +{ RET_OPTIMAL_SOLUTION_FOUND, "Optimal solution of neighbouring QP found", VS_VISIBLE }, +{ RET_HOMOTOPY_STEP_FAILED, "Unable to perform homotopy step", VS_VISIBLE }, +{ RET_HOTSTART_STOPPED_INFEASIBILITY, "Premature homotopy termination because QP is infeasible", VS_VISIBLE }, +{ RET_HOTSTART_STOPPED_UNBOUNDEDNESS, "Premature homotopy termination because QP is unbounded", VS_VISIBLE }, +{ RET_WORKINGSET_UPDATE_FAILED, "Unable to update working sets according to initial guesses", VS_VISIBLE }, +{ RET_MAX_NWSR_REACHED, "Maximum number of working set recalculations performed", VS_VISIBLE }, +{ RET_CONSTRAINTS_NOT_SPECIFIED, "Problem does comprise constraints! You have to specify new constraints' bounds", VS_VISIBLE }, +{ RET_INVALID_FACTORISATION_FLAG, "Invalid factorisation flag", VS_VISIBLE }, +{ RET_UNABLE_TO_SAVE_QPDATA, "Unable to save QP data", VS_VISIBLE }, +{ RET_STEPDIRECTION_FAILED_TQ, "Abnormal termination due to TQ factorisation", VS_VISIBLE }, +{ RET_STEPDIRECTION_FAILED_CHOLESKY, "Abnormal termination due to Cholesky factorisation", VS_VISIBLE }, +{ RET_CYCLING_DETECTED, "Cycling detected", VS_VISIBLE }, +{ RET_CYCLING_NOT_RESOLVED, "Cycling cannot be resolved, QP is probably infeasible", VS_VISIBLE }, +{ RET_CYCLING_RESOLVED, "Cycling probably resolved", VS_VISIBLE }, +{ RET_STEPSIZE, "", VS_VISIBLE }, +{ RET_STEPSIZE_NONPOSITIVE, "", VS_VISIBLE }, +{ RET_SETUPSUBJECTTOTYPE_FAILED, "Setup of SubjectToTypes failed", VS_VISIBLE }, +{ RET_ADDCONSTRAINT_FAILED, "Addition of constraint to working set failed", VS_VISIBLE }, +{ RET_ADDCONSTRAINT_FAILED_INFEASIBILITY, "Addition of constraint to working set failed", VS_VISIBLE }, +{ RET_ADDBOUND_FAILED, "Addition of bound to working set failed", VS_VISIBLE }, +{ RET_ADDBOUND_FAILED_INFEASIBILITY, "Addition of bound to working set failed", VS_VISIBLE }, +{ RET_REMOVECONSTRAINT_FAILED, "Removal of constraint from working set failed", VS_VISIBLE }, +{ RET_REMOVEBOUND_FAILED, "Removal of bound from working set failed", VS_VISIBLE }, +{ RET_REMOVE_FROM_ACTIVESET, "Removing from active set:", VS_VISIBLE }, +{ RET_ADD_TO_ACTIVESET, "Adding to active set:", VS_VISIBLE }, +{ RET_REMOVE_FROM_ACTIVESET_FAILED, "Removing from active set failed", VS_VISIBLE }, +{ RET_ADD_TO_ACTIVESET_FAILED, "Adding to active set failed", VS_VISIBLE }, +{ RET_CONSTRAINT_ALREADY_ACTIVE, "Constraint is already active", VS_VISIBLE }, +{ RET_ALL_CONSTRAINTS_ACTIVE, "All constraints are active, no further constraint can be added", VS_VISIBLE }, +{ RET_LINEARLY_DEPENDENT, "New bound/constraint is linearly dependent", VS_VISIBLE }, +{ RET_LINEARLY_INDEPENDENT, "New bound/constraint is linearly independent", VS_VISIBLE }, +{ RET_LI_RESOLVED, "Linear independence of active contraint matrix successfully resolved", VS_VISIBLE }, +{ RET_ENSURELI_FAILED, "Failed to ensure linear indepence of active contraint matrix", VS_VISIBLE }, +{ RET_ENSURELI_FAILED_TQ, "Abnormal termination due to TQ factorisation", VS_VISIBLE }, +{ RET_ENSURELI_FAILED_NOINDEX, "No index found, QP is probably infeasible", VS_VISIBLE }, +{ RET_ENSURELI_FAILED_CYCLING, "Cycling detected, QP is probably infeasible", VS_VISIBLE }, +{ RET_BOUND_ALREADY_ACTIVE, "Bound is already active", VS_VISIBLE }, +{ RET_ALL_BOUNDS_ACTIVE, "All bounds are active, no further bound can be added", VS_VISIBLE }, +{ RET_CONSTRAINT_NOT_ACTIVE, "Constraint is not active", VS_VISIBLE }, +{ RET_BOUND_NOT_ACTIVE, "Bound is not active", VS_VISIBLE }, +{ RET_HESSIAN_NOT_SPD, "Projected Hessian matrix not positive definite", VS_VISIBLE }, +{ RET_MATRIX_SHIFT_FAILED, "Unable to update matrices or to transform vectors", VS_VISIBLE }, +{ RET_MATRIX_FACTORISATION_FAILED, "Unable to calculate new matrix factorisations", VS_VISIBLE }, +{ RET_PRINT_ITERATION_FAILED, "Unable to print information on current iteration", VS_VISIBLE }, +{ RET_NO_GLOBAL_MESSAGE_OUTPUTFILE, "No global message output file initialised", VS_VISIBLE }, +/* Utils */ +{ RET_UNABLE_TO_OPEN_FILE, "Unable to open file", VS_VISIBLE }, +{ RET_UNABLE_TO_WRITE_FILE, "Unable to write into file", VS_VISIBLE }, +{ RET_UNABLE_TO_READ_FILE, "Unable to read from file", VS_VISIBLE }, +{ RET_FILEDATA_INCONSISTENT, "File contains inconsistent data", VS_VISIBLE }, +/* SolutionAnalysis */ +{ RET_NO_SOLUTION, "QP solution does not satisfy KKT optimality conditions", VS_VISIBLE }, +{ RET_INACCURATE_SOLUTION, "KKT optimality conditions not satisfied to sufficient accuracy", VS_VISIBLE }, +{ TERMINAL_LIST_ELEMENT, "", VS_HIDDEN } /* IMPORTANT: Terminal list element! */ +}; + + + +/***************************************************************************** + * P U B L I C * + *****************************************************************************/ + + +/* + * M e s s a g e H a n d l i n g + */ +MessageHandling::MessageHandling( ) : errorVisibility( VS_VISIBLE ), + warningVisibility( VS_VISIBLE ), + infoVisibility( VS_VISIBLE ), + outputFile( myStdout ), + errorCount( 0 ) +{ +} + +/* + * M e s s a g e H a n d l i n g + */ +MessageHandling::MessageHandling( myFILE* _outputFile ) : + errorVisibility( VS_VISIBLE ), + warningVisibility( VS_VISIBLE ), + infoVisibility( VS_VISIBLE ), + outputFile( _outputFile ), + errorCount( 0 ) +{ +} + +/* + * M e s s a g e H a n d l i n g + */ +MessageHandling::MessageHandling( VisibilityStatus _errorVisibility, + VisibilityStatus _warningVisibility, + VisibilityStatus _infoVisibility + ) : + errorVisibility( _errorVisibility ), + warningVisibility( _warningVisibility ), + infoVisibility( _infoVisibility ), + outputFile( myStderr ), + errorCount( 0 ) +{ +} + +/* + * M e s s a g e H a n d l i n g + */ +MessageHandling::MessageHandling( myFILE* _outputFile, + VisibilityStatus _errorVisibility, + VisibilityStatus _warningVisibility, + VisibilityStatus _infoVisibility + ) : + errorVisibility( _errorVisibility ), + warningVisibility( _warningVisibility ), + infoVisibility( _infoVisibility ), + outputFile( _outputFile ), + errorCount( 0 ) +{ +} + + + +/* + * M e s s a g e H a n d l i n g + */ +MessageHandling::MessageHandling( const MessageHandling& rhs ) : + errorVisibility( rhs.errorVisibility ), + warningVisibility( rhs.warningVisibility ), + infoVisibility( rhs.infoVisibility ), + outputFile( rhs.outputFile ), + errorCount( rhs.errorCount ) +{ +} + + +/* + * ~ M e s s a g e H a n d l i n g + */ +MessageHandling::~MessageHandling( ) +{ + #ifdef PC_DEBUG + if ( outputFile != 0 ) + fclose( outputFile ); + #endif +} + + +/* + * o p e r a t o r = + */ +MessageHandling& MessageHandling::operator=( const MessageHandling& rhs ) +{ + if ( this != &rhs ) + { + errorVisibility = rhs.errorVisibility; + warningVisibility = rhs.warningVisibility; + infoVisibility = rhs.infoVisibility; + outputFile = rhs.outputFile; + errorCount = rhs.errorCount; + } + + return *this; +} + + +/* + * t h r o w E r r o r + */ +returnValue MessageHandling::throwError( + returnValue Enumber, + const char* additionaltext, + const char* functionname, + const char* filename, + const unsigned long linenumber, + VisibilityStatus localVisibilityStatus + ) +{ + /* consistency check */ + if ( Enumber <= SUCCESSFUL_RETURN ) + return throwError( RET_ERROR_UNDEFINED,0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); + + /* Call to common throwMessage function if error shall be displayed. */ + if ( errorVisibility == VS_VISIBLE ) + return throwMessage( Enumber,additionaltext,functionname,filename,linenumber,localVisibilityStatus,"ERROR" ); + else + return Enumber; +} + + +/* + * t h r o w W a r n i n g + */ +returnValue MessageHandling::throwWarning( + returnValue Wnumber, + const char* additionaltext, + const char* functionname, + const char* filename, + const unsigned long linenumber, + VisibilityStatus localVisibilityStatus + ) +{ + /* consistency check */ + if ( Wnumber <= SUCCESSFUL_RETURN ) + return throwError( RET_WARNING_UNDEFINED,0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); + + /* Call to common throwMessage function if warning shall be displayed. */ + if ( warningVisibility == VS_VISIBLE ) + return throwMessage( Wnumber,additionaltext,functionname,filename,linenumber,localVisibilityStatus,"WARNING" ); + else + return Wnumber; +} + + +/* + * t h r o w I n f o + */ +returnValue MessageHandling::throwInfo( + returnValue Inumber, + const char* additionaltext, + const char* functionname, + const char* filename, + const unsigned long linenumber, + VisibilityStatus localVisibilityStatus + ) +{ + /* consistency check */ + if ( Inumber < SUCCESSFUL_RETURN ) + return throwError( RET_INFO_UNDEFINED,0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); + + /* Call to common throwMessage function if info shall be displayed. */ + if ( infoVisibility == VS_VISIBLE ) + return throwMessage( Inumber,additionaltext,functionname,filename,linenumber,localVisibilityStatus,"INFO" ); + else + return Inumber; +} + + +/* + * r e s e t + */ +returnValue MessageHandling::reset( ) +{ + setErrorVisibilityStatus( VS_VISIBLE ); + setWarningVisibilityStatus( VS_VISIBLE ); + setInfoVisibilityStatus( VS_VISIBLE ); + + setOutputFile( myStderr ); + setErrorCount( 0 ); + + return SUCCESSFUL_RETURN; +} + + +/* + * l i s t A l l M e s s a g e s + */ +returnValue MessageHandling::listAllMessages( ) +{ + #ifdef PC_DEBUG + int keypos = 0; + char myPrintfString[160]; + + /* Run through whole returnValueList and print each item. */ + while ( returnValueList[keypos].key != TERMINAL_LIST_ELEMENT ) + { + sprintf( myPrintfString," %d - %s \n",keypos,returnValueList[keypos].data ); + myPrintf( myPrintfString ); + + ++keypos; + } + #endif + + return SUCCESSFUL_RETURN; +} + + + +/***************************************************************************** + * P R O T E C T E D * + *****************************************************************************/ + + +#ifdef PC_DEBUG /* Re-define throwMessage function for embedded code! */ + +/* + * t h r o w M e s s a g e + */ +returnValue MessageHandling::throwMessage( + returnValue RETnumber, + const char* additionaltext, + const char* functionname, + const char* filename, + const unsigned long linenumber, + VisibilityStatus localVisibilityStatus, + const char* RETstring + ) +{ + int i; + + int keypos = 0; + char myPrintfString[160]; + + /* 1) Determine number of whitespace for output. */ + char whitespaces[41]; + int numberOfWhitespaces = (errorCount-1)*2; + + if ( numberOfWhitespaces < 0 ) + numberOfWhitespaces = 0; + + if ( numberOfWhitespaces > 40 ) + numberOfWhitespaces = 40; + + for( i=0; i 0 ) + { + sprintf( myPrintfString,"%s->", whitespaces ); + myPrintf( myPrintfString ); + } + + if ( additionaltext == 0 ) + { + sprintf( myPrintfString,"%s (%s, %s:%d): \t%s\n", + RETstring,functionname,filename,(int)linenumber,returnValueList[keypos].data + ); + myPrintf( myPrintfString ); + } + else + { + sprintf( myPrintfString,"%s (%s, %s:%d): \t%s %s\n", + RETstring,functionname,filename,(int)linenumber,returnValueList[keypos].data,additionaltext + ); + myPrintf( myPrintfString ); + } + + /* take care of proper indention for subsequent error messages */ + if ( RETstring[0] == 'E' ) + { + ++errorCount; + } + else + { + if ( errorCount > 0 ) + myPrintf( "\n" ); + errorCount = 0; + } + } + + return RETnumber; +} + +#else /* = PC_DEBUG not defined */ + +/* + * t h r o w M e s s a g e + */ +returnValue MessageHandling::throwMessage( + returnValue RETnumber, + const char* additionaltext, + const char* functionname, + const char* filename, + const unsigned long linenumber, + VisibilityStatus localVisibilityStatus, + const char* RETstring + ) +{ + /* DUMMY CODE FOR PRETENDING USE OF ARGUMENTS + * FOR SUPPRESSING COMPILER WARNINGS! */ + int i = 0; + if ( additionaltext == 0 ) i++; + if ( functionname == 0 ) i++; + if ( filename == 0 ) i++; + if ( linenumber == 0 ) i++; + if ( localVisibilityStatus == VS_VISIBLE ) i++; + if ( RETstring == 0 ) i++; + /* END OF DUMMY CODE */ + + return RETnumber; +} + +#endif /* PC_DEBUG */ + + + +/***************************************************************************** + * G L O B A L M E S S A G E H A N D L E R * + *****************************************************************************/ + + +/** Global message handler for all qpOASES modules.*/ +MessageHandling globalMessageHandler( myStderr,VS_VISIBLE,VS_VISIBLE,VS_VISIBLE ); + + +/* + * g e t G l o b a l M e s s a g e H a n d l e r + */ +MessageHandling* getGlobalMessageHandler( ) +{ + return &globalMessageHandler; +} + +const char* MessageHandling::getErrorString(int error) +{ + return returnValueList[ error ].data; +} + + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/SRC/MessageHandling.ipp b/phonelibs/qpoases/SRC/MessageHandling.ipp index ad9624b3d69a62..033957b2842610 100644 --- a/phonelibs/qpoases/SRC/MessageHandling.ipp +++ b/phonelibs/qpoases/SRC/MessageHandling.ipp @@ -1,137 +1,137 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/MessageHandling.ipp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of inlined member functions of the MessageHandling class. - */ - - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - -/* - * g e t E r r o r V i s i b i l i t y S t a t u s - */ -inline VisibilityStatus MessageHandling::getErrorVisibilityStatus( ) const -{ - return errorVisibility; -} - - -/* - * g e t W a r n i n g V i s i b i l i t y S t a t u s - */ -inline VisibilityStatus MessageHandling::getWarningVisibilityStatus( ) const -{ - return warningVisibility; -} - - -/* - * g e t I n f o V i s i b i l i t y S t a t u s - */ -inline VisibilityStatus MessageHandling::getInfoVisibilityStatus( ) const -{ - return infoVisibility; -} - - -/* - * g e t O u t p u t F i l e - */ -inline myFILE* MessageHandling::getOutputFile( ) const -{ - return outputFile; -} - - -/* - * g e t E r r o r C o u n t - */ -inline int MessageHandling::getErrorCount( ) const -{ - return errorCount; -} - - -/* - * s e t E r r o r V i s i b i l i t y S t a t u s - */ -inline void MessageHandling::setErrorVisibilityStatus( VisibilityStatus _errorVisibility ) -{ - errorVisibility = _errorVisibility; -} - - -/* - * s e t W a r n i n g V i s i b i l i t y S t a t u s - */ -inline void MessageHandling::setWarningVisibilityStatus( VisibilityStatus _warningVisibility ) -{ - warningVisibility = _warningVisibility; -} - - -/* - * s e t I n f o V i s i b i l i t y S t a t u s - */ -inline void MessageHandling::setInfoVisibilityStatus( VisibilityStatus _infoVisibility ) -{ - infoVisibility = _infoVisibility; -} - - -/* - * s e t O u t p u t F i l e - */ -inline void MessageHandling::setOutputFile( myFILE* _outputFile ) -{ - outputFile = _outputFile; -} - - -/* - * s e t E r r o r C o u n t - */ -inline returnValue MessageHandling::setErrorCount( int _errorCount ) -{ - if ( _errorCount >= 0 ) - { - errorCount = _errorCount; - return SUCCESSFUL_RETURN; - } - else - return RET_INVALID_ARGUMENTS; -} - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file SRC/MessageHandling.ipp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Implementation of inlined member functions of the MessageHandling class. + */ + + + +/***************************************************************************** + * P U B L I C * + *****************************************************************************/ + +/* + * g e t E r r o r V i s i b i l i t y S t a t u s + */ +inline VisibilityStatus MessageHandling::getErrorVisibilityStatus( ) const +{ + return errorVisibility; +} + + +/* + * g e t W a r n i n g V i s i b i l i t y S t a t u s + */ +inline VisibilityStatus MessageHandling::getWarningVisibilityStatus( ) const +{ + return warningVisibility; +} + + +/* + * g e t I n f o V i s i b i l i t y S t a t u s + */ +inline VisibilityStatus MessageHandling::getInfoVisibilityStatus( ) const +{ + return infoVisibility; +} + + +/* + * g e t O u t p u t F i l e + */ +inline myFILE* MessageHandling::getOutputFile( ) const +{ + return outputFile; +} + + +/* + * g e t E r r o r C o u n t + */ +inline int MessageHandling::getErrorCount( ) const +{ + return errorCount; +} + + +/* + * s e t E r r o r V i s i b i l i t y S t a t u s + */ +inline void MessageHandling::setErrorVisibilityStatus( VisibilityStatus _errorVisibility ) +{ + errorVisibility = _errorVisibility; +} + + +/* + * s e t W a r n i n g V i s i b i l i t y S t a t u s + */ +inline void MessageHandling::setWarningVisibilityStatus( VisibilityStatus _warningVisibility ) +{ + warningVisibility = _warningVisibility; +} + + +/* + * s e t I n f o V i s i b i l i t y S t a t u s + */ +inline void MessageHandling::setInfoVisibilityStatus( VisibilityStatus _infoVisibility ) +{ + infoVisibility = _infoVisibility; +} + + +/* + * s e t O u t p u t F i l e + */ +inline void MessageHandling::setOutputFile( myFILE* _outputFile ) +{ + outputFile = _outputFile; +} + + +/* + * s e t E r r o r C o u n t + */ +inline returnValue MessageHandling::setErrorCount( int _errorCount ) +{ + if ( _errorCount >= 0 ) + { + errorCount = _errorCount; + return SUCCESSFUL_RETURN; + } + else + return RET_INVALID_ARGUMENTS; +} + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/SRC/QProblem.cpp b/phonelibs/qpoases/SRC/QProblem.cpp index 68a6a79e534f65..75e2f324d567c5 100644 --- a/phonelibs/qpoases/SRC/QProblem.cpp +++ b/phonelibs/qpoases/SRC/QProblem.cpp @@ -1,3867 +1,3867 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/QProblem.cpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of the QProblem class which is able to use the newly - * developed online active set strategy for parametric quadratic programming. - */ - - -#include - -#include - -void printmatrix2(char *name, double *A, int m, int n) { - int i, j; - - printf("%s = [...\n", name); - for (i = 0; i < m; i++) { - for (j = 0; j < n; j++) - printf(" % 9.4f", A[i*n+j]); - printf(",\n"); - } - printf("];\n"); -} - -//#define __PERFORM_KKT_TEST__ - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - - -/* - * Q P r o b l e m - */ -QProblem::QProblem( ) : QProblemB( ) -{ - constraints.init( 0 ); - - sizeT = 0; - - cyclingManager.init( 0,0 ); -} - - -/* - * Q P r o b l e m - */ -QProblem::QProblem( int _nV, int _nC ) : QProblemB( _nV ) -{ - /* consistency checks */ - if ( _nV <= 0 ) - _nV = 1; - - if ( _nC < 0 ) - { - _nC = 0; - THROWERROR( RET_INVALID_ARGUMENTS ); - } - - constraints.init( _nC ); - - - sizeT = _nC; - if ( _nC > _nV ) - sizeT = _nV; - - cyclingManager.init( _nV,_nC ); -} - - -/* - * Q P r o b l e m - */ -QProblem::QProblem( const QProblem& rhs ) : QProblemB( rhs ) -{ - int i, j; - - int _nV = rhs.bounds.getNV( ); - int _nC = rhs.constraints.getNC( ); - - for( i=0; i<_nC; ++i ) - for( j=0; j<_nV; ++j ) - A[i*NVMAX + j] = rhs.A[i*NVMAX + j]; - - for( i=0; i<_nC; ++i ) - lbA[i] = rhs.lbA[i]; - - for( i=0; i<_nC; ++i ) - ubA[i] = rhs.ubA[i]; - - constraints = rhs.constraints; - - for( i=0; i<(_nV+_nC); ++i ) - y[i] = rhs.y[i]; - - - sizeT = rhs.sizeT; - - for( i=0; ithrowInfo( RET_ITERATION_STARTED,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - #endif - } - - /* 1) Setup index arrays. */ - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - if ( bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - if ( constraints.getActive( )->getNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - if ( constraints.getInactive( )->getNumberArray( IAC_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - /* 2) Detemination of shift direction of the gradient and the (constraints') bounds. */ - returnvalue = hotstart_determineDataShift( FX_idx, AC_idx, - g_new,lbA_new,ubA_new,lb_new,ub_new, - delta_g,delta_lbA,delta_ubA,delta_lb,delta_ub, - Delta_bC_isZero, Delta_bB_isZero ); - if ( returnvalue != SUCCESSFUL_RETURN ) - { - nWSR = l; - THROWERROR( RET_SHIFT_DETERMINATION_FAILED ); - return returnvalue; - } - - /* 3) Determination of step direction of X and Y. */ - returnvalue = hotstart_determineStepDirection( FR_idx,FX_idx,AC_idx, - delta_g,delta_lbA,delta_ubA,delta_lb,delta_ub, - Delta_bC_isZero, Delta_bB_isZero, - delta_xFX,delta_xFR,delta_yAC,delta_yFX - ); - if ( returnvalue != SUCCESSFUL_RETURN ) - { - nWSR = l; - THROWERROR( RET_STEPDIRECTION_DETERMINATION_FAILED ); - return returnvalue; - } - - /* 4) Determination of step length TAU. */ - returnvalue = hotstart_determineStepLength( FR_idx,FX_idx,AC_idx,IAC_idx, - delta_lbA,delta_ubA,delta_lb,delta_ub, - delta_xFX,delta_xFR,delta_yAC,delta_yFX,delta_Ax, - BC_idx,BC_status,BC_isBound - ); - if ( returnvalue != SUCCESSFUL_RETURN ) - { - nWSR = l; - THROWERROR( RET_STEPLENGTH_DETERMINATION_FAILED ); - return returnvalue; - } - - /* 5) Realisation of the homotopy step. */ - returnvalue = hotstart_performStep( FR_idx,FX_idx,AC_idx,IAC_idx, - delta_g,delta_lbA,delta_ubA,delta_lb,delta_ub, - delta_xFX,delta_xFR,delta_yAC,delta_yFX,delta_Ax, - BC_idx,BC_status,BC_isBound - ); - - if ( returnvalue != SUCCESSFUL_RETURN ) - { - nWSR = l; - - /* stop runtime measurement */ - if ( cputime != 0 ) - *cputime = getCPUtime( ) - starttime; - - /* optimal solution found? */ - if ( returnvalue == RET_OPTIMAL_SOLUTION_FOUND ) - { - status = QPS_SOLVED; - - if ( printlevel == PL_HIGH ) - THROWINFO( RET_OPTIMAL_SOLUTION_FOUND ); - - #ifdef PC_DEBUG - if ( printIteration( l,BC_idx,BC_status,BC_isBound ) != SUCCESSFUL_RETURN ) - THROWERROR( RET_PRINT_ITERATION_FAILED ); /* do not pass this as return value! */ - #endif - - /* check KKT optimality conditions */ - return checkKKTconditions( ); - } - else - { - /* checks for infeasibility... */ - if ( isInfeasible( ) == BT_TRUE ) - { - status = QPS_HOMOTOPYQPSOLVED; - return THROWERROR( RET_HOTSTART_STOPPED_INFEASIBILITY ); - } - - /* ...unboundedness... */ - if ( unbounded == BT_TRUE ) /* not necessary since objective function convex! */ - return THROWERROR( RET_HOTSTART_STOPPED_UNBOUNDEDNESS ); - - /* ... and throw unspecific error otherwise */ - THROWERROR( RET_HOMOTOPY_STEP_FAILED ); - return returnvalue; - } - } - - /* 6) Output information of successful QP iteration. */ - status = QPS_HOMOTOPYQPSOLVED; - - #ifdef PC_DEBUG - if ( printIteration( l,BC_idx,BC_status,BC_isBound ) != SUCCESSFUL_RETURN ) - THROWERROR( RET_PRINT_ITERATION_FAILED ); /* do not pass this as return value! */ - #endif - } - - - /* stop runtime measurement */ - if ( cputime != 0 ) - *cputime = getCPUtime( ) - starttime; - - - /* if programm gets to here, output information that QP could not be solved - * within the given maximum numbers of working set changes */ - if ( printlevel == PL_HIGH ) - { - #ifdef PC_DEBUG - sprintf( messageString,"(nWSR = %d)",nWSR ); - return getGlobalMessageHandler( )->throwWarning( RET_MAX_NWSR_REACHED,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - #endif - } - - /* Finally check KKT optimality conditions. */ - returnValue returnvalueKKTcheck = checkKKTconditions( ); - - if ( returnvalueKKTcheck != SUCCESSFUL_RETURN ) - return returnvalueKKTcheck; - else - return RET_MAX_NWSR_REACHED; -} - - -/* - * g e t N Z - */ -int QProblem::getNZ( ) -{ - /* nZ = nFR - nAC */ - return bounds.getFree( )->getLength( ) - constraints.getActive( )->getLength( ); -} - - -/* - * g e t D u a l S o l u t i o n - */ -returnValue QProblem::getDualSolution( real_t* const yOpt ) const -{ - int i; - - /* return optimal dual solution vector - * only if current QP has been solved */ - if ( ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || - ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || - ( getStatus( ) == QPS_SOLVED ) ) - { - for( i=0; i -INFTY ) - { - constraints.setNoLower( BT_FALSE ); - break; - } - } - - /* 2) Check if upper constraints' bounds are present. */ - constraints.setNoUpper( BT_TRUE ); - for( i=0; i INFTY - BOUNDTOL ) ) - { - constraints.setType( i,ST_UNBOUNDED ); - ++nUC; - } - else - { - if ( lbA[i] > ubA[i] - BOUNDTOL ) - { - constraints.setType( i,ST_EQUALITY ); - ++nEC; - } - else - { - constraints.setType( i,ST_BOUNDED ); - } - } - } - - /* 4) Set dimensions of constraints structure. */ - constraints.setNEC( nEC ); - constraints.setNUC( nUC ); - constraints.setNIC( nC - nEC - nUC ); - - return SUCCESSFUL_RETURN; -} - - -/* - * c h o l e s k y D e c o m p o s i t i o n P r o j e c t e d - */ -returnValue QProblem::setupCholeskyDecompositionProjected( ) -{ - int i, j, k, ii, kk; - int nV = getNV( ); - int nFR = getNFR( ); - int nZ = getNZ( ); - - /* 1) Initialises R with all zeros. */ - for( i=0; i 0 ) - { - int FR_idx[NVMAX]; - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_INDEXLIST_CORRUPTED ); - -#if 0 - real_t HZ[NVMAX*NVMAX]; - real_t ZHZ[NVMAX*NVMAX]; - - /* calculate H*Z */ - for ( i=0; i=0; --k ) - sum -= R[k*NVMAX + i] * R[k*NVMAX + i]; - - if ( sum > 0.0 ) - { - R[i*NVMAX + i] = sqrt( sum ); - inv = 1.0 / R[i * NVMAX + i]; - } - else - { - hessianType = HST_SEMIDEF; - return THROWERROR( RET_HESSIAN_NOT_SPD ); - } - - for( j=(i+1); j=0; --k ) - sum -= R[k*NVMAX + i] * R[k*NVMAX + j]; - - R[i*NVMAX + j] = sum * inv; - } - } -#else - real_t HZ[NVMAX]; - real_t ZHZ[NVMAX]; - - real_t sum, inv; - for (j = 0; j < nZ; ++j) - { - /* Cache one column of Z. */ - for (i = 0; i < NVMAX; ++i) - ZHZ[i] = Q[i * NVMAX + j]; - - /* Create one column of the product H * Z. */ - for (i = 0; i < nFR; ++i) - { - ii = FR_idx[i]; - - sum = 0.0; - for (k = 0; k < nFR; ++k) - { - kk = FR_idx[k]; - sum += H[ii * NVMAX + kk] * ZHZ[kk]; - } - HZ[ii] = sum; - } - - /* Create one column of the product Z^T * H * Z. */ - for (i = j; i < nZ; ++i) - ZHZ[ i ] = 0.0; - - for (k = 0; k < nFR; ++k) - { - kk = FR_idx[k]; - real_t q = HZ[kk]; - for (i = j; i < nZ; ++i) - { - ZHZ[i] += Q[kk * NVMAX + i] * q; - } - } - - /* Use the computed column to update the factorization. */ - /* j == i */ - sum = ZHZ[j]; - - for (k = (j - 1); k >= 0; --k) - sum -= R[k * NVMAX + j] * R[k * NVMAX + j]; - - if (sum > 0.0) - { - R[j * NVMAX + j] = sqrt(sum); - inv = 1.0 / R[j * NVMAX + j]; - } - else - { - hessianType = HST_SEMIDEF; - return THROWERROR( RET_HESSIAN_NOT_SPD ); - } - - for (i = (j + 1); i < nZ; ++i) - { - sum = ZHZ[i]; - - for (k = (j - 1); k >= 0; --k) - sum -= R[k * NVMAX + j] * R[k * NVMAX + i]; - - R[j * NVMAX + i] = sum * inv; - } - } -#endif - } - } - - return SUCCESSFUL_RETURN; -} - - -/* - * s e t u p T Q f a c t o r i s a t i o n - */ -returnValue QProblem::setupTQfactorisation( ) -{ - int i, j, ii; - int nV = getNV( ); - int nFR = getNFR( ); - - int FR_idx[NVMAX]; - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_INDEXLIST_CORRUPTED ); - - /* 1) Set Q to unity matrix. */ - for( i=0; igetStatus( i ); - - if ( constraints.getType( i ) == ST_EQUALITY ) - { - if ( auxiliaryConstraints->setupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - else - { - if ( auxiliaryConstraints->setupConstraint( i,guessedStatus ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - } - } - else /* No initial working set specified. */ - { - /* Obtain initial working set by "clipping". */ - if ( ( xOpt != 0 ) && ( yOpt == 0 ) ) - { - for( i=0; isetupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - continue; - } - - if ( Ax[i] >= ubA[i] - BOUNDTOL ) - { - if ( auxiliaryConstraints->setupConstraint( i,ST_UPPER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - continue; - } - - /* Moreover, add all equality constraints if specified. */ - if ( constraints.getType( i ) == ST_EQUALITY ) - { - if ( auxiliaryConstraints->setupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - else - { - if ( auxiliaryConstraints->setupConstraint( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - } - } - - /* Obtain initial working set in accordance to sign of dual solution vector. */ - if ( ( xOpt == 0 ) && ( yOpt != 0 ) ) - { - for( i=0; i ZERO ) - { - if ( auxiliaryConstraints->setupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - continue; - } - - if ( yOpt[nV+i] < -ZERO ) - { - if ( auxiliaryConstraints->setupConstraint( i,ST_UPPER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - continue; - } - - /* Moreover, add all equality constraints if specified. */ - if ( constraints.getType( i ) == ST_EQUALITY ) - { - if ( auxiliaryConstraints->setupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - else - { - if ( auxiliaryConstraints->setupConstraint( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - } - } - - /* If xOpt and yOpt are null pointer and no initial working is specified, - * start with empty working set (or implicitly fixed bounds and equality constraints only) - * for auxiliary QP. */ - if ( ( xOpt == 0 ) && ( yOpt == 0 ) ) - { - for( i=0; isetupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - else - { - if ( auxiliaryConstraints->setupConstraint( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - } - } - } - - return SUCCESSFUL_RETURN; -} - - - -/* - * s e t u p A u x i l i a r y W o r k i n g S e t - */ -returnValue QProblem::setupAuxiliaryWorkingSet( const Bounds* const auxiliaryBounds, - const Constraints* const auxiliaryConstraints, - BooleanType setupAfresh - ) -{ - int i; - int nV = getNV( ); - int nC = getNC( ); - - /* consistency checks */ - if ( auxiliaryBounds != 0 ) - { - for( i=0; igetStatus( i ) == ST_UNDEFINED ) ) - return THROWERROR( RET_UNKNOWN_BUG ); - } - else - { - return THROWERROR( RET_INVALID_ARGUMENTS ); - } - - if ( auxiliaryConstraints != 0 ) - { - for( i=0; igetStatus( i ) == ST_UNDEFINED ) ) - return THROWERROR( RET_UNKNOWN_BUG ); - } - else - { - return THROWERROR( RET_INVALID_ARGUMENTS ); - } - - - /* I) SETUP CHOLESKY FLAG: - * Cholesky decomposition shall only be updated if working set - * shall be updated (i.e. NOT setup afresh!) */ - BooleanType updateCholesky; - if ( setupAfresh == BT_TRUE ) - updateCholesky = BT_FALSE; - else - updateCholesky = BT_TRUE; - - - /* II) REMOVE FORMERLY ACTIVE (CONSTRAINTS') BOUNDS (IF NECESSARY): */ - if ( setupAfresh == BT_FALSE ) - { - /* 1) Remove all active constraints that shall be inactive AND - * all active constraints that are active at the wrong bound. */ - for( i=0; igetStatus( i ) != ST_LOWER ) ) - if ( removeConstraint( i,updateCholesky ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); - - if ( ( constraints.getStatus( i ) == ST_UPPER ) && ( auxiliaryConstraints->getStatus( i ) != ST_UPPER ) ) - if ( removeConstraint( i,updateCholesky ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); - } - - /* 2) Remove all active bounds that shall be inactive AND - * all active bounds that are active at the wrong bound. */ - for( i=0; igetStatus( i ) != ST_LOWER ) ) - if ( removeBound( i,updateCholesky ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); - - if ( ( bounds.getStatus( i ) == ST_UPPER ) && ( auxiliaryBounds->getStatus( i ) != ST_UPPER ) ) - if ( removeBound( i,updateCholesky ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); - } - } - - - /* III) ADD NEWLY ACTIVE (CONSTRAINTS') BOUNDS: */ - /* 1) Add all inactive bounds that shall be active AND - * all formerly active bounds that have been active at the wrong bound. */ - for( i=0; igetStatus( i ) != ST_INACTIVE ) ) - { - /* Add bound only if it is linearly independent from the current working set. */ - if ( addBound_checkLI( i ) == RET_LINEARLY_INDEPENDENT ) - { - if ( addBound( i,auxiliaryBounds->getStatus( i ),updateCholesky ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); - } - } - } - - /* 2) Add all inactive constraints that shall be active AND - * all formerly active constraints that have been active at the wrong bound. */ - for( i=0; igetStatus( i ) == ST_LOWER ) || ( auxiliaryConstraints->getStatus( i ) == ST_UPPER ) ) - { - /* formerly inactive */ - if ( constraints.getStatus( i ) == ST_INACTIVE ) - { - /* Add constraint only if it is linearly independent from the current working set. */ - if ( addConstraint_checkLI( i ) == RET_LINEARLY_INDEPENDENT ) - { - if ( addConstraint( i,auxiliaryConstraints->getStatus( i ),updateCholesky ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); - } - } - } - } - - return SUCCESSFUL_RETURN; -} - - -/* - * s e t u p A u x i l i a r y Q P s o l u t i o n - */ -returnValue QProblem::setupAuxiliaryQPsolution( const real_t* const xOpt, const real_t* const yOpt - ) -{ - int i, j; - int nV = getNV( ); - int nC = getNC( ); - - - /* Setup primal/dual solution vector for auxiliary initial QP: - * if a null pointer is passed, a zero vector is assigned; - * old solution vector is kept if pointer to internal solution vevtor is passed. */ - if ( xOpt != 0 ) - { - if ( xOpt != x ) - for( i=0; igetStatus( i ) == ST_LOWER ) - lb[i] = x[i]; - else - lb[i] = x[i] - BOUNDRELAXATION; - - if ( auxiliaryBounds->getStatus( i ) == ST_UPPER ) - ub[i] = x[i]; - else - ub[i] = x[i] + BOUNDRELAXATION; - } - } - break; - - case ST_LOWER: - lb[i] = x[i]; - if ( bounds.getType( i ) == ST_EQUALITY ) - { - ub[i] = x[i]; - } - else - { - if ( useRelaxation == BT_TRUE ) - ub[i] = x[i] + BOUNDRELAXATION; - } - break; - - case ST_UPPER: - ub[i] = x[i]; - if ( bounds.getType( i ) == ST_EQUALITY ) - { - lb[i] = x[i]; - } - else - { - if ( useRelaxation == BT_TRUE ) - lb[i] = x[i] - BOUNDRELAXATION; - } - break; - - default: - return THROWERROR( RET_UNKNOWN_BUG ); - } - } - - /* 2) Setup constraints vectors. */ - for ( i=0; igetStatus( i ) == ST_LOWER ) - lbA[i] = Ax[i]; - else - lbA[i] = Ax[i] - BOUNDRELAXATION; - - if ( auxiliaryConstraints->getStatus( i ) == ST_UPPER ) - ubA[i] = Ax[i]; - else - ubA[i] = Ax[i] + BOUNDRELAXATION; - } - } - break; - - case ST_LOWER: - lbA[i] = Ax[i]; - if ( constraints.getType( i ) == ST_EQUALITY ) - { - ubA[i] = Ax[i]; - } - else - { - if ( useRelaxation == BT_TRUE ) - ubA[i] = Ax[i] + BOUNDRELAXATION; - } - break; - - case ST_UPPER: - ubA[i] = Ax[i]; - if ( constraints.getType( i ) == ST_EQUALITY ) - { - lbA[i] = Ax[i]; - } - else - { - if ( useRelaxation == BT_TRUE ) - lbA[i] = Ax[i] - BOUNDRELAXATION; - } - break; - - default: - return THROWERROR( RET_UNKNOWN_BUG ); - } - } - - return SUCCESSFUL_RETURN; -} - - -/* - * a d d C o n s t r a i n t - */ -returnValue QProblem::addConstraint( int number, SubjectToStatus C_status, - BooleanType updateCholesky - ) -{ - int i, j, ii; - - /* consistency checks */ - if ( constraints.getStatus( number ) != ST_INACTIVE ) - return THROWERROR( RET_CONSTRAINT_ALREADY_ACTIVE ); - - if ( ( constraints.getNC( ) - getNAC( ) ) == constraints.getNUC( ) ) - return THROWERROR( RET_ALL_CONSTRAINTS_ACTIVE ); - - if ( ( getStatus( ) == QPS_NOTINITIALISED ) || - ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || - ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || - ( getStatus( ) == QPS_SOLVED ) ) - { - return THROWERROR( RET_UNKNOWN_BUG ); - } - - - /* I) ENSURE LINEAR INDEPENDENCE OF THE WORKING SET, - * i.e. remove a constraint or bound if linear dependence occurs. */ - /* check for LI only if Cholesky decomposition shall be updated! */ - if ( updateCholesky == BT_TRUE ) - { - returnValue ensureLIreturnvalue = addConstraint_ensureLI( number,C_status ); - - switch ( ensureLIreturnvalue ) - { - case SUCCESSFUL_RETURN: - break; - - case RET_LI_RESOLVED: - break; - - case RET_ENSURELI_FAILED_NOINDEX: - return THROWERROR( RET_ADDCONSTRAINT_FAILED_INFEASIBILITY ); - - case RET_ENSURELI_FAILED_CYCLING: - return THROWERROR( RET_ADDCONSTRAINT_FAILED_INFEASIBILITY ); - - default: - return THROWERROR( RET_ENSURELI_FAILED ); - } - } - - /* some definitions */ - int nFR = getNFR( ); - int nAC = getNAC( ); - int nZ = getNZ( ); - - int tcol = sizeT - nAC; - - - int FR_idx[NVMAX]; - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ADDCONSTRAINT_FAILED ); - - real_t aFR[NVMAX]; - real_t wZ[NVMAX]; - for( i=0; i 0 ) - { - for( j=0; j 0 ) - { - /* II) RESTORE TRIANGULAR FORM OF T: */ - /* Use column-wise Givens rotations to restore reverse triangular form - * of T, simultanenous change of Q (i.e. Z) and R. */ - for( j=0; jgetNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_INDEXLIST_CORRUPTED ); - - /* Check if constraint is linearly independent from the - the active ones (<=> is element of null space of Afr). */ - real_t sum; - - for( i=0; i 10.0*EPS ) - return RET_LINEARLY_INDEPENDENT; - } - - return RET_LINEARLY_DEPENDENT; -} - - -/* - * a d d C o n s t r a i n t _ e n s u r e L I - */ -returnValue QProblem::addConstraint_ensureLI( int number, SubjectToStatus C_status ) -{ - int i, j, ii, jj; - int nV = getNV( ); - int nFR = getNFR( ); - int nFX = getNFX( ); - int nAC = getNAC( ); - int nZ = getNZ( ); - - - /* I) Check if new constraint is linearly independent from the active ones. */ - returnValue returnvalueCheckLI = addConstraint_checkLI( number ); - - if ( returnvalueCheckLI == RET_INDEXLIST_CORRUPTED ) - return THROWERROR( RET_ENSURELI_FAILED ); - - if ( returnvalueCheckLI == RET_LINEARLY_INDEPENDENT ) - return SUCCESSFUL_RETURN; - - - /* II) NEW CONSTRAINT IS LINEARLY DEPENDENT: */ - /* 1) Determine coefficients of linear combination, - * cf. M.J. Best. Applied Mathematics and Parallel Computing, chapter: - * An Algorithm for the Solution of the Parametric Quadratic Programming - * Problem, pages 57-76. Physica-Verlag, Heidelberg, 1996. */ - int FR_idx[NVMAX]; - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ENSURELI_FAILED ); - - int FX_idx[NVMAX]; - if ( bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ENSURELI_FAILED ); - - real_t xiC[NCMAX_ALLOC]; - real_t xiC_TMP[NCMAX_ALLOC]; - real_t xiB[NVMAX]; - - /* 2) Calculate xiC */ - if ( nAC > 0 ) - { - if ( C_status == ST_LOWER ) - { - for( i=0; igetNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ENSURELI_FAILED ); - - if ( C_status == ST_LOWER ) - { - for( i=0; i ZERO ) && ( y[nV+ii] >= 0.0 ) ) - { - if ( y[nV+ii]/xiC[i] < y_min ) - { - y_min = y[nV+ii]/xiC[i]; - y_min_number = ii; - } - } - } - else - { - if ( ( xiC[i] < -ZERO ) && ( y[nV+ii] <= 0.0 ) ) - { - if ( y[nV+ii]/xiC[i] < y_min ) - { - y_min = y[nV+ii]/xiC[i]; - y_min_number = ii; - } - } - } - } - - /* 2) Bounds. */ - for( i=0; i ZERO ) && ( y[ii] >= 0.0 ) ) - { - if ( y[ii]/xiB[i] < y_min ) - { - y_min = y[ii]/xiB[i]; - y_min_number = ii; - y_min_isBound = BT_TRUE; - } - } - } - else - { - if ( ( xiB[i] < -ZERO ) && ( y[ii] <= 0.0 ) ) - { - if ( y[ii]/xiB[i] < y_min ) - { - y_min = y[ii]/xiB[i]; - y_min_number = ii; - y_min_isBound = BT_TRUE; - } - } - } - } - - /* setup output preferences */ - #ifdef PC_DEBUG - char messageString[80]; - VisibilityStatus visibilityStatus; - - if ( printlevel == PL_HIGH ) - visibilityStatus = VS_VISIBLE; - else - visibilityStatus = VS_HIDDEN; - #endif - - - /* IV) REMOVE CONSTRAINT/BOUND FOR RESOLVING LINEAR DEPENDENCE: */ - if ( y_min_number >= 0 ) - { - /* 1) Check for cycling due to infeasibility. */ - if ( ( cyclingManager.getCyclingStatus( number,BT_FALSE ) == CYC_PREV_REMOVED ) && - ( cyclingManager.getCyclingStatus( y_min_number,y_min_isBound ) == CYC_PREV_ADDED ) ) - { - infeasible = BT_TRUE; - - return THROWERROR( RET_ENSURELI_FAILED_CYCLING ); - } - else - { - /* set cycling data */ - cyclingManager.clearCyclingData( ); - cyclingManager.setCyclingStatus( number,BT_FALSE, CYC_PREV_ADDED ); - cyclingManager.setCyclingStatus( y_min_number,y_min_isBound, CYC_PREV_REMOVED ); - } - - /* 2) Update Lagrange multiplier... */ - for( i=0; ithrowInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); - #endif - - if ( removeBound( y_min_number,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); - - y[y_min_number] = 0.0; - } - else - { - #ifdef PC_DEBUG - sprintf( messageString,"constraint no. %d.",y_min_number ); - getGlobalMessageHandler( )->throwInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); - #endif - - if ( removeConstraint( y_min_number,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); - - y[nV+y_min_number] = 0.0; - } - } - else - { - /* no constraint/bound can be removed => QP is infeasible! */ - infeasible = BT_TRUE; - - return THROWERROR( RET_ENSURELI_FAILED_NOINDEX ); - } - - return getGlobalMessageHandler( )->throwInfo( RET_LI_RESOLVED,0,__FUNCTION__,__FILE__,__LINE__,VS_HIDDEN ); -} - - - -/* - * a d d B o u n d - */ -returnValue QProblem::addBound( int number, SubjectToStatus B_status, - BooleanType updateCholesky - ) -{ - int i, j, ii; - - /* consistency checks */ - if ( bounds.getStatus( number ) != ST_INACTIVE ) - return THROWERROR( RET_BOUND_ALREADY_ACTIVE ); - - if ( getNFR( ) == bounds.getNUV( ) ) - return THROWERROR( RET_ALL_BOUNDS_ACTIVE ); - - if ( ( getStatus( ) == QPS_NOTINITIALISED ) || - ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || - ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || - ( getStatus( ) == QPS_SOLVED ) ) - { - return THROWERROR( RET_UNKNOWN_BUG ); - } - - - /* I) ENSURE LINEAR INDEPENDENCE OF THE WORKING SET, - * i.e. remove a constraint or bound if linear dependence occurs. */ - /* check for LI only if Cholesky decomposition shall be updated! */ - if ( updateCholesky == BT_TRUE ) - { - returnValue ensureLIreturnvalue = addBound_ensureLI( number,B_status ); - - switch ( ensureLIreturnvalue ) - { - case SUCCESSFUL_RETURN: - break; - - case RET_LI_RESOLVED: - break; - - case RET_ENSURELI_FAILED_NOINDEX: - return THROWERROR( RET_ADDBOUND_FAILED_INFEASIBILITY ); - - case RET_ENSURELI_FAILED_CYCLING: - return THROWERROR( RET_ADDBOUND_FAILED_INFEASIBILITY ); - - default: - return THROWERROR( RET_ENSURELI_FAILED ); - } - } - - - /* some definitions */ - int nFR = getNFR( ); - int nAC = getNAC( ); - int nZ = getNZ( ); - - int tcol = sizeT - nAC; - - - /* I) SWAP INDEXLIST OF FREE VARIABLES: - * move the variable to be fixed to the end of the list of free variables. */ - int lastfreenumber = bounds.getFree( )->getLastNumber( ); - if ( lastfreenumber != number ) - if ( bounds.swapFree( number,lastfreenumber ) != SUCCESSFUL_RETURN ) - THROWERROR( RET_ADDBOUND_FAILED ); - - - int FR_idx[NVMAX]; - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ADDBOUND_FAILED ); - - real_t w[NVMAX]; - - - /* II) ADD NEW ACTIVE BOUND TO TOP OF MATRIX T: */ - /* 1) add row [wZ wY] = [Z Y](number) at the top of T: assign w */ - for( i=0; i 0 ) /* ( nAC == 0 ) <=> ( nZ == nFR ) <=> Y and T are empty => nothing to do */ - { - /* store new column a in a temporary vector instead of shifting T one column to the left */ - real_t tmp[NCMAX_ALLOC]; - for( i=0; i is linearly independent from the - the active ones (<=> is element of null space of Afr). */ - for( i=0; i EPS ) - return RET_LINEARLY_INDEPENDENT; - } - - return RET_LINEARLY_DEPENDENT; -} - - -/* - * a d d B o u n d _ e n s u r e L I - */ -returnValue QProblem::addBound_ensureLI( int number, SubjectToStatus B_status ) -{ - int i, j, ii, jj; - int nV = getNV( ); - int nFX = getNFX( ); - int nAC = getNAC( ); - int nZ = getNZ( ); - - - /* I) Check if new constraint is linearly independent from the active ones. */ - returnValue returnvalueCheckLI = addBound_checkLI( number ); - - if ( returnvalueCheckLI == RET_LINEARLY_INDEPENDENT ) - return SUCCESSFUL_RETURN; - - - /* II) NEW BOUND IS LINEARLY DEPENDENT: */ - /* 1) Determine coefficients of linear combination, - * cf. M.J. Best. Applied Mathematics and Parallel Computing, chapter: - * An Algorithm for the Solution of the Parametric Quadratic Programming - * Problem, pages 57-76. Physica-Verlag, Heidelberg, 1996. */ - int FR_idx[NVMAX]; - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ENSURELI_FAILED ); - - int FX_idx[NVMAX]; - if ( bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ENSURELI_FAILED ); - - int AC_idx[NCMAX_ALLOC]; - if ( constraints.getActive( )->getNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ENSURELI_FAILED ); - - real_t xiC[NCMAX_ALLOC]; - real_t xiC_TMP[NCMAX_ALLOC]; - real_t xiB[NVMAX]; - - /* 2) Calculate xiC. */ - if ( nAC > 0 ) - { - if ( B_status == ST_LOWER ) - { - for( i=0; i ZERO ) && ( y[nV+ii] >= 0.0 ) ) - { - if ( y[nV+ii]/xiC[i] < y_min ) - { - y_min = y[nV+ii]/xiC[i]; - y_min_number = ii; - } - } - } - else - { - if ( ( xiC[i] < -ZERO ) && ( y[nV+ii] <= 0.0 ) ) - { - if ( y[nV+ii]/xiC[i] < y_min ) - { - y_min = y[nV+ii]/xiC[i]; - y_min_number = ii; - } - } - } - } - - /* 2) Bounds. */ - for( i=0; i ZERO ) && ( y[ii] >= 0.0 ) ) - { - if ( y[ii]/xiB[i] < y_min ) - { - y_min = y[ii]/xiB[i]; - y_min_number = ii; - y_min_isBound = BT_TRUE; - } - } - } - else - { - if ( ( xiB[i] < -ZERO ) && ( y[ii] <= 0.0 ) ) - { - if ( y[ii]/xiB[i] < y_min ) - { - y_min = y[ii]/xiB[i]; - y_min_number = ii; - y_min_isBound = BT_TRUE; - } - } - } - } - - /* setup output preferences */ - #ifdef PC_DEBUG - char messageString[80]; - VisibilityStatus visibilityStatus; - - if ( printlevel == PL_HIGH ) - visibilityStatus = VS_VISIBLE; - else - visibilityStatus = VS_HIDDEN; - #endif - - - /* IV) REMOVE CONSTRAINT/BOUND FOR RESOLVING LINEAR DEPENDENCE: */ - if ( y_min_number >= 0 ) - { - /* 1) Check for cycling due to infeasibility. */ - if ( ( cyclingManager.getCyclingStatus( number,BT_TRUE ) == CYC_PREV_REMOVED ) && - ( cyclingManager.getCyclingStatus( y_min_number,y_min_isBound ) == CYC_PREV_ADDED ) ) - { - infeasible = BT_TRUE; - - return THROWERROR( RET_ENSURELI_FAILED_CYCLING ); - } - else - { - /* set cycling data */ - cyclingManager.clearCyclingData( ); - cyclingManager.setCyclingStatus( number,BT_TRUE, CYC_PREV_ADDED ); - cyclingManager.setCyclingStatus( y_min_number,y_min_isBound, CYC_PREV_REMOVED ); - } - - - /* 2) Update Lagrange multiplier... */ - for( i=0; ithrowInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); - #endif - - if ( removeBound( y_min_number,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); - - y[y_min_number] = 0.0; - } - else - { - #ifdef PC_DEBUG - sprintf( messageString,"constraint no. %d.",y_min_number ); - getGlobalMessageHandler( )->throwInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); - #endif - - if ( removeConstraint( y_min_number,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); - - y[nV+y_min_number] = 0.0; - } - } - else - { - /* no constraint/bound can be removed => QP is infeasible! */ - infeasible = BT_TRUE; - - return THROWERROR( RET_ENSURELI_FAILED_NOINDEX ); - } - - return getGlobalMessageHandler( )->throwInfo( RET_LI_RESOLVED,0,__FUNCTION__,__FILE__,__LINE__,VS_HIDDEN ); -} - - - -/* - * r e m o v e C o n s t r a i n t - */ -returnValue QProblem::removeConstraint( int number, - BooleanType updateCholesky - ) -{ - int i, j, ii, jj; - - /* consistency check */ - if ( ( getStatus( ) == QPS_NOTINITIALISED ) || - ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || - ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || - ( getStatus( ) == QPS_SOLVED ) ) - { - return THROWERROR( RET_UNKNOWN_BUG ); - } - - /* some definitions */ - int nFR = getNFR( ); - int nAC = getNAC( ); - int nZ = getNZ( ); - - int tcol = sizeT - nAC; - int number_idx = constraints.getActive( )->getIndex( number ); - - - /* consistency checks */ - if ( constraints.getStatus( number ) == ST_INACTIVE ) - return THROWERROR( RET_CONSTRAINT_NOT_ACTIVE ); - - if ( ( number_idx < 0 ) || ( number_idx >= nAC ) ) - return THROWERROR( RET_CONSTRAINT_NOT_ACTIVE ); - - - int FR_idx[NVMAX]; - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVECONSTRAINT_FAILED ); - - - /* I) REMOVE th ROW FROM T, - * i.e. shift rows number+1 through nAC upwards (instead of the actual - * constraint number its corresponding index within matrix A is used). */ - if ( number_idx < nAC-1 ) - { - for( i=(number_idx+1); i=0; --j ) - { - computeGivens( T[(nAC-2-j)*NVMAX + tcol+1+j],T[(nAC-2-j)*NVMAX + tcol+j], T[(nAC-2-j)*NVMAX + tcol+1+j],T[(nAC-2-j)*NVMAX + tcol+j],c,s ); - - for( i=(nAC-j-1); i<(nAC-1); ++i ) - applyGivens( c,s,T[i*NVMAX + tcol+1+j],T[i*NVMAX + tcol+j], T[i*NVMAX + tcol+1+j],T[i*NVMAX + tcol+j] ); - - for( i=0; i 0 ) - { - real_t ZHz[NVMAX]; - for ( i=0; i 0.0 ) - R[nZ*NVMAX + nZ] = sqrt( rho2 ); - else - { - hessianType = HST_SEMIDEF; - return THROWERROR( RET_HESSIAN_NOT_SPD ); - } - } - - /* IV) UPDATE INDICES */ - if ( constraints.moveActiveToInactive( number ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVECONSTRAINT_FAILED ); - - - return SUCCESSFUL_RETURN; -} - - -/* - * r e m o v e B o u n d - */ -returnValue QProblem::removeBound( int number, - BooleanType updateCholesky - ) -{ - int i, j, ii, jj; - - /* consistency checks */ - if ( bounds.getStatus( number ) == ST_INACTIVE ) - return THROWERROR( RET_BOUND_NOT_ACTIVE ); - - if ( ( getStatus( ) == QPS_NOTINITIALISED ) || - ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || - ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || - ( getStatus( ) == QPS_SOLVED ) ) - { - return THROWERROR( RET_UNKNOWN_BUG ); - } - - /* some definitions */ - int nFR = getNFR( ); - int nAC = getNAC( ); - int nZ = getNZ( ); - - int tcol = sizeT - nAC; - - - /* I) UPDATE INDICES */ - if ( bounds.moveFixedToFree( number ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVEBOUND_FAILED ); - - - int FR_idx[NVMAX]; - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVEBOUND_FAILED ); - - /* I) APPEND th UNITY VECOTR TO Q. */ - int nnFRp1 = FR_idx[nFR]; - for( i=0; i 0 ) - { - /* store new column a in a temporary vector instead of shifting T one column to the left and appending a */ - int AC_idx[NCMAX_ALLOC]; - if ( constraints.getActive( )->getNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVEBOUND_FAILED ); - - real_t tmp[NCMAX_ALLOC]; - for( i=0; i=0; --j ) - { - computeGivens( tmp[nAC-1-j],T[(nAC-1-j)*NVMAX + tcol+j],T[(nAC-1-j)*NVMAX + tcol+j],tmp[nAC-1-j],c,s ); - - for( i=(nAC-j); i 0 ) - { - real_t Hz[NVMAX]; - for( i=0; i 0 ) - { - real_t r[NVMAX]; - real_t rhs[NVMAX]; - for( i=0; i 0.0 ) - R[nZ*NVMAX + nZ] = sqrt( rho2 ); - else - { - hessianType = HST_SEMIDEF; - return THROWERROR( RET_HESSIAN_NOT_SPD ); - } - } - - return SUCCESSFUL_RETURN; -} - - -/* - * b a c k s o l v e R (CODE DUPLICATE OF QProblemB CLASS!!!) - */ -returnValue QProblem::backsolveR( const real_t* const b, BooleanType transposed, - real_t* const a - ) -{ - /* Call standard backsolve procedure (i.e. removingBound == BT_FALSE). */ - return backsolveR( b,transposed,BT_FALSE,a ); -} - - -/* - * b a c k s o l v e R (CODE DUPLICATE OF QProblemB CLASS!!!) - */ -returnValue QProblem::backsolveR( const real_t* const b, BooleanType transposed, - BooleanType removingBound, - real_t* const a - ) -{ - int i, j; - int nR = getNZ( ); - - real_t sum; - - /* if backsolve is called while removing a bound, reduce nZ by one. */ - if ( removingBound == BT_TRUE ) - --nR; - - /* nothing to do */ - if ( nR <= 0 ) - return SUCCESSFUL_RETURN; - - - /* Solve Ra = b, where R might be transposed. */ - if ( transposed == BT_FALSE ) - { - /* solve Ra = b */ - for( i=(nR-1); i>=0; --i ) - { - sum = b[i]; - for( j=(i+1); j ZERO ) - a[i] = sum / R[i*NVMAX + i]; - else - return THROWERROR( RET_DIV_BY_ZERO ); - } - } - else - { - /* solve R^T*a = b */ - for( i=0; i ZERO ) - a[i] = sum / R[i*NVMAX + i]; - else - return THROWERROR( RET_DIV_BY_ZERO ); - } - } - - return SUCCESSFUL_RETURN; -} - - - -/* - * b a c k s o l v e T - */ -returnValue QProblem::backsolveT( const real_t* const b, BooleanType transposed, real_t* const a ) -{ - int i, j; - int nT = getNAC( ); - int tcol = sizeT - nT; - - real_t sum; - - /* nothing to do */ - if ( nT <= 0 ) - return SUCCESSFUL_RETURN; - - - /* Solve Ta = b, where T might be transposed. */ - if ( transposed == BT_FALSE ) - { - /* solve Ta = b */ - for( i=0; i ZERO ) - a[nT-1-i] = sum / T[i*NVMAX + sizeT-1-i]; - else - return THROWERROR( RET_DIV_BY_ZERO ); - } - } - else - { - /* solve T^T*a = b */ - for( i=0; i ZERO ) - a[nT-1-i] = sum / T[(nT-1-i)*NVMAX + tcol+i]; - else - return THROWERROR( RET_DIV_BY_ZERO ); - } - } - - - return SUCCESSFUL_RETURN; -} - - -/* - * h o t s t a r t _ d e t e r m i n e D a t a S h i f t - */ -returnValue QProblem::hotstart_determineDataShift( const int* const FX_idx, const int* const AC_idx, - const real_t* const g_new, const real_t* const lbA_new, const real_t* const ubA_new, - const real_t* const lb_new, const real_t* const ub_new, - real_t* const delta_g, real_t* const delta_lbA, real_t* const delta_ubA, - real_t* const delta_lb, real_t* const delta_ub, - BooleanType& Delta_bC_isZero, BooleanType& Delta_bB_isZero - ) -{ - int i, ii; - int nC = getNC( ); - int nAC = getNAC( ); - - - /* I) DETERMINE DATA SHIFT FOR BOUNDS */ - QProblemB::hotstart_determineDataShift( FX_idx,g_new,lb_new,ub_new, delta_g,delta_lb,delta_ub, Delta_bB_isZero ); - - - /* II) DETERMINE DATA SHIFT FOR CONSTRAINTS */ - /* 1) Calculate shift directions. */ - for( i=0; i EPS ) || ( getAbs( delta_ubA[ii] ) > EPS ) ) - { - Delta_bC_isZero = BT_FALSE; - break; - } - } - - return SUCCESSFUL_RETURN; -} - - -/* - * h o t s t a r t _ d e t e r m i n e S t e p D i r e c t i o n - */ -returnValue QProblem::hotstart_determineStepDirection( const int* const FR_idx, const int* const FX_idx, const int* const AC_idx, - const real_t* const delta_g, const real_t* const delta_lbA, const real_t* const delta_ubA, - const real_t* const delta_lb, const real_t* const delta_ub, - BooleanType Delta_bC_isZero, BooleanType Delta_bB_isZero, - real_t* const delta_xFX, real_t* const delta_xFR, - real_t* const delta_yAC, real_t* const delta_yFX - ) -{ - int i, j, ii, jj; - int nFR = getNFR( ); - int nFX = getNFX( ); - int nAC = getNAC( ); - int nZ = getNZ( ); - - /* initialise auxiliary vectors */ - real_t HMX_delta_xFX[NVMAX]; - real_t YFR_delta_xFRy[NVMAX]; - real_t ZFR_delta_xFRz[NVMAX]; - real_t HFR_YFR_delta_xFRy[NVMAX]; - for( i=0; i 0 ) - { - for( i=0; i 0 ) - { - /* 1) Determine delta_xFRy. */ - if ( nAC > 0 ) - { - if ( ( Delta_bC_isZero == BT_TRUE ) && ( Delta_bB_isZero == BT_TRUE ) ) - { - for( i=0; i 0 ) - { - for( i=0; i 0 ) - { - if ( ( Delta_bC_isZero == BT_FALSE ) || ( Delta_bB_isZero == BT_FALSE ) ) - { - for( i=0; i 0 ) - { - /* auxiliary variable */ - real_t delta_xFRz_TMP[NVMAX]; - real_t delta_xFRz_RHS[NVMAX]; - - - if ( ( nAC > 0 ) && ( nFX > 0 ) && ( Delta_bB_isZero == BT_FALSE ) ) - { - for( j=0; j 0 ) /* => Delta_bB_isZero == BT_TRUE, as BT_FALSE would imply nFX>0 */ - { - for( j=0; j 0 ) /* => ( nFR = nZ + nAC > 0 ) */ - { - /* auxiliary variables */ - real_t delta_yAC_TMP[NCMAX_ALLOC]; - for( i=0; i 0 ) - { - for( i=0; i 0 ) - { - if ( Delta_bB_isZero == BT_FALSE ) - { - for( i=0; i 0 ) - { - for( i=0; i 0.0 ) - maxStepLength[nV+ii] = y[nV+ii] / ( -delta_yAC[i] ); - else - maxStepLength[nV+ii] = 0.0; - } - } - else - { - /* active upper constraints' bounds */ - if ( delta_yAC[i] > ZERO ) - { - if ( y[nV+ii] < 0.0 ) - maxStepLength[nV+ii] = y[nV+ii] / ( -delta_yAC[i] ); - else - maxStepLength[nV+ii] = 0.0; - } - } - } - } - - /* 2) Ensure that active dual bounds remain valid - * (ignoring implicitly fixed variables). */ - for( i=0; i 0.0 ) - maxStepLength[ii] = y[ii] / ( -delta_yFX[i] ); - else - maxStepLength[ii] = 0.0; - } - } - else - { - /* active upper bounds */ - if ( delta_yFX[i] > ZERO ) - { - if ( y[ii] < 0.0 ) - maxStepLength[ii] = y[ii] / ( -delta_yFX[i] ); - else - maxStepLength[ii] = 0.0; - } - } - } - } - - - /* II) DETERMINE MAXIMUM PRIMAL STEPLENGTH */ - /* 1) Ensure that inactive constraints' bounds remain valid - * (ignoring unbounded constraints). */ - real_t delta_x[NVMAX]; - for( j=0; j delta_Ax[ii] ) - { - if ( Ax[ii] > lbA[ii] ) - maxStepLength[nV+ii] = ( Ax[ii] - lbA[ii] ) / ( delta_lbA[ii] - delta_Ax[ii] ); - else - maxStepLength[nV+ii] = 0.0; - } - } - - /* inactive upper constraints' bounds */ - if ( constraints.isNoUpper( ) == BT_FALSE ) - { - if ( delta_ubA[ii] < delta_Ax[ii] ) - { - if ( Ax[ii] < ubA[ii] ) - maxStepLength[nV+nC+nV+ii] = ( Ax[ii] - ubA[ii] ) / ( delta_ubA[ii] - delta_Ax[ii] ); - else - maxStepLength[nV+nC+nV+ii] = 0.0; - } - } - } - } - - - /* 2) Ensure that inactive bounds remain valid - * (ignoring unbounded variables). */ - /* inactive lower bounds */ - if ( bounds.isNoLower( ) == BT_FALSE ) - { - for( i=0; i delta_xFR[i] ) - { - if ( x[ii] > lb[ii] ) - maxStepLength[ii] = ( x[ii] - lb[ii] ) / ( delta_lb[ii] - delta_xFR[i] ); - else - maxStepLength[ii] = 0.0; - } - } - } - - /* inactive upper bounds */ - if ( bounds.isNoUpper( ) == BT_FALSE ) - { - for( i=0; i EPS ) - cyclingManager.clearCyclingData( ); - - - /* V) SET MAXIMUM HOMOTOPY STEPLENGTH */ - tau = tau_new; - - #ifdef PC_DEBUG - if ( printlevel == PL_HIGH ) - { - - char messageString[80]; - - if ( BC_status == ST_UNDEFINED ) - sprintf( messageString,"Stepsize is %.6e!",tau ); - else - sprintf( messageString,"Stepsize is %.6e! (BC_idx = %d, BC_isBound = %d, BC_status = %d)",tau,BC_idx,BC_isBound,BC_status ); - - getGlobalMessageHandler( )->throwInfo( RET_STEPSIZE_NONPOSITIVE,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - } - #endif - - return SUCCESSFUL_RETURN; -} - - -/* - * h o t s t a r t _ p e r f o r m S t e p - */ -returnValue QProblem::hotstart_performStep( const int* const FR_idx, const int* const FX_idx, const int* const AC_idx, const int* const IAC_idx, - const real_t* const delta_g, const real_t* const delta_lbA, const real_t* const delta_ubA, - const real_t* const delta_lb, const real_t* const delta_ub, - const real_t* const delta_xFX, const real_t* const delta_xFR, - const real_t* const delta_yAC, const real_t* const delta_yFX, - const real_t* const delta_Ax, int BC_idx, SubjectToStatus BC_status, BooleanType BC_isBound - ) -{ - int i, j, ii; - int nV = getNV( ); - int nC = getNC( ); - int nFR = getNFR( ); - int nFX = getNFX( ); - int nAC = getNAC( ); - int nIAC = getNIAC( ); - - - /* I) CHECK (CONSTRAINTS') BOUNDS' CONSISTENCY */ - if ( areBoundsConsistent( delta_lb,delta_ub,delta_lbA,delta_ubA ) == BT_FALSE ) - { - infeasible = BT_TRUE; - tau = 0.0; - - return THROWERROR( RET_QP_INFEASIBLE ); - } - - - /* II) GO TO ACTIVE SET CHANGE */ - if ( tau > ZERO ) - { - /* 1) Perform step in primal und dual space... */ - for( i=0; ithrowWarning( RET_STEPSIZE,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - #endif - } - - - /* setup output preferences */ - #ifdef PC_DEBUG - char messageString[80]; - VisibilityStatus visibilityStatus; - - if ( printlevel == PL_HIGH ) - visibilityStatus = VS_VISIBLE; - else - visibilityStatus = VS_HIDDEN; - #endif - - - /* III) UPDATE ACTIVE SET */ - switch ( BC_status ) - { - /* Optimal solution found as no working set change detected. */ - case ST_UNDEFINED: - return RET_OPTIMAL_SOLUTION_FOUND; - - - /* Remove one variable from active set. */ - case ST_INACTIVE: - if ( BC_isBound == BT_TRUE ) - { - #ifdef PC_DEBUG - sprintf( messageString,"bound no. %d.", BC_idx ); - getGlobalMessageHandler( )->throwInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); - #endif - - if ( removeBound( BC_idx,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); - - y[BC_idx] = 0.0; - } - else - { - #ifdef PC_DEBUG - sprintf( messageString,"constraint no. %d.", BC_idx ); - getGlobalMessageHandler( )->throwInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); - #endif - - if ( removeConstraint( BC_idx,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); - - y[nV+BC_idx] = 0.0; - } - break; - - - /* Add one variable to active set. */ - default: - if ( BC_isBound == BT_TRUE ) - { - #ifdef PC_DEBUG - if ( BC_status == ST_LOWER ) - sprintf( messageString,"lower bound no. %d.", BC_idx ); - else - sprintf( messageString,"upper bound no. %d.", BC_idx ); - getGlobalMessageHandler( )->throwInfo( RET_ADD_TO_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); - #endif - - if ( addBound( BC_idx,BC_status,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ADD_TO_ACTIVESET_FAILED ); - } - else - { - #ifdef PC_DEBUG - if ( BC_status == ST_LOWER ) - sprintf( messageString,"lower constraint's bound no. %d.", BC_idx ); - else - sprintf( messageString,"upper constraint's bound no. %d.", BC_idx ); - getGlobalMessageHandler( )->throwInfo( RET_ADD_TO_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); - #endif - - if ( addConstraint( BC_idx,BC_status,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ADD_TO_ACTIVESET_FAILED ); - } - break; - } - - return SUCCESSFUL_RETURN; -} - - -/* - * a r e B o u n d s C o n s i s t e n t - */ -BooleanType QProblem::areBoundsConsistent( const real_t* const delta_lb, const real_t* const delta_ub, - const real_t* const delta_lbA, const real_t* const delta_ubA - ) const -{ - int i; - - /* 1) Check bounds' consistency. */ - if ( QProblemB::areBoundsConsistent( delta_lb,delta_ub ) == BT_FALSE ) - return BT_FALSE; - - /* 2) Check constraints' consistency, i.e. - * check if delta_lb[i] is greater than delta_ub[i] - * for a component i whose bounds are already (numerically) equal. */ - for( i=0; i ubA[i] - BOUNDTOL ) && ( delta_lbA[i] > delta_ubA[i] + EPS ) ) - return BT_FALSE; - - return BT_TRUE; -} - - -/* - * s e t u p Q P d a t a - */ -returnValue QProblem::setupQPdata( const real_t* const _H, const real_t* const _R, const real_t* const _g, const real_t* const _A, - const real_t* const _lb, const real_t* const _ub, - const real_t* const _lbA, const real_t* const _ubA - ) -{ - int i, j; - int nV = getNV( ); - int nC = getNC( ); - - - /* 1) Load Hessian matrix as well as lower and upper bounds vectors. */ - if (QProblemB::setupQPdata(_H, _R, _g, _lb, _ub) != SUCCESSFUL_RETURN) - return THROWERROR( RET_INVALID_ARGUMENTS ); - - /* 2) Load constraint matrix. */ - if ( ( nC > 0 ) && ( _A == 0 ) ) - return THROWERROR( RET_INVALID_ARGUMENTS ); - - if ( nC > 0 ) - { - for( i=0; igetNumberArray( AC_idx ); - - /* 1) check for Hx + g - [yFX yAC]*[Id A]' = 0. */ - for( i=0; i maxKKTviolation ) - maxKKTviolation = getAbs( tmp ); - } - - /* 2) Check for [lb lbA] <= [Id A]*x <= [ub ubA]. */ - /* lbA <= Ax <= ubA */ - for( i=0; i maxKKTviolation ) - maxKKTviolation = lbA[i] - Ax[i]; - - if ( Ax[i] - ubA[i] > maxKKTviolation ) - maxKKTviolation = Ax[i] - ubA[i]; - } - - /* lb <= x <= ub */ - for( i=0; i maxKKTviolation ) - maxKKTviolation = lb[i] - x[i]; - - if ( x[i] - ub[i] > maxKKTviolation ) - maxKKTviolation = x[i] - ub[i]; - } - - /* 3) Check for correct sign of y and for complementary slackness. */ - /* bounds */ - for( i=0; i maxKKTviolation ) - maxKKTviolation = -y[i]; - if ( getAbs( x[i] - lb[i] ) > maxKKTviolation ) - maxKKTviolation = getAbs( x[i] - lb[i] ); - break; - - case ST_UPPER: - if ( y[i] > maxKKTviolation ) - maxKKTviolation = y[i]; - if ( getAbs( ub[i] - x[i] ) > maxKKTviolation ) - maxKKTviolation = getAbs( ub[i] - x[i] ); - break; - - default: /* inactive */ - if ( getAbs( y[i] ) > maxKKTviolation ) - maxKKTviolation = getAbs( y[i] ); - break; - } - } - - /* constraints */ - for( i=0; i maxKKTviolation ) - maxKKTviolation = -y[nV+i]; - if ( getAbs( Ax[i] - lbA[i] ) > maxKKTviolation ) - maxKKTviolation = getAbs( Ax[i] - lbA[i] ); - break; - - case ST_UPPER: - if ( y[nV+i] > maxKKTviolation ) - maxKKTviolation = y[nV+i]; - if ( getAbs( ubA[i] - Ax[i] ) > maxKKTviolation ) - maxKKTviolation = getAbs( ubA[i] - Ax[i] ); - break; - - default: /* inactive */ - if ( getAbs( y[nV+i] ) > maxKKTviolation ) - maxKKTviolation = getAbs( y[nV+i] ); - break; - } - } - - if ( maxKKTviolation > CRITICALACCURACY ) - return RET_NO_SOLUTION; - - if ( maxKKTviolation > DESIREDACCURACY ) - return RET_INACCURATE_SOLUTION; - - #endif /* __PERFORM_KKT_TEST__ */ - - return SUCCESSFUL_RETURN; -} - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file SRC/QProblem.cpp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Implementation of the QProblem class which is able to use the newly + * developed online active set strategy for parametric quadratic programming. + */ + + +#include + +#include + +void printmatrix2(char *name, double *A, int m, int n) { + int i, j; + + printf("%s = [...\n", name); + for (i = 0; i < m; i++) { + for (j = 0; j < n; j++) + printf(" % 9.4f", A[i*n+j]); + printf(",\n"); + } + printf("];\n"); +} + +//#define __PERFORM_KKT_TEST__ + + +/***************************************************************************** + * P U B L I C * + *****************************************************************************/ + + +/* + * Q P r o b l e m + */ +QProblem::QProblem( ) : QProblemB( ) +{ + constraints.init( 0 ); + + sizeT = 0; + + cyclingManager.init( 0,0 ); +} + + +/* + * Q P r o b l e m + */ +QProblem::QProblem( int _nV, int _nC ) : QProblemB( _nV ) +{ + /* consistency checks */ + if ( _nV <= 0 ) + _nV = 1; + + if ( _nC < 0 ) + { + _nC = 0; + THROWERROR( RET_INVALID_ARGUMENTS ); + } + + constraints.init( _nC ); + + + sizeT = _nC; + if ( _nC > _nV ) + sizeT = _nV; + + cyclingManager.init( _nV,_nC ); +} + + +/* + * Q P r o b l e m + */ +QProblem::QProblem( const QProblem& rhs ) : QProblemB( rhs ) +{ + int i, j; + + int _nV = rhs.bounds.getNV( ); + int _nC = rhs.constraints.getNC( ); + + for( i=0; i<_nC; ++i ) + for( j=0; j<_nV; ++j ) + A[i*NVMAX + j] = rhs.A[i*NVMAX + j]; + + for( i=0; i<_nC; ++i ) + lbA[i] = rhs.lbA[i]; + + for( i=0; i<_nC; ++i ) + ubA[i] = rhs.ubA[i]; + + constraints = rhs.constraints; + + for( i=0; i<(_nV+_nC); ++i ) + y[i] = rhs.y[i]; + + + sizeT = rhs.sizeT; + + for( i=0; ithrowInfo( RET_ITERATION_STARTED,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); + #endif + } + + /* 1) Setup index arrays. */ + if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_HOTSTART_FAILED ); + + if ( bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_HOTSTART_FAILED ); + + if ( constraints.getActive( )->getNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_HOTSTART_FAILED ); + + if ( constraints.getInactive( )->getNumberArray( IAC_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_HOTSTART_FAILED ); + + /* 2) Detemination of shift direction of the gradient and the (constraints') bounds. */ + returnvalue = hotstart_determineDataShift( FX_idx, AC_idx, + g_new,lbA_new,ubA_new,lb_new,ub_new, + delta_g,delta_lbA,delta_ubA,delta_lb,delta_ub, + Delta_bC_isZero, Delta_bB_isZero ); + if ( returnvalue != SUCCESSFUL_RETURN ) + { + nWSR = l; + THROWERROR( RET_SHIFT_DETERMINATION_FAILED ); + return returnvalue; + } + + /* 3) Determination of step direction of X and Y. */ + returnvalue = hotstart_determineStepDirection( FR_idx,FX_idx,AC_idx, + delta_g,delta_lbA,delta_ubA,delta_lb,delta_ub, + Delta_bC_isZero, Delta_bB_isZero, + delta_xFX,delta_xFR,delta_yAC,delta_yFX + ); + if ( returnvalue != SUCCESSFUL_RETURN ) + { + nWSR = l; + THROWERROR( RET_STEPDIRECTION_DETERMINATION_FAILED ); + return returnvalue; + } + + /* 4) Determination of step length TAU. */ + returnvalue = hotstart_determineStepLength( FR_idx,FX_idx,AC_idx,IAC_idx, + delta_lbA,delta_ubA,delta_lb,delta_ub, + delta_xFX,delta_xFR,delta_yAC,delta_yFX,delta_Ax, + BC_idx,BC_status,BC_isBound + ); + if ( returnvalue != SUCCESSFUL_RETURN ) + { + nWSR = l; + THROWERROR( RET_STEPLENGTH_DETERMINATION_FAILED ); + return returnvalue; + } + + /* 5) Realisation of the homotopy step. */ + returnvalue = hotstart_performStep( FR_idx,FX_idx,AC_idx,IAC_idx, + delta_g,delta_lbA,delta_ubA,delta_lb,delta_ub, + delta_xFX,delta_xFR,delta_yAC,delta_yFX,delta_Ax, + BC_idx,BC_status,BC_isBound + ); + + if ( returnvalue != SUCCESSFUL_RETURN ) + { + nWSR = l; + + /* stop runtime measurement */ + if ( cputime != 0 ) + *cputime = getCPUtime( ) - starttime; + + /* optimal solution found? */ + if ( returnvalue == RET_OPTIMAL_SOLUTION_FOUND ) + { + status = QPS_SOLVED; + + if ( printlevel == PL_HIGH ) + THROWINFO( RET_OPTIMAL_SOLUTION_FOUND ); + + #ifdef PC_DEBUG + if ( printIteration( l,BC_idx,BC_status,BC_isBound ) != SUCCESSFUL_RETURN ) + THROWERROR( RET_PRINT_ITERATION_FAILED ); /* do not pass this as return value! */ + #endif + + /* check KKT optimality conditions */ + return checkKKTconditions( ); + } + else + { + /* checks for infeasibility... */ + if ( isInfeasible( ) == BT_TRUE ) + { + status = QPS_HOMOTOPYQPSOLVED; + return THROWERROR( RET_HOTSTART_STOPPED_INFEASIBILITY ); + } + + /* ...unboundedness... */ + if ( unbounded == BT_TRUE ) /* not necessary since objective function convex! */ + return THROWERROR( RET_HOTSTART_STOPPED_UNBOUNDEDNESS ); + + /* ... and throw unspecific error otherwise */ + THROWERROR( RET_HOMOTOPY_STEP_FAILED ); + return returnvalue; + } + } + + /* 6) Output information of successful QP iteration. */ + status = QPS_HOMOTOPYQPSOLVED; + + #ifdef PC_DEBUG + if ( printIteration( l,BC_idx,BC_status,BC_isBound ) != SUCCESSFUL_RETURN ) + THROWERROR( RET_PRINT_ITERATION_FAILED ); /* do not pass this as return value! */ + #endif + } + + + /* stop runtime measurement */ + if ( cputime != 0 ) + *cputime = getCPUtime( ) - starttime; + + + /* if programm gets to here, output information that QP could not be solved + * within the given maximum numbers of working set changes */ + if ( printlevel == PL_HIGH ) + { + #ifdef PC_DEBUG + sprintf( messageString,"(nWSR = %d)",nWSR ); + return getGlobalMessageHandler( )->throwWarning( RET_MAX_NWSR_REACHED,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); + #endif + } + + /* Finally check KKT optimality conditions. */ + returnValue returnvalueKKTcheck = checkKKTconditions( ); + + if ( returnvalueKKTcheck != SUCCESSFUL_RETURN ) + return returnvalueKKTcheck; + else + return RET_MAX_NWSR_REACHED; +} + + +/* + * g e t N Z + */ +int QProblem::getNZ( ) +{ + /* nZ = nFR - nAC */ + return bounds.getFree( )->getLength( ) - constraints.getActive( )->getLength( ); +} + + +/* + * g e t D u a l S o l u t i o n + */ +returnValue QProblem::getDualSolution( real_t* const yOpt ) const +{ + int i; + + /* return optimal dual solution vector + * only if current QP has been solved */ + if ( ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || + ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || + ( getStatus( ) == QPS_SOLVED ) ) + { + for( i=0; i -INFTY ) + { + constraints.setNoLower( BT_FALSE ); + break; + } + } + + /* 2) Check if upper constraints' bounds are present. */ + constraints.setNoUpper( BT_TRUE ); + for( i=0; i INFTY - BOUNDTOL ) ) + { + constraints.setType( i,ST_UNBOUNDED ); + ++nUC; + } + else + { + if ( lbA[i] > ubA[i] - BOUNDTOL ) + { + constraints.setType( i,ST_EQUALITY ); + ++nEC; + } + else + { + constraints.setType( i,ST_BOUNDED ); + } + } + } + + /* 4) Set dimensions of constraints structure. */ + constraints.setNEC( nEC ); + constraints.setNUC( nUC ); + constraints.setNIC( nC - nEC - nUC ); + + return SUCCESSFUL_RETURN; +} + + +/* + * c h o l e s k y D e c o m p o s i t i o n P r o j e c t e d + */ +returnValue QProblem::setupCholeskyDecompositionProjected( ) +{ + int i, j, k, ii, kk; + int nV = getNV( ); + int nFR = getNFR( ); + int nZ = getNZ( ); + + /* 1) Initialises R with all zeros. */ + for( i=0; i 0 ) + { + int FR_idx[NVMAX]; + if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_INDEXLIST_CORRUPTED ); + +#if 0 + real_t HZ[NVMAX*NVMAX]; + real_t ZHZ[NVMAX*NVMAX]; + + /* calculate H*Z */ + for ( i=0; i=0; --k ) + sum -= R[k*NVMAX + i] * R[k*NVMAX + i]; + + if ( sum > 0.0 ) + { + R[i*NVMAX + i] = sqrt( sum ); + inv = 1.0 / R[i * NVMAX + i]; + } + else + { + hessianType = HST_SEMIDEF; + return THROWERROR( RET_HESSIAN_NOT_SPD ); + } + + for( j=(i+1); j=0; --k ) + sum -= R[k*NVMAX + i] * R[k*NVMAX + j]; + + R[i*NVMAX + j] = sum * inv; + } + } +#else + real_t HZ[NVMAX]; + real_t ZHZ[NVMAX]; + + real_t sum, inv; + for (j = 0; j < nZ; ++j) + { + /* Cache one column of Z. */ + for (i = 0; i < NVMAX; ++i) + ZHZ[i] = Q[i * NVMAX + j]; + + /* Create one column of the product H * Z. */ + for (i = 0; i < nFR; ++i) + { + ii = FR_idx[i]; + + sum = 0.0; + for (k = 0; k < nFR; ++k) + { + kk = FR_idx[k]; + sum += H[ii * NVMAX + kk] * ZHZ[kk]; + } + HZ[ii] = sum; + } + + /* Create one column of the product Z^T * H * Z. */ + for (i = j; i < nZ; ++i) + ZHZ[ i ] = 0.0; + + for (k = 0; k < nFR; ++k) + { + kk = FR_idx[k]; + real_t q = HZ[kk]; + for (i = j; i < nZ; ++i) + { + ZHZ[i] += Q[kk * NVMAX + i] * q; + } + } + + /* Use the computed column to update the factorization. */ + /* j == i */ + sum = ZHZ[j]; + + for (k = (j - 1); k >= 0; --k) + sum -= R[k * NVMAX + j] * R[k * NVMAX + j]; + + if (sum > 0.0) + { + R[j * NVMAX + j] = sqrt(sum); + inv = 1.0 / R[j * NVMAX + j]; + } + else + { + hessianType = HST_SEMIDEF; + return THROWERROR( RET_HESSIAN_NOT_SPD ); + } + + for (i = (j + 1); i < nZ; ++i) + { + sum = ZHZ[i]; + + for (k = (j - 1); k >= 0; --k) + sum -= R[k * NVMAX + j] * R[k * NVMAX + i]; + + R[j * NVMAX + i] = sum * inv; + } + } +#endif + } + } + + return SUCCESSFUL_RETURN; +} + + +/* + * s e t u p T Q f a c t o r i s a t i o n + */ +returnValue QProblem::setupTQfactorisation( ) +{ + int i, j, ii; + int nV = getNV( ); + int nFR = getNFR( ); + + int FR_idx[NVMAX]; + if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_INDEXLIST_CORRUPTED ); + + /* 1) Set Q to unity matrix. */ + for( i=0; igetStatus( i ); + + if ( constraints.getType( i ) == ST_EQUALITY ) + { + if ( auxiliaryConstraints->setupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + } + else + { + if ( auxiliaryConstraints->setupConstraint( i,guessedStatus ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + } + } + } + else /* No initial working set specified. */ + { + /* Obtain initial working set by "clipping". */ + if ( ( xOpt != 0 ) && ( yOpt == 0 ) ) + { + for( i=0; isetupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + continue; + } + + if ( Ax[i] >= ubA[i] - BOUNDTOL ) + { + if ( auxiliaryConstraints->setupConstraint( i,ST_UPPER ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + continue; + } + + /* Moreover, add all equality constraints if specified. */ + if ( constraints.getType( i ) == ST_EQUALITY ) + { + if ( auxiliaryConstraints->setupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + } + else + { + if ( auxiliaryConstraints->setupConstraint( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + } + } + } + + /* Obtain initial working set in accordance to sign of dual solution vector. */ + if ( ( xOpt == 0 ) && ( yOpt != 0 ) ) + { + for( i=0; i ZERO ) + { + if ( auxiliaryConstraints->setupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + continue; + } + + if ( yOpt[nV+i] < -ZERO ) + { + if ( auxiliaryConstraints->setupConstraint( i,ST_UPPER ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + continue; + } + + /* Moreover, add all equality constraints if specified. */ + if ( constraints.getType( i ) == ST_EQUALITY ) + { + if ( auxiliaryConstraints->setupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + } + else + { + if ( auxiliaryConstraints->setupConstraint( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + } + } + } + + /* If xOpt and yOpt are null pointer and no initial working is specified, + * start with empty working set (or implicitly fixed bounds and equality constraints only) + * for auxiliary QP. */ + if ( ( xOpt == 0 ) && ( yOpt == 0 ) ) + { + for( i=0; isetupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + } + else + { + if ( auxiliaryConstraints->setupConstraint( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + } + } + } + } + + return SUCCESSFUL_RETURN; +} + + + +/* + * s e t u p A u x i l i a r y W o r k i n g S e t + */ +returnValue QProblem::setupAuxiliaryWorkingSet( const Bounds* const auxiliaryBounds, + const Constraints* const auxiliaryConstraints, + BooleanType setupAfresh + ) +{ + int i; + int nV = getNV( ); + int nC = getNC( ); + + /* consistency checks */ + if ( auxiliaryBounds != 0 ) + { + for( i=0; igetStatus( i ) == ST_UNDEFINED ) ) + return THROWERROR( RET_UNKNOWN_BUG ); + } + else + { + return THROWERROR( RET_INVALID_ARGUMENTS ); + } + + if ( auxiliaryConstraints != 0 ) + { + for( i=0; igetStatus( i ) == ST_UNDEFINED ) ) + return THROWERROR( RET_UNKNOWN_BUG ); + } + else + { + return THROWERROR( RET_INVALID_ARGUMENTS ); + } + + + /* I) SETUP CHOLESKY FLAG: + * Cholesky decomposition shall only be updated if working set + * shall be updated (i.e. NOT setup afresh!) */ + BooleanType updateCholesky; + if ( setupAfresh == BT_TRUE ) + updateCholesky = BT_FALSE; + else + updateCholesky = BT_TRUE; + + + /* II) REMOVE FORMERLY ACTIVE (CONSTRAINTS') BOUNDS (IF NECESSARY): */ + if ( setupAfresh == BT_FALSE ) + { + /* 1) Remove all active constraints that shall be inactive AND + * all active constraints that are active at the wrong bound. */ + for( i=0; igetStatus( i ) != ST_LOWER ) ) + if ( removeConstraint( i,updateCholesky ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); + + if ( ( constraints.getStatus( i ) == ST_UPPER ) && ( auxiliaryConstraints->getStatus( i ) != ST_UPPER ) ) + if ( removeConstraint( i,updateCholesky ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); + } + + /* 2) Remove all active bounds that shall be inactive AND + * all active bounds that are active at the wrong bound. */ + for( i=0; igetStatus( i ) != ST_LOWER ) ) + if ( removeBound( i,updateCholesky ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); + + if ( ( bounds.getStatus( i ) == ST_UPPER ) && ( auxiliaryBounds->getStatus( i ) != ST_UPPER ) ) + if ( removeBound( i,updateCholesky ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); + } + } + + + /* III) ADD NEWLY ACTIVE (CONSTRAINTS') BOUNDS: */ + /* 1) Add all inactive bounds that shall be active AND + * all formerly active bounds that have been active at the wrong bound. */ + for( i=0; igetStatus( i ) != ST_INACTIVE ) ) + { + /* Add bound only if it is linearly independent from the current working set. */ + if ( addBound_checkLI( i ) == RET_LINEARLY_INDEPENDENT ) + { + if ( addBound( i,auxiliaryBounds->getStatus( i ),updateCholesky ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); + } + } + } + + /* 2) Add all inactive constraints that shall be active AND + * all formerly active constraints that have been active at the wrong bound. */ + for( i=0; igetStatus( i ) == ST_LOWER ) || ( auxiliaryConstraints->getStatus( i ) == ST_UPPER ) ) + { + /* formerly inactive */ + if ( constraints.getStatus( i ) == ST_INACTIVE ) + { + /* Add constraint only if it is linearly independent from the current working set. */ + if ( addConstraint_checkLI( i ) == RET_LINEARLY_INDEPENDENT ) + { + if ( addConstraint( i,auxiliaryConstraints->getStatus( i ),updateCholesky ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); + } + } + } + } + + return SUCCESSFUL_RETURN; +} + + +/* + * s e t u p A u x i l i a r y Q P s o l u t i o n + */ +returnValue QProblem::setupAuxiliaryQPsolution( const real_t* const xOpt, const real_t* const yOpt + ) +{ + int i, j; + int nV = getNV( ); + int nC = getNC( ); + + + /* Setup primal/dual solution vector for auxiliary initial QP: + * if a null pointer is passed, a zero vector is assigned; + * old solution vector is kept if pointer to internal solution vevtor is passed. */ + if ( xOpt != 0 ) + { + if ( xOpt != x ) + for( i=0; igetStatus( i ) == ST_LOWER ) + lb[i] = x[i]; + else + lb[i] = x[i] - BOUNDRELAXATION; + + if ( auxiliaryBounds->getStatus( i ) == ST_UPPER ) + ub[i] = x[i]; + else + ub[i] = x[i] + BOUNDRELAXATION; + } + } + break; + + case ST_LOWER: + lb[i] = x[i]; + if ( bounds.getType( i ) == ST_EQUALITY ) + { + ub[i] = x[i]; + } + else + { + if ( useRelaxation == BT_TRUE ) + ub[i] = x[i] + BOUNDRELAXATION; + } + break; + + case ST_UPPER: + ub[i] = x[i]; + if ( bounds.getType( i ) == ST_EQUALITY ) + { + lb[i] = x[i]; + } + else + { + if ( useRelaxation == BT_TRUE ) + lb[i] = x[i] - BOUNDRELAXATION; + } + break; + + default: + return THROWERROR( RET_UNKNOWN_BUG ); + } + } + + /* 2) Setup constraints vectors. */ + for ( i=0; igetStatus( i ) == ST_LOWER ) + lbA[i] = Ax[i]; + else + lbA[i] = Ax[i] - BOUNDRELAXATION; + + if ( auxiliaryConstraints->getStatus( i ) == ST_UPPER ) + ubA[i] = Ax[i]; + else + ubA[i] = Ax[i] + BOUNDRELAXATION; + } + } + break; + + case ST_LOWER: + lbA[i] = Ax[i]; + if ( constraints.getType( i ) == ST_EQUALITY ) + { + ubA[i] = Ax[i]; + } + else + { + if ( useRelaxation == BT_TRUE ) + ubA[i] = Ax[i] + BOUNDRELAXATION; + } + break; + + case ST_UPPER: + ubA[i] = Ax[i]; + if ( constraints.getType( i ) == ST_EQUALITY ) + { + lbA[i] = Ax[i]; + } + else + { + if ( useRelaxation == BT_TRUE ) + lbA[i] = Ax[i] - BOUNDRELAXATION; + } + break; + + default: + return THROWERROR( RET_UNKNOWN_BUG ); + } + } + + return SUCCESSFUL_RETURN; +} + + +/* + * a d d C o n s t r a i n t + */ +returnValue QProblem::addConstraint( int number, SubjectToStatus C_status, + BooleanType updateCholesky + ) +{ + int i, j, ii; + + /* consistency checks */ + if ( constraints.getStatus( number ) != ST_INACTIVE ) + return THROWERROR( RET_CONSTRAINT_ALREADY_ACTIVE ); + + if ( ( constraints.getNC( ) - getNAC( ) ) == constraints.getNUC( ) ) + return THROWERROR( RET_ALL_CONSTRAINTS_ACTIVE ); + + if ( ( getStatus( ) == QPS_NOTINITIALISED ) || + ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || + ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || + ( getStatus( ) == QPS_SOLVED ) ) + { + return THROWERROR( RET_UNKNOWN_BUG ); + } + + + /* I) ENSURE LINEAR INDEPENDENCE OF THE WORKING SET, + * i.e. remove a constraint or bound if linear dependence occurs. */ + /* check for LI only if Cholesky decomposition shall be updated! */ + if ( updateCholesky == BT_TRUE ) + { + returnValue ensureLIreturnvalue = addConstraint_ensureLI( number,C_status ); + + switch ( ensureLIreturnvalue ) + { + case SUCCESSFUL_RETURN: + break; + + case RET_LI_RESOLVED: + break; + + case RET_ENSURELI_FAILED_NOINDEX: + return THROWERROR( RET_ADDCONSTRAINT_FAILED_INFEASIBILITY ); + + case RET_ENSURELI_FAILED_CYCLING: + return THROWERROR( RET_ADDCONSTRAINT_FAILED_INFEASIBILITY ); + + default: + return THROWERROR( RET_ENSURELI_FAILED ); + } + } + + /* some definitions */ + int nFR = getNFR( ); + int nAC = getNAC( ); + int nZ = getNZ( ); + + int tcol = sizeT - nAC; + + + int FR_idx[NVMAX]; + if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_ADDCONSTRAINT_FAILED ); + + real_t aFR[NVMAX]; + real_t wZ[NVMAX]; + for( i=0; i 0 ) + { + for( j=0; j 0 ) + { + /* II) RESTORE TRIANGULAR FORM OF T: */ + /* Use column-wise Givens rotations to restore reverse triangular form + * of T, simultanenous change of Q (i.e. Z) and R. */ + for( j=0; jgetNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_INDEXLIST_CORRUPTED ); + + /* Check if constraint is linearly independent from the + the active ones (<=> is element of null space of Afr). */ + real_t sum; + + for( i=0; i 10.0*EPS ) + return RET_LINEARLY_INDEPENDENT; + } + + return RET_LINEARLY_DEPENDENT; +} + + +/* + * a d d C o n s t r a i n t _ e n s u r e L I + */ +returnValue QProblem::addConstraint_ensureLI( int number, SubjectToStatus C_status ) +{ + int i, j, ii, jj; + int nV = getNV( ); + int nFR = getNFR( ); + int nFX = getNFX( ); + int nAC = getNAC( ); + int nZ = getNZ( ); + + + /* I) Check if new constraint is linearly independent from the active ones. */ + returnValue returnvalueCheckLI = addConstraint_checkLI( number ); + + if ( returnvalueCheckLI == RET_INDEXLIST_CORRUPTED ) + return THROWERROR( RET_ENSURELI_FAILED ); + + if ( returnvalueCheckLI == RET_LINEARLY_INDEPENDENT ) + return SUCCESSFUL_RETURN; + + + /* II) NEW CONSTRAINT IS LINEARLY DEPENDENT: */ + /* 1) Determine coefficients of linear combination, + * cf. M.J. Best. Applied Mathematics and Parallel Computing, chapter: + * An Algorithm for the Solution of the Parametric Quadratic Programming + * Problem, pages 57-76. Physica-Verlag, Heidelberg, 1996. */ + int FR_idx[NVMAX]; + if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_ENSURELI_FAILED ); + + int FX_idx[NVMAX]; + if ( bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_ENSURELI_FAILED ); + + real_t xiC[NCMAX_ALLOC]; + real_t xiC_TMP[NCMAX_ALLOC]; + real_t xiB[NVMAX]; + + /* 2) Calculate xiC */ + if ( nAC > 0 ) + { + if ( C_status == ST_LOWER ) + { + for( i=0; igetNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_ENSURELI_FAILED ); + + if ( C_status == ST_LOWER ) + { + for( i=0; i ZERO ) && ( y[nV+ii] >= 0.0 ) ) + { + if ( y[nV+ii]/xiC[i] < y_min ) + { + y_min = y[nV+ii]/xiC[i]; + y_min_number = ii; + } + } + } + else + { + if ( ( xiC[i] < -ZERO ) && ( y[nV+ii] <= 0.0 ) ) + { + if ( y[nV+ii]/xiC[i] < y_min ) + { + y_min = y[nV+ii]/xiC[i]; + y_min_number = ii; + } + } + } + } + + /* 2) Bounds. */ + for( i=0; i ZERO ) && ( y[ii] >= 0.0 ) ) + { + if ( y[ii]/xiB[i] < y_min ) + { + y_min = y[ii]/xiB[i]; + y_min_number = ii; + y_min_isBound = BT_TRUE; + } + } + } + else + { + if ( ( xiB[i] < -ZERO ) && ( y[ii] <= 0.0 ) ) + { + if ( y[ii]/xiB[i] < y_min ) + { + y_min = y[ii]/xiB[i]; + y_min_number = ii; + y_min_isBound = BT_TRUE; + } + } + } + } + + /* setup output preferences */ + #ifdef PC_DEBUG + char messageString[80]; + VisibilityStatus visibilityStatus; + + if ( printlevel == PL_HIGH ) + visibilityStatus = VS_VISIBLE; + else + visibilityStatus = VS_HIDDEN; + #endif + + + /* IV) REMOVE CONSTRAINT/BOUND FOR RESOLVING LINEAR DEPENDENCE: */ + if ( y_min_number >= 0 ) + { + /* 1) Check for cycling due to infeasibility. */ + if ( ( cyclingManager.getCyclingStatus( number,BT_FALSE ) == CYC_PREV_REMOVED ) && + ( cyclingManager.getCyclingStatus( y_min_number,y_min_isBound ) == CYC_PREV_ADDED ) ) + { + infeasible = BT_TRUE; + + return THROWERROR( RET_ENSURELI_FAILED_CYCLING ); + } + else + { + /* set cycling data */ + cyclingManager.clearCyclingData( ); + cyclingManager.setCyclingStatus( number,BT_FALSE, CYC_PREV_ADDED ); + cyclingManager.setCyclingStatus( y_min_number,y_min_isBound, CYC_PREV_REMOVED ); + } + + /* 2) Update Lagrange multiplier... */ + for( i=0; ithrowInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); + #endif + + if ( removeBound( y_min_number,BT_TRUE ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); + + y[y_min_number] = 0.0; + } + else + { + #ifdef PC_DEBUG + sprintf( messageString,"constraint no. %d.",y_min_number ); + getGlobalMessageHandler( )->throwInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); + #endif + + if ( removeConstraint( y_min_number,BT_TRUE ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); + + y[nV+y_min_number] = 0.0; + } + } + else + { + /* no constraint/bound can be removed => QP is infeasible! */ + infeasible = BT_TRUE; + + return THROWERROR( RET_ENSURELI_FAILED_NOINDEX ); + } + + return getGlobalMessageHandler( )->throwInfo( RET_LI_RESOLVED,0,__FUNCTION__,__FILE__,__LINE__,VS_HIDDEN ); +} + + + +/* + * a d d B o u n d + */ +returnValue QProblem::addBound( int number, SubjectToStatus B_status, + BooleanType updateCholesky + ) +{ + int i, j, ii; + + /* consistency checks */ + if ( bounds.getStatus( number ) != ST_INACTIVE ) + return THROWERROR( RET_BOUND_ALREADY_ACTIVE ); + + if ( getNFR( ) == bounds.getNUV( ) ) + return THROWERROR( RET_ALL_BOUNDS_ACTIVE ); + + if ( ( getStatus( ) == QPS_NOTINITIALISED ) || + ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || + ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || + ( getStatus( ) == QPS_SOLVED ) ) + { + return THROWERROR( RET_UNKNOWN_BUG ); + } + + + /* I) ENSURE LINEAR INDEPENDENCE OF THE WORKING SET, + * i.e. remove a constraint or bound if linear dependence occurs. */ + /* check for LI only if Cholesky decomposition shall be updated! */ + if ( updateCholesky == BT_TRUE ) + { + returnValue ensureLIreturnvalue = addBound_ensureLI( number,B_status ); + + switch ( ensureLIreturnvalue ) + { + case SUCCESSFUL_RETURN: + break; + + case RET_LI_RESOLVED: + break; + + case RET_ENSURELI_FAILED_NOINDEX: + return THROWERROR( RET_ADDBOUND_FAILED_INFEASIBILITY ); + + case RET_ENSURELI_FAILED_CYCLING: + return THROWERROR( RET_ADDBOUND_FAILED_INFEASIBILITY ); + + default: + return THROWERROR( RET_ENSURELI_FAILED ); + } + } + + + /* some definitions */ + int nFR = getNFR( ); + int nAC = getNAC( ); + int nZ = getNZ( ); + + int tcol = sizeT - nAC; + + + /* I) SWAP INDEXLIST OF FREE VARIABLES: + * move the variable to be fixed to the end of the list of free variables. */ + int lastfreenumber = bounds.getFree( )->getLastNumber( ); + if ( lastfreenumber != number ) + if ( bounds.swapFree( number,lastfreenumber ) != SUCCESSFUL_RETURN ) + THROWERROR( RET_ADDBOUND_FAILED ); + + + int FR_idx[NVMAX]; + if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_ADDBOUND_FAILED ); + + real_t w[NVMAX]; + + + /* II) ADD NEW ACTIVE BOUND TO TOP OF MATRIX T: */ + /* 1) add row [wZ wY] = [Z Y](number) at the top of T: assign w */ + for( i=0; i 0 ) /* ( nAC == 0 ) <=> ( nZ == nFR ) <=> Y and T are empty => nothing to do */ + { + /* store new column a in a temporary vector instead of shifting T one column to the left */ + real_t tmp[NCMAX_ALLOC]; + for( i=0; i is linearly independent from the + the active ones (<=> is element of null space of Afr). */ + for( i=0; i EPS ) + return RET_LINEARLY_INDEPENDENT; + } + + return RET_LINEARLY_DEPENDENT; +} + + +/* + * a d d B o u n d _ e n s u r e L I + */ +returnValue QProblem::addBound_ensureLI( int number, SubjectToStatus B_status ) +{ + int i, j, ii, jj; + int nV = getNV( ); + int nFX = getNFX( ); + int nAC = getNAC( ); + int nZ = getNZ( ); + + + /* I) Check if new constraint is linearly independent from the active ones. */ + returnValue returnvalueCheckLI = addBound_checkLI( number ); + + if ( returnvalueCheckLI == RET_LINEARLY_INDEPENDENT ) + return SUCCESSFUL_RETURN; + + + /* II) NEW BOUND IS LINEARLY DEPENDENT: */ + /* 1) Determine coefficients of linear combination, + * cf. M.J. Best. Applied Mathematics and Parallel Computing, chapter: + * An Algorithm for the Solution of the Parametric Quadratic Programming + * Problem, pages 57-76. Physica-Verlag, Heidelberg, 1996. */ + int FR_idx[NVMAX]; + if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_ENSURELI_FAILED ); + + int FX_idx[NVMAX]; + if ( bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_ENSURELI_FAILED ); + + int AC_idx[NCMAX_ALLOC]; + if ( constraints.getActive( )->getNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_ENSURELI_FAILED ); + + real_t xiC[NCMAX_ALLOC]; + real_t xiC_TMP[NCMAX_ALLOC]; + real_t xiB[NVMAX]; + + /* 2) Calculate xiC. */ + if ( nAC > 0 ) + { + if ( B_status == ST_LOWER ) + { + for( i=0; i ZERO ) && ( y[nV+ii] >= 0.0 ) ) + { + if ( y[nV+ii]/xiC[i] < y_min ) + { + y_min = y[nV+ii]/xiC[i]; + y_min_number = ii; + } + } + } + else + { + if ( ( xiC[i] < -ZERO ) && ( y[nV+ii] <= 0.0 ) ) + { + if ( y[nV+ii]/xiC[i] < y_min ) + { + y_min = y[nV+ii]/xiC[i]; + y_min_number = ii; + } + } + } + } + + /* 2) Bounds. */ + for( i=0; i ZERO ) && ( y[ii] >= 0.0 ) ) + { + if ( y[ii]/xiB[i] < y_min ) + { + y_min = y[ii]/xiB[i]; + y_min_number = ii; + y_min_isBound = BT_TRUE; + } + } + } + else + { + if ( ( xiB[i] < -ZERO ) && ( y[ii] <= 0.0 ) ) + { + if ( y[ii]/xiB[i] < y_min ) + { + y_min = y[ii]/xiB[i]; + y_min_number = ii; + y_min_isBound = BT_TRUE; + } + } + } + } + + /* setup output preferences */ + #ifdef PC_DEBUG + char messageString[80]; + VisibilityStatus visibilityStatus; + + if ( printlevel == PL_HIGH ) + visibilityStatus = VS_VISIBLE; + else + visibilityStatus = VS_HIDDEN; + #endif + + + /* IV) REMOVE CONSTRAINT/BOUND FOR RESOLVING LINEAR DEPENDENCE: */ + if ( y_min_number >= 0 ) + { + /* 1) Check for cycling due to infeasibility. */ + if ( ( cyclingManager.getCyclingStatus( number,BT_TRUE ) == CYC_PREV_REMOVED ) && + ( cyclingManager.getCyclingStatus( y_min_number,y_min_isBound ) == CYC_PREV_ADDED ) ) + { + infeasible = BT_TRUE; + + return THROWERROR( RET_ENSURELI_FAILED_CYCLING ); + } + else + { + /* set cycling data */ + cyclingManager.clearCyclingData( ); + cyclingManager.setCyclingStatus( number,BT_TRUE, CYC_PREV_ADDED ); + cyclingManager.setCyclingStatus( y_min_number,y_min_isBound, CYC_PREV_REMOVED ); + } + + + /* 2) Update Lagrange multiplier... */ + for( i=0; ithrowInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); + #endif + + if ( removeBound( y_min_number,BT_TRUE ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); + + y[y_min_number] = 0.0; + } + else + { + #ifdef PC_DEBUG + sprintf( messageString,"constraint no. %d.",y_min_number ); + getGlobalMessageHandler( )->throwInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); + #endif + + if ( removeConstraint( y_min_number,BT_TRUE ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); + + y[nV+y_min_number] = 0.0; + } + } + else + { + /* no constraint/bound can be removed => QP is infeasible! */ + infeasible = BT_TRUE; + + return THROWERROR( RET_ENSURELI_FAILED_NOINDEX ); + } + + return getGlobalMessageHandler( )->throwInfo( RET_LI_RESOLVED,0,__FUNCTION__,__FILE__,__LINE__,VS_HIDDEN ); +} + + + +/* + * r e m o v e C o n s t r a i n t + */ +returnValue QProblem::removeConstraint( int number, + BooleanType updateCholesky + ) +{ + int i, j, ii, jj; + + /* consistency check */ + if ( ( getStatus( ) == QPS_NOTINITIALISED ) || + ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || + ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || + ( getStatus( ) == QPS_SOLVED ) ) + { + return THROWERROR( RET_UNKNOWN_BUG ); + } + + /* some definitions */ + int nFR = getNFR( ); + int nAC = getNAC( ); + int nZ = getNZ( ); + + int tcol = sizeT - nAC; + int number_idx = constraints.getActive( )->getIndex( number ); + + + /* consistency checks */ + if ( constraints.getStatus( number ) == ST_INACTIVE ) + return THROWERROR( RET_CONSTRAINT_NOT_ACTIVE ); + + if ( ( number_idx < 0 ) || ( number_idx >= nAC ) ) + return THROWERROR( RET_CONSTRAINT_NOT_ACTIVE ); + + + int FR_idx[NVMAX]; + if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_REMOVECONSTRAINT_FAILED ); + + + /* I) REMOVE th ROW FROM T, + * i.e. shift rows number+1 through nAC upwards (instead of the actual + * constraint number its corresponding index within matrix A is used). */ + if ( number_idx < nAC-1 ) + { + for( i=(number_idx+1); i=0; --j ) + { + computeGivens( T[(nAC-2-j)*NVMAX + tcol+1+j],T[(nAC-2-j)*NVMAX + tcol+j], T[(nAC-2-j)*NVMAX + tcol+1+j],T[(nAC-2-j)*NVMAX + tcol+j],c,s ); + + for( i=(nAC-j-1); i<(nAC-1); ++i ) + applyGivens( c,s,T[i*NVMAX + tcol+1+j],T[i*NVMAX + tcol+j], T[i*NVMAX + tcol+1+j],T[i*NVMAX + tcol+j] ); + + for( i=0; i 0 ) + { + real_t ZHz[NVMAX]; + for ( i=0; i 0.0 ) + R[nZ*NVMAX + nZ] = sqrt( rho2 ); + else + { + hessianType = HST_SEMIDEF; + return THROWERROR( RET_HESSIAN_NOT_SPD ); + } + } + + /* IV) UPDATE INDICES */ + if ( constraints.moveActiveToInactive( number ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_REMOVECONSTRAINT_FAILED ); + + + return SUCCESSFUL_RETURN; +} + + +/* + * r e m o v e B o u n d + */ +returnValue QProblem::removeBound( int number, + BooleanType updateCholesky + ) +{ + int i, j, ii, jj; + + /* consistency checks */ + if ( bounds.getStatus( number ) == ST_INACTIVE ) + return THROWERROR( RET_BOUND_NOT_ACTIVE ); + + if ( ( getStatus( ) == QPS_NOTINITIALISED ) || + ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || + ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || + ( getStatus( ) == QPS_SOLVED ) ) + { + return THROWERROR( RET_UNKNOWN_BUG ); + } + + /* some definitions */ + int nFR = getNFR( ); + int nAC = getNAC( ); + int nZ = getNZ( ); + + int tcol = sizeT - nAC; + + + /* I) UPDATE INDICES */ + if ( bounds.moveFixedToFree( number ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_REMOVEBOUND_FAILED ); + + + int FR_idx[NVMAX]; + if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_REMOVEBOUND_FAILED ); + + /* I) APPEND th UNITY VECOTR TO Q. */ + int nnFRp1 = FR_idx[nFR]; + for( i=0; i 0 ) + { + /* store new column a in a temporary vector instead of shifting T one column to the left and appending a */ + int AC_idx[NCMAX_ALLOC]; + if ( constraints.getActive( )->getNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_REMOVEBOUND_FAILED ); + + real_t tmp[NCMAX_ALLOC]; + for( i=0; i=0; --j ) + { + computeGivens( tmp[nAC-1-j],T[(nAC-1-j)*NVMAX + tcol+j],T[(nAC-1-j)*NVMAX + tcol+j],tmp[nAC-1-j],c,s ); + + for( i=(nAC-j); i 0 ) + { + real_t Hz[NVMAX]; + for( i=0; i 0 ) + { + real_t r[NVMAX]; + real_t rhs[NVMAX]; + for( i=0; i 0.0 ) + R[nZ*NVMAX + nZ] = sqrt( rho2 ); + else + { + hessianType = HST_SEMIDEF; + return THROWERROR( RET_HESSIAN_NOT_SPD ); + } + } + + return SUCCESSFUL_RETURN; +} + + +/* + * b a c k s o l v e R (CODE DUPLICATE OF QProblemB CLASS!!!) + */ +returnValue QProblem::backsolveR( const real_t* const b, BooleanType transposed, + real_t* const a + ) +{ + /* Call standard backsolve procedure (i.e. removingBound == BT_FALSE). */ + return backsolveR( b,transposed,BT_FALSE,a ); +} + + +/* + * b a c k s o l v e R (CODE DUPLICATE OF QProblemB CLASS!!!) + */ +returnValue QProblem::backsolveR( const real_t* const b, BooleanType transposed, + BooleanType removingBound, + real_t* const a + ) +{ + int i, j; + int nR = getNZ( ); + + real_t sum; + + /* if backsolve is called while removing a bound, reduce nZ by one. */ + if ( removingBound == BT_TRUE ) + --nR; + + /* nothing to do */ + if ( nR <= 0 ) + return SUCCESSFUL_RETURN; + + + /* Solve Ra = b, where R might be transposed. */ + if ( transposed == BT_FALSE ) + { + /* solve Ra = b */ + for( i=(nR-1); i>=0; --i ) + { + sum = b[i]; + for( j=(i+1); j ZERO ) + a[i] = sum / R[i*NVMAX + i]; + else + return THROWERROR( RET_DIV_BY_ZERO ); + } + } + else + { + /* solve R^T*a = b */ + for( i=0; i ZERO ) + a[i] = sum / R[i*NVMAX + i]; + else + return THROWERROR( RET_DIV_BY_ZERO ); + } + } + + return SUCCESSFUL_RETURN; +} + + + +/* + * b a c k s o l v e T + */ +returnValue QProblem::backsolveT( const real_t* const b, BooleanType transposed, real_t* const a ) +{ + int i, j; + int nT = getNAC( ); + int tcol = sizeT - nT; + + real_t sum; + + /* nothing to do */ + if ( nT <= 0 ) + return SUCCESSFUL_RETURN; + + + /* Solve Ta = b, where T might be transposed. */ + if ( transposed == BT_FALSE ) + { + /* solve Ta = b */ + for( i=0; i ZERO ) + a[nT-1-i] = sum / T[i*NVMAX + sizeT-1-i]; + else + return THROWERROR( RET_DIV_BY_ZERO ); + } + } + else + { + /* solve T^T*a = b */ + for( i=0; i ZERO ) + a[nT-1-i] = sum / T[(nT-1-i)*NVMAX + tcol+i]; + else + return THROWERROR( RET_DIV_BY_ZERO ); + } + } + + + return SUCCESSFUL_RETURN; +} + + +/* + * h o t s t a r t _ d e t e r m i n e D a t a S h i f t + */ +returnValue QProblem::hotstart_determineDataShift( const int* const FX_idx, const int* const AC_idx, + const real_t* const g_new, const real_t* const lbA_new, const real_t* const ubA_new, + const real_t* const lb_new, const real_t* const ub_new, + real_t* const delta_g, real_t* const delta_lbA, real_t* const delta_ubA, + real_t* const delta_lb, real_t* const delta_ub, + BooleanType& Delta_bC_isZero, BooleanType& Delta_bB_isZero + ) +{ + int i, ii; + int nC = getNC( ); + int nAC = getNAC( ); + + + /* I) DETERMINE DATA SHIFT FOR BOUNDS */ + QProblemB::hotstart_determineDataShift( FX_idx,g_new,lb_new,ub_new, delta_g,delta_lb,delta_ub, Delta_bB_isZero ); + + + /* II) DETERMINE DATA SHIFT FOR CONSTRAINTS */ + /* 1) Calculate shift directions. */ + for( i=0; i EPS ) || ( getAbs( delta_ubA[ii] ) > EPS ) ) + { + Delta_bC_isZero = BT_FALSE; + break; + } + } + + return SUCCESSFUL_RETURN; +} + + +/* + * h o t s t a r t _ d e t e r m i n e S t e p D i r e c t i o n + */ +returnValue QProblem::hotstart_determineStepDirection( const int* const FR_idx, const int* const FX_idx, const int* const AC_idx, + const real_t* const delta_g, const real_t* const delta_lbA, const real_t* const delta_ubA, + const real_t* const delta_lb, const real_t* const delta_ub, + BooleanType Delta_bC_isZero, BooleanType Delta_bB_isZero, + real_t* const delta_xFX, real_t* const delta_xFR, + real_t* const delta_yAC, real_t* const delta_yFX + ) +{ + int i, j, ii, jj; + int nFR = getNFR( ); + int nFX = getNFX( ); + int nAC = getNAC( ); + int nZ = getNZ( ); + + /* initialise auxiliary vectors */ + real_t HMX_delta_xFX[NVMAX]; + real_t YFR_delta_xFRy[NVMAX]; + real_t ZFR_delta_xFRz[NVMAX]; + real_t HFR_YFR_delta_xFRy[NVMAX]; + for( i=0; i 0 ) + { + for( i=0; i 0 ) + { + /* 1) Determine delta_xFRy. */ + if ( nAC > 0 ) + { + if ( ( Delta_bC_isZero == BT_TRUE ) && ( Delta_bB_isZero == BT_TRUE ) ) + { + for( i=0; i 0 ) + { + for( i=0; i 0 ) + { + if ( ( Delta_bC_isZero == BT_FALSE ) || ( Delta_bB_isZero == BT_FALSE ) ) + { + for( i=0; i 0 ) + { + /* auxiliary variable */ + real_t delta_xFRz_TMP[NVMAX]; + real_t delta_xFRz_RHS[NVMAX]; + + + if ( ( nAC > 0 ) && ( nFX > 0 ) && ( Delta_bB_isZero == BT_FALSE ) ) + { + for( j=0; j 0 ) /* => Delta_bB_isZero == BT_TRUE, as BT_FALSE would imply nFX>0 */ + { + for( j=0; j 0 ) /* => ( nFR = nZ + nAC > 0 ) */ + { + /* auxiliary variables */ + real_t delta_yAC_TMP[NCMAX_ALLOC]; + for( i=0; i 0 ) + { + for( i=0; i 0 ) + { + if ( Delta_bB_isZero == BT_FALSE ) + { + for( i=0; i 0 ) + { + for( i=0; i 0.0 ) + maxStepLength[nV+ii] = y[nV+ii] / ( -delta_yAC[i] ); + else + maxStepLength[nV+ii] = 0.0; + } + } + else + { + /* active upper constraints' bounds */ + if ( delta_yAC[i] > ZERO ) + { + if ( y[nV+ii] < 0.0 ) + maxStepLength[nV+ii] = y[nV+ii] / ( -delta_yAC[i] ); + else + maxStepLength[nV+ii] = 0.0; + } + } + } + } + + /* 2) Ensure that active dual bounds remain valid + * (ignoring implicitly fixed variables). */ + for( i=0; i 0.0 ) + maxStepLength[ii] = y[ii] / ( -delta_yFX[i] ); + else + maxStepLength[ii] = 0.0; + } + } + else + { + /* active upper bounds */ + if ( delta_yFX[i] > ZERO ) + { + if ( y[ii] < 0.0 ) + maxStepLength[ii] = y[ii] / ( -delta_yFX[i] ); + else + maxStepLength[ii] = 0.0; + } + } + } + } + + + /* II) DETERMINE MAXIMUM PRIMAL STEPLENGTH */ + /* 1) Ensure that inactive constraints' bounds remain valid + * (ignoring unbounded constraints). */ + real_t delta_x[NVMAX]; + for( j=0; j delta_Ax[ii] ) + { + if ( Ax[ii] > lbA[ii] ) + maxStepLength[nV+ii] = ( Ax[ii] - lbA[ii] ) / ( delta_lbA[ii] - delta_Ax[ii] ); + else + maxStepLength[nV+ii] = 0.0; + } + } + + /* inactive upper constraints' bounds */ + if ( constraints.isNoUpper( ) == BT_FALSE ) + { + if ( delta_ubA[ii] < delta_Ax[ii] ) + { + if ( Ax[ii] < ubA[ii] ) + maxStepLength[nV+nC+nV+ii] = ( Ax[ii] - ubA[ii] ) / ( delta_ubA[ii] - delta_Ax[ii] ); + else + maxStepLength[nV+nC+nV+ii] = 0.0; + } + } + } + } + + + /* 2) Ensure that inactive bounds remain valid + * (ignoring unbounded variables). */ + /* inactive lower bounds */ + if ( bounds.isNoLower( ) == BT_FALSE ) + { + for( i=0; i delta_xFR[i] ) + { + if ( x[ii] > lb[ii] ) + maxStepLength[ii] = ( x[ii] - lb[ii] ) / ( delta_lb[ii] - delta_xFR[i] ); + else + maxStepLength[ii] = 0.0; + } + } + } + + /* inactive upper bounds */ + if ( bounds.isNoUpper( ) == BT_FALSE ) + { + for( i=0; i EPS ) + cyclingManager.clearCyclingData( ); + + + /* V) SET MAXIMUM HOMOTOPY STEPLENGTH */ + tau = tau_new; + + #ifdef PC_DEBUG + if ( printlevel == PL_HIGH ) + { + + char messageString[80]; + + if ( BC_status == ST_UNDEFINED ) + sprintf( messageString,"Stepsize is %.6e!",tau ); + else + sprintf( messageString,"Stepsize is %.6e! (BC_idx = %d, BC_isBound = %d, BC_status = %d)",tau,BC_idx,BC_isBound,BC_status ); + + getGlobalMessageHandler( )->throwInfo( RET_STEPSIZE_NONPOSITIVE,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); + } + #endif + + return SUCCESSFUL_RETURN; +} + + +/* + * h o t s t a r t _ p e r f o r m S t e p + */ +returnValue QProblem::hotstart_performStep( const int* const FR_idx, const int* const FX_idx, const int* const AC_idx, const int* const IAC_idx, + const real_t* const delta_g, const real_t* const delta_lbA, const real_t* const delta_ubA, + const real_t* const delta_lb, const real_t* const delta_ub, + const real_t* const delta_xFX, const real_t* const delta_xFR, + const real_t* const delta_yAC, const real_t* const delta_yFX, + const real_t* const delta_Ax, int BC_idx, SubjectToStatus BC_status, BooleanType BC_isBound + ) +{ + int i, j, ii; + int nV = getNV( ); + int nC = getNC( ); + int nFR = getNFR( ); + int nFX = getNFX( ); + int nAC = getNAC( ); + int nIAC = getNIAC( ); + + + /* I) CHECK (CONSTRAINTS') BOUNDS' CONSISTENCY */ + if ( areBoundsConsistent( delta_lb,delta_ub,delta_lbA,delta_ubA ) == BT_FALSE ) + { + infeasible = BT_TRUE; + tau = 0.0; + + return THROWERROR( RET_QP_INFEASIBLE ); + } + + + /* II) GO TO ACTIVE SET CHANGE */ + if ( tau > ZERO ) + { + /* 1) Perform step in primal und dual space... */ + for( i=0; ithrowWarning( RET_STEPSIZE,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); + #endif + } + + + /* setup output preferences */ + #ifdef PC_DEBUG + char messageString[80]; + VisibilityStatus visibilityStatus; + + if ( printlevel == PL_HIGH ) + visibilityStatus = VS_VISIBLE; + else + visibilityStatus = VS_HIDDEN; + #endif + + + /* III) UPDATE ACTIVE SET */ + switch ( BC_status ) + { + /* Optimal solution found as no working set change detected. */ + case ST_UNDEFINED: + return RET_OPTIMAL_SOLUTION_FOUND; + + + /* Remove one variable from active set. */ + case ST_INACTIVE: + if ( BC_isBound == BT_TRUE ) + { + #ifdef PC_DEBUG + sprintf( messageString,"bound no. %d.", BC_idx ); + getGlobalMessageHandler( )->throwInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); + #endif + + if ( removeBound( BC_idx,BT_TRUE ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); + + y[BC_idx] = 0.0; + } + else + { + #ifdef PC_DEBUG + sprintf( messageString,"constraint no. %d.", BC_idx ); + getGlobalMessageHandler( )->throwInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); + #endif + + if ( removeConstraint( BC_idx,BT_TRUE ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); + + y[nV+BC_idx] = 0.0; + } + break; + + + /* Add one variable to active set. */ + default: + if ( BC_isBound == BT_TRUE ) + { + #ifdef PC_DEBUG + if ( BC_status == ST_LOWER ) + sprintf( messageString,"lower bound no. %d.", BC_idx ); + else + sprintf( messageString,"upper bound no. %d.", BC_idx ); + getGlobalMessageHandler( )->throwInfo( RET_ADD_TO_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); + #endif + + if ( addBound( BC_idx,BC_status,BT_TRUE ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_ADD_TO_ACTIVESET_FAILED ); + } + else + { + #ifdef PC_DEBUG + if ( BC_status == ST_LOWER ) + sprintf( messageString,"lower constraint's bound no. %d.", BC_idx ); + else + sprintf( messageString,"upper constraint's bound no. %d.", BC_idx ); + getGlobalMessageHandler( )->throwInfo( RET_ADD_TO_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); + #endif + + if ( addConstraint( BC_idx,BC_status,BT_TRUE ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_ADD_TO_ACTIVESET_FAILED ); + } + break; + } + + return SUCCESSFUL_RETURN; +} + + +/* + * a r e B o u n d s C o n s i s t e n t + */ +BooleanType QProblem::areBoundsConsistent( const real_t* const delta_lb, const real_t* const delta_ub, + const real_t* const delta_lbA, const real_t* const delta_ubA + ) const +{ + int i; + + /* 1) Check bounds' consistency. */ + if ( QProblemB::areBoundsConsistent( delta_lb,delta_ub ) == BT_FALSE ) + return BT_FALSE; + + /* 2) Check constraints' consistency, i.e. + * check if delta_lb[i] is greater than delta_ub[i] + * for a component i whose bounds are already (numerically) equal. */ + for( i=0; i ubA[i] - BOUNDTOL ) && ( delta_lbA[i] > delta_ubA[i] + EPS ) ) + return BT_FALSE; + + return BT_TRUE; +} + + +/* + * s e t u p Q P d a t a + */ +returnValue QProblem::setupQPdata( const real_t* const _H, const real_t* const _R, const real_t* const _g, const real_t* const _A, + const real_t* const _lb, const real_t* const _ub, + const real_t* const _lbA, const real_t* const _ubA + ) +{ + int i, j; + int nV = getNV( ); + int nC = getNC( ); + + + /* 1) Load Hessian matrix as well as lower and upper bounds vectors. */ + if (QProblemB::setupQPdata(_H, _R, _g, _lb, _ub) != SUCCESSFUL_RETURN) + return THROWERROR( RET_INVALID_ARGUMENTS ); + + /* 2) Load constraint matrix. */ + if ( ( nC > 0 ) && ( _A == 0 ) ) + return THROWERROR( RET_INVALID_ARGUMENTS ); + + if ( nC > 0 ) + { + for( i=0; igetNumberArray( AC_idx ); + + /* 1) check for Hx + g - [yFX yAC]*[Id A]' = 0. */ + for( i=0; i maxKKTviolation ) + maxKKTviolation = getAbs( tmp ); + } + + /* 2) Check for [lb lbA] <= [Id A]*x <= [ub ubA]. */ + /* lbA <= Ax <= ubA */ + for( i=0; i maxKKTviolation ) + maxKKTviolation = lbA[i] - Ax[i]; + + if ( Ax[i] - ubA[i] > maxKKTviolation ) + maxKKTviolation = Ax[i] - ubA[i]; + } + + /* lb <= x <= ub */ + for( i=0; i maxKKTviolation ) + maxKKTviolation = lb[i] - x[i]; + + if ( x[i] - ub[i] > maxKKTviolation ) + maxKKTviolation = x[i] - ub[i]; + } + + /* 3) Check for correct sign of y and for complementary slackness. */ + /* bounds */ + for( i=0; i maxKKTviolation ) + maxKKTviolation = -y[i]; + if ( getAbs( x[i] - lb[i] ) > maxKKTviolation ) + maxKKTviolation = getAbs( x[i] - lb[i] ); + break; + + case ST_UPPER: + if ( y[i] > maxKKTviolation ) + maxKKTviolation = y[i]; + if ( getAbs( ub[i] - x[i] ) > maxKKTviolation ) + maxKKTviolation = getAbs( ub[i] - x[i] ); + break; + + default: /* inactive */ + if ( getAbs( y[i] ) > maxKKTviolation ) + maxKKTviolation = getAbs( y[i] ); + break; + } + } + + /* constraints */ + for( i=0; i maxKKTviolation ) + maxKKTviolation = -y[nV+i]; + if ( getAbs( Ax[i] - lbA[i] ) > maxKKTviolation ) + maxKKTviolation = getAbs( Ax[i] - lbA[i] ); + break; + + case ST_UPPER: + if ( y[nV+i] > maxKKTviolation ) + maxKKTviolation = y[nV+i]; + if ( getAbs( ubA[i] - Ax[i] ) > maxKKTviolation ) + maxKKTviolation = getAbs( ubA[i] - Ax[i] ); + break; + + default: /* inactive */ + if ( getAbs( y[nV+i] ) > maxKKTviolation ) + maxKKTviolation = getAbs( y[nV+i] ); + break; + } + } + + if ( maxKKTviolation > CRITICALACCURACY ) + return RET_NO_SOLUTION; + + if ( maxKKTviolation > DESIREDACCURACY ) + return RET_INACCURATE_SOLUTION; + + #endif /* __PERFORM_KKT_TEST__ */ + + return SUCCESSFUL_RETURN; +} + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/SRC/QProblem.ipp b/phonelibs/qpoases/SRC/QProblem.ipp index cec58e291ddeab..e98ada6330fb22 100644 --- a/phonelibs/qpoases/SRC/QProblem.ipp +++ b/phonelibs/qpoases/SRC/QProblem.ipp @@ -1,299 +1,299 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/QProblem.ipp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of inlined member functions of the QProblem class which - * is able to use the newly developed online active set strategy for - * parametric quadratic programming. - */ - - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - -/* - * g e t A - */ -inline returnValue QProblem::getA( real_t* const _A ) const -{ - int i; - - for ( i=0; i= 0 ) && ( number < getNC( ) ) ) - { - for ( int i=0; i= 0 ) && ( number < getNC( ) ) ) - { - value = lbA[number]; - return SUCCESSFUL_RETURN; - } - else - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); -} - - -/* - * g e t U B A - */ -inline returnValue QProblem::getUBA( real_t* const _ubA ) const -{ - int i; - - for ( i=0; i= 0 ) && ( number < getNC( ) ) ) - { - value = ubA[number]; - return SUCCESSFUL_RETURN; - } - else - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); -} - - -/* - * g e t C o n s t r a i n t s - */ -inline returnValue QProblem::getConstraints( Constraints* const _constraints ) const -{ - *_constraints = constraints; - - return SUCCESSFUL_RETURN; -} - - - -/* - * g e t N C - */ -inline int QProblem::getNC( ) const -{ - return constraints.getNC( ); -} - - -/* - * g e t N E C - */ -inline int QProblem::getNEC( ) const -{ - return constraints.getNEC( ); -} - - -/* - * g e t N A C - */ -inline int QProblem::getNAC( ) -{ - return constraints.getNAC( ); -} - - -/* - * g e t N I A C - */ -inline int QProblem::getNIAC( ) -{ - return constraints.getNIAC( ); -} - - - -/***************************************************************************** - * P R O T E C T E D * - *****************************************************************************/ - - -/* - * s e t A - */ -inline returnValue QProblem::setA( const real_t* const A_new ) -{ - int i, j; - int nV = getNV( ); - int nC = getNC( ); - - /* Set constraint matrix AND update member AX. */ - for( j=0; j= 0 ) && ( number < getNC( ) ) ) - { - Ax[number] = 0.0; - - for( i=0; i= 0 ) && ( number < getNC( ) ) ) - { - lbA[number] = value; - return SUCCESSFUL_RETURN; - } - else - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); -} - - -/* - * s e t U B A - */ -inline returnValue QProblem::setUBA( const real_t* const ubA_new ) -{ - int i; - int nC = getNC(); - - for( i=0; i= 0 ) && ( number < getNC( ) ) ) - { - ubA[number] = value; - return SUCCESSFUL_RETURN; - } - else - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); -} - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file SRC/QProblem.ipp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Implementation of inlined member functions of the QProblem class which + * is able to use the newly developed online active set strategy for + * parametric quadratic programming. + */ + + + +/***************************************************************************** + * P U B L I C * + *****************************************************************************/ + +/* + * g e t A + */ +inline returnValue QProblem::getA( real_t* const _A ) const +{ + int i; + + for ( i=0; i= 0 ) && ( number < getNC( ) ) ) + { + for ( int i=0; i= 0 ) && ( number < getNC( ) ) ) + { + value = lbA[number]; + return SUCCESSFUL_RETURN; + } + else + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); +} + + +/* + * g e t U B A + */ +inline returnValue QProblem::getUBA( real_t* const _ubA ) const +{ + int i; + + for ( i=0; i= 0 ) && ( number < getNC( ) ) ) + { + value = ubA[number]; + return SUCCESSFUL_RETURN; + } + else + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); +} + + +/* + * g e t C o n s t r a i n t s + */ +inline returnValue QProblem::getConstraints( Constraints* const _constraints ) const +{ + *_constraints = constraints; + + return SUCCESSFUL_RETURN; +} + + + +/* + * g e t N C + */ +inline int QProblem::getNC( ) const +{ + return constraints.getNC( ); +} + + +/* + * g e t N E C + */ +inline int QProblem::getNEC( ) const +{ + return constraints.getNEC( ); +} + + +/* + * g e t N A C + */ +inline int QProblem::getNAC( ) +{ + return constraints.getNAC( ); +} + + +/* + * g e t N I A C + */ +inline int QProblem::getNIAC( ) +{ + return constraints.getNIAC( ); +} + + + +/***************************************************************************** + * P R O T E C T E D * + *****************************************************************************/ + + +/* + * s e t A + */ +inline returnValue QProblem::setA( const real_t* const A_new ) +{ + int i, j; + int nV = getNV( ); + int nC = getNC( ); + + /* Set constraint matrix AND update member AX. */ + for( j=0; j= 0 ) && ( number < getNC( ) ) ) + { + Ax[number] = 0.0; + + for( i=0; i= 0 ) && ( number < getNC( ) ) ) + { + lbA[number] = value; + return SUCCESSFUL_RETURN; + } + else + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); +} + + +/* + * s e t U B A + */ +inline returnValue QProblem::setUBA( const real_t* const ubA_new ) +{ + int i; + int nC = getNC(); + + for( i=0; i= 0 ) && ( number < getNC( ) ) ) + { + ubA[number] = value; + return SUCCESSFUL_RETURN; + } + else + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); +} + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/SRC/QProblemB.cpp b/phonelibs/qpoases/SRC/QProblemB.cpp index f84daabc025d3f..47ac3536f35cf5 100644 --- a/phonelibs/qpoases/SRC/QProblemB.cpp +++ b/phonelibs/qpoases/SRC/QProblemB.cpp @@ -1,2151 +1,2151 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/QProblemB.cpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of the QProblemB class which is able to use the newly - * developed online active set strategy for parametric quadratic programming. - */ - - -#include - -#include - -void printmatrix(char *name, double *A, int m, int n) { - int i, j; - - printf("%s = [...\n", name); - for (i = 0; i < m; i++) { - for (j = 0; j < n; j++) - printf(" % 9.4f", A[i*n+j]); - printf(",\n"); - } - printf("];\n"); -} - - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - - -/* - * Q P r o b l e m B - */ -QProblemB::QProblemB( ) -{ - /* reset global message handler */ - getGlobalMessageHandler( )->reset( ); - - hasHessian = BT_FALSE; - - bounds.init( 0 ); - - hasCholesky = BT_FALSE; - - tau = 0.0; - - hessianType = HST_POSDEF_NULLSPACE; /* Hessian is assumed to be positive definite by default */ - infeasible = BT_FALSE; - unbounded = BT_FALSE; - - status = QPS_NOTINITIALISED; - - #ifdef PC_DEBUG - printlevel = PL_MEDIUM; - setPrintLevel( PL_MEDIUM ); - #else - printlevel = QPOASES_PRINTLEVEL; - #endif - - count = 0; -} - - -/* - * Q P r o b l e m B - */ -QProblemB::QProblemB( int _nV ) -{ - /* consistency check */ - if ( _nV <= 0 ) - { - _nV = 1; - THROWERROR( RET_INVALID_ARGUMENTS ); - } - - hasHessian = BT_FALSE; - - /* reset global message handler */ - getGlobalMessageHandler( )->reset( ); - - bounds.init( _nV ); - - hasCholesky = BT_FALSE; - - tau = 0.0; - - hessianType = HST_POSDEF_NULLSPACE; /* Hessian is assumed to be positive definite by default */ - infeasible = BT_FALSE; - unbounded = BT_FALSE; - - status = QPS_NOTINITIALISED; - - #ifdef PC_DEBUG - printlevel = PL_MEDIUM; - setPrintLevel( PL_MEDIUM ); - #else - printlevel = QPOASES_PRINTLEVEL; - #endif - - count = 0; -} - - -/* - * Q P r o b l e m B - */ -QProblemB::QProblemB( const QProblemB& rhs ) -{ - int i, j; - - int _nV = rhs.bounds.getNV( ); - - for( i=0; i<_nV; ++i ) - for( j=0; j<_nV; ++j ) - H[i*NVMAX + j] = rhs.H[i*NVMAX + j]; - - hasHessian = rhs.hasHessian; - - for( i=0; i<_nV; ++i ) - g[i] = rhs.g[i]; - - for( i=0; i<_nV; ++i ) - lb[i] = rhs.lb[i]; - - for( i=0; i<_nV; ++i ) - ub[i] = rhs.ub[i]; - - - bounds = rhs.bounds; - - for( i=0; i<_nV; ++i ) - for( j=0; j<_nV; ++j ) - R[i*NVMAX + j] = rhs.R[i*NVMAX + j]; - hasCholesky = rhs.hasCholesky; - - for( i=0; i<_nV; ++i ) - x[i] = rhs.x[i]; - - for( i=0; i<_nV; ++i ) - y[i] = rhs.y[i]; - - tau = rhs.tau; - - hessianType = rhs.hessianType; - infeasible = rhs.infeasible; - unbounded = rhs.unbounded; - - status = rhs.status; - - printlevel = rhs.printlevel; - - count = rhs.count; -} - - -/* - * ~ Q P r o b l e m B - */ -QProblemB::~QProblemB( ) -{ -} - - -/* - * o p e r a t o r = - */ -QProblemB& QProblemB::operator=( const QProblemB& rhs ) -{ - int i, j; - - if ( this != &rhs ) - { - int _nV = rhs.bounds.getNV( ); - - for( i=0; i<_nV; ++i ) - for( j=0; j<_nV; ++j ) - H[i*NVMAX + j] = rhs.H[i*NVMAX + j]; - - hasHessian = rhs.hasHessian; - - for( i=0; i<_nV; ++i ) - g[i] = rhs.g[i]; - - for( i=0; i<_nV; ++i ) - lb[i] = rhs.lb[i]; - - for( i=0; i<_nV; ++i ) - ub[i] = rhs.ub[i]; - - bounds = rhs.bounds; - - for( i=0; i<_nV; ++i ) - for( j=0; j<_nV; ++j ) - R[i*NVMAX + j] = rhs.R[i*NVMAX + j]; - hasCholesky = rhs.hasCholesky; - - - for( i=0; i<_nV; ++i ) - x[i] = rhs.x[i]; - - for( i=0; i<_nV; ++i ) - y[i] = rhs.y[i]; - - tau = rhs.tau; - - hessianType = rhs.hessianType; - infeasible = rhs.infeasible; - unbounded = rhs.unbounded; - - status = rhs.status; - - printlevel = rhs.printlevel; - setPrintLevel( rhs.printlevel ); - - count = rhs.count; - } - - return *this; -} - - -/* - * r e s e t - */ -returnValue QProblemB::reset( ) -{ - int i, j; - int nV = getNV( ); - - /** 0) Reset has Hessian flag. */ - hasHessian = BT_FALSE; - - /* 1) Reset bounds. */ - bounds.init( nV ); - - /* 2) Reset Cholesky decomposition. */ - for( i=0; ithrowInfo( RET_ITERATION_STARTED,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - #endif - } - - /* 1) Setup index arrays. */ - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - if ( bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - /* 2) Initialize shift direction of the gradient and the bounds. */ - returnvalue = hotstart_determineDataShift( FX_idx, - g_new,lb_new,ub_new, - delta_g,delta_lb,delta_ub, - Delta_bB_isZero - ); - if ( returnvalue != SUCCESSFUL_RETURN ) - { - nWSR = l; - THROWERROR( RET_SHIFT_DETERMINATION_FAILED ); - return returnvalue; - } - - /* 3) Determination of step direction of X and Y. */ - returnvalue = hotstart_determineStepDirection( FR_idx,FX_idx, - delta_g,delta_lb,delta_ub, - Delta_bB_isZero, - delta_xFX,delta_xFR,delta_yFX - ); - if ( returnvalue != SUCCESSFUL_RETURN ) - { - nWSR = l; - THROWERROR( RET_STEPDIRECTION_DETERMINATION_FAILED ); - return returnvalue; - } - - - /* 4) Determination of step length TAU. */ - returnvalue = hotstart_determineStepLength( FR_idx,FX_idx, - delta_lb,delta_ub, - delta_xFR,delta_yFX, - BC_idx,BC_status ); - if ( returnvalue != SUCCESSFUL_RETURN ) - { - nWSR = l; - THROWERROR( RET_STEPLENGTH_DETERMINATION_FAILED ); - return returnvalue; - } - - /* 5) Realization of the homotopy step. */ - returnvalue = hotstart_performStep( FR_idx,FX_idx, - delta_g,delta_lb,delta_ub, - delta_xFX,delta_xFR,delta_yFX, - BC_idx,BC_status - ); - - - if ( returnvalue != SUCCESSFUL_RETURN ) - { - nWSR = l; - - /* stop runtime measurement */ - if ( cputime != 0 ) - *cputime = getCPUtime( ) - starttime; - - /* optimal solution found? */ - if ( returnvalue == RET_OPTIMAL_SOLUTION_FOUND ) - { - status = QPS_SOLVED; - - if ( printlevel == PL_HIGH ) - THROWINFO( RET_OPTIMAL_SOLUTION_FOUND ); - - #ifdef PC_DEBUG - if ( printIteration( l,BC_idx,BC_status ) != SUCCESSFUL_RETURN ) - THROWERROR( RET_PRINT_ITERATION_FAILED ); /* do not pass this as return value! */ - #endif - - /* check KKT optimality conditions */ - return checkKKTconditions( ); - } - else - { - /* checks for infeasibility... */ - if ( infeasible == BT_TRUE ) - { - status = QPS_HOMOTOPYQPSOLVED; - return THROWERROR( RET_HOTSTART_STOPPED_INFEASIBILITY ); - } - - /* ...unboundedness... */ - if ( unbounded == BT_TRUE ) /* not necessary since objective function convex! */ - return THROWERROR( RET_HOTSTART_STOPPED_UNBOUNDEDNESS ); - - /* ... and throw unspecific error otherwise */ - THROWERROR( RET_HOMOTOPY_STEP_FAILED ); - return returnvalue; - } - } - - /* 6) Output information of successful QP iteration. */ - status = QPS_HOMOTOPYQPSOLVED; - - #ifdef PC_DEBUG - if ( printIteration( l,BC_idx,BC_status ) != SUCCESSFUL_RETURN ) - THROWERROR( RET_PRINT_ITERATION_FAILED ); /* do not pass this as return value! */ - #endif - } - - - /* stop runtime measurement */ - if ( cputime != 0 ) - *cputime = getCPUtime( ) - starttime; - - - /* if programm gets to here, output information that QP could not be solved - * within the given maximum numbers of working set changes */ - if ( printlevel == PL_HIGH ) - { - #ifdef PC_DEBUG - sprintf( messageString,"(nWSR = %d)",nWSR ); - return getGlobalMessageHandler( )->throwWarning( RET_MAX_NWSR_REACHED,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - #endif - } - - /* Finally check KKT optimality conditions. */ - returnValue returnvalueKKTcheck = checkKKTconditions( ); - - if ( returnvalueKKTcheck != SUCCESSFUL_RETURN ) - return returnvalueKKTcheck; - else - return RET_MAX_NWSR_REACHED; -} - - -/* - * g e t N Z - */ -int QProblemB::getNZ( ) -{ - /* if no constraints are present: nZ=nFR */ - return bounds.getFree( )->getLength( ); -} - - -/* - * g e t O b j V a l - */ -real_t QProblemB::getObjVal( ) const -{ - real_t objVal; - - /* calculated optimal objective function value - * only if current QP has been solved */ - if ( ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || - ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || - ( getStatus( ) == QPS_SOLVED ) ) - { - objVal = getObjVal( x ); - } - else - { - objVal = INFTY; - } - - return objVal; -} - - -/* - * g e t O b j V a l - */ -real_t QProblemB::getObjVal( const real_t* const _x ) const -{ - int i, j; - int nV = getNV( ); - - real_t obj_tmp = 0.0; - - for( i=0; i= PL_MEDIUM ) && ( printlevel != _printlevel ) ) - THROWINFO( RET_PRINTLEVEL_CHANGED ); - #endif - - printlevel = _printlevel; - - /* update message handler preferences */ - switch ( printlevel ) - { - case PL_NONE: - getGlobalMessageHandler( )->setErrorVisibilityStatus( VS_HIDDEN ); - getGlobalMessageHandler( )->setWarningVisibilityStatus( VS_HIDDEN ); - getGlobalMessageHandler( )->setInfoVisibilityStatus( VS_HIDDEN ); - break; - - case PL_LOW: - getGlobalMessageHandler( )->setErrorVisibilityStatus( VS_VISIBLE ); - getGlobalMessageHandler( )->setWarningVisibilityStatus( VS_HIDDEN ); - getGlobalMessageHandler( )->setInfoVisibilityStatus( VS_HIDDEN ); - break; - - default: /* PL_MEDIUM, PL_HIGH */ - getGlobalMessageHandler( )->setErrorVisibilityStatus( VS_VISIBLE ); - getGlobalMessageHandler( )->setWarningVisibilityStatus( VS_VISIBLE ); - getGlobalMessageHandler( )->setInfoVisibilityStatus( VS_VISIBLE ); - break; - } - - return SUCCESSFUL_RETURN; -} - - - -/***************************************************************************** - * P R O T E C T E D * - *****************************************************************************/ - -/* - * c h e c k F o r I d e n t i t y H e s s i a n - */ -returnValue QProblemB::checkForIdentityHessian( ) -{ - int i, j; - int nV = getNV( ); - - /* nothing to do as status flag remains unaltered - * if Hessian differs from identity matrix */ - if ( hessianType == HST_IDENTITY ) - return SUCCESSFUL_RETURN; - - /* 1) If Hessian differs from identity matrix, - * return without changing the internal HessianType. */ - for ( i=0; i EPS ) - return SUCCESSFUL_RETURN; - - for ( i=0; i EPS ) || ( getAbs( H[j*NVMAX + i] ) > EPS ) ) - return SUCCESSFUL_RETURN; - } - - /* 2) If this point is reached, Hessian equals the idetity matrix. */ - hessianType = HST_IDENTITY; - - return SUCCESSFUL_RETURN; -} - - -/* - * s e t u p S u b j e c t T o T y p e - */ -returnValue QProblemB::setupSubjectToType( ) -{ - int i; - int nV = getNV( ); - - - /* 1) Check if lower bounds are present. */ - bounds.setNoLower( BT_TRUE ); - for( i=0; i -INFTY ) - { - bounds.setNoLower( BT_FALSE ); - break; - } - - /* 2) Check if upper bounds are present. */ - bounds.setNoUpper( BT_TRUE ); - for( i=0; i INFTY - BOUNDTOL ) ) - { - bounds.setType( i,ST_UNBOUNDED ); - ++nUV; - } - else - { - if ( lb[i] > ub[i] - BOUNDTOL ) - { - bounds.setType( i,ST_EQUALITY ); - ++nFV; - } - else - { - bounds.setType( i,ST_BOUNDED ); - } - } - - /* 4) Set dimensions of bounds structure. */ - bounds.setNFV( nFV ); - bounds.setNUV( nUV ); - bounds.setNBV( nV - nFV - nUV ); - - return SUCCESSFUL_RETURN; -} - - -/* - * c h o l e s k y D e c o m p o s i t i o n - */ -returnValue QProblemB::setupCholeskyDecomposition( ) -{ - int i, j, k, ii, jj; - int nV = getNV( ); - int nFR = getNFR( ); - - /* If Hessian flag is false, it means that H & R already contain Cholesky - * factorization -- provided from outside. */ - if (hasHessian == BT_FALSE) - return SUCCESSFUL_RETURN; - - /* 1) Initialises R with all zeros. */ - for( i=0; i 0 ) - { - int FR_idx[NVMAX]; - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_INDEXLIST_CORRUPTED ); - - /* R'*R = H */ - real_t sum; - real_t inv; - - for( i=0; i=0; --k ) - sum -= R[k*NVMAX + i] * R[k*NVMAX + i]; - - if ( sum > 0.0 ) - { - R[i*NVMAX + i] = sqrt( sum ); - inv = 1.0 / R[i*NVMAX + i]; - } - else - { - hessianType = HST_SEMIDEF; - return THROWERROR( RET_HESSIAN_NOT_SPD ); - } - - /* j > i */ - for( j=(i+1); j=0; --k ) - sum -= R[k*NVMAX + i] * R[k*NVMAX + j]; - - R[i*NVMAX + j] = sum * inv; - } - } - } - } - - return SUCCESSFUL_RETURN; -} - - -/* - * s o l v e I n i t i a l Q P - */ -returnValue QProblemB::solveInitialQP( const real_t* const xOpt, const real_t* const yOpt, - const Bounds* const guessedBounds, - int& nWSR, real_t* const cputime - ) -{ - int i, nFR; - int nV = getNV( ); - - - /* start runtime measurement */ - real_t starttime = 0.0; - if ( cputime != 0 ) - starttime = getCPUtime( ); - - - status = QPS_NOTINITIALISED; - - /* I) ANALYSE QP DATA: */ - /* 1) Check if Hessian happens to be the identity matrix. */ - if ( checkForIdentityHessian( ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_INIT_FAILED ); - - /* 2) Setup type of bounds (i.e. unbounded, implicitly fixed etc.). */ - if ( setupSubjectToType( ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_INIT_FAILED ); - - status = QPS_PREPARINGAUXILIARYQP; - - - /* II) SETUP AUXILIARY QP WITH GIVEN OPTIMAL SOLUTION: */ - /* 1) Setup bounds data structure. */ - if ( bounds.setupAllFree( ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_INIT_FAILED ); - - /* 2) Setup optimal primal/dual solution for auxiliary QP. */ - if ( setupAuxiliaryQPsolution( xOpt,yOpt ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_INIT_FAILED ); - - /* 3) Obtain linear independent working set for auxiliary QP. */ - - static Bounds auxiliaryBounds; - - auxiliaryBounds.init( nV ); - - if ( obtainAuxiliaryWorkingSet( xOpt,yOpt,guessedBounds, &auxiliaryBounds ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_INIT_FAILED ); - - /* 4) Setup working set of auxiliary QP and setup cholesky decomposition. */ - if ( setupAuxiliaryWorkingSet( &auxiliaryBounds,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_INIT_FAILED ); - - nFR = getNFR(); - /* At the moment we can only provide a Cholesky of the Hessian if - * the solver is cold-started. */ - if (hasCholesky == BT_FALSE || nFR != nV) - if (setupCholeskyDecomposition() != SUCCESSFUL_RETURN) - return THROWERROR( RET_INIT_FAILED_CHOLESKY ); - - /* 5) Store original QP formulation... */ - real_t g_original[NVMAX]; - real_t lb_original[NVMAX]; - real_t ub_original[NVMAX]; - - for( i=0; isetupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - else - { - if ( auxiliaryBounds->setupBound( i,guessedBounds->getStatus( i ) ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - } - } - else /* No initial working set specified. */ - { - if ( ( xOpt != 0 ) && ( yOpt == 0 ) ) - { - /* Obtain initial working set by "clipping". */ - for( i=0; isetupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - continue; - } - - if ( xOpt[i] >= ub[i] - BOUNDTOL ) - { - if ( auxiliaryBounds->setupBound( i,ST_UPPER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - continue; - } - - /* Moreover, add all implictly fixed variables if specified. */ - if ( bounds.getType( i ) == ST_EQUALITY ) - { - if ( auxiliaryBounds->setupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - else - { - if ( auxiliaryBounds->setupBound( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - } - } - - if ( ( xOpt == 0 ) && ( yOpt != 0 ) ) - { - /* Obtain initial working set in accordance to sign of dual solution vector. */ - for( i=0; i ZERO ) - { - if ( auxiliaryBounds->setupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - continue; - } - - if ( yOpt[i] < -ZERO ) - { - if ( auxiliaryBounds->setupBound( i,ST_UPPER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - continue; - } - - /* Moreover, add all implictly fixed variables if specified. */ - if ( bounds.getType( i ) == ST_EQUALITY ) - { - if ( auxiliaryBounds->setupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - else - { - if ( auxiliaryBounds->setupBound( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - } - } - - /* If xOpt and yOpt are null pointer and no initial working is specified, - * start with empty working set (or implicitly fixed bounds only) - * for auxiliary QP. */ - if ( ( xOpt == 0 ) && ( yOpt == 0 ) ) - { - for( i=0; isetupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - else - { - if ( auxiliaryBounds->setupBound( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - } - } - } - - return SUCCESSFUL_RETURN; -} - - -/* - * s e t u p A u x i l i a r y W o r k i n g S e t - */ -returnValue QProblemB::setupAuxiliaryWorkingSet( const Bounds* const auxiliaryBounds, - BooleanType setupAfresh - ) -{ - int i; - int nV = getNV( ); - - /* consistency checks */ - if ( auxiliaryBounds != 0 ) - { - for( i=0; igetStatus( i ) == ST_UNDEFINED ) ) - return THROWERROR( RET_UNKNOWN_BUG ); - } - else - { - return THROWERROR( RET_INVALID_ARGUMENTS ); - } - - - /* I) SETUP CHOLESKY FLAG: - * Cholesky decomposition shall only be updated if working set - * shall be updated (i.e. NOT setup afresh!) */ - BooleanType updateCholesky; - if ( setupAfresh == BT_TRUE ) - updateCholesky = BT_FALSE; - else - updateCholesky = BT_TRUE; - - - /* II) REMOVE FORMERLY ACTIVE BOUNDS (IF NECESSARY): */ - if ( setupAfresh == BT_FALSE ) - { - /* Remove all active bounds that shall be inactive AND - * all active bounds that are active at the wrong bound. */ - for( i=0; igetStatus( i ) != ST_LOWER ) ) - if ( removeBound( i,updateCholesky ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); - - if ( ( bounds.getStatus( i ) == ST_UPPER ) && ( auxiliaryBounds->getStatus( i ) != ST_UPPER ) ) - if ( removeBound( i,updateCholesky ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); - } - } - - - /* III) ADD NEWLY ACTIVE BOUNDS: */ - /* Add all inactive bounds that shall be active AND - * all formerly active bounds that have been active at the wrong bound. */ - for( i=0; igetStatus( i ) != ST_INACTIVE ) ) - { - if ( addBound( i,auxiliaryBounds->getStatus( i ),updateCholesky ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); - } - } - - return SUCCESSFUL_RETURN; -} - - -/* - * s e t u p A u x i l i a r y Q P s o l u t i o n - */ -returnValue QProblemB::setupAuxiliaryQPsolution( const real_t* const xOpt, const real_t* const yOpt - ) -{ - int i; - int nV = getNV( ); - - - /* Setup primal/dual solution vectors for auxiliary initial QP: - * if a null pointer is passed, a zero vector is assigned; - * old solution vector is kept if pointer to internal solution vector is passed. */ - if ( xOpt != 0 ) - { - if ( xOpt != x ) - for( i=0; igetIndex( number ); - - real_t c, s; - - /* 2) Use row-wise Givens rotations to restore upper triangular form of R. */ - for( i=number_idx+1; ith column and ... */ - for( i=0; igetNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVEBOUND_FAILED ); - - /* 1) Calculate new column of cholesky decomposition. */ - real_t rhs[NVMAX]; - real_t r[NVMAX]; - real_t r0 = H[number*NVMAX + number]; - - for( i=0; i 0.0 ) - R[nFR*NVMAX + nFR] = sqrt( r0 ); - else - { - hessianType = HST_SEMIDEF; - return THROWERROR( RET_HESSIAN_NOT_SPD ); - } - - - return SUCCESSFUL_RETURN; -} - - -/* - * b a c k s o l v e R (CODE DUPLICATED IN QProblem CLASS!!!) - */ -returnValue QProblemB::backsolveR( const real_t* const b, BooleanType transposed, - real_t* const a - ) -{ - /* Call standard backsolve procedure (i.e. removingBound == BT_FALSE). */ - return backsolveR( b,transposed,BT_FALSE,a ); -} - - -/* - * b a c k s o l v e R (CODE DUPLICATED IN QProblem CLASS!!!) - */ -returnValue QProblemB::backsolveR( const real_t* const b, BooleanType transposed, - BooleanType removingBound, - real_t* const a - ) -{ - int i, j; - int nR = getNZ( ); - - real_t sum; - - /* if backsolve is called while removing a bound, reduce nZ by one. */ - if ( removingBound == BT_TRUE ) - --nR; - - /* nothing to do */ - if ( nR <= 0 ) - return SUCCESSFUL_RETURN; - - - /* Solve Ra = b, where R might be transposed. */ - if ( transposed == BT_FALSE ) - { - /* solve Ra = b */ - for( i=(nR-1); i>=0; --i ) - { - sum = b[i]; - for( j=(i+1); j ZERO ) - a[i] = sum / R[i*NVMAX + i]; - else - return THROWERROR( RET_DIV_BY_ZERO ); - } - } - else - { - /* solve R^T*a = b */ - for( i=0; i ZERO ) - a[i] = sum / R[i*NVMAX + i]; - else - return THROWERROR( RET_DIV_BY_ZERO ); - } - } - - return SUCCESSFUL_RETURN; -} - - -/* - * h o t s t a r t _ d e t e r m i n e D a t a S h i f t - */ -returnValue QProblemB::hotstart_determineDataShift( const int* const FX_idx, - const real_t* const g_new, const real_t* const lb_new, const real_t* const ub_new, - real_t* const delta_g, real_t* const delta_lb, real_t* const delta_ub, - BooleanType& Delta_bB_isZero - ) -{ - int i, ii; - int nV = getNV( ); - int nFX = getNFX( ); - - - /* 1) Calculate shift directions. */ - for( i=0; i EPS ) || ( getAbs( delta_ub[ii] ) > EPS ) ) - { - Delta_bB_isZero = BT_FALSE; - break; - } - } - - return SUCCESSFUL_RETURN; -} - - -/* - * a r e B o u n d s C o n s i s t e n t - */ -BooleanType QProblemB::areBoundsConsistent( const real_t* const delta_lb, const real_t* const delta_ub - ) const -{ - int i; - - /* Check if delta_lb[i] is greater than delta_ub[i] - * for a component i whose bounds are already (numerically) equal. */ - for( i=0; i ub[i] - BOUNDTOL ) && ( delta_lb[i] > delta_ub[i] + EPS ) ) - return BT_FALSE; - - return BT_TRUE; -} - - -/* - * s e t u p Q P d a t a - */ -returnValue QProblemB::setupQPdata( const real_t* const _H, const real_t* const _R, const real_t* const _g, - const real_t* const _lb, const real_t* const _ub - ) -{ - int i, j; - int nV = getNV( ); - - /* 1) Setup Hessian matrix and it's Cholesky factorization. */ - if (_H != 0) - { - for( i=0; i 0 ) - { - for( i=0; i 0 ) - { - /* auxiliary variables */ - real_t delta_xFRz_TMP[NVMAX]; - real_t delta_xFRz_RHS[NVMAX]; - - /* Determine delta_xFRz. */ - if ( Delta_bB_isZero == BT_FALSE ) - { - for( i=0; i 0 ) - { - for( i=0; i= 0.0 ) ) - { - tau_tmp = y[ii] / ( -delta_yFX[i] ); - if ( tau_tmp < tau_new ) - { - if ( tau_tmp >= 0.0 ) - { - tau_new = tau_tmp; - BC_idx = ii; - BC_status = ST_INACTIVE; - } - } - } - } - else - { - /* 2) Active upper bounds. */ - if ( ( delta_yFX[i] > ZERO ) && ( y[ii] <= 0.0 ) ) - { - tau_tmp = y[ii] / ( -delta_yFX[i] ); - if ( tau_tmp < tau_new ) - { - if ( tau_tmp >= 0.0 ) - { - tau_new = tau_tmp; - BC_idx = ii; - BC_status = ST_INACTIVE; - } - } - } - } - } - } - - - /* II) DETERMINE MAXIMUM PRIMAL STEPLENGTH, i.e. ensure that - * inactive bounds remain valid (ignoring unbounded variables). */ - /* 1) Inactive lower bounds. */ - if ( bounds.isNoLower( ) == BT_FALSE ) - { - for( i=0; i delta_xFR[i] ) - { - if ( x[ii] > lb[ii] ) - tau_tmp = ( x[ii] - lb[ii] ) / ( delta_lb[ii] - delta_xFR[i] ); - else - tau_tmp = 0.0; - - if ( tau_tmp < tau_new ) - { - if ( tau_tmp >= 0.0 ) - { - tau_new = tau_tmp; - BC_idx = ii; - BC_status = ST_LOWER; - } - } - } - } - } - } - - /* 2) Inactive upper bounds. */ - if ( bounds.isNoUpper( ) == BT_FALSE ) - { - for( i=0; i= 0.0 ) - { - tau_new = tau_tmp; - BC_idx = ii; - BC_status = ST_UPPER; - } - } - } - } - } - } - - - /* III) SET MAXIMUM HOMOTOPY STEPLENGTH */ - tau = tau_new; - - if ( printlevel == PL_HIGH ) - { - #ifdef PC_DEBUG - char messageString[80]; - - if ( BC_status == ST_UNDEFINED ) - sprintf( messageString,"Stepsize is %.6e!",tau ); - else - sprintf( messageString,"Stepsize is %.6e! (BC_idx = %d, BC_status = %d)",tau,BC_idx,BC_status ); - - getGlobalMessageHandler( )->throwInfo( RET_STEPSIZE_NONPOSITIVE,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - #endif - } - - return SUCCESSFUL_RETURN; -} - - -/* - * h o t s t a r t _ p e r f o r m S t e p - */ -returnValue QProblemB::hotstart_performStep( const int* const FR_idx, const int* const FX_idx, - const real_t* const delta_g, const real_t* const delta_lb, const real_t* const delta_ub, - const real_t* const delta_xFX, const real_t* const delta_xFR, - const real_t* const delta_yFX, - int BC_idx, SubjectToStatus BC_status - ) -{ - int i, ii; - int nV = getNV( ); - int nFR = getNFR( ); - int nFX = getNFX( ); - - - /* I) CHECK BOUNDS' CONSISTENCY */ - if ( areBoundsConsistent( delta_lb,delta_ub ) == BT_FALSE ) - { - infeasible = BT_TRUE; - tau = 0.0; - - return THROWERROR( RET_QP_INFEASIBLE ); - } - - - /* II) GO TO ACTIVE SET CHANGE */ - if ( tau > ZERO ) - { - /* 1) Perform step in primal und dual space. */ - for( i=0; ithrowWarning( RET_STEPSIZE,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - #endif - } - - - /* setup output preferences */ - #ifdef PC_DEBUG - char messageString[80]; - VisibilityStatus visibilityStatus; - - if ( printlevel == PL_HIGH ) - visibilityStatus = VS_VISIBLE; - else - visibilityStatus = VS_HIDDEN; - #endif - - - /* III) UPDATE ACTIVE SET */ - switch ( BC_status ) - { - /* Optimal solution found as no working set change detected. */ - case ST_UNDEFINED: - return RET_OPTIMAL_SOLUTION_FOUND; - - - /* Remove one variable from active set. */ - case ST_INACTIVE: - #ifdef PC_DEBUG - sprintf( messageString,"bound no. %d.", BC_idx ); - getGlobalMessageHandler( )->throwInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); - #endif - - if ( removeBound( BC_idx,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); - - y[BC_idx] = 0.0; - break; - - - /* Add one variable to active set. */ - default: - #ifdef PC_DEBUG - if ( BC_status == ST_LOWER ) - sprintf( messageString,"lower bound no. %d.", BC_idx ); - else - sprintf( messageString,"upper bound no. %d.", BC_idx ); - getGlobalMessageHandler( )->throwInfo( RET_ADD_TO_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); - #endif - - if ( addBound( BC_idx,BC_status,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ADD_TO_ACTIVESET_FAILED ); - break; - } - - return SUCCESSFUL_RETURN; -} - - -#ifdef PC_DEBUG /* Define print functions only for debugging! */ - -/* - * p r i n t I t e r a t i o n - */ -returnValue QProblemB::printIteration( int iteration, - int BC_idx, SubjectToStatus BC_status - ) -{ - char myPrintfString[160]; - - /* consistency check */ - if ( iteration < 0 ) - return THROWERROR( RET_INVALID_ARGUMENTS ); - - /* nothing to do */ - if ( printlevel != PL_MEDIUM ) - return SUCCESSFUL_RETURN; - - - /* 1) Print header at first iteration. */ - if ( iteration == 0 ) - { - sprintf( myPrintfString,"\n############## qpOASES -- QP NO.%4.1d ###############\n", count ); - myPrintf( myPrintfString ); - - sprintf( myPrintfString," Iter | StepLength | Info | nFX \n" ); - myPrintf( myPrintfString ); - } - - /* 2) Print iteration line. */ - if ( BC_status == ST_UNDEFINED ) - { - sprintf( myPrintfString," %4.1d | %1.5e | QP SOLVED | %4.1d \n", iteration,tau,getNFX( ) ); - myPrintf( myPrintfString ); - } - else - { - char info[8]; - - if ( BC_status == ST_INACTIVE ) - sprintf( info,"REM BND" ); - else - sprintf( info,"ADD BND" ); - - sprintf( myPrintfString," %4.1d | %1.5e | %s%4.1d | %4.1d \n", iteration,tau,info,BC_idx,getNFX( ) ); - myPrintf( myPrintfString ); - } - - return SUCCESSFUL_RETURN; -} - -#endif /* PC_DEBUG */ - - - -/* - * c h e c k K K T c o n d i t i o n s - */ -returnValue QProblemB::checkKKTconditions( ) -{ - #ifdef __PERFORM_KKT_TEST__ - - int i, j; - int nV = getNV( ); - - real_t tmp; - real_t maxKKTviolation = 0.0; - - - /* 1) Check for Hx + g - y*A' = 0 (here: A = Id). */ - for( i=0; i maxKKTviolation ) - maxKKTviolation = getAbs( tmp ); - } - - /* 2) Check for lb <= x <= ub. */ - for( i=0; i maxKKTviolation ) - maxKKTviolation = lb[i] - x[i]; - - if ( x[i] - ub[i] > maxKKTviolation ) - maxKKTviolation = x[i] - ub[i]; - } - - /* 3) Check for correct sign of y and for complementary slackness. */ - for( i=0; i maxKKTviolation ) - maxKKTviolation = -y[i]; - if ( getAbs( ( x[i] - lb[i] ) * y[i] ) > maxKKTviolation ) - maxKKTviolation = getAbs( ( x[i] - lb[i] ) * y[i] ); - break; - - case ST_UPPER: - if ( y[i] > maxKKTviolation ) - maxKKTviolation = y[i]; - if ( getAbs( ( ub[i] - x[i] ) * y[i] ) > maxKKTviolation ) - maxKKTviolation = getAbs( ( ub[i] - x[i] ) * y[i] ); - break; - - default: /* inactive */ - if ( getAbs( y[i] ) > maxKKTviolation ) - maxKKTviolation = getAbs( y[i] ); - break; - } - } - - if ( maxKKTviolation > CRITICALACCURACY ) - return RET_NO_SOLUTION; - - if ( maxKKTviolation > DESIREDACCURACY ) - return RET_INACCURATE_SOLUTION; - - #endif /* __PERFORM_KKT_TEST__ */ - - return SUCCESSFUL_RETURN; -} - - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file SRC/QProblemB.cpp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Implementation of the QProblemB class which is able to use the newly + * developed online active set strategy for parametric quadratic programming. + */ + + +#include + +#include + +void printmatrix(char *name, double *A, int m, int n) { + int i, j; + + printf("%s = [...\n", name); + for (i = 0; i < m; i++) { + for (j = 0; j < n; j++) + printf(" % 9.4f", A[i*n+j]); + printf(",\n"); + } + printf("];\n"); +} + + + +/***************************************************************************** + * P U B L I C * + *****************************************************************************/ + + +/* + * Q P r o b l e m B + */ +QProblemB::QProblemB( ) +{ + /* reset global message handler */ + getGlobalMessageHandler( )->reset( ); + + hasHessian = BT_FALSE; + + bounds.init( 0 ); + + hasCholesky = BT_FALSE; + + tau = 0.0; + + hessianType = HST_POSDEF_NULLSPACE; /* Hessian is assumed to be positive definite by default */ + infeasible = BT_FALSE; + unbounded = BT_FALSE; + + status = QPS_NOTINITIALISED; + + #ifdef PC_DEBUG + printlevel = PL_MEDIUM; + setPrintLevel( PL_MEDIUM ); + #else + printlevel = QPOASES_PRINTLEVEL; + #endif + + count = 0; +} + + +/* + * Q P r o b l e m B + */ +QProblemB::QProblemB( int _nV ) +{ + /* consistency check */ + if ( _nV <= 0 ) + { + _nV = 1; + THROWERROR( RET_INVALID_ARGUMENTS ); + } + + hasHessian = BT_FALSE; + + /* reset global message handler */ + getGlobalMessageHandler( )->reset( ); + + bounds.init( _nV ); + + hasCholesky = BT_FALSE; + + tau = 0.0; + + hessianType = HST_POSDEF_NULLSPACE; /* Hessian is assumed to be positive definite by default */ + infeasible = BT_FALSE; + unbounded = BT_FALSE; + + status = QPS_NOTINITIALISED; + + #ifdef PC_DEBUG + printlevel = PL_MEDIUM; + setPrintLevel( PL_MEDIUM ); + #else + printlevel = QPOASES_PRINTLEVEL; + #endif + + count = 0; +} + + +/* + * Q P r o b l e m B + */ +QProblemB::QProblemB( const QProblemB& rhs ) +{ + int i, j; + + int _nV = rhs.bounds.getNV( ); + + for( i=0; i<_nV; ++i ) + for( j=0; j<_nV; ++j ) + H[i*NVMAX + j] = rhs.H[i*NVMAX + j]; + + hasHessian = rhs.hasHessian; + + for( i=0; i<_nV; ++i ) + g[i] = rhs.g[i]; + + for( i=0; i<_nV; ++i ) + lb[i] = rhs.lb[i]; + + for( i=0; i<_nV; ++i ) + ub[i] = rhs.ub[i]; + + + bounds = rhs.bounds; + + for( i=0; i<_nV; ++i ) + for( j=0; j<_nV; ++j ) + R[i*NVMAX + j] = rhs.R[i*NVMAX + j]; + hasCholesky = rhs.hasCholesky; + + for( i=0; i<_nV; ++i ) + x[i] = rhs.x[i]; + + for( i=0; i<_nV; ++i ) + y[i] = rhs.y[i]; + + tau = rhs.tau; + + hessianType = rhs.hessianType; + infeasible = rhs.infeasible; + unbounded = rhs.unbounded; + + status = rhs.status; + + printlevel = rhs.printlevel; + + count = rhs.count; +} + + +/* + * ~ Q P r o b l e m B + */ +QProblemB::~QProblemB( ) +{ +} + + +/* + * o p e r a t o r = + */ +QProblemB& QProblemB::operator=( const QProblemB& rhs ) +{ + int i, j; + + if ( this != &rhs ) + { + int _nV = rhs.bounds.getNV( ); + + for( i=0; i<_nV; ++i ) + for( j=0; j<_nV; ++j ) + H[i*NVMAX + j] = rhs.H[i*NVMAX + j]; + + hasHessian = rhs.hasHessian; + + for( i=0; i<_nV; ++i ) + g[i] = rhs.g[i]; + + for( i=0; i<_nV; ++i ) + lb[i] = rhs.lb[i]; + + for( i=0; i<_nV; ++i ) + ub[i] = rhs.ub[i]; + + bounds = rhs.bounds; + + for( i=0; i<_nV; ++i ) + for( j=0; j<_nV; ++j ) + R[i*NVMAX + j] = rhs.R[i*NVMAX + j]; + hasCholesky = rhs.hasCholesky; + + + for( i=0; i<_nV; ++i ) + x[i] = rhs.x[i]; + + for( i=0; i<_nV; ++i ) + y[i] = rhs.y[i]; + + tau = rhs.tau; + + hessianType = rhs.hessianType; + infeasible = rhs.infeasible; + unbounded = rhs.unbounded; + + status = rhs.status; + + printlevel = rhs.printlevel; + setPrintLevel( rhs.printlevel ); + + count = rhs.count; + } + + return *this; +} + + +/* + * r e s e t + */ +returnValue QProblemB::reset( ) +{ + int i, j; + int nV = getNV( ); + + /** 0) Reset has Hessian flag. */ + hasHessian = BT_FALSE; + + /* 1) Reset bounds. */ + bounds.init( nV ); + + /* 2) Reset Cholesky decomposition. */ + for( i=0; ithrowInfo( RET_ITERATION_STARTED,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); + #endif + } + + /* 1) Setup index arrays. */ + if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_HOTSTART_FAILED ); + + if ( bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_HOTSTART_FAILED ); + + /* 2) Initialize shift direction of the gradient and the bounds. */ + returnvalue = hotstart_determineDataShift( FX_idx, + g_new,lb_new,ub_new, + delta_g,delta_lb,delta_ub, + Delta_bB_isZero + ); + if ( returnvalue != SUCCESSFUL_RETURN ) + { + nWSR = l; + THROWERROR( RET_SHIFT_DETERMINATION_FAILED ); + return returnvalue; + } + + /* 3) Determination of step direction of X and Y. */ + returnvalue = hotstart_determineStepDirection( FR_idx,FX_idx, + delta_g,delta_lb,delta_ub, + Delta_bB_isZero, + delta_xFX,delta_xFR,delta_yFX + ); + if ( returnvalue != SUCCESSFUL_RETURN ) + { + nWSR = l; + THROWERROR( RET_STEPDIRECTION_DETERMINATION_FAILED ); + return returnvalue; + } + + + /* 4) Determination of step length TAU. */ + returnvalue = hotstart_determineStepLength( FR_idx,FX_idx, + delta_lb,delta_ub, + delta_xFR,delta_yFX, + BC_idx,BC_status ); + if ( returnvalue != SUCCESSFUL_RETURN ) + { + nWSR = l; + THROWERROR( RET_STEPLENGTH_DETERMINATION_FAILED ); + return returnvalue; + } + + /* 5) Realization of the homotopy step. */ + returnvalue = hotstart_performStep( FR_idx,FX_idx, + delta_g,delta_lb,delta_ub, + delta_xFX,delta_xFR,delta_yFX, + BC_idx,BC_status + ); + + + if ( returnvalue != SUCCESSFUL_RETURN ) + { + nWSR = l; + + /* stop runtime measurement */ + if ( cputime != 0 ) + *cputime = getCPUtime( ) - starttime; + + /* optimal solution found? */ + if ( returnvalue == RET_OPTIMAL_SOLUTION_FOUND ) + { + status = QPS_SOLVED; + + if ( printlevel == PL_HIGH ) + THROWINFO( RET_OPTIMAL_SOLUTION_FOUND ); + + #ifdef PC_DEBUG + if ( printIteration( l,BC_idx,BC_status ) != SUCCESSFUL_RETURN ) + THROWERROR( RET_PRINT_ITERATION_FAILED ); /* do not pass this as return value! */ + #endif + + /* check KKT optimality conditions */ + return checkKKTconditions( ); + } + else + { + /* checks for infeasibility... */ + if ( infeasible == BT_TRUE ) + { + status = QPS_HOMOTOPYQPSOLVED; + return THROWERROR( RET_HOTSTART_STOPPED_INFEASIBILITY ); + } + + /* ...unboundedness... */ + if ( unbounded == BT_TRUE ) /* not necessary since objective function convex! */ + return THROWERROR( RET_HOTSTART_STOPPED_UNBOUNDEDNESS ); + + /* ... and throw unspecific error otherwise */ + THROWERROR( RET_HOMOTOPY_STEP_FAILED ); + return returnvalue; + } + } + + /* 6) Output information of successful QP iteration. */ + status = QPS_HOMOTOPYQPSOLVED; + + #ifdef PC_DEBUG + if ( printIteration( l,BC_idx,BC_status ) != SUCCESSFUL_RETURN ) + THROWERROR( RET_PRINT_ITERATION_FAILED ); /* do not pass this as return value! */ + #endif + } + + + /* stop runtime measurement */ + if ( cputime != 0 ) + *cputime = getCPUtime( ) - starttime; + + + /* if programm gets to here, output information that QP could not be solved + * within the given maximum numbers of working set changes */ + if ( printlevel == PL_HIGH ) + { + #ifdef PC_DEBUG + sprintf( messageString,"(nWSR = %d)",nWSR ); + return getGlobalMessageHandler( )->throwWarning( RET_MAX_NWSR_REACHED,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); + #endif + } + + /* Finally check KKT optimality conditions. */ + returnValue returnvalueKKTcheck = checkKKTconditions( ); + + if ( returnvalueKKTcheck != SUCCESSFUL_RETURN ) + return returnvalueKKTcheck; + else + return RET_MAX_NWSR_REACHED; +} + + +/* + * g e t N Z + */ +int QProblemB::getNZ( ) +{ + /* if no constraints are present: nZ=nFR */ + return bounds.getFree( )->getLength( ); +} + + +/* + * g e t O b j V a l + */ +real_t QProblemB::getObjVal( ) const +{ + real_t objVal; + + /* calculated optimal objective function value + * only if current QP has been solved */ + if ( ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || + ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || + ( getStatus( ) == QPS_SOLVED ) ) + { + objVal = getObjVal( x ); + } + else + { + objVal = INFTY; + } + + return objVal; +} + + +/* + * g e t O b j V a l + */ +real_t QProblemB::getObjVal( const real_t* const _x ) const +{ + int i, j; + int nV = getNV( ); + + real_t obj_tmp = 0.0; + + for( i=0; i= PL_MEDIUM ) && ( printlevel != _printlevel ) ) + THROWINFO( RET_PRINTLEVEL_CHANGED ); + #endif + + printlevel = _printlevel; + + /* update message handler preferences */ + switch ( printlevel ) + { + case PL_NONE: + getGlobalMessageHandler( )->setErrorVisibilityStatus( VS_HIDDEN ); + getGlobalMessageHandler( )->setWarningVisibilityStatus( VS_HIDDEN ); + getGlobalMessageHandler( )->setInfoVisibilityStatus( VS_HIDDEN ); + break; + + case PL_LOW: + getGlobalMessageHandler( )->setErrorVisibilityStatus( VS_VISIBLE ); + getGlobalMessageHandler( )->setWarningVisibilityStatus( VS_HIDDEN ); + getGlobalMessageHandler( )->setInfoVisibilityStatus( VS_HIDDEN ); + break; + + default: /* PL_MEDIUM, PL_HIGH */ + getGlobalMessageHandler( )->setErrorVisibilityStatus( VS_VISIBLE ); + getGlobalMessageHandler( )->setWarningVisibilityStatus( VS_VISIBLE ); + getGlobalMessageHandler( )->setInfoVisibilityStatus( VS_VISIBLE ); + break; + } + + return SUCCESSFUL_RETURN; +} + + + +/***************************************************************************** + * P R O T E C T E D * + *****************************************************************************/ + +/* + * c h e c k F o r I d e n t i t y H e s s i a n + */ +returnValue QProblemB::checkForIdentityHessian( ) +{ + int i, j; + int nV = getNV( ); + + /* nothing to do as status flag remains unaltered + * if Hessian differs from identity matrix */ + if ( hessianType == HST_IDENTITY ) + return SUCCESSFUL_RETURN; + + /* 1) If Hessian differs from identity matrix, + * return without changing the internal HessianType. */ + for ( i=0; i EPS ) + return SUCCESSFUL_RETURN; + + for ( i=0; i EPS ) || ( getAbs( H[j*NVMAX + i] ) > EPS ) ) + return SUCCESSFUL_RETURN; + } + + /* 2) If this point is reached, Hessian equals the idetity matrix. */ + hessianType = HST_IDENTITY; + + return SUCCESSFUL_RETURN; +} + + +/* + * s e t u p S u b j e c t T o T y p e + */ +returnValue QProblemB::setupSubjectToType( ) +{ + int i; + int nV = getNV( ); + + + /* 1) Check if lower bounds are present. */ + bounds.setNoLower( BT_TRUE ); + for( i=0; i -INFTY ) + { + bounds.setNoLower( BT_FALSE ); + break; + } + + /* 2) Check if upper bounds are present. */ + bounds.setNoUpper( BT_TRUE ); + for( i=0; i INFTY - BOUNDTOL ) ) + { + bounds.setType( i,ST_UNBOUNDED ); + ++nUV; + } + else + { + if ( lb[i] > ub[i] - BOUNDTOL ) + { + bounds.setType( i,ST_EQUALITY ); + ++nFV; + } + else + { + bounds.setType( i,ST_BOUNDED ); + } + } + + /* 4) Set dimensions of bounds structure. */ + bounds.setNFV( nFV ); + bounds.setNUV( nUV ); + bounds.setNBV( nV - nFV - nUV ); + + return SUCCESSFUL_RETURN; +} + + +/* + * c h o l e s k y D e c o m p o s i t i o n + */ +returnValue QProblemB::setupCholeskyDecomposition( ) +{ + int i, j, k, ii, jj; + int nV = getNV( ); + int nFR = getNFR( ); + + /* If Hessian flag is false, it means that H & R already contain Cholesky + * factorization -- provided from outside. */ + if (hasHessian == BT_FALSE) + return SUCCESSFUL_RETURN; + + /* 1) Initialises R with all zeros. */ + for( i=0; i 0 ) + { + int FR_idx[NVMAX]; + if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_INDEXLIST_CORRUPTED ); + + /* R'*R = H */ + real_t sum; + real_t inv; + + for( i=0; i=0; --k ) + sum -= R[k*NVMAX + i] * R[k*NVMAX + i]; + + if ( sum > 0.0 ) + { + R[i*NVMAX + i] = sqrt( sum ); + inv = 1.0 / R[i*NVMAX + i]; + } + else + { + hessianType = HST_SEMIDEF; + return THROWERROR( RET_HESSIAN_NOT_SPD ); + } + + /* j > i */ + for( j=(i+1); j=0; --k ) + sum -= R[k*NVMAX + i] * R[k*NVMAX + j]; + + R[i*NVMAX + j] = sum * inv; + } + } + } + } + + return SUCCESSFUL_RETURN; +} + + +/* + * s o l v e I n i t i a l Q P + */ +returnValue QProblemB::solveInitialQP( const real_t* const xOpt, const real_t* const yOpt, + const Bounds* const guessedBounds, + int& nWSR, real_t* const cputime + ) +{ + int i, nFR; + int nV = getNV( ); + + + /* start runtime measurement */ + real_t starttime = 0.0; + if ( cputime != 0 ) + starttime = getCPUtime( ); + + + status = QPS_NOTINITIALISED; + + /* I) ANALYSE QP DATA: */ + /* 1) Check if Hessian happens to be the identity matrix. */ + if ( checkForIdentityHessian( ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_INIT_FAILED ); + + /* 2) Setup type of bounds (i.e. unbounded, implicitly fixed etc.). */ + if ( setupSubjectToType( ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_INIT_FAILED ); + + status = QPS_PREPARINGAUXILIARYQP; + + + /* II) SETUP AUXILIARY QP WITH GIVEN OPTIMAL SOLUTION: */ + /* 1) Setup bounds data structure. */ + if ( bounds.setupAllFree( ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_INIT_FAILED ); + + /* 2) Setup optimal primal/dual solution for auxiliary QP. */ + if ( setupAuxiliaryQPsolution( xOpt,yOpt ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_INIT_FAILED ); + + /* 3) Obtain linear independent working set for auxiliary QP. */ + + static Bounds auxiliaryBounds; + + auxiliaryBounds.init( nV ); + + if ( obtainAuxiliaryWorkingSet( xOpt,yOpt,guessedBounds, &auxiliaryBounds ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_INIT_FAILED ); + + /* 4) Setup working set of auxiliary QP and setup cholesky decomposition. */ + if ( setupAuxiliaryWorkingSet( &auxiliaryBounds,BT_TRUE ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_INIT_FAILED ); + + nFR = getNFR(); + /* At the moment we can only provide a Cholesky of the Hessian if + * the solver is cold-started. */ + if (hasCholesky == BT_FALSE || nFR != nV) + if (setupCholeskyDecomposition() != SUCCESSFUL_RETURN) + return THROWERROR( RET_INIT_FAILED_CHOLESKY ); + + /* 5) Store original QP formulation... */ + real_t g_original[NVMAX]; + real_t lb_original[NVMAX]; + real_t ub_original[NVMAX]; + + for( i=0; isetupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + } + else + { + if ( auxiliaryBounds->setupBound( i,guessedBounds->getStatus( i ) ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + } + } + } + else /* No initial working set specified. */ + { + if ( ( xOpt != 0 ) && ( yOpt == 0 ) ) + { + /* Obtain initial working set by "clipping". */ + for( i=0; isetupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + continue; + } + + if ( xOpt[i] >= ub[i] - BOUNDTOL ) + { + if ( auxiliaryBounds->setupBound( i,ST_UPPER ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + continue; + } + + /* Moreover, add all implictly fixed variables if specified. */ + if ( bounds.getType( i ) == ST_EQUALITY ) + { + if ( auxiliaryBounds->setupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + } + else + { + if ( auxiliaryBounds->setupBound( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + } + } + } + + if ( ( xOpt == 0 ) && ( yOpt != 0 ) ) + { + /* Obtain initial working set in accordance to sign of dual solution vector. */ + for( i=0; i ZERO ) + { + if ( auxiliaryBounds->setupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + continue; + } + + if ( yOpt[i] < -ZERO ) + { + if ( auxiliaryBounds->setupBound( i,ST_UPPER ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + continue; + } + + /* Moreover, add all implictly fixed variables if specified. */ + if ( bounds.getType( i ) == ST_EQUALITY ) + { + if ( auxiliaryBounds->setupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + } + else + { + if ( auxiliaryBounds->setupBound( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + } + } + } + + /* If xOpt and yOpt are null pointer and no initial working is specified, + * start with empty working set (or implicitly fixed bounds only) + * for auxiliary QP. */ + if ( ( xOpt == 0 ) && ( yOpt == 0 ) ) + { + for( i=0; isetupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + } + else + { + if ( auxiliaryBounds->setupBound( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); + } + } + } + } + + return SUCCESSFUL_RETURN; +} + + +/* + * s e t u p A u x i l i a r y W o r k i n g S e t + */ +returnValue QProblemB::setupAuxiliaryWorkingSet( const Bounds* const auxiliaryBounds, + BooleanType setupAfresh + ) +{ + int i; + int nV = getNV( ); + + /* consistency checks */ + if ( auxiliaryBounds != 0 ) + { + for( i=0; igetStatus( i ) == ST_UNDEFINED ) ) + return THROWERROR( RET_UNKNOWN_BUG ); + } + else + { + return THROWERROR( RET_INVALID_ARGUMENTS ); + } + + + /* I) SETUP CHOLESKY FLAG: + * Cholesky decomposition shall only be updated if working set + * shall be updated (i.e. NOT setup afresh!) */ + BooleanType updateCholesky; + if ( setupAfresh == BT_TRUE ) + updateCholesky = BT_FALSE; + else + updateCholesky = BT_TRUE; + + + /* II) REMOVE FORMERLY ACTIVE BOUNDS (IF NECESSARY): */ + if ( setupAfresh == BT_FALSE ) + { + /* Remove all active bounds that shall be inactive AND + * all active bounds that are active at the wrong bound. */ + for( i=0; igetStatus( i ) != ST_LOWER ) ) + if ( removeBound( i,updateCholesky ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); + + if ( ( bounds.getStatus( i ) == ST_UPPER ) && ( auxiliaryBounds->getStatus( i ) != ST_UPPER ) ) + if ( removeBound( i,updateCholesky ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); + } + } + + + /* III) ADD NEWLY ACTIVE BOUNDS: */ + /* Add all inactive bounds that shall be active AND + * all formerly active bounds that have been active at the wrong bound. */ + for( i=0; igetStatus( i ) != ST_INACTIVE ) ) + { + if ( addBound( i,auxiliaryBounds->getStatus( i ),updateCholesky ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); + } + } + + return SUCCESSFUL_RETURN; +} + + +/* + * s e t u p A u x i l i a r y Q P s o l u t i o n + */ +returnValue QProblemB::setupAuxiliaryQPsolution( const real_t* const xOpt, const real_t* const yOpt + ) +{ + int i; + int nV = getNV( ); + + + /* Setup primal/dual solution vectors for auxiliary initial QP: + * if a null pointer is passed, a zero vector is assigned; + * old solution vector is kept if pointer to internal solution vector is passed. */ + if ( xOpt != 0 ) + { + if ( xOpt != x ) + for( i=0; igetIndex( number ); + + real_t c, s; + + /* 2) Use row-wise Givens rotations to restore upper triangular form of R. */ + for( i=number_idx+1; ith column and ... */ + for( i=0; igetNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_REMOVEBOUND_FAILED ); + + /* 1) Calculate new column of cholesky decomposition. */ + real_t rhs[NVMAX]; + real_t r[NVMAX]; + real_t r0 = H[number*NVMAX + number]; + + for( i=0; i 0.0 ) + R[nFR*NVMAX + nFR] = sqrt( r0 ); + else + { + hessianType = HST_SEMIDEF; + return THROWERROR( RET_HESSIAN_NOT_SPD ); + } + + + return SUCCESSFUL_RETURN; +} + + +/* + * b a c k s o l v e R (CODE DUPLICATED IN QProblem CLASS!!!) + */ +returnValue QProblemB::backsolveR( const real_t* const b, BooleanType transposed, + real_t* const a + ) +{ + /* Call standard backsolve procedure (i.e. removingBound == BT_FALSE). */ + return backsolveR( b,transposed,BT_FALSE,a ); +} + + +/* + * b a c k s o l v e R (CODE DUPLICATED IN QProblem CLASS!!!) + */ +returnValue QProblemB::backsolveR( const real_t* const b, BooleanType transposed, + BooleanType removingBound, + real_t* const a + ) +{ + int i, j; + int nR = getNZ( ); + + real_t sum; + + /* if backsolve is called while removing a bound, reduce nZ by one. */ + if ( removingBound == BT_TRUE ) + --nR; + + /* nothing to do */ + if ( nR <= 0 ) + return SUCCESSFUL_RETURN; + + + /* Solve Ra = b, where R might be transposed. */ + if ( transposed == BT_FALSE ) + { + /* solve Ra = b */ + for( i=(nR-1); i>=0; --i ) + { + sum = b[i]; + for( j=(i+1); j ZERO ) + a[i] = sum / R[i*NVMAX + i]; + else + return THROWERROR( RET_DIV_BY_ZERO ); + } + } + else + { + /* solve R^T*a = b */ + for( i=0; i ZERO ) + a[i] = sum / R[i*NVMAX + i]; + else + return THROWERROR( RET_DIV_BY_ZERO ); + } + } + + return SUCCESSFUL_RETURN; +} + + +/* + * h o t s t a r t _ d e t e r m i n e D a t a S h i f t + */ +returnValue QProblemB::hotstart_determineDataShift( const int* const FX_idx, + const real_t* const g_new, const real_t* const lb_new, const real_t* const ub_new, + real_t* const delta_g, real_t* const delta_lb, real_t* const delta_ub, + BooleanType& Delta_bB_isZero + ) +{ + int i, ii; + int nV = getNV( ); + int nFX = getNFX( ); + + + /* 1) Calculate shift directions. */ + for( i=0; i EPS ) || ( getAbs( delta_ub[ii] ) > EPS ) ) + { + Delta_bB_isZero = BT_FALSE; + break; + } + } + + return SUCCESSFUL_RETURN; +} + + +/* + * a r e B o u n d s C o n s i s t e n t + */ +BooleanType QProblemB::areBoundsConsistent( const real_t* const delta_lb, const real_t* const delta_ub + ) const +{ + int i; + + /* Check if delta_lb[i] is greater than delta_ub[i] + * for a component i whose bounds are already (numerically) equal. */ + for( i=0; i ub[i] - BOUNDTOL ) && ( delta_lb[i] > delta_ub[i] + EPS ) ) + return BT_FALSE; + + return BT_TRUE; +} + + +/* + * s e t u p Q P d a t a + */ +returnValue QProblemB::setupQPdata( const real_t* const _H, const real_t* const _R, const real_t* const _g, + const real_t* const _lb, const real_t* const _ub + ) +{ + int i, j; + int nV = getNV( ); + + /* 1) Setup Hessian matrix and it's Cholesky factorization. */ + if (_H != 0) + { + for( i=0; i 0 ) + { + for( i=0; i 0 ) + { + /* auxiliary variables */ + real_t delta_xFRz_TMP[NVMAX]; + real_t delta_xFRz_RHS[NVMAX]; + + /* Determine delta_xFRz. */ + if ( Delta_bB_isZero == BT_FALSE ) + { + for( i=0; i 0 ) + { + for( i=0; i= 0.0 ) ) + { + tau_tmp = y[ii] / ( -delta_yFX[i] ); + if ( tau_tmp < tau_new ) + { + if ( tau_tmp >= 0.0 ) + { + tau_new = tau_tmp; + BC_idx = ii; + BC_status = ST_INACTIVE; + } + } + } + } + else + { + /* 2) Active upper bounds. */ + if ( ( delta_yFX[i] > ZERO ) && ( y[ii] <= 0.0 ) ) + { + tau_tmp = y[ii] / ( -delta_yFX[i] ); + if ( tau_tmp < tau_new ) + { + if ( tau_tmp >= 0.0 ) + { + tau_new = tau_tmp; + BC_idx = ii; + BC_status = ST_INACTIVE; + } + } + } + } + } + } + + + /* II) DETERMINE MAXIMUM PRIMAL STEPLENGTH, i.e. ensure that + * inactive bounds remain valid (ignoring unbounded variables). */ + /* 1) Inactive lower bounds. */ + if ( bounds.isNoLower( ) == BT_FALSE ) + { + for( i=0; i delta_xFR[i] ) + { + if ( x[ii] > lb[ii] ) + tau_tmp = ( x[ii] - lb[ii] ) / ( delta_lb[ii] - delta_xFR[i] ); + else + tau_tmp = 0.0; + + if ( tau_tmp < tau_new ) + { + if ( tau_tmp >= 0.0 ) + { + tau_new = tau_tmp; + BC_idx = ii; + BC_status = ST_LOWER; + } + } + } + } + } + } + + /* 2) Inactive upper bounds. */ + if ( bounds.isNoUpper( ) == BT_FALSE ) + { + for( i=0; i= 0.0 ) + { + tau_new = tau_tmp; + BC_idx = ii; + BC_status = ST_UPPER; + } + } + } + } + } + } + + + /* III) SET MAXIMUM HOMOTOPY STEPLENGTH */ + tau = tau_new; + + if ( printlevel == PL_HIGH ) + { + #ifdef PC_DEBUG + char messageString[80]; + + if ( BC_status == ST_UNDEFINED ) + sprintf( messageString,"Stepsize is %.6e!",tau ); + else + sprintf( messageString,"Stepsize is %.6e! (BC_idx = %d, BC_status = %d)",tau,BC_idx,BC_status ); + + getGlobalMessageHandler( )->throwInfo( RET_STEPSIZE_NONPOSITIVE,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); + #endif + } + + return SUCCESSFUL_RETURN; +} + + +/* + * h o t s t a r t _ p e r f o r m S t e p + */ +returnValue QProblemB::hotstart_performStep( const int* const FR_idx, const int* const FX_idx, + const real_t* const delta_g, const real_t* const delta_lb, const real_t* const delta_ub, + const real_t* const delta_xFX, const real_t* const delta_xFR, + const real_t* const delta_yFX, + int BC_idx, SubjectToStatus BC_status + ) +{ + int i, ii; + int nV = getNV( ); + int nFR = getNFR( ); + int nFX = getNFX( ); + + + /* I) CHECK BOUNDS' CONSISTENCY */ + if ( areBoundsConsistent( delta_lb,delta_ub ) == BT_FALSE ) + { + infeasible = BT_TRUE; + tau = 0.0; + + return THROWERROR( RET_QP_INFEASIBLE ); + } + + + /* II) GO TO ACTIVE SET CHANGE */ + if ( tau > ZERO ) + { + /* 1) Perform step in primal und dual space. */ + for( i=0; ithrowWarning( RET_STEPSIZE,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); + #endif + } + + + /* setup output preferences */ + #ifdef PC_DEBUG + char messageString[80]; + VisibilityStatus visibilityStatus; + + if ( printlevel == PL_HIGH ) + visibilityStatus = VS_VISIBLE; + else + visibilityStatus = VS_HIDDEN; + #endif + + + /* III) UPDATE ACTIVE SET */ + switch ( BC_status ) + { + /* Optimal solution found as no working set change detected. */ + case ST_UNDEFINED: + return RET_OPTIMAL_SOLUTION_FOUND; + + + /* Remove one variable from active set. */ + case ST_INACTIVE: + #ifdef PC_DEBUG + sprintf( messageString,"bound no. %d.", BC_idx ); + getGlobalMessageHandler( )->throwInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); + #endif + + if ( removeBound( BC_idx,BT_TRUE ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); + + y[BC_idx] = 0.0; + break; + + + /* Add one variable to active set. */ + default: + #ifdef PC_DEBUG + if ( BC_status == ST_LOWER ) + sprintf( messageString,"lower bound no. %d.", BC_idx ); + else + sprintf( messageString,"upper bound no. %d.", BC_idx ); + getGlobalMessageHandler( )->throwInfo( RET_ADD_TO_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); + #endif + + if ( addBound( BC_idx,BC_status,BT_TRUE ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_ADD_TO_ACTIVESET_FAILED ); + break; + } + + return SUCCESSFUL_RETURN; +} + + +#ifdef PC_DEBUG /* Define print functions only for debugging! */ + +/* + * p r i n t I t e r a t i o n + */ +returnValue QProblemB::printIteration( int iteration, + int BC_idx, SubjectToStatus BC_status + ) +{ + char myPrintfString[160]; + + /* consistency check */ + if ( iteration < 0 ) + return THROWERROR( RET_INVALID_ARGUMENTS ); + + /* nothing to do */ + if ( printlevel != PL_MEDIUM ) + return SUCCESSFUL_RETURN; + + + /* 1) Print header at first iteration. */ + if ( iteration == 0 ) + { + sprintf( myPrintfString,"\n############## qpOASES -- QP NO.%4.1d ###############\n", count ); + myPrintf( myPrintfString ); + + sprintf( myPrintfString," Iter | StepLength | Info | nFX \n" ); + myPrintf( myPrintfString ); + } + + /* 2) Print iteration line. */ + if ( BC_status == ST_UNDEFINED ) + { + sprintf( myPrintfString," %4.1d | %1.5e | QP SOLVED | %4.1d \n", iteration,tau,getNFX( ) ); + myPrintf( myPrintfString ); + } + else + { + char info[8]; + + if ( BC_status == ST_INACTIVE ) + sprintf( info,"REM BND" ); + else + sprintf( info,"ADD BND" ); + + sprintf( myPrintfString," %4.1d | %1.5e | %s%4.1d | %4.1d \n", iteration,tau,info,BC_idx,getNFX( ) ); + myPrintf( myPrintfString ); + } + + return SUCCESSFUL_RETURN; +} + +#endif /* PC_DEBUG */ + + + +/* + * c h e c k K K T c o n d i t i o n s + */ +returnValue QProblemB::checkKKTconditions( ) +{ + #ifdef __PERFORM_KKT_TEST__ + + int i, j; + int nV = getNV( ); + + real_t tmp; + real_t maxKKTviolation = 0.0; + + + /* 1) Check for Hx + g - y*A' = 0 (here: A = Id). */ + for( i=0; i maxKKTviolation ) + maxKKTviolation = getAbs( tmp ); + } + + /* 2) Check for lb <= x <= ub. */ + for( i=0; i maxKKTviolation ) + maxKKTviolation = lb[i] - x[i]; + + if ( x[i] - ub[i] > maxKKTviolation ) + maxKKTviolation = x[i] - ub[i]; + } + + /* 3) Check for correct sign of y and for complementary slackness. */ + for( i=0; i maxKKTviolation ) + maxKKTviolation = -y[i]; + if ( getAbs( ( x[i] - lb[i] ) * y[i] ) > maxKKTviolation ) + maxKKTviolation = getAbs( ( x[i] - lb[i] ) * y[i] ); + break; + + case ST_UPPER: + if ( y[i] > maxKKTviolation ) + maxKKTviolation = y[i]; + if ( getAbs( ( ub[i] - x[i] ) * y[i] ) > maxKKTviolation ) + maxKKTviolation = getAbs( ( ub[i] - x[i] ) * y[i] ); + break; + + default: /* inactive */ + if ( getAbs( y[i] ) > maxKKTviolation ) + maxKKTviolation = getAbs( y[i] ); + break; + } + } + + if ( maxKKTviolation > CRITICALACCURACY ) + return RET_NO_SOLUTION; + + if ( maxKKTviolation > DESIREDACCURACY ) + return RET_INACCURATE_SOLUTION; + + #endif /* __PERFORM_KKT_TEST__ */ + + return SUCCESSFUL_RETURN; +} + + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/SRC/QProblemB.ipp b/phonelibs/qpoases/SRC/QProblemB.ipp index 0c1c8b231147b5..0b031301e6c415 100644 --- a/phonelibs/qpoases/SRC/QProblemB.ipp +++ b/phonelibs/qpoases/SRC/QProblemB.ipp @@ -1,425 +1,425 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/QProblemB.ipp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of inlined member functions of the QProblemB class which - * is able to use the newly developed online active set strategy for - * parametric quadratic programming. - */ - - - -#include - - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - -/* - * g e t H - */ -inline returnValue QProblemB::getH( real_t* const _H ) const -{ - int i; - - for ( i=0; i= 0 ) && ( number < getNV( ) ) ) - { - value = lb[number]; - return SUCCESSFUL_RETURN; - } - else - { - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - } -} - - -/* - * g e t U B - */ -inline returnValue QProblemB::getUB( real_t* const _ub ) const -{ - int i; - - for ( i=0; i= 0 ) && ( number < getNV( ) ) ) - { - value = ub[number]; - return SUCCESSFUL_RETURN; - } - else - { - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - } -} - - -/* - * g e t B o u n d s - */ -inline returnValue QProblemB::getBounds( Bounds* const _bounds ) const -{ - *_bounds = bounds; - - return SUCCESSFUL_RETURN; -} - - -/* - * g e t N V - */ -inline int QProblemB::getNV( ) const -{ - return bounds.getNV( ); -} - - -/* - * g e t N F R - */ -inline int QProblemB::getNFR( ) -{ - return bounds.getNFR( ); -} - - -/* - * g e t N F X - */ -inline int QProblemB::getNFX( ) -{ - return bounds.getNFX( ); -} - - -/* - * g e t N F V - */ -inline int QProblemB::getNFV( ) const -{ - return bounds.getNFV( ); -} - - -/* - * g e t S t a t u s - */ -inline QProblemStatus QProblemB::getStatus( ) const -{ - return status; -} - - -/* - * i s I n i t i a l i s e d - */ -inline BooleanType QProblemB::isInitialised( ) const -{ - if ( status == QPS_NOTINITIALISED ) - return BT_FALSE; - else - return BT_TRUE; -} - - -/* - * i s S o l v e d - */ -inline BooleanType QProblemB::isSolved( ) const -{ - if ( status == QPS_SOLVED ) - return BT_TRUE; - else - return BT_FALSE; -} - - -/* - * i s I n f e a s i b l e - */ -inline BooleanType QProblemB::isInfeasible( ) const -{ - return infeasible; -} - - -/* - * i s U n b o u n d e d - */ -inline BooleanType QProblemB::isUnbounded( ) const -{ - return unbounded; -} - - -/* - * g e t P r i n t L e v e l - */ -inline PrintLevel QProblemB::getPrintLevel( ) const -{ - return printlevel; -} - - -/* - * g e t H e s s i a n T y p e - */ -inline HessianType QProblemB::getHessianType( ) const -{ - return hessianType; -} - - -/* - * s e t H e s s i a n T y p e - */ -inline returnValue QProblemB::setHessianType( HessianType _hessianType ) -{ - hessianType = _hessianType; - return SUCCESSFUL_RETURN; -} - - - -/***************************************************************************** - * P R O T E C T E D * - *****************************************************************************/ - -/* - * s e t H - */ -inline returnValue QProblemB::setH( const real_t* const H_new ) -{ - int i, j; - - int nV = getNV(); - - for( i=0; i= 0 ) && ( number < getNV( ) ) ) - { - lb[number] = value; - return SUCCESSFUL_RETURN; - } - else - { - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - } -} - - -/* - * s e t U B - */ -inline returnValue QProblemB::setUB( const real_t* const ub_new ) -{ - int i; - - int nV = getNV(); - - for( i=0; i= 0 ) && ( number < getNV( ) ) ) - { - ub[number] = value; - - return SUCCESSFUL_RETURN; - } - else - { - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - } -} - - -/* - * c o m p u t e G i v e n s - */ -inline void QProblemB::computeGivens( real_t xold, real_t yold, real_t& xnew, real_t& ynew, - real_t& c, real_t& s - ) const -{ - if ( getAbs( yold ) <= ZERO ) - { - c = 1.0; - s = 0.0; - - xnew = xold; - ynew = yold; - } - else - { - real_t t, mu; - - mu = getAbs( xold ); - if ( getAbs( yold ) > mu ) - mu = getAbs( yold ); - - t = mu * sqrt( (xold/mu)*(xold/mu) + (yold/mu)*(yold/mu) ); - - if ( xold < 0.0 ) - t = -t; - - c = xold/t; - s = yold/t; - xnew = t; - ynew = 0.0; - } - - return; -} - - -/* - * a p p l y G i v e n s - */ -inline void QProblemB::applyGivens( real_t c, real_t s, real_t xold, real_t yold, - real_t& xnew, real_t& ynew - ) const -{ - /* Usual Givens plane rotation requiring four multiplications. */ - xnew = c*xold + s*yold; - ynew = -s*xold + c*yold; -// double nu = s/(1.0+c); -// -// xnew = xold*c + yold*s; -// ynew = (xnew+xold)*nu - yold; - - return; -} - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file SRC/QProblemB.ipp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Implementation of inlined member functions of the QProblemB class which + * is able to use the newly developed online active set strategy for + * parametric quadratic programming. + */ + + + +#include + + + +/***************************************************************************** + * P U B L I C * + *****************************************************************************/ + +/* + * g e t H + */ +inline returnValue QProblemB::getH( real_t* const _H ) const +{ + int i; + + for ( i=0; i= 0 ) && ( number < getNV( ) ) ) + { + value = lb[number]; + return SUCCESSFUL_RETURN; + } + else + { + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); + } +} + + +/* + * g e t U B + */ +inline returnValue QProblemB::getUB( real_t* const _ub ) const +{ + int i; + + for ( i=0; i= 0 ) && ( number < getNV( ) ) ) + { + value = ub[number]; + return SUCCESSFUL_RETURN; + } + else + { + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); + } +} + + +/* + * g e t B o u n d s + */ +inline returnValue QProblemB::getBounds( Bounds* const _bounds ) const +{ + *_bounds = bounds; + + return SUCCESSFUL_RETURN; +} + + +/* + * g e t N V + */ +inline int QProblemB::getNV( ) const +{ + return bounds.getNV( ); +} + + +/* + * g e t N F R + */ +inline int QProblemB::getNFR( ) +{ + return bounds.getNFR( ); +} + + +/* + * g e t N F X + */ +inline int QProblemB::getNFX( ) +{ + return bounds.getNFX( ); +} + + +/* + * g e t N F V + */ +inline int QProblemB::getNFV( ) const +{ + return bounds.getNFV( ); +} + + +/* + * g e t S t a t u s + */ +inline QProblemStatus QProblemB::getStatus( ) const +{ + return status; +} + + +/* + * i s I n i t i a l i s e d + */ +inline BooleanType QProblemB::isInitialised( ) const +{ + if ( status == QPS_NOTINITIALISED ) + return BT_FALSE; + else + return BT_TRUE; +} + + +/* + * i s S o l v e d + */ +inline BooleanType QProblemB::isSolved( ) const +{ + if ( status == QPS_SOLVED ) + return BT_TRUE; + else + return BT_FALSE; +} + + +/* + * i s I n f e a s i b l e + */ +inline BooleanType QProblemB::isInfeasible( ) const +{ + return infeasible; +} + + +/* + * i s U n b o u n d e d + */ +inline BooleanType QProblemB::isUnbounded( ) const +{ + return unbounded; +} + + +/* + * g e t P r i n t L e v e l + */ +inline PrintLevel QProblemB::getPrintLevel( ) const +{ + return printlevel; +} + + +/* + * g e t H e s s i a n T y p e + */ +inline HessianType QProblemB::getHessianType( ) const +{ + return hessianType; +} + + +/* + * s e t H e s s i a n T y p e + */ +inline returnValue QProblemB::setHessianType( HessianType _hessianType ) +{ + hessianType = _hessianType; + return SUCCESSFUL_RETURN; +} + + + +/***************************************************************************** + * P R O T E C T E D * + *****************************************************************************/ + +/* + * s e t H + */ +inline returnValue QProblemB::setH( const real_t* const H_new ) +{ + int i, j; + + int nV = getNV(); + + for( i=0; i= 0 ) && ( number < getNV( ) ) ) + { + lb[number] = value; + return SUCCESSFUL_RETURN; + } + else + { + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); + } +} + + +/* + * s e t U B + */ +inline returnValue QProblemB::setUB( const real_t* const ub_new ) +{ + int i; + + int nV = getNV(); + + for( i=0; i= 0 ) && ( number < getNV( ) ) ) + { + ub[number] = value; + + return SUCCESSFUL_RETURN; + } + else + { + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); + } +} + + +/* + * c o m p u t e G i v e n s + */ +inline void QProblemB::computeGivens( real_t xold, real_t yold, real_t& xnew, real_t& ynew, + real_t& c, real_t& s + ) const +{ + if ( getAbs( yold ) <= ZERO ) + { + c = 1.0; + s = 0.0; + + xnew = xold; + ynew = yold; + } + else + { + real_t t, mu; + + mu = getAbs( xold ); + if ( getAbs( yold ) > mu ) + mu = getAbs( yold ); + + t = mu * sqrt( (xold/mu)*(xold/mu) + (yold/mu)*(yold/mu) ); + + if ( xold < 0.0 ) + t = -t; + + c = xold/t; + s = yold/t; + xnew = t; + ynew = 0.0; + } + + return; +} + + +/* + * a p p l y G i v e n s + */ +inline void QProblemB::applyGivens( real_t c, real_t s, real_t xold, real_t yold, + real_t& xnew, real_t& ynew + ) const +{ + /* Usual Givens plane rotation requiring four multiplications. */ + xnew = c*xold + s*yold; + ynew = -s*xold + c*yold; +// double nu = s/(1.0+c); +// +// xnew = xold*c + yold*s; +// ynew = (xnew+xold)*nu - yold; + + return; +} + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/SRC/SubjectTo.cpp b/phonelibs/qpoases/SRC/SubjectTo.cpp index 5dbf707c9d1f21..371f0d76d32781 100644 --- a/phonelibs/qpoases/SRC/SubjectTo.cpp +++ b/phonelibs/qpoases/SRC/SubjectTo.cpp @@ -1,200 +1,200 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/SubjectTo.cpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of the SubjectTo class designed to manage working sets of - * constraints and bounds within a QProblem. - */ - - -#include - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - - -/* - * S u b j e c t T o - */ -SubjectTo::SubjectTo( ) : noLower( BT_TRUE ), - noUpper( BT_TRUE ), - size( 0 ) -{ - int i; - - for( i=0; iaddNumber( newnumber ) == RET_INDEXLIST_EXCEEDS_MAX_LENGTH ) - return THROWERROR( RET_ADDINDEX_FAILED ); - - return SUCCESSFUL_RETURN; -} - - -/* - * r e m o v e I n d e x - */ -returnValue SubjectTo::removeIndex( Indexlist* const indexlist, - int removenumber - ) -{ - status[removenumber] = ST_UNDEFINED; - - if ( indexlist->removeNumber( removenumber ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_UNKNOWN_BUG ); - - return SUCCESSFUL_RETURN; -} - - -/* - * s w a p I n d e x - */ -returnValue SubjectTo::swapIndex( Indexlist* const indexlist, - int number1, int number2 - ) -{ - /* consistency checks */ - if ( status[number1] != status[number2] ) - return THROWERROR( RET_SWAPINDEX_FAILED ); - - if ( number1 == number2 ) - { - THROWWARNING( RET_NOTHING_TO_DO ); - return SUCCESSFUL_RETURN; - } - - if ( indexlist->swapNumbers( number1,number2 ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SWAPINDEX_FAILED ); - - return SUCCESSFUL_RETURN; -} - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file SRC/SubjectTo.cpp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Implementation of the SubjectTo class designed to manage working sets of + * constraints and bounds within a QProblem. + */ + + +#include + + +/***************************************************************************** + * P U B L I C * + *****************************************************************************/ + + +/* + * S u b j e c t T o + */ +SubjectTo::SubjectTo( ) : noLower( BT_TRUE ), + noUpper( BT_TRUE ), + size( 0 ) +{ + int i; + + for( i=0; iaddNumber( newnumber ) == RET_INDEXLIST_EXCEEDS_MAX_LENGTH ) + return THROWERROR( RET_ADDINDEX_FAILED ); + + return SUCCESSFUL_RETURN; +} + + +/* + * r e m o v e I n d e x + */ +returnValue SubjectTo::removeIndex( Indexlist* const indexlist, + int removenumber + ) +{ + status[removenumber] = ST_UNDEFINED; + + if ( indexlist->removeNumber( removenumber ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_UNKNOWN_BUG ); + + return SUCCESSFUL_RETURN; +} + + +/* + * s w a p I n d e x + */ +returnValue SubjectTo::swapIndex( Indexlist* const indexlist, + int number1, int number2 + ) +{ + /* consistency checks */ + if ( status[number1] != status[number2] ) + return THROWERROR( RET_SWAPINDEX_FAILED ); + + if ( number1 == number2 ) + { + THROWWARNING( RET_NOTHING_TO_DO ); + return SUCCESSFUL_RETURN; + } + + if ( indexlist->swapNumbers( number1,number2 ) != SUCCESSFUL_RETURN ) + return THROWERROR( RET_SWAPINDEX_FAILED ); + + return SUCCESSFUL_RETURN; +} + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/SRC/SubjectTo.ipp b/phonelibs/qpoases/SRC/SubjectTo.ipp index 7cd6dc69fe9bd7..32215ba7e45855 100644 --- a/phonelibs/qpoases/SRC/SubjectTo.ipp +++ b/phonelibs/qpoases/SRC/SubjectTo.ipp @@ -1,132 +1,132 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/SubjectTo.ipp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of the inlined member functions of the SubjectTo class - * designed to manage working sets of constraints and bounds within a QProblem. - */ - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - - -/* - * g e t T y p e - */ -inline SubjectToType SubjectTo::getType( int i ) const -{ - if ( ( i >= 0 ) && ( i < size ) ) - return type[i]; - else - return ST_UNKNOWN; -} - - -/* - * g e t S t a t u s - */ -inline SubjectToStatus SubjectTo::getStatus( int i ) const -{ - if ( ( i >= 0 ) && ( i < size ) ) - return status[i]; - else - return ST_UNDEFINED; -} - - -/* - * s e t T y p e - */ -inline returnValue SubjectTo::setType( int i, SubjectToType value ) -{ - if ( ( i >= 0 ) && ( i < size ) ) - { - type[i] = value; - return SUCCESSFUL_RETURN; - } - else - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); -} - - -/* - * s e t S t a t u s - */ -inline returnValue SubjectTo::setStatus( int i, SubjectToStatus value ) -{ - if ( ( i >= 0 ) && ( i < size ) ) - { - status[i] = value; - return SUCCESSFUL_RETURN; - } - else - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); -} - - -/* - * s e t N o L o w e r - */ -inline void SubjectTo::setNoLower( BooleanType _status ) -{ - noLower = _status; -} - - -/* - * s e t N o U p p e r - */ -inline void SubjectTo::setNoUpper( BooleanType _status ) -{ - noUpper = _status; -} - - -/* - * i s N o L o w e r - */ -inline BooleanType SubjectTo::isNoLower( ) const -{ - return noLower; -} - - -/* - * i s N o L o w e r - */ -inline BooleanType SubjectTo::isNoUpper( ) const -{ - return noUpper; -} - - -/* - * end of file - */ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. + * + * qpOASES is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * qpOASES is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with qpOASES; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/** + * \file SRC/SubjectTo.ipp + * \author Hans Joachim Ferreau + * \version 1.3embedded + * \date 2007-2008 + * + * Implementation of the inlined member functions of the SubjectTo class + * designed to manage working sets of constraints and bounds within a QProblem. + */ + + +/***************************************************************************** + * P U B L I C * + *****************************************************************************/ + + +/* + * g e t T y p e + */ +inline SubjectToType SubjectTo::getType( int i ) const +{ + if ( ( i >= 0 ) && ( i < size ) ) + return type[i]; + else + return ST_UNKNOWN; +} + + +/* + * g e t S t a t u s + */ +inline SubjectToStatus SubjectTo::getStatus( int i ) const +{ + if ( ( i >= 0 ) && ( i < size ) ) + return status[i]; + else + return ST_UNDEFINED; +} + + +/* + * s e t T y p e + */ +inline returnValue SubjectTo::setType( int i, SubjectToType value ) +{ + if ( ( i >= 0 ) && ( i < size ) ) + { + type[i] = value; + return SUCCESSFUL_RETURN; + } + else + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); +} + + +/* + * s e t S t a t u s + */ +inline returnValue SubjectTo::setStatus( int i, SubjectToStatus value ) +{ + if ( ( i >= 0 ) && ( i < size ) ) + { + status[i] = value; + return SUCCESSFUL_RETURN; + } + else + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); +} + + +/* + * s e t N o L o w e r + */ +inline void SubjectTo::setNoLower( BooleanType _status ) +{ + noLower = _status; +} + + +/* + * s e t N o U p p e r + */ +inline void SubjectTo::setNoUpper( BooleanType _status ) +{ + noUpper = _status; +} + + +/* + * i s N o L o w e r + */ +inline BooleanType SubjectTo::isNoLower( ) const +{ + return noLower; +} + + +/* + * i s N o L o w e r + */ +inline BooleanType SubjectTo::isNoUpper( ) const +{ + return noUpper; +} + + +/* + * end of file + */ diff --git a/phonelibs/qpoases/SRC/Utils.cpp b/phonelibs/qpoases/SRC/Utils.cpp index 7a3d0a5226203b..c11722c4797d99 100644 --- a/phonelibs/qpoases/SRC/Utils.cpp +++ b/phonelibs/qpoases/SRC/Utils.cpp @@ -1,471 +1,471 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/Utils.cpp - * \author Hans Joachim Ferreau, Eckhard Arnold - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of some inlined utilities for working with the different QProblem - * classes. - */ - - -#include - -#if defined(__WIN32__) || defined(WIN32) - #include -#elif defined(LINUX) - #include - #include -#endif - -#ifdef __MATLAB__ - #include -#endif - - -#include - - - -#ifdef PC_DEBUG /* Define print functions only for debugging! */ -/* - * p r i n t - */ -returnValue print( const real_t* const v, int n ) -{ - int i; - char myPrintfString[160]; - - /* Print a vector. */ - myPrintf( "[\t" ); - for( i=0; ithrowError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - } - - /* 2) Read data from file. */ - for( i=0; ithrowError( RET_UNABLE_TO_READ_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - } - data[i*ncol + j] = ( (real_t) float_data ); - } - } - - /* 3) Close file. */ - fclose( datafile ); - - return SUCCESSFUL_RETURN; -} - - -/* - * r e a d F r o m F i l e - */ -returnValue readFromFile( real_t* data, int n, - const char* datafilename - ) -{ - return readFromFile( data, n, 1, datafilename ); -} - - - -/* - * r e a d F r o m F i l e - */ -returnValue readFromFile( int* data, int n, - const char* datafilename - ) -{ - int i; - myFILE* datafile; - - /* 1) Open file. */ - if ( ( datafile = fopen( datafilename, "r" ) ) == 0 ) - { - char errstr[80]; - sprintf( errstr,"(%s)",datafilename ); - return getGlobalMessageHandler( )->throwError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - } - - /* 2) Read data from file. */ - for( i=0; ithrowError( RET_UNABLE_TO_READ_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - } - } - - /* 3) Close file. */ - fclose( datafile ); - - return SUCCESSFUL_RETURN; -} - - -/* - * w r i t e I n t o F i l e - */ -returnValue writeIntoFile( const real_t* const data, int nrow, int ncol, - const char* datafilename, BooleanType append - ) -{ - int i, j; - myFILE* datafile; - - /* 1) Open file. */ - if ( append == BT_TRUE ) - { - /* append data */ - if ( ( datafile = fopen( datafilename, "a" ) ) == 0 ) - { - char errstr[80]; - sprintf( errstr,"(%s)",datafilename ); - return getGlobalMessageHandler( )->throwError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - } - } - else - { - /* do not append data */ - if ( ( datafile = fopen( datafilename, "w" ) ) == 0 ) - { - char errstr[80]; - sprintf( errstr,"(%s)",datafilename ); - return getGlobalMessageHandler( )->throwError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - } - } - - /* 2) Write data into file. */ - for( i=0; ithrowError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - } - } - else - { - /* do not append data */ - if ( ( datafile = fopen( datafilename, "w" ) ) == 0 ) - { - char errstr[80]; - sprintf( errstr,"(%s)",datafilename ); - return getGlobalMessageHandler( )->throwError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - } - } - - /* 2) Write data into file. */ - for( i=0; i + +#if defined(__WIN32__) || defined(WIN32) + #include +#elif defined(LINUX) + #include + #include +#endif + +#ifdef __MATLAB__ + #include +#endif + + +#include + + + +#ifdef PC_DEBUG /* Define print functions only for debugging! */ +/* + * p r i n t + */ +returnValue print( const real_t* const v, int n ) +{ + int i; + char myPrintfString[160]; + + /* Print a vector. */ + myPrintf( "[\t" ); + for( i=0; ithrowError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); + } + + /* 2) Read data from file. */ + for( i=0; ithrowError( RET_UNABLE_TO_READ_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); + } + data[i*ncol + j] = ( (real_t) float_data ); + } + } + + /* 3) Close file. */ + fclose( datafile ); + + return SUCCESSFUL_RETURN; +} + + +/* + * r e a d F r o m F i l e + */ +returnValue readFromFile( real_t* data, int n, + const char* datafilename + ) +{ + return readFromFile( data, n, 1, datafilename ); +} + + + +/* + * r e a d F r o m F i l e + */ +returnValue readFromFile( int* data, int n, + const char* datafilename + ) +{ + int i; + myFILE* datafile; + + /* 1) Open file. */ + if ( ( datafile = fopen( datafilename, "r" ) ) == 0 ) + { + char errstr[80]; + sprintf( errstr,"(%s)",datafilename ); + return getGlobalMessageHandler( )->throwError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); + } + + /* 2) Read data from file. */ + for( i=0; ithrowError( RET_UNABLE_TO_READ_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); + } + } + + /* 3) Close file. */ + fclose( datafile ); + + return SUCCESSFUL_RETURN; +} + + +/* + * w r i t e I n t o F i l e + */ +returnValue writeIntoFile( const real_t* const data, int nrow, int ncol, + const char* datafilename, BooleanType append + ) +{ + int i, j; + myFILE* datafile; + + /* 1) Open file. */ + if ( append == BT_TRUE ) + { + /* append data */ + if ( ( datafile = fopen( datafilename, "a" ) ) == 0 ) + { + char errstr[80]; + sprintf( errstr,"(%s)",datafilename ); + return getGlobalMessageHandler( )->throwError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); + } + } + else + { + /* do not append data */ + if ( ( datafile = fopen( datafilename, "w" ) ) == 0 ) + { + char errstr[80]; + sprintf( errstr,"(%s)",datafilename ); + return getGlobalMessageHandler( )->throwError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); + } + } + + /* 2) Write data into file. */ + for( i=0; ithrowError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); + } + } + else + { + /* do not append data */ + if ( ( datafile = fopen( datafilename, "w" ) ) == 0 ) + { + char errstr[80]; + sprintf( errstr,"(%s)",datafilename ); + return getGlobalMessageHandler( )->throwError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); + } + } + + /* 2) Write data into file. */ + for( i=0; i #include "DiagLog/Options.hpp" #include "DlSystem/String.hpp" +#include "DlSystem/ZdlExportDefine.hpp" namespace zdl { @@ -26,10 +23,10 @@ namespace DiagLog @{ */ /// @brief . -/// +/// /// Interface for controlling logging for zdl components. -class ZDL_LOGGING_EXPORT IDiagLog +class ZDL_EXPORT IDiagLog { public: @@ -48,7 +45,7 @@ class ZDL_LOGGING_EXPORT IDiagLog /// /// @return Diag log options object. virtual Options getOptions() = 0; - + /// @brief . /// /// Allows for setting the log mask once diag logging has started diff --git a/phonelibs/snpe/include/DiagLog/Options.hpp b/phonelibs/snpe/include/DiagLog/Options.hpp index ba0c82119bfebb..798fa3f1240a62 100644 --- a/phonelibs/snpe/include/DiagLog/Options.hpp +++ b/phonelibs/snpe/include/DiagLog/Options.hpp @@ -1,6 +1,6 @@ //============================================================================= // -// Copyright (c) 2015 Qualcomm Technologies, Inc. +// Copyright (c) 2015, 2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -8,12 +8,8 @@ #ifndef __DIAGLOG_OPTIONS_HPP_ #define __DIAGLOG_OPTIONS_HPP_ -#ifndef ZDL_LOGGING_EXPORT -#define ZDL_LOGGING_EXPORT __attribute__((visibility("default"))) -#endif - #include -#include +#include "DlSystem/ZdlExportDefine.hpp" namespace zdl { @@ -25,26 +21,27 @@ namespace DiagLog /// @brief . /// /// Options for setting up diagnostic logging for zdl components. -class ZDL_LOGGING_EXPORT Options +class ZDL_EXPORT Options { public: Options() : DiagLogMask(""), LogFileDirectory("diaglogs"), LogFileName("DiagLog"), - LogFileRotateCount(20) + LogFileRotateCount(20), + LogFileReplace(true) { // Solves the empty string problem with multiple std libs DiagLogMask.reserve(1); } /// @brief . - /// + /// /// Enables diag logging only on the specified area mask (DNN_RUNTIME=ON | OFF) std::string DiagLogMask; /// @brief . - /// + /// /// The path to the directory where log files will be written. /// The path may be relative or absolute. Relative paths are interpreted /// from the current working directory. @@ -52,19 +49,26 @@ class ZDL_LOGGING_EXPORT Options std::string LogFileDirectory; /// @brief . - /// + /// //// The name used for log files. If this value is empty then BaseName will be /// used as the default file name. /// Default value is "DiagLog" std::string LogFileName; /// @brief . - /// - /// The maximum number of log files to create. If set to 0 no log rotation + /// + /// The maximum number of log files to create. If set to 0 no log rotation /// will be used and the log file name specified will be used each time, overwriting /// any existing log file that may exist. /// Default value is 20 uint32_t LogFileRotateCount; + + /// @brief + /// + /// If the log file already exists, control whether it will be replaced + /// (existing contents truncated), or appended. + /// Default value is true + bool LogFileReplace; }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ diff --git a/phonelibs/snpe/include/DlContainer/IDlContainer.hpp b/phonelibs/snpe/include/DlContainer/IDlContainer.hpp index c4b465fd04bbe6..4e29b39bb41eb8 100644 --- a/phonelibs/snpe/include/DlContainer/IDlContainer.hpp +++ b/phonelibs/snpe/include/DlContainer/IDlContainer.hpp @@ -1,6 +1,6 @@ //============================================================================= // -// Copyright (c) 2015 Qualcomm Technologies, Inc. +// Copyright (c) 2015-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -14,7 +14,6 @@ #include #include #include -#include #include "DlSystem/ZdlExportDefine.hpp" #include "DlSystem/String.hpp" @@ -43,7 +42,15 @@ struct ZDL_EXPORT DlcRecord : name(std::move(other.name)) , data(std::move(other.data)) {} - + DlcRecord(const std::string& new_name) + : name(new_name) + , data() + { + if(name.empty()) + { + name.reserve(1); + } + } DlcRecord(const DlcRecord&) = delete; }; @@ -63,12 +70,12 @@ class ZDL_EXPORT IDlContainer public: /** * Initializes a container from a container archive file. - * + * * @param[in] filename Container archive file path. - * + * * @return A pointer to the initialized container */ - ZDL_EXPORT static std::unique_ptr + static std::unique_ptr open(const std::string &filename) noexcept; /** @@ -78,31 +85,31 @@ class ZDL_EXPORT IDlContainer * * @return A pointer to the initialized container */ - ZDL_EXPORT static std::unique_ptr + static std::unique_ptr open(const zdl::DlSystem::String &filename) noexcept; /** * Initializes a container from a byte buffer. - * - * @param[in] buffer Byte buffer holding the contents of an archive + * + * @param[in] buffer Byte buffer holding the contents of an archive * file. - * + * * @return A pointer to the initialized container */ - ZDL_EXPORT static std::unique_ptr + static std::unique_ptr open(const std::vector &buffer) noexcept; /** * Initializes a container from a byte buffer. - * - * @param[in] buffer Byte buffer holding the contents of an archive + * + * @param[in] buffer Byte buffer holding the contents of an archive * file. * * @param[in] size Size of the byte buffer. - * + * * @return A pointer to the initialized container */ - ZDL_EXPORT static std::unique_ptr + static std::unique_ptr open(const uint8_t* buffer, const size_t size) noexcept; @@ -110,8 +117,8 @@ class ZDL_EXPORT IDlContainer /** * Get the record catalog for a container. - * - * @param[out] catalog Buffer that will hold the record names on + * + * @param[out] catalog Buffer that will hold the record names on * return. */ virtual void getCatalog(std::set &catalog) const = 0; @@ -126,7 +133,7 @@ class ZDL_EXPORT IDlContainer /** * Get a record from a container by name. - * + * * @param[in] name Name of the record to fetch. * @param[out] record The passed in record will be populated with the * record data on return. Note that the caller @@ -146,6 +153,34 @@ class ZDL_EXPORT IDlContainer */ virtual void getRecord(const zdl::DlSystem::String &name, DlcRecord &record) const = 0; + /** + * Save the container to an archive on disk. This function will save the + * container if the filename is different from the file that it was opened + * from, or if at least one record was modified since the container was + * opened. + * + * It will truncate any existing file at the target path. + * + * @param filename Container archive file path. + * + * @return indication of success/failure + */ + virtual bool save(const std::string &filename) = 0; + + /** + * Save the container to an archive on disk. This function will save the + * container if the filename is different from the file that it was opened + * from, or if at least one record was modified since the container was + * opened. + * + * It will truncate any existing file at the target path. + * + * @param filename Container archive file path. + * + * @return indication of success/failure + */ + virtual bool save (const zdl::DlSystem::String &filename) = 0; + virtual ~IDlContainer() {} }; diff --git a/phonelibs/snpe/include/DlSystem/DlEnums.hpp b/phonelibs/snpe/include/DlSystem/DlEnums.hpp index fde252ca7f6742..14470635538767 100644 --- a/phonelibs/snpe/include/DlSystem/DlEnums.hpp +++ b/phonelibs/snpe/include/DlSystem/DlEnums.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2014-2018 Qualcomm Technologies, Inc. +// Copyright (c) 2014-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -43,6 +43,12 @@ enum class Runtime_t /// Math: float 16bit GPU_FLOAT16 = 3, + /// Run the processing on Snapdragon AIX+HVX. + /// Data: 8bit fixed point Tensorflow style format + /// Math: 8bit fixed point Tensorflow style format + AIP_FIXED8_TF = 5, + AIP_FIXED_TF = AIP_FIXED8_TF, + /// Default legacy enum to retain backward compatibility. /// CPU = CPU_FLOAT32 CPU = CPU_FLOAT32, @@ -53,7 +59,23 @@ enum class Runtime_t /// Default legacy enum to retain backward compatibility. /// DSP = DSP_FIXED8_TF - DSP = DSP_FIXED8_TF + DSP = DSP_FIXED8_TF, + + /// Special value indicating the property is unset. + UNSET = -1 +}; + +/** + * Enumeration of runtime available check options. + */ +enum class RuntimeCheckOption_t +{ + /// Perform standard runtime available check + DEFAULT = 0, + /// Perform standard runtime available check + NORMAL_CHECK = 0, + /// Perform basic runtime available check, may be runtime specific + BASIC_CHECK = 1, }; /** @@ -68,17 +90,51 @@ enum class PerformanceProfile_t BALANCED = 0, /// Run in high performance mode - HIGH_PERFORMANCE, + HIGH_PERFORMANCE = 1, /// Run in a power sensitive mode, at the expense of performance. - POWER_SAVER, + POWER_SAVER = 2, /// Use system settings. SNPE makes no calls to any performance related APIs. - SYSTEM_SETTINGS, + SYSTEM_SETTINGS = 3, /// Run in sustained high performance mode - SUSTAINED_HIGH_PERFORMANCE + SUSTAINED_HIGH_PERFORMANCE = 4, + /// Run in burst mode + BURST = 5, + + /// Run in lower clock than POWER_SAVER, at the expense of performance. + LOW_POWER_SAVER = 6, + + /// Run in higher clock and provides better performance than POWER_SAVER. + HIGH_POWER_SAVER = 7, + + /// Run in lower balanced mode + LOW_BALANCED = 8, +}; + +/** + * Enumeration of various profilngLevels that can be requested. + */ +enum class ProfilingLevel_t +{ + /// No profiling. + /// Collects no runtime stats in the DiagLog + OFF = 0, + + /// Basic profiling + /// Collects some runtime stats in the DiagLog + BASIC = 1, + + /// Detailed profiling + /// Collects more runtime stats in the DiagLog, including per-layer statistics + /// Performance may be impacted + DETAILED = 2, + + /// Moderate profiling + /// Collects more runtime stats in the DiagLog, no per-layer statistics + MODERATE = 3 }; /** @@ -90,10 +146,10 @@ enum class ExecutionPriorityHint_t NORMAL = 0, /// Higher than normal priority - HIGH, + HIGH = 1, /// Lower priority - LOW + LOW = 2 }; @@ -110,34 +166,34 @@ enum class ImageEncoding_t /// The RGB format consists of 3 bytes per pixel: one byte for /// Red, one for Green, and one for Blue. The byte ordering is /// endian independent and is always in RGB byte order. - RGB, + RGB = 1, /// The ARGB32 format consists of 4 bytes per pixel: one byte for /// Red, one for Green, one for Blue, and one for the alpha channel. /// The alpha channel is ignored. The byte ordering depends on the /// underlying CPU. For little endian CPUs, the byte order is BGRA. /// For big endian CPUs, the byte order is ARGB. - ARGB32, + ARGB32 = 2, /// The RGBA format consists of 4 bytes per pixel: one byte for /// Red, one for Green, one for Blue, and one for the alpha channel. /// The alpha channel is ignored. The byte ordering is endian independent /// and is always in RGBA byte order. - RGBA, + RGBA = 3, /// The GRAYSCALE format is for 8-bit grayscale. - GRAYSCALE, + GRAYSCALE = 4, /// NV21 is the Android version of YUV. The Chrominance is down /// sampled and has a subsampling ratio of 4:2:0. Note that this /// image format has 3 channels, but the U and V channels /// are subsampled. For every four Y pixels there is one U and one V pixel. @newpage - NV21, + NV21 = 5, /// The BGR format consists of 3 bytes per pixel: one byte for /// Red, one for Green and one for Blue. The byte ordering is /// endian independent and is always BGR byte order. - BGR + BGR = 6 }; }} // namespaces end diff --git a/phonelibs/snpe/include/DlSystem/DlError.hpp b/phonelibs/snpe/include/DlSystem/DlError.hpp index 383403b5418a26..f0a66e8e458ad1 100644 --- a/phonelibs/snpe/include/DlSystem/DlError.hpp +++ b/phonelibs/snpe/include/DlSystem/DlError.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2016-18 Qualcomm Technologies, Inc. +// Copyright (c) 2016-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -34,6 +34,7 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { SNPE_CONFIG_WRONG_INPUT_NAME = 105, SNPE_CONFIG_INCORRECT_INPUT_DIMENSIONS = 106, SNPE_CONFIG_DIMENSIONS_MODIFICATION_NOT_SUPPORTED = 107, + SNPE_CONFIG_BOTH_OUTPUT_LAYER_TENSOR_NAMES_SET = 108, SNPE_CONFIG_NNCONFIG_ONLY_TENSOR_SUPPORTED = 120, SNPE_CONFIG_NNCONFIG_ONLY_USER_BUFFER_SUPPORTED = 121, @@ -56,8 +57,11 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { SNPE_DLSYSTEM_BUFFER_MANAGER_MISSING = 214, SNPE_DLSYSTEM_RUNTIME_BUFFER_SOURCE_UNSUPPORTED = 215, SNPE_DLSYSTEM_BUFFER_CAST_FAILED = 216, + SNPE_DLSYSTEM_WRONG_TRANSITION_TYPE = 217, + SNPE_DLSYSTEM_LAYER_ALREADY_REGISTERED = 218, SNPE_DLSYSTEM_BUFFERENCODING_UNKNOWN = 240, + SNPE_DLSYSTEM_BUFFER_INVALID_PARAM = 241, // DlContainer errors SNPE_DLCONTAINER_MODEL_PARSING_FAILED = 300, @@ -75,6 +79,7 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { SNPE_DLCONTAINER_BAD_DNN_FORMAT_VERSION = 312, SNPE_DLCONTAINER_UNKNOWN_AXIS_ANNOTATION = 313, SNPE_DLCONTAINER_UNKNOWN_SHUFFLE_TYPE = 314, + SNPE_DLCONTAINER_TEMP_FILE_FAILURE = 315, // Network errors SNPE_NETWORK_EMPTY_NETWORK = 400, @@ -95,6 +100,7 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { SNPE_CPU_LAYER_PARAM_COMBINATION_INVALID = 603, SNPE_CPU_BUFFER_NOT_FOUND = 604, SNPE_CPU_NETWORK_NOT_SUPPORTED = 605, + SNPE_CPU_UDO_OPERATION_FAILED = 606, // CPU fixed-point runtime errors SNPE_CPU_FXP_LAYER_NOT_SUPPORTED = 700, @@ -119,7 +125,8 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { SNPE_GPU_LAYER_PROXY_ERROR = 814, SNPE_GPU_BUFFER_IN_USE = 815, SNPE_GPU_BUFFER_MODIFICATION_ERROR = 816, - + SNPE_GPU_DATA_ARRANGEMENT_INVALID = 817, + SNPE_GPU_UDO_OPERATION_FAILED = 818, // DSP runtime errors SNPE_DSP_LAYER_NOT_SUPPORTED = 900, SNPE_DSP_LAYER_PARAM_NOT_SUPPORTED = 901, @@ -132,6 +139,7 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { SNPE_DSP_RUNTIME_COMMUNICATION_ERROR = 908, SNPE_DSP_RUNTIME_INVALID_PARAM_ERROR = 909, SNPE_DSP_RUNTIME_SYSTEM_ERROR = 910, + SNPE_DSP_RUNTIME_CRASHED_ERROR = 911, // Model validataion errors SNPE_MODEL_VALIDATION_LAYER_NOT_SUPPORTED = 1000, @@ -143,6 +151,8 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { SNPE_MODEL_VALIDATION_INVALID_CONSTRAINT = 1006, SNPE_MODEL_VALIDATION_MISSING_BUFFER = 1007, SNPE_MODEL_VALIDATION_BUFFER_REUSE_NOT_SUPPORTED = 1008, + SNPE_MODEL_VALIDATION_LAYER_COULD_NOT_BE_ASSIGNED = 1009, + SNPE_MODEL_VALIDATION_UDO_LAYER_FAILED = 1010, // UDL errors SNPE_UDL_LAYER_EMPTY_UDL_NETWORK = 1100, @@ -151,6 +161,9 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { SNPE_UDL_LAYER_SETUP_FAILED = 1103, SNPE_UDL_EXECUTE_FAILED = 1104, SNPE_UDL_BUNDLE_INVALID = 1105, + SNPE_UDO_REGISTRATION_FAILED = 1106, + SNPE_UDO_GET_PACKAGE_FAILED = 1107, + SNPE_UDO_GET_IMPLEMENTATION_FAILED = 1108, // Dependent library errors SNPE_STD_LIBRARY_ERROR = 1200, @@ -161,6 +174,30 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { // Storage Errors SNPE_STORAGE_INVALID_KERNEL_REPO = 1300, + // AIP runtime errors + SNPE_AIP_LAYER_NOT_SUPPORTED = 1400, + SNPE_AIP_LAYER_PARAM_NOT_SUPPORTED = 1401, + SNPE_AIP_LAYER_PARAM_INVALID = 1402, + SNPE_AIP_LAYER_PARAM_COMBINATION_INVALID = 1403, + SNPE_AIP_STUB_NOT_PRESENT = 1404, + SNPE_AIP_LAYER_NAME_TRUNCATED = 1405, + SNPE_AIP_LAYER_INPUT_BUFFER_NAME_TRUNCATED = 1406, + SNPE_AIP_LAYER_OUTPUT_BUFFER_NAME_TRUNCATED = 1407, + SNPE_AIP_RUNTIME_COMMUNICATION_ERROR = 1408, + SNPE_AIP_RUNTIME_INVALID_PARAM_ERROR = 1409, + SNPE_AIP_RUNTIME_SYSTEM_ERROR = 1410, + SNPE_AIP_RUNTIME_TENSOR_MISSING = 1411, + SNPE_AIP_RUNTIME_TENSOR_SHAPE_MISMATCH = 1412, + SNPE_AIP_RUNTIME_BAD_AIX_RECORD = 1413, + + // DlCaching errors + SNPE_DLCACHING_INVALID_METADATA = 1500, + SNPE_DLCACHING_INVALID_INITBLOB = 1501, + + // Infrastructure Errors + SNPE_INFRA_CLUSTERMGR_INSTANCE_INVALID = 1600, + SNPE_INFRA_CLUSTERMGR_EXECUTE_SYNC_FAILED = 1601 + }; @@ -187,6 +224,11 @@ ZDL_EXPORT ErrorCode getLastErrorCode(); */ ZDL_EXPORT const char* getLastErrorString(); +/** + * Returns the info string of the last error encountered. + */ +ZDL_EXPORT const char* getLastInfoString(); + /** * Returns the uint32_t representation of the error code enum. * diff --git a/phonelibs/snpe/include/DlSystem/DlOptional.hpp b/phonelibs/snpe/include/DlSystem/DlOptional.hpp index 2c41b6b6894ee4..4f83e6b4e417fc 100644 --- a/phonelibs/snpe/include/DlSystem/DlOptional.hpp +++ b/phonelibs/snpe/include/DlSystem/DlOptional.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2016 Qualcomm Technologies, Inc. +// Copyright (c) 2016, 2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -11,6 +11,7 @@ #include #include +#include #include "DlSystem/ZdlExportDefine.hpp" @@ -35,10 +36,10 @@ template class ZDL_EXPORT Optional final { public: enum class LIFECYCLE { - NONE, - REFERENCE_OWNED, - POINTER_OWNED, - POINTER_NOT_OWNED + NONE = 0, + REFERENCE_OWNED = 1, + POINTER_OWNED = 2, + POINTER_NOT_OWNED = 3 }; struct ReferenceCount { @@ -173,25 +174,25 @@ class ZDL_EXPORT Optional final { template typename std::enable_if::value, const Q&>::type GetReference() const noexcept { - if (!isReference()) throw std::bad_exception(); + if (!isReference()) std::terminate(); return *static_cast(m_StoragePtr); } template typename std::enable_if::value, const Q&>::type GetReference() const noexcept { - if (!isPointer()) throw std::bad_exception(); + if (!isPointer()) std::terminate(); return static_cast(m_StoragePtr); } template typename std::enable_if::value, Q&>::type GetReference() noexcept { - if (!isReference()) throw std::bad_exception(); + if (!isReference()) std::terminate(); return *m_StoragePtr; } template typename std::enable_if::value, Q&>::type GetReference() noexcept { - if (!isPointer()) throw std::bad_exception(); + if (!isPointer()) std::terminate(); return m_StoragePtr; } diff --git a/phonelibs/snpe/include/DlSystem/IBufferAttributes.hpp b/phonelibs/snpe/include/DlSystem/IBufferAttributes.hpp index e80f6c134c9ab4..f893e0a2370880 100644 --- a/phonelibs/snpe/include/DlSystem/IBufferAttributes.hpp +++ b/phonelibs/snpe/include/DlSystem/IBufferAttributes.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2017 Qualcomm Technologies, Inc. +// Copyright (c) 2017-2019 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -21,7 +21,6 @@ namespace zdl { namespace zdl { namespace DlSystem { - /** * @brief IBufferAttributes returns a buffer's dimension and alignment * requirements, along with info on its encoding type @@ -65,6 +64,15 @@ class ZDL_EXPORT IBufferAttributes { */ virtual const TensorShape getAlignments() const noexcept = 0; + /** + * @brief Gets the buffer encoding returned from the network responsible + * for generating this buffer. Depending on the encoding type, this will + * be an instance of an encoding type specific derived class. + * + * @return Derived user buffer encoding object. + */ + virtual zdl::DlSystem::UserBufferEncoding* getEncoding() const noexcept = 0; + virtual ~IBufferAttributes() {} }; diff --git a/phonelibs/snpe/include/DlSystem/ITensor.hpp b/phonelibs/snpe/include/DlSystem/ITensor.hpp index ed6d5f1072e888..2f006c857fc442 100644 --- a/phonelibs/snpe/include/DlSystem/ITensor.hpp +++ b/phonelibs/snpe/include/DlSystem/ITensor.hpp @@ -1,6 +1,6 @@ //============================================================================= // -// Copyright (c) 2015-2018 Qualcomm Technologies, Inc. +// Copyright (c) 2015-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -14,7 +14,6 @@ #include "TensorShape.hpp" #include "ZdlExportDefine.hpp" #include -#include #include #include diff --git a/phonelibs/snpe/include/DlSystem/ITensorItrImpl.hpp b/phonelibs/snpe/include/DlSystem/ITensorItrImpl.hpp index 7923c160b95b0d..069e7a1d69031f 100644 --- a/phonelibs/snpe/include/DlSystem/ITensorItrImpl.hpp +++ b/phonelibs/snpe/include/DlSystem/ITensorItrImpl.hpp @@ -1,6 +1,6 @@ //============================================================================= // -// Copyright (c) 2015 Qualcomm Technologies, Inc. +// Copyright (c) 2015-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -13,7 +13,6 @@ #include #include -#include namespace DlSystem { diff --git a/phonelibs/snpe/include/DlSystem/IUserBuffer.hpp b/phonelibs/snpe/include/DlSystem/IUserBuffer.hpp index 70f6b33cbba1a9..5e5731dd83a41d 100644 --- a/phonelibs/snpe/include/DlSystem/IUserBuffer.hpp +++ b/phonelibs/snpe/include/DlSystem/IUserBuffer.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2017-2018 Qualcomm Technologies, Inc. +// Copyright (c) 2017-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -11,6 +11,7 @@ #include "TensorShape.hpp" #include "ZdlExportDefine.hpp" +#include namespace zdl { namespace DlSystem { @@ -44,7 +45,10 @@ class ZDL_EXPORT UserBufferEncoding { UNSIGNED8BIT = 2, /// Each element is presented by an 8-bit quantized value. - TF8 = 10 + TF8 = 10, + + /// Each element is presented by an 16-bit quantized value. + TF16 = 11 }; /** @@ -147,6 +151,7 @@ class ZDL_EXPORT UserBufferEncodingFloat : public UserBufferEncoding { * An encoding type where each element is represented by tf8, which is an * 8-bit quantizd value, which has an exact representation of 0.0 */ + class ZDL_EXPORT UserBufferEncodingTf8 : public UserBufferEncodingUnsigned8Bit { public: UserBufferEncodingTf8() = delete; @@ -155,60 +160,80 @@ class ZDL_EXPORT UserBufferEncodingTf8 : public UserBufferEncodingUnsigned8Bit { m_StepExactly0(stepFor0), m_QuantizedStepSize(stepSize) {}; - /** + UserBufferEncodingTf8(const zdl::DlSystem::UserBufferEncoding &ubEncoding) : UserBufferEncodingUnsigned8Bit(ubEncoding.getElementType()){ + const zdl::DlSystem::UserBufferEncodingTf8* ubEncodingTf8 + = dynamic_cast (&ubEncoding); + if (ubEncodingTf8) { + m_StepExactly0 = ubEncodingTf8->getStepExactly0(); + m_QuantizedStepSize = ubEncodingTf8->getQuantizedStepSize(); + } + } + +/** * @brief Sets the step value that represents 0 * * @param[in] stepExactly0 The step value that represents 0 * */ + void setStepExactly0(const unsigned char stepExactly0) { m_StepExactly0 = stepExactly0; } - /** + +/** * @brief Sets the float value that each step represents * * @param[in] quantizedStepSize The float value of each step size * */ + void setQuantizedStepSize(const float quantizedStepSize) { m_QuantizedStepSize = quantizedStepSize; } - /** + +/** * @brief Retrieves the step that represents 0.0 * * @return Step value */ + unsigned char getStepExactly0() const { return m_StepExactly0; } - /** + +/** * Calculates the minimum floating point value that * can be represented with this encoding. * * @return Minimum representable floating point value */ + float getMin() const { return m_QuantizedStepSize * (0 - m_StepExactly0); } - /** + +/** * Calculates the maximum floating point value that * can be represented with this encoding. * * @return Maximum representable floating point value */ + float getMax() const { return m_QuantizedStepSize * (255 - m_StepExactly0); } - /** + +/** * @brief Retrieves the step size * * @return Step size */ + float getQuantizedStepSize() const { return m_QuantizedStepSize; } @@ -219,6 +244,95 @@ class ZDL_EXPORT UserBufferEncodingTf8 : public UserBufferEncodingUnsigned8Bit { float m_QuantizedStepSize; }; + + +class ZDL_EXPORT UserBufferEncodingTfN : public UserBufferEncoding { +public: + UserBufferEncodingTfN() = delete; + UserBufferEncodingTfN(uint64_t stepFor0, float stepSize, uint8_t bWidth=8): + UserBufferEncoding(getTypeFromWidth(bWidth)), + bitWidth(bWidth), + m_StepExactly0(stepFor0), + m_QuantizedStepSize(stepSize){}; + + UserBufferEncodingTfN(const zdl::DlSystem::UserBufferEncoding &ubEncoding) : UserBufferEncoding(ubEncoding.getElementType()){ + const zdl::DlSystem::UserBufferEncodingTfN* ubEncodingTfN + = dynamic_cast (&ubEncoding); + if (ubEncodingTfN) { + m_StepExactly0 = ubEncodingTfN->getStepExactly0(); + m_QuantizedStepSize = ubEncodingTfN->getQuantizedStepSize(); + bitWidth = ubEncodingTfN->bitWidth; + } + } + + size_t getElementSize() const noexcept override; + /** + * @brief Sets the step value that represents 0 + * + * @param[in] stepExactly0 The step value that represents 0 + * + */ + void setStepExactly0(uint64_t stepExactly0) { + m_StepExactly0 = stepExactly0; + } + + /** + * @brief Sets the float value that each step represents + * + * @param[in] quantizedStepSize The float value of each step size + * + */ + void setQuantizedStepSize(const float quantizedStepSize) { + m_QuantizedStepSize = quantizedStepSize; + } + + /** + * @brief Retrieves the step that represents 0.0 + * + * @return Step value + */ + uint64_t getStepExactly0() const { + return m_StepExactly0; + } + + /** + * Calculates the minimum floating point value that + * can be represented with this encoding. + * + * @return Minimum representable floating point value + */ + float getMin() const { + return static_cast(m_QuantizedStepSize * (0 - (double)m_StepExactly0)); + } + + /** + * Calculates the maximum floating point value that + * can be represented with this encoding. + * + * @return Maximum representable floating point value + */ + float getMax() const{ + return static_cast(m_QuantizedStepSize * (pow(2,bitWidth)-1 - (double)m_StepExactly0)); + }; + + /** + * @brief Retrieves the step size + * + * @return Step size + */ + float getQuantizedStepSize() const { + return m_QuantizedStepSize; + } + + ElementType_t getTypeFromWidth(uint8_t width); + + uint8_t bitWidth; +private: + uint64_t m_StepExactly0; + float m_QuantizedStepSize; +}; + + /** * @brief UserBuffer contains a pointer and info on how to walk it and interpret its content. */ @@ -243,6 +357,24 @@ class ZDL_EXPORT IUserBuffer { */ virtual size_t getSize() const = 0; + /** + * @brief Retrieves the size of the inference data in the buffer, in bytes. + * + * The inference results from a dynamic-sized model may not be exactly the same size + * as the UserBuffer provided to SNPE. This function can be used to get the amount + * of output inference data, which may be less or greater than the size of the UserBuffer. + * + * If the inference results fit in the UserBuffer, getOutputSize() would be less than + * or equal to getSize(). But if the inference results were more than the capacity of + * the provided UserBuffer, the results would be truncated to fit the UserBuffer. But, + * getOutputSize() would be greater than getSize(), which indicates a bigger buffer + * needs to be provided to SNPE to hold all of the inference results. + * + * @return Size required for the buffer to hold all inference results, which can be less + * or more than the size of the buffer, in bytes. + */ + virtual size_t getOutputSize() const = 0; + /** * @brief Changes the underlying memory that backs the UserBuffer. * diff --git a/phonelibs/snpe/include/DlSystem/PlatformConfig.hpp b/phonelibs/snpe/include/DlSystem/PlatformConfig.hpp index df452dc46970bf..3f15f177e3eeba 100644 --- a/phonelibs/snpe/include/DlSystem/PlatformConfig.hpp +++ b/phonelibs/snpe/include/DlSystem/PlatformConfig.hpp @@ -10,6 +10,7 @@ #define _DL_SYSTEM_PLATFORM_CONFIG_HPP_ #include "DlSystem/ZdlExportDefine.hpp" +#include namespace zdl{ namespace DlSystem @@ -92,7 +93,8 @@ class ZDL_EXPORT PlatformConfig PlatformConfigInfo(){}; }; - PlatformConfig() : m_PlatformType(PlatformType_t::UNKNOWN) {}; + PlatformConfig() : m_PlatformType(PlatformType_t::UNKNOWN), + m_PlatformOptions("") {}; /** * @brief Retrieves the platform type @@ -156,9 +158,42 @@ class ZDL_EXPORT PlatformConfig return false; } + /** + * @brief Sets the platform options + * + * @param[in] options Options as a string in the form of "keyword:options" + * + * @return True if options are pass validation; otherwise false. If false, the options are not updated. + */ + bool setPlatformOptions(std::string options) { + std::string oldOptions = m_PlatformOptions; + m_PlatformOptions = options; + if (isOptionsValid()) { + return true; + } else { + m_PlatformOptions = oldOptions; + return false; + } + } + + /** + * @brief Indicates whther the plaform configuration is valid. + * + * @return True if the platform configuration is valid; false otherwise. + */ + bool isOptionsValid() const; + + /** + * @brief Gets the platform options + * + * @return Options as a string + */ + std::string getPlatformOptions() const { return m_PlatformOptions; } + private: PlatformType_t m_PlatformType; PlatformConfigInfo m_PlatformConfigInfo; + std::string m_PlatformOptions; }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ diff --git a/phonelibs/snpe/include/DlSystem/RuntimeList.hpp b/phonelibs/snpe/include/DlSystem/RuntimeList.hpp new file mode 100644 index 00000000000000..1088a5b31f4538 --- /dev/null +++ b/phonelibs/snpe/include/DlSystem/RuntimeList.hpp @@ -0,0 +1,154 @@ +//============================================================================= +// +// Copyright (c) 2019 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================= + +#include "ZdlExportDefine.hpp" +#include "DlSystem/DlEnums.hpp" +#include "DlSystem/StringList.hpp" +#include +#include + +#ifndef DL_SYSTEM_RUNTIME_LIST_HPP +#define DL_SYSTEM_RUNTIME_LIST_HPP + +namespace DlSystem +{ + // Forward declaration of Runtime List implementation. + class RuntimeListImpl; +} + +namespace zdl +{ +namespace DlSystem +{ + +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +/** + * @brief . + * + * A class representing list of runtimes + */ +class ZDL_EXPORT RuntimeList final +{ +public: + + /** + * @brief . + * + * Creates a new runtime list + * + */ + RuntimeList(); + + /** + * @brief . + * + * copy constructor. + * @param[in] other object to copy. + */ + RuntimeList(const RuntimeList& other); + + /** + * @brief . + * + * constructor with single Runtime_t object + * @param[in] Runtime_t object + */ + RuntimeList(const zdl::DlSystem::Runtime_t& runtime); + + /** + * @brief . + * + * assignment operator. + */ + RuntimeList& operator=(const RuntimeList& other); + + /** + * @brief . + * + * subscript operator. + */ + Runtime_t& operator[](size_t index); + + /** + * @brief Adds runtime to the end of the runtime list + * order of precedence is former followed by latter entry + * + * @param[in] runtime to add + * + * Ruturns false If the runtime already exists + */ + bool add(const zdl::DlSystem::Runtime_t& runtime); + + /** + * @brief Removes the runtime from the list + * + * @param[in] runtime to be removed + * + * @note If the runtime is not found, nothing is done. + */ + void remove(const zdl::DlSystem::Runtime_t runtime) noexcept; + + /** + * @brief Returns the number of runtimes in the list + */ + size_t size() const noexcept; + + /** + * @brief Returns true if the list is empty + */ + bool empty() const noexcept; + + /** + * @brief . + * + * Removes all runtime from the list + */ + void clear() noexcept; + + /** + * @brief . + * + * Returns a StringList of names from the runtime list in + * order of precedence + */ + zdl::DlSystem::StringList getRuntimeListNames() const; + + /** + * @brief . + * + * @param[in] runtime string + * Returns a Runtime enum corresponding to the in param string + * + */ + static zdl::DlSystem::Runtime_t stringToRuntime(const char* runtimeStr); + + /** + * @brief . + * + * @param[in] runtime + * Returns a string corresponding to the in param runtime enum + * + */ + static const char* runtimeToString(const zdl::DlSystem::Runtime_t runtime); + + ~RuntimeList(); + +private: + void deepCopy(const RuntimeList &other); + std::unique_ptr<::DlSystem::RuntimeListImpl> m_RuntimeListImpl; +}; + +} // DlSystem namespace +} // zdl namespace + +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ + +#endif // DL_SYSTEM_RUNTIME_LIST_HPP + diff --git a/phonelibs/snpe/include/DlSystem/String.hpp b/phonelibs/snpe/include/DlSystem/String.hpp index 97b07726c72bc7..c1eba3bad96b02 100644 --- a/phonelibs/snpe/include/DlSystem/String.hpp +++ b/phonelibs/snpe/include/DlSystem/String.hpp @@ -1,6 +1,6 @@ //============================================================================= // -// Copyright (c) 2017 Qualcomm Technologies, Inc. +// Copyright (c) 2017, 2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -12,10 +12,7 @@ #include #include #include - -#ifndef ZDL_EXPORT -#define ZDL_EXPORT __attribute__((visibility("default"))) -#endif +#include "DlSystem/ZdlExportDefine.hpp" namespace zdl { @@ -105,4 +102,3 @@ ZDL_EXPORT std::ostream& operator<<(std::ostream& os, const String& str) noexcep /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #endif // PLATFORM_STANDARD_STRING_HPP - diff --git a/phonelibs/snpe/include/DlSystem/TensorShapeMap.hpp b/phonelibs/snpe/include/DlSystem/TensorShapeMap.hpp index 00dc41a113160d..cef946e2e6dbc9 100644 --- a/phonelibs/snpe/include/DlSystem/TensorShapeMap.hpp +++ b/phonelibs/snpe/include/DlSystem/TensorShapeMap.hpp @@ -1,6 +1,6 @@ //============================================================================= // -// Copyright (c) 2017 Qualcomm Technologies, Inc. +// Copyright (c) 2017-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -8,7 +8,6 @@ #include #include #include -#include #include "ZdlExportDefine.hpp" #include "DlSystem/TensorShape.hpp" #include "DlSystem/StringList.hpp" diff --git a/phonelibs/snpe/include/DlSystem/ZdlExportDefine.hpp b/phonelibs/snpe/include/DlSystem/ZdlExportDefine.hpp index dd0704dd8c996d..92eb786d312f6d 100644 --- a/phonelibs/snpe/include/DlSystem/ZdlExportDefine.hpp +++ b/phonelibs/snpe/include/DlSystem/ZdlExportDefine.hpp @@ -1,16 +1,13 @@ //============================================================================= // -// Copyright (c) 2015 Qualcomm Technologies, Inc. +// Copyright (c) 2015, 2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================= -#ifndef _ZDL_EXPORT_DEFINE_HPP_ -#define _ZDL_EXPORT_DEFINE_HPP_ +#pragma once #ifndef ZDL_EXPORT -#define ZDL_EXPORT __attribute__((visibility("default"))) -#endif - +#define ZDL_EXPORT #endif diff --git a/phonelibs/snpe/include/PlatformValidator/PlatformValidator.hpp b/phonelibs/snpe/include/PlatformValidator/PlatformValidator.hpp new file mode 100644 index 00000000000000..e74278ead7bff5 --- /dev/null +++ b/phonelibs/snpe/include/PlatformValidator/PlatformValidator.hpp @@ -0,0 +1,93 @@ +// ============================================================================= +// +// Copyright (c) 2018-2019 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +// ============================================================================= + +#ifndef SNPE_PLATFORMVALIDATOR_HPP +#define SNPE_PLATFORMVALIDATOR_HPP + +#include "DlSystem/DlEnums.hpp" +#include "DlSystem/DlMacros.hpp" +SNPE_DISABLE_WARNINGS("-Wdelete-non-virtual-dtor","-Wdelete-non-virtual-dtor") +#include +#include +SNPE_ENABLE_WARNINGS + +namespace zdl +{ + namespace SNPE + { + class PlatformValidator; + + class IPlatformValidatorRuntime; + } +} + +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +/** +* The class for checking SNPE compatibility/capability of a device. +* +*/ + +class zdl::SNPE::PlatformValidator +{ +public: + /** + * @brief Default Constructor of the PlatformValidator Class + * + * @return A new instance of a PlatformValidator object + * that can be used to check the SNPE compatibility + * of a device + */ + PlatformValidator(); + + ~PlatformValidator(); + + /** + * @brief Sets the runtime processor for compatibility check + * + * @return Void + */ + void setRuntime(zdl::DlSystem::Runtime_t runtime); + + /** + * @brief Checks if the Runtime prerequisites for SNPE are available. + * + * @return True if the Runtime prerequisites are available, else false. + */ + bool isRuntimeAvailable(); + + /** + * @brief Returns the core version for the Runtime selected. + * + * @return String which contains the actual core version value + */ + std::string getCoreVersion(); + + /** + * @brief Returns the library version for the Runtime selected. + * + * @return String which contains the actual lib version value + */ + std::string getLibVersion(); + + /** + * @brief Runs a small program on the runtime and Checks if SNPE is supported for Runtime. + * + * @return If True, the device is ready for SNPE execution, else not. + */ + + bool runtimeCheck(); + +private: + zdl::DlSystem::Runtime_t m_runtimeType; + std::unique_ptr m_platformValidatorRuntime; +}; +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ + +#endif //SNPE_PLATFORMVALIDATOR_HPP diff --git a/phonelibs/snpe/include/SNPE/ApplicationBufferMap.hpp b/phonelibs/snpe/include/SNPE/ApplicationBufferMap.hpp new file mode 100644 index 00000000000000..380a3e0e6e77ee --- /dev/null +++ b/phonelibs/snpe/include/SNPE/ApplicationBufferMap.hpp @@ -0,0 +1,101 @@ +//============================================================================== +// +// Copyright (c) 2019 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================== + +#ifndef PSNPE_APPLICATIONBUFFERMAP_HPP +#define PSNPE_APPLICATIONBUFFERMAP_HPP +#include +#include +#include + +#include "DlSystem/UserBufferMap.hpp" +#include "DlSystem/ZdlExportDefine.hpp" + +namespace zdl +{ +namespace PSNPE +{ +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +/** + * @brief . + * + * A class representing the UserBufferMap of Input and Output asynchronous mode. + */ + +class ZDL_EXPORT ApplicationBufferMap final +{ + + public: + /** + * @brief Adds a name and the corresponding buffer + * to the map + * + * @param[in] name The name of the UserBuffer + * @param[in] buffer The vector of the uint8_t data + * + * @note If a UserBuffer with the same name already exists, the new + * UserBuffer pointer would be updated. + */ + void add(const char* name, std::vector& buff) noexcept; + void add(const char* name, std::vector& buff) noexcept; + /** + * @brief Removes a mapping of one UserBuffer and its name by its name + * + * @param[in] name The name of UserBuffer to be removed + * + * @note If no UserBuffer with the specified name is found, nothing + * is done. + */ + void remove(const char* name) noexcept; + + /** + * @brief Returns the number of UserBuffers in the map + */ + size_t size() const noexcept; + + /** + * @brief . + * + * Removes all UserBuffers from the map + */ + void clear() noexcept; + + /** + * @brief Returns the UserBuffer given its name. + * + * @param[in] name The name of the UserBuffer to get. + * + * @return nullptr if no UserBuffer with the specified name is + * found; otherwise, a valid pointer to the UserBuffer. + */ + const std::vector& getUserBuffer(const char* name) const; + const std::vector& operator[](const char* name) const; + /** + * @brief . + * + * Returns the names of all UserAsyncBufferMap + * + * @return A list of UserBuffer names. + */ + zdl::DlSystem::StringList getUserBufferNames() const; + const std::unordered_map>& getUserBuffer() const; + explicit ApplicationBufferMap(); + ~ApplicationBufferMap(); + explicit ApplicationBufferMap( + const std::unordered_map> buffer); + + private: + std::unordered_map> m_UserMap; +}; + +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ +} // namespace PSNPE +} // namespace zdl + +#endif // PSNPE_APPLICATIONBUFFERMAP_HPP diff --git a/phonelibs/snpe/include/SNPE/PSNPE.hpp b/phonelibs/snpe/include/SNPE/PSNPE.hpp new file mode 100644 index 00000000000000..c0a6fb55d67a45 --- /dev/null +++ b/phonelibs/snpe/include/SNPE/PSNPE.hpp @@ -0,0 +1,194 @@ +// ============================================================================= +// +// Copyright (c) 2019-2020 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +// ============================================================================= + +#ifndef PSNPE_HPP +#define PSNPE_HPP + +#include +#include +#include "SNPE/SNPE.hpp" +#include "DlSystem/UserBufferMap.hpp" +#include "DlContainer/IDlContainer.hpp" +#include "DlSystem/DlEnums.hpp" +#include "DlSystem/ZdlExportDefine.hpp" + +#include "UserBufferList.hpp" +#include "RuntimeConfigList.hpp" +#include "ApplicationBufferMap.hpp" + +namespace zdl +{ +namespace PSNPE +{ + +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +/** + *@ brief build snpe instance in serial or parallel + * + */ +enum ZDL_EXPORT BuildMode { + SERIAL = 0, + PARALLEL = 1 +}; +/** + * @brief Input and output transmission mode + */ +enum ZDL_EXPORT InputOutputTransmissionMode +{ + sync = 0, + outputAsync = 1, + inputOutputAsync = 2 +}; + +/** + * @brief A structure representing parameters of callback function of Async Output mode + */ +struct ZDL_EXPORT OutputAsyncCallbackParam +{ + size_t dataIndex; + bool executeStatus; + OutputAsyncCallbackParam(size_t _index,bool _status) + : dataIndex(_index),executeStatus(_status){}; +}; +/** + * @brief A structure representing parameters of callback function of Async Input/Output mode + */ +struct ZDL_EXPORT InputOutputAsyncCallbackParam +{ + size_t dataIndex; + const ApplicationBufferMap& outputMap; + bool executeStatus; + InputOutputAsyncCallbackParam(size_t _index, const ApplicationBufferMap& output_map,bool _status) + : dataIndex(_index) + , outputMap(output_map) + ,executeStatus(_status){ + + }; +}; +/** + * @brief This callback is called when the output data is ready, only use for Output Async mode + */ +using OutputAsyncCallbackFunc = std::function; +/** + * @brief This callback is called when the output data is ready, only use for Output-Input Async mode + */ +using InputOutputAsyncCallbackFunc = std::function; +/** + * @brief This callback is called when the input data is ready,only use for Output-Input Async mode + */ +using InputOutputAsyncInputCallback = std::function(const std::vector &, + const zdl::DlSystem::StringList &)>; +/** + * @brief . + * + * A structure PSNPE configuration + * + */ +struct ZDL_EXPORT BuildConfig final +{ + BuildMode buildMode = BuildMode::SERIAL; ///< Specify build in serial mode or parallel mode + zdl::DlContainer::IDlContainer* container;///< The opened container ptr + zdl::DlSystem::StringList outputBufferNames;///< Specify the output layer name + RuntimeConfigList runtimeConfigList;///< The runtime config list for PSNPE, @see RuntimeConfig + size_t inputThreadNumbers = 1;///< Specify the number of threads used in the execution phase to process input data, only used in inputOutputAsync mode + size_t outputThreadNumbers = 1;///< Specify the number of threads used in the execution phase to process output data, only used in inputOutputAsync and outputAsync mode + OutputAsyncCallbackFunc outputCallback;///< The callback to deal with output data ,only used in outputAsync mode + InputOutputAsyncCallbackFunc inputOutputCallback;///< The callback to deal with output data ,only used in inputOutputAsync mode + InputOutputAsyncInputCallback inputOutputInputCallback;///< The callback to deal with input data ,only used in inputOutputAsync mode + InputOutputTransmissionMode inputOutputTransmissionMode = InputOutputTransmissionMode::sync;///< Specify execution mode + zdl::DlSystem::ProfilingLevel_t profilingLevel = zdl::DlSystem::ProfilingLevel_t::OFF;///< Specify profiling level for Diaglog + uint64_t encode[2] = {0, 0}; + bool enableInitCache = false; +}; +/** + * @brief . + * + * The class for executing SNPE instances in parallel. + */ +class ZDL_EXPORT PSNPE final +{ + public: + ~PSNPE(); + + explicit PSNPE() noexcept :m_TransmissionMode(InputOutputTransmissionMode::sync){}; + + /** + * @brief Build snpe instances. + * + */ + bool build(BuildConfig& buildConfig) noexcept; + + /** + * @brief Execute snpe instances in Async Output mode and Sync mode + * + * @param[in] inputBufferList A list of user buffers that contains the input data + * + * @param[in,out] outputBufferList A list of user buffers that will hold the output data + * + */ + bool execute(UserBufferList& inputBufferList, UserBufferList& outputBufferList) noexcept; + + /** + * @brief Execute snpe instances in Async Input/Output mode + * + * @param[in]inputMap A map of input buffers that contains input data. The names of buffers + * need to be matched with names retrived through getInputTensorNames() + * + * @param dataIndex Index of the input data + * + * @param isTF8buff Whether prefer to using 8 bit quantized element for inference + * + * @return True if executed successfully; flase, otherwise. + */ + bool executeInputOutputAsync(const std::vector& inputMap, size_t dataIndex, bool isTF8buff) noexcept; + bool executeInputOutputAsync(const std::vector& inputMap, size_t dataIndex, bool isTF8buff,bool isTF8Outputbuff) noexcept; + /** + * @brief Returns the input layer names of the network. + * + * @return StringList which contains the input layer names + */ + const zdl::DlSystem::StringList getInputTensorNames() const noexcept; + + /** + * @brief Returns the output layer names of the network. + * + * @return StringList which contains the output layer names + */ + const zdl::DlSystem::StringList getOutputTensorNames() const noexcept; + + /** + * @brief Returns the input tensor dimensions of the network. + * + * @return TensorShape which contains the dimensions. + */ + const zdl::DlSystem::TensorShape getInputDimensions() const noexcept; + + /** + * @brief Returns attributes of buffers. + * + * @see zdl::SNPE + * + * @return BufferAttributes of input/output tensor named. + */ + const zdl::DlSystem::TensorShape getBufferAttributesDims(const char *name) const noexcept; + + zdl::DlSystem::Optional getInputOutputBufferAttributes(const char *name) const noexcept; + + private: + PSNPE(const PSNPE&) = delete; + PSNPE& operator=(const PSNPE&) = delete; + zdl::PSNPE::InputOutputTransmissionMode m_TransmissionMode; + +}; + +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ +} // namespace PSNPE +} // namespace zdl +#endif // PSNPE_HPP diff --git a/phonelibs/snpe/include/SNPE/RuntimeConfigList.hpp b/phonelibs/snpe/include/SNPE/RuntimeConfigList.hpp new file mode 100644 index 00000000000000..837dba092a1d21 --- /dev/null +++ b/phonelibs/snpe/include/SNPE/RuntimeConfigList.hpp @@ -0,0 +1,85 @@ +//============================================================================== +// +// Copyright (c) 2019-2020 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================== +#ifndef PSNPE_RUNTIMECONFIGLIST_HPP +#define PSNPE_RUNTIMECONFIGLIST_HPP + +#include +#include "DlContainer/IDlContainer.hpp" +#include "DlSystem/DlEnums.hpp" +#include "DlSystem/RuntimeList.hpp" +#include "DlSystem/TensorShapeMap.hpp" +#include "DlSystem/ZdlExportDefine.hpp" +namespace zdl { +namespace PSNPE { + +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +/** + * @brief . + * + * The structure for configuring a BulkSNPE runtime + * + */ +struct ZDL_EXPORT RuntimeConfig final { + zdl::DlSystem::Runtime_t runtime; + zdl::DlSystem::RuntimeList runtimeList; + zdl::DlSystem::PerformanceProfile_t perfProfile; + zdl::DlSystem::TensorShapeMap inputDimensionsMap; + bool enableCPUFallback; + RuntimeConfig() + : runtime{zdl::DlSystem::Runtime_t::CPU_FLOAT32}, + perfProfile{zdl::DlSystem::PerformanceProfile_t::HIGH_PERFORMANCE}, + enableCPUFallback{false} {} + RuntimeConfig(const RuntimeConfig& other) { + runtime = other.runtime; + runtimeList = other.runtimeList; + perfProfile = other.perfProfile; + enableCPUFallback = other.enableCPUFallback; + inputDimensionsMap = other.inputDimensionsMap; + } + + RuntimeConfig& operator=(const RuntimeConfig& other) { + this->runtimeList = other.runtimeList; + this->runtime = other.runtime; + this->perfProfile = other.perfProfile; + this->enableCPUFallback = other.enableCPUFallback; + this->inputDimensionsMap = other.inputDimensionsMap; + return *this; + } + + ~RuntimeConfig() {} +}; + +/** + * @brief . + * + * The class for creating a RuntimeConfig container. + * + */ +class ZDL_EXPORT RuntimeConfigList final { + public: + RuntimeConfigList(); + RuntimeConfigList(const size_t size); + void push_back(const RuntimeConfig& runtimeConfig); + RuntimeConfig& operator[](const size_t index); + RuntimeConfigList& operator=(const RuntimeConfigList& other); + size_t size() const noexcept; + size_t capacity() const noexcept; + void clear() noexcept; + ~RuntimeConfigList() = default; + + private: + void swap(const RuntimeConfigList& other); + std::vector m_runtimeConfigs; +}; +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ + +} // namespace PSNPE +} // namespace zdl +#endif // PSNPE_RUNTIMECONFIGLIST_HPP diff --git a/phonelibs/snpe/include/SNPE/SNPE.hpp b/phonelibs/snpe/include/SNPE/SNPE.hpp index ba84265b9663f8..239690ab2c7f1c 100644 --- a/phonelibs/snpe/include/SNPE/SNPE.hpp +++ b/phonelibs/snpe/include/SNPE/SNPE.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2015-2017 Qualcomm Technologies, Inc. +// Copyright (c) 2015-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -9,9 +9,6 @@ #ifndef _SNPE_SNPE_HPP_ #define _SNPE_SNPE_HPP_ -#include -#include - #include "DlSystem/DlOptional.hpp" #include "DlSystem/DlVersion.hpp" #include "DlSystem/IBufferAttributes.hpp" @@ -83,6 +80,14 @@ class ZDL_EXPORT SNPE final zdl::DlSystem::Optional getOutputTensorNames() const noexcept; + /** + * @brief Gets the name of output tensor from the input layer name + * + * @return Output tensor name. + */ + zdl::DlSystem::StringList + getOutputTensorNamesByLayerName(const char *name) const noexcept; + /** * @brief Processes the input data and returns the output * diff --git a/phonelibs/snpe/include/SNPE/SNPEBuilder.hpp b/phonelibs/snpe/include/SNPE/SNPEBuilder.hpp index 13e80e8c1a703d..f314d88bcff949 100644 --- a/phonelibs/snpe/include/SNPE/SNPEBuilder.hpp +++ b/phonelibs/snpe/include/SNPE/SNPEBuilder.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2017 Qualcomm Technologies, Inc. +// Copyright (c) 2017-2019 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -15,6 +15,7 @@ #include "DlSystem/DlOptional.hpp" #include "DlSystem/TensorShapeMap.hpp" #include "DlSystem/PlatformConfig.hpp" +#include "DlSystem/RuntimeList.hpp" namespace zdl { namespace DlContainer @@ -55,6 +56,9 @@ class ZDL_EXPORT SNPEBuilder final ~SNPEBuilder(); /** + * NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE. Please use + * setRuntimeProcessorOrder() + * * @brief Sets the runtime processor. * * @param[in] targetRuntimeProcessor The target runtime. @@ -74,6 +78,17 @@ class ZDL_EXPORT SNPEBuilder final SNPEBuilder& setPerformanceProfile( zdl::DlSystem::PerformanceProfile_t performanceProfile); + /** + * @brief Sets the profiling level. Default profiling level for + * SNPEBuilder is off. Off and basic only applies to DSP runtime. + * + * @param[in] profilingLevel The target profiling level. + * + * @return The current instance of SNPEBuilder. + */ + SNPEBuilder& setProfilingLevel( + zdl::DlSystem::ProfilingLevel_t profilingLevel); + /** * @brief Sets a preference for execution priority. * @@ -104,6 +119,20 @@ class ZDL_EXPORT SNPEBuilder final SNPEBuilder& setOutputLayers( const zdl::DlSystem::StringList& outputLayerNames); + /** + * @brief Sets the output tensor names. + * + * @param[in] outputTensorNames List of tensor names to + * output. An empty list will + * result in producing output for the final + * output tensor of the model. + * The list will be copied. + * + * @return The current instance of SNPEBuilder. + */ + SNPEBuilder& setOutputTensors( + const zdl::DlSystem::StringList& outputTensorNames); + /** * @brief Passes in a User-defined layer. * @@ -144,6 +173,9 @@ class ZDL_EXPORT SNPEBuilder final bool debugMode); /** + * NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE. Please use + * setRuntimeProcessorOrder() + * * @brief Sets the mode of CPU fallback functionality. * * @param[in] mode This flag enables/disables the functionality @@ -185,6 +217,22 @@ class ZDL_EXPORT SNPEBuilder final */ SNPEBuilder& setInputDimensions(const zdl::DlSystem::TensorShapeMap& inputDimensionsMap); + /** + * @brief Sets the mode of init caching functionality. + * + * @param[in] mode This flag enables/disables the functionality of init caching. + * When init caching functionality is enabled, a set of init caches + * will be created during network building/initialization process + * and will be added to DLC container. If such DLC container is saved + * by the user, in subsequent network building/initialization processes + * these init caches will be loaded from the DLC so as to reduce initialization time. + * In disable mode, no init caches will be added to DLC container. + * + * @return The current instance of SNPEBuilder. + */ + SNPEBuilder& setInitCacheMode( + bool cacheMode); + /** * @brief Returns an instance of SNPE based on the current parameters. * @@ -202,6 +250,31 @@ class ZDL_EXPORT SNPEBuilder final */ SNPEBuilder& setPlatformConfig(const zdl::DlSystem::PlatformConfig& platformConfig); + /** + * @brief Sets network's runtime order of precedence. Example: + * CPU_FLOAT32, GPU_FLOAT16, AIP_FIXED8_TF + * Note:- setRuntimeProcessor() or setCPUFallbackMode() will be silently ignored when + * setRuntimeProcessorOrder() is invoked + * + * @param[in] runtimeList The list of runtime in order of precedence + * + * @return The current instance of SNPEBuilder. + */ + SNPEBuilder& setRuntimeProcessorOrder(const zdl::DlSystem::RuntimeList& runtimeList); + + /** + * @brief Sets the unconsumed tensors as output + * + * @param[in] setOutput This enables unconsumed tensors (i.e) + * outputs which are not inputs to any + * layer (basically dead ends) to be marked + * for output + * + * @return The current instance of SNPEBuilder. + */ + SNPEBuilder& setUnconsumedTensorsAsOutputs( + bool setOutput); + }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ diff --git a/phonelibs/snpe/include/SNPE/SNPEFactory.hpp b/phonelibs/snpe/include/SNPE/SNPEFactory.hpp index bb9921afe10591..7bef45d877c4c1 100644 --- a/phonelibs/snpe/include/SNPE/SNPEFactory.hpp +++ b/phonelibs/snpe/include/SNPE/SNPEFactory.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2015-2016 Qualcomm Technologies, Inc. +// Copyright (c) 2015-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -42,19 +42,35 @@ class ZDL_EXPORT SNPEFactory public: /** - * Indicates whether the supplied runtime is available on the + * Indicates whether the supplied runtime is available on the * current platform. - * + * * @param[in] runtime The target runtime to check. - * - * @return True if the supplied runtime is available; false, + * + * @param[in] option Extent to perform runtime available check. + * + * @return True if the supplied runtime is available; false, * otherwise. */ static bool isRuntimeAvailable(zdl::DlSystem::Runtime_t runtime); + /** + * Indicates whether the supplied runtime is available on the + * current platform. + * + * @param[in] runtime The target runtime to check. + * + * @param[in] option Extent to perform runtime available check. + * + * @return True if the supplied runtime is available; false, + * otherwise. + */ + static bool isRuntimeAvailable(zdl::DlSystem::Runtime_t runtime, + zdl::DlSystem::RuntimeCheckOption_t option); + /** * Gets a reference to the tensor factory. - * + * * @return A reference to the tensor factory. */ static zdl::DlSystem::ITensorFactory& getTensorFactory(); @@ -87,6 +103,17 @@ class ZDL_EXPORT SNPEFactory */ static bool setSNPEStorageLocation(const char* storagePath); + /** + * @brief Register a user-defined op package with SNPE. + * + * @param[in] regLibraryPath Path to the registration library + * that allows clients to register a set of operations that are + * part of the package, and share op info with SNPE + * + * @return True if successful, False otherwise. + */ + static bool addOpPackage( const std::string& regLibraryPath ); + /** * Indicates whether the OpenGL and OpenCL interoperability is supported * on GPU platform. diff --git a/phonelibs/snpe/include/SNPE/UserBufferList.hpp b/phonelibs/snpe/include/SNPE/UserBufferList.hpp new file mode 100644 index 00000000000000..a660bca0f6a525 --- /dev/null +++ b/phonelibs/snpe/include/SNPE/UserBufferList.hpp @@ -0,0 +1,49 @@ +//============================================================================== +// +// Copyright (c) 2019 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================== +#ifndef PSNPE_USERBUFFERLIST_HPP +#define PSNPE_USERBUFFERLIST_HPP + +#include +#include "DlSystem/UserBufferMap.hpp" +#include "DlSystem/ZdlExportDefine.hpp" + +namespace zdl { +namespace PSNPE +{ + +/** @addtogroup c_plus_plus_apis C++ +@{ */ +/** +* @brief . +* +* The class for creating a UserBufferMap container. +* +*/ +class ZDL_EXPORT UserBufferList final +{ +public: + UserBufferList(); + UserBufferList(const size_t size); + void push_back(const zdl::DlSystem::UserBufferMap &userBufferMap); + zdl::DlSystem::UserBufferMap& operator[](const size_t index); + UserBufferList& operator =(const UserBufferList &other); + size_t size() const noexcept; + size_t capacity() const noexcept; + void clear() noexcept; + ~UserBufferList() = default; + +private: + void swap(const UserBufferList &other); + std::vector m_userBufferMaps; + +}; +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ + +} // namespace PSNPE +} // namespace zdl +#endif //PSNPE_USERBUFFERLIST_HPP diff --git a/phonelibs/snpe/include/SnpeUdo/UdoBase.h b/phonelibs/snpe/include/SnpeUdo/UdoBase.h new file mode 100644 index 00000000000000..be370e1ac5b975 --- /dev/null +++ b/phonelibs/snpe/include/SnpeUdo/UdoBase.h @@ -0,0 +1,483 @@ +//============================================================================== +// +// Copyright (c) 2019-2020 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================== + +#ifndef SNPE_UDO_BASE_H +#define SNPE_UDO_BASE_H + +#include + +// Provide values to use for API version. +#define API_VERSION_MAJOR 1 +#define API_VERSION_MINOR 5 +#define API_VERSION_TEENY 0 + +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +// Defines a bitmask of enum values. +typedef uint32_t SnpeUdo_Bitmask_t; + +// A string of characters, rather than an array of bytes. +// Assumed to be UTF-8. +typedef char* SnpeUdo_String_t; + +// The maximum allowable length of a SnpeUdo_String_t in bytes, +// including null terminator. SNPE will truncate strings longer +// than this. +#define SNPE_UDO_MAX_STRING_SIZE 1024 + +/** + * An enum which holds the various error types. + * The error types are divided to classes : + * 0 - 99 : generic errors + * 100 - 200 : errors related to configuration + * + */ +typedef enum +{ + /// No Error + SNPE_UDO_NO_ERROR = 0, + /// Unsupported value for core type + SNPE_UDO_WRONG_CORE = 1, + /// Invalid attribute/argument passed into UDO API + SNPE_UDO_INVALID_ARGUMENT = 2, + /// Unsupported feature error + SNPE_UDO_UNSUPPORTED_FEATURE = 3, + /// Error relating to memory allocation + SNPE_UDO_MEM_ALLOC_ERROR = 4, + /* Configuration Specific errors */ + /// No op with given attributes available in library + SNPE_UDO_WRONG_OPERATION = 100, + /// Unsupported value for core type in UDO configuration + SNPE_UDO_WRONG_CORE_TYPE = 101, + /// Wrong number of params in UDO definition + SNPE_UDO_WRONG_NUM_OF_PARAMS = 102, + /// Wrong number of dimensions for tensor(s) in UDO definition + SNPE_UDO_WRONG_NUM_OF_DIMENSIONS = 103, + /// Wrong number of input tensors in UDO definition + SNPE_UDO_WRONG_NUM_OF_INPUTS = 104, + /// Wrong number of output tensors in UDO definition + SNPE_UDO_WRONG_NUM_OF_OUTPUTS = 105, + SNPE_UDO_PROGRAM_CACHE_NOT_FOUND = 106, + SNPE_UDO_UNKNOWN_ERROR = 0xFFFFFFFF +} SnpeUdo_ErrorType_t; + +/** + * An enum which holds the various data types. + * Designed to be used as single values or combined into a bitfield parameter + * (0x1, 0x2, 0x4, etc) + * \n FIXED_XX types are targeted for data in tensors. + * \n UINT / INT types are targeted for scalar params + */ +typedef enum +{ + /// data type: 16-bit floating point + SNPE_UDO_DATATYPE_FLOAT_16 = 0x01, + /// data type: 32-bit floating point + SNPE_UDO_DATATYPE_FLOAT_32 = 0x02, + /// data type: 4-bit fixed point + SNPE_UDO_DATATYPE_FIXED_4 = 0x04, + /// data type: 8-bit fixed point + SNPE_UDO_DATATYPE_FIXED_8 = 0x08, + /// data type: 16-bit fixed point + SNPE_UDO_DATATYPE_FIXED_16 = 0x10, + /// data type: 32-bit fixed point + SNPE_UDO_DATATYPE_FIXED_32 = 0x20, + /// data type: 8-bit unsigned integer + SNPE_UDO_DATATYPE_UINT_8 = 0x100, + /// data type: 16-bit unsigned integer + SNPE_UDO_DATATYPE_UINT_16 = 0x200, + /// data type: 32-bit unsigned integer + SNPE_UDO_DATATYPE_UINT_32 = 0x400, + /// data type: 8-bit signed integer + SNPE_UDO_DATATYPE_INT_8 = 0x1000, + /// data type: 16-bit signed integer + SNPE_UDO_DATATYPE_INT_16 = 0x2000, + /// data type: 32-bit signed integer + SNPE_UDO_DATATYPE_INT_32 = 0x4000, + SNPE_UDO_DATATYPE_LAST = 0xFFFFFFFF +} SnpeUdo_DataType_t; + +/** + * An enum which holds the various layouts. + * Designed to be used as single values or combined into a bitfield parameter + * (0x1, 0x2, 0x4, etc) + */ +typedef enum +{ + /// data layout (4D): NHWC (batch-height-width-channel) + SNPE_UDO_LAYOUT_NHWC = 0x01, + /// data layout (4D): NCHW (batch-channel-height-width) + SNPE_UDO_LAYOUT_NCHW = 0x02, + /// data layout (5D): NDHWC (batch-dimension-height-width-channel) + SNPE_UDO_LAYOUT_NDHWC = 0x04, + SNPE_UDO_LAYOUT_GPU_OPTIMAL1 = 0x08, + SNPE_UDO_LAYOUT_GPU_OPTIMAL2 = 0x10, + SNPE_UDO_LAYOUT_DSP_OPTIMAL1 = 0x11, + SNPE_UDO_LAYOUT_DSP_OPTIMAL2 = 0x12, + // Indicates no data will be allocated for this tensor. + // Used to specify optional inputs/outputs positionally. + SNPE_UDO_LAYOUT_NULL = 0x13, + SNPE_UDO_LAYOUT_LAST = 0xFFFFFFFF +} SnpeUdo_TensorLayout_t; + +/** + * An enum which holds the UDO library Core type . + * Designed to be used as single values or combined into a bitfield parameter + * (0x1, 0x2, 0x4, etc) + */ +typedef enum +{ + /// Library target IP Core is undefined + SNPE_UDO_CORETYPE_UNDEFINED = 0x00, + /// Library target IP Core is CPU + SNPE_UDO_CORETYPE_CPU = 0x01, + /// Library target IP Core is GPU + SNPE_UDO_CORETYPE_GPU = 0x02, + /// Library target IP Core is DSP + SNPE_UDO_CORETYPE_DSP = 0x04, + SNPE_UDO_CORETYPE_LAST = 0xFFFFFFFF +} SnpeUdo_CoreType_t; + +/** + * An enum to specify the parameter type : Scalar or Tensor + */ +typedef enum +{ + /// UDO static param type: scalar + SNPE_UDO_PARAMTYPE_SCALAR, + /// UDO static param type: string + SNPE_UDO_PARAMTYPE_STRING, + /// UDO static param type: tensor + SNPE_UDO_PARAMTYPE_TENSOR, + SNPE_UDO_PARAMTYPE_LAST = 0xFFFFFFFF +} SnpeUdo_ParamType_t; + +/** + * An enum to specify quantization type + */ +typedef enum +{ + /// Tensor Quantization type: NONE. Signifies unquantized tensor data + SNPE_UDO_QUANTIZATION_NONE, + /// Tensor Quantization type: Tensorflow-style + SNPE_UDO_QUANTIZATION_TF, + SNPE_UDO_QUANTIZATION_QMN, + SNPE_UDO_QUANTIZATION_LAST = 0xFFFFFFFF +} SnpeUdo_QuantizationType_t; + +/** + * @brief A struct which is used to provide a version number using 3 values : major, minor, teeny + * + */ +typedef struct +{ + /// version field: major - for backward-incompatible changes + uint32_t major; + /// version field: minor - for backward-compatible feature updates + uint32_t minor; + /// version field: teeny - for minor bug-fixes and clean-up + uint32_t teeny; +} SnpeUdo_Version_t; + +/** + * @brief A struct returned from version query, contains the Library version and API version + * + */ +typedef struct +{ + /// Version of UDO library. Controlled by users + SnpeUdo_Version_t libVersion; + /// Version of SNPE UDO API used in compiling library. Determined by SNPE + SnpeUdo_Version_t apiVersion; +} SnpeUdo_LibVersion_t; + +/** + * @brief A union to hold the value of a generic type. Allows defining a parameter struct + * in a generic way, with a "value" location that holds the data regardless of the type. + * + */ +typedef union +{ + /// value type: float + float floatValue; + /// value type: unsigned 32-bit integer + uint32_t uint32Value; + /// value type: signed 32-bit integer + int32_t int32Value; + /// value type: unsigned 16-bit integer + uint16_t uint16Value; + /// value type: signed 16-bit integer + int16_t int16Value; + /// value type: unsigned 8-bit integer + uint8_t uint8Value; + /// value type: signed 8-bit integer + int8_t int8Value; +} SnpeUdo_Value_t; + +/** + * @brief A struct which defines a scalar parameter : name, data type, and union of values + * + */ +typedef struct +{ + /// The parameter data type : float, int, etc. + SnpeUdo_DataType_t dataType; + /// a union of specified type which holds the data + SnpeUdo_Value_t dataValue; +} SnpeUdo_ScalarParam_t; + +/** + * @brief A struct which defines the quantization parameters in case of Tensorflow style quantization + * + */ +typedef struct +{ + /// minimum value of the quantization range of data + float minValue; + /// maximum value of the quantization range of data + float maxValue; +} SnpeUdo_TFQuantize_t; + +/** + * @brief A struct which defines the quantization type, and union of supported quantization structs + * + */ +typedef struct +{ + /// quantization type (only TF-style currently supported) + SnpeUdo_QuantizationType_t quantizeType; + union + { + /// TF-style min-max quantization ranges + SnpeUdo_TFQuantize_t TFParams; + }; +} SnpeUdo_QuantizeParams_t; + +/** + * @brief A struct which defines the datatype associated with a specified core-type + * This should be used to denote the datatypes for a single tensor info, depending + * on the intended execution core. + * + */ +typedef struct +{ + /// The IP Core + SnpeUdo_CoreType_t coreType; + /// The associated datatype for this coreType + SnpeUdo_DataType_t dataType; +} SnpeUdo_PerCoreDatatype_t; + +/** + * @brief A struct which defines a tensor parameter : name, data type, layout, quantization, more. + * Also holds a pointer to the tensor data. + * + */ +typedef struct +{ + /// The maximum allowable dimensions of the tensor. The memory held in + /// _tensorData_ is guaranteed to be large enough for this. + uint32_t* maxDimensions; + /// The current dimensions of the tensor. An operation may modify the current + /// dimensions of its output, to indicate cases where the output has been + /// "resized". + /// Note that for static parameters, the current and max dimensions must + /// match. + uint32_t* currDimensions; + /// Quantization params applicable to the tensor. Currently only supports + /// Tensorflow quantization style. + SnpeUdo_QuantizeParams_t quantizeParams; + /// Number of dimensions to the tensor: 3D, 4D, etc. + uint32_t tensorRank; + /// The parameter data type: float, int, etc. + SnpeUdo_DataType_t dataType; + /// The tensor layout type: NCHW, NHWC, etc. + SnpeUdo_TensorLayout_t layout; + /// Opaque pointer to tensor data. User may be required to re-interpret the pointer + /// based on core-specific definitions. + void* tensorData; +} SnpeUdo_TensorParam_t; + +/** + * @brief A struct which defines tensor information for activation tensors only + * + * It describes an activation tensor object using its name, the intended layout and the datatype + * it will take depending on the intended runtime core. The repeated field indicates that + * that the tensor info describes several input/output activation tensors, which all share the + * aforementioned properties. + */ +typedef struct +{ + /// The tensor name + SnpeUdo_String_t tensorName; + /// The tensor layout type: NCHW, NHWC, etc. + SnpeUdo_TensorLayout_t layout; + /// The per core datatype: {SNPE_UDO_DATATYPE, SNPE_UDO_CORE_TYPE} + SnpeUdo_PerCoreDatatype_t* perCoreDatatype; + /// A boolean field indicating that this tensorinfo will be repeated e.x for ops such as Concat or Split + bool repeated; + +} SnpeUdo_TensorInfo_t; + + +/** + * @brief struct which defines a UDO parameter - a union of scalar, tensor and string parameters + * + */ +typedef struct +{ + /// Type is scalar or tensor + SnpeUdo_ParamType_t paramType; + /// The param name, for example : "offset", "activation_type" + SnpeUdo_String_t paramName; + union + { + /// scalar param value + SnpeUdo_ScalarParam_t scalarParam; + /// tensor param value + SnpeUdo_TensorParam_t tensorParam; + /// string param value + SnpeUdo_String_t stringParam; + }; +} SnpeUdo_Param_t; + +/** + * @brief A struct which defines Operation information which is specific for IP core (CPU, GPU, DSP ...) + * + */ +typedef struct +{ + /// The IP Core + SnpeUdo_CoreType_t udoCoreType; + /// Bitmask, defines supported internal calculation types (like FLOAT_32, etc) + /// Based on SnpeUdo_DataType + SnpeUdo_Bitmask_t operationCalculationTypes; +} SnpeUdo_OpCoreInfo_t; + +/** + * @brief A struct which defines the common and core-specific Operation information + * + */ +typedef struct +{ + /// Operation type + SnpeUdo_String_t operationType; + /// A bitmask describing which IP Cores (CPU, GPU, DSP ...) support this operation + /// Translated based on SnpeUdo_CoreType + SnpeUdo_Bitmask_t supportedByCores; + /// Number of static parameters defined by the op + uint32_t numOfStaticParams; + /// Array of static parameters. Can be scalar or tensor params + SnpeUdo_Param_t* staticParams; + /// Number of input tensors this op receives + uint32_t numOfInputs; + /// Array of input tensor names to this operation + SnpeUdo_String_t* inputNames; + /// Number of output tensors this op receives + uint32_t numOfOutputs; + /// Array of output tensor names to this operation + SnpeUdo_String_t* outputNames; + /// Number of cores that the op can execute on + uint32_t numOfCoreInfo; + /// Array of per-core information entries + SnpeUdo_OpCoreInfo_t* opPerCoreInfo; + /// Array of input tensor infos for this operation + SnpeUdo_TensorInfo_t* inputInfos; + /// Array of output tensor infos for this operation + SnpeUdo_TensorInfo_t* outputInfos; +} SnpeUdo_OperationInfo_t; + +/** + * @brief A struct which provides the implementation library info : type, name + * + */ +typedef struct +{ + /// Defines the IP Core that this implementation library is targeting + SnpeUdo_CoreType_t udoCoreType; + /// library name. will be looked at in the standard library path + SnpeUdo_String_t libraryName; +} SnpeUdo_LibraryInfo_t; + +/** + * @brief A struct returned by the registration library and contains information on the UDO package : + * name, operations, libraries, etc. + * + */ +typedef struct +{ + /// A string containing the package name + SnpeUdo_String_t packageName; + /// A bitmask describing supported IP cores (CPU, GPU, DSP ...) + /// Translated based on SnpeUdo_CoreType + SnpeUdo_Bitmask_t supportedCoreTypes; + /// The number of implementation libraries in the package + uint32_t numOfImplementationLib; + /// Array of implementation libraries names/types + SnpeUdo_LibraryInfo_t* implementationLib; + /// A string containing all operation types separated by space + SnpeUdo_String_t operationsString; + /// Number of supported operations + uint32_t numOfOperations; + /// Array of Operation info structs. Each entry describes one + /// Operation (name, params, inputs, outputs) + SnpeUdo_OperationInfo_t* operationsInfo; +} SnpeUdo_RegInfo_t; + +/** +* @brief A struct returned by the implementation library and contains information on the +* specific library: name, IP Core, operations, etc. +* +*/ +typedef struct +{ + /// Defines the IP Core that this implementation library is targeting + SnpeUdo_CoreType_t udoCoreType; + /// A string containing the package name + SnpeUdo_String_t packageName; + /// A string containing all operation types separated by space + SnpeUdo_String_t operationsString; + /// Number of supported operations + uint32_t numOfOperations; +} SnpeUdo_ImpInfo_t; + +/** + * @brief This struct defines an operation. It is used for validation + * or creation of an operation. + * In case of using it for creation, the static params which are tensors + * contain pointers to the real data (weights, for example), and input/output + * tensors also include pointers to the buffers used. + */ +typedef struct +{ + /// The IP Core that the operation is defined for - CPU, GPU, DSP... + SnpeUdo_CoreType_t udoCoreType; + /// Operation type + SnpeUdo_String_t operationType; + /// The number of static parameters provided in the staticParams array. + /// this number has to match the number provided by the UDO Registration library information + uint32_t numOfStaticParams; + /// Array of static parameters + SnpeUdo_Param_t* staticParams; + /// The number of input parameters provided in inputs array. + /// this number has to match the number provided by the UDO Registration library information + uint32_t numOfInputs; + /// Array of input tensors, providing layout, data type, sizes, etc + /// When used to create an operation, also contains the initial location of the data + SnpeUdo_TensorParam_t* inputs; + /// The number of output parameters provided in inputs array. + /// this number has to match the number provided by the UDO Registration library information + uint32_t numOfOutputs; + /// Array of output tensors, providing layout, data type, sizes, etc + /// When used to create an operation, also contains the initial location of the data + SnpeUdo_TensorParam_t* outputs; +} SnpeUdo_OpDefinition_t; + +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ + +#endif //SNPE_UDO_BASE_H diff --git a/phonelibs/snpe/include/SnpeUdo/UdoImpl.h b/phonelibs/snpe/include/SnpeUdo/UdoImpl.h new file mode 100644 index 00000000000000..bd29bc251dd688 --- /dev/null +++ b/phonelibs/snpe/include/SnpeUdo/UdoImpl.h @@ -0,0 +1,323 @@ +//============================================================================== +// +// Copyright (c) 2019-2020 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================== + +#ifndef SNPE_UDO_IMPL_H +#define SNPE_UDO_IMPL_H + +#include + +#include "SnpeUdo/UdoShared.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +typedef struct _SnpeUdo_OpFactory_t* SnpeUdo_OpFactory_t; +typedef struct _SnpeUdo_Operation_t* SnpeUdo_Operation_t; + +/** + * @brief Initialize the shared library's data structures. Calling any other + * library function before this one will result in error. + * + * @param[in] globalInfrastructure Global core-specific infrastructure to be + * used by operations created in this library. The definition and + * semantics of this object will be defined in the corresponding + * implementation header for the core type. + * @return Error code + */ +SnpeUdo_ErrorType_t +SnpeUdo_initImplLibrary(void* globalInfrastructure); + +typedef SnpeUdo_ErrorType_t +(*SnpeUdo_InitImplLibraryFunction_t)(void*); + +/** + * @brief A function to query the API version of the UDO implementation library. + * The function populates a SnpeUdo_LibVersion_t struct, which contains a SnpeUdo_Version_t + * struct for API version and library version. + * + * @param[in, out] version A pointer to struct which contains major, minor, teeny information for + * library and api versions. + * + * @return Error code + */ +SnpeUdo_ErrorType_t +SnpeUdo_getImplVersion(SnpeUdo_LibVersion_t** version); + +typedef SnpeUdo_ErrorType_t +(*SnpeUdo_getImplVersion_t)(SnpeUdo_LibVersion_t** version); + +/** + * @brief Release the shared library's data structures, and invalidate any + * handles returned by the library. The behavior of any outstanding + * asynchronous calls made to this library when this function is called + * are undefined. All library functions (except SnpeUdo_initImplLibrary) will + * return an error after this function has been successfully called. + * + * It should be possible to call SnpeUdo_initImplLibrary after calling this + * function, and re-initialize the library. + * + * @return Error code + */ +SnpeUdo_ErrorType_t +SnpeUdo_terminateImplLibrary(void); + +typedef SnpeUdo_ErrorType_t +(*SnpeUdo_TerminateImplLibraryFunction_t)(void); + + +/** + * @brief A function to query info on the UDO implementation library. + * The function populates a structure which contains information about + * operations that are part of this library + * + * @param[in, out] implementationInfo A pointer to struct which contains information + * on the operations + * + * @return error code + * + */ +SnpeUdo_ErrorType_t +SnpeUdo_getImpInfo(SnpeUdo_ImpInfo_t** implementationInfo); + +typedef SnpeUdo_ErrorType_t +(*SnpeUdo_GetImpInfoFunction_t)(SnpeUdo_ImpInfo_t** implementationInfo); + +/** + * @brief A function to create an operation factory. + * The function receives the operation type, and an array of static parameters, + * and returns operation factory handler + * + * @param[in] udoCoreType The Core type to create the operation on. An error will + * be returned if this does not match the core type of the library. + * + * @param[in] perFactoryInfrastructure CreateOpFactory infrastructure appropriate to this + * core type. The definition and semantics of this object will be defined + * in the corresponding implementation header for the core type. + * + * @param[in] operationType A string containing Operation type. for example "MY_CONV" + * + * @param[in] numOfStaticParams The number of static parameters. + * + * @param[in] staticParams Array of static parameters + * + * @param[in,out] opFactory Handler to Operation Factory, to be used when creating operations + * + * @return Error Code + */ +SnpeUdo_ErrorType_t +SnpeUdo_createOpFactory(SnpeUdo_CoreType_t udoCoreType, + void* perFactoryInfrastructure, + SnpeUdo_String_t operationType, + uint32_t numOfStaticParams, + SnpeUdo_Param_t* staticParams, + SnpeUdo_OpFactory_t* opFactory); + +typedef SnpeUdo_ErrorType_t +(*SnpeUdo_CreateOpFactoryFunction_t)(SnpeUdo_CoreType_t, + void*, + SnpeUdo_String_t, + uint32_t, + SnpeUdo_Param_t*, + SnpeUdo_OpFactory_t*); + + +/** + * @brief A function to release the resources allocated for an operation factory + * created by this library. + * + * @param[in] factory The operation factory to release. Upon success this handle will be invalidated. + * + * @return Error Code + */ +SnpeUdo_ErrorType_t +SnpeUdo_releaseOpFactory(SnpeUdo_OpFactory_t opFactory); + +typedef SnpeUdo_ErrorType_t +(*SnpeUdo_ReleaseOpFactoryFunction_t)(SnpeUdo_OpFactory_t); + +/** + * @brief A function to create an operation from the factory. + * The function receives array of inputs and array of outputs, and creates an operation + * instance, returning the operation instance handler. + * + * @param[in] opFactory OpFactory instance containing the parameters for this operation. + * + * @param[in] perOpInfrastructure Per-Op infrastructure for this operation. The definition + * and semantics of this object will be defined in the implementation header + * appropriate to this core type. + * + * @param[in] numOfInputs The number of input tensors this operation will receive. + * + * @param[in] inputs Array of input tensors, providing both the sizes and initial + * location of the data. + * + * @param[in] numOfOutputs Number of output tensors this operation will produce. + * + * @param[in] outputs Array of output tensors, providing both the sizes and + * initial location of the data. + * + * @param[in,out] operation Handle for newly created operation instance. + * + * @return Error Code + */ +SnpeUdo_ErrorType_t +SnpeUdo_createOperation(SnpeUdo_OpFactory_t opFactory, + void* perOpInfrastructure, + uint32_t numOfInputs, + SnpeUdo_TensorParam_t* inputs, + uint32_t numOfOutputs, + SnpeUdo_TensorParam_t* outputs, + SnpeUdo_Operation_t* operation); + +typedef SnpeUdo_ErrorType_t +(*SnpeUdo_CreateOperationFunction_t)(SnpeUdo_OpFactory_t, + void*, + uint32_t, + SnpeUdo_TensorParam_t*, + uint32_t, + SnpeUdo_TensorParam_t*, + SnpeUdo_Operation_t*); + +/** + * @brief A pointer to notification function. + * + * The notification function supports the non-blocking (e.g. asynchronous) execution use-case. + * In case an "executeUdoOp" function is called with "blocking" set to zero, and a + * notify function, this function will be called by the implementation library at the + * end of execution. The implementation library will pass the notify function the ID + * that was provided to it when "executeUdoOp" was called. + * + * @param[in] ID 32-bit value, that was provided to executeUdoOp by the calling entity. + * Can be used to track the notifications, in case of multiple execute calls issued. + * + * @return Error code + * + */ +typedef SnpeUdo_ErrorType_t +(*SnpeUdo_ExternalNotify_t)(const uint32_t ID); + +/** + * @brief Operation execution function. + * + * Calling this function will run the operation on set of inputs, generating a set of outputs. + * The call can be blocking (synchronous) or non-blocking (asynchronous). To support the + * non-blocking mode, the calling entity can pass an ID and a notification function. + * At the end of the execution this notification function would be called, passing it the ID. + * NOTE: Asynchronous execution mode not supported in this release. + * + * @param[in] operation handle to the operation on which execute is invoked + * @param[in] blocking flag to indicate execution mode. + * If set, execution is blocking, + * e.g SnpeUdo_executeOp call does not return until execution is done. + * If not set, SnpeUdo_executeOp returns immediately, and the + * library will call the notification function (if set) when execution is done. + * + * @param[in] ID 32-bit number that can be used by the calling entity to track execution + * in case of non-blocking execution. + * For example, it can be a sequence number, increased by one on each call. + * + * @param[in] notifyFunc Pointer to notification function. if the pointer is set, and execution is + * non-blocking, the library will call this function at end of execution, + * passing the number provided as ID + * + * @return Error code + * + */ +SnpeUdo_ErrorType_t +SnpeUdo_executeOp(SnpeUdo_Operation_t operation, + bool blocking, + const uint32_t ID, + SnpeUdo_ExternalNotify_t notifyFunc); + +typedef SnpeUdo_ErrorType_t +(*SnpeUdo_ExecuteOpFunction_t)(SnpeUdo_Operation_t, + bool, + const uint32_t, + SnpeUdo_ExternalNotify_t); + +/** + * @brief A function to setting the inputs & outputs. part of SnpeUdo_Operation struct, + * returned from creation of a new operation instance. + * Not supported in this release. + * + * This function allows the calling entity to change some of the inputs and outputs + * between calls to execute. + * Note that the change is limited to changing the pointer to the tensor data only. + * Any other change may be rejected by the implementation library, causing + * immediate invalidation of the operation instance + * + * @param[in] operation Operation on which IO tensors are set + * + * @param[in] inputs array of tensor parameters. The calling entity may provide a subset of the + * operation inputs, providing only those that it wants to change. + * + * @param[in] outputs array of tensor parameters. The calling entity may provide a subset of the + * operation outputs, providing only those that it wants to change. + * + * @return Error code + * + */ +SnpeUdo_ErrorType_t +SnpeUdo_setOpIO(SnpeUdo_Operation_t operation, + SnpeUdo_TensorParam_t* inputs, + SnpeUdo_TensorParam_t* outputs); + +typedef SnpeUdo_ErrorType_t +(*SnpeUdo_SetOpIOFunction_t)(SnpeUdo_Operation_t, + SnpeUdo_TensorParam_t*, + SnpeUdo_TensorParam_t*); + +/** + * @brief A function to return execution times. + * + * This function can be called to query the operation execution times on the IP core + * on which the operation is run. The time is provided in micro-seconds + * + * @param[in] operation Handle to operation whose execution time is being profiled + * + * @param[in,out] executionTime pointer to a uint32 value.This function writes the operation + * execution time in usec into this value. + * + * @return Error code + * + */ +SnpeUdo_ErrorType_t +SnpeUdo_profileOp(SnpeUdo_Operation_t operation, uint32_t *executionTime); + +typedef SnpeUdo_ErrorType_t +(*SnpeUdo_ProfileOpFunction_t)(SnpeUdo_Operation_t, uint32_t*); + +/** + * @brief A function to release the operation instance + * \n When it is called, the implementation library needs to release all resources + * allocated for this operation instance. + * \n Note that all function pointers which are part of SnpeUdo_Operation become + * invalid once releaseUdoOp call returns. + * + * @param[in] operation Handle to operation to be released + * @return Error code + * + */ +SnpeUdo_ErrorType_t +SnpeUdo_releaseOp(SnpeUdo_Operation_t operation); + +typedef SnpeUdo_ErrorType_t +(*SnpeUdo_ReleaseOpFunction_t)(SnpeUdo_Operation_t); + +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif //SNPE_UDO_IMPL_H diff --git a/phonelibs/snpe/include/SnpeUdo/UdoImplCpu.h b/phonelibs/snpe/include/SnpeUdo/UdoImplCpu.h new file mode 100644 index 00000000000000..3bbe0638e60fc8 --- /dev/null +++ b/phonelibs/snpe/include/SnpeUdo/UdoImplCpu.h @@ -0,0 +1,44 @@ +//============================================================================== +// +// Copyright (c) 2019-2020 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================== + +// Header to be used by a CPU UDO Implementation library + +#ifndef SNPE_UDO_IMPL_CPU_H +#define SNPE_UDO_IMPL_CPU_H + +#include + +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +/** + * @brief This struct provides the infrastructure needed by a developer of + * CPU UDO Implementation library. + * + * The framework/runtime which loads the CPU UDO implementation library provides + * this infrastructure data to the loaded library at the time of op factory creation. + * as an opaque pointer. It contains hooks for the UDO library to invoke supported + * functionality at the time of execution + * + * @param getData function pointer to retrieve raw tensor data from opaque pointer + * passed into the UDO when creating an instance. + * @param getDataSize function pointer to retrieve tensor data size from opaque pointer + */ + +typedef struct +{ + /// function pointer to retrieve raw tensor data from opaque pointer + /// passed into the UDO when creating an instance. + float* (*getData)(void*); + /// function pointer to retrieve tensor data size from opaque pointer + size_t (*getDataSize) (void*); +} SnpeUdo_CpuInfrastructure_t; + +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ + +#endif // SNPE_UDO_IMPL_CPU_H \ No newline at end of file diff --git a/phonelibs/snpe/include/SnpeUdo/UdoImplDsp.h b/phonelibs/snpe/include/SnpeUdo/UdoImplDsp.h new file mode 100644 index 00000000000000..7e85bf15d87871 --- /dev/null +++ b/phonelibs/snpe/include/SnpeUdo/UdoImplDsp.h @@ -0,0 +1,187 @@ +//============================================================================== +// +// Copyright (c) 2019-2020 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================== + +//============================================================================== +/* + * THIS HEADER FILE IS COPIED FROM HEXAGON-NN PROJECT + * + */ +//============================================================================== + + +// Header to be used by a DSP Hexnn UDO Implementation library + +#ifndef SNPE_UDO_IMPL_DSP_H +#define SNPE_UDO_IMPL_DSP_H +#include +#include "SnpeUdo/UdoImpl.h" + +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +/** + * @brief A function to validate that a set of params is supported by an operation + * This function is HexNN specific, use case is when registration library is not in use. + * Optional function. + * + * @param[in] operationType Operation type + * @param[in] numOfStaticParams Number of static params defined by the op + * @param[in] staticParams Array of static params to the op + * @return Error code, indicating if the operation can be created on this set of configuration or not. + * + */ + +SnpeUdo_ErrorType_t +SnpeUdo_validateOperation (SnpeUdo_String_t operationType, + uint32_t numOfStaticParams, + const SnpeUdo_Param_t* staticParams); + +typedef SnpeUdo_ErrorType_t (*SnpeUdo_ValidateOperationFunction_t) (SnpeUdo_String_t, + uint32_t, + const SnpeUdo_Param_t*); + + +// enum used for indicating input/outout tensor data layouts on DSP, plain vs d32 +typedef enum { + SNPE_UDO_DSP_TENSOR_LAYOUT_PLAIN, + SNPE_UDO_DSP_TENSOR_LAYOUT_D32 +} SnpeUdo_HexNNTensorLayout_t; + +/** + * @brief A function to query numbers of inputs and outputs, + * quantization type of each input and each output as arrays, + * and data layout (plain vs d32) of each input and each output as arrays + * of an operation. + * inputsQuantTypes and inputsLayouts should point to arrays of size numOfInputs + * outputsQuantTypes and outputsLayouts should point to arrays of size numOfOutputs + * + * Note: inputsLayouts and inputsLayouts can point to NULL, in this case, it is + * assumed all inputs and/or outputs have plain data layouts, i.e. no D32 + * + * @param[in] operationType Operation type + * @param[in] numOfStaticParams Number of static params defined by the op + * @param[in] staticParams Array of static params to the op + * @param[in,out] numOfInputs Number of input tensors to the op + * @param[in,out] inputsQuantTypes Array of Quantization info for each input tensor + * @param[in,out] inputsLayouts Array of layout type for each input tensor + * @param[in,out] numOfOutputs Number of output tensors to the op + * @param[in,out] outputsQuantTypes Array of Quantization info for each output tensor + * @param[in,out] outputsLayouts Array of layout type for each output tensor + * @return error code, indicating status of query + */ + +SnpeUdo_ErrorType_t +SnpeUdo_queryOperation (SnpeUdo_String_t operationType, + uint32_t numOfStaticParams, + const SnpeUdo_Param_t* staticParams, + uint32_t* numOfInputs, + SnpeUdo_QuantizationType_t** inputsQuantTypes, + SnpeUdo_HexNNTensorLayout_t** inputsLayouts, + uint32_t* numOfOutputs, + SnpeUdo_QuantizationType_t** outputsQuantTypes, + SnpeUdo_HexNNTensorLayout_t** outputsLayouts); + +typedef SnpeUdo_ErrorType_t (*SnpeUdo_QueryOperationFunction_t) (SnpeUdo_String_t, + uint32_t, + const SnpeUdo_Param_t*, + uint32_t*, + SnpeUdo_QuantizationType_t**, + SnpeUdo_HexNNTensorLayout_t**, + uint32_t*, + SnpeUdo_QuantizationType_t**, + SnpeUdo_HexNNTensorLayout_t**); + + + +// Global infrastructure functions supported by Hexagon-NN v2 +typedef void (*workerThread_t) (void* perOpInfrastructure, void* userData); +typedef int (*udoSetOutputTensorSize_t) (void* perOpInfrastructure, uint32_t outIdx, uint32_t size); +typedef int (*udoGetInputD32Paddings_t) (void* perOpInfrastructure, uint32_t inIdx, + uint32_t* heightPadBefore, uint32_t* heightPadAfter, + uint32_t* widthPadBefore, uint32_t* widthPadAfter, + uint32_t* depthPadBefore, uint32_t* depthPadAfter); +typedef int (*udoSetOutputD32ShapeSizePaddings_t) (void* perOpInfrastructure, uint32_t outIdx, + uint32_t batch, + uint32_t height, uint32_t heightPadBefore, uint32_t heightPadAfter, + uint32_t width, uint32_t widthPadBefore, uint32_t widthPadAfter, + uint32_t depth, uint32_t depthPadBefore, uint32_t depthPadAfter, + SnpeUdo_DataType_t dataType); +typedef void* (*udoMemalign_t) (size_t n, size_t size); +typedef void* (*udoMalloc_t) (size_t size); +typedef void* (*udoCalloc_t) (size_t n, size_t size); +typedef void (*udoFree_t) (void* ptr); +typedef uint32_t (*udoGetVtcmSize_t) (void* perOpInfrastructure); +typedef void* (*udoGetVtcmPtr_t) (void* perOpInfrastructure); +typedef uint32_t (*udoVtcmIsReal_t) (void* perOpInfrastructure); +typedef void (*udoRunWorkerThreads_t) (void* perOpInfrastructure, uint32_t nThreads, workerThread_t w, void* userData); + +typedef struct hexNNv2GlobalInfra { + udoSetOutputTensorSize_t udoSetOutputTensorSize; + udoGetInputD32Paddings_t udoGetInputD32Paddings; + udoSetOutputD32ShapeSizePaddings_t udoSetOutputD32ShapeSizePaddings; + udoMemalign_t udoMemalign; + udoMalloc_t udoMalloc; + udoCalloc_t udoCalloc; + udoFree_t udoFree; + udoGetVtcmSize_t udoGetVtcmSize; + udoGetVtcmPtr_t udoGetVtcmPtr; + udoVtcmIsReal_t udoVtcmIsReal; + udoRunWorkerThreads_t udoRunWorkerThreads; +} SnpeUdo_HexNNv2GlobalInfra_t; + +// hexnn types +typedef enum hexnnInfraType { + UDO_INFRA_HEXNN_V2, + UDO_INFRA_HEXNN_V3 // reserved, do not use +} SnpeUdo_HexNNInfraType_t; + + +/** + * @brief Infrastructures needed by a developer of DSP Hexnn UDO Implementation library. + * + * The framework/runtime which loads the Hexnn UDO implementation library provides + * this infrastructure to the loaded library by calling "SnpeUdo_initImplLibrary" + * function, and passing it (cast to void*). The Hexnn UDO library is expected + * to cast it back to this structure. + * + */ +typedef struct dspGlobalInfrastructure { + SnpeUdo_Version_t dspInfraVersion; // api version + SnpeUdo_HexNNInfraType_t infraType; + SnpeUdo_HexNNv2GlobalInfra_t hexNNv2Infra; +} SnpeUdo_DspGlobalInfrastructure_t; + + +/** + * hexnn v2 per op factory infrastructure + * + * The framework/runtime passes per op factory infrastructure as a void pointer + * to HexNN UDO implementation library by calling function "SnpeUdo_createOpFactory". + * UDO implementation library is expected to cast it back to this following struct. + * + */ +typedef struct hexnnv2OpFactoryInfra { + unsigned long graphId; +} SnpeUdo_HexNNv2OpFactoryInfra_t; + + +/** + * hexnn v2 per operation infrastructure + * + * The framework/runtime passes per operation infrastructure as a void pointer + * to HexNN UDO implementation library by calling function "SnpeUdo_createOperation". + * UDO implementation library is expected to cast it to the following type and save it. + * + * This is needed to be passed back into some functions from global infrastructure. + * + */ +typedef void* SnpeUdo_HexNNv2OpInfra_t; + +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ + +#endif // SNPE_UDO_IMPL_DSP_H diff --git a/phonelibs/snpe/include/SnpeUdo/UdoImplGpu.h b/phonelibs/snpe/include/SnpeUdo/UdoImplGpu.h new file mode 100644 index 00000000000000..1af654d110c26b --- /dev/null +++ b/phonelibs/snpe/include/SnpeUdo/UdoImplGpu.h @@ -0,0 +1,112 @@ +//============================================================================== +// +// Copyright (c) 2019-2020 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================== + +// Header to be used by a GPU UDO Implementation library + +#ifndef SNPE_UDO_IMPL_GPU_H +#define SNPE_UDO_IMPL_GPU_H + +#include "CL/cl.h" +#include "SnpeUdo/UdoBase.h" + +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +/** + * This header defines version 0.0.0 of the GPU UDO Infrastructure. + * It defines the interpretation of the global and per-OpFactory infrastructure pointers + * as well as the interpretation of tensorData pointers. + * + * The per-Operation infrastructure pointer is defined to be null, and should not be used. + * + * The SnpeUdoTensorParam_t struct below provides the interpretation for + * the tensorData opaque pointer for SnpeUdoTensorParams representing inputs or outputs. + * + * The tensorData opaque pointer populated in SnpeUdoScalarParam_t structs should be interpreted + * as a host-readable data pointer. + * + */ + +/** + * @brief Function to retrieve opencl program from Program Cache repository. + * @param programCache is opaque pointer to Program Cache repository provided by + * SNPE GPU UDO runtime. + * @param programName is name associated with opencl program for UDO. + * @param program is pointer to opencl program which will be populated with + * valid opencl program if found in Program Cache repository. + * @return SnpeUdo_ErrorType_t is error type returned. SNPE_UDO_NO_ERROR is returned + * on success. + */ +typedef SnpeUdo_ErrorType_t (*SnpeUdo_getProgram_t) + (void* programCache, const char* programName, cl_program* program); + +/** + * @brief Function to store valid opencl program in Program Cache repository. + * @param programCache is opaque pointer to Program Cache repository provided by + * SNPE GPU UDO runtime. + * @param programName is name associated with opencl program for UDO. + * @param program is valid opencl program after program is built. + * @return SnpeUdo_ErrorType_t is error type returned. SNPE_UDO_NO_ERROR is returned + * on success. + * */ +typedef SnpeUdo_ErrorType_t (*SnpeUdo_storeProgram_t) + (void* programCache, const char * programName, cl_program program); + +/** + * @brief Global Infrastructure Definition for GPU UDO Implementations. + */ +typedef struct { + // Infrastructure definition version. This header is 0.0.0 + SnpeUdo_Version_t gpuInfraVersion; + SnpeUdo_getProgram_t SnpeUdo_getProgram; + SnpeUdo_storeProgram_t SnpeUdo_storeProgram; +} SnpeUdo_GpuInfrastructure_t; + +/** + * @brief Per OpFactory Infrastructure Definition for GPU UDO Implementations. + * @note This version of the infrastructure definition guarantees that the same + * Per OpFactory infrastructure pointer will be provided to all OpFactories + * in the same network. + */ +typedef struct +{ + cl_context context; + cl_command_queue commandQueue; + void* programCache; +} SnpeUdo_GpuOpFactoryInfrastructure_t; + +/** + * @brief Opaque tensorData definition for operation inputs and outputs. + * + * The following is a list of all SnpeUdoTensorLayout_t values supported by the + * GPU UDO implementation, and how the parameters of the struct should be + * interpreted in each case: + * + * SNPE_UDO_LAYOUT_NHWC: + * mem shall be single-element array, pointing to a cl buffer memory object. + * the dimensions of this object match the dimensions specified in the encompassing + * SnpeUdoTensorParam_t's currDimensions. + * + * memCount shall be 1. + * + * paddedRank and paddedDimensions are undefined and shall be ignored by the UDO + * implementation. + * + */ +typedef struct +{ + cl_mem* mem; + uint32_t memCount; + uint32_t paddedRank; + uint32_t* paddedDimensions; + +} SnpeUdo_GpuTensorData_t; + +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ + +#endif // SNPE_UDO_IMPL_GPU_H diff --git a/phonelibs/snpe/include/SnpeUdo/UdoReg.h b/phonelibs/snpe/include/SnpeUdo/UdoReg.h new file mode 100644 index 00000000000000..a5d239883355ab --- /dev/null +++ b/phonelibs/snpe/include/SnpeUdo/UdoReg.h @@ -0,0 +1,108 @@ +//============================================================================== +// +// Copyright (c) 2019-2020 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================== + +#ifndef SNPE_UDO_REG_H +#define SNPE_UDO_REG_H + +#include "SnpeUdo/UdoShared.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +/** + * @brief Initialize the shared library's data structures. Calling any other + * library function before this one will result in an error being returned. + * + * @return Error code + */ +SnpeUdo_ErrorType_t +SnpeUdo_initRegLibrary(void); + +typedef SnpeUdo_ErrorType_t +(*SnpeUdo_InitRegLibraryFunction_t)(void); + +/** + * @brief A function to query the API version of the UDO registration library. + * The function populates a SnpeUdo_LibVersion_t struct, which contains a SnpeUdo_Version_t + * struct for API version and library version. + * + * @param[in, out] version A pointer to struct which contains major, minor, teeny information for + * library and api versions. + * + * @return Error code + */ +SnpeUdo_ErrorType_t +SnpeUdo_getRegLibraryVersion(SnpeUdo_LibVersion_t** version); + +typedef SnpeUdo_ErrorType_t +(*SnpeUdo_getRegLibraryVersion_t)(SnpeUdo_LibVersion_t** version); + +/** + * @brief Release the shared library's data structures, and invalidate any + * handles returned by the library. The behavior of any outstanding + * asynchronous calls made to this library when this function is called + * are undefined. All library functions (except SnpeUdo_InitRegLibrary) will + * return an error after this function has been successfully called. + * + * It should be possible to call SnpeUdo_InitRegLibrary after calling this + * function, and re-initialize the library. + * + * @return Error code + */ +SnpeUdo_ErrorType_t +SnpeUdo_terminateRegLibrary(void); + +typedef SnpeUdo_ErrorType_t +(*SnpeUdo_TerminateRegLibraryFunction_t)(void); + + +/** + * @brief A function to query the info on the UDO set. + * The function populates a structure which contains information about + * the package and operations contained in it. + * + * @param[in, out] registrationInfo A struct which contains information on the set of UDOs + * + * @return Error code + * + */ +SnpeUdo_ErrorType_t +SnpeUdo_getRegInfo(SnpeUdo_RegInfo_t** registrationInfo); + +typedef SnpeUdo_ErrorType_t +(*SnpeUdo_GetRegInfoFunction_t)(SnpeUdo_RegInfo_t** registrationInfo); + +/** + * @brief A function to validate that a set of params is supported by an operation + * The function receives an operation definition struct, and returns if this configuration is + * supported (e.g. if an operation can be created using this configuration) + * + * @param[in] opDefinition A struct of SnpeUdo_OpDefinition type, containing the information needed to + * validate that an operation can be created with this configuration. + * + * @return Error code, indicating is the operation can be created on this set or not. + * + */ +SnpeUdo_ErrorType_t +SnpeUdo_validateOperation(SnpeUdo_OpDefinition_t* opDefinition); + +typedef SnpeUdo_ErrorType_t +(*SnpeUdo_ValidateOperationFunction_t)(SnpeUdo_OpDefinition_t* opDefinition); + +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif //SNPE_UDO_REG_H diff --git a/phonelibs/snpe/include/SnpeUdo/UdoShared.h b/phonelibs/snpe/include/SnpeUdo/UdoShared.h new file mode 100644 index 00000000000000..6fd50c318acc28 --- /dev/null +++ b/phonelibs/snpe/include/SnpeUdo/UdoShared.h @@ -0,0 +1,46 @@ +//============================================================================== +// +// Copyright (c) 2019-2020 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================== + +#ifndef SNPE_UDO_SHARED_H +#define SNPE_UDO_SHARED_H + +#include "SnpeUdo/UdoBase.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +/** + * @brief A function to return the various versions as they relate to the UDO + * The function returns a struct containing the the following: + * libVersion: the version of the implementation library compiled for the UDO. Set by user + * apiVersion: the version of the UDO API used in compiling the implementation library. + * Set by SNPE + * + * @param[in, out] version A pointer to Version struct of type SnpeUdo_LibVersion_t + * + * @return Error code + * + */ +SnpeUdo_ErrorType_t +SnpeUdo_getVersion (SnpeUdo_LibVersion_t** version); + +typedef SnpeUdo_ErrorType_t +(*SnpeUdo_GetVersionFunction_t) (SnpeUdo_LibVersion_t** version); + +#ifdef __cplusplus +} // extern "C" +#endif + +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ + +#endif // SNPE_UDO_SHARED_H diff --git a/phonelibs/snpe/x86_64-linux-clang/libSNPE.so b/phonelibs/snpe/x86_64-linux-clang/libSNPE.so deleted file mode 100644 index cc1de85075bfba..00000000000000 Binary files a/phonelibs/snpe/x86_64-linux-clang/libSNPE.so and /dev/null differ diff --git a/phonelibs/snpe/x86_64-linux-clang/libsymphony-cpu.so b/phonelibs/snpe/x86_64-linux-clang/libsymphony-cpu.so deleted file mode 100755 index 70d6f146a34a0a..00000000000000 Binary files a/phonelibs/snpe/x86_64-linux-clang/libsymphony-cpu.so and /dev/null differ diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/anchor.h b/phonelibs/yaml-cpp/include/yaml-cpp/anchor.h deleted file mode 100644 index 06759c724d28e8..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/anchor.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include - -namespace YAML { -typedef std::size_t anchor_t; -const anchor_t NullAnchor = 0; -} - -#endif // ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/binary.h b/phonelibs/yaml-cpp/include/yaml-cpp/binary.h deleted file mode 100644 index 29d5dbd027a94b..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/binary.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include -#include - -#include "yaml-cpp/dll.h" - -namespace YAML { -YAML_CPP_API std::string EncodeBase64(const unsigned char *data, - std::size_t size); -YAML_CPP_API std::vector DecodeBase64(const std::string &input); - -class YAML_CPP_API Binary { - public: - Binary() : m_unownedData(0), m_unownedSize(0) {} - Binary(const unsigned char *data_, std::size_t size_) - : m_unownedData(data_), m_unownedSize(size_) {} - - bool owned() const { return !m_unownedData; } - std::size_t size() const { return owned() ? m_data.size() : m_unownedSize; } - const unsigned char *data() const { - return owned() ? &m_data[0] : m_unownedData; - } - - void swap(std::vector &rhs) { - if (m_unownedData) { - m_data.swap(rhs); - rhs.clear(); - rhs.resize(m_unownedSize); - std::copy(m_unownedData, m_unownedData + m_unownedSize, rhs.begin()); - m_unownedData = 0; - m_unownedSize = 0; - } else { - m_data.swap(rhs); - } - } - - bool operator==(const Binary &rhs) const { - const std::size_t s = size(); - if (s != rhs.size()) - return false; - const unsigned char *d1 = data(); - const unsigned char *d2 = rhs.data(); - for (std::size_t i = 0; i < s; i++) { - if (*d1++ != *d2++) - return false; - } - return true; - } - - bool operator!=(const Binary &rhs) const { return !(*this == rhs); } - - private: - std::vector m_data; - const unsigned char *m_unownedData; - std::size_t m_unownedSize; -}; -} - -#endif // BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/contrib/anchordict.h b/phonelibs/yaml-cpp/include/yaml-cpp/contrib/anchordict.h deleted file mode 100644 index 78db9ec9288275..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/contrib/anchordict.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include - -#include "../anchor.h" - -namespace YAML { -/** - * An object that stores and retrieves values correlating to {@link anchor_t} - * values. - * - *

Efficient implementation that can make assumptions about how - * {@code anchor_t} values are assigned by the {@link Parser} class. - */ -template -class AnchorDict { - public: - void Register(anchor_t anchor, T value) { - if (anchor > m_data.size()) { - m_data.resize(anchor); - } - m_data[anchor - 1] = value; - } - - T Get(anchor_t anchor) const { return m_data[anchor - 1]; } - - private: - std::vector m_data; -}; -} - -#endif // ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/contrib/graphbuilder.h b/phonelibs/yaml-cpp/include/yaml-cpp/contrib/graphbuilder.h deleted file mode 100644 index 7c2159b4659742..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/contrib/graphbuilder.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/mark.h" -#include - -namespace YAML { -class Parser; - -// GraphBuilderInterface -// . Abstraction of node creation -// . pParentNode is always NULL or the return value of one of the NewXXX() -// functions. -class GraphBuilderInterface { - public: - // Create and return a new node with a null value. - virtual void *NewNull(const Mark &mark, void *pParentNode) = 0; - - // Create and return a new node with the given tag and value. - virtual void *NewScalar(const Mark &mark, const std::string &tag, - void *pParentNode, const std::string &value) = 0; - - // Create and return a new sequence node - virtual void *NewSequence(const Mark &mark, const std::string &tag, - void *pParentNode) = 0; - - // Add pNode to pSequence. pNode was created with one of the NewXxx() - // functions and pSequence with NewSequence(). - virtual void AppendToSequence(void *pSequence, void *pNode) = 0; - - // Note that no moew entries will be added to pSequence - virtual void SequenceComplete(void *pSequence) { (void)pSequence; } - - // Create and return a new map node - virtual void *NewMap(const Mark &mark, const std::string &tag, - void *pParentNode) = 0; - - // Add the pKeyNode => pValueNode mapping to pMap. pKeyNode and pValueNode - // were created with one of the NewXxx() methods and pMap with NewMap(). - virtual void AssignInMap(void *pMap, void *pKeyNode, void *pValueNode) = 0; - - // Note that no more assignments will be made in pMap - virtual void MapComplete(void *pMap) { (void)pMap; } - - // Return the node that should be used in place of an alias referencing - // pNode (pNode by default) - virtual void *AnchorReference(const Mark &mark, void *pNode) { - (void)mark; - return pNode; - } -}; - -// Typesafe wrapper for GraphBuilderInterface. Assumes that Impl defines -// Node, Sequence, and Map types. Sequence and Map must derive from Node -// (unless Node is defined as void). Impl must also implement function with -// all of the same names as the virtual functions in GraphBuilderInterface -// -- including the ones with default implementations -- but with the -// prototypes changed to accept an explicit Node*, Sequence*, or Map* where -// appropriate. -template -class GraphBuilder : public GraphBuilderInterface { - public: - typedef typename Impl::Node Node; - typedef typename Impl::Sequence Sequence; - typedef typename Impl::Map Map; - - GraphBuilder(Impl &impl) : m_impl(impl) { - Map *pMap = NULL; - Sequence *pSeq = NULL; - Node *pNode = NULL; - - // Type consistency checks - pNode = pMap; - pNode = pSeq; - } - - GraphBuilderInterface &AsBuilderInterface() { return *this; } - - virtual void *NewNull(const Mark &mark, void *pParentNode) { - return CheckType(m_impl.NewNull(mark, AsNode(pParentNode))); - } - - virtual void *NewScalar(const Mark &mark, const std::string &tag, - void *pParentNode, const std::string &value) { - return CheckType( - m_impl.NewScalar(mark, tag, AsNode(pParentNode), value)); - } - - virtual void *NewSequence(const Mark &mark, const std::string &tag, - void *pParentNode) { - return CheckType( - m_impl.NewSequence(mark, tag, AsNode(pParentNode))); - } - virtual void AppendToSequence(void *pSequence, void *pNode) { - m_impl.AppendToSequence(AsSequence(pSequence), AsNode(pNode)); - } - virtual void SequenceComplete(void *pSequence) { - m_impl.SequenceComplete(AsSequence(pSequence)); - } - - virtual void *NewMap(const Mark &mark, const std::string &tag, - void *pParentNode) { - return CheckType(m_impl.NewMap(mark, tag, AsNode(pParentNode))); - } - virtual void AssignInMap(void *pMap, void *pKeyNode, void *pValueNode) { - m_impl.AssignInMap(AsMap(pMap), AsNode(pKeyNode), AsNode(pValueNode)); - } - virtual void MapComplete(void *pMap) { m_impl.MapComplete(AsMap(pMap)); } - - virtual void *AnchorReference(const Mark &mark, void *pNode) { - return CheckType(m_impl.AnchorReference(mark, AsNode(pNode))); - } - - private: - Impl &m_impl; - - // Static check for pointer to T - template - static T *CheckType(U *p) { - return p; - } - - static Node *AsNode(void *pNode) { return static_cast(pNode); } - static Sequence *AsSequence(void *pSeq) { - return static_cast(pSeq); - } - static Map *AsMap(void *pMap) { return static_cast(pMap); } -}; - -void *BuildGraphOfNextDocument(Parser &parser, - GraphBuilderInterface &graphBuilder); - -template -typename Impl::Node *BuildGraphOfNextDocument(Parser &parser, Impl &impl) { - GraphBuilder graphBuilder(impl); - return static_cast( - BuildGraphOfNextDocument(parser, graphBuilder)); -} -} - -#endif // GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/dll.h b/phonelibs/yaml-cpp/include/yaml-cpp/dll.h deleted file mode 100644 index a32c06b2e308aa..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/dll.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -// The following ifdef block is the standard way of creating macros which make -// exporting from a DLL simpler. All files within this DLL are compiled with the -// yaml_cpp_EXPORTS symbol defined on the command line. This symbol should not -// be defined on any project that uses this DLL. This way any other project -// whose source files include this file see YAML_CPP_API functions as being -// imported from a DLL, whereas this DLL sees symbols defined with this macro as -// being exported. -#undef YAML_CPP_API - -#ifdef YAML_CPP_DLL // Using or Building YAML-CPP DLL (definition defined - // manually) -#ifdef yaml_cpp_EXPORTS // Building YAML-CPP DLL (definition created by CMake - // or defined manually) -// #pragma message( "Defining YAML_CPP_API for DLL export" ) -#define YAML_CPP_API __declspec(dllexport) -#else // yaml_cpp_EXPORTS -// #pragma message( "Defining YAML_CPP_API for DLL import" ) -#define YAML_CPP_API __declspec(dllimport) -#endif // yaml_cpp_EXPORTS -#else // YAML_CPP_DLL -#define YAML_CPP_API -#endif // YAML_CPP_DLL - -#endif // DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/emitfromevents.h b/phonelibs/yaml-cpp/include/yaml-cpp/emitfromevents.h deleted file mode 100644 index f14b051ab0ee8b..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/emitfromevents.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include - -#include "yaml-cpp/anchor.h" -#include "yaml-cpp/emitterstyle.h" -#include "yaml-cpp/eventhandler.h" - -namespace YAML { -struct Mark; -} // namespace YAML - -namespace YAML { -class Emitter; - -class EmitFromEvents : public EventHandler { - public: - EmitFromEvents(Emitter& emitter); - - virtual void OnDocumentStart(const Mark& mark); - virtual void OnDocumentEnd(); - - virtual void OnNull(const Mark& mark, anchor_t anchor); - virtual void OnAlias(const Mark& mark, anchor_t anchor); - virtual void OnScalar(const Mark& mark, const std::string& tag, - anchor_t anchor, const std::string& value); - - virtual void OnSequenceStart(const Mark& mark, const std::string& tag, - anchor_t anchor, EmitterStyle::value style); - virtual void OnSequenceEnd(); - - virtual void OnMapStart(const Mark& mark, const std::string& tag, - anchor_t anchor, EmitterStyle::value style); - virtual void OnMapEnd(); - - private: - void BeginNode(); - void EmitProps(const std::string& tag, anchor_t anchor); - - private: - Emitter& m_emitter; - - struct State { - enum value { WaitingForSequenceEntry, WaitingForKey, WaitingForValue }; - }; - std::stack m_stateStack; -}; -} - -#endif // EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/emitter.h b/phonelibs/yaml-cpp/include/yaml-cpp/emitter.h deleted file mode 100644 index ef92cc4035b441..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/emitter.h +++ /dev/null @@ -1,254 +0,0 @@ -#ifndef EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include -#include -#include -#include - -#include "yaml-cpp/binary.h" -#include "yaml-cpp/dll.h" -#include "yaml-cpp/emitterdef.h" -#include "yaml-cpp/emittermanip.h" -#include "yaml-cpp/noncopyable.h" -#include "yaml-cpp/null.h" -#include "yaml-cpp/ostream_wrapper.h" - -namespace YAML { -class Binary; -struct _Null; -} // namespace YAML - -namespace YAML { -class EmitterState; - -class YAML_CPP_API Emitter : private noncopyable { - public: - Emitter(); - explicit Emitter(std::ostream& stream); - ~Emitter(); - - // output - const char* c_str() const; - std::size_t size() const; - - // state checking - bool good() const; - const std::string GetLastError() const; - - // global setters - bool SetOutputCharset(EMITTER_MANIP value); - bool SetStringFormat(EMITTER_MANIP value); - bool SetBoolFormat(EMITTER_MANIP value); - bool SetIntBase(EMITTER_MANIP value); - bool SetSeqFormat(EMITTER_MANIP value); - bool SetMapFormat(EMITTER_MANIP value); - bool SetIndent(std::size_t n); - bool SetPreCommentIndent(std::size_t n); - bool SetPostCommentIndent(std::size_t n); - bool SetFloatPrecision(std::size_t n); - bool SetDoublePrecision(std::size_t n); - - // local setters - Emitter& SetLocalValue(EMITTER_MANIP value); - Emitter& SetLocalIndent(const _Indent& indent); - Emitter& SetLocalPrecision(const _Precision& precision); - - // overloads of write - Emitter& Write(const std::string& str); - Emitter& Write(bool b); - Emitter& Write(char ch); - Emitter& Write(const _Alias& alias); - Emitter& Write(const _Anchor& anchor); - Emitter& Write(const _Tag& tag); - Emitter& Write(const _Comment& comment); - Emitter& Write(const _Null& n); - Emitter& Write(const Binary& binary); - - template - Emitter& WriteIntegralType(T value); - - template - Emitter& WriteStreamable(T value); - - private: - template - void SetStreamablePrecision(std::stringstream&) {} - std::size_t GetFloatPrecision() const; - std::size_t GetDoublePrecision() const; - - void PrepareIntegralStream(std::stringstream& stream) const; - void StartedScalar(); - - private: - void EmitBeginDoc(); - void EmitEndDoc(); - void EmitBeginSeq(); - void EmitEndSeq(); - void EmitBeginMap(); - void EmitEndMap(); - void EmitNewline(); - void EmitKindTag(); - void EmitTag(bool verbatim, const _Tag& tag); - - void PrepareNode(EmitterNodeType::value child); - void PrepareTopNode(EmitterNodeType::value child); - void FlowSeqPrepareNode(EmitterNodeType::value child); - void BlockSeqPrepareNode(EmitterNodeType::value child); - - void FlowMapPrepareNode(EmitterNodeType::value child); - - void FlowMapPrepareLongKey(EmitterNodeType::value child); - void FlowMapPrepareLongKeyValue(EmitterNodeType::value child); - void FlowMapPrepareSimpleKey(EmitterNodeType::value child); - void FlowMapPrepareSimpleKeyValue(EmitterNodeType::value child); - - void BlockMapPrepareNode(EmitterNodeType::value child); - - void BlockMapPrepareLongKey(EmitterNodeType::value child); - void BlockMapPrepareLongKeyValue(EmitterNodeType::value child); - void BlockMapPrepareSimpleKey(EmitterNodeType::value child); - void BlockMapPrepareSimpleKeyValue(EmitterNodeType::value child); - - void SpaceOrIndentTo(bool requireSpace, std::size_t indent); - - const char* ComputeFullBoolName(bool b) const; - bool CanEmitNewline() const; - - private: - std::unique_ptr m_pState; - ostream_wrapper m_stream; -}; - -template -inline Emitter& Emitter::WriteIntegralType(T value) { - if (!good()) - return *this; - - PrepareNode(EmitterNodeType::Scalar); - - std::stringstream stream; - PrepareIntegralStream(stream); - stream << value; - m_stream << stream.str(); - - StartedScalar(); - - return *this; -} - -template -inline Emitter& Emitter::WriteStreamable(T value) { - if (!good()) - return *this; - - PrepareNode(EmitterNodeType::Scalar); - - std::stringstream stream; - SetStreamablePrecision(stream); - stream << value; - m_stream << stream.str(); - - StartedScalar(); - - return *this; -} - -template <> -inline void Emitter::SetStreamablePrecision(std::stringstream& stream) { - stream.precision(static_cast(GetFloatPrecision())); -} - -template <> -inline void Emitter::SetStreamablePrecision(std::stringstream& stream) { - stream.precision(static_cast(GetDoublePrecision())); -} - -// overloads of insertion -inline Emitter& operator<<(Emitter& emitter, const std::string& v) { - return emitter.Write(v); -} -inline Emitter& operator<<(Emitter& emitter, bool v) { - return emitter.Write(v); -} -inline Emitter& operator<<(Emitter& emitter, char v) { - return emitter.Write(v); -} -inline Emitter& operator<<(Emitter& emitter, unsigned char v) { - return emitter.Write(static_cast(v)); -} -inline Emitter& operator<<(Emitter& emitter, const _Alias& v) { - return emitter.Write(v); -} -inline Emitter& operator<<(Emitter& emitter, const _Anchor& v) { - return emitter.Write(v); -} -inline Emitter& operator<<(Emitter& emitter, const _Tag& v) { - return emitter.Write(v); -} -inline Emitter& operator<<(Emitter& emitter, const _Comment& v) { - return emitter.Write(v); -} -inline Emitter& operator<<(Emitter& emitter, const _Null& v) { - return emitter.Write(v); -} -inline Emitter& operator<<(Emitter& emitter, const Binary& b) { - return emitter.Write(b); -} - -inline Emitter& operator<<(Emitter& emitter, const char* v) { - return emitter.Write(std::string(v)); -} - -inline Emitter& operator<<(Emitter& emitter, int v) { - return emitter.WriteIntegralType(v); -} -inline Emitter& operator<<(Emitter& emitter, unsigned int v) { - return emitter.WriteIntegralType(v); -} -inline Emitter& operator<<(Emitter& emitter, short v) { - return emitter.WriteIntegralType(v); -} -inline Emitter& operator<<(Emitter& emitter, unsigned short v) { - return emitter.WriteIntegralType(v); -} -inline Emitter& operator<<(Emitter& emitter, long v) { - return emitter.WriteIntegralType(v); -} -inline Emitter& operator<<(Emitter& emitter, unsigned long v) { - return emitter.WriteIntegralType(v); -} -inline Emitter& operator<<(Emitter& emitter, long long v) { - return emitter.WriteIntegralType(v); -} -inline Emitter& operator<<(Emitter& emitter, unsigned long long v) { - return emitter.WriteIntegralType(v); -} - -inline Emitter& operator<<(Emitter& emitter, float v) { - return emitter.WriteStreamable(v); -} -inline Emitter& operator<<(Emitter& emitter, double v) { - return emitter.WriteStreamable(v); -} - -inline Emitter& operator<<(Emitter& emitter, EMITTER_MANIP value) { - return emitter.SetLocalValue(value); -} - -inline Emitter& operator<<(Emitter& emitter, _Indent indent) { - return emitter.SetLocalIndent(indent); -} - -inline Emitter& operator<<(Emitter& emitter, _Precision precision) { - return emitter.SetLocalPrecision(precision); -} -} - -#endif // EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/emitterdef.h b/phonelibs/yaml-cpp/include/yaml-cpp/emitterdef.h deleted file mode 100644 index 0b426957fae276..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/emitterdef.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -namespace YAML { -struct EmitterNodeType { - enum value { NoType, Property, Scalar, FlowSeq, BlockSeq, FlowMap, BlockMap }; -}; -} - -#endif // EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/emittermanip.h b/phonelibs/yaml-cpp/include/yaml-cpp/emittermanip.h deleted file mode 100644 index 89f7256714e30f..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/emittermanip.h +++ /dev/null @@ -1,137 +0,0 @@ -#ifndef EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include - -namespace YAML { -enum EMITTER_MANIP { - // general manipulators - Auto, - TagByKind, - Newline, - - // output character set - EmitNonAscii, - EscapeNonAscii, - - // string manipulators - // Auto, // duplicate - SingleQuoted, - DoubleQuoted, - Literal, - - // bool manipulators - YesNoBool, // yes, no - TrueFalseBool, // true, false - OnOffBool, // on, off - UpperCase, // TRUE, N - LowerCase, // f, yes - CamelCase, // No, Off - LongBool, // yes, On - ShortBool, // y, t - - // int manipulators - Dec, - Hex, - Oct, - - // document manipulators - BeginDoc, - EndDoc, - - // sequence manipulators - BeginSeq, - EndSeq, - Flow, - Block, - - // map manipulators - BeginMap, - EndMap, - Key, - Value, - // Flow, // duplicate - // Block, // duplicate - // Auto, // duplicate - LongKey -}; - -struct _Indent { - _Indent(int value_) : value(value_) {} - int value; -}; - -inline _Indent Indent(int value) { return _Indent(value); } - -struct _Alias { - _Alias(const std::string& content_) : content(content_) {} - std::string content; -}; - -inline _Alias Alias(const std::string content) { return _Alias(content); } - -struct _Anchor { - _Anchor(const std::string& content_) : content(content_) {} - std::string content; -}; - -inline _Anchor Anchor(const std::string content) { return _Anchor(content); } - -struct _Tag { - struct Type { - enum value { Verbatim, PrimaryHandle, NamedHandle }; - }; - - explicit _Tag(const std::string& prefix_, const std::string& content_, - Type::value type_) - : prefix(prefix_), content(content_), type(type_) {} - std::string prefix; - std::string content; - Type::value type; -}; - -inline _Tag VerbatimTag(const std::string content) { - return _Tag("", content, _Tag::Type::Verbatim); -} - -inline _Tag LocalTag(const std::string content) { - return _Tag("", content, _Tag::Type::PrimaryHandle); -} - -inline _Tag LocalTag(const std::string& prefix, const std::string content) { - return _Tag(prefix, content, _Tag::Type::NamedHandle); -} - -inline _Tag SecondaryTag(const std::string content) { - return _Tag("", content, _Tag::Type::NamedHandle); -} - -struct _Comment { - _Comment(const std::string& content_) : content(content_) {} - std::string content; -}; - -inline _Comment Comment(const std::string content) { return _Comment(content); } - -struct _Precision { - _Precision(int floatPrecision_, int doublePrecision_) - : floatPrecision(floatPrecision_), doublePrecision(doublePrecision_) {} - - int floatPrecision; - int doublePrecision; -}; - -inline _Precision FloatPrecision(int n) { return _Precision(n, -1); } - -inline _Precision DoublePrecision(int n) { return _Precision(-1, n); } - -inline _Precision Precision(int n) { return _Precision(n, n); } -} - -#endif // EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/emitterstyle.h b/phonelibs/yaml-cpp/include/yaml-cpp/emitterstyle.h deleted file mode 100644 index 67bb3981b12cb2..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/emitterstyle.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -namespace YAML { -struct EmitterStyle { - enum value { Default, Block, Flow }; -}; -} - -#endif // EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/eventhandler.h b/phonelibs/yaml-cpp/include/yaml-cpp/eventhandler.h deleted file mode 100644 index efe381c62187e5..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/eventhandler.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include - -#include "yaml-cpp/anchor.h" -#include "yaml-cpp/emitterstyle.h" - -namespace YAML { -struct Mark; - -class EventHandler { - public: - virtual ~EventHandler() {} - - virtual void OnDocumentStart(const Mark& mark) = 0; - virtual void OnDocumentEnd() = 0; - - virtual void OnNull(const Mark& mark, anchor_t anchor) = 0; - virtual void OnAlias(const Mark& mark, anchor_t anchor) = 0; - virtual void OnScalar(const Mark& mark, const std::string& tag, - anchor_t anchor, const std::string& value) = 0; - - virtual void OnSequenceStart(const Mark& mark, const std::string& tag, - anchor_t anchor, EmitterStyle::value style) = 0; - virtual void OnSequenceEnd() = 0; - - virtual void OnMapStart(const Mark& mark, const std::string& tag, - anchor_t anchor, EmitterStyle::value style) = 0; - virtual void OnMapEnd() = 0; -}; -} - -#endif // EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/exceptions.h b/phonelibs/yaml-cpp/include/yaml-cpp/exceptions.h deleted file mode 100644 index a0b7e3c72b79d8..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/exceptions.h +++ /dev/null @@ -1,257 +0,0 @@ -#ifndef EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/mark.h" -#include "yaml-cpp/traits.h" -#include -#include -#include - -namespace YAML { -// error messages -namespace ErrorMsg { -const char* const YAML_DIRECTIVE_ARGS = - "YAML directives must have exactly one argument"; -const char* const YAML_VERSION = "bad YAML version: "; -const char* const YAML_MAJOR_VERSION = "YAML major version too large"; -const char* const REPEATED_YAML_DIRECTIVE = "repeated YAML directive"; -const char* const TAG_DIRECTIVE_ARGS = - "TAG directives must have exactly two arguments"; -const char* const REPEATED_TAG_DIRECTIVE = "repeated TAG directive"; -const char* const CHAR_IN_TAG_HANDLE = - "illegal character found while scanning tag handle"; -const char* const TAG_WITH_NO_SUFFIX = "tag handle with no suffix"; -const char* const END_OF_VERBATIM_TAG = "end of verbatim tag not found"; -const char* const END_OF_MAP = "end of map not found"; -const char* const END_OF_MAP_FLOW = "end of map flow not found"; -const char* const END_OF_SEQ = "end of sequence not found"; -const char* const END_OF_SEQ_FLOW = "end of sequence flow not found"; -const char* const MULTIPLE_TAGS = - "cannot assign multiple tags to the same node"; -const char* const MULTIPLE_ANCHORS = - "cannot assign multiple anchors to the same node"; -const char* const MULTIPLE_ALIASES = - "cannot assign multiple aliases to the same node"; -const char* const ALIAS_CONTENT = - "aliases can't have any content, *including* tags"; -const char* const INVALID_HEX = "bad character found while scanning hex number"; -const char* const INVALID_UNICODE = "invalid unicode: "; -const char* const INVALID_ESCAPE = "unknown escape character: "; -const char* const UNKNOWN_TOKEN = "unknown token"; -const char* const DOC_IN_SCALAR = "illegal document indicator in scalar"; -const char* const EOF_IN_SCALAR = "illegal EOF in scalar"; -const char* const CHAR_IN_SCALAR = "illegal character in scalar"; -const char* const TAB_IN_INDENTATION = - "illegal tab when looking for indentation"; -const char* const FLOW_END = "illegal flow end"; -const char* const BLOCK_ENTRY = "illegal block entry"; -const char* const MAP_KEY = "illegal map key"; -const char* const MAP_VALUE = "illegal map value"; -const char* const ALIAS_NOT_FOUND = "alias not found after *"; -const char* const ANCHOR_NOT_FOUND = "anchor not found after &"; -const char* const CHAR_IN_ALIAS = - "illegal character found while scanning alias"; -const char* const CHAR_IN_ANCHOR = - "illegal character found while scanning anchor"; -const char* const ZERO_INDENT_IN_BLOCK = - "cannot set zero indentation for a block scalar"; -const char* const CHAR_IN_BLOCK = "unexpected character in block scalar"; -const char* const AMBIGUOUS_ANCHOR = - "cannot assign the same alias to multiple nodes"; -const char* const UNKNOWN_ANCHOR = "the referenced anchor is not defined"; - -const char* const INVALID_NODE = - "invalid node; this may result from using a map iterator as a sequence " - "iterator, or vice-versa"; -const char* const INVALID_SCALAR = "invalid scalar"; -const char* const KEY_NOT_FOUND = "key not found"; -const char* const BAD_CONVERSION = "bad conversion"; -const char* const BAD_DEREFERENCE = "bad dereference"; -const char* const BAD_SUBSCRIPT = "operator[] call on a scalar"; -const char* const BAD_PUSHBACK = "appending to a non-sequence"; -const char* const BAD_INSERT = "inserting in a non-convertible-to-map"; - -const char* const UNMATCHED_GROUP_TAG = "unmatched group tag"; -const char* const UNEXPECTED_END_SEQ = "unexpected end sequence token"; -const char* const UNEXPECTED_END_MAP = "unexpected end map token"; -const char* const SINGLE_QUOTED_CHAR = - "invalid character in single-quoted string"; -const char* const INVALID_ANCHOR = "invalid anchor"; -const char* const INVALID_ALIAS = "invalid alias"; -const char* const INVALID_TAG = "invalid tag"; -const char* const BAD_FILE = "bad file"; - -template -inline const std::string KEY_NOT_FOUND_WITH_KEY( - const T&, typename disable_if>::type* = 0) { - return KEY_NOT_FOUND; -} - -inline const std::string KEY_NOT_FOUND_WITH_KEY(const std::string& key) { - std::stringstream stream; - stream << KEY_NOT_FOUND << ": " << key; - return stream.str(); -} - -template -inline const std::string KEY_NOT_FOUND_WITH_KEY( - const T& key, typename enable_if>::type* = 0) { - std::stringstream stream; - stream << KEY_NOT_FOUND << ": " << key; - return stream.str(); -} -} - -class YAML_CPP_API Exception : public std::runtime_error { - public: - Exception(const Mark& mark_, const std::string& msg_) - : std::runtime_error(build_what(mark_, msg_)), mark(mark_), msg(msg_) {} - virtual ~Exception() noexcept; - - Exception(const Exception&) = default; - - Mark mark; - std::string msg; - - private: - static const std::string build_what(const Mark& mark, - const std::string& msg) { - if (mark.is_null()) { - return msg.c_str(); - } - - std::stringstream output; - output << "yaml-cpp: error at line " << mark.line + 1 << ", column " - << mark.column + 1 << ": " << msg; - return output.str(); - } -}; - -class YAML_CPP_API ParserException : public Exception { - public: - ParserException(const Mark& mark_, const std::string& msg_) - : Exception(mark_, msg_) {} - ParserException(const ParserException&) = default; - virtual ~ParserException() noexcept; -}; - -class YAML_CPP_API RepresentationException : public Exception { - public: - RepresentationException(const Mark& mark_, const std::string& msg_) - : Exception(mark_, msg_) {} - RepresentationException(const RepresentationException&) = default; - virtual ~RepresentationException() noexcept; -}; - -// representation exceptions -class YAML_CPP_API InvalidScalar : public RepresentationException { - public: - InvalidScalar(const Mark& mark_) - : RepresentationException(mark_, ErrorMsg::INVALID_SCALAR) {} - InvalidScalar(const InvalidScalar&) = default; - virtual ~InvalidScalar() noexcept; -}; - -class YAML_CPP_API KeyNotFound : public RepresentationException { - public: - template - KeyNotFound(const Mark& mark_, const T& key_) - : RepresentationException(mark_, ErrorMsg::KEY_NOT_FOUND_WITH_KEY(key_)) { - } - KeyNotFound(const KeyNotFound&) = default; - virtual ~KeyNotFound() noexcept; -}; - -template -class YAML_CPP_API TypedKeyNotFound : public KeyNotFound { - public: - TypedKeyNotFound(const Mark& mark_, const T& key_) - : KeyNotFound(mark_, key_), key(key_) {} - virtual ~TypedKeyNotFound() noexcept {} - - T key; -}; - -template -inline TypedKeyNotFound MakeTypedKeyNotFound(const Mark& mark, - const T& key) { - return TypedKeyNotFound(mark, key); -} - -class YAML_CPP_API InvalidNode : public RepresentationException { - public: - InvalidNode() - : RepresentationException(Mark::null_mark(), ErrorMsg::INVALID_NODE) {} - InvalidNode(const InvalidNode&) = default; - virtual ~InvalidNode() noexcept; -}; - -class YAML_CPP_API BadConversion : public RepresentationException { - public: - explicit BadConversion(const Mark& mark_) - : RepresentationException(mark_, ErrorMsg::BAD_CONVERSION) {} - BadConversion(const BadConversion&) = default; - virtual ~BadConversion() noexcept; -}; - -template -class TypedBadConversion : public BadConversion { - public: - explicit TypedBadConversion(const Mark& mark_) : BadConversion(mark_) {} -}; - -class YAML_CPP_API BadDereference : public RepresentationException { - public: - BadDereference() - : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_DEREFERENCE) {} - BadDereference(const BadDereference&) = default; - virtual ~BadDereference() noexcept; -}; - -class YAML_CPP_API BadSubscript : public RepresentationException { - public: - BadSubscript() - : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_SUBSCRIPT) {} - BadSubscript(const BadSubscript&) = default; - virtual ~BadSubscript() noexcept; -}; - -class YAML_CPP_API BadPushback : public RepresentationException { - public: - BadPushback() - : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_PUSHBACK) {} - BadPushback(const BadPushback&) = default; - virtual ~BadPushback() noexcept; -}; - -class YAML_CPP_API BadInsert : public RepresentationException { - public: - BadInsert() - : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_INSERT) {} - BadInsert(const BadInsert&) = default; - virtual ~BadInsert() noexcept; -}; - -class YAML_CPP_API EmitterException : public Exception { - public: - EmitterException(const std::string& msg_) - : Exception(Mark::null_mark(), msg_) {} - EmitterException(const EmitterException&) = default; - virtual ~EmitterException() noexcept; -}; - -class YAML_CPP_API BadFile : public Exception { - public: - BadFile() : Exception(Mark::null_mark(), ErrorMsg::BAD_FILE) {} - BadFile(const BadFile&) = default; - virtual ~BadFile() noexcept; -}; -} - -#endif // EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/mark.h b/phonelibs/yaml-cpp/include/yaml-cpp/mark.h deleted file mode 100644 index bf94b4f41fc6c9..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/mark.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/dll.h" - -namespace YAML { -struct YAML_CPP_API Mark { - Mark() : pos(0), line(0), column(0) {} - - static const Mark null_mark() { return Mark(-1, -1, -1); } - - bool is_null() const { return pos == -1 && line == -1 && column == -1; } - - int pos; - int line, column; - - private: - Mark(int pos_, int line_, int column_) - : pos(pos_), line(line_), column(column_) {} -}; -} - -#endif // MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/node/convert.h b/phonelibs/yaml-cpp/include/yaml-cpp/node/convert.h deleted file mode 100644 index 45a878ab0c021c..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/node/convert.h +++ /dev/null @@ -1,331 +0,0 @@ -#ifndef NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include -#include -#include -#include -#include -#include - -#include "yaml-cpp/binary.h" -#include "yaml-cpp/node/impl.h" -#include "yaml-cpp/node/iterator.h" -#include "yaml-cpp/node/node.h" -#include "yaml-cpp/node/type.h" -#include "yaml-cpp/null.h" - -namespace YAML { -class Binary; -struct _Null; -template -struct convert; -} // namespace YAML - -namespace YAML { -namespace conversion { -inline bool IsInfinity(const std::string& input) { - return input == ".inf" || input == ".Inf" || input == ".INF" || - input == "+.inf" || input == "+.Inf" || input == "+.INF"; -} - -inline bool IsNegativeInfinity(const std::string& input) { - return input == "-.inf" || input == "-.Inf" || input == "-.INF"; -} - -inline bool IsNaN(const std::string& input) { - return input == ".nan" || input == ".NaN" || input == ".NAN"; -} -} - -// Node -template <> -struct convert { - static Node encode(const Node& rhs) { return rhs; } - - static bool decode(const Node& node, Node& rhs) { - rhs.reset(node); - return true; - } -}; - -// std::string -template <> -struct convert { - static Node encode(const std::string& rhs) { return Node(rhs); } - - static bool decode(const Node& node, std::string& rhs) { - if (!node.IsScalar()) - return false; - rhs = node.Scalar(); - return true; - } -}; - -// C-strings can only be encoded -template <> -struct convert { - static Node encode(const char*& rhs) { return Node(rhs); } -}; - -template -struct convert { - static Node encode(const char(&rhs)[N]) { return Node(rhs); } -}; - -template <> -struct convert<_Null> { - static Node encode(const _Null& /* rhs */) { return Node(); } - - static bool decode(const Node& node, _Null& /* rhs */) { - return node.IsNull(); - } -}; - -#define YAML_DEFINE_CONVERT_STREAMABLE(type, negative_op) \ - template <> \ - struct convert { \ - static Node encode(const type& rhs) { \ - std::stringstream stream; \ - stream.precision(std::numeric_limits::digits10 + 1); \ - stream << rhs; \ - return Node(stream.str()); \ - } \ - \ - static bool decode(const Node& node, type& rhs) { \ - if (node.Type() != NodeType::Scalar) \ - return false; \ - const std::string& input = node.Scalar(); \ - std::stringstream stream(input); \ - stream.unsetf(std::ios::dec); \ - if ((stream >> std::noskipws >> rhs) && (stream >> std::ws).eof()) \ - return true; \ - if (std::numeric_limits::has_infinity) { \ - if (conversion::IsInfinity(input)) { \ - rhs = std::numeric_limits::infinity(); \ - return true; \ - } else if (conversion::IsNegativeInfinity(input)) { \ - rhs = negative_op std::numeric_limits::infinity(); \ - return true; \ - } \ - } \ - \ - if (std::numeric_limits::has_quiet_NaN && \ - conversion::IsNaN(input)) { \ - rhs = std::numeric_limits::quiet_NaN(); \ - return true; \ - } \ - \ - return false; \ - } \ - } - -#define YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(type) \ - YAML_DEFINE_CONVERT_STREAMABLE(type, -) - -#define YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(type) \ - YAML_DEFINE_CONVERT_STREAMABLE(type, +) - -YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(int); -YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(short); -YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long); -YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long long); -YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned); -YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned short); -YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned long); -YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned long long); - -YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(char); -YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(signed char); -YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned char); - -YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(float); -YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(double); -YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long double); - -#undef YAML_DEFINE_CONVERT_STREAMABLE_SIGNED -#undef YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED -#undef YAML_DEFINE_CONVERT_STREAMABLE - -// bool -template <> -struct convert { - static Node encode(bool rhs) { return rhs ? Node("true") : Node("false"); } - - YAML_CPP_API static bool decode(const Node& node, bool& rhs); -}; - -// std::map -template -struct convert> { - static Node encode(const std::map& rhs) { - Node node(NodeType::Map); - for (typename std::map::const_iterator it = rhs.begin(); - it != rhs.end(); ++it) - node.force_insert(it->first, it->second); - return node; - } - - static bool decode(const Node& node, std::map& rhs) { - if (!node.IsMap()) - return false; - - rhs.clear(); - for (const_iterator it = node.begin(); it != node.end(); ++it) -#if defined(__GNUC__) && __GNUC__ < 4 - // workaround for GCC 3: - rhs[it->first.template as()] = it->second.template as(); -#else - rhs[it->first.as()] = it->second.as(); -#endif - return true; - } -}; - -// std::vector -template -struct convert> { - static Node encode(const std::vector& rhs) { - Node node(NodeType::Sequence); - for (typename std::vector::const_iterator it = rhs.begin(); - it != rhs.end(); ++it) - node.push_back(*it); - return node; - } - - static bool decode(const Node& node, std::vector& rhs) { - if (!node.IsSequence()) - return false; - - rhs.clear(); - for (const_iterator it = node.begin(); it != node.end(); ++it) -#if defined(__GNUC__) && __GNUC__ < 4 - // workaround for GCC 3: - rhs.push_back(it->template as()); -#else - rhs.push_back(it->as()); -#endif - return true; - } -}; - -// std::list -template -struct convert> { - static Node encode(const std::list& rhs) { - Node node(NodeType::Sequence); - for (typename std::list::const_iterator it = rhs.begin(); - it != rhs.end(); ++it) - node.push_back(*it); - return node; - } - - static bool decode(const Node& node, std::list& rhs) { - if (!node.IsSequence()) - return false; - - rhs.clear(); - for (const_iterator it = node.begin(); it != node.end(); ++it) -#if defined(__GNUC__) && __GNUC__ < 4 - // workaround for GCC 3: - rhs.push_back(it->template as()); -#else - rhs.push_back(it->as()); -#endif - return true; - } -}; - -// std::array -template -struct convert> { - static Node encode(const std::array& rhs) { - Node node(NodeType::Sequence); - for (const auto& element : rhs) { - node.push_back(element); - } - return node; - } - - static bool decode(const Node& node, std::array& rhs) { - if (!isNodeValid(node)) { - return false; - } - - for (auto i = 0u; i < node.size(); ++i) { -#if defined(__GNUC__) && __GNUC__ < 4 - // workaround for GCC 3: - rhs[i] = node[i].template as(); -#else - rhs[i] = node[i].as(); -#endif - } - return true; - } - - private: - static bool isNodeValid(const Node& node) { - return node.IsSequence() && node.size() == N; - } -}; - -// std::pair -template -struct convert> { - static Node encode(const std::pair& rhs) { - Node node(NodeType::Sequence); - node.push_back(rhs.first); - node.push_back(rhs.second); - return node; - } - - static bool decode(const Node& node, std::pair& rhs) { - if (!node.IsSequence()) - return false; - if (node.size() != 2) - return false; - -#if defined(__GNUC__) && __GNUC__ < 4 - // workaround for GCC 3: - rhs.first = node[0].template as(); -#else - rhs.first = node[0].as(); -#endif -#if defined(__GNUC__) && __GNUC__ < 4 - // workaround for GCC 3: - rhs.second = node[1].template as(); -#else - rhs.second = node[1].as(); -#endif - return true; - } -}; - -// binary -template <> -struct convert { - static Node encode(const Binary& rhs) { - return Node(EncodeBase64(rhs.data(), rhs.size())); - } - - static bool decode(const Node& node, Binary& rhs) { - if (!node.IsScalar()) - return false; - - std::vector data = DecodeBase64(node.Scalar()); - if (data.empty() && !node.Scalar().empty()) - return false; - - rhs.swap(data); - return true; - } -}; -} - -#endif // NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/bool_type.h b/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/bool_type.h deleted file mode 100644 index 2c80705c9ae749..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/bool_type.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -namespace YAML { -namespace detail { -struct unspecified_bool { - struct NOT_ALLOWED; - static void true_value(NOT_ALLOWED*) {} -}; -typedef void (*unspecified_bool_type)(unspecified_bool::NOT_ALLOWED*); -} -} - -#define YAML_CPP_OPERATOR_BOOL() \ - operator YAML::detail::unspecified_bool_type() const { \ - return this->operator!() ? 0 \ - : &YAML::detail::unspecified_bool::true_value; \ - } - -#endif // NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/impl.h b/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/impl.h deleted file mode 100644 index 59318264ad6599..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/impl.h +++ /dev/null @@ -1,185 +0,0 @@ -#ifndef NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/node/detail/node.h" -#include "yaml-cpp/node/detail/node_data.h" -#include - -namespace YAML { -namespace detail { -template -struct get_idx { - static node* get(const std::vector& /* sequence */, - const Key& /* key */, shared_memory_holder /* pMemory */) { - return 0; - } -}; - -template -struct get_idx::value && - !std::is_same::value>::type> { - static node* get(const std::vector& sequence, const Key& key, - shared_memory_holder /* pMemory */) { - return key < sequence.size() ? sequence[key] : 0; - } - - static node* get(std::vector& sequence, const Key& key, - shared_memory_holder pMemory) { - if (key > sequence.size() || (key > 0 && !sequence[key-1]->is_defined())) - return 0; - if (key == sequence.size()) - sequence.push_back(&pMemory->create_node()); - return sequence[key]; - } -}; - -template -struct get_idx::value>::type> { - static node* get(const std::vector& sequence, const Key& key, - shared_memory_holder pMemory) { - return key >= 0 ? get_idx::get( - sequence, static_cast(key), pMemory) - : 0; - } - static node* get(std::vector& sequence, const Key& key, - shared_memory_holder pMemory) { - return key >= 0 ? get_idx::get( - sequence, static_cast(key), pMemory) - : 0; - } -}; - -template -inline bool node::equals(const T& rhs, shared_memory_holder pMemory) { - T lhs; - if (convert::decode(Node(*this, pMemory), lhs)) { - return lhs == rhs; - } - return false; -} - -inline bool node::equals(const char* rhs, shared_memory_holder pMemory) { - return equals(rhs, pMemory); -} - -// indexing -template -inline node* node_data::get(const Key& key, - shared_memory_holder pMemory) const { - switch (m_type) { - case NodeType::Map: - break; - case NodeType::Undefined: - case NodeType::Null: - return NULL; - case NodeType::Sequence: - if (node* pNode = get_idx::get(m_sequence, key, pMemory)) - return pNode; - return NULL; - case NodeType::Scalar: - throw BadSubscript(); - } - - for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) { - if (it->first->equals(key, pMemory)) { - return it->second; - } - } - - return NULL; -} - -template -inline node& node_data::get(const Key& key, shared_memory_holder pMemory) { - switch (m_type) { - case NodeType::Map: - break; - case NodeType::Undefined: - case NodeType::Null: - case NodeType::Sequence: - if (node* pNode = get_idx::get(m_sequence, key, pMemory)) { - m_type = NodeType::Sequence; - return *pNode; - } - - convert_to_map(pMemory); - break; - case NodeType::Scalar: - throw BadSubscript(); - } - - for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) { - if (it->first->equals(key, pMemory)) { - return *it->second; - } - } - - node& k = convert_to_node(key, pMemory); - node& v = pMemory->create_node(); - insert_map_pair(k, v); - return v; -} - -template -inline bool node_data::remove(const Key& key, shared_memory_holder pMemory) { - if (m_type != NodeType::Map) - return false; - - kv_pairs::iterator it = m_undefinedPairs.begin(); - while (it != m_undefinedPairs.end()) { - kv_pairs::iterator jt = std::next(it); - if (it->first->equals(key, pMemory)) - m_undefinedPairs.erase(it); - it = jt; - } - - for (node_map::iterator it = m_map.begin(); it != m_map.end(); ++it) { - if (it->first->equals(key, pMemory)) { - m_map.erase(it); - return true; - } - } - - return false; -} - -// map -template -inline void node_data::force_insert(const Key& key, const Value& value, - shared_memory_holder pMemory) { - switch (m_type) { - case NodeType::Map: - break; - case NodeType::Undefined: - case NodeType::Null: - case NodeType::Sequence: - convert_to_map(pMemory); - break; - case NodeType::Scalar: - throw BadInsert(); - } - - node& k = convert_to_node(key, pMemory); - node& v = convert_to_node(value, pMemory); - insert_map_pair(k, v); -} - -template -inline node& node_data::convert_to_node(const T& rhs, - shared_memory_holder pMemory) { - Node value = convert::encode(rhs); - value.EnsureNodeExists(); - pMemory->merge(*value.m_pMemory); - return *value.m_pNode; -} -} -} - -#endif // NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/iterator.h b/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/iterator.h deleted file mode 100644 index 65f81524988748..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/iterator.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/dll.h" -#include "yaml-cpp/node/ptr.h" -#include "yaml-cpp/node/detail/node_iterator.h" -#include -#include - -namespace YAML { -namespace detail { -struct iterator_value; - -template -class iterator_base : public std::iterator { - - private: - template - friend class iterator_base; - struct enabler {}; - typedef node_iterator base_type; - - struct proxy { - explicit proxy(const V& x) : m_ref(x) {} - V* operator->() { return std::addressof(m_ref); } - operator V*() { return std::addressof(m_ref); } - - V m_ref; - }; - - public: - typedef typename iterator_base::value_type value_type; - - public: - iterator_base() : m_iterator(), m_pMemory() {} - explicit iterator_base(base_type rhs, shared_memory_holder pMemory) - : m_iterator(rhs), m_pMemory(pMemory) {} - - template - iterator_base(const iterator_base& rhs, - typename std::enable_if::value, - enabler>::type = enabler()) - : m_iterator(rhs.m_iterator), m_pMemory(rhs.m_pMemory) {} - - iterator_base& operator++() { - ++m_iterator; - return *this; - } - - iterator_base operator++(int) { - iterator_base iterator_pre(*this); - ++(*this); - return iterator_pre; - } - - template - bool operator==(const iterator_base& rhs) const { - return m_iterator == rhs.m_iterator; - } - - template - bool operator!=(const iterator_base& rhs) const { - return m_iterator != rhs.m_iterator; - } - - value_type operator*() const { - const typename base_type::value_type& v = *m_iterator; - if (v.pNode) - return value_type(Node(*v, m_pMemory)); - if (v.first && v.second) - return value_type(Node(*v.first, m_pMemory), Node(*v.second, m_pMemory)); - return value_type(); - } - - proxy operator->() const { return proxy(**this); } - - private: - base_type m_iterator; - shared_memory_holder m_pMemory; -}; -} -} - -#endif // VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/iterator_fwd.h b/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/iterator_fwd.h deleted file mode 100644 index 5f1ffe7436d735..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/iterator_fwd.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/dll.h" -#include -#include -#include - -namespace YAML { - -namespace detail { -struct iterator_value; -template -class iterator_base; -} - -typedef detail::iterator_base iterator; -typedef detail::iterator_base const_iterator; -} - -#endif // VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/memory.h b/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/memory.h deleted file mode 100644 index 8f2bc2657a2286..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/memory.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include - -#include "yaml-cpp/dll.h" -#include "yaml-cpp/node/ptr.h" - -namespace YAML { -namespace detail { -class node; -} // namespace detail -} // namespace YAML - -namespace YAML { -namespace detail { -class YAML_CPP_API memory { - public: - node& create_node(); - void merge(const memory& rhs); - - private: - typedef std::set Nodes; - Nodes m_nodes; -}; - -class YAML_CPP_API memory_holder { - public: - memory_holder() : m_pMemory(new memory) {} - - node& create_node() { return m_pMemory->create_node(); } - void merge(memory_holder& rhs); - - private: - shared_memory m_pMemory; -}; -} -} - -#endif // VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/node.h b/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/node.h deleted file mode 100644 index 3154a527c327d7..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/node.h +++ /dev/null @@ -1,169 +0,0 @@ -#ifndef NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/emitterstyle.h" -#include "yaml-cpp/dll.h" -#include "yaml-cpp/node/type.h" -#include "yaml-cpp/node/ptr.h" -#include "yaml-cpp/node/detail/node_ref.h" -#include - -namespace YAML { -namespace detail { -class node { - public: - node() : m_pRef(new node_ref) {} - node(const node&) = delete; - node& operator=(const node&) = delete; - - bool is(const node& rhs) const { return m_pRef == rhs.m_pRef; } - const node_ref* ref() const { return m_pRef.get(); } - - bool is_defined() const { return m_pRef->is_defined(); } - const Mark& mark() const { return m_pRef->mark(); } - NodeType::value type() const { return m_pRef->type(); } - - const std::string& scalar() const { return m_pRef->scalar(); } - const std::string& tag() const { return m_pRef->tag(); } - EmitterStyle::value style() const { return m_pRef->style(); } - - template - bool equals(const T& rhs, shared_memory_holder pMemory); - bool equals(const char* rhs, shared_memory_holder pMemory); - - void mark_defined() { - if (is_defined()) - return; - - m_pRef->mark_defined(); - for (nodes::iterator it = m_dependencies.begin(); - it != m_dependencies.end(); ++it) - (*it)->mark_defined(); - m_dependencies.clear(); - } - - void add_dependency(node& rhs) { - if (is_defined()) - rhs.mark_defined(); - else - m_dependencies.insert(&rhs); - } - - void set_ref(const node& rhs) { - if (rhs.is_defined()) - mark_defined(); - m_pRef = rhs.m_pRef; - } - void set_data(const node& rhs) { - if (rhs.is_defined()) - mark_defined(); - m_pRef->set_data(*rhs.m_pRef); - } - - void set_mark(const Mark& mark) { m_pRef->set_mark(mark); } - - void set_type(NodeType::value type) { - if (type != NodeType::Undefined) - mark_defined(); - m_pRef->set_type(type); - } - void set_null() { - mark_defined(); - m_pRef->set_null(); - } - void set_scalar(const std::string& scalar) { - mark_defined(); - m_pRef->set_scalar(scalar); - } - void set_tag(const std::string& tag) { - mark_defined(); - m_pRef->set_tag(tag); - } - - // style - void set_style(EmitterStyle::value style) { - mark_defined(); - m_pRef->set_style(style); - } - - // size/iterator - std::size_t size() const { return m_pRef->size(); } - - const_node_iterator begin() const { - return static_cast(*m_pRef).begin(); - } - node_iterator begin() { return m_pRef->begin(); } - - const_node_iterator end() const { - return static_cast(*m_pRef).end(); - } - node_iterator end() { return m_pRef->end(); } - - // sequence - void push_back(node& node, shared_memory_holder pMemory) { - m_pRef->push_back(node, pMemory); - node.add_dependency(*this); - } - void insert(node& key, node& value, shared_memory_holder pMemory) { - m_pRef->insert(key, value, pMemory); - key.add_dependency(*this); - value.add_dependency(*this); - } - - // indexing - template - node* get(const Key& key, shared_memory_holder pMemory) const { - // NOTE: this returns a non-const node so that the top-level Node can wrap - // it, and returns a pointer so that it can be NULL (if there is no such - // key). - return static_cast(*m_pRef).get(key, pMemory); - } - template - node& get(const Key& key, shared_memory_holder pMemory) { - node& value = m_pRef->get(key, pMemory); - value.add_dependency(*this); - return value; - } - template - bool remove(const Key& key, shared_memory_holder pMemory) { - return m_pRef->remove(key, pMemory); - } - - node* get(node& key, shared_memory_holder pMemory) const { - // NOTE: this returns a non-const node so that the top-level Node can wrap - // it, and returns a pointer so that it can be NULL (if there is no such - // key). - return static_cast(*m_pRef).get(key, pMemory); - } - node& get(node& key, shared_memory_holder pMemory) { - node& value = m_pRef->get(key, pMemory); - key.add_dependency(*this); - value.add_dependency(*this); - return value; - } - bool remove(node& key, shared_memory_holder pMemory) { - return m_pRef->remove(key, pMemory); - } - - // map - template - void force_insert(const Key& key, const Value& value, - shared_memory_holder pMemory) { - m_pRef->force_insert(key, value, pMemory); - } - - private: - shared_node_ref m_pRef; - typedef std::set nodes; - nodes m_dependencies; -}; -} -} - -#endif // NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/node_data.h b/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/node_data.h deleted file mode 100644 index 50bcd74352da9b..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/node_data.h +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include -#include -#include -#include -#include - -#include "yaml-cpp/dll.h" -#include "yaml-cpp/node/detail/node_iterator.h" -#include "yaml-cpp/node/iterator.h" -#include "yaml-cpp/node/ptr.h" -#include "yaml-cpp/node/type.h" - -namespace YAML { -namespace detail { -class node; -} // namespace detail -} // namespace YAML - -namespace YAML { -namespace detail { -class YAML_CPP_API node_data { - public: - node_data(); - node_data(const node_data&) = delete; - node_data& operator=(const node_data&) = delete; - - void mark_defined(); - void set_mark(const Mark& mark); - void set_type(NodeType::value type); - void set_tag(const std::string& tag); - void set_null(); - void set_scalar(const std::string& scalar); - void set_style(EmitterStyle::value style); - - bool is_defined() const { return m_isDefined; } - const Mark& mark() const { return m_mark; } - NodeType::value type() const { - return m_isDefined ? m_type : NodeType::Undefined; - } - const std::string& scalar() const { return m_scalar; } - const std::string& tag() const { return m_tag; } - EmitterStyle::value style() const { return m_style; } - - // size/iterator - std::size_t size() const; - - const_node_iterator begin() const; - node_iterator begin(); - - const_node_iterator end() const; - node_iterator end(); - - // sequence - void push_back(node& node, shared_memory_holder pMemory); - void insert(node& key, node& value, shared_memory_holder pMemory); - - // indexing - template - node* get(const Key& key, shared_memory_holder pMemory) const; - template - node& get(const Key& key, shared_memory_holder pMemory); - template - bool remove(const Key& key, shared_memory_holder pMemory); - - node* get(node& key, shared_memory_holder pMemory) const; - node& get(node& key, shared_memory_holder pMemory); - bool remove(node& key, shared_memory_holder pMemory); - - // map - template - void force_insert(const Key& key, const Value& value, - shared_memory_holder pMemory); - - public: - static std::string empty_scalar; - - private: - void compute_seq_size() const; - void compute_map_size() const; - - void reset_sequence(); - void reset_map(); - - void insert_map_pair(node& key, node& value); - void convert_to_map(shared_memory_holder pMemory); - void convert_sequence_to_map(shared_memory_holder pMemory); - - template - static node& convert_to_node(const T& rhs, shared_memory_holder pMemory); - - private: - bool m_isDefined; - Mark m_mark; - NodeType::value m_type; - std::string m_tag; - EmitterStyle::value m_style; - - // scalar - std::string m_scalar; - - // sequence - typedef std::vector node_seq; - node_seq m_sequence; - - mutable std::size_t m_seqSize; - - // map - typedef std::vector> node_map; - node_map m_map; - - typedef std::pair kv_pair; - typedef std::list kv_pairs; - mutable kv_pairs m_undefinedPairs; -}; -} -} - -#endif // VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/node_iterator.h b/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/node_iterator.h deleted file mode 100644 index 4337df4167375c..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/node_iterator.h +++ /dev/null @@ -1,180 +0,0 @@ -#ifndef VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/dll.h" -#include "yaml-cpp/node/ptr.h" -#include -#include -#include -#include -#include -#include - -namespace YAML { -namespace detail { -struct iterator_type { - enum value { None, Sequence, Map }; -}; - -template -struct node_iterator_value : public std::pair { - typedef std::pair kv; - - node_iterator_value() : kv(), pNode(0) {} - explicit node_iterator_value(V& rhs) : kv(), pNode(&rhs) {} - explicit node_iterator_value(V& key, V& value) : kv(&key, &value), pNode(0) {} - - V& operator*() const { return *pNode; } - V& operator->() const { return *pNode; } - - V* pNode; -}; - -typedef std::vector node_seq; -typedef std::vector> node_map; - -template -struct node_iterator_type { - typedef node_seq::iterator seq; - typedef node_map::iterator map; -}; - -template -struct node_iterator_type { - typedef node_seq::const_iterator seq; - typedef node_map::const_iterator map; -}; - -template -class node_iterator_base - : public std::iterator, - std::ptrdiff_t, node_iterator_value*, - node_iterator_value> { - private: - struct enabler {}; - - struct proxy { - explicit proxy(const node_iterator_value& x) : m_ref(x) {} - node_iterator_value* operator->() { return std::addressof(m_ref); } - operator node_iterator_value*() { return std::addressof(m_ref); } - - node_iterator_value m_ref; - }; - - public: - typedef typename node_iterator_type::seq SeqIter; - typedef typename node_iterator_type::map MapIter; - typedef node_iterator_value value_type; - - node_iterator_base() - : m_type(iterator_type::None), m_seqIt(), m_mapIt(), m_mapEnd() {} - explicit node_iterator_base(SeqIter seqIt) - : m_type(iterator_type::Sequence), - m_seqIt(seqIt), - m_mapIt(), - m_mapEnd() {} - explicit node_iterator_base(MapIter mapIt, MapIter mapEnd) - : m_type(iterator_type::Map), - m_seqIt(), - m_mapIt(mapIt), - m_mapEnd(mapEnd) { - m_mapIt = increment_until_defined(m_mapIt); - } - - template - node_iterator_base(const node_iterator_base& rhs, - typename std::enable_if::value, - enabler>::type = enabler()) - : m_type(rhs.m_type), - m_seqIt(rhs.m_seqIt), - m_mapIt(rhs.m_mapIt), - m_mapEnd(rhs.m_mapEnd) {} - - template - friend class node_iterator_base; - - template - bool operator==(const node_iterator_base& rhs) const { - if (m_type != rhs.m_type) - return false; - - switch (m_type) { - case iterator_type::None: - return true; - case iterator_type::Sequence: - return m_seqIt == rhs.m_seqIt; - case iterator_type::Map: - return m_mapIt == rhs.m_mapIt; - } - return true; - } - - template - bool operator!=(const node_iterator_base& rhs) const { - return !(*this == rhs); - } - - node_iterator_base& operator++() { - switch (m_type) { - case iterator_type::None: - break; - case iterator_type::Sequence: - ++m_seqIt; - break; - case iterator_type::Map: - ++m_mapIt; - m_mapIt = increment_until_defined(m_mapIt); - break; - } - return *this; - } - - node_iterator_base operator++(int) { - node_iterator_base iterator_pre(*this); - ++(*this); - return iterator_pre; - } - - value_type operator*() const { - switch (m_type) { - case iterator_type::None: - return value_type(); - case iterator_type::Sequence: - return value_type(**m_seqIt); - case iterator_type::Map: - return value_type(*m_mapIt->first, *m_mapIt->second); - } - return value_type(); - } - - proxy operator->() const { return proxy(**this); } - - MapIter increment_until_defined(MapIter it) { - while (it != m_mapEnd && !is_defined(it)) - ++it; - return it; - } - - bool is_defined(MapIter it) const { - return it->first->is_defined() && it->second->is_defined(); - } - - private: - typename iterator_type::value m_type; - - SeqIter m_seqIt; - MapIter m_mapIt, m_mapEnd; -}; - -typedef node_iterator_base node_iterator; -typedef node_iterator_base const_node_iterator; -} -} - -#endif // VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/node_ref.h b/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/node_ref.h deleted file mode 100644 index d8a94f8b8045cf..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/node/detail/node_ref.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/dll.h" -#include "yaml-cpp/node/type.h" -#include "yaml-cpp/node/ptr.h" -#include "yaml-cpp/node/detail/node_data.h" - -namespace YAML { -namespace detail { -class node_ref { - public: - node_ref() : m_pData(new node_data) {} - node_ref(const node_ref&) = delete; - node_ref& operator=(const node_ref&) = delete; - - bool is_defined() const { return m_pData->is_defined(); } - const Mark& mark() const { return m_pData->mark(); } - NodeType::value type() const { return m_pData->type(); } - const std::string& scalar() const { return m_pData->scalar(); } - const std::string& tag() const { return m_pData->tag(); } - EmitterStyle::value style() const { return m_pData->style(); } - - void mark_defined() { m_pData->mark_defined(); } - void set_data(const node_ref& rhs) { m_pData = rhs.m_pData; } - - void set_mark(const Mark& mark) { m_pData->set_mark(mark); } - void set_type(NodeType::value type) { m_pData->set_type(type); } - void set_tag(const std::string& tag) { m_pData->set_tag(tag); } - void set_null() { m_pData->set_null(); } - void set_scalar(const std::string& scalar) { m_pData->set_scalar(scalar); } - void set_style(EmitterStyle::value style) { m_pData->set_style(style); } - - // size/iterator - std::size_t size() const { return m_pData->size(); } - - const_node_iterator begin() const { - return static_cast(*m_pData).begin(); - } - node_iterator begin() { return m_pData->begin(); } - - const_node_iterator end() const { - return static_cast(*m_pData).end(); - } - node_iterator end() { return m_pData->end(); } - - // sequence - void push_back(node& node, shared_memory_holder pMemory) { - m_pData->push_back(node, pMemory); - } - void insert(node& key, node& value, shared_memory_holder pMemory) { - m_pData->insert(key, value, pMemory); - } - - // indexing - template - node* get(const Key& key, shared_memory_holder pMemory) const { - return static_cast(*m_pData).get(key, pMemory); - } - template - node& get(const Key& key, shared_memory_holder pMemory) { - return m_pData->get(key, pMemory); - } - template - bool remove(const Key& key, shared_memory_holder pMemory) { - return m_pData->remove(key, pMemory); - } - - node* get(node& key, shared_memory_holder pMemory) const { - return static_cast(*m_pData).get(key, pMemory); - } - node& get(node& key, shared_memory_holder pMemory) { - return m_pData->get(key, pMemory); - } - bool remove(node& key, shared_memory_holder pMemory) { - return m_pData->remove(key, pMemory); - } - - // map - template - void force_insert(const Key& key, const Value& value, - shared_memory_holder pMemory) { - m_pData->force_insert(key, value, pMemory); - } - - private: - shared_node_data m_pData; -}; -} -} - -#endif // VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/node/emit.h b/phonelibs/yaml-cpp/include/yaml-cpp/node/emit.h deleted file mode 100644 index 032268c5d04af8..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/node/emit.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include -#include - -#include "yaml-cpp/dll.h" - -namespace YAML { -class Emitter; -class Node; - -/** - * Emits the node to the given {@link Emitter}. If there is an error in writing, - * {@link Emitter#good} will return false. - */ -YAML_CPP_API Emitter& operator<<(Emitter& out, const Node& node); - -/** Emits the node to the given output stream. */ -YAML_CPP_API std::ostream& operator<<(std::ostream& out, const Node& node); - -/** Converts the node to a YAML string. */ -YAML_CPP_API std::string Dump(const Node& node); -} // namespace YAML - -#endif // NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/node/impl.h b/phonelibs/yaml-cpp/include/yaml-cpp/node/impl.h deleted file mode 100644 index 20c487a687f62f..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/node/impl.h +++ /dev/null @@ -1,448 +0,0 @@ -#ifndef NODE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/node/node.h" -#include "yaml-cpp/node/iterator.h" -#include "yaml-cpp/node/detail/memory.h" -#include "yaml-cpp/node/detail/node.h" -#include "yaml-cpp/exceptions.h" -#include - -namespace YAML { -inline Node::Node() : m_isValid(true), m_pNode(NULL) {} - -inline Node::Node(NodeType::value type) - : m_isValid(true), - m_pMemory(new detail::memory_holder), - m_pNode(&m_pMemory->create_node()) { - m_pNode->set_type(type); -} - -template -inline Node::Node(const T& rhs) - : m_isValid(true), - m_pMemory(new detail::memory_holder), - m_pNode(&m_pMemory->create_node()) { - Assign(rhs); -} - -inline Node::Node(const detail::iterator_value& rhs) - : m_isValid(rhs.m_isValid), - m_pMemory(rhs.m_pMemory), - m_pNode(rhs.m_pNode) {} - -inline Node::Node(const Node& rhs) - : m_isValid(rhs.m_isValid), - m_pMemory(rhs.m_pMemory), - m_pNode(rhs.m_pNode) {} - -inline Node::Node(Zombie) : m_isValid(false), m_pNode(NULL) {} - -inline Node::Node(detail::node& node, detail::shared_memory_holder pMemory) - : m_isValid(true), m_pMemory(pMemory), m_pNode(&node) {} - -inline Node::~Node() {} - -inline void Node::EnsureNodeExists() const { - if (!m_isValid) - throw InvalidNode(); - if (!m_pNode) { - m_pMemory.reset(new detail::memory_holder); - m_pNode = &m_pMemory->create_node(); - m_pNode->set_null(); - } -} - -inline bool Node::IsDefined() const { - if (!m_isValid) { - return false; - } - return m_pNode ? m_pNode->is_defined() : true; -} - -inline Mark Node::Mark() const { - if (!m_isValid) { - throw InvalidNode(); - } - return m_pNode ? m_pNode->mark() : Mark::null_mark(); -} - -inline NodeType::value Node::Type() const { - if (!m_isValid) - throw InvalidNode(); - return m_pNode ? m_pNode->type() : NodeType::Null; -} - -// access - -// template helpers -template -struct as_if { - explicit as_if(const Node& node_) : node(node_) {} - const Node& node; - - T operator()(const S& fallback) const { - if (!node.m_pNode) - return fallback; - - T t; - if (convert::decode(node, t)) - return t; - return fallback; - } -}; - -template -struct as_if { - explicit as_if(const Node& node_) : node(node_) {} - const Node& node; - - std::string operator()(const S& fallback) const { - if (node.Type() != NodeType::Scalar) - return fallback; - return node.Scalar(); - } -}; - -template -struct as_if { - explicit as_if(const Node& node_) : node(node_) {} - const Node& node; - - T operator()() const { - if (!node.m_pNode) - throw TypedBadConversion(node.Mark()); - - T t; - if (convert::decode(node, t)) - return t; - throw TypedBadConversion(node.Mark()); - } -}; - -template <> -struct as_if { - explicit as_if(const Node& node_) : node(node_) {} - const Node& node; - - std::string operator()() const { - if (node.Type() != NodeType::Scalar) - throw TypedBadConversion(node.Mark()); - return node.Scalar(); - } -}; - -// access functions -template -inline T Node::as() const { - if (!m_isValid) - throw InvalidNode(); - return as_if(*this)(); -} - -template -inline T Node::as(const S& fallback) const { - if (!m_isValid) - return fallback; - return as_if(*this)(fallback); -} - -inline const std::string& Node::Scalar() const { - if (!m_isValid) - throw InvalidNode(); - return m_pNode ? m_pNode->scalar() : detail::node_data::empty_scalar; -} - -inline const std::string& Node::Tag() const { - if (!m_isValid) - throw InvalidNode(); - return m_pNode ? m_pNode->tag() : detail::node_data::empty_scalar; -} - -inline void Node::SetTag(const std::string& tag) { - if (!m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - m_pNode->set_tag(tag); -} - -inline EmitterStyle::value Node::Style() const { - if (!m_isValid) - throw InvalidNode(); - return m_pNode ? m_pNode->style() : EmitterStyle::Default; -} - -inline void Node::SetStyle(EmitterStyle::value style) { - if (!m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - m_pNode->set_style(style); -} - -// assignment -inline bool Node::is(const Node& rhs) const { - if (!m_isValid || !rhs.m_isValid) - throw InvalidNode(); - if (!m_pNode || !rhs.m_pNode) - return false; - return m_pNode->is(*rhs.m_pNode); -} - -template -inline Node& Node::operator=(const T& rhs) { - if (!m_isValid) - throw InvalidNode(); - Assign(rhs); - return *this; -} - -inline void Node::reset(const YAML::Node& rhs) { - if (!m_isValid || !rhs.m_isValid) - throw InvalidNode(); - m_pMemory = rhs.m_pMemory; - m_pNode = rhs.m_pNode; -} - -template -inline void Node::Assign(const T& rhs) { - if (!m_isValid) - throw InvalidNode(); - AssignData(convert::encode(rhs)); -} - -template <> -inline void Node::Assign(const std::string& rhs) { - if (!m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - m_pNode->set_scalar(rhs); -} - -inline void Node::Assign(const char* rhs) { - if (!m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - m_pNode->set_scalar(rhs); -} - -inline void Node::Assign(char* rhs) { - if (!m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - m_pNode->set_scalar(rhs); -} - -inline Node& Node::operator=(const Node& rhs) { - if (!m_isValid || !rhs.m_isValid) - throw InvalidNode(); - if (is(rhs)) - return *this; - AssignNode(rhs); - return *this; -} - -inline void Node::AssignData(const Node& rhs) { - if (!m_isValid || !rhs.m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - rhs.EnsureNodeExists(); - - m_pNode->set_data(*rhs.m_pNode); - m_pMemory->merge(*rhs.m_pMemory); -} - -inline void Node::AssignNode(const Node& rhs) { - if (!m_isValid || !rhs.m_isValid) - throw InvalidNode(); - rhs.EnsureNodeExists(); - - if (!m_pNode) { - m_pNode = rhs.m_pNode; - m_pMemory = rhs.m_pMemory; - return; - } - - m_pNode->set_ref(*rhs.m_pNode); - m_pMemory->merge(*rhs.m_pMemory); - m_pNode = rhs.m_pNode; -} - -// size/iterator -inline std::size_t Node::size() const { - if (!m_isValid) - throw InvalidNode(); - return m_pNode ? m_pNode->size() : 0; -} - -inline const_iterator Node::begin() const { - if (!m_isValid) - return const_iterator(); - return m_pNode ? const_iterator(m_pNode->begin(), m_pMemory) - : const_iterator(); -} - -inline iterator Node::begin() { - if (!m_isValid) - return iterator(); - return m_pNode ? iterator(m_pNode->begin(), m_pMemory) : iterator(); -} - -inline const_iterator Node::end() const { - if (!m_isValid) - return const_iterator(); - return m_pNode ? const_iterator(m_pNode->end(), m_pMemory) : const_iterator(); -} - -inline iterator Node::end() { - if (!m_isValid) - return iterator(); - return m_pNode ? iterator(m_pNode->end(), m_pMemory) : iterator(); -} - -// sequence -template -inline void Node::push_back(const T& rhs) { - if (!m_isValid) - throw InvalidNode(); - push_back(Node(rhs)); -} - -inline void Node::push_back(const Node& rhs) { - if (!m_isValid || !rhs.m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - rhs.EnsureNodeExists(); - - m_pNode->push_back(*rhs.m_pNode, m_pMemory); - m_pMemory->merge(*rhs.m_pMemory); -} - -// helpers for indexing -namespace detail { -template -struct to_value_t { - explicit to_value_t(const T& t_) : t(t_) {} - const T& t; - typedef const T& return_type; - - const T& operator()() const { return t; } -}; - -template <> -struct to_value_t { - explicit to_value_t(const char* t_) : t(t_) {} - const char* t; - typedef std::string return_type; - - const std::string operator()() const { return t; } -}; - -template <> -struct to_value_t { - explicit to_value_t(char* t_) : t(t_) {} - const char* t; - typedef std::string return_type; - - const std::string operator()() const { return t; } -}; - -template -struct to_value_t { - explicit to_value_t(const char* t_) : t(t_) {} - const char* t; - typedef std::string return_type; - - const std::string operator()() const { return t; } -}; - -// converts C-strings to std::strings so they can be copied -template -inline typename to_value_t::return_type to_value(const T& t) { - return to_value_t(t)(); -} -} - -// indexing -template -inline const Node Node::operator[](const Key& key) const { - if (!m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - detail::node* value = static_cast(*m_pNode) - .get(detail::to_value(key), m_pMemory); - if (!value) { - return Node(ZombieNode); - } - return Node(*value, m_pMemory); -} - -template -inline Node Node::operator[](const Key& key) { - if (!m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - detail::node& value = m_pNode->get(detail::to_value(key), m_pMemory); - return Node(value, m_pMemory); -} - -template -inline bool Node::remove(const Key& key) { - if (!m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - return m_pNode->remove(detail::to_value(key), m_pMemory); -} - -inline const Node Node::operator[](const Node& key) const { - if (!m_isValid || !key.m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - key.EnsureNodeExists(); - m_pMemory->merge(*key.m_pMemory); - detail::node* value = - static_cast(*m_pNode).get(*key.m_pNode, m_pMemory); - if (!value) { - return Node(ZombieNode); - } - return Node(*value, m_pMemory); -} - -inline Node Node::operator[](const Node& key) { - if (!m_isValid || !key.m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - key.EnsureNodeExists(); - m_pMemory->merge(*key.m_pMemory); - detail::node& value = m_pNode->get(*key.m_pNode, m_pMemory); - return Node(value, m_pMemory); -} - -inline bool Node::remove(const Node& key) { - if (!m_isValid || !key.m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - key.EnsureNodeExists(); - return m_pNode->remove(*key.m_pNode, m_pMemory); -} - -// map -template -inline void Node::force_insert(const Key& key, const Value& value) { - if (!m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - m_pNode->force_insert(detail::to_value(key), detail::to_value(value), - m_pMemory); -} - -// free functions -inline bool operator==(const Node& lhs, const Node& rhs) { return lhs.is(rhs); } -} - -#endif // NODE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/node/iterator.h b/phonelibs/yaml-cpp/include/yaml-cpp/node/iterator.h deleted file mode 100644 index 366a9c807fe899..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/node/iterator.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/dll.h" -#include "yaml-cpp/node/node.h" -#include "yaml-cpp/node/detail/iterator_fwd.h" -#include "yaml-cpp/node/detail/iterator.h" -#include -#include -#include - -namespace YAML { -namespace detail { -struct iterator_value : public Node, std::pair { - iterator_value() {} - explicit iterator_value(const Node& rhs) - : Node(rhs), - std::pair(Node(Node::ZombieNode), Node(Node::ZombieNode)) {} - explicit iterator_value(const Node& key, const Node& value) - : Node(Node::ZombieNode), std::pair(key, value) {} -}; -} -} - -#endif // VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/node/node.h b/phonelibs/yaml-cpp/include/yaml-cpp/node/node.h deleted file mode 100644 index 1ded7d27b72f8b..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/node/node.h +++ /dev/null @@ -1,145 +0,0 @@ -#ifndef NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include - -#include "yaml-cpp/dll.h" -#include "yaml-cpp/emitterstyle.h" -#include "yaml-cpp/mark.h" -#include "yaml-cpp/node/detail/bool_type.h" -#include "yaml-cpp/node/detail/iterator_fwd.h" -#include "yaml-cpp/node/ptr.h" -#include "yaml-cpp/node/type.h" - -namespace YAML { -namespace detail { -class node; -class node_data; -struct iterator_value; -} // namespace detail -} // namespace YAML - -namespace YAML { -class YAML_CPP_API Node { - public: - friend class NodeBuilder; - friend class NodeEvents; - friend struct detail::iterator_value; - friend class detail::node; - friend class detail::node_data; - template - friend class detail::iterator_base; - template - friend struct as_if; - - typedef YAML::iterator iterator; - typedef YAML::const_iterator const_iterator; - - Node(); - explicit Node(NodeType::value type); - template - explicit Node(const T& rhs); - explicit Node(const detail::iterator_value& rhs); - Node(const Node& rhs); - ~Node(); - - YAML::Mark Mark() const; - NodeType::value Type() const; - bool IsDefined() const; - bool IsNull() const { return Type() == NodeType::Null; } - bool IsScalar() const { return Type() == NodeType::Scalar; } - bool IsSequence() const { return Type() == NodeType::Sequence; } - bool IsMap() const { return Type() == NodeType::Map; } - - // bool conversions - YAML_CPP_OPERATOR_BOOL() - bool operator!() const { return !IsDefined(); } - - // access - template - T as() const; - template - T as(const S& fallback) const; - const std::string& Scalar() const; - - const std::string& Tag() const; - void SetTag(const std::string& tag); - - // style - // WARNING: This API might change in future releases. - EmitterStyle::value Style() const; - void SetStyle(EmitterStyle::value style); - - // assignment - bool is(const Node& rhs) const; - template - Node& operator=(const T& rhs); - Node& operator=(const Node& rhs); - void reset(const Node& rhs = Node()); - - // size/iterator - std::size_t size() const; - - const_iterator begin() const; - iterator begin(); - - const_iterator end() const; - iterator end(); - - // sequence - template - void push_back(const T& rhs); - void push_back(const Node& rhs); - - // indexing - template - const Node operator[](const Key& key) const; - template - Node operator[](const Key& key); - template - bool remove(const Key& key); - - const Node operator[](const Node& key) const; - Node operator[](const Node& key); - bool remove(const Node& key); - - // map - template - void force_insert(const Key& key, const Value& value); - - private: - enum Zombie { ZombieNode }; - explicit Node(Zombie); - explicit Node(detail::node& node, detail::shared_memory_holder pMemory); - - void EnsureNodeExists() const; - - template - void Assign(const T& rhs); - void Assign(const char* rhs); - void Assign(char* rhs); - - void AssignData(const Node& rhs); - void AssignNode(const Node& rhs); - - private: - bool m_isValid; - mutable detail::shared_memory_holder m_pMemory; - mutable detail::node* m_pNode; -}; - -YAML_CPP_API bool operator==(const Node& lhs, const Node& rhs); - -YAML_CPP_API Node Clone(const Node& node); - -template -struct convert; -} - -#endif // NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/node/parse.h b/phonelibs/yaml-cpp/include/yaml-cpp/node/parse.h deleted file mode 100644 index 7745fd7245bec0..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/node/parse.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include -#include -#include - -#include "yaml-cpp/dll.h" - -namespace YAML { -class Node; - -/** - * Loads the input string as a single YAML document. - * - * @throws {@link ParserException} if it is malformed. - */ -YAML_CPP_API Node Load(const std::string& input); - -/** - * Loads the input string as a single YAML document. - * - * @throws {@link ParserException} if it is malformed. - */ -YAML_CPP_API Node Load(const char* input); - -/** - * Loads the input stream as a single YAML document. - * - * @throws {@link ParserException} if it is malformed. - */ -YAML_CPP_API Node Load(std::istream& input); - -/** - * Loads the input file as a single YAML document. - * - * @throws {@link ParserException} if it is malformed. - * @throws {@link BadFile} if the file cannot be loaded. - */ -YAML_CPP_API Node LoadFile(const std::string& filename); - -/** - * Loads the input string as a list of YAML documents. - * - * @throws {@link ParserException} if it is malformed. - */ -YAML_CPP_API std::vector LoadAll(const std::string& input); - -/** - * Loads the input string as a list of YAML documents. - * - * @throws {@link ParserException} if it is malformed. - */ -YAML_CPP_API std::vector LoadAll(const char* input); - -/** - * Loads the input stream as a list of YAML documents. - * - * @throws {@link ParserException} if it is malformed. - */ -YAML_CPP_API std::vector LoadAll(std::istream& input); - -/** - * Loads the input file as a list of YAML documents. - * - * @throws {@link ParserException} if it is malformed. - * @throws {@link BadFile} if the file cannot be loaded. - */ -YAML_CPP_API std::vector LoadAllFromFile(const std::string& filename); -} // namespace YAML - -#endif // VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/node/ptr.h b/phonelibs/yaml-cpp/include/yaml-cpp/node/ptr.h deleted file mode 100644 index ce085dd5cd8ad1..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/node/ptr.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/dll.h" -#include - -namespace YAML { -namespace detail { -class node; -class node_ref; -class node_data; -class memory; -class memory_holder; - -typedef std::shared_ptr shared_node; -typedef std::shared_ptr shared_node_ref; -typedef std::shared_ptr shared_node_data; -typedef std::shared_ptr shared_memory_holder; -typedef std::shared_ptr shared_memory; -} -} - -#endif // VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/node/type.h b/phonelibs/yaml-cpp/include/yaml-cpp/node/type.h deleted file mode 100644 index 9d55ca96621619..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/node/type.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -namespace YAML { -struct NodeType { - enum value { Undefined, Null, Scalar, Sequence, Map }; -}; -} - -#endif // VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/noncopyable.h b/phonelibs/yaml-cpp/include/yaml-cpp/noncopyable.h deleted file mode 100644 index a261040739bc17..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/noncopyable.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/dll.h" - -namespace YAML { -// this is basically boost::noncopyable -class YAML_CPP_API noncopyable { - protected: - noncopyable() {} - ~noncopyable() {} - - private: - noncopyable(const noncopyable&); - const noncopyable& operator=(const noncopyable&); -}; -} - -#endif // NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/null.h b/phonelibs/yaml-cpp/include/yaml-cpp/null.h deleted file mode 100644 index b9521d488a6acb..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/null.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/dll.h" -#include - -namespace YAML { -class Node; - -struct YAML_CPP_API _Null {}; -inline bool operator==(const _Null&, const _Null&) { return true; } -inline bool operator!=(const _Null&, const _Null&) { return false; } - -YAML_CPP_API bool IsNull(const Node& node); // old API only -YAML_CPP_API bool IsNullString(const std::string& str); - -extern YAML_CPP_API _Null Null; -} - -#endif // NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/ostream_wrapper.h b/phonelibs/yaml-cpp/include/yaml-cpp/ostream_wrapper.h deleted file mode 100644 index 09d45f39b78b15..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/ostream_wrapper.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include -#include - -#include "yaml-cpp/dll.h" - -namespace YAML { -class YAML_CPP_API ostream_wrapper { - public: - ostream_wrapper(); - explicit ostream_wrapper(std::ostream& stream); - ~ostream_wrapper(); - - void write(const std::string& str); - void write(const char* str, std::size_t size); - - void set_comment() { m_comment = true; } - - const char* str() const { - if (m_pStream) { - return 0; - } else { - m_buffer[m_pos] = '\0'; - return &m_buffer[0]; - } - } - - std::size_t row() const { return m_row; } - std::size_t col() const { return m_col; } - std::size_t pos() const { return m_pos; } - bool comment() const { return m_comment; } - - private: - void update_pos(char ch); - - private: - mutable std::vector m_buffer; - std::ostream* const m_pStream; - - std::size_t m_pos; - std::size_t m_row, m_col; - bool m_comment; -}; - -template -inline ostream_wrapper& operator<<(ostream_wrapper& stream, - const char(&str)[N]) { - stream.write(str, N - 1); - return stream; -} - -inline ostream_wrapper& operator<<(ostream_wrapper& stream, - const std::string& str) { - stream.write(str); - return stream; -} - -inline ostream_wrapper& operator<<(ostream_wrapper& stream, char ch) { - stream.write(&ch, 1); - return stream; -} -} - -#endif // OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/parser.h b/phonelibs/yaml-cpp/include/yaml-cpp/parser.h deleted file mode 100644 index ceac22d0268929..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/parser.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include -#include - -#include "yaml-cpp/dll.h" -#include "yaml-cpp/noncopyable.h" - -namespace YAML { -class EventHandler; -class Node; -class Scanner; -struct Directives; -struct Token; - -/** - * A parser turns a stream of bytes into one stream of "events" per YAML - * document in the input stream. - */ -class YAML_CPP_API Parser : private noncopyable { - public: - /** Constructs an empty parser (with no input. */ - Parser(); - - /** - * Constructs a parser from the given input stream. The input stream must - * live as long as the parser. - */ - explicit Parser(std::istream& in); - - ~Parser(); - - /** Evaluates to true if the parser has some valid input to be read. */ - explicit operator bool() const; - - /** - * Resets the parser with the given input stream. Any existing state is - * erased. - */ - void Load(std::istream& in); - - /** - * Handles the next document by calling events on the {@code eventHandler}. - * - * @throw a ParserException on error. - * @return false if there are no more documents - */ - bool HandleNextDocument(EventHandler& eventHandler); - - void PrintTokens(std::ostream& out); - - private: - /** - * Reads any directives that are next in the queue, setting the internal - * {@code m_pDirectives} state. - */ - void ParseDirectives(); - - void HandleDirective(const Token& token); - - /** - * Handles a "YAML" directive, which should be of the form 'major.minor' (like - * a version number). - */ - void HandleYamlDirective(const Token& token); - - /** - * Handles a "TAG" directive, which should be of the form 'handle prefix', - * where 'handle' is converted to 'prefix' in the file. - */ - void HandleTagDirective(const Token& token); - - private: - std::unique_ptr m_pScanner; - std::unique_ptr m_pDirectives; -}; -} - -#endif // PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/stlemitter.h b/phonelibs/yaml-cpp/include/yaml-cpp/stlemitter.h deleted file mode 100644 index 06780c861f16c1..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/stlemitter.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include -#include -#include -#include - -namespace YAML { -template -inline Emitter& EmitSeq(Emitter& emitter, const Seq& seq) { - emitter << BeginSeq; - for (typename Seq::const_iterator it = seq.begin(); it != seq.end(); ++it) - emitter << *it; - emitter << EndSeq; - return emitter; -} - -template -inline Emitter& operator<<(Emitter& emitter, const std::vector& v) { - return EmitSeq(emitter, v); -} - -template -inline Emitter& operator<<(Emitter& emitter, const std::list& v) { - return EmitSeq(emitter, v); -} - -template -inline Emitter& operator<<(Emitter& emitter, const std::set& v) { - return EmitSeq(emitter, v); -} - -template -inline Emitter& operator<<(Emitter& emitter, const std::map& m) { - typedef typename std::map map; - emitter << BeginMap; - for (typename map::const_iterator it = m.begin(); it != m.end(); ++it) - emitter << Key << it->first << Value << it->second; - emitter << EndMap; - return emitter; -} -} - -#endif // STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/traits.h b/phonelibs/yaml-cpp/include/yaml-cpp/traits.h deleted file mode 100644 index f33d0e1f637385..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/traits.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -namespace YAML { -template -struct is_numeric { - enum { value = false }; -}; - -template <> -struct is_numeric { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; -#if defined(_MSC_VER) && (_MSC_VER < 1310) -template <> -struct is_numeric<__int64> { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; -#else -template <> -struct is_numeric { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; -#endif -template <> -struct is_numeric { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; - -template -struct enable_if_c { - typedef T type; -}; - -template -struct enable_if_c {}; - -template -struct enable_if : public enable_if_c {}; - -template -struct disable_if_c { - typedef T type; -}; - -template -struct disable_if_c {}; - -template -struct disable_if : public disable_if_c {}; -} - -#endif // TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/include/yaml-cpp/yaml.h b/phonelibs/yaml-cpp/include/yaml-cpp/yaml.h deleted file mode 100644 index 7f515efb961056..00000000000000 --- a/phonelibs/yaml-cpp/include/yaml-cpp/yaml.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/parser.h" -#include "yaml-cpp/emitter.h" -#include "yaml-cpp/emitterstyle.h" -#include "yaml-cpp/stlemitter.h" -#include "yaml-cpp/exceptions.h" - -#include "yaml-cpp/node/node.h" -#include "yaml-cpp/node/impl.h" -#include "yaml-cpp/node/convert.h" -#include "yaml-cpp/node/iterator.h" -#include "yaml-cpp/node/detail/impl.h" -#include "yaml-cpp/node/parse.h" -#include "yaml-cpp/node/emit.h" - -#endif // YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/phonelibs/yaml-cpp/lib/libyaml-cpp.a b/phonelibs/yaml-cpp/lib/libyaml-cpp.a deleted file mode 100644 index c03917510782c7..00000000000000 Binary files a/phonelibs/yaml-cpp/lib/libyaml-cpp.a and /dev/null differ diff --git a/phonelibs/zmq/x64/include/czmq.h b/phonelibs/zmq/x64/include/czmq.h deleted file mode 100644 index dbf1fe5e40a517..00000000000000 --- a/phonelibs/zmq/x64/include/czmq.h +++ /dev/null @@ -1,39 +0,0 @@ -/* ========================================================================= - CZMQ - a high-level binding in C for ZeroMQ - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= - - "Tell them I was a writer. - A maker of software. - A humanist. A father. - And many things. - But above all, a writer. - Thank You. :) - - Pieter Hintjens -*/ - -#ifndef __CZMQ_H_INCLUDED__ -#define __CZMQ_H_INCLUDED__ - -// These are signatures for handler functions that customize the -// behavior of CZMQ containers. These are shared between all CZMQ -// container types. - -// -- destroy an item -typedef void (czmq_destructor) (void **item); -// -- duplicate an item -typedef void *(czmq_duplicator) (const void *item); -// - compare two items, for sorting -typedef int (czmq_comparator) (const void *item1, const void *item2); - -// Include the project library file -#include "czmq_library.h" - -#endif diff --git a/phonelibs/zmq/x64/include/czmq_library.h b/phonelibs/zmq/x64/include/czmq_library.h deleted file mode 100644 index 89dc4eb9179dd6..00000000000000 --- a/phonelibs/zmq/x64/include/czmq_library.h +++ /dev/null @@ -1,178 +0,0 @@ -/* ========================================================================= - czmq - generated layer of public API - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -################################################################################ -# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # -# Read the zproject/README.md for information about making permanent changes. # -################################################################################ - ========================================================================= -*/ - -#ifndef CZMQ_LIBRARY_H_INCLUDED -#define CZMQ_LIBRARY_H_INCLUDED - -// Set up environment for the application -#include "czmq_prelude.h" - -// External dependencies -#include - -// CZMQ version macros for compile-time API detection -#define CZMQ_VERSION_MAJOR 4 -#define CZMQ_VERSION_MINOR 0 -#define CZMQ_VERSION_PATCH 2 - -#define CZMQ_MAKE_VERSION(major, minor, patch) \ - ((major) * 10000 + (minor) * 100 + (patch)) -#define CZMQ_VERSION \ - CZMQ_MAKE_VERSION(CZMQ_VERSION_MAJOR, CZMQ_VERSION_MINOR, CZMQ_VERSION_PATCH) - -#if defined (__WINDOWS__) -# if defined CZMQ_STATIC -# define CZMQ_EXPORT -# elif defined CZMQ_INTERNAL_BUILD -# if defined DLL_EXPORT -# define CZMQ_EXPORT __declspec(dllexport) -# else -# define CZMQ_EXPORT -# endif -# elif defined CZMQ_EXPORTS -# define CZMQ_EXPORT __declspec(dllexport) -# else -# define CZMQ_EXPORT __declspec(dllimport) -# endif -# define CZMQ_PRIVATE -#else -# define CZMQ_EXPORT -# if (defined __GNUC__ && __GNUC__ >= 4) || defined __INTEL_COMPILER -# define CZMQ_PRIVATE __attribute__ ((visibility ("hidden"))) -# else -# define CZMQ_PRIVATE -# endif -#endif - -// Opaque class structures to allow forward references -// These classes are stable or legacy and built in all releases -typedef struct _zactor_t zactor_t; -#define ZACTOR_T_DEFINED -typedef struct _zarmour_t zarmour_t; -#define ZARMOUR_T_DEFINED -typedef struct _zcert_t zcert_t; -#define ZCERT_T_DEFINED -typedef struct _zcertstore_t zcertstore_t; -#define ZCERTSTORE_T_DEFINED -typedef struct _zchunk_t zchunk_t; -#define ZCHUNK_T_DEFINED -typedef struct _zclock_t zclock_t; -#define ZCLOCK_T_DEFINED -typedef struct _zconfig_t zconfig_t; -#define ZCONFIG_T_DEFINED -typedef struct _zdigest_t zdigest_t; -#define ZDIGEST_T_DEFINED -typedef struct _zdir_t zdir_t; -#define ZDIR_T_DEFINED -typedef struct _zdir_patch_t zdir_patch_t; -#define ZDIR_PATCH_T_DEFINED -typedef struct _zfile_t zfile_t; -#define ZFILE_T_DEFINED -typedef struct _zframe_t zframe_t; -#define ZFRAME_T_DEFINED -typedef struct _zhash_t zhash_t; -#define ZHASH_T_DEFINED -typedef struct _zhashx_t zhashx_t; -#define ZHASHX_T_DEFINED -typedef struct _ziflist_t ziflist_t; -#define ZIFLIST_T_DEFINED -typedef struct _zlist_t zlist_t; -#define ZLIST_T_DEFINED -typedef struct _zlistx_t zlistx_t; -#define ZLISTX_T_DEFINED -typedef struct _zloop_t zloop_t; -#define ZLOOP_T_DEFINED -typedef struct _zmsg_t zmsg_t; -#define ZMSG_T_DEFINED -typedef struct _zpoller_t zpoller_t; -#define ZPOLLER_T_DEFINED -typedef struct _zsock_t zsock_t; -#define ZSOCK_T_DEFINED -typedef struct _zstr_t zstr_t; -#define ZSTR_T_DEFINED -typedef struct _zuuid_t zuuid_t; -#define ZUUID_T_DEFINED -typedef struct _zauth_t zauth_t; -#define ZAUTH_T_DEFINED -typedef struct _zbeacon_t zbeacon_t; -#define ZBEACON_T_DEFINED -typedef struct _zgossip_t zgossip_t; -#define ZGOSSIP_T_DEFINED -typedef struct _zmonitor_t zmonitor_t; -#define ZMONITOR_T_DEFINED -typedef struct _zproxy_t zproxy_t; -#define ZPROXY_T_DEFINED -typedef struct _zrex_t zrex_t; -#define ZREX_T_DEFINED -typedef struct _zsys_t zsys_t; -#define ZSYS_T_DEFINED -// Draft classes are by default not built in stable releases -#ifdef CZMQ_BUILD_DRAFT_API -typedef struct _zproc_t zproc_t; -#define ZPROC_T_DEFINED -typedef struct _ztimerset_t ztimerset_t; -#define ZTIMERSET_T_DEFINED -typedef struct _ztrie_t ztrie_t; -#define ZTRIE_T_DEFINED -#endif // CZMQ_BUILD_DRAFT_API - - -// Public classes, each with its own header file -#include "zactor.h" -#include "zarmour.h" -#include "zcert.h" -#include "zcertstore.h" -#include "zchunk.h" -#include "zclock.h" -#include "zconfig.h" -#include "zdigest.h" -#include "zdir.h" -#include "zdir_patch.h" -#include "zfile.h" -#include "zframe.h" -#include "zhash.h" -#include "zhashx.h" -#include "ziflist.h" -#include "zlist.h" -#include "zlistx.h" -#include "zloop.h" -#include "zmsg.h" -#include "zpoller.h" -#include "zsock.h" -#include "zstr.h" -#include "zuuid.h" -#include "zauth.h" -#include "zbeacon.h" -#include "zgossip.h" -#include "zmonitor.h" -#include "zproxy.h" -#include "zrex.h" -#include "zsys.h" -#ifdef CZMQ_BUILD_DRAFT_API -#include "zproc.h" -#include "ztimerset.h" -#include "ztrie.h" -#endif // CZMQ_BUILD_DRAFT_API - -#endif -/* -################################################################################ -# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # -# Read the zproject/README.md for information about making permanent changes. # -################################################################################ -*/ diff --git a/phonelibs/zmq/x64/include/czmq_prelude.h b/phonelibs/zmq/x64/include/czmq_prelude.h deleted file mode 100644 index 534f47023cc756..00000000000000 --- a/phonelibs/zmq/x64/include/czmq_prelude.h +++ /dev/null @@ -1,647 +0,0 @@ -/* ========================================================================= - czmq_prelude.h - CZMQ environment - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __CZMQ_PRELUDE_H_INCLUDED__ -#define __CZMQ_PRELUDE_H_INCLUDED__ - -//- Establish the compiler and computer system ------------------------------ -/* - * Defines zero or more of these symbols, for use in any non-portable - * code: - * - * __WINDOWS__ Microsoft C/C++ with Windows calls - * __MSDOS__ System is MS-DOS (set if __WINDOWS__ set) - * __VMS__ System is VAX/VMS or Alpha/OpenVMS - * __UNIX__ System is UNIX - * __OS2__ System is OS/2 - * - * __IS_32BIT__ OS/compiler is 32 bits - * __IS_64BIT__ OS/compiler is 64 bits - * - * When __UNIX__ is defined, we also define exactly one of these: - * - * __UTYPE_AUX Apple AUX - * __UTYPE_BEOS BeOS - * __UTYPE_BSDOS BSD/OS - * __UTYPE_DECALPHA Digital UNIX (Alpha) - * __UTYPE_IBMAIX IBM RS/6000 AIX - * __UTYPE_FREEBSD FreeBSD - * __UTYPE_HPUX HP/UX - * __UTYPE_ANDROID Android - * __UTYPE_LINUX Linux - * __UTYPE_GNU GNU/Hurd - * __UTYPE_MIPS MIPS (BSD 4.3/System V mixture) - * __UTYPE_NETBSD NetBSD - * __UTYPE_NEXT NeXT - * __UTYPE_OPENBSD OpenBSD - * __UTYPE_OSX Apple Macintosh OS X - * __UTYPE_IOS Apple iOS - * __UTYPE_QNX QNX - * __UTYPE_IRIX Silicon Graphics IRIX - * __UTYPE_SINIX SINIX-N (Siemens-Nixdorf Unix) - * __UTYPE_SUNOS SunOS - * __UTYPE_SUNSOLARIS Sun Solaris - * __UTYPE_UNIXWARE SCO UnixWare - * ... these are the ones I know about so far. - * __UTYPE_GENERIC Any other UNIX - * - * When __VMS__ is defined, we may define one or more of these: - * - * __VMS_XOPEN Supports XOPEN functions - */ - -#if (defined (__64BIT__) || defined (__x86_64__)) -# define __IS_64BIT__ // May have 64-bit OS/compiler -#else -# define __IS_32BIT__ // Else assume 32-bit OS/compiler -#endif - -#if (defined WIN32 || defined _WIN32) -# undef __WINDOWS__ -# define __WINDOWS__ -# undef __MSDOS__ -# define __MSDOS__ -#endif - -#if (defined WINDOWS || defined _WINDOWS || defined __WINDOWS__) -# undef __WINDOWS__ -# define __WINDOWS__ -# undef __MSDOS__ -# define __MSDOS__ -// Stop cheeky warnings about "deprecated" functions like fopen -# if _MSC_VER >= 1500 -# undef _CRT_SECURE_NO_DEPRECATE -# define _CRT_SECURE_NO_DEPRECATE -# pragma warning(disable: 4996) -# endif -#endif - -// MSDOS Microsoft C -// _MSC_VER Microsoft C -#if (defined (MSDOS) || defined (_MSC_VER)) -# undef __MSDOS__ -# define __MSDOS__ -# if (defined (_DEBUG) && !defined (DEBUG)) -# define DEBUG -# endif -#endif - -#if (defined (__EMX__) && defined (__i386__)) -# undef __OS2__ -# define __OS2__ -#endif - -// VMS VAX C (VAX/VMS) -// __VMS Dec C (Alpha/OpenVMS) -// __vax__ gcc -#if (defined (VMS) || defined (__VMS) || defined (__vax__)) -# undef __VMS__ -# define __VMS__ -# if (__VMS_VER >= 70000000) -# define __VMS_XOPEN -# endif -#endif - -// Try to define a __UTYPE_xxx symbol... -// unix SunOS at least -// __unix__ gcc -// _POSIX_SOURCE is various UNIX systems, maybe also VAX/VMS -#if (defined (unix) || defined (__unix__) || defined (_POSIX_SOURCE)) -# if (!defined (__VMS__)) -# undef __UNIX__ -# define __UNIX__ -# if (defined (__alpha)) // Digital UNIX is 64-bit -# undef __IS_32BIT__ -# define __IS_64BIT__ -# define __UTYPE_DECALPHA -# endif -# endif -#endif - -#if (defined (_AUX)) -# define __UTYPE_AUX -# define __UNIX__ -#elif (defined (__BEOS__)) -# define __UTYPE_BEOS -# define __UNIX__ -#elif (defined (__hpux)) -# define __UTYPE_HPUX -# define __UNIX__ -# define _INCLUDE_HPUX_SOURCE -# define _INCLUDE_XOPEN_SOURCE -# define _INCLUDE_POSIX_SOURCE -#elif (defined (_AIX) || defined (AIX)) -# define __UTYPE_IBMAIX -# define __UNIX__ -#elif (defined (BSD) || defined (bsd)) -# define __UTYPE_BSDOS -# define __UNIX__ -#elif (defined (__ANDROID__)) -# define __UTYPE_ANDROID -# define __UNIX__ -#elif (defined (LINUX) || defined (linux) || defined (__linux__)) -# define __UTYPE_LINUX -# define __UNIX__ -# ifndef __NO_CTYPE -# define __NO_CTYPE // Suppress warnings on tolower() -# endif -# ifndef _DEFAULT_SOURCE -# define _DEFAULT_SOURCE // Include stuff from 4.3 BSD Unix -# endif -#elif (defined (__GNU__)) -# define __UTYPE_GNU -# define __UNIX__ -#elif (defined (Mips)) -# define __UTYPE_MIPS -# define __UNIX__ -#elif (defined (FreeBSD) || defined (__FreeBSD__)) -# define __UTYPE_FREEBSD -# define __UNIX__ -#elif (defined (NetBSD) || defined (__NetBSD__)) -# define __UTYPE_NETBSD -# define __UNIX__ -#elif (defined (OpenBSD) || defined (__OpenBSD__)) -# define __UTYPE_OPENBSD -# define __UNIX__ -#elif (defined (APPLE) || defined (__APPLE__)) -# include -# define __UNIX__ -# if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR -# define __UTYPE_IOS -# else -# define __UTYPE_OSX -# endif -#elif (defined (NeXT)) -# define __UTYPE_NEXT -# define __UNIX__ -#elif (defined (__QNX__)) -# define __UTYPE_QNX -# define __UNIX__ -#elif (defined (sgi)) -# define __UTYPE_IRIX -# define __UNIX__ -#elif (defined (sinix)) -# define __UTYPE_SINIX -# define __UNIX__ -#elif (defined (SOLARIS) || defined (__SVR4)) || defined (SVR4) -# define __UTYPE_SUNSOLARIS -# define __UNIX__ -#elif (defined (SUNOS) || defined (SUN) || defined (sun)) -# define __UTYPE_SUNOS -# define __UNIX__ -#elif (defined (__USLC__) || defined (UnixWare)) -# define __UTYPE_UNIXWARE -# define __UNIX__ -#elif (defined (__CYGWIN__)) -# define __UTYPE_CYGWIN -# define __UNIX__ -#elif (defined (__UNIX__)) -# define __UTYPE_GENERIC -#endif - -//- Always include ZeroMQ headers ------------------------------------------- - -#include "zmq.h" -#if (ZMQ_VERSION < ZMQ_MAKE_VERSION (4, 2, 0)) -# include "zmq_utils.h" -#endif - -//- Standard ANSI include files --------------------------------------------- - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//- System-specific include files ------------------------------------------- - -#if (defined (__MSDOS__)) -# if (defined (__WINDOWS__)) -# if (_WIN32_WINNT < 0x0600) -# undef _WIN32_WINNT -# define _WIN32_WINNT 0x0600 -# endif -# if (!defined (FD_SETSIZE)) -# define FD_SETSIZE 1024 // Max. filehandles/sockets -# endif -# include -# include -# include -# include -# include // For getnameinfo () -# include // For GetAdaptersAddresses () -# endif -# include -# include -# include -# include -# include -# include -# include -# include -#endif - -#if (defined (__UNIX__)) -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include // Let CZMQ build with libzmq/3.x -# include // Must come before arpa/inet.h -# if (!defined (__UTYPE_ANDROID)) && (!defined (__UTYPE_IBMAIX)) \ - && (!defined (__UTYPE_HPUX)) -# include -# endif -# if defined (__UTYPE_SUNSOLARIS) || defined (__UTYPE_SUNOS) -# include -# endif -# if (!defined (__UTYPE_BEOS)) -# include -# if (!defined (TCP_NODELAY)) -# include -# endif -# endif -# if (defined (__UTYPE_IBMAIX) || defined(__UTYPE_QNX)) -# include -# endif -# if (defined (__UTYPE_BEOS)) -# include -# endif -# if ((defined (_XOPEN_REALTIME) && (_XOPEN_REALTIME >= 1)) \ - || (defined (_POSIX_VERSION) && (_POSIX_VERSION >= 199309L))) -# include -# endif -# if (defined (__UTYPE_OSX) || defined (__UTYPE_IOS)) -# include -# include // For monotonic clocks -# endif -# if (defined (__UTYPE_OSX)) -# include // For _NSGetEnviron() -# endif -# if (defined (__UTYPE_ANDROID)) -# include -# endif -# if (defined (__UTYPE_LINUX) && defined (HAVE_LIBSYSTEMD)) -# include -# endif -#endif - -#if (defined (__VMS__)) -# if (!defined (vaxc)) -# include // Not provided by Vax C -# endif -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif - -#if (defined (__OS2__)) -# include // Required near top -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include // Must come before arpa/inet.h -# include -# include -# if (!defined (TCP_NODELAY)) -# include -# endif -#endif - -// Add missing defines for non-POSIX systems -#ifndef S_IRUSR -# define S_IRUSR S_IREAD -#endif -#ifndef S_IWUSR -# define S_IWUSR S_IWRITE -#endif -#ifndef S_ISDIR -# define S_ISDIR(m) (((m) & S_IFDIR) != 0) -#endif -#ifndef S_ISREG -# define S_ISREG(m) (((m) & S_IFREG) != 0) -#endif - - -//- Check compiler data type sizes ------------------------------------------ - -#if (UCHAR_MAX != 0xFF) -# error "Cannot compile: must change definition of 'byte'." -#endif -#if (USHRT_MAX != 0xFFFFU) -# error "Cannot compile: must change definition of 'dbyte'." -#endif -#if (UINT_MAX != 0xFFFFFFFFU) -# error "Cannot compile: must change definition of 'qbyte'." -#endif - -//- Data types -------------------------------------------------------------- - -typedef unsigned char byte; // Single unsigned byte = 8 bits -typedef unsigned short dbyte; // Double byte = 16 bits -typedef unsigned int qbyte; // Quad byte = 32 bits -typedef struct sockaddr_in inaddr_t; // Internet socket address structure -typedef struct sockaddr_in6 in6addr_t; // Internet 6 socket address structure - -// Common structure to hold inaddr_t and in6addr_t with length -typedef struct { - union { - inaddr_t __addr; // IPv4 address - in6addr_t __addr6; // IPv6 address - } __inaddr_u; -#define ipv4addr __inaddr_u.__addr -#define ipv6addr __inaddr_u.__addr6 - int inaddrlen; -} inaddr_storage_t; - -//- Inevitable macros ------------------------------------------------------- - -#define streq(s1,s2) (!strcmp ((s1), (s2))) -#define strneq(s1,s2) (strcmp ((s1), (s2))) - -// Provide random number from 0..(num-1) -// Note that (at least in Solaris) while rand() returns an int limited by -// RAND_MAX, random() returns a 32-bit value all filled with random bits. -#if (defined (__WINDOWS__)) || (defined (__UTYPE_IBMAIX)) \ - || (defined (__UTYPE_HPUX)) || (defined (__UTYPE_SUNOS)) || (defined (__UTYPE_SOLARIS)) -# define randof(num) (int) ((float) (num) * rand () / (RAND_MAX + 1.0)) -#else -# if defined(RAND_MAX) -# define randof(num) (int) ((float) (num) * (random () % RAND_MAX) / (RAND_MAX + 1.0)) -# else -# define randof(num) (int) ((float) (num) * (uint32_t)random () / (UINT32_MAX + 1.0)) -# endif -#endif - -// Windows MSVS doesn't have stdbool -#if (defined (_MSC_VER)) -# if (!defined (__cplusplus) && (!defined (true))) -# define true 1 -# define false 0 - typedef char bool; -# endif -#else -# include -#endif - -//- A number of POSIX and C99 keywords and data types ----------------------- -// CZMQ uses uint for array indices; equivalent to unsigned int, but more -// convenient in code. We define it in czmq_prelude.h on systems that do -// not define it by default. - -#if (defined (__WINDOWS__)) -# if (!defined (__cplusplus) && (!defined (inline))) -# define inline __inline -# endif -# define strtoull _strtoui64 -# define atoll _atoi64 -# define srandom srand -# define TIMEZONE _timezone -# if (!defined (__MINGW32__)) -# define snprintf _snprintf -# define vsnprintf _vsnprintf -# endif - typedef unsigned long ulong; - typedef unsigned int uint; -# if (!defined (__MINGW32__)) - typedef int mode_t; -# if !defined (_SSIZE_T_DEFINED) -typedef intptr_t ssize_t; -# define _SSIZE_T_DEFINED -# endif -# endif -# if ((!defined (__MINGW32__) \ - || (defined (__MINGW32__) && defined (__IS_64BIT__))) \ - && !defined (ZMQ_DEFINED_STDINT)) - typedef __int8 int8_t; - typedef __int16 int16_t; - typedef __int32 int32_t; - typedef __int64 int64_t; - typedef unsigned __int8 uint8_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int32 uint32_t; - typedef unsigned __int64 uint64_t; -# endif - typedef uint32_t in_addr_t; -# if (!defined (PRId8)) -# define PRId8 "d" -# endif -# if (!defined (PRId16)) -# define PRId16 "d" -# endif -# if (!defined (PRId32)) -# define PRId32 "d" -# endif -# if (!defined (PRId64)) -# define PRId64 "I64d" -# endif -# if (!defined (PRIu8)) -# define PRIu8 "u" -# endif -# if (!defined (PRIu16)) -# define PRIu16 "u" -# endif -# if (!defined (PRIu32)) -# define PRIu32 "u" -# endif -# if (!defined (PRIu64)) -# define PRIu64 "I64u" -# endif -# if (!defined (va_copy)) - // MSVC does not support C99's va_copy so we use a regular assignment -# define va_copy(dest,src) (dest) = (src) -# endif -#elif (defined (__UTYPE_OSX)) - typedef unsigned long ulong; - typedef unsigned int uint; - // This fixes header-order dependence problem with some Linux versions -#elif (defined (__UTYPE_LINUX)) -# if (__STDC_VERSION__ >= 199901L && !defined (__USE_MISC)) - typedef unsigned int uint; -# endif -#endif - -//- Non-portable declaration specifiers ------------------------------------- - -// For thread-local storage -#if defined (__WINDOWS__) -# define CZMQ_THREADLS __declspec(thread) -#else -# define CZMQ_THREADLS __thread -#endif - -// Replacement for malloc() which asserts if we run out of heap, and -// which zeroes the allocated block. -static inline void * -safe_malloc (size_t size, const char *file, unsigned line) -{ -// printf ("%s:%u %08d\n", file, line, (int) size); - void *mem = calloc (1, size); - if (mem == NULL) { - fprintf (stderr, "FATAL ERROR at %s:%u\n", file, line); - fprintf (stderr, "OUT OF MEMORY (malloc returned NULL)\n"); - fflush (stderr); - abort (); - } - return mem; -} - -// Define _ZMALLOC_DEBUG if you need to trace memory leaks using e.g. mtrace, -// otherwise all allocations will claim to come from czmq_prelude.h. For best -// results, compile all classes so you see dangling object allocations. -// _ZMALLOC_PEDANTIC does the same thing, but its intention is to propagate -// out of memory condition back up the call stack. -#if defined (_ZMALLOC_DEBUG) || defined (_ZMALLOC_PEDANTIC) -# define zmalloc(size) calloc(1,(size)) -#else -# define zmalloc(size) safe_malloc((size), __FILE__, __LINE__) -#endif - -// GCC supports validating format strings for functions that act like printf -#if defined (__GNUC__) && (__GNUC__ >= 2) -# define CHECK_PRINTF(a) __attribute__((format (printf, a, a + 1))) -#else -# define CHECK_PRINTF(a) -#endif - -// Lets us write code that compiles both on Windows and normal platforms -#if !defined (__WINDOWS__) -typedef int SOCKET; -# define closesocket close -# define INVALID_SOCKET -1 -# define SOCKET_ERROR -1 -# define O_BINARY 0 -#endif - -//- Include non-portable header files based on platform.h ------------------- - -#if defined (HAVE_LINUX_WIRELESS_H) -# include -// This would normally come from net/if.h -unsigned int if_nametoindex (const char *ifname); -#else -# if defined (HAVE_NET_IF_H) -# include -# endif -# if defined (HAVE_NET_IF_MEDIA_H) -# include -# endif -#endif - -#if defined (__WINDOWS__) && !defined (HAVE_UUID) -# define HAVE_UUID 1 -#endif -#if defined (__UTYPE_OSX) && !defined (HAVE_UUID) -# define HAVE_UUID 1 -#endif -#if defined (HAVE_UUID) -# if defined (__UTYPE_FREEBSD) || defined (__UTYPE_NETBSD) -# include -# elif defined __UTYPE_HPUX -# include -# elif defined (__UNIX__) -# include -# endif -#endif - -// ZMQ compatibility macros - -#if ZMQ_VERSION_MAJOR == 4 -# define ZMQ_POLL_MSEC 1 // zmq_poll is msec - -#elif ZMQ_VERSION_MAJOR == 3 -# define ZMQ_POLL_MSEC 1 // zmq_poll is msec -# if ZMQ_VERSION_MINOR < 2 -# define zmq_ctx_new zmq_init -# endif -# define zmq_ctx_term zmq_term - -#elif ZMQ_VERSION_MAJOR == 2 -# define ZMQ_POLL_MSEC 1000 // zmq_poll is usec -# define zmq_sendmsg zmq_send // Smooth out 2.x changes -# define zmq_recvmsg zmq_recv -# define zmq_ctx_new zmq_init -# define zmq_ctx_term zmq_term -# define zmq_msg_send(m,s,f) zmq_sendmsg ((s),(m),(f)) -# define zmq_msg_recv(m,s,f) zmq_recvmsg ((s),(m),(f)) - // Older libzmq APIs may be missing some aspects of libzmq v3.0 -# ifndef ZMQ_ROUTER -# define ZMQ_ROUTER ZMQ_XREP -# endif -# ifndef ZMQ_DEALER -# define ZMQ_DEALER ZMQ_XREQ -# endif -# ifndef ZMQ_DONTWAIT -# define ZMQ_DONTWAIT ZMQ_NOBLOCK -# endif -# ifndef ZMQ_XSUB -# error "please upgrade your libzmq from http://zeromq.org" -# endif -# if ZMQ_VERSION_MINOR == 0 \ - || (ZMQ_VERSION_MINOR == 1 && ZMQ_VERSION_PATCH < 7) -# error "CZMQ requires at least libzmq/2.1.7 stable" -# endif -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zactor.h b/phonelibs/zmq/x64/include/zactor.h deleted file mode 100644 index c865c65daf1efa..00000000000000 --- a/phonelibs/zmq/x64/include/zactor.h +++ /dev/null @@ -1,76 +0,0 @@ -/* ========================================================================= - zactor - actor - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZACTOR_H_INCLUDED__ -#define __ZACTOR_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zactor.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// Actors get a pipe and arguments from caller -typedef void (zactor_fn) ( - zsock_t *pipe, void *args); - -// Create a new actor passing arbitrary arguments reference. -CZMQ_EXPORT zactor_t * - zactor_new (zactor_fn task, void *args); - -// Destroy an actor. -CZMQ_EXPORT void - zactor_destroy (zactor_t **self_p); - -// Send a zmsg message to the actor, take ownership of the message -// and destroy when it has been sent. -CZMQ_EXPORT int - zactor_send (zactor_t *self, zmsg_t **msg_p); - -// Receive a zmsg message from the actor. Returns NULL if the actor -// was interrupted before the message could be received, or if there -// was a timeout on the actor. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zmsg_t * - zactor_recv (zactor_t *self); - -// Probe the supplied object, and report if it looks like a zactor_t. -CZMQ_EXPORT bool - zactor_is (void *self); - -// Probe the supplied reference. If it looks like a zactor_t instance, -// return the underlying libzmq actor handle; else if it looks like -// a libzmq actor handle, return the supplied value. -CZMQ_EXPORT void * - zactor_resolve (void *self); - -// Return the actor's zsock handle. Use this when you absolutely need -// to work with the zsock instance rather than the actor. -CZMQ_EXPORT zsock_t * - zactor_sock (zactor_t *self); - -// Self test of this class. -CZMQ_EXPORT void - zactor_test (bool verbose); - -// @end - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zarmour.h b/phonelibs/zmq/x64/include/zarmour.h deleted file mode 100644 index c7f299f7afe989..00000000000000 --- a/phonelibs/zmq/x64/include/zarmour.h +++ /dev/null @@ -1,114 +0,0 @@ -/* ========================================================================= - zarmour - armoured text encoding and decoding - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZARMOUR_H_INCLUDED__ -#define __ZARMOUR_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zarmour.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -#define ZARMOUR_MODE_BASE64_STD 0 // Standard base 64 -#define ZARMOUR_MODE_BASE64_URL 1 // URL and filename friendly base 64 -#define ZARMOUR_MODE_BASE32_STD 2 // Standard base 32 -#define ZARMOUR_MODE_BASE32_HEX 3 // Extended hex base 32 -#define ZARMOUR_MODE_BASE16 4 // Standard base 16 -#define ZARMOUR_MODE_Z85 5 // Z85 from ZeroMQ RFC 32 - -// Create a new zarmour -CZMQ_EXPORT zarmour_t * - zarmour_new (void); - -// Destroy the zarmour -CZMQ_EXPORT void - zarmour_destroy (zarmour_t **self_p); - -// Encode a stream of bytes into an armoured string. Returns the armoured -// string, or NULL if there was insufficient memory available to allocate -// a new string. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zarmour_encode (zarmour_t *self, const byte *data, size_t size); - -// Decode an armoured string into a chunk. The decoded output is -// null-terminated, so it may be treated as a string, if that's what -// it was prior to encoding. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zchunk_t * - zarmour_decode (zarmour_t *self, const char *data); - -// Get the mode property. -CZMQ_EXPORT int - zarmour_mode (zarmour_t *self); - -// Get printable string for mode. -CZMQ_EXPORT const char * - zarmour_mode_str (zarmour_t *self); - -// Set the mode property. -CZMQ_EXPORT void - zarmour_set_mode (zarmour_t *self, int mode); - -// Return true if padding is turned on. -CZMQ_EXPORT bool - zarmour_pad (zarmour_t *self); - -// Turn padding on or off. Default is on. -CZMQ_EXPORT void - zarmour_set_pad (zarmour_t *self, bool pad); - -// Get the padding character. -CZMQ_EXPORT char - zarmour_pad_char (zarmour_t *self); - -// Set the padding character. -CZMQ_EXPORT void - zarmour_set_pad_char (zarmour_t *self, char pad_char); - -// Return if splitting output into lines is turned on. Default is off. -CZMQ_EXPORT bool - zarmour_line_breaks (zarmour_t *self); - -// Turn splitting output into lines on or off. -CZMQ_EXPORT void - zarmour_set_line_breaks (zarmour_t *self, bool line_breaks); - -// Get the line length used for splitting lines. -CZMQ_EXPORT size_t - zarmour_line_length (zarmour_t *self); - -// Set the line length used for splitting lines. -CZMQ_EXPORT void - zarmour_set_line_length (zarmour_t *self, size_t line_length); - -// Print properties of object -CZMQ_EXPORT void - zarmour_print (zarmour_t *self); - -// Self test of this class. -CZMQ_EXPORT void - zarmour_test (bool verbose); - -// @end - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zauth.h b/phonelibs/zmq/x64/include/zauth.h deleted file mode 100644 index 3e0e59ecabf544..00000000000000 --- a/phonelibs/zmq/x64/include/zauth.h +++ /dev/null @@ -1,100 +0,0 @@ -/* ========================================================================= - zauth - authentication for ZeroMQ security mechanisms - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZAUTH_H_INCLUDED__ -#define __ZAUTH_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @interface -#define CURVE_ALLOW_ANY "*" - -// CZMQ v3 API (for use with zsock, not zsocket, which is deprecated). -// -// Create new zauth actor instance. This installs authentication on all -// zsock sockets. Until you add policies, all incoming NULL connections are -// allowed (classic ZeroMQ behaviour), and all PLAIN and CURVE connections -// are denied: -// -// zactor_t *auth = zactor_new (zauth, NULL); -// -// Destroy zauth instance. This removes authentication and allows all -// connections to pass, without authentication: -// -// zactor_destroy (&auth); -// -// Note that all zauth commands are synchronous, so your application always -// waits for a signal from the actor after each command. -// -// Enable verbose logging of commands and activity. Verbose logging can help -// debug non-trivial authentication policies: -// -// zstr_send (auth, "VERBOSE"); -// zsock_wait (auth); -// -// Allow (whitelist) a list of IP addresses. For NULL, all clients from -// these addresses will be accepted. For PLAIN and CURVE, they will be -// allowed to continue with authentication. You can call this method -// multiple times to whitelist more IP addresses. If you whitelist one -// or more addresses, any non-whitelisted addresses are treated as -// blacklisted: -// -// zstr_sendx (auth, "ALLOW", "127.0.0.1", "127.0.0.2", NULL); -// zsock_wait (auth); -// -// Deny (blacklist) a list of IP addresses. For all security mechanisms, -// this rejects the connection without any further authentication. Use -// either a whitelist, or a blacklist, not not both. If you define both -// a whitelist and a blacklist, only the whitelist takes effect: -// -// zstr_sendx (auth, "DENY", "192.168.0.1", "192.168.0.2", NULL); -// zsock_wait (auth); -// -// Configure PLAIN authentication using a plain-text password file. You can -// modify the password file at any time; zauth will reload it automatically -// if modified externally: -// -// zstr_sendx (auth, "PLAIN", filename, NULL); -// zsock_wait (auth); -// -// Configure CURVE authentication, using a directory that holds all public -// client certificates, i.e. their public keys. The certificates must be in -// zcert_save format. You can add and remove certificates in that directory -// at any time. To allow all client keys without checking, specify -// CURVE_ALLOW_ANY for the directory name: -// -// zstr_sendx (auth, "CURVE", directory, NULL); -// zsock_wait (auth); -// -// Configure GSSAPI authentication, using an underlying mechanism (usually -// Kerberos) to establish a secure context and perform mutual authentication: -// -// zstr_sendx (auth, "GSSAPI", NULL); -// zsock_wait (auth); -// -// This is the zauth constructor as a zactor_fn: -CZMQ_EXPORT void - zauth (zsock_t *pipe, void *certstore); - -// Selftest -CZMQ_EXPORT void - zauth_test (bool verbose); -// @end - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zbeacon.h b/phonelibs/zmq/x64/include/zbeacon.h deleted file mode 100644 index 78917e9577e40f..00000000000000 --- a/phonelibs/zmq/x64/include/zbeacon.h +++ /dev/null @@ -1,86 +0,0 @@ -/* ========================================================================= - zbeacon - LAN discovery and presence - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZBEACON_H_INCLUDED__ -#define __ZBEACON_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @interface -// Create new zbeacon actor instance: -// -// zactor_t *beacon = zactor_new (zbeacon, NULL); -// -// Destroy zbeacon instance: -// -// zactor_destroy (&beacon); -// -// Enable verbose logging of commands and activity: -// -// zstr_send (beacon, "VERBOSE"); -// -// Configure beacon to run on specified UDP port, and return the name of -// the host, which can be used as endpoint for incoming connections. To -// force the beacon to operate on a given interface, set the environment -// variable ZSYS_INTERFACE, or call zsys_set_interface() before creating -// the beacon. If the system does not support UDP broadcasts (lacking a -// workable interface), returns an empty hostname: -// -// // Pictures: 's' = C string, 'i' = int -// zsock_send (beacon, "si", "CONFIGURE", port_number); -// char *hostname = zstr_recv (beacon); -// -// Start broadcasting a beacon at a specified interval in msec. The beacon -// data can be at most UDP_FRAME_MAX bytes; this constant is defined in -// zsys.h to be 255: -// -// // Pictures: 'b' = byte * data + size_t size -// zsock_send (beacon, "sbi", "PUBLISH", data, size, interval); -// -// Stop broadcasting the beacon: -// -// zstr_sendx (beacon, "SILENCE", NULL); -// -// Start listening to beacons from peers. The filter is used to do a prefix -// match on received beacons, to remove junk. Note that any received data -// that is identical to our broadcast beacon_data is discarded in any case. -// If the filter size is zero, we get all peer beacons: -// -// zsock_send (beacon, "sb", "SUBSCRIBE", filter_data, filter_size); -// -// Stop listening to other peers -// -// zstr_sendx (beacon, "UNSUBSCRIBE", NULL); -// -// Receive next beacon from a peer. Received beacons are always a 2-frame -// message containing the ipaddress of the sender, and then the binary -// beacon data as published by the sender: -// -// zmsg_t *msg = zmsg_recv (beacon); -// -// This is the zbeacon constructor as a zactor_fn: -CZMQ_EXPORT void - zbeacon (zsock_t *pipe, void *unused); - -// Self test of this class -CZMQ_EXPORT void - zbeacon_test (bool verbose); -// @end - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zcert.h b/phonelibs/zmq/x64/include/zcert.h deleted file mode 100644 index 3161bc0596b51b..00000000000000 --- a/phonelibs/zmq/x64/include/zcert.h +++ /dev/null @@ -1,128 +0,0 @@ -/* ========================================================================= - zcert - work with CURVE security certificates - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZCERT_H_INCLUDED__ -#define __ZCERT_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zcert.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// This class has draft methods, which may change over time. They are not -// in stable releases, by default. Use --enable-drafts to enable. -// Create and initialize a new certificate in memory -CZMQ_EXPORT zcert_t * - zcert_new (void); - -// Accepts public/secret key pair from caller -CZMQ_EXPORT zcert_t * - zcert_new_from (const byte *public_key, const byte *secret_key); - -// Load certificate from file -CZMQ_EXPORT zcert_t * - zcert_load (const char *filename); - -// Destroy a certificate in memory -CZMQ_EXPORT void - zcert_destroy (zcert_t **self_p); - -// Return public part of key pair as 32-byte binary string -CZMQ_EXPORT const byte * - zcert_public_key (zcert_t *self); - -// Return secret part of key pair as 32-byte binary string -CZMQ_EXPORT const byte * - zcert_secret_key (zcert_t *self); - -// Return public part of key pair as Z85 armored string -CZMQ_EXPORT const char * - zcert_public_txt (zcert_t *self); - -// Return secret part of key pair as Z85 armored string -CZMQ_EXPORT const char * - zcert_secret_txt (zcert_t *self); - -// Set certificate metadata from formatted string. -CZMQ_EXPORT void - zcert_set_meta (zcert_t *self, const char *name, const char *format, ...) CHECK_PRINTF (3); - -// Get metadata value from certificate; if the metadata value doesn't -// exist, returns NULL. -CZMQ_EXPORT const char * - zcert_meta (zcert_t *self, const char *name); - -// Get list of metadata fields from certificate. Caller is responsible for -// destroying list. Caller should not modify the values of list items. -CZMQ_EXPORT zlist_t * - zcert_meta_keys (zcert_t *self); - -// Save full certificate (public + secret) to file for persistent storage -// This creates one public file and one secret file (filename + "_secret"). -CZMQ_EXPORT int - zcert_save (zcert_t *self, const char *filename); - -// Save public certificate only to file for persistent storage -CZMQ_EXPORT int - zcert_save_public (zcert_t *self, const char *filename); - -// Save secret certificate only to file for persistent storage -CZMQ_EXPORT int - zcert_save_secret (zcert_t *self, const char *filename); - -// Apply certificate to socket, i.e. use for CURVE security on socket. -// If certificate was loaded from public file, the secret key will be -// undefined, and this certificate will not work successfully. -CZMQ_EXPORT void - zcert_apply (zcert_t *self, void *socket); - -// Return copy of certificate; if certificate is NULL or we exhausted -// heap memory, returns NULL. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zcert_t * - zcert_dup (zcert_t *self); - -// Return true if two certificates have the same keys -CZMQ_EXPORT bool - zcert_eq (zcert_t *self, zcert_t *compare); - -// Print certificate contents to stdout -CZMQ_EXPORT void - zcert_print (zcert_t *self); - -// Self test of this class -CZMQ_EXPORT void - zcert_test (bool verbose); - -#ifdef CZMQ_BUILD_DRAFT_API -// *** Draft method, for development use, may change without warning *** -// Unset certificate metadata. -CZMQ_EXPORT void - zcert_unset_meta (zcert_t *self, const char *name); - -#endif // CZMQ_BUILD_DRAFT_API -// @end - - -#ifdef __cplusplus -} -#endif - -// Deprecated method aliases -#define zcert_dump(s) zcert_print(s) - -#endif diff --git a/phonelibs/zmq/x64/include/zcertstore.h b/phonelibs/zmq/x64/include/zcertstore.h deleted file mode 100644 index 689b228ac1ed17..00000000000000 --- a/phonelibs/zmq/x64/include/zcertstore.h +++ /dev/null @@ -1,92 +0,0 @@ -/* ========================================================================= - zcertstore - work with CURVE security certificate stores - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZCERTSTORE_H_INCLUDED__ -#define __ZCERTSTORE_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zcertstore.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// This class has draft methods, which may change over time. They are not -// in stable releases, by default. Use --enable-drafts to enable. -// Create a new certificate store from a disk directory, loading and -// indexing all certificates in that location. The directory itself may be -// absent, and created later, or modified at any time. The certificate store -// is automatically refreshed on any zcertstore_lookup() call. If the -// location is specified as NULL, creates a pure-memory store, which you -// can work with by inserting certificates at runtime. -CZMQ_EXPORT zcertstore_t * - zcertstore_new (const char *location); - -// Destroy a certificate store object in memory. Does not affect anything -// stored on disk. -CZMQ_EXPORT void - zcertstore_destroy (zcertstore_t **self_p); - -// Look up certificate by public key, returns zcert_t object if found, -// else returns NULL. The public key is provided in Z85 text format. -CZMQ_EXPORT zcert_t * - zcertstore_lookup (zcertstore_t *self, const char *public_key); - -// Insert certificate into certificate store in memory. Note that this -// does not save the certificate to disk. To do that, use zcert_save() -// directly on the certificate. Takes ownership of zcert_t object. -CZMQ_EXPORT void - zcertstore_insert (zcertstore_t *self, zcert_t **cert_p); - -// Print list of certificates in store to logging facility -CZMQ_EXPORT void - zcertstore_print (zcertstore_t *self); - -// Self test of this class -CZMQ_EXPORT void - zcertstore_test (bool verbose); - -#ifdef CZMQ_BUILD_DRAFT_API -// Loaders retrieve certificates from an arbitrary source. -typedef void (zcertstore_loader) ( - zcertstore_t *self); - -// Destructor for loader state. -typedef void (zcertstore_destructor) ( - void **self_p); - -// *** Draft method, for development use, may change without warning *** -// Override the default disk loader with a custom loader fn. -CZMQ_EXPORT void - zcertstore_set_loader (zcertstore_t *self, zcertstore_loader loader, zcertstore_destructor destructor, void *state); - -// *** Draft method, for development use, may change without warning *** -// Empty certificate hashtable. This wrapper exists to be friendly to bindings, -// which don't usually have access to struct internals. -CZMQ_EXPORT void - zcertstore_empty (zcertstore_t *self); - -#endif // CZMQ_BUILD_DRAFT_API -// @end - - -#ifdef __cplusplus -} -#endif - -// Deprecated method aliases -#define zcertstore_dump(s) zcertstore_print(s) - -#endif diff --git a/phonelibs/zmq/x64/include/zchunk.h b/phonelibs/zmq/x64/include/zchunk.h deleted file mode 100644 index 56f29b161a37e5..00000000000000 --- a/phonelibs/zmq/x64/include/zchunk.h +++ /dev/null @@ -1,163 +0,0 @@ -/* ========================================================================= - zchunk - work with memory chunks - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZCHUNK_H_INCLUDED__ -#define __ZCHUNK_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zchunk.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// Create a new chunk of the specified size. If you specify the data, it -// is copied into the chunk. If you do not specify the data, the chunk is -// allocated and left empty, and you can then add data using zchunk_append. -CZMQ_EXPORT zchunk_t * - zchunk_new (const void *data, size_t size); - -// Destroy a chunk -CZMQ_EXPORT void - zchunk_destroy (zchunk_t **self_p); - -// Resizes chunk max_size as requested; chunk_cur size is set to zero -CZMQ_EXPORT void - zchunk_resize (zchunk_t *self, size_t size); - -// Return chunk cur size -CZMQ_EXPORT size_t - zchunk_size (zchunk_t *self); - -// Return chunk max size -CZMQ_EXPORT size_t - zchunk_max_size (zchunk_t *self); - -// Return chunk data -CZMQ_EXPORT byte * - zchunk_data (zchunk_t *self); - -// Set chunk data from user-supplied data; truncate if too large. Data may -// be null. Returns actual size of chunk -CZMQ_EXPORT size_t - zchunk_set (zchunk_t *self, const void *data, size_t size); - -// Fill chunk data from user-supplied octet -CZMQ_EXPORT size_t - zchunk_fill (zchunk_t *self, byte filler, size_t size); - -// Append user-supplied data to chunk, return resulting chunk size. If the -// data would exceeded the available space, it is truncated. If you want to -// grow the chunk to accommodate new data, use the zchunk_extend method. -CZMQ_EXPORT size_t - zchunk_append (zchunk_t *self, const void *data, size_t size); - -// Append user-supplied data to chunk, return resulting chunk size. If the -// data would exceeded the available space, the chunk grows in size. -CZMQ_EXPORT size_t - zchunk_extend (zchunk_t *self, const void *data, size_t size); - -// Copy as much data from 'source' into the chunk as possible; returns the -// new size of chunk. If all data from 'source' is used, returns exhausted -// on the source chunk. Source can be consumed as many times as needed until -// it is exhausted. If source was already exhausted, does not change chunk. -CZMQ_EXPORT size_t - zchunk_consume (zchunk_t *self, zchunk_t *source); - -// Returns true if the chunk was exhausted by consume methods, or if the -// chunk has a size of zero. -CZMQ_EXPORT bool - zchunk_exhausted (zchunk_t *self); - -// Read chunk from an open file descriptor -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zchunk_t * - zchunk_read (FILE *handle, size_t bytes); - -// Write chunk to an open file descriptor -CZMQ_EXPORT int - zchunk_write (zchunk_t *self, FILE *handle); - -// Try to slurp an entire file into a chunk. Will read up to maxsize of -// the file. If maxsize is 0, will attempt to read the entire file and -// fail with an assertion if that cannot fit into memory. Returns a new -// chunk containing the file data, or NULL if the file could not be read. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zchunk_t * - zchunk_slurp (const char *filename, size_t maxsize); - -// Create copy of chunk, as new chunk object. Returns a fresh zchunk_t -// object, or null if there was not enough heap memory. If chunk is null, -// returns null. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zchunk_t * - zchunk_dup (zchunk_t *self); - -// Return chunk data encoded as printable hex string. Caller must free -// string when finished with it. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zchunk_strhex (zchunk_t *self); - -// Return chunk data copied into freshly allocated string -// Caller must free string when finished with it. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zchunk_strdup (zchunk_t *self); - -// Return TRUE if chunk body is equal to string, excluding terminator -CZMQ_EXPORT bool - zchunk_streq (zchunk_t *self, const char *string); - -// Transform zchunk into a zframe that can be sent in a message. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zframe_t * - zchunk_pack (zchunk_t *self); - -// Transform a zframe into a zchunk. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zchunk_t * - zchunk_unpack (zframe_t *frame); - -// Calculate SHA1 digest for chunk, using zdigest class. -CZMQ_EXPORT const char * - zchunk_digest (zchunk_t *self); - -// Dump chunk to FILE stream, for debugging and tracing. -CZMQ_EXPORT void - zchunk_fprint (zchunk_t *self, FILE *file); - -// Dump message to stderr, for debugging and tracing. -// See zchunk_fprint for details -CZMQ_EXPORT void - zchunk_print (zchunk_t *self); - -// Probe the supplied object, and report if it looks like a zchunk_t. -CZMQ_EXPORT bool - zchunk_is (void *self); - -// Self test of this class. -CZMQ_EXPORT void - zchunk_test (bool verbose); - -// @end - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/phonelibs/zmq/x64/include/zclock.h b/phonelibs/zmq/x64/include/zclock.h deleted file mode 100644 index eb064162c4722a..00000000000000 --- a/phonelibs/zmq/x64/include/zclock.h +++ /dev/null @@ -1,73 +0,0 @@ -/* ========================================================================= - zclock - millisecond clocks and delays - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZCLOCK_H_INCLUDED__ -#define __ZCLOCK_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zclock.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// Sleep for a number of milliseconds -CZMQ_EXPORT void - zclock_sleep (int msecs); - -// Return current system clock as milliseconds. Note that this clock can -// jump backwards (if the system clock is changed) so is unsafe to use for -// timers and time offsets. Use zclock_mono for that instead. -CZMQ_EXPORT int64_t - zclock_time (void); - -// Return current monotonic clock in milliseconds. Use this when you compute -// time offsets. The monotonic clock is not affected by system changes and -// so will never be reset backwards, unlike a system clock. -CZMQ_EXPORT int64_t - zclock_mono (void); - -// Return current monotonic clock in microseconds. Use this when you compute -// time offsets. The monotonic clock is not affected by system changes and -// so will never be reset backwards, unlike a system clock. -CZMQ_EXPORT int64_t - zclock_usecs (void); - -// Return formatted date/time as fresh string. Free using zstr_free(). -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zclock_timestr (void); - -// Self test of this class. -CZMQ_EXPORT void - zclock_test (bool verbose); - -// @end - - -// DEPRECATED in favor of zsys logging, see issue #519 -// Print formatted string to stdout, prefixed by date/time and -// terminated with a newline. -CZMQ_EXPORT void - zclock_log (const char *format, ...); - -// Compiler hints -CZMQ_EXPORT void zclock_log (const char *format, ...) CHECK_PRINTF (1); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zconfig.h b/phonelibs/zmq/x64/include/zconfig.h deleted file mode 100644 index df0c708493f512..00000000000000 --- a/phonelibs/zmq/x64/include/zconfig.h +++ /dev/null @@ -1,185 +0,0 @@ -/* ========================================================================= - zconfig - work with config files written in rfc.zeromq.org/spec:4/ZPL. - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZCONFIG_H_INCLUDED__ -#define __ZCONFIG_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zconfig.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// -typedef int (zconfig_fct) ( - zconfig_t *self, void *arg, int level); - -// Create new config item -CZMQ_EXPORT zconfig_t * - zconfig_new (const char *name, zconfig_t *parent); - -// Load a config tree from a specified ZPL text file; returns a zconfig_t -// reference for the root, if the file exists and is readable. Returns NULL -// if the file does not exist. -CZMQ_EXPORT zconfig_t * - zconfig_load (const char *filename); - -// Equivalent to zconfig_load, taking a format string instead of a fixed -// filename. -CZMQ_EXPORT zconfig_t * - zconfig_loadf (const char *format, ...) CHECK_PRINTF (1); - -// Destroy a config item and all its children -CZMQ_EXPORT void - zconfig_destroy (zconfig_t **self_p); - -// Return name of config item -CZMQ_EXPORT char * - zconfig_name (zconfig_t *self); - -// Return value of config item -CZMQ_EXPORT char * - zconfig_value (zconfig_t *self); - -// Insert or update configuration key with value -CZMQ_EXPORT void - zconfig_put (zconfig_t *self, const char *path, const char *value); - -// Equivalent to zconfig_put, accepting a format specifier and variable -// argument list, instead of a single string value. -CZMQ_EXPORT void - zconfig_putf (zconfig_t *self, const char *path, const char *format, ...) CHECK_PRINTF (3); - -// Get value for config item into a string value; leading slash is optional -// and ignored. -CZMQ_EXPORT char * - zconfig_get (zconfig_t *self, const char *path, const char *default_value); - -// Set config item name, name may be NULL -CZMQ_EXPORT void - zconfig_set_name (zconfig_t *self, const char *name); - -// Set new value for config item. The new value may be a string, a printf -// format, or NULL. Note that if string may possibly contain '%', or if it -// comes from an insecure source, you must use '%s' as the format, followed -// by the string. -CZMQ_EXPORT void - zconfig_set_value (zconfig_t *self, const char *format, ...) CHECK_PRINTF (2); - -// Find our first child, if any -CZMQ_EXPORT zconfig_t * - zconfig_child (zconfig_t *self); - -// Find our first sibling, if any -CZMQ_EXPORT zconfig_t * - zconfig_next (zconfig_t *self); - -// Find a config item along a path; leading slash is optional and ignored. -CZMQ_EXPORT zconfig_t * - zconfig_locate (zconfig_t *self, const char *path); - -// Locate the last config item at a specified depth -CZMQ_EXPORT zconfig_t * - zconfig_at_depth (zconfig_t *self, int level); - -// Execute a callback for each config item in the tree; returns zero if -// successful, else -1. -CZMQ_EXPORT int - zconfig_execute (zconfig_t *self, zconfig_fct handler, void *arg); - -// Add comment to config item before saving to disk. You can add as many -// comment lines as you like. If you use a null format, all comments are -// deleted. -CZMQ_EXPORT void - zconfig_set_comment (zconfig_t *self, const char *format, ...) CHECK_PRINTF (2); - -// Return comments of config item, as zlist. -CZMQ_EXPORT zlist_t * - zconfig_comments (zconfig_t *self); - -// Save a config tree to a specified ZPL text file, where a filename -// "-" means dump to standard output. -CZMQ_EXPORT int - zconfig_save (zconfig_t *self, const char *filename); - -// Equivalent to zconfig_save, taking a format string instead of a fixed -// filename. -CZMQ_EXPORT int - zconfig_savef (zconfig_t *self, const char *format, ...) CHECK_PRINTF (2); - -// Report filename used during zconfig_load, or NULL if none -CZMQ_EXPORT const char * - zconfig_filename (zconfig_t *self); - -// Reload config tree from same file that it was previously loaded from. -// Returns 0 if OK, -1 if there was an error (and then does not change -// existing data). -CZMQ_EXPORT int - zconfig_reload (zconfig_t **self_p); - -// Load a config tree from a memory chunk -CZMQ_EXPORT zconfig_t * - zconfig_chunk_load (zchunk_t *chunk); - -// Save a config tree to a new memory chunk -CZMQ_EXPORT zchunk_t * - zconfig_chunk_save (zconfig_t *self); - -// Load a config tree from a null-terminated string -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zconfig_t * - zconfig_str_load (const char *string); - -// Save a config tree to a new null terminated string -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zconfig_str_save (zconfig_t *self); - -// Return true if a configuration tree was loaded from a file and that -// file has changed in since the tree was loaded. -CZMQ_EXPORT bool - zconfig_has_changed (zconfig_t *self); - -// Print the config file to open stream -CZMQ_EXPORT void - zconfig_fprint (zconfig_t *self, FILE *file); - -// Print properties of object -CZMQ_EXPORT void - zconfig_print (zconfig_t *self); - -// Self test of this class -CZMQ_EXPORT void - zconfig_test (bool verbose); - -// @end - -// Self test of this class -CZMQ_EXPORT void - zconfig_test (bool verbose); - -// Compiler hints -CZMQ_EXPORT void zconfig_set_value (zconfig_t *self, const char *format, ...) CHECK_PRINTF (2); - -#ifdef __cplusplus -} -#endif - -// Deprecated method aliases -#define zconfig_dump(s) zconfig_print(s) -#define zconfig_resolve(s,p,d) zconfig_get((s),(p),(d)) - -#endif diff --git a/phonelibs/zmq/x64/include/zdigest.h b/phonelibs/zmq/x64/include/zdigest.h deleted file mode 100644 index def9e860537094..00000000000000 --- a/phonelibs/zmq/x64/include/zdigest.h +++ /dev/null @@ -1,65 +0,0 @@ -/* ========================================================================= - zdigest - provides hashing functions (SHA-1 at present) - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZDIGEST_H_INCLUDED__ -#define __ZDIGEST_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zdigest.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// Constructor - creates new digest object, which you use to build up a -// digest by repeatedly calling zdigest_update() on chunks of data. -CZMQ_EXPORT zdigest_t * - zdigest_new (void); - -// Destroy a digest object -CZMQ_EXPORT void - zdigest_destroy (zdigest_t **self_p); - -// Add buffer into digest calculation -CZMQ_EXPORT void - zdigest_update (zdigest_t *self, const byte *buffer, size_t length); - -// Return final digest hash data. If built without crypto support, -// returns NULL. -CZMQ_EXPORT const byte * - zdigest_data (zdigest_t *self); - -// Return final digest hash size -CZMQ_EXPORT size_t - zdigest_size (zdigest_t *self); - -// Return digest as printable hex string; caller should not modify nor -// free this string. After calling this, you may not use zdigest_update() -// on the same digest. If built without crypto support, returns NULL. -CZMQ_EXPORT char * - zdigest_string (zdigest_t *self); - -// Self test of this class. -CZMQ_EXPORT void - zdigest_test (bool verbose); - -// @end - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zdir.h b/phonelibs/zmq/x64/include/zdir.h deleted file mode 100644 index 6c5551b57eead4..00000000000000 --- a/phonelibs/zmq/x64/include/zdir.h +++ /dev/null @@ -1,149 +0,0 @@ -/* ========================================================================= - zdir - work with file-system directories - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZDIR_H_INCLUDED__ -#define __ZDIR_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zdir.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// Create a new directory item that loads in the full tree of the specified -// path, optionally located under some parent path. If parent is "-", then -// loads only the top-level directory, and does not use parent as a path. -CZMQ_EXPORT zdir_t * - zdir_new (const char *path, const char *parent); - -// Destroy a directory tree and all children it contains. -CZMQ_EXPORT void - zdir_destroy (zdir_t **self_p); - -// Return directory path -CZMQ_EXPORT const char * - zdir_path (zdir_t *self); - -// Return last modification time for directory. -CZMQ_EXPORT time_t - zdir_modified (zdir_t *self); - -// Return total hierarchy size, in bytes of data contained in all files -// in the directory tree. -CZMQ_EXPORT off_t - zdir_cursize (zdir_t *self); - -// Return directory count -CZMQ_EXPORT size_t - zdir_count (zdir_t *self); - -// Returns a sorted list of zfile objects; Each entry in the list is a pointer -// to a zfile_t item already allocated in the zdir tree. Do not destroy the -// original zdir tree until you are done with this list. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zlist_t * - zdir_list (zdir_t *self); - -// Remove directory, optionally including all files that it contains, at -// all levels. If force is false, will only remove the directory if empty. -// If force is true, will remove all files and all subdirectories. -CZMQ_EXPORT void - zdir_remove (zdir_t *self, bool force); - -// Calculate differences between two versions of a directory tree. -// Returns a list of zdir_patch_t patches. Either older or newer may -// be null, indicating the directory is empty/absent. If alias is set, -// generates virtual filename (minus path, plus alias). -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zlist_t * - zdir_diff (zdir_t *older, zdir_t *newer, const char *alias); - -// Return full contents of directory as a zdir_patch list. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zlist_t * - zdir_resync (zdir_t *self, const char *alias); - -// Load directory cache; returns a hash table containing the SHA-1 digests -// of every file in the tree. The cache is saved between runs in .cache. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zhash_t * - zdir_cache (zdir_t *self); - -// Print contents of directory to open stream -CZMQ_EXPORT void - zdir_fprint (zdir_t *self, FILE *file, int indent); - -// Print contents of directory to stdout -CZMQ_EXPORT void - zdir_print (zdir_t *self, int indent); - -// Create a new zdir_watch actor instance: -// -// zactor_t *watch = zactor_new (zdir_watch, NULL); -// -// Destroy zdir_watch instance: -// -// zactor_destroy (&watch); -// -// Enable verbose logging of commands and activity: -// -// zstr_send (watch, "VERBOSE"); -// -// Subscribe to changes to a directory path: -// -// zsock_send (watch, "ss", "SUBSCRIBE", "directory_path"); -// -// Unsubscribe from changes to a directory path: -// -// zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path"); -// -// Receive directory changes: -// zsock_recv (watch, "sp", &path, &patches); -// -// // Delete the received data. -// free (path); -// zlist_destroy (&patches); -CZMQ_EXPORT void - zdir_watch (zsock_t *pipe, void *unused); - -// Self test of this class. -CZMQ_EXPORT void - zdir_test (bool verbose); - -// @end - - -// Returns a sorted array of zfile objects; returns a single block of memory, -// that you destroy by calling zstr_free(). Each entry in the array is a pointer -// to a zfile_t item already allocated in the zdir tree. The array ends with -// a null pointer. Do not destroy the original zdir tree until you are done -// with this array. -CZMQ_EXPORT zfile_t ** - zdir_flatten (zdir_t *self); - -// Free a provided string, and nullify the parent pointer. Safe to call on -// a null pointer. -CZMQ_EXPORT void - zdir_flatten_free (zfile_t ***files_p); - -#ifdef __cplusplus -} -#endif - -// Deprecated method aliases -#define zdir_dump(s,i) zdir_print(s,i) - -#endif diff --git a/phonelibs/zmq/x64/include/zdir_patch.h b/phonelibs/zmq/x64/include/zdir_patch.h deleted file mode 100644 index 8d15b9aeb40c42..00000000000000 --- a/phonelibs/zmq/x64/include/zdir_patch.h +++ /dev/null @@ -1,82 +0,0 @@ -/* ========================================================================= - zdir_patch - work with directory patches - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZDIR_PATCH_H_INCLUDED__ -#define __ZDIR_PATCH_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// un-namespaced enumeration values -#define patch_create ZDIR_PATCH_CREATE -#define patch_delete ZDIR_PATCH_DELETE - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zdir_patch.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -#define ZDIR_PATCH_CREATE 1 // Creates a new file -#define ZDIR_PATCH_DELETE 2 // Delete a file - -// Create new patch -CZMQ_EXPORT zdir_patch_t * - zdir_patch_new (const char *path, zfile_t *file, int op, const char *alias); - -// Destroy a patch -CZMQ_EXPORT void - zdir_patch_destroy (zdir_patch_t **self_p); - -// Create copy of a patch. If the patch is null, or memory was exhausted, -// returns null. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zdir_patch_t * - zdir_patch_dup (zdir_patch_t *self); - -// Return patch file directory path -CZMQ_EXPORT const char * - zdir_patch_path (zdir_patch_t *self); - -// Return patch file item -CZMQ_EXPORT zfile_t * - zdir_patch_file (zdir_patch_t *self); - -// Return operation -CZMQ_EXPORT int - zdir_patch_op (zdir_patch_t *self); - -// Return patch virtual file path -CZMQ_EXPORT const char * - zdir_patch_vpath (zdir_patch_t *self); - -// Calculate hash digest for file (create only) -CZMQ_EXPORT void - zdir_patch_digest_set (zdir_patch_t *self); - -// Return hash digest for patch file -CZMQ_EXPORT const char * - zdir_patch_digest (zdir_patch_t *self); - -// Self test of this class. -CZMQ_EXPORT void - zdir_patch_test (bool verbose); - -// @end - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zfile.h b/phonelibs/zmq/x64/include/zfile.h deleted file mode 100644 index 75c35774b97fd1..00000000000000 --- a/phonelibs/zmq/x64/include/zfile.h +++ /dev/null @@ -1,177 +0,0 @@ -/* ========================================================================= - zfile - helper functions for working with files. - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZFILE_H_INCLUDED__ -#define __ZFILE_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zfile.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// If file exists, populates properties. CZMQ supports portable symbolic -// links, which are files with the extension ".ln". A symbolic link is a -// text file containing one line, the filename of a target file. Reading -// data from the symbolic link actually reads from the target file. Path -// may be NULL, in which case it is not used. -CZMQ_EXPORT zfile_t * - zfile_new (const char *path, const char *name); - -// Destroy a file item -CZMQ_EXPORT void - zfile_destroy (zfile_t **self_p); - -// Duplicate a file item, returns a newly constructed item. If the file -// is null, or memory was exhausted, returns null. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zfile_t * - zfile_dup (zfile_t *self); - -// Return file name, remove path if provided -CZMQ_EXPORT const char * - zfile_filename (zfile_t *self, const char *path); - -// Refresh file properties from disk; this is not done automatically -// on access methods, otherwise it is not possible to compare directory -// snapshots. -CZMQ_EXPORT void - zfile_restat (zfile_t *self); - -// Return when the file was last modified. If you want this to reflect the -// current situation, call zfile_restat before checking this property. -CZMQ_EXPORT time_t - zfile_modified (zfile_t *self); - -// Return the last-known size of the file. If you want this to reflect the -// current situation, call zfile_restat before checking this property. -CZMQ_EXPORT off_t - zfile_cursize (zfile_t *self); - -// Return true if the file is a directory. If you want this to reflect -// any external changes, call zfile_restat before checking this property. -CZMQ_EXPORT bool - zfile_is_directory (zfile_t *self); - -// Return true if the file is a regular file. If you want this to reflect -// any external changes, call zfile_restat before checking this property. -CZMQ_EXPORT bool - zfile_is_regular (zfile_t *self); - -// Return true if the file is readable by this process. If you want this to -// reflect any external changes, call zfile_restat before checking this -// property. -CZMQ_EXPORT bool - zfile_is_readable (zfile_t *self); - -// Return true if the file is writeable by this process. If you want this -// to reflect any external changes, call zfile_restat before checking this -// property. -CZMQ_EXPORT bool - zfile_is_writeable (zfile_t *self); - -// Check if file has stopped changing and can be safely processed. -// Updates the file statistics from disk at every call. -CZMQ_EXPORT bool - zfile_is_stable (zfile_t *self); - -// Return true if the file was changed on disk since the zfile_t object -// was created, or the last zfile_restat() call made on it. -CZMQ_EXPORT bool - zfile_has_changed (zfile_t *self); - -// Remove the file from disk -CZMQ_EXPORT void - zfile_remove (zfile_t *self); - -// Open file for reading -// Returns 0 if OK, -1 if not found or not accessible -CZMQ_EXPORT int - zfile_input (zfile_t *self); - -// Open file for writing, creating directory if needed -// File is created if necessary; chunks can be written to file at any -// location. Returns 0 if OK, -1 if error. -CZMQ_EXPORT int - zfile_output (zfile_t *self); - -// Read chunk from file at specified position. If this was the last chunk, -// sets the eof property. Returns a null chunk in case of error. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zchunk_t * - zfile_read (zfile_t *self, size_t bytes, off_t offset); - -// Returns true if zfile_read() just read the last chunk in the file. -CZMQ_EXPORT bool - zfile_eof (zfile_t *self); - -// Write chunk to file at specified position -// Return 0 if OK, else -1 -CZMQ_EXPORT int - zfile_write (zfile_t *self, zchunk_t *chunk, off_t offset); - -// Read next line of text from file. Returns a pointer to the text line, -// or NULL if there was nothing more to read from the file. -CZMQ_EXPORT const char * - zfile_readln (zfile_t *self); - -// Close file, if open -CZMQ_EXPORT void - zfile_close (zfile_t *self); - -// Return file handle, if opened -CZMQ_EXPORT FILE * - zfile_handle (zfile_t *self); - -// Calculate SHA1 digest for file, using zdigest class. -CZMQ_EXPORT const char * - zfile_digest (zfile_t *self); - -// Self test of this class. -CZMQ_EXPORT void - zfile_test (bool verbose); - -// @end - - -// @interface -// These methods are deprecated, and now moved to zsys class. -CZMQ_EXPORT bool - zfile_exists (const char *filename); -CZMQ_EXPORT ssize_t - zfile_size (const char *filename); -CZMQ_EXPORT mode_t - zfile_mode (const char *filename); -CZMQ_EXPORT int - zfile_delete (const char *filename); -CZMQ_EXPORT bool - zfile_stable (const char *filename); -CZMQ_EXPORT int - zfile_mkdir (const char *pathname); -CZMQ_EXPORT int - zfile_rmdir (const char *pathname); -CZMQ_EXPORT void - zfile_mode_private (void); -CZMQ_EXPORT void - zfile_mode_default (void); -// @end - -#ifdef __cplusplus -} -#endif - - -#endif // __ZFILE_H_INCLUDED__ diff --git a/phonelibs/zmq/x64/include/zframe.h b/phonelibs/zmq/x64/include/zframe.h deleted file mode 100644 index 728093c36ce117..00000000000000 --- a/phonelibs/zmq/x64/include/zframe.h +++ /dev/null @@ -1,176 +0,0 @@ -/* ========================================================================= - zframe - working with single message frames - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZFRAME_H_INCLUDED__ -#define __ZFRAME_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zframe.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// This class has draft methods, which may change over time. They are not -// in stable releases, by default. Use --enable-drafts to enable. -#define ZFRAME_MORE 1 // -#define ZFRAME_REUSE 2 // -#define ZFRAME_DONTWAIT 4 // - -// Create a new frame. If size is not null, allocates the frame data -// to the specified size. If additionally, data is not null, copies -// size octets from the specified data into the frame body. -CZMQ_EXPORT zframe_t * - zframe_new (const void *data, size_t size); - -// Create an empty (zero-sized) frame -CZMQ_EXPORT zframe_t * - zframe_new_empty (void); - -// Create a frame with a specified string content. -CZMQ_EXPORT zframe_t * - zframe_from (const char *string); - -// Receive frame from socket, returns zframe_t object or NULL if the recv -// was interrupted. Does a blocking recv, if you want to not block then use -// zpoller or zloop. -CZMQ_EXPORT zframe_t * - zframe_recv (void *source); - -// Destroy a frame -CZMQ_EXPORT void - zframe_destroy (zframe_t **self_p); - -// Send a frame to a socket, destroy frame after sending. -// Return -1 on error, 0 on success. -CZMQ_EXPORT int - zframe_send (zframe_t **self_p, void *dest, int flags); - -// Return number of bytes in frame data -CZMQ_EXPORT size_t - zframe_size (zframe_t *self); - -// Return address of frame data -CZMQ_EXPORT byte * - zframe_data (zframe_t *self); - -// Return meta data property for frame -// Caller must free string when finished with it. -CZMQ_EXPORT const char * - zframe_meta (zframe_t *self, const char *property); - -// Create a new frame that duplicates an existing frame. If frame is null, -// or memory was exhausted, returns null. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zframe_t * - zframe_dup (zframe_t *self); - -// Return frame data encoded as printable hex string, useful for 0MQ UUIDs. -// Caller must free string when finished with it. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zframe_strhex (zframe_t *self); - -// Return frame data copied into freshly allocated string -// Caller must free string when finished with it. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zframe_strdup (zframe_t *self); - -// Return TRUE if frame body is equal to string, excluding terminator -CZMQ_EXPORT bool - zframe_streq (zframe_t *self, const char *string); - -// Return frame MORE indicator (1 or 0), set when reading frame from socket -// or by the zframe_set_more() method -CZMQ_EXPORT int - zframe_more (zframe_t *self); - -// Set frame MORE indicator (1 or 0). Note this is NOT used when sending -// frame to socket, you have to specify flag explicitly. -CZMQ_EXPORT void - zframe_set_more (zframe_t *self, int more); - -// Return TRUE if two frames have identical size and data -// If either frame is NULL, equality is always false. -CZMQ_EXPORT bool - zframe_eq (zframe_t *self, zframe_t *other); - -// Set new contents for frame -CZMQ_EXPORT void - zframe_reset (zframe_t *self, const void *data, size_t size); - -// Send message to zsys log sink (may be stdout, or system facility as -// configured by zsys_set_logstream). Prefix shows before frame, if not null. -CZMQ_EXPORT void - zframe_print (zframe_t *self, const char *prefix); - -// Probe the supplied object, and report if it looks like a zframe_t. -CZMQ_EXPORT bool - zframe_is (void *self); - -// Self test of this class. -CZMQ_EXPORT void - zframe_test (bool verbose); - -#ifdef CZMQ_BUILD_DRAFT_API -// *** Draft method, for development use, may change without warning *** -// Return frame routing ID, if the frame came from a ZMQ_SERVER socket. -// Else returns zero. -CZMQ_EXPORT uint32_t - zframe_routing_id (zframe_t *self); - -// *** Draft method, for development use, may change without warning *** -// Set routing ID on frame. This is used if/when the frame is sent to a -// ZMQ_SERVER socket. -CZMQ_EXPORT void - zframe_set_routing_id (zframe_t *self, uint32_t routing_id); - -// *** Draft method, for development use, may change without warning *** -// Return frame group of radio-dish pattern. -CZMQ_EXPORT const char * - zframe_group (zframe_t *self); - -// *** Draft method, for development use, may change without warning *** -// Set group on frame. This is used if/when the frame is sent to a -// ZMQ_RADIO socket. -// Return -1 on error, 0 on success. -CZMQ_EXPORT int - zframe_set_group (zframe_t *self, const char *group); - -#endif // CZMQ_BUILD_DRAFT_API -// @end - - -// DEPRECATED as poor style -- callers should use zloop or zpoller -// Receive a new frame off the socket. Returns newly allocated frame, or -// NULL if there was no input waiting, or if the read was interrupted. -CZMQ_EXPORT zframe_t * - zframe_recv_nowait (void *source); - -// DEPRECATED as inconsistent; breaks principle that logging should all go -// to a single destination. -// Print contents of the frame to FILE stream. -CZMQ_EXPORT void - zframe_fprint (zframe_t *self, const char *prefix, FILE *file); - -// Deprecated method aliases -#define zframe_print_to_stream(s,p,F) zframe_fprint(s,p,F) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zgossip.h b/phonelibs/zmq/x64/include/zgossip.h deleted file mode 100644 index 647cb28c080731..00000000000000 --- a/phonelibs/zmq/x64/include/zgossip.h +++ /dev/null @@ -1,95 +0,0 @@ -/* ========================================================================= - zgossip - zgossip server - - ** WARNING ************************************************************* - THIS SOURCE FILE IS 100% GENERATED. If you edit this file, you will lose - your changes at the next build cycle. This is great for temporary printf - statements. DO NOT MAKE ANY CHANGES YOU WISH TO KEEP. The correct places - for commits are: - - * The XML model used for this code generation: zgossip.xml, or - * The code generation script that built this file: zproto_server_c - ************************************************************************ - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef ZGOSSIP_H_INCLUDED -#define ZGOSSIP_H_INCLUDED - -#include "czmq.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// @interface -// To work with zgossip, use the CZMQ zactor API: -// -// Create new zgossip instance, passing logging prefix: -// -// zactor_t *zgossip = zactor_new (zgossip, "myname"); -// -// Destroy zgossip instance -// -// zactor_destroy (&zgossip); -// -// Enable verbose logging of commands and activity: -// -// zstr_send (zgossip, "VERBOSE"); -// -// Bind zgossip to specified endpoint. TCP endpoints may specify -// the port number as "*" to aquire an ephemeral port: -// -// zstr_sendx (zgossip, "BIND", endpoint, NULL); -// -// Return assigned port number, specifically when BIND was done using an -// an ephemeral port: -// -// zstr_sendx (zgossip, "PORT", NULL); -// char *command, *port_str; -// zstr_recvx (zgossip, &command, &port_str, NULL); -// assert (streq (command, "PORT")); -// -// Specify configuration file to load, overwriting any previous loaded -// configuration file or options: -// -// zstr_sendx (zgossip, "LOAD", filename, NULL); -// -// Set configuration path value: -// -// zstr_sendx (zgossip, "SET", path, value, NULL); -// -// Save configuration data to config file on disk: -// -// zstr_sendx (zgossip, "SAVE", filename, NULL); -// -// Send zmsg_t instance to zgossip: -// -// zactor_send (zgossip, &msg); -// -// Receive zmsg_t instance from zgossip: -// -// zmsg_t *msg = zactor_recv (zgossip); -// -// This is the zgossip constructor as a zactor_fn: -// -CZMQ_EXPORT void - zgossip (zsock_t *pipe, void *args); - -// Self test of this class -CZMQ_EXPORT void - zgossip_test (bool verbose); -// @end - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zhash.h b/phonelibs/zmq/x64/include/zhash.h deleted file mode 100644 index 138adf63ac00e9..00000000000000 --- a/phonelibs/zmq/x64/include/zhash.h +++ /dev/null @@ -1,182 +0,0 @@ -/* ========================================================================= - zhash - generic type-free hash container (simple) - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZHASH_H_INCLUDED__ -#define __ZHASH_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zhash.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// Callback function for zhash_freefn method -typedef void (zhash_free_fn) ( - void *data); - -// Create a new, empty hash container -CZMQ_EXPORT zhash_t * - zhash_new (void); - -// Unpack binary frame into a new hash table. Packed data must follow format -// defined by zhash_pack. Hash table is set to autofree. An empty frame -// unpacks to an empty hash table. -CZMQ_EXPORT zhash_t * - zhash_unpack (zframe_t *frame); - -// Destroy a hash container and all items in it -CZMQ_EXPORT void - zhash_destroy (zhash_t **self_p); - -// Insert item into hash table with specified key and item. -// If key is already present returns -1 and leaves existing item unchanged -// Returns 0 on success. -CZMQ_EXPORT int - zhash_insert (zhash_t *self, const char *key, void *item); - -// Update item into hash table with specified key and item. -// If key is already present, destroys old item and inserts new one. -// Use free_fn method to ensure deallocator is properly called on item. -CZMQ_EXPORT void - zhash_update (zhash_t *self, const char *key, void *item); - -// Remove an item specified by key from the hash table. If there was no such -// item, this function does nothing. -CZMQ_EXPORT void - zhash_delete (zhash_t *self, const char *key); - -// Return the item at the specified key, or null -CZMQ_EXPORT void * - zhash_lookup (zhash_t *self, const char *key); - -// Reindexes an item from an old key to a new key. If there was no such -// item, does nothing. Returns 0 if successful, else -1. -CZMQ_EXPORT int - zhash_rename (zhash_t *self, const char *old_key, const char *new_key); - -// Set a free function for the specified hash table item. When the item is -// destroyed, the free function, if any, is called on that item. -// Use this when hash items are dynamically allocated, to ensure that -// you don't have memory leaks. You can pass 'free' or NULL as a free_fn. -// Returns the item, or NULL if there is no such item. -CZMQ_EXPORT void * - zhash_freefn (zhash_t *self, const char *key, zhash_free_fn free_fn); - -// Return the number of keys/items in the hash table -CZMQ_EXPORT size_t - zhash_size (zhash_t *self); - -// Make copy of hash table; if supplied table is null, returns null. -// Does not copy items themselves. Rebuilds new table so may be slow on -// very large tables. NOTE: only works with item values that are strings -// since there's no other way to know how to duplicate the item value. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zhash_t * - zhash_dup (zhash_t *self); - -// Return keys for items in table -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zlist_t * - zhash_keys (zhash_t *self); - -// Simple iterator; returns first item in hash table, in no given order, -// or NULL if the table is empty. This method is simpler to use than the -// foreach() method, which is deprecated. To access the key for this item -// use zhash_cursor(). NOTE: do NOT modify the table while iterating. -CZMQ_EXPORT void * - zhash_first (zhash_t *self); - -// Simple iterator; returns next item in hash table, in no given order, -// or NULL if the last item was already returned. Use this together with -// zhash_first() to process all items in a hash table. If you need the -// items in sorted order, use zhash_keys() and then zlist_sort(). To -// access the key for this item use zhash_cursor(). NOTE: do NOT modify -// the table while iterating. -CZMQ_EXPORT void * - zhash_next (zhash_t *self); - -// After a successful first/next method, returns the key for the item that -// was returned. This is a constant string that you may not modify or -// deallocate, and which lasts as long as the item in the hash. After an -// unsuccessful first/next, returns NULL. -CZMQ_EXPORT const char * - zhash_cursor (zhash_t *self); - -// Add a comment to hash table before saving to disk. You can add as many -// comment lines as you like. These comment lines are discarded when loading -// the file. If you use a null format, all comments are deleted. -CZMQ_EXPORT void - zhash_comment (zhash_t *self, const char *format, ...) CHECK_PRINTF (2); - -// Serialize hash table to a binary frame that can be sent in a message. -// The packed format is compatible with the 'dictionary' type defined in -// http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: -// -// ; A list of name/value pairs -// dictionary = dict-count *( dict-name dict-value ) -// dict-count = number-4 -// dict-value = longstr -// dict-name = string -// -// ; Strings are always length + text contents -// longstr = number-4 *VCHAR -// string = number-1 *VCHAR -// -// ; Numbers are unsigned integers in network byte order -// number-1 = 1OCTET -// number-4 = 4OCTET -// -// Comments are not included in the packed data. Item values MUST be -// strings. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zframe_t * - zhash_pack (zhash_t *self); - -// Save hash table to a text file in name=value format. Hash values must be -// printable strings; keys may not contain '=' character. Returns 0 if OK, -// else -1 if a file error occurred. -CZMQ_EXPORT int - zhash_save (zhash_t *self, const char *filename); - -// Load hash table from a text file in name=value format; hash table must -// already exist. Hash values must printable strings; keys may not contain -// '=' character. Returns 0 if OK, else -1 if a file was not readable. -CZMQ_EXPORT int - zhash_load (zhash_t *self, const char *filename); - -// When a hash table was loaded from a file by zhash_load, this method will -// reload the file if it has been modified since, and is "stable", i.e. not -// still changing. Returns 0 if OK, -1 if there was an error reloading the -// file. -CZMQ_EXPORT int - zhash_refresh (zhash_t *self); - -// Set hash for automatic value destruction -CZMQ_EXPORT void - zhash_autofree (zhash_t *self); - -// Self test of this class. -CZMQ_EXPORT void - zhash_test (bool verbose); - -// @end - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zhashx.h b/phonelibs/zmq/x64/include/zhashx.h deleted file mode 100644 index 360a773ee88ec1..00000000000000 --- a/phonelibs/zmq/x64/include/zhashx.h +++ /dev/null @@ -1,277 +0,0 @@ -/* ========================================================================= - zhashx - extended generic type-free hash container - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZHASHX_H_INCLUDED__ -#define __ZHASHX_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zhashx.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// This class has draft methods, which may change over time. They are not -// in stable releases, by default. Use --enable-drafts to enable. -// Destroy an item -typedef void (zhashx_destructor_fn) ( - void **item); - -// Duplicate an item -typedef void * (zhashx_duplicator_fn) ( - const void *item); - -// Compare two items, for sorting -typedef int (zhashx_comparator_fn) ( - const void *item1, const void *item2); - -// compare two items, for sorting -typedef void (zhashx_free_fn) ( - void *data); - -// compare two items, for sorting -typedef size_t (zhashx_hash_fn) ( - const void *key); - -// Serializes an item to a longstr. -// The caller takes ownership of the newly created object. -typedef char * (zhashx_serializer_fn) ( - const void *item); - -// Deserializes a longstr into an item. -// The caller takes ownership of the newly created object. -typedef void * (zhashx_deserializer_fn) ( - const char *item_str); - -// Create a new, empty hash container -CZMQ_EXPORT zhashx_t * - zhashx_new (void); - -// Unpack binary frame into a new hash table. Packed data must follow format -// defined by zhashx_pack. Hash table is set to autofree. An empty frame -// unpacks to an empty hash table. -CZMQ_EXPORT zhashx_t * - zhashx_unpack (zframe_t *frame); - -// Destroy a hash container and all items in it -CZMQ_EXPORT void - zhashx_destroy (zhashx_t **self_p); - -// Insert item into hash table with specified key and item. -// If key is already present returns -1 and leaves existing item unchanged -// Returns 0 on success. -CZMQ_EXPORT int - zhashx_insert (zhashx_t *self, const void *key, void *item); - -// Update or insert item into hash table with specified key and item. If the -// key is already present, destroys old item and inserts new one. If you set -// a container item destructor, this is called on the old value. If the key -// was not already present, inserts a new item. Sets the hash cursor to the -// new item. -CZMQ_EXPORT void - zhashx_update (zhashx_t *self, const void *key, void *item); - -// Remove an item specified by key from the hash table. If there was no such -// item, this function does nothing. -CZMQ_EXPORT void - zhashx_delete (zhashx_t *self, const void *key); - -// Delete all items from the hash table. If the key destructor is -// set, calls it on every key. If the item destructor is set, calls -// it on every item. -CZMQ_EXPORT void - zhashx_purge (zhashx_t *self); - -// Return the item at the specified key, or null -CZMQ_EXPORT void * - zhashx_lookup (zhashx_t *self, const void *key); - -// Reindexes an item from an old key to a new key. If there was no such -// item, does nothing. Returns 0 if successful, else -1. -CZMQ_EXPORT int - zhashx_rename (zhashx_t *self, const void *old_key, const void *new_key); - -// Set a free function for the specified hash table item. When the item is -// destroyed, the free function, if any, is called on that item. -// Use this when hash items are dynamically allocated, to ensure that -// you don't have memory leaks. You can pass 'free' or NULL as a free_fn. -// Returns the item, or NULL if there is no such item. -CZMQ_EXPORT void * - zhashx_freefn (zhashx_t *self, const void *key, zhashx_free_fn free_fn); - -// Return the number of keys/items in the hash table -CZMQ_EXPORT size_t - zhashx_size (zhashx_t *self); - -// Return a zlistx_t containing the keys for the items in the -// table. Uses the key_duplicator to duplicate all keys and sets the -// key_destructor as destructor for the list. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zlistx_t * - zhashx_keys (zhashx_t *self); - -// Return a zlistx_t containing the values for the items in the -// table. Uses the duplicator to duplicate all items and sets the -// destructor as destructor for the list. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zlistx_t * - zhashx_values (zhashx_t *self); - -// Simple iterator; returns first item in hash table, in no given order, -// or NULL if the table is empty. This method is simpler to use than the -// foreach() method, which is deprecated. To access the key for this item -// use zhashx_cursor(). NOTE: do NOT modify the table while iterating. -CZMQ_EXPORT void * - zhashx_first (zhashx_t *self); - -// Simple iterator; returns next item in hash table, in no given order, -// or NULL if the last item was already returned. Use this together with -// zhashx_first() to process all items in a hash table. If you need the -// items in sorted order, use zhashx_keys() and then zlistx_sort(). To -// access the key for this item use zhashx_cursor(). NOTE: do NOT modify -// the table while iterating. -CZMQ_EXPORT void * - zhashx_next (zhashx_t *self); - -// After a successful first/next method, returns the key for the item that -// was returned. This is a constant string that you may not modify or -// deallocate, and which lasts as long as the item in the hash. After an -// unsuccessful first/next, returns NULL. -CZMQ_EXPORT const void * - zhashx_cursor (zhashx_t *self); - -// Add a comment to hash table before saving to disk. You can add as many -// comment lines as you like. These comment lines are discarded when loading -// the file. If you use a null format, all comments are deleted. -CZMQ_EXPORT void - zhashx_comment (zhashx_t *self, const char *format, ...) CHECK_PRINTF (2); - -// Save hash table to a text file in name=value format. Hash values must be -// printable strings; keys may not contain '=' character. Returns 0 if OK, -// else -1 if a file error occurred. -CZMQ_EXPORT int - zhashx_save (zhashx_t *self, const char *filename); - -// Load hash table from a text file in name=value format; hash table must -// already exist. Hash values must printable strings; keys may not contain -// '=' character. Returns 0 if OK, else -1 if a file was not readable. -CZMQ_EXPORT int - zhashx_load (zhashx_t *self, const char *filename); - -// When a hash table was loaded from a file by zhashx_load, this method will -// reload the file if it has been modified since, and is "stable", i.e. not -// still changing. Returns 0 if OK, -1 if there was an error reloading the -// file. -CZMQ_EXPORT int - zhashx_refresh (zhashx_t *self); - -// Serialize hash table to a binary frame that can be sent in a message. -// The packed format is compatible with the 'dictionary' type defined in -// http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: -// -// ; A list of name/value pairs -// dictionary = dict-count *( dict-name dict-value ) -// dict-count = number-4 -// dict-value = longstr -// dict-name = string -// -// ; Strings are always length + text contents -// longstr = number-4 *VCHAR -// string = number-1 *VCHAR -// -// ; Numbers are unsigned integers in network byte order -// number-1 = 1OCTET -// number-4 = 4OCTET -// -// Comments are not included in the packed data. Item values MUST be -// strings. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zframe_t * - zhashx_pack (zhashx_t *self); - -// Make a copy of the list; items are duplicated if you set a duplicator -// for the list, otherwise not. Copying a null reference returns a null -// reference. Note that this method's behavior changed slightly for CZMQ -// v3.x, as it does not set nor respect autofree. It does however let you -// duplicate any hash table safely. The old behavior is in zhashx_dup_v2. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zhashx_t * - zhashx_dup (zhashx_t *self); - -// Set a user-defined deallocator for hash items; by default items are not -// freed when the hash is destroyed. -CZMQ_EXPORT void - zhashx_set_destructor (zhashx_t *self, zhashx_destructor_fn destructor); - -// Set a user-defined duplicator for hash items; by default items are not -// copied when the hash is duplicated. -CZMQ_EXPORT void - zhashx_set_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator); - -// Set a user-defined deallocator for keys; by default keys are freed -// when the hash is destroyed using free(). -CZMQ_EXPORT void - zhashx_set_key_destructor (zhashx_t *self, zhashx_destructor_fn destructor); - -// Set a user-defined duplicator for keys; by default keys are duplicated -// using strdup. -CZMQ_EXPORT void - zhashx_set_key_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator); - -// Set a user-defined comparator for keys; by default keys are -// compared using strcmp. -CZMQ_EXPORT void - zhashx_set_key_comparator (zhashx_t *self, zhashx_comparator_fn comparator); - -// Set a user-defined comparator for keys; by default keys are -// compared using strcmp. -CZMQ_EXPORT void - zhashx_set_key_hasher (zhashx_t *self, zhashx_hash_fn hasher); - -// Make copy of hash table; if supplied table is null, returns null. -// Does not copy items themselves. Rebuilds new table so may be slow on -// very large tables. NOTE: only works with item values that are strings -// since there's no other way to know how to duplicate the item value. -CZMQ_EXPORT zhashx_t * - zhashx_dup_v2 (zhashx_t *self); - -// Self test of this class. -CZMQ_EXPORT void - zhashx_test (bool verbose); - -#ifdef CZMQ_BUILD_DRAFT_API -// *** Draft method, for development use, may change without warning *** -// Same as unpack but uses a user-defined deserializer function to convert -// a longstr back into item format. -CZMQ_EXPORT zhashx_t * - zhashx_unpack_own (zframe_t *frame, zhashx_deserializer_fn deserializer); - -// *** Draft method, for development use, may change without warning *** -// Same as pack but uses a user-defined serializer function to convert items -// into longstr. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zframe_t * - zhashx_pack_own (zhashx_t *self, zhashx_serializer_fn serializer); - -#endif // CZMQ_BUILD_DRAFT_API -// @end - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/ziflist.h b/phonelibs/zmq/x64/include/ziflist.h deleted file mode 100644 index cb2b1448025f89..00000000000000 --- a/phonelibs/zmq/x64/include/ziflist.h +++ /dev/null @@ -1,77 +0,0 @@ -/* ========================================================================= - ziflist - List of network interfaces available on system - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZIFLIST_H_INCLUDED__ -#define __ZIFLIST_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/ziflist.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// Get a list of network interfaces currently defined on the system -CZMQ_EXPORT ziflist_t * - ziflist_new (void); - -// Destroy a ziflist instance -CZMQ_EXPORT void - ziflist_destroy (ziflist_t **self_p); - -// Reload network interfaces from system -CZMQ_EXPORT void - ziflist_reload (ziflist_t *self); - -// Return the number of network interfaces on system -CZMQ_EXPORT size_t - ziflist_size (ziflist_t *self); - -// Get first network interface, return NULL if there are none -CZMQ_EXPORT const char * - ziflist_first (ziflist_t *self); - -// Get next network interface, return NULL if we hit the last one -CZMQ_EXPORT const char * - ziflist_next (ziflist_t *self); - -// Return the current interface IP address as a printable string -CZMQ_EXPORT const char * - ziflist_address (ziflist_t *self); - -// Return the current interface broadcast address as a printable string -CZMQ_EXPORT const char * - ziflist_broadcast (ziflist_t *self); - -// Return the current interface network mask as a printable string -CZMQ_EXPORT const char * - ziflist_netmask (ziflist_t *self); - -// Return the list of interfaces. -CZMQ_EXPORT void - ziflist_print (ziflist_t *self); - -// Self test of this class. -CZMQ_EXPORT void - ziflist_test (bool verbose); - -// @end - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zlist.h b/phonelibs/zmq/x64/include/zlist.h deleted file mode 100644 index 1dcd39b9955c9e..00000000000000 --- a/phonelibs/zmq/x64/include/zlist.h +++ /dev/null @@ -1,158 +0,0 @@ -/* ========================================================================= - zlist - simple generic list container - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZLIST_H_INCLUDED__ -#define __ZLIST_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zlist.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// Comparison function e.g. for sorting and removing. -typedef int (zlist_compare_fn) ( - void *item1, void *item2); - -// Callback function for zlist_freefn method -typedef void (zlist_free_fn) ( - void *data); - -// Create a new list container -CZMQ_EXPORT zlist_t * - zlist_new (void); - -// Destroy a list container -CZMQ_EXPORT void - zlist_destroy (zlist_t **self_p); - -// Return the item at the head of list. If the list is empty, returns NULL. -// Leaves cursor pointing at the head item, or NULL if the list is empty. -CZMQ_EXPORT void * - zlist_first (zlist_t *self); - -// Return the next item. If the list is empty, returns NULL. To move to -// the start of the list call zlist_first (). Advances the cursor. -CZMQ_EXPORT void * - zlist_next (zlist_t *self); - -// Return the item at the tail of list. If the list is empty, returns NULL. -// Leaves cursor pointing at the tail item, or NULL if the list is empty. -CZMQ_EXPORT void * - zlist_last (zlist_t *self); - -// Return first item in the list, or null, leaves the cursor -CZMQ_EXPORT void * - zlist_head (zlist_t *self); - -// Return last item in the list, or null, leaves the cursor -CZMQ_EXPORT void * - zlist_tail (zlist_t *self); - -// Return the current item of list. If the list is empty, returns NULL. -// Leaves cursor pointing at the current item, or NULL if the list is empty. -CZMQ_EXPORT void * - zlist_item (zlist_t *self); - -// Append an item to the end of the list, return 0 if OK or -1 if this -// failed for some reason (out of memory). Note that if a duplicator has -// been set, this method will also duplicate the item. -CZMQ_EXPORT int - zlist_append (zlist_t *self, void *item); - -// Push an item to the start of the list, return 0 if OK or -1 if this -// failed for some reason (out of memory). Note that if a duplicator has -// been set, this method will also duplicate the item. -CZMQ_EXPORT int - zlist_push (zlist_t *self, void *item); - -// Pop the item off the start of the list, if any -CZMQ_EXPORT void * - zlist_pop (zlist_t *self); - -// Checks if an item already is present. Uses compare method to determine if -// items are equal. If the compare method is NULL the check will only compare -// pointers. Returns true if item is present else false. -CZMQ_EXPORT bool - zlist_exists (zlist_t *self, void *item); - -// Remove the specified item from the list if present -CZMQ_EXPORT void - zlist_remove (zlist_t *self, void *item); - -// Make a copy of list. If the list has autofree set, the copied list will -// duplicate all items, which must be strings. Otherwise, the list will hold -// pointers back to the items in the original list. If list is null, returns -// NULL. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zlist_t * - zlist_dup (zlist_t *self); - -// Purge all items from list -CZMQ_EXPORT void - zlist_purge (zlist_t *self); - -// Return number of items in the list -CZMQ_EXPORT size_t - zlist_size (zlist_t *self); - -// Sort the list. If the compare function is null, sorts the list by -// ascending key value using a straight ASCII comparison. If you specify -// a compare function, this decides how items are sorted. The sort is not -// stable, so may reorder items with the same keys. The algorithm used is -// combsort, a compromise between performance and simplicity. -CZMQ_EXPORT void - zlist_sort (zlist_t *self, zlist_compare_fn compare); - -// Set list for automatic item destruction; item values MUST be strings. -// By default a list item refers to a value held elsewhere. When you set -// this, each time you append or push a list item, zlist will take a copy -// of the string value. Then, when you destroy the list, it will free all -// item values automatically. If you use any other technique to allocate -// list values, you must free them explicitly before destroying the list. -// The usual technique is to pop list items and destroy them, until the -// list is empty. -CZMQ_EXPORT void - zlist_autofree (zlist_t *self); - -// Sets a compare function for this list. The function compares two items. -// It returns an integer less than, equal to, or greater than zero if the -// first item is found, respectively, to be less than, to match, or be -// greater than the second item. -// This function is used for sorting, removal and exists checking. -CZMQ_EXPORT void - zlist_comparefn (zlist_t *self, zlist_compare_fn fn); - -// Set a free function for the specified list item. When the item is -// destroyed, the free function, if any, is called on that item. -// Use this when list items are dynamically allocated, to ensure that -// you don't have memory leaks. You can pass 'free' or NULL as a free_fn. -// Returns the item, or NULL if there is no such item. -CZMQ_EXPORT void * - zlist_freefn (zlist_t *self, void *item, zlist_free_fn fn, bool at_tail); - -// Self test of this class. -CZMQ_EXPORT void - zlist_test (bool verbose); - -// @end - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zlistx.h b/phonelibs/zmq/x64/include/zlistx.h deleted file mode 100644 index 512637cef3bff5..00000000000000 --- a/phonelibs/zmq/x64/include/zlistx.h +++ /dev/null @@ -1,205 +0,0 @@ -/* ========================================================================= - zlistx - extended generic list container - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZLISTX_H_INCLUDED__ -#define __ZLISTX_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zlistx.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// Destroy an item -typedef void (zlistx_destructor_fn) ( - void **item); - -// Duplicate an item -typedef void * (zlistx_duplicator_fn) ( - const void *item); - -// Compare two items, for sorting -typedef int (zlistx_comparator_fn) ( - const void *item1, const void *item2); - -// Create a new, empty list. -CZMQ_EXPORT zlistx_t * - zlistx_new (void); - -// Destroy a list. If an item destructor was specified, all items in the -// list are automatically destroyed as well. -CZMQ_EXPORT void - zlistx_destroy (zlistx_t **self_p); - -// Add an item to the head of the list. Calls the item duplicator, if any, -// on the item. Resets cursor to list head. Returns an item handle on -// success, NULL if memory was exhausted. -CZMQ_EXPORT void * - zlistx_add_start (zlistx_t *self, void *item); - -// Add an item to the tail of the list. Calls the item duplicator, if any, -// on the item. Resets cursor to list head. Returns an item handle on -// success, NULL if memory was exhausted. -CZMQ_EXPORT void * - zlistx_add_end (zlistx_t *self, void *item); - -// Return the number of items in the list -CZMQ_EXPORT size_t - zlistx_size (zlistx_t *self); - -// Return first item in the list, or null, leaves the cursor -CZMQ_EXPORT void * - zlistx_head (zlistx_t *self); - -// Return last item in the list, or null, leaves the cursor -CZMQ_EXPORT void * - zlistx_tail (zlistx_t *self); - -// Return the item at the head of list. If the list is empty, returns NULL. -// Leaves cursor pointing at the head item, or NULL if the list is empty. -CZMQ_EXPORT void * - zlistx_first (zlistx_t *self); - -// Return the next item. At the end of the list (or in an empty list), -// returns NULL. Use repeated zlistx_next () calls to work through the list -// from zlistx_first (). First time, acts as zlistx_first(). -CZMQ_EXPORT void * - zlistx_next (zlistx_t *self); - -// Return the previous item. At the start of the list (or in an empty list), -// returns NULL. Use repeated zlistx_prev () calls to work through the list -// backwards from zlistx_last (). First time, acts as zlistx_last(). -CZMQ_EXPORT void * - zlistx_prev (zlistx_t *self); - -// Return the item at the tail of list. If the list is empty, returns NULL. -// Leaves cursor pointing at the tail item, or NULL if the list is empty. -CZMQ_EXPORT void * - zlistx_last (zlistx_t *self); - -// Returns the value of the item at the cursor, or NULL if the cursor is -// not pointing to an item. -CZMQ_EXPORT void * - zlistx_item (zlistx_t *self); - -// Returns the handle of the item at the cursor, or NULL if the cursor is -// not pointing to an item. -CZMQ_EXPORT void * - zlistx_cursor (zlistx_t *self); - -// Returns the item associated with the given list handle, or NULL if passed -// in handle is NULL. Asserts that the passed in handle points to a list element. -CZMQ_EXPORT void * - zlistx_handle_item (void *handle); - -// Find an item in the list, searching from the start. Uses the item -// comparator, if any, else compares item values directly. Returns the -// item handle found, or NULL. Sets the cursor to the found item, if any. -CZMQ_EXPORT void * - zlistx_find (zlistx_t *self, void *item); - -// Detach an item from the list, using its handle. The item is not modified, -// and the caller is responsible for destroying it if necessary. If handle is -// null, detaches the first item on the list. Returns item that was detached, -// or null if none was. If cursor was at item, moves cursor to previous item, -// so you can detach items while iterating forwards through a list. -CZMQ_EXPORT void * - zlistx_detach (zlistx_t *self, void *handle); - -// Detach item at the cursor, if any, from the list. The item is not modified, -// and the caller is responsible for destroying it as necessary. Returns item -// that was detached, or null if none was. Moves cursor to previous item, so -// you can detach items while iterating forwards through a list. -CZMQ_EXPORT void * - zlistx_detach_cur (zlistx_t *self); - -// Delete an item, using its handle. Calls the item destructor is any is -// set. If handle is null, deletes the first item on the list. Returns 0 -// if an item was deleted, -1 if not. If cursor was at item, moves cursor -// to previous item, so you can delete items while iterating forwards -// through a list. -CZMQ_EXPORT int - zlistx_delete (zlistx_t *self, void *handle); - -// Move an item to the start of the list, via its handle. -CZMQ_EXPORT void - zlistx_move_start (zlistx_t *self, void *handle); - -// Move an item to the end of the list, via its handle. -CZMQ_EXPORT void - zlistx_move_end (zlistx_t *self, void *handle); - -// Remove all items from the list, and destroy them if the item destructor -// is set. -CZMQ_EXPORT void - zlistx_purge (zlistx_t *self); - -// Sort the list. If an item comparator was set, calls that to compare -// items, otherwise compares on item value. The sort is not stable, so may -// reorder equal items. -CZMQ_EXPORT void - zlistx_sort (zlistx_t *self); - -// Create a new node and insert it into a sorted list. Calls the item -// duplicator, if any, on the item. If low_value is true, starts searching -// from the start of the list, otherwise searches from the end. Use the item -// comparator, if any, to find where to place the new node. Returns a handle -// to the new node, or NULL if memory was exhausted. Resets the cursor to the -// list head. -CZMQ_EXPORT void * - zlistx_insert (zlistx_t *self, void *item, bool low_value); - -// Move an item, specified by handle, into position in a sorted list. Uses -// the item comparator, if any, to determine the new location. If low_value -// is true, starts searching from the start of the list, otherwise searches -// from the end. -CZMQ_EXPORT void - zlistx_reorder (zlistx_t *self, void *handle, bool low_value); - -// Make a copy of the list; items are duplicated if you set a duplicator -// for the list, otherwise not. Copying a null reference returns a null -// reference. -CZMQ_EXPORT zlistx_t * - zlistx_dup (zlistx_t *self); - -// Set a user-defined deallocator for list items; by default items are not -// freed when the list is destroyed. -CZMQ_EXPORT void - zlistx_set_destructor (zlistx_t *self, zlistx_destructor_fn destructor); - -// Set a user-defined duplicator for list items; by default items are not -// copied when the list is duplicated. -CZMQ_EXPORT void - zlistx_set_duplicator (zlistx_t *self, zlistx_duplicator_fn duplicator); - -// Set a user-defined comparator for zlistx_find and zlistx_sort; the method -// must return -1, 0, or 1 depending on whether item1 is less than, equal to, -// or greater than, item2. -CZMQ_EXPORT void - zlistx_set_comparator (zlistx_t *self, zlistx_comparator_fn comparator); - -// Self test of this class. -CZMQ_EXPORT void - zlistx_test (bool verbose); - -// @end - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zloop.h b/phonelibs/zmq/x64/include/zloop.h deleted file mode 100644 index 83f46f282aa2ec..00000000000000 --- a/phonelibs/zmq/x64/include/zloop.h +++ /dev/null @@ -1,163 +0,0 @@ -/* ========================================================================= - zloop - event-driven reactor - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZLOOP_H_INCLUDED__ -#define __ZLOOP_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zloop.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// Callback function for reactor socket activity -typedef int (zloop_reader_fn) ( - zloop_t *loop, zsock_t *reader, void *arg); - -// Callback function for reactor events (low-level) -typedef int (zloop_fn) ( - zloop_t *loop, zmq_pollitem_t *item, void *arg); - -// Callback for reactor timer events -typedef int (zloop_timer_fn) ( - zloop_t *loop, int timer_id, void *arg); - -// Create a new zloop reactor -CZMQ_EXPORT zloop_t * - zloop_new (void); - -// Destroy a reactor -CZMQ_EXPORT void - zloop_destroy (zloop_t **self_p); - -// Register socket reader with the reactor. When the reader has messages, -// the reactor will call the handler, passing the arg. Returns 0 if OK, -1 -// if there was an error. If you register the same socket more than once, -// each instance will invoke its corresponding handler. -CZMQ_EXPORT int - zloop_reader (zloop_t *self, zsock_t *sock, zloop_reader_fn handler, void *arg); - -// Cancel a socket reader from the reactor. If multiple readers exist for -// same socket, cancels ALL of them. -CZMQ_EXPORT void - zloop_reader_end (zloop_t *self, zsock_t *sock); - -// Configure a registered reader to ignore errors. If you do not set this, -// then readers that have errors are removed from the reactor silently. -CZMQ_EXPORT void - zloop_reader_set_tolerant (zloop_t *self, zsock_t *sock); - -// Register low-level libzmq pollitem with the reactor. When the pollitem -// is ready, will call the handler, passing the arg. Returns 0 if OK, -1 -// if there was an error. If you register the pollitem more than once, each -// instance will invoke its corresponding handler. A pollitem with -// socket=NULL and fd=0 means 'poll on FD zero'. -CZMQ_EXPORT int - zloop_poller (zloop_t *self, zmq_pollitem_t *item, zloop_fn handler, void *arg); - -// Cancel a pollitem from the reactor, specified by socket or FD. If both -// are specified, uses only socket. If multiple poll items exist for same -// socket/FD, cancels ALL of them. -CZMQ_EXPORT void - zloop_poller_end (zloop_t *self, zmq_pollitem_t *item); - -// Configure a registered poller to ignore errors. If you do not set this, -// then poller that have errors are removed from the reactor silently. -CZMQ_EXPORT void - zloop_poller_set_tolerant (zloop_t *self, zmq_pollitem_t *item); - -// Register a timer that expires after some delay and repeats some number of -// times. At each expiry, will call the handler, passing the arg. To run a -// timer forever, use 0 times. Returns a timer_id that is used to cancel the -// timer in the future. Returns -1 if there was an error. -CZMQ_EXPORT int - zloop_timer (zloop_t *self, size_t delay, size_t times, zloop_timer_fn handler, void *arg); - -// Cancel a specific timer identified by a specific timer_id (as returned by -// zloop_timer). -CZMQ_EXPORT int - zloop_timer_end (zloop_t *self, int timer_id); - -// Register a ticket timer. Ticket timers are very fast in the case where -// you use a lot of timers (thousands), and frequently remove and add them. -// The main use case is expiry timers for servers that handle many clients, -// and which reset the expiry timer for each message received from a client. -// Whereas normal timers perform poorly as the number of clients grows, the -// cost of ticket timers is constant, no matter the number of clients. You -// must set the ticket delay using zloop_set_ticket_delay before creating a -// ticket. Returns a handle to the timer that you should use in -// zloop_ticket_reset and zloop_ticket_delete. -CZMQ_EXPORT void * - zloop_ticket (zloop_t *self, zloop_timer_fn handler, void *arg); - -// Reset a ticket timer, which moves it to the end of the ticket list and -// resets its execution time. This is a very fast operation. -CZMQ_EXPORT void - zloop_ticket_reset (zloop_t *self, void *handle); - -// Delete a ticket timer. We do not actually delete the ticket here, as -// other code may still refer to the ticket. We mark as deleted, and remove -// later and safely. -CZMQ_EXPORT void - zloop_ticket_delete (zloop_t *self, void *handle); - -// Set the ticket delay, which applies to all tickets. If you lower the -// delay and there are already tickets created, the results are undefined. -CZMQ_EXPORT void - zloop_set_ticket_delay (zloop_t *self, size_t ticket_delay); - -// Set hard limit on number of timers allowed. Setting more than a small -// number of timers (10-100) can have a dramatic impact on the performance -// of the reactor. For high-volume cases, use ticket timers. If the hard -// limit is reached, the reactor stops creating new timers and logs an -// error. -CZMQ_EXPORT void - zloop_set_max_timers (zloop_t *self, size_t max_timers); - -// Set verbose tracing of reactor on/off. The default verbose setting is -// off (false). -CZMQ_EXPORT void - zloop_set_verbose (zloop_t *self, bool verbose); - -// By default the reactor stops if the process receives a SIGINT or SIGTERM -// signal. This makes it impossible to shut-down message based architectures -// like zactors. This method lets you switch off break handling. The default -// nonstop setting is off (false). -CZMQ_EXPORT void - zloop_set_nonstop (zloop_t *self, bool nonstop); - -// Start the reactor. Takes control of the thread and returns when the 0MQ -// context is terminated or the process is interrupted, or any event handler -// returns -1. Event handlers may register new sockets and timers, and -// cancel sockets. Returns 0 if interrupted, -1 if canceled by a handler. -CZMQ_EXPORT int - zloop_start (zloop_t *self); - -// Self test of this class. -CZMQ_EXPORT void - zloop_test (bool verbose); - -// @end - - -// Deprecated method aliases -#define zloop_set_tolerant(s,i) zloop_poller_set_tolerant(s,i) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zmonitor.h b/phonelibs/zmq/x64/include/zmonitor.h deleted file mode 100644 index b490bcb1a0dfbc..00000000000000 --- a/phonelibs/zmq/x64/include/zmonitor.h +++ /dev/null @@ -1,73 +0,0 @@ -/* ========================================================================= - zmonitor - socket event monitor - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZMONITOR_H_INCLUDED__ -#define __ZMONITOR_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @interface -// Create new zmonitor actor instance to monitor a zsock_t socket: -// -// zactor_t *monitor = zactor_new (zmonitor, mysocket); -// -// Destroy zmonitor instance. -// -// zactor_destroy (&monitor); -// -// Enable verbose logging of commands and activity. -// -// zstr_send (monitor, "VERBOSE"); -// -// Listen to monitor event type (zero or types, ending in NULL): -// zstr_sendx (monitor, "LISTEN", type, ..., NULL); -// -// Events: -// CONNECTED -// CONNECT_DELAYED -// CONNECT_RETRIED -// LISTENING -// BIND_FAILED -// ACCEPTED -// ACCEPT_FAILED -// CLOSED -// CLOSE_FAILED -// DISCONNECTED -// MONITOR_STOPPED -// ALL -// -// Start monitor; after this, any further LISTEN commands are ignored. -// -// zstr_send (monitor, "START"); -// zsock_wait (monitor); -// -// Receive next monitor event: -// -// zmsg_t *msg = zmsg_recv (monitor); -// -// This is the zmonitor constructor as a zactor_fn; the argument can be -// a zactor_t, zsock_t, or libzmq void * socket: -CZMQ_EXPORT void - zmonitor (zsock_t *pipe, void *sock); - -// Selftest -CZMQ_EXPORT void - zmonitor_test (bool verbose); -// @end -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zmq.h b/phonelibs/zmq/x64/include/zmq.h deleted file mode 100644 index 21a78eb6576be2..00000000000000 --- a/phonelibs/zmq/x64/include/zmq.h +++ /dev/null @@ -1,643 +0,0 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . - - ************************************************************************* - NOTE to contributors. This file comprises the principal public contract - for ZeroMQ API users. Any change to this file supplied in a stable - release SHOULD not break existing applications. - In practice this means that the value of constants must not change, and - that old values may not be reused for new constants. - ************************************************************************* -*/ - -#ifndef __ZMQ_H_INCLUDED__ -#define __ZMQ_H_INCLUDED__ - -/* Version macros for compile-time API version detection */ -#define ZMQ_VERSION_MAJOR 4 -#define ZMQ_VERSION_MINOR 2 -#define ZMQ_VERSION_PATCH 2 - -#define ZMQ_MAKE_VERSION(major, minor, patch) \ - ((major) * 10000 + (minor) * 100 + (patch)) -#define ZMQ_VERSION \ - ZMQ_MAKE_VERSION(ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR, ZMQ_VERSION_PATCH) - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined _WIN32_WCE -#include -#endif -#include -#include -#if defined _WIN32 -// Set target version to Windows Server 2008, Windows Vista or higher. -// Windows XP (0x0501) is supported but without client & server socket types. -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0600 -#endif - -#ifdef __MINGW32__ -// Require Windows XP or higher with MinGW for getaddrinfo(). -#if(_WIN32_WINNT >= 0x0600) -#else -#undef _WIN32_WINNT -#define _WIN32_WINNT 0x0600 -#endif -#endif -#include -#endif - -/* Handle DSO symbol visibility */ -#if defined _WIN32 -# if defined ZMQ_STATIC -# define ZMQ_EXPORT -# elif defined DLL_EXPORT -# define ZMQ_EXPORT __declspec(dllexport) -# else -# define ZMQ_EXPORT __declspec(dllimport) -# endif -#else -# if defined __SUNPRO_C || defined __SUNPRO_CC -# define ZMQ_EXPORT __global -# elif (defined __GNUC__ && __GNUC__ >= 4) || defined __INTEL_COMPILER -# define ZMQ_EXPORT __attribute__ ((visibility("default"))) -# else -# define ZMQ_EXPORT -# endif -#endif - -/* Define integer types needed for event interface */ -#define ZMQ_DEFINED_STDINT 1 -#if defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_OPENVMS -# include -#elif defined _MSC_VER && _MSC_VER < 1600 -# ifndef int32_t - typedef __int32 int32_t; -# endif -# ifndef uint16_t - typedef unsigned __int16 uint16_t; -# endif -# ifndef uint8_t - typedef unsigned __int8 uint8_t; -# endif -#else -# include -#endif - -// 32-bit AIX's pollfd struct members are called reqevents and rtnevents so it -// defines compatibility macros for them. Need to include that header first to -// stop build failures since zmq_pollset_t defines them as events and revents. -#ifdef ZMQ_HAVE_AIX - #include -#endif - - -/******************************************************************************/ -/* 0MQ errors. */ -/******************************************************************************/ - -/* A number random enough not to collide with different errno ranges on */ -/* different OSes. The assumption is that error_t is at least 32-bit type. */ -#define ZMQ_HAUSNUMERO 156384712 - -/* On Windows platform some of the standard POSIX errnos are not defined. */ -#ifndef ENOTSUP -#define ENOTSUP (ZMQ_HAUSNUMERO + 1) -#endif -#ifndef EPROTONOSUPPORT -#define EPROTONOSUPPORT (ZMQ_HAUSNUMERO + 2) -#endif -#ifndef ENOBUFS -#define ENOBUFS (ZMQ_HAUSNUMERO + 3) -#endif -#ifndef ENETDOWN -#define ENETDOWN (ZMQ_HAUSNUMERO + 4) -#endif -#ifndef EADDRINUSE -#define EADDRINUSE (ZMQ_HAUSNUMERO + 5) -#endif -#ifndef EADDRNOTAVAIL -#define EADDRNOTAVAIL (ZMQ_HAUSNUMERO + 6) -#endif -#ifndef ECONNREFUSED -#define ECONNREFUSED (ZMQ_HAUSNUMERO + 7) -#endif -#ifndef EINPROGRESS -#define EINPROGRESS (ZMQ_HAUSNUMERO + 8) -#endif -#ifndef ENOTSOCK -#define ENOTSOCK (ZMQ_HAUSNUMERO + 9) -#endif -#ifndef EMSGSIZE -#define EMSGSIZE (ZMQ_HAUSNUMERO + 10) -#endif -#ifndef EAFNOSUPPORT -#define EAFNOSUPPORT (ZMQ_HAUSNUMERO + 11) -#endif -#ifndef ENETUNREACH -#define ENETUNREACH (ZMQ_HAUSNUMERO + 12) -#endif -#ifndef ECONNABORTED -#define ECONNABORTED (ZMQ_HAUSNUMERO + 13) -#endif -#ifndef ECONNRESET -#define ECONNRESET (ZMQ_HAUSNUMERO + 14) -#endif -#ifndef ENOTCONN -#define ENOTCONN (ZMQ_HAUSNUMERO + 15) -#endif -#ifndef ETIMEDOUT -#define ETIMEDOUT (ZMQ_HAUSNUMERO + 16) -#endif -#ifndef EHOSTUNREACH -#define EHOSTUNREACH (ZMQ_HAUSNUMERO + 17) -#endif -#ifndef ENETRESET -#define ENETRESET (ZMQ_HAUSNUMERO + 18) -#endif - -/* Native 0MQ error codes. */ -#define EFSM (ZMQ_HAUSNUMERO + 51) -#define ENOCOMPATPROTO (ZMQ_HAUSNUMERO + 52) -#define ETERM (ZMQ_HAUSNUMERO + 53) -#define EMTHREAD (ZMQ_HAUSNUMERO + 54) - -/* This function retrieves the errno as it is known to 0MQ library. The goal */ -/* of this function is to make the code 100% portable, including where 0MQ */ -/* compiled with certain CRT library (on Windows) is linked to an */ -/* application that uses different CRT library. */ -ZMQ_EXPORT int zmq_errno (void); - -/* Resolves system errors and 0MQ errors to human-readable string. */ -ZMQ_EXPORT const char *zmq_strerror (int errnum); - -/* Run-time API version detection */ -ZMQ_EXPORT void zmq_version (int *major, int *minor, int *patch); - -/******************************************************************************/ -/* 0MQ infrastructure (a.k.a. context) initialisation & termination. */ -/******************************************************************************/ - -/* Context options */ -#define ZMQ_IO_THREADS 1 -#define ZMQ_MAX_SOCKETS 2 -#define ZMQ_SOCKET_LIMIT 3 -#define ZMQ_THREAD_PRIORITY 3 -#define ZMQ_THREAD_SCHED_POLICY 4 -#define ZMQ_MAX_MSGSZ 5 - -/* Default for new contexts */ -#define ZMQ_IO_THREADS_DFLT 1 -#define ZMQ_MAX_SOCKETS_DFLT 1023 -#define ZMQ_THREAD_PRIORITY_DFLT -1 -#define ZMQ_THREAD_SCHED_POLICY_DFLT -1 - -ZMQ_EXPORT void *zmq_ctx_new (void); -ZMQ_EXPORT int zmq_ctx_term (void *context); -ZMQ_EXPORT int zmq_ctx_shutdown (void *context); -ZMQ_EXPORT int zmq_ctx_set (void *context, int option, int optval); -ZMQ_EXPORT int zmq_ctx_get (void *context, int option); - -/* Old (legacy) API */ -ZMQ_EXPORT void *zmq_init (int io_threads); -ZMQ_EXPORT int zmq_term (void *context); -ZMQ_EXPORT int zmq_ctx_destroy (void *context); - - -/******************************************************************************/ -/* 0MQ message definition. */ -/******************************************************************************/ - -/* Some architectures, like sparc64 and some variants of aarch64, enforce pointer - * alignment and raise sigbus on violations. Make sure applications allocate - * zmq_msg_t on addresses aligned on a pointer-size boundary to avoid this issue. - */ -typedef struct zmq_msg_t { -#if defined (__GNUC__) || defined ( __INTEL_COMPILER) || \ - (defined (__SUNPRO_C) && __SUNPRO_C >= 0x590) || \ - (defined (__SUNPRO_CC) && __SUNPRO_CC >= 0x590) - unsigned char _ [64] __attribute__ ((aligned (sizeof (void *)))); -#elif defined (_MSC_VER) && (defined (_M_X64) || defined (_M_ARM64)) - __declspec (align (8)) unsigned char _ [64]; -#elif defined (_MSC_VER) && (defined (_M_IX86) || defined (_M_ARM_ARMV7VE)) - __declspec (align (4)) unsigned char _ [64]; -#else - unsigned char _ [64]; -#endif -} zmq_msg_t; - -typedef void (zmq_free_fn) (void *data, void *hint); - -ZMQ_EXPORT int zmq_msg_init (zmq_msg_t *msg); -ZMQ_EXPORT int zmq_msg_init_size (zmq_msg_t *msg, size_t size); -ZMQ_EXPORT int zmq_msg_init_data (zmq_msg_t *msg, void *data, - size_t size, zmq_free_fn *ffn, void *hint); -ZMQ_EXPORT int zmq_msg_send (zmq_msg_t *msg, void *s, int flags); -ZMQ_EXPORT int zmq_msg_recv (zmq_msg_t *msg, void *s, int flags); -ZMQ_EXPORT int zmq_msg_close (zmq_msg_t *msg); -ZMQ_EXPORT int zmq_msg_move (zmq_msg_t *dest, zmq_msg_t *src); -ZMQ_EXPORT int zmq_msg_copy (zmq_msg_t *dest, zmq_msg_t *src); -ZMQ_EXPORT void *zmq_msg_data (zmq_msg_t *msg); -ZMQ_EXPORT size_t zmq_msg_size (zmq_msg_t *msg); -ZMQ_EXPORT int zmq_msg_more (zmq_msg_t *msg); -ZMQ_EXPORT int zmq_msg_get (zmq_msg_t *msg, int property); -ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int property, int optval); -ZMQ_EXPORT const char *zmq_msg_gets (zmq_msg_t *msg, const char *property); - -/******************************************************************************/ -/* 0MQ socket definition. */ -/******************************************************************************/ - -/* Socket types. */ -#define ZMQ_PAIR 0 -#define ZMQ_PUB 1 -#define ZMQ_SUB 2 -#define ZMQ_REQ 3 -#define ZMQ_REP 4 -#define ZMQ_DEALER 5 -#define ZMQ_ROUTER 6 -#define ZMQ_PULL 7 -#define ZMQ_PUSH 8 -#define ZMQ_XPUB 9 -#define ZMQ_XSUB 10 -#define ZMQ_STREAM 11 - -/* Deprecated aliases */ -#define ZMQ_XREQ ZMQ_DEALER -#define ZMQ_XREP ZMQ_ROUTER - -/* Socket options. */ -#define ZMQ_AFFINITY 4 -#define ZMQ_IDENTITY 5 -#define ZMQ_SUBSCRIBE 6 -#define ZMQ_UNSUBSCRIBE 7 -#define ZMQ_RATE 8 -#define ZMQ_RECOVERY_IVL 9 -#define ZMQ_SNDBUF 11 -#define ZMQ_RCVBUF 12 -#define ZMQ_RCVMORE 13 -#define ZMQ_FD 14 -#define ZMQ_EVENTS 15 -#define ZMQ_TYPE 16 -#define ZMQ_LINGER 17 -#define ZMQ_RECONNECT_IVL 18 -#define ZMQ_BACKLOG 19 -#define ZMQ_RECONNECT_IVL_MAX 21 -#define ZMQ_MAXMSGSIZE 22 -#define ZMQ_SNDHWM 23 -#define ZMQ_RCVHWM 24 -#define ZMQ_MULTICAST_HOPS 25 -#define ZMQ_RCVTIMEO 27 -#define ZMQ_SNDTIMEO 28 -#define ZMQ_LAST_ENDPOINT 32 -#define ZMQ_ROUTER_MANDATORY 33 -#define ZMQ_TCP_KEEPALIVE 34 -#define ZMQ_TCP_KEEPALIVE_CNT 35 -#define ZMQ_TCP_KEEPALIVE_IDLE 36 -#define ZMQ_TCP_KEEPALIVE_INTVL 37 -#define ZMQ_IMMEDIATE 39 -#define ZMQ_XPUB_VERBOSE 40 -#define ZMQ_ROUTER_RAW 41 -#define ZMQ_IPV6 42 -#define ZMQ_MECHANISM 43 -#define ZMQ_PLAIN_SERVER 44 -#define ZMQ_PLAIN_USERNAME 45 -#define ZMQ_PLAIN_PASSWORD 46 -#define ZMQ_CURVE_SERVER 47 -#define ZMQ_CURVE_PUBLICKEY 48 -#define ZMQ_CURVE_SECRETKEY 49 -#define ZMQ_CURVE_SERVERKEY 50 -#define ZMQ_PROBE_ROUTER 51 -#define ZMQ_REQ_CORRELATE 52 -#define ZMQ_REQ_RELAXED 53 -#define ZMQ_CONFLATE 54 -#define ZMQ_ZAP_DOMAIN 55 -#define ZMQ_ROUTER_HANDOVER 56 -#define ZMQ_TOS 57 -#define ZMQ_CONNECT_RID 61 -#define ZMQ_GSSAPI_SERVER 62 -#define ZMQ_GSSAPI_PRINCIPAL 63 -#define ZMQ_GSSAPI_SERVICE_PRINCIPAL 64 -#define ZMQ_GSSAPI_PLAINTEXT 65 -#define ZMQ_HANDSHAKE_IVL 66 -#define ZMQ_SOCKS_PROXY 68 -#define ZMQ_XPUB_NODROP 69 -#define ZMQ_BLOCKY 70 -#define ZMQ_XPUB_MANUAL 71 -#define ZMQ_XPUB_WELCOME_MSG 72 -#define ZMQ_STREAM_NOTIFY 73 -#define ZMQ_INVERT_MATCHING 74 -#define ZMQ_HEARTBEAT_IVL 75 -#define ZMQ_HEARTBEAT_TTL 76 -#define ZMQ_HEARTBEAT_TIMEOUT 77 -#define ZMQ_XPUB_VERBOSER 78 -#define ZMQ_CONNECT_TIMEOUT 79 -#define ZMQ_TCP_MAXRT 80 -#define ZMQ_THREAD_SAFE 81 -#define ZMQ_MULTICAST_MAXTPDU 84 -#define ZMQ_VMCI_BUFFER_SIZE 85 -#define ZMQ_VMCI_BUFFER_MIN_SIZE 86 -#define ZMQ_VMCI_BUFFER_MAX_SIZE 87 -#define ZMQ_VMCI_CONNECT_TIMEOUT 88 -#define ZMQ_USE_FD 89 - -/* Message options */ -#define ZMQ_MORE 1 -#define ZMQ_SHARED 3 - -/* Send/recv options. */ -#define ZMQ_DONTWAIT 1 -#define ZMQ_SNDMORE 2 - -/* Security mechanisms */ -#define ZMQ_NULL 0 -#define ZMQ_PLAIN 1 -#define ZMQ_CURVE 2 -#define ZMQ_GSSAPI 3 - -/* RADIO-DISH protocol */ -#define ZMQ_GROUP_MAX_LENGTH 15 - -/* Deprecated options and aliases */ -#define ZMQ_TCP_ACCEPT_FILTER 38 -#define ZMQ_IPC_FILTER_PID 58 -#define ZMQ_IPC_FILTER_UID 59 -#define ZMQ_IPC_FILTER_GID 60 -#define ZMQ_IPV4ONLY 31 -#define ZMQ_DELAY_ATTACH_ON_CONNECT ZMQ_IMMEDIATE -#define ZMQ_NOBLOCK ZMQ_DONTWAIT -#define ZMQ_FAIL_UNROUTABLE ZMQ_ROUTER_MANDATORY -#define ZMQ_ROUTER_BEHAVIOR ZMQ_ROUTER_MANDATORY - -/* Deprecated Message options */ -#define ZMQ_SRCFD 2 - -/******************************************************************************/ -/* 0MQ socket events and monitoring */ -/******************************************************************************/ - -/* Socket transport events (TCP, IPC and TIPC only) */ - -#define ZMQ_EVENT_CONNECTED 0x0001 -#define ZMQ_EVENT_CONNECT_DELAYED 0x0002 -#define ZMQ_EVENT_CONNECT_RETRIED 0x0004 -#define ZMQ_EVENT_LISTENING 0x0008 -#define ZMQ_EVENT_BIND_FAILED 0x0010 -#define ZMQ_EVENT_ACCEPTED 0x0020 -#define ZMQ_EVENT_ACCEPT_FAILED 0x0040 -#define ZMQ_EVENT_CLOSED 0x0080 -#define ZMQ_EVENT_CLOSE_FAILED 0x0100 -#define ZMQ_EVENT_DISCONNECTED 0x0200 -#define ZMQ_EVENT_MONITOR_STOPPED 0x0400 -#define ZMQ_EVENT_ALL 0xFFFF - -ZMQ_EXPORT void *zmq_socket (void *, int type); -ZMQ_EXPORT int zmq_close (void *s); -ZMQ_EXPORT int zmq_setsockopt (void *s, int option, const void *optval, - size_t optvallen); -ZMQ_EXPORT int zmq_getsockopt (void *s, int option, void *optval, - size_t *optvallen); -ZMQ_EXPORT int zmq_bind (void *s, const char *addr); -ZMQ_EXPORT int zmq_connect (void *s, const char *addr); -ZMQ_EXPORT int zmq_unbind (void *s, const char *addr); -ZMQ_EXPORT int zmq_disconnect (void *s, const char *addr); -ZMQ_EXPORT int zmq_send (void *s, const void *buf, size_t len, int flags); -ZMQ_EXPORT int zmq_send_const (void *s, const void *buf, size_t len, int flags); -ZMQ_EXPORT int zmq_recv (void *s, void *buf, size_t len, int flags); -ZMQ_EXPORT int zmq_socket_monitor (void *s, const char *addr, int events); - - -/******************************************************************************/ -/* I/O multiplexing. */ -/******************************************************************************/ - -#define ZMQ_POLLIN 1 -#define ZMQ_POLLOUT 2 -#define ZMQ_POLLERR 4 -#define ZMQ_POLLPRI 8 - -typedef struct zmq_pollitem_t -{ - void *socket; -#if defined _WIN32 - SOCKET fd; -#else - int fd; -#endif - short events; - short revents; -} zmq_pollitem_t; - -#define ZMQ_POLLITEMS_DFLT 16 - -ZMQ_EXPORT int zmq_poll (zmq_pollitem_t *items, int nitems, long timeout); - -/******************************************************************************/ -/* Message proxying */ -/******************************************************************************/ - -ZMQ_EXPORT int zmq_proxy (void *frontend, void *backend, void *capture); -ZMQ_EXPORT int zmq_proxy_steerable (void *frontend, void *backend, void *capture, void *control); - -/******************************************************************************/ -/* Probe library capabilities */ -/******************************************************************************/ - -#define ZMQ_HAS_CAPABILITIES 1 -ZMQ_EXPORT int zmq_has (const char *capability); - -/* Deprecated aliases */ -#define ZMQ_STREAMER 1 -#define ZMQ_FORWARDER 2 -#define ZMQ_QUEUE 3 - -/* Deprecated methods */ -ZMQ_EXPORT int zmq_device (int type, void *frontend, void *backend); -ZMQ_EXPORT int zmq_sendmsg (void *s, zmq_msg_t *msg, int flags); -ZMQ_EXPORT int zmq_recvmsg (void *s, zmq_msg_t *msg, int flags); -struct iovec; -ZMQ_EXPORT int zmq_sendiov (void *s, struct iovec *iov, size_t count, int flags); -ZMQ_EXPORT int zmq_recviov (void *s, struct iovec *iov, size_t *count, int flags); - -/******************************************************************************/ -/* Encryption functions */ -/******************************************************************************/ - -/* Encode data with Z85 encoding. Returns encoded data */ -ZMQ_EXPORT char *zmq_z85_encode (char *dest, const uint8_t *data, size_t size); - -/* Decode data with Z85 encoding. Returns decoded data */ -ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest, const char *string); - -/* Generate z85-encoded public and private keypair with tweetnacl/libsodium. */ -/* Returns 0 on success. */ -ZMQ_EXPORT int zmq_curve_keypair (char *z85_public_key, char *z85_secret_key); - -/* Derive the z85-encoded public key from the z85-encoded secret key. */ -/* Returns 0 on success. */ -ZMQ_EXPORT int zmq_curve_public (char *z85_public_key, const char *z85_secret_key); - -/******************************************************************************/ -/* Atomic utility methods */ -/******************************************************************************/ - -ZMQ_EXPORT void *zmq_atomic_counter_new (void); -ZMQ_EXPORT void zmq_atomic_counter_set (void *counter, int value); -ZMQ_EXPORT int zmq_atomic_counter_inc (void *counter); -ZMQ_EXPORT int zmq_atomic_counter_dec (void *counter); -ZMQ_EXPORT int zmq_atomic_counter_value (void *counter); -ZMQ_EXPORT void zmq_atomic_counter_destroy (void **counter_p); - - -/******************************************************************************/ -/* These functions are not documented by man pages -- use at your own risk. */ -/* If you need these to be part of the formal ZMQ API, then (a) write a man */ -/* page, and (b) write a test case in tests. */ -/******************************************************************************/ - -/* Helper functions are used by perf tests so that they don't have to care */ -/* about minutiae of time-related functions on different OS platforms. */ - -/* Starts the stopwatch. Returns the handle to the watch. */ -ZMQ_EXPORT void *zmq_stopwatch_start (void); - -/* Stops the stopwatch. Returns the number of microseconds elapsed since */ -/* the stopwatch was started. */ -ZMQ_EXPORT unsigned long zmq_stopwatch_stop (void *watch_); - -/* Sleeps for specified number of seconds. */ -ZMQ_EXPORT void zmq_sleep (int seconds_); - -typedef void (zmq_thread_fn) (void*); - -/* Start a thread. Returns a handle to the thread. */ -ZMQ_EXPORT void *zmq_threadstart (zmq_thread_fn* func, void* arg); - -/* Wait for thread to complete then free up resources. */ -ZMQ_EXPORT void zmq_threadclose (void* thread); - - -/******************************************************************************/ -/* These functions are DRAFT and disabled in stable releases, and subject to */ -/* change at ANY time until declared stable. */ -/******************************************************************************/ - -#ifdef ZMQ_BUILD_DRAFT_API - -/* DRAFT Socket types. */ -#define ZMQ_SERVER 12 -#define ZMQ_CLIENT 13 -#define ZMQ_RADIO 14 -#define ZMQ_DISH 15 -#define ZMQ_GATHER 16 -#define ZMQ_SCATTER 17 -#define ZMQ_DGRAM 18 - -/* DRAFT 0MQ socket events and monitoring */ -#define ZMQ_EVENT_HANDSHAKE_FAILED 0x0800 -#define ZMQ_EVENT_HANDSHAKE_SUCCEED 0x1000 - -/* DRAFT Context options */ -#define ZMQ_MSG_T_SIZE 6 - -/* DRAFT Socket methods. */ -ZMQ_EXPORT int zmq_join (void *s, const char *group); -ZMQ_EXPORT int zmq_leave (void *s, const char *group); - -/* DRAFT Msg methods. */ -ZMQ_EXPORT int zmq_msg_set_routing_id(zmq_msg_t *msg, uint32_t routing_id); -ZMQ_EXPORT uint32_t zmq_msg_routing_id(zmq_msg_t *msg); -ZMQ_EXPORT int zmq_msg_set_group(zmq_msg_t *msg, const char *group); -ZMQ_EXPORT const char *zmq_msg_group(zmq_msg_t *msg); - -/******************************************************************************/ -/* Poller polling on sockets,fd and thread-safe sockets */ -/******************************************************************************/ - -#define ZMQ_HAVE_POLLER - -typedef struct zmq_poller_event_t -{ - void *socket; -#if defined _WIN32 - SOCKET fd; -#else - int fd; -#endif - void *user_data; - short events; -} zmq_poller_event_t; - -ZMQ_EXPORT void *zmq_poller_new (void); -ZMQ_EXPORT int zmq_poller_destroy (void **poller_p); -ZMQ_EXPORT int zmq_poller_add (void *poller, void *socket, void *user_data, short events); -ZMQ_EXPORT int zmq_poller_modify (void *poller, void *socket, short events); -ZMQ_EXPORT int zmq_poller_remove (void *poller, void *socket); -ZMQ_EXPORT int zmq_poller_wait (void *poller, zmq_poller_event_t *event, long timeout); -ZMQ_EXPORT int zmq_poller_wait_all (void *poller, zmq_poller_event_t *events, int n_events, long timeout); - -#if defined _WIN32 -ZMQ_EXPORT int zmq_poller_add_fd (void *poller, SOCKET fd, void *user_data, short events); -ZMQ_EXPORT int zmq_poller_modify_fd (void *poller, SOCKET fd, short events); -ZMQ_EXPORT int zmq_poller_remove_fd (void *poller, SOCKET fd); -#else -ZMQ_EXPORT int zmq_poller_add_fd (void *poller, int fd, void *user_data, short events); -ZMQ_EXPORT int zmq_poller_modify_fd (void *poller, int fd, short events); -ZMQ_EXPORT int zmq_poller_remove_fd (void *poller, int fd); -#endif - -/******************************************************************************/ -/* Scheduling timers */ -/******************************************************************************/ - -#define ZMQ_HAVE_TIMERS - -typedef void (zmq_timer_fn)(int timer_id, void *arg); - -ZMQ_EXPORT void *zmq_timers_new (void); -ZMQ_EXPORT int zmq_timers_destroy (void **timers_p); -ZMQ_EXPORT int zmq_timers_add (void *timers, size_t interval, zmq_timer_fn handler, void *arg); -ZMQ_EXPORT int zmq_timers_cancel (void *timers, int timer_id); -ZMQ_EXPORT int zmq_timers_set_interval (void *timers, int timer_id, size_t interval); -ZMQ_EXPORT int zmq_timers_reset (void *timers, int timer_id); -ZMQ_EXPORT long zmq_timers_timeout (void *timers); -ZMQ_EXPORT int zmq_timers_execute (void *timers); - -#endif // ZMQ_BUILD_DRAFT_API - - -#undef ZMQ_EXPORT - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zmq_utils.h b/phonelibs/zmq/x64/include/zmq_utils.h deleted file mode 100644 index f29638d5539414..00000000000000 --- a/phonelibs/zmq/x64/include/zmq_utils.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ - -/* This file is deprecated, and all its functionality provided by zmq.h */ -/* Note that -Wpedantic compilation requires GCC to avoid using its custom - extensions such as #warning, hence the trick below. Also, pragmas for - warnings or other messages are not standard, not portable, and not all - compilers even have an equivalent concept. - So in the worst case, this include file is treated as silently empty. */ - -#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) || defined(_MSC_VER) -#if defined(__GNUC__) || defined(__GNUG__) -#pragma GCC diagnostic push -#pragma GCC diagnostic warning "-Wcpp" -#pragma GCC diagnostic ignored "-Werror" -#pragma GCC diagnostic ignored "-Wall" -#endif -#pragma message("Warning: zmq_utils.h is deprecated. All its functionality is provided by zmq.h.") -#if defined(__GNUC__) || defined(__GNUG__) -#pragma GCC diagnostic pop -#endif -#endif diff --git a/phonelibs/zmq/x64/include/zmsg.h b/phonelibs/zmq/x64/include/zmsg.h deleted file mode 100644 index d8a84d1f4198ed..00000000000000 --- a/phonelibs/zmq/x64/include/zmsg.h +++ /dev/null @@ -1,280 +0,0 @@ -/* ========================================================================= - zmsg - working with multipart messages - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZMSG_H_INCLUDED__ -#define __ZMSG_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zmsg.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// This class has draft methods, which may change over time. They are not -// in stable releases, by default. Use --enable-drafts to enable. -// Create a new empty message object -CZMQ_EXPORT zmsg_t * - zmsg_new (void); - -// Receive message from socket, returns zmsg_t object or NULL if the recv -// was interrupted. Does a blocking recv. If you want to not block then use -// the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input -// before receiving. -CZMQ_EXPORT zmsg_t * - zmsg_recv (void *source); - -// Load/append an open file into new message, return the message. -// Returns NULL if the message could not be loaded. -CZMQ_EXPORT zmsg_t * - zmsg_load (FILE *file); - -// Decodes a serialized message frame created by zmsg_encode () and returns -// a new zmsg_t object. Returns NULL if the frame was badly formatted or -// there was insufficient memory to work. -CZMQ_EXPORT zmsg_t * - zmsg_decode (zframe_t *frame); - -// Generate a signal message encoding the given status. A signal is a short -// message carrying a 1-byte success/failure code (by convention, 0 means -// OK). Signals are encoded to be distinguishable from "normal" messages. -CZMQ_EXPORT zmsg_t * - zmsg_new_signal (byte status); - -// Destroy a message object and all frames it contains -CZMQ_EXPORT void - zmsg_destroy (zmsg_t **self_p); - -// Send message to destination socket, and destroy the message after sending -// it successfully. If the message has no frames, sends nothing but destroys -// the message anyhow. Nullifies the caller's reference to the message (as -// it is a destructor). -CZMQ_EXPORT int - zmsg_send (zmsg_t **self_p, void *dest); - -// Send message to destination socket as part of a multipart sequence, and -// destroy the message after sending it successfully. Note that after a -// zmsg_sendm, you must call zmsg_send or another method that sends a final -// message part. If the message has no frames, sends nothing but destroys -// the message anyhow. Nullifies the caller's reference to the message (as -// it is a destructor). -CZMQ_EXPORT int - zmsg_sendm (zmsg_t **self_p, void *dest); - -// Return size of message, i.e. number of frames (0 or more). -CZMQ_EXPORT size_t - zmsg_size (zmsg_t *self); - -// Return total size of all frames in message. -CZMQ_EXPORT size_t - zmsg_content_size (zmsg_t *self); - -// Push frame to the front of the message, i.e. before all other frames. -// Message takes ownership of frame, will destroy it when message is sent. -// Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not -// nullify the caller's frame reference. -CZMQ_EXPORT int - zmsg_prepend (zmsg_t *self, zframe_t **frame_p); - -// Add frame to the end of the message, i.e. after all other frames. -// Message takes ownership of frame, will destroy it when message is sent. -// Returns 0 on success. Deprecates zmsg_add, which did not nullify the -// caller's frame reference. -CZMQ_EXPORT int - zmsg_append (zmsg_t *self, zframe_t **frame_p); - -// Remove first frame from message, if any. Returns frame, or NULL. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zframe_t * - zmsg_pop (zmsg_t *self); - -// Push block of memory to front of message, as a new frame. -// Returns 0 on success, -1 on error. -CZMQ_EXPORT int - zmsg_pushmem (zmsg_t *self, const void *data, size_t size); - -// Add block of memory to the end of the message, as a new frame. -// Returns 0 on success, -1 on error. -CZMQ_EXPORT int - zmsg_addmem (zmsg_t *self, const void *data, size_t size); - -// Push string as new frame to front of message. -// Returns 0 on success, -1 on error. -CZMQ_EXPORT int - zmsg_pushstr (zmsg_t *self, const char *string); - -// Push string as new frame to end of message. -// Returns 0 on success, -1 on error. -CZMQ_EXPORT int - zmsg_addstr (zmsg_t *self, const char *string); - -// Push formatted string as new frame to front of message. -// Returns 0 on success, -1 on error. -CZMQ_EXPORT int - zmsg_pushstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2); - -// Push formatted string as new frame to end of message. -// Returns 0 on success, -1 on error. -CZMQ_EXPORT int - zmsg_addstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2); - -// Pop frame off front of message, return as fresh string. If there were -// no more frames in the message, returns NULL. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zmsg_popstr (zmsg_t *self); - -// Push encoded message as a new frame. Message takes ownership of -// submessage, so the original is destroyed in this call. Returns 0 on -// success, -1 on error. -CZMQ_EXPORT int - zmsg_addmsg (zmsg_t *self, zmsg_t **msg_p); - -// Remove first submessage from message, if any. Returns zmsg_t, or NULL if -// decoding was not successful. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zmsg_t * - zmsg_popmsg (zmsg_t *self); - -// Remove specified frame from list, if present. Does not destroy frame. -CZMQ_EXPORT void - zmsg_remove (zmsg_t *self, zframe_t *frame); - -// Set cursor to first frame in message. Returns frame, or NULL, if the -// message is empty. Use this to navigate the frames as a list. -CZMQ_EXPORT zframe_t * - zmsg_first (zmsg_t *self); - -// Return the next frame. If there are no more frames, returns NULL. To move -// to the first frame call zmsg_first(). Advances the cursor. -CZMQ_EXPORT zframe_t * - zmsg_next (zmsg_t *self); - -// Return the last frame. If there are no frames, returns NULL. -CZMQ_EXPORT zframe_t * - zmsg_last (zmsg_t *self); - -// Save message to an open file, return 0 if OK, else -1. The message is -// saved as a series of frames, each with length and data. Note that the -// file is NOT guaranteed to be portable between operating systems, not -// versions of CZMQ. The file format is at present undocumented and liable -// to arbitrary change. -CZMQ_EXPORT int - zmsg_save (zmsg_t *self, FILE *file); - -// Serialize multipart message to a single message frame. Use this method -// to send structured messages across transports that do not support -// multipart data. Allocates and returns a new frame containing the -// serialized message. To decode a serialized message frame, use -// zmsg_decode (). -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zframe_t * - zmsg_encode (zmsg_t *self); - -// Create copy of message, as new message object. Returns a fresh zmsg_t -// object. If message is null, or memory was exhausted, returns null. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT zmsg_t * - zmsg_dup (zmsg_t *self); - -// Send message to zsys log sink (may be stdout, or system facility as -// configured by zsys_set_logstream). -CZMQ_EXPORT void - zmsg_print (zmsg_t *self); - -// Return true if the two messages have the same number of frames and each -// frame in the first message is identical to the corresponding frame in the -// other message. As with zframe_eq, return false if either message is NULL. -CZMQ_EXPORT bool - zmsg_eq (zmsg_t *self, zmsg_t *other); - -// Return signal value, 0 or greater, if message is a signal, -1 if not. -CZMQ_EXPORT int - zmsg_signal (zmsg_t *self); - -// Probe the supplied object, and report if it looks like a zmsg_t. -CZMQ_EXPORT bool - zmsg_is (void *self); - -// Self test of this class. -CZMQ_EXPORT void - zmsg_test (bool verbose); - -#ifdef CZMQ_BUILD_DRAFT_API -// *** Draft method, for development use, may change without warning *** -// Return message routing ID, if the message came from a ZMQ_SERVER socket. -// Else returns zero. -CZMQ_EXPORT uint32_t - zmsg_routing_id (zmsg_t *self); - -// *** Draft method, for development use, may change without warning *** -// Set routing ID on message. This is used if/when the message is sent to a -// ZMQ_SERVER socket. -CZMQ_EXPORT void - zmsg_set_routing_id (zmsg_t *self, uint32_t routing_id); - -#endif // CZMQ_BUILD_DRAFT_API -// @end - - -// DEPRECATED as over-engineered, poor style -// Pop frame off front of message, caller now owns frame -// If next frame is empty, pops and destroys that empty frame. -CZMQ_EXPORT zframe_t * - zmsg_unwrap (zmsg_t *self); - -// DEPRECATED as poor style -- callers should use zloop or zpoller -// Receive message from socket, returns zmsg_t object, or NULL either if -// there was no input waiting, or the recv was interrupted. -CZMQ_EXPORT zmsg_t * - zmsg_recv_nowait (void *source); - -// DEPRECATED as unsafe -- does not nullify frame reference. -// Push frame plus empty frame to front of message, before first frame. -// Message takes ownership of frame, will destroy it when message is sent. -CZMQ_EXPORT void - zmsg_wrap (zmsg_t *self, zframe_t *frame); - -// DEPRECATED - will be removed for next + 1 stable release -// Add frame to the front of the message, i.e. before all other frames. -// Message takes ownership of frame, will destroy it when message is sent. -// Returns 0 on success, -1 on error. -CZMQ_EXPORT int - zmsg_push (zmsg_t *self, zframe_t *frame); - -// DEPRECATED - will be removed for next stable release -CZMQ_EXPORT int - zmsg_add (zmsg_t *self, zframe_t *frame); - -// DEPRECATED as inconsistent; breaks principle that logging should all go -// to a single destination. -// Print message to open stream -// Truncates to first 10 frames, for readability. -CZMQ_EXPORT void - zmsg_fprint (zmsg_t *self, FILE *file); - -// Compiler hints -CZMQ_EXPORT int zmsg_addstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2); -CZMQ_EXPORT int zmsg_pushstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2); - -#ifdef __cplusplus -} -#endif - -// Deprecated method aliases -#define zmsg_dump(s) zmsg_print(s) -#define zmsg_dump_to_stream(s,F) zmsg_fprint(s,F) - -#endif diff --git a/phonelibs/zmq/x64/include/zpoller.h b/phonelibs/zmq/x64/include/zpoller.h deleted file mode 100644 index 3b394c35161840..00000000000000 --- a/phonelibs/zmq/x64/include/zpoller.h +++ /dev/null @@ -1,87 +0,0 @@ -/* ========================================================================= - zpoller - trivial socket poller class - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __zpoller_H_INCLUDED__ -#define __zpoller_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zpoller.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// Create new poller, specifying zero or more readers. The list of -// readers ends in a NULL. Each reader can be a zsock_t instance, a -// zactor_t instance, a libzmq socket (void *), or a file handle. -CZMQ_EXPORT zpoller_t * - zpoller_new (void *reader, ...); - -// Destroy a poller -CZMQ_EXPORT void - zpoller_destroy (zpoller_t **self_p); - -// Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may -// be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. -CZMQ_EXPORT int - zpoller_add (zpoller_t *self, void *reader); - -// Remove a reader from the poller; returns 0 if OK, -1 on failure. The reader -// must have been passed during construction, or in an zpoller_add () call. -CZMQ_EXPORT int - zpoller_remove (zpoller_t *self, void *reader); - -// By default the poller stops if the process receives a SIGINT or SIGTERM -// signal. This makes it impossible to shut-down message based architectures -// like zactors. This method lets you switch off break handling. The default -// nonstop setting is off (false). -CZMQ_EXPORT void - zpoller_set_nonstop (zpoller_t *self, bool nonstop); - -// Poll the registered readers for I/O, return first reader that has input. -// The reader will be a libzmq void * socket, or a zsock_t or zactor_t -// instance as specified in zpoller_new/zpoller_add. The timeout should be -// zero or greater, or -1 to wait indefinitely. Socket priority is defined -// by their order in the poll list. If you need a balanced poll, use the low -// level zmq_poll method directly. If the poll call was interrupted (SIGINT), -// or the ZMQ context was destroyed, or the timeout expired, returns NULL. -// You can test the actual exit condition by calling zpoller_expired () and -// zpoller_terminated (). The timeout is in msec. -CZMQ_EXPORT void * - zpoller_wait (zpoller_t *self, int timeout); - -// Return true if the last zpoller_wait () call ended because the timeout -// expired, without any error. -CZMQ_EXPORT bool - zpoller_expired (zpoller_t *self); - -// Return true if the last zpoller_wait () call ended because the process -// was interrupted, or the parent context was destroyed. -CZMQ_EXPORT bool - zpoller_terminated (zpoller_t *self); - -// Self test of this class. -CZMQ_EXPORT void - zpoller_test (bool verbose); - -// @end - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/phonelibs/zmq/x64/include/zproc.h b/phonelibs/zmq/x64/include/zproc.h deleted file mode 100644 index 4fd3fcf445c55f..00000000000000 --- a/phonelibs/zmq/x64/include/zproc.h +++ /dev/null @@ -1,168 +0,0 @@ -/* ========================================================================= - zproc - process configuration and status - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef ZPROC_H_INCLUDED -#define ZPROC_H_INCLUDED - -#ifdef __cplusplus -extern "C" { -#endif - - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zproc.api" to make changes. -// @interface -// This is a draft class, and may change without notice. It is disabled in -// stable builds by default. If you use this in applications, please ask -// for it to be pushed to stable state. Use --enable-drafts to enable. -#ifdef CZMQ_BUILD_DRAFT_API -// *** Draft method, for development use, may change without warning *** -// Returns CZMQ version as a single 6-digit integer encoding the major -// version (x 10000), the minor version (x 100) and the patch. -CZMQ_EXPORT int - zproc_czmq_version (void); - -// *** Draft method, for development use, may change without warning *** -// Returns true if the process received a SIGINT or SIGTERM signal. -// It is good practice to use this method to exit any infinite loop -// processing messages. -CZMQ_EXPORT bool - zproc_interrupted (void); - -// *** Draft method, for development use, may change without warning *** -// Returns true if the underlying libzmq supports CURVE security. -CZMQ_EXPORT bool - zproc_has_curve (void); - -// *** Draft method, for development use, may change without warning *** -// Return current host name, for use in public tcp:// endpoints. -// If the host name is not resolvable, returns NULL. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zproc_hostname (void); - -// *** Draft method, for development use, may change without warning *** -// Move the current process into the background. The precise effect -// depends on the operating system. On POSIX boxes, moves to a specified -// working directory (if specified), closes all file handles, reopens -// stdin, stdout, and stderr to the null device, and sets the process to -// ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there -// was an error. -CZMQ_EXPORT void - zproc_daemonize (const char *workdir); - -// *** Draft method, for development use, may change without warning *** -// Drop the process ID into the lockfile, with exclusive lock, and -// switch the process to the specified group and/or user. Any of the -// arguments may be null, indicating a no-op. Returns 0 on success, -// -1 on failure. Note if you combine this with zsys_daemonize, run -// after, not before that method, or the lockfile will hold the wrong -// process ID. -CZMQ_EXPORT void - zproc_run_as (const char *lockfile, const char *group, const char *user); - -// *** Draft method, for development use, may change without warning *** -// Configure the number of I/O threads that ZeroMQ will use. A good -// rule of thumb is one thread per gigabit of traffic in or out. The -// default is 1, sufficient for most applications. If the environment -// variable ZSYS_IO_THREADS is defined, that provides the default. -// Note that this method is valid only before any socket is created. -CZMQ_EXPORT void - zproc_set_io_threads (size_t io_threads); - -// *** Draft method, for development use, may change without warning *** -// Configure the number of sockets that ZeroMQ will allow. The default -// is 1024. The actual limit depends on the system, and you can query it -// by using zsys_socket_limit (). A value of zero means "maximum". -// Note that this method is valid only before any socket is created. -CZMQ_EXPORT void - zproc_set_max_sockets (size_t max_sockets); - -// *** Draft method, for development use, may change without warning *** -// Set network interface name to use for broadcasts, particularly zbeacon. -// This lets the interface be configured for test environments where required. -// For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is -// the default when there is no specified interface. If the environment -// variable ZSYS_INTERFACE is set, use that as the default interface name. -// Setting the interface to "*" means "use all available interfaces". -CZMQ_EXPORT void - zproc_set_biface (const char *value); - -// *** Draft method, for development use, may change without warning *** -// Return network interface to use for broadcasts, or "" if none was set. -CZMQ_EXPORT const char * - zproc_biface (void); - -// *** Draft method, for development use, may change without warning *** -// Set log identity, which is a string that prefixes all log messages sent -// by this process. The log identity defaults to the environment variable -// ZSYS_LOGIDENT, if that is set. -CZMQ_EXPORT void - zproc_set_log_ident (const char *value); - -// *** Draft method, for development use, may change without warning *** -// Sends log output to a PUB socket bound to the specified endpoint. To -// collect such log output, create a SUB socket, subscribe to the traffic -// you care about, and connect to the endpoint. Log traffic is sent as a -// single string frame, in the same format as when sent to stdout. The -// log system supports a single sender; multiple calls to this method will -// bind the same sender to multiple endpoints. To disable the sender, call -// this method with a null argument. -CZMQ_EXPORT void - zproc_set_log_sender (const char *endpoint); - -// *** Draft method, for development use, may change without warning *** -// Enable or disable logging to the system facility (syslog on POSIX boxes, -// event log on Windows). By default this is disabled. -CZMQ_EXPORT void - zproc_set_log_system (bool logsystem); - -// *** Draft method, for development use, may change without warning *** -// Log error condition - highest priority -CZMQ_EXPORT void - zproc_log_error (const char *format, ...) CHECK_PRINTF (1); - -// *** Draft method, for development use, may change without warning *** -// Log warning condition - high priority -CZMQ_EXPORT void - zproc_log_warning (const char *format, ...) CHECK_PRINTF (1); - -// *** Draft method, for development use, may change without warning *** -// Log normal, but significant, condition - normal priority -CZMQ_EXPORT void - zproc_log_notice (const char *format, ...) CHECK_PRINTF (1); - -// *** Draft method, for development use, may change without warning *** -// Log informational message - low priority -CZMQ_EXPORT void - zproc_log_info (const char *format, ...) CHECK_PRINTF (1); - -// *** Draft method, for development use, may change without warning *** -// Log debug-level message - lowest priority -CZMQ_EXPORT void - zproc_log_debug (const char *format, ...) CHECK_PRINTF (1); - -// *** Draft method, for development use, may change without warning *** -// Self test of this class. -CZMQ_EXPORT void - zproc_test (bool verbose); - -#endif // CZMQ_BUILD_DRAFT_API -// @end - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zproxy.h b/phonelibs/zmq/x64/include/zproxy.h deleted file mode 100644 index f672c5e72417a5..00000000000000 --- a/phonelibs/zmq/x64/include/zproxy.h +++ /dev/null @@ -1,111 +0,0 @@ -/* ========================================================================= - zproxy - run a steerable proxy in the background - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZPROXY_H_INCLUDED__ -#define __ZPROXY_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @interface -// Create new zproxy actor instance. The proxy switches messages between -// a frontend socket and a backend socket; use the FRONTEND and BACKEND -// commands to configure these: -// -// zactor_t *proxy = zactor_new (zproxy, NULL); -// -// Destroy zproxy instance. This destroys the two sockets and stops any -// message flow between them: -// -// zactor_destroy (&proxy); -// -// Note that all zproxy commands are synchronous, so your application always -// waits for a signal from the actor after each command. -// -// Enable verbose logging of commands and activity: -// -// zstr_send (proxy, "VERBOSE"); -// zsock_wait (proxy); -// -// Specify frontend socket type -- see zsock_type_str () -- and attach to -// endpoints, see zsock_attach (). Note that a proxy socket is always -// serverish: -// -// zstr_sendx (proxy, "FRONTEND", "XSUB", endpoints, NULL); -// zsock_wait (proxy); -// -// Specify backend socket type -- see zsock_type_str () -- and attach to -// endpoints, see zsock_attach (). Note that a proxy socket is always -// serverish: -// -// zstr_sendx (proxy, "BACKEND", "XPUB", endpoints, NULL); -// zsock_wait (proxy); -// -// Capture all proxied messages; these are delivered to the application -// via an inproc PULL socket that you have already bound to the specified -// endpoint: -// -// zstr_sendx (proxy, "CAPTURE", endpoint, NULL); -// zsock_wait (proxy); -// -// Pause the proxy. A paused proxy will cease processing messages, causing -// them to be queued up and potentially hit the high-water mark on the -// frontend or backend socket, causing messages to be dropped, or writing -// applications to block: -// -// zstr_sendx (proxy, "PAUSE", NULL); -// zsock_wait (proxy); -// -// Resume the proxy. Note that the proxy starts automatically as soon as it -// has a properly attached frontend and backend socket: -// -// zstr_sendx (proxy, "RESUME", NULL); -// zsock_wait (proxy); -// -// Configure an authentication domain for the "FRONTEND" or "BACKEND" proxy -// socket -- see zsock_set_zap_domain (). Call before binding socket: -// -// zstr_sendx (proxy, "DOMAIN", "FRONTEND", "global", NULL); -// zsock_wait (proxy); -// -// Configure PLAIN authentication for the "FRONTEND" or "BACKEND" proxy -// socket -- see zsock_set_plain_server (). Call before binding socket: -// -// zstr_sendx (proxy, "PLAIN", "BACKEND", NULL); -// zsock_wait (proxy); -// -// Configure CURVE authentication for the "FRONTEND" or "BACKEND" proxy -// socket -- see zsock_set_curve_server () -- specifying both the public and -// secret keys of a certificate as Z85 armored strings -- see -// zcert_public_txt () and zcert_secret_txt (). Call before binding socket: -// -// zstr_sendx (proxy, "CURVE", "FRONTEND", public_txt, secret_txt, NULL); -// zsock_wait (proxy); -// -// This is the zproxy constructor as a zactor_fn; the argument is a -// character string specifying frontend and backend socket types as two -// uppercase strings separated by a hyphen: -CZMQ_EXPORT void - zproxy (zsock_t *pipe, void *unused); - -// Selftest -CZMQ_EXPORT void - zproxy_test (bool verbose); -// @end - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zrex.h b/phonelibs/zmq/x64/include/zrex.h deleted file mode 100644 index 8b50618a34837c..00000000000000 --- a/phonelibs/zmq/x64/include/zrex.h +++ /dev/null @@ -1,82 +0,0 @@ -/* ========================================================================= - zrex - work with regular expressions - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZREX_H_INCLUDED__ -#define __ZREX_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @interface -// Constructor. Optionally, sets an expression against which we can match -// text and capture hits. If there is an error in the expression, reports -// zrex_valid() as false and provides the error in zrex_strerror(). If you -// set a pattern, you can call zrex_matches() to test it against text. -CZMQ_EXPORT zrex_t * - zrex_new (const char *expression); - -// Destructor -CZMQ_EXPORT void - zrex_destroy (zrex_t **self_p); - -// Return true if the expression was valid and compiled without errors. -CZMQ_EXPORT bool - zrex_valid (zrex_t *self); - -// Return the error message generated during compilation of the expression. -CZMQ_EXPORT const char * - zrex_strerror (zrex_t *self); - -// Returns true if the text matches the previously compiled expression. -// Use this method to compare one expression against many strings. -CZMQ_EXPORT bool - zrex_matches (zrex_t *self, const char *text); - -// Returns true if the text matches the supplied expression. Use this -// method to compare one string against several expressions. -CZMQ_EXPORT bool - zrex_eq (zrex_t *self, const char *text, const char *expression); - -// Returns number of hits from last zrex_matches or zrex_eq. If the text -// matched, returns 1 plus the number of capture groups. If the text did -// not match, returns zero. To retrieve individual capture groups, call -// zrex_hit (). -CZMQ_EXPORT int - zrex_hits (zrex_t *self); - -// Returns the Nth capture group from the last expression match, where -// N is 0 to the value returned by zrex_hits(). Capture group 0 is the -// whole matching string. Sequence 1 is the first capture group, if any, -// and so on. -CZMQ_EXPORT const char * - zrex_hit (zrex_t *self, uint index); - -// Fetches hits into string variables provided by caller; this makes for -// nicer code than accessing hits by index. Caller should not modify nor -// free the returned values. Returns number of strings returned. This -// method starts at hit 1, i.e. first capture group, as hit 0 is always -// the original matched string. -CZMQ_EXPORT int - zrex_fetch (zrex_t *self, const char **string_p, ...); - -// Self test of this class -CZMQ_EXPORT void - zrex_test (bool verbose); -// @end - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zsock.h b/phonelibs/zmq/x64/include/zsock.h deleted file mode 100644 index 9ab060d6a3b8e4..00000000000000 --- a/phonelibs/zmq/x64/include/zsock.h +++ /dev/null @@ -1,1159 +0,0 @@ -/* ========================================================================= - zsock - high-level socket API that hides libzmq contexts and sockets - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZSOCK_H_INCLUDED__ -#define __ZSOCK_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// This interface includes some smart constructors, which create sockets with -// additional set-up. In all of these, the endpoint is NULL, or starts with -// '@' (bind) or '>' (connect). Multiple endpoints are allowed, separated by -// commas. If endpoint does not start with '@' or '>', default action depends -// on socket type. - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zsock.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// This class has draft methods, which may change over time. They are not -// in stable releases, by default. Use --enable-drafts to enable. -// Create a new socket. Returns the new socket, or NULL if the new socket -// could not be created. Note that the symbol zsock_new (and other -// constructors/destructors for zsock) are redirected to the *_checked -// variant, enabling intelligent socket leak detection. This can have -// performance implications if you use a LOT of sockets. To turn off this -// redirection behaviour, define ZSOCK_NOCHECK. -CZMQ_EXPORT zsock_t * - zsock_new (int type); - -// Create a PUB socket. Default action is bind. -CZMQ_EXPORT zsock_t * - zsock_new_pub (const char *endpoint); - -// Create a SUB socket, and optionally subscribe to some prefix string. Default -// action is connect. -CZMQ_EXPORT zsock_t * - zsock_new_sub (const char *endpoint, const char *subscribe); - -// Create a REQ socket. Default action is connect. -CZMQ_EXPORT zsock_t * - zsock_new_req (const char *endpoint); - -// Create a REP socket. Default action is bind. -CZMQ_EXPORT zsock_t * - zsock_new_rep (const char *endpoint); - -// Create a DEALER socket. Default action is connect. -CZMQ_EXPORT zsock_t * - zsock_new_dealer (const char *endpoint); - -// Create a ROUTER socket. Default action is bind. -CZMQ_EXPORT zsock_t * - zsock_new_router (const char *endpoint); - -// Create a PUSH socket. Default action is connect. -CZMQ_EXPORT zsock_t * - zsock_new_push (const char *endpoint); - -// Create a PULL socket. Default action is bind. -CZMQ_EXPORT zsock_t * - zsock_new_pull (const char *endpoint); - -// Create an XPUB socket. Default action is bind. -CZMQ_EXPORT zsock_t * - zsock_new_xpub (const char *endpoint); - -// Create an XSUB socket. Default action is connect. -CZMQ_EXPORT zsock_t * - zsock_new_xsub (const char *endpoint); - -// Create a PAIR socket. Default action is connect. -CZMQ_EXPORT zsock_t * - zsock_new_pair (const char *endpoint); - -// Create a STREAM socket. Default action is connect. -CZMQ_EXPORT zsock_t * - zsock_new_stream (const char *endpoint); - -// Destroy the socket. You must use this for any socket created via the -// zsock_new method. -CZMQ_EXPORT void - zsock_destroy (zsock_t **self_p); - -// Bind a socket to a formatted endpoint. For tcp:// endpoints, supports -// ephemeral ports, if you specify the port number as "*". By default -// zsock uses the IANA designated range from C000 (49152) to FFFF (65535). -// To override this range, follow the "*" with "[first-last]". Either or -// both first and last may be empty. To bind to a random port within the -// range, use "!" in place of "*". -// -// Examples: -// tcp://127.0.0.1:* bind to first free port from C000 up -// tcp://127.0.0.1:! bind to random port from C000 to FFFF -// tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up -// tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 -// tcp://127.0.0.1:![55000-55999] -// bind to random port from 55000 to 55999 -// -// On success, returns the actual port number used, for tcp:// endpoints, -// and 0 for other transports. On failure, returns -1. Note that when using -// ephemeral ports, a port may be reused by different services without -// clients being aware. Protocols that run on ephemeral ports should take -// this into account. -CZMQ_EXPORT int - zsock_bind (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); - -// Returns last bound endpoint, if any. -CZMQ_EXPORT const char * - zsock_endpoint (zsock_t *self); - -// Unbind a socket from a formatted endpoint. -// Returns 0 if OK, -1 if the endpoint was invalid or the function -// isn't supported. -CZMQ_EXPORT int - zsock_unbind (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); - -// Connect a socket to a formatted endpoint -// Returns 0 if OK, -1 if the endpoint was invalid. -CZMQ_EXPORT int - zsock_connect (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); - -// Disconnect a socket from a formatted endpoint -// Returns 0 if OK, -1 if the endpoint was invalid or the function -// isn't supported. -CZMQ_EXPORT int - zsock_disconnect (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); - -// Attach a socket to zero or more endpoints. If endpoints is not null, -// parses as list of ZeroMQ endpoints, separated by commas, and prefixed by -// '@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all -// endpoints were valid, or -1 if there was a syntax error. If the endpoint -// does not start with '@' or '>', the serverish argument defines whether -// it is used to bind (serverish = true) or connect (serverish = false). -CZMQ_EXPORT int - zsock_attach (zsock_t *self, const char *endpoints, bool serverish); - -// Returns socket type as printable constant string. -CZMQ_EXPORT const char * - zsock_type_str (zsock_t *self); - -// Send a 'picture' message to the socket (or actor). The picture is a -// string that defines the type of each frame. This makes it easy to send -// a complex multiframe message in one call. The picture can contain any -// of these characters, each corresponding to one or two arguments: -// -// i = int (signed) -// 1 = uint8_t -// 2 = uint16_t -// 4 = uint32_t -// 8 = uint64_t -// s = char * -// b = byte *, size_t (2 arguments) -// c = zchunk_t * -// f = zframe_t * -// h = zhashx_t * -// U = zuuid_t * -// p = void * (sends the pointer value, only meaningful over inproc) -// m = zmsg_t * (sends all frames in the zmsg) -// z = sends zero-sized frame (0 arguments) -// u = uint (deprecated) -// -// Note that s, b, c, and f are encoded the same way and the choice is -// offered as a convenience to the sender, which may or may not already -// have data in a zchunk or zframe. Does not change or take ownership of -// any arguments. Returns 0 if successful, -1 if sending failed for any -// reason. -CZMQ_EXPORT int - zsock_send (void *self, const char *picture, ...); - -// Send a 'picture' message to the socket (or actor). This is a va_list -// version of zsock_send (), so please consult its documentation for the -// details. -CZMQ_EXPORT int - zsock_vsend (void *self, const char *picture, va_list argptr); - -// Receive a 'picture' message to the socket (or actor). See zsock_send for -// the format and meaning of the picture. Returns the picture elements into -// a series of pointers as provided by the caller: -// -// i = int * (stores signed integer) -// 4 = uint32_t * (stores 32-bit unsigned integer) -// 8 = uint64_t * (stores 64-bit unsigned integer) -// s = char ** (allocates new string) -// b = byte **, size_t * (2 arguments) (allocates memory) -// c = zchunk_t ** (creates zchunk) -// f = zframe_t ** (creates zframe) -// U = zuuid_t * (creates a zuuid with the data) -// h = zhashx_t ** (creates zhashx) -// p = void ** (stores pointer) -// m = zmsg_t ** (creates a zmsg with the remaing frames) -// z = null, asserts empty frame (0 arguments) -// u = uint * (stores unsigned integer, deprecated) -// -// Note that zsock_recv creates the returned objects, and the caller must -// destroy them when finished with them. The supplied pointers do not need -// to be initialized. Returns 0 if successful, or -1 if it failed to recv -// a message, in which case the pointers are not modified. When message -// frames are truncated (a short message), sets return values to zero/null. -// If an argument pointer is NULL, does not store any value (skips it). -// An 'n' picture matches an empty frame; if the message does not match, -// the method will return -1. -CZMQ_EXPORT int - zsock_recv (void *self, const char *picture, ...); - -// Receive a 'picture' message from the socket (or actor). This is a -// va_list version of zsock_recv (), so please consult its documentation -// for the details. -CZMQ_EXPORT int - zsock_vrecv (void *self, const char *picture, va_list argptr); - -// Send a binary encoded 'picture' message to the socket (or actor). This -// method is similar to zsock_send, except the arguments are encoded in a -// binary format that is compatible with zproto, and is designed to reduce -// memory allocations. The pattern argument is a string that defines the -// type of each argument. Supports these argument types: -// -// pattern C type zproto type: -// 1 uint8_t type = "number" size = "1" -// 2 uint16_t type = "number" size = "2" -// 4 uint32_t type = "number" size = "3" -// 8 uint64_t type = "number" size = "4" -// s char *, 0-255 chars type = "string" -// S char *, 0-2^32-1 chars type = "longstr" -// c zchunk_t * type = "chunk" -// f zframe_t * type = "frame" -// u zuuid_t * type = "uuid" -// m zmsg_t * type = "msg" -// p void *, sends pointer value, only over inproc -// -// Does not change or take ownership of any arguments. Returns 0 if -// successful, -1 if sending failed for any reason. -CZMQ_EXPORT int - zsock_bsend (void *self, const char *picture, ...); - -// Receive a binary encoded 'picture' message from the socket (or actor). -// This method is similar to zsock_recv, except the arguments are encoded -// in a binary format that is compatible with zproto, and is designed to -// reduce memory allocations. The pattern argument is a string that defines -// the type of each argument. See zsock_bsend for the supported argument -// types. All arguments must be pointers; this call sets them to point to -// values held on a per-socket basis. -// Note that zsock_brecv creates the returned objects, and the caller must -// destroy them when finished with them. The supplied pointers do not need -// to be initialized. Returns 0 if successful, or -1 if it failed to read -// a message. -CZMQ_EXPORT int - zsock_brecv (void *self, const char *picture, ...); - -// Set socket to use unbounded pipes (HWM=0); use this in cases when you are -// totally certain the message volume can fit in memory. This method works -// across all versions of ZeroMQ. Takes a polymorphic socket reference. -CZMQ_EXPORT void - zsock_set_unbounded (void *self); - -// Send a signal over a socket. A signal is a short message carrying a -// success/failure code (by convention, 0 means OK). Signals are encoded -// to be distinguishable from "normal" messages. Accepts a zsock_t or a -// zactor_t argument, and returns 0 if successful, -1 if the signal could -// not be sent. Takes a polymorphic socket reference. -CZMQ_EXPORT int - zsock_signal (void *self, byte status); - -// Wait on a signal. Use this to coordinate between threads, over pipe -// pairs. Blocks until the signal is received. Returns -1 on error, 0 or -// greater on success. Accepts a zsock_t or a zactor_t as argument. -// Takes a polymorphic socket reference. -CZMQ_EXPORT int - zsock_wait (void *self); - -// If there is a partial message still waiting on the socket, remove and -// discard it. This is useful when reading partial messages, to get specific -// message types. -CZMQ_EXPORT void - zsock_flush (void *self); - -// Probe the supplied object, and report if it looks like a zsock_t. -// Takes a polymorphic socket reference. -CZMQ_EXPORT bool - zsock_is (void *self); - -// Probe the supplied reference. If it looks like a zsock_t instance, return -// the underlying libzmq socket handle; else if it looks like a file -// descriptor, return NULL; else if it looks like a libzmq socket handle, -// return the supplied value. Takes a polymorphic socket reference. -CZMQ_EXPORT void * - zsock_resolve (void *self); - -// Get socket option `heartbeat_ivl`. -// Available from libzmq 4.2.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_heartbeat_ivl (void *self); - -// Set socket option `heartbeat_ivl`. -// Available from libzmq 4.2.0. -CZMQ_EXPORT void - zsock_set_heartbeat_ivl (void *self, int heartbeat_ivl); - -// Get socket option `heartbeat_ttl`. -// Available from libzmq 4.2.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_heartbeat_ttl (void *self); - -// Set socket option `heartbeat_ttl`. -// Available from libzmq 4.2.0. -CZMQ_EXPORT void - zsock_set_heartbeat_ttl (void *self, int heartbeat_ttl); - -// Get socket option `heartbeat_timeout`. -// Available from libzmq 4.2.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_heartbeat_timeout (void *self); - -// Set socket option `heartbeat_timeout`. -// Available from libzmq 4.2.0. -CZMQ_EXPORT void - zsock_set_heartbeat_timeout (void *self, int heartbeat_timeout); - -// Get socket option `use_fd`. -// Available from libzmq 4.2.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_use_fd (void *self); - -// Set socket option `use_fd`. -// Available from libzmq 4.2.0. -CZMQ_EXPORT void - zsock_set_use_fd (void *self, int use_fd); - -// Set socket option `xpub_manual`. -// Available from libzmq 4.2.0. -CZMQ_EXPORT void - zsock_set_xpub_manual (void *self, int xpub_manual); - -// Set socket option `xpub_welcome_msg`. -// Available from libzmq 4.2.0. -CZMQ_EXPORT void - zsock_set_xpub_welcome_msg (void *self, const char *xpub_welcome_msg); - -// Set socket option `stream_notify`. -// Available from libzmq 4.2.0. -CZMQ_EXPORT void - zsock_set_stream_notify (void *self, int stream_notify); - -// Get socket option `invert_matching`. -// Available from libzmq 4.2.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_invert_matching (void *self); - -// Set socket option `invert_matching`. -// Available from libzmq 4.2.0. -CZMQ_EXPORT void - zsock_set_invert_matching (void *self, int invert_matching); - -// Set socket option `xpub_verboser`. -// Available from libzmq 4.2.0. -CZMQ_EXPORT void - zsock_set_xpub_verboser (void *self, int xpub_verboser); - -// Get socket option `connect_timeout`. -// Available from libzmq 4.2.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_connect_timeout (void *self); - -// Set socket option `connect_timeout`. -// Available from libzmq 4.2.0. -CZMQ_EXPORT void - zsock_set_connect_timeout (void *self, int connect_timeout); - -// Get socket option `tcp_maxrt`. -// Available from libzmq 4.2.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_tcp_maxrt (void *self); - -// Set socket option `tcp_maxrt`. -// Available from libzmq 4.2.0. -CZMQ_EXPORT void - zsock_set_tcp_maxrt (void *self, int tcp_maxrt); - -// Get socket option `thread_safe`. -// Available from libzmq 4.2.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_thread_safe (void *self); - -// Get socket option `multicast_maxtpdu`. -// Available from libzmq 4.2.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_multicast_maxtpdu (void *self); - -// Set socket option `multicast_maxtpdu`. -// Available from libzmq 4.2.0. -CZMQ_EXPORT void - zsock_set_multicast_maxtpdu (void *self, int multicast_maxtpdu); - -// Get socket option `vmci_buffer_size`. -// Available from libzmq 4.2.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_vmci_buffer_size (void *self); - -// Set socket option `vmci_buffer_size`. -// Available from libzmq 4.2.0. -CZMQ_EXPORT void - zsock_set_vmci_buffer_size (void *self, int vmci_buffer_size); - -// Get socket option `vmci_buffer_min_size`. -// Available from libzmq 4.2.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_vmci_buffer_min_size (void *self); - -// Set socket option `vmci_buffer_min_size`. -// Available from libzmq 4.2.0. -CZMQ_EXPORT void - zsock_set_vmci_buffer_min_size (void *self, int vmci_buffer_min_size); - -// Get socket option `vmci_buffer_max_size`. -// Available from libzmq 4.2.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_vmci_buffer_max_size (void *self); - -// Set socket option `vmci_buffer_max_size`. -// Available from libzmq 4.2.0. -CZMQ_EXPORT void - zsock_set_vmci_buffer_max_size (void *self, int vmci_buffer_max_size); - -// Get socket option `vmci_connect_timeout`. -// Available from libzmq 4.2.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_vmci_connect_timeout (void *self); - -// Set socket option `vmci_connect_timeout`. -// Available from libzmq 4.2.0. -CZMQ_EXPORT void - zsock_set_vmci_connect_timeout (void *self, int vmci_connect_timeout); - -// Get socket option `tos`. -// Available from libzmq 4.1.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_tos (void *self); - -// Set socket option `tos`. -// Available from libzmq 4.1.0. -CZMQ_EXPORT void - zsock_set_tos (void *self, int tos); - -// Set socket option `router_handover`. -// Available from libzmq 4.1.0. -CZMQ_EXPORT void - zsock_set_router_handover (void *self, int router_handover); - -// Set socket option `connect_rid`. -// Available from libzmq 4.1.0. -CZMQ_EXPORT void - zsock_set_connect_rid (void *self, const char *connect_rid); - -// Set socket option `connect_rid` from 32-octet binary -// Available from libzmq 4.1.0. -CZMQ_EXPORT void - zsock_set_connect_rid_bin (void *self, const byte *connect_rid); - -// Get socket option `handshake_ivl`. -// Available from libzmq 4.1.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_handshake_ivl (void *self); - -// Set socket option `handshake_ivl`. -// Available from libzmq 4.1.0. -CZMQ_EXPORT void - zsock_set_handshake_ivl (void *self, int handshake_ivl); - -// Get socket option `socks_proxy`. -// Available from libzmq 4.1.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zsock_socks_proxy (void *self); - -// Set socket option `socks_proxy`. -// Available from libzmq 4.1.0. -CZMQ_EXPORT void - zsock_set_socks_proxy (void *self, const char *socks_proxy); - -// Set socket option `xpub_nodrop`. -// Available from libzmq 4.1.0. -CZMQ_EXPORT void - zsock_set_xpub_nodrop (void *self, int xpub_nodrop); - -// Set socket option `router_mandatory`. -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_router_mandatory (void *self, int router_mandatory); - -// Set socket option `probe_router`. -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_probe_router (void *self, int probe_router); - -// Set socket option `req_relaxed`. -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_req_relaxed (void *self, int req_relaxed); - -// Set socket option `req_correlate`. -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_req_correlate (void *self, int req_correlate); - -// Set socket option `conflate`. -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_conflate (void *self, int conflate); - -// Get socket option `zap_domain`. -// Available from libzmq 4.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zsock_zap_domain (void *self); - -// Set socket option `zap_domain`. -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_zap_domain (void *self, const char *zap_domain); - -// Get socket option `mechanism`. -// Available from libzmq 4.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_mechanism (void *self); - -// Get socket option `plain_server`. -// Available from libzmq 4.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_plain_server (void *self); - -// Set socket option `plain_server`. -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_plain_server (void *self, int plain_server); - -// Get socket option `plain_username`. -// Available from libzmq 4.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zsock_plain_username (void *self); - -// Set socket option `plain_username`. -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_plain_username (void *self, const char *plain_username); - -// Get socket option `plain_password`. -// Available from libzmq 4.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zsock_plain_password (void *self); - -// Set socket option `plain_password`. -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_plain_password (void *self, const char *plain_password); - -// Get socket option `curve_server`. -// Available from libzmq 4.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_curve_server (void *self); - -// Set socket option `curve_server`. -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_curve_server (void *self, int curve_server); - -// Get socket option `curve_publickey`. -// Available from libzmq 4.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zsock_curve_publickey (void *self); - -// Set socket option `curve_publickey`. -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_curve_publickey (void *self, const char *curve_publickey); - -// Set socket option `curve_publickey` from 32-octet binary -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_curve_publickey_bin (void *self, const byte *curve_publickey); - -// Get socket option `curve_secretkey`. -// Available from libzmq 4.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zsock_curve_secretkey (void *self); - -// Set socket option `curve_secretkey`. -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_curve_secretkey (void *self, const char *curve_secretkey); - -// Set socket option `curve_secretkey` from 32-octet binary -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_curve_secretkey_bin (void *self, const byte *curve_secretkey); - -// Get socket option `curve_serverkey`. -// Available from libzmq 4.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zsock_curve_serverkey (void *self); - -// Set socket option `curve_serverkey`. -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_curve_serverkey (void *self, const char *curve_serverkey); - -// Set socket option `curve_serverkey` from 32-octet binary -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_curve_serverkey_bin (void *self, const byte *curve_serverkey); - -// Get socket option `gssapi_server`. -// Available from libzmq 4.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_gssapi_server (void *self); - -// Set socket option `gssapi_server`. -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_gssapi_server (void *self, int gssapi_server); - -// Get socket option `gssapi_plaintext`. -// Available from libzmq 4.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_gssapi_plaintext (void *self); - -// Set socket option `gssapi_plaintext`. -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_gssapi_plaintext (void *self, int gssapi_plaintext); - -// Get socket option `gssapi_principal`. -// Available from libzmq 4.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zsock_gssapi_principal (void *self); - -// Set socket option `gssapi_principal`. -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_gssapi_principal (void *self, const char *gssapi_principal); - -// Get socket option `gssapi_service_principal`. -// Available from libzmq 4.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zsock_gssapi_service_principal (void *self); - -// Set socket option `gssapi_service_principal`. -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_gssapi_service_principal (void *self, const char *gssapi_service_principal); - -// Get socket option `ipv6`. -// Available from libzmq 4.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_ipv6 (void *self); - -// Set socket option `ipv6`. -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_ipv6 (void *self, int ipv6); - -// Get socket option `immediate`. -// Available from libzmq 4.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_immediate (void *self); - -// Set socket option `immediate`. -// Available from libzmq 4.0.0. -CZMQ_EXPORT void - zsock_set_immediate (void *self, int immediate); - -// Get socket option `type`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_type (void *self); - -// Get socket option `sndhwm`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_sndhwm (void *self); - -// Set socket option `sndhwm`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_sndhwm (void *self, int sndhwm); - -// Get socket option `rcvhwm`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_rcvhwm (void *self); - -// Set socket option `rcvhwm`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_rcvhwm (void *self, int rcvhwm); - -// Get socket option `affinity`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_affinity (void *self); - -// Set socket option `affinity`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_affinity (void *self, int affinity); - -// Set socket option `subscribe`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_subscribe (void *self, const char *subscribe); - -// Set socket option `unsubscribe`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_unsubscribe (void *self, const char *unsubscribe); - -// Get socket option `identity`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zsock_identity (void *self); - -// Set socket option `identity`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_identity (void *self, const char *identity); - -// Get socket option `rate`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_rate (void *self); - -// Set socket option `rate`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_rate (void *self, int rate); - -// Get socket option `recovery_ivl`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_recovery_ivl (void *self); - -// Set socket option `recovery_ivl`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_recovery_ivl (void *self, int recovery_ivl); - -// Get socket option `sndbuf`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_sndbuf (void *self); - -// Set socket option `sndbuf`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_sndbuf (void *self, int sndbuf); - -// Get socket option `rcvbuf`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_rcvbuf (void *self); - -// Set socket option `rcvbuf`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_rcvbuf (void *self, int rcvbuf); - -// Get socket option `linger`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_linger (void *self); - -// Set socket option `linger`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_linger (void *self, int linger); - -// Get socket option `reconnect_ivl`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_reconnect_ivl (void *self); - -// Set socket option `reconnect_ivl`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_reconnect_ivl (void *self, int reconnect_ivl); - -// Get socket option `reconnect_ivl_max`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_reconnect_ivl_max (void *self); - -// Set socket option `reconnect_ivl_max`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max); - -// Get socket option `backlog`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_backlog (void *self); - -// Set socket option `backlog`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_backlog (void *self, int backlog); - -// Get socket option `maxmsgsize`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_maxmsgsize (void *self); - -// Set socket option `maxmsgsize`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_maxmsgsize (void *self, int maxmsgsize); - -// Get socket option `multicast_hops`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_multicast_hops (void *self); - -// Set socket option `multicast_hops`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_multicast_hops (void *self, int multicast_hops); - -// Get socket option `rcvtimeo`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_rcvtimeo (void *self); - -// Set socket option `rcvtimeo`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_rcvtimeo (void *self, int rcvtimeo); - -// Get socket option `sndtimeo`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_sndtimeo (void *self); - -// Set socket option `sndtimeo`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_sndtimeo (void *self, int sndtimeo); - -// Set socket option `xpub_verbose`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_xpub_verbose (void *self, int xpub_verbose); - -// Get socket option `tcp_keepalive`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_tcp_keepalive (void *self); - -// Set socket option `tcp_keepalive`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_tcp_keepalive (void *self, int tcp_keepalive); - -// Get socket option `tcp_keepalive_idle`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_tcp_keepalive_idle (void *self); - -// Set socket option `tcp_keepalive_idle`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle); - -// Get socket option `tcp_keepalive_cnt`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_tcp_keepalive_cnt (void *self); - -// Set socket option `tcp_keepalive_cnt`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt); - -// Get socket option `tcp_keepalive_intvl`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_tcp_keepalive_intvl (void *self); - -// Set socket option `tcp_keepalive_intvl`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl); - -// Get socket option `tcp_accept_filter`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zsock_tcp_accept_filter (void *self); - -// Set socket option `tcp_accept_filter`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_tcp_accept_filter (void *self, const char *tcp_accept_filter); - -// Get socket option `rcvmore`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_rcvmore (void *self); - -// Get socket option `fd`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT SOCKET - zsock_fd (void *self); - -// Get socket option `events`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_events (void *self); - -// Get socket option `last_endpoint`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zsock_last_endpoint (void *self); - -// Set socket option `router_raw`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_router_raw (void *self, int router_raw); - -// Get socket option `ipv4only`. -// Available from libzmq 3.0.0. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT int - zsock_ipv4only (void *self); - -// Set socket option `ipv4only`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_ipv4only (void *self, int ipv4only); - -// Set socket option `delay_attach_on_connect`. -// Available from libzmq 3.0.0. -CZMQ_EXPORT void - zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect); - -// Self test of this class. -CZMQ_EXPORT void - zsock_test (bool verbose); - -#ifdef CZMQ_BUILD_DRAFT_API -// *** Draft method, for development use, may change without warning *** -// Create a SERVER socket. Default action is bind. -CZMQ_EXPORT zsock_t * - zsock_new_server (const char *endpoint); - -// *** Draft method, for development use, may change without warning *** -// Create a CLIENT socket. Default action is connect. -CZMQ_EXPORT zsock_t * - zsock_new_client (const char *endpoint); - -// *** Draft method, for development use, may change without warning *** -// Create a RADIO socket. Default action is bind. -CZMQ_EXPORT zsock_t * - zsock_new_radio (const char *endpoint); - -// *** Draft method, for development use, may change without warning *** -// Create a DISH socket. Default action is connect. -CZMQ_EXPORT zsock_t * - zsock_new_dish (const char *endpoint); - -// *** Draft method, for development use, may change without warning *** -// Create a GATHER socket. Default action is bind. -CZMQ_EXPORT zsock_t * - zsock_new_gather (const char *endpoint); - -// *** Draft method, for development use, may change without warning *** -// Create a SCATTER socket. Default action is connect. -CZMQ_EXPORT zsock_t * - zsock_new_scatter (const char *endpoint); - -// *** Draft method, for development use, may change without warning *** -// Return socket routing ID if any. This returns 0 if the socket is not -// of type ZMQ_SERVER or if no request was already received on it. -CZMQ_EXPORT uint32_t - zsock_routing_id (zsock_t *self); - -// *** Draft method, for development use, may change without warning *** -// Set routing ID on socket. The socket MUST be of type ZMQ_SERVER. -// This will be used when sending messages on the socket via the zsock API. -CZMQ_EXPORT void - zsock_set_routing_id (zsock_t *self, uint32_t routing_id); - -// *** Draft method, for development use, may change without warning *** -// Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. -// Returns 0 if OK, -1 if failed. -CZMQ_EXPORT int - zsock_join (void *self, const char *group); - -// *** Draft method, for development use, may change without warning *** -// Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. -// Returns 0 if OK, -1 if failed. -CZMQ_EXPORT int - zsock_leave (void *self, const char *group); - -#endif // CZMQ_BUILD_DRAFT_API -// @end - - -// zsock leak detection - not a part of the official interface to zsock. This -// enables CZMQ to report socket leaks intelligently. -#if defined ZSOCK_NOCHECK - // no checking active - use the above interface methods directly. -#else -# define zsock_new(t) zsock_new_checked((t), __FILE__, __LINE__) -# define zsock_new_pub(e) zsock_new_pub_checked((e), __FILE__, __LINE__) -# define zsock_new_sub(e,s) zsock_new_sub_checked((e), (s), __FILE__, __LINE__) -# define zsock_new_req(e) zsock_new_req_checked((e), __FILE__, __LINE__) -# define zsock_new_rep(e) zsock_new_rep_checked((e), __FILE__, __LINE__) -# define zsock_new_dealer(e) zsock_new_dealer_checked((e), __FILE__, __LINE__) -# define zsock_new_router(e) zsock_new_router_checked((e), __FILE__, __LINE__) -# define zsock_new_pull(e) zsock_new_pull_checked((e), __FILE__, __LINE__) -# define zsock_new_push(e) zsock_new_push_checked((e), __FILE__, __LINE__) -# define zsock_new_xpub(e) zsock_new_xpub_checked((e), __FILE__, __LINE__) -# define zsock_new_xsub(e) zsock_new_xsub_checked((e), __FILE__, __LINE__) -# define zsock_new_pair(e) zsock_new_pair_checked((e), __FILE__, __LINE__) -# define zsock_new_stream(e) zsock_new_stream_checked((e), __FILE__, __LINE__) -# define zsock_destroy(t) zsock_destroy_checked((t), __FILE__, __LINE__) -#endif - -CZMQ_EXPORT zsock_t * - zsock_new_checked (int type, const char *filename, size_t line_nbr); - -CZMQ_EXPORT void - zsock_destroy_checked (zsock_t **self_p, const char *filename, size_t line_nbr); - -CZMQ_EXPORT zsock_t * - zsock_new_pub_checked (const char *endpoint, const char *filename, size_t line_nbr); - -CZMQ_EXPORT zsock_t * - zsock_new_sub_checked (const char *endpoint, const char *subscribe, const char *filename, size_t line_nbr); - -CZMQ_EXPORT zsock_t * - zsock_new_req_checked (const char *endpoint, const char *filename, size_t line_nbr); - -CZMQ_EXPORT zsock_t * - zsock_new_rep_checked (const char *endpoint, const char *filename, size_t line_nbr); - -CZMQ_EXPORT zsock_t * - zsock_new_dealer_checked (const char *endpoint, const char *filename, size_t line_nbr); - -CZMQ_EXPORT zsock_t * - zsock_new_router_checked (const char *endpoint, const char *filename, size_t line_nbr); - -CZMQ_EXPORT zsock_t * - zsock_new_push_checked (const char *endpoint, const char *filename, size_t line_nbr); - -CZMQ_EXPORT zsock_t * - zsock_new_pull_checked (const char *endpoint, const char *filename, size_t line_nbr); - -CZMQ_EXPORT zsock_t * - zsock_new_xpub_checked (const char *endpoint, const char *filename, size_t line_nbr); - -CZMQ_EXPORT zsock_t * - zsock_new_xsub_checked (const char *endpoint, const char *filename, size_t line_nbr); - -CZMQ_EXPORT zsock_t * - zsock_new_pair_checked (const char *endpoint, const char *filename, size_t line_nbr); - -CZMQ_EXPORT zsock_t * - zsock_new_stream_checked (const char *endpoint, const char *filename, size_t line_nbr); - -#ifdef CZMQ_BUILD_DRAFT_API -CZMQ_EXPORT zsock_t * - zsock_new_server_checked (const char *endpoint, const char *filename, size_t line_nbr); - -CZMQ_EXPORT zsock_t * - zsock_new_client_checked (const char *endpoint, const char *filename, size_t line_nbr); - -CZMQ_EXPORT zsock_t * - zsock_new_radio_checked (const char *endpoint, const char *filename, size_t line_nbr); - -CZMQ_EXPORT zsock_t * - zsock_new_dish_checked (const char *endpoint, const char *filename, size_t line_nbr); - -CZMQ_EXPORT zsock_t * - zsock_new_gather_checked (const char *endpoint, const char *filename, size_t line_nbr); - -CZMQ_EXPORT zsock_t * - zsock_new_scatter_checked (const char *endpoint, const char *filename, size_t line_nbr); -#endif // CZMQ_BUILD_DRAFT_API - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zstr.h b/phonelibs/zmq/x64/include/zstr.h deleted file mode 100644 index 67f2f852b623ea..00000000000000 --- a/phonelibs/zmq/x64/include/zstr.h +++ /dev/null @@ -1,110 +0,0 @@ -/* ========================================================================= - zstr - sending and receiving strings - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZSTR_H_INCLUDED__ -#define __ZSTR_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zstr.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// This class has draft methods, which may change over time. They are not -// in stable releases, by default. Use --enable-drafts to enable. -// Receive C string from socket. Caller must free returned string using -// zstr_free(). Returns NULL if the context is being terminated or the -// process was interrupted. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zstr_recv (void *source); - -// Receive a series of strings (until NULL) from multipart data. -// Each string is allocated and filled with string data; if there -// are not enough frames, unallocated strings are set to NULL. -// Returns -1 if the message could not be read, else returns the -// number of strings filled, zero or more. Free each returned string -// using zstr_free(). If not enough strings are provided, remaining -// multipart frames in the message are dropped. -CZMQ_EXPORT int - zstr_recvx (void *source, char **string_p, ...); - -// Send a C string to a socket, as a frame. The string is sent without -// trailing null byte; to read this you can use zstr_recv, or a similar -// method that adds a null terminator on the received string. String -// may be NULL, which is sent as "". -CZMQ_EXPORT int - zstr_send (void *dest, const char *string); - -// Send a C string to a socket, as zstr_send(), with a MORE flag, so that -// you can send further strings in the same multi-part message. -CZMQ_EXPORT int - zstr_sendm (void *dest, const char *string); - -// Send a formatted string to a socket. Note that you should NOT use -// user-supplied strings in the format (they may contain '%' which -// will create security holes). -CZMQ_EXPORT int - zstr_sendf (void *dest, const char *format, ...) CHECK_PRINTF (2); - -// Send a formatted string to a socket, as for zstr_sendf(), with a -// MORE flag, so that you can send further strings in the same multi-part -// message. -CZMQ_EXPORT int - zstr_sendfm (void *dest, const char *format, ...) CHECK_PRINTF (2); - -// Send a series of strings (until NULL) as multipart data -// Returns 0 if the strings could be sent OK, or -1 on error. -CZMQ_EXPORT int - zstr_sendx (void *dest, const char *string, ...); - -// Free a provided string, and nullify the parent pointer. Safe to call on -// a null pointer. -CZMQ_EXPORT void - zstr_free (char **string_p); - -// Self test of this class. -CZMQ_EXPORT void - zstr_test (bool verbose); - -#ifdef CZMQ_BUILD_DRAFT_API -// *** Draft method, for development use, may change without warning *** -// Accepts a void pointer and returns a fresh character string. If source -// is null, returns an empty string. -// Caller owns return value and must destroy it when done. -CZMQ_EXPORT char * - zstr_str (void *source); - -#endif // CZMQ_BUILD_DRAFT_API -// @end - - -// DEPRECATED as poor style -- callers should use zloop or zpoller -// Receive C string from socket, if socket had input ready. Caller must -// free returned string using zstr_free. Returns NULL if there was no input -// waiting, or if the context was terminated. Use zctx_interrupted to exit -// any loop that relies on this method. -CZMQ_EXPORT char * - zstr_recv_nowait (void *source); - -// Compiler hints -CZMQ_EXPORT int zstr_sendf (void *dest, const char *format, ...) CHECK_PRINTF (2); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zsys.h b/phonelibs/zmq/x64/include/zsys.h deleted file mode 100644 index 200271d9249cbb..00000000000000 --- a/phonelibs/zmq/x64/include/zsys.h +++ /dev/null @@ -1,395 +0,0 @@ -/* ========================================================================= - zsys - system-level methods - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZSYS_H_INCLUDED__ -#define __ZSYS_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -// @interface -#define UDP_FRAME_MAX 255 // Max size of UDP frame - -// Callback for interrupt signal handler -typedef void (zsys_handler_fn) (int signal_value); - -// Initialize CZMQ zsys layer; this happens automatically when you create -// a socket or an actor; however this call lets you force initialization -// earlier, so e.g. logging is properly set-up before you start working. -// Not threadsafe, so call only from main thread. Safe to call multiple -// times. Returns global CZMQ context. -CZMQ_EXPORT void * - zsys_init (void); - -// Optionally shut down the CZMQ zsys layer; this normally happens automatically -// when the process exits; however this call lets you force a shutdown -// earlier, avoiding any potential problems with atexit() ordering, especially -// with Windows dlls. -CZMQ_EXPORT void - zsys_shutdown (void); - -// Get a new ZMQ socket, automagically creating a ZMQ context if this is -// the first time. Caller is responsible for destroying the ZMQ socket -// before process exits, to avoid a ZMQ deadlock. Note: you should not use -// this method in CZMQ apps, use zsock_new() instead. -// *** This is for CZMQ internal use only and may change arbitrarily *** -CZMQ_EXPORT void * - zsys_socket (int type, const char *filename, size_t line_nbr); - -// Destroy/close a ZMQ socket. You should call this for every socket you -// create using zsys_socket(). -// *** This is for CZMQ internal use only and may change arbitrarily *** -CZMQ_EXPORT int - zsys_close (void *handle, const char *filename, size_t line_nbr); - -// Return ZMQ socket name for socket type -// *** This is for CZMQ internal use only and may change arbitrarily *** -CZMQ_EXPORT char * - zsys_sockname (int socktype); - -// Create a pipe, which consists of two PAIR sockets connected over inproc. -// The pipe is configured to use the zsys_pipehwm setting. Returns the -// frontend socket successful, NULL if failed. -CZMQ_EXPORT zsock_t * - zsys_create_pipe (zsock_t **backend_p); - -// Set interrupt handler; this saves the default handlers so that a -// zsys_handler_reset () can restore them. If you call this multiple times -// then the last handler will take affect. If handler_fn is NULL, disables -// default SIGINT/SIGTERM handling in CZMQ. -CZMQ_EXPORT void - zsys_handler_set (zsys_handler_fn *handler_fn); - -// Reset interrupt handler, call this at exit if needed -CZMQ_EXPORT void - zsys_handler_reset (void); - -// Set default interrupt handler, so Ctrl-C or SIGTERM will set -// zsys_interrupted. Idempotent; safe to call multiple times. -// *** This is for CZMQ internal use only and may change arbitrarily *** -CZMQ_EXPORT void - zsys_catch_interrupts (void); - -// Return 1 if file exists, else zero -CZMQ_EXPORT bool - zsys_file_exists (const char *filename); - -// Return size of file, or -1 if not found -CZMQ_EXPORT ssize_t - zsys_file_size (const char *filename); - -// Return file modification time. Returns 0 if the file does not exist. -CZMQ_EXPORT time_t - zsys_file_modified (const char *filename); - -// Return file mode; provides at least support for the POSIX S_ISREG(m) -// and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. -// Returns a mode_t cast to int, or -1 in case of error. -CZMQ_EXPORT int - zsys_file_mode (const char *filename); - -// Delete file. Does not complain if the file is absent -CZMQ_EXPORT int - zsys_file_delete (const char *filename); - -// Check if file is 'stable' -CZMQ_EXPORT bool - zsys_file_stable (const char *filename); - -// Create a file path if it doesn't exist. The file path is treated as a -// printf format. -CZMQ_EXPORT int - zsys_dir_create (const char *pathname, ...); - -// Remove a file path if empty; the pathname is treated as printf format. -CZMQ_EXPORT int - zsys_dir_delete (const char *pathname, ...); - -// Move to a specified working directory. Returns 0 if OK, -1 if this failed. -CZMQ_EXPORT int - zsys_dir_change (const char *pathname); - -// Set private file creation mode; all files created from here will be -// readable/writable by the owner only. -CZMQ_EXPORT void - zsys_file_mode_private (void); - -// Reset default file creation mode; all files created from here will use -// process file mode defaults. -CZMQ_EXPORT void - zsys_file_mode_default (void); - -// Return the CZMQ version for run-time API detection; returns version -// number into provided fields, providing reference isn't null in each case. -CZMQ_EXPORT void - zsys_version (int *major, int *minor, int *patch); - -// Format a string using printf formatting, returning a freshly allocated -// buffer. If there was insufficient memory, returns NULL. Free the returned -// string using zstr_free(). -CZMQ_EXPORT char * - zsys_sprintf (const char *format, ...); - -// Format a string with a va_list argument, returning a freshly allocated -// buffer. If there was insufficient memory, returns NULL. Free the returned -// string using zstr_free(). -CZMQ_EXPORT char * - zsys_vprintf (const char *format, va_list argptr); - -// Create UDP beacon socket; if the routable option is true, uses -// multicast (not yet implemented), else uses broadcast. This method -// and related ones might _eventually_ be moved to a zudp class. -// *** This is for CZMQ internal use only and may change arbitrarily *** -CZMQ_EXPORT SOCKET - zsys_udp_new (bool routable); - -// Close a UDP socket -// *** This is for CZMQ internal use only and may change arbitrarily *** -CZMQ_EXPORT int - zsys_udp_close (SOCKET handle); - -// Send zframe to UDP socket, return -1 if sending failed due to -// interface having disappeared (happens easily with WiFi) -// *** This is for CZMQ internal use only and may change arbitrarily *** -CZMQ_EXPORT int - zsys_udp_send (SOCKET udpsock, zframe_t *frame, inaddr_t *address, int addrlen); - -// Receive zframe from UDP socket, and set address of peer that sent it -// The peername must be a char [INET_ADDRSTRLEN] array. -// *** This is for CZMQ internal use only and may change arbitrarily *** -CZMQ_EXPORT zframe_t * - zsys_udp_recv (SOCKET udpsock, char *peername, int peerlen); - -// Handle an I/O error on some socket operation; will report and die on -// fatal errors, and continue silently on "try again" errors. -// *** This is for CZMQ internal use only and may change arbitrarily *** -CZMQ_EXPORT void - zsys_socket_error (const char *reason); - -// Return current host name, for use in public tcp:// endpoints. Caller gets -// a freshly allocated string, should free it using zstr_free(). If the host -// name is not resolvable, returns NULL. -CZMQ_EXPORT char * - zsys_hostname (void); - -// Move the current process into the background. The precise effect depends -// on the operating system. On POSIX boxes, moves to a specified working -// directory (if specified), closes all file handles, reopens stdin, stdout, -// and stderr to the null device, and sets the process to ignore SIGHUP. On -// Windows, does nothing. Returns 0 if OK, -1 if there was an error. -CZMQ_EXPORT int - zsys_daemonize (const char *workdir); - -// Drop the process ID into the lockfile, with exclusive lock, and switch -// the process to the specified group and/or user. Any of the arguments -// may be null, indicating a no-op. Returns 0 on success, -1 on failure. -// Note if you combine this with zsys_daemonize, run after, not before -// that method, or the lockfile will hold the wrong process ID. -CZMQ_EXPORT int - zsys_run_as (const char *lockfile, const char *group, const char *user); - -// Returns true if the underlying libzmq supports CURVE security. -// Uses a heuristic probe according to the version of libzmq being used. -CZMQ_EXPORT bool - zsys_has_curve (void); - -// Configure the number of I/O threads that ZeroMQ will use. A good -// rule of thumb is one thread per gigabit of traffic in or out. The -// default is 1, sufficient for most applications. If the environment -// variable ZSYS_IO_THREADS is defined, that provides the default. -// Note that this method is valid only before any socket is created. -CZMQ_EXPORT void - zsys_set_io_threads (size_t io_threads); - -// Configure the number of sockets that ZeroMQ will allow. The default -// is 1024. The actual limit depends on the system, and you can query it -// by using zsys_socket_limit (). A value of zero means "maximum". -// Note that this method is valid only before any socket is created. -CZMQ_EXPORT void - zsys_set_max_sockets (size_t max_sockets); - -// Return maximum number of ZeroMQ sockets that the system will support. -CZMQ_EXPORT size_t - zsys_socket_limit (void); - -// Configure the maximum allowed size of a message sent. -// The default is INT_MAX. -CZMQ_EXPORT void - zsys_set_max_msgsz (int max_msgsz); - -// Return maximum message size. -CZMQ_EXPORT int - zsys_max_msgsz (void); - -// Configure the default linger timeout in msecs for new zsock instances. -// You can also set this separately on each zsock_t instance. The default -// linger time is zero, i.e. any pending messages will be dropped. If the -// environment variable ZSYS_LINGER is defined, that provides the default. -// Note that process exit will typically be delayed by the linger time. -CZMQ_EXPORT void - zsys_set_linger (size_t linger); - -// Configure the default outgoing pipe limit (HWM) for new zsock instances. -// You can also set this separately on each zsock_t instance. The default -// HWM is 1,000, on all versions of ZeroMQ. If the environment variable -// ZSYS_SNDHWM is defined, that provides the default. Note that a value of -// zero means no limit, i.e. infinite memory consumption. -CZMQ_EXPORT void - zsys_set_sndhwm (size_t sndhwm); - -// Configure the default incoming pipe limit (HWM) for new zsock instances. -// You can also set this separately on each zsock_t instance. The default -// HWM is 1,000, on all versions of ZeroMQ. If the environment variable -// ZSYS_RCVHWM is defined, that provides the default. Note that a value of -// zero means no limit, i.e. infinite memory consumption. -CZMQ_EXPORT void - zsys_set_rcvhwm (size_t rcvhwm); - -// Configure the default HWM for zactor internal pipes; this is set on both -// ends of the pipe, for outgoing messages only (sndhwm). The default HWM is -// 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is -// defined, that provides the default. Note that a value of zero means no -// limit, i.e. infinite memory consumption. -CZMQ_EXPORT void - zsys_set_pipehwm (size_t pipehwm); - -// Return the HWM for zactor internal pipes. -CZMQ_EXPORT size_t - zsys_pipehwm (void); - -// Configure use of IPv6 for new zsock instances. By default sockets accept -// and make only IPv4 connections. When you enable IPv6, sockets will accept -// and connect to both IPv4 and IPv6 peers. You can override the setting on -// each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the -// environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the -// default. Note: has no effect on ZMQ v2. -CZMQ_EXPORT void - zsys_set_ipv6 (int ipv6); - -// Return use of IPv6 for zsock instances. -CZMQ_EXPORT int - zsys_ipv6 (void); - -// Set network interface name to use for broadcasts, particularly zbeacon. -// This lets the interface be configured for test environments where required. -// For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is -// the default when there is no specified interface. If the environment -// variable ZSYS_INTERFACE is set, use that as the default interface name. -// Setting the interface to "*" means "use all available interfaces". -CZMQ_EXPORT void - zsys_set_interface (const char *value); - -// Return network interface to use for broadcasts, or "" if none was set. -CZMQ_EXPORT const char * - zsys_interface (void); - -// Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon. -// This needs to be set IPv6 is enabled as IPv6 can have multiple addresses -// on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set, -// use that as the default IPv6 address. -CZMQ_EXPORT void - zsys_set_ipv6_address (const char *value); - -// Return IPv6 address to use for zbeacon reception, or "" if none was set. -CZMQ_EXPORT const char * - zsys_ipv6_address (void); - -// Set IPv6 milticast address to use for sending zbeacon messages. This needs -// to be set if IPv6 is enabled. If the environment variable -// ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast -// address. -CZMQ_EXPORT void - zsys_set_ipv6_mcast_address (const char *value); - -// Return IPv6 multicast address to use for sending zbeacon, or "" if none was -// set. -CZMQ_EXPORT const char * - zsys_ipv6_mcast_address (void); - -// Configure the automatic use of pre-allocated FDs when creating new sockets. -// If 0 (default), nothing will happen. Else, when a new socket is bound, the -// system API will be used to check if an existing pre-allocated FD with a -// matching port (if TCP) or path (if IPC) exists, and if it does it will be -// set via the ZMQ_USE_FD socket option so that the library will use it -// instead of creating a new socket. -CZMQ_EXPORT void - zsys_set_auto_use_fd (int auto_use_fd); - -// Return use of automatic pre-allocated FDs for zsock instances. -CZMQ_EXPORT int - zsys_auto_use_fd (void); - -// Set log identity, which is a string that prefixes all log messages sent -// by this process. The log identity defaults to the environment variable -// ZSYS_LOGIDENT, if that is set. -CZMQ_EXPORT void - zsys_set_logident (const char *value); - -// Set stream to receive log traffic. By default, log traffic is sent to -// stdout. If you set the stream to NULL, no stream will receive the log -// traffic (it may still be sent to the system facility). -CZMQ_EXPORT void - zsys_set_logstream (FILE *stream); - -// Sends log output to a PUB socket bound to the specified endpoint. To -// collect such log output, create a SUB socket, subscribe to the traffic -// you care about, and connect to the endpoint. Log traffic is sent as a -// single string frame, in the same format as when sent to stdout. The -// log system supports a single sender; multiple calls to this method will -// bind the same sender to multiple endpoints. To disable the sender, call -// this method with a null argument. -CZMQ_EXPORT void - zsys_set_logsender (const char *endpoint); - -// Enable or disable logging to the system facility (syslog on POSIX boxes, -// event log on Windows). By default this is disabled. -CZMQ_EXPORT void - zsys_set_logsystem (bool logsystem); - -// Log error condition - highest priority -CZMQ_EXPORT void - zsys_error (const char *format, ...); - -// Log warning condition - high priority -CZMQ_EXPORT void - zsys_warning (const char *format, ...); - -// Log normal, but significant, condition - normal priority -CZMQ_EXPORT void - zsys_notice (const char *format, ...); - -// Log informational message - low priority -CZMQ_EXPORT void - zsys_info (const char *format, ...); - -// Log debug-level message - lowest priority -CZMQ_EXPORT void - zsys_debug (const char *format, ...); - -// Self test of this class -CZMQ_EXPORT void - zsys_test (bool verbose); - -// Global signal indicator, TRUE when user presses Ctrl-C or the process -// gets a SIGTERM signal. -CZMQ_EXPORT extern volatile int zsys_interrupted; -// Deprecated name for this variable -CZMQ_EXPORT extern volatile int zctx_interrupted; -// @end - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/ztimerset.h b/phonelibs/zmq/x64/include/ztimerset.h deleted file mode 100644 index 29633fafdbdd30..00000000000000 --- a/phonelibs/zmq/x64/include/ztimerset.h +++ /dev/null @@ -1,90 +0,0 @@ -/* ========================================================================= - ztimerset - timer set - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef ZTIMERSET_H_INCLUDED -#define ZTIMERSET_H_INCLUDED - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/ztimerset.api" to make changes. -// @interface -// This is a draft class, and may change without notice. It is disabled in -// stable builds by default. If you use this in applications, please ask -// for it to be pushed to stable state. Use --enable-drafts to enable. -#ifdef CZMQ_BUILD_DRAFT_API -// Callback function for timer event. -typedef void (ztimerset_fn) ( - int timer_id, void *arg); - -// *** Draft method, for development use, may change without warning *** -// Create new timer set. -CZMQ_EXPORT ztimerset_t * - ztimerset_new (void); - -// *** Draft method, for development use, may change without warning *** -// Destroy a timer set -CZMQ_EXPORT void - ztimerset_destroy (ztimerset_t **self_p); - -// *** Draft method, for development use, may change without warning *** -// Add a timer to the set. Returns timer id if OK, -1 on failure. -CZMQ_EXPORT int - ztimerset_add (ztimerset_t *self, size_t interval, ztimerset_fn handler, void *arg); - -// *** Draft method, for development use, may change without warning *** -// Cancel a timer. Returns 0 if OK, -1 on failure. -CZMQ_EXPORT int - ztimerset_cancel (ztimerset_t *self, int timer_id); - -// *** Draft method, for development use, may change without warning *** -// Set timer interval. Returns 0 if OK, -1 on failure. -// This method is slow, canceling the timer and adding a new one yield better performance. -CZMQ_EXPORT int - ztimerset_set_interval (ztimerset_t *self, int timer_id, size_t interval); - -// *** Draft method, for development use, may change without warning *** -// Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure. -// This method is slow, canceling the timer and adding a new one yield better performance. -CZMQ_EXPORT int - ztimerset_reset (ztimerset_t *self, int timer_id); - -// *** Draft method, for development use, may change without warning *** -// Return the time until the next interval. -// Should be used as timeout parameter for the zpoller wait method. -// The timeout is in msec. -CZMQ_EXPORT int - ztimerset_timeout (ztimerset_t *self); - -// *** Draft method, for development use, may change without warning *** -// Invoke callback function of all timers which their interval has elapsed. -// Should be call after zpoller wait method. -// Returns 0 if OK, -1 on failure. -CZMQ_EXPORT int - ztimerset_execute (ztimerset_t *self); - -// *** Draft method, for development use, may change without warning *** -// Self test of this class. -CZMQ_EXPORT void - ztimerset_test (bool verbose); - -#endif // CZMQ_BUILD_DRAFT_API -// @end - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/ztrie.h b/phonelibs/zmq/x64/include/ztrie.h deleted file mode 100644 index 6fd53234b1274c..00000000000000 --- a/phonelibs/zmq/x64/include/ztrie.h +++ /dev/null @@ -1,106 +0,0 @@ -/* ========================================================================= - ztrie - simple trie for tokenizable strings - - Copyright (c) 1991-2012 iMatix Corporation -- http://www.imatix.com - Copyright other contributors as noted in the AUTHORS file. - - This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef ZTRIE_H_INCLUDED -#define ZTRIE_H_INCLUDED - -#ifdef __cplusplus -extern "C" { -#endif - - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/ztrie.api" to make changes. -// @interface -// This is a draft class, and may change without notice. It is disabled in -// stable builds by default. If you use this in applications, please ask -// for it to be pushed to stable state. Use --enable-drafts to enable. -#ifdef CZMQ_BUILD_DRAFT_API -// Callback function for ztrie_node to destroy node data. -typedef void (ztrie_destroy_data_fn) ( - void **data); - -// *** Draft method, for development use, may change without warning *** -// Creates a new ztrie. -CZMQ_EXPORT ztrie_t * - ztrie_new (char delimiter); - -// *** Draft method, for development use, may change without warning *** -// Destroy the ztrie. -CZMQ_EXPORT void - ztrie_destroy (ztrie_t **self_p); - -// *** Draft method, for development use, may change without warning *** -// Inserts a new route into the tree and attaches the data. Returns -1 -// if the route already exists, otherwise 0. This method takes ownership of -// the provided data if a destroy_data_fn is provided. -CZMQ_EXPORT int - ztrie_insert_route (ztrie_t *self, const char *path, void *data, ztrie_destroy_data_fn destroy_data_fn); - -// *** Draft method, for development use, may change without warning *** -// Removes a route from the trie and destroys its data. Returns -1 if the -// route does not exists, otherwise 0. -// the start of the list call zlist_first (). Advances the cursor. -CZMQ_EXPORT int - ztrie_remove_route (ztrie_t *self, const char *path); - -// *** Draft method, for development use, may change without warning *** -// Returns true if the path matches a route in the tree, otherwise false. -CZMQ_EXPORT bool - ztrie_matches (ztrie_t *self, const char *path); - -// *** Draft method, for development use, may change without warning *** -// Returns the data of a matched route from last ztrie_matches. If the path -// did not match, returns NULL. Do not delete the data as it's owned by -// ztrie. -CZMQ_EXPORT void * - ztrie_hit_data (ztrie_t *self); - -// *** Draft method, for development use, may change without warning *** -// Returns the count of parameters that a matched route has. -CZMQ_EXPORT size_t - ztrie_hit_parameter_count (ztrie_t *self); - -// *** Draft method, for development use, may change without warning *** -// Returns the parameters of a matched route with named regexes from last -// ztrie_matches. If the path did not match or the route did not contain any -// named regexes, returns NULL. -CZMQ_EXPORT zhashx_t * - ztrie_hit_parameters (ztrie_t *self); - -// *** Draft method, for development use, may change without warning *** -// Returns the asterisk matched part of a route, if there has been no match -// or no asterisk match, returns NULL. -CZMQ_EXPORT const char * - ztrie_hit_asterisk_match (ztrie_t *self); - -// *** Draft method, for development use, may change without warning *** -// Print the trie -CZMQ_EXPORT void - ztrie_print (ztrie_t *self); - -// *** Draft method, for development use, may change without warning *** -// Self test of this class. -CZMQ_EXPORT void - ztrie_test (bool verbose); - -#endif // CZMQ_BUILD_DRAFT_API -// @end - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/include/zuuid.h b/phonelibs/zmq/x64/include/zuuid.h deleted file mode 100644 index afc1104fea952b..00000000000000 --- a/phonelibs/zmq/x64/include/zuuid.h +++ /dev/null @@ -1,96 +0,0 @@ -/* ========================================================================= - zuuid - UUID support class - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of CZMQ, the high-level C binding for 0MQ: - http://czmq.zeromq.org. - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -#ifndef __ZUUID_H_INCLUDED__ -#define __ZUUID_H_INCLUDED__ - -#define ZUUID_LEN 16 -#define ZUUID_STR_LEN (ZUUID_LEN * 2) - -#ifdef __cplusplus -extern "C" { -#endif - -// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT -// @warning Please edit the model at "api/zuuid.api" to make changes. -// @interface -// This is a stable class, and may not change except for emergencies. It -// is provided in stable builds. -// Create a new UUID object. -CZMQ_EXPORT zuuid_t * - zuuid_new (void); - -// Create UUID object from supplied ZUUID_LEN-octet value. -CZMQ_EXPORT zuuid_t * - zuuid_new_from (const byte *source); - -// Destroy a specified UUID object. -CZMQ_EXPORT void - zuuid_destroy (zuuid_t **self_p); - -// Set UUID to new supplied ZUUID_LEN-octet value. -CZMQ_EXPORT void - zuuid_set (zuuid_t *self, const byte *source); - -// Set UUID to new supplied string value skipping '-' and '{' '}' -// optional delimiters. Return 0 if OK, else returns -1. -CZMQ_EXPORT int - zuuid_set_str (zuuid_t *self, const char *source); - -// Return UUID binary data. -CZMQ_EXPORT const byte * - zuuid_data (zuuid_t *self); - -// Return UUID binary size -CZMQ_EXPORT size_t - zuuid_size (zuuid_t *self); - -// Returns UUID as string -CZMQ_EXPORT const char * - zuuid_str (zuuid_t *self); - -// Return UUID in the canonical string format: 8-4-4-4-12, in lower -// case. Caller does not modify or free returned value. See -// http://en.wikipedia.org/wiki/Universally_unique_identifier -CZMQ_EXPORT const char * - zuuid_str_canonical (zuuid_t *self); - -// Store UUID blob in target array -CZMQ_EXPORT void - zuuid_export (zuuid_t *self, byte *target); - -// Check if UUID is same as supplied value -CZMQ_EXPORT bool - zuuid_eq (zuuid_t *self, const byte *compare); - -// Check if UUID is different from supplied value -CZMQ_EXPORT bool - zuuid_neq (zuuid_t *self, const byte *compare); - -// Make copy of UUID object; if uuid is null, or memory was exhausted, -// returns null. -CZMQ_EXPORT zuuid_t * - zuuid_dup (zuuid_t *self); - -// Self test of this class. -CZMQ_EXPORT void - zuuid_test (bool verbose); - -// @end - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/phonelibs/zmq/x64/lib/libczmq.a b/phonelibs/zmq/x64/lib/libczmq.a deleted file mode 100644 index 9045eb980eae46..00000000000000 Binary files a/phonelibs/zmq/x64/lib/libczmq.a and /dev/null differ diff --git a/phonelibs/zmq/x64/lib/libczmq.la b/phonelibs/zmq/x64/lib/libczmq.la deleted file mode 100755 index 8e4a9ee3645a65..00000000000000 --- a/phonelibs/zmq/x64/lib/libczmq.la +++ /dev/null @@ -1,41 +0,0 @@ -# libczmq.la - a libtool library file -# Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1 -# -# Please DO NOT delete this file! -# It is necessary for linking the library. - -# The name that we can dlopen(3). -dlname='libczmq.so.4' - -# Names of this library. -library_names='libczmq.so.4.0.2 libczmq.so.4 libczmq.so' - -# The name of the static archive. -old_library='libczmq.a' - -# Linker flags that can not go in dependency_libs. -inherited_linker_flags=' -pthread' - -# Libraries that this one depends upon. -dependency_libs=' -L/home/batman/one/external/zmq/lib -L/usr/local/lib /home/batman/one/external/zmq/lib/libzmq.la -lrt -lpthread -ldl' - -# Names of additional weak libraries provided by this library -weak_library_names='' - -# Version information for libczmq. -current=4 -age=0 -revision=2 - -# Is this an already installed library? -installed=yes - -# Should we warn about portability when linking against -modules? -shouldnotlink=no - -# Files to dlopen/dlpreopen -dlopen='' -dlpreopen='' - -# Directory that this library needs to be installed in: -libdir='/home/batman/one/external/zmq/lib' diff --git a/phonelibs/zmq/x64/lib/libczmq.so b/phonelibs/zmq/x64/lib/libczmq.so deleted file mode 120000 index db9aa60f9b5868..00000000000000 --- a/phonelibs/zmq/x64/lib/libczmq.so +++ /dev/null @@ -1 +0,0 @@ -libczmq.so.4.0.2 \ No newline at end of file diff --git a/phonelibs/zmq/x64/lib/libczmq.so.4 b/phonelibs/zmq/x64/lib/libczmq.so.4 deleted file mode 120000 index db9aa60f9b5868..00000000000000 --- a/phonelibs/zmq/x64/lib/libczmq.so.4 +++ /dev/null @@ -1 +0,0 @@ -libczmq.so.4.0.2 \ No newline at end of file diff --git a/phonelibs/zmq/x64/lib/libczmq.so.4.0.2 b/phonelibs/zmq/x64/lib/libczmq.so.4.0.2 deleted file mode 100755 index eaf4cce8b9c5f3..00000000000000 Binary files a/phonelibs/zmq/x64/lib/libczmq.so.4.0.2 and /dev/null differ diff --git a/phonelibs/zmq/x64/lib/libzmq.a b/phonelibs/zmq/x64/lib/libzmq.a deleted file mode 100644 index 28c77cc36e58ed..00000000000000 Binary files a/phonelibs/zmq/x64/lib/libzmq.a and /dev/null differ diff --git a/phonelibs/zmq/x64/lib/libzmq.la b/phonelibs/zmq/x64/lib/libzmq.la deleted file mode 100644 index 69652b3463048a..00000000000000 --- a/phonelibs/zmq/x64/lib/libzmq.la +++ /dev/null @@ -1,41 +0,0 @@ -# libzmq.la - a libtool library file -# Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-0.1 -# -# Please DO NOT delete this file! -# It is necessary for linking the library. - -# The name that we can dlopen(3). -dlname='libzmq.so.5' - -# Names of this library. -library_names='libzmq.so.5.1.2 libzmq.so.5 libzmq.so' - -# The name of the static archive. -old_library='libzmq.a' - -# Linker flags that cannot go in dependency_libs. -inherited_linker_flags='' - -# Libraries that this one depends upon. -dependency_libs=' -lrt -lpthread -ldl' - -# Names of additional weak libraries provided by this library -weak_library_names='' - -# Version information for libzmq. -current=6 -age=1 -revision=2 - -# Is this an already installed library? -installed=yes - -# Should we warn about portability when linking against -modules? -shouldnotlink=no - -# Files to dlopen/dlpreopen -dlopen='' -dlpreopen='' - -# Directory that this library needs to be installed in: -libdir='/home/batman/one/external/zmq/lib' diff --git a/phonelibs/zmq/x64/lib/libzmq.lai b/phonelibs/zmq/x64/lib/libzmq.lai deleted file mode 100644 index 93c1a83dc393ff..00000000000000 --- a/phonelibs/zmq/x64/lib/libzmq.lai +++ /dev/null @@ -1,41 +0,0 @@ -# libzmq.la - a libtool library file -# Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-0.1 -# -# Please DO NOT delete this file! -# It is necessary for linking the library. - -# The name that we can dlopen(3). -dlname='libzmq.so.5' - -# Names of this library. -library_names='libzmq.so.5.1.2 libzmq.so.5 libzmq.so' - -# The name of the static archive. -old_library='libzmq.a' - -# Linker flags that cannot go in dependency_libs. -inherited_linker_flags='' - -# Libraries that this one depends upon. -dependency_libs=' -lrt -lpthread -ldl' - -# Names of additional weak libraries provided by this library -weak_library_names='' - -# Version information for libzmq. -current=6 -age=1 -revision=2 - -# Is this an already installed library? -installed=yes - -# Should we warn about portability when linking against -modules? -shouldnotlink=no - -# Files to dlopen/dlpreopen -dlopen='' -dlpreopen='' - -# Directory that this library needs to be installed in: -libdir='/usr/local/lib' diff --git a/phonelibs/zmq/x64/lib/libzmq.so b/phonelibs/zmq/x64/lib/libzmq.so deleted file mode 120000 index ef44cafc6ac861..00000000000000 --- a/phonelibs/zmq/x64/lib/libzmq.so +++ /dev/null @@ -1 +0,0 @@ -libzmq.so.5.1.2 \ No newline at end of file diff --git a/phonelibs/zmq/x64/lib/libzmq.so.5 b/phonelibs/zmq/x64/lib/libzmq.so.5 deleted file mode 120000 index ef44cafc6ac861..00000000000000 --- a/phonelibs/zmq/x64/lib/libzmq.so.5 +++ /dev/null @@ -1 +0,0 @@ -libzmq.so.5.1.2 \ No newline at end of file diff --git a/phonelibs/zmq/x64/lib/libzmq.so.5.1.2 b/phonelibs/zmq/x64/lib/libzmq.so.5.1.2 deleted file mode 100755 index e08e8c2dfb47d7..00000000000000 Binary files a/phonelibs/zmq/x64/lib/libzmq.so.5.1.2 and /dev/null differ diff --git a/phonelibs/zmq/x64/lib/pkgconfig/libczmq.pc b/phonelibs/zmq/x64/lib/pkgconfig/libczmq.pc deleted file mode 100644 index b6fb3dc13322f6..00000000000000 --- a/phonelibs/zmq/x64/lib/pkgconfig/libczmq.pc +++ /dev/null @@ -1,24 +0,0 @@ -################################################################################ -# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # -# Read the zproject/README.md for information about making permanent changes. # -################################################################################ - -prefix=/home/batman/one/external/zmq -exec_prefix=${prefix} -libdir=${exec_prefix}/lib -includedir=${prefix}/include - -Name: libczmq -Description: The high-level C binding for 0MQ -Version: 4.0.2 - -Requires:libzmq - -Libs: -L${libdir} -lczmq -Cflags: -I${includedir} -Libs.private: -L/usr/local/lib -lzmq - -################################################################################ -# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # -# Read the zproject/README.md for information about making permanent changes. # -################################################################################ diff --git a/phonelibs/zmq/x64/lib/pkgconfig/libzmq.pc b/phonelibs/zmq/x64/lib/pkgconfig/libzmq.pc deleted file mode 100644 index aba3d3a75e09e3..00000000000000 --- a/phonelibs/zmq/x64/lib/pkgconfig/libzmq.pc +++ /dev/null @@ -1,10 +0,0 @@ -prefix=/home/batman/one/external/zmq -exec_prefix=${prefix} -libdir=${exec_prefix}/lib -includedir=${prefix}/include - -Name: libzmq -Description: 0MQ c++ library -Version: 4.2.2 -Libs: -L${libdir} -lzmq -Cflags: -I${includedir} diff --git a/pyextra/logentries/__init__.py b/pyextra/logentries/__init__.py deleted file mode 100644 index b64e423b8b7b3d..00000000000000 --- a/pyextra/logentries/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .utils import LogentriesHandler diff --git a/pyextra/logentries/helpers.py b/pyextra/logentries/helpers.py deleted file mode 100644 index bec676e22a9129..00000000000000 --- a/pyextra/logentries/helpers.py +++ /dev/null @@ -1,49 +0,0 @@ - -""" This file contains some helpers methods in both Python2 and 3 """ -import sys -import re - -if sys.version < '3': - # Python2.x imports - import Queue - import codecs -else: - # Python 3.x imports - import queue - - -def check_token(token): - """ Checks if the given token is a valid UUID.""" - valid = re.compile(r"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-" - r"[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$") - - return valid.match(token) - -# We need to do some things different pending if its Python 2.x or 3.x -if sys.version < '3': - def to_unicode(ch): - return codecs.unicode_escape_decode(ch)[0] - - def is_unicode(ch): - return isinstance(ch, unicode) - - def create_unicode(ch): - try: - return unicode(ch, 'utf-8') - except UnicodeDecodeError as e: - return str(e) - - def create_queue(max_size): - return Queue.Queue(max_size) -else: - def to_unicode(ch): - return ch - - def is_unicode(ch): - return isinstance(ch, str) - - def create_unicode(ch): - return str(ch) - - def create_queue(max_size): - return queue.Queue(max_size) diff --git a/pyextra/logentries/metrics.py b/pyextra/logentries/metrics.py deleted file mode 100644 index 03ddb6437493fc..00000000000000 --- a/pyextra/logentries/metrics.py +++ /dev/null @@ -1,57 +0,0 @@ -from logentries import LogentriesHandler -from threading import Lock -from functools import wraps -import logging -import time -import sys -import psutil - -glob_time = 0 -glob_name = 0 - -log = logging.getLogger('logentries') -log.setLevel(logging.INFO) - -class Metric(object): - - def __init__(self, token): - self._count = 0.0 - self._sum = 0.0 - self._lock = Lock() - self.token = token - handler = LogentriesHandler(token) - log.addHandler(handler) - - def observe(self, amount): - with self._lock: - self._count += 1 - self._sum += amount - - def metric(self): - '''Mesaure function execution time in seconds - and forward it to Logentries''' - - class Timer(object): - - def __init__(self, summary): - self._summary = summary - - def __enter__(self): - self._start = time.time() - - def __exit__(self, typ, value, traceback): - global glob_time - self._summary.observe(max(time.time() - self._start, 0)) - glob_time = time.time()- self._start - log.info("function_name=" + glob_name + " " + "execution_time=" + str(glob_time) + " " + "cpu=" + str(psutil.cpu_percent(interval=None)) + " " + "cpu_count=" + str(psutil.cpu_count())+ " " + "memory=" + str(psutil.virtual_memory()) ) - - def __call__(self, f): - @wraps(f) - def wrapped(*args, **kwargs): - with self: - global glob_name - glob_name = f.__name__ - - return f(*args, **kwargs) - return wrapped - return Timer(self) diff --git a/pyextra/logentries/utils.py b/pyextra/logentries/utils.py deleted file mode 100644 index c17a1070cdb9e8..00000000000000 --- a/pyextra/logentries/utils.py +++ /dev/null @@ -1,218 +0,0 @@ -# coding: utf-8 -# vim: set ts=4 sw=4 et: -""" This file contains some utils for connecting to Logentries - as well as storing logs in a queue and sending them.""" - -VERSION = '2.0.7' - -from logentries import helpers as le_helpers - -import logging -import threading -import socket -import random -import time -import sys - -import certifi - - -# Size of the internal event queue -QUEUE_SIZE = 32768 -# Logentries API server address -LE_API_DEFAULT = "data.logentries.com" -# Port number for token logging to Logentries API server -LE_PORT_DEFAULT = 80 -LE_TLS_PORT_DEFAULT = 443 -# Minimal delay between attempts to reconnect in seconds -MIN_DELAY = 0.1 -# Maximal delay between attempts to recconect in seconds -MAX_DELAY = 10 -# Unicode Line separator character \u2028 -LINE_SEP = le_helpers.to_unicode('\u2028') - - -# LE appender signature - used for debugging messages -LE = "LE: " -# Error message displayed when an incorrect Token has been detected -INVALID_TOKEN = ("\n\nIt appears the LOGENTRIES_TOKEN " - "parameter you entered is incorrect!\n\n") - - -def dbg(msg): - print(LE + msg) - - -class PlainTextSocketAppender(threading.Thread): - def __init__(self, verbose=True, le_api=LE_API_DEFAULT, le_port=LE_PORT_DEFAULT, le_tls_port=LE_TLS_PORT_DEFAULT): - threading.Thread.__init__(self) - - # Logentries API server address - self.le_api = le_api - - # Port number for token logging to Logentries API server - self.le_port = le_port - self.le_tls_port = le_tls_port - - self.daemon = True - self.verbose = verbose - self._conn = None - self._queue = le_helpers.create_queue(QUEUE_SIZE) - - def empty(self): - return self._queue.empty() - - def open_connection(self): - self._conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self._conn.connect((self.le_api, self.le_port)) - - def reopen_connection(self): - self.close_connection() - - root_delay = MIN_DELAY - while True: - try: - self.open_connection() - return - except Exception: - if self.verbose: - dbg("Unable to connect to Logentries") - - root_delay *= 2 - if(root_delay > MAX_DELAY): - root_delay = MAX_DELAY - - wait_for = root_delay + random.uniform(0, root_delay) - - try: - time.sleep(wait_for) - except KeyboardInterrupt: - raise - - def close_connection(self): - if self._conn is not None: - self._conn.close() - - def run(self): - try: - # Open connection - self.reopen_connection() - - # Send data in queue - while True: - # Take data from queue - data = self._queue.get(block=True) - - # Replace newlines with Unicode line separator - # for multi-line events - if not le_helpers.is_unicode(data): - multiline = le_helpers.create_unicode(data).replace( - '\n', LINE_SEP) - else: - multiline = data.replace('\n', LINE_SEP) - multiline += "\n" - # Send data, reconnect if needed - while True: - try: - self._conn.send(multiline.encode('utf-8')) - except socket.error: - self.reopen_connection() - continue - break - except KeyboardInterrupt: - if self.verbose: - dbg("Logentries asynchronous socket client interrupted") - - self.close_connection() - -SocketAppender = PlainTextSocketAppender - -try: - import ssl - ssl_enabled = True -except ImportError: # for systems without TLS support. - ssl_enabled = False - dbg("Unable to import ssl module. Will send over port 80.") -else: - class TLSSocketAppender(PlainTextSocketAppender): - - def open_connection(self): - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sock = ssl.wrap_socket( - sock=sock, - keyfile=None, - certfile=None, - server_side=False, - cert_reqs=ssl.CERT_REQUIRED, - ssl_version=getattr( - ssl, - 'PROTOCOL_TLSv1_2', - ssl.PROTOCOL_TLSv1 - ), - ca_certs=certifi.where(), - do_handshake_on_connect=True, - suppress_ragged_eofs=True, - ) - - sock.connect((self.le_api, self.le_tls_port)) - self._conn = sock - - -class LogentriesHandler(logging.Handler): - def __init__(self, token, use_tls=True, verbose=True, format=None, le_api=LE_API_DEFAULT, le_port=LE_PORT_DEFAULT, le_tls_port=LE_TLS_PORT_DEFAULT): - logging.Handler.__init__(self) - self.token = token - self.good_config = True - self.verbose = verbose - # give the socket 10 seconds to flush, - # otherwise drop logs - self.timeout = 10 - if not le_helpers.check_token(token): - if self.verbose: - dbg(INVALID_TOKEN) - self.good_config = False - if format is None: - format = logging.Formatter('%(asctime)s : %(levelname)s, %(message)s', - '%a %b %d %H:%M:%S %Z %Y') - self.setFormatter(format) - self.setLevel(logging.DEBUG) - if use_tls and ssl_enabled: - self._thread = TLSSocketAppender(verbose=verbose, le_api=le_api, le_port=le_port, le_tls_port=le_tls_port) - else: - self._thread = SocketAppender(verbose=verbose, le_api=le_api, le_port=le_port, le_tls_port=le_tls_port) - - def flush(self): - # wait for all queued logs to be send - now = time.time() - while not self._thread.empty(): - time.sleep(0.2) - if time.time() - now > self.timeout: - break - - def emit_raw(self, msg): - if self.good_config and not self._thread.is_alive(): - try: - self._thread.start() - if self.verbose: - dbg("Starting Logentries Asynchronous Socket Appender") - except RuntimeError: # It's already started. - pass - - msg = self.token + msg - try: - self._thread._queue.put_nowait(msg) - except Exception: - # Queue is full, try to remove the oldest message and put again - try: - self._thread._queue.get_nowait() - self._thread._queue.put_nowait(msg) - except Exception: - # Race condition, no need for any action here - pass - - def emit(self, record): - msg = self.format(record).rstrip('\n') - self.emit_raw(msg) - - def close(self): - logging.Handler.close(self) diff --git a/pyextra/overpy/__about__.py b/pyextra/overpy/__about__.py deleted file mode 100644 index 33c6c493c8aef6..00000000000000 --- a/pyextra/overpy/__about__.py +++ /dev/null @@ -1,22 +0,0 @@ -__all__ = [ - "__author__", - "__copyright__", - "__email__", - "__license__", - "__summary__", - "__title__", - "__uri__", - "__version__", -] - -__title__ = "overpy" -__summary__ = "Python Wrapper to access the OpenStreepMap Overpass API" -__uri__ = "https://github.com/DinoTools/python-overpy" - -__version__ = "0.4" - -__author__ = "PhiBo (DinoTools)" -__email__ = "" - -__license__ = "MIT" -__copyright__ = "Copyright 2014-2016 %s" % __author__ diff --git a/pyextra/overpy/__init__.py b/pyextra/overpy/__init__.py deleted file mode 100644 index 2836080ab7d017..00000000000000 --- a/pyextra/overpy/__init__.py +++ /dev/null @@ -1,1619 +0,0 @@ -from collections import OrderedDict -from datetime import datetime -from decimal import Decimal -from xml.sax import handler, make_parser -import json -import re -import sys -import time -import requests - -from overpy import exception -from overpy.__about__ import ( - __author__, __copyright__, __email__, __license__, __summary__, __title__, - __uri__, __version__ -) - -PY2 = sys.version_info[0] == 2 -PY3 = sys.version_info[0] == 3 - -XML_PARSER_DOM = 1 -XML_PARSER_SAX = 2 - -# Try to convert some common attributes -# http://wiki.openstreetmap.org/wiki/Elements#Common_attributes -GLOBAL_ATTRIBUTE_MODIFIERS = { - "changeset": int, - "timestamp": lambda ts: datetime.strptime(ts, "%Y-%m-%dT%H:%M:%SZ"), - "uid": int, - "version": int, - "visible": lambda v: v.lower() == "true" -} - - -def is_valid_type(element, cls): - """ - Test if an element is of a given type. - - :param Element() element: The element instance to test - :param Element cls: The element class to test - :return: False or True - :rtype: Boolean - """ - return isinstance(element, cls) and element.id is not None - - -class Overpass(object): - """ - Class to access the Overpass API - - :cvar default_max_retry_count: Global max number of retries (Default: 0) - :cvar default_retry_timeout: Global time to wait between tries (Default: 1.0s) - """ - default_max_retry_count = 0 - default_read_chunk_size = 4096 - default_retry_timeout = 1.0 - default_url = "http://overpass-api.de/api/interpreter" - - def __init__(self, read_chunk_size=None, url=None, xml_parser=XML_PARSER_SAX, max_retry_count=None, retry_timeout=None, timeout=5.0, headers=None): - """ - :param read_chunk_size: Max size of each chunk read from the server response - :type read_chunk_size: Integer - :param url: Optional URL of the Overpass server. Defaults to http://overpass-api.de/api/interpreter - :type url: str - :param xml_parser: The xml parser to use - :type xml_parser: Integer - :param max_retry_count: Max number of retries (Default: default_max_retry_count) - :type max_retry_count: Integer - :param retry_timeout: Time to wait between tries (Default: default_retry_timeout) - :type retry_timeout: float - :param timeout: HTTP request timeout - :type timeout: float - :param headers: HTTP request headers - :type headers: dict - """ - self.url = self.default_url - if url is not None: - self.url = url - - self._regex_extract_error_msg = re.compile(b"\(?P\") - self._regex_remove_tag = re.compile(b"<[^>]*?>") - if read_chunk_size is None: - read_chunk_size = self.default_read_chunk_size - self.read_chunk_size = read_chunk_size - - if max_retry_count is None: - max_retry_count = self.default_max_retry_count - self.max_retry_count = max_retry_count - - if retry_timeout is None: - retry_timeout = self.default_retry_timeout - self.retry_timeout = retry_timeout - - self.xml_parser = xml_parser - self.timeout = timeout - self.headers = headers - - def _handle_remark_msg(self, msg): - """ - Try to parse the message provided with the remark tag or element. - - :param str msg: The message - :raises overpy.exception.OverpassRuntimeError: If message starts with 'runtime error:' - :raises overpy.exception.OverpassRuntimeRemark: If message starts with 'runtime remark:' - :raises overpy.exception.OverpassUnknownError: If we are unable to identify the error - """ - msg = msg.strip() - if msg.startswith("runtime error:"): - raise exception.OverpassRuntimeError(msg=msg) - elif msg.startswith("runtime remark:"): - raise exception.OverpassRuntimeRemark(msg=msg) - raise exception.OverpassUnknownError(msg=msg) - - def query(self, query): - """ - Query the Overpass API - - :param String|Bytes query: The query string in Overpass QL - :return: The parsed result - :rtype: overpy.Result - """ - if not isinstance(query, bytes): - query = query.encode("utf-8") - - retry_num = 0 - retry_exceptions = [] - do_retry = True if self.max_retry_count > 0 else False - while retry_num <= self.max_retry_count: - if retry_num > 0: - time.sleep(self.retry_timeout) - retry_num += 1 - - try: - if self.headers is not None: - r = requests.post(self.url, query, timeout=self.timeout, headers=self.headers) - else: - r = requests.post(self.url, query, timeout=self.timeout) - response = r.content - except (requests.exceptions.BaseHTTPError, requests.exceptions.RequestException) as e: - if not do_retry: - raise e - retry_exceptions.append(e) - continue - - if r.status_code == 200: - content_type = r.headers["Content-Type"] - - if content_type == "application/json": - return self.parse_json(response) - - if content_type == "application/osm3s+xml": - return self.parse_xml(response) - - e = exception.OverpassUnknownContentType(content_type) - if not do_retry: - raise e - retry_exceptions.append(e) - continue - elif r.status_code == 400: - msgs = [] - for msg in self._regex_extract_error_msg.finditer(response): - tmp = self._regex_remove_tag.sub(b"", msg.group("msg")) - try: - tmp = tmp.decode("utf-8") - except UnicodeDecodeError: - tmp = repr(tmp) - msgs.append(tmp) - - e = exception.OverpassBadRequest( - query, - msgs=msgs - ) - if not do_retry: - raise e - retry_exceptions.append(e) - continue - elif r.status_code == 429: - e = exception.OverpassTooManyRequests - if not do_retry: - raise e - retry_exceptions.append(e) - continue - elif r.status_code == 504: - e = exception.OverpassGatewayTimeout - if not do_retry: - raise e - retry_exceptions.append(e) - continue - - # No valid response code - e = exception.OverpassUnknownHTTPStatusCode(r.status_code) - if not do_retry: - raise e - retry_exceptions.append(e) - continue - - raise exception.MaxRetriesReached(retry_count=retry_num, exceptions=retry_exceptions) - - def parse_json(self, data, encoding="utf-8"): - """ - Parse raw response from Overpass service. - - :param data: Raw JSON Data - :type data: String or Bytes - :param encoding: Encoding to decode byte string - :type encoding: String - :return: Result object - :rtype: overpy.Result - """ - if isinstance(data, bytes): - data = data.decode(encoding) - - data = json.loads(data, parse_float=Decimal) - if "remark" in data: - self._handle_remark_msg(msg=data.get("remark")) - return Result.from_json(data, api=self) - - def parse_xml(self, data, encoding="utf-8", parser=None): - """ - - :param data: Raw XML Data - :type data: String or Bytes - :param encoding: Encoding to decode byte string - :type encoding: String - :return: Result object - :rtype: overpy.Result - """ - if parser is None: - parser = self.xml_parser - if isinstance(data, bytes): - data = data.decode(encoding) - if PY2 and not isinstance(data, str): - # Python 2.x: Convert unicode strings - data = data.encode(encoding) - - m = re.compile("(?P[^<>]*)").search(data) - if m: - self._handle_remark_msg(m.group("msg")) - - return Result.from_xml(data, api=self, parser=parser) - - -class Result(object): - """ - Class to handle the result. - """ - - def __init__(self, elements=None, api=None): - """ - - :param List elements: - :param api: - :type api: overpy.Overpass - """ - if elements is None: - elements = [] - self._areas = OrderedDict((element.id, element) for element in elements if is_valid_type(element, Area)) - self._nodes = OrderedDict((element.id, element) for element in elements if is_valid_type(element, Node)) - self._ways = OrderedDict((element.id, element) for element in elements if is_valid_type(element, Way)) - self._relations = OrderedDict((element.id, element) - for element in elements if is_valid_type(element, Relation)) - self._class_collection_map = {Node: self._nodes, Way: self._ways, Relation: self._relations, Area: self._areas} - self.api = api - - def expand(self, other): - """ - Add all elements from an other result to the list of elements of this result object. - - It is used by the auto resolve feature. - - :param other: Expand the result with the elements from this result. - :type other: overpy.Result - :raises ValueError: If provided parameter is not instance of :class:`overpy.Result` - """ - if not isinstance(other, Result): - raise ValueError("Provided argument has to be instance of overpy:Result()") - - other_collection_map = {Node: other.nodes, Way: other.ways, Relation: other.relations, Area: other.areas} - for element_type, own_collection in self._class_collection_map.items(): - for element in other_collection_map[element_type]: - if is_valid_type(element, element_type) and element.id not in own_collection: - own_collection[element.id] = element - - def append(self, element): - """ - Append a new element to the result. - - :param element: The element to append - :type element: overpy.Element - """ - if is_valid_type(element, Element): - self._class_collection_map[element.__class__].setdefault(element.id, element) - - def get_elements(self, filter_cls, elem_id=None): - """ - Get a list of elements from the result and filter the element type by a class. - - :param filter_cls: - :param elem_id: ID of the object - :type elem_id: Integer - :return: List of available elements - :rtype: List - """ - result = [] - if elem_id is not None: - try: - result = [self._class_collection_map[filter_cls][elem_id]] - except KeyError: - result = [] - else: - for e in self._class_collection_map[filter_cls].values(): - result.append(e) - return result - - def get_ids(self, filter_cls): - """ - - :param filter_cls: - :return: - """ - return list(self._class_collection_map[filter_cls].keys()) - - def get_node_ids(self): - return self.get_ids(filter_cls=Node) - - def get_way_ids(self): - return self.get_ids(filter_cls=Way) - - def get_relation_ids(self): - return self.get_ids(filter_cls=Relation) - - def get_area_ids(self): - return self.get_ids(filter_cls=Area) - - @classmethod - def from_json(cls, data, api=None): - """ - Create a new instance and load data from json object. - - :param data: JSON data returned by the Overpass API - :type data: Dict - :param api: - :type api: overpy.Overpass - :return: New instance of Result object - :rtype: overpy.Result - """ - result = cls(api=api) - for elem_cls in [Node, Way, Relation, Area]: - for element in data.get("elements", []): - e_type = element.get("type") - if hasattr(e_type, "lower") and e_type.lower() == elem_cls._type_value: - result.append(elem_cls.from_json(element, result=result)) - - return result - - @classmethod - def from_xml(cls, data, api=None, parser=None): - """ - Create a new instance and load data from xml data or object. - - .. note:: - If parser is set to None, the functions tries to find the best parse. - By default the SAX parser is chosen if a string is provided as data. - The parser is set to DOM if an xml.etree.ElementTree.Element is provided as data value. - - :param data: Root element - :type data: str | xml.etree.ElementTree.Element - :param api: The instance to query additional information if required. - :type api: Overpass - :param parser: Specify the parser to use(DOM or SAX)(Default: None = autodetect, defaults to SAX) - :type parser: Integer | None - :return: New instance of Result object - :rtype: Result - """ - if parser is None: - if isinstance(data, str): - parser = XML_PARSER_SAX - else: - parser = XML_PARSER_DOM - - result = cls(api=api) - if parser == XML_PARSER_DOM: - import xml.etree.ElementTree as ET - if isinstance(data, str): - root = ET.fromstring(data) - elif isinstance(data, ET.Element): - root = data - else: - raise exception.OverPyException("Unable to detect data type.") - - for elem_cls in [Node, Way, Relation, Area]: - for child in root: - if child.tag.lower() == elem_cls._type_value: - result.append(elem_cls.from_xml(child, result=result)) - - elif parser == XML_PARSER_SAX: - if PY2: - from StringIO import StringIO - else: - from io import StringIO - source = StringIO(data) - sax_handler = OSMSAXHandler(result) - parser = make_parser() - parser.setContentHandler(sax_handler) - parser.parse(source) - else: - # ToDo: better exception - raise Exception("Unknown XML parser") - return result - - def get_area(self, area_id, resolve_missing=False): - """ - Get an area by its ID. - - :param area_id: The area ID - :type area_id: Integer - :param resolve_missing: Query the Overpass API if the area is missing in the result set. - :return: The area - :rtype: overpy.Area - :raises overpy.exception.DataIncomplete: The requested way is not available in the result cache. - :raises overpy.exception.DataIncomplete: If resolve_missing is True and the area can't be resolved. - """ - areas = self.get_areas(area_id=area_id) - if len(areas) == 0: - if resolve_missing is False: - raise exception.DataIncomplete("Resolve missing area is disabled") - - query = ("\n" - "[out:json];\n" - "area({area_id});\n" - "out body;\n" - ) - query = query.format( - area_id=area_id - ) - tmp_result = self.api.query(query) - self.expand(tmp_result) - - areas = self.get_areas(area_id=area_id) - - if len(areas) == 0: - raise exception.DataIncomplete("Unable to resolve requested areas") - - return areas[0] - - def get_areas(self, area_id=None, **kwargs): - """ - Alias for get_elements() but filter the result by Area - - :param area_id: The Id of the area - :type area_id: Integer - :return: List of elements - """ - return self.get_elements(Area, elem_id=area_id, **kwargs) - - def get_node(self, node_id, resolve_missing=False): - """ - Get a node by its ID. - - :param node_id: The node ID - :type node_id: Integer - :param resolve_missing: Query the Overpass API if the node is missing in the result set. - :return: The node - :rtype: overpy.Node - :raises overpy.exception.DataIncomplete: At least one referenced node is not available in the result cache. - :raises overpy.exception.DataIncomplete: If resolve_missing is True and at least one node can't be resolved. - """ - nodes = self.get_nodes(node_id=node_id) - if len(nodes) == 0: - if not resolve_missing: - raise exception.DataIncomplete("Resolve missing nodes is disabled") - - query = ("\n" - "[out:json];\n" - "node({node_id});\n" - "out body;\n" - ) - query = query.format( - node_id=node_id - ) - tmp_result = self.api.query(query) - self.expand(tmp_result) - - nodes = self.get_nodes(node_id=node_id) - - if len(nodes) == 0: - raise exception.DataIncomplete("Unable to resolve all nodes") - - return nodes[0] - - def get_nodes(self, node_id=None, **kwargs): - """ - Alias for get_elements() but filter the result by Node() - - :param node_id: The Id of the node - :type node_id: Integer - :return: List of elements - """ - return self.get_elements(Node, elem_id=node_id, **kwargs) - - def get_relation(self, rel_id, resolve_missing=False): - """ - Get a relation by its ID. - - :param rel_id: The relation ID - :type rel_id: Integer - :param resolve_missing: Query the Overpass API if the relation is missing in the result set. - :return: The relation - :rtype: overpy.Relation - :raises overpy.exception.DataIncomplete: The requested relation is not available in the result cache. - :raises overpy.exception.DataIncomplete: If resolve_missing is True and the relation can't be resolved. - """ - relations = self.get_relations(rel_id=rel_id) - if len(relations) == 0: - if resolve_missing is False: - raise exception.DataIncomplete("Resolve missing relations is disabled") - - query = ("\n" - "[out:json];\n" - "relation({relation_id});\n" - "out body;\n" - ) - query = query.format( - relation_id=rel_id - ) - tmp_result = self.api.query(query) - self.expand(tmp_result) - - relations = self.get_relations(rel_id=rel_id) - - if len(relations) == 0: - raise exception.DataIncomplete("Unable to resolve requested reference") - - return relations[0] - - def get_relations(self, rel_id=None, **kwargs): - """ - Alias for get_elements() but filter the result by Relation - - :param rel_id: Id of the relation - :type rel_id: Integer - :return: List of elements - """ - return self.get_elements(Relation, elem_id=rel_id, **kwargs) - - def get_way(self, way_id, resolve_missing=False): - """ - Get a way by its ID. - - :param way_id: The way ID - :type way_id: Integer - :param resolve_missing: Query the Overpass API if the way is missing in the result set. - :return: The way - :rtype: overpy.Way - :raises overpy.exception.DataIncomplete: The requested way is not available in the result cache. - :raises overpy.exception.DataIncomplete: If resolve_missing is True and the way can't be resolved. - """ - ways = self.get_ways(way_id=way_id) - if len(ways) == 0: - if resolve_missing is False: - raise exception.DataIncomplete("Resolve missing way is disabled") - - query = ("\n" - "[out:json];\n" - "way({way_id});\n" - "out body;\n" - ) - query = query.format( - way_id=way_id - ) - tmp_result = self.api.query(query) - self.expand(tmp_result) - - ways = self.get_ways(way_id=way_id) - - if len(ways) == 0: - raise exception.DataIncomplete("Unable to resolve requested way") - - return ways[0] - - def get_ways(self, way_id=None, **kwargs): - """ - Alias for get_elements() but filter the result by Way - - :param way_id: The Id of the way - :type way_id: Integer - :return: List of elements - """ - return self.get_elements(Way, elem_id=way_id, **kwargs) - - area_ids = property(get_area_ids) - areas = property(get_areas) - node_ids = property(get_node_ids) - nodes = property(get_nodes) - relation_ids = property(get_relation_ids) - relations = property(get_relations) - way_ids = property(get_way_ids) - ways = property(get_ways) - - -class Element(object): - """ - Base element - """ - - def __init__(self, attributes=None, result=None, tags=None): - """ - :param attributes: Additional attributes - :type attributes: Dict - :param result: The result object this element belongs to - :param tags: List of tags - :type tags: Dict - """ - - self._result = result - self.attributes = attributes - # ToDo: Add option to modify attribute modifiers - attribute_modifiers = dict(GLOBAL_ATTRIBUTE_MODIFIERS.items()) - for n, m in attribute_modifiers.items(): - if n in self.attributes: - self.attributes[n] = m(self.attributes[n]) - self.id = None - self.tags = tags - - @classmethod - def get_center_from_json(cls, data): - """ - Get center information from json data - - :param data: json data - :return: tuple with two elements: lat and lon - :rtype: tuple - """ - center_lat = None - center_lon = None - center = data.get("center") - if isinstance(center, dict): - center_lat = center.get("lat") - center_lon = center.get("lon") - if center_lat is None or center_lon is None: - raise ValueError("Unable to get lat or lon of way center.") - center_lat = Decimal(center_lat) - center_lon = Decimal(center_lon) - return (center_lat, center_lon) - - @classmethod - def get_center_from_xml_dom(cls, sub_child): - center_lat = sub_child.attrib.get("lat") - center_lon = sub_child.attrib.get("lon") - if center_lat is None or center_lon is None: - raise ValueError("Unable to get lat or lon of way center.") - center_lat = Decimal(center_lat) - center_lon = Decimal(center_lon) - return center_lat, center_lon - - -class Area(Element): - """ - Class to represent an element of type area - """ - - _type_value = "area" - - def __init__(self, area_id=None, **kwargs): - """ - :param area_id: Id of the area element - :type area_id: Integer - :param kwargs: Additional arguments are passed directly to the parent class - - """ - - Element.__init__(self, **kwargs) - #: The id of the way - self.id = area_id - - def __repr__(self): - return "".format(self.id) - - @classmethod - def from_json(cls, data, result=None): - """ - Create new Area element from JSON data - - :param data: Element data from JSON - :type data: Dict - :param result: The result this element belongs to - :type result: overpy.Result - :return: New instance of Way - :rtype: overpy.Area - :raises overpy.exception.ElementDataWrongType: If type value of the passed JSON data does not match. - """ - if data.get("type") != cls._type_value: - raise exception.ElementDataWrongType( - type_expected=cls._type_value, - type_provided=data.get("type") - ) - - tags = data.get("tags", {}) - - area_id = data.get("id") - - attributes = {} - ignore = ["id", "tags", "type"] - for n, v in data.items(): - if n in ignore: - continue - attributes[n] = v - - return cls(area_id=area_id, attributes=attributes, tags=tags, result=result) - - @classmethod - def from_xml(cls, child, result=None): - """ - Create new way element from XML data - - :param child: XML node to be parsed - :type child: xml.etree.ElementTree.Element - :param result: The result this node belongs to - :type result: overpy.Result - :return: New Way oject - :rtype: overpy.Way - :raises overpy.exception.ElementDataWrongType: If name of the xml child node doesn't match - :raises ValueError: If the ref attribute of the xml node is not provided - :raises ValueError: If a tag doesn't have a name - """ - if child.tag.lower() != cls._type_value: - raise exception.ElementDataWrongType( - type_expected=cls._type_value, - type_provided=child.tag.lower() - ) - - tags = {} - - for sub_child in child: - if sub_child.tag.lower() == "tag": - name = sub_child.attrib.get("k") - if name is None: - raise ValueError("Tag without name/key.") - value = sub_child.attrib.get("v") - tags[name] = value - - area_id = child.attrib.get("id") - if area_id is not None: - area_id = int(area_id) - - attributes = {} - ignore = ["id"] - for n, v in child.attrib.items(): - if n in ignore: - continue - attributes[n] = v - - return cls(area_id=area_id, attributes=attributes, tags=tags, result=result) - - -class Node(Element): - """ - Class to represent an element of type node - """ - - _type_value = "node" - - def __init__(self, node_id=None, lat=None, lon=None, **kwargs): - """ - :param lat: Latitude - :type lat: Decimal or Float - :param lon: Longitude - :type long: Decimal or Float - :param node_id: Id of the node element - :type node_id: Integer - :param kwargs: Additional arguments are passed directly to the parent class - """ - - Element.__init__(self, **kwargs) - self.id = node_id - self.lat = lat - self.lon = lon - - def __repr__(self): - return "".format(self.id, self.lat, self.lon) - - @classmethod - def from_json(cls, data, result=None): - """ - Create new Node element from JSON data - - :param data: Element data from JSON - :type data: Dict - :param result: The result this element belongs to - :type result: overpy.Result - :return: New instance of Node - :rtype: overpy.Node - :raises overpy.exception.ElementDataWrongType: If type value of the passed JSON data does not match. - """ - if data.get("type") != cls._type_value: - raise exception.ElementDataWrongType( - type_expected=cls._type_value, - type_provided=data.get("type") - ) - - tags = data.get("tags", {}) - - node_id = data.get("id") - lat = data.get("lat") - lon = data.get("lon") - - attributes = {} - ignore = ["type", "id", "lat", "lon", "tags"] - for n, v in data.items(): - if n in ignore: - continue - attributes[n] = v - - return cls(node_id=node_id, lat=lat, lon=lon, tags=tags, attributes=attributes, result=result) - - @classmethod - def from_xml(cls, child, result=None): - """ - Create new way element from XML data - - :param child: XML node to be parsed - :type child: xml.etree.ElementTree.Element - :param result: The result this node belongs to - :type result: overpy.Result - :return: New Way oject - :rtype: overpy.Node - :raises overpy.exception.ElementDataWrongType: If name of the xml child node doesn't match - :raises ValueError: If a tag doesn't have a name - """ - if child.tag.lower() != cls._type_value: - raise exception.ElementDataWrongType( - type_expected=cls._type_value, - type_provided=child.tag.lower() - ) - - tags = {} - - for sub_child in child: - if sub_child.tag.lower() == "tag": - name = sub_child.attrib.get("k") - if name is None: - raise ValueError("Tag without name/key.") - value = sub_child.attrib.get("v") - tags[name] = value - - node_id = child.attrib.get("id") - if node_id is not None: - node_id = int(node_id) - lat = child.attrib.get("lat") - if lat is not None: - lat = Decimal(lat) - lon = child.attrib.get("lon") - if lon is not None: - lon = Decimal(lon) - - attributes = {} - ignore = ["id", "lat", "lon"] - for n, v in child.attrib.items(): - if n in ignore: - continue - attributes[n] = v - - return cls(node_id=node_id, lat=lat, lon=lon, tags=tags, attributes=attributes, result=result) - - -class Way(Element): - """ - Class to represent an element of type way - """ - - _type_value = "way" - - def __init__(self, way_id=None, center_lat=None, center_lon=None, node_ids=None, **kwargs): - """ - :param node_ids: List of node IDs - :type node_ids: List or Tuple - :param way_id: Id of the way element - :type way_id: Integer - :param kwargs: Additional arguments are passed directly to the parent class - - """ - - Element.__init__(self, **kwargs) - #: The id of the way - self.id = way_id - - #: List of Ids of the associated nodes - self._node_ids = node_ids - - #: The lat/lon of the center of the way (optional depending on query) - self.center_lat = center_lat - self.center_lon = center_lon - - def __repr__(self): - return "".format(self.id, self._node_ids) - - @property - def nodes(self): - """ - List of nodes associated with the way. - """ - return self.get_nodes() - - def get_nodes(self, resolve_missing=False): - """ - Get the nodes defining the geometry of the way - - :param resolve_missing: Try to resolve missing nodes. - :type resolve_missing: Boolean - :return: List of nodes - :rtype: List of overpy.Node - :raises overpy.exception.DataIncomplete: At least one referenced node is not available in the result cache. - :raises overpy.exception.DataIncomplete: If resolve_missing is True and at least one node can't be resolved. - """ - result = [] - resolved = False - - for node_id in self._node_ids: - try: - node = self._result.get_node(node_id) - except exception.DataIncomplete: - node = None - - if node is not None: - result.append(node) - continue - - if not resolve_missing: - raise exception.DataIncomplete("Resolve missing nodes is disabled") - - # We tried to resolve the data but some nodes are still missing - if resolved: - raise exception.DataIncomplete("Unable to resolve all nodes") - - query = ("\n" - "[out:json];\n" - "way({way_id});\n" - "node(w);\n" - "out body;\n" - ) - query = query.format( - way_id=self.id - ) - tmp_result = self._result.api.query(query) - self._result.expand(tmp_result) - resolved = True - - try: - node = self._result.get_node(node_id) - except exception.DataIncomplete: - node = None - - if node is None: - raise exception.DataIncomplete("Unable to resolve all nodes") - - result.append(node) - - return result - - @classmethod - def from_json(cls, data, result=None): - """ - Create new Way element from JSON data - - :param data: Element data from JSON - :type data: Dict - :param result: The result this element belongs to - :type result: overpy.Result - :return: New instance of Way - :rtype: overpy.Way - :raises overpy.exception.ElementDataWrongType: If type value of the passed JSON data does not match. - """ - if data.get("type") != cls._type_value: - raise exception.ElementDataWrongType( - type_expected=cls._type_value, - type_provided=data.get("type") - ) - - tags = data.get("tags", {}) - - way_id = data.get("id") - node_ids = data.get("nodes") - (center_lat, center_lon) = cls.get_center_from_json(data=data) - - attributes = {} - ignore = ["center", "id", "nodes", "tags", "type"] - for n, v in data.items(): - if n in ignore: - continue - attributes[n] = v - - return cls( - attributes=attributes, - center_lat=center_lat, - center_lon=center_lon, - node_ids=node_ids, - tags=tags, - result=result, - way_id=way_id - ) - - @classmethod - def from_xml(cls, child, result=None): - """ - Create new way element from XML data - - :param child: XML node to be parsed - :type child: xml.etree.ElementTree.Element - :param result: The result this node belongs to - :type result: overpy.Result - :return: New Way oject - :rtype: overpy.Way - :raises overpy.exception.ElementDataWrongType: If name of the xml child node doesn't match - :raises ValueError: If the ref attribute of the xml node is not provided - :raises ValueError: If a tag doesn't have a name - """ - if child.tag.lower() != cls._type_value: - raise exception.ElementDataWrongType( - type_expected=cls._type_value, - type_provided=child.tag.lower() - ) - - tags = {} - node_ids = [] - center_lat = None - center_lon = None - - for sub_child in child: - if sub_child.tag.lower() == "tag": - name = sub_child.attrib.get("k") - if name is None: - raise ValueError("Tag without name/key.") - value = sub_child.attrib.get("v") - tags[name] = value - if sub_child.tag.lower() == "nd": - ref_id = sub_child.attrib.get("ref") - if ref_id is None: - raise ValueError("Unable to find required ref value.") - ref_id = int(ref_id) - node_ids.append(ref_id) - if sub_child.tag.lower() == "center": - (center_lat, center_lon) = cls.get_center_from_xml_dom(sub_child=sub_child) - - way_id = child.attrib.get("id") - if way_id is not None: - way_id = int(way_id) - - attributes = {} - ignore = ["id"] - for n, v in child.attrib.items(): - if n in ignore: - continue - attributes[n] = v - - return cls(way_id=way_id, center_lat=center_lat, center_lon=center_lon, - attributes=attributes, node_ids=node_ids, tags=tags, result=result) - - -class Relation(Element): - """ - Class to represent an element of type relation - """ - - _type_value = "relation" - - def __init__(self, rel_id=None, center_lat=None, center_lon=None, members=None, **kwargs): - """ - :param members: - :param rel_id: Id of the relation element - :type rel_id: Integer - :param kwargs: - :return: - """ - - Element.__init__(self, **kwargs) - self.id = rel_id - self.members = members - - #: The lat/lon of the center of the way (optional depending on query) - self.center_lat = center_lat - self.center_lon = center_lon - - def __repr__(self): - return "".format(self.id) - - @classmethod - def from_json(cls, data, result=None): - """ - Create new Relation element from JSON data - - :param data: Element data from JSON - :type data: Dict - :param result: The result this element belongs to - :type result: overpy.Result - :return: New instance of Relation - :rtype: overpy.Relation - :raises overpy.exception.ElementDataWrongType: If type value of the passed JSON data does not match. - """ - if data.get("type") != cls._type_value: - raise exception.ElementDataWrongType( - type_expected=cls._type_value, - type_provided=data.get("type") - ) - - tags = data.get("tags", {}) - - rel_id = data.get("id") - (center_lat, center_lon) = cls.get_center_from_json(data=data) - - members = [] - - supported_members = [RelationNode, RelationWay, RelationRelation] - for member in data.get("members", []): - type_value = member.get("type") - for member_cls in supported_members: - if member_cls._type_value == type_value: - members.append( - member_cls.from_json( - member, - result=result - ) - ) - - attributes = {} - ignore = ["id", "members", "tags", "type"] - for n, v in data.items(): - if n in ignore: - continue - attributes[n] = v - - return cls( - rel_id=rel_id, - attributes=attributes, - center_lat=center_lat, - center_lon=center_lon, - members=members, - tags=tags, - result=result - ) - - @classmethod - def from_xml(cls, child, result=None): - """ - Create new way element from XML data - - :param child: XML node to be parsed - :type child: xml.etree.ElementTree.Element - :param result: The result this node belongs to - :type result: overpy.Result - :return: New Way oject - :rtype: overpy.Relation - :raises overpy.exception.ElementDataWrongType: If name of the xml child node doesn't match - :raises ValueError: If a tag doesn't have a name - """ - if child.tag.lower() != cls._type_value: - raise exception.ElementDataWrongType( - type_expected=cls._type_value, - type_provided=child.tag.lower() - ) - - tags = {} - members = [] - center_lat = None - center_lon = None - - supported_members = [RelationNode, RelationWay, RelationRelation, RelationArea] - for sub_child in child: - if sub_child.tag.lower() == "tag": - name = sub_child.attrib.get("k") - if name is None: - raise ValueError("Tag without name/key.") - value = sub_child.attrib.get("v") - tags[name] = value - if sub_child.tag.lower() == "member": - type_value = sub_child.attrib.get("type") - for member_cls in supported_members: - if member_cls._type_value == type_value: - members.append( - member_cls.from_xml( - sub_child, - result=result - ) - ) - if sub_child.tag.lower() == "center": - (center_lat, center_lon) = cls.get_center_from_xml_dom(sub_child=sub_child) - - rel_id = child.attrib.get("id") - if rel_id is not None: - rel_id = int(rel_id) - - attributes = {} - ignore = ["id"] - for n, v in child.attrib.items(): - if n in ignore: - continue - attributes[n] = v - - return cls( - rel_id=rel_id, - attributes=attributes, - center_lat=center_lat, - center_lon=center_lon, - members=members, - tags=tags, - result=result - ) - - -class RelationMember(object): - """ - Base class to represent a member of a relation. - """ - - def __init__(self, attributes=None, geometry=None, ref=None, role=None, result=None): - """ - :param ref: Reference Id - :type ref: Integer - :param role: The role of the relation member - :type role: String - :param result: - """ - self.ref = ref - self._result = result - self.role = role - self.attributes = attributes - self.geometry = geometry - - @classmethod - def from_json(cls, data, result=None): - """ - Create new RelationMember element from JSON data - - :param child: Element data from JSON - :type child: Dict - :param result: The result this element belongs to - :type result: overpy.Result - :return: New instance of RelationMember - :rtype: overpy.RelationMember - :raises overpy.exception.ElementDataWrongType: If type value of the passed JSON data does not match. - """ - if data.get("type") != cls._type_value: - raise exception.ElementDataWrongType( - type_expected=cls._type_value, - type_provided=data.get("type") - ) - - ref = data.get("ref") - role = data.get("role") - - attributes = {} - ignore = ["geometry", "type", "ref", "role"] - for n, v in data.items(): - if n in ignore: - continue - attributes[n] = v - - geometry = data.get("geometry") - if isinstance(geometry, list): - geometry_orig = geometry - geometry = [] - for v in geometry_orig: - geometry.append( - RelationWayGeometryValue( - lat=v.get("lat"), - lon=v.get("lon") - ) - ) - else: - geometry = None - - return cls( - attributes=attributes, - geometry=geometry, - ref=ref, - role=role, - result=result - ) - - @classmethod - def from_xml(cls, child, result=None): - """ - Create new RelationMember from XML data - - :param child: XML node to be parsed - :type child: xml.etree.ElementTree.Element - :param result: The result this element belongs to - :type result: overpy.Result - :return: New relation member oject - :rtype: overpy.RelationMember - :raises overpy.exception.ElementDataWrongType: If name of the xml child node doesn't match - """ - if child.attrib.get("type") != cls._type_value: - raise exception.ElementDataWrongType( - type_expected=cls._type_value, - type_provided=child.tag.lower() - ) - - ref = child.attrib.get("ref") - if ref is not None: - ref = int(ref) - role = child.attrib.get("role") - - attributes = {} - ignore = ["geometry", "ref", "role", "type"] - for n, v in child.attrib.items(): - if n in ignore: - continue - attributes[n] = v - - geometry = None - for sub_child in child: - if sub_child.tag.lower() == "nd": - if geometry is None: - geometry = [] - geometry.append( - RelationWayGeometryValue( - lat=Decimal(sub_child.attrib["lat"]), - lon=Decimal(sub_child.attrib["lon"]) - ) - ) - - return cls( - attributes=attributes, - geometry=geometry, - ref=ref, - role=role, - result=result - ) - - -class RelationNode(RelationMember): - _type_value = "node" - - def resolve(self, resolve_missing=False): - return self._result.get_node(self.ref, resolve_missing=resolve_missing) - - def __repr__(self): - return "".format(self.ref, self.role) - - -class RelationWay(RelationMember): - _type_value = "way" - - def resolve(self, resolve_missing=False): - return self._result.get_way(self.ref, resolve_missing=resolve_missing) - - def __repr__(self): - return "".format(self.ref, self.role) - - -class RelationWayGeometryValue(object): - def __init__(self, lat, lon): - self.lat = lat - self.lon = lon - - def __repr__(self): - return "".format(self.lat, self.lon) - - -class RelationRelation(RelationMember): - _type_value = "relation" - - def resolve(self, resolve_missing=False): - return self._result.get_relation(self.ref, resolve_missing=resolve_missing) - - def __repr__(self): - return "".format(self.ref, self.role) - - -class RelationArea(RelationMember): - _type_value = "area" - - def resolve(self, resolve_missing=False): - return self._result.get_area(self.ref, resolve_missing=resolve_missing) - - def __repr__(self): - return "".format(self.ref, self.role) - - -class OSMSAXHandler(handler.ContentHandler): - """ - SAX parser for Overpass XML response. - """ - #: Tuple of opening elements to ignore - ignore_start = ('osm', 'meta', 'note', 'bounds', 'remark') - #: Tuple of closing elements to ignore - ignore_end = ('osm', 'meta', 'note', 'bounds', 'remark', 'tag', 'nd', 'center') - - def __init__(self, result): - """ - :param result: Append results to this result set. - :type result: overpy.Result - """ - handler.ContentHandler.__init__(self) - self._result = result - self._curr = {} - #: Current relation member object - self.cur_relation_member = None - - def startElement(self, name, attrs): - """ - Handle opening elements. - - :param name: Name of the element - :type name: String - :param attrs: Attributes of the element - :type attrs: Dict - """ - if name in self.ignore_start: - return - try: - handler = getattr(self, '_handle_start_%s' % name) - except AttributeError: - raise KeyError("Unknown element start '%s'" % name) - handler(attrs) - - def endElement(self, name): - """ - Handle closing elements - - :param name: Name of the element - :type name: String - """ - if name in self.ignore_end: - return - try: - handler = getattr(self, '_handle_end_%s' % name) - except AttributeError: - raise KeyError("Unknown element end '%s'" % name) - handler() - - def _handle_start_center(self, attrs): - """ - Handle opening center element - - :param attrs: Attributes of the element - :type attrs: Dict - """ - center_lat = attrs.get("lat") - center_lon = attrs.get("lon") - if center_lat is None or center_lon is None: - raise ValueError("Unable to get lat or lon of way center.") - self._curr["center_lat"] = Decimal(center_lat) - self._curr["center_lon"] = Decimal(center_lon) - - def _handle_start_tag(self, attrs): - """ - Handle opening tag element - - :param attrs: Attributes of the element - :type attrs: Dict - """ - try: - tag_key = attrs['k'] - except KeyError: - raise ValueError("Tag without name/key.") - self._curr['tags'][tag_key] = attrs.get('v') - - def _handle_start_node(self, attrs): - """ - Handle opening node element - - :param attrs: Attributes of the element - :type attrs: Dict - """ - self._curr = { - 'attributes': dict(attrs), - 'lat': None, - 'lon': None, - 'node_id': None, - 'tags': {} - } - if attrs.get('id', None) is not None: - self._curr['node_id'] = int(attrs['id']) - del self._curr['attributes']['id'] - if attrs.get('lat', None) is not None: - self._curr['lat'] = Decimal(attrs['lat']) - del self._curr['attributes']['lat'] - if attrs.get('lon', None) is not None: - self._curr['lon'] = Decimal(attrs['lon']) - del self._curr['attributes']['lon'] - - def _handle_end_node(self): - """ - Handle closing node element - """ - self._result.append(Node(result=self._result, **self._curr)) - self._curr = {} - - def _handle_start_way(self, attrs): - """ - Handle opening way element - - :param attrs: Attributes of the element - :type attrs: Dict - """ - self._curr = { - 'center_lat': None, - 'center_lon': None, - 'attributes': dict(attrs), - 'node_ids': [], - 'tags': {}, - 'way_id': None - } - if attrs.get('id', None) is not None: - self._curr['way_id'] = int(attrs['id']) - del self._curr['attributes']['id'] - - def _handle_end_way(self): - """ - Handle closing way element - """ - self._result.append(Way(result=self._result, **self._curr)) - self._curr = {} - - def _handle_start_area(self, attrs): - """ - Handle opening area element - - :param attrs: Attributes of the element - :type attrs: Dict - """ - self._curr = { - 'attributes': dict(attrs), - 'tags': {}, - 'area_id': None - } - if attrs.get('id', None) is not None: - self._curr['area_id'] = int(attrs['id']) - del self._curr['attributes']['id'] - - def _handle_end_area(self): - """ - Handle closing area element - """ - self._result.append(Area(result=self._result, **self._curr)) - self._curr = {} - - def _handle_start_nd(self, attrs): - """ - Handle opening nd element - - :param attrs: Attributes of the element - :type attrs: Dict - """ - if isinstance(self.cur_relation_member, RelationWay): - if self.cur_relation_member.geometry is None: - self.cur_relation_member.geometry = [] - self.cur_relation_member.geometry.append( - RelationWayGeometryValue( - lat=Decimal(attrs["lat"]), - lon=Decimal(attrs["lon"]) - ) - ) - else: - try: - node_ref = attrs['ref'] - except KeyError: - raise ValueError("Unable to find required ref value.") - self._curr['node_ids'].append(int(node_ref)) - - def _handle_start_relation(self, attrs): - """ - Handle opening relation element - - :param attrs: Attributes of the element - :type attrs: Dict - """ - self._curr = { - 'attributes': dict(attrs), - 'members': [], - 'rel_id': None, - 'tags': {} - } - if attrs.get('id', None) is not None: - self._curr['rel_id'] = int(attrs['id']) - del self._curr['attributes']['id'] - - def _handle_end_relation(self): - """ - Handle closing relation element - """ - self._result.append(Relation(result=self._result, **self._curr)) - self._curr = {} - - def _handle_start_member(self, attrs): - """ - Handle opening member element - - :param attrs: Attributes of the element - :type attrs: Dict - """ - - params = { - # ToDo: Parse attributes - 'attributes': {}, - 'ref': None, - 'result': self._result, - 'role': None - } - if attrs.get('ref', None): - params['ref'] = int(attrs['ref']) - if attrs.get('role', None): - params['role'] = attrs['role'] - - cls_map = { - "area": RelationArea, - "node": RelationNode, - "relation": RelationRelation, - "way": RelationWay - } - cls = cls_map.get(attrs["type"]) - if cls is None: - raise ValueError("Undefined type for member: '%s'" % attrs['type']) - - self.cur_relation_member = cls(**params) - self._curr['members'].append(self.cur_relation_member) - - def _handle_end_member(self): - self.cur_relation_member = None diff --git a/pyextra/overpy/exception.py b/pyextra/overpy/exception.py deleted file mode 100644 index 3d8416a1257ef1..00000000000000 --- a/pyextra/overpy/exception.py +++ /dev/null @@ -1,166 +0,0 @@ -class OverPyException(BaseException): - """OverPy base exception""" - pass - - -class DataIncomplete(OverPyException): - """ - Raised if the requested data isn't available in the result. - Try to improve the query or to resolve the missing data. - """ - def __init__(self, *args, **kwargs): - OverPyException.__init__( - self, - "Data incomplete try to improve the query to resolve the missing data", - *args, - **kwargs - ) - - -class ElementDataWrongType(OverPyException): - """ - Raised if the provided element does not match the expected type. - - :param type_expected: The expected element type - :type type_expected: String - :param type_provided: The provided element type - :type type_provided: String|None - """ - def __init__(self, type_expected, type_provided=None): - self.type_expected = type_expected - self.type_provided = type_provided - - def __str__(self): - return "Type expected '%s' but '%s' provided" % ( - self.type_expected, - str(self.type_provided) - ) - - -class MaxRetriesReached(OverPyException): - """ - Raised if max retries reached and the Overpass server didn't respond with a result. - """ - def __init__(self, retry_count, exceptions): - self.exceptions = exceptions - self.retry_count = retry_count - - def __str__(self): - return "Unable get any result from the Overpass API server after %d retries." % self.retry_count - - -class OverpassBadRequest(OverPyException): - """ - Raised if the Overpass API service returns a syntax error. - - :param query: The encoded query how it was send to the server - :type query: Bytes - :param msgs: List of error messages - :type msgs: List - """ - def __init__(self, query, msgs=None): - self.query = query - if msgs is None: - msgs = [] - self.msgs = msgs - - def __str__(self): - tmp_msgs = [] - for tmp_msg in self.msgs: - if not isinstance(tmp_msg, str): - tmp_msg = str(tmp_msg) - tmp_msgs.append(tmp_msg) - - return "\n".join(tmp_msgs) - - -class OverpassError(OverPyException): - """ - Base exception to report errors if the response returns a remark tag or element. - - .. note:: - If you are not sure which of the subexceptions you should use, use this one and try to parse the message. - - For more information have a look at https://github.com/DinoTools/python-overpy/issues/62 - - :param str msg: The message from the remark tag or element - """ - def __init__(self, msg=None): - #: The message from the remark tag or element - self.msg = msg - - def __str__(self): - if self.msg is None: - return "No error message provided" - if not isinstance(self.msg, str): - return str(self.msg) - return self.msg - - -class OverpassGatewayTimeout(OverPyException): - """ - Raised if load of the Overpass API service is too high and it can't handle the request. - """ - def __init__(self): - OverPyException.__init__(self, "Server load too high") - - -class OverpassRuntimeError(OverpassError): - """ - Raised if the server returns a remark-tag(xml) or remark element(json) with a message starting with - 'runtime error:'. - """ - pass - - -class OverpassRuntimeRemark(OverpassError): - """ - Raised if the server returns a remark-tag(xml) or remark element(json) with a message starting with - 'runtime remark:'. - """ - pass - - -class OverpassTooManyRequests(OverPyException): - """ - Raised if the Overpass API service returns a 429 status code. - """ - def __init__(self): - OverPyException.__init__(self, "Too many requests") - - -class OverpassUnknownContentType(OverPyException): - """ - Raised if the reported content type isn't handled by OverPy. - - :param content_type: The reported content type - :type content_type: None or String - """ - def __init__(self, content_type): - self.content_type = content_type - - def __str__(self): - if self.content_type is None: - return "No content type returned" - return "Unknown content type: %s" % self.content_type - - -class OverpassUnknownError(OverpassError): - """ - Raised if the server returns a remark-tag(xml) or remark element(json) and we are unable to find any reason. - """ - pass - - -class OverpassUnknownHTTPStatusCode(OverPyException): - """ - Raised if the returned HTTP status code isn't handled by OverPy. - - :param code: The HTTP status code - :type code: Integer - """ - def __init__(self, code): - self.code = code - - def __str__(self): - return "Unknown/Unhandled status code: %d" % self.code \ No newline at end of file diff --git a/pyextra/overpy/helper.py b/pyextra/overpy/helper.py deleted file mode 100644 index e3ac0170bcb882..00000000000000 --- a/pyextra/overpy/helper.py +++ /dev/null @@ -1,64 +0,0 @@ -__author__ = 'mjob' - -import overpy - - -def get_street(street, areacode, api=None): - """ - Retrieve streets in a given bounding area - - :param overpy.Overpass api: First street of intersection - :param String street: Name of street - :param String areacode: The OSM id of the bounding area - :return: Parsed result - :raises overpy.exception.OverPyException: If something bad happens. - """ - if api is None: - api = overpy.Overpass() - - query = """ - area(%s)->.location; - ( - way[highway][name="%s"](area.location); - - ( - way[highway=service](area.location); - way[highway=track](area.location); - ); - ); - out body; - >; - out skel qt; - """ - - data = api.query(query % (areacode, street)) - - return data - - -def get_intersection(street1, street2, areacode, api=None): - """ - Retrieve intersection of two streets in a given bounding area - - :param overpy.Overpass api: First street of intersection - :param String street1: Name of first street of intersection - :param String street2: Name of second street of intersection - :param String areacode: The OSM id of the bounding area - :return: List of intersections - :raises overpy.exception.OverPyException: If something bad happens. - """ - if api is None: - api = overpy.Overpass() - - query = """ - area(%s)->.location; - ( - way[highway][name="%s"](area.location); node(w)->.n1; - way[highway][name="%s"](area.location); node(w)->.n2; - ); - node.n1.n2; - out meta; - """ - - data = api.query(query % (areacode, street1, street2)) - - return data.get_nodes() diff --git a/rednose/__init__.py b/rednose/__init__.py new file mode 100644 index 00000000000000..25f82adc700249 --- /dev/null +++ b/rednose/__init__.py @@ -0,0 +1,58 @@ +from typing import Any, Dict + +import numpy as np + +from rednose.helpers.ekf_sym import EKF_sym + + +class KalmanFilter: + name = "" + initial_x = np.zeros((0, 0)) + initial_P_diag = np.zeros((0, 0)) + Q = np.zeros((0, 0)) + obs_noise: Dict[int, Any] = {} + + def __init__(self, generated_dir): + dim_state = self.initial_x.shape[0] + dim_state_err = self.initial_P_diag.shape[0] + + # init filter + self.filter = EKF_sym(generated_dir, self.name, self.Q, self.initial_x, np.diag(self.initial_P_diag), dim_state, dim_state_err) + + @property + def x(self): + return self.filter.state() + + @property + def t(self): + return self.filter.filter_time + + @property + def P(self): + return self.filter.covs() + + def init_state(self, state, covs_diag=None, covs=None, filter_time=None): + if covs_diag is not None: + P = np.diag(covs_diag) + elif covs is not None: + P = covs + else: + P = self.filter.covs() + self.filter.init_state(state, P, filter_time) + + def get_R(self, kind, n): + obs_noise = self.obs_noise[kind] + dim = obs_noise.shape[0] + R = np.zeros((n, dim, dim)) + for i in range(n): + R[i, :, :] = obs_noise + return R + + def predict_and_observe(self, t, kind, data, R=None): + if len(data) > 0: + data = np.atleast_2d(data) + + if R is None: + R = self.get_R(kind, len(data)) + + self.filter.predict_and_update_batch(t, kind, data, R) diff --git a/rednose/helpers/__init__.py b/rednose/helpers/__init__.py new file mode 100644 index 00000000000000..aba6b41fe902b9 --- /dev/null +++ b/rednose/helpers/__init__.py @@ -0,0 +1,30 @@ +import os +import platform +from cffi import FFI + +TEMPLATE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'templates')) + + +def write_code(folder, name, code, header): + if not os.path.exists(folder): + os.mkdir(folder) + + open(os.path.join(folder, f"{name}.cpp"), 'w').write(code) + open(os.path.join(folder, f"{name}.h"), 'w').write(header) + + +def load_code(folder, name): + shared_ext = "dylib" if platform.system() == "Darwin" else "so" + shared_fn = os.path.join(folder, f"lib{name}.{shared_ext}") + header_fn = os.path.join(folder, f"{name}.h") + + with open(header_fn) as f: + header = f.read() + + ffi = FFI() + ffi.cdef(header) + return (ffi, ffi.dlopen(shared_fn)) + + +class KalmanError(Exception): + pass diff --git a/rednose/helpers/chi2_lookup.py b/rednose/helpers/chi2_lookup.py new file mode 100644 index 00000000000000..e22cc97299e175 --- /dev/null +++ b/rednose/helpers/chi2_lookup.py @@ -0,0 +1,22 @@ +import os + +import numpy as np + + +def gen_chi2_ppf_lookup(max_dim=200): + from scipy.stats import chi2 + table = np.zeros((max_dim, 98)) + for dim in range(1, max_dim): + table[dim] = chi2.ppf(np.arange(.01, .99, .01), dim) + + np.save('chi2_lookup_table', table) + + +def chi2_ppf(p, dim): + table = np.load(os.path.dirname(os.path.realpath(__file__)) + '/chi2_lookup_table.npy') + result = np.interp(p, np.arange(.01, .99, .01), table[dim]) + return result + + +if __name__ == "__main__": + gen_chi2_ppf_lookup() diff --git a/rednose/helpers/chi2_lookup_table.npy b/rednose/helpers/chi2_lookup_table.npy new file mode 100644 index 00000000000000..6f1bd959c194cb Binary files /dev/null and b/rednose/helpers/chi2_lookup_table.npy differ diff --git a/rednose/helpers/ekf_sym.py b/rednose/helpers/ekf_sym.py new file mode 100644 index 00000000000000..6df607e5907203 --- /dev/null +++ b/rednose/helpers/ekf_sym.py @@ -0,0 +1,606 @@ +import os +from bisect import bisect_right + +import numpy as np +import sympy as sp +from numpy import dot + +from rednose.helpers.sympy_helpers import sympy_into_c +from rednose.helpers import (TEMPLATE_DIR, load_code, write_code) +from rednose.helpers.chi2_lookup import chi2_ppf + + +def solve(a, b): + if a.shape[0] == 1 and a.shape[1] == 1: + return b / a[0][0] + else: + return np.linalg.solve(a, b) + + +def null(H, eps=1e-12): + _, s, vh = np.linalg.svd(H) + padding = max(0, np.shape(H)[1] - np.shape(s)[0]) + null_mask = np.concatenate(((s <= eps), np.ones((padding,), dtype=bool)), axis=0) + null_space = np.compress(null_mask, vh, axis=0) + return np.transpose(null_space) + + +def gen_code(folder, name, f_sym, dt_sym, x_sym, obs_eqs, dim_x, dim_err, eskf_params=None, msckf_params=None, # pylint: disable=dangerous-default-value + maha_test_kinds=[], global_vars=None): + # optional state transition matrix, H modifier + # and err_function if an error-state kalman filter (ESKF) + # is desired. Best described in "Quaternion kinematics + # for the error-state Kalman filter" by Joan Sola + + if eskf_params: + err_eqs = eskf_params[0] + inv_err_eqs = eskf_params[1] + H_mod_sym = eskf_params[2] + f_err_sym = eskf_params[3] + x_err_sym = eskf_params[4] + else: + nom_x = sp.MatrixSymbol('nom_x', dim_x, 1) + true_x = sp.MatrixSymbol('true_x', dim_x, 1) + delta_x = sp.MatrixSymbol('delta_x', dim_x, 1) + err_function_sym = sp.Matrix(nom_x + delta_x) + inv_err_function_sym = sp.Matrix(true_x - nom_x) + err_eqs = [err_function_sym, nom_x, delta_x] + inv_err_eqs = [inv_err_function_sym, nom_x, true_x] + + H_mod_sym = sp.Matrix(np.eye(dim_x)) + f_err_sym = f_sym + x_err_sym = x_sym + + # This configures the multi-state augmentation + # needed for EKF-SLAM with MSCKF (Mourikis et al 2007) + if msckf_params: + msckf = True + dim_main = msckf_params[0] # size of the main state + dim_augment = msckf_params[1] # size of one augment state chunk + dim_main_err = msckf_params[2] + dim_augment_err = msckf_params[3] + N = msckf_params[4] + feature_track_kinds = msckf_params[5] + assert dim_main + dim_augment * N == dim_x + assert dim_main_err + dim_augment_err * N == dim_err + else: + msckf = False + dim_main = dim_x + dim_augment = 0 + dim_main_err = dim_err + dim_augment_err = 0 + N = 0 + + # linearize with jacobians + F_sym = f_err_sym.jacobian(x_err_sym) + + if eskf_params: + for sym in x_err_sym: + F_sym = F_sym.subs(sym, 0) + + assert dt_sym in F_sym.free_symbols + + for i in range(len(obs_eqs)): + obs_eqs[i].append(obs_eqs[i][0].jacobian(x_sym)) + if msckf and obs_eqs[i][1] in feature_track_kinds: + obs_eqs[i].append(obs_eqs[i][0].jacobian(obs_eqs[i][2])) + else: + obs_eqs[i].append(None) + + # collect sympy functions + sympy_functions = [] + + # error functions + sympy_functions.append(('err_fun', err_eqs[0], [err_eqs[1], err_eqs[2]])) + sympy_functions.append(('inv_err_fun', inv_err_eqs[0], [inv_err_eqs[1], inv_err_eqs[2]])) + + # H modifier for ESKF updates + sympy_functions.append(('H_mod_fun', H_mod_sym, [x_sym])) + + # state propagation function + sympy_functions.append(('f_fun', f_sym, [x_sym, dt_sym])) + sympy_functions.append(('F_fun', F_sym, [x_sym, dt_sym])) + + # observation functions + for h_sym, kind, ea_sym, H_sym, He_sym in obs_eqs: + sympy_functions.append(('h_%d' % kind, h_sym, [x_sym, ea_sym])) + sympy_functions.append(('H_%d' % kind, H_sym, [x_sym, ea_sym])) + if msckf and kind in feature_track_kinds: + sympy_functions.append(('He_%d' % kind, He_sym, [x_sym, ea_sym])) + + # Generate and wrap all th c code + header, code = sympy_into_c(sympy_functions, global_vars) + extra_header = "#define DIM %d\n" % dim_x + extra_header += "#define EDIM %d\n" % dim_err + extra_header += "#define MEDIM %d\n" % dim_main_err + extra_header += "typedef void (*Hfun)(double *, double *, double *);\n" + + extra_header += "\nvoid predict(double *x, double *P, double *Q, double dt);" + + extra_post = "" + + for h_sym, kind, ea_sym, H_sym, He_sym in obs_eqs: + if msckf and kind in feature_track_kinds: + He_str = 'He_%d' % kind + # ea_dim = ea_sym.shape[0] + else: + He_str = 'NULL' + # ea_dim = 1 # not really dim of ea but makes c function work + maha_thresh = chi2_ppf(0.95, int(h_sym.shape[0])) # mahalanobis distance for outlier detection + maha_test = kind in maha_test_kinds + extra_post += """ + void update_%d(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) { + update<%d,%d,%d>(in_x, in_P, h_%d, H_%d, %s, in_z, in_R, in_ea, MAHA_THRESH_%d); + } + """ % (kind, h_sym.shape[0], 3, maha_test, kind, kind, He_str, kind) + extra_header += "\nconst static double MAHA_THRESH_%d = %f;" % (kind, maha_thresh) + extra_header += "\nvoid update_%d(double *, double *, double *, double *, double *);" % kind + + code += '\nextern "C"{\n' + extra_header + "\n}\n" + code += "\n" + open(os.path.join(TEMPLATE_DIR, "ekf_c.c")).read() + code += '\nextern "C"{\n' + extra_post + "\n}\n" + + if global_vars is not None: + global_code = '\nextern "C"{\n' + for var in global_vars: + global_code += f"\ndouble {var.name};\n" + global_code += f"\nvoid set_{var.name}(double x){{ {var.name} = x;}}\n" + extra_header += f"\nvoid set_{var.name}(double x);\n" + + global_code += '\n}\n' + code = global_code + code + + header += "\n" + extra_header + + write_code(folder, name, code, header) + + +class EKF_sym(): + def __init__(self, folder, name, Q, x_initial, P_initial, dim_main, dim_main_err, # pylint: disable=dangerous-default-value + N=0, dim_augment=0, dim_augment_err=0, maha_test_kinds=[], global_vars=None, max_rewind_age=1.0): + """Generates process function and all observation functions for the kalman filter.""" + self.msckf = N > 0 + self.N = N + self.dim_augment = dim_augment + self.dim_augment_err = dim_augment_err + self.dim_main = dim_main + self.dim_main_err = dim_main_err + + # state + x_initial = x_initial.reshape((-1, 1)) + self.dim_x = x_initial.shape[0] + self.dim_err = P_initial.shape[0] + assert dim_main + dim_augment * N == self.dim_x + assert dim_main_err + dim_augment_err * N == self.dim_err + assert Q.shape == P_initial.shape + + # kinds that should get mahalanobis distance + # tested for outlier rejection + self.maha_test_kinds = maha_test_kinds + + self.global_vars = global_vars + + # process noise + self.Q = Q + + # rewind stuff + self.max_rewind_age = max_rewind_age + self.rewind_t = [] + self.rewind_states = [] + self.rewind_obscache = [] + self.init_state(x_initial, P_initial, None) + + ffi, lib = load_code(folder, name) + kinds, self.feature_track_kinds = [], [] + for func in dir(lib): + if func[:2] == 'h_': + kinds.append(int(func[2:])) + if func[:3] == 'He_': + self.feature_track_kinds.append(int(func[3:])) + + # wrap all the sympy functions + def wrap_1lists(name): + func = eval("lib.%s" % name, {"lib": lib}) # pylint: disable=eval-used + + def ret(lst1, out): + func(ffi.cast("double *", lst1.ctypes.data), + ffi.cast("double *", out.ctypes.data)) + return ret + + def wrap_2lists(name): + func = eval("lib.%s" % name, {"lib": lib}) # pylint: disable=eval-used + + def ret(lst1, lst2, out): + func(ffi.cast("double *", lst1.ctypes.data), + ffi.cast("double *", lst2.ctypes.data), + ffi.cast("double *", out.ctypes.data)) + return ret + + def wrap_1list_1float(name): + func = eval("lib.%s" % name, {"lib": lib}) # pylint: disable=eval-used + + def ret(lst1, fl, out): + func(ffi.cast("double *", lst1.ctypes.data), + ffi.cast("double", fl), + ffi.cast("double *", out.ctypes.data)) + return ret + + self.f = wrap_1list_1float("f_fun") + self.F = wrap_1list_1float("F_fun") + + self.err_function = wrap_2lists("err_fun") + self.inv_err_function = wrap_2lists("inv_err_fun") + self.H_mod = wrap_1lists("H_mod_fun") + + self.hs, self.Hs, self.Hes = {}, {}, {} + for kind in kinds: + self.hs[kind] = wrap_2lists("h_%d" % kind) + self.Hs[kind] = wrap_2lists("H_%d" % kind) + if self.msckf and kind in self.feature_track_kinds: + self.Hes[kind] = wrap_2lists("He_%d" % kind) + + if self.global_vars is not None: + for var in self.global_vars: + fun_name = f"set_{var.name}" + setattr(self, fun_name, getattr(lib, fun_name)) + + # wrap the C++ predict function + def _predict_blas(x, P, dt): + lib.predict(ffi.cast("double *", x.ctypes.data), + ffi.cast("double *", P.ctypes.data), + ffi.cast("double *", self.Q.ctypes.data), + ffi.cast("double", dt)) + return x, P + + # wrap the C++ update function + def fun_wrapper(f, kind): + f = eval("lib.%s" % f, {"lib": lib}) # pylint: disable=eval-used + + def _update_inner_blas(x, P, z, R, extra_args): + f(ffi.cast("double *", x.ctypes.data), + ffi.cast("double *", P.ctypes.data), + ffi.cast("double *", z.ctypes.data), + ffi.cast("double *", R.ctypes.data), + ffi.cast("double *", extra_args.ctypes.data)) + if self.msckf and kind in self.feature_track_kinds: + y = z[:-len(extra_args)] + else: + y = z + return x, P, y + return _update_inner_blas + + self._updates = {} + for kind in kinds: + self._updates[kind] = fun_wrapper("update_%d" % kind, kind) + + def _update_blas(x, P, kind, z, R, extra_args=[]): # pylint: disable=dangerous-default-value + return self._updates[kind](x, P, z, R, extra_args) + + # assign the functions + self._predict = _predict_blas + # self._predict = self._predict_python + self._update = _update_blas + # self._update = self._update_python + + def init_state(self, state, covs, filter_time): + self.x = np.array(state.reshape((-1, 1))).astype(np.float64) + self.P = np.array(covs).astype(np.float64) + self.filter_time = filter_time + self.augment_times = [0] * self.N + self.rewind_obscache = [] + self.rewind_t = [] + self.rewind_states = [] + + def reset_rewind(self): + self.rewind_obscache = [] + self.rewind_t = [] + self.rewind_states = [] + + def augment(self): + # TODO this is not a generalized way of doing this and implies that the augmented states + # are simply the first (dim_augment_state) elements of the main state. + assert self.msckf + d1 = self.dim_main + d2 = self.dim_main_err + d3 = self.dim_augment + d4 = self.dim_augment_err + + # push through augmented states + self.x[d1:-d3] = self.x[d1 + d3:] + self.x[-d3:] = self.x[:d3] + assert self.x.shape == (self.dim_x, 1) + + # push through augmented covs + assert self.P.shape == (self.dim_err, self.dim_err) + P_reduced = self.P + P_reduced = np.delete(P_reduced, np.s_[d2:d2 + d4], axis=1) + P_reduced = np.delete(P_reduced, np.s_[d2:d2 + d4], axis=0) + assert P_reduced.shape == (self.dim_err - d4, self.dim_err - d4) + to_mult = np.zeros((self.dim_err, self.dim_err - d4)) + to_mult[:-d4, :] = np.eye(self.dim_err - d4) + to_mult[-d4:, :d4] = np.eye(d4) + self.P = to_mult.dot(P_reduced.dot(to_mult.T)) + self.augment_times = self.augment_times[1:] + self.augment_times.append(self.filter_time) + assert self.P.shape == (self.dim_err, self.dim_err) + + def state(self): + return np.array(self.x).flatten() + + def covs(self): + return self.P + + def rewind(self, t): + # find where we are rewinding to + idx = bisect_right(self.rewind_t, t) + assert self.rewind_t[idx - 1] <= t + assert self.rewind_t[idx] > t # must be true, or rewind wouldn't be called + + # set the state to the time right before that + self.filter_time = self.rewind_t[idx - 1] + self.x[:] = self.rewind_states[idx - 1][0] + self.P[:] = self.rewind_states[idx - 1][1] + + # return the observations we rewound over for fast forwarding + ret = self.rewind_obscache[idx:] + + # throw away the old future + # TODO: is this making a copy? + self.rewind_t = self.rewind_t[:idx] + self.rewind_states = self.rewind_states[:idx] + self.rewind_obscache = self.rewind_obscache[:idx] + + return ret + + def checkpoint(self, obs): + # push to rewinder + self.rewind_t.append(self.filter_time) + self.rewind_states.append((np.copy(self.x), np.copy(self.P))) + self.rewind_obscache.append(obs) + + # only keep a certain number around + REWIND_TO_KEEP = 512 + self.rewind_t = self.rewind_t[-REWIND_TO_KEEP:] + self.rewind_states = self.rewind_states[-REWIND_TO_KEEP:] + self.rewind_obscache = self.rewind_obscache[-REWIND_TO_KEEP:] + + def predict(self, t): + # initialize time + if self.filter_time is None: + self.filter_time = t + + # predict + dt = t - self.filter_time + assert dt >= 0 + self.x, self.P = self._predict(self.x, self.P, dt) + self.filter_time = t + + def predict_and_update_batch(self, t, kind, z, R, extra_args=[[]], augment=False): # pylint: disable=dangerous-default-value + # TODO handle rewinding at this level" + + # rewind + if self.filter_time is not None and t < self.filter_time: + if len(self.rewind_t) == 0 or t < self.rewind_t[0] or t < self.rewind_t[-1] - self.max_rewind_age: + print("observation too old at %.3f with filter at %.3f, ignoring" % (t, self.filter_time)) + return None + rewound = self.rewind(t) + else: + rewound = [] + + ret = self._predict_and_update_batch(t, kind, z, R, extra_args, augment) + + # optional fast forward + for r in rewound: + self._predict_and_update_batch(*r) + + return ret + + def _predict_and_update_batch(self, t, kind, z, R, extra_args, augment=False): + """The main kalman filter function + Predicts the state and then updates a batch of observations + + dim_x: dimensionality of the state space + dim_z: dimensionality of the observation and depends on kind + n: number of observations + + Args: + t (float): Time of observation + kind (int): Type of observation + z (vec [n,dim_z]): Measurements + R (mat [n,dim_z, dim_z]): Measurement Noise + extra_args (list, [n]): Values used in H computations + """ + assert z.shape[0] == R.shape[0] + assert z.shape[1] == R.shape[1] + assert z.shape[1] == R.shape[2] + + # initialize time + if self.filter_time is None: + self.filter_time = t + + # predict + dt = t - self.filter_time + assert dt >= 0 + self.x, self.P = self._predict(self.x, self.P, dt) + self.filter_time = t + xk_km1, Pk_km1 = np.copy(self.x).flatten(), np.copy(self.P) + + # update batch + y = [] + for i in range(len(z)): + # these are from the user, so we canonicalize them + z_i = np.array(z[i], dtype=np.float64, order='F') + R_i = np.array(R[i], dtype=np.float64, order='F') + extra_args_i = np.array(extra_args[i], dtype=np.float64, order='F') + # update + self.x, self.P, y_i = self._update(self.x, self.P, kind, z_i, R_i, extra_args=extra_args_i) + y.append(y_i) + xk_k, Pk_k = np.copy(self.x).flatten(), np.copy(self.P) + + if augment: + self.augment() + + # checkpoint + self.checkpoint((t, kind, z, R, extra_args)) + + return xk_km1, xk_k, Pk_km1, Pk_k, t, kind, y, z, extra_args + + def _predict_python(self, x, P, dt): + x_new = np.zeros(x.shape, dtype=np.float64) + self.f(x, dt, x_new) + + F = np.zeros(P.shape, dtype=np.float64) + self.F(x, dt, F) + + if not self.msckf: + P = dot(dot(F, P), F.T) + else: + # Update the predicted state covariance: + # Pk+1|k = |F*Pii*FT + Q*dt F*Pij | + # |PijT*FT Pjj | + # Where F is the jacobian of the main state + # predict function, Pii is the main state's + # covariance and Q its process noise. Pij + # is the covariance between the augmented + # states and the main state. + # + d2 = self.dim_main_err # known at compile time + F_curr = F[:d2, :d2] + P[:d2, :d2] = (F_curr.dot(P[:d2, :d2])).dot(F_curr.T) + P[:d2, d2:] = F_curr.dot(P[:d2, d2:]) + P[d2:, :d2] = P[d2:, :d2].dot(F_curr.T) + + P += dt * self.Q + return x_new, P + + def _update_python(self, x, P, kind, z, R, extra_args=[]): # pylint: disable=dangerous-default-value + # init vars + z = z.reshape((-1, 1)) + h = np.zeros(z.shape, dtype=np.float64) + H = np.zeros((z.shape[0], self.dim_x), dtype=np.float64) + + # C functions + self.hs[kind](x, extra_args, h) + self.Hs[kind](x, extra_args, H) + + # y is the "loss" + y = z - h + + # *** same above this line *** + + if self.msckf and kind in self.Hes: + # Do some algebraic magic to decorrelate + He = np.zeros((z.shape[0], len(extra_args)), dtype=np.float64) + self.Hes[kind](x, extra_args, He) + + # TODO: Don't call a function here, do projection locally + A = null(He.T) + + y = A.T.dot(y) + H = A.T.dot(H) + R = A.T.dot(R.dot(A)) + + # TODO If nullspace isn't the dimension we want + if A.shape[1] + He.shape[1] != A.shape[0]: + print('Warning: null space projection failed, measurement ignored') + return x, P, np.zeros(A.shape[0] - He.shape[1]) + + # if using eskf + H_mod = np.zeros((x.shape[0], P.shape[0]), dtype=np.float64) + self.H_mod(x, H_mod) + H = H.dot(H_mod) + + # Do mahalobis distance test + # currently just runs on msckf observations + # could run on anything if needed + if self.msckf and kind in self.maha_test_kinds: + a = np.linalg.inv(H.dot(P).dot(H.T) + R) + maha_dist = y.T.dot(a.dot(y)) + if maha_dist > chi2_ppf(0.95, y.shape[0]): + R = 10e16 * R + + # *** same below this line *** + + # Outlier resilient weighting as described in: + # "A Kalman Filter for Robust Outlier Detection - Jo-Anne Ting, ..." + weight = 1 # (1.5)/(1 + np.sum(y**2)/np.sum(R)) + + S = dot(dot(H, P), H.T) + R / weight + K = solve(S, dot(H, P.T)).T + I_KH = np.eye(P.shape[0]) - dot(K, H) + + # update actual state + delta_x = dot(K, y) + P = dot(dot(I_KH, P), I_KH.T) + dot(dot(K, R), K.T) + + # inject observed error into state + x_new = np.zeros(x.shape, dtype=np.float64) + self.err_function(x, delta_x, x_new) + return x_new, P, y.flatten() + + def maha_test(self, x, P, kind, z, R, extra_args=[], maha_thresh=0.95): # pylint: disable=dangerous-default-value + # init vars + z = z.reshape((-1, 1)) + h = np.zeros(z.shape, dtype=np.float64) + H = np.zeros((z.shape[0], self.dim_x), dtype=np.float64) + + # C functions + self.hs[kind](x, extra_args, h) + self.Hs[kind](x, extra_args, H) + + # y is the "loss" + y = z - h + + # if using eskf + H_mod = np.zeros((x.shape[0], P.shape[0]), dtype=np.float64) + self.H_mod(x, H_mod) + H = H.dot(H_mod) + + a = np.linalg.inv(H.dot(P).dot(H.T) + R) + maha_dist = y.T.dot(a.dot(y)) + if maha_dist > chi2_ppf(maha_thresh, y.shape[0]): + return False + else: + return True + + def rts_smooth(self, estimates, norm_quats=False): + ''' + Returns rts smoothed results of + kalman filter estimates + + If the kalman state is augmented with + old states only the main state is smoothed + ''' + xk_n = estimates[-1][0] + Pk_n = estimates[-1][2] + Fk_1 = np.zeros(Pk_n.shape, dtype=np.float64) + + states_smoothed = [xk_n] + covs_smoothed = [Pk_n] + for k in range(len(estimates) - 2, -1, -1): + xk1_n = xk_n + if norm_quats: + xk1_n[3:7] /= np.linalg.norm(xk1_n[3:7]) + Pk1_n = Pk_n + + xk1_k, _, Pk1_k, _, t2, _, _, _, _ = estimates[k + 1] + _, xk_k, _, Pk_k, t1, _, _, _, _ = estimates[k] + dt = t2 - t1 + self.F(xk_k, dt, Fk_1) + + d1 = self.dim_main + d2 = self.dim_main_err + Ck = np.linalg.solve(Pk1_k[:d2, :d2], Fk_1[:d2, :d2].dot(Pk_k[:d2, :d2].T)).T + xk_n = xk_k + delta_x = np.zeros((Pk_n.shape[0], 1), dtype=np.float64) + self.inv_err_function(xk1_k, xk1_n, delta_x) + delta_x[:d2] = Ck.dot(delta_x[:d2]) + x_new = np.zeros((xk_n.shape[0], 1), dtype=np.float64) + self.err_function(xk_k, delta_x, x_new) + xk_n[:d1] = x_new[:d1, 0] + Pk_n = Pk_k + Pk_n[:d2, :d2] = Pk_k[:d2, :d2] + Ck.dot(Pk1_n[:d2, :d2] - Pk1_k[:d2, :d2]).dot(Ck.T) + states_smoothed.append(xk_n) + covs_smoothed.append(Pk_n) + + return np.flipud(np.vstack(states_smoothed)), np.stack(covs_smoothed, 0)[::-1] diff --git a/rednose/helpers/feature_handler.py b/rednose/helpers/feature_handler.py new file mode 100755 index 00000000000000..f8ac65145c351a --- /dev/null +++ b/rednose/helpers/feature_handler.py @@ -0,0 +1,158 @@ +#!/usr/bin/env python3 + +import os +import sys + +import numpy as np + +from rednose.helpers import TEMPLATE_DIR, load_code, write_code +from rednose.helpers.sympy_helpers import quat_matrix_l, rot_matrix + + +def sane(track): + img_pos = track[1:, 2:4] + diffs_x = abs(img_pos[1:, 0] - img_pos[:-1, 0]) + diffs_y = abs(img_pos[1:, 1] - img_pos[:-1, 1]) + for i in range(1, len(diffs_x)): + if ((diffs_x[i] > 0.05 or diffs_x[i - 1] > 0.05) and + (diffs_x[i] > 2 * diffs_x[i - 1] or + diffs_x[i] < .5 * diffs_x[i - 1])) or \ + ((diffs_y[i] > 0.05 or diffs_y[i - 1] > 0.05) and + (diffs_y[i] > 2 * diffs_y[i - 1] or + diffs_y[i] < .5 * diffs_y[i - 1])): + return False + return True + + +class FeatureHandler(): + name = 'feature_handler' + + @staticmethod + def generate_code(generated_dir, K=5): + # Wrap c code for slow matching + c_header = "\nvoid merge_features(double *tracks, double *features, long long *empty_idxs);" + + c_code = "#include \n" + c_code += "#include \n" + c_code += "#define K %d\n" % K + c_code += "\n" + open(os.path.join(TEMPLATE_DIR, "feature_handler.c")).read() + + filename = f"{FeatureHandler.name}_{K}" + write_code(generated_dir, filename, c_code, c_header) + + def __init__(self, generated_dir, K=5): + self.MAX_TRACKS = 6000 + self.K = K + + # Array of tracks, each track has K 5D features preceded + # by 5 params that inidicate [f_idx, last_idx, updated, complete, valid] + # f_idx: idx of current last feature in track + # idx of of last feature in frame + # bool for whether this track has been update + # bool for whether this track is complete + # bool for whether this track is valid + self.tracks = np.zeros((self.MAX_TRACKS, K + 1, 5)) + self.tracks[:] = np.nan + + name = f"{FeatureHandler.name}_{K}" + ffi, lib = load_code(generated_dir, name) + + def merge_features_c(tracks, features, empty_idxs): + lib.merge_features(ffi.cast("double *", tracks.ctypes.data), + ffi.cast("double *", features.ctypes.data), + ffi.cast("long long *", empty_idxs.ctypes.data)) + + # self.merge_features = self.merge_features_python + self.merge_features = merge_features_c + + def reset(self): + self.tracks[:] = np.nan + + def merge_features_python(self, tracks, features, empty_idxs): + empty_idx = 0 + for f in features: + match_idx = int(f[4]) + if tracks[match_idx, 0, 1] == match_idx and tracks[match_idx, 0, 2] == 0: + tracks[match_idx, 0, 0] += 1 + tracks[match_idx, 0, 1] = f[1] + tracks[match_idx, 0, 2] = 1 + tracks[match_idx, int(tracks[match_idx, 0, 0])] = f + if tracks[match_idx, 0, 0] == self.K: + tracks[match_idx, 0, 3] = 1 + if sane(tracks[match_idx]): + tracks[match_idx, 0, 4] = 1 + else: + if empty_idx == len(empty_idxs): + print('need more empty space') + continue + tracks[empty_idxs[empty_idx], 0, 0] = 1 + tracks[empty_idxs[empty_idx], 0, 1] = f[1] + tracks[empty_idxs[empty_idx], 0, 2] = 1 + tracks[empty_idxs[empty_idx], 1] = f + empty_idx += 1 + + def update_tracks(self, features): + last_idxs = np.copy(self.tracks[:, 0, 1]) + real = np.isfinite(last_idxs) + self.tracks[last_idxs[real].astype(int)] = self.tracks[real] + + mask = np.ones(self.MAX_TRACKS, np.bool) + mask[last_idxs[real].astype(int)] = 0 + empty_idxs = np.arange(self.MAX_TRACKS)[mask] + + self.tracks[empty_idxs] = np.nan + self.tracks[:, 0, 2] = 0 + self.merge_features(self.tracks, features, empty_idxs) + + def handle_features(self, features): + self.update_tracks(features) + valid_idxs = self.tracks[:, 0, 4] == 1 + complete_idxs = self.tracks[:, 0, 3] == 1 + stale_idxs = self.tracks[:, 0, 2] == 0 + valid_tracks = self.tracks[valid_idxs] + self.tracks[complete_idxs] = np.nan + self.tracks[stale_idxs] = np.nan + return valid_tracks[:, 1:, :4].reshape((len(valid_tracks), self.K * 4)) + + +def generate_orient_error_jac(K): + import sympy as sp + from rednose.helpers.sympy_helpers import quat_rotate + + x_sym = sp.MatrixSymbol('abr', 3, 1) + dtheta = sp.MatrixSymbol('dtheta', 3, 1) + delta_quat = sp.Matrix(np.ones(4)) + delta_quat[1:, :] = sp.Matrix(0.5 * dtheta[0:3, :]) + poses_sym = sp.MatrixSymbol('poses', 7 * K, 1) + img_pos_sym = sp.MatrixSymbol('img_positions', 2 * K, 1) + alpha, beta, rho = x_sym + to_c = sp.Matrix(rot_matrix(-np.pi / 2, -np.pi / 2, 0)) + pos_0 = sp.Matrix(np.array(poses_sym[K * 7 - 7:K * 7 - 4])[:, 0]) + q = quat_matrix_l(poses_sym[K * 7 - 4:K * 7]) * delta_quat + quat_rot = quat_rotate(*q) + rot_g_to_0 = to_c * quat_rot.T + rows = [] + for i in range(K): + pos_i = sp.Matrix(np.array(poses_sym[i * 7:i * 7 + 3])[:, 0]) + q = quat_matrix_l(poses_sym[7 * i + 3:7 * i + 7]) * delta_quat + quat_rot = quat_rotate(*q) + rot_g_to_i = to_c * quat_rot.T + rot_0_to_i = rot_g_to_i * (rot_g_to_0.T) + trans_0_to_i = rot_g_to_i * (pos_0 - pos_i) + funct_vec = rot_0_to_i * sp.Matrix([alpha, beta, 1]) + rho * trans_0_to_i + h1, h2, h3 = funct_vec + rows.append(h1 / h3 - img_pos_sym[i * 2 + 0]) + rows.append(h2 / h3 - img_pos_sym[i * 2 + 1]) + img_pos_residual_sym = sp.Matrix(rows) + + # sympy into c + sympy_functions = [] + sympy_functions.append(('orient_error_jac', img_pos_residual_sym.jacobian(dtheta), [x_sym, poses_sym, img_pos_sym, dtheta])) + + return sympy_functions + + +if __name__ == "__main__": + K = int(sys.argv[1].split("_")[-1]) + generated_dir = sys.argv[2] + FeatureHandler.generate_code(generated_dir, K=K) diff --git a/rednose/helpers/lst_sq_computer.py b/rednose/helpers/lst_sq_computer.py new file mode 100755 index 00000000000000..18fd6d7f582b9b --- /dev/null +++ b/rednose/helpers/lst_sq_computer.py @@ -0,0 +1,173 @@ +#!/usr/bin/env python3 +import os +import sys + +import numpy as np +import sympy as sp + +from rednose.helpers import TEMPLATE_DIR, load_code, write_code +from rednose.helpers.sympy_helpers import quat_rotate, sympy_into_c, rot_matrix, rotations_from_quats + + +def generate_residual(K): + x_sym = sp.MatrixSymbol('abr', 3, 1) + poses_sym = sp.MatrixSymbol('poses', 7 * K, 1) + img_pos_sym = sp.MatrixSymbol('img_positions', 2 * K, 1) + alpha, beta, rho = x_sym + to_c = sp.Matrix(rot_matrix(-np.pi / 2, -np.pi / 2, 0)) + pos_0 = sp.Matrix(np.array(poses_sym[K * 7 - 7:K * 7 - 4])[:, 0]) + q = poses_sym[K * 7 - 4:K * 7] + quat_rot = quat_rotate(*q) + rot_g_to_0 = to_c * quat_rot.T + rows = [] + + for i in range(K): + pos_i = sp.Matrix(np.array(poses_sym[i * 7:i * 7 + 3])[:, 0]) + q = poses_sym[7 * i + 3:7 * i + 7] + quat_rot = quat_rotate(*q) + rot_g_to_i = to_c * quat_rot.T + rot_0_to_i = rot_g_to_i * rot_g_to_0.T + trans_0_to_i = rot_g_to_i * (pos_0 - pos_i) + funct_vec = rot_0_to_i * sp.Matrix([alpha, beta, 1]) + rho * trans_0_to_i + h1, h2, h3 = funct_vec + rows.append(h1 / h3 - img_pos_sym[i * 2 + 0]) + rows.append(h2 / h3 - img_pos_sym[i * 2 + 1]) + img_pos_residual_sym = sp.Matrix(rows) + + # sympy into c + sympy_functions = [] + sympy_functions.append(('res_fun', img_pos_residual_sym, [x_sym, poses_sym, img_pos_sym])) + sympy_functions.append(('jac_fun', img_pos_residual_sym.jacobian(x_sym), [x_sym, poses_sym, img_pos_sym])) + + return sympy_functions + + +class LstSqComputer(): + name = 'pos_computer' + + @staticmethod + def generate_code(generated_dir, K=4): + sympy_functions = generate_residual(K) + header, code = sympy_into_c(sympy_functions) + + code += "\n#define KDIM %d\n" % K + code += "\n" + open(os.path.join(TEMPLATE_DIR, "compute_pos.c")).read() + + header += """ + void compute_pos(double *to_c, double *in_poses, double *in_img_positions, double *param, double *pos); + """ + + filename = f"{LstSqComputer.name}_{K}" + write_code(generated_dir, filename, code, header) + + def __init__(self, generated_dir, K=4, MIN_DEPTH=2, MAX_DEPTH=500): + self.to_c = rot_matrix(-np.pi / 2, -np.pi / 2, 0) + self.MAX_DEPTH = MAX_DEPTH + self.MIN_DEPTH = MIN_DEPTH + + name = f"{LstSqComputer.name}_{K}" + ffi, lib = load_code(generated_dir, name) + + # wrap c functions + def residual_jac(x, poses, img_positions): + out = np.zeros(((K * 2, 3)), dtype=np.float64) + lib.jac_fun(ffi.cast("double *", x.ctypes.data), + ffi.cast("double *", poses.ctypes.data), + ffi.cast("double *", img_positions.ctypes.data), + ffi.cast("double *", out.ctypes.data)) + return out + self.residual_jac = residual_jac + + def residual(x, poses, img_positions): + out = np.zeros((K * 2), dtype=np.float64) + lib.res_fun(ffi.cast("double *", x.ctypes.data), + ffi.cast("double *", poses.ctypes.data), + ffi.cast("double *", img_positions.ctypes.data), + ffi.cast("double *", out.ctypes.data)) + return out + self.residual = residual + + def compute_pos_c(poses, img_positions): + pos = np.zeros(3, dtype=np.float64) + param = np.zeros(3, dtype=np.float64) + # Can't be a view for the ctype + img_positions = np.copy(img_positions) + lib.compute_pos(ffi.cast("double *", self.to_c.ctypes.data), + ffi.cast("double *", poses.ctypes.data), + ffi.cast("double *", img_positions.ctypes.data), + ffi.cast("double *", param.ctypes.data), + ffi.cast("double *", pos.ctypes.data)) + return pos, param + self.compute_pos_c = compute_pos_c + + def compute_pos(self, poses, img_positions, debug=False): + pos, param = self.compute_pos_c(poses, img_positions) + # pos, param = self.compute_pos_python(poses, img_positions) + + depth = 1 / param[2] + if debug: + # orient_err_jac = self.orient_error_jac(param, poses, img_positions, np.zeros(3)).reshape((-1,2,3)) + jac = self.residual_jac(param, poses, img_positions).reshape((-1, 2, 3)) + res = self.residual(param, poses, img_positions).reshape((-1, 2)) + return pos, param, res, jac # , orient_err_jac + elif (self.MIN_DEPTH < depth < self.MAX_DEPTH): + return pos + else: + return None + + def gauss_newton(self, fun, jac, x, args): + poses, img_positions = args + delta = 1 + counter = 0 + while abs(np.linalg.norm(delta)) > 1e-4 and counter < 30: + delta = np.linalg.pinv(jac(x, poses, img_positions)).dot(fun(x, poses, img_positions)) + x = x - delta + counter += 1 + return [x] + + def compute_pos_python(self, poses, img_positions, check_quality=False): + import scipy.optimize as opt + + # This procedure is also described + # in the MSCKF paper (Mourikis et al. 2007) + x = np.array([img_positions[-1][0], + img_positions[-1][1], 0.1]) + res = opt.leastsq(self.residual, x, Dfun=self.residual_jac, args=(poses, img_positions)) # scipy opt + # res = self.gauss_newton(self.residual, self.residual_jac, x, (poses, img_positions)) # diy gauss_newton + + alpha, beta, rho = res[0] + rot_0_to_g = (rotations_from_quats(poses[-1, 3:])).dot(self.to_c.T) + return (rot_0_to_g.dot(np.array([alpha, beta, 1]))) / rho + poses[-1, :3] + + +# EXPERIMENTAL CODE +def unroll_shutter(img_positions, poses, v, rot_rates, ecef_pos): + # only speed correction for now + t_roll = 0.016 # 16ms rolling shutter? + vroll, vpitch, vyaw = rot_rates + A = 0.5 * np.array([[-1, -vroll, -vpitch, -vyaw], + [vroll, 0, vyaw, -vpitch], + [vpitch, -vyaw, 0, vroll], + [vyaw, vpitch, -vroll, 0]]) + q_dot = A.dot(poses[-1][3:7]) + v = np.append(v, q_dot) + v = np.array([v[0], v[1], v[2], 0, 0, 0, 0]) + current_pose = poses[-1] + v * 0.05 + poses = np.vstack((current_pose, poses)) + dt = -img_positions[:, 1] * t_roll / 0.48 + errs = project(poses, ecef_pos) - project(poses + np.atleast_2d(dt).T.dot(np.atleast_2d(v)), ecef_pos) + return img_positions - errs + + +def project(poses, ecef_pos): + img_positions = np.zeros((len(poses), 2)) + for i, p in enumerate(poses): + cam_frame = rotations_from_quats(p[3:]).T.dot(ecef_pos - p[:3]) + img_positions[i] = np.array([cam_frame[1] / cam_frame[0], cam_frame[2] / cam_frame[0]]) + return img_positions + + +if __name__ == "__main__": + K = int(sys.argv[1].split("_")[-1]) + generated_dir = sys.argv[2] + LstSqComputer.generate_code(generated_dir, K=K) diff --git a/rednose/helpers/sympy_helpers.py b/rednose/helpers/sympy_helpers.py new file mode 100644 index 00000000000000..12b7188e732395 --- /dev/null +++ b/rednose/helpers/sympy_helpers.py @@ -0,0 +1,156 @@ +#!/usr/bin/env python3 +import sympy as sp +import numpy as np + +# TODO: remove code duplication between openpilot.common.orientation +def quat2rot(quats): + quats = np.array(quats) + input_shape = quats.shape + quats = np.atleast_2d(quats) + Rs = np.zeros((quats.shape[0], 3, 3)) + q0 = quats[:, 0] + q1 = quats[:, 1] + q2 = quats[:, 2] + q3 = quats[:, 3] + Rs[:, 0, 0] = q0 * q0 + q1 * q1 - q2 * q2 - q3 * q3 + Rs[:, 0, 1] = 2 * (q1 * q2 - q0 * q3) + Rs[:, 0, 2] = 2 * (q0 * q2 + q1 * q3) + Rs[:, 1, 0] = 2 * (q1 * q2 + q0 * q3) + Rs[:, 1, 1] = q0 * q0 - q1 * q1 + q2 * q2 - q3 * q3 + Rs[:, 1, 2] = 2 * (q2 * q3 - q0 * q1) + Rs[:, 2, 0] = 2 * (q1 * q3 - q0 * q2) + Rs[:, 2, 1] = 2 * (q0 * q1 + q2 * q3) + Rs[:, 2, 2] = q0 * q0 - q1 * q1 - q2 * q2 + q3 * q3 + + if len(input_shape) < 2: + return Rs[0] + else: + return Rs + + +def euler2quat(eulers): + eulers = np.array(eulers) + if len(eulers.shape) > 1: + output_shape = (-1,4) + else: + output_shape = (4,) + eulers = np.atleast_2d(eulers) + gamma, theta, psi = eulers[:,0], eulers[:,1], eulers[:,2] + + q0 = np.cos(gamma / 2) * np.cos(theta / 2) * np.cos(psi / 2) + \ + np.sin(gamma / 2) * np.sin(theta / 2) * np.sin(psi / 2) + q1 = np.sin(gamma / 2) * np.cos(theta / 2) * np.cos(psi / 2) - \ + np.cos(gamma / 2) * np.sin(theta / 2) * np.sin(psi / 2) + q2 = np.cos(gamma / 2) * np.sin(theta / 2) * np.cos(psi / 2) + \ + np.sin(gamma / 2) * np.cos(theta / 2) * np.sin(psi / 2) + q3 = np.cos(gamma / 2) * np.cos(theta / 2) * np.sin(psi / 2) - \ + np.sin(gamma / 2) * np.sin(theta / 2) * np.cos(psi / 2) + + quats = np.array([q0, q1, q2, q3]).T + for i in range(len(quats)): + if quats[i,0] < 0: # pylint: disable=unsubscriptable-object + quats[i] = -quats[i] # pylint: disable=unsupported-assignment-operation,unsubscriptable-object + return quats.reshape(output_shape) + + +def euler2rot(eulers): + return quat2rot(euler2quat(eulers)) + +rotations_from_quats = quat2rot + + +def cross(x): + ret = sp.Matrix(np.zeros((3, 3))) + ret[0, 1], ret[0, 2] = -x[2], x[1] + ret[1, 0], ret[1, 2] = x[2], -x[0] + ret[2, 0], ret[2, 1] = -x[1], x[0] + return ret + + +def rot_matrix(roll, pitch, yaw): + cr, sr = np.cos(roll), np.sin(roll) + cp, sp = np.cos(pitch), np.sin(pitch) + cy, sy = np.cos(yaw), np.sin(yaw) + rr = np.array([[1,0,0],[0, cr,-sr],[0, sr, cr]]) + rp = np.array([[cp,0,sp],[0, 1,0],[-sp, 0, cp]]) + ry = np.array([[cy,-sy,0],[sy, cy,0],[0, 0, 1]]) + return ry.dot(rp.dot(rr)) + + +def euler_rotate(roll, pitch, yaw): + # make symbolic rotation matrix from eulers + matrix_roll = sp.Matrix([[1, 0, 0], + [0, sp.cos(roll), -sp.sin(roll)], + [0, sp.sin(roll), sp.cos(roll)]]) + matrix_pitch = sp.Matrix([[sp.cos(pitch), 0, sp.sin(pitch)], + [0, 1, 0], + [-sp.sin(pitch), 0, sp.cos(pitch)]]) + matrix_yaw = sp.Matrix([[sp.cos(yaw), -sp.sin(yaw), 0], + [sp.sin(yaw), sp.cos(yaw), 0], + [0, 0, 1]]) + return matrix_yaw * matrix_pitch * matrix_roll + + +def quat_rotate(q0, q1, q2, q3): + # make symbolic rotation matrix from quat + return sp.Matrix([[q0**2 + q1**2 - q2**2 - q3**2, 2 * (q1 * q2 + q0 * q3), 2 * (q1 * q3 - q0 * q2)], + [2 * (q1 * q2 - q0 * q3), q0**2 - q1**2 + q2**2 - q3**2, 2 * (q2 * q3 + q0 * q1)], + [2 * (q1 * q3 + q0 * q2), 2 * (q2 * q3 - q0 * q1), q0**2 - q1**2 - q2**2 + q3**2]]).T + + +def quat_matrix_l(p): + return sp.Matrix([[p[0], -p[1], -p[2], -p[3]], + [p[1], p[0], -p[3], p[2]], + [p[2], p[3], p[0], -p[1]], + [p[3], -p[2], p[1], p[0]]]) + + +def quat_matrix_r(p): + return sp.Matrix([[p[0], -p[1], -p[2], -p[3]], + [p[1], p[0], p[3], -p[2]], + [p[2], -p[3], p[0], p[1]], + [p[3], p[2], -p[1], p[0]]]) + + +def sympy_into_c(sympy_functions, global_vars=None): + from sympy.utilities import codegen + routines = [] + for name, expr, args in sympy_functions: + r = codegen.make_routine(name, expr, language="C99", global_vars=global_vars) + + # argument ordering input to sympy is broken with function with output arguments + nargs = [] + + # reorder the input arguments + for aa in args: + if aa is None: + nargs.append(codegen.InputArgument(sp.Symbol('unused'), dimensions=[1, 1])) + continue + found = False + for a in r.arguments: + if str(aa.name) == str(a.name): + nargs.append(a) + found = True + break + if not found: + # [1,1] is a hack for Matrices + nargs.append(codegen.InputArgument(aa, dimensions=[1, 1])) + + # add the output arguments + for a in r.arguments: + if type(a) == codegen.OutputArgument: + nargs.append(a) + + # assert len(r.arguments) == len(args)+1 + r.arguments = nargs + + # add routine to list + routines.append(r) + + [(_, c_code), (_, c_header)] = codegen.get_code_generator('C', 'ekf', 'C99').write(routines, "ekf") + c_header = '\n'.join(x for x in c_header.split("\n") if len(x) > 0 and x[0] != '#') + + c_code = '\n'.join(x for x in c_code.split("\n") if len(x) > 0 and x[0] != '#') + c_code = 'extern "C" {\n#include \n' + c_code + "\n}\n" + + return c_header, c_code diff --git a/rednose/templates/compute_pos.c b/rednose/templates/compute_pos.c new file mode 100644 index 00000000000000..3c7b16efae5f6e --- /dev/null +++ b/rednose/templates/compute_pos.c @@ -0,0 +1,54 @@ +#include +#include +#include + +typedef Eigen::Matrix R3M; +typedef Eigen::Matrix R1M; +typedef Eigen::Matrix O1M; +typedef Eigen::Matrix M3D; + +extern "C" { +void gauss_newton(double *in_x, double *in_poses, double *in_img_positions) { + + double res[KDIM*2] = {0}; + double jac[KDIM*6] = {0}; + + O1M x(in_x); + O1M delta; + int counter = 0; + while ((delta.squaredNorm() > 0.0001 and counter < 30) or counter == 0){ + res_fun(in_x, in_poses, in_img_positions, res); + jac_fun(in_x, in_poses, in_img_positions, jac); + R1M E(res); R3M J(jac); + delta = (J.transpose()*J).inverse() * J.transpose() * E; + x = x - delta; + memcpy(in_x, x.data(), 3 * sizeof(double)); + counter = counter + 1; + } +} + + +void compute_pos(double *to_c, double *poses, double *img_positions, double *param, double *pos) { + param[0] = img_positions[KDIM*2-2]; + param[1] = img_positions[KDIM*2-1]; + param[2] = 0.1; + gauss_newton(param, poses, img_positions); + + Eigen::Quaterniond q; + q.w() = poses[KDIM*7-4]; + q.x() = poses[KDIM*7-3]; + q.y() = poses[KDIM*7-2]; + q.z() = poses[KDIM*7-1]; + M3D RC(to_c); + Eigen::Matrix3d R = q.normalized().toRotationMatrix(); + Eigen::Matrix3d rot = R * RC.transpose(); + + pos[0] = param[0]/param[2]; + pos[1] = param[1]/param[2]; + pos[2] = 1.0/param[2]; + O1M ecef_offset(poses + KDIM*7-7); + O1M ecef_output(pos); + ecef_output = rot*ecef_output + ecef_offset; + memcpy(pos, ecef_output.data(), 3 * sizeof(double)); +} +} diff --git a/rednose/templates/ekf_c.c b/rednose/templates/ekf_c.c new file mode 100644 index 00000000000000..3b4acdfe3cfa48 --- /dev/null +++ b/rednose/templates/ekf_c.c @@ -0,0 +1,123 @@ +#include +#include + +typedef Eigen::Matrix DDM; +typedef Eigen::Matrix EEM; +typedef Eigen::Matrix DEM; + +void predict(double *in_x, double *in_P, double *in_Q, double dt) { + typedef Eigen::Matrix RRM; + + double nx[DIM] = {0}; + double in_F[EDIM*EDIM] = {0}; + + // functions from sympy + f_fun(in_x, dt, nx); + F_fun(in_x, dt, in_F); + + + EEM F(in_F); + EEM P(in_P); + EEM Q(in_Q); + + RRM F_main = F.topLeftCorner(MEDIM, MEDIM); + P.topLeftCorner(MEDIM, MEDIM) = (F_main * P.topLeftCorner(MEDIM, MEDIM)) * F_main.transpose(); + P.topRightCorner(MEDIM, EDIM - MEDIM) = F_main * P.topRightCorner(MEDIM, EDIM - MEDIM); + P.bottomLeftCorner(EDIM - MEDIM, MEDIM) = P.bottomLeftCorner(EDIM - MEDIM, MEDIM) * F_main.transpose(); + + P = P + dt*Q; + + // copy out state + memcpy(in_x, nx, DIM * sizeof(double)); + memcpy(in_P, P.data(), EDIM * EDIM * sizeof(double)); +} + +// note: extra_args dim only correct when null space projecting +// otherwise 1 +template +void update(double *in_x, double *in_P, Hfun h_fun, Hfun H_fun, Hfun Hea_fun, double *in_z, double *in_R, double *in_ea, double MAHA_THRESHOLD) { + typedef Eigen::Matrix ZZM; + typedef Eigen::Matrix ZDM; + typedef Eigen::Matrix XEM; + //typedef Eigen::Matrix EZM; + typedef Eigen::Matrix X1M; + typedef Eigen::Matrix XXM; + + double in_hx[ZDIM] = {0}; + double in_H[ZDIM * DIM] = {0}; + double in_H_mod[EDIM * DIM] = {0}; + double delta_x[EDIM] = {0}; + double x_new[DIM] = {0}; + + + // state x, P + Eigen::Matrix z(in_z); + EEM P(in_P); + ZZM pre_R(in_R); + + // functions from sympy + h_fun(in_x, in_ea, in_hx); + H_fun(in_x, in_ea, in_H); + ZDM pre_H(in_H); + + // get y (y = z - hx) + Eigen::Matrix pre_y(in_hx); pre_y = z - pre_y; + X1M y; XXM H; XXM R; + if (Hea_fun){ + typedef Eigen::Matrix ZAM; + double in_Hea[ZDIM * EADIM] = {0}; + Hea_fun(in_x, in_ea, in_Hea); + ZAM Hea(in_Hea); + XXM A = Hea.transpose().fullPivLu().kernel(); + + + y = A.transpose() * pre_y; + H = A.transpose() * pre_H; + R = A.transpose() * pre_R * A; + } else { + y = pre_y; + H = pre_H; + R = pre_R; + } + // get modified H + H_mod_fun(in_x, in_H_mod); + DEM H_mod(in_H_mod); + XEM H_err = H * H_mod; + + // Do mahalobis distance test + if (MAHA_TEST){ + XXM a = (H_err * P * H_err.transpose() + R).inverse(); + double maha_dist = y.transpose() * a * y; + if (maha_dist > MAHA_THRESHOLD){ + R = 1.0e16 * R; + } + } + + // Outlier resilient weighting + double weight = 1;//(1.5)/(1 + y.squaredNorm()/R.sum()); + + // kalman gains and I_KH + XXM S = ((H_err * P) * H_err.transpose()) + R/weight; + XEM KT = S.fullPivLu().solve(H_err * P.transpose()); + //EZM K = KT.transpose(); TODO: WHY DOES THIS NOT COMPILE? + //EZM K = S.fullPivLu().solve(H_err * P.transpose()).transpose(); + //std::cout << "Here is the matrix rot:\n" << K << std::endl; + EEM I_KH = Eigen::Matrix::Identity() - (KT.transpose() * H_err); + + // update state by injecting dx + Eigen::Matrix dx(delta_x); + dx = (KT.transpose() * y); + memcpy(delta_x, dx.data(), EDIM * sizeof(double)); + err_fun(in_x, delta_x, x_new); + Eigen::Matrix x(x_new); + + // update cov + P = ((I_KH * P) * I_KH.transpose()) + ((KT.transpose() * R) * KT); + + // copy out state + memcpy(in_x, x.data(), DIM * sizeof(double)); + memcpy(in_P, P.data(), EDIM * EDIM * sizeof(double)); + memcpy(in_z, y.data(), y.rows() * sizeof(double)); +} + + diff --git a/rednose/templates/feature_handler.c b/rednose/templates/feature_handler.c new file mode 100644 index 00000000000000..330972339ce263 --- /dev/null +++ b/rednose/templates/feature_handler.c @@ -0,0 +1,58 @@ +extern "C"{ +bool sane(double track [K + 1][5]) { + double diffs_x [K-1]; + double diffs_y [K-1]; + int i; + for (i = 0; i < K-1; i++) { + diffs_x[i] = fabs(track[i+2][2] - track[i+1][2]); + diffs_y[i] = fabs(track[i+2][3] - track[i+1][3]); + } + for (i = 1; i < K-1; i++) { + if (((diffs_x[i] > 0.05 or diffs_x[i-1] > 0.05) and + (diffs_x[i] > 2*diffs_x[i-1] or + diffs_x[i] < .5*diffs_x[i-1])) or + ((diffs_y[i] > 0.05 or diffs_y[i-1] > 0.05) and + (diffs_y[i] > 2*diffs_y[i-1] or + diffs_y[i] < .5*diffs_y[i-1]))){ + return false; + } + } + return true; +} + +void merge_features(double *tracks, double *features, long long *empty_idxs) { + double feature_arr [3000][5]; + memcpy(feature_arr, features, 3000 * 5 * sizeof(double)); + double track_arr [6000][K + 1][5]; + memcpy(track_arr, tracks, (K+1) * 6000 * 5 * sizeof(double)); + int match; + int empty_idx = 0; + int idx; + for (int i = 0; i < 3000; i++) { + match = feature_arr[i][4]; + if (track_arr[match][0][1] == match and track_arr[match][0][2] == 0){ + track_arr[match][0][0] = track_arr[match][0][0] + 1; + track_arr[match][0][1] = feature_arr[i][1]; + track_arr[match][0][2] = 1; + idx = track_arr[match][0][0]; + memcpy(track_arr[match][idx], feature_arr[i], 5 * sizeof(double)); + if (idx == K){ + // label complete + track_arr[match][0][3] = 1; + if (sane(track_arr[match])){ + // label valid + track_arr[match][0][4] = 1; + } + } + } else { + // gen new track with this feature + track_arr[empty_idxs[empty_idx]][0][0] = 1; + track_arr[empty_idxs[empty_idx]][0][1] = feature_arr[i][1]; + track_arr[empty_idxs[empty_idx]][0][2] = 1; + memcpy(track_arr[empty_idxs[empty_idx]][1], feature_arr[i], 5 * sizeof(double)); + empty_idx = empty_idx + 1; + } + } + memcpy(tracks, track_arr, (K+1) * 6000 * 5 * sizeof(double)); +} +} diff --git a/release/build_release2.sh b/release/build_release2.sh new file mode 100755 index 00000000000000..f47686a6be8bb2 --- /dev/null +++ b/release/build_release2.sh @@ -0,0 +1,94 @@ +#!/usr/bin/env bash +set -e + +export GIT_COMMITTER_NAME="Vehicle Researcher" +export GIT_COMMITTER_EMAIL="user@comma.ai" +export GIT_AUTHOR_NAME="Vehicle Researcher" +export GIT_AUTHOR_EMAIL="user@comma.ai" + +export GIT_SSH_COMMAND="ssh -i /data/gitkey" + +# set CLEAN to build outside of CI +if [ ! -z "$CLEAN" ]; then + # Create folders + rm -rf /data/openpilot + mkdir -p /data/openpilot + cd /data/openpilot + + # Create git repo + git init + git remote add origin git@github.com:commaai/openpilot.git + git fetch origin devel-staging +else + cd /data/openpilot + git clean -xdf + git branch -D release2-staging || true +fi + +git fetch origin release2-staging +git fetch origin dashcam-staging + +# Create release2 with no history +if [ ! -z "$CLEAN" ]; then + git checkout --orphan release2-staging origin/devel-staging +else + git checkout --orphan release2-staging +fi + +VERSION=$(cat selfdrive/common/version.h | awk -F[\"-] '{print $2}') +echo "#define COMMA_VERSION \"$VERSION-release\"" > selfdrive/common/version.h + +git commit -m "openpilot v$VERSION" + +# Build signed panda firmware +pushd panda/board/ +cp -r /tmp/pandaextra /data/openpilot/ +RELEASE=1 make obj/panda.bin +mv obj/panda.bin /tmp/panda.bin +make clean +mv /tmp/panda.bin obj/panda.bin.signed +rm -rf /data/openpilot/pandaextra +popd + +# Build stuff +ln -sfn /data/openpilot /data/pythonpath +export PYTHONPATH="/data/openpilot:/data/openpilot/pyextra" +SCONS_CACHE=1 scons -j3 + +# Run tests +nosetests -s selfdrive/test/test_openpilot.py +selfdrive/car/tests/test_car_interfaces.py + +# Cleanup +find . -name '*.a' -delete +find . -name '*.o' -delete +find . -name '*.os' -delete +find . -name '*.pyc' -delete +find . -name '__pycache__' -delete +rm -rf .sconsign.dblite Jenkinsfile release/ + +# Restore phonelibs +git checkout phonelibs/ + +# Mark as prebuilt release +touch prebuilt + +# Add built files to git +git add -f . +git commit --amend -m "openpilot v$VERSION" + +# Print committed files that are normally gitignored +#git status --ignored + +if [ ! -z "$PUSH" ]; then + git remote set-url origin git@github.com:commaai/openpilot.git + + # Push to release2-staging + git push -f origin release2-staging + + # Create dashcam release + git rm selfdrive/car/*/carcontroller.py + + git commit -m "create dashcam release from release2" + git push -f origin release2-staging:dashcam-staging +fi diff --git a/run_docker_tests.sh b/run_docker_tests.sh deleted file mode 100755 index dfee5f86696fb2..00000000000000 --- a/run_docker_tests.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -e - -docker build -t tmppilot -f Dockerfile.openpilot . - -docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && make -C cereal && cd /tmp/openpilot/selfdrive/test/ && ./test_fingerprints.py' -docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && pyflakes $(find . -iname "*.py" | grep -vi "^\./pyextra.*" | grep -vi "^\./panda" | grep -vi "^\./tools")' -docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && pylint $(find . -iname "*.py" | grep -vi "^\./pyextra.*" | grep -vi "^\./panda" | grep -vi "^\./tools"); exit $(($? & 3))' -docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && make -C cereal && python -m unittest discover common' -docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && make -C cereal && python -m unittest discover selfdrive/can' -docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && make -C cereal && python -m unittest discover selfdrive/boardd' -docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && make -C cereal && python -m unittest discover selfdrive/controls' -docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && python -m unittest discover selfdrive/loggerd' -docker run --rm -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' -docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && make -C cereal && cd /tmp/openpilot/selfdrive/test/tests/process_replay/ && ./test_processes.py' -docker run --rm tmppilot /bin/sh -c 'mkdir -p /data/params && cd /tmp/openpilot/ && make -C cereal && cd /tmp/openpilot/selfdrive/test/ && ./test_car_models_openpilot.py' diff --git a/scripts/stop_updater.sh b/scripts/stop_updater.sh new file mode 100755 index 00000000000000..4243d30e9f9ea5 --- /dev/null +++ b/scripts/stop_updater.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh + +# Stop updater +pkill -2 -f selfdrive.updated + +# Remove pending update +rm -f /data/safe_staging/finalized/.overlay_consistent diff --git a/scripts/update_now.sh b/scripts/update_now.sh new file mode 100755 index 00000000000000..3f0193f081a15c --- /dev/null +++ b/scripts/update_now.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh + +# Send SIGHUP to updater +pkill -1 -f selfdrive.updated diff --git a/selfdrive/assets/images/battery.png b/selfdrive/assets/images/battery.png new file mode 100644 index 00000000000000..cac3b9096a756e Binary files /dev/null and b/selfdrive/assets/images/battery.png differ diff --git a/selfdrive/assets/images/battery_charging.png b/selfdrive/assets/images/battery_charging.png new file mode 100644 index 00000000000000..4c25566d075986 Binary files /dev/null and b/selfdrive/assets/images/battery_charging.png differ diff --git a/selfdrive/assets/images/button_home.png b/selfdrive/assets/images/button_home.png new file mode 100644 index 00000000000000..9f52faf9e2da48 Binary files /dev/null and b/selfdrive/assets/images/button_home.png differ diff --git a/selfdrive/assets/images/button_settings.png b/selfdrive/assets/images/button_settings.png new file mode 100644 index 00000000000000..e04262b887cea5 Binary files /dev/null and b/selfdrive/assets/images/button_settings.png differ diff --git a/selfdrive/assets/images/network_0.png b/selfdrive/assets/images/network_0.png new file mode 100644 index 00000000000000..2ce959ca5f9b4e Binary files /dev/null and b/selfdrive/assets/images/network_0.png differ diff --git a/selfdrive/assets/images/network_1.png b/selfdrive/assets/images/network_1.png new file mode 100644 index 00000000000000..d7ae713f9090ce Binary files /dev/null and b/selfdrive/assets/images/network_1.png differ diff --git a/selfdrive/assets/images/network_2.png b/selfdrive/assets/images/network_2.png new file mode 100644 index 00000000000000..17ecd977f1ead7 Binary files /dev/null and b/selfdrive/assets/images/network_2.png differ diff --git a/selfdrive/assets/images/network_3.png b/selfdrive/assets/images/network_3.png new file mode 100644 index 00000000000000..1e854e678db733 Binary files /dev/null and b/selfdrive/assets/images/network_3.png differ diff --git a/selfdrive/assets/images/network_4.png b/selfdrive/assets/images/network_4.png new file mode 100644 index 00000000000000..08c9ab91f4990c Binary files /dev/null and b/selfdrive/assets/images/network_4.png differ diff --git a/selfdrive/assets/images/network_5.png b/selfdrive/assets/images/network_5.png new file mode 100644 index 00000000000000..fba67a95a5a786 Binary files /dev/null and b/selfdrive/assets/images/network_5.png differ diff --git a/selfdrive/assets/img_spinner_comma.honda.png b/selfdrive/assets/img_spinner_comma.honda.png deleted file mode 100644 index 0e4db4dae7cb0c..00000000000000 Binary files a/selfdrive/assets/img_spinner_comma.honda.png and /dev/null differ diff --git a/selfdrive/assets/img_spinner_comma.honda2.png b/selfdrive/assets/img_spinner_comma.honda2.png deleted file mode 100644 index bc6c475b782129..00000000000000 Binary files a/selfdrive/assets/img_spinner_comma.honda2.png and /dev/null differ diff --git a/selfdrive/assets/img_spinner_comma.toyota.png b/selfdrive/assets/img_spinner_comma.toyota.png deleted file mode 100644 index 63d9334491e764..00000000000000 Binary files a/selfdrive/assets/img_spinner_comma.toyota.png and /dev/null differ diff --git a/selfdrive/assets/img_spinner_comma.toyota2.png b/selfdrive/assets/img_spinner_comma.toyota2.png deleted file mode 100644 index 609b7ab26ba428..00000000000000 Binary files a/selfdrive/assets/img_spinner_comma.toyota2.png and /dev/null differ diff --git a/selfdrive/assets/offroad/circled-checkmark-empty.png b/selfdrive/assets/offroad/circled-checkmark-empty.png new file mode 100644 index 00000000000000..e6740f11056bf6 Binary files /dev/null and b/selfdrive/assets/offroad/circled-checkmark-empty.png differ diff --git a/selfdrive/assets/offroad/circled-checkmark.png b/selfdrive/assets/offroad/circled-checkmark.png new file mode 100644 index 00000000000000..bc6b49585d098c Binary files /dev/null and b/selfdrive/assets/offroad/circled-checkmark.png differ diff --git a/selfdrive/assets/offroad/icon_app_store.png b/selfdrive/assets/offroad/icon_app_store.png new file mode 100644 index 00000000000000..ae0dd95ceee604 Binary files /dev/null and b/selfdrive/assets/offroad/icon_app_store.png differ diff --git a/selfdrive/assets/offroad/icon_calibration.png b/selfdrive/assets/offroad/icon_calibration.png new file mode 100644 index 00000000000000..c4ee0d63d46210 Binary files /dev/null and b/selfdrive/assets/offroad/icon_calibration.png differ diff --git a/selfdrive/assets/offroad/icon_checkmark.png b/selfdrive/assets/offroad/icon_checkmark.png new file mode 100644 index 00000000000000..06efdfb0cbc471 Binary files /dev/null and b/selfdrive/assets/offroad/icon_checkmark.png differ diff --git a/selfdrive/assets/offroad/icon_chevron_right.png b/selfdrive/assets/offroad/icon_chevron_right.png new file mode 100644 index 00000000000000..a3aaa76486170d Binary files /dev/null and b/selfdrive/assets/offroad/icon_chevron_right.png differ diff --git a/selfdrive/assets/offroad/icon_connect_app.png b/selfdrive/assets/offroad/icon_connect_app.png new file mode 100644 index 00000000000000..cd216d3e6f4aae Binary files /dev/null and b/selfdrive/assets/offroad/icon_connect_app.png differ diff --git a/selfdrive/assets/offroad/icon_eon.png b/selfdrive/assets/offroad/icon_eon.png new file mode 100644 index 00000000000000..72856c4e685d8a Binary files /dev/null and b/selfdrive/assets/offroad/icon_eon.png differ diff --git a/selfdrive/assets/offroad/icon_map.png b/selfdrive/assets/offroad/icon_map.png new file mode 100644 index 00000000000000..21dd0bacc65f76 Binary files /dev/null and b/selfdrive/assets/offroad/icon_map.png differ diff --git a/selfdrive/assets/offroad/icon_map_speed.png b/selfdrive/assets/offroad/icon_map_speed.png new file mode 100644 index 00000000000000..1eeab84600e3f0 Binary files /dev/null and b/selfdrive/assets/offroad/icon_map_speed.png differ diff --git a/selfdrive/assets/offroad/icon_menu.png b/selfdrive/assets/offroad/icon_menu.png new file mode 100644 index 00000000000000..837cf5831c3b15 Binary files /dev/null and b/selfdrive/assets/offroad/icon_menu.png differ diff --git a/selfdrive/assets/offroad/icon_metric.png b/selfdrive/assets/offroad/icon_metric.png new file mode 100644 index 00000000000000..eaa2438fa3701c Binary files /dev/null and b/selfdrive/assets/offroad/icon_metric.png differ diff --git a/selfdrive/assets/offroad/icon_minus.png b/selfdrive/assets/offroad/icon_minus.png new file mode 100644 index 00000000000000..e5327c0d3b2d48 Binary files /dev/null and b/selfdrive/assets/offroad/icon_minus.png differ diff --git a/selfdrive/assets/offroad/icon_monitoring.png b/selfdrive/assets/offroad/icon_monitoring.png new file mode 100644 index 00000000000000..05f78811e274a5 Binary files /dev/null and b/selfdrive/assets/offroad/icon_monitoring.png differ diff --git a/selfdrive/assets/offroad/icon_network.png b/selfdrive/assets/offroad/icon_network.png new file mode 100644 index 00000000000000..3236924f4dd90b Binary files /dev/null and b/selfdrive/assets/offroad/icon_network.png differ diff --git a/selfdrive/assets/offroad/icon_openpilot.png b/selfdrive/assets/offroad/icon_openpilot.png new file mode 100644 index 00000000000000..0a90a879106c89 Binary files /dev/null and b/selfdrive/assets/offroad/icon_openpilot.png differ diff --git a/selfdrive/assets/offroad/icon_openpilot_mirrored.png b/selfdrive/assets/offroad/icon_openpilot_mirrored.png new file mode 100644 index 00000000000000..23a7d5a5528b78 Binary files /dev/null and b/selfdrive/assets/offroad/icon_openpilot_mirrored.png differ diff --git a/selfdrive/assets/offroad/icon_play_store.png b/selfdrive/assets/offroad/icon_play_store.png new file mode 100644 index 00000000000000..1eca9d58902f8a Binary files /dev/null and b/selfdrive/assets/offroad/icon_play_store.png differ diff --git a/selfdrive/assets/offroad/icon_plus.png b/selfdrive/assets/offroad/icon_plus.png new file mode 100644 index 00000000000000..92b448b0bdcfcb Binary files /dev/null and b/selfdrive/assets/offroad/icon_plus.png differ diff --git a/selfdrive/assets/offroad/icon_road.png b/selfdrive/assets/offroad/icon_road.png new file mode 100644 index 00000000000000..5868ed1ccc3f73 Binary files /dev/null and b/selfdrive/assets/offroad/icon_road.png differ diff --git a/selfdrive/assets/offroad/icon_settings.png b/selfdrive/assets/offroad/icon_settings.png new file mode 100644 index 00000000000000..d0c90a620d780d Binary files /dev/null and b/selfdrive/assets/offroad/icon_settings.png differ diff --git a/selfdrive/assets/offroad/icon_shell.png b/selfdrive/assets/offroad/icon_shell.png new file mode 100644 index 00000000000000..f1d655416a88c6 Binary files /dev/null and b/selfdrive/assets/offroad/icon_shell.png differ diff --git a/selfdrive/assets/offroad/icon_speed_limit.png b/selfdrive/assets/offroad/icon_speed_limit.png new file mode 100644 index 00000000000000..0aa7038f909985 Binary files /dev/null and b/selfdrive/assets/offroad/icon_speed_limit.png differ diff --git a/selfdrive/assets/offroad/icon_user.png b/selfdrive/assets/offroad/icon_user.png new file mode 100644 index 00000000000000..9b653cc4b3f620 Binary files /dev/null and b/selfdrive/assets/offroad/icon_user.png differ diff --git a/selfdrive/assets/offroad/icon_warning.png b/selfdrive/assets/offroad/icon_warning.png new file mode 100644 index 00000000000000..50fe8211277954 Binary files /dev/null and b/selfdrive/assets/offroad/icon_warning.png differ diff --git a/selfdrive/assets/offroad/illustration_arrow.png b/selfdrive/assets/offroad/illustration_arrow.png new file mode 100644 index 00000000000000..22190866419e47 Binary files /dev/null and b/selfdrive/assets/offroad/illustration_arrow.png differ diff --git a/selfdrive/assets/offroad/illustration_sim_absent.png b/selfdrive/assets/offroad/illustration_sim_absent.png new file mode 100644 index 00000000000000..554097409bc0a5 Binary files /dev/null and b/selfdrive/assets/offroad/illustration_sim_absent.png differ diff --git a/selfdrive/assets/offroad/illustration_sim_present.png b/selfdrive/assets/offroad/illustration_sim_present.png new file mode 100644 index 00000000000000..0856795f019ffc Binary files /dev/null and b/selfdrive/assets/offroad/illustration_sim_present.png differ diff --git a/selfdrive/assets/offroad/illustration_training_lane_01.png b/selfdrive/assets/offroad/illustration_training_lane_01.png new file mode 100644 index 00000000000000..27d9bcee3e1be0 Binary files /dev/null and b/selfdrive/assets/offroad/illustration_training_lane_01.png differ diff --git a/selfdrive/assets/offroad/illustration_training_lane_02.png b/selfdrive/assets/offroad/illustration_training_lane_02.png new file mode 100644 index 00000000000000..4f3e2ef44c1de5 Binary files /dev/null and b/selfdrive/assets/offroad/illustration_training_lane_02.png differ diff --git a/selfdrive/assets/offroad/illustration_training_lead_01.png b/selfdrive/assets/offroad/illustration_training_lead_01.png new file mode 100644 index 00000000000000..12f3f6bae8ccc2 Binary files /dev/null and b/selfdrive/assets/offroad/illustration_training_lead_01.png differ diff --git a/selfdrive/assets/offroad/illustration_training_lead_02.png b/selfdrive/assets/offroad/illustration_training_lead_02.png new file mode 100644 index 00000000000000..26c9ffe7197b2f Binary files /dev/null and b/selfdrive/assets/offroad/illustration_training_lead_02.png differ diff --git a/selfdrive/assets/offroad/indicator_wifi_0.png b/selfdrive/assets/offroad/indicator_wifi_0.png new file mode 100644 index 00000000000000..9cf9762ad3d8f3 Binary files /dev/null and b/selfdrive/assets/offroad/indicator_wifi_0.png differ diff --git a/selfdrive/assets/offroad/indicator_wifi_100.png b/selfdrive/assets/offroad/indicator_wifi_100.png new file mode 100644 index 00000000000000..dc9f28fab3917b Binary files /dev/null and b/selfdrive/assets/offroad/indicator_wifi_100.png differ diff --git a/selfdrive/assets/offroad/indicator_wifi_25.png b/selfdrive/assets/offroad/indicator_wifi_25.png new file mode 100644 index 00000000000000..cbf9bc89e52588 Binary files /dev/null and b/selfdrive/assets/offroad/indicator_wifi_25.png differ diff --git a/selfdrive/assets/offroad/indicator_wifi_50.png b/selfdrive/assets/offroad/indicator_wifi_50.png new file mode 100644 index 00000000000000..8ee118a419506b Binary files /dev/null and b/selfdrive/assets/offroad/indicator_wifi_50.png differ diff --git a/selfdrive/assets/offroad/indicator_wifi_75.png b/selfdrive/assets/offroad/indicator_wifi_75.png new file mode 100644 index 00000000000000..bcbebce85d754c Binary files /dev/null and b/selfdrive/assets/offroad/indicator_wifi_75.png differ diff --git a/selfdrive/assets/sounds/disengaged.wav b/selfdrive/assets/sounds/disengaged.wav index 655aa31261df04..3aa8e51e690420 100644 Binary files a/selfdrive/assets/sounds/disengaged.wav and b/selfdrive/assets/sounds/disengaged.wav differ diff --git a/selfdrive/assets/sounds/engaged.wav b/selfdrive/assets/sounds/engaged.wav index b33e8181fac3ee..1451f937f32879 100644 Binary files a/selfdrive/assets/sounds/engaged.wav and b/selfdrive/assets/sounds/engaged.wav differ diff --git a/selfdrive/assets/sounds/error.wav b/selfdrive/assets/sounds/error.wav index 309eaef8ae4d21..e805181aeb6374 100644 Binary files a/selfdrive/assets/sounds/error.wav and b/selfdrive/assets/sounds/error.wav differ diff --git a/selfdrive/assets/sounds/warning_1.wav b/selfdrive/assets/sounds/warning_1.wav index 920c11846a13d2..43ca74cc5cbfa2 100644 Binary files a/selfdrive/assets/sounds/warning_1.wav and b/selfdrive/assets/sounds/warning_1.wav differ diff --git a/selfdrive/assets/sounds/warning_2.wav b/selfdrive/assets/sounds/warning_2.wav index f5ed8521dd0ac8..4909f11982df11 100644 Binary files a/selfdrive/assets/sounds/warning_2.wav and b/selfdrive/assets/sounds/warning_2.wav differ diff --git a/selfdrive/assets/sounds/warning_repeat.wav b/selfdrive/assets/sounds/warning_repeat.wav new file mode 100644 index 00000000000000..9f6f672e2829c0 Binary files /dev/null and b/selfdrive/assets/sounds/warning_repeat.wav differ diff --git a/selfdrive/athena/athenad.py b/selfdrive/athena/athenad.py index 6aa84d106e009f..27e8b587f111f9 100755 --- a/selfdrive/athena/athenad.py +++ b/selfdrive/athena/athenad.py @@ -1,52 +1,59 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python3 +import base64 +import hashlib +import io import json -import jwt import os +import queue import random -import re import select -import subprocess import socket -import time import threading -import traceback -import zmq -import requests -import six.moves.queue -from datetime import datetime, timedelta +import time +from collections import namedtuple from functools import partial +from typing import Any + +import requests from jsonrpc import JSONRPCResponseManager, dispatcher -from websocket import create_connection, WebSocketTimeoutException, ABNF -from selfdrive.loggerd.config import ROOT +from websocket import ABNF, WebSocketTimeoutException, create_connection -import selfdrive.crash as crash -import selfdrive.messaging as messaging +import cereal.messaging as messaging +from cereal.services import service_list from common.api import Api +from common.basedir import PERSIST from common.params import Params -from selfdrive.services import service_list +from common.realtime import sec_since_boot +from selfdrive.hardware import HARDWARE +from selfdrive.loggerd.config import ROOT from selfdrive.swaglog import cloudlog -from selfdrive.version import version, dirty ATHENA_HOST = os.getenv('ATHENA_HOST', 'wss://athena.comma.ai') -HANDLER_THREADS = os.getenv('HANDLER_THREADS', 4) +HANDLER_THREADS = int(os.getenv('HANDLER_THREADS', "4")) LOCAL_PORT_WHITELIST = set([8022]) dispatcher["echo"] = lambda s: s -payload_queue = six.moves.queue.Queue() -response_queue = six.moves.queue.Queue() +payload_queue: Any = queue.Queue() +response_queue: Any = queue.Queue() +upload_queue: Any = queue.Queue() +cancelled_uploads: Any = set() +UploadItem = namedtuple('UploadItem', ['path', 'url', 'headers', 'created_at', 'id']) + def handle_long_poll(ws): end_event = threading.Event() threads = [ threading.Thread(target=ws_recv, args=(ws, end_event)), - threading.Thread(target=ws_send, args=(ws, end_event)) + threading.Thread(target=ws_send, args=(ws, end_event)), + threading.Thread(target=upload_handler, args=(end_event,)) ] + [ threading.Thread(target=jsonrpc_handler, args=(end_event,)) - for x in xrange(HANDLER_THREADS) + for x in range(HANDLER_THREADS) ] - map(lambda thread: thread.start(), threads) + for thread in threads: + thread.start() try: while not end_event.is_set(): time.sleep(0.1) @@ -54,9 +61,10 @@ def handle_long_poll(ws): end_event.set() raise finally: - for i, thread in enumerate(threads): + for thread in threads: thread.join() + def jsonrpc_handler(end_event): dispatcher["startLocalProxy"] = partial(startLocalProxy, end_event) while not end_event.is_set(): @@ -64,49 +72,113 @@ def jsonrpc_handler(end_event): data = payload_queue.get(timeout=1) response = JSONRPCResponseManager.handle(data, dispatcher) response_queue.put_nowait(response) - except six.moves.queue.Empty: + except queue.Empty: pass except Exception as e: cloudlog.exception("athena jsonrpc handler failed") - traceback.print_exc() response_queue.put_nowait(json.dumps({"error": str(e)})) + +def upload_handler(end_event): + while not end_event.is_set(): + try: + item = upload_queue.get(timeout=1) + if item.id in cancelled_uploads: + cancelled_uploads.remove(item.id) + continue + _do_upload(item) + except queue.Empty: + pass + except Exception: + cloudlog.exception("athena.upload_handler.exception") + + +def _do_upload(upload_item): + with open(upload_item.path, "rb") as f: + size = os.fstat(f.fileno()).st_size + return requests.put(upload_item.url, + data=f, + headers={**upload_item.headers, 'Content-Length': str(size)}, + timeout=10) + + # security: user should be able to request any message from their car -# TODO: add service to, for example, start visiond and take a picture @dispatcher.add_method def getMessage(service=None, timeout=1000): if service is None or service not in service_list: raise Exception("invalid service") - socket = messaging.sub_sock(service_list[service].port) - socket.setsockopt(zmq.RCVTIMEO, timeout) + + socket = messaging.sub_sock(service, timeout=timeout) ret = messaging.recv_one(socket) + + if ret is None: + raise TimeoutError + return ret.to_dict() + @dispatcher.add_method def listDataDirectory(): files = [os.path.relpath(os.path.join(dp, f), ROOT) for dp, dn, fn in os.walk(ROOT) for f in fn] return files + +@dispatcher.add_method +def reboot(): + thermal_sock = messaging.sub_sock("thermal", timeout=1000) + ret = messaging.recv_one(thermal_sock) + if ret is None or ret.thermal.started: + raise Exception("Reboot unavailable") + + def do_reboot(): + time.sleep(2) + HARDWARE.reboot() + + threading.Thread(target=do_reboot).start() + + return {"success": 1} + + @dispatcher.add_method def uploadFileToUrl(fn, url, headers): if len(fn) == 0 or fn[0] == '/' or '..' in fn: return 500 - with open(os.path.join(ROOT, fn), "rb") as f: - ret = requests.put(url, data=f, headers=headers, timeout=10) - return ret.status_code + path = os.path.join(ROOT, fn) + if not os.path.exists(path): + return 404 + + item = UploadItem(path=path, url=url, headers=headers, created_at=int(time.time() * 1000), id=None) + upload_id = hashlib.sha1(str(item).encode()).hexdigest() + item = item._replace(id=upload_id) + + upload_queue.put_nowait(item) + + return {"enqueued": 1, "item": item._asdict()} + + +@dispatcher.add_method +def listUploadQueue(): + return [item._asdict() for item in list(upload_queue.queue)] + + +@dispatcher.add_method +def cancelUpload(upload_id): + upload_ids = set(item.id for item in list(upload_queue.queue)) + if upload_id not in upload_ids: + return 404 + + cancelled_uploads.add(upload_id) + return {"success": 1} + def startLocalProxy(global_end_event, remote_ws_uri, local_port): try: - cloudlog.event("athena startLocalProxy", remote_ws_uri=remote_ws_uri, local_port=local_port) - if local_port not in LOCAL_PORT_WHITELIST: raise Exception("Requested local port not whitelisted") params = Params() - dongle_id = params.get("DongleId") - private_key = open("/persist/comma/id_rsa").read() - identity_token = jwt.encode({'identity':dongle_id, 'exp': datetime.utcnow() + timedelta(hours=1)}, private_key, algorithm='RS256') - + dongle_id = params.get("DongleId").decode('utf8') + identity_token = Api(dongle_id).get_token() ws = create_connection(remote_ws_uri, cookie="jwt=" + identity_token, enable_multithread=True) @@ -121,48 +193,56 @@ def startLocalProxy(global_end_event, remote_ws_uri, local_port): threading.Thread(target=ws_proxy_recv, args=(ws, local_sock, ssock, proxy_end_event, global_end_event)), threading.Thread(target=ws_proxy_send, args=(ws, local_sock, csock, proxy_end_event)) ] - - map(lambda thread: thread.start(), threads) + for thread in threads: + thread.start() return {"success": 1} except Exception as e: - traceback.print_exc() + cloudlog.exception("athenad.startLocalProxy.exception") raise e + @dispatcher.add_method def getPublicKey(): - if not os.path.isfile('/persist/comma/id_rsa.pub'): + if not os.path.isfile(PERSIST + '/comma/id_rsa.pub'): return None - with open('/persist/comma/id_rsa.pub', 'r') as f: + with open(PERSIST + '/comma/id_rsa.pub', 'r') as f: return f.read() + @dispatcher.add_method def getSshAuthorizedKeys(): - with open('/system/comma/home/.ssh/authorized_keys', 'r') as f: - return f.read() + return Params().get("GithubSshKeys", encoding='utf8') or '' + @dispatcher.add_method def getSimInfo(): - sim_state = subprocess.check_output(['getprop', 'gsm.sim.state']).strip().split(',') - network_type = subprocess.check_output(['getprop', 'gsm.network.type']).strip().split(',') - mcc_mnc = subprocess.check_output(['getprop', 'gsm.sim.operator.numeric']).strip() or None - - sim_id_aidl_out = subprocess.check_output(['service', 'call', 'iphonesubinfo', '11']) - sim_id_aidl_lines = sim_id_aidl_out.split('\n') - if len(sim_id_aidl_lines) > 3: - sim_id_lines = sim_id_aidl_lines[1:4] - sim_id_fragments = [re.search(r"'([0-9\.]+)'", line).group(1) for line in sim_id_lines] - sim_id = reduce(lambda frag1, frag2: frag1.replace('.', '') + frag2.replace('.', ''), sim_id_fragments) + return HARDWARE.get_sim_info() + + +@dispatcher.add_method +def getNetworkType(): + return HARDWARE.get_network_type() + + +@dispatcher.add_method +def takeSnapshot(): + from selfdrive.camerad.snapshot.snapshot import snapshot, jpeg_write + ret = snapshot() + if ret is not None: + def b64jpeg(x): + if x is not None: + f = io.BytesIO() + jpeg_write(f, x) + return base64.b64encode(f.getvalue()).decode("utf-8") + else: + return None + return {'jpegBack': b64jpeg(ret[0]), + 'jpegFront': b64jpeg(ret[1])} else: - sim_id = None + raise Exception("not available while camerad is started") - return { - 'sim_id': sim_id, - 'mcc_mnc': mcc_mnc, - 'network_type': network_type, - 'sim_state': sim_state - } def ws_proxy_recv(ws, local_sock, ssock, end_event, global_end_event): while not (end_event.is_set() or global_end_event.is_set()): @@ -172,12 +252,14 @@ def ws_proxy_recv(ws, local_sock, ssock, end_event, global_end_event): except WebSocketTimeoutException: pass except Exception: - traceback.print_exc() + cloudlog.exception("athenad.ws_proxy_recv.exception") break ssock.close() + local_sock.close() end_event.set() + def ws_proxy_send(ws, local_sock, signal_sock, end_event): while not end_event.is_set(): try: @@ -195,65 +277,69 @@ def ws_proxy_send(ws, local_sock, signal_sock, end_event): ws.send(data, ABNF.OPCODE_BINARY) except Exception: - traceback.print_exc() - end_event.set() + cloudlog.exception("athenad.ws_proxy_send.exception") + end_event.set() + def ws_recv(ws, end_event): while not end_event.is_set(): try: - data = ws.recv() - payload_queue.put_nowait(data) + opcode, data = ws.recv_data(control_frame=True) + if opcode in (ABNF.OPCODE_TEXT, ABNF.OPCODE_BINARY): + if opcode == ABNF.OPCODE_TEXT: + data = data.decode("utf-8") + payload_queue.put_nowait(data) + elif opcode == ABNF.OPCODE_PING: + Params().put("LastAthenaPingTime", str(int(sec_since_boot() * 1e9))) except WebSocketTimeoutException: pass except Exception: - traceback.print_exc() + cloudlog.exception("athenad.ws_recv.exception") end_event.set() + def ws_send(ws, end_event): while not end_event.is_set(): try: response = response_queue.get(timeout=1) ws.send(response.json) - except six.moves.queue.Empty: + except queue.Empty: pass except Exception: - traceback.print_exc() + cloudlog.exception("athenad.ws_send.exception") end_event.set() + def backoff(retries): return random.randrange(0, min(128, int(2 ** retries))) -def main(gctx=None): + +def main(): params = Params() - dongle_id = params.get("DongleId") + dongle_id = params.get("DongleId").decode('utf-8') ws_uri = ATHENA_HOST + "/ws/v2/" + dongle_id - crash.bind_user(id=dongle_id) - crash.bind_extra(version=version, dirty=dirty, is_eon=True) - crash.install() - - private_key = open("/persist/comma/id_rsa").read() - api = Api(dongle_id, private_key) + api = Api(dongle_id) conn_retries = 0 while 1: try: - print("connecting to %s" % ws_uri) ws = create_connection(ws_uri, cookie="jwt=" + api.get_token(), enable_multithread=True) + cloudlog.event("athenad.main.connected_ws", ws_uri=ws_uri) ws.settimeout(1) conn_retries = 0 handle_long_poll(ws) except (KeyboardInterrupt, SystemExit): break except Exception: + cloudlog.exception("athenad.main.exception") conn_retries += 1 - traceback.print_exc() + params.delete("LastAthenaPingTime") time.sleep(backoff(conn_retries)) - params.delete("AthenadPid") if __name__ == "__main__": main() diff --git a/selfdrive/athena/manage_athenad.py b/selfdrive/athena/manage_athenad.py new file mode 100755 index 00000000000000..49120d972fb41a --- /dev/null +++ b/selfdrive/athena/manage_athenad.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 + +import time +from multiprocessing import Process + +import selfdrive.crash as crash +from common.params import Params +from selfdrive.launcher import launcher +from selfdrive.swaglog import cloudlog +from selfdrive.version import version, dirty + +ATHENA_MGR_PID_PARAM = "AthenadPid" + +def main(): + params = Params() + dongle_id = params.get("DongleId").decode('utf-8') + cloudlog.bind_global(dongle_id=dongle_id, version=version, dirty=dirty, is_eon=True) + crash.bind_user(id=dongle_id) + crash.bind_extra(version=version, dirty=dirty, is_eon=True) + crash.install() + + try: + while 1: + cloudlog.info("starting athena daemon") + proc = Process(name='athenad', target=launcher, args=('selfdrive.athena.athenad',)) + proc.start() + proc.join() + cloudlog.event("athenad exited", exitcode=proc.exitcode) + time.sleep(5) + except Exception: + cloudlog.exception("manage_athenad.exception") + finally: + params.delete(ATHENA_MGR_PID_PARAM) + +if __name__ == '__main__': + main() diff --git a/selfdrive/boardd/.gitignore b/selfdrive/boardd/.gitignore index b030dc97cdec07..1f653bde8fb8cc 100644 --- a/selfdrive/boardd/.gitignore +++ b/selfdrive/boardd/.gitignore @@ -1 +1,2 @@ boardd +boardd_api_impl.cpp diff --git a/selfdrive/boardd/Makefile b/selfdrive/boardd/Makefile deleted file mode 100644 index c6b5f21910fe56..00000000000000 --- a/selfdrive/boardd/Makefile +++ /dev/null @@ -1,109 +0,0 @@ -CC = clang -CXX = clang++ - -ARCH := $(shell uname -m) -OS := $(shell uname -o) - -BASEDIR = ../.. -PHONELIBS = ../../phonelibs - -WARN_FLAGS = -Werror=implicit-function-declaration \ - -Werror=incompatible-pointer-types \ - -Werror=int-conversion \ - -Werror=return-type \ - -Werror=format-extra-args - -CFLAGS = -std=gnu11 -g -fPIC -I../ -I../../ -O2 $(WARN_FLAGS) -CXXFLAGS = -std=c++11 -g -fPIC -I../ -I../../ -O2 $(WARN_FLAGS) - -ZMQ_LIBS = -l:libczmq.a -l:libzmq.a -lgnustl_shared - -JSON_FLAGS = -I$(PHONELIBS)/json/src - -EXTRA_LIBS = -lusb-1.0 - -# ifeq ($(OS),GNU/Linux) -# # for Drive PX2 -# ZMQ_LIBS = -lczmq -lzmq -# CEREAL_LIBS = -lcapnp -lkj -lcapnp_c -# EXTRA_LIBS = -lusb-1.0 -lpthread -# endif -ifeq ($(ARCH),aarch64) -CFLAGS += -mcpu=cortex-a57 -CXXFLAGS += -mcpu=cortex-a57 -endif - - -ifeq ($(ARCH),x86_64) -ZMQ_FLAGS = -I$(PHONELIBS)/zmq/aarch64/include -ZMQ_LIBS = -L$(BASEDIR)/external/zmq/lib/ \ - -l:libczmq.a -l:libzmq.a -EXTRA_LIBS = -lusb-1.0 -lpthread -CXXFLAGS += -I/usr/include/libusb-1.0 -CFLAGS += -I/usr/include/libusb-1.0 -endif - -.PHONY: all -all: boardd - -include ../common/cereal.mk - -OBJS = boardd.o \ - can_list_to_can_capnp.o \ - ../common/swaglog.o \ - ../common/params.o \ - ../common/util.o \ - $(PHONELIBS)/json/src/json.o \ - $(CEREAL_OBJS) - -DEPS := $(OBJS:.o=.d) - -boardd: $(OBJS) - @echo "[ LINK ] $@" - $(CXX) -fPIC -o '$@' $^ \ - $(CEREAL_LIBS) \ - $(ZMQ_LIBS) \ - $(EXTRA_LIBS) - -boardd.o: boardd.cc - @echo "[ CXX ] $@" - $(CXX) $(CXXFLAGS) -MMD \ - -I$(PHONELIBS)/android_system_core/include \ - $(CEREAL_CFLAGS) \ - $(CEREAL_CXXFLAGS) \ - $(ZMQ_FLAGS) \ - -I../ \ - -I../../ \ - -c -o '$@' '$<' - - -boardd_api_impl.so: libcan_list_to_can_capnp.a boardd_api_impl.pyx boardd_setup.py - python2 boardd_setup.py build_ext --inplace - rm -rf build - rm -f boardd_api_impl.cpp - -libcan_list_to_can_capnp.a: can_list_to_can_capnp.o $(CEREAL_OBJS) - ar rcsD '$@' $^ - -%.o: %.c - @echo "[ CC ] $@" - $(CC) $(CFLAGS) -MMD \ - -Iinclude -I.. -I../.. \ - $(CEREAL_CFLAGS) \ - $(ZMQ_FLAGS) \ - $(JSON_FLAGS) \ - -c -o '$@' '$<' - -%.o: %.cc - @echo "[ CC ] $@" - $(CXX) $(CXXFLAGS) -MMD \ - -Iinclude -I.. -I../.. \ - $(CEREAL_CXXFLAGS) \ - $(ZMQ_FLAGS) \ - -c -o '$@' '$<' - -.PHONY: clean -clean: - rm -f boardd libcan_list_to_can_capnp.a boardd_api_impl.so $(OBJS) $(DEPS) - --include $(DEPS) diff --git a/selfdrive/boardd/SConscript b/selfdrive/boardd/SConscript new file mode 100644 index 00000000000000..f2a1f3f7bd9f2d --- /dev/null +++ b/selfdrive/boardd/SConscript @@ -0,0 +1,6 @@ +Import('env', 'envCython', 'common', 'cereal', 'messaging') + +env.Program('boardd', ['boardd.cc', 'panda.cc', 'pigeon.cc'], LIBS=['usb-1.0', common, cereal, messaging, 'pthread', 'zmq', 'capnp', 'kj']) +env.Library('libcan_list_to_can_capnp', ['can_list_to_can_capnp.cc']) + +envCython.Program('boardd_api_impl.so', 'boardd_api_impl.pyx', LIBS=["can_list_to_can_capnp", 'capnp', 'kj'] + envCython["LIBS"]) diff --git a/selfdrive/boardd/boardd.cc b/selfdrive/boardd/boardd.cc index ba3f62a613a2fd..2caa80d32444cf 100644 --- a/selfdrive/boardd/boardd.cc +++ b/selfdrive/boardd/boardd.cc @@ -1,467 +1,259 @@ #include #include #include -#include #include #include #include -#include +#include #include #include -#include #include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include #include -#include -#include "cereal/gen/cpp/log.capnp.h" #include "cereal/gen/cpp/car.capnp.h" -#include "common/messaging.h" +#include "common/util.h" #include "common/params.h" #include "common/swaglog.h" #include "common/timing.h" +#include "messaging.hpp" + +#include "panda.h" +#include "pigeon.h" -#include -// double the FIFO size -#define RECV_SIZE (0x1000) -#define TIMEOUT 0 - -#define SAFETY_NOOUTPUT 0 -#define SAFETY_HONDA 1 -#define SAFETY_TOYOTA 2 -#define SAFETY_GM 3 -#define SAFETY_HONDA_BOSCH 4 -#define SAFETY_FORD 5 -#define SAFETY_CADILLAC 6 -#define SAFETY_HYUNDAI 7 -#define SAFETY_TESLA 8 -#define SAFETY_CHRYSLER 9 -#define SAFETY_SUBARU 10 -#define SAFETY_TOYOTA_IPAS 0x1335 -#define SAFETY_TOYOTA_NOLIMITS 0x1336 -#define SAFETY_ALLOUTPUT 0x1337 -#define SAFETY_ELM327 0xE327 // diagnostic only - -namespace { - -volatile int do_exit = 0; - -libusb_context *ctx = NULL; -libusb_device_handle *dev_handle; -pthread_mutex_t usb_lock; +#define MAX_IR_POWER 0.5f +#define MIN_IR_POWER 0.0f +#define CUTOFF_IL 200 +#define SATURATE_IL 1600 +#define NIBBLE_TO_HEX(n) ((n) < 10 ? (n) + '0' : ((n) - 10) + 'a') +Panda * panda = NULL; +std::atomic safety_setter_thread_running(false); +volatile sig_atomic_t do_exit = 0; bool spoofing_started = false; bool fake_send = false; -bool loopback_can = false; -cereal::HealthData::HwType hw_type = cereal::HealthData::HwType::UNKNOWN; -bool is_pigeon = false; +bool connected_once = false; +bool ignition = false; + +struct tm get_time(){ + time_t rawtime; + time(&rawtime); + + struct tm sys_time; + gmtime_r(&rawtime, &sys_time); -pthread_t safety_setter_thread_handle = -1; -pthread_t pigeon_thread_handle = -1; -bool pigeon_needs_init; + return sys_time; +} -void pigeon_init(); -void *pigeon_thread(void *crap); +bool time_valid(struct tm sys_time){ + int year = 1900 + sys_time.tm_year; + int month = 1 + sys_time.tm_mon; + return (year > 2020) || (year == 2020 && month >= 10); +} -void *safety_setter_thread(void *s) { - char *value_vin; - size_t value_vin_sz = 0; +void safety_setter_thread() { + LOGD("Starting safety setter thread"); + // diagnostic only is the default, needed for VIN query + panda->set_safety_model(cereal::CarParams::SafetyModel::ELM327); - // switch to no_output when CarVin param is read + // switch to SILENT when CarVin param is read while (1) { - if (do_exit) return NULL; - const int result = read_db_value(NULL, "CarVin", &value_vin, &value_vin_sz); - if (value_vin_sz > 0) { + if (do_exit || !panda->connected){ + safety_setter_thread_running = false; + return; + }; + + std::vector value_vin = Params().read_db_bytes("CarVin"); + if (value_vin.size() > 0) { // sanity check VIN format - assert(value_vin_sz == 17); + assert(value_vin.size() == 17); + std::string str_vin(value_vin.begin(), value_vin.end()); + LOGW("got CarVin %s", str_vin.c_str()); break; } usleep(100*1000); } - LOGW("got CarVin %s", value_vin); - - pthread_mutex_lock(&usb_lock); - // VIN qury done, stop listening to OBDII - libusb_control_transfer(dev_handle, 0x40, 0xdc, SAFETY_NOOUTPUT, 0, NULL, 0, TIMEOUT); - - pthread_mutex_unlock(&usb_lock); - - char *value; - size_t value_sz = 0; + // VIN query done, stop listening to OBDII + //Tesla prevent changes to safety model +//panda->set_safety_model(cereal::CarParams::SafetyModel::NO_OUTPUT); + std::vector params; LOGW("waiting for params to set safety model"); while (1) { - if (do_exit) return NULL; + if (do_exit || !panda->connected){ + safety_setter_thread_running = false; + return; + }; - const int result = read_db_value(NULL, "CarParams", &value, &value_sz); - if (value_sz > 0) break; + params = Params().read_db_bytes("CarParams"); + if (params.size() > 0) break; usleep(100*1000); } - LOGW("got %d bytes CarParams", value_sz); + LOGW("got %d bytes CarParams", params.size()); // format for board, make copy due to alignment issues, will be freed on out of scope - auto amsg = kj::heapArray((value_sz / sizeof(capnp::word)) + 1); - memcpy(amsg.begin(), value, value_sz); - free(value); + auto amsg = kj::heapArray((params.size() / sizeof(capnp::word)) + 1); + memcpy(amsg.begin(), params.data(), params.size()); capnp::FlatArrayMessageReader cmsg(amsg); cereal::CarParams::Reader car_params = cmsg.getRoot(); + cereal::CarParams::SafetyModel safety_model = car_params.getSafetyModel(); - auto safety_model = car_params.getSafetyModel(); - auto safety_param = car_params.getSafetyParam(); - LOGW("setting safety model: %d with param %d", safety_model, safety_param); - - int safety_setting = 0; - switch (safety_model) { - case cereal::CarParams::SafetyModel::NO_OUTPUT: - safety_setting = SAFETY_NOOUTPUT; - break; - case cereal::CarParams::SafetyModel::HONDA: - safety_setting = SAFETY_HONDA; - break; - case cereal::CarParams::SafetyModel::TOYOTA: - safety_setting = SAFETY_TOYOTA; - break; - case cereal::CarParams::SafetyModel::ELM327: - safety_setting = SAFETY_ELM327; - break; - case cereal::CarParams::SafetyModel::GM: - safety_setting = SAFETY_GM; - break; - case cereal::CarParams::SafetyModel::HONDA_BOSCH: - safety_setting = SAFETY_HONDA_BOSCH; - break; - case cereal::CarParams::SafetyModel::FORD: - safety_setting = SAFETY_FORD; - break; - case cereal::CarParams::SafetyModel::CADILLAC: - safety_setting = SAFETY_CADILLAC; - break; - case cereal::CarParams::SafetyModel::HYUNDAI: - safety_setting = SAFETY_HYUNDAI; - break; - case cereal::CarParams::SafetyModel::CHRYSLER: - safety_setting = SAFETY_CHRYSLER; - break; - case cereal::CarParams::SafetyModel::SUBARU: - safety_setting = SAFETY_SUBARU; - break; - case cereal::CarParams::SafetyModel::TESLA: - safety_setting = SAFETY_TESLA; - break; - default: - LOGE("unknown safety model: %d", safety_model); - } + panda->set_unsafe_mode(0); // see safety_declarations.h for allowed values - pthread_mutex_lock(&usb_lock); + auto safety_param = car_params.getSafetyParam(); + LOGW("setting safety model: %d with param %d", (int)safety_model, safety_param); - // set in the mutex to avoid race - safety_setter_thread_handle = -1; +//Tesla: Avoid changes to safety model + //panda->set_safety_model(safety_model, safety_param); - // set if long_control is allowed by openpilot. Hardcoded to True for now - libusb_control_transfer(dev_handle, 0x40, 0xdf, 1, 0, NULL, 0, TIMEOUT); + //safety_setter_thread_running = false; +} - libusb_control_transfer(dev_handle, 0x40, 0xdc, safety_setting, safety_param, NULL, 0, TIMEOUT); - pthread_mutex_unlock(&usb_lock); +bool usb_connect() { + try { + assert(panda == NULL); + panda = new Panda(); + } catch (std::exception &e) { + return false; + } - return NULL; -} + Params params = Params(); -// must be called before threads or with mutex -bool usb_connect() { - int err; - unsigned char hw_query[1] = {0}; + if (getenv("BOARDD_LOOPBACK")) { + panda->set_loopback(true); + } - dev_handle = libusb_open_device_with_vid_pid(ctx, 0xbbaa, 0xddcc); - if (dev_handle == NULL) { goto fail; } + const char *fw_sig_buf = panda->get_firmware_version(); + if (fw_sig_buf){ + params.write_db_value("PandaFirmware", fw_sig_buf, 128); - err = libusb_set_configuration(dev_handle, 1); - if (err != 0) { goto fail; } + // Convert to hex for offroad + char fw_sig_hex_buf[16] = {0}; + for (size_t i = 0; i < 8; i++){ + fw_sig_hex_buf[2*i] = NIBBLE_TO_HEX((uint8_t)fw_sig_buf[i] >> 4); + fw_sig_hex_buf[2*i+1] = NIBBLE_TO_HEX((uint8_t)fw_sig_buf[i] & 0xF); + } - err = libusb_claim_interface(dev_handle, 0); - if (err != 0) { goto fail; } + params.write_db_value("PandaFirmwareHex", fw_sig_hex_buf, 16); + LOGW("fw signature: %.*s", 16, fw_sig_hex_buf); - if (loopback_can) { - libusb_control_transfer(dev_handle, 0xc0, 0xe5, 1, 0, NULL, 0, TIMEOUT); - } + delete[] fw_sig_buf; + } else { return false; } - // power off ESP - libusb_control_transfer(dev_handle, 0xc0, 0xd9, 0, 0, NULL, 0, TIMEOUT); + // get panda serial + const char *serial_buf = panda->get_serial(); + if (serial_buf) { + size_t serial_sz = strnlen(serial_buf, 16); - // power on charging (may trigger a reconnection, should be okay) - #ifndef __x86_64__ - libusb_control_transfer(dev_handle, 0xc0, 0xe6, 1, 0, NULL, 0, TIMEOUT); - #else - LOGW("not enabling charging on x86_64"); - #endif + params.write_db_value("PandaDongleId", serial_buf, serial_sz); + LOGW("panda serial: %.*s", serial_sz, serial_buf); - // diagnostic only is the default, needed for VIN query - libusb_control_transfer(dev_handle, 0x40, 0xdc, SAFETY_ELM327, 0, NULL, 0, TIMEOUT); + delete[] serial_buf; + } else { return false; } - if (safety_setter_thread_handle == -1) { - err = pthread_create(&safety_setter_thread_handle, NULL, safety_setter_thread, NULL); - assert(err == 0); + // power on charging, only the first time. Panda can also change mode and it causes a brief disconneciton +#ifndef __x86_64__ + if (!connected_once) { + panda->set_usb_power_mode(cereal::HealthData::UsbPowerMode::CDP); } +#endif - libusb_control_transfer(dev_handle, 0xc0, 0xc1, 0, 0, hw_query, 1, TIMEOUT); + if (panda->has_rtc){ + struct tm sys_time = get_time(); + struct tm rtc_time = panda->get_rtc(); - hw_type = (cereal::HealthData::HwType)(hw_query[0]); - is_pigeon = (hw_type == cereal::HealthData::HwType::GREY_PANDA) || (hw_type == cereal::HealthData::HwType::BLACK_PANDA); - if (is_pigeon) { - LOGW("panda with gps detected"); - pigeon_needs_init = true; - if (pigeon_thread_handle == -1) { - err = pthread_create(&pigeon_thread_handle, NULL, pigeon_thread, NULL); - assert(err == 0); + if (!time_valid(sys_time) && time_valid(rtc_time)) { + LOGE("System time wrong, setting from RTC"); + + setenv("TZ","UTC",1); + const struct timeval tv = {mktime(&rtc_time), 0}; + settimeofday(&tv, 0); } } + connected_once = true; return true; -fail: - return false; } +// must be called before threads or with mutex void usb_retry_connect() { - LOG("attempting to connect"); + LOGW("attempting to connect"); while (!usb_connect()) { usleep(100*1000); } LOGW("connected to board"); } -void handle_usb_issue(int err, const char func[]) { - LOGE_100("usb error %d \"%s\" in %s", err, libusb_strerror((enum libusb_error)err), func); - if (err == -4) { - LOGE("lost connection"); - usb_retry_connect(); - } - // TODO: check other errors, is simply retrying okay? -} - -void can_recv(void *s) { - int err; - uint32_t data[RECV_SIZE/4]; - int recv; - uint32_t f1, f2; - - uint64_t start_time = nanos_since_boot(); - - // do recv - pthread_mutex_lock(&usb_lock); - - do { - err = libusb_bulk_transfer(dev_handle, 0x81, (uint8_t*)data, RECV_SIZE, &recv, TIMEOUT); - if (err != 0) { handle_usb_issue(err, __func__); } - if (err == -8) { LOGE_100("overflow got 0x%x", recv); }; - - // timeout is okay to exit, recv still happened - if (err == -7) { break; } - } while(err != 0); - - pthread_mutex_unlock(&usb_lock); - - // return if length is 0 - if (recv <= 0) { - return; - } - - // create message - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(start_time); - size_t num_msg = recv / 0x10; - - auto canData = event.initCan(num_msg); - - // populate message - for (int i = 0; i < num_msg; i++) { - if (data[i*4] & 4) { - // extended - canData[i].setAddress(data[i*4] >> 3); - //printf("got extended: %x\n", data[i*4] >> 3); - } else { - // normal - canData[i].setAddress(data[i*4] >> 21); - } - canData[i].setBusTime(data[i*4+1] >> 16); - int len = data[i*4+1]&0xF; - canData[i].setDat(kj::arrayPtr((uint8_t*)&data[i*4+2], len)); - canData[i].setSrc((data[i*4+1] >> 4) & 0xff); - } - - // send to can - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - zmq_send(s, bytes.begin(), bytes.size(), 0); -} - -void can_health(void *s) { - int cnt; - - // copied from board/main.c - struct __attribute__((packed)) health { - uint32_t voltage; - uint32_t current; - uint32_t can_send_errs; - uint32_t can_fwd_errs; - uint32_t gmlan_send_errs; - uint8_t started; - uint8_t controls_allowed; - uint8_t gas_interceptor_detected; - uint8_t car_harness_status_pkt; - } health; - - // recv from board - pthread_mutex_lock(&usb_lock); - - do { - cnt = libusb_control_transfer(dev_handle, 0xc0, 0xd2, 0, 0, (unsigned char*)&health, sizeof(health), TIMEOUT); - if (cnt != sizeof(health)) { - handle_usb_issue(cnt, __func__); - } - } while(cnt != sizeof(health)); - - pthread_mutex_unlock(&usb_lock); - +void can_recv(PubMaster &pm) { // create message - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto healthData = event.initHealth(); - - // set fields - healthData.setVoltage(health.voltage); - healthData.setCurrent(health.current); - if (spoofing_started) { - healthData.setStarted(1); - } else { - healthData.setStarted(health.started); - } - healthData.setControlsAllowed(health.controls_allowed); - healthData.setGasInterceptorDetected(health.gas_interceptor_detected); - healthData.setHasGps(is_pigeon); - healthData.setCanSendErrs(health.can_send_errs); - healthData.setCanFwdErrs(health.can_fwd_errs); - healthData.setGmlanSendErrs(health.gmlan_send_errs); - healthData.setHwType(hw_type); - - // send to health - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - zmq_send(s, bytes.begin(), bytes.size(), 0); - - pthread_mutex_lock(&usb_lock); - - // send heartbeat back to panda - libusb_control_transfer(dev_handle, 0x40, 0xf3, 1, 0, NULL, 0, TIMEOUT); - - pthread_mutex_unlock(&usb_lock); + MessageBuilder msg; + auto event = msg.initEvent(); + panda->can_receive(event); + pm.send("can", msg); } +void can_send_thread() { + LOGD("start send thread"); -void can_send(void *s) { - int err; - - // recv from sendcan - zmq_msg_t msg; - zmq_msg_init(&msg); - err = zmq_msg_recv(&msg, s, 0); - assert(err >= 0); - - // format for board, make copy due to alignment issues, will be freed on out of scope - auto amsg = kj::heapArray((zmq_msg_size(&msg) / sizeof(capnp::word)) + 1); - memcpy(amsg.begin(), zmq_msg_data(&msg), zmq_msg_size(&msg)); - - capnp::FlatArrayMessageReader cmsg(amsg); - cereal::Event::Reader event = cmsg.getRoot(); - if (nanos_since_boot() - event.getLogMonoTime() > 1e9) { - //Older than 1 second. Dont send. - zmq_msg_close(&msg); - return; - } - int msg_count = event.getCan().size(); + Context * context = Context::create(); + SubSocket * subscriber = SubSocket::create(context, "sendcan"); + assert(subscriber != NULL); + subscriber->setTimeout(100); - uint32_t *send = (uint32_t*)malloc(msg_count*0x10); - memset(send, 0, msg_count*0x10); + // run as fast as messages come in + while (!do_exit && panda->connected) { + Message * msg = subscriber->receive(); - for (int i = 0; i < msg_count; i++) { - auto cmsg = event.getSendcan()[i]; - if (cmsg.getAddress() >= 0x800) { - // extended - send[i*4] = (cmsg.getAddress() << 3) | 5; - } else { - // normal - send[i*4] = (cmsg.getAddress() << 21) | 1; + if (!msg){ + if (errno == EINTR) { + do_exit = true; + } + continue; } - assert(cmsg.getDat().size() <= 8); - send[i*4+1] = cmsg.getDat().size() | (cmsg.getSrc() << 4); - memcpy(&send[i*4+2], cmsg.getDat().begin(), cmsg.getDat().size()); - } - - // release msg - zmq_msg_close(&msg); - - // send to board - int sent; - pthread_mutex_lock(&usb_lock); - if (!fake_send) { - do { - err = libusb_bulk_transfer(dev_handle, 3, (uint8_t*)send, msg_count*0x10, &sent, TIMEOUT); - if (err != 0 || msg_count*0x10 != sent) { handle_usb_issue(err, __func__); } - } while(err != 0); - } - - pthread_mutex_unlock(&usb_lock); - - // done - free(send); -} + auto amsg = kj::heapArray((msg->getSize() / sizeof(capnp::word)) + 1); + memcpy(amsg.begin(), msg->getData(), msg->getSize()); -// **** threads **** + capnp::FlatArrayMessageReader cmsg(amsg); + cereal::Event::Reader event = cmsg.getRoot(); -void *can_send_thread(void *crap) { - LOGD("start send thread"); - - // sendcan = 8017 - void *context = zmq_ctx_new(); - void *subscriber = sub_sock(context, "tcp://127.0.0.1:8017"); + //Dont send if older than 1 second + if (nanos_since_boot() - event.getLogMonoTime() < 1e9) { + if (!fake_send){ + panda->can_send(event.getSendcan()); + } + } - // drain sendcan to delete any stale messages from previous runs - zmq_msg_t msg; - zmq_msg_init(&msg); - int err = 0; - while(err >= 0) { - err = zmq_msg_recv(&msg, subscriber, ZMQ_DONTWAIT); + delete msg; } - // run as fast as messages come in - while (!do_exit) { - can_send(subscriber); - } - return NULL; + delete subscriber; + delete context; } -void *can_recv_thread(void *crap) { +void can_recv_thread() { LOGD("start recv thread"); // can = 8006 - void *context = zmq_ctx_new(); - void *publisher = zmq_socket(context, ZMQ_PUB); - zmq_bind(publisher, "tcp://*:8006"); + PubMaster pm({"can"}); // run at 100hz const uint64_t dt = 10000000ULL; uint64_t next_frame_time = nanos_since_boot() + dt; - while (!do_exit) { - can_recv(publisher); + while (!do_exit && panda->connected) { + can_recv(pm); uint64_t cur_time = nanos_since_boot(); int64_t remaining = next_frame_time - cur_time; @@ -469,196 +261,267 @@ void *can_recv_thread(void *crap) { useconds_t sleep = remaining / 1000; usleep(sleep); } else { - LOGW("missed cycle"); + if (ignition){ + LOGW("missed cycles (%d) %lld", (int)-1*remaining/dt, remaining); + } next_frame_time = cur_time; } next_frame_time += dt; } - return NULL; } -void *can_health_thread(void *crap) { +void can_health_thread() { LOGD("start health thread"); + PubMaster pm({"health"}); - // health = 8011 - void *context = zmq_ctx_new(); - void *publisher = zmq_socket(context, ZMQ_PUB); - zmq_bind(publisher, "tcp://*:8011"); + uint32_t no_ignition_cnt = 0; + bool ignition_last = false; + Params params = Params(); - // run at 2hz - while (!do_exit) { - can_health(publisher); + // Broadcast empty health message when panda is not yet connected + while (!panda){ + MessageBuilder msg; + auto healthData = msg.initEvent().initHealth(); + + healthData.setHwType(cereal::HealthData::HwType::UNKNOWN); + pm.send("health", msg); usleep(500*1000); } - return NULL; -} -#define pigeon_send(x) _pigeon_send(x, sizeof(x)-1) + // run at 2hz + while (!do_exit && panda->connected) { + MessageBuilder msg; + auto healthData = msg.initEvent().initHealth(); -void hexdump(unsigned char *d, int l) { - for (int i = 0; i < l; i++) { - if (i!=0 && i%0x10 == 0) printf("\n"); - printf("%2.2X ", d[i]); - } - printf("\n"); -} + health_t health = panda->get_health(); -void _pigeon_send(const char *dat, int len) { - int sent; - unsigned char a[0x20]; - int err; - a[0] = 1; - for (int i=0; iset_safety_model(cereal::CarParams::SafetyModel::NO_OUTPUT); + } + + ignition = ((health.ignition_line != 0) || (health.ignition_can != 0)); + + if (ignition) { + no_ignition_cnt = 0; + } else { + no_ignition_cnt += 1; + } + +#ifndef __x86_64__ + bool power_save_desired = !ignition; + if (health.power_save_enabled != power_save_desired){ + panda->set_power_saving(power_save_desired); + } + + // set safety mode to NO_OUTPUT when car is off. ELM327 is an alternative if we want to leverage athenad/connect + if (!ignition && (health.safety_model != (uint8_t)(cereal::CarParams::SafetyModel::NO_OUTPUT))) { + panda->set_safety_model(cereal::CarParams::SafetyModel::NO_OUTPUT); + } +#endif + + // clear VIN, CarParams, and set new safety on car start + if (ignition && !ignition_last) { + int result = params.delete_db_value("CarVin"); + assert((result == 0) || (result == ERR_NO_VALUE)); + result = params.delete_db_value("CarParams"); + assert((result == 0) || (result == ERR_NO_VALUE)); + + if (!safety_setter_thread_running) { + safety_setter_thread_running = true; + std::thread(safety_setter_thread).detach(); + } else { + LOGW("Safety setter thread already running"); + } + } + + // Write to rtc once per minute when no ignition present + if ((panda->has_rtc) && !ignition && (no_ignition_cnt % 120 == 1)){ + // Write time to RTC if it looks reasonable + struct tm sys_time = get_time(); + if (time_valid(sys_time)){ + panda->set_rtc(sys_time); + } + } + + ignition_last = ignition; + uint16_t fan_speed_rpm = panda->get_fan_speed(); + + // set fields + healthData.setUptime(health.uptime); + healthData.setVoltage(health.voltage); + healthData.setCurrent(health.current); + healthData.setIgnitionLine(health.ignition_line); + healthData.setIgnitionCan(health.ignition_can); + healthData.setControlsAllowed(health.controls_allowed); + healthData.setGasInterceptorDetected(health.gas_interceptor_detected); + healthData.setHasGps(panda->is_pigeon); + healthData.setCanRxErrs(health.can_rx_errs); + healthData.setCanSendErrs(health.can_send_errs); + healthData.setCanFwdErrs(health.can_fwd_errs); + healthData.setGmlanSendErrs(health.gmlan_send_errs); + healthData.setHwType(panda->hw_type); + healthData.setUsbPowerMode(cereal::HealthData::UsbPowerMode(health.usb_power_mode)); + healthData.setSafetyModel(cereal::CarParams::SafetyModel(health.safety_model)); + healthData.setFanSpeedRpm(fan_speed_rpm); + healthData.setFaultStatus(cereal::HealthData::FaultStatus(health.fault_status)); + healthData.setPowerSaveEnabled((bool)(health.power_save_enabled)); + + // Convert faults bitset to capnp list + std::bitset fault_bits(health.faults); + auto faults = healthData.initFaults(fault_bits.count()); + + size_t i = 0; + for (size_t f = size_t(cereal::HealthData::FaultType::RELAY_MALFUNCTION); + f <= size_t(cereal::HealthData::FaultType::INTERRUPT_RATE_TIM9); f++){ + if (fault_bits.test(f)) { + faults.set(i, cereal::HealthData::FaultType(f)); + i++; + } + } + pm.send("health", msg); + panda->send_heartbeat(); + usleep(500*1000); } } -void pigeon_set_power(int power) { - pthread_mutex_lock(&usb_lock); - int err = libusb_control_transfer(dev_handle, 0xc0, 0xd9, power, 0, NULL, 0, TIMEOUT); - if (err < 0) { handle_usb_issue(err, __func__); } - pthread_mutex_unlock(&usb_lock); -} +void hardware_control_thread() { + LOGD("start hardware control thread"); + SubMaster sm({"thermal", "frontFrame"}); -void pigeon_set_baud(int baud) { - int err; - pthread_mutex_lock(&usb_lock); - err = libusb_control_transfer(dev_handle, 0xc0, 0xe2, 1, 0, NULL, 0, TIMEOUT); - if (err < 0) { handle_usb_issue(err, __func__); } - err = libusb_control_transfer(dev_handle, 0xc0, 0xe4, 1, baud/300, NULL, 0, TIMEOUT); - if (err < 0) { handle_usb_issue(err, __func__); } - pthread_mutex_unlock(&usb_lock); -} + uint64_t last_front_frame_t = 0; + uint16_t prev_fan_speed = 999; + uint16_t ir_pwr = 0; + uint16_t prev_ir_pwr = 999; +#ifdef QCOM + bool prev_charging_disabled = false; +#endif + unsigned int cnt = 0; + + while (!do_exit && panda->connected) { + cnt++; + sm.update(1000); // TODO: what happens if EINTR is sent while in sm.update? + +#ifdef QCOM + if (sm.updated("thermal")){ + // Charging mode + bool charging_disabled = sm["thermal"].getThermal().getChargingDisabled(); + if (charging_disabled != prev_charging_disabled){ + if (charging_disabled){ + panda->set_usb_power_mode(cereal::HealthData::UsbPowerMode::CLIENT); + LOGW("TURN OFF CHARGING!\n"); + } else { + panda->set_usb_power_mode(cereal::HealthData::UsbPowerMode::CDP); + LOGW("TURN ON CHARGING!\n"); + } + prev_charging_disabled = charging_disabled; + } + } +#endif + + // Other pandas don't have fan/IR to control + if (panda->hw_type != cereal::HealthData::HwType::UNO && panda->hw_type != cereal::HealthData::HwType::DOS) continue; + if (sm.updated("thermal")){ + // Fan speed + uint16_t fan_speed = sm["thermal"].getThermal().getFanSpeed(); + if (fan_speed != prev_fan_speed || cnt % 100 == 0){ + panda->set_fan_speed(fan_speed); + prev_fan_speed = fan_speed; + } + } + if (sm.updated("frontFrame")){ + auto event = sm["frontFrame"]; + int cur_integ_lines = event.getFrontFrame().getIntegLines(); + last_front_frame_t = event.getLogMonoTime(); + + if (cur_integ_lines <= CUTOFF_IL) { + ir_pwr = 100.0 * MIN_IR_POWER; + } else if (cur_integ_lines > SATURATE_IL) { + ir_pwr = 100.0 * MAX_IR_POWER; + } else { + ir_pwr = 100.0 * (MIN_IR_POWER + ((cur_integ_lines - CUTOFF_IL) * (MAX_IR_POWER - MIN_IR_POWER) / (SATURATE_IL - CUTOFF_IL))); + } + } + // Disable ir_pwr on front frame timeout + uint64_t cur_t = nanos_since_boot(); + if (cur_t - last_front_frame_t > 1e9){ + ir_pwr = 0; + } -void pigeon_init() { - usleep(1000*1000); - LOGW("panda GPS start"); - - // power off pigeon - pigeon_set_power(0); - usleep(100*1000); - - // 9600 baud at init - pigeon_set_baud(9600); - - // power on pigeon - pigeon_set_power(1); - usleep(500*1000); - - // baud rate upping - pigeon_send("\x24\x50\x55\x42\x58\x2C\x34\x31\x2C\x31\x2C\x30\x30\x30\x37\x2C\x30\x30\x30\x33\x2C\x34\x36\x30\x38\x30\x30\x2C\x30\x2A\x31\x35\x0D\x0A"); - usleep(100*1000); - - // set baud rate to 460800 - pigeon_set_baud(460800); - usleep(100*1000); - - // init from ubloxd - pigeon_send("\xB5\x62\x06\x00\x14\x00\x03\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x1E\x7F"); - pigeon_send("\xB5\x62\x06\x3E\x00\x00\x44\xD2"); - pigeon_send("\xB5\x62\x06\x00\x14\x00\x00\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x19\x35"); - pigeon_send("\xB5\x62\x06\x00\x14\x00\x01\x00\x00\x00\xC0\x08\x00\x00\x00\x08\x07\x00\x01\x00\x01\x00\x00\x00\x00\x00\xF4\x80"); - pigeon_send("\xB5\x62\x06\x00\x14\x00\x04\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1D\x85"); - pigeon_send("\xB5\x62\x06\x00\x00\x00\x06\x18"); - pigeon_send("\xB5\x62\x06\x00\x01\x00\x01\x08\x22"); - pigeon_send("\xB5\x62\x06\x00\x01\x00\x02\x09\x23"); - pigeon_send("\xB5\x62\x06\x00\x01\x00\x03\x0A\x24"); - pigeon_send("\xB5\x62\x06\x08\x06\x00\x64\x00\x01\x00\x00\x00\x79\x10"); - pigeon_send("\xB5\x62\x06\x24\x24\x00\x05\x00\x04\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x5A\x63"); - pigeon_send("\xB5\x62\x06\x1E\x14\x00\x00\x00\x00\x00\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3C\x37"); - pigeon_send("\xB5\x62\x06\x24\x00\x00\x2A\x84"); - pigeon_send("\xB5\x62\x06\x23\x00\x00\x29\x81"); - pigeon_send("\xB5\x62\x06\x1E\x00\x00\x24\x72"); - pigeon_send("\xB5\x62\x06\x01\x03\x00\x01\x07\x01\x13\x51"); - pigeon_send("\xB5\x62\x06\x01\x03\x00\x02\x15\x01\x22\x70"); - pigeon_send("\xB5\x62\x06\x01\x03\x00\x02\x13\x01\x20\x6C"); - - LOGW("panda GPS on"); + if (ir_pwr != prev_ir_pwr || cnt % 100 == 0 || ir_pwr >= 50.0){ + panda->set_ir_pwr(ir_pwr); + prev_ir_pwr = ir_pwr; + } + + } } -static void pigeon_publish_raw(void *publisher, unsigned char *dat, int alen) { +static void pigeon_publish_raw(PubMaster &pm, std::string dat) { // create message - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto ublox_raw = event.initUbloxRaw(alen); - memcpy(ublox_raw.begin(), dat, alen); - - // send to ubloxRaw - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - zmq_send(publisher, bytes.begin(), bytes.size(), 0); + MessageBuilder msg; + auto ublox_raw = msg.initEvent().initUbloxRaw(dat.length()); + memcpy(ublox_raw.begin(), dat.data(), dat.length()); + + pm.send("ubloxRaw", msg); } -void *pigeon_thread(void *crap) { +void pigeon_thread() { + if (!panda->is_pigeon){ return; }; + // ubloxRaw = 8042 - void *context = zmq_ctx_new(); - void *publisher = zmq_socket(context, ZMQ_PUB); - zmq_bind(publisher, "tcp://*:8042"); - - // run at ~100hz - unsigned char dat[0x1000]; - uint64_t cnt = 0; - while (!do_exit) { - if (pigeon_needs_init) { - pigeon_needs_init = false; - pigeon_init(); - } - int alen = 0; - while (alen < 0xfc0) { - pthread_mutex_lock(&usb_lock); - int len = libusb_control_transfer(dev_handle, 0xc0, 0xe0, 1, 0, dat+alen, 0x40, TIMEOUT); - if (len < 0) { handle_usb_issue(len, __func__); } - pthread_mutex_unlock(&usb_lock); - if (len <= 0) break; - - //printf("got %d\n", len); - alen += len; - } - if (alen > 0) { - if (dat[0] == (char)0x00){ - LOGW("received invalid ublox message, resetting pigeon"); - pigeon_init(); + PubMaster pm({"ubloxRaw"}); + bool ignition_last = false; + +#ifdef QCOM2 + Pigeon * pigeon = Pigeon::connect("/dev/ttyHS0"); +#else + Pigeon * pigeon = Pigeon::connect(panda); +#endif + + while (!do_exit && panda->connected) { + std::string recv = pigeon->receive(); + if (recv.length() > 0) { + if (recv[0] == (char)0x00){ + if (ignition) { + LOGW("received invalid ublox message while onroad, resetting panda GPS"); + pigeon->init(); + } } else { - pigeon_publish_raw(publisher, dat, alen); + pigeon_publish_raw(pm, recv); } } - // 10ms + // init pigeon on rising ignition edge + // since it was turned off in low power mode + if(ignition && !ignition_last) { + pigeon->init(); + } + + ignition_last = ignition; + + // 10ms - 100 Hz usleep(10*1000); - cnt++; } - return NULL; + delete pigeon; } -int set_realtime_priority(int level) { - // should match python using chrt - struct sched_param sa; - memset(&sa, 0, sizeof(sa)); - sa.sched_priority = level; - return sched_setscheduler(getpid(), SCHED_FIFO, &sa); -} - -} int main() { int err; LOGW("starting boardd"); - // set process priority - err = set_realtime_priority(4); - LOG("setpriority returns %d", err); + // set process priority and affinity + err = set_realtime_priority(54); + LOG("set priority returns %d", err); + err = set_core_affinity(3); + LOG("set affinity returns %d", err); // check the environment if (getenv("STARTED")) { @@ -669,50 +532,23 @@ int main() { fake_send = true; } - if (getenv("BOARDD_LOOPBACK")){ - loopback_can = true; - } - - // init libusb - err = libusb_init(&ctx); - assert(err == 0); - libusb_set_debug(ctx, 3); + panda_set_power(true); - // connect to the board - usb_retry_connect(); + while (!do_exit){ + std::vector threads; + threads.push_back(std::thread(can_health_thread)); + // connect to the board + usb_retry_connect(); - // create threads - pthread_t can_health_thread_handle; - err = pthread_create(&can_health_thread_handle, NULL, - can_health_thread, NULL); - assert(err == 0); - - pthread_t can_send_thread_handle; - err = pthread_create(&can_send_thread_handle, NULL, - can_send_thread, NULL); - assert(err == 0); - - pthread_t can_recv_thread_handle; - err = pthread_create(&can_recv_thread_handle, NULL, - can_recv_thread, NULL); - assert(err == 0); - - // join threads - - err = pthread_join(can_recv_thread_handle, NULL); - assert(err == 0); - - err = pthread_join(can_send_thread_handle, NULL); - assert(err == 0); - - err = pthread_join(can_health_thread_handle, NULL); - assert(err == 0); - - //while (!do_exit) usleep(1000); + threads.push_back(std::thread(can_send_thread)); + threads.push_back(std::thread(can_recv_thread)); + threads.push_back(std::thread(hardware_control_thread)); + threads.push_back(std::thread(pigeon_thread)); - // destruct libusb + for (auto &t : threads) t.join(); - libusb_close(dev_handle); - libusb_exit(ctx); + delete panda; + panda = NULL; + } } diff --git a/selfdrive/boardd/boardd.py b/selfdrive/boardd/boardd.py index d3bcb1471054d3..527f1f4f52dc7d 100644 --- a/selfdrive/boardd/boardd.py +++ b/selfdrive/boardd/boardd.py @@ -1,14 +1,9 @@ # pylint: skip-file -import os -import subprocess -# Cython -boardd_api_dir = os.path.dirname(os.path.abspath(__file__)) -subprocess.check_call(["make", "boardd_api_impl.so"], cwd=boardd_api_dir) +# Cython, now uses scons to build from selfdrive.boardd.boardd_api_impl import can_list_to_can_capnp assert can_list_to_can_capnp - def can_capnp_to_can_list(can, src_filter=None): ret = [] for msg in can: diff --git a/selfdrive/boardd/boardd_api_impl.pyx b/selfdrive/boardd/boardd_api_impl.pyx index eddf1fbf7aedf6..3f50fbaab6c5ca 100644 --- a/selfdrive/boardd/boardd_api_impl.pyx +++ b/selfdrive/boardd/boardd_api_impl.pyx @@ -1,4 +1,5 @@ # distutils: language = c++ +# cython: language_level=3 from libcpp.vector cimport vector from libcpp.string cimport string from libcpp cimport bool diff --git a/selfdrive/boardd/boardd_setup.py b/selfdrive/boardd/boardd_setup.py deleted file mode 100644 index f614a06161dc7f..00000000000000 --- a/selfdrive/boardd/boardd_setup.py +++ /dev/null @@ -1,25 +0,0 @@ -import subprocess -from distutils.core import setup, Extension -from Cython.Build import cythonize - -PHONELIBS = '../../phonelibs' - -ARCH = subprocess.check_output(["uname", "-m"]).rstrip() -ARCH_DIR = 'x64' if ARCH == "x86_64" else 'aarch64' - -setup(name='Boardd API Implementation', - ext_modules=cythonize( - Extension( - "boardd_api_impl", - libraries=[':libcan_list_to_can_capnp.a', ':libcapnp.a', ':libcapnp.a', ':libkj.a'], - library_dirs=[ - './', - PHONELIBS + '/capnp-cpp/' + ARCH_DIR + '/lib/', - PHONELIBS + '/capnp-c/' + ARCH_DIR + '/lib/' - ], - sources=['boardd_api_impl.pyx'], - language="c++", - extra_compile_args=["-std=c++11"], - ) - ) -) diff --git a/selfdrive/boardd/can_list_to_can_capnp.cc b/selfdrive/boardd/can_list_to_can_capnp.cc index 8ba9d3d5609d9c..2fa3f5b9bcbdfd 100644 --- a/selfdrive/boardd/can_list_to_can_capnp.cc +++ b/selfdrive/boardd/can_list_to_can_capnp.cc @@ -1,10 +1,4 @@ -#include -#include -#include -#include "common/timing.h" -#include -#include "cereal/gen/cpp/log.capnp.h" -#include "cereal/gen/cpp/car.capnp.h" +#include "messaging.hpp" typedef struct { long address; @@ -16,21 +10,19 @@ typedef struct { extern "C" { void can_list_to_can_capnp_cpp(const std::vector &can_list, std::string &out, bool sendCan, bool valid) { - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - event.setValid(valid); + MessageBuilder msg; + auto event = msg.initEvent(valid); auto canData = sendCan ? event.initSendcan(can_list.size()) : event.initCan(can_list.size()); int j = 0; for (auto it = can_list.begin(); it != can_list.end(); it++, j++) { - canData[j].setAddress(it->address); - canData[j].setBusTime(it->busTime); - canData[j].setDat(kj::arrayPtr((uint8_t*)it->dat.data(), it->dat.size())); - canData[j].setSrc(it->src); + auto c = canData[j]; + c.setAddress(it->address); + c.setBusTime(it->busTime); + c.setDat(kj::arrayPtr((uint8_t*)it->dat.data(), it->dat.size())); + c.setSrc(it->src); } - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); + auto bytes = msg.toBytes(); out.append((const char *)bytes.begin(), bytes.size()); } diff --git a/selfdrive/boardd/panda.cc b/selfdrive/boardd/panda.cc new file mode 100644 index 00000000000000..d89e302fa14802 --- /dev/null +++ b/selfdrive/boardd/panda.cc @@ -0,0 +1,366 @@ +#include +#include +#include + +#include + +#include "common/swaglog.h" +#include "common/gpio.h" + +#include "panda.h" + +#ifdef QCOM2 +bool is_legacy_panda_reset() { + FILE *file = fopen("/persist/LEGACY_PANDA_RESET", "r"); + if(file) { + fclose(file); + } + return (file != NULL); +} +#endif + +void panda_set_power(bool power){ +#ifdef QCOM2 + int err = 0; + bool is_legacy = is_legacy_panda_reset(); + + err += gpio_init(GPIO_STM_RST_N, true); + err += gpio_init(GPIO_STM_BOOT0, true); + + err += gpio_set(GPIO_STM_RST_N, is_legacy ? false : true); + err += gpio_set(GPIO_STM_BOOT0, false); + + usleep(100*1000); // 100 ms + + err += gpio_set(GPIO_STM_RST_N, is_legacy ? power : (!power)); + assert(err == 0); +#endif +} + +Panda::Panda(){ + int err; + + err = pthread_mutex_init(&usb_lock, NULL); + if (err != 0) { goto fail; } + + // init libusb + err = libusb_init(&ctx); + if (err != 0) { goto fail; } + +#if LIBUSB_API_VERSION >= 0x01000106 + libusb_set_option(ctx, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_INFO); +#else + libusb_set_debug(ctx, 3); +#endif + + dev_handle = libusb_open_device_with_vid_pid(ctx, 0xbbaa, 0xddcc); + if (dev_handle == NULL) { goto fail; } + + if (libusb_kernel_driver_active(dev_handle, 0) == 1) { + libusb_detach_kernel_driver(dev_handle, 0); + } + + err = libusb_set_configuration(dev_handle, 1); + if (err != 0) { goto fail; } + + err = libusb_claim_interface(dev_handle, 0); + if (err != 0) { goto fail; } + + hw_type = get_hw_type(); + is_pigeon = + (hw_type == cereal::HealthData::HwType::GREY_PANDA) || + (hw_type == cereal::HealthData::HwType::BLACK_PANDA) || + (hw_type == cereal::HealthData::HwType::UNO) || + (hw_type == cereal::HealthData::HwType::DOS); + has_rtc = (hw_type == cereal::HealthData::HwType::UNO) || + (hw_type == cereal::HealthData::HwType::DOS); + + return; + +fail: + cleanup(); + throw std::runtime_error("Error connecting to panda"); +} + +Panda::~Panda(){ + pthread_mutex_lock(&usb_lock); + cleanup(); + connected = false; + pthread_mutex_unlock(&usb_lock); +} + +void Panda::cleanup(){ + if (dev_handle){ + libusb_release_interface(dev_handle, 0); + libusb_close(dev_handle); + } + + if (ctx) { + libusb_exit(ctx); + } +} + +void Panda::handle_usb_issue(int err, const char func[]) { + LOGE_100("usb error %d \"%s\" in %s", err, libusb_strerror((enum libusb_error)err), func); + if (err == LIBUSB_ERROR_NO_DEVICE) { + LOGE("lost connection"); + connected = false; + } + // TODO: check other errors, is simply retrying okay? +} + +int Panda::usb_write(uint8_t bRequest, uint16_t wValue, uint16_t wIndex, unsigned int timeout) { + int err; + const uint8_t bmRequestType = LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE; + + if (!connected){ + return LIBUSB_ERROR_NO_DEVICE; + } + + pthread_mutex_lock(&usb_lock); + do { + err = libusb_control_transfer(dev_handle, bmRequestType, bRequest, wValue, wIndex, NULL, 0, timeout); + if (err < 0) handle_usb_issue(err, __func__); + } while (err < 0 && connected); + + pthread_mutex_unlock(&usb_lock); + + return err; +} + +int Panda::usb_read(uint8_t bRequest, uint16_t wValue, uint16_t wIndex, unsigned char *data, uint16_t wLength, unsigned int timeout) { + int err; + const uint8_t bmRequestType = LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE; + + pthread_mutex_lock(&usb_lock); + do { + err = libusb_control_transfer(dev_handle, bmRequestType, bRequest, wValue, wIndex, data, wLength, timeout); + if (err < 0) handle_usb_issue(err, __func__); + } while (err < 0 && connected); + pthread_mutex_unlock(&usb_lock); + + return err; +} + +int Panda::usb_bulk_write(unsigned char endpoint, unsigned char* data, int length, unsigned int timeout) { + int err; + int transferred = 0; + + if (!connected){ + return 0; + } + + pthread_mutex_lock(&usb_lock); + do { + // Try sending can messages. If the receive buffer on the panda is full it will NAK + // and libusb will try again. After 5ms, it will time out. We will drop the messages. + err = libusb_bulk_transfer(dev_handle, endpoint, data, length, &transferred, timeout); + + if (err == LIBUSB_ERROR_TIMEOUT) { + LOGW("Transmit buffer full"); + break; + } else if (err != 0 || length != transferred) { + handle_usb_issue(err, __func__); + } + } while(err != 0 && connected); + + pthread_mutex_unlock(&usb_lock); + return transferred; +} + +int Panda::usb_bulk_read(unsigned char endpoint, unsigned char* data, int length, unsigned int timeout) { + int err; + int transferred = 0; + + if (!connected){ + return 0; + } + + pthread_mutex_lock(&usb_lock); + + do { + err = libusb_bulk_transfer(dev_handle, endpoint, data, length, &transferred, timeout); + + if (err == LIBUSB_ERROR_TIMEOUT) { + break; // timeout is okay to exit, recv still happened + } else if (err == LIBUSB_ERROR_OVERFLOW) { + LOGE_100("overflow got 0x%x", transferred); + } else if (err != 0) { + handle_usb_issue(err, __func__); + } + + } while(err != 0 && connected); + + pthread_mutex_unlock(&usb_lock); + + return transferred; +} + +void Panda::set_safety_model(cereal::CarParams::SafetyModel safety_model, int safety_param){ + usb_write(0xdc, (uint16_t)safety_model, safety_param); +} + +void Panda::set_unsafe_mode(uint16_t unsafe_mode) { + usb_write(0xdf, unsafe_mode, 0); +} + +cereal::HealthData::HwType Panda::get_hw_type() { + unsigned char hw_query[1] = {0}; + + usb_read(0xc1, 0, 0, hw_query, 1); + return (cereal::HealthData::HwType)(hw_query[0]); +} + +void Panda::set_rtc(struct tm sys_time){ + // tm struct has year defined as years since 1900 + usb_write(0xa1, (uint16_t)(1900 + sys_time.tm_year), 0); + usb_write(0xa2, (uint16_t)(1 + sys_time.tm_mon), 0); + usb_write(0xa3, (uint16_t)sys_time.tm_mday, 0); + // usb_write(0xa4, (uint16_t)(1 + sys_time.tm_wday), 0); + usb_write(0xa5, (uint16_t)sys_time.tm_hour, 0); + usb_write(0xa6, (uint16_t)sys_time.tm_min, 0); + usb_write(0xa7, (uint16_t)sys_time.tm_sec, 0); +} + +struct tm Panda::get_rtc(){ + struct __attribute__((packed)) timestamp_t { + uint16_t year; // Starts at 0 + uint8_t month; + uint8_t day; + uint8_t weekday; + uint8_t hour; + uint8_t minute; + uint8_t second; + } rtc_time = {0}; + + usb_read(0xa0, 0, 0, (unsigned char*)&rtc_time, sizeof(rtc_time)); + + struct tm new_time = { 0 }; + new_time.tm_year = rtc_time.year - 1900; // tm struct has year defined as years since 1900 + new_time.tm_mon = rtc_time.month - 1; + new_time.tm_mday = rtc_time.day; + new_time.tm_hour = rtc_time.hour; + new_time.tm_min = rtc_time.minute; + new_time.tm_sec = rtc_time.second; + + return new_time; +} + +void Panda::set_fan_speed(uint16_t fan_speed){ + usb_write(0xb1, fan_speed, 0); +} + +uint16_t Panda::get_fan_speed(){ + uint16_t fan_speed_rpm = 0; + usb_read(0xb2, 0, 0, (unsigned char*)&fan_speed_rpm, sizeof(fan_speed_rpm)); + return fan_speed_rpm; +} + +void Panda::set_ir_pwr(uint16_t ir_pwr) { + usb_write(0xb0, ir_pwr, 0); +} + +health_t Panda::get_health(){ + health_t health {0}; + usb_read(0xd2, 0, 0, (unsigned char*)&health, sizeof(health)); + return health; +} + +void Panda::set_loopback(bool loopback){ + usb_write(0xe5, loopback, 0); +} + +const char* Panda::get_firmware_version(){ + const char* fw_sig_buf = new char[128](); + + int read_1 = usb_read(0xd3, 0, 0, (unsigned char*)fw_sig_buf, 64); + int read_2 = usb_read(0xd4, 0, 0, (unsigned char*)fw_sig_buf + 64, 64); + + if ((read_1 == 64) && (read_2 == 64)) { + return fw_sig_buf; + } + + delete[] fw_sig_buf; + return NULL; +} + +const char* Panda::get_serial(){ + const char* serial_buf = new char[16](); + + int err = usb_read(0xd0, 0, 0, (unsigned char*)serial_buf, 16); + + if (err >= 0) { + return serial_buf; + } + + delete[] serial_buf; + return NULL; +} + +void Panda::set_power_saving(bool power_saving){ + usb_write(0xe7, power_saving, 0); +} + +void Panda::set_usb_power_mode(cereal::HealthData::UsbPowerMode power_mode){ + usb_write(0xe6, (uint16_t)power_mode, 0); +} + +void Panda::send_heartbeat(){ + usb_write(0xf3, 1, 0); +} + +void Panda::can_send(capnp::List::Reader can_data_list){ + int msg_count = can_data_list.size(); + + uint32_t *send = new uint32_t[msg_count*0x10](); + + for (int i = 0; i < msg_count; i++) { + auto cmsg = can_data_list[i]; + if (cmsg.getAddress() >= 0x800) { // extended + send[i*4] = (cmsg.getAddress() << 3) | 5; + } else { // normal + send[i*4] = (cmsg.getAddress() << 21) | 1; + } + auto can_data = cmsg.getDat(); + assert(can_data.size() <= 8); + send[i*4+1] = can_data.size() | (cmsg.getSrc() << 4); + memcpy(&send[i*4+2], can_data.begin(), can_data.size()); + } + + usb_bulk_write(3, (unsigned char*)send, msg_count*0x10, 5); + + delete[] send; +} + +int Panda::can_receive(cereal::Event::Builder &event){ + uint32_t data[RECV_SIZE/4]; + int recv = usb_bulk_read(0x81, (unsigned char*)data, RECV_SIZE); + + // Not sure if this can happen + if (recv < 0) recv = 0; + + if (recv == RECV_SIZE) { + LOGW("Receive buffer full"); + } + + size_t num_msg = recv / 0x10; + auto canData = event.initCan(num_msg); + + // populate message + for (int i = 0; i < num_msg; i++) { + if (data[i*4] & 4) { + // extended + canData[i].setAddress(data[i*4] >> 3); + //printf("got extended: %x\n", data[i*4] >> 3); + } else { + // normal + canData[i].setAddress(data[i*4] >> 21); + } + canData[i].setBusTime(data[i*4+1] >> 16); + int len = data[i*4+1]&0xF; + canData[i].setDat(kj::arrayPtr((uint8_t*)&data[i*4+2], len)); + canData[i].setSrc((data[i*4+1] >> 4) & 0xff); + } + + return recv; +} diff --git a/selfdrive/boardd/panda.h b/selfdrive/boardd/panda.h new file mode 100644 index 00000000000000..119c123b1f6f10 --- /dev/null +++ b/selfdrive/boardd/panda.h @@ -0,0 +1,82 @@ +#pragma once + +#include +#include +#include + +#include + +#include "cereal/gen/cpp/car.capnp.h" +#include "cereal/gen/cpp/log.capnp.h" + +// double the FIFO size +#define RECV_SIZE (0x1000) +#define TIMEOUT 0 + +// copied from panda/board/main.c +struct __attribute__((packed)) health_t { + uint32_t uptime; + uint32_t voltage; + uint32_t current; + uint32_t can_rx_errs; + uint32_t can_send_errs; + uint32_t can_fwd_errs; + uint32_t gmlan_send_errs; + uint32_t faults; + uint8_t ignition_line; + uint8_t ignition_can; + uint8_t controls_allowed; + uint8_t gas_interceptor_detected; + uint8_t car_harness_status; + uint8_t usb_power_mode; + uint8_t safety_model; + uint8_t fault_status; + uint8_t power_save_enabled; +}; + + +void panda_set_power(bool power); + +class Panda { + private: + libusb_context *ctx = NULL; + libusb_device_handle *dev_handle = NULL; + pthread_mutex_t usb_lock; + void handle_usb_issue(int err, const char func[]); + void cleanup(); + + public: + Panda(); + ~Panda(); + + bool connected = true; + cereal::HealthData::HwType hw_type = cereal::HealthData::HwType::UNKNOWN; + bool is_pigeon = false; + bool has_rtc = false; + + // HW communication + int usb_write(uint8_t bRequest, uint16_t wValue, uint16_t wIndex, unsigned int timeout=TIMEOUT); + int usb_read(uint8_t bRequest, uint16_t wValue, uint16_t wIndex, unsigned char *data, uint16_t wLength, unsigned int timeout=TIMEOUT); + int usb_bulk_write(unsigned char endpoint, unsigned char* data, int length, unsigned int timeout=TIMEOUT); + int usb_bulk_read(unsigned char endpoint, unsigned char* data, int length, unsigned int timeout=TIMEOUT); + + // Panda functionality + cereal::HealthData::HwType get_hw_type(); + void set_safety_model(cereal::CarParams::SafetyModel safety_model, int safety_param=0); + void set_unsafe_mode(uint16_t unsafe_mode); + void set_rtc(struct tm sys_time); + struct tm get_rtc(); + void set_fan_speed(uint16_t fan_speed); + uint16_t get_fan_speed(); + void set_ir_pwr(uint16_t ir_pwr); + health_t get_health(); + void set_loopback(bool loopback); + const char* get_firmware_version(); + const char* get_serial(); + void set_power_saving(bool power_saving); + void set_usb_power_mode(cereal::HealthData::UsbPowerMode power_mode); + void send_heartbeat(); + void can_send(capnp::List::Reader can_data_list); + int can_receive(cereal::Event::Builder &event); + +}; diff --git a/selfdrive/boardd/pigeon.cc b/selfdrive/boardd/pigeon.cc new file mode 100644 index 00000000000000..4ec7ebf8ce3d70 --- /dev/null +++ b/selfdrive/boardd/pigeon.cc @@ -0,0 +1,226 @@ +#include +#include +#include +#include +#include + +#include "common/swaglog.h" +#include "common/gpio.h" + +#include "pigeon.h" + +// Termios on macos doesn't define all baud rate constants +#ifndef B460800 +#define B460800 0010004 +#endif + +using namespace std::string_literals; + + +Pigeon * Pigeon::connect(Panda * p){ + PandaPigeon * pigeon = new PandaPigeon(); + pigeon->connect(p); + + return pigeon; +} + +Pigeon * Pigeon::connect(const char * tty){ + TTYPigeon * pigeon = new TTYPigeon(); + pigeon->connect(tty); + + return pigeon; +} + +void Pigeon::init() { + usleep(1000*1000); + LOGW("panda GPS start"); + + // power off pigeon + set_power(0); + usleep(100*1000); + + // 9600 baud at init + set_baud(9600); + + // power on pigeon + set_power(1); + usleep(500*1000); + + // baud rate upping + send("\x24\x50\x55\x42\x58\x2C\x34\x31\x2C\x31\x2C\x30\x30\x30\x37\x2C\x30\x30\x30\x33\x2C\x34\x36\x30\x38\x30\x30\x2C\x30\x2A\x31\x35\x0D\x0A"s); + usleep(100*1000); + + // set baud rate to 460800 + set_baud(460800); + usleep(100*1000); + + // init from ubloxd + // To generate this data, run test/ubloxd.py with the print statements enabled in the write function in panda/python/serial.py + send("\xB5\x62\x06\x00\x14\x00\x03\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x1E\x7F"s); + send("\xB5\x62\x06\x3E\x00\x00\x44\xD2"s); + send("\xB5\x62\x06\x00\x14\x00\x00\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x19\x35"s); + send("\xB5\x62\x06\x00\x14\x00\x01\x00\x00\x00\xC0\x08\x00\x00\x00\x08\x07\x00\x01\x00\x01\x00\x00\x00\x00\x00\xF4\x80"s); + send("\xB5\x62\x06\x00\x14\x00\x04\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1D\x85"s); + send("\xB5\x62\x06\x00\x00\x00\x06\x18"s); + send("\xB5\x62\x06\x00\x01\x00\x01\x08\x22"s); + send("\xB5\x62\x06\x00\x01\x00\x02\x09\x23"s); + send("\xB5\x62\x06\x00\x01\x00\x03\x0A\x24"s); + send("\xB5\x62\x06\x08\x06\x00\x64\x00\x01\x00\x00\x00\x79\x10"s); + send("\xB5\x62\x06\x24\x24\x00\x05\x00\x04\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x5A\x63"s); + send("\xB5\x62\x06\x1E\x14\x00\x00\x00\x00\x00\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3C\x37"s); + send("\xB5\x62\x06\x24\x00\x00\x2A\x84"s); + send("\xB5\x62\x06\x23\x00\x00\x29\x81"s); + send("\xB5\x62\x06\x1E\x00\x00\x24\x72"s); + send("\xB5\x62\x06\x01\x03\x00\x01\x07\x01\x13\x51"s); + send("\xB5\x62\x06\x01\x03\x00\x02\x15\x01\x22\x70"s); + send("\xB5\x62\x06\x01\x03\x00\x02\x13\x01\x20\x6C"s); + send("\xB5\x62\x06\x01\x03\x00\x0A\x09\x01\x1E\x70"s); + + LOGW("panda GPS on"); +} + +void PandaPigeon::connect(Panda * p) { + panda = p; +} + +void PandaPigeon::set_baud(int baud) { + panda->usb_write(0xe2, 1, 0); + panda->usb_write(0xe4, 1, baud/300); +} + +void PandaPigeon::send(std::string s) { + int len = s.length(); + const char * dat = s.data(); + + unsigned char a[0x20+1]; + a[0] = 1; + for (int i=0; iusb_bulk_write(2, a, ll+1); + } +} + +std::string PandaPigeon::receive() { + std::string r; + + while (true){ + unsigned char dat[0x40]; + int len = panda->usb_read(0xe0, 1, 0, dat, sizeof(dat)); + if (len <= 0 || r.length() > 0x1000) break; + r.append((char*)dat, len); + } + + return r; +} + +void PandaPigeon::set_power(bool power) { + panda->usb_write(0xd9, power, 0); +} + +PandaPigeon::~PandaPigeon(){ +} + +void handle_tty_issue(int err, const char func[]) { + LOGE_100("tty error %d \"%s\" in %s", err, strerror(err), func); +} + +void TTYPigeon::connect(const char * tty) { + pigeon_tty_fd = open(tty, O_RDWR); + if (pigeon_tty_fd < 0){ + handle_tty_issue(errno, __func__); + assert(pigeon_tty_fd >= 0); + } + assert(tcgetattr(pigeon_tty_fd, &pigeon_tty) == 0); + + // configure tty + pigeon_tty.c_cflag &= ~PARENB; // disable parity + pigeon_tty.c_cflag &= ~CSTOPB; // single stop bit + pigeon_tty.c_cflag |= CS8; // 8 bits per byte + pigeon_tty.c_cflag &= ~CRTSCTS; // no RTS/CTS flow control + pigeon_tty.c_cflag |= CREAD | CLOCAL; // turn on READ & ignore ctrl lines + pigeon_tty.c_lflag &= ~ICANON; // disable canonical mode + pigeon_tty.c_lflag &= ~ISIG; // disable interpretation of INTR, QUIT and SUSP + pigeon_tty.c_iflag &= ~(IXON | IXOFF | IXANY); // turn off software flow ctrl + pigeon_tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL); // disable any special handling of received bytes + pigeon_tty.c_oflag &= ~OPOST; // prevent special interpretation of output bytes + pigeon_tty.c_oflag &= ~ONLCR; // prevent conversion of newline to carriage return/line feed + + // configure blocking behavior + pigeon_tty.c_cc[VMIN] = 0; // min amount of characters returned + pigeon_tty.c_cc[VTIME] = 0; // max blocking time in s/10 (0=inf) + + assert(tcsetattr(pigeon_tty_fd, TCSANOW, &pigeon_tty) == 0); +} + +void TTYPigeon::set_baud(int baud){ + speed_t baud_const = 0; + switch(baud){ + case 9600: + baud_const = B9600; + break; + case 460800: + baud_const = B460800; + break; + default: + assert(false); + } + + // make sure everything is tx'ed before changing baud + assert(tcdrain(pigeon_tty_fd) == 0); + + // change baud + assert(tcgetattr(pigeon_tty_fd, &pigeon_tty) == 0); + assert(cfsetspeed(&pigeon_tty, baud_const) == 0); + assert(tcsetattr(pigeon_tty_fd, TCSANOW, &pigeon_tty) == 0); + + // flush + assert(tcflush(pigeon_tty_fd, TCIOFLUSH) == 0); +} + +void TTYPigeon::send(std::string s) { + int len = s.length(); + const char * dat = s.data(); + + int err = write(pigeon_tty_fd, dat, len); + if(err < 0) { handle_tty_issue(err, __func__); } + err = tcdrain(pigeon_tty_fd); + if(err < 0) { handle_tty_issue(err, __func__); } +} + +std::string TTYPigeon::receive() { + std::string r; + + while (true){ + char dat[0x40]; + int len = read(pigeon_tty_fd, dat, sizeof(dat)); + if(len < 0) { + handle_tty_issue(len, __func__); + } else if (len == 0 || r.length() > 0x1000){ + break; + } else { + r.append(dat, len); + } + + } + return r; +} + +void TTYPigeon::set_power(bool power){ +#ifdef QCOM2 + int err = 0; + err += gpio_init(GPIO_UBLOX_RST_N, true); + err += gpio_init(GPIO_UBLOX_SAFEBOOT_N, true); + err += gpio_init(GPIO_UBLOX_PWR_EN, true); + + err += gpio_set(GPIO_UBLOX_RST_N, power); + err += gpio_set(GPIO_UBLOX_SAFEBOOT_N, power); + err += gpio_set(GPIO_UBLOX_PWR_EN, power); + assert(err == 0); +#endif +} + +TTYPigeon::~TTYPigeon(){ + close(pigeon_tty_fd); +} diff --git a/selfdrive/boardd/pigeon.h b/selfdrive/boardd/pigeon.h new file mode 100644 index 00000000000000..667ac70610c840 --- /dev/null +++ b/selfdrive/boardd/pigeon.h @@ -0,0 +1,43 @@ +#pragma once +#include +#include + + +#include "panda.h" + +class Pigeon { + public: + static Pigeon* connect(Panda * p); + static Pigeon* connect(const char * tty); + virtual ~Pigeon(){}; + + void init(); + virtual void set_baud(int baud) = 0; + virtual void send(std::string s) = 0; + virtual std::string receive() = 0; + virtual void set_power(bool power) = 0; +}; + +class PandaPigeon : public Pigeon { + Panda * panda = NULL; +public: + ~PandaPigeon(); + void connect(Panda * p); + void set_baud(int baud); + void send(std::string s); + std::string receive(); + void set_power(bool power); +}; + + +class TTYPigeon : public Pigeon { + int pigeon_tty_fd = -1; + struct termios pigeon_tty; +public: + ~TTYPigeon(); + void connect(const char* tty); + void set_baud(int baud); + void send(std::string s); + std::string receive(); + void set_power(bool power); +}; diff --git a/selfdrive/boardd/tests/boardd_old.py b/selfdrive/boardd/tests/boardd_old.py deleted file mode 100755 index 5989e627463a8c..00000000000000 --- a/selfdrive/boardd/tests/boardd_old.py +++ /dev/null @@ -1,250 +0,0 @@ -#!/usr/bin/env python - -# This file is not used by OpenPilot. Only boardd.cc is used. -# The python version is slower, but has more options for development. - -# TODO: merge the extra functionalities of this file (like MOCK) in boardd.c and -# delete this python version of boardd - -import os -import struct -import time - -import selfdrive.messaging as messaging -from common.realtime import Ratekeeper -from selfdrive.services import service_list -from selfdrive.swaglog import cloudlog -from selfdrive.boardd.boardd import can_capnp_to_can_list - -# USB is optional -try: - import usb1 - from usb1 import USBErrorIO, USBErrorOverflow #pylint: disable=no-name-in-module -except Exception: - pass - -SAFETY_NOOUTPUT = 0 -SAFETY_HONDA = 1 -SAFETY_TOYOTA = 2 -SAFETY_CHRYSLER = 9 -SAFETY_TOYOTA_NOLIMITS = 0x1336 -SAFETY_ALLOUTPUT = 0x1337 - -# *** serialization functions *** -def can_list_to_can_capnp(can_msgs, msgtype='can'): - dat = messaging.new_message() - dat.init(msgtype, len(can_msgs)) - for i, can_msg in enumerate(can_msgs): - if msgtype == 'sendcan': - cc = dat.sendcan[i] - else: - cc = dat.can[i] - cc.address = can_msg[0] - cc.busTime = can_msg[1] - cc.dat = str(can_msg[2]) - cc.src = can_msg[3] - return dat - - -# *** can driver *** -def can_health(): - while 1: - try: - dat = handle.controlRead(usb1.TYPE_VENDOR | usb1.RECIPIENT_DEVICE, 0xd2, 0, 0, 0x10) - break - except (USBErrorIO, USBErrorOverflow): - cloudlog.exception("CAN: BAD HEALTH, RETRYING") - v, i, started = struct.unpack("IIB", dat[0:9]) - # TODO: units - return {"voltage": v, "current": i, "started": bool(started)} - -def __parse_can_buffer(dat): - ret = [] - for j in range(0, len(dat), 0x10): - ddat = dat[j:j+0x10] - f1, f2 = struct.unpack("II", ddat[0:8]) - ret.append((f1 >> 21, f2>>16, ddat[8:8+(f2&0xF)], (f2>>4)&0xFF)) - return ret - -def can_send_many(arr): - snds = [] - for addr, _, dat, alt in arr: - if addr < 0x800: # only support 11 bit addr - snd = struct.pack("II", ((addr << 21) | 1), len(dat) | (alt << 4)) + dat - snd = snd.ljust(0x10, '\x00') - snds.append(snd) - while 1: - try: - handle.bulkWrite(3, ''.join(snds)) - break - except (USBErrorIO, USBErrorOverflow): - cloudlog.exception("CAN: BAD SEND MANY, RETRYING") - -def can_recv(): - dat = "" - while 1: - try: - dat = handle.bulkRead(1, 0x10*256) - break - except (USBErrorIO, USBErrorOverflow): - cloudlog.exception("CAN: BAD RECV, RETRYING") - return __parse_can_buffer(dat) - -def can_init(): - global handle, context - handle = None - cloudlog.info("attempting can init") - - context = usb1.USBContext() - #context.setDebug(9) - - for device in context.getDeviceList(skip_on_error=True): - if device.getVendorID() == 0xbbaa and device.getProductID() == 0xddcc: - handle = device.open() - handle.claimInterface(0) - handle.controlWrite(0x40, 0xdc, SAFETY_ALLOUTPUT, 0, b'') - - if handle is None: - cloudlog.warn("CAN NOT FOUND") - exit(-1) - - cloudlog.info("got handle") - cloudlog.info("can init done") - -def boardd_mock_loop(): - can_init() - handle.controlWrite(0x40, 0xdc, SAFETY_ALLOUTPUT, 0, b'') - - logcan = messaging.sub_sock(service_list['can'].port) - sendcan = messaging.pub_sock(service_list['sendcan'].port) - - while 1: - tsc = messaging.drain_sock(logcan, wait_for_one=True) - snds = map(lambda x: can_capnp_to_can_list(x.can), tsc) - snd = [] - for s in snds: - snd += s - snd = filter(lambda x: x[-1] <= 2, snd) - snd_0 = len(filter(lambda x: x[-1] == 0, snd)) - snd_1 = len(filter(lambda x: x[-1] == 1, snd)) - snd_2 = len(filter(lambda x: x[-1] == 2, snd)) - can_send_many(snd) - - # recv @ 100hz - can_msgs = can_recv() - got_0 = len(filter(lambda x: x[-1] == 0+0x80, can_msgs)) - got_1 = len(filter(lambda x: x[-1] == 1+0x80, can_msgs)) - got_2 = len(filter(lambda x: x[-1] == 2+0x80, can_msgs)) - print("sent %3d (%3d/%3d/%3d) got %3d (%3d/%3d/%3d)" % - (len(snd), snd_0, snd_1, snd_2, len(can_msgs), got_0, got_1, got_2)) - m = can_list_to_can_capnp(can_msgs, msgtype='sendcan') - sendcan.send(m.to_bytes()) - -def boardd_test_loop(): - can_init() - cnt = 0 - while 1: - can_send_many([[0xbb,0,"\xaa\xaa\xaa\xaa",0], [0xaa,0,"\xaa\xaa\xaa\xaa"+struct.pack("!I", cnt),1]]) - #can_send_many([[0xaa,0,"\xaa\xaa\xaa\xaa",0]]) - #can_send_many([[0xaa,0,"\xaa\xaa\xaa\xaa",1]]) - # recv @ 100hz - can_msgs = can_recv() - print("got %d" % (len(can_msgs))) - time.sleep(0.01) - cnt += 1 - -# *** main loop *** -def boardd_loop(rate=200): - rk = Ratekeeper(rate) - - can_init() - - # *** publishes can and health - logcan = messaging.pub_sock(service_list['can'].port) - health_sock = messaging.pub_sock(service_list['health'].port) - - # *** subscribes to can send - sendcan = messaging.sub_sock(service_list['sendcan'].port) - - # drain sendcan to delete any stale messages from previous runs - messaging.drain_sock(sendcan) - - while 1: - # health packet @ 1hz - if (rk.frame%rate) == 0: - health = can_health() - msg = messaging.new_message() - msg.init('health') - - # store the health to be logged - msg.health.voltage = health['voltage'] - msg.health.current = health['current'] - msg.health.started = health['started'] - msg.health.controlsAllowed = True - - health_sock.send(msg.to_bytes()) - - # recv @ 100hz - can_msgs = can_recv() - - # publish to logger - # TODO: refactor for speed - if len(can_msgs) > 0: - dat = can_list_to_can_capnp(can_msgs).to_bytes() - logcan.send(dat) - - # send can if we have a packet - tsc = messaging.recv_sock(sendcan) - if tsc is not None: - can_send_many(can_capnp_to_can_list(tsc.sendcan)) - - rk.keep_time() - -# *** main loop *** -def boardd_proxy_loop(rate=200, address="192.168.2.251"): - rk = Ratekeeper(rate) - - can_init() - - # *** subscribes can - logcan = messaging.sub_sock(service_list['can'].port, addr=address) - # *** publishes to can send - sendcan = messaging.pub_sock(service_list['sendcan'].port) - - # drain sendcan to delete any stale messages from previous runs - messaging.drain_sock(sendcan) - - while 1: - # recv @ 100hz - can_msgs = can_recv() - #for m in can_msgs: - # print("R: {0} {1}".format(hex(m[0]), str(m[2]).encode("hex"))) - - # publish to logger - # TODO: refactor for speed - if len(can_msgs) > 0: - dat = can_list_to_can_capnp(can_msgs, "sendcan") - sendcan.send(dat) - - # send can if we have a packet - tsc = messaging.recv_sock(logcan) - if tsc is not None: - cl = can_capnp_to_can_list(tsc.can) - #for m in cl: - # print("S: {0} {1}".format(hex(m[0]), str(m[2]).encode("hex"))) - can_send_many(cl) - - rk.keep_time() - -def main(gctx=None): - if os.getenv("MOCK") is not None: - boardd_mock_loop() - elif os.getenv("PROXY") is not None: - boardd_proxy_loop() - elif os.getenv("BOARDTEST") is not None: - boardd_test_loop() - else: - boardd_loop() - -if __name__ == "__main__": - main() diff --git a/selfdrive/boardd/tests/fuzzer.py b/selfdrive/boardd/tests/fuzzer.py deleted file mode 100755 index cb6edf710603ce..00000000000000 --- a/selfdrive/boardd/tests/fuzzer.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python -import time -import random - -from boardd_old import can_init, can_recv, can_send_many, can_health - -if __name__ == "__main__": - can_init() - while 1: - c = random.randint(0, 3) - if c == 0: - print can_recv() - elif c == 1: - print can_health() - elif c == 2: - many = [[0x123, 0, "abcdef", 0]] * random.randint(1, 10) - can_send_many(many) - elif c == 3: - time.sleep(random.randint(0, 100) / 1000.0) diff --git a/selfdrive/boardd/tests/replay_many.py b/selfdrive/boardd/tests/replay_many.py deleted file mode 100755 index 710cfee486ded5..00000000000000 --- a/selfdrive/boardd/tests/replay_many.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python -import sys -import time -import signal -from panda import Panda -from multiprocessing import Pool - -import selfdrive.messaging as messaging -from selfdrive.services import service_list -from selfdrive.boardd.boardd import can_capnp_to_can_list - -def initializer(): - """Ignore CTRL+C in the worker process. - source: https://stackoverflow.com/a/44869451 """ - signal.signal(signal.SIGINT, signal.SIG_IGN) - -def send_thread(serial): - panda = Panda(serial) - panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT) - panda.set_can_loopback(False) - - can_sock = messaging.sub_sock(service_list['can'].port) - - while True: - # Send messages one bus 0 and 1 - tsc = messaging.recv_one(can_sock) - snd = can_capnp_to_can_list(tsc.can) - snd = filter(lambda x: x[-1] <= 2, snd) - panda.can_send_many(snd) - - # Drain panda message buffer - panda.can_recv() - - -if __name__ == "__main__": - serials = Panda.list() - num_pandas = len(serials) - - if num_pandas == 0: - print("No pandas found. Exiting") - sys.exit(1) - else: - print("%d pandas found. Starting broadcast" % num_pandas) - - pool = Pool(num_pandas, initializer=initializer) - pool.map_async(send_thread, serials) - - while True: - try: - time.sleep(10) - except KeyboardInterrupt: - pool.terminate() - pool.join() - raise diff --git a/selfdrive/boardd/tests/test_boardd_api.py b/selfdrive/boardd/tests/test_boardd_api.py deleted file mode 100644 index 0e862b0952c3c2..00000000000000 --- a/selfdrive/boardd/tests/test_boardd_api.py +++ /dev/null @@ -1,76 +0,0 @@ -import random -import numpy as np - -import boardd_old -import selfdrive.boardd.boardd as boardd - -from common.realtime import sec_since_boot -from cereal import log -import unittest - - -def generate_random_can_data_list(): - can_list = [] - cnt = random.randint(1, 64) - for j in xrange(cnt): - can_data = np.random.bytes(random.randint(1, 8)) - can_list.append([random.randint(0, 128), random.randint(0, 128), can_data, random.randint(0, 128)]) - return can_list, cnt - - -class TestBoarddApiMethods(unittest.TestCase): - def test_correctness(self): - for i in xrange(1000): - can_list, _ = generate_random_can_data_list() - - # Sendcan - # Old API - m_old = boardd_old.can_list_to_can_capnp(can_list, 'sendcan').to_bytes() - # new API - m = boardd.can_list_to_can_capnp(can_list, 'sendcan') - - ev_old = log.Event.from_bytes(m_old) - ev = log.Event.from_bytes(m) - self.assertEqual(ev_old.which(), ev.which()) - self.assertEqual(len(ev.sendcan), len(ev_old.sendcan)) - for i in xrange(len(ev.sendcan)): - attrs = ['address', 'busTime', 'dat', 'src'] - for attr in attrs: - self.assertEqual(getattr(ev.sendcan[i], attr, 'new'), getattr(ev_old.sendcan[i], attr, 'old')) - - # Can - m_old = boardd_old.can_list_to_can_capnp(can_list, 'can').to_bytes() - # new API - m = boardd.can_list_to_can_capnp(can_list, 'can') - - ev_old = log.Event.from_bytes(m_old) - ev = log.Event.from_bytes(m) - self.assertEqual(ev_old.which(), ev.which()) - self.assertEqual(len(ev.can), len(ev_old.can)) - for i in xrange(len(ev.can)): - attrs = ['address', 'busTime', 'dat', 'src'] - for attr in attrs: - self.assertEqual(getattr(ev.can[i], attr, 'new'), getattr(ev_old.can[i], attr, 'old')) - - def test_performance(self): - can_list, cnt = generate_random_can_data_list() - recursions = 1000 - - n1 = sec_since_boot() - for i in xrange(recursions): - boardd_old.can_list_to_can_capnp(can_list, 'sendcan').to_bytes() - n2 = sec_since_boot() - elapsed_old = n2 - n1 - - # print('Old API, elapsed time: {} secs'.format(elapsed_old)) - n1 = sec_since_boot() - for i in xrange(recursions): - boardd.can_list_to_can_capnp(can_list) - n2 = sec_since_boot() - elapsed_new = n2 - n1 - # print('New API, elapsed time: {} secs'.format(elapsed_new)) - self.assertTrue(elapsed_new < elapsed_old / 2) - - -if __name__ == '__main__': - unittest.main() diff --git a/selfdrive/boardd/tests/test_boardd_loopback.py b/selfdrive/boardd/tests/test_boardd_loopback.py deleted file mode 100755 index 042a5783a5f13a..00000000000000 --- a/selfdrive/boardd/tests/test_boardd_loopback.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -"""Run boardd with the BOARDD_LOOPBACK envvar before running this test.""" - -import os -import random -import time - -from selfdrive.boardd.boardd import can_list_to_can_capnp -from selfdrive.messaging import drain_sock, pub_sock, sub_sock -from selfdrive.services import service_list - -def get_test_string(): - return b"test"+os.urandom(10) - -BUS = 0 - -def main(): - rcv = sub_sock(service_list['can'].port) # port 8006 - snd = pub_sock(service_list['sendcan'].port) # port 8017 - time.sleep(0.3) # wait to bind before send/recv - - for i in range(10): - print("Loop %d" % i) - at = random.randint(1024, 2000) - st = get_test_string()[0:8] - snd.send(can_list_to_can_capnp([[at, 0, st, 0]], msgtype='sendcan').to_bytes()) - time.sleep(0.1) - res = drain_sock(rcv, True) - assert len(res) == 1 - - res = res[0].can - assert len(res) == 2 - - msg0, msg1 = res - - assert msg0.dat == st - assert msg1.dat == st - - assert msg0.address == at - assert msg1.address == at - - assert msg0.src == 0x80 | BUS - assert msg1.src == BUS - - print("Success") - -if __name__ == "__main__": - main() diff --git a/selfdrive/camerad/SConscript b/selfdrive/camerad/SConscript new file mode 100644 index 00000000000000..feb55a59e80187 --- /dev/null +++ b/selfdrive/camerad/SConscript @@ -0,0 +1,40 @@ +Import('env', 'arch', 'cereal', 'messaging', 'common', 'gpucommon', 'visionipc', 'USE_WEBCAM', 'QCOM_REPLAY') + +libs = ['m', 'pthread', common, 'jpeg', 'OpenCL', cereal, messaging, 'zmq', 'capnp', 'kj', visionipc, gpucommon] + +if arch == "aarch64": + libs += ['gsl', 'CB', 'adreno_utils', 'EGL', 'GLESv3', 'cutils', 'ui'] + if QCOM_REPLAY: + cameras = ['cameras/camera_frame_stream.cc'] + else: + cameras = ['cameras/camera_qcom.cc'] +elif arch == "larch64": + libs += ['atomic'] + cameras = ['cameras/camera_qcom2.cc'] +else: + if USE_WEBCAM: + libs += ['opencv_core', 'opencv_highgui', 'opencv_imgproc', 'opencv_videoio'] + cameras = ['cameras/camera_webcam.cc'] + env = env.Clone() + env.Append(CXXFLAGS = '-DWEBCAM') + env.Append(CFLAGS = '-DWEBCAM') + env.Append(CPPPATH = '/usr/local/include/opencv4') + else: + cameras = ['cameras/camera_frame_stream.cc'] + + if arch == "Darwin": + del libs[libs.index('OpenCL')] + del libs[libs.index(gpucommon)][gpucommon.index('GL')] + env = env.Clone() + env['FRAMEWORKS'] = ['OpenCL', 'OpenGL'] + +env.SharedLibrary('snapshot/visionipc', + ["#selfdrive/common/visionipc.c", "#selfdrive/common/ipc.c"]) + +env.Program('camerad', [ + 'main.cc', + 'cameras/camera_common.cc', + 'transforms/rgb_to_yuv.cc', + 'imgproc/utils.cc', + cameras, + ], LIBS=libs) diff --git a/selfdrive/camerad/cameras/camera_common.cc b/selfdrive/camerad/cameras/camera_common.cc new file mode 100644 index 00000000000000..273103aa1e32d5 --- /dev/null +++ b/selfdrive/camerad/cameras/camera_common.cc @@ -0,0 +1,427 @@ +#include +#include +#include +#include +#include + +#if defined(QCOM) && !defined(QCOM_REPLAY) +#include "cameras/camera_qcom.h" +#elif QCOM2 +#include "cameras/camera_qcom2.h" +#elif WEBCAM +#include "cameras/camera_webcam.h" +#else +#include "cameras/camera_frame_stream.h" +#endif + +#include "camera_common.h" +#include +#include + +#include "clutil.h" +#include "common/params.h" +#include "common/swaglog.h" +#include "common/util.h" +#include "imgproc/utils.h" + +const int env_xmin = getenv("XMIN") ? atoi(getenv("XMIN")) : 0; +const int env_xmax = getenv("XMAX") ? atoi(getenv("XMAX")) : -1; +const int env_ymin = getenv("YMIN") ? atoi(getenv("YMIN")) : 0; +const int env_ymax = getenv("YMAX") ? atoi(getenv("YMAX")) : -1; +const int env_scale = getenv("SCALE") ? atoi(getenv("SCALE")) : 1; + +static cl_program build_debayer_program(cl_device_id device_id, cl_context context, const CameraInfo *ci, const CameraBuf *b) { + char args[4096]; + snprintf(args, sizeof(args), + "-cl-fast-relaxed-math -cl-denorms-are-zero " + "-DFRAME_WIDTH=%d -DFRAME_HEIGHT=%d -DFRAME_STRIDE=%d " + "-DRGB_WIDTH=%d -DRGB_HEIGHT=%d -DRGB_STRIDE=%d " + "-DBAYER_FLIP=%d -DHDR=%d", + ci->frame_width, ci->frame_height, ci->frame_stride, + b->rgb_width, b->rgb_height, b->rgb_stride, + ci->bayer_flip, ci->hdr); +#ifdef QCOM2 + return cl_program_from_file(context, device_id, "cameras/real_debayer.cl", args); +#else + return cl_program_from_file(context, device_id, "cameras/debayer.cl", args); +#endif +} + +void CameraBuf::init(cl_device_id device_id, cl_context context, CameraState *s, int frame_cnt, + const char *name, release_cb relase_callback) { + const CameraInfo *ci = &s->ci; + camera_state = s; + frame_buf_count = frame_cnt; + frame_size = ci->frame_height * ci->frame_stride; + + camera_bufs = std::make_unique(frame_buf_count); + camera_bufs_metadata = std::make_unique(frame_buf_count); + for (int i = 0; i < frame_buf_count; i++) { + camera_bufs[i] = visionbuf_allocate_cl(frame_size, device_id, context); + } + + rgb_width = ci->frame_width; + rgb_height = ci->frame_height; +#ifndef QCOM2 + // debayering does a 2x downscale + if (ci->bayer) { + rgb_width = ci->frame_width / 2; + rgb_height = ci->frame_height / 2; + } + float db_s = 0.5; +#else + float db_s = 1.0; +#endif + + if (ci->bayer) { + yuv_transform = transform_scale_buffer(s->transform, db_s); + } else { + yuv_transform = s->transform; + } + + for (int i = 0; i < UI_BUF_COUNT; i++) { + VisionImg img = visionimg_alloc_rgb24(device_id, context, rgb_width, rgb_height, &rgb_bufs[i]); + if (i == 0) { + rgb_stride = img.stride; + } + } + tbuffer_init(&ui_tb, UI_BUF_COUNT, name); + tbuffer_init2(&camera_tb, frame_buf_count, "frame", relase_callback, s); + + // yuv back for recording and orbd + pool_init(&yuv_pool, YUV_COUNT); + yuv_tb = pool_get_tbuffer(&yuv_pool); + + yuv_width = rgb_width; + yuv_height = rgb_height; + yuv_buf_size = rgb_width * rgb_height * 3 / 2; + + for (int i = 0; i < YUV_COUNT; i++) { + yuv_ion[i] = visionbuf_allocate_cl(yuv_buf_size, device_id, context); + yuv_bufs[i].y = (uint8_t *)yuv_ion[i].addr; + yuv_bufs[i].u = yuv_bufs[i].y + (yuv_width * yuv_height); + yuv_bufs[i].v = yuv_bufs[i].u + (yuv_width / 2 * yuv_height / 2); + } + + if (ci->bayer) { + cl_program prg_debayer = build_debayer_program(device_id, context, ci, this); + krnl_debayer = CL_CHECK_ERR(clCreateKernel(prg_debayer, "debayer10", &err)); + CL_CHECK(clReleaseProgram(prg_debayer)); + } + + rgb_to_yuv_init(&rgb_to_yuv_state, context, device_id, yuv_width, yuv_height, rgb_stride); + +#ifdef __APPLE__ + q = CL_CHECK_ERR(clCreateCommandQueue(context, device_id, 0, &err)); +#else + const cl_queue_properties props[] = {0}; //CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_HIGH_KHR, 0}; + q = CL_CHECK_ERR(clCreateCommandQueueWithProperties(context, device_id, props, &err)); +#endif +} + +CameraBuf::~CameraBuf() { + for (int i = 0; i < frame_buf_count; i++) { + visionbuf_free(&camera_bufs[i]); + } + for (int i = 0; i < UI_BUF_COUNT; i++) { + visionbuf_free(&rgb_bufs[i]); + } + for (int i = 0; i < YUV_COUNT; i++) { + visionbuf_free(&yuv_ion[i]); + } + rgb_to_yuv_destroy(&rgb_to_yuv_state); + + if (krnl_debayer) { + CL_CHECK(clReleaseKernel(krnl_debayer)); + } + CL_CHECK(clReleaseCommandQueue(q)); +} + +bool CameraBuf::acquire() { + const int buf_idx = tbuffer_acquire(&camera_tb); + if (buf_idx < 0) { + return false; + } + const FrameMetadata &frame_data = camera_bufs_metadata[buf_idx]; + if (frame_data.frame_id == -1) { + LOGE("no frame data? wtf"); + tbuffer_release(&camera_tb, buf_idx); + return false; + } + + cur_frame_data = frame_data; + + cur_rgb_idx = tbuffer_select(&ui_tb); + cur_rgb_buf = &rgb_bufs[cur_rgb_idx]; + + cl_event debayer_event; + cl_mem camrabuf_cl = camera_bufs[buf_idx].buf_cl; + if (camera_state->ci.bayer) { + CL_CHECK(clSetKernelArg(krnl_debayer, 0, sizeof(cl_mem), &camrabuf_cl)); + CL_CHECK(clSetKernelArg(krnl_debayer, 1, sizeof(cl_mem), &cur_rgb_buf->buf_cl)); +#ifdef QCOM2 + constexpr int localMemSize = (DEBAYER_LOCAL_WORKSIZE + 2 * (3 / 2)) * (DEBAYER_LOCAL_WORKSIZE + 2 * (3 / 2)) * sizeof(float); + const size_t globalWorkSize[] = {size_t(camera_state->ci.frame_width), size_t(camera_state->ci.frame_height)}; + const size_t localWorkSize[] = {DEBAYER_LOCAL_WORKSIZE, DEBAYER_LOCAL_WORKSIZE}; + CL_CHECK(clSetKernelArg(krnl_debayer, 2, localMemSize, 0)); + CL_CHECK(clEnqueueNDRangeKernel(q, krnl_debayer, 2, NULL, globalWorkSize, localWorkSize, + 0, 0, &debayer_event)); +#else + float digital_gain = camera_state->digital_gain; + if ((int)digital_gain == 0) { + digital_gain = 1.0; + } + CL_CHECK(clSetKernelArg(krnl_debayer, 2, sizeof(float), &digital_gain)); + const size_t debayer_work_size = rgb_height; // doesn't divide evenly, is this okay? + CL_CHECK(clEnqueueNDRangeKernel(q, krnl_debayer, 1, NULL, + &debayer_work_size, NULL, 0, 0, &debayer_event)); +#endif + } else { + assert(cur_rgb_buf->len >= frame_size); + assert(rgb_stride == camera_state->ci.frame_stride); + CL_CHECK(clEnqueueCopyBuffer(q, camrabuf_cl, cur_rgb_buf->buf_cl, 0, 0, + cur_rgb_buf->len, 0, 0, &debayer_event)); + } + + clWaitForEvents(1, &debayer_event); + CL_CHECK(clReleaseEvent(debayer_event)); + + tbuffer_release(&camera_tb, buf_idx); + visionbuf_sync(cur_rgb_buf, VISIONBUF_SYNC_FROM_DEVICE); + + cur_yuv_idx = pool_select(&yuv_pool); + yuv_metas[cur_yuv_idx] = frame_data; + rgb_to_yuv_queue(&rgb_to_yuv_state, q, cur_rgb_buf->buf_cl, yuv_ion[cur_yuv_idx].buf_cl); + visionbuf_sync(&yuv_ion[cur_yuv_idx], VISIONBUF_SYNC_FROM_DEVICE); + + // keep another reference around till were done processing + pool_acquire(&yuv_pool, cur_yuv_idx); + pool_push(&yuv_pool, cur_yuv_idx); + + tbuffer_dispatch(&ui_tb, cur_rgb_idx); + + return true; +} + +void CameraBuf::release() { + pool_release(&yuv_pool, cur_yuv_idx); +} + +void CameraBuf::stop() { + tbuffer_stop(&ui_tb); + tbuffer_stop(&camera_tb); + pool_stop(&yuv_pool); +} + +// common functions + +void fill_frame_data(cereal::FrameData::Builder &framed, const FrameMetadata &frame_data, uint32_t cnt) { + framed.setFrameId(frame_data.frame_id); + framed.setTimestampEof(frame_data.timestamp_eof); + framed.setFrameLength(frame_data.frame_length); + framed.setIntegLines(frame_data.integ_lines); + framed.setGlobalGain(frame_data.global_gain); + framed.setLensPos(frame_data.lens_pos); + framed.setLensSag(frame_data.lens_sag); + framed.setLensErr(frame_data.lens_err); + framed.setLensTruePos(frame_data.lens_true_pos); + framed.setGainFrac(frame_data.gain_frac); +} + +void fill_frame_image(cereal::FrameData::Builder &framed, uint8_t *dat, int w, int h, int stride) { + if (dat != nullptr) { + int scale = env_scale; + int x_min = env_xmin; int y_min = env_ymin; int x_max = w-1; int y_max = h-1; + if (env_xmax != -1) x_max = env_xmax; + if (env_ymax != -1) y_max = env_ymax; + int new_width = (x_max - x_min + 1) / scale; + int new_height = (y_max - y_min + 1) / scale; + uint8_t *resized_dat = new uint8_t[new_width*new_height*3]; + + int goff = x_min*3 + y_min*stride; + for (int r=0;rbuf; + + uint8_t* thumbnail_buffer = NULL; + unsigned long thumbnail_len = 0; + + unsigned char *row = (unsigned char *)malloc(b->rgb_width/4*3); + + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; + + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_compress(&cinfo); + jpeg_mem_dest(&cinfo, &thumbnail_buffer, &thumbnail_len); + + cinfo.image_width = b->rgb_width / 4; + cinfo.image_height = b->rgb_height / 4; + cinfo.input_components = 3; + cinfo.in_color_space = JCS_RGB; + + jpeg_set_defaults(&cinfo); +#ifndef __APPLE__ + jpeg_set_quality(&cinfo, 50, true); + jpeg_start_compress(&cinfo, true); +#else + jpeg_set_quality(&cinfo, 50, static_cast(true) ); + jpeg_start_compress(&cinfo, static_cast(true) ); +#endif + + JSAMPROW row_pointer[1]; + for (int ii = 0; ii < b->rgb_height/4; ii+=1) { + for (int j = 0; j < b->rgb_width*3; j+=12) { + for (int k = 0; k < 3; k++) { + uint16_t dat = 0; + int i = ii * 4; + dat += bgr_ptr[b->rgb_stride*i + j + k]; + dat += bgr_ptr[b->rgb_stride*i + j+3 + k]; + dat += bgr_ptr[b->rgb_stride*(i+1) + j + k]; + dat += bgr_ptr[b->rgb_stride*(i+1) + j+3 + k]; + dat += bgr_ptr[b->rgb_stride*(i+2) + j + k]; + dat += bgr_ptr[b->rgb_stride*(i+2) + j+3 + k]; + dat += bgr_ptr[b->rgb_stride*(i+3) + j + k]; + dat += bgr_ptr[b->rgb_stride*(i+3) + j+3 + k]; + row[(j/4) + (2-k)] = dat/8; + } + } + row_pointer[0] = row; + jpeg_write_scanlines(&cinfo, row_pointer, 1); + } + jpeg_finish_compress(&cinfo); + jpeg_destroy_compress(&cinfo); + free(row); + + MessageBuilder msg; + auto thumbnaild = msg.initEvent().initThumbnail(); + thumbnaild.setFrameId(b->cur_frame_data.frame_id); + thumbnaild.setTimestampEof(b->cur_frame_data.timestamp_eof); + thumbnaild.setThumbnail(kj::arrayPtr((const uint8_t*)thumbnail_buffer, thumbnail_len)); + + if (s->pm != NULL) { + s->pm->send("thumbnail", msg); + } + free(thumbnail_buffer); +} + +void set_exposure_target(CameraState *c, const uint8_t *pix_ptr, int x_start, int x_end, int x_skip, int y_start, int y_end, int y_skip) { + const CameraBuf *b = &c->buf; + + uint32_t lum_binning[256] = {0}; + for (int y = y_start; y < y_end; y += y_skip) { + for (int x = x_start; x < x_end; x += x_skip) { + uint8_t lum = pix_ptr[(y * b->yuv_width) + x]; + lum_binning[lum]++; + } + } + + unsigned int lum_total = (y_end - y_start) * (x_end - x_start) / x_skip / y_skip; + unsigned int lum_cur = 0; + int lum_med = 0; + int lum_med_alt = 0; + for (lum_med=255; lum_med>=0; lum_med--) { + lum_cur += lum_binning[lum_med]; +#ifdef QCOM2 + bool reach_hlc_perc = false; + if (c->camera_num == 0) { // wide + reach_hlc_perc = lum_cur > 2*lum_total / (3*HLC_A); + } else { + reach_hlc_perc = lum_cur > lum_total / HLC_A; + } + if (reach_hlc_perc && lum_med > HLC_THRESH) { + lum_med_alt = 86; + } +#endif + if (lum_cur >= lum_total / 2) { + break; + } + } + lum_med = lum_med_alt>lum_med?lum_med_alt:lum_med; + camera_autoexposure(c, lum_med / 256.0); +} + +extern volatile sig_atomic_t do_exit; + +void *processing_thread(MultiCameraState *cameras, const char *tname, + CameraState *cs, process_thread_cb callback) { + set_thread_name(tname); + + for (int cnt = 0; !do_exit; cnt++) { + if (!cs->buf.acquire()) continue; + + callback(cameras, cs, cnt); + + cs->buf.release(); + } + return NULL; +} + +std::thread start_process_thread(MultiCameraState *cameras, const char *tname, + CameraState *cs, process_thread_cb callback) { + return std::thread(processing_thread, cameras, tname, cs, callback); +} + +void common_camera_process_front(SubMaster *sm, PubMaster *pm, CameraState *c, int cnt) { + const CameraBuf *b = &c->buf; + + static int x_min = 0, x_max = 0, y_min = 0, y_max = 0; + static const bool rhd_front = Params().read_db_bool("IsRHD"); + + // auto exposure + if (cnt % 3 == 0) { + if (sm->update(0) > 0 && sm->updated("driverState")) { + auto state = (*sm)["driverState"].getDriverState(); + // set front camera metering target + if (state.getFaceProb() > 0.4) { + auto face_position = state.getFacePosition(); + int x_offset = rhd_front ? 0 : b->rgb_width - (0.5 * b->rgb_height); + x_offset += (face_position[0] * (rhd_front ? -1.0 : 1.0) + 0.5) * (0.5 * b->rgb_height); + const int y_offset = (face_position[1] + 0.5) * b->rgb_height; + + x_min = std::max(0, x_offset - 72); + x_max = std::min(b->rgb_width - 1, x_offset + 72); + y_min = std::max(0, y_offset - 72); + y_max = std::min(b->rgb_height - 1, y_offset + 72); + } else { // use default setting if no face + x_min = x_max = y_min = y_max = 0; + } + } + + int skip = 1; + // use driver face crop for AE + if (x_max == 0) { + // default setting + x_min = rhd_front ? 0 : b->rgb_width * 3 / 5; + x_max = rhd_front ? b->rgb_width * 2 / 5 : b->rgb_width; + y_min = b->rgb_height / 3; + y_max = b->rgb_height; + } +#ifdef QCOM2 + x_min = 96; + x_max = 1832; + y_min = 242; + y_max = 1148; + skip = 4; +#endif + set_exposure_target(c, (const uint8_t *)b->yuv_bufs[b->cur_yuv_idx].y, x_min, x_max, 2, y_min, y_max, skip); + } + + MessageBuilder msg; + auto framed = msg.initEvent().initFrontFrame(); + framed.setFrameType(cereal::FrameData::FrameType::FRONT); + fill_frame_data(framed, b->cur_frame_data, cnt); + if (env_send_front) { + fill_frame_image(framed, (uint8_t*)b->cur_rgb_buf->addr, b->rgb_width, b->rgb_height, b->rgb_stride); + } + pm->send("frontFrame", msg); +} diff --git a/selfdrive/camerad/cameras/camera_common.h b/selfdrive/camerad/cameras/camera_common.h new file mode 100644 index 00000000000000..1eb68422e5183f --- /dev/null +++ b/selfdrive/camerad/cameras/camera_common.h @@ -0,0 +1,142 @@ +#pragma once + +#include +#include +#include +#include +#include +#include "common/buffering.h" +#include "common/mat.h" +#include "common/swaglog.h" +#include "common/visionbuf.h" +#include "common/visionimg.h" +#include "imgproc/utils.h" +#include "messaging.hpp" +#include "transforms/rgb_to_yuv.h" + +#include "common/visionipc.h" + +#define CAMERA_ID_IMX298 0 +#define CAMERA_ID_IMX179 1 +#define CAMERA_ID_S5K3P8SP 2 +#define CAMERA_ID_OV8865 3 +#define CAMERA_ID_IMX298_FLIPPED 4 +#define CAMERA_ID_OV10640 5 +#define CAMERA_ID_LGC920 6 +#define CAMERA_ID_LGC615 7 +#define CAMERA_ID_AR0231 8 +#define CAMERA_ID_MAX 9 + +#define UI_BUF_COUNT 4 +#define YUV_COUNT 40 +#define LOG_CAMERA_ID_FCAMERA 0 +#define LOG_CAMERA_ID_DCAMERA 1 +#define LOG_CAMERA_ID_ECAMERA 2 +#define LOG_CAMERA_ID_QCAMERA 3 +#define LOG_CAMERA_ID_MAX 4 + +const bool env_send_front = getenv("SEND_FRONT") != NULL; +const bool env_send_rear = getenv("SEND_REAR") != NULL; +const bool env_send_wide = getenv("SEND_WIDE") != NULL; + +typedef struct CameraInfo { + const char* name; + int frame_width, frame_height; + int frame_stride; + bool bayer; + int bayer_flip; + bool hdr; +} CameraInfo; + +typedef struct LogCameraInfo { + const char* filename; + const char* frame_packet_name; + const char* encode_idx_name; + VisionStreamType stream_type; + int frame_width, frame_height; + int fps; + int bitrate; + bool is_h265; + bool downscale; + bool has_qcamera; +} LogCameraInfo; + +typedef struct FrameMetadata { + uint32_t frame_id; + uint64_t timestamp_sof; // only set on tici + uint64_t timestamp_eof; + unsigned int frame_length; + unsigned int integ_lines; + unsigned int global_gain; + unsigned int lens_pos; + float lens_sag; + float lens_err; + float lens_true_pos; + float gain_frac; +} FrameMetadata; + +typedef struct CameraExpInfo { + int op_id; + float grey_frac; +} CameraExpInfo; + +extern CameraInfo cameras_supported[CAMERA_ID_MAX]; + +typedef struct { + uint8_t *y, *u, *v; +} YUVBuf; + +struct MultiCameraState; +struct CameraState; +typedef void (*release_cb)(void *cookie, int buf_idx); + +class CameraBuf { +public: + + CameraState *camera_state; + cl_kernel krnl_debayer; + cl_command_queue q; + + Pool yuv_pool; + VisionBuf yuv_ion[YUV_COUNT]; + YUVBuf yuv_bufs[YUV_COUNT]; + FrameMetadata yuv_metas[YUV_COUNT]; + size_t yuv_buf_size; + int yuv_width, yuv_height; + RGBToYUVState rgb_to_yuv_state; + + int rgb_width, rgb_height, rgb_stride; + VisionBuf rgb_bufs[UI_BUF_COUNT]; + + mat3 yuv_transform; + + int cur_yuv_idx, cur_rgb_idx; + FrameMetadata cur_frame_data; + VisionBuf *cur_rgb_buf; + + + std::unique_ptr camera_bufs; + std::unique_ptr camera_bufs_metadata; + TBuffer camera_tb, ui_tb; + TBuffer *yuv_tb; // only for visionserver + + CameraBuf() = default; + ~CameraBuf(); + void init(cl_device_id device_id, cl_context context, CameraState *s, int frame_cnt, + const char *name = "frame", release_cb relase_callback = nullptr); + bool acquire(); + void release(); + void stop(); + int frame_buf_count; + int frame_size; +}; + +typedef void (*process_thread_cb)(MultiCameraState *s, CameraState *c, int cnt); + +void fill_frame_data(cereal::FrameData::Builder &framed, const FrameMetadata &frame_data, uint32_t cnt); +void fill_frame_image(cereal::FrameData::Builder &framed, uint8_t *dat, int w, int h, int stride); +void create_thumbnail(MultiCameraState *s, CameraState *c, uint8_t *bgr_ptr); +void set_exposure_target(CameraState *c, const uint8_t *pix_ptr, int x_start, int x_end, int x_skip, int y_start, int y_end, int y_skip); +std::thread start_process_thread(MultiCameraState *cameras, const char *tname, + CameraState *cs, process_thread_cb callback); +void common_camera_process_front(SubMaster *sm, PubMaster *pm, CameraState *c, int cnt); diff --git a/selfdrive/camerad/cameras/camera_frame_stream.cc b/selfdrive/camerad/cameras/camera_frame_stream.cc new file mode 100644 index 00000000000000..aab8d72c6b3e9d --- /dev/null +++ b/selfdrive/camerad/cameras/camera_frame_stream.cc @@ -0,0 +1,134 @@ +#include "camera_frame_stream.h" + +#include +#include +#include +#include + +#include +#include "messaging.hpp" + +#include "common/util.h" +#include "common/timing.h" +#include "common/swaglog.h" +#include "buffering.h" + +extern "C" { +#include +} + +extern volatile sig_atomic_t do_exit; + +#define FRAME_WIDTH 1164 +#define FRAME_HEIGHT 874 + +namespace { +void camera_open(CameraState *s, bool rear) { +} + +void camera_close(CameraState *s) { + s->buf.stop(); +} + +void camera_init(CameraState *s, int camera_id, unsigned int fps, cl_device_id device_id, cl_context ctx) { + assert(camera_id < ARRAYSIZE(cameras_supported)); + s->ci = cameras_supported[camera_id]; + assert(s->ci.frame_width != 0); + + s->fps = fps; + s->buf.init(device_id, ctx, s, FRAME_BUF_COUNT, "camera"); +} + +void run_frame_stream(MultiCameraState *s) { + s->sm = new SubMaster({"frame"}); + + CameraState *const rear_camera = &s->rear; + auto *tb = &rear_camera->buf.camera_tb; + + while (!do_exit) { + if (s->sm->update(1000) == 0) continue; + + auto frame = (*(s->sm))["frame"].getFrame(); + + const int buf_idx = tbuffer_select(tb); + rear_camera->buf.camera_bufs_metadata[buf_idx] = { + .frame_id = frame.getFrameId(), + .timestamp_eof = frame.getTimestampEof(), + .frame_length = static_cast(frame.getFrameLength()), + .integ_lines = static_cast(frame.getIntegLines()), + .global_gain = static_cast(frame.getGlobalGain()), + }; + + cl_command_queue q = rear_camera->buf.camera_bufs[buf_idx].copy_q; + cl_mem yuv_cl = rear_camera->buf.camera_bufs[buf_idx].buf_cl; + + clEnqueueWriteBuffer(q, yuv_cl, CL_TRUE, 0, frame.getImage().size(), frame.getImage().begin(), 0, NULL, NULL); + tbuffer_dispatch(tb, buf_idx); + } +} + +} // namespace + +CameraInfo cameras_supported[CAMERA_ID_MAX] = { + [CAMERA_ID_IMX298] = { + .frame_width = FRAME_WIDTH, + .frame_height = FRAME_HEIGHT, + .frame_stride = FRAME_WIDTH*3, + .bayer = false, + .bayer_flip = false, + }, + [CAMERA_ID_OV8865] = { + .frame_width = 1632, + .frame_height = 1224, + .frame_stride = 2040, // seems right + .bayer = true, + .bayer_flip = 3, + .hdr = false + }, +}; + +void cameras_init(MultiCameraState *s, cl_device_id device_id, cl_context ctx) { + camera_init(&s->rear, CAMERA_ID_IMX298, 20, device_id, ctx); + s->rear.transform = (mat3){{ + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0, + }}; + + camera_init(&s->front, CAMERA_ID_OV8865, 10, device_id, ctx); + s->front.transform = (mat3){{ + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0, + }}; +} + +void camera_autoexposure(CameraState *s, float grey_frac) {} + +void cameras_open(MultiCameraState *s) { + // LOG("*** open front ***"); + camera_open(&s->front, false); + + // LOG("*** open rear ***"); + camera_open(&s->rear, true); +} + +void cameras_close(MultiCameraState *s) { + camera_close(&s->rear); +} + +// called by processing_thread +void camera_process_rear(MultiCameraState *s, CameraState *c, int cnt) { + if (cnt % 100 == 3) { + const CameraBuf *b = &c->buf; + create_thumbnail(s, c, (uint8_t*)b->cur_rgb_buf->addr); + } +} + +void cameras_run(MultiCameraState *s) { + std::thread t = start_process_thread(s, "processing", &s->rear, camera_process_rear); + set_thread_name("frame_streaming"); + run_frame_stream(s); + cameras_close(s); + t.join(); +} diff --git a/selfdrive/camerad/cameras/camera_frame_stream.h b/selfdrive/camerad/cameras/camera_frame_stream.h new file mode 100644 index 00000000000000..5d6f71b875b00c --- /dev/null +++ b/selfdrive/camerad/cameras/camera_frame_stream.h @@ -0,0 +1,43 @@ +#pragma once + +#include + +#define CL_USE_DEPRECATED_OPENCL_1_2_APIS +#ifdef __APPLE__ +#include +#else +#include +#endif + +#include "camera_common.h" + +#define FRAME_BUF_COUNT 16 + +typedef struct CameraState { + int camera_id; + CameraInfo ci; + + int fps; + float digital_gain; + float cur_gain_frac; + + mat3 transform; + + CameraBuf buf; +} CameraState; + +typedef struct MultiCameraState { + int ispif_fd; + + CameraState rear; + CameraState front; + + SubMaster *sm; + PubMaster *pm; +} MultiCameraState; + +void cameras_init(MultiCameraState *s, cl_device_id device_id, cl_context ctx); +void cameras_open(MultiCameraState *s); +void cameras_run(MultiCameraState *s); +void cameras_close(MultiCameraState *s); +void camera_autoexposure(CameraState *s, float grey_frac); diff --git a/selfdrive/camerad/cameras/camera_qcom.cc b/selfdrive/camerad/cameras/camera_qcom.cc new file mode 100644 index 00000000000000..451829ec482372 --- /dev/null +++ b/selfdrive/camerad/cameras/camera_qcom.cc @@ -0,0 +1,2273 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include "msmb_isp.h" +#include "msmb_ispif.h" +#include "msmb_camera.h" +#include "msm_cam_sensor.h" + +#include "common/util.h" +#include "common/timing.h" +#include "common/swaglog.h" +#include "common/params.h" +#include "clutil.h" + +#include "cereal/gen/cpp/log.capnp.h" + +#include "sensor_i2c.h" + +#include "camera_qcom.h" + + +extern volatile sig_atomic_t do_exit; + +// global var for AE/AF ops +std::atomic rear_exp{{0}}; +std::atomic front_exp{{0}}; + +CameraInfo cameras_supported[CAMERA_ID_MAX] = { + [CAMERA_ID_IMX298] = { + .frame_width = 2328, + .frame_height = 1748, + .frame_stride = 2912, + .bayer = true, + .bayer_flip = 0, + .hdr = true + }, + [CAMERA_ID_IMX179] = { + .frame_width = 3280, + .frame_height = 2464, + .frame_stride = 4104, + .bayer = true, + .bayer_flip = 0, + .hdr = false + }, + [CAMERA_ID_S5K3P8SP] = { + .frame_width = 2304, + .frame_height = 1728, + .frame_stride = 2880, + .bayer = true, + .bayer_flip = 1, + .hdr = false + }, + [CAMERA_ID_OV8865] = { + .frame_width = 1632, + .frame_height = 1224, + .frame_stride = 2040, // seems right + .bayer = true, + .bayer_flip = 3, + .hdr = false + }, + // this exists to get the kernel to build for the LeEco in release + [CAMERA_ID_IMX298_FLIPPED] = { + .frame_width = 2328, + .frame_height = 1748, + .frame_stride = 2912, + .bayer = true, + .bayer_flip = 3, + .hdr = true + }, + [CAMERA_ID_OV10640] = { + .frame_width = 1280, + .frame_height = 1080, + .frame_stride = 2040, + .bayer = true, + .bayer_flip = 0, + .hdr = true + }, +}; + +static void camera_release_buffer(void* cookie, int buf_idx) { + CameraState *s = (CameraState *)cookie; + // printf("camera_release_buffer %d\n", buf_idx); + s->ss[0].qbuf_info[buf_idx].dirty_buf = 1; + ioctl(s->isp_fd, VIDIOC_MSM_ISP_ENQUEUE_BUF, &s->ss[0].qbuf_info[buf_idx]); +} + +static void camera_init(CameraState *s, int camera_id, int camera_num, + uint32_t pixel_clock, uint32_t line_length_pclk, + unsigned int max_gain, unsigned int fps, cl_device_id device_id, cl_context ctx) { + s->camera_num = camera_num; + s->camera_id = camera_id; + + assert(camera_id < ARRAYSIZE(cameras_supported)); + s->ci = cameras_supported[camera_id]; + assert(s->ci.frame_width != 0); + + s->pixel_clock = pixel_clock; + s->line_length_pclk = line_length_pclk; + s->max_gain = max_gain; + s->fps = fps; + + s->self_recover = 0; + + s->buf.init(device_id, ctx, s, FRAME_BUF_COUNT, "frame", camera_release_buffer); + + pthread_mutex_init(&s->frame_info_lock, NULL); +} + + +int sensor_write_regs(CameraState *s, struct msm_camera_i2c_reg_array* arr, size_t size, msm_camera_i2c_data_type data_type) { + struct msm_camera_i2c_reg_setting out_settings = { + .reg_setting = arr, + .size = (uint16_t)size, + .addr_type = MSM_CAMERA_I2C_WORD_ADDR, + .data_type = data_type, + .delay = 0, + }; + struct sensorb_cfg_data cfg_data = {0}; + cfg_data.cfgtype = CFG_WRITE_I2C_ARRAY; + cfg_data.cfg.setting = &out_settings; + return ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &cfg_data); +} + +static int imx298_apply_exposure(CameraState *s, int gain, int integ_lines, int frame_length) { + int err; + + int analog_gain = std::min(gain, 448); + + if (gain > 448) { + s->digital_gain = (512.0/(512-(gain))) / 8.0; + } else { + s->digital_gain = 1.0; + } + + //printf("%5d/%5d %5d %f\n", s->cur_integ_lines, s->cur_frame_length, analog_gain, s->digital_gain); + + struct msm_camera_i2c_reg_array reg_array[] = { + // REG_HOLD + {0x104,0x1,0}, + {0x3002,0x0,0}, // long autoexposure off + + // FRM_LENGTH + {0x340, (uint16_t)(frame_length >> 8), 0}, {0x341, (uint16_t)(frame_length & 0xff), 0}, + // INTEG_TIME aka coarse_int_time_addr aka shutter speed + {0x202, (uint16_t)(integ_lines >> 8), 0}, {0x203, (uint16_t)(integ_lines & 0xff),0}, + // global_gain_addr + // if you assume 1x gain is 32, 448 is 14x gain, aka 2^14=16384 + {0x204, (uint16_t)(analog_gain >> 8), 0}, {0x205, (uint16_t)(analog_gain & 0xff),0}, + + // digital gain for colors: gain_greenR, gain_red, gain_blue, gain_greenB + /*{0x20e, digital_gain_gr >> 8, 0}, {0x20f,digital_gain_gr & 0xFF,0}, + {0x210, digital_gain_r >> 8, 0}, {0x211,digital_gain_r & 0xFF,0}, + {0x212, digital_gain_b >> 8, 0}, {0x213,digital_gain_b & 0xFF,0}, + {0x214, digital_gain_gb >> 8, 0}, {0x215,digital_gain_gb & 0xFF,0},*/ + + // REG_HOLD + {0x104,0x0,0}, + }; + + err = sensor_write_regs(s, reg_array, ARRAYSIZE(reg_array), MSM_CAMERA_I2C_BYTE_DATA); + if (err != 0) { + LOGE("apply_exposure err %d", err); + } + return err; +} + +static int ov8865_apply_exposure(CameraState *s, int gain, int integ_lines, int frame_length) { + //printf("front camera: %d %d %d\n", gain, integ_lines, frame_length); + int err, coarse_gain_bitmap, fine_gain_bitmap; + + // get bitmaps from iso + static const int gains[] = {0, 100, 200, 400, 800}; + int i; + for (i = 1; i < ARRAYSIZE(gains); i++) { + if (gain >= gains[i - 1] && gain < gains[i]) + break; + } + int coarse_gain = i - 1; + float fine_gain = (gain - gains[coarse_gain])/(float)(gains[coarse_gain+1]-gains[coarse_gain]); + coarse_gain_bitmap = (1 << coarse_gain) - 1; + fine_gain_bitmap = ((int)(16*fine_gain) << 3) + 128; // 7th is always 1, 0-2nd are always 0 + + integ_lines *= 16; // The exposure value in reg is in 16ths of a line + + struct msm_camera_i2c_reg_array reg_array[] = { + //{0x104,0x1,0}, + + // FRM_LENGTH + {0x380e, (uint16_t)(frame_length >> 8), 0}, {0x380f, (uint16_t)(frame_length & 0xff), 0}, + // AEC EXPO + {0x3500, (uint16_t)(integ_lines >> 16), 0}, {0x3501, (uint16_t)(integ_lines >> 8), 0}, {0x3502, (uint16_t)(integ_lines & 0xff),0}, + // AEC MANUAL + {0x3503, 0x4, 0}, + // AEC GAIN + {0x3508, (uint16_t)(coarse_gain_bitmap), 0}, {0x3509, (uint16_t)(fine_gain_bitmap), 0}, + + //{0x104,0x0,0}, + }; + err = sensor_write_regs(s, reg_array, ARRAYSIZE(reg_array), MSM_CAMERA_I2C_BYTE_DATA); + if (err != 0) { + LOGE("apply_exposure err %d", err); + } + return err; +} + +static int imx179_s5k3p8sp_apply_exposure(CameraState *s, int gain, int integ_lines, int frame_length) { + //printf("front camera: %d %d %d\n", gain, integ_lines, frame_length); + int err; + + struct msm_camera_i2c_reg_array reg_array[] = { + {0x104,0x1,0}, + + // FRM_LENGTH + {0x340, (uint16_t)(frame_length >> 8), 0}, {0x341, (uint16_t)(frame_length & 0xff), 0}, + // coarse_int_time + {0x202, (uint16_t)(integ_lines >> 8), 0}, {0x203, (uint16_t)(integ_lines & 0xff),0}, + // global_gain + {0x204, (uint16_t)(gain >> 8), 0}, {0x205, (uint16_t)(gain & 0xff),0}, + + {0x104,0x0,0}, + }; + err = sensor_write_regs(s, reg_array, ARRAYSIZE(reg_array), MSM_CAMERA_I2C_BYTE_DATA); + if (err != 0) { + LOGE("apply_exposure err %d", err); + } + return err; +} + +cl_program build_conv_program(cl_device_id device_id, cl_context context, int image_w, int image_h, int filter_size) { + char args[4096]; + snprintf(args, sizeof(args), + "-cl-fast-relaxed-math -cl-denorms-are-zero " + "-DIMAGE_W=%d -DIMAGE_H=%d -DFLIP_RB=%d " + "-DFILTER_SIZE=%d -DHALF_FILTER_SIZE=%d -DTWICE_HALF_FILTER_SIZE=%d -DHALF_FILTER_SIZE_IMAGE_W=%d", + image_w, image_h, 1, + filter_size, filter_size/2, (filter_size/2)*2, (filter_size/2)*image_w); + return cl_program_from_file(context, device_id, "imgproc/conv.cl", args); +} + +void cameras_init(MultiCameraState *s, cl_device_id device_id, cl_context ctx) { + char project_name[1024] = {0}; + property_get("ro.boot.project_name", project_name, ""); + + char product_name[1024] = {0}; + property_get("ro.product.name", product_name, ""); + + if (strlen(project_name) == 0) { + LOGD("LePro 3 op system detected"); + s->device = DEVICE_LP3; + + // sensor is flipped in LP3 + // IMAGE_ORIENT = 3 + init_array_imx298[0].reg_data = 3; + cameras_supported[CAMERA_ID_IMX298].bayer_flip = 3; + } else if (strcmp(product_name, "OnePlus3") == 0 && strcmp(project_name, "15811") != 0) { + // no more OP3 support + s->device = DEVICE_OP3; + assert(false); + } else if (strcmp(product_name, "OnePlus3") == 0 && strcmp(project_name, "15811") == 0) { + // only OP3T support + s->device = DEVICE_OP3T; + } else { + assert(false); + } + + // 0 = ISO 100 + // 256 = ISO 200 + // 384 = ISO 400 + // 448 = ISO 800 + // 480 = ISO 1600 + // 496 = ISO 3200 + // 504 = ISO 6400, 8x digital gain + // 508 = ISO 12800, 16x digital gain + // 510 = ISO 25600, 32x digital gain + + camera_init(&s->rear, CAMERA_ID_IMX298, 0, + /*pixel_clock=*/600000000, /*line_length_pclk=*/5536, + /*max_gain=*/510, //0 (ISO 100)- 448 (ISO 800, max analog gain) - 511 (super noisy) +#ifdef HIGH_FPS + /*fps*/ 60, +#else + /*fps*/ 20, +#endif + device_id, ctx); + s->rear.apply_exposure = imx298_apply_exposure; + + if (s->device == DEVICE_OP3T) { + camera_init(&s->front, CAMERA_ID_S5K3P8SP, 1, + /*pixel_clock=*/560000000, /*line_length_pclk=*/5120, + /*max_gain=*/510, 10, device_id, ctx); + s->front.apply_exposure = imx179_s5k3p8sp_apply_exposure; + } else if (s->device == DEVICE_LP3) { + camera_init(&s->front, CAMERA_ID_OV8865, 1, + /*pixel_clock=*/72000000, /*line_length_pclk=*/1602, + /*max_gain=*/510, 10, device_id, ctx); + s->front.apply_exposure = ov8865_apply_exposure; + } else { + camera_init(&s->front, CAMERA_ID_IMX179, 1, + /*pixel_clock=*/251200000, /*line_length_pclk=*/3440, + /*max_gain=*/224, 20, device_id, ctx); + s->front.apply_exposure = imx179_s5k3p8sp_apply_exposure; + } + + // assume the device is upside-down (not anymore) + s->rear.transform = (mat3){{ + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0, + }}; + + // probably wrong + s->front.transform = (mat3){{ + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0, + }}; + + s->rear.device = s->device; + s->front.device = s->device; + + s->sm_front = new SubMaster({"driverState"}); + s->pm = new PubMaster({"frame", "frontFrame", "thumbnail"}); + + for (int i = 0; i < FRAME_BUF_COUNT; i++) { + // TODO: make lengths correct + s->focus_bufs[i] = visionbuf_allocate(0xb80); + s->stats_bufs[i] = visionbuf_allocate(0xb80); + } + const int width = s->rear.buf.rgb_width/NUM_SEGMENTS_X; + const int height = s->rear.buf.rgb_height/NUM_SEGMENTS_Y; + s->prg_rgb_laplacian = build_conv_program(device_id, ctx, width, height, 3); + s->krnl_rgb_laplacian = CL_CHECK_ERR(clCreateKernel(s->prg_rgb_laplacian, "rgb2gray_conv2d", &err)); + // TODO: Removed CL_MEM_SVM_FINE_GRAIN_BUFFER, confirm it doesn't matter + s->rgb_conv_roi_cl = CL_CHECK_ERR(clCreateBuffer(ctx, CL_MEM_READ_WRITE, + width * height * 3 * sizeof(uint8_t), NULL, &err)); + s->rgb_conv_result_cl = CL_CHECK_ERR(clCreateBuffer(ctx, CL_MEM_READ_WRITE, + width * height * sizeof(int16_t), NULL, &err)); + s->rgb_conv_filter_cl = CL_CHECK_ERR(clCreateBuffer(ctx, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, + 9 * sizeof(int16_t), (void*)&lapl_conv_krnl, &err)); + + std::fill_n(s->lapres, std::size(s->lapres), 16160); +} + +static void set_exposure(CameraState *s, float exposure_frac, float gain_frac) { + int err = 0; + + unsigned int frame_length = s->pixel_clock / s->line_length_pclk / s->fps; + + unsigned int gain = s->cur_gain; + unsigned int integ_lines = s->cur_integ_lines; + + if (exposure_frac >= 0) { + exposure_frac = std::clamp(exposure_frac, 2.0f / frame_length, 1.0f); + integ_lines = frame_length * exposure_frac; + + // See page 79 of the datasheet, this is the max allowed (-1 for phase adjust) + integ_lines = std::min(integ_lines, frame_length-11); + } + + if (gain_frac >= 0) { + // ISO200 is minimum gain + gain_frac = std::clamp(gain_frac, 1.0f/64, 1.0f); + + // linearize gain response + // TODO: will be wrong for front camera + // 0.125 -> 448 + // 0.25 -> 480 + // 0.5 -> 496 + // 1.0 -> 504 + // 512 - 512/(128*gain_frac) + gain = (s->max_gain/510) * (512 - 512/(256*gain_frac)); + } + + if (gain != s->cur_gain + || integ_lines != s->cur_integ_lines + || frame_length != s->cur_frame_length) { + + if (s->apply_exposure == ov8865_apply_exposure) { + gain = 800 * gain_frac; // ISO + err = s->apply_exposure(s, gain, integ_lines, frame_length); + } else if (s->apply_exposure) { + err = s->apply_exposure(s, gain, integ_lines, frame_length); + } + + if (err == 0) { + pthread_mutex_lock(&s->frame_info_lock); + s->cur_gain = gain; + s->cur_integ_lines = integ_lines; + s->cur_frame_length = frame_length; + pthread_mutex_unlock(&s->frame_info_lock); + } + } + + if (err == 0) { + s->cur_exposure_frac = exposure_frac; + pthread_mutex_lock(&s->frame_info_lock); + s->cur_gain_frac = gain_frac; + pthread_mutex_unlock(&s->frame_info_lock); + } + + //LOGD("set exposure: %f %f - %d", exposure_frac, gain_frac, err); +} + +static void do_autoexposure(CameraState *s, float grey_frac) { + const float target_grey = 0.3; + if (s->apply_exposure == ov8865_apply_exposure) { + // gain limits downstream + const float gain_frac_min = 0.015625; + const float gain_frac_max = 1.0; + // exposure time limits + unsigned int frame_length = s->pixel_clock / s->line_length_pclk / s->fps; + const unsigned int exposure_time_min = 16; + const unsigned int exposure_time_max = frame_length - 11; // copied from set_exposure() + + float cur_gain_frac = s->cur_gain_frac; + float exposure_factor = pow(1.05, (target_grey - grey_frac) / 0.05); + if (cur_gain_frac > 0.125 && exposure_factor < 1) { + cur_gain_frac *= exposure_factor; + } else if (s->cur_integ_lines * exposure_factor <= exposure_time_max && s->cur_integ_lines * exposure_factor >= exposure_time_min) { // adjust exposure time first + s->cur_exposure_frac *= exposure_factor; + } else if (cur_gain_frac * exposure_factor <= gain_frac_max && cur_gain_frac * exposure_factor >= gain_frac_min) { + cur_gain_frac *= exposure_factor; + } + pthread_mutex_lock(&s->frame_info_lock); + s->cur_gain_frac = cur_gain_frac; + pthread_mutex_unlock(&s->frame_info_lock); + + set_exposure(s, s->cur_exposure_frac, cur_gain_frac); + + } else { // keep the old for others + float new_exposure = s->cur_exposure_frac; + new_exposure *= pow(1.05, (target_grey - grey_frac) / 0.05 ); + //LOGD("diff %f: %f to %f", target_grey - grey_frac, s->cur_exposure_frac, new_exposure); + + float new_gain = s->cur_gain_frac; + if (new_exposure < 0.10) { + new_gain *= 0.95; + } else if (new_exposure > 0.40) { + new_gain *= 1.05; + } + + set_exposure(s, new_exposure, new_gain); + } +} + +static uint8_t* get_eeprom(int eeprom_fd, size_t *out_len) { + int err; + + struct msm_eeprom_cfg_data cfg = {}; + cfg.cfgtype = CFG_EEPROM_GET_CAL_DATA; + err = ioctl(eeprom_fd, VIDIOC_MSM_EEPROM_CFG, &cfg); + assert(err >= 0); + + uint32_t num_bytes = cfg.cfg.get_data.num_bytes; + assert(num_bytes > 100); + + uint8_t* buffer = (uint8_t*)malloc(num_bytes); + assert(buffer); + memset(buffer, 0, num_bytes); + + cfg.cfgtype = CFG_EEPROM_READ_CAL_DATA; + cfg.cfg.read_data.num_bytes = num_bytes; + cfg.cfg.read_data.dbuffer = buffer; + err = ioctl(eeprom_fd, VIDIOC_MSM_EEPROM_CFG, &cfg); + assert(err >= 0); + + *out_len = num_bytes; + return buffer; +} + +static void imx298_ois_calibration(int ois_fd, uint8_t* eeprom) { + int err; + + const int ois_registers[][2] = { + // == SET_FADJ_PARAM() == (factory adjustment) + + // Set Hall Current DAC + {0x8230, *(uint16_t*)(eeprom+0x102)}, //_P_30_ADC_CH0 (CURDAT) + + // Set Hall PreAmp Offset + {0x8231, *(uint16_t*)(eeprom+0x104)}, //_P_31_ADC_CH1 (HALOFS_X) + {0x8232, *(uint16_t*)(eeprom+0x106)}, //_P_32_ADC_CH2 (HALOFS_Y) + + // Set Hall-X/Y PostAmp Offset + {0x841e, *(uint16_t*)(eeprom+0x108)}, //_M_X_H_ofs + {0x849e, *(uint16_t*)(eeprom+0x10a)}, //_M_Y_H_ofs + + // Set Residual Offset + {0x8239, *(uint16_t*)(eeprom+0x10c)}, //_P_39_Ch3_VAL_1 (PSTXOF) + {0x823b, *(uint16_t*)(eeprom+0x10e)}, //_P_3B_Ch3_VAL_3 (PSTYOF) + + // DIGITAL GYRO OFFSET + {0x8406, *(uint16_t*)(eeprom+0x110)}, //_M_Kgx00 + {0x8486, *(uint16_t*)(eeprom+0x112)}, //_M_Kgy00 + {0x846a, *(uint16_t*)(eeprom+0x120)}, //_M_TMP_X_ + {0x846b, *(uint16_t*)(eeprom+0x122)}, //_M_TMP_Y_ + + // HALLSENSE + // Set Hall Gain + {0x8446, *(uint16_t*)(eeprom+0x114)}, //_M_KgxHG + {0x84c6, *(uint16_t*)(eeprom+0x116)}, //_M_KgyHG + // Set Cross Talk Canceller + {0x8470, *(uint16_t*)(eeprom+0x124)}, //_M_KgxH0 + {0x8472, *(uint16_t*)(eeprom+0x126)}, //_M_KgyH0 + + // LOOPGAIN + {0x840f, *(uint16_t*)(eeprom+0x118)}, //_M_KgxG + {0x848f, *(uint16_t*)(eeprom+0x11a)}, //_M_KgyG + + // Position Servo ON ( OIS OFF ) + {0x847f, 0x0c0c}, //_M_EQCTL + }; + + + struct msm_ois_cfg_data cfg = {0}; + struct msm_camera_i2c_seq_reg_array ois_reg_settings[ARRAYSIZE(ois_registers)] = {{0}}; + for (int i=0; i> 8) & 0xff; + ois_reg_settings[i].reg_data_size = 2; + } + struct msm_camera_i2c_seq_reg_setting ois_reg_setting = { + .reg_setting = &ois_reg_settings[0], + .size = ARRAYSIZE(ois_reg_settings), + .addr_type = MSM_CAMERA_I2C_WORD_ADDR, + .delay = 0, + }; + cfg.cfgtype = CFG_OIS_I2C_WRITE_SEQ_TABLE; + cfg.cfg.settings = &ois_reg_setting; + err = ioctl(ois_fd, VIDIOC_MSM_OIS_CFG, &cfg); + LOG("ois reg calibration: %d", err); +} + + + + +static void sensors_init(MultiCameraState *s) { + int err; + + unique_fd sensorinit_fd; + if (s->device == DEVICE_LP3) { + sensorinit_fd = open("/dev/v4l-subdev11", O_RDWR | O_NONBLOCK); + } else { + sensorinit_fd = open("/dev/v4l-subdev12", O_RDWR | O_NONBLOCK); + } + assert(sensorinit_fd >= 0); + + struct sensor_init_cfg_data sensor_init_cfg = {}; + + // init rear sensor + + struct msm_camera_sensor_slave_info slave_info = {0}; + if (s->device == DEVICE_LP3) { + slave_info = (struct msm_camera_sensor_slave_info){ + .sensor_name = "imx298", + .eeprom_name = "sony_imx298", + .actuator_name = "dw9800w", + .ois_name = "", + .flash_name = "pmic", + .camera_id = CAMERA_0, + .slave_addr = 32, + .i2c_freq_mode = I2C_FAST_MODE, + .addr_type = MSM_CAMERA_I2C_WORD_ADDR, + .sensor_id_info = { + .sensor_id_reg_addr = 22, + .sensor_id = 664, + .sensor_id_mask = 0, + .module_id = 9, + .vcm_id = 6, + }, + .power_setting_array = { + .power_setting_a = { + { + .seq_type = SENSOR_GPIO, + .seq_val = 0, + .config_val = 0, + .delay = 1, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 2, + .config_val = 0, + .delay = 0, + },{ + .seq_type = SENSOR_GPIO, + .seq_val = 5, + .config_val = 2, + .delay = 0, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 1, + .config_val = 0, + .delay = 0, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 3, + .config_val = 0, + .delay = 1, + },{ + .seq_type = SENSOR_CLK, + .seq_val = 0, + .config_val = 24000000, + .delay = 1, + },{ + .seq_type = SENSOR_GPIO, + .seq_val = 0, + .config_val = 2, + .delay = 10, + }, + }, + .size = 7, + .power_down_setting_a = { + { + .seq_type = SENSOR_CLK, + .seq_val = 0, + .config_val = 0, + .delay = 1, + },{ + .seq_type = SENSOR_GPIO, + .seq_val = 0, + .config_val = 0, + .delay = 1, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 1, + .config_val = 0, + .delay = 0, + },{ + .seq_type = SENSOR_GPIO, + .seq_val = 5, + .config_val = 0, + .delay = 0, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 2, + .config_val = 0, + .delay = 0, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 3, + .config_val = 0, + .delay = 1, + }, + }, + .size_down = 6, + }, + .is_init_params_valid = 0, + .sensor_init_params = { + .modes_supported = 1, + .position = BACK_CAMERA_B, + .sensor_mount_angle = 90, + }, + .output_format = MSM_SENSOR_BAYER, + }; + } else { + slave_info = (struct msm_camera_sensor_slave_info){ + .sensor_name = "imx298", + .eeprom_name = "sony_imx298", + .actuator_name = "rohm_bu63165gwl", + .ois_name = "rohm_bu63165gwl", + .camera_id = CAMERA_0, + .slave_addr = 52, + .i2c_freq_mode = I2C_CUSTOM_MODE, + .addr_type = MSM_CAMERA_I2C_WORD_ADDR, + .sensor_id_info = { + .sensor_id_reg_addr = 22, + .sensor_id = 664, + .sensor_id_mask = 0, + }, + .power_setting_array = { + .power_setting_a = { + { + .seq_type = SENSOR_GPIO, + .seq_val = 0, + .config_val = 0, + .delay = 2, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 2, + .config_val = 0, + .delay = 2, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 0, + .config_val = 0, + .delay = 2, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 1, + .config_val = 0, + .delay = 2, + },{ + .seq_type = SENSOR_GPIO, + .seq_val = 6, + .config_val = 2, + .delay = 0, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 3, + .config_val = 0, + .delay = 5, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 4, + .config_val = 0, + .delay = 5, + },{ + .seq_type = SENSOR_CLK, + .seq_val = 0, + .config_val = 24000000, + .delay = 2, + },{ + .seq_type = SENSOR_GPIO, + .seq_val = 0, + .config_val = 2, + .delay = 2, + }, + }, + .size = 9, + .power_down_setting_a = { + { + .seq_type = SENSOR_GPIO, + .seq_val = 0, + .config_val = 0, + .delay = 10, + },{ + .seq_type = SENSOR_CLK, + .seq_val = 0, + .config_val = 0, + .delay = 1, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 4, + .config_val = 0, + .delay = 0, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 3, + .config_val = 0, + .delay = 1, + },{ + .seq_type = SENSOR_GPIO, + .seq_val = 6, + .config_val = 0, + .delay = 0, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 1, + .config_val = 0, + .delay = 0, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 0, + .config_val = 0, + .delay = 0, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 2, + .config_val = 0, + .delay = 0, + }, + }, + .size_down = 8, + }, + .is_init_params_valid = 0, + .sensor_init_params = { + .modes_supported = 1, + .position = BACK_CAMERA_B, + .sensor_mount_angle = 360, + }, + .output_format = MSM_SENSOR_BAYER, + }; + } + slave_info.power_setting_array.power_setting = + (struct msm_sensor_power_setting *)&slave_info.power_setting_array.power_setting_a[0]; + slave_info.power_setting_array.power_down_setting = + (struct msm_sensor_power_setting *)&slave_info.power_setting_array.power_down_setting_a[0]; + sensor_init_cfg.cfgtype = CFG_SINIT_PROBE; + sensor_init_cfg.cfg.setting = &slave_info; + err = ioctl(sensorinit_fd, VIDIOC_MSM_SENSOR_INIT_CFG, &sensor_init_cfg); + LOG("sensor init cfg (rear): %d", err); + assert(err >= 0); + + + struct msm_camera_sensor_slave_info slave_info2 = {0}; + if (s->device == DEVICE_LP3) { + slave_info2 = (struct msm_camera_sensor_slave_info){ + .sensor_name = "ov8865_sunny", + .eeprom_name = "ov8865_plus", + .actuator_name = "", + .ois_name = "", + .flash_name = "", + .camera_id = CAMERA_2, + .slave_addr = 108, + .i2c_freq_mode = I2C_FAST_MODE, + .addr_type = MSM_CAMERA_I2C_WORD_ADDR, + .sensor_id_info = { + .sensor_id_reg_addr = 12299, + .sensor_id = 34917, + .sensor_id_mask = 0, + .module_id = 2, + .vcm_id = 0, + }, + .power_setting_array = { + .power_setting_a = { + { + .seq_type = SENSOR_GPIO, + .seq_val = 0, + .config_val = 0, + .delay = 5, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 1, + .config_val = 0, + .delay = 0, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 2, + .config_val = 0, + .delay = 0, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 0, + .config_val = 0, + .delay = 0, + },{ + .seq_type = SENSOR_CLK, + .seq_val = 0, + .config_val = 24000000, + .delay = 1, + },{ + .seq_type = SENSOR_GPIO, + .seq_val = 0, + .config_val = 2, + .delay = 1, + }, + }, + .size = 6, + .power_down_setting_a = { + { + .seq_type = SENSOR_GPIO, + .seq_val = 0, + .config_val = 0, + .delay = 5, + },{ + .seq_type = SENSOR_CLK, + .seq_val = 0, + .config_val = 0, + .delay = 1, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 0, + .config_val = 0, + .delay = 0, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 1, + .config_val = 0, + .delay = 0, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 2, + .config_val = 0, + .delay = 1, + }, + }, + .size_down = 5, + }, + .is_init_params_valid = 0, + .sensor_init_params = { + .modes_supported = 1, + .position = FRONT_CAMERA_B, + .sensor_mount_angle = 270, + }, + .output_format = MSM_SENSOR_BAYER, + }; + } else if (s->front.camera_id == CAMERA_ID_S5K3P8SP) { + // init front camera + slave_info2 = (struct msm_camera_sensor_slave_info){ + .sensor_name = "s5k3p8sp", + .eeprom_name = "s5k3p8sp_m24c64s", + .actuator_name = "", + .ois_name = "", + .camera_id = CAMERA_1, + .slave_addr = 32, + .i2c_freq_mode = I2C_FAST_MODE, + .addr_type = MSM_CAMERA_I2C_WORD_ADDR, + .sensor_id_info = { + .sensor_id_reg_addr = 0, + .sensor_id = 12552, + .sensor_id_mask = 0, + }, + .power_setting_array = { + .power_setting_a = { + { + .seq_type = SENSOR_GPIO, + .seq_val = 0, + .config_val = 0, + .delay = 1, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 2, + .config_val = 0, + .delay = 1, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 1, + .config_val = 0, + .delay = 1, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 0, + .config_val = 0, + .delay = 1, + },{ + .seq_type = SENSOR_CLK, + .seq_val = 0, + .config_val = 24000000, + .delay = 1, + },{ + .seq_type = SENSOR_GPIO, + .seq_val = 0, + .config_val = 2, + .delay = 1, + }, + }, + .size = 6, + .power_down_setting_a = { + { + .seq_type = SENSOR_CLK, + .seq_val = 0, + .config_val = 0, + .delay = 1, + },{ + .seq_type = SENSOR_GPIO, + .seq_val = 0, + .config_val = 0, + .delay = 1, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 0, + .config_val = 0, + .delay = 1, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 1, + .config_val = 0, + .delay = 1, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 2, + .config_val = 0, + .delay = 1, + }, + }, + .size_down = 5, + }, + .is_init_params_valid = 0, + .sensor_init_params = { + .modes_supported = 1, + .position = FRONT_CAMERA_B, + .sensor_mount_angle = 270, + }, + .output_format = MSM_SENSOR_BAYER, + }; + } else { + // init front camera + slave_info2 = (struct msm_camera_sensor_slave_info){ + .sensor_name = "imx179", + .eeprom_name = "sony_imx179", + .actuator_name = "", + .ois_name = "", + .camera_id = CAMERA_1, + .slave_addr = 32, + .i2c_freq_mode = I2C_FAST_MODE, + .addr_type = MSM_CAMERA_I2C_WORD_ADDR, + .sensor_id_info = { + .sensor_id_reg_addr = 2, + .sensor_id = 377, + .sensor_id_mask = 4095, + }, + .power_setting_array = { + .power_setting_a = { + { + .seq_type = SENSOR_VREG, + .seq_val = 2, + .config_val = 0, + .delay = 0, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 1, + .config_val = 0, + .delay = 0, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 0, + .config_val = 0, + .delay = 0, + },{ + .seq_type = SENSOR_GPIO, + .seq_val = 0, + .config_val = 2, + .delay = 0, + },{ + .seq_type = SENSOR_CLK, + .seq_val = 0, + .config_val = 24000000, + .delay = 0, + }, + }, + .size = 5, + .power_down_setting_a = { + { + .seq_type = SENSOR_CLK, + .seq_val = 0, + .config_val = 0, + .delay = 0, + },{ + .seq_type = SENSOR_GPIO, + .seq_val = 0, + .config_val = 0, + .delay = 1, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 0, + .config_val = 0, + .delay = 2, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 1, + .config_val = 0, + .delay = 0, + },{ + .seq_type = SENSOR_VREG, + .seq_val = 2, + .config_val = 0, + .delay = 0, + }, + }, + .size_down = 5, + }, + .is_init_params_valid = 0, + .sensor_init_params = { + .modes_supported = 1, + .position = FRONT_CAMERA_B, + .sensor_mount_angle = 270, + }, + .output_format = MSM_SENSOR_BAYER, + }; + } + slave_info2.power_setting_array.power_setting = + (struct msm_sensor_power_setting *)&slave_info2.power_setting_array.power_setting_a[0]; + slave_info2.power_setting_array.power_down_setting = + (struct msm_sensor_power_setting *)&slave_info2.power_setting_array.power_down_setting_a[0]; + sensor_init_cfg.cfgtype = CFG_SINIT_PROBE; + sensor_init_cfg.cfg.setting = &slave_info2; + err = ioctl(sensorinit_fd, VIDIOC_MSM_SENSOR_INIT_CFG, &sensor_init_cfg); + LOG("sensor init cfg (front): %d", err); + assert(err >= 0); +} + +static void camera_open(CameraState *s, bool rear) { + int err; + + struct sensorb_cfg_data sensorb_cfg_data = {}; + struct csid_cfg_data csid_cfg_data = {}; + struct csiphy_cfg_data csiphy_cfg_data = {}; + struct msm_camera_csiphy_params csiphy_params = {}; + struct msm_camera_csid_params csid_params = {}; + struct msm_vfe_input_cfg input_cfg = {}; + struct msm_vfe_axi_stream_update_cmd update_cmd = {}; + struct v4l2_event_subscription sub = {}; + + struct msm_actuator_cfg_data actuator_cfg_data = {}; + struct msm_ois_cfg_data ois_cfg_data = {}; + + // open devices + const char *sensor_dev; + if (rear) { + s->csid_fd = open("/dev/v4l-subdev3", O_RDWR | O_NONBLOCK); + assert(s->csid_fd >= 0); + s->csiphy_fd = open("/dev/v4l-subdev0", O_RDWR | O_NONBLOCK); + assert(s->csiphy_fd >= 0); + if (s->device == DEVICE_LP3) { + sensor_dev = "/dev/v4l-subdev17"; + } else { + sensor_dev = "/dev/v4l-subdev18"; + } + if (s->device == DEVICE_LP3) { + s->isp_fd = open("/dev/v4l-subdev13", O_RDWR | O_NONBLOCK); + } else { + s->isp_fd = open("/dev/v4l-subdev14", O_RDWR | O_NONBLOCK); + } + assert(s->isp_fd >= 0); + s->eeprom_fd = open("/dev/v4l-subdev8", O_RDWR | O_NONBLOCK); + assert(s->eeprom_fd >= 0); + + s->actuator_fd = open("/dev/v4l-subdev7", O_RDWR | O_NONBLOCK); + assert(s->actuator_fd >= 0); + + if (s->device != DEVICE_LP3) { + s->ois_fd = open("/dev/v4l-subdev10", O_RDWR | O_NONBLOCK); + assert(s->ois_fd >= 0); + } + } else { + s->csid_fd = open("/dev/v4l-subdev5", O_RDWR | O_NONBLOCK); + assert(s->csid_fd >= 0); + s->csiphy_fd = open("/dev/v4l-subdev2", O_RDWR | O_NONBLOCK); + assert(s->csiphy_fd >= 0); + if (s->device == DEVICE_LP3) { + sensor_dev = "/dev/v4l-subdev18"; + } else { + sensor_dev = "/dev/v4l-subdev19"; + } + if (s->device == DEVICE_LP3) { + s->isp_fd = open("/dev/v4l-subdev14", O_RDWR | O_NONBLOCK); + } else { + s->isp_fd = open("/dev/v4l-subdev15", O_RDWR | O_NONBLOCK); + } + assert(s->isp_fd >= 0); + s->eeprom_fd = open("/dev/v4l-subdev9", O_RDWR | O_NONBLOCK); + assert(s->eeprom_fd >= 0); + } + + // wait for sensor device + // on first startup, these devices aren't present yet + for (int i = 0; i < 10; i++) { + s->sensor_fd = open(sensor_dev, O_RDWR | O_NONBLOCK); + if (s->sensor_fd >= 0) break; + LOGW("waiting for sensors..."); + sleep(1); + } + assert(s->sensor_fd >= 0); + + // *** SHUTDOWN ALL *** + + // CSIPHY: release csiphy + struct msm_camera_csi_lane_params csi_lane_params = {0}; + csi_lane_params.csi_lane_mask = 0x1f; + csiphy_cfg_data.cfg.csi_lane_params = &csi_lane_params; + csiphy_cfg_data.cfgtype = CSIPHY_RELEASE; + err = ioctl(s->csiphy_fd, VIDIOC_MSM_CSIPHY_IO_CFG, &csiphy_cfg_data); + LOG("release csiphy: %d", err); + + // CSID: release csid + csid_cfg_data.cfgtype = CSID_RELEASE; + err = ioctl(s->csid_fd, VIDIOC_MSM_CSID_IO_CFG, &csid_cfg_data); + LOG("release csid: %d", err); + + // SENSOR: send power down + memset(&sensorb_cfg_data, 0, sizeof(sensorb_cfg_data)); + sensorb_cfg_data.cfgtype = CFG_POWER_DOWN; + err = ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &sensorb_cfg_data); + LOG("sensor power down: %d", err); + + if (rear && s->device != DEVICE_LP3) { + // ois powerdown + ois_cfg_data.cfgtype = CFG_OIS_POWERDOWN; + err = ioctl(s->ois_fd, VIDIOC_MSM_OIS_CFG, &ois_cfg_data); + LOG("ois powerdown: %d", err); + } + + // actuator powerdown + actuator_cfg_data.cfgtype = CFG_ACTUATOR_POWERDOWN; + err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data); + LOG("actuator powerdown: %d", err); + + // reset isp + // struct msm_vfe_axi_halt_cmd halt_cmd = { + // .stop_camif = 1, + // .overflow_detected = 1, + // .blocking_halt = 1, + // }; + // err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_AXI_HALT, &halt_cmd); + // printf("axi halt: %d\n", err); + + // struct msm_vfe_axi_reset_cmd reset_cmd = { + // .blocking = 1, + // .frame_id = 1, + // }; + // err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_AXI_RESET, &reset_cmd); + // printf("axi reset: %d\n", err); + + // struct msm_vfe_axi_restart_cmd restart_cmd = { + // .enable_camif = 1, + // }; + // err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_AXI_RESTART, &restart_cmd); + // printf("axi restart: %d\n", err); + + // **** GO GO GO **** + LOG("******************** GO GO GO ************************"); + + s->eeprom = get_eeprom(s->eeprom_fd, &s->eeprom_size); + + // printf("eeprom:\n"); + // for (int i=0; ieeprom_size; i++) { + // printf("%02x", s->eeprom[i]); + // } + // printf("\n"); + + // CSID: init csid + csid_cfg_data.cfgtype = CSID_INIT; + err = ioctl(s->csid_fd, VIDIOC_MSM_CSID_IO_CFG, &csid_cfg_data); + LOG("init csid: %d", err); + + // CSIPHY: init csiphy + memset(&csiphy_cfg_data, 0, sizeof(csiphy_cfg_data)); + csiphy_cfg_data.cfgtype = CSIPHY_INIT; + err = ioctl(s->csiphy_fd, VIDIOC_MSM_CSIPHY_IO_CFG, &csiphy_cfg_data); + LOG("init csiphy: %d", err); + + // SENSOR: stop stream + struct msm_camera_i2c_reg_setting stop_settings = { + .reg_setting = stop_reg_array, + .size = ARRAYSIZE(stop_reg_array), + .addr_type = MSM_CAMERA_I2C_WORD_ADDR, + .data_type = MSM_CAMERA_I2C_BYTE_DATA, + .delay = 0 + }; + sensorb_cfg_data.cfgtype = CFG_SET_STOP_STREAM_SETTING; + sensorb_cfg_data.cfg.setting = &stop_settings; + err = ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &sensorb_cfg_data); + LOG("stop stream: %d", err); + + // SENSOR: send power up + memset(&sensorb_cfg_data, 0, sizeof(sensorb_cfg_data)); + sensorb_cfg_data.cfgtype = CFG_POWER_UP; + err = ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &sensorb_cfg_data); + LOG("sensor power up: %d", err); + + // **** configure the sensor **** + + // SENSOR: send i2c configuration + if (s->camera_id == CAMERA_ID_IMX298) { + err = sensor_write_regs(s, init_array_imx298, ARRAYSIZE(init_array_imx298), MSM_CAMERA_I2C_BYTE_DATA); + } else if (s->camera_id == CAMERA_ID_S5K3P8SP) { + err = sensor_write_regs(s, init_array_s5k3p8sp, ARRAYSIZE(init_array_s5k3p8sp), MSM_CAMERA_I2C_WORD_DATA); + } else if (s->camera_id == CAMERA_ID_IMX179) { + err = sensor_write_regs(s, init_array_imx179, ARRAYSIZE(init_array_imx179), MSM_CAMERA_I2C_BYTE_DATA); + } else if (s->camera_id == CAMERA_ID_OV8865) { + err = sensor_write_regs(s, init_array_ov8865, ARRAYSIZE(init_array_ov8865), MSM_CAMERA_I2C_BYTE_DATA); + } else { + assert(false); + } + LOG("sensor init i2c: %d", err); + + if (rear) { + // init the actuator + actuator_cfg_data.cfgtype = CFG_ACTUATOR_POWERUP; + err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data); + LOG("actuator powerup: %d", err); + + actuator_cfg_data.cfgtype = CFG_ACTUATOR_INIT; + err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data); + LOG("actuator init: %d", err); + + + // no OIS in LP3 + if (s->device != DEVICE_LP3) { + // see sony_imx298_eeprom_format_afdata in libmmcamera_sony_imx298_eeprom.so + const float far_margin = -0.28; + uint16_t macro_dac = *(uint16_t*)(s->eeprom + 0x24); + s->infinity_dac = *(uint16_t*)(s->eeprom + 0x26); + LOG("macro_dac: %d infinity_dac: %d", macro_dac, s->infinity_dac); + + int dac_range = macro_dac - s->infinity_dac; + s->infinity_dac += far_margin * dac_range; + + LOG(" -> macro_dac: %d infinity_dac: %d", macro_dac, s->infinity_dac); + + struct msm_actuator_reg_params_t actuator_reg_params[] = { + { + .reg_write_type = MSM_ACTUATOR_WRITE_DAC, + .hw_mask = 0, + .reg_addr = 240, + .hw_shift = 0, + .data_type = 10, + .addr_type = 4, + .reg_data = 0, + .delay = 0, + }, { + .reg_write_type = MSM_ACTUATOR_WRITE_DAC, + .hw_mask = 0, + .reg_addr = 241, + .hw_shift = 0, + .data_type = 10, + .addr_type = 4, + .reg_data = 0, + .delay = 0, + }, { + .reg_write_type = MSM_ACTUATOR_WRITE_DAC, + .hw_mask = 0, + .reg_addr = 242, + .hw_shift = 0, + .data_type = 10, + .addr_type = 4, + .reg_data = 0, + .delay = 0, + }, { + .reg_write_type = MSM_ACTUATOR_WRITE_DAC, + .hw_mask = 0, + .reg_addr = 243, + .hw_shift = 0, + .data_type = 10, + .addr_type = 4, + .reg_data = 0, + .delay = 0, + }, + }; + + //... + struct reg_settings_t actuator_init_settings[1] = {0}; + + struct region_params_t region_params[] = { + { + .step_bound = {512, 0,}, + .code_per_step = 118, + .qvalue = 128, + }, + }; + + actuator_cfg_data.cfgtype = CFG_SET_ACTUATOR_INFO; + actuator_cfg_data.cfg.set_info = (struct msm_actuator_set_info_t){ + .actuator_params = { + .act_type = ACTUATOR_VCM, + .reg_tbl_size = 4, + .data_size = 10, + .init_setting_size = 0, + .i2c_freq_mode = I2C_CUSTOM_MODE, + .i2c_addr = 28, + .i2c_addr_type = MSM_ACTUATOR_BYTE_ADDR, + .i2c_data_type = MSM_ACTUATOR_BYTE_DATA, + .reg_tbl_params = &actuator_reg_params[0], + .init_settings = &actuator_init_settings[0], + .park_lens = { + .damping_step = 1023, + .damping_delay = 15000, + .hw_params = 58404, + .max_step = 20, + } + }, + .af_tuning_params = { + .initial_code = (int16_t)s->infinity_dac, + .pwd_step = 0, + .region_size = 1, + .total_steps = 512, + .region_params = ®ion_params[0], + }, + }; + err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data); + LOG("actuator set info: %d", err); + + // power up ois + ois_cfg_data.cfgtype = CFG_OIS_POWERUP; + err = ioctl(s->ois_fd, VIDIOC_MSM_OIS_CFG, &ois_cfg_data); + LOG("ois powerup: %d", err); + + ois_cfg_data.cfgtype = CFG_OIS_INIT; + err = ioctl(s->ois_fd, VIDIOC_MSM_OIS_CFG, &ois_cfg_data); + LOG("ois init: %d", err); + + ois_cfg_data.cfgtype = CFG_OIS_CONTROL; + ois_cfg_data.cfg.set_info.ois_params = (struct msm_ois_params_t){ + // .data_size = 26312, + .setting_size = 120, + .i2c_addr = 28, + .i2c_freq_mode = I2C_CUSTOM_MODE, + // .i2c_addr_type = wtf + // .i2c_data_type = wtf + .settings = &ois_init_settings[0], + }; + err = ioctl(s->ois_fd, VIDIOC_MSM_OIS_CFG, &ois_cfg_data); + LOG("ois init settings: %d", err); + } else { + // leeco actuator (DW9800W H-Bridge Driver IC) + // from sniff + s->infinity_dac = 364; + + struct msm_actuator_reg_params_t actuator_reg_params[] = { + { + .reg_write_type = MSM_ACTUATOR_WRITE_DAC, + .hw_mask = 0, + // MSB here at address 3 + .reg_addr = 3, + .hw_shift = 0, + .data_type = 9, + .addr_type = 4, + .reg_data = 0, + .delay = 0, + }, + }; + + struct reg_settings_t actuator_init_settings[] = { + { .reg_addr=2, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=1, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 0 }, // PD = power down + { .reg_addr=2, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=0, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 2 }, // 0 = power up + { .reg_addr=2, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=2, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 2 }, // RING = SAC mode + { .reg_addr=6, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=64, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 0 }, // 0x40 = SAC3 mode + { .reg_addr=7, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=113, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 0 }, + // 0x71 = DIV1 | DIV0 | SACT0 -- Tvib x 1/4 (quarter) + // SAC Tvib = 6.3 ms + 0.1 ms = 6.4 ms / 4 = 1.6 ms + // LSC 1-step = 252 + 1*4 = 256 ms / 4 = 64 ms + }; + + struct region_params_t region_params[] = { + { + .step_bound = {238, 0,}, + .code_per_step = 235, + .qvalue = 128, + }, + }; + + actuator_cfg_data.cfgtype = CFG_SET_ACTUATOR_INFO; + actuator_cfg_data.cfg.set_info = (struct msm_actuator_set_info_t){ + .actuator_params = { + .act_type = ACTUATOR_BIVCM, + .reg_tbl_size = 1, + .data_size = 10, + .init_setting_size = 5, + .i2c_freq_mode = I2C_STANDARD_MODE, + .i2c_addr = 24, + .i2c_addr_type = MSM_ACTUATOR_BYTE_ADDR, + .i2c_data_type = MSM_ACTUATOR_WORD_DATA, + .reg_tbl_params = &actuator_reg_params[0], + .init_settings = &actuator_init_settings[0], + .park_lens = { + .damping_step = 1023, + .damping_delay = 14000, + .hw_params = 11, + .max_step = 20, + } + }, + .af_tuning_params = { + .initial_code = (int16_t)s->infinity_dac, + .pwd_step = 0, + .region_size = 1, + .total_steps = 238, + .region_params = ®ion_params[0], + }, + }; + + err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data); + LOG("actuator set info: %d", err); + } + } + + if (s->camera_id == CAMERA_ID_IMX298) { + err = sensor_write_regs(s, mode_setting_array_imx298, ARRAYSIZE(mode_setting_array_imx298), MSM_CAMERA_I2C_BYTE_DATA); + LOG("sensor setup: %d", err); + } + + // CSIPHY: configure csiphy + if (s->camera_id == CAMERA_ID_IMX298) { + csiphy_params.lane_cnt = 4; + csiphy_params.settle_cnt = 14; + csiphy_params.lane_mask = 0x1f; + csiphy_params.csid_core = 0; + } else if (s->camera_id == CAMERA_ID_S5K3P8SP) { + csiphy_params.lane_cnt = 4; + csiphy_params.settle_cnt = 24; + csiphy_params.lane_mask = 0x1f; + csiphy_params.csid_core = 0; + } else if (s->camera_id == CAMERA_ID_IMX179) { + csiphy_params.lane_cnt = 4; + csiphy_params.settle_cnt = 11; + csiphy_params.lane_mask = 0x1f; + csiphy_params.csid_core = 2; + } else if (s->camera_id == CAMERA_ID_OV8865) { + // guess! + csiphy_params.lane_cnt = 4; + csiphy_params.settle_cnt = 24; + csiphy_params.lane_mask = 0x1f; + csiphy_params.csid_core = 2; + } + csiphy_cfg_data.cfgtype = CSIPHY_CFG; + csiphy_cfg_data.cfg.csiphy_params = &csiphy_params; + err = ioctl(s->csiphy_fd, VIDIOC_MSM_CSIPHY_IO_CFG, &csiphy_cfg_data); + LOG("csiphy configure: %d", err); + + // CSID: configure csid + csid_params.lane_cnt = 4; + csid_params.lane_assign = 0x4320; + if (rear) { + csid_params.phy_sel = 0; + } else { + csid_params.phy_sel = 2; + } + csid_params.lut_params.num_cid = rear ? 3 : 1; + +#define CSI_STATS 0x35 +#define CSI_PD 0x36 + + csid_params.lut_params.vc_cfg_a[0].cid = 0; + csid_params.lut_params.vc_cfg_a[0].dt = CSI_RAW10; + csid_params.lut_params.vc_cfg_a[0].decode_format = CSI_DECODE_10BIT; + csid_params.lut_params.vc_cfg_a[1].cid = 1; + csid_params.lut_params.vc_cfg_a[1].dt = CSI_PD; + csid_params.lut_params.vc_cfg_a[1].decode_format = CSI_DECODE_10BIT; + csid_params.lut_params.vc_cfg_a[2].cid = 2; + csid_params.lut_params.vc_cfg_a[2].dt = CSI_STATS; + csid_params.lut_params.vc_cfg_a[2].decode_format = CSI_DECODE_10BIT; + + csid_params.lut_params.vc_cfg[0] = &csid_params.lut_params.vc_cfg_a[0]; + csid_params.lut_params.vc_cfg[1] = &csid_params.lut_params.vc_cfg_a[1]; + csid_params.lut_params.vc_cfg[2] = &csid_params.lut_params.vc_cfg_a[2]; + + csid_cfg_data.cfgtype = CSID_CFG; + csid_cfg_data.cfg.csid_params = &csid_params; + err = ioctl(s->csid_fd, VIDIOC_MSM_CSID_IO_CFG, &csid_cfg_data); + LOG("csid configure: %d", err); + + // ISP: SMMU_ATTACH + struct msm_vfe_smmu_attach_cmd smmu_attach_cmd = { + .security_mode = 0, + .iommu_attach_mode = IOMMU_ATTACH + }; + err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_SMMU_ATTACH, &smmu_attach_cmd); + LOG("isp smmu attach: %d", err); + + // ******************* STREAM RAW ***************************** + + // configure QMET input + for (int i = 0; i < (rear ? 3 : 1); i++) { + StreamState *ss = &s->ss[i]; + + memset(&input_cfg, 0, sizeof(struct msm_vfe_input_cfg)); + input_cfg.input_src = (msm_vfe_input_src)(VFE_RAW_0+i); + input_cfg.input_pix_clk = s->pixel_clock; + input_cfg.d.rdi_cfg.cid = i; + input_cfg.d.rdi_cfg.frame_based = 1; + err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_INPUT_CFG, &input_cfg); + LOG("configure input(%d): %d", i, err); + + // ISP: REQUEST_STREAM + ss->stream_req.axi_stream_handle = 0; + if (rear) { + ss->stream_req.session_id = 2; + ss->stream_req.stream_id = /*ISP_META_CHANNEL_BIT | */ISP_NATIVE_BUF_BIT | (1+i); + } else { + ss->stream_req.session_id = 3; + ss->stream_req.stream_id = ISP_NATIVE_BUF_BIT | 1; + } + + if (i == 0) { + ss->stream_req.output_format = v4l2_fourcc('R', 'G', '1', '0'); + } else { + ss->stream_req.output_format = v4l2_fourcc('Q', 'M', 'E', 'T'); + } + ss->stream_req.stream_src = (msm_vfe_axi_stream_src)(RDI_INTF_0+i); + +#ifdef HIGH_FPS + if (rear) { + ss->stream_req.frame_skip_pattern = EVERY_3FRAME; + } +#endif + + ss->stream_req.frame_base = 1; + ss->stream_req.buf_divert = 1; //i == 0; + + // setup stream plane. doesn't even matter? + /*s->stream_req.plane_cfg[0].output_plane_format = Y_PLANE; + s->stream_req.plane_cfg[0].output_width = s->ci.frame_width; + s->stream_req.plane_cfg[0].output_height = s->ci.frame_height; + s->stream_req.plane_cfg[0].output_stride = s->ci.frame_width; + s->stream_req.plane_cfg[0].output_scan_lines = s->ci.frame_height; + s->stream_req.plane_cfg[0].rdi_cid = 0;*/ + + err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_REQUEST_STREAM, &ss->stream_req); + LOG("isp request stream: %d -> 0x%x", err, ss->stream_req.axi_stream_handle); + + // ISP: REQUEST_BUF + ss->buf_request.session_id = ss->stream_req.session_id; + ss->buf_request.stream_id = ss->stream_req.stream_id; + ss->buf_request.num_buf = FRAME_BUF_COUNT; + ss->buf_request.buf_type = ISP_PRIVATE_BUF; + ss->buf_request.handle = 0; + err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_REQUEST_BUF, &ss->buf_request); + LOG("isp request buf: %d", err); + LOG("got buf handle: 0x%x", ss->buf_request.handle); + + // ENQUEUE all buffers + for (int j = 0; j < ss->buf_request.num_buf; j++) { + ss->qbuf_info[j].handle = ss->buf_request.handle; + ss->qbuf_info[j].buf_idx = j; + ss->qbuf_info[j].buffer.num_planes = 1; + ss->qbuf_info[j].buffer.planes[0].addr = ss->bufs[j].fd; + ss->qbuf_info[j].buffer.planes[0].length = ss->bufs[j].len; + err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_ENQUEUE_BUF, &ss->qbuf_info[j]); + } + + // ISP: UPDATE_STREAM + update_cmd.num_streams = 1; + update_cmd.update_info[0].user_stream_id = ss->stream_req.stream_id; + update_cmd.update_info[0].stream_handle = ss->stream_req.axi_stream_handle; + update_cmd.update_type = UPDATE_STREAM_ADD_BUFQ; + err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_UPDATE_STREAM, &update_cmd); + LOG("isp update stream: %d", err); + } + + LOG("******** START STREAMS ********"); + + sub.id = 0; + sub.type = 0x1ff; + err = ioctl(s->isp_fd, VIDIOC_SUBSCRIBE_EVENT, &sub); + LOG("isp subscribe: %d", err); + + // ISP: START_STREAM + s->stream_cfg.cmd = START_STREAM; + s->stream_cfg.num_streams = rear ? 3 : 1; + for (int i = 0; i < s->stream_cfg.num_streams; i++) { + s->stream_cfg.stream_handle[i] = s->ss[i].stream_req.axi_stream_handle; + } + err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_CFG_STREAM, &s->stream_cfg); + LOG("isp start stream: %d", err); +} + + +static struct damping_params_t actuator_ringing_params = { + .damping_step = 1023, + .damping_delay = 15000, + .hw_params = 0x0000e422, +}; + +static void rear_start(CameraState *s) { + int err; + + struct msm_actuator_cfg_data actuator_cfg_data = {0}; + + set_exposure(s, 1.0, 1.0); + + err = sensor_write_regs(s, start_reg_array, ARRAYSIZE(start_reg_array), MSM_CAMERA_I2C_BYTE_DATA); + LOG("sensor start regs: %d", err); + + // focus on infinity assuming phone is perpendicular + int inf_step; + + if (s->device != DEVICE_LP3) { + imx298_ois_calibration(s->ois_fd, s->eeprom); + inf_step = 332 - s->infinity_dac; + + // initial guess + s->lens_true_pos = 300; + } else { + // default is OP3, this is for LeEco + actuator_ringing_params.damping_step = 1023; + actuator_ringing_params.damping_delay = 20000; + actuator_ringing_params.hw_params = 13; + + inf_step = 512 - s->infinity_dac; + + // initial guess + s->lens_true_pos = 400; + } + + // reset lens position + memset(&actuator_cfg_data, 0, sizeof(actuator_cfg_data)); + actuator_cfg_data.cfgtype = CFG_SET_POSITION; + actuator_cfg_data.cfg.setpos = (struct msm_actuator_set_position_t){ + .number_of_steps = 1, + .hw_params = (uint32_t)((s->device != DEVICE_LP3) ? 0x0000e424 : 7), + .pos = {s->infinity_dac, 0}, + .delay = {0,} + }; + err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data); + LOG("actuator set pos: %d", err); + + // TODO: confirm this isn't needed + /*memset(&actuator_cfg_data, 0, sizeof(actuator_cfg_data)); + actuator_cfg_data.cfgtype = CFG_MOVE_FOCUS; + actuator_cfg_data.cfg.move = (struct msm_actuator_move_params_t){ + .dir = 0, + .sign_dir = 1, + .dest_step_pos = inf_step, + .num_steps = inf_step, + .curr_lens_pos = 0, + .ringing_params = &actuator_ringing_params, + }; + err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data); // should be ~332 at startup ? + LOG("init actuator move focus: %d", err);*/ + //actuator_cfg_data.cfg.move.curr_lens_pos; + + s->cur_lens_pos = 0; + s->cur_step_pos = inf_step; + + actuator_move(s, s->cur_lens_pos); + + LOG("init lens pos: %d", s->cur_lens_pos); +} + +void actuator_move(CameraState *s, uint16_t target) { + int err; + + int step = target - s->cur_lens_pos; + // LP3 moves only on even positions. TODO: use proper sensor params + if (s->device == DEVICE_LP3) { + step /= 2; + } + + int dest_step_pos = s->cur_step_pos + step; + dest_step_pos = std::clamp(dest_step_pos, 0, 255); + + struct msm_actuator_cfg_data actuator_cfg_data = {0}; + actuator_cfg_data.cfgtype = CFG_MOVE_FOCUS; + actuator_cfg_data.cfg.move = (struct msm_actuator_move_params_t){ + .dir = (int8_t)((step > 0) ? 0 : 1), + .sign_dir = (int8_t)((step > 0) ? 1 : -1), + .dest_step_pos = (int16_t)dest_step_pos, + .num_steps = abs(step), + .curr_lens_pos = s->cur_lens_pos, + .ringing_params = &actuator_ringing_params, + }; + err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data); + //LOGD("actuator move focus: %d", err); + + s->cur_step_pos = dest_step_pos; + s->cur_lens_pos = actuator_cfg_data.cfg.move.curr_lens_pos; + + //LOGD("step %d target: %d lens pos: %d", dest_step_pos, target, s->cur_lens_pos); +} + +static void parse_autofocus(CameraState *s, uint8_t *d) { + int good_count = 0; + int16_t max_focus = -32767; + int avg_focus = 0; + + /*printf("FOCUS: "); + for (int i = 0; i < 0x10; i++) { + printf("%2.2X ", d[i]); + }*/ + + for (int i = 0; i < NUM_FOCUS; i++) { + int doff = i*5+5; + s->confidence[i] = d[doff]; + // this should just be a 10-bit signed int instead of 11 + // TODO: write it in a nicer way + int16_t focus_t = (d[doff+1] << 3) | (d[doff+2] >> 5); + if (focus_t >= 1024) focus_t = -(2048-focus_t); + s->focus[i] = focus_t; + //printf("%x->%d ", d[doff], focus_t); + if (s->confidence[i] > 0x20) { + good_count++; + max_focus = std::max(max_focus, s->focus[i]); + avg_focus += s->focus[i]; + } + } + // self recover override + if (s->self_recover > 1) { + s->focus_err = 200 * ((s->self_recover % 2 == 0) ? 1:-1); // far for even numbers, close for odd + s->self_recover -= 2; + return; + } + + if (good_count < 4) { + s->focus_err = nan(""); + return; + } + + avg_focus /= good_count; + + // outlier rejection + if (abs(avg_focus - max_focus) > 200) { + s->focus_err = nan(""); + return; + } + + s->focus_err = max_focus*1.0; +} + +static std::optional get_accel_z(SubMaster *sm) { + if (sm->update(0) > 0) { + for (auto event : (*sm)["sensorEvents"].getSensorEvents()) { + if (event.which() == cereal::SensorEventData::ACCELERATION) { + if (auto v = event.getAcceleration().getV(); v.size() >= 3) + return -v[2]; + break; + } + } + } + return std::nullopt; +} + +static void do_autofocus(CameraState *s, SubMaster *sm) { + // params for focus PI controller + const int dac_up = s->device == DEVICE_LP3? LP3_AF_DAC_UP:OP3T_AF_DAC_UP; + const int dac_down = s->device == DEVICE_LP3? LP3_AF_DAC_DOWN:OP3T_AF_DAC_DOWN; + + float lens_true_pos = s->lens_true_pos.load(); + if (!isnan(s->focus_err)) { + // learn lens_true_pos + const float focus_kp = 0.005; + lens_true_pos -= s->focus_err*focus_kp; + } + + if (auto accel_z = get_accel_z(sm)) { + s->last_sag_acc_z = *accel_z; + } + const float sag = (s->last_sag_acc_z / 9.8) * 128; + // stay off the walls + lens_true_pos = std::clamp(lens_true_pos, float(dac_down), float(dac_up)); + int target = std::clamp(lens_true_pos - sag, float(dac_down), float(dac_up)); + s->lens_true_pos.store(lens_true_pos); + + /*char debug[4096]; + char *pdebug = debug; + pdebug += sprintf(pdebug, "focus "); + for (int i = 0; i < NUM_FOCUS; i++) pdebug += sprintf(pdebug, "%2x(%4d) ", s->confidence[i], s->focus[i]); + pdebug += sprintf(pdebug, " err: %7.2f offset: %6.2f sag: %6.2f lens_true_pos: %6.2f cur_lens_pos: %4d->%4d", err * focus_kp, offset, sag, s->lens_true_pos, s->cur_lens_pos, target); + LOGD(debug);*/ + + actuator_move(s, target); +} + +void camera_autoexposure(CameraState *s, float grey_frac) { + if (s->camera_num == 0) { + CameraExpInfo tmp = rear_exp.load(); + tmp.op_id++; + tmp.grey_frac = grey_frac; + rear_exp.store(tmp); + } else { + CameraExpInfo tmp = front_exp.load(); + tmp.op_id++; + tmp.grey_frac = grey_frac; + front_exp.store(tmp); + } +} + +static void front_start(CameraState *s) { + int err; + + set_exposure(s, 1.0, 1.0); + + err = sensor_write_regs(s, start_reg_array, ARRAYSIZE(start_reg_array), MSM_CAMERA_I2C_BYTE_DATA); + LOG("sensor start regs: %d", err); +} + +void cameras_open(MultiCameraState *s) { + int err; + struct ispif_cfg_data ispif_cfg_data = {}; + struct msm_ispif_param_data ispif_params = {}; + ispif_params.num = 4; + // rear camera + ispif_params.entries[0].vfe_intf = VFE0; + ispif_params.entries[0].intftype = RDI0; + ispif_params.entries[0].num_cids = 1; + ispif_params.entries[0].cids[0] = CID0; + ispif_params.entries[0].csid = CSID0; + // front camera + ispif_params.entries[1].vfe_intf = VFE1; + ispif_params.entries[1].intftype = RDI0; + ispif_params.entries[1].num_cids = 1; + ispif_params.entries[1].cids[0] = CID0; + ispif_params.entries[1].csid = CSID2; + // rear camera (focus) + ispif_params.entries[2].vfe_intf = VFE0; + ispif_params.entries[2].intftype = RDI1; + ispif_params.entries[2].num_cids = CID1; + ispif_params.entries[2].cids[0] = CID1; + ispif_params.entries[2].csid = CSID0; + // rear camera (stats, for AE) + ispif_params.entries[3].vfe_intf = VFE0; + ispif_params.entries[3].intftype = RDI2; + ispif_params.entries[3].num_cids = 1; + ispif_params.entries[3].cids[0] = CID2; + ispif_params.entries[3].csid = CSID0; + + s->msmcfg_fd = open("/dev/media0", O_RDWR | O_NONBLOCK); + assert(s->msmcfg_fd >= 0); + + sensors_init(s); + + s->v4l_fd = open("/dev/video0", O_RDWR | O_NONBLOCK); + assert(s->v4l_fd >= 0); + + if (s->device == DEVICE_LP3) { + s->ispif_fd = open("/dev/v4l-subdev15", O_RDWR | O_NONBLOCK); + } else { + s->ispif_fd = open("/dev/v4l-subdev16", O_RDWR | O_NONBLOCK); + } + assert(s->ispif_fd >= 0); + + // ISPIF: stop + // memset(&ispif_cfg_data, 0, sizeof(ispif_cfg_data)); + // ispif_cfg_data.cfg_type = ISPIF_STOP_FRAME_BOUNDARY; + // ispif_cfg_data.params = ispif_params; + // err = ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data); + // LOG("ispif stop: %d", err); + + LOG("*** open front ***"); + s->front.ss[0].bufs = s->front.buf.camera_bufs.get(); + camera_open(&s->front, false); + + LOG("*** open rear ***"); + s->rear.ss[0].bufs = s->rear.buf.camera_bufs.get(); + s->rear.ss[1].bufs = s->focus_bufs; + s->rear.ss[2].bufs = s->stats_bufs; + camera_open(&s->rear, true); + + if (getenv("CAMERA_TEST")) { + cameras_close(s); + exit(0); + } + + // ISPIF: set vfe info + memset(&ispif_cfg_data, 0, sizeof(ispif_cfg_data)); + ispif_cfg_data.cfg_type = ISPIF_SET_VFE_INFO; + ispif_cfg_data.vfe_info.num_vfe = 2; + err = ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data); + LOG("ispif set vfe info: %d", err); + + // ISPIF: setup + memset(&ispif_cfg_data, 0, sizeof(ispif_cfg_data)); + ispif_cfg_data.cfg_type = ISPIF_INIT; + ispif_cfg_data.csid_version = 0x30050000; //CSID_VERSION_V35 + err = ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data); + LOG("ispif setup: %d", err); + + memset(&ispif_cfg_data, 0, sizeof(ispif_cfg_data)); + ispif_cfg_data.cfg_type = ISPIF_CFG; + ispif_cfg_data.params = ispif_params; + + err = ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data); + LOG("ispif cfg: %d", err); + + ispif_cfg_data.cfg_type = ISPIF_START_FRAME_BOUNDARY; + err = ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data); + LOG("ispif start_frame_boundary: %d", err); + + front_start(&s->front); + rear_start(&s->rear); +} + + +static void camera_close(CameraState *s) { + int err; + + s->buf.stop(); + + // ISP: STOP_STREAM + s->stream_cfg.cmd = STOP_STREAM; + err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_CFG_STREAM, &s->stream_cfg); + LOG("isp stop stream: %d", err); + + for (int i = 0; i < 3; i++) { + StreamState *ss = &s->ss[i]; + if (ss->stream_req.axi_stream_handle != 0) { + err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_RELEASE_BUF, &ss->buf_request); + LOG("isp release buf: %d", err); + + struct msm_vfe_axi_stream_release_cmd stream_release = { + .stream_handle = ss->stream_req.axi_stream_handle, + }; + err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_RELEASE_STREAM, &stream_release); + LOG("isp release stream: %d", err); + } + } + + free(s->eeprom); +} + + +const char* get_isp_event_name(unsigned int type) { + switch (type) { + case ISP_EVENT_REG_UPDATE: return "ISP_EVENT_REG_UPDATE"; + case ISP_EVENT_EPOCH_0: return "ISP_EVENT_EPOCH_0"; + case ISP_EVENT_EPOCH_1: return "ISP_EVENT_EPOCH_1"; + case ISP_EVENT_START_ACK: return "ISP_EVENT_START_ACK"; + case ISP_EVENT_STOP_ACK: return "ISP_EVENT_STOP_ACK"; + case ISP_EVENT_IRQ_VIOLATION: return "ISP_EVENT_IRQ_VIOLATION"; + case ISP_EVENT_STATS_OVERFLOW: return "ISP_EVENT_STATS_OVERFLOW"; + case ISP_EVENT_ERROR: return "ISP_EVENT_ERROR"; + case ISP_EVENT_SOF: return "ISP_EVENT_SOF"; + case ISP_EVENT_EOF: return "ISP_EVENT_EOF"; + case ISP_EVENT_BUF_DONE: return "ISP_EVENT_BUF_DONE"; + case ISP_EVENT_BUF_DIVERT: return "ISP_EVENT_BUF_DIVERT"; + case ISP_EVENT_STATS_NOTIFY: return "ISP_EVENT_STATS_NOTIFY"; + case ISP_EVENT_COMP_STATS_NOTIFY: return "ISP_EVENT_COMP_STATS_NOTIFY"; + case ISP_EVENT_FE_READ_DONE: return "ISP_EVENT_FE_READ_DONE"; + case ISP_EVENT_IOMMU_P_FAULT: return "ISP_EVENT_IOMMU_P_FAULT"; + case ISP_EVENT_HW_FATAL_ERROR: return "ISP_EVENT_HW_FATAL_ERROR"; + case ISP_EVENT_PING_PONG_MISMATCH: return "ISP_EVENT_PING_PONG_MISMATCH"; + case ISP_EVENT_REG_UPDATE_MISSING: return "ISP_EVENT_REG_UPDATE_MISSING"; + case ISP_EVENT_BUF_FATAL_ERROR: return "ISP_EVENT_BUF_FATAL_ERROR"; + case ISP_EVENT_STREAM_UPDATE_DONE: return "ISP_EVENT_STREAM_UPDATE_DONE"; + default: return "unknown"; + } +} + +static FrameMetadata get_frame_metadata(CameraState *s, uint32_t frame_id) { + pthread_mutex_lock(&s->frame_info_lock); + for (int i=0; iframe_metadata[i].frame_id == frame_id) { + pthread_mutex_unlock(&s->frame_info_lock); + return s->frame_metadata[i]; + } + } + pthread_mutex_unlock(&s->frame_info_lock); + + // should never happen + return (FrameMetadata){ + .frame_id = (uint32_t)-1, + }; +} + +static void* ops_thread(void* arg) { + MultiCameraState *s = (MultiCameraState*)arg; + + int rear_op_id_last = 0; + int front_op_id_last = 0; + + CameraExpInfo rear_op; + CameraExpInfo front_op; + + set_thread_name("camera_settings"); + SubMaster sm({"sensorEvents"}); + while(!do_exit) { + rear_op = rear_exp.load(); + if (rear_op.op_id != rear_op_id_last) { + do_autoexposure(&s->rear, rear_op.grey_frac); + do_autofocus(&s->rear, &sm); + rear_op_id_last = rear_op.op_id; + } + + front_op = front_exp.load(); + if (front_op.op_id != front_op_id_last) { + do_autoexposure(&s->front, front_op.grey_frac); + front_op_id_last = front_op.op_id; + } + + usleep(50000); + } + + return NULL; +} + +static void update_lapmap(MultiCameraState *s, const CameraBuf *b, const int cnt) { + const size_t width = b->rgb_width / NUM_SEGMENTS_X; + const size_t height = b->rgb_height / NUM_SEGMENTS_Y; + static std::unique_ptr rgb_roi_buf = std::make_unique(width * height * 3); + static std::unique_ptr conv_result = std::make_unique(width * height); + + // sharpness scores + const int roi_id = cnt % std::size(s->lapres); // rolling roi + const int x_offset = ROI_X_MIN + roi_id % (ROI_X_MAX - ROI_X_MIN + 1); + const int y_offset = ROI_Y_MIN + roi_id / (ROI_X_MAX - ROI_X_MIN + 1); + + const uint8_t *rgb_addr_offset = (uint8_t *)b->cur_rgb_buf->addr + y_offset * height * FULL_STRIDE_X * 3 + x_offset * width * 3; + for (int i = 0; i < height; ++i) { + memcpy(rgb_roi_buf.get() + i * width * 3, rgb_addr_offset + i * FULL_STRIDE_X * 3, width * 3); + } + + constexpr int conv_cl_localMemSize = (CONV_LOCAL_WORKSIZE + 2 * (3 / 2)) * (CONV_LOCAL_WORKSIZE + 2 * (3 / 2)) * (3 * sizeof(uint8_t)); + CL_CHECK(clEnqueueWriteBuffer(b->q, s->rgb_conv_roi_cl, true, 0, width * height * 3 * sizeof(uint8_t), rgb_roi_buf.get(), 0, 0, 0)); + CL_CHECK(clSetKernelArg(s->krnl_rgb_laplacian, 0, sizeof(cl_mem), (void *)&s->rgb_conv_roi_cl)); + CL_CHECK(clSetKernelArg(s->krnl_rgb_laplacian, 1, sizeof(cl_mem), (void *)&s->rgb_conv_result_cl)); + CL_CHECK(clSetKernelArg(s->krnl_rgb_laplacian, 2, sizeof(cl_mem), (void *)&s->rgb_conv_filter_cl)); + CL_CHECK(clSetKernelArg(s->krnl_rgb_laplacian, 3, conv_cl_localMemSize, 0)); + cl_event conv_event; + CL_CHECK(clEnqueueNDRangeKernel(b->q, s->krnl_rgb_laplacian, 2, NULL, + (size_t[]){width, height}, (size_t[]){CONV_LOCAL_WORKSIZE, CONV_LOCAL_WORKSIZE}, 0, 0, &conv_event)); + clWaitForEvents(1, &conv_event); + CL_CHECK(clReleaseEvent(conv_event)); + + CL_CHECK(clEnqueueReadBuffer(b->q, s->rgb_conv_result_cl, true, 0, + width * height * sizeof(int16_t), conv_result.get(), 0, 0, 0)); + + s->lapres[roi_id] = get_lapmap_one(conv_result.get(), width, height); +} + +static void setup_self_recover(CameraState *c, const uint16_t *lapres, size_t lapres_size) { + const int dac_down = c->device == DEVICE_LP3 ? LP3_AF_DAC_DOWN : OP3T_AF_DAC_DOWN; + const int dac_up = c->device == DEVICE_LP3 ? LP3_AF_DAC_UP : OP3T_AF_DAC_UP; + const int dac_m = c->device == DEVICE_LP3 ? LP3_AF_DAC_M : OP3T_AF_DAC_M; + const int dac_3sig = c->device == DEVICE_LP3 ? LP3_AF_DAC_3SIG : OP3T_AF_DAC_3SIG; + + const float lens_true_pos = c->lens_true_pos.load(); + int self_recover = c->self_recover.load(); + if (self_recover < 2 && (lens_true_pos < (dac_down + 1) || lens_true_pos > (dac_up - 1)) && is_blur(lapres, lapres_size)) { + // truly stuck, needs help + if (--self_recover < -FOCUS_RECOVER_PATIENCE) { + LOGD("rear camera bad state detected. attempting recovery from %.1f, recover state is %d", lens_true_pos, self_recover); + // parity determined by which end is stuck at + self_recover = FOCUS_RECOVER_STEPS + (lens_true_pos < dac_m ? 1 : 0); + } + } else if (self_recover < 2 && (lens_true_pos < (dac_m - dac_3sig) || lens_true_pos > (dac_m + dac_3sig))) { + // in suboptimal position with high prob, but may still recover by itself + if (--self_recover < -(FOCUS_RECOVER_PATIENCE * 3)) { + self_recover = FOCUS_RECOVER_STEPS / 2 + (lens_true_pos < dac_m ? 1 : 0); + } + } else if (self_recover < 0) { + self_recover += 1; // reset if fine + } + c->self_recover.store(self_recover); +} + +void camera_process_front(MultiCameraState *s, CameraState *c, int cnt) { + common_camera_process_front(s->sm_front, s->pm, c, cnt); +} + +// called by processing_thread +void camera_process_frame(MultiCameraState *s, CameraState *c, int cnt) { + const CameraBuf *b = &c->buf; + update_lapmap(s, b, cnt); + setup_self_recover(c, &s->lapres[0], std::size(s->lapres)); + + MessageBuilder msg; + auto framed = msg.initEvent().initFrame(); + fill_frame_data(framed, b->cur_frame_data, cnt); + if (env_send_rear) { + fill_frame_image(framed, (uint8_t *)b->cur_rgb_buf->addr, b->rgb_width, b->rgb_height, b->rgb_stride); + } + framed.setFocusVal(s->rear.focus); + framed.setFocusConf(s->rear.confidence); + framed.setRecoverState(s->rear.self_recover); + framed.setSharpnessScore(s->lapres); + framed.setTransform(b->yuv_transform.v); + s->pm->send("frame", msg); + + if (cnt % 100 == 3) { + create_thumbnail(s, c, (uint8_t *)b->cur_rgb_buf->addr); + } + + if (cnt % 3 == 0) { + const int x = 290, y = 322, width = 560, height = 314; + const int skip = 1; + set_exposure_target(c, (const uint8_t *)b->yuv_bufs[b->cur_yuv_idx].y, x, x + width, skip, y, y + height, skip); + } +} + +void cameras_run(MultiCameraState *s) { + int err; + + pthread_t ops_thread_handle; + err = pthread_create(&ops_thread_handle, NULL, + ops_thread, s); + assert(err == 0); + std::vector threads; + threads.push_back(start_process_thread(s, "processing", &s->rear, camera_process_frame)); + threads.push_back(start_process_thread(s, "frontview", &s->front, camera_process_front)); + + CameraState* cameras[2] = {&s->rear, &s->front}; + + while (!do_exit) { + struct pollfd fds[2] = {{0}}; + + fds[0].fd = cameras[0]->isp_fd; + fds[0].events = POLLPRI; + + fds[1].fd = cameras[1]->isp_fd; + fds[1].events = POLLPRI; + + int ret = poll(fds, ARRAYSIZE(fds), 1000); + if (ret <= 0) { + if (errno == EINTR || errno == EAGAIN) continue; + LOGE("poll failed (%d - %d)", ret, errno); + break; + } + + // process cameras + for (int i=0; i<2; i++) { + if (!fds[i].revents) continue; + + CameraState *c = cameras[i]; + + struct v4l2_event ev; + ret = ioctl(c->isp_fd, VIDIOC_DQEVENT, &ev); + struct msm_isp_event_data *isp_event_data = (struct msm_isp_event_data *)ev.u.data; + unsigned int event_type = ev.type; + + uint64_t timestamp = (isp_event_data->mono_timestamp.tv_sec*1000000000ULL + + isp_event_data->mono_timestamp.tv_usec*1000); + + int buf_idx = isp_event_data->u.buf_done.buf_idx; + int stream_id = isp_event_data->u.buf_done.stream_id; + int buffer = (stream_id&0xFFFF) - 1; + + uint64_t t = nanos_since_boot(); + + /*if (i == 1) { + printf("%10.2f: VIDIOC_DQEVENT: %d type:%X (%s)\n", t*1.0/1e6, ret, event_type, get_isp_event_name(event_type)); + }*/ + + // printf("%d: %s\n", i, get_isp_event_name(event_type)); + + switch (event_type) { + case ISP_EVENT_BUF_DIVERT: + + /*if (c->is_samsung) { + printf("write %d\n", c->frame_size); + FILE *f = fopen("/tmp/test", "wb"); + fwrite((void*)c->camera_bufs[i].addr, 1, c->frame_size, f); + fclose(f); + }*/ + //printf("divert: %d %d %d\n", i, buffer, buf_idx); + + if (buffer == 0) { + c->buf.camera_bufs_metadata[buf_idx] = get_frame_metadata(c, isp_event_data->frame_id); + tbuffer_dispatch(&c->buf.camera_tb, buf_idx); + } else { + uint8_t *d = (uint8_t*)(c->ss[buffer].bufs[buf_idx].addr); + if (buffer == 1) { + parse_autofocus(c, d); + } + c->ss[buffer].qbuf_info[buf_idx].dirty_buf = 1; + ioctl(c->isp_fd, VIDIOC_MSM_ISP_ENQUEUE_BUF, &c->ss[buffer].qbuf_info[buf_idx]); + } + break; + case ISP_EVENT_EOF: + // printf("ISP_EVENT_EOF delta %f\n", (t-last_t)/1e6); + c->last_t = t; + + pthread_mutex_lock(&c->frame_info_lock); + c->frame_metadata[c->frame_metadata_idx] = (FrameMetadata){ + .frame_id = isp_event_data->frame_id, + .timestamp_eof = timestamp, + .frame_length = (unsigned int)c->cur_frame_length, + .integ_lines = (unsigned int)c->cur_integ_lines, + .global_gain = (unsigned int)c->cur_gain, + .lens_pos = c->cur_lens_pos, + .lens_sag = c->last_sag_acc_z, + .lens_err = c->focus_err, + .lens_true_pos = c->lens_true_pos, + .gain_frac = c->cur_gain_frac, + }; + c->frame_metadata_idx = (c->frame_metadata_idx+1)%METADATA_BUF_COUNT; + pthread_mutex_unlock(&c->frame_info_lock); + + break; + case ISP_EVENT_ERROR: + LOGE("ISP_EVENT_ERROR! err type: 0x%08x", isp_event_data->u.error_info.err_type); + break; + } + } + } + + LOG(" ************** STOPPING **************"); + + err = pthread_join(ops_thread_handle, NULL); + assert(err == 0); + + cameras_close(s); + + for (auto &t : threads) t.join(); +} + +void cameras_close(MultiCameraState *s) { + camera_close(&s->rear); + camera_close(&s->front); + for (int i = 0; i < FRAME_BUF_COUNT; i++) { + visionbuf_free(&s->focus_bufs[i]); + visionbuf_free(&s->stats_bufs[i]); + } + CL_CHECK(clReleaseMemObject(s->rgb_conv_roi_cl)); + CL_CHECK(clReleaseMemObject(s->rgb_conv_result_cl)); + CL_CHECK(clReleaseMemObject(s->rgb_conv_filter_cl)); + + CL_CHECK(clReleaseKernel(s->krnl_rgb_laplacian)); + CL_CHECK(clReleaseProgram(s->prg_rgb_laplacian)); + delete s->sm_front; + delete s->pm; +} diff --git a/selfdrive/camerad/cameras/camera_qcom.h b/selfdrive/camerad/cameras/camera_qcom.h new file mode 100644 index 00000000000000..7bef442d367307 --- /dev/null +++ b/selfdrive/camerad/cameras/camera_qcom.h @@ -0,0 +1,149 @@ +#pragma once + +#include +#include +#include +#include +#include +#include "messaging.hpp" + +#include "msmb_isp.h" +#include "msmb_ispif.h" +#include "msmb_camera.h" +#include "msm_cam_sensor.h" + +#include "common/mat.h" +#include "common/visionbuf.h" +#include "common/buffering.h" +#include "common/utilpp.h" + +#include "camera_common.h" + +#define FRAME_BUF_COUNT 4 +#define METADATA_BUF_COUNT 4 + +#define DEVICE_OP3 0 +#define DEVICE_OP3T 1 +#define DEVICE_LP3 2 + +#define NUM_FOCUS 8 + +#define LP3_AF_DAC_DOWN 366 +#define LP3_AF_DAC_UP 634 +#define LP3_AF_DAC_M 440 +#define LP3_AF_DAC_3SIG 52 +#define OP3T_AF_DAC_DOWN 224 +#define OP3T_AF_DAC_UP 456 +#define OP3T_AF_DAC_M 300 +#define OP3T_AF_DAC_3SIG 96 + +#define FOCUS_RECOVER_PATIENCE 50 // 2.5 seconds of complete blur +#define FOCUS_RECOVER_STEPS 240 // 6 seconds + +typedef struct CameraState CameraState; + +typedef int (*camera_apply_exposure_func)(CameraState *s, int gain, int integ_lines, int frame_length); + +typedef struct StreamState { + struct msm_isp_buf_request buf_request; + struct msm_vfe_axi_stream_request_cmd stream_req; + struct msm_isp_qbuf_info qbuf_info[FRAME_BUF_COUNT]; + VisionBuf *bufs; +} StreamState; + +typedef struct CameraState { + int camera_num; + int camera_id; + CameraInfo ci; + + int device; + + uint32_t pixel_clock; + uint32_t line_length_pclk; + unsigned int max_gain; + + unique_fd csid_fd; + unique_fd csiphy_fd; + unique_fd sensor_fd; + unique_fd isp_fd; + unique_fd eeprom_fd; + // rear only + unique_fd ois_fd, actuator_fd; + uint16_t infinity_dac; + + struct msm_vfe_axi_stream_cfg_cmd stream_cfg; + + size_t eeprom_size; + uint8_t *eeprom; + + // uint32_t camera_bufs_ids[FRAME_BUF_COUNT]; + + pthread_mutex_t frame_info_lock; + FrameMetadata frame_metadata[METADATA_BUF_COUNT]; + int frame_metadata_idx; + float cur_exposure_frac; + float cur_gain_frac; + int cur_gain; + int cur_frame_length; + int cur_integ_lines; + + std::atomic digital_gain; + + StreamState ss[3]; + + uint64_t last_t; + + camera_apply_exposure_func apply_exposure; + + int16_t focus[NUM_FOCUS]; + uint8_t confidence[NUM_FOCUS]; + + float focus_err; + + uint16_t cur_step_pos; + uint16_t cur_lens_pos; + std::atomic last_sag_acc_z; + std::atomic lens_true_pos; + + std::atomic self_recover; // af recovery counter, neg is patience, pos is active + + int fps; + + mat3 transform; + + CameraBuf buf; +} CameraState; + + +typedef struct MultiCameraState { + int device; + + unique_fd ispif_fd; + unique_fd msmcfg_fd; + unique_fd v4l_fd; + + cl_mem rgb_conv_roi_cl, rgb_conv_result_cl, rgb_conv_filter_cl; + uint16_t lapres[(ROI_X_MAX-ROI_X_MIN+1)*(ROI_Y_MAX-ROI_Y_MIN+1)]; + + VisionBuf focus_bufs[FRAME_BUF_COUNT]; + VisionBuf stats_bufs[FRAME_BUF_COUNT]; + + cl_program prg_rgb_laplacian; + cl_kernel krnl_rgb_laplacian; + + CameraState rear; + CameraState front; + + SubMaster *sm_front; + PubMaster *pm; + +} MultiCameraState; + +void cameras_init(MultiCameraState *s, cl_device_id device_id, cl_context ctx); +void cameras_open(MultiCameraState *s); +void cameras_run(MultiCameraState *s); +void cameras_close(MultiCameraState *s); + +void camera_autoexposure(CameraState *s, float grey_frac); +void actuator_move(CameraState *s, uint16_t target); +int sensor_write_regs(CameraState *s, struct msm_camera_i2c_reg_array* arr, size_t size, int data_type); diff --git a/selfdrive/visiond/cameras/debayer.cl b/selfdrive/camerad/cameras/debayer.cl similarity index 99% rename from selfdrive/visiond/cameras/debayer.cl rename to selfdrive/camerad/cameras/debayer.cl index 344ead035672ec..5188dc88c1926e 100644 --- a/selfdrive/visiond/cameras/debayer.cl +++ b/selfdrive/camerad/cameras/debayer.cl @@ -84,6 +84,7 @@ __kernel void debayer10(__global uchar const * const in, // 64 is the black level of the sensor, remove // (changed to 56 for HDR) const float black_level = 56.0f; + // TODO: switch to max here? p = (p - black_level); // correct vignetting (no pow function?) diff --git a/selfdrive/visiond/cameras/sensor_i2c.h b/selfdrive/camerad/cameras/sensor_i2c.h similarity index 99% rename from selfdrive/visiond/cameras/sensor_i2c.h rename to selfdrive/camerad/cameras/sensor_i2c.h index c33bc3468ae5df..74f56b027ba05f 100644 --- a/selfdrive/visiond/cameras/sensor_i2c.h +++ b/selfdrive/camerad/cameras/sensor_i2c.h @@ -1810,8 +1810,8 @@ static struct msm_camera_i2c_reg_array init_array_ov8865[] = { {0x3806,0x9,0}, {0x3807,0xa3,0}, // 2467 {0x3808,0x6,0}, {0x3809,0x60,0}, // 0x660 = 1632 (width) {0x380a,0x4,0}, {0x380b,0xc8,0}, // 0x4c8 = 1224 (height) -{0x380c,0x7,0}, {0x380d,0x83,0}, // 0x783 = 1923 (stride) -{0x380e,0x4,0}, {0x380f,0xe0,0}, // 0x4e0 = 1248 (vstride) +{0x380c,0x6,0}, {0x380d,0x42,0}, // line_length_pck +{0x380e,0x5,0}, {0x380f,0xda,0}, // frame_length_lines {0x3810,0x0,0}, {0x3811,0x4,0}, {0x3813,0x4,0}, {0x3814,0x3,0}, {0x3815,0x1,0}, // H-binning {0x3820,0x6,0}, // format1 diff --git a/selfdrive/camerad/imgproc/conv.cl b/selfdrive/camerad/imgproc/conv.cl new file mode 100644 index 00000000000000..a7115ae76cad7a --- /dev/null +++ b/selfdrive/camerad/imgproc/conv.cl @@ -0,0 +1,110 @@ +// const __constant float3 rgb_weights = (0.299, 0.587, 0.114); // opencv rgb2gray weights +// const __constant float3 bgr_weights = (0.114, 0.587, 0.299); // bgr2gray weights + +// convert input rgb image to single channel then conv +__kernel void rgb2gray_conv2d( + const __global uchar * input, + __global short * output, + __constant short * filter, + __local uchar3 * cached +) +{ + const int rowOffset = get_global_id(1) * IMAGE_W; + const int my = get_global_id(0) + rowOffset; + + const int localRowLen = TWICE_HALF_FILTER_SIZE + get_local_size(0); + const int localRowOffset = ( get_local_id(1) + HALF_FILTER_SIZE ) * localRowLen; + const int myLocal = localRowOffset + get_local_id(0) + HALF_FILTER_SIZE; + + // cache local pixels + cached[ myLocal ].x = input[ my * 3 ]; // r + cached[ myLocal ].y = input[ my * 3 + 1]; // g + cached[ myLocal ].z = input[ my * 3 + 2]; // b + + // pad + if ( + get_global_id(0) < HALF_FILTER_SIZE || + get_global_id(0) > IMAGE_W - HALF_FILTER_SIZE - 1 || + get_global_id(1) < HALF_FILTER_SIZE || + get_global_id(1) > IMAGE_H - HALF_FILTER_SIZE - 1 + ) + { + barrier(CLK_LOCAL_MEM_FENCE); + return; + } + else + { + int localColOffset = -1; + int globalColOffset = -1; + + // cache extra + if ( get_local_id(0) < HALF_FILTER_SIZE ) + { + localColOffset = get_local_id(0); + globalColOffset = -HALF_FILTER_SIZE; + + cached[ localRowOffset + get_local_id(0) ].x = input[ my * 3 - HALF_FILTER_SIZE * 3 ]; + cached[ localRowOffset + get_local_id(0) ].y = input[ my * 3 - HALF_FILTER_SIZE * 3 + 1]; + cached[ localRowOffset + get_local_id(0) ].z = input[ my * 3 - HALF_FILTER_SIZE * 3 + 2]; + } + else if ( get_local_id(0) >= get_local_size(0) - HALF_FILTER_SIZE ) + { + localColOffset = get_local_id(0) + TWICE_HALF_FILTER_SIZE; + globalColOffset = HALF_FILTER_SIZE; + + cached[ myLocal + HALF_FILTER_SIZE ].x = input[ my * 3 + HALF_FILTER_SIZE * 3 ]; + cached[ myLocal + HALF_FILTER_SIZE ].y = input[ my * 3 + HALF_FILTER_SIZE * 3 + 1]; + cached[ myLocal + HALF_FILTER_SIZE ].z = input[ my * 3 + HALF_FILTER_SIZE * 3 + 2]; + } + + + if ( get_local_id(1) < HALF_FILTER_SIZE ) + { + cached[ get_local_id(1) * localRowLen + get_local_id(0) + HALF_FILTER_SIZE ].x = input[ my * 3 - HALF_FILTER_SIZE_IMAGE_W * 3 ]; + cached[ get_local_id(1) * localRowLen + get_local_id(0) + HALF_FILTER_SIZE ].y = input[ my * 3 - HALF_FILTER_SIZE_IMAGE_W * 3 + 1]; + cached[ get_local_id(1) * localRowLen + get_local_id(0) + HALF_FILTER_SIZE ].z = input[ my * 3 - HALF_FILTER_SIZE_IMAGE_W * 3 + 2]; + if (localColOffset > 0) + { + cached[ get_local_id(1) * localRowLen + localColOffset ].x = input[ my * 3 - HALF_FILTER_SIZE_IMAGE_W * 3 + globalColOffset * 3]; + cached[ get_local_id(1) * localRowLen + localColOffset ].y = input[ my * 3 - HALF_FILTER_SIZE_IMAGE_W * 3 + globalColOffset * 3 + 1]; + cached[ get_local_id(1) * localRowLen + localColOffset ].z = input[ my * 3 - HALF_FILTER_SIZE_IMAGE_W * 3 + globalColOffset * 3 + 2]; + } + } + else if ( get_local_id(1) >= get_local_size(1) -HALF_FILTER_SIZE ) + { + int offset = ( get_local_id(1) + TWICE_HALF_FILTER_SIZE ) * localRowLen; + cached[ offset + get_local_id(0) + HALF_FILTER_SIZE ].x = input[ my * 3 + HALF_FILTER_SIZE_IMAGE_W * 3 ]; + cached[ offset + get_local_id(0) + HALF_FILTER_SIZE ].y = input[ my * 3 + HALF_FILTER_SIZE_IMAGE_W * 3 + 1]; + cached[ offset + get_local_id(0) + HALF_FILTER_SIZE ].z = input[ my * 3 + HALF_FILTER_SIZE_IMAGE_W * 3 + 2]; + if (localColOffset > 0) + { + cached[ offset + localColOffset ].x = input[ my * 3 + HALF_FILTER_SIZE_IMAGE_W * 3 + globalColOffset * 3]; + cached[ offset + localColOffset ].y = input[ my * 3 + HALF_FILTER_SIZE_IMAGE_W * 3 + globalColOffset * 3 + 1]; + cached[ offset + localColOffset ].z = input[ my * 3 + HALF_FILTER_SIZE_IMAGE_W * 3 + globalColOffset * 3 + 2]; + } + } + + // sync + barrier(CLK_LOCAL_MEM_FENCE); + + // perform convolution + int fIndex = 0; + short sum = 0; + + for (int r = -HALF_FILTER_SIZE; r <= HALF_FILTER_SIZE; r++) + { + int curRow = r * localRowLen; + for (int c = -HALF_FILTER_SIZE; c <= HALF_FILTER_SIZE; c++, fIndex++) + { + if (!FLIP_RB){ + // sum += dot(rgb_weights, cached[ myLocal + curRow + c ]) * filter[ fIndex ]; + sum += (cached[ myLocal + curRow + c ].x / 3 + cached[ myLocal + curRow + c ].y / 2 + cached[ myLocal + curRow + c ].z / 9) * filter[ fIndex ]; + } else { + // sum += dot(bgr_weights, cached[ myLocal + curRow + c ]) * filter[ fIndex ]; + sum += (cached[ myLocal + curRow + c ].x / 9 + cached[ myLocal + curRow + c ].y / 2 + cached[ myLocal + curRow + c ].z / 3) * filter[ fIndex ]; + } + } + } + output[my] = sum; + } +} \ No newline at end of file diff --git a/selfdrive/camerad/imgproc/pool.cl b/selfdrive/camerad/imgproc/pool.cl new file mode 100644 index 00000000000000..d674b5f363eda7 --- /dev/null +++ b/selfdrive/camerad/imgproc/pool.cl @@ -0,0 +1,34 @@ +// calculate variance in each subregion +__kernel void var_pool( + const __global char * input, + __global ushort * output // should not be larger than 128*128 so uint16 +) +{ + const int xidx = get_global_id(0) + ROI_X_MIN; + const int yidx = get_global_id(1) + ROI_Y_MIN; + + const int size = X_PITCH * Y_PITCH; + + float fsum = 0; + char mean, max; + + for (int i = 0; i < size; i++) { + int x_offset = i % X_PITCH; + int y_offset = i / X_PITCH; + fsum += input[xidx*X_PITCH + yidx*Y_PITCH*FULL_STRIDE_X + x_offset + y_offset*FULL_STRIDE_X]; + max = input[xidx*X_PITCH + yidx*Y_PITCH*FULL_STRIDE_X + x_offset + y_offset*FULL_STRIDE_X]>max ? input[xidx*X_PITCH + yidx*Y_PITCH*FULL_STRIDE_X + x_offset + y_offset*FULL_STRIDE_X]:max; + } + + mean = convert_char_rte(fsum / size); + + float fvar = 0; + for (int i = 0; i < size; i++) { + int x_offset = i % X_PITCH; + int y_offset = i / X_PITCH; + fvar += (input[xidx*X_PITCH + yidx*Y_PITCH*FULL_STRIDE_X + x_offset + y_offset*FULL_STRIDE_X] - mean) * (input[xidx*X_PITCH + yidx*Y_PITCH*FULL_STRIDE_X + x_offset + y_offset*FULL_STRIDE_X] - mean); + } + + fvar = fvar / size; + + output[(xidx-ROI_X_MIN)+(yidx-ROI_Y_MIN)*(ROI_X_MAX-ROI_X_MIN+1)] = convert_ushort_rte(5 * fvar + convert_float_rte(max)); +} \ No newline at end of file diff --git a/selfdrive/camerad/imgproc/utils.cc b/selfdrive/camerad/imgproc/utils.cc new file mode 100644 index 00000000000000..4aeffac5302ee8 --- /dev/null +++ b/selfdrive/camerad/imgproc/utils.cc @@ -0,0 +1,37 @@ +#include "utils.h" +#include +#include +#include +// calculate score based on laplacians in one area +uint16_t get_lapmap_one(const int16_t *lap, int x_pitch, int y_pitch) { + const int size = x_pitch * y_pitch; + // avg and max of roi + int16_t max = 0; + int sum = 0; + for (int i = 0; i < size; ++i) { + const int16_t v = lap[i % x_pitch + (i / x_pitch) * x_pitch]; + sum += v; + if (v > max) max = v; + } + + const int16_t mean = sum / size; + + // var of roi + int var = 0; + for (int i = 0; i < size; ++i) { + var += std::pow(lap[i % x_pitch + (i / x_pitch) * x_pitch] - mean, 2); + } + + const float fvar = (float)var / size; + return std::min(5 * fvar + max, (float)65535); +} + +bool is_blur(const uint16_t *lapmap, const size_t size) { + float bad_sum = 0; + for (int i = 0; i < size; i++) { + if (lapmap[i] < LM_THRESH) { + bad_sum += 1 / (float)size; + } + } + return (bad_sum > LM_PREC_THRESH); +} \ No newline at end of file diff --git a/selfdrive/camerad/imgproc/utils.h b/selfdrive/camerad/imgproc/utils.h new file mode 100644 index 00000000000000..4928f55a687f98 --- /dev/null +++ b/selfdrive/camerad/imgproc/utils.h @@ -0,0 +1,27 @@ +#pragma once + +#include +#include +#define NUM_SEGMENTS_X 8 +#define NUM_SEGMENTS_Y 6 + +#define ROI_X_MIN 1 +#define ROI_X_MAX 6 +#define ROI_Y_MIN 2 +#define ROI_Y_MAX 3 + +#define LM_THRESH 120 +#define LM_PREC_THRESH 0.9 // 90 perc is blur + +// only apply to QCOM +#define FULL_STRIDE_X 1280 +#define FULL_STRIDE_Y 896 + +#define CONV_LOCAL_WORKSIZE 16 + +const int16_t lapl_conv_krnl[9] = {0, 1, 0, + 1, -4, 1, + 0, 1, 0}; + +uint16_t get_lapmap_one(const int16_t *lap, int x_pitch, int y_pitch); +bool is_blur(const uint16_t *lapmap, const size_t size); diff --git a/selfdrive/camerad/include/media/cam_cpas.h b/selfdrive/camerad/include/media/cam_cpas.h new file mode 100644 index 00000000000000..c5cbac82e71b50 --- /dev/null +++ b/selfdrive/camerad/include/media/cam_cpas.h @@ -0,0 +1,25 @@ +#ifndef __UAPI_CAM_CPAS_H__ +#define __UAPI_CAM_CPAS_H__ + +#include "cam_defs.h" + +#define CAM_FAMILY_CAMERA_SS 1 +#define CAM_FAMILY_CPAS_SS 2 + +/** + * struct cam_cpas_query_cap - CPAS query device capability payload + * + * @camera_family : Camera family type + * @reserved : Reserved field for alignment + * @camera_version : Camera platform version + * @cpas_version : Camera CPAS version within camera platform + * + */ +struct cam_cpas_query_cap { + uint32_t camera_family; + uint32_t reserved; + struct cam_hw_version camera_version; + struct cam_hw_version cpas_version; +}; + +#endif /* __UAPI_CAM_CPAS_H__ */ diff --git a/selfdrive/camerad/include/media/cam_defs.h b/selfdrive/camerad/include/media/cam_defs.h new file mode 100644 index 00000000000000..e006463d2aa6c3 --- /dev/null +++ b/selfdrive/camerad/include/media/cam_defs.h @@ -0,0 +1,477 @@ +#ifndef __UAPI_CAM_DEFS_H__ +#define __UAPI_CAM_DEFS_H__ + +#include +#include +#include + + +/* camera op codes */ +#define CAM_COMMON_OPCODE_BASE 0x100 +#define CAM_QUERY_CAP (CAM_COMMON_OPCODE_BASE + 0x1) +#define CAM_ACQUIRE_DEV (CAM_COMMON_OPCODE_BASE + 0x2) +#define CAM_START_DEV (CAM_COMMON_OPCODE_BASE + 0x3) +#define CAM_STOP_DEV (CAM_COMMON_OPCODE_BASE + 0x4) +#define CAM_CONFIG_DEV (CAM_COMMON_OPCODE_BASE + 0x5) +#define CAM_RELEASE_DEV (CAM_COMMON_OPCODE_BASE + 0x6) +#define CAM_SD_SHUTDOWN (CAM_COMMON_OPCODE_BASE + 0x7) +#define CAM_FLUSH_REQ (CAM_COMMON_OPCODE_BASE + 0x8) +#define CAM_COMMON_OPCODE_MAX (CAM_COMMON_OPCODE_BASE + 0x9) + +#define CAM_EXT_OPCODE_BASE 0x200 +#define CAM_CONFIG_DEV_EXTERNAL (CAM_EXT_OPCODE_BASE + 0x1) + +/* camera handle type */ +#define CAM_HANDLE_USER_POINTER 1 +#define CAM_HANDLE_MEM_HANDLE 2 + +/* Generic Blob CmdBuffer header properties */ +#define CAM_GENERIC_BLOB_CMDBUFFER_SIZE_MASK 0xFFFFFF00 +#define CAM_GENERIC_BLOB_CMDBUFFER_SIZE_SHIFT 8 +#define CAM_GENERIC_BLOB_CMDBUFFER_TYPE_MASK 0xFF +#define CAM_GENERIC_BLOB_CMDBUFFER_TYPE_SHIFT 0 + +/* Command Buffer Types */ +#define CAM_CMD_BUF_DMI 0x1 +#define CAM_CMD_BUF_DMI16 0x2 +#define CAM_CMD_BUF_DMI32 0x3 +#define CAM_CMD_BUF_DMI64 0x4 +#define CAM_CMD_BUF_DIRECT 0x5 +#define CAM_CMD_BUF_INDIRECT 0x6 +#define CAM_CMD_BUF_I2C 0x7 +#define CAM_CMD_BUF_FW 0x8 +#define CAM_CMD_BUF_GENERIC 0x9 +#define CAM_CMD_BUF_LEGACY 0xA + +/** + * enum flush_type_t - Identifies the various flush types + * + * @CAM_FLUSH_TYPE_REQ: Flush specific request + * @CAM_FLUSH_TYPE_ALL: Flush all requests belonging to a context + * @CAM_FLUSH_TYPE_MAX: Max enum to validate flush type + * + */ +enum flush_type_t { + CAM_FLUSH_TYPE_REQ, + CAM_FLUSH_TYPE_ALL, + CAM_FLUSH_TYPE_MAX +}; + +/** + * struct cam_control - Structure used by ioctl control for camera + * + * @op_code: This is the op code for camera control + * @size: Control command size + * @handle_type: User pointer or shared memory handle + * @reserved: Reserved field for 64 bit alignment + * @handle: Control command payload + */ +struct cam_control { + uint32_t op_code; + uint32_t size; + uint32_t handle_type; + uint32_t reserved; + uint64_t handle; +}; + +/* camera IOCTL */ +#define VIDIOC_CAM_CONTROL \ + _IOWR('V', BASE_VIDIOC_PRIVATE, struct cam_control) + +/** + * struct cam_hw_version - Structure for HW version of camera devices + * + * @major : Hardware version major + * @minor : Hardware version minor + * @incr : Hardware version increment + * @reserved : Reserved for 64 bit aligngment + */ +struct cam_hw_version { + uint32_t major; + uint32_t minor; + uint32_t incr; + uint32_t reserved; +}; + +/** + * struct cam_iommu_handle - Structure for IOMMU handles of camera hw devices + * + * @non_secure: Device Non Secure IOMMU handle + * @secure: Device Secure IOMMU handle + * + */ +struct cam_iommu_handle { + int32_t non_secure; + int32_t secure; +}; + +/* camera secure mode */ +#define CAM_SECURE_MODE_NON_SECURE 0 +#define CAM_SECURE_MODE_SECURE 1 + +/* Camera Format Type */ +#define CAM_FORMAT_BASE 0 +#define CAM_FORMAT_MIPI_RAW_6 1 +#define CAM_FORMAT_MIPI_RAW_8 2 +#define CAM_FORMAT_MIPI_RAW_10 3 +#define CAM_FORMAT_MIPI_RAW_12 4 +#define CAM_FORMAT_MIPI_RAW_14 5 +#define CAM_FORMAT_MIPI_RAW_16 6 +#define CAM_FORMAT_MIPI_RAW_20 7 +#define CAM_FORMAT_QTI_RAW_8 8 +#define CAM_FORMAT_QTI_RAW_10 9 +#define CAM_FORMAT_QTI_RAW_12 10 +#define CAM_FORMAT_QTI_RAW_14 11 +#define CAM_FORMAT_PLAIN8 12 +#define CAM_FORMAT_PLAIN16_8 13 +#define CAM_FORMAT_PLAIN16_10 14 +#define CAM_FORMAT_PLAIN16_12 15 +#define CAM_FORMAT_PLAIN16_14 16 +#define CAM_FORMAT_PLAIN16_16 17 +#define CAM_FORMAT_PLAIN32_20 18 +#define CAM_FORMAT_PLAIN64 19 +#define CAM_FORMAT_PLAIN128 20 +#define CAM_FORMAT_ARGB 21 +#define CAM_FORMAT_ARGB_10 22 +#define CAM_FORMAT_ARGB_12 23 +#define CAM_FORMAT_ARGB_14 24 +#define CAM_FORMAT_DPCM_10_6_10 25 +#define CAM_FORMAT_DPCM_10_8_10 26 +#define CAM_FORMAT_DPCM_12_6_12 27 +#define CAM_FORMAT_DPCM_12_8_12 28 +#define CAM_FORMAT_DPCM_14_8_14 29 +#define CAM_FORMAT_DPCM_14_10_14 30 +#define CAM_FORMAT_NV21 31 +#define CAM_FORMAT_NV12 32 +#define CAM_FORMAT_TP10 33 +#define CAM_FORMAT_YUV422 34 +#define CAM_FORMAT_PD8 35 +#define CAM_FORMAT_PD10 36 +#define CAM_FORMAT_UBWC_NV12 37 +#define CAM_FORMAT_UBWC_NV12_4R 38 +#define CAM_FORMAT_UBWC_TP10 39 +#define CAM_FORMAT_UBWC_P010 40 +#define CAM_FORMAT_PLAIN8_SWAP 41 +#define CAM_FORMAT_PLAIN8_10 42 +#define CAM_FORMAT_PLAIN8_10_SWAP 43 +#define CAM_FORMAT_YV12 44 +#define CAM_FORMAT_Y_ONLY 45 +#define CAM_FORMAT_MAX 46 + +/* camera rotaion */ +#define CAM_ROTATE_CW_0_DEGREE 0 +#define CAM_ROTATE_CW_90_DEGREE 1 +#define CAM_RORATE_CW_180_DEGREE 2 +#define CAM_ROTATE_CW_270_DEGREE 3 + +/* camera Color Space */ +#define CAM_COLOR_SPACE_BASE 0 +#define CAM_COLOR_SPACE_BT601_FULL 1 +#define CAM_COLOR_SPACE_BT601625 2 +#define CAM_COLOR_SPACE_BT601525 3 +#define CAM_COLOR_SPACE_BT709 4 +#define CAM_COLOR_SPACE_DEPTH 5 +#define CAM_COLOR_SPACE_MAX 6 + +/* camera buffer direction */ +#define CAM_BUF_INPUT 1 +#define CAM_BUF_OUTPUT 2 +#define CAM_BUF_IN_OUT 3 + +/* camera packet device Type */ +#define CAM_PACKET_DEV_BASE 0 +#define CAM_PACKET_DEV_IMG_SENSOR 1 +#define CAM_PACKET_DEV_ACTUATOR 2 +#define CAM_PACKET_DEV_COMPANION 3 +#define CAM_PACKET_DEV_EEPOM 4 +#define CAM_PACKET_DEV_CSIPHY 5 +#define CAM_PACKET_DEV_OIS 6 +#define CAM_PACKET_DEV_FLASH 7 +#define CAM_PACKET_DEV_FD 8 +#define CAM_PACKET_DEV_JPEG_ENC 9 +#define CAM_PACKET_DEV_JPEG_DEC 10 +#define CAM_PACKET_DEV_VFE 11 +#define CAM_PACKET_DEV_CPP 12 +#define CAM_PACKET_DEV_CSID 13 +#define CAM_PACKET_DEV_ISPIF 14 +#define CAM_PACKET_DEV_IFE 15 +#define CAM_PACKET_DEV_ICP 16 +#define CAM_PACKET_DEV_LRME 17 +#define CAM_PACKET_DEV_MAX 18 + + +/* constants */ +#define CAM_PACKET_MAX_PLANES 3 + +/** + * struct cam_plane_cfg - Plane configuration info + * + * @width: Plane width in pixels + * @height: Plane height in lines + * @plane_stride: Plane stride in pixel + * @slice_height: Slice height in line (not used by ISP) + * @meta_stride: UBWC metadata stride + * @meta_size: UBWC metadata plane size + * @meta_offset: UBWC metadata offset + * @packer_config: UBWC packer config + * @mode_config: UBWC mode config + * @tile_config: UBWC tile config + * @h_init: UBWC horizontal initial coordinate in pixels + * @v_init: UBWC vertical initial coordinate in lines + * + */ +struct cam_plane_cfg { + uint32_t width; + uint32_t height; + uint32_t plane_stride; + uint32_t slice_height; + uint32_t meta_stride; + uint32_t meta_size; + uint32_t meta_offset; + uint32_t packer_config; + uint32_t mode_config; + uint32_t tile_config; + uint32_t h_init; + uint32_t v_init; +}; + +/** + * struct cam_cmd_buf_desc - Command buffer descriptor + * + * @mem_handle: Command buffer handle + * @offset: Command start offset + * @size: Size of the command buffer in bytes + * @length: Used memory in command buffer in bytes + * @type: Type of the command buffer + * @meta_data: Data type for private command buffer + * Between UMD and KMD + * + */ +struct cam_cmd_buf_desc { + int32_t mem_handle; + uint32_t offset; + uint32_t size; + uint32_t length; + uint32_t type; + uint32_t meta_data; +}; + +/** + * struct cam_buf_io_cfg - Buffer io configuration for buffers + * + * @mem_handle: Mem_handle array for the buffers. + * @offsets: Offsets for each planes in the buffer + * @planes: Per plane information + * @width: Main plane width in pixel + * @height: Main plane height in lines + * @format: Format of the buffer + * @color_space: Color space for the buffer + * @color_pattern: Color pattern in the buffer + * @bpp: Bit per pixel + * @rotation: Rotation information for the buffer + * @resource_type: Resource type associated with the buffer + * @fence: Fence handle + * @early_fence: Fence handle for early signal + * @aux_cmd_buf: An auxiliary command buffer that may be + * used for programming the IO + * @direction: Direction of the config + * @batch_size: Batch size in HFR mode + * @subsample_pattern: Subsample pattern. Used in HFR mode. It + * should be consistent with batchSize and + * CAMIF programming. + * @subsample_period: Subsample period. Used in HFR mode. It + * should be consistent with batchSize and + * CAMIF programming. + * @framedrop_pattern: Framedrop pattern + * @framedrop_period: Framedrop period + * @flag: Flags for extra information + * @direction: Buffer direction: input or output + * @padding: Padding for the structure + * + */ +struct cam_buf_io_cfg { + int32_t mem_handle[CAM_PACKET_MAX_PLANES]; + uint32_t offsets[CAM_PACKET_MAX_PLANES]; + struct cam_plane_cfg planes[CAM_PACKET_MAX_PLANES]; + uint32_t format; + uint32_t color_space; + uint32_t color_pattern; + uint32_t bpp; + uint32_t rotation; + uint32_t resource_type; + int32_t fence; + int32_t early_fence; + struct cam_cmd_buf_desc aux_cmd_buf; + uint32_t direction; + uint32_t batch_size; + uint32_t subsample_pattern; + uint32_t subsample_period; + uint32_t framedrop_pattern; + uint32_t framedrop_period; + uint32_t flag; + uint32_t padding; +}; + +/** + * struct cam_packet_header - Camera packet header + * + * @op_code: Camera packet opcode + * @size: Size of the camera packet in bytes + * @request_id: Request id for this camera packet + * @flags: Flags for the camera packet + * @padding: Padding + * + */ +struct cam_packet_header { + uint32_t op_code; + uint32_t size; + uint64_t request_id; + uint32_t flags; + uint32_t padding; +}; + +/** + * struct cam_patch_desc - Patch structure + * + * @dst_buf_hdl: Memory handle for the dest buffer + * @dst_offset: Offset byte in the dest buffer + * @src_buf_hdl: Memory handle for the source buffer + * @src_offset: Offset byte in the source buffer + * + */ +struct cam_patch_desc { + int32_t dst_buf_hdl; + uint32_t dst_offset; + int32_t src_buf_hdl; + uint32_t src_offset; +}; + +/** + * struct cam_packet - Camera packet structure + * + * @header: Camera packet header + * @cmd_buf_offset: Command buffer start offset + * @num_cmd_buf: Number of the command buffer in the packet + * @io_config_offset: Buffer io configuration start offset + * @num_io_configs: Number of the buffer io configurations + * @patch_offset: Patch offset for the patch structure + * @num_patches: Number of the patch structure + * @kmd_cmd_buf_index: Command buffer index which contains extra + * space for the KMD buffer + * @kmd_cmd_buf_offset: Offset from the beginning of the command + * buffer for KMD usage. + * @payload: Camera packet payload + * + */ +struct cam_packet { + struct cam_packet_header header; + uint32_t cmd_buf_offset; + uint32_t num_cmd_buf; + uint32_t io_configs_offset; + uint32_t num_io_configs; + uint32_t patch_offset; + uint32_t num_patches; + uint32_t kmd_cmd_buf_index; + uint32_t kmd_cmd_buf_offset; + uint64_t payload[1]; + +}; + +/** + * struct cam_release_dev_cmd - Control payload for release devices + * + * @session_handle: Session handle for the release + * @dev_handle: Device handle for the release + */ +struct cam_release_dev_cmd { + int32_t session_handle; + int32_t dev_handle; +}; + +/** + * struct cam_start_stop_dev_cmd - Control payload for start/stop device + * + * @session_handle: Session handle for the start/stop command + * @dev_handle: Device handle for the start/stop command + * + */ +struct cam_start_stop_dev_cmd { + int32_t session_handle; + int32_t dev_handle; +}; + +/** + * struct cam_config_dev_cmd - Command payload for configure device + * + * @session_handle: Session handle for the command + * @dev_handle: Device handle for the command + * @offset: Offset byte in the packet handle. + * @packet_handle: Packet memory handle for the actual packet: + * struct cam_packet. + * + */ +struct cam_config_dev_cmd { + int32_t session_handle; + int32_t dev_handle; + uint64_t offset; + uint64_t packet_handle; +}; + +/** + * struct cam_query_cap_cmd - Payload for query device capability + * + * @size: Handle size + * @handle_type: User pointer or shared memory handle + * @caps_handle: Device specific query command payload + * + */ +struct cam_query_cap_cmd { + uint32_t size; + uint32_t handle_type; + uint64_t caps_handle; +}; + +/** + * struct cam_acquire_dev_cmd - Control payload for acquire devices + * + * @session_handle: Session handle for the acquire command + * @dev_handle: Device handle to be returned + * @handle_type: Resource handle type: + * 1 = user pointer, 2 = mem handle + * @num_resources: Number of the resources to be acquired + * @resources_hdl: Resource handle that refers to the actual + * resource array. Each item in this + * array is device specific resource structure + * + */ +struct cam_acquire_dev_cmd { + int32_t session_handle; + int32_t dev_handle; + uint32_t handle_type; + uint32_t num_resources; + uint64_t resource_hdl; +}; + +/** + * struct cam_flush_dev_cmd - Control payload for flush devices + * + * @version: Version + * @session_handle: Session handle for the acquire command + * @dev_handle: Device handle to be returned + * @flush_type: Flush type: + * 0 = flush specific request + * 1 = flush all + * @reserved: Reserved for 64 bit aligngment + * @req_id: Request id that needs to cancel + * + */ +struct cam_flush_dev_cmd { + uint64_t version; + int32_t session_handle; + int32_t dev_handle; + uint32_t flush_type; + uint32_t reserved; + int64_t req_id; +}; + +#endif /* __UAPI_CAM_DEFS_H__ */ diff --git a/selfdrive/camerad/include/media/cam_fd.h b/selfdrive/camerad/include/media/cam_fd.h new file mode 100644 index 00000000000000..8feb6e4da89a79 --- /dev/null +++ b/selfdrive/camerad/include/media/cam_fd.h @@ -0,0 +1,127 @@ +#ifndef __UAPI_CAM_FD_H__ +#define __UAPI_CAM_FD_H__ + +#include "cam_defs.h" + +#define CAM_FD_MAX_FACES 35 +#define CAM_FD_RAW_RESULT_ENTRIES 512 + +/* FD Op Codes */ +#define CAM_PACKET_OPCODES_FD_FRAME_UPDATE 0x0 + +/* FD Command Buffer identifiers */ +#define CAM_FD_CMD_BUFFER_ID_GENERIC 0x0 +#define CAM_FD_CMD_BUFFER_ID_CDM 0x1 +#define CAM_FD_CMD_BUFFER_ID_MAX 0x2 + +/* FD Blob types */ +#define CAM_FD_BLOB_TYPE_SOC_CLOCK_BW_REQUEST 0x0 +#define CAM_FD_BLOB_TYPE_RAW_RESULTS_REQUIRED 0x1 + +/* FD Resource IDs */ +#define CAM_FD_INPUT_PORT_ID_IMAGE 0x0 +#define CAM_FD_INPUT_PORT_ID_MAX 0x1 + +#define CAM_FD_OUTPUT_PORT_ID_RESULTS 0x0 +#define CAM_FD_OUTPUT_PORT_ID_RAW_RESULTS 0x1 +#define CAM_FD_OUTPUT_PORT_ID_WORK_BUFFER 0x2 +#define CAM_FD_OUTPUT_PORT_ID_MAX 0x3 + +/** + * struct cam_fd_soc_clock_bw_request - SOC clock, bandwidth request info + * + * @clock_rate : Clock rate required while processing frame + * @bandwidth : Bandwidth required while processing frame + * @reserved : Reserved for future use + */ +struct cam_fd_soc_clock_bw_request { + uint64_t clock_rate; + uint64_t bandwidth; + uint64_t reserved[4]; +}; + +/** + * struct cam_fd_face - Face properties + * + * @prop1 : Property 1 of face + * @prop2 : Property 2 of face + * @prop3 : Property 3 of face + * @prop4 : Property 4 of face + * + * Do not change this layout, this is inline with how HW writes + * these values directly when the buffer is programmed to HW + */ +struct cam_fd_face { + uint32_t prop1; + uint32_t prop2; + uint32_t prop3; + uint32_t prop4; +}; + +/** + * struct cam_fd_results - FD results layout + * + * @faces : Array of faces with face properties + * @face_count : Number of faces detected + * @reserved : Reserved for alignment + * + * Do not change this layout, this is inline with how HW writes + * these values directly when the buffer is programmed to HW + */ +struct cam_fd_results { + struct cam_fd_face faces[CAM_FD_MAX_FACES]; + uint32_t face_count; + uint32_t reserved[3]; +}; + +/** + * struct cam_fd_hw_caps - Face properties + * + * @core_version : FD core version + * @wrapper_version : FD wrapper version + * @raw_results_available : Whether raw results are available on this HW + * @supported_modes : Modes supported by this HW. + * @reserved : Reserved for future use + */ +struct cam_fd_hw_caps { + struct cam_hw_version core_version; + struct cam_hw_version wrapper_version; + uint32_t raw_results_available; + uint32_t supported_modes; + uint64_t reserved; +}; + +/** + * struct cam_fd_query_cap_cmd - FD Query capabilities information + * + * @device_iommu : FD IOMMU handles + * @cdm_iommu : CDM iommu handles + * @hw_caps : FD HW capabilities + * @reserved : Reserved for alignment + */ +struct cam_fd_query_cap_cmd { + struct cam_iommu_handle device_iommu; + struct cam_iommu_handle cdm_iommu; + struct cam_fd_hw_caps hw_caps; + uint64_t reserved; +}; + +/** + * struct cam_fd_acquire_dev_info - FD acquire device information + * + * @clk_bw_request : SOC clock, bandwidth request + * @priority : Priority for this acquire + * @mode : Mode in which to run FD HW. + * @get_raw_results : Whether this acquire needs face raw results + * while frame processing + * @reserved : Reserved field for 64 bit alignment + */ +struct cam_fd_acquire_dev_info { + struct cam_fd_soc_clock_bw_request clk_bw_request; + uint32_t priority; + uint32_t mode; + uint32_t get_raw_results; + uint32_t reserved[13]; +}; + +#endif /* __UAPI_CAM_FD_H__ */ diff --git a/selfdrive/camerad/include/media/cam_icp.h b/selfdrive/camerad/include/media/cam_icp.h new file mode 100644 index 00000000000000..680d05b630a67e --- /dev/null +++ b/selfdrive/camerad/include/media/cam_icp.h @@ -0,0 +1,179 @@ +#ifndef __UAPI_CAM_ICP_H__ +#define __UAPI_CAM_ICP_H__ + +#include "cam_defs.h" + +/* icp, ipe, bps, cdm(ipe/bps) are used in querycap */ +#define CAM_ICP_DEV_TYPE_A5 1 +#define CAM_ICP_DEV_TYPE_IPE 2 +#define CAM_ICP_DEV_TYPE_BPS 3 +#define CAM_ICP_DEV_TYPE_IPE_CDM 4 +#define CAM_ICP_DEV_TYPE_BPS_CDM 5 +#define CAM_ICP_DEV_TYPE_MAX 5 + +/* definitions needed for icp aquire device */ +#define CAM_ICP_RES_TYPE_BPS 1 +#define CAM_ICP_RES_TYPE_IPE_RT 2 +#define CAM_ICP_RES_TYPE_IPE 3 +#define CAM_ICP_RES_TYPE_MAX 4 + +/* packet opcode types */ +#define CAM_ICP_OPCODE_IPE_UPDATE 0 +#define CAM_ICP_OPCODE_BPS_UPDATE 1 + +/* IPE input port resource type */ +#define CAM_ICP_IPE_INPUT_IMAGE_FULL 0x0 +#define CAM_ICP_IPE_INPUT_IMAGE_DS4 0x1 +#define CAM_ICP_IPE_INPUT_IMAGE_DS16 0x2 +#define CAM_ICP_IPE_INPUT_IMAGE_DS64 0x3 +#define CAM_ICP_IPE_INPUT_IMAGE_FULL_REF 0x4 +#define CAM_ICP_IPE_INPUT_IMAGE_DS4_REF 0x5 +#define CAM_ICP_IPE_INPUT_IMAGE_DS16_REF 0x6 +#define CAM_ICP_IPE_INPUT_IMAGE_DS64_REF 0x7 + +/* IPE output port resource type */ +#define CAM_ICP_IPE_OUTPUT_IMAGE_DISPLAY 0x8 +#define CAM_ICP_IPE_OUTPUT_IMAGE_VIDEO 0x9 +#define CAM_ICP_IPE_OUTPUT_IMAGE_FULL_REF 0xA +#define CAM_ICP_IPE_OUTPUT_IMAGE_DS4_REF 0xB +#define CAM_ICP_IPE_OUTPUT_IMAGE_DS16_REF 0xC +#define CAM_ICP_IPE_OUTPUT_IMAGE_DS64_REF 0xD + +#define CAM_ICP_IPE_IMAGE_MAX 0xE + +/* BPS input port resource type */ +#define CAM_ICP_BPS_INPUT_IMAGE 0x0 + +/* BPS output port resource type */ +#define CAM_ICP_BPS_OUTPUT_IMAGE_FULL 0x1 +#define CAM_ICP_BPS_OUTPUT_IMAGE_DS4 0x2 +#define CAM_ICP_BPS_OUTPUT_IMAGE_DS16 0x3 +#define CAM_ICP_BPS_OUTPUT_IMAGE_DS64 0x4 +#define CAM_ICP_BPS_OUTPUT_IMAGE_STATS_BG 0x5 +#define CAM_ICP_BPS_OUTPUT_IMAGE_STATS_BHIST 0x6 +#define CAM_ICP_BPS_OUTPUT_IMAGE_REG1 0x7 +#define CAM_ICP_BPS_OUTPUT_IMAGE_REG2 0x8 + +#define CAM_ICP_BPS_IO_IMAGES_MAX 0x9 + +/* Command meta types */ +#define CAM_ICP_CMD_META_GENERIC_BLOB 0x1 + +/* Generic blob types */ +#define CAM_ICP_CMD_GENERIC_BLOB_CLK 0x1 +#define CAM_ICP_CMD_GENERIC_BLOB_CFG_IO 0x2 + +/** + * struct cam_icp_clk_bw_request + * + * @budget_ns: Time required to process frame + * @frame_cycles: Frame cycles needed to process the frame + * @rt_flag: Flag to indicate real time stream + * @uncompressed_bw: Bandwidth required to process frame + * @compressed_bw: Compressed bandwidth to process frame + */ +struct cam_icp_clk_bw_request { + uint64_t budget_ns; + uint32_t frame_cycles; + uint32_t rt_flag; + uint64_t uncompressed_bw; + uint64_t compressed_bw; +}; + +/** + * struct cam_icp_dev_ver - Device information for particular hw type + * + * This is used to get device version info of + * ICP, IPE, BPS and CDM related IPE and BPS from firmware + * and use this info in CAM_QUERY_CAP IOCTL + * + * @dev_type: hardware type for the cap info(icp, ipe, bps, cdm(ipe/bps)) + * @reserved: reserved field + * @hw_ver: major, minor and incr values of a device version + */ +struct cam_icp_dev_ver { + uint32_t dev_type; + uint32_t reserved; + struct cam_hw_version hw_ver; +}; + +/** + * struct cam_icp_ver - ICP version info + * + * This strcuture is used for fw and api version + * this is used to get firmware version and api version from firmware + * and use this info in CAM_QUERY_CAP IOCTL + * + * @major: FW version major + * @minor: FW version minor + * @revision: FW version increment + */ +struct cam_icp_ver { + uint32_t major; + uint32_t minor; + uint32_t revision; + uint32_t reserved; +}; + +/** + * struct cam_icp_query_cap_cmd - ICP query device capability payload + * + * @dev_iommu_handle: icp iommu handles for secure/non secure modes + * @cdm_iommu_handle: iommu handles for secure/non secure modes + * @fw_version: firmware version info + * @api_version: api version info + * @num_ipe: number of ipes + * @num_bps: number of bps + * @dev_ver: returned device capability array + */ +struct cam_icp_query_cap_cmd { + struct cam_iommu_handle dev_iommu_handle; + struct cam_iommu_handle cdm_iommu_handle; + struct cam_icp_ver fw_version; + struct cam_icp_ver api_version; + uint32_t num_ipe; + uint32_t num_bps; + struct cam_icp_dev_ver dev_ver[CAM_ICP_DEV_TYPE_MAX]; +}; + +/** + * struct cam_icp_res_info - ICP output resource info + * + * @format: format of the resource + * @width: width in pixels + * @height: height in lines + * @fps: fps + */ +struct cam_icp_res_info { + uint32_t format; + uint32_t width; + uint32_t height; + uint32_t fps; +}; + +/** + * struct cam_icp_acquire_dev_info - An ICP device info + * + * @scratch_mem_size: Output param - size of scratch memory + * @dev_type: device type (IPE_RT/IPE_NON_RT/BPS) + * @io_config_cmd_size: size of IO config command + * @io_config_cmd_handle: IO config command for each acquire + * @secure_mode: camera mode (secure/non secure) + * @chain_info: chaining info of FW device handles + * @in_res: resource info used for clock and bandwidth calculation + * @num_out_res: number of output resources + * @out_res: output resource + */ +struct cam_icp_acquire_dev_info { + uint32_t scratch_mem_size; + uint32_t dev_type; + uint32_t io_config_cmd_size; + int32_t io_config_cmd_handle; + uint32_t secure_mode; + int32_t chain_info; + struct cam_icp_res_info in_res; + uint32_t num_out_res; + struct cam_icp_res_info out_res[1]; +} __attribute__((__packed__)); + +#endif /* __UAPI_CAM_ICP_H__ */ diff --git a/selfdrive/camerad/include/media/cam_isp.h b/selfdrive/camerad/include/media/cam_isp.h new file mode 100644 index 00000000000000..266840d38c2547 --- /dev/null +++ b/selfdrive/camerad/include/media/cam_isp.h @@ -0,0 +1,379 @@ +#ifndef __UAPI_CAM_ISP_H__ +#define __UAPI_CAM_ISP_H__ + +#include "cam_defs.h" +#include "cam_isp_vfe.h" +#include "cam_isp_ife.h" + + +/* ISP driver name */ +#define CAM_ISP_DEV_NAME "cam-isp" + +/* HW type */ +#define CAM_ISP_HW_BASE 0 +#define CAM_ISP_HW_CSID 1 +#define CAM_ISP_HW_VFE 2 +#define CAM_ISP_HW_IFE 3 +#define CAM_ISP_HW_ISPIF 4 +#define CAM_ISP_HW_MAX 5 + +/* Color Pattern */ +#define CAM_ISP_PATTERN_BAYER_RGRGRG 0 +#define CAM_ISP_PATTERN_BAYER_GRGRGR 1 +#define CAM_ISP_PATTERN_BAYER_BGBGBG 2 +#define CAM_ISP_PATTERN_BAYER_GBGBGB 3 +#define CAM_ISP_PATTERN_YUV_YCBYCR 4 +#define CAM_ISP_PATTERN_YUV_YCRYCB 5 +#define CAM_ISP_PATTERN_YUV_CBYCRY 6 +#define CAM_ISP_PATTERN_YUV_CRYCBY 7 +#define CAM_ISP_PATTERN_MAX 8 + +/* Usage Type */ +#define CAM_ISP_RES_USAGE_SINGLE 0 +#define CAM_ISP_RES_USAGE_DUAL 1 +#define CAM_ISP_RES_USAGE_MAX 2 + +/* Resource ID */ +#define CAM_ISP_RES_ID_PORT 0 +#define CAM_ISP_RES_ID_CLK 1 +#define CAM_ISP_RES_ID_MAX 2 + +/* Resource Type - Type of resource for the resource id + * defined in cam_isp_vfe.h, cam_isp_ife.h + */ + +/* Lane Type in input resource for Port */ +#define CAM_ISP_LANE_TYPE_DPHY 0 +#define CAM_ISP_LANE_TYPE_CPHY 1 +#define CAM_ISP_LANE_TYPE_MAX 2 + +/* ISP Resurce Composite Group ID */ +#define CAM_ISP_RES_COMP_GROUP_NONE 0 +#define CAM_ISP_RES_COMP_GROUP_ID_0 1 +#define CAM_ISP_RES_COMP_GROUP_ID_1 2 +#define CAM_ISP_RES_COMP_GROUP_ID_2 3 +#define CAM_ISP_RES_COMP_GROUP_ID_3 4 +#define CAM_ISP_RES_COMP_GROUP_ID_4 5 +#define CAM_ISP_RES_COMP_GROUP_ID_5 6 +#define CAM_ISP_RES_COMP_GROUP_ID_MAX 6 + +/* ISP packet opcode for ISP */ +#define CAM_ISP_PACKET_OP_BASE 0 +#define CAM_ISP_PACKET_INIT_DEV 1 +#define CAM_ISP_PACKET_UPDATE_DEV 2 +#define CAM_ISP_PACKET_OP_MAX 3 + +/* ISP packet meta_data type for command buffer */ +#define CAM_ISP_PACKET_META_BASE 0 +#define CAM_ISP_PACKET_META_LEFT 1 +#define CAM_ISP_PACKET_META_RIGHT 2 +#define CAM_ISP_PACKET_META_COMMON 3 +#define CAM_ISP_PACKET_META_DMI_LEFT 4 +#define CAM_ISP_PACKET_META_DMI_RIGHT 5 +#define CAM_ISP_PACKET_META_DMI_COMMON 6 +#define CAM_ISP_PACKET_META_CLOCK 7 +#define CAM_ISP_PACKET_META_CSID 8 +#define CAM_ISP_PACKET_META_DUAL_CONFIG 9 +#define CAM_ISP_PACKET_META_GENERIC_BLOB_LEFT 10 +#define CAM_ISP_PACKET_META_GENERIC_BLOB_RIGHT 11 +#define CAM_ISP_PACKET_META_GENERIC_BLOB_COMMON 12 + +/* DSP mode */ +#define CAM_ISP_DSP_MODE_NONE 0 +#define CAM_ISP_DSP_MODE_ONE_WAY 1 +#define CAM_ISP_DSP_MODE_ROUND 2 + +/* ISP Generic Cmd Buffer Blob types */ +#define CAM_ISP_GENERIC_BLOB_TYPE_HFR_CONFIG 0 +#define CAM_ISP_GENERIC_BLOB_TYPE_CLOCK_CONFIG 1 +#define CAM_ISP_GENERIC_BLOB_TYPE_BW_CONFIG 2 + +/* Query devices */ +/** + * struct cam_isp_dev_cap_info - A cap info for particular hw type + * + * @hw_type: Hardware type for the cap info + * @reserved: reserved field for alignment + * @hw_version: Hardware version + * + */ +struct cam_isp_dev_cap_info { + uint32_t hw_type; + uint32_t reserved; + struct cam_hw_version hw_version; +}; + +/** + * struct cam_isp_query_cap_cmd - ISP query device capability payload + * + * @device_iommu: returned iommu handles for device + * @cdm_iommu: returned iommu handles for cdm + * @num_dev: returned number of device capabilities + * @reserved: reserved field for alignment + * @dev_caps: returned device capability array + * + */ +struct cam_isp_query_cap_cmd { + struct cam_iommu_handle device_iommu; + struct cam_iommu_handle cdm_iommu; + int32_t num_dev; + uint32_t reserved; + struct cam_isp_dev_cap_info dev_caps[CAM_ISP_HW_MAX]; +}; + +/* Acquire Device */ +/** + * struct cam_isp_out_port_info - An output port resource info + * + * @res_type: output resource type defined in file + * cam_isp_vfe.h or cam_isp_ife.h + * @format: output format of the resource + * @wdith: output width in pixels + * @height: output height in lines + * @comp_grp_id: composite group id for the resource. + * @split_point: split point in pixels for the dual VFE. + * @secure_mode: flag to tell if output should be run in secure + * mode or not. See cam_defs.h for definition + * @reserved: reserved field for alignment + * + */ +struct cam_isp_out_port_info { + uint32_t res_type; + uint32_t format; + uint32_t width; + uint32_t height; + uint32_t comp_grp_id; + uint32_t split_point; + uint32_t secure_mode; + uint32_t reserved; +}; + +/** + * struct cam_isp_in_port_info - An input port resource info + * + * @res_type: input resource type define in file + * cam_isp_vfe.h or cam_isp_ife.h + * @lane_type: lane type: c-phy or d-phy. + * @lane_num: active lane number + * @lane_cfg: lane configurations: 4 bits per lane + * @vc: input virtual channel number + * @dt: input data type number + * @format: input format + * @test_pattern: test pattern for the testgen + * @usage_type: whether dual vfe is required + * @left_start: left input start offset in pixels + * @left_stop: left input stop offset in pixels + * @left_width: left input width in pixels + * @right_start: right input start offset in pixels. + * Only for Dual VFE + * @right_stop: right input stop offset in pixels. + * Only for Dual VFE + * @right_width: right input width in pixels. + * Only for dual VFE + * @line_start: top of the line number + * @line_stop: bottome of the line number + * @height: input height in lines + * @pixel_clk; sensor output clock + * @batch_size: batch size for HFR mode + * @dsp_mode: DSP stream mode (Defines as CAM_ISP_DSP_MODE_*) + * @hbi_cnt: HBI count for the camif input + * @reserved: Reserved field for alignment + * @num_out_res: number of the output resource associated + * @data: payload that contains the output resources + * + */ +struct cam_isp_in_port_info { + uint32_t res_type; + uint32_t lane_type; + uint32_t lane_num; + uint32_t lane_cfg; + uint32_t vc; + uint32_t dt; + uint32_t format; + uint32_t test_pattern; + uint32_t usage_type; + uint32_t left_start; + uint32_t left_stop; + uint32_t left_width; + uint32_t right_start; + uint32_t right_stop; + uint32_t right_width; + uint32_t line_start; + uint32_t line_stop; + uint32_t height; + uint32_t pixel_clk; + uint32_t batch_size; + uint32_t dsp_mode; + uint32_t hbi_cnt; + uint32_t custom_csid; + uint32_t reserved; + uint32_t num_out_res; + struct cam_isp_out_port_info data[1]; +}; + +/** + * struct cam_isp_resource - A resource bundle + * + * @resoruce_id: resource id for the resource bundle + * @length: length of the while resource blob + * @handle_type: type of the resource handle + * @reserved: reserved field for alignment + * @res_hdl: resource handle that points to the + * resource array; + * + */ +struct cam_isp_resource { + uint32_t resource_id; + uint32_t length; + uint32_t handle_type; + uint32_t reserved; + uint64_t res_hdl; +}; + +/** + * struct cam_isp_port_hfr_config - HFR configuration for this port + * + * @resource_type: Resource type + * @subsample_pattern: Subsample pattern. Used in HFR mode. It + * should be consistent with batchSize and + * CAMIF programming. + * @subsample_period: Subsample period. Used in HFR mode. It + * should be consistent with batchSize and + * CAMIF programming. + * @framedrop_pattern: Framedrop pattern + * @framedrop_period: Framedrop period + * @reserved: Reserved for alignment + */ +struct cam_isp_port_hfr_config { + uint32_t resource_type; + uint32_t subsample_pattern; + uint32_t subsample_period; + uint32_t framedrop_pattern; + uint32_t framedrop_period; + uint32_t reserved; +} __attribute__((packed)); + +/** + * struct cam_isp_resource_hfr_config - Resource HFR configuration + * + * @num_ports: Number of ports + * @reserved: Reserved for alignment + * @port_hfr_config: HFR configuration for each IO port + */ +struct cam_isp_resource_hfr_config { + uint32_t num_ports; + uint32_t reserved; + struct cam_isp_port_hfr_config port_hfr_config[1]; +} __attribute__((packed)); + +/** + * struct cam_isp_dual_split_params - dual isp spilt parameters + * + * @split_point: Split point information x, where (0 < x < width) + * left ISP's input ends at x + righ padding and + * Right ISP's input starts at x - left padding + * @right_padding: Padding added past the split point for left + * ISP's input + * @left_padding: Padding added before split point for right + * ISP's input + * @reserved: Reserved filed for alignment + * + */ +struct cam_isp_dual_split_params { + uint32_t split_point; + uint32_t right_padding; + uint32_t left_padding; + uint32_t reserved; +}; + +/** + * struct cam_isp_dual_stripe_config - stripe config per bus client + * + * @offset: Start horizontal offset relative to + * output buffer + * In UBWC mode, this value indicates the H_INIT + * value in pixel + * @width: Width of the stripe in bytes + * @tileconfig Ubwc meta tile config. Contain the partial + * tile info + * @port_id: port id of ISP output + * + */ +struct cam_isp_dual_stripe_config { + uint32_t offset; + uint32_t width; + uint32_t tileconfig; + uint32_t port_id; +}; + +/** + * struct cam_isp_dual_config - dual isp configuration + * + * @num_ports Number of isp output ports + * @reserved Reserved field for alignment + * @split_params: Inpput split parameters + * @stripes: Stripe information + * + */ +struct cam_isp_dual_config { + uint32_t num_ports; + uint32_t reserved; + struct cam_isp_dual_split_params split_params; + struct cam_isp_dual_stripe_config stripes[1]; +} __attribute__((packed)); + +/** + * struct cam_isp_clock_config - Clock configuration + * + * @usage_type: Usage type (Single/Dual) + * @num_rdi: Number of RDI votes + * @left_pix_hz: Pixel Clock for Left ISP + * @right_pix_hz: Pixel Clock for Right ISP, valid only if Dual + * @rdi_hz: RDI Clock. ISP clock will be max of RDI and + * PIX clocks. For a particular context which ISP + * HW the RDI is allocated to is not known to UMD. + * Hence pass the clock and let KMD decide. + */ +struct cam_isp_clock_config { + uint32_t usage_type; + uint32_t num_rdi; + uint64_t left_pix_hz; + uint64_t right_pix_hz; + uint64_t rdi_hz[1]; +} __attribute__((packed)); + +/** + * struct cam_isp_bw_vote - Bandwidth vote information + * + * @resource_id: Resource ID + * @reserved: Reserved field for alignment + * @cam_bw_bps: Bandwidth vote for CAMNOC + * @ext_bw_bps: Bandwidth vote for path-to-DDR after CAMNOC + */ + +struct cam_isp_bw_vote { + uint32_t resource_id; + uint32_t reserved; + uint64_t cam_bw_bps; + uint64_t ext_bw_bps; +} __attribute__((packed)); + +/** + * struct cam_isp_bw_config - Bandwidth configuration + * + * @usage_type: Usage type (Single/Dual) + * @num_rdi: Number of RDI votes + * @left_pix_vote: Bandwidth vote for left ISP + * @right_pix_vote: Bandwidth vote for right ISP + * @rdi_vote: RDI bandwidth requirements + */ + +struct cam_isp_bw_config { + uint32_t usage_type; + uint32_t num_rdi; + struct cam_isp_bw_vote left_pix_vote; + struct cam_isp_bw_vote right_pix_vote; + struct cam_isp_bw_vote rdi_vote[1]; +} __attribute__((packed)); + +#endif /* __UAPI_CAM_ISP_H__ */ diff --git a/selfdrive/camerad/include/media/cam_isp_ife.h b/selfdrive/camerad/include/media/cam_isp_ife.h new file mode 100644 index 00000000000000..f5e72813fc0d2d --- /dev/null +++ b/selfdrive/camerad/include/media/cam_isp_ife.h @@ -0,0 +1,39 @@ +#ifndef __UAPI_CAM_ISP_IFE_H__ +#define __UAPI_CAM_ISP_IFE_H__ + +/* IFE output port resource type (global unique)*/ +#define CAM_ISP_IFE_OUT_RES_BASE 0x3000 + +#define CAM_ISP_IFE_OUT_RES_FULL (CAM_ISP_IFE_OUT_RES_BASE + 0) +#define CAM_ISP_IFE_OUT_RES_DS4 (CAM_ISP_IFE_OUT_RES_BASE + 1) +#define CAM_ISP_IFE_OUT_RES_DS16 (CAM_ISP_IFE_OUT_RES_BASE + 2) +#define CAM_ISP_IFE_OUT_RES_RAW_DUMP (CAM_ISP_IFE_OUT_RES_BASE + 3) +#define CAM_ISP_IFE_OUT_RES_FD (CAM_ISP_IFE_OUT_RES_BASE + 4) +#define CAM_ISP_IFE_OUT_RES_PDAF (CAM_ISP_IFE_OUT_RES_BASE + 5) +#define CAM_ISP_IFE_OUT_RES_RDI_0 (CAM_ISP_IFE_OUT_RES_BASE + 6) +#define CAM_ISP_IFE_OUT_RES_RDI_1 (CAM_ISP_IFE_OUT_RES_BASE + 7) +#define CAM_ISP_IFE_OUT_RES_RDI_2 (CAM_ISP_IFE_OUT_RES_BASE + 8) +#define CAM_ISP_IFE_OUT_RES_RDI_3 (CAM_ISP_IFE_OUT_RES_BASE + 9) +#define CAM_ISP_IFE_OUT_RES_STATS_HDR_BE (CAM_ISP_IFE_OUT_RES_BASE + 10) +#define CAM_ISP_IFE_OUT_RES_STATS_HDR_BHIST (CAM_ISP_IFE_OUT_RES_BASE + 11) +#define CAM_ISP_IFE_OUT_RES_STATS_TL_BG (CAM_ISP_IFE_OUT_RES_BASE + 12) +#define CAM_ISP_IFE_OUT_RES_STATS_BF (CAM_ISP_IFE_OUT_RES_BASE + 13) +#define CAM_ISP_IFE_OUT_RES_STATS_AWB_BG (CAM_ISP_IFE_OUT_RES_BASE + 14) +#define CAM_ISP_IFE_OUT_RES_STATS_BHIST (CAM_ISP_IFE_OUT_RES_BASE + 15) +#define CAM_ISP_IFE_OUT_RES_STATS_RS (CAM_ISP_IFE_OUT_RES_BASE + 16) +#define CAM_ISP_IFE_OUT_RES_STATS_CS (CAM_ISP_IFE_OUT_RES_BASE + 17) +#define CAM_ISP_IFE_OUT_RES_STATS_IHIST (CAM_ISP_IFE_OUT_RES_BASE + 18) +#define CAM_ISP_IFE_OUT_RES_MAX (CAM_ISP_IFE_OUT_RES_BASE + 19) + + +/* IFE input port resource type (global unique) */ +#define CAM_ISP_IFE_IN_RES_BASE 0x4000 + +#define CAM_ISP_IFE_IN_RES_TPG (CAM_ISP_IFE_IN_RES_BASE + 0) +#define CAM_ISP_IFE_IN_RES_PHY_0 (CAM_ISP_IFE_IN_RES_BASE + 1) +#define CAM_ISP_IFE_IN_RES_PHY_1 (CAM_ISP_IFE_IN_RES_BASE + 2) +#define CAM_ISP_IFE_IN_RES_PHY_2 (CAM_ISP_IFE_IN_RES_BASE + 3) +#define CAM_ISP_IFE_IN_RES_PHY_3 (CAM_ISP_IFE_IN_RES_BASE + 4) +#define CAM_ISP_IFE_IN_RES_MAX (CAM_ISP_IFE_IN_RES_BASE + 5) + +#endif /* __UAPI_CAM_ISP_IFE_H__ */ diff --git a/selfdrive/camerad/include/media/cam_isp_vfe.h b/selfdrive/camerad/include/media/cam_isp_vfe.h new file mode 100644 index 00000000000000..e48db2f98d91c2 --- /dev/null +++ b/selfdrive/camerad/include/media/cam_isp_vfe.h @@ -0,0 +1,44 @@ +#ifndef __UAPI_CAM_ISP_VFE_H__ +#define __UAPI_CAM_ISP_VFE_H__ + +/* VFE output port resource type (global unique) */ +#define CAM_ISP_VFE_OUT_RES_BASE 0x1000 + +#define CAM_ISP_VFE_OUT_RES_ENC (CAM_ISP_VFE_OUT_RES_BASE + 0) +#define CAM_ISP_VFE_OUT_RES_VIEW (CAM_ISP_VFE_OUT_RES_BASE + 1) +#define CAM_ISP_VFE_OUT_RES_VID (CAM_ISP_VFE_OUT_RES_BASE + 2) +#define CAM_ISP_VFE_OUT_RES_RDI_0 (CAM_ISP_VFE_OUT_RES_BASE + 3) +#define CAM_ISP_VFE_OUT_RES_RDI_1 (CAM_ISP_VFE_OUT_RES_BASE + 4) +#define CAM_ISP_VFE_OUT_RES_RDI_2 (CAM_ISP_VFE_OUT_RES_BASE + 5) +#define CAM_ISP_VFE_OUT_RES_RDI_3 (CAM_ISP_VFE_OUT_RES_BASE + 6) +#define CAM_ISP_VFE_OUT_RES_STATS_AEC (CAM_ISP_VFE_OUT_RES_BASE + 7) +#define CAM_ISP_VFE_OUT_RES_STATS_AF (CAM_ISP_VFE_OUT_RES_BASE + 8) +#define CAM_ISP_VFE_OUT_RES_STATS_AWB (CAM_ISP_VFE_OUT_RES_BASE + 9) +#define CAM_ISP_VFE_OUT_RES_STATS_RS (CAM_ISP_VFE_OUT_RES_BASE + 10) +#define CAM_ISP_VFE_OUT_RES_STATS_CS (CAM_ISP_VFE_OUT_RES_BASE + 11) +#define CAM_ISP_VFE_OUT_RES_STATS_IHIST (CAM_ISP_VFE_OUT_RES_BASE + 12) +#define CAM_ISP_VFE_OUT_RES_STATS_SKIN (CAM_ISP_VFE_OUT_RES_BASE + 13) +#define CAM_ISP_VFE_OUT_RES_STATS_BG (CAM_ISP_VFE_OUT_RES_BASE + 14) +#define CAM_ISP_VFE_OUT_RES_STATS_BF (CAM_ISP_VFE_OUT_RES_BASE + 15) +#define CAM_ISP_VFE_OUT_RES_STATS_BE (CAM_ISP_VFE_OUT_RES_BASE + 16) +#define CAM_ISP_VFE_OUT_RES_STATS_BHIST (CAM_ISP_VFE_OUT_RES_BASE + 17) +#define CAM_ISP_VFE_OUT_RES_STATS_BF_SCALE (CAM_ISP_VFE_OUT_RES_BASE + 18) +#define CAM_ISP_VFE_OUT_RES_STATS_HDR_BE (CAM_ISP_VFE_OUT_RES_BASE + 19) +#define CAM_ISP_VFE_OUT_RES_STATS_HDR_BHIST (CAM_ISP_VFE_OUT_RES_BASE + 20) +#define CAM_ISP_VFE_OUT_RES_STATS_AEC_BG (CAM_ISP_VFE_OUT_RES_BASE + 21) +#define CAM_ISP_VFE_OUT_RES_CAMIF_RAW (CAM_ISP_VFE_OUT_RES_BASE + 22) +#define CAM_ISP_VFE_OUT_RES_IDEAL_RAW (CAM_ISP_VFE_OUT_RES_BASE + 23) +#define CAM_ISP_VFE_OUT_RES_MAX (CAM_ISP_VFE_OUT_RES_BASE + 24) + +/* VFE input port_ resource type (global unique) */ +#define CAM_ISP_VFE_IN_RES_BASE 0x2000 + +#define CAM_ISP_VFE_IN_RES_TPG (CAM_ISP_VFE_IN_RES_BASE + 0) +#define CAM_ISP_VFE_IN_RES_PHY_0 (CAM_ISP_VFE_IN_RES_BASE + 1) +#define CAM_ISP_VFE_IN_RES_PHY_1 (CAM_ISP_VFE_IN_RES_BASE + 2) +#define CAM_ISP_VFE_IN_RES_PHY_2 (CAM_ISP_VFE_IN_RES_BASE + 3) +#define CAM_ISP_VFE_IN_RES_PHY_3 (CAM_ISP_VFE_IN_RES_BASE + 4) +#define CAM_ISP_VFE_IN_RES_FE (CAM_ISP_VFE_IN_RES_BASE + 5) +#define CAM_ISP_VFE_IN_RES_MAX (CAM_ISP_VFE_IN_RES_BASE + 6) + +#endif /* __UAPI_CAM_ISP_VFE_H__ */ diff --git a/selfdrive/camerad/include/media/cam_jpeg.h b/selfdrive/camerad/include/media/cam_jpeg.h new file mode 100644 index 00000000000000..f3082f3bfe295b --- /dev/null +++ b/selfdrive/camerad/include/media/cam_jpeg.h @@ -0,0 +1,117 @@ +#ifndef __UAPI_CAM_JPEG_H__ +#define __UAPI_CAM_JPEG_H__ + +#include "cam_defs.h" + +/* enc, dma, cdm(enc/dma) are used in querycap */ +#define CAM_JPEG_DEV_TYPE_ENC 0 +#define CAM_JPEG_DEV_TYPE_DMA 1 +#define CAM_JPEG_DEV_TYPE_MAX 2 + +#define CAM_JPEG_NUM_DEV_PER_RES_MAX 1 + +/* definitions needed for jpeg aquire device */ +#define CAM_JPEG_RES_TYPE_ENC 0 +#define CAM_JPEG_RES_TYPE_DMA 1 +#define CAM_JPEG_RES_TYPE_MAX 2 + +/* packet opcode types */ +#define CAM_JPEG_OPCODE_ENC_UPDATE 0 +#define CAM_JPEG_OPCODE_DMA_UPDATE 1 + +/* ENC input port resource type */ +#define CAM_JPEG_ENC_INPUT_IMAGE 0x0 + +/* ENC output port resource type */ +#define CAM_JPEG_ENC_OUTPUT_IMAGE 0x1 + +#define CAM_JPEG_ENC_IO_IMAGES_MAX 0x2 + +/* DMA input port resource type */ +#define CAM_JPEG_DMA_INPUT_IMAGE 0x0 + +/* DMA output port resource type */ +#define CAM_JPEG_DMA_OUTPUT_IMAGE 0x1 + +#define CAM_JPEG_DMA_IO_IMAGES_MAX 0x2 + +#define CAM_JPEG_IMAGE_MAX 0x2 + +/** + * struct cam_jpeg_dev_ver - Device information for particular hw type + * + * This is used to get device version info of JPEG ENC, JPEG DMA + * from hardware and use this info in CAM_QUERY_CAP IOCTL + * + * @size : Size of struct passed + * @dev_type: Hardware type for the cap info(jpeg enc, jpeg dma) + * @hw_ver: Major, minor and incr values of a device version + */ +struct cam_jpeg_dev_ver { + uint32_t size; + uint32_t dev_type; + struct cam_hw_version hw_ver; +}; + +/** + * struct cam_jpeg_query_cap_cmd - JPEG query device capability payload + * + * @dev_iommu_handle: Jpeg iommu handles for secure/non secure + * modes + * @cdm_iommu_handle: Iommu handles for secure/non secure modes + * @num_enc: Number of encoder + * @num_dma: Number of dma + * @dev_ver: Returned device capability array + */ +struct cam_jpeg_query_cap_cmd { + struct cam_iommu_handle dev_iommu_handle; + struct cam_iommu_handle cdm_iommu_handle; + uint32_t num_enc; + uint32_t num_dma; + struct cam_jpeg_dev_ver dev_ver[CAM_JPEG_DEV_TYPE_MAX]; +}; + +/** + * struct cam_jpeg_res_info - JPEG output resource info + * + * @format: Format of the resource + * @width: Width in pixels + * @height: Height in lines + * @fps: Fps + */ +struct cam_jpeg_res_info { + uint32_t format; + uint32_t width; + uint32_t height; + uint32_t fps; +}; + +/** + * struct cam_jpeg_acquire_dev_info - An JPEG device info + * + * @dev_type: Device type (ENC/DMA) + * @reserved: Reserved Bytes + * @in_res: In resource info + * @in_res: Iut resource info + */ +struct cam_jpeg_acquire_dev_info { + uint32_t dev_type; + uint32_t reserved; + struct cam_jpeg_res_info in_res; + struct cam_jpeg_res_info out_res; +}; + +/** + * struct cam_jpeg_config_inout_param_info - JPEG Config time + * input output params + * + * @clk_index: Input Param- clock selection index.(-1 default) + * @output_size: Output Param - jpeg encode/dma output size in + * bytes + */ +struct cam_jpeg_config_inout_param_info { + int32_t clk_index; + int32_t output_size; +}; + +#endif /* __UAPI_CAM_JPEG_H__ */ diff --git a/selfdrive/camerad/include/media/cam_lrme.h b/selfdrive/camerad/include/media/cam_lrme.h new file mode 100644 index 00000000000000..97d957835ee3b7 --- /dev/null +++ b/selfdrive/camerad/include/media/cam_lrme.h @@ -0,0 +1,65 @@ +#ifndef __UAPI_CAM_LRME_H__ +#define __UAPI_CAM_LRME_H__ + +#include "cam_defs.h" + +/* LRME Resource Types */ + +enum CAM_LRME_IO_TYPE { + CAM_LRME_IO_TYPE_TAR, + CAM_LRME_IO_TYPE_REF, + CAM_LRME_IO_TYPE_RES, + CAM_LRME_IO_TYPE_DS2, +}; + +#define CAM_LRME_INPUT_PORT_TYPE_TAR (1 << 0) +#define CAM_LRME_INPUT_PORT_TYPE_REF (1 << 1) + +#define CAM_LRME_OUTPUT_PORT_TYPE_DS2 (1 << 0) +#define CAM_LRME_OUTPUT_PORT_TYPE_RES (1 << 1) + +#define CAM_LRME_DEV_MAX 1 + + +struct cam_lrme_hw_version { + uint32_t gen; + uint32_t rev; + uint32_t step; +}; + +struct cam_lrme_dev_cap { + struct cam_lrme_hw_version clc_hw_version; + struct cam_lrme_hw_version bus_rd_hw_version; + struct cam_lrme_hw_version bus_wr_hw_version; + struct cam_lrme_hw_version top_hw_version; + struct cam_lrme_hw_version top_titan_version; +}; + +/** + * struct cam_lrme_query_cap_cmd - LRME query device capability payload + * + * @dev_iommu_handle: LRME iommu handles for secure/non secure + * modes + * @cdm_iommu_handle: Iommu handles for secure/non secure modes + * @num_devices: number of hardware devices + * @dev_caps: Returned device capability array + */ +struct cam_lrme_query_cap_cmd { + struct cam_iommu_handle device_iommu; + struct cam_iommu_handle cdm_iommu; + uint32_t num_devices; + struct cam_lrme_dev_cap dev_caps[CAM_LRME_DEV_MAX]; +}; + +struct cam_lrme_soc_info { + uint64_t clock_rate; + uint64_t bandwidth; + uint64_t reserved[4]; +}; + +struct cam_lrme_acquire_args { + struct cam_lrme_soc_info lrme_soc_info; +}; + +#endif /* __UAPI_CAM_LRME_H__ */ + diff --git a/selfdrive/camerad/include/media/cam_req_mgr.h b/selfdrive/camerad/include/media/cam_req_mgr.h new file mode 100644 index 00000000000000..ae65649964ff0a --- /dev/null +++ b/selfdrive/camerad/include/media/cam_req_mgr.h @@ -0,0 +1,436 @@ +#ifndef __UAPI_LINUX_CAM_REQ_MGR_H +#define __UAPI_LINUX_CAM_REQ_MGR_H + +#include +#include +#include +#include +#include + +#define CAM_REQ_MGR_VNODE_NAME "cam-req-mgr-devnode" + +#define CAM_DEVICE_TYPE_BASE (MEDIA_ENT_F_OLD_BASE) +#define CAM_VNODE_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE) +#define CAM_SENSOR_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 1) +#define CAM_IFE_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 2) +#define CAM_ICP_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 3) +#define CAM_LRME_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 4) +#define CAM_JPEG_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 5) +#define CAM_FD_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 6) +#define CAM_CPAS_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 7) +#define CAM_CSIPHY_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 8) +#define CAM_ACTUATOR_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 9) +#define CAM_CCI_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 10) +#define CAM_FLASH_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 11) +#define CAM_EEPROM_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 12) +#define CAM_OIS_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 13) + +/* cam_req_mgr hdl info */ +#define CAM_REQ_MGR_HDL_IDX_POS 8 +#define CAM_REQ_MGR_HDL_IDX_MASK ((1 << CAM_REQ_MGR_HDL_IDX_POS) - 1) +#define CAM_REQ_MGR_GET_HDL_IDX(hdl) (hdl & CAM_REQ_MGR_HDL_IDX_MASK) + +/** + * Max handles supported by cam_req_mgr + * It includes both session and device handles + */ +#define CAM_REQ_MGR_MAX_HANDLES 64 +#define MAX_LINKS_PER_SESSION 2 + +/* V4L event type which user space will subscribe to */ +#define V4L_EVENT_CAM_REQ_MGR_EVENT (V4L2_EVENT_PRIVATE_START + 0) + +/* Specific event ids to get notified in user space */ +#define V4L_EVENT_CAM_REQ_MGR_SOF 0 +#define V4L_EVENT_CAM_REQ_MGR_ERROR 1 +#define V4L_EVENT_CAM_REQ_MGR_SOF_BOOT_TS 2 + +/* SOF Event status */ +#define CAM_REQ_MGR_SOF_EVENT_SUCCESS 0 +#define CAM_REQ_MGR_SOF_EVENT_ERROR 1 + +/* Link control operations */ +#define CAM_REQ_MGR_LINK_ACTIVATE 0 +#define CAM_REQ_MGR_LINK_DEACTIVATE 1 + +/** + * Request Manager : flush_type + * @CAM_REQ_MGR_FLUSH_TYPE_ALL: Req mgr will remove all the pending + * requests from input/processing queue. + * @CAM_REQ_MGR_FLUSH_TYPE_CANCEL_REQ: Req mgr will remove only particular + * request id from input/processing queue. + * @CAM_REQ_MGR_FLUSH_TYPE_MAX: Max number of the flush type + * @opcode: CAM_REQ_MGR_FLUSH_REQ + */ +#define CAM_REQ_MGR_FLUSH_TYPE_ALL 0 +#define CAM_REQ_MGR_FLUSH_TYPE_CANCEL_REQ 1 +#define CAM_REQ_MGR_FLUSH_TYPE_MAX 2 + +/** + * Request Manager : Sync Mode type + * @CAM_REQ_MGR_SYNC_MODE_NO_SYNC: Req mgr will apply non-sync mode for this + * request. + * @CAM_REQ_MGR_SYNC_MODE_SYNC: Req mgr will apply sync mode for this request. + */ +#define CAM_REQ_MGR_SYNC_MODE_NO_SYNC 0 +#define CAM_REQ_MGR_SYNC_MODE_SYNC 1 + +/** + * struct cam_req_mgr_event_data + * @session_hdl: session handle + * @link_hdl: link handle + * @frame_id: frame id + * @reserved: reserved for 64 bit aligngment + * @req_id: request id + * @tv_sec: timestamp in seconds + * @tv_usec: timestamp in micro seconds + */ +struct cam_req_mgr_event_data { + int32_t session_hdl; + int32_t link_hdl; + int32_t frame_id; + int32_t reserved; + int64_t req_id; + uint64_t tv_sec; + uint64_t tv_usec; +}; + +/** + * struct cam_req_mgr_session_info + * @session_hdl: In/Output param - session_handle + * @opcode1: CAM_REQ_MGR_CREATE_SESSION + * @opcode2: CAM_REQ_MGR_DESTROY_SESSION + */ +struct cam_req_mgr_session_info { + int32_t session_hdl; + int32_t reserved; +}; + +/** + * struct cam_req_mgr_link_info + * @session_hdl: Input param - Identifier for CSL session + * @num_devices: Input Param - Num of devices to be linked + * @dev_hdls: Input param - List of device handles to be linked + * @link_hdl: Output Param -Identifier for link + * @opcode: CAM_REQ_MGR_LINK + */ +struct cam_req_mgr_link_info { + int32_t session_hdl; + uint32_t num_devices; + int32_t dev_hdls[CAM_REQ_MGR_MAX_HANDLES]; + int32_t link_hdl; +}; + +/** + * struct cam_req_mgr_unlink_info + * @session_hdl: input param - session handle + * @link_hdl: input param - link handle + * @opcode: CAM_REQ_MGR_UNLINK + */ +struct cam_req_mgr_unlink_info { + int32_t session_hdl; + int32_t link_hdl; +}; + +/** + * struct cam_req_mgr_flush_info + * @brief: User can tell drivers to flush a particular request id or + * flush all requests from its pending processing queue. Flush is a + * blocking call and driver shall ensure all requests are flushed + * before returning. + * @session_hdl: Input param - Identifier for CSL session + * @link_hdl: Input Param -Identifier for link + * @flush_type: User can cancel a particular req id or can flush + * all requests in queue + * @reserved: reserved for 64 bit aligngment + * @req_id: field is valid only if flush type is cancel request + * for flush all this field value is not considered. + * @opcode: CAM_REQ_MGR_FLUSH_REQ + */ +struct cam_req_mgr_flush_info { + int32_t session_hdl; + int32_t link_hdl; + uint32_t flush_type; + uint32_t reserved; + int64_t req_id; +}; + +/** struct cam_req_mgr_sched_info + * @session_hdl: Input param - Identifier for CSL session + * @link_hdl: Input Param -Identifier for link + * inluding itself. + * @bubble_enable: Input Param - Cam req mgr will do bubble recovery if this + * flag is set. + * @sync_mode: Type of Sync mode for this request + * @req_id: Input Param - Request Id from which all requests will be flushed + */ +struct cam_req_mgr_sched_request { + int32_t session_hdl; + int32_t link_hdl; + int32_t bubble_enable; + int32_t sync_mode; + int64_t req_id; +}; + +/** + * struct cam_req_mgr_sync_mode + * @session_hdl: Input param - Identifier for CSL session + * @sync_mode: Input Param - Type of sync mode + * @num_links: Input Param - Num of links in sync mode (Valid only + * when sync_mode is one of SYNC enabled modes) + * @link_hdls: Input Param - Array of link handles to be in sync mode + * (Valid only when sync_mode is one of SYNC + * enabled modes) + * @master_link_hdl: Input Param - To dictate which link's SOF drives system + * (Valid only when sync_mode is one of SYNC + * enabled modes) + * + * @opcode: CAM_REQ_MGR_SYNC_MODE + */ +struct cam_req_mgr_sync_mode { + int32_t session_hdl; + int32_t sync_mode; + int32_t num_links; + int32_t link_hdls[MAX_LINKS_PER_SESSION]; + int32_t master_link_hdl; + int32_t reserved; +}; + +/** + * struct cam_req_mgr_link_control + * @ops: Link operations: activate/deactive + * @session_hdl: Input param - Identifier for CSL session + * @num_links: Input Param - Num of links + * @reserved: reserved field + * @link_hdls: Input Param - Links to be activated/deactivated + * + * @opcode: CAM_REQ_MGR_LINK_CONTROL + */ +struct cam_req_mgr_link_control { + int32_t ops; + int32_t session_hdl; + int32_t num_links; + int32_t reserved; + int32_t link_hdls[MAX_LINKS_PER_SESSION]; +}; + +/** + * cam_req_mgr specific opcode ids + */ +#define CAM_REQ_MGR_CREATE_DEV_NODES (CAM_COMMON_OPCODE_MAX + 1) +#define CAM_REQ_MGR_CREATE_SESSION (CAM_COMMON_OPCODE_MAX + 2) +#define CAM_REQ_MGR_DESTROY_SESSION (CAM_COMMON_OPCODE_MAX + 3) +#define CAM_REQ_MGR_LINK (CAM_COMMON_OPCODE_MAX + 4) +#define CAM_REQ_MGR_UNLINK (CAM_COMMON_OPCODE_MAX + 5) +#define CAM_REQ_MGR_SCHED_REQ (CAM_COMMON_OPCODE_MAX + 6) +#define CAM_REQ_MGR_FLUSH_REQ (CAM_COMMON_OPCODE_MAX + 7) +#define CAM_REQ_MGR_SYNC_MODE (CAM_COMMON_OPCODE_MAX + 8) +#define CAM_REQ_MGR_ALLOC_BUF (CAM_COMMON_OPCODE_MAX + 9) +#define CAM_REQ_MGR_MAP_BUF (CAM_COMMON_OPCODE_MAX + 10) +#define CAM_REQ_MGR_RELEASE_BUF (CAM_COMMON_OPCODE_MAX + 11) +#define CAM_REQ_MGR_CACHE_OPS (CAM_COMMON_OPCODE_MAX + 12) +#define CAM_REQ_MGR_LINK_CONTROL (CAM_COMMON_OPCODE_MAX + 13) +/* end of cam_req_mgr opcodes */ + +#define CAM_MEM_FLAG_HW_READ_WRITE (1<<0) +#define CAM_MEM_FLAG_HW_READ_ONLY (1<<1) +#define CAM_MEM_FLAG_HW_WRITE_ONLY (1<<2) +#define CAM_MEM_FLAG_KMD_ACCESS (1<<3) +#define CAM_MEM_FLAG_UMD_ACCESS (1<<4) +#define CAM_MEM_FLAG_PROTECTED_MODE (1<<5) +#define CAM_MEM_FLAG_CMD_BUF_TYPE (1<<6) +#define CAM_MEM_FLAG_PIXEL_BUF_TYPE (1<<7) +#define CAM_MEM_FLAG_STATS_BUF_TYPE (1<<8) +#define CAM_MEM_FLAG_PACKET_BUF_TYPE (1<<9) +#define CAM_MEM_FLAG_CACHE (1<<10) +#define CAM_MEM_FLAG_HW_SHARED_ACCESS (1<<11) + +#define CAM_MEM_MMU_MAX_HANDLE 16 + +/* Maximum allowed buffers in existence */ +#define CAM_MEM_BUFQ_MAX 1024 + +#define CAM_MEM_MGR_SECURE_BIT_POS 15 +#define CAM_MEM_MGR_HDL_IDX_SIZE 15 +#define CAM_MEM_MGR_HDL_FD_SIZE 16 +#define CAM_MEM_MGR_HDL_IDX_END_POS 16 +#define CAM_MEM_MGR_HDL_FD_END_POS 32 + +#define CAM_MEM_MGR_HDL_IDX_MASK ((1 << CAM_MEM_MGR_HDL_IDX_SIZE) - 1) + +#define GET_MEM_HANDLE(idx, fd) \ + ((idx & CAM_MEM_MGR_HDL_IDX_MASK) | \ + (fd << (CAM_MEM_MGR_HDL_FD_END_POS - CAM_MEM_MGR_HDL_FD_SIZE))) \ + +#define GET_FD_FROM_HANDLE(hdl) \ + (hdl >> (CAM_MEM_MGR_HDL_FD_END_POS - CAM_MEM_MGR_HDL_FD_SIZE)) \ + +#define CAM_MEM_MGR_GET_HDL_IDX(hdl) (hdl & CAM_MEM_MGR_HDL_IDX_MASK) + +#define CAM_MEM_MGR_SET_SECURE_HDL(hdl, flag) \ + ((flag) ? (hdl |= (1 << CAM_MEM_MGR_SECURE_BIT_POS)) : \ + ((hdl) &= ~(1 << CAM_MEM_MGR_SECURE_BIT_POS))) + +#define CAM_MEM_MGR_IS_SECURE_HDL(hdl) \ + (((hdl) & \ + (1<> CAM_MEM_MGR_SECURE_BIT_POS) + +/** + * memory allocation type + */ +#define CAM_MEM_DMA_NONE 0 +#define CAM_MEM_DMA_BIDIRECTIONAL 1 +#define CAM_MEM_DMA_TO_DEVICE 2 +#define CAM_MEM_DMA_FROM_DEVICE 3 + + +/** + * memory cache operation + */ +#define CAM_MEM_CLEAN_CACHE 1 +#define CAM_MEM_INV_CACHE 2 +#define CAM_MEM_CLEAN_INV_CACHE 3 + + +/** + * struct cam_mem_alloc_out_params + * @buf_handle: buffer handle + * @fd: output buffer file descriptor + * @vaddr: virtual address pointer + */ +struct cam_mem_alloc_out_params { + uint32_t buf_handle; + int32_t fd; + uint64_t vaddr; +}; + +/** + * struct cam_mem_map_out_params + * @buf_handle: buffer handle + * @reserved: reserved for future + * @vaddr: virtual address pointer + */ +struct cam_mem_map_out_params { + uint32_t buf_handle; + uint32_t reserved; + uint64_t vaddr; +}; + +/** + * struct cam_mem_mgr_alloc_cmd + * @len: size of buffer to allocate + * @align: alignment of the buffer + * @mmu_hdls: array of mmu handles + * @num_hdl: number of handles + * @flags: flags of the buffer + * @out: out params + */ +/* CAM_REQ_MGR_ALLOC_BUF */ +struct cam_mem_mgr_alloc_cmd { + uint64_t len; + uint64_t align; + int32_t mmu_hdls[CAM_MEM_MMU_MAX_HANDLE]; + uint32_t num_hdl; + uint32_t flags; + struct cam_mem_alloc_out_params out; +}; + +/** + * struct cam_mem_mgr_map_cmd + * @mmu_hdls: array of mmu handles + * @num_hdl: number of handles + * @flags: flags of the buffer + * @fd: output buffer file descriptor + * @reserved: reserved field + * @out: out params + */ + +/* CAM_REQ_MGR_MAP_BUF */ +struct cam_mem_mgr_map_cmd { + int32_t mmu_hdls[CAM_MEM_MMU_MAX_HANDLE]; + uint32_t num_hdl; + uint32_t flags; + int32_t fd; + uint32_t reserved; + struct cam_mem_map_out_params out; +}; + +/** + * struct cam_mem_mgr_map_cmd + * @buf_handle: buffer handle + * @reserved: reserved field + */ +/* CAM_REQ_MGR_RELEASE_BUF */ +struct cam_mem_mgr_release_cmd { + int32_t buf_handle; + uint32_t reserved; +}; + +/** + * struct cam_mem_mgr_map_cmd + * @buf_handle: buffer handle + * @ops: cache operations + */ +/* CAM_REQ_MGR_CACHE_OPS */ +struct cam_mem_cache_ops_cmd { + int32_t buf_handle; + uint32_t mem_cache_ops; +}; + +/** + * Request Manager : error message type + * @CAM_REQ_MGR_ERROR_TYPE_DEVICE: Device error message, fatal to session + * @CAM_REQ_MGR_ERROR_TYPE_REQUEST: Error on a single request, not fatal + * @CAM_REQ_MGR_ERROR_TYPE_BUFFER: Buffer was not filled, not fatal + */ +#define CAM_REQ_MGR_ERROR_TYPE_DEVICE 0 +#define CAM_REQ_MGR_ERROR_TYPE_REQUEST 1 +#define CAM_REQ_MGR_ERROR_TYPE_BUFFER 2 + +/** + * struct cam_req_mgr_error_msg + * @error_type: type of error + * @request_id: request id of frame + * @device_hdl: device handle + * @linke_hdl: link_hdl + * @resource_size: size of the resource + */ +struct cam_req_mgr_error_msg { + uint32_t error_type; + uint32_t request_id; + int32_t device_hdl; + int32_t link_hdl; + uint64_t resource_size; +}; + +/** + * struct cam_req_mgr_frame_msg + * @request_id: request id of the frame + * @frame_id: frame id of the frame + * @timestamp: timestamp of the frame + * @link_hdl: link handle associated with this message + * @sof_status: sof status success or fail + */ +struct cam_req_mgr_frame_msg { + uint64_t request_id; + uint64_t frame_id; + uint64_t timestamp; + int32_t link_hdl; + uint32_t sof_status; +}; + +/** + * struct cam_req_mgr_message + * @session_hdl: session to which the frame belongs to + * @reserved: reserved field + * @u: union which can either be error or frame message + */ +struct cam_req_mgr_message { + int32_t session_hdl; + int32_t reserved; + union { + struct cam_req_mgr_error_msg err_msg; + struct cam_req_mgr_frame_msg frame_msg; + } u; +}; +#endif /* __UAPI_LINUX_CAM_REQ_MGR_H */ diff --git a/selfdrive/camerad/include/media/cam_sensor.h b/selfdrive/camerad/include/media/cam_sensor.h new file mode 100644 index 00000000000000..f5af6047f5ac88 --- /dev/null +++ b/selfdrive/camerad/include/media/cam_sensor.h @@ -0,0 +1,477 @@ +#ifndef __UAPI_CAM_SENSOR_H__ +#define __UAPI_CAM_SENSOR_H__ + +#include +#include +#include + +#define CAM_SENSOR_PROBE_CMD (CAM_COMMON_OPCODE_MAX + 1) +#define CAM_FLASH_MAX_LED_TRIGGERS 3 +#define MAX_OIS_NAME_SIZE 32 +#define CAM_CSIPHY_SECURE_MODE_ENABLED 1 +/** + * struct cam_sensor_query_cap - capabilities info for sensor + * + * @slot_info : Indicates about the slotId or cell Index + * @secure_camera : Camera is in secure/Non-secure mode + * @pos_pitch : Sensor position pitch + * @pos_roll : Sensor position roll + * @pos_yaw : Sensor position yaw + * @actuator_slot_id : Actuator slot id which connected to sensor + * @eeprom_slot_id : EEPROM slot id which connected to sensor + * @ois_slot_id : OIS slot id which connected to sensor + * @flash_slot_id : Flash slot id which connected to sensor + * @csiphy_slot_id : CSIphy slot id which connected to sensor + * + */ +struct cam_sensor_query_cap { + uint32_t slot_info; + uint32_t secure_camera; + uint32_t pos_pitch; + uint32_t pos_roll; + uint32_t pos_yaw; + uint32_t actuator_slot_id; + uint32_t eeprom_slot_id; + uint32_t ois_slot_id; + uint32_t flash_slot_id; + uint32_t csiphy_slot_id; +} __attribute__((packed)); + +/** + * struct cam_csiphy_query_cap - capabilities info for csiphy + * + * @slot_info : Indicates about the slotId or cell Index + * @version : CSIphy version + * @clk lane : Of the 5 lanes, informs lane configured + * as clock lane + * @reserved + */ +struct cam_csiphy_query_cap { + uint32_t slot_info; + uint32_t version; + uint32_t clk_lane; + uint32_t reserved; +} __attribute__((packed)); + +/** + * struct cam_actuator_query_cap - capabilities info for actuator + * + * @slot_info : Indicates about the slotId or cell Index + * @reserved + */ +struct cam_actuator_query_cap { + uint32_t slot_info; + uint32_t reserved; +} __attribute__((packed)); + +/** + * struct cam_eeprom_query_cap_t - capabilities info for eeprom + * + * @slot_info : Indicates about the slotId or cell Index + * @eeprom_kernel_probe : Indicates about the kernel or userspace probe + */ +struct cam_eeprom_query_cap_t { + uint32_t slot_info; + uint16_t eeprom_kernel_probe; + uint16_t reserved; +} __attribute__((packed)); + +/** + * struct cam_ois_query_cap_t - capabilities info for ois + * + * @slot_info : Indicates about the slotId or cell Index + */ +struct cam_ois_query_cap_t { + uint32_t slot_info; + uint16_t reserved; +} __attribute__((packed)); + +/** + * struct cam_cmd_i2c_info - Contains slave I2C related info + * + * @slave_addr : Slave address + * @i2c_freq_mode : 4 bits are used for I2c freq mode + * @cmd_type : Explains type of command + */ +struct cam_cmd_i2c_info { + uint16_t slave_addr; + uint8_t i2c_freq_mode; + uint8_t cmd_type; +} __attribute__((packed)); + +/** + * struct cam_ois_opcode - Contains OIS opcode + * + * @prog : OIS FW prog register address + * @coeff : OIS FW coeff register address + * @pheripheral : OIS pheripheral + * @memory : OIS memory + */ +struct cam_ois_opcode { + uint32_t prog; + uint32_t coeff; + uint32_t pheripheral; + uint32_t memory; +} __attribute__((packed)); + +/** + * struct cam_cmd_ois_info - Contains OIS slave info + * + * @slave_addr : OIS i2c slave address + * @i2c_freq_mode : i2c frequency mode + * @cmd_type : Explains type of command + * @ois_fw_flag : indicates if fw is present or not + * @is_ois_calib : indicates the calibration data is available + * @ois_name : OIS name + * @opcode : opcode + */ +struct cam_cmd_ois_info { + uint16_t slave_addr; + uint8_t i2c_freq_mode; + uint8_t cmd_type; + uint8_t ois_fw_flag; + uint8_t is_ois_calib; + char ois_name[MAX_OIS_NAME_SIZE]; + struct cam_ois_opcode opcode; +} __attribute__((packed)); + +/** + * struct cam_cmd_probe - Contains sensor slave info + * + * @data_type : Slave register data type + * @addr_type : Slave register address type + * @op_code : Don't Care + * @cmd_type : Explains type of command + * @reg_addr : Slave register address + * @expected_data : Data expected at slave register address + * @data_mask : Data mask if only few bits are valid + * @camera_id : Indicates the slot to which camera + * needs to be probed + * @reserved + */ +struct cam_cmd_probe { + uint8_t data_type; + uint8_t addr_type; + uint8_t op_code; + uint8_t cmd_type; + uint32_t reg_addr; + uint32_t expected_data; + uint32_t data_mask; + uint16_t camera_id; + uint16_t reserved; +} __attribute__((packed)); + +/** + * struct cam_power_settings - Contains sensor power setting info + * + * @power_seq_type : Type of power sequence + * @reserved + * @config_val_low : Lower 32 bit value configuration value + * @config_val_high : Higher 32 bit value configuration value + * + */ +struct cam_power_settings { + uint16_t power_seq_type; + uint16_t reserved; + uint32_t config_val_low; + uint32_t config_val_high; +} __attribute__((packed)); + +/** + * struct cam_cmd_power - Explains about the power settings + * + * @count : Number of power settings follows + * @reserved + * @cmd_type : Explains type of command + * @power_settings : Contains power setting info + */ +struct cam_cmd_power { + uint16_t count; + uint8_t reserved; + uint8_t cmd_type; + struct cam_power_settings power_settings[1]; +} __attribute__((packed)); + +/** + * struct i2c_rdwr_header - header of READ/WRITE I2C command + * + * @ count : Number of registers / data / reg-data pairs + * @ op_code : Operation code + * @ cmd_type : Command buffer type + * @ data_type : I2C data type + * @ addr_type : I2C address type + * @ reserved + */ +struct i2c_rdwr_header { + uint16_t count; + uint8_t op_code; + uint8_t cmd_type; + uint8_t data_type; + uint8_t addr_type; + uint16_t reserved; +} __attribute__((packed)); + +/** + * struct i2c_random_wr_payload - payload for I2C random write + * + * @ reg_addr : Register address + * @ reg_data : Register data + * + */ +struct i2c_random_wr_payload { + uint32_t reg_addr; + uint32_t reg_data; +} __attribute__((packed)); + +/** + * struct cam_cmd_i2c_random_wr - I2C random write command + * @ header : header of READ/WRITE I2C command + * @ random_wr_payload : payload for I2C random write + */ +struct cam_cmd_i2c_random_wr { + struct i2c_rdwr_header header; + struct i2c_random_wr_payload random_wr_payload[1]; +} __attribute__((packed)); + +/** + * struct cam_cmd_read - I2C read command + * @ reg_data : Register data + * @ reserved + */ +struct cam_cmd_read { + uint32_t reg_data; + uint32_t reserved; +} __attribute__((packed)); + +/** + * struct cam_cmd_i2c_continuous_wr - I2C continuous write command + * @ header : header of READ/WRITE I2C command + * @ reg_addr : Register address + * @ data_read : I2C read command + */ +struct cam_cmd_i2c_continuous_wr { + struct i2c_rdwr_header header; + uint32_t reg_addr; + struct cam_cmd_read data_read[1]; +} __attribute__((packed)); + +/** + * struct cam_cmd_i2c_random_rd - I2C random read command + * @ header : header of READ/WRITE I2C command + * @ data_read : I2C read command + */ +struct cam_cmd_i2c_random_rd { + struct i2c_rdwr_header header; + struct cam_cmd_read data_read[1]; +} __attribute__((packed)); + +/** + * struct cam_cmd_i2c_continuous_rd - I2C continuous continuous read command + * @ header : header of READ/WRITE I2C command + * @ reg_addr : Register address + * + */ +struct cam_cmd_i2c_continuous_rd { + struct i2c_rdwr_header header; + uint32_t reg_addr; +} __attribute__((packed)); + +/** + * struct cam_cmd_conditional_wait - Conditional wait command + * @data_type : Data type + * @addr_type : Address type + * @op_code : Opcode + * @cmd_type : Explains type of command + * @timeout : Timeout for retries + * @reserved + * @reg_addr : Register Address + * @reg_data : Register data + * @data_mask : Data mask if only few bits are valid + * @camera_id : Indicates the slot to which camera + * needs to be probed + * + */ +struct cam_cmd_conditional_wait { + uint8_t data_type; + uint8_t addr_type; + uint8_t op_code; + uint8_t cmd_type; + uint16_t timeout; + uint16_t reserved; + uint32_t reg_addr; + uint32_t reg_data; + uint32_t data_mask; +} __attribute__((packed)); + +/** + * struct cam_cmd_unconditional_wait - Un-conditional wait command + * @delay : Delay + * @op_code : Opcode + * @cmd_type : Explains type of command + */ +struct cam_cmd_unconditional_wait { + int16_t delay; + uint8_t op_code; + uint8_t cmd_type; +} __attribute__((packed)); + +/** + * cam_csiphy_info: Provides cmdbuffer structre + * @lane_mask : Lane mask details + * @lane_assign : Lane sensor will be using + * @csiphy_3phase : Total number of lanes + * @combo_mode : Info regarding combo_mode is enable / disable + * @lane_cnt : Total number of lanes + * @secure_mode : Secure mode flag to enable / disable + * @3phase : Details whether 3Phase / 2Phase operation + * @settle_time : Settling time in ms + * @data_rate : Data rate + * + */ +struct cam_csiphy_info { + uint16_t lane_mask; + uint16_t lane_assign; + uint8_t csiphy_3phase; + uint8_t combo_mode; + uint8_t lane_cnt; + uint8_t secure_mode; + uint64_t settle_time; + uint64_t data_rate; +} __attribute__((packed)); + +/** + * cam_csiphy_acquire_dev_info : Information needed for + * csiphy at the time of acquire + * @combo_mode : Indicates the device mode of operation + * @reserved + * + */ +struct cam_csiphy_acquire_dev_info { + uint32_t combo_mode; + uint32_t reserved; +} __attribute__((packed)); + +/** + * cam_sensor_acquire_dev : Updates sensor acuire cmd + * @device_handle : Updates device handle + * @session_handle : Session handle for acquiring device + * @handle_type : Resource handle type + * @reserved + * @info_handle : Handle to additional info + * needed for sensor sub modules + * + */ +struct cam_sensor_acquire_dev { + uint32_t session_handle; + uint32_t device_handle; + uint32_t handle_type; + uint32_t reserved; + uint64_t info_handle; +} __attribute__((packed)); + +/** + * cam_sensor_streamon_dev : StreamOn command for the sensor + * @session_handle : Session handle for acquiring device + * @device_handle : Updates device handle + * @handle_type : Resource handle type + * @reserved + * @info_handle : Information Needed at the time of streamOn + * + */ +struct cam_sensor_streamon_dev { + uint32_t session_handle; + uint32_t device_handle; + uint32_t handle_type; + uint32_t reserved; + uint64_t info_handle; +} __attribute__((packed)); + +/** + * struct cam_flash_init : Init command for the flash + * @flash_type : flash hw type + * @reserved + * @cmd_type : command buffer type + */ +struct cam_flash_init { + uint8_t flash_type; + uint16_t reserved; + uint8_t cmd_type; +} __attribute__((packed)); + +/** + * struct cam_flash_set_rer : RedEyeReduction command buffer + * + * @count : Number of flash leds + * @opcode : Command buffer opcode + * CAM_FLASH_FIRE_RER + * @cmd_type : command buffer operation type + * @num_iteration : Number of led turn on/off sequence + * @reserved + * @led_on_delay_ms : flash led turn on time in ms + * @led_off_delay_ms : flash led turn off time in ms + * @led_current_ma : flash led current in ma + * + */ +struct cam_flash_set_rer { + uint16_t count; + uint8_t opcode; + uint8_t cmd_type; + uint16_t num_iteration; + uint16_t reserved; + uint32_t led_on_delay_ms; + uint32_t led_off_delay_ms; + uint32_t led_current_ma[CAM_FLASH_MAX_LED_TRIGGERS]; +} __attribute__((packed)); + +/** + * struct cam_flash_set_on_off : led turn on/off command buffer + * + * @count : Number of Flash leds + * @opcode : command buffer opcodes + * CAM_FLASH_FIRE_LOW + * CAM_FLASH_FIRE_HIGH + * CAM_FLASH_OFF + * @cmd_type : command buffer operation type + * @led_current_ma : flash led current in ma + * + */ +struct cam_flash_set_on_off { + uint16_t count; + uint8_t opcode; + uint8_t cmd_type; + uint32_t led_current_ma[CAM_FLASH_MAX_LED_TRIGGERS]; +} __attribute__((packed)); + +/** + * struct cam_flash_query_curr : query current command buffer + * + * @reserved + * @opcode : command buffer opcode + * @cmd_type : command buffer operation type + * @query_current_ma : battery current in ma + * + */ +struct cam_flash_query_curr { + uint16_t reserved; + uint8_t opcode; + uint8_t cmd_type; + uint32_t query_current_ma; +} __attribute__ ((packed)); + +/** + * struct cam_flash_query_cap : capabilities info for flash + * + * @slot_info : Indicates about the slotId or cell Index + * @max_current_flash : max supported current for flash + * @max_duration_flash : max flash turn on duration + * @max_current_torch : max supported current for torch + * + */ +struct cam_flash_query_cap_info { + uint32_t slot_info; + uint32_t max_current_flash[CAM_FLASH_MAX_LED_TRIGGERS]; + uint32_t max_duration_flash[CAM_FLASH_MAX_LED_TRIGGERS]; + uint32_t max_current_torch[CAM_FLASH_MAX_LED_TRIGGERS]; +} __attribute__ ((packed)); + +#endif diff --git a/selfdrive/camerad/include/media/cam_sensor_cmn_header.h b/selfdrive/camerad/include/media/cam_sensor_cmn_header.h new file mode 100644 index 00000000000000..24617b39bd1266 --- /dev/null +++ b/selfdrive/camerad/include/media/cam_sensor_cmn_header.h @@ -0,0 +1,391 @@ +/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef _CAM_SENSOR_CMN_HEADER_ +#define _CAM_SENSOR_CMN_HEADER_ + +#include +#include +#include + +#define MAX_REGULATOR 5 +#define MAX_POWER_CONFIG 12 + +#define MAX_PER_FRAME_ARRAY 32 +#define BATCH_SIZE_MAX 16 + +#define CAM_SENSOR_NAME "cam-sensor" +#define CAM_ACTUATOR_NAME "cam-actuator" +#define CAM_CSIPHY_NAME "cam-csiphy" +#define CAM_FLASH_NAME "cam-flash" +#define CAM_EEPROM_NAME "cam-eeprom" +#define CAM_OIS_NAME "cam-ois" + +#define MAX_SYSTEM_PIPELINE_DELAY 2 + +#define CAM_PKT_NOP_OPCODE 127 + +enum camera_sensor_cmd_type { + CAMERA_SENSOR_CMD_TYPE_INVALID, + CAMERA_SENSOR_CMD_TYPE_PROBE, + CAMERA_SENSOR_CMD_TYPE_PWR_UP, + CAMERA_SENSOR_CMD_TYPE_PWR_DOWN, + CAMERA_SENSOR_CMD_TYPE_I2C_INFO, + CAMERA_SENSOR_CMD_TYPE_I2C_RNDM_WR, + CAMERA_SENSOR_CMD_TYPE_I2C_RNDM_RD, + CAMERA_SENSOR_CMD_TYPE_I2C_CONT_WR, + CAMERA_SENSOR_CMD_TYPE_I2C_CONT_RD, + CAMERA_SENSOR_CMD_TYPE_WAIT, + CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_INFO, + CAMERA_SENSOR_FLASH_CMD_TYPE_FIRE, + CAMERA_SENSOR_FLASH_CMD_TYPE_RER, + CAMERA_SENSOR_FLASH_CMD_TYPE_QUERYCURR, + CAMERA_SENSOR_FLASH_CMD_TYPE_WIDGET, + CAMERA_SENSOR_CMD_TYPE_RD_DATA, + CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_FIRE, + CAMERA_SENSOR_CMD_TYPE_MAX, +}; + +enum camera_sensor_i2c_op_code { + CAMERA_SENSOR_I2C_OP_INVALID, + CAMERA_SENSOR_I2C_OP_RNDM_WR, + CAMERA_SENSOR_I2C_OP_RNDM_WR_VERF, + CAMERA_SENSOR_I2C_OP_CONT_WR_BRST, + CAMERA_SENSOR_I2C_OP_CONT_WR_BRST_VERF, + CAMERA_SENSOR_I2C_OP_CONT_WR_SEQN, + CAMERA_SENSOR_I2C_OP_CONT_WR_SEQN_VERF, + CAMERA_SENSOR_I2C_OP_MAX, +}; + +enum camera_sensor_wait_op_code { + CAMERA_SENSOR_WAIT_OP_INVALID, + CAMERA_SENSOR_WAIT_OP_COND, + CAMERA_SENSOR_WAIT_OP_HW_UCND, + CAMERA_SENSOR_WAIT_OP_SW_UCND, + CAMERA_SENSOR_WAIT_OP_MAX, +}; + +enum camera_flash_opcode { + CAMERA_SENSOR_FLASH_OP_INVALID, + CAMERA_SENSOR_FLASH_OP_OFF, + CAMERA_SENSOR_FLASH_OP_FIRELOW, + CAMERA_SENSOR_FLASH_OP_FIREHIGH, + CAMERA_SENSOR_FLASH_OP_MAX, +}; + +enum camera_sensor_i2c_type { + CAMERA_SENSOR_I2C_TYPE_INVALID, + CAMERA_SENSOR_I2C_TYPE_BYTE, + CAMERA_SENSOR_I2C_TYPE_WORD, + CAMERA_SENSOR_I2C_TYPE_3B, + CAMERA_SENSOR_I2C_TYPE_DWORD, + CAMERA_SENSOR_I2C_TYPE_MAX, +}; + +enum i2c_freq_mode { + I2C_STANDARD_MODE, + I2C_FAST_MODE, + I2C_CUSTOM_MODE, + I2C_FAST_PLUS_MODE, + I2C_MAX_MODES, +}; + +enum position_roll { + ROLL_0 = 0, + ROLL_90 = 90, + ROLL_180 = 180, + ROLL_270 = 270, + ROLL_INVALID = 360, +}; + +enum position_yaw { + FRONT_CAMERA_YAW = 0, + REAR_CAMERA_YAW = 180, + INVALID_YAW = 360, +}; + +enum position_pitch { + LEVEL_PITCH = 0, + INVALID_PITCH = 360, +}; + +enum sensor_sub_module { + SUB_MODULE_SENSOR, + SUB_MODULE_ACTUATOR, + SUB_MODULE_EEPROM, + SUB_MODULE_LED_FLASH, + SUB_MODULE_CSID, + SUB_MODULE_CSIPHY, + SUB_MODULE_OIS, + SUB_MODULE_EXT, + SUB_MODULE_MAX, +}; + +enum msm_camera_power_seq_type { + SENSOR_MCLK, + SENSOR_VANA, + SENSOR_VDIG, + SENSOR_VIO, + SENSOR_VAF, + SENSOR_VAF_PWDM, + SENSOR_CUSTOM_REG1, + SENSOR_CUSTOM_REG2, + SENSOR_RESET, + SENSOR_STANDBY, + SENSOR_CUSTOM_GPIO1, + SENSOR_CUSTOM_GPIO2, + SENSOR_SEQ_TYPE_MAX, +}; + +enum cam_sensor_packet_opcodes { + CAM_SENSOR_PACKET_OPCODE_SENSOR_STREAMON, + CAM_SENSOR_PACKET_OPCODE_SENSOR_UPDATE, + CAM_SENSOR_PACKET_OPCODE_SENSOR_INITIAL_CONFIG, + CAM_SENSOR_PACKET_OPCODE_SENSOR_PROBE, + CAM_SENSOR_PACKET_OPCODE_SENSOR_CONFIG, + CAM_SENSOR_PACKET_OPCODE_SENSOR_STREAMOFF, + CAM_SENSOR_PACKET_OPCODE_SENSOR_NOP = 127 +}; + +enum cam_actuator_packet_opcodes { + CAM_ACTUATOR_PACKET_OPCODE_INIT, + CAM_ACTUATOR_PACKET_AUTO_MOVE_LENS, + CAM_ACTUATOR_PACKET_MANUAL_MOVE_LENS +}; + +enum cam_eeprom_packet_opcodes { + CAM_EEPROM_PACKET_OPCODE_INIT +}; + +enum cam_ois_packet_opcodes { + CAM_OIS_PACKET_OPCODE_INIT, + CAM_OIS_PACKET_OPCODE_OIS_CONTROL +}; + +enum msm_bus_perf_setting { + S_INIT, + S_PREVIEW, + S_VIDEO, + S_CAPTURE, + S_ZSL, + S_STEREO_VIDEO, + S_STEREO_CAPTURE, + S_DEFAULT, + S_LIVESHOT, + S_DUAL, + S_EXIT +}; + +enum msm_camera_device_type_t { + MSM_CAMERA_I2C_DEVICE, + MSM_CAMERA_PLATFORM_DEVICE, + MSM_CAMERA_SPI_DEVICE, +}; + +enum cam_flash_device_type { + CAMERA_FLASH_DEVICE_TYPE_PMIC = 0, + CAMERA_FLASH_DEVICE_TYPE_I2C, + CAMERA_FLASH_DEVICE_TYPE_GPIO, +}; + +enum cci_i2c_master_t { + MASTER_0, + MASTER_1, + MASTER_MAX, +}; + +enum camera_vreg_type { + VREG_TYPE_DEFAULT, + VREG_TYPE_CUSTOM, +}; + +enum cam_sensor_i2c_cmd_type { + CAM_SENSOR_I2C_WRITE_RANDOM, + CAM_SENSOR_I2C_WRITE_BURST, + CAM_SENSOR_I2C_WRITE_SEQ, + CAM_SENSOR_I2C_READ, + CAM_SENSOR_I2C_POLL +}; + +struct common_header { + uint16_t first_word; + uint8_t third_byte; + uint8_t cmd_type; +}; + +struct camera_vreg_t { + const char *reg_name; + int min_voltage; + int max_voltage; + int op_mode; + uint32_t delay; + const char *custom_vreg_name; + enum camera_vreg_type type; +}; + +struct msm_camera_gpio_num_info { + uint16_t gpio_num[SENSOR_SEQ_TYPE_MAX]; + uint8_t valid[SENSOR_SEQ_TYPE_MAX]; +}; + +struct msm_cam_clk_info { + const char *clk_name; + long clk_rate; + uint32_t delay; +}; + +struct msm_pinctrl_info { + struct pinctrl *pinctrl; + struct pinctrl_state *gpio_state_active; + struct pinctrl_state *gpio_state_suspend; + bool use_pinctrl; +}; + +struct cam_sensor_i2c_reg_array { + uint32_t reg_addr; + uint32_t reg_data; + uint32_t delay; + uint32_t data_mask; +}; + +struct cam_sensor_i2c_reg_setting { + struct cam_sensor_i2c_reg_array *reg_setting; + unsigned short size; + enum camera_sensor_i2c_type addr_type; + enum camera_sensor_i2c_type data_type; + unsigned short delay; +}; + +/*struct i2c_settings_list { + struct cam_sensor_i2c_reg_setting i2c_settings; + enum cam_sensor_i2c_cmd_type op_code; + struct list_head list; +}; + +struct i2c_settings_array { + struct list_head list_head; + int32_t is_settings_valid; + int64_t request_id; +}; + +struct i2c_data_settings { + struct i2c_settings_array init_settings; + struct i2c_settings_array config_settings; + struct i2c_settings_array streamon_settings; + struct i2c_settings_array streamoff_settings; + struct i2c_settings_array *per_frame; +};*/ + +struct cam_sensor_power_ctrl_t { + struct device *dev; + struct cam_sensor_power_setting *power_setting; + uint16_t power_setting_size; + struct cam_sensor_power_setting *power_down_setting; + uint16_t power_down_setting_size; + struct msm_camera_gpio_num_info *gpio_num_info; + struct msm_pinctrl_info pinctrl_info; + uint8_t cam_pinctrl_status; +}; + +struct cam_camera_slave_info { + uint16_t sensor_slave_addr; + uint16_t sensor_id_reg_addr; + uint16_t sensor_id; + uint16_t sensor_id_mask; +}; + +struct msm_sensor_init_params { + int modes_supported; + unsigned int sensor_mount_angle; +}; + +enum msm_sensor_camera_id_t { + CAMERA_0, + CAMERA_1, + CAMERA_2, + CAMERA_3, + CAMERA_4, + CAMERA_5, + CAMERA_6, + MAX_CAMERAS, +}; + +struct msm_sensor_id_info_t { + unsigned short sensor_id_reg_addr; + unsigned short sensor_id; + unsigned short sensor_id_mask; +}; + +enum msm_sensor_output_format_t { + MSM_SENSOR_BAYER, + MSM_SENSOR_YCBCR, + MSM_SENSOR_META, +}; + +struct cam_sensor_power_setting { + enum msm_camera_power_seq_type seq_type; + unsigned short seq_val; + long config_val; + unsigned short delay; + void *data[10]; +}; + +struct cam_sensor_board_info { + struct cam_camera_slave_info slave_info; + int32_t sensor_mount_angle; + int32_t secure_mode; + int modes_supported; + int32_t pos_roll; + int32_t pos_yaw; + int32_t pos_pitch; + int32_t subdev_id[SUB_MODULE_MAX]; + int32_t subdev_intf[SUB_MODULE_MAX]; + const char *misc_regulator; + struct cam_sensor_power_ctrl_t power_info; +}; + +enum msm_camera_vreg_name_t { + CAM_VDIG, + CAM_VIO, + CAM_VANA, + CAM_VAF, + CAM_V_CUSTOM1, + CAM_V_CUSTOM2, + CAM_VREG_MAX, +}; + +struct msm_camera_gpio_conf { + void *cam_gpiomux_conf_tbl; + uint8_t cam_gpiomux_conf_tbl_size; + struct gpio *cam_gpio_common_tbl; + uint8_t cam_gpio_common_tbl_size; + struct gpio *cam_gpio_req_tbl; + uint8_t cam_gpio_req_tbl_size; + uint32_t gpio_no_mux; + uint32_t *camera_off_table; + uint8_t camera_off_table_size; + uint32_t *camera_on_table; + uint8_t camera_on_table_size; + struct msm_camera_gpio_num_info *gpio_num_info; +}; + +/*for tof camera Begin*/ +enum EEPROM_DATA_OP_T{ + EEPROM_DEFAULT_DATA = 0, + EEPROM_INIT_DATA, + EEPROM_CONFIG_DATA, + EEPROM_STREAMON_DATA, + EEPROM_STREAMOFF_DATA, + EEPROM_OTHER_DATA, +}; +/*for tof camera End*/ +#endif /* _CAM_SENSOR_CMN_HEADER_ */ diff --git a/selfdrive/camerad/include/media/cam_sync.h b/selfdrive/camerad/include/media/cam_sync.h new file mode 100644 index 00000000000000..4a8781fc823d54 --- /dev/null +++ b/selfdrive/camerad/include/media/cam_sync.h @@ -0,0 +1,134 @@ +#ifndef __UAPI_CAM_SYNC_H__ +#define __UAPI_CAM_SYNC_H__ + +#include +#include +#include +#include + +#define CAM_SYNC_DEVICE_NAME "cam_sync_device" + +/* V4L event which user space will subscribe to */ +#define CAM_SYNC_V4L_EVENT (V4L2_EVENT_PRIVATE_START + 0) + +/* Specific event ids to get notified in user space */ +#define CAM_SYNC_V4L_EVENT_ID_CB_TRIG 0 + +/* Size of opaque payload sent to kernel for safekeeping until signal time */ +#define CAM_SYNC_USER_PAYLOAD_SIZE 2 + +/* Device type for sync device needed for device discovery */ +#define CAM_SYNC_DEVICE_TYPE (MEDIA_ENT_F_OLD_BASE) + +#define CAM_SYNC_GET_PAYLOAD_PTR(ev, type) \ + (type *)((char *)ev.u.data + sizeof(struct cam_sync_ev_header)) + +#define CAM_SYNC_GET_HEADER_PTR(ev) \ + ((struct cam_sync_ev_header *)ev.u.data) + +#define CAM_SYNC_STATE_INVALID 0 +#define CAM_SYNC_STATE_ACTIVE 1 +#define CAM_SYNC_STATE_SIGNALED_SUCCESS 2 +#define CAM_SYNC_STATE_SIGNALED_ERROR 3 + +/** + * struct cam_sync_ev_header - Event header for sync event notification + * + * @sync_obj: Sync object + * @status: Status of the object + */ +struct cam_sync_ev_header { + int32_t sync_obj; + int32_t status; +}; + +/** + * struct cam_sync_info - Sync object creation information + * + * @name: Optional string representation of the sync object + * @sync_obj: Sync object returned after creation in kernel + */ +struct cam_sync_info { + char name[64]; + int32_t sync_obj; +}; + +/** + * struct cam_sync_signal - Sync object signaling struct + * + * @sync_obj: Sync object to be signaled + * @sync_state: State of the sync object to which it should be signaled + */ +struct cam_sync_signal { + int32_t sync_obj; + uint32_t sync_state; +}; + +/** + * struct cam_sync_merge - Merge information for sync objects + * + * @sync_objs: Pointer to sync objects + * @num_objs: Number of objects in the array + * @merged: Merged sync object + */ +struct cam_sync_merge { + __u64 sync_objs; + uint32_t num_objs; + int32_t merged; +}; + +/** + * struct cam_sync_userpayload_info - Payload info from user space + * + * @sync_obj: Sync object for which payload has to be registered for + * @reserved: Reserved + * @payload: Pointer to user payload + */ +struct cam_sync_userpayload_info { + int32_t sync_obj; + uint32_t reserved; + __u64 payload[CAM_SYNC_USER_PAYLOAD_SIZE]; +}; + +/** + * struct cam_sync_wait - Sync object wait information + * + * @sync_obj: Sync object to wait on + * @reserved: Reserved + * @timeout_ms: Timeout in milliseconds + */ +struct cam_sync_wait { + int32_t sync_obj; + uint32_t reserved; + uint64_t timeout_ms; +}; + +/** + * struct cam_private_ioctl_arg - Sync driver ioctl argument + * + * @id: IOCTL command id + * @size: Size of command payload + * @result: Result of command execution + * @reserved: Reserved + * @ioctl_ptr: Pointer to user data + */ +struct cam_private_ioctl_arg { + __u32 id; + __u32 size; + __u32 result; + __u32 reserved; + __u64 ioctl_ptr; +}; + +#define CAM_PRIVATE_IOCTL_CMD \ + _IOWR('V', BASE_VIDIOC_PRIVATE, struct cam_private_ioctl_arg) + +#define CAM_SYNC_CREATE 0 +#define CAM_SYNC_DESTROY 1 +#define CAM_SYNC_SIGNAL 2 +#define CAM_SYNC_MERGE 3 +#define CAM_SYNC_REGISTER_PAYLOAD 4 +#define CAM_SYNC_DEREGISTER_PAYLOAD 5 +#define CAM_SYNC_WAIT 6 + +#endif /* __UAPI_CAM_SYNC_H__ */ diff --git a/selfdrive/visiond/include/msm_cam_sensor.h b/selfdrive/camerad/include/msm_cam_sensor.h similarity index 100% rename from selfdrive/visiond/include/msm_cam_sensor.h rename to selfdrive/camerad/include/msm_cam_sensor.h diff --git a/selfdrive/visiond/include/msm_camsensor_sdk.h b/selfdrive/camerad/include/msm_camsensor_sdk.h similarity index 100% rename from selfdrive/visiond/include/msm_camsensor_sdk.h rename to selfdrive/camerad/include/msm_camsensor_sdk.h diff --git a/selfdrive/visiond/include/msmb_camera.h b/selfdrive/camerad/include/msmb_camera.h similarity index 100% rename from selfdrive/visiond/include/msmb_camera.h rename to selfdrive/camerad/include/msmb_camera.h diff --git a/selfdrive/visiond/include/msmb_isp.h b/selfdrive/camerad/include/msmb_isp.h similarity index 100% rename from selfdrive/visiond/include/msmb_isp.h rename to selfdrive/camerad/include/msmb_isp.h diff --git a/selfdrive/visiond/include/msmb_ispif.h b/selfdrive/camerad/include/msmb_ispif.h similarity index 100% rename from selfdrive/visiond/include/msmb_ispif.h rename to selfdrive/camerad/include/msmb_ispif.h diff --git a/selfdrive/camerad/main.cc b/selfdrive/camerad/main.cc new file mode 100644 index 00000000000000..b6b948fe0e38f0 --- /dev/null +++ b/selfdrive/camerad/main.cc @@ -0,0 +1,350 @@ +#include +#include +#include +#include +#include +#include +#include + +#if defined(QCOM) && !defined(QCOM_REPLAY) +#include "cameras/camera_qcom.h" +#elif QCOM2 +#include "cameras/camera_qcom2.h" +#elif WEBCAM +#include "cameras/camera_webcam.h" +#else +#include "cameras/camera_frame_stream.h" +#endif + +#include + +#include "clutil.h" +#include "common/ipc.h" +#include "common/params.h" +#include "common/swaglog.h" +#include "common/util.h" +#include "common/visionipc.h" + +#define MAX_CLIENTS 6 + +volatile sig_atomic_t do_exit = 0; + +static void set_do_exit(int sig) { + do_exit = 1; +} + +struct VisionState; + +struct VisionClientState { + VisionState *s; + int fd; + pthread_t thread_handle; + bool running; +}; + +struct VisionClientStreamState { + bool subscribed; + int bufs_outstanding; + bool tb; + TBuffer* tbuffer; + PoolQueue* queue; +}; + +struct VisionState { + MultiCameraState cameras; + pthread_mutex_t clients_lock; + VisionClientState clients[MAX_CLIENTS]; +}; + +static CameraBuf *get_camerabuf_by_type(VisionState *s, VisionStreamType type) { + assert(type >= 0 && type < VISION_STREAM_MAX); + if (type == VISION_STREAM_RGB_BACK || type == VISION_STREAM_YUV) { + return &s->cameras.rear.buf; + } else if (type == VISION_STREAM_RGB_FRONT || type == VISION_STREAM_YUV_FRONT) { + return &s->cameras.front.buf; + } +#ifdef QCOM2 + return &s->cameras.wide.buf; +#endif + assert(0); +} + +// visionserver +void* visionserver_client_thread(void* arg) { + int err; + VisionClientState *client = (VisionClientState*)arg; + VisionState *s = client->s; + int fd = client->fd; + + set_thread_name("clientthread"); + + VisionClientStreamState streams[VISION_STREAM_MAX] = {{0}}; + + LOGW("client start fd %d", fd); + + while (true) { + struct pollfd polls[1+VISION_STREAM_MAX] = {{0}}; + polls[0].fd = fd; + polls[0].events = POLLIN; + + int poll_to_stream[1+VISION_STREAM_MAX] = {0}; + int num_polls = 1; + for (int i=0; i= 2) { + continue; + } + if (streams[i].tb) { + polls[num_polls].fd = tbuffer_efd(streams[i].tbuffer); + } else { + polls[num_polls].fd = poolq_efd(streams[i].queue); + } + poll_to_stream[num_polls] = i; + num_polls++; + } + int ret = poll(polls, num_polls, -1); + if (ret < 0) { + if (errno == EINTR || errno == EAGAIN) continue; + LOGE("poll failed (%d - %d)", ret, errno); + break; + } + if (do_exit) break; + if (polls[0].revents) { + VisionPacket p; + err = vipc_recv(fd, &p); + if (err <= 0) { + break; + } else if (p.type == VIPC_STREAM_SUBSCRIBE) { + VisionStreamType stream_type = p.d.stream_sub.type; + VisionPacket rep = { + .type = VIPC_STREAM_BUFS, + .d = { .stream_bufs = { .type = stream_type }, }, + }; + + VisionClientStreamState *stream = &streams[stream_type]; + stream->tb = p.d.stream_sub.tbuffer; + + VisionStreamBufs *stream_bufs = &rep.d.stream_bufs; + CameraBuf *b = get_camerabuf_by_type(s, stream_type); + if (stream_type == VISION_STREAM_RGB_BACK || + stream_type == VISION_STREAM_RGB_FRONT || + stream_type == VISION_STREAM_RGB_WIDE) { + stream_bufs->width = b->rgb_width; + stream_bufs->height = b->rgb_height; + stream_bufs->stride = b->rgb_stride; + stream_bufs->buf_len = b->rgb_bufs[0].len; + rep.num_fds = UI_BUF_COUNT; + for (int i = 0; i < rep.num_fds; i++) { + rep.fds[i] = b->rgb_bufs[i].fd; + } + if (stream->tb) { + stream->tbuffer = &b->ui_tb; + } else { + assert(false); + } + } else { + stream_bufs->width = b->yuv_width; + stream_bufs->height = b->yuv_height; + stream_bufs->stride = b->yuv_width; + stream_bufs->buf_len = b->yuv_buf_size; + rep.num_fds = YUV_COUNT; + for (int i = 0; i < rep.num_fds; i++) { + rep.fds[i] = b->yuv_ion[i].fd; + } + if (stream->tb) { + stream->tbuffer = b->yuv_tb; + } else { + stream->queue = pool_get_queue(&b->yuv_pool); + } + } + vipc_send(fd, &rep); + streams[stream_type].subscribed = true; + } else if (p.type == VIPC_STREAM_RELEASE) { + int si = p.d.stream_rel.type; + assert(si < VISION_STREAM_MAX); + if (streams[si].tb) { + tbuffer_release(streams[si].tbuffer, p.d.stream_rel.idx); + } else { + poolq_release(streams[si].queue, p.d.stream_rel.idx); + } + streams[p.d.stream_rel.type].bufs_outstanding--; + } else { + assert(false); + } + } else { + int stream_i = VISION_STREAM_MAX; + for (int i=1; iyuv_metas[idx].frame_id; + rep.d.stream_acq.extra.timestamp_sof = b->yuv_metas[idx].timestamp_sof; + rep.d.stream_acq.extra.timestamp_eof = b->yuv_metas[idx].timestamp_eof; + } + vipc_send(fd, &rep); + } + } + } + + LOGW("client end fd %d", fd); + + for (int i=0; iclients_lock); + client->running = false; + pthread_mutex_unlock(&s->clients_lock); + + return NULL; +} + +void* visionserver_thread(void* arg) { + int err; + VisionState *s = (VisionState*)arg; + + set_thread_name("visionserver"); + + int sock = ipc_bind(VIPC_SOCKET_PATH); + while (!do_exit) { + struct pollfd polls[1] = {{0}}; + polls[0].fd = sock; + polls[0].events = POLLIN; + + int ret = poll(polls, ARRAYSIZE(polls), 1000); + if (ret < 0) { + if (errno == EINTR || errno == EAGAIN) continue; + LOGE("poll failed (%d - %d)", ret, errno); + break; + } + if (do_exit) break; + if (!polls[0].revents) { + continue; + } + + int fd = accept(sock, NULL, NULL); + assert(fd >= 0); + + pthread_mutex_lock(&s->clients_lock); + + int client_idx = 0; + for (; client_idx < MAX_CLIENTS; client_idx++) { + if (!s->clients[client_idx].running) break; + } + + if (client_idx >= MAX_CLIENTS) { + LOG("ignoring visionserver connection, max clients connected"); + close(fd); + + pthread_mutex_unlock(&s->clients_lock); + continue; + } + + VisionClientState *client = &s->clients[client_idx]; + client->s = s; + client->fd = fd; + client->running = true; + + err = pthread_create(&client->thread_handle, NULL, + visionserver_client_thread, client); + assert(err == 0); + + pthread_mutex_unlock(&s->clients_lock); + } + + for (int i=0; iclients_lock); + bool running = s->clients[i].running; + pthread_mutex_unlock(&s->clients_lock); + if (running) { + err = pthread_join(s->clients[i].thread_handle, NULL); + assert(err == 0); + } + } + + close(sock); + + return NULL; +} + +void party(cl_device_id device_id, cl_context context) { + VisionState state = {}; + VisionState *s = &state; + + cameras_init(&s->cameras, device_id, context); + cameras_open(&s->cameras); + + std::thread server_thread(visionserver_thread, s); + + // priority for cameras + int err = set_realtime_priority(53); + LOG("setpriority returns %d", err); + + cameras_run(&s->cameras); + + server_thread.join(); +} + +#ifdef QCOM +#include "CL/cl_ext_qcom.h" +#endif + +int main(int argc, char *argv[]) { + set_realtime_priority(53); +#if defined(QCOM) + set_core_affinity(2); +#elif defined(QCOM2) + set_core_affinity(6); +#endif + + signal(SIGINT, (sighandler_t)set_do_exit); + signal(SIGTERM, (sighandler_t)set_do_exit); + + cl_device_id device_id = cl_get_device_id(CL_DEVICE_TYPE_DEFAULT); + + // TODO: do this for QCOM2 too +#if defined(QCOM) + const cl_context_properties props[] = {CL_CONTEXT_PRIORITY_HINT_QCOM, CL_PRIORITY_HINT_HIGH_QCOM, 0}; + cl_context context = CL_CHECK_ERR(clCreateContext(props, 1, &device_id, NULL, NULL, &err)); +#else + cl_context context = CL_CHECK_ERR(clCreateContext(NULL, 1, &device_id, NULL, NULL, &err)); +#endif + + party(device_id, context); + + CL_CHECK(clReleaseContext(context)); +} diff --git a/panda/tests/__init__.py b/selfdrive/camerad/snapshot/__init__.py similarity index 100% rename from panda/tests/__init__.py rename to selfdrive/camerad/snapshot/__init__.py diff --git a/selfdrive/camerad/snapshot/snapshot.py b/selfdrive/camerad/snapshot/snapshot.py new file mode 100755 index 00000000000000..addf293cc0bfa8 --- /dev/null +++ b/selfdrive/camerad/snapshot/snapshot.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 +import os +import signal +import subprocess +import time +from PIL import Image +from common.basedir import BASEDIR +from common.params import Params +from selfdrive.camerad.snapshot.visionipc import VisionIPC +from selfdrive.controls.lib.alertmanager import set_offroad_alert + + +def jpeg_write(fn, dat): + img = Image.fromarray(dat) + img.save(fn, "JPEG") + + +def snapshot(): + params = Params() + front_camera_allowed = int(params.get("RecordFront")) + + if params.get("IsOffroad") != b"1" or params.get("IsTakingSnapshot") == b"1": + return None + + params.put("IsTakingSnapshot", "1") + set_offroad_alert("Offroad_IsTakingSnapshot", True) + time.sleep(2.0) # Give thermald time to read the param, or if just started give camerad time to start + + # Check if camerad is already started + ps = subprocess.Popen("ps | grep camerad", shell=True, stdout=subprocess.PIPE) + ret = list(filter(lambda x: 'grep ' not in x, ps.communicate()[0].decode('utf-8').strip().split("\n"))) + if len(ret) > 0: + params.put("IsTakingSnapshot", "0") + params.delete("Offroad_IsTakingSnapshot") + return None + + proc = subprocess.Popen(os.path.join(BASEDIR, "selfdrive/camerad/camerad"), cwd=os.path.join(BASEDIR, "selfdrive/camerad")) + time.sleep(3.0) + + ret = None + start_time = time.time() + while time.time() - start_time < 5.0: + try: + ipc = VisionIPC() + pic = ipc.get() + del ipc + + if front_camera_allowed: + ipc_front = VisionIPC(front=True) + fpic = ipc_front.get() + del ipc_front + else: + fpic = None + + ret = pic, fpic + break + except Exception: + time.sleep(1) + + proc.send_signal(signal.SIGINT) + proc.communicate() + + params.put("IsTakingSnapshot", "0") + set_offroad_alert("Offroad_IsTakingSnapshot", False) + return ret + + +if __name__ == "__main__": + pic, fpic = snapshot() + print(pic.shape) + jpeg_write("/tmp/back.jpg", pic) + jpeg_write("/tmp/front.jpg", fpic) diff --git a/selfdrive/camerad/snapshot/visionipc.py b/selfdrive/camerad/snapshot/visionipc.py new file mode 100644 index 00000000000000..4df79e2cc276b0 --- /dev/null +++ b/selfdrive/camerad/snapshot/visionipc.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python3 +import os +from cffi import FFI + +import numpy as np + +gf_dir = os.path.dirname(os.path.abspath(__file__)) + +ffi = FFI() +ffi.cdef(""" + +typedef enum VisionStreamType { + VISION_STREAM_RGB_BACK, + VISION_STREAM_RGB_FRONT, + VISION_STREAM_YUV, + VISION_STREAM_YUV_FRONT, + VISION_STREAM_MAX, +} VisionStreamType; + +typedef struct VisionUIInfo { + int big_box_x, big_box_y; + int big_box_width, big_box_height; + int transformed_width, transformed_height; + + int front_box_x, front_box_y; + int front_box_width, front_box_height; +} VisionUIInfo; + +typedef struct VisionStreamBufs { + VisionStreamType type; + + int width, height, stride; + size_t buf_len; + + union { + VisionUIInfo ui_info; + } buf_info; +} VisionStreamBufs; + +typedef struct VIPCBuf { + int fd; + size_t len; + void* addr; +} VIPCBuf; + +typedef struct VIPCBufExtra { + // only for yuv + uint32_t frame_id; + uint64_t timestamp_eof; +} VIPCBufExtra; + +typedef struct VisionStream { + int ipc_fd; + int last_idx; + int last_type; + int num_bufs; + VisionStreamBufs bufs_info; + VIPCBuf *bufs; +} VisionStream; + +int visionstream_init(VisionStream *s, VisionStreamType type, bool tbuffer, VisionStreamBufs *out_bufs_info); +VIPCBuf* visionstream_get(VisionStream *s, VIPCBufExtra *out_extra); +void visionstream_destroy(VisionStream *s); + +""" +) + + +class VisionIPCError(Exception): + pass + + +class VisionIPC(): + def __init__(self, front=False): + self.clib = ffi.dlopen(os.path.join(gf_dir, "libvisionipc.so")) + + self.s = ffi.new("VisionStream*") + self.buf_info = ffi.new("VisionStreamBufs*") + + err = self.clib.visionstream_init(self.s, self.clib.VISION_STREAM_RGB_FRONT if front else self.clib.VISION_STREAM_RGB_BACK, True, self.buf_info) + + if err != 0: + self.clib.visionstream_destroy(self.s) + raise VisionIPCError + + def __del__(self): + self.clib.visionstream_destroy(self.s) + + def get(self): + buf = self.clib.visionstream_get(self.s, ffi.NULL) + pbuf = ffi.buffer(buf.addr, buf.len) + ret = np.frombuffer(pbuf, dtype=np.uint8).reshape((-1, self.buf_info.stride//3, 3)) + return ret[:self.buf_info.height, :self.buf_info.width, [2, 1, 0]] diff --git a/selfdrive/camerad/transforms/rgb_to_yuv.cc b/selfdrive/camerad/transforms/rgb_to_yuv.cc new file mode 100644 index 00000000000000..c0ac1920763898 --- /dev/null +++ b/selfdrive/camerad/transforms/rgb_to_yuv.cc @@ -0,0 +1,45 @@ +#include +#include + +#include "clutil.h" + +#include "rgb_to_yuv.h" + +void rgb_to_yuv_init(RGBToYUVState* s, cl_context ctx, cl_device_id device_id, int width, int height, int rgb_stride) { + memset(s, 0, sizeof(*s)); + printf("width %d, height %d, rgb_stride %d\n", width, height, rgb_stride); + assert(width % 2 == 0); + assert(height % 2 == 0); + s->width = width; + s->height = height; + char args[1024]; + snprintf(args, sizeof(args), + "-cl-fast-relaxed-math -cl-denorms-are-zero " +#ifdef CL_DEBUG + "-DCL_DEBUG " +#endif + "-DWIDTH=%d -DHEIGHT=%d -DUV_WIDTH=%d -DUV_HEIGHT=%d -DRGB_STRIDE=%d -DRGB_SIZE=%d", + width, height, width/ 2, height / 2, rgb_stride, width * height); + cl_program prg = cl_program_from_file(ctx, device_id, "transforms/rgb_to_yuv.cl", args); + + s->rgb_to_yuv_krnl = CL_CHECK_ERR(clCreateKernel(prg, "rgb_to_yuv", &err)); + // done with this + CL_CHECK(clReleaseProgram(prg)); +} + +void rgb_to_yuv_destroy(RGBToYUVState* s) { + CL_CHECK(clReleaseKernel(s->rgb_to_yuv_krnl)); +} + +void rgb_to_yuv_queue(RGBToYUVState* s, cl_command_queue q, cl_mem rgb_cl, cl_mem yuv_cl) { + CL_CHECK(clSetKernelArg(s->rgb_to_yuv_krnl, 0, sizeof(cl_mem), &rgb_cl)); + CL_CHECK(clSetKernelArg(s->rgb_to_yuv_krnl, 1, sizeof(cl_mem), &yuv_cl)); + const size_t work_size[2] = { + (size_t)(s->width + (s->width % 4 == 0 ? 0 : (4 - s->width % 4))) / 4, + (size_t)(s->height + (s->height % 4 == 0 ? 0 : (4 - s->height % 4))) / 4 + }; + cl_event event; + CL_CHECK(clEnqueueNDRangeKernel(q, s->rgb_to_yuv_krnl, 2, NULL, &work_size[0], NULL, 0, 0, &event)); + CL_CHECK(clWaitForEvents(1, &event)); + CL_CHECK(clReleaseEvent(event)); +} diff --git a/selfdrive/visiond/transforms/rgb_to_yuv.cl b/selfdrive/camerad/transforms/rgb_to_yuv.cl similarity index 100% rename from selfdrive/visiond/transforms/rgb_to_yuv.cl rename to selfdrive/camerad/transforms/rgb_to_yuv.cl diff --git a/selfdrive/visiond/transforms/rgb_to_yuv.h b/selfdrive/camerad/transforms/rgb_to_yuv.h similarity index 77% rename from selfdrive/visiond/transforms/rgb_to_yuv.h rename to selfdrive/camerad/transforms/rgb_to_yuv.h index 79895803456d69..05d5c5ece4a870 100644 --- a/selfdrive/visiond/transforms/rgb_to_yuv.h +++ b/selfdrive/camerad/transforms/rgb_to_yuv.h @@ -1,5 +1,4 @@ -#ifndef RGB_TO_YUV_H -#define RGB_TO_YUV_H +#pragma once #include #include @@ -10,10 +9,6 @@ #include #endif -#ifdef __cplusplus -extern "C" { -#endif - typedef struct { int width, height; cl_kernel rgb_to_yuv_krnl; @@ -24,9 +19,3 @@ void rgb_to_yuv_init(RGBToYUVState* s, cl_context ctx, cl_device_id device_id, i void rgb_to_yuv_destroy(RGBToYUVState* s); void rgb_to_yuv_queue(RGBToYUVState* s, cl_command_queue q, cl_mem rgb_cl, cl_mem yuv_cl); - -#ifdef __cplusplus -} -#endif - -#endif // RGB_TO_YUV_H diff --git a/selfdrive/visiond/transforms/rgb_to_yuv_test.cc b/selfdrive/camerad/transforms/rgb_to_yuv_test.cc similarity index 90% rename from selfdrive/visiond/transforms/rgb_to_yuv_test.cc rename to selfdrive/camerad/transforms/rgb_to_yuv_test.cc index c8b87510586d5e..a2fd4035b9cfd1 100644 --- a/selfdrive/visiond/transforms/rgb_to_yuv_test.cc +++ b/selfdrive/camerad/transforms/rgb_to_yuv_test.cc @@ -41,16 +41,8 @@ static inline double millis_since_boot() { } void cl_init(cl_device_id &device_id, cl_context &context) { - int err; - cl_platform_id platform_id = NULL; - cl_uint num_devices; - cl_uint num_platforms; - - err = clGetPlatformIDs(1, &platform_id, &num_platforms); - err = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_DEFAULT, 1, - &device_id, &num_devices); - cl_print_info(platform_id, device_id); - context = clCreateContext(NULL, 1, &device_id, NULL, NULL, &err); + device_id = cl_get_device_id(CL_DEVICE_TYPE_DEFAULT); + context = CL_CHECK_ERR(clCreateContext(NULL, 1, &device_id, NULL, NULL, &err)); } @@ -109,7 +101,6 @@ bool compare_results(uint8_t *a, uint8_t *b, int len, int stride, int width, int int main(int argc, char** argv) { srand(1337); - clu_init(); cl_device_id device_id; cl_context context; cl_init(device_id, context) ; @@ -144,13 +135,13 @@ int main(int argc, char** argv) { rgb_to_yuv_init(&rgb_to_yuv_state, context, device_id, width, height, width * 3); int frame_yuv_buf_size = width * height * 3 / 2; - cl_mem yuv_cl = clCreateBuffer(context, CL_MEM_READ_WRITE, frame_yuv_buf_size, (void*)NULL, &err); + cl_mem yuv_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, frame_yuv_buf_size, (void*)NULL, &err)); uint8_t *frame_yuv_buf = new uint8_t[frame_yuv_buf_size]; uint8_t *frame_yuv_ptr_y = frame_yuv_buf; uint8_t *frame_yuv_ptr_u = frame_yuv_buf + (width * height); uint8_t *frame_yuv_ptr_v = frame_yuv_ptr_u + ((width/2) * (height/2)); - cl_mem rgb_cl = clCreateBuffer(context, CL_MEM_READ_WRITE, width * height * 3, (void*)NULL, &err); + cl_mem rgb_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, width * height * 3, (void*)NULL, &err)); int mismatched = 0; int counter = 0; srand (time(NULL)); diff --git a/selfdrive/can/Makefile b/selfdrive/can/Makefile deleted file mode 100644 index a9ee1e6861ef5d..00000000000000 --- a/selfdrive/can/Makefile +++ /dev/null @@ -1,112 +0,0 @@ -CC = clang -CXX = clang++ - -BASEDIR = ../.. -PHONELIBS := ../../phonelibs - -UNAME_S := $(shell uname -s) -UNAME_M := $(shell uname -m) - -WARN_FLAGS = -Werror=implicit-function-declaration \ - -Werror=incompatible-pointer-types \ - -Werror=int-conversion \ - -Werror=return-type \ - -Werror=format-extra-args \ - -Wno-deprecated-declarations - -CFLAGS = -std=gnu11 -g -fPIC -O2 $(WARN_FLAGS) -CXXFLAGS = -std=c++11 -g -fPIC -O2 $(WARN_FLAGS) -LDFLAGS = - -ifeq ($(ARCH),aarch64) -CFLAGS += -mcpu=cortex-a57 -CXXFLAGS += -mcpu=cortex-a57 -endif - -ifeq ($(UNAME_S),Darwin) - ZMQ_LIBS = -L/usr/local/lib -lzmq -else ifeq ($(OPTEST),1) - ZMQ_LIBS = -lzmq -else ifeq ($(UNAME_M),x86_64) - ZMQ_FLAGS = -I$(PHONELIBS)/zmq/x64/include - ZMQ_LIBS = -L$(PHONELIBS)/zmq/x64/lib -l:libzmq.a -else ifeq ($(UNAME_M),aarch64) - ZMQ_LIBS = -l:libzmq.a -lgnustl_shared -endif - -OBJDIR = obj - -OPENDBC_PATH := $(shell python2 -c 'import opendbc; print opendbc.DBC_PATH') - -DBC_SOURCES := $(sort $(wildcard $(OPENDBC_PATH)/*.dbc)) -DBC_OBJS := $(patsubst $(OPENDBC_PATH)/%.dbc,$(OBJDIR)/%.o,$(DBC_SOURCES)) -DBC_CCS := $(patsubst $(OPENDBC_PATH)/%.dbc,dbc_out/%.cc,$(DBC_SOURCES)) -.SECONDARY: $(DBC_CCS) - -LIBDBC_OBJS := $(OBJDIR)/dbc.o $(OBJDIR)/parser.o $(OBJDIR)/packer.o - -CWD := $(shell pwd) - -.PHONY: all -all: $(OBJDIR) libdbc.so parser_pyx.so - -include ../common/cereal.mk - -# make sure cereal is built -libdbc.so:: ../../cereal/gen/cpp/log.capnp.h - -../../cereal/gen/cpp/log.capnp.h: - cd ../../cereal && make - -libdbc.so:: $(LIBDBC_OBJS) $(DBC_OBJS) - @echo "[ LINK ] $@" - $(CXX) -fPIC -shared -o '$@' $^ \ - -I. -I../.. \ - $(CXXFLAGS) \ - $(LDFLAGS) \ - $(ZMQ_FLAGS) \ - $(ZMQ_LIBS) \ - $(CEREAL_CXXFLAGS) \ - $(CEREAL_LIBS) - -packer_impl.so: packer_impl.pyx packer_setup.py - python2 packer_setup.py build_ext --inplace - rm -rf build - rm -f packer_impl.cpp - -parser_pyx.so: parser_pyx_setup.py parser_pyx.pyx parser_pyx.pxd - python $< build_ext --inplace - rm -rf build - rm -f parser_pyx.cpp - -$(OBJDIR)/%.o: %.cc - @echo "[ CXX ] $@" - $(CXX) -fPIC -c -o '$@' $^ \ - -I. -I../.. \ - $(CXXFLAGS) \ - $(ZMQ_FLAGS) \ - $(CEREAL_CXXFLAGS) \ - -$(OBJDIR)/%.o: dbc_out/%.cc - @echo "[ CXX ] $@" - $(CXX) -fPIC -c -o '$@' $^ \ - -I. -I../.. \ - $(CXXFLAGS) \ - $(ZMQ_FLAGS) \ - $(CEREAL_CXXFLAGS) \ - -dbc_out/%.cc: process_dbc.py dbc_template.cc $(OPENDBC_PATH)/%.dbc - @echo "[ DBC GEN ] $@" - @echo "Missing prereq $?" - ./process_dbc.py $(OPENDBC_PATH) dbc_out - -$(OBJDIR): - mkdir -p $@ - -.PHONY: clean $(OBJDIR) -clean: - rm -rf libdbc.so* - rm -f dbc_out/*.cc - rm -f dbcs.txt - rm -f dbcs.csv - rm -rf $(OBJDIR)/* diff --git a/selfdrive/can/can_define.py b/selfdrive/can/can_define.py deleted file mode 100644 index 48ff8798fdf150..00000000000000 --- a/selfdrive/can/can_define.py +++ /dev/null @@ -1,39 +0,0 @@ -from collections import defaultdict -from selfdrive.can.libdbc_py import libdbc, ffi - -class CANDefine(object): - def __init__(self, dbc_name): - self.dv = defaultdict(dict) - self.dbc_name = dbc_name - self.dbc = libdbc.dbc_lookup(dbc_name) - - num_vals = self.dbc[0].num_vals - - self.address_to_msg_name = {} - num_msgs = self.dbc[0].num_msgs - for i in range(num_msgs): - msg = self.dbc[0].msgs[i] - name = ffi.string(msg.name) - address = msg.address - self.address_to_msg_name[address] = name - - for i in range(num_vals): - val = self.dbc[0].vals[i] - - sgname = ffi.string(val.name) - address = val.address - def_val = ffi.string(val.def_val) - - #separate definition/value pairs - def_val = def_val.split() - values = [int(v) for v in def_val[::2]] - defs = def_val[1::2] - - if address not in self.dv: - self.dv[address] = {} - msgname = self.address_to_msg_name[address] - self.dv[msgname] = {} - - # two ways to lookup: address or msg name - self.dv[address][sgname] = {v: d for v, d in zip(values, defs)} #build dict - self.dv[msgname][sgname] = self.dv[address][sgname] diff --git a/selfdrive/can/common.h b/selfdrive/can/common.h deleted file mode 100644 index 4f097228432543..00000000000000 --- a/selfdrive/can/common.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef SELFDRIVE_CAN_COMMON_H -#define SELFDRIVE_CAN_COMMON_H - -#include -#include -#include - -#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0])) - - -unsigned int honda_checksum(unsigned int address, uint64_t d, int l); -unsigned int toyota_checksum(unsigned int address, uint64_t d, int l); -unsigned int pedal_checksum(unsigned int address, uint64_t d, int l); - -struct SignalPackValue { - const char* name; - double value; -}; - - -struct SignalParseOptions { - uint32_t address; - const char* name; - double default_value; -}; - -struct MessageParseOptions { - uint32_t address; - int check_frequency; -}; - -struct SignalValue { - uint32_t address; - uint16_t ts; - const char* name; - double value; -}; - - -enum SignalType { - DEFAULT, - HONDA_CHECKSUM, - HONDA_COUNTER, - TOYOTA_CHECKSUM, - PEDAL_CHECKSUM, - PEDAL_COUNTER, -}; - -struct Signal { - const char* name; - int b1, b2, bo; - bool is_signed; - double factor, offset; - bool is_little_endian; - SignalType type; -}; - -struct Msg { - const char* name; - uint32_t address; - unsigned int size; - size_t num_sigs; - const Signal *sigs; -}; - -struct Val { - const char* name; - uint32_t address; - const char* def_val; - const Signal *sigs; -}; - -struct DBC { - const char* name; - size_t num_msgs; - const Msg *msgs; - const Val *vals; - size_t num_vals; -}; - -const DBC* dbc_lookup(const std::string& dbc_name); - -void dbc_register(const DBC* dbc); - -#define dbc_init(dbc) \ -static void __attribute__((constructor)) do_dbc_init_ ## dbc(void) { \ - dbc_register(&dbc); \ -} - -#endif diff --git a/selfdrive/can/libdbc_py.py b/selfdrive/can/libdbc_py.py deleted file mode 100644 index 61cf8cd057ace2..00000000000000 --- a/selfdrive/can/libdbc_py.py +++ /dev/null @@ -1,94 +0,0 @@ -import os -import subprocess - -from cffi import FFI - -can_dir = os.path.dirname(os.path.abspath(__file__)) -libdbc_fn = os.path.join(can_dir, "libdbc.so") -subprocess.check_call(["make"], cwd=can_dir) - -ffi = FFI() -ffi.cdef(""" - -typedef struct { - const char* name; - double value; -} SignalPackValue; - -typedef struct { - uint32_t address; - const char* name; - double default_value; -} SignalParseOptions; - -typedef struct { - uint32_t address; - int check_frequency; -} MessageParseOptions; - -typedef struct { - uint32_t address; - uint16_t ts; - const char* name; - double value; -} SignalValue; - - -typedef enum { - DEFAULT, - HONDA_CHECKSUM, - HONDA_COUNTER, - TOYOTA_CHECKSUM, - PEDAL_CHECKSUM, - PEDAL_COUNTER, -} SignalType; - -typedef struct { - const char* name; - int b1, b2, bo; - bool is_signed; - double factor, offset; - SignalType type; -} Signal; - -typedef struct { - const char* name; - uint32_t address; - unsigned int size; - size_t num_sigs; - const Signal *sigs; -} Msg; - -typedef struct { - const char* name; - uint32_t address; - const char* def_val; - const Signal *sigs; -} Val; - -typedef struct { - const char* name; - size_t num_msgs; - const Msg *msgs; - const Val *vals; - size_t num_vals; -} DBC; - - -void* can_init(int bus, const char* dbc_name, - size_t num_message_options, const MessageParseOptions* message_options, - size_t num_signal_options, const SignalParseOptions* signal_options, bool sendcan, - const char* tcp_addr, int timeout); - -int can_update(void* can, uint64_t sec, bool wait); - -size_t can_query(void* can, uint64_t sec, bool *out_can_valid, size_t out_values_size, SignalValue* out_values); - -const DBC* dbc_lookup(const char* dbc_name); - -void* canpack_init(const char* dbc_name); - -uint64_t canpack_pack(void* inst, uint32_t address, size_t num_vals, const SignalPackValue *vals, int counter); -""") - -libdbc = ffi.dlopen(libdbc_fn) diff --git a/selfdrive/can/packer.cc b/selfdrive/can/packer.cc deleted file mode 100644 index d0e84197887a8f..00000000000000 --- a/selfdrive/can/packer.cc +++ /dev/null @@ -1,136 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include "common.h" - -#define WARN printf - -namespace { - - // this is the same as read_u64_le, but uses uint64_t as in/out - uint64_t ReverseBytes(uint64_t x) { - return ((x & 0xff00000000000000ull) >> 56) | - ((x & 0x00ff000000000000ull) >> 40) | - ((x & 0x0000ff0000000000ull) >> 24) | - ((x & 0x000000ff00000000ull) >> 8) | - ((x & 0x00000000ff000000ull) << 8) | - ((x & 0x0000000000ff0000ull) << 24) | - ((x & 0x000000000000ff00ull) << 40) | - ((x & 0x00000000000000ffull) << 56); - } - - uint64_t set_value(uint64_t ret, Signal sig, int64_t ival){ - int shift = sig.is_little_endian? sig.b1 : sig.bo; - uint64_t mask = ((1ULL << sig.b2)-1) << shift; - uint64_t dat = (ival & ((1ULL << sig.b2)-1)) << shift; - if (sig.is_little_endian) { - dat = ReverseBytes(dat); - mask = ReverseBytes(mask); - } - ret &= ~mask; - ret |= dat; - return ret; - } - - class CANPacker { - public: - CANPacker(const std::string& dbc_name) { - dbc = dbc_lookup(dbc_name); - assert(dbc); - - for (int i=0; inum_msgs; i++) { - const Msg* msg = &dbc->msgs[i]; - message_lookup[msg->address] = *msg; - for (int j=0; jnum_sigs; j++) { - const Signal* sig = &msg->sigs[j]; - signal_lookup[std::make_pair(msg->address, std::string(sig->name))] = *sig; - } - } - } - - uint64_t pack(uint32_t address, const std::vector &signals, int counter) { - uint64_t ret = 0; - for (const auto& sigval : signals) { - std::string name = std::string(sigval.name); - double value = sigval.value; - - auto sig_it = signal_lookup.find(std::make_pair(address, name)); - if (sig_it == signal_lookup.end()) { - WARN("undefined signal %s - %d\n", name.c_str(), address); - continue; - } - auto sig = sig_it->second; - - int64_t ival = (int64_t)(round((value - sig.offset) / sig.factor)); - if (ival < 0) { - ival = (1ULL << sig.b2) + ival; - } - - ret = set_value(ret, sig, ival); - } - - if (counter >= 0){ - auto sig_it = signal_lookup.find(std::make_pair(address, "COUNTER")); - if (sig_it == signal_lookup.end()) { - WARN("COUNTER not defined\n"); - return ret; - } - auto sig = sig_it->second; - - if (sig.type != SignalType::HONDA_COUNTER){ - WARN("COUNTER signal type not valid\n"); - } - - ret = set_value(ret, sig, counter); - } - - auto sig_it = signal_lookup.find(std::make_pair(address, "CHECKSUM")); - if (sig_it != signal_lookup.end()) { - auto sig = sig_it->second; - if (sig.type == SignalType::HONDA_CHECKSUM){ - unsigned int chksm = honda_checksum(address, ret, message_lookup[address].size); - ret = set_value(ret, sig, chksm); - } - else if (sig.type == SignalType::TOYOTA_CHECKSUM){ - unsigned int chksm = toyota_checksum(address, ret, message_lookup[address].size); - ret = set_value(ret, sig, chksm); - } else { - //WARN("CHECKSUM signal type not valid\n"); - } - } - - return ret; - } - - - - private: - const DBC *dbc = NULL; - std::map, Signal> signal_lookup; - std::map message_lookup; - }; - -} - -extern "C" { - void* canpack_init(const char* dbc_name) { - CANPacker *ret = new CANPacker(std::string(dbc_name)); - return (void*)ret; - } - - uint64_t canpack_pack(void* inst, uint32_t address, size_t num_vals, const SignalPackValue *vals, int counter, bool checksum) { - CANPacker *cp = (CANPacker*)inst; - - return cp->pack(address, std::vector(vals, vals+num_vals), counter); - } - - uint64_t canpack_pack_vector(void* inst, uint32_t address, const std::vector &signals, int counter) { - CANPacker *cp = (CANPacker*)inst; - return cp->pack(address, signals, counter); - } -} diff --git a/selfdrive/can/packer.py b/selfdrive/can/packer.py deleted file mode 100644 index 81a8c34270fb75..00000000000000 --- a/selfdrive/can/packer.py +++ /dev/null @@ -1,9 +0,0 @@ -# pylint: skip-file -import os -import subprocess - -can_dir = os.path.dirname(os.path.abspath(__file__)) -subprocess.check_call(["make", "packer_impl.so"], cwd=can_dir) - -from selfdrive.can.packer_impl import CANPacker -assert CANPacker diff --git a/selfdrive/can/packer_impl.pyx b/selfdrive/can/packer_impl.pyx deleted file mode 100644 index 26ce8c12679314..00000000000000 --- a/selfdrive/can/packer_impl.pyx +++ /dev/null @@ -1,111 +0,0 @@ -# distutils: language = c++ -from libc.stdint cimport uint32_t, uint64_t -from libcpp.vector cimport vector -from libcpp.map cimport map -from libcpp.string cimport string -from libcpp cimport bool -from posix.dlfcn cimport dlopen, dlsym, RTLD_LAZY -import os -import subprocess - -cdef struct SignalPackValue: - const char* name - double value - -ctypedef enum SignalType: - DEFAULT, - HONDA_CHECKSUM, - HONDA_COUNTER, - TOYOTA_CHECKSUM, - PEDAL_CHECKSUM, - PEDAL_COUNTER - -cdef struct Signal: - const char* name - int b1, b2, bo - bool is_signed - double factor, offset - SignalType type - - - -cdef struct Msg: - const char* name - uint32_t address - unsigned int size - size_t num_sigs - const Signal *sigs - -cdef struct Val: - const char* name - uint32_t address - const char* def_val - const Signal *sigs - -cdef struct DBC: - const char* name - size_t num_msgs - const Msg *msgs - const Val *vals - size_t num_vals - -ctypedef void * (*canpack_init_func)(const char* dbc_name) -ctypedef uint64_t (*canpack_pack_vector_func)(void* inst, uint32_t address, const vector[SignalPackValue] &signals, int counter) -ctypedef const DBC * (*dbc_lookup_func)(const char* dbc_name) - - -cdef class CANPacker(object): - cdef void *packer - cdef const DBC *dbc - cdef map[string, (int, int)] name_to_address_and_size - cdef map[int, int] address_to_size - cdef canpack_init_func canpack_init - cdef canpack_pack_vector_func canpack_pack_vector - cdef dbc_lookup_func dbc_lookup - - def __init__(self, dbc_name): - can_dir = os.path.dirname(os.path.abspath(__file__)) - libdbc_fn = os.path.join(can_dir, "libdbc.so") - subprocess.check_call(["make"], cwd=can_dir) - cdef void *libdbc = dlopen(libdbc_fn, RTLD_LAZY) - self.canpack_init = dlsym(libdbc, 'canpack_init') - self.canpack_pack_vector = dlsym(libdbc, 'canpack_pack_vector') - self.dbc_lookup = dlsym(libdbc, 'dbc_lookup') - self.packer = self.canpack_init(dbc_name) - self.dbc = self.dbc_lookup(dbc_name) - num_msgs = self.dbc[0].num_msgs - for i in range(num_msgs): - msg = self.dbc[0].msgs[i] - self.name_to_address_and_size[string(msg.name)] = (msg.address, msg.size) - self.address_to_size[msg.address] = msg.size - - cdef uint64_t pack(self, addr, values, counter): - cdef vector[SignalPackValue] values_thing - cdef SignalPackValue spv - for name, value in values.iteritems(): - spv.name = name - spv.value = value - values_thing.push_back(spv) - - return self.canpack_pack_vector(self.packer, addr, values_thing, counter) - - cdef inline uint64_t ReverseBytes(self, uint64_t x): - return (((x & 0xff00000000000000ull) >> 56) | - ((x & 0x00ff000000000000ull) >> 40) | - ((x & 0x0000ff0000000000ull) >> 24) | - ((x & 0x000000ff00000000ull) >> 8) | - ((x & 0x00000000ff000000ull) << 8) | - ((x & 0x0000000000ff0000ull) << 24) | - ((x & 0x000000000000ff00ull) << 40) | - ((x & 0x00000000000000ffull) << 56)) - - cpdef make_can_msg(self, name_or_addr, bus, values, counter=-1): - cdef int addr, size - if type(name_or_addr) == int: - addr = name_or_addr - size = self.address_to_size[name_or_addr] - else: - addr, size = self.name_to_address_and_size[name_or_addr] - cdef uint64_t val = self.pack(addr, values, counter) - val = self.ReverseBytes(val) - return [addr, 0, (&val)[:size], bus] diff --git a/selfdrive/can/packer_setup.py b/selfdrive/can/packer_setup.py deleted file mode 100644 index a36d4199ee57dc..00000000000000 --- a/selfdrive/can/packer_setup.py +++ /dev/null @@ -1,5 +0,0 @@ -from distutils.core import setup, Extension -from Cython.Build import cythonize - -setup(name='CAN Packer API Implementation', - ext_modules=cythonize(Extension("packer_impl", ["packer_impl.pyx"], language="c++", extra_compile_args=["-std=c++11"]))) diff --git a/selfdrive/can/parser.cc b/selfdrive/can/parser.cc deleted file mode 100644 index eadaa39e35674f..00000000000000 --- a/selfdrive/can/parser.cc +++ /dev/null @@ -1,581 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include "cereal/gen/cpp/log.capnp.h" - -#include "common.h" - -#define DEBUG(...) -// #define DEBUG printf -#define INFO printf - - -#define MAX_BAD_COUNTER 5 - -unsigned int honda_checksum(unsigned int address, uint64_t d, int l) { - d >>= ((8-l)*8); // remove padding - d >>= 4; // remove checksum - - int s = 0; - while (address) { s += (address & 0xF); address >>= 4; } - while (d) { s += (d & 0xF); d >>= 4; } - s = 8-s; - s &= 0xF; - - return s; -} - -unsigned int toyota_checksum(unsigned int address, uint64_t d, int l) { - d >>= ((8-l)*8); // remove padding - d >>= 8; // remove checksum - - unsigned int s = l; - while (address) { s += address & 0xff; address >>= 8; } - while (d) { s += d & 0xff; d >>= 8; } - - return s & 0xFF; -} - -unsigned int pedal_checksum(unsigned int address, uint64_t d, int l) { - uint8_t crc = 0xFF; - uint8_t poly = 0xD5; // standard crc8 - - d >>= ((8-l)*8); // remove padding - d >>= 8; // remove checksum - - uint8_t *dat = (uint8_t *)&d; - - int i, j; - for (i = 0; i < l - 1; i++) { - crc ^= dat[i]; - for (j = 0; j < 8; j++) { - if ((crc & 0x80) != 0) { - crc = (uint8_t)((crc << 1) ^ poly); - } - else { - crc <<= 1; - } - } - } - return crc; -} - -namespace { - -uint64_t read_u64_be(const uint8_t* v) { - return (((uint64_t)v[0] << 56) - | ((uint64_t)v[1] << 48) - | ((uint64_t)v[2] << 40) - | ((uint64_t)v[3] << 32) - | ((uint64_t)v[4] << 24) - | ((uint64_t)v[5] << 16) - | ((uint64_t)v[6] << 8) - | (uint64_t)v[7]); -} - -uint64_t read_u64_le(const uint8_t* v) { - return ((uint64_t)v[0] - | ((uint64_t)v[1] << 8) - | ((uint64_t)v[2] << 16) - | ((uint64_t)v[3] << 24) - | ((uint64_t)v[4] << 32) - | ((uint64_t)v[5] << 40) - | ((uint64_t)v[6] << 48) - | ((uint64_t)v[7] << 56)); -} - - -struct MessageState { - uint32_t address; - unsigned int size; - - std::vector parse_sigs; - std::vector vals; - - uint16_t ts; - uint64_t seen; - uint64_t check_threshold; - - uint8_t counter; - uint8_t counter_fail; - - bool parse(uint64_t sec, uint16_t ts_, uint64_t dat) { - for (int i=0; i < parse_sigs.size(); i++) { - auto& sig = parse_sigs[i]; - int64_t tmp; - - if (sig.is_little_endian){ - tmp = (dat >> sig.b1) & ((1ULL << sig.b2)-1); - } else { - tmp = (dat >> sig.bo) & ((1ULL << sig.b2)-1); - } - - if (sig.is_signed) { - tmp -= (tmp >> (sig.b2-1)) ? (1ULL << sig.b2) : 0; //signed - } - - // Testing both little and big endian signals (Tesla messages) - //if ( (address == 0x318) || (address == 0x118)) { - // INFO("parse %X %s -> %f, dat -> %lX\n", address, sig.name, tmp * sig.factor + sig.offset, dat); - //} - - DEBUG("parse %X %s -> %lld\n", address, sig.name, tmp); - - if (sig.type == SignalType::HONDA_CHECKSUM) { - if (honda_checksum(address, dat, size) != tmp) { - INFO("%X CHECKSUM FAIL\n", address); - return false; - } - } else if (sig.type == SignalType::HONDA_COUNTER) { - if (!update_counter_generic(tmp, sig.b2)) { - return false; - } - } else if (sig.type == SignalType::TOYOTA_CHECKSUM) { - if (toyota_checksum(address, dat, size) != tmp) { - INFO("%X CHECKSUM FAIL\n", address); - return false; - } - } else if (sig.type == SignalType::PEDAL_CHECKSUM) { - if (pedal_checksum(address, dat, size) != tmp) { - INFO("%X PEDAL CHECKSUM FAIL\n", address); - return false; - } - } else if (sig.type == SignalType::PEDAL_COUNTER) { - if (!update_counter_generic(tmp, sig.b2)) { - return false; - } - } - - vals[i] = tmp * sig.factor + sig.offset; - } - ts = ts_; - seen = sec; - - return true; - } - - - bool update_counter_generic(int64_t v, int cnt_size) { - uint8_t old_counter = counter; - counter = v; - if (((old_counter+1) & ((1 << cnt_size) -1)) != v) { - counter_fail += 1; - if (counter_fail > 1) { - INFO("%X COUNTER FAIL %d -- %d vs %d\n", address, counter_fail, old_counter, (int)v); - } - if (counter_fail >= MAX_BAD_COUNTER) { - return false; - } - } else if (counter_fail > 0) { - counter_fail--; - } - return true; - } - -}; - - -class CANParser { - public: - CANParser(int abus, const std::string& dbc_name, - const std::vector &options, - const std::vector &sigoptions, - bool sendcan, const std::string& tcp_addr, int timeout=-1) - : bus(abus) { - // connect to can on 8006 - context = zmq_ctx_new(); - - if (tcp_addr.length() > 0) { - subscriber = zmq_socket(context, ZMQ_SUB); - zmq_setsockopt(subscriber, ZMQ_SUBSCRIBE, "", 0); - zmq_setsockopt(subscriber, ZMQ_RCVTIMEO, &timeout, sizeof(int)); - - std::string tcp_addr_str; - - if (sendcan) { - tcp_addr_str = "tcp://" + tcp_addr + ":8017"; - } else { - tcp_addr_str = "tcp://" + tcp_addr + ":8006"; - } - const char *tcp_addr_char = tcp_addr_str.c_str(); - - zmq_connect(subscriber, tcp_addr_char); - - // drain sendcan to delete any stale messages from previous runs - zmq_msg_t msgDrain; - zmq_msg_init(&msgDrain); - int err = 0; - while(err >= 0) { - err = zmq_msg_recv(&msgDrain, subscriber, ZMQ_DONTWAIT); - } - } else { - subscriber = NULL; - } - - dbc = dbc_lookup(dbc_name); - assert(dbc); - for (const auto& op : options) { - MessageState state = { - .address = op.address, - // .check_frequency = op.check_frequency, - }; - - // msg is not valid if a message isn't received for 10 consecutive steps - if (op.check_frequency > 0) { - state.check_threshold = (1000000000ULL / op.check_frequency) * 10; - } - - - const Msg* msg = NULL; - for (int i=0; inum_msgs; i++) { - if (dbc->msgs[i].address == op.address) { - msg = &dbc->msgs[i]; - break; - } - } - if (!msg) { - fprintf(stderr, "CANParser: could not find message 0x%X in dnc %s\n", op.address, dbc_name.c_str()); - assert(false); - } - - state.size = msg->size; - - // track checksums and counters for this message - for (int i=0; inum_sigs; i++) { - const Signal *sig = &msg->sigs[i]; - if (sig->type != SignalType::DEFAULT) { - state.parse_sigs.push_back(*sig); - state.vals.push_back(0); - } - } - - // track requested signals for this message - for (const auto& sigop : sigoptions) { - if (sigop.address != op.address) continue; - - for (int i=0; inum_sigs; i++) { - const Signal *sig = &msg->sigs[i]; - if (strcmp(sig->name, sigop.name) == 0 - && sig->type == SignalType::DEFAULT) { - state.parse_sigs.push_back(*sig); - state.vals.push_back(sigop.default_value); - break; - } - } - - } - - message_states[state.address] = state; - } - } - - void UpdateCans(uint64_t sec, const capnp::List::Reader& cans) { - int msg_count = cans.size(); - uint64_t p; - - DEBUG("got %d messages\n", msg_count); - - // parse the messages - for (int i = 0; i < msg_count; i++) { - auto cmsg = cans[i]; - if (cmsg.getSrc() != bus) { - // DEBUG("skip %d: wrong bus\n", cmsg.getAddress()); - continue; - } - auto state_it = message_states.find(cmsg.getAddress()); - if (state_it == message_states.end()) { - // DEBUG("skip %d: not specified\n", cmsg.getAddress()); - continue; - } - - if (cmsg.getDat().size() > 8) continue; //shouldnt ever happen - uint8_t dat[8] = {0}; - memcpy(dat, cmsg.getDat().begin(), cmsg.getDat().size()); - - // Assumes all signals in the message are of the same type (little or big endian) - // TODO: allow signals within the same message to have different endianess - auto& sig = message_states[cmsg.getAddress()].parse_sigs[0]; - if (sig.is_little_endian) { - p = read_u64_le(dat); - } else { - p = read_u64_be(dat); - } - - DEBUG(" proc %X: %llx\n", cmsg.getAddress(), p); - - state_it->second.parse(sec, cmsg.getBusTime(), p); - } - } - - void UpdateValid(uint64_t sec) { - can_valid = true; - for (const auto& kv : message_states) { - const auto& state = kv.second; - if (state.check_threshold > 0 && (sec - state.seen) > state.check_threshold) { - if (state.seen > 0) { - DEBUG("%X TIMEOUT\n", state.address); - } - can_valid = false; - } - } - } - - void update_string(uint64_t sec, std::string data) { - // format for board, make copy due to alignment issues, will be freed on out of scope - auto amsg = kj::heapArray((data.length() / sizeof(capnp::word)) + 1); - memcpy(amsg.begin(), data.data(), data.length()); - - // extract the messages - capnp::FlatArrayMessageReader cmsg(amsg); - cereal::Event::Reader event = cmsg.getRoot(); - - auto cans = event.getCan(); - UpdateCans(sec, cans); - - UpdateValid(sec); - } - - int update(uint64_t sec, bool wait) { - int err; - int frame_count; - int result = 0; - - // recv from can - zmq_msg_t msg; - zmq_msg_init(&msg); - - // multiple recv is fine - bool first = wait; - while (subscriber != NULL) { - if (first) { - err = zmq_msg_recv(&msg, subscriber, 0); - first = false; - - // When we timeout on the first message, return error - if (err < 0){ - result = -1; - } - } else { - err = zmq_msg_recv(&msg, subscriber, ZMQ_DONTWAIT); - } - if (err < 0) break; - frame_count++; - // format for board, make copy due to alignment issues, will be freed on out of scope - auto amsg = kj::heapArray((zmq_msg_size(&msg) / sizeof(capnp::word)) + 1); - memcpy(amsg.begin(), zmq_msg_data(&msg), zmq_msg_size(&msg)); - - // extract the messages - capnp::FlatArrayMessageReader cmsg(amsg); - cereal::Event::Reader event = cmsg.getRoot(); - - auto cans = event.getCan(); - UpdateCans(sec, cans); - } - //if (frame_count > 1) printf(" %d frames received!", frame_count); - UpdateValid(sec); - zmq_msg_close(&msg); - return result; - } - - std::vector query(uint64_t sec) { - std::vector ret; - - for (const auto& kv : message_states) { - const auto& state = kv.second; - if (sec != 0 && state.seen != sec) continue; - - for (int i=0; i message_states; -}; - -} - -extern "C" { - -void* can_init(int bus, const char* dbc_name, - size_t num_message_options, const MessageParseOptions* message_options, - size_t num_signal_options, const SignalParseOptions* signal_options, - bool sendcan, const char* tcp_addr, int timeout) { - CANParser* ret = new CANParser(bus, std::string(dbc_name), - (message_options ? std::vector(message_options, message_options+num_message_options) - : std::vector{}), - (signal_options ? std::vector(signal_options, signal_options+num_signal_options) - : std::vector{}), sendcan, std::string(tcp_addr), timeout); - return (void*)ret; -} - -void* can_init_with_vectors(int bus, const char* dbc_name, - std::vector message_options, - std::vector signal_options, - bool sendcan, const char* tcp_addr, int timeout) { - CANParser* ret = new CANParser(bus, std::string(dbc_name), - message_options, - signal_options, - sendcan, std::string(tcp_addr), timeout); - return (void*)ret; -} - -int can_update(void* can, uint64_t sec, bool wait) { - CANParser* cp = (CANParser*)can; - return cp->update(sec, wait); -} - -void can_update_string(void *can, uint64_t sec, const char* dat, int len) { - CANParser* cp = (CANParser*)can; - cp->update_string(sec, std::string(dat, len)); -} - -size_t can_query(void* can, uint64_t sec, bool *out_can_valid, size_t out_values_size, SignalValue* out_values) { - CANParser* cp = (CANParser*)can; - - if (out_can_valid) { - *out_can_valid = cp->can_valid; - } - - const std::vector values = cp->query(sec); - if (out_values) { - std::copy(values.begin(), values.begin()+std::min(out_values_size, values.size()), out_values); - } - return values.size(); -}; - -void can_query_vector(void* can, uint64_t sec, bool *out_can_valid, std::vector &values) { - CANParser* cp = (CANParser*)can; - if (out_can_valid) { - *out_can_valid = cp->can_valid; - } - values = cp->query(sec); -}; - -} - -#ifdef TEST - -int main(int argc, char** argv) { - CANParser cp(0, "honda_civic_touring_2016_can", - std::vector{ - // address, check_frequency - {0x14a, 100}, - {0x158, 100}, - {0x17c, 100}, - {0x191, 100}, - {0x1a4, 50}, - {0x326, 10}, - {0x1b0, 50}, - {0x1d0, 50}, - {0x305, 10}, - {0x324, 10}, - {0x405, 3}, - {0x18f, 0}, - {0x130, 0}, - {0x296, 0}, - {0x30c, 0}, - }, - std::vector{ - // sig_name, sig_address, default - {0x158, "XMISSION_SPEED", 0}, - {0x1d0, "WHEEL_SPEED_FL", 0}, - {0x1d0, "WHEEL_SPEED_FR", 0}, - {0x1d0, "WHEEL_SPEED_RL", 0}, - {0x14a, "STEER_ANGLE", 0}, - {0x18f, "STEER_TORQUE_SENSOR", 0}, - {0x191, "GEAR", 0}, - {0x1b0, "WHEELS_MOVING", 1}, - {0x405, "DOOR_OPEN_FL", 1}, - {0x405, "DOOR_OPEN_FR", 1}, - {0x405, "DOOR_OPEN_RL", 1}, - {0x405, "DOOR_OPEN_RR", 1}, - {0x324, "CRUISE_SPEED_PCM", 0}, - {0x305, "SEATBELT_DRIVER_LAMP", 1}, - {0x305, "SEATBELT_DRIVER_LATCHED", 0}, - {0x17c, "BRAKE_PRESSED", 0}, - {0x130, "CAR_GAS", 0}, - {0x296, "CRUISE_BUTTONS", 0}, - {0x1a4, "ESP_DISABLED", 1}, - {0x30c, "HUD_LEAD", 0}, - {0x1a4, "USER_BRAKE", 0}, - {0x18f, "STEER_STATUS", 5}, - {0x1d0, "WHEEL_SPEED_RR", 0}, - {0x1b0, "BRAKE_ERROR_1", 1}, - {0x1b0, "BRAKE_ERROR_2", 1}, - {0x191, "GEAR_SHIFTER", 0}, - {0x326, "MAIN_ON", 0}, - {0x17c, "ACC_STATUS", 0}, - {0x17c, "PEDAL_GAS", 0}, - {0x296, "CRUISE_SETTING", 0}, - {0x326, "LEFT_BLINKER", 0}, - {0x326, "RIGHT_BLINKER", 0}, - {0x324, "COUNTER", 0}, - {0x17c, "ENGINE_RPM", 0}, - }); - - - - const std::string log_fn = "dats.bin"; - - int log_fd = open(log_fn.c_str(), O_RDONLY, 0); - assert(log_fd >= 0); - - off_t log_size = lseek(log_fd, 0, SEEK_END); - lseek(log_fd, 0, SEEK_SET); - - void* log_data = mmap(NULL, log_size, PROT_READ, MAP_PRIVATE, log_fd, 0); - assert(log_data); - - auto words = kj::arrayPtr((const capnp::word*)log_data, log_size/sizeof(capnp::word)); - while (words.size() > 0) { - capnp::FlatArrayMessageReader reader(words); - - auto evt = reader.getRoot(); - auto cans = evt.getCan(); - - cp.UpdateCans(0, cans); - - words = kj::arrayPtr(reader.getEnd(), words.end()); - } - - munmap(log_data, log_size); - - close(log_fd); - - return 0; -} - -#endif diff --git a/selfdrive/can/parser.py b/selfdrive/can/parser.py deleted file mode 100644 index b8b2061dc9167d..00000000000000 --- a/selfdrive/can/parser.py +++ /dev/null @@ -1,9 +0,0 @@ -import os -import subprocess - -can_dir = os.path.dirname(os.path.abspath(__file__)) -libdbc_fn = os.path.join(can_dir, "libdbc.so") -subprocess.check_call(["make"], cwd=can_dir) - -from selfdrive.can.parser_pyx import CANParser # pylint: disable=no-name-in-module, import-error -assert CANParser diff --git a/selfdrive/can/parser_pyx.pxd b/selfdrive/can/parser_pyx.pxd deleted file mode 100644 index ac619707acc77b..00000000000000 --- a/selfdrive/can/parser_pyx.pxd +++ /dev/null @@ -1,94 +0,0 @@ -# distutils: language = c++ -from libc.stdint cimport uint32_t, uint64_t, uint16_t -from libcpp.vector cimport vector -from libcpp.map cimport map -from libcpp.string cimport string -from libcpp.unordered_set cimport unordered_set -from libcpp cimport bool - -ctypedef enum SignalType: - DEFAULT, - HONDA_CHECKSUM, - HONDA_COUNTER, - TOYOTA_CHECKSUM, - PEDAL_CHECKSUM, - PEDAL_COUNTER - -cdef struct Signal: - const char* name - int b1, b2, bo - bool is_signed - double factor, offset - SignalType type - - - -cdef struct Msg: - const char* name - uint32_t address - unsigned int size - size_t num_sigs - const Signal *sigs - -cdef struct Val: - const char* name - uint32_t address - const char* def_val - const Signal *sigs - -cdef struct DBC: - const char* name - size_t num_msgs - const Msg *msgs - const Val *vals - size_t num_vals - -cdef struct SignalParseOptions: - uint32_t address - const char* name - double default_value - - -cdef struct MessageParseOptions: - uint32_t address - int check_frequency - -cdef struct SignalValue: - uint32_t address - uint16_t ts - const char* name - double value - -ctypedef const DBC * (*dbc_lookup_func)(const char* dbc_name) -ctypedef void* (*can_init_with_vectors_func)(int bus, const char* dbc_name, - vector[MessageParseOptions] message_options, - vector[SignalParseOptions] signal_options, - bool sendcan, - const char* tcp_addr, - int timeout) -ctypedef int (*can_update_func)(void* can, uint64_t sec, bool wait); -ctypedef void (*can_update_string_func)(void* can, uint64_t sec, const char* dat, int len); -ctypedef size_t (*can_query_func)(void* can, uint64_t sec, bool *out_can_valid, size_t out_values_size, SignalValue* out_values); -ctypedef void (*can_query_vector_func)(void* can, uint64_t sec, bool *out_can_valid, vector[SignalValue] &values) - -cdef class CANParser: - cdef: - void *can - const DBC *dbc - dbc_lookup_func dbc_lookup - can_init_with_vectors_func can_init_with_vectors - can_update_func can_update - can_update_string_func can_update_string - can_query_vector_func can_query_vector - map[string, uint32_t] msg_name_to_address - map[uint32_t, string] address_to_msg_name - vector[SignalValue] can_values - bool test_mode_enabled - cdef public: - string dbc_name - dict vl - dict ts - bool can_valid - int can_invalid_cnt - - cdef unordered_set[uint32_t] update_vl(self, uint64_t sec) diff --git a/selfdrive/can/parser_pyx.pyx b/selfdrive/can/parser_pyx.pyx deleted file mode 100644 index c6f1f58e030dc9..00000000000000 --- a/selfdrive/can/parser_pyx.pyx +++ /dev/null @@ -1,119 +0,0 @@ -# distutils: language = c++ -from posix.dlfcn cimport dlopen, dlsym, RTLD_LAZY - -from libcpp cimport bool -import os -import numbers - -cdef int CAN_INVALID_CNT = 5 - -cdef class CANParser: - def __init__(self, dbc_name, signals, checks=None, bus=0, sendcan=False, tcp_addr="", timeout=-1): - self.test_mode_enabled = False - can_dir = os.path.dirname(os.path.abspath(__file__)) - libdbc_fn = os.path.join(can_dir, "libdbc.so") - - cdef void *libdbc = dlopen(libdbc_fn, RTLD_LAZY) - self.can_init_with_vectors = dlsym(libdbc, 'can_init_with_vectors') - self.dbc_lookup = dlsym(libdbc, 'dbc_lookup') - self.can_update = dlsym(libdbc, 'can_update') - self.can_update_string = dlsym(libdbc, 'can_update_string') - self.can_query_vector = dlsym(libdbc, 'can_query_vector') - if checks is None: - checks = [] - - self.can_valid = True - self.dbc_name = dbc_name - self.dbc = self.dbc_lookup(dbc_name) - self.vl = {} - self.ts = {} - - self.can_invalid_cnt = CAN_INVALID_CNT - - num_msgs = self.dbc[0].num_msgs - for i in range(num_msgs): - msg = self.dbc[0].msgs[i] - self.msg_name_to_address[string(msg.name)] = msg.address - self.address_to_msg_name[msg.address] = string(msg.name) - self.vl[msg.address] = {} - self.vl[str(msg.name)] = {} - self.ts[msg.address] = {} - self.ts[str(msg.name)] = {} - - # Convert message names into addresses - for i in range(len(signals)): - s = signals[i] - if not isinstance(s[1], numbers.Number): - s = (s[0], self.msg_name_to_address[s[1]], s[2]) - signals[i] = s - - for i in range(len(checks)): - c = checks[i] - if not isinstance(c[0], numbers.Number): - c = (self.msg_name_to_address[c[0]], c[1]) - checks[i] = c - - cdef vector[SignalParseOptions] signal_options_v - cdef SignalParseOptions spo - for sig_name, sig_address, sig_default in signals: - spo.address = sig_address - spo.name = sig_name - spo.default_value = sig_default - signal_options_v.push_back(spo) - - message_options = dict((address, 0) for _, address, _ in signals) - message_options.update(dict(checks)) - - cdef vector[MessageParseOptions] message_options_v - cdef MessageParseOptions mpo - for msg_address, freq in message_options.items(): - mpo.address = msg_address - mpo.check_frequency = freq - message_options_v.push_back(mpo) - - self.can = self.can_init_with_vectors(bus, dbc_name, message_options_v, signal_options_v, sendcan, tcp_addr, timeout) - self.update_vl(0) - - cdef unordered_set[uint32_t] update_vl(self, uint64_t sec): - cdef string sig_name - cdef unordered_set[uint32_t] updated_val - cdef bool valid = False - - self.can_query_vector(self.can, sec, &valid, self.can_values) - - # Update invalid flag - self.can_invalid_cnt += 1 - if valid: - self.can_invalid_cnt = 0 - self.can_valid = self.can_invalid_cnt < CAN_INVALID_CNT - - - for cv in self.can_values: - self.vl[cv.address][string(cv.name)] = cv.value - self.ts[cv.address][string(cv.name)] = cv.ts - - sig_name = self.address_to_msg_name[cv.address] - self.vl[sig_name][string(cv.name)] = cv.value - self.ts[sig_name][string(cv.name)] = cv.ts - - updated_val.insert(cv.address) - - return updated_val - - def update_string(self, uint64_t sec, dat): - self.can_update_string(self.can, sec, dat, len(dat)) - return self.update_vl(sec) - - def update_strings(self, uint64_t sec, strings): - updated_vals = set() - - for s in strings: - updated_val = self.update_string(sec, s) - updated_vals.update(updated_val) - - return updated_vals - - def update(self, uint64_t sec, bool wait): - r = (self.can_update(self.can, sec, wait) >= 0) - updated_val = self.update_vl(sec) - return r, updated_val diff --git a/selfdrive/can/parser_pyx_setup.py b/selfdrive/can/parser_pyx_setup.py deleted file mode 100644 index f20224f34352ae..00000000000000 --- a/selfdrive/can/parser_pyx_setup.py +++ /dev/null @@ -1,18 +0,0 @@ -from distutils.core import setup, Extension -from Cython.Build import cythonize -import subprocess - -sourcefiles = ['parser_pyx.pyx'] -extra_compile_args = ["-std=c++11"] -ARCH = subprocess.check_output(["uname", "-m"]).rstrip() -if ARCH == "aarch64": - extra_compile_args += ["-Wno-deprecated-register"] - -setup(name='Radard Thread', - ext_modules=cythonize( - Extension( - "parser_pyx", - sources=sourcefiles, - extra_compile_args=extra_compile_args - ), - nthreads=4)) diff --git a/selfdrive/can/plant_can_parser.py b/selfdrive/can/plant_can_parser.py deleted file mode 100644 index 40799db83c8130..00000000000000 --- a/selfdrive/can/plant_can_parser.py +++ /dev/null @@ -1,138 +0,0 @@ -### old can parser just used by plant.py for regression tests -import os -import opendbc -from collections import defaultdict - -from selfdrive.car.honda.hondacan import fix -from common.realtime import sec_since_boot -from common.dbc import dbc -from selfdrive.tinklad.tinkla_interface import TinklaClient - -class CANParser(object): - def __init__(self, dbc_f, signals, checks=None): - ### input: - # dbc_f : dbc file - # signals : List of tuples (name, address, ival) where - # - name is the signal name. - # - address is the corresponding message address. - # - ival is the initial value. - # checks : List of pairs (address, frequency) where - # - address is the message address of a message for which health should be - # monitored. - # - frequency is the frequency at which health should be monitored. - - checks = [] if checks is None else checks - self.msgs_ck = set([check[0] for check in checks]) - self.frqs = dict(checks) - self.can_valid = False # start with False CAN assumption - # list of received msg we want to monitor counter and checksum for - # read dbc file - self.can_dbc = dbc(os.path.join(opendbc.DBC_PATH, dbc_f)) - # initialize variables to initial values - self.vl = {} # signal values - self.ts = {} # time stamp recorded in log - self.ct = {} # current time stamp - self.ok = {} # valid message? - self.cn = {} # message counter - self.cn_vl = {} # message counter mismatch value - self.ck = {} # message checksum status - - for _, addr, _ in signals: - self.vl[addr] = {} - self.ts[addr] = {} - self.ct[addr] = sec_since_boot() - self.ok[addr] = True - self.cn[addr] = 0 - self.cn_vl[addr] = 0 - self.ck[addr] = False - - for name, addr, ival in signals: - self.vl[addr][name] = ival - self.ts[addr][name] = 0 - - self._msgs = [s[1] for s in signals] - self._sgs = [s[0] for s in signals] - - self._message_indices = defaultdict(list) - for i, x in enumerate(self._msgs): - self._message_indices[x].append(i) - - self.tinklaClient = TinklaClient() - - def update_can(self, can_recv): - msgs_upd = [] - cn_vl_max = 5 # no more than 5 wrong counter checks - - self.sec_since_boot_cached = sec_since_boot() - - # we are subscribing to PID_XXX, else data from USB - for msg, ts, cdat, _ in can_recv: - idxs = self._message_indices[msg] - if idxs: - msgs_upd.append(msg) - # read the entire message - out = self.can_dbc.decode((msg, 0, cdat))[1] - # checksum check - self.ck[msg] = True - if "CHECKSUM" in out.keys() and msg in self.msgs_ck: - # remove checksum (half byte) - ck_portion = cdat[:-1] + chr(ord(cdat[-1]) & 0xF0) - # recalculate checksum - msg_vl = fix(ck_portion, msg) - # compare recalculated vs received checksum - if msg_vl != cdat: - print("CHECKSUM FAIL: {0}".format(hex(msg))) - self.tinklaClient.logCANErrorEvent(canMessage=msg, additionalInformation="Checksum failure") - self.ck[msg] = False - self.ok[msg] = False - # counter check - cn = 0 - if "COUNTER" in out.keys(): - cn = out["COUNTER"] - # check counter validity if it's a relevant message - if cn != ((self.cn[msg] + 1) % 4) and msg in self.msgs_ck and "COUNTER" in out.keys(): - #print("FAILED COUNTER: {0}".format(hex(msg)() - self.cn_vl[msg] += 1 # counter check failed - else: - self.cn_vl[msg] -= 1 # counter check passed - # message status is invalid if we received too many wrong counter values - if self.cn_vl[msg] >= cn_vl_max: - print("COUNTER WRONG: {0}".format(hex(msg))) - self.tinklaClient.logCANErrorEvent(canMessage=msg, additionalInformation="Too many wrong counter values") - self.ok[msg] = False - - # update msg time stamps and counter value - self.ct[msg] = self.sec_since_boot_cached - self.cn[msg] = cn - self.cn_vl[msg] = min(max(self.cn_vl[msg], 0), cn_vl_max) - - # set msg valid status if checksum is good and wrong counter counter is zero - if self.ck[msg] and self.cn_vl[msg] == 0: - self.ok[msg] = True - - # update value of signals in the - for ii in idxs: - sg = self._sgs[ii] - self.vl[msg][sg] = out[sg] - self.ts[msg][sg] = ts - - # for each message, check if it's too long since last time we received it - self._check_dead_msgs() - - # assess overall can validity: if there is one relevant message invalid, then set can validity flag to False - self.can_valid = True - - if False in self.ok.values(): - #print("CAN INVALID!") - self.can_valid = False - - return msgs_upd - - def _check_dead_msgs(self): - ### input: - ## simple stuff for now: msg is not valid if a message isn't received for 10 consecutive steps - for msg in set(self._msgs): - if msg in self.msgs_ck and self.sec_since_boot_cached - self.ct[msg] > 10./self.frqs[msg]: - self.ok[msg] = False - self.tinklaClient.logCANErrorEvent(canMessage=msg, additionalInformation="Dead message") - diff --git a/selfdrive/can/process_dbc.py b/selfdrive/can/process_dbc.py deleted file mode 100755 index 5f9237020b8221..00000000000000 --- a/selfdrive/can/process_dbc.py +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env python2 -import os -import glob -import sys - -import jinja2 - -from collections import Counter -from common.dbc import dbc - -def main(): - if len(sys.argv) != 3: - print "usage: %s dbc_directory output_directory" % (sys.argv[0],) - sys.exit(0) - - dbc_dir = sys.argv[1] - out_dir = sys.argv[2] - - template_fn = os.path.join(os.path.dirname(__file__), "dbc_template.cc") - template_mtime = os.path.getmtime(template_fn) - - this_file_mtime = os.path.getmtime(__file__) - - with open(template_fn, "r") as template_f: - template = jinja2.Template(template_f.read(), trim_blocks=True, lstrip_blocks=True) - - for dbc_path in glob.iglob(os.path.join(dbc_dir, "*.dbc")): - dbc_mtime = os.path.getmtime(dbc_path) - dbc_fn = os.path.split(dbc_path)[1] - dbc_name = os.path.splitext(dbc_fn)[0] - can_dbc = dbc(dbc_path) - out_fn = os.path.join(os.path.dirname(__file__), out_dir, dbc_name + ".cc") - if os.path.exists(out_fn): - out_mtime = os.path.getmtime(out_fn) - else: - out_mtime = 0 - - if dbc_mtime < out_mtime and template_mtime < out_mtime and this_file_mtime < out_mtime: - continue #skip output is newer than template and dbc - - msgs = [(address, msg_name, msg_size, sorted(msg_sigs, key=lambda s: s.name not in ("COUNTER", "CHECKSUM"))) # process counter and checksums first - for address, ((msg_name, msg_size), msg_sigs) in sorted(can_dbc.msgs.items()) if msg_sigs] - - def_vals = {a: set(b) for a,b in can_dbc.def_vals.items()} #remove duplicates - def_vals = [(address, sig) for address, sig in sorted(def_vals.items())] - - if can_dbc.name.startswith("honda") or can_dbc.name.startswith("acura"): - checksum_type = "honda" - checksum_size = 4 - elif can_dbc.name.startswith("toyota") or can_dbc.name.startswith("lexus"): - checksum_type = "toyota" - checksum_size = 8 - else: - checksum_type = None - - for address, msg_name, msg_size, sigs in msgs: - for sig in sigs: - if checksum_type is not None and sig.name == "CHECKSUM": - if sig.size != checksum_size: - sys.exit("CHECKSUM is not %d bits longs %s" % (checksum_size, msg_name)) - if checksum_type == "honda" and sig.start_bit % 8 != 3: - sys.exit("CHECKSUM starts at wrong bit %s" % msg_name) - if checksum_type == "toyota" and sig.start_bit % 8 != 7: - sys.exit("CHECKSUM starts at wrong bit %s" % msg_name) - if checksum_type == "honda" and sig.name == "COUNTER": - if sig.size != 2: - sys.exit("COUNTER is not 2 bits longs %s" % msg_name) - if sig.start_bit % 8 != 5: - sys.exit("COUNTER starts at wrong bit %s" % msg_name) - if address in [0x200, 0x201]: - if sig.name == "COUNTER_PEDAL" and sig.size != 4: - sys.exit("PEDAL COUNTER is not 4 bits longs %s" % msg_name) - if sig.name == "CHECKSUM_PEDAL" and sig.size != 8: - sys.exit("PEDAL CHECKSUM is not 8 bits longs %s" % msg_name) - - # Fail on duplicate message names - c = Counter([msg_name for address, msg_name, msg_size, sigs in msgs]) - for name, count in c.items(): - if count > 1: - sys.exit("Duplicate message name in DBC file %s" % name) - - parser_code = template.render(dbc=can_dbc, checksum_type=checksum_type, msgs=msgs, def_vals=def_vals, len=len) - - - with open(out_fn, "w") as out_f: - out_f.write(parser_code) - -if __name__ == '__main__': - main() diff --git a/selfdrive/can/tests/packer_old.py b/selfdrive/can/tests/packer_old.py deleted file mode 100644 index 0c17c2e4d9177a..00000000000000 --- a/selfdrive/can/tests/packer_old.py +++ /dev/null @@ -1,67 +0,0 @@ -import struct -from selfdrive.can.libdbc_py import libdbc, ffi - - -class CANPacker(object): - def __init__(self, dbc_name): - self.packer = libdbc.canpack_init(dbc_name) - self.dbc = libdbc.dbc_lookup(dbc_name) - self.sig_names = {} - self.name_to_address_and_size = {} - - num_msgs = self.dbc[0].num_msgs - for i in range(num_msgs): - msg = self.dbc[0].msgs[i] - - name = ffi.string(msg.name) - address = msg.address - self.name_to_address_and_size[name] = (address, msg.size) - self.name_to_address_and_size[address] = (address, msg.size) - - def pack(self, addr, values, counter): - values_thing = [] - for name, value in values.iteritems(): - if name not in self.sig_names: - self.sig_names[name] = ffi.new("char[]", name) - - values_thing.append({ - 'name': self.sig_names[name], - 'value': value - }) - - values_c = ffi.new("SignalPackValue[]", values_thing) - - return libdbc.canpack_pack(self.packer, addr, len(values_thing), values_c, counter) - - def pack_bytes(self, addr, values, counter=-1): - addr, size = self.name_to_address_and_size[addr] - - val = self.pack(addr, values, counter) - r = struct.pack(">Q", val) - return addr, r[:size] - - def make_can_msg(self, addr, bus, values, counter=-1): - addr, msg = self.pack_bytes(addr, values, counter) - return [addr, 0, msg, bus] - - -if __name__ == "__main__": - ## little endian test - cp = CANPacker("hyundai_santa_fe_2019_ccan") - s = cp.pack_bytes(0x340, { - "CR_Lkas_StrToqReq": -0.06, - #"CF_Lkas_FcwBasReq": 1, - "CF_Lkas_MsgCount": 7, - "CF_Lkas_HbaSysState": 0, - #"CF_Lkas_Chksum": 3, - }) - s = cp.pack_bytes(0x340, { - "CF_Lkas_MsgCount": 1, - }) - # big endian test - #cp = CANPacker("honda_civic_touring_2016_can_generated") - #s = cp.pack_bytes(0xe4, { - # "STEER_TORQUE": -2, - #}) - print([hex(ord(v)) for v in s[1]]) - print(s[1].encode("hex")) diff --git a/selfdrive/can/tests/parser_old.py b/selfdrive/can/tests/parser_old.py deleted file mode 100644 index 5a899efa50c6f4..00000000000000 --- a/selfdrive/can/tests/parser_old.py +++ /dev/null @@ -1,220 +0,0 @@ -import time -import numbers - -from selfdrive.can.libdbc_py import libdbc, ffi - -CAN_INVALID_CNT = 5 # after so many consecutive CAN data with wrong checksum, counter or frequency, flag CAN invalidity - -class CANParser(object): - def __init__(self, dbc_name, signals, checks=None, bus=0, sendcan=False, tcp_addr="127.0.0.1", timeout=-1): - if checks is None: - checks = [] - - self.can_valid = True - self.can_invalid_cnt = CAN_INVALID_CNT - self.vl = {} - self.ts = {} - - self.dbc_name = dbc_name - self.dbc = libdbc.dbc_lookup(dbc_name) - self.msg_name_to_addres = {} - self.address_to_msg_name = {} - - num_msgs = self.dbc[0].num_msgs - for i in range(num_msgs): - msg = self.dbc[0].msgs[i] - - name = ffi.string(msg.name) - address = msg.address - - self.msg_name_to_addres[name] = address - self.address_to_msg_name[address] = name - - self.vl[address] = {} - self.vl[name] = {} - self.ts[address] = {} - self.ts[name] = {} - - # Convert message names into addresses - for i in range(len(signals)): - s = signals[i] - if not isinstance(s[1], numbers.Number): - s = (s[0], self.msg_name_to_addres[s[1]], s[2]) - signals[i] = s - - for i in range(len(checks)): - c = checks[i] - if not isinstance(c[0], numbers.Number): - c = (self.msg_name_to_addres[c[0]], c[1]) - checks[i] = c - - sig_names = dict((name, ffi.new("char[]", name)) for name, _, _ in signals) - - signal_options_c = ffi.new("SignalParseOptions[]", [ - { - 'address': sig_address, - 'name': sig_names[sig_name], - 'default_value': sig_default, - } for sig_name, sig_address, sig_default in signals]) - - message_options = dict((address, 0) for _, address, _ in signals) - message_options.update(dict(checks)) - - message_options_c = ffi.new("MessageParseOptions[]", [ - { - 'address': msg_address, - 'check_frequency': freq, - } for msg_address, freq in message_options.items()]) - - self.can = libdbc.can_init(bus, dbc_name, len(message_options_c), message_options_c, - len(signal_options_c), signal_options_c, sendcan, tcp_addr, timeout) - - self.p_can_valid = ffi.new("bool*") - - value_count = libdbc.can_query(self.can, 0, self.p_can_valid, 0, ffi.NULL) - self.can_values = ffi.new("SignalValue[%d]" % value_count) - self.update_vl(0) - - def update_vl(self, sec): - can_values_len = libdbc.can_query(self.can, sec, self.p_can_valid, len(self.can_values), self.can_values) - assert can_values_len <= len(self.can_values) - - self.can_invalid_cnt += 1 - if self.p_can_valid[0]: - self.can_invalid_cnt = 0 - self.can_valid = self.can_invalid_cnt < CAN_INVALID_CNT - - ret = set() - for i in xrange(can_values_len): - cv = self.can_values[i] - address = cv.address - # print("{0} {1}".format(hex(cv.address), ffi.string(cv.name))) - name = ffi.string(cv.name) - self.vl[address][name] = cv.value - self.ts[address][name] = cv.ts - - sig_name = self.address_to_msg_name[address] - self.vl[sig_name][name] = cv.value - self.ts[sig_name][name] = cv.ts - ret.add(address) - return ret - - def update(self, sec, wait): - """Returns if the update was successfull (e.g. no rcv timeout happened)""" - r = libdbc.can_update(self.can, sec, wait) - return bool(r >= 0), self.update_vl(sec) - - -if __name__ == "__main__": - from common.realtime import sec_since_boot - - radar_messages = range(0x430, 0x43A) + range(0x440, 0x446) - # signals = zip(['LONG_DIST'] * 16 + ['NEW_TRACK'] * 16 + ['LAT_DIST'] * 16 + - # ['REL_SPEED'] * 16, radar_messages * 4, - # [255] * 16 + [1] * 16 + [0] * 16 + [0] * 16) - # checks = zip(radar_messages, [20]*16) - - # cp = CANParser("acura_ilx_2016_nidec", signals, checks, 1) - - - # signals = [ - # ("XMISSION_SPEED", 0x158, 0), #sig_name, sig_address, default - # ("WHEEL_SPEED_FL", 0x1d0, 0), - # ("WHEEL_SPEED_FR", 0x1d0, 0), - # ("WHEEL_SPEED_RL", 0x1d0, 0), - # ("STEER_ANGLE", 0x14a, 0), - # ("STEER_TORQUE_SENSOR", 0x18f, 0), - # ("GEAR", 0x191, 0), - # ("WHEELS_MOVING", 0x1b0, 1), - # ("DOOR_OPEN_FL", 0x405, 1), - # ("DOOR_OPEN_FR", 0x405, 1), - # ("DOOR_OPEN_RL", 0x405, 1), - # ("DOOR_OPEN_RR", 0x405, 1), - # ("CRUISE_SPEED_PCM", 0x324, 0), - # ("SEATBELT_DRIVER_LAMP", 0x305, 1), - # ("SEATBELT_DRIVER_LATCHED", 0x305, 0), - # ("BRAKE_PRESSED", 0x17c, 0), - # ("CAR_GAS", 0x130, 0), - # ("CRUISE_BUTTONS", 0x296, 0), - # ("ESP_DISABLED", 0x1a4, 1), - # ("HUD_LEAD", 0x30c, 0), - # ("USER_BRAKE", 0x1a4, 0), - # ("STEER_STATUS", 0x18f, 5), - # ("WHEEL_SPEED_RR", 0x1d0, 0), - # ("BRAKE_ERROR_1", 0x1b0, 1), - # ("BRAKE_ERROR_2", 0x1b0, 1), - # ("GEAR_SHIFTER", 0x191, 0), - # ("MAIN_ON", 0x326, 0), - # ("ACC_STATUS", 0x17c, 0), - # ("PEDAL_GAS", 0x17c, 0), - # ("CRUISE_SETTING", 0x296, 0), - # ("LEFT_BLINKER", 0x326, 0), - # ("RIGHT_BLINKER", 0x326, 0), - # ("COUNTER", 0x324, 0), - # ("ENGINE_RPM", 0x17C, 0) - # ] - # checks = [ - # (0x14a, 100), # address, frequency - # (0x158, 100), - # (0x17c, 100), - # (0x191, 100), - # (0x1a4, 50), - # (0x326, 10), - # (0x1b0, 50), - # (0x1d0, 50), - # (0x305, 10), - # (0x324, 10), - # (0x405, 3), - # ] - - # cp = CANParser("honda_civic_touring_2016_can_generated", signals, checks, 0) - - - signals = [ - # sig_name, sig_address, default - ("GEAR", 956, 0x20), - ("BRAKE_PRESSED", 548, 0), - ("GAS_PEDAL", 705, 0), - - ("WHEEL_SPEED_FL", 170, 0), - ("WHEEL_SPEED_FR", 170, 0), - ("WHEEL_SPEED_RL", 170, 0), - ("WHEEL_SPEED_RR", 170, 0), - ("DOOR_OPEN_FL", 1568, 1), - ("DOOR_OPEN_FR", 1568, 1), - ("DOOR_OPEN_RL", 1568, 1), - ("DOOR_OPEN_RR", 1568, 1), - ("SEATBELT_DRIVER_UNLATCHED", 1568, 1), - ("TC_DISABLED", 951, 1), - ("STEER_ANGLE", 37, 0), - ("STEER_FRACTION", 37, 0), - ("STEER_RATE", 37, 0), - ("GAS_RELEASED", 466, 0), - ("CRUISE_STATE", 466, 0), - ("MAIN_ON", 467, 0), - ("SET_SPEED", 467, 0), - ("STEER_TORQUE_DRIVER", 608, 0), - ("STEER_TORQUE_EPS", 608, 0), - ("TURN_SIGNALS", 1556, 3), # 3 is no blinkers - ("LKA_STATE", 610, 0), - ] - checks = [ - (548, 40), - (705, 33), - - (170, 80), - (37, 80), - (466, 33), - (608, 50), - ] - - cp = CANParser("toyota_rav4_2017_pt_generated", signals, checks, 0) - - # print(cp.vl) - - while True: - cp.update(int(sec_since_boot()*1e9), True) - # print(cp.vl) - print(cp.ts) - print(cp.can_valid) - time.sleep(0.01) diff --git a/selfdrive/can/tests/test_packer_chrysler.py b/selfdrive/can/tests/test_packer_chrysler.py deleted file mode 100644 index da85a9841500fb..00000000000000 --- a/selfdrive/can/tests/test_packer_chrysler.py +++ /dev/null @@ -1,35 +0,0 @@ -import unittest -import random - -from selfdrive.can.tests.packer_old import CANPacker as CANPackerOld -from selfdrive.can.packer import CANPacker -import selfdrive.car.chrysler.chryslercan as chryslercan - - -class TestPackerMethods(unittest.TestCase): - def setUp(self): - self.chrysler_cp_old = CANPackerOld("chrysler_pacifica_2017_hybrid") - self.chrysler_cp = CANPacker("chrysler_pacifica_2017_hybrid") - - def test_correctness(self): - # Test all commands, randomize the params. - for _ in xrange(1000): - gear = ('drive', 'reverse', 'low')[random.randint(0, 3) % 3] - lkas_active = (random.randint(0, 2) % 2 == 0) - hud_alert = random.randint(0, 6) - hud_count = random.randint(0, 65536) - lkas_car_model = random.randint(0, 65536) - m_old = chryslercan.create_lkas_hud(self.chrysler_cp_old, gear, lkas_active, hud_alert, hud_count, lkas_car_model) - m = chryslercan.create_lkas_hud(self.chrysler_cp, gear, lkas_active, hud_alert, hud_count, lkas_car_model) - self.assertEqual(m_old, m) - - apply_steer = (random.randint(0, 2) % 2 == 0) - moving_fast = (random.randint(0, 2) % 2 == 0) - frame = random.randint(0, 65536) - m_old = chryslercan.create_lkas_command(self.chrysler_cp_old, apply_steer, moving_fast, frame) - m = chryslercan.create_lkas_command(self.chrysler_cp, apply_steer, moving_fast, frame) - self.assertEqual(m_old, m) - - -if __name__ == "__main__": - unittest.main() diff --git a/selfdrive/can/tests/test_packer_gm.py b/selfdrive/can/tests/test_packer_gm.py deleted file mode 100644 index db5631fbbe4986..00000000000000 --- a/selfdrive/can/tests/test_packer_gm.py +++ /dev/null @@ -1,66 +0,0 @@ -import unittest -import random - -from selfdrive.can.tests.packer_old import CANPacker as CANPackerOld -from selfdrive.can.packer import CANPacker -import selfdrive.car.gm.gmcan as gmcan -from selfdrive.car.gm.interface import CanBus as GMCanBus - - -class TestPackerMethods(unittest.TestCase): - def setUp(self): - self.gm_cp_old = CANPackerOld("gm_global_a_powertrain") - self.gm_cp = CANPacker("gm_global_a_powertrain") - - self.ct6_cp_old = CANPackerOld("cadillac_ct6_chassis") - self.ct6_cp = CANPacker("cadillac_ct6_chassis") - - def test_correctness(self): - # Test all cars' commands, randomize the params. - for _ in xrange(1000): - bus = random.randint(0, 65536) - apply_steer = (random.randint(0, 2) % 2 == 0) - idx = random.randint(0, 65536) - lkas_active = (random.randint(0, 2) % 2 == 0) - m_old = gmcan.create_steering_control(self.gm_cp_old, bus, apply_steer, idx, lkas_active) - m = gmcan.create_steering_control(self.gm_cp, bus, apply_steer, idx, lkas_active) - self.assertEqual(m_old, m) - - canbus = GMCanBus() - apply_steer = (random.randint(0, 2) % 2 == 0) - v_ego = random.randint(0, 65536) - idx = random.randint(0, 65536) - enabled = (random.randint(0, 2) % 2 == 0) - m_old = gmcan.create_steering_control_ct6(self.ct6_cp_old, canbus, apply_steer, v_ego, idx, enabled) - m = gmcan.create_steering_control_ct6(self.ct6_cp, canbus, apply_steer, v_ego, idx, enabled) - self.assertEqual(m_old, m) - - bus = random.randint(0, 65536) - throttle = random.randint(0, 65536) - idx = random.randint(0, 65536) - acc_engaged = (random.randint(0, 2) % 2 == 0) - at_full_stop = (random.randint(0, 2) % 2 == 0) - m_old = gmcan.create_gas_regen_command(self.gm_cp_old, bus, throttle, idx, acc_engaged, at_full_stop) - m = gmcan.create_gas_regen_command(self.gm_cp, bus, throttle, idx, acc_engaged, at_full_stop) - self.assertEqual(m_old, m) - - bus = random.randint(0, 65536) - apply_brake = (random.randint(0, 2) % 2 == 0) - idx = random.randint(0, 65536) - near_stop = (random.randint(0, 2) % 2 == 0) - at_full_stop = (random.randint(0, 2) % 2 == 0) - m_old = gmcan.create_friction_brake_command(self.ct6_cp_old, bus, apply_brake, idx, near_stop, at_full_stop) - m = gmcan.create_friction_brake_command(self.ct6_cp, bus, apply_brake, idx, near_stop, at_full_stop) - self.assertEqual(m_old, m) - - bus = random.randint(0, 65536) - acc_engaged = (random.randint(0, 2) % 2 == 0) - target_speed_kph = random.randint(0, 65536) - lead_car_in_sight = (random.randint(0, 2) % 2 == 0) - m_old = gmcan.create_acc_dashboard_command(self.gm_cp_old, bus, acc_engaged, target_speed_kph, lead_car_in_sight) - m = gmcan.create_acc_dashboard_command(self.gm_cp, bus, acc_engaged, target_speed_kph, lead_car_in_sight) - self.assertEqual(m_old, m) - - -if __name__ == "__main__": - unittest.main() diff --git a/selfdrive/can/tests/test_packer_honda.py b/selfdrive/can/tests/test_packer_honda.py deleted file mode 100644 index b6e779e40cf60d..00000000000000 --- a/selfdrive/can/tests/test_packer_honda.py +++ /dev/null @@ -1,56 +0,0 @@ -import unittest -import random - -from selfdrive.can.tests.packer_old import CANPacker as CANPackerOld -from selfdrive.can.packer import CANPacker -import selfdrive.car.honda.hondacan as hondacan -from selfdrive.car.honda.values import HONDA_BOSCH -from selfdrive.car.honda.carcontroller import HUDData - - -class TestPackerMethods(unittest.TestCase): - def setUp(self): - self.honda_cp_old = CANPackerOld("honda_pilot_touring_2017_can_generated") - self.honda_cp = CANPacker("honda_pilot_touring_2017_can_generated") - - def test_correctness(self): - # Test all commands, randomize the params. - for _ in xrange(1000): - is_panda_black = False - car_fingerprint = HONDA_BOSCH[0] - - apply_brake = (random.randint(0, 2) % 2 == 0) - pump_on = (random.randint(0, 2) % 2 == 0) - pcm_override = (random.randint(0, 2) % 2 == 0) - pcm_cancel_cmd = (random.randint(0, 2) % 2 == 0) - fcw = random.randint(0, 65536) - idx = random.randint(0, 65536) - m_old = hondacan.create_brake_command(self.honda_cp_old, apply_brake, pump_on, pcm_override, pcm_cancel_cmd, fcw, idx, car_fingerprint, is_panda_black) - m = hondacan.create_brake_command(self.honda_cp, apply_brake, pump_on, pcm_override, pcm_cancel_cmd, fcw, idx, car_fingerprint, is_panda_black) - self.assertEqual(m_old, m) - - apply_steer = (random.randint(0, 2) % 2 == 0) - lkas_active = (random.randint(0, 2) % 2 == 0) - idx = random.randint(0, 65536) - m_old = hondacan.create_steering_control(self.honda_cp_old, apply_steer, lkas_active, car_fingerprint, idx, is_panda_black) - m = hondacan.create_steering_control(self.honda_cp, apply_steer, lkas_active, car_fingerprint, idx, is_panda_black) - self.assertEqual(m_old, m) - - pcm_speed = random.randint(0, 65536) - hud = HUDData(random.randint(0, 65536), random.randint(0, 65536), 1, random.randint(0, 65536), - 0xc1, random.randint(0, 65536), random.randint(0, 65536), random.randint(0, 65536), random.randint(0, 65536)) - idx = random.randint(0, 65536) - is_metric = (random.randint(0, 2) % 2 == 0) - m_old = hondacan.create_ui_commands(self.honda_cp_old, pcm_speed, hud, car_fingerprint, is_metric, idx, is_panda_black) - m = hondacan.create_ui_commands(self.honda_cp, pcm_speed, hud, car_fingerprint, is_metric, idx, is_panda_black) - self.assertEqual(m_old, m) - - button_val = random.randint(0, 65536) - idx = random.randint(0, 65536) - m_old = hondacan.spam_buttons_command(self.honda_cp_old, button_val, idx, car_fingerprint, is_panda_black) - m = hondacan.spam_buttons_command(self.honda_cp, button_val, idx, car_fingerprint, is_panda_black) - self.assertEqual(m_old, m) - - -if __name__ == "__main__": - unittest.main() diff --git a/selfdrive/can/tests/test_packer_hyundai.py b/selfdrive/can/tests/test_packer_hyundai.py deleted file mode 100644 index d9e829ad59dafe..00000000000000 --- a/selfdrive/can/tests/test_packer_hyundai.py +++ /dev/null @@ -1,70 +0,0 @@ -import unittest -import random - -from selfdrive.can.tests.packer_old import CANPacker as CANPackerOld -from selfdrive.can.packer import CANPacker -import selfdrive.car.hyundai.hyundaican as hyundaican -from selfdrive.car.hyundai.values import CHECKSUM as hyundai_checksum - - -class TestPackerMethods(unittest.TestCase): - def setUp(self): - self.hyundai_cp_old = CANPackerOld("hyundai_kia_generic") - self.hyundai_cp = CANPacker("hyundai_kia_generic") - - def test_correctness(self): - # Test all commands, randomize the params. - for _ in xrange(1000): - # Hyundai - car_fingerprint = hyundai_checksum["crc8"][0] - apply_steer = (random.randint(0, 2) % 2 == 0) - steer_req = (random.randint(0, 2) % 2 == 0) - cnt = random.randint(0, 65536) - enabled = (random.randint(0, 2) % 2 == 0) - lkas11 = { - "CF_Lkas_LdwsSysState": random.randint(0,65536), - "CF_Lkas_SysWarning": random.randint(0,65536), - "CF_Lkas_LdwsLHWarning": random.randint(0,65536), - "CF_Lkas_LdwsRHWarning": random.randint(0,65536), - "CF_Lkas_HbaLamp": random.randint(0,65536), - "CF_Lkas_FcwBasReq": random.randint(0,65536), - "CF_Lkas_ToiFlt": random.randint(0,65536), - "CF_Lkas_HbaSysState": random.randint(0,65536), - "CF_Lkas_FcwOpt": random.randint(0,65536), - "CF_Lkas_HbaOpt": random.randint(0,65536), - "CF_Lkas_FcwSysState": random.randint(0,65536), - "CF_Lkas_FcwCollisionWarning": random.randint(0,65536), - "CF_Lkas_FusionState": random.randint(0,65536), - "CF_Lkas_FcwOpt_USM": random.randint(0,65536), - "CF_Lkas_LdwsOpt_USM": random.randint(0,65536) - } - hud_alert = random.randint(0, 65536) - keep_stock = (random.randint(0, 2) % 2 == 0) - m_old = hyundaican.create_lkas11(self.hyundai_cp_old, car_fingerprint, apply_steer, steer_req, cnt, enabled, - lkas11, hud_alert, keep_stock) - m = hyundaican.create_lkas11(self.hyundai_cp, car_fingerprint, apply_steer, steer_req, cnt, enabled, - lkas11, hud_alert, keep_stock) - self.assertEqual(m_old, m) - - clu11 = { - "CF_Clu_CruiseSwState": random.randint(0,65536), - "CF_Clu_CruiseSwMain": random.randint(0,65536), - "CF_Clu_SldMainSW": random.randint(0,65536), - "CF_Clu_ParityBit1": random.randint(0,65536), - "CF_Clu_VanzDecimal": random.randint(0,65536), - "CF_Clu_Vanz": random.randint(0,65536), - "CF_Clu_SPEED_UNIT": random.randint(0,65536), - "CF_Clu_DetentOut": random.randint(0,65536), - "CF_Clu_RheostatLevel": random.randint(0,65536), - "CF_Clu_CluInfo": random.randint(0,65536), - "CF_Clu_AmpInfo": random.randint(0,65536), - "CF_Clu_AliveCnt1": random.randint(0,65536), - } - button = random.randint(0, 65536) - m_old = hyundaican.create_clu11(self.hyundai_cp_old, clu11, button) - m = hyundaican.create_clu11(self.hyundai_cp, clu11, button) - self.assertEqual(m_old, m) - - -if __name__ == "__main__": - unittest.main() diff --git a/selfdrive/can/tests/test_packer_subaru.py b/selfdrive/can/tests/test_packer_subaru.py deleted file mode 100644 index 65dd77cf8311b9..00000000000000 --- a/selfdrive/can/tests/test_packer_subaru.py +++ /dev/null @@ -1,37 +0,0 @@ -import unittest -import random - -from selfdrive.can.tests.packer_old import CANPacker as CANPackerOld -from selfdrive.can.packer import CANPacker -import selfdrive.car.subaru.subarucan as subarucan -from selfdrive.car.subaru.values import CAR as subaru_car - - -class TestPackerMethods(unittest.TestCase): - def setUp(self): - self.subaru_cp_old = CANPackerOld("subaru_global_2017") - self.subaru_cp = CANPacker("subaru_global_2017") - - def test_correctness(self): - # Test all cars' commands, randomize the params. - for _ in xrange(1000): - apply_steer = (random.randint(0, 2) % 2 == 0) - frame = random.randint(1, 65536) - steer_step = random.randint(1, 65536) - m_old = subarucan.create_steering_control(self.subaru_cp_old, subaru_car.IMPREZA, apply_steer, frame, steer_step) - m = subarucan.create_steering_control(self.subaru_cp, subaru_car.IMPREZA, apply_steer, frame, steer_step) - self.assertEqual(m_old, m) - - m_old = subarucan.create_steering_status(self.subaru_cp_old, subaru_car.IMPREZA, apply_steer, frame, steer_step) - m = subarucan.create_steering_status(self.subaru_cp, subaru_car.IMPREZA, apply_steer, frame, steer_step) - self.assertEqual(m_old, m) - - es_distance_msg = {} - pcm_cancel_cmd = (random.randint(0, 2) % 2 == 0) - m_old = subarucan.create_es_distance(self.subaru_cp_old, es_distance_msg, pcm_cancel_cmd) - m = subarucan.create_es_distance(self.subaru_cp, es_distance_msg, pcm_cancel_cmd) - self.assertEqual(m_old, m) - - -if __name__ == "__main__": - unittest.main() diff --git a/selfdrive/can/tests/test_packer_toyota.py b/selfdrive/can/tests/test_packer_toyota.py deleted file mode 100644 index f5f0e8a7f431d0..00000000000000 --- a/selfdrive/can/tests/test_packer_toyota.py +++ /dev/null @@ -1,84 +0,0 @@ -import unittest -import random - -from selfdrive.can.tests.packer_old import CANPacker as CANPackerOld -from selfdrive.can.packer import CANPacker -from selfdrive.car.toyota.toyotacan import ( - create_ipas_steer_command, create_steer_command, create_accel_command, - create_fcw_command, create_ui_command -) -from common.realtime import sec_since_boot - - -class TestPackerMethods(unittest.TestCase): - def setUp(self): - self.cp_old = CANPackerOld("toyota_rav4_hybrid_2017_pt_generated") - self.cp = CANPacker("toyota_rav4_hybrid_2017_pt_generated") - - def test_correctness(self): - # Test all commands, randomize the params. - for _ in xrange(1000): - # Toyota - steer = random.randint(-1, 1) - enabled = (random.randint(0, 2) % 2 == 0) - apgs_enabled = (random.randint(0, 2) % 2 == 0) - m_old = create_ipas_steer_command(self.cp_old, steer, enabled, apgs_enabled) - m = create_ipas_steer_command(self.cp, steer, enabled, apgs_enabled) - self.assertEqual(m_old, m) - - steer = (random.randint(0, 2) % 2 == 0) - steer_req = (random.randint(0, 2) % 2 == 0) - raw_cnt = random.randint(1, 65536) - m_old = create_steer_command(self.cp_old, steer, steer_req, raw_cnt) - m = create_steer_command(self.cp, steer, steer_req, raw_cnt) - self.assertEqual(m_old, m) - - accel = (random.randint(0, 2) % 2 == 0) - pcm_cancel = (random.randint(0, 2) % 2 == 0) - standstill_req = (random.randint(0, 2) % 2 == 0) - lead = (random.randint(0, 2) % 2 == 0) - m_old = create_accel_command(self.cp_old, accel, pcm_cancel, standstill_req, lead) - m = create_accel_command(self.cp, accel, pcm_cancel, standstill_req, lead) - self.assertEqual(m_old, m) - - fcw = random.randint(1, 65536) - m_old = create_fcw_command(self.cp_old, fcw) - m = create_fcw_command(self.cp, fcw) - self.assertEqual(m_old, m) - - steer = (random.randint(0, 2) % 2 == 0) - left_line = (random.randint(0, 2) % 2 == 0) - right_line = (random.randint(0, 2) % 2 == 0) - left_lane_depart = (random.randint(0, 2) % 2 == 0) - right_lane_depart = (random.randint(0, 2) % 2 == 0) - m_old = create_ui_command(self.cp_old, steer, left_line, right_line, left_lane_depart, right_lane_depart) - m = create_ui_command(self.cp, steer, left_line, right_line, left_lane_depart, right_lane_depart) - self.assertEqual(m_old, m) - - def test_performance(self): - n1 = sec_since_boot() - recursions = 100000 - steer = (random.randint(0, 2) % 2 == 0) - left_line = (random.randint(0, 2) % 2 == 0) - right_line = (random.randint(0, 2) % 2 == 0) - left_lane_depart = (random.randint(0, 2) % 2 == 0) - right_lane_depart = (random.randint(0, 2) % 2 == 0) - - for _ in xrange(recursions): - create_ui_command(self.cp_old, steer, left_line, right_line, left_lane_depart, right_lane_depart) - n2 = sec_since_boot() - elapsed_old = n2 - n1 - - # print('Old API, elapsed time: {} secs'.format(elapsed_old)) - n1 = sec_since_boot() - for _ in xrange(recursions): - create_ui_command(self.cp, steer, left_line, right_line, left_lane_depart, right_lane_depart) - n2 = sec_since_boot() - elapsed_new = n2 - n1 - # print('New API, elapsed time: {} secs'.format(elapsed_new)) - self.assertTrue(elapsed_new < elapsed_old / 2) - - - -if __name__ == "__main__": - unittest.main() diff --git a/selfdrive/can/tests/test_parser.py b/selfdrive/can/tests/test_parser.py deleted file mode 100755 index 53c95ce912be15..00000000000000 --- a/selfdrive/can/tests/test_parser.py +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env python2 - -import os -import unittest - -import requests - -import selfdrive.messaging as messaging -from selfdrive.can.parser import CANParser as CANParserNew -from selfdrive.can.tests.parser_old import CANParser as CANParserOld -from selfdrive.car.honda.carstate import get_can_signals -from selfdrive.car.honda.interface import CarInterface -from selfdrive.car.honda.values import CAR, DBC -from selfdrive.services import service_list -from tools.lib.logreader import LogReader - -BASE_URL = "https://commadataci.blob.core.windows.net/openpilotci/" -DT = int(0.01 * 1e9) # ns - - -def dict_keys_differ(dict1, dict2): - keys1 = set(dict1.keys()) - keys2 = set(dict2.keys()) - - if keys1 != keys2: - return True - - for k in keys1: - keys1 = set(dict1[k].keys()) - keys2 = set(dict2[k].keys()) - - if keys1 != keys2: - return True - - return False - -def dicts_vals_differ(dict1, dict2): - for k_outer in dict1.keys(): - for k_inner in dict1[k_outer].keys(): - if dict1[k_outer][k_inner] != dict2[k_outer][k_inner]: - return True - - return False - -def run_route(route): - can = messaging.pub_sock(service_list['can'].port) - - CP = CarInterface.get_params(CAR.CIVIC, {}) - signals, checks = get_can_signals(CP) - parser_old = CANParserOld(DBC[CP.carFingerprint]['pt'], signals, checks, 0, timeout=-1, tcp_addr="127.0.0.1") - parser_new = CANParserNew(DBC[CP.carFingerprint]['pt'], signals, checks, 0, timeout=-1, tcp_addr="127.0.0.1") - parser_string = CANParserNew(DBC[CP.carFingerprint]['pt'], signals, checks, 0, timeout=-1) - - if dict_keys_differ(parser_old.vl, parser_new.vl): - return False - - lr = LogReader(route + ".bz2") - - route_ok = True - - t = 0 - for msg in lr: - if msg.which() == 'can': - t += DT - msg_bytes = msg.as_builder().to_bytes() - can.send(msg_bytes) - - _, updated_old = parser_old.update(t, True) - _, updated_new = parser_new.update(t, True) - updated_string = parser_string.update_string(t, msg_bytes) - - if updated_old != updated_new: - route_ok = False - print(t, "Diff in seen") - - if updated_new != updated_string: - route_ok = False - print(t, "Diff in seen string") - - if dicts_vals_differ(parser_old.vl, parser_new.vl): - print(t, "Diff in dict") - route_ok = False - - if dicts_vals_differ(parser_new.vl, parser_string.vl): - print(t, "Diff in dict string") - route_ok = False - - return route_ok - -class TestCanParser(unittest.TestCase): - def setUp(self): - self.routes = { - CAR.CIVIC: "b0c9d2329ad1606b|2019-05-30--20-23-57" - } - - for route in self.routes.values(): - route_filename = route + ".bz2" - if not os.path.isfile(route_filename): - with open(route + ".bz2", "w") as f: - f.write(requests.get(BASE_URL + route_filename).content) - - def test_parser_civic(self): - self.assertTrue(run_route(self.routes[CAR.CIVIC])) - - -if __name__ == "__main__": - unittest.main() diff --git a/selfdrive/car/__init__.py b/selfdrive/car/__init__.py index 3b259c622289fd..7701f90a6d9062 100644 --- a/selfdrive/car/__init__.py +++ b/selfdrive/car/__init__.py @@ -4,6 +4,11 @@ # kg of standard extra cargo to count for drive, gas, etc... STD_CARGO_KG = 136. + +def gen_empty_fingerprint(): + return {i: {} for i in range(0, 4)} + + # FIXME: hardcoding honda civic 2016 touring params so they can be used to # scale unknown params for other cars class CivicParams: @@ -15,11 +20,13 @@ class CivicParams: TIRE_STIFFNESS_FRONT = 192150 TIRE_STIFFNESS_REAR = 202500 + # TODO: get actual value, for now starting with reasonable value for # civic and scaling by mass and wheelbase def scale_rot_inertia(mass, wheelbase): return CivicParams.ROTATIONAL_INERTIA * mass * wheelbase ** 2 / (CivicParams.MASS * CivicParams.WHEELBASE ** 2) + # TODO: start from empirically derived lateral slip stiffness for the civic and scale by # mass and CG position, so all cars will have approximately similar dyn behaviors def scale_tire_stiffness(mass, wheelbase, center_to_front, tire_stiffness_factor=1.0): @@ -31,9 +38,10 @@ def scale_tire_stiffness(mass, wheelbase, center_to_front, tire_stiffness_factor (center_to_front / wheelbase) / (CivicParams.CENTER_TO_FRONT / CivicParams.WHEELBASE) return tire_stiffness_front, tire_stiffness_rear - -def dbc_dict(pt_dbc, radar_dbc, chassis_dbc=None): - return {'pt': pt_dbc, 'radar': radar_dbc, 'chassis': chassis_dbc} + + +def dbc_dict(pt_dbc, radar_dbc, chassis_dbc=None, body_dbc=None): + return {'pt': pt_dbc, 'radar': radar_dbc, 'chassis': chassis_dbc, 'body': body_dbc} def apply_std_steer_torque_limits(apply_torque, apply_torque_last, driver_torque, LIMITS): @@ -48,16 +56,15 @@ def apply_std_steer_torque_limits(apply_torque, apply_torque_last, driver_torque # slow rate if steer torque increases in magnitude if apply_torque_last > 0: apply_torque = clip(apply_torque, max(apply_torque_last - LIMITS.STEER_DELTA_DOWN, -LIMITS.STEER_DELTA_UP), - apply_torque_last + LIMITS.STEER_DELTA_UP) + apply_torque_last + LIMITS.STEER_DELTA_UP) else: apply_torque = clip(apply_torque, apply_torque_last - LIMITS.STEER_DELTA_UP, - min(apply_torque_last + LIMITS.STEER_DELTA_DOWN, LIMITS.STEER_DELTA_UP)) + min(apply_torque_last + LIMITS.STEER_DELTA_DOWN, LIMITS.STEER_DELTA_UP)) - return int(round(apply_torque)) + return int(round(float(apply_torque))) def apply_toyota_steer_torque_limits(apply_torque, apply_torque_last, motor_torque, LIMITS): - # limits due to comparison of commanded torque VS motor reported torque max_lim = min(max(motor_torque + LIMITS.STEER_ERROR_MAX, LIMITS.STEER_ERROR_MAX), LIMITS.STEER_MAX) min_lim = max(min(motor_torque - LIMITS.STEER_ERROR_MAX, -LIMITS.STEER_ERROR_MAX), -LIMITS.STEER_MAX) @@ -74,16 +81,16 @@ def apply_toyota_steer_torque_limits(apply_torque, apply_torque_last, motor_torq apply_torque_last - LIMITS.STEER_DELTA_UP, min(apply_torque_last + LIMITS.STEER_DELTA_DOWN, LIMITS.STEER_DELTA_UP)) - return int(round(apply_torque)) + return int(round(float(apply_torque))) def crc8_pedal(data): crc = 0xFF # standard init value poly = 0xD5 # standard crc8: x8+x7+x6+x4+x2+1 size = len(data) - for i in range(size-1, -1, -1): + for i in range(size - 1, -1, -1): crc ^= data[i] - for j in range(8): + for _ in range(8): if ((crc & 0x80) != 0): crc = ((crc << 1) ^ poly) & 0xFF else: @@ -106,8 +113,23 @@ def create_gas_command(packer, gas_amount, idx): dat = packer.make_can_msg("GAS_COMMAND", 0, values)[2] - dat = [ord(i) for i in dat] checksum = crc8_pedal(dat[:-1]) values["CHECKSUM_PEDAL"] = checksum return packer.make_can_msg("GAS_COMMAND", 0, values) + + +def is_ecu_disconnected(fingerprint, fingerprint_list, ecu_fingerprint, car, ecu): + # check if a stock ecu is disconnected by looking for specific CAN msgs in the fingerprint + # return True if the reference car fingerprint contains the ecu fingerprint msg and + # fingerprint does not contains messages normally sent by a given ecu + ecu_in_car = False + for car_finger in fingerprint_list[car]: + if any(msg in car_finger for msg in ecu_fingerprint[ecu]): + ecu_in_car = True + + return ecu_in_car and not any(msg in fingerprint for msg in ecu_fingerprint[ecu]) + + +def make_can_msg(addr, dat, bus): + return [addr, 0, dat, bus] diff --git a/selfdrive/car/car_helpers.py b/selfdrive/car/car_helpers.py index 8646cccae0b084..77423994f0db8f 100644 --- a/selfdrive/car/car_helpers.py +++ b/selfdrive/car/car_helpers.py @@ -1,21 +1,40 @@ import os -from cereal import car from common.params import Params -from common.vin import get_vin, VIN_UNKNOWN from common.basedir import BASEDIR -from common.fingerprints import eliminate_incompatible_cars, all_known_cars +from selfdrive.version import comma_remote, tested_branch +from selfdrive.car.fingerprints import eliminate_incompatible_cars, all_known_cars +from selfdrive.car.vin import get_vin, VIN_UNKNOWN +from selfdrive.car.fw_versions import get_fw_versions, match_fw_to_car +from selfdrive.hardware import EON from selfdrive.swaglog import cloudlog -import selfdrive.messaging as messaging +import cereal.messaging as messaging +from selfdrive.car import gen_empty_fingerprint from selfdrive.car.tesla.readconfig import CarSettings +from cereal import car +EventName = car.CarEvent.EventName + + +def get_startup_event(car_recognized, controller_available): + if comma_remote and tested_branch: + event = EventName.startup + else: + event = EventName.startupMaster -def get_startup_alert(car_recognized, controller_available): - alert = 'startup' if not car_recognized: - alert = 'startupNoCar' + event = EventName.startupNoCar elif car_recognized and not controller_available: - alert = 'startupNoControl' - return alert + event = EventName.startupNoControl + elif EON and "letv" not in open("/proc/cmdline").read(): + event = EventName.startupOneplus + return event + + +def get_one_can(logcan): + while True: + can = messaging.recv_one_retry(logcan) + if len(can.can) > 0: + return can def load_interfaces(brand_names): @@ -23,12 +42,19 @@ def load_interfaces(brand_names): for brand_name in brand_names: path = ('selfdrive.car.%s' % brand_name) CarInterface = __import__(path + '.interface', fromlist=['CarInterface']).CarInterface + + if os.path.exists(BASEDIR + '/' + path.replace('.', '/') + '/carstate.py'): + CarState = __import__(path + '.carstate', fromlist=['CarState']).CarState + else: + CarState = None + if os.path.exists(BASEDIR + '/' + path.replace('.', '/') + '/carcontroller.py'): CarController = __import__(path + '.carcontroller', fromlist=['CarController']).CarController else: CarController = None + for model_name in brand_names[brand_name]: - ret[model_name] = (CarInterface, CarController) + ret[model_name] = (CarInterface, CarController, CarState) return ret @@ -50,36 +76,47 @@ def _get_interface_names(): # imports from directory selfdrive/car// -interfaces = load_interfaces(_get_interface_names()) +interface_names = _get_interface_names() +interfaces = load_interfaces(interface_names) + def only_toyota_left(candidate_cars): return all(("TOYOTA" in c or "LEXUS" in c) for c in candidate_cars) and len(candidate_cars) > 0 -# BOUNTY: every added fingerprint in selfdrive/car/*/values.py is a $100 coupon code on shop.comma.ai + # **** for use live only **** -def fingerprint(logcan, sendcan, is_panda_black): - if os.getenv("SIMULATOR2") is not None: - return ("simulator2", None, "") - elif os.getenv("SIMULATOR") is not None: - return ("simulator", None, "") - - params = Params() - car_params = params.get("CarParams") - - if car_params is not None: - # use already stored VIN: a new VIN query cannot be done, since panda isn't in ELM327 mode - car_params = car.CarParams.from_bytes(car_params) - vin = VIN_UNKNOWN if car_params.carVin == "" else car_params.carVin - elif is_panda_black: +def fingerprint(logcan, sendcan): + fixed_fingerprint = os.environ.get('FINGERPRINT', "") + skip_fw_query = os.environ.get('SKIP_FW_QUERY', False) + + if not fixed_fingerprint and not skip_fw_query: # Vin query only reliably works thorugh OBDII - vin = get_vin(logcan, sendcan, 1) + bus = 1 + + cached_params = Params().get("CarParamsCache") + if cached_params is not None: + cached_params = car.CarParams.from_bytes(cached_params) + if cached_params.carName == "mock": + cached_params = None + + if cached_params is not None and len(cached_params.carFw) > 0 and cached_params.carVin is not VIN_UNKNOWN: + cloudlog.warning("Using cached CarParams") + vin = cached_params.carVin + car_fw = list(cached_params.carFw) + else: + cloudlog.warning("Getting VIN & FW versions") + _, vin = get_vin(logcan, sendcan, bus) + car_fw = get_fw_versions(logcan, sendcan, bus) + + fw_candidates = match_fw_to_car(car_fw) else: vin = VIN_UNKNOWN + fw_candidates, car_fw = set(), [] cloudlog.warning("VIN %s", vin) Params().put("CarVin", vin) - finger = {i: {} for i in range(0, 4)} # collect on all buses + finger = gen_empty_fingerprint() candidate_cars = {i: all_known_cars() for i in [0, 1]} # attempt fingerprint on both bus 0 and 1 frame = 0 frame_fingerprint = 10 # 0.1s @@ -87,7 +124,7 @@ def fingerprint(logcan, sendcan, is_panda_black): done = False while not done: - a = messaging.recv_one(logcan) + a = get_one_can(logcan) for can in a.can: # need to independently try to fingerprint both bus 0 and 1 to work @@ -95,10 +132,11 @@ def fingerprint(logcan, sendcan, is_panda_black): # and VIN query response. # Include bus 2 for toyotas to disambiguate cars using camera messages # (ideally should be done for all cars but we can't for Honda Bosch) + if can.src in range(0, 4): + finger[can.src][can.address] = len(can.dat) for b in candidate_cars: if (can.src == b or (only_toyota_left(candidate_cars[b]) and can.src == 2)) and \ can.address < 0x800 and can.address not in [0x7df, 0x7e0, 0x7e8]: - finger[can.src][can.address] = len(can.dat) candidate_cars[b] = eliminate_incompatible_cars(can, candidate_cars[b]) # if we only have one car choice and the time since we got our first @@ -107,44 +145,60 @@ def fingerprint(logcan, sendcan, is_panda_black): # Toyota needs higher time to fingerprint, since DSU does not broadcast immediately if only_toyota_left(candidate_cars[b]): frame_fingerprint = 100 # 1s - if len(candidate_cars[b]) == 1: - if frame > frame_fingerprint: + if len(candidate_cars[b]) == 1 and frame > frame_fingerprint: # fingerprint done car_fingerprint = candidate_cars[b][0] if (car_fingerprint is None) and CarSettings().forceFingerprintTesla: - print "Fingerprinting Failed: Returning Tesla (based on branch)" + print ("Fingerprinting Failed: Returning Tesla (based on branch)") car_fingerprint = "TESLA MODEL S" vin = "TESLAFAKEVIN12345" # bail if no cars left or we've been waiting for more than 2s - failed = all(len(cc) == 0 for cc in candidate_cars.itervalues()) or frame > 200 + failed = all(len(cc) == 0 for cc in candidate_cars.values()) or frame > 200 succeeded = car_fingerprint is not None done = failed or succeeded frame += 1 + source = car.CarParams.FingerprintSource.can + + # If FW query returns exactly 1 candidate, use it + if len(fw_candidates) == 1: + car_fingerprint = list(fw_candidates)[0] + source = car.CarParams.FingerprintSource.fw + + if fixed_fingerprint: + car_fingerprint = fixed_fingerprint + source = car.CarParams.FingerprintSource.fixed + cloudlog.warning("fingerprinted %s", car_fingerprint) - return car_fingerprint, finger, vin + return car_fingerprint, finger, vin, car_fw, source -def get_car(logcan, sendcan, is_panda_black): +def get_car(logcan, sendcan): if CarSettings().forceFingerprintTesla: candidate="TESLA MODEL S" fingerprints=["","",""] vin="TESLAFORCED123456" + #BB + car_fw = [] + source=car.CarParams.FingerprintSource.fixed cloudlog.warning("VIN %s", vin) Params().put("CarVin", vin) else: - candidate, fingerprints, vin = fingerprint(logcan, sendcan, is_panda_black) + candidate, fingerprints, vin, car_fw, source = fingerprint(logcan, sendcan) if candidate is None: cloudlog.warning("car doesn't match any fingerprints: %r", fingerprints) candidate = "mock" - CarInterface, CarController = interfaces[candidate] - car_params = CarInterface.get_params(candidate, fingerprints[0], vin, is_panda_black) + CarInterface, CarController, CarState = interfaces[candidate] + car_params = CarInterface.get_params(candidate, fingerprints, car_fw) + car_params.carVin = vin + car_params.carFw = car_fw + car_params.fingerprintSource = source - return CarInterface(car_params, CarController), car_params + return CarInterface(car_params, CarController, CarState), car_params diff --git a/selfdrive/car/chrysler/carcontroller.py b/selfdrive/car/chrysler/carcontroller.py index dac43ca95d7c9f..b81526e9c002f8 100644 --- a/selfdrive/car/chrysler/carcontroller.py +++ b/selfdrive/car/chrysler/carcontroller.py @@ -1,37 +1,22 @@ from selfdrive.car import apply_toyota_steer_torque_limits from selfdrive.car.chrysler.chryslercan import create_lkas_hud, create_lkas_command, \ create_wheel_buttons -from selfdrive.car.chrysler.values import ECU, CAR -from selfdrive.can.packer import CANPacker +from selfdrive.car.chrysler.values import CAR, SteerLimitParams +from opendbc.can.packer import CANPacker -class SteerLimitParams: - STEER_MAX = 261 # 262 faults - STEER_DELTA_UP = 3 # 3 is stock. 100 is fine. 200 is too much it seems - STEER_DELTA_DOWN = 3 # no faults on the way down it seems - STEER_ERROR_MAX = 80 - - -class CarController(object): - def __init__(self, dbc_name, car_fingerprint, enable_camera): - self.braking = False - # redundant safety check with the board - self.controls_allowed = True +class CarController(): + def __init__(self, dbc_name, CP, VM): self.apply_steer_last = 0 self.ccframe = 0 self.prev_frame = -1 self.hud_count = 0 - self.car_fingerprint = car_fingerprint - self.alert_active = False + self.car_fingerprint = CP.carFingerprint self.gone_fast_yet = False - - self.fake_ecus = set() - if enable_camera: - self.fake_ecus.add(ECU.CAM) + self.steer_rate_limited = False self.packer = CANPacker(dbc_name) - - def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, hud_alert): + def update(self, enabled, CS, actuators, pcm_cancel_cmd, hud_alert): # this seems needed to avoid steering faults and to force the sync with the EPS counter frame = CS.lkas_counter if self.prev_frame == frame: @@ -39,15 +24,16 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, hud_alert): # *** compute control surfaces *** # steer torque - apply_steer = actuators.steer * SteerLimitParams.STEER_MAX - apply_steer = apply_toyota_steer_torque_limits(apply_steer, self.apply_steer_last, - CS.steer_torque_motor, SteerLimitParams) + new_steer = actuators.steer * SteerLimitParams.STEER_MAX + apply_steer = apply_toyota_steer_torque_limits(new_steer, self.apply_steer_last, + CS.out.steeringTorqueEps, SteerLimitParams) + self.steer_rate_limited = new_steer != apply_steer - moving_fast = CS.v_ego > CS.CP.minSteerSpeed # for status message - if CS.v_ego > (CS.CP.minSteerSpeed - 0.5): # for command high bit + moving_fast = CS.out.vEgo > CS.CP.minSteerSpeed # for status message + if CS.out.vEgo > (CS.CP.minSteerSpeed - 0.5): # for command high bit self.gone_fast_yet = True elif self.car_fingerprint in (CAR.PACIFICA_2019_HYBRID, CAR.JEEP_CHEROKEE_2019): - if CS.v_ego < (CS.CP.minSteerSpeed - 3.0): + if CS.out.vEgo < (CS.CP.minSteerSpeed - 3.0): self.gone_fast_yet = False # < 14.5m/s stock turns off this bit, but fine down to 13.5 lkas_active = moving_fast and enabled @@ -62,7 +48,7 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, hud_alert): if pcm_cancel_cmd: # TODO: would be better to start from frame_2b3 - new_msg = create_wheel_buttons(self.ccframe) + new_msg = create_wheel_buttons(self.packer, self.ccframe, cancel=True) can_sends.append(new_msg) # LKAS_HEARTBIT is forwarded by Panda so no need to send it here. @@ -70,7 +56,7 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, hud_alert): if (self.ccframe % 25 == 0): # 0.25s period if (CS.lkas_car_model != -1): new_msg = create_lkas_hud( - self.packer, CS.gear_shifter, lkas_active, hud_alert, + self.packer, CS.out.gearShifter, lkas_active, hud_alert, self.hud_count, CS.lkas_car_model) can_sends.append(new_msg) self.hud_count += 1 diff --git a/selfdrive/car/chrysler/carstate.py b/selfdrive/car/chrysler/carstate.py index 6368847c8f9fd4..b6fdb11314c294 100644 --- a/selfdrive/car/chrysler/carstate.py +++ b/selfdrive/car/chrysler/carstate.py @@ -1,157 +1,131 @@ -from selfdrive.can.parser import CANParser +from cereal import car +from opendbc.can.parser import CANParser +from opendbc.can.can_define import CANDefine +from selfdrive.config import Conversions as CV +from selfdrive.car.interfaces import CarStateBase from selfdrive.car.chrysler.values import DBC, STEER_THRESHOLD -from common.kalman.simple_kalman import KF1D - - -def parse_gear_shifter(can_gear): - if can_gear == 0x1: - return "park" - elif can_gear == 0x2: - return "reverse" - elif can_gear == 0x3: - return "neutral" - elif can_gear == 0x4: - return "drive" - elif can_gear == 0x5: - return "low" - return "unknown" - - -def get_can_parser(CP): - - signals = [ - # sig_name, sig_address, default - ("PRNDL", "GEAR", 0), - ("DOOR_OPEN_FL", "DOORS", 0), - ("DOOR_OPEN_FR", "DOORS", 0), - ("DOOR_OPEN_RL", "DOORS", 0), - ("DOOR_OPEN_RR", "DOORS", 0), - ("BRAKE_PRESSED_2", "BRAKE_2", 0), - ("ACCEL_134", "ACCEL_GAS_134", 0), - ("SPEED_LEFT", "SPEED_1", 0), - ("SPEED_RIGHT", "SPEED_1", 0), - ("WHEEL_SPEED_FL", "WHEEL_SPEEDS", 0), - ("WHEEL_SPEED_RR", "WHEEL_SPEEDS", 0), - ("WHEEL_SPEED_RL", "WHEEL_SPEEDS", 0), - ("WHEEL_SPEED_FR", "WHEEL_SPEEDS", 0), - ("STEER_ANGLE", "STEERING", 0), - ("STEERING_RATE", "STEERING", 0), - ("TURN_SIGNALS", "STEERING_LEVERS", 0), - ("ACC_STATUS_2", "ACC_2", 0), - ("HIGH_BEAM_FLASH", "STEERING_LEVERS", 0), - ("ACC_SPEED_CONFIG_KPH", "DASHBOARD", 0), - ("TORQUE_DRIVER", "EPS_STATUS", 0), - ("TORQUE_MOTOR", "EPS_STATUS", 0), - ("LKAS_STATE", "EPS_STATUS", 1), - ("COUNTER", "EPS_STATUS", -1), - ("TRACTION_OFF", "TRACTION_BUTTON", 0), - ("SEATBELT_DRIVER_UNLATCHED", "SEATBELT_STATUS", 0), - ("COUNTER", "WHEEL_BUTTONS", -1), # incrementing counter for 23b - ] - - # It's considered invalid if it is not received for 10x the expected period (1/f). - checks = [ - # sig_address, frequency - ("BRAKE_2", 50), - ("EPS_STATUS", 100), - ("SPEED_1", 100), - ("WHEEL_SPEEDS", 50), - ("STEERING", 100), - ("ACC_2", 50), - ] - - return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0) - -def get_camera_parser(CP): - signals = [ - # sig_name, sig_address, default - # TODO read in all the other values - ("COUNTER", "LKAS_COMMAND", -1), - ("CAR_MODEL", "LKAS_HUD", -1), - ("LKAS_STATUS_OK", "LKAS_HEARTBIT", -1) - ] - checks = [] - - return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2) - - -class CarState(object): - def __init__(self, CP): - - self.CP = CP - self.left_blinker_on = 0 - self.right_blinker_on = 0 - - # initialize can parser - self.car_fingerprint = CP.carFingerprint - # vEgo kalman filter - dt = 0.01 - # Q = np.matrix([[10.0, 0.0], [0.0, 100.0]]) - # R = 1e3 - self.v_ego_kf = KF1D(x0=[[0.0], [0.0]], - A=[[1.0, dt], [0.0, 1.0]], - C=[1.0, 0.0], - K=[[0.12287673], [0.29666309]]) - self.v_ego = 0.0 +class CarState(CarStateBase): + def __init__(self, CP): + super().__init__(CP) + can_define = CANDefine(DBC[CP.carFingerprint]['pt']) + self.shifter_values = can_define.dv["GEAR"]['PRNDL'] def update(self, cp, cp_cam): - # update prevs, update must run once per loop - self.prev_left_blinker_on = self.left_blinker_on - self.prev_right_blinker_on = self.right_blinker_on + ret = car.CarState.new_message() - self.frame_23b = int(cp.vl["WHEEL_BUTTONS"]['COUNTER']) self.frame = int(cp.vl["EPS_STATUS"]['COUNTER']) - self.door_all_closed = not any([cp.vl["DOORS"]['DOOR_OPEN_FL'], - cp.vl["DOORS"]['DOOR_OPEN_FR'], - cp.vl["DOORS"]['DOOR_OPEN_RL'], - cp.vl["DOORS"]['DOOR_OPEN_RR']]) - self.seatbelt = (cp.vl["SEATBELT_STATUS"]['SEATBELT_DRIVER_UNLATCHED'] == 0) - - self.brake_pressed = cp.vl["BRAKE_2"]['BRAKE_PRESSED_2'] == 5 # human-only - self.pedal_gas = cp.vl["ACCEL_GAS_134"]['ACCEL_134'] - self.car_gas = self.pedal_gas - self.esp_disabled = (cp.vl["TRACTION_BUTTON"]['TRACTION_OFF'] == 1) - - self.v_wheel_fl = cp.vl['WHEEL_SPEEDS']['WHEEL_SPEED_FL'] - self.v_wheel_rr = cp.vl['WHEEL_SPEEDS']['WHEEL_SPEED_RR'] - self.v_wheel_rl = cp.vl['WHEEL_SPEEDS']['WHEEL_SPEED_RL'] - self.v_wheel_fr = cp.vl['WHEEL_SPEEDS']['WHEEL_SPEED_FR'] - v_wheel = (cp.vl['SPEED_1']['SPEED_LEFT'] + cp.vl['SPEED_1']['SPEED_RIGHT']) / 2. - - # Kalman filter - if abs(v_wheel - self.v_ego) > 2.0: # Prevent large accelerations when car starts at non zero speed - self.v_ego_kf.x = [[v_wheel], [0.0]] - - self.v_ego_raw = v_wheel - v_ego_x = self.v_ego_kf.update(v_wheel) - self.v_ego = float(v_ego_x[0]) - self.a_ego = float(v_ego_x[1]) - self.standstill = not v_wheel > 0.001 - - self.angle_steers = cp.vl["STEERING"]['STEER_ANGLE'] - self.angle_steers_rate = cp.vl["STEERING"]['STEERING_RATE'] - self.gear_shifter = parse_gear_shifter(cp.vl['GEAR']['PRNDL']) - self.main_on = cp.vl["ACC_2"]['ACC_STATUS_2'] == 7 # ACC is green. - self.left_blinker_on = cp.vl["STEERING_LEVERS"]['TURN_SIGNALS'] == 1 - self.right_blinker_on = cp.vl["STEERING_LEVERS"]['TURN_SIGNALS'] == 2 - - self.steer_torque_driver = cp.vl["EPS_STATUS"]["TORQUE_DRIVER"] - self.steer_torque_motor = cp.vl["EPS_STATUS"]["TORQUE_MOTOR"] - self.steer_override = abs(self.steer_torque_driver) > STEER_THRESHOLD + ret.doorOpen = any([cp.vl["DOORS"]['DOOR_OPEN_FL'], + cp.vl["DOORS"]['DOOR_OPEN_FR'], + cp.vl["DOORS"]['DOOR_OPEN_RL'], + cp.vl["DOORS"]['DOOR_OPEN_RR']]) + ret.seatbeltUnlatched = cp.vl["SEATBELT_STATUS"]['SEATBELT_DRIVER_UNLATCHED'] == 1 + + ret.brakePressed = cp.vl["BRAKE_2"]['BRAKE_PRESSED_2'] == 5 # human-only + ret.brake = 0 + ret.brakeLights = ret.brakePressed + ret.gas = cp.vl["ACCEL_GAS_134"]['ACCEL_134'] + ret.gasPressed = ret.gas > 1e-5 + + ret.espDisabled = (cp.vl["TRACTION_BUTTON"]['TRACTION_OFF'] == 1) + + ret.wheelSpeeds.fl = cp.vl['WHEEL_SPEEDS']['WHEEL_SPEED_FL'] + ret.wheelSpeeds.rr = cp.vl['WHEEL_SPEEDS']['WHEEL_SPEED_RR'] + ret.wheelSpeeds.rl = cp.vl['WHEEL_SPEEDS']['WHEEL_SPEED_RL'] + ret.wheelSpeeds.fr = cp.vl['WHEEL_SPEEDS']['WHEEL_SPEED_FR'] + ret.vEgoRaw = (cp.vl['SPEED_1']['SPEED_LEFT'] + cp.vl['SPEED_1']['SPEED_RIGHT']) / 2. + ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) + ret.standstill = not ret.vEgoRaw > 0.001 + + ret.leftBlinker = cp.vl["STEERING_LEVERS"]['TURN_SIGNALS'] == 1 + ret.rightBlinker = cp.vl["STEERING_LEVERS"]['TURN_SIGNALS'] == 2 + ret.steeringAngle = cp.vl["STEERING"]['STEER_ANGLE'] + ret.steeringRate = cp.vl["STEERING"]['STEERING_RATE'] + ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(cp.vl['GEAR']['PRNDL'], None)) + + ret.cruiseState.enabled = cp.vl["ACC_2"]['ACC_STATUS_2'] == 7 # ACC is green. + ret.cruiseState.available = ret.cruiseState.enabled # FIXME: for now same as enabled + ret.cruiseState.speed = cp.vl["DASHBOARD"]['ACC_SPEED_CONFIG_KPH'] * CV.KPH_TO_MS + + ret.steeringTorque = cp.vl["EPS_STATUS"]["TORQUE_DRIVER"] + ret.steeringTorqueEps = cp.vl["EPS_STATUS"]["TORQUE_MOTOR"] + ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD steer_state = cp.vl["EPS_STATUS"]["LKAS_STATE"] - self.steer_error = steer_state == 4 or (steer_state == 0 and self.v_ego > self.CP.minSteerSpeed) - - self.user_brake = 0 - self.brake_lights = self.brake_pressed - self.v_cruise_pcm = cp.vl["DASHBOARD"]['ACC_SPEED_CONFIG_KPH'] - self.pcm_acc_status = self.main_on + ret.steerError = steer_state == 4 or (steer_state == 0 and ret.vEgo > self.CP.minSteerSpeed) - self.generic_toggle = bool(cp.vl["STEERING_LEVERS"]['HIGH_BEAM_FLASH']) + ret.genericToggle = bool(cp.vl["STEERING_LEVERS"]['HIGH_BEAM_FLASH']) self.lkas_counter = cp_cam.vl["LKAS_COMMAND"]['COUNTER'] self.lkas_car_model = cp_cam.vl["LKAS_HUD"]['CAR_MODEL'] self.lkas_status_ok = cp_cam.vl["LKAS_HEARTBIT"]['LKAS_STATUS_OK'] + + return ret + + @staticmethod + def get_can_parser(CP): + signals = [ + # sig_name, sig_address, default + ("PRNDL", "GEAR", 0), + ("DOOR_OPEN_FL", "DOORS", 0), + ("DOOR_OPEN_FR", "DOORS", 0), + ("DOOR_OPEN_RL", "DOORS", 0), + ("DOOR_OPEN_RR", "DOORS", 0), + ("BRAKE_PRESSED_2", "BRAKE_2", 0), + ("ACCEL_134", "ACCEL_GAS_134", 0), + ("SPEED_LEFT", "SPEED_1", 0), + ("SPEED_RIGHT", "SPEED_1", 0), + ("WHEEL_SPEED_FL", "WHEEL_SPEEDS", 0), + ("WHEEL_SPEED_RR", "WHEEL_SPEEDS", 0), + ("WHEEL_SPEED_RL", "WHEEL_SPEEDS", 0), + ("WHEEL_SPEED_FR", "WHEEL_SPEEDS", 0), + ("STEER_ANGLE", "STEERING", 0), + ("STEERING_RATE", "STEERING", 0), + ("TURN_SIGNALS", "STEERING_LEVERS", 0), + ("ACC_STATUS_2", "ACC_2", 0), + ("HIGH_BEAM_FLASH", "STEERING_LEVERS", 0), + ("ACC_SPEED_CONFIG_KPH", "DASHBOARD", 0), + ("TORQUE_DRIVER", "EPS_STATUS", 0), + ("TORQUE_MOTOR", "EPS_STATUS", 0), + ("LKAS_STATE", "EPS_STATUS", 1), + ("COUNTER", "EPS_STATUS", -1), + ("TRACTION_OFF", "TRACTION_BUTTON", 0), + ("SEATBELT_DRIVER_UNLATCHED", "SEATBELT_STATUS", 0), + ] + + checks = [ + # sig_address, frequency + ("BRAKE_2", 50), + ("EPS_STATUS", 100), + ("SPEED_1", 100), + ("WHEEL_SPEEDS", 50), + ("STEERING", 100), + ("ACC_2", 50), + ("GEAR", 50), + ("ACCEL_GAS_134", 50), + ("DASHBOARD", 15), + ("STEERING_LEVERS", 10), + ("SEATBELT_STATUS", 2), + ("DOORS", 1), + ("TRACTION_BUTTON", 1), + ] + + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0) + + @staticmethod + def get_cam_can_parser(CP): + signals = [ + # sig_name, sig_address, default + ("COUNTER", "LKAS_COMMAND", -1), + ("CAR_MODEL", "LKAS_HUD", -1), + ("LKAS_STATUS_OK", "LKAS_HEARTBIT", -1) + ] + checks = [ + ("LKAS_COMMAND", 100), + ("LKAS_HEARTBIT", 10), + ("LKAS_HUD", 4), + ] + + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2) diff --git a/selfdrive/car/chrysler/chryslercan.py b/selfdrive/car/chrysler/chryslercan.py index d710262e9169ea..63d1fbe0b45e87 100644 --- a/selfdrive/car/chrysler/chryslercan.py +++ b/selfdrive/car/chrysler/chryslercan.py @@ -1,65 +1,26 @@ from cereal import car +from selfdrive.car import make_can_msg +GearShifter = car.CarState.GearShifter VisualAlert = car.CarControl.HUDControl.VisualAlert -def calc_checksum(data): - """This function does not want the checksum byte in the input data. - - jeep chrysler canbus checksum from http://illmatics.com/Remote%20Car%20Hacking.pdf - """ - end_index = len(data) - index = 0 - checksum = 0xFF - temp_chk = 0 - bit_sum = 0 - if(end_index <= index): - return False - for index in range(0, end_index): - shift = 0x80 - curr = data[index] - iterate = 8 - while(iterate > 0): - iterate -= 1 - bit_sum = curr & shift - temp_chk = checksum & 0x80 - if (bit_sum != 0): - bit_sum = 0x1C - if (temp_chk != 0): - bit_sum = 1 - checksum = checksum << 1 - temp_chk = checksum | 1 - bit_sum ^= temp_chk - else: - if (temp_chk != 0): - bit_sum = 0x1D - checksum = checksum << 1 - bit_sum ^= checksum - checksum = bit_sum - shift = shift >> 1 - return ~checksum & 0xFF - - -def make_can_msg(addr, dat): - return [addr, 0, dat, 0] - - def create_lkas_hud(packer, gear, lkas_active, hud_alert, hud_count, lkas_car_model): # LKAS_HUD 0x2a6 (678) Controls what lane-keeping icon is displayed. if hud_alert == VisualAlert.steerRequired: - msg = '0000000300000000'.decode('hex') - return make_can_msg(0x2a6, msg) + msg = b'\x00\x00\x00\x03\x00\x00\x00\x00' + return make_can_msg(0x2a6, msg, 0) color = 1 # default values are for park or neutral in 2017 are 0 0, but trying 1 1 for 2019 lines = 1 alerts = 0 - if hud_count < (1 *4): # first 3 seconds, 4Hz + if hud_count < (1 * 4): # first 3 seconds, 4Hz alerts = 1 # CAR.PACIFICA_2018_HYBRID and CAR.PACIFICA_2019_HYBRID # had color = 1 and lines = 1 but trying 2017 hybrid style for now. - if gear in ('drive', 'reverse', 'low'): + if gear in (GearShifter.drive, GearShifter.reverse, GearShifter.low): if lkas_active: color = 2 # control active, display green. lines = 6 @@ -84,19 +45,13 @@ def create_lkas_command(packer, apply_steer, moving_fast, frame): "LKAS_HIGH_TORQUE": int(moving_fast), "COUNTER": frame % 0x10, } - - dat = packer.make_can_msg("LKAS_COMMAND", 0, values)[2] - dat = [ord(i) for i in dat][:-1] - checksum = calc_checksum(dat) - - values["CHECKSUM"] = checksum return packer.make_can_msg("LKAS_COMMAND", 0, values) -def create_wheel_buttons(frame): +def create_wheel_buttons(packer, frame, cancel=False): # WHEEL_BUTTONS (571) Message sent to cancel ACC. - start = [0x01] # acc cancel set - counter = (frame % 10) << 4 - dat = start + [counter] - dat = dat + [calc_checksum(dat)] - return make_can_msg(0x23b, str(bytearray(dat))) + values = { + "ACC_CANCEL": cancel, + "COUNTER": frame % 10 + } + return packer.make_can_msg("WHEEL_BUTTONS", 0, values) diff --git a/selfdrive/car/chrysler/chryslercan_test.py b/selfdrive/car/chrysler/chryslercan_test.py deleted file mode 100644 index 54b845342fcb15..00000000000000 --- a/selfdrive/car/chrysler/chryslercan_test.py +++ /dev/null @@ -1,59 +0,0 @@ -from selfdrive.car.chrysler import chryslercan -from selfdrive.can.packer import CANPacker - -from cereal import car -VisualAlert = car.CarControl.HUDControl.VisualAlert - -import unittest - - -class TestChryslerCan(unittest.TestCase): - - def test_checksum(self): - self.assertEqual(0x75, chryslercan.calc_checksum([0x01, 0x20])) - self.assertEqual(0xcc, chryslercan.calc_checksum([0x14, 0, 0, 0, 0x20])) - - def test_hud(self): - packer = CANPacker('chrysler_pacifica_2017_hybrid') - self.assertEqual( - [0x2a6, 0, '0100010100000000'.decode('hex'), 0], - chryslercan.create_lkas_hud( - packer, - 'park', False, False, 1, 0)) - self.assertEqual( - [0x2a6, 0, '0100010000000000'.decode('hex'), 0], - chryslercan.create_lkas_hud( - packer, - 'park', False, False, 5*4, 0)) - self.assertEqual( - [0x2a6, 0, '0100010000000000'.decode('hex'), 0], - chryslercan.create_lkas_hud( - packer, - 'park', False, False, 99999, 0)) - self.assertEqual( - [0x2a6, 0, '0200060000000000'.decode('hex'), 0], - chryslercan.create_lkas_hud( - packer, - 'drive', True, False, 99999, 0)) - self.assertEqual( - [0x2a6, 0, '0264060000000000'.decode('hex'), 0], - chryslercan.create_lkas_hud( - packer, - 'drive', True, False, 99999, 0x64)) - - def test_command(self): - packer = CANPacker('chrysler_pacifica_2017_hybrid') - self.assertEqual( - [0x292, 0, '140000001086'.decode('hex'), 0], - chryslercan.create_lkas_command( - packer, - 0, True, 1)) - self.assertEqual( - [0x292, 0, '040000008083'.decode('hex'), 0], - chryslercan.create_lkas_command( - packer, - 0, False, 8)) - - -if __name__ == '__main__': - unittest.main() diff --git a/selfdrive/car/chrysler/interface.py b/selfdrive/car/chrysler/interface.py index c43c6c08abbf09..e433665d992f9a 100755 --- a/selfdrive/car/chrysler/interface.py +++ b/selfdrive/car/chrysler/interface.py @@ -1,66 +1,37 @@ -#!/usr/bin/env python -from common.realtime import sec_since_boot +#!/usr/bin/env python3 from cereal import car -from selfdrive.config import Conversions as CV -from selfdrive.controls.lib.drive_helpers import EventTypes as ET, create_event -from selfdrive.controls.lib.vehicle_model import VehicleModel -from selfdrive.car.chrysler.carstate import CarState, get_can_parser, get_camera_parser -from selfdrive.car.chrysler.values import ECU, check_ecu_msgs, CAR -from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness - - -class CarInterface(object): - def __init__(self, CP, CarController): - self.CP = CP - self.VM = VehicleModel(CP) - - self.frame = 0 - self.gas_pressed_prev = False - self.brake_pressed_prev = False - self.cruise_enabled_prev = False - self.low_speed_alert = False - - # *** init the major players *** - self.CS = CarState(CP) - self.cp = get_can_parser(CP) - self.cp_cam = get_camera_parser(CP) - - self.CC = None - if CarController is not None: - self.CC = CarController(self.cp.dbc_name, CP.carFingerprint, CP.enableCamera) +from selfdrive.car.chrysler.values import CAR +from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint +from selfdrive.car.interfaces import CarInterfaceBase + +class CarInterface(CarInterfaceBase): @staticmethod def compute_gb(accel, speed): return float(accel) / 3.0 @staticmethod - def calc_accel_override(a_ego, a_target, v_ego, v_target): - return 1.0 - - @staticmethod - def get_params(candidate, fingerprint, vin="", is_panda_black=False): - - ret = car.CarParams.new_message() + def get_params(candidate, fingerprint=None, car_fw=None): + if fingerprint is None: + fingerprint = gen_empty_fingerprint() + ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "chrysler" - ret.carFingerprint = candidate - ret.carVin = vin - ret.isPandaBlack = is_panda_black - ret.safetyModel = car.CarParams.SafetyModel.chrysler - # pedal - ret.enableCruise = True + # Chrysler port is a community feature, since we don't own one to test + ret.communityFeature = True # Speed conversion: 20, 45 mph ret.wheelbase = 3.089 # in meters for Pacifica Hybrid 2017 - ret.steerRatio = 16.2 # Pacifica Hybrid 2017 + ret.steerRatio = 16.2 # Pacifica Hybrid 2017 ret.mass = 2858. + STD_CARGO_KG # kg curb weight Pacifica Hybrid 2017 ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kiBP = [[9., 20.], [9., 20.]] - ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.15,0.30], [0.03,0.05]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.15, 0.30], [0.03, 0.05]] ret.lateralTuning.pid.kf = 0.00006 # full torque for 10 deg at 80mph means 0.00007818594 ret.steerActuatorDelay = 0.1 ret.steerRateCost = 0.7 + ret.steerLimitTimer = 0.4 if candidate in (CAR.JEEP_CHEROKEE, CAR.JEEP_CHEROKEE_2019): ret.wheelbase = 2.91 # in meters @@ -69,175 +40,56 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): ret.centerToFront = ret.wheelbase * 0.44 - ret.minSteerSpeed = 3.8 # m/s - ret.minEnableSpeed = -1. # enable is done by stock ACC, so ignore this - if candidate in (CAR.PACIFICA_2019_HYBRID, CAR.JEEP_CHEROKEE_2019): - ret.minSteerSpeed = 17.5 # m/s 17 on the way up, 13 on the way down once engaged. + if candidate in (CAR.PACIFICA_2019_HYBRID, CAR.PACIFICA_2020, CAR.JEEP_CHEROKEE_2019): # TODO allow 2019 cars to steer down to 13 m/s if already engaged. + ret.minSteerSpeed = 17.5 # m/s 17 on the way up, 13 on the way down once engaged. - # TODO: get actual value, for now starting with reasonable value for - # civic and scaling by mass and wheelbase + # starting with reasonable value for civic and scaling by mass and wheelbase ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) # TODO: start from empirically derived lateral slip stiffness for the civic and scale by # mass and CG position, so all cars will have approximately similar dyn behaviors ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront) - # no rear steering, at least on the listed cars above - ret.steerRatioRear = 0. - - # steer, gas, brake limitations VS speed - ret.steerMaxBP = [16. * CV.KPH_TO_MS, 45. * CV.KPH_TO_MS] # breakpoints at 1 and 40 kph - ret.steerMaxV = [1., 1.] # 2/3rd torque allowed above 45 kph - ret.gasMaxBP = [0.] - ret.gasMaxV = [0.5] - ret.brakeMaxBP = [5., 20.] - ret.brakeMaxV = [1., 0.8] - - ret.enableCamera = not check_ecu_msgs(fingerprint, ECU.CAM) or is_panda_black - print("ECU Camera Simulated: {0}".format(ret.enableCamera)) - ret.openpilotLongitudinalControl = False - - ret.steerLimitAlert = True - ret.stoppingControl = False - ret.startAccel = 0.0 - - ret.longitudinalTuning.deadzoneBP = [0., 9.] - ret.longitudinalTuning.deadzoneV = [0., .15] - ret.longitudinalTuning.kpBP = [0., 5., 35.] - ret.longitudinalTuning.kpV = [3.6, 2.4, 1.5] - ret.longitudinalTuning.kiBP = [0., 35.] - ret.longitudinalTuning.kiV = [0.54, 0.36] + ret.enableCamera = True return ret # returns a car.CarState def update(self, c, can_strings): # ******************* do can recv ******************* - self.cp.update_strings(int(sec_since_boot() * 1e9), can_strings) - self.cp_cam.update_strings(int(sec_since_boot() * 1e9), can_strings) - - self.CS.update(self.cp, self.cp_cam) + self.cp.update_strings(can_strings) + self.cp_cam.update_strings(can_strings) - # create message - ret = car.CarState.new_message() + ret = self.CS.update(self.cp, self.cp_cam) ret.canValid = self.cp.can_valid and self.cp_cam.can_valid # speeds - ret.vEgo = self.CS.v_ego - ret.vEgoRaw = self.CS.v_ego_raw - ret.aEgo = self.CS.a_ego - ret.yawRate = self.VM.yaw_rate(self.CS.angle_steers * CV.DEG_TO_RAD, self.CS.v_ego) - ret.standstill = self.CS.standstill - ret.wheelSpeeds.fl = self.CS.v_wheel_fl - ret.wheelSpeeds.fr = self.CS.v_wheel_fr - ret.wheelSpeeds.rl = self.CS.v_wheel_rl - ret.wheelSpeeds.rr = self.CS.v_wheel_rr - - # gear shifter - ret.gearShifter = self.CS.gear_shifter - - # gas pedal - ret.gas = self.CS.car_gas - ret.gasPressed = self.CS.pedal_gas > 0 - - # brake pedal - ret.brake = self.CS.user_brake - ret.brakePressed = self.CS.brake_pressed - ret.brakeLights = self.CS.brake_lights - - # steering wheel - ret.steeringAngle = self.CS.angle_steers - ret.steeringRate = self.CS.angle_steers_rate - - ret.steeringTorque = self.CS.steer_torque_driver - ret.steeringPressed = self.CS.steer_override - - # cruise state - ret.cruiseState.enabled = self.CS.pcm_acc_status # same as main_on - ret.cruiseState.speed = self.CS.v_cruise_pcm * CV.KPH_TO_MS - ret.cruiseState.available = self.CS.main_on - ret.cruiseState.speedOffset = 0. - # ignore standstill in hybrid rav4, since pcm allows to restart without - # receiving any special command - ret.cruiseState.standstill = False - - # TODO: button presses - buttonEvents = [] - - if self.CS.left_blinker_on != self.CS.prev_left_blinker_on: - be = car.CarState.ButtonEvent.new_message() - be.type = 'leftBlinker' - be.pressed = self.CS.left_blinker_on != 0 - buttonEvents.append(be) - - if self.CS.right_blinker_on != self.CS.prev_right_blinker_on: - be = car.CarState.ButtonEvent.new_message() - be.type = 'rightBlinker' - be.pressed = self.CS.right_blinker_on != 0 - buttonEvents.append(be) - - ret.buttonEvents = buttonEvents - ret.leftBlinker = bool(self.CS.left_blinker_on) - ret.rightBlinker = bool(self.CS.right_blinker_on) - - ret.doorOpen = not self.CS.door_all_closed - ret.seatbeltUnlatched = not self.CS.seatbelt - self.low_speed_alert = (ret.vEgo < self.CP.minSteerSpeed) - - ret.genericToggle = self.CS.generic_toggle - #ret.lkasCounter = self.CS.lkas_counter - #ret.lkasCarModel = self.CS.lkas_car_model + ret.steeringRateLimited = self.CC.steer_rate_limited if self.CC is not None else False # events - events = [] - if not (ret.gearShifter in ('drive', 'low')): - events.append(create_event('wrongGear', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if ret.doorOpen: - events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if ret.seatbeltUnlatched: - events.append(create_event('seatbeltNotLatched', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if self.CS.esp_disabled: - events.append(create_event('espDisabled', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if not self.CS.main_on: - events.append(create_event('wrongCarMode', [ET.NO_ENTRY, ET.USER_DISABLE])) - if ret.gearShifter == 'reverse': - events.append(create_event('reverseGear', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) - if self.CS.steer_error: - events.append(create_event('steerUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT])) - - if ret.cruiseState.enabled and not self.cruise_enabled_prev: - events.append(create_event('pcmEnable', [ET.ENABLE])) - elif not ret.cruiseState.enabled: - events.append(create_event('pcmDisable', [ET.USER_DISABLE])) - - # disable on gas pedal and speed isn't zero. Gas pedal is used to resume ACC - # from a 3+ second stop. - if (ret.gasPressed and (not self.gas_pressed_prev) and ret.vEgo > 2.0): - events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) - - if self.low_speed_alert: - events.append(create_event('belowSteerSpeed', [ET.WARNING])) - - ret.events = events - - self.gas_pressed_prev = ret.gasPressed - self.brake_pressed_prev = ret.brakePressed - self.cruise_enabled_prev = ret.cruiseState.enabled - - return ret.as_reader() + events = self.create_common_events(ret, extra_gears=[car.CarState.GearShifter.low], + gas_resume_speed=2.) + + if ret.vEgo < self.CP.minSteerSpeed: + events.add(car.CarEvent.EventName.belowSteerSpeed) + + ret.events = events.to_msg() + + # copy back carState packet to CS + self.CS.out = ret.as_reader() + + return self.CS.out # pass in a car.CarControl # to be called @ 100hz def apply(self, c): if (self.CS.frame == -1): - return [] # if we haven't seen a frame 220, then do not update. + return [] # if we haven't seen a frame 220, then do not update. - self.frame = self.CS.frame - can_sends = self.CC.update(c.enabled, self.CS, self.frame, - c.actuators, c.cruiseControl.cancel, c.hudControl.visualAlert) + can_sends = self.CC.update(c.enabled, self.CS, c.actuators, c.cruiseControl.cancel, c.hudControl.visualAlert) return can_sends diff --git a/selfdrive/car/chrysler/radar_interface.py b/selfdrive/car/chrysler/radar_interface.py index 43f5c6105eccf5..3139efad34ab4d 100755 --- a/selfdrive/car/chrysler/radar_interface.py +++ b/selfdrive/car/chrysler/radar_interface.py @@ -1,16 +1,15 @@ -#!/usr/bin/env python -import os -from selfdrive.can.parser import CANParser +#!/usr/bin/env python3 +from opendbc.can.parser import CANParser from cereal import car -from common.realtime import sec_since_boot +from selfdrive.car.interfaces import RadarInterfaceBase +from selfdrive.car.chrysler.values import DBC -RADAR_MSGS_C = range(0x2c2, 0x2d4+2, 2) # c_ messages 706,...,724 -RADAR_MSGS_D = range(0x2a2, 0x2b4+2, 2) # d_ messages +RADAR_MSGS_C = list(range(0x2c2, 0x2d4+2, 2)) # c_ messages 706,...,724 +RADAR_MSGS_D = list(range(0x2a2, 0x2b4+2, 2)) # d_ messages LAST_MSG = max(RADAR_MSGS_C + RADAR_MSGS_D) NUMBER_MSGS = len(RADAR_MSGS_C) + len(RADAR_MSGS_D) -def _create_radar_can_parser(): - dbc_f = 'chrysler_pacifica_2017_hybrid_private_fusion.dbc' +def _create_radar_can_parser(car_fingerprint): msg_n = len(RADAR_MSGS_C) # list of [(signal name, message name or number, initial values), (...)] # [('RADAR_STATE', 1024, 0), @@ -37,7 +36,7 @@ def _create_radar_can_parser(): [20]*msg_n + # 20Hz (0.05s) [20]*msg_n)) # 20Hz (0.05s) - return CANParser(os.path.splitext(dbc_f)[0], signals, checks, 1) + return CANParser(DBC[car_fingerprint]['radar'], signals, checks, 1) def _address_to_track(address): if address in RADAR_MSGS_C: @@ -46,17 +45,15 @@ def _address_to_track(address): return (address - RADAR_MSGS_D[0]) // 2 raise ValueError("radar received unexpected address %d" % address) -class RadarInterface(object): +class RadarInterface(RadarInterfaceBase): def __init__(self, CP): - self.pts = {} - self.delay = 0.0 # Delay of radar #TUNE - self.rcp = _create_radar_can_parser() + super().__init__(CP) + self.rcp = _create_radar_can_parser(CP.carFingerprint) self.updated_messages = set() self.trigger_msg = LAST_MSG def update(self, can_strings): - tm = int(sec_since_boot() * 1e9) - vls = self.rcp.update_strings(tm, can_strings) + vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) if self.trigger_msg not in self.updated_messages: diff --git a/selfdrive/car/chrysler/run_tests.sh b/selfdrive/car/chrysler/run_tests.sh deleted file mode 100644 index 1dcc8b2acf0bbf..00000000000000 --- a/selfdrive/car/chrysler/run_tests.sh +++ /dev/null @@ -1 +0,0 @@ -PYTHONPATH=`realpath ../../../` python chryslercan_test.py diff --git a/selfdrive/car/chrysler/values.py b/selfdrive/car/chrysler/values.py index 2e74d70239dca6..88110f0530a91d 100644 --- a/selfdrive/car/chrysler/values.py +++ b/selfdrive/car/chrysler/values.py @@ -1,12 +1,24 @@ +# flake8: noqa + from selfdrive.car import dbc_dict +from cereal import car +Ecu = car.CarParams.Ecu + +class SteerLimitParams: + STEER_MAX = 261 # 262 faults + STEER_DELTA_UP = 3 # 3 is stock. 100 is fine. 200 is too much it seems + STEER_DELTA_DOWN = 3 # no faults on the way down it seems + STEER_ERROR_MAX = 80 + class CAR: PACIFICA_2017_HYBRID = "CHRYSLER PACIFICA HYBRID 2017" PACIFICA_2018_HYBRID = "CHRYSLER PACIFICA HYBRID 2018" PACIFICA_2019_HYBRID = "CHRYSLER PACIFICA HYBRID 2019" - PACIFICA_2018 = "CHRYSLER PACIFICA 2018" - JEEP_CHEROKEE = "JEEP GRAND CHEROKEE V6 2018" # Also covers Tailhawk 2017. - JEEP_CHEROKEE_2019 = "JEEP GRAND CHEROKEE 2019" + PACIFICA_2018 = "CHRYSLER PACIFICA 2018" # includes 2017 Pacifica + PACIFICA_2020 = "CHRYSLER PACIFICA 2020" + JEEP_CHEROKEE = "JEEP GRAND CHEROKEE V6 2018" # includes 2017 Trailhawk + JEEP_CHEROKEE_2019 = "JEEP GRAND CHEROKEE 2019" # includes 2020 Trailhawk # Unique can messages: # Only the hybrids have 270: 8 @@ -25,14 +37,20 @@ class CAR: ], CAR.PACIFICA_2018: [ {55: 8, 257: 5, 258: 8, 264: 8, 268: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 516: 7, 517: 7, 520: 8, 524: 8, 526: 6, 528: 8, 532: 8, 542: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 656: 4, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 746: 5, 752: 2, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 882: 8, 897: 8, 924: 8, 926: 3, 937: 8, 947: 8, 948: 8, 969: 4, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1098: 8, 1100: 8, 1537: 8, 1538: 8, 1562: 8}, + {55: 8, 257: 5, 258: 8, 264: 8, 268: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 516: 7, 517: 7, 520: 8, 524: 8, 526: 6, 528: 8, 532: 8, 542: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 4, 571: 3, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 656: 4, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 746: 5, 752: 2, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 882: 8, 897: 8, 924: 3, 926: 3, 937: 8, 947: 8, 948: 8, 969: 4, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1098: 8, 1100: 8, 1537: 8, 1538: 8, 1562: 8}, + ], + CAR.PACIFICA_2020: [ + { + 55: 8, 179: 8, 181: 8, 257: 5, 258: 8, 264: 8, 268: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 528: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 650: 8, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 676: 8, 678: 8, 680: 8, 683: 8, 703: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 746: 5, 752: 2, 754: 8, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 847: 1, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 882: 8, 897: 8, 906: 8, 924: 8, 926: 3, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 962: 8, 969: 4, 973: 8, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1098: 8, 1100: 8, 1216: 8, 1218: 8, 1220: 8, 1223: 7, 1225: 8, 1235: 8, 1242: 8, 1246: 8, 1250: 8, 1251: 8, 1252: 8, 1284: 8, 1568: 8, 1570: 8, 1856: 8, 1858: 8, 1860: 8, 1863: 8, 1865: 8, 1875: 8, 1882: 8, 1886: 8, 1890: 8, 1891: 8, 1892: 8, 2016: 8, 2024: 8 + } ], CAR.PACIFICA_2018_HYBRID: [ - {68: 8, 168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 528: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 660: 8, 669: 3, 671: 8, 672: 8, 680: 8, 701: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 736: 8, 737: 8, 746: 5, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 969: 4, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8}, + {68: 8, 168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 528: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 680: 8, 701: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 736: 8, 737: 8, 746: 5, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 969: 4, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8}, # based on 9ae7821dc4e92455|2019-07-01--16-42-55 {168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 515: 7, 516: 7, 517: 7, 518: 7, 520: 8, 528: 8, 532: 8, 542: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 701: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 746: 5, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 969: 4, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8, 1216: 8, 1218: 8, 1220: 8, 1225: 8, 1235: 8, 1242: 8, 1246: 8, 1250: 8, 1251: 8, 1252: 8, 1258: 8, 1259: 8, 1260: 8, 1262: 8, 1284: 8, 1537: 8, 1538: 8, 1562: 8, 1568: 8, 1856: 8, 1858: 8, 1860: 8, 1865: 8, 1875: 8, 1882: 8, 1886: 8, 1890: 8, 1891: 8, 1892: 8, 1898: 8, 1899: 8, 1900: 8, 1902: 8, 2016: 8, 2018: 8, 2019: 8, 2020: 8, 2023: 8, 2024: 8, 2026: 8, 2027: 8, 2028: 8, 2031: 8}, ], CAR.PACIFICA_2019_HYBRID: [ - {168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 515: 7, 516: 7, 517: 7, 518: 7, 520: 8, 528: 8, 532: 8, 542: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 660: 8, 669: 3, 671: 8, 672: 8, 680: 8, 701: 8, 703: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 736: 8, 737: 8, 746: 5, 752: 2, 754: 8, 760: 8, 764: 8, 766: 8, 770:8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 906: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 962: 8, 969: 4, 973: 8, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8, 1538: 8}, + {168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 515: 7, 516: 7, 517: 7, 518: 7, 520: 8, 528: 8, 532: 8, 542: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 680: 8, 701: 8, 703: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 736: 8, 737: 8, 746: 5, 752: 2, 754: 8, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 906: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 962: 8, 969: 4, 973: 8, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8, 1538: 8}, # Based on 0607d2516fc2148f|2019-02-13--23-03-16 { 168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 528: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 701: 8, 703: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 746: 5, 752: 2, 754: 8, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 906: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 962: 8, 969: 4, 973: 8, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8, 1537: 8 @@ -40,55 +58,36 @@ class CAR: # Based on 3c7ce223e3571b54|2019-05-11--20-16-14 { 168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 528: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 701: 8, 703: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 746: 5, 752: 2, 754: 8, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 906: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 962: 8, 969: 4, 973: 8, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8, 1562: 8, 1570: 8 + }, + { + 168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 515: 7, 516: 7, 517: 7, 518: 7, 520: 8, 524: 8, 526: 6, 528: 8, 532: 8, 542: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 650: 8, 653: 8, 654: 8, 655: 8, 656: 4, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 683: 8, 701: 8, 703: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 738: 8, 746: 5, 752: 2, 754: 8, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 906: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 962: 8, 969: 4, 973: 8, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8, 2015: 8, 2016: 8, 2024: 8 + }, + # Based on "8190c7275a24557b|2020-02-24--09-57-23" + { + 168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 528: 8, 532: 8, 542: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 650: 8, 656: 4, 653: 8, 654: 8, 655: 8, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 683: 8, 701: 8, 703: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 738: 8, 746: 5, 752: 2, 754: 8, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 906: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 962: 8, 969: 4, 973: 8, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8, 1216: 8, 1218: 8, 1220: 8, 1225: 8, 1235: 8, 1242: 8, 1246: 8, 1250: 8, 1251: 8, 1252: 8, 1258: 8, 1259: 8, 1260: 8, 1262: 8, 1284: 8, 1568: 8, 1570: 8, 1856: 8, 1858: 8, 1860: 8, 1865: 8, 1875: 8, 1882: 8, 1886: 8, 1890: 8, 1891: 8, 1892: 8, 1898: 8, 1899: 8, 1900: 8, 1902: 8, 2015: 8, 2016: 8, 2018: 8, 2019: 8, 2020: 8, 2023: 8, 2024: 8, 2026: 8, 2027: 8, 2028: 8, 2031: 8 } ], CAR.JEEP_CHEROKEE: [ # JEEP GRAND CHEROKEE V6 2018 {55: 8, 168: 8, 181: 8, 256: 4, 257: 5, 258: 8, 264: 8, 268: 8, 272: 6, 273: 6, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 352: 8, 362: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 4, 571: 3, 579: 8, 584: 8, 608: 8, 618: 8, 624: 8, 625: 8, 632: 8, 639: 8, 656: 4, 658: 6, 660: 8, 671: 8, 672: 8, 676: 8, 678: 8, 680: 8, 683: 8, 684: 8, 703: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 738: 8, 746: 5, 752: 2, 754: 8, 760: 8, 761: 8, 764: 8, 766: 8, 773: 8, 776: 8, 779: 8, 782: 8, 783: 8, 784: 8, 785: 8, 788: 3, 792: 8, 799: 8, 800: 8, 804: 8, 806: 2, 808: 8, 810: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 831: 6, 832: 8, 838: 2, 844: 5, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 882: 8, 897: 8, 906: 8, 924: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 956: 8, 968: 8, 969: 4, 970: 8, 973: 8, 974: 5, 976: 8, 977: 4, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1062: 8, 1098: 8, 1100: 8}, # Jeep Grand Cherokee 2017 Trailhawk - {257: 5, 258: 8, 264: 8, 268: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 352: 8, 362: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 4, 571: 3, 584: 8, 608: 8, 618: 8, 624: 8, 625: 8, 632: 8, 639: 8, 660: 8, 671: 8, 672: 8, 680: 8, 684: 8, 703: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 736: 8, 737: 8, 746: 5, 752: 2, 760: 8, 761: 8, 764: 8, 766: 8, 773: 8, 776: 8, 779: 8, 783: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 806: 2, 808: 8, 810: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 831: 6, 832: 8, 838: 2, 844: 5, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 882: 8, 897: 8, 924: 3, 937: 8, 947: 8, 948: 8, 969: 4, 974: 5, 977: 4, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1062: 8, 1098: 8, 1100: 8}, + {257: 5, 258: 8, 264: 8, 268: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 352: 8, 362: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 4, 571: 3, 584: 8, 608: 8, 618: 8, 624: 8, 625: 8, 632: 8, 639: 8, 658: 6, 660: 8, 671: 8, 672: 8, 680: 8, 684: 8, 703: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 736: 8, 737: 8, 746: 5, 752: 2, 760: 8, 761: 8, 764: 8, 766: 8, 773: 8, 776: 8, 779: 8, 783: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 806: 2, 808: 8, 810: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 831: 6, 832: 8, 838: 2, 844: 5, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 882: 8, 897: 8, 924: 3, 937: 8, 947: 8, 948: 8, 969: 4, 974: 5, 977: 4, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1062: 8, 1098: 8, 1100: 8}, ], CAR.JEEP_CHEROKEE_2019: [ - # Jeep Grand Cherokee 2019 from Switzerland - # 530: 8 is so far only in this Jeep. - {55: 8, 181: 8, 256: 4, 257: 5, 258: 8, 264: 8, 268: 8, 272: 6, 273: 6, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 352: 8, 362: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 530: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 618: 8, 624: 8, 625: 8, 632: 8, 639: 8, 660: 8, 671: 8, 672: 8, 676: 8, 680: 8, 683: 8, 684: 8, 703: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 736: 8, 737: 8, 738: 8, 746: 5, 752: 2, 754: 8, 760: 8, 761: 8, 764: 8, 773: 8, 776: 8, 779: 8, 782: 8, 783: 8, 784: 8, 792: 8, 799: 8, 804: 8, 806: 2, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 831: 6, 832: 8, 838: 2, 844: 5, 848: 8, 853: 8, 856: 4, 860: 6, 882: 8, 897: 8, 906: 8, 924: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 968: 8, 969: 4, 970: 8, 973: 8, 974: 5, 977: 4, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1062: 8, 1098: 8, 1100: 8}, + # Jeep Grand Cherokee 2019, including most 2020 models + {55: 8, 168: 8, 179: 8, 181: 8, 256: 4, 257: 5, 258: 8, 264: 8, 268: 8, 272: 6, 273: 6, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 341: 8, 344: 8, 352: 8, 362: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 530: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 618: 8, 624: 8, 625: 8, 632: 8, 639: 8, 640: 1, 656: 4, 658: 6, 660: 8, 671: 8, 672: 8, 676: 8, 678: 8, 680: 8, 683: 8, 684: 8, 703: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 738: 8, 746: 5, 752: 2, 754: 8, 760: 8, 761: 8, 764: 8, 766: 8, 773: 8, 776: 8, 779: 8, 782: 8, 783: 8, 784: 8, 785: 8, 792: 8, 799: 8, 800: 8, 804: 8, 806: 2, 808: 8, 810: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 831: 6, 832: 8, 838: 2, 840: 8, 844: 5, 847: 1, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 882: 8, 897: 8, 906: 8, 924: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 960: 4, 968: 8, 969: 4, 970: 8, 973: 8, 974: 5, 976: 8, 977: 4, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1062: 8, 1098: 8, 1100: 8, 1216: 8, 1218: 8, 1220: 8, 1223: 8, 1225: 8, 1227: 8, 1235: 8, 1242: 8, 1250: 8, 1251: 8, 1252: 8, 1254: 8, 1264: 8, 1284: 8, 1536: 8, 1537: 8, 1543: 8, 1545: 8, 1562: 8, 1568: 8, 1570: 8, 1572: 8, 1593: 8, 1856: 8, 1858: 8, 1860: 8, 1863: 8, 1865: 8, 1867: 8, 1875: 8, 1882: 8, 1890: 8, 1891: 8, 1892: 8, 1894: 8, 1896: 8, 1904: 8, 2015: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8}, ], } DBC = { - CAR.PACIFICA_2017_HYBRID: dbc_dict( - 'chrysler_pacifica_2017_hybrid', # 'pt' - 'chrysler_pacifica_2017_hybrid_private_fusion'), # 'radar' - CAR.PACIFICA_2018: dbc_dict( # Same DBC file works. - 'chrysler_pacifica_2017_hybrid', # 'pt' - 'chrysler_pacifica_2017_hybrid_private_fusion'), # 'radar' - CAR.PACIFICA_2018_HYBRID: dbc_dict( # Same DBC file works. - 'chrysler_pacifica_2017_hybrid', # 'pt' - 'chrysler_pacifica_2017_hybrid_private_fusion'), # 'radar' - CAR.PACIFICA_2019_HYBRID: dbc_dict( # Same DBC file works. - 'chrysler_pacifica_2017_hybrid', # 'pt' - 'chrysler_pacifica_2017_hybrid_private_fusion'), # 'radar' - CAR.JEEP_CHEROKEE: dbc_dict( # Same DBC file works. - 'chrysler_pacifica_2017_hybrid', # 'pt' - 'chrysler_pacifica_2017_hybrid_private_fusion'), # 'radar' - CAR.JEEP_CHEROKEE_2019: dbc_dict( # Same DBC file works. - 'chrysler_pacifica_2017_hybrid', # 'pt' - 'chrysler_pacifica_2017_hybrid_private_fusion'), # 'radar' + CAR.PACIFICA_2017_HYBRID: dbc_dict('chrysler_pacifica_2017_hybrid', 'chrysler_pacifica_2017_hybrid_private_fusion'), + CAR.PACIFICA_2018: dbc_dict('chrysler_pacifica_2017_hybrid', 'chrysler_pacifica_2017_hybrid_private_fusion'), + CAR.PACIFICA_2020: dbc_dict('chrysler_pacifica_2017_hybrid', 'chrysler_pacifica_2017_hybrid_private_fusion'), + CAR.PACIFICA_2018_HYBRID: dbc_dict('chrysler_pacifica_2017_hybrid', 'chrysler_pacifica_2017_hybrid_private_fusion'), + CAR.PACIFICA_2019_HYBRID: dbc_dict('chrysler_pacifica_2017_hybrid', 'chrysler_pacifica_2017_hybrid_private_fusion'), + CAR.JEEP_CHEROKEE: dbc_dict('chrysler_pacifica_2017_hybrid', 'chrysler_pacifica_2017_hybrid_private_fusion'), + CAR.JEEP_CHEROKEE_2019: dbc_dict('chrysler_pacifica_2017_hybrid', 'chrysler_pacifica_2017_hybrid_private_fusion'), } STEER_THRESHOLD = 120 - - -class ECU: - CAM = 0 # LKAS camera - - -ECU_FINGERPRINT = { - ECU.CAM: 0x2d9, # steer torque cmd -} - - -def check_ecu_msgs(fingerprint, ecu): - # return True if fingerprint contains messages normally sent by a given ecu - return ECU_FINGERPRINT[ecu] in fingerprint diff --git a/selfdrive/car/fingerprints.py b/selfdrive/car/fingerprints.py new file mode 100644 index 00000000000000..64dc56625cb844 --- /dev/null +++ b/selfdrive/car/fingerprints.py @@ -0,0 +1,79 @@ +import os +from common.basedir import BASEDIR + + +def get_attr_from_cars(attr, result=dict, combine_brands=True): + # read all the folders in selfdrive/car and return a dict where: + # - keys are all the car models + # - values are attr values from all car folders + result = result() + + for car_folder in [x[0] for x in os.walk(BASEDIR + '/selfdrive/car')]: + try: + car_name = car_folder.split('/')[-1] + values = __import__('selfdrive.car.%s.values' % car_name, fromlist=[attr]) + if hasattr(values, attr): + attr_values = getattr(values, attr) + else: + continue + + if isinstance(attr_values, dict): + for f, v in attr_values.items(): + if combine_brands: + result[f] = v + else: + if car_name not in result: + result[car_name] = {} + result[car_name][f] = v + elif isinstance(attr_values, list): + result += attr_values + + except (ImportError, IOError): + pass + + return result + + +FW_VERSIONS = get_attr_from_cars('FW_VERSIONS') +_FINGERPRINTS = get_attr_from_cars('FINGERPRINTS') +IGNORED_FINGERPRINTS = get_attr_from_cars('IGNORED_FINGERPRINTS', list) + +_DEBUG_ADDRESS = {1880: 8} # reserved for debug purposes + +def is_valid_for_fingerprint(msg, car_fingerprint): + adr = msg.address + # ignore addresses that are more than 11 bits + return (adr in car_fingerprint and car_fingerprint[adr] == len(msg.dat)) or adr >= 0x800 + + +def eliminate_incompatible_cars(msg, candidate_cars): + """Removes cars that could not have sent msg. + + Inputs: + msg: A cereal/log CanData message from the car. + candidate_cars: A list of cars to consider. + + Returns: + A list containing the subset of candidate_cars that could have sent msg. + """ + compatible_cars = [] + + for car_name in candidate_cars: + if car_name in IGNORED_FINGERPRINTS: + continue + + car_fingerprints = _FINGERPRINTS[car_name] + + for fingerprint in car_fingerprints: + fingerprint.update(_DEBUG_ADDRESS) # add alien debug address + + if is_valid_for_fingerprint(msg, fingerprint): + compatible_cars.append(car_name) + break + + return compatible_cars + + +def all_known_cars(): + """Returns a list of all known car strings.""" + return list(_FINGERPRINTS.keys()) diff --git a/selfdrive/car/ford/.gitignore b/selfdrive/car/ford/.gitignore deleted file mode 100644 index 89fa7bc7daf83e..00000000000000 --- a/selfdrive/car/ford/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -buttons.msg -buttons.cc.msg diff --git a/selfdrive/car/ford/carcontroller.py b/selfdrive/car/ford/carcontroller.py new file mode 100644 index 00000000000000..648fa077410b89 --- /dev/null +++ b/selfdrive/car/ford/carcontroller.py @@ -0,0 +1,87 @@ +from cereal import car +from selfdrive.car import make_can_msg +from selfdrive.car.ford.fordcan import create_steer_command, create_lkas_ui, spam_cancel_button +from opendbc.can.packer import CANPacker + + +MAX_STEER_DELTA = 1 +TOGGLE_DEBUG = False + +class CarController(): + def __init__(self, dbc_name, CP, VM): + self.packer = CANPacker(dbc_name) + self.enable_camera = CP.enableCamera + self.enabled_last = False + self.main_on_last = False + self.vehicle_model = VM + self.generic_toggle_last = 0 + self.steer_alert_last = False + self.lkas_action = 0 + + def update(self, enabled, CS, frame, actuators, visual_alert, pcm_cancel): + + can_sends = [] + steer_alert = visual_alert == car.CarControl.HUDControl.VisualAlert.steerRequired + + apply_steer = actuators.steer + + if self.enable_camera: + + if pcm_cancel: + #print "CANCELING!!!!" + can_sends.append(spam_cancel_button(self.packer)) + + if (frame % 3) == 0: + + curvature = self.vehicle_model.calc_curvature(actuators.steerAngle*3.1415/180., CS.out.vEgo) + + # The use of the toggle below is handy for trying out the various LKAS modes + if TOGGLE_DEBUG: + self.lkas_action += int(CS.out.genericToggle and not self.generic_toggle_last) + self.lkas_action &= 0xf + else: + self.lkas_action = 5 # 4 and 5 seem the best. 8 and 9 seem to aggressive and laggy + + can_sends.append(create_steer_command(self.packer, apply_steer, enabled, + CS.lkas_state, CS.out.steeringAngle, curvature, self.lkas_action)) + self.generic_toggle_last = CS.out.genericToggle + + if (frame % 100) == 0: + + can_sends.append(make_can_msg(973, b'\x00\x00\x00\x00\x00\x00\x00\x00', 0)) + #can_sends.append(make_can_msg(984, b'\x00\x00\x00\x00\x80\x45\x60\x30', 0)) + + if (frame % 100) == 0 or (self.enabled_last != enabled) or (self.main_on_last != CS.out.cruiseState.available) or \ + (self.steer_alert_last != steer_alert): + can_sends.append(create_lkas_ui(self.packer, CS.out.cruiseState.available, enabled, steer_alert)) + + if (frame % 200) == 0: + can_sends.append(make_can_msg(1875, b'\x80\xb0\x55\x55\x78\x90\x00\x00', 1)) + + if (frame % 10) == 0: + + can_sends.append(make_can_msg(1648, b'\x00\x00\x00\x40\x00\x00\x50\x00', 1)) + can_sends.append(make_can_msg(1649, b'\x10\x10\xf1\x70\x04\x00\x00\x00', 1)) + + can_sends.append(make_can_msg(1664, b'\x00\x00\x03\xe8\x00\x01\xa9\xb2', 1)) + can_sends.append(make_can_msg(1674, b'\x08\x00\x00\xff\x0c\xfb\x6a\x08', 1)) + can_sends.append(make_can_msg(1675, b'\x00\x00\x3b\x60\x37\x00\x00\x00', 1)) + can_sends.append(make_can_msg(1690, b'\x70\x00\x00\x55\x86\x1c\xe0\x00', 1)) + + can_sends.append(make_can_msg(1910, b'\x06\x4b\x06\x4b\x42\xd3\x11\x30', 1)) + can_sends.append(make_can_msg(1911, b'\x48\x53\x37\x54\x48\x53\x37\x54', 1)) + can_sends.append(make_can_msg(1912, b'\x31\x34\x47\x30\x38\x31\x43\x42', 1)) + can_sends.append(make_can_msg(1913, b'\x31\x34\x47\x30\x38\x32\x43\x42', 1)) + can_sends.append(make_can_msg(1969, b'\xf4\x40\x00\x00\x00\x00\x00\x00', 1)) + can_sends.append(make_can_msg(1971, b'\x0b\xc0\x00\x00\x00\x00\x00\x00', 1)) + + static_msgs = range(1653, 1658) + for addr in static_msgs: + cnt = (frame % 10) + 1 + can_sends.append(make_can_msg(addr, (cnt << 4).to_bytes(1, 'little') + b'\x00\x00\x00\x00\x00\x00\x00', 1)) + + self.enabled_last = enabled + self.main_on_last = CS.out.cruiseState.available + self.steer_alert_last = steer_alert + + return can_sends diff --git a/selfdrive/car/ford/carstate.py b/selfdrive/car/ford/carstate.py index 5e87a2c87812f1..7f34acc9df855c 100644 --- a/selfdrive/car/ford/carstate.py +++ b/selfdrive/car/ford/carstate.py @@ -1,87 +1,56 @@ -from selfdrive.can.parser import CANParser +from cereal import car +from opendbc.can.parser import CANParser +from common.numpy_fast import mean from selfdrive.config import Conversions as CV +from selfdrive.car.interfaces import CarStateBase from selfdrive.car.ford.values import DBC -from common.kalman.simple_kalman import KF1D -import numpy as np WHEEL_RADIUS = 0.33 -def get_can_parser(CP): - - signals = [ - # sig_name, sig_address, default - ("WhlRr_W_Meas", "WheelSpeed_CG1", 0.), - ("WhlRl_W_Meas", "WheelSpeed_CG1", 0.), - ("WhlFr_W_Meas", "WheelSpeed_CG1", 0.), - ("WhlFl_W_Meas", "WheelSpeed_CG1", 0.), - ("SteWhlRelInit_An_Sns", "Steering_Wheel_Data_CG1", 0.), - ("Cruise_State", "Cruise_Status", 0.), - ("Set_Speed", "Cruise_Status", 0.), - ("LaActAvail_D_Actl", "Lane_Keep_Assist_Status", 0), - ("LaHandsOff_B_Actl", "Lane_Keep_Assist_Status", 0), - ("LaActDeny_B_Actl", "Lane_Keep_Assist_Status", 0), - ("ApedPosScal_Pc_Actl", "EngineData_14", 0.), - ("Dist_Incr", "Steering_Buttons", 0.), - ("Brake_Drv_Appl", "Cruise_Status", 0.), - ("Brake_Lights", "BCM_to_HS_Body", 0.), - ] - - checks = [ - ] - - return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0) - - -class CarState(object): - def __init__(self, CP): - - self.CP = CP - self.left_blinker_on = 0 - self.right_blinker_on = 0 - - # initialize can parser - self.car_fingerprint = CP.carFingerprint - - # vEgo kalman filter - dt = 0.01 - # Q = np.matrix([[10.0, 0.0], [0.0, 100.0]]) - # R = 1e3 - self.v_ego_kf = KF1D(x0=[[0.0], [0.0]], - A=[[1.0, dt], [0.0, 1.0]], - C=[1.0, 0.0], - K=[[0.12287673], [0.29666309]]) - self.v_ego = 0.0 - +class CarState(CarStateBase): def update(self, cp): - # update prevs, update must run once per loop - self.prev_left_blinker_on = self.left_blinker_on - self.prev_right_blinker_on = self.right_blinker_on - - # calc best v_ego estimate, by averaging two opposite corners - self.v_wheel_fl = cp.vl["WheelSpeed_CG1"]['WhlRr_W_Meas'] * WHEEL_RADIUS - self.v_wheel_fr = cp.vl["WheelSpeed_CG1"]['WhlRl_W_Meas'] * WHEEL_RADIUS - self.v_wheel_rl = cp.vl["WheelSpeed_CG1"]['WhlFr_W_Meas'] * WHEEL_RADIUS - self.v_wheel_rr = cp.vl["WheelSpeed_CG1"]['WhlFl_W_Meas'] * WHEEL_RADIUS - v_wheel = float(np.mean([self.v_wheel_fl, self.v_wheel_fr, self.v_wheel_rl, self.v_wheel_rr])) - - # Kalman filter - if abs(v_wheel - self.v_ego) > 2.0: # Prevent large accelerations when car starts at non zero speed - self.v_ego_kf.x = [[v_wheel], [0.0]] - - self.v_ego_raw = v_wheel - v_ego_x = self.v_ego_kf.update(v_wheel) - self.v_ego = float(v_ego_x[0]) - self.a_ego = float(v_ego_x[1]) - self.standstill = not v_wheel > 0.001 - - self.angle_steers = cp.vl["Steering_Wheel_Data_CG1"]['SteWhlRelInit_An_Sns'] - self.v_cruise_pcm = cp.vl["Cruise_Status"]['Set_Speed'] * CV.MPH_TO_MS - self.pcm_acc_status = cp.vl["Cruise_Status"]['Cruise_State'] - self.main_on = cp.vl["Cruise_Status"]['Cruise_State'] != 0 + ret = car.CarState.new_message() + ret.wheelSpeeds.rr = cp.vl["WheelSpeed_CG1"]['WhlRr_W_Meas'] * WHEEL_RADIUS + ret.wheelSpeeds.rl = cp.vl["WheelSpeed_CG1"]['WhlRl_W_Meas'] * WHEEL_RADIUS + ret.wheelSpeeds.fr = cp.vl["WheelSpeed_CG1"]['WhlFr_W_Meas'] * WHEEL_RADIUS + ret.wheelSpeeds.fl = cp.vl["WheelSpeed_CG1"]['WhlFl_W_Meas'] * WHEEL_RADIUS + ret.vEgoRaw = mean([ret.wheelSpeeds.rr, ret.wheelSpeeds.rl, ret.wheelSpeeds.fr, ret.wheelSpeeds.fl]) + ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) + ret.standstill = not ret.vEgoRaw > 0.001 + ret.steeringAngle = cp.vl["Steering_Wheel_Data_CG1"]['SteWhlRelInit_An_Sns'] + ret.steeringPressed = not cp.vl["Lane_Keep_Assist_Status"]['LaHandsOff_B_Actl'] + ret.steerError = cp.vl["Lane_Keep_Assist_Status"]['LaActDeny_B_Actl'] == 1 + ret.cruiseState.speed = cp.vl["Cruise_Status"]['Set_Speed'] * CV.MPH_TO_MS + ret.cruiseState.enabled = not (cp.vl["Cruise_Status"]['Cruise_State'] in [0, 3]) + ret.cruiseState.available = cp.vl["Cruise_Status"]['Cruise_State'] != 0 + ret.gas = cp.vl["EngineData_14"]['ApedPosScal_Pc_Actl'] / 100. + ret.gasPressed = ret.gas > 1e-6 + ret.brakePressed = bool(cp.vl["Cruise_Status"]["Brake_Drv_Appl"]) + ret.brakeLights = bool(cp.vl["BCM_to_HS_Body"]["Brake_Lights"]) + ret.genericToggle = bool(cp.vl["Steering_Buttons"]["Dist_Incr"]) + # TODO: we also need raw driver torque, needed for Assisted Lane Change self.lkas_state = cp.vl["Lane_Keep_Assist_Status"]['LaActAvail_D_Actl'] - self.steer_override = not cp.vl["Lane_Keep_Assist_Status"]['LaHandsOff_B_Actl'] - self.steer_error = cp.vl["Lane_Keep_Assist_Status"]['LaActDeny_B_Actl'] - self.user_gas = cp.vl["EngineData_14"]['ApedPosScal_Pc_Actl'] - self.brake_pressed = bool(cp.vl["Cruise_Status"]["Brake_Drv_Appl"]) - self.brake_lights = bool(cp.vl["BCM_to_HS_Body"]["Brake_Lights"]) - self.generic_toggle = bool(cp.vl["Steering_Buttons"]["Dist_Incr"]) + + return ret + + @staticmethod + def get_can_parser(CP): + signals = [ + # sig_name, sig_address, default + ("WhlRr_W_Meas", "WheelSpeed_CG1", 0.), + ("WhlRl_W_Meas", "WheelSpeed_CG1", 0.), + ("WhlFr_W_Meas", "WheelSpeed_CG1", 0.), + ("WhlFl_W_Meas", "WheelSpeed_CG1", 0.), + ("SteWhlRelInit_An_Sns", "Steering_Wheel_Data_CG1", 0.), + ("Cruise_State", "Cruise_Status", 0.), + ("Set_Speed", "Cruise_Status", 0.), + ("LaActAvail_D_Actl", "Lane_Keep_Assist_Status", 0), + ("LaHandsOff_B_Actl", "Lane_Keep_Assist_Status", 0), + ("LaActDeny_B_Actl", "Lane_Keep_Assist_Status", 0), + ("ApedPosScal_Pc_Actl", "EngineData_14", 0.), + ("Dist_Incr", "Steering_Buttons", 0.), + ("Brake_Drv_Appl", "Cruise_Status", 0.), + ("Brake_Lights", "BCM_to_HS_Body", 0.), + ] + checks = [] + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0) diff --git a/selfdrive/car/ford/fordcan.py b/selfdrive/car/ford/fordcan.py new file mode 100644 index 00000000000000..e98dec584baa74 --- /dev/null +++ b/selfdrive/car/ford/fordcan.py @@ -0,0 +1,50 @@ +from common.numpy_fast import clip +from selfdrive.car.ford.values import MAX_ANGLE + + +def create_steer_command(packer, angle_cmd, enabled, lkas_state, angle_steers, curvature, lkas_action): + """Creates a CAN message for the Ford Steer Command.""" + + #if enabled and lkas available: + if enabled and lkas_state in [2, 3]: # and (frame % 500) >= 3: + action = lkas_action + else: + action = 0xf + angle_cmd = angle_steers/MAX_ANGLE + + angle_cmd = clip(angle_cmd * MAX_ANGLE, - MAX_ANGLE, MAX_ANGLE) + + values = { + "Lkas_Action": action, + "Lkas_Alert": 0xf, # no alerts + "Lane_Curvature": clip(curvature, -0.01, 0.01), # is it just for debug? + #"Lane_Curvature": 0, # is it just for debug? + "Steer_Angle_Req": angle_cmd + } + return packer.make_can_msg("Lane_Keep_Assist_Control", 0, values) + + +def create_lkas_ui(packer, main_on, enabled, steer_alert): + """Creates a CAN message for the Ford Steer Ui.""" + + if not main_on: + lines = 0xf + elif enabled: + lines = 0x3 + else: + lines = 0x6 + + values = { + "Set_Me_X80": 0x80, + "Set_Me_X45": 0x45, + "Set_Me_X30": 0x30, + "Lines_Hud": lines, + "Hands_Warning_W_Chime": steer_alert, + } + return packer.make_can_msg("Lane_Keep_Assist_Ui", 0, values) + +def spam_cancel_button(packer): + values = { + "Cancel": 1 + } + return packer.make_can_msg("Steering_Buttons", 0, values) diff --git a/selfdrive/car/ford/interface.py b/selfdrive/car/ford/interface.py index 59acc843241d78..9def1ca86b8d8e 100755 --- a/selfdrive/car/ford/interface.py +++ b/selfdrive/car/ford/interface.py @@ -1,56 +1,24 @@ -#!/usr/bin/env python -from common.realtime import sec_since_boot +#!/usr/bin/env python3 from cereal import car from selfdrive.swaglog import cloudlog from selfdrive.config import Conversions as CV -from selfdrive.controls.lib.drive_helpers import EventTypes as ET, create_event -from selfdrive.controls.lib.vehicle_model import VehicleModel -from selfdrive.car.ford.carstate import CarState, get_can_parser from selfdrive.car.ford.values import MAX_ANGLE -from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness +from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint +from selfdrive.car.interfaces import CarInterfaceBase -class CarInterface(object): - def __init__(self, CP, CarController): - self.CP = CP - self.VM = VehicleModel(CP) - - self.frame = 0 - self.gas_pressed_prev = False - self.brake_pressed_prev = False - self.cruise_enabled_prev = False - - # *** init the major players *** - self.CS = CarState(CP) - - self.cp = get_can_parser(CP) - - self.CC = None - if CarController is not None: - self.CC = CarController(self.cp.dbc_name, CP.enableCamera, self.VM) +class CarInterface(CarInterfaceBase): @staticmethod def compute_gb(accel, speed): return float(accel) / 3.0 @staticmethod - def calc_accel_override(a_ego, a_target, v_ego, v_target): - return 1.0 - - @staticmethod - def get_params(candidate, fingerprint, vin="", is_panda_black=False): - - ret = car.CarParams.new_message() - + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "ford" - ret.carFingerprint = candidate - ret.carVin = vin - ret.isPandaBlack = is_panda_black - ret.safetyModel = car.CarParams.SafetyModel.ford - - # pedal - ret.enableCruise = True + ret.dashcamOnly = True ret.wheelbase = 2.85 ret.steerRatio = 14.8 @@ -59,14 +27,11 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.01], [0.005]] # TODO: tune this ret.lateralTuning.pid.kf = 1. / MAX_ANGLE # MAX Steer angle to normalize FF ret.steerActuatorDelay = 0.1 # Default delay, not measured yet + ret.steerLimitTimer = 0.8 ret.steerRateCost = 1.0 ret.centerToFront = ret.wheelbase * 0.44 tire_stiffness_factor = 0.5328 - # min speed to enable ACC. if car can do stop and go, then set enabling speed - # to a negative value, so it won't matter. - ret.minEnableSpeed = -1. - # TODO: get actual value, for now starting with reasonable value for # civic and scaling by mass and wheelbase ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) @@ -76,102 +41,32 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront, tire_stiffness_factor=tire_stiffness_factor) - # no rear steering, at least on the listed cars above - ret.steerRatioRear = 0. ret.steerControlType = car.CarParams.SteerControlType.angle - # steer, gas, brake limitations VS speed - ret.steerMaxBP = [0.] # breakpoints at 1 and 40 kph - ret.steerMaxV = [1.0] # 2/3rd torque allowed above 45 kph - ret.gasMaxBP = [0.] - ret.gasMaxV = [0.5] - ret.brakeMaxBP = [5., 20.] - ret.brakeMaxV = [1., 0.8] - - ret.enableCamera = not any(x for x in [970, 973, 984] if x in fingerprint) or is_panda_black - ret.openpilotLongitudinalControl = False - cloudlog.warn("ECU Camera Simulated: %r", ret.enableCamera) - - ret.steerLimitAlert = False - ret.stoppingControl = False - ret.startAccel = 0.0 - - ret.longitudinalTuning.deadzoneBP = [0., 9.] - ret.longitudinalTuning.deadzoneV = [0., .15] - ret.longitudinalTuning.kpBP = [0., 5., 35.] - ret.longitudinalTuning.kpV = [3.6, 2.4, 1.5] - ret.longitudinalTuning.kiBP = [0., 35.] - ret.longitudinalTuning.kiV = [0.54, 0.36] + ret.enableCamera = True + cloudlog.warning("ECU Camera Simulated: %r", ret.enableCamera) return ret # returns a car.CarState def update(self, c, can_strings): # ******************* do can recv ******************* - self.cp.update_strings(int(sec_since_boot() * 1e9), can_strings) + self.cp.update_strings(can_strings) - self.CS.update(self.cp) - - # create message - ret = car.CarState.new_message() + ret = self.CS.update(self.cp) ret.canValid = self.cp.can_valid - # speeds - ret.vEgo = self.CS.v_ego - ret.vEgoRaw = self.CS.v_ego_raw - ret.standstill = self.CS.standstill - ret.wheelSpeeds.fl = self.CS.v_wheel_fl - ret.wheelSpeeds.fr = self.CS.v_wheel_fr - ret.wheelSpeeds.rl = self.CS.v_wheel_rl - ret.wheelSpeeds.rr = self.CS.v_wheel_rr - - # steering wheel - ret.steeringAngle = self.CS.angle_steers - ret.steeringPressed = self.CS.steer_override - - # gas pedal - ret.gas = self.CS.user_gas / 100. - ret.gasPressed = self.CS.user_gas > 0.0001 - ret.brakePressed = self.CS.brake_pressed - ret.brakeLights = self.CS.brake_lights - - ret.cruiseState.enabled = not (self.CS.pcm_acc_status in [0, 3]) - ret.cruiseState.speed = self.CS.v_cruise_pcm - ret.cruiseState.available = self.CS.pcm_acc_status != 0 - - ret.genericToggle = self.CS.generic_toggle - # events - events = [] - - if self.CS.steer_error: - events.append(create_event('steerUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT])) - - # enable request in prius is simple, as we activate when Toyota is active (rising edge) - if ret.cruiseState.enabled and not self.cruise_enabled_prev: - events.append(create_event('pcmEnable', [ET.ENABLE])) - elif not ret.cruiseState.enabled: - events.append(create_event('pcmDisable', [ET.USER_DISABLE])) - - # disable on pedals rising edge or when brake is pressed and speed isn't zero - if (ret.gasPressed and not self.gas_pressed_prev) or \ - (ret.brakePressed and (not self.brake_pressed_prev or ret.vEgo > 0.001)): - events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) - - if ret.gasPressed: - events.append(create_event('pedalPressed', [ET.PRE_ENABLE])) - - if self.CS.lkas_state not in [2, 3] and ret.vEgo > 13.* CV.MPH_TO_MS and ret.cruiseState.enabled: - events.append(create_event('steerTempUnavailableMute', [ET.WARNING])) + events = self.create_common_events(ret) - ret.events = events + if self.CS.lkas_state not in [2, 3] and ret.vEgo > 13. * CV.MPH_TO_MS and ret.cruiseState.enabled: + events.add(car.CarEvent.EventName.steerTempUnavailableMute) - self.gas_pressed_prev = ret.gasPressed - self.brake_pressed_prev = ret.brakePressed - self.cruise_enabled_prev = ret.cruiseState.enabled + ret.events = events.to_msg() - return ret.as_reader() + self.CS.out = ret.as_reader() + return self.CS.out # pass in a car.CarControl # to be called @ 100hz diff --git a/selfdrive/car/ford/radar_interface.py b/selfdrive/car/ford/radar_interface.py index 04cab9c66d7e1b..20a435b0821dff 100755 --- a/selfdrive/car/ford/radar_interface.py +++ b/selfdrive/car/ford/radar_interface.py @@ -1,52 +1,45 @@ -#!/usr/bin/env python -import os -import numpy as np -from selfdrive.can.parser import CANParser +#!/usr/bin/env python3 from cereal import car -from common.realtime import sec_since_boot +from opendbc.can.parser import CANParser +from selfdrive.car.ford.values import DBC +from selfdrive.config import Conversions as CV +from selfdrive.car.interfaces import RadarInterfaceBase -RADAR_MSGS = range(0x500, 0x540) +RADAR_MSGS = list(range(0x500, 0x540)) -def _create_radar_can_parser(): - dbc_f = 'ford_fusion_2018_adas.dbc' +def _create_radar_can_parser(car_fingerprint): msg_n = len(RADAR_MSGS) signals = list(zip(['X_Rel'] * msg_n + ['Angle'] * msg_n + ['V_Rel'] * msg_n, RADAR_MSGS * 3, [0] * msg_n + [0] * msg_n + [0] * msg_n)) checks = list(zip(RADAR_MSGS, [20]*msg_n)) - return CANParser(os.path.splitext(dbc_f)[0], signals, checks, 1) + return CANParser(DBC[car_fingerprint]['radar'], signals, checks, 1) -class RadarInterface(object): +class RadarInterface(RadarInterfaceBase): def __init__(self, CP): - # radar - self.pts = {} + super().__init__(CP) self.validCnt = {key: 0 for key in RADAR_MSGS} self.track_id = 0 - self.delay = 0.0 # Delay of radar - - # Nidec - self.rcp = _create_radar_can_parser() + self.rcp = _create_radar_can_parser(CP.carFingerprint) self.trigger_msg = 0x53f self.updated_messages = set() def update(self, can_strings): - tm = int(sec_since_boot() * 1e9) - vls = self.rcp.update_strings(tm, can_strings) + vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) if self.trigger_msg not in self.updated_messages: return None - ret = car.RadarData.new_message() errors = [] if not self.rcp.can_valid: errors.append("canError") ret.errors = errors - for ii in self.updated_messages: + for ii in sorted(self.updated_messages): cpt = self.rcp.vl[ii] if cpt['X_Rel'] > 0.00001: @@ -55,7 +48,7 @@ def update(self, can_strings): if cpt['X_Rel'] > 0.00001: self.validCnt[ii] += 1 else: - self.validCnt[ii] = max(self.validCnt[ii] -1, 0) + self.validCnt[ii] = max(self.validCnt[ii] - 1, 0) #print ii, self.validCnt[ii], cpt['VALID'], cpt['X_Rel'], cpt['Angle'] # radar point only valid if there have been enough valid measurements @@ -65,7 +58,7 @@ def update(self, can_strings): self.pts[ii].trackId = self.track_id self.track_id += 1 self.pts[ii].dRel = cpt['X_Rel'] # from front of car - self.pts[ii].yRel = cpt['X_Rel'] * cpt['Angle'] * np.pi / 180. # in car frame's y axis, left is positive + self.pts[ii].yRel = cpt['X_Rel'] * cpt['Angle'] * CV.DEG_TO_RAD # in car frame's y axis, left is positive self.pts[ii].vRel = cpt['V_Rel'] self.pts[ii].aRel = float('nan') self.pts[ii].yvRel = float('nan') @@ -74,6 +67,6 @@ def update(self, can_strings): if ii in self.pts: del self.pts[ii] - ret.points = self.pts.values() + ret.points = list(self.pts.values()) self.updated_messages.clear() return ret diff --git a/selfdrive/car/ford/values.py b/selfdrive/car/ford/values.py index 6ab0b3750bf52d..315c398ab69016 100644 --- a/selfdrive/car/ford/values.py +++ b/selfdrive/car/ford/values.py @@ -1,4 +1,8 @@ +# flake8: noqa + from selfdrive.car import dbc_dict +from cereal import car +Ecu = car.CarParams.Ecu MAX_ANGLE = 87. # make sure we never command the extremes (0xfff) which cause latching fault diff --git a/selfdrive/car/fw_versions.py b/selfdrive/car/fw_versions.py new file mode 100755 index 00000000000000..29d5db5a9e4e04 --- /dev/null +++ b/selfdrive/car/fw_versions.py @@ -0,0 +1,251 @@ +#!/usr/bin/env python3 +import struct +import traceback +from typing import Any + +from tqdm import tqdm + +import panda.python.uds as uds +from cereal import car +from selfdrive.car.fingerprints import FW_VERSIONS, get_attr_from_cars +from selfdrive.car.isotp_parallel_query import IsoTpParallelQuery +from selfdrive.car.toyota.values import CAR as TOYOTA +from selfdrive.swaglog import cloudlog + +Ecu = car.CarParams.Ecu + + +def p16(val): + return struct.pack("!H", val) + + +TESTER_PRESENT_REQUEST = bytes([uds.SERVICE_TYPE.TESTER_PRESENT, 0x0]) +TESTER_PRESENT_RESPONSE = bytes([uds.SERVICE_TYPE.TESTER_PRESENT + 0x40, 0x0]) + +SHORT_TESTER_PRESENT_REQUEST = bytes([uds.SERVICE_TYPE.TESTER_PRESENT]) +SHORT_TESTER_PRESENT_RESPONSE = bytes([uds.SERVICE_TYPE.TESTER_PRESENT + 0x40]) + +DEFAULT_DIAGNOSTIC_REQUEST = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL, + uds.SESSION_TYPE.DEFAULT]) +DEFAULT_DIAGNOSTIC_RESPONSE = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL + 0x40, + uds.SESSION_TYPE.DEFAULT, 0x0, 0x32, 0x1, 0xf4]) + +EXTENDED_DIAGNOSTIC_REQUEST = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL, + uds.SESSION_TYPE.EXTENDED_DIAGNOSTIC]) +EXTENDED_DIAGNOSTIC_RESPONSE = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL + 0x40, + uds.SESSION_TYPE.EXTENDED_DIAGNOSTIC, 0x0, 0x32, 0x1, 0xf4]) + +UDS_VERSION_REQUEST = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \ + p16(uds.DATA_IDENTIFIER_TYPE.APPLICATION_SOFTWARE_IDENTIFICATION) +UDS_VERSION_RESPONSE = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) + \ + p16(uds.DATA_IDENTIFIER_TYPE.APPLICATION_SOFTWARE_IDENTIFICATION) + + +HYUNDAI_VERSION_REQUEST_SHORT = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \ + p16(0xf1a0) # 4 Byte version number +HYUNDAI_VERSION_REQUEST_LONG = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \ + p16(0xf100) # Long description +HYUNDAI_VERSION_REQUEST_MULTI = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \ + p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_SPARE_PART_NUMBER) + \ + p16(uds.DATA_IDENTIFIER_TYPE.APPLICATION_SOFTWARE_IDENTIFICATION) + \ + p16(0xf100) + \ + p16(0xf1a0) +HYUNDAI_VERSION_RESPONSE = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) + + +TOYOTA_VERSION_REQUEST = b'\x1a\x88\x01' +TOYOTA_VERSION_RESPONSE = b'\x5a\x88\x01' + +OBD_VERSION_REQUEST = b'\x09\x04' +OBD_VERSION_RESPONSE = b'\x49\x04' + + +# supports subaddressing, request, response +REQUESTS = [ + # Hundai + ( + "hyundai", + [HYUNDAI_VERSION_REQUEST_SHORT], + [HYUNDAI_VERSION_RESPONSE], + ), + ( + "hyundai", + [HYUNDAI_VERSION_REQUEST_LONG], + [HYUNDAI_VERSION_RESPONSE], + ), + ( + "hyundai", + [HYUNDAI_VERSION_REQUEST_MULTI], + [HYUNDAI_VERSION_RESPONSE], + ), + # Honda + ( + "honda", + [UDS_VERSION_REQUEST], + [UDS_VERSION_RESPONSE], + ), + # Toyota + ( + "toyota", + [SHORT_TESTER_PRESENT_REQUEST, TOYOTA_VERSION_REQUEST], + [SHORT_TESTER_PRESENT_RESPONSE, TOYOTA_VERSION_RESPONSE], + ), + ( + "toyota", + [SHORT_TESTER_PRESENT_REQUEST, OBD_VERSION_REQUEST], + [SHORT_TESTER_PRESENT_RESPONSE, OBD_VERSION_RESPONSE], + ), + ( + "toyota", + [TESTER_PRESENT_REQUEST, DEFAULT_DIAGNOSTIC_REQUEST, EXTENDED_DIAGNOSTIC_REQUEST, UDS_VERSION_REQUEST], + [TESTER_PRESENT_RESPONSE, DEFAULT_DIAGNOSTIC_RESPONSE, EXTENDED_DIAGNOSTIC_RESPONSE, UDS_VERSION_RESPONSE], + ) +] + + +def chunks(l, n=128): + for i in range(0, len(l), n): + yield l[i:i + n] + + +def match_fw_to_car(fw_versions): + candidates = FW_VERSIONS + invalid = [] + + fw_versions_dict = {} + for fw in fw_versions: + addr = fw.address + sub_addr = fw.subAddress if fw.subAddress != 0 else None + fw_versions_dict[(addr, sub_addr)] = fw.fwVersion + + for candidate, fws in candidates.items(): + for ecu, expected_versions in fws.items(): + ecu_type = ecu[0] + addr = ecu[1:] + found_version = fw_versions_dict.get(addr, None) + ESSENTIAL_ECUS = [Ecu.engine, Ecu.eps, Ecu.esp, Ecu.fwdRadar, Ecu.fwdCamera, Ecu.vsa, Ecu.electricBrakeBooster] + if ecu_type == Ecu.esp and candidate in [TOYOTA.RAV4, TOYOTA.COROLLA, TOYOTA.HIGHLANDER] and found_version is None: + continue + + # TODO: on some toyota, the engine can show on two different addresses + if ecu_type == Ecu.engine and candidate in [TOYOTA.COROLLA_TSS2, TOYOTA.CHR, TOYOTA.LEXUS_IS] and found_version is None: + continue + + # ignore non essential ecus + if ecu_type not in ESSENTIAL_ECUS and found_version is None: + continue + + if found_version not in expected_versions: + invalid.append(candidate) + break + + return set(candidates.keys()) - set(invalid) + + +def get_fw_versions(logcan, sendcan, bus, extra=None, timeout=0.1, debug=False, progress=False): + ecu_types = {} + + # Extract ECU adresses to query from fingerprints + # ECUs using a subadress need be queried one by one, the rest can be done in parallel + addrs = [] + parallel_addrs = [] + + versions = get_attr_from_cars('FW_VERSIONS', combine_brands=False) + if extra is not None: + versions.update(extra) + + for brand, brand_versions in versions.items(): + for c in brand_versions.values(): + for ecu_type, addr, sub_addr in c.keys(): + a = (brand, addr, sub_addr) + if a not in ecu_types: + ecu_types[(addr, sub_addr)] = ecu_type + + if sub_addr is None: + if a not in parallel_addrs: + parallel_addrs.append(a) + else: + if [a] not in addrs: + addrs.append([a]) + + addrs.insert(0, parallel_addrs) + + fw_versions = {} + for i, addr in enumerate(tqdm(addrs, disable=not progress)): + for addr_chunk in chunks(addr): + for brand, request, response in REQUESTS: + try: + addrs = [(a, s) for (b, a, s) in addr_chunk if b in (brand, 'any')] + + if addrs: + query = IsoTpParallelQuery(sendcan, logcan, bus, addrs, request, response, debug=debug) + t = 2 * timeout if i == 0 else timeout + fw_versions.update(query.get_data(t)) + except Exception: + cloudlog.warning(f"FW query exception: {traceback.format_exc()}") + + # Build capnp list to put into CarParams + car_fw = [] + for addr, version in fw_versions.items(): + f = car.CarParams.CarFw.new_message() + + f.ecu = ecu_types[addr] + f.fwVersion = version + f.address = addr[0] + + if addr[1] is not None: + f.subAddress = addr[1] + + car_fw.append(f) + + return car_fw + + +if __name__ == "__main__": + import time + import argparse + import cereal.messaging as messaging + from selfdrive.car.vin import get_vin + + parser = argparse.ArgumentParser(description='Get firmware version of ECUs') + parser.add_argument('--scan', action='store_true') + parser.add_argument('--debug', action='store_true') + args = parser.parse_args() + + logcan = messaging.sub_sock('can') + sendcan = messaging.pub_sock('sendcan') + + extra: Any = None + if args.scan: + extra = {} + # Honda + for i in range(256): + extra[(Ecu.unknown, 0x18da00f1 + (i << 8), None)] = [] + extra[(Ecu.unknown, 0x700 + i, None)] = [] + extra[(Ecu.unknown, 0x750, i)] = [] + extra = {"any": {"debug": extra}} + + time.sleep(1.) + + t = time.time() + print("Getting vin...") + addr, vin = get_vin(logcan, sendcan, 1, retry=10, debug=args.debug) + print(f"VIN: {vin}") + print("Getting VIN took %.3f s" % (time.time() - t)) + print() + + t = time.time() + fw_vers = get_fw_versions(logcan, sendcan, 1, extra=extra, debug=args.debug, progress=True) + candidates = match_fw_to_car(fw_vers) + + print() + print("Found FW versions") + print("{") + for version in fw_vers: + subaddr = None if version.subAddress == 0 else hex(version.subAddress) + print(f" (Ecu.{version.ecu}, {hex(version.address)}, {subaddr}): [{version.fwVersion}]") + print("}") + + print() + print("Possible matches:", candidates) + print("Getting fw took %.3f s" % (time.time() - t)) diff --git a/selfdrive/car/gm/.gitignore b/selfdrive/car/gm/.gitignore deleted file mode 100644 index 89fa7bc7daf83e..00000000000000 --- a/selfdrive/car/gm/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -buttons.msg -buttons.cc.msg diff --git a/selfdrive/car/gm/carcontroller.py b/selfdrive/car/gm/carcontroller.py index da820864f0d93a..9b8e68fee46d7c 100644 --- a/selfdrive/car/gm/carcontroller.py +++ b/selfdrive/car/gm/carcontroller.py @@ -4,31 +4,23 @@ from selfdrive.config import Conversions as CV from selfdrive.car import apply_std_steer_torque_limits from selfdrive.car.gm import gmcan -from selfdrive.car.gm.values import DBC, SUPERCRUISE_CARS -from selfdrive.can.packer import CANPacker +from selfdrive.car.gm.values import DBC, CanBus +from opendbc.can.packer import CANPacker VisualAlert = car.CarControl.HUDControl.VisualAlert class CarControllerParams(): - def __init__(self, car_fingerprint): - if car_fingerprint in SUPERCRUISE_CARS: - self.STEER_MAX = 150 - self.STEER_STEP = 1 # how often we update the steer cmd - self.STEER_DELTA_UP = 2 # 0.75s time to peak torque - self.STEER_DELTA_DOWN = 5 # 0.3s from peak torque to zero - self.MIN_STEER_SPEED = -1. # can steer down to zero - else: - self.STEER_MAX = 300 - self.STEER_STEP = 2 # how often we update the steer cmd - self.STEER_DELTA_UP = 7 # ~0.75s time to peak torque (255/50hz/0.75s) - self.STEER_DELTA_DOWN = 17 # ~0.3s from peak torque to zero - self.MIN_STEER_SPEED = 3. - + def __init__(self): + self.STEER_MAX = 300 + self.STEER_STEP = 2 # how often we update the steer cmd + self.STEER_DELTA_UP = 7 # ~0.75s time to peak torque (255/50hz/0.75s) + self.STEER_DELTA_DOWN = 17 # ~0.3s from peak torque to zero + self.MIN_STEER_SPEED = 3. self.STEER_DRIVER_ALLOWANCE = 50 # allowed driver torque before start limiting self.STEER_DRIVER_MULTIPLIER = 4 # weight driver torque heavily self.STEER_DRIVER_FACTOR = 100 # from dbc - self.NEAR_STOP_BRAKE_PHASE = 0.5 # m/s, more aggressive braking near full stop + self.NEAR_STOP_BRAKE_PHASE = 0.5 # m/s, more aggressive braking near full stop # Takes case of "Service Adaptive Cruise" and "Service Front Camera" # dashboard messages. @@ -46,140 +38,98 @@ def __init__(self, car_fingerprint): self.BRAKE_LOOKUP_V = [MAX_BRAKE, 0] -def actuator_hystereses(final_pedal, pedal_steady): - # hyst params... TODO: move these to VehicleParams - pedal_hyst_gap = 0.01 # don't change pedal command for small oscillations within this value - - # for small pedal oscillations within pedal_hyst_gap, don't change the pedal command - if final_pedal == 0.: - pedal_steady = 0. - elif final_pedal > pedal_steady + pedal_hyst_gap: - pedal_steady = final_pedal - pedal_hyst_gap - elif final_pedal < pedal_steady - pedal_hyst_gap: - pedal_steady = final_pedal + pedal_hyst_gap - final_pedal = pedal_steady - - return final_pedal, pedal_steady - -def process_hud_alert(hud_alert): - # initialize to no alert - steer = 0 - if hud_alert == VisualAlert.steerRequired: - steer = 1 - return steer - -class CarController(object): - def __init__(self, canbus, car_fingerprint): - self.pedal_steady = 0. +class CarController(): + def __init__(self, dbc_name, CP, VM): self.start_time = 0. - self.steer_idx = 0 self.apply_steer_last = 0 - self.car_fingerprint = car_fingerprint self.lka_icon_status_last = (False, False) + self.steer_rate_limited = False - # Setup detection helper. Routes commands to - # an appropriate CAN bus number. - self.canbus = canbus - self.params = CarControllerParams(car_fingerprint) + self.params = CarControllerParams() - self.packer_pt = CANPacker(DBC[car_fingerprint]['pt']) - self.packer_ch = CANPacker(DBC[car_fingerprint]['chassis']) + self.packer_pt = CANPacker(DBC[CP.carFingerprint]['pt']) + self.packer_obj = CANPacker(DBC[CP.carFingerprint]['radar']) + self.packer_ch = CANPacker(DBC[CP.carFingerprint]['chassis']) - def update(self, enabled, CS, frame, actuators, \ + def update(self, enabled, CS, frame, actuators, hud_v_cruise, hud_show_lanes, hud_show_car, hud_alert): P = self.params # Send CAN commands. can_sends = [] - canbus = self.canbus - - alert_out = process_hud_alert(hud_alert) - steer = alert_out - - ### STEER ### + # STEER if (frame % P.STEER_STEP) == 0: - lkas_enabled = enabled and not CS.steer_not_allowed and CS.v_ego > P.MIN_STEER_SPEED + lkas_enabled = enabled and not CS.out.steerWarning and CS.out.vEgo > P.MIN_STEER_SPEED if lkas_enabled: - apply_steer = actuators.steer * P.STEER_MAX - apply_steer = apply_std_steer_torque_limits(apply_steer, self.apply_steer_last, CS.steer_torque_driver, P) + new_steer = actuators.steer * P.STEER_MAX + apply_steer = apply_std_steer_torque_limits(new_steer, self.apply_steer_last, CS.out.steeringTorque, P) + self.steer_rate_limited = new_steer != apply_steer else: apply_steer = 0 self.apply_steer_last = apply_steer idx = (frame // P.STEER_STEP) % 4 - if self.car_fingerprint in SUPERCRUISE_CARS: - can_sends += gmcan.create_steering_control_ct6(self.packer_pt, - canbus, apply_steer, CS.v_ego, idx, lkas_enabled) - else: - can_sends.append(gmcan.create_steering_control(self.packer_pt, - canbus.powertrain, apply_steer, idx, lkas_enabled)) - - ### GAS/BRAKE ### + can_sends.append(gmcan.create_steering_control(self.packer_pt, CanBus.POWERTRAIN, apply_steer, idx, lkas_enabled)) - if self.car_fingerprint not in SUPERCRUISE_CARS: - # no output if not enabled, but keep sending keepalive messages - # treat pedals as one - final_pedal = actuators.gas - actuators.brake + # GAS/BRAKE + # no output if not enabled, but keep sending keepalive messages + # treat pedals as one + final_pedal = actuators.gas - actuators.brake - # *** apply pedal hysteresis *** - final_brake, self.brake_steady = actuator_hystereses( - final_pedal, self.pedal_steady) - - if not enabled: - # Stock ECU sends max regen when not enabled. - apply_gas = P.MAX_ACC_REGEN - apply_brake = 0 - else: - apply_gas = int(round(interp(final_pedal, P.GAS_LOOKUP_BP, P.GAS_LOOKUP_V))) - apply_brake = int(round(interp(final_pedal, P.BRAKE_LOOKUP_BP, P.BRAKE_LOOKUP_V))) - - # Gas/regen and brakes - all at 25Hz - if (frame % 4) == 0: - idx = (frame // 4) % 4 - - at_full_stop = enabled and CS.standstill - near_stop = enabled and (CS.v_ego < P.NEAR_STOP_BRAKE_PHASE) - can_sends.append(gmcan.create_friction_brake_command(self.packer_ch, canbus.chassis, apply_brake, idx, near_stop, at_full_stop)) - - at_full_stop = enabled and CS.standstill - can_sends.append(gmcan.create_gas_regen_command(self.packer_pt, canbus.powertrain, apply_gas, idx, enabled, at_full_stop)) - - # Send dashboard UI commands (ACC status), 25hz - if (frame % 4) == 0: - can_sends.append(gmcan.create_acc_dashboard_command(self.packer_pt, canbus.powertrain, enabled, hud_v_cruise * CV.MS_TO_KPH, hud_show_car)) - - # Radar needs to know current speed and yaw rate (50hz), - # and that ADAS is alive (10hz) - time_and_headlights_step = 10 - tt = frame * DT_CTRL - - if frame % time_and_headlights_step == 0: - idx = (frame // time_and_headlights_step) % 4 - can_sends.append(gmcan.create_adas_time_status(canbus.obstacle, int((tt - self.start_time) * 60), idx)) - can_sends.append(gmcan.create_adas_headlights_status(canbus.obstacle)) - - speed_and_accelerometer_step = 2 - if frame % speed_and_accelerometer_step == 0: - idx = (frame // speed_and_accelerometer_step) % 4 - can_sends.append(gmcan.create_adas_steering_status(canbus.obstacle, idx)) - can_sends.append(gmcan.create_adas_accelerometer_speed_status(canbus.obstacle, CS.v_ego, idx)) - - if frame % P.ADAS_KEEPALIVE_STEP == 0: - can_sends += gmcan.create_adas_keepalive(canbus.powertrain) - - # Show green icon when LKA torque is applied, and - # alarming orange icon when approaching torque limit. - # If not sent again, LKA icon disappears in about 5 seconds. - # Conveniently, sending camera message periodically also works as a keepalive. - lka_active = CS.lkas_status == 1 - lka_critical = lka_active and abs(actuators.steer) > 0.9 - lka_icon_status = (lka_active, lka_critical) - if frame % P.CAMERA_KEEPALIVE_STEP == 0 \ - or lka_icon_status != self.lka_icon_status_last: - can_sends.append(gmcan.create_lka_icon_command(canbus.sw_gmlan, lka_active, lka_critical, steer)) - self.lka_icon_status_last = lka_icon_status + if not enabled: + # Stock ECU sends max regen when not enabled. + apply_gas = P.MAX_ACC_REGEN + apply_brake = 0 + else: + apply_gas = int(round(interp(final_pedal, P.GAS_LOOKUP_BP, P.GAS_LOOKUP_V))) + apply_brake = int(round(interp(final_pedal, P.BRAKE_LOOKUP_BP, P.BRAKE_LOOKUP_V))) + + # Gas/regen and brakes - all at 25Hz + if (frame % 4) == 0: + idx = (frame // 4) % 4 + + at_full_stop = enabled and CS.out.standstill + near_stop = enabled and (CS.out.vEgo < P.NEAR_STOP_BRAKE_PHASE) + can_sends.append(gmcan.create_friction_brake_command(self.packer_ch, CanBus.CHASSIS, apply_brake, idx, near_stop, at_full_stop)) + can_sends.append(gmcan.create_gas_regen_command(self.packer_pt, CanBus.POWERTRAIN, apply_gas, idx, enabled, at_full_stop)) + + # Send dashboard UI commands (ACC status), 25hz + if (frame % 4) == 0: + send_fcw = hud_alert == VisualAlert.fcw + can_sends.append(gmcan.create_acc_dashboard_command(self.packer_pt, CanBus.POWERTRAIN, enabled, hud_v_cruise * CV.MS_TO_KPH, hud_show_car, send_fcw)) + + # Radar needs to know current speed and yaw rate (50hz), + # and that ADAS is alive (10hz) + time_and_headlights_step = 10 + tt = frame * DT_CTRL + + if frame % time_and_headlights_step == 0: + idx = (frame // time_and_headlights_step) % 4 + can_sends.append(gmcan.create_adas_time_status(CanBus.OBSTACLE, int((tt - self.start_time) * 60), idx)) + can_sends.append(gmcan.create_adas_headlights_status(self.packer_obj, CanBus.OBSTACLE)) + + speed_and_accelerometer_step = 2 + if frame % speed_and_accelerometer_step == 0: + idx = (frame // speed_and_accelerometer_step) % 4 + can_sends.append(gmcan.create_adas_steering_status(CanBus.OBSTACLE, idx)) + can_sends.append(gmcan.create_adas_accelerometer_speed_status(CanBus.OBSTACLE, CS.out.vEgo, idx)) + + if frame % P.ADAS_KEEPALIVE_STEP == 0: + can_sends += gmcan.create_adas_keepalive(CanBus.POWERTRAIN) + + # Show green icon when LKA torque is applied, and + # alarming orange icon when approaching torque limit. + # If not sent again, LKA icon disappears in about 5 seconds. + # Conveniently, sending camera message periodically also works as a keepalive. + lka_active = CS.lkas_status == 1 + lka_critical = lka_active and abs(actuators.steer) > 0.9 + lka_icon_status = (lka_active, lka_critical) + if frame % P.CAMERA_KEEPALIVE_STEP == 0 or lka_icon_status != self.lka_icon_status_last: + steer_alert = hud_alert == VisualAlert.steerRequired + can_sends.append(gmcan.create_lka_icon_command(CanBus.SW_GMLAN, lka_active, lka_critical, steer_alert)) + self.lka_icon_status_last = lka_icon_status return can_sends diff --git a/selfdrive/car/gm/carstate.py b/selfdrive/car/gm/carstate.py index 2501598dd6cf7d..7f45e7ea9e6e93 100644 --- a/selfdrive/car/gm/carstate.py +++ b/selfdrive/car/gm/carstate.py @@ -1,151 +1,108 @@ -import numpy as np from cereal import car -from common.kalman.simple_kalman import KF1D +from common.numpy_fast import mean from selfdrive.config import Conversions as CV -from selfdrive.can.parser import CANParser -from selfdrive.car.gm.values import DBC, CAR, parse_gear_shifter, \ - CruiseButtons, is_eps_status_ok, \ - STEER_THRESHOLD, SUPERCRUISE_CARS - -def get_powertrain_can_parser(CP, canbus): - # this function generates lists for signal, messages and initial values - signals = [ - # sig_name, sig_address, default - ("BrakePedalPosition", "EBCMBrakePedalPosition", 0), - ("FrontLeftDoor", "BCMDoorBeltStatus", 0), - ("FrontRightDoor", "BCMDoorBeltStatus", 0), - ("RearLeftDoor", "BCMDoorBeltStatus", 0), - ("RearRightDoor", "BCMDoorBeltStatus", 0), - ("LeftSeatBelt", "BCMDoorBeltStatus", 0), - ("RightSeatBelt", "BCMDoorBeltStatus", 0), - ("TurnSignals", "BCMTurnSignals", 0), - ("AcceleratorPedal", "AcceleratorPedal", 0), - ("ACCButtons", "ASCMSteeringButton", CruiseButtons.UNPRESS), - ("SteeringWheelAngle", "PSCMSteeringAngle", 0), - ("FLWheelSpd", "EBCMWheelSpdFront", 0), - ("FRWheelSpd", "EBCMWheelSpdFront", 0), - ("RLWheelSpd", "EBCMWheelSpdRear", 0), - ("RRWheelSpd", "EBCMWheelSpdRear", 0), - ("PRNDL", "ECMPRDNL", 0), - ("LKADriverAppldTrq", "PSCMStatus", 0), - ("LKATorqueDeliveredStatus", "PSCMStatus", 0), - ] - - if CP.carFingerprint == CAR.VOLT: - signals += [ - ("RegenPaddle", "EBCMRegenPaddle", 0), - ] - if CP.carFingerprint in SUPERCRUISE_CARS: - signals += [ - ("ACCCmdActive", "ASCMActiveCruiseControlStatus", 0) - ] - else: - signals += [ - ("TractionControlOn", "ESPStatus", 0), - ("EPBClosed", "EPBStatus", 0), - ("CruiseMainOn", "ECMEngineStatus", 0), - ("CruiseState", "AcceleratorPedal2", 0), - ] +from opendbc.can.can_define import CANDefine +from opendbc.can.parser import CANParser +from selfdrive.car.interfaces import CarStateBase +from selfdrive.car.gm.values import DBC, CAR, AccState, CanBus, \ + CruiseButtons, STEER_THRESHOLD - return CANParser(DBC[CP.carFingerprint]['pt'], signals, [], canbus.powertrain) - -class CarState(object): - def __init__(self, CP, canbus): - self.CP = CP - # initialize can parser - - self.car_fingerprint = CP.carFingerprint - self.cruise_buttons = CruiseButtons.UNPRESS - self.left_blinker_on = False - self.prev_left_blinker_on = False - self.right_blinker_on = False - self.prev_right_blinker_on = False - - # vEgo kalman filter - dt = 0.01 - self.v_ego_kf = KF1D(x0=[[0.], [0.]], - A=[[1., dt], [0., 1.]], - C=[1., 0.], - K=[[0.12287673], [0.29666309]]) - self.v_ego = 0. +class CarState(CarStateBase): + def __init__(self, CP): + super().__init__(CP) + can_define = CANDefine(DBC[CP.carFingerprint]['pt']) + self.shifter_values = can_define.dv["ECMPRDNL"]["PRNDL"] def update(self, pt_cp): + ret = car.CarState.new_message() + self.prev_cruise_buttons = self.cruise_buttons self.cruise_buttons = pt_cp.vl["ASCMSteeringButton"]['ACCButtons'] - self.v_wheel_fl = pt_cp.vl["EBCMWheelSpdFront"]['FLWheelSpd'] * CV.KPH_TO_MS - self.v_wheel_fr = pt_cp.vl["EBCMWheelSpdFront"]['FRWheelSpd'] * CV.KPH_TO_MS - self.v_wheel_rl = pt_cp.vl["EBCMWheelSpdRear"]['RLWheelSpd'] * CV.KPH_TO_MS - self.v_wheel_rr = pt_cp.vl["EBCMWheelSpdRear"]['RRWheelSpd'] * CV.KPH_TO_MS - v_wheel = float(np.mean([self.v_wheel_fl, self.v_wheel_fr, self.v_wheel_rl, self.v_wheel_rr])) + ret.wheelSpeeds.fl = pt_cp.vl["EBCMWheelSpdFront"]['FLWheelSpd'] * CV.KPH_TO_MS + ret.wheelSpeeds.fr = pt_cp.vl["EBCMWheelSpdFront"]['FRWheelSpd'] * CV.KPH_TO_MS + ret.wheelSpeeds.rl = pt_cp.vl["EBCMWheelSpdRear"]['RLWheelSpd'] * CV.KPH_TO_MS + ret.wheelSpeeds.rr = pt_cp.vl["EBCMWheelSpdRear"]['RRWheelSpd'] * CV.KPH_TO_MS + ret.vEgoRaw = mean([ret.wheelSpeeds.fl, ret.wheelSpeeds.fr, ret.wheelSpeeds.rl, ret.wheelSpeeds.rr]) + ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) + ret.standstill = ret.vEgoRaw < 0.01 + + ret.steeringAngle = pt_cp.vl["PSCMSteeringAngle"]['SteeringWheelAngle'] + ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(pt_cp.vl["ECMPRDNL"]['PRNDL'], None)) + ret.brake = pt_cp.vl["EBCMBrakePedalPosition"]['BrakePedalPosition'] / 0xd0 + # Brake pedal's potentiometer returns near-zero reading even when pedal is not pressed. + if ret.brake < 10/0xd0: + ret.brake = 0. + + ret.gas = pt_cp.vl["AcceleratorPedal"]['AcceleratorPedal'] / 254. + ret.gasPressed = ret.gas > 1e-5 - if abs(v_wheel - self.v_ego) > 2.0: # Prevent large accelerations when car starts at non zero speed - self.v_ego_kf.x = [[v_wheel], [0.0]] + ret.steeringTorque = pt_cp.vl["PSCMStatus"]['LKADriverAppldTrq'] + ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD - self.v_ego_raw = v_wheel - v_ego_x = self.v_ego_kf.update(v_wheel) - self.v_ego = float(v_ego_x[0]) - self.a_ego = float(v_ego_x[1]) + # 1 - open, 0 - closed + ret.doorOpen = (pt_cp.vl["BCMDoorBeltStatus"]['FrontLeftDoor'] == 1 or + pt_cp.vl["BCMDoorBeltStatus"]['FrontRightDoor'] == 1 or + pt_cp.vl["BCMDoorBeltStatus"]['RearLeftDoor'] == 1 or + pt_cp.vl["BCMDoorBeltStatus"]['RearRightDoor'] == 1) - self.standstill = self.v_ego_raw < 0.01 + # 1 - latched + ret.seatbeltUnlatched = pt_cp.vl["BCMDoorBeltStatus"]['LeftSeatBelt'] == 0 + ret.leftBlinker = pt_cp.vl["BCMTurnSignals"]['TurnSignals'] == 1 + ret.rightBlinker = pt_cp.vl["BCMTurnSignals"]['TurnSignals'] == 2 - self.angle_steers = pt_cp.vl["PSCMSteeringAngle"]['SteeringWheelAngle'] - self.gear_shifter = parse_gear_shifter(pt_cp.vl["ECMPRDNL"]['PRNDL']) - self.user_brake = pt_cp.vl["EBCMBrakePedalPosition"]['BrakePedalPosition'] + self.park_brake = pt_cp.vl["EPBStatus"]['EPBClosed'] + ret.cruiseState.available = bool(pt_cp.vl["ECMEngineStatus"]['CruiseMainOn']) + ret.espDisabled = pt_cp.vl["ESPStatus"]['TractionControlOn'] != 1 + self.pcm_acc_status = pt_cp.vl["AcceleratorPedal2"]['CruiseState'] - self.pedal_gas = pt_cp.vl["AcceleratorPedal"]['AcceleratorPedal'] - self.user_gas_pressed = self.pedal_gas > 0 + ret.brakePressed = ret.brake > 1e-5 + # Regen braking is braking + if self.car_fingerprint == CAR.VOLT: + ret.brakePressed = ret.brakePressed or bool(pt_cp.vl["EBCMRegenPaddle"]['RegenPaddle']) - self.steer_torque_driver = pt_cp.vl["PSCMStatus"]['LKADriverAppldTrq'] - self.steer_override = abs(self.steer_torque_driver) > STEER_THRESHOLD + ret.cruiseState.enabled = self.pcm_acc_status != AccState.OFF + ret.cruiseState.standstill = self.pcm_acc_status == AccState.STANDSTILL # 0 - inactive, 1 - active, 2 - temporary limited, 3 - failed self.lkas_status = pt_cp.vl["PSCMStatus"]['LKATorqueDeliveredStatus'] - self.steer_not_allowed = not is_eps_status_ok(self.lkas_status, self.car_fingerprint) - - # 1 - open, 0 - closed - self.door_all_closed = (pt_cp.vl["BCMDoorBeltStatus"]['FrontLeftDoor'] == 0 and - pt_cp.vl["BCMDoorBeltStatus"]['FrontRightDoor'] == 0 and - pt_cp.vl["BCMDoorBeltStatus"]['RearLeftDoor'] == 0 and - pt_cp.vl["BCMDoorBeltStatus"]['RearRightDoor'] == 0) - - # 1 - latched - self.seatbelt = pt_cp.vl["BCMDoorBeltStatus"]['LeftSeatBelt'] == 1 - - self.steer_error = False - - self.brake_error = False - - self.prev_left_blinker_on = self.left_blinker_on - self.prev_right_blinker_on = self.right_blinker_on - self.left_blinker_on = pt_cp.vl["BCMTurnSignals"]['TurnSignals'] == 1 - self.right_blinker_on = pt_cp.vl["BCMTurnSignals"]['TurnSignals'] == 2 - - if self.car_fingerprint in SUPERCRUISE_CARS: - self.park_brake = False - self.main_on = False - self.acc_active = pt_cp.vl["ASCMActiveCruiseControlStatus"]['ACCCmdActive'] - self.esp_disabled = False - self.regen_pressed = False - self.pcm_acc_status = int(self.acc_active) - else: - self.park_brake = pt_cp.vl["EPBStatus"]['EPBClosed'] - self.main_on = pt_cp.vl["ECMEngineStatus"]['CruiseMainOn'] - self.acc_active = False - self.esp_disabled = pt_cp.vl["ESPStatus"]['TractionControlOn'] != 1 - self.pcm_acc_status = pt_cp.vl["AcceleratorPedal2"]['CruiseState'] - if self.car_fingerprint == CAR.VOLT: - self.regen_pressed = bool(pt_cp.vl["EBCMRegenPaddle"]['RegenPaddle']) - else: - self.regen_pressed = False - - # Brake pedal's potentiometer returns near-zero reading - # even when pedal is not pressed. - if self.user_brake < 10: - self.user_brake = 0 + ret.steerWarning = self.lkas_status not in [0, 1] + + return ret + + @staticmethod + def get_can_parser(CP): + # this function generates lists for signal, messages and initial values + signals = [ + # sig_name, sig_address, default + ("BrakePedalPosition", "EBCMBrakePedalPosition", 0), + ("FrontLeftDoor", "BCMDoorBeltStatus", 0), + ("FrontRightDoor", "BCMDoorBeltStatus", 0), + ("RearLeftDoor", "BCMDoorBeltStatus", 0), + ("RearRightDoor", "BCMDoorBeltStatus", 0), + ("LeftSeatBelt", "BCMDoorBeltStatus", 0), + ("RightSeatBelt", "BCMDoorBeltStatus", 0), + ("TurnSignals", "BCMTurnSignals", 0), + ("AcceleratorPedal", "AcceleratorPedal", 0), + ("CruiseState", "AcceleratorPedal2", 0), + ("ACCButtons", "ASCMSteeringButton", CruiseButtons.UNPRESS), + ("SteeringWheelAngle", "PSCMSteeringAngle", 0), + ("FLWheelSpd", "EBCMWheelSpdFront", 0), + ("FRWheelSpd", "EBCMWheelSpdFront", 0), + ("RLWheelSpd", "EBCMWheelSpdRear", 0), + ("RRWheelSpd", "EBCMWheelSpdRear", 0), + ("PRNDL", "ECMPRDNL", 0), + ("LKADriverAppldTrq", "PSCMStatus", 0), + ("LKATorqueDeliveredStatus", "PSCMStatus", 0), + ("TractionControlOn", "ESPStatus", 0), + ("EPBClosed", "EPBStatus", 0), + ("CruiseMainOn", "ECMEngineStatus", 0), + ] - # Regen braking is braking - self.brake_pressed = self.user_brake > 10 or self.regen_pressed + if CP.carFingerprint == CAR.VOLT: + signals += [ + ("RegenPaddle", "EBCMRegenPaddle", 0), + ] - self.gear_shifter_valid = self.gear_shifter == car.CarState.GearShifter.drive + return CANParser(DBC[CP.carFingerprint]['pt'], signals, [], CanBus.POWERTRAIN) diff --git a/selfdrive/car/gm/gmcan.py b/selfdrive/car/gm/gmcan.py index 6919de3bd12f26..47e6090a03a32a 100644 --- a/selfdrive/car/gm/gmcan.py +++ b/selfdrive/car/gm/gmcan.py @@ -1,3 +1,5 @@ +from selfdrive.car import make_can_msg + def create_steering_control(packer, bus, apply_steer, idx, lkas_active): values = { @@ -9,35 +11,9 @@ def create_steering_control(packer, bus, apply_steer, idx, lkas_active): return packer.make_can_msg("ASCMLKASteeringCmd", bus, values) -def create_steering_control_ct6(packer, canbus, apply_steer, v_ego, idx, enabled): - - values = { - "LKASteeringCmdActive": 1 if enabled else 0, - "LKASteeringCmd": apply_steer, - "RollingCounter": idx, - "SetMe1": 1, - "LKASVehicleSpeed": abs(v_ego * 3.6), - "LKASMode": 2 if enabled else 0, - "LKASteeringCmdChecksum": 0 # assume zero and then manually compute it - } - - dat = packer.make_can_msg("ASCMLKASteeringCmd", 0, values)[2] - # the checksum logic is weird - values['LKASteeringCmdChecksum'] = (0x2a + - sum([ord(i) for i in dat][:4]) + - values['LKASMode']) & 0x3ff - # pack again with checksum - dat = packer.make_can_msg("ASCMLKASteeringCmd", 0, values)[2] - - return [0x152, 0, dat, canbus.powertrain], \ - [0x154, 0, dat, canbus.powertrain], \ - [0x151, 0, dat, canbus.chassis], \ - [0x153, 0, dat, canbus.chassis] - - def create_adas_keepalive(bus): - dat = "\x00\x00\x00\x00\x00\x00\x00" - return [[0x409, 0, dat, bus], [0x40a, 0, dat, bus]] + dat = b"\x00\x00\x00\x00\x00\x00\x00" + return [make_can_msg(0x409, dat, bus), make_can_msg(0x40a, dat, bus)] def create_gas_regen_command(packer, bus, throttle, idx, acc_engaged, at_full_stop): values = { @@ -52,21 +28,19 @@ def create_gas_regen_command(packer, bus, throttle, idx, acc_engaged, at_full_st } dat = packer.make_can_msg("ASCMGasRegenCmd", bus, values)[2] - values["GasRegenChecksum"] = (((0xff - ord(dat[1])) & 0xff) << 16) | \ - (((0xff - ord(dat[2])) & 0xff) << 8) | \ - ((0x100 - ord(dat[3]) - idx) & 0xff) + values["GasRegenChecksum"] = (((0xff - dat[1]) & 0xff) << 16) | \ + (((0xff - dat[2]) & 0xff) << 8) | \ + ((0x100 - dat[3] - idx) & 0xff) return packer.make_can_msg("ASCMGasRegenCmd", bus, values) def create_friction_brake_command(packer, bus, apply_brake, idx, near_stop, at_full_stop): - - if apply_brake == 0: - mode = 0x1 - else: + mode = 0x1 + if apply_brake > 0: mode = 0xa - if at_full_stop: mode = 0xd + # TODO: this is to have GM bringing the car to complete stop, # but currently it conflicts with OP controls, so turned off. #elif near_stop: @@ -84,7 +58,7 @@ def create_friction_brake_command(packer, bus, apply_brake, idx, near_stop, at_f return packer.make_can_msg("EBCMFrictionBrakeCmd", bus, values) -def create_acc_dashboard_command(packer, bus, acc_engaged, target_speed_kph, lead_car_in_sight): +def create_acc_dashboard_command(packer, bus, acc_engaged, target_speed_kph, lead_car_in_sight, fcw): # Not a bit shift, dash can round up based on low 4 bits. target_speed = int(target_speed_kph * 16) & 0xfff @@ -92,10 +66,11 @@ def create_acc_dashboard_command(packer, bus, acc_engaged, target_speed_kph, lea "ACCAlwaysOne" : 1, "ACCResumeButton" : 0, "ACCSpeedSetpoint" : target_speed, - "ACCGapLevel" : 3 * acc_engaged, # 3 "far", 0 "inactive" + "ACCGapLevel" : 3 * acc_engaged, # 3 "far", 0 "inactive" "ACCCmdActive" : acc_engaged, "ACCAlwaysOne2" : 1, - "ACCLeadCar" : lead_car_in_sight + "ACCLeadCar" : lead_car_in_sight, + "FCWAlert": 0x3 if fcw else 0 } return packer.make_can_msg("ASCMActiveCruiseControlStatus", bus, values) @@ -106,13 +81,13 @@ def create_adas_time_status(bus, tt, idx): chksum = 0x1000 - dat[0] - dat[1] - dat[2] - dat[3] chksum = chksum & 0xfff dat += [0x40 + (chksum >> 8), chksum & 0xff, 0x12] - return [0xa1, 0, "".join(map(chr, dat)), bus] + return make_can_msg(0xa1, bytes(dat), bus) def create_adas_steering_status(bus, idx): dat = [idx << 6, 0xf0, 0x20, 0, 0, 0] chksum = 0x60 + sum(dat) dat += [chksum >> 8, chksum & 0xff] - return [0x306, 0, "".join(map(chr, dat)), bus] + return make_can_msg(0x306, bytes(dat), bus) def create_adas_accelerometer_speed_status(bus, speed_ms, idx): spd = int(speed_ms * 16) & 0xfff @@ -125,67 +100,26 @@ def create_adas_accelerometer_speed_status(bus, speed_ms, idx): dat = [0x08, spd >> 4, ((spd & 0xf) << 4) | (accel >> 8), accel & 0xff, 0] chksum = 0x62 + far_range_mode + (idx << 2) + dat[0] + dat[1] + dat[2] + dat[3] + dat[4] dat += [(idx << 5) + (far_range_mode << 4) + (near_range_mode << 3) + (chksum >> 8), chksum & 0xff] - return [0x308, 0, "".join(map(chr, dat)), bus] + return make_can_msg(0x308, bytes(dat), bus) -def create_adas_headlights_status(bus): - return [0x310, 0, "\x42\x04", bus] +def create_adas_headlights_status(packer, bus): + values = { + "Always42": 0x42, + "Always4": 0x4, + } + return packer.make_can_msg("ASCMHeadlight", bus, values) def create_lka_icon_command(bus, active, critical, steer): if active and steer == 1: if critical: - dat = "\x50\xc0\x14" + dat = b"\x50\xc0\x14" else: - dat = "\x50\x40\x18" + dat = b"\x50\x40\x18" elif active: if critical: - dat = "\x40\xc0\x14" + dat = b"\x40\xc0\x14" else: - dat = "\x40\x40\x18" - else: - dat = "\x00\x00\x00" - return [0x104c006c, 0, dat, bus] - -# TODO: WIP -''' -def create_friction_brake_command_ct6(packer, bus, apply_brake, idx, near_stop, at_full_stop): - - # counters loops across [0, 29, 42, 55] but checksum only considers 0, 1, 2, 3 - cntrs = [0, 29, 42, 55] - if apply_brake == 0: - mode = 0x1 + dat = b"\x40\x40\x18" else: - mode = 0xa - - if at_full_stop: - mode = 0xd - elif near_stop: - mode = 0xb - - brake = (0x1000 - apply_brake) & 0xfff - checksum = (0x10000 - (mode << 12) - brake - idx) & 0xffff - - values = { - "RollingCounter" : cntrs[idx], - "FrictionBrakeMode" : mode, - "FrictionBrakeChecksum": checksum, - "FrictionBrakeCmd" : -apply_brake - } - - dat = packer.make_can_msg("EBCMFrictionBrakeCmd", 0, values)[2] - # msg is 0x315 but we are doing the panda forwarding - return [0x314, 0, dat, 2] - -def create_gas_regen_command_ct6(bus, throttle, idx, acc_engaged, at_full_stop): - cntrs = [0, 7, 10, 13] - eng_bit = 1 if acc_engaged else 0 - gas_high = (throttle >> 8) | 0x80 - gas_low = (throttle) & 0xff - full_stop = 0x20 if at_full_stop else 0 - - chk1 = (0x100 - gas_high - 1) & 0xff - chk2 = (0x100 - gas_low - idx) & 0xff - dat = [(idx << 6) | eng_bit, 0xc2 | full_stop, gas_high, gas_low, - (1 - eng_bit) | (cntrs[idx] << 1), 0x5d - full_stop, chk1, chk2] - return [0x2cb, 0, "".join(map(chr, dat)), bus] - -''' + dat = b"\x00\x00\x00" + return make_can_msg(0x104c006c, dat, bus) diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index f5f641836f6921..2f7d8f473bfb1e 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -1,87 +1,63 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from cereal import car -from common.realtime import sec_since_boot from selfdrive.config import Conversions as CV -from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET -from selfdrive.controls.lib.vehicle_model import VehicleModel -from selfdrive.car.gm.values import DBC, CAR, STOCK_CONTROL_MSGS, \ - SUPERCRUISE_CARS, AccState -from selfdrive.car.gm.carstate import CarState, CruiseButtons, get_powertrain_can_parser -from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness - - -class CanBus(object): - def __init__(self): - self.powertrain = 0 - self.obstacle = 1 - self.chassis = 2 - self.sw_gmlan = 3 - -class CarInterface(object): - def __init__(self, CP, CarController): - self.CP = CP - - self.frame = 0 - self.gas_pressed_prev = False - self.brake_pressed_prev = False - self.acc_active_prev = 0 - - # *** init the major players *** - canbus = CanBus() - self.CS = CarState(CP, canbus) - self.VM = VehicleModel(CP) - self.pt_cp = get_powertrain_can_parser(CP, canbus) - self.ch_cp_dbc_name = DBC[CP.carFingerprint]['chassis'] - - self.CC = None - if CarController is not None: - self.CC = CarController(canbus, CP.carFingerprint) +from selfdrive.car.gm.values import CAR, CruiseButtons, \ + AccState +from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint +from selfdrive.car.interfaces import CarInterfaceBase + +ButtonType = car.CarState.ButtonEvent.Type +EventName = car.CarEvent.EventName + +class CarInterface(CarInterfaceBase): @staticmethod def compute_gb(accel, speed): return float(accel) / 4.0 @staticmethod - def calc_accel_override(a_ego, a_target, v_ego, v_target): - return 1.0 - - @staticmethod - def get_params(candidate, fingerprint, vin="", is_panda_black=False): - ret = car.CarParams.new_message() - + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "gm" - ret.carFingerprint = candidate - ret.carVin = vin - ret.isPandaBlack = is_panda_black + ret.safetyModel = car.CarParams.SafetyModel.gm + ret.enableCruise = False # stock cruise control is kept off - ret.enableCruise = False + # GM port is a community feature + # TODO: make a port that uses a car harness and it only intercepts the camera + ret.communityFeature = True # Presence of a camera on the object bus is ok. # Have to go to read_only if ASCM is online (ACC-enabled cars), # or camera is on powertrain bus (LKA cars without ACC). - ret.enableCamera = not any(x for x in STOCK_CONTROL_MSGS[candidate] if x in fingerprint) or is_panda_black + ret.enableCamera = True ret.openpilotLongitudinalControl = ret.enableCamera tire_stiffness_factor = 0.444 # not optimized yet + # Start with a baseline lateral tuning for all GM vehicles. Override tuning as needed in each model section below. + ret.minSteerSpeed = 7 * CV.MPH_TO_MS + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2], [0.00]] + ret.lateralTuning.pid.kf = 0.00004 # full torque for 20 deg at 80mph means 0.00007818594 + ret.steerRateCost = 1.0 + ret.steerActuatorDelay = 0.1 # Default delay, not measured yet + if candidate == CAR.VOLT: # supports stop and go, but initial engage must be above 18mph (which include conservatism) ret.minEnableSpeed = 18 * CV.MPH_TO_MS ret.mass = 1607. + STD_CARGO_KG - ret.safetyModel = car.CarParams.SafetyModel.gm ret.wheelbase = 2.69 ret.steerRatio = 15.7 ret.steerRatioRear = 0. - ret.centerToFront = ret.wheelbase * 0.4 # wild guess + ret.centerToFront = ret.wheelbase * 0.4 # wild guess elif candidate == CAR.MALIBU: # supports stop and go, but initial engage must be above 18mph (which include conservatism) ret.minEnableSpeed = 18 * CV.MPH_TO_MS ret.mass = 1496. + STD_CARGO_KG - ret.safetyModel = car.CarParams.SafetyModel.gm ret.wheelbase = 2.83 ret.steerRatio = 15.8 ret.steerRatioRear = 0. - ret.centerToFront = ret.wheelbase * 0.4 # wild guess + ret.centerToFront = ret.wheelbase * 0.4 # wild guess elif candidate == CAR.HOLDEN_ASTRA: ret.mass = 1363. + STD_CARGO_KG @@ -89,48 +65,33 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): # Remaining parameters copied from Volt for now ret.centerToFront = ret.wheelbase * 0.4 ret.minEnableSpeed = 18 * CV.MPH_TO_MS - ret.safetyModel = car.CarParams.SafetyModel.gm ret.steerRatio = 15.7 ret.steerRatioRear = 0. elif candidate == CAR.ACADIA: - ret.minEnableSpeed = -1. # engage speed is decided by pcm + ret.minEnableSpeed = -1. # engage speed is decided by pcm ret.mass = 4353. * CV.LB_TO_KG + STD_CARGO_KG - ret.safetyModel = car.CarParams.SafetyModel.gm ret.wheelbase = 2.86 - ret.steerRatio = 14.4 #end to end is 13.46 + ret.steerRatio = 14.4 # end to end is 13.46 ret.steerRatioRear = 0. ret.centerToFront = ret.wheelbase * 0.4 elif candidate == CAR.BUICK_REGAL: ret.minEnableSpeed = 18 * CV.MPH_TO_MS - ret.mass = 3779. * CV.LB_TO_KG + STD_CARGO_KG # (3849+3708)/2 - ret.safetyModel = car.CarParams.SafetyModel.gm - ret.wheelbase = 2.83 #111.4 inches in meters - ret.steerRatio = 14.4 # guess for tourx + ret.mass = 3779. * CV.LB_TO_KG + STD_CARGO_KG # (3849+3708)/2 + ret.wheelbase = 2.83 # 111.4 inches in meters + ret.steerRatio = 14.4 # guess for tourx ret.steerRatioRear = 0. - ret.centerToFront = ret.wheelbase * 0.4 # guess for tourx + ret.centerToFront = ret.wheelbase * 0.4 # guess for tourx elif candidate == CAR.CADILLAC_ATS: ret.minEnableSpeed = 18 * CV.MPH_TO_MS ret.mass = 1601. + STD_CARGO_KG - ret.safetyModel = car.CarParams.SafetyModel.gm ret.wheelbase = 2.78 ret.steerRatio = 15.3 ret.steerRatioRear = 0. ret.centerToFront = ret.wheelbase * 0.49 - elif candidate == CAR.CADILLAC_CT6: - # engage speed is decided by pcm - ret.minEnableSpeed = -1. - ret.mass = 4016. * CV.LB_TO_KG + STD_CARGO_KG - ret.safetyModel = car.CarParams.SafetyModel.cadillac - ret.wheelbase = 3.11 - ret.steerRatio = 14.6 # it's 16.3 without rear active steering - ret.steerRatioRear = 0. # TODO: there is RAS on this car! - ret.centerToFront = ret.wheelbase * 0.465 - - # TODO: get actual value, for now starting with reasonable value for # civic and scaling by mass and wheelbase ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) @@ -140,104 +101,33 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront, tire_stiffness_factor=tire_stiffness_factor) - # same tuning for Volt and CT6 for now - ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] - ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2], [0.00]] - ret.lateralTuning.pid.kf = 0.00004 # full torque for 20 deg at 80mph means 0.00007818594 - - ret.steerMaxBP = [0.] # m/s - ret.steerMaxV = [1.] - ret.gasMaxBP = [0.] - ret.gasMaxV = [.5] - ret.brakeMaxBP = [0.] - ret.brakeMaxV = [1.] - ret.longitudinalTuning.kpBP = [5., 35.] ret.longitudinalTuning.kpV = [2.4, 1.5] ret.longitudinalTuning.kiBP = [0.] ret.longitudinalTuning.kiV = [0.36] - ret.longitudinalTuning.deadzoneBP = [0.] - ret.longitudinalTuning.deadzoneV = [0.] - - ret.steerLimitAlert = True ret.stoppingControl = True ret.startAccel = 0.8 - ret.steerActuatorDelay = 0.1 # Default delay, not measured yet - ret.steerRateCost = 1.0 - ret.steerControlType = car.CarParams.SteerControlType.torque + ret.steerLimitTimer = 0.4 + ret.radarTimeStep = 0.0667 # GM radar runs at 15Hz instead of standard 20Hz return ret # returns a car.CarState def update(self, c, can_strings): - self.pt_cp.update_strings(int(sec_since_boot() * 1e9), can_strings) - - self.CS.update(self.pt_cp) - - # create message - ret = car.CarState.new_message() - - ret.canValid = self.pt_cp.can_valid - - # speeds - ret.vEgo = self.CS.v_ego - ret.aEgo = self.CS.a_ego - ret.vEgoRaw = self.CS.v_ego_raw - ret.yawRate = self.VM.yaw_rate(self.CS.angle_steers * CV.DEG_TO_RAD, self.CS.v_ego) - ret.standstill = self.CS.standstill - ret.wheelSpeeds.fl = self.CS.v_wheel_fl - ret.wheelSpeeds.fr = self.CS.v_wheel_fr - ret.wheelSpeeds.rl = self.CS.v_wheel_rl - ret.wheelSpeeds.rr = self.CS.v_wheel_rr - - # gas pedal information. - ret.gas = self.CS.pedal_gas / 254.0 - ret.gasPressed = self.CS.user_gas_pressed - - # brake pedal - ret.brake = self.CS.user_brake / 0xd0 - ret.brakePressed = self.CS.brake_pressed - - # steering wheel - ret.steeringAngle = self.CS.angle_steers - - # torque and user override. Driver awareness - # timer resets when the user uses the steering wheel. - ret.steeringPressed = self.CS.steer_override - ret.steeringTorque = self.CS.steer_torque_driver - - # cruise state - ret.cruiseState.available = bool(self.CS.main_on) - cruiseEnabled = self.CS.pcm_acc_status != AccState.OFF - ret.cruiseState.enabled = cruiseEnabled - ret.cruiseState.standstill = self.CS.pcm_acc_status == 4 - - ret.leftBlinker = self.CS.left_blinker_on - ret.rightBlinker = self.CS.right_blinker_on - ret.doorOpen = not self.CS.door_all_closed - ret.seatbeltUnlatched = not self.CS.seatbelt - ret.gearShifter = self.CS.gear_shifter + self.cp.update_strings(can_strings) - buttonEvents = [] + ret = self.CS.update(self.cp) - # blinkers - if self.CS.left_blinker_on != self.CS.prev_left_blinker_on: - be = car.CarState.ButtonEvent.new_message() - be.type = 'leftBlinker' - be.pressed = self.CS.left_blinker_on - buttonEvents.append(be) + ret.canValid = self.cp.can_valid + ret.steeringRateLimited = self.CC.steer_rate_limited if self.CC is not None else False - if self.CS.right_blinker_on != self.CS.prev_right_blinker_on: - be = car.CarState.ButtonEvent.new_message() - be.type = 'rightBlinker' - be.pressed = self.CS.right_blinker_on - buttonEvents.append(be) + buttonEvents = [] - if self.CS.cruise_buttons != self.CS.prev_cruise_buttons: + if self.CS.cruise_buttons != self.CS.prev_cruise_buttons and self.CS.prev_cruise_buttons != CruiseButtons.INIT: be = car.CarState.ButtonEvent.new_message() - be.type = 'unknown' + be.type = ButtonType.unknown if self.CS.cruise_buttons != CruiseButtons.UNPRESS: be.pressed = True but = self.CS.cruise_buttons @@ -245,81 +135,47 @@ def update(self, c, can_strings): be.pressed = False but = self.CS.prev_cruise_buttons if but == CruiseButtons.RES_ACCEL: - if not (cruiseEnabled and self.CS.standstill): - be.type = 'accelCruise' # Suppress resume button if we're resuming from stop so we don't adjust speed. + if not (ret.cruiseState.enabled and ret.standstill): + be.type = ButtonType.accelCruise # Suppress resume button if we're resuming from stop so we don't adjust speed. elif but == CruiseButtons.DECEL_SET: - be.type = 'decelCruise' + be.type = ButtonType.decelCruise elif but == CruiseButtons.CANCEL: - be.type = 'cancel' + be.type = ButtonType.cancel elif but == CruiseButtons.MAIN: - be.type = 'altButton3' + be.type = ButtonType.altButton3 buttonEvents.append(be) ret.buttonEvents = buttonEvents - events = [] - if self.CS.steer_error: - events.append(create_event('steerUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT])) - if self.CS.steer_not_allowed: - events.append(create_event('steerTempUnavailable', [ET.NO_ENTRY, ET.WARNING])) - if ret.doorOpen: - events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if ret.seatbeltUnlatched: - events.append(create_event('seatbeltNotLatched', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - - if self.CS.car_fingerprint in SUPERCRUISE_CARS: - if self.CS.acc_active and not self.acc_active_prev: - events.append(create_event('pcmEnable', [ET.ENABLE])) - if not self.CS.acc_active: - events.append(create_event('pcmDisable', [ET.USER_DISABLE])) - - else: - if self.CS.brake_error: - events.append(create_event('brakeUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT])) - if not self.CS.gear_shifter_valid: - events.append(create_event('wrongGear', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if self.CS.esp_disabled: - events.append(create_event('espDisabled', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if not self.CS.main_on: - events.append(create_event('wrongCarMode', [ET.NO_ENTRY, ET.USER_DISABLE])) - if self.CS.gear_shifter == 3: - events.append(create_event('reverseGear', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) - if ret.vEgo < self.CP.minEnableSpeed: - events.append(create_event('speedTooLow', [ET.NO_ENTRY])) - if self.CS.park_brake: - events.append(create_event('parkBrake', [ET.NO_ENTRY, ET.USER_DISABLE])) - # disable on pedals rising edge or when brake is pressed and speed isn't zero - if (ret.gasPressed and not self.gas_pressed_prev) or \ - (ret.brakePressed): # and (not self.brake_pressed_prev or ret.vEgo > 0.001)): - events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) - if ret.gasPressed: - events.append(create_event('pedalPressed', [ET.PRE_ENABLE])) - if ret.cruiseState.standstill: - events.append(create_event('resumeRequired', [ET.WARNING])) - if self.CS.pcm_acc_status == AccState.FAULTED: - events.append(create_event('controlsFailed', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) - - # handle button presses - for b in ret.buttonEvents: - # do enable on both accel and decel buttons - if b.type in ["accelCruise", "decelCruise"] and not b.pressed: - events.append(create_event('buttonEnable', [ET.ENABLE])) - # do disable on button down - if b.type == "cancel" and b.pressed: - events.append(create_event('buttonCancel', [ET.USER_DISABLE])) - - ret.events = events - - # update previous brake/gas pressed - self.acc_active_prev = self.CS.acc_active - self.gas_pressed_prev = ret.gasPressed - self.brake_pressed_prev = ret.brakePressed - - # cast to reader so it can't be modified - return ret.as_reader() - - # pass in a car.CarControl - # to be called @ 100hz + events = self.create_common_events(ret, pcm_enable=False) + + if ret.vEgo < self.CP.minEnableSpeed: + events.add(EventName.belowEngageSpeed) + if self.CS.park_brake: + events.add(EventName.parkBrake) + if ret.cruiseState.standstill: + events.add(EventName.resumeRequired) + if self.CS.pcm_acc_status == AccState.FAULTED: + events.add(EventName.controlsFailed) + if ret.vEgo < self.CP.minSteerSpeed: + events.add(car.CarEvent.EventName.belowSteerSpeed) + + # handle button presses + for b in ret.buttonEvents: + # do enable on both accel and decel buttons + if b.type in [ButtonType.accelCruise, ButtonType.decelCruise] and not b.pressed: + events.add(EventName.buttonEnable) + # do disable on button down + if b.type == ButtonType.cancel and b.pressed: + events.add(EventName.buttonCancel) + + ret.events = events.to_msg() + + # copy back carState packet to CS + self.CS.out = ret.as_reader() + + return self.CS.out + def apply(self, c): hud_v_cruise = c.hudControl.setSpeed if hud_v_cruise > 70: @@ -327,11 +183,11 @@ def apply(self, c): # For Openpilot, "enabled" includes pre-enable. # In GM, PCM faults out if ACC command overlaps user gas. - enabled = c.enabled and not self.CS.user_gas_pressed + enabled = c.enabled and not self.CS.out.gasPressed - can_sends = self.CC.update(enabled, self.CS, self.frame, \ + can_sends = self.CC.update(enabled, self.CS, self.frame, c.actuators, - hud_v_cruise, c.hudControl.lanesVisible, \ + hud_v_cruise, c.hudControl.lanesVisible, c.hudControl.leadVisible, c.hudControl.visualAlert) self.frame += 1 diff --git a/selfdrive/car/gm/radar_interface.py b/selfdrive/car/gm/radar_interface.py index 6788e1ce74e414..dc2c2f7b7cb055 100755 --- a/selfdrive/car/gm/radar_interface.py +++ b/selfdrive/car/gm/radar_interface.py @@ -1,12 +1,11 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +from __future__ import print_function import math -import time -import numpy as np from cereal import car -from selfdrive.can.parser import CANParser -from selfdrive.car.gm.interface import CanBus -from selfdrive.car.gm.values import DBC, CAR -from common.realtime import sec_since_boot +from opendbc.can.parser import CANParser +from selfdrive.car.gm.values import DBC, CAR, CanBus +from selfdrive.config import Conversions as CV +from selfdrive.car.interfaces import RadarInterfaceBase RADAR_HEADER_MSG = 1120 SLOT_1_MSG = RADAR_HEADER_MSG + 1 @@ -16,58 +15,49 @@ # messages that are present in DBC LAST_RADAR_MSG = RADAR_HEADER_MSG + NUM_SLOTS -def create_radar_can_parser(canbus, car_fingerprint): - - dbc_f = DBC[car_fingerprint]['radar'] - if car_fingerprint in (CAR.VOLT, CAR.MALIBU, CAR.HOLDEN_ASTRA, CAR.ACADIA, CAR.CADILLAC_ATS): - # C1A-ARS3-A by Continental - radar_targets = range(SLOT_1_MSG, SLOT_1_MSG + NUM_SLOTS) - signals = list(zip(['FLRRNumValidTargets', - 'FLRRSnsrBlckd', 'FLRRYawRtPlsblityFlt', - 'FLRRHWFltPrsntInt', 'FLRRAntTngFltPrsnt', - 'FLRRAlgnFltPrsnt', 'FLRRSnstvFltPrsntInt'] + - ['TrkRange'] * NUM_SLOTS + ['TrkRangeRate'] * NUM_SLOTS + - ['TrkRangeAccel'] * NUM_SLOTS + ['TrkAzimuth'] * NUM_SLOTS + - ['TrkWidth'] * NUM_SLOTS + ['TrkObjectID'] * NUM_SLOTS, - [RADAR_HEADER_MSG] * 7 + radar_targets * 6, - [0] * 7 + - [0.0] * NUM_SLOTS + [0.0] * NUM_SLOTS + - [0.0] * NUM_SLOTS + [0.0] * NUM_SLOTS + - [0.0] * NUM_SLOTS + [0] * NUM_SLOTS)) - - checks = [] - - return CANParser(dbc_f, signals, checks, canbus.obstacle) - else: +def create_radar_can_parser(car_fingerprint): + if car_fingerprint not in (CAR.VOLT, CAR.MALIBU, CAR.HOLDEN_ASTRA, CAR.ACADIA, CAR.CADILLAC_ATS): return None -class RadarInterface(object): + # C1A-ARS3-A by Continental + radar_targets = list(range(SLOT_1_MSG, SLOT_1_MSG + NUM_SLOTS)) + signals = list(zip(['FLRRNumValidTargets', + 'FLRRSnsrBlckd', 'FLRRYawRtPlsblityFlt', + 'FLRRHWFltPrsntInt', 'FLRRAntTngFltPrsnt', + 'FLRRAlgnFltPrsnt', 'FLRRSnstvFltPrsntInt'] + + ['TrkRange'] * NUM_SLOTS + ['TrkRangeRate'] * NUM_SLOTS + + ['TrkRangeAccel'] * NUM_SLOTS + ['TrkAzimuth'] * NUM_SLOTS + + ['TrkWidth'] * NUM_SLOTS + ['TrkObjectID'] * NUM_SLOTS, + [RADAR_HEADER_MSG] * 7 + radar_targets * 6, + [0] * 7 + + [0.0] * NUM_SLOTS + [0.0] * NUM_SLOTS + + [0.0] * NUM_SLOTS + [0.0] * NUM_SLOTS + + [0.0] * NUM_SLOTS + [0] * NUM_SLOTS)) + + checks = [] + + return CANParser(DBC[car_fingerprint]['radar'], signals, checks, CanBus.OBSTACLE) + +class RadarInterface(RadarInterfaceBase): def __init__(self, CP): - # radar - self.pts = {} + super().__init__(CP) - self.delay = 0.0 # Delay of radar - - canbus = CanBus() - print "Using %d as obstacle CAN bus ID" % canbus.obstacle - self.rcp = create_radar_can_parser(canbus, CP.carFingerprint) + self.rcp = create_radar_can_parser(CP.carFingerprint) self.trigger_msg = LAST_RADAR_MSG self.updated_messages = set() + self.radar_ts = CP.radarTimeStep def update(self, can_strings): if self.rcp is None: - time.sleep(0.05) # nothing to do - return car.RadarData.new_message() + return super().update(None) - tm = int(sec_since_boot() * 1e9) - vls = self.rcp.update_strings(tm, can_strings) + vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) if self.trigger_msg not in self.updated_messages: return None - ret = car.RadarData.new_message() header = self.rcp.vl[RADAR_HEADER_MSG] fault = header['FLRRSnsrBlckd'] or header['FLRRSnstvFltPrsntInt'] or \ @@ -101,18 +91,17 @@ def update(self, can_strings): self.pts[targetId] = car.RadarData.RadarPoint.new_message() self.pts[targetId].trackId = targetId distance = cpt['TrkRange'] - self.pts[targetId].dRel = distance # from front of car + self.pts[targetId].dRel = distance # from front of car # From driver's pov, left is positive - deg_to_rad = np.pi/180. - self.pts[targetId].yRel = math.sin(deg_to_rad * cpt['TrkAzimuth']) * distance + self.pts[targetId].yRel = math.sin(cpt['TrkAzimuth'] * CV.DEG_TO_RAD) * distance self.pts[targetId].vRel = cpt['TrkRangeRate'] self.pts[targetId].aRel = float('nan') self.pts[targetId].yvRel = float('nan') - for oldTarget in self.pts.keys(): - if not oldTarget in currentTargets: + for oldTarget in list(self.pts.keys()): + if oldTarget not in currentTargets: del self.pts[oldTarget] - ret.points = self.pts.values() + ret.points = list(self.pts.values()) self.updated_messages.clear() return ret diff --git a/selfdrive/car/gm/values.py b/selfdrive/car/gm/values.py index 1aa5a64b13f9d0..5e50e6166eaf16 100644 --- a/selfdrive/car/gm/values.py +++ b/selfdrive/car/gm/values.py @@ -1,59 +1,46 @@ +# flake8: noqa + from cereal import car from selfdrive.car import dbc_dict +Ecu = car.CarParams.Ecu class CAR: HOLDEN_ASTRA = "HOLDEN ASTRA RS-V BK 2017" VOLT = "CHEVROLET VOLT PREMIER 2017" CADILLAC_ATS = "CADILLAC ATS Premium Performance 2018" - CADILLAC_CT6 = "CADILLAC CT6 SUPERCRUISE 2018" MALIBU = "CHEVROLET MALIBU PREMIER 2017" ACADIA = "GMC ACADIA DENALI 2018" BUICK_REGAL = "BUICK REGAL ESSENCE 2018" -SUPERCRUISE_CARS = [CAR.CADILLAC_CT6] - class CruiseButtons: - UNPRESS = 1 - RES_ACCEL = 2 - DECEL_SET = 3 - MAIN = 5 - CANCEL = 6 + INIT = 0 + UNPRESS = 1 + RES_ACCEL = 2 + DECEL_SET = 3 + MAIN = 5 + CANCEL = 6 class AccState: - OFF = 0 - ACTIVE = 1 - FAULTED = 3 + OFF = 0 + ACTIVE = 1 + FAULTED = 3 STANDSTILL = 4 -def is_eps_status_ok(eps_status, car_fingerprint): - valid_eps_status = [] - if car_fingerprint in SUPERCRUISE_CARS: - valid_eps_status += [0, 1, 4, 5, 6] - else: - valid_eps_status += [0, 1] - return eps_status in valid_eps_status - -def parse_gear_shifter(can_gear): - if can_gear == 0: - return car.CarState.GearShifter.park - elif can_gear == 1: - return car.CarState.GearShifter.neutral - elif can_gear == 2: - return car.CarState.GearShifter.drive - elif can_gear == 3: - return car.CarState.GearShifter.reverse - else: - return car.CarState.GearShifter.unknown +class CanBus: + POWERTRAIN = 0 + OBSTACLE = 1 + CHASSIS = 2 + SW_GMLAN = 3 FINGERPRINTS = { # Astra BK MY17, ASCM unplugged CAR.HOLDEN_ASTRA: [{ - 190: 8, 193: 8, 197: 8, 199: 4, 201: 8, 209: 7, 211: 8, 241: 6, 249: 8, 288: 5, 298: 8, 304: 1, 309: 8, 311: 8, 313: 8, 320: 3, 328: 1, 352: 5, 381: 6, 386: 8, 388: 8, 393: 8, 398: 8, 401: 8, 413: 8, 417: 8, 419: 8, 422: 1, 426: 7, 431: 8, 442: 8, 451: 8, 452: 8, 453: 8, 455: 7, 456: 8, 458: 5, 479: 8, 481: 7, 485: 8, 489: 8, 497: 8, 499: 3, 500: 8, 501: 8, 508: 8, 528: 5, 532: 6, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 567: 5, 647: 5, 707: 8, 723: 8, 753: 5, 761: 7, 806: 1, 810: 8, 840: 5, 842: 5, 844: 8, 866: 4, 961: 8, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1009: 8, 1011: 6, 1017: 8, 1019: 3, 1020: 8, 1105: 6, 1217: 8, 1221: 5, 1225: 8, 1233: 8, 1249: 8, 1257: 6, 1259: 8, 1261: 7, 1263: 4, 1265: 8, 1267: 8, 1280: 4, 1300: 8, 1328: 4, 1417: 8, 1906: 7, 1907: 7, 1908: 7, 1912: 7, 1919: 7, + 190: 8, 193: 8, 197: 8, 199: 4, 201: 8, 209: 7, 211: 8, 241: 6, 249: 8, 288: 5, 298: 8, 304: 1, 309: 8, 311: 8, 313: 8, 320: 3, 328: 1, 352: 5, 381: 6, 384: 4, 386: 8, 388: 8, 393: 8, 398: 8, 401: 8, 413: 8, 417: 8, 419: 8, 422: 1, 426: 7, 431: 8, 442: 8, 451: 8, 452: 8, 453: 8, 455: 7, 456: 8, 458: 5, 479: 8, 481: 7, 485: 8, 489: 8, 497: 8, 499: 3, 500: 8, 501: 8, 508: 8, 528: 5, 532: 6, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 567: 5, 647: 5, 707: 8, 715: 8, 723: 8, 753: 5, 761: 7, 806: 1, 810: 8, 840: 5, 842: 5, 844: 8, 866: 4, 961: 8, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1009: 8, 1011: 6, 1017: 8, 1019: 3, 1020: 8, 1105: 6, 1217: 8, 1221: 5, 1225: 8, 1233: 8, 1249: 8, 1257: 6, 1259: 8, 1261: 7, 1263: 4, 1265: 8, 1267: 8, 1280: 4, 1300: 8, 1328: 4, 1417: 8, 1906: 7, 1907: 7, 1908: 7, 1912: 7, 1919: 7, }], CAR.VOLT: [ # Volt Premier w/ ACC 2017 { - 170: 8, 171: 8, 189: 7, 190: 6, 193: 8, 197: 8, 199: 4, 201: 8, 209: 7, 211: 2, 241: 6, 288: 5, 289: 8, 298: 8, 304: 1, 308: 4, 309: 8, 311: 8, 313: 8, 320: 3, 328: 1, 352: 5, 381: 6, 386: 8, 388: 8, 389: 2, 390: 7, 417: 7, 419: 1, 426: 7, 451: 8, 452: 8, 453: 6, 454: 8, 456: 8, 479: 3, 481: 7, 485: 8, 489: 8, 493: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 528: 4, 532: 6, 546: 7, 550: 8, 554: 3, 558: 8, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 566: 5, 567: 3, 568: 1, 573: 1, 577: 8, 647: 3, 707: 8, 711: 6, 761: 7, 810: 8, 840: 5, 842: 5, 844: 8, 866: 4, 961: 8, 969: 8, 977: 8, 979: 7, 988: 6, 989: 8, 995: 7, 1001: 8, 1005: 6, 1009: 8, 1017: 8, 1019: 2, 1020: 8, 1105: 6, 1187: 4, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1227: 4, 1233: 8, 1249: 8, 1257: 6, 1265: 8, 1267: 1, 1273: 3, 1275: 3, 1280: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1417: 8, 1601: 8, 1905: 7, 1906: 7, 1907: 7, 1910: 7, 1912: 7, 1922: 7, 1927: 7, 1928: 7, 2016: 8, 2020: 8, 2024: 8, 2028: 8 + 170: 8, 171: 8, 189: 7, 190: 6, 193: 8, 197: 8, 199: 4, 201: 8, 209: 7, 211: 2, 241: 6, 288: 5, 289: 8, 298: 8, 304: 1, 308: 4, 309: 8, 311: 8, 313: 8, 320: 3, 328: 1, 352: 5, 381: 6, 384: 4, 386: 8, 388: 8, 389: 2, 390: 7, 417: 7, 419: 1, 426: 7, 451: 8, 452: 8, 453: 6, 454: 8, 456: 8, 479: 3, 481: 7, 485: 8, 489: 8, 493: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 528: 4, 532: 6, 546: 7, 550: 8, 554: 3, 558: 8, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 566: 5, 567: 3, 568: 1, 573: 1, 577: 8, 647: 3, 707: 8, 711: 6, 715: 8, 761: 7, 810: 8, 840: 5, 842: 5, 844: 8, 866: 4, 961: 8, 969: 8, 977: 8, 979: 7, 988: 6, 989: 8, 995: 7, 1001: 8, 1005: 6, 1009: 8, 1017: 8, 1019: 2, 1020: 8, 1105: 6, 1187: 4, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1227: 4, 1233: 8, 1249: 8, 1257: 6, 1265: 8, 1267: 1, 1273: 3, 1275: 3, 1280: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1417: 8, 1601: 8, 1905: 7, 1906: 7, 1907: 7, 1910: 7, 1912: 7, 1922: 7, 1927: 7, 1928: 7, 2016: 8, 2020: 8, 2024: 8, 2028: 8 }, # Volt Premier w/ ACC 2018 { @@ -69,9 +56,6 @@ def parse_gear_shifter(can_gear): { 190: 6, 193: 8, 197: 8, 199: 4, 201: 8, 209: 7, 211: 2, 241: 6, 249: 8, 288: 5, 298: 8, 304: 1, 309: 8, 311: 8, 313: 8, 320: 3, 322: 7, 328: 1, 352: 5, 368: 3, 381: 6, 384: 4, 386: 8, 388: 8, 393: 7, 398: 8, 401: 8, 407: 7, 413: 8, 417: 7, 419: 1, 422: 4, 426: 7, 431: 8, 442: 8, 451: 8, 452: 8, 453: 6, 455: 7, 456: 8, 462: 4, 479: 3, 481: 7, 485: 8, 487: 8, 489: 8, 491: 2, 493: 8, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 510: 8, 528: 5, 532: 6, 534: 2, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 567: 5, 573: 1, 577: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 6, 707: 8, 715: 8, 717: 5, 719: 5, 723: 2, 753: 5, 761: 7, 801: 8, 804: 3, 810: 8, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 882: 8, 890: 1, 892: 2, 893: 2, 894: 1, 961: 8, 967: 4, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1005: 6, 1009: 8, 1011: 6, 1013: 3, 1017: 8, 1019: 2, 1020: 8, 1033: 7, 1034: 7, 1105: 6, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1233: 8, 1241: 3, 1249: 8, 1257: 6, 1259: 8, 1261: 7, 1263: 4, 1265: 8, 1267: 1, 1271: 8, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1417: 8, 1601: 8, 1904: 7, 1906: 7, 1907: 7, 1912: 7, 1916: 7, 1917: 7, 1918: 7, 1919: 7, 1920: 7, 1930: 7, 2016: 8, 2024: 8 }], - CAR.CADILLAC_CT6: [{ - 190: 6, 193: 8, 197: 8, 199: 4, 201: 8, 209: 7, 211: 2, 241: 6, 249: 8, 288: 5, 298: 8, 304: 1, 309: 8, 313: 8, 320: 3, 322: 7, 328: 1, 336: 1, 338: 6, 340: 6, 352: 5, 354: 5, 356: 8, 368: 3, 372: 5, 381: 8, 386: 8, 393: 7, 398: 8, 407: 7, 413: 8, 417: 7, 419: 1, 422: 4, 426: 7, 431: 8, 442: 8, 451: 8, 452: 8, 453: 6, 455: 7, 456: 8, 458: 5, 460: 5, 462: 4, 463: 3, 479: 3, 481: 7, 485: 8, 487: 8, 489: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 528: 5, 532: 6, 534: 2, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 567: 5, 569: 3, 573: 1, 577: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 6, 707: 8, 715: 8, 717: 5, 719: 5, 723: 2, 753: 5, 761: 7, 800: 6, 801: 8, 804: 3, 810: 8, 832: 8, 833: 8, 834: 8, 835: 6, 836: 5, 837: 8, 838: 8, 839: 8, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 884: 8, 961: 8, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1005: 6, 1009: 8, 1011: 6, 1013: 1, 1017: 8, 1019: 2, 1020: 8, 1105: 6, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1233: 8, 1249: 8, 1257: 6, 1259: 8, 1261: 7, 1263: 4, 1265: 8, 1267: 1, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1417: 8, 1601: 8, 1906: 7, 1907: 7, 1912: 7, 1914: 7, 1918: 7, 1919: 7, 1934: 7, 2016: 8, 2024: 8 - }], CAR.MALIBU: [ # Malibu Premier w/ ACC 2017 { @@ -86,16 +70,6 @@ def parse_gear_shifter(can_gear): STEER_THRESHOLD = 1.0 -STOCK_CONTROL_MSGS = { - CAR.HOLDEN_ASTRA: [384, 715], - CAR.VOLT: [384, 715], # 384 = "ASCMLKASteeringCmd", 715 = "ASCMGasRegenCmd" - CAR.MALIBU: [384, 715], # 384 = "ASCMLKASteeringCmd", 715 = "ASCMGasRegenCmd" - CAR.ACADIA: [384, 715], # 384 = "ASCMLKASteeringCmd", 715 = "ASCMGasRegenCmd" - CAR.CADILLAC_ATS: [384, 715], # 384 = "ASCMLKASteeringCmd", 715 = "ASCMGasRegenCmd" - CAR.BUICK_REGAL: [384, 715], # 384 = "ASCMLKASteeringCmd", 715 = "ASCMGasRegenCmd" - CAR.CADILLAC_CT6: [], # CT6 does not require ASCMs to be disconnected -} - DBC = { CAR.HOLDEN_ASTRA: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), CAR.VOLT: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), @@ -103,5 +77,4 @@ def parse_gear_shifter(can_gear): CAR.ACADIA: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), CAR.CADILLAC_ATS: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), CAR.BUICK_REGAL: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), - CAR.CADILLAC_CT6: dbc_dict('cadillac_ct6_powertrain', 'cadillac_ct6_object', chassis_dbc='cadillac_ct6_chassis'), } diff --git a/selfdrive/car/honda/.gitignore b/selfdrive/car/honda/.gitignore deleted file mode 100644 index 89fa7bc7daf83e..00000000000000 --- a/selfdrive/car/honda/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -buttons.msg -buttons.cc.msg diff --git a/selfdrive/car/honda/carcontroller.py b/selfdrive/car/honda/carcontroller.py index 8a2cad64daf2c1..b73af39a66841c 100644 --- a/selfdrive/car/honda/carcontroller.py +++ b/selfdrive/car/honda/carcontroller.py @@ -1,12 +1,14 @@ from collections import namedtuple +from cereal import car from common.realtime import DT_CTRL from selfdrive.controls.lib.drive_helpers import rate_limit -from common.numpy_fast import clip +from common.numpy_fast import clip, interp from selfdrive.car import create_gas_command from selfdrive.car.honda import hondacan -from selfdrive.car.honda.values import AH, CruiseButtons, CAR, HONDA_BOSCH -from selfdrive.can.packer import CANPacker +from selfdrive.car.honda.values import CruiseButtons, CAR, VISUAL_HUD, HONDA_BOSCH +from opendbc.can.packer import CANPacker +VisualAlert = car.CarControl.HUDControl.VisualAlert def actuator_hystereses(brake, braking, brake_steady, v_ego, car_fingerprint): # hyst params @@ -28,7 +30,7 @@ def actuator_hystereses(brake, braking, brake_steady, v_ego, car_fingerprint): brake_steady = brake + brake_hyst_gap brake = brake_steady - if (car_fingerprint in (CAR.ACURA_ILX, CAR.CRV)) and brake > 0.0: + if (car_fingerprint in (CAR.ACURA_ILX, CAR.CRV, CAR.CRV_EU)) and brake > 0.0: brake += 0.15 return brake, braking, brake_steady @@ -56,25 +58,34 @@ def process_hud_alert(hud_alert): fcw_display = 0 steer_required = 0 acc_alert = 0 - if hud_alert == AH.NONE: # no alert - pass - elif hud_alert == AH.FCW: # FCW - fcw_display = hud_alert[1] - elif hud_alert == AH.STEER: # STEER - steer_required = hud_alert[1] - else: # any other ACC alert - acc_alert = hud_alert[1] + + # priority is: FCW, steer required, all others + if hud_alert == VisualAlert.fcw: + fcw_display = VISUAL_HUD[hud_alert.raw] + elif hud_alert == VisualAlert.steerRequired: + steer_required = VISUAL_HUD[hud_alert.raw] + else: + acc_alert = VISUAL_HUD[hud_alert.raw] return fcw_display, steer_required, acc_alert HUDData = namedtuple("HUDData", - ["pcm_accel", "v_cruise", "mini_car", "car", "X4", - "lanes", "fcw", "acc_alert", "steer_required"]) - - -class CarController(object): - def __init__(self, dbc_name): + ["pcm_accel", "v_cruise", "car", + "lanes", "fcw", "acc_alert", "steer_required"]) + +class CarControllerParams(): + def __init__(self, CP): + self.BRAKE_MAX = 1024//4 + self.STEER_MAX = CP.lateralParams.torqueBP[-1] + # mirror of list (assuming first item is zero) for interp of signed request values + assert(CP.lateralParams.torqueBP[0] == 0) + assert(CP.lateralParams.torqueBP[0] == 0) + self.STEER_LOOKUP_BP = [v * -1 for v in CP.lateralParams.torqueBP][1:][::-1] + list(CP.lateralParams.torqueBP) + self.STEER_LOOKUP_V = [v * -1 for v in CP.lateralParams.torqueV][1:][::-1] + list(CP.lateralParams.torqueV) + +class CarController(): + def __init__(self, dbc_name, CP, VM): self.braking = False self.brake_steady = 0. self.brake_last = 0. @@ -83,20 +94,24 @@ def __init__(self, dbc_name): self.packer = CANPacker(dbc_name) self.new_radar_config = False - def update(self, enabled, CS, frame, actuators, \ - pcm_speed, pcm_override, pcm_cancel_cmd, pcm_accel, \ + self.params = CarControllerParams(CP) + + def update(self, enabled, CS, frame, actuators, + pcm_speed, pcm_override, pcm_cancel_cmd, pcm_accel, hud_v_cruise, hud_show_lanes, hud_show_car, hud_alert): + P = self.params + # *** apply brake hysteresis *** - brake, self.braking, self.brake_steady = actuator_hystereses(actuators.brake, self.braking, self.brake_steady, CS.v_ego, CS.CP.carFingerprint) + brake, self.braking, self.brake_steady = actuator_hystereses(actuators.brake, self.braking, self.brake_steady, CS.out.vEgo, CS.CP.carFingerprint) # *** no output if not enabled *** - if not enabled and CS.pcm_acc_status: + if not enabled and CS.out.cruiseState.enabled: # send pcm acc cancel cmd if drive is disabled but pcm is still on, or if the system can't be activated pcm_cancel_cmd = True # *** rate limit after the enable check *** - self.brake_last = rate_limit(brake, self.brake_last, -2., 1./100) + self.brake_last = rate_limit(brake, self.brake_last, -2., DT_CTRL) # vehicle hud display, wait for one update from 10Hz 0x304 msg if hud_show_lanes: @@ -114,72 +129,57 @@ def update(self, enabled, CS, frame, actuators, \ fcw_display, steer_required, acc_alert = process_hud_alert(hud_alert) - hud = HUDData(int(pcm_accel), int(round(hud_v_cruise)), 1, hud_car, - 0xc1, hud_lanes, fcw_display, acc_alert, steer_required) + hud = HUDData(int(pcm_accel), int(round(hud_v_cruise)), hud_car, + hud_lanes, fcw_display, acc_alert, steer_required) # **** process the car messages **** - # *** compute control surfaces *** - BRAKE_MAX = 1024//4 - if CS.CP.carFingerprint in (CAR.ACURA_ILX): - STEER_MAX = 0xF00 - elif CS.CP.carFingerprint in (CAR.CRV, CAR.ACURA_RDX): - STEER_MAX = 0x3e8 # CR-V only uses 12-bits and requires a lower value (max value from energee) - else: - STEER_MAX = 0x1000 - - # gas and brake - apply_accel = actuators.gas - actuators.brake - apply_accel, self.accel_steady = accel_hysteresis(apply_accel, self.accel_steady, enabled) - apply_accel = clip(apply_accel * ACCEL_SCALE, ACCEL_MIN, ACCEL_MAX) - # steer torque is converted back to CAN reference (positive when steering right) - apply_gas = clip(actuators.gas, 0., 1.) - apply_brake = int(clip(self.brake_last * BRAKE_MAX, 0, BRAKE_MAX - 1)) - apply_steer = int(clip(-actuators.steer * STEER_MAX, -STEER_MAX, STEER_MAX)) + apply_steer = int(interp(-actuators.steer * P.STEER_MAX, P.STEER_LOOKUP_BP, P.STEER_LOOKUP_V)) lkas_active = enabled and not CS.steer_not_allowed # Send CAN commands. can_sends = [] - self.radarVin_idx = 0 - - #if using radar, we need to send the VIN - if CS.useTeslaRadar and (frame % 100 == 0): - can_sends.append(hondacan.create_radar_VIN_msg(self.radarVin_idx,CS.radarVIN,2,0x1d6,CS.useTeslaRadar)) - self.radarVin_idx += 1 - self.radarVin_idx = self.radarVin_idx % 3 # Send steering command. idx = frame % 4 can_sends.append(hondacan.create_steering_control(self.packer, apply_steer, - lkas_active, CS.CP.carFingerprint, idx, CS.CP.isPandaBlack)) + lkas_active, CS.CP.carFingerprint, idx, CS.CP.openpilotLongitudinalControl)) # Send dashboard UI commands. if (frame % 10) == 0: idx = (frame//10) % 4 - can_sends.extend(hondacan.create_ui_commands(self.packer, pcm_speed, hud, CS.CP.carFingerprint, CS.is_metric, idx, CS.CP.isPandaBlack)) + can_sends.extend(hondacan.create_ui_commands(self.packer, pcm_speed, hud, CS.CP.carFingerprint, CS.is_metric, idx, CS.CP.openpilotLongitudinalControl, CS.stock_hud)) if not CS.CP.openpilotLongitudinalControl: + if (frame % 2) == 0: + idx = frame // 2 + can_sends.append(hondacan.create_bosch_supplemental_1(self.packer, CS.CP.carFingerprint, idx)) # If using stock ACC, spam cancel command to kill gas when OP disengages. if pcm_cancel_cmd: - can_sends.append(hondacan.spam_buttons_command(self.packer, CruiseButtons.CANCEL, idx, CS.CP.carFingerprint, CS.CP.isPandaBlack)) - elif CS.stopped: - can_sends.append(hondacan.spam_buttons_command(self.packer, CruiseButtons.RES_ACCEL, idx, CS.CP.carFingerprint, CS.CP.isPandaBlack)) + can_sends.append(hondacan.spam_buttons_command(self.packer, CruiseButtons.CANCEL, idx, CS.CP.carFingerprint)) + elif CS.out.cruiseState.standstill: + can_sends.append(hondacan.spam_buttons_command(self.packer, CruiseButtons.RES_ACCEL, idx, CS.CP.carFingerprint)) else: # Send gas and brake commands. if (frame % 2) == 0: idx = frame // 2 ts = frame * DT_CTRL - pump_on, self.last_pump_ts = brake_pump_hysteresis(apply_brake, self.apply_brake_last, self.last_pump_ts, ts) - can_sends.append(hondacan.create_brake_command(self.packer, apply_brake, pump_on, - pcm_override, pcm_cancel_cmd, hud.fcw, idx, CS.CP.carFingerprint, CS.CP.isPandaBlack)) - self.apply_brake_last = apply_brake - - if CS.CP.enableGasInterceptor: - # send exactly zero if apply_gas is zero. Interceptor will send the max between read value and apply_gas. - # This prevents unexpected pedal range rescaling - can_sends.append(create_gas_command(self.packer, apply_gas, idx)) + if CS.CP.carFingerprint in HONDA_BOSCH: + pass # TODO: implement + else: + apply_gas = clip(actuators.gas, 0., 1.) + apply_brake = int(clip(self.brake_last * P.BRAKE_MAX, 0, P.BRAKE_MAX - 1)) + pump_on, self.last_pump_ts = brake_pump_hysteresis(apply_brake, self.apply_brake_last, self.last_pump_ts, ts) + can_sends.append(hondacan.create_brake_command(self.packer, apply_brake, pump_on, + pcm_override, pcm_cancel_cmd, hud.fcw, idx, CS.CP.carFingerprint, CS.stock_brake)) + self.apply_brake_last = apply_brake + + if CS.CP.enableGasInterceptor: + # send exactly zero if apply_gas is zero. Interceptor will send the max between read value and apply_gas. + # This prevents unexpected pedal range rescaling + can_sends.append(create_gas_command(self.packer, apply_gas, idx)) return can_sends diff --git a/selfdrive/car/honda/carstate.py b/selfdrive/car/honda/carstate.py index 7f04dbc1902a8d..16d85892a621b6 100644 --- a/selfdrive/car/honda/carstate.py +++ b/selfdrive/car/honda/carstate.py @@ -1,20 +1,11 @@ +from cereal import car +from collections import defaultdict from common.numpy_fast import interp -from common.kalman.simple_kalman import KF1D -from selfdrive.can.can_define import CANDefine -from selfdrive.can.parser import CANParser +from opendbc.can.can_define import CANDefine +from opendbc.can.parser import CANParser from selfdrive.config import Conversions as CV +from selfdrive.car.interfaces import CarStateBase from selfdrive.car.honda.values import CAR, DBC, STEER_THRESHOLD, SPEED_FACTOR, HONDA_BOSCH -from selfdrive.car.honda.readconfig import read_config_file - -def parse_gear_shifter(gear, vals): - - val_to_capnp = {'P': 'park', 'R': 'reverse', 'N': 'neutral', - 'D': 'drive', 'S': 'sport', 'L': 'low'} - try: - return val_to_capnp[vals[gear]] - except KeyError: - return "unknown" - def calc_cruise_offset(offset, speed): # euristic formula so that speed is controlled to ~ 0.3m/s below pid_speed @@ -29,7 +20,7 @@ def calc_cruise_offset(offset, speed): def get_can_signals(CP): -# this function generates lists for signal, messages and initial values + # this function generates lists for signal, messages and initial values signals = [ ("XMISSION_SPEED", "ENGINE_DATA", 0), ("WHEEL_SPEED_FL", "WHEEL_SPEEDS", 0), @@ -38,8 +29,8 @@ def get_can_signals(CP): ("WHEEL_SPEED_RR", "WHEEL_SPEEDS", 0), ("STEER_ANGLE", "STEERING_SENSORS", 0), ("STEER_ANGLE_RATE", "STEERING_SENSORS", 0), + ("MOTOR_TORQUE", "STEER_MOTOR_TORQUE", 0), ("STEER_TORQUE_SENSOR", "STEER_STATUS", 0), - ("STEER_TORQUE_MOTOR", "STEER_STATUS", 0), ("LEFT_BLINKER", "SCM_FEEDBACK", 0), ("RIGHT_BLINKER", "SCM_FEEDBACK", 0), ("GEAR", "GEARBOX", 0), @@ -62,18 +53,35 @@ def get_can_signals(CP): ("ENGINE_DATA", 100), ("WHEEL_SPEEDS", 50), ("STEERING_SENSORS", 100), - ("SCM_FEEDBACK", 10), - ("GEARBOX", 100), ("SEATBELT_STATUS", 10), ("CRUISE", 10), ("POWERTRAIN_DATA", 100), ("VSA_STATUS", 50), - ("SCM_BUTTONS", 25), ] + if CP.carFingerprint == CAR.ODYSSEY_CHN: + checks += [ + ("SCM_FEEDBACK", 25), + ("SCM_BUTTONS", 50), + ] + else: + checks += [ + ("SCM_FEEDBACK", 10), + ("SCM_BUTTONS", 25), + ] + + if CP.carFingerprint in (CAR.CRV_HYBRID, CAR.CIVIC_BOSCH_DIESEL, CAR.ACURA_RDX_3G): + checks += [ + ("GEARBOX", 50), + ] + else: + checks += [ + ("GEARBOX", 100), + ] + if CP.carFingerprint in HONDA_BOSCH: # Civic is only bosch to use the same brake message as other hondas. - if CP.carFingerprint not in (CAR.ACCORDH, CAR.CIVIC_BOSCH): + if CP.carFingerprint not in (CAR.ACCORDH, CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL, CAR.CRV_HYBRID, CAR.INSIGHT): signals += [("BRAKE_PRESSED", "BRAKE_MODULE", 0)] checks += [("BRAKE_MODULE", 50)] signals += [("CAR_GAS", "GAS_PEDAL_2", 0), @@ -82,23 +90,29 @@ def get_can_signals(CP): ("EPB_STATE", "EPB_STATUS", 0), ("CRUISE_SPEED", "ACC_HUD", 0)] checks += [("GAS_PEDAL_2", 100)] - - # TODO: why were these removed from bosch? - signals += [("BRAKE_ERROR_1", "STANDSTILL", 1), - ("BRAKE_ERROR_2", "STANDSTILL", 1)] - checks += [("STANDSTILL", 50)] - + if CP.openpilotLongitudinalControl: + signals += [("BRAKE_ERROR_1", "STANDSTILL", 1), + ("BRAKE_ERROR_2", "STANDSTILL", 1)] + checks += [("STANDSTILL", 50)] else: # Nidec signals. signals += [("BRAKE_ERROR_1", "STANDSTILL", 1), ("BRAKE_ERROR_2", "STANDSTILL", 1), ("CRUISE_SPEED_PCM", "CRUISE", 0), ("CRUISE_SPEED_OFFSET", "CRUISE_PARAMS", 0)] - checks += [("CRUISE_PARAMS", 50), - ("STANDSTILL", 50)] + checks += [("STANDSTILL", 50)] - if CP.carFingerprint in (CAR.ACCORD, CAR.ACCORD_15, CAR.ACCORDH, CAR.CIVIC_BOSCH): + if CP.carFingerprint == CAR.ODYSSEY_CHN: + checks += [("CRUISE_PARAMS", 10)] + else: + checks += [("CRUISE_PARAMS", 50)] + if CP.carFingerprint in (CAR.ACCORD, CAR.ACCORD_15, CAR.ACCORDH, CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL, CAR.CRV_HYBRID, CAR.INSIGHT, CAR.ACURA_RDX_3G): signals += [("DRIVERS_DOOR_OPEN", "SCM_FEEDBACK", 1)] + elif CP.carFingerprint == CAR.ODYSSEY_CHN: + signals += [("DRIVERS_DOOR_OPEN", "SCM_BUTTONS", 1)] + elif CP.carFingerprint == CAR.HRV: + signals += [("DRIVERS_DOOR_OPEN", "SCM_BUTTONS", 1), + ("WHEELS_MOVING", "STANDSTILL", 1)] else: signals += [("DOOR_OPEN_FL", "DOORS_STATUS", 1), ("DOOR_OPEN_FR", "DOORS_STATUS", 1), @@ -115,8 +129,17 @@ def get_can_signals(CP): elif CP.carFingerprint == CAR.ACURA_ILX: signals += [("CAR_GAS", "GAS_PEDAL_2", 0), ("MAIN_ON", "SCM_BUTTONS", 0)] - elif CP.carFingerprint in (CAR.CRV, CAR.ACURA_RDX, CAR.PILOT_2019, CAR.RIDGELINE): + elif CP.carFingerprint in (CAR.CRV, CAR.CRV_EU, CAR.ACURA_RDX, CAR.PILOT_2019, CAR.RIDGELINE): signals += [("MAIN_ON", "SCM_BUTTONS", 0)] + elif CP.carFingerprint == CAR.FIT: + signals += [("CAR_GAS", "GAS_PEDAL_2", 0), + ("MAIN_ON", "SCM_BUTTONS", 0), + ("BRAKE_HOLD_ACTIVE", "VSA_STATUS", 0)] + elif CP.carFingerprint == CAR.HRV: + signals += [("CAR_GAS", "GAS_PEDAL", 0), + ("MAIN_ON", "SCM_BUTTONS", 0), + ("BRAKE_HOLD_ACTIVE", "VSA_STATUS", 0)] + elif CP.carFingerprint == CAR.ODYSSEY: signals += [("MAIN_ON", "SCM_FEEDBACK", 0), ("EPB_STATE", "EPB_STATUS", 0)] @@ -124,6 +147,10 @@ def get_can_signals(CP): elif CP.carFingerprint == CAR.PILOT: signals += [("MAIN_ON", "SCM_BUTTONS", 0), ("CAR_GAS", "GAS_PEDAL_2", 0)] + elif CP.carFingerprint == CAR.ODYSSEY_CHN: + signals += [("MAIN_ON", "SCM_BUTTONS", 0), + ("EPB_STATE", "EPB_STATUS", 0)] + checks += [("EPB_STATUS", 50)] # add gas interceptor reading if we are using it if CP.enableGasInterceptor: @@ -134,64 +161,22 @@ def get_can_signals(CP): return signals, checks -def get_can_parser(CP): - signals, checks = get_can_signals(CP) - bus_pt = 1 if CP.isPandaBlack and CP.carFingerprint in HONDA_BOSCH else 0 - return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, bus_pt) - - -def get_cam_can_parser(CP): - signals = [] - - # all hondas except CRV and RDX use 0xe4 for steering - checks = [(0xe4, 100)] - if CP.carFingerprint in [CAR.CRV, CAR.ACURA_RDX]: - checks = [(0x194, 100)] - - bus_cam = 1 if CP.carFingerprint in HONDA_BOSCH and not CP.isPandaBlack else 2 - return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, bus_cam) - -class CarState(object): +class CarState(CarStateBase): def __init__(self, CP): - self.CP = CP - self.can_define = CANDefine(DBC[CP.carFingerprint]['pt']) - self.shifter_values = self.can_define.dv["GEARBOX"]["GEAR_SHIFTER"] + super().__init__(CP) + can_define = CANDefine(DBC[CP.carFingerprint]['pt']) + self.shifter_values = can_define.dv["GEARBOX"]["GEAR_SHIFTER"] + self.steer_status_values = defaultdict(lambda: "UNKNOWN", can_define.dv["STEER_STATUS"]["STEER_STATUS"]) self.user_gas, self.user_gas_pressed = 0., 0 self.brake_switch_prev = 0 self.brake_switch_ts = 0 - - self.cruise_buttons = 0 self.cruise_setting = 0 self.v_cruise_pcm_prev = 0 - self.blinker_on = 0 - - self.left_blinker_on = 0 - self.right_blinker_on = 0 - self.cruise_mode = 0 - self.stopped = 0 - - ### START OF MAIN CONFIG OPTIONS ### - ### Do NOT modify here, modify in /data/honda_openpilot.cfg and reboot - self.useTeslaRadar = False - self.radarVIN = " " - self.radarOffset = 0 - #read config file - read_config_file(self) - ### END OF MAIN CONFIG OPTIONS ### - - # vEgo kalman filter - dt = 0.01 - # Q = np.matrix([[10.0, 0.0], [0.0, 100.0]]) - # R = 1e3 - self.v_ego_kf = KF1D(x0=[[0.0], [0.0]], - A=[[1.0, dt], [0.0, 1.0]], - C=[1.0, 0.0], - K=[[0.12287673], [0.29666309]]) - self.v_ego = 0.0 - - def update(self, cp, cp_cam): + + def update(self, cp, cp_cam, cp_body): + ret = car.CarState.new_message() # car params v_weight_v = [0., 1.] # don't trust smooth speed at low values to avoid premature zero snapping @@ -200,147 +185,194 @@ def update(self, cp, cp_cam): # update prevs, update must run once per loop self.prev_cruise_buttons = self.cruise_buttons self.prev_cruise_setting = self.cruise_setting - self.prev_blinker_on = self.blinker_on - - self.prev_left_blinker_on = self.left_blinker_on - self.prev_right_blinker_on = self.right_blinker_on # ******************* parse out can ******************* - - if self.CP.carFingerprint in (CAR.ACCORD, CAR.ACCORD_15, CAR.ACCORDH, CAR.CIVIC_BOSCH): # TODO: find wheels moving bit in dbc - self.standstill = cp.vl["ENGINE_DATA"]['XMISSION_SPEED'] < 0.1 - self.door_all_closed = not cp.vl["SCM_FEEDBACK"]['DRIVERS_DOOR_OPEN'] + # TODO: find wheels moving bit in dbc + if self.CP.carFingerprint in (CAR.ACCORD, CAR.ACCORD_15, CAR.ACCORDH, CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL, CAR.CRV_HYBRID, CAR.INSIGHT, CAR.ACURA_RDX_3G): + ret.standstill = cp.vl["ENGINE_DATA"]['XMISSION_SPEED'] < 0.1 + ret.doorOpen = bool(cp.vl["SCM_FEEDBACK"]['DRIVERS_DOOR_OPEN']) + elif self.CP.carFingerprint == CAR.ODYSSEY_CHN: + ret.standstill = cp.vl["ENGINE_DATA"]['XMISSION_SPEED'] < 0.1 + ret.doorOpen = bool(cp.vl["SCM_BUTTONS"]['DRIVERS_DOOR_OPEN']) + elif self.CP.carFingerprint == CAR.HRV: + ret.doorOpen = bool(cp.vl["SCM_BUTTONS"]['DRIVERS_DOOR_OPEN']) else: - self.standstill = not cp.vl["STANDSTILL"]['WHEELS_MOVING'] - self.door_all_closed = not any([cp.vl["DOORS_STATUS"]['DOOR_OPEN_FL'], cp.vl["DOORS_STATUS"]['DOOR_OPEN_FR'], - cp.vl["DOORS_STATUS"]['DOOR_OPEN_RL'], cp.vl["DOORS_STATUS"]['DOOR_OPEN_RR']]) - self.seatbelt = not cp.vl["SEATBELT_STATUS"]['SEATBELT_DRIVER_LAMP'] and cp.vl["SEATBELT_STATUS"]['SEATBELT_DRIVER_LATCHED'] - - # 2 = temporary; 3 = TBD; 4 = temporary, hit a bump; 5 = (permanent); 6 = temporary; 7 = (permanent) - # TODO: Use values from DBC to parse this field - self.steer_error = cp.vl["STEER_STATUS"]['STEER_STATUS'] not in [0, 2, 3, 4, 6] - self.steer_not_allowed = cp.vl["STEER_STATUS"]['STEER_STATUS'] != 0 - self.steer_warning = cp.vl["STEER_STATUS"]['STEER_STATUS'] not in [0, 3] # 3 is low speed lockout, not worth a warning + ret.standstill = not cp.vl["STANDSTILL"]['WHEELS_MOVING'] + ret.doorOpen = any([cp.vl["DOORS_STATUS"]['DOOR_OPEN_FL'], cp.vl["DOORS_STATUS"]['DOOR_OPEN_FR'], + cp.vl["DOORS_STATUS"]['DOOR_OPEN_RL'], cp.vl["DOORS_STATUS"]['DOOR_OPEN_RR']]) + ret.seatbeltUnlatched = bool(cp.vl["SEATBELT_STATUS"]['SEATBELT_DRIVER_LAMP'] or not cp.vl["SEATBELT_STATUS"]['SEATBELT_DRIVER_LATCHED']) + + steer_status = self.steer_status_values[cp.vl["STEER_STATUS"]['STEER_STATUS']] + ret.steerError = steer_status not in ['NORMAL', 'NO_TORQUE_ALERT_1', 'NO_TORQUE_ALERT_2', 'LOW_SPEED_LOCKOUT', 'TMP_FAULT'] + # NO_TORQUE_ALERT_2 can be caused by bump OR steering nudge from driver + self.steer_not_allowed = steer_status not in ['NORMAL', 'NO_TORQUE_ALERT_2'] + # LOW_SPEED_LOCKOUT is not worth a warning + ret.steerWarning = steer_status not in ['NORMAL', 'LOW_SPEED_LOCKOUT', 'NO_TORQUE_ALERT_2'] + if not self.CP.openpilotLongitudinalControl: self.brake_error = 0 else: self.brake_error = cp.vl["STANDSTILL"]['BRAKE_ERROR_1'] or cp.vl["STANDSTILL"]['BRAKE_ERROR_2'] - self.esp_disabled = cp.vl["VSA_STATUS"]['ESP_DISABLED'] + ret.espDisabled = cp.vl["VSA_STATUS"]['ESP_DISABLED'] != 0 - # calc best v_ego estimate, by averaging two opposite corners speed_factor = SPEED_FACTOR[self.CP.carFingerprint] - self.v_wheel_fl = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_FL'] * CV.KPH_TO_MS * speed_factor - self.v_wheel_fr = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_FR'] * CV.KPH_TO_MS * speed_factor - self.v_wheel_rl = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_RL'] * CV.KPH_TO_MS * speed_factor - self.v_wheel_rr = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_RR'] * CV.KPH_TO_MS * speed_factor - v_wheel = (self.v_wheel_fl + self.v_wheel_fr + self.v_wheel_rl + self.v_wheel_rr)/4. + ret.wheelSpeeds.fl = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_FL'] * CV.KPH_TO_MS * speed_factor + ret.wheelSpeeds.fr = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_FR'] * CV.KPH_TO_MS * speed_factor + ret.wheelSpeeds.rl = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_RL'] * CV.KPH_TO_MS * speed_factor + ret.wheelSpeeds.rr = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_RR'] * CV.KPH_TO_MS * speed_factor + v_wheel = (ret.wheelSpeeds.fl + ret.wheelSpeeds.fr + ret.wheelSpeeds.rl + ret.wheelSpeeds.rr)/4. # blend in transmission speed at low speed, since it has more low speed accuracy - self.v_weight = interp(v_wheel, v_weight_bp, v_weight_v) - speed = (1. - self.v_weight) * cp.vl["ENGINE_DATA"]['XMISSION_SPEED'] * CV.KPH_TO_MS * speed_factor + \ - self.v_weight * v_wheel + v_weight = interp(v_wheel, v_weight_bp, v_weight_v) + ret.vEgoRaw = (1. - v_weight) * cp.vl["ENGINE_DATA"]['XMISSION_SPEED'] * CV.KPH_TO_MS * speed_factor + v_weight * v_wheel + ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) - if abs(speed - self.v_ego) > 2.0: # Prevent large accelerations when car starts at non zero speed - self.v_ego_kf.x = [[speed], [0.0]] - - self.v_ego_raw = speed - v_ego_x = self.v_ego_kf.update(speed) - self.v_ego = float(v_ego_x[0]) - self.a_ego = float(v_ego_x[1]) - - # this is a hack for the interceptor. This is now only used in the simulation - # TODO: Replace tests by toyota so this can go away - if self.CP.enableGasInterceptor: - self.user_gas = (cp.vl["GAS_SENSOR"]['INTERCEPTOR_GAS'] + cp.vl["GAS_SENSOR"]['INTERCEPTOR_GAS2']) / 2. - self.user_gas_pressed = self.user_gas > 0 # this works because interceptor read < 0 when pedal position is 0. Once calibrated, this will change - - self.gear = 0 if self.CP.carFingerprint == CAR.CIVIC else cp.vl["GEARBOX"]['GEAR'] - self.angle_steers = cp.vl["STEERING_SENSORS"]['STEER_ANGLE'] - self.angle_steers_rate = cp.vl["STEERING_SENSORS"]['STEER_ANGLE_RATE'] + ret.steeringAngle = cp.vl["STEERING_SENSORS"]['STEER_ANGLE'] + ret.steeringRate = cp.vl["STEERING_SENSORS"]['STEER_ANGLE_RATE'] self.cruise_setting = cp.vl["SCM_BUTTONS"]['CRUISE_SETTING'] self.cruise_buttons = cp.vl["SCM_BUTTONS"]['CRUISE_BUTTONS'] - self.blinker_on = cp.vl["SCM_FEEDBACK"]['LEFT_BLINKER'] or cp.vl["SCM_FEEDBACK"]['RIGHT_BLINKER'] - self.left_blinker_on = cp.vl["SCM_FEEDBACK"]['LEFT_BLINKER'] - self.right_blinker_on = cp.vl["SCM_FEEDBACK"]['RIGHT_BLINKER'] + ret.leftBlinker = cp.vl["SCM_FEEDBACK"]['LEFT_BLINKER'] != 0 + ret.rightBlinker = cp.vl["SCM_FEEDBACK"]['RIGHT_BLINKER'] != 0 self.brake_hold = cp.vl["VSA_STATUS"]['BRAKE_HOLD_ACTIVE'] - if self.CP.carFingerprint in (CAR.CIVIC, CAR.ODYSSEY, CAR.CRV_5G, CAR.ACCORD, CAR.ACCORD_15, CAR.ACCORDH, CAR.CIVIC_BOSCH): + if self.CP.carFingerprint in (CAR.CIVIC, CAR.ODYSSEY, CAR.CRV_5G, CAR.ACCORD, CAR.ACCORD_15, CAR.ACCORDH, CAR.CIVIC_BOSCH, + CAR.CIVIC_BOSCH_DIESEL, CAR.CRV_HYBRID, CAR.INSIGHT, CAR.ACURA_RDX_3G): self.park_brake = cp.vl["EPB_STATUS"]['EPB_STATE'] != 0 - self.main_on = cp.vl["SCM_FEEDBACK"]['MAIN_ON'] + main_on = cp.vl["SCM_FEEDBACK"]['MAIN_ON'] + elif self.CP.carFingerprint == CAR.ODYSSEY_CHN: + self.park_brake = cp.vl["EPB_STATUS"]['EPB_STATE'] != 0 + main_on = cp.vl["SCM_BUTTONS"]['MAIN_ON'] else: self.park_brake = 0 # TODO - self.main_on = cp.vl["SCM_BUTTONS"]['MAIN_ON'] + main_on = cp.vl["SCM_BUTTONS"]['MAIN_ON'] - can_gear_shifter = int(cp.vl["GEARBOX"]['GEAR_SHIFTER']) - self.gear_shifter = parse_gear_shifter(can_gear_shifter, self.shifter_values) + gear = int(cp.vl["GEARBOX"]['GEAR_SHIFTER']) + ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(gear, None)) self.pedal_gas = cp.vl["POWERTRAIN_DATA"]['PEDAL_GAS'] # crv doesn't include cruise control - if self.CP.carFingerprint in (CAR.CRV, CAR.ODYSSEY, CAR.ACURA_RDX, CAR.RIDGELINE, CAR.PILOT_2019): - self.car_gas = self.pedal_gas + if self.CP.carFingerprint in (CAR.CRV, CAR.CRV_EU, CAR.HRV, CAR.ODYSSEY, CAR.ACURA_RDX, CAR.RIDGELINE, CAR.PILOT_2019, CAR.ODYSSEY_CHN): + ret.gas = self.pedal_gas / 256. else: - self.car_gas = cp.vl["GAS_PEDAL_2"]['CAR_GAS'] + ret.gas = cp.vl["GAS_PEDAL_2"]['CAR_GAS'] / 256. - self.steer_torque_driver = cp.vl["STEER_STATUS"]['STEER_TORQUE_SENSOR'] - self.steer_torque_motor = cp.vl["STEER_STATUS"]['STEER_TORQUE_MOTOR'] - self.steer_override = abs(self.steer_torque_driver) > STEER_THRESHOLD[self.CP.carFingerprint] + # this is a hack for the interceptor. This is now only used in the simulation + # TODO: Replace tests by toyota so this can go away + if self.CP.enableGasInterceptor: + self.user_gas = (cp.vl["GAS_SENSOR"]['INTERCEPTOR_GAS'] + cp.vl["GAS_SENSOR"]['INTERCEPTOR_GAS2']) / 2. + self.user_gas_pressed = self.user_gas > 1e-5 # this works because interceptor read < 0 when pedal position is 0. Once calibrated, this will change + ret.gasPressed = self.user_gas_pressed + else: + ret.gasPressed = self.pedal_gas > 1e-5 + + ret.steeringTorque = cp.vl["STEER_STATUS"]['STEER_TORQUE_SENSOR'] + ret.steeringTorqueEps = cp.vl["STEER_MOTOR_TORQUE"]['MOTOR_TORQUE'] + ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD[self.CP.carFingerprint] - self.brake_switch = cp.vl["POWERTRAIN_DATA"]['BRAKE_SWITCH'] + self.brake_switch = cp.vl["POWERTRAIN_DATA"]['BRAKE_SWITCH'] != 0 - if self.CP.radarOffCan: + if self.CP.carFingerprint in HONDA_BOSCH: self.cruise_mode = cp.vl["ACC_HUD"]['CRUISE_CONTROL_LABEL'] - self.stopped = cp.vl["ACC_HUD"]['CRUISE_SPEED'] == 252. - self.cruise_speed_offset = calc_cruise_offset(0, self.v_ego) - if self.CP.carFingerprint in (CAR.CIVIC_BOSCH, CAR.ACCORDH): - self.brake_switch = cp.vl["POWERTRAIN_DATA"]['BRAKE_SWITCH'] - self.brake_pressed = cp.vl["POWERTRAIN_DATA"]['BRAKE_PRESSED'] or \ - (self.brake_switch and self.brake_switch_prev and \ + ret.cruiseState.standstill = cp.vl["ACC_HUD"]['CRUISE_SPEED'] == 252. + ret.cruiseState.speedOffset = calc_cruise_offset(0, ret.vEgo) + if self.CP.carFingerprint in (CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL, CAR.ACCORDH, CAR.CRV_HYBRID, CAR.INSIGHT): + ret.brakePressed = cp.vl["POWERTRAIN_DATA"]['BRAKE_PRESSED'] != 0 or \ + (self.brake_switch and self.brake_switch_prev and cp.ts["POWERTRAIN_DATA"]['BRAKE_SWITCH'] != self.brake_switch_ts) self.brake_switch_prev = self.brake_switch self.brake_switch_ts = cp.ts["POWERTRAIN_DATA"]['BRAKE_SWITCH'] else: - self.brake_switch = cp.vl["BRAKE_MODULE"]['BRAKE_PRESSED'] - self.brake_pressed = cp.vl["BRAKE_MODULE"]['BRAKE_PRESSED'] + ret.brakePressed = cp.vl["BRAKE_MODULE"]['BRAKE_PRESSED'] != 0 # On set, cruise set speed pulses between 254~255 and the set speed prev is set to avoid this. - self.v_cruise_pcm = self.v_cruise_pcm_prev if cp.vl["ACC_HUD"]['CRUISE_SPEED'] > 160.0 else cp.vl["ACC_HUD"]['CRUISE_SPEED'] - self.v_cruise_pcm_prev = self.v_cruise_pcm + ret.cruiseState.speed = self.v_cruise_pcm_prev if cp.vl["ACC_HUD"]['CRUISE_SPEED'] > 160.0 else cp.vl["ACC_HUD"]['CRUISE_SPEED'] * CV.KPH_TO_MS + self.v_cruise_pcm_prev = ret.cruiseState.speed else: - self.brake_switch = cp.vl["POWERTRAIN_DATA"]['BRAKE_SWITCH'] - self.cruise_speed_offset = calc_cruise_offset(cp.vl["CRUISE_PARAMS"]['CRUISE_SPEED_OFFSET'], self.v_ego) - self.v_cruise_pcm = cp.vl["CRUISE"]['CRUISE_SPEED_PCM'] + ret.cruiseState.speedOffset = calc_cruise_offset(cp.vl["CRUISE_PARAMS"]['CRUISE_SPEED_OFFSET'], ret.vEgo) + ret.cruiseState.speed = cp.vl["CRUISE"]['CRUISE_SPEED_PCM'] * CV.KPH_TO_MS # brake switch has shown some single time step noise, so only considered when # switch is on for at least 2 consecutive CAN samples - self.brake_pressed = cp.vl["POWERTRAIN_DATA"]['BRAKE_PRESSED'] or \ - (self.brake_switch and self.brake_switch_prev and \ - cp.ts["POWERTRAIN_DATA"]['BRAKE_SWITCH'] != self.brake_switch_ts) + ret.brakePressed = bool(cp.vl["POWERTRAIN_DATA"]['BRAKE_PRESSED'] or + (self.brake_switch and self.brake_switch_prev and + cp.ts["POWERTRAIN_DATA"]['BRAKE_SWITCH'] != self.brake_switch_ts)) self.brake_switch_prev = self.brake_switch self.brake_switch_ts = cp.ts["POWERTRAIN_DATA"]['BRAKE_SWITCH'] - self.user_brake = cp.vl["VSA_STATUS"]['USER_BRAKE'] - self.pcm_acc_status = cp.vl["POWERTRAIN_DATA"]['ACC_STATUS'] + ret.brake = cp.vl["VSA_STATUS"]['USER_BRAKE'] + ret.cruiseState.enabled = cp.vl["POWERTRAIN_DATA"]['ACC_STATUS'] != 0 + ret.cruiseState.available = bool(main_on) + ret.cruiseState.nonAdaptive = self.cruise_mode != 0 # Gets rid of Pedal Grinding noise when brake is pressed at slow speeds for some models if self.CP.carFingerprint in (CAR.PILOT, CAR.PILOT_2019, CAR.RIDGELINE): - if self.user_brake > 0.05: - self.brake_pressed = 1 + if ret.brake > 0.05: + ret.brakePressed = True # TODO: discover the CAN msg that has the imperial unit bit for all other cars self.is_metric = not cp.vl["HUD_SETTING"]['IMPERIAL_UNIT'] if self.CP.carFingerprint in (CAR.CIVIC) else False -# carstate standalone tester -if __name__ == '__main__': - import zmq - context = zmq.Context() - - class CarParams(object): - def __init__(self): - self.carFingerprint = "HONDA CIVIC 2016 TOURING" - self.enableGasInterceptor = 0 - CP = CarParams() - CS = CarState(CP) - - # while 1: - # CS.update() - # time.sleep(0.01) \ No newline at end of file + if self.CP.carFingerprint in HONDA_BOSCH: + ret.stockAeb = bool(cp_cam.vl["ACC_CONTROL"]["AEB_STATUS"] and cp_cam.vl["ACC_CONTROL"]["ACCEL_COMMAND"] < -1e-5) + else: + ret.stockAeb = bool(cp_cam.vl["BRAKE_COMMAND"]["AEB_REQ_1"] and cp_cam.vl["BRAKE_COMMAND"]["COMPUTER_BRAKE"] > 1e-5) + + if self.CP.carFingerprint in HONDA_BOSCH: + self.stock_hud = False + ret.stockFcw = False + else: + ret.stockFcw = cp_cam.vl["BRAKE_COMMAND"]["FCW"] != 0 + self.stock_hud = cp_cam.vl["ACC_HUD"] + self.stock_brake = cp_cam.vl["BRAKE_COMMAND"] + + if self.CP.carFingerprint in (CAR.CRV_5G, ): + # BSM messages are on B-CAN, requires a panda forwarding B-CAN messages to CAN 0 + # more info here: https://github.com/commaai/openpilot/pull/1867 + ret.leftBlindspot = cp_body.vl["BSM_STATUS_LEFT"]['BSM_ALERT'] == 1 + ret.rightBlindspot = cp_body.vl["BSM_STATUS_RIGHT"]['BSM_ALERT'] == 1 + + return ret + + @staticmethod + def get_can_parser(CP): + signals, checks = get_can_signals(CP) + bus_pt = 1 if CP.carFingerprint in HONDA_BOSCH else 0 + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, bus_pt) + + @staticmethod + def get_cam_can_parser(CP): + signals = [] + + if CP.carFingerprint in HONDA_BOSCH: + signals += [("ACCEL_COMMAND", "ACC_CONTROL", 0), + ("AEB_STATUS", "ACC_CONTROL", 0)] + else: + signals += [("COMPUTER_BRAKE", "BRAKE_COMMAND", 0), + ("AEB_REQ_1", "BRAKE_COMMAND", 0), + ("FCW", "BRAKE_COMMAND", 0), + ("CHIME", "BRAKE_COMMAND", 0), + ("FCM_OFF", "ACC_HUD", 0), + ("FCM_OFF_2", "ACC_HUD", 0), + ("FCM_PROBLEM", "ACC_HUD", 0), + ("ICONS", "ACC_HUD", 0)] + + # all hondas except CRV, RDX and 2019 Odyssey@China use 0xe4 for steering + checks = [(0xe4, 100)] + if CP.carFingerprint in [CAR.CRV, CAR.CRV_EU, CAR.ACURA_RDX, CAR.ODYSSEY_CHN]: + checks = [(0x194, 100)] + + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2) + + @staticmethod + def get_body_can_parser(CP): + signals = [] + checks = [] + + if CP.carFingerprint == CAR.CRV_5G: + signals += [("BSM_ALERT", "BSM_STATUS_RIGHT", 0), + ("BSM_ALERT", "BSM_STATUS_LEFT", 0)] + + bus_body = 0 # B-CAN is forwarded to ACC-CAN radar side (CAN 0 on fake ethernet port) + return CANParser(DBC[CP.carFingerprint]['body'], signals, checks, bus_body) + + return None diff --git a/selfdrive/car/honda/hondacan.py b/selfdrive/car/honda/hondacan.py index 74254ca57f917f..ef256470225a68 100644 --- a/selfdrive/car/honda/hondacan.py +++ b/selfdrive/car/honda/hondacan.py @@ -1,34 +1,25 @@ -import struct from selfdrive.config import Conversions as CV -from ctypes import create_string_buffer -from selfdrive.car.honda.values import CAR, HONDA_BOSCH +from selfdrive.car.honda.values import HONDA_BOSCH -# *** Honda specific *** -def can_cksum(mm): - s = 0 - for c in mm: - c = ord(c) - s += (c>>4) - s += c & 0xF - s = 8-s - s %= 0x10 - return s +# CAN bus layout with relay +# 0 = ACC-CAN - radar side +# 1 = F-CAN B - powertrain +# 2 = ACC-CAN - camera side +# 3 = F-CAN A - OBDII port +def get_pt_bus(car_fingerprint): + return 1 if car_fingerprint in HONDA_BOSCH else 0 -def fix(msg, addr): - msg2 = msg[0:-1] + chr(ord(msg[-1]) | can_cksum(struct.pack("I", addr)+msg)) - return msg2 +def get_lkas_cmd_bus(car_fingerprint, radar_disabled=False): + if radar_disabled: + # when radar is disabled, steering commands are sent directly to powertrain bus + return get_pt_bus(car_fingerprint) + # normally steering commands are sent to radar, which forwards them to powertrain bus + return 0 -def get_pt_bus(car_fingerprint, is_panda_black): - return 1 if car_fingerprint in HONDA_BOSCH and is_panda_black else 0 - -def get_lkas_cmd_bus(car_fingerprint, is_panda_black): - return 2 if car_fingerprint in HONDA_BOSCH and not is_panda_black else 0 - - -def create_brake_command(packer, apply_brake, pump_on, pcm_override, pcm_cancel_cmd, fcw, idx, car_fingerprint, is_panda_black): +def create_brake_command(packer, apply_brake, pump_on, pcm_override, pcm_cancel_cmd, fcw, idx, car_fingerprint, stock_brake): # TODO: do we loose pressure if we keep pump off for long? brakelights = apply_brake > 0 brake_rq = apply_brake > 0 @@ -43,43 +34,105 @@ def create_brake_command(packer, apply_brake, pump_on, pcm_override, pcm_cancel_ "COMPUTER_BRAKE_REQUEST": brake_rq, "SET_ME_1": 1, "BRAKE_LIGHTS": brakelights, - "CHIME": 0, - # TODO: Why are there two bits for fcw? According to dbc file the first bit should also work - "FCW": fcw << 1, + "CHIME": stock_brake["CHIME"] if fcw else 0, # send the chime for stock fcw + "FCW": fcw << 1, # TODO: Why are there two bits for fcw? "AEB_REQ_1": 0, "AEB_REQ_2": 0, - "AEB": 0, + "AEB_STATUS": 0, } - bus = get_pt_bus(car_fingerprint, is_panda_black) + bus = get_pt_bus(car_fingerprint) return packer.make_can_msg("BRAKE_COMMAND", bus, values, idx) -def create_steering_control(packer, apply_steer, lkas_active, car_fingerprint, idx, is_panda_black): +def create_acc_commands(packer, enabled, accel, gas, idx, stopping, starting, car_fingerprint): + commands = [] + bus = get_pt_bus(car_fingerprint) + + control_on = 5 if enabled else 0 + # no gas = -30000 + gas_command = gas if enabled and gas > 0 else -30000 + accel_command = accel if enabled else 0 + braking = 1 if enabled and accel < 0 else 0 + standstill = 1 if enabled and stopping else 0 + standstill_release = 1 if enabled and starting else 0 + + acc_control_values = { + # setting CONTROL_ON causes car to set POWERTRAIN_DATA->ACC_STATUS = 1 + "CONTROL_ON": control_on, + "GAS_COMMAND": gas_command, # used for gas + "ACCEL_COMMAND": accel_command, # used for brakes + "BRAKE_LIGHTS": braking, + "BRAKE_REQUEST": braking, + "STANDSTILL": standstill, + "STANDSTILL_RELEASE": standstill_release, + } + commands.append(packer.make_can_msg("ACC_CONTROL", bus, acc_control_values, idx)) + + acc_control_on_values = { + "SET_TO_3": 0x03, + "CONTROL_ON": enabled, + "SET_TO_FF": 0xff, + "SET_TO_75": 0x75, + "SET_TO_30": 0x30, + } + commands.append(packer.make_can_msg("ACC_CONTROL_ON", bus, acc_control_on_values, idx)) + + return commands + +def create_steering_control(packer, apply_steer, lkas_active, car_fingerprint, idx, radar_disabled): values = { "STEER_TORQUE": apply_steer if lkas_active else 0, "STEER_TORQUE_REQUEST": lkas_active, } - bus = get_lkas_cmd_bus(car_fingerprint, is_panda_black) + bus = get_lkas_cmd_bus(car_fingerprint, radar_disabled) return packer.make_can_msg("STEERING_CONTROL", bus, values, idx) -def create_ui_commands(packer, pcm_speed, hud, car_fingerprint, is_metric, idx, is_panda_black): +def create_bosch_supplemental_1(packer, car_fingerprint, idx): + # non-active params + values = { + "SET_ME_X04": 0x04, + "SET_ME_X80": 0x80, + "SET_ME_X10": 0x10, + } + bus = get_lkas_cmd_bus(car_fingerprint) + return packer.make_can_msg("BOSCH_SUPPLEMENTAL_1", bus, values, idx) + + +def create_ui_commands(packer, pcm_speed, hud, car_fingerprint, is_metric, idx, openpilot_longitudinal_control, stock_hud): commands = [] - bus_pt = get_pt_bus(car_fingerprint, is_panda_black) - bus_lkas = get_lkas_cmd_bus(car_fingerprint, is_panda_black) - - if car_fingerprint not in HONDA_BOSCH: - acc_hud_values = { - 'PCM_SPEED': pcm_speed * CV.MS_TO_KPH, - 'PCM_GAS': hud.pcm_accel, - 'CRUISE_SPEED': hud.v_cruise, - 'ENABLE_MINI_CAR': hud.mini_car, - 'HUD_LEAD': hud.car, - 'HUD_DISTANCE': 3, # max distance setting on display - 'IMPERIAL_UNIT': int(not is_metric), - 'SET_ME_X01_2': 1, - 'SET_ME_X01': 1, - } + bus_pt = get_pt_bus(car_fingerprint) + radar_disabled = car_fingerprint in HONDA_BOSCH and openpilot_longitudinal_control + bus_lkas = get_lkas_cmd_bus(car_fingerprint, radar_disabled) + + if openpilot_longitudinal_control: + if car_fingerprint in HONDA_BOSCH: + acc_hud_values = { + 'CRUISE_SPEED': hud.v_cruise, + 'ENABLE_MINI_CAR': 1, + 'SET_TO_1': 1, + 'HUD_LEAD': hud.car, + 'HUD_DISTANCE': 3, + 'ACC_ON': hud.car != 0, + 'SET_TO_X1': 1, + 'IMPERIAL_UNIT': int(not is_metric), + } + else: + acc_hud_values = { + 'PCM_SPEED': pcm_speed * CV.MS_TO_KPH, + 'PCM_GAS': hud.pcm_accel, + 'CRUISE_SPEED': hud.v_cruise, + 'ENABLE_MINI_CAR': 1, + 'HUD_LEAD': hud.car, + 'HUD_DISTANCE': 3, # max distance setting on display + 'IMPERIAL_UNIT': int(not is_metric), + 'SET_ME_X01_2': 1, + 'SET_ME_X01': 1, + "FCM_OFF": stock_hud["FCM_OFF"], + "FCM_OFF_2": stock_hud["FCM_OFF_2"], + "FCM_PROBLEM": stock_hud["FCM_PROBLEM"], + "ICONS": stock_hud["ICONS"], + } commands.append(packer.make_can_msg("ACC_HUD", bus_pt, acc_hud_values, idx)) lkas_hud_values = { @@ -91,21 +144,19 @@ def create_ui_commands(packer, pcm_speed, hud, car_fingerprint, is_metric, idx, } commands.append(packer.make_can_msg('LKAS_HUD', bus_lkas, lkas_hud_values, idx)) - if car_fingerprint in (CAR.CIVIC, CAR.ODYSSEY): + if radar_disabled and car_fingerprint in HONDA_BOSCH: radar_hud_values = { - 'ACC_ALERTS': hud.acc_alert, - 'LEAD_SPEED': 0x1fe, # What are these magic values - 'LEAD_STATE': 0x7, - 'LEAD_DISTANCE': 0x1e, + 'SET_TO_1' : 0x01, } commands.append(packer.make_can_msg('RADAR_HUD', bus_pt, radar_hud_values, idx)) + return commands -def spam_buttons_command(packer, button_val, idx, car_fingerprint, is_panda_black): +def spam_buttons_command(packer, button_val, idx, car_fingerprint): values = { 'CRUISE_BUTTONS': button_val, 'CRUISE_SETTING': 0, } - bus = get_pt_bus(car_fingerprint, is_panda_black) + bus = get_pt_bus(car_fingerprint) return packer.make_can_msg("SCM_BUTTONS", bus, values, idx) diff --git a/selfdrive/car/honda/interface.py b/selfdrive/car/honda/interface.py old mode 100644 new mode 100755 index 912f218b6e3b97..73dd2ca3988428 --- a/selfdrive/car/honda/interface.py +++ b/selfdrive/car/honda/interface.py @@ -1,20 +1,21 @@ -#!/usr/bin/env python -import os +#!/usr/bin/env python3 import numpy as np from cereal import car from common.numpy_fast import clip, interp -from common.realtime import sec_since_boot, DT_CTRL +from common.realtime import DT_CTRL from selfdrive.swaglog import cloudlog from selfdrive.config import Conversions as CV -from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET, get_events -from selfdrive.controls.lib.vehicle_model import VehicleModel -from selfdrive.car.honda.carstate import CarState, get_can_parser, get_cam_can_parser -from selfdrive.car.honda.values import CruiseButtons, CAR, HONDA_BOSCH, VISUAL_HUD, CAMERA_MSGS -from selfdrive.car import STD_CARGO_KG, CivicParams, scale_rot_inertia, scale_tire_stiffness +from selfdrive.controls.lib.events import ET +from selfdrive.car.honda.values import CruiseButtons, CAR, HONDA_BOSCH +from selfdrive.car import STD_CARGO_KG, CivicParams, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint from selfdrive.controls.lib.planner import _A_CRUISE_MAX_V_FOLLOWING +from selfdrive.car.interfaces import CarInterfaceBase A_ACC_MAX = max(_A_CRUISE_MAX_V_FOLLOWING) +ButtonType = car.CarState.ButtonEvent.Type +EventName = car.CarEvent.EventName + def compute_gb_honda(accel, speed): creep_brake = 0.0 @@ -70,38 +71,28 @@ def _compute_gb_acura(accel, speed): return _compute_gb_acura -class CarInterface(object): - def __init__(self, CP, CarController): - self.CP = CP +class CarInterface(CarInterfaceBase): + def __init__(self, CP, CarController, CarState): + super().__init__(CP, CarController, CarState) - self.frame = 0 self.last_enable_pressed = 0 self.last_enable_sent = 0 - self.gas_pressed_prev = False - self.brake_pressed_prev = False - - self.cp = get_can_parser(CP) - self.cp_cam = get_cam_can_parser(CP) - - # *** init the major players *** - self.CS = CarState(CP) - self.VM = VehicleModel(CP) - - self.CC = None - if CarController is not None: - self.CC = CarController(self.cp.dbc_name) if self.CS.CP.carFingerprint == CAR.ACURA_ILX: self.compute_gb = get_compute_gb_acura() else: self.compute_gb = compute_gb_honda + @staticmethod + def compute_gb(accel, speed): # pylint: disable=method-hidden + raise NotImplementedError + @staticmethod def calc_accel_override(a_ego, a_target, v_ego, v_target): # normalized max accel. Allowing max accel at low speed causes speed overshoots max_accel_bp = [10, 20] # m/s - max_accel_v = [0.714, 1.0] # unit of max accel + max_accel_v = [0.714, 1.0] # unit of max accel max_accel = interp(v_ego, max_accel_bp, max_accel_v) # limit the pcm accel cmd if: @@ -129,81 +120,106 @@ def calc_accel_override(a_ego, a_target, v_ego, v_target): return float(max(max_accel, a_target / A_ACC_MAX)) * min(speedLimiter, accelLimiter) @staticmethod - def get_params(candidate, fingerprint, vin="", is_panda_black=False): - - ret = car.CarParams.new_message() + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # pylint: disable=dangerous-default-value + ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "honda" - ret.carFingerprint = candidate - ret.carVin = vin - ret.isPandaBlack = is_panda_black if candidate in HONDA_BOSCH: - ret.safetyModel = car.CarParams.SafetyModel.hondaBosch + ret.safetyModel = car.CarParams.SafetyModel.hondaBoschHarness ret.enableCamera = True ret.radarOffCan = True - ret.openpilotLongitudinalControl = not any(x for x in BOSCH_RADAR_MSGS if x in fingerprint) - ret.enableCruise = not ret.openpilotLongitudinalControl + ret.openpilotLongitudinalControl = False else: - ret.safetyModel = car.CarParams.SafetyModel.honda - ret.enableCamera = not any(x for x in CAMERA_MSGS if x in fingerprint) or is_panda_black - ret.enableGasInterceptor = 0x201 in fingerprint + ret.safetyModel = car.CarParams.SafetyModel.hondaNidec + ret.enableCamera = True + ret.enableGasInterceptor = 0x201 in fingerprint[0] ret.openpilotLongitudinalControl = ret.enableCamera - ret.enableCruise = not ret.enableGasInterceptor - cloudlog.warn("ECU Camera Simulated: %r", ret.enableCamera) - cloudlog.warn("ECU Gas Interceptor: %r", ret.enableGasInterceptor) + cloudlog.warning("ECU Camera Simulated: %r", ret.enableCamera) + cloudlog.warning("ECU Gas Interceptor: %r", ret.enableGasInterceptor) ret.enableCruise = not ret.enableGasInterceptor + ret.communityFeature = ret.enableGasInterceptor - # Optimized car params: tire_stiffness_factor and steerRatio are a result of a vehicle - # model optimization process. Certain Hondas have an extra steering sensor at the bottom - # of the steering rack, which improves controls quality as it removes the steering column - # torsion from feedback. + # Certain Hondas have an extra steering sensor at the bottom of the steering rack, + # which improves controls quality as it removes the steering column torsion from feedback. # Tire stiffness factor fictitiously lower if it includes the steering column torsion effect. # For modeling details, see p.198-200 in "The Science of Vehicle Dynamics (2014), M. Guiggiani" - + ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0], [0]] ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] - ret.lateralTuning.pid.kf = 0.00006 # conservative feed-forward + ret.lateralTuning.pid.kf = 0.00006 # conservative feed-forward - if candidate in [CAR.CIVIC, CAR.CIVIC_BOSCH]: + eps_modified = False + for fw in car_fw: + if fw.ecu == "eps" and b"," in fw.fwVersion: + eps_modified = True + + if candidate == CAR.CIVIC: stop_and_go = True ret.mass = CivicParams.MASS ret.wheelbase = CivicParams.WHEELBASE ret.centerToFront = CivicParams.CENTER_TO_FRONT ret.steerRatio = 15.38 # 10.93 is end-to-end spec + if eps_modified: + # stock request input values: 0x0000, 0x00DE, 0x014D, 0x01EF, 0x0290, 0x0377, 0x0454, 0x0610, 0x06EE + # stock request output values: 0x0000, 0x0917, 0x0DC5, 0x1017, 0x119F, 0x140B, 0x1680, 0x1680, 0x1680 + # modified request output values: 0x0000, 0x0917, 0x0DC5, 0x1017, 0x119F, 0x140B, 0x1680, 0x2880, 0x3180 + # stock filter output values: 0x009F, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108 + # modified filter output values: 0x009F, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0400, 0x0480 + # note: max request allowed is 4096, but request is capped at 3840 in firmware, so modifications result in 2x max + ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 2560, 8000], [0, 2560, 3840]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.1]] + else: + ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 2560], [0, 2560]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[1.1], [0.33]] tire_stiffness_factor = 1. - # Civic at comma has modified steering FW, so different tuning for the Neo in that car - is_fw_modified = os.getenv("DONGLE_ID") in ['5b7c365c50084530'] - if is_fw_modified: - ret.lateralTuning.pid.kf = 0.00004 - ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.4], [0.12]] if is_fw_modified else [[0.8], [0.24]] ret.longitudinalTuning.kpBP = [0., 5., 35.] ret.longitudinalTuning.kpV = [3.6, 2.4, 1.5] ret.longitudinalTuning.kiBP = [0., 35.] ret.longitudinalTuning.kiV = [0.54, 0.36] + elif candidate in (CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL): + stop_and_go = True + ret.mass = CivicParams.MASS + ret.wheelbase = CivicParams.WHEELBASE + ret.centerToFront = CivicParams.CENTER_TO_FRONT + ret.steerRatio = 15.38 # 10.93 is end-to-end spec + ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end + tire_stiffness_factor = 1. + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]] + ret.longitudinalTuning.kpBP = [0., 5., 35.] + ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5] + ret.longitudinalTuning.kiBP = [0., 35.] + ret.longitudinalTuning.kiV = [0.18, 0.12] + elif candidate in (CAR.ACCORD, CAR.ACCORD_15, CAR.ACCORDH): stop_and_go = True - if not candidate == CAR.ACCORDH: # Hybrid uses same brake msg as hatch - ret.safetyParam = 1 # Accord and CRV 5G use an alternate user brake msg + if not candidate == CAR.ACCORDH: # Hybrid uses same brake msg as hatch + ret.safetyParam = 1 # Accord(ICE), CRV 5G, and RDX 3G use an alternate user brake msg ret.mass = 3279. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.83 ret.centerToFront = ret.wheelbase * 0.39 ret.steerRatio = 16.33 # 11.82 is spec end-to-end + ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end tire_stiffness_factor = 0.8467 - ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.18]] ret.longitudinalTuning.kpBP = [0., 5., 35.] ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5] ret.longitudinalTuning.kiBP = [0., 35.] ret.longitudinalTuning.kiV = [0.18, 0.12] + if eps_modified: + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.09]] + else: + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.18]] + elif candidate == CAR.ACURA_ILX: stop_and_go = False ret.mass = 3095. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.67 ret.centerToFront = ret.wheelbase * 0.37 ret.steerRatio = 18.61 # 15.3 is spec end-to-end + ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 3840], [0, 3840]] # TODO: determine if there is a dead zone at the top end tire_stiffness_factor = 0.72 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]] ret.longitudinalTuning.kpBP = [0., 5., 35.] @@ -211,13 +227,14 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): ret.longitudinalTuning.kiBP = [0., 35.] ret.longitudinalTuning.kiV = [0.18, 0.12] - elif candidate == CAR.CRV: + elif candidate in (CAR.CRV, CAR.CRV_EU): stop_and_go = False ret.mass = 3572. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.62 ret.centerToFront = ret.wheelbase * 0.41 - ret.steerRatio = 16.89 # as spec - tire_stiffness_factor = 0.444 # not optimized yet + ret.steerRatio = 16.89 # as spec + ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 1000], [0, 1000]] # TODO: determine if there is a dead zone at the top end + tire_stiffness_factor = 0.444 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]] ret.longitudinalTuning.kpBP = [0., 5., 35.] ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5] @@ -226,13 +243,21 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): elif candidate == CAR.CRV_5G: stop_and_go = True - ret.safetyParam = 1 # Accord and CRV 5G use an alternate user brake msg + ret.safetyParam = 1 # Accord(ICE), CRV 5G, and RDX 3G use an alternate user brake msg ret.mass = 3410. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.66 ret.centerToFront = ret.wheelbase * 0.41 - ret.steerRatio = 16.0 # 12.3 is spec end-to-end + ret.steerRatio = 16.0 # 12.3 is spec end-to-end + if eps_modified: + # stock request input values: 0x0000, 0x00DB, 0x01BB, 0x0296, 0x0377, 0x0454, 0x0532, 0x0610, 0x067F + # stock request output values: 0x0000, 0x0500, 0x0A15, 0x0E6D, 0x1100, 0x1200, 0x129A, 0x134D, 0x1400 + # modified request output values: 0x0000, 0x0500, 0x0A15, 0x0E6D, 0x1100, 0x1200, 0x1ACD, 0x239A, 0x2800 + ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 2560, 10000], [0, 2560, 3840]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.21], [0.07]] + else: + ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 3840], [0, 3840]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.64], [0.192]] tire_stiffness_factor = 0.677 - ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.18]] ret.longitudinalTuning.kpBP = [0., 5., 35.] ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5] ret.longitudinalTuning.kiBP = [0., 35.] @@ -240,11 +265,12 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): elif candidate == CAR.CRV_HYBRID: stop_and_go = True - ret.safetyParam = 1 # Accord and CRV 5G use an alternate user brake msg - ret.mass = 1667. + STD_CARGO_KG # mean of 4 models in kg + ret.safetyParam = 1 # Accord(ICE), CRV 5G, and RDX 3G use an alternate user brake msg + ret.mass = 1667. + STD_CARGO_KG # mean of 4 models in kg ret.wheelbase = 2.66 ret.centerToFront = ret.wheelbase * 0.41 - ret.steerRatio = 16.0 # 12.3 is spec end-to-end + ret.steerRatio = 16.0 # 12.3 is spec end-to-end + ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end tire_stiffness_factor = 0.677 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.18]] ret.longitudinalTuning.kpBP = [0., 5., 35.] @@ -252,25 +278,70 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): ret.longitudinalTuning.kiBP = [0., 35.] ret.longitudinalTuning.kiV = [0.18, 0.12] + elif candidate == CAR.FIT: + stop_and_go = False + ret.mass = 2644. * CV.LB_TO_KG + STD_CARGO_KG + ret.wheelbase = 2.53 + ret.centerToFront = ret.wheelbase * 0.39 + ret.steerRatio = 13.06 + ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end + tire_stiffness_factor = 0.75 + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.06]] + ret.longitudinalTuning.kpBP = [0., 5., 35.] + ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5] + ret.longitudinalTuning.kiBP = [0., 35.] + ret.longitudinalTuning.kiV = [0.18, 0.12] + + elif candidate == CAR.HRV: + stop_and_go = False + ret.mass = 3125 * CV.LB_TO_KG + STD_CARGO_KG + ret.wheelbase = 2.61 + ret.centerToFront = ret.wheelbase * 0.41 + ret.steerRatio = 15.2 + ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] + tire_stiffness_factor = 0.5 + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16], [0.025]] + ret.longitudinalTuning.kpBP = [0., 5., 35.] + ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5] + ret.longitudinalTuning.kiBP = [0., 35.] + ret.longitudinalTuning.kiV = [0.18, 0.12] + elif candidate == CAR.ACURA_RDX: stop_and_go = False ret.mass = 3935. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.68 ret.centerToFront = ret.wheelbase * 0.38 - ret.steerRatio = 15.0 # as spec - tire_stiffness_factor = 0.444 # not optimized yet + ret.steerRatio = 15.0 # as spec + ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 1000], [0, 1000]] # TODO: determine if there is a dead zone at the top end + tire_stiffness_factor = 0.444 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]] ret.longitudinalTuning.kpBP = [0., 5., 35.] ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5] ret.longitudinalTuning.kiBP = [0., 35.] ret.longitudinalTuning.kiV = [0.18, 0.12] + elif candidate == CAR.ACURA_RDX_3G: + stop_and_go = True + ret.safetyParam = 1 # Accord(ICE), CRV 5G, and RDX 3G use an alternate user brake msg + ret.mass = 4068. * CV.LB_TO_KG + STD_CARGO_KG + ret.wheelbase = 2.75 + ret.centerToFront = ret.wheelbase * 0.41 + ret.steerRatio = 11.95 # as spec + ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 3840], [0, 3840]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.18]] + tire_stiffness_factor = 0.677 + ret.longitudinalTuning.kpBP = [0., 5., 35.] + ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5] + ret.longitudinalTuning.kiBP = [0., 35.] + ret.longitudinalTuning.kiV = [0.18, 0.12] + elif candidate == CAR.ODYSSEY: stop_and_go = False ret.mass = 4471. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 3.00 ret.centerToFront = ret.wheelbase * 0.41 - ret.steerRatio = 14.35 # as spec + ret.steerRatio = 14.35 # as spec + ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end tire_stiffness_factor = 0.82 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.45], [0.135]] ret.longitudinalTuning.kpBP = [0., 5., 35.] @@ -280,11 +351,12 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): elif candidate == CAR.ODYSSEY_CHN: stop_and_go = False - ret.mass = 1849.2 + STD_CARGO_KG # mean of 4 models in kg - ret.wheelbase = 2.90 # spec - ret.centerToFront = ret.wheelbase * 0.41 # from CAR.ODYSSEY - ret.steerRatio = 14.35 # from CAR.ODYSSEY - tire_stiffness_factor = 0.82 # from CAR.ODYSSEY + ret.mass = 1849.2 + STD_CARGO_KG # mean of 4 models in kg + ret.wheelbase = 2.90 + ret.centerToFront = ret.wheelbase * 0.41 # from CAR.ODYSSEY + ret.steerRatio = 14.35 + ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 32767], [0, 32767]] # TODO: determine if there is a dead zone at the top end + tire_stiffness_factor = 0.82 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.45], [0.135]] ret.longitudinalTuning.kpBP = [0., 5., 35.] ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5] @@ -293,11 +365,12 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): elif candidate in (CAR.PILOT, CAR.PILOT_2019): stop_and_go = False - ret.mass = 4204. * CV.LB_TO_KG + STD_CARGO_KG # average weight + ret.mass = 4204. * CV.LB_TO_KG + STD_CARGO_KG # average weight ret.wheelbase = 2.82 - ret.centerToFront = ret.wheelbase * 0.428 # average weight distribution - ret.steerRatio = 17.25 # as spec - tire_stiffness_factor = 0.444 # not optimized yet + ret.centerToFront = ret.wheelbase * 0.428 + ret.steerRatio = 17.25 # as spec + ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end + tire_stiffness_factor = 0.444 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.38], [0.11]] ret.longitudinalTuning.kpBP = [0., 5., 35.] ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5] @@ -309,19 +382,32 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): ret.mass = 4515. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 3.18 ret.centerToFront = ret.wheelbase * 0.41 - ret.steerRatio = 15.59 # as spec - tire_stiffness_factor = 0.444 # not optimized yet + ret.steerRatio = 15.59 # as spec + ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end + tire_stiffness_factor = 0.444 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.38], [0.11]] ret.longitudinalTuning.kpBP = [0., 5., 35.] ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5] ret.longitudinalTuning.kiBP = [0., 35.] ret.longitudinalTuning.kiV = [0.18, 0.12] + elif candidate == CAR.INSIGHT: + stop_and_go = True + ret.mass = 2987. * CV.LB_TO_KG + STD_CARGO_KG + ret.wheelbase = 2.7 + ret.centerToFront = ret.wheelbase * 0.39 + ret.steerRatio = 15.0 # 12.58 is spec end-to-end + ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end + tire_stiffness_factor = 0.82 + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.18]] + ret.longitudinalTuning.kpBP = [0., 5., 35.] + ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5] + ret.longitudinalTuning.kiBP = [0., 35.] + ret.longitudinalTuning.kiV = [0.18, 0.12] + else: raise ValueError("unsupported car %s" % candidate) - ret.steerControlType = car.CarParams.SteerControlType.torque - # min speed to enable ACC. if car can do stop and go, then set enabling speed # to a negative value, so it won't matter. Otherwise, add 0.5 mph margin to not # conflict with PCM acc @@ -336,111 +422,42 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront, tire_stiffness_factor=tire_stiffness_factor) - # no rear steering, at least on the listed cars above - ret.steerRatioRear = 0. - - # no max steer limit VS speed - ret.steerMaxBP = [0.] # m/s - ret.steerMaxV = [1.] # max steer allowed - ret.gasMaxBP = [0.] # m/s - # TODO: what is the correct way to handle this? - ret.gasMaxV = [1.] #if ret.enableGasInterceptor else [0.] # max gas allowed + ret.gasMaxV = [0.6] if ret.enableGasInterceptor else [0.] # max gas allowed ret.brakeMaxBP = [5., 20.] # m/s ret.brakeMaxV = [1., 0.8] # max brake allowed - ret.longitudinalTuning.deadzoneBP = [0.] - ret.longitudinalTuning.deadzoneV = [0.] - ret.stoppingControl = True - ret.steerLimitAlert = True ret.startAccel = 0.5 ret.steerActuatorDelay = 0.1 ret.steerRateCost = 0.5 + ret.steerLimitTimer = 0.8 return ret # returns a car.CarState def update(self, c, can_strings): # ******************* do can recv ******************* - self.cp.update_strings(int(sec_since_boot() * 1e9), can_strings) - self.cp_cam.update_strings(int(sec_since_boot() * 1e9), can_strings) - - self.CS.update(self.cp, self.cp_cam) - - # create message - ret = car.CarState.new_message() - - ret.canValid = self.cp.can_valid - - # speeds - ret.vEgo = self.CS.v_ego - ret.aEgo = self.CS.a_ego - ret.vEgoRaw = self.CS.v_ego_raw - ret.yawRate = self.VM.yaw_rate(self.CS.angle_steers * CV.DEG_TO_RAD, self.CS.v_ego) - ret.standstill = self.CS.standstill - ret.wheelSpeeds.fl = self.CS.v_wheel_fl - ret.wheelSpeeds.fr = self.CS.v_wheel_fr - ret.wheelSpeeds.rl = self.CS.v_wheel_rl - ret.wheelSpeeds.rr = self.CS.v_wheel_rr - - # gas pedal - ret.gas = self.CS.car_gas / 256.0 - if not self.CP.enableGasInterceptor: - ret.gasPressed = self.CS.pedal_gas > 0 - else: - ret.gasPressed = self.CS.user_gas_pressed + self.cp.update_strings(can_strings) + self.cp_cam.update_strings(can_strings) + if self.cp_body: + self.cp_body.update_strings(can_strings) + + ret = self.CS.update(self.cp, self.cp_cam, self.cp_body) - # brake pedal - ret.brake = self.CS.user_brake - ret.brakePressed = self.CS.brake_pressed != 0 + ret.canValid = self.cp.can_valid and self.cp_cam.can_valid and (self.cp_body is None or self.cp_body.can_valid) + ret.yawRate = self.VM.yaw_rate(ret.steeringAngle * CV.DEG_TO_RAD, ret.vEgo) # FIXME: read sendcan for brakelights brakelights_threshold = 0.02 if self.CS.CP.carFingerprint == CAR.CIVIC else 0.1 ret.brakeLights = bool(self.CS.brake_switch or c.actuators.brake > brakelights_threshold) - # steering wheel - ret.steeringAngle = self.CS.angle_steers - ret.steeringRate = self.CS.angle_steers_rate - - # gear shifter lever - ret.gearShifter = self.CS.gear_shifter - - ret.steeringTorque = self.CS.steer_torque_driver - ret.steeringTorqueEps = self.CS.steer_torque_motor - ret.steeringPressed = self.CS.steer_override - - # cruise state - ret.cruiseState.enabled = self.CS.pcm_acc_status != 0 - ret.cruiseState.speed = self.CS.v_cruise_pcm * CV.KPH_TO_MS - ret.cruiseState.available = bool(self.CS.main_on) and not bool(self.CS.cruise_mode) - ret.cruiseState.speedOffset = self.CS.cruise_speed_offset - ret.cruiseState.standstill = False - - # TODO: button presses buttonEvents = [] - ret.leftBlinker = bool(self.CS.left_blinker_on) - ret.rightBlinker = bool(self.CS.right_blinker_on) - - ret.doorOpen = not self.CS.door_all_closed - ret.seatbeltUnlatched = not self.CS.seatbelt - - if self.CS.left_blinker_on != self.CS.prev_left_blinker_on: - be = car.CarState.ButtonEvent.new_message() - be.type = 'leftBlinker' - be.pressed = self.CS.left_blinker_on != 0 - buttonEvents.append(be) - - if self.CS.right_blinker_on != self.CS.prev_right_blinker_on: - be = car.CarState.ButtonEvent.new_message() - be.type = 'rightBlinker' - be.pressed = self.CS.right_blinker_on != 0 - buttonEvents.append(be) if self.CS.cruise_buttons != self.CS.prev_cruise_buttons: be = car.CarState.ButtonEvent.new_message() - be.type = 'unknown' + be.type = ButtonType.unknown if self.CS.cruise_buttons != 0: be.pressed = True but = self.CS.cruise_buttons @@ -448,18 +465,18 @@ def update(self, c, can_strings): be.pressed = False but = self.CS.prev_cruise_buttons if but == CruiseButtons.RES_ACCEL: - be.type = 'accelCruise' + be.type = ButtonType.accelCruise elif but == CruiseButtons.DECEL_SET: - be.type = 'decelCruise' + be.type = ButtonType.decelCruise elif but == CruiseButtons.CANCEL: - be.type = 'cancel' + be.type = ButtonType.cancel elif but == CruiseButtons.MAIN: - be.type = 'altButton3' + be.type = ButtonType.altButton3 buttonEvents.append(be) if self.CS.cruise_setting != self.CS.prev_cruise_setting: be = car.CarState.ButtonEvent.new_message() - be.type = 'unknown' + be.type = ButtonType.unknown if self.CS.cruise_setting != 0: be.pressed = True but = self.CS.cruise_setting @@ -467,60 +484,34 @@ def update(self, c, can_strings): be.pressed = False but = self.CS.prev_cruise_setting if but == 1: - be.type = 'altButton1' + be.type = ButtonType.altButton1 # TODO: more buttons? buttonEvents.append(be) ret.buttonEvents = buttonEvents # events - events = [] - # wait 1.0s before throwing the alert to avoid it popping when you turn off the car - if self.cp_cam.can_invalid_cnt >= 100 and self.CS.CP.carFingerprint not in HONDA_BOSCH and self.CP.enableCamera: - events.append(create_event('invalidGiraffeHonda', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT])) - if self.CS.steer_error: - events.append(create_event('steerUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT])) - elif self.CS.steer_warning: - events.append(create_event('steerTempUnavailable', [ET.WARNING])) + events = self.create_common_events(ret, pcm_enable=False) if self.CS.brake_error: - events.append(create_event('brakeUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT])) - if not ret.gearShifter == 'drive': - events.append(create_event('wrongGear', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if ret.doorOpen: - events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if ret.seatbeltUnlatched: - events.append(create_event('seatbeltNotLatched', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if self.CS.esp_disabled: - events.append(create_event('espDisabled', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if not self.CS.main_on or self.CS.cruise_mode: - events.append(create_event('wrongCarMode', [ET.NO_ENTRY, ET.USER_DISABLE])) - if ret.gearShifter == 'reverse': - events.append(create_event('reverseGear', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) + events.add(EventName.brakeUnavailable) if self.CS.brake_hold and self.CS.CP.openpilotLongitudinalControl: - events.append(create_event('brakeHold', [ET.NO_ENTRY, ET.USER_DISABLE])) + events.add(EventName.brakeHold) if self.CS.park_brake: - events.append(create_event('parkBrake', [ET.NO_ENTRY, ET.USER_DISABLE])) + events.add(EventName.parkBrake) if self.CP.enableCruise and ret.vEgo < self.CP.minEnableSpeed: - events.append(create_event('speedTooLow', [ET.NO_ENTRY])) - - # disable on pedals rising edge or when brake is pressed and speed isn't zero - if (ret.gasPressed and not self.gas_pressed_prev) or \ - (ret.brakePressed and (not self.brake_pressed_prev or ret.vEgo > 0.001)): - events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) - - if ret.gasPressed: - events.append(create_event('pedalPressed', [ET.PRE_ENABLE])) + events.add(EventName.belowEngageSpeed) # it can happen that car cruise disables while comma system is enabled: need to # keep braking if needed or if the speed is very low - if self.CP.enableCruise and not ret.cruiseState.enabled and c.actuators.brake <= 0.: - # non loud alert if cruise disbales below 25mph as expected (+ a little margin) + if self.CP.enableCruise and not ret.cruiseState.enabled \ + and (c.actuators.brake <= 0. or not self.CP.openpilotLongitudinalControl): + # non loud alert if cruise disables below 25mph as expected (+ a little margin) if ret.vEgo < self.CP.minEnableSpeed + 2.: - events.append(create_event('speedTooLow', [ET.IMMEDIATE_DISABLE])) + events.add(EventName.speedTooLow) else: - events.append(create_event("cruiseDisabled", [ET.IMMEDIATE_DISABLE])) + events.add(EventName.cruiseDisabled) if self.CS.CP.minEnableSpeed > 0 and ret.vEgo < 0.001: - events.append(create_event('manualRestart', [ET.WARNING])) + events.add(EventName.manualRestart) cur_time = self.frame * DT_CTRL enable_pressed = False @@ -528,36 +519,32 @@ def update(self, c, can_strings): for b in ret.buttonEvents: # do enable on both accel and decel buttons - if b.type in ["accelCruise", "decelCruise"] and not b.pressed: + if b.type in [ButtonType.accelCruise, ButtonType.decelCruise] and not b.pressed: self.last_enable_pressed = cur_time enable_pressed = True # do disable on button down if b.type == "cancel" and b.pressed: - events.append(create_event('buttonCancel', [ET.USER_DISABLE])) + events.add(EventName.buttonCancel) if self.CP.enableCruise: # KEEP THIS EVENT LAST! send enable event if button is pressed and there are # NO_ENTRY events, so controlsd will display alerts. Also not send enable events # too close in time, so a no_entry will not be followed by another one. - # TODO: button press should be the only thing that triggers enble + # TODO: button press should be the only thing that triggers enable if ((cur_time - self.last_enable_pressed) < 0.2 and (cur_time - self.last_enable_sent) > 0.2 and ret.cruiseState.enabled) or \ - (enable_pressed and get_events(events, [ET.NO_ENTRY])): - events.append(create_event('buttonEnable', [ET.ENABLE])) + (enable_pressed and events.any(ET.NO_ENTRY)): + events.add(EventName.buttonEnable) self.last_enable_sent = cur_time elif enable_pressed: - events.append(create_event('buttonEnable', [ET.ENABLE])) + events.add(EventName.buttonEnable) - ret.events = events + ret.events = events.to_msg() - # update previous brake/gas pressed - self.gas_pressed_prev = ret.gasPressed - self.brake_pressed_prev = ret.brakePressed - - # cast to reader so it can't be modified - return ret.as_reader() + self.CS.out = ret.as_reader() + return self.CS.out # pass in a car.CarControl # to be called @ 100hz @@ -567,8 +554,6 @@ def apply(self, c): else: hud_v_cruise = 255 - hud_alert = VISUAL_HUD[c.hudControl.visualAlert.raw] - pcm_accel = int(clip(c.cruiseControl.accelOverride, 0, 1) * 0xc6) can_sends = self.CC.update(c.enabled, self.CS, self.frame, @@ -580,7 +565,7 @@ def apply(self, c): hud_v_cruise, c.hudControl.lanesVisible, hud_show_car=c.hudControl.leadVisible, - hud_alert=hud_alert) + hud_alert=c.hudControl.visualAlert) self.frame += 1 return can_sends diff --git a/selfdrive/car/honda/radar_interface.py b/selfdrive/car/honda/radar_interface.py index 8972d775a6971a..cae84e1d29ccc8 100644 --- a/selfdrive/car/honda/radar_interface.py +++ b/selfdrive/car/honda/radar_interface.py @@ -1,38 +1,37 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from cereal import car -import time -import os -import time -from cereal import car -from selfdrive.can.parser import CANParser -from common.realtime import sec_since_boot +from opendbc.can.parser import CANParser +from selfdrive.car.interfaces import RadarInterfaceBase +from selfdrive.car.honda.values import DBC -def _create_nidec_can_parser(): - dbc_f = 'acura_ilx_2016_nidec.dbc' - radar_messages = [0x400] + range(0x430, 0x43A) + range(0x440, 0x446) +def _create_nidec_can_parser(car_fingerprint): + radar_messages = [0x400] + list(range(0x430, 0x43A)) + list(range(0x440, 0x446)) signals = list(zip(['RADAR_STATE'] + ['LONG_DIST'] * 16 + ['NEW_TRACK'] * 16 + ['LAT_DIST'] * 16 + ['REL_SPEED'] * 16, [0x400] + radar_messages[1:] * 4, [0] + [255] * 16 + [1] * 16 + [0] * 16 + [0] * 16)) checks = list(zip([0x445], [20])) - - return CANParser(os.path.splitext(dbc_f)[0], signals, checks, 1) + return CANParser(DBC[car_fingerprint]['radar'], signals, checks, 1) -class RadarInterface(object): - def __init__(self,CP): - # radar - self.pts = {} +class RadarInterface(RadarInterfaceBase): + def __init__(self, CP): + super().__init__(CP) + self.track_id = 0 self.delay = 0.1 self.TRACK_LEFT_LANE = False self.TRACK_RIGHT_LANE = False self.radar_off_can = CP.radarOffCan + self.radar_ts = CP.radarTimeStep - self.delay = 0.1 # Delay of radar + self.delay = int(round(0.1 / CP.radarTimeStep)) # 0.1s delay of radar # Nidec - self.rcp = _create_nidec_can_parser() + if self.radar_off_can: + self.rcp = None + else: + self.rcp = _create_nidec_can_parser(CP.carFingerprint) self.trigger_msg = 0x445 self.updated_messages = set() @@ -40,11 +39,9 @@ def update(self, can_strings): # in Bosch radar and we are only steering for now, so sleep 0.05s to keep # radard at 20Hz and return no points if self.radar_off_can: - time.sleep(0.05) - return car.RadarData.new_message() + return super().update(None) - tm = int(sec_since_boot() * 1e9) - vls = self.rcp.update_strings(tm, can_strings) + vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) if self.trigger_msg not in self.updated_messages: @@ -54,11 +51,10 @@ def update(self, can_strings): self.updated_messages.clear() return rr - def _update(self, updated_messages): ret = car.RadarData.new_message() - for ii in updated_messages: + for ii in sorted(updated_messages): cpt = self.rcp.vl[ii] if ii == 0x400: # check for radar faults @@ -88,6 +84,6 @@ def _update(self, updated_messages): errors.append("wrongConfig") ret.errors = errors - ret.points = self.pts.values() + ret.points = list(self.pts.values()) return ret diff --git a/selfdrive/car/honda/readconfig.py b/selfdrive/car/honda/readconfig.py index e595f90d717623..f03bcc01b55fe0 100644 --- a/selfdrive/car/honda/readconfig.py +++ b/selfdrive/car/honda/readconfig.py @@ -1,4 +1,4 @@ -import ConfigParser +import configparser config_path = '/data/honda_openpilot.cfg' config_file_r = 'r' @@ -6,13 +6,13 @@ def read_config_file(CS): file_changed = False - configr = ConfigParser.ConfigParser() + configr = configparser.ConfigParser() try: configr.read(config_path) except: file_changed = True - print "no config file, creating with defaults..." - config = ConfigParser.RawConfigParser() + print ("no config file, creating with defaults...") + config = configparser.RawConfigParser() config.add_section('OP_CONFIG') diff --git a/selfdrive/car/honda/values.py b/selfdrive/car/honda/values.py index c7acaffc82497e..e4e0dd409b1f04 100644 --- a/selfdrive/car/honda/values.py +++ b/selfdrive/car/honda/values.py @@ -1,34 +1,27 @@ +# flake8: noqa + from cereal import car from selfdrive.car import dbc_dict +Ecu = car.CarParams.Ecu VisualAlert = car.CarControl.HUDControl.VisualAlert # Car button codes class CruiseButtons: - RES_ACCEL = 4 - DECEL_SET = 3 - CANCEL = 2 - MAIN = 1 - -class AH: - #[alert_idx, value] - # See dbc files for info on values" - NONE = [0, 0] - FCW = [1, 1] - STEER = [2, 1] - BRAKE_PRESSED = [3, 10] - GEAR_NOT_D = [4, 6] - SEATBELT = [5, 5] - SPEED_TOO_HIGH = [6, 8] + RES_ACCEL = 4 + DECEL_SET = 3 + CANCEL = 2 + MAIN = 1 +# See dbc files for info on values" VISUAL_HUD = { - VisualAlert.none: AH.NONE, - VisualAlert.fcw: AH.FCW, - VisualAlert.steerRequired: AH.STEER, - VisualAlert.brakePressed: AH.BRAKE_PRESSED, - VisualAlert.wrongGear: AH.GEAR_NOT_D, - VisualAlert.seatbeltUnbuckled: AH.SEATBELT, - VisualAlert.speedTooHigh: AH.SPEED_TOO_HIGH} + VisualAlert.none: 0, + VisualAlert.fcw: 1, + VisualAlert.steerRequired: 1, + VisualAlert.brakePressed: 10, + VisualAlert.wrongGear: 6, + VisualAlert.seatbeltUnbuckled: 5, + VisualAlert.speedTooHigh: 8} class CAR: ACCORD = "HONDA ACCORD 2018 SPORT 2T" @@ -36,16 +29,22 @@ class CAR: ACCORDH = "HONDA ACCORD 2018 HYBRID TOURING" CIVIC = "HONDA CIVIC 2016 TOURING" CIVIC_BOSCH = "HONDA CIVIC HATCHBACK 2017 SEDAN/COUPE 2019" + CIVIC_BOSCH_DIESEL = "HONDA CIVIC SEDAN 1.6 DIESEL" ACURA_ILX = "ACURA ILX 2016 ACURAWATCH PLUS" CRV = "HONDA CR-V 2016 TOURING" CRV_5G = "HONDA CR-V 2017 EX" + CRV_EU = "HONDA CR-V 2016 EXECUTIVE" CRV_HYBRID = "HONDA CR-V 2019 HYBRID" + FIT = "HONDA FIT 2018 EX" + HRV = "HONDA HRV 2019 TOURING" ODYSSEY = "HONDA ODYSSEY 2018 EX-L" ODYSSEY_CHN = "HONDA ODYSSEY 2019 EXCLUSIVE CHN" ACURA_RDX = "ACURA RDX 2018 ACURAWATCH PLUS" + ACURA_RDX_3G = "ACURA RDX 2020 TECH" PILOT = "HONDA PILOT 2017 TOURING" PILOT_2019 = "HONDA PILOT 2019 ELITE" RIDGELINE = "HONDA RIDGELINE 2017 BLACK EDITION" + INSIGHT = "HONDA INSIGHT 2019 TOURING" # diag message that in some Nidec cars only appear with 1s freq if VIN query is performed DIAG_MSGS = {1600: 5, 1601: 8} @@ -67,22 +66,43 @@ class CAR: CAR.ACURA_RDX: [{ 57: 3, 145: 8, 229: 4, 308: 5, 316: 8, 342: 6, 344: 8, 380: 8, 392: 6, 398: 3, 399: 6, 404: 4, 420: 8, 422: 8, 426: 8, 432: 7, 464: 8, 474: 5, 476: 4, 487: 4, 490: 8, 506: 8, 512: 6, 513: 6, 542: 7, 545: 4, 597: 8, 660: 8, 773: 7, 777: 8, 780: 8, 800: 8, 804: 8, 808: 8, 819: 7, 821: 5, 829: 5, 882: 2, 884: 7, 887: 8, 888: 8, 892: 8, 923: 2, 929: 4, 963: 8, 965: 8, 966: 8, 967: 8, 983: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1033: 5, 1034: 5, 1036: 8, 1039: 8, 1057: 5, 1064: 7, 1108: 8, 1365: 5, 1424: 5, 1729: 1 }], + CAR.ACURA_RDX_3G: [{ + 57: 3, 148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 423: 2, 427: 3, 428: 8, 432: 7, 441: 5, 450: 8, 464: 8, 470: 2, 476: 7, 477: 8, 479: 8, 490: 8, 493: 5, 495: 8, 506: 8, 507: 1, 545: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 815: 8, 825: 4, 829: 5, 846: 8, 862: 8, 881: 8, 882: 4, 884: 8, 888: 8, 891: 8, 892: 8, 918: 7, 927: 8, 929: 8, 983: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1064: 6, 1092: 1, 1108: 8, 1115: 2, 1125: 8, 1127: 2, 1296: 8, 1302: 8, 1322: 5, 1361: 5, 1365: 5, 1424: 5, 1600: 5, 1601: 8, 1633: 8 + }], CAR.CIVIC: [{ 57: 3, 148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 427: 3, 428: 8, 432: 7, 450: 8, 464: 8, 470: 2, 476: 7, 487: 4, 490: 8, 493: 5, 506: 8, 512: 6, 513: 6, 545: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 829: 5, 862: 8, 884: 8, 891: 8, 892: 8, 927: 8, 929: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1108: 8, 1302: 8, 1322: 5, 1361: 5, 1365: 5, 1424: 5, 1633: 8, }], CAR.CIVIC_BOSCH: [{ - # 2017 Civic Hatchback EX and 2019 Civic Sedan Touring Canadian - 57: 3, 148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 427: 3, 428: 8, 432: 7, 441: 5, 450: 8, 464: 8, 470: 2, 476: 7, 477: 8, 479: 8, 490: 8, 493: 5, 495: 8, 506: 8, 545: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 829: 5, 862: 8, 884: 8, 891: 8, 892: 8, 927: 8, 929: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1108: 8, 1302: 8, 1322: 5, 1361: 5, 1365: 5, 1424: 5, 1600: 5, 1601: 8, 1633: 8, + # 2017 Civic Hatchback EX, 2019 Civic Sedan Touring Canadian, and 2018 Civic Hatchback Executive Premium 1.0L CVT European + 57: 3, 148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 427: 3, 428: 8, 432: 7, 441: 5, 450: 8, 460: 3, 464: 8, 470: 2, 476: 7, 477: 8, 479: 8, 490: 8, 493: 5, 495: 8, 506: 8, 545: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 829: 5, 862: 8, 884: 8, 891: 8, 892: 8, 927: 8, 929: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1108: 8, 1302: 8, 1322: 5, 1361: 5, 1365: 5, 1424: 5, 1600: 5, 1601: 8, 1625: 5, 1629: 5, 1633: 8, + }, + # 2017 Civic Hatchback LX + { + 57: 3, 148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 423: 2, 427: 3, 428: 8, 432: 7, 441: 5, 450: 8, 464: 8, 470: 2, 476: 7, 477: 8, 479: 8, 490: 8, 493: 5, 495: 8, 506: 8, 545: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 815: 8, 825: 4, 829: 5, 846: 8, 862: 8, 881: 8, 882: 4, 884: 8, 888: 8, 891: 8, 892: 8, 918: 7, 927: 8, 929: 8, 983: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1064: 7, 1092: 1, 1108: 8, 1125: 8, 1127: 2, 1296: 8, 1302: 8, 1322: 5, 1361: 5, 1365: 5, 1424: 5, 1600: 5, 1601: 8, 1633: 8 + }], + CAR.CIVIC_BOSCH_DIESEL: [{ + # 2019 Civic Sedan 1.6 i-dtec Diesel European + 57: 3, 148: 8, 228: 5, 308: 5, 316: 8, 330: 8, 344: 8, 380: 8, 399: 7, 419: 8, 420: 8, 426: 8, 427: 3, 432: 7, 441: 5, 450: 8, 464: 8, 470: 2, 476: 7, 477: 8, 479: 8, 490: 8, 493: 5, 495: 8, 506: 8, 507: 1, 545: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 801: 3, 804: 8, 806: 8, 808: 8, 815: 8, 824: 8, 825: 4, 829: 5, 837: 5, 862: 8, 881: 8, 882: 4, 884: 8, 887: 8, 888: 8, 891: 8, 902: 8, 918: 7, 927: 8, 929: 8, 983: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1064: 7, 1092: 1, 1108: 8, 1115: 2, 1125: 8, 1296: 8, 1302: 8, 1322: 5, 1337: 5, 1361: 5, 1365: 5, 1424: 5, 1600: 5, 1601: 8 }], CAR.CRV: [{ 57: 3, 145: 8, 316: 8, 340: 8, 342: 6, 344: 8, 380: 8, 398: 3, 399: 6, 401: 8, 404: 4, 420: 8, 422: 8, 426: 8, 432: 7, 464: 8, 474: 5, 476: 4, 487: 4, 490: 8, 493: 3, 506: 8, 507: 1, 512: 6, 513: 6, 542: 7, 545: 4, 597: 8, 660: 8, 661: 4, 773: 7, 777: 8, 780: 8, 800: 8, 804: 8, 808: 8, 829: 5, 882: 2, 884: 7, 888: 8, 891: 8, 892: 8, 923: 2, 929: 8, 983: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1033: 5, 1036: 8, 1039: 8, 1057: 5, 1064: 7, 1108: 8, 1125: 8, 1296: 8, 1365: 5, 1424: 5, 1600: 5, 1601: 8, }], CAR.CRV_5G: [{ - 57: 3, 148: 8, 199: 4, 228: 5, 231: 5, 232: 7, 304: 8, 330: 8, 340: 8, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 423: 2, 427: 3, 428: 8, 432: 7, 441: 5, 446: 3, 450: 8, 464: 8, 467: 2, 469: 3, 470: 2, 474: 8, 476: 7, 477: 8, 479: 8, 490: 8, 493: 5, 495: 8, 507: 1, 545: 6, 597: 8, 661: 4, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 814: 4, 815: 8, 817: 4, 825: 4, 829: 5, 862: 8, 881: 8, 882: 4, 884: 8, 888: 8, 891: 8, 927: 8, 918: 7, 929: 8, 983: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1064: 7, 1108: 8, 1092: 1, 1115: 4, 1125: 8, 1127: 2, 1296: 8, 1302: 8, 1322: 5, 1361: 5, 1365: 5, 1424: 5, 1600: 5, 1601: 8, 1618: 5, 1633: 8, 1670: 5 + 57: 3, 148: 8, 199: 4, 228: 5, 231: 5, 232: 7, 304: 8, 330: 8, 340: 8, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 423: 2, 427: 3, 428: 8, 432: 7, 441: 5, 446: 3, 450: 8, 464: 8, 467: 2, 469: 3, 470: 2, 474: 8, 476: 7, 477: 8, 479: 8, 490: 8, 493: 5, 495: 8, 507: 1, 545: 6, 597: 8, 661: 4, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 814: 4, 815: 8, 817: 4, 825: 4, 829: 5, 862: 8, 881: 8, 882: 4, 884: 8, 888: 8, 891: 8, 927: 8, 918: 7, 929: 8, 983: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1064: 7, 1108: 8, 1092: 1, 1115: 2, 1125: 8, 1127: 2, 1296: 8, 1302: 8, 1322: 5, 1361: 5, 1365: 5, 1424: 5, 1600: 5, 1601: 8, 1618: 5, 1633: 8, 1670: 5 + }], + # 1057: 5 1024: 5 are also on the OBD2 bus. their lengths differ from the camera's f-can bus. re-fingerprint after obd2 connection is split in panda firmware from bus 1. + CAR.CRV_EU: [{ + 57: 3, 145: 8, 308: 5, 316: 8, 342: 6, 344: 8, 380: 8, 398: 3, 399: 6, 404: 4, 419: 8, 420: 8, 422: 8, 426: 8, 432: 7, 464: 8, 474: 5, 476: 4, 487: 4, 490: 8, 493: 3, 506: 8, 507: 1, 510: 3, 538: 3, 542: 7, 545: 4, 597: 8, 660: 8, 661: 4, 768: 8, 769: 8, 773: 7, 777: 8, 780: 8, 800: 8, 801: 3, 803: 8, 804: 8, 808: 8, 824: 8, 829: 5, 837: 5, 862: 8, 882: 2, 884: 7, 888: 8, 891: 8, 892: 8, 923: 2, 927: 8, 929: 8, 930: 8, 931: 8, 983: 8, 1024: 8, 1027: 5, 1029: 8, 1033: 5, 1036: 8, 1039: 8, 1040: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1045: 8, 1046: 8, 1047: 8, 1056: 8, 1057: 8, 1058: 8, 1059: 8, 1060: 8, 1064: 7, 1072: 8, 1073: 8, 1074: 8, 1075: 8, 1076: 8, 1077: 8, 1078: 8, 1079: 8, 1080: 8, 1081: 8, 1088: 8, 1089: 8, 1090: 8, 1091: 8, 1092: 8, 1093: 8, 1108: 8, 1125: 8, 1279: 8, 1280: 8, 1296: 8, 1297: 8, 1365: 5, 1424: 5, 1600: 5, 1601: 8, }], CAR.CRV_HYBRID: [{ 57: 3, 148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 387: 8, 388: 8, 399: 7, 408: 6, 415: 6, 419: 8, 420: 8, 427: 3, 428: 8, 432: 7, 441: 5, 450: 8, 464: 8, 477: 8, 479: 8, 490: 8, 495: 8, 525: 8, 531: 8, 545: 6, 662: 4, 773: 7, 777: 8, 780: 8, 804: 8, 806: 8, 808: 8, 814: 4, 829: 5, 833: 6, 862: 8, 884: 8, 891: 8, 927: 8, 929: 8, 930: 8, 931: 8, 1302: 8, 1361: 5, 1365: 5, 1600: 5, 1601: 8, 1626: 5, 1627: 5 }], + CAR.FIT: [{ + 57: 3, 145: 8, 228: 5, 304: 8, 342: 6, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 422: 8, 427: 3, 428: 8, 432: 7, 464: 8, 487: 4, 490: 8, 506: 8, 597: 8, 660: 8, 661: 4, 773: 7, 777: 8, 780: 8, 800: 8, 804: 8, 808: 8, 829: 5, 862: 8, 884: 7, 892: 8, 929: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1108: 8, 1322: 5, 1361: 5, 1365: 5, 1424: 5, 1600: 5, 1601: 8 + }], + CAR.HRV: [{ + 57: 3, 145: 8, 228: 5, 316: 8, 340: 8, 342: 6, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 422: 8, 423: 2, 426: 8, 427: 3, 432: 7, 441: 5, 450: 8, 464: 8, 474: 8, 490: 8, 493: 3, 506: 8, 538: 5, 578: 2, 597: 8, 660: 8, 661: 4, 773: 7, 777: 8, 780: 8, 804: 8, 808: 8, 829: 5, 862: 8, 882: 2, 884: 7, 892: 8, 929: 8, 985: 3, 1030: 5, 1033: 5, 1108: 8, 1137: 8, 1348: 5, 1361: 5, 1365: 5, 1600: 5, 1601: 8, 1618: 5 + }], # 2018 Odyssey w/ Added Comma Pedal Support (512L & 513L) CAR.ODYSSEY: [{ 57: 3, 148: 8, 228: 5, 229: 4, 316: 8, 342: 6, 344: 8, 380: 8, 399: 7, 411: 5, 419: 8, 420: 8, 427: 3, 432: 7, 450: 8, 463: 8, 464: 8, 476: 4, 490: 8, 506: 8, 512: 6, 513: 6, 542: 7, 545: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 817: 4, 819: 7, 821: 5, 825: 4, 829: 5, 837: 5, 856: 7, 862: 8, 871: 8, 881: 8, 882: 4, 884: 8, 891: 8, 892: 8, 905: 8, 923: 2, 927: 8, 929: 8, 963: 8, 965: 8, 966: 8, 967: 8, 983: 8, 985: 3, 1029: 8, 1036: 8, 1052: 8, 1064: 7, 1088: 8, 1089: 8, 1092: 1, 1108: 8, 1110: 8, 1125: 8, 1296: 8, 1302: 8, 1600: 5, 1601: 8, 1612: 5, 1613: 5, 1614: 5, 1615: 8, 1616: 5, 1619: 5, 1623: 5, 1668: 5 @@ -92,7 +112,7 @@ class CAR: 57: 3, 148: 8, 228: 5, 229: 4, 304: 8, 342: 6, 344: 8, 380: 8, 399: 7, 411: 5, 419: 8, 420: 8, 427: 3, 432: 7, 440: 8, 450: 8, 463: 8, 464: 8, 476: 4, 490: 8, 506: 8, 507: 1, 542: 7, 545: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 817: 4, 819: 7, 821: 5, 825: 4, 829: 5, 837: 5, 856: 7, 862: 8, 871: 8, 881: 8, 882: 4, 884: 8, 891: 8, 892: 8, 905: 8, 923: 2, 927: 8, 929: 8, 963: 8, 965: 8, 966: 8, 967: 8, 983: 8, 985: 3, 1029: 8, 1036: 8, 1052: 8, 1064: 7, 1088: 8, 1089: 8, 1092: 1, 1108: 8, 1110: 8, 1125: 8, 1296: 8, 1302: 8, 1600: 5, 1601: 8, 1612: 5, 1613: 5, 1614: 5, 1616: 5, 1619: 5, 1623: 5, 1668: 5 }], CAR.ODYSSEY_CHN: [{ - 57: 3, 145: 8, 316: 8, 342: 6, 344: 8, 380: 8, 398: 3, 399: 7, 401: 8, 404: 4, 411: 5, 420: 8, 422: 8, 423: 2, 426: 8, 432: 7, 450: 8, 464: 8, 490: 8, 506: 8, 507: 1, 597: 8, 610: 8, 611: 8, 612: 8, 617: 8, 660: 8, 661: 4, 773: 7, 780: 8, 804: 8, 808: 8, 829: 5, 862: 8, 884: 7, 892: 8, 923: 2, 929: 8, 1030: 5, 1137: 8, 1302: 8, 1348: 5, 1361: 5, 1365: 5, 1600: 5, 1601: 8, 1639: 8 + 57: 3, 145: 8, 316: 8, 342: 6, 344: 8, 380: 8, 398: 3, 399: 7, 401: 8, 404: 4, 411: 5, 420: 8, 422: 8, 423: 2, 426: 8, 432: 7, 450: 8, 464: 8, 490: 8, 506: 8, 507: 1, 512: 6, 513: 6, 597: 8, 610: 8, 611: 8, 612: 8, 617: 8, 660: 8, 661: 4, 773: 7, 780: 8, 804: 8, 808: 8, 829: 5, 862: 8, 884: 7, 892: 8, 923: 2, 929: 8, 1030: 5, 1137: 8, 1302: 8, 1348: 5, 1361: 5, 1365: 5, 1600: 5, 1601: 8, 1639: 8 }], # 2017 Pilot Touring AND 2016 Pilot EX-L w/ Added Comma Pedal Support (512L & 513L) CAR.PILOT: [{ @@ -112,32 +132,914 @@ class CAR: }, # 2019 Ridgeline { - 57: 3, 145: 8, 229: 4, 308: 5, 316: 8, 339: 7, 342: 6, 344: 8, 380: 8, 392: 6, 399: 7, 419: 8, 420: 8, 422:8, 425: 8, 426: 8, 427: 3, 432: 7, 464: 8, 476: 4, 490: 8, 545: 5, 546: 3, 597: 8, 660: 8, 773: 7, 777: 8, 795: 8, 800: 8, 804: 8, 808: 8, 819: 7, 821: 5, 871: 8, 882: 2, 884: 7, 892: 8, 923: 2, 929: 8, 963: 8, 965: 8, 966: 8, 967: 8, 983: 8, 985: 3, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1064: 7, 1088: 8, 1089: 8, 1092: 1, 1108: 8, 1125: 8, 1296: 8, 1365: 5, 424: 5, 1613: 5, 1616: 5, 1618: 5, 1623: 5, 1668: 5 + 57: 3, 145: 8, 228: 5, 229: 4, 308: 5, 316: 8, 339: 7, 342: 6, 344: 8, 380: 8, 392: 6, 399: 7, 419: 8, 420: 8, 422: 8, 425: 8, 426: 8, 427: 3, 432: 7, 464: 8, 476: 4, 490: 8, 512: 6, 513: 6, 545: 5, 546: 3, 597: 8, 660: 8, 773: 7, 777: 8, 795: 8, 800: 8, 804: 8, 808: 8, 819: 7, 821: 5, 871: 8, 882: 2, 884: 7, 892: 8, 923: 2, 929: 8, 963: 8, 965: 8, 966: 8, 967: 8, 983: 8, 985: 3, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1064: 7, 1088: 8, 1089: 8, 1092: 1, 1108: 8, 1125: 8, 1296: 8, 1365: 5, 424: 5, 1613: 5, 1616: 5, 1618: 5, 1623: 5, 1668: 5 + }], + # 2019 Insight + CAR.INSIGHT: [{ + 57: 3, 148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 387: 8, 388: 8, 399: 7, 419: 8, 420: 8, 427: 3, 432: 7, 441: 5, 450: 8, 464: 8, 476: 8, 477: 8, 479: 8, 490: 8, 495: 8, 507: 1, 525: 8, 531: 8, 545: 6, 547: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 804: 8, 806: 8, 808: 8, 814: 4, 815: 8, 829: 5, 832: 3, 862: 8, 884: 8, 891: 8, 927: 8, 929: 8, 954: 2, 985: 3, 1029: 8, 1093: 4, 1115: 2, 1302: 8, 1361: 5, 1365: 5, 1600: 5, 1601: 8, 1652: 8, 2015: 3 }] } +# Don't use theses fingerprints for fingerprinting, they are still needed for ECU detection +IGNORED_FINGERPRINTS = [CAR.INSIGHT, CAR.CIVIC_BOSCH_DIESEL, CAR.CRV_EU, CAR.HRV, CAR.ACURA_RDX_3G] + # add DIAG_MSGS to fingerprints for c in FINGERPRINTS: for f, _ in enumerate(FINGERPRINTS[c]): for d in DIAG_MSGS: FINGERPRINTS[c][f][d] = DIAG_MSGS[d] +# TODO: Figure out what is relevant +FW_VERSIONS = { + CAR.ACCORD: { + (Ecu.programmedFuelInjection, 0x18da10f1, None): [ + b'37805-6A0-A640\x00\x00', + b'37805-6B2-A550\x00\x00', + b'37805-6B2-A560\x00\x00', + b'37805-6B2-A650\x00\x00', + b'37805-6B2-A660\x00\x00', + b'37805-6B2-A720\x00\x00', + b'37805-6B2-M520\x00\x00', + ], + (Ecu.shiftByWire, 0x18da0bf1, None): [ + b'54008-TVC-A910\x00\x00', + ], + (Ecu.transmission, 0x18da1ef1, None): [ + b'28102-6B8-A560\x00\x00', + b'28102-6B8-A570\x00\x00', + b'28102-6B8-A800\x00\x00', + b'28102-6B8-C570\x00\x00', + b'28102-6B8-M520\x00\x00', + ], + (Ecu.electricBrakeBooster, 0x18da2bf1, None): [ + b'46114-TVA-A060\x00\x00', + b'46114-TVA-A080\x00\x00', + b'46114-TVA-A120\x00\x00', + ], + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-TVA-C040\x00\x00', + b'57114-TVA-C050\x00\x00', + b'57114-TVA-C060\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TVA,A150\x00\x00', + b'39990-TVA-A150\x00\x00', + b'39990-TVA-A160\x00\x00', + b'39990-TVA-X030\x00\x00', + ], + (Ecu.unknown, 0x18da3af1, None): [ + b'39390-TVA-A020\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-TVA-A460\x00\x00', + b'77959-TVA-X330\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-TVA-A210\x00\x00', + b'78109-TVC-A010\x00\x00', + b'78109-TVC-A020\x00\x00', + b'78109-TVC-A110\x00\x00', + b'78109-TVC-A210\x00\x00', + b'78109-TVC-C110\x00\x00', + b'78109-TVC-M510\x00\x00', + ], + (Ecu.hud, 0x18da61f1, None): [ + b'78209-TVA-A010\x00\x00', + ], + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'36802-TVA-A160\x00\x00', + b'36802-TVA-A170\x00\x00', + b'36802-TWA-A070\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab5f1, None): [ + b'36161-TVA-A060\x00\x00', + b'36161-TWA-A070\x00\x00', + ], + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-TVA-A010\x00\x00', + ], + }, + CAR.ACCORD_15: { + (Ecu.programmedFuelInjection, 0x18da10f1, None): [ + b'37805-6A0-9620\x00\x00', + b'37805-6A0-A540\x00\x00', + b'37805-6A0-A640\x00\x00', + b'37805-6A0-A650\x00\x00', + b'37805-6A0-A740\x00\x00', + b'37805-6A0-A750\x00\x00', + b'37805-6A0-A840\x00\x00', + b'37805-6A0-A850\x00\x00', + b'37805-6A0-C540\x00\x00', + b'37805-6A1-H650\x00\x00', + b'37805-6M4-B730\x00\x00', + ], + (Ecu.transmission, 0x18da1ef1, None): [ + b'28101-6A7-A220\x00\x00', + b'28101-6A7-A230\x00\x00', + b'28101-6A7-A320\x00\x00', + b'28101-6A7-A330\x00\x00', + b'28101-6A7-A510\x00\x00', + b'28101-6A9-H140\x00\x00', + b'28101-6A9-H420\x00\x00', + ], + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-TVA-A230\x00\x00', + ], + (Ecu.electricBrakeBooster, 0x18da2bf1, None): [ + b'46114-TVA-A050\x00\x00', + b'46114-TVA-A060\x00\x00', + b'46114-TVA-A080\x00\x00', + b'46114-TVA-A120\x00\x00', + b'46114-TVE-H550\x00\x00', + b'46114-TVE-H560\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-TVA-A010\x00\x00', + b'78109-TVA-A110\x00\x00', + b'78109-TVA-A210\x00\x00', + b'78109-TVA-A220\x00\x00', + b'78109-TVA-A310\x00\x00', + b'78109-TVA-C010\x00\x00', + b'78109-TVE-H610\x00\x00', + b'78109-TWA-A210\x00\x00', + b'78109-TBX-H310\x00\x00', + ], + (Ecu.hud, 0x18da61f1, None): [ + b'78209-TVA-A010\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab5f1, None): [ + b'36161-TVA-A060\x00\x00', + b'36161-TVE-H050\x00\x00', + b'36161-TBX-H130\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-TVA-A460\x00\x00', + b'77959-TVA-H230\x00\x00', + b'77959-TBX-H230\x00\x00', + ], + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-TVA-B050\x00\x00', + b'57114-TVA-B040\x00\x00', + b'57114-TVE-H250\x00\x00', + ], + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'36802-TVA-A150\x00\x00', + b'36802-TVA-A160\x00\x00', + b'36802-TVA-A170\x00\x00', + b'36802-TVE-H070\x00\x00', + b'36802-TBX-H140\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TVA-A140\x00\x00', + b'39990-TVA-A150\x00\x00', # Are these two different steerRatio? + b'39990-TVA-A160\x00\x00', # Sport, Sport 2.0T and Touring 2.0T have different ratios + b'39990-TVE-H130\x00\x00', + b'39990-TBX-H120\x00\x00', + ], + }, + CAR.ACCORDH: { + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-TWA-A120\x00\x00', + ], + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-TWA-A040\x00\x00', + b'57114-TWA-A050\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-TWA-A440\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-TWA-A010\x00\x00', + b'78109-TWA-A020\x00\x00', + b'78109-TWA-A110\x00\x00', + b'78109-TWA-A120\x00\x00', + b'78109-TWA-A210\x00\x00', + b'78109-TWA-A220\x00\x00', + + ], + (Ecu.shiftByWire, 0x18da0bf1, None): [ + b'54008-TWA-A910\x00\x00', + ], + (Ecu.hud, 0x18da61f1, None): [ + b'78209-TVA-A010\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab5f1, None): [ + b'36161-TWA-A070\x00\x00', + ], + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'36802-TWA-A080\x00\x00', + b'36802-TWA-A070\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TVA-A160\x00\x00', + b'39990-TVA-A150\x00\x00', + ], + }, + CAR.CIVIC: { + (Ecu.programmedFuelInjection, 0x18da10f1, None): [ + b'37805-5AA-A640\x00\x00', + b'37805-5AA-A650\x00\x00', + b'37805-5AA-A670\x00\x00', + b'37805-5AA-A680\x00\x00', + b'37805-5AA-A810\x00\x00', + b'37805-5AA-C680\x00\x00', + b'37805-5AA-C820\x00\x00', + b'37805-5AA-L650\x00\x00', + b'37805-5AA-L660\x00\x00', + b'37805-5AA-L680\x00\x00', + b'37805-5AA-L690\x00\x00', + b'37805-5AJ-A610\x00\x00', + b'37805-5AJ-A620\x00\x00', + b'37805-5BA-A310\x00\x00', + b'37805-5BA-A510\x00\x00', + b'37805-5BA-A740\x00\x00', + b'37805-5BA-A760\x00\x00', + b'37805-5BA-A960\x00\x00', + b'37805-5BA-L930\x00\x00', + b'37805-5BA-L940\x00\x00', + b'37805-5BA-L960\x00\x00', + b'37805-5AG-Q710\x00\x00', + ], + (Ecu.transmission, 0x18da1ef1, None): [ + b'28101-5CG-A040\x00\x00', + b'28101-5CG-A050\x00\x00', + b'28101-5CG-A070\x00\x00', + b'28101-5CG-A080\x00\x00', + b'28101-5CG-A810\x00\x00', + b'28101-5CG-A820\x00\x00', + b'28101-5DJ-A040\x00\x00', + b'28101-5DJ-A060\x00\x00', + b'28101-5DJ-A510\x00\x00', + b'28101-5CG-A320\x00\x00', + ], + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-TBA-A540\x00\x00', + b'57114-TBA-A550\x00\x00', + b'57114-TBA-A560\x00\x00', + b'57114-TBA-A570\x00\x00', + b'57114-TEA-Q220\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TBA,A030\x00\x00', + b'39990-TBA-A030\x00\x00', + b'39990-TBG-A030\x00\x00', + b'39990-TEG-A010\x00\x00', + b'39990-TEA-T020\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-TBA-A030\x00\x00', + b'77959-TBA-A040\x00\x00', + b'77959-TBG-A030\x00\x00', + b'77959-TEA-Q820\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-TBA-A510\x00\x00', + b'78109-TBA-A520\x00\x00', + b'78109-TBA-A530\x00\x00', + b'78109-TBC-A310\x00\x00', + b'78109-TBC-A320\x00\x00', + b'78109-TBC-A510\x00\x00', + b'78109-TBC-A520\x00\x00', + b'78109-TBC-A530\x00\x00', + b'78109-TBC-C510\x00\x00', + b'78109-TBC-C520\x00\x00', + b'78109-TBC-C530\x00\x00', + b'78109-TBH-A530\x00\x00', + b'78109-TEG-A310\x00\x00', + b'78109-TED-Q510\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab0f1, None): [ + b'36161-TBA-A020\x00\x00', + b'36161-TBA-A030\x00\x00', + b'36161-TBA-A040\x00\x00', + b'36161-TBC-A020\x00\x00', + b'36161-TBC-A030\x00\x00', + b'36161-TEG-A010\x00\x00', + b'36161-TEG-A020\x00\x00', + b'36161-TED-Q320\x00\x00', + ], + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-TBA-A010\x00\x00', + b'38897-TBA-A020\x00\x00', + ], + }, + CAR.CIVIC_BOSCH: { + (Ecu.programmedFuelInjection, 0x18da10f1, None): [ + b'37805-5AA-A940\x00\x00', + b'37805-5AA-A950\x00\x00', + b'37805-5AA-L940\x00\x00', + b'37805-5AA-L950\x00\x00', + b'37805-5AN-A750\x00\x00', + b'37805-5AN-A830\x00\x00', + b'37805-5AN-A840\x00\x00', + b'37805-5AN-A930\x00\x00', + b'37805-5AN-A940\x00\x00', + b'37805-5AN-A950\x00\x00', + b'37805-5AN-AG20\x00\x00', + b'37805-5AN-AH20\x00\x00', + b'37805-5AN-AJ30\x00\x00', + b'37805-5AN-AK20\x00\x00', + b'37805-5AN-AR20\x00\x00', + b'37805-5AN-L940\x00\x00', + b'37805-5AN-LF20\x00\x00', + b'37805-5AN-LH20\x00\x00', + b'37805-5AN-LJ20\x00\x00', + b'37805-5AN-LR20\x00\x00', + b'37805-5AN-LS20\x00\x00', + b'37805-5AW-G720\x00\x00', + b'37805-5AZ-E850\x00\x00', + b'37805-5BB-A630\x00\x00', + b'37805-5BB-A640\x00\x00', + b'37805-5BB-C540\x00\x00', + b'37805-5BB-C630\x00\x00', + b'37805-5BB-L540\x00\x00', + b'37805-5BB-L640\x00\x00', + b'37805-5AZ-G740\x00\x00', + ], + (Ecu.transmission, 0x18da1ef1, None): [ + b'28101-5CG-A920\x00\x00', + b'28101-5CG-AB10\x00\x00', + b'28101-5CG-C110\x00\x00', + b'28101-5CG-C220\x00\x00', + b'28101-5CG-C320\x00\x00', + b'28101-5CG-G020\x00\x00', + b'28101-5CK-A130\x00\x00', + b'28101-5CK-A140\x00\x00', + b'28101-5CK-A150\x00\x00', + b'28101-5CK-C130\x00\x00', + b'28101-5CK-C140\x00\x00', + b'28101-5CK-C150\x00\x00', + b'28101-5DJ-A610\x00\x00', + b'28101-5DJ-A710\x00\x00', + b'28101-5DV-E330\x00\x00', + b'28101-5DV-E610\x00\x00', + ], + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-TBG-A340\x00\x00', + b'57114-TBG-A350\x00\x00', + b'57114-TGG-A340\x00\x00', + b'57114-TGG-C320\x00\x00', + b'57114-TGG-L320\x00\x00', + b'57114-TGG-L330\x00\x00', + b'57114-TGL-G330\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TBA-C020\x00\x00', + b'39990-TBA-C120\x00\x00', + b'39990-TEZ-T020\x00\x00', + b'39990-TGG-A020\x00\x00', + b'39990-TGG-A120\x00\x00', + b'39990-TGL-E130\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-TBA-A060\x00\x00', + b'77959-TEA-G020\x00\x00', + b'77959-TGG-A020\x00\x00', + b'77959-TGG-A030\x00\x00', + b'77959-TGG-G010\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-TBA-A110\x00\x00', + b'78109-TBA-A910\x00\x00', + b'78109-TBA-C340\x00\x00', + b'78109-TBA-C910\x00\x00', + b'78109-TBC-A740\x00\x00', + b'78109-TFJ-G020\x00\x00', + b'78109-TGG-A210\x00\x00', + b'78109-TGG-A220\x00\x00', + b'78109-TGG-A310\x00\x00', + b'78109-TGG-A320\x00\x00', + b'78109-TGG-A330\x00\x00', + b'78109-TGG-A610\x00\x00', + b'78109-TGG-A620\x00\x00', + b'78109-TGG-A810\x00\x00', + b'78109-TGG-A820\x00\x00', + b'78109-TGL-G120\x00\x00', + b'78109-TGL-G130\x00\x00', + ], + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'36802-TBA-A150\x00\x00', + b'36802-TFJ-G060\x00\x00', + b'36802-TGG-A050\x00\x00', + b'36802-TGG-A060\x00\x00', + b'36802-TGG-A130\x00\x00', + b'36802-TGL-G040\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab5f1, None): [ + b'36161-TBA-A130\x00\x00', + b'36161-TBA-A140\x00\x00', + b'36161-TFJ-G070\x00\x00', + b'36161-TGG-A060\x00\x00', + b'36161-TGG-A080\x00\x00', + b'36161-TGG-A120\x00\x00', + b'36161-TGL-G050\x00\x00', + b'36161-TGL-G070\x00\x00', + ], + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-TBA-A110\x00\x00', + b'38897-TBA-A020\x00\x00', + ], + }, + CAR.CIVIC_BOSCH_DIESEL: { + (Ecu.programmedFuelInjection, 0x18da10f1, None): [b'37805-59N-G830\x00\x00'], + (Ecu.transmission, 0x18da1ef1, None): [b'28101-59Y-G620\x00\x00'], + (Ecu.vsa, 0x18da28f1, None): [b'57114-TGN-E320\x00\x00'], + (Ecu.eps, 0x18da30f1, None): [b'39990-TFK-G020\x00\x00'], + (Ecu.srs, 0x18da53f1, None): [b'77959-TFK-G210\x00\x00'], + (Ecu.combinationMeter, 0x18da60f1, None): [b'78109-TFK-G020\x00\x00'], + (Ecu.fwdRadar, 0x18dab0f1, None): [b'36802-TFK-G130\x00\x00'], + (Ecu.shiftByWire, 0x18da0bf1, None): [b'54008-TGN-E010\x00\x00'], + (Ecu.fwdCamera, 0x18dab5f1, None): [b'36161-TFK-G130\x00\x00'], + (Ecu.gateway, 0x18daeff1, None): [b'38897-TBA-A020\x00\x00'], + }, + CAR.CRV: { + (Ecu.vsa, 0x18da28f1, None): [b'57114-T1W-A230\x00\x00',], + (Ecu.srs, 0x18da53f1, None): [b'77959-T0A-A230\x00\x00',], + (Ecu.combinationMeter, 0x18da60f1, None): [b'78109-T1W-A210\x00\x00',], + (Ecu.fwdRadar, 0x18dab0f1, None): [b'36161-T1W-A830\x00\x00',], + }, + CAR.CRV_5G: { + (Ecu.programmedFuelInjection, 0x18da10f1, None): [ + b'37805-5PA-3060\x00\x00', + b'37805-5PA-3080\x00\x00', + b'37805-5PA-4050\x00\x00', + b'37805-5PA-6520\x00\x00', + b'37805-5PA-6530\x00\x00', + b'37805-5PA-6630\x00\x00', + b'37805-5PA-9640\x00\x00', + b'37805-5PA-9830\x00\x00', + b'37805-5PA-A650\x00\x00', + b'37805-5PA-A670\x00\x00', + b'37805-5PA-A680\x00\x00', + b'37805-5PA-A850\x00\x00', + b'37805-5PA-A870\x00\x00', + b'37805-5PA-A880\x00\x00', + b'37805-5PA-A890\x00\x00', + b'37805-5PD-Q630\x00\x00', + ], + (Ecu.transmission, 0x18da1ef1, None): [ + b'28101-5RG-A020\x00\x00', + b'28101-5RG-A030\x00\x00', + b'28101-5RG-A040\x00\x00', + b'28101-5RG-A120\x00\x00', + b'28101-5RG-A220\x00\x00', + b'28101-5RH-A020\x00\x00', + b'28101-5RH-A030\x00\x00', + b'28101-5RH-A040\x00\x00', + b'28101-5RH-A120\x00\x00', + b'28101-5RH-A220\x00\x00', + b'28101-5RL-Q010\x00\x00', + ], + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-TLA-A040\x00\x00', + b'57114-TLA-A050\x00\x00', + b'57114-TLA-A060\x00\x00', + b'57114-TLB-A830\x00\x00', + b'57114-TMC-Z050\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TLA,A040\x00\x00', + b'39990-TLA-A040\x00\x00', + b'39990-TLA-A110\x00\x00', + b'39990-TLA-A220\x00\x00', + b'39990-TMT-T010\x00\x00', + ], + (Ecu.electricBrakeBooster, 0x18da2bf1, None): [ + b'46114-TLA-A040\x00\x00', + b'46114-TLA-A050\x00\x00', + b'46114-TLA-A930\x00\x00', + b'46114-TMC-U020\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-TLA-A110\x00\x00', + b'78109-TLA-A210\x00\x00', + b'78109-TLA-A220\x00\x00', + b'78109-TLA-C210\x00\x00', + b'78109-TLB-A110\x00\x00', + b'78109-TLB-A210\x00\x00', + b'78109-TLB-A220\x00\x00', + b'78109-TMC-Q210\x00\x00', + ], + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-TLA-A010\x00\x00', + b'38897-TLA-A110\x00\x00', + b'38897-TNY-G010\x00\x00', + ], + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'36802-TLA-A040\x00\x00', + b'36802-TLA-A050\x00\x00', + b'36802-TLA-A060\x00\x00', + b'36802-TMC-Q070\x00\x00', + b'36802-TNY-A030\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab5f1, None): [ + b'36161-TLA-A060\x00\x00', + b'36161-TLA-A070\x00\x00', + b'36161-TLA-A080\x00\x00', + b'36161-TMC-Q040\x00\x00', + b'36161-TNY-A020\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-TLA-A240\x00\x00', + b'77959-TLA-A250\x00\x00', + b'77959-TLA-A320\x00\x00', + b'77959-TLA-Q040\x00\x00', + ], + }, + CAR.CRV_EU: { + (Ecu.programmedFuelInjection, 0x18da10f1, None): [ + b'37805-R5Z-G740\x00\x00', + b'37805-R5Z-G780\x00\x00', + ], + (Ecu.vsa, 0x18da28f1, None): [b'57114-T1V-G920\x00\x00'], + (Ecu.fwdRadar, 0x18dab0f1, None): [b'36161-T1V-G520\x00\x00'], + (Ecu.shiftByWire, 0x18da0bf1, None): [b'54008-T1V-G010\x00\x00'], + (Ecu.transmission, 0x18da1ef1, None): [ + b'28101-5LH-E120\x00\x00', + b'28103-5LH-E100\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-T1V-G020\x00\x00', + b'78109-T1B-3050\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [b'77959-T1G-G940\x00\x00'], + }, + CAR.CRV_HYBRID: { + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-TPA-G020\x00\x00', + b'57114-TPG-A020\x00\x00', + b'57114-TMB-H030\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TPA-G030\x00\x00', + b'39990-TPG-A020\x00\x00', + b'39990-TMA-H020\x00\x00', + ], + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-TMA-H110\x00\x00', + b'38897-TPG-A110\x00\x00', + ], + (Ecu.shiftByWire, 0x18da0bf1, None): [ + b'54008-TMB-H510\x00\x00', + b'54008-TMB-H610\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab5f1, None): [ + b'36161-TPA-E050\x00\x00', + b'36161-TPG-A030\x00\x00', + b'36161-TMB-H040\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-TPA-G520\x00\x00', + b'78109-TPG-A110\x00\x00', + b'78109-TMB-H220\x00\x00', + ], + (Ecu.hud, 0x18da61f1, None): [ + b'78209-TLA-X010\x00\x00', + ], + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'36802-TPA-E040\x00\x00', + b'36802-TPG-A020\x00\x00', + b'36802-TMB-H040\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-TLA-G220\x00\x00', + b'77959-TLA-C320\x00\x00', + b'77959-TLA-H240\x00\x00', + ], + }, + CAR.FIT: { + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-T5R-L220\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-T5R-C020\x00\x00', + b'39990-T5R-C030\x00\x00', + ], + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-T5A-J010\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-T5A-A420\x00\x00', + b'78109-T5A-A910\x00\x00', + ], + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'36161-T5R-A240\x00\x00', + b'36161-T5R-A520\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-T5R-A230\x00\x00', + ], + }, + CAR.ODYSSEY: { + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-THR-A010\x00\x00', + b'38897-THR-A020\x00\x00', + ], + (Ecu.programmedFuelInjection, 0x18da10f1, None): [ + b'37805-5MR-A250\x00\x00', + b'37805-5MR-A310\x00\x00', + b'37805-5MR-A750\x00\x00', + b'37805-5MR-A840\x00\x00', + b'37805-5MR-C620\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-THR-A020\x00\x00', + b'39990-THR-A030\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-THR-A010\x00\x00', + b'77959-THR-A110\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab0f1, None): [ + b'36161-THR-A030\x00\x00', + b'36161-THR-A110\x00\x00', + b'36161-THR-A720\x00\x00', + b'36161-THR-A730\x00\x00', + b'36161-THR-A810\x00\x00', + b'36161-THR-A910\x00\x00', + b'36161-THR-C010\x00\x00', + ], + (Ecu.transmission, 0x18da1ef1, None): [ + b'28101-5NZ-A310\x00\x00', + b'28101-5NZ-C310\x00\x00', + b'28102-5MX-A001\x00\x00', + b'28102-5MX-A600\x00\x00', + b'28102-5MX-A610\x00\x00', + b'28102-5MX-A710\x00\x00', + b'28102-5MX-A900\x00\x00', + b'28102-5MX-A910\x00\x00', + b'28102-5MX-C001\x00\x00', + b'28103-5NZ-A300\x00\x00', + ], + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-THR-A040\x00\x00', + b'57114-THR-A110\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-THR-A230\x00\x00', + b'78109-THR-A430\x00\x00', + b'78109-THR-A820\x00\x00', + b'78109-THR-A830\x00\x00', + b'78109-THR-AB20\x00\x00', + b'78109-THR-AB30\x00\x00', + b'78109-THR-AB40\x00\x00', + b'78109-THR-AC20\x00\x00', + b'78109-THR-AC40\x00\x00', + b'78109-THR-AE20\x00\x00', + b'78109-THR-AE40\x00\x00', + b'78109-THR-AL10\x00\x00', + b'78109-THR-AN10\x00\x00', + b'78109-THR-C330\x00\x00', + b'78109-THR-CE20\x00\x00', + ], + (Ecu.shiftByWire, 0x18da0bf1, None): [ + b'54008-THR-A020\x00\x00', + ], + }, + CAR.PILOT: { + (Ecu.shiftByWire, 0x18da0bf1, None): [ + b'54008-TG7-A520\x00\x00', + ], + (Ecu.transmission, 0x18da1ef1, None): [ + b'28101-5EZ-A210\x00\x00', + b'28101-5EZ-A100\x00\x00', + b'28101-5EZ-A060\x00\x00', + b'28101-5EZ-A050\x00\x00', + ], + (Ecu.programmedFuelInjection, 0x18da10f1, None): [ + b'37805-RLV-C910\x00\x00', + b'37805-RLV-C520\x00\x00', + b'37805-RLV-C510\x00\x00', + b'37805-RLV-4070\x00\x00', + b'37805-RLV-A830\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TG7-A040\x00\x00', + b'39990-TG7-A030\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab0f1, None): [ + b'36161-TG7-A520\x00\x00', + b'36161-TG7-A820\x00\x00', + b'36161-TG7-A720\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-TG7-A110\x00\x00', + b'77959-TG7-A020\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-TG7-A720\x00\x00', + b'78109-TG7-A520\x00\x00', + b'78109-TG7-A420\x00\x00', + b'78109-TG7-A040\x00\x00', + ], + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-TG7-A140\x00\x00', + b'57114-TG7-A240\x00\x00', + b'57114-TG7-A230\x00\x00', + ], + + }, + CAR.PILOT_2019: { + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TG7-A060\x00\x00', + b'39990-TGS-A230\x00\x00', + ], + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-TG7-A030\x00\x00', + b'38897-TG7-A110\x00\x00', + b'38897-TG7-A210\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab0f1, None): [ + b'36161-TG7-A630\x00\x00', + b'36161-TG7-A930\x00\x00', + b'36161-TG8-A630\x00\x00', + b'36161-TGS-A130\x00\x00', + b'36161-TGT-A030\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-TG7-A210\x00\x00', + b'77959-TGS-A010\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-TG7-AJ20\x00\x00', + b'78109-TG7-AK10\x00\x00', + b'78109-TG7-AK20\x00\x00', + b'78109-TG7-AP10\x00\x00', + b'78109-TG7-AP20\x00\x00', + b'78109-TG8-AJ20\x00\x00', + b'78109-TGS-AK20\x00\x00', + b'78109-TGS-AP20\x00\x00', + b'78109-TGT-AJ20\x00\x00', + ], + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-TG7-A630\x00\x00', + b'57114-TG7-A730\x00\x00', + b'57114-TG8-A630\x00\x00', + b'57114-TGS-A530\x00\x00', + b'57114-TGT-A530\x00\x00', + ], + }, + CAR.ACURA_RDX_3G: { + (Ecu.programmedFuelInjection, 0x18da10f1, None): [ + b'37805-5YF-A230\x00\x00', + b'37805-5YF-A420\x00\x00', + ], + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-TJB-A040\x00\x00', + ], + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'36802-TJB-A040\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab5f1, None): [ + b'36161-TJB-A040\x00\x00', + ], + (Ecu.shiftByWire, 0x18da0bf1, None): [ + b'54008-TJB-A520\x00\x00', + ], + (Ecu.transmission, 0x18da1ef1, None): [ + b'28102-5YK-A700\x00\x00', + b'28102-5YK-A711\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-TJB-AB10\x00\x00', + b'78109-TJB-AF10\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-TJB-A040\x00\x00', + ], + (Ecu.electricBrakeBooster, 0x18da2bf1, None): [ + b'46114-TJB-A050\x00\x00', + b'46114-TJB-A060\x00\x00', + ], + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-TJB-A110\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TJB-A030\x00\x00', + ], + }, + CAR.RIDGELINE: { + (Ecu.eps, 0x18da30f1, None): [ + b'39990-T6Z-A020\x00\x00', + b'39990-T6Z-A030\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab0f1, None): [ + b'36161-T6Z-A020\x00\x00', + b'36161-T6Z-A310\x00\x00', + b'36161-T6Z-A420\x00\x00', + b'36161-T6Z-A520\x00\x00', + b'36161-TJZ-A120\x00\x00', + ], + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-T6Z-A010\x00\x00', + b'38897-T6Z-A110\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-T6Z-A420\x00\x00', + b'78109-T6Z-A510\x00\x00', + b'78109-T6Z-A710\x00\x00', + b'78109-TJZ-A510\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-T6Z-A020\x00\x00', + ], + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-T6Z-A120\x00\x00', + b'57114-T6Z-A130\x00\x00', + b'57114-T6Z-A520\x00\x00', + b'57114-TJZ-A520\x00\x00', + ], + }, + CAR.INSIGHT: { + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TXM-A040\x00\x00', + ], + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'36802-TXM-A070\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab5f1, None): [ + b'36161-TXM-A050\x00\x00', + b'36161-TXM-A060\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-TXM-A230\x00\x00', + ], + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-TXM-A030\x00\x00', + b'57114-TXM-A040\x00\x00', + ], + (Ecu.shiftByWire, 0x18da0bf1, None): [ + b'54008-TWA-A910\x00\x00', + ], + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-TXM-A020\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-TXM-A010\x00\x00', + b'78109-TXM-A020\x00\x00', + b'78109-TXM-A110\x00\x00', + ], + }, + CAR.HRV: { + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-T7A-A010\x00\x00', + b'38897-T7A-A110\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-THX-A020\x00\x00', + ], + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'36161-T7A-A140\x00\x00', + b'36161-T7A-A240\x00\x00', + b'36161-T7A-C440\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-T7A-A230\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-THX-A110\x00\x00', + b'78109-THX-A210\x00\x00', + b'78109-THX-C220\x00\x00', + ], + }, + CAR.ACURA_ILX: { + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-TX6-A010\x00\x00', + ], + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'36161-TX6-A030\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-TX6-C210\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-T3R-A120\x00\x00', + ], + }, +} + DBC = { CAR.ACCORD: dbc_dict('honda_accord_s2t_2018_can_generated', None), CAR.ACCORD_15: dbc_dict('honda_accord_lx15t_2018_can_generated', None), CAR.ACCORDH: dbc_dict('honda_accord_s2t_2018_can_generated', None), CAR.ACURA_ILX: dbc_dict('acura_ilx_2016_can_generated', 'acura_ilx_2016_nidec'), CAR.ACURA_RDX: dbc_dict('acura_rdx_2018_can_generated', 'acura_ilx_2016_nidec'), + CAR.ACURA_RDX_3G: dbc_dict('acura_rdx_2020_can_generated', None), CAR.CIVIC: dbc_dict('honda_civic_touring_2016_can_generated', 'acura_ilx_2016_nidec'), CAR.CIVIC_BOSCH: dbc_dict('honda_civic_hatchback_ex_2017_can_generated', None), + CAR.CIVIC_BOSCH_DIESEL: dbc_dict('honda_civic_sedan_16_diesel_2019_can_generated', None), CAR.CRV: dbc_dict('honda_crv_touring_2016_can_generated', 'acura_ilx_2016_nidec'), - CAR.CRV_5G: dbc_dict('honda_crv_ex_2017_can_generated', None), + CAR.CRV_5G: dbc_dict('honda_crv_ex_2017_can_generated', None, body_dbc='honda_crv_ex_2017_body_generated'), + CAR.CRV_EU: dbc_dict('honda_crv_executive_2016_can_generated', 'acura_ilx_2016_nidec'), CAR.CRV_HYBRID: dbc_dict('honda_crv_hybrid_2019_can_generated', None), + CAR.FIT: dbc_dict('honda_fit_ex_2018_can_generated', 'acura_ilx_2016_nidec'), + CAR.HRV: dbc_dict('honda_hrv_touring_2019_can_generated', 'acura_ilx_2016_nidec'), CAR.ODYSSEY: dbc_dict('honda_odyssey_exl_2018_generated', 'acura_ilx_2016_nidec'), - CAR.ODYSSEY_CHN: dbc_dict('honda_odyssey_extreme_edition_2018_china_can', 'acura_ilx_2016_nidec'), + CAR.ODYSSEY_CHN: dbc_dict('honda_odyssey_extreme_edition_2018_china_can_generated', 'acura_ilx_2016_nidec'), CAR.PILOT: dbc_dict('honda_pilot_touring_2017_can_generated', 'acura_ilx_2016_nidec'), CAR.PILOT_2019: dbc_dict('honda_pilot_touring_2017_can_generated', 'acura_ilx_2016_nidec'), CAR.RIDGELINE: dbc_dict('honda_ridgeline_black_edition_2017_can_generated', 'acura_ilx_2016_nidec'), + CAR.INSIGHT: dbc_dict('honda_insight_ex_2019_can_generated', None), } STEER_THRESHOLD = { @@ -146,16 +1048,22 @@ class CAR: CAR.ACCORDH: 1200, CAR.ACURA_ILX: 1200, CAR.ACURA_RDX: 400, + CAR.ACURA_RDX_3G: 1200, CAR.CIVIC: 1200, CAR.CIVIC_BOSCH: 1200, + CAR.CIVIC_BOSCH_DIESEL: 1200, CAR.CRV: 1200, CAR.CRV_5G: 1200, + CAR.CRV_EU: 400, CAR.CRV_HYBRID: 1200, + CAR.FIT: 1200, + CAR.HRV: 1200, CAR.ODYSSEY: 1200, CAR.ODYSSEY_CHN: 1200, CAR.PILOT: 1200, CAR.PILOT_2019: 1200, CAR.RIDGELINE: 1200, + CAR.INSIGHT: 1200, } SPEED_FACTOR = { @@ -164,21 +1072,22 @@ class CAR: CAR.ACCORDH: 1., CAR.ACURA_ILX: 1., CAR.ACURA_RDX: 1., + CAR.ACURA_RDX_3G: 1., CAR.CIVIC: 1., CAR.CIVIC_BOSCH: 1., + CAR.CIVIC_BOSCH_DIESEL: 1., CAR.CRV: 1.025, CAR.CRV_5G: 1.025, + CAR.CRV_EU: 1.025, CAR.CRV_HYBRID: 1.025, + CAR.FIT: 1., + CAR.HRV: 1.025, CAR.ODYSSEY: 1., CAR.ODYSSEY_CHN: 1., CAR.PILOT: 1., CAR.PILOT_2019: 1., CAR.RIDGELINE: 1., + CAR.INSIGHT: 1., } -# msgs sent for steering controller by camera module on can 0. -# those messages are mutually exclusive on CRV and non-CRV cars -CAMERA_MSGS = [0xe4, 0x194] - -# TODO: get these from dbc file -HONDA_BOSCH = [CAR.ACCORD, CAR.ACCORD_15, CAR.ACCORDH, CAR.CIVIC_BOSCH, CAR.CRV_5G, CAR.CRV_HYBRID] +HONDA_BOSCH = set([CAR.ACCORD, CAR.ACCORD_15, CAR.ACCORDH, CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL, CAR.CRV_5G, CAR.CRV_HYBRID, CAR.INSIGHT, CAR.ACURA_RDX_3G]) diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index a1a688ff5ef7c8..4483d7b2192ecf 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -1,70 +1,86 @@ +from cereal import car +from common.realtime import DT_CTRL from selfdrive.car import apply_std_steer_torque_limits -from selfdrive.car.hyundai.hyundaican import create_lkas11, create_lkas12, \ - create_1191, create_1156, \ - create_clu11 -from selfdrive.car.hyundai.values import Buttons -from selfdrive.can.packer import CANPacker +from selfdrive.car.hyundai.hyundaican import create_lkas11, create_clu11, create_lfa_mfa +from selfdrive.car.hyundai.values import Buttons, SteerLimitParams, CAR +from opendbc.can.packer import CANPacker +VisualAlert = car.CarControl.HUDControl.VisualAlert -# Steer torque limits -class SteerLimitParams: - STEER_MAX = 255 # 409 is the max, 255 is stock - STEER_DELTA_UP = 3 - STEER_DELTA_DOWN = 7 - STEER_DRIVER_ALLOWANCE = 50 - STEER_DRIVER_MULTIPLIER = 2 - STEER_DRIVER_FACTOR = 1 +def process_hud_alert(enabled, fingerprint, visual_alert, left_lane, + right_lane, left_lane_depart, right_lane_depart): + sys_warning = (visual_alert == VisualAlert.steerRequired) -class CarController(object): - def __init__(self, dbc_name, car_fingerprint): - self.apply_steer_last = 0 - self.car_fingerprint = car_fingerprint - self.lkas11_cnt = 0 - self.cnt = 0 - self.last_resume_cnt = 0 - # True when giraffe switch 2 is low and we need to replace all the camera messages - # otherwise we forward the camera msgs and we just replace the lkas cmd signals - self.camera_disconnected = False + # initialize to no line visible + sys_state = 1 + if left_lane and right_lane or sys_warning: # HUD alert only display when LKAS status is active + sys_state = 3 if enabled or sys_warning else 4 + elif left_lane: + sys_state = 5 + elif right_lane: + sys_state = 6 - self.packer = CANPacker(dbc_name) + # initialize to no warnings + left_lane_warning = 0 + right_lane_warning = 0 + if left_lane_depart: + left_lane_warning = 1 if fingerprint in [CAR.GENESIS_G90, CAR.GENESIS_G80] else 2 + if right_lane_depart: + right_lane_warning = 1 if fingerprint in [CAR.GENESIS_G90, CAR.GENESIS_G80] else 2 - def update(self, enabled, CS, actuators, pcm_cancel_cmd, hud_alert): + return sys_warning, sys_state, left_lane_warning, right_lane_warning - ### Steering Torque - apply_steer = actuators.steer * SteerLimitParams.STEER_MAX - apply_steer = apply_std_steer_torque_limits(apply_steer, self.apply_steer_last, CS.steer_torque_driver, SteerLimitParams) +class CarController(): + def __init__(self, dbc_name, CP, VM): + self.p = SteerLimitParams(CP) + self.packer = CANPacker(dbc_name) - if not enabled: - apply_steer = 0 + self.apply_steer_last = 0 + self.car_fingerprint = CP.carFingerprint + self.steer_rate_limited = False + self.last_resume_frame = 0 - steer_req = 1 if enabled else 0 + def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, + left_lane, right_lane, left_lane_depart, right_lane_depart): + # Steering Torque + new_steer = actuators.steer * self.p.STEER_MAX + apply_steer = apply_std_steer_torque_limits(new_steer, self.apply_steer_last, CS.out.steeringTorque, self.p) + self.steer_rate_limited = new_steer != apply_steer - self.apply_steer_last = apply_steer + # disable if steer angle reach 90 deg, otherwise mdps fault in some models + lkas_active = enabled and abs(CS.out.steeringAngle) < 90. - can_sends = [] + # fix for Genesis hard fault at low speed + if CS.out.vEgo < 16.7 and self.car_fingerprint == CAR.HYUNDAI_GENESIS: + lkas_active = False + + if not lkas_active: + apply_steer = 0 - self.lkas11_cnt = self.cnt % 0x10 - self.clu11_cnt = self.cnt % 0x10 + self.apply_steer_last = apply_steer - if self.camera_disconnected: - if (self.cnt % 10) == 0: - can_sends.append(create_lkas12()) - if (self.cnt % 50) == 0: - can_sends.append(create_1191()) - if (self.cnt % 7) == 0: - can_sends.append(create_1156()) + sys_warning, sys_state, left_lane_warning, right_lane_warning = \ + process_hud_alert(enabled, self.car_fingerprint, visual_alert, + left_lane, right_lane, left_lane_depart, right_lane_depart) - can_sends.append(create_lkas11(self.packer, self.car_fingerprint, apply_steer, steer_req, self.lkas11_cnt, - enabled, CS.lkas11, hud_alert, keep_stock=(not self.camera_disconnected))) + can_sends = [] + can_sends.append(create_lkas11(self.packer, frame, self.car_fingerprint, apply_steer, lkas_active, + CS.lkas11, sys_warning, sys_state, enabled, + left_lane, right_lane, + left_lane_warning, right_lane_warning)) if pcm_cancel_cmd: - can_sends.append(create_clu11(self.packer, CS.clu11, Buttons.CANCEL)) - elif CS.stopped and (self.cnt - self.last_resume_cnt) > 5: - self.last_resume_cnt = self.cnt - can_sends.append(create_clu11(self.packer, CS.clu11, Buttons.RES_ACCEL)) - - self.cnt += 1 + can_sends.append(create_clu11(self.packer, frame, CS.clu11, Buttons.CANCEL)) + elif CS.out.cruiseState.standstill: + # send resume at a max freq of 10Hz + if (frame - self.last_resume_frame)*DT_CTRL > 0.1: + can_sends.extend([create_clu11(self.packer, frame, CS.clu11, Buttons.RES_ACCEL)] * 20) + self.last_resume_frame = frame + + # 20 Hz LFA MFA message + if frame % 5 == 0 and self.car_fingerprint in [CAR.SONATA, CAR.PALISADE, CAR.IONIQ, CAR.KIA_NIRO_EV, CAR.IONIQ_EV_2020]: + can_sends.append(create_lfa_mfa(self.packer, frame, enabled)) return can_sends diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index d529cf631f4039..b799a13fe309eb 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -1,251 +1,304 @@ -from selfdrive.car.hyundai.values import DBC, STEER_THRESHOLD -from selfdrive.can.parser import CANParser +import copy +from cereal import car +from selfdrive.car.hyundai.values import DBC, STEER_THRESHOLD, FEATURES, EV_HYBRID +from selfdrive.car.interfaces import CarStateBase +from opendbc.can.parser import CANParser from selfdrive.config import Conversions as CV -from common.kalman.simple_kalman import KF1D - - -def get_can_parser(CP): - - signals = [ - # sig_name, sig_address, default - ("WHL_SPD_FL", "WHL_SPD11", 0), - ("WHL_SPD_FR", "WHL_SPD11", 0), - ("WHL_SPD_RL", "WHL_SPD11", 0), - ("WHL_SPD_RR", "WHL_SPD11", 0), - - ("YAW_RATE", "ESP12", 0), - - ("CF_Gway_DrvSeatBeltInd", "CGW4", 1), - - ("CF_Gway_DrvSeatBeltSw", "CGW1", 0), - ("CF_Gway_TSigLHSw", "CGW1", 0), - ("CF_Gway_TurnSigLh", "CGW1", 0), - ("CF_Gway_TSigRHSw", "CGW1", 0), - ("CF_Gway_TurnSigRh", "CGW1", 0), - ("CF_Gway_ParkBrakeSw", "CGW1", 0), - - ("BRAKE_ACT", "EMS12", 0), - ("PV_AV_CAN", "EMS12", 0), - ("TPS", "EMS12", 0), - - ("CYL_PRES", "ESP12", 0), - - ("CF_Clu_CruiseSwState", "CLU11", 0), - ("CF_Clu_CruiseSwMain" , "CLU11", 0), - ("CF_Clu_SldMainSW", "CLU11", 0), - ("CF_Clu_ParityBit1", "CLU11", 0), - ("CF_Clu_VanzDecimal" , "CLU11", 0), - ("CF_Clu_Vanz", "CLU11", 0), - ("CF_Clu_SPEED_UNIT", "CLU11", 0), - ("CF_Clu_DetentOut", "CLU11", 0), - ("CF_Clu_RheostatLevel", "CLU11", 0), - ("CF_Clu_CluInfo", "CLU11", 0), - ("CF_Clu_AmpInfo", "CLU11", 0), - ("CF_Clu_AliveCnt1", "CLU11", 0), - - ("CF_Clu_InhibitD", "CLU15", 0), - ("CF_Clu_InhibitP", "CLU15", 0), - ("CF_Clu_InhibitN", "CLU15", 0), - ("CF_Clu_InhibitR", "CLU15", 0), - - ("CF_Lvr_Gear","LVR12",0), - ("CUR_GR", "TCU12",0), - - ("ACCEnable", "TCS13", 0), - ("ACC_REQ", "TCS13", 0), - ("DriverBraking", "TCS13", 0), - ("DriverOverride", "TCS13", 0), - - ("ESC_Off_Step", "TCS15", 0), - - ("CF_Lvr_GearInf", "LVR11", 0), #Transmission Gear (0 = N or P, 1-8 = Fwd, 14 = Rev) - - ("CR_Mdps_DrvTq", "MDPS11", 0), - - ("CR_Mdps_StrColTq", "MDPS12", 0), - ("CF_Mdps_ToiActive", "MDPS12", 0), - ("CF_Mdps_ToiUnavail", "MDPS12", 0), - ("CF_Mdps_FailStat", "MDPS12", 0), - ("CR_Mdps_OutTq", "MDPS12", 0), - - ("VSetDis", "SCC11", 0), - ("SCCInfoDisplay", "SCC11", 0), - ("ACCMode", "SCC12", 1), - - ("SAS_Angle", "SAS11", 0), - ("SAS_Speed", "SAS11", 0), - ] - - checks = [ - # address, frequency - ("MDPS12", 50), - ("MDPS11", 100), - ("TCS15", 10), - ("TCS13", 50), - ("CLU11", 50), - ("ESP12", 100), - ("EMS12", 100), - ("CGW1", 10), - ("CGW4", 5), - ("WHL_SPD11", 50), - ("SCC11", 50), - ("SCC12", 50), - ("SAS11", 100) - ] - - return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0) - - -def get_camera_parser(CP): - - signals = [ - # sig_name, sig_address, default - ("CF_Lkas_LdwsSysState", "LKAS11", 0), - ("CF_Lkas_SysWarning", "LKAS11", 0), - ("CF_Lkas_LdwsLHWarning", "LKAS11", 0), - ("CF_Lkas_LdwsRHWarning", "LKAS11", 0), - ("CF_Lkas_HbaLamp", "LKAS11", 0), - ("CF_Lkas_FcwBasReq", "LKAS11", 0), - ("CF_Lkas_ToiFlt", "LKAS11", 0), - ("CF_Lkas_HbaSysState", "LKAS11", 0), - ("CF_Lkas_FcwOpt", "LKAS11", 0), - ("CF_Lkas_HbaOpt", "LKAS11", 0), - ("CF_Lkas_FcwSysState", "LKAS11", 0), - ("CF_Lkas_FcwCollisionWarning", "LKAS11", 0), - ("CF_Lkas_FusionState", "LKAS11", 0), - ("CF_Lkas_FcwOpt_USM", "LKAS11", 0), - ("CF_Lkas_LdwsOpt_USM", "LKAS11", 0) - ] - - checks = [] - - return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2) - - -class CarState(object): - def __init__(self, CP): - - self.CP = CP - - # initialize can parser - self.car_fingerprint = CP.carFingerprint - - # vEgo kalman filter - dt = 0.01 - # Q = np.matrix([[10.0, 0.0], [0.0, 100.0]]) - # R = 1e3 - self.v_ego_kf = KF1D(x0=[[0.0], [0.0]], - A=[[1.0, dt], [0.0, 1.0]], - C=[1.0, 0.0], - K=[[0.12287673], [0.29666309]]) - self.v_ego = 0.0 - self.left_blinker_on = 0 - self.left_blinker_flash = 0 - self.right_blinker_on = 0 - self.right_blinker_flash = 0 +GearShifter = car.CarState.GearShifter + + +class CarState(CarStateBase): def update(self, cp, cp_cam): - # update prevs, update must run once per Loop - self.prev_left_blinker_on = self.left_blinker_on - self.prev_right_blinker_on = self.right_blinker_on + ret = car.CarState.new_message() + + ret.doorOpen = any([cp.vl["CGW1"]['CF_Gway_DrvDrSw'], cp.vl["CGW1"]['CF_Gway_AstDrSw'], + cp.vl["CGW2"]['CF_Gway_RLDrSw'], cp.vl["CGW2"]['CF_Gway_RRDrSw']]) + + ret.seatbeltUnlatched = cp.vl["CGW1"]['CF_Gway_DrvSeatBeltSw'] == 0 + + ret.wheelSpeeds.fl = cp.vl["WHL_SPD11"]['WHL_SPD_FL'] * CV.KPH_TO_MS + ret.wheelSpeeds.fr = cp.vl["WHL_SPD11"]['WHL_SPD_FR'] * CV.KPH_TO_MS + ret.wheelSpeeds.rl = cp.vl["WHL_SPD11"]['WHL_SPD_RL'] * CV.KPH_TO_MS + ret.wheelSpeeds.rr = cp.vl["WHL_SPD11"]['WHL_SPD_RR'] * CV.KPH_TO_MS + ret.vEgoRaw = (ret.wheelSpeeds.fl + ret.wheelSpeeds.fr + ret.wheelSpeeds.rl + ret.wheelSpeeds.rr) / 4. + ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) + + ret.standstill = ret.vEgoRaw < 0.1 + + ret.steeringAngle = cp.vl["SAS11"]['SAS_Angle'] + ret.steeringRate = cp.vl["SAS11"]['SAS_Speed'] + ret.yawRate = cp.vl["ESP12"]['YAW_RATE'] + ret.leftBlinker, ret.rightBlinker = self.update_blinker(50, cp.vl["CGW1"]['CF_Gway_TurnSigLh'], + cp.vl["CGW1"]['CF_Gway_TurnSigRh']) + ret.steeringTorque = cp.vl["MDPS12"]['CR_Mdps_StrColTq'] + ret.steeringTorqueEps = cp.vl["MDPS12"]['CR_Mdps_OutTq'] + ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD + ret.steerWarning = cp.vl["MDPS12"]['CF_Mdps_ToiUnavail'] != 0 + + # cruise state + ret.cruiseState.available = True + ret.cruiseState.enabled = cp.vl["SCC12"]['ACCMode'] != 0 + ret.cruiseState.standstill = cp.vl["SCC11"]['SCCInfoDisplay'] == 4. + + if ret.cruiseState.enabled: + speed_conv = CV.MPH_TO_MS if cp.vl["CLU11"]["CF_Clu_SPEED_UNIT"] else CV.KPH_TO_MS + ret.cruiseState.speed = cp.vl["SCC11"]['VSetDis'] * speed_conv + else: + ret.cruiseState.speed = 0 - self.door_all_closed = True - self.seatbelt = cp.vl["CGW1"]['CF_Gway_DrvSeatBeltSw'] + # TODO: Find brake pressure + ret.brake = 0 + ret.brakePressed = cp.vl["TCS13"]['DriverBraking'] != 0 - self.brake_pressed = cp.vl["TCS13"]['DriverBraking'] - self.esp_disabled = cp.vl["TCS15"]['ESC_Off_Step'] + # TODO: Check this + ret.brakeLights = bool(cp.vl["TCS13"]['BrakeLight'] or ret.brakePressed) - self.park_brake = cp.vl["CGW1"]['CF_Gway_ParkBrakeSw'] - self.main_on = True - self.acc_active = cp.vl["SCC12"]['ACCMode'] != 0 - self.pcm_acc_status = int(self.acc_active) - - # calc best v_ego estimate, by averaging two opposite corners - self.v_wheel_fl = cp.vl["WHL_SPD11"]['WHL_SPD_FL'] * CV.KPH_TO_MS - self.v_wheel_fr = cp.vl["WHL_SPD11"]['WHL_SPD_FR'] * CV.KPH_TO_MS - self.v_wheel_rl = cp.vl["WHL_SPD11"]['WHL_SPD_RL'] * CV.KPH_TO_MS - self.v_wheel_rr = cp.vl["WHL_SPD11"]['WHL_SPD_RR'] * CV.KPH_TO_MS - v_wheel = (self.v_wheel_fl + self.v_wheel_fr + self.v_wheel_rl + self.v_wheel_rr) / 4. - - self.low_speed_lockout = v_wheel < 1.0 - - # Kalman filter, even though Hyundai raw wheel speed is heaviliy filtered by default - if abs(v_wheel - self.v_ego) > 2.0: # Prevent large accelerations when car starts at non zero speed - self.v_ego_kf.x = [[v_wheel], [0.0]] - - self.v_ego_raw = v_wheel - v_ego_x = self.v_ego_kf.update(v_wheel) - self.v_ego = float(v_ego_x[0]) - self.a_ego = float(v_ego_x[1]) - is_set_speed_in_mph = int(cp.vl["CLU11"]["CF_Clu_SPEED_UNIT"]) - speed_conv = CV.MPH_TO_MS if is_set_speed_in_mph else CV.KPH_TO_MS - self.cruise_set_speed = cp.vl["SCC11"]['VSetDis'] * speed_conv - self.standstill = not v_wheel > 0.1 - - self.angle_steers = cp.vl["SAS11"]['SAS_Angle'] - - # The defined value in the DBC is always positive, so the calculated value needs to be used - self.angle_steers_rate = 0.0 #cp.vl["SAS11"]['SAS_Speed'] - self.yaw_rate = cp.vl["ESP12"]['YAW_RATE'] - self.main_on = True - self.left_blinker_on = cp.vl["CGW1"]['CF_Gway_TSigLHSw'] - self.left_blinker_flash = cp.vl["CGW1"]['CF_Gway_TurnSigLh'] - self.right_blinker_on = cp.vl["CGW1"]['CF_Gway_TSigRHSw'] - self.right_blinker_flash = cp.vl["CGW1"]['CF_Gway_TurnSigRh'] - self.steer_override = abs(cp.vl["MDPS11"]['CR_Mdps_DrvTq']) > STEER_THRESHOLD - self.steer_state = cp.vl["MDPS12"]['CF_Mdps_ToiActive'] #0 NOT ACTIVE, 1 ACTIVE - self.steer_error = cp.vl["MDPS12"]['CF_Mdps_ToiUnavail'] - self.brake_error = 0 - self.steer_torque_driver = cp.vl["MDPS11"]['CR_Mdps_DrvTq'] - self.steer_torque_motor = cp.vl["MDPS12"]['CR_Mdps_OutTq'] - self.stopped = cp.vl["SCC11"]['SCCInfoDisplay'] == 4. - - self.user_brake = 0 - - self.brake_pressed = cp.vl["TCS13"]['DriverBraking'] - self.brake_lights = bool(self.brake_pressed) - if (cp.vl["TCS13"]["DriverOverride"] == 0 and cp.vl["TCS13"]['ACC_REQ'] == 1): - self.pedal_gas = 0 + if self.CP.carFingerprint in EV_HYBRID: + ret.gas = cp.vl["E_EMS11"]['Accel_Pedal_Pos'] / 256. + ret.gasPressed = ret.gas > 0 else: - self.pedal_gas = cp.vl["EMS12"]['TPS'] - self.car_gas = cp.vl["EMS12"]['TPS'] - + ret.gas = cp.vl["EMS12"]['PV_AV_CAN'] / 100 + ret.gasPressed = bool(cp.vl["EMS16"]["CF_Ems_AclAct"]) + + # TODO: refactor gear parsing in function + # Gear Selection via Cluster - For those Kia/Hyundai which are not fully discovered, we can use the Cluster Indicator for Gear Selection, + # as this seems to be standard over all cars, but is not the preferred method. + if self.CP.carFingerprint in FEATURES["use_cluster_gears"]: + if cp.vl["CLU15"]["CF_Clu_InhibitD"] == 1: + ret.gearShifter = GearShifter.drive + elif cp.vl["CLU15"]["CF_Clu_InhibitN"] == 1: + ret.gearShifter = GearShifter.neutral + elif cp.vl["CLU15"]["CF_Clu_InhibitP"] == 1: + ret.gearShifter = GearShifter.park + elif cp.vl["CLU15"]["CF_Clu_InhibitR"] == 1: + ret.gearShifter = GearShifter.reverse + else: + ret.gearShifter = GearShifter.unknown + # Gear Selecton via TCU12 + elif self.CP.carFingerprint in FEATURES["use_tcu_gears"]: + gear = cp.vl["TCU12"]["CUR_GR"] + if gear == 0: + ret.gearShifter = GearShifter.park + elif gear == 14: + ret.gearShifter = GearShifter.reverse + elif gear > 0 and gear < 9: # unaware of anything over 8 currently + ret.gearShifter = GearShifter.drive + else: + ret.gearShifter = GearShifter.unknown + # Gear Selecton - This is only compatible with optima hybrid 2017 + elif self.CP.carFingerprint in FEATURES["use_elect_gears"]: + gear = cp.vl["ELECT_GEAR"]["Elect_Gear_Shifter"] + if gear in (5, 8): # 5: D, 8: sport mode + ret.gearShifter = GearShifter.drive + elif gear == 6: + ret.gearShifter = GearShifter.neutral + elif gear == 0: + ret.gearShifter = GearShifter.park + elif gear == 7: + ret.gearShifter = GearShifter.reverse + else: + ret.gearShifter = GearShifter.unknown # Gear Selecton - This is not compatible with all Kia/Hyundai's, But is the best way for those it is compatible with - gear = cp.vl["LVR12"]["CF_Lvr_Gear"] - if gear == 5: - self.gear_shifter = "drive" - elif gear == 6: - self.gear_shifter = "neutral" - elif gear == 0: - self.gear_shifter = "park" - elif gear == 7: - self.gear_shifter = "reverse" else: - self.gear_shifter = "unknown" - - # Gear Selection via Cluster - For those Kia/Hyundai which are not fully discovered, we can use the Cluster Indicator for Gear Selection, as this seems to be standard over all cars, but is not the preferred method. - if cp.vl["CLU15"]["CF_Clu_InhibitD"] == 1: - self.gear_shifter_cluster = "drive" - elif cp.vl["CLU15"]["CF_Clu_InhibitN"] == 1: - self.gear_shifter_cluster = "neutral" - elif cp.vl["CLU15"]["CF_Clu_InhibitP"] == 1: - self.gear_shifter_cluster = "park" - elif cp.vl["CLU15"]["CF_Clu_InhibitR"] == 1: - self.gear_shifter_cluster = "reverse" + gear = cp.vl["LVR12"]["CF_Lvr_Gear"] + if gear in (5, 8): # 5: D, 8: sport mode + ret.gearShifter = GearShifter.drive + elif gear == 6: + ret.gearShifter = GearShifter.neutral + elif gear == 0: + ret.gearShifter = GearShifter.park + elif gear == 7: + ret.gearShifter = GearShifter.reverse + else: + ret.gearShifter = GearShifter.unknown + + if self.CP.carFingerprint in FEATURES["use_fca"]: + ret.stockAeb = cp.vl["FCA11"]['FCA_CmdAct'] != 0 + ret.stockFcw = cp.vl["FCA11"]['CF_VSM_Warn'] == 2 else: - self.gear_shifter_cluster = "unknown" + ret.stockAeb = cp.vl["SCC12"]['AEB_CmdAct'] != 0 + ret.stockFcw = cp.vl["SCC12"]['CF_VSM_Warn'] == 2 - # Gear Selecton via TCU12 - gear2 = cp.vl["TCU12"]["CUR_GR"] - if gear2 == 0: - self.gear_tcu = "park" - elif gear2 == 14: - self.gear_tcu = "reverse" - elif gear2 > 0 and gear2 < 9: # unaware of anything over 8 currently - self.gear_tcu = "drive" - else: - self.gear_tcu = "unknown" + if self.CP.carFingerprint in FEATURES["use_bsm"]: + ret.leftBlindspot = cp.vl["LCA11"]["CF_Lca_IndLeft"] != 0 + ret.rightBlindspot = cp.vl["LCA11"]["CF_Lca_IndRight"] != 0 # save the entire LKAS11 and CLU11 - self.lkas11 = cp_cam.vl["LKAS11"] - self.clu11 = cp.vl["CLU11"] + self.lkas11 = copy.copy(cp_cam.vl["LKAS11"]) + self.clu11 = copy.copy(cp.vl["CLU11"]) + self.park_brake = cp.vl["CGW1"]['CF_Gway_ParkBrakeSw'] + self.steer_state = cp.vl["MDPS12"]['CF_Mdps_ToiActive'] # 0 NOT ACTIVE, 1 ACTIVE + self.lead_distance = cp.vl["SCC11"]['ACC_ObjDist'] + + return ret + + @staticmethod + def get_can_parser(CP): + signals = [ + # sig_name, sig_address, default + ("WHL_SPD_FL", "WHL_SPD11", 0), + ("WHL_SPD_FR", "WHL_SPD11", 0), + ("WHL_SPD_RL", "WHL_SPD11", 0), + ("WHL_SPD_RR", "WHL_SPD11", 0), + + ("YAW_RATE", "ESP12", 0), + + ("CF_Gway_DrvSeatBeltInd", "CGW4", 1), + + ("CF_Gway_DrvSeatBeltSw", "CGW1", 0), + ("CF_Gway_DrvDrSw", "CGW1", 0), # Driver Door + ("CF_Gway_AstDrSw", "CGW1", 0), # Passenger door + ("CF_Gway_RLDrSw", "CGW2", 0), # Rear reft door + ("CF_Gway_RRDrSw", "CGW2", 0), # Rear right door + ("CF_Gway_TurnSigLh", "CGW1", 0), + ("CF_Gway_TurnSigRh", "CGW1", 0), + ("CF_Gway_ParkBrakeSw", "CGW1", 0), + + ("CYL_PRES", "ESP12", 0), + + ("CF_Clu_CruiseSwState", "CLU11", 0), + ("CF_Clu_CruiseSwMain", "CLU11", 0), + ("CF_Clu_SldMainSW", "CLU11", 0), + ("CF_Clu_ParityBit1", "CLU11", 0), + ("CF_Clu_VanzDecimal" , "CLU11", 0), + ("CF_Clu_Vanz", "CLU11", 0), + ("CF_Clu_SPEED_UNIT", "CLU11", 0), + ("CF_Clu_DetentOut", "CLU11", 0), + ("CF_Clu_RheostatLevel", "CLU11", 0), + ("CF_Clu_CluInfo", "CLU11", 0), + ("CF_Clu_AmpInfo", "CLU11", 0), + ("CF_Clu_AliveCnt1", "CLU11", 0), + + ("ACCEnable", "TCS13", 0), + ("BrakeLight", "TCS13", 0), + ("DriverBraking", "TCS13", 0), + + ("ESC_Off_Step", "TCS15", 0), + + ("CF_Lvr_GearInf", "LVR11", 0), # Transmission Gear (0 = N or P, 1-8 = Fwd, 14 = Rev) + + ("CR_Mdps_StrColTq", "MDPS12", 0), + ("CF_Mdps_ToiActive", "MDPS12", 0), + ("CF_Mdps_ToiUnavail", "MDPS12", 0), + ("CF_Mdps_FailStat", "MDPS12", 0), + ("CR_Mdps_OutTq", "MDPS12", 0), + + ("SAS_Angle", "SAS11", 0), + ("SAS_Speed", "SAS11", 0), + + ("MainMode_ACC", "SCC11", 0), + ("VSetDis", "SCC11", 0), + ("SCCInfoDisplay", "SCC11", 0), + ("ACC_ObjDist", "SCC11", 0), + ("ACCMode", "SCC12", 1), + ] + + checks = [ + # address, frequency + ("MDPS12", 50), + ("TCS13", 50), + ("TCS15", 10), + ("CLU11", 50), + ("ESP12", 100), + ("CGW1", 10), + ("CGW4", 5), + ("WHL_SPD11", 50), + ("SAS11", 100), + ("SCC11", 50), + ("SCC12", 50), + ] + + if CP.carFingerprint in FEATURES["use_bsm"]: + signals += [ + ("CF_Lca_IndLeft", "LCA11", 0), + ("CF_Lca_IndRight", "LCA11", 0), + ] + checks += [("LCA11", 50)] + + if CP.carFingerprint in EV_HYBRID: + signals += [ + ("Accel_Pedal_Pos", "E_EMS11", 0), + ] + checks += [ + ("E_EMS11", 50), + ] + else: + signals += [ + ("PV_AV_CAN", "EMS12", 0), + ("CF_Ems_AclAct", "EMS16", 0), + ] + checks += [ + ("EMS12", 100), + ("EMS16", 100), + ] + + if CP.carFingerprint in FEATURES["use_cluster_gears"]: + signals += [ + ("CF_Clu_InhibitD", "CLU15", 0), + ("CF_Clu_InhibitP", "CLU15", 0), + ("CF_Clu_InhibitN", "CLU15", 0), + ("CF_Clu_InhibitR", "CLU15", 0), + ] + checks += [ + ("CLU15", 5) + ] + elif CP.carFingerprint in FEATURES["use_tcu_gears"]: + signals += [ + ("CUR_GR", "TCU12", 0) + ] + checks += [ + ("TCU12", 100) + ] + elif CP.carFingerprint in FEATURES["use_elect_gears"]: + signals += [("Elect_Gear_Shifter", "ELECT_GEAR", 0)] + checks += [("ELECT_GEAR", 20)] + else: + signals += [ + ("CF_Lvr_Gear", "LVR12", 0) + ] + checks += [ + ("LVR12", 100) + ] + + if CP.carFingerprint in FEATURES["use_fca"]: + signals += [ + ("FCA_CmdAct", "FCA11", 0), + ("CF_VSM_Warn", "FCA11", 0), + ] + checks += [("FCA11", 50)] + else: + signals += [ + ("AEB_CmdAct", "SCC12", 0), + ("CF_VSM_Warn", "SCC12", 0), + ] + + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0) + + @staticmethod + def get_cam_can_parser(CP): + + signals = [ + # sig_name, sig_address, default + ("CF_Lkas_LdwsActivemode", "LKAS11", 0), + ("CF_Lkas_LdwsSysState", "LKAS11", 0), + ("CF_Lkas_SysWarning", "LKAS11", 0), + ("CF_Lkas_LdwsLHWarning", "LKAS11", 0), + ("CF_Lkas_LdwsRHWarning", "LKAS11", 0), + ("CF_Lkas_HbaLamp", "LKAS11", 0), + ("CF_Lkas_FcwBasReq", "LKAS11", 0), + ("CF_Lkas_HbaSysState", "LKAS11", 0), + ("CF_Lkas_FcwOpt", "LKAS11", 0), + ("CF_Lkas_HbaOpt", "LKAS11", 0), + ("CF_Lkas_FcwSysState", "LKAS11", 0), + ("CF_Lkas_FcwCollisionWarning", "LKAS11", 0), + ("CF_Lkas_FusionState", "LKAS11", 0), + ("CF_Lkas_FcwOpt_USM", "LKAS11", 0), + ("CF_Lkas_LdwsOpt_USM", "LKAS11", 0) + ] + + checks = [ + ("LKAS11", 100) + ] + + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2) diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index d9e7cf3a92a64d..9f064edff1fa61 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -1,79 +1,87 @@ import crcmod -from selfdrive.car.hyundai.values import CHECKSUM +from selfdrive.car.hyundai.values import CAR, CHECKSUM hyundai_checksum = crcmod.mkCrcFun(0x11D, initCrc=0xFD, rev=False, xorOut=0xdf) -def make_can_msg(addr, dat, alt): - return [addr, 0, dat, alt] -def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled, lkas11, hud_alert, keep_stock=False): - values = { - "CF_Lkas_Bca_R": 3 if enabled else 0, - "CF_Lkas_LdwsSysState": 3 if steer_req else 1, - "CF_Lkas_SysWarning": hud_alert, - "CF_Lkas_LdwsLHWarning": lkas11["CF_Lkas_LdwsLHWarning"] if keep_stock else 0, - "CF_Lkas_LdwsRHWarning": lkas11["CF_Lkas_LdwsRHWarning"] if keep_stock else 0, - "CF_Lkas_HbaLamp": lkas11["CF_Lkas_HbaLamp"] if keep_stock else 0, - "CF_Lkas_FcwBasReq": lkas11["CF_Lkas_FcwBasReq"] if keep_stock else 0, - "CR_Lkas_StrToqReq": apply_steer, - "CF_Lkas_ActToi": steer_req, - "CF_Lkas_ToiFlt": 0, - "CF_Lkas_HbaSysState": lkas11["CF_Lkas_HbaSysState"] if keep_stock else 1, - "CF_Lkas_FcwOpt": lkas11["CF_Lkas_FcwOpt"] if keep_stock else 0, - "CF_Lkas_HbaOpt": lkas11["CF_Lkas_HbaOpt"] if keep_stock else 3, - "CF_Lkas_MsgCount": cnt, - "CF_Lkas_FcwSysState": lkas11["CF_Lkas_FcwSysState"] if keep_stock else 0, - "CF_Lkas_FcwCollisionWarning": lkas11["CF_Lkas_FcwCollisionWarning"] if keep_stock else 0, - "CF_Lkas_FusionState": lkas11["CF_Lkas_FusionState"] if keep_stock else 0, - "CF_Lkas_Chksum": 0, - "CF_Lkas_FcwOpt_USM": 2 if enabled else 1, - "CF_Lkas_LdwsOpt_USM": lkas11["CF_Lkas_LdwsOpt_USM"] if keep_stock else 3, - } +def create_lkas11(packer, frame, car_fingerprint, apply_steer, steer_req, + lkas11, sys_warning, sys_state, enabled, + left_lane, right_lane, + left_lane_depart, right_lane_depart): + values = lkas11 + values["CF_Lkas_LdwsSysState"] = sys_state + values["CF_Lkas_SysWarning"] = 3 if sys_warning else 0 + values["CF_Lkas_LdwsLHWarning"] = left_lane_depart + values["CF_Lkas_LdwsRHWarning"] = right_lane_depart + values["CR_Lkas_StrToqReq"] = apply_steer + values["CF_Lkas_ActToi"] = steer_req + values["CF_Lkas_MsgCount"] = frame % 0x10 + + if car_fingerprint in [CAR.SONATA, CAR.PALISADE, CAR.KIA_NIRO_EV, CAR.SANTA_FE, CAR.IONIQ_EV_2020]: + values["CF_Lkas_LdwsActivemode"] = int(left_lane) + (int(right_lane) << 1) + values["CF_Lkas_LdwsOpt_USM"] = 2 + + # FcwOpt_USM 5 = Orange blinking car + lanes + # FcwOpt_USM 4 = Orange car + lanes + # FcwOpt_USM 3 = Green blinking car + lanes + # FcwOpt_USM 2 = Green car + lanes + # FcwOpt_USM 1 = White car + lanes + # FcwOpt_USM 0 = No car + lanes + values["CF_Lkas_FcwOpt_USM"] = 2 if enabled else 1 + + # SysWarning 4 = keep hands on wheel + # SysWarning 5 = keep hands on wheel (red) + # SysWarning 6 = keep hands on wheel (red) + beep + # Note: the warning is hidden while the blinkers are on + values["CF_Lkas_SysWarning"] = 4 if sys_warning else 0 + + elif car_fingerprint == CAR.HYUNDAI_GENESIS: + # This field is actually LdwsActivemode + # Genesis and Optima fault when forwarding while engaged + values["CF_Lkas_LdwsActivemode"] = 2 + elif car_fingerprint == CAR.KIA_OPTIMA: + values["CF_Lkas_LdwsActivemode"] = 0 dat = packer.make_can_msg("LKAS11", 0, values)[2] if car_fingerprint in CHECKSUM["crc8"]: # CRC Checksum as seen on 2019 Hyundai Santa Fe - dat = dat[:6] + dat[7] + dat = dat[:6] + dat[7:8] checksum = hyundai_checksum(dat) elif car_fingerprint in CHECKSUM["6B"]: # Checksum of first 6 Bytes, as seen on 2018 Kia Sorento - dat = [ord(i) for i in dat] checksum = sum(dat[:6]) % 256 - elif car_fingerprint in CHECKSUM["7B"]: + else: # Checksum of first 6 Bytes and last Byte as seen on 2018 Kia Stinger - dat = [ord(i) for i in dat] checksum = (sum(dat[:6]) + dat[7]) % 256 values["CF_Lkas_Chksum"] = checksum return packer.make_can_msg("LKAS11", 0, values) -def create_lkas12(): - return make_can_msg(1342, "\x00\x00\x00\x00\x60\x05", 0) - - -def create_1191(): - return make_can_msg(1191, "\x01\x00", 0) +def create_clu11(packer, frame, clu11, button): + values = clu11 + values["CF_Clu_CruiseSwState"] = button + values["CF_Clu_AliveCnt1"] = frame % 0x10 + return packer.make_can_msg("CLU11", 0, values) -def create_1156(): - return make_can_msg(1156, "\x08\x20\xfe\x3f\x00\xe0\xfd\x3f", 0) -def create_clu11(packer, clu11, button): +def create_lfa_mfa(packer, frame, enabled): values = { - "CF_Clu_CruiseSwState": button, - "CF_Clu_CruiseSwMain": clu11["CF_Clu_CruiseSwMain"], - "CF_Clu_SldMainSW": clu11["CF_Clu_SldMainSW"], - "CF_Clu_ParityBit1": clu11["CF_Clu_ParityBit1"], - "CF_Clu_VanzDecimal": clu11["CF_Clu_VanzDecimal"], - "CF_Clu_Vanz": clu11["CF_Clu_Vanz"], - "CF_Clu_SPEED_UNIT": clu11["CF_Clu_SPEED_UNIT"], - "CF_Clu_DetentOut": clu11["CF_Clu_DetentOut"], - "CF_Clu_RheostatLevel": clu11["CF_Clu_RheostatLevel"], - "CF_Clu_CluInfo": clu11["CF_Clu_CluInfo"], - "CF_Clu_AmpInfo": clu11["CF_Clu_AmpInfo"], - "CF_Clu_AliveCnt1": 0, + "ACTIVE": enabled, } - return packer.make_can_msg("CLU11", 0, values) + # ACTIVE 1 = Green steering wheel icon + + # LFA_USM 2 & 3 = LFA cancelled, fast loud beeping + # LFA_USM 0 & 1 = No mesage + + # LFA_SysWarning 1 = "Switching to HDA", short beep + # LFA_SysWarning 2 = "Switching to Smart Cruise control", short beep + # LFA_SysWarning 3 = LFA error + + # ACTIVE2: nothing + # HDA_USM: nothing + + return packer.make_can_msg("LFAHDA_MFC", 0, values) diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index 9c7a5376b87155..47c468dde7b053 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -1,99 +1,135 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from cereal import car -from common.realtime import sec_since_boot from selfdrive.config import Conversions as CV -from selfdrive.controls.lib.drive_helpers import EventTypes as ET, create_event -from selfdrive.controls.lib.vehicle_model import VehicleModel -from selfdrive.car.hyundai.carstate import CarState, get_can_parser, get_camera_parser -from selfdrive.car.hyundai.values import CAMERA_MSGS, CAR, get_hud_alerts, FEATURES -from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness +from selfdrive.car.hyundai.values import CAR +from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint +from selfdrive.car.interfaces import CarInterfaceBase - -class CarInterface(object): - def __init__(self, CP, CarController): - self.CP = CP - self.VM = VehicleModel(CP) - self.idx = 0 - self.lanes = 0 - self.lkas_request = 0 - - self.gas_pressed_prev = False - self.brake_pressed_prev = False - self.cruise_enabled_prev = False - self.low_speed_alert = False - - # *** init the major players *** - self.CS = CarState(CP) - self.cp = get_can_parser(CP) - self.cp_cam = get_camera_parser(CP) - - self.CC = None - if CarController is not None: - self.CC = CarController(self.cp.dbc_name, CP.carFingerprint) +class CarInterface(CarInterfaceBase): @staticmethod def compute_gb(accel, speed): return float(accel) / 3.0 @staticmethod - def calc_accel_override(a_ego, a_target, v_ego, v_target): - return 1.0 - - @staticmethod - def get_params(candidate, fingerprint, vin="", is_panda_black=False): - - ret = car.CarParams.new_message() + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # pylint: disable=dangerous-default-value + ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "hyundai" - ret.carFingerprint = candidate - ret.carVin = vin - ret.isPandaBlack = is_panda_black - ret.radarOffCan = True ret.safetyModel = car.CarParams.SafetyModel.hyundai - ret.enableCruise = True # stock acc + ret.radarOffCan = True + + # Most Hyundai car ports are community features for now + ret.communityFeature = candidate not in [CAR.SONATA, CAR.PALISADE] ret.steerActuatorDelay = 0.1 # Default delay ret.steerRateCost = 0.5 + ret.steerLimitTimer = 0.4 tire_stiffness_factor = 1. if candidate == CAR.SANTA_FE: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 3982. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.766 - # Values from optimizer ret.steerRatio = 16.55 # 13.8 is spec end-to-end tire_stiffness_factor = 0.82 - ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[9., 22.], [9., 22.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2, 0.35], [0.05, 0.09]] - ret.minSteerSpeed = 0. - elif candidate == CAR.KIA_SORENTO: + elif candidate == CAR.SONATA: ret.lateralTuning.pid.kf = 0.00005 - ret.mass = 1985. + STD_CARGO_KG - ret.wheelbase = 2.78 - ret.steerRatio = 14.4 * 1.1 # 10% higher at the center seems reasonable + ret.mass = 1513. + STD_CARGO_KG + ret.wheelbase = 2.84 + ret.steerRatio = 13.27 * 1.15 # 15% higher at the center seems reasonable + tire_stiffness_factor = 0.65 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] + elif candidate == CAR.SONATA_2019: + ret.lateralTuning.pid.kf = 0.00005 + ret.mass = 4497. * CV.LB_TO_KG + ret.wheelbase = 2.804 + ret.steerRatio = 13.27 * 1.15 # 15% higher at the center seems reasonable ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] - ret.minSteerSpeed = 0. - elif candidate == CAR.ELANTRA: + elif candidate == CAR.PALISADE: + ret.lateralTuning.pid.kf = 0.00005 + ret.mass = 1999. + STD_CARGO_KG + ret.wheelbase = 2.90 + ret.steerRatio = 13.75 * 1.15 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] + elif candidate in [CAR.ELANTRA, CAR.ELANTRA_GT_I30]: ret.lateralTuning.pid.kf = 0.00006 ret.mass = 1275. + STD_CARGO_KG ret.wheelbase = 2.7 - ret.steerRatio = 13.73 #Spec - tire_stiffness_factor = 0.385 + ret.steerRatio = 15.4 # 14 is Stock | Settled Params Learner values are steerRatio: 15.401566348670535 + tire_stiffness_factor = 0.385 # stiffnessFactor settled on 1.0081302973865127 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] ret.minSteerSpeed = 32 * CV.MPH_TO_MS - elif candidate == CAR.GENESIS: + elif candidate == CAR.HYUNDAI_GENESIS: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 2060. + STD_CARGO_KG ret.wheelbase = 3.01 ret.steerRatio = 16.5 + ret.lateralTuning.init('indi') + ret.lateralTuning.indi.innerLoopGain = 3.5 + ret.lateralTuning.indi.outerLoopGain = 2.0 + ret.lateralTuning.indi.timeConstant = 1.4 + ret.lateralTuning.indi.actuatorEffectiveness = 2.3 + ret.minSteerSpeed = 60 * CV.KPH_TO_MS + elif candidate == CAR.KONA: + ret.lateralTuning.pid.kf = 0.00005 + ret.mass = 1275. + STD_CARGO_KG + ret.wheelbase = 2.7 + ret.steerRatio = 13.73 * 1.15 # Spec + tire_stiffness_factor = 0.385 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] - ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16], [0.01]] - ret.minSteerSpeed = 35 * CV.MPH_TO_MS - elif candidate == CAR.KIA_OPTIMA: + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] + elif candidate == CAR.KONA_EV: + ret.lateralTuning.pid.kf = 0.00006 + ret.mass = 1685. + STD_CARGO_KG + ret.wheelbase = 2.7 + ret.steerRatio = 13.73 # Spec + tire_stiffness_factor = 0.385 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] + elif candidate in [CAR.IONIQ, CAR.IONIQ_EV_LTD, CAR.IONIQ_EV_2020]: + ret.lateralTuning.pid.kf = 0.00006 + ret.mass = 1490. + STD_CARGO_KG # weight per hyundai site https://www.hyundaiusa.com/ioniq-electric/specifications.aspx + ret.wheelbase = 2.7 + ret.steerRatio = 13.73 # Spec + tire_stiffness_factor = 0.385 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] + if candidate != CAR.IONIQ_EV_2020: + ret.minSteerSpeed = 32 * CV.MPH_TO_MS + elif candidate == CAR.VELOSTER: + ret.lateralTuning.pid.kf = 0.00005 + ret.mass = 3558. * CV.LB_TO_KG + ret.wheelbase = 2.80 + ret.steerRatio = 13.75 * 1.15 + tire_stiffness_factor = 0.5 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] + + # Kia + elif candidate == CAR.KIA_SORENTO: + ret.lateralTuning.pid.kf = 0.00005 + ret.mass = 1985. + STD_CARGO_KG + ret.wheelbase = 2.78 + ret.steerRatio = 14.4 * 1.1 # 10% higher at the center seems reasonable + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] + elif candidate == CAR.KIA_NIRO_EV: + ret.lateralTuning.pid.kf = 0.00006 + ret.mass = 1737. + STD_CARGO_KG + ret.wheelbase = 2.7 + ret.steerRatio = 13.73 # Spec + tire_stiffness_factor = 0.385 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] + elif candidate in [CAR.KIA_OPTIMA, CAR.KIA_OPTIMA_H]: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 3558. * CV.LB_TO_KG ret.wheelbase = 2.80 @@ -108,15 +144,45 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): ret.steerRatio = 14.4 * 1.15 # 15% higher at the center seems reasonable ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] - ret.minSteerSpeed = 0. - ret.minEnableSpeed = -1. # enable is done by stock ACC, so ignore this - ret.longitudinalTuning.kpBP = [0.] - ret.longitudinalTuning.kpV = [0.] - ret.longitudinalTuning.kiBP = [0.] - ret.longitudinalTuning.kiV = [0.] - ret.longitudinalTuning.deadzoneBP = [0.] - ret.longitudinalTuning.deadzoneV = [0.] + elif candidate == CAR.KIA_FORTE: + ret.lateralTuning.pid.kf = 0.00005 + ret.mass = 3558. * CV.LB_TO_KG + ret.wheelbase = 2.80 + ret.steerRatio = 13.75 + tire_stiffness_factor = 0.5 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] + + # Genesis + elif candidate == CAR.GENESIS_G70: + ret.lateralTuning.init('indi') + ret.lateralTuning.indi.innerLoopGain = 2.5 + ret.lateralTuning.indi.outerLoopGain = 3.5 + ret.lateralTuning.indi.timeConstant = 1.4 + ret.lateralTuning.indi.actuatorEffectiveness = 1.8 + ret.steerActuatorDelay = 0.1 + ret.mass = 1640.0 + STD_CARGO_KG + ret.wheelbase = 2.84 + ret.steerRatio = 13.56 + elif candidate == CAR.GENESIS_G80: + ret.lateralTuning.pid.kf = 0.00005 + ret.mass = 2060. + STD_CARGO_KG + ret.wheelbase = 3.01 + ret.steerRatio = 16.5 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16], [0.01]] + elif candidate == CAR.GENESIS_G90: + ret.mass = 2200 + ret.wheelbase = 3.15 + ret.steerRatio = 12.069 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16], [0.01]] + + # these cars require a special panda safety mode due to missing counters and checksums in the messages + if candidate in [CAR.HYUNDAI_GENESIS, CAR.IONIQ_EV_2020, CAR.IONIQ_EV_LTD, CAR.IONIQ, CAR.KONA_EV, CAR.KIA_SORENTO, CAR.SONATA_2019, + CAR.KIA_NIRO_EV, CAR.KIA_OPTIMA, CAR.VELOSTER, CAR.KIA_STINGER, CAR.GENESIS_G70, CAR.GENESIS_G80]: + ret.safetyModel = car.CarParams.SafetyModel.hyundaiLegacy ret.centerToFront = ret.wheelbase * 0.4 @@ -129,159 +195,37 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront, tire_stiffness_factor=tire_stiffness_factor) - - # no rear steering, at least on the listed cars above - ret.steerRatioRear = 0. - ret.steerControlType = car.CarParams.SteerControlType.torque - - # steer, gas, brake limitations VS speed - ret.steerMaxBP = [0.] - ret.steerMaxV = [1.0] - ret.gasMaxBP = [0.] - ret.gasMaxV = [1.] - ret.brakeMaxBP = [0.] - ret.brakeMaxV = [1.] - - ret.enableCamera = not any(x for x in CAMERA_MSGS if x in fingerprint) or is_panda_black - ret.openpilotLongitudinalControl = False - - ret.steerLimitAlert = False - ret.stoppingControl = False - ret.startAccel = 0.0 + ret.enableCamera = True return ret - # returns a car.CarState def update(self, c, can_strings): - # ******************* do can recv ******************* - self.cp.update_strings(int(sec_since_boot() * 1e9), can_strings) - self.cp_cam.update_strings(int(sec_since_boot() * 1e9), can_strings) - - self.CS.update(self.cp, self.cp_cam) - # create message - ret = car.CarState.new_message() - - ret.canValid = self.cp.can_valid # TODO: check cp_cam validity - - # speeds - ret.vEgo = self.CS.v_ego - ret.vEgoRaw = self.CS.v_ego_raw - ret.aEgo = self.CS.a_ego - ret.yawRate = self.CS.yaw_rate - ret.standstill = self.CS.standstill - ret.wheelSpeeds.fl = self.CS.v_wheel_fl - ret.wheelSpeeds.fr = self.CS.v_wheel_fr - ret.wheelSpeeds.rl = self.CS.v_wheel_rl - ret.wheelSpeeds.rr = self.CS.v_wheel_rr - - # gear shifter - if self.CP.carFingerprint in FEATURES["use_cluster_gears"]: - ret.gearShifter = self.CS.gear_shifter_cluster - elif self.CP.carFingerprint in FEATURES["use_tcu_gears"]: - ret.gearShifter = self.CS.gear_tcu - else: - ret.gearShifter = self.CS.gear_shifter - - # gas pedal - ret.gas = self.CS.car_gas - ret.gasPressed = self.CS.pedal_gas > 1e-3 # tolerance to avoid false press reading - - # brake pedal - ret.brake = self.CS.user_brake - ret.brakePressed = self.CS.brake_pressed != 0 - ret.brakeLights = self.CS.brake_lights - - # steering wheel - ret.steeringAngle = self.CS.angle_steers - # use calculated steering rate since this is unsigned - ret.steeringRate = 0 - - ret.steeringTorque = self.CS.steer_torque_driver - ret.steeringPressed = self.CS.steer_override - - # cruise state - ret.cruiseState.enabled = self.CS.pcm_acc_status != 0 - if self.CS.pcm_acc_status != 0: - ret.cruiseState.speed = self.CS.cruise_set_speed - else: - ret.cruiseState.speed = 0 - ret.cruiseState.available = bool(self.CS.main_on) - ret.cruiseState.standstill = False + self.cp.update_strings(can_strings) + self.cp_cam.update_strings(can_strings) - # TODO: button presses - buttonEvents = [] + ret = self.CS.update(self.cp, self.cp_cam) + ret.canValid = self.cp.can_valid and self.cp_cam.can_valid + ret.steeringRateLimited = self.CC.steer_rate_limited if self.CC is not None else False - if self.CS.left_blinker_on != self.CS.prev_left_blinker_on: - be = car.CarState.ButtonEvent.new_message() - be.type = 'leftBlinker' - be.pressed = self.CS.left_blinker_on != 0 - buttonEvents.append(be) - - if self.CS.right_blinker_on != self.CS.prev_right_blinker_on: - be = car.CarState.ButtonEvent.new_message() - be.type = 'rightBlinker' - be.pressed = self.CS.right_blinker_on != 0 - buttonEvents.append(be) - - ret.buttonEvents = buttonEvents - ret.leftBlinker = bool(self.CS.left_blinker_on) - ret.rightBlinker = bool(self.CS.right_blinker_on) - - ret.doorOpen = not self.CS.door_all_closed - ret.seatbeltUnlatched = not self.CS.seatbelt + events = self.create_common_events(ret) + # TODO: addd abs(self.CS.angle_steers) > 90 to 'steerTempUnavailable' event # low speed steer alert hysteresis logic (only for cars with steer cut off above 10 m/s) if ret.vEgo < (self.CP.minSteerSpeed + 2.) and self.CP.minSteerSpeed > 10.: self.low_speed_alert = True if ret.vEgo > (self.CP.minSteerSpeed + 4.): self.low_speed_alert = False - - events = [] - if not ret.gearShifter == 'drive': - events.append(create_event('wrongGear', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if ret.doorOpen: - events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if ret.seatbeltUnlatched: - events.append(create_event('seatbeltNotLatched', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if self.CS.esp_disabled: - events.append(create_event('espDisabled', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if not self.CS.main_on: - events.append(create_event('wrongCarMode', [ET.NO_ENTRY, ET.USER_DISABLE])) - if ret.gearShifter == 'reverse': - events.append(create_event('reverseGear', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) - if self.CS.steer_error: - events.append(create_event('steerTempUnavailable', [ET.NO_ENTRY, ET.WARNING])) - - # enable request in prius is simple, as we activate when Toyota is active (rising edge) - if ret.cruiseState.enabled and not self.cruise_enabled_prev: - events.append(create_event('pcmEnable', [ET.ENABLE])) - elif not ret.cruiseState.enabled: - events.append(create_event('pcmDisable', [ET.USER_DISABLE])) - - # disable on pedals rising edge or when brake is pressed and speed isn't zero - if (ret.gasPressed and not self.gas_pressed_prev) or \ - (ret.brakePressed and (not self.brake_pressed_prev or ret.vEgoRaw > 0.1)): - events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) - - if ret.gasPressed: - events.append(create_event('pedalPressed', [ET.PRE_ENABLE])) - if self.low_speed_alert: - events.append(create_event('belowSteerSpeed', [ET.WARNING])) - - ret.events = events + events.add(car.CarEvent.EventName.belowSteerSpeed) - self.gas_pressed_prev = ret.gasPressed - self.brake_pressed_prev = ret.brakePressed - self.cruise_enabled_prev = ret.cruiseState.enabled + ret.events = events.to_msg() - return ret.as_reader() + self.CS.out = ret.as_reader() + return self.CS.out def apply(self, c): - - hud_alert = get_hud_alerts(c.hudControl.visualAlert) - - can_sends = self.CC.update(c.enabled, self.CS, c.actuators, - c.cruiseControl.cancel, hud_alert) - + can_sends = self.CC.update(c.enabled, self.CS, self.frame, c.actuators, + c.cruiseControl.cancel, c.hudControl.visualAlert, c.hudControl.leftLaneVisible, + c.hudControl.rightLaneVisible, c.hudControl.leftLaneDepart, c.hudControl.rightLaneDepart) + self.frame += 1 return can_sends diff --git a/selfdrive/car/hyundai/radar_interface.py b/selfdrive/car/hyundai/radar_interface.py index 1d7772fd3bb626..fdbe837af6ad66 100644 --- a/selfdrive/car/hyundai/radar_interface.py +++ b/selfdrive/car/hyundai/radar_interface.py @@ -1,16 +1,70 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from cereal import car -import time +from opendbc.can.parser import CANParser +from selfdrive.car.interfaces import RadarInterfaceBase +from selfdrive.car.hyundai.values import DBC -class RadarInterface(object): +def get_radar_can_parser(CP): + signals = [ + # sig_name, sig_address, default + ("ACC_ObjStatus", "SCC11", 0), + ("ACC_ObjLatPos", "SCC11", 0), + ("ACC_ObjDist", "SCC11", 0), + ("ACC_ObjRelSpd", "SCC11", 0), + ] + checks = [ + # address, frequency + ("SCC11", 50), + ] + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0) + + +class RadarInterface(RadarInterfaceBase): def __init__(self, CP): - # radar - self.pts = {} - self.delay = 0.1 + super().__init__(CP) + self.rcp = get_radar_can_parser(CP) + self.updated_messages = set() + self.trigger_msg = 0x420 + self.track_id = 0 + self.radar_off_can = CP.radarOffCan def update(self, can_strings): + if self.radar_off_can: + return super().update(None) + + vls = self.rcp.update_strings(can_strings) + self.updated_messages.update(vls) + + if self.trigger_msg not in self.updated_messages: + return None + + rr = self._update(self.updated_messages) + self.updated_messages.clear() + + return rr + + def _update(self, updated_messages): ret = car.RadarData.new_message() - time.sleep(0.05) # radard runs on RI updates + cpt = self.rcp.vl + errors = [] + if not self.rcp.can_valid: + errors.append("canError") + ret.errors = errors + + valid = cpt["SCC11"]['ACC_ObjStatus'] + if valid: + for ii in range(2): + if ii not in self.pts: + self.pts[ii] = car.RadarData.RadarPoint.new_message() + self.pts[ii].trackId = self.track_id + self.track_id += 1 + self.pts[ii].dRel = cpt["SCC11"]['ACC_ObjDist'] # from front of car + self.pts[ii].yRel = -cpt["SCC11"]['ACC_ObjLatPos'] # in car frame's y axis, left is negative + self.pts[ii].vRel = cpt["SCC11"]['ACC_ObjRelSpd'] + self.pts[ii].aRel = float('nan') + self.pts[ii].yvRel = float('nan') + self.pts[ii].measured = True + ret.points = list(self.pts.values()) return ret diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index 6380ca446318e9..94712a0c75d087 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -1,21 +1,52 @@ +# flake8: noqa + from cereal import car from selfdrive.car import dbc_dict +Ecu = car.CarParams.Ecu -VisualAlert = car.CarControl.HUDControl.VisualAlert +# Steer torque limits +class SteerLimitParams: + def __init__(self, CP): + if CP.carFingerprint in [CAR.SONATA, CAR.PALISADE, CAR.SANTA_FE, CAR.VELOSTER, CAR.GENESIS_G70, CAR.IONIQ_EV_2020]: + self.STEER_MAX = 384 + else: + self.STEER_MAX = 255 + self.STEER_DELTA_UP = 3 + self.STEER_DELTA_DOWN = 7 + self.STEER_DRIVER_ALLOWANCE = 50 + self.STEER_DRIVER_MULTIPLIER = 2 + self.STEER_DRIVER_FACTOR = 1 -def get_hud_alerts(visual_alert): - if visual_alert == VisualAlert.steerRequired: - return 5 - else: - return 0 class CAR: + # Hyundai ELANTRA = "HYUNDAI ELANTRA LIMITED ULTIMATE 2017" - GENESIS = "HYUNDAI GENESIS 2018" - KIA_OPTIMA = "KIA OPTIMA SX 2019" + ELANTRA_GT_I30 = "HYUNDAI I30 N LINE 2019 & GT 2018 DCT" + HYUNDAI_GENESIS = "HYUNDAI GENESIS 2015-2016" + IONIQ = "HYUNDAI IONIQ HYBRID 2017-2019" + IONIQ_EV_LTD = "HYUNDAI IONIQ ELECTRIC LIMITED 2019" + IONIQ_EV_2020 = "HYUNDAI IONIQ ELECTRIC 2020" + KONA = "HYUNDAI KONA 2020" + KONA_EV = "HYUNDAI KONA ELECTRIC 2019" + SANTA_FE = "HYUNDAI SANTA FE LIMITED 2019" + SONATA = "HYUNDAI SONATA 2020" + SONATA_2019 = "HYUNDAI SONATA 2019" + PALISADE = "HYUNDAI PALISADE 2020" + VELOSTER = "HYUNDAI VELOSTER 2019" + + # Kia + KIA_FORTE = "KIA FORTE E 2018" + KIA_NIRO_EV = "KIA NIRO EV 2020" + KIA_OPTIMA = "KIA OPTIMA SX 2019 & 2016" + KIA_OPTIMA_H = "KIA OPTIMA HYBRID 2017 & SPORTS 2019" KIA_SORENTO = "KIA SORENTO GT LINE 2018" KIA_STINGER = "KIA STINGER GT2 2018" - SANTA_FE = "HYUNDAI SANTA FE LIMITED 2019" + + # Genesis + GENESIS_G70 = "GENESIS G70 2018" + GENESIS_G80 = "GENESIS G80 2017" + GENESIS_G90 = "GENESIS G90 2017" + class Buttons: NONE = 0 @@ -25,52 +56,298 @@ class Buttons: FINGERPRINTS = { CAR.ELANTRA: [{ - 66: 8, 67: 8, 68: 8, 127: 8, 273: 8, 274: 8, 275: 8, 339: 8, 356: 4, 399: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 897: 8, 899: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1170: 8, 1265: 4, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1314: 8, 1322: 8, 1345: 8, 1349: 8, 1351: 8, 1353: 8, 1363: 8, 1366: 8, 1367: 8, 1369: 8, 1407: 8, 1415: 8, 1419: 8, 1425: 2, 1427: 6, 1440: 8, 1456: 4, 1472: 8, 1486: 8, 1487: 8, 1491: 8, 1530: 8, 1532: 5, 2001: 8, 2003: 8, 2004: 8, 2009: 8, 2012: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8 + 66: 8, 67: 8, 68: 8, 127: 8, 273: 8, 274: 8, 275: 8, 339: 8, 356: 4, 399: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 897: 8, 832: 8, 899: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1170: 8, 1265: 4, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1314: 8, 1322: 8, 1345: 8, 1349: 8, 1351: 8, 1353: 8, 1363: 8, 1366: 8, 1367: 8, 1369: 8, 1407: 8, 1415: 8, 1419: 8, 1425: 2, 1427: 6, 1440: 8, 1456: 4, 1472: 8, 1486: 8, 1487: 8, 1491: 8, 1530: 8, 1532: 5, 2001: 8, 2003: 8, 2004: 8, 2009: 8, 2012: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8 + }], + CAR.ELANTRA_GT_I30: [{ + 66: 8, 67: 8, 68: 8, 127: 8, 128: 8, 129: 8, 273: 8, 274: 8, 275: 8, 339: 8, 354: 3, 356: 4, 399: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 884: 8, 897: 8, 899: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1151: 6, 1168: 7, 1170: 8, 1193: 8, 1265: 4, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1345: 8, 1348: 8, 1349: 8, 1351: 8, 1353: 8, 1356: 8, 1363: 8, 1365: 8, 1366: 8, 1367: 8, 1369: 8, 1407: 8, 1414: 3, 1415: 8, 1427: 6, 1440: 8, 1456: 4, 1470: 8, 1486: 8, 1487: 8, 1491: 8, 1530: 8, 1952: 8, 1960: 8, 1988: 8, 2000: 8, 2001: 8, 2005: 8, 2008: 8, 2009: 8, 2013: 8, 2017: 8, 2025: 8 + }, + { + 66: 8, 67: 8, 68: 8, 127: 8, 128: 8, 129: 8, 273: 8, 274: 8, 275: 8, 339: 8, 354: 3, 356: 4, 399: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 832: 8, 897: 8, 899: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1151: 6, 1168: 7, 1170: 8, 1265: 4, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1349: 8, 1351: 8, 1353: 8, 1356: 8, 1363: 8, 1366: 8, 1367: 8, 1369: 8, 1407: 8, 1414: 3, 1415: 8, 1419: 8, 1440: 8, 1456: 4, 1470: 8, 1486: 8, 1487: 8, 1491: 8, 1530: 8 + }, + { + 66: 8, 67: 8, 68: 8, 127: 8, 128: 8, 129: 8, 273: 8, 274: 8, 275: 8, 339: 8, 354: 3, 356: 4, 399: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 832: 8, 897: 8, 899: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1151: 6, 1168: 7, 1170: 8, 1265: 4, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1349: 8, 1351: 8, 1353: 8, 1356: 8, 1363: 8, 1366: 8, 1367: 8, 1369: 8, 1407: 8, 1414: 3, 1419: 8, 1427: 6, 1440: 8, 1456: 4, 1470: 8, 1486: 8, 1487: 8, 1491: 8, 1960: 8, 1990: 8, 1998: 8, 2000: 8, 2001: 8, 2004: 8, 2005: 8, 2008: 8, 2009: 8, 2012: 8, 2013: 8, 2015: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8 }], - CAR.GENESIS: [{ + CAR.HYUNDAI_GENESIS: [{ 67: 8, 68: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 7, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 5, 897: 8, 902: 8, 903: 6, 916: 8, 1024: 2, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1287: 4, 1292: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1334: 8, 1335: 8, 1342: 6, 1345: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1378: 4, 1384: 5, 1407: 8, 1419: 8, 1427: 6, 1434: 2, 1456: 4 }, { 67: 8, 68: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 7, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 5, 897: 8, 902: 8, 903: 6, 916: 8, 1024: 2, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1281: 3, 1287: 4, 1292: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1334: 8, 1335: 8, 1345: 8, 1363: 8, 1369: 8, 1370: 8, 1378: 4, 1379: 8, 1384: 5, 1407: 8, 1419: 8, 1427: 6, 1434: 2, 1456: 4 + }, + { + 67: 8, 68: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 7, 593: 8, 608: 8, 688: 5, 809: 8, 854: 7, 870: 7, 871: 8, 872: 5, 897: 8, 902: 8, 903: 6, 912: 7, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1268: 8, 1280: 1, 1281: 3, 1287: 4, 1292: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1334: 8, 1335: 8, 1345: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1378: 4, 1384: 5, 1407: 8, 1419: 8, 1427: 6, 1434: 2, 1437: 8, 1456: 4 + }, + { + 67: 8, 68: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 7, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 5, 897: 8, 902: 8, 903: 6, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1287: 4, 1292: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1334: 8, 1335: 8, 1345: 8, 1363: 8, 1369: 8, 1370: 8, 1378: 4, 1379: 8, 1384: 5, 1407: 8, 1425: 2, 1427: 6, 1437: 8, 1456: 4 + }, + { + 67: 8, 68: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 7, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 5, 897: 8, 902: 8, 903: 6, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1287: 4, 1292: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1334: 8, 1335: 8, 1345: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1378: 4, 1384: 5, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1437: 8, 1456: 4 + }], + CAR.SANTA_FE: [{ + 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 593: 8, 608: 8, 688: 6, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1155: 8, 1156: 8, 1162: 8, 1164: 8, 1168: 7, 1170: 8, 1173: 8, 1183: 8, 1186: 2, 1191: 2, 1227: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1379: 8, 1384: 8, 1407: 8, 1414: 3, 1419: 8, 1427: 6, 1456: 4, 1470: 8 + }, + { + 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 593: 8, 608: 8, 688: 6, 764: 8, 809: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1155: 8, 1162: 8, 1164: 8, 1168: 7, 1170: 8, 1173: 8, 1180: 8, 1183: 8, 1186: 2, 1227: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1371: 8, 1378: 8, 1384: 8, 1407: 8, 1414: 3, 1419: 8, 1427: 6, 1456: 4, 1470: 8, 1988: 8, 2000: 8, 2004: 8, 2008: 8, 2012: 8 + }, + { + 67: 8, 68: 8, 80: 4, 160: 8, 161: 8, 272: 8, 288: 4, 339: 8, 356: 8, 357: 8, 399: 8, 544: 8, 608: 8, 672: 8, 688: 5, 704: 1, 790: 8, 809: 8, 848: 8, 880: 8, 898: 8, 900: 8, 901: 8, 904: 8, 1056: 8, 1064: 8, 1065: 8, 1072: 8, 1075: 8, 1087: 8, 1088: 8, 1151: 8, 1200: 8, 1201: 8, 1232: 4, 1264: 8, 1265: 8, 1266: 8, 1296: 8, 1306: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1348: 8, 1349: 8, 1369: 8, 1370: 8, 1371: 8, 1407: 8, 1415: 8, 1419: 8, 1440: 8, 1442: 4, 1461: 8, 1470: 8 }], + CAR.SONATA: [ + {67: 8, 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 546: 8, 549: 8, 550: 8, 576: 8, 593: 8, 608: 8, 688: 6, 809: 8, 832: 8, 854: 8, 865: 8, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 905: 8, 908: 8, 909: 8, 912: 7, 913: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1089: 5, 1096: 8, 1107: 5, 1108: 8, 1114: 8, 1136: 8, 1145: 8, 1151: 8, 1155: 8, 1156: 8, 1157: 4, 1162: 8, 1164: 8, 1168: 8, 1170: 8, 1173: 8, 1180: 8, 1183: 8, 1184: 8, 1186: 2, 1191: 2, 1193: 8, 1210: 8, 1225: 8, 1227: 8, 1265: 4, 1268: 8, 1280: 8, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1330: 8, 1339: 8, 1342: 6, 1343: 8, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1371: 8, 1378: 8, 1379: 8, 1384: 8, 1394: 8, 1407: 8, 1419: 8, 1427: 6, 1446: 8, 1456: 4, 1460: 8, 1470: 8, 1485: 8, 1504: 3, 1988: 8, 1996: 8, 2000: 8, 2004: 8, 2008: 8, 2012: 8, 2015: 8}, + ], + CAR.SONATA_2019: [ + {66: 8, 67: 8, 68: 8, 127: 8, 273: 8, 274: 8, 275: 8, 339: 8, 356: 4, 399: 8, 447: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 832: 8, 884: 8, 897: 8, 899: 8, 902: 8, 903: 6, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1151: 6, 1168: 7, 1170: 8, 1253: 8, 1254: 8, 1255: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1314: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1342: 6, 1345: 8, 1348: 8, 1349: 8, 1351: 8, 1353: 8, 1363: 8, 1365: 8, 1366: 8, 1367: 8, 1369: 8, 1397: 8, 1407: 8, 1415: 8, 1419: 8, 1425: 2, 1427: 6, 1440: 8, 1456: 4, 1470: 8, 1472: 8, 1486: 8, 1487: 8, 1491: 8, 1530: 8, 1532: 5, 2000: 8, 2001: 8, 2004: 8, 2005: 8, 2008: 8, 2009: 8, 2012: 8, 2013: 8, 2014: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8}, + ], CAR.KIA_OPTIMA: [{ - 64: 8, 66: 8, 67: 8, 68: 8, 127: 8, 273: 8, 274: 8, 275: 8, 339: 8, 356: 4, 399: 8, 447: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 832: 8, 884: 8, 897: 8, 899: 8, 902: 8, 903: 6, 909: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1151: 6, 1168: 7, 1170: 8, 1186: 2, 1191: 2, 1253: 8, 1254: 8, 1255: 8, 1265: 4, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1342: 6, 1345: 8, 1348: 8, 1349: 8, 1351: 8, 1353: 8, 1363: 8, 1365: 8, 1366: 8, 1367: 8, 1369: 8, 1407: 8, 1414: 3, 1415: 8, 1419: 8, 1425: 2, 1427: 6, 1440: 8, 1456: 4, 1470: 8, 1472: 8, 1486: 8, 1487: 8, 1491: 8, 1530: 8, 1532: 5, 1952: 8, 1960: 8, 1988: 8, 1996: 8, 2001: 8, 2004: 8, 2008: 8, 2009: 8, 2012: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8 + 64: 8, 66: 8, 67: 8, 68: 8, 127: 8, 128: 8, 129: 8, 273: 8, 274: 8, 275: 8, 339: 8, 354: 3, 356: 4, 399: 8, 447: 8, 512: 6, 544: 8, 558: 8, 593: 8, 608: 8, 640: 8, 688: 5, 790: 8, 809: 8, 832: 8, 884: 8, 897: 8, 899: 8, 902: 8, 903: 6, 909: 8, 912: 7, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1151: 6, 1168: 7, 1170: 8, 1186: 2, 1191: 2, 1253: 8, 1254: 8, 1255: 8, 1265: 4, 1268: 8, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1342: 6, 1345: 8, 1348: 8, 1349: 8, 1351: 8, 1353: 8, 1356: 8, 1363: 8, 1365: 8, 1366: 8, 1367: 8, 1369: 8, 1407: 8, 1414: 3, 1415: 8, 1419: 8, 1425: 2, 1427: 6, 1440: 8, 1456: 4, 1470: 8, 1472: 8, 1486: 8, 1487: 8, 1491: 8, 1492: 8, 1530: 8, 1532: 5, 1792: 8, 1872: 8, 1937: 8, 1953: 8, 1968: 8, 1988: 8, 1996: 8, 2000: 8, 2001: 8, 2004: 8, 2008: 8, 2009: 8, 2012: 8, 2015: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8, 1371: 8, 1397: 8, 1961: 8 }], CAR.KIA_SORENTO: [{ 67: 8, 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1384: 8, 1407: 8, 1411: 8, 1419: 8, 1425: 2, 1427: 6, 1444: 8, 1456: 4, 1470: 8, 1489: 1 }], CAR.KIA_STINGER: [{ - 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 358: 6, 359: 8, 544: 8, 576: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1281: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1378: 4, 1379: 8, 1384: 8, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1456: 4, 1470: 8 + 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 358: 6, 359: 8, 544: 8, 576: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1281: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1371: 8, 1378: 4, 1379: 8, 1384: 8, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1456: 4, 1470: 8 }], - CAR.SANTA_FE: [{ - 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 593: 8, 608: 8, 688: 6, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1155: 8, 1156: 8, 1162: 8, 1164: 8, 1168: 7, 1170: 8, 1173: 8, 1183: 8, 1186: 2, 1191: 2, 1227: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1379: 8, 1384: 8, 1407: 8, 1414: 3, 1419: 8, 1427: 6, 1456: 4, 1470: 8 + CAR.GENESIS_G70: [{ + 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 358: 6, 544: 8, 576: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832:8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1156: 8, 1168: 7, 1170: 8, 1173:8, 1184: 8, 1186: 2, 1191: 2, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1379: 8, 1384: 8, 1407: 8, 1419:8, 1427: 6, 1456: 4, 1470: 8, 1988: 8, 1996: 8, 2000: 8, 2004: 8, 2008: 8, 2012: 8, 2015: 8 + }], + CAR.GENESIS_G80: [{ + 67: 8, 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 358: 6, 544: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 916: 8, 1024: 2, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1156: 8, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1191: 2, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1378: 4, 1384: 8, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1434: 2, 1456: 4, 1470: 8 }, { - 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 593: 8, 608: 8, 688: 6, 764: 8, 809: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1155: 8, 1162: 8, 1164: 8, 1168: 7, 1170: 8, 1173: 8, 1180: 8, 1183: 8, 1186: 2, 1227: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1371: 8, 1378: 8, 1384: 8, 1407: 8, 1414: 3, 1419: 8, 1427: 6, 1456: 4, 1470: 8, 1988: 8, 2000: 8, 2004: 8, 2008: 8, 2012: 8 - } - ], + 67: 8, 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 358: 6, 359: 8, 544: 8, 546: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1156: 8, 1157: 4, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1281: 3, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1378: 4, 1384: 8, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1434: 2, 1437: 8, 1456: 4, 1470: 8 + }, + { + 67: 8, 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 358: 6, 544: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1156: 8, 1157: 4, 1162: 8, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1193: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1371: 8, 1378: 4, 1384: 8, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1437: 8, 1456: 4, 1470: 8 + }], + CAR.GENESIS_G90: [{ + 67: 8, 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 358: 6, 359: 8, 544: 8, 593: 8, 608: 8, 688: 5, 809: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1162: 4, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1281: 3, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1378: 4, 1384: 8, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1434: 2, 1456: 4, 1470: 8, 1988: 8, 2000: 8, 2003: 8, 2004: 8, 2005: 8, 2008: 8, 2011: 8, 2012: 8, 2013: 8 + }], + CAR.IONIQ_EV_2020: [{ + 127: 8, 304: 8, 320: 8, 339: 8, 352: 8, 356: 4, 524: 8, 544: 7, 593: 8, 688: 5, 832: 8, 881: 8, 882: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1136: 8, 1151: 6, 1155: 8, 1156: 8, 1157: 4, 1164: 8, 1168: 7, 1173: 8, 1183: 8, 1186: 2, 1191: 2, 1225: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1291: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1355: 8, 1363: 8, 1369: 8, 1379: 8, 1407: 8, 1419: 8, 1426: 8, 1427: 6, 1429: 8, 1430: 8, 1456: 4, 1470: 8, 1473: 8, 1507: 8, 1535: 8, 1988: 8, 1996: 8, 2000: 8, 2004: 8, 2005: 8, 2008: 8, 2012: 8, 2013: 8 + }], + CAR.IONIQ_EV_LTD: [{ + 127: 8, 304: 8, 320: 8, 339: 8, 352: 8, 356: 4, 544: 7, 593: 8, 688: 5, 832: 8, 881: 8, 882: 8, 897: 8, 902: 8, 903: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1136: 8, 1151: 6, 1168: 7, 1173: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1291: 8, 1292: 8, 1294: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1355: 8, 1363: 8, 1369: 8, 1407: 8, 1419: 8, 1425: 2, 1426: 8, 1427: 6, 1429: 8, 1430: 8, 1456: 4, 1470: 8, 1507: 8, 1535: 8 + }], + CAR.IONIQ: [{ + 68:8, 127: 8, 304: 8, 320: 8, 339: 8, 352: 8, 356: 4, 524: 8, 544: 8, 576:8, 593: 8, 688: 5, 832: 8, 881: 8, 882: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1136: 6, 1151: 6, 1155: 8, 1156: 8, 1157: 4, 1164: 8, 1168: 7, 1173: 8, 1183: 8, 1186: 2, 1191: 2, 1225: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1291: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1355: 8, 1363: 8, 1369: 8, 1379: 8, 1407: 8, 1419: 8, 1426: 8, 1427: 6, 1429: 8, 1430: 8, 1448: 8, 1456: 4, 1470: 8, 1473: 8, 1476: 8, 1507: 8, 1535: 8, 1988: 8, 1996: 8, 2000: 8, 2004: 8, 2005: 8, 2008: 8, 2012: 8, 2013: 8 + }], + CAR.KONA: [{ + 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 354: 3, 356: 4, 544: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832 : 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1156: 8, 1170: 8, 1173: 8, 1186: 2, 1191: 2, 1193: 8, 1265: 4,1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1378: 8, 1384: 8, 1394: 8, 1407: 8, 1414: 3, 1419: 8, 1427: 6, 1456: 4, 1470: 8, 1988: 8, 1996: 8, 2000: 8, 2001: 8, 2004: 8, 2008: 8, 2009: 8, 2012: 8 + }], + CAR.KONA_EV: [{ + 127: 8, 304: 8, 320: 8, 339: 8, 352: 8, 356: 4, 544: 8, 549: 8, 593: 8, 688: 5, 832: 8, 881: 8, 882: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1136: 8, 1151: 6, 1168: 7, 1173: 8, 1183: 8, 1186: 2, 1191: 2, 1225: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1291: 8, 1292: 8, 1294: 8, 1307: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1355: 8, 1363: 8, 1369: 8, 1378: 4, 1407: 8, 1419: 8, 1426: 8, 1427: 6, 1429: 8, 1430: 8, 1456: 4, 1470: 8, 1473: 8, 1507: 8, 1535: 8, 2000: 8, 2004: 8, 2008: 8, 2012: 8, 1157: 4, 1193: 8, 1379: 8, 1988: 8, 1996: 8 + }], + CAR.KIA_NIRO_EV: [{ + 127: 8, 304: 8, 320: 8, 339: 8, 352: 8, 356: 4, 516: 8, 544: 8, 593: 8, 688: 5, 832: 8, 881: 8, 882: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1136: 8, 1151: 6, 1156: 8, 1157: 4, 1168: 7, 1173: 8, 1183: 8, 1186: 2, 1191: 2, 1193: 8, 1225: 8, 1260: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1291: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1355: 8, 1363: 8, 1369: 8, 1407: 8, 1419: 8, 1426: 8, 1427: 6, 1429: 8, 1430: 8, 1456: 4, 1470: 8, 1473: 8, 1507: 8, 1535: 8, 1990: 8, 1998: 8, 1996: 8, 2000: 8, 2004: 8, 2008: 8, 2012: 8, 2015: 8 + }], + CAR.KIA_FORTE: [{ + 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1078: 4, 1107: 5, 1136: 8, 1156: 8, 1170: 8, 1173: 8, 1191: 2, 1225: 8, 1265: 4, 1280: 4, 1287: 4, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1384: 8, 1394: 8, 1407: 8, 1427: 6, 1456: 4, 1470: 8 + }], + CAR.KIA_OPTIMA_H: [{ + 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 352: 8, 356: 4, 544: 8, 593: 8, 688: 5, 832: 8, 881: 8, 882: 8, 897: 8, 902: 8, 903: 6, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1136: 6, 1151: 6, 1168: 7, 1173: 8, 1236: 2, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1291: 8, 1292: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1342: 6, 1345: 8, 1348: 8, 1355: 8, 1363: 8, 1369: 8, 1371: 8, 1407: 8, 1419: 8, 1427: 6, 1429: 8, 1430: 8, 1448: 8, 1456: 4, 1470: 8, 1476: 8, 1535: 8 + }, + { + 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 352: 8, 356: 4, 544: 8, 576: 8, 593: 8, 688: 5, 881: 8, 882: 8, 897: 8, 902: 8, 903: 8, 909: 8, 912: 7, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1136: 6, 1151: 6, 1168: 7, 1173: 8, 1180: 8, 1186: 2, 1191: 2, 1265: 4, 1268: 8, 1280: 1, 1287: 4, 1290: 8, 1291: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1355: 8, 1363: 8, 1369: 8, 1371: 8, 1407: 8, 1419: 8, 1420: 8, 1425: 2, 1427: 6, 1429: 8, 1430: 8, 1448: 8, 1456: 4, 1470: 8, 1476: 8, 1535: 8 + }], + CAR.PALISADE: [{ + 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 546: 8, 547: 8, 548: 8, 549: 8, 576: 8, 593: 8, 608: 8, 688: 6, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 913: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1123: 8, 1136: 8, 1151: 6, 1155: 8, 1156: 8, 1157: 4, 1162: 8, 1164: 8, 1168: 7, 1170: 8, 1173: 8, 1180: 8, 1186: 2, 1191: 2, 1193: 8, 1210: 8, 1225: 8, 1227: 8, 1265: 4, 1280: 8, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1371: 8, 1378: 8, 1384: 8, 1407: 8, 1419: 8, 1427: 6, 1456: 4, 1470: 8, 1988: 8, 1996: 8, 2000: 8, 2004: 8, 2005: 8, 2008: 8, 2012: 8 + }], + CAR.VELOSTER: [{ + 64: 8, 66: 8, 67: 8, 68: 8, 127: 8, 128: 8, 129: 8, 273: 8, 274: 8, 275: 8, 339: 8, 354: 3, 356: 4, 399: 8, 512: 6, 544: 8, 558: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 832: 8, 884: 8, 897: 8, 899: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1170: 8, 1181: 5, 1186: 2, 1191: 2, 1265: 4, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1349: 8, 1351: 8, 1353: 8, 1356: 8, 1363: 8, 1365: 8, 1366: 8, 1367: 8, 1369: 8, 1378: 4, 1407: 8, 1414: 3, 1415: 8, 1419: 8, 1427: 6, 1440: 8, 1456: 4, 1470: 8, 1486: 8, 1487: 8, 1491: 8, 1530: 8, 1532: 5, 1872: 8, 1988: 8, 1996: 8, 2000: 8, 2001: 8, 2004: 8, 2008: 8, 2009: 8, 2012: 8, 2015: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8 + }] } -CAMERA_MSGS = [832, 1156, 1191, 1342] +# Don't use these fingerprints for fingerprinting, they are still used for ECU detection +IGNORED_FINGERPRINTS = [CAR.VELOSTER, CAR.GENESIS_G70, CAR.KONA] + +FW_VERSIONS = { + CAR.SONATA: { + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x00DN8_ SCC FHCUP 1.00 1.01 99110-L1000 ', + b'\xf1\x00DN8_ SCC FHCUP 1.00 1.00 99110-L0000 ', + b'\xf1\x00DN8_ SCC F-CU- 1.00 1.00 99110-L0000 ', + b'\xf1\x00DN8_ SCC F-CUP 1.00 1.00 99110-L0000 ', + ], + (Ecu.esp, 0x7d1, None): [ + b'\xf1\x00DN ESC \x01 102\x19\x04\x13 58910-L1300\xf1\xa01.02', + b'\xf1\x00DN ESC \x06 104\x19\x08\x01 58910-L0100', + b'\xf1\x8758910-L0100\xf1\x00DN ESC \x06 104\x19\x08\x01 58910-L0100\xf1\xa01.04', + b'\xf1\x8758910-L0100\xf1\x00DN ESC \x07 104\x19\x08\x01 58910-L0100\xf1\xa01.04', + ], + (Ecu.engine, 0x7e0, None): [ + b'HM6M2_0a0_BD0', + b'\xf1\x87391162M003\xf1\xa0000F', + b'\xf1\x87391162M003\xf1\xa00240', + b'HM6M1_0a0_F00', + ], + (Ecu.eps, 0x7d4, None): [ + b'\xf1\x8756310-L1010\xf1\x00DN8 MDPS C 1.00 1.03 56310-L1010 4DNDC103\xf1\xa01.03', + b'\xf1\x8756310L0010\x00\xf1\x00DN8 MDPS C 1.00 1.01 56310L0010\x00 4DNAC101\xf1\xa01.01', + b'\xf1\x8756310-L0010\xf1\x00DN8 MDPS C 1.00 1.01 56310-L0010 4DNAC101\xf1\xa01.01', + ], + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00DN8 MFC AT KOR LHD 1.00 1.02 99211-L1000 190422', + b'\xf1\x00DN8 MFC AT USA LHD 1.00 1.00 99211-L0000 190716', + b'\xf1\x00DN8 MFC AT USA LHD 1.00 1.01 99211-L0000 191016', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x00HT6TA260BLHT6TA800A1TDN8C20KS4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x00HT6WA250BLHT6WA910A1SDN8G25NB1\x00\x00\x00\x00\x00\x00\x96\xa1\xf1\x92', + ], + }, + CAR.SANTA_FE: { + (Ecu.fwdRadar, 0x7d0, None): [b'\xf1\x00TM__ SCC F-CUP 1.00 1.02 99110-S2000 \xf1\xa01.02'], + (Ecu.esp, 0x7d1, None): [b'\xf1\x00TM ESC \x02 100\x18\x030 58910-S2600\xf1\xa01.00',], + (Ecu.engine, 0x7e0, None): [b'\xf1\x81606EA051\x00\x00\x00\x00\x00\x00\x00\x00'], + (Ecu.eps, 0x7d4, None): [b'\xf1\x00TM MDPS C 1.00 1.00 56340-S2000 8409'], + (Ecu.fwdCamera, 0x7c4, None): [b'\xf1\x00TM MFC AT USA LHD 1.00 1.00 99211-S2000 180409'], + (Ecu.transmission, 0x7e1, None): [b'\xf1\x87SBJWAA6562474GG0ffvgeTeFx\x88\x97\x88ww\x87www\x87w\x84o\xfa\xff\x87fO\xff\xc2 \xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM2G24NS1\x00\x00\x00\x00'], + }, + CAR.KIA_STINGER: { + (Ecu.fwdRadar, 0x7d0, None): [ b'\xf1\x00CK__ SCC F_CUP 1.00 1.01 96400-J5100 \xf1\xa01.01'], + (Ecu.engine, 0x7e0, None): [ b'\xf1\x81640E0051\x00\x00\x00\x00\x00\x00\x00\x00',], + (Ecu.eps, 0x7d4, None): [b'\xf1\x00CK MDPS R 1.00 1.04 57700-J5420 4C4VL104'], + (Ecu.fwdCamera, 0x7c4, None): [b'\xf1\x00CK MFC AT USA LHD 1.00 1.03 95740-J5000 170822'], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x87VDHLG17118862DK2\x8awWwgu\x96wVfUVwv\x97xWvfvUTGTx\x87o\xff\xc9\xed\xf1\x81E21\x00\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 E21\x00\x00\x00\x00\x00\x00\x00SCK0T33NB0\x88\xa2\xe6\xf0', + b'\xf1\x87VDHLG17000192DK2xdFffT\xa5VUD$DwT\x86wveVeeD&T\x99\xba\x8f\xff\xcc\x99\xf1\x81E21\x00\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 E21\x00\x00\x00\x00\x00\x00\x00SCK0T33NB0\x88\xa2\xe6\xf0', + ], + }, + CAR.KIA_OPTIMA_H: { + (Ecu.fwdRadar, 0x7d0, None): [b'\xf1\x00DEhe SCC H-CUP 1.01 1.02 96400-G5100 ',], + (Ecu.engine, 0x7e0, None): [b'\xf1\x816H6F4051\x00\x00\x00\x00\x00\x00\x00\x00',], + (Ecu.eps, 0x7d4, None): [b'\xf1\x00DE MDPS C 1.00 1.09 56310G5301\x00 4DEHC109',], + (Ecu.fwdCamera, 0x7c4, None): [b'\xf1\x00DEP MFC AT USA LHD 1.00 1.01 95740-G5010 170424',], + (Ecu.transmission, 0x7e1, None): [b"\xf1\x816U3J2051\x00\x00\xf1\x006U3H0_C2\x00\x006U3J2051\x00\x00PDE0G16NS2\xf4'\\\x91",], + }, + CAR.PALISADE: { + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x00LX2_ SCC FHCUP 1.00 1.04 99110-S8100 \xf1\xa01.04', + b'\xf1\x00LX2 SCC FHCUP 1.00 1.04 99110-S8100 \xf1\xa01.04', + ], + (Ecu.esp, 0x7d1, None): [ + b'\xf1\x00LX ESC \v 102\x19\x05\a 58910-S8330\xf1\xa01.02', + b'\xf1\x00LX ESC \v 103\x19\t\x10 58910-S8360\xf1\xa01.03', + b'\xf1\x00LX ESC \x01 103\x19\t\x10 58910-S8360\xf1\xa01.03', + b'\xf1\x00LX ESC \x0b 102\x19\x05\x07 58910-S8330', + ], + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x81640J0051\x00\x00\x00\x00\x00\x00\x00\x00', + b'\xf1\x81640K0051\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7d4, None): [b'\xf1\x00LX2 MDPS C 1.00 1.03 56310-S8020 4LXDC103',], + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00LX2 MFC AT USA LHD 1.00 1.03 99211-S8100 190125', + b'\xf1\x00LX2 MFC AT USA LHD 1.00 1.05 99211-S8100 190909', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x87LBLUFN650868KF36\xa9\x98\x89\x88\xa8\x88\x88\x88h\x99\xa6\x89fw\x86gw\x88\x97x\xaa\x7f\xf6\xff\xbb\xbb\x8f\xff+\x82\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX2G38NB3\xd1\xc3\xf8\xa8', + b'\xf1\x87LDKVBN424201KF26\xba\xaa\x9a\xa9\x99\x99\x89\x98\x89\x99\xa8\x99\x88\x99\x98\x89\x88\x99\xa8\x89v\x7f\xf7\xffwf_\xffq\xa6\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB2\xafL]\xe7', + b'\xf1\x87LDLVBN560098KF26\x86fff\x87vgfg\x88\x96xfw\x86gfw\x86g\x95\xf6\xffeU_\xff\x92c\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB2\xafL]\xe7', + ], + }, + CAR.VELOSTER: { + (Ecu.fwdRadar, 0x7d0, None): [b'\xf1\x00JS__ SCC H-CUP 1.00 1.02 95650-J3200 ', ], + (Ecu.esp, 0x7d1, None): [b'\xf1\x00\x00\x00\x00\x00\x00\x00', ], + (Ecu.engine, 0x7e0, None): [b'\x01TJS-JNU06F200H0A', ], + (Ecu.eps, 0x7d4, None): [b'\xf1\x00JSL MDPS C 1.00 1.03 56340-J3000 8308', ], + (Ecu.fwdCamera, 0x7c4, None): [b'\xf1\x00JS LKAS AT USA LHD 1.00 1.02 95740-J3000 K32', ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x816U2V8051\x00\x00\xf1\x006U2V0_C2\x00\x006U2V8051\x00\x00DJS0T16NS1\xba\x02\xb8\x80', + b'\xf1\x816U2V8051\x00\x00\xf1\x006U2V0_C2\x00\x006U2V8051\x00\x00DJS0T16NS1\x00\x00\x00\x00', + ], + }, + CAR.GENESIS_G70: { + (Ecu.fwdRadar, 0x7d0, None): [b'\xf1\x00IK__ SCC F-CUP 1.00 1.02 96400-G9100 \xf1\xa01.02', ], + (Ecu.engine, 0x7e0, None): [b'\xf1\x81640F0051\x00\x00\x00\x00\x00\x00\x00\x00', ], + (Ecu.eps, 0x7d4, None): [b'\xf1\x00IK MDPS R 1.00 1.06 57700-G9420 4I4VL106', ], + (Ecu.fwdCamera, 0x7c4, None): [b'\xf1\x00IK MFC AT USA LHD 1.00 1.01 95740-G9000 170920', ], + (Ecu.transmission, 0x7e1, None): [b'\xf1\x87VDJLT17895112DN4\x88fVf\x99\x88\x88\x88\x87fVe\x88vhwwUFU\x97eFex\x99\xff\xb7\x82\xf1\x81E25\x00\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 E25\x00\x00\x00\x00\x00\x00\x00SIK0T33NB2\x11\x1am\xda', ], + }, + CAR.KONA: { + (Ecu.fwdRadar, 0x7d0, None): [b'\xf1\x00OS__ SCC F-CUP 1.00 1.00 95655-J9200 \xf1\xa01.00', ], + (Ecu.esp, 0x7d1, None): [b'\xf1\x816V5RAK00018.ELF\xf1\x00\x00\x00\x00\x00\x00\x00\xf1\xa01.05', ], + (Ecu.engine, 0x7e0, None): [b'"\x01TOS-0NU06F301J02', ], + (Ecu.eps, 0x7d4, None): [b'\xf1\x00OS MDPS C 1.00 1.05 56310J9030\x00 4OSDC105', ], + (Ecu.fwdCamera, 0x7c4, None): [b'\xf1\x00OS9 LKAS AT USA LHD 1.00 1.00 95740-J9300 g21', ], + (Ecu.transmission, 0x7e1, None): [b'\xf1\x816U2VE051\x00\x00\xf1\x006U2V0_C2\x00\x006U2VE051\x00\x00DOS4T16NS3\x00\x00\x00\x00', ], + }, + CAR.KONA_EV: { + (Ecu.esp, 0x7D1, None): [b'\xf1\x00OS IEB \r 105\x18\t\x18 58520-K4000\xf1\xa01.05', ], + (Ecu.fwdCamera, 0x7C4, None): [b'\xf1\x00OSE LKAS AT EUR LHD 1.00 1.00 95740-K4100 W40', ], + (Ecu.eps, 0x7D4, None): [b'\xf1\x00OS MDPS C 1.00 1.04 56310K4050\x00 4OEDC104', ], + (Ecu.fwdRadar, 0x7D0, None): [b'\xf1\x00OSev SCC F-CUP 1.00 1.01 99110-K4000 \xf1\xa01.01', ], + }, + CAR.KIA_NIRO_EV: { + (Ecu.fwdRadar, 0x7D0, None): [ + b'\xf1\x00DEev SCC F-CUP 1.00 1.03 96400-Q4100 \xf1\xa01.03', + b'\xf1\x00DEev SCC F-CUP 1.00 1.00 99110-Q4000 \xf1\xa01.00', + ], + (Ecu.esp, 0x7D1, None): [ + b'\xf1\xa01.06', + b'\xf1\xa01.07', + ], + (Ecu.eps, 0x7D4, None): [ + b'\xf1\x00DE MDPS C 1.00 1.05 56310Q4000\x00 4DEEC105', + b'\xf1\x00DE MDPS C 1.00 1.05 56310Q4100\x00 4DEEC105', + ], + (Ecu.fwdCamera, 0x7C4, None): [ + b'\xf1\x00DEE MFC AT USA LHD 1.00 1.03 95740-Q4000 180821', + b'\xf1\x00DEE MFC AT EUR LHD 1.00 1.00 99211-Q4000 191211', + ], + }, + CAR.KIA_OPTIMA: { + (Ecu.fwdRadar, 0x7d0, None): [b'\xf1\x00JF__ SCC F-CUP 1.00 1.00 96400-D4110 '], + (Ecu.esp, 0x7d1, None): [b'\xf1\x00JF ESC \v 11 \x18\x030 58920-D5180',], + (Ecu.engine, 0x7e0, None): [b'\x01TJFAJNU06F201H03'], + (Ecu.eps, 0x7d4, None): [b'\xf1\x00TM MDPS C 1.00 1.00 56340-S2000 8409'], + (Ecu.fwdCamera, 0x7c4, None): [b'\xf1\x00JFA LKAS AT USA LHD 1.00 1.02 95895-D5000 h31'], + (Ecu.transmission, 0x7e1, None): [b'\xf1\x816U2V8051\x00\x00\xf1\x006U2V0_C2\x00\x006U2V8051\x00\x00DJF0T16NL0\t\xd2GW'], + } +} CHECKSUM = { - "crc8": [CAR.SANTA_FE], - "6B": [CAR.KIA_SORENTO, CAR.GENESIS], - "7B": [CAR.KIA_STINGER, CAR.ELANTRA, CAR.KIA_OPTIMA], + "crc8": [CAR.SANTA_FE, CAR.SONATA, CAR.PALISADE], + "6B": [CAR.KIA_SORENTO, CAR.HYUNDAI_GENESIS], } FEATURES = { - "use_cluster_gears": [CAR.ELANTRA], # Use Cluster for Gear Selection, rather than Transmission - "use_tcu_gears": [CAR.KIA_OPTIMA], # Use TCU Message for Gear Selection + # which message has the gear + "use_cluster_gears": set([CAR.ELANTRA, CAR.ELANTRA_GT_I30, CAR.KONA]), + "use_tcu_gears": set([CAR.KIA_OPTIMA, CAR.SONATA_2019, CAR.VELOSTER]), + "use_elect_gears": set([CAR.KIA_NIRO_EV, CAR.KIA_OPTIMA_H, CAR.IONIQ_EV_LTD, CAR.KONA_EV, CAR.IONIQ, CAR.IONIQ_EV_2020]), + + # these cars use the FCA11 message for the AEB and FCW signals, all others use SCC12 + "use_fca": set([CAR.SONATA, CAR.ELANTRA, CAR.ELANTRA_GT_I30, CAR.KIA_STINGER, CAR.IONIQ, CAR.IONIQ_EV_2020, CAR.KONA_EV, CAR.KIA_FORTE, CAR.KIA_NIRO_EV, CAR.PALISADE, CAR.GENESIS_G70, CAR.KONA]), + + "use_bsm": set([CAR.SONATA, CAR.PALISADE, CAR.HYUNDAI_GENESIS, CAR.GENESIS_G70, CAR.GENESIS_G80, CAR.GENESIS_G90, CAR.KONA, CAR.IONIQ_EV_2020]), } +EV_HYBRID = set([CAR.IONIQ_EV_2020, CAR.IONIQ_EV_LTD, CAR.IONIQ, CAR.KONA_EV, CAR.KIA_NIRO_EV]) + DBC = { CAR.ELANTRA: dbc_dict('hyundai_kia_generic', None), - CAR.GENESIS: dbc_dict('hyundai_kia_generic', None), + CAR.ELANTRA_GT_I30: dbc_dict('hyundai_kia_generic', None), + CAR.GENESIS_G70: dbc_dict('hyundai_kia_generic', None), + CAR.GENESIS_G80: dbc_dict('hyundai_kia_generic', None), + CAR.GENESIS_G90: dbc_dict('hyundai_kia_generic', None), + CAR.HYUNDAI_GENESIS: dbc_dict('hyundai_kia_generic', None), + CAR.IONIQ_EV_2020: dbc_dict('hyundai_kia_generic', None), + CAR.IONIQ_EV_LTD: dbc_dict('hyundai_kia_generic', None), + CAR.IONIQ: dbc_dict('hyundai_kia_generic', None), + CAR.KIA_FORTE: dbc_dict('hyundai_kia_generic', None), + CAR.KIA_NIRO_EV: dbc_dict('hyundai_kia_generic', None), CAR.KIA_OPTIMA: dbc_dict('hyundai_kia_generic', None), + CAR.KIA_OPTIMA_H: dbc_dict('hyundai_kia_generic', None), CAR.KIA_SORENTO: dbc_dict('hyundai_kia_generic', None), CAR.KIA_STINGER: dbc_dict('hyundai_kia_generic', None), + CAR.KONA: dbc_dict('hyundai_kia_generic', None), + CAR.KONA_EV: dbc_dict('hyundai_kia_generic', None), CAR.SANTA_FE: dbc_dict('hyundai_kia_generic', None), + CAR.SONATA: dbc_dict('hyundai_kia_generic', None), + CAR.SONATA_2019: dbc_dict('hyundai_kia_generic', None), + CAR.PALISADE: dbc_dict('hyundai_kia_generic', None), + CAR.VELOSTER: dbc_dict('hyundai_kia_generic', None), } -STEER_THRESHOLD = 100 +STEER_THRESHOLD = 150 diff --git a/selfdrive/car/interfaces.py b/selfdrive/car/interfaces.py new file mode 100644 index 00000000000000..746dabb9eb3309 --- /dev/null +++ b/selfdrive/car/interfaces.py @@ -0,0 +1,200 @@ +import os +import time +from typing import Dict + +from cereal import car +from common.kalman.simple_kalman import KF1D +from common.realtime import DT_CTRL +from selfdrive.car import gen_empty_fingerprint +from selfdrive.config import Conversions as CV +from selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX +from selfdrive.controls.lib.events import Events +from selfdrive.controls.lib.vehicle_model import VehicleModel + +GearShifter = car.CarState.GearShifter +EventName = car.CarEvent.EventName +MAX_CTRL_SPEED = (V_CRUISE_MAX + 4) * CV.KPH_TO_MS # 144 + 4 = 92 mph + +# generic car and radar interfaces + + +class CarInterfaceBase(): + def __init__(self, CP, CarController, CarState): + self.CP = CP + self.VM = VehicleModel(CP) + + self.frame = 0 + self.low_speed_alert = False + + if CarState is not None: + self.CS = CarState(CP) + self.cp = self.CS.get_can_parser(CP) + self.cp_cam = self.CS.get_cam_can_parser(CP) + self.cp_body = self.CS.get_body_can_parser(CP) + + self.CC = None + if CarController is not None: + self.CC = CarController(self.cp.dbc_name, CP, self.VM) + + @staticmethod + def calc_accel_override(a_ego, a_target, v_ego, v_target): + return 1. + + @staticmethod + def compute_gb(accel, speed): + raise NotImplementedError + + @staticmethod + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + raise NotImplementedError + + # returns a set of default params to avoid repetition in car specific params + @staticmethod + def get_std_params(candidate, fingerprint): + ret = car.CarParams.new_message() + ret.carFingerprint = candidate + ret.isPandaBlack = True # TODO: deprecate this field + + # standard ALC params + ret.steerControlType = car.CarParams.SteerControlType.torque + ret.steerMaxBP = [0.] + ret.steerMaxV = [1.] + ret.minSteerSpeed = 0. + + # stock ACC by default + ret.enableCruise = True + ret.minEnableSpeed = -1. # enable is done by stock ACC, so ignore this + ret.steerRatioRear = 0. # no rear steering, at least on the listed cars aboveA + ret.gasMaxBP = [0.] + ret.gasMaxV = [.5] # half max brake + ret.brakeMaxBP = [0.] + ret.brakeMaxV = [1.] + ret.openpilotLongitudinalControl = False + ret.startAccel = 0.0 + ret.minSpeedCan = 0.3 + ret.stoppingBrakeRate = 0.2 # brake_travel/s while trying to stop + ret.startingBrakeRate = 0.8 # brake_travel/s while releasing on restart + ret.stoppingControl = False + ret.longitudinalTuning.deadzoneBP = [0.] + ret.longitudinalTuning.deadzoneV = [0.] + ret.longitudinalTuning.kpBP = [0.] + ret.longitudinalTuning.kpV = [1.] + ret.longitudinalTuning.kiBP = [0.] + ret.longitudinalTuning.kiV = [1.] + return ret + + # returns a car.CarState, pass in car.CarControl + def update(self, c, can_strings): + raise NotImplementedError + + # return sendcan, pass in a car.CarControl + def apply(self, c): + raise NotImplementedError + + def create_common_events(self, cs_out, extra_gears=[], gas_resume_speed=-1, pcm_enable=True): # pylint: disable=dangerous-default-value + events = Events() + + if cs_out.doorOpen: + events.add(EventName.doorOpen) + if cs_out.seatbeltUnlatched: + events.add(EventName.seatbeltNotLatched) + if cs_out.gearShifter != GearShifter.drive and cs_out.gearShifter not in extra_gears: + events.add(EventName.wrongGear) + if cs_out.gearShifter == GearShifter.reverse: + events.add(EventName.reverseGear) + if not cs_out.cruiseState.available: + events.add(EventName.wrongCarMode) + if cs_out.espDisabled: + events.add(EventName.espDisabled) + if cs_out.gasPressed: + events.add(EventName.gasPressed) + if cs_out.stockFcw: + events.add(EventName.stockFcw) + if cs_out.stockAeb: + events.add(EventName.stockAeb) + if cs_out.vEgo > MAX_CTRL_SPEED: + events.add(EventName.speedTooHigh) + if cs_out.cruiseState.nonAdaptive: + events.add(EventName.wrongCruiseMode) + + if cs_out.steerError: + events.add(EventName.steerUnavailable) + elif cs_out.steerWarning: + events.add(EventName.steerTempUnavailable) + + # Disable on rising edge of gas or brake. Also disable on brake when speed > 0. + # Optionally allow to press gas at zero speed to resume. + # e.g. Chrysler does not spam the resume button yet, so resuming with gas is handy. FIXME! + if (cs_out.gasPressed and (not self.CS.out.gasPressed) and cs_out.vEgo > gas_resume_speed) or \ + (cs_out.brakePressed and (not self.CS.out.brakePressed or not cs_out.standstill)): + events.add(EventName.pedalPressed) + + # we engage when pcm is active (rising edge) + if pcm_enable: + if cs_out.cruiseState.enabled and not self.CS.out.cruiseState.enabled: + events.add(EventName.pcmEnable) + elif not cs_out.cruiseState.enabled: + events.add(EventName.pcmDisable) + + return events + + +class RadarInterfaceBase(): + def __init__(self, CP): + self.pts = {} + self.delay = 0 + self.radar_ts = CP.radarTimeStep + self.no_radar_sleep = 'NO_RADAR_SLEEP' in os.environ + + def update(self, can_strings): + ret = car.RadarData.new_message() + if not self.no_radar_sleep: + time.sleep(self.radar_ts) # radard runs on RI updates + return ret + + +class CarStateBase: + def __init__(self, CP): + self.CP = CP + self.car_fingerprint = CP.carFingerprint + self.out = car.CarState.new_message() + + self.cruise_buttons = 0 + self.left_blinker_cnt = 0 + self.right_blinker_cnt = 0 + + # Q = np.matrix([[10.0, 0.0], [0.0, 100.0]]) + # R = 1e3 + self.v_ego_kf = KF1D(x0=[[0.0], [0.0]], + A=[[1.0, DT_CTRL], [0.0, 1.0]], + C=[1.0, 0.0], + K=[[0.12287673], [0.29666309]]) + + def update_speed_kf(self, v_ego_raw): + if abs(v_ego_raw - self.v_ego_kf.x[0][0]) > 2.0: # Prevent large accelerations when car starts at non zero speed + self.v_ego_kf.x = [[v_ego_raw], [0.0]] + + v_ego_x = self.v_ego_kf.update(v_ego_raw) + return float(v_ego_x[0]), float(v_ego_x[1]) + + def update_blinker(self, blinker_time: int, left_blinker_lamp: bool, right_blinker_lamp: bool): + self.left_blinker_cnt = blinker_time if left_blinker_lamp else max(self.left_blinker_cnt - 1, 0) + self.right_blinker_cnt = blinker_time if right_blinker_lamp else max(self.right_blinker_cnt - 1, 0) + return self.left_blinker_cnt > 0, self.right_blinker_cnt > 0 + + @staticmethod + def parse_gear_shifter(gear: str) -> car.CarState.GearShifter: + d: Dict[str, car.CarState.GearShifter] = { + 'P': GearShifter.park, 'R': GearShifter.reverse, 'N': GearShifter.neutral, + 'E': GearShifter.eco, 'T': GearShifter.manumatic, 'D': GearShifter.drive, + 'S': GearShifter.sport, 'L': GearShifter.low, 'B': GearShifter.brake + } + return d.get(gear, GearShifter.unknown) + + @staticmethod + def get_cam_can_parser(CP): + return None + + @staticmethod + def get_body_can_parser(CP): + return None diff --git a/selfdrive/car/isotp_parallel_query.py b/selfdrive/car/isotp_parallel_query.py new file mode 100644 index 00000000000000..c5185dec5c28b4 --- /dev/null +++ b/selfdrive/car/isotp_parallel_query.py @@ -0,0 +1,129 @@ +import time +from collections import defaultdict +from functools import partial + +import cereal.messaging as messaging +from selfdrive.swaglog import cloudlog +from selfdrive.boardd.boardd import can_list_to_can_capnp +from panda.python.uds import CanClient, IsoTpMessage, FUNCTIONAL_ADDRS, get_rx_addr_for_tx_addr + + +class IsoTpParallelQuery(): + def __init__(self, sendcan, logcan, bus, addrs, request, response, functional_addr=False, debug=False): + self.sendcan = sendcan + self.logcan = logcan + self.bus = bus + self.request = request + self.response = response + self.debug = debug + self.functional_addr = functional_addr + + self.real_addrs = [] + for a in addrs: + if isinstance(a, tuple): + self.real_addrs.append(a) + else: + self.real_addrs.append((a, None)) + + self.msg_addrs = {tx_addr: get_rx_addr_for_tx_addr(tx_addr[0]) for tx_addr in self.real_addrs} + self.msg_buffer = defaultdict(list) + + def rx(self): + """Drain can socket and sort messages into buffers based on address""" + can_packets = messaging.drain_sock(self.logcan, wait_for_one=True) + + for packet in can_packets: + for msg in packet.can: + if msg.src == self.bus: + if self.functional_addr: + if (0x7E8 <= msg.address <= 0x7EF) or (0x18DAF100 <= msg.address <= 0x18DAF1FF): + fn_addr = next(a for a in FUNCTIONAL_ADDRS if msg.address - a <= 32) + self.msg_buffer[fn_addr].append((msg.address, msg.busTime, msg.dat, msg.src)) + elif msg.address in self.msg_addrs.values(): + self.msg_buffer[msg.address].append((msg.address, msg.busTime, msg.dat, msg.src)) + + def _can_tx(self, tx_addr, dat, bus): + """Helper function to send single message""" + msg = [tx_addr, 0, dat, bus] + self.sendcan.send(can_list_to_can_capnp([msg], msgtype='sendcan')) + + def _can_rx(self, addr, sub_addr=None): + """Helper function to retrieve message with specified address and subadress from buffer""" + keep_msgs = [] + + if sub_addr is None: + msgs = self.msg_buffer[addr] + else: + # Filter based on subadress + msgs = [] + for m in self.msg_buffer[addr]: + first_byte = m[2][0] + if first_byte == sub_addr: + msgs.append(m) + else: + keep_msgs.append(m) + + self.msg_buffer[addr] = keep_msgs + return msgs + + def _drain_rx(self): + messaging.drain_sock(self.logcan) + self.msg_buffer = defaultdict(list) + + def get_data(self, timeout): + self._drain_rx() + + # Create message objects + msgs = {} + request_counter = {} + request_done = {} + for tx_addr, rx_addr in self.msg_addrs.items(): + # rx_addr not set when using functional tx addr + id_addr = rx_addr or tx_addr[0] + sub_addr = tx_addr[1] + + can_client = CanClient(self._can_tx, partial(self._can_rx, id_addr, sub_addr=sub_addr), tx_addr[0], rx_addr, + self.bus, sub_addr=sub_addr, debug=self.debug) + + max_len = 8 if sub_addr is None else 7 + + msg = IsoTpMessage(can_client, timeout=0, max_len=max_len, debug=self.debug) + msg.send(self.request[0]) + + msgs[tx_addr] = msg + request_counter[tx_addr] = 0 + request_done[tx_addr] = False + + results = {} + start_time = time.time() + while True: + self.rx() + + if all(request_done.values()): + break + + for tx_addr, msg in msgs.items(): + dat = msg.recv() + + if not dat: + continue + + counter = request_counter[tx_addr] + expected_response = self.response[counter] + response_valid = dat[:len(expected_response)] == expected_response + + if response_valid: + if counter + 1 < len(self.request): + msg.send(self.request[counter + 1]) + request_counter[tx_addr] += 1 + else: + results[tx_addr] = dat[len(expected_response):] + request_done[tx_addr] = True + else: + request_done[tx_addr] = True + cloudlog.warning(f"iso-tp query bad response: 0x{bytes.hex(dat)}") + + if time.time() - start_time > timeout: + break + + return results diff --git a/panda/tests/automated/__init__.py b/selfdrive/car/mazda/__init__.py similarity index 100% rename from panda/tests/automated/__init__.py rename to selfdrive/car/mazda/__init__.py diff --git a/selfdrive/car/mazda/carcontroller.py b/selfdrive/car/mazda/carcontroller.py new file mode 100644 index 00000000000000..20d80e519adf5c --- /dev/null +++ b/selfdrive/car/mazda/carcontroller.py @@ -0,0 +1,43 @@ +from selfdrive.car.mazda import mazdacan +from selfdrive.car.mazda.values import SteerLimitParams, Buttons +from opendbc.can.packer import CANPacker +from selfdrive.car import apply_std_steer_torque_limits + +class CarController(): + def __init__(self, dbc_name, CP, VM): + self.apply_steer_last = 0 + self.packer = CANPacker(dbc_name) + self.steer_rate_limited = False + + def update(self, enabled, CS, frame, actuators): + """ Controls thread """ + + can_sends = [] + + ### STEER ### + + if enabled: + # calculate steer and also set limits due to driver torque + new_steer = int(round(actuators.steer * SteerLimitParams.STEER_MAX)) + apply_steer = apply_std_steer_torque_limits(new_steer, self.apply_steer_last, + CS.out.steeringTorque, SteerLimitParams) + self.steer_rate_limited = new_steer != apply_steer + + if CS.out.standstill and frame % 20 == 0: + # Mazda Stop and Go requires a RES button (or gas) press if the car stops more than 3 seconds + # Send Resume button at 5hz if we're engaged at standstill to support full stop and go! + # TODO: improve the resume trigger logic by looking at actual radar data + can_sends.append(mazdacan.create_button_cmd(self.packer, CS.CP.carFingerprint, Buttons.RESUME)) + else: + apply_steer = 0 + self.steer_rate_limited = False + if CS.out.cruiseState.enabled and frame % 20 == 0: + # Cancel Stock ACC if it's enabled while OP is disengaged + # Send at a rate of 5hz until we sync with stock ACC state + can_sends.append(mazdacan.create_button_cmd(self.packer, CS.CP.carFingerprint, Buttons.CANCEL)) + + self.apply_steer_last = apply_steer + + can_sends.append(mazdacan.create_steering_control(self.packer, CS.CP.carFingerprint, + frame, apply_steer, CS.cam_lkas)) + return can_sends diff --git a/selfdrive/car/mazda/carstate.py b/selfdrive/car/mazda/carstate.py new file mode 100644 index 00000000000000..bc6c6d0eb9f27a --- /dev/null +++ b/selfdrive/car/mazda/carstate.py @@ -0,0 +1,188 @@ +from cereal import car +from selfdrive.config import Conversions as CV +from opendbc.can.can_define import CANDefine +from opendbc.can.parser import CANParser +from selfdrive.car.interfaces import CarStateBase +from selfdrive.car.mazda.values import DBC, LKAS_LIMITS, GEN1 + +class CarState(CarStateBase): + def __init__(self, CP): + super().__init__(CP) + + can_define = CANDefine(DBC[CP.carFingerprint]['pt']) + self.shifter_values = can_define.dv["GEAR"]['GEAR'] + + self.cruise_speed = 0 + self.acc_active_last = False + self.low_speed_lockout = True + self.low_speed_alert = False + self.lkas_allowed = False + + def update(self, cp, cp_cam): + + ret = car.CarState.new_message() + ret.wheelSpeeds.fl = cp.vl["WHEEL_SPEEDS"]['FL'] * CV.KPH_TO_MS + ret.wheelSpeeds.fr = cp.vl["WHEEL_SPEEDS"]['FR'] * CV.KPH_TO_MS + ret.wheelSpeeds.rl = cp.vl["WHEEL_SPEEDS"]['RL'] * CV.KPH_TO_MS + ret.wheelSpeeds.rr = cp.vl["WHEEL_SPEEDS"]['RR'] * CV.KPH_TO_MS + ret.vEgoRaw = (ret.wheelSpeeds.fl + ret.wheelSpeeds.fr + ret.wheelSpeeds.rl + ret.wheelSpeeds.rr) / 4. + ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) + + # Match panda speed reading + speed_kph = cp.vl["ENGINE_DATA"]['SPEED'] + ret.standstill = speed_kph < .1 + + can_gear = int(cp.vl["GEAR"]['GEAR']) + ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(can_gear, None)) + + ret.leftBlinker = cp.vl["BLINK_INFO"]['LEFT_BLINK'] == 1 + ret.rightBlinker = cp.vl["BLINK_INFO"]['RIGHT_BLINK'] == 1 + + ret.steeringAngle = cp.vl["STEER"]['STEER_ANGLE'] + ret.steeringTorque = cp.vl["STEER_TORQUE"]['STEER_TORQUE_SENSOR'] + ret.steeringPressed = abs(ret.steeringTorque) > LKAS_LIMITS.STEER_THRESHOLD + + ret.steeringTorqueEps = cp.vl["STEER_TORQUE"]['STEER_TORQUE_MOTOR'] + ret.steeringRate = cp.vl["STEER_RATE"]['STEER_ANGLE_RATE'] + + ret.brakePressed = cp.vl["PEDALS"]['BRAKE_ON'] == 1 + ret.brake = cp.vl["BRAKE"]['BRAKE_PRESSURE'] + ret.brakeLights = ret.brakePressed + + ret.seatbeltUnlatched = cp.vl["SEATBELT"]['DRIVER_SEATBELT'] == 0 + ret.doorOpen = any([cp.vl["DOORS"]['FL'], cp.vl["DOORS"]['FR'], + cp.vl["DOORS"]['BL'], cp.vl["DOORS"]['BR']]) + + ret.gas = cp.vl["ENGINE_DATA"]['PEDAL_GAS'] + ret.gasPressed = ret.gas > 0 + + ret.leftBlindspot = cp.vl["BSM"]['LEFT_BS1'] == 1 + ret.rightBlindspot = cp.vl["BSM"]['RIGHT_BS1'] == 1 + + # LKAS is enabled at 52kph going up and disabled at 45kph going down + if speed_kph > LKAS_LIMITS.ENABLE_SPEED: + self.lkas_allowed = True + elif speed_kph < LKAS_LIMITS.DISABLE_SPEED: + self.lkas_allowed = False + + # if any of the cruize buttons is pressed force state update + if any([cp.vl["CRZ_BTNS"]['RES'], + cp.vl["CRZ_BTNS"]['SET_P'], + cp.vl["CRZ_BTNS"]['SET_M']]): + self.cruise_speed = ret.vEgoRaw + + ret.cruiseState.available = True + ret.cruiseState.enabled = cp.vl["CRZ_CTRL"]['CRZ_ACTIVE'] == 1 + ret.cruiseState.speed = self.cruise_speed + + if ret.cruiseState.enabled: + if not self.lkas_allowed: + if not self.acc_active_last: + self.low_speed_lockout = True + else: + self.low_speed_alert = True + else: + self.low_speed_lockout = False + self.low_speed_alert = False + + # On if no driver torque the last 5 seconds + ret.steerWarning = cp.vl["STEER_RATE"]['HANDS_OFF_5_SECONDS'] == 1 + + self.acc_active_last = ret.cruiseState.enabled + + self.cam_lkas = cp_cam.vl["CAM_LKAS"] + ret.steerError = cp_cam.vl["CAM_LKAS"]['ERR_BIT_1'] == 1 + + return ret + + @staticmethod + def get_can_parser(CP): + # this function generates lists for signal, messages and initial values + signals = [ + # sig_name, sig_address, default + ("LEFT_BLINK", "BLINK_INFO", 0), + ("RIGHT_BLINK", "BLINK_INFO", 0), + ("STEER_ANGLE", "STEER", 0), + ("STEER_ANGLE_RATE", "STEER_RATE", 0), + ("STEER_TORQUE_SENSOR", "STEER_TORQUE", 0), + ("STEER_TORQUE_MOTOR", "STEER_TORQUE", 0), + ("FL", "WHEEL_SPEEDS", 0), + ("FR", "WHEEL_SPEEDS", 0), + ("RL", "WHEEL_SPEEDS", 0), + ("RR", "WHEEL_SPEEDS", 0), + ] + + checks = [ + # sig_address, frequency + ("BLINK_INFO", 10), + ("STEER", 67), + ("STEER_RATE", 83), + ("STEER_TORQUE", 83), + ("WHEEL_SPEEDS", 100), + ] + + if CP.carFingerprint in GEN1: + signals += [ + ("LKAS_BLOCK", "STEER_RATE", 0), + ("LKAS_TRACK_STATE", "STEER_RATE", 0), + ("HANDS_OFF_5_SECONDS", "STEER_RATE", 0), + ("CRZ_ACTIVE", "CRZ_CTRL", 0), + ("STANDSTILL", "PEDALS", 0), + ("BRAKE_ON", "PEDALS", 0), + ("BRAKE_PRESSURE", "BRAKE", 0), + ("GEAR", "GEAR", 0), + ("DRIVER_SEATBELT", "SEATBELT", 0), + ("FL", "DOORS", 0), + ("FR", "DOORS", 0), + ("BL", "DOORS", 0), + ("BR", "DOORS", 0), + ("PEDAL_GAS", "ENGINE_DATA", 0), + ("SPEED", "ENGINE_DATA", 0), + ("RES", "CRZ_BTNS", 0), + ("SET_P", "CRZ_BTNS", 0), + ("SET_M", "CRZ_BTNS", 0), + ("CTR", "CRZ_BTNS", 0), + ("LEFT_BS1", "BSM", 0), + ("RIGHT_BS1", "BSM", 0), + ] + + checks += [ + ("ENGINE_DATA", 100), + ("CRZ_CTRL", 50), + ("CRZ_BTNS", 10), + ("PEDALS", 50), + ("BRAKE", 50), + ("SEATBELT", 10), + ("DOORS", 10), + ("GEAR", 20), + ("BSM", 10), + ] + + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0) + + @staticmethod + def get_cam_can_parser(CP): + signals = [] + checks = [] + + if CP.carFingerprint in GEN1: + signals += [ + # sig_name, sig_address, default + ("LKAS_REQUEST", "CAM_LKAS", 0), + ("CTR", "CAM_LKAS", 0), + ("ERR_BIT_1", "CAM_LKAS", 0), + ("LINE_NOT_VISIBLE", "CAM_LKAS", 0), + ("LDW", "CAM_LKAS", 0), + ("BIT_1", "CAM_LKAS", 1), + ("ERR_BIT_2", "CAM_LKAS", 0), + ("STEERING_ANGLE", "CAM_LKAS", 0), + ("ANGLE_ENABLED", "CAM_LKAS", 0), + ("CHKSUM", "CAM_LKAS", 0), + ] + + checks += [ + # sig_address, frequency + ("CAM_LKAS", 16), + ] + + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2) diff --git a/selfdrive/car/mazda/interface.py b/selfdrive/car/mazda/interface.py new file mode 100755 index 00000000000000..a7ab0ee0cdbef2 --- /dev/null +++ b/selfdrive/car/mazda/interface.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python3 +from cereal import car +from selfdrive.config import Conversions as CV +from selfdrive.car.mazda.values import CAR, LKAS_LIMITS +from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint +from selfdrive.car.interfaces import CarInterfaceBase + +ButtonType = car.CarState.ButtonEvent.Type +EventName = car.CarEvent.EventName + +class CarInterface(CarInterfaceBase): + + @staticmethod + def compute_gb(accel, speed): + return float(accel) / 4.0 + + @staticmethod + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + ret = CarInterfaceBase.get_std_params(candidate, fingerprint) + + ret.carName = "mazda" + ret.safetyModel = car.CarParams.SafetyModel.mazda + + ret.dashcamOnly = True + + ret.radarOffCan = True + + ret.steerActuatorDelay = 0.1 + ret.steerRateCost = 1.0 + ret.steerLimitTimer = 0.8 + tire_stiffness_factor = 0.70 # not optimized yet + + if candidate == CAR.CX5: + ret.mass = 3655 * CV.LB_TO_KG + STD_CARGO_KG + ret.wheelbase = 2.7 + ret.steerRatio = 15.5 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.19], [0.019]] + ret.lateralTuning.pid.kf = 0.00006 + elif candidate == CAR.CX9: + ret.mass = 4217 * CV.LB_TO_KG + STD_CARGO_KG + ret.wheelbase = 3.1 + ret.steerRatio = 17.6 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.19], [0.019]] + ret.lateralTuning.pid.kf = 0.00006 + elif candidate == CAR.Mazda3: + ret.mass = 2875 * CV.LB_TO_KG + STD_CARGO_KG + ret.wheelbase = 2.7 + ret.steerRatio = 14.0 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.19], [0.019]] + ret.lateralTuning.pid.kf = 0.00006 + + # No steer below disable speed + ret.minSteerSpeed = LKAS_LIMITS.DISABLE_SPEED * CV.KPH_TO_MS + + ret.centerToFront = ret.wheelbase * 0.41 + + # TODO: get actual value, for now starting with reasonable value for + # civic and scaling by mass and wheelbase + ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) + + # TODO: start from empirically derived lateral slip stiffness for the civic and scale by + # mass and CG position, so all cars will have approximately similar dyn behaviors + ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront, + tire_stiffness_factor=tire_stiffness_factor) + + ret.enableCamera = True + + return ret + + # returns a car.CarState + def update(self, c, can_strings): + + self.cp.update_strings(can_strings) + self.cp_cam.update_strings(can_strings) + + ret = self.CS.update(self.cp, self.cp_cam) + ret.canValid = self.cp.can_valid and self.cp_cam.can_valid + + # events + events = self.create_common_events(ret) + + if self.CS.low_speed_lockout: + events.add(EventName.belowEngageSpeed) + + if self.CS.low_speed_alert: + events.add(EventName.belowSteerSpeed) + + ret.events = events.to_msg() + + self.CS.out = ret.as_reader() + return self.CS.out + + def apply(self, c): + can_sends = self.CC.update(c.enabled, self.CS, self.frame, c.actuators) + self.frame += 1 + return can_sends diff --git a/selfdrive/car/mazda/mazdacan.py b/selfdrive/car/mazda/mazdacan.py new file mode 100644 index 00000000000000..dabbd2129d8823 --- /dev/null +++ b/selfdrive/car/mazda/mazdacan.py @@ -0,0 +1,104 @@ +from selfdrive.car.mazda.values import GEN1, Buttons + +def create_steering_control(packer, car_fingerprint, frame, apply_steer, lkas): + + tmp = apply_steer + 2048 + + lo = tmp & 0xFF + hi = tmp >> 8 + + b1 = int(lkas["BIT_1"]) + ldw = int(lkas["LDW"]) + er1 = int(lkas["ERR_BIT_1"]) + lnv = 0 + er2 = int(lkas["ERR_BIT_2"]) + + steering_angle = int(lkas["STEERING_ANGLE"]) + b2 = int(lkas["ANGLE_ENABLED"]) + + tmp = steering_angle + 2048 + ahi = tmp >> 10 + amd = (tmp & 0x3FF) >> 2 + amd = (amd >> 4) | (( amd & 0xF) << 4) + alo = (tmp & 0x3) << 2 + + ctr = frame % 16 + # bytes: [ 1 ] [ 2 ] [ 3 ] [ 4 ] + csum = 249 - ctr - hi - lo - (lnv << 3) - er1 - (ldw << 7) - ( er2 << 4) - (b1 << 5) + + #bytes [ 5 ] [ 6 ] [ 7 ] + csum = csum - ahi - amd - alo - b2 + + if ahi == 1: + csum = csum + 15 + + if csum < 0: + if csum < -256: + csum = csum + 512 + else: + csum = csum + 256 + + csum = csum % 256 + + if car_fingerprint in GEN1: + values = { + "LKAS_REQUEST" : apply_steer, + "CTR" : ctr, + "ERR_BIT_1" : er1, + "LINE_NOT_VISIBLE" : lnv, + "LDW" : ldw, + "BIT_1" : b1, + "ERR_BIT_2" : er2, + "STEERING_ANGLE" : steering_angle, + "ANGLE_ENABLED" : b2, + "CHKSUM" : csum + } + + return packer.make_can_msg("CAM_LKAS", 0, values) + + +def create_button_cmd(packer, car_fingerprint, button): + + if button == Buttons.CANCEL: + can = 1 + res = 0 + elif button == Buttons.RESUME: + can = 0 + res = 1 + else: + can = 0 + res = 0 + + if car_fingerprint in GEN1: + values = { + "CAN_OFF" : can, + "CAN_OFF_INV" : (can + 1) % 2, + + "SET_P" : 0, + "SET_P_INV" : 1, + + "RES" : res, + "RES_INV" : (res + 1) % 2, + + "SET_M" : 0, + "SET_M_INV" : 1, + + "DISTANCE_LESS" : 0, + "DISTANCE_LESS_INV" : 1, + + "DISTANCE_MORE" : 0, + "DISTANCE_MORE_INV" : 1, + + "MODE_X" : 0, + "MODE_X_INV" : 1, + + "MODE_Y" : 0, + "MODE_Y_INV" : 1, + + "BIT1" : 1, + "BIT2" : 1, + "BIT3" : 1, + "CTR" : 0 + } + + return packer.make_can_msg("CRZ_BTNS", 0, values) diff --git a/selfdrive/car/mazda/radar_interface.py b/selfdrive/car/mazda/radar_interface.py new file mode 100755 index 00000000000000..b2f76511360320 --- /dev/null +++ b/selfdrive/car/mazda/radar_interface.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python3 +from selfdrive.car.interfaces import RadarInterfaceBase + +class RadarInterface(RadarInterfaceBase): + pass diff --git a/selfdrive/car/mazda/values.py b/selfdrive/car/mazda/values.py new file mode 100644 index 00000000000000..81c2b2b4a43fdb --- /dev/null +++ b/selfdrive/car/mazda/values.py @@ -0,0 +1,81 @@ +# flake8: noqa + +from selfdrive.car import dbc_dict +from cereal import car +Ecu = car.CarParams.Ecu + + +# Steer torque limits + +class SteerLimitParams: + STEER_MAX = 600 # max_steer 2048 + STEER_STEP = 1 # how often we update the steer cmd + STEER_DELTA_UP = 10 # torque increase per refresh + STEER_DELTA_DOWN = 20 # torque decrease per refresh + STEER_DRIVER_ALLOWANCE = 15 # allowed driver torque before start limiting + STEER_DRIVER_MULTIPLIER = 1 # weight driver torque + STEER_DRIVER_FACTOR = 1 # from dbc + +class CAR: + CX5 = "Mazda CX-5 2017" + CX9 = "Mazda CX-9 2017" + Mazda3 = "Mazda3 2017" + +class LKAS_LIMITS: + STEER_THRESHOLD = 15 + DISABLE_SPEED = 45 # kph + ENABLE_SPEED = 52 # kph + +class Buttons: + NONE = 0 + SET_PLUS = 1 + SET_MINUS = 2 + RESUME = 3 + CANCEL = 4 + +FINGERPRINTS = { + CAR.CX5: [ + # CX-5 2017 GT + { + 64: 8, 70: 8, 80: 8, 117: 8, 118: 8, 120: 8, 121: 8, 130: 8, 134: 8, 145: 8, 154: 8, 155: 8, 157: 8, 158: 8, 159: 8, 253: 8, 304: 8, 305: 8, 357: 8, 358: 8, 359: 8, 512: 8, 514: 8, 515: 8, 529: 8, 533: 8, 535: 8, 539: 8, 540: 8, 541: 8, 542: 8, 543: 8, 552: 8, 576: 8, 577: 8, 578: 8, 579: 8, 580: 8, 581: 8, 582: 8, 605: 8, 606: 8, 607: 8, 608: 8, 628: 8, 832: 8, 836: 8, 863: 8, 865: 8, 866: 8, 867: 8, 868: 8, 869: 8, 870: 8, 976: 8, 977: 8, 978: 8, 1034: 8, 1045: 8, 1056: 8, 1061: 8, 1067: 8, 1070: 8, 1078: 8, 1080: 8, 1085: 8, 1086: 8, 1088: 8, 1093: 8, 1108: 8, 1114: 8, 1115: 8, 1116: 8, 1139: 8, 1143: 8, 1147: 8, 1154: 8, 1157: 8, 1160: 8, 1163: 8, 1166: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1183: 8, 1233: 8, 1236: 8, 1237: 8, 1238: 8, 1239: 8, 1241: 8, 1242: 8, 1243: 8, 1244: 8, 1264: 8, 1266: 8, 1267: 8, 1269: 8, 1270: 8, 1271: 8, 1272: 8, 1274: 8, 1275: 8, 1277: 8, 1278: 8, 1409: 8, 1416: 8, 1425: 8, 1430: 8, 1435: 8, 1440: 8, 1446: 8, 1456: 8, 1479: 8 + }, + + # CX-5 2019 GTR + { + 64: 8, 70: 8, 80: 8, 117: 8, 118: 8, 120: 8, 121: 8, 130: 8, 134: 8, 145: 8, 154: 8, 155: 8, 157: 8, 158: 8, 159: 8, 253: 8, 254: 8, 304: 8, 305: 8, 357: 8, 358: 8, 359: 8, 512: 8, 514: 8, 515: 8, 529: 8, 533: 8, 535: 8, 539: 8, 540: 8, 541: 8, 542: 8, 543: 8, 552: 8, 576: 8, 577: 8, 578: 8, 579: 8, 580: 8, 581: 8, 582: 8, 605: 8, 606: 8, 607: 8, 608: 8, 628: 8, 736: 8, 832: 8, 836: 8, 863: 8, 865: 8, 866: 8, 867: 8, 868: 8, 869: 8, 870: 8, 976: 8, 977: 8, 978: 8, 1034: 8, 1045: 8, 1056: 8, 1061: 8, 1067: 8, 1078: 8, 1080: 8, 1085: 8, 1086: 8, 1088: 8, 1093: 8, 1108: 8, 1114: 8, 1115: 8, 1116: 8, 1139: 8, 1143: 8, 1147: 8, 1154: 8, 1157: 8, 1160: 8, 1163: 8, 1166: 8, 1170: 8, 1171: 8, 1173: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1183: 8, 1233: 8, 1236: 8, 1237: 8, 1238: 8, 1239: 8, 1241: 8, 1242: 8, 1244: 8, 1260: 8, 1264: 8, 1266: 8, 1267: 8, 1269: 8, 1270: 8, 1271: 8, 1272: 8, 1274: 8, 1277: 8, 1278: 8, 1409: 8, 1416: 8, 1425: 8, 1430: 8, 1435: 8, 1440: 8, 1446: 8, 1456: 8, 1479: 8, 1776: 8, 1792: 8, 1872: 8, 1937: 8, 1953: 8, 1968: 8, 2015: 8, 2016: 8, 2024: 8 + } + ], + + CAR.CX9: [ + # CX-9 2017 Australia - old CAM connector + { + 64: 8, 70: 8, 80: 8, 117: 8, 118: 8, 120: 8, 121: 8, 130: 8, 134: 8, 138: 8, 145: 8, 154: 8, 155: 8, 157: 8, 158: 8, 159: 8, 253: 8, 304: 8, 305: 8, 357: 8, 358: 8, 359: 8, 512: 8, 514: 8, 515: 8, 522: 8, 529: 8, 533: 8, 535: 8, 539: 8, 540: 8, 541: 8, 542: 8, 543: 8, 552: 8, 576: 8, 577: 8, 578: 8, 579: 8, 580: 8, 581: 8, 582: 8, 583: 8, 605: 8, 606: 8, 628: 8, 832: 8, 976: 8, 977: 8, 978: 8, 1034: 8, 1045: 8, 1056: 8, 1061: 8, 1067: 8, 1078: 8, 1085: 8, 1086: 8, 1088: 8, 1093: 8, 1108: 8, 1114: 8, 1115: 8, 1116: 8, 1139: 8, 1143: 8, 1147: 8, 1154: 8, 1157: 8, 1160: 8, 1163: 8, 1166: 8, 1170: 8, 1177: 8, 1180: 8, 1183: 8, 1233: 8, 1236: 8, 1237: 8, 1238: 8, 1239: 8, 1241: 8, 1242: 8, 1243: 8, 1244: 8, 1247: 8, 1264: 8, 1266: 8, 1267: 8, 1269: 8, 1271: 8, 1272: 8, 1274: 8, 1277: 8, 1278: 8, 1409: 8, 1416: 8, 1425: 8, 1430: 8, 1435: 8, 1440: 8, 1446: 8, 1456: 8, 1479: 8 + }, + + # CX-9 2016 - old CAM connector + { + 64: 8, 70: 8, 80: 8, 117: 8, 118: 8, 120: 8, 121: 8, 130: 8, 134: 8, 145: 8, 154: 8, 155: 8, 157: 8, 158: 8, 159: 8, 253: 8, 304: 8, 305: 8, 357: 8, 358: 8, 359: 8, 512: 8, 514: 8, 515: 8, 529: 8, 533: 8, 535: 8, 539: 8, 540: 8, 541: 8, 542: 8, 543: 8, 552: 8, 576: 8, 577: 8, 578: 8, 579: 8, 580: 8, 581: 8, 582: 8, 583: 8, 605: 8, 606: 8, 608: 8, 628: 8, 832: 8, 836: 8, 976: 8, 977: 8, 978: 8, 1034: 8, 1045: 8, 1056: 8, 1061: 8, 1067: 8, 1078: 8, 1080: 8, 1085: 8, 1086: 8, 1088: 8, 1093: 8, 1108: 8, 1114: 8, 1115: 8, 1116: 8, 1139: 8, 1143: 8, 1147: 8, 1154: 8, 1157: 8, 1160: 8, 1163: 8, 1166: 8, 1170: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1183: 8, 1233: 8, 1236: 8, 1237: 8, 1238: 8, 1239: 8, 1241: 8, 1242: 8, 1244: 8, 1264: 8, 1266: 8, 1267: 8, 1269: 8, 1271: 8, 1272: 8, 1274: 8, 1277: 8, 1278: 8, 1409: 8, 1416: 8, 1425: 8, 1430: 8, 1435: 8, 1440: 8, 1446: 8, 1456: 8, 1479: 8, 1792: 8, 1872: 8, 1937: 8, 1953: 8, 1968: 8, 1988: 8, 1996: 8, 2000: 8, 2001: 8, 2004: 8, 2015: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8 + } + ], + + CAR.Mazda3: [ + # Mazda 3 2017 + { + 19: 5, 80: 8, 117: 8, 118: 8, 120: 8, 121: 8, 130: 8, 134: 8, 145: 8, 154: 8, 155: 8, 157: 8, 158: 8, 159: 8, 253: 8, 304: 8, 305: 8, 357: 8, 358: 8, 359: 8, 512: 8, 514: 8, 515: 8, 529: 8, 533: 8, 535: 8, 539: 8, 540: 8, 541: 8, 542: 8, 543: 8, 552: 8, 576: 8, 577: 8, 578: 8, 579: 8, 580: 8, 581: 8, 582: 8, 605: 8, 606: 8, 607: 8, 628: 8, 832: 8, 863: 8, 865: 8, 866: 8, 867: 8, 868: 8, 869: 8, 870: 8, 976: 8, 977: 8, 978: 8, 1034: 8, 1045: 8, 1056: 8, 1061: 8, 1067: 8, 1070: 8, 1078: 8, 1086: 8, 1088: 8, 1093: 8, 1108: 8, 1114: 8, 1115: 8, 1116: 8, 1143: 8, 1147: 8, 1154: 8, 1157: 8, 1160: 8, 1163: 8, 1166: 8, 1169: 8, 1170: 8, 1173: 8, 1177: 8, 1180: 8, 1182: 8, 1183: 8, 1233: 8, 1236: 8, 1237: 8, 1238: 8, 1239: 8, 1241: 8, 1242: 8, 1243: 8, 1244: 8, 1264: 8, 1266: 8, 1267: 8, 1269: 8, 1270: 8, 1271: 8, 1272: 8, 1274: 8, 1275: 8, 1277: 8, 1278: 8, 1409: 8, 1416: 8, 1425: 8, 1430: 8, 1435: 8, 1440: 8, 1456: 8, 1479: 8, 2015: 8, 2024: 8, 2025: 8 + }, + + # Mazda 6 2017 GT + { + 64: 8, 70: 8, 80: 8, 117: 8, 118: 8, 120: 8, 121: 8, 130: 8, 134: 8, 145: 8, 154: 8, 155: 8, 157: 8, 158: 8, 159: 8, 253: 8, 304: 8, 305: 8, 357: 8, 358: 8, 359: 8, 512: 8, 514: 8, 515: 8, 529: 8, 533: 8, 535: 8, 539: 8, 540: 8, 541: 8, 542: 8, 543: 8, 552: 8, 576: 8, 577: 8, 578: 8, 579: 8, 580: 8, 581: 8, 582: 8, 605: 8, 606: 8, 607: 8, 628: 8, 832: 8, 836: 8, 863: 8, 865: 8, 866: 8, 867: 8, 868: 8, 869: 8, 870: 8, 976: 8, 977: 8, 978: 8, 1034: 8, 1045: 8, 1056: 8, 1061: 8, 1067: 8, 1070: 8, 1078: 8, 1080: 8, 1085: 8, 1086: 8, 1088: 8, 1093: 8, 1108: 8, 1114: 8, 1115: 8, 1116: 8, 1143: 8, 1147: 8, 1154: 8, 1157: 8, 1160: 8, 1163: 8, 1166: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1182: 8, 1183: 8, 1233: 8, 1236: 8, 1237: 8, 1238: 8, 1239: 8, 1241: 8, 1242: 8, 1243: 8, 1244: 8, 1264: 8, 1266: 8, 1267: 8, 1269: 8, 1270: 8, 1271: 8, 1272: 8, 1274: 8, 1275: 8, 1277: 8, 1278: 8, 1409: 8, 1416: 8, 1425: 8, 1430: 8, 1435: 8, 1440: 8, 1456: 8, 1479: 8 + } + ], +} + + +DBC = { + CAR.CX5: dbc_dict('mazda_2017', None), + CAR.CX9: dbc_dict('mazda_2017', None), + CAR.Mazda3: dbc_dict('mazda_2017', None), +} + +GEN1 = [ CAR.CX5, CAR.CX9, CAR.Mazda3 ] diff --git a/selfdrive/car/mock/interface.py b/selfdrive/car/mock/interface.py index c19a523861e6e2..f75d1c58ffcd26 100755 --- a/selfdrive/car/mock/interface.py +++ b/selfdrive/car/mock/interface.py @@ -1,28 +1,27 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from cereal import car from selfdrive.config import Conversions as CV -from selfdrive.services import service_list from selfdrive.swaglog import cloudlog -import selfdrive.messaging as messaging +import cereal.messaging as messaging +from selfdrive.car import gen_empty_fingerprint +from selfdrive.car.interfaces import CarInterfaceBase # mocked car interface to work with chffrplus TS = 0.01 # 100Hz -YAW_FR = 0.2 # ~0.8s time constant on yaw rate filter +YAW_FR = 0.2 # ~0.8s time constant on yaw rate filter # low pass gain LPG = 2 * 3.1415 * YAW_FR * TS / (1 + 2 * 3.1415 * YAW_FR * TS) -class CarInterface(object): - def __init__(self, CP, CarController): - - self.CP = CP - self.CC = CarController +class CarInterface(CarInterfaceBase): + def __init__(self, CP, CarController, CarState): + super().__init__(CP, CarController, CarState) cloudlog.debug("Using Mock Car Interface") # TODO: subscribe to phone sensor - self.sensor = messaging.sub_sock(service_list['sensorEvents'].port) - self.gps = messaging.sub_sock(service_list['gpsLocation'].port) + self.sensor = messaging.sub_sock('sensorEvents') + self.gps = messaging.sub_sock('gpsLocation') self.speed = 0. self.prev_speed = 0. @@ -34,48 +33,17 @@ def compute_gb(accel, speed): return accel @staticmethod - def calc_accel_override(a_ego, a_target, v_ego, v_target): - return 1.0 - - @staticmethod - def get_params(candidate, fingerprint, vin="", is_panda_black=False): - - ret = car.CarParams.new_message() - + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "mock" - ret.carFingerprint = candidate - ret.safetyModel = car.CarParams.SafetyModel.noOutput - ret.openpilotLongitudinalControl = False - - # FIXME: hardcoding honda civic 2016 touring params so they can be used to - # scale unknown params for other cars ret.mass = 1700. ret.rotationalInertia = 2500. ret.wheelbase = 2.70 ret.centerToFront = ret.wheelbase * 0.5 - ret.steerRatio = 13. # reasonable + ret.steerRatio = 13. # reasonable ret.tireStiffnessFront = 1e6 # very stiff to neglect slip ret.tireStiffnessRear = 1e6 # very stiff to neglect slip - ret.steerRatioRear = 0. - - ret.steerMaxBP = [0.] - ret.steerMaxV = [0.] # 2/3rd torque allowed above 45 kph - ret.gasMaxBP = [0.] - ret.gasMaxV = [0.] - ret.brakeMaxBP = [0.] - ret.brakeMaxV = [0.] - - ret.longitudinalTuning.kpBP = [0.] - ret.longitudinalTuning.kpV = [0.] - ret.longitudinalTuning.kiBP = [0.] - ret.longitudinalTuning.kiV = [0.] - ret.longitudinalTuning.deadzoneBP = [0.] - ret.longitudinalTuning.deadzoneV = [0.] - ret.steerActuatorDelay = 0. - # ret.steerReactance = 0.7 - # ret.steerInductance = 1.0 - # ret.steerResistance = 1.0 return ret @@ -95,6 +63,7 @@ def update(self, c, can_strings): # create message ret = car.CarState.new_message() + ret.canValid = True # speeds ret.vEgo = self.speed @@ -104,19 +73,16 @@ def update(self, c, can_strings): ret.aEgo = a ret.brakePressed = a < -0.5 - self.yawRate = LPG * self.yaw_rate_meas + (1. - LPG) * self.yaw_rate - ret.yawRate = self.yaw_rate ret.standstill = self.speed < 0.01 ret.wheelSpeeds.fl = self.speed ret.wheelSpeeds.fr = self.speed ret.wheelSpeeds.rl = self.speed ret.wheelSpeeds.rr = self.speed + + self.yawRate = LPG * self.yaw_rate_meas + (1. - LPG) * self.yaw_rate curvature = self.yaw_rate / max(self.speed, 1.) ret.steeringAngle = curvature * self.CP.steerRatio * self.CP.wheelbase * CV.RAD_TO_DEG - events = [] - ret.events = events - return ret.as_reader() def apply(self, c): diff --git a/selfdrive/car/mock/radar_interface.py b/selfdrive/car/mock/radar_interface.py index 8e5f7b7fcaf150..b2f76511360320 100755 --- a/selfdrive/car/mock/radar_interface.py +++ b/selfdrive/car/mock/radar_interface.py @@ -1,15 +1,5 @@ -#!/usr/bin/env python -from cereal import car -import time +#!/usr/bin/env python3 +from selfdrive.car.interfaces import RadarInterfaceBase - -class RadarInterface(object): - def __init__(self, CP): - # radar - self.pts = {} - self.delay = 0.1 - - def update(self, can_strings): - ret = car.RadarData.new_message() - time.sleep(0.05) # radard runs on RI updates - return ret +class RadarInterface(RadarInterfaceBase): + pass diff --git a/selfdrive/car/modules/ALCA_module.py b/selfdrive/car/modules/ALCA_module.py index 4305d377f4e456..6c2aaf92610342 100644 --- a/selfdrive/car/modules/ALCA_module.py +++ b/selfdrive/car/modules/ALCA_module.py @@ -31,6 +31,7 @@ HISTORY ------- +v4.1 - OP 0.6.5 operating model v4.0 - integrated into model_parser.py v3.6 - moved parameters to carstate.py v3.5 - changing the start angle to keep turning until we reach MAX_ANGLE_DELTA @@ -43,12 +44,11 @@ v1.0 - fixed angle move """ -from common.numpy_fast import interp +from common.numpy_fast import interp,clip from selfdrive.controls.lib.pid import PIController from common.realtime import sec_since_boot -from selfdrive.services import service_list -import selfdrive.messaging as messaging -import zmq +from cereal.services import service_list +import cereal.messaging as messaging import numpy as np from cereal import tesla @@ -56,69 +56,89 @@ WAIT_TIME_AFTER_TURN = 2.0 #ALCA -ALCA_line_check_low_limit = 0.25 -ALCA_line_check_high_limit = 0.75 -ALCA_line_min_prob = 0.1 +ALCA_line_min_prob = 0.01 ALCA_release_distance = 0.3 +ALCA_line_prob_low = 0.2 +ALCA_line_prob_high = 0.4 +ALCA_distance_jump = 1.1 +ALCA_lane_change_coefficient = 0.7 +ITERATIONS_AHEAD_TO_ESTIMATE = 2 +ALCA_duration_seconds = 5. +ALCA_right_lane_multiplier = 1. +ALCA_distance_left_min = 0.7 -ALCA_DEBUG = True +ALCA_DEBUG = False +DEBUG_INFO = "step {step} of {total_steps}: direction = {ALCA_direction} | using visual = {ALCA_use_visual} | over line = {ALCA_over_line} | lane width = {ALCA_lane_width} | left to move = {left_to_move} | from center = {from_center} | C2 offset = {ALCA_OFFSET_C2} | C1 offset = {ALCA_OFFSET_C1} | Prob Low = {prob_low} | Prob High = {prob_high}" -class ALCAController(object): + +class ALCAController(): def __init__(self,carcontroller,alcaEnabled,steerByAngle): #import settings + self.frame = 0 self.CC = carcontroller # added to start, will see if we need it actually # variables for lane change self.angle_offset = 0. #added when one needs to compensate for missalignment self.alcaEnabled = alcaEnabled - self.alca_duration = [2., 3.5, 5.] - self.laneChange_strStartFactor = 2. - self.laneChange_strStartMultiplier = 1.5 - self.laneChange_steerByAngle = steerByAngle # steer only by angle; do not call PID - self.laneChange_last_actuator_angle = 0. - self.laneChange_last_actuator_delta = 0. - self.laneChange_last_sent_angle = 0. self.laneChange_over_the_line = 0 # did we cross the line? - self.laneChange_avg_angle = 0. # used if we do average entry angle over x frames - self.laneChange_avg_count = 0. # used if we do average entry angle over x frames self.laneChange_enabled = 1 # set to zero for no lane change self.laneChange_counter = 0 # used to count frames during lane change - self.laneChange_min_duration = 2. # min time to wait before looking for next lane - self.laneChange_duration = 5.6 # how many max seconds to actually do the move; if lane not found after this then send error - self.laneChange_after_lane_duration_mult = 1. # multiplier for time after we cross the line before we let OP take over; multiplied with CL_TIMEA_T - self.laneChange_wait = 1 # how many seconds to wait before it starts the change - self.laneChange_lw = 3.7 # lane width in meters - self.laneChange_angle = 0. # saves the last angle from actuators before lane change starts - self.laneChange_angled = 0. # angle delta - self.laneChange_steerr = 15.75 # steer ratio for lane change starting with the Tesla one + self.laneChange_wait = 2 # how many seconds to wait before it starts the change self.laneChange_direction = 0 # direction of the lane change - self.prev_right_blinker_on = False # local variable for prev position - self.prev_left_blinker_on = False # local variable for prev position - self.keep_angle = False #local variable to keep certain angle delta vs. actuator - self.last10delta = [] self.laneChange_cancelled = False self.laneChange_cancelled_counter = 0 - self.last_time_enabled = 0 + self.alcaStatusSocket = messaging.pub_sock('alcaStatus') + + def debug_alca(self,message): + if ALCA_DEBUG: + print (message) + + def send_status(self,CS): + CS.ALCA_enabled = (self.laneChange_enabled > 1) and self.alcaEnabled + CS.ALCA_total_steps = int(20 * ALCA_duration_seconds) + if self.laneChange_enabled == 3: + CS.ALCA_direction = -self.laneChange_direction + else: + CS.ALCA_direction = 0 + if not (self.frame % 20 == 0): + return + alca_status = tesla.ALCAStatus.new_message() + alca_status.alcaEnabled = bool(CS.ALCA_enabled) + alca_status.alcaTotalSteps = int(CS.ALCA_total_steps) + alca_status.alcaDirection = int(CS.ALCA_direction) + alca_status.alcaError = bool(CS.ALCA_error) + self.alcaStatusSocket.send(alca_status.to_bytes()) def update_status(self,alcaEnabled): self.alcaEnabled = alcaEnabled - def stop_ALCA(self, CS): + def stop_ALCA(self, CS, isDone): # something is not right; ALCAModelParser is not engaged; cancel - CS.UE.custom_alert_message(3,"Auto Lane Change Canceled! (d)",200,5) - self.laneChange_cancelled = True - self.laneChange_cancelled_counter = 200 + self.debug_alca("ALCA canceled: stop_ALCA called") + if not isDone: + CS.UE.custom_alert_message(3,"Auto Lane Change Canceled! (d)",200,5) + self.laneChange_cancelled = True + self.laneChange_cancelled_counter = 200 + else: + self.laneChange_cancelled = False + self.laneChange_cancelled_counter = 0 self.laneChange_enabled = 1 self.laneChange_counter = 0 self.laneChange_direction = 0 CS.cstm_btns.set_button_status("alca",1) + self.send_status(CS) - def update(self,enabled,CS,actuators): + def update(self,enabled,CS,actuators,alcaStateData,frame,blinker): cl_min_v = CS.CL_MIN_V cl_max_a = CS.CL_MAX_A - alca_mode = CS.cstm_btns.get_button_label2_index("alca") + self.frame = frame + + if (alcaStateData is not None) and (((self.laneChange_direction != 0) and alcaStateData.alcaError) or (alcaStateData.alcaDirection == 100)): + self.debug_alca("ALCA canceled: stop_ALCA called (1)") + self.stop_ALCA(CS,alcaStateData.alcaDirection == 100) + return 0, False if self.laneChange_cancelled_counter > 0: self.laneChange_cancelled_counter -= 1 @@ -126,26 +146,13 @@ def update(self,enabled,CS,actuators): self.laneChange_cancelled = False # Basic highway lane change logic - actuator_delta = 0. - laneChange_angle = 0. - turn_signal_needed = 0 # send 1 for left, 2 for right 0 for not needed - - if (not CS.right_blinker_on) and (not CS.left_blinker_on) and \ - (self.laneChange_enabled == 4): - self.laneChange_enabled =1 - self.laneChange_counter =0 - self.laneChange_direction =0 - CS.UE.custom_alert_message(-1,"",0) - - if (not CS.right_blinker_on) and (not CS.left_blinker_on) and \ - (self.laneChange_enabled > 1): - # no blinkers on but we are still changing lane, so we need to send blinker command - if self.laneChange_direction == -1: - turn_signal_needed = 1 - elif self.laneChange_direction == 1: - turn_signal_needed = 2 - else: - turn_signal_needed = 0 + + if self.laneChange_enabled == 4 and frame > blinker.override_frame_end: + self.debug_alca("ALCA reset: resetting 4 -> 1") + self.laneChange_enabled = 1 + self.laneChange_counter = 0 + self.laneChange_direction = 0 + CS.UE.custom_alert_message(-1, "", 0) if (CS.cstm_btns.get_button_status("alca") > 0) and self.alcaEnabled and (self.laneChange_enabled == 1): if ((CS.v_ego < cl_min_v) or (abs(actuators.steerAngle) >= cl_max_a) or \ @@ -154,49 +161,42 @@ def update(self,enabled,CS,actuators): else: CS.cstm_btns.set_button_status("alca",1) - if self.alcaEnabled and enabled and (((not self.prev_right_blinker_on) and CS.right_blinker_on) or \ - ((not self.prev_left_blinker_on) and CS.left_blinker_on)) and \ + if self.alcaEnabled and enabled and (self.laneChange_enabled > 1) and \ ((CS.v_ego < cl_min_v) or (abs(actuators.steerAngle) >= cl_max_a) or (abs(CS.angle_steers) >=cl_max_a)): # something is not right, the speed or angle is limitting - CS.UE.custom_alert_message(3,"Auto Lane Change Unavailable!",500,3) + self.debug_alca("ALCA Unavailable (2)") + CS.UE.custom_alert_message(3,"Auto Lane Change Unavailable!",200,3) CS.cstm_btns.set_button_status("alca",9) + self.stop_ALCA(CS, False) + return 0, False - - if self.alcaEnabled and enabled and (((not self.prev_right_blinker_on) and CS.right_blinker_on) or \ - ((not self.prev_left_blinker_on) and CS.left_blinker_on)) and \ - (CS.v_ego >= cl_min_v) and (abs(actuators.steerAngle) < cl_max_a): + if self.alcaEnabled and enabled and blinker.tap_direction != 0 and \ + (CS.v_ego >= cl_min_v) and (abs(actuators.steerAngle) < cl_max_a) and (self.laneChange_enabled == 1): # start blinker, speed and angle is within limits, let's go - laneChange_direction = 1 - # changing lanes - if CS.left_blinker_on: - laneChange_direction = -1 - - if (self.laneChange_enabled > 1) and (self.laneChange_direction <> laneChange_direction): - # something is not right; signal in oposite direction; cancel - CS.UE.custom_alert_message(3,"Auto Lane Change Canceled! (s)",200,5) - self.laneChange_cancelled = True - self.laneChange_cancelled_counter = 200 - self.laneChange_enabled = 1 - self.laneChange_counter = 0 - self.laneChange_direction = 0 - CS.cstm_btns.set_button_status("alca",1) - elif (self.laneChange_enabled == 1) : - # compute angle delta for lane change - CS.UE.custom_alert_message(2,"Auto Lane Change Engaged!",100) - self.laneChange_enabled = 2 - self.laneChange_counter = 1 - self.laneChange_direction = laneChange_direction - CS.cstm_btns.set_button_status("alca",2) + laneChange_direction = -1 if blinker.tap_direction == 1 else 1 # left -1, right 1 + blinker.override_direction = blinker.tap_direction + self.debug_alca("ALCA blinker tap detected") + + CS.UE.custom_alert_message(2,"Auto Lane Change Engaged!",100) + self.debug_alca("ALCA engaged") + self.laneChange_enabled = 2 + self.laneChange_counter = 1 + self.laneChange_direction = laneChange_direction + CS.cstm_btns.set_button_status("alca",2) if (not self.alcaEnabled) and self.laneChange_enabled > 1: + self.debug_alca("ALCA canceled: not enabled") self.laneChange_enabled = 1 self.laneChange_counter = 0 self.laneChange_direction = 0 + self.stop_ALCA(CS, False) + return 0, False # lane change in progress if self.laneChange_enabled > 1: if (CS.steer_override or (CS.v_ego < cl_min_v)): CS.UE.custom_alert_message(4,"Auto Lane Change Canceled! (u)",200,3) + self.debug_alca("ALCA canceled: steer override") self.laneChange_cancelled = True self.laneChange_cancelled_counter = 200 # if any steer override cancel process or if speed less than min speed @@ -204,238 +204,252 @@ def update(self,enabled,CS,actuators): self.laneChange_enabled = 1 self.laneChange_direction = 0 CS.cstm_btns.set_button_status("alca",1) + self.stop_ALCA(CS, False) + return 0, False if self.laneChange_enabled == 2: if self.laneChange_counter == 1: CS.UE.custom_alert_message(2,"Auto Lane Change Engaged! (1)",self.laneChange_wait * 100) self.laneChange_counter += 1 + self.debug_alca("ALCA phase 2: " + str(self.laneChange_counter)) if self.laneChange_counter == self.laneChange_wait * 100: self.laneChange_enabled = 3 self.laneChange_counter = 0 if self.laneChange_enabled ==3: if self.laneChange_counter == 1: - CS.UE.custom_alert_message(2,"Auto Lane Change Engaged! (2)",int(self.alca_duration[alca_mode] * 100)) + CS.UE.custom_alert_message(2,"Auto Lane Change Engaged! (2)",int(ALCA_duration_seconds * 100)) self.laneChange_counter += 1 - if self.laneChange_counter >= self.alca_duration[alca_mode] * 100: + self.debug_alca("ALCA phase 3: " + str(self.laneChange_counter)) + if self.laneChange_counter >= (ALCA_duration_seconds + 2) * 100.: + self.debug_alca("ALCA phase 3: Canceled due to time restriction") self.laneChange_enabled = 4 self.laneChange_counter = 0 if self.laneChange_enabled == 4: + self.debug_alca("ALCA phase 4: " +str(self.laneChange_counter)) if self.laneChange_counter == 1: CS.UE.custom_alert_message(2,"Auto Lane Change Complete!",100) self.laneChange_enabled = 1 self.laneChange_counter = 0 + self.stop_ALCA(CS, True) + return 0, False + else: + blinker.override_frame_end = max(blinker.override_frame_end, frame + 25) - CS.ALCA_enabled = (self.laneChange_enabled > 1) and self.alcaEnabled - CS.ALCA_total_steps = int(20 * self.alca_duration[alca_mode]) - if self.laneChange_enabled == 3: - CS.ALCA_direction = -self.laneChange_direction - else: - CS.ALCA_direction = 0 - - return turn_signal_needed, self.laneChange_enabled > 1 + self.send_status(CS) + return self.laneChange_enabled > 1 -class ALCAModelParser(object): +class ALCAModelParser(): def __init__(self): #ALCA params self.ALCA_error = False self.ALCA_lane_width = 3.6 - self.ALCA_direction = 0 # left 1, right -1 + self.ALCA_direction = 100 #none 0, left 1, right -1,reset 100 self.ALCA_step = 0 - self.ALCA_total_steps = 20 * 5 #20 Hz, 5 seconds, wifey mode + self.ALCA_total_steps = 20 * ALCA_duration_seconds #20 Hz, 5 seconds, wifey mode self.ALCA_cancelling = False self.ALCA_enabled = False self.ALCA_OFFSET_C3 = 0. self.ALCA_OFFSET_C2 = 0. + self.ALCA_OFFSET_C1 = 0. self.ALCA_over_line = False self.prev_CS_ALCA_error = False self.ALCA_use_visual = True - self.ALCA_l_poly = np.array([0., 0., 0., -100.]) - self.ALCA_r_poly = np.array([0., 0., 0., -100.]) self.ALCA_vego = 0. self.ALCA_vego_prev = 0. - self.mx = 0. - self.dx = 0. - self.poller = zmq.Poller() - self.alcaStatus = messaging.sub_sock(service_list['alcaStatus'].port, conflate=True, poller=self.poller) + self.alcaStatus = messaging.sub_sock('alcaStatus', conflate=True) + self.alcaState = messaging.pub_sock('alcaState') self.alcas = None + self.hit_prob_low = False + self.hit_prob_high = False + self.distance_to_line_L = 100. + self.prev_distance_to_line_L = 100. + self.distance_to_line_R = 100. + self.prev_distance_to_line_R = 100. - def reset_alca (self): + def reset_alca (self,v_ego): self.ALCA_step = 0 - self.ALCA_direction = 0 + self.ALCA_direction = 100 self.ALCA_cancelling = False - self.ALCA_error = True + self.ALCA_error = False self.ALCA_enabled = False self.ALCA_OFFSET_C3 = 0. self.ALCA_OFFSET_C2 = 0. + self.ALCA_OFFSET_C1 = 0. self.ALCA_over_line = False self.ALCA_use_visual = True - self.ALCA_l_poly = np.array([0., 0., 0., -100.]) - self.ALCA_r_poly = np.array([0., 0., 0., -100.]) - self.ALCA_vego_prev = 0. - self.mx = 0. - self.dx = 0. + self.ALCA_vego_prev = v_ego self.alcas = None + self.hit_prob_low = False + self.hit_prob_high = False + self.distance_to_line_L = 100. + self.prev_distance_to_line_L = 100. + self.distance_to_line_R = 100. + self.prev_distance_to_line_R = 100. + self.send_state() def debug_alca(self,message): if ALCA_DEBUG: - print message + print (message) - def update(self, v_ego, md, r_poly, l_poly, r_prob, l_prob, lane_width): + def send_state(self): + alca_state = tesla.ALCAState.new_message() + #ALCA params + alca_state.alcaDirection = int(self.ALCA_direction) + alca_state.alcaError = bool(self.ALCA_error) + alca_state.alcaCancelling = bool(self.ALCA_cancelling) + alca_state.alcaEnabled = bool(self.ALCA_enabled) + alca_state.alcaLaneWidth = float(self.ALCA_lane_width) + alca_state.alcaStep = int(self.ALCA_step) + alca_state.alcaTotalSteps = int(self.ALCA_total_steps) + self.alcaState.send(alca_state.to_bytes()) - self.ALCA_direction = cs.alcaDirection - self.ALCA_enabled = cs.alcaEnabled - self.ALCA_total_steps = cs.alcaTotalSteps - self.ALCA_error = self.ALCA_error or (cs.alcaError and not self.prev_CS_ALCA_error) - self.prev_CS_ALCA_error = cs.alcaError - - if not self.ALCA_enabled: - return np.array(r_poly),np.array(l_poly),r_prob, l_prob, lane_width + def update(self, v_ego, md, r_poly, l_poly, r_prob, l_prob, lane_width, p_poly): - self.ALCA_direction = self.alcas.alcaDirection - self.ALCA_enabled = self.alcas.alcaEnabled - self.ALCA_total_steps = self.alcas.alcaTotalSteps - self.ALCA_error = self.ALCA_error or (self.alcas.alcaError and not self.prev_CS_ALCA_error) - self.prev_CS_ALCA_error = self.alcas.alcaError + alcaStatusMsg = self.alcaStatus.receive(non_blocking=True) + if alcaStatusMsg is not None: + self.alcas = tesla.ALCAStatus.from_bytes(alcaStatusMsg) #if we don't have yet ALCA status, return same values if self.alcas is None: - return np.array(r_poly),np.array(l_poly),r_prob, l_prob, lane_width + self.send_state() + return np.array(r_poly),np.array(l_poly),r_prob, l_prob, lane_width, p_poly + + if self.alcas.alcaDirection == 0: + self.ALCA_direction = 0 + + if self.ALCA_direction < 100: + self.ALCA_direction = self.alcas.alcaDirection + + self.ALCA_enabled = self.alcas.alcaEnabled + + self.ALCA_total_steps = self.alcas.alcaTotalSteps + self.ALCA_error = self.ALCA_error or (self.alcas.alcaError and not self.prev_CS_ALCA_error) + self.prev_CS_ALCA_error = self.alcas.alcaError + + if self.ALCA_enabled: + if self.ALCA_direction == 0: + self.ALCA_lane_width = lane_width + else: + lane_width = self.ALCA_lane_width #if error but no direction, the carcontroller component is fine and we need to reset if self.ALCA_error and (self.ALCA_direction == 0): self.ALCA_error = False - mx = 0. - if self.ALCA_enabled and not (self.ALCA_direction == 0): - mx = min(abs(r_poly[3] - self.ALCA_r_poly[3]),abs(l_poly[3] - self.ALCA_l_poly[3])) - if mx > 0.5: - mx = self.mx - self.mx = mx - else: - self.mx = 0 - - self.ALCA_l_poly = np.array(l_poly) - self.ALCA_r_poly = np.array(r_poly) + + if (not self.ALCA_enabled) or (self.ALCA_direction == 100) or (self.ALCA_direction == 0): + self.ALCA_vego_prev = v_ego + self.send_state() + return np.array(r_poly),np.array(l_poly),r_prob, l_prob, lane_width,np.array(p_poly) + + self.hit_prob_low = self.hit_prob_low and ((self.ALCA_direction != 0) and (self.hit_prob_low or ((self.ALCA_direction == 1) and (l_prob < ALCA_line_prob_low)) or ((self.ALCA_direction == -1) and (r_prob < ALCA_line_prob_low)))) + self.hit_prob_high = (self.ALCA_direction != 0) and (self.hit_prob_low) and (self.hit_prob_high or ((self.ALCA_direction == 1) and (r_prob > ALCA_line_prob_high)) or ((self.ALCA_direction == -1) and (l_prob < ALCA_line_prob_high))) + + if self.hit_prob_high: + self.debug_alca("Hit high probability for line, ALCA done, releasing...") + self.reset_alca(v_ego) + return np.array(r_poly),np.array(l_poly),r_prob, l_prob, lane_width,np.array(p_poly) #where are we in alca as % ALCA_perc_complete = float(self.ALCA_step) / float(self.ALCA_total_steps) if self.ALCA_error and self.ALCA_cancelling: self.debug_alca(" Error and Cancelling -> resetting...") - self.reset_alca() + self.reset_alca(v_ego) + return np.array(r_poly),np.array(l_poly),r_prob, l_prob, lane_width,np.array(p_poly) if self.ALCA_error and not self.ALCA_cancelling: if (ALCA_perc_complete < 0.1) or (ALCA_perc_complete > 0.9): self.debug_alca(" Error and less than 10% -> resetting...") - self.reset_alca() + self.reset_alca(v_ego) + return np.array(r_poly),np.array(l_poly),r_prob, l_prob, lane_width,np.array(p_poly) else: self.debug_alca(" Error and not Cancelling -> rewinding...") self.ALCA_cancelling = True self.ALCA_error = False - if self.ALCA_enabled and not (self.ALCA_direction == 0): - if ALCA_DEBUG: - print ALCA_perc_complete, self.ALCA_step,self.ALCA_total_steps - self.debug_alca(" ALCA enabled and direction not 0 -> let's go...") - ALCA_increment = -3 if self.ALCA_cancelling else 1 - if ALCA_DEBUG: - print "increment", ALCA_increment - self.ALCA_step += ALCA_increment - if (self.ALCA_step < 0) or (self.ALCA_step >= self.ALCA_total_steps): - #done so end ALCA - self.debug_alca(" step out of bounds -> resetting...") - self.reset_alca() - else: - #if between 20% and 80% of change is done, let's check if we are over the line - if ALCA_line_check_low_limit < ALCA_perc_complete < ALCA_line_check_high_limit : - self.debug_alca("perc complete between ALCA_line_check_low_limit and ALCA_line_check_high_limit...") - if self.ALCA_direction == -1: - #if we are moving to the right - if (l_prob > ALCA_line_min_prob ) and (0 < l_poly[3] < (self.ALCA_lane_width / 3.)): - self.debug_alca("alca over the line...") - self.ALCA_over_line = True - if self.ALCA_direction == 1: - #if we are moving to the left - if (r_prob > ALCA_line_min_prob ) and ((-self.ALCA_lane_width / 3.) < r_poly[3] < 0 ): - self.debug_alca("alca over the line...") - self.ALCA_over_line = True - elif ALCA_perc_complete >= ALCA_line_check_high_limit : - self.debug_alca("alca over the line (ALCA_line_check_high_limit )...") - self.ALCA_over_line = True - else: - self.debug_alca("alca not over the line (ALCA_line_check_low_limit)...") - self.ALCA_over_line = False - #make sure we always have the line we need in sight - if self.ALCA_over_line: - self.debug_alca("OVER THE LINE") - prev_ALCA_use_visual = self.ALCA_use_visual - if (not self.ALCA_over_line) and (((self.ALCA_direction == 1) and (l_prob < ALCA_line_min_prob)) or ((self.ALCA_direction == -1) and (r_prob < ALCA_line_min_prob))): - self.debug_alca("alca not over line, not using visual") - self.ALCA_use_visual = False - elif self.ALCA_over_line and (((self.ALCA_direction == 1) and (r_prob < ALCA_line_min_prob)) or ((self.ALCA_direction == -1) and (l_prob < ALCA_line_min_prob))): - self.debug_alca("alca over line, not using visual") - self.ALCA_use_visual = False - else: - self.debug_alca("alca using visual") - self.ALCA_use_visual = True - - #did we just switch between visual and non-visual? - if prev_ALCA_use_visual != self.ALCA_use_visual: - self.reset_alca() - - #maybe we need to change this with real time than assume 0.05s at 20Hz - #compute how much distance we did since last iteration - dx = 0.05 * (self.ALCA_vego_prev + v_ego) / 2 - #total distance traveled through the lane change - self.dx += dx - ix = 0. - - #compute offset - if (not self.ALCA_error) and self.ALCA_use_visual: - if self.ALCA_over_line: - if (self.ALCA_total_steps - self.ALCA_step <= 1) or (self.ALCA_over_line and ((self.ALCA_direction == 1) and (r_poly[3] < -ALCA_release_distance)) or ((self.ALCA_direction == -1) and (l_poly[3] > ALCA_release_distance))): - self.reset_alca() - self.ALCA_error = False - ix = self.ALCA_lane_width * float(self.ALCA_direction) / float(self.ALCA_total_steps) - if self.ALCA_direction == 1: - #ix = -(self.ALCA_lane_width/2 + r_poly[3]) / float(self.ALCA_total_steps - self.ALCA_step) - self.ALCA_OFFSET_C3 = ix * float (self.ALCA_step) - self.ALCA_lane_width - else: - #ix = -(self.ALCA_lane_width/2 - l_poly[3]) / float(self.ALCA_total_steps - self.ALCA_step) - self.ALCA_OFFSET_C3 = ix * float (self.ALCA_step) + self.ALCA_lane_width - #self.ALCA_OFFSET_C3 = ix * float(self.ALCA_total_steps - self.ALCA_step -1) - self.ALCA_OFFSET_C2 = self.mx * float(self.ALCA_direction) / dx - else: - ix = self.ALCA_lane_width * float(self.ALCA_direction) / float(self.ALCA_total_steps) - self.ALCA_OFFSET_C3 = ix * float (self.ALCA_step) - self.ALCA_OFFSET_C2 = self.mx * float(self.ALCA_direction) / dx - else: - self.ALCA_OFFSET_C3 = 0. - self.ALCA_OFFSET_C2 = 0. - - - if (self.ALCA_direction == 1 and not self.ALCA_over_line) or (self.ALCA_direction == -1 and self.ALCA_over_line): - r_poly = np.array(l_poly) - l_prob = 1 - r_prob = l_prob - r_poly[3] = l_poly[3] - self.ALCA_lane_width - elif (self.ALCA_direction == -1 and not self.ALCA_over_line) or (self.ALCA_direction == 1 and self.ALCA_over_line): - l_poly = np.array(r_poly) - r_prob = 1 - l_prob = r_prob - l_poly[3] = r_poly[3] + self.ALCA_lane_width - l_poly[3] += self.ALCA_OFFSET_C3 - r_poly[3] += self.ALCA_OFFSET_C3 - l_poly[2] += self.ALCA_OFFSET_C2 - r_poly[2] += self.ALCA_OFFSET_C2 + self.ALCA_step += 1 #ALCA_increment + + + if (self.ALCA_step < 0) or (self.ALCA_step >= self.ALCA_total_steps): + #done so end ALCA + self.debug_alca(" step out of bounds -> resetting...") + self.reset_alca(v_ego) + return np.array(r_poly),np.array(l_poly),r_prob, l_prob, lane_width,np.array(p_poly) + + #compute offset + from_center = 0. + left_to_move = 0. + + #compute distances to lines + self.distance_to_line_L = abs(l_poly[3]) + self.distance_to_line_R = abs(r_poly[3]) + percent_completed = float(self.ALCA_total_steps - self.ALCA_step) / float(self.ALCA_total_steps) + percent_completed = clip(percent_completed, ALCA_distance_left_min, 1.0) + distance_left = float((self.ALCA_total_steps) * 0.05 * percent_completed * (self.ALCA_vego_prev + v_ego) / 2.) #5m + distance left + distance_estimate = float(ITERATIONS_AHEAD_TO_ESTIMATE * 0.05 * (self.ALCA_vego_prev + v_ego) / 2.) + estimate_curv_at = distance_estimate / distance_left + left_to_move = self.ALCA_lane_width * estimate_curv_at + # if ((self.ALCA_direction == 1) and ((self.distance_to_line_L > ALCA_distance_jump * self.prev_distance_to_line_L) or (self.distance_to_line_R < self.ALCA_lane_width / 3.))) or \ + # ((self.ALCA_direction == -1) and ((self.distance_to_line_R > ALCA_distance_jump * self.prev_distance_to_line_R) or (self.distance_to_line_L < self.ALCA_lane_width / 3.))): + # self.ALCA_over_line = True + if ((self.ALCA_direction == 1) and (self.distance_to_line_R < self.ALCA_lane_width / 3.)) or \ + ((self.ALCA_direction == -1) and (self.distance_to_line_L < self.ALCA_lane_width / 3.)): + self.ALCA_over_line = True + left_to_move = self.ALCA_lane_width * estimate_curv_at + if self.ALCA_over_line: + left_to_move2 = (self.distance_to_line_L if self.ALCA_direction == 1 else self.distance_to_line_R) - self.ALCA_lane_width / 2. + if left_to_move2 < ALCA_release_distance: + self.reset_alca(v_ego) + return np.array(r_poly),np.array(l_poly),r_prob, l_prob, lane_width, p_poly + + d1 = np.polyval(p_poly,distance_estimate -1) + d2 = np.polyval(p_poly,distance_estimate + 1) + cos = 0. + turn_mult = 0. + if abs(d2 - d1) > 0.001: + cos = abs(np.cos(np.arctan(2/abs(d2-d1)))) + # turn mult is used to detect if we move in the same direction as the turn or oposite direction + # should be + if we move in the same direction and - if opposite + # it will increase or decrease the turn angle by cos(angle) + turn_mult = max (0, self.ALCA_direction * (d2-d1)/abs(d2-d1)) + d0 = (d2 + d1) / 2.0 - np.polyval(p_poly,distance_estimate) + ltm = left_to_move * (1 + cos * turn_mult) + #compute offsets + self.ALCA_OFFSET_C1 = 0. + lane_multiplier = 1. if self.ALCA_direction == 1 else ALCA_right_lane_multiplier + self.ALCA_OFFSET_C2 = lane_multiplier * ALCA_lane_change_coefficient * float(self.ALCA_direction * ltm) / (distance_estimate ) + self.prev_distance_to_line_R = self.distance_to_line_R + self.prev_distance_to_line_L = self.distance_to_line_L + if ALCA_DEBUG: + debug_string = DEBUG_INFO.format(step=self.ALCA_step,total_steps=self.ALCA_total_steps,ALCA_direction=self.ALCA_direction,ALCA_use_visual=self.ALCA_use_visual,ALCA_over_line=self.ALCA_over_line,ALCA_lane_width=self.ALCA_lane_width, left_to_move=left_to_move/estimate_curv_at, from_center=from_center, ALCA_OFFSET_C2=self.ALCA_OFFSET_C2, ALCA_OFFSET_C1=self.ALCA_OFFSET_C1,prob_low=self.hit_prob_low,prob_high=self.hit_prob_high) + self.debug_alca(debug_string) + + if (not self.ALCA_error) and self.ALCA_use_visual: + if self.ALCA_over_line: + if (self.ALCA_total_steps - self.ALCA_step <= 1) or (self.ALCA_over_line and ((self.ALCA_direction == 1) and ((r_poly[3] < -ALCA_release_distance) or (l_poly[3] < self.ALCA_lane_width / 2. - ALCA_release_distance))) or ((self.ALCA_direction == -1) and ((l_poly[3] > ALCA_release_distance) or (r_poly[3] > -(self.ALCA_lane_width / 2. - ALCA_release_distance))))): + self.ALCA_error = False + self.reset_alca(v_ego) + return np.array(r_poly),np.array(l_poly),r_prob, l_prob, lane_width, p_poly + + if l_prob > r_prob: + r_poly = np.array(l_poly) + if l_prob > ALCA_line_prob_low: + l_prob = 1 + r_prob = l_prob else: - self.reset_alca() - self.ALCA_error = False - - self.ALCA_vego_prev = v_ego - - if self.ALCA_enabled: - if self.ALCA_direction == 0: - self.ALCA_lane_width = lane_width - else: - lane_width = self.ALCA_lane_width - - return np.array(r_poly),np.array(l_poly),r_prob, l_prob, self.ALCA_lane_width - + l_poly = np.array(r_poly) + if r_prob > ALCA_line_prob_low: + r_prob = 1 + l_prob = r_prob + l_poly[3] = self.ALCA_lane_width / 2 + r_poly[3] = -self.ALCA_lane_width / 2 + l_poly[2] += self.ALCA_OFFSET_C2 + r_poly[2] += self.ALCA_OFFSET_C2 + l_poly[1] += self.ALCA_OFFSET_C1 + r_poly[1] += self.ALCA_OFFSET_C1 + p_poly[3] = 0 + p_poly[2] += self.ALCA_OFFSET_C2 + p_poly[1] += self.ALCA_OFFSET_C1 + + self.ALCA_vego_prev = v_ego + self.send_state() + return np.array(r_poly),np.array(l_poly),r_prob, l_prob, self.ALCA_lane_width, np.array(p_poly) + diff --git a/selfdrive/car/modules/GYRO_module.py b/selfdrive/car/modules/GYRO_module.py index cec7c34864e9e7..4f9ef34d4e4f99 100644 --- a/selfdrive/car/modules/GYRO_module.py +++ b/selfdrive/car/modules/GYRO_module.py @@ -1,7 +1,6 @@ -from selfdrive.services import service_list +from cereal.services import service_list from collections import deque -import selfdrive.messaging as messaging -import zmq +import cereal.messaging as messaging import cereal import math from common.realtime import sec_since_boot @@ -22,8 +21,7 @@ class GYROController: def __init__(self): - self.poller = zmq.Poller() - self.sensorEvents = messaging.sub_sock(service_list['sensorEvents'].port, conflate=True, poller=self.poller) + self.sensorEvents = messaging.sub_sock('sensorEvents', conflate=True) self.roll = 0. self.pitch = 0.01 self.yaw = 9.8 @@ -105,9 +103,7 @@ def update(self,v,a,str_angl): d = str_angl / abs(str_angl) r = wb / math.sqrt(2-2*math.cos(2*str_angl/str_ratio)) lat_a = d * v * v / r - for socket, _ in self.poller.poll(0): - if socket is self.sensorEvents: - se_list = messaging.recv_sock(socket) + se_list = messaging.recv_sock(self.sensorEvents,wait=False) if se_list is not None: for se in se_list.sensorEvents: if se.which == cereal_SensorEventData_acceleration: diff --git a/selfdrive/car/modules/UIBT_module.py b/selfdrive/car/modules/UIBT_module.py index 8f2caf6351ad37..f6612cfa846caf 100644 --- a/selfdrive/car/modules/UIBT_module.py +++ b/selfdrive/car/modules/UIBT_module.py @@ -3,6 +3,7 @@ from ctypes import create_string_buffer import os from datetime import datetime +from common.basedir import BASEDIR buttons_file_rw = "wb" @@ -22,7 +23,7 @@ class UIButtons: def write_buttons_labels_to_file(self): fo = open(self.buttons_labels_path, buttons_file_rw) for btn in self.btns: - fo.write(struct.pack(btn_msg_struct,btn.btn_name,btn.btn_label,btn.btn_label2)) + fo.write(struct.pack(btn_msg_struct,btn.btn_name.encode('utf8'),btn.btn_label.encode('utf8'),btn.btn_label2.encode('utf8'))) fo.close() def read_buttons_labels_from_file(self): @@ -34,18 +35,22 @@ def read_buttons_labels_from_file(self): for i in range(0, len(indata), btn_msg_len): j = int(i/btn_msg_len) name,label,label2 = struct.unpack(btn_msg_struct, indata[i:i+btn_msg_len]) - if self.btns[j].btn_name == name.rstrip("\0"): + if self.btns[j].btn_name.rstrip("\0") == name.decode('utf8').rstrip("\0"): file_matches = True - self.btns[j].btn_label = label.rstrip("\0") + self.btns[j].btn_label = label.decode('utf8').rstrip("\0") #check if label is actually a valid option - if label2.rstrip("\0") in self.CS.btns_init[j][2]: - self.btns[j].btn_label2 = label2.rstrip("\0") + if label2.decode('utf8').rstrip("\0") in self.CS.btns_init[j][2]: + self.btns[j].btn_label2 = label2.decode('utf8').rstrip("\0") + print (self.btns[j].btn_name," label2: using last value from file") else: self.btns[j].btn_label2 = self.CS.btns_init[j][2][0] + print (self.btns[j].btn_name," label2: using default value") + else: + print(self.btns[j].btn_name," label does not match, using default") return file_matches else: #we don't have all the data, ignore - print "labels file is bad" + print ("labels file is bad") return False @@ -64,10 +69,10 @@ def read_buttons_out_file(self): fi.close() if len(indata) == 6: for i in range(0,len(indata)): - self.btns[i].btn_status = ord(indata[i]) - 48 + self.btns[i].btn_status = (indata[i]) - 48 else: #something wrong with the file - print "status file is bad" + print ("status file is bad") def send_button_info(self): if self.isLive: @@ -80,8 +85,8 @@ def __init__(self, carstate,car,folder,showLogo,showCar): self.CS = carstate self.car_folder = folder self.car_name = car - self.buttons_labels_path = "/data/openpilot/selfdrive/car/"+self.car_folder+"/buttons.msg" - self.buttons_status_out_path = "/data/openpilot/selfdrive/car/"+self.car_folder+"/buttons.cc.msg" + self.buttons_labels_path = BASEDIR + "/selfdrive/car/"+self.car_folder+"/buttons.msg" + self.buttons_status_out_path = BASEDIR + "/selfdrive/car/"+self.car_folder+"/buttons.cc.msg" self.btns = [] self.hasChanges = True self.last_in_read_time = datetime.min @@ -110,10 +115,10 @@ def init_ui_buttons(self): self.btns = [] try: self.CS.init_ui_buttons() - print "Buttons iniatlized with custom CS code" + print ("Buttons iniatlized with custom CS code") except AttributeError: # no init method - print "Buttons iniatlized with just base code" + print ("Buttons iniatlized with just base code") for i in range(0,len(self.CS.btns_init)): self.btns.append(UIButton(self.CS.btns_init[i][0],self.CS.btns_init[i][1],1,self.CS.btns_init[i][2][0],i)) @@ -197,4 +202,4 @@ def update_ui_buttons(self,id,btn_status): self.CS.update_ui_buttons(id,btn_status) except AttributeError: # no update method - print "Buttons updated with just base code" + print ("Buttons updated with just base code") diff --git a/selfdrive/car/modules/UIEV_module.py b/selfdrive/car/modules/UIEV_module.py index 9c831d6b1c1fac..5c84044d241050 100644 --- a/selfdrive/car/modules/UIEV_module.py +++ b/selfdrive/car/modules/UIEV_module.py @@ -1,19 +1,16 @@ from cereal import ui from common import realtime -import selfdrive.messaging as messaging -from selfdrive.services import service_list -import zmq +import cereal.messaging as messaging -class UIEvents(object): +class UIEvents(): def __init__(self,carstate): self.CS = carstate - self.buttons_poller = zmq.Poller() - self.uiCustomAlert = messaging.pub_sock(service_list['uiCustomAlert'].port) - self.uiButtonInfo = messaging.pub_sock(service_list['uiButtonInfo'].port) - self.uiSetCar = messaging.pub_sock(service_list['uiSetCar'].port) - self.uiPlaySound = messaging.pub_sock(service_list['uiPlaySound'].port) - self.uiGyroInfo = messaging.pub_sock(service_list['uiGyroInfo'].port) - self.uiButtonStatus = messaging.sub_sock(service_list['uiButtonStatus'].port, conflate=True, poller=self.buttons_poller) + self.uiCustomAlert = messaging.pub_sock('uiCustomAlert') + self.uiButtonInfo = messaging.pub_sock('uiButtonInfo') + self.uiSetCar = messaging.pub_sock('uiSetCar') + self.uiPlaySound = messaging.pub_sock('uiPlaySound') + self.uiGyroInfo = messaging.pub_sock('uiGyroInfo') + self.uiButtonStatus = messaging.sub_sock('uiButtonStatus', conflate=True) self.prev_cstm_message = "" self.prev_cstm_status = -1 @@ -90,9 +87,9 @@ def custom_alert_message(self,status,message,duration,sound=-1): def update_custom_ui(self): btn_message = None - for socket, event in self.buttons_poller.poll(0): - if socket is self.uiButtonStatus: - btn_message = ui.UIButtonStatus.from_bytes(socket.recv()) + btn_messageMsg = self.uiButtonStatus.receive(non_blocking=True) + if btn_messageMsg is not None: + btn_message = ui.UIButtonStatus.from_bytes(btn_messageMsg) if btn_message is not None: btn_id = btn_message.btnId self.CS.cstm_btns.set_button_status_from_ui(btn_id,btn_message.btnStatus) diff --git a/selfdrive/car/modules/test_UIBT_module.py b/selfdrive/car/modules/test_UIBT_module.py new file mode 100644 index 00000000000000..11052ce90033d0 --- /dev/null +++ b/selfdrive/car/modules/test_UIBT_module.py @@ -0,0 +1,31 @@ +import time +from selfdrive.car.modules.UIBT_module import UIButtons +from selfdrive.car.tesla.ACC_module import ACCMode +from selfdrive.car.tesla.PCC_module import PCCModes +from selfdrive.car.modules.UIEV_module import UIEvents + +class CarState(): + def __init__(self): + # labels for buttons + self.btns_init = [["alca", "ALC", ["MadMax", "Normal", "Calm"]], + [PCCModes.BUTTON_NAME, PCCModes.BUTTON_ABREVIATION, PCCModes.labels()], + ["dsp", "DSP", ["OP","MIN","OFF","GYRO"]], + ["", "", [""]], + ["msg", "MSG", [""]], + ["sound", "SND", [""]]] + self.UE = UIEvents(self) + self.cstm_btns = UIButtons(self,"Tesla Model S","tesla", False, False) + self.custom_alert_counter = 0 + for i in range(6): + print (self.cstm_btns.btns[i].btn_name,len(self.cstm_btns.btns[i].btn_name)) + print (self.cstm_btns.btns[i].btn_label,len(self.cstm_btns.btns[i].btn_label)) + print (self.cstm_btns.btns[i].btn_label2,len(self.cstm_btns.btns[i].btn_label2)) + print (self.cstm_btns.btns[i].btn_status) + + +cs = CarState() + +while 1: + cs.UE.update_custom_ui() + CS.cstm_btns.send_button_info() + time.sleep(0.1) \ No newline at end of file diff --git a/panda/tests/safety/__init__.py b/selfdrive/car/nissan/__init__.py similarity index 100% rename from panda/tests/safety/__init__.py rename to selfdrive/car/nissan/__init__.py diff --git a/selfdrive/car/nissan/carcontroller.py b/selfdrive/car/nissan/carcontroller.py new file mode 100644 index 00000000000000..5838d67ae3241f --- /dev/null +++ b/selfdrive/car/nissan/carcontroller.py @@ -0,0 +1,94 @@ +from cereal import car +from common.numpy_fast import clip, interp +from selfdrive.car.nissan import nissancan +from opendbc.can.packer import CANPacker +from selfdrive.car.nissan.values import CAR, STEER_THRESHOLD + +# Steer angle limits +ANGLE_DELTA_BP = [0., 5., 15.] +ANGLE_DELTA_V = [5., .8, .15] # windup limit +ANGLE_DELTA_VU = [5., 3.5, 0.4] # unwind limit +LKAS_MAX_TORQUE = 1 # A value of 1 is easy to overpower + +VisualAlert = car.CarControl.HUDControl.VisualAlert + + +class CarController(): + def __init__(self, dbc_name, CP, VM): + self.CP = CP + self.car_fingerprint = CP.carFingerprint + + self.lkas_max_torque = 0 + self.last_angle = 0 + + self.packer = CANPacker(dbc_name) + + def update(self, enabled, CS, frame, actuators, cruise_cancel, hud_alert, + left_line, right_line, left_lane_depart, right_lane_depart): + """ Controls thread """ + + # Send CAN commands. + can_sends = [] + + ### STEER ### + acc_active = bool(CS.out.cruiseState.enabled) + lkas_hud_msg = CS.lkas_hud_msg + lkas_hud_info_msg = CS.lkas_hud_info_msg + apply_angle = actuators.steerAngle + + steer_hud_alert = 1 if hud_alert == VisualAlert.steerRequired else 0 + + if enabled: + # # windup slower + if self.last_angle * apply_angle > 0. and abs(apply_angle) > abs(self.last_angle): + angle_rate_lim = interp(CS.out.vEgo, ANGLE_DELTA_BP, ANGLE_DELTA_V) + else: + angle_rate_lim = interp(CS.out.vEgo, ANGLE_DELTA_BP, ANGLE_DELTA_VU) + + apply_angle = clip(apply_angle, self.last_angle - angle_rate_lim, self.last_angle + angle_rate_lim) + + # Max torque from driver before EPS will give up and not apply torque + if not bool(CS.out.steeringPressed): + self.lkas_max_torque = LKAS_MAX_TORQUE + else: + # Scale max torque based on how much torque the driver is applying to the wheel + self.lkas_max_torque = max( + # Scale max torque down to half LKAX_MAX_TORQUE as a minimum + LKAS_MAX_TORQUE * 0.5, + # Start scaling torque at STEER_THRESHOLD + LKAS_MAX_TORQUE - 0.6 * max(0, abs(CS.out.steeringTorque) - STEER_THRESHOLD) + ) + + else: + apply_angle = CS.out.steeringAngle + self.lkas_max_torque = 0 + + self.last_angle = apply_angle + + if not enabled and acc_active: + # send acc cancel cmd if drive is disabled but pcm is still on, or if the system can't be activated + cruise_cancel = 1 + + if self.CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL] and cruise_cancel: + can_sends.append(nissancan.create_acc_cancel_cmd(self.packer, CS.cruise_throttle_msg, frame)) + + # TODO: Find better way to cancel! + # For some reason spamming the cancel button is unreliable on the Leaf + # We now cancel by making propilot think the seatbelt is unlatched, + # this generates a beep and a warning message every time you disengage + if self.CP.carFingerprint == CAR.LEAF and frame % 2 == 0: + can_sends.append(nissancan.create_cancel_msg(self.packer, CS.cancel_msg, cruise_cancel)) + + can_sends.append(nissancan.create_steering_control( + self.packer, self.car_fingerprint, apply_angle, frame, enabled, self.lkas_max_torque)) + + if frame % 2 == 0: + can_sends.append(nissancan.create_lkas_hud_msg( + self.packer, lkas_hud_msg, enabled, left_line, right_line, left_lane_depart, right_lane_depart)) + + if frame % 50 == 0: + can_sends.append(nissancan.create_lkas_hud_info_msg( + self.packer, lkas_hud_info_msg, steer_hud_alert + )) + + return can_sends diff --git a/selfdrive/car/nissan/carstate.py b/selfdrive/car/nissan/carstate.py new file mode 100644 index 00000000000000..f2076183d97857 --- /dev/null +++ b/selfdrive/car/nissan/carstate.py @@ -0,0 +1,286 @@ +import copy +from collections import deque +from cereal import car +from opendbc.can.can_define import CANDefine +from selfdrive.car.interfaces import CarStateBase +from selfdrive.config import Conversions as CV +from opendbc.can.parser import CANParser +from selfdrive.car.nissan.values import CAR, DBC, STEER_THRESHOLD + +TORQUE_SAMPLES = 12 + +class CarState(CarStateBase): + def __init__(self, CP): + super().__init__(CP) + can_define = CANDefine(DBC[CP.carFingerprint]['pt']) + + self.steeringTorqueSamples = deque(TORQUE_SAMPLES*[0], TORQUE_SAMPLES) + self.shifter_values = can_define.dv["GEARBOX"]["GEAR_SHIFTER"] + + def update(self, cp, cp_adas, cp_cam): + ret = car.CarState.new_message() + + if self.CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL]: + ret.gas = cp.vl["GAS_PEDAL"]["GAS_PEDAL"] + elif self.CP.carFingerprint == CAR.LEAF: + ret.gas = cp.vl["CRUISE_THROTTLE"]["GAS_PEDAL"] + + ret.gasPressed = bool(ret.gas > 3) + + if self.CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL]: + ret.brakePressed = bool(cp.vl["DOORS_LIGHTS"]["USER_BRAKE_PRESSED"]) + elif self.CP.carFingerprint == CAR.LEAF: + ret.brakePressed = bool(cp.vl["BRAKE_PEDAL"]["BRAKE_PEDAL"] > 3) + + if self.CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL]: + ret.brakeLights = bool(cp.vl["DOORS_LIGHTS"]["BRAKE_LIGHT"]) + + ret.wheelSpeeds.fl = cp.vl["WHEEL_SPEEDS_FRONT"]["WHEEL_SPEED_FL"] * CV.KPH_TO_MS + ret.wheelSpeeds.fr = cp.vl["WHEEL_SPEEDS_FRONT"]["WHEEL_SPEED_FR"] * CV.KPH_TO_MS + ret.wheelSpeeds.rl = cp.vl["WHEEL_SPEEDS_REAR"]["WHEEL_SPEED_RL"] * CV.KPH_TO_MS + ret.wheelSpeeds.rr = cp.vl["WHEEL_SPEEDS_REAR"]["WHEEL_SPEED_RR"] * CV.KPH_TO_MS + + ret.vEgoRaw = (ret.wheelSpeeds.fl + ret.wheelSpeeds.fr + ret.wheelSpeeds.rl + ret.wheelSpeeds.rr) / 4. + + ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) + ret.standstill = ret.vEgoRaw < 0.01 + + ret.cruiseState.enabled = bool(cp_adas.vl["CRUISE_STATE"]["CRUISE_ENABLED"]) + if self.CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL]: + ret.seatbeltUnlatched = cp.vl["HUD"]["SEATBELT_DRIVER_LATCHED"] == 0 + ret.cruiseState.available = bool(cp_cam.vl["PRO_PILOT"]["CRUISE_ON"]) + elif self.CP.carFingerprint == CAR.LEAF: + ret.seatbeltUnlatched = cp.vl["SEATBELT"]["SEATBELT_DRIVER_LATCHED"] == 0 + ret.cruiseState.available = bool(cp.vl["CRUISE_THROTTLE"]["CRUISE_AVAILABLE"]) + + speed = cp_adas.vl["PROPILOT_HUD"]["SET_SPEED"] + if speed != 255: + if self.CP.carFingerprint == CAR.LEAF: + conversion = CV.MPH_TO_MS if cp.vl["HUD_SETTINGS"]["SPEED_MPH"] else CV.KPH_TO_MS + else: + conversion = CV.MPH_TO_MS if cp.vl["HUD"]["SPEED_MPH"] else CV.KPH_TO_MS + speed -= 1 # Speed on HUD is always 1 lower than actually sent on can bus + ret.cruiseState.speed = speed * conversion + + ret.steeringTorque = cp.vl["STEER_TORQUE_SENSOR"]["STEER_TORQUE_DRIVER"] + self.steeringTorqueSamples.append(ret.steeringTorque) + # Filtering driver torque to prevent steeringPressed false positives + ret.steeringPressed = bool(abs(sum(self.steeringTorqueSamples) / TORQUE_SAMPLES) > STEER_THRESHOLD) + + ret.steeringAngle = cp.vl["STEER_ANGLE_SENSOR"]["STEER_ANGLE"] + + ret.leftBlinker = bool(cp.vl["LIGHTS"]["LEFT_BLINKER"]) + ret.rightBlinker = bool(cp.vl["LIGHTS"]["RIGHT_BLINKER"]) + + ret.doorOpen = any([cp.vl["DOORS_LIGHTS"]["DOOR_OPEN_RR"], + cp.vl["DOORS_LIGHTS"]["DOOR_OPEN_RL"], + cp.vl["DOORS_LIGHTS"]["DOOR_OPEN_FR"], + cp.vl["DOORS_LIGHTS"]["DOOR_OPEN_FL"]]) + + ret.espDisabled = bool(cp.vl["ESP"]["ESP_DISABLED"]) + + can_gear = int(cp.vl["GEARBOX"]["GEAR_SHIFTER"]) + ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(can_gear, None)) + + self.lkas_enabled = bool(cp_adas.vl["LKAS_SETTINGS"]["LKAS_ENABLED"]) + + self.cruise_throttle_msg = copy.copy(cp.vl["CRUISE_THROTTLE"]) + + if self.CP.carFingerprint == CAR.LEAF: + self.cancel_msg = copy.copy(cp.vl["CANCEL_MSG"]) + + self.lkas_hud_msg = copy.copy(cp_adas.vl["PROPILOT_HUD"]) + self.lkas_hud_info_msg = copy.copy(cp_adas.vl["PROPILOT_HUD_INFO_MSG"]) + + return ret + + @staticmethod + def get_can_parser(CP): + # this function generates lists for signal, messages and initial values + signals = [ + # sig_name, sig_address, default + ("WHEEL_SPEED_FL", "WHEEL_SPEEDS_FRONT", 0), + ("WHEEL_SPEED_FR", "WHEEL_SPEEDS_FRONT", 0), + ("WHEEL_SPEED_RL", "WHEEL_SPEEDS_REAR", 0), + ("WHEEL_SPEED_RR", "WHEEL_SPEEDS_REAR", 0), + + + ("STEER_TORQUE_DRIVER", "STEER_TORQUE_SENSOR", 0), + ("STEER_ANGLE", "STEER_ANGLE_SENSOR", 0), + + ("DOOR_OPEN_FR", "DOORS_LIGHTS", 1), + ("DOOR_OPEN_FL", "DOORS_LIGHTS", 1), + ("DOOR_OPEN_RR", "DOORS_LIGHTS", 1), + ("DOOR_OPEN_RL", "DOORS_LIGHTS", 1), + + ("RIGHT_BLINKER", "LIGHTS", 0), + ("LEFT_BLINKER", "LIGHTS", 0), + + ("ESP_DISABLED", "ESP", 0), + + ("GEAR_SHIFTER", "GEARBOX", 0), + ] + + checks = [ + # sig_address, frequency + ("WHEEL_SPEEDS_REAR", 50), + ("WHEEL_SPEEDS_FRONT", 50), + ("STEER_TORQUE_SENSOR", 100), + ("STEER_ANGLE_SENSOR", 100), + ("DOORS_LIGHTS", 10), + ] + + if CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL]: + signals += [ + ("USER_BRAKE_PRESSED", "DOORS_LIGHTS", 1), + ("BRAKE_LIGHT", "DOORS_LIGHTS", 1), + + ("GAS_PEDAL", "GAS_PEDAL", 0), + ("SEATBELT_DRIVER_LATCHED", "HUD", 0), + ("SPEED_MPH", "HUD", 0), + + ("PROPILOT_BUTTON", "CRUISE_THROTTLE", 0), + ("CANCEL_BUTTON", "CRUISE_THROTTLE", 0), + ("GAS_PEDAL_INVERTED", "CRUISE_THROTTLE", 0), + ("SET_BUTTON", "CRUISE_THROTTLE", 0), + ("RES_BUTTON", "CRUISE_THROTTLE", 0), + ("FOLLOW_DISTANCE_BUTTON", "CRUISE_THROTTLE", 0), + ("NO_BUTTON_PRESSED", "CRUISE_THROTTLE", 0), + ("GAS_PEDAL", "CRUISE_THROTTLE", 0), + ("USER_BRAKE_PRESSED", "CRUISE_THROTTLE", 0), + ("NEW_SIGNAL_2", "CRUISE_THROTTLE", 0), + ("GAS_PRESSED_INVERTED", "CRUISE_THROTTLE", 0), + ("unsure1", "CRUISE_THROTTLE", 0), + ("unsure2", "CRUISE_THROTTLE", 0), + ("unsure3", "CRUISE_THROTTLE", 0), + ] + + checks += [ + ("GAS_PEDAL", 50), + ] + + elif CP.carFingerprint == CAR.LEAF: + signals += [ + ("BRAKE_PEDAL", "BRAKE_PEDAL", 0), + + ("GAS_PEDAL", "CRUISE_THROTTLE", 0), + ("CRUISE_AVAILABLE", "CRUISE_THROTTLE", 0), + ("SPEED_MPH", "HUD_SETTINGS", 0), + ("SEATBELT_DRIVER_LATCHED", "SEATBELT", 0), + + # Copy other values, we use this to cancel + ("CANCEL_SEATBELT", "CANCEL_MSG", 0), + ("NEW_SIGNAL_1", "CANCEL_MSG", 0), + ("NEW_SIGNAL_2", "CANCEL_MSG", 0), + ("NEW_SIGNAL_3", "CANCEL_MSG", 0), + ] + checks += [ + ("BRAKE_PEDAL", 100), + ("CRUISE_THROTTLE", 50), + ] + + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0) + + @staticmethod + def get_adas_can_parser(CP): + # this function generates lists for signal, messages and initial values + signals = [ + # sig_name, sig_address, default + ("LKAS_ENABLED", "LKAS_SETTINGS", 0), + + ("CRUISE_ENABLED", "CRUISE_STATE", 0), + + ("DESIRED_ANGLE", "LKAS", 0), + ("SET_0x80_2", "LKAS", 0), + ("MAX_TORQUE", "LKAS", 0), + ("SET_0x80", "LKAS", 0), + ("COUNTER", "LKAS", 0), + ("LKA_ACTIVE", "LKAS", 0), + + # Below are the HUD messages. We copy the stock message and modify + ("LARGE_WARNING_FLASHING", "PROPILOT_HUD", 0), + ("SIDE_RADAR_ERROR_FLASHING1", "PROPILOT_HUD", 0), + ("SIDE_RADAR_ERROR_FLASHING2", "PROPILOT_HUD", 0), + ("LEAD_CAR", "PROPILOT_HUD", 0), + ("LEAD_CAR_ERROR", "PROPILOT_HUD", 0), + ("FRONT_RADAR_ERROR", "PROPILOT_HUD", 0), + ("FRONT_RADAR_ERROR_FLASHING", "PROPILOT_HUD", 0), + ("SIDE_RADAR_ERROR_FLASHING3", "PROPILOT_HUD", 0), + ("LKAS_ERROR_FLASHING", "PROPILOT_HUD", 0), + ("SAFETY_SHIELD_ACTIVE", "PROPILOT_HUD", 0), + ("RIGHT_LANE_GREEN_FLASH", "PROPILOT_HUD", 0), + ("LEFT_LANE_GREEN_FLASH", "PROPILOT_HUD", 0), + ("FOLLOW_DISTANCE", "PROPILOT_HUD", 0), + ("AUDIBLE_TONE", "PROPILOT_HUD", 0), + ("SPEED_SET_ICON", "PROPILOT_HUD", 0), + ("SMALL_STEERING_WHEEL_ICON", "PROPILOT_HUD", 0), + ("unknown59", "PROPILOT_HUD", 0), + ("unknown55", "PROPILOT_HUD", 0), + ("unknown26", "PROPILOT_HUD", 0), + ("unknown28", "PROPILOT_HUD", 0), + ("unknown31", "PROPILOT_HUD", 0), + ("SET_SPEED", "PROPILOT_HUD", 0), + ("unknown43", "PROPILOT_HUD", 0), + ("unknown08", "PROPILOT_HUD", 0), + ("unknown05", "PROPILOT_HUD", 0), + ("unknown02", "PROPILOT_HUD", 0), + + ("NA_HIGH_ACCEL_TEMP", "PROPILOT_HUD_INFO_MSG", 0), + ("SIDE_RADAR_NA_HIGH_CABIN_TEMP", "PROPILOT_HUD_INFO_MSG", 0), + ("SIDE_RADAR_MALFUNCTION", "PROPILOT_HUD_INFO_MSG", 0), + ("LKAS_MALFUNCTION", "PROPILOT_HUD_INFO_MSG", 0), + ("FRONT_RADAR_MALFUNCTION", "PROPILOT_HUD_INFO_MSG", 0), + ("SIDE_RADAR_NA_CLEAN_REAR_CAMERA", "PROPILOT_HUD_INFO_MSG", 0), + ("NA_POOR_ROAD_CONDITIONS", "PROPILOT_HUD_INFO_MSG", 0), + ("CURRENTLY_UNAVAILABLE", "PROPILOT_HUD_INFO_MSG", 0), + ("SAFETY_SHIELD_OFF", "PROPILOT_HUD_INFO_MSG", 0), + ("FRONT_COLLISION_NA_FRONT_RADAR_OBSTRUCTION", "PROPILOT_HUD_INFO_MSG", 0), + ("PEDAL_MISSAPPLICATION_SYSTEM_ACTIVATED", "PROPILOT_HUD_INFO_MSG", 0), + ("SIDE_IMPACT_NA_RADAR_OBSTRUCTION", "PROPILOT_HUD_INFO_MSG", 0), + ("WARNING_DO_NOT_ENTER", "PROPILOT_HUD_INFO_MSG", 0), + ("SIDE_IMPACT_SYSTEM_OFF", "PROPILOT_HUD_INFO_MSG", 0), + ("SIDE_IMPACT_MALFUNCTION", "PROPILOT_HUD_INFO_MSG", 0), + ("FRONT_COLLISION_MALFUNCTION", "PROPILOT_HUD_INFO_MSG", 0), + ("SIDE_RADAR_MALFUNCTION2", "PROPILOT_HUD_INFO_MSG", 0), + ("LKAS_MALFUNCTION2", "PROPILOT_HUD_INFO_MSG", 0), + ("FRONT_RADAR_MALFUNCTION2", "PROPILOT_HUD_INFO_MSG", 0), + ("PROPILOT_NA_MSGS", "PROPILOT_HUD_INFO_MSG", 0), + ("BOTTOM_MSG", "PROPILOT_HUD_INFO_MSG", 0), + ("HANDS_ON_WHEEL_WARNING", "PROPILOT_HUD_INFO_MSG", 0), + ("WARNING_STEP_ON_BRAKE_NOW", "PROPILOT_HUD_INFO_MSG", 0), + ("PROPILOT_NA_FRONT_CAMERA_OBSTRUCTED", "PROPILOT_HUD_INFO_MSG", 0), + ("PROPILOT_NA_HIGH_CABIN_TEMP", "PROPILOT_HUD_INFO_MSG", 0), + ("WARNING_PROPILOT_MALFUNCTION", "PROPILOT_HUD_INFO_MSG", 0), + ("ACC_UNAVAILABLE_HIGH_CABIN_TEMP", "PROPILOT_HUD_INFO_MSG", 0), + ("ACC_NA_FRONT_CAMERA_IMPARED", "PROPILOT_HUD_INFO_MSG", 0), + ("unknown07", "PROPILOT_HUD_INFO_MSG", 0), + ("unknown10", "PROPILOT_HUD_INFO_MSG", 0), + ("unknown15", "PROPILOT_HUD_INFO_MSG", 0), + ("unknown23", "PROPILOT_HUD_INFO_MSG", 0), + ("unknown19", "PROPILOT_HUD_INFO_MSG", 0), + ("unknown31", "PROPILOT_HUD_INFO_MSG", 0), + ("unknown32", "PROPILOT_HUD_INFO_MSG", 0), + ("unknown46", "PROPILOT_HUD_INFO_MSG", 0), + ("unknown61", "PROPILOT_HUD_INFO_MSG", 0), + ("unknown55", "PROPILOT_HUD_INFO_MSG", 0), + ("unknown50", "PROPILOT_HUD_INFO_MSG", 0), + ] + + checks = [ + ("CRUISE_STATE", 50), + ] + + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2) + + @staticmethod + def get_cam_can_parser(CP): + signals = [] + if CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL]: + signals += [ + ("CRUISE_ON", "PRO_PILOT", 0), + ] + + checks = [ + ] + + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 1) diff --git a/selfdrive/car/nissan/interface.py b/selfdrive/car/nissan/interface.py new file mode 100644 index 00000000000000..1a003a8824a004 --- /dev/null +++ b/selfdrive/car/nissan/interface.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python3 +from cereal import car +from selfdrive.car.nissan.values import CAR +from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint +from selfdrive.car.interfaces import CarInterfaceBase + + +class CarInterface(CarInterfaceBase): + def __init__(self, CP, CarController, CarState): + super().__init__(CP, CarController, CarState) + self.cp_adas = self.CS.get_adas_can_parser(CP) + + @staticmethod + def compute_gb(accel, speed): + return float(accel) / 4.0 + + @staticmethod + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + + ret = CarInterfaceBase.get_std_params(candidate, fingerprint) + ret.carName = "nissan" + ret.safetyModel = car.CarParams.SafetyModel.nissan + + # Nissan port is a community feature, since we don't own one to test + ret.communityFeature = True + + ret.steerLimitAlert = False + ret.enableCamera = True + ret.steerRateCost = 0.5 + + ret.steerActuatorDelay = 0.1 + ret.lateralTuning.pid.kf = 0.00006 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.0], [0.0]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.01], [0.005]] + ret.steerMaxBP = [0.] # m/s + ret.steerMaxV = [1.] + + if candidate in [CAR.ROGUE, CAR.XTRAIL]: + ret.mass = 1610 + STD_CARGO_KG + ret.wheelbase = 2.705 + ret.centerToFront = ret.wheelbase * 0.44 + ret.steerRatio = 17 + elif candidate == CAR.LEAF: + ret.mass = 1610 + STD_CARGO_KG + ret.wheelbase = 2.705 + ret.centerToFront = ret.wheelbase * 0.44 + ret.steerRatio = 17 + + ret.steerControlType = car.CarParams.SteerControlType.angle + ret.radarOffCan = True + + # TODO: get actual value, for now starting with reasonable value for + # civic and scaling by mass and wheelbase + ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) + + # TODO: start from empirically derived lateral slip stiffness for the civic and scale by + # mass and CG position, so all cars will have approximately similar dyn behaviors + ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront) + + return ret + + # returns a car.CarState + def update(self, c, can_strings): + self.cp.update_strings(can_strings) + self.cp_cam.update_strings(can_strings) + self.cp_adas.update_strings(can_strings) + + ret = self.CS.update(self.cp, self.cp_adas, self.cp_cam) + + ret.canValid = self.cp.can_valid and self.cp_adas.can_valid and self.cp_cam.can_valid + + buttonEvents = [] + be = car.CarState.ButtonEvent.new_message() + be.type = car.CarState.ButtonEvent.Type.accelCruise + buttonEvents.append(be) + + events = self.create_common_events(ret) + + if self.CS.lkas_enabled: + events.add(car.CarEvent.EventName.invalidLkasSetting) + + ret.events = events.to_msg() + + self.CS.out = ret.as_reader() + return self.CS.out + + def apply(self, c): + can_sends = self.CC.update(c.enabled, self.CS, self.frame, c.actuators, + c.cruiseControl.cancel, c.hudControl.visualAlert, + c.hudControl.leftLaneVisible, c.hudControl.rightLaneVisible, + c.hudControl.leftLaneDepart, c.hudControl.rightLaneDepart) + self.frame += 1 + return can_sends diff --git a/selfdrive/car/nissan/nissancan.py b/selfdrive/car/nissan/nissancan.py new file mode 100644 index 00000000000000..a264442e645232 --- /dev/null +++ b/selfdrive/car/nissan/nissancan.py @@ -0,0 +1,66 @@ +import copy +import crcmod + +nissan_checksum = crcmod.mkCrcFun(0x11d, initCrc=0x00, rev=False, xorOut=0xff) + + +def create_steering_control(packer, car_fingerprint, apply_steer, frame, steer_on, lkas_max_torque): + idx = (frame % 16) + values = { + "DESIRED_ANGLE": apply_steer, + "SET_0x80_2": 0x80, + "SET_0x80": 0x80, + "MAX_TORQUE": lkas_max_torque if steer_on else 0, + "COUNTER": idx, + "LKA_ACTIVE": steer_on, + } + + dat = packer.make_can_msg("LKAS", 0, values)[2] + + values["CHECKSUM"] = nissan_checksum(dat[:7]) + return packer.make_can_msg("LKAS", 0, values) + + +def create_acc_cancel_cmd(packer, cruise_throttle_msg, frame): + values = copy.copy(cruise_throttle_msg) + + values["CANCEL_BUTTON"] = 1 + values["NO_BUTTON_PRESSED"] = 0 + values["PROPILOT_BUTTON"] = 0 + values["SET_BUTTON"] = 0 + values["RES_BUTTON"] = 0 + values["FOLLOW_DISTANCE_BUTTON"] = 0 + values["COUNTER"] = (frame % 4) + + return packer.make_can_msg("CRUISE_THROTTLE", 2, values) + + +def create_cancel_msg(packer, cancel_msg, cruise_cancel): + values = copy.copy(cancel_msg) + + if cruise_cancel: + values["CANCEL_SEATBELT"] = 1 + + return packer.make_can_msg("CANCEL_MSG", 2, values) + + +def create_lkas_hud_msg(packer, lkas_hud_msg, enabled, left_line, right_line, left_lane_depart, right_lane_depart): + values = lkas_hud_msg + + values["RIGHT_LANE_YELLOW_FLASH"] = 1 if right_lane_depart else 0 + values["LEFT_LANE_YELLOW_FLASH"] = 1 if left_lane_depart else 0 + + values["LARGE_STEERING_WHEEL_ICON"] = 2 if enabled else 0 + values["RIGHT_LANE_GREEN"] = 1 if right_line and enabled else 0 + values["LEFT_LANE_GREEN"] = 1 if left_line and enabled else 0 + + return packer.make_can_msg("PROPILOT_HUD", 0, values) + + +def create_lkas_hud_info_msg(packer, lkas_hud_info_msg, steer_hud_alert): + values = lkas_hud_info_msg + + if steer_hud_alert: + values["HANDS_ON_WHEEL_WARNING"] = 1 + + return packer.make_can_msg("PROPILOT_HUD_INFO_MSG", 0, values) diff --git a/selfdrive/car/nissan/radar_interface.py b/selfdrive/car/nissan/radar_interface.py new file mode 100644 index 00000000000000..b2f76511360320 --- /dev/null +++ b/selfdrive/car/nissan/radar_interface.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python3 +from selfdrive.car.interfaces import RadarInterfaceBase + +class RadarInterface(RadarInterfaceBase): + pass diff --git a/selfdrive/car/nissan/values.py b/selfdrive/car/nissan/values.py new file mode 100644 index 00000000000000..ea4af219ea1a49 --- /dev/null +++ b/selfdrive/car/nissan/values.py @@ -0,0 +1,42 @@ +# flake8: noqa + +from selfdrive.car import dbc_dict + +STEER_THRESHOLD = 1.0 + +class CAR: + XTRAIL = "NISSAN X-TRAIL 2017" + LEAF = "NISSAN LEAF 2018" + ROGUE = "NISSAN ROGUE 2019" + + +FINGERPRINTS = { + CAR.XTRAIL: [ + { + 2: 5, 42: 6, 346: 6, 347: 5, 348: 8, 349: 7, 361: 8, 386: 8, 389: 8, 397: 8, 398: 8, 403: 8, 520: 2, 523: 6, 548: 8, 645: 8, 658: 8, 665: 8, 666: 8, 674: 2, 682: 8, 683: 8, 689: 8, 723: 8, 758: 3, 768: 2, 783: 3, 851: 8, 855: 8, 1041: 8, 1055: 2, 1104: 4, 1105: 6, 1107: 4, 1108: 8, 1111: 4, 1227: 8, 1228: 8, 1247: 4, 1266: 8, 1273: 7, 1342: 1, 1376: 6, 1401: 8, 1474: 2, 1497: 3, 1821: 8, 1823: 8, 1837: 8, 2015: 8, 2016: 8, 2024: 8 + }, + { + 2: 5, 42: 6, 346: 6, 347: 5, 348: 8, 349: 7, 361: 8, 386: 8, 389: 8, 397: 8, 398: 8, 403: 8, 520: 2, 523: 6, 527: 1, 548: 8, 637: 4, 645: 8, 658: 8, 665: 8, 666: 8, 674: 2, 682: 8, 683: 8, 689: 8, 723: 8, 758: 3, 768: 6, 783: 3, 851: 8, 855: 8, 1041: 8, 1055: 2, 1104: 4, 1105: 6, 1107: 4, 1108: 8, 1111: 4, 1227: 8, 1228: 8, 1247: 4, 1266: 8, 1273: 7, 1342: 1, 1376: 6, 1401: 8, 1474: 8, 1497: 3, 1534: 6, 1792: 8, 1821: 8, 1823: 8, 1837: 8, 1872: 8, 1937: 8, 1953: 8, 1968: 8, 2015: 8, 2016: 8, 2024: 8 + }, + ], + CAR.LEAF: [ + { + 2: 5, 42: 6, 264: 3, 361: 8, 372: 8, 384: 8, 389: 8, 403: 8, 459: 7, 460: 4, 470: 8, 520: 1, 569: 8, 581: 8, 634: 7, 640: 8, 644: 8, 645: 8, 646: 5, 658: 8, 682: 8, 683: 8, 689: 8, 724: 6, 758: 3, 761: 2, 783: 3, 852: 8, 853: 8, 856: 8, 861: 8, 944: 1, 976: 6, 1008: 7, 1011: 7, 1057: 3, 1227: 8, 1228: 8, 1261: 5, 1342: 1, 1354: 8, 1361: 8, 1459: 8, 1477: 8, 1497: 3, 1549: 8, 1573: 6, 1821: 8, 1837: 8, 1856: 8, 1859: 8, 1861: 8, 1864: 8, 1874: 8, 1888: 8, 1891: 8, 1893: 8, 1906: 8, 1947: 8, 1949: 8, 1979: 8, 1981: 8, 2016: 8, 2017: 8, 2021: 8, 643: 5, 1792: 8, 1872: 8, 1937: 8, 1953: 8, 1968: 8, 1988: 8, 2000: 8, 2001: 8, 2004: 8, 2005: 8, 2015: 8 + }, + # 2020 Leaf SV Plus + { + 2: 5, 42: 8, 264: 3, 361: 8, 372: 8, 384: 8, 389: 8, 403: 8, 459: 7, 460: 4, 470: 8, 520: 1, 569: 8, 581: 8, 634: 7, 640: 8, 643: 5, 644: 8, 645: 8, 646: 5, 658: 8, 682: 8, 683: 8, 689: 8, 724: 6, 758: 3, 761: 2, 772: 8, 773: 6, 774: 7, 775: 8, 776: 6, 777: 7, 778: 6, 783: 3, 852: 8, 853: 8, 856: 8, 861: 8, 943: 8, 944: 1, 976: 6, 1008: 7, 1009: 8, 1010: 8, 1011: 7, 1012: 8, 1013: 8, 1019: 8, 1020: 8, 1021: 8, 1022: 8, 1057: 3, 1227: 8, 1228: 8, 1261: 5, 1342: 1, 1354: 8, 1361: 8, 1402: 8, 1459: 8, 1477: 8, 1497: 3, 1549: 8, 1573: 6, 1821: 8, 1837: 8 + }, + ], + CAR.ROGUE: [ + { + 2: 5, 42: 6, 346: 6, 347: 5, 348: 8, 349: 7, 361: 8, 386: 8, 389: 8, 397: 8, 398: 8, 403: 8, 520: 2, 523: 6, 548: 8, 634: 7, 643: 5, 645: 8, 658: 8, 665: 8, 666: 8, 674: 2, 682: 8, 683: 8, 689: 8, 723: 8, 758: 3, 772: 8, 773: 6, 774: 7, 775: 8, 776: 6, 777: 7, 778: 6, 783: 3, 851: 8, 855: 8, 1041: 8, 1042: 8, 1055: 2, 1104: 4, 1105: 6, 1107: 4, 1108: 8, 1110: 7, 1111: 7, 1227: 8, 1228: 8, 1247: 4, 1266: 8, 1273: 7, 1342: 1, 1376: 6, 1401: 8, 1474: 2, 1497: 3, 1534: 7, 1792: 8, 1821: 8, 1823: 8, 1837: 8, 1839: 8, 1872: 8, 1937: 8, 1953: 8, 1968: 8, 1988: 8, 2000: 8, 2001: 8, 2004: 8, 2005: 8, 2015: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8 + }, + ] +} + +DBC = { + CAR.XTRAIL: dbc_dict('nissan_x_trail_2017', None), + CAR.LEAF: dbc_dict('nissan_leaf_2018', None), + CAR.ROGUE: dbc_dict('nissan_x_trail_2017', None), +} diff --git a/selfdrive/car/subaru/__init__.py b/selfdrive/car/subaru/__init__.py index 8b137891791fe9..e69de29bb2d1d6 100644 --- a/selfdrive/car/subaru/__init__.py +++ b/selfdrive/car/subaru/__init__.py @@ -1 +0,0 @@ - diff --git a/selfdrive/car/subaru/carcontroller.py b/selfdrive/car/subaru/carcontroller.py index 95e0013faa9e37..744fd0bcc9ddbb 100644 --- a/selfdrive/car/subaru/carcontroller.py +++ b/selfdrive/car/subaru/carcontroller.py @@ -1,73 +1,87 @@ -#from common.numpy_fast import clip from selfdrive.car import apply_std_steer_torque_limits from selfdrive.car.subaru import subarucan -from selfdrive.car.subaru.values import CAR, DBC -from selfdrive.can.packer import CANPacker +from selfdrive.car.subaru.values import DBC, PREGLOBAL_CARS +from opendbc.can.packer import CANPacker class CarControllerParams(): - def __init__(self, car_fingerprint): + def __init__(self): self.STEER_MAX = 2047 # max_steer 4095 self.STEER_STEP = 2 # how often we update the steer cmd self.STEER_DELTA_UP = 50 # torque increase per refresh, 0.8s to max self.STEER_DELTA_DOWN = 70 # torque decrease per refresh - if car_fingerprint == CAR.IMPREZA: - self.STEER_DRIVER_ALLOWANCE = 60 # allowed driver torque before start limiting - self.STEER_DRIVER_MULTIPLIER = 10 # weight driver torque heavily - self.STEER_DRIVER_FACTOR = 1 # from dbc + self.STEER_DRIVER_ALLOWANCE = 60 # allowed driver torque before start limiting + self.STEER_DRIVER_MULTIPLIER = 10 # weight driver torque heavily + self.STEER_DRIVER_FACTOR = 1 # from dbc - -class CarController(object): - def __init__(self, car_fingerprint): - self.lkas_active = False - self.steer_idx = 0 +class CarController(): + def __init__(self, dbc_name, CP, VM): self.apply_steer_last = 0 - self.car_fingerprint = car_fingerprint self.es_distance_cnt = -1 + self.es_accel_cnt = -1 self.es_lkas_cnt = -1 + self.fake_button_prev = 0 + self.steer_rate_limited = False - # Setup detection helper. Routes commands to - # an appropriate CAN bus number. - self.params = CarControllerParams(car_fingerprint) - print(DBC) - self.packer = CANPacker(DBC[car_fingerprint]['pt']) + self.params = CarControllerParams() + self.packer = CANPacker(DBC[CP.carFingerprint]['pt']) def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, left_line, right_line): - """ Controls thread """ - - P = self.params - # Send CAN commands. can_sends = [] - ### STEER ### + # *** steering *** + if (frame % self.params.STEER_STEP) == 0: - if (frame % P.STEER_STEP) == 0: - - final_steer = actuators.steer if enabled else 0. - apply_steer = int(round(final_steer * P.STEER_MAX)) + apply_steer = int(round(actuators.steer * self.params.STEER_MAX)) # limits due to driver torque - apply_steer = int(round(apply_steer)) - apply_steer = apply_std_steer_torque_limits(apply_steer, self.apply_steer_last, CS.steer_torque_driver, P) - - lkas_enabled = enabled and not CS.steer_not_allowed + new_steer = int(round(apply_steer)) + apply_steer = apply_std_steer_torque_limits(new_steer, self.apply_steer_last, CS.out.steeringTorque, self.params) + self.steer_rate_limited = new_steer != apply_steer - if not lkas_enabled: + if not enabled: apply_steer = 0 - can_sends.append(subarucan.create_steering_control(self.packer, CS.CP.carFingerprint, apply_steer, frame, P.STEER_STEP)) + if CS.CP.carFingerprint in PREGLOBAL_CARS: + can_sends.append(subarucan.create_preglobal_steering_control(self.packer, apply_steer, frame, self.params.STEER_STEP)) + else: + can_sends.append(subarucan.create_steering_control(self.packer, apply_steer, frame, self.params.STEER_STEP)) self.apply_steer_last = apply_steer - if self.es_distance_cnt != CS.es_distance_msg["Counter"]: - can_sends.append(subarucan.create_es_distance(self.packer, CS.es_distance_msg, pcm_cancel_cmd)) - self.es_distance_cnt = CS.es_distance_msg["Counter"] - if self.es_lkas_cnt != CS.es_lkas_msg["Counter"]: - can_sends.append(subarucan.create_es_lkas(self.packer, CS.es_lkas_msg, visual_alert, left_line, right_line)) - self.es_lkas_cnt = CS.es_lkas_msg["Counter"] + # *** alerts and pcm cancel *** + + if CS.CP.carFingerprint in PREGLOBAL_CARS: + if self.es_accel_cnt != CS.es_accel_msg["Counter"]: + # 1 = main, 2 = set shallow, 3 = set deep, 4 = resume shallow, 5 = resume deep + # disengage ACC when OP is disengaged + if pcm_cancel_cmd: + fake_button = 1 + # turn main on if off and past start-up state + elif not CS.out.cruiseState.available and CS.ready: + fake_button = 1 + else: + fake_button = CS.button + + # unstick previous mocked button press + if fake_button == 1 and self.fake_button_prev == 1: + fake_button = 0 + self.fake_button_prev = fake_button + + can_sends.append(subarucan.create_es_throttle_control(self.packer, fake_button, CS.es_accel_msg)) + self.es_accel_cnt = CS.es_accel_msg["Counter"] + + else: + if self.es_distance_cnt != CS.es_distance_msg["Counter"]: + can_sends.append(subarucan.create_es_distance(self.packer, CS.es_distance_msg, pcm_cancel_cmd)) + self.es_distance_cnt = CS.es_distance_msg["Counter"] + + if self.es_lkas_cnt != CS.es_lkas_msg["Counter"]: + can_sends.append(subarucan.create_es_lkas(self.packer, CS.es_lkas_msg, visual_alert, left_line, right_line)) + self.es_lkas_cnt = CS.es_lkas_msg["Counter"] return can_sends diff --git a/selfdrive/car/subaru/carstate.py b/selfdrive/car/subaru/carstate.py index 6c5f6782662bc7..3be516ed3395ce 100644 --- a/selfdrive/car/subaru/carstate.py +++ b/selfdrive/car/subaru/carstate.py @@ -1,153 +1,230 @@ import copy -from common.kalman.simple_kalman import KF1D +from cereal import car +from opendbc.can.can_define import CANDefine from selfdrive.config import Conversions as CV -from selfdrive.can.parser import CANParser -from selfdrive.car.subaru.values import DBC, STEER_THRESHOLD - -def get_powertrain_can_parser(CP): - # this function generates lists for signal, messages and initial values - signals = [ - # sig_name, sig_address, default - ("Steer_Torque_Sensor", "Steering_Torque", 0), - ("Steering_Angle", "Steering_Torque", 0), - ("Cruise_On", "CruiseControl", 0), - ("Cruise_Activated", "CruiseControl", 0), - ("Brake_Pedal", "Brake_Pedal", 0), - ("Throttle_Pedal", "Throttle", 0), - ("LEFT_BLINKER", "Dashlights", 0), - ("RIGHT_BLINKER", "Dashlights", 0), - ("SEATBELT_FL", "Dashlights", 0), - ("FL", "Wheel_Speeds", 0), - ("FR", "Wheel_Speeds", 0), - ("RL", "Wheel_Speeds", 0), - ("RR", "Wheel_Speeds", 0), - ("DOOR_OPEN_FR", "BodyInfo", 1), - ("DOOR_OPEN_FL", "BodyInfo", 1), - ("DOOR_OPEN_RR", "BodyInfo", 1), - ("DOOR_OPEN_RL", "BodyInfo", 1), - ("Units", "Dash_State", 1), - ] - - checks = [ - # sig_address, frequency - ("Dashlights", 10), - ("CruiseControl", 20), - ("Wheel_Speeds", 50), - ("Steering_Torque", 50), - ("BodyInfo", 10), - ] - - return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0) - - -def get_camera_can_parser(CP): - signals = [ - ("Cruise_Set_Speed", "ES_DashStatus", 0), - - ("Counter", "ES_Distance", 0), - ("Signal1", "ES_Distance", 0), - ("Signal2", "ES_Distance", 0), - ("Main", "ES_Distance", 0), - ("Signal3", "ES_Distance", 0), - - ("Checksum", "ES_LKAS_State", 0), - ("Counter", "ES_LKAS_State", 0), - ("Keep_Hands_On_Wheel", "ES_LKAS_State", 0), - ("Empty_Box", "ES_LKAS_State", 0), - ("Signal1", "ES_LKAS_State", 0), - ("LKAS_ACTIVE", "ES_LKAS_State", 0), - ("Signal2", "ES_LKAS_State", 0), - ("Backward_Speed_Limit_Menu", "ES_LKAS_State", 0), - ("LKAS_ENABLE_3", "ES_LKAS_State", 0), - ("Signal3", "ES_LKAS_State", 0), - ("LKAS_ENABLE_2", "ES_LKAS_State", 0), - ("Signal4", "ES_LKAS_State", 0), - ("LKAS_Left_Line_Visible", "ES_LKAS_State", 0), - ("Signal6", "ES_LKAS_State", 0), - ("LKAS_Right_Line_Visible", "ES_LKAS_State", 0), - ("Signal7", "ES_LKAS_State", 0), - ("FCW_Cont_Beep", "ES_LKAS_State", 0), - ("FCW_Repeated_Beep", "ES_LKAS_State", 0), - ("Throttle_Management_Activated", "ES_LKAS_State", 0), - ("Traffic_light_Ahead", "ES_LKAS_State", 0), - ("Right_Depart", "ES_LKAS_State", 0), - ("Signal5", "ES_LKAS_State", 0), - - ] - - checks = [ - ("ES_DashStatus", 10), - ] - - return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2) - - -class CarState(object): +from selfdrive.car.interfaces import CarStateBase +from opendbc.can.parser import CANParser +from selfdrive.car.subaru.values import DBC, STEER_THRESHOLD, CAR, PREGLOBAL_CARS + + +class CarState(CarStateBase): def __init__(self, CP): - # initialize can parser - self.CP = CP - - self.car_fingerprint = CP.carFingerprint - self.left_blinker_on = False - self.prev_left_blinker_on = False - self.right_blinker_on = False - self.prev_right_blinker_on = False - self.steer_torque_driver = 0 - self.steer_not_allowed = False - self.main_on = False - - # vEgo kalman filter - dt = 0.01 - self.v_ego_kf = KF1D(x0=[[0.], [0.]], - A=[[1., dt], [0., 1.]], - C=[1., 0.], - K=[[0.12287673], [0.29666309]]) - self.v_ego = 0. + super().__init__(CP) + can_define = CANDefine(DBC[CP.carFingerprint]['pt']) + self.shifter_values = can_define.dv["Transmission"]['Gear'] def update(self, cp, cp_cam): - - self.pedal_gas = cp.vl["Throttle"]['Throttle_Pedal'] - self.brake_pressure = cp.vl["Brake_Pedal"]['Brake_Pedal'] - self.user_gas_pressed = self.pedal_gas > 0 - self.brake_pressed = self.brake_pressure > 0 - self.brake_lights = bool(self.brake_pressed) - - self.v_wheel_fl = cp.vl["Wheel_Speeds"]['FL'] * CV.KPH_TO_MS - self.v_wheel_fr = cp.vl["Wheel_Speeds"]['FR'] * CV.KPH_TO_MS - self.v_wheel_rl = cp.vl["Wheel_Speeds"]['RL'] * CV.KPH_TO_MS - self.v_wheel_rr = cp.vl["Wheel_Speeds"]['RR'] * CV.KPH_TO_MS - - self.v_cruise_pcm = cp_cam.vl["ES_DashStatus"]['Cruise_Set_Speed'] - # 1 = imperial, 6 = metric - if cp.vl["Dash_State"]['Units'] == 1: - self.v_cruise_pcm *= CV.MPH_TO_KPH - - v_wheel = (self.v_wheel_fl + self.v_wheel_fr + self.v_wheel_rl + self.v_wheel_rr) / 4. - # Kalman filter, even though Hyundai raw wheel speed is heaviliy filtered by default - if abs(v_wheel - self.v_ego) > 2.0: # Prevent large accelerations when car starts at non zero speed - self.v_ego_kf.x = [[v_wheel], [0.0]] - - self.v_ego_raw = v_wheel - v_ego_x = self.v_ego_kf.update(v_wheel) - - self.v_ego = float(v_ego_x[0]) - self.a_ego = float(v_ego_x[1]) - self.standstill = self.v_ego_raw < 0.01 - - self.prev_left_blinker_on = self.left_blinker_on - self.prev_right_blinker_on = self.right_blinker_on - self.left_blinker_on = cp.vl["Dashlights"]['LEFT_BLINKER'] == 1 - self.right_blinker_on = cp.vl["Dashlights"]['RIGHT_BLINKER'] == 1 - self.seatbelt_unlatched = cp.vl["Dashlights"]['SEATBELT_FL'] == 1 - self.steer_torque_driver = cp.vl["Steering_Torque"]['Steer_Torque_Sensor'] - self.acc_active = cp.vl["CruiseControl"]['Cruise_Activated'] - self.main_on = cp.vl["CruiseControl"]['Cruise_On'] - self.steer_override = abs(self.steer_torque_driver) > STEER_THRESHOLD[self.car_fingerprint] - self.angle_steers = cp.vl["Steering_Torque"]['Steering_Angle'] - self.door_open = any([cp.vl["BodyInfo"]['DOOR_OPEN_RR'], - cp.vl["BodyInfo"]['DOOR_OPEN_RL'], - cp.vl["BodyInfo"]['DOOR_OPEN_FR'], - cp.vl["BodyInfo"]['DOOR_OPEN_FL']]) - - self.es_distance_msg = copy.copy(cp_cam.vl["ES_Distance"]) - self.es_lkas_msg = copy.copy(cp_cam.vl["ES_LKAS_State"]) + ret = car.CarState.new_message() + + ret.gas = cp.vl["Throttle"]['Throttle_Pedal'] / 255. + ret.gasPressed = ret.gas > 1e-5 + if self.car_fingerprint in PREGLOBAL_CARS: + ret.brakePressed = cp.vl["Brake_Pedal"]['Brake_Pedal'] > 2 + else: + ret.brakePressed = cp.vl["Brake_Pedal"]['Brake_Pedal'] > 1e-5 + ret.brakeLights = ret.brakePressed + + ret.wheelSpeeds.fl = cp.vl["Wheel_Speeds"]['FL'] * CV.KPH_TO_MS + ret.wheelSpeeds.fr = cp.vl["Wheel_Speeds"]['FR'] * CV.KPH_TO_MS + ret.wheelSpeeds.rl = cp.vl["Wheel_Speeds"]['RL'] * CV.KPH_TO_MS + ret.wheelSpeeds.rr = cp.vl["Wheel_Speeds"]['RR'] * CV.KPH_TO_MS + ret.vEgoRaw = (ret.wheelSpeeds.fl + ret.wheelSpeeds.fr + ret.wheelSpeeds.rl + ret.wheelSpeeds.rr) / 4. + # Kalman filter, even though Subaru raw wheel speed is heaviliy filtered by default + ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) + ret.standstill = ret.vEgoRaw < 0.01 + + # continuous blinker signals for assisted lane change + ret.leftBlinker, ret.rightBlinker = self.update_blinker(50, cp.vl["Dashlights"]['LEFT_BLINKER'], + cp.vl["Dashlights"]['RIGHT_BLINKER']) + + ret.leftBlindspot = (cp.vl["BSD_RCTA"]['L_ADJACENT'] == 1) or (cp.vl["BSD_RCTA"]['L_APPROACHING'] == 1) + ret.rightBlindspot = (cp.vl["BSD_RCTA"]['R_ADJACENT'] == 1) or (cp.vl["BSD_RCTA"]['R_APPROACHING'] == 1) + + can_gear = int(cp.vl["Transmission"]['Gear']) + ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(can_gear, None)) + + ret.steeringAngle = cp.vl["Steering_Torque"]['Steering_Angle'] + ret.steeringTorque = cp.vl["Steering_Torque"]['Steer_Torque_Sensor'] + ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD[self.car_fingerprint] + + ret.cruiseState.enabled = cp.vl["CruiseControl"]['Cruise_Activated'] != 0 + ret.cruiseState.available = cp.vl["CruiseControl"]['Cruise_On'] != 0 + ret.cruiseState.speed = cp_cam.vl["ES_DashStatus"]['Cruise_Set_Speed'] * CV.KPH_TO_MS + + # UDM Forester, Legacy: mph = 0 + if self.car_fingerprint in [CAR.FORESTER_PREGLOBAL, CAR.LEGACY_PREGLOBAL] and cp.vl["Dash_State"]['Units'] == 0: + ret.cruiseState.speed *= CV.MPH_TO_KPH + # EDM Global: mph = 1, 2; All Outback: mph = 1, UDM Forester: mph = 7 + elif self.car_fingerprint not in [CAR.FORESTER_PREGLOBAL, CAR.LEGACY_PREGLOBAL] and cp.vl["Dash_State"]['Units'] in [1, 2, 7]: + ret.cruiseState.speed *= CV.MPH_TO_KPH + + ret.seatbeltUnlatched = cp.vl["Dashlights"]['SEATBELT_FL'] == 1 + ret.doorOpen = any([cp.vl["BodyInfo"]['DOOR_OPEN_RR'], + cp.vl["BodyInfo"]['DOOR_OPEN_RL'], + cp.vl["BodyInfo"]['DOOR_OPEN_FR'], + cp.vl["BodyInfo"]['DOOR_OPEN_FL']]) + + if self.car_fingerprint in PREGLOBAL_CARS: + ret.steerError = cp.vl["Steering_Torque"]["LKA_Lockout"] == 1 + self.button = cp_cam.vl["ES_CruiseThrottle"]["Button"] + self.ready = not cp_cam.vl["ES_DashStatus"]["Not_Ready_Startup"] + self.es_accel_msg = copy.copy(cp_cam.vl["ES_CruiseThrottle"]) + else: + ret.steerError = cp.vl["Steering_Torque"]['Steer_Error_1'] == 1 + ret.steerWarning = cp.vl["Steering_Torque"]['Steer_Warning'] == 1 + ret.cruiseState.nonAdaptive = cp_cam.vl["ES_DashStatus"]['Conventional_Cruise'] == 1 + self.es_distance_msg = copy.copy(cp_cam.vl["ES_Distance"]) + self.es_lkas_msg = copy.copy(cp_cam.vl["ES_LKAS_State"]) + + return ret + + @staticmethod + def get_can_parser(CP): + # this function generates lists for signal, messages and initial values + signals = [ + # sig_name, sig_address, default + ("Steer_Torque_Sensor", "Steering_Torque", 0), + ("Steering_Angle", "Steering_Torque", 0), + ("Cruise_On", "CruiseControl", 0), + ("Cruise_Activated", "CruiseControl", 0), + ("Brake_Pedal", "Brake_Pedal", 0), + ("Throttle_Pedal", "Throttle", 0), + ("LEFT_BLINKER", "Dashlights", 0), + ("RIGHT_BLINKER", "Dashlights", 0), + ("SEATBELT_FL", "Dashlights", 0), + ("FL", "Wheel_Speeds", 0), + ("FR", "Wheel_Speeds", 0), + ("RL", "Wheel_Speeds", 0), + ("RR", "Wheel_Speeds", 0), + ("DOOR_OPEN_FR", "BodyInfo", 1), + ("DOOR_OPEN_FL", "BodyInfo", 1), + ("DOOR_OPEN_RR", "BodyInfo", 1), + ("DOOR_OPEN_RL", "BodyInfo", 1), + ("Units", "Dash_State", 1), + ("Gear", "Transmission", 0), + ("L_ADJACENT", "BSD_RCTA", 0), + ("R_ADJACENT", "BSD_RCTA", 0), + ("L_APPROACHING", "BSD_RCTA", 0), + ("R_APPROACHING", "BSD_RCTA", 0), + ] + + checks = [ + # sig_address, frequency + ("Throttle", 100), + ("Dashlights", 10), + ("Brake_Pedal", 50), + ("Wheel_Speeds", 50), + ("Transmission", 100), + ("Steering_Torque", 50), + ] + + if CP.carFingerprint in PREGLOBAL_CARS: + signals += [ + ("LKA_Lockout", "Steering_Torque", 0), + ] + else: + signals += [ + ("Steer_Error_1", "Steering_Torque", 0), + ("Steer_Warning", "Steering_Torque", 0), + ] + + checks += [ + ("Dashlights", 10), + ("BodyInfo", 10), + ("CruiseControl", 20), + ] + + if CP.carFingerprint == CAR.FORESTER_PREGLOBAL: + checks += [ + ("Dashlights", 20), + ("BodyInfo", 1), + ("CruiseControl", 50), + ] + + if CP.carFingerprint in [CAR.LEGACY_PREGLOBAL, CAR.OUTBACK_PREGLOBAL, CAR.OUTBACK_PREGLOBAL_2018]: + checks += [ + ("Dashlights", 10), + ("CruiseControl", 50), + ] + + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0) + + @staticmethod + def get_cam_can_parser(CP): + if CP.carFingerprint in PREGLOBAL_CARS: + signals = [ + ("Cruise_Set_Speed", "ES_DashStatus", 0), + ("Not_Ready_Startup", "ES_DashStatus", 0), + + ("Throttle_Cruise", "ES_CruiseThrottle", 0), + ("Signal1", "ES_CruiseThrottle", 0), + ("Cruise_Activated", "ES_CruiseThrottle", 0), + ("Signal2", "ES_CruiseThrottle", 0), + ("Brake_On", "ES_CruiseThrottle", 0), + ("DistanceSwap", "ES_CruiseThrottle", 0), + ("Standstill", "ES_CruiseThrottle", 0), + ("Signal3", "ES_CruiseThrottle", 0), + ("CloseDistance", "ES_CruiseThrottle", 0), + ("Signal4", "ES_CruiseThrottle", 0), + ("Standstill_2", "ES_CruiseThrottle", 0), + ("ES_Error", "ES_CruiseThrottle", 0), + ("Signal5", "ES_CruiseThrottle", 0), + ("Counter", "ES_CruiseThrottle", 0), + ("Signal6", "ES_CruiseThrottle", 0), + ("Button", "ES_CruiseThrottle", 0), + ("Signal7", "ES_CruiseThrottle", 0), + ] + + checks = [ + ("ES_DashStatus", 20), + ("ES_CruiseThrottle", 20), + ] + else: + signals = [ + ("Cruise_Set_Speed", "ES_DashStatus", 0), + ("Conventional_Cruise", "ES_DashStatus", 0), + + ("Counter", "ES_Distance", 0), + ("Signal1", "ES_Distance", 0), + ("Cruise_Fault", "ES_Distance", 0), + ("Cruise_Throttle", "ES_Distance", 0), + ("Signal2", "ES_Distance", 0), + ("Car_Follow", "ES_Distance", 0), + ("Signal3", "ES_Distance", 0), + ("Cruise_Brake_Active", "ES_Distance", 0), + ("Distance_Swap", "ES_Distance", 0), + ("Cruise_EPB", "ES_Distance", 0), + ("Signal4", "ES_Distance", 0), + ("Close_Distance", "ES_Distance", 0), + ("Signal5", "ES_Distance", 0), + ("Cruise_Cancel", "ES_Distance", 0), + ("Cruise_Set", "ES_Distance", 0), + ("Cruise_Resume", "ES_Distance", 0), + ("Signal6", "ES_Distance", 0), + + ("Counter", "ES_LKAS_State", 0), + ("Keep_Hands_On_Wheel", "ES_LKAS_State", 0), + ("Empty_Box", "ES_LKAS_State", 0), + ("Signal1", "ES_LKAS_State", 0), + ("LKAS_ACTIVE", "ES_LKAS_State", 0), + ("Signal2", "ES_LKAS_State", 0), + ("Backward_Speed_Limit_Menu", "ES_LKAS_State", 0), + ("LKAS_ENABLE_3", "ES_LKAS_State", 0), + ("LKAS_Left_Line_Light_Blink", "ES_LKAS_State", 0), + ("LKAS_ENABLE_2", "ES_LKAS_State", 0), + ("LKAS_Right_Line_Light_Blink", "ES_LKAS_State", 0), + ("LKAS_Left_Line_Visible", "ES_LKAS_State", 0), + ("LKAS_Left_Line_Green", "ES_LKAS_State", 0), + ("LKAS_Right_Line_Visible", "ES_LKAS_State", 0), + ("LKAS_Right_Line_Green", "ES_LKAS_State", 0), + ("LKAS_Alert", "ES_LKAS_State", 0), + ("Signal3", "ES_LKAS_State", 0), + ] + + checks = [ + ("ES_DashStatus", 10), + ("ES_Distance", 20), + ("ES_LKAS_State", 10), + ] + + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2) diff --git a/selfdrive/car/subaru/interface.py b/selfdrive/car/subaru/interface.py index c5fe0062a7c761..0cfb6fb4940cf7 100644 --- a/selfdrive/car/subaru/interface.py +++ b/selfdrive/car/subaru/interface.py @@ -1,60 +1,47 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from cereal import car -from common.realtime import sec_since_boot -from selfdrive.config import Conversions as CV -from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET -from selfdrive.controls.lib.vehicle_model import VehicleModel -from selfdrive.car.subaru.values import CAR -from selfdrive.car.subaru.carstate import CarState, get_powertrain_can_parser, get_camera_can_parser -from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness +from selfdrive.car.subaru.values import CAR, PREGLOBAL_CARS +from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint +from selfdrive.car.interfaces import CarInterfaceBase - -class CarInterface(object): - def __init__(self, CP, CarController): - self.CP = CP - - self.frame = 0 - self.acc_active_prev = 0 - self.gas_pressed_prev = False - - # *** init the major players *** - self.CS = CarState(CP) - self.VM = VehicleModel(CP) - self.pt_cp = get_powertrain_can_parser(CP) - self.cam_cp = get_camera_can_parser(CP) - - self.gas_pressed_prev = False - - self.CC = None - if CarController is not None: - self.CC = CarController(CP.carFingerprint) +class CarInterface(CarInterfaceBase): @staticmethod def compute_gb(accel, speed): return float(accel) / 4.0 @staticmethod - def calc_accel_override(a_ego, a_target, v_ego, v_target): - return 1.0 - - @staticmethod - def get_params(candidate, fingerprint, vin="", is_panda_black=False): - ret = car.CarParams.new_message() + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "subaru" - ret.carFingerprint = candidate - ret.carVin = vin - ret.isPandaBlack = is_panda_black - ret.safetyModel = car.CarParams.SafetyModel.subaru + ret.radarOffCan = True + + if candidate in PREGLOBAL_CARS: + ret.safetyModel = car.CarParams.SafetyModel.subaruLegacy + else: + ret.safetyModel = car.CarParams.SafetyModel.subaru - ret.enableCruise = True - ret.steerLimitAlert = True + # Subaru port is a community feature, since we don't own one to test + ret.communityFeature = True + ret.dashcamOnly = candidate in PREGLOBAL_CARS ret.enableCamera = True ret.steerRateCost = 0.7 + ret.steerLimitTimer = 0.4 + + if candidate == CAR.ASCENT: + ret.mass = 2031. + STD_CARGO_KG + ret.wheelbase = 2.89 + ret.centerToFront = ret.wheelbase * 0.5 + ret.steerRatio = 13.5 + ret.steerActuatorDelay = 0.3 # end-to-end angle controller + ret.lateralTuning.pid.kf = 0.00003 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0., 20.], [0., 20.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.0025, 0.1], [0.00025, 0.01]] - if candidate in [CAR.IMPREZA]: + if candidate == CAR.IMPREZA: ret.mass = 1568. + STD_CARGO_KG ret.wheelbase = 2.67 ret.centerToFront = ret.wheelbase * 0.5 @@ -63,26 +50,47 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): ret.lateralTuning.pid.kf = 0.00005 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0., 20.], [0., 20.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2, 0.3], [0.02, 0.03]] - ret.steerMaxBP = [0.] # m/s - ret.steerMaxV = [1.] - - ret.steerControlType = car.CarParams.SteerControlType.torque - ret.steerRatioRear = 0. - # testing tuning - - # No long control in subaru - ret.gasMaxBP = [0.] - ret.gasMaxV = [0.] - ret.brakeMaxBP = [0.] - ret.brakeMaxV = [0.] - ret.longitudinalTuning.deadzoneBP = [0.] - ret.longitudinalTuning.deadzoneV = [0.] - ret.longitudinalTuning.kpBP = [0.] - ret.longitudinalTuning.kpV = [0.] - ret.longitudinalTuning.kiBP = [0.] - ret.longitudinalTuning.kiV = [0.] - - # end from gm + + if candidate == CAR.FORESTER: + ret.mass = 1568. + STD_CARGO_KG + ret.wheelbase = 2.67 + ret.centerToFront = ret.wheelbase * 0.5 + ret.steerRatio = 17 # learned, 14 stock + ret.steerActuatorDelay = 0.1 + ret.lateralTuning.pid.kf = 0.000038 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0., 14., 23.], [0., 14., 23.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.01, 0.065, 0.2], [0.001, 0.015, 0.025]] + + if candidate in [CAR.FORESTER_PREGLOBAL, CAR.OUTBACK_PREGLOBAL_2018]: + ret.safetyParam = 1 # Outback 2018-2019 and Forester have reversed driver torque signal + ret.mass = 1568 + STD_CARGO_KG + ret.wheelbase = 2.67 + ret.centerToFront = ret.wheelbase * 0.5 + ret.steerRatio = 20 # learned, 14 stock + ret.steerActuatorDelay = 0.1 + ret.lateralTuning.pid.kf = 0.000039 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0., 10., 20.], [0., 10., 20.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.01, 0.05, 0.2], [0.003, 0.018, 0.025]] + + if candidate == CAR.LEGACY_PREGLOBAL: + ret.mass = 1568 + STD_CARGO_KG + ret.wheelbase = 2.67 + ret.centerToFront = ret.wheelbase * 0.5 + ret.steerRatio = 12.5 # 14.5 stock + ret.steerActuatorDelay = 0.15 + ret.lateralTuning.pid.kf = 0.00005 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0., 20.], [0., 20.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.1, 0.2], [0.01, 0.02]] + + if candidate == CAR.OUTBACK_PREGLOBAL: + ret.mass = 1568 + STD_CARGO_KG + ret.wheelbase = 2.67 + ret.centerToFront = ret.wheelbase * 0.5 + ret.steerRatio = 20 # learned, 14 stock + ret.steerActuatorDelay = 0.1 + ret.lateralTuning.pid.kf = 0.000039 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0., 10., 20.], [0., 10., 20.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.01, 0.05, 0.2], [0.003, 0.018, 0.025]] # TODO: get actual value, for now starting with reasonable value for # civic and scaling by mass and wheelbase @@ -96,96 +104,18 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): # returns a car.CarState def update(self, c, can_strings): - self.pt_cp.update_strings(int(sec_since_boot() * 1e9), can_strings) - self.cam_cp.update_strings(int(sec_since_boot() * 1e9), can_strings) - - self.CS.update(self.pt_cp, self.cam_cp) - - # create message - ret = car.CarState.new_message() - - ret.canValid = self.pt_cp.can_valid and self.cam_cp.can_valid - - # speeds - ret.vEgo = self.CS.v_ego - ret.aEgo = self.CS.a_ego - ret.vEgoRaw = self.CS.v_ego_raw - ret.yawRate = self.VM.yaw_rate(self.CS.angle_steers * CV.DEG_TO_RAD, self.CS.v_ego) - ret.standstill = self.CS.standstill - ret.wheelSpeeds.fl = self.CS.v_wheel_fl - ret.wheelSpeeds.fr = self.CS.v_wheel_fr - ret.wheelSpeeds.rl = self.CS.v_wheel_rl - ret.wheelSpeeds.rr = self.CS.v_wheel_rr - - # steering wheel - ret.steeringAngle = self.CS.angle_steers - - # torque and user override. Driver awareness - # timer resets when the user uses the steering wheel. - ret.steeringPressed = self.CS.steer_override - ret.steeringTorque = self.CS.steer_torque_driver - - ret.gas = self.CS.pedal_gas / 255. - ret.gasPressed = self.CS.user_gas_pressed - - # cruise state - ret.cruiseState.enabled = bool(self.CS.acc_active) - ret.cruiseState.speed = self.CS.v_cruise_pcm * CV.KPH_TO_MS - ret.cruiseState.available = bool(self.CS.main_on) - ret.cruiseState.speedOffset = 0. - - ret.leftBlinker = self.CS.left_blinker_on - ret.rightBlinker = self.CS.right_blinker_on - ret.seatbeltUnlatched = self.CS.seatbelt_unlatched - ret.doorOpen = self.CS.door_open - - buttonEvents = [] - - # blinkers - if self.CS.left_blinker_on != self.CS.prev_left_blinker_on: - be = car.CarState.ButtonEvent.new_message() - be.type = 'leftBlinker' - be.pressed = self.CS.left_blinker_on - buttonEvents.append(be) - - if self.CS.right_blinker_on != self.CS.prev_right_blinker_on: - be = car.CarState.ButtonEvent.new_message() - be.type = 'rightBlinker' - be.pressed = self.CS.right_blinker_on - buttonEvents.append(be) - - be = car.CarState.ButtonEvent.new_message() - be.type = 'accelCruise' - buttonEvents.append(be) - - - events = [] - if ret.seatbeltUnlatched: - events.append(create_event('seatbeltNotLatched', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - - if ret.doorOpen: - events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - - if self.CS.acc_active and not self.acc_active_prev: - events.append(create_event('pcmEnable', [ET.ENABLE])) - if not self.CS.acc_active: - events.append(create_event('pcmDisable', [ET.USER_DISABLE])) - - # disable on gas pedal rising edge - if (ret.gasPressed and not self.gas_pressed_prev): - events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) + self.cp.update_strings(can_strings) + self.cp_cam.update_strings(can_strings) - if ret.gasPressed: - events.append(create_event('pedalPressed', [ET.PRE_ENABLE])) + ret = self.CS.update(self.cp, self.cp_cam) - ret.events = events + ret.canValid = self.cp.can_valid and self.cp_cam.can_valid + ret.steeringRateLimited = self.CC.steer_rate_limited if self.CC is not None else False - # update previous brake/gas pressed - self.gas_pressed_prev = ret.gasPressed - self.acc_active_prev = self.CS.acc_active + ret.events = self.create_common_events(ret).to_msg() - # cast to reader so it can't be modified - return ret.as_reader() + self.CS.out = ret.as_reader() + return self.CS.out def apply(self, c): can_sends = self.CC.update(c.enabled, self.CS, self.frame, c.actuators, diff --git a/selfdrive/car/subaru/radar_interface.py b/selfdrive/car/subaru/radar_interface.py index 0f8108771110ab..b2f76511360320 100644 --- a/selfdrive/car/subaru/radar_interface.py +++ b/selfdrive/car/subaru/radar_interface.py @@ -1,17 +1,5 @@ -#!/usr/bin/env python -from cereal import car -import time +#!/usr/bin/env python3 +from selfdrive.car.interfaces import RadarInterfaceBase - -class RadarInterface(object): - def __init__(self, CP): - # radar - self.pts = {} - self.delay = 0.1 - - def update(self, can_strings): - - ret = car.RadarData.new_message() - time.sleep(0.05) # radard runs on RI updates - - return ret +class RadarInterface(RadarInterfaceBase): + pass diff --git a/selfdrive/car/subaru/subarucan.py b/selfdrive/car/subaru/subarucan.py index 922012f318dd42..8249d36ba93197 100644 --- a/selfdrive/car/subaru/subarucan.py +++ b/selfdrive/car/subaru/subarucan.py @@ -1,45 +1,29 @@ import copy from cereal import car -from selfdrive.car.subaru.values import CAR VisualAlert = car.CarControl.HUDControl.VisualAlert -def subaru_checksum(packer, values, addr): - dat = packer.make_can_msg(addr, 0, values)[2] - dat = [ord(i) for i in dat] - return (sum(dat[1:]) + (addr >> 8) + addr) & 0xff - -def create_steering_control(packer, car_fingerprint, apply_steer, frame, steer_step): +def create_steering_control(packer, apply_steer, frame, steer_step): - if car_fingerprint == CAR.IMPREZA: - #counts from 0 to 15 then back to 0 + 16 for enable bit - idx = ((frame // steer_step) % 16) + idx = (frame / steer_step) % 16 - values = { - "Counter": idx, - "LKAS_Output": apply_steer, - "LKAS_Request": 1 if apply_steer != 0 else 0, - "SET_1": 1 - } - values["Checksum"] = subaru_checksum(packer, values, 0x122) + values = { + "Counter": idx, + "LKAS_Output": apply_steer, + "LKAS_Request": 1 if apply_steer != 0 else 0, + "SET_1": 1 + } return packer.make_can_msg("ES_LKAS", 0, values) -def create_steering_status(packer, car_fingerprint, apply_steer, frame, steer_step): - - if car_fingerprint == CAR.IMPREZA: - values = {} - values["Checksum"] = subaru_checksum(packer, {}, 0x322) - - return packer.make_can_msg("ES_LKAS_State", 0, values) +def create_steering_status(packer, apply_steer, frame, steer_step): + return packer.make_can_msg("ES_LKAS_State", 0, {}) def create_es_distance(packer, es_distance_msg, pcm_cancel_cmd): values = copy.copy(es_distance_msg) if pcm_cancel_cmd: - values["Main"] = 1 - - values["Checksum"] = subaru_checksum(packer, values, 545) + values["Cruise_Cancel"] = 1 return packer.make_can_msg("ES_Distance", 0, values) @@ -52,6 +36,32 @@ def create_es_lkas(packer, es_lkas_msg, visual_alert, left_line, right_line): values["LKAS_Left_Line_Visible"] = int(left_line) values["LKAS_Right_Line_Visible"] = int(right_line) - values["Checksum"] = subaru_checksum(packer, values, 802) - return packer.make_can_msg("ES_LKAS_State", 0, values) + +# *** Subaru Pre-global *** + +def subaru_preglobal_checksum(packer, values, addr): + dat = packer.make_can_msg(addr, 0, values)[2] + return (sum(dat[:7])) % 256 + +def create_preglobal_steering_control(packer, apply_steer, frame, steer_step): + + idx = (frame / steer_step) % 8 + + values = { + "Counter": idx, + "LKAS_Command": apply_steer, + "LKAS_Active": 1 if apply_steer != 0 else 0 + } + values["Checksum"] = subaru_preglobal_checksum(packer, values, "ES_LKAS") + + return packer.make_can_msg("ES_LKAS", 0, values) + +def create_es_throttle_control(packer, fake_button, es_accel_msg): + + values = copy.copy(es_accel_msg) + values["Button"] = fake_button + + values["Checksum"] = subaru_preglobal_checksum(packer, values, "ES_CruiseThrottle") + + return packer.make_can_msg("ES_CruiseThrottle", 0, values) diff --git a/selfdrive/car/subaru/values.py b/selfdrive/car/subaru/values.py index 0e444d736157e6..88c4ec690166a2 100644 --- a/selfdrive/car/subaru/values.py +++ b/selfdrive/car/subaru/values.py @@ -1,22 +1,87 @@ +# flake8: noqa + from selfdrive.car import dbc_dict +from cereal import car +Ecu = car.CarParams.Ecu class CAR: + ASCENT = "SUBARU ASCENT LIMITED 2019" IMPREZA = "SUBARU IMPREZA LIMITED 2019" + FORESTER = "SUBARU FORESTER 2019" + FORESTER_PREGLOBAL = "SUBARU FORESTER 2017 - 2018" + LEGACY_PREGLOBAL = "SUBARU LEGACY 2015 - 2018" + OUTBACK_PREGLOBAL = "SUBARU OUTBACK 2015 - 2017" + OUTBACK_PREGLOBAL_2018 = "SUBARU OUTBACK 2018 - 2019" FINGERPRINTS = { + CAR.ASCENT: [{ + # SUBARU ASCENT LIMITED 2019 + 2: 8, 64: 8, 65: 8, 72: 8, 73: 8, 280: 8, 281: 8, 290: 8, 312: 8, 313: 8, 314: 8, 315: 8, 316: 8, 326: 8, 544: 8, 545: 8, 546: 8, 552: 8, 554: 8, 557: 8, 576: 8, 577: 8, 722: 8, 801: 8, 802: 8, 805: 8, 808: 8, 811: 8, 816: 8, 826: 8, 837: 8, 838: 8, 839: 8, 842: 8, 912: 8, 915: 8, 940: 8, 1614: 8, 1617: 8, 1632: 8, 1650: 8, 1657: 8, 1658: 8, 1677: 8, 1722: 8, 1743: 8, 1759: 8, 1785: 5, 1786: 5, 1787: 5, 1788: 8 + }], CAR.IMPREZA: [{ + # SUBARU IMPREZA LIMITED 2019 2: 8, 64: 8, 65: 8, 72: 8, 73: 8, 280: 8, 281: 8, 290: 8, 312: 8, 313: 8, 314: 8, 315: 8, 316: 8, 326: 8, 544: 8, 545: 8, 546: 8, 552: 8, 554: 8, 557: 8, 576: 8, 577: 8, 722: 8, 801: 8, 802: 8, 805: 8, 808: 8, 816: 8, 826: 8, 837: 8, 838: 8, 839: 8, 842: 8, 912: 8, 915: 8, 940: 8, 1614: 8, 1617: 8, 1632: 8, 1650: 8, 1657: 8, 1658: 8, 1677: 8, 1697: 8, 1722: 8, 1743: 8, 1759: 8, 1786: 5, 1787: 5, 1788: 8, 1809: 8, 1813: 8, 1817: 8, 1821: 8, 1840: 8, 1848: 8, 1924: 8, 1932: 8, 1952: 8, 1960: 8 }, - # Crosstrek 2018 (same platform as Subaru) + # SUBARU CROSSTREK 2018 + { + 2: 8, 64: 8, 65: 8, 72: 8, 73: 8, 280: 8, 281: 8, 290: 8, 312: 8, 313: 8, 314: 8, 315: 8, 316: 8, 326: 8, 372: 8, 544: 8, 545: 8, 546: 8, 554: 8, 557: 8, 576: 8, 577: 8, 722: 8, 801: 8, 802: 8, 805: 8, 808: 8, 811: 8, 826: 8, 837: 8, 838: 8, 839: 8, 842: 8, 912: 8, 915: 8, 940: 8, 1614: 8, 1617: 8, 1632: 8, 1650: 8, 1657: 8, 1658: 8, 1677: 8, 1697: 8, 1759: 8, 1786: 5, 1787: 5, 1788: 8 + }], + CAR.FORESTER: [{ + # Forester 2019-2020 + 2: 8, 64: 8, 65: 8, 72: 8, 73: 8, 280: 8, 281: 8, 282: 8, 290: 8, 312: 8, 313: 8, 314: 8, 315: 8, 316: 8, 326: 8, 372: 8, 544: 8, 545: 8, 546: 8, 552: 8, 554: 8, 557: 8, 576: 8, 577: 8, 722: 8, 801: 8, 802: 8, 803: 8, 805: 8, 808: 8, 811: 8, 816: 8, 826: 8, 837: 8, 838: 8, 839: 8, 842: 8, 912: 8, 915: 8, 940: 8, 961: 8, 984: 8, 1614: 8, 1617: 8, 1632: 8, 1650: 8, 1651: 8, 1657: 8, 1658: 8, 1677: 8, 1697: 8, 1698: 8, 1722: 8, 1743: 8, 1759: 8, 1787: 5, 1788: 8, 1809: 8, 1813: 8, 1817: 8, 1821: 8, 1840: 8, 1848: 8, 1924: 8, 1932: 8, 1952: 8, 1960: 8 + }], + CAR.OUTBACK_PREGLOBAL: [{ + # OUTBACK PREMIUM 2.5i 2015 + 2: 8, 208: 8, 209: 4, 210: 8, 211: 7, 212: 8, 320: 8, 321: 8, 324: 8, 328: 8, 329: 8, 336: 2, 338: 8, 342: 8, 346: 8, 352: 8, 353: 8, 354: 8, 356: 8, 358: 8, 359: 8, 392: 8, 640: 8, 642: 8, 644: 8, 864: 8, 865: 8, 866: 8, 872: 8, 880: 8, 881: 8, 882: 8, 884: 8, 977: 8, 1632: 8, 1745: 8, 1786: 5, 1882: 8, 2015: 8, 2016: 8, 2024: 8, 604: 8, 885: 8, 1788: 8, 316: 8, 1614: 8, 1640: 8, 1657: 8, 1658: 8, 1672: 8, 1743: 8, 1785: 5, 1787: 5 + }, + # OUTBACK PREMIUM 3.6i 2015 + { + 2: 8, 208: 8, 209: 4, 210: 8, 211: 7, 212: 8, 320: 8, 321: 8, 324: 8, 328: 8, 329: 8, 336: 2, 338: 8, 342: 8, 392: 8, 604: 8, 640: 8, 642: 8, 644: 8, 864: 8, 865: 8, 866: 8, 872: 8, 880: 8, 881: 8, 882: 8, 884: 8, 977: 8, 1632: 8, 1745: 8, 1779: 8, 1786: 5 + }, + # OUTBACK LIMITED 2.5i 2018 { - 2: 8, 64: 8, 65: 8, 72: 8, 73: 8, 256: 8, 280: 8, 281: 8, 290: 8, 312: 8, 313: 8, 314: 8, 315: 8, 316: 8, 326: 8, 372: 8, 544: 8, 545: 8, 546: 8, 554: 8, 557: 8, 576: 8, 577: 8, 722: 8, 801: 8, 802: 8, 805: 8, 808: 8, 811: 8, 826: 8, 837: 8, 838: 8, 839: 8, 842: 8, 912: 8, 915: 8, 940: 8, 1614: 8, 1617: 8, 1632: 8, 1650: 8, 1657: 8, 1658: 8, 1677: 8, 1697: 8, 1759: 8, 1786: 5, 1787: 5, 1788: 8 + 2: 8, 208: 8, 209: 4, 210: 8, 211: 7, 212: 8, 316: 8, 320: 8, 321: 8, 324: 8, 328: 8, 329: 8, 336: 2, 338: 8, 342: 8, 352: 8, 353: 8, 354: 8, 356: 8, 358: 8, 359: 8, 392: 8, 554: 8, 604: 8, 640: 8, 642: 8, 644: 8, 805: 8, 864: 8, 865: 8, 866: 8, 872: 8, 880: 8, 881: 8, 882: 8, 884: 8, 885: 8, 977: 8, 1614: 8, 1632: 8, 1657: 8, 1658: 8, 1672: 8, 1722: 8, 1736: 8, 1743: 8, 1745: 8, 1785: 5, 1786: 5, 1787: 5, 1788: 8 + }], + CAR.OUTBACK_PREGLOBAL_2018: [{ + # OUTBACK LIMITED 3.6R 2019 + 2: 8, 208: 8, 209: 4, 210: 8, 211: 7, 212: 8, 316: 8, 320: 8, 321: 8, 324: 8, 328: 8, 329: 8, 336: 2, 338: 8, 342: 8, 352: 8, 353: 8, 354: 8, 356: 8, 358: 8, 359: 8, 392: 8, 554: 8, 604: 8, 640: 8, 642: 8, 644: 8, 805: 8, 864: 8, 865: 8, 866: 8, 872: 8, 880: 8, 881: 8, 882: 8, 884: 8, 885: 8, 886: 2, 977: 8, 1614: 8, 1632: 8, 1657: 8, 1658: 8, 1672: 8, 1736: 8, 1743: 8, 1745: 8, 1785: 5, 1786: 5, 1787: 5, 1788: 8, 1862: 8, 1870: 8, 1920: 8, 1927: 8, 1928: 8, 1935: 8, 1968: 8, 1976: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8 + }], + CAR.FORESTER_PREGLOBAL: [{ + # FORESTER PREMIUM 2.5i 2017 + 2: 8, 112: 8, 117: 8, 128: 8, 208: 8, 209: 4, 210: 8, 211: 7, 212: 8, 320: 8, 321: 8, 324: 8, 328: 8, 329: 8, 336: 2, 338: 8, 340: 7, 342: 8, 352: 8, 353: 8, 354: 8, 355: 8, 356: 8, 554: 8, 604: 8, 640: 8, 641: 8, 642: 8, 805: 8, 864: 8, 865: 8, 866: 8, 872: 8, 880: 8, 881: 8, 882: 8, 884: 8, 885: 8, 886: 1, 888: 8, 977: 8, 1398: 8, 1632: 8, 1743: 8, 1744: 8, 1745: 8, 1785: 5, 1786: 5, 1787: 5, 1788: 8, 1882: 8, 1895: 8, 1903: 8, 1986: 8, 1994: 8, 2015: 8, 2016: 8, 2024: 8, 644:8, 890:8, 1736:8 + }], + CAR.LEGACY_PREGLOBAL: [{ + # LEGACY 2.5i 2017 + 2: 8, 208: 8, 209: 4, 210: 8, 211: 7, 212: 8, 320: 8, 321: 8, 324: 8, 328: 8, 329: 8, 336: 2, 338: 8, 342: 8, 392: 8, 604: 8, 640: 8, 642: 8, 864: 8, 865: 8, 866: 8, 872: 8, 880: 8, 881: 8, 882: 8, 884: 8, 885: 8, 977: 8, 1632: 8, 1640: 8, 1736: 8, 1745: 8, 1785: 5, 1786: 5, 1787: 5, 1788: 8, 352: 8, 353: 8, 354: 8, 356: 8, 358: 8, 359: 8, 644: 8 + }, + # LEGACY 2018 + { + 2: 8, 208: 8, 209: 4, 210: 8, 211: 7, 212: 8, 316: 8, 320: 8, 321: 8, 324: 8, 328: 8, 329: 8, 336: 2, 338: 8, 342: 8, 392: 8, 604: 8, 640: 8, 642: 8, 864: 8, 865: 8, 866: 8, 872: 8, 880: 8, 881: 8, 882: 8, 884: 8, 885: 8, 977: 8, 1614: 8, 1632: 8, 1640: 8, 1657: 8, 1658: 8, 1672: 8, 1722: 8, 1743: 8, 1745: 8, 1778: 8, 1785: 5, 1786: 5, 1787: 5, 1788: 8, 2015: 8, 2016: 8, 2024: 8 + }, + # LEGACY 2018 + { + 2: 8, 208: 8, 209: 4, 210: 8, 211: 7, 212: 8, 316: 8, 320: 8, 321: 8, 324: 8, 328: 8, 329: 8, 336: 2, 338: 8, 342: 8, 352: 8, 353: 8, 354: 8, 356: 8, 358: 8, 359: 8, 392: 8, 554: 8, 604: 8, 640: 8, 642: 8, 805: 8, 864: 8, 865: 8, 866: 8, 872: 8, 880: 8, 881: 8, 882: 8, 884: 8, 885: 8, 977: 8, 1614: 8, 1632: 8, 1640: 8, 1657: 8, 1658: 8, 1672: 8, 1722: 8, 1743: 8, 1745: 8, 1785: 5, 1786: 5, 1787: 5, 1788: 8, 2015: 8, 2016: 8, 2024: 8 }], } STEER_THRESHOLD = { + CAR.ASCENT: 80, CAR.IMPREZA: 80, + CAR.FORESTER: 80, + CAR.FORESTER_PREGLOBAL: 75, + CAR.LEGACY_PREGLOBAL: 75, + CAR.OUTBACK_PREGLOBAL: 75, + CAR.OUTBACK_PREGLOBAL_2018: 75, } DBC = { - CAR.IMPREZA: dbc_dict('subaru_global_2017', None), + CAR.ASCENT: dbc_dict('subaru_global_2017_generated', None), + CAR.IMPREZA: dbc_dict('subaru_global_2017_generated', None), + CAR.FORESTER: dbc_dict('subaru_global_2017_generated', None), + CAR.FORESTER_PREGLOBAL: dbc_dict('subaru_forester_2017_generated', None), + CAR.LEGACY_PREGLOBAL: dbc_dict('subaru_outback_2015_generated', None), + CAR.OUTBACK_PREGLOBAL: dbc_dict('subaru_outback_2015_generated', None), + CAR.OUTBACK_PREGLOBAL_2018: dbc_dict('subaru_outback_2019_generated', None), } + +PREGLOBAL_CARS = [CAR.FORESTER_PREGLOBAL, CAR.LEGACY_PREGLOBAL, CAR.OUTBACK_PREGLOBAL, CAR.OUTBACK_PREGLOBAL_2018] diff --git a/selfdrive/car/tesla/ACC_module.py b/selfdrive/car/tesla/ACC_module.py index 390ba53a2ca856..5be456016c9297 100644 --- a/selfdrive/car/tesla/ACC_module.py +++ b/selfdrive/car/tesla/ACC_module.py @@ -1,14 +1,12 @@ -from selfdrive.services import service_list +from selfdrive.car.tesla.speed_utils.fleet_speed import FleetSpeed from selfdrive.car.tesla.values import CruiseButtons, CruiseState from selfdrive.config import Conversions as CV -import selfdrive.messaging as messaging +import cereal.messaging as messaging import sys import time -import zmq -from selfdrive.car.tesla.movingaverage import MovingAverage - -class ACCState(object): + +class ACCState(): # Possible states of the ACC system, following the DI_cruiseState naming # scheme. OFF = 0 # Disabled by UI. @@ -16,25 +14,27 @@ class ACCState(object): ENABLED = 2 # Engaged. NOT_READY = 9 # Not ready to be engaged due to the state of the car. -class _Mode(object): - def __init__(self, label, autoresume, state): +class _Mode(): + def __init__(self, label, autoresume, state,adaptive): self.label = label self.autoresume = autoresume self.state = state + self.adaptive = adaptive self.next = None -class ACCMode(object): +class ACCMode(): # Possible ACC modes, controlling how ACC behaves. # This is separate from ACC state. For example, you could # have ACC in "Autoresume" mode in "Standby" state. - FOLLOW = _Mode(label="follow", autoresume=False, state=ACCState.STANDBY) - AUTO = _Mode(label="auto", autoresume=True, state=ACCState.STANDBY) + FOLLOW = _Mode(label="follow", autoresume=False, state=ACCState.STANDBY, adaptive=True) + AUTO = _Mode(label="auto", autoresume=True, state=ACCState.STANDBY, adaptive=True) + PLAINCC = _Mode(label="cc", autoresume=False, state=ACCState.STANDBY, adaptive=False) BUTTON_NAME = 'acc' BUTTON_ABREVIATION = 'ACC' # Toggle order: OFF -> ON -> AUTO -> OFF - _all_modes = [FOLLOW, AUTO] + _all_modes = [FOLLOW, AUTO,PLAINCC] for index, mode in enumerate(_all_modes): mode.next = _all_modes[(index + 1) % len(_all_modes)] @@ -52,7 +52,7 @@ def _current_time_millis(): return int(round(time.time() * 1000)) -class ACCController(object): +class ACCController(): # Tesla cruise only functions above 17 MPH MIN_CRUISE_SPEED_MS = 17.1 * CV.MPH_TO_MS @@ -61,14 +61,15 @@ def __init__(self,carcontroller): self.CC = carcontroller self.human_cruise_action_time = 0 self.automated_cruise_action_time = 0 - self.poller = zmq.Poller() - self.radarState = messaging.sub_sock(service_list['radarState'].port, conflate=True, poller=self.poller) + self.radarState = messaging.sub_sock('radarState', conflate=True) self.last_update_time = 0 self.enable_adaptive_cruise = False self.prev_enable_adaptive_cruise = False # Whether to re-engage automatically after being paused due to low speed or # user-initated deceleration. self.autoresume = False + self.adaptive = False + self.last_brake_press_time = 0 self.last_cruise_stalk_pull_time = 0 self.prev_cruise_buttons = CruiseButtons.IDLE self.prev_pcm_acc_status = 0 @@ -81,8 +82,8 @@ def __init__(self,carcontroller): self.lead_last_seen_time_ms = 0 # BB speed for testing self.new_speed = 0 - self.average_speed_over_x_suggestions = 20 #2 seconds.... 10x a second - self.maxsuggestedspeed_avg = MovingAverage(self.average_speed_over_x_suggestions) + average_speed_over_x_suggestions = 20 # 1 second (20x a second) + self.fleet_speed = FleetSpeed(average_speed_over_x_suggestions) # Updates the internal state of this controller based on user input, # specifically the steering wheel mounted cruise control stalk, and OpenPilot @@ -96,61 +97,67 @@ def update_stat(self, CS, enabled): acc_mode = ACCMode.from_label(acc_string) CS.cstm_btns.get_button(ACCMode.BUTTON_NAME).btn_label2 = acc_mode.label self.autoresume = acc_mode.autoresume + self.adaptive = acc_mode.adaptive curr_time_ms = _current_time_millis() # Handle pressing the enable button. - if (CS.cruise_buttons == CruiseButtons.MAIN and - self.prev_cruise_buttons != CruiseButtons.MAIN): + if (CS.cruise_buttons == CruiseButtons.MAIN or CS.cruise_buttons == CruiseButtons.DECEL_SET) and self.prev_cruise_buttons != CS.cruise_buttons: double_pull = curr_time_ms - self.last_cruise_stalk_pull_time < 750 self.last_cruise_stalk_pull_time = curr_time_ms ready = (CS.cstm_btns.get_button_status(ACCMode.BUTTON_NAME) > ACCState.OFF - and enabled + and (enabled or (CS.cruise_buttons == CruiseButtons.DECEL_SET and not self.adaptive)) and CruiseState.is_enabled_or_standby(CS.pcm_acc_status) and CS.v_ego > self.MIN_CRUISE_SPEED_MS) - if ready and double_pull: + if ready and double_pull and ((self.adaptive and CS.cruise_buttons == CruiseButtons.MAIN) or ((not self.adaptive) and CS.cruise_buttons == CruiseButtons.DECEL_SET)): # A double pull enables ACC. updating the max ACC speed if necessary. self.enable_adaptive_cruise = True # Increase ACC speed to match current, if applicable. - self.acc_speed_kph = max(CS.v_ego_raw * CV.MS_TO_KPH, self.speed_limit_kph) + if self.adaptive: + self.acc_speed_kph = max(CS.v_ego_raw * CV.MS_TO_KPH, self.speed_limit_kph) + else: + self.acc_speed_kph = CS.v_ego_raw * CV.MS_TO_KPH self.user_has_braked = False self.has_gone_below_min_speed = False else: # A single pull disables ACC (falling back to just steering). - self.enable_adaptive_cruise = False + if CS.cruise_buttons == CruiseButtons.MAIN: + self.enable_adaptive_cruise = False # Handle pressing the cancel button. - elif CS.cruise_buttons == CruiseButtons.CANCEL: + if CS.cruise_buttons == CruiseButtons.CANCEL: self.enable_adaptive_cruise = False self.acc_speed_kph = 0. self.last_cruise_stalk_pull_time = 0 # Handle pressing up and down buttons. - elif (self.enable_adaptive_cruise and + elif (CS.cruise_buttons != CruiseButtons.MAIN and self.enable_adaptive_cruise and CS.cruise_buttons != self.prev_cruise_buttons): self._update_max_acc_speed(CS) if CS.brake_pressed: self.user_has_braked = True + self.last_brake_press_time = _current_time_millis() if not self.autoresume: self.enable_adaptive_cruise = False if CS.v_ego < self.MIN_CRUISE_SPEED_MS: self.has_gone_below_min_speed = True - # If autoresume is not enabled, manually steering or slowing disables ACC. + # If autoresume is not enabled and not in standard CC, disable if we hit the brakes or gone below 18mph if not self.autoresume: - if not enabled or self.user_has_braked or self.has_gone_below_min_speed: + if (self.adaptive and not enabled) or self.user_has_braked or self.has_gone_below_min_speed: self.enable_adaptive_cruise = False # Notify if ACC was toggled if self.prev_enable_adaptive_cruise and not self.enable_adaptive_cruise: - CS.UE.custom_alert_message(3, "ACC Disabled", 150, 4) + CS.UE.custom_alert_message(3, "%s Disabled" % ("ACC" if self.adaptive else "CC"), 150, 4) CS.cstm_btns.set_button_status(ACCMode.BUTTON_NAME, ACCState.STANDBY) + self.fleet_speed.reset_averager() elif self.enable_adaptive_cruise: CS.cstm_btns.set_button_status(ACCMode.BUTTON_NAME, ACCState.ENABLED) if not self.prev_enable_adaptive_cruise: - CS.UE.custom_alert_message(2, "ACC Enabled", 150) + CS.UE.custom_alert_message(2, "%s Enabled" % ("ACC" if self.adaptive else "CC"), 150) # Update the UI to show whether the current car state allows ACC. if CS.cstm_btns.get_button_status(ACCMode.BUTTON_NAME) in [ACCState.STANDBY, ACCState.NOT_READY]: - if (enabled + if ((enabled or not self.adaptive) and CruiseState.is_enabled_or_standby(CS.pcm_acc_status) and CS.v_ego > self.MIN_CRUISE_SPEED_MS): CS.cstm_btns.set_button_status(ACCMode.BUTTON_NAME, ACCState.STANDBY) @@ -175,50 +182,48 @@ def _update_max_acc_speed(self, CS): # Clip ACC speed between 0 and 170 KPH. self.acc_speed_kph = min(self.acc_speed_kph, 170) self.acc_speed_kph = max(self.acc_speed_kph, 0) - - def max_v_by_speed_limit(self, acc_set_speed_ms, CS): - # if more than 10 kph / 2.78 ms, consider we have speed limit - if (CS.maxdrivespeed > 0) and CS.useTeslaMapData and (CS.mapAwareSpeed or (CS.baseMapSpeedLimitMPS <2.7)): - #do we know the based speed limit? - sl1 = 0. - if CS.baseMapSpeedLimitMPS >= 2.7: - #computer adjusted maxdrive based on set speed - sl1 = min (acc_set_speed_ms * CS.maxdrivespeed / CS.baseMapSpeedLimitMPS, acc_set_speed_ms) - sl1 = self.maxsuggestedspeed_avg.add(sl1) - else: - sl1 = self.maxsuggestedspeed_avg.add(CS.maxdrivespeed) - return min(acc_set_speed_ms, sl1) - else: - return acc_set_speed_ms - # Decide which cruise control buttons to simluate to get the car to the - # desired speed. - def update_acc(self, enabled, CS, frame, actuators, pcm_speed, speed_limit_kph, speed_limit_valid, set_speed_limit_active, speed_limit_offset): + # Decide which cruise control buttons to simluate to get the car to the desired speed. + def update_acc(self, enabled, CS, frame, actuators, pcm_speed, speed_limit_kph, set_speed_limit_active, speed_limit_offset): # Adaptive cruise control self.prev_speed_limit_kph = self.speed_limit_kph - if speed_limit_valid and set_speed_limit_active and (speed_limit_kph >= 10): - self.speed_limit_kph = speed_limit_kph + speed_limit_offset - if not (int(self.prev_speed_limit_kph) == int(self.speed_limit_kph)): + if set_speed_limit_active and speed_limit_kph > 0: + self.speed_limit_kph = speed_limit_kph + speed_limit_offset + if int(self.prev_speed_limit_kph) != int(self.speed_limit_kph): self.acc_speed_kph = self.speed_limit_kph - self.maxsuggestedspeed_avg.reset() + self.fleet_speed.reset_averager() + else: # reset internal speed limit, so double pull doesn't set higher speed than current (e.g. after leaving the highway) + self.speed_limit_kph = 0. current_time_ms = _current_time_millis() if CruiseButtons.should_be_throttled(CS.cruise_buttons): self.human_cruise_action_time = current_time_ms button_to_press = None # If ACC is disabled, disengage traditional cruise control. - if (self.prev_enable_adaptive_cruise and not self.enable_adaptive_cruise - and CS.pcm_acc_status == CruiseState.ENABLED): + if((self.prev_enable_adaptive_cruise) and (not self.enable_adaptive_cruise) + and (CS.pcm_acc_status == CruiseState.ENABLED)): button_to_press = CruiseButtons.CANCEL + #if non addaptive and we just engaged ACC but pcm is not engaged, then engage + if (not self.adaptive) and self.enable_adaptive_cruise and (CS.pcm_acc_status != CruiseState.ENABLED): + button_to_press = CruiseButtons.MAIN + + #if plain cc, not adaptive, then just return None or Cancel + if (not self.adaptive) and self.enable_adaptive_cruise: + self.acc_speed_kph = CS.v_cruise_actual #if not CS.imperial_speed_units else CS.v_cruise_actual * CV.MPH_TO_KPH + return button_to_press + + #disengage if cruise is canceled + if (not self.enable_adaptive_cruise) and (CS.pcm_acc_status >= 2) and (CS.pcm_acc_status <= 4): + button_to_press = CruiseButtons.CANCEL lead_1 = None #if enabled: - for socket, _ in self.poller.poll(0): - if socket is self.radarState: - lead_1 = messaging.recv_one(socket).radarState.leadOne + lead = messaging.recv_one_or_none(self.radarState) + if lead is not None: + lead_1 = lead.radarState.leadOne if lead_1.dRel: self.lead_last_seen_time_ms = current_time_ms - if self.enable_adaptive_cruise and enabled: + if self.enable_adaptive_cruise and enabled: # and (button_to_press == None): if CS.cstm_btns.get_button_label2(ACCMode.BUTTON_NAME) in ["OP", "AutoOP"]: button_to_press = self._calc_button(CS, pcm_speed) self.new_speed = pcm_speed * CV.MS_TO_KPH @@ -227,7 +232,7 @@ def update_acc(self, enabled, CS, frame, actuators, pcm_speed, speed_limit_kph, # and speed more directly. # Bring in the lead car distance from the radarState feed - button_to_press = self._calc_follow_button(CS, lead_1,speed_limit_kph, speed_limit_valid, set_speed_limit_active, speed_limit_offset) + button_to_press = self._calc_follow_button(CS, lead_1, speed_limit_kph, set_speed_limit_active, speed_limit_offset, frame) if button_to_press: self.automated_cruise_action_time = current_time_ms # If trying to slow below the min cruise speed, just cancel cruise. @@ -243,7 +248,7 @@ def update_acc(self, enabled, CS, frame, actuators, pcm_speed, speed_limit_kph, return button_to_press # function to calculate the cruise button based on a safe follow distance - def _calc_follow_button(self, CS, lead_car,speed_limit_kph, speed_limit_valid, set_speed_limit_active, speed_limit_offset): + def _calc_follow_button(self, CS, lead_car, speed_limit_kph, set_speed_limit_active, speed_limit_offset, frame): if lead_car is None: return None # Desired gap (in seconds) between cars. @@ -258,7 +263,7 @@ def _calc_follow_button(self, CS, lead_car,speed_limit_kph, speed_limit_valid, s # Relative velocity between the lead car and our set cruise speed. future_vrel_kph = lead_speed_kph - CS.v_cruise_actual # How much we can accelerate without exceeding the max allowed speed. - max_acc_speed_kph = self.max_v_by_speed_limit(self.acc_speed_kph * CV.KPH_TO_MS, CS) * CV.MS_TO_KPH + max_acc_speed_kph = self.fleet_speed.adjust(CS, self.acc_speed_kph * CV.KPH_TO_MS, frame) * CV.MS_TO_KPH available_speed_kph = max_acc_speed_kph - CS.v_cruise_actual half_press_kph, full_press_kph = self._get_cc_units_kph(CS.imperial_speed_units) # button to issue @@ -349,11 +354,11 @@ def _calc_follow_button(self, CS, lead_car,speed_limit_kph, speed_limit_valid, s ratio = 0 if safe_dist_m > 0: ratio = (lead_dist_m / safe_dist_m) * 100 - print "Ratio: {0:.1f}% lead: {1:.1f}m avail: {2:.1f}kph vRel: {3:.1f}kph Angle: {4:.1f}deg".format( - ratio, lead_dist_m, available_speed_kph, lead_car.vRel * CV.MS_TO_KPH, CS.angle_steers) + print ("Ratio: {0:.1f}% lead: {1:.1f}m avail: {2:.1f}kph vRel: {3:.1f}kph Angle: {4:.1f}deg".format( + ratio, lead_dist_m, available_speed_kph, lead_car.vRel * CV.MS_TO_KPH, CS.angle_steers)) self.last_update_time = current_time_ms - if msg != None: - print "ACC: " + msg + if msg is not None: + print ("ACC: " + msg) return button def _should_autoengage_cc(self, CS, lead_car=None): @@ -366,11 +371,14 @@ def _should_autoengage_cc(self, CS, lead_car=None): and CS.v_ego >= self.MIN_CRUISE_SPEED_MS and _current_time_millis() > self.fast_decel_time + 2000) - slow_lead = lead_car and lead_car.dRel > 0 and lead_car.vRel < 0 or self._fast_decel_required(CS, lead_car) + slow_lead = lead_car and lead_car.dRel > 0 and lead_car.vRel < 0 or self._fast_decel_required(CS, lead_car) # pylint: disable=chained-comparison # "Autoresume" mode allows cruise to engage even after brake events, but # shouldn't trigger DURING braking. - autoresume_ready = self.autoresume and CS.a_ego >= 0.1 + autoresume_ready = (self.autoresume + and CS.a_ego >= 0.1 + and not self.CC.HSO.human_control + and _current_time_millis() > self.last_brake_press_time + 1000) braked = self.user_has_braked or self.has_gone_below_min_speed @@ -390,9 +398,9 @@ def _fast_decel_required(self, CS, lead_car): def _seconds_to_collision(self, CS, lead_car): if not lead_car or not lead_car.dRel: - return sys.maxint + return sys.maxsize elif lead_car.vRel >= 0: - return sys.maxint + return sys.maxsize return abs(float(lead_car.dRel) / lead_car.vRel) def _get_cc_units_kph(self, is_imperial_units): diff --git a/selfdrive/car/tesla/AHB_module.py b/selfdrive/car/tesla/AHB_module.py new file mode 100644 index 00000000000000..0f5f4254f0b440 --- /dev/null +++ b/selfdrive/car/tesla/AHB_module.py @@ -0,0 +1,136 @@ +from selfdrive.config import Conversions as CV +from cereal import tesla,log +import cereal.messaging as messaging +import time + +DEBUG = False + +class AHBReason(): + HIGH_BEAM_ON = 0 + HIGH_BEAM_OFF_REASON_MOVING_VISION_TARGET = 1 + HIGH_BEAM_OFF_REASON_MOVING_RADAR_TARGET = 2 + HIGH_BEAM_OFF_REASON_AMBIENT_LIGHT = 3 + HIGH_BEAM_OFF_REASON_HEAD_LIGHT = 4 + HIGH_BEAM_OFF_REASON_SNA = 5 + +class AHBDecision(): + DAS_HIGH_BEAM_UNDECIDED = 0 + DAS_HIGH_BEAM_OFF = 1 + DAS_HIGH_BEAM_ON = 2 + DAS_HIGH_BEAM_SNA = 3 + +def _current_time_millis(): + return int(round(time.time() * 1000)) + +def _debug(message): + if DEBUG: + print(message) + +class AHBController(): + + def __init__(self,carcontroller): + self.time_last_car_detected = 0 + self.time_last_high_beam_cancel = 0 + self.prev_car_present = False + self.prev_highLowBeamStatus = 0 + self.prev_highLowBeamReason = 0 + self.prev_light_stalk_position = 0 + self.prev_high_beam_on = False + self.prev_lights_on = False + self.ahbInfo = messaging.sub_sock('ahbInfo', conflate=True) + self.ahbInfoData = None + self.ahbIsEnabled = False + self.frameInfo = messaging.sub_sock('frame', conflate=True) + self.frameInfoData = None + self.frameInfoGain = 0 + + def set_and_return(self,CS,frame,highLowBeamStatus,highLowBeamReason): + self.prev_light_stalk_position = CS.ahbHighBeamStalkPosition + if self.ahbInfoData is not None: + self.prev_car_present = self.ahbInfoData.cameraCarDetected or self.ahbInfoData.radarCarDetected + self.prev_highLowBeamStatus = highLowBeamStatus + self.prev_highLowBeamReason = highLowBeamReason + self.prev_high_beam_on = CS.ahbHiBeamOn + self.prev_lights_on = CS.ahbLoBeamOn + self.ahbIsEnabled = self.ahbIsEnabled and CS.ahbEnabled + return highLowBeamStatus,highLowBeamReason,self.ahbIsEnabled + + def update(self, CS, frame,ahbLead1): + tms_now = _current_time_millis() + ahbInfoMsg = self.ahbInfo.receive(non_blocking=True) + frameInfoMsg = messaging.recv_one_or_none(self.frameInfo) + if ahbInfoMsg is not None: + self.ahbInfoData = tesla.AHBinfo.from_bytes(ahbInfoMsg) + if frameInfoMsg is not None: + self.frameInfoData = frameInfoMsg.frame + frameInfoGain = self.frameInfoData.globalGain + exposureTime = self.frameInfoData.androidCaptureResult.exposureTime + frameDuration = self.frameInfoData.androidCaptureResult.frameDuration + if frameInfoGain != self.frameInfoGain: + self.frameInfoGain = frameInfoGain + _debug("AHB Camera has new data [ frame - " + str(self.frameInfoData.frameId) + "] = " + str(frameInfoGain) + ", exposure = " + str(exposureTime) + ", frame duration = " + str(frameDuration)) + #if AHB not enabled, then return OFF + if CS.ahbEnabled != 1: + _debug("AHB not enabled in CID") + highLowBeamStatus = AHBDecision.DAS_HIGH_BEAM_UNDECIDED + highLowBeamReason = AHBReason.HIGH_BEAM_OFF_REASON_SNA + return self.set_and_return(CS,frame,highLowBeamStatus,highLowBeamReason) + #if stalk is not in the high beam position, return UNDECIDED + if (CS.ahbHighBeamStalkPosition != 1): + _debug("High Beam not on") + highLowBeamStatus = AHBDecision.DAS_HIGH_BEAM_UNDECIDED + highLowBeamReason = AHBReason.HIGH_BEAM_OFF_REASON_SNA + self.ahbIsEnabled = False + return self.set_and_return(CS,frame,highLowBeamStatus,highLowBeamReason) + else : + self.ahbIsEnabled = True + #if moving below 10mph take no decision, then return undecided + if CS.v_ego < 4.47: + _debug("moving too slow for decision") + highLowBeamStatus = self.prev_highLowBeamStatus + highLowBeamReason = self.prev_highLowBeamReason + return self.set_and_return(CS,frame,highLowBeamStatus,highLowBeamReason) + if self.ahbInfoData is None: + _debug("No radar info") + highLowBeamStatus = AHBDecision.DAS_HIGH_BEAM_UNDECIDED + highLowBeamReason = AHBReason.HIGH_BEAM_OFF_REASON_SNA + return self.set_and_return(CS,frame,highLowBeamStatus,highLowBeamReason) + # if gain less than max, we might see incoming car + if self.frameInfoGain < 510: + _debug("OP camera gain < 510") + self.time_last_car_detected = tms_now + highLowBeamStatus = AHBDecision.DAS_HIGH_BEAM_OFF + highLowBeamReason = AHBReason.HIGH_BEAM_OFF_REASON_MOVING_RADAR_TARGET + return self.set_and_return(CS,frame,highLowBeamStatus,highLowBeamReason) + #if lead car detected by radarD, i.e. OP has Lead, then reset timer and return OFF + if False and ahbLead1 is not None: + _debug("OP detected car") + self.time_last_car_detected = tms_now + highLowBeamStatus = AHBDecision.DAS_HIGH_BEAM_OFF + highLowBeamReason = AHBReason.HIGH_BEAM_OFF_REASON_MOVING_RADAR_TARGET + return self.set_and_return(CS,frame,highLowBeamStatus,highLowBeamReason) + #if lead car detected by radar, then reset timer and return OFF + if self.ahbInfoData.radarCarDetected: + _debug("Radar detected car") + self.time_last_car_detected = tms_now + highLowBeamStatus = AHBDecision.DAS_HIGH_BEAM_OFF + highLowBeamReason = AHBReason.HIGH_BEAM_OFF_REASON_MOVING_RADAR_TARGET + return self.set_and_return(CS,frame,highLowBeamStatus,highLowBeamReason) + #if lead car detected by vision, then reset timer and return OFF + if self.ahbInfoData.cameraCarDetected: + _debug("Vision detected car") + self.time_last_car_detected = tms_now + highLowBeamStatus = AHBDecision.DAS_HIGH_BEAM_OFF + highLowBeamReason = AHBReason.HIGH_BEAM_OFF_REASON_MOVING_VISION_TARGET + return self.set_and_return(CS,frame,highLowBeamStatus,highLowBeamReason) + #if still waiting for the delay after car detected, send off + if (tms_now - self.time_last_car_detected < 1000 * CS.ahbOffDuration ): + _debug("Waiting for time delay since last car") + highLowBeamStatus = AHBDecision.DAS_HIGH_BEAM_OFF + highLowBeamReason = AHBReason.HIGH_BEAM_OFF_REASON_MOVING_RADAR_TARGET + return self.set_and_return(CS,frame,highLowBeamStatus,highLowBeamReason) + #we got here, high beam should be on + highLowBeamStatus = AHBDecision.DAS_HIGH_BEAM_UNDECIDED + highLowBeamReason = AHBReason.HIGH_BEAM_ON + _debug("All conditions met, turn lights ON") + return self.set_and_return(CS,frame,highLowBeamStatus,highLowBeamReason) diff --git a/selfdrive/car/tesla/HSO_module.py b/selfdrive/car/tesla/HSO_module.py index 7253fc37dd49dc..d774a1a88f8231 100644 --- a/selfdrive/car/tesla/HSO_module.py +++ b/selfdrive/car/tesla/HSO_module.py @@ -1,43 +1,32 @@ #human steer override module -import time -def _current_time_millis(): - return int(round(time.time() * 1000)) +class HSOController(): + def __init__(self, carcontroller): + self.human_control = False + self.frame_humanSteered = 0 -class HSOController(object): - def __init__(self,carcontroller): - self.CC = carcontroller - self.frame_humanSteered = 0 - + def update_stat(self, CC, CS, enabled, actuators, frame): + human_control = False - def update_stat(self,CC,CS,enabled,actuators,frame): - human_control = False - if CS.enableHSO and enabled: - #if steering but not by ALCA - if (CS.right_blinker_on or CS.left_blinker_on) and (self.CC.ALCA.laneChange_enabled <= 1): + if CS.enableHSO and enabled: + # if steering but not by ALCA + if CS.steer_override > 0: + self.frame_humanSteered = frame + elif CC.ALCA.laneChange_enabled <= 1 and frame > CC.blinker.blinker_on_frame_start + CC.blinker.tap_duration_frames: + if CS.turn_signal_stalk_state > 0 or frame <= (CC.blinker.blinker_on_frame_start + int(100 * CS.hsoNumbPeriod)): # stalk locked or blinker within numbPeriod + self.frame_humanSteered = frame + elif frame - self.frame_humanSteered < 50: # Need more human testing of handoff timing + # Find steering difference between visiond model and human (no need to do every frame if we run out of CPU): + apply_steer = int(-actuators.steerAngle) + angle_diff = abs(apply_steer - CS.angle_steers) + if angle_diff > 15.: self.frame_humanSteered = frame - if (CS.steer_override > 0) and (frame - self.frame_humanSteered > 50): - self.frame_humanSteered = frame - else: - if (frame - self.frame_humanSteered < 50): # Need more human testing of handoff timing - # Find steering difference between visiond model and human (no need to do every frame if we run out of CPU): - steer_current=(CS.angle_steers) # Formula to convert current steering angle to match apply_steer calculated number - apply_steer = int(-actuators.steerAngle) - angle = abs(apply_steer-steer_current) - if angle > 10.: - self.frame_humanSteered = frame - if enabled: - if CS.enableHSO: - if (frame - self.frame_humanSteered < 50): - human_control = True - #CS.cstm_btns.set_button_status("steer",3) - CS.UE.custom_alert_message(3,"Manual Steering Enabled",51,4) - #else: - # CS.cstm_btns.set_button_status("steer",2) - #else: - # if CS.cstm_btns.get_button_status("steer") > 0: - # CS.cstm_btns.set_button_status("steer",1) - if (not human_control) and (CC.DAS_219_lcTempUnavailableSpeed == 1): - CC.DAS_219_lcTempUnavailableSpeed = 0 - CC.warningNeeded = 1 - return human_control and enabled + if frame - self.frame_humanSteered < 50: + human_control = True + CS.UE.custom_alert_message(3, "Manual Steering Enabled", 51, 4) + + if (not human_control) and (CC.DAS_219_lcTempUnavailableSpeed == 1): + CC.DAS_219_lcTempUnavailableSpeed = 0 + CC.warningNeeded = 1 + self.human_control = human_control + return human_control and enabled diff --git a/selfdrive/car/tesla/PCC_module.py b/selfdrive/car/tesla/PCC_module.py index 49db80fba888f9..1008dbd65a048f 100644 --- a/selfdrive/car/tesla/PCC_module.py +++ b/selfdrive/car/tesla/PCC_module.py @@ -1,828 +1,791 @@ -#!/usr/bin/env python -from selfdrive.car.tesla import teslacan -from selfdrive.controls.lib.longcontrol import LongControl, LongCtrlState -from common.numpy_fast import clip, interp -from selfdrive.services import service_list -from selfdrive.car.tesla.values import CruiseState, CruiseButtons -from selfdrive.config import Conversions as CV -from selfdrive.controls.lib.speed_smoother import speed_smoother -from selfdrive.controls.lib.planner import calc_cruise_accel_limits -from common.realtime import sec_since_boot -import selfdrive.messaging as messaging -import time -import zmq -import math -from collections import OrderedDict -from common.params import Params -from selfdrive.car.tesla.movingaverage import MovingAverage - -_DT = 0.05 # 10Hz in our case, since we don't want to process more than once the same radarState message -_DT_MPC = _DT - -# TODO: these should end up in values.py at some point, probably variable by trim -# Accel limits -MAX_RADAR_DISTANCE = 120. #max distance to take in consideration radar reading -MAX_PEDAL_VALUE = 112. -PEDAL_HYST_GAP = 1.0 # don't change pedal command for small oscilalitons within this value -# Cap the pedal to go from 0 to max in 4 seconds -PEDAL_MAX_UP = MAX_PEDAL_VALUE * _DT / 4 -# Cap the pedal to go from max to 0 in 0.4 seconds -PEDAL_MAX_DOWN = MAX_PEDAL_VALUE * _DT / 0.4 - -# min safe distance in meters. Roughly 2 car lengths. -MIN_SAFE_DIST_M = 6. - -#BBTODO: move the vehicle variables; maybe make them speed variable -TORQUE_LEVEL_ACC = 0. -TORQUE_LEVEL_DECEL = -30. - -MIN_PCC_V_KPH = 0. # -MAX_PCC_V_KPH = 170. - -ANGLE_STOP_ACCEL = 10. #this should be speed dependent - -MIN_CAN_SPEED = 0.3 #TODO: parametrize this in car interface - -# Pull the cruise stalk twice in this many ms for a 'double pull' -STALK_DOUBLE_PULL_MS = 750 - -class Mode(object): - label = None - -class OpMode(Mode): - label = 'OP' - -class FollowMode(Mode): - label = 'FOLLOW' - -class PCCModes(object): - _all_modes = [OpMode(), FollowMode()] - _mode_map = {mode.label : mode for mode in _all_modes} - BUTTON_NAME = 'pedal' - BUTTON_ABREVIATION = 'PDL' - - @classmethod - def from_label(cls, label): - return cls._mode_map.get(label, OpMode()) - - @classmethod - def from_buttons(cls, cstm_btns): - return cls.from_label(cstm_btns.get_button_label2(cls.BUTTON_NAME)) - - @classmethod - def is_selected(cls, mode, cstm_butns): - """Tell if the UI buttons are set to the given mode""" - button_mode = cls.from_buttons(cstm_butns) - if not (isinstance(mode, Mode) and isinstance(button_mode, Mode)): - return False - return mode.label == button_mode.label - - @classmethod - def labels(cls): - return [mode.label for mode in cls._all_modes] - - -def tesla_compute_gb(accel, speed): - return float(accel) / 3. - - -def max_v_in_mapped_curve_ms(map_data, pedal_set_speed_kph): - """Use HD map data to limit speed in sharper turns.""" - if map_data and map_data.curvatureValid: - pedal_set_speed_ms = pedal_set_speed_kph * CV.KPH_TO_MS - # Max lateral acceleration, used to caclulate how much to slow down in turns - a_y_max = 1.85 # m/s^2 - curvature = abs(map_data.curvature) - v_curvature_ms = math.sqrt(a_y_max / max(1e-4, curvature)) - time_to_turn_s = max(0, map_data.distToTurn / max(pedal_set_speed_ms, 1.)) - v_approaching_turn_ms = OrderedDict([ - # seconds til turn, max allowed velocity - (0, pedal_set_speed_ms), - (8, v_curvature_ms) - ]) - return _interp_map(time_to_turn_s, v_approaching_turn_ms) - else: - return None - - - -class PCCState(object): - # Possible state of the ACC system, following the DI_cruiseState naming - # scheme. - OFF = 0 # Disabled by UI. - STANDBY = 1 # Ready to be enaged. - ENABLED = 2 # Engaged. - NOT_READY = 9 # Not ready to be engaged due to the state of the car. - - -def _current_time_millis(): - return int(round(time.time() * 1000)) - - -#this is for the pedal cruise control -class PCCController(object): - def __init__(self,carcontroller): - self.CC = carcontroller - self.human_cruise_action_time = 0 - self.pedal_state = False - self.prev_pedal_state = False - self.automated_cruise_action_time = 0 - self.last_angle = 0. - self.poller = zmq.Poller() - self.radarState = messaging.sub_sock(service_list['radarState'].port, conflate=True, poller=self.poller) - self.live_map_data = messaging.sub_sock(service_list['liveMapData'].port, conflate=True, poller=self.poller) - self.lead_1 = None - self.last_update_time = 0 - self.enable_pedal_cruise = False - self.stalk_pull_time_ms = 0 - self.prev_stalk_pull_time_ms = -1000 - self.prev_pcm_acc_status = 0 - self.prev_cruise_buttons = CruiseButtons.IDLE - self.pedal_speed_kph = 0. - self.speed_limit_kph = 0. - self.prev_speed_limit_kph = 0. - self.pedal_idx = 0 - self.pedal_steady = 0. - self.prev_tesla_accel = 0. - self.prev_tesla_pedal = 0. - self.pedal_interceptor_state = 0 - self.torqueLevel_last = 0. - self.prev_v_ego = 0. - self.PedalForZeroTorque = 18. #starting number, works on my S85 - self.lastTorqueForPedalForZeroTorque = TORQUE_LEVEL_DECEL - self.v_pid = 0. - self.a_pid = 0. - self.last_output_gb = 0. - self.last_speed_kph = 0. - #for smoothing the changes in speed - self.v_acc_start = 0.0 - self.a_acc_start = 0.0 - self.acc_start_time = sec_since_boot() - self.v_acc = 0.0 - self.v_acc_sol = 0.0 - self.v_acc_future = 0.0 - self.a_acc = 0.0 - self.a_acc_sol = 0.0 - self.v_cruise = 0.0 - self.a_cruise = 0.0 - self.had_lead = False - #Long Control - self.LoC = None - #when was radar data last updated? - self.lead_last_seen_time_ms = 0 - self.continuous_lead_sightings = 0 - self.params = Params() - self.average_speed_over_x_suggestions = 3 #10x a second - self.maxsuggestedspeed_avg = MovingAverage(self.average_speed_over_x_suggestions) - - def max_v_by_speed_limit(self,pedal_set_speed_ms ,speed_limit_ms, CS): - # if more than 10 kph / 2.78 ms, consider we have speed limit - if (CS.maxdrivespeed > 0) and CS.useTeslaMapData and (CS.mapAwareSpeed or (CS.baseMapSpeedLimitMPS <2.7)): - #do we know the based speed limit? - sl1 = 0. - if CS.baseMapSpeedLimitMPS >= 2.7: - #computer adjusted maxdrive based on set speed - sl1 = min (speed_limit_ms * CS.maxdrivespeed / CS.baseMapSpeedLimitMPS, speed_limit_ms) - sl1 = self.maxsuggestedspeed_avg.add(sl1) - else: - sl1 = self.maxsuggestedspeed_avg.add(CS.maxdrivespeed) - return min(pedal_set_speed_ms, sl1) - else: - return pedal_set_speed_ms - - def reset(self, v_pid): - if self.LoC: - self.LoC.reset(v_pid) - - def update_stat(self, CS, enabled): - if not self.LoC: - self.LoC = LongControl(CS.CP, tesla_compute_gb) - - can_sends = [] - if CS.pedal_interceptor_available and not CS.cstm_btns.get_button_status("pedal"): - # pedal hardware, enable button - CS.cstm_btns.set_button_status("pedal", 1) - print "enabling pedal" - elif not CS.pedal_interceptor_available: - if CS.cstm_btns.get_button_status("pedal"): - # no pedal hardware, disable button - CS.cstm_btns.set_button_status("pedal", 0) - print "disabling pedal" - print "Pedal unavailable." - return can_sends - - # check if we had error before - if self.pedal_interceptor_state != CS.pedal_interceptor_state: - self.pedal_interceptor_state = CS.pedal_interceptor_state - CS.cstm_btns.set_button_status("pedal", 1 if self.pedal_interceptor_state > 0 else 0) - if self.pedal_interceptor_state > 0: - # send reset command - idx = self.pedal_idx - self.pedal_idx = (self.pedal_idx + 1) % 16 - can_sends.append(teslacan.create_pedal_command_msg(0, 0, idx)) - CS.UE.custom_alert_message(3, "Pedal Interceptor Off (state %s)" % self.pedal_interceptor_state, 150, 3) - else: - CS.UE.custom_alert_message(3, "Pedal Interceptor On", 150, 3) - # disable on brake - if CS.brake_pressed and self.enable_pedal_cruise: - self.enable_pedal_cruise = False - self.reset(0.) - CS.UE.custom_alert_message(3, "PDL Disabled", 150, 4) - CS.cstm_btns.set_button_status("pedal", 1) - print "brake pressed" - - prev_enable_pedal_cruise = self.enable_pedal_cruise - # process any stalk movement - curr_time_ms = _current_time_millis() - speed_uom_kph = 1. - if CS.imperial_speed_units: - speed_uom_kph = CV.MPH_TO_KPH - if (CS.cruise_buttons == CruiseButtons.MAIN and - self.prev_cruise_buttons != CruiseButtons.MAIN): - self.prev_stalk_pull_time_ms = self.stalk_pull_time_ms - self.stalk_pull_time_ms = curr_time_ms - double_pull = self.stalk_pull_time_ms - self.prev_stalk_pull_time_ms < STALK_DOUBLE_PULL_MS - ready = (CS.cstm_btns.get_button_status("pedal") > PCCState.OFF - and enabled - and (CruiseState.is_off(CS.pcm_acc_status)) or CS.forcePedalOverCC) - if ready and double_pull: - # A double pull enables ACC. updating the max ACC speed if necessary. - self.enable_pedal_cruise = True - self.LoC.reset(CS.v_ego) - # Increase PCC speed to match current, if applicable. - self.pedal_speed_kph = max(CS.v_ego * CV.MS_TO_KPH, self.speed_limit_kph) - # Handle pressing the cancel button. - elif CS.cruise_buttons == CruiseButtons.CANCEL: - self.enable_pedal_cruise = False - self.pedal_speed_kph = 0. - self.stalk_pull_time_ms = 0 - self.prev_stalk_pull_time_ms = -1000 - # Handle pressing up and down buttons. - elif (self.enable_pedal_cruise - and CS.cruise_buttons != self.prev_cruise_buttons): - # Real stalk command while PCC is already enabled. Adjust the max PCC - # speed if necessary. - actual_speed_kph = CS.v_ego * CV.MS_TO_KPH - if CS.cruise_buttons == CruiseButtons.RES_ACCEL: - self.pedal_speed_kph = max(self.pedal_speed_kph, actual_speed_kph) + speed_uom_kph - elif CS.cruise_buttons == CruiseButtons.RES_ACCEL_2ND: - self.pedal_speed_kph = max(self.pedal_speed_kph, actual_speed_kph) + 5 * speed_uom_kph - elif CS.cruise_buttons == CruiseButtons.DECEL_SET: - self.pedal_speed_kph = min(self.pedal_speed_kph, actual_speed_kph) - speed_uom_kph - elif CS.cruise_buttons == CruiseButtons.DECEL_2ND: - self.pedal_speed_kph = min(self.pedal_speed_kph, actual_speed_kph) - 5 * speed_uom_kph - # Clip PCC speed between 0 and 170 KPH. - self.pedal_speed_kph = clip(self.pedal_speed_kph, MIN_PCC_V_KPH, MAX_PCC_V_KPH) - # If something disabled cruise control, disable PCC too - elif self.enable_pedal_cruise and CS.pcm_acc_status and not CS.forcePedalOverCC: - self.enable_pedal_cruise = False - # A single pull disables PCC (falling back to just steering). Wait some time - # in case a double pull comes along. - elif (self.enable_pedal_cruise - and curr_time_ms - self.stalk_pull_time_ms > STALK_DOUBLE_PULL_MS - and self.stalk_pull_time_ms - self.prev_stalk_pull_time_ms > STALK_DOUBLE_PULL_MS): - self.enable_pedal_cruise = False - - # Notify if PCC was toggled - if prev_enable_pedal_cruise and not self.enable_pedal_cruise: - CS.UE.custom_alert_message(3, "PCC Disabled", 150, 4) - CS.cstm_btns.set_button_status("pedal", PCCState.STANDBY) - elif self.enable_pedal_cruise and not prev_enable_pedal_cruise: - CS.UE.custom_alert_message(2, "PCC Enabled", 150) - CS.cstm_btns.set_button_status("pedal", PCCState.ENABLED) - - # Update the UI to show whether the current car state allows PCC. - if CS.cstm_btns.get_button_status("pedal") in [PCCState.STANDBY, PCCState.NOT_READY]: - if enabled and (CruiseState.is_off(CS.pcm_acc_status) or CS.forcePedalOverCC): - CS.cstm_btns.set_button_status("pedal", PCCState.STANDBY) - else: - CS.cstm_btns.set_button_status("pedal", PCCState.NOT_READY) - - # Update prev state after all other actions. - self.prev_cruise_buttons = CS.cruise_buttons - self.prev_pcm_acc_status = CS.pcm_acc_status - - return can_sends - - def update_pdl(self, enabled, CS, frame, actuators, pcm_speed, speed_limit_ms, speed_limit_valid, set_speed_limit_active, speed_limit_offset,alca_enabled): - cur_time = sec_since_boot() - idx = self.pedal_idx - - self.prev_speed_limit_kph = self.speed_limit_kph - - if speed_limit_valid and set_speed_limit_active and (speed_limit_ms > 2.7): - self.speed_limit_kph = (speed_limit_ms + speed_limit_offset) * CV.MS_TO_KPH - if not (int(self.prev_speed_limit_kph) == int(self.speed_limit_kph)): - self.pedal_speed_kph = self.speed_limit_kph - #also reset maxsuggestedspeed_avg - self.maxsuggestedspeed_avg.reset() - self.pedal_idx = (self.pedal_idx + 1) % 16 - - if not CS.pedal_interceptor_available or not enabled: - return 0., 0, idx - # Alternative speed decision logic that uses the lead car's distance - # and speed more directly. - # Bring in the lead car distance from the radarState feed - radSt = None - mapd = None - #if enabled: do it always - for socket, _ in self.poller.poll(0): - if socket is self.radarState: - radSt = messaging.recv_one(socket) - elif socket is self.live_map_data: - mapd = messaging.recv_one(socket) - if radSt is not None: - self.lead_1 = radSt.radarState.leadOne - if _is_present(self.lead_1): - self.lead_last_seen_time_ms = _current_time_millis() - self.continuous_lead_sightings += 1 - else: - self.continuous_lead_sightings = 0 - - - v_ego = CS.v_ego - following = self.lead_1.status and self.lead_1.dRel < MAX_RADAR_DISTANCE and self.lead_1.vLeadK > v_ego and self.lead_1.aLeadK > 0.0 - accel_limits = [float(x) for x in calc_cruise_accel_limits(v_ego, following)] - accel_limits[1] *= _accel_limit_multiplier(CS, self.lead_1) - accel_limits[0] = _decel_limit(accel_limits[0], CS.v_ego, self.lead_1, CS, self.pedal_speed_kph) - jerk_limits = [min(-0.1, accel_limits[0]/2.), max(0.1, accel_limits[1]/2.)] # TODO: make a separate lookup for jerk tuning - #accel_limits = limit_accel_in_turns(v_ego, CS.angle_steers, accel_limits, CS.CP) - - output_gb = 0 - #################################################################### - # this mode (Follow) uses the Follow logic created by JJ for ACC - # - # once the speed is detected we have to use our own PID to determine - # how much accel and break we have to do - #################################################################### - if PCCModes.is_selected(FollowMode(), CS.cstm_btns): - self.v_pid = self.calc_follow_speed_ms(CS,alca_enabled) - if mapd is not None: - v_curve = max_v_in_mapped_curve_ms(mapd.liveMapData, self.pedal_speed_kph) - if v_curve: - self.v_pid = min(self.v_pid, v_curve) - # now check and do the limit vs speed limit + offset - self.v_pid = self.max_v_by_speed_limit(self.v_pid ,self.pedal_speed_kph * CV.KPH_TO_MS, CS) - # cruise speed can't be negative even is user is distracted - self.v_pid = max(self.v_pid, 0.) - - enabled = self.enable_pedal_cruise and self.LoC.long_control_state in [LongCtrlState.pid, LongCtrlState.stopping] - # determine if pedal is pressed by human - self.prev_pedal_state = self.pedal_state - self.pedal_state = CS.pedal_interceptor_value > 10 - #reset PID if we just lifted foot of accelerator - if (not self.pedal_state) and self.prev_pedal_state: - self.LoC.reset(v_pid=CS.v_ego) - - if self.enable_pedal_cruise and (not self.pedal_state): - jerk_min, jerk_max = _jerk_limits(CS.v_ego, self.lead_1, self.v_pid * CV.MS_TO_KPH, self.lead_last_seen_time_ms, CS) - self.v_cruise, self.a_cruise = speed_smoother(self.v_acc_start, self.a_acc_start, - self.v_pid, - accel_limits[1], accel_limits[0], - jerk_limits[1], jerk_limits[0], #jerk_max, jerk_min, - _DT_MPC) - - # cruise speed can't be negative even is user is distracted - self.v_cruise = max(self.v_cruise, 0.) - - self.v_acc = self.v_cruise - self.a_acc = self.a_cruise - self.v_acc_future = self.v_pid - self.acc_start_time = cur_time - - # Interpolation of trajectory - self.a_acc_sol = self.a_acc_start + (_DT / _DT_MPC) * (self.a_acc - self.a_acc_start) - self.v_acc_sol = self.v_acc_start + _DT * (self.a_acc_sol + self.a_acc_start) / 2.0 - - - self.v_acc_start = self.v_acc_sol - self.a_acc_start = self.a_acc_sol - - # we will try to feed forward the pedal position.... we might want to feed the last_output_gb.... - # op feeds forward self.a_acc_sol - # it's all about testing now. - vTarget = clip(self.v_acc_sol, 0, self.v_cruise) - self.vTargetFuture = clip(self.v_acc_future, 0, self.v_pid) - feedforward = self.a_acc_sol - #feedforward = self.last_output_gb - t_go, t_brake = self.LoC.update(self.enable_pedal_cruise, CS.v_ego, CS.brake_pressed != 0, CS.standstill, False, - self.v_cruise , vTarget, self.vTargetFuture, feedforward, CS.CP) - output_gb = t_go - t_brake - #print "Output GB Follow:", output_gb - else: - self.LoC.reset(v_pid=CS.v_ego) - #print "PID reset" - output_gb = 0. - starting = self.LoC.long_control_state == LongCtrlState.starting - a_ego = min(CS.a_ego, 0.0) - reset_speed = MIN_CAN_SPEED if starting else CS.v_ego - reset_accel = CS.CP.startAccel if starting else a_ego - self.v_acc = reset_speed - self.a_acc = reset_accel - self.v_acc_start = reset_speed - self.a_acc_start = reset_accel - self.v_cruise = reset_speed - self.a_cruise = reset_accel - self.v_acc_sol = reset_speed - self.a_acc_sol = reset_accel - self.v_pid = reset_speed - - ############################################################## - # This mode uses the longitudinal MPC built in OP - # - # we use the values from actuator.accel and actuator.brake - ############################################################## - elif PCCModes.is_selected(OpMode(), CS.cstm_btns): - output_gb = actuators.gas - actuators.brake - self.v_pid = -10. - - ###################################################################################### - # Determine pedal "zero" - # - #save position for cruising (zero acc, zero brake, no torque) when we are above 10 MPH - ###################################################################################### - if (CS.torqueLevel < TORQUE_LEVEL_ACC - and CS.torqueLevel > TORQUE_LEVEL_DECEL - and CS.v_ego >= 10.* CV.MPH_TO_MS - and abs(CS.torqueLevel) < abs(self.lastTorqueForPedalForZeroTorque) - and self.prev_tesla_accel > 0.): - self.PedalForZeroTorque = self.prev_tesla_accel - self.lastTorqueForPedalForZeroTorque = CS.torqueLevel - #print "Detected new Pedal For Zero Torque at %s" % (self.PedalForZeroTorque) - #print "Torque level at detection %s" % (CS.torqueLevel) - #print "Speed level at detection %s" % (CS.v_ego * CV.MS_TO_MPH) - - self.last_output_gb = output_gb - # accel and brake - apply_accel = clip(output_gb, 0., _accel_pedal_max(CS.v_ego, self.v_pid, self.lead_1, self.prev_tesla_accel, CS)) - MPC_BRAKE_MULTIPLIER = 6. - apply_brake = -clip(output_gb * MPC_BRAKE_MULTIPLIER, _brake_pedal_min(CS.v_ego, self.v_pid, self.lead_1, CS, self.pedal_speed_kph), 0.) - - # if speed is over 5mph, the "zero" is at PedalForZeroTorque; otherwise it is zero - pedal_zero = 0. - if CS.v_ego >= 5.* CV.MPH_TO_MS: - pedal_zero = self.PedalForZeroTorque - tesla_brake = clip((1. - apply_brake) * pedal_zero, 0, pedal_zero) - tesla_accel = clip(apply_accel * (MAX_PEDAL_VALUE - pedal_zero) , 0, MAX_PEDAL_VALUE - pedal_zero) - tesla_pedal = tesla_brake + tesla_accel - - tesla_pedal = self.pedal_hysteresis(tesla_pedal, enabled) - - tesla_pedal = clip(tesla_pedal, self.prev_tesla_pedal - PEDAL_MAX_DOWN, self.prev_tesla_pedal + PEDAL_MAX_UP) - tesla_pedal = clip(tesla_pedal, 0., MAX_PEDAL_VALUE) if self.enable_pedal_cruise else 0. - enable_pedal = 1. if self.enable_pedal_cruise else 0. - - self.torqueLevel_last = CS.torqueLevel - self.prev_tesla_pedal = tesla_pedal * enable_pedal - self.prev_tesla_accel = apply_accel * enable_pedal - self.prev_v_ego = CS.v_ego - - - return self.prev_tesla_pedal, enable_pedal, idx - - # function to calculate the cruise speed based on a safe follow distance - def calc_follow_speed_ms(self, CS, alca_enabled): - # Make sure we were able to populate lead_1. - lead_dist_m = 0. - if self.lead_1 is None: - return None, None, None - # dRel is in meters. - if CS.useTeslaRadar: - lead_dist_m = self.lead_1.dRel - else: - lead_dist_m = _visual_radar_adjusted_dist_m(self.lead_1.dRel, CS) - # Grab the relative speed. - rel_speed_kph = 0. - #if self.had_lead: - #avoid inital break when lead just detected - self.vRel = 0. - self.aRel = 0. - if abs(self.lead_1.vRel) > .5: - self.vRel = self.lead_1.vRel - if abs(self.lead_1.aRel) > .5: - self.aRel = self.lead_1.aRel - rel_speed_kph = (self.vRel + 0 * CS.apFollowTimeInS * self.aRel) * CV.MS_TO_KPH - # v_ego is in m/s, so safe_distance is in meters. - safe_dist_m = _safe_distance_m(CS.v_ego,CS) - # Current speed in kph - actual_speed_kph = CS.v_ego * CV.MS_TO_KPH - # speed and brake to issue - new_speed_kph = self.last_speed_kph - ### Logic to determine best cruise speed ### - if self.enable_pedal_cruise: - # If no lead is present, accel up to max speed - if lead_dist_m == 0 or lead_dist_m > MAX_RADAR_DISTANCE: - new_speed_kph = self.pedal_speed_kph - self.had_lead = False - elif lead_dist_m > 0: - self.had_lead = True - #BB Use the Kalman lead speed and acceleration - lead_absolute_speed_kph = actual_speed_kph + rel_speed_kph #(self.lead_1.vLeadK + _DT * self.lead_1.aLeadK) * CV.MS_TO_KPH - rel_speed_kph = lead_absolute_speed_kph - actual_speed_kph - if lead_dist_m < MIN_SAFE_DIST_M and rel_speed_kph >= 3: - # If lead is going faster, but we're not at a safe distance, hold - # speed and let the lead car move father away from us - new_speed_kph = actual_speed_kph - # If lead is not going faster than 3kpm from us, lets slow down a - # bit to get him moving faster relative to us - elif lead_dist_m < MIN_SAFE_DIST_M: - new_speed_kph = MIN_PCC_V_KPH - # In a 10 meter cruise zone, lets match the car in front - elif lead_dist_m > MIN_SAFE_DIST_M and lead_dist_m < safe_dist_m + 2: # BB we might want to try this and rel_speed_kph > 0: - min_vrel_kph_map = OrderedDict([ - # (distance in m, min allowed relative kph) - (0.5 * safe_dist_m, 3.0), - (0.8 * safe_dist_m, 2.0), - (1.0 * safe_dist_m, 0.0)]) - min_vrel_kph = _interp_map(lead_dist_m, min_vrel_kph_map) - new_speed_kph = lead_absolute_speed_kph - min_vrel_kph - else: - # Force speed into a band that is generally slower than lead if too - # close, and faster than lead if too far. Allow a range of speeds at - # any given distance, to prevent continuous jerky adjustments. - # BB band should be % of v_ego - min_vrel_kph_map = OrderedDict([ - # (distance in m, min allowed relative kph) - (0.5 * safe_dist_m, 3), - (1.0 * safe_dist_m, -1 - 0.025 * CS.v_ego * CV.MS_TO_KPH), - (1.5 * safe_dist_m, -5 - 0.05 * CS.v_ego * CV.MS_TO_KPH), - (3.0 * safe_dist_m, -10 - 0.1 * CS.v_ego * CV.MS_TO_KPH)]) - min_vrel_kph = _interp_map(lead_dist_m, min_vrel_kph_map) - max_vrel_kph_map = OrderedDict([ - # (distance in m, max allowed relative kph) - (0.5 * safe_dist_m, 6), - (1.0 * safe_dist_m, 2), - (1.5 * safe_dist_m, -3), - # With visual radar the relative velocity is 0 until the confidence - # gets high. So even a small negative number here gives constant - # accel until lead lead car gets close enough to read. - (3 * safe_dist_m, -7)]) - max_vrel_kph = _interp_map(lead_dist_m, max_vrel_kph_map) - #if CS.useTeslaRadar: - # min_vrel_kph = -1 - # max_vrel_kph = -2 - min_kph = lead_absolute_speed_kph - max_vrel_kph - max_kph = lead_absolute_speed_kph - min_vrel_kph - # In the special case were we are going faster than intended but it's - # still an acceptable speed, accept it. This could happen if the - # driver manually accelerates, or if we roll down a hill. In either - # case, don't fight the extra velocity unless necessary. - if lead_dist_m >= 0.8 * safe_dist_m and lead_absolute_speed_kph > actual_speed_kph and self.lead_1.aLeadK >= 0.: - new_speed_kph = lead_absolute_speed_kph - new_speed_kph = clip(new_speed_kph, min_kph, max_kph) - if (actual_speed_kph > new_speed_kph) and (min_kph < actual_speed_kph < max_kph) and (lead_absolute_speed_kph > 30): - new_speed_kph = actual_speed_kph - #BB disabled this condition as it might not allow fast enough braking - #if (actual_speed_kph > 80) and abs(actual_speed_kph - new_speed_kph) < 3.: - # new_speed_kph = (actual_speed_kph + new_speed_kph)/2.0 - # Enforce limits on speed in the presence of a lead car. - new_speed_kph = min(new_speed_kph, - _max_safe_speed_kph(self.lead_1,CS), - max(lead_absolute_speed_kph - _min_safe_vrel_kph(self.lead_1,CS,actual_speed_kph),2)) - # Enforce limits on speed - new_speed_kph = clip(new_speed_kph, MIN_PCC_V_KPH, MAX_PCC_V_KPH) - new_speed_kph = clip(new_speed_kph, MIN_PCC_V_KPH, self.pedal_speed_kph) - if CS.blinker_on or (abs(CS.angle_steers) > ANGLE_STOP_ACCEL) or alca_enabled: - # Don't accelerate during manual turns, curves or ALCA. - new_speed_kph = min(new_speed_kph, self.last_speed_kph) - #BB Last safety check. Zero if below MIN_SAFE_DIST_M - if (lead_dist_m > 0) and (lead_dist_m < MIN_SAFE_DIST_M) and (rel_speed_kph < 3.): - new_speed_kph = MIN_PCC_V_KPH - self.last_speed_kph = new_speed_kph - return new_speed_kph * CV.KPH_TO_MS - - def pedal_hysteresis(self, pedal, enabled): - # for small accel oscillations within PEDAL_HYST_GAP, don't change the command - if not enabled: - # send 0 when disabled, otherwise acc faults - self.pedal_steady = 0. - elif pedal > self.pedal_steady + PEDAL_HYST_GAP: - self.pedal_steady = pedal - PEDAL_HYST_GAP - elif pedal < self.pedal_steady - PEDAL_HYST_GAP: - self.pedal_steady = pedal + PEDAL_HYST_GAP - return self.pedal_steady - -def _visual_radar_adjusted_dist_m(m, CS): - # visual radar sucks at short distances. It rarely shows readings below 7m. - # So rescale distances with 7m -> 0m. Maxes out at 1km, if that matters. - mapping = OrderedDict([ - # (input distance, output distance) - (7, 0), # anything below 7m is set to 0m. - (1000, 1000)]) # values >7m are scaled, maxing out at 1km. - return _interp_map(m, mapping) - -def _safe_distance_m(v_ego_ms, CS): - return max(CS.apFollowTimeInS * (v_ego_ms+1), MIN_SAFE_DIST_M) - -def _max_safe_speed_kph(lead,CS): - if _is_present(lead): - return (CS.v_ego + lead.vRel + (lead.dRel - _safe_distance_m(CS.v_ego,CS))/CS.apFollowTimeInS) * CV.MS_TO_KPH - else: - return 150. - -def _min_safe_vrel_kph(lead,CS,actual_speed_kph): - m = lead.dRel - #BB if lead accelerating do not use this for limit, we have other conditions - if lead.vLeadK * CV.MS_TO_KPH > actual_speed_kph: - return -100 - min_vrel_by_distance = OrderedDict([ - # (meters, safe relative velocity in kph) - # Remember, a negative relative velocity means we are closing the distance. - (MIN_SAFE_DIST_M, 2), # If lead is close, it better be pulling away. - (100, -25), - (1000, -50)]) # if lead is far, it's ok if we're closing. - return _interp_map(m, min_vrel_by_distance) - -def _is_present(lead): - return bool((not (lead is None)) and (lead.dRel > 0)) - -def _sec_til_collision(lead, CS): - if _is_present(lead) and lead.vRel < 0: - if CS.useTeslaRadar: - #BB: take in consideration acceleration when looking at time to collision. - return min(0.1,-4+lead.dRel / abs(lead.vRel + min(0,lead.aRel) * CS.apFollowTimeInS)) - else: - return _visual_radar_adjusted_dist_m(lead.dRel, CS) / abs(lead.vRel + min(0,lead.aRel) * CS.apFollowTimeInS) - else: - return 60. # Arbitrary, but better than MAXINT because we can still do math on it. - -def _interp_map(val, val_map): - """Helper to call interp with an OrderedDict for the mapping. I find - this easier to read than interp, which takes two arrays.""" - return interp(val, val_map.keys(), val_map.values()) - -def _accel_limit_multiplier(CS, lead): - """Limits acceleration in the presence of a lead car. The further the lead car - is, the more accel is allowed. Range: 0 to 1, so that it can be multiplied - with other accel limits.""" - accel_by_speed = OrderedDict([ - # (speed m/s, decel) - (0., 2.5), # 0 MPH - (10., 1.5), # 22 MPH - (20., 1.2), # 45 MPH - (30., 0.7)]) # 67 MPH - if CS.teslaModel in ["SP","SPD"]: - accel_by_speed = OrderedDict([ - # (speed m/s, decel) - (0., 0.95), # 0 kmh - (10., 0.8), # 35 kmh - (20., 0.6), # 72 kmh - (30., 0.7)]) # 107 kmh - accel_mult = _interp_map(CS.v_ego, accel_by_speed) - if _is_present(lead): - safe_dist_m = _safe_distance_m(CS.v_ego,CS) - accel_multipliers = OrderedDict([ - # (distance in m, acceleration fraction) - (0.6 * safe_dist_m, 0.15), - (1.0 * safe_dist_m, 0.2), - (3.0 * safe_dist_m, 0.4)]) - vrel_multipliers = OrderedDict([ - # vrel m/s, accel mult - (0. , 1.), - (10., 1.5)]) - - return min(accel_mult * _interp_map(lead.vRel, vrel_multipliers) * _interp_map(lead.dRel, accel_multipliers),1.0) - else: - return min(accel_mult * 0.4, 1.0) - -def _decel_limit(accel_min,v_ego, lead, CS, max_speed_kph): - max_speed_mult = 1. - safe_dist_m = _safe_distance_m(v_ego,CS) - # if above speed limit quickly decel - if v_ego * CV.MS_TO_KPH > max_speed_kph: - max_speed_mult = 2. - if _is_present(lead): - time_to_brake = max(0.1,_sec_til_collision(lead, CS)) - if 0 < lead.dRel < MIN_SAFE_DIST_M: - return -100. - elif lead.vRel >= 0.1 * v_ego and lead.aRel < 0.5 and lead.dRel <= 1.1 * safe_dist_m: - # going faster but decelerating, reduce with up to the same acceleration - return -2 + lead.aRel - elif lead.vRel <= 0.1 * v_ego and lead.aLeadK < 0.5 and lead.dRel <= 1.1 * safe_dist_m: - # going slower AND decelerating - accel_to_compensate = min(3 * lead.vRel / time_to_brake,-0.7) - return -2 + lead.aRel + accel_to_compensate - elif lead.vRel < -0.1 * v_ego and lead.dRel <= 1.1 * safe_dist_m: - return -3 + 2 * lead.vRel / time_to_brake - # if we got here, aLeadK >=0 so use the old logic - decel_map = OrderedDict([ - # (sec to collision, decel) - (0, 10.0), - (4, 1.0), - (7, 0.5), - (10, 0.3)]) - decel_speed_map = OrderedDict([ - # (m/s, decel) - (0, 10.0), - (4, 5.0), - (7, 2.50), - (10, 1.0)]) - return accel_min * max_speed_mult * _interp_map(_sec_til_collision(lead, CS), decel_map) * _interp_map(v_ego, decel_speed_map) - else: - #BB: if we don't have a lead, don't do full regen to slow down smoother - return accel_min * 0.5 * max_speed_mult - -def _accel_pedal_max(v_ego, v_target, lead, prev_tesla_accel,CS): - pedal_max = prev_tesla_accel - if _is_present(lead): - #we have lead, base on speed and distance - safe_dist_m = _safe_distance_m(CS.v_ego,CS) - v_rel = lead.vLeadK - v_ego - accel_speed_map = OrderedDict([ - # (speed m/s, decel) change in accel (0..1) per second - (0., 0.01), # 0 MPH - (1., 0.1), # 4 MPH - (5., 0.15), # 11 MPH - (30., 0.20)]) # 67 MPH - accel_distance_map = OrderedDict([ - # (distance in m, acceleration fraction) - (0.6 * safe_dist_m, 0.3), - (1.0 * safe_dist_m, 1.0), - (3.0 * safe_dist_m, 2.0)]) - pedal_max = prev_tesla_accel + _interp_map(safe_dist_m, accel_distance_map) * _interp_map(v_rel, accel_speed_map) * _DT - else: - #no lead, do just based on speed - accel_speed_map = OrderedDict([ - # (speed m/s, decel) change in accel (0..1) per second - (0., 0.25), # 0 MPH - (10., 0.15), # 22 MPH - (20., 0.12), # 45 MPH - (30., 0.10)]) # 67 MPH - pedal_max = prev_tesla_accel + _interp_map(v_ego, accel_speed_map) * _DT - return 1. #pedal_max - -def _brake_pedal_min(v_ego, v_target, lead, CS, max_speed_kph): - #if less than 7 MPH we don't have much left till 5MPH to brake, so full regen - if v_ego <= 7 * CV.MPH_TO_MS: - return -1 - # if above speed limit quickly decel - if v_ego * CV.MS_TO_KPH > max_speed_kph: - return -0.8 - speed_delta_perc = 100 * (v_ego - v_target)/v_ego - brake_perc_map = OrderedDict([ - # (perc change, decel) - (0., 0.3), - (1.5, 0.5), - (5., 0.8), - (7., 1.0), - (50., 1.0)]) - brake_mult1 = _interp_map(speed_delta_perc, brake_perc_map) - brake_mult2 = 0. - if _is_present(lead): - safe_dist_m = _safe_distance_m(CS.v_ego,CS) - brake_distance_map = OrderedDict([ - # (distance in m, decceleration fraction) - (0.8 * safe_dist_m, 1.), - (1.0 * safe_dist_m, .6), - (3.0 * safe_dist_m, .4)]) - brake_mult2 = _interp_map(lead.dRel, brake_distance_map) - brake_mult = max(brake_mult1, brake_mult2) - return -brake_mult - -def _jerk_limits(v_ego, lead, max_speed_kph, lead_last_seen_time_ms, CS): - # Allow higher accel jerk at low speed, to get started - accel_jerk_by_speed = OrderedDict([ - # (Speed in m/s, accel jerk) - (0, 0.18), - (9, 0.10)]) - accel_jerk = _interp_map(v_ego, accel_jerk_by_speed) - - # prevent high accel jerk near max speed - near_max_speed_multipliers = OrderedDict([ - # (kph under max speed, accel jerk multiplier) - (0, 0.01), - (4, 1.0)]) - near_max_speed_multiplier = _interp_map(max_speed_kph - v_ego * CV.MS_TO_KPH, near_max_speed_multipliers) - accel_jerk *= near_max_speed_multiplier - - if _is_present(lead): - # pick decel jerk based on how much time we have til collision - decel_jerk_map = OrderedDict([ - # (sec to collision, decel jerk) - (0, -1.00), - (2, -0.25), - (4, -0.01), - (80, -0.001)]) - decel_jerk = _interp_map(_sec_til_collision(lead, CS), decel_jerk_map) - safe_dist_m = _safe_distance_m(v_ego,CS) - distance_multipliers = OrderedDict([ - # (distance in m, accel jerk) - (0.8 * safe_dist_m, 0.01), - (2.8 * safe_dist_m, 1.00)]) - distance_multiplier = _interp_map(lead.dRel, distance_multipliers) - accel_jerk *= distance_multiplier - return decel_jerk, accel_jerk - else: - # In the absence of a lead car - decel_jerk = -0.15 - # Limit accel jerk if the lead was only recently lost, to prevent - # bucking as a lead is intermittently detected. - time_since_lead_seen_ms = _current_time_millis() - lead_last_seen_time_ms - time_since_lead_seen_multipliers = OrderedDict([ - # (ms since last lead sighting, accel jerk multiplier) - (0, 0.1), - (2000, 1.0)]) - time_since_lead_seen_multiplier = _interp_map(time_since_lead_seen_ms, time_since_lead_seen_multipliers) - accel_jerk *= time_since_lead_seen_multiplier - - return decel_jerk, accel_jerk +#!/usr/bin/env python +from selfdrive.car.tesla import teslacan +from selfdrive.car.tesla.speed_utils.fleet_speed import FleetSpeed +from selfdrive.controls.lib.longcontrol import LongControl, LongCtrlState +from common.numpy_fast import clip, interp +from selfdrive.car.tesla.values import CruiseState, CruiseButtons +from selfdrive.config import Conversions as CV +from selfdrive.controls.lib.speed_smoother import speed_smoother +from selfdrive.controls.lib.planner import calc_cruise_accel_limits, limit_accel_in_turns +from cereal import car +import cereal.messaging as messaging +import time +import math +from collections import OrderedDict +from common.params import Params +import json + +_DT = 0.05 # 10Hz in our case, since we don't want to process more than once the same radarState message +_DT_MPC = _DT + +#Reset the PID completely on disengage of PCC +RESET_PID_ON_DISENGAGE = False + +# TODO: these should end up in values.py at some point, probably variable by trim +# Accel limits +MAX_RADAR_DISTANCE = 120. #max distance to take in consideration radar reading +MAX_PEDAL_VALUE = 112. +PEDAL_HYST_GAP = 1.0 # don't change pedal command for small oscilalitons within this value +# Cap the pedal to go from 0 to max in 2 seconds +PEDAL_MAX_UP = MAX_PEDAL_VALUE * _DT / 2 +# Cap the pedal to go from max to 0 in 0.4 seconds +PEDAL_MAX_DOWN = MAX_PEDAL_VALUE * _DT / 0.4 + +# min safe distance in meters. Roughly 2 car lengths. +MIN_SAFE_DIST_M = 6. + +#BBTODO: move the vehicle variables; maybe make them speed variable +TORQUE_LEVEL_ACC = 0. +TORQUE_LEVEL_DECEL = -30. + +MIN_PCC_V_KPH = 0. # +MAX_PCC_V_KPH = 270. + +ANGLE_STOP_ACCEL = 10. #this should be speed dependent + +MIN_CAN_SPEED = 0.3 #TODO: parametrize this in car interface + +# Pull the cruise stalk twice in this many ms for a 'double pull' +STALK_DOUBLE_PULL_MS = 750 + +V_PID_FILE = '/data/params/pidParams' + +class Mode(): + label = None + +class OpMode(Mode): + label = 'OP' + +class FollowMode(Mode): + label = 'FOLLOW' + +class PCCModes(): + _all_modes = [OpMode(), FollowMode()] + _mode_map = {mode.label : mode for mode in _all_modes} + BUTTON_NAME = 'pedal' + BUTTON_ABREVIATION = 'PCC' + + @classmethod + def from_label(cls, label): + return cls._mode_map.get(label, OpMode()) + + @classmethod + def from_buttons(cls, cstm_btns): + return cls.from_label(cstm_btns.get_button_label2(cls.BUTTON_NAME)) + + @classmethod + def is_selected(cls, mode, cstm_butns): + """Tell if the UI buttons are set to the given mode""" + button_mode = cls.from_buttons(cstm_butns) + if not (isinstance(mode, Mode) and isinstance(button_mode, Mode)): + return False + return mode.label == button_mode.label + + @classmethod + def labels(cls): + return [mode.label for mode in cls._all_modes] + + +def tesla_compute_gb(accel, speed): + return float(accel) / 3. + + +def max_v_in_mapped_curve_ms(map_data, pedal_set_speed_kph): + """Use HD map data to limit speed in sharper turns.""" + if map_data and map_data.curvatureValid: + pedal_set_speed_ms = pedal_set_speed_kph * CV.KPH_TO_MS + # Max lateral acceleration, used to caclulate how much to slow down in turns + a_y_max = 1.85 # m/s^2 + curvature = abs(map_data.curvature) + v_curvature_ms = math.sqrt(a_y_max / max(1e-4, curvature)) + time_to_turn_s = max(0, map_data.distToTurn / max(pedal_set_speed_ms, 1.)) + v_approaching_turn_ms = OrderedDict([ + # seconds til turn, max allowed velocity + (0, pedal_set_speed_ms), + (8, v_curvature_ms) + ]) + return _interp_map(time_to_turn_s, v_approaching_turn_ms) + else: + return None + + + +class PCCState(): + # Possible state of the PCC system, following the DI_cruiseState naming scheme. + OFF = 0 # Disabled by UI (effectively never happens since button switches over to ACC mode). + STANDBY = 1 # Ready to be engaged. + ENABLED = 2 # Engaged. + NOT_READY = 9 # Not ready to be engaged due to the state of the car. + + +def _current_time_millis(): + return int(round(time.time() * 1000)) + + +#this is for the pedal cruise control +class PCCController(): + def __init__(self,carcontroller): + self.CC = carcontroller + self.human_cruise_action_time = 0 + self.pcc_available = self.prev_pcc_available = False + self.pedal_timeout_frame = 0 + self.accelerator_pedal_pressed = self.prev_accelerator_pedal_pressed = False + self.automated_cruise_action_time = 0 + self.last_angle = 0. + self.radarState = messaging.sub_sock('radarState', conflate=True) + self.live_map_data = messaging.sub_sock('liveMapData', conflate=True) + self.lead_1 = None + self.last_update_time = 0 + self.enable_pedal_cruise = False + self.stalk_pull_time_ms = 0 + self.prev_stalk_pull_time_ms = -1000 + self.prev_pcm_acc_status = 0 + self.prev_cruise_buttons = CruiseButtons.IDLE + self.pedal_speed_kph = 0. + self.speed_limit_kph = 0. + self.prev_speed_limit_kph = 0. + self.pedal_idx = 0 + self.pedal_steady = 0. + self.prev_tesla_accel = 0. + self.prev_tesla_pedal = 0. + self.torqueLevel_last = 0. + self.prev_v_ego = 0. + self.PedalForZeroTorque = 18. #starting number, works on my S85 + self.lastTorqueForPedalForZeroTorque = TORQUE_LEVEL_DECEL + self.v_pid = 0. + self.a_pid = 0. + self.last_output_gb = 0. + self.last_speed_kph = None + #for smoothing the changes in speed + self.v_acc_start = 0.0 + self.a_acc_start = 0.0 + self.v_acc = 0.0 + self.v_acc_sol = 0.0 + self.v_acc_future = 0.0 + self.a_acc = 0.0 + self.a_acc_sol = 0.0 + self.v_cruise = 0.0 + self.a_cruise = 0.0 + #Long Control + self.LoC = None + #when was radar data last updated? + self.lead_last_seen_time_ms = 0 + self.continuous_lead_sightings = 0 + self.params = Params() + average_speed_over_x_suggestions = 6 # 0.3 seconds (20x a second) + self.fleet_speed = FleetSpeed(average_speed_over_x_suggestions) + + def load_pid(self): + try: + v_pid_json = open(V_PID_FILE) + data = json.load(v_pid_json) + if (self.LoC): + if self.LoC.pid: + self.LoC.pid.p = data['p'] + self.LoC.pid.i = data['i'] + if 'd' not in data: + self.Loc.pid.d = 0.01 + else: + self.LoC.pid.d = data['d'] + self.LoC.pid.f = data['f'] + else: + print("self.LoC not initialized!") + except : + print("file not present, creating at next reset") + + + #Helper function for saving the PCC pid constants across drives + def save_pid(self, pid): + data = {} + data['p'] = pid.p + data['i'] = pid.i + data['d'] = pid.d + data['f'] = pid.f + try: + with open(V_PID_FILE , 'w') as outfile : + json.dump(data, outfile) + except IOError: + print("PDD pid parameters could not be saved to file") + + def reset(self, v_pid): + if self.LoC and RESET_PID_ON_DISENGAGE: + self.LoC.reset(v_pid) + + def update_stat(self, CS, frame): + if not self.LoC: + self.LoC = LongControl(CS.CP, tesla_compute_gb) + # Get v_id from the stored file when initiating the LoC and reset_on_disengage==false + if (not RESET_PID_ON_DISENGAGE): + self.load_pid() + + self._update_pedal_state(CS, frame) + + can_sends = [] + if not self.pcc_available: + timed_out = frame >= self.pedal_timeout_frame + if timed_out or CS.pedal_interceptor_state > 0: + if self.prev_pcc_available: + CS.UE.custom_alert_message(4, "Pedal Interceptor %s" % ("timed out" if timed_out else "fault (state %s)" % CS.pedal_interceptor_state), 200, 4) + if frame % 50 == 0: + # send reset command + idx = self.pedal_idx + self.pedal_idx = (self.pedal_idx + 1) % 16 + pedalcan = 2 + if CS.useWithoutHarness: + pedalcan = 0 + can_sends.append(teslacan.create_pedal_command_msg(0, 0, idx, pedalcan)) + return can_sends + + prev_enable_pedal_cruise = self.enable_pedal_cruise + # disable on brake + if CS.brake_pressed and self.enable_pedal_cruise: + self.enable_pedal_cruise = False + self.reset(0.) + + # process any stalk movement + curr_time_ms = _current_time_millis() + speed_uom_kph = 1. + if CS.imperial_speed_units: + speed_uom_kph = CV.MPH_TO_KPH + if (CS.cruise_buttons == CruiseButtons.MAIN and + self.prev_cruise_buttons != CruiseButtons.MAIN): + self.prev_stalk_pull_time_ms = self.stalk_pull_time_ms + self.stalk_pull_time_ms = curr_time_ms + double_pull = self.stalk_pull_time_ms - self.prev_stalk_pull_time_ms < STALK_DOUBLE_PULL_MS + ready = (CS.cstm_btns.get_button_status(PCCModes.BUTTON_NAME) > PCCState.OFF + and (CruiseState.is_off(CS.pcm_acc_status)) or CS.forcePedalOverCC) + if ready and double_pull: + # A double pull enables ACC. updating the max ACC speed if necessary. + self.enable_pedal_cruise = True + self.reset(CS.v_ego) + # Increase PCC speed to match current, if applicable. + # We round the target speed in the user's units of measurement to avoid jumpy speed readings + current_speed_kph_uom_rounded = int(CS.v_ego * CV.MS_TO_KPH / speed_uom_kph + 0.5) * speed_uom_kph + self.pedal_speed_kph = max(current_speed_kph_uom_rounded, self.speed_limit_kph) + # Handle pressing the cancel button. + elif CS.cruise_buttons == CruiseButtons.CANCEL: + self.enable_pedal_cruise = False + self.pedal_speed_kph = 0. + self.stalk_pull_time_ms = 0 + self.prev_stalk_pull_time_ms = -1000 + # Handle pressing up and down buttons. + elif (self.enable_pedal_cruise + and CS.cruise_buttons != self.prev_cruise_buttons): + # Real stalk command while PCC is already enabled. Adjust the max PCC speed if necessary. + # We round the target speed in the user's units of measurement to avoid jumpy speed readings + actual_speed_kph_uom_rounded = int(CS.v_ego * CV.MS_TO_KPH / speed_uom_kph + 0.5) * speed_uom_kph + if CS.cruise_buttons == CruiseButtons.RES_ACCEL: + self.pedal_speed_kph = max(self.pedal_speed_kph, actual_speed_kph_uom_rounded) + speed_uom_kph + elif CS.cruise_buttons == CruiseButtons.RES_ACCEL_2ND: + self.pedal_speed_kph = max(self.pedal_speed_kph, actual_speed_kph_uom_rounded) + 5 * speed_uom_kph + elif CS.cruise_buttons == CruiseButtons.DECEL_SET: + self.pedal_speed_kph = self.pedal_speed_kph - speed_uom_kph + elif CS.cruise_buttons == CruiseButtons.DECEL_2ND: + self.pedal_speed_kph = self.pedal_speed_kph - 5 * speed_uom_kph + # Clip PCC speed between 0 and 170 KPH. + self.pedal_speed_kph = clip(self.pedal_speed_kph, MIN_PCC_V_KPH, MAX_PCC_V_KPH) + # If something disabled cruise control, disable PCC too + elif self.enable_pedal_cruise and CS.pcm_acc_status and not CS.forcePedalOverCC: + self.enable_pedal_cruise = False + # A single pull disables PCC (falling back to just steering). Wait some time + # in case a double pull comes along. + elif (self.enable_pedal_cruise + and curr_time_ms - self.stalk_pull_time_ms > STALK_DOUBLE_PULL_MS + and self.stalk_pull_time_ms - self.prev_stalk_pull_time_ms > STALK_DOUBLE_PULL_MS): + self.enable_pedal_cruise = False + + # Notify if PCC was toggled + if prev_enable_pedal_cruise and not self.enable_pedal_cruise: + CS.UE.custom_alert_message(3, "PCC Disabled", 150, 4) + CS.cstm_btns.set_button_status(PCCModes.BUTTON_NAME, PCCState.STANDBY) + self.fleet_speed.reset_averager() + #save the pid parameters to params file + self.save_pid(self.LoC.pid) + elif self.enable_pedal_cruise and not prev_enable_pedal_cruise: + CS.UE.custom_alert_message(2, "PCC Enabled", 150) + CS.cstm_btns.set_button_status(PCCModes.BUTTON_NAME, PCCState.ENABLED) + + # Update the UI to show whether the current car state allows PCC. + if CS.cstm_btns.get_button_status(PCCModes.BUTTON_NAME) in [PCCState.STANDBY, PCCState.NOT_READY]: + if CruiseState.is_off(CS.pcm_acc_status) or CS.forcePedalOverCC: + CS.cstm_btns.set_button_status(PCCModes.BUTTON_NAME, PCCState.STANDBY) + else: + CS.cstm_btns.set_button_status(PCCModes.BUTTON_NAME, PCCState.NOT_READY) + + # Update prev state after all other actions. + self.prev_cruise_buttons = CS.cruise_buttons + self.prev_pcm_acc_status = CS.pcm_acc_status + + return can_sends + + def update_pdl(self, enabled, CS, frame, actuators, pcm_speed, pcm_override, + speed_limit_ms, set_speed_limit_active, speed_limit_offset, + alca_enabled): + idx = self.pedal_idx + + self.prev_speed_limit_kph = self.speed_limit_kph + + ###################################################################################### + # Determine pedal "zero" + # + #save position for cruising (zero acc, zero brake, no torque) when we are above 10 MPH + ###################################################################################### + if (CS.torqueLevel < TORQUE_LEVEL_ACC + and CS.torqueLevel > TORQUE_LEVEL_DECEL + and CS.v_ego >= 10.* CV.MPH_TO_MS + and abs(CS.torqueLevel) < abs(self.lastTorqueForPedalForZeroTorque) + and self.prev_tesla_accel > 0.): + self.PedalForZeroTorque = self.prev_tesla_accel + self.lastTorqueForPedalForZeroTorque = CS.torqueLevel + #print ("Detected new Pedal For Zero Torque at %s" % (self.PedalForZeroTorque)) + #print ("Torque level at detection %s" % (CS.torqueLevel)) + #print ("Speed level at detection %s" % (CS.v_ego * CV.MS_TO_MPH)) + + if set_speed_limit_active and speed_limit_ms > 0: + self.speed_limit_kph = (speed_limit_ms + speed_limit_offset) * CV.MS_TO_KPH + if int(self.prev_speed_limit_kph) != int(self.speed_limit_kph): + self.pedal_speed_kph = self.speed_limit_kph + # reset MovingAverage for fleet speed when speed limit changes + self.fleet_speed.reset_averager() + else: # reset internal speed limit, so double pull doesn't set higher speed than current (e.g. after leaving the highway) + self.speed_limit_kph = 0. + self.pedal_idx = (self.pedal_idx + 1) % 16 + + if not self.pcc_available or not enabled: + return 0., 0, idx + # Alternative speed decision logic that uses the lead car's distance + # and speed more directly. + # Bring in the lead car distance from the radarState feed + radSt = messaging.recv_one_or_none(self.radarState) + mapd = messaging.recv_one_or_none(self.live_map_data) + if radSt is not None: + self.lead_1 = radSt.radarState.leadOne + if _is_present(self.lead_1): + self.lead_last_seen_time_ms = _current_time_millis() + self.continuous_lead_sightings += 1 + else: + self.continuous_lead_sightings = 0 + + + v_ego = CS.v_ego + + following = False + if self.lead_1: + following = self.lead_1.status and self.lead_1.dRel < MAX_RADAR_DISTANCE and self.lead_1.vLeadK > v_ego and self.lead_1.aLeadK > 0.0 + accel_limits = [float(x) for x in calc_cruise_accel_limits(v_ego,following,is_tesla=True)] + + + accel_limits[1] *= _accel_limit_multiplier(CS, self.lead_1) + accel_limits[0] = _decel_limit(accel_limits[0], CS.v_ego, self.lead_1, CS, self.pedal_speed_kph) + jerk_limits = [min(-0.1, accel_limits[0]/2.), max(0.1, accel_limits[1]/2.)] # TODO: make a separate lookup for jerk tuning + accel_limits = limit_accel_in_turns(v_ego, CS.angle_steers, accel_limits, CS.CP) + + output_gb = 0 + #################################################################### + # this mode (Follow) uses the Follow logic created by JJ for ACC + # + # once the speed is detected we have to use our own PID to determine + # how much accel and break we have to do + #################################################################### + if PCCModes.is_selected(FollowMode(), CS.cstm_btns): + MPC_BRAKE_MULTIPLIER = 6. + enabled = self.enable_pedal_cruise and self.LoC.long_control_state in [LongCtrlState.pid, LongCtrlState.stopping] + # determine if pedal is pressed by human + self.prev_accelerator_pedal_pressed = self.accelerator_pedal_pressed + self.accelerator_pedal_pressed = CS.pedal_interceptor_value > 5 + #reset PID if we just lifted foot of accelerator + if (not self.accelerator_pedal_pressed) and self.prev_accelerator_pedal_pressed: + self.reset(CS.v_ego) + + if self.enable_pedal_cruise and not self.accelerator_pedal_pressed: + self.v_pid = self.calc_follow_speed_ms(CS,alca_enabled) + + if mapd is not None: + v_curve = max_v_in_mapped_curve_ms(mapd.liveMapData, self.pedal_speed_kph) + if v_curve: + self.v_pid = min(self.v_pid, v_curve) + # take fleet speed into consideration + self.v_pid = min(self.v_pid, self.fleet_speed.adjust(CS, self.pedal_speed_kph * CV.KPH_TO_MS, frame)) + # cruise speed can't be negative even if user is distracted + self.v_pid = max(self.v_pid, 0.) + + self.v_cruise, self.a_cruise = speed_smoother(self.v_acc_start, self.a_acc_start, + self.v_pid, + accel_limits[1], accel_limits[0], + jerk_limits[1], jerk_limits[0], + _DT_MPC) + + # cruise speed can't be negative even is user is distracted + self.v_cruise = max(self.v_cruise, 0.) + + self.v_acc = self.v_cruise + self.a_acc = self.a_cruise + self.v_acc_future = self.v_pid + + # Interpolation of trajectory + self.a_acc_sol = self.a_acc_start + (_DT / _DT_MPC) * (self.a_acc - self.a_acc_start) + self.v_acc_sol = self.v_acc_start + _DT * (self.a_acc_sol + self.a_acc_start) / 2.0 + + + self.v_acc_start = self.v_acc_sol + self.a_acc_start = self.a_acc_sol + + # we will try to feed forward the pedal position.... we might want to feed the last_output_gb.... + # op feeds forward self.a_acc_sol + # it's all about testing now. + vTarget = clip(self.v_acc_sol, 0, self.v_cruise) + self.vTargetFuture = clip(self.v_acc_future, 0, self.v_pid) + feedforward = self.a_acc_sol + #feedforward = self.last_output_gb + + carState = car.CarState.new_message() + carState.vEgo = CS.v_ego + carState.brakePressed = CS.brake_pressed != 0 + carState.gasPressed = CS.user_gas_pressed + carState.standstill = CS.standstill + carState.cruiseState.standstill = False + t_go, t_brake = self.LoC.update( + self.enable_pedal_cruise, # active + carState, # CS + vTarget, # v_target + self.vTargetFuture, # v_target_future + feedforward, # a_target + CS.CP # CP + ) + output_gb = t_go - t_brake + #print ("Output GB Follow:", output_gb) + else: + self.reset(CS.v_ego) + #print ("PID reset") + output_gb = 0. + starting = self.LoC.long_control_state == LongCtrlState.starting + a_ego = min(CS.a_ego, 0.0) + reset_speed = MIN_CAN_SPEED if starting else CS.v_ego + reset_accel = CS.CP.startAccel if starting else a_ego + self.v_acc = reset_speed + self.a_acc = reset_accel + self.v_acc_start = reset_speed + self.a_acc_start = reset_accel + self.v_cruise = reset_speed + self.a_cruise = reset_accel + self.v_acc_sol = reset_speed + self.a_acc_sol = reset_accel + self.v_pid = reset_speed + self.last_speed_kph = None + + ############################################################## + # This mode uses the longitudinal MPC built in OP + # + # we use the values from actuator.accel and actuator.brake + ############################################################## + elif PCCModes.is_selected(OpMode(), CS.cstm_btns): + output_gb = actuators.gas - actuators.brake + self.v_pid = pcm_override + MPC_BRAKE_MULTIPLIER = 12. + + self.last_output_gb = output_gb + # accel and brake + apply_accel = clip(output_gb, 0., 1) #_accel_pedal_max(CS.v_ego, self.v_pid, self.lead_1, self.prev_tesla_accel, CS)) + apply_brake = -clip(output_gb * MPC_BRAKE_MULTIPLIER, _brake_pedal_min(CS.v_ego, self.v_pid, self.lead_1, CS, self.pedal_speed_kph), 0.) + + # if speed is over 5mph, the "zero" is at PedalForZeroTorque; otherwise it is zero + pedal_zero = 0. + if CS.v_ego >= 5.* CV.MPH_TO_MS: + pedal_zero = self.PedalForZeroTorque + tesla_brake = clip((1. - apply_brake) * pedal_zero, 0, pedal_zero) + tesla_accel = clip(apply_accel * (MAX_PEDAL_VALUE - pedal_zero) , 0, MAX_PEDAL_VALUE - pedal_zero) + tesla_pedal = tesla_brake + tesla_accel + + tesla_pedal = self.pedal_hysteresis(tesla_pedal, enabled) + + tesla_pedal = clip(tesla_pedal, self.prev_tesla_pedal - PEDAL_MAX_DOWN, self.prev_tesla_pedal + PEDAL_MAX_UP) + tesla_pedal = clip(tesla_pedal, 0., MAX_PEDAL_VALUE) if self.enable_pedal_cruise else 0. + enable_pedal = 1. if self.enable_pedal_cruise else 0. + + self.torqueLevel_last = CS.torqueLevel + self.prev_tesla_pedal = tesla_pedal * enable_pedal + self.prev_tesla_accel = apply_accel * enable_pedal + self.prev_v_ego = CS.v_ego + + + return self.prev_tesla_pedal, enable_pedal, idx + + # function to calculate the cruise speed based on a safe follow distance + def calc_follow_speed_ms(self, CS, alca_enabled): + # Make sure we were able to populate lead_1. + if self.lead_1 is None: + return None, None, None + # dRel is in meters. + lead_dist_m = self.lead_1.dRel + if not CS.useTeslaRadar: + lead_dist_m = _visual_radar_adjusted_dist_m(lead_dist_m, CS) + # Grab the relative speed. + v_rel = self.lead_1.vRel if abs(self.lead_1.vRel) > .5 else 0 + a_rel = self.lead_1.aRel if abs(self.lead_1.aRel) > .5 else 0 + rel_speed_kph = (v_rel + 0 * CS.apFollowTimeInS * a_rel) * CV.MS_TO_KPH + # v_ego is in m/s, so safe_distance is in meters. + safe_dist_m = _safe_distance_m(CS.v_ego,CS) + # Current speed in kph + actual_speed_kph = CS.v_ego * CV.MS_TO_KPH + # speed and brake to issue + if self.last_speed_kph is None: + self.last_speed_kph = actual_speed_kph + new_speed_kph = self.last_speed_kph + ### Logic to determine best cruise speed ### + if self.enable_pedal_cruise: + # If no lead is present, accel up to max speed + if lead_dist_m == 0 or lead_dist_m > MAX_RADAR_DISTANCE: + new_speed_kph = self.pedal_speed_kph + elif lead_dist_m > 0: + #BB Use the Kalman lead speed and acceleration + lead_absolute_speed_kph = actual_speed_kph + rel_speed_kph #(self.lead_1.vLeadK + _DT * self.lead_1.aLeadK) * CV.MS_TO_KPH + rel_speed_kph = lead_absolute_speed_kph - actual_speed_kph + if lead_dist_m < MIN_SAFE_DIST_M and rel_speed_kph >= 3: + # If lead is going faster, but we're not at a safe distance, hold + # speed and let the lead car move father away from us + new_speed_kph = actual_speed_kph + # If lead is not going faster than 3kpm from us, lets slow down a + # bit to get him moving faster relative to us + elif lead_dist_m < MIN_SAFE_DIST_M: + new_speed_kph = MIN_PCC_V_KPH + # In a 10 meter cruise zone, lets match the car in front + elif safe_dist_m + 2 > lead_dist_m > MIN_SAFE_DIST_M: # BB we might want to try this and rel_speed_kph > 0: + min_vrel_kph_map = OrderedDict([ + # (distance in m, min allowed relative kph) + (0.5 * safe_dist_m, 3.0), + (0.8 * safe_dist_m, 2.0), + (1.0 * safe_dist_m, 0.0)]) + min_vrel_kph = _interp_map(lead_dist_m, min_vrel_kph_map) + new_speed_kph = lead_absolute_speed_kph - min_vrel_kph + else: + # Force speed into a band that is generally slower than lead if too + # close, and faster than lead if too far. Allow a range of speeds at + # any given distance, to prevent continuous jerky adjustments. + # BB band should be % of v_ego + min_vrel_kph_map = OrderedDict([ + # (distance in m, min allowed relative kph) + (0.5 * safe_dist_m, 3), + (1.0 * safe_dist_m, -1 - 0.025 * CS.v_ego * CV.MS_TO_KPH), + (1.5 * safe_dist_m, -5 - 0.05 * CS.v_ego * CV.MS_TO_KPH), + (3.0 * safe_dist_m, -10 - 0.1 * CS.v_ego * CV.MS_TO_KPH)]) + min_vrel_kph = _interp_map(lead_dist_m, min_vrel_kph_map) + max_vrel_kph_map = OrderedDict([ + # (distance in m, max allowed relative kph) + (0.5 * safe_dist_m, 6), + (1.0 * safe_dist_m, 2), + (1.5 * safe_dist_m, -3), + # With visual radar the relative velocity is 0 until the confidence + # gets high. So even a small negative number here gives constant + # accel until lead lead car gets close enough to read. + (3 * safe_dist_m, -7)]) + max_vrel_kph = _interp_map(lead_dist_m, max_vrel_kph_map) + #if CS.useTeslaRadar: + # min_vrel_kph = -1 + # max_vrel_kph = -2 + min_kph = lead_absolute_speed_kph - max_vrel_kph + max_kph = lead_absolute_speed_kph - min_vrel_kph + # In the special case were we are going faster than intended but it's + # still an acceptable speed, accept it. This could happen if the + # driver manually accelerates, or if we roll down a hill. In either + # case, don't fight the extra velocity unless necessary. + if lead_dist_m >= 0.8 * safe_dist_m and lead_absolute_speed_kph > actual_speed_kph and self.lead_1.aLeadK >= 0.: + new_speed_kph = lead_absolute_speed_kph + new_speed_kph = clip(new_speed_kph, min_kph, max_kph) + if (actual_speed_kph > new_speed_kph) and (min_kph < actual_speed_kph < max_kph) and (lead_absolute_speed_kph > 30): + new_speed_kph = actual_speed_kph + #BB disabled this condition as it might not allow fast enough braking + #if (actual_speed_kph > 80) and abs(actual_speed_kph - new_speed_kph) < 3.: + # new_speed_kph = (actual_speed_kph + new_speed_kph)/2.0 + # Enforce limits on speed in the presence of a lead car. + new_speed_kph = min(new_speed_kph, + _max_safe_speed_kph(self.lead_1,CS), + max(lead_absolute_speed_kph - _min_safe_vrel_kph(self.lead_1,CS,actual_speed_kph),2)) + # Enforce limits on speed + new_speed_kph = clip(new_speed_kph, MIN_PCC_V_KPH, MAX_PCC_V_KPH) + new_speed_kph = clip(new_speed_kph, MIN_PCC_V_KPH, self.pedal_speed_kph) + if CS.turn_signal_blinking or (abs(CS.angle_steers) > ANGLE_STOP_ACCEL) or alca_enabled: + # Don't accelerate during manual turns, curves or ALCA. + new_speed_kph = min(new_speed_kph, self.last_speed_kph) + #BB Last safety check. Zero if below MIN_SAFE_DIST_M + if (MIN_SAFE_DIST_M > lead_dist_m > 0) and (rel_speed_kph < 3.): + new_speed_kph = MIN_PCC_V_KPH + self.last_speed_kph = new_speed_kph + return new_speed_kph * CV.KPH_TO_MS + + def pedal_hysteresis(self, pedal, enabled): + # for small accel oscillations within PEDAL_HYST_GAP, don't change the command + if not enabled: + # send 0 when disabled, otherwise acc faults + self.pedal_steady = 0. + elif pedal > self.pedal_steady + PEDAL_HYST_GAP: + self.pedal_steady = pedal - PEDAL_HYST_GAP + elif pedal < self.pedal_steady - PEDAL_HYST_GAP: + self.pedal_steady = pedal + PEDAL_HYST_GAP + return self.pedal_steady + + def _update_pedal_state(self, CS, frame): + if CS.pedal_idx != CS.prev_pedal_idx: + # time out pedal after 500ms without receiving a new CAN message from it + self.pedal_timeout_frame = frame + 50 + self.prev_pcc_available = self.pcc_available + pedal_ready = frame < self.pedal_timeout_frame and CS.pedal_interceptor_state == 0 + acc_disabled = CS.forcePedalOverCC or CruiseState.is_off(CS.pcm_acc_status) + # Mark pedal unavailable while traditional cruise is on. + self.pcc_available = pedal_ready and acc_disabled + + if self.pcc_available != self.prev_pcc_available: + CS.config_ui_buttons(self.pcc_available, pedal_ready and not acc_disabled) + + +def _visual_radar_adjusted_dist_m(m, CS): + # visual radar sucks at short distances. It rarely shows readings below 7m. + # So rescale distances with 7m -> 0m. Maxes out at 1km, if that matters. + mapping = OrderedDict([ + # (input distance, output distance) + (7, 0), # anything below 7m is set to 0m. + (1000, 1000)]) # values >7m are scaled, maxing out at 1km. + return _interp_map(m, mapping) + +def _safe_distance_m(v_ego_ms, CS): + return max(CS.apFollowTimeInS * (v_ego_ms+1), MIN_SAFE_DIST_M) + +def _max_safe_speed_kph(lead,CS): + if _is_present(lead): + return (CS.v_ego + lead.vRel + (lead.dRel - _safe_distance_m(CS.v_ego,CS))/CS.apFollowTimeInS) * CV.MS_TO_KPH + else: + return MAX_PCC_V_KPH + +def _min_safe_vrel_kph(lead,CS,actual_speed_kph): + m = lead.dRel + #BB if lead accelerating do not use this for limit, we have other conditions + if lead.vLeadK * CV.MS_TO_KPH > actual_speed_kph: + return -100 + min_vrel_by_distance = OrderedDict([ + # (meters, safe relative velocity in kph) + # Remember, a negative relative velocity means we are closing the distance. + (MIN_SAFE_DIST_M, 2), # If lead is close, it better be pulling away. + (100, -25), + (1000, -50)]) # if lead is far, it's ok if we're closing. + return _interp_map(m, min_vrel_by_distance) + +def _is_present(lead): + return bool((not (lead is None)) and (lead.dRel > 0)) + +def _sec_til_collision(lead, CS): + if _is_present(lead) and lead.vRel < 0: + if CS.useTeslaRadar: + #BB: take in consideration acceleration when looking at time to collision. + return min(0.1,-4+lead.dRel / abs(lead.vRel + min(0,lead.aRel) * CS.apFollowTimeInS)) + else: + return _visual_radar_adjusted_dist_m(lead.dRel, CS) / abs(lead.vRel + min(0,lead.aRel) * CS.apFollowTimeInS) + else: + return 60. # Arbitrary, but better than MAXINT because we can still do math on it. + +def _interp_map(val, val_map): + """Helper to call interp with an OrderedDict for the mapping. I find + this easier to read than interp, which takes two arrays.""" + return interp(val, list(val_map.keys()), list(val_map.values())) + +def _accel_limit_multiplier(CS, lead): + """Limits acceleration in the presence of a lead car. The further the lead car + is, the more accel is allowed. Range: 0 to 1, so that it can be multiplied + with other accel limits.""" + accel_by_speed = OrderedDict([ + # (speed m/s, decel) + (0., 0.95), # 0 kmh + (10., 0.95), # 35 kmh + (20., 0.925), # 72 kmh + (30., 0.875)]) # 107 kmh + if CS.teslaModel in ["SP","SPD"]: + accel_by_speed = OrderedDict([ + # (speed m/s, decel) + (0., 0.985), # 0 kmh + (10., 0.975), # 35 kmh + (20., 0.95), # 72 kmh + (30., 0.9)]) # 107 kmh + accel_mult = _interp_map(CS.v_ego, accel_by_speed) + if _is_present(lead): + safe_dist_m = _safe_distance_m(CS.v_ego,CS) + accel_multipliers = OrderedDict([ + # (distance in m, acceleration fraction) + (0.6 * safe_dist_m, 0.15), + (1.0 * safe_dist_m, 0.2), + (3.0 * safe_dist_m, 0.4)]) + vrel_multipliers = OrderedDict([ + # vrel m/s, accel mult + (0. , 1.), + (10., 1.5)]) + + return min(accel_mult * _interp_map(lead.vRel, vrel_multipliers) * _interp_map(lead.dRel, accel_multipliers),1.0) + else: + return min(accel_mult * 0.4, 1.0) + +def _decel_limit(accel_min,v_ego, lead, CS, max_speed_kph): + max_speed_mult = 1. + safe_dist_m = _safe_distance_m(v_ego,CS) + # if above speed limit quickly decel + if v_ego * CV.MS_TO_KPH > max_speed_kph: + overshot = v_ego * CV.MS_TO_KPH - max_speed_kph + if overshot >= 5: + max_speed_mult = 2. + elif overshot >= 2.: + max_speed_mult = 1.5 + if _is_present(lead): + time_to_brake = max(0.1,_sec_til_collision(lead, CS)) + if 0 < lead.dRel < MIN_SAFE_DIST_M: + return -100. + elif lead.vRel >= 0.1 * v_ego and lead.aRel < 0.5 and lead.dRel <= 1.1 * safe_dist_m: + # going faster but decelerating, reduce with up to the same acceleration + return -2 + lead.aRel + elif lead.vRel <= 0.1 * v_ego and lead.aLeadK < 0.5 and lead.dRel <= 1.1 * safe_dist_m: + # going slower AND decelerating + accel_to_compensate = min(3 * lead.vRel / time_to_brake,-0.7) + return -2 + lead.aRel + accel_to_compensate + elif lead.vRel < -0.1 * v_ego and lead.dRel <= 1.1 * safe_dist_m: + return -3 + 2 * lead.vRel / time_to_brake + # if we got here, aLeadK >=0 so use the old logic + decel_map = OrderedDict([ + # (sec to collision, decel) + (0, 10.0), + (4, 1.0), + (7, 0.5), + (10, 0.3)]) + decel_speed_map = OrderedDict([ + # (m/s, decel) + (0, 10.0), + (4, 5.0), + (7, 2.50), + (10, 1.0)]) + return accel_min * max_speed_mult * _interp_map(_sec_til_collision(lead, CS), decel_map) * _interp_map(v_ego, decel_speed_map) + else: + #BB: if we don't have a lead, don't do full regen to slow down smoother + return accel_min * 0.5 * max_speed_mult + +def _brake_pedal_min(v_ego, v_target, lead, CS, max_speed_kph): + #if less than 7 MPH we don't have much left till 5MPH to brake, so full regen + if v_ego <= 7 * CV.MPH_TO_MS: + return -1 + # if above speed limit quickly decel + if v_ego * CV.MS_TO_KPH > max_speed_kph: + return -0.8 + speed_delta_perc = 100 * (v_ego - v_target)/v_ego + brake_perc_map = OrderedDict([ + # (perc change, decel) + (0., 0.3), + (1.5, 0.5), + (5., 0.8), + (7., 1.0), + (50., 1.0)]) + brake_mult1 = _interp_map(speed_delta_perc, brake_perc_map) + brake_mult2 = 0. + if _is_present(lead): + safe_dist_m = _safe_distance_m(CS.v_ego,CS) + brake_distance_map = OrderedDict([ + # (distance in m, decceleration fraction) + (0.8 * safe_dist_m, 1.), + (1.0 * safe_dist_m, .6), + (3.0 * safe_dist_m, .4)]) + brake_mult2 = _interp_map(lead.dRel, brake_distance_map) + brake_mult = max(brake_mult1, brake_mult2) + return -brake_mult + diff --git a/selfdrive/car/tesla/blinker_module.py b/selfdrive/car/tesla/blinker_module.py new file mode 100644 index 00000000000000..f837691dc45b83 --- /dev/null +++ b/selfdrive/car/tesla/blinker_module.py @@ -0,0 +1,28 @@ +class Blinker: + + def __init__(self): + self.tap_duration_frames = 55 # stalk signal for less than 550ms means it was tapped + self.tap_direction = 0 # tap direction lasts for one frame (when it was let go) + self.blinker_on_frame_start = 0 + self.override_frame_end = 0 + self.override_direction = 0 + + def update_state(self, CS, frame): + self.tap_direction = 0 + if CS.turn_signal_stalk_state > 0 and CS.prev_turn_signal_stalk_state == 0: + if self.override_frame_end == 0: + self.blinker_on_frame_start = frame + elif CS.turn_signal_stalk_state == 0 and CS.prev_turn_signal_stalk_state > 0: # turn signal stalk just turned off + if frame - self.blinker_on_frame_start <= self.tap_duration_frames: + self.tap_direction = CS.prev_turn_signal_stalk_state + if CS.tapBlinkerExtension > 0 and self.override_frame_end == 0: + blink_duration_frames = 58 # one blink takes ~580ms + total_blinks = 3 + CS.tapBlinkerExtension # 3 blinks are minimum and controlled by the car + self.override_frame_end = self.blinker_on_frame_start + blink_duration_frames * total_blinks + self.override_direction = CS.prev_turn_signal_stalk_state + + if 0 < self.override_frame_end < frame or (self.override_direction > 0 and (CS.turn_signal_stalk_state > 0 or self.override_frame_end == 0)): + self.override_frame_end = 0 + self.override_direction = 0 + if self.blinker_on_frame_start > 0 and CS.turn_signal_stalk_state == 0 and not CS.turn_signal_blinking and self.override_frame_end == 0: + self.blinker_on_frame_start = 0 diff --git a/selfdrive/car/tesla/carcontroller.py b/selfdrive/car/tesla/carcontroller.py index 8bb6c5bd516130..eee928ee78b524 100644 --- a/selfdrive/car/tesla/carcontroller.py +++ b/selfdrive/car/tesla/carcontroller.py @@ -3,20 +3,21 @@ from common.params import Params from collections import namedtuple from common.numpy_fast import clip, interp -from common.realtime import DT_CTRL +from common import realtime from selfdrive.car.tesla import teslacan +from selfdrive.car.tesla.blinker_module import Blinker +from selfdrive.car.tesla.speed_utils.fleet_speed import FleetSpeed from selfdrive.car.tesla.values import AH, CM -from selfdrive.can.packer import CANPacker +from opendbc.can.packer import CANPacker from selfdrive.config import Conversions as CV from selfdrive.car.modules.ALCA_module import ALCAController from selfdrive.car.modules.GYRO_module import GYROController from selfdrive.car.tesla.ACC_module import ACCController from selfdrive.car.tesla.PCC_module import PCCController from selfdrive.car.tesla.HSO_module import HSOController -from selfdrive.car.tesla.movingaverage import MovingAverage -import zmq -import selfdrive.messaging as messaging -from selfdrive.services import service_list +from selfdrive.car.tesla.speed_utils.movingaverage import MovingAverage +from selfdrive.car.tesla.AHB_module import AHBController +import cereal.messaging as messaging # Steer angle limits ANGLE_MAX_BP = [0., 27., 36.] @@ -25,14 +26,10 @@ ANGLE_DELTA_BP = [0., 5., 15.] ANGLE_DELTA_V = [5., .8, .25] # windup limit ANGLE_DELTA_VU = [5., 3.5, 0.8] # unwind limit -#steering adjustment with speed -DES_ANGLE_ADJUST_FACTOR_BP = [0.,13., 44.] -DES_ANGLE_ADJUST_FACTOR = [1.0, 1.0, 1.0] - #LDW WARNING LEVELS -LDW_WARNING_1 = 1.0 -LDW_WARNING_2 = 0.9 -LDW_LANE_PROBAB = 0.3 +LDW_WARNING_1 = 0.9 +LDW_WARNING_2 = 0.5 +LDW_LANE_PROBAB = 0.2 def gen_solution(CS): fix = 0 @@ -78,8 +75,10 @@ def process_hud_alert(hud_alert): -class CarController(object): - def __init__(self, dbc_name): +class CarController(): + def __init__(self, dbc_name,CP,VM): + self.fleet_speed_state = 0 + self.cc_counter = 0 self.alcaStateData = None self.icLeadsData = None self.params = Params() @@ -90,24 +89,22 @@ def __init__(self, dbc_name): self.epas_disabled = True self.last_angle = 0. self.last_accel = 0. + self.blinker = Blinker() self.ALCA = ALCAController(self,True,True) # Enabled and SteerByAngle both True self.ACC = ACCController(self) self.PCC = PCCController(self) self.HSO = HSOController(self) self.GYRO = GYROController() + self.AHB = AHBController(self) self.sent_DAS_bootID = False - self.poller = zmq.Poller() self.speedlimit = None - self.trafficevents = messaging.sub_sock(service_list['trafficEvents'].port, conflate=True, poller=self.poller) - self.pathPlan = messaging.sub_sock(service_list['pathPlan'].port, conflate=True, poller=self.poller) - self.radarState = messaging.sub_sock(service_list['radarState'].port, conflate=True, poller=self.poller) - self.icLeads = messaging.sub_sock(service_list['uiIcLeads'].port, conflate=True, poller=self.poller) - self.icCarLR = messaging.sub_sock(service_list['uiIcCarLR'].port, conflate=True, poller=self.poller) - self.alcaState = messaging.sub_sock(service_list['alcaState'].port, conflate=True, poller=self.poller) + self.trafficevents = messaging.sub_sock('trafficEvents', conflate=True) + self.pathPlan = messaging.sub_sock('pathPlan', conflate=True) + self.radarState = messaging.sub_sock('radarState', conflate=True) + self.icLeads = messaging.sub_sock('uiIcLeads', conflate=True) + self.icCarLR = messaging.sub_sock('uiIcCarLR', conflate=True) + self.alcaState = messaging.sub_sock('alcaState', conflate=True) self.gpsLocationExternal = None - self.speedlimit_ms = 0. - self.speedlimit_valid = False - self.speedlimit_units = 0 self.opState = 0 # 0-disabled, 1-enabled, 2-disabling, 3-unavailable, 5-warning self.accPitch = 0. self.accRoll = 0. @@ -120,7 +117,7 @@ def __init__(self, dbc_name): self.gyroYaw = 0. self.set_speed_limit_active = False self.speed_limit_offset = 0. - self.speed_limit_for_cc = 0. + self.speed_limit_ms = 0. # for warnings self.warningCounter = 0 @@ -161,11 +158,8 @@ def __init__(self, dbc_name): self.curv2 = 0. self.curv3 = 0. self.visionCurvC0 = 0. - self.laneRange = 50 #max is 160m but OP has issues with precision beyond 50 - self.useZeroC0 = False - self.useMap = False - self.clipC0 = False - self.useMapOnly = False + self.laneRange = 30 #max is 160m but OP has issues with precision beyond 50 + self.laneWidth = 0. self.stopSign_visible = False @@ -196,9 +190,14 @@ def __init__(self, dbc_name): self.prev_ldwStatus = 0 self.radarVin_idx = 0 + self.LDW_ENABLE_SPEED = 16 + self.should_ldw = False + self.ldw_numb_frame_end = 0 self.isMetric = (self.params.get("IsMetric") == "1") + self.ahbLead1 = None + def reset_traffic_events(self): self.stopSign_visible = False self.stopSign_distance = 1000. @@ -270,7 +269,7 @@ def update(self, enabled, CS, frame, actuators, \ if not CS.useTeslaMapData: if self.speedlimit is None: - self.speedlimit = messaging.sub_sock(service_list['liveMapData'].port, conflate=True, poller=self.poller) + self.speedlimit = messaging.sub_sock('liveMapData', conflate=True) # *** no output if not enabled *** @@ -303,20 +302,16 @@ def update(self, enabled, CS, frame, actuators, \ 0xc1, hud_lanes, int(snd_beep), snd_chime, fcw_display, acc_alert, steer_required) if not all(isinstance(x, int) and 0 <= x < 256 for x in hud): - print "INVALID HUD", hud + print ("INVALID HUD", hud) hud = HUDData(0xc6, 255, 64, 0xc0, 209, 0x40, 0, 0, 0, 0) # **** process the car messages **** # *** compute control surfaces *** - STEER_MAX = 420 # Prevent steering while stopped MIN_STEERING_VEHICLE_VELOCITY = 0.05 # m/s vehicle_moving = (CS.v_ego >= MIN_STEERING_VEHICLE_VELOCITY) - - # Basic highway lane change logic - changing_lanes = CS.right_blinker_on or CS.left_blinker_on #upodate custom UI buttons and alerts CS.UE.update_custom_ui() @@ -327,21 +322,19 @@ def update(self, enabled, CS, frame, actuators, \ if CS.hasTeslaIcIntegration: self.set_speed_limit_active = True self.speed_limit_offset = CS.userSpeedLimitOffsetKph - self.speed_limit_for_cc = CS.userSpeedLimitKph - #print self.speed_limit_for_cc else: self.set_speed_limit_active = (self.params.get("SpeedLimitOffset") is not None) and (self.params.get("LimitSetSpeed") == "1") if self.set_speed_limit_active: self.speed_limit_offset = float(self.params.get("SpeedLimitOffset")) + if not self.isMetric: + self.speed_limit_offset = self.speed_limit_offset * CV.MPH_TO_MS else: self.speed_limit_offset = 0. - if not self.isMetric: - self.speed_limit_offset = self.speed_limit_offset * CV.MPH_TO_MS - if CS.useTeslaGPS: + if CS.useTeslaGPS and (frame % 10 == 0): if self.gpsLocationExternal is None: - self.gpsLocationExternal = messaging.pub_sock(service_list['gpsLocationExternal'].port) + self.gpsLocationExternal = messaging.pub_sock('gpsLocationExternal') sol = gen_solution(CS) - sol.logMonoTime = int(frame * DT_CTRL * 1e9) + sol.logMonoTime = int(realtime.sec_since_boot() * 1e9) self.gpsLocationExternal.send(sol.to_bytes()) #get pitch/roll/yaw every 0.1 sec @@ -351,35 +344,35 @@ def update(self, enabled, CS, frame, actuators, \ # Update statuses for custom buttons every 0.1 sec. if (frame % 10 == 0): - #self.ALCA.update_status(False) self.ALCA.update_status((CS.cstm_btns.get_button_status("alca") > 0) and ((CS.enableALCA and not CS.hasTeslaIcIntegration) or (CS.hasTeslaIcIntegration and CS.alcaEnabled))) - - pedal_can_sends = [] - - if CS.pedal_interceptor_available: - #update PCC module info - pedal_can_sends = self.PCC.update_stat(CS, True) + + self.blinker.update_state(CS, frame) + + # update PCC module info + pedal_can_sends = self.PCC.update_stat(CS, frame) + if self.PCC.pcc_available: self.ACC.enable_adaptive_cruise = False else: # Update ACC module info. self.ACC.update_stat(CS, True) self.PCC.enable_pedal_cruise = False - - # Update HSO module info. - human_control = False # update CS.v_cruise_pcm based on module selected. + speed_uom_kph = 1. + if CS.imperial_speed_units: + speed_uom_kph = CV.KPH_TO_MPH if self.ACC.enable_adaptive_cruise: - CS.v_cruise_pcm = self.ACC.acc_speed_kph + CS.v_cruise_pcm = self.ACC.acc_speed_kph * speed_uom_kph elif self.PCC.enable_pedal_cruise: - CS.v_cruise_pcm = self.PCC.pedal_speed_kph + CS.v_cruise_pcm = self.PCC.pedal_speed_kph * speed_uom_kph else: - CS.v_cruise_pcm = max(0.,CS.v_ego * CV.MS_TO_KPH +0.5) #BB try v_ego to reduce the false FCW warnings; was: vCS.v_cruise_actual - # Get the turn signal from ALCA. - turn_signal_needed, self.alca_enabled = self.ALCA.update(enabled, CS, actuators) + CS.v_cruise_pcm = max(0., CS.v_ego * CV.MS_TO_KPH) * speed_uom_kph + self.alca_enabled = self.ALCA.update(enabled, CS, actuators, self.alcaStateData, frame, self.blinker) + self.should_ldw = self._should_ldw(CS, frame) apply_angle = -actuators.steerAngle # Tesla is reversed vs OP. + # Update HSO module info. human_control = self.HSO.update_stat(self,CS, enabled, actuators, frame) - human_lane_changing = changing_lanes and not self.alca_enabled + human_lane_changing = CS.turn_signal_stalk_state > 0 and not self.alca_enabled enable_steer_control = (enabled and not human_lane_changing and not human_control @@ -393,11 +386,8 @@ def update(self, enabled, CS, frame, actuators, \ else: angle_rate_lim = interp(CS.v_ego, ANGLE_DELTA_BP, ANGLE_DELTA_VU) - des_angle_factor = interp(CS.v_ego, DES_ANGLE_ADJUST_FACTOR_BP, DES_ANGLE_ADJUST_FACTOR ) - if self.alca_enabled or not CS.enableSpeedVariableDesAngle: - des_angle_factor = 1. #BB disable limits to test 0.5.8 - # apply_angle = clip(apply_angle * des_angle_factor, self.last_angle - angle_rate_lim, self.last_angle + angle_rate_lim) + # apply_angle = clip(apply_angle , self.last_angle - angle_rate_lim, self.last_angle + angle_rate_lim) # If human control, send the steering angle as read at steering wheel. if human_control: apply_angle = CS.angle_steers @@ -417,95 +407,50 @@ def update(self, enabled, CS, frame, actuators, \ #First we emulate DAS. # DAS_longC_enabled (1),DAS_speed_override (1),DAS_apUnavailable (1), DAS_collision_warning (1), DAS_op_status (4) # DAS_speed_kph(8), - # DAS_turn_signal_request (2),DAS_forward_collision_warning (2), DAS_hands_on_state (4), + # DAS_turn_signal_request (2),DAS_forward_collision_warning (2), DAS_hands_on_state (3), # DAS_cc_state (2), DAS_usingPedal(1),DAS_alca_state (5), - # DAS_acc_speed_limit_mph (8), + # DAS_acc_speed_limit (8), # DAS_speed_limit_units(8) #send fake_das data as 0x553 - # TODO: forward collission warning + # TODO: forward collision warning - if CS.hasTeslaIcIntegration: - self.set_speed_limit_active = True - self.speed_limit_offset = CS.userSpeedLimitOffsetKph - # only change the speed limit when we have a valid vaue - if CS.userSpeedLimitKph >= 10: - self.speed_limit_for_cc = CS.userSpeedLimitKph - - if CS.useTeslaMapData: - self.speedlimit_ms = CS.speedLimitKph * CV.KPH_TO_MS - self.speedlimit_valid = True - if self.speedlimit_ms == 0: - self.speedlimit_valid = False - self.speedlimit_units = self.speedUnits(fromMetersPerSecond = self.speedlimit_ms) if frame % 10 == 0: - for socket, _ in self.poller.poll(1): - if socket is self.speedlimit and not CS.useTeslaMapData: - #get speed limit - lmd = messaging.recv_one(socket).liveMapData - self.speedlimit_ms = lmd.speedLimit - self.speedlimit_valid = lmd.speedLimitValid - self.speedlimit_units = self.speedUnits(fromMetersPerSecond = self.speedlimit_ms) - self.speed_limit_for_cc = self.speedlimit_ms * CV.MS_TO_KPH - elif socket is self.icLeads: - self.icLeadsData = tesla.ICLeads.from_bytes(socket.recv()) - elif socket is self.radarState: + speedlimitMsg = None + if self.speedlimit is not None: + speedlimitMsg = messaging.recv_one_or_none(self.speedlimit) + icLeadsMsg = self.icLeads.receive(non_blocking=True) + radarStateMsg = messaging.recv_one_or_none(self.radarState) + alcaStateMsg = self.alcaState.receive(non_blocking=True) + pathPlanMsg = messaging.recv_one_or_none(self.pathPlan) + icCarLRMsg = self.icCarLR.receive(non_blocking=True) + trafficeventsMsgs = None + if self.trafficevents is not None: + trafficeventsMsgs = messaging.recv_sock(self.trafficevents) + if CS.hasTeslaIcIntegration: + self.speed_limit_ms = CS.speed_limit_ms + if (speedlimitMsg is not None) and not CS.useTeslaMapData: + lmd = speedlimitMsg.liveMapData + self.speed_limit_ms = lmd.speedLimit if lmd.speedLimitValid else 0 + if icLeadsMsg is not None: + self.icLeadsData = tesla.ICLeads.from_bytes(icLeadsMsg) + if radarStateMsg is not None: #to show lead car on IC if self.icLeadsData is not None: - can_messages = self.showLeadCarOnICCanMessage(radarSocket = socket) + can_messages = self.showLeadCarOnICCanMessage(radarStateMsg = radarStateMsg) can_sends.extend(can_messages) - elif socket is self.alcaState: - self.alcaStateData = tesla.ALCAState.from_bytes(socket.recv()) - elif socket is self.pathPlan: + if alcaStateMsg is not None: + self.alcaStateData = tesla.ALCAState.from_bytes(alcaStateMsg) + if pathPlanMsg is not None: #to show curvature and lanes on IC if self.alcaStateData is not None: - self.handlePathPlanSocketForCurvatureOnIC(pathPlanSocket = socket, alcaStateData = self.alcaStateData,CS = CS) - elif socket is self.icCarLR: - can_messages = self.showLeftAndRightCarsOnICCanMessages(icCarLRSocket = socket) + self.handlePathPlanSocketForCurvatureOnIC(pathPlanMsg = pathPlanMsg, alcaStateData = self.alcaStateData,CS = CS) + if icCarLRMsg is not None: + can_messages = self.showLeftAndRightCarsOnICCanMessages(icCarLRMsg = tesla.ICCarsLR.from_bytes(icCarLRMsg)) can_sends.extend(can_messages) - elif socket is self.trafficevents: - can_messages = self.handleTrafficEvents(trafficEventsSocket = socket) + if trafficeventsMsgs is not None: + can_messages = self.handleTrafficEvents(trafficEventsMsgs = trafficeventsMsgs) can_sends.extend(can_messages) - if (CS.roadCurvRange > 20) and self.useMap: - if self.useZeroC0: - self.curv0 = 0. - elif self.clipC0: - self.curv0 = -clip(CS.roadCurvC0,-0.5,0.5) - #else: - # self.curv0 = -CS.roadCurvC0 - #if CS.v_ego > 9: - # self.curv1 = -CS.roadCurvC1 - #else: - # self.curv1 = 0. - self.curv2 = -CS.roadCurvC2 - self.curv3 = -CS.roadCurvC3 - self.laneRange = CS.roadCurvRange - #else: - # self.curv0 = 0. - # self.curv1 = 0. - # self.curv2 = 0. - # self.curv3 = 0. - # self.laneRange = 0 - - if (CS.csaRoadCurvRange > 2.) and self.useMap and not self.useMapOnly: - self.curv2 = -CS.csaRoadCurvC2 - self.curv3 = -CS.csaRoadCurvC3 - #if self.laneRange > 0: - # self.laneRange = min(self.laneRange,CS.csaRoadCurvRange) - #else: - self.laneRange = CS.csaRoadCurvRange - elif (CS.csaOfframpCurvRange > 2.) and self.useMap and not self.useMapOnly: - #self.curv2 = -CS.csaOfframpCurvC2 - #self.curv3 = -CS.csaOfframpCurvC3 - #self.curv0 = 0. - #self.curv1 = 0. - #if self.laneRange > 0: - # self.laneRange = min(self.laneRange,CS.csaOfframpCurvRange) - #else: - self.laneRange = CS.csaOfframpCurvRange - else: - self.laneRange = 50 - self.laneRange = int(clip(self.laneRange,0,159)) op_status = 0x02 hands_on_state = 0x00 forward_collision_warning = 0 #1 if needed @@ -515,18 +460,19 @@ def update(self, enabled, CS, frame, actuators, \ forward_collision_warning = 1 #cruise state: 0 unavailable, 1 available, 2 enabled, 3 hold cc_state = 1 - speed_limit_to_car = int(self.speedlimit_units) alca_state = 0x00 speed_override = 0 collision_warning = 0x00 - acc_speed_limit_mph = 0 speed_control_enabled = 0 accel_min = -15 accel_max = 5 acc_speed_kph = 0 + send_fake_warning = False + send_fake_msg = False if enabled: #self.opState 0-disabled, 1-enabled, 2-disabling, 3-unavailable, 5-warning + alca_state = 0x01 if self.opState == 0: op_status = 0x02 if self.opState == 1: @@ -537,13 +483,25 @@ def update(self, enabled, CS, frame, actuators, \ op_status = 0x01 if self.opState == 5: op_status = 0x03 - alca_state = 0x08 + turn_signal_needed + if self.blinker.override_direction > 0: + alca_state = 0x08 + self.blinker.override_direction + elif (self.lLine > 1) and (self.rLine > 1): + alca_state = 0x08 + elif (self.lLine > 1): + alca_state = 0x06 + elif (self.rLine > 1): + alca_state = 0x07 + else: + alca_state = 0x01 #canceled by user if self.ALCA.laneChange_cancelled and (self.ALCA.laneChange_cancelled_counter > 0): alca_state = 0x14 #min speed for ALCA - if CS.CL_MIN_V > CS.v_ego: + if (CS.CL_MIN_V > CS.v_ego): alca_state = 0x05 + #max angle for ALCA + if (abs(actuators.steerAngle) >= CS.CL_MAX_A): + alca_state = 0x15 if not enable_steer_control: #op_status = 0x08 hands_on_state = 0x02 @@ -552,9 +510,7 @@ def update(self, enabled, CS, frame, actuators, \ hands_on_state = 0x03 else: hands_on_state = 0x05 - acc_speed_limit_mph = max(self.ACC.acc_speed_kph * CV.KPH_TO_MPH,1) - if CS.pedal_interceptor_available: - acc_speed_limit_mph = max(self.PCC.pedal_speed_kph * CV.KPH_TO_MPH,1) + if self.PCC.pcc_available: acc_speed_kph = self.PCC.pedal_speed_kph if hud_alert == AH.FCW: collision_warning = hud_alert[1] @@ -565,19 +521,20 @@ def update(self, enabled, CS, frame, actuators, \ op_status = 0x08 if self.ACC.enable_adaptive_cruise: acc_speed_kph = self.ACC.new_speed #pcm_speed * CV.MS_TO_KPH - if (CS.pedal_interceptor_available and self.PCC.enable_pedal_cruise) or (self.ACC.enable_adaptive_cruise): + if (self.PCC.pcc_available and self.PCC.enable_pedal_cruise) or (self.ACC.enable_adaptive_cruise): speed_control_enabled = 1 cc_state = 2 + if not self.ACC.adaptive: + cc_state = 3 CS.speed_control_enabled = 1 else: CS.speed_control_enabled = 0 if (CS.pcm_acc_status == 4): #car CC enabled but not OP, display the HOLD message cc_state = 3 - - send_fake_msg = False - send_fake_warning = False - + else: + if (CS.pcm_acc_status == 4): + cc_state = 3 if enabled: if frame % 2 == 0: send_fake_msg = True @@ -598,29 +555,49 @@ def update(self, enabled, CS, frame, actuators, \ self.DAS_219_lcTempUnavailableSpeed = 1 self.warningCounter = 100 self.warningNeeded = 1 - if enabled and self.ALCA.laneChange_cancelled and (not CS.steer_override) and (not CS.blinker_on) and (self.ALCA.laneChange_cancelled_counter > 0): + if enabled and self.ALCA.laneChange_cancelled and (not CS.steer_override) and (CS.turn_signal_stalk_state == 0) and (self.ALCA.laneChange_cancelled_counter > 0): self.DAS_221_lcAborting = 1 self.warningCounter = 300 self.warningNeeded = 1 + if CS.hasTeslaIcIntegration: + highLowBeamStatus,highLowBeamReason,ahbIsEnabled = self.AHB.update(CS,frame,self.ahbLead1) + if frame % 5 == 0: + self.cc_counter = (self.cc_counter + 1) % 40 #use this to change status once a second + self.fleet_speed_state = 0x00 #fleet speed unavailable + if FleetSpeed.is_available(CS): + if self.ACC.fleet_speed.is_active(frame) or self.PCC.fleet_speed.is_active(frame): + self.fleet_speed_state = 0x02 #fleet speed enabled + else: + self.fleet_speed_state = 0x01 #fleet speed available + can_sends.append(teslacan.create_fake_DAS_msg2(highLowBeamStatus,highLowBeamReason,ahbIsEnabled,self.fleet_speed_state)) + if (self.cc_counter < 3) and (self.fleet_speed_state == 0x02): + CS.v_cruise_pcm = CS.v_cruise_pcm + 1 + send_fake_msg = True + if (self.cc_counter == 3): + send_fake_msg = True if send_fake_msg: if enable_steer_control and op_status == 3: op_status = 0x5 + park_brake_request = 0 #experimental; disabled for now + if park_brake_request == 1: + print("Park Brake Request received") + adaptive_cruise = 1 if (not self.PCC.pcc_available and self.ACC.adaptive) or self.PCC.pcc_available else 0 can_sends.append(teslacan.create_fake_DAS_msg(speed_control_enabled,speed_override,self.DAS_206_apUnavailable, collision_warning, op_status, \ acc_speed_kph, \ - turn_signal_needed,forward_collision_warning,hands_on_state, \ - cc_state, 1 if (CS.pedal_interceptor_available) else 0,alca_state, \ - #acc_speed_limit_mph, - CS.v_cruise_pcm * CV.KPH_TO_MPH, - speed_limit_to_car, + self.blinker.override_direction,forward_collision_warning, adaptive_cruise, hands_on_state, \ + cc_state, 1 if self.PCC.pcc_available else 0, alca_state, \ + CS.v_cruise_pcm, + CS.DAS_fusedSpeedLimit, apply_angle, - 1 if enable_steer_control else 0)) + 1 if enable_steer_control else 0, + park_brake_request)) if send_fake_warning or (self.opState == 2) or (self.opState == 5) or (self.stopSignWarning != self.stopSignWarning_last) or (self.stopLightWarning != self.stopLightWarning_last) or (self.warningNeeded == 1) or (frame % 100 == 0): #if it's time to send OR we have a warning or emergency disable can_sends.append(teslacan.create_fake_DAS_warning(self.DAS_211_accNoSeatBelt, CS.DAS_canErrors, \ self.DAS_202_noisyEnvironment, CS.DAS_doorOpen, CS.DAS_notInDrive, CS.enableDasEmulation, CS.enableRadarEmulation, \ self.stopSignWarning, self.stopLightWarning, \ self.DAS_222_accCameraBlind, self.DAS_219_lcTempUnavailableSpeed, self.DAS_220_lcTempUnavailableRoad, self.DAS_221_lcAborting, \ - self.DAS_207_lkasUnavailable,self.DAS_208_rackDetected, self.DAS_025_steeringOverride,self.ldwStatus,0,CS.useWithoutHarness)) + self.DAS_207_lkasUnavailable,self.DAS_208_rackDetected, self.DAS_025_steeringOverride,self.ldwStatus,CS.useWithoutHarness,CS.usesApillarHarness)) self.stopLightWarning_last = self.stopLightWarning self.stopSignWarning_last = self.stopSignWarning self.warningNeeded = 0 @@ -628,39 +605,52 @@ def update(self, enabled, CS, frame, actuators, \ if frame % 100 == 0: # and CS.hasTeslaIcIntegration: #IF WE HAVE softPanda RUNNING, send a message every second to say we are still awake can_sends.append(teslacan.create_fake_IC_msg()) - idx = frame % 16 - cruise_btn = None - if self.ACC.enable_adaptive_cruise and not CS.pedal_interceptor_available: + + # send enabled ethernet every 0.2 sec + if frame % 20 == 0: + can_sends.append(teslacan.create_enabled_eth_msg(1)) + if (not self.PCC.pcc_available) and frame % 5 == 0: # acc processed at 20Hz cruise_btn = self.ACC.update_acc(enabled, CS, frame, actuators, pcm_speed, \ - self.speed_limit_for_cc, self.speedlimit_valid, \ + self.speed_limit_ms * CV.MS_TO_KPH, self.set_speed_limit_active, self.speed_limit_offset) if cruise_btn: cruise_msg = teslacan.create_cruise_adjust_msg( spdCtrlLvr_stat=cruise_btn, - turnIndLvr_Stat= 0, #turn_signal_needed, + turnIndLvr_Stat= 0, real_steering_wheel_stalk=CS.steering_wheel_stalk) # Send this CAN msg first because it is racing against the real stalk. can_sends.insert(0, cruise_msg) apply_accel = 0. - if CS.pedal_interceptor_available and frame % 5 == 0: # pedal processed at 20Hz - apply_accel, accel_needed, accel_idx = self.PCC.update_pdl(enabled, CS, frame, actuators, pcm_speed, \ - self.speed_limit_for_cc * CV.KPH_TO_MS, self.speedlimit_valid, \ + if self.PCC.pcc_available and frame % 5 == 0: # pedal processed at 20Hz + pedalcan = 2 + if CS.useWithoutHarness: + pedalcan = 0 + apply_accel, accel_needed, accel_idx = self.PCC.update_pdl( + enabled, + CS, + frame, + actuators, + pcm_speed, + pcm_override, + self.speed_limit_ms, self.set_speed_limit_active, self.speed_limit_offset * CV.KPH_TO_MS, self.alca_enabled) - can_sends.append(teslacan.create_pedal_command_msg(apply_accel, int(accel_needed), accel_idx)) + can_sends.append(teslacan.create_pedal_command_msg(apply_accel, int(accel_needed), accel_idx,pedalcan)) self.last_angle = apply_angle self.last_accel = apply_accel return pedal_can_sends + can_sends #to show lead car on IC - def showLeadCarOnICCanMessage(self, radarSocket): + def showLeadCarOnICCanMessage(self, radarStateMsg): messages = [] - leads = messaging.recv_one(radarSocket).radarState + leads = radarStateMsg.radarState if leads is None: + self.ahbLead1 = None return messages lead_1 = leads.leadOne lead_2 = leads.leadTwo if (lead_1 is not None) and lead_1.status: + self.ahbLead1 = lead_1 self.leadDx = lead_1.dRel self.leadDy = self.curv0-lead_1.yRel self.leadId = self.icLeadsData.lead1trackId @@ -693,8 +683,8 @@ def showLeadCarOnICCanMessage(self, radarSocket): self.lead2Id,self.lead2Dx,self.lead2Dy,self.lead2Vx)) return messages - def handlePathPlanSocketForCurvatureOnIC(self, pathPlanSocket, alcaStateData, CS): - pp = messaging.recv_one(pathPlanSocket).pathPlan + def handlePathPlanSocketForCurvatureOnIC(self, pathPlanMsg, alcaStateData, CS): + pp = pathPlanMsg.pathPlan if pp.paramsValid: if pp.lProb > 0.75: self.lLine = 3 @@ -718,19 +708,18 @@ def handlePathPlanSocketForCurvatureOnIC(self, pathPlanSocket, alcaStateData, CS self.curv2 = -clip(pp.dPoly[1],-0.0025,0.0025) #self.curv2Matrix.add(-clip(pp.cPoly[1],-0.0025,0.0025)) self.curv3 = -clip(pp.dPoly[0],-0.00003,0.00003) #self.curv3Matrix.add(-clip(pp.cPoly[0],-0.00003,0.00003)) self.laneWidth = pp.laneWidth - self.laneRange = 50 # it is fixed in OP at 50m pp.viewRange self.visionCurvC0 = self.curv0 self.prev_ldwStatus = self.ldwStatus self.ldwStatus = 0 - if (self.ALCA.laneChange_direction != 0) and alcaStateData.alcaError: - self.ALCA.stop_ALCA(CS) - if self.alca_enabled: + if alcaStateData.alcaEnabled: #exagerate position a little during ALCA to make lane change look smoother on IC - if self.ALCA.laneChange_over_the_line: - self.curv0 = self.ALCA.laneChange_direction * self.laneWidth - self.curv0 + self.curv1 = 0.0 #straighten the turn for ALCA + self.curv0 = -self.ALCA.laneChange_direction * alcaStateData.alcaLaneWidth * alcaStateData.alcaStep / alcaStateData.alcaTotalSteps #animas late change on IC self.curv0 = clip(self.curv0, -3.5, 3.5) + self.lLine = 3 + self.rLine = 3 else: - if CS.enableLdw and (not CS.blinker_on) and (CS.v_ego > 15.6) and (not CS.steer_override): + if self.should_ldw: if pp.lProb > LDW_LANE_PROBAB: lLaneC0 = -pp.lPoly[3] if abs(lLaneC0) < LDW_WARNING_2: @@ -740,9 +729,9 @@ def handlePathPlanSocketForCurvatureOnIC(self, pathPlanSocket, alcaStateData, CS if pp.rProb > LDW_LANE_PROBAB: rLaneC0 = -pp.rPoly[3] if abs(rLaneC0) < LDW_WARNING_2: - self.ldwStatus = 3 + self.ldwStatus = 4 elif abs(rLaneC0) < LDW_WARNING_1: - self.ldwStatus = 1 + self.ldwStatus = 2 if not(self.prev_ldwStatus == self.ldwStatus): self.warningNeeded = 1 if self.ldwStatus > 0: @@ -756,9 +745,9 @@ def handlePathPlanSocketForCurvatureOnIC(self, pathPlanSocket, alcaStateData, CS self.curv3 = self.curv3Matrix.add(0.) # Generates IC messages for the Left and Right radar identified cars from radard - def showLeftAndRightCarsOnICCanMessages(self, icCarLRSocket): + def showLeftAndRightCarsOnICCanMessages(self, icCarLRMsg): messages = [] - icCarLR_msg = tesla.ICCarsLR.from_bytes(icCarLRSocket.recv()) + icCarLR_msg = icCarLRMsg if icCarLR_msg is not None: #for icCarLR_msg in icCarLR_list: messages.append(teslacan.create_DAS_LR_object_msg(1,icCarLR_msg.v1Type,icCarLR_msg.v1Id, @@ -769,10 +758,10 @@ def showLeftAndRightCarsOnICCanMessages(self, icCarLRSocket): icCarLR_msg.v4Id,icCarLR_msg.v4Dx,icCarLR_msg.v4Dy,icCarLR_msg.v4Vrel)) return messages - def handleTrafficEvents(self, trafficEventsSocket): + def handleTrafficEvents(self, trafficEventsMsgs): messages = [] self.reset_traffic_events() - tr_ev_list = messaging.recv_sock(trafficEventsSocket) + tr_ev_list = trafficEventsMsgs if tr_ev_list is not None: for tr_ev in tr_ev_list.trafficEvents: if tr_ev.type == 0x00: @@ -814,6 +803,10 @@ def handleTrafficEvents(self, trafficEventsSocket): messages.append(teslacan.create_fake_DAS_sign_msg(self.roadSignType,self.roadSignStopDist,self.roadSignColor,self.roadSignControlActive)) return messages - # Returns speed as it needs to be displayed on the IC - def speedUnits(self, fromMetersPerSecond): - return fromMetersPerSecond * (CV.MS_TO_KPH if self.isMetric else CV.MS_TO_MPH) + 0.5 + def _should_ldw(self, CS, frame): + if not CS.enableLdw: + return False + if CS.prev_turn_signal_blinking and not CS.turn_signal_blinking: + self.ldw_numb_frame_end = frame + int(100 * CS.ldwNumbPeriod) + + return CS.v_ego >= self.LDW_ENABLE_SPEED and not CS.turn_signal_blinking and frame > self.ldw_numb_frame_end diff --git a/selfdrive/car/tesla/carstate.py b/selfdrive/car/tesla/carstate.py index 51244f1104e300..b7cd5bb5448397 100644 --- a/selfdrive/car/tesla/carstate.py +++ b/selfdrive/car/tesla/carstate.py @@ -1,5 +1,5 @@ from common.kalman.simple_kalman import KF1D -from selfdrive.can.parser import CANParser +from opendbc.can.parser import CANParser from selfdrive.config import Conversions as CV from selfdrive.car.tesla.ACC_module import ACCMode from selfdrive.car.tesla.PCC_module import PCCModes @@ -7,10 +7,11 @@ from selfdrive.car.modules.UIBT_module import UIButtons from selfdrive.car.modules.UIEV_module import UIEvents from selfdrive.car.tesla.readconfig import read_config_file +from selfdrive.car.interfaces import CarStateBase import os import subprocess -from common.params import read_db, write_db - +from common.params import Params + def parse_gear_shifter(can_gear_shifter, car_fingerprint): # TODO: Use VAL from DBC to parse this field @@ -29,27 +30,15 @@ def parse_gear_shifter(can_gear_shifter, car_fingerprint): -def calc_cruise_offset(offset, speed): - # euristic formula so that speed is controlled to ~ 0.3m/s below pid_speed - # constraints to solve for _K0, _K1, _K2 are: - # - speed = 0m/s, out = -0.3 - # - speed = 34m/s, offset = 20, out = -0.25 - # - speed = 34m/s, offset = -2.5, out = -1.8 - _K0 = -0.3 - _K1 = -0.01879 - _K2 = 0.01013 - return min(_K0 + _K1 * speed + _K2 * speed * offset, 0.) - - def get_can_signals(CP): # this function generates lists for signal, messages and initial values signals = [ - ("MCU_gpsVehicleHeading", "MCU_gpsVehicleSpeed", 0), - ("MCU_gpsVehicleSpeed", "MCU_gpsVehicleSpeed", 0), - ("MCU_userSpeedOffset", "MCU_gpsVehicleSpeed", 0), - ("MCU_userSpeedOffsetUnits", "MCU_gpsVehicleSpeed", 0), - ("MCU_mppSpeedLimit", "MCU_gpsVehicleSpeed", 0), - ("MCU_mapSpeedLimitUnits", "MCU_gpsVehicleSpeed", 0), + ("UI_gpsVehicleHeading", "UI_gpsVehicleSpeed", 0), + ("UI_gpsVehicleSpeed", "UI_gpsVehicleSpeed", 0), + ("UI_userSpeedOffset", "UI_gpsVehicleSpeed", 0), + ("UI_userSpeedOffsetUnits", "UI_gpsVehicleSpeed", 0), + ("UI_mppSpeedLimit", "UI_gpsVehicleSpeed", 0), + ("UI_mapSpeedLimitUnits", "UI_gpsVehicleSpeed", 0), ("MCU_gpsAccuracy", "MCU_locationStatus", 0), ("MCU_latitude", "MCU_locationStatus", 0), ("MCU_longitude", "MCU_locationStatus", 0), @@ -59,7 +48,7 @@ def get_can_signals(CP): ("MCU_ldwEnable", "MCU_chassisControl", 0), ("MCU_aebEnable", "MCU_chassisControl", 0), ("MCU_pedalSafetyEnable", "MCU_chassisControl", 0), - #("StW_AnglHP", "STW_ANGLHP_STAT", 0), + ("MCU_ahlbEnable", "MCU_chassisControl", 0), ("DI_gear", "DI_torque2", 3), ("DI_brakePedal", "DI_torque2", 0), ("DI_vehicleSpeed", "DI_torque2", 0), @@ -67,15 +56,16 @@ def get_can_signals(CP): ("DOOR_STATE_FR", "GTW_carState", 1), ("DOOR_STATE_RL", "GTW_carState", 1), ("DOOR_STATE_RR", "GTW_carState", 1), - #("DI_stateCounter", "DI_state", 0), - #("GTW_driverPresent", "GTW_status", 0), + ("BC_indicatorLStatus", "GTW_carState", 0), + ("BC_indicatorRStatus", "GTW_carState", 0), ("DI_cruiseSet", "DI_state", 0), ("DI_cruiseState", "DI_state", 0), - #("TSL_P_Psd_StW","SBW_RQ_SCCM" , 0), - #("DI_motorRPM", "DI_torque1", 0), - #("DI_pedalPos", "DI_torque1", 0), + ("LoBm_On_Rq","BODY_R1" , 0), + ("HiBm_On", "BODY_R1", 0), + ("LgtSens_Night", "BODY_R1", 0), ("DI_torqueMotor", "DI_torque1",0), ("DI_speedUnits", "DI_state", 0), + ("DI_analogSpeed", "DI_state", 0), # Steering wheel stalk signals (useful for managing cruise control) ("SpdCtrlLvr_Stat", "STW_ACTN_RQ", 0), ("VSL_Enbl_Rq", "STW_ACTN_RQ", 0), @@ -141,32 +131,26 @@ def get_can_signals(CP): ("UI_medianFleetSpeedMPS", "UI_driverAssistRoadSign", 0), ("UI_topQrtlFleetSpeedMPS", "UI_driverAssistRoadSign", 0), ("UI_splineLocConfidence", "UI_driverAssistRoadSign", 0), + ("UI_splineID", "UI_driverAssistRoadSign", 0), ("UI_baseMapSpeedLimitMPS", "UI_driverAssistRoadSign", 0), ("UI_bottomQrtlFleetSpeedMPS", "UI_driverAssistRoadSign", 0), ("UI_rampType", "UI_driverAssistRoadSign", 0), - - + ("UI_autoSummonEnable","UI_driverAssistControl",0), ] checks = [ - #("STW_ANGLHP_STAT", 200), #JCT Actual message freq is 40 Hz (0.025 sec) ("STW_ACTN_RQ", 20), #JCT Actual message freq is 3.5 Hz (0.285 sec) - #("SBW_RQ_SCCM", 175), #JCT Actual message freq is 35 Hz (0.0286 sec) ("DI_torque1", 59), #JCT Actual message freq is 11.8 Hz (0.084 sec) ("DI_torque2", 18), #JCT Actual message freq is 3.7 Hz (0.275 sec) - #("MCU_gpsVehicleSpeed", 2), #JCT Actual message freq is 0.487 Hz (2.05 sec) ("GTW_carState", 20), #JCT Actual message freq is 3.3 Hz (0.3 sec) - #("GTW_status", 2), #JCT Actual message freq is 0.5 Hz (2 sec) ("DI_state", 7), #JCT Actual message freq is 1 Hz (1 sec) - #("MCU_locationStatus", 5), #JCT Actual message freq is 1.3 Hz (0.76 sec) ("GTW_carConfig", 7), #BB Actual message freq is 1 Hz (1 sec) ] #checks = [] return signals, checks - + def get_epas_can_signals(CP): -# this function generates lists for signal, messages and initial values signals = [ ("EPAS_torsionBarTorque", "EPAS_sysStatus", 0), # Used in interface.py ("EPAS_eacStatus", "EPAS_sysStatus", 0), @@ -174,12 +158,17 @@ def get_epas_can_signals(CP): ("EPAS_handsOnLevel", "EPAS_sysStatus", 0), ("EPAS_steeringFault", "EPAS_sysStatus", 0), ("EPAS_internalSAS", "EPAS_sysStatus", 0), #BB see if this works better than STW_ANGLHP_STAT for angle + ("SDM_bcklDrivStatus", "SDM1", 0), + ("LoBm_On_Rq","BODY_R1" , 0), + ("HiBm_On", "BODY_R1", 0), + ("LgtSens_Night", "BODY_R1", 0), ] checks = [ ("EPAS_sysStatus", 12), #JCT Actual message freq is 1.3 Hz (0.76 sec) ] + #checks = [] return signals, checks @@ -194,42 +183,30 @@ def get_pedal_can_signals(CP): checks = [] return signals, checks - -def get_can_parser(CP,mydbc): - signals, checks = get_can_signals(CP) - return CANParser(mydbc, signals, checks, 0) - -def get_epas_parser(CP,epascan): - signals, checks = get_epas_can_signals(CP) - return CANParser(DBC[CP.carFingerprint]['pt']+"_epas", signals, checks, epascan) -def get_pedal_parser(CP): - signals, checks = get_pedal_can_signals(CP) - return CANParser(DBC[CP.carFingerprint]['pt']+"_pedal", signals, checks, 2) - -class CarState(object): +class CarState(CarStateBase): def __init__(self, CP): + super().__init__(CP) + self.params = Params() self.speed_control_enabled = 0 self.CL_MIN_V = 8.9 self.CL_MAX_A = 20. # labels for buttons - self.btns_init = [["alca", "ALC", ["MadMax", "Normal", "Calm"]], + self.btns_init = [["alca", "ALC", [""]], [ACCMode.BUTTON_NAME, ACCMode.BUTTON_ABREVIATION, ACCMode.labels()], ["dsp", "DSP", ["OP","MIN","OFF","GYRO"]], ["", "", [""]], ["msg", "MSG", [""]], ["sound", "SND", [""]]] - + ### START OF MAIN CONFIG OPTIONS ### ### Do NOT modify here, modify in /data/bb_openpilot.cfg and reboot self.forcePedalOverCC = True - self.enableHSO = True + self.usesApillarHarness = False + self.enableHSO = True self.enableALCA = True self.enableDasEmulation = True self.enableRadarEmulation = True - self.enableSpeedVariableDesAngle = False - self.enableRollAngleCorrection = False - self.enableFeedForwardAngleCorrection = True self.enableDriverMonitor = True self.enableShowCar = True self.enableShowLogo = True @@ -252,7 +229,18 @@ def __init__(self, CP): self.radarEpasType = 0 self.fix1916 = False self.forceFingerprintTesla = False - self.eonToFront = 0.9 + self.spinnerText = "" + self.hsoNumbPeriod = 1.5 + self.ldwNumbPeriod = 1.5 + self.tapBlinkerExtension = 2 + self.ahbOffDuration = 5 + self.roadCameraID = "" + self.driverCameraID = "" + self.roadCameraFx = 0.73 + self.driverCameraFx = 0.75 + self.roadCameraFlip = 0 + self.driverCameraFlip = 0 + self.monitorForcedRes = "" #read config file read_config_file(self) ### END OF MAIN CONFIG OPTIONS ### @@ -265,7 +253,9 @@ def __init__(self, CP): # Tesla Model self.teslaModelDetected = 1 - self.teslaModel = read_db('/data/params','TeslaModel') + self.teslaModel = self.params.get('TeslaModel') + if self.teslaModel is not None: + self.teslaModel = self.teslaModel.decode() if self.teslaModel is None: self.teslaModel = "S" self.teslaModelDetected = 0 @@ -288,10 +278,8 @@ def __init__(self, CP): self.roadCurvC2 = 0. self.roadCurvC3 = 0. - self.speedLimitUnits = 0 - self.speedLimit = 0 - self.meanFleetSplineSpeedMPS = 0. + self.UI_splineID = 0 self.meanFleetSplineAccelMPS2 = 0. self.medianFleetSpeedMPS = 0. self.topQrtlFleetSplineSpeedMPS = 0. @@ -302,7 +290,7 @@ def __init__(self, CP): self.mapBasedSuggestedSpeed = 0. self.splineBasedSuggestedSpeed = 0. - self.maxdrivespeed = 0. + self.map_suggested_speed = 0. self.gpsLongitude = 0. self.gpsLatitude = 0. @@ -311,8 +299,9 @@ def __init__(self, CP): self.gpsHeading = 0. self.gpsVehicleSpeed = 0. - self.userSpeedLimitKph = 0. + self.speed_limit_ms = 0. self.userSpeedLimitOffsetKph = 0. + self.DAS_fusedSpeedLimit = 0 self.brake_only = CP.enableCruise self.last_cruise_stalk_pull_time = 0 @@ -320,20 +309,24 @@ def __init__(self, CP): self.user_gas = 0. self.user_gas_pressed = False - self.pedal_interceptor_state = 0 + self.pedal_interceptor_state = self.prev_pedal_interceptor_state = 0 self.pedal_interceptor_value = 0. self.pedal_interceptor_value2 = 0. - self.pedal_interceptor_missed_counter = 0 + self.pedal_idx = self.prev_pedal_idx = 0 self.brake_switch_prev = 0 self.brake_switch_ts = 0 self.cruise_buttons = 0 - self.blinker_on = 0 - self.left_blinker_on = 0 - self.right_blinker_on = 0 + self.turn_signal_state_left = 0 # 0 = off, 1 = on (blinking), 2 = failed, 3 = default + self.turn_signal_state_right = 0 # 0 = off, 1 = on (blinking), 2 = failed, 3 = default + self.prev_turn_signal_blinking = False + self.turn_signal_blinking = False + self.prev_turn_signal_stalk_state = 0 + self.turn_signal_stalk_state = 0 # 0 = off, 1 = indicate left (stalk down), 2 = indicate right (stalk up) + self.steer_warning = 0 - + self.stopped = 0 # variables used for the fake DAS creation @@ -366,13 +359,12 @@ def __init__(self, CP): self.DAS_doorOpen = 0 self.DAS_notInDrive = 0 + self.summonButton = 0 + #BB variables for pedal CC self.pedal_speed_kph = 0. - # Pedal mode is ready, i.e. hardware is present and normal cruise is off. - self.pedal_interceptor_available = False - self.prev_pedal_interceptor_available = False #BB UIEvents self.UE = UIEvents(self) @@ -389,15 +381,15 @@ def __init__(self, CP): #BB steering_wheel_stalk last position, used by ACC and ALCA self.steering_wheel_stalk = None - + #BB carConfig data used to change IC info self.real_carConfig = None self.real_dasHw = 0 #BB visiond last type self.last_visiond = self.cstm_btns.btns[3].btn_label2 - - + + # vEgo kalman filter dt = 0.01 # Q = np.matrix([[10.0, 0.0], [0.0, 100.0]]) @@ -424,19 +416,60 @@ def __init__(self, CP): self.angle_offset = 0. self.init_angle_offset = False + + #AHB params + self.ahbHighBeamStalkPosition = 0 + self.ahbEnabled = 0 + self.ahbLoBeamOn = 0 + self.ahbHiBeamOn = 0 + self.ahbNightMode = 0 + + @staticmethod + def get_can_parser(CP): + signals, checks = get_can_signals(CP) + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0) + + @staticmethod + def get_can_parser2(CP,mydbc): + signals, checks = get_can_signals(CP) + return CANParser(mydbc, signals, checks, 0) + + @staticmethod + def get_epas_parser(CP,epascan): + signals, checks = get_epas_can_signals(CP) + return CANParser(DBC[CP.carFingerprint]['pt']+"_epas", signals, checks, epascan) + + @staticmethod + def get_pedal_parser(CP,pedalcan): + signals, checks = get_pedal_can_signals(CP) + return CANParser(DBC[CP.carFingerprint]['pt']+"_pedal", signals, checks, pedalcan) + + - def config_ui_buttons(self, pedalPresent): - if pedalPresent: + def config_ui_buttons(self, pcc_available, pcc_blocked_by_acc_mode): + if pcc_available: self.btns_init[1] = [PCCModes.BUTTON_NAME, PCCModes.BUTTON_ABREVIATION, PCCModes.labels()] else: - # we don't have pedal interceptor self.btns_init[1] = [ACCMode.BUTTON_NAME, ACCMode.BUTTON_ABREVIATION, ACCMode.labels()] btn = self.cstm_btns.btns[1] btn.btn_name = self.btns_init[1][0] btn.btn_label = self.btns_init[1][1] btn.btn_label2 = self.btns_init[1][2][0] btn.btn_status = 1 - self.cstm_btns.update_ui_buttons(1, 1) + + if (not pcc_available) and pcc_blocked_by_acc_mode: + btn.btn_label2 = self.btns_init[1][2][1] + self.cstm_btns.update_ui_buttons(1, 1) + + def _convert_to_DAS_fusedSpeedLimit(self, speed_limit_uom, speed_limit_type): + if speed_limit_uom > 0: + if speed_limit_type == 0x1E: # Autobahn with no speed limit + return 0x1F # no speed limit sign + return int(speed_limit_uom / 5 + 0.5) # sign ID in 5 kph/mph increments (7 shows as 5) + else: + if speed_limit_type == 0x1F: # SNA (parking lot, no public road, etc.) + return 0 # no sign + return 1 # show 5 kph/mph for unknown limit where we should have one def compute_speed(self): # if one of them is zero, select max of the two @@ -449,16 +482,16 @@ def compute_speed(self): if self.splineLocConfidence > 60: self.mapBasedSuggestedSpeed = (self.splineLocConfidence * self.meanFleetSplineSpeedMPS + (100-self.splineLocConfidence) * self.bottomQrtlFleetSpeedMPS ) / 100. else: - self.mapBasedSuggestedSpeed = self.baseMapSpeedLimitMPS + self.mapBasedSuggestedSpeed = self.speed_limit_ms if self.rampType > 0: #we are on a ramp, use the spline info if available if self.splineBasedSuggestedSpeed > 0: - self.maxdrivespeed = self.splineBasedSuggestedSpeed + self.map_suggested_speed = self.splineBasedSuggestedSpeed else: - self.maxdrivespeed = self.mapBasedSuggestedSpeed + self.map_suggested_speed = self.mapBasedSuggestedSpeed else: #we are on a normal road, use max of the two - self.maxdrivespeed = max(self.mapBasedSuggestedSpeed, self.splineBasedSuggestedSpeed) + self.map_suggested_speed = max(self.mapBasedSuggestedSpeed, self.splineBasedSuggestedSpeed) def update_ui_buttons(self,btn_id,btn_status): # we only focus on btn_id=3, which is for visiond @@ -471,27 +504,20 @@ def update_ui_buttons(self,btn_id,btn_status): def update(self, cp, epas_cp, pedal_cp): - # car params - v_weight_v = [0., 1.] # don't trust smooth speed at low values to avoid premature zero snapping - v_weight_bp = [1., 6.] # smooth blending, below ~0.6m/s the smooth speed snaps to zero - - # update prevs, update must run once per loop - self.prev_cruise_buttons = self.cruise_buttons - self.prev_blinker_on = self.blinker_on - - self.prev_left_blinker_on = self.left_blinker_on - self.prev_right_blinker_on = self.right_blinker_on - self.steering_wheel_stalk = cp.vl["STW_ACTN_RQ"] self.real_carConfig = cp.vl["GTW_carConfig"] self.real_dasHw = cp.vl["GTW_carConfig"]['GTW_dasHw'] + self.prev_cruise_buttons = self.cruise_buttons self.cruise_buttons = cp.vl["STW_ACTN_RQ"]['SpdCtrlLvr_Stat'] # ******************* parse out can ******************* self.door_all_closed = not any([cp.vl["GTW_carState"]['DOOR_STATE_FL'], cp.vl["GTW_carState"]['DOOR_STATE_FR'], cp.vl["GTW_carState"]['DOOR_STATE_RL'], cp.vl["GTW_carState"]['DOOR_STATE_RR']]) #JCT - self.seatbelt = cp.vl["SDM1"]['SDM_bcklDrivStatus'] + if self.usesApillarHarness: + self.seatbelt = epas_cp.vl["SDM1"]['SDM_bcklDrivStatus'] + else: + self.seatbelt = cp.vl["SDM1"]['SDM_bcklDrivStatus'] #self.seatbelt = cp.vl["SDM1"]['SDM_bcklDrivStatus'] and cp.vl["GTW_status"]['GTW_driverPresent'] if (cp.vl["GTW_carConfig"]['GTW_performanceConfig']) and (cp.vl["GTW_carConfig"]['GTW_performanceConfig'] > 0): prev_teslaModel = self.teslaModel @@ -501,7 +527,7 @@ def update(self, cp, epas_cp, pedal_cp): if (cp.vl["GTW_carConfig"]['GTW_fourWheelDrive'] == 1): self.teslaModel = self.teslaModel + "D" if (self.teslaModelDetected == 0) or (prev_teslaModel != self.teslaModel): - write_db('/data/params','TeslaModel',self.teslaModel) + self.params.put('TeslaModel',self.teslaModel) self.teslaModelDetected = 1 #Nav Map Data @@ -526,46 +552,62 @@ def update(self, cp, epas_cp, pedal_cp): self.gpsLatitude = cp.vl['MCU_locationStatus']["MCU_latitude"] self.gpsAccuracy = cp.vl['MCU_locationStatus']["MCU_gpsAccuracy"] self.gpsElevation = cp.vl['MCU_locationStatus2']["MCU_elevation"] - self.gpsHeading = cp.vl['MCU_gpsVehicleSpeed']["MCU_gpsVehicleHeading"] - self.gpsVehicleSpeed = cp.vl['MCU_gpsVehicleSpeed']["MCU_gpsVehicleSpeed"] * CV.KPH_TO_MS + self.gpsHeading = cp.vl['UI_gpsVehicleSpeed']["UI_gpsVehicleHeading"] + self.gpsVehicleSpeed = cp.vl['UI_gpsVehicleSpeed']["UI_gpsVehicleSpeed"] * CV.KPH_TO_MS if (self.hasTeslaIcIntegration): - self.apEnabled = (cp.vl["MCU_chassisControl"]["MCU_latControlEnable"] == 1) + #BB: AutoSteer enabled does not work unless we do old style port mapping on MCU + #self.apEnabled = (cp.vl["MCU_chassisControl"]["MCU_latControlEnable"] == 1) + self.summonButton = int(cp.vl["UI_driverAssistControl"]["UI_autoSummonEnable"]) self.apFollowTimeInS = 1 + cp.vl["MCU_chassisControl"]["MCU_fcwSensitivity"] * 0.5 self.keepEonOff = cp.vl["MCU_chassisControl"]["MCU_ldwEnable"] == 1 self.alcaEnabled = cp.vl["MCU_chassisControl"]["MCU_pedalSafetyEnable"] == 1 - self.mapAwareSpeed = cp.vl["MCU_chassisControl"]["MCU_aebEnable"] == 1 + self.mapAwareSpeed = cp.vl["MCU_chassisControl"]["MCU_aebEnable"] == 1 and self.useTeslaMapData + #AHB info + self.ahbHighBeamStalkPosition = cp.vl["STW_ACTN_RQ"]["HiBmLvr_Stat"] + self.ahbEnabled = cp.vl["MCU_chassisControl"]["MCU_ahlbEnable"] + if self.usesApillarHarness: + self.ahbLoBeamOn = epas_cp.vl["BODY_R1"]["LoBm_On_Rq"] + self.ahbHiBeamOn = epas_cp.vl["BODY_R1"]["HiBm_On"] + self.ahbNightMode = epas_cp.vl["BODY_R1"]["LgtSens_Night"] + else: + self.ahbLoBeamOn = cp.vl["BODY_R1"]["LoBm_On_Rq"] + self.ahbHiBeamOn = cp.vl["BODY_R1"]["HiBm_On"] + self.ahbNightMode = cp.vl["BODY_R1"]["LgtSens_Night"] - usu = cp.vl['MCU_gpsVehicleSpeed']["MCU_userSpeedOffsetUnits"] + usu = cp.vl['UI_gpsVehicleSpeed']["UI_userSpeedOffsetUnits"] if usu == 1: - self.userSpeedLimitOffsetKph = cp.vl['MCU_gpsVehicleSpeed']["MCU_userSpeedOffset"] - else: - self.userSpeedLimitOffsetKph = cp.vl['MCU_gpsVehicleSpeed']["MCU_userSpeedOffset"] * CV.MPH_TO_KPH - msu = cp.vl['MCU_gpsVehicleSpeed']["MCU_mapSpeedLimitUnits"] - if msu == 1: - self.userSpeedLimitKph = cp.vl['MCU_gpsVehicleSpeed']["MCU_mppSpeedLimit"] + self.userSpeedLimitOffsetKph = cp.vl['UI_gpsVehicleSpeed']["UI_userSpeedOffset"] else: - self.userSpeedLimitKph = cp.vl['MCU_gpsVehicleSpeed']["MCU_mppSpeedLimit"] * CV.MPH_TO_KPH - - speed_limit_tesla_lookup = [0,5,7,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,130,140,150,160,0,0] - self.speedLimitUnits = cp.vl["UI_driverAssistMapData"]["UI_mapSpeedUnits"] - self.speedLimitKph = speed_limit_tesla_lookup[int(cp.vl["UI_driverAssistMapData"]["UI_mapSpeedLimit"])] * (1 + 0.609 * (1 - self.speedLimitUnits)) - + self.userSpeedLimitOffsetKph = cp.vl['UI_gpsVehicleSpeed']["UI_userSpeedOffset"] * CV.MPH_TO_KPH + msu = cp.vl['UI_gpsVehicleSpeed']["UI_mapSpeedLimitUnits"] + map_speed_uom_to_ms = CV.KPH_TO_MS if msu == 1 else CV.MPH_TO_MS + map_speed_ms_to_uom = CV.MS_TO_KPH if msu == 1 else CV.MS_TO_MPH + speed_limit_type = int(cp.vl["UI_driverAssistMapData"]["UI_mapSpeedLimit"]) rdSignMsg = cp.vl["UI_driverAssistRoadSign"]["UI_roadSign"] - if rdSignMsg == 4: + if rdSignMsg == 4: # ROAD_SIGN_SPEED_SPLINE self.meanFleetSplineSpeedMPS = cp.vl["UI_driverAssistRoadSign"]["UI_meanFleetSplineSpeedMPS"] self.meanFleetSplineAccelMPS2 = cp.vl["UI_driverAssistRoadSign"]["UI_meanFleetSplineAccelMPS2"] self.medianFleetSpeedMPS = cp.vl["UI_driverAssistRoadSign"]["UI_medianFleetSpeedMPS"] self.splineLocConfidence = cp.vl["UI_driverAssistRoadSign"]["UI_splineLocConfidence"] + self.UI_splineID = cp.vl["UI_driverAssistRoadSign"]["UI_splineID"] self.rampType = cp.vl["UI_driverAssistRoadSign"]["UI_rampType"] - - if rdSignMsg == 3: + + elif rdSignMsg == 3: # ROAD_SIGN_SPEED_LIMIT self.topQrtlFleetSplineSpeedMPS = cp.vl["UI_driverAssistRoadSign"]["UI_topQrtlFleetSpeedMPS"] self.splineLocConfidence = cp.vl["UI_driverAssistRoadSign"]["UI_splineLocConfidence"] self.baseMapSpeedLimitMPS = cp.vl["UI_driverAssistRoadSign"]["UI_baseMapSpeedLimitMPS"] + # we round the speed limit in the map's units of measurement to fix noisy data (there are no signs with a limit of 79.2 kph) + self.baseMapSpeedLimitMPS = int(self.baseMapSpeedLimitMPS * map_speed_ms_to_uom + 0.99) / map_speed_ms_to_uom self.bottomQrtlFleetSpeedMPS = cp.vl["UI_driverAssistRoadSign"]["UI_bottomQrtlFleetSpeedMPS"] - + + if self.baseMapSpeedLimitMPS > 0 and (speed_limit_type != 0x1F or self.baseMapSpeedLimitMPS <= 5.56): + self.speed_limit_ms = self.baseMapSpeedLimitMPS # this one is earlier than the actual sign but can also be unreliable, so we ignore it on SNA at higher speeds + else: + self.speed_limit_ms = cp.vl['UI_gpsVehicleSpeed']["UI_mppSpeedLimit"] * map_speed_uom_to_ms + self.DAS_fusedSpeedLimit = self._convert_to_DAS_fusedSpeedLimit(self.speed_limit_ms * map_speed_ms_to_uom, speed_limit_type) + self.compute_speed() # 2 = temporary 3= TBD 4 = temporary, hit a bump 5 (permanent) 6 = temporary 7 (permanent) @@ -584,50 +626,48 @@ def update(self, cp, epas_cp, pedal_cp): self.v_wheel_rr = 0 #JCT self.v_wheel = 0 #JCT self.v_weight = 0 #JCT - speed = (cp.vl["DI_torque2"]['DI_vehicleSpeed']) * CV.MPH_TO_KPH/3.6 #JCT MPH_TO_MS. Tesla is in MPH, v_ego is expected in M/S - speed = speed * 1.01 # To match car's displayed speed + self.imperial_speed_units = cp.vl["DI_state"]['DI_speedUnits'] == 0 + speed_ms = cp.vl["DI_state"]['DI_analogSpeed'] * (CV.MPH_TO_MS if self.imperial_speed_units else CV.KPH_TO_MS) # car's displayed speed in m/s - if abs(speed - self.v_ego) > 2.0: # Prevent large accelerations when car starts at non zero speed - self.v_ego_kf.x = [[speed], [0.0]] + if abs(speed_ms - self.v_ego) > 2.0: # Prevent large accelerations when car starts at non zero speed + self.v_ego_kf.x = [[speed_ms], [0.0]] - self.v_ego_raw = speed - v_ego_x = self.v_ego_kf.update(speed) + self.v_ego_raw = speed_ms + v_ego_x = self.v_ego_kf.update(speed_ms) self.v_ego = float(v_ego_x[0]) self.a_ego = float(v_ego_x[1]) #BB use this set for pedal work as the user_gas_xx is used in other places + self.prev_pedal_interceptor_state = self.pedal_interceptor_state self.pedal_interceptor_state = pedal_cp.vl["GAS_SENSOR"]['STATE'] self.pedal_interceptor_value = pedal_cp.vl["GAS_SENSOR"]['INTERCEPTOR_GAS'] self.pedal_interceptor_value2 = pedal_cp.vl["GAS_SENSOR"]['INTERCEPTOR_GAS2'] + self.prev_pedal_idx = self.pedal_idx + self.pedal_idx = pedal_cp.vl["GAS_SENSOR"]['IDX'] can_gear_shifter = cp.vl["DI_torque2"]['DI_gear'] - self.gear = 0 # JCT # self.angle_steers = -(cp.vl["STW_ANGLHP_STAT"]['StW_AnglHP']) #JCT polarity reversed from Honda/Acura self.angle_steers = -(epas_cp.vl["EPAS_sysStatus"]['EPAS_internalSAS']) #BB see if this works better than STW_ANGLHP_STAT for angle - + self.angle_steers_rate = 0 #JCT - self.blinker_on = (cp.vl["STW_ACTN_RQ"]['TurnIndLvr_Stat'] == 1) or (cp.vl["STW_ACTN_RQ"]['TurnIndLvr_Stat'] == 2) - self.left_blinker_on = cp.vl["STW_ACTN_RQ"]['TurnIndLvr_Stat'] == 1 - self.right_blinker_on = cp.vl["STW_ACTN_RQ"]['TurnIndLvr_Stat'] == 2 + self.turn_signal_state_left = cp.vl["GTW_carState"]['BC_indicatorLStatus'] + self.turn_signal_state_right = cp.vl["GTW_carState"]['BC_indicatorRStatus'] + self.prev_turn_signal_blinking = self.turn_signal_blinking + self.turn_signal_blinking = self.turn_signal_state_left == 1 or self.turn_signal_state_right == 1 + self.prev_turn_signal_stalk_state = self.turn_signal_stalk_state + self.turn_signal_stalk_state = 0 if cp.vl["STW_ACTN_RQ"]['TurnIndLvr_Stat'] == 3 else int(cp.vl["STW_ACTN_RQ"]['TurnIndLvr_Stat']) - #if self.CP.carFingerprint in (CAR.CIVIC, CAR.ODYSSEY): - # self.park_brake = cp.vl["EPB_STATUS"]['EPB_STATE'] != 0 - # self.brake_hold = cp.vl["VSA_STATUS"]['BRAKE_HOLD_ACTIVE'] - # self.main_on = cp.vl["SCM_FEEDBACK"]['MAIN_ON'] - #else: - self.park_brake = 0 # TODO self.brake_hold = 0 # TODO self.main_on = 1 #cp.vl["SCM_BUTTONS"]['MAIN_ON'] - self.imperial_speed_units = cp.vl["DI_state"]['DI_speedUnits'] == 0 self.DI_cruiseSet = cp.vl["DI_state"]['DI_cruiseSet'] if self.imperial_speed_units: self.DI_cruiseSet = self.DI_cruiseSet * CV.MPH_TO_KPH - self.cruise_speed_offset = calc_cruise_offset(self.DI_cruiseSet*CV.KPH_TO_MS, self.v_ego) self.gear_shifter = parse_gear_shifter(can_gear_shifter, self.CP.carFingerprint) + self.park_brake = self.gear_shifter == 'park' # TODO self.pedal_gas = 0. # cp.vl["DI_torque1"]['DI_pedalPos'] / 102 #BB: to make it between 0..1 self.car_gas = self.pedal_gas @@ -645,34 +685,16 @@ def update(self, cp, epas_cp, pedal_cp): self.standstill = cp.vl["DI_torque2"]['DI_vehicleSpeed'] == 0 self.torqueMotor = cp.vl["DI_torque1"]['DI_torqueMotor'] self.pcm_acc_status = cp.vl["DI_state"]['DI_cruiseState'] - + self.regenLight = cp.vl["DI_state"]['DI_regenLight'] == 1 - - self.prev_pedal_interceptor_available = self.pedal_interceptor_available - pedal_has_value = bool(self.pedal_interceptor_value) or bool(self.pedal_interceptor_value2) - pedal_interceptor_present = self.pedal_interceptor_state in [0, 5] and pedal_has_value - # Add loggic if we just miss some CAN messages so we don't immediately disable pedal - if pedal_has_value: - self.pedal_interceptor_missed_counter = 0 - if pedal_interceptor_present: - self.pedal_interceptor_missed_counter = 0 - else: - self.pedal_interceptor_missed_counter += 1 - pedal_interceptor_present = pedal_interceptor_present and (self.pedal_interceptor_missed_counter < 10) - # Mark pedal unavailable while traditional cruise is on. - self.pedal_interceptor_available = pedal_interceptor_present and (self.forcePedalOverCC or not bool(self.pcm_acc_status)) - if self.pedal_interceptor_available != self.prev_pedal_interceptor_available: - self.config_ui_buttons(self.pedal_interceptor_available) self.v_cruise_actual = self.DI_cruiseSet - self.hud_lead = 0 #JCT - self.cruise_speed_offset = calc_cruise_offset(self.v_cruise_pcm, self.v_ego) # carstate standalone tester if __name__ == '__main__': - class CarParams(object): + class CarParams(): def __init__(self): self.carFingerprint = "TESLA MODEL S" self.enableCruise = 0 diff --git a/selfdrive/car/tesla/interface.py b/selfdrive/car/tesla/interface.py index 5a56d1f47296d2..03dbfaad0e6de3 100644 --- a/selfdrive/car/tesla/interface.py +++ b/selfdrive/car/tesla/interface.py @@ -1,31 +1,29 @@ #!/usr/bin/env python from cereal import car, tesla from common.numpy_fast import clip, interp -from common.realtime import sec_since_boot, DT_CTRL +from common.realtime import DT_CTRL from selfdrive.config import Conversions as CV -from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET, get_events +from selfdrive.controls.lib.events import ET from selfdrive.controls.lib.vehicle_model import VehicleModel -from selfdrive.car.tesla.carstate import CarState, get_can_parser, get_epas_parser, get_pedal_parser from selfdrive.car.tesla.values import CruiseButtons, CM, BP, AH, CAR,DBC -from selfdrive.controls.lib.planner import _A_CRUISE_MAX_V_FOLLOWING -from common.params import read_db -from selfdrive.car import STD_CARGO_KG +from common.params import Params +from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, is_ecu_disconnected, gen_empty_fingerprint from selfdrive.car.tesla.readconfig import CarSettings -import selfdrive.messaging as messaging -from selfdrive.services import service_list +from selfdrive.controls.lib.planner import _A_CRUISE_MAX_V +from selfdrive.car.interfaces import CarInterfaceBase +EventName = car.CarEvent.EventName + +A_ACC_MAX = max(_A_CRUISE_MAX_V) AudibleAlert = car.CarControl.HUDControl.AudibleAlert VisualAlert = car.CarControl.HUDControl.VisualAlert K_MULT = 0.8 K_MULTi = 280000. -def tesla_compute_gb(accel, speed): - return float(accel) / 3. - - -class CarInterface(object): - def __init__(self, CP, CarController): +class CarInterface(CarInterfaceBase): + def __init__(self, CP, CarController, CarState): + super().__init__(CP, CarController, CarState) self.CP = CP self.frame = 0 @@ -34,8 +32,6 @@ def __init__(self, CP, CarController): self.gas_pressed_prev = False self.brake_pressed_prev = False self.can_invalid_count = 0 - self.alca = messaging.pub_sock(service_list['alcaStatus'].port) - # *** init the major players *** @@ -44,20 +40,25 @@ def __init__(self, CP, CarController): mydbc = DBC[CP.carFingerprint]['pt'] if CP.carFingerprint == CAR.MODELS and self.CS.fix1916: mydbc = mydbc + "1916" - self.cp = get_can_parser(CP,mydbc) + self.cp = self.CS.get_can_parser2(CP,mydbc) self.epas_cp = None + self.pedal_cp = None if self.CS.useWithoutHarness: - self.epas_cp = get_epas_parser(CP,0) + self.epas_cp = self.CS.get_epas_parser(CP,0) + self.pedal_cp = self.CS.get_pedal_parser(CP,0) else: - self.epas_cp = get_epas_parser(CP,2) - self.pedal_cp = get_pedal_parser(CP) + self.epas_cp = self.CS.get_epas_parser(CP,2) + self.pedal_cp = self.CS.get_pedal_parser(CP,2) self.CC = None if CarController is not None: - self.CC = CarController(self.cp.dbc_name) + self.CC = CarController(self.cp.dbc_name,CP,self.VM) + + + @staticmethod + def compute_gb(accel, speed): + return float(accel) / 3. - self.compute_gb = tesla_compute_gb - @staticmethod @@ -66,6 +67,11 @@ def calc_accel_override(a_ego, a_target, v_ego, v_target): # - v_ego exceeds v_target, or # - a_ego exceeds a_target and v_ego is close to v_target + # normalized max accel. Allowing max accel at low speed causes speed overshoots + max_accel_bp = [10, 20] # m/s + max_accel_v = [0.714, 1.0] # unit of max accel + max_accel = interp(v_ego, max_accel_bp, max_accel_v) + eA = a_ego - a_target valuesA = [1.0, 0.1] bpA = [0.3, 1.1] @@ -84,32 +90,34 @@ def calc_accel_override(a_ego, a_target, v_ego, v_target): # accelOverride is more or less the max throttle allowed to pcm: usually set to a constant # unless aTargetMax is very high and then we scale with it; this help in quicker restart - return float(max(0.714, a_target / max(_A_CRUISE_MAX_V_FOLLOWING))) * min(speedLimiter, accelLimiter) + return float(max(max_accel, a_target / A_ACC_MAX)) * min(speedLimiter, accelLimiter) @staticmethod - def get_params(candidate, fingerprint, vin="", is_panda_black=False): + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # Scaled tire stiffness ts_factor = 8 - ret = car.CarParams.new_message() + ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "tesla" ret.carFingerprint = candidate - ret.isPandaBlack = is_panda_black - teslaModel = read_db('/data/params','TeslaModel') + params = Params() + teslaModel = params.get("TeslaModel") + if teslaModel is not None: + teslaModel = teslaModel.decode() if teslaModel is None: teslaModel = "S" ret.safetyModel = car.CarParams.SafetyModel.tesla ret.safetyParam = 1 - ret.carVin = vin + ret.carVin = "TESLAFAKEVIN12345" ret.enableCamera = True ret.enableGasInterceptor = False #keep this False for now - print "ECU Camera Simulated: ", ret.enableCamera - print "ECU Gas Interceptor: ", ret.enableGasInterceptor + print ("ECU Camera Simulated: ", ret.enableCamera) + print ("ECU Gas Interceptor: ", ret.enableGasInterceptor) ret.enableCruise = not ret.enableGasInterceptor @@ -128,7 +136,7 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): ret.mass = mass_models ret.wheelbase = wheelbase_models ret.centerToFront = centerToFront_models - ret.steerRatio = 12. + ret.steerRatio = 11.5 # Kp and Ki for the lateral control for 0, 20, 40, 60 mph ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[1.20, 0.80, 0.60, 0.30], [0.16, 0.12, 0.08, 0.04]] ret.lateralTuning.pid.kf = 0.00006 # Initial test value TODO: investigate FF steer control for Model S? @@ -140,31 +148,31 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): # Kp and Ki for the longitudinal control if teslaModel == "S": - ret.longitudinalTuning.kpBP = [0., 5., 35.] - ret.longitudinalTuning.kpV = [0.50, 0.45, 0.4] - ret.longitudinalTuning.kiBP = [0., 5., 35.] - ret.longitudinalTuning.kiV = [0.01,0.01,0.01] + ret.longitudinalTuning.kpBP = [0., 5., 22., 35.] + ret.longitudinalTuning.kpV = [0.50, 0.45, 0.4, 0.4] + ret.longitudinalTuning.kiBP = [0., 5., 22., 35.] + ret.longitudinalTuning.kiV = [0.01,0.01,0.01,0.01] elif teslaModel == "SP": - ret.longitudinalTuning.kpBP = [0., 5., 35.] - ret.longitudinalTuning.kpV = [0.375, 0.325, 0.3] - ret.longitudinalTuning.kiBP = [0., 5., 35.] - ret.longitudinalTuning.kiV = [0.009,0.008,0.007] + ret.longitudinalTuning.kpBP = [0., 5., 22., 35.] # 0km/h, 18 km/h, 80, 128km/h + ret.longitudinalTuning.kiBP = [0., 5., 22., 35.] + ret.longitudinalTuning.kpV = [0.3, 0.3, 0.35, 0.37] + ret.longitudinalTuning.kiV = [0.07, 0.07, 0.093, 0.092] elif teslaModel == "SD": - ret.longitudinalTuning.kpBP = [0., 5., 35.] - ret.longitudinalTuning.kpV = [0.50, 0.45, 0.4] - ret.longitudinalTuning.kiBP = [0., 5., 35.] - ret.longitudinalTuning.kiV = [0.01,0.01,0.01] + ret.longitudinalTuning.kpBP = [0., 5., 22., 35.] + ret.longitudinalTuning.kpV = [0.50, 0.45, 0.4,0.4] + ret.longitudinalTuning.kiBP = [0., 5., 22., 35.] + ret.longitudinalTuning.kiV = [0.01,0.01,0.01,0.01] elif teslaModel == "SPD": - ret.longitudinalTuning.kpBP = [0., 5., 35.] - ret.longitudinalTuning.kpV = [0.50, 0.45, 0.4] - ret.longitudinalTuning.kiBP = [0., 5., 35.] - ret.longitudinalTuning.kiV = [0.009,0.008,0.007] + ret.longitudinalTuning.kpBP = [0., 5., 22., 35.] + ret.longitudinalTuning.kpV = [0.375, 0.325, 0.325, 0.325] + ret.longitudinalTuning.kiBP = [0., 5., 22.,35.] + ret.longitudinalTuning.kiV = [0.00915,0.00825,0.00725, 0.00725] else: #use S numbers if we can't match anything - ret.longitudinalTuning.kpBP = [0., 5., 35.] - ret.longitudinalTuning.kpV = [0.375, 0.325, 0.3] - ret.longitudinalTuning.kiBP = [0., 5., 35.] - ret.longitudinalTuning.kiV = [0.08,0.08,0.08] + ret.longitudinalTuning.kpBP = [0., 5., 22., 35.] + ret.longitudinalTuning.kpV = [0.375, 0.325, 0.3, 0.3] + ret.longitudinalTuning.kiBP = [0., 5., 22., 35.] + ret.longitudinalTuning.kiV = [0.08,0.08,0.08, 0.08] else: @@ -198,20 +206,22 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): ret.steerMaxBP = [0.,15.] # m/s ret.steerMaxV = [420.,420.] # max steer allowed - ret.gasMaxBP = [0.] # m/s - ret.gasMaxV = [0.3] #if ret.enableGasInterceptor else [0.] # max gas allowed - ret.brakeMaxBP = [0., 20.] # m/s - ret.brakeMaxV = [1., 1.] # max brake allowed - BB: since we are using regen, make this even + ret.gasMaxBP = [0., 20.] # m/s + ret.gasMaxV = [0.225, 0.525] #if ret.enableGasInterceptor else [0.] # max gas allowed + ret.brakeMaxBP = [0.] # m/s + ret.brakeMaxV = [1.] # max brake allowed - BB: since we are using regen, make this even - ret.longitudinalTuning.deadzoneBP = [0., 9.] #BB: added from Toyota to start pedal work; need to tune - ret.longitudinalTuning.deadzoneV = [0., 0.] #BB: added from Toyota to start pedal work; need to tune; changed to 0 for now + ret.longitudinalTuning.deadzoneBP = [0.] #BB: added from Toyota to start pedal work; need to tune + ret.longitudinalTuning.deadzoneV = [0.] #BB: added from Toyota to start pedal work; need to tune; changed to 0 for now ret.stoppingControl = True ret.openpilotLongitudinalControl = True ret.steerLimitAlert = False ret.startAccel = 0.5 - ret.steerRateCost = 0.6 + ret.steerRateCost = 1.0 + ret.radarOffCan = not CarSettings().get_value("useTeslaRadar") + ret.radarTimeStep = 0.05 #20Hz return ret @@ -220,11 +230,11 @@ def update(self, c, can_strings): # ******************* do can recv ******************* canMonoTimes = [] - self.cp.update_strings(int(sec_since_boot() * 1e9), can_strings) + self.cp.update_strings(can_strings) ch_can_valid = self.cp.can_valid - self.epas_cp.update_strings(int(sec_since_boot() * 1e9), can_strings) + self.epas_cp.update_strings(can_strings) epas_can_valid = self.epas_cp.can_valid - self.pedal_cp.update_strings(int(sec_since_boot() * 1e9), can_strings) + self.pedal_cp.update_strings(can_strings) pedal_can_valid = self.pedal_cp.can_valid can_rcv_error = not (ch_can_valid and epas_can_valid and pedal_can_valid) @@ -267,35 +277,35 @@ def update(self, c, can_strings): ret.gearShifter = self.CS.gear_shifter ret.steeringTorque = self.CS.steer_torque_driver - ret.steeringPressed = self.CS.steer_override or not self.CS.enableDriverMonitor + ret.steeringPressed = self.CS.steer_override # cruise state ret.cruiseState.enabled = True #self.CS.pcm_acc_status != 0 - ret.cruiseState.speed = self.CS.v_cruise_pcm * CV.KPH_TO_MS + ret.cruiseState.speed = self.CS.v_cruise_pcm * CV.KPH_TO_MS * (CV.MPH_TO_KPH if self.CS.imperial_speed_units else 1.) ret.cruiseState.available = bool(self.CS.main_on) - ret.cruiseState.speedOffset = self.CS.cruise_speed_offset + ret.cruiseState.speedOffset = 0. ret.cruiseState.standstill = False # TODO: button presses buttonEvents = [] - ret.leftBlinker = bool(self.CS.left_blinker_on) - ret.rightBlinker = bool(self.CS.right_blinker_on) + ret.leftBlinker = bool(self.CS.turn_signal_state_left == 1) + ret.rightBlinker = bool(self.CS.turn_signal_state_right == 1) ret.doorOpen = not self.CS.door_all_closed ret.seatbeltUnlatched = not self.CS.seatbelt - if self.CS.left_blinker_on != self.CS.prev_left_blinker_on: - be = car.CarState.ButtonEvent.new_message() - be.type = 'leftBlinker' - be.pressed = self.CS.left_blinker_on != 0 - buttonEvents.append(be) - - if self.CS.right_blinker_on != self.CS.prev_right_blinker_on: - be = car.CarState.ButtonEvent.new_message() - be.type = 'rightBlinker' - be.pressed = self.CS.right_blinker_on != 0 - buttonEvents.append(be) + if self.CS.prev_turn_signal_stalk_state != self.CS.turn_signal_stalk_state: + if self.CS.turn_signal_stalk_state == 1 or self.CS.prev_turn_signal_stalk_state == 1: + be = car.CarState.ButtonEvent.new_message() + be.type = 'leftBlinker' + be.pressed = self.CS.turn_signal_stalk_state == 1 + buttonEvents.append(be) + if self.CS.turn_signal_stalk_state == 2 or self.CS.prev_turn_signal_stalk_state == 2: + be = car.CarState.ButtonEvent.new_message() + be.type = 'rightBlinker' + be.pressed = self.CS.turn_signal_stalk_state == 2 + buttonEvents.append(be) if self.CS.cruise_buttons != self.CS.prev_cruise_buttons: be = car.CarState.ButtonEvent.new_message() @@ -324,7 +334,7 @@ def update(self, c, can_strings): ret.buttonEvents = buttonEvents # events - events = [] + events = self.create_common_events(ret) #notification messages for DAS if (not c.enabled) and (self.CC.opState == 2): @@ -333,8 +343,9 @@ def update(self, c, can_strings): self.CC.opState = 1 if can_rcv_error: self.can_invalid_count += 1 - if self.can_invalid_count >= 100: #BB increased to 100 to see if we still get the can error messages - events.append(create_event('invalidGiraffeHonda', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) + if self.can_invalid_count >= 200: #Raf increased to 200 #BB increased to 100 to see if we still get the can error messages + events.add(EventName.canError) + self.can_invalid_count = 0 self.CS.DAS_canErrors = 1 if self.CC.opState == 1: self.CC.opState = 2 @@ -342,29 +353,29 @@ def update(self, c, can_strings): self.can_invalid_count = 0 if self.CS.steer_error: if not self.CS.enableHSO: - events.append(create_event('steerUnavailable', [ET.NO_ENTRY, ET.WARNING])) + events.add(EventName.steerUnavailable) elif self.CS.steer_warning: if not self.CS.enableHSO: - events.append(create_event('steerTempUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) + events.add(EventName.steerTempUnavailable) if self.CC.opState == 1: self.CC.opState = 2 if self.CS.brake_error: - events.append(create_event('brakeUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT])) + events.add(EventName.brakeUnavailable) if self.CC.opState == 1: self.CC.opState = 2 if not ret.gearShifter == 'drive': - events.append(create_event('wrongGear', [ET.NO_ENTRY, ET.SOFT_DISABLE])) + events.add(EventName.wrongGear) if c.enabled: self.CC.DAS_222_accCameraBlind = 1 self.CC.warningCounter = 300 self.CC.warningNeeded = 1 if ret.doorOpen: - events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE])) + events.add(EventName.doorOpen) self.CS.DAS_doorOpen = 1 if self.CC.opState == 1: self.CC.opState = 0 if ret.seatbeltUnlatched: - events.append(create_event('seatbeltNotLatched', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) + events.add(EventName.seatbeltNotLatched) if c.enabled: self.CC.DAS_211_accNoSeatBelt = 1 self.CC.warningCounter = 300 @@ -372,31 +383,33 @@ def update(self, c, can_strings): if self.CC.opState == 1: self.CC.opState = 2 if self.CS.esp_disabled: - events.append(create_event('espDisabled', [ET.NO_ENTRY, ET.SOFT_DISABLE])) + events.add(EventName.espDisabled) if self.CC.opState == 1: self.CC.opState = 2 if not self.CS.main_on: - events.append(create_event('wrongCarMode', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) + events.add(EventName.wrongCarMode) if self.CC.opState == 1: self.CC.opState = 0 if ret.gearShifter == 'reverse': - events.append(create_event('reverseGear', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) + events.add(EventName.reverseGear) self.CS.DAS_notInDrive = 1 if self.CC.opState == 1: self.CC.opState = 0 + if ret.gearShifter == 'drive': + self.CS.DAS_notInDrive =0 if self.CS.brake_hold: - events.append(create_event('brakeHold', [ET.NO_ENTRY, ET.USER_DISABLE])) + events.add(EventName.brakeHold) if self.CC.opState == 1: self.CC.opState = 0 if self.CS.park_brake: - events.append(create_event('parkBrake', [ET.NO_ENTRY, ET.USER_DISABLE])) + events.add(EventName.parkBrake) if self.CC.opState == 1: self.CC.opState = 0 if (not c.enabled) and (self.CC.opState == 1): self.CC.opState = 0 if self.CP.enableCruise and ret.vEgo < self.CP.minEnableSpeed: - events.append(create_event('speedTooLow', [ET.NO_ENTRY])) + events.add(EventName.speedTooLow) # Standard OP method to disengage: # disable on pedals rising edge or when brake is pressed and speed isn't zero @@ -410,19 +423,19 @@ def update(self, c, can_strings): #else: # if ret.brakePressed: # events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) - if ret.gasPressed: - events.append(create_event('pedalPressed', [ET.PRE_ENABLE])) + #if ret.gasPressed: + # events.append(create_event('pedalPressed', [ET.PRE_ENABLE])) # it can happen that car cruise disables while comma system is enabled: need to # keep braking if needed or if the speed is very low if self.CP.enableCruise and not ret.cruiseState.enabled and c.actuators.brake <= 0.: # non loud alert if cruise disbales below 25mph as expected (+ a little margin) if ret.vEgo < self.CP.minEnableSpeed + 2.: - events.append(create_event('speedTooLow', [ET.IMMEDIATE_DISABLE])) + events.add(EventName.speedTooLow) else: - events.append(create_event("cruiseDisabled", [ET.IMMEDIATE_DISABLE])) + events.add(EventName.cruiseDisabled) if self.CS.CP.minEnableSpeed > 0 and ret.vEgo < 0.001: - events.append(create_event('manualRestart', [ET.WARNING])) + events.add(EventName.manualRestart) cur_time = self.frame * DT_CTRL enable_pressed = False @@ -431,23 +444,23 @@ def update(self, c, can_strings): # do enable on both accel and decel buttons if b.type == "altButton3" and not b.pressed: - print "enabled pressed at", cur_time + print ("enabled pressed at", cur_time) self.last_enable_pressed = cur_time enable_pressed = True # do disable on button down if b.type == "cancel" and b.pressed: - events.append(create_event('buttonCancel', [ET.USER_DISABLE])) + events.add(EventName.buttonCancel) if self.CP.enableCruise: # KEEP THIS EVENT LAST! send enable event if button is pressed and there are # NO_ENTRY events, so controlsd will display alerts. Also not send enable events # too close in time, so a no_entry will not be followed by another one. # TODO: button press should be the only thing that triggers enble - if ((cur_time - self.last_enable_pressed) < 0.2 and + if ((cur_time - self.last_enable_pressed) < 0.2 and # pylint: disable=chained-comparison (cur_time - self.last_enable_sent) > 0.2 and ret.cruiseState.enabled) or \ - (enable_pressed and get_events(events, [ET.NO_ENTRY])): + (enable_pressed and events.any(ET.NO_ENTRY)): if ret.seatbeltUnlatched: self.CC.DAS_211_accNoSeatBelt = 1 self.CC.warningCounter = 300 @@ -461,7 +474,7 @@ def update(self, c, can_strings): self.CC.warningCounter = 300 self.CC.warningNeeded = 1 else: - events.append(create_event('buttonEnable', [ET.ENABLE])) + events.add(EventName.buttonEnable) self.last_enable_sent = cur_time elif enable_pressed: if ret.seatbeltUnlatched: @@ -477,29 +490,17 @@ def update(self, c, can_strings): self.CC.warningCounter = 300 self.CC.warningNeeded = 1 else: - events.append(create_event('buttonEnable', [ET.ENABLE])) - - + events.add(EventName.buttonEnable) - ret.events = events + ret.events = events.to_msg() ret.canMonoTimes = canMonoTimes # update previous brake/gas pressed self.gas_pressed_prev = ret.gasPressed self.brake_pressed_prev = self.CS.brake_pressed != 0 - #pass ALCA status - alca_status = tesla.ALCAStatus.new_message() - - alca_status.alcaEnabled = bool(self.CS.ALCA_enabled) - alca_status.alcaTotalSteps = int(self.CS.ALCA_total_steps) - alca_status.alcaDirection = int(self.CS.ALCA_direction) - alca_status.alcaError = bool(self.CS.ALCA_error) - - self.alca.send(alca_status.to_bytes()) - - # cast to reader so it can't be modified - return ret.as_reader() + self.CS.out = ret.as_reader() + return self.CS.out # pass in a car.CarControl # to be called @ 100hz diff --git a/selfdrive/car/tesla/movingaverage.py b/selfdrive/car/tesla/movingaverage.py deleted file mode 100644 index e6c7f1770b17eb..00000000000000 --- a/selfdrive/car/tesla/movingaverage.py +++ /dev/null @@ -1,49 +0,0 @@ -class MovingAverage(object): - def __init__(self, length): - self.position = 0 - self.length = length - self.sum = 0. - self.no_items = 0 - self.values = [0.] * length - - def reset(self): - self.position = 0 - self.sum = 0. - self.no_items = 0 - self.values = [0.] * self.length - - def add(self,element): - if self.no_items == self.length: - self.no_items -= 1 - self.sum -= self.values[self.position] - self.values[self.position] = element - self.sum += self.values[self.position] - self.no_items += 1 - self.position += 1 - if self.sum == 0.: - #all empty so initialize - self.position = 0 - self.sum = 0. - self.no_items = 0 - return 0. - self.position = self.position % self.length - return self.sum/self.no_items - - def dele(self): - if self.no_items == 0: - return 0. - if self.no_items > 0: - self.no_items -= 1 - self.sum -= self.values[self.position] - self.values[self.position] = 0. - self.position -= 1 - if self.position < 0: - self.position = self.length-1 - if self.sum == 0. or self.no_items == 0.: - #all empty so initialize - self.position = 0 - self.sum = 0. - self.no_items = 0 - return 0. - self.position = self.position % self.length - return self.sum/self.no_items diff --git a/selfdrive/car/tesla/radar_interface.py b/selfdrive/car/tesla/radar_interface.py index 4966615eda5604..d670d706a2ca79 100644 --- a/selfdrive/car/tesla/radar_interface.py +++ b/selfdrive/car/tesla/radar_interface.py @@ -1,21 +1,37 @@ -#!/usr/bin/env python -from cereal import car,tesla -import time +#!/usr/bin/env python3 import os -from selfdrive.can.parser import CANParser -from common.realtime import sec_since_boot -from selfdrive.services import service_list -import selfdrive.messaging as messaging +import time +from cereal import car, tesla +from opendbc.can.parser import CANParser +from cereal.services import service_list +import cereal.messaging as messaging +from selfdrive.car.interfaces import RadarInterfaceBase from selfdrive.car.tesla.readconfig import CarSettings +from selfdrive.tinklad.tinkla_interface import TinklaClient +from selfdrive.car.interfaces import RadarInterfaceBase + +BOSCH_MAX_DIST = 250. #max distance for radar +#use these for tracks (5 tracks) #RADAR_A_MSGS = list(range(0x371, 0x37F , 3)) #RADAR_B_MSGS = list(range(0x372, 0x37F, 3)) -BOSCH_MAX_DIST = 150. #max distance for radar +#use these for point cloud (32 points) RADAR_A_MSGS = list(range(0x310, 0x36F , 3)) RADAR_B_MSGS = list(range(0x311, 0x36F, 3)) -OBJECT_MIN_PROBABILITY = 20. -CLASS_MIN_PROBABILITY = 20. - +OBJECT_MIN_PROBABILITY = 50. +CLASS_MIN_PROBABILITY = 50. +RADAR_MESSAGE_FREQUENCY = 0.050 * 1e9 #time in ns, radar sends data at 0.06 s +VALID_MESSAGE_COUNT_THRESHOLD = 4 +#these are settings for Auto High Beam +#they are use to detect objects that are moving either in the same direction with us or towards us +#for AHB radar is forced in low speed mode that widents the angle and reduces distance +#in these cases at night we will rely on visual radar to detect the lead car +AHB_VALID_MESSAGE_COUNT_THRESHOLD = 4 # -1 to use any point +AHB_OBJECT_MIN_PROBABILITY = 20. # 0. to use any point +AHB_CLASS_MIN_PROBABILITY = 10. # 0. to use any point +AHB_STATIONARY_MARGIN = 1.8 # m/s +AHB_DEBUG = False +AHB_MAX_DISTANCE = 100 # ignore if more than 100m # Tesla Bosch firmware has 32 objects in all objects or a selected set of the 5 we should look at # definetly switch to all objects when calibrating but most likely use select set of 5 for normal use @@ -27,7 +43,7 @@ def _create_radard_can_parser(): msg_a_n = len(RADAR_A_MSGS) msg_b_n = len(RADAR_B_MSGS) - signals = zip(['LongDist'] * msg_a_n + ['LatDist'] * msg_a_n + + signals = list(zip(['LongDist'] * msg_a_n + ['LatDist'] * msg_a_n + ['LongSpeed'] * msg_a_n + ['LongAccel'] * msg_a_n + ['Valid'] * msg_a_n + ['Tracked'] * msg_a_n + ['Meas'] * msg_a_n + ['ProbExist'] * msg_a_n + @@ -39,59 +55,70 @@ def _create_radard_can_parser(): [255.] * msg_a_n + [0.] * msg_a_n + [0.] * msg_a_n + [0.] * msg_a_n + [0] * msg_a_n + [0] * msg_a_n + [0] * msg_a_n + [0.] * msg_a_n + [0] * msg_a_n + [0.] * msg_a_n + [0.] * msg_b_n + [0] * msg_b_n + - [0] * msg_b_n + [0.] * msg_b_n + [0.] * msg_b_n +[0.] * msg_b_n + [0]* msg_b_n) + [0] * msg_b_n + [0.] * msg_b_n + [0.] * msg_b_n +[0.] * msg_b_n + [0]* msg_b_n)) + + checks = list(zip(RADAR_A_MSGS + RADAR_B_MSGS, [6]*(msg_a_n + msg_b_n))) + + + return CANParser(os.path.splitext(dbc_f)[0].encode('utf8'), signals, checks, 1) - checks = zip(RADAR_A_MSGS + RADAR_B_MSGS, [20]*(msg_a_n + msg_b_n)) - return CANParser(os.path.splitext(dbc_f)[0], signals, checks, 1) +class RadarInterface(RadarInterfaceBase): + tinklaClient = TinklaClient() -class RadarInterface(object): def __init__(self,CP): # radar self.pts = {} self.extPts = {} - self.delay = 0.1 - self.useTeslaRadar = CarSettings().get_value("useTeslaRadar") + self.delay = 0 self.TRACK_LEFT_LANE = True self.TRACK_RIGHT_LANE = True self.updated_messages = set() - if self.useTeslaRadar: + self.canErrorCounter = 0 + self.AHB_car_detected = False + self.track_id = 0 + self.radar_fault = False + self.radar_wrong_config = False + self.radar_off_can = CP.radarOffCan + self.radar_ts = CP.radarTimeStep + if not self.radar_off_can: self.pts = {} self.extPts = {} self.valid_cnt = {key: 0 for key in RADAR_A_MSGS} - self.delay = 0.1 # Delay of radar self.rcp = _create_radard_can_parser() - self.logcan = messaging.sub_sock(service_list['can'].port) self.radarOffset = CarSettings().get_value("radarOffset") self.trackId = 1 - self.trigger_msg = RADAR_B_MSGS[-1] + self.trigger_start_msg = RADAR_A_MSGS[0] + self.trigger_end_msg = RADAR_B_MSGS[-1] + self.delay = int(round(0.1 / CP.radarTimeStep)) # 0.1s delay of radar - - def update(self, can_strings): - # in Bosch radar and we are only steering for now, so sleep 0.05s to keep + def update(self, can_strings,v_ego): # radard at 20Hz and return no points - if not self.useTeslaRadar: - time.sleep(0.05) - return car.RadarData.new_message(),self.extPts.values() + if self.radar_off_can: + if 'NO_RADAR_SLEEP' not in os.environ: + time.sleep(self.radar_ts) + return car.RadarData.new_message(),self.extPts.values(),self.AHB_car_detected - tm = int(sec_since_boot() * 1e9) - if can_strings != None: - vls = self.rcp.update_strings(tm, can_strings) + if can_strings is not None: + vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) - if self.trigger_msg not in self.updated_messages: - return None,None + if self.trigger_start_msg not in self.updated_messages: + return None,None,self.AHB_car_detected + + if self.trigger_end_msg not in self.updated_messages: + return None,None,self.AHB_car_detected - rr,rrext = self._update(self.updated_messages) + rr,rrext,self.AHB_car_detected = self._update(self.updated_messages,v_ego) self.updated_messages.clear() - return rr,rrext + return rr,rrext,self.AHB_car_detected - def _update(self, updated_messages): + def _update(self, updated_messages,v_ego): ret = car.RadarData.new_message() - + AHB_car_detected = False for message in updated_messages: if not(message in RADAR_A_MSGS): if message in self.pts: @@ -99,7 +126,13 @@ def _update(self, updated_messages): del self.extPts[message] continue cpt = self.rcp.vl[message] - if (cpt['LongDist'] >= BOSCH_MAX_DIST) or (cpt['LongDist']==0) or (not cpt['Tracked']): + if not (message + 1 in updated_messages): + continue + cpt2 = self.rcp.vl[message+1] + # ensure the two messages are from the same frame reading + if cpt['Index'] != cpt2['Index2']: + continue + if (cpt['LongDist'] >= BOSCH_MAX_DIST) or (cpt['LongDist']==0) or (not cpt['Tracked']) or (not cpt['Valid']): self.valid_cnt[message] = 0 # reset counter if message in self.pts: del self.pts[message] @@ -107,20 +140,26 @@ def _update(self, updated_messages): elif cpt['Valid'] and (cpt['LongDist'] < BOSCH_MAX_DIST) and (cpt['LongDist'] > 0) and (cpt['ProbExist'] >= OBJECT_MIN_PROBABILITY): self.valid_cnt[message] += 1 else: - self.valid_cnt[message] = max(self.valid_cnt[message] -1, 0) + self.valid_cnt[message] = max(self.valid_cnt[message] -20, 0) if (self.valid_cnt[message]==0) and (message in self.pts): del self.pts[message] del self.extPts[message] - #score = self.rcp.vl[ii+16]['SCORE'] - #print ii, self.valid_cnt[ii], cpt['Valid'], cpt['LongDist'], cpt['LatDist'] - + # this is the logic used for Auto High Beam (AHB) car detection + if (cpt['Valid'] or cpt['Tracked']) and (abs(cpt['LongSpeed']) < 80) and (cpt['LongDist']>0) and (cpt['LongDist'] < AHB_MAX_DISTANCE) and (cpt['LongDist'] < BOSCH_MAX_DIST) and \ + (self.valid_cnt[message] > AHB_VALID_MESSAGE_COUNT_THRESHOLD) and (cpt['ProbExist'] >= AHB_OBJECT_MIN_PROBABILITY) and \ + (cpt2['Class'] < 4) and (cpt2['ProbClass'] >= AHB_CLASS_MIN_PROBABILITY): + # if moving or the relative speed is x% larger than our speed then use to turn high beam off + if ((cpt['LongSpeed'] <= - AHB_STATIONARY_MARGIN - v_ego) or (cpt['LongSpeed'] >= AHB_STATIONARY_MARGIN - v_ego)): + AHB_car_detected = True + if AHB_DEBUG: + print(cpt,cpt2) # radar point only valid if it's a valid measurement and score is above 50 # bosch radar data needs to match Index and Index2 for validity # also for now ignore construction elements if (cpt['Valid'] or cpt['Tracked'])and (cpt['LongDist']>0) and (cpt['LongDist'] < BOSCH_MAX_DIST) and \ - (cpt['Index'] == self.rcp.vl[message+1]['Index2']) and (self.valid_cnt[message] > 5) and \ - (cpt['ProbExist'] >= OBJECT_MIN_PROBABILITY): # and (self.rcp.vl[ii+1]['Class'] < 4): # and ((self.rcp.vl[ii+1]['MovingState']<3) or (self.rcp.vl[ii+1]['Class'] > 0)): + (self.valid_cnt[message] > VALID_MESSAGE_COUNT_THRESHOLD) and (cpt['ProbExist'] >= OBJECT_MIN_PROBABILITY) and \ + (cpt2['Class'] < 4) and ((cpt['LongSpeed'] >= AHB_STATIONARY_MARGIN - v_ego) or (v_ego < 2)): if message not in self.pts and ( cpt['Tracked']): self.pts[message] = car.RadarData.RadarPoint.new_message() self.pts[message].trackId = self.trackId @@ -134,39 +173,46 @@ def _update(self, updated_messages): self.pts[message].yRel = cpt['LatDist'] - self.radarOffset # in car frame's y axis, left is positive self.pts[message].vRel = cpt['LongSpeed'] self.pts[message].aRel = cpt['LongAccel'] - self.pts[message].yvRel = self.rcp.vl[message+1]['LatSpeed'] + self.pts[message].yvRel = cpt2['LatSpeed'] self.pts[message].measured = bool(cpt['Meas']) - self.extPts[message].dz = self.rcp.vl[message+1]['dZ'] - self.extPts[message].movingState = self.rcp.vl[message+1]['MovingState'] - self.extPts[message].length = self.rcp.vl[message+1]['Length'] + self.extPts[message].dz = cpt2['dZ'] + self.extPts[message].movingState = cpt2['MovingState'] + self.extPts[message].length = cpt2['Length'] self.extPts[message].obstacleProb = cpt['ProbObstacle'] - if self.rcp.vl[message+1]['Class'] >= CLASS_MIN_PROBABILITY: - self.extPts[message].objectClass = self.rcp.vl[message+1]['Class'] + self.extPts[message].timeStamp = int(self.rcp.ts[message+1]['Index2']) + if cpt2['ProbClass'] >= CLASS_MIN_PROBABILITY: + self.extPts[message].objectClass = cpt2['Class'] # for now we will use class 0- unknown stuff to show trucks # we will base that on being a class 1 and length of 2 (hoping they meant width not length, but as germans could not decide) # 0-unknown 1-four wheel vehicle 2-two wheel vehicle 3-pedestrian 4-construction element # going to 0-unknown 1-truck 2-car 3/4-motorcycle/bicycle 5 pedestrian - we have two bits so - if self.extPts[message].objectClass == 0: + if cpt2['Class'] == 0: self.extPts[message].objectClass = 1 - if (self.extPts[message].objectClass == 1) and ((self.extPts[message].length >= 1.8) or (1.6 < self.extPts[message].dz < 4.5)): + if (cpt2['Class'] == 1) and ((self.extPts[message].length >= 1.8) or (.6 < self.extPts[message].dz < 4.5)): self.extPts[message].objectClass = 0 - if self.extPts[message].objectClass == 4: - self.extPts[message].objectClass = 1 else: self.extPts[message].objectClass = 1 - ret.points = self.pts.values() + ret.points = list(self.pts.values()) errors = [] if not self.rcp.can_valid: errors.append("canError") - ret.errors = errors - return ret,self.extPts.values() + self.tinklaClient.logCANErrorEvent(source="radar_interface", canMessage=0, additionalInformation="Invalid CAN Count") + self.canErrorCounter += 1 + else: + self.canErrorCounter = 0 + #BB: Only trigger canError for 3 consecutive errors + if self.canErrorCounter > 9: + ret.errors = errors + else: + ret.errors = [] + return ret,self.extPts.values(),AHB_car_detected # radar_interface standalone tester if __name__ == "__main__": - CP = car.CarParams() + CP = None RI = RadarInterface(CP) while 1: - ret,retext = RI.update(can_strings = None) + ret,retext,ahb = RI.update(can_strings = None, v_ego = 0.) print(chr(27) + "[2J") - print(ret) + print(ret,retext) diff --git a/selfdrive/car/tesla/radar_tools/calibrateRadar.py b/selfdrive/car/tesla/radar_tools/calibrateRadar.py index 0289935a9eaa85..30dab80c4fe5c6 100644 --- a/selfdrive/car/tesla/radar_tools/calibrateRadar.py +++ b/selfdrive/car/tesla/radar_tools/calibrateRadar.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys try: sys.path.index('/data/openpilot/') @@ -8,144 +8,40 @@ from cereal import car import time import os -import zmq -from selfdrive.can.parser import CANParser +from opendbc.can.parser import CANParser from common.realtime import sec_since_boot -from selfdrive.services import service_list -import selfdrive.messaging as messaging +from cereal.services import service_list +import cereal.messaging as messaging from selfdrive.car.tesla.readconfig import read_config_file,CarSettings +from selfdrive.car.tesla.radar_interface import RadarInterface -#RADAR_A_MSGS = list(range(0x371, 0x37F , 3)) -#RADAR_B_MSGS = list(range(0x372, 0x37F, 3)) -BOSCH_MAX_DIST = 150. #max distance for radar -RADAR_A_MSGS = list(range(0x310, 0x36F , 3)) -RADAR_B_MSGS = list(range(0x311, 0x36F, 3)) -OBJECT_MIN_PROBABILITY = 20. -CLASS_MIN_PROBABILITY = 20. #for calibration we only want fixed objects within 1 m of the center line and between 2.5 and 4.5 m far from radar MINX = 2.5 -MAXX = 4.5 +MAXX = 14.5 MINY = -1.0 MAXY = 1.0 - -# Tesla Bosch firmware has 32 objects in all objects or a selected set of the 5 we should look at -# definetly switch to all objects when calibrating but most likely use select set of 5 for normal use -USE_ALL_OBJECTS = True - -def _create_radard_can_parser(): - dbc_f = 'teslaradar.dbc' - - msg_a_n = len(RADAR_A_MSGS) - msg_b_n = len(RADAR_B_MSGS) - - signals = zip(['LongDist'] * msg_a_n + ['LatDist'] * msg_a_n + - ['LongSpeed'] * msg_a_n + ['LongAccel'] * msg_a_n + - ['Valid'] * msg_a_n + ['Tracked'] * msg_a_n + - ['Meas'] * msg_a_n + ['ProbExist'] * msg_a_n + - ['Index'] * msg_a_n + ['ProbObstacle'] * msg_a_n + - ['LatSpeed'] * msg_b_n + ['Index2'] * msg_b_n + - ['Class'] * msg_b_n + ['ProbClass'] * msg_b_n + - ['Length'] * msg_b_n + ['dZ'] * msg_b_n + ['MovingState'] * msg_b_n, - RADAR_A_MSGS * 10 + RADAR_B_MSGS * 7, - [255.] * msg_a_n + [0.] * msg_a_n + [0.] * msg_a_n + [0.] * msg_a_n + - [0] * msg_a_n + [0] * msg_a_n + [0] * msg_a_n + [0.] * msg_a_n + - [0] * msg_a_n + [0.] * msg_a_n + [0.] * msg_b_n + [0] * msg_b_n + - [0] * msg_b_n + [0.] * msg_b_n + [0.] * msg_b_n +[0.] * msg_b_n + [0]* msg_b_n) - - checks = zip(RADAR_A_MSGS + RADAR_B_MSGS, [20]*(msg_a_n + msg_b_n)) - - return CANParser(os.path.splitext(dbc_f)[0], signals, checks, 1) - - -class RadarInterface(object): - def __init__(self): - # radar - self.pts = {} - self.delay = 0.1 - self.useTeslaRadar = CarSettings().get_value("useTeslaRadar") - self.TRACK_LEFT_LANE = True - self.TRACK_RIGHT_LANE = True - if self.useTeslaRadar: - self.pts = {} - self.valid_cnt = {key: 0 for key in RADAR_A_MSGS} - self.delay = 0.05 # Delay of radar - self.rcp = _create_radard_can_parser() - self.logcan = messaging.sub_sock(service_list['can'].port) - - def update(self): - - ret = car.RadarData.new_message() - if not self.useTeslaRadar: - time.sleep(0.05) - return ret - - canMonoTimes = [] - updated_messages = set() - while 1: - tm = int(sec_since_boot() * 1e9) - _ , vls = self.rcp.update(tm, True) - updated_messages.update(vls) - if RADAR_B_MSGS[-1] in updated_messages: - break - errors = [] - if not self.rcp.can_valid: - errors.append("commIssue") - ret.errors = errors - ret.canMonoTimes = canMonoTimes - for ii in updated_messages: - if ii in RADAR_A_MSGS: - cpt = self.rcp.vl[ii] - if (cpt['LongDist'] >= BOSCH_MAX_DIST) or (cpt['LongDist']==0) or (not cpt['Tracked']): - self.valid_cnt[ii] = 0 # reset counter - elif cpt['Valid'] and (cpt['LongDist'] < BOSCH_MAX_DIST) and (cpt['LongDist'] > 0) and (cpt['ProbExist'] >= OBJECT_MIN_PROBABILITY): - self.valid_cnt[ii] += 1 - else: - self.valid_cnt[ii] = max(self.valid_cnt[ii] -1, 0) - - if (cpt['Valid'] or cpt['Tracked'])and (cpt['LongDist']>=MINX) and (cpt['LongDist'] <= MAXX) and \ - (cpt['Index'] == self.rcp.vl[ii+1]['Index2']) and (self.valid_cnt[ii] > 4) and \ - (cpt['ProbExist'] >= OBJECT_MIN_PROBABILITY) and (cpt['LatDist']>=MINY) and (cpt['LatDist']<=MAXY): - if ii not in self.pts and ( cpt['Tracked']): - self.pts[ii] = car.RadarData.RadarPoint.new_message() - self.pts[ii].trackId = int((ii - 0x310)/3) - if ii in self.pts: - self.pts[ii].dRel = cpt['LongDist'] # from front of car - self.pts[ii].yRel = cpt['LatDist'] # in car frame's y axis, left is positive - self.pts[ii].vRel = cpt['LongSpeed'] - self.pts[ii].aRel = cpt['LongAccel'] - self.pts[ii].yvRel = self.rcp.vl[ii+1]['LatSpeed'] - self.pts[ii].measured = bool(cpt['Meas']) - self.pts[ii].dz = self.rcp.vl[ii+1]['dZ'] - self.pts[ii].movingState = self.rcp.vl[ii+1]['MovingState'] - self.pts[ii].length = self.rcp.vl[ii+1]['Length'] - self.pts[ii].obstacleProb = cpt['ProbObstacle'] - if self.rcp.vl[ii+1]['Class'] >= CLASS_MIN_PROBABILITY: - self.pts[ii].objectClass = self.rcp.vl[ii+1]['Class'] - # for now we will use class 0- unknown stuff to show trucks - # we will base that on being a class 1 and length of 2 (hoping they meant width not length, but as germans could not decide) - # 0-unknown 1-four wheel vehicle 2-two wheel vehicle 3-pedestrian 4-construction element - # going to 0-unknown 1-truck 2-car 3/4-motorcycle/bicycle 5 pedestrian - we have two bits so - if self.pts[ii].objectClass == 0: - self.pts[ii].objectClass = 1 - if (self.pts[ii].objectClass == 1) and ((self.pts[ii].length >= 1.8) or (1.6 < self.pts[ii].dz < 4.5)): - self.pts[ii].objectClass = 0 - if self.pts[ii].objectClass == 4: - self.pts[ii].objectClass = 1 - else: - self.pts[ii].objectClass = 1 - else: - if ii in self.pts: - del self.pts[ii] - - ret.points = self.pts.values() - return ret - - +def get_rrext_by_trackId(rrext,trackId): + if rrext is not None: + for p in rrext: + if p.trackId == trackId: + return p + return None if __name__ == "__main__": - RI = RadarInterface() + CP = None + RI = RadarInterface(CP) + can_sock = messaging.sub_sock('can') while 1: - ret = RI.update() + can_strings = messaging.drain_sock_raw(can_sock, wait_for_one=True) + rr,rrext,ahb = RI.update(can_strings,0.) + + if (rr is None) or (rrext is None): + continue + print(chr(27) + "[2J") - print ret + + for pt in rr.points: + if (pt.dRel >= MINX) and (pt.dRel <= MAXX) and (pt.yRel >= MINY) and (pt.yRel <= MAXY): + extpt = get_rrext_by_trackId(rrext,pt.trackId) + print (pt,extpt) diff --git a/selfdrive/car/tesla/radar_tools/readRadarVin.py b/selfdrive/car/tesla/radar_tools/readRadarVin.py old mode 100644 new mode 100755 index cffd811455865a..0bcebfa275c6f9 --- a/selfdrive/car/tesla/radar_tools/readRadarVin.py +++ b/selfdrive/car/tesla/radar_tools/readRadarVin.py @@ -1,8 +1,8 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import time import struct from enum import IntEnum -from Queue import Queue, Empty +from queue import Queue, Empty import threading from binascii import hexlify @@ -134,7 +134,7 @@ def _isotp_thread(panda, bus, tx_addr, tx_queue, rx_queue): # send flow control message (send all bytes) msg = "\x30\x00\x00".ljust(8, "\x00") if (DEBUG): print("S: {} {}".format(hex(tx_addr), hexlify(msg))) - panda.can_send(tx_addr, msg, bus) + panda.can_send(tx_addr, msg.encode('utf-8'), bus) elif rx_data[0] >> 4 == 0x2: # consecutive rx frame assert rx_frame["done"] == False, "rx: no active frame" @@ -158,9 +158,9 @@ def _isotp_thread(panda, bus, tx_addr, tx_queue, rx_queue): for i in range(start, end, 7): tx_frame["idx"] += 1 # consecutive tx frames - msg = (chr(0x20 | (tx_frame["idx"] & 0xF)) + tx_frame["data"][i:i+7]).ljust(8, "\x00") + msg = (chr(0x20 | (tx_frame["idx"] & 0xF)) + tx_frame["data"][i:i+7]).ljust(8, b'\0') if (DEBUG): print("S: {} {}".format(hex(tx_addr), hexlify(msg))) - panda.can_send(tx_addr, msg, bus) + panda.can_send(tx_addr, msg.encode('utf-8'), bus) tx_frame["done"] = True if not tx_queue.empty(): @@ -171,15 +171,15 @@ def _isotp_thread(panda, bus, tx_addr, tx_queue, rx_queue): if tx_frame["size"] < 8: # single frame tx_frame["done"] = True - msg = (chr(tx_frame["size"]) + tx_frame["data"]).ljust(8, "\x00") + msg = (chr(tx_frame["size"]).encode("utf-8") + tx_frame["data"]).ljust(8, b'\0') if (DEBUG): print("S: {} {}".format(hex(tx_addr), hexlify(msg))) panda.can_send(tx_addr, msg, bus) else: # first rx_frame tx_frame["done"] = False - msg = (struct.pack("!H", 0x1000 | tx_frame["size"]) + tx_frame["data"][:6]).ljust(8, "\x00") + msg = (struct.pack("!H", 0x1000 | tx_frame["size"]) + tx_frame["data"][:6]).ljust(8, b'\0') if (DEBUG): print("S: {} {}".format(hex(tx_addr), hexlify(msg))) - panda.can_send(tx_addr, msg, bus) + panda.can_send(tx_addr, msg.encode('utf-8'), bus) else: time.sleep(0.01) finally: @@ -187,9 +187,9 @@ def _isotp_thread(panda, bus, tx_addr, tx_queue, rx_queue): # generic uds request def _uds_request(address, service_type, subfunction=None, data=None): - req = chr(service_type) + req = chr(service_type).encode('utf-8') if subfunction is not None: - req += chr(subfunction) + req += chr(subfunction).encode('utf-8') if data is not None: req += data tx_queue.put(req) @@ -198,7 +198,8 @@ def _uds_request(address, service_type, subfunction=None, data=None): try: resp = rx_queue.get(block=True, timeout=10) except Empty: - raise MessageTimeoutError("timeout waiting for response") + print("** Timeout waiting for response. Make sure ignition line is on.") + exit(1) resp_sid = resp[0] if len(resp) > 0 else None # negative response @@ -710,30 +711,30 @@ def request_transfer_exit(address): diagnostic_session_control(tx_addr, SESSION_TYPE.EXTENDED_DIAGNOSTIC) print("reading VIN from radar...") vin = read_data_by_identifier(tx_addr, DATA_IDENTIFIER_TYPE.VIN) - print("new VIN: {} [{}]".format(vin, hexlify(vin))) + print("new VIN: {} [{}]".format(vin.decode("utf-8"), hexlify(vin))) vin = read_data_by_identifier(tx_addr, 0xA022) - print("plant mode: {} [{}]".format(vin, hexlify(vin))) + print("plant mode: {} [{}]".format(vin.decode("utf-8"), hexlify(vin))) vin = read_data_by_identifier(tx_addr, 0xF014) - print("board part #: {} [{}]".format(vin, hexlify(vin))) + print("board part #: {} [{}]".format(vin.decode("utf-8"), hexlify(vin))) vin = read_data_by_identifier(tx_addr, 0xF015) - print("board ser #: {} [{}]".format(vin, hexlify(vin))) + print("board ser #: {} [{}]".format(vin.decode("utf-8"), hexlify(vin))) vin = read_data_by_identifier(tx_addr, 0xFC01) - print("Active alignment horizontal angle: {} [{}]".format(vin, hexlify(vin))) + print("Active alignment horizontal angle: {} [{}]".format(vin.decode("utf-8"), hexlify(vin))) vin = read_data_by_identifier(tx_addr, 0x508) - print("Active Alignment Horizontal Screw: {} [{}]".format(vin, hexlify(vin))) + print("Active Alignment Horizontal Screw: {} [{}]".format(vin.decode("utf-8"), hexlify(vin))) vin = read_data_by_identifier(tx_addr, 0x505) - print("Active Alignment State: {} [{}]".format(vin, hexlify(vin))) + print("Active Alignment State: {} [{}]".format(vin.decode("utf-8"), hexlify(vin))) vin = read_data_by_identifier(tx_addr, 0xFC02) - print("Active Alignment Vertical Angle: {} [{}]".format(vin, hexlify(vin))) + print("Active Alignment Vertical Angle: {} [{}]".format(vin.decode("utf-8"), hexlify(vin))) vin = read_data_by_identifier(tx_addr, 0x507) - print("Active Alignment Vertical Screw: {} [{}]".format(vin, hexlify(vin))) + print("Active Alignment Vertical Screw: {} [{}]".format(vin.decode("utf-8"), hexlify(vin))) vin = read_data_by_identifier(tx_addr, 0x506) - print("Active Alignment Operation: {} [{}]".format(vin, hexlify(vin))) + print("Active Alignment Operation: {} [{}]".format(vin.decode("utf-8"), hexlify(vin))) vin = read_data_by_identifier(tx_addr, 0x50A) - print("Service Drive Alignment State: {} [{}]".format(vin, hexlify(vin))) + print("Service Drive Alignment State: {} [{}]".format(vin.decode("utf-8"), hexlify(vin))) vin = read_data_by_identifier(tx_addr, 0x509) - print("Service Drive Alignment Status: {} [{}]".format(vin, hexlify(vin))) + print("Service Drive Alignment Status: {} [{}]".format(vin.decode("utf-8"), hexlify(vin))) print("reading variables from radar...") for i in range(0xF100, 0xF2FF): diff --git a/selfdrive/car/tesla/readconfig.py b/selfdrive/car/tesla/readconfig.py index 22c65d08b02506..023f132c909aa4 100644 --- a/selfdrive/car/tesla/readconfig.py +++ b/selfdrive/car/tesla/readconfig.py @@ -1,399 +1,550 @@ -import ConfigParser - -default_config_file_path = '/data/bb_openpilot.cfg' - -class ConfigFile(object): - config_file_r = 'r' - config_file_w = 'wb' - - ### Do NOT modify here, modify in /data/bb_openpilot.cfg and reboot - def read(self, into, config_path): - configr = ConfigParser.ConfigParser() - file_changed = False - - try: - configr.read(config_path) - fd = open(config_path, "r") - prev_file_contents = fd.read() - fd.close() - except IOError: - prev_file_contents = "" - print("no config file, creating with defaults...") - - main_section = 'OP_CONFIG' - config = ConfigParser.RawConfigParser(allow_no_value=True) - config.add_section(main_section) - - #user_handle -> userHandle - into.userHandle, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'user_handle', entry_type = str, - default_value = 'your_tinkla_username', - comment = 'Username at tinkla.com, for dashboard data and support. If you don\'t have a username, ask for one on Discord, or just enter your Discord handle here.' - ) - file_changed |= didUpdate - - #force_fingerprint_tesla -> forceFingerprintTesla - into.forceFingerprintTesla, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'force_fingerprint_tesla', entry_type = bool, - default_value = False, - comment = 'Forces the fingerprint to Tesla Model S if OpenPilot fails to identify car via fingerprint.' - ) - file_changed |= didUpdate - - #eon_to_front -> eonToFront - into.eonToFront, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'eon_to_front', entry_type = float, - default_value = 0.9, - comment = 'Distance between EON plane and front of the car.' - ) - file_changed |= didUpdate - - #force_pedal_over_cc -> forcePedalOverCC - into.forcePedalOverCC, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'force_pedal_over_cc', entry_type = bool, - default_value = False, - comment = 'Forces the use of Tesla Pedal over ACC completely disabling the Tesla CC' - ) - file_changed |= didUpdate - - #enable_hso -> enableHSO - into.enableHSO, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'enable_hso', entry_type = bool, - default_value = True, - comment = 'Enables Human Steering Override (HSO) feature which allows you to take control of the steering wheel and correct the course of the car without disengaging OpenPilot lane keep assis (LKS, lateral control)' - ) - file_changed |= didUpdate - - #enable_das_emulation -> enableDasEmulation - into.enableALCA, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'enable_alca', entry_type = bool, - default_value = True, - comment = 'Enables the Adaptive Lane Change Assist (ALCA) feature which will automatically change lanes when driving above 18 MPH (29 km/h) by just pushing 1/2 way on your turn signal stalk; turn signal will remain on for the duration of lane change' - ) - file_changed |= didUpdate - - #enable_das_emulation -> enableDasEmulation - into.enableDasEmulation, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'enable_das_emulation', entry_type = bool, - default_value = False, - comment = 'The secret sauce of IC/CID integration; this feature makes the Panda generate all the CAN messages needed for IC/CID integration that mimiinto the AP interface' - ) - file_changed |= didUpdate - - #enable_radar_emulation -> enableRadarEmulation - into.enableRadarEmulation, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'enable_radar_emulation', entry_type = bool, - default_value = False, - comment = 'The secret sauce to make the Tesla Radar work; this feature make the Panda generate all the CAN messages needed by the Tesla Bosch Radar to operate' - ) - file_changed |= didUpdate - - #enable_roll_angle_correction -> enableRollAngleCorrection - into.enableSpeedVariableDesAngle, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'enable_speed_variable_angle', entry_type = bool, - default_value = True, - comment = '' - ) - file_changed |= didUpdate - - #enable_roll_angle_correction -> enableRollAngleCorrection - into.enableRollAngleCorrection, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'enable_roll_angle_correction', entry_type = bool, - default_value = False, - comment = '' - ) - file_changed |= didUpdate - - #enable_feed_forward_angle_correction -> enableFeedForwardAngleCorrection - into.enableFeedForwardAngleCorrection, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'enable_feed_forward_angle_correction', entry_type = bool, - default_value = True, - comment = '' - ) - file_changed |= didUpdate - - #enable_driver_monitor -> enableDriverMonitor - into.enableDriverMonitor, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'enable_driver_monitor', entry_type = bool, - default_value = True, - comment = 'When turned off, the OpenPilot is tricked into thinking you have the hands on the sterring wheel all the time' - ) - file_changed |= didUpdate - - #enable_show_car -> enableShowCar - into.enableShowCar, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'enable_show_car', entry_type = bool, - default_value = True, - comment = 'Shows a Tesla car in the limitted UI mode instead of the triangle that identifies the lead car; this is only used if you do not have IC/CID integration' - ) - file_changed |= didUpdate - - #enable_show_logo -> enableShowLogo - into.enableShowLogo, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'enable_show_logo', entry_type = bool, - default_value = True, - comment = 'Shows a Tesla red logo on the EON screen when OP is not enabled' - ) - file_changed |= didUpdate - - #has_noctua_fan -> hasNoctuaFan - into.hasNoctuaFan, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'has_noctua_fan', entry_type = bool, - default_value = False, - comment = 'Enables control of Noctua fan (at higher RPMS) when you have a Noctua fan installed' - ) - file_changed |= didUpdate - - #limit_battery_minmax -> limitBatteryMinMax - into.limitBatteryMinMax, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'limit_battery_minmax', entry_type = bool, - default_value = True, - comment = 'Enables battery charging limits; the battery will start charging when battery percentage is below limit_battery_min and will stop charging when battery percentage is above limit_battery_max' - ) - file_changed |= didUpdate - - #limit_battery_min -> limitBattery_Min - into.limitBattery_Min, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'limit_battery_min', entry_type = int, - default_value = 60, - comment = 'See limit_battery_minmax' - ) - file_changed |= didUpdate - - #limitBattery_Max -> limitBattery_Max - into.limitBattery_Max, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'limit_battery_max', entry_type = int, - default_value = 80, - comment = 'See limit_battery_minmax' - ) - file_changed |= didUpdate - - #block_upload_while_tethering -> blockUploadWhileTethering - into.blockUploadWhileTethering, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'block_upload_while_tethering', entry_type = bool, - default_value = False, - comment = 'This setting will block uploading OP videos to Comma when you are tethering through the phone. You should set the tether_ip to the first 3 values that your phone provides as IP when you tether. This is phone/carrier specific. For example iPhone give addresses like 172.20.10.x so you would enter 172.20.10.' - ) - file_changed |= didUpdate - - #tether_ip -> tetherIP - into.tetherIP, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'tether_ip', entry_type = str, - default_value = "127.0.0.", - comment = 'See block_upload_while_tethering' - ) - file_changed |= didUpdate - - #use_tesla_gps -> useTeslaGPS - into.useTeslaGPS, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'use_tesla_gps', entry_type = bool, - default_value = False, - comment = 'This setting makes OP to use Tesla GPS data instead of the GPS that comes with the gray panda; both GPS systems use Ublox and both are very close in accuracy; this also allows one to use a White Panda and still have map integration' - ) - file_changed |= didUpdate - - #use_tesla_map_data -> useTeslaMapData - into.useTeslaMapData, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'use_tesla_map_data', entry_type = bool, - default_value = False, - comment = 'This setting (which requires root) allows OP to use Tesla navigation map data (under development)' - ) - file_changed |= didUpdate - - #has_tesla_ic_integration -> hasTeslaIcIntegration - into.hasTeslaIcIntegration, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'has_tesla_ic_integration', entry_type = bool, - default_value = False, - comment = 'This setting (in conjunction with enable_radar_emulation) help create the IC integration' - ) - file_changed |= didUpdate - - #use_tesla_radar -> useTeslaRadar - into.useTeslaRadar, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'use_tesla_radar', entry_type = bool, - default_value = False, - comment = 'Set this setting to True if you have a Tesla Bosch Radar installed (works in conjunction with enable_radar_emulation)' - ) - file_changed |= didUpdate - - #use_without_harness = useWithoutHarness - into.useWithoutHarness, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'use_without_harness', entry_type = bool, - default_value = False, - comment = 'Not used at the moment; should be False' - ) - file_changed |= didUpdate - - #radar_vin -> into.radarVIN - default_radar_vin = '" "' - into.radarVIN, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'radar_vin', entry_type = str, - default_value = default_radar_vin, - comment = 'If you used an aftermarket Tesla Bosch Radar that already has a coded VIN, you will have to enter that VIN value here' - ) - file_changed |= didUpdate - if into.radarVIN == '': - into.radarVIN = default_radar_vin - file_changed = True - - #enable_ldw = enableLdw - into.enableLdw, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'enable_ldw', entry_type = bool, - default_value = True, - comment = 'Enable the Lane Departure Warning (LDW) feature; this feature warns the driver is the car gets too close to one of the lines when driving above 45 MPH (72 km/h) without touching the steering wheel and when the turn signal is off' - ) - file_changed |= didUpdate - - #radar_offset -> radarOffset - into.radarOffset, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'radar_offset', entry_type = float, - default_value = 0, - comment = 'If your Tesla Bosch Radar is not centered on the car, this value will allow to enter a correction offset' - ) - file_changed |= didUpdate - - #radar_epas_type -> radarEpasType - into.radarEpasType, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'radar_epas_type', entry_type = int, - default_value = 0, - comment = 'Depending on the source of your Tesla Bosch Radar (older or newer Model S or Model X), this setting has to match what the radar was programmed to recognize as EPAS; values are between 0 and 4; finding the right one is trial and error' - ) - file_changed |= didUpdate - - #radar_position -> radarPosition - into.radarPosition, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'radar_position', entry_type = int, - default_value = 0, - comment = 'Depending on the source of your Tesla Bosch Radar (older or newer Model S or Model X), this setting has to match what the radar was programmed to have a position (Model S, Model S facelift, Model X); values are between 0 and 3; finding the right one is trial and error' - ) - file_changed |= didUpdate - - #fix_1916 -> fix1916 - into.fix1916, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'fix_1916', entry_type = bool, - default_value = False, - comment = 'Set this value to True if you are running Tesla software v2019.16 and above. This fixes the DI_state can message change for DI_cruiseSet which changed from 9 bits to 8 bits' - ) - file_changed |= didUpdate - - #do_auto_update -> doAutoUpdate - into.doAutoUpdate, didUpdate = self.read_config_entry( - config, configr, prev_file_contents, section = main_section, - entry = 'do_auto_update', entry_type = bool, - default_value = True, - comment = 'Set this setting to False if you do not want OP to autoupdate every time you reboot and there is a change on the repo' - ) - file_changed |= didUpdate - - if file_changed: - did_write = True - with open(config_path, self.config_file_w) as configfile: - config.write(configfile) - else: - did_write = False - - # Remove double quotes from VIN (they are required for empty case) - into.radarVIN = into.radarVIN.replace('"', '') - return did_write - - def read_config_entry(self, config, configr, prev_file_contents, section, entry, entry_type, default_value, comment): - updated = self.update_comment(config, prev_file_contents, section, entry, default_value, comment) - result = None - try: - if entry_type == bool: - result = configr.getboolean(section, entry) - elif entry_type == int: - result = configr.getint(section, entry) - elif entry_type == float: - result = configr.getfloat(section, entry) - else: - result = configr.get(section, entry) - except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): - result = default_value - updated = True - config.set(section, entry, result) - return result, updated - - def update_comment(self, config, prev_file_contents, section, entry, default_value, comment): - new_comment = ("# " + entry + ": " + comment + " (Default: " + str(default_value) + ")").lower() - config.set(section, new_comment) - updated = (prev_file_contents.find(new_comment) == -1) - return updated - -class CarSettings(object): - - userHandle = None - forceFingerprintTesla = None - eonToFront = None - forcePedalOverCC = None - enableHSO = None - enableALCA = None - enableDasEmulation = None - enableRadarEmulation = None - enableSpeedVariableDesAngle = None - enableRollAngleCorrection = None - enableFeedForwardAngleCorrection = None - enableDriverMonitor = None - enableShowCar = None - enableShowLogo = None - hasNoctuaFan = None - limitBatteryMinMax = None - limitBattery_Min = None - limitBattery_Max = None - blockUploadWhileTethering = None - tetherIP = None - useTeslaGPS = None - useTeslaMapData = None - hasTeslaIcIntegration = None - useTeslaRadar = None - useWithoutHarness = None - radarVIN = None - enableLdw = None - radarOffset = None - radarEpasType = None - radarPosition = None - fix1916 = None - doAutoUpdate = None - - def __init__(self, optional_config_file_path = default_config_file_path): - config_file = ConfigFile() - self.did_write_file = config_file.read(self, config_path = optional_config_file_path) - - def get_value(self, name_of_variable): - return self.__dict__[name_of_variable] - -# Legacy support -def read_config_file(into, config_path = default_config_file_path): - config_file = ConfigFile() - config_file.read(into, config_path) +import configparser +from common.params import Params +import subprocess +from common.basedir import BASEDIR + +default_config_file_path = '%s/../bb_openpilot.cfg' % BASEDIR + +class ConfigFile(): + config_file_r = 'r' + config_file_w = 'w' + + ### Do NOT modify here, modify in /data/bb_openpilot.cfg and reboot + def read(self, into, config_path): + configr = configparser.RawConfigParser() + file_changed = False + params = Params() + + try: + configr.read(config_path) + fd = open(config_path, "r") + prev_file_contents = fd.read() + fd.close() + except IOError: + prev_file_contents = "" + print("no config file, creating with defaults...") + + main_section = 'OP_CONFIG' + pref_section = 'OP_PREFERENCES' + jetson_section = 'JETSON_PREFERENCES' + logging_section = 'LOGGING' + config = configparser.RawConfigParser(allow_no_value=True) + config.add_section(main_section) + config.add_section(pref_section) + config.add_section(jetson_section) + config.add_section(logging_section) + + #user_handle -> userHandle + into.userHandle, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'user_handle', entry_type = str, + default_value = 'your_tinkla_username', + comment = 'Username at tinkla.us, for dashboard data and support. If you don\'t have a username, ask for one on Discord, or just enter your Discord handle here.' + ) + file_changed |= didUpdate + + #force_fingerprint_tesla -> forceFingerprintTesla + into.forceFingerprintTesla, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'force_fingerprint_tesla', entry_type = bool, + default_value = False, + comment = 'Forces the fingerprint to Tesla Model S if OpenPilot fails to identify car via fingerprint.' + ) + file_changed |= didUpdate + + #uses_a_pillar_harness -> usesApillarHarness + into.usesApillarHarness, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'uses_a_pillar_harness', entry_type = bool, + default_value = False, + comment = 'Enable when using the new A pillar harness.' + ) + file_changed |= didUpdate + + #force_pedal_over_cc -> forcePedalOverCC + into.forcePedalOverCC, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'force_pedal_over_cc', entry_type = bool, + default_value = False, + comment = 'Forces the use of Tesla Pedal over ACC completely disabling the Tesla CC.' + ) + file_changed |= didUpdate + + #enable_hso -> enableHSO + into.enableHSO, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'enable_hso', entry_type = bool, + default_value = True, + comment = 'Enables Human Steering Override (HSO) feature which allows you to take control of the steering wheel and correct the course of the car without disengaging OpenPilot lane keep assist (LKS, lateral control).' + ) + file_changed |= didUpdate + + #enable_alca -> enableALCA + into.enableALCA, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'enable_alca', entry_type = bool, + default_value = True, + comment = 'Enables the Adaptive Lane Change Assist (ALCA) feature which will automatically change lanes when driving above 18 MPH (29 km/h) by just pushing 1/2 way on your turn signal stalk; turn signal will remain on for the duration of lane change.' + ) + file_changed |= didUpdate + + #enable_das_emulation -> enableDasEmulation + into.enableDasEmulation, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'enable_das_emulation', entry_type = bool, + default_value = False, + comment = 'The secret sauce of IC/CID integration; this feature makes the Panda generate all the CAN messages needed for IC/CID integration that mimic the AP interface.' + ) + file_changed |= didUpdate + + #enable_radar_emulation -> enableRadarEmulation + into.enableRadarEmulation, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'enable_radar_emulation', entry_type = bool, + default_value = False, + comment = 'The secret sauce to make the Tesla Radar work; this feature makes the Panda generate all the CAN messages needed by the Tesla Bosch Radar to operate.' + ) + file_changed |= didUpdate + + #enable_driver_monitor -> enableDriverMonitor + into.enableDriverMonitor, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = pref_section, + entry = 'enable_driver_monitor', entry_type = bool, + default_value = True, + comment = 'Disable driver monitoring at your own risk, might get you banned from comma.ai' + ) + file_changed |= didUpdate + + #throttle_driver_monitor -> throttleDriverMonitor + into.throttleDriverMonitor, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = pref_section, + entry = 'throttle_driver_monitor', entry_type = bool, + default_value = False, + comment = 'Throttle driver monitoring so it consumes less cpu cycles' + ) + file_changed |= didUpdate + + #has_noctua_fan -> hasNoctuaFan + into.hasNoctuaFan, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'has_noctua_fan', entry_type = bool, + default_value = False, + comment = 'Enables control of Noctua fan (at higher RPMS) when you have a Noctua fan installed on an offcial EON fan control module. (Doesn\'t work for FrEONs with Noctua fans.)' + ) + file_changed |= didUpdate + + #limit_battery_minmax -> limitBatteryMinMax + into.limitBatteryMinMax, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'limit_battery_minmax', entry_type = bool, + default_value = True, + comment = 'Enables battery charging limits; the battery will start charging when battery percentage is below limit_battery_min and will stop charging when battery percentage is above limit_battery_max.' + ) + file_changed |= didUpdate + + #limit_battery_min -> limitBattery_Min + into.limitBattery_Min, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'limit_battery_min', entry_type = int, + default_value = 60, + comment = 'See limit_battery_minmax.' + ) + file_changed |= didUpdate + + #limitBattery_Max -> limitBattery_Max + into.limitBattery_Max, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'limit_battery_max', entry_type = int, + default_value = 80, + comment = 'See limit_battery_minmax.' + ) + file_changed |= didUpdate + + #block_upload_while_tethering -> blockUploadWhileTethering + into.blockUploadWhileTethering, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'block_upload_while_tethering', entry_type = bool, + default_value = False, + comment = 'This setting will block uploading OP videos to Comma when you are tethering through a phone or specified network address. You should set the tether_ip to the first 3 values that your phone provides as IP when you tether. This is phone/carrier specific. For example iPhone addresses start with 172.20.10.x so you would enter 172.20.10.' + ) + file_changed |= didUpdate + + #tether_ip -> tetherIP + into.tetherIP, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'tether_ip', entry_type = str, + default_value = "127.0.0.", + comment = 'See block_upload_while_tethering.' + ) + file_changed |= didUpdate + + #use_tesla_gps -> useTeslaGPS + into.useTeslaGPS, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'use_tesla_gps', entry_type = bool, + default_value = False, + comment = 'This setting forces OP to use Tesla GPS data instead of the GPS that comes with the gray panda; both GPS systems use Ublox and both are very close in accuracy; this also allows one to use a White Panda and still have map integration.' + ) + file_changed |= didUpdate + + #use_tesla_map_data -> useTeslaMapData + into.useTeslaMapData, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'use_tesla_map_data', entry_type = bool, + default_value = False, + comment = 'This setting (which requires root) allows OP to use Tesla navigation map data. (under development)' + ) + file_changed |= didUpdate + + #has_tesla_ic_integration -> hasTeslaIcIntegration + into.hasTeslaIcIntegration, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'has_tesla_ic_integration', entry_type = bool, + default_value = False, + comment = 'This setting (in conjunction with enable_radar_emulation) helps create the IC integration' + ) + file_changed |= didUpdate + + #use_tesla_radar -> useTeslaRadar + into.useTeslaRadar, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'use_tesla_radar', entry_type = bool, + default_value = False, + comment = 'Set this setting to True if you have a Tesla Bosch Radar installed (works in conjunction with enable_radar_emulation).' + ) + file_changed |= didUpdate + + #use_without_harness = useWithoutHarness + into.useWithoutHarness, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'use_without_harness', entry_type = bool, + default_value = False, + comment = 'Not used at the moment; should be False.' + ) + file_changed |= didUpdate + + #radar_vin -> into.radarVIN + default_radar_vin = '" "' + into.radarVIN, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'radar_vin', entry_type = str, + default_value = default_radar_vin, + comment = 'If you use an aftermarket Tesla Bosch Radar that already has a coded VIN, you will have to enter that VIN value here.' + ) + file_changed |= didUpdate + + if into.radarVIN == '': + into.radarVIN = default_radar_vin + file_changed = True + + #radar_offset -> radarOffset + into.radarOffset, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'radar_offset', entry_type = float, + default_value = 0, + comment = 'If your Tesla Bosch Radar is not centered on the car, this value will allow to enter a correction offset.' + ) + file_changed |= didUpdate + + #radar_epas_type -> radarEpasType + into.radarEpasType, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'radar_epas_type', entry_type = int, + default_value = 0, + comment = 'Depending on the source of your Tesla Bosch Radar (older or newer Model S or Model X), this setting has to match what the radar was programmed to recognize as EPAS; values are between 0 and 4; finding the right one is trial and error.' + ) + file_changed |= didUpdate + + #radar_position -> radarPosition + into.radarPosition, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'radar_position', entry_type = int, + default_value = 0, + comment = 'Depending on the source of your Tesla Bosch Radar (older or newer Model S or Model X), this setting has to match what the radar was programmed to have a position (Model S, Model S facelift, Model X); values are between 0 and 3; finding the right one is trial and error.' + ) + file_changed |= didUpdate + + #fix_1916 -> fix1916 + into.fix1916, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'fix_1916', entry_type = bool, + default_value = True, + comment = 'Set this value to False if you are running Tesla software earlier than v2019.16. This fixes the DI_state can message change for DI_cruiseSet which changed in 2019.16 from 9 bits to 8 bits.' + ) + file_changed |= didUpdate + + #do_auto_update -> doAutoUpdate + into.doAutoUpdate, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = main_section, + entry = 'do_auto_update', entry_type = bool, + default_value = True, + comment = 'Set this setting to False if you do not want OP to autoupdate every time you reboot and there is a change on the repo.' + ) + file_changed |= didUpdate + + #spiner_text -> spinnerText + into.spinnerText, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = pref_section, + entry = 'spinner_text', entry_type = str, + default_value = '%d', + comment = 'Here you can customize the text that is shown for the spinner when OP is loading from boot. %d is the current loading percentage.' + ) + file_changed |= didUpdate + + #hso_numb_period -> hsoNumbPeriod + into.hsoNumbPeriod, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = pref_section, + entry = 'hso_numb_period', entry_type = float, + default_value = 1.5, + comment = 'Seconds to delay the reengagement of LKAS after turn signal has been used. Time starts when the turn signal is turned on.' + ) + file_changed |= didUpdate + + #enable_ldw = enableLdw + into.enableLdw, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = pref_section, + entry = 'enable_ldw', entry_type = bool, + default_value = True, + comment = 'Enable the Lane Departure Warning (LDW) feature; this feature warns the driver if the car gets too close to one of the lane lines when driving above 35 MPH (57 km/h) without touching the steering wheel or when the turn signal is off.' + ) + file_changed |= didUpdate + + #ldw_numb_period -> ldwNumbPeriod + into.ldwNumbPeriod, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = pref_section, + entry = 'ldw_numb_period', entry_type = float, + default_value = 1.5, + comment = 'Seconds to disable LDW after the blinker stops blinking.' + ) + file_changed |= didUpdate + + #tap_blinker_extension -> tapBlinkerExtension + into.tapBlinkerExtension, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = pref_section, + entry = 'tap_blinker_extension', entry_type = int, + default_value = 2, + comment = 'Number of additional blinks when tapping the turn signal stalk. A value of 2 means 5 blinks total, because the car normally blinks 3 times.' + ) + file_changed |= didUpdate + + #enable_show_car -> enableShowCar + into.enableShowCar, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = pref_section, + entry = 'enable_show_car', entry_type = bool, + default_value = True, + comment = 'Shows a Tesla car in OP\'s limited UI mode instead of the triangle that identifies the lead car; this is only used if you do not have IC/CID integration.' + ) + file_changed |= didUpdate + + #enable_show_logo -> enableShowLogo + into.enableShowLogo, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = pref_section, + entry = 'enable_show_logo', entry_type = bool, + default_value = True, + comment = 'Shows a Tesla red logo on the EON screen when OP is not engaged.' + ) + file_changed |= didUpdate + + #ahb_off_duration -> ahbOffDuration + into.ahbOffDuration, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = pref_section, + entry = 'ahb_off_duration', entry_type = int, + default_value = 5, + comment = 'Duration Auto High Beams (AHB) should be off after last detecting a vehicle. Radar is required to use AHB.' + ) + file_changed |= didUpdate + + #jetson_road_camera_id -> roadCameraID + into.roadCameraID, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = jetson_section, + entry = 'jetson_road_camera_id', entry_type = str, + default_value = 'NotSet', + comment = 'ID of camera facing road, as seen in ls -al /dev/v4l/by-id' + ) + file_changed |= didUpdate + + #jetson_driver_camera_id -> driverCameraID + into.driverCameraID, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = jetson_section, + entry = 'jetson_driver_camera_id', entry_type = str, + default_value = 'NotSet', + comment = 'ID of camera facing driver, as seen in ls -al /dev/v4l/by-id' + ) + file_changed |= didUpdate + + #jetson_road_camera_fx -> roadCameraFx + into.roadCameraFx, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = jetson_section, + entry = 'jetson_road_camera_fx', entry_type = float, + default_value = 0.73, + comment = 'Focal length correction factor to match the EON camera view window' + ) + file_changed |= didUpdate + + #jetson_driver_camera_fx -> driverCameraFx + into.driverCameraFx, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = jetson_section, + entry = 'jetson_driver_camera_fx', entry_type = float, + default_value = 0.75, + comment = 'Focal length correction factor to match the EON camera view window' + ) + file_changed |= didUpdate + + #jetson_driver_camera_flip -> driverCameraFlip + into.driverCameraFlip, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = jetson_section, + entry = 'jetson_driver_camera_flip', entry_type = int, + default_value = 0, + comment = 'Flip the image for the driver camera' + ) + file_changed |= didUpdate + + #jetson_road_camera_flip -> roadCameraFlip + into.roadCameraFlip, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = jetson_section, + entry = 'jetson_road_camera_flip', entry_type = int, + default_value = 0, + comment = 'Flip the image for the road camera' + ) + file_changed |= didUpdate + + #jetson_monitor_forced_resolution -> monitorForcedRes + into.monitorForcedRes, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = jetson_section, + entry = 'jetson_monitor_forced_resolution', entry_type = str, + default_value = "-rez 1280 720", + comment = 'To use the Pi 7" HDMI screen this has to be set to "-rez 800 480"' + ) + file_changed |= didUpdate + + #check camera_id values against LiveParams + # savedRoadCameraID = params.get("RoadUsbCameraID") + # savedDriverCameraID = params.get("DriverUsbCameraID") + savedRoadCameraFx = params.get("RoadUsbCameraFx") + savedDriverCameraFx = params.get("DriverUsbCameraFx") + savedRoadCameraFlip = params.get("RoadUsbCameraFlip") + savedDriverCameraFlip = params.get("DriverUsbCameraFlip") + # if into.driverCameraID != savedDriverCameraID: + # params.put("DriverUsbCameraID",into.driverCameraID) + # if into.roadCameraID != savedRoadCameraID: + # params.put("RoadUsbCameraID",into.roadCameraID) + if into.driverCameraFx != savedDriverCameraFx: + params.put("DriverUsbCameraFx","%f" % into.driverCameraFx) + if into.roadCameraFx != savedRoadCameraFx: + params.put("RoadUsbCameraFx","%f" % into.roadCameraFx) + if into.driverCameraFlip != savedDriverCameraFlip: + params.put("DriverUsbCameraFlip","%d" % into.driverCameraFlip) + if into.roadCameraFlip != savedRoadCameraFlip: + params.put("RoadUsbCameraFlip","%d" % into.roadCameraFlip) + + + into.shouldLogCanErrors, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = logging_section, + entry = 'should_log_can_errors', entry_type = bool, + default_value = False, + comment = 'Enable CAN error logging to Tinkla' + ) + file_changed |= didUpdate + + into.shouldLogProcessCommErrors, didUpdate = self.read_config_entry( + config, configr, prev_file_contents, section = logging_section, + entry = 'should_log_process_comm_errors', entry_type = bool, + default_value = False, + comment = 'Enable Process Comm error logging to Tinkla' + ) + file_changed |= didUpdate + + if file_changed: + did_write = True + with open(config_path, self.config_file_w) as configfile: + config.write(configfile) + else: + did_write = False + + # Remove double quotes from VIN (they are required for empty case) + into.radarVIN = into.radarVIN.replace('"', '') + return did_write + + def read_config_entry(self, config, configr, prev_file_contents, section, entry, entry_type, default_value, comment): + updated = self.update_comment(config, prev_file_contents, section, entry, default_value, comment) + result = None + try: + if entry_type == bool: + result = configr.getboolean(section, entry) + elif entry_type == int: + result = configr.getint(section, entry) + elif entry_type == float: + result = configr.getfloat(section, entry) + else: + result = configr.get(section, entry) + except (configparser.NoSectionError, configparser.NoOptionError): + result = default_value + updated = True + config.set(section, entry, result) + return result, updated + + def update_comment(self, config, prev_file_contents, section, entry, default_value, comment): + new_comment = ("# " + entry + ": " + comment + " (Default: " + str(default_value) + ")").lower() + config.set(section, new_comment) + updated = (prev_file_contents.find(new_comment) == -1) + return updated + +class CarSettings(): + + userHandle = None + forceFingerprintTesla = None + forcePedalOverCC = None + enableHSO = None + enableALCA = None + enableDasEmulation = None + enableRadarEmulation = None + enableDriverMonitor = None + throttleDriverMonitor = None + enableShowCar = None + enableShowLogo = None + hasNoctuaFan = None + limitBatteryMinMax = None + limitBattery_Min = None + limitBattery_Max = None + blockUploadWhileTethering = None + tetherIP = None + useTeslaGPS = None + useTeslaMapData = None + hasTeslaIcIntegration = None + useTeslaRadar = None + useWithoutHarness = None + radarVIN = None + enableLdw = None + radarOffset = None + radarEpasType = None + radarPosition = None + fix1916 = None + doAutoUpdate = None + spinnerText = None + shouldLogProcessCommErrors = None + shouldLogCanErrors = None + hsoNumbPeriod = None + ldwNumbPeriod = None + tapBlinkerExtension = None + ahbOffDuration = None + usesApillarHarness = None + roadCameraID = None + driverCameraID = None + roadCameraFx = None + driverCameraFx = None + roadCameraFlip = None + driverCameraFlip = None + monitorForcedRes = None + + def __init__(self, optional_config_file_path = default_config_file_path): + config_file = ConfigFile() + self.did_write_file = config_file.read(self, config_path = optional_config_file_path) + + def get_value(self, name_of_variable): + return self.__dict__[name_of_variable] + +# Legacy support +def read_config_file(into, config_path = default_config_file_path): + config_file = ConfigFile() + config_file.read(into, config_path) + diff --git a/selfdrive/car/tesla/readconfig.sh b/selfdrive/car/tesla/readconfig.sh index 352ab9e66720f5..9146fab54430a2 100755 --- a/selfdrive/car/tesla/readconfig.sh +++ b/selfdrive/car/tesla/readconfig.sh @@ -1,4 +1,10 @@ -#!/usr/bin/bash -CFG_FILE=/data/bb_openpilot.cfg -CFG_CONTENT=$(cat $CFG_FILE | sed -r '/[^=]+=[^=]+/!d' | sed -r 's/\s+=\s/=/g') -eval "$CFG_CONTENT" +if [ -z "$BASEDIR" ]; then + BASEDIR="/data/openpilot" +fi +CFG_FILE="$BASEDIR/../bb_openpilot.cfg" +CFG_CONTENT=$(cat $CFG_FILE | sed -r "s/'/SINGLE_Q/" | sed -r '/[^=]+=[^=]+/!d' | sed -r 's/\s+=\s/=/g' | sed -e 's/[[:space:]]*\=[[:space:]]*/=/g' \ + -e 's/#.*$//' \ + -e 's/[[:space:]]*$//' \ + -e 's/^[[:space:]]*//' \ + -e "s/^\(.*\)=\([^\"']*\)$/\1=\"\2\"/" | sed -r "s/SINGLE_Q/'/" ) +eval "export $CFG_CONTENT" diff --git a/panda/tests/safety_replay/__init__.py b/selfdrive/car/tesla/speed_utils/__init__.py similarity index 100% rename from panda/tests/safety_replay/__init__.py rename to selfdrive/car/tesla/speed_utils/__init__.py diff --git a/selfdrive/car/tesla/speed_utils/fleet_speed.py b/selfdrive/car/tesla/speed_utils/fleet_speed.py new file mode 100644 index 00000000000000..fe5a6db4a27adf --- /dev/null +++ b/selfdrive/car/tesla/speed_utils/fleet_speed.py @@ -0,0 +1,39 @@ +from selfdrive.car.tesla.speed_utils.movingaverage import MovingAverage + + +class FleetSpeed: + + def __init__(self, average_speed_over_x_suggestions): + self.speed_avg = MovingAverage(average_speed_over_x_suggestions) + self.frame_last_adjustment = 0 + + def adjust(self, CS, max_speed_ms, frame): + if CS.mapAwareSpeed and self.is_valid(CS, max_speed_ms): + self.frame_last_adjustment = frame + # if max speed is greater than the speed limit, apply a relative offset to map speed + if CS.rampType == 0 and max_speed_ms > CS.speed_limit_ms > CS.map_suggested_speed: + return self.speed_avg.add(max_speed_ms * CS.map_suggested_speed / CS.speed_limit_ms) + else: + return self.speed_avg.add(CS.map_suggested_speed) + return max_speed_ms + + def is_active(self, frame): + return self.frame_last_adjustment > 0 and frame <= self.frame_last_adjustment + 10 + + def reset_averager(self): + self.speed_avg.reset() + + @classmethod + def is_available(cls, CS): + return CS.mapAwareSpeed and CS.medianFleetSpeedMPS > 0 and CS.splineLocConfidence > 60 and CS.UI_splineID > 0 + + @classmethod + def is_valid(cls, CS, max_speed_ms): + if CS.map_suggested_speed <= 0 or CS.map_suggested_speed > max_speed_ms: + return False + if CS.speed_limit_ms == 0: # no or unknown speed limit + if CS.rampType == 0 and CS.map_suggested_speed >= 17: # more than 61 kph / 38 mph, means we may be on a road without speed limit + return False + elif CS.speed_limit_ms < CS.map_suggested_speed: # if map speed exceeds the speed limit, we'll ignore it + return False + return True diff --git a/selfdrive/car/tesla/speed_utils/movingaverage.py b/selfdrive/car/tesla/speed_utils/movingaverage.py new file mode 100644 index 00000000000000..5281f40ff2f1a7 --- /dev/null +++ b/selfdrive/car/tesla/speed_utils/movingaverage.py @@ -0,0 +1,20 @@ +import queue + +class MovingAverage(): + def __init__(self, length): + self.length = length + self.reset() + + def reset(self): + self.queue = queue.Queue(maxsize=self.length) + self.sum = 0 + + def add(self, sample): + if self.queue.full(): + self.sum -= self.queue.get_nowait() + self.queue.put_nowait(sample) + self.sum += sample + return self.sum / self.queue.qsize() + + def full(self): + return self.queue.full() diff --git a/selfdrive/car/tesla/teslacan.py b/selfdrive/car/tesla/teslacan.py index 84631a0bb4da79..c7988633cba88f 100644 --- a/selfdrive/car/tesla/teslacan.py +++ b/selfdrive/car/tesla/teslacan.py @@ -31,13 +31,13 @@ def add_tesla_crc(msg,msg_len): def add_tesla_checksum(msg_id,msg): """Calculates the checksum for the data part of the Tesla message""" - checksum = ((msg_id) & 0xFF) + ((msg_id >> 8) & 0xFF) + checksum = ((msg_id) & 0xFF) + int((msg_id >> 8) & 0xFF) for i in range(0,len(msg),1): checksum = (checksum + ord(msg[i])) & 0xFF return checksum -def create_pedal_command_msg(accelCommand, enable, idx): +def create_pedal_command_msg(accelCommand, enable, idx, pedalcan): """Create GAS_COMMAND (0x551) message to comma pedal""" msg_id = 0x551 msg_len = 6 @@ -52,10 +52,17 @@ def create_pedal_command_msg(accelCommand, enable, idx): int_accelCommand = 0 int_accelCommand2 = 0 msg = create_string_buffer(msg_len) - struct.pack_into('BBBBB', msg, 0, (int_accelCommand >> 8) & 0xFF, int_accelCommand & 0xFF, \ - (int_accelCommand2 >> 8) & 0xFF, int_accelCommand2 & 0XFF,((enable << 7) + idx) & 0xFF) + struct.pack_into('BBBBB', msg, 0, int((int_accelCommand >> 8) & 0xFF), int_accelCommand & 0xFF, \ + int((int_accelCommand2 >> 8) & 0xFF), int_accelCommand2 & 0XFF,((enable << 7) + idx) & 0xFF) struct.pack_into('B', msg, msg_len-1, add_tesla_checksum(msg_id,msg)) - return [msg_id, 0, msg.raw, 2] + return [msg_id, 0, msg.raw, pedalcan] + +def create_enabled_eth_msg(status): + msg_id = 0x018 + msg_len = 1 + msg = create_string_buffer(msg_len) + struct.pack_into('B', msg, 0, status) + return [msg_id, 0, msg.raw, 0] def create_fake_IC_msg(): msg_id = 0x649 @@ -69,7 +76,7 @@ def create_radar_VIN_msg(radarId,radarVIN,radarCAN,radarTriggerMessage,useRadar, msg_len = 8 msg = create_string_buffer(msg_len) if radarId == 0: - struct.pack_into('BBBBBBBB', msg, 0, radarId, radarCAN, useRadar + (radarPosition << 1) + (radarEpasType << 3),((radarTriggerMessage >> 8) & 0xFF),(radarTriggerMessage & 0xFF),ord(radarVIN[0]),ord(radarVIN[1]),ord(radarVIN[2])) + struct.pack_into('BBBBBBBB', msg, 0, radarId, radarCAN, useRadar + (radarPosition << 1) + (radarEpasType << 3),int((radarTriggerMessage >> 8) & 0xFF),(radarTriggerMessage & 0xFF),ord(radarVIN[0]),ord(radarVIN[1]),ord(radarVIN[2])) if radarId == 1: struct.pack_into('BBBBBBBB', msg, 0, radarId, ord(radarVIN[3]), ord(radarVIN[4]),ord(radarVIN[5]),ord(radarVIN[6]),ord(radarVIN[7]),ord(radarVIN[8]),ord(radarVIN[9])) if radarId == 2: @@ -83,12 +90,13 @@ def create_DAS_LR_object_msg(lane,v1Class,v1Id,v1Dx,v1Dy,v1V,v2Class,v2Id,v2Dx,v important1 = 0 important2 = 0 if (v1Dx > 0) and (v1Id >= 0): - important1 = 1 + if lane == 0: + important1 = 1 v1Class += 1 if v1Class == 4: v1Class = 5 if (v2Dx > 0) and (v2Id >= 0): - important2 = 1 + #important2 = 1 v2Class += 1 if v2Class == 4: v2Class = 5 @@ -117,31 +125,41 @@ def create_DAS_LR_object_msg(lane,v1Class,v1Id,v1Dx,v1Dy,v1V,v2Class,v2Id,v2Dx,v important2 = 0 v2Class = 0 struct.pack_into('BBBBBBBB', msg, 0,lane + (v1Class << 3) + (important1 << 7),v1x, v1v + ((v1y << 4) & 0xF0), - ((v1y >> 4) & 0x07) + ((v1Id << 3) & 0xF8), ((v1Id >> 5) & 0x03) + (v2Class << 2) +(important2 << 6) + ((v2x << 7) & 0x80), - ((v2x >> 1) & 0x7F) + ((v2v << 7) & 0x80), ((v2v >> 1) & 0x07) + ((v2y << 3) & 0xF8), - ((v2y >> 5) & 0x03) + ((v2Id << 2) & 0xFC)) + int((v1y >> 4) & 0x07) + ((v1Id << 3) & 0xF8), int((v1Id >> 5) & 0x03) + (v2Class << 2) +(important2 << 6) + ((v2x << 7) & 0x80), + int((v2x >> 1) & 0x7F) + ((v2v << 7) & 0x80), int((v2v >> 1) & 0x07) + ((v2y << 3) & 0xF8), + int((v2y >> 5) & 0x03) + ((v2Id << 2) & 0xFC)) + return [msg_id, 0, msg.raw, 0] + +def create_fake_DAS_msg2(hiLoBeamStatus,hiLoBeamReason,ahbIsEnabled,fleet_speed_state): + msg_id = 0x65A + msg_len = 3 + msg = create_string_buffer(msg_len) + struct.pack_into('BBB', msg, 0, hiLoBeamStatus, hiLoBeamReason,(1 if ahbIsEnabled else 0) + (fleet_speed_state << 1)) return [msg_id, 0, msg.raw, 0] + def create_fake_DAS_msg(speed_control_enabled,speed_override,apUnavailable, collision_warning, op_status, \ acc_speed_kph, \ - turn_signal_needed,forward_collission_warning,hands_on_state, \ - cc_state, pedal_state, alca_state, \ - acc_speed_limit_mph, + turn_signal_needed,forward_collission_warning,adaptive_cruise, hands_on_state, \ + cc_state, pcc_available, alca_state, \ + acc_speed_limit, # IC cruise speed, kph or mph legal_speed_limit, apply_angle, - enable_steer_control): - msg_id = 0x659 #0x553 //we will try to use DAS_udsRequest to send this info to IC + enable_steer_control, + park_brake_request): + msg_id = 0x659 #we will use DAS_udsRequest to send this info to IC msg_len = 8 msg = create_string_buffer(msg_len) - c_apply_steer = ((int( apply_angle * 10 + 0x4000 )) & 0x7FFF) + (enable_steer_control << 15) - struct.pack_into('BBBBBBBB', msg, 0,(speed_control_enabled << 7) + (speed_override << 6) + (apUnavailable << 5) + (collision_warning << 4) + op_status, \ - acc_speed_kph, \ - (turn_signal_needed << 6) + (forward_collission_warning << 4) + hands_on_state, \ - (cc_state << 6) + (pedal_state << 5) + alca_state, \ - acc_speed_limit_mph, - legal_speed_limit, - c_apply_steer & 0xFF, - (c_apply_steer >> 8) & 0xFF) + units_included = 1 + c_apply_steer = int(((int( apply_angle * 10 + 0x4000 )) & 0x7FFF) + (enable_steer_control << 15)) + struct.pack_into('BBBBBBBB', msg, 0,int((speed_control_enabled << 7) + (speed_override << 6) + (apUnavailable << 5) + (collision_warning << 4) + op_status), \ + int(acc_speed_kph), \ + int((turn_signal_needed << 6) + (units_included << 5) + (forward_collission_warning << 4) + (adaptive_cruise << 3) + hands_on_state), \ + int((cc_state << 6) + (pcc_available << 5) + alca_state), \ + int(acc_speed_limit + 0.5), # IC rounds current speed, so we need to round cruise speed the same way + int((legal_speed_limit & 0x1F) + ((park_brake_request << 5) & 0x20)), #positions 7 and 6 not used yet + int(c_apply_steer & 0xFF), + int((c_apply_steer >> 8) & 0xFF)) return [msg_id, 0, msg.raw, 0] def create_fake_DAS_obj_lane_msg(leadDx,leadDy,leadClass,rLine,lLine,curv0,curv1,curv2,curv3,laneRange,laneWidth): @@ -177,8 +195,8 @@ def create_fake_DAS_sign_msg(roadSignType,roadSignStopDist,roadSignColor,roadSig source = 0x02 #vision roadSignStopDist_t = (((roadSignStopDist + 20) / 0.2) & 0x3FF) sign1 = ((roadSignType & 0x03) << 6) +(roadSignColor << 3) + 0x04 - sign2 = ((roadSignStopDist_t & 0x03) << 6) + (roadSignType >> 2) - sign3 = (roadSignStopDist_t >> 2) + sign2 = ((roadSignStopDist_t & 0x03) << 6) + int((roadSignType >> 2) & 0xFF) + sign3 = int(roadSignStopDist_t >> 2) sign4 = (orientation << 6) + (arrow << 3) + (source << 1) + roadSignControlActive msg = create_string_buffer(msg_len) struct.pack_into('BBBB',msg ,0 , sign1,sign2,sign3,sign4) @@ -188,7 +206,7 @@ def create_fake_DAS_warning(DAS_211_accNoSeatBelt, DAS_canErrors, \ DAS_202_noisyEnvironment, DAS_doorOpen, DAS_notInDrive, enableDasEmulation, enableRadarEmulation, \ stopSignWarning, stopLightWarning, \ DAS_222_accCameraBlind, DAS_219_lcTempUnavailableSpeed, DAS_220_lcTempUnavailableRoad, DAS_221_lcAborting, \ - DAS_207_lkasUnavailable,DAS_208_rackDetected, DAS_025_steeringOverride, ldwStatus,FLAG_notUsed,useWithoutHarness): + DAS_207_lkasUnavailable,DAS_208_rackDetected, DAS_025_steeringOverride, ldwStatus, useWithoutHarness,usesApillarHarness): msg_id = 0x554 msg_len = 3 fd = 0 @@ -201,9 +219,13 @@ def create_fake_DAS_warning(DAS_211_accNoSeatBelt, DAS_canErrors, \ wh = 0 if useWithoutHarness: wh = 1 + aph = 0 + if usesApillarHarness: + aph=1 + autoPilotAborting = 0 #not used at the moment warn1 = (stopLightWarning<< 7) + (rd << 6) + (fd << 5) + (DAS_211_accNoSeatBelt << 4) + (DAS_canErrors << 3) + (DAS_202_noisyEnvironment << 2) + (DAS_doorOpen << 1) + DAS_notInDrive warn2 = stopSignWarning + (DAS_222_accCameraBlind << 1) + (DAS_219_lcTempUnavailableSpeed << 2) + (DAS_220_lcTempUnavailableRoad << 3) + (DAS_221_lcAborting << 4) + (DAS_207_lkasUnavailable << 5) + (DAS_208_rackDetected << 6) + (DAS_025_steeringOverride << 7) - warn3 = ldwStatus + (FLAG_notUsed << 3) + (wh << 4) + warn3 = ldwStatus + (autoPilotAborting << 3) + (wh << 4) + (aph << 5) msg = create_string_buffer(msg_len) struct.pack_into('BBB',msg ,0 , warn1,warn2,warn3) return [msg_id,0,msg.raw,0] @@ -253,7 +275,7 @@ def create_cruise_adjust_msg(spdCtrlLvr_stat, turnIndLvr_Stat, real_steering_whe (fake_stalk['SpdCtrlLvr_Stat']) + (int(round(fake_stalk['VSL_Enbl_Rq'])) << 6)) # Set the 2nd byte, containing DTR_Dist_Rq - struct.pack_into('B', msg, 1, fake_stalk['DTR_Dist_Rq']) + struct.pack_into('B', msg, 1, int(fake_stalk['DTR_Dist_Rq'])) # Set the 3rd byte, containing turn indicator, highbeams, and wiper wash struct.pack_into('B', msg, 2, int(round(fake_stalk['TurnIndLvr_Stat'])) + @@ -268,7 +290,7 @@ def create_cruise_adjust_msg(spdCtrlLvr_stat, turnIndLvr_Stat, real_steering_whe # Finally, set the CRC for the message. Must be calculated last! fake_stalk['CRC_STW_ACTN_RQ'] = add_tesla_crc(msg=msg, msg_len=7) - struct.pack_into('B', msg, msg_len-1, fake_stalk['CRC_STW_ACTN_RQ']) + struct.pack_into('B', msg, msg_len-1, int(fake_stalk['CRC_STW_ACTN_RQ'])) return [msg_id, 0, msg.raw, 0] diff --git a/selfdrive/car/tesla/test_readconfig.py b/selfdrive/car/tesla/test_readconfig.py index decb1c884a75e0..560be2d298c143 100755 --- a/selfdrive/car/tesla/test_readconfig.py +++ b/selfdrive/car/tesla/test_readconfig.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python3 import unittest import os @@ -6,7 +6,7 @@ from selfdrive.car.tesla.readconfig import read_config_file, CarSettings -class CarSettingsTestClass(object): +class CarSettingsTestClass(): forcePedalOverCC = None fix1916 = None @@ -171,10 +171,13 @@ def test_readconfig_no_arguments(self): # Test get_value interface: def test_get_value(self): - value = CarSettings().get_value("userHandle") + config_file_path = "./test_config_file3.cfg" + cs = readconfig.CarSettings(optional_config_file_path=config_file_path) + value = cs.get_value("userHandle") self.assertEqual(value, 'your_tinkla_username') - value = CarSettings().get_value("doAutoUpdate") + value = cs.get_value("doAutoUpdate") self.assertEqual(value, True) + os.remove(config_file_path) def check_defaults(self, cs): self.assertEqual(cs.userHandle, 'your_tinkla_username') @@ -184,9 +187,6 @@ def check_defaults(self, cs): self.assertEqual(cs.enableALCA, True) self.assertEqual(cs.enableDasEmulation, False) self.assertEqual(cs.enableRadarEmulation, False) - self.assertEqual(cs.enableSpeedVariableDesAngle, True) - self.assertEqual(cs.enableRollAngleCorrection, False) - self.assertEqual(cs.enableFeedForwardAngleCorrection, True) self.assertEqual(cs.enableDriverMonitor, True) self.assertEqual(cs.enableShowCar, True) self.assertEqual(cs.enableShowLogo, True) @@ -210,6 +210,8 @@ def check_defaults(self, cs): self.assertEqual(cs.fix1916, False) self.assertEqual(cs.get_value("userHandle"), 'your_tinkla_username') self.assertEqual(cs.get_value("doAutoUpdate"), True) + self.assertEqual(cs.shouldLogCanErrors, False) + self.assertEqual(cs.shouldLogProcessCommErrors, False) # Helper methods diff --git a/selfdrive/boardd/tests/__init__.py b/selfdrive/car/tests/__init__.py similarity index 100% rename from selfdrive/boardd/tests/__init__.py rename to selfdrive/car/tests/__init__.py diff --git a/selfdrive/car/tests/test_car_interfaces.py b/selfdrive/car/tests/test_car_interfaces.py new file mode 100755 index 00000000000000..be05c9d065cd90 --- /dev/null +++ b/selfdrive/car/tests/test_car_interfaces.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 +import unittest +import importlib +from selfdrive.car.fingerprints import all_known_cars +from selfdrive.car.car_helpers import interfaces +from selfdrive.car.fingerprints import _FINGERPRINTS as FINGERPRINTS + +from cereal import car + + +class TestCarInterfaces(unittest.TestCase): + def test_car_interfaces(self): + all_cars = all_known_cars() + + for car_name in all_cars: + print(car_name) + fingerprint = FINGERPRINTS[car_name][0] + + CarInterface, CarController, CarState = interfaces[car_name] + fingerprints = { + 0: fingerprint, + 1: fingerprint, + 2: fingerprint, + } + + car_fw = [] + + car_params = CarInterface.get_params(car_name, fingerprints, car_fw) + car_interface = CarInterface(car_params, CarController, CarState) + assert car_params + assert car_interface + + self.assertGreater(car_params.mass, 1) + self.assertGreater(car_params.steerRateCost, 1e-3) + + tuning = car_params.lateralTuning.which() + if tuning == 'pid': + self.assertTrue(len(car_params.lateralTuning.pid.kpV)) + elif tuning == 'lqr': + self.assertTrue(len(car_params.lateralTuning.lqr.a)) + elif tuning == 'indi': + self.assertGreater(car_params.lateralTuning.indi.outerLoopGain, 1e-3) + + # Run car interface + CC = car.CarControl.new_message() + for _ in range(10): + car_interface.update(CC, []) + car_interface.apply(CC) + car_interface.apply(CC) + + CC = car.CarControl.new_message() + CC.enabled = True + for _ in range(10): + car_interface.update(CC, []) + car_interface.apply(CC) + car_interface.apply(CC) + + # Test radar interface + RadarInterface = importlib.import_module('selfdrive.car.%s.radar_interface' % car_params.carName).RadarInterface + radar_interface = RadarInterface(car_params) + assert radar_interface + + # Run radar interface once + radar_interface.update([]) + if not car_params.radarOffCan and hasattr(radar_interface, '_update') and hasattr(radar_interface, 'trigger_msg'): + radar_interface._update([radar_interface.trigger_msg]) + +if __name__ == "__main__": + unittest.main() diff --git a/selfdrive/car/toyota/.gitignore b/selfdrive/car/toyota/.gitignore deleted file mode 100644 index 89fa7bc7daf83e..00000000000000 --- a/selfdrive/car/toyota/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -buttons.msg -buttons.cc.msg diff --git a/selfdrive/car/toyota/carcontroller.py b/selfdrive/car/toyota/carcontroller.py index 2b55b4a34f72b9..b76b66b3e9112b 100644 --- a/selfdrive/car/toyota/carcontroller.py +++ b/selfdrive/car/toyota/carcontroller.py @@ -1,43 +1,20 @@ from cereal import car -from common.numpy_fast import clip, interp -from selfdrive.car import apply_toyota_steer_torque_limits -from selfdrive.car import create_gas_command -from selfdrive.car.toyota.toyotacan import make_can_msg, create_video_target,\ - create_steer_command, create_ui_command, \ - create_ipas_steer_command, create_accel_command, \ +from common.numpy_fast import clip +from selfdrive.car import apply_toyota_steer_torque_limits, create_gas_command, make_can_msg +from selfdrive.car.toyota.toyotacan import create_steer_command, create_ui_command, \ + create_accel_command, create_acc_cancel_command, \ create_fcw_command -from selfdrive.car.toyota.values import ECU, STATIC_MSGS, TSS2_CAR -from selfdrive.can.packer import CANPacker -from selfdrive.car.modules.ALCA_module import ALCAController +from selfdrive.car.toyota.values import Ecu, CAR, STATIC_MSGS, NO_STOP_TIMER_CAR, SteerLimitParams +from opendbc.can.packer import CANPacker VisualAlert = car.CarControl.HUDControl.VisualAlert # Accel limits ACCEL_HYST_GAP = 0.02 # don't change accel command for small oscilalitons within this value ACCEL_MAX = 1.5 # 1.5 m/s2 -ACCEL_MIN = -3.0 # 3 m/s2 +ACCEL_MIN = -3.0 # 3 m/s2 ACCEL_SCALE = max(ACCEL_MAX, -ACCEL_MIN) -# Steer torque limits -class SteerLimitParams: - STEER_MAX = 1500 - STEER_DELTA_UP = 10 # 1.5s time to peak torque - STEER_DELTA_DOWN = 25 # always lower than 45 otherwise the Rav4 faults (Prius seems ok with 50) - STEER_ERROR_MAX = 350 # max delta between torque cmd and torque motor - -# Steer angle limits (tested at the Crows Landing track and considered ok) -ANGLE_MAX_BP = [0., 5.] -ANGLE_MAX_V = [510., 300.] -ANGLE_DELTA_BP = [0., 5., 15.] -ANGLE_DELTA_V = [5., .8, .15] # windup limit -ANGLE_DELTA_VU = [5., 3.5, 0.4] # unwind limit - -TARGET_IDS = [0x340, 0x341, 0x342, 0x343, 0x344, 0x345, - 0x363, 0x364, 0x365, 0x370, 0x371, 0x372, - 0x373, 0x374, 0x375, 0x380, 0x381, 0x382, - 0x383] - - def accel_hysteresis(accel, accel_steady, enabled): # for small accel oscillations within ACCEL_HYST_GAP, don't change the accel command @@ -53,72 +30,26 @@ def accel_hysteresis(accel, accel_steady, enabled): return accel, accel_steady -def process_hud_alert(hud_alert): - # initialize to no alert - steer = 0 - fcw = 0 - - if hud_alert == VisualAlert.fcw: - fcw = 1 - elif hud_alert == VisualAlert.steerRequired: - steer = 1 - - return steer, fcw - - -def ipas_state_transition(steer_angle_enabled, enabled, ipas_active, ipas_reset_counter): - - if enabled and not steer_angle_enabled: - #ipas_reset_counter = max(0, ipas_reset_counter - 1) - #if ipas_reset_counter == 0: - # steer_angle_enabled = True - #else: - # steer_angle_enabled = False - #return steer_angle_enabled, ipas_reset_counter - return True, 0 - - elif enabled and steer_angle_enabled: - if steer_angle_enabled and not ipas_active: - ipas_reset_counter += 1 - else: - ipas_reset_counter = 0 - if ipas_reset_counter > 10: # try every 0.1s - steer_angle_enabled = False - return steer_angle_enabled, ipas_reset_counter - - else: - return False, 0 - - -class CarController(object): - def __init__(self, dbc_name, car_fingerprint, enable_camera, enable_dsu, enable_apg): - self.braking = False - # redundant safety check with the board - self.controls_allowed = True +class CarController(): + def __init__(self, dbc_name, CP, VM): self.last_steer = 0 - self.last_angle = 0 self.accel_steady = 0. - self.car_fingerprint = car_fingerprint self.alert_active = False self.last_standstill = False self.standstill_req = False - self.angle_control = False - self.steer_angle_enabled = False - self.ipas_reset_counter = 0 - self.last_fault_frame = -200 + self.steer_rate_limited = False self.fake_ecus = set() - if enable_camera: self.fake_ecus.add(ECU.CAM) - if enable_dsu: self.fake_ecus.add(ECU.DSU) - if enable_apg: self.fake_ecus.add(ECU.APGS) - self.ALCA = ALCAController(self,True,False) # Enabled True and SteerByAngle only False + if CP.enableCamera: + self.fake_ecus.add(Ecu.fwdCamera) + if CP.enableDsu: + self.fake_ecus.add(Ecu.dsu) self.packer = CANPacker(dbc_name) - def update(self, enabled, CS, frame, actuators, - pcm_cancel_cmd, hud_alert, forwarding_camera, left_line, - right_line, lead, left_lane_depart, right_lane_depart): + def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, hud_alert, + left_line, right_line, lead, left_lane_depart, right_lane_depart): # *** compute control surfaces *** @@ -135,70 +66,33 @@ def update(self, enabled, CS, frame, actuators, apply_accel, self.accel_steady = accel_hysteresis(apply_accel, self.accel_steady, enabled) apply_accel = clip(apply_accel * ACCEL_SCALE, ACCEL_MIN, ACCEL_MAX) - # Get the angle from ALCA. - alca_enabled = False - alca_steer = 0. - alca_angle = 0. - turn_signal_needed = 0 - # Update ALCA status and custom button every 0.1 sec. - if self.ALCA.pid == None: - self.ALCA.set_pid(CS) - if (frame % 10 == 0): - self.ALCA.update_status(CS.cstm_btns.get_button_status("alca") > 0) - # steer torque - alca_angle, alca_steer, alca_enabled, turn_signal_needed = self.ALCA.update(enabled, CS, frame, actuators) - apply_steer = int(round(alca_steer * SteerLimitParams.STEER_MAX)) - apply_steer = apply_toyota_steer_torque_limits(apply_steer, self.last_steer, CS.steer_torque_motor, SteerLimitParams) - - # only cut torque when steer state is a known fault - if CS.steer_state in [9, 25]: - self.last_fault_frame = frame + # steer torque + new_steer = int(round(actuators.steer * SteerLimitParams.STEER_MAX)) + apply_steer = apply_toyota_steer_torque_limits(new_steer, self.last_steer, CS.out.steeringTorqueEps, SteerLimitParams) + self.steer_rate_limited = new_steer != apply_steer - # Cut steering for 2s after fault - if not enabled or (frame - self.last_fault_frame < 200): + # Cut steering while we're in a known fault state (2s) + if not enabled or CS.steer_state in [9, 25]: apply_steer = 0 apply_steer_req = 0 else: apply_steer_req = 1 - self.steer_angle_enabled, self.ipas_reset_counter = \ - ipas_state_transition(self.steer_angle_enabled, enabled, CS.ipas_active, self.ipas_reset_counter) - #print("{0} {1} {2}".format(self.steer_angle_enabled, self.ipas_reset_counter, CS.ipas_active)) - - - # steer angle - if self.steer_angle_enabled and CS.ipas_active: - - apply_angle = alca_angle - angle_lim = interp(CS.v_ego, ANGLE_MAX_BP, ANGLE_MAX_V) - apply_angle = clip(apply_angle, -angle_lim, angle_lim) - - # windup slower - if self.last_angle * apply_angle > 0. and abs(apply_angle) > abs(self.last_angle): - angle_rate_lim = interp(CS.v_ego, ANGLE_DELTA_BP, ANGLE_DELTA_V) - else: - angle_rate_lim = interp(CS.v_ego, ANGLE_DELTA_BP, ANGLE_DELTA_VU) - - apply_angle = clip(apply_angle, self.last_angle - angle_rate_lim, self.last_angle + angle_rate_lim) - else: - apply_angle = CS.angle_steers - if not enabled and CS.pcm_acc_status: # send pcm acc cancel cmd if drive is disabled but pcm is still on, or if the system can't be activated pcm_cancel_cmd = 1 # on entering standstill, send standstill request - if CS.standstill and not self.last_standstill: + if CS.out.standstill and not self.last_standstill and CS.CP.carFingerprint not in NO_STOP_TIMER_CAR: self.standstill_req = True if CS.pcm_acc_status != 8: # pcm entered standstill or it's disabled self.standstill_req = False self.last_steer = apply_steer - self.last_angle = apply_angle self.last_accel = apply_accel - self.last_standstill = CS.standstill + self.last_standstill = CS.out.standstill can_sends = [] @@ -208,70 +102,56 @@ def update(self, enabled, CS, frame, actuators, # toyota can trace shows this message at 42Hz, with counter adding alternatively 1 and 2; # sending it at 100Hz seem to allow a higher rate limit, as the rate limit seems imposed # on consecutive messages - if ECU.CAM in self.fake_ecus: - if self.angle_control: - can_sends.append(create_steer_command(self.packer, 0., 0, frame)) - else: - can_sends.append(create_steer_command(self.packer, apply_steer, apply_steer_req, frame)) - - if self.angle_control: - can_sends.append(create_ipas_steer_command(self.packer, apply_angle, self.steer_angle_enabled, - ECU.APGS in self.fake_ecus)) - elif ECU.APGS in self.fake_ecus: - can_sends.append(create_ipas_steer_command(self.packer, 0, 0, True)) - - # accel cmd comes from DSU, but we can spam can to cancel the system even if we are using lat only control - if (frame % 3 == 0 and ECU.DSU in self.fake_ecus) or (pcm_cancel_cmd and ECU.CAM in self.fake_ecus): - lead = lead or CS.v_ego < 12. # at low speed we always assume the lead is present do ACC can be engaged - if ECU.DSU in self.fake_ecus: + if Ecu.fwdCamera in self.fake_ecus: + can_sends.append(create_steer_command(self.packer, apply_steer, apply_steer_req, frame)) + + # LTA mode. Set ret.steerControlType = car.CarParams.SteerControlType.angle and whitelist 0x191 in the panda + # if frame % 2 == 0: + # can_sends.append(create_steer_command(self.packer, 0, 0, frame // 2)) + # can_sends.append(create_lta_steer_command(self.packer, actuators.steerAngle, apply_steer_req, frame // 2)) + + # we can spam can to cancel the system even if we are using lat only control + if (frame % 3 == 0 and CS.CP.openpilotLongitudinalControl) or (pcm_cancel_cmd and Ecu.fwdCamera in self.fake_ecus): + lead = lead or CS.out.vEgo < 12. # at low speed we always assume the lead is present do ACC can be engaged + + # Lexus IS uses a different cancellation message + if pcm_cancel_cmd and CS.CP.carFingerprint == CAR.LEXUS_IS: + can_sends.append(create_acc_cancel_command(self.packer)) + elif CS.CP.openpilotLongitudinalControl: can_sends.append(create_accel_command(self.packer, apply_accel, pcm_cancel_cmd, self.standstill_req, lead)) else: can_sends.append(create_accel_command(self.packer, 0, pcm_cancel_cmd, False, lead)) if (frame % 2 == 0) and (CS.CP.enableGasInterceptor): - # send exactly zero if apply_gas is zero. Interceptor will send the max between read value and apply_gas. - # This prevents unexpected pedal range rescaling - can_sends.append(create_gas_command(self.packer, apply_gas, frame//2)) - - if frame % 10 == 0 and ECU.CAM in self.fake_ecus and not forwarding_camera: - for addr in TARGET_IDS: - can_sends.append(create_video_target(frame//10, addr)) + # send exactly zero if apply_gas is zero. Interceptor will send the max between read value and apply_gas. + # This prevents unexpected pedal range rescaling + can_sends.append(create_gas_command(self.packer, apply_gas, frame//2)) # ui mesg is at 100Hz but we send asap if: # - there is something to display # - there is something to stop displaying - alert_out = process_hud_alert(hud_alert) - steer, fcw = alert_out + fcw_alert = hud_alert == VisualAlert.fcw + steer_alert = hud_alert == VisualAlert.steerRequired - if (any(alert_out) and not self.alert_active) or \ - (not any(alert_out) and self.alert_active): + send_ui = False + if ((fcw_alert or steer_alert) and not self.alert_active) or \ + (not (fcw_alert or steer_alert) and self.alert_active): send_ui = True self.alert_active = not self.alert_active - else: - send_ui = False + elif pcm_cancel_cmd: + # forcing the pcm to disengage causes a bad fault sound so play a good sound instead + send_ui = True - if (frame % 100 == 0 or send_ui) and ECU.CAM in self.fake_ecus: - can_sends.append(create_ui_command(self.packer, steer, left_line, right_line, left_lane_depart, right_lane_depart)) + if (frame % 100 == 0 or send_ui) and Ecu.fwdCamera in self.fake_ecus: + can_sends.append(create_ui_command(self.packer, steer_alert, pcm_cancel_cmd, left_line, right_line, left_lane_depart, right_lane_depart)) - if frame % 100 == 0 and ECU.DSU in self.fake_ecus and self.car_fingerprint not in TSS2_CAR: - can_sends.append(create_fcw_command(self.packer, fcw)) + if frame % 100 == 0 and Ecu.dsu in self.fake_ecus: + can_sends.append(create_fcw_command(self.packer, fcw_alert)) #*** static msgs *** for (addr, ecu, cars, bus, fr_step, vl) in STATIC_MSGS: - if frame % fr_step == 0 and ecu in self.fake_ecus and self.car_fingerprint in cars and not (ecu == ECU.CAM and forwarding_camera): - # special cases - if fr_step == 5 and ecu == ECU.CAM and bus == 1: - cnt = (((frame // 5) % 7) + 1) << 5 - vl = chr(cnt) + vl - elif addr in (0x489, 0x48a) and bus == 0: - # add counter for those 2 messages (last 4 bits) - cnt = ((frame // 100) % 0xf) + 1 - if addr == 0x48a: - # 0x48a has a 8 preceding the counter - cnt += 1 << 7 - vl += chr(cnt) - - can_sends.append(make_can_msg(addr, vl, bus, False)) + if frame % fr_step == 0 and ecu in self.fake_ecus and CS.CP.carFingerprint in cars: + can_sends.append(make_can_msg(addr, vl, bus)) return can_sends diff --git a/selfdrive/car/toyota/carstate.py b/selfdrive/car/toyota/carstate.py index 76d53ae5691ae8..4cf84904e733c3 100644 --- a/selfdrive/car/toyota/carstate.py +++ b/selfdrive/car/toyota/carstate.py @@ -1,238 +1,195 @@ -import numpy as np -from common.kalman.simple_kalman import KF1D -from selfdrive.can.can_define import CANDefine -from selfdrive.can.parser import CANParser +from cereal import car +from common.numpy_fast import mean +from opendbc.can.can_define import CANDefine +from selfdrive.car.interfaces import CarStateBase +from opendbc.can.parser import CANParser from selfdrive.config import Conversions as CV -from selfdrive.car.toyota.values import CAR, DBC, STEER_THRESHOLD, TSS2_CAR, NO_DSU_CAR - -def parse_gear_shifter(gear, vals): - - val_to_capnp = {'P': 'park', 'R': 'reverse', 'N': 'neutral', - 'D': 'drive', 'B': 'brake'} - try: - return val_to_capnp[vals[gear]] - except KeyError: - return "unknown" - - -def get_can_parser(CP): - - signals = [ - # sig_name, sig_address, default - ("STEER_ANGLE", "STEER_ANGLE_SENSOR", 0), - ("GEAR", "GEAR_PACKET", 0), - ("BRAKE_PRESSED", "BRAKE_MODULE", 0), - ("GAS_PEDAL", "GAS_PEDAL", 0), - ("WHEEL_SPEED_FL", "WHEEL_SPEEDS", 0), - ("WHEEL_SPEED_FR", "WHEEL_SPEEDS", 0), - ("WHEEL_SPEED_RL", "WHEEL_SPEEDS", 0), - ("WHEEL_SPEED_RR", "WHEEL_SPEEDS", 0), - ("DOOR_OPEN_FL", "SEATS_DOORS", 1), - ("DOOR_OPEN_FR", "SEATS_DOORS", 1), - ("DOOR_OPEN_RL", "SEATS_DOORS", 1), - ("DOOR_OPEN_RR", "SEATS_DOORS", 1), - ("SEATBELT_DRIVER_UNLATCHED", "SEATS_DOORS", 1), - ("TC_DISABLED", "ESP_CONTROL", 1), - ("STEER_FRACTION", "STEER_ANGLE_SENSOR", 0), - ("STEER_RATE", "STEER_ANGLE_SENSOR", 0), - ("CRUISE_ACTIVE", "PCM_CRUISE", 0), - ("CRUISE_STATE", "PCM_CRUISE", 0), - ("MAIN_ON", "PCM_CRUISE_2", 0), - ("SET_SPEED", "PCM_CRUISE_2", 0), - ("LOW_SPEED_LOCKOUT", "PCM_CRUISE_2", 0), - ("STEER_TORQUE_DRIVER", "STEER_TORQUE_SENSOR", 0), - ("STEER_TORQUE_EPS", "STEER_TORQUE_SENSOR", 0), - ("TURN_SIGNALS", "STEERING_LEVERS", 3), # 3 is no blinkers - ("LKA_STATE", "EPS_STATUS", 0), - ("IPAS_STATE", "EPS_STATUS", 1), - ("BRAKE_LIGHTS_ACC", "ESP_CONTROL", 0), - ("AUTO_HIGH_BEAM", "LIGHT_STALK", 0), - ] - - checks = [ - ("BRAKE_MODULE", 40), - ("GAS_PEDAL", 33), - ("WHEEL_SPEEDS", 80), - ("STEER_ANGLE_SENSOR", 80), - ("PCM_CRUISE", 33), - ("PCM_CRUISE_2", 33), - ("STEER_TORQUE_SENSOR", 50), - ("EPS_STATUS", 25), - ] - - if CP.carFingerprint in NO_DSU_CAR: - signals += [("STEER_ANGLE", "STEER_TORQUE_SENSOR", 0)] - - if CP.carFingerprint == CAR.PRIUS: - signals += [("STATE", "AUTOPARK_STATUS", 0)] - - # add gas interceptor reading if we are using it - if CP.enableGasInterceptor: - signals.append(("INTERCEPTOR_GAS", "GAS_SENSOR", 0)) - signals.append(("INTERCEPTOR_GAS2", "GAS_SENSOR", 0)) - checks.append(("GAS_SENSOR", 50)) - - return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0) - - -def get_cam_can_parser(CP): - - signals = [] - - # use steering message to check if panda is connected to frc - checks = [("STEERING_LKA", 42)] - - return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2) - - -class CarState(object): +from selfdrive.car.toyota.values import CAR, DBC, STEER_THRESHOLD, TSS2_CAR, NO_STOP_TIMER_CAR + + +class CarState(CarStateBase): def __init__(self, CP): - #labels for buttons - self.btns_init = [["alca","ALC",["MadMax","Normal","Wifey"]], \ - ["","",[""]], \ - ["","",[""]], \ - ["sound","SND",[""]], \ - ["", "",[""]], \ - ["", "", [""]]] - #if (CP.carFingerprint == CAR.MODELS): - # ALCA PARAMS - # max REAL delta angle for correction vs actuator - self.CL_MAX_ANGLE_DELTA_BP = [10., 44.] - self.CL_MAX_ANGLE_DELTA = [1.8, .3] - - # adjustment factor for merging steer angle to actuator; should be over 4; the higher the smoother - self.CL_ADJUST_FACTOR_BP = [10., 44.] - self.CL_ADJUST_FACTOR = [16. , 8.] - - - # reenrey angle when to let go - self.CL_REENTRY_ANGLE_BP = [10., 44.] - self.CL_REENTRY_ANGLE = [5. , 5.] - - # a jump in angle above the CL_LANE_DETECT_FACTOR means we crossed the line - self.CL_LANE_DETECT_BP = [10., 44.] - self.CL_LANE_DETECT_FACTOR = [1.5, 1.5] - - self.CL_LANE_PASS_BP = [10., 20., 44.] - self.CL_LANE_PASS_TIME = [40.,10., 3.] - - # change lane delta angles and other params - self.CL_MAXD_BP = [10., 32., 44.] - self.CL_MAXD_A = [.358, 0.084, 0.042] #delta angle based on speed; needs fine tune, based on Tesla steer ratio of 16.75 - - self.CL_MIN_V = 8.9 # do not turn if speed less than x m/2; 20 mph = 8.9 m/s - - # do not turn if actuator wants more than x deg for going straight; this should be interp based on speed - self.CL_MAX_A_BP = [10., 44.] - self.CL_MAX_A = [10., 10.] - - # define limits for angle change every 0.1 s - # we need to force correction above 10 deg but less than 20 - # anything more means we are going to steep or not enough in a turn - self.CL_MAX_ACTUATOR_DELTA = 2. - self.CL_MIN_ACTUATOR_DELTA = 0. - self.CL_CORRECTION_FACTOR = 1. - - #duration after we cross the line until we release is a factor of speed - self.CL_TIMEA_BP = [10., 32., 44.] - self.CL_TIMEA_T = [0.7 ,0.30, 0.20] - - #duration to wait (in seconds) with blinkers on before starting to turn - self.CL_WAIT_BEFORE_START = 1 - #END OF ALCA PARAMS - - self.CP = CP - self.can_define = CANDefine(DBC[CP.carFingerprint]['pt']) - self.shifter_values = self.can_define.dv["GEAR_PACKET"]['GEAR'] - self.left_blinker_on = 0 - self.right_blinker_on = 0 + super().__init__(CP) + can_define = CANDefine(DBC[CP.carFingerprint]['pt']) + self.shifter_values = can_define.dv["GEAR_PACKET"]['GEAR'] + + # All TSS2 car have the accurate sensor + self.accurate_steer_angle_seen = CP.carFingerprint in TSS2_CAR + + # On NO_DSU cars but not TSS2 cars the cp.vl["STEER_TORQUE_SENSOR"]['STEER_ANGLE'] + # is zeroed to where the steering angle is at start. + # Need to apply an offset as soon as the steering angle measurements are both received + self.needs_angle_offset = CP.carFingerprint not in TSS2_CAR self.angle_offset = 0. - self.init_angle_offset = False - - # initialize can parser - self.car_fingerprint = CP.carFingerprint - - # vEgo kalman filter - dt = 0.01 - # Q = np.matrix([[10.0, 0.0], [0.0, 100.0]]) - # R = 1e3 - self.v_ego_kf = KF1D(x0=[[0.0], [0.0]], - A=[[1.0, dt], [0.0, 1.0]], - C=[1.0, 0.0], - K=[[0.12287673], [0.29666309]]) - self.v_ego = 0.0 - - - def update(self, cp): - # update prevs, update must run once per loop - self.prev_left_blinker_on = self.left_blinker_on - self.prev_right_blinker_on = self.right_blinker_on - - self.door_all_closed = not any([cp.vl["SEATS_DOORS"]['DOOR_OPEN_FL'], cp.vl["SEATS_DOORS"]['DOOR_OPEN_FR'], - cp.vl["SEATS_DOORS"]['DOOR_OPEN_RL'], cp.vl["SEATS_DOORS"]['DOOR_OPEN_RR']]) - self.seatbelt = not cp.vl["SEATS_DOORS"]['SEATBELT_DRIVER_UNLATCHED'] - - self.brake_pressed = cp.vl["BRAKE_MODULE"]['BRAKE_PRESSED'] + + def update(self, cp, cp_cam): + ret = car.CarState.new_message() + + ret.doorOpen = any([cp.vl["SEATS_DOORS"]['DOOR_OPEN_FL'], cp.vl["SEATS_DOORS"]['DOOR_OPEN_FR'], + cp.vl["SEATS_DOORS"]['DOOR_OPEN_RL'], cp.vl["SEATS_DOORS"]['DOOR_OPEN_RR']]) + ret.seatbeltUnlatched = cp.vl["SEATS_DOORS"]['SEATBELT_DRIVER_UNLATCHED'] != 0 + + ret.brakePressed = cp.vl["BRAKE_MODULE"]['BRAKE_PRESSED'] != 0 + ret.brakeLights = bool(cp.vl["ESP_CONTROL"]['BRAKE_LIGHTS_ACC'] or ret.brakePressed) if self.CP.enableGasInterceptor: - self.pedal_gas = (cp.vl["GAS_SENSOR"]['INTERCEPTOR_GAS'] + cp.vl["GAS_SENSOR"]['INTERCEPTOR_GAS2']) / 2. + ret.gas = (cp.vl["GAS_SENSOR"]['INTERCEPTOR_GAS'] + cp.vl["GAS_SENSOR"]['INTERCEPTOR_GAS2']) / 2. + ret.gasPressed = ret.gas > 15 else: - self.pedal_gas = cp.vl["GAS_PEDAL"]['GAS_PEDAL'] - self.car_gas = self.pedal_gas - self.esp_disabled = cp.vl["ESP_CONTROL"]['TC_DISABLED'] - - # calc best v_ego estimate, by averaging two opposite corners - self.v_wheel_fl = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_FL'] * CV.KPH_TO_MS - self.v_wheel_fr = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_FR'] * CV.KPH_TO_MS - self.v_wheel_rl = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_RL'] * CV.KPH_TO_MS - self.v_wheel_rr = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_RR'] * CV.KPH_TO_MS - v_wheel = float(np.mean([self.v_wheel_fl, self.v_wheel_fr, self.v_wheel_rl, self.v_wheel_rr])) - - # Kalman filter - if abs(v_wheel - self.v_ego) > 2.0: # Prevent large accelerations when car starts at non zero speed - self.v_ego_kf.x = [[v_wheel], [0.0]] - - self.v_ego_raw = v_wheel - v_ego_x = self.v_ego_kf.update(v_wheel) - self.v_ego = float(v_ego_x[0]) - self.a_ego = float(v_ego_x[1]) - self.standstill = not v_wheel > 0.001 - - if self.CP.carFingerprint in TSS2_CAR: - self.angle_steers = cp.vl["STEER_TORQUE_SENSOR"]['STEER_ANGLE'] - elif self.CP.carFingerprint in NO_DSU_CAR: - # cp.vl["STEER_TORQUE_SENSOR"]['STEER_ANGLE'] is zeroed to where the steering angle is at start. - # need to apply an offset as soon as the steering angle measurements are both received - self.angle_steers = cp.vl["STEER_TORQUE_SENSOR"]['STEER_ANGLE'] - self.angle_offset - angle_wheel = cp.vl["STEER_ANGLE_SENSOR"]['STEER_ANGLE'] + cp.vl["STEER_ANGLE_SENSOR"]['STEER_FRACTION'] - if abs(angle_wheel) > 1e-3 and abs(self.angle_steers) > 1e-3 and not self.init_angle_offset: - self.init_angle_offset = True - self.angle_offset = self.angle_steers - angle_wheel + ret.gas = cp.vl["GAS_PEDAL"]['GAS_PEDAL'] + ret.gasPressed = cp.vl["PCM_CRUISE"]['GAS_RELEASED'] == 0 + + ret.wheelSpeeds.fl = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_FL'] * CV.KPH_TO_MS + ret.wheelSpeeds.fr = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_FR'] * CV.KPH_TO_MS + ret.wheelSpeeds.rl = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_RL'] * CV.KPH_TO_MS + ret.wheelSpeeds.rr = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_RR'] * CV.KPH_TO_MS + ret.vEgoRaw = mean([ret.wheelSpeeds.fl, ret.wheelSpeeds.fr, ret.wheelSpeeds.rl, ret.wheelSpeeds.rr]) + ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) + + ret.standstill = ret.vEgoRaw < 0.001 + + # Some newer models have a more accurate angle measurement in the TORQUE_SENSOR message. Use if non-zero + if abs(cp.vl["STEER_TORQUE_SENSOR"]['STEER_ANGLE']) > 1e-3: + self.accurate_steer_angle_seen = True + + if self.accurate_steer_angle_seen: + ret.steeringAngle = cp.vl["STEER_TORQUE_SENSOR"]['STEER_ANGLE'] - self.angle_offset + + if self.needs_angle_offset: + angle_wheel = cp.vl["STEER_ANGLE_SENSOR"]['STEER_ANGLE'] + cp.vl["STEER_ANGLE_SENSOR"]['STEER_FRACTION'] + if abs(angle_wheel) > 1e-3 and abs(ret.steeringAngle) > 1e-3: + self.needs_angle_offset = False + self.angle_offset = ret.steeringAngle - angle_wheel else: - self.angle_steers = cp.vl["STEER_ANGLE_SENSOR"]['STEER_ANGLE'] + cp.vl["STEER_ANGLE_SENSOR"]['STEER_FRACTION'] - self.angle_steers_rate = cp.vl["STEER_ANGLE_SENSOR"]['STEER_RATE'] + ret.steeringAngle = cp.vl["STEER_ANGLE_SENSOR"]['STEER_ANGLE'] + cp.vl["STEER_ANGLE_SENSOR"]['STEER_FRACTION'] + + ret.steeringRate = cp.vl["STEER_ANGLE_SENSOR"]['STEER_RATE'] can_gear = int(cp.vl["GEAR_PACKET"]['GEAR']) - self.gear_shifter = parse_gear_shifter(can_gear, self.shifter_values) - self.main_on = cp.vl["PCM_CRUISE_2"]['MAIN_ON'] - self.left_blinker_on = cp.vl["STEERING_LEVERS"]['TURN_SIGNALS'] == 1 - self.right_blinker_on = cp.vl["STEERING_LEVERS"]['TURN_SIGNALS'] == 2 + ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(can_gear, None)) + ret.leftBlinker = cp.vl["STEERING_LEVERS"]['TURN_SIGNALS'] == 1 + ret.rightBlinker = cp.vl["STEERING_LEVERS"]['TURN_SIGNALS'] == 2 - # 2 is standby, 10 is active. TODO: check that everything else is really a faulty state - self.steer_state = cp.vl["EPS_STATUS"]['LKA_STATE'] - self.steer_error = cp.vl["EPS_STATUS"]['LKA_STATE'] not in [1, 5] - self.ipas_active = cp.vl['EPS_STATUS']['IPAS_STATE'] == 3 - self.brake_error = 0 - self.steer_torque_driver = cp.vl["STEER_TORQUE_SENSOR"]['STEER_TORQUE_DRIVER'] - self.steer_torque_motor = cp.vl["STEER_TORQUE_SENSOR"]['STEER_TORQUE_EPS'] + ret.steeringTorque = cp.vl["STEER_TORQUE_SENSOR"]['STEER_TORQUE_DRIVER'] + ret.steeringTorqueEps = cp.vl["STEER_TORQUE_SENSOR"]['STEER_TORQUE_EPS'] # we could use the override bit from dbc, but it's triggered at too high torque values - self.steer_override = abs(self.steer_torque_driver) > STEER_THRESHOLD + ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD + ret.steerWarning = cp.vl["EPS_STATUS"]['LKA_STATE'] not in [1, 5] - self.user_brake = 0 - self.v_cruise_pcm = cp.vl["PCM_CRUISE_2"]['SET_SPEED'] + if self.CP.carFingerprint == CAR.LEXUS_IS: + ret.cruiseState.available = cp.vl["DSU_CRUISE"]['MAIN_ON'] != 0 + ret.cruiseState.speed = cp.vl["DSU_CRUISE"]['SET_SPEED'] * CV.KPH_TO_MS + self.low_speed_lockout = False + else: + ret.cruiseState.available = cp.vl["PCM_CRUISE_2"]['MAIN_ON'] != 0 + ret.cruiseState.speed = cp.vl["PCM_CRUISE_2"]['SET_SPEED'] * CV.KPH_TO_MS + self.low_speed_lockout = cp.vl["PCM_CRUISE_2"]['LOW_SPEED_LOCKOUT'] == 2 self.pcm_acc_status = cp.vl["PCM_CRUISE"]['CRUISE_STATE'] - self.pcm_acc_active = bool(cp.vl["PCM_CRUISE"]['CRUISE_ACTIVE']) - self.low_speed_lockout = cp.vl["PCM_CRUISE_2"]['LOW_SPEED_LOCKOUT'] == 2 - self.brake_lights = bool(cp.vl["ESP_CONTROL"]['BRAKE_LIGHTS_ACC'] or self.brake_pressed) + if self.CP.carFingerprint in NO_STOP_TIMER_CAR or self.CP.enableGasInterceptor: + # ignore standstill in hybrid vehicles, since pcm allows to restart without + # receiving any special command. Also if interceptor is detected + ret.cruiseState.standstill = False + else: + ret.cruiseState.standstill = self.pcm_acc_status == 7 + ret.cruiseState.enabled = bool(cp.vl["PCM_CRUISE"]['CRUISE_ACTIVE']) + # TODO: CRUISE_STATE is a 4 bit signal, find any other non-adaptive cruise states + ret.cruiseState.nonAdaptive = cp.vl["PCM_CRUISE"]['CRUISE_STATE'] in [5] + if self.CP.carFingerprint == CAR.PRIUS: - self.generic_toggle = cp.vl["AUTOPARK_STATUS"]['STATE'] != 0 + ret.genericToggle = cp.vl["AUTOPARK_STATUS"]['STATE'] != 0 + else: + ret.genericToggle = bool(cp.vl["LIGHT_STALK"]['AUTO_HIGH_BEAM']) + ret.stockAeb = bool(cp_cam.vl["PRE_COLLISION"]["PRECOLLISION_ACTIVE"] and cp_cam.vl["PRE_COLLISION"]["FORCE"] < -1e-5) + + ret.espDisabled = cp.vl["ESP_CONTROL"]['TC_DISABLED'] != 0 + # 2 is standby, 10 is active. TODO: check that everything else is really a faulty state + self.steer_state = cp.vl["EPS_STATUS"]['LKA_STATE'] + + if self.CP.carFingerprint in TSS2_CAR: + ret.leftBlindspot = (cp.vl["BSM"]['L_ADJACENT'] == 1) or (cp.vl["BSM"]['L_APPROACHING'] == 1) + ret.rightBlindspot = (cp.vl["BSM"]['R_ADJACENT'] == 1) or (cp.vl["BSM"]['R_APPROACHING'] == 1) + + return ret + + @staticmethod + def get_can_parser(CP): + + signals = [ + # sig_name, sig_address, default + ("STEER_ANGLE", "STEER_ANGLE_SENSOR", 0), + ("GEAR", "GEAR_PACKET", 0), + ("BRAKE_PRESSED", "BRAKE_MODULE", 0), + ("GAS_PEDAL", "GAS_PEDAL", 0), + ("WHEEL_SPEED_FL", "WHEEL_SPEEDS", 0), + ("WHEEL_SPEED_FR", "WHEEL_SPEEDS", 0), + ("WHEEL_SPEED_RL", "WHEEL_SPEEDS", 0), + ("WHEEL_SPEED_RR", "WHEEL_SPEEDS", 0), + ("DOOR_OPEN_FL", "SEATS_DOORS", 1), + ("DOOR_OPEN_FR", "SEATS_DOORS", 1), + ("DOOR_OPEN_RL", "SEATS_DOORS", 1), + ("DOOR_OPEN_RR", "SEATS_DOORS", 1), + ("SEATBELT_DRIVER_UNLATCHED", "SEATS_DOORS", 1), + ("TC_DISABLED", "ESP_CONTROL", 1), + ("STEER_FRACTION", "STEER_ANGLE_SENSOR", 0), + ("STEER_RATE", "STEER_ANGLE_SENSOR", 0), + ("CRUISE_ACTIVE", "PCM_CRUISE", 0), + ("CRUISE_STATE", "PCM_CRUISE", 0), + ("GAS_RELEASED", "PCM_CRUISE", 1), + ("STEER_TORQUE_DRIVER", "STEER_TORQUE_SENSOR", 0), + ("STEER_TORQUE_EPS", "STEER_TORQUE_SENSOR", 0), + ("STEER_ANGLE", "STEER_TORQUE_SENSOR", 0), + ("TURN_SIGNALS", "STEERING_LEVERS", 3), # 3 is no blinkers + ("LKA_STATE", "EPS_STATUS", 0), + ("BRAKE_LIGHTS_ACC", "ESP_CONTROL", 0), + ("AUTO_HIGH_BEAM", "LIGHT_STALK", 0), + ] + + checks = [ + ("BRAKE_MODULE", 40), + ("GAS_PEDAL", 33), + ("WHEEL_SPEEDS", 80), + ("STEER_ANGLE_SENSOR", 80), + ("PCM_CRUISE", 33), + ("STEER_TORQUE_SENSOR", 50), + ("EPS_STATUS", 25), + ] + + if CP.carFingerprint == CAR.LEXUS_IS: + signals.append(("MAIN_ON", "DSU_CRUISE", 0)) + signals.append(("SET_SPEED", "DSU_CRUISE", 0)) + checks.append(("DSU_CRUISE", 5)) else: - self.generic_toggle = bool(cp.vl["LIGHT_STALK"]['AUTO_HIGH_BEAM']) + signals.append(("MAIN_ON", "PCM_CRUISE_2", 0)) + signals.append(("SET_SPEED", "PCM_CRUISE_2", 0)) + signals.append(("LOW_SPEED_LOCKOUT", "PCM_CRUISE_2", 0)) + checks.append(("PCM_CRUISE_2", 33)) + + if CP.carFingerprint == CAR.PRIUS: + signals += [("STATE", "AUTOPARK_STATUS", 0)] + + # add gas interceptor reading if we are using it + if CP.enableGasInterceptor: + signals.append(("INTERCEPTOR_GAS", "GAS_SENSOR", 0)) + signals.append(("INTERCEPTOR_GAS2", "GAS_SENSOR", 0)) + checks.append(("GAS_SENSOR", 50)) + + if CP.carFingerprint in TSS2_CAR: + signals += [("L_ADJACENT", "BSM", 0)] + signals += [("L_APPROACHING", "BSM", 0)] + signals += [("R_ADJACENT", "BSM", 0)] + signals += [("R_APPROACHING", "BSM", 0)] + + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0) + + @staticmethod + def get_cam_can_parser(CP): + + signals = [ + ("FORCE", "PRE_COLLISION", 0), + ("PRECOLLISION_ACTIVE", "PRE_COLLISION", 0) + ] + + # use steering message to check if panda is connected to frc + checks = [ + ("STEERING_LKA", 42) + ] + + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2) diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index bc7482ab7ab78b..b2a3c70b2c79f9 100755 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -1,69 +1,33 @@ -#!/usr/bin/env python -from common.realtime import sec_since_boot +#!/usr/bin/env python3 from cereal import car from selfdrive.config import Conversions as CV -from selfdrive.controls.lib.drive_helpers import EventTypes as ET, create_event -from selfdrive.controls.lib.vehicle_model import VehicleModel -from selfdrive.car.toyota.carstate import CarState, get_can_parser, get_cam_can_parser -from selfdrive.car.toyota.values import ECU, check_ecu_msgs, CAR, NO_STOP_TIMER_CAR -from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness +from selfdrive.car.toyota.values import Ecu, ECU_FINGERPRINT, CAR, TSS2_CAR, FINGERPRINTS +from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, is_ecu_disconnected, gen_empty_fingerprint from selfdrive.swaglog import cloudlog +from selfdrive.car.interfaces import CarInterfaceBase -class CarInterface(object): - def __init__(self, CP, CarController): - self.CP = CP - self.VM = VehicleModel(CP) +EventName = car.CarEvent.EventName - self.frame = 0 - self.gas_pressed_prev = False - self.brake_pressed_prev = False - self.cruise_enabled_prev = False - - # *** init the major players *** - self.CS = CarState(CP) - - self.cp = get_can_parser(CP) - self.cp_cam = get_cam_can_parser(CP) - - self.forwarding_camera = False - - self.CC = None - if CarController is not None: - self.CC = CarController(self.cp.dbc_name, CP.carFingerprint, CP.enableCamera, CP.enableDsu, CP.enableApgs) +class CarInterface(CarInterfaceBase): @staticmethod def compute_gb(accel, speed): return float(accel) / 3.0 @staticmethod - def calc_accel_override(a_ego, a_target, v_ego, v_target): - return 1.0 - - @staticmethod - def get_params(candidate, fingerprint, vin="", is_panda_black=False): - - ret = car.CarParams.new_message() + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # pylint: disable=dangerous-default-value + ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "toyota" - ret.carFingerprint = candidate - ret.carVin = vin - ret.isPandaBlack = is_panda_black - ret.safetyModel = car.CarParams.SafetyModel.toyota - # pedal - ret.enableCruise = not ret.enableGasInterceptor - ret.steerActuatorDelay = 0.12 # Default delay, Prius has larger delay + ret.steerLimitTimer = 0.4 - if candidate not in [CAR.PRIUS, CAR.RAV4, CAR.RAV4H]: # These cars use LQR/INDI + if candidate not in [CAR.PRIUS, CAR.RAV4, CAR.RAV4H]: # These cars use LQR/INDI ret.lateralTuning.init('pid') ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] - ret.steerReactance = 1.0 - ret.steerInductance = 1.0 - ret.steerResistance = 1.0 - if candidate == CAR.PRIUS: stop_and_go = True ret.safetyParam = 66 # see conversion factor for STEER_TORQUE_EPS in dbc file @@ -77,19 +41,6 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): ret.lateralTuning.indi.outerLoopGain = 3.0 ret.lateralTuning.indi.timeConstant = 1.0 ret.lateralTuning.indi.actuatorEffectiveness = 1.0 - - # TODO: Determine if this is better than INDI - # ret.lateralTuning.init('lqr') - # ret.lateralTuning.lqr.scale = 1500.0 - # ret.lateralTuning.lqr.ki = 0.01 - - # ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268] - # ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05] - # ret.lateralTuning.lqr.c = [1., 0.] - # ret.lateralTuning.lqr.k = [-110.73572306, 451.22718255] - # ret.lateralTuning.lqr.l = [0.03233671, 0.03185757] - # ret.lateralTuning.lqr.dcGain = 0.002237852961363602 - ret.steerActuatorDelay = 0.5 elif candidate in [CAR.RAV4, CAR.RAV4H]: @@ -113,7 +64,7 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): elif candidate == CAR.COROLLA: stop_and_go = False - ret.safetyParam = 100 + ret.safetyParam = 88 ret.wheelbase = 2.70 ret.steerRatio = 18.27 tire_stiffness_factor = 0.444 # not optimized yet @@ -121,6 +72,16 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2], [0.05]] ret.lateralTuning.pid.kf = 0.00003 # full torque for 20 deg at 80mph means 0.00007818594 + elif candidate == CAR.LEXUS_RX: + stop_and_go = True + ret.safetyParam = 73 + ret.wheelbase = 2.79 + ret.steerRatio = 14.8 + tire_stiffness_factor = 0.5533 + ret.mass = 4387. * CV.LB_TO_KG + STD_CARGO_KG + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.05]] + ret.lateralTuning.pid.kf = 0.00006 + elif candidate == CAR.LEXUS_RXH: stop_and_go = True ret.safetyParam = 73 @@ -131,6 +92,26 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] ret.lateralTuning.pid.kf = 0.00006 # full torque for 10 deg at 80mph means 0.00007818594 + elif candidate == CAR.LEXUS_RX_TSS2: + stop_and_go = True + ret.safetyParam = 73 + ret.wheelbase = 2.79 + ret.steerRatio = 14.8 + tire_stiffness_factor = 0.5533 # not optimized yet + ret.mass = 4387. * CV.LB_TO_KG + STD_CARGO_KG + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] + ret.lateralTuning.pid.kf = 0.00007818594 + + elif candidate == CAR.LEXUS_RXH_TSS2: + stop_and_go = True + ret.safetyParam = 73 + ret.wheelbase = 2.79 + ret.steerRatio = 16.0 # 14.8 is spec end-to-end + tire_stiffness_factor = 0.444 # not optimized yet + ret.mass = 4481.0 * CV.LB_TO_KG + STD_CARGO_KG # mean between min and max + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.15]] + ret.lateralTuning.pid.kf = 0.00007818594 + elif candidate in [CAR.CHR, CAR.CHRH]: stop_and_go = True ret.safetyParam = 73 @@ -141,23 +122,33 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.723], [0.0428]] ret.lateralTuning.pid.kf = 0.00006 - elif candidate in [CAR.CAMRY, CAR.CAMRYH]: + elif candidate in [CAR.CAMRY, CAR.CAMRYH, CAR.CAMRY_TSS2]: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 2.82448 ret.steerRatio = 13.7 tire_stiffness_factor = 0.7933 - ret.mass = 3400. * CV.LB_TO_KG + STD_CARGO_KG #mean between normal and hybrid + ret.mass = 3400. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] ret.lateralTuning.pid.kf = 0.00006 + elif candidate in [CAR.HIGHLANDER_TSS2, CAR.HIGHLANDERH_TSS2]: + stop_and_go = True + ret.safetyParam = 73 + ret.wheelbase = 2.84988 # 112.2 in = 2.84988 m + ret.steerRatio = 16.0 + tire_stiffness_factor = 0.8 + ret.mass = 4700. * CV.LB_TO_KG + STD_CARGO_KG # 4260 + 4-5 people + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.18], [0.015]] # community tuning + ret.lateralTuning.pid.kf = 0.00012 # community tuning + elif candidate in [CAR.HIGHLANDER, CAR.HIGHLANDERH]: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 2.78 ret.steerRatio = 16.0 tire_stiffness_factor = 0.8 - ret.mass = 4607. * CV.LB_TO_KG + STD_CARGO_KG #mean between normal and hybrid limited + ret.mass = 4607. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid limited ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.18], [0.015]] # community tuning ret.lateralTuning.pid.kf = 0.00012 # community tuning @@ -165,7 +156,7 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): stop_and_go = False ret.safetyParam = 73 ret.wheelbase = 2.82 - ret.steerRatio = 14.8 #Found at https://pressroom.toyota.com/releases/2016+avalon+product+specs.download + ret.steerRatio = 14.8 # Found at https://pressroom.toyota.com/releases/2016+avalon+product+specs.download tire_stiffness_factor = 0.7983 ret.mass = 3505. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.17], [0.03]] @@ -177,12 +168,35 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): ret.wheelbase = 2.68986 ret.steerRatio = 14.3 tire_stiffness_factor = 0.7933 - ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.15], [0.05]] ret.mass = 3370. * CV.LB_TO_KG + STD_CARGO_KG - ret.lateralTuning.pid.kf = 0.00007818594 + ret.lateralTuning.pid.kf = 0.00004 + + for fw in car_fw: + if fw.ecu == "eps" and fw.fwVersion == b"8965B42170\x00\x00\x00\x00\x00\x00": + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] + ret.lateralTuning.pid.kf = 0.00007818594 + break + + elif candidate == CAR.RAV4H_TSS2: + stop_and_go = True + ret.safetyParam = 73 + ret.wheelbase = 2.68986 + ret.steerRatio = 14.3 + tire_stiffness_factor = 0.7933 + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.15], [0.05]] + ret.mass = 3800. * CV.LB_TO_KG + STD_CARGO_KG + ret.lateralTuning.pid.kf = 0.00004 + + for fw in car_fw: + if fw.ecu == "eps" and fw.fwVersion == b"8965B42170\x00\x00\x00\x00\x00\x00": + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] + ret.lateralTuning.pid.kf = 0.00007818594 + break - elif candidate == CAR.COROLLA_TSS2: + elif candidate in [CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2]: stop_and_go = True + ret.minSpeedCan = 0.375 ret.safetyParam = 73 ret.wheelbase = 2.63906 ret.steerRatio = 13.9 @@ -191,11 +205,11 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] ret.lateralTuning.pid.kf = 0.00007818594 - elif candidate == CAR.LEXUS_ESH_TSS2: + elif candidate in [CAR.LEXUS_ES_TSS2, CAR.LEXUS_ESH_TSS2]: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 2.8702 - ret.steerRatio = 16.0 # not optimized + ret.steerRatio = 16.0 # not optimized tire_stiffness_factor = 0.444 # not optimized yet ret.mass = 3704. * CV.LB_TO_KG + STD_CARGO_KG ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] @@ -205,22 +219,55 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 3.03 - ret.steerRatio = 16.0 + ret.steerRatio = 15.5 tire_stiffness_factor = 0.444 ret.mass = 4590. * CV.LB_TO_KG + STD_CARGO_KG + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.19], [0.02]] + ret.lateralTuning.pid.kf = 0.00007818594 + + elif candidate == CAR.LEXUS_IS: + stop_and_go = False + ret.safetyParam = 77 + ret.wheelbase = 2.79908 + ret.steerRatio = 13.3 + tire_stiffness_factor = 0.444 + ret.mass = 3736.8 * CV.LB_TO_KG + STD_CARGO_KG ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.05]] + ret.lateralTuning.pid.kf = 0.00006 + + elif candidate == CAR.LEXUS_CTH: + stop_and_go = True + ret.safetyParam = 100 + ret.wheelbase = 2.60 + ret.steerRatio = 18.6 + tire_stiffness_factor = 0.517 + ret.mass = 3108 * CV.LB_TO_KG + STD_CARGO_KG # mean between min and max + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.05]] + ret.lateralTuning.pid.kf = 0.00007 + + elif candidate in [CAR.LEXUS_NXH, CAR.LEXUS_NX]: + stop_and_go = True + ret.safetyParam = 73 + ret.wheelbase = 2.66 + ret.steerRatio = 14.7 + tire_stiffness_factor = 0.444 # not optimized yet + ret.mass = 4070 * CV.LB_TO_KG + STD_CARGO_KG + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] + ret.lateralTuning.pid.kf = 0.00006 + + elif candidate == CAR.PRIUS_TSS2: + stop_and_go = True + ret.safetyParam = 73 + ret.wheelbase = 2.70002 # from toyota online sepc. + ret.steerRatio = 13.4 # True steerRation from older prius + tire_stiffness_factor = 0.6371 # hand-tune + ret.mass = 3115. * CV.LB_TO_KG + STD_CARGO_KG + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.35], [0.15]] ret.lateralTuning.pid.kf = 0.00007818594 ret.steerRateCost = 1. ret.centerToFront = ret.wheelbase * 0.44 - #detect the Pedal address - ret.enableGasInterceptor = 0x201 in fingerprint - - # min speed to enable ACC. if car can do stop and go, then set enabling speed - # to a negative value, so it won't matter. - ret.minEnableSpeed = -1. if (stop_and_go or ret.enableGasInterceptor) else 19. * CV.MPH_TO_MS - # TODO: get actual value, for now starting with reasonable value for # civic and scaling by mass and wheelbase ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) @@ -230,33 +277,30 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront, tire_stiffness_factor=tire_stiffness_factor) - # no rear steering, at least on the listed cars above - ret.steerRatioRear = 0. - ret.steerControlType = car.CarParams.SteerControlType.torque - - # steer, gas, brake limitations VS speed - ret.steerMaxBP = [16. * CV.KPH_TO_MS, 45. * CV.KPH_TO_MS] # breakpoints at 1 and 40 kph - ret.steerMaxV = [1., 1.] # 2/3rd torque allowed above 45 kph - ret.brakeMaxBP = [0.] - ret.brakeMaxV = [1.] + ret.enableCamera = True + # Detect smartDSU, which intercepts ACC_CMD from the DSU allowing openpilot to send it + smartDsu = 0x2FF in fingerprint[0] + # In TSS2 cars the camera does long control + ret.enableDsu = is_ecu_disconnected(fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate, Ecu.dsu) and candidate not in TSS2_CAR + ret.enableGasInterceptor = 0x201 in fingerprint[0] + # if the smartDSU is detected, openpilot can send ACC_CMD (and the smartDSU will block it from the DSU) or not (the DSU is "connected") + ret.openpilotLongitudinalControl = ret.enableCamera and (smartDsu or ret.enableDsu or candidate in TSS2_CAR) + cloudlog.warning("ECU Camera Simulated: %r", ret.enableCamera) + cloudlog.warning("ECU DSU Simulated: %r", ret.enableDsu) + cloudlog.warning("ECU Gas Interceptor: %r", ret.enableGasInterceptor) - ret.enableCamera = not check_ecu_msgs(fingerprint, ECU.CAM) or is_panda_black - ret.enableDsu = not check_ecu_msgs(fingerprint, ECU.DSU) - ret.enableApgs = False #not check_ecu_msgs(fingerprint, ECU.APGS) - ret.openpilotLongitudinalControl = ret.enableCamera and ret.enableDsu - cloudlog.warn("ECU Camera Simulated: %r", ret.enableCamera) - cloudlog.warn("ECU DSU Simulated: %r", ret.enableDsu) - cloudlog.warn("ECU APGS Simulated: %r", ret.enableApgs) - cloudlog.warn("ECU Gas Interceptor: %r", ret.enableGasInterceptor) + # min speed to enable ACC. if car can do stop and go, then set enabling speed + # to a negative value, so it won't matter. + ret.minEnableSpeed = -1. if (stop_and_go or ret.enableGasInterceptor) else 19. * CV.MPH_TO_MS - ret.steerLimitAlert = False + # removing the DSU disables AEB and it's considered a community maintained feature + # intercepting the DSU is a community feature since it requires unofficial hardware + ret.communityFeature = ret.enableGasInterceptor or ret.enableDsu or smartDsu ret.longitudinalTuning.deadzoneBP = [0., 9.] ret.longitudinalTuning.deadzoneV = [0., .15] ret.longitudinalTuning.kpBP = [0., 5., 35.] ret.longitudinalTuning.kiBP = [0., 35.] - ret.stoppingControl = False - ret.startAccel = 0.0 if ret.enableGasInterceptor: ret.gasMaxBP = [0., 9., 35] @@ -274,153 +318,40 @@ def get_params(candidate, fingerprint, vin="", is_panda_black=False): # returns a car.CarState def update(self, c, can_strings): # ******************* do can recv ******************* - self.cp.update_strings(int(sec_since_boot() * 1e9), can_strings) - - # run the cam can update for 10s as we just need to know if the camera is alive - if self.frame < 1000: - self.cp_cam.update_strings(int(sec_since_boot() * 1e9), can_strings) - - self.CS.update(self.cp) - - # create message - ret = car.CarState.new_message() - - ret.canValid = self.cp.can_valid - - # speeds - ret.vEgo = self.CS.v_ego - ret.vEgoRaw = self.CS.v_ego_raw - ret.aEgo = self.CS.a_ego - ret.yawRate = self.VM.yaw_rate(self.CS.angle_steers * CV.DEG_TO_RAD, self.CS.v_ego) - ret.standstill = self.CS.standstill - ret.wheelSpeeds.fl = self.CS.v_wheel_fl - ret.wheelSpeeds.fr = self.CS.v_wheel_fr - ret.wheelSpeeds.rl = self.CS.v_wheel_rl - ret.wheelSpeeds.rr = self.CS.v_wheel_rr - - # gear shifter - ret.gearShifter = self.CS.gear_shifter - - # gas pedal - ret.gas = self.CS.car_gas - if self.CP.enableGasInterceptor: - # use interceptor values to disengage on pedal press - ret.gasPressed = self.CS.pedal_gas > 15 - else: - ret.gasPressed = self.CS.pedal_gas > 0 + self.cp.update_strings(can_strings) + self.cp_cam.update_strings(can_strings) - # brake pedal - ret.brake = self.CS.user_brake - ret.brakePressed = self.CS.brake_pressed != 0 - ret.brakeLights = self.CS.brake_lights + ret = self.CS.update(self.cp, self.cp_cam) - # steering wheel - ret.steeringAngle = self.CS.angle_steers - - if self.CP.carFingerprint in [CAR.RAV4H, CAR.RAV4, CAR.RAV4H, CAR.COROLLA]: - ret.steeringRate = self.CS.angle_steers_rate - else: - ret.steeringRate = 0 - - ret.steeringTorque = self.CS.steer_torque_driver - ret.steeringTorqueEps = self.CS.steer_torque_motor - ret.steeringPressed = self.CS.steer_override - - # cruise state - ret.cruiseState.enabled = self.CS.pcm_acc_active - ret.cruiseState.speed = self.CS.v_cruise_pcm * CV.KPH_TO_MS - ret.cruiseState.available = bool(self.CS.main_on) - ret.cruiseState.speedOffset = 0. - - if self.CP.carFingerprint in NO_STOP_TIMER_CAR or self.CP.enableGasInterceptor: - # ignore standstill in hybrid vehicles, since pcm allows to restart without - # receiving any special command - # also if interceptor is detected - ret.cruiseState.standstill = False - else: - ret.cruiseState.standstill = self.CS.pcm_acc_status == 7 - - buttonEvents = [] - if self.CS.left_blinker_on != self.CS.prev_left_blinker_on: - be = car.CarState.ButtonEvent.new_message() - be.type = 'leftBlinker' - be.pressed = self.CS.left_blinker_on != 0 - buttonEvents.append(be) - - if self.CS.right_blinker_on != self.CS.prev_right_blinker_on: - be = car.CarState.ButtonEvent.new_message() - be.type = 'rightBlinker' - be.pressed = self.CS.right_blinker_on != 0 - buttonEvents.append(be) - - ret.buttonEvents = buttonEvents - ret.leftBlinker = bool(self.CS.left_blinker_on) - ret.rightBlinker = bool(self.CS.right_blinker_on) - - ret.doorOpen = not self.CS.door_all_closed - ret.seatbeltUnlatched = not self.CS.seatbelt - - ret.genericToggle = self.CS.generic_toggle + ret.canValid = self.cp.can_valid and self.cp_cam.can_valid + ret.steeringRateLimited = self.CC.steer_rate_limited if self.CC is not None else False # events - events = [] - if self.cp_cam.can_valid: - self.forwarding_camera = True - - if not ret.gearShifter == 'drive' and self.CP.enableDsu: - events.append(create_event('wrongGear', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if ret.doorOpen: - events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if ret.seatbeltUnlatched: - events.append(create_event('seatbeltNotLatched', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if self.CS.esp_disabled and self.CP.enableDsu: - events.append(create_event('espDisabled', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if not self.CS.main_on and self.CP.enableDsu: - events.append(create_event('wrongCarMode', [ET.NO_ENTRY, ET.USER_DISABLE])) - if ret.gearShifter == 'reverse' and self.CP.enableDsu: - events.append(create_event('reverseGear', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) - if self.CS.steer_error: - events.append(create_event('steerTempUnavailable', [ET.NO_ENTRY, ET.WARNING])) - if self.CS.low_speed_lockout and self.CP.enableDsu: - events.append(create_event('lowSpeedLockout', [ET.NO_ENTRY, ET.PERMANENT])) - if ret.vEgo < self.CP.minEnableSpeed and self.CP.enableDsu: - events.append(create_event('speedTooLow', [ET.NO_ENTRY])) + events = self.create_common_events(ret) + + if self.CS.low_speed_lockout and self.CP.openpilotLongitudinalControl: + events.add(EventName.lowSpeedLockout) + if ret.vEgo < self.CP.minEnableSpeed and self.CP.openpilotLongitudinalControl: + events.add(EventName.belowEngageSpeed) if c.actuators.gas > 0.1: # some margin on the actuator to not false trigger cancellation while stopping - events.append(create_event('speedTooLow', [ET.IMMEDIATE_DISABLE])) + events.add(EventName.speedTooLow) if ret.vEgo < 0.001: # while in standstill, send a user alert - events.append(create_event('manualRestart', [ET.WARNING])) - - # enable request in prius is simple, as we activate when Toyota is active (rising edge) - if ret.cruiseState.enabled and not self.cruise_enabled_prev: - events.append(create_event('pcmEnable', [ET.ENABLE])) - elif not ret.cruiseState.enabled: - events.append(create_event('pcmDisable', [ET.USER_DISABLE])) - - # disable on pedals rising edge or when brake is pressed and speed isn't zero - if (ret.gasPressed and not self.gas_pressed_prev) or \ - (ret.brakePressed and (not self.brake_pressed_prev or ret.vEgo > 0.001)): - events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) - - if ret.gasPressed: - events.append(create_event('pedalPressed', [ET.PRE_ENABLE])) - - ret.events = events + events.add(EventName.manualRestart) - self.gas_pressed_prev = ret.gasPressed - self.brake_pressed_prev = ret.brakePressed - self.cruise_enabled_prev = ret.cruiseState.enabled + ret.events = events.to_msg() - return ret.as_reader() + self.CS.out = ret.as_reader() + return self.CS.out # pass in a car.CarControl # to be called @ 100hz def apply(self, c): can_sends = self.CC.update(c.enabled, self.CS, self.frame, - c.actuators, c.cruiseControl.cancel, c.hudControl.visualAlert, - self.forwarding_camera, c.hudControl.leftLaneVisible, + c.actuators, c.cruiseControl.cancel, + c.hudControl.visualAlert, c.hudControl.leftLaneVisible, c.hudControl.rightLaneVisible, c.hudControl.leadVisible, c.hudControl.leftLaneDepart, c.hudControl.rightLaneDepart) diff --git a/selfdrive/car/toyota/radar_interface.py b/selfdrive/car/toyota/radar_interface.py index 4e0a0e809b777a..a7d2ec37bb26db 100755 --- a/selfdrive/car/toyota/radar_interface.py +++ b/selfdrive/car/toyota/radar_interface.py @@ -1,14 +1,10 @@ -#!/usr/bin/env python -import os -import time -from selfdrive.can.parser import CANParser +#!/usr/bin/env python3 +from opendbc.can.parser import CANParser from cereal import car -from common.realtime import sec_since_boot from selfdrive.car.toyota.values import NO_DSU_CAR, DBC, TSS2_CAR +from selfdrive.car.interfaces import RadarInterfaceBase def _create_radar_can_parser(car_fingerprint): - dbc_f = DBC[car_fingerprint]['radar'] - if car_fingerprint in TSS2_CAR: RADAR_A_MSGS = list(range(0x180, 0x190)) RADAR_B_MSGS = list(range(0x190, 0x1a0)) @@ -19,22 +15,20 @@ def _create_radar_can_parser(car_fingerprint): msg_a_n = len(RADAR_A_MSGS) msg_b_n = len(RADAR_B_MSGS) - signals = zip(['LONG_DIST'] * msg_a_n + ['NEW_TRACK'] * msg_a_n + ['LAT_DIST'] * msg_a_n + + signals = list(zip(['LONG_DIST'] * msg_a_n + ['NEW_TRACK'] * msg_a_n + ['LAT_DIST'] * msg_a_n + ['REL_SPEED'] * msg_a_n + ['VALID'] * msg_a_n + ['SCORE'] * msg_b_n, RADAR_A_MSGS * 5 + RADAR_B_MSGS, - [255] * msg_a_n + [1] * msg_a_n + [0] * msg_a_n + [0] * msg_a_n + [0] * msg_a_n + [0] * msg_b_n) + [255] * msg_a_n + [1] * msg_a_n + [0] * msg_a_n + [0] * msg_a_n + [0] * msg_a_n + [0] * msg_b_n)) - checks = zip(RADAR_A_MSGS + RADAR_B_MSGS, [20]*(msg_a_n + msg_b_n)) + checks = list(zip(RADAR_A_MSGS + RADAR_B_MSGS, [20]*(msg_a_n + msg_b_n))) - return CANParser(os.path.splitext(dbc_f)[0], signals, checks, 1) + return CANParser(DBC[car_fingerprint]['radar'], signals, checks, 1) -class RadarInterface(object): +class RadarInterface(RadarInterfaceBase): def __init__(self, CP): - # radar - self.pts = {} + super().__init__(CP) self.track_id = 0 - - self.delay = 0.0 # Delay of radar + self.radar_ts = CP.radarTimeStep if CP.carFingerprint in TSS2_CAR: self.RADAR_A_MSGS = list(range(0x180, 0x190)) @@ -55,17 +49,15 @@ def __init__(self, CP): def update(self, can_strings): if self.no_radar: - time.sleep(0.05) - return car.RadarData.new_message() + return super().update(None) - tm = int(sec_since_boot() * 1e9) - vls = self.rcp.update_strings(tm, can_strings) + vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) if self.trigger_msg not in self.updated_messages: return None - rr = self._update(self.updated_messages) + rr = self._update(self.updated_messages) self.updated_messages.clear() return rr @@ -77,16 +69,16 @@ def _update(self, updated_messages): errors.append("canError") ret.errors = errors - for ii in updated_messages: + for ii in sorted(updated_messages): if ii in self.RADAR_A_MSGS: cpt = self.rcp.vl[ii] - if cpt['LONG_DIST'] >=255 or cpt['NEW_TRACK']: + if cpt['LONG_DIST'] >= 255 or cpt['NEW_TRACK']: self.valid_cnt[ii] = 0 # reset counter if cpt['VALID'] and cpt['LONG_DIST'] < 255: self.valid_cnt[ii] += 1 else: - self.valid_cnt[ii] = max(self.valid_cnt[ii] -1, 0) + self.valid_cnt[ii] = max(self.valid_cnt[ii] - 1, 0) score = self.rcp.vl[ii+16]['SCORE'] # print ii, self.valid_cnt[ii], score, cpt['VALID'], cpt['LONG_DIST'], cpt['LAT_DIST'] @@ -107,5 +99,5 @@ def _update(self, updated_messages): if ii in self.pts: del self.pts[ii] - ret.points = self.pts.values() + ret.points = list(self.pts.values()) return ret diff --git a/selfdrive/car/toyota/toyotacan.py b/selfdrive/car/toyota/toyotacan.py index 35ba674528ae9b..14bc407446bb8e 100644 --- a/selfdrive/car/toyota/toyotacan.py +++ b/selfdrive/car/toyota/toyotacan.py @@ -1,57 +1,3 @@ -import struct - - -# *** Toyota specific *** - -def fix(msg, addr): - checksum = 0 - idh = (addr & 0xff00) >> 8 - idl = (addr & 0xff) - - checksum = idh + idl + len(msg) + 1 - for d_byte in msg: - checksum += ord(d_byte) - - #return msg + chr(checksum & 0xFF) - return msg + struct.pack("B", checksum & 0xFF) - - -def make_can_msg(addr, dat, alt, cks=False): - if cks: - dat = fix(dat, addr) - return [addr, 0, dat, alt] - - -def create_video_target(frame, addr): - counter = frame & 0xff - msg = struct.pack("!BBBBBBB", counter, 0x03, 0xff, 0x00, 0x00, 0x00, 0x00) - return make_can_msg(addr, msg, 1, True) - - -def create_ipas_steer_command(packer, steer, enabled, apgs_enabled): - """Creates a CAN message for the Toyota Steer Command.""" - if steer < 0: - direction = 3 - elif steer > 0: - direction = 1 - else: - direction = 2 - - mode = 3 if enabled else 1 - - values = { - "STATE": mode, - "DIRECTION_CMD": direction, - "ANGLE": steer, - "SET_ME_X10": 0x10, - "SET_ME_X40": 0x40 - } - if apgs_enabled: - return packer.make_can_msg("STEERING_IPAS", 0, values) - else: - return packer.make_can_msg("STEERING_IPAS_COMMA", 0, values) - - def create_steer_command(packer, steer, steer_req, raw_cnt): """Creates a CAN message for the Toyota Steer Command.""" @@ -64,17 +10,19 @@ def create_steer_command(packer, steer, steer_req, raw_cnt): return packer.make_can_msg("STEERING_LKA", 0, values) -def create_lta_steer_command(packer, steer, steer_req, raw_cnt, angle): +def create_lta_steer_command(packer, steer, steer_req, raw_cnt): """Creates a CAN message for the Toyota LTA Steer Command.""" values = { - "COUNTER": raw_cnt, + "COUNTER": raw_cnt + 128, + "SETME_X1": 1, "SETME_X3": 3, - "PERCENTAGE" : 100, + "PERCENTAGE": 100, "SETME_X64": 0x64, - "ANGLE": angle, + "ANGLE": 0, # Rate limit? Lower values seeem to work better, but needs more testing "STEER_ANGLE_CMD": steer, "STEER_REQUEST": steer_req, + "STEER_REQUEST_2": steer_req, "BIT": 0, } return packer.make_can_msg("STEERING_LTA", 0, values) @@ -88,13 +36,25 @@ def create_accel_command(packer, accel, pcm_cancel, standstill_req, lead): "DISTANCE": 0, "MINI_CAR": lead, "SET_ME_X3": 3, - "SET_ME_1": 1, + "PERMIT_BRAKING": 1, "RELEASE_STANDSTILL": not standstill_req, "CANCEL_REQ": pcm_cancel, } return packer.make_can_msg("ACC_CONTROL", 0, values) +def create_acc_cancel_command(packer): + values = { + "GAS_RELEASED": 0, + "CRUISE_ACTIVE": 0, + "STANDSTILL_ON": 0, + "ACCEL_NET": 0, + "CRUISE_STATE": 0, + "CANCEL_REQ": 1, + } + return packer.make_can_msg("PCM_CRUISE", 0, values) + + def create_fcw_command(packer, fcw): values = { "FCW": fcw, @@ -105,11 +65,11 @@ def create_fcw_command(packer, fcw): return packer.make_can_msg("ACC_HUD", 0, values) -def create_ui_command(packer, steer, left_line, right_line, left_lane_depart, right_lane_depart): +def create_ui_command(packer, steer, chime, left_line, right_line, left_lane_depart, right_lane_depart): values = { "RIGHT_LINE": 3 if right_lane_depart else 1 if right_line else 2, "LEFT_LINE": 3 if left_lane_depart else 1 if left_line else 2, - "BARRIERS" : 3 if left_lane_depart or right_lane_depart else 0, + "BARRIERS" : 3 if left_lane_depart else 2 if right_lane_depart else 0, "SET_ME_X0C": 0x0c, "SET_ME_X2C": 0x2c, "SET_ME_X38": 0x38, @@ -117,7 +77,7 @@ def create_ui_command(packer, steer, left_line, right_line, left_lane_depart, ri "SET_ME_X01": 1, "SET_ME_X01_2": 1, "REPEATED_BEEPS": 0, - "TWO_BEEPS": 0, + "TWO_BEEPS": chime, "LDA_ALERT": steer, } return packer.make_can_msg("LKAS_HUD", 0, values) diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index df535eab05a852..6ef056ff24665b 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -1,187 +1,1338 @@ +# flake8: noqa + from selfdrive.car import dbc_dict +from cereal import car +Ecu = car.CarParams.Ecu + +# Steer torque limits +class SteerLimitParams: + STEER_MAX = 1500 + STEER_DELTA_UP = 10 # 1.5s time to peak torque + STEER_DELTA_DOWN = 25 # always lower than 45 otherwise the Rav4 faults (Prius seems ok with 50) + STEER_ERROR_MAX = 350 # max delta between torque cmd and torque motor class CAR: PRIUS = "TOYOTA PRIUS 2017" + PRIUS_TSS2 = "TOYOTA PRIUS TSS2 2021" RAV4H = "TOYOTA RAV4 HYBRID 2017" RAV4 = "TOYOTA RAV4 2017" COROLLA = "TOYOTA COROLLA 2017" + LEXUS_RX = "LEXUS RX 350 2016" LEXUS_RXH = "LEXUS RX HYBRID 2017" + LEXUS_RX_TSS2 = "LEXUS RX350 2020" + LEXUS_RXH_TSS2 = "LEXUS RX450 HYBRID 2020" CHR = "TOYOTA C-HR 2018" CHRH = "TOYOTA C-HR HYBRID 2018" CAMRY = "TOYOTA CAMRY 2018" CAMRYH = "TOYOTA CAMRY HYBRID 2018" + CAMRY_TSS2 = "TOYOTA CAMRY 2021" # TSS 2.5 HIGHLANDER = "TOYOTA HIGHLANDER 2017" + HIGHLANDER_TSS2 = "TOYOTA HIGHLANDER 2020" HIGHLANDERH = "TOYOTA HIGHLANDER HYBRID 2018" + HIGHLANDERH_TSS2 = "TOYOTA HIGHLANDER HYBRID 2020" AVALON = "TOYOTA AVALON 2016" RAV4_TSS2 = "TOYOTA RAV4 2019" COROLLA_TSS2 = "TOYOTA COROLLA TSS2 2019" + COROLLAH_TSS2 = "TOYOTA COROLLA HYBRID TSS2 2019" + LEXUS_ES_TSS2 = "LEXUS ES 2019" LEXUS_ESH_TSS2 = "LEXUS ES 300H 2019" SIENNA = "TOYOTA SIENNA XLE 2018" - - -class ECU: - CAM = 0 # camera - DSU = 1 # driving support unit - APGS = 2 # advanced parking guidance system - + LEXUS_IS = "LEXUS IS300 2018" + LEXUS_CTH = "LEXUS CT 200H 2018" + RAV4H_TSS2 = "TOYOTA RAV4 HYBRID 2019" + LEXUS_NXH = "LEXUS NX300H 2018" + LEXUS_NX = "LEXUS NX300 2018" # addr: (ecu, cars, bus, 1/freq*100, vl) STATIC_MSGS = [ - (0x130, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 1, 100, '\x00\x00\x00\x00\x00\x00\x38'), - (0x240, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 1, 5, '\x00\x10\x01\x00\x10\x01\x00'), - (0x241, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 1, 5, '\x00\x10\x01\x00\x10\x01\x00'), - (0x244, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 1, 5, '\x00\x10\x01\x00\x10\x01\x00'), - (0x245, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 1, 5, '\x00\x10\x01\x00\x10\x01\x00'), - (0x248, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 1, 5, '\x00\x00\x00\x00\x00\x00\x01'), - (0x367, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 0, 40, '\x06\x00'), - (0x414, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 0, 100, '\x00\x00\x00\x00\x00\x00\x17\x00'), - (0x466, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.HIGHLANDER, CAR.HIGHLANDERH), 1, 100, '\x20\x20\xAD'), - (0x466, ECU.CAM, (CAR.COROLLA, CAR.AVALON), 1, 100, '\x24\x20\xB1'), - (0x489, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 0, 100, '\x00\x00\x00\x00\x00\x00\x00'), - (0x48a, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 0, 100, '\x00\x00\x00\x00\x00\x00\x00'), - (0x48b, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON), 0, 100, '\x66\x06\x08\x0a\x02\x00\x00\x00'), - (0x4d3, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.AVALON), 0, 100, '\x1C\x00\x00\x01\x00\x00\x00\x00'), - - (0x128, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.AVALON), 1, 3, '\xf4\x01\x90\x83\x00\x37'), - (0x128, ECU.DSU, (CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.SIENNA), 1, 3, '\x03\x00\x20\x00\x00\x52'), - (0x141, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON, CAR.SIENNA), 1, 2, '\x00\x00\x00\x46'), - (0x160, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON, CAR.SIENNA), 1, 7, '\x00\x00\x08\x12\x01\x31\x9c\x51'), - (0x161, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.AVALON), 1, 7, '\x00\x1e\x00\x00\x00\x80\x07'), - (0X161, ECU.DSU, (CAR.HIGHLANDERH, CAR.HIGHLANDER, CAR.SIENNA), 1, 7, '\x00\x1e\x00\xd4\x00\x00\x5b'), - (0x283, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON, CAR.SIENNA), 0, 3, '\x00\x00\x00\x00\x00\x00\x8c'), - (0x2E6, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH), 0, 3, '\xff\xf8\x00\x08\x7f\xe0\x00\x4e'), - (0x2E7, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH), 0, 3, '\xa8\x9c\x31\x9c\x00\x00\x00\x02'), - (0x33E, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH), 0, 20, '\x0f\xff\x26\x40\x00\x1f\x00'), - (0x344, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON, CAR.SIENNA), 0, 5, '\x00\x00\x01\x00\x00\x00\x00\x50'), - (0x365, ECU.DSU, (CAR.PRIUS, CAR.LEXUS_RXH, CAR.HIGHLANDERH), 0, 20, '\x00\x00\x00\x80\x03\x00\x08'), - (0x365, ECU.DSU, (CAR.RAV4, CAR.RAV4H, CAR.COROLLA, CAR.HIGHLANDER, CAR.AVALON, CAR.SIENNA), 0, 20, '\x00\x00\x00\x80\xfc\x00\x08'), - (0x366, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.HIGHLANDERH), 0, 20, '\x00\x00\x4d\x82\x40\x02\x00'), - (0x366, ECU.DSU, (CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.AVALON, CAR.SIENNA), 0, 20, '\x00\x72\x07\xff\x09\xfe\x00'), - (0x470, ECU.DSU, (CAR.PRIUS, CAR.LEXUS_RXH), 1, 100, '\x00\x00\x02\x7a'), - (0x470, ECU.DSU, (CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.RAV4H, CAR.SIENNA), 1, 100, '\x00\x00\x01\x79'), - (0x4CB, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDERH, CAR.HIGHLANDER, CAR.AVALON, CAR.SIENNA), 0, 100, '\x0c\x00\x00\x00\x00\x00\x00\x00'), - - (0x292, ECU.APGS, (CAR.PRIUS), 0, 3, '\x00\x00\x00\x00\x00\x00\x00\x9e'), - (0x32E, ECU.APGS, (CAR.PRIUS), 0, 20, '\x00\x00\x00\x00\x00\x00\x00\x00'), - (0x396, ECU.APGS, (CAR.PRIUS), 0, 100, '\xBD\x00\x00\x00\x60\x0F\x02\x00'), - (0x43A, ECU.APGS, (CAR.PRIUS), 0, 100, '\x84\x00\x00\x00\x00\x00\x00\x00'), - (0x43B, ECU.APGS, (CAR.PRIUS), 0, 100, '\x00\x00\x00\x00\x00\x00\x00\x00'), - (0x497, ECU.APGS, (CAR.PRIUS), 0, 100, '\x00\x00\x00\x00\x00\x00\x00\x00'), - (0x4CC, ECU.APGS, (CAR.PRIUS), 0, 100, '\x0D\x00\x00\x00\x00\x00\x00\x00'), + (0x128, Ecu.dsu, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.RAV4, CAR.COROLLA, CAR.AVALON), 1, 3, b'\xf4\x01\x90\x83\x00\x37'), + (0x128, Ecu.dsu, (CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.SIENNA, CAR.LEXUS_CTH), 1, 3, b'\x03\x00\x20\x00\x00\x52'), + (0x141, Ecu.dsu, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_RX), 1, 2, b'\x00\x00\x00\x46'), + (0x160, Ecu.dsu, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_RX), 1, 7, b'\x00\x00\x08\x12\x01\x31\x9c\x51'), + (0x161, Ecu.dsu, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.RAV4, CAR.COROLLA, CAR.AVALON, CAR.LEXUS_RX), 1, 7, b'\x00\x1e\x00\x00\x00\x80\x07'), + (0X161, Ecu.dsu, (CAR.HIGHLANDERH, CAR.HIGHLANDER, CAR.SIENNA, CAR.LEXUS_CTH), 1, 7, b'\x00\x1e\x00\xd4\x00\x00\x5b'), + (0x283, Ecu.dsu, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_RX), 0, 3, b'\x00\x00\x00\x00\x00\x00\x8c'), + (0x2E6, Ecu.dsu, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH), 0, 3, b'\xff\xf8\x00\x08\x7f\xe0\x00\x4e'), + (0x2E7, Ecu.dsu, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH), 0, 3, b'\xa8\x9c\x31\x9c\x00\x00\x00\x02'), + (0x33E, Ecu.dsu, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH), 0, 20, b'\x0f\xff\x26\x40\x00\x1f\x00'), + (0x344, Ecu.dsu, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_RX), 0, 5, b'\x00\x00\x01\x00\x00\x00\x00\x50'), + (0x365, Ecu.dsu, (CAR.PRIUS, CAR.LEXUS_RXH, CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.HIGHLANDERH), 0, 20, b'\x00\x00\x00\x80\x03\x00\x08'), + (0x365, Ecu.dsu, (CAR.RAV4, CAR.RAV4H, CAR.COROLLA, CAR.HIGHLANDER, CAR.AVALON, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_RX), 0, 20, b'\x00\x00\x00\x80\xfc\x00\x08'), + (0x366, Ecu.dsu, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.HIGHLANDERH), 0, 20, b'\x00\x00\x4d\x82\x40\x02\x00'), + (0x366, Ecu.dsu, (CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.AVALON, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_RX), 0, 20, b'\x00\x72\x07\xff\x09\xfe\x00'), + (0x470, Ecu.dsu, (CAR.PRIUS, CAR.LEXUS_RXH), 1, 100, b'\x00\x00\x02\x7a'), + (0x470, Ecu.dsu, (CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.RAV4H, CAR.SIENNA, CAR.LEXUS_CTH), 1, 100, b'\x00\x00\x01\x79'), + (0x4CB, Ecu.dsu, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDERH, CAR.HIGHLANDER, CAR.AVALON, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_RX), 0, 100, b'\x0c\x00\x00\x00\x00\x00\x00\x00'), ] ECU_FINGERPRINT = { - ECU.CAM: 0x2e4, # steer torque cmd - ECU.DSU: 0x343, # accel cmd - ECU.APGS: 0x835, # angle cmd + Ecu.fwdCamera: [0x2e4], # steer torque cmd + Ecu.dsu: [0x283], # accel cmd } -def check_ecu_msgs(fingerprint, ecu): - # return True if fingerprint contains messages normally sent by a given ecu - return ECU_FINGERPRINT[ecu] in fingerprint - - FINGERPRINTS = { CAR.RAV4: [{ - 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 512: 6, 513: 6, 547: 8, 548: 8, 552: 4, 562: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 918: 7, 921: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 4, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1008: 2, 1014: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1596: 8, 1597: 8, 1600: 8, 1656: 8, 1664: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8, 2015: 8, 2024: 8 + 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 512: 6, 513: 6, 547: 8, 548: 8, 552: 4, 562: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 767: 4, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 918: 7, 921: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 4, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1008: 2, 1014: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1596: 8, 1597: 8, 1600: 8, 1656: 8, 1664: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8, 2015: 8, 2024: 8 }], CAR.RAV4H: [{ - 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 296: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 547: 8, 548: 8, 550: 8, 552: 4, 560: 7, 562: 4, 581: 5, 608: 8, 610: 5, 643: 7, 705: 8, 713: 8, 725: 2, 740: 5, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 918: 7, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 3, 955: 8, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1008: 2, 1014: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1184: 8, 1185: 8, 1186: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1212: 8, 1227: 8, 1228: 8, 1232: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1596: 8, 1597: 8, 1600: 8, 1656: 8, 1664: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 296: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 547: 8, 548: 8, 550: 8, 552: 4, 560: 7, 562: 4, 581: 5, 608: 8, 610: 5, 643: 7, 705: 8, 713: 8, 725: 2, 740: 5, 767: 4, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 918: 7, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 3, 955: 8, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1008: 2, 1014: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1184: 8, 1185: 8, 1186: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1212: 8, 1227: 8, 1228: 8, 1232: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1596: 8, 1597: 8, 1600: 8, 1656: 8, 1664: 8, 1728: 8, 1745: 8, 1779: 8, 1872: 8, 1880: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, # Chinese RAV4 { - 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 355: 5, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 512: 6, 513: 6, 547: 8, 548: 8, 552: 4, 562: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 742: 8, 743: 8, 800: 8, 830: 7, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 921: 8, 922: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1008: 2, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1207: 8, 1227: 8, 1235: 8, 1263: 8, 1279: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1596: 8, 1597: 8, 1600: 8, 1664: 8, 1728: 8, 1745: 8, 1779: 8 + 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 355: 5, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 512: 6, 513: 6, 547: 8, 548: 8, 552: 4, 562: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 742: 8, 743: 8, 767: 4, 800: 8, 830: 7, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 921: 8, 922: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1008: 2, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1207: 8, 1227: 8, 1235: 8, 1263: 8, 1279: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1596: 8, 1597: 8, 1600: 8, 1664: 8, 1728: 8, 1745: 8, 1779: 8 }], CAR.PRIUS: [{ - # with ipas - 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 512: 6, 513: 6, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 800: 8, 810: 2, 814: 8, 824: 2, 829: 2, 830: 7, 835: 8, 836: 8, 845: 5, 863: 8, 869: 7, 870: 7, 871: 2,898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 974: 8, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1083: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1175: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 512: 6, 513: 6, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 767: 4, 800: 8, 810: 2, 814: 8, 824: 2, 829: 2, 830: 7, 835: 8, 836: 8, 845: 5, 863: 8, 869: 7, 870: 7, 871: 2, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 974: 8, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1083: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1175: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, #2019 LE { - 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 800: 8, 810: 2, 814: 8, 829: 2, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1083: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1175: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1595: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 767: 4, 800: 8, 810: 2, 814: 8, 829: 2, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1083: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1175: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1595: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + }, + # 2020 Prius Prime LE + { + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 740: 5, 742: 8, 743: 8, 764: 8, 767: 4, 800: 8, 810: 2, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 974: 8, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1227: 8, 1235: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1595: 8, 1649: 8, 1777: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + }, + #2020 Prius Prime Limited + { + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 767: 4, 800: 8, 810: 2, 814: 8, 824: 2, 829: 2, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 974: 8, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1083: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1175: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1595: 8, 1649: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8, 2015: 8, 2024: 8, 2026: 8, 2027: 8, 2029: 8, 2030: 8, 2031: 8 + }, + #2020 Central Europe Prime + { + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 740: 5, 742: 8, 743: 8, 764: 8, 767: 4, 800: 8, 810: 2, 818: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 845: 5, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 889: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 8, 974: 8, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1227: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1595: 8, 1777: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8 + }, + #2017 German Prius + { + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 767: 4, 800: 8, 810: 2, 814: 8, 829: 2, 830: 7, 835: 8, 836: 8, 845: 5, 863: 8, 869: 7, 870: 7, 871: 2, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1077: 8, 1082: 8, 1083: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1175: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1777: 8, 1779: 8, 1792: 8, 1767: 4, 1863: 8, 1904: 8, 1912: 8, 1984: 8, 1988: 8, 1990: 8, 1992: 8, 1996: 8, 1998: 8, 2002: 8, 2010: 8, 2015: 8, 2016: 8, 2018: 8, 2024: 8, 2026: 8, 2030: 8 }], #Corolla w/ added Pedal Support (512L and 513L) CAR.COROLLA: [{ - 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 512: 6, 513: 6, 547: 8, 548: 8, 552: 4, 608: 8, 610: 5, 643: 7, 705: 8, 740: 5, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 2, 921: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 4, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1196: 8, 1227: 8, 1235: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1596: 8, 1597: 8, 1600: 8, 1664: 8, 1728: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8, 2016: 8, 2017: 8, 2018: 8, 2019: 8, 2020: 8, 2021: 8, 2022: 8, 2023: 8, 2024: 8 + 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 512: 6, 513: 6, 547: 8, 548: 8, 552: 4, 608: 8, 610: 5, 643: 7, 705: 8, 740: 5, 767: 4, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 2, 921: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 4, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1196: 8, 1227: 8, 1235: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1596: 8, 1597: 8, 1600: 8, 1664: 8, 1728: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8, 2016: 8, 2017: 8, 2018: 8, 2019: 8, 2020: 8, 2021: 8, 2022: 8, 2023: 8, 2024: 8 + }], + CAR.LEXUS_RX: [{ + # 2016 Lexus RX 350 + 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 5, 643: 7, 705: 8, 740: 5, 742: 8, 743: 8, 767: 4, 800: 8, 810: 2, 812: 3, 818: 8, 819: 8, 820: 8, 821: 8, 822: 8, 830: 7, 835: 8, 836: 8, 845: 5, 869: 7, 870: 7, 871: 2, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1063: 8, 1077: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1349: 8, 1350: 8, 1351: 8, 1413: 8, 1414: 8, 1415: 8, 1416: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1595: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8, 2015: 8, 2016: 8, 2024: 8 + }, + # 2017 Lexus RX 350 + { + 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 5, 643: 7, 658: 8, 705: 8, 740: 5, 742: 8, 743: 8, 767: 4, 800: 8, 810: 2, 812: 3, 814: 8, 818: 8, 819: 8, 820: 8, 821: 8, 822: 8, 830: 7, 835: 8, 836: 8, 869: 7, 870: 7, 871: 2, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1063: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1349: 8, 1350: 8, 1351: 8, 1413: 8, 1414: 8, 1415: 8, 1416: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1595: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }], CAR.LEXUS_RXH: [{ - 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 512: 6, 513:6, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 5, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 800: 8, 810: 2, 812: 3, 814: 8, 830: 7, 835: 8, 836: 8, 845: 5, 863: 8, 869: 7, 870: 7, 871: 2, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 6, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1063: 8, 1071: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1595: 8, 1777: 8, 1779: 8, 1808: 8, 1810: 8, 1816: 8, 1818: 8, 1840: 8, 1848: 8, 1904: 8, 1912: 8, 1940: 8, 1941: 8, 1948: 8, 1949: 8, 1952: 8, 1956: 8, 1960: 8, 1964: 8, 1986: 8, 1990: 8, 1994: 8, 1998: 8, 2004: 8, 2012: 8 + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 512: 6, 513: 6, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 5, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 767: 4, 800: 8, 810: 2, 812: 3, 814: 8, 830: 7, 835: 8, 836: 8, 845: 5, 863: 8, 869: 7, 870: 7, 871: 2, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 6, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1063: 8, 1071: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1595: 8, 1777: 8, 1779: 8, 1808: 8, 1810: 8, 1816: 8, 1818: 8, 1840: 8, 1848: 8, 1904: 8, 1912: 8, 1940: 8, 1941: 8, 1948: 8, 1949: 8, 1952: 8, 1956: 8, 1960: 8, 1964: 8, 1986: 8, 1990: 8, 1994: 8, 1998: 8, 2004: 8, 2012: 8 }, # RX450HL + # TODO: get proper fingerprint in stock mode { - 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 512: 6, 513: 6, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 5, 643: 7, 658: 8, 713: 8, 742: 8, 743: 8, 800: 8, 810: 2, 812: 3, 814: 8, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 6, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1056: 8, 1057: 8, 1059: 1, 1063: 8, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1227: 8, 1228: 8, 1237: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 512: 6, 513: 6, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 5, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 767: 4, 800: 8, 810: 2, 812: 3, 814: 8, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 6, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1056: 8, 1057: 8, 1059: 1, 1063: 8, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1227: 8, 1228: 8, 1237: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, # RX540H 2019 with color hud { - 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 512: 6, 513: 6, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 5, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 800: 8, 810: 2, 812: 3, 814: 8, 818: 8, 819: 8, 820: 8, 821: 8, 822: 8, 830: 7, 835: 8, 836: 8, 845: 5, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 6, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1063: 8, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1349: 8, 1350: 8, 1351: 8, 1413: 8, 1414: 8, 1415: 8, 1416: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1777: 8, 1779: 8, 1808: 8, 1810: 8, 1816: 8, 1818: 8, 1904: 8, 1912: 8, 1952: 8, 1960: 8, 1990: 8, 1998: 8 + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 512: 6, 513: 6, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 5, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 767: 4, 800: 8, 810: 2, 812: 3, 814: 8, 818: 8, 819: 8, 820: 8, 821: 8, 822: 8, 830: 7, 835: 8, 836: 8, 845: 5, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 6, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1063: 8, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1349: 8, 1350: 8, 1351: 8, 1413: 8, 1414: 8, 1415: 8, 1416: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1777: 8, 1779: 8, 1808: 8, 1810: 8, 1816: 8, 1818: 8, 1904: 8, 1912: 8, 1952: 8, 1960: 8, 1990: 8, 1998: 8 + }, + # 2017 RX 450h + { + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 5, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 744: 8, 767: 4, 800: 8, 810: 2, 812: 3, 814: 8, 818: 8, 819: 8, 820: 8, 821: 8, 822: 8, 830: 7, 835: 8, 836: 8, 845: 5, 863: 8, 869: 7, 870: 7, 871: 2, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 6, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1063: 8, 1071: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1349: 8, 1350: 8, 1351: 8, 1413: 8, 1414: 8, 1415: 8, 1416: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1595: 8, 1745: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8, 2015: 8, 2016: 8, 2024: 8 + }], + CAR.LEXUS_RX_TSS2: [ + # 2020 Lexus RX 350 + { + 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 401: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 740: 5, 742: 8, 743: 8, 764: 8, 765: 8, 767: 4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 824: 8, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 891: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 987: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1063: 8, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1592: 8, 1594: 8, 1595: 8, 1600: 8, 1649: 8, 1775: 8, 1777: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1816: 8, 1872: 8, 1880: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8, 2015: 8, 2016: 8, 2024: 8 + }], + CAR.LEXUS_RXH_TSS2: [ + # 2020 Lexus RX 450h + { + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 401: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 744: 8, 764: 8, 765: 8, 800: 8, 810: 2, 812: 3, 814: 8, 818: 8, 822: 8, 824: 8, 830: 7, 835: 8, 836: 8, 845: 5, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 889: 8, 891: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 942: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 6, 987: 8, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1063: 8, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1592: 8, 1594: 8, 1595: 8, 1600: 8, 1649: 8, 1775: 8, 1777: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1792: 8, 1808: 8, 1809: 8, 1810: 8, 1816: 8, 1818: 8, 1840: 8, 1848: 8, 1872: 8, 1880: 8, 1904: 8, 1912: 8, 1937: 8, 1940: 8, 1941: 8, 1945: 8, 1948: 8, 1949: 8, 1952: 8, 1953: 8, 1956: 8, 1960: 8, 1961: 8, 1968: 8, 1976: 8, 1986: 8, 1990: 8, 1994: 8, 1998: 8, 2004: 8, 2012: 8, 2015: 8, 2016: 8, 2024: 8 }], CAR.CHR: [{ - 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 705: 8, 740: 5, 800: 8, 810: 2, 812: 8, 814: 8, 830: 7, 835: 8, 836: 8, 845: 5, 869: 7, 870: 7, 871: 2, 898: 8, 913: 8, 918: 8, 921: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 1014: 8, 1017: 8, 1020: 8, 1021: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1082: 8, 1083: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1175: 8, 1228: 8, 1235: 8, 1237: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8 + 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 705: 8, 740: 5, 767: 4, 800: 8, 810: 2, 812: 8, 814: 8, 830: 7, 835: 8, 836: 8, 845: 5, 869: 7, 870: 7, 871: 2, 898: 8, 913: 8, 918: 8, 921: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 1014: 8, 1017: 8, 1020: 8, 1021: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1082: 8, 1083: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1175: 8, 1228: 8, 1235: 8, 1237: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8 }], CAR.CHRH: [{ - 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 713: 8, 740: 5, 800: 8, 810: 2, 812: 8, 814: 8, 829: 2, 830: 7, 835: 8, 836: 8, 845: 5, 869: 7, 870: 7, 871: 2, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1014: 8, 1017: 8, 1020: 8, 1021: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1083: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1175: 8, 1228: 8, 1235: 8, 1237: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 713: 8, 740: 5, 767: 4, 800: 8, 810: 2, 812: 8, 814: 8, 829: 2, 830: 7, 835: 8, 836: 8, 845: 5, 869: 7, 870: 7, 871: 2, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1014: 8, 1017: 8, 1020: 8, 1021: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1083: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1175: 8, 1228: 8, 1235: 8, 1237: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }], CAR.CAMRY: [ #XLE and LE { - 36: 8, 37: 8, 119: 6, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 830: 7, 835: 8, 836: 8, 869: 7, 870: 7, 871: 2, 888: 8, 889: 8, 891: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 983: 8, 984: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1412: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1816: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + 36: 8, 37: 8, 119: 6, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 767: 4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 830: 7, 835: 8, 836: 8, 869: 7, 870: 7, 871: 2, 888: 8, 889: 8, 891: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 983: 8, 984: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1412: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1816: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, #XSE and SE + # TODO: get proper fingerprint in stock mode + { + 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 767: 4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 830: 7, 835: 8, 836: 8, 869: 7, 870: 7, 888: 8, 889: 8, 891: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 983: 8, 984: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1412: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1816: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + }, { - 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 761: 8, 764: 8, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 830: 7, 835: 8, 836: 8, 869: 7, 870: 7, 888: 8, 889: 8, 891: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 983: 8, 984: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1412: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1816: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + # 2019 XSE + 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 767: 4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 888: 8, 889: 8, 891: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 942: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 983: 8, 984: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1412: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1792: 8, 1767: 4, 1808: 8, 1816: 8, 1872: 8, 1880: 8, 1904: 8, 1912: 8, 1937: 8, 1945: 8, 1953: 8, 1961: 8, 1968: 8, 1976: 8, 1990: 8, 1998: 8, 2015: 8, 2016: 8, 2024: 8 }], CAR.CAMRYH: [ #SE, LE and LE with Blindspot Monitor { - 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 728: 8, 740: 5, 761: 8, 764: 8, 800: 8, 810: 2, 812: 8, 818: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 889: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 983: 8, 984: 8, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1810: 8, 1816: 8, 1818: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 728: 8, 740: 5, 761: 8, 764: 8, 767: 4, 800: 8, 810: 2, 812: 8, 818: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 889: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 983: 8, 984: 8, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1810: 8, 1816: 8, 1818: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, #SL { - 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 728: 8, 740: 5, 761: 8, 764: 8, 800: 8, 810: 2, 812: 8, 818: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 869: 7, 870: 7, 871: 2, 888: 8, 889: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 728: 8, 740: 5, 761: 8, 764: 8, 767: 4, 800: 8, 810: 2, 812: 8, 818: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 869: 7, 870: 7, 871: 2, 888: 8, 889: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, #XLE { - 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 658: 8, 713: 8, 728: 8, 740: 5, 761: 8, 764: 8, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 869: 7, 870: 7, 871: 2, 888: 8, 889: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 983: 8, 984: 8, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 658: 8, 713: 8, 728: 8, 740: 5, 761: 8, 764: 8, 767: 4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 869: 7, 870: 7, 871: 2, 888: 8, 889: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 983: 8, 984: 8, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + }], + CAR.CAMRY_TSS2: [{ + 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 401: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 765: 8, 791: 8, 800: 8, 810: 2, 812: 8, 818: 8, 824: 8, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 885: 8, 889: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 983: 8, 984: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1593: 8, 1594: 8, 1595: 8, 1649: 8, 1653: 8, 1654: 8, 1655: 8, 1677: 8, 1745: 8, 1775: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1792: 8, 1800: 8, 1808: 8, 1809: 8, 1816: 8, 1817: 8, 1840: 8, 1841: 8, 1848: 8, 1872: 8, 1880: 8, 1904: 8, 1912: 8, 1937: 8, 1940: 8, 1941: 8, 1945: 8, 1948: 8, 1949: 8, 1952: 8, 1953: 8, 1956: 8, 1960: 8, 1961: 8, 1964: 8, 1968: 8, 1973: 8, 1976: 8, 1981: 8, 1986: 8, 1988: 8, 1990: 8, 1994: 8, 1996: 8, 1998: 8, 2000: 8, 2001: 8, 2004: 8, 2008: 8, 2012: 8, 2016: 8, 2017: 8 }], CAR.HIGHLANDER: [{ - 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 238: 4, 355: 5, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 545: 5, 550: 8, 552: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 921: 8, 922: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1008: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1182: 8, 1183: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1207: 8, 1212: 8, 1227: 8, 1235: 8, 1237: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1656: 8, 1666: 8, 1667: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 238: 4, 355: 5, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 545: 5, 550: 8, 552: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 767: 4, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 921: 8, 922: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1008: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1182: 8, 1183: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1207: 8, 1212: 8, 1227: 8, 1235: 8, 1237: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1656: 8, 1666: 8, 1667: 8, 1728: 8, 1745: 8, 1779: 8, 1872: 8, 1880: 8, 1904: 8, 1912: 8, 1984: 8, 1988: 8, 1992: 8, 1996: 8, 1990: 8, 1998: 8 }, # 2019 Highlander XLE { - 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 238: 4, 355: 5, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 545: 5, 550: 8, 552: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 921: 8, 922: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1008: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1182: 8, 1183: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1207: 8, 1212: 8, 1227: 8, 1235: 8, 1237: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1656: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 238: 4, 355: 5, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 545: 5, 550: 8, 552: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 767: 4, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 921: 8, 922: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1008: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1182: 8, 1183: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1207: 8, 1212: 8, 1227: 8, 1235: 8, 1237: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1656: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, # 2017 Highlander Limited { - 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 238: 4, 355: 5, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 545: 5, 550: 8, 552: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 918: 7, 921: 8, 922: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1008: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1182: 8, 1183: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1207: 8, 1212: 8, 1227: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1656: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 238: 4, 355: 5, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 545: 5, 550: 8, 552: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 767: 4, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 918: 7, 921: 8, 922: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1008: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1182: 8, 1183: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1207: 8, 1212: 8, 1227: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1656: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + }, + # 2018 Highlander Limited Platinum + { + 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 238: 4, 355: 5, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 545: 5, 550: 8, 552: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 767: 4, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 918: 7, 921: 8, 922: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1008: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1182: 8, 1183: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1207: 8, 1212: 8, 1227: 8, 1235: 8, 1237: 8, 1263: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1585: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1656: 8, 1728: 8, 1745: 8, 1779: 8, 1872: 8, 1880: 8, 1904: 8, 1912: 8, 1988: 8, 1990: 8, 1996: 8, 1998: 8, 2015: 8, 2016: 8, 2024: 8 + }], + CAR.HIGHLANDER_TSS2: [{ + # 2020 highlander limited + 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 355: 5, 401: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 565: 8, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 765: 8, 767: 4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 824: 8, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 885: 8, 889: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 987: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1063: 8, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1696: 8, 1775: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1816: 8, 1904: 8, 1912: 8, 1952: 8, 1960: 8, 1990: 8, 1998: 8 }], CAR.HIGHLANDERH: [{ - 36: 8, 37: 8, 170: 8, 180: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 581: 5, 608: 8, 610: 5, 643: 7, 713: 8, 740: 5, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 918: 7, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 3, 955: 8, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1112: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1184: 8, 1185: 8, 1186: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1212: 8, 1227: 8, 1232: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1554: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1656: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + 36: 8, 37: 8, 170: 8, 180: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 581: 5, 608: 8, 610: 5, 643: 7, 713: 8, 740: 5, 767: 4, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 918: 7, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 3, 955: 8, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1112: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1184: 8, 1185: 8, 1186: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1212: 8, 1227: 8, 1232: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1554: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1656: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + }, + { + # 2019 Highlander Hybrid Limited Platinum + 36: 8, 37: 8, 170: 8, 180: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 581: 5, 608: 8, 610: 5, 643: 7, 713: 8, 740: 5, 767: 4, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 918: 7, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 3, 955: 8, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1076: 8, 1077: 8, 1112: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1184: 8, 1185: 8, 1186: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1212: 8, 1227: 8, 1232: 8, 1235: 8, 1237: 8, 1263: 8, 1279: 8, 1552: 8, 1553: 8, 1554: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1656: 8, 1666: 8, 1667: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + }], + CAR.HIGHLANDERH_TSS2: [{ + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 401: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 658: 8, 713: 8, 728: 8, 740: 5, 761: 8, 765: 8, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 881: 8, 885: 8, 891: 8, 896: 8, 898: 8, 918: 8, 942: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 971: 7, 975: 5, 987: 8, 993: 8, 1014: 8, 1017: 8, 1020: 8, 1059: 1, 1063: 8, 1071: 8, 1082: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1235: 8, 1552: 8, 1553: 8, 1556: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1696: 8, 1745: 8 }], CAR.AVALON: [{ - 36: 8, 37: 8, 170: 8, 180: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 547: 8, 550: 8, 552: 4, 562: 6, 608: 8, 610: 5, 643: 7, 705: 8, 740: 5, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 905: 8, 911: 1, 916: 2, 921: 8, 933: 6, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 1005: 2, 1014: 8, 1017: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1200: 8, 1201: 8, 1202: 8, 1203: 8, 1206: 8, 1227: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1558: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1596: 8, 1597: 8, 1664: 8, 1728: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + 36: 8, 37: 8, 170: 8, 180: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 547: 8, 550: 8, 552: 4, 562: 6, 608: 8, 610: 5, 643: 7, 705: 8, 740: 5, 767: 4, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 905: 8, 911: 1, 916: 2, 921: 8, 933: 6, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 1005: 2, 1014: 8, 1017: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1200: 8, 1201: 8, 1202: 8, 1203: 8, 1206: 8, 1227: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1558: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1596: 8, 1597: 8, 1664: 8, 1728: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }], CAR.RAV4_TSS2: [ # LE { - 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 355: 5, 401: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 565: 8, 608: 8, 610: 8, 643: 7, 705: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 764: 8, 765: 8, 800: 8, 810: 2, 812: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 882: 8, 885: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1063: 8, 1076: 8, 1077: 8,1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1235: 8, 1279: 8, 1541: 8, 1552: 8, 1553:8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1745: 8, 1775: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 355: 5, 401: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 565: 8, 608: 8, 610: 8, 643: 7, 705: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 764: 8, 765: 8, 767: 4, 800: 8, 810: 2, 812: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 882: 8, 885: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1063: 8, 1076: 8, 1077: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1235: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1745: 8, 1775: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, # XLE, Limited, and AWD { - 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 401: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 565: 8, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 764: 8, 765: 8, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 882: 8, 885: 8, 889: 8, 891: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 987: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1063: 8, 1076: 8, 1077: 8, 1082: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1696: 8, 1745: 8, 1775: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8, 2015: 8, 2016: 8, 2024: 8 + 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 401: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 565: 8, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 764: 8, 765: 8, 767: 4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 882: 8, 885: 8, 889: 8, 891: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 987: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1063: 8, 1076: 8, 1077: 8, 1082: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1696: 8, 1745: 8, 1775: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8, 2015: 8, 2016: 8, 2024: 8 }], CAR.COROLLA_TSS2: [ # hatch 2019+ and sedan 2020+ { - 36: 8, 37: 8, 114: 5, 170: 8, 180: 8, 186: 4, 401: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 705: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 764: 8, 765: 8, 800: 8, 810: 2, 812: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1235: 8, 1237: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1595: 8, 1649: 8, 1745: 8, 1775: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1809: 8, 1816: 8, 1817: 8, 1840: 8, 1848: 8, 1904: 8, 1912: 8, 1940: 8, 1941: 8, 1948: 8, 1949: 8, 1952: 8, 1960: 8, 1981: 8, 1986: 8, 1990: 8, 1994: 8, 1998: 8, 2004: 8 + 36: 8, 37: 8, 114: 5, 170: 8, 180: 8, 186: 4, 401: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 705: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 764: 8, 765: 8, 767: 4, 800: 8, 810: 2, 812: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1235: 8, 1237: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1595: 8, 1649: 8, 1745: 8, 1775: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1809: 8, 1816: 8, 1817: 8, 1840: 8, 1848: 8, 1904: 8, 1912: 8, 1940: 8, 1941: 8, 1948: 8, 1949: 8, 1952: 8, 1960: 8, 1981: 8, 1986: 8, 1990: 8, 1994: 8, 1998: 8, 2004: 8 + }], + CAR.COROLLAH_TSS2: [ + # 2019 Taiwan Altis Hybrid + { + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 401: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 765: 8, 767: 4, 800: 8, 810: 2, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 885: 8, 896: 8, 898: 8, 918: 7, 921: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 987: 8, 993: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1082: 8, 1112: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1172: 8, 1235: 8, 1237: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1745: 8, 1775: 8, 1779: 8 + }, + # 2019 Chinese Levin Hybrid + { + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 401: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 765: 8, 767: 4, 800: 8, 810: 2, 812: 8, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 885: 8, 896: 8, 898: 8, 921: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 993: 8, 1002: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1172: 8, 1235: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1600: 8, 1649: 8, 1745: 8, 1775: 8, 1779: 8 + } + ], + CAR.LEXUS_ES_TSS2: [{ + 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 401: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 765: 8, 767: 4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 824: 8, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 882: 8, 885: 8, 889: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 987: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1696: 8, 1775: 8, 1777: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8, }], CAR.LEXUS_ESH_TSS2: [ { - 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 401: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 658: 8, 713: 8, 728: 8, 740: 5, 742: 8, 743: 8, 744: 8, 761: 8, 764: 8, 765: 8, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 882: 8, 885: 8, 889: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 987: 8, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1228: 8, 1235: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1696: 8, 1775: 8, 1777: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 401: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 658: 8, 713: 8, 728: 8, 740: 5, 742: 8, 743: 8, 744: 8, 761: 8, 764: 8, 765: 8, 767: 4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 882: 8, 885: 8, 889: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 987: 8, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1228: 8, 1235: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1696: 8, 1775: 8, 1777: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + }], + CAR.SIENNA: [ + { + 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 545: 5, 548: 8, 550: 8, 552: 4, 562: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 764: 8, 767: 4, 800: 8, 824: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 888: 8, 896: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 1, 918: 7, 921: 8, 933: 8, 944: 6, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1008: 2, 1014: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1114: 8, 1160: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1182: 8, 1183: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1200: 8, 1201: 8, 1202: 8, 1203: 8, 1212: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1279: 8, 1552: 8, 1553: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1656: 8, 1664: 8, 1666: 8, 1667: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + }, + # XLE AWD 2018 + { + 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 238: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 545: 5, 548: 8, 550: 8, 552: 4, 562: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 764: 8, 767: 4, 800: 8, 824: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 1, 921: 8, 933: 8, 944: 6, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1008: 2, 1014: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1114: 8, 1160: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1182: 8, 1183: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1200: 8, 1201: 8, 1202: 8, 1203: 8, 1212: 8, 1227: 8, 1235: 8, 1237: 8, 1279: 8, 1552: 8, 1553: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1656: 8, 1664: 8, 1666: 8, 1667: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }], - CAR.SIENNA: [{ - 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 545: 5, 548: 8, 550: 8, 552: 4, 562: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 764: 8, 800: 8, 824: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 888: 8, 896: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 1, 918: 7, 921: 8, 933: 8, 944: 6, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1008: 2, 1014: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1114: 8, 1160: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1182: 8, 1183: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1200: 8, 1201: 8, 1202: 8, 1203: 8, 1212: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1279: 8, 1552: 8, 1553: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1656: 8, 1664: 8, 1666: 8, 1667: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + CAR.LEXUS_IS: [ + # IS300 2018 + { + 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 238: 4, 400: 6, 426: 6, 452: 8, 464: 8, 466: 8, 467: 5, 544: 4, 550: 8, 552: 4, 608: 8, 610: 5, 643: 7, 705: 8, 740: 5, 767: 4, 800: 8, 836: 8, 845: 5, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 913: 8, 916: 3, 918: 7, 921: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1008: 2, 1009: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1112: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1168: 1, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1182: 8, 1183: 8, 1184: 8, 1185: 8, 1186: 8, 1187: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1208: 8, 1212: 8, 1227: 8, 1235: 8, 1237: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1584: 8, 1589: 8, 1590: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1648: 8, 1666: 8, 1667: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + }, + # IS300H 2017 + { + 36: 8, 37: 8, 170: 8, 180: 8, 295: 8, 296: 8, 400: 6, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 581: 5, 608: 8, 610: 5, 643: 7, 713: 8, 740: 5, 767: 4, 800: 8, 836: 8, 845: 5, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 913: 8, 916: 3, 918: 7, 921: 7, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 3, 955: 8, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1009: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1112: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1168: 1, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1184: 8, 1185: 8, 1186: 8, 1187: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1208: 8, 1212: 8, 1227: 8, 1232: 8, 1235: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1728: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + }], + CAR.RAV4H_TSS2: [ + #Hybrid Limited + { + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 401: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 658: 8, 713: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 764: 8, 765: 8, 767: 4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 882: 8, 885: 8, 889: 8, 891: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 987: 8, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1063: 8, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1696: 8, 1745: 8, 1775: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1810: 8, 1816: 8, 1818: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + }, + ], + CAR.LEXUS_CTH: [{ + 36: 8, 37: 8, 170: 8, 180: 8, 288: 8, 426: 6, 452: 8, 466: 8, 467: 8, 548: 8, 552: 4, 560: 7, 581: 5, 608: 8, 610: 5, 643: 7, 713: 8, 740: 5, 800: 8, 810: 2, 832: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 1, 921: 8, 933: 8, 944: 6, 945: 8, 950: 8, 951: 8, 953: 3, 955: 4, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1056: 8, 1057: 8, 1059: 1, 1076: 8, 1077: 8, 1114: 8, 1116: 8, 1160: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1184: 8, 1185: 8, 1186: 8, 1190: 8, 1191: 8, 1192: 8, 1227: 8, 1235: 8, 1279: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1558: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1664: 8, 1728: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }], + CAR.LEXUS_NXH: [{ + 36: 8, 37: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 5, 643: 7, 713: 8, 740: 5, 742: 8, 743: 8, 764: 8, 800: 8, 810: 2, 812: 3, 818: 8, 822: 8, 824: 8, 835: 8, 836: 8, 845: 5, 849: 4, 869: 7, 870: 7, 871: 2, 889: 8, 891: 8, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 913: 8, 916: 3, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 3, 955: 8, 956: 8, 979: 2, 987: 8, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1006: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1056: 8, 1057: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1168: 1, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1184: 8, 1185: 8, 1186: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1195: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1208: 8, 1212: 8, 1227: 8, 1228: 8, 1232: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1656: 8, 1728: 8, 1745: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + }], + CAR.LEXUS_NX: [{ + 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 238: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 5, 643: 7, 658: 8, 705: 8, 725: 2, 740: 5, 764: 8, 800: 8, 810: 2, 812: 3, 818: 8, 824: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 888: 8, 889: 8, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1006: 8, 1008: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1168: 1, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1182: 8, 1183: 8, 1184: 8, 1185: 8, 1186: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1195: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1200: 8, 1201: 8, 1202: 8, 1203: 8, 1206: 8, 1208: 8, 1212: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1656: 8, 1666: 8, 1667: 8, 1728: 8, 1745: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + }], + CAR.PRIUS_TSS2: [{ + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 401: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 764: 8, 765: 8, 800: 8, 810: 2, 814: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 882: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1083: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1175: 8, 1228: 8, 1235: 8, 1237: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1593: 8, 1595: 8, 1649: 8, 1653: 8, 1654: 8, 1655: 8, 1775: 8, 1777: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + }] +} + +# Don't use theses fingerprints for fingerprinting, they are still needed for ECU detection +IGNORED_FINGERPRINTS = [CAR.RAV4H_TSS2, CAR.HIGHLANDERH_TSS2, CAR.LEXUS_RXH_TSS2, CAR.PRIUS_TSS2, + CAR.LEXUS_NX, CAR.CAMRY_TSS2] + +FW_VERSIONS = { + CAR.AVALON: { + (Ecu.esp, 0x7b0, None): [b'F152607060\x00\x00\x00\x00\x00\x00'], + (Ecu.dsu, 0x791, None): [ + b'881510705200\x00\x00\x00\x00', + b'881510701300\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [b'8965B41051\x00\x00\x00\x00\x00\x00'], + (Ecu.engine, 0x7e0, None): [ + b'\x0230721100\x00\x00\x00\x00\x00\x00\x00\x00A0C01000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0230721200\x00\x00\x00\x00\x00\x00\x00\x00A0C01000\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4702000\x00\x00\x00\x00', + b'8821F4702100\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F0701100\x00\x00\x00\x00', + b'8646F0703000\x00\x00\x00\x00', + ], + }, + CAR.CAMRY: { + (Ecu.engine, 0x700, None): [ + b'\x018966306L3100\x00\x00\x00\x00', + b'\x018966306L4200\x00\x00\x00\x00', + b'\x018966306L5200\x00\x00\x00\x00', + b'\x018966306Q3100\x00\x00\x00\x00', + b'\x018966306Q4000\x00\x00\x00\x00', + b'\x018966306Q4100\x00\x00\x00\x00', + b'\x018966306Q4200\x00\x00\x00\x00', + b'\x018966333P3100\x00\x00\x00\x00', + b'\x018966333P3200\x00\x00\x00\x00', + b'\x018966333P4200\x00\x00\x00\x00', + b'\x018966333P4300\x00\x00\x00\x00', + b'\x018966333P4400\x00\x00\x00\x00', + b'\x018966333P4500\x00\x00\x00\x00', + b'\x018966333P4700\x00\x00\x00\x00', + b'\x018966333Q6000\x00\x00\x00\x00', + b'\x018966333Q6200\x00\x00\x00\x00', + b'\x018966333Q6300\x00\x00\x00\x00', + b'\x018966333W6000\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'8821F0601200 ', + b'8821F0601300 ', + b'8821F0603300 ', + b'8821F0607200 ', + b'8821F0608000 ', + b'8821F0608200 ', + b'8821F0609100 ', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152606210\x00\x00\x00\x00\x00\x00', + b'F152606230\x00\x00\x00\x00\x00\x00', + b'F152606290\x00\x00\x00\x00\x00\x00', + b'F152633540\x00\x00\x00\x00\x00\x00', + b'F152633A20\x00\x00\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B33540\x00\x00\x00\x00\x00\x00', + b'8965B33542\x00\x00\x00\x00\x00\x00', + b'8965B33580\x00\x00\x00\x00\x00\x00', + b'8965B33581\x00\x00\x00\x00\x00\x00', + b'8965B33621\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ # Same as 0x791 + b'8821F0601200 ', + b'8821F0601300 ', + b'8821F0603300 ', + b'8821F0607200 ', + b'8821F0608000 ', + b'8821F0608200 ', + b'8821F0609100 ', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F0601200 ', + b'8646F0601300 ', + b'8646F0603400 ', + b'8646F0605000 ', + b'8646F0606000 ', + b'8646F0606100 ', + b'8646F0607100 ', + ], + }, + CAR.CAMRYH: { + (Ecu.engine, 0x700, None): [ + b'\x018966333N4300\x00\x00\x00\x00', + b'\x018966333X0000\x00\x00\x00\x00', + b'\x028966306B2100\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', + b'\x028966306B2300\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', + b'\x028966306N8100\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', + b'\x028966306N8200\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', + b'\x028966306N8300\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', + b'\x028966306N8400\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', + b'\x028966306R5000\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', + b'\x028966306R5000\x00\x00\x00\x00897CF3305001\x00\x00\x00\x00', + b'\x028966306R6000\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', + b'\x028966306R6000\x00\x00\x00\x00897CF3305001\x00\x00\x00\x00', + b'\x028966306S0000\x00\x00\x00\x00897CF3305001\x00\x00\x00\x00', + b'\x028966306S0100\x00\x00\x00\x00897CF3305001\x00\x00\x00\x00', + b'\x028966306S1100\x00\x00\x00\x00897CF3305001\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152633214\x00\x00\x00\x00\x00\x00', + b'F152633660\x00\x00\x00\x00\x00\x00', + b'F152633712\x00\x00\x00\x00\x00\x00', + b'F152633713\x00\x00\x00\x00\x00\x00', + b'F152633B51\x00\x00\x00\x00\x00\x00', + b'F152633B60\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'8821F0601200 ', + b'8821F0601300 ', + b'8821F0603400 ', + b'8821F0604200 ', + b'8821F0606200 ', + b'8821F0607200 ', + b'8821F0608000 ', + b'8821F0609000 ', + b'8821F0609100 ', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B33540\x00\x00\x00\x00\x00\x00', + b'8965B33542\x00\x00\x00\x00\x00\x00', + b'8965B33550\x00\x00\x00\x00\x00\x00', + b'8965B33551\x00\x00\x00\x00\x00\x00', + b'8965B33580\x00\x00\x00\x00\x00\x00', + b'8965B33581\x00\x00\x00\x00\x00\x00', + b'8965B33611\x00\x00\x00\x00\x00\x00', + b'8965B33621\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ # Same as 0x791 + b'8821F0601200 ', + b'8821F0601300 ', + b'8821F0603400 ', + b'8821F0604200 ', + b'8821F0606200 ', + b'8821F0607200 ', + b'8821F0608000 ', + b'8821F0609000 ', + b'8821F0609100 ', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F0601200 ', + b'8646F0601300 ', + b'8646F0601400 ', + b'8646F0603500 ', + b'8646F0604100 ', + b'8646F0605000 ', + b'8646F0606000 ', + b'8646F0606100 ', + b'8646F0607000 ', + b'8646F0607100 ', + ], + }, + CAR.CAMRY_TSS2: { + (Ecu.eps, 0x7a1, None): [ + b'8965B33630\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'\x01F152606400\x00\x00\x00\x00\x00\x00', + ], + (Ecu.engine, 0x700, None): [ + b'\x018966306Q5000\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 15): [ + b'\x018821F6201200\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 109): [ + b'\x028646F3305200\x00\x00\x00\x008646G5301200\x00\x00\x00\x00', + ], + }, + CAR.CHR: { + (Ecu.engine, 0x700, None): [ + b'\x01896631017100\x00\x00\x00\x00', + b'\x01896631017200\x00\x00\x00\x00', + b'\x0189663F413100\x00\x00\x00\x00', + b'\x0189663F414100\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'8821F0W01000 ', + b'8821FF401600 ', + b'8821FF404000 ', + b'8821FF404100 ', + b'8821FF405100 ', + b'8821FF406000 ', + b'8821F0W01100 ', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152610020\x00\x00\x00\x00\x00\x00', + b'F152610153\x00\x00\x00\x00\x00\x00', + b'F1526F4034\x00\x00\x00\x00\x00\x00', + b'F1526F4044\x00\x00\x00\x00\x00\x00', + b'F1526F4073\x00\x00\x00\x00\x00\x00', + b'F1526F4121\x00\x00\x00\x00\x00\x00', + b'F1526F4122\x00\x00\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B10011\x00\x00\x00\x00\x00\x00', + b'8965B10040\x00\x00\x00\x00\x00\x00', + ], + (Ecu.engine, 0x7e0, None): [ + b'\x033F401100\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203102\x00\x00\x00\x00', + b'\x033F424000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203202\x00\x00\x00\x00', + b'\x0331024000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203302\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F0W01000 ', + b'8821FF401600 ', + b'8821FF404000 ', + b'8821FF404100 ', + b'8821FF405100 ', + b'8821FF406000 ', + b'8821F0W01100 ', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646FF401800 ', + b'8646FF404000 ', + b'8646FF406000 ', + ], + }, + CAR.CHRH: { + (Ecu.engine, 0x700, None): [ + b'\x0289663F423000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x0289663F431000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x0189663F438000\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152610040\x00\x00\x00\x00\x00\x00', + b'F152610190\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'8821FF404000 ', + b'8821FF407100 ', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B10040\x00\x00\x00\x00\x00\x00', + b'8965B10050\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821FF404000 ', + b'8821FF407100 ', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646FF404000 ', + b'8646FF407000 ', + ], + }, + CAR.COROLLA: { + (Ecu.engine, 0x7e0, None): [ + b'\x01896630E88000\x00\x00\x00\x00', + b'\x0230ZC2000\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0230ZC2100\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0230ZC2200\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0230ZC2300\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0230ZC3000\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0230ZC3200\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0230ZC3300\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0330ZC1200\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00895231203202\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'881510201100\x00\x00\x00\x00', + b'881510201200\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152602190\x00\x00\x00\x00\x00\x00', + b'F152602191\x00\x00\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B02181\x00\x00\x00\x00\x00\x00', + b'8965B02191\x00\x00\x00\x00\x00\x00', + b'8965B48150\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4702100\x00\x00\x00\x00', + b'8821F4702300\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F0201101\x00\x00\x00\x00', + b'8646F0201200\x00\x00\x00\x00', + b'8646F0E01300\x00\x00\x00\x00', + ], + }, + CAR.COROLLA_TSS2: { + (Ecu.engine, 0x700, None): [ + b'\x01896630ZG5000\x00\x00\x00\x00', + b'\x01896630ZG5100\x00\x00\x00\x00', + b'\x01896630ZG5200\x00\x00\x00\x00', + b'\x01896630ZG5300\x00\x00\x00\x00', + b'\x01896630ZQ5000\x00\x00\x00\x00', + b'\x018966312L8000\x00\x00\x00\x00', + b'\x018966312P9000\x00\x00\x00\x00', + b'\x018966312P9100\x00\x00\x00\x00', + b'\x018966312P9200\x00\x00\x00\x00', + b'\x018966312R0100\x00\x00\x00\x00', + b'\x018966312R1000\x00\x00\x00\x00', + b'\x018966312R1100\x00\x00\x00\x00', + b'\x018966312R3100\x00\x00\x00\x00', + ], + (Ecu.engine, 0x7e0, None): [ + b'\x0230ZN4000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x03312N6000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203202\x00\x00\x00\x00', + b'\x03312N6000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203302\x00\x00\x00\x00', + b'\x03312N6100\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203302\x00\x00\x00\x00', + b'\x03312N6100\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203402\x00\x00\x00\x00', + b'\x03312M3000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203402\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'\x018965B1255000\x00\x00\x00\x00', + b'8965B12361\x00\x00\x00\x00\x00\x00', + b'\x018965B12350\x00\x00\x00\x00\x00\x00', + b'\x018965B12470\x00\x00\x00\x00\x00\x00', + b'\x018965B12500\x00\x00\x00\x00\x00\x00', + b'\x018965B12520\x00\x00\x00\x00\x00\x00', + b'\x018965B12530\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152602191\x00\x00\x00\x00\x00\x00', + b'\x01F152602280\x00\x00\x00\x00\x00\x00', + b'\x01F152602560\x00\x00\x00\x00\x00\x00', + b'\x01F152602650\x00\x00\x00\x00\x00\x00', + b'\x01F152612641\x00\x00\x00\x00\x00\x00', + b'\x01F152612651\x00\x00\x00\x00\x00\x00', + b'\x01F152612B10\x00\x00\x00\x00\x00\x00', + b'\x01F152612B60\x00\x00\x00\x00\x00\x00', + b'\x01F152612B61\x00\x00\x00\x00\x00\x00', + b'\x01F152612B90\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'\x018821F3301100\x00\x00\x00\x00', + b'\x018821F3301200\x00\x00\x00\x00', + b'\x018821F3301300\x00\x00\x00\x00', + b'\x018821F3301400\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'\x028646F12010D0\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F1201100\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F1201200\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F1201300\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', + b'\x028646F1202000\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + b'\x028646F1202100\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', + ], + }, + CAR.COROLLAH_TSS2: { + (Ecu.engine, 0x700, None): [ + b'\x01896630ZJ1000\x00\x00\x00\x00', + b'\x018966342M5000\x00\x00\x00\x00', + b'\x02896630ZQ3000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896630ZR2000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x028966312Q4000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x038966312L7000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF1205001\x00\x00\x00\x00', + b'\x038966312N1000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF1203001\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B12361\x00\x00\x00\x00\x00\x00', + b'8965B12451\x00\x00\x00\x00\x00\x00', + b'\x018965B12350\x00\x00\x00\x00\x00\x00', + b'\x018965B12470\x00\x00\x00\x00\x00\x00', + b'\x018965B12500\x00\x00\x00\x00\x00\x00', + b'\x018965B12520\x00\x00\x00\x00\x00\x00', + b'\x018965B12530\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152612590\x00\x00\x00\x00\x00\x00', + b'F152612691\x00\x00\x00\x00\x00\x00', + b'F152612692\x00\x00\x00\x00\x00\x00', + b'F152612700\x00\x00\x00\x00\x00\x00', + b'F152612800\x00\x00\x00\x00\x00\x00', + b'F152612840\x00\x00\x00\x00\x00\x00', + b'F152612A10\x00\x00\x00\x00\x00\x00', + b'F152642540\x00\x00\x00\x00\x00\x00', + b'F152612A00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'\x018821F3301100\x00\x00\x00\x00', + b'\x018821F3301200\x00\x00\x00\x00', + b'\x018821F3301300\x00\x00\x00\x00', + b'\x018821F3301400\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'\x028646F1201100\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F1201300\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', + b'\x028646F1202000\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + b'\x028646F1202100\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', + b'\x028646F4203400\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + ], + }, + CAR.HIGHLANDER: { + (Ecu.engine, 0x700, None): [ + b'\x01896630E09000\x00\x00\x00\x00', + b'\x01896630E43100\x00\x00\x00\x00', + b'\x01896630E43200\x00\x00\x00\x00', + b'\x01896630E44200\x00\x00\x00\x00', + b'\x01896630E45000\x00\x00\x00\x00', + b'\x01896630E45100\x00\x00\x00\x00', + b'\x01896630E45200\x00\x00\x00\x00', + b'\x01896630E74000\x00\x00\x00\x00', + b'\x01896630E76000\x00\x00\x00\x00', + b'\x01896630E83000\x00\x00\x00\x00', + b'\x01896630E84000\x00\x00\x00\x00', + b'\x01896630E85000\x00\x00\x00\x00', + b'\x01896630E88000\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B48140\x00\x00\x00\x00\x00\x00', + b'8965B48150\x00\x00\x00\x00\x00\x00', + b'8965B48210\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [b'F15260E011\x00\x00\x00\x00\x00\x00'], + (Ecu.dsu, 0x791, None): [ + b'881510E01100\x00\x00\x00\x00', + b'881510E01200\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4702100\x00\x00\x00\x00', + b'8821F4702300\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F0E01200\x00\x00\x00\x00', + b'8646F0E01300\x00\x00\x00\x00', + ], + }, + CAR.HIGHLANDERH: { + (Ecu.eps, 0x7a1, None): [ + b'8965B48160\x00\x00\x00\x00\x00\x00' + ], + (Ecu.esp, 0x7b0, None): [ + b'F152648541\x00\x00\x00\x00\x00\x00', + b'F152648542\x00\x00\x00\x00\x00\x00', + ], + (Ecu.engine, 0x7e0, None): [ + b'\x0230E40000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0230EA2000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0230EA2100\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4702100\x00\x00\x00\x00', + b'8821F4702300\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F0E01200\x00\x00\x00\x00', + b'8646F0E01300\x00\x00\x00\x00', + ], + }, + CAR.HIGHLANDER_TSS2: { + (Ecu.eps, 0x7a1, None): [ + b'8965B48241\x00\x00\x00\x00\x00\x00', + b'8965B48310\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'\x01F15260E051\x00\x00\x00\x00\x00\x00', + b'\x01F15260E110\x00\x00\x00\x00\x00\x00', + ], + (Ecu.engine, 0x700, None): [ + b'\x01896630E62200\x00\x00\x00\x00', + b'\x01896630E64100\x00\x00\x00\x00', + b'\x01896630E64200\x00\x00\x00\x00', + b'\x01896630EB2000\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'\x018821F3301400\x00\x00\x00\x00', + b'\x018821F6201200\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'\x028646F0E02100\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + b'\x028646F4803000\x00\x00\x00\x008646G5301200\x00\x00\x00\x00', + ], + }, + CAR.HIGHLANDERH_TSS2: { + (Ecu.eps, 0x7a1, None): [ + b'8965B48241\x00\x00\x00\x00\x00\x00', + b'8965B48310\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'\x01F15264872300\x00\x00\x00\x00', + b'\x01F15264872400\x00\x00\x00\x00', + ], + (Ecu.engine, 0x700, None): [ + b'\x02896630E66000\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', + b'\x02896630EB3000\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'\x018821F3301400\x00\x00\x00\x00', + b'\x018821F6201200\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'\x028646F0E02100\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + b'\x028646F4803000\x00\x00\x00\x008646G5301200\x00\x00\x00\x00', + ], + }, + CAR.LEXUS_IS: { + (Ecu.engine, 0x700, None): [ + b'\x018966353M7100\x00\x00\x00\x00', + b'\x018966353Q2300\x00\x00\x00\x00', + b'\x018966353R1100\x00\x00\x00\x00', + b'\x018966353R7100\x00\x00\x00\x00', + b'\x018966353R8100\x00\x00\x00\x00', + ], + (Ecu.engine, 0x7e0, None): [ + b'\x02353P7000\x00\x00\x00\x00\x00\x00\x00\x00530J5000\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152653330\x00\x00\x00\x00\x00\x00', + b'F152653301\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'881515306400\x00\x00\x00\x00', + b'881515306500\x00\x00\x00\x00', + b'881515306200\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B53271\x00\x00\x00\x00\x00\x00', + b'8965B53280\x00\x00\x00\x00\x00\x00', + b'8965B53281\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4702300\x00\x00\x00\x00', + b'8821F4702100\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F5301300\x00\x00\x00\x00', + b'8646F5301400\x00\x00\x00\x00', + b'8646F5301200\x00\x00\x00\x00', + ], + }, + CAR.PRIUS: { + (Ecu.engine, 0x700, None): [ + b'\x02896634761000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634761100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634761200\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634763000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634765000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634769100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634774000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634774100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634774200\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634782000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634784000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x028966347A5000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x028966347A8000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634765100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x03896634759100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701003\x00\x00\x00\x00', + b'\x03896634759200\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701003\x00\x00\x00\x00', + b'\x03896634759200\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701004\x00\x00\x00\x00', + b'\x03896634759300\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701004\x00\x00\x00\x00', + b'\x03896634760000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701002\x00\x00\x00\x00', + b'\x03896634760000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701003\x00\x00\x00\x00', + b'\x03896634760100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701003\x00\x00\x00\x00', + b'\x03896634760200\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701003\x00\x00\x00\x00', + b'\x03896634760200\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701004\x00\x00\x00\x00', + b'\x03896634760300\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701004\x00\x00\x00\x00', + b'\x03896634768000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4703001\x00\x00\x00\x00', + b'\x03896634768000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4703002\x00\x00\x00\x00', + b'\x03896634768100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4703002\x00\x00\x00\x00', + b'\x03896634785000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4705001\x00\x00\x00\x00', + b'\x03896634786000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4705001\x00\x00\x00\x00', + b'\x03896634786000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4710001\x00\x00\x00\x00', + b'\x03896634789000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4703002\x00\x00\x00\x00', + b'\x038966347A3000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4707001\x00\x00\x00\x00', + b'\x038966347B6000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4710001\x00\x00\x00\x00', + b'\x038966347B7000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4710001\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B47021\x00\x00\x00\x00\x00\x00', + b'8965B47022\x00\x00\x00\x00\x00\x00', + b'8965B47023\x00\x00\x00\x00\x00\x00', + b'8965B47050\x00\x00\x00\x00\x00\x00', + b'8965B47060\x00\x00\x00\x00\x00\x00', # This is the EPS with good angle sensor + ], + (Ecu.esp, 0x7b0, None): [ + b'F152647290\x00\x00\x00\x00\x00\x00', + b'F152647300\x00\x00\x00\x00\x00\x00', + b'F152647310\x00\x00\x00\x00\x00\x00', + b'F152647414\x00\x00\x00\x00\x00\x00', + b'F152647415\x00\x00\x00\x00\x00\x00', + b'F152647416\x00\x00\x00\x00\x00\x00', + b'F152647417\x00\x00\x00\x00\x00\x00', + b'F152647470\x00\x00\x00\x00\x00\x00', + b'F152647490\x00\x00\x00\x00\x00\x00', + b'F152647684\x00\x00\x00\x00\x00\x00', + b'F152647862\x00\x00\x00\x00\x00\x00', + b'F152647863\x00\x00\x00\x00\x00\x00', + b'F152647864\x00\x00\x00\x00\x00\x00', + b'F152647865\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'881514702300\x00\x00\x00\x00', + b'881514703100\x00\x00\x00\x00', + b'881514704100\x00\x00\x00\x00', + b'881514706000\x00\x00\x00\x00', + b'881514706100\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4702000\x00\x00\x00\x00', + b'8821F4702100\x00\x00\x00\x00', + b'8821F4702300\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F4201200\x00\x00\x00\x00', + b'8646F4701300\x00\x00\x00\x00', + b'8646F4702001\x00\x00\x00\x00', + b'8646F4702100\x00\x00\x00\x00', + b'8646F4702200\x00\x00\x00\x00', + b'8646F4705000\x00\x00\x00\x00', + b'8646F4705200\x00\x00\x00\x00', + ], + }, + CAR.RAV4: { + (Ecu.engine, 0x7e0, None): [ + b'\x02342Q1000\x00\x00\x00\x00\x00\x00\x00\x0054212000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02342Q1100\x00\x00\x00\x00\x00\x00\x00\x0054212000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02342Q1200\x00\x00\x00\x00\x00\x00\x00\x0054212000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02342Q1300\x00\x00\x00\x00\x00\x00\x00\x0054212000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02342Q2000\x00\x00\x00\x00\x00\x00\x00\x0054213000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02342Q2100\x00\x00\x00\x00\x00\x00\x00\x0054213000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02342Q2200\x00\x00\x00\x00\x00\x00\x00\x0054213000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02342Q4000\x00\x00\x00\x00\x00\x00\x00\x0054215000\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B42082\x00\x00\x00\x00\x00\x00', + b'8965B42083\x00\x00\x00\x00\x00\x00', + b'8965B42063\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F15260R102\x00\x00\x00\x00\x00\x00', + b'F15260R103\x00\x00\x00\x00\x00\x00', + b'F152642493\x00\x00\x00\x00\x00\x00', + b'F152642492\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'881514201200\x00\x00\x00\x00', + b'881514201300\x00\x00\x00\x00', + b'881514201400\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4702000\x00\x00\x00\x00', + b'8821F4702100\x00\x00\x00\x00', + b'8821F4702300\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F4201200\x00\x00\x00\x00', + b'8646F4202001\x00\x00\x00\x00', + b'8646F4202100\x00\x00\x00\x00', + ], + }, + CAR.RAV4H: { + (Ecu.engine, 0x7e0, None): [ + b'\x02342N9000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02342N9100\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02342P0000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02342Q2000\x00\x00\x00\x00\x00\x00\x00\x0054213000\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B42103\x00\x00\x00\x00\x00\x00', + b'8965B42162\x00\x00\x00\x00\x00\x00', + b'8965B42163\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152642090\x00\x00\x00\x00\x00\x00', + b'F152642120\x00\x00\x00\x00\x00\x00', + b'F152642400\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'881514202200\x00\x00\x00\x00', + b'881514202300\x00\x00\x00\x00', + b'881514202400\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4702000\x00\x00\x00\x00', + b'8821F4702100\x00\x00\x00\x00', + b'8821F4702300\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F4201100\x00\x00\x00\x00', + b'8646F4201200\x00\x00\x00\x00', + b'8646F4202001\x00\x00\x00\x00', + b'8646F4202100\x00\x00\x00\x00', + b'8646F4204000\x00\x00\x00\x00', + ], + }, + CAR.RAV4_TSS2: { + (Ecu.engine, 0x700, None): [ + b'\x01896630R58000\x00\x00\x00\x00', + b'\x018966342E2000\x00\x00\x00\x00', + b'\x018966342M8000\x00\x00\x00\x00', + b'\x018966342T1000\x00\x00\x00\x00', + b'\x018966342T6000\x00\x00\x00\x00', + b'\x018966342T9000\x00\x00\x00\x00', + b'\x018966342U4000\x00\x00\x00\x00', + b'\x018966342U4100\x00\x00\x00\x00', + b'\x018966342V3100\x00\x00\x00\x00', + b'\x018966342V3200\x00\x00\x00\x00', + b'\x018966342X5000\x00\x00\x00\x00', + b'\x01896634A05000\x00\x00\x00\x00', + b'\x01896634A19000\x00\x00\x00\x00', + b'\x01896634A19100\x00\x00\x00\x00', + b'\x01896634A20000\x00\x00\x00\x00', + b'\x01896634A22000\x00\x00\x00\x00', + b'\x01896634A44000\x00\x00\x00\x00', + b'\x01896634A45000\x00\x00\x00\x00', + b'\x01896634A46000\x00\x00\x00\x00', + b'\x01F152642551\x00\x00\x00\x00\x00\x00', + b'\x028966342T0000\x00\x00\x00\x00897CF1201001\x00\x00\x00\x00', + b'\x028966342V1000\x00\x00\x00\x00897CF1202001\x00\x00\x00\x00', + b'\x028966342Y8000\x00\x00\x00\x00897CF1201001\x00\x00\x00\x00', + b'\x02896634A18000\x00\x00\x00\x00897CF1201001\x00\x00\x00\x00', + b'\x02896634A43000\x00\x00\x00\x00897CF4201001\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'\x01F15260R210\x00\x00\x00\x00\x00\x00', + b'\x01F15260R220\x00\x00\x00\x00\x00\x00', + b'\x01F15260R300\x00\x00\x00\x00\x00\x00', + b'\x01F152642551\x00\x00\x00\x00\x00\x00', + b'\x01F152642561\x00\x00\x00\x00\x00\x00', + b'\x01F152642700\x00\x00\x00\x00\x00\x00', + b'\x01F152642710\x00\x00\x00\x00\x00\x00', + b'\x01F152642711\x00\x00\x00\x00\x00\x00', + b'\x01F152642750\x00\x00\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B42170\x00\x00\x00\x00\x00\x00', + b'8965B42171\x00\x00\x00\x00\x00\x00', + b'8965B42180\x00\x00\x00\x00\x00\x00', + b'8965B42181\x00\x00\x00\x00\x00\x00', + b'\x028965B0R01200\x00\x00\x00\x008965B0R02200\x00\x00\x00\x00', + b'\x028965B0R01300\x00\x00\x00\x008965B0R02300\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'\x018821F3301100\x00\x00\x00\x00', + b'\x018821F3301200\x00\x00\x00\x00', + b'\x018821F3301300\x00\x00\x00\x00', + b'\x018821F3301400\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'\x028646F4203200\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F4203300\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F4203400\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + b'\x028646F4203500\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + b'\x028646F4203700\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', + b'\x028646F4203800\x00\x00\x00\x008646G2601500\x00\x00\x00\x00', + ], + }, + CAR.RAV4H_TSS2: { + (Ecu.engine, 0x700, None): [ + b'\x01896634A15000\x00\x00\x00\x00', + b'\x018966342M5000\x00\x00\x00\x00', + b'\x018966342W8000\x00\x00\x00\x00', + b'\0018966342X5000\x00\x00\x00\x00', + b'\x018966342X6000\x00\x00\x00\x00', + b'\x01896634A25000\x00\x00\x00\x00', + b'\x018966342W5000\x00\x00\x00\x00', + b'\x028966342W4001\x00\x00\x00\x00897CF1203001\x00\x00\x00\x00', + b'\x02896634A14001\x00\x00\x00\x00897CF1203001\x00\x00\x00\x00', + b'\x02896634A23001\x00\x00\x00\x00897CF1203001\x00\x00\x00\x00', + b'\x02896634A14001\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152642291\x00\x00\x00\x00\x00\x00', + b'F152642330\x00\x00\x00\x00\x00\x00', + b'F152642331\x00\x00\x00\x00\x00\x00', + b'F152642531\x00\x00\x00\x00\x00\x00', + b'F152642532\x00\x00\x00\x00\x00\x00', + b'F152642520\x00\x00\x00\x00\x00\x00', + b'F152642521\x00\x00\x00\x00\x00\x00', + b'F152642540\x00\x00\x00\x00\x00\x00', + b'F152642541\x00\x00\x00\x00\x00\x00', + b'F152642542\x00\x00\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B42170\x00\x00\x00\x00\x00\x00', + b'8965B42171\x00\x00\x00\x00\x00\x00', + b'8965B42180\x00\x00\x00\x00\x00\x00', + b'8965B42181\x00\x00\x00\x00\x00\x00', + b'\x028965B0R01200\x00\x00\x00\x008965B0R02200\x00\x00\x00\x00', + b'\x028965B0R01300\x00\x00\x00\x008965B0R02300\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'\x018821F3301100\x00\x00\x00\x00', + b'\x018821F3301200\x00\x00\x00\x00', + b'\x018821F3301300\x00\x00\x00\x00', + b'\x018821F3301400\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'\x028646F4203200\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F4203300\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F4203400\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + b'\x028646F4203500\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + b'\x028646F4203700\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', + b'\x028646F4203800\x00\x00\x00\x008646G2601500\x00\x00\x00\x00', + ], + }, + CAR.LEXUS_ES_TSS2: { + (Ecu.engine, 0x700, None): [ + b'\x018966333T5100\x00\x00\x00\x00', + b'\x018966333T5000\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [b'\x01F152606281\x00\x00\x00\x00\x00\x00'], + (Ecu.eps, 0x7a1, None): [b'8965B33252\x00\x00\x00\x00\x00\x00'], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'\x018821F3301200\x00\x00\x00\x00', + b'\x018821F3301100\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'\x028646F3303200\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F33030D0\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + ], + }, + CAR.SIENNA: { + (Ecu.engine, 0x700, None): [ + b'\x01896630832100\x00\x00\x00\x00', + b'\x01896630838000\x00\x00\x00\x00', + b'\x01896630838100\x00\x00\x00\x00', + b'\x01896630842000\x00\x00\x00\x00', + b'\x01896630843000\x00\x00\x00\x00', + b'\x01896630851000\x00\x00\x00\x00', + b'\x01896630851100\x00\x00\x00\x00', + b'\x01896630852100\x00\x00\x00\x00', + b'\x01896630859000\x00\x00\x00\x00', + b'\x01896630860000\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B45070\x00\x00\x00\x00\x00\x00', + b'8965B45082\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152608130\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'881510801100\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4702100\x00\x00\x00\x00', + b'8821F4702200\x00\x00\x00\x00', + b'8821F4702300\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F0801100\x00\x00\x00\x00', + ], + }, + CAR.LEXUS_ESH_TSS2: { + (Ecu.engine, 0x700, None): [ + b'\x028966333S8000\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', + b'\x028966333V4000\x00\x00\x00\x00897CF3305001\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152633423\x00\x00\x00\x00\x00\x00', + b'F152633680\x00\x00\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B33252\x00\x00\x00\x00\x00\x00', + b'8965B33590\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'\x018821F3301100\x00\x00\x00\x00', + b'\x018821F3301300\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'\x028646F33030D0\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F3303100\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F3304100\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + ], + }, + CAR.LEXUS_NX: { + (Ecu.engine, 0x700, None): [ + b'\x01896637851000\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152678140\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'881517803100\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B78060\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4702300\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F7801100\x00\x00\x00\x00', + ], + }, + CAR.LEXUS_NXH: { + (Ecu.engine, 0x7e0, None): [ + b'\x0237882000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0237841000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152678160\x00\x00\x00\x00\x00\x00', + b'F152678170\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'881517804300\x00\x00\x00\x00', + b'881517804100\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B78100\x00\x00\x00\x00\x00\x00', + b'8965B78060\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4702300\x00\x00\x00\x00', + b'8821F4702100\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F7801300\x00\x00\x00\x00', + b'8646F7801100\x00\x00\x00\x00', + ], + }, + CAR.LEXUS_RX: { + (Ecu.engine, 0x700, None): [ + b'\x01896630E37200\x00\x00\x00\x00', + b'\x01896630E41000\x00\x00\x00\x00', + b'\x01896630E41100\x00\x00\x00\x00', + b'\x01896630E41200\x00\x00\x00\x00', + b'\x01896630E37300\x00\x00\x00\x00', + b'\x01896630E36300\x00\x00\x00\x00', + b'\x018966348R8500\x00\x00\x00\x00', + b'\x018966348W1300\x00\x00\x00\x00', + b'\x01896630EA4300\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152648472\x00\x00\x00\x00\x00\x00', + b'F152648473\x00\x00\x00\x00\x00\x00', + b'F152648492\x00\x00\x00\x00\x00\x00', + b'F152648493\x00\x00\x00\x00\x00\x00', + b'F152648474\x00\x00\x00\x00\x00\x00', + b'F152648630\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'881514810300\x00\x00\x00\x00', + b'881514810500\x00\x00\x00\x00', + b'881514810700\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B0E011\x00\x00\x00\x00\x00\x00', + b'8965B0E012\x00\x00\x00\x00\x00\x00', + b'8965B48102\x00\x00\x00\x00\x00\x00', + b'8965B48112\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4701000\x00\x00\x00\x00', + b'8821F4701100\x00\x00\x00\x00', + b'8821F4701200\x00\x00\x00\x00', + b'8821F4701300\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F4801100\x00\x00\x00\x00', + b'8646F4801200\x00\x00\x00\x00', + b'8646F4802001\x00\x00\x00\x00', + b'8646F4802100\x00\x00\x00\x00', + b'8646F4802200\x00\x00\x00\x00', + b'8646F4809000\x00\x00\x00\x00', + ], + }, + CAR.LEXUS_RXH: { + (Ecu.engine, 0x7e0, None): [ + b'\x02348N0000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02348Q4000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02348T1100\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02348V6000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02348Z3000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152648361\x00\x00\x00\x00\x00\x00', + b'F152648501\x00\x00\x00\x00\x00\x00', + b'F152648502\x00\x00\x00\x00\x00\x00', + b'F152648504\x00\x00\x00\x00\x00\x00', + b'F152648A30\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'881514811300\x00\x00\x00\x00', + b'881514811500\x00\x00\x00\x00', + b'881514811700\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B0E011\x00\x00\x00\x00\x00\x00', + b'8965B0E012\x00\x00\x00\x00\x00\x00', + b'8965B48112\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4701000\x00\x00\x00\x00', + b'8821F4701100\x00\x00\x00\x00', + b'8821F4701200\x00\x00\x00\x00', + b'8821F4701300\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F4801200\x00\x00\x00\x00', + b'8646F4802100\x00\x00\x00\x00', + b'8646F4802200\x00\x00\x00\x00', + b'8646F4809000\x00\x00\x00\x00', + ], + }, + CAR.LEXUS_RX_TSS2: { + (Ecu.engine, 0x700, None): [ + b'\x01896634D12000\x00\x00\x00\x00', + b'\x01896630EB0000\x00\x00\x00\x00', + b'\x01896630EA9000\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'\x01F152648801\x00\x00\x00\x00\x00\x00', + b'\x01F15260E031\x00\x00\x00\x00\x00\x00', + b'\x01F15260E041\x00\x00\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B48271\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'\x018821F3301100\x00\x00\x00\x00', + b'\x018821F3301300\x00\x00\x00\x00', + b'\x018821F3301400\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'\x028646F4810200\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', + b'\x028646F4810100\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + ], + }, + CAR.LEXUS_RXH_TSS2: { + (Ecu.engine, 0x7e0, None): [ + b'\x02348X8000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152648831\x00\x00\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B48271\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'\x018821F3301400\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'\x028646F4810100\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + ], + }, + CAR.PRIUS_TSS2: { + (Ecu.engine, 0x700, None): [ + b'\x038966347C1000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4710101\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152647520\x00\x00\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B47070\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'\x018821F3301400\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'\x028646F4707000\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', + ], + }, } STEER_THRESHOLD = 100 @@ -191,20 +1342,40 @@ def check_ecu_msgs(fingerprint, ecu): CAR.RAV4: dbc_dict('toyota_rav4_2017_pt_generated', 'toyota_adas'), CAR.PRIUS: dbc_dict('toyota_prius_2017_pt_generated', 'toyota_adas'), CAR.COROLLA: dbc_dict('toyota_corolla_2017_pt_generated', 'toyota_adas'), + CAR.LEXUS_RX: dbc_dict('lexus_rx_350_2016_pt_generated', 'toyota_adas'), CAR.LEXUS_RXH: dbc_dict('lexus_rx_hybrid_2017_pt_generated', 'toyota_adas'), + CAR.LEXUS_RX_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), + CAR.LEXUS_RXH_TSS2: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_tss2_adas'), CAR.CHR: dbc_dict('toyota_nodsu_pt_generated', 'toyota_adas'), CAR.CHRH: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_adas'), CAR.CAMRY: dbc_dict('toyota_nodsu_pt_generated', 'toyota_adas'), CAR.CAMRYH: dbc_dict('toyota_camry_hybrid_2018_pt_generated', 'toyota_adas'), + CAR.CAMRY_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), CAR.HIGHLANDER: dbc_dict('toyota_highlander_2017_pt_generated', 'toyota_adas'), + CAR.HIGHLANDER_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), CAR.HIGHLANDERH: dbc_dict('toyota_highlander_hybrid_2018_pt_generated', 'toyota_adas'), + CAR.HIGHLANDERH_TSS2: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_tss2_adas'), CAR.AVALON: dbc_dict('toyota_avalon_2017_pt_generated', 'toyota_adas'), CAR.RAV4_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), CAR.COROLLA_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), - CAR.LEXUS_ESH_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), + CAR.COROLLAH_TSS2: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_tss2_adas'), + CAR.LEXUS_ES_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), + CAR.LEXUS_ESH_TSS2: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_tss2_adas'), CAR.SIENNA: dbc_dict('toyota_sienna_xle_2018_pt_generated', 'toyota_adas'), + CAR.LEXUS_IS: dbc_dict('lexus_is_2018_pt_generated', 'toyota_adas'), + CAR.LEXUS_CTH: dbc_dict('lexus_ct200h_2018_pt_generated', 'toyota_adas'), + CAR.RAV4H_TSS2: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_tss2_adas'), + CAR.LEXUS_NXH: dbc_dict('lexus_nx300h_2018_pt_generated', 'toyota_adas'), + CAR.LEXUS_NX: dbc_dict('lexus_nx300_2018_pt_generated', 'toyota_adas'), + CAR.PRIUS_TSS2: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_tss2_adas'), } -NO_DSU_CAR = [CAR.CHR, CAR.CHRH, CAR.CAMRY, CAR.CAMRYH, CAR.RAV4_TSS2, CAR.COROLLA_TSS2, CAR.LEXUS_ESH_TSS2] -TSS2_CAR = [CAR.RAV4_TSS2, CAR.COROLLA_TSS2, CAR.LEXUS_ESH_TSS2] -NO_STOP_TIMER_CAR = [CAR.RAV4H, CAR.HIGHLANDERH, CAR.HIGHLANDER, CAR.RAV4_TSS2, CAR.COROLLA_TSS2, CAR.LEXUS_ESH_TSS2, CAR.SIENNA] # no resume button press required + +# Toyota/Lexus Safety Sense 2.0 and 2.5 +TSS2_CAR = set([CAR.RAV4_TSS2, CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2, CAR.LEXUS_ES_TSS2, CAR.LEXUS_ESH_TSS2, CAR.RAV4H_TSS2, + CAR.LEXUS_RX_TSS2, CAR.LEXUS_RXH_TSS2, CAR.HIGHLANDER_TSS2, CAR.HIGHLANDERH_TSS2, CAR.PRIUS_TSS2, CAR.CAMRY_TSS2]) + +NO_DSU_CAR = TSS2_CAR | set([CAR.CHR, CAR.CHRH, CAR.CAMRY, CAR.CAMRYH]) + +# no resume button press required +NO_STOP_TIMER_CAR = TSS2_CAR | set([CAR.RAV4H, CAR.HIGHLANDERH, CAR.HIGHLANDER, CAR.SIENNA]) diff --git a/selfdrive/car/vin.py b/selfdrive/car/vin.py new file mode 100755 index 00000000000000..648f4165117ca1 --- /dev/null +++ b/selfdrive/car/vin.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +import traceback + +import cereal.messaging as messaging +from panda.python.uds import FUNCTIONAL_ADDRS +from selfdrive.car.isotp_parallel_query import IsoTpParallelQuery +from selfdrive.swaglog import cloudlog + +VIN_REQUEST = b'\x09\x02' +VIN_RESPONSE = b'\x49\x02\x01' +VIN_UNKNOWN = "0" * 17 + + +def get_vin(logcan, sendcan, bus, timeout=0.1, retry=5, debug=False): + for i in range(retry): + try: + query = IsoTpParallelQuery(sendcan, logcan, bus, FUNCTIONAL_ADDRS, [VIN_REQUEST], [VIN_RESPONSE], functional_addr=True, debug=debug) + for addr, vin in query.get_data(timeout).items(): + return addr[0], vin.decode() + print(f"vin query retry ({i+1}) ...") + except Exception: + cloudlog.warning(f"VIN query exception: {traceback.format_exc()}") + + return 0, VIN_UNKNOWN + + +if __name__ == "__main__": + import time + sendcan = messaging.pub_sock('sendcan') + logcan = messaging.sub_sock('can') + time.sleep(1) + addr, vin = get_vin(logcan, sendcan, 1, debug=False) + print(hex(addr), vin) diff --git a/selfdrive/can/__init__.py b/selfdrive/car/volkswagen/__init__.py similarity index 100% rename from selfdrive/can/__init__.py rename to selfdrive/car/volkswagen/__init__.py diff --git a/selfdrive/car/volkswagen/carcontroller.py b/selfdrive/car/volkswagen/carcontroller.py new file mode 100644 index 00000000000000..5bb5dcc1094e05 --- /dev/null +++ b/selfdrive/car/volkswagen/carcontroller.py @@ -0,0 +1,185 @@ +from cereal import car +from selfdrive.car import apply_std_steer_torque_limits +from selfdrive.car.volkswagen import volkswagencan +from selfdrive.car.volkswagen.values import DBC, CANBUS, MQB_LDW_MESSAGES, BUTTON_STATES, CarControllerParams +from opendbc.can.packer import CANPacker + + +class CarController(): + def __init__(self, dbc_name, CP, VM): + self.apply_steer_last = 0 + + self.packer_pt = CANPacker(DBC[CP.carFingerprint]['pt']) + + self.hcaSameTorqueCount = 0 + self.hcaEnabledFrameCount = 0 + self.graButtonStatesToSend = None + self.graMsgSentCount = 0 + self.graMsgStartFramePrev = 0 + self.graMsgBusCounterPrev = 0 + + self.steer_rate_limited = False + + def update(self, enabled, CS, frame, actuators, visual_alert, audible_alert, leftLaneVisible, rightLaneVisible): + """ Controls thread """ + + P = CarControllerParams + + # Send CAN commands. + can_sends = [] + + #-------------------------------------------------------------------------- + # # + # Prepare HCA_01 Heading Control Assist messages with steering torque. # + # # + #-------------------------------------------------------------------------- + + # The factory camera sends at 50Hz while steering and 1Hz when not. When + # OP is active, Panda filters HCA_01 from the factory camera and OP emits + # HCA_01 at 50Hz. Rate switching creates some confusion in Cabana and + # doesn't seem to add value at this time. The rack will accept HCA_01 at + # 100Hz if we want to control at finer resolution in the future. + if frame % P.HCA_STEP == 0: + + # FAULT AVOIDANCE: HCA must not be enabled at standstill. Also stop + # commanding HCA if there's a fault, so the steering rack recovers. + if enabled and not (CS.out.standstill or CS.steeringFault): + + # FAULT AVOIDANCE: Requested HCA torque must not exceed 3.0 Nm. This + # is inherently handled by scaling to STEER_MAX. The rack doesn't seem + # to care about up/down rate, but we have some evidence it may do its + # own rate limiting, and matching OP helps for accurate tuning. + new_steer = int(round(actuators.steer * P.STEER_MAX)) + apply_steer = apply_std_steer_torque_limits(new_steer, self.apply_steer_last, CS.out.steeringTorque, P) + self.steer_rate_limited = new_steer != apply_steer + + # FAULT AVOIDANCE: HCA must not be enabled for >360 seconds. Sending + # a single frame with HCA disabled is an effective workaround. + if apply_steer == 0: + # We can usually reset the timer for free, just by disabling HCA + # when apply_steer is exactly zero, which happens by chance during + # many steer torque direction changes. This could be expanded with + # a small dead-zone to capture all zero crossings, but not seeing a + # major need at this time. + hcaEnabled = False + self.hcaEnabledFrameCount = 0 + else: + self.hcaEnabledFrameCount += 1 + if self.hcaEnabledFrameCount >= 118 * (100 / P.HCA_STEP): # 118s + # The Kansas I-70 Crosswind Problem: if we truly do need to steer + # in one direction for > 360 seconds, we have to disable HCA for a + # frame while actively steering. Testing shows we can just set the + # disabled flag, and keep sending non-zero torque, which keeps the + # Panda torque rate limiting safety happy. Do so 3x within the 360 + # second window for safety and redundancy. + hcaEnabled = False + self.hcaEnabledFrameCount = 0 + else: + hcaEnabled = True + # FAULT AVOIDANCE: HCA torque must not be static for > 6 seconds. + # This is to detect the sending camera being stuck or frozen. OP + # can trip this on a curve if steering is saturated. Avoid this by + # reducing torque 0.01 Nm for one frame. Do so 3x within the 6 + # second period for safety and redundancy. + if self.apply_steer_last == apply_steer: + self.hcaSameTorqueCount += 1 + if self.hcaSameTorqueCount > 1.9 * (100 / P.HCA_STEP): # 1.9s + apply_steer -= (1, -1)[apply_steer < 0] + self.hcaSameTorqueCount = 0 + else: + self.hcaSameTorqueCount = 0 + + else: + # Continue sending HCA_01 messages, with the enable flags turned off. + hcaEnabled = False + apply_steer = 0 + + self.apply_steer_last = apply_steer + idx = (frame / P.HCA_STEP) % 16 + can_sends.append(volkswagencan.create_mqb_steering_control(self.packer_pt, CANBUS.pt, apply_steer, + idx, hcaEnabled)) + + #-------------------------------------------------------------------------- + # # + # Prepare LDW_02 HUD messages with lane borders, confidence levels, and # + # the LKAS status LED. # + # # + #-------------------------------------------------------------------------- + + # The factory camera emits this message at 10Hz. When OP is active, Panda + # filters LDW_02 from the factory camera and OP emits LDW_02 at 10Hz. + + if frame % P.LDW_STEP == 0: + hcaEnabled = True if enabled and not CS.out.standstill else False + + if visual_alert == car.CarControl.HUDControl.VisualAlert.steerRequired: + hud_alert = MQB_LDW_MESSAGES["laneAssistTakeOverSilent"] + else: + hud_alert = MQB_LDW_MESSAGES["none"] + + can_sends.append(volkswagencan.create_mqb_hud_control(self.packer_pt, CANBUS.pt, hcaEnabled, + CS.out.steeringPressed, hud_alert, leftLaneVisible, + rightLaneVisible)) + + #-------------------------------------------------------------------------- + # # + # Prepare GRA_ACC_01 ACC control messages with button press events. # + # # + #-------------------------------------------------------------------------- + + # The car sends this message at 33hz. OP sends it on-demand only for + # virtual button presses. + # + # First create any virtual button press event needed by openpilot, to sync + # stock ACC with OP disengagement, or to auto-resume from stop. + + if frame > self.graMsgStartFramePrev + P.GRA_VBP_STEP: + if not enabled and CS.out.cruiseState.enabled: + # Cancel ACC if it's engaged with OP disengaged. + self.graButtonStatesToSend = BUTTON_STATES.copy() + self.graButtonStatesToSend["cancel"] = True + elif enabled and CS.out.standstill: + # Blip the Resume button if we're engaged at standstill. + # FIXME: This is a naive implementation, improve with visiond or radar input. + # A subset of MQBs like to "creep" too aggressively with this implementation. + self.graButtonStatesToSend = BUTTON_STATES.copy() + self.graButtonStatesToSend["resumeCruise"] = True + + # OP/Panda can see this message but can't filter it when integrated at the + # R242 LKAS camera. It could do so if integrated at the J533 gateway, but + # we need a generalized solution that works for either. The message is + # counter-protected, so we need to time our transmissions very precisely + # to achieve fast and fault-free switching between message flows accepted + # at the J428 ACC radar. + # + # Example message flow on the bus, frequency of 33Hz (GRA_ACC_STEP): + # + # CAR: 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 + # EON: 3 4 5 6 7 8 9 A B C D E F 0 1 2 GG^ + # + # If OP needs to send a button press, it waits to see a GRA_ACC_01 message + # counter change, and then immediately follows up with the next increment. + # The OP message will be sent within about 1ms of the car's message, which + # is about 2ms before the car's next message is expected. OP sends for an + # arbitrary duration of 16 messages / ~0.5 sec, in lockstep with each new + # message from the car. + # + # Because OP's counter is synced to the car, J428 immediately accepts the + # OP messages as valid. Further messages from the car get discarded as + # duplicates without a fault. When OP stops sending, the extra time gap + # (GG) to the next valid car message is less than 1 * GRA_ACC_STEP. J428 + # tolerates the gap just fine and control returns to the car immediately. + + if CS.graMsgBusCounter != self.graMsgBusCounterPrev: + self.graMsgBusCounterPrev = CS.graMsgBusCounter + if self.graButtonStatesToSend is not None: + if self.graMsgSentCount == 0: + self.graMsgStartFramePrev = frame + idx = (CS.graMsgBusCounter + 1) % 16 + can_sends.append(volkswagencan.create_mqb_acc_buttons_control(self.packer_pt, CANBUS.pt, self.graButtonStatesToSend, CS, idx)) + self.graMsgSentCount += 1 + if self.graMsgSentCount >= P.GRA_VBP_COUNT: + self.graButtonStatesToSend = None + self.graMsgSentCount = 0 + + return can_sends diff --git a/selfdrive/car/volkswagen/carstate.py b/selfdrive/car/volkswagen/carstate.py new file mode 100644 index 00000000000000..a994130929ad15 --- /dev/null +++ b/selfdrive/car/volkswagen/carstate.py @@ -0,0 +1,208 @@ +import numpy as np +from cereal import car +from selfdrive.config import Conversions as CV +from selfdrive.car.interfaces import CarStateBase +from opendbc.can.parser import CANParser +from opendbc.can.can_define import CANDefine +from selfdrive.car.volkswagen.values import DBC, CANBUS, BUTTON_STATES, CarControllerParams + +class CarState(CarStateBase): + def __init__(self, CP): + super().__init__(CP) + can_define = CANDefine(DBC[CP.carFingerprint]['pt']) + self.shifter_values = can_define.dv["Getriebe_11"]['GE_Fahrstufe'] + self.buttonStates = BUTTON_STATES.copy() + + def update(self, pt_cp): + ret = car.CarState.new_message() + # Update vehicle speed and acceleration from ABS wheel speeds. + ret.wheelSpeeds.fl = pt_cp.vl["ESP_19"]['ESP_VL_Radgeschw_02'] * CV.KPH_TO_MS + ret.wheelSpeeds.fr = pt_cp.vl["ESP_19"]['ESP_VR_Radgeschw_02'] * CV.KPH_TO_MS + ret.wheelSpeeds.rl = pt_cp.vl["ESP_19"]['ESP_HL_Radgeschw_02'] * CV.KPH_TO_MS + ret.wheelSpeeds.rr = pt_cp.vl["ESP_19"]['ESP_HR_Radgeschw_02'] * CV.KPH_TO_MS + + ret.vEgoRaw = float(np.mean([ret.wheelSpeeds.fl, ret.wheelSpeeds.fr, ret.wheelSpeeds.rl, ret.wheelSpeeds.rr])) + ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) + + ret.standstill = ret.vEgoRaw < 0.1 + + # Update steering angle, rate, yaw rate, and driver input torque. VW send + # the sign/direction in a separate signal so they must be recombined. + ret.steeringAngle = pt_cp.vl["LWI_01"]['LWI_Lenkradwinkel'] * (1, -1)[int(pt_cp.vl["LWI_01"]['LWI_VZ_Lenkradwinkel'])] + ret.steeringRate = pt_cp.vl["LWI_01"]['LWI_Lenkradw_Geschw'] * (1, -1)[int(pt_cp.vl["LWI_01"]['LWI_VZ_Lenkradwinkel'])] + ret.steeringTorque = pt_cp.vl["EPS_01"]['Driver_Strain'] * (1, -1)[int(pt_cp.vl["EPS_01"]['Driver_Strain_VZ'])] + ret.steeringPressed = abs(ret.steeringTorque) > CarControllerParams.STEER_DRIVER_ALLOWANCE + ret.yawRate = pt_cp.vl["ESP_02"]['ESP_Gierrate'] * (1, -1)[int(pt_cp.vl["ESP_02"]['ESP_VZ_Gierrate'])] * CV.DEG_TO_RAD + + # Update gas, brakes, and gearshift. + ret.gas = pt_cp.vl["Motor_20"]['MO_Fahrpedalrohwert_01'] / 100.0 + ret.gasPressed = ret.gas > 0 + ret.brake = pt_cp.vl["ESP_05"]['ESP_Bremsdruck'] / 250.0 # FIXME: this is pressure in Bar, not sure what OP expects + ret.brakePressed = bool(pt_cp.vl["ESP_05"]['ESP_Fahrer_bremst']) + ret.brakeLights = bool(pt_cp.vl["ESP_05"]['ESP_Status_Bremsdruck']) + + # Update gear and/or clutch position data. + can_gear_shifter = int(pt_cp.vl["Getriebe_11"]['GE_Fahrstufe']) + ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(can_gear_shifter, None)) + + # Update door and trunk/hatch lid open status. + ret.doorOpen = any([pt_cp.vl["Gateway_72"]['ZV_FT_offen'], + pt_cp.vl["Gateway_72"]['ZV_BT_offen'], + pt_cp.vl["Gateway_72"]['ZV_HFS_offen'], + pt_cp.vl["Gateway_72"]['ZV_HBFS_offen'], + pt_cp.vl["Gateway_72"]['ZV_HD_offen']]) + + # Update seatbelt fastened status. + ret.seatbeltUnlatched = pt_cp.vl["Airbag_02"]["AB_Gurtschloss_FA"] != 3 + + # Update driver preference for metric. VW stores many different unit + # preferences, including separate units for for distance vs. speed. + # We use the speed preference for OP. + self.displayMetricUnits = not pt_cp.vl["Einheiten_01"]["KBI_MFA_v_Einheit_02"] + + # Update ACC radar status. + accStatus = pt_cp.vl["TSK_06"]['TSK_Status'] + if accStatus == 2: + # ACC okay and enabled, but not currently engaged + ret.cruiseState.available = True + ret.cruiseState.enabled = False + elif accStatus in [3, 4, 5]: + # ACC okay and enabled, currently engaged and regulating speed (3) or engaged with driver accelerating (4) or overrun (5) + ret.cruiseState.available = True + ret.cruiseState.enabled = True + else: + # ACC okay but disabled (1), or a radar visibility or other fault/disruption (6 or 7) + ret.cruiseState.available = False + ret.cruiseState.enabled = False + + # Update ACC setpoint. When the setpoint is zero or there's an error, the + # radar sends a set-speed of ~90.69 m/s / 203mph. + ret.cruiseState.speed = pt_cp.vl["ACC_02"]['SetSpeed'] + if ret.cruiseState.speed > 90: + ret.cruiseState.speed = 0 + + # Update control button states for turn signals and ACC controls. + self.buttonStates["accelCruise"] = bool(pt_cp.vl["GRA_ACC_01"]['GRA_Tip_Hoch']) + self.buttonStates["decelCruise"] = bool(pt_cp.vl["GRA_ACC_01"]['GRA_Tip_Runter']) + self.buttonStates["cancel"] = bool(pt_cp.vl["GRA_ACC_01"]['GRA_Abbrechen']) + self.buttonStates["setCruise"] = bool(pt_cp.vl["GRA_ACC_01"]['GRA_Tip_Setzen']) + self.buttonStates["resumeCruise"] = bool(pt_cp.vl["GRA_ACC_01"]['GRA_Tip_Wiederaufnahme']) + self.buttonStates["gapAdjustCruise"] = bool(pt_cp.vl["GRA_ACC_01"]['GRA_Verstellung_Zeitluecke']) + ret.leftBlinker = bool(pt_cp.vl["Gateway_72"]['BH_Blinker_li']) + ret.rightBlinker = bool(pt_cp.vl["Gateway_72"]['BH_Blinker_re']) + + # Read ACC hardware button type configuration info that has to pass thru + # to the radar. Ends up being different for steering wheel buttons vs + # third stalk type controls. + self.graHauptschalter = pt_cp.vl["GRA_ACC_01"]['GRA_Hauptschalter'] + self.graTypHauptschalter = pt_cp.vl["GRA_ACC_01"]['GRA_Typ_Hauptschalter'] + self.graButtonTypeInfo = pt_cp.vl["GRA_ACC_01"]['GRA_ButtonTypeInfo'] + self.graTipStufe2 = pt_cp.vl["GRA_ACC_01"]['GRA_Tip_Stufe_2'] + # Pick up the GRA_ACC_01 CAN message counter so we can sync to it for + # later cruise-control button spamming. + self.graMsgBusCounter = pt_cp.vl["GRA_ACC_01"]['COUNTER'] + + # Check to make sure the electric power steering rack is configured to + # accept and respond to HCA_01 messages and has not encountered a fault. + self.steeringFault = not pt_cp.vl["EPS_01"]["HCA_Ready"] + + # Additional safety checks performed in CarInterface. + self.parkingBrakeSet = bool(pt_cp.vl["Kombi_01"]['KBI_Handbremse']) # FIXME: need to include an EPB check as well + ret.espDisabled = pt_cp.vl["ESP_21"]['ESP_Tastung_passiv'] != 0 + + return ret + + @staticmethod + def get_can_parser(CP): + # this function generates lists for signal, messages and initial values + signals = [ + # sig_name, sig_address, default + ("LWI_Lenkradwinkel", "LWI_01", 0), # Absolute steering angle + ("LWI_VZ_Lenkradwinkel", "LWI_01", 0), # Steering angle sign + ("LWI_Lenkradw_Geschw", "LWI_01", 0), # Absolute steering rate + ("LWI_VZ_Lenkradw_Geschw", "LWI_01", 0), # Steering rate sign + ("ESP_VL_Radgeschw_02", "ESP_19", 0), # ABS wheel speed, front left + ("ESP_VR_Radgeschw_02", "ESP_19", 0), # ABS wheel speed, front right + ("ESP_HL_Radgeschw_02", "ESP_19", 0), # ABS wheel speed, rear left + ("ESP_HR_Radgeschw_02", "ESP_19", 0), # ABS wheel speed, rear right + ("ESP_Gierrate", "ESP_02", 0), # Absolute yaw rate + ("ESP_VZ_Gierrate", "ESP_02", 0), # Yaw rate sign + ("ZV_FT_offen", "Gateway_72", 0), # Door open, driver + ("ZV_BT_offen", "Gateway_72", 0), # Door open, passenger + ("ZV_HFS_offen", "Gateway_72", 0), # Door open, rear left + ("ZV_HBFS_offen", "Gateway_72", 0), # Door open, rear right + ("ZV_HD_offen", "Gateway_72", 0), # Trunk or hatch open + ("BH_Blinker_li", "Gateway_72", 0), # Left turn signal on + ("BH_Blinker_re", "Gateway_72", 0), # Right turn signal on + ("GE_Fahrstufe", "Getriebe_11", 0), # Auto trans gear selector position + ("AB_Gurtschloss_FA", "Airbag_02", 0), # Seatbelt status, driver + ("AB_Gurtschloss_BF", "Airbag_02", 0), # Seatbelt status, passenger + ("ESP_Fahrer_bremst", "ESP_05", 0), # Brake pedal pressed + ("ESP_Status_Bremsdruck", "ESP_05", 0), # Brakes applied + ("ESP_Bremsdruck", "ESP_05", 0), # Brake pressure applied + ("MO_Fahrpedalrohwert_01", "Motor_20", 0), # Accelerator pedal value + ("MO_Kuppl_schalter", "Motor_14", 0), # Clutch switch + ("Driver_Strain", "EPS_01", 0), # Absolute driver torque input + ("Driver_Strain_VZ", "EPS_01", 0), # Driver torque input sign + ("HCA_Ready", "EPS_01", 0), # Steering rack HCA support configured + ("ESP_Tastung_passiv", "ESP_21", 0), # Stability control disabled + ("KBI_MFA_v_Einheit_02", "Einheiten_01", 0), # MPH vs KMH speed display + ("KBI_Handbremse", "Kombi_01", 0), # Manual handbrake applied + ("TSK_Status", "TSK_06", 0), # ACC engagement status from drivetrain coordinator + ("TSK_Fahrzeugmasse_02", "Motor_16", 0), # Estimated vehicle mass from drivetrain coordinator + ("ACC_Status_ACC", "ACC_06", 0), # ACC engagement status + ("ACC_Typ", "ACC_06", 0), # ACC type (follow to stop, stop&go) + ("SetSpeed", "ACC_02", 0), # ACC set speed + ("GRA_Hauptschalter", "GRA_ACC_01", 0), # ACC button, on/off + ("GRA_Abbrechen", "GRA_ACC_01", 0), # ACC button, cancel + ("GRA_Tip_Setzen", "GRA_ACC_01", 0), # ACC button, set + ("GRA_Tip_Hoch", "GRA_ACC_01", 0), # ACC button, increase or accel + ("GRA_Tip_Runter", "GRA_ACC_01", 0), # ACC button, decrease or decel + ("GRA_Tip_Wiederaufnahme", "GRA_ACC_01", 0), # ACC button, resume + ("GRA_Verstellung_Zeitluecke", "GRA_ACC_01", 0), # ACC button, time gap adj + ("GRA_Typ_Hauptschalter", "GRA_ACC_01", 0), # ACC main button type + ("GRA_Tip_Stufe_2", "GRA_ACC_01", 0), # unknown related to stalk type + ("GRA_ButtonTypeInfo", "GRA_ACC_01", 0), # unknown related to stalk type + ("COUNTER", "GRA_ACC_01", 0), # GRA_ACC_01 CAN message counter + ] + + checks = [ + # sig_address, frequency + ("LWI_01", 100), # From J500 Steering Assist with integrated sensors + ("EPS_01", 100), # From J500 Steering Assist with integrated sensors + ("ESP_19", 100), # From J104 ABS/ESP controller + ("ESP_05", 50), # From J104 ABS/ESP controller + ("ESP_21", 50), # From J104 ABS/ESP controller + ("ACC_06", 50), # From J428 ACC radar control module + ("Motor_20", 50), # From J623 Engine control module + ("TSK_06", 50), # From J623 Engine control module + ("GRA_ACC_01", 33), # From J??? steering wheel control buttons + ("ACC_02", 17), # From J428 ACC radar control module + ("Getriebe_11", 20), # From J743 Auto transmission control module + ("Gateway_72", 10), # From J533 CAN gateway (aggregated data) + ("Motor_14", 10), # From J623 Engine control module + ("Airbag_02", 5), # From J234 Airbag control module + ("Kombi_01", 2), # From J285 Instrument cluster + ("Motor_16", 2), # From J623 Engine control module + ("Einheiten_01", 1), # From J??? not known if gateway, cluster, or BCM + ] + + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, CANBUS.pt) + + # A single signal is monitored from the camera CAN bus, and then ignored, + # so the presence of CAN traffic can be verified with cam_cp.valid. + + @staticmethod + def get_cam_can_parser(CP): + + signals = [ + # sig_name, sig_address, default + ("Kombi_Lamp_Green", "LDW_02", 0), # Lane Assist status LED + ] + + checks = [ + # sig_address, frequency + ("LDW_02", 10) # From R242 Driver assistance camera + ] + + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, CANBUS.cam) diff --git a/selfdrive/car/volkswagen/interface.py b/selfdrive/car/volkswagen/interface.py new file mode 100644 index 00000000000000..63da6672baed17 --- /dev/null +++ b/selfdrive/car/volkswagen/interface.py @@ -0,0 +1,119 @@ +from cereal import car +from selfdrive.car.volkswagen.values import CAR, BUTTON_STATES +from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint +from selfdrive.car.interfaces import CarInterfaceBase + +GEAR = car.CarState.GearShifter +EventName = car.CarEvent.EventName + + +class CarInterface(CarInterfaceBase): + def __init__(self, CP, CarController, CarState): + super().__init__(CP, CarController, CarState) + + self.displayMetricUnitsPrev = None + self.buttonStatesPrev = BUTTON_STATES.copy() + + @staticmethod + def compute_gb(accel, speed): + return float(accel) / 4.0 + + @staticmethod + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + ret = CarInterfaceBase.get_std_params(candidate, fingerprint) + + # VW port is a community feature, since we don't own one to test + ret.communityFeature = True + + if candidate == CAR.GOLF: + # Set common MQB parameters that will apply globally + ret.carName = "volkswagen" + ret.radarOffCan = True + ret.safetyModel = car.CarParams.SafetyModel.volkswagen + + # Additional common MQB parameters that may be overridden per-vehicle + ret.steerRateCost = 1.0 + ret.steerActuatorDelay = 0.05 # Hopefully all MQB racks are similar here + ret.steerLimitTimer = 0.4 + + ret.lateralTuning.pid.kpBP = [0.] + ret.lateralTuning.pid.kiBP = [0.] + + ret.mass = 1500 + STD_CARGO_KG + ret.wheelbase = 2.64 + ret.centerToFront = ret.wheelbase * 0.45 + ret.steerRatio = 15.6 + ret.lateralTuning.pid.kf = 0.00006 + ret.lateralTuning.pid.kpV = [0.6] + ret.lateralTuning.pid.kiV = [0.2] + tire_stiffness_factor = 1.0 + + ret.enableCamera = True # Stock camera detection doesn't apply to VW + ret.transmissionType = car.CarParams.TransmissionType.automatic + + # TODO: get actual value, for now starting with reasonable value for + # civic and scaling by mass and wheelbase + ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) + + # TODO: start from empirically derived lateral slip stiffness for the civic and scale by + # mass and CG position, so all cars will have approximately similar dyn behaviors + ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront, + tire_stiffness_factor=tire_stiffness_factor) + + return ret + + # returns a car.CarState + def update(self, c, can_strings): + buttonEvents = [] + + # Process the most recent CAN message traffic, and check for validity + # The camera CAN has no signals we use at this time, but we process it + # anyway so we can test connectivity with can_valid + self.cp.update_strings(can_strings) + self.cp_cam.update_strings(can_strings) + + ret = self.CS.update(self.cp) + ret.canValid = self.cp.can_valid and self.cp_cam.can_valid + ret.steeringRateLimited = self.CC.steer_rate_limited if self.CC is not None else False + + # TODO: add a field for this to carState, car interface code shouldn't write params + # Update the device metric configuration to match the car at first startup, + # or if there's been a change. + #if self.CS.displayMetricUnits != self.displayMetricUnitsPrev: + # put_nonblocking("IsMetric", "1" if self.CS.displayMetricUnits else "0") + + # Check for and process state-change events (button press or release) from + # the turn stalk switch or ACC steering wheel/control stalk buttons. + for button in self.CS.buttonStates: + if self.CS.buttonStates[button] != self.buttonStatesPrev[button]: + be = car.CarState.ButtonEvent.new_message() + be.type = button + be.pressed = self.CS.buttonStates[button] + buttonEvents.append(be) + + events = self.create_common_events(ret, extra_gears=[GEAR.eco, GEAR.sport]) + + # Vehicle health and operation safety checks + if self.CS.parkingBrakeSet: + events.add(EventName.parkBrake) + if self.CS.steeringFault: + events.add(EventName.steerTempUnavailable) + + ret.events = events.to_msg() + ret.buttonEvents = buttonEvents + + # update previous car states + self.displayMetricUnitsPrev = self.CS.displayMetricUnits + self.buttonStatesPrev = self.CS.buttonStates.copy() + + self.CS.out = ret.as_reader() + return self.CS.out + + def apply(self, c): + can_sends = self.CC.update(c.enabled, self.CS, self.frame, c.actuators, + c.hudControl.visualAlert, + c.hudControl.audibleAlert, + c.hudControl.leftLaneVisible, + c.hudControl.rightLaneVisible) + self.frame += 1 + return can_sends diff --git a/selfdrive/car/volkswagen/radar_interface.py b/selfdrive/car/volkswagen/radar_interface.py new file mode 100644 index 00000000000000..b2f76511360320 --- /dev/null +++ b/selfdrive/car/volkswagen/radar_interface.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python3 +from selfdrive.car.interfaces import RadarInterfaceBase + +class RadarInterface(RadarInterfaceBase): + pass diff --git a/selfdrive/car/volkswagen/values.py b/selfdrive/car/volkswagen/values.py new file mode 100644 index 00000000000000..d99d7810261247 --- /dev/null +++ b/selfdrive/car/volkswagen/values.py @@ -0,0 +1,60 @@ +# flake8: noqa + +from selfdrive.car import dbc_dict + +class CarControllerParams: + HCA_STEP = 2 # HCA_01 message frequency 50Hz + LDW_STEP = 10 # LDW_02 message frequency 10Hz + GRA_ACC_STEP = 3 # GRA_ACC_01 message frequency 33Hz + + GRA_VBP_STEP = 100 # Send ACC virtual button presses once a second + GRA_VBP_COUNT = 16 # Send VBP messages for ~0.5s (GRA_ACC_STEP * 16) + + # Observed documented MQB limits: 3.00 Nm max, rate of change 5.00 Nm/sec. + # Limiting rate-of-change based on real-world testing and Comma's safety + # requirements for minimum time to lane departure. + STEER_MAX = 300 # Max heading control assist torque 3.00 Nm + STEER_DELTA_UP = 4 # Max HCA reached in 1.50s (STEER_MAX / (50Hz * 1.50)) + STEER_DELTA_DOWN = 10 # Min HCA reached in 0.60s (STEER_MAX / (50Hz * 0.60)) + STEER_DRIVER_ALLOWANCE = 80 + STEER_DRIVER_MULTIPLIER = 3 # weight driver torque heavily + STEER_DRIVER_FACTOR = 1 # from dbc + +class CANBUS: + pt = 0 + cam = 2 + +BUTTON_STATES = { + "accelCruise": False, + "decelCruise": False, + "cancel": False, + "setCruise": False, + "resumeCruise": False, + "gapAdjustCruise": False +} + +MQB_LDW_MESSAGES = { + "none": 0, # Nothing to display + "laneAssistUnavailChime": 1, # "Lane Assist currently not available." with chime + "laneAssistUnavailNoSensorChime": 3, # "Lane Assist not available. No sensor view." with chime + "laneAssistTakeOverUrgent": 4, # "Lane Assist: Please Take Over Steering" with urgent beep + "emergencyAssistUrgent": 6, # "Emergency Assist: Please Take Over Steering" with urgent beep + "laneAssistTakeOverChime": 7, # "Lane Assist: Please Take Over Steering" with chime + "laneAssistTakeOverSilent": 8, # "Lane Assist: Please Take Over Steering" silent + "emergencyAssistChangingLanes": 9, # "Emergency Assist: Changing lanes..." with urgent beep + "laneAssistDeactivated": 10, # "Lane Assist deactivated." silent with persistent icon afterward +} + +class CAR: + GOLF = "VOLKSWAGEN GOLF" + +FINGERPRINTS = { + CAR.GOLF: [ + # 76b83eb0245de90e|2019-10-21--17-40-42 - jyoung8607 car + {64: 8, 134: 8, 159: 8, 173: 8, 178: 8, 253: 8, 257: 8, 260: 8, 262: 8, 264: 8, 278: 8, 279: 8, 283: 8, 286: 8, 288: 8, 289: 8, 290: 8, 294: 8, 299: 8, 302: 8, 346: 8, 385: 8, 418: 8, 427: 8, 668: 8, 679: 8, 681: 8, 695: 8, 779: 8, 780: 8, 783: 8, 792: 8, 795: 8, 804: 8, 806: 8, 807: 8, 808: 8, 809: 8, 870: 8, 896: 8, 897: 8, 898: 8, 901: 8, 917: 8, 919: 8, 949: 8, 958: 8, 960: 4, 981: 8, 987: 8, 988: 8, 991: 8, 997: 8, 1000: 8, 1019: 8, 1120: 8, 1122: 8, 1123: 8, 1124: 8, 1153: 8, 1162: 8, 1175: 8, 1312: 8, 1385: 8, 1413: 8, 1440: 5, 1514: 8, 1515: 8, 1520: 8, 1600: 8, 1601: 8, 1603: 8, 1605: 8, 1624: 8, 1626: 8, 1629: 8, 1631: 8, 1646: 8, 1648: 8, 1712: 6, 1714: 8, 1716: 8, 1717: 8, 1719: 8, 1720: 8, 1721: 8 + }], +} + +DBC = { + CAR.GOLF: dbc_dict('vw_mqb_2010', None), +} diff --git a/selfdrive/car/volkswagen/volkswagencan.py b/selfdrive/car/volkswagen/volkswagencan.py new file mode 100644 index 00000000000000..3cd47a0957ee12 --- /dev/null +++ b/selfdrive/car/volkswagen/volkswagencan.py @@ -0,0 +1,51 @@ +# CAN controls for MQB platform Volkswagen, Audi, Skoda and SEAT. +# PQ35/PQ46/NMS, and any future MLB, to come later. + +def create_mqb_steering_control(packer, bus, apply_steer, idx, lkas_enabled): + values = { + "SET_ME_0X3": 0x3, + "Assist_Torque": abs(apply_steer), + "Assist_Requested": lkas_enabled, + "Assist_VZ": 1 if apply_steer < 0 else 0, + "HCA_Available": 1, + "HCA_Standby": not lkas_enabled, + "HCA_Active": lkas_enabled, + "SET_ME_0XFE": 0xFE, + "SET_ME_0X07": 0x07, + } + return packer.make_can_msg("HCA_01", bus, values, idx) + +def create_mqb_hud_control(packer, bus, hca_enabled, steering_pressed, hud_alert, leftLaneVisible, rightLaneVisible): + + if hca_enabled: + leftlanehud = 3 if leftLaneVisible else 1 + rightlanehud = 3 if rightLaneVisible else 1 + else: + leftlanehud = 2 if leftLaneVisible else 1 + rightlanehud = 2 if rightLaneVisible else 1 + + values = { + "LDW_Unknown": 2, # FIXME: possible speed or attention relationship + "Kombi_Lamp_Orange": 1 if hca_enabled and steering_pressed else 0, + "Kombi_Lamp_Green": 1 if hca_enabled and not steering_pressed else 0, + "Left_Lane_Status": leftlanehud, + "Right_Lane_Status": rightlanehud, + "Alert_Message": hud_alert, + } + return packer.make_can_msg("LDW_02", bus, values) + +def create_mqb_acc_buttons_control(packer, bus, buttonStatesToSend, CS, idx): + values = { + "GRA_Hauptschalter": CS.graHauptschalter, + "GRA_Abbrechen": buttonStatesToSend["cancel"], + "GRA_Tip_Setzen": buttonStatesToSend["setCruise"], + "GRA_Tip_Hoch": buttonStatesToSend["accelCruise"], + "GRA_Tip_Runter": buttonStatesToSend["decelCruise"], + "GRA_Tip_Wiederaufnahme": buttonStatesToSend["resumeCruise"], + "GRA_Verstellung_Zeitluecke": 3 if buttonStatesToSend["gapAdjustCruise"] else 0, + "GRA_Typ_Hauptschalter": CS.graTypHauptschalter, + "GRA_Codierung": 2, + "GRA_Tip_Stufe_2": CS.graTipStufe2, + "GRA_ButtonTypeInfo": CS.graButtonTypeInfo + } + return packer.make_can_msg("GRA_ACC_01", bus, values, idx) diff --git a/selfdrive/clocksd/.gitignore b/selfdrive/clocksd/.gitignore new file mode 100644 index 00000000000000..a6d841d65ea4f0 --- /dev/null +++ b/selfdrive/clocksd/.gitignore @@ -0,0 +1 @@ +clocksd diff --git a/selfdrive/clocksd/SConscript b/selfdrive/clocksd/SConscript new file mode 100644 index 00000000000000..d1cf13e9e8428a --- /dev/null +++ b/selfdrive/clocksd/SConscript @@ -0,0 +1,2 @@ +Import('env', 'common', 'cereal', 'messaging') +env.Program('clocksd.cc', LIBS=[common, cereal, messaging, 'capnp', 'zmq', 'kj']) diff --git a/selfdrive/clocksd/clocksd.cc b/selfdrive/clocksd/clocksd.cc new file mode 100644 index 00000000000000..d9fa9eda36a864 --- /dev/null +++ b/selfdrive/clocksd/clocksd.cc @@ -0,0 +1,83 @@ +#include +#include + +#include +#include +#include +#include +#include + +#include +#include "messaging.hpp" +#include "common/timing.h" + +// Apple doesn't have timerfd +#ifndef __APPLE__ +#include +#endif + +#ifdef QCOM +namespace { + int64_t arm_cntpct() { + int64_t v; + asm volatile("mrs %0, cntpct_el0" : "=r"(v)); + return v; + } +} +#endif + +int main() { + setpriority(PRIO_PROCESS, 0, -13); + + PubMaster pm({"clocks"}); + +#ifndef __APPLE__ + int timerfd = timerfd_create(CLOCK_BOOTTIME, 0); + assert(timerfd >= 0); + + struct itimerspec spec = {0}; + spec.it_interval.tv_sec = 1; + spec.it_interval.tv_nsec = 0; + spec.it_value.tv_sec = 1; + spec.it_value.tv_nsec = 0; + + int err = timerfd_settime(timerfd, 0, &spec, 0); + assert(err == 0); + + uint64_t expirations = 0; + while ((err = read(timerfd, &expirations, sizeof(expirations)))) { + if (err < 0) break; +#else + // Just run at 1Hz on apple + while (true){ + std::this_thread::sleep_for(std::chrono::seconds(1)); +#endif + + uint64_t boottime = nanos_since_boot(); + uint64_t monotonic = nanos_monotonic(); + uint64_t monotonic_raw = nanos_monotonic_raw(); + uint64_t wall_time = nanos_since_epoch(); + +#ifdef QCOM + uint64_t modem_uptime_v = arm_cntpct() / 19200ULL; // 19.2 mhz clock +#endif + + MessageBuilder msg; + auto clocks = msg.initEvent().initClocks(); + + clocks.setBootTimeNanos(boottime); + clocks.setMonotonicNanos(monotonic); + clocks.setMonotonicRawNanos(monotonic_raw); + clocks.setWallTimeNanos(wall_time); +#ifdef QCOM + clocks.setModemUptimeMillis(modem_uptime_v); +#endif + + pm.send("clocks", msg); + } + +#ifndef __APPLE__ + close(timerfd); +#endif + return 0; +} diff --git a/selfdrive/common/SConscript b/selfdrive/common/SConscript new file mode 100644 index 00000000000000..fdca02e8343b34 --- /dev/null +++ b/selfdrive/common/SConscript @@ -0,0 +1,43 @@ +Import('env', 'arch', 'SHARED', 'QCOM_REPLAY') + +if SHARED: + fxn = env.SharedLibrary +else: + fxn = env.Library + +common_libs = ['params.cc', 'swaglog.cc', 'util.c', 'cqueue.c', 'gpio.cc', 'i2c.cc'] + +_common = fxn('common', common_libs, LIBS="json11") +_visionipc = fxn('visionipc', ['visionipc.c', 'ipc.c']) + +files = [ + 'buffering.c', + 'clutil.cc', + 'efd.c', + 'glutil.c', + 'visionimg.cc', +] + +if arch == "aarch64": + files += [ + 'framebuffer.cc', + 'touch.c', + ] + if QCOM_REPLAY: + files += ['visionbuf_cl.c'] + else: + files += ['visionbuf_ion.c'] + _gpu_libs = ['gui', 'adreno_utils'] +elif arch == "larch64": + files += [ + 'visionbuf_ion.c', + ] + _gpu_libs = ['GL'] +else: + files += [ + 'visionbuf_cl.c', + ] + _gpu_libs = ["GL"] + +_gpucommon = fxn('gpucommon', files, LIBS=_gpu_libs) +Export('_common', '_visionipc', '_gpucommon', '_gpu_libs') diff --git a/selfdrive/common/buffering.c b/selfdrive/common/buffering.c index 9cbb1b86e0df11..bba2e82ab97ebd 100644 --- a/selfdrive/common/buffering.c +++ b/selfdrive/common/buffering.c @@ -70,7 +70,7 @@ void tbuffer_dispatch(TBuffer *tb, int idx) { efd_write(tb->efd); pthread_cond_signal(&tb->cv); - pthread_mutex_unlock(&tb->lock); + pthread_mutex_unlock(&tb->lock); } int tbuffer_acquire(TBuffer *tb) { @@ -344,7 +344,7 @@ void pool_push(Pool *s, int idx) { for (int i=0; iqueues[i]; if (!c->inited) continue; - + pthread_mutex_lock(&c->lock); if (((c->head+1) % c->num) == c->tail) { // queue is full. skip for now diff --git a/selfdrive/common/cereal.mk b/selfdrive/common/cereal.mk deleted file mode 100644 index ed05efc08caa3e..00000000000000 --- a/selfdrive/common/cereal.mk +++ /dev/null @@ -1,38 +0,0 @@ -UNAME_M ?= $(shell uname -m) -UNAME_S ?= $(shell uname -s) - -ifeq ($(UNAME_S),Darwin) -CEREAL_CFLAGS = -I$(PHONELIBS)/capnp-c/include -CEREAL_CXXFLAGS = -I$(PHONELIBS)/capnp-cpp/mac/include -CEREAL_LIBS = $(PHONELIBS)/capnp-cpp/mac/lib/libcapnp.a \ - $(PHONELIBS)/capnp-cpp/mac/lib/libkj.a \ - $(PHONELIBS)/capnp-c/mac/lib/libcapnp_c.a - -else ifeq ($(UNAME_M),x86_64) -CEREAL_CFLAGS = -I$(PHONELIBS)/capnp-c/include -CEREAL_CXXFLAGS = -I$(PHONELIBS)/capnp-cpp/include -ifeq ($(CEREAL_LIBS),) - CEREAL_LIBS = -L$(PHONELIBS)/capnp-cpp/x64/lib/ \ - -L$(PHONELIBS)/capnp-c/x64/lib/ \ - -l:libcapnp.a -l:libkj.a -l:libcapnp_c.a -endif - -else - -#CEREAL_CXXFLAGS = -I$(PHONELIBS)/capnp-cpp/include -ifeq ($(CEREAL_LIBS),) - CEREAL_LIBS = -l:libcapn.a -l:libcapnp.a -l:libkj.a -endif -endif - -CEREAL_OBJS = ../../cereal/gen/c/log.capnp.o ../../cereal/gen/c/car.capnp.o - -log.capnp.o: ../../cereal/gen/cpp/log.capnp.c++ - @echo "[ CXX ] $@" - $(CXX) $(CXXFLAGS) $(CEREAL_CXXFLAGS) \ - -c -o '$@' '$<' - -car.capnp.o: ../../cereal/gen/cpp/car.capnp.c++ - @echo "[ CXX ] $@" - $(CXX) $(CXXFLAGS) $(CEREAL_CXXFLAGS) \ - -c -o '$@' '$<' diff --git a/selfdrive/common/clutil.cc b/selfdrive/common/clutil.cc new file mode 100644 index 00000000000000..45767fc508dc5c --- /dev/null +++ b/selfdrive/common/clutil.cc @@ -0,0 +1,185 @@ +#include "clutil.h" +#include +#include +#include +#include +#include +#include +#include +#include "util.h" +#include "utilpp.h" + +namespace { // helper functions + +template +std::string get_info(Func get_info_func, Id id, Name param_name) { + size_t size = 0; + CL_CHECK(get_info_func(id, param_name, 0, NULL, &size)); + std::string info(size, '\0'); + CL_CHECK(get_info_func(id, param_name, size, info.data(), NULL)); + return info; +} +inline std::string get_platform_info(cl_platform_id id, cl_platform_info name) { return get_info(&clGetPlatformInfo, id, name); } +inline std::string get_device_info(cl_device_id id, cl_device_info name) { return get_info(&clGetDeviceInfo, id, name); } + +void cl_print_info(cl_platform_id platform, cl_device_id device) { + size_t work_group_size = 0; + cl_device_type device_type = 0; + clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(work_group_size), &work_group_size, NULL); + clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(device_type), &device_type, NULL); + const char *type_str = "Other..."; + switch (device_type) { + case CL_DEVICE_TYPE_CPU: type_str ="CL_DEVICE_TYPE_CPU"; break; + case CL_DEVICE_TYPE_GPU: type_str = "CL_DEVICE_TYPE_GPU"; break; + case CL_DEVICE_TYPE_ACCELERATOR: type_str = "CL_DEVICE_TYPE_ACCELERATOR"; break; + } + + std::cout << "vendor: " << get_platform_info(platform, CL_PLATFORM_VENDOR) << std::endl + << "platform version: " << get_platform_info(platform, CL_PLATFORM_VERSION) << std::endl + << "profile: " << get_platform_info(platform, CL_PLATFORM_PROFILE) << std::endl + << "extensions: " << get_platform_info(platform, CL_PLATFORM_EXTENSIONS) << std::endl + << "name :" << get_device_info(device, CL_DEVICE_NAME) << std::endl + << "device version :" << get_device_info(device, CL_DEVICE_VERSION) << std::endl + << "max work group size :" << work_group_size << std::endl + << "type = " << device_type << " = " << type_str << std::endl; +} + +void cl_print_build_errors(cl_program program, cl_device_id device) { + cl_build_status status; + clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS, sizeof(status), &status, NULL); + size_t log_size; + clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size); + std::string log(log_size, '\0'); + clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, log_size, &log[0], NULL); + + std::cout << "build failed; status=" << status << ", log:" << std::endl << log << std::endl; +} + +} // namespace + +cl_device_id cl_get_device_id(cl_device_type device_type) { + cl_uint num_platforms = 0; + CL_CHECK(clGetPlatformIDs(0, NULL, &num_platforms)); + std::unique_ptr platform_ids = std::make_unique(num_platforms); + CL_CHECK(clGetPlatformIDs(num_platforms, &platform_ids[0], NULL)); + + for (size_t i = 0; i < num_platforms; ++i) { + std::cout << "platform[" << i << "] CL_PLATFORM_NAME: " << get_platform_info(platform_ids[i], CL_PLATFORM_NAME) << std::endl; + // Get first device + if (cl_device_id device_id = NULL; clGetDeviceIDs(platform_ids[i], device_type, 1, &device_id, NULL) == 0 && device_id) { + cl_print_info(platform_ids[i], device_id); + return device_id; + } + } + std::cout << "No valid openCL platform found" << std::endl; + assert(0); + return nullptr; +} + +cl_program cl_program_from_file(cl_context ctx, cl_device_id device_id, const char* path, const char* args) { + std::string src = util::read_file(path); + assert(src.length() > 0); + cl_program prg = CL_CHECK_ERR(clCreateProgramWithSource(ctx, 1, (const char*[]){src.c_str()}, NULL, &err)); + if (int err = clBuildProgram(prg, 1, &device_id, args, NULL, NULL); err != 0) { + cl_print_build_errors(prg, device_id); + assert(0); + } + return prg; +} + +// Given a cl code and return a string represenation +#define CL_ERR_TO_STR(err) case err: return #err +const char* cl_get_error_string(int err) { + switch (err) { + CL_ERR_TO_STR(CL_SUCCESS); + CL_ERR_TO_STR(CL_DEVICE_NOT_FOUND); + CL_ERR_TO_STR(CL_DEVICE_NOT_AVAILABLE); + CL_ERR_TO_STR(CL_COMPILER_NOT_AVAILABLE); + CL_ERR_TO_STR(CL_MEM_OBJECT_ALLOCATION_FAILURE); + CL_ERR_TO_STR(CL_OUT_OF_RESOURCES); + CL_ERR_TO_STR(CL_OUT_OF_HOST_MEMORY); + CL_ERR_TO_STR(CL_PROFILING_INFO_NOT_AVAILABLE); + CL_ERR_TO_STR(CL_MEM_COPY_OVERLAP); + CL_ERR_TO_STR(CL_IMAGE_FORMAT_MISMATCH); + CL_ERR_TO_STR(CL_IMAGE_FORMAT_NOT_SUPPORTED); + CL_ERR_TO_STR(CL_MAP_FAILURE); + CL_ERR_TO_STR(CL_MISALIGNED_SUB_BUFFER_OFFSET); + CL_ERR_TO_STR(CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST); + CL_ERR_TO_STR(CL_COMPILE_PROGRAM_FAILURE); + CL_ERR_TO_STR(CL_LINKER_NOT_AVAILABLE); + CL_ERR_TO_STR(CL_LINK_PROGRAM_FAILURE); + CL_ERR_TO_STR(CL_DEVICE_PARTITION_FAILED); + CL_ERR_TO_STR(CL_KERNEL_ARG_INFO_NOT_AVAILABLE); + CL_ERR_TO_STR(CL_INVALID_VALUE); + CL_ERR_TO_STR(CL_INVALID_DEVICE_TYPE); + CL_ERR_TO_STR(CL_INVALID_PLATFORM); + CL_ERR_TO_STR(CL_INVALID_DEVICE); + CL_ERR_TO_STR(CL_INVALID_CONTEXT); + CL_ERR_TO_STR(CL_INVALID_QUEUE_PROPERTIES); + CL_ERR_TO_STR(CL_INVALID_COMMAND_QUEUE); + CL_ERR_TO_STR(CL_INVALID_HOST_PTR); + CL_ERR_TO_STR(CL_INVALID_MEM_OBJECT); + CL_ERR_TO_STR(CL_INVALID_IMAGE_FORMAT_DESCRIPTOR); + CL_ERR_TO_STR(CL_INVALID_IMAGE_SIZE); + CL_ERR_TO_STR(CL_INVALID_SAMPLER); + CL_ERR_TO_STR(CL_INVALID_BINARY); + CL_ERR_TO_STR(CL_INVALID_BUILD_OPTIONS); + CL_ERR_TO_STR(CL_INVALID_PROGRAM); + CL_ERR_TO_STR(CL_INVALID_PROGRAM_EXECUTABLE); + CL_ERR_TO_STR(CL_INVALID_KERNEL_NAME); + CL_ERR_TO_STR(CL_INVALID_KERNEL_DEFINITION); + CL_ERR_TO_STR(CL_INVALID_KERNEL); + CL_ERR_TO_STR(CL_INVALID_ARG_INDEX); + CL_ERR_TO_STR(CL_INVALID_ARG_VALUE); + CL_ERR_TO_STR(CL_INVALID_ARG_SIZE); + CL_ERR_TO_STR(CL_INVALID_KERNEL_ARGS); + CL_ERR_TO_STR(CL_INVALID_WORK_DIMENSION); + CL_ERR_TO_STR(CL_INVALID_WORK_GROUP_SIZE); + CL_ERR_TO_STR(CL_INVALID_WORK_ITEM_SIZE); + CL_ERR_TO_STR(CL_INVALID_GLOBAL_OFFSET); + CL_ERR_TO_STR(CL_INVALID_EVENT_WAIT_LIST); + CL_ERR_TO_STR(CL_INVALID_EVENT); + CL_ERR_TO_STR(CL_INVALID_OPERATION); + CL_ERR_TO_STR(CL_INVALID_GL_OBJECT); + CL_ERR_TO_STR(CL_INVALID_BUFFER_SIZE); + CL_ERR_TO_STR(CL_INVALID_MIP_LEVEL); + CL_ERR_TO_STR(CL_INVALID_GLOBAL_WORK_SIZE); + CL_ERR_TO_STR(CL_INVALID_PROPERTY); + CL_ERR_TO_STR(CL_INVALID_IMAGE_DESCRIPTOR); + CL_ERR_TO_STR(CL_INVALID_COMPILER_OPTIONS); + CL_ERR_TO_STR(CL_INVALID_LINKER_OPTIONS); + CL_ERR_TO_STR(CL_INVALID_DEVICE_PARTITION_COUNT); + case -69: return "CL_INVALID_PIPE_SIZE"; + case -70: return "CL_INVALID_DEVICE_QUEUE"; + case -71: return "CL_INVALID_SPEC_ID"; + case -72: return "CL_MAX_SIZE_RESTRICTION_EXCEEDED"; + case -1002: return "CL_INVALID_D3D10_DEVICE_KHR"; + case -1003: return "CL_INVALID_D3D10_RESOURCE_KHR"; + case -1004: return "CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHR"; + case -1005: return "CL_D3D10_RESOURCE_NOT_ACQUIRED_KHR"; + case -1006: return "CL_INVALID_D3D11_DEVICE_KHR"; + case -1007: return "CL_INVALID_D3D11_RESOURCE_KHR"; + case -1008: return "CL_D3D11_RESOURCE_ALREADY_ACQUIRED_KHR"; + case -1009: return "CL_D3D11_RESOURCE_NOT_ACQUIRED_KHR"; + case -1010: return "CL_INVALID_DX9_MEDIA_ADAPTER_KHR"; + case -1011: return "CL_INVALID_DX9_MEDIA_SURFACE_KHR"; + case -1012: return "CL_DX9_MEDIA_SURFACE_ALREADY_ACQUIRED_KHR"; + case -1013: return "CL_DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR"; + case -1093: return "CL_INVALID_EGL_OBJECT_KHR"; + case -1092: return "CL_EGL_RESOURCE_NOT_ACQUIRED_KHR"; + case -1001: return "CL_PLATFORM_NOT_FOUND_KHR"; + case -1057: return "CL_DEVICE_PARTITION_FAILED_EXT"; + case -1058: return "CL_INVALID_PARTITION_COUNT_EXT"; + case -1059: return "CL_INVALID_PARTITION_NAME_EXT"; + case -1094: return "CL_INVALID_ACCELERATOR_INTEL"; + case -1095: return "CL_INVALID_ACCELERATOR_TYPE_INTEL"; + case -1096: return "CL_INVALID_ACCELERATOR_DESCRIPTOR_INTEL"; + case -1097: return "CL_ACCELERATOR_TYPE_NOT_SUPPORTED_INTEL"; + case -1000: return "CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR"; + case -1098: return "CL_INVALID_VA_API_MEDIA_ADAPTER_INTEL"; + case -1099: return "CL_INVALID_VA_API_MEDIA_SURFACE_INTEL"; + case -1100: return "CL_VA_API_MEDIA_SURFACE_ALREADY_ACQUIRED_INTEL"; + case -1101: return "CL_VA_API_MEDIA_SURFACE_NOT_ACQUIRED_INTEL"; + default: return "CL_UNKNOWN_ERROR"; + } +} diff --git a/selfdrive/common/clutil.h b/selfdrive/common/clutil.h new file mode 100644 index 00000000000000..793d6e7f35ff1f --- /dev/null +++ b/selfdrive/common/clutil.h @@ -0,0 +1,36 @@ +#pragma once + +#include +#include +#include + +#ifdef __APPLE__ +#include +#else +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define CL_CHECK(_expr) \ + do { \ + assert(CL_SUCCESS == _expr); \ + } while (0) + +#define CL_CHECK_ERR(_expr) \ + ({ \ + cl_int err = CL_INVALID_VALUE; \ + __typeof__(_expr) _ret = _expr; \ + assert(_ret&& err == CL_SUCCESS); \ + _ret; \ + }) + +cl_device_id cl_get_device_id(cl_device_type device_type); +cl_program cl_program_from_file(cl_context ctx, cl_device_id device_id, const char* path, const char* args); +const char* cl_get_error_string(int err); + +#ifdef __cplusplus +} +#endif diff --git a/selfdrive/common/framebuffer.cc b/selfdrive/common/framebuffer.cc index 757c2a1ead46f0..30ef7ae8ea2319 100644 --- a/selfdrive/common/framebuffer.cc +++ b/selfdrive/common/framebuffer.cc @@ -1,4 +1,4 @@ - +#include "util.h" #include #include #include @@ -13,8 +13,7 @@ #include #include -#define BACKLIGHT_CONTROL "/sys/class/leds/lcd-backlight/brightness" -#define BACKLIGHT_LEVEL "205" +#define BACKLIGHT_LEVEL 205 using namespace android; @@ -33,13 +32,23 @@ struct FramebufferState { EGLContext context; }; +extern "C" void framebuffer_swap(FramebufferState *s) { + eglSwapBuffers(s->display, s->surface); + assert(glGetError() == GL_NO_ERROR); +} + +extern "C" bool set_brightness(int brightness) { + char bright[64]; + snprintf(bright, sizeof(bright), "%d", brightness); + return 0 == write_file("/sys/class/leds/lcd-backlight/brightness", bright, strlen(bright)); +} + extern "C" void framebuffer_set_power(FramebufferState *s, int mode) { SurfaceComposerClient::setDisplayPowerMode(s->dtoken, mode); } extern "C" FramebufferState* framebuffer_init( const char* name, int32_t layer, int alpha, - EGLDisplay *out_display, EGLSurface *out_surface, int *out_w, int *out_h) { status_t status; int success; @@ -90,6 +99,9 @@ extern "C" FramebufferState* framebuffer_init( EGL_DEPTH_SIZE, 0, EGL_STENCIL_SIZE, 8, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR, + // enable MSAA + EGL_SAMPLE_BUFFERS, 1, + EGL_SAMPLES, 4, EGL_NONE, }; @@ -100,7 +112,7 @@ extern "C" FramebufferState* framebuffer_init( assert(success); printf("egl version %d.%d\n", s->egl_major, s->egl_minor); - + EGLint num_configs; success = eglChooseConfig(s->display, attribs, &s->config, 1, &num_configs); assert(success); @@ -125,15 +137,8 @@ extern "C" FramebufferState* framebuffer_init( printf("gl version %s\n", glGetString(GL_VERSION)); + set_brightness(BACKLIGHT_LEVEL); - // set brightness - int brightness_fd = open(BACKLIGHT_CONTROL, O_RDWR); - const char brightness_level[] = BACKLIGHT_LEVEL; - write(brightness_fd, brightness_level, strlen(brightness_level)); - - - if (out_display) *out_display = s->display; - if (out_surface) *out_surface = s->surface; if (out_w) *out_w = w; if (out_h) *out_h = h; diff --git a/selfdrive/common/framebuffer.h b/selfdrive/common/framebuffer.h index 6091eebce50780..45053bbb14a5bb 100644 --- a/selfdrive/common/framebuffer.h +++ b/selfdrive/common/framebuffer.h @@ -1,7 +1,4 @@ -#ifndef FRAMEBUFFER_H -#define FRAMEBUFFER_H - -#include +#pragma once #ifdef __cplusplus extern "C" { @@ -11,10 +8,11 @@ typedef struct FramebufferState FramebufferState; FramebufferState* framebuffer_init( const char* name, int32_t layer, int alpha, - EGLDisplay *out_display, EGLSurface *out_surface, int *out_w, int *out_h); void framebuffer_set_power(FramebufferState *s, int mode); +void framebuffer_swap(FramebufferState *s); +bool set_brightness(int brightness); /* Display power modes */ enum { @@ -42,9 +40,6 @@ enum { HWC_POWER_MODE_DOZE_SUSPEND = 3, }; - #ifdef __cplusplus } #endif - -#endif diff --git a/selfdrive/common/glutil.c b/selfdrive/common/glutil.c index d118dd8af68451..e208891e2bb6a5 100644 --- a/selfdrive/common/glutil.c +++ b/selfdrive/common/glutil.c @@ -1,8 +1,6 @@ #include #include -#include - #include "glutil.h" GLuint load_shader(GLenum shaderType, const char *src) { diff --git a/selfdrive/common/glutil.h b/selfdrive/common/glutil.h index 68d6cfa630d3c1..d907b09e78ba12 100644 --- a/selfdrive/common/glutil.h +++ b/selfdrive/common/glutil.h @@ -1,8 +1,21 @@ #ifndef COMMON_GLUTIL_H #define COMMON_GLUTIL_H -#include +#ifdef __APPLE__ + #include +#else + #include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + GLuint load_shader(GLenum shaderType, const char *src); GLuint load_program(const char *vert_src, const char *frag_src); +#ifdef __cplusplus +} +#endif + #endif diff --git a/selfdrive/common/gpio.cc b/selfdrive/common/gpio.cc new file mode 100644 index 00000000000000..8a72388d468ea0 --- /dev/null +++ b/selfdrive/common/gpio.cc @@ -0,0 +1,29 @@ +#include "gpio.h" +#include "util.h" +#include +#include +#include + +// We assume that all pins have already been exported on boot, +// and that we have permission to write to them. + +int gpio_init(int pin_nr, bool output){ + char pin_dir_path[50]; + int pin_dir_path_len = snprintf(pin_dir_path, sizeof(pin_dir_path), + "/sys/class/gpio/gpio%d/direction", pin_nr); + if(pin_dir_path_len <= 0){ + return -1; + } + const char *value = output ? "out" : "in"; + return write_file(pin_dir_path, (void*)value, strlen(value)); +} + +int gpio_set(int pin_nr, bool high){ + char pin_val_path[50]; + int pin_val_path_len = snprintf(pin_val_path, sizeof(pin_val_path), + "/sys/class/gpio/gpio%d/value", pin_nr); + if(pin_val_path_len <= 0){ + return -1; + } + return write_file(pin_val_path, (void*)(high ? "1" : "0"), 1); +} diff --git a/selfdrive/common/gpio.h b/selfdrive/common/gpio.h new file mode 100644 index 00000000000000..479b4f7e066e9e --- /dev/null +++ b/selfdrive/common/gpio.h @@ -0,0 +1,35 @@ +#ifndef GPIO_H +#define GPIO_H + +#include + +// Pin definitions +#ifdef QCOM2 + #define GPIO_HUB_RST_N 30 + #define GPIO_UBLOX_RST_N 32 + #define GPIO_UBLOX_SAFEBOOT_N 33 + #define GPIO_UBLOX_PWR_EN 34 + #define GPIO_STM_RST_N 124 + #define GPIO_STM_BOOT0 134 +#else + #define GPIO_HUB_RST_N 0 + #define GPIO_UBLOX_RST_N 0 + #define GPIO_UBLOX_SAFEBOOT_N 0 + #define GPIO_UBLOX_PWR_EN 0 + #define GPIO_STM_RST_N 0 + #define GPIO_STM_BOOT0 0 +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +int gpio_init(int pin_nr, bool output); +int gpio_set(int pin_nr, bool high); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif diff --git a/selfdrive/common/i2c.cc b/selfdrive/common/i2c.cc new file mode 100644 index 00000000000000..95d0aedd5ef4ed --- /dev/null +++ b/selfdrive/common/i2c.cc @@ -0,0 +1,83 @@ +#include "i2c.h" + +#include +#include +#include +#include +#include +#include +#include "common/swaglog.h" + +#define UNUSED(x) (void)(x) + +#ifdef QCOM2 +// TODO: decide if we want to isntall libi2c-dev everywhere +extern "C" { + #include + #include +} + +I2CBus::I2CBus(uint8_t bus_id){ + char bus_name[20]; + snprintf(bus_name, 20, "/dev/i2c-%d", bus_id); + + i2c_fd = open(bus_name, O_RDWR); + if(i2c_fd < 0){ + throw std::runtime_error("Failed to open I2C bus"); + } +} + +I2CBus::~I2CBus(){ + if(i2c_fd >= 0){ close(i2c_fd); } +} + +int I2CBus::read_register(uint8_t device_address, uint register_address, uint8_t *buffer, uint8_t len){ + int ret = 0; + + ret = ioctl(i2c_fd, I2C_SLAVE, device_address); + if(ret < 0) { goto fail; } + + ret = i2c_smbus_read_i2c_block_data(i2c_fd, register_address, len, buffer); + if((ret < 0) || (ret != len)) { goto fail; } + +fail: + return ret; +} + +int I2CBus::set_register(uint8_t device_address, uint register_address, uint8_t data){ + int ret = 0; + + ret = ioctl(i2c_fd, I2C_SLAVE, device_address); + if(ret < 0) { goto fail; } + + ret = i2c_smbus_write_byte_data(i2c_fd, register_address, data); + if(ret < 0) { goto fail; } + +fail: + return ret; +} + +#else + +I2CBus::I2CBus(uint8_t bus_id){ + UNUSED(bus_id); + i2c_fd = -1; +} + +I2CBus::~I2CBus(){} + +int I2CBus::read_register(uint8_t device_address, uint register_address, uint8_t *buffer, uint8_t len){ + UNUSED(device_address); + UNUSED(register_address); + UNUSED(buffer); + UNUSED(len); + return -1; +} + +int I2CBus::set_register(uint8_t device_address, uint register_address, uint8_t data){ + UNUSED(device_address); + UNUSED(register_address); + UNUSED(data); + return -1; +} +#endif diff --git a/selfdrive/common/i2c.h b/selfdrive/common/i2c.h new file mode 100644 index 00000000000000..d5788510d3f5e3 --- /dev/null +++ b/selfdrive/common/i2c.h @@ -0,0 +1,16 @@ +#pragma once + +#include +#include + +class I2CBus { + private: + int i2c_fd; + + public: + I2CBus(uint8_t bus_id); + ~I2CBus(); + + int read_register(uint8_t device_address, uint register_address, uint8_t *buffer, uint8_t len); + int set_register(uint8_t device_address, uint register_address, uint8_t data); +}; diff --git a/selfdrive/common/ipc.c b/selfdrive/common/ipc.c index 8d391074786815..a5993598d2960e 100644 --- a/selfdrive/common/ipc.c +++ b/selfdrive/common/ipc.c @@ -15,8 +15,12 @@ int ipc_connect(const char* socket_path) { int err; +#ifdef __APPLE__ + int sock = socket(AF_UNIX, SOCK_STREAM, 0); +#else int sock = socket(AF_UNIX, SOCK_SEQPACKET, 0); - assert(sock >= 0); +#endif + if (sock < 0) return -1; struct sockaddr_un addr = { .sun_family = AF_UNIX, }; @@ -35,7 +39,11 @@ int ipc_bind(const char* socket_path) { unlink(socket_path); +#ifdef __APPLE__ + int sock = socket(AF_UNIX, SOCK_STREAM, 0); +#else int sock = socket(AF_UNIX, SOCK_SEQPACKET, 0); +#endif struct sockaddr_un addr = { .sun_family = AF_UNIX, }; @@ -52,8 +60,6 @@ int ipc_bind(const char* socket_path) { int ipc_sendrecv_with_fds(bool send, int fd, void *buf, size_t buf_size, int* fds, int num_fds, int *out_num_fds) { - int err; - char control_buf[CMSG_SPACE(sizeof(int) * num_fds)]; memset(control_buf, 0, CMSG_SPACE(sizeof(int) * num_fds)); diff --git a/selfdrive/common/mat.h b/selfdrive/common/mat.h index 1c20eae17fd034..626f3404feab49 100644 --- a/selfdrive/common/mat.h +++ b/selfdrive/common/mat.h @@ -1,5 +1,4 @@ -#ifndef COMMON_MAT_H -#define COMMON_MAT_H +#pragma once typedef struct vec3 { float v[3]; @@ -17,7 +16,7 @@ typedef struct mat4 { float v[4*4]; } mat4; -static inline mat3 matmul3(const mat3 a, const mat3 b) { +static inline mat3 matmul3(const mat3 &a, const mat3 &b) { mat3 ret = {{0.0}}; for (int r=0; r<3; r++) { for (int c=0; c<3; c++) { @@ -31,7 +30,7 @@ static inline mat3 matmul3(const mat3 a, const mat3 b) { return ret; } -static inline vec3 matvecmul3(const mat3 a, const vec3 b) { +static inline vec3 matvecmul3(const mat3 &a, const vec3 &b) { vec3 ret = {{0.0}}; for (int r=0; r<3; r++) { for (int c=0; c<3; c++) { @@ -41,7 +40,7 @@ static inline vec3 matvecmul3(const mat3 a, const vec3 b) { return ret; } -static inline mat4 matmul(const mat4 a, const mat4 b) { +static inline mat4 matmul(const mat4 &a, const mat4 &b) { mat4 ret = {{0.0}}; for (int r=0; r<4; r++) { for (int c=0; c<4; c++) { @@ -55,7 +54,7 @@ static inline mat4 matmul(const mat4 a, const mat4 b) { return ret; } -static inline vec4 matvecmul(const mat4 a, const vec4 b) { +static inline vec4 matvecmul(const mat4 &a, const vec4 &b) { vec4 ret = {{0.0}}; for (int r=0; r<4; r++) { for (int c=0; c<4; c++) { @@ -67,7 +66,7 @@ static inline vec4 matvecmul(const mat4 a, const vec4 b) { // scales the input and output space of a transformation matrix // that assumes pixel-center origin. -static inline mat3 transform_scale_buffer(const mat3 in, float s) { +static inline mat3 transform_scale_buffer(const mat3 &in, float s) { // in_pt = ( transform(out_pt/s + 0.5) - 0.5) * s mat3 transform_out = {{ @@ -84,5 +83,3 @@ static inline mat3 transform_scale_buffer(const mat3 in, float s) { return matmul3(transform_in, matmul3(in, transform_out)); } - -#endif diff --git a/selfdrive/common/messaging.h b/selfdrive/common/messaging.h deleted file mode 100644 index 725129508fd268..00000000000000 --- a/selfdrive/common/messaging.h +++ /dev/null @@ -1,15 +0,0 @@ -// the c version of selfdrive/messaging.py - -#include - -// TODO: refactor to take in service instead of endpoint? -void *sub_sock(void *ctx, const char *endpoint) { - void* sock = zmq_socket(ctx, ZMQ_SUB); - assert(sock); - zmq_setsockopt(sock, ZMQ_SUBSCRIBE, "", 0); - int reconnect_ivl = 500; - zmq_setsockopt(sock, ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl, sizeof(reconnect_ivl)); - zmq_connect(sock, endpoint); - return sock; -} - diff --git a/selfdrive/common/modeldata.h b/selfdrive/common/modeldata.h index 6c0cd006f67aaa..9946b40f07d878 100644 --- a/selfdrive/common/modeldata.h +++ b/selfdrive/common/modeldata.h @@ -1,37 +1,10 @@ -#ifndef MODELDATA_H -#define MODELDATA_H - -#define MODEL_PATH_DISTANCE 192 -#define POLYFIT_DEGREE 4 -#define SPEED_PERCENTILES 10 - -typedef struct PathData { - float points[MODEL_PATH_DISTANCE]; - float prob; - float std; - float stds[MODEL_PATH_DISTANCE]; - float poly[POLYFIT_DEGREE]; -} PathData; - -typedef struct LeadData { - float dist; - float prob; - float std; - float rel_y; - float rel_y_std; - float rel_v; - float rel_v_std; - float rel_a; - float rel_a_std; -} LeadData; - -typedef struct ModelData { - PathData path; - PathData left_lane; - PathData right_lane; - LeadData lead; - LeadData lead_future; - float speed[SPEED_PERCENTILES]; -} ModelData; - -#endif +#pragma once + +constexpr int MODEL_PATH_DISTANCE = 192; +constexpr int TRAJECTORY_SIZE = 33; +constexpr float MIN_DRAW_DISTANCE = 10.0; +constexpr float MAX_DRAW_DISTANCE = 100.0; +constexpr int POLYFIT_DEGREE = 4; +constexpr int SPEED_PERCENTILES = 10; +constexpr int DESIRE_PRED_SIZE = 32; +constexpr int OTHER_META_SIZE = 4; diff --git a/selfdrive/common/params.cc b/selfdrive/common/params.cc index 723b06d9212d94..ce079a99621520 100644 --- a/selfdrive/common/params.cc +++ b/selfdrive/common/params.cc @@ -9,65 +9,183 @@ #include #include #include +#include #include #include +#include +#include +#include #include "common/util.h" #include "common/utilpp.h" -namespace { -template -T* null_coalesce(T* a, T* b) { - return a != NULL ? a : b; +std::string getenv_default(const char* env_var, const char * suffix, const char* default_val) { + const char* env_val = getenv(env_var); + if (env_val != NULL){ + return std::string(env_val) + std::string(suffix); + } else { + return std::string(default_val); + } } -static const char* default_params_path = null_coalesce( - const_cast(getenv("PARAMS_PATH")), "/data/params"); +#if defined(QCOM) || defined(QCOM2) +const std::string default_params_path = "/data/params"; +#else +const std::string default_params_path = getenv_default("HOME", "/.comma/params", "/data/params"); +#endif + +#if defined(QCOM) || defined(QCOM2) +const std::string persistent_params_path = "/persist/comma/params"; +#else +const std::string persistent_params_path = default_params_path; +#endif -} // namespace -int write_db_value(const char* params_path, const char* key, const char* value, - size_t value_size) { +volatile sig_atomic_t params_do_exit = 0; +void params_sig_handler(int signal) { + params_do_exit = 1; +} + +static int fsync_dir(const char* path){ + int fd = open(path, O_RDONLY, 0755); + if (fd < 0){ + return -1; + } + + int result = fsync(fd); + int result_close = close(fd); + if (result_close < 0) { + result = result_close; + } + return result; +} + +static int mkdir_p(std::string path) { + char * _path = (char *)path.c_str(); + + mode_t prev_mask = umask(0); + for (char *p = _path + 1; *p; p++) { + if (*p == '/') { + *p = '\0'; // Temporarily truncate + if (mkdir(_path, 0777) != 0) { + if (errno != EEXIST) return -1; + } + *p = '/'; + } + } + if (mkdir(_path, 0777) != 0) { + if (errno != EEXIST) return -1; + } + chmod(_path, 0777); + umask(prev_mask); + return 0; +} + +static int ensure_dir_exists(std::string path) { + // TODO: replace by std::filesystem::create_directories + return mkdir_p(path.c_str()); +} + + +Params::Params(bool persistent_param){ + params_path = persistent_param ? persistent_params_path : default_params_path; +} + +Params::Params(std::string path) { + params_path = path; +} + +int Params::write_db_value(std::string key, std::string dat){ + return write_db_value(key.c_str(), dat.c_str(), dat.length()); +} + +int Params::write_db_value(const char* key, const char* value, size_t value_size) { + // Information about safely and atomically writing a file: https://lwn.net/Articles/457667/ + // 1) Create temp file + // 2) Write data to temp file + // 3) fsync() the temp file + // 4) rename the temp file to the real name + // 5) fsync() the containing directory + int lock_fd = -1; int tmp_fd = -1; int result; - char tmp_path[1024]; - char path[1024]; + std::string path; + std::string tmp_path; ssize_t bytes_written; - if (params_path == NULL) { - params_path = default_params_path; - } - - // Write value to temp. - result = - snprintf(tmp_path, sizeof(tmp_path), "%s/.tmp_value_XXXXXX", params_path); + // Make sure params path exists + result = ensure_dir_exists(params_path); if (result < 0) { goto cleanup; } - tmp_fd = mkstemp(tmp_path); + // See if the symlink exists, otherwise create it + path = params_path + "/d"; + struct stat st; + if (stat(path.c_str(), &st) == -1) { + // Create temp folder + path = params_path + "/.tmp_XXXXXX"; + + char *t = mkdtemp((char*)path.c_str()); + if (t == NULL){ + goto cleanup; + } + std::string tmp_dir(t); + + // Set permissions + result = chmod(tmp_dir.c_str(), 0777); + if (result < 0) { + goto cleanup; + } + + // Symlink it to temp link + tmp_path = tmp_dir + ".link"; + result = symlink(tmp_dir.c_str(), tmp_path.c_str()); + if (result < 0) { + goto cleanup; + } + + // Move symlink to /d + path = params_path + "/d"; + result = rename(tmp_path.c_str(), path.c_str()); + if (result < 0) { + goto cleanup; + } + } else { + // Ensure permissions are correct in case we didn't create the symlink + result = chmod(path.c_str(), 0777); + if (result < 0) { + goto cleanup; + } + } + + // Write value to temp. + tmp_path = params_path + "/.tmp_value_XXXXXX"; + tmp_fd = mkstemp((char*)tmp_path.c_str()); bytes_written = write(tmp_fd, value, value_size); - if (bytes_written != value_size) { + if (bytes_written < 0 || (size_t)bytes_written != value_size) { result = -20; goto cleanup; } - result = snprintf(path, sizeof(path), "%s/.lock", params_path); - if (result < 0) { - goto cleanup; - } - lock_fd = open(path, 0); + // Build lock path + path = params_path + "/.lock"; + lock_fd = open(path.c_str(), O_CREAT, 0775); - result = snprintf(path, sizeof(path), "%s/d/%s", params_path, key); + // Build key path + path = params_path + "/d/" + std::string(key); + + // Take lock. + result = flock(lock_fd, LOCK_EX); if (result < 0) { goto cleanup; } - // Take lock. - result = flock(lock_fd, LOCK_EX); + // change permissions to 0666 for apks + result = fchmod(tmp_fd, 0666); if (result < 0) { goto cleanup; } @@ -79,7 +197,17 @@ int write_db_value(const char* params_path, const char* key, const char* value, } // Move temp into place. - result = rename(tmp_path, path); + result = rename(tmp_path.c_str(), path.c_str()); + if (result < 0) { + goto cleanup; + } + + // fsync parent directory + path = params_path + "/d"; + result = fsync_dir(path.c_str()); + if (result < 0) { + goto cleanup; + } cleanup: // Release lock. @@ -88,33 +216,21 @@ int write_db_value(const char* params_path, const char* key, const char* value, } if (tmp_fd >= 0) { if (result < 0) { - remove(tmp_path); + remove(tmp_path.c_str()); } close(tmp_fd); } return result; } -int read_db_value(const char* params_path, const char* key, char** value, - size_t* value_sz) { +int Params::delete_db_value(std::string key) { int lock_fd = -1; int result; - char path[1024]; + std::string path; - if (params_path == NULL) { - params_path = default_params_path; - } - - result = snprintf(path, sizeof(path), "%s/.lock", params_path); - if (result < 0) { - goto cleanup; - } - lock_fd = open(path, 0); - - result = snprintf(path, sizeof(path), "%s/d/%s", params_path, key); - if (result < 0) { - goto cleanup; - } + // Build lock path, and open lockfile + path = params_path + "/.lock"; + lock_fd = open(path.c_str(), O_CREAT, 0775); // Take lock. result = flock(lock_fd, LOCK_EX); @@ -122,20 +238,20 @@ int read_db_value(const char* params_path, const char* key, char** value, goto cleanup; } - // Read value. - // TODO(mgraczyk): If there is a lot of contention, we can release the lock - // after opening the file, before reading. - *value = static_cast(read_file(path, value_sz)); - if (*value == NULL) { - result = -22; + // Delete value. + path = params_path + "/d/" + key; + result = remove(path.c_str()); + if (result != 0) { + result = ERR_NO_VALUE; goto cleanup; } - // Remove one for null byte. - if (value_sz != NULL) { - *value_sz -= 1; + // fsync parent directory + path = params_path + "/d"; + result = fsync_dir(path.c_str()); + if (result < 0) { + goto cleanup; } - result = 0; cleanup: // Release lock. @@ -145,35 +261,69 @@ int read_db_value(const char* params_path, const char* key, char** value, return result; } -void read_db_value_blocking(const char* params_path, const char* key, - char** value, size_t* value_sz) { - while (1) { - const int result = read_db_value(params_path, key, value, value_sz); +std::string Params::get(std::string key, bool block){ + char* value; + size_t size; + int r; + + if (block){ + r = read_db_value_blocking((const char*)key.c_str(), &value, &size); + } else { + r = read_db_value((const char*)key.c_str(), &value, &size); + } + + if (r == 0){ + std::string s(value, size); + free(value); + return s; + } else { + return ""; + } +} + +int Params::read_db_value(const char* key, char** value, size_t* value_sz) { + std::string path = params_path + "/d/" + std::string(key); + *value = static_cast(read_file(path.c_str(), value_sz)); + if (*value == NULL) { + return -22; + } + return 0; +} + +int Params::read_db_value_blocking(const char* key, char** value, size_t* value_sz) { + params_do_exit = 0; + void (*prev_handler_sigint)(int) = std::signal(SIGINT, params_sig_handler); + void (*prev_handler_sigterm)(int) = std::signal(SIGTERM, params_sig_handler); + + while (!params_do_exit) { + const int result = read_db_value(key, value, value_sz); if (result == 0) { - return; + break; } else { - // Sleep for 0.1 seconds. - usleep(100000); + usleep(100000); // 0.1 s } } + + std::signal(SIGINT, prev_handler_sigint); + std::signal(SIGTERM, prev_handler_sigterm); + return params_do_exit; // Return 0 if we had no interrupt } -int read_db_all(const char* params_path, std::map *params) { +int Params::read_db_all(std::map *params) { int err = 0; - if (params_path == NULL) { - params_path = default_params_path; - } - - std::string lock_path = util::string_format("%s/.lock", params_path); + std::string lock_path = params_path + "/.lock"; int lock_fd = open(lock_path.c_str(), 0); if (lock_fd < 0) return -1; - err = flock(lock_fd, LOCK_EX); - if (err < 0) return err; + err = flock(lock_fd, LOCK_SH); + if (err < 0) { + close(lock_fd); + return err; + } - std::string key_path = util::string_format("%s/d", params_path); + std::string key_path = params_path + "/d"; DIR *d = opendir(key_path.c_str()); if (!d) { close(lock_fd); @@ -184,10 +334,7 @@ int read_db_all(const char* params_path, std::map *par while ((de = readdir(d))) { if (!isalnum(de->d_name[0])) continue; std::string key = std::string(de->d_name); - - if (key == "AccessToken") continue; - - std::string value = util::read_file(util::string_format("%s/%s", key_path.c_str(), key.c_str())); + std::string value = util::read_file(key_path + "/" + key); (*params)[key] = value; } @@ -197,3 +344,20 @@ int read_db_all(const char* params_path, std::map *par close(lock_fd); return 0; } + +std::vector Params::read_db_bytes(const char* param_name) { + std::vector bytes; + char* value; + size_t sz; + int result = read_db_value(param_name, &value, &sz); + if (result == 0) { + bytes.assign(value, value+sz); + free(value); + } + return bytes; +} + +bool Params::read_db_bool(const char* param_name) { + std::vector bytes = read_db_bytes(param_name); + return bytes.size() > 0 and bytes[0] == '1'; +} diff --git a/selfdrive/common/params.h b/selfdrive/common/params.h index 299dcccd0a412d..8da077cfdc3834 100644 --- a/selfdrive/common/params.h +++ b/selfdrive/common/params.h @@ -1,41 +1,46 @@ -#ifndef _SELFDRIVE_COMMON_PARAMS_H_ -#define _SELFDRIVE_COMMON_PARAMS_H_ - +#pragma once #include - -#ifdef __cplusplus -extern "C" { -#endif - -int write_db_value(const char* params_path, const char* key, const char* value, - size_t value_size); - -// Reads a value from the params database. -// Inputs: -// params_path: The path of the database, or NULL to use the default. -// key: The key to read. -// value: A pointer where a newly allocated string containing the db value will -// be written. -// value_sz: A pointer where the size of value will be written. Does not -// include the NULL terminator. -// -// Returns: Negative on failure, otherwise 0. -int read_db_value(const char* params_path, const char* key, char** value, - size_t* value_sz); - -// Reads a value from the params database, blocking until successful. -// Inputs are the same as read_db_value. -void read_db_value_blocking(const char* params_path, const char* key, - char** value, size_t* value_sz); - -#ifdef __cplusplus -} // extern "C" -#endif - -#ifdef __cplusplus #include #include -int read_db_all(const char* params_path, std::map *params); -#endif - -#endif // _SELFDRIVE_COMMON_PARAMS_H_ +#include + +#define ERR_NO_VALUE -33 + +class Params { +private: + std::string params_path; + +public: + Params(bool persistent_param = false); + Params(std::string path); + + int write_db_value(std::string key, std::string dat); + int write_db_value(const char* key, const char* value, size_t value_size); + + // Reads a value from the params database. + // Inputs: + // key: The key to read. + // value: A pointer where a newly allocated string containing the db value will + // be written. + // value_sz: A pointer where the size of value will be written. Does not + // include the NULL terminator. + // persistent_param: Boolean indicating if the param store in the /persist partition is to be used. + // e.g. for sensor calibration files. Will not be cleared after wipe or re-install. + // + // Returns: Negative on failure, otherwise 0. + int read_db_value(const char* key, char** value, size_t* value_sz); + + // Delete a value from the params database. + // Inputs are the same as read_db_value, without value and value_sz. + int delete_db_value(std::string key); + + // Reads a value from the params database, blocking until successful. + // Inputs are the same as read_db_value. + int read_db_value_blocking(const char* key, char** value, size_t* value_sz); + + int read_db_all(std::map *params); + std::vector read_db_bytes(const char* param_name); + bool read_db_bool(const char* param_name); + + std::string get(std::string key, bool block=false); +}; diff --git a/selfdrive/common/swaglog.c b/selfdrive/common/swaglog.c deleted file mode 100644 index 70cba78167532b..00000000000000 --- a/selfdrive/common/swaglog.c +++ /dev/null @@ -1,119 +0,0 @@ -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "common/timing.h" -#include "common/version.h" - -#include "swaglog.h" - -typedef struct LogState { - pthread_mutex_t lock; - bool inited; - JsonNode *ctx_j; - void *zctx; - void *sock; - int print_level; -} LogState; - -static LogState s = { - .lock = PTHREAD_MUTEX_INITIALIZER, -}; - -static void cloudlog_bind_locked(const char* k, const char* v) { - json_append_member(s.ctx_j, k, json_mkstring(v)); -} - -static void cloudlog_init() { - if (s.inited) return; - s.ctx_j = json_mkobject(); - s.zctx = zmq_ctx_new(); - s.sock = zmq_socket(s.zctx, ZMQ_PUSH); - zmq_connect(s.sock, "ipc:///tmp/logmessage"); - - s.print_level = CLOUDLOG_WARNING; - const char* print_level = getenv("LOGPRINT"); - if (print_level) { - if (strcmp(print_level, "debug") == 0) { - s.print_level = CLOUDLOG_DEBUG; - } else if (strcmp(print_level, "info") == 0) { - s.print_level = CLOUDLOG_INFO; - } else if (strcmp(print_level, "warning") == 0) { - s.print_level = CLOUDLOG_WARNING; - } - } - - // openpilot bindings - char* dongle_id = getenv("DONGLE_ID"); - if (dongle_id) { - cloudlog_bind_locked("dongle_id", dongle_id); - } - cloudlog_bind_locked("version", COMMA_VERSION); - bool dirty = !getenv("CLEAN"); - json_append_member(s.ctx_j, "dirty", json_mkbool(dirty)); - - s.inited = true; -} - -void cloudlog_e(int levelnum, const char* filename, int lineno, const char* func, - const char* fmt, ...) { - pthread_mutex_lock(&s.lock); - cloudlog_init(); - - char* msg_buf = NULL; - va_list args; - va_start(args, fmt); - vasprintf(&msg_buf, fmt, args); - va_end(args); - - if (!msg_buf) { - pthread_mutex_unlock(&s.lock); - return; - } - - if (levelnum >= s.print_level) { - printf("%s: %s\n", filename, msg_buf); - } - - JsonNode *log_j = json_mkobject(); - assert(log_j); - - json_append_member(log_j, "msg", json_mkstring(msg_buf)); - json_append_member(log_j, "ctx", s.ctx_j); - json_append_member(log_j, "levelnum", json_mknumber(levelnum)); - json_append_member(log_j, "filename", json_mkstring(filename)); - json_append_member(log_j, "lineno", json_mknumber(lineno)); - json_append_member(log_j, "funcname", json_mkstring(func)); - json_append_member(log_j, "created", json_mknumber(seconds_since_epoch())); - - char* log_s = json_encode(log_j); - assert(log_s); - - json_remove_from_parent(s.ctx_j); - - json_delete(log_j); - free(msg_buf); - - char levelnum_c = levelnum; - zmq_send(s.sock, &levelnum_c, 1, ZMQ_NOBLOCK | ZMQ_SNDMORE); - zmq_send(s.sock, log_s, strlen(log_s), ZMQ_NOBLOCK); - free(log_s); - - pthread_mutex_unlock(&s.lock); -} - -void cloudlog_bind(const char* k, const char* v) { - pthread_mutex_lock(&s.lock); - cloudlog_init(); - cloudlog_bind_locked(k, v); - pthread_mutex_unlock(&s.lock); -} diff --git a/selfdrive/common/swaglog.cc b/selfdrive/common/swaglog.cc new file mode 100644 index 00000000000000..9d90347547caf4 --- /dev/null +++ b/selfdrive/common/swaglog.cc @@ -0,0 +1,112 @@ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include +#include +#include + +#include +#include + +#include "json11.hpp" + +#include "common/timing.h" +#include "common/version.h" + +#include "swaglog.h" + +typedef struct LogState { + pthread_mutex_t lock; + bool inited; + json11::Json::object ctx_j; + void *zctx; + void *sock; + int print_level; +} LogState; + +static LogState s = { + .lock = PTHREAD_MUTEX_INITIALIZER, +}; + +static void cloudlog_bind_locked(const char* k, const char* v) { + s.ctx_j[k] = v; +} + +static void cloudlog_init() { + if (s.inited) return; + s.ctx_j = json11::Json::object {}; + s.zctx = zmq_ctx_new(); + s.sock = zmq_socket(s.zctx, ZMQ_PUSH); + zmq_connect(s.sock, "ipc:///tmp/logmessage"); + + s.print_level = CLOUDLOG_WARNING; + const char* print_level = getenv("LOGPRINT"); + if (print_level) { + if (strcmp(print_level, "debug") == 0) { + s.print_level = CLOUDLOG_DEBUG; + } else if (strcmp(print_level, "info") == 0) { + s.print_level = CLOUDLOG_INFO; + } else if (strcmp(print_level, "warning") == 0) { + s.print_level = CLOUDLOG_WARNING; + } + } + + // openpilot bindings + char* dongle_id = getenv("DONGLE_ID"); + if (dongle_id) { + cloudlog_bind_locked("dongle_id", dongle_id); + } + cloudlog_bind_locked("version", COMMA_VERSION); + s.ctx_j["dirty"] = !getenv("CLEAN"); + + s.inited = true; +} + +void cloudlog_e(int levelnum, const char* filename, int lineno, const char* func, + const char* fmt, ...) { + pthread_mutex_lock(&s.lock); + cloudlog_init(); + + char* msg_buf = NULL; + va_list args; + va_start(args, fmt); + vasprintf(&msg_buf, fmt, args); + va_end(args); + + if (!msg_buf) { + pthread_mutex_unlock(&s.lock); + return; + } + + if (levelnum >= s.print_level) { + printf("%s: %s\n", filename, msg_buf); + } + + json11::Json log_j = json11::Json::object { + {"msg", msg_buf}, + {"ctx", s.ctx_j}, + {"levelnum", levelnum}, + {"filename", filename}, + {"lineno", lineno}, + {"funcname", func}, + {"created", seconds_since_epoch()} + }; + + std::string log_s = log_j.dump(); + + free(msg_buf); + + char levelnum_c = levelnum; + zmq_send(s.sock, &levelnum_c, 1, ZMQ_NOBLOCK | ZMQ_SNDMORE); + zmq_send(s.sock, log_s.c_str(), log_s.length(), ZMQ_NOBLOCK); + + pthread_mutex_unlock(&s.lock); +} + +void cloudlog_bind(const char* k, const char* v) { + pthread_mutex_lock(&s.lock); + cloudlog_init(); + cloudlog_bind_locked(k, v); + pthread_mutex_unlock(&s.lock); +} diff --git a/selfdrive/common/swaglog.h b/selfdrive/common/swaglog.h index 33e77f618aef59..3a828ed49b3ea5 100644 --- a/selfdrive/common/swaglog.h +++ b/selfdrive/common/swaglog.h @@ -1,7 +1,7 @@ #ifndef SWAGLOG_H #define SWAGLOG_H -#include "common/timing.h" +#include "selfdrive/common/timing.h" #define CLOUDLOG_DEBUG 10 #define CLOUDLOG_INFO 20 diff --git a/selfdrive/common/touch.c b/selfdrive/common/touch.c index d35df4b3b58e4b..0ab1e38c009b55 100644 --- a/selfdrive/common/touch.c +++ b/selfdrive/common/touch.c @@ -10,6 +10,13 @@ #include "touch.h" +/* this macro is used to tell if "bit" is set in "array" + * it selects a byte from the array, and does a boolean AND + * operation with a byte that only has the relevant bit set. + * eg. to check for the 12th bit, we do (array[1] & 1<<4) + */ +#define test_bit(bit, array) (array[bit/8] & (1<<(bit%8))) + static int find_dev() { int err; @@ -28,10 +35,7 @@ static int find_dev() { err = ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(ev_bits)), ev_bits); assert(err >= 0); - const int x_key = ABS_MT_POSITION_X / 8; - const int y_key = ABS_MT_POSITION_Y / 8; - if ((ev_bits[x_key] & (ABS_MT_POSITION_X - x_key)) && - (ev_bits[y_key] & (ABS_MT_POSITION_Y - y_key))) { + if (test_bit(ABS_MT_POSITION_X, ev_bits) && test_bit(ABS_MT_POSITION_Y, ev_bits)) { ret = fd; break; } @@ -69,14 +73,15 @@ int touch_poll(TouchState *s, int* out_x, int* out_y, int timeout) { return -1; } - switch (event.type) { + switch (event.type) { case EV_ABS: if (event.code == ABS_MT_POSITION_X) { s->last_x = event.value; } else if (event.code == ABS_MT_POSITION_Y) { s->last_y = event.value; - } else - up = true; + } else if (event.code == ABS_MT_TRACKING_ID && event.value != -1) { + up = true; + } break; default: break; @@ -89,32 +94,3 @@ int touch_poll(TouchState *s, int* out_x, int* out_y, int timeout) { } return up; } - -int touch_read(TouchState *s, int* out_x, int* out_y) { - assert(out_x && out_y); - struct input_event event; - int err = read(s->fd, &event, sizeof(event)); - if (err < sizeof(event)) { - return false; //-1; - } - bool up = false; - switch (event.type) { - case EV_ABS: - if (event.code == ABS_MT_POSITION_X) { - s->last_x = event.value; - } else if (event.code == ABS_MT_POSITION_Y) { - s->last_y = event.value; - } - up = true; - break; - default: - break; - } - if (up) { - // adjust for flippening - *out_x = s->last_y; - *out_y = 1080 - s->last_x; - } - return up; -} - diff --git a/selfdrive/common/touch.h b/selfdrive/common/touch.h index c48f66b9827214..fa0faa271b5008 100644 --- a/selfdrive/common/touch.h +++ b/selfdrive/common/touch.h @@ -1,5 +1,4 @@ -#ifndef TOUCH_H -#define TOUCH_H +#pragma once #ifdef __cplusplus extern "C" { @@ -12,10 +11,7 @@ typedef struct TouchState { void touch_init(TouchState *s); int touch_poll(TouchState *s, int *out_x, int *out_y, int timeout); -int touch_read(TouchState *s, int* out_x, int* out_y); #ifdef __cplusplus } #endif - -#endif diff --git a/selfdrive/common/util.c b/selfdrive/common/util.c index 01b8a0b6d92c80..49f53db33db09d 100644 --- a/selfdrive/common/util.c +++ b/selfdrive/common/util.c @@ -3,12 +3,17 @@ #include #include #include +#include +#include #ifdef __linux__ #include #include -#include +#ifndef __USE_GNU +#define __USE_GNU #endif +#include +#endif // __linux__ void* read_file(const char* path, size_t* out_len) { FILE* f = fopen(path, "r"); @@ -19,7 +24,9 @@ void* read_file(const char* path, size_t* out_len) { long f_len = ftell(f); rewind(f); - char* buf = calloc(f_len + 1, 1); + // malloc one extra byte so the file will always be NULL terminated + // cl_cached_program_from_file relies on this + char* buf = (char*)malloc(f_len+1); assert(buf); size_t num_read = fread(buf, f_len, 1, f); @@ -30,13 +37,24 @@ void* read_file(const char* path, size_t* out_len) { return NULL; } + buf[f_len] = '\0'; if (out_len) { - *out_len = f_len + 1; + *out_len = f_len; } return buf; } +int write_file(const char* path, const void* data, size_t size) { + int fd = open(path, O_WRONLY); + if (fd == -1) { + return -1; + } + ssize_t n = write(fd, data, size); + close(fd); + return (n >= 0 && (size_t)n == size) ? 0 : -1; +} + void set_thread_name(const char* name) { #ifdef __linux__ // pthread_setname_np is dumb (fails instead of truncates) @@ -46,7 +64,6 @@ void set_thread_name(const char* name) { int set_realtime_priority(int level) { #ifdef __linux__ - long tid = syscall(SYS_gettid); // should match python using chrt @@ -54,6 +71,20 @@ int set_realtime_priority(int level) { memset(&sa, 0, sizeof(sa)); sa.sched_priority = level; return sched_setscheduler(tid, SCHED_FIFO, &sa); +#else + return -1; #endif } +int set_core_affinity(int core) { +#ifdef __linux__ + long tid = syscall(SYS_gettid); + cpu_set_t rt_cpu; + + CPU_ZERO(&rt_cpu); + CPU_SET(core, &rt_cpu); + return sched_setaffinity(tid, sizeof(rt_cpu), &rt_cpu); +#else + return -1; +#endif +} diff --git a/selfdrive/common/util.h b/selfdrive/common/util.h index b3ca916941654d..c7a1dbfc88694a 100644 --- a/selfdrive/common/util.h +++ b/selfdrive/common/util.h @@ -3,6 +3,10 @@ #include +#ifndef sighandler_t +typedef void (*sighandler_t)(int sig); +#endif + #ifndef __cplusplus #define min(a,b) \ @@ -17,14 +21,9 @@ #endif -#define clamp(a,b,c) \ - ({ __typeof__ (a) _a = (a); \ - __typeof__ (b) _b = (b); \ - __typeof__ (c) _c = (c); \ - _a < _b ? _b : (_a > _c ? _c : _a); }) - #define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0])) +#undef ALIGN #define ALIGN(x, align) (((x) + (align)-1) & ~((align)-1)) #ifdef __cplusplus @@ -36,10 +35,12 @@ extern "C" { // Returns NULL on failure, otherwise the NULL-terminated file contents. // The result must be freed by the caller. void* read_file(const char* path, size_t* out_len); +int write_file(const char* path, const void* data, size_t size); void set_thread_name(const char* name); int set_realtime_priority(int level); +int set_core_affinity(int core); #ifdef __cplusplus } diff --git a/selfdrive/common/utilpp.h b/selfdrive/common/utilpp.h index e374c5c256f772..e0547e0c16c56d 100644 --- a/selfdrive/common/utilpp.h +++ b/selfdrive/common/utilpp.h @@ -1,5 +1,4 @@ -#ifndef UTILPP_H -#define UTILPP_H +#pragma once #include #include @@ -18,7 +17,7 @@ inline bool starts_with(std::string s, std::string prefix) { template inline std::string string_format( const std::string& format, Args ... args ) { size_t size = snprintf( nullptr, 0, format.c_str(), args ... ) + 1; - std::unique_ptr buf( new char[ size ] ); + std::unique_ptr buf( new char[ size ] ); snprintf( buf.get(), size, format.c_str(), args ... ); return std::string( buf.get(), buf.get() + size - 1 ); } @@ -32,7 +31,7 @@ inline std::string read_file(std::string fn) { inline std::string tohex(const uint8_t* buf, size_t buf_size) { std::unique_ptr hexbuf(new char[buf_size*2+1]); - for (int i=0; i #else @@ -13,6 +13,7 @@ extern "C" { typedef struct VisionBuf { size_t len; + size_t mmap_len; void* addr; int handle; int fd; @@ -27,13 +28,10 @@ typedef struct VisionBuf { #define VISIONBUF_SYNC_TO_DEVICE 1 VisionBuf visionbuf_allocate(size_t len); -VisionBuf visionbuf_allocate_cl(size_t len, cl_device_id device_id, cl_context ctx, cl_mem *out_mem); -cl_mem visionbuf_to_cl(const VisionBuf* buf, cl_device_id device_id, cl_context ctx); +VisionBuf visionbuf_allocate_cl(size_t len, cl_device_id device_id, cl_context ctx); void visionbuf_sync(const VisionBuf* buf, int dir); void visionbuf_free(const VisionBuf* buf); #ifdef __cplusplus } #endif - -#endif diff --git a/selfdrive/common/visionbuf_cl.c b/selfdrive/common/visionbuf_cl.c new file mode 100644 index 00000000000000..1cf6ad6b803309 --- /dev/null +++ b/selfdrive/common/visionbuf_cl.c @@ -0,0 +1,101 @@ +#include "visionbuf.h" + +#include +#include +#include +#include +#include +#include +#include +#include "common/clutil.h" + +#define CL_USE_DEPRECATED_OPENCL_1_2_APIS +#ifdef __APPLE__ +#include +#else +#include +#endif + +int offset = 0; +void *malloc_with_fd(size_t len, int *fd) { + char full_path[0x100]; +#ifdef __APPLE__ + snprintf(full_path, sizeof(full_path)-1, "/tmp/visionbuf_%d_%d", getpid(), offset++); +#else + snprintf(full_path, sizeof(full_path)-1, "/dev/shm/visionbuf_%d_%d", getpid(), offset++); +#endif + *fd = open(full_path, O_RDWR | O_CREAT, 0777); + assert(*fd >= 0); + unlink(full_path); + ftruncate(*fd, len); + void *addr = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, *fd, 0); + assert(addr != MAP_FAILED); + return addr; +} + +VisionBuf visionbuf_allocate(size_t len) { + // const size_t alignment = 4096; + // void* addr = aligned_alloc(alignment, alignment * ((len - 1) / alignment + 1)); + //void* addr = calloc(1, len); + + int fd; + void *addr = malloc_with_fd(len, &fd); + + return (VisionBuf){ + .len = len, .addr = addr, .handle = 1, .fd = fd, + }; +} + +VisionBuf visionbuf_allocate_cl(size_t len, cl_device_id device_id, cl_context ctx) { +#if __OPENCL_VERSION__ >= 200 + void* host_ptr = + clSVMAlloc(ctx, CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER, len, 0); + assert(host_ptr); +#else + int fd; + void* host_ptr = malloc_with_fd(len, &fd); + + cl_command_queue q = CL_CHECK_ERR(clCreateCommandQueue(ctx, device_id, 0, &err)); +#endif + + cl_mem mem = CL_CHECK_ERR(clCreateBuffer(ctx, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, len, host_ptr, &err)); + + return (VisionBuf){ + .len = len, .addr = host_ptr, .handle = 0, .fd = fd, + .device_id = device_id, .ctx = ctx, .buf_cl = mem, + +#if __OPENCL_VERSION__ < 200 + .copy_q = q, +#endif + + }; +} + +void visionbuf_sync(const VisionBuf* buf, int dir) { + if (!buf->buf_cl) return; + +#if __OPENCL_VERSION__ < 200 + if (dir == VISIONBUF_SYNC_FROM_DEVICE) { + CL_CHECK(clEnqueueReadBuffer(buf->copy_q, buf->buf_cl, CL_FALSE, 0, buf->len, buf->addr, 0, NULL, NULL)); + } else { + CL_CHECK(clEnqueueWriteBuffer(buf->copy_q, buf->buf_cl, CL_FALSE, 0, buf->len, buf->addr, 0, NULL, NULL)); + } + clFinish(buf->copy_q); +#endif +} + +void visionbuf_free(const VisionBuf* buf) { + if (buf->handle) { + munmap(buf->addr, buf->len); + close(buf->fd); + } else { + CL_CHECK(clReleaseMemObject(buf->buf_cl)); +#if __OPENCL_VERSION__ >= 200 + clSVMFree(buf->ctx, buf->addr); +#else + CL_CHECK(clReleaseCommandQueue(buf->copy_q)); + munmap(buf->addr, buf->len); + close(buf->fd); +#endif + } +} diff --git a/selfdrive/common/visionbuf_ion.c b/selfdrive/common/visionbuf_ion.c index 724e75e9b0c0d5..5c26bea6ad4422 100644 --- a/selfdrive/common/visionbuf_ion.c +++ b/selfdrive/common/visionbuf_ion.c @@ -1,12 +1,16 @@ #include #include +#include #include #include #include - +#include +#include +#include +#include #include #include - +#include "common/clutil.h" #include #include "visionbuf.h" @@ -60,37 +64,31 @@ VisionBuf visionbuf_allocate(size_t len) { return (VisionBuf){ .len = len, + .mmap_len = ion_alloc.len, .addr = addr, .handle = ion_alloc.handle, .fd = ion_fd_data.fd, }; } -VisionBuf visionbuf_allocate_cl(size_t len, cl_device_id device_id, cl_context ctx, cl_mem *out_mem) { - VisionBuf r = visionbuf_allocate(len); - *out_mem = visionbuf_to_cl(&r, device_id, ctx); - return r; -} - -cl_mem visionbuf_to_cl(const VisionBuf* buf, cl_device_id device_id, cl_context ctx) { - int err = 0; +VisionBuf visionbuf_allocate_cl(size_t len, cl_device_id device_id, cl_context ctx) { + VisionBuf buf = visionbuf_allocate(len); - assert(((uintptr_t)buf->addr % DEVICE_PAGE_SIZE_CL) == 0); + assert(((uintptr_t)buf.addr % DEVICE_PAGE_SIZE_CL) == 0); cl_mem_ion_host_ptr ion_cl = {0}; ion_cl.ext_host_ptr.allocation_type = CL_MEM_ION_HOST_PTR_QCOM; ion_cl.ext_host_ptr.host_cache_policy = CL_MEM_HOST_UNCACHED_QCOM; - ion_cl.ion_filedesc = buf->fd; - ion_cl.ion_hostptr = buf->addr; + ion_cl.ion_filedesc = buf.fd; + ion_cl.ion_hostptr = buf.addr; - cl_mem mem = clCreateBuffer(ctx, + buf.buf_cl = CL_CHECK_ERR(clCreateBuffer(ctx, CL_MEM_USE_HOST_PTR | CL_MEM_EXT_HOST_PTR_QCOM, - buf->len, &ion_cl, &err); - assert(err == 0); - - return mem; + buf.len, &ion_cl, &err)); + return buf; } + void visionbuf_sync(const VisionBuf* buf, int dir) { int err; @@ -133,6 +131,11 @@ void visionbuf_sync(const VisionBuf* buf, int dir) { } void visionbuf_free(const VisionBuf* buf) { + if (buf->buf_cl) { + CL_CHECK(clReleaseMemObject(buf->buf_cl)); + } + munmap(buf->addr, buf->mmap_len); + close(buf->fd); struct ion_handle_data handle_data = { .handle = buf->handle, }; diff --git a/selfdrive/common/visionimg.cc b/selfdrive/common/visionimg.cc index a533acb597ac4c..5f300299250021 100644 --- a/selfdrive/common/visionimg.cc +++ b/selfdrive/common/visionimg.cc @@ -37,26 +37,25 @@ extern "C" void compute_aligned_width_and_height(int width, #endif void visionimg_compute_aligned_width_and_height(int width, int height, int *aligned_w, int *aligned_h) { -#ifdef QCOM +#if defined(QCOM) && !defined(QCOM_REPLAY) compute_aligned_width_and_height(ALIGN(width, 32), ALIGN(height, 32), 3, 0, 0, 512, aligned_w, aligned_h); #else *aligned_w = width; *aligned_h = height; #endif } -VisionImg visionimg_alloc_rgb24(int width, int height, VisionBuf *out_buf) { +VisionImg visionimg_alloc_rgb24(cl_device_id device_id, cl_context ctx, int width, int height, VisionBuf *out_buf) { + assert(out_buf != nullptr); int aligned_w = 0, aligned_h = 0; visionimg_compute_aligned_width_and_height(width, height, &aligned_w, &aligned_h); int stride = aligned_w * 3; - size_t size = aligned_w * aligned_h * 3; - - VisionBuf buf = visionbuf_allocate(size); + size_t size = (size_t) aligned_w * aligned_h * 3; - *out_buf = buf; + *out_buf = visionbuf_allocate_cl(size, device_id, ctx); return (VisionImg){ - .fd = buf.fd, + .fd = out_buf->fd, .format = VISIONIMG_FORMAT_RGB24, .width = width, .height = height, diff --git a/selfdrive/common/visionimg.h b/selfdrive/common/visionimg.h index 74b0f3137d1b8c..14ee9f86336a25 100644 --- a/selfdrive/common/visionimg.h +++ b/selfdrive/common/visionimg.h @@ -1,14 +1,18 @@ #ifndef VISIONIMG_H #define VISIONIMG_H +#include "common/visionbuf.h" +#include "common/glutil.h" + #ifdef QCOM -#include #include #include +#undef Status +#else +typedef int EGLImageKHR; +typedef void *EGLClientBuffer; #endif -#include "common/visionbuf.h" - #ifdef __cplusplus extern "C" { #endif @@ -24,13 +28,11 @@ typedef struct VisionImg { } VisionImg; void visionimg_compute_aligned_width_and_height(int width, int height, int *aligned_w, int *aligned_h); -VisionImg visionimg_alloc_rgb24(int width, int height, VisionBuf *out_buf); +VisionImg visionimg_alloc_rgb24(cl_device_id device_id, cl_context ctx, int width, int height, VisionBuf *out_buf); -#ifdef QCOM EGLClientBuffer visionimg_to_egl(const VisionImg *img, void **pph); GLuint visionimg_to_gl(const VisionImg *img, EGLImageKHR *pkhr, void **pph); void visionimg_destroy_gl(EGLImageKHR khr, void *ph); -#endif #ifdef __cplusplus } // extern "C" diff --git a/selfdrive/common/visionipc.c b/selfdrive/common/visionipc.c index 314f7d0a55c712..6820491156fb3c 100644 --- a/selfdrive/common/visionipc.c +++ b/selfdrive/common/visionipc.c @@ -35,6 +35,7 @@ int vipc_recv(int fd, VisionPacket *out_p) { p2.d = p.d; *out_p = p2; } + //printf("%d = vipc_recv(%d, %d): %d %d %d %zu\n", ret, fd, p2.num_fds, out_p->d.stream_bufs.type, out_p->d.stream_bufs.width, out_p->d.stream_bufs.height, out_p->d.stream_bufs.buf_len); return ret; } @@ -45,7 +46,9 @@ int vipc_send(int fd, const VisionPacket *p2) { .type = p2->type, .d = p2->d, }; - return ipc_sendrecv_with_fds(true, fd, (void*)&p, sizeof(p), (int*)p2->fds, p2->num_fds, NULL); + int ret = ipc_sendrecv_with_fds(true, fd, (void*)&p, sizeof(p), (int*)p2->fds, p2->num_fds, NULL); + //printf("%d = vipc_send(%d, %d): %d %d %d %zu\n", ret, fd, p2->num_fds, p2->d.stream_bufs.type, p2->d.stream_bufs.width, p2->d.stream_bufs.height, p2->d.stream_bufs.buf_len); + return ret; } void vipc_bufs_load(VIPCBuf *bufs, const VisionStreamBufs *stream_bufs, @@ -87,6 +90,7 @@ int visionstream_init(VisionStream *s, VisionStreamType type, bool tbuffer, Visi err = vipc_send(s->ipc_fd, &p); if (err < 0) { close(s->ipc_fd); + s->ipc_fd = -1; return -1; } @@ -94,9 +98,10 @@ int visionstream_init(VisionStream *s, VisionStreamType type, bool tbuffer, Visi err = vipc_recv(s->ipc_fd, &rp); if (err <= 0) { close(s->ipc_fd); + s->ipc_fd = -1; return -1; } - assert(rp.type = VIPC_STREAM_BUFS); + assert(rp.type == VIPC_STREAM_BUFS); assert(rp.d.stream_bufs.type == type); s->bufs_info = rp.d.stream_bufs; @@ -187,5 +192,5 @@ void visionstream_destroy(VisionStream *s) { } } if (s->bufs) free(s->bufs); - close(s->ipc_fd); + if (s->ipc_fd >= 0) close(s->ipc_fd); } diff --git a/selfdrive/common/visionipc.h b/selfdrive/common/visionipc.h index 4844a71b1d756b..e20500db6b14c1 100644 --- a/selfdrive/common/visionipc.h +++ b/selfdrive/common/visionipc.h @@ -23,8 +23,10 @@ typedef enum VisionIPCPacketType { typedef enum VisionStreamType { VISION_STREAM_RGB_BACK, VISION_STREAM_RGB_FRONT, + VISION_STREAM_RGB_WIDE, VISION_STREAM_YUV, VISION_STREAM_YUV_FRONT, + VISION_STREAM_YUV_WIDE, VISION_STREAM_MAX, } VisionStreamType; @@ -35,6 +37,10 @@ typedef struct VisionUIInfo { int front_box_x, front_box_y; int front_box_width, front_box_height; + + int wide_box_x, wide_box_y; + int wide_box_width, wide_box_height; + } VisionUIInfo; typedef struct VisionStreamBufs { @@ -51,6 +57,7 @@ typedef struct VisionStreamBufs { typedef struct VIPCBufExtra { // only for yuv uint32_t frame_id; + uint64_t timestamp_sof; uint64_t timestamp_eof; } VIPCBufExtra; diff --git a/selfdrive/config.py b/selfdrive/config.py index 751a84e285f52c..2a895808890f27 100644 --- a/selfdrive/config.py +++ b/selfdrive/config.py @@ -17,13 +17,13 @@ class Conversions: LB_TO_KG = 0.453592 -RADAR_TO_CENTER = 2.7 # RADAR is ~ 2.7m ahead from center of car +RADAR_TO_CENTER = 2.7 # (deprecated) RADAR is ~ 2.7m ahead from center of car +RADAR_TO_CAMERA = 1.52 # RADAR is ~ 1.5m ahead from center of mesh frame class UIParams: lidar_x, lidar_y, lidar_zoom = 384, 960, 6 lidar_car_x, lidar_car_y = lidar_x/2., lidar_y/1.1 car_hwidth = 1.7272/2 * lidar_zoom car_front = 2.6924 * lidar_zoom - car_back = 1.8796 * lidar_zoom + car_back = 1.8796 * lidar_zoom car_color = 110 - diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 3a731f7678b93e..16dd43cfad36cb 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -1,567 +1,595 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import os -import gc -import capnp from cereal import car, log from common.numpy_fast import clip -from common.realtime import sec_since_boot, set_realtime_priority, Ratekeeper, DT_CTRL +from common.realtime import sec_since_boot, config_realtime_process, Priority, Ratekeeper, DT_CTRL from common.profiler import Profiler -from common.params import Params -import selfdrive.messaging as messaging +from common.params import Params, put_nonblocking +import cereal.messaging as messaging from selfdrive.config import Conversions as CV -from selfdrive.services import service_list from selfdrive.boardd.boardd import can_list_to_can_capnp -from selfdrive.car.car_helpers import get_car, get_startup_alert +from selfdrive.car.car_helpers import get_car, get_startup_event, get_one_can from selfdrive.controls.lib.lane_planner import CAMERA_OFFSET -from selfdrive.controls.lib.drive_helpers import get_events, \ - create_event, \ - EventTypes as ET, \ - update_v_cruise, \ - initialize_v_cruise +from selfdrive.controls.lib.drive_helpers import update_v_cruise, initialize_v_cruise from selfdrive.controls.lib.longcontrol import LongControl, STARTING_TARGET_SPEED from selfdrive.controls.lib.latcontrol_pid import LatControlPID from selfdrive.controls.lib.latcontrol_indi import LatControlINDI from selfdrive.controls.lib.latcontrol_lqr import LatControlLQR +from selfdrive.controls.lib.events import Events, ET from selfdrive.controls.lib.alertmanager import AlertManager from selfdrive.controls.lib.vehicle_model import VehicleModel -from selfdrive.controls.lib.driver_monitor import DriverStatus, MAX_TERMINAL_ALERTS from selfdrive.controls.lib.planner import LON_MPC_STEP -from selfdrive.locationd.calibration_helpers import Calibration, Filter +from selfdrive.locationd.calibrationd import Calibration +from selfdrive.hardware import HARDWARE +from selfdrive.tinklad.tinkla_interface import TinklaClient + +LDW_MIN_SPEED = 31 * CV.MPH_TO_MS +LANE_DEPARTURE_THRESHOLD = 0.1 +STEER_ANGLE_SATURATION_TIMEOUT = 1.0 / DT_CTRL +STEER_ANGLE_SATURATION_THRESHOLD = 250 # Degrees + +SIMULATION = "SIMULATION" in os.environ +NOSENSOR = "NOSENSOR" in os.environ ThermalStatus = log.ThermalData.ThermalStatus State = log.ControlsState.OpenpilotState +HwType = log.HealthData.HwType +LongitudinalPlanSource = log.Plan.LongitudinalPlanSource +Desire = log.PathPlan.Desire +LaneChangeState = log.PathPlan.LaneChangeState +LaneChangeDirection = log.PathPlan.LaneChangeDirection +EventName = car.CarEvent.EventName + + +class Controls: + + tinklaClient = None + + def __init__(self, sm=None, pm=None, can_sock=None): + config_realtime_process(3, Priority.CTRL_HIGH) + + self.tinklaClient = TinklaClient() + + # Setup sockets + self.pm = pm + if self.pm is None: + self.pm = messaging.PubMaster(['sendcan', 'controlsState', 'carState', + 'carControl', 'carEvents', 'carParams']) + + self.sm = sm + if self.sm is None: + self.sm = messaging.SubMaster(['thermal', 'health', 'model', 'liveCalibration', 'frontFrame', + 'dMonitoringState', 'plan', 'pathPlan', 'liveLocationKalman']) + + self.can_sock = can_sock + if can_sock is None: + can_timeout = None if os.environ.get('NO_CAN_TIMEOUT', False) else 100 + self.can_sock = messaging.sub_sock('can', timeout=can_timeout) + + # wait for one health and one CAN packet + print("Waiting for CAN messages...") + get_one_can(self.can_sock) + + self.CI, self.CP = get_car(self.can_sock, self.pm.sock['sendcan']) + + # read params + params = Params() + self.is_metric = params.get("IsMetric", encoding='utf8') == "1" + self.is_ldw_enabled = params.get("IsLdwEnabled", encoding='utf8') == "1" + internet_needed = (params.get("Offroad_ConnectivityNeeded", encoding='utf8') is not None) and (params.get("DisableUpdates") != b"1") + community_feature_toggle = params.get("CommunityFeaturesToggle", encoding='utf8') == "1" + openpilot_enabled_toggle = params.get("OpenpilotEnabledToggle", encoding='utf8') == "1" + passive = params.get("Passive", encoding='utf8') == "1" or \ + internet_needed or not openpilot_enabled_toggle + + # detect sound card presence and ensure successful init + sounds_available = HARDWARE.get_sound_card_online() + + car_recognized = self.CP.carName != 'mock' + # If stock camera is disconnected, we loaded car controls and it's not dashcam mode + controller_available = self.CP.enableCamera and self.CI.CC is not None and not passive and not self.CP.dashcamOnly + community_feature_disallowed = self.CP.communityFeature and not community_feature_toggle + self.read_only = not car_recognized or not controller_available or \ + self.CP.dashcamOnly or community_feature_disallowed + if self.read_only: + self.CP.safetyModel = car.CarParams.SafetyModel.noOutput + + # Write CarParams for radard and boardd safety mode + cp_bytes = self.CP.to_bytes() + params.put("CarParams", cp_bytes) + put_nonblocking("CarParamsCache", cp_bytes) + + self.CC = car.CarControl.new_message() + self.AM = AlertManager() + self.events = Events() + + self.LoC = LongControl(self.CP, self.CI.compute_gb) + self.VM = VehicleModel(self.CP) + + if self.CP.lateralTuning.which() == 'pid': + self.LaC = LatControlPID(self.CP) + elif self.CP.lateralTuning.which() == 'indi': + self.LaC = LatControlINDI(self.CP) + elif self.CP.lateralTuning.which() == 'lqr': + self.LaC = LatControlLQR(self.CP) + + self.state = State.disabled + self.enabled = False + self.active = False + self.can_rcv_error = False + self.soft_disable_timer = 0 + self.v_cruise_kph = 255 + self.v_cruise_kph_last = 0 + self.mismatch_counter = 0 + self.can_error_counter = 0 + self.last_blinker_frame = 0 + self.saturated_count = 0 + self.distance_traveled = 0 + self.last_functional_fan_frame = 0 + self.events_prev = [] + self.current_alert_types = [ET.PERMANENT] + + self.sm['liveCalibration'].calStatus = Calibration.CALIBRATED + self.sm['thermal'].freeSpace = 1. + self.sm['dMonitoringState'].events = [] + self.sm['dMonitoringState'].awarenessStatus = 1. + self.sm['dMonitoringState'].faceDetected = False + + self.startup_event = get_startup_event(car_recognized, controller_available) + if not sounds_available: + self.events.add(EventName.soundsUnavailable, static=True) + if internet_needed: + self.events.add(EventName.internetConnectivityNeeded, static=True) + if community_feature_disallowed: + self.events.add(EventName.communityFeatureDisallowed, static=True) + if not car_recognized: + self.events.add(EventName.carUnrecognized, static=True) + + # controlsd is driven by can recv, expected at 100Hz + self.rk = Ratekeeper(100, print_delay_threshold=None) + self.prof = Profiler(False) # off by default + + def update_events(self, CS): + """Compute carEvents from carState""" + + self.events.clear() + self.events.add_from_msg(CS.events) + self.events.add_from_msg(self.sm['dMonitoringState'].events) + + # Handle startup event + if self.startup_event is not None: + self.events.add(self.startup_event) + self.startup_event = None + + # Create events for battery, temperature, disk space, and memory + if self.sm['thermal'].batteryPercent < 1 and self.sm['thermal'].chargingError: + # at zero percent battery, while discharging, OP should not allowed + self.events.add(EventName.lowBattery) + if self.sm['thermal'].thermalStatus >= ThermalStatus.red: + self.events.add(EventName.overheat) + if self.sm['thermal'].freeSpace < 0.07: + # under 7% of space free no enable allowed + self.events.add(EventName.outOfSpace) + if self.sm['thermal'].memUsedPercent > 90: + self.events.add(EventName.lowMemory) + + # Alert if fan isn't spinning for 5 seconds + if self.sm['health'].hwType in [HwType.uno, HwType.dos]: + if self.sm['health'].fanSpeedRpm == 0 and self.sm['thermal'].fanSpeed > 50: + if (self.sm.frame - self.last_functional_fan_frame) * DT_CTRL > 5.0: + self.events.add(EventName.fanMalfunction) + else: + self.last_functional_fan_frame = self.sm.frame -def isActive(state): - """Check if the actuators are enabled""" - return state in [State.enabled, State.softDisabling] + # Handle calibration status + cal_status = self.sm['liveCalibration'].calStatus + if cal_status != Calibration.CALIBRATED: + if cal_status == Calibration.UNCALIBRATED: + self.events.add(EventName.calibrationIncomplete) + else: + self.events.add(EventName.calibrationInvalid) + + # Handle lane change + if self.sm['pathPlan'].laneChangeState == LaneChangeState.preLaneChange: + direction = self.sm['pathPlan'].laneChangeDirection + if (CS.leftBlindspot and direction == LaneChangeDirection.left) or \ + (CS.rightBlindspot and direction == LaneChangeDirection.right): + self.events.add(EventName.laneChangeBlocked) + else: + if direction == LaneChangeDirection.left: + self.events.add(EventName.preLaneChangeLeft) + else: + self.events.add(EventName.preLaneChangeRight) + elif self.sm['pathPlan'].laneChangeState in [LaneChangeState.laneChangeStarting, + LaneChangeState.laneChangeFinishing]: + self.events.add(EventName.laneChange) + + if self.can_rcv_error or (not CS.canValid and self.sm.frame > 5 / DT_CTRL): + self.events.add(EventName.canError) + if (self.sm['health'].safetyModel != self.CP.safetyModel and self.sm.frame > 2 / DT_CTRL) or \ + self.mismatch_counter >= 200: + self.events.add(EventName.controlsMismatch) + if not self.sm.alive['plan'] and self.sm.alive['pathPlan']: + # only plan not being received: radar not communicating + self.events.add(EventName.radarCommIssue) + elif not self.sm.all_alive_and_valid(): + self.events.add(EventName.commIssue) + logAllAliveAndValidInfoToTinklad(sm=self.sm, tinklaClient=self.tinklaClient) + if not self.sm['pathPlan'].mpcSolutionValid: + self.events.add(EventName.plannerError) + if not self.sm['liveLocationKalman'].sensorsOK and not NOSENSOR: + if self.sm.frame > 5 / DT_CTRL: # Give locationd some time to receive all the inputs + self.events.add(EventName.sensorDataInvalid) + if not self.sm['liveLocationKalman'].gpsOK and (self.distance_traveled > 1000): + # Not show in first 1 km to allow for driving out of garage. This event shows after 5 minutes + if not (SIMULATION or NOSENSOR): # TODO: send GPS in carla + self.events.add(EventName.noGps) + if not self.sm['pathPlan'].paramsValid: + self.events.add(EventName.vehicleModelInvalid) + if not self.sm['liveLocationKalman'].posenetOK: + self.events.add(EventName.posenetInvalid) + if not self.sm['liveLocationKalman'].deviceStable: + self.events.add(EventName.deviceFalling) + if not self.sm['plan'].radarValid: + self.events.add(EventName.radarFault) + if self.sm['plan'].radarCanError: + self.events.add(EventName.radarCanError) + if log.HealthData.FaultType.relayMalfunction in self.sm['health'].faults: + self.events.add(EventName.relayMalfunction) + if self.sm['plan'].fcw: + self.events.add(EventName.fcw) + if not self.sm.alive['frontFrame'] and (self.sm.frame > 5 / DT_CTRL) and not SIMULATION: + self.events.add(EventName.cameraMalfunction) + + if self.sm['model'].frameDropPerc > 20 and not SIMULATION: + self.events.add(EventName.modeldLagging) + # Only allow engagement with brake pressed when stopped behind another stopped car + if CS.brakePressed and self.sm['plan'].vTargetFuture >= STARTING_TARGET_SPEED \ + and self.CP.openpilotLongitudinalControl and CS.vEgo < 0.3: + self.events.add(EventName.noTarget) -def isEnabled(state): - """Check if openpilot is engaged""" - return (isActive(state) or state == State.preEnabled) + def data_sample(self): + """Receive data from sockets and update carState""" -def events_to_bytes(events): - # optimization when comparing capnp structs: str() or tree traverse are much slower - ret = [] - for e in events: - if isinstance(e, capnp.lib.capnp._DynamicStructReader): - e = e.as_builder() - ret.append(e.to_bytes()) - return ret + # Update carState from CAN + can_strs = messaging.drain_sock_raw(self.can_sock, wait_for_one=True) + CS = self.CI.update(self.CC, can_strs) -def wait_for_can(logcan): - print("Waiting for CAN messages...") - while len(messaging.recv_one(logcan).can) == 0: - pass + self.sm.update(0) -def data_sample(CI, CC, sm, can_sock, cal_status, cal_perc, overtemp, free_space, low_battery, - driver_status, state, mismatch_counter, params): - """Receive data from sockets and create events for battery, temperature and disk space""" + # Check for CAN timeout + if not can_strs: + self.can_error_counter += 1 + self.can_rcv_error = True + else: + self.can_rcv_error = False - # Update carstate from CAN and create events - can_strs = messaging.drain_sock_raw(can_sock, wait_for_one=True) - CS = CI.update(CC, can_strs) + # When the panda and controlsd do not agree on controls_allowed + # we want to disengage openpilot. However the status from the panda goes through + # another socket other than the CAN messages and one can arrive earlier than the other. + # Therefore we allow a mismatch for two samples, then we trigger the disengagement. + if not self.enabled: + self.mismatch_counter = 0 - sm.update(0) + if not self.sm['health'].controlsAllowed and self.enabled: + self.mismatch_counter += 1 - events = list(CS.events) - enabled = isEnabled(state) + self.distance_traveled += CS.vEgo * DT_CTRL - # Check for CAN timeout - if not can_strs: - events.append(create_event('canError', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) + return CS - if sm.updated['thermal']: - overtemp = sm['thermal'].thermalStatus >= ThermalStatus.red - free_space = sm['thermal'].freeSpace < 0.07 # under 7% of space free no enable allowed - low_battery = sm['thermal'].batteryPercent < 1 and sm['thermal'].chargingError # at zero percent battery, while discharging, OP should not allowed + def state_transition(self, CS): + """Compute conditional state transitions and execute actions on state transitions""" - # Create events for battery, temperature and disk space - if low_battery: - events.append(create_event('lowBattery', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if overtemp: - events.append(create_event('overheat', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if free_space: - events.append(create_event('outOfSpace', [ET.NO_ENTRY])) + self.v_cruise_kph_last = self.v_cruise_kph + # if stock cruise is completely disabled, then we can use our own set speed logic + if not self.CP.enableCruise: + self.v_cruise_kph = update_v_cruise(self.v_cruise_kph, CS.buttonEvents, self.enabled) + elif self.CP.enableCruise and CS.cruiseState.enabled: + self.v_cruise_kph = CS.cruiseState.speed * CV.MS_TO_KPH - # Handle calibration - if sm.updated['liveCalibration']: - cal_status = sm['liveCalibration'].calStatus - cal_perc = sm['liveCalibration'].calPerc + # decrease the soft disable timer at every step, as it's reset on + # entrance in SOFT_DISABLING state + self.soft_disable_timer = max(0, self.soft_disable_timer - 1) - cal_rpy = [0,0,0] - if cal_status != Calibration.CALIBRATED: - if cal_status == Calibration.UNCALIBRATED: - events.append(create_event('calibrationIncomplete', [ET.NO_ENTRY, ET.SOFT_DISABLE, ET.PERMANENT])) - else: - events.append(create_event('calibrationInvalid', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - else: - rpy = sm['liveCalibration'].rpyCalib - if len(rpy) == 3: - cal_rpy = rpy - - # When the panda and controlsd do not agree on controls_allowed - # we want to disengage openpilot. However the status from the panda goes through - # another socket other than the CAN messages and one can arrive earlier than the other. - # Therefore we allow a mismatch for two samples, then we trigger the disengagement. - if not enabled: - mismatch_counter = 0 - - if sm.updated['health']: - controls_allowed = sm['health'].controlsAllowed - if not controls_allowed and enabled: - mismatch_counter += 1 - if mismatch_counter >= 2: - events.append(create_event('controlsMismatch', [ET.IMMEDIATE_DISABLE])) - - # Driver monitoring - if sm.updated['driverMonitoring']: - driver_status.get_pose(sm['driverMonitoring'], params, cal_rpy) - - if driver_status.terminal_alert_cnt >= MAX_TERMINAL_ALERTS: - events.append(create_event("tooDistracted", [ET.NO_ENTRY])) - - return CS, events, cal_status, cal_perc, overtemp, free_space, low_battery, mismatch_counter - - -def state_transition(frame, CS, CP, state, events, soft_disable_timer, v_cruise_kph, AM): - """Compute conditional state transitions and execute actions on state transitions""" - enabled = isEnabled(state) - - v_cruise_kph_last = v_cruise_kph - - # if stock cruise is completely disabled, then we can use our own set speed logic - if not CP.enableCruise: - v_cruise_kph = update_v_cruise(v_cruise_kph, CS.buttonEvents, enabled) - elif CP.enableCruise and CS.cruiseState.enabled: - v_cruise_kph = CS.cruiseState.speed * CV.MS_TO_KPH - - # decrease the soft disable timer at every step, as it's reset on - # entrance in SOFT_DISABLING state - soft_disable_timer = max(0, soft_disable_timer - 1) - - # DISABLED - if state == State.disabled: - if get_events(events, [ET.ENABLE]): - if get_events(events, [ET.NO_ENTRY]): - for e in get_events(events, [ET.NO_ENTRY]): - AM.add(frame, str(e) + "NoEntry", enabled) + self.current_alert_types = [ET.PERMANENT] + + # ENABLED, PRE ENABLING, SOFT DISABLING + if self.state != State.disabled: + # user and immediate disable always have priority in a non-disabled state + if self.events.any(ET.USER_DISABLE): + self.state = State.disabled + self.current_alert_types.append(ET.USER_DISABLE) + + elif self.events.any(ET.IMMEDIATE_DISABLE): + self.state = State.disabled + self.current_alert_types.append(ET.IMMEDIATE_DISABLE) else: - if get_events(events, [ET.PRE_ENABLE]): - state = State.preEnabled - else: - state = State.enabled - AM.add(frame, "enable", enabled) - v_cruise_kph = initialize_v_cruise(CS.vEgo, CS.buttonEvents, v_cruise_kph_last) - - # ENABLED - elif state == State.enabled: - if get_events(events, [ET.USER_DISABLE]): - state = State.disabled - AM.add(frame, "disable", enabled) - - elif get_events(events, [ET.IMMEDIATE_DISABLE]): - state = State.disabled - for e in get_events(events, [ET.IMMEDIATE_DISABLE]): - AM.add(frame, e, enabled) - - elif get_events(events, [ET.SOFT_DISABLE]): - state = State.softDisabling - soft_disable_timer = 300 # 3s - for e in get_events(events, [ET.SOFT_DISABLE]): - AM.add(frame, e, enabled) - - # SOFT DISABLING - elif state == State.softDisabling: - if get_events(events, [ET.USER_DISABLE]): - state = State.disabled - AM.add(frame, "disable", enabled) - - elif get_events(events, [ET.IMMEDIATE_DISABLE]): - state = State.disabled - for e in get_events(events, [ET.IMMEDIATE_DISABLE]): - AM.add(frame, e, enabled) - - elif not get_events(events, [ET.SOFT_DISABLE]): - # no more soft disabling condition, so go back to ENABLED - state = State.enabled - - elif get_events(events, [ET.SOFT_DISABLE]) and soft_disable_timer > 0: - for e in get_events(events, [ET.SOFT_DISABLE]): - AM.add(frame, e, enabled) - - elif soft_disable_timer <= 0: - state = State.disabled - - # PRE ENABLING - elif state == State.preEnabled: - if get_events(events, [ET.USER_DISABLE]): - state = State.disabled - AM.add(frame, "disable", enabled) - - elif get_events(events, [ET.IMMEDIATE_DISABLE, ET.SOFT_DISABLE]): - state = State.disabled - for e in get_events(events, [ET.IMMEDIATE_DISABLE, ET.SOFT_DISABLE]): - AM.add(frame, e, enabled) - - elif not get_events(events, [ET.PRE_ENABLE]): - state = State.enabled - - return state, soft_disable_timer, v_cruise_kph, v_cruise_kph_last - - -def state_control(frame, rcv_frame, plan, path_plan, live_params, CS, CP, state, events, v_cruise_kph, v_cruise_kph_last, - AM, rk, driver_status, LaC, LoC, VM, read_only, is_metric, cal_perc): - """Given the state, this function returns an actuators packet""" - - actuators = car.CarControl.Actuators.new_message() - - enabled = isEnabled(state) - active = isActive(state) - - # check if user has interacted with the car - driver_engaged = len(CS.buttonEvents) > 0 or \ - v_cruise_kph != v_cruise_kph_last or \ - CS.steeringPressed - - # add eventual driver distracted events - events = driver_status.update(events, driver_engaged, isActive(state), CS.standstill) - - # send FCW alert if triggered by planner - if plan.fcw: - AM.add(frame, "fcw", enabled) - - # State specific actions - - if state in [State.preEnabled, State.disabled]: - LaC.reset() - LoC.reset(v_pid=CS.vEgo) - - elif state in [State.enabled, State.softDisabling]: - # parse warnings from car specific interface - for e in get_events(events, [ET.WARNING]): - extra_text = "" - if e == "belowSteerSpeed": - if is_metric: - extra_text = str(int(round(CP.minSteerSpeed * CV.MS_TO_KPH))) + " kph" + # ENABLED + if self.state == State.enabled: + if self.events.any(ET.SOFT_DISABLE): + self.state = State.softDisabling + self.soft_disable_timer = 300 # 3s + self.current_alert_types.append(ET.SOFT_DISABLE) + + # SOFT DISABLING + elif self.state == State.softDisabling: + if not self.events.any(ET.SOFT_DISABLE): + # no more soft disabling condition, so go back to ENABLED + self.state = State.enabled + + elif self.events.any(ET.SOFT_DISABLE) and self.soft_disable_timer > 0: + self.current_alert_types.append(ET.SOFT_DISABLE) + + elif self.soft_disable_timer <= 0: + self.state = State.disabled + + # PRE ENABLING + elif self.state == State.preEnabled: + if not self.events.any(ET.PRE_ENABLE): + self.state = State.enabled + else: + self.current_alert_types.append(ET.PRE_ENABLE) + + # DISABLED + elif self.state == State.disabled: + if self.events.any(ET.ENABLE): + if self.events.any(ET.NO_ENTRY): + self.current_alert_types.append(ET.NO_ENTRY) + else: - extra_text = str(int(round(CP.minSteerSpeed * CV.MS_TO_MPH))) + " mph" - AM.add(frame, e, enabled, extra_text_2=extra_text) - - plan_age = DT_CTRL * (frame - rcv_frame['plan']) - dt = min(plan_age, LON_MPC_STEP + DT_CTRL) + DT_CTRL # no greater than dt mpc + dt, to prevent too high extraps - - a_acc_sol = plan.aStart + (dt / LON_MPC_STEP) * (plan.aTarget - plan.aStart) - v_acc_sol = plan.vStart + dt * (a_acc_sol + plan.aStart) / 2.0 - - # Gas/Brake PID loop - actuators.gas, actuators.brake = LoC.update(active, CS.vEgo, CS.brakePressed, CS.standstill, CS.cruiseState.standstill, - v_cruise_kph, v_acc_sol, plan.vTargetFuture, a_acc_sol, CP) - # Steering PID loop and lateral MPC - actuators.steer, actuators.steerAngle, lac_log = LaC.update(active, CS.vEgo, CS.steeringAngle, CS.steeringRate, CS.steeringTorqueEps, CS.steeringPressed, CP, VM, path_plan) - - # Send a "steering required alert" if saturation count has reached the limit - if LaC.sat_flag and CP.steerLimitAlert: - AM.add(frame, "steerSaturated", enabled) - - # Parse permanent warnings to display constantly - for e in get_events(events, [ET.PERMANENT]): - extra_text_1, extra_text_2 = "", "" - if e == "calibrationIncomplete": - extra_text_1 = str(cal_perc) + "%" - if is_metric: - extra_text_2 = str(int(round(Filter.MIN_SPEED * CV.MS_TO_KPH))) + " kph" - else: - extra_text_2 = str(int(round(Filter.MIN_SPEED * CV.MS_TO_MPH))) + " mph" - AM.add(frame, str(e) + "Permanent", enabled, extra_text_1=extra_text_1, extra_text_2=extra_text_2) - - AM.process_alerts(frame) - - return actuators, v_cruise_kph, driver_status, v_acc_sol, a_acc_sol, lac_log - - -def data_send(sm, CS, CI, CP, VM, state, events, actuators, v_cruise_kph, rk, carstate, - carcontrol, carevents, carparams, controlsstate, sendcan, AM, driver_status, - LaC, LoC, read_only, start_time, v_acc, a_acc, lac_log, events_prev): - """Send actuators and hud commands to the car, send controlsstate and MPC logging""" - - CC = car.CarControl.new_message() - CC.enabled = isEnabled(state) - CC.actuators = actuators - - CC.cruiseControl.override = True - CC.cruiseControl.cancel = not CP.enableCruise or (not isEnabled(state) and CS.cruiseState.enabled) - - # Some override values for Honda - brake_discount = (1.0 - clip(actuators.brake * 3., 0.0, 1.0)) # brake discount removes a sharp nonlinearity - CC.cruiseControl.speedOverride = float(max(0.0, (LoC.v_pid + CS.cruiseState.speedOffset) * brake_discount) if CP.enableCruise else 0.0) - CC.cruiseControl.accelOverride = CI.calc_accel_override(CS.aEgo, sm['plan'].aTarget, CS.vEgo, sm['plan'].vTarget) - - CC.hudControl.setSpeed = float(v_cruise_kph * CV.KPH_TO_MS) - CC.hudControl.speedVisible = isEnabled(state) - CC.hudControl.lanesVisible = isEnabled(state) - CC.hudControl.leadVisible = sm['plan'].hasLead - - right_lane_visible = sm['pathPlan'].rProb > 0.5 - left_lane_visible = sm['pathPlan'].lProb > 0.5 - - CC.hudControl.rightLaneVisible = bool(right_lane_visible) - CC.hudControl.leftLaneVisible = bool(left_lane_visible) - - blinker = CS.leftBlinker or CS.rightBlinker - ldw_allowed = CS.vEgo > 12.5 and not blinker - - if len(list(sm['pathPlan'].rPoly)) == 4: - CC.hudControl.rightLaneDepart = bool(ldw_allowed and sm['pathPlan'].rPoly[3] > -(1.08 + CAMERA_OFFSET) and right_lane_visible) - if len(list(sm['pathPlan'].lPoly)) == 4: - CC.hudControl.leftLaneDepart = bool(ldw_allowed and sm['pathPlan'].lPoly[3] < (1.08 - CAMERA_OFFSET) and left_lane_visible) - - CC.hudControl.visualAlert = AM.visual_alert - - if not read_only: - # send car controls over can - can_sends = CI.apply(CC) - sendcan.send(can_list_to_can_capnp(can_sends, msgtype='sendcan', valid=CS.canValid)) - - force_decel = driver_status.awareness < 0. - - # controlsState - dat = messaging.new_message() - dat.init('controlsState') - dat.valid = CS.canValid - dat.controlsState = { - "alertText1": AM.alert_text_1, - "alertText2": AM.alert_text_2, - "alertSize": AM.alert_size, - "alertStatus": AM.alert_status, - "alertBlinkingRate": AM.alert_rate, - "alertType": AM.alert_type, - "alertSound": AM.audible_alert, - "awarenessStatus": max(driver_status.awareness, 0.0) if isEnabled(state) else 0.0, - "driverMonitoringOn": bool(driver_status.monitor_on and driver_status.face_detected), - "canMonoTimes": list(CS.canMonoTimes), - "planMonoTime": sm.logMonoTime['plan'], - "pathPlanMonoTime": sm.logMonoTime['pathPlan'], - "enabled": isEnabled(state), - "active": isActive(state), - "vEgo": CS.vEgo, - "vEgoRaw": CS.vEgoRaw, - "angleSteers": CS.steeringAngle, - "curvature": VM.calc_curvature((CS.steeringAngle - sm['pathPlan'].angleOffset) * CV.DEG_TO_RAD, CS.vEgo), - "steerOverride": CS.steeringPressed, - "state": state, - "engageable": not bool(get_events(events, [ET.NO_ENTRY])), - "longControlState": LoC.long_control_state, - "vPid": float(LoC.v_pid), - "vCruise": float(v_cruise_kph), - "upAccelCmd": float(LoC.pid.p), - "uiAccelCmd": float(LoC.pid.i), - "ufAccelCmd": float(LoC.pid.f), - "angleSteersDes": float(LaC.angle_steers_des), - "vTargetLead": float(v_acc), - "aTarget": float(a_acc), - "jerkFactor": float(sm['plan'].jerkFactor), - "angleModelBias": 0., - "gpsPlannerActive": sm['plan'].gpsPlannerActive, - "vCurvature": sm['plan'].vCurvature, - "decelForModel": sm['plan'].longitudinalPlanSource == log.Plan.LongitudinalPlanSource.model, - "cumLagMs": -rk.remaining * 1000., - "startMonoTime": int(start_time * 1e9), - "mapValid": sm['plan'].mapValid, - "forceDecel": bool(force_decel), - } - - if CP.lateralTuning.which() == 'pid': - dat.controlsState.lateralControlState.pidState = lac_log - elif CP.lateralTuning.which() == 'lqr': - dat.controlsState.lateralControlState.lqrState = lac_log - elif CP.lateralTuning.which() == 'indi': - dat.controlsState.lateralControlState.indiState = lac_log - controlsstate.send(dat.to_bytes()) - - # carState - cs_send = messaging.new_message() - cs_send.init('carState') - cs_send.valid = CS.canValid - cs_send.carState = CS - cs_send.carState.events = events - carstate.send(cs_send.to_bytes()) - - # carEvents - logged every second or on change - events_bytes = events_to_bytes(events) - if (sm.frame % int(1. / DT_CTRL) == 0) or (events_bytes != events_prev): - ce_send = messaging.new_message() - ce_send.init('carEvents', len(events)) - ce_send.carEvents = events - carevents.send(ce_send.to_bytes()) - - # carParams - logged every 50 seconds (> 1 per segment) - if (sm.frame % int(50. / DT_CTRL) == 0): - cp_send = messaging.new_message() - cp_send.init('carParams') - cp_send.carParams = CP - carparams.send(cp_send.to_bytes()) - - # carControl - cc_send = messaging.new_message() - cc_send.init('carControl') - cc_send.valid = CS.canValid - cc_send.carControl = CC - carcontrol.send(cc_send.to_bytes()) - - return CC, events_bytes - - -def controlsd_thread(gctx=None): - gc.disable() - - # start the loop - set_realtime_priority(3) - - params = Params() - - # Pub Sockets - sendcan = messaging.pub_sock(service_list['sendcan'].port) - controlsstate = messaging.pub_sock(service_list['controlsState'].port) - carstate = messaging.pub_sock(service_list['carState'].port) - carcontrol = messaging.pub_sock(service_list['carControl'].port) - carevents = messaging.pub_sock(service_list['carEvents'].port) - carparams = messaging.pub_sock(service_list['carParams'].port) - - is_metric = params.get("IsMetric") == "1" - passive = params.get("Passive") != "0" - - sm = messaging.SubMaster(['thermal', 'health', 'liveCalibration', 'driverMonitoring', 'plan', 'pathPlan', 'liveParameters']) - - logcan = messaging.sub_sock(service_list['can'].port) - - # wait for health and CAN packets - hw_type = messaging.recv_one(sm.sock['health']).health.hwType - is_panda_black = hw_type == log.HealthData.HwType.blackPanda - wait_for_can(logcan) - - CI, CP = get_car(logcan, sendcan, is_panda_black) - logcan.close() - - # TODO: Use the logcan socket from above, but that will currenly break the tests - can_timeout = None if os.environ.get('NO_CAN_TIMEOUT', False) else 100 - can_sock = messaging.sub_sock(service_list['can'].port, timeout=can_timeout) - - car_recognized = CP.carName != 'mock' - # If stock camera is disconnected, we loaded car controls and it's not chffrplus - controller_available = CP.enableCamera and CI.CC is not None and not passive - read_only = not car_recognized or not controller_available - if read_only: - CP.safetyModel = car.CarParams.SafetyModel.elm327 # diagnostic only - - # Write CarParams for radard and boardd safety mode - params.put("CarParams", CP.to_bytes()) - params.put("LongitudinalControl", "1" if CP.openpilotLongitudinalControl else "0") - - CC = car.CarControl.new_message() - AM = AlertManager() - - startup_alert = get_startup_alert(car_recognized, controller_available) - AM.add(sm.frame, startup_alert, False) - - LoC = LongControl(CP, CI.compute_gb) - VM = VehicleModel(CP) - - if CP.lateralTuning.which() == 'pid': - LaC = LatControlPID(CP) - elif CP.lateralTuning.which() == 'indi': - LaC = LatControlINDI(CP) - elif CP.lateralTuning.which() == 'lqr': - LaC = LatControlLQR(CP) - - driver_status = DriverStatus() - - state = State.disabled - soft_disable_timer = 0 - v_cruise_kph = 255 - v_cruise_kph_last = 0 - overtemp = False - free_space = False - cal_status = Calibration.INVALID - cal_perc = 0 - mismatch_counter = 0 - low_battery = False - events_prev = [] - - sm['pathPlan'].sensorValid = True - sm['pathPlan'].posenetValid = True + if self.events.any(ET.PRE_ENABLE): + self.state = State.preEnabled + else: + self.state = State.enabled + self.current_alert_types.append(ET.ENABLE) + self.v_cruise_kph = initialize_v_cruise(CS.vEgo, CS.buttonEvents, self.v_cruise_kph_last) - # detect sound card presence - sounds_available = not os.path.isfile('/EON') or (os.path.isdir('/proc/asound/card0') and open('/proc/asound/card0/state').read().strip() == 'ONLINE') + # Check if actuators are enabled + self.active = self.state == State.enabled or self.state == State.softDisabling + if self.active: + self.current_alert_types.append(ET.WARNING) - # controlsd is driven by can recv, expected at 100Hz - rk = Ratekeeper(100, print_delay_threshold=None) + # Check if openpilot is engaged + self.enabled = self.active or self.state == State.preEnabled - prof = Profiler(False) # off by default + def state_control(self, CS): + """Given the state, this function returns an actuators packet""" - while True: - start_time = sec_since_boot() - prof.checkpoint("Ratekeeper", ignore=True) - - # Sample data and compute car events - CS, events, cal_status, cal_perc, overtemp, free_space, low_battery, mismatch_counter =\ - data_sample(CI, CC, sm, can_sock, cal_status, cal_perc, overtemp, free_space, low_battery, - driver_status, state, mismatch_counter, params) - prof.checkpoint("Sample") - - # Create alerts - if not sm.all_alive_and_valid(): - events.append(create_event('commIssue', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if not sm['pathPlan'].mpcSolutionValid: - events.append(create_event('plannerError', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) - if not sm['pathPlan'].sensorValid: - events.append(create_event('sensorDataInvalid', [ET.NO_ENTRY, ET.PERMANENT])) - if not sm['pathPlan'].paramsValid: - events.append(create_event('vehicleModelInvalid', [ET.WARNING])) - if not sm['pathPlan'].posenetValid: - events.append(create_event('posenetInvalid', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if not sm['plan'].radarValid: - events.append(create_event('radarFault', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if sm['plan'].radarCanError: - events.append(create_event('radarCanError', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if not CS.canValid: - events.append(create_event('canError', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) - if not sounds_available: - events.append(create_event('soundsUnavailable', [ET.NO_ENTRY, ET.PERMANENT])) + plan = self.sm['plan'] + path_plan = self.sm['pathPlan'] - # Only allow engagement with brake pressed when stopped behind another stopped car - if CS.brakePressed and sm['plan'].vTargetFuture >= STARTING_TARGET_SPEED and not CP.radarOffCan and CS.vEgo < 0.3: - events.append(create_event('noTarget', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) + actuators = car.CarControl.Actuators.new_message() - if not read_only: - # update control state - state, soft_disable_timer, v_cruise_kph, v_cruise_kph_last = \ - state_transition(sm.frame, CS, CP, state, events, soft_disable_timer, v_cruise_kph, AM) - prof.checkpoint("State transition") + if CS.leftBlinker or CS.rightBlinker: + self.last_blinker_frame = self.sm.frame - # Compute actuators (runs PID loops and lateral MPC) - actuators, v_cruise_kph, driver_status, v_acc, a_acc, lac_log = \ - state_control(sm.frame, sm.rcv_frame, sm['plan'], sm['pathPlan'], sm['liveParameters'], CS, CP, state, events, v_cruise_kph, v_cruise_kph_last, AM, rk, - driver_status, LaC, LoC, VM, read_only, is_metric, cal_perc) + # State specific actions - rk.keep_time(1. / 10000) # Run at 100Hz - prof.checkpoint("State Control") + if not self.active: + self.LaC.reset() + self.LoC.reset(v_pid=CS.vEgo) - # Publish data - CC, events_prev = data_send(sm, CS, CI, CP, VM, state, events, actuators, v_cruise_kph, rk, carstate, carcontrol, carevents, carparams, - controlsstate, sendcan, AM, driver_status, LaC, LoC, read_only, start_time, v_acc, a_acc, lac_log, events_prev) - prof.checkpoint("Sent") + plan_age = DT_CTRL * (self.sm.frame - self.sm.rcv_frame['plan']) + # no greater than dt mpc + dt, to prevent too high extraps + dt = min(plan_age, LON_MPC_STEP + DT_CTRL) + DT_CTRL + + a_acc_sol = plan.aStart + (dt / LON_MPC_STEP) * (plan.aTarget - plan.aStart) + v_acc_sol = plan.vStart + dt * (a_acc_sol + plan.aStart) / 2.0 - rk.monitor_time() - prof.display() + # Gas/Brake PID loop + actuators.gas, actuators.brake = self.LoC.update(self.active, CS, v_acc_sol, plan.vTargetFuture, a_acc_sol, self.CP) + # Steering PID loop and lateral MPC + actuators.steer, actuators.steerAngle, lac_log = self.LaC.update(self.active, CS, self.CP, path_plan) + # Check for difference between desired angle and angle for angle based control + angle_control_saturated = self.CP.steerControlType == car.CarParams.SteerControlType.angle and \ + abs(actuators.steerAngle - CS.steeringAngle) > STEER_ANGLE_SATURATION_THRESHOLD -def main(gctx=None): - controlsd_thread(gctx) + if angle_control_saturated and not CS.steeringPressed and self.active: + self.saturated_count += 1 + else: + self.saturated_count = 0 + + # Send a "steering required alert" if saturation count has reached the limit + if (lac_log.saturated and not CS.steeringPressed) or \ + (self.saturated_count > STEER_ANGLE_SATURATION_TIMEOUT): + # Check if we deviated from the path + left_deviation = actuators.steer > 0 and path_plan.dPoly[3] > 0.1 + right_deviation = actuators.steer < 0 and path_plan.dPoly[3] < -0.1 + + if left_deviation or right_deviation: + self.events.add(EventName.steerSaturated) + + return actuators, v_acc_sol, a_acc_sol, lac_log + + def publish_logs(self, CS, start_time, actuators, v_acc, a_acc, lac_log): + """Send actuators and hud commands to the car, send controlsstate and MPC logging""" + + CC = car.CarControl.new_message() + CC.enabled = self.enabled + CC.actuators = actuators + + CC.cruiseControl.override = True + CC.cruiseControl.cancel = not self.CP.enableCruise or (not self.enabled and CS.cruiseState.enabled) + + # Some override values for Honda + # brake discount removes a sharp nonlinearity + brake_discount = (1.0 - clip(actuators.brake * 3., 0.0, 1.0)) + speed_override = max(0.0, (self.LoC.v_pid + CS.cruiseState.speedOffset) * brake_discount) + CC.cruiseControl.speedOverride = float(speed_override if self.CP.enableCruise else 0.0) + CC.cruiseControl.accelOverride = self.CI.calc_accel_override(CS.aEgo, self.sm['plan'].aTarget, CS.vEgo, self.sm['plan'].vTarget) + + CC.hudControl.setSpeed = float(self.v_cruise_kph * CV.KPH_TO_MS) + CC.hudControl.speedVisible = self.enabled + CC.hudControl.lanesVisible = self.enabled + CC.hudControl.leadVisible = self.sm['plan'].hasLead + + right_lane_visible = self.sm['pathPlan'].rProb > 0.5 + left_lane_visible = self.sm['pathPlan'].lProb > 0.5 + CC.hudControl.rightLaneVisible = bool(right_lane_visible) + CC.hudControl.leftLaneVisible = bool(left_lane_visible) + + recent_blinker = (self.sm.frame - self.last_blinker_frame) * DT_CTRL < 5.0 # 5s blinker cooldown + ldw_allowed = self.is_ldw_enabled and CS.vEgo > LDW_MIN_SPEED and not recent_blinker \ + and not self.active and self.sm['liveCalibration'].calStatus == Calibration.CALIBRATED + + meta = self.sm['model'].meta + if len(meta.desirePrediction) and ldw_allowed: + l_lane_change_prob = meta.desirePrediction[Desire.laneChangeLeft - 1] + r_lane_change_prob = meta.desirePrediction[Desire.laneChangeRight - 1] + l_lane_close = left_lane_visible and (self.sm['pathPlan'].lPoly[3] < (1.08 - CAMERA_OFFSET)) + r_lane_close = right_lane_visible and (self.sm['pathPlan'].rPoly[3] > -(1.08 + CAMERA_OFFSET)) + + CC.hudControl.leftLaneDepart = bool(l_lane_change_prob > LANE_DEPARTURE_THRESHOLD and l_lane_close) + CC.hudControl.rightLaneDepart = bool(r_lane_change_prob > LANE_DEPARTURE_THRESHOLD and r_lane_close) + + if CC.hudControl.rightLaneDepart or CC.hudControl.leftLaneDepart: + self.events.add(EventName.ldw) + + clear_event = ET.WARNING if ET.WARNING not in self.current_alert_types else None + alerts = self.events.create_alerts(self.current_alert_types, [self.CP, self.sm, self.is_metric]) + self.AM.add_many(self.sm.frame, alerts, self.enabled) + self.AM.process_alerts(self.sm.frame, clear_event) + CC.hudControl.visualAlert = self.AM.visual_alert + + if not self.read_only: + # send car controls over can + can_sends = self.CI.apply(CC) + self.pm.send('sendcan', can_list_to_can_capnp(can_sends, msgtype='sendcan', valid=CS.canValid)) + + force_decel = (self.sm['dMonitoringState'].awarenessStatus < 0.) or \ + (self.state == State.softDisabling) + + steer_angle_rad = (CS.steeringAngle - self.sm['pathPlan'].angleOffset) * CV.DEG_TO_RAD + + # controlsState + dat = messaging.new_message('controlsState') + dat.valid = CS.canValid + controlsState = dat.controlsState + controlsState.alertText1 = self.AM.alert_text_1 + controlsState.alertText2 = self.AM.alert_text_2 + controlsState.alertSize = self.AM.alert_size + controlsState.alertStatus = self.AM.alert_status + controlsState.alertBlinkingRate = self.AM.alert_rate + controlsState.alertType = self.AM.alert_type + controlsState.alertSound = self.AM.audible_alert + controlsState.driverMonitoringOn = self.sm['dMonitoringState'].faceDetected + controlsState.canMonoTimes = list(CS.canMonoTimes) + controlsState.planMonoTime = self.sm.logMonoTime['plan'] + controlsState.pathPlanMonoTime = self.sm.logMonoTime['pathPlan'] + controlsState.enabled = self.enabled + controlsState.active = self.active + controlsState.vEgo = CS.vEgo + controlsState.vEgoRaw = CS.vEgoRaw + controlsState.angleSteers = CS.steeringAngle + controlsState.curvature = self.VM.calc_curvature(steer_angle_rad, CS.vEgo) + controlsState.steerOverride = CS.steeringPressed + controlsState.state = self.state + controlsState.engageable = not self.events.any(ET.NO_ENTRY) + controlsState.longControlState = self.LoC.long_control_state + controlsState.vPid = float(self.LoC.v_pid) + controlsState.vCruise = float(self.v_cruise_kph) + controlsState.upAccelCmd = float(self.LoC.pid.p) + controlsState.uiAccelCmd = float(self.LoC.pid.i) + controlsState.ufAccelCmd = float(self.LoC.pid.f) + controlsState.angleSteersDes = float(self.LaC.angle_steers_des) + controlsState.vTargetLead = float(v_acc) + controlsState.aTarget = float(a_acc) + controlsState.jerkFactor = float(self.sm['plan'].jerkFactor) + controlsState.gpsPlannerActive = self.sm['plan'].gpsPlannerActive + controlsState.vCurvature = self.sm['plan'].vCurvature + controlsState.decelForModel = self.sm['plan'].longitudinalPlanSource == LongitudinalPlanSource.model + controlsState.cumLagMs = -self.rk.remaining * 1000. + controlsState.startMonoTime = int(start_time * 1e9) + controlsState.mapValid = self.sm['plan'].mapValid + controlsState.forceDecel = bool(force_decel) + controlsState.canErrorCounter = self.can_error_counter + + if self.CP.lateralTuning.which() == 'pid': + controlsState.lateralControlState.pidState = lac_log + elif self.CP.lateralTuning.which() == 'lqr': + controlsState.lateralControlState.lqrState = lac_log + elif self.CP.lateralTuning.which() == 'indi': + controlsState.lateralControlState.indiState = lac_log + self.pm.send('controlsState', dat) + + # carState + car_events = self.events.to_msg() + cs_send = messaging.new_message('carState') + cs_send.valid = CS.canValid + cs_send.carState = CS + cs_send.carState.events = car_events + self.pm.send('carState', cs_send) + + # carEvents - logged every second or on change + if (self.sm.frame % int(1. / DT_CTRL) == 0) or (self.events.names != self.events_prev): + ce_send = messaging.new_message('carEvents', len(self.events)) + ce_send.carEvents = car_events + self.pm.send('carEvents', ce_send) + self.events_prev = self.events.names.copy() + + # carParams - logged every 50 seconds (> 1 per segment) + if (self.sm.frame % int(50. / DT_CTRL) == 0): + cp_send = messaging.new_message('carParams') + cp_send.carParams = self.CP + self.pm.send('carParams', cp_send) + + # carControl + cc_send = messaging.new_message('carControl') + cc_send.valid = CS.canValid + cc_send.carControl = CC + self.pm.send('carControl', cc_send) + + # copy CarControl to pass to CarInterface on the next iteration + self.CC = CC + + def step(self): + start_time = sec_since_boot() + self.prof.checkpoint("Ratekeeper", ignore=True) + # Sample data from sockets and get a carState + CS = self.data_sample() + self.prof.checkpoint("Sample") + + self.update_events(CS) + + if not self.read_only: + # Update control state + self.state_transition(CS) + self.prof.checkpoint("State transition") + + # Compute actuators (runs PID loops and lateral MPC) + actuators, v_acc, a_acc, lac_log = self.state_control(CS) + + self.prof.checkpoint("State Control") + + # Publish data + self.publish_logs(CS, start_time, actuators, v_acc, a_acc, lac_log) + self.prof.checkpoint("Sent") + + def controlsd_thread(self): + while True: + self.step() + self.rk.monitor_time() + self.prof.display() + +def logAllAliveAndValidInfoToTinklad(sm, tinklaClient): + # areAllAlive, aliveProcessName, aliveCount = sm.all_alive_with_info() + # areAllValid, validProcessName, validCount = sm.all_valid_with_info() + # if not areAllAlive: + # tinklaClient.logProcessCommErrorEvent(source="carcontroller", processName=aliveProcessName, count=aliveCount, eventType="Not Alive") + # else: + # tinklaClient.logProcessCommErrorEvent(source="carcontroller", processName=validProcessName, count=validCount, eventType="Not Valid") + pass + +def main(sm=None, pm=None, logcan=None): + controls = Controls(sm, pm, logcan) + controls.controlsd_thread() if __name__ == "__main__": main() diff --git a/selfdrive/controls/lib/alertmanager.py b/selfdrive/controls/lib/alertmanager.py index 77196273b6e402..44d6f987705ca0 100644 --- a/selfdrive/controls/lib/alertmanager.py +++ b/selfdrive/controls/lib/alertmanager.py @@ -1,60 +1,74 @@ +import os +import copy +import json +from typing import List, Optional + from cereal import car, log +from common.basedir import BASEDIR +from common.params import Params from common.realtime import DT_CTRL +from selfdrive.controls.lib.events import Alert from selfdrive.swaglog import cloudlog -from selfdrive.controls.lib.alerts import ALERTS -import copy -AlertSize = log.ControlsState.AlertSize -AlertStatus = log.ControlsState.AlertStatus -VisualAlert = car.CarControl.HUDControl.VisualAlert -AudibleAlert = car.CarControl.HUDControl.AudibleAlert +with open(os.path.join(BASEDIR, "selfdrive/controls/lib/alerts_offroad.json")) as f: + OFFROAD_ALERTS = json.load(f) -class AlertManager(object): - def __init__(self): - self.activealerts = [] - self.alerts = {alert.alert_type: alert for alert in ALERTS} +def set_offroad_alert(alert: str, show_alert: bool, extra_text: Optional[str] = None) -> None: + if show_alert: + a = OFFROAD_ALERTS[alert] + if extra_text is not None: + a = copy.copy(OFFROAD_ALERTS[alert]) + a['text'] += extra_text + Params().put(alert, json.dumps(a)) + else: + Params().delete(alert) - def alertPresent(self): - return len(self.activealerts) > 0 - def add(self, frame, alert_type, enabled=True, extra_text_1='', extra_text_2=''): - alert_type = str(alert_type) - added_alert = copy.copy(self.alerts[alert_type]) - added_alert.alert_text_1 += extra_text_1 - added_alert.alert_text_2 += extra_text_2 - added_alert.start_time = frame * DT_CTRL +class AlertManager: - # if new alert is higher priority, log it - if not self.alertPresent() or added_alert.alert_priority > self.activealerts[0].alert_priority: - cloudlog.event('alert_add', alert_type=alert_type, enabled=enabled) + def __init__(self): + self.activealerts: List[Alert] = [] + self.clear_current_alert() + + def clear_current_alert(self) -> None: + self.alert_type: str = "" + self.alert_text_1: str = "" + self.alert_text_2: str = "" + self.alert_status = log.ControlsState.AlertStatus.normal + self.alert_size = log.ControlsState.AlertSize.none + self.visual_alert = car.CarControl.HUDControl.VisualAlert.none + self.audible_alert = car.CarControl.HUDControl.AudibleAlert.none + self.alert_rate: float = 0. + + def add_many(self, frame: int, alerts: List[Alert], enabled: bool = True) -> None: + for alert in alerts: + added_alert = copy.copy(alert) + added_alert.start_time = frame * DT_CTRL + + # if new alert is higher priority, log it + if not len(self.activealerts) or added_alert.alert_priority > self.activealerts[0].alert_priority: + cloudlog.event('alert_add', alert_type=added_alert.alert_type, enabled=enabled) + + self.activealerts.append(added_alert) + + def process_alerts(self, frame: int, clear_event_type=None) -> None: + cur_time = frame * DT_CTRL - self.activealerts.append(added_alert) + # first get rid of all the expired alerts + self.activealerts = [a for a in self.activealerts if a.event_type != clear_event_type and + a.start_time + max(a.duration_sound, a.duration_hud_alert, a.duration_text) > cur_time] # sort by priority first and then by start_time self.activealerts.sort(key=lambda k: (k.alert_priority, k.start_time), reverse=True) - def process_alerts(self, frame): - cur_time = frame * DT_CTRL - - # first get rid of all the expired alerts - self.activealerts = [a for a in self.activealerts if a.start_time + - max(a.duration_sound, a.duration_hud_alert, a.duration_text) > cur_time] + # start with assuming no alerts + self.clear_current_alert() - current_alert = self.activealerts[0] if self.alertPresent() else None + if len(self.activealerts): + current_alert = self.activealerts[0] - # start with assuming no alerts - self.alert_type = "" - self.alert_text_1 = "" - self.alert_text_2 = "" - self.alert_status = AlertStatus.normal - self.alert_size = AlertSize.none - self.visual_alert = VisualAlert.none - self.audible_alert = AudibleAlert.none - self.alert_rate = 0. - - if current_alert: self.alert_type = current_alert.alert_type if current_alert.start_time + current_alert.duration_sound > cur_time: diff --git a/selfdrive/controls/lib/alerts.py b/selfdrive/controls/lib/alerts.py deleted file mode 100644 index 13fcd3c572d9d4..00000000000000 --- a/selfdrive/controls/lib/alerts.py +++ /dev/null @@ -1,697 +0,0 @@ -from cereal import car, log - -# Priority -class Priority: - LOWEST = 0 - LOW_LOWEST = 1 - LOW = 2 - MID = 3 - HIGH = 4 - HIGHEST = 5 - -AlertSize = log.ControlsState.AlertSize -AlertStatus = log.ControlsState.AlertStatus -AudibleAlert = car.CarControl.HUDControl.AudibleAlert -VisualAlert = car.CarControl.HUDControl.VisualAlert - -class Alert(object): - def __init__(self, - alert_type, - alert_text_1, - alert_text_2, - alert_status, - alert_size, - alert_priority, - visual_alert, - audible_alert, - duration_sound, - duration_hud_alert, - duration_text, - alert_rate=0.): - - self.alert_type = alert_type - self.alert_text_1 = alert_text_1 - self.alert_text_2 = alert_text_2 - self.alert_status = alert_status - self.alert_size = alert_size - self.alert_priority = alert_priority - self.visual_alert = visual_alert - self.audible_alert = audible_alert - - self.duration_sound = duration_sound - self.duration_hud_alert = duration_hud_alert - self.duration_text = duration_text - - self.start_time = 0. - self.alert_rate = alert_rate - - # typecheck that enums are valid on startup - tst = car.CarControl.new_message() - tst.hudControl.visualAlert = self.visual_alert - - def __str__(self): - return self.alert_text_1 + "/" + self.alert_text_2 + " " + str(self.alert_priority) + " " + str( - self.visual_alert) + " " + str(self.audible_alert) - - def __gt__(self, alert2): - return self.alert_priority > alert2.alert_priority - - -ALERTS = [ - # Miscellaneous alerts - Alert( - "enable", - "", - "", - AlertStatus.normal, AlertSize.none, - Priority.MID, VisualAlert.none, AudibleAlert.chimeEngage, .2, 0., 0.), - - Alert( - "disable", - "", - "", - AlertStatus.normal, AlertSize.none, - Priority.MID, VisualAlert.none, AudibleAlert.chimeDisengage, .2, 0., 0.), - - Alert( - "fcw", - "BRAKE!", - "Risk of Collision", - AlertStatus.critical, AlertSize.full, - Priority.HIGHEST, VisualAlert.fcw, AudibleAlert.chimeWarningRepeat, 1., 2., 2.), - - Alert( - "steerSaturated", - "TAKE CONTROL", - "Turn Exceeds Steering Limit", - AlertStatus.userPrompt, AlertSize.mid, - Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimePrompt, 1., 2., 3.), - - Alert( - "steerTempUnavailable", - "TAKE CONTROL", - "Steering Temporarily Unavailable", - AlertStatus.userPrompt, AlertSize.mid, - Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimeWarning1, .4, 2., 3.), - - Alert( - "steerTempUnavailableMute", - "TAKE CONTROL", - "Steering Temporarily Unavailable", - AlertStatus.userPrompt, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.none, .2, .2, .2), - - Alert( - "preDriverDistracted", - "KEEP EYES ON ROAD: User Appears Distracted", - "", - AlertStatus.normal, AlertSize.small, - Priority.LOW, VisualAlert.steerRequired, AudibleAlert.none, .0, .1, .1, alert_rate=0.75), - - Alert( - "promptDriverDistracted", - "KEEP EYES ON ROAD", - "User Appears Distracted", - AlertStatus.userPrompt, AlertSize.mid, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2, .1, .1, .1), - - Alert( - "driverDistracted", - "DISENGAGE IMMEDIATELY", - "User Was Distracted", - AlertStatus.critical, AlertSize.full, - Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, .1, .1, .1), - - Alert( - "preDriverUnresponsive", - "TOUCH STEERING WHEEL: No Driver Monitoring", - "", - AlertStatus.normal, AlertSize.small, - Priority.LOW, VisualAlert.steerRequired, AudibleAlert.none, .0, .1, .1, alert_rate=0.75), - - Alert( - "promptDriverUnresponsive", - "TOUCH STEERING WHEEL", - "User Is Unresponsive", - AlertStatus.userPrompt, AlertSize.mid, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2, .1, .1, .1), - - Alert( - "driverUnresponsive", - "DISENGAGE IMMEDIATELY", - "User Was Unresponsive", - AlertStatus.critical, AlertSize.full, - Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, .1, .1, .1), - - Alert( - "driverMonitorOff", - "DRIVER MONITOR IS UNAVAILABLE", - "Accuracy Is Low", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.none, .4, 0., 4.), - - Alert( - "driverMonitorOn", - "DRIVER MONITOR IS AVAILABLE", - "Accuracy Is High", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.none, .4, 0., 4.), - - Alert( - "geofence", - "DISENGAGEMENT REQUIRED", - "Not in Geofenced Area", - AlertStatus.userPrompt, AlertSize.mid, - Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, .1, .1, .1), - - Alert( - "startup", - "Be ready to take over at any time", - "Always keep hands on wheel and eyes on road", - AlertStatus.normal, AlertSize.mid, - Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., 15.), - - Alert( - "startupNoControl", - "Dashcam mode", - "Always keep hands on wheel and eyes on road", - AlertStatus.normal, AlertSize.mid, - Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., 15.), - - Alert( - "startupNoCar", - "Dashcam mode with unsupported car", - "If Tesla, please force fingerprint", - AlertStatus.normal, AlertSize.mid, - Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., 15.), - - Alert( - "ethicalDilemma", - "TAKE CONTROL IMMEDIATELY", - "Ethical Dilemma Detected", - AlertStatus.critical, AlertSize.full, - Priority.HIGHEST, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, 1., 3., 3.), - - Alert( - "steerTempUnavailableNoEntry", - "openpilot Unavailable", - "Steering Temporarily Unavailable", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 0., 3.), - - Alert( - "manualRestart", - "TAKE CONTROL", - "Resume Driving Manually", - AlertStatus.userPrompt, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2), - - Alert( - "resumeRequired", - "STOPPED", - "Press Resume to Move", - AlertStatus.userPrompt, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2), - - Alert( - "belowSteerSpeed", - "TAKE CONTROL", - "Steer Unavailable Below ", - AlertStatus.userPrompt, AlertSize.mid, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning1, 0., 0., .1), - - Alert( - "debugAlert", - "DEBUG ALERT", - "", - AlertStatus.userPrompt, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.none, .1, .1, .1), - - # Non-entry only alerts - Alert( - "wrongCarModeNoEntry", - "openpilot Unavailable", - "Main Switch Off", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 0., 3.), - - Alert( - "dataNeededNoEntry", - "openpilot Unavailable", - "Data Needed for Calibration. Upload Drive, Try Again", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 0., 3.), - - Alert( - "outOfSpaceNoEntry", - "openpilot Unavailable", - "Out of Storage Space", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 0., 3.), - - Alert( - "pedalPressedNoEntry", - "openpilot Unavailable", - "Pedal Pressed During Attempt", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, "brakePressed", AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "speedTooLowNoEntry", - "openpilot Unavailable", - "Speed Too Low", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "brakeHoldNoEntry", - "openpilot Unavailable", - "Brake Hold Active", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "parkBrakeNoEntry", - "openpilot Unavailable", - "Park Brake Engaged", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "lowSpeedLockoutNoEntry", - "openpilot Unavailable", - "Cruise Fault: Restart the Car", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "lowBatteryNoEntry", - "openpilot Unavailable", - "Low Battery", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "sensorDataInvalidNoEntry", - "openpilot Unavailable", - "No Data from EON Sensors", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "soundsUnavailableNoEntry", - "openpilot Unavailable", - "Speaker not found", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "tooDistractedNoEntry", - "openpilot Unavailable", - "Distraction Level Too High", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - # Cancellation alerts causing soft disabling - Alert( - "overheat", - "TAKE CONTROL IMMEDIATELY", - "System Overheated", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, .1, 2., 2.), - - Alert( - "wrongGear", - "TAKE CONTROL IMMEDIATELY", - "Gear not D", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, .1, 2., 2.), - - Alert( - "calibrationInvalid", - "TAKE CONTROL IMMEDIATELY", - "Calibration Invalid: Reposition EON and Recalibrate", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, .1, 2., 2.), - - Alert( - "calibrationIncomplete", - "TAKE CONTROL IMMEDIATELY", - "Calibration in Progress", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, .1, 2., 2.), - - Alert( - "doorOpen", - "TAKE CONTROL IMMEDIATELY", - "Door Open", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, .1, 2., 2.), - - Alert( - "seatbeltNotLatched", - "TAKE CONTROL IMMEDIATELY", - "Seatbelt Unlatched", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, .1, 2., 2.), - - Alert( - "espDisabled", - "TAKE CONTROL IMMEDIATELY", - "ESP Off", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, .1, 2., 2.), - - Alert( - "lowBattery", - "TAKE CONTROL IMMEDIATELY", - "Low Battery", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, .1, 2., 2.), - - Alert( - "commIssue", - "TAKE CONTROL IMMEDIATELY", - "Communication Issue between Processes", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, .1, 2., 2.), - - Alert( - "radarCanError", - "TAKE CONTROL IMMEDIATELY", - "Radar Error: Restart the Car", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, .1, 2., 2.), - - Alert( - "radarFault", - "TAKE CONTROL IMMEDIATELY", - "Radar Error: Restart the Car", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, .1, 2., 2.), - - Alert( - "posenetInvalid", - "TAKE CONTROL IMMEDIATELY", - "Vision Failure: Check Camera View", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, .1, 2., 2.), - - # Cancellation alerts causing immediate disabling - Alert( - "controlsFailed", - "TAKE CONTROL IMMEDIATELY", - "Controls Failed", - AlertStatus.critical, AlertSize.full, - Priority.HIGHEST, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, 1., 3., 4.), - - Alert( - "controlsMismatch", - "TAKE CONTROL IMMEDIATELY", - "Controls Mismatch", - AlertStatus.critical, AlertSize.full, - Priority.HIGHEST, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, 1., 3., 4.), - - Alert( - "canError", - "TAKE CONTROL IMMEDIATELY", - "CAN Error: Check Connections", - AlertStatus.critical, AlertSize.full, - Priority.HIGHEST, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, 1., 3., 4.), - - Alert( - "steerUnavailable", - "TAKE CONTROL IMMEDIATELY", - "LKAS Fault: Restart the Car", - AlertStatus.critical, AlertSize.full, - Priority.HIGHEST, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, 1., 3., 4.), - - Alert( - "brakeUnavailable", - "TAKE CONTROL IMMEDIATELY", - "Cruise Fault: Restart the Car", - AlertStatus.critical, AlertSize.full, - Priority.HIGHEST, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, 1., 3., 4.), - - Alert( - "gasUnavailable", - "TAKE CONTROL IMMEDIATELY", - "Gas Fault: Restart the Car", - AlertStatus.critical, AlertSize.full, - Priority.HIGHEST, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, 1., 3., 4.), - - Alert( - "reverseGear", - "TAKE CONTROL IMMEDIATELY", - "Reverse Gear", - AlertStatus.critical, AlertSize.full, - Priority.HIGHEST, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, 1., 3., 4.), - - Alert( - "cruiseDisabled", - "TAKE CONTROL IMMEDIATELY", - "Cruise Is Off", - AlertStatus.critical, AlertSize.full, - Priority.HIGHEST, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, 1., 3., 4.), - - Alert( - "plannerError", - "TAKE CONTROL IMMEDIATELY", - "Planner Solution Error", - AlertStatus.critical, AlertSize.full, - Priority.HIGHEST, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, 1., 3., 4.), - - # not loud cancellations (user is in control) - Alert( - "noTarget", - "openpilot Canceled", - "No close lead car", - AlertStatus.normal, AlertSize.mid, - Priority.HIGH, VisualAlert.none, AudibleAlert.chimeDisengage, .4, 2., 3.), - - Alert( - "speedTooLow", - "openpilot Canceled", - "Speed too low", - AlertStatus.normal, AlertSize.mid, - Priority.HIGH, VisualAlert.none, AudibleAlert.chimeDisengage, .4, 2., 3.), - - Alert( - "invalidGiraffeHonda", - "CAN Errors", - " ", - AlertStatus.normal, AlertSize.mid, - Priority.HIGH, VisualAlert.none, AudibleAlert.chimeDisengage, .4, 2., 3.), - - # Cancellation alerts causing non-entry - Alert( - "overheatNoEntry", - "openpilot Unavailable", - "System overheated", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "wrongGearNoEntry", - "openpilot Unavailable", - "Gear not D", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "calibrationInvalidNoEntry", - "openpilot Unavailable", - "Calibration Invalid: Reposition EON and Recalibrate", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "calibrationIncompleteNoEntry", - "openpilot Unavailable", - "Calibration in Progress", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "doorOpenNoEntry", - "openpilot Unavailable", - "Door open", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "seatbeltNotLatchedNoEntry", - "openpilot Unavailable", - "Seatbelt unlatched", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "espDisabledNoEntry", - "openpilot Unavailable", - "ESP Off", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "geofenceNoEntry", - "openpilot Unavailable", - "Not in Geofenced Area", - AlertStatus.normal, AlertSize.mid, - Priority.MID, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "radarCanErrorNoEntry", - "openpilot Unavailable", - "Radar Error: Restart the Car", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "radarFaultNoEntry", - "openpilot Unavailable", - "Radar Error: Restart the Car", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "posenetInvalidNoEntry", - "openpilot Unavailable", - "Vision Failure: Check Camera View", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "controlsFailedNoEntry", - "openpilot Unavailable", - "Controls Failed", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "canErrorNoEntry", - "openpilot Unavailable", - "CAN Error: Check Connections", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "steerUnavailableNoEntry", - "openpilot Unavailable", - "LKAS Fault: Restart the Car", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "brakeUnavailableNoEntry", - "openpilot Unavailable", - "Cruise Fault: Restart the Car", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "gasUnavailableNoEntry", - "openpilot Unavailable", - "Gas Error: Restart the Car", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "reverseGearNoEntry", - "openpilot Unavailable", - "Reverse Gear", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "cruiseDisabledNoEntry", - "openpilot Unavailable", - "Cruise is Off", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "noTargetNoEntry", - "openpilot Unavailable", - "No Close Lead Car", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "plannerErrorNoEntry", - "openpilot Unavailable", - "Planner Solution Error", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), - - Alert( - "invalidGiraffeHondaNoEntry", - "openpilot Unavailable", - "Set 0111 for openpilot. 1011 for stock", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeDisengage, .4, 2., 3.), - - Alert( - "commIssueNoEntry", - "openpilot unavailable", - "Communication Issue between Processes", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeDisengage, .4, 2., 3.), - - # permanent alerts - Alert( - "steerUnavailablePermanent", - "LKAS Fault: Restart the car to engage", - "", - AlertStatus.normal, AlertSize.small, - Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), - - Alert( - "brakeUnavailablePermanent", - "Cruise Fault: Restart the car to engage", - "", - AlertStatus.normal, AlertSize.small, - Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), - - Alert( - "lowSpeedLockoutPermanent", - "Cruise Fault: Restart the car to engage", - "", - AlertStatus.normal, AlertSize.small, - Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), - - Alert( - "calibrationIncompletePermanent", - "Calibration in Progress: ", - "Drive Above ", - AlertStatus.normal, AlertSize.mid, - Priority.LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), - - Alert( - "invalidGiraffeHondaPermanent", - "CAN Errors", - " ", - AlertStatus.normal, AlertSize.mid, - Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), - - Alert( - "sensorDataInvalidPermanent", - "No Data from EON Sensors", - "Reboot your EON", - AlertStatus.normal, AlertSize.mid, - Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), - - Alert( - "soundsUnavailablePermanent", - "Speaker not found", - "Reboot your EON", - AlertStatus.normal, AlertSize.mid, - Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), - - Alert( - "vehicleModelInvalid", - "Vehicle Parameter Identification Failed", - "", - AlertStatus.normal, AlertSize.small, - Priority.LOWEST, VisualAlert.steerRequired, AudibleAlert.none, .0, .0, .1), -] diff --git a/selfdrive/controls/lib/alerts_offroad.json b/selfdrive/controls/lib/alerts_offroad.json new file mode 100644 index 00000000000000..a47eb8c0a22fa8 --- /dev/null +++ b/selfdrive/controls/lib/alerts_offroad.json @@ -0,0 +1,44 @@ +{ + "Offroad_ChargeDisabled": { + "text": "EON charging disabled after car being off for more than 30 hours. Turn ignition on to start charging again.", + "severity": 0 + }, + "Offroad_TemperatureTooHigh": { + "text": "Device temperature too high. System won't start.", + "severity": 1 + }, + "Offroad_ConnectivityNeededPrompt": { + "text": "Immediately connect to the internet to check for updates. If you do not connect to the internet, openpilot won't engage in ", + "severity": 0, + "_comment": "Append the number of days at the end of the text" + }, + "Offroad_ConnectivityNeeded": { + "text": "Connect to internet to check for updates. openpilot won't engage until it connects to internet to check for updates.", + "severity": 1 + }, + "Offroad_UpdateFailed": { + "text": "Unable to download updates\n", + "severity": 1, + "_comment": "Append the command and error to the text." + }, + "Offroad_PandaFirmwareMismatch": { + "text": "Unexpected panda firmware version. System won't start. Reboot your device to reflash panda.", + "severity": 1 + }, + "Offroad_InvalidTime": { + "text": "Invalid date and time settings, system won't start. Connect to internet to set time.", + "severity": 1 + }, + "Offroad_IsTakingSnapshot": { + "text": "Taking camera snapshots. System won't start until finished.", + "severity": 0 + }, + "Offroad_NeosUpdate": { + "text": "An update to your device's operating system is downloading in the background. You will be prompted to update when it's ready to install.", + "severity": 0 + }, + "Offroad_HardwareUnsupported": { + "text": "White and grey panda are unsupported. Upgrade to comma two or black panda.", + "severity": 0 + } +} diff --git a/selfdrive/controls/lib/cluster/Makefile b/selfdrive/controls/lib/cluster/Makefile deleted file mode 100644 index ca4a23da59fa8c..00000000000000 --- a/selfdrive/controls/lib/cluster/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -CC = clang -CXX = clang++ - -CXXFLAGS = -Wall -g -fPIC -std=c++11 -O2 - -ifeq ($(ARCH),aarch64) -CXXFLAGS += -mcpu=cortex-a57 -endif - -OBJS = fastcluster.o test.o -DEPS := $(OBJS:.o=.d) - -all: libfastcluster.so - -test: libfastcluster.so test.o - $(CXX) -g -L. -lfastcluster -o $@ $+ - -valgrind: test - valgrind --leak-check=full ./test - - -libfastcluster.so: fastcluster.o - $(CXX) -g -shared -o $@ $+ - -%.o: %.cpp - $(CXX) $(CXXFLAGS) -MMD -c $*.cpp - -clean: - rm -f $(OBJS) $(DEPS) libfastcluster.so test - - --include $(DEPS) diff --git a/selfdrive/controls/lib/cluster/SConscript b/selfdrive/controls/lib/cluster/SConscript new file mode 100644 index 00000000000000..97eb4300d4da66 --- /dev/null +++ b/selfdrive/controls/lib/cluster/SConscript @@ -0,0 +1,8 @@ +Import('env') + +fc = env.SharedLibrary("fastcluster", "fastcluster.cpp") + +# TODO: how do I gate on test +#env.Program("test", ["test.cpp"], LIBS=[fc]) +#valgrind --leak-check=full ./test + diff --git a/selfdrive/controls/lib/cluster/fastcluster_dm.cpp b/selfdrive/controls/lib/cluster/fastcluster_dm.cpp index 8834bc24a04dd2..ee6670c2042420 100644 --- a/selfdrive/controls/lib/cluster/fastcluster_dm.cpp +++ b/selfdrive/controls/lib/cluster/fastcluster_dm.cpp @@ -49,8 +49,8 @@ #ifdef NO_INCLUDE_FENV #pragma message("Do not use fenv header.") #else -#pragma message("Use fenv header. If there is a warning about unknown #pragma STDC FENV_ACCESS, this can be ignored.") -#pragma STDC FENV_ACCESS on +//#pragma message("Use fenv header. If there is a warning about unknown #pragma STDC FENV_ACCESS, this can be ignored.") +//#pragma STDC FENV_ACCESS on #include #endif diff --git a/selfdrive/controls/lib/cluster/fastcluster_py.py b/selfdrive/controls/lib/cluster/fastcluster_py.py index 371804ce5ecf40..1c9ecee369c6a3 100644 --- a/selfdrive/controls/lib/cluster/fastcluster_py.py +++ b/selfdrive/controls/lib/cluster/fastcluster_py.py @@ -2,12 +2,10 @@ import numpy as np from cffi import FFI -import subprocess +from common.ffi_wrapper import suffix cluster_dir = os.path.join(os.path.dirname(os.path.abspath(__file__))) -subprocess.check_call(["make", "-j4"], cwd=cluster_dir) - -cluster_fn = os.path.join(cluster_dir, "libfastcluster.so") +cluster_fn = os.path.join(cluster_dir, "libfastcluster"+suffix()) ffi = FFI() ffi.cdef(""" diff --git a/selfdrive/controls/lib/drive_helpers.py b/selfdrive/controls/lib/drive_helpers.py index 9c1144b966abdc..ea7002475f0976 100644 --- a/selfdrive/controls/lib/drive_helpers.py +++ b/selfdrive/controls/lib/drive_helpers.py @@ -1,6 +1,6 @@ -from cereal import car from common.numpy_fast import clip, interp from selfdrive.config import Conversions as CV +from cereal import car # kph V_CRUISE_MAX = 144 @@ -23,34 +23,6 @@ class MPC_COST_LONG: JERK = 20.0 -class EventTypes: - ENABLE = 'enable' - PRE_ENABLE = 'preEnable' - NO_ENTRY = 'noEntry' - WARNING = 'warning' - USER_DISABLE = 'userDisable' - SOFT_DISABLE = 'softDisable' - IMMEDIATE_DISABLE = 'immediateDisable' - PERMANENT = 'permanent' - - -def create_event(name, types): - event = car.CarEvent.new_message() - event.name = name - for t in types: - setattr(event, t, True) - return event - - -def get_events(events, types): - out = [] - for e in events: - for t in types: - if getattr(e, t): - out.append(e.name) - return out - - def rate_limit(new_value, last_value, dw_step, up_step): return clip(new_value, last_value + dw_step, last_value + up_step) @@ -59,34 +31,14 @@ def get_steer_max(CP, v_ego): return interp(v_ego, CP.steerMaxBP, CP.steerMaxV) -def learn_angle_model_bias(lateral_control, v_ego, angle_model_bias, c_poly, c_prob, angle_steers, steer_override): - # simple integral controller that learns how much steering offset to put to have the car going straight - # while being in the middle of the lane - min_offset = -5. # deg - max_offset = 5. # deg - alpha = 1. / 36000. # correct by 1 deg in 2 mins, at 30m/s, with 50cm of error, at 20Hz - min_learn_speed = 1. - - # learn less at low speed or when turning - slow_factor = 1. / (1. + 0.02 * abs(angle_steers) * v_ego) - alpha_v = alpha * c_prob * (max(v_ego - min_learn_speed, 0.)) * slow_factor - - # only learn if lateral control is active and if driver is not overriding: - if lateral_control and not steer_override: - angle_model_bias += c_poly[3] * alpha_v - angle_model_bias = clip(angle_model_bias, min_offset, max_offset) - - return angle_model_bias - - def update_v_cruise(v_cruise_kph, buttonEvents, enabled): # handle button presses. TODO: this should be in state_control, but a decelCruise press # would have the effect of both enabling and changing speed is checked after the state transition for b in buttonEvents: if enabled and not b.pressed: - if b.type == "accelCruise": + if b.type == car.CarState.ButtonEvent.Type.accelCruise: v_cruise_kph += V_CRUISE_DELTA - (v_cruise_kph % V_CRUISE_DELTA) - elif b.type == "decelCruise": + elif b.type == car.CarState.ButtonEvent.Type.decelCruise: v_cruise_kph -= V_CRUISE_DELTA - ((V_CRUISE_DELTA - v_cruise_kph) % V_CRUISE_DELTA) v_cruise_kph = clip(v_cruise_kph, V_CRUISE_MIN, V_CRUISE_MAX) @@ -96,7 +48,7 @@ def update_v_cruise(v_cruise_kph, buttonEvents, enabled): def initialize_v_cruise(v_ego, buttonEvents, v_cruise_last): for b in buttonEvents: # 250kph or above probably means we never had a set speed - if b.type == "accelCruise" and v_cruise_last < 250: + if b.type == car.CarState.ButtonEvent.Type.accelCruise and v_cruise_last < 250: return v_cruise_last return int(round(clip(v_ego * CV.MS_TO_KPH, V_CRUISE_ENABLE_MIN, V_CRUISE_MAX))) diff --git a/selfdrive/controls/lib/driver_monitor.py b/selfdrive/controls/lib/driver_monitor.py deleted file mode 100644 index 3b45e5a063e884..00000000000000 --- a/selfdrive/controls/lib/driver_monitor.py +++ /dev/null @@ -1,203 +0,0 @@ -import numpy as np -from common.realtime import sec_since_boot, DT_CTRL, DT_DMON -from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET -from common.filter_simple import FirstOrderFilter - -_AWARENESS_TIME = 90. # 1.5 minutes limit without user touching steering wheels make the car enter a terminal status -_AWARENESS_PRE_TIME_TILL_TERMINAL = 20. # a first alert is issued 20s before expiration -_AWARENESS_PROMPT_TIME_TILL_TERMINAL = 5. # a second alert is issued 5s before start decelerating the car -_DISTRACTED_TIME = 10. -_DISTRACTED_PRE_TIME_TILL_TERMINAL = 7. -_DISTRACTED_PROMPT_TIME_TILL_TERMINAL = 5. - -_FACE_THRESHOLD = 0.4 -_EYE_THRESHOLD = 0.4 -_BLINK_THRESHOLD = 0.2 # 0.225 -_PITCH_WEIGHT = 1.35 # 1.5 # pitch matters a lot more -_METRIC_THRESHOLD = 0.4 -_PITCH_POS_ALLOWANCE = 0.04 # 0.08 # rad, to not be too sensitive on positive pitch -_PITCH_NATURAL_OFFSET = 0.12 # 0.1 # people don't seem to look straight when they drive relaxed, rather a bit up -_YAW_NATURAL_OFFSET = 0.08 # people don't seem to look straight when they drive relaxed, rather a bit to the right (center of car) -_DISTRACTED_FILTER_TS = 0.25 # 0.6Hz -_VARIANCE_FILTER_TS = 20. # 0.008Hz - -MAX_TERMINAL_ALERTS = 3 # not allowed to engage after 3 terminal alerts - -# model output refers to center of cropped image, so need to apply the x displacement offset -RESIZED_FOCAL = 320.0 -H, W, FULL_W = 320, 160, 426 - -class DistractedType(object): - NOT_DISTRACTED = 0 - BAD_POSE = 1 - BAD_BLINK = 2 - -def head_orientation_from_descriptor(angles_desc, pos_desc, rpy_calib): - # the output of these angles are in device frame - # so from driver's perspective, pitch is up and yaw is right - - # TODO: calibrate based on position - pitch_prnet = angles_desc[0] - yaw_prnet = angles_desc[1] - roll_prnet = angles_desc[2] - - face_pixel_position = ((pos_desc[0] + .5)*W - W + FULL_W, (pos_desc[1]+.5)*H) - yaw_focal_angle = np.arctan2(face_pixel_position[0] - FULL_W/2, RESIZED_FOCAL) - pitch_focal_angle = np.arctan2(face_pixel_position[1] - H/2, RESIZED_FOCAL) - - roll = roll_prnet - pitch = pitch_prnet + pitch_focal_angle - yaw = -yaw_prnet + yaw_focal_angle - - # no calib for roll - pitch -= rpy_calib[1] - yaw -= rpy_calib[2] - - return np.array([roll, pitch, yaw]) - - -class _DriverPose(): - def __init__(self): - self.yaw = 0. - self.pitch = 0. - self.roll = 0. - self.yaw_offset = 0. - self.pitch_offset = 0. - -class _DriverBlink(): - def __init__(self): - self.left_blink = 0. - self.right_blink = 0. - - - -def _monitor_hysteresis(variance_level, monitor_valid_prev): - var_thr = 0.63 if monitor_valid_prev else 0.37 - return variance_level < var_thr - -class DriverStatus(): - def __init__(self, monitor_on=False): - self.pose = _DriverPose() - self.blink = _DriverBlink() - self.monitor_on = monitor_on - self.monitor_param_on = monitor_on - self.monitor_valid = True # variance needs to be low - self.awareness = 1. - self.driver_distracted = False - self.driver_distraction_filter = FirstOrderFilter(0., _DISTRACTED_FILTER_TS, DT_DMON) - self.variance_high = False - self.variance_filter = FirstOrderFilter(0., _VARIANCE_FILTER_TS, DT_DMON) - self.ts_last_check = 0. - self.face_detected = False - self.terminal_alert_cnt = 0 - self.step_change = 0. - self._set_timers(self.monitor_on) - - def _reset_filters(self): - self.driver_distraction_filter.x = 0. - self.variance_filter.x = 0. - self.monitor_valid = True - - def _set_timers(self, active_monitoring): - if active_monitoring: - # when falling back from passive mode to active mode, reset awareness to avoid false alert - if self.step_change == DT_CTRL / _AWARENESS_TIME: - self.awareness = 1. - self.threshold_pre = _DISTRACTED_PRE_TIME_TILL_TERMINAL / _DISTRACTED_TIME - self.threshold_prompt = _DISTRACTED_PROMPT_TIME_TILL_TERMINAL / _DISTRACTED_TIME - self.step_change = DT_CTRL / _DISTRACTED_TIME - else: - self.threshold_pre = _AWARENESS_PRE_TIME_TILL_TERMINAL / _AWARENESS_TIME - self.threshold_prompt = _AWARENESS_PROMPT_TIME_TILL_TERMINAL / _AWARENESS_TIME - self.step_change = DT_CTRL / _AWARENESS_TIME - - def _is_driver_distracted(self, pose, blink): - # TODO: natural pose calib of each driver - pitch_error = pose.pitch - _PITCH_NATURAL_OFFSET - yaw_error = pose.yaw - _YAW_NATURAL_OFFSET - # add positive pitch allowance - if pitch_error > 0.: - pitch_error = max(pitch_error - _PITCH_POS_ALLOWANCE, 0.) - pitch_error *= _PITCH_WEIGHT - pose_metric = np.sqrt(yaw_error**2 + pitch_error**2) - - if pose_metric > _METRIC_THRESHOLD: - return DistractedType.BAD_POSE - elif blink.left_blink>_BLINK_THRESHOLD and blink.right_blink>_BLINK_THRESHOLD: - return DistractedType.BAD_BLINK - else: - return DistractedType.NOT_DISTRACTED - - - def get_pose(self, driver_monitoring, params, cal_rpy): - if len(driver_monitoring.faceOrientation) == 0 or len(driver_monitoring.facePosition) == 0: - return - - self.pose.roll, self.pose.pitch, self.pose.yaw = head_orientation_from_descriptor(driver_monitoring.faceOrientation, driver_monitoring.facePosition, cal_rpy) - self.blink.left_blink = driver_monitoring.leftBlinkProb * (driver_monitoring.leftEyeProb>_EYE_THRESHOLD) - self.blink.right_blink = driver_monitoring.rightBlinkProb * (driver_monitoring.rightEyeProb>_EYE_THRESHOLD) - self.face_detected = driver_monitoring.faceProb > _FACE_THRESHOLD - - self.driver_distracted = self._is_driver_distracted(self.pose, self.blink)>0 - # first order filters - self.driver_distraction_filter.update(self.driver_distracted) - - monitor_param_on_prev = self.monitor_param_on - - # don't check for param too often as it's a kernel call - ts = sec_since_boot() - if ts - self.ts_last_check > 1.: - self.monitor_param_on = params.get("IsDriverMonitoringEnabled") == "1" - self.ts_last_check = ts - - self.monitor_on = self.monitor_valid and self.monitor_param_on - if monitor_param_on_prev != self.monitor_param_on: - self._reset_filters() - self._set_timers(self.monitor_on and self.face_detected) - - - def update(self, events, driver_engaged, ctrl_active, standstill): - if driver_engaged: - self.awareness = 1. - return events - - driver_engaged |= (self.driver_distraction_filter.x < 0.37 and self.monitor_on) - awareness_prev = self.awareness - - if (driver_engaged and self.awareness > 0) or not ctrl_active: - # always reset if driver is in control (unless we are in red alert state) or op isn't active - self.awareness = min(self.awareness + (2.75*(1.-self.awareness)+1.25)*self.step_change, 1.) - - # should always be counting if distracted unless at standstill and reaching orange - if ((not self.monitor_on or (self.monitor_on and not self.face_detected)) or (self.driver_distraction_filter.x > 0.63 and self.driver_distracted and self.face_detected)) and \ - not (standstill and self.awareness - self.step_change <= self.threshold_prompt): - self.awareness = max(self.awareness - self.step_change, -0.1) - - alert = None - if self.awareness < 0.: - # terminal red alert: disengagement required - alert = 'driverDistracted' if self.monitor_on else 'driverUnresponsive' - if awareness_prev >= 0.: - self.terminal_alert_cnt += 1 - elif self.awareness <= self.threshold_prompt: - # prompt orange alert - alert = 'promptDriverDistracted' if self.monitor_on else 'promptDriverUnresponsive' - elif self.awareness <= self.threshold_pre: - # pre green alert - alert = 'preDriverDistracted' if self.monitor_on else 'preDriverUnresponsive' - - if alert is not None: - events.append(create_event(alert, [ET.WARNING])) - - return events - - -if __name__ == "__main__": - ds = DriverStatus(True) - ds.driver_distraction_filter.x = 0. - ds.driver_distracted = 1 - for i in range(10): - ds.update([], False, True, False) - print(ds.awareness, ds.driver_distracted, ds.driver_distraction_filter.x) - ds.update([], True, True, False) - print(ds.awareness, ds.driver_distracted, ds.driver_distraction_filter.x) diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py new file mode 100644 index 00000000000000..1c82b1f1cfb9e6 --- /dev/null +++ b/selfdrive/controls/lib/events.py @@ -0,0 +1,765 @@ +from enum import IntEnum +from typing import Dict, Union, Callable, Any + +from cereal import log, car +import cereal.messaging as messaging +from common.realtime import DT_CTRL +from selfdrive.config import Conversions as CV +from selfdrive.locationd.calibrationd import MIN_SPEED_FILTER + +AlertSize = log.ControlsState.AlertSize +AlertStatus = log.ControlsState.AlertStatus +VisualAlert = car.CarControl.HUDControl.VisualAlert +AudibleAlert = car.CarControl.HUDControl.AudibleAlert +EventName = car.CarEvent.EventName + +# Alert priorities +class Priority(IntEnum): + LOWEST = 0 + LOWER = 1 + LOW = 2 + MID = 3 + HIGH = 4 + HIGHEST = 5 + +# Event types +class ET: + ENABLE = 'enable' + PRE_ENABLE = 'preEnable' + NO_ENTRY = 'noEntry' + WARNING = 'warning' + USER_DISABLE = 'userDisable' + SOFT_DISABLE = 'softDisable' + IMMEDIATE_DISABLE = 'immediateDisable' + PERMANENT = 'permanent' + +# get event name from enum +EVENT_NAME = {v: k for k, v in EventName.schema.enumerants.items()} + + +class Events: + def __init__(self): + self.events = [] + self.static_events = [] + self.events_prev = dict.fromkeys(EVENTS.keys(), 0) + + @property + def names(self): + return self.events + + def __len__(self): + return len(self.events) + + def add(self, event_name, static=False): + if static: + self.static_events.append(event_name) + self.events.append(event_name) + + def clear(self): + self.events_prev = {k: (v+1 if k in self.events else 0) for k, v in self.events_prev.items()} + self.events = self.static_events.copy() + + def any(self, event_type): + for e in self.events: + if event_type in EVENTS.get(e, {}).keys(): + return True + return False + + def create_alerts(self, event_types, callback_args=None): + if callback_args is None: + callback_args = [] + + ret = [] + for e in self.events: + if e not in EVENTS: #Raf: Avoid crash if key doesn't exist + print("** Trying to create alert with invalid event key: ", e) + continue + types = EVENTS[e].keys() + for et in event_types: + if et in types: + alert = EVENTS[e][et] + if not isinstance(alert, Alert): + alert = alert(*callback_args) + + if DT_CTRL * (self.events_prev[e] + 1) >= alert.creation_delay: + alert.alert_type = f"{EVENT_NAME[e]}/{et}" + alert.event_type = et + ret.append(alert) + return ret + + def add_from_msg(self, events): + for e in events: + self.events.append(e.name.raw) + + def to_msg(self): + ret = [] + for event_name in self.events: + event = car.CarEvent.new_message() + event.name = event_name + for event_type in EVENTS.get(event_name, {}).keys(): + setattr(event, event_type , True) + ret.append(event) + return ret + +class Alert: + def __init__(self, + alert_text_1: str, + alert_text_2: str, + alert_status: log.ControlsState.AlertStatus, + alert_size: log.ControlsState.AlertSize, + alert_priority: Priority, + visual_alert: car.CarControl.HUDControl.VisualAlert, + audible_alert: car.CarControl.HUDControl.AudibleAlert, + duration_sound: float, + duration_hud_alert: float, + duration_text: float, + alert_rate: float = 0., + creation_delay: float = 0.): + + self.alert_text_1 = alert_text_1 + self.alert_text_2 = alert_text_2 + self.alert_status = alert_status + self.alert_size = alert_size + self.alert_priority = alert_priority + self.visual_alert = visual_alert + self.audible_alert = audible_alert + + self.duration_sound = duration_sound + self.duration_hud_alert = duration_hud_alert + self.duration_text = duration_text + + self.alert_rate = alert_rate + self.creation_delay = creation_delay + + self.start_time = 0. + self.alert_type = "" + self.event_type = None + + def __str__(self) -> str: + return f"{self.alert_text_1}/{self.alert_text_2} {self.alert_priority} {self.visual_alert} {self.audible_alert}" + + def __gt__(self, alert2) -> bool: + return self.alert_priority > alert2.alert_priority + +class NoEntryAlert(Alert): + def __init__(self, alert_text_2, audible_alert=AudibleAlert.chimeError, + visual_alert=VisualAlert.none, duration_hud_alert=2.): + super().__init__("openpilot Unavailable", alert_text_2, AlertStatus.normal, + AlertSize.mid, Priority.LOW, visual_alert, + audible_alert, .4, duration_hud_alert, 3.) + + +class SoftDisableAlert(Alert): + def __init__(self, alert_text_2): + super().__init__("TAKE CONTROL IMMEDIATELY", alert_text_2, + AlertStatus.critical, AlertSize.full, + Priority.MID, VisualAlert.steerRequired, + AudibleAlert.chimeWarningRepeat, .1, 2., 2.), + + +class ImmediateDisableAlert(Alert): + def __init__(self, alert_text_2, alert_text_1="TAKE CONTROL IMMEDIATELY"): + super().__init__(alert_text_1, alert_text_2, + AlertStatus.critical, AlertSize.full, + Priority.HIGHEST, VisualAlert.steerRequired, + AudibleAlert.chimeWarningRepeat, 2.2, 3., 4.), + +class EngagementAlert(Alert): + def __init__(self, audible_alert=True): + super().__init__("", "", + AlertStatus.normal, AlertSize.none, + Priority.MID, VisualAlert.none, + audible_alert, .2, 0., 0.), + +class NormalPermanentAlert(Alert): + def __init__(self, alert_text_1, alert_text_2): + super().__init__(alert_text_1, alert_text_2, + AlertStatus.normal, AlertSize.mid, + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), + +# ********** alert callback functions ********** + +def below_steer_speed_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Alert: + speed = int(round(CP.minSteerSpeed * (CV.MS_TO_KPH if metric else CV.MS_TO_MPH))) + unit = "km/h" if metric else "mph" + return Alert( + "TAKE CONTROL", + "Steer Unavailable Below %d %s" % (speed, unit), + AlertStatus.userPrompt, AlertSize.mid, + Priority.MID, VisualAlert.steerRequired, AudibleAlert.none, 0., 0.4, .3) + +def calibration_incomplete_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Alert: + speed = int(MIN_SPEED_FILTER * (CV.MS_TO_KPH if metric else CV.MS_TO_MPH)) + unit = "km/h" if metric else "mph" + return Alert( + "Calibration in Progress: %d%%" % sm['liveCalibration'].calPerc, + "Drive Above %d %s" % (speed, unit), + AlertStatus.normal, AlertSize.mid, + Priority.LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2) + +def no_gps_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Alert: + gps_integrated = sm['health'].hwType in [log.HealthData.HwType.uno, log.HealthData.HwType.dos] + return Alert( + "Poor GPS reception", + "If sky is visible, contact support" if gps_integrated else "Check GPS antenna placement", + AlertStatus.normal, AlertSize.mid, + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2, creation_delay=300.) + +def wrong_car_mode_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Alert: + text = "Cruise Mode Disabled" + if CP.carName == "honda": + text = "Main Switch Off" + return NoEntryAlert(text, duration_hud_alert=0.) + +EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, bool], Alert]]]] = { + # ********** events with no alerts ********** + + # ********** events only containing alerts displayed in all states ********** + + EventName.debugAlert: { + ET.PERMANENT: Alert( + "DEBUG ALERT", + "", + AlertStatus.userPrompt, AlertSize.mid, + Priority.LOW, VisualAlert.none, AudibleAlert.none, .1, .1, .1), + }, + + EventName.startup: { + ET.PERMANENT: Alert( + "Be ready to take over at any time", + "Always keep hands on wheel and eyes on road", + AlertStatus.normal, AlertSize.mid, + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 15.), + }, + + EventName.startupMaster: { + ET.PERMANENT: Alert( + "WARNING: This branch is not tested", + "Always keep hands on wheel and eyes on road", + AlertStatus.userPrompt, AlertSize.mid, + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 15.), + }, + + EventName.startupNoControl: { + ET.PERMANENT: Alert( + "Dashcam mode", + "Always keep hands on wheel and eyes on road", + AlertStatus.normal, AlertSize.mid, + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 15.), + }, + + EventName.startupNoCar: { + ET.PERMANENT: Alert( + "Dashcam mode for unsupported car", + "Always keep hands on wheel and eyes on road", + AlertStatus.normal, AlertSize.mid, + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 15.), + }, + + EventName.startupOneplus: { + ET.PERMANENT: Alert( + "WARNING: Original EON deprecated", + "Device will no longer update", + AlertStatus.userPrompt, AlertSize.mid, + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 15.), + }, + + EventName.invalidLkasSetting: { + ET.PERMANENT: Alert( + "Stock LKAS is turned on", + "Turn off stock LKAS to engage", + AlertStatus.normal, AlertSize.mid, + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), + }, + + EventName.communityFeatureDisallowed: { + # LOW priority to overcome Cruise Error + ET.PERMANENT: Alert( + "Community Feature Detected", + "Enable Community Features in Developer Settings", + AlertStatus.normal, AlertSize.mid, + Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2), + }, + + EventName.carUnrecognized: { + ET.PERMANENT: Alert( + "Dashcam Mode", + "Car Unrecognized", + AlertStatus.normal, AlertSize.mid, + Priority.LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), + }, + + EventName.stockAeb: { + ET.PERMANENT: Alert( + "BRAKE!", + "Stock AEB: Risk of Collision", + AlertStatus.critical, AlertSize.full, + Priority.HIGHEST, VisualAlert.fcw, AudibleAlert.none, 1., 2., 2.), + }, + + EventName.stockFcw: { + ET.PERMANENT: Alert( + "BRAKE!", + "Stock FCW: Risk of Collision", + AlertStatus.critical, AlertSize.full, + Priority.HIGHEST, VisualAlert.fcw, AudibleAlert.none, 1., 2., 2.), + }, + + EventName.fcw: { + ET.PERMANENT: Alert( + "BRAKE!", + "Risk of Collision", + AlertStatus.critical, AlertSize.full, + Priority.HIGHEST, VisualAlert.fcw, AudibleAlert.chimeWarningRepeat, 1., 2., 2.), + }, + + EventName.ldw: { + ET.PERMANENT: Alert( + "TAKE CONTROL", + "Lane Departure Detected", + AlertStatus.userPrompt, AlertSize.mid, + Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimePrompt, 1., 2., 3.), + }, + + # ********** events only containing alerts that display while engaged ********** + + EventName.gasPressed: { + ET.PRE_ENABLE: Alert( + "openpilot will not brake while gas pressed", + "", + AlertStatus.normal, AlertSize.small, + Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .0, .0, .1, creation_delay=1.), + }, + + EventName.vehicleModelInvalid: { + ET.WARNING: Alert( + "Vehicle Parameter Identification Failed", + "", + AlertStatus.normal, AlertSize.small, + Priority.LOWEST, VisualAlert.steerRequired, AudibleAlert.none, .0, .0, .1), + }, + + EventName.steerTempUnavailableMute: { + ET.WARNING: Alert( + "TAKE CONTROL", + "Steering Temporarily Unavailable", + AlertStatus.userPrompt, AlertSize.mid, + Priority.LOW, VisualAlert.none, AudibleAlert.none, .2, .2, .2), + }, + + EventName.preDriverDistracted: { + ET.WARNING: Alert( + "KEEP EYES ON ROAD: Driver Distracted", + "", + AlertStatus.normal, AlertSize.small, + Priority.LOW, VisualAlert.steerRequired, AudibleAlert.none, .0, .1, .1), + }, + + EventName.promptDriverDistracted: { + ET.WARNING: Alert( + "KEEP EYES ON ROAD", + "Driver Distracted", + AlertStatus.userPrompt, AlertSize.mid, + Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2Repeat, .1, .1, .1), + }, + + EventName.driverDistracted: { + ET.WARNING: Alert( + "DISENGAGE IMMEDIATELY", + "Driver Distracted", + AlertStatus.critical, AlertSize.full, + Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, .1, .1, .1), + }, + + EventName.preDriverUnresponsive: { + ET.WARNING: Alert( + "TOUCH STEERING WHEEL: No Face Detected", + "", + AlertStatus.normal, AlertSize.small, + Priority.LOW, VisualAlert.steerRequired, AudibleAlert.none, .0, .1, .1, alert_rate=0.75), + }, + + EventName.promptDriverUnresponsive: { + ET.WARNING: Alert( + "TOUCH STEERING WHEEL", + "Driver Unresponsive", + AlertStatus.userPrompt, AlertSize.mid, + Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2Repeat, .1, .1, .1), + }, + + EventName.driverUnresponsive: { + ET.WARNING: Alert( + "DISENGAGE IMMEDIATELY", + "Driver Unresponsive", + AlertStatus.critical, AlertSize.full, + Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, .1, .1, .1), + }, + + EventName.driverMonitorLowAcc: { + ET.WARNING: Alert( + "CHECK DRIVER FACE VISIBILITY", + "Driver Monitoring Uncertain", + AlertStatus.normal, AlertSize.mid, + Priority.LOW, VisualAlert.steerRequired, AudibleAlert.none, .4, 0., 1.5), + }, + + EventName.manualRestart: { + ET.WARNING: Alert( + "TAKE CONTROL", + "Resume Driving Manually", + AlertStatus.userPrompt, AlertSize.mid, + Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2), + }, + + EventName.resumeRequired: { + ET.WARNING: Alert( + "STOPPED", + "Press Resume to Move", + AlertStatus.userPrompt, AlertSize.mid, + Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2), + }, + + EventName.belowSteerSpeed: { + ET.WARNING: below_steer_speed_alert, + }, + + EventName.preLaneChangeLeft: { + ET.WARNING: Alert( + "Steer Left to Start Lane Change", + "Monitor Other Vehicles", + AlertStatus.normal, AlertSize.mid, + Priority.LOW, VisualAlert.steerRequired, AudibleAlert.none, .0, .1, .1, alert_rate=0.75), + }, + + EventName.preLaneChangeRight: { + ET.WARNING: Alert( + "Steer Right to Start Lane Change", + "Monitor Other Vehicles", + AlertStatus.normal, AlertSize.mid, + Priority.LOW, VisualAlert.steerRequired, AudibleAlert.none, .0, .1, .1, alert_rate=0.75), + }, + + EventName.laneChangeBlocked: { + ET.WARNING: Alert( + "Car Detected in Blindspot", + "Monitor Other Vehicles", + AlertStatus.normal, AlertSize.mid, + Priority.LOW, VisualAlert.steerRequired, AudibleAlert.none, .0, .1, .1), + }, + + EventName.laneChange: { + ET.WARNING: Alert( + "Changing Lane", + "Monitor Other Vehicles", + AlertStatus.normal, AlertSize.mid, + Priority.LOW, VisualAlert.steerRequired, AudibleAlert.none, .0, .1, .1), + }, + + EventName.steerSaturated: { + ET.WARNING: Alert( + "TAKE CONTROL", + "Turn Exceeds Steering Limit", + AlertStatus.userPrompt, AlertSize.mid, + Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimePrompt, 1., 1., 1.), + }, + + EventName.fanMalfunction: { + ET.PERMANENT: NormalPermanentAlert("Fan Malfunction", "Contact Support"), + }, + + EventName.cameraMalfunction: { + ET.PERMANENT: NormalPermanentAlert("Camera Malfunction", "Contact Support"), + }, + + # ********** events that affect controls state transitions ********** + + EventName.pcmEnable: { + ET.ENABLE: EngagementAlert(AudibleAlert.chimeEngage), + }, + + EventName.buttonEnable: { + ET.ENABLE: EngagementAlert(AudibleAlert.chimeEngage), + }, + + EventName.pcmDisable: { + ET.USER_DISABLE: EngagementAlert(AudibleAlert.chimeDisengage), + }, + + EventName.buttonCancel: { + ET.USER_DISABLE: EngagementAlert(AudibleAlert.chimeDisengage), + }, + + EventName.brakeHold: { + ET.USER_DISABLE: EngagementAlert(AudibleAlert.chimeDisengage), + ET.NO_ENTRY: NoEntryAlert("Brake Hold Active"), + }, + + EventName.parkBrake: { + ET.USER_DISABLE: EngagementAlert(AudibleAlert.chimeDisengage), + ET.NO_ENTRY: NoEntryAlert("Park Brake Engaged"), + }, + + EventName.pedalPressed: { + ET.USER_DISABLE: EngagementAlert(AudibleAlert.chimeDisengage), + ET.NO_ENTRY: NoEntryAlert("Pedal Pressed During Attempt", + visual_alert=VisualAlert.brakePressed), + }, + + EventName.wrongCarMode: { + ET.USER_DISABLE: EngagementAlert(AudibleAlert.chimeDisengage), + ET.NO_ENTRY: wrong_car_mode_alert, + }, + + EventName.wrongCruiseMode: { + ET.USER_DISABLE: EngagementAlert(AudibleAlert.chimeDisengage), + ET.NO_ENTRY: NoEntryAlert("Enable Adaptive Cruise"), + }, + + EventName.steerTempUnavailable: { + ET.WARNING: Alert( + "TAKE CONTROL", + "Steering Temporarily Unavailable", + AlertStatus.userPrompt, AlertSize.mid, + Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimeWarning1, .4, 2., 1.), + ET.NO_ENTRY: NoEntryAlert("Steering Temporarily Unavailable", + duration_hud_alert=0.), + }, + + EventName.outOfSpace: { + ET.PERMANENT: Alert( + "Out of Storage", + "", + AlertStatus.normal, AlertSize.small, + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), + ET.NO_ENTRY: NoEntryAlert("Out of Storage Space", + duration_hud_alert=0.), + }, + + EventName.belowEngageSpeed: { + ET.NO_ENTRY: NoEntryAlert("Speed Too Low"), + }, + + EventName.sensorDataInvalid: { + ET.PERMANENT: Alert( + "No Data from Device Sensors", + "Reboot your Device", + AlertStatus.normal, AlertSize.mid, + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2, creation_delay=1.), + ET.NO_ENTRY: NoEntryAlert("No Data from Device Sensors"), + }, + + EventName.noGps: { + ET.PERMANENT: no_gps_alert, + }, + + EventName.soundsUnavailable: { + ET.PERMANENT: NormalPermanentAlert("Speaker not found", "Reboot your Device"), + ET.NO_ENTRY: NoEntryAlert("Speaker not found"), + }, + + EventName.tooDistracted: { + ET.NO_ENTRY: NoEntryAlert("Distraction Level Too High"), + }, + + EventName.overheat: { + ET.PERMANENT: Alert( + "System Overheated", + "", + AlertStatus.normal, AlertSize.small, + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), + ET.SOFT_DISABLE: SoftDisableAlert("System Overheated"), + ET.NO_ENTRY: NoEntryAlert("System Overheated"), + }, + + EventName.wrongGear: { + ET.SOFT_DISABLE: SoftDisableAlert("Gear not D"), + ET.NO_ENTRY: NoEntryAlert("Gear not D"), + }, + + EventName.calibrationInvalid: { + ET.PERMANENT: NormalPermanentAlert("Calibration Invalid", "Remount Device and Recalibrate"), + ET.SOFT_DISABLE: SoftDisableAlert("Calibration Invalid: Remount Device & Recalibrate"), + ET.NO_ENTRY: NoEntryAlert("Calibration Invalid: Remount Device & Recalibrate"), + }, + + EventName.calibrationIncomplete: { + ET.PERMANENT: calibration_incomplete_alert, + ET.SOFT_DISABLE: SoftDisableAlert("Calibration in Progress"), + ET.NO_ENTRY: NoEntryAlert("Calibration in Progress"), + }, + + EventName.doorOpen: { + ET.SOFT_DISABLE: SoftDisableAlert("Door Open"), + ET.NO_ENTRY: NoEntryAlert("Door Open"), + }, + + EventName.seatbeltNotLatched: { + ET.SOFT_DISABLE: SoftDisableAlert("Seatbelt Unlatched"), + ET.NO_ENTRY: NoEntryAlert("Seatbelt Unlatched"), + }, + + EventName.espDisabled: { + ET.SOFT_DISABLE: SoftDisableAlert("ESP Off"), + ET.NO_ENTRY: NoEntryAlert("ESP Off"), + }, + + EventName.lowBattery: { + ET.SOFT_DISABLE: SoftDisableAlert("Low Battery"), + ET.NO_ENTRY: NoEntryAlert("Low Battery"), + }, + + EventName.commIssue: { + ET.SOFT_DISABLE: SoftDisableAlert("Communication Issue between Processes"), + ET.NO_ENTRY: NoEntryAlert("Communication Issue between Processes", + audible_alert=AudibleAlert.chimeDisengage), + }, + + EventName.radarCommIssue: { + ET.SOFT_DISABLE: SoftDisableAlert("Radar Communication Issue"), + ET.NO_ENTRY: NoEntryAlert("Radar Communication Issue", + audible_alert=AudibleAlert.chimeDisengage), + }, + + EventName.radarCanError: { + ET.SOFT_DISABLE: SoftDisableAlert("Radar Error: Restart the Car"), + ET.NO_ENTRY: NoEntryAlert("Radar Error: Restart the Car"), + }, + + EventName.radarFault: { + ET.SOFT_DISABLE: SoftDisableAlert("Radar Error: Restart the Car"), + ET.NO_ENTRY : NoEntryAlert("Radar Error: Restart the Car"), + }, + + EventName.modeldLagging: { + ET.SOFT_DISABLE: SoftDisableAlert("Driving model lagging"), + ET.NO_ENTRY : NoEntryAlert("Driving model lagging"), + }, + + EventName.posenetInvalid: { + ET.SOFT_DISABLE: SoftDisableAlert("Model Output Uncertain"), + ET.NO_ENTRY: NoEntryAlert("Model Output Uncertain"), + }, + + EventName.deviceFalling: { + ET.SOFT_DISABLE: SoftDisableAlert("Device Fell Off Mount"), + ET.NO_ENTRY: NoEntryAlert("Device Fell Off Mount"), + }, + + EventName.lowMemory: { + ET.SOFT_DISABLE: SoftDisableAlert("Low Memory: Reboot Your Device"), + ET.PERMANENT: NormalPermanentAlert("Low Memory", "Reboot your Device"), + ET.NO_ENTRY : NoEntryAlert("Low Memory: Reboot Your Device", + audible_alert=AudibleAlert.chimeDisengage), + }, + + EventName.controlsFailed: { + ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("Controls Failed"), + ET.NO_ENTRY: NoEntryAlert("Controls Failed"), + }, + + EventName.controlsMismatch: { + ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("Controls Mismatch"), + }, + + EventName.canError: { + ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("CAN Error: Check Connections"), + ET.PERMANENT: Alert( + "CAN Error: Check Connections", + "", + AlertStatus.normal, AlertSize.small, + Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2, creation_delay=1.), + ET.NO_ENTRY: NoEntryAlert("CAN Error: Check Connections"), + }, + + EventName.steerUnavailable: { + ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("LKAS Fault: Restart the Car"), + ET.PERMANENT: Alert( + "LKAS Fault: Restart the car to engage", + "", + AlertStatus.normal, AlertSize.small, + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), + ET.NO_ENTRY: NoEntryAlert("LKAS Fault: Restart the Car"), + }, + + EventName.brakeUnavailable: { + ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("Cruise Fault: Restart the Car"), + ET.PERMANENT: Alert( + "Cruise Fault: Restart the car to engage", + "", + AlertStatus.normal, AlertSize.small, + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), + ET.NO_ENTRY: NoEntryAlert("Cruise Fault: Restart the Car"), + }, + + EventName.reverseGear: { + ET.PERMANENT: Alert( + "Reverse\nGear", + "", + AlertStatus.normal, AlertSize.full, + Priority.LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2, creation_delay=0.5), + ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("Reverse Gear"), + ET.NO_ENTRY: NoEntryAlert("Reverse Gear"), + }, + + EventName.cruiseDisabled: { + ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("Cruise Is Off"), + }, + + EventName.plannerError: { + ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("Planner Solution Error"), + ET.NO_ENTRY: NoEntryAlert("Planner Solution Error"), + }, + + EventName.relayMalfunction: { + ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("Harness Malfunction"), + ET.PERMANENT: NormalPermanentAlert("Harness Malfunction", "Check Hardware"), + ET.NO_ENTRY: NoEntryAlert("Harness Malfunction"), + }, + + EventName.noTarget: { + ET.IMMEDIATE_DISABLE: Alert( + "openpilot Canceled", + "No close lead car", + AlertStatus.normal, AlertSize.mid, + Priority.HIGH, VisualAlert.none, AudibleAlert.chimeDisengage, .4, 2., 3.), + ET.NO_ENTRY : NoEntryAlert("No Close Lead Car"), + }, + + EventName.speedTooLow: { + ET.IMMEDIATE_DISABLE: Alert( + "openpilot Canceled", + "Speed too low", + AlertStatus.normal, AlertSize.mid, + Priority.HIGH, VisualAlert.none, AudibleAlert.chimeDisengage, .4, 2., 3.), + }, + + EventName.speedTooHigh: { + ET.WARNING: Alert( + "Speed Too High", + "Slow down to resume operation", + AlertStatus.normal, AlertSize.mid, + Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.none, 2.2, 3., 4.), + ET.NO_ENTRY: Alert( + "Speed Too High", + "Slow down to engage", + AlertStatus.normal, AlertSize.mid, + Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), + }, + + # TODO: this is unclear, update check only happens offroad + EventName.internetConnectivityNeeded: { + ET.PERMANENT: NormalPermanentAlert("Connect to Internet", "An Update Check Is Required to Engage"), + ET.NO_ENTRY: NoEntryAlert("Connect to Internet", + audible_alert=AudibleAlert.chimeDisengage), + }, + + EventName.lowSpeedLockout: { + ET.PERMANENT: Alert( + "Cruise Fault: Restart the car to engage", + "", + AlertStatus.normal, AlertSize.small, + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), + ET.NO_ENTRY: NoEntryAlert("Cruise Fault: Restart the Car"), + }, + +} diff --git a/selfdrive/controls/lib/fcw.py b/selfdrive/controls/lib/fcw.py index 7a8023608a70b3..e582f54f5f936d 100644 --- a/selfdrive/controls/lib/fcw.py +++ b/selfdrive/controls/lib/fcw.py @@ -1,4 +1,4 @@ -import numpy as np +import math from collections import defaultdict from common.numpy_fast import interp @@ -7,9 +7,10 @@ _FCW_A_ACT_BP = [0., 30.] -class FCWChecker(object): +class FCWChecker(): def __init__(self): self.reset_lead(0.0) + self.common_counters = defaultdict(lambda: 0) def reset_lead(self, cur_time): self.last_fcw_a = 0.0 @@ -31,44 +32,44 @@ def calc_ttc(v_ego, a_ego, x_lead, v_lead, a_lead): # then limit ARel so that v_lead will get to zero in no sooner than t_decel. # This helps underweighting ARel when v_lead is close to zero. t_decel = 2. - a_rel = np.minimum(a_rel, v_lead / t_decel) + a_rel = min(a_rel, v_lead / t_decel) # delta of the quadratic equation to solve for ttc delta = v_rel**2 + 2 * x_lead * a_rel # assign an arbitrary high ttc value if there is no solution to ttc - if delta < 0.1 or (np.sqrt(delta) + v_rel < 0.1): + if delta < 0.1 or (math.sqrt(delta) + v_rel < 0.1): ttc = max_ttc else: - ttc = np.minimum(2 * x_lead / (np.sqrt(delta) + v_rel), max_ttc) + ttc = min(2 * x_lead / (math.sqrt(delta) + v_rel), max_ttc) return ttc def update(self, mpc_solution, cur_time, active, v_ego, a_ego, x_lead, v_lead, a_lead, y_lead, vlat_lead, fcw_lead, blinkers): mpc_solution_a = list(mpc_solution[0].a_ego) - a_target = mpc_solution_a[1] self.last_min_a = min(mpc_solution_a) self.v_lead_max = max(self.v_lead_max, v_lead) + self.common_counters['blinkers'] = self.common_counters['blinkers'] + 10.0 / (20 * 3.0) if not blinkers else 0 + self.common_counters['v_ego'] = self.common_counters['v_ego'] + 1 if v_ego > 5.0 else 0 + if (fcw_lead > 0.99): ttc = self.calc_ttc(v_ego, a_ego, x_lead, v_lead, a_lead) - self.counters['v_ego'] = self.counters['v_ego'] + 1 if v_ego > 5.0 else 0 self.counters['ttc'] = self.counters['ttc'] + 1 if ttc < 2.5 else 0 self.counters['v_lead_max'] = self.counters['v_lead_max'] + 1 if self.v_lead_max > 2.5 else 0 self.counters['v_ego_lead'] = self.counters['v_ego_lead'] + 1 if v_ego > v_lead else 0 self.counters['lead_seen'] = self.counters['lead_seen'] + 0.33 self.counters['y_lead'] = self.counters['y_lead'] + 1 if abs(y_lead) < 1.0 else 0 self.counters['vlat_lead'] = self.counters['vlat_lead'] + 1 if abs(vlat_lead) < 0.4 else 0 - self.counters['blinkers'] = self.counters['blinkers'] + 10.0 / (20 * 3.0) if not blinkers else 0 a_thr = interp(v_lead, _FCW_A_ACT_BP, _FCW_A_ACT_V) a_delta = min(mpc_solution_a[:15]) - min(0.0, a_ego) future_fcw_allowed = all(c >= 10 for c in self.counters.values()) + future_fcw_allowed = future_fcw_allowed and all(c >= 10 for c in self.common_counters.values()) future_fcw = (self.last_min_a < -3.0 or a_delta < a_thr) and future_fcw_allowed - current_fcw = a_target < -3.0 and active and False - if (future_fcw or current_fcw) and (self.last_fcw_time + 5.0 < cur_time): + if future_fcw and (self.last_fcw_time + 5.0 < cur_time): self.last_fcw_time = cur_time self.last_fcw_a = self.last_min_a return True diff --git a/selfdrive/controls/lib/lane_planner.py b/selfdrive/controls/lib/lane_planner.py index 28dc1e9039b14d..3a181e2e891d07 100644 --- a/selfdrive/controls/lib/lane_planner.py +++ b/selfdrive/controls/lib/lane_planner.py @@ -1,30 +1,29 @@ from common.numpy_fast import interp import numpy as np -from selfdrive.controls.lib.latcontrol_helpers import model_polyfit, compute_path_pinv from selfdrive.car.modules.ALCA_module import ALCAModelParser +from cereal import log CAMERA_OFFSET = 0.06 # m from center car to camera -def calc_d_poly(l_poly, r_poly, p_poly, l_prob, r_prob, lane_width): - # This will improve behaviour when lanes suddenly widen - lane_width = min(4.0, lane_width) - l_prob = l_prob * interp(abs(l_poly[3]), [2, 2.5], [1.0, 0.0]) - r_prob = r_prob * interp(abs(r_poly[3]), [2, 2.5], [1.0, 0.0]) +def compute_path_pinv(length=50): + deg = 3 + x = np.arange(length*1.0) + X = np.vstack(tuple(x**n for n in range(deg, -1, -1))).T + pinv = np.linalg.pinv(X) + return pinv - path_from_left_lane = l_poly.copy() - path_from_left_lane[3] -= lane_width / 2.0 - path_from_right_lane = r_poly.copy() - path_from_right_lane[3] += lane_width / 2.0 - lr_prob = l_prob + r_prob - l_prob * r_prob +def model_polyfit(points, path_pinv): + return np.dot(path_pinv, [float(x) for x in points]) - d_poly_lane = (l_prob * path_from_left_lane + r_prob * path_from_right_lane) / (l_prob + r_prob + 0.0001) - return lr_prob * d_poly_lane + (1.0 - lr_prob) * p_poly +def eval_poly(poly, x): + return poly[3] + poly[2]*x + poly[1]*x**2 + poly[0]*x**3 -class LanePlanner(object): - def __init__(self): + +class LanePlanner: + def __init__(self, shouldUseAlca): self.l_poly = [0., 0., 0., 0.] self.r_poly = [0., 0., 0., 0.] self.p_poly = [0., 0., 0., 0.] @@ -36,16 +35,25 @@ def __init__(self): self.l_prob = 0. self.r_prob = 0. - self.lr_prob = 0. + + self.l_std = 0. + self.r_std = 0. + + self.l_lane_change_prob = 0. + self.r_lane_change_prob = 0. self._path_pinv = compute_path_pinv() self.x_points = np.arange(50) - self.ALCAMP = ALCAModelParser() + self.shouldUseAlca = shouldUseAlca + if shouldUseAlca: + self.ALCAMP = ALCAModelParser() def parse_model(self, md): if len(md.leftLane.poly): self.l_poly = np.array(md.leftLane.poly) + self.l_std = float(md.leftLane.std) self.r_poly = np.array(md.rightLane.poly) + self.r_std = float(md.rightLane.std) self.p_poly = np.array(md.path.poly) else: self.l_poly = model_polyfit(md.leftLane.points, self._path_pinv) # left line @@ -54,27 +62,57 @@ def parse_model(self, md): self.l_prob = md.leftLane.prob # left line prob self.r_prob = md.rightLane.prob # right line prob - def update_lane(self, v_ego, md, alca ): + if len(md.meta.desireState): + self.l_lane_change_prob = md.meta.desireState[log.PathPlan.Desire.laneChangeLeft] + self.r_lane_change_prob = md.meta.desireState[log.PathPlan.Desire.laneChangeRight] + + def update_d_poly(self, v_ego, md, alca ): # only offset left and right lane lines; offsetting p_poly does not make sense self.l_poly[3] += CAMERA_OFFSET self.r_poly[3] += CAMERA_OFFSET - self.lr_prob = self.l_prob + self.r_prob - self.l_prob * self.r_prob + # Reduce reliance on lanelines that are too far apart or + # will be in a few seconds + l_prob, r_prob = self.l_prob, self.r_prob + width_poly = self.l_poly - self.r_poly + prob_mods = [] + for t_check in [0.0, 1.5, 3.0]: + width_at_t = eval_poly(width_poly, t_check * (v_ego + 7)) + prob_mods.append(interp(width_at_t, [4.0, 5.0], [1.0, 0.0])) + mod = min(prob_mods) + l_prob *= mod + r_prob *= mod + + # Reduce reliance on uncertain lanelines + l_std_mod = interp(self.l_std, [.15, .3], [1.0, 0.0]) + r_std_mod = interp(self.r_std, [.15, .3], [1.0, 0.0]) + l_prob *= l_std_mod + r_prob *= r_std_mod # Find current lanewidth - self.lane_width_certainty += 0.05 * (self.l_prob * self.r_prob - self.lane_width_certainty) + self.lane_width_certainty += 0.05 * (l_prob * r_prob - self.lane_width_certainty) current_lane_width = abs(self.l_poly[3] - self.r_poly[3]) self.lane_width_estimate += 0.005 * (current_lane_width - self.lane_width_estimate) speed_lane_width = interp(v_ego, [0., 31.], [2.8, 3.5]) self.lane_width = self.lane_width_certainty * self.lane_width_estimate + \ (1 - self.lane_width_certainty) * speed_lane_width + clipped_lane_width = min(4.0, self.lane_width) + path_from_left_lane = self.l_poly.copy() + path_from_left_lane[3] -= clipped_lane_width / 2.0 + path_from_right_lane = self.r_poly.copy() + path_from_right_lane[3] += clipped_lane_width / 2.0 + + lr_prob = l_prob + r_prob - l_prob * r_prob + + d_poly_lane = (l_prob * path_from_left_lane + r_prob * path_from_right_lane) / (l_prob + r_prob + 0.0001) + # ALCA integration - if alca: - self.r_poly,self.l_poly,self.r_prob,self.l_prob,self.lane_width = self.ALCAMP.update(v_ego, md, np.array(self.r_poly), np.array(self.l_poly), self.r_prob, self.l_prob, self.lane_width) + if self.shouldUseAlca and alca: + self.r_poly,self.l_poly,self.r_prob,self.l_prob,self.lane_width, self.p_poly = self.ALCAMP.update(v_ego, md, np.array(self.r_poly), np.array(self.l_poly), self.r_prob, self.l_prob, self.lane_width, self.p_poly) - self.d_poly = calc_d_poly(self.l_poly, self.r_poly, self.p_poly, self.l_prob, self.r_prob, self.lane_width) + self.d_poly = lr_prob * d_poly_lane + (1.0 - lr_prob) * self.p_poly.copy() def update(self, v_ego, md, alca): self.parse_model(md) - self.update_lane(v_ego, md, alca) + self.update_d_poly(v_ego, md, alca) diff --git a/selfdrive/controls/lib/latcontrol_helpers.py b/selfdrive/controls/lib/latcontrol_helpers.py deleted file mode 100644 index ff5fa478accd36..00000000000000 --- a/selfdrive/controls/lib/latcontrol_helpers.py +++ /dev/null @@ -1,62 +0,0 @@ -import numpy as np -import math -from common.numpy_fast import interp - -_K_CURV_V = [1., 0.6] -_K_CURV_BP = [0., 0.002] - -# lane width http://safety.fhwa.dot.gov/geometric/pubs/mitigationstrategies/chapter3/3_lanewidth.cfm -_LANE_WIDTH_V = [3., 3.8] - -# break points of speed -_LANE_WIDTH_BP = [0., 31.] - - -def calc_d_lookahead(v_ego, d_poly): - # this function computes how far too look for lateral control - # howfar we look ahead is function of speed and how much curvy is the path - offset_lookahead = 1. - k_lookahead = 7. - # integrate abs value of second derivative of poly to get a measure of path curvature - pts_len = 50. # m - if len(d_poly) > 0: - pts = np.polyval([6 * d_poly[0], 2 * d_poly[1]], np.arange(0, pts_len)) - else: - pts = 0. - curv = np.sum(np.abs(pts)) / pts_len - - k_curv = interp(curv, _K_CURV_BP, _K_CURV_V) - - # sqrt on speed is needed to keep, for a given curvature, the y_des - # proportional to speed. Indeed, y_des is prop to d_lookahead^2 - # 36m at 25m/s - d_lookahead = offset_lookahead + math.sqrt(max(v_ego, 0)) * k_lookahead * k_curv - return d_lookahead - - -def calc_lookahead_offset(v_ego, angle_steers, d_lookahead, VM, angle_offset): - # this function returns the lateral offset given the steering angle, speed and the lookahead distance - sa = math.radians(angle_steers - angle_offset) - curvature = VM.calc_curvature(sa, v_ego) - # clip is to avoid arcsin NaNs due to too sharp turns - y_actual = d_lookahead * np.tan(np.arcsin(np.clip(d_lookahead * curvature, -0.999, 0.999)) / 2.) - return y_actual, curvature - - -def calc_desired_steer_angle(v_ego, y_des, d_lookahead, VM, angle_offset): - # inverse of the above function - curvature = np.sin(np.arctan(y_des / d_lookahead) * 2.) / d_lookahead - steer_des = math.degrees(VM.get_steer_from_curvature(curvature, v_ego)) + angle_offset - return steer_des, curvature - - -def compute_path_pinv(l=50): - deg = 3 - x = np.arange(l*1.0) - X = np.vstack(tuple(x**n for n in range(deg, -1, -1))).T - pinv = np.linalg.pinv(X) - return pinv - - -def model_polyfit(points, path_pinv): - return np.dot(path_pinv, [float(x) for x in points]) diff --git a/selfdrive/controls/lib/latcontrol_indi.py b/selfdrive/controls/lib/latcontrol_indi.py index 38ba8883b9f64d..51872f6d0ffa40 100644 --- a/selfdrive/controls/lib/latcontrol_indi.py +++ b/selfdrive/controls/lib/latcontrol_indi.py @@ -4,35 +4,35 @@ from cereal import log from common.realtime import DT_CTRL from common.numpy_fast import clip -from selfdrive.car.toyota.carcontroller import SteerLimitParams +from selfdrive.car.toyota.values import SteerLimitParams from selfdrive.car import apply_toyota_steer_torque_limits from selfdrive.controls.lib.drive_helpers import get_steer_max -class LatControlINDI(object): +class LatControlINDI(): def __init__(self, CP): self.angle_steers_des = 0. - A = np.matrix([[1.0, DT_CTRL, 0.0], - [0.0, 1.0, DT_CTRL], - [0.0, 0.0, 1.0]]) - C = np.matrix([[1.0, 0.0, 0.0], - [0.0, 1.0, 0.0]]) + A = np.array([[1.0, DT_CTRL, 0.0], + [0.0, 1.0, DT_CTRL], + [0.0, 0.0, 1.0]]) + C = np.array([[1.0, 0.0, 0.0], + [0.0, 1.0, 0.0]]) # Q = np.matrix([[1e-2, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 10.0]]) # R = np.matrix([[1e-2, 0.0], [0.0, 1e3]]) # (x, l, K) = control.dare(np.transpose(A), np.transpose(C), Q, R) # K = np.transpose(K) - K = np.matrix([[7.30262179e-01, 2.07003658e-04], - [7.29394177e+00, 1.39159419e-02], - [1.71022442e+01, 3.38495381e-02]]) + K = np.array([[7.30262179e-01, 2.07003658e-04], + [7.29394177e+00, 1.39159419e-02], + [1.71022442e+01, 3.38495381e-02]]) self.K = K self.A_K = A - np.dot(K, C) - self.x = np.matrix([[0.], [0.], [0.]]) + self.x = np.array([[0.], [0.], [0.]]) - self.enfore_rate_limit = CP.carName == "toyota" + self.enforce_rate_limit = CP.carName == "toyota" self.RC = CP.lateralTuning.indi.timeConstant self.G = CP.lateralTuning.indi.actuatorEffectiveness @@ -40,16 +40,31 @@ def __init__(self, CP): self.inner_loop_gain = CP.lateralTuning.indi.innerLoopGain self.alpha = 1. - DT_CTRL / (self.RC + DT_CTRL) + self.sat_count_rate = 1.0 * DT_CTRL + self.sat_limit = CP.steerLimitTimer + self.reset() def reset(self): self.delayed_output = 0. self.output_steer = 0. - self.counter = 0 + self.sat_count = 0.0 + + def _check_saturation(self, control, check_saturation, limit): + saturated = abs(control) == limit + + if saturated and check_saturation: + self.sat_count += self.sat_count_rate + else: + self.sat_count -= self.sat_count_rate - def update(self, active, v_ego, angle_steers, angle_steers_rate, eps_torque, steer_override, CP, VM, path_plan): + self.sat_count = clip(self.sat_count, 0.0, 1.0) + + return self.sat_count > self.sat_limit + + def update(self, active, CS, CP, path_plan): # Update Kalman filter - y = np.matrix([[math.radians(angle_steers)], [math.radians(angle_steers_rate)]]) + y = np.array([[math.radians(CS.steeringAngle)], [math.radians(CS.steeringRate)]]) self.x = np.dot(self.A_K, self.x) + np.dot(self.K, y) indi_log = log.ControlsState.LateralINDIState.new_message() @@ -57,7 +72,7 @@ def update(self, active, v_ego, angle_steers, angle_steers_rate, eps_torque, ste indi_log.steerRate = math.degrees(self.x[1]) indi_log.steerAccel = math.degrees(self.x[2]) - if v_ego < 0.3 or not active: + if CS.vEgo < 0.3 or not active: indi_log.active = False self.output_steer = 0.0 self.delayed_output = 0.0 @@ -81,7 +96,7 @@ def update(self, active, v_ego, angle_steers, angle_steers_rate, eps_torque, ste delta_u = g_inv * accel_error # Enforce rate limit - if self.enfore_rate_limit: + if self.enforce_rate_limit: steer_max = float(SteerLimitParams.STEER_MAX) new_output_steer_cmd = steer_max * (self.delayed_output + delta_u) prev_output_steer_cmd = steer_max * self.output_steer @@ -90,7 +105,7 @@ def update(self, active, v_ego, angle_steers, angle_steers_rate, eps_torque, ste else: self.output_steer = self.delayed_output + delta_u - steers_max = get_steer_max(CP, v_ego) + steers_max = get_steer_max(CP, CS.vEgo) self.output_steer = clip(self.output_steer, -steers_max, steers_max) indi_log.active = True @@ -101,5 +116,7 @@ def update(self, active, v_ego, angle_steers, angle_steers_rate, eps_torque, ste indi_log.delta = float(delta_u) indi_log.output = float(self.output_steer) - self.sat_flag = False + check_saturation = (CS.vEgo > 10.) and not CS.steeringRateLimited and not CS.steeringPressed + indi_log.saturated = self._check_saturation(self.output_steer, check_saturation, steers_max) + return float(self.output_steer), float(self.angle_steers_des), indi_log diff --git a/selfdrive/controls/lib/latcontrol_lqr.py b/selfdrive/controls/lib/latcontrol_lqr.py index 8c0e3ec31f96c9..cb54e52ebdffae 100644 --- a/selfdrive/controls/lib/latcontrol_lqr.py +++ b/selfdrive/controls/lib/latcontrol_lqr.py @@ -1,72 +1,97 @@ import numpy as np from selfdrive.controls.lib.drive_helpers import get_steer_max from common.numpy_fast import clip +from common.realtime import DT_CTRL from cereal import log -class LatControlLQR(object): - def __init__(self, CP, rate=100): - self.sat_flag = False +class LatControlLQR(): + def __init__(self, CP): self.scale = CP.lateralTuning.lqr.scale self.ki = CP.lateralTuning.lqr.ki - - self.A = np.array(CP.lateralTuning.lqr.a).reshape((2,2)) - self.B = np.array(CP.lateralTuning.lqr.b).reshape((2,1)) - self.C = np.array(CP.lateralTuning.lqr.c).reshape((1,2)) - self.K = np.array(CP.lateralTuning.lqr.k).reshape((1,2)) - self.L = np.array(CP.lateralTuning.lqr.l).reshape((2,1)) + self.A = np.array(CP.lateralTuning.lqr.a).reshape((2, 2)) + self.B = np.array(CP.lateralTuning.lqr.b).reshape((2, 1)) + self.C = np.array(CP.lateralTuning.lqr.c).reshape((1, 2)) + self.K = np.array(CP.lateralTuning.lqr.k).reshape((1, 2)) + self.L = np.array(CP.lateralTuning.lqr.l).reshape((2, 1)) self.dc_gain = CP.lateralTuning.lqr.dcGain self.x_hat = np.array([[0], [0]]) - self.i_unwind_rate = 0.3 / rate - self.i_rate = 1.0 / rate + self.i_unwind_rate = 0.3 * DT_CTRL + self.i_rate = 1.0 * DT_CTRL + + self.sat_count_rate = 1.0 * DT_CTRL + self.sat_limit = CP.steerLimitTimer self.reset() def reset(self): self.i_lqr = 0.0 self.output_steer = 0.0 + self.sat_count = 0.0 + + def _check_saturation(self, control, check_saturation, limit): + saturated = abs(control) == limit + + if saturated and check_saturation: + self.sat_count += self.sat_count_rate + else: + self.sat_count -= self.sat_count_rate + + self.sat_count = clip(self.sat_count, 0.0, 1.0) - def update(self, active, v_ego, angle_steers, angle_steers_rate, eps_torque, steer_override, CP, VM, path_plan): + return self.sat_count > self.sat_limit + + def update(self, active, CS, CP, path_plan): lqr_log = log.ControlsState.LateralLQRState.new_message() - torque_scale = (0.45 + v_ego / 60.0)**2 # Scale actuator model with speed + steers_max = get_steer_max(CP, CS.vEgo) + torque_scale = (0.45 + CS.vEgo / 60.0)**2 # Scale actuator model with speed + + steering_angle = CS.steeringAngle # Subtract offset. Zero angle should correspond to zero torque self.angle_steers_des = path_plan.angleSteers - path_plan.angleOffset - angle_steers -= path_plan.angleOffset + steering_angle -= path_plan.angleOffset # Update Kalman filter angle_steers_k = float(self.C.dot(self.x_hat)) - e = angle_steers - angle_steers_k - self.x_hat = self.A.dot(self.x_hat) + self.B.dot(eps_torque / torque_scale) + self.L.dot(e) + e = steering_angle - angle_steers_k + self.x_hat = self.A.dot(self.x_hat) + self.B.dot(CS.steeringTorqueEps / torque_scale) + self.L.dot(e) - if v_ego < 0.3 or not active: + if CS.vEgo < 0.3 or not active: lqr_log.active = False + lqr_output = 0. self.reset() else: lqr_log.active = True # LQR u_lqr = float(self.angle_steers_des / self.dc_gain - self.K.dot(self.x_hat)) + lqr_output = torque_scale * u_lqr / self.scale # Integrator - if steer_override: + if CS.steeringPressed: self.i_lqr -= self.i_unwind_rate * float(np.sign(self.i_lqr)) else: - self.i_lqr += self.ki * self.i_rate * (self.angle_steers_des - angle_steers_k) + error = self.angle_steers_des - angle_steers_k + i = self.i_lqr + self.ki * self.i_rate * error + control = lqr_output + i - lqr_output = torque_scale * u_lqr / self.scale - self.i_lqr = clip(self.i_lqr, -1.0 - lqr_output, 1.0 - lqr_output) # (LQR + I) has to be between -1 and 1 + if (error >= 0 and (control <= steers_max or i < 0.0)) or \ + (error <= 0 and (control >= -steers_max or i > 0.0)): + self.i_lqr = i self.output_steer = lqr_output + self.i_lqr - - # Clip output - steers_max = get_steer_max(CP, v_ego) self.output_steer = clip(self.output_steer, -steers_max, steers_max) + check_saturation = (CS.vEgo > 10) and not CS.steeringRateLimited and not CS.steeringPressed + saturated = self._check_saturation(self.output_steer, check_saturation, steers_max) + lqr_log.steerAngle = angle_steers_k + path_plan.angleOffset lqr_log.i = self.i_lqr lqr_log.output = self.output_steer + lqr_log.lqrOutput = lqr_output + lqr_log.saturated = saturated return self.output_steer, float(self.angle_steers_des), lqr_log diff --git a/selfdrive/controls/lib/latcontrol_pid.py b/selfdrive/controls/lib/latcontrol_pid.py index 595d98912d1564..642422098ead0f 100644 --- a/selfdrive/controls/lib/latcontrol_pid.py +++ b/selfdrive/controls/lib/latcontrol_pid.py @@ -4,39 +4,42 @@ from cereal import log -class LatControlPID(object): +class LatControlPID(): def __init__(self, CP): self.pid = PIController((CP.lateralTuning.pid.kpBP, CP.lateralTuning.pid.kpV), (CP.lateralTuning.pid.kiBP, CP.lateralTuning.pid.kiV), - k_f=CP.lateralTuning.pid.kf, pos_limit=1.0) + k_f=CP.lateralTuning.pid.kf, pos_limit=1.0, neg_limit=-1.0, + sat_limit=CP.steerLimitTimer) self.angle_steers_des = 0. def reset(self): self.pid.reset() - def update(self, active, v_ego, angle_steers, angle_steers_rate, eps_torque, steer_override, CP, VM, path_plan): + def update(self, active, CS, CP, path_plan): pid_log = log.ControlsState.LateralPIDState.new_message() - pid_log.steerAngle = float(angle_steers) - pid_log.steerRate = float(angle_steers_rate) + pid_log.steerAngle = float(CS.steeringAngle) + pid_log.steerRate = float(CS.steeringRate) - if v_ego < 0.3 or not active: + if CS.vEgo < 0.3 or not active: output_steer = 0.0 pid_log.active = False self.pid.reset() else: - self.angle_steers_des = path_plan.angleSteers # get from MPC/PathPlanner + self.angle_steers_des = path_plan.angleSteers # get from MPC/PathPlanner - steers_max = get_steer_max(CP, v_ego) + steers_max = get_steer_max(CP, CS.vEgo) self.pid.pos_limit = steers_max self.pid.neg_limit = -steers_max steer_feedforward = self.angle_steers_des # feedforward desired angle if CP.steerControlType == car.CarParams.SteerControlType.torque: # TODO: feedforward something based on path_plan.rateSteers steer_feedforward -= path_plan.angleOffset # subtract the offset, since it does not contribute to resistive torque - steer_feedforward *= v_ego**2 # proportional to realigning tire momentum (~ lateral accel) + steer_feedforward *= CS.vEgo**2 # proportional to realigning tire momentum (~ lateral accel) deadzone = 0.0 - output_steer = self.pid.update(self.angle_steers_des, angle_steers, check_saturation=(v_ego > 10), override=steer_override, - feedforward=steer_feedforward, speed=v_ego, deadzone=deadzone) + + check_saturation = (CS.vEgo > 10) and not CS.steeringRateLimited and not CS.steeringPressed + output_steer = self.pid.update(self.angle_steers_des, CS.steeringAngle, check_saturation=check_saturation, override=CS.steeringPressed, + feedforward=steer_feedforward, speed=CS.vEgo, deadzone=deadzone) pid_log.active = True pid_log.p = self.pid.p pid_log.i = self.pid.i @@ -44,6 +47,9 @@ def update(self, active, v_ego, angle_steers, angle_steers_rate, eps_torque, ste pid_log.output = output_steer pid_log.saturated = bool(self.pid.saturated) - self.sat_flag = self.pid.saturated + # we only deal with Tesla, so we return two angles, no torque info - return float(self.angle_steers_des), path_plan.angleSteers, pid_log + if CP.carName == "tesla": + return float(self.angle_steers_des), path_plan.angleSteers, pid_log + else: + return output_steer, float(self.angle_steers_des), pid_log diff --git a/selfdrive/controls/lib/lateral_mpc/.gitignore b/selfdrive/controls/lib/lateral_mpc/.gitignore new file mode 100644 index 00000000000000..f61a939cdaa77e --- /dev/null +++ b/selfdrive/controls/lib/lateral_mpc/.gitignore @@ -0,0 +1,2 @@ +generator +lib_qp/ diff --git a/selfdrive/controls/lib/lateral_mpc/Makefile b/selfdrive/controls/lib/lateral_mpc/Makefile deleted file mode 100644 index 42970efd661e75..00000000000000 --- a/selfdrive/controls/lib/lateral_mpc/Makefile +++ /dev/null @@ -1,89 +0,0 @@ - -CC = clang -CXX = clang++ - -PHONELIBS = ../../../../phonelibs - -UNAME_S := $(shell uname -s) -UNAME_M := $(shell uname -m) - -CFLAGS = -O3 -fPIC -I. -CXXFLAGS = -O3 -fPIC -I. - -QPOASES_FLAGS = -I$(PHONELIBS)/qpoases -I$(PHONELIBS)/qpoases/INCLUDE -I$(PHONELIBS)/qpoases/SRC - -ACADO_FLAGS = -I$(PHONELIBS)/acado/include -I$(PHONELIBS)/acado/include/acado - -ifeq ($(UNAME_S),Darwin) -ACADO_LIBS := -lacado_toolkit_s -else ifeq ($(UNAME_M),aarch64) -ACADO_LIBS := -L $(PHONELIBS)/acado/aarch64/lib -l:libacado_toolkit.a -l:libacado_casadi.a -l:libacado_csparse.a -CFLAGS += -mcpu=cortex-a57 -CXXFLAGS += -mcpu=cortex-a57 -else -ACADO_LIBS := -L $(PHONELIBS)/acado/x64/lib -l:libacado_toolkit.a -l:libacado_casadi.a -l:libacado_csparse.a -endif - -OBJS = \ - lib_qp/Bounds.o \ - lib_qp/Constraints.o \ - lib_qp/CyclingManager.o \ - lib_qp/Indexlist.o \ - lib_qp/MessageHandling.o \ - lib_qp/QProblem.o \ - lib_qp/QProblemB.o \ - lib_qp/SubjectTo.o \ - lib_qp/Utils.o \ - lib_qp/EXTRAS/SolutionAnalysis.o \ - lib_mpc_export/acado_qpoases_interface.o \ - lib_mpc_export/acado_integrator.o \ - lib_mpc_export/acado_solver.o \ - lib_mpc_export/acado_auxiliary_functions.o \ - lateral_mpc.o - -DEPS := $(OBJS:.o=.d) - -.PHONY: all -all: libmpc.so - -libmpc.so: $(OBJS) - $(CXX) -shared -o '$@' $^ -lm - -lib_qp/%.o: $(PHONELIBS)/qpoases/SRC/%.cpp - @echo "[ CXX ] $@" - mkdir -p lib_qp/EXTRAS - $(CXX) $(CXXFLAGS) -MMD \ - -I lib_mpc_export/ \ - $(QPOASES_FLAGS) \ - -c -o '$@' '$<' - -%.o: %.cpp - @echo "[ CXX ] $@" - $(CXX) $(CXXFLAGS) -MMD \ - -I lib_mpc_export/ \ - $(QPOASES_FLAGS) \ - -c -o '$@' '$<' - -%.o: %.c - @echo "[ CC ] $@" - $(CC) $(CFLAGS) -MMD \ - -I lib_mpc_export/ \ - $(QPOASES_FLAGS) \ - -c -o '$@' '$<' - -generator: generator.cpp - $(CXX) -v -Wall -std=c++11 \ - generator.cpp \ - -o generator \ - $(ACADO_FLAGS) \ - $(ACADO_LIBS) - -.PHONY: generate -generate: generator - ./generator - -.PHONY: clean -clean: - rm -f *.so generator $(OBJS) $(DEPS) - --include $(DEPS) diff --git a/selfdrive/controls/lib/lateral_mpc/SConscript b/selfdrive/controls/lib/lateral_mpc/SConscript new file mode 100644 index 00000000000000..6cdc22d17d1fb8 --- /dev/null +++ b/selfdrive/controls/lib/lateral_mpc/SConscript @@ -0,0 +1,29 @@ +Import('env', 'arch') + +cpp_path = [ + "#phonelibs/acado/include", + "#phonelibs/acado/include/acado", + "#phonelibs/qpoases/INCLUDE", + "#phonelibs/qpoases/INCLUDE/EXTRAS", + "#phonelibs/qpoases/SRC/", + "#phonelibs/qpoases", + "lib_mpc_export" + +] + +mpc_files = [ + "lateral_mpc.c", + Glob("lib_mpc_export/*.c"), + Glob("lib_mpc_export/*.cpp"), +] + +interface_dir = Dir('lib_mpc_export') + +SConscript(['#phonelibs/qpoases/SConscript'], variant_dir='lib_qp', exports=['interface_dir']) + +env.SharedLibrary('mpc', mpc_files, LIBS=['m', 'qpoases'], LIBPATH=['lib_qp'], CPPPATH=cpp_path) +# if arch != "aarch64": +# acado_libs = [File("#phonelibs/acado/x64/lib/libacado_toolkit.a"), +# File("#phonelibs/acado/x64/lib/libacado_casadi.a"), +# File("#phonelibs/acado/x64/lib/libacado_csparse.a")] +# env.Program('generator', 'generator.cpp', LIBS=acado_libs, CPPPATH=cpp_path) diff --git a/selfdrive/controls/lib/lateral_mpc/lateral_mpc.c b/selfdrive/controls/lib/lateral_mpc/lateral_mpc.c index d8d29cc61c07b2..4972dbc3ff6ec3 100644 --- a/selfdrive/controls/lib/lateral_mpc/lateral_mpc.c +++ b/selfdrive/controls/lib/lateral_mpc/lateral_mpc.c @@ -30,22 +30,10 @@ typedef struct { double cost; } log_t; -void init(double pathCost, double laneCost, double headingCost, double steerRateCost){ - acado_initializeSolver(); +void init_weights(double pathCost, double laneCost, double headingCost, double steerRateCost){ int i; const int STEP_MULTIPLIER = 3; - /* Initialize the states and controls. */ - for (i = 0; i < NX * (N + 1); ++i) acadoVariables.x[ i ] = 0.0; - for (i = 0; i < NU * N; ++i) acadoVariables.u[ i ] = 0.1; - - /* Initialize the measurements/reference. */ - for (i = 0; i < NY * N; ++i) acadoVariables.y[ i ] = 0.0; - for (i = 0; i < NYN; ++i) acadoVariables.yN[ i ] = 0.0; - - /* MPC: initialize the current state feedback. */ - for (i = 0; i < NX; ++i) acadoVariables.x0[ i ] = 0.0; - for (i = 0; i < N; i++) { int f = 1; if (i > 4){ @@ -64,6 +52,24 @@ void init(double pathCost, double laneCost, double headingCost, double steerRate acadoVariables.WN[(NYN+1)*3] = headingCost * STEP_MULTIPLIER; } +void init(double pathCost, double laneCost, double headingCost, double steerRateCost){ + acado_initializeSolver(); + int i; + + /* Initialize the states and controls. */ + for (i = 0; i < NX * (N + 1); ++i) acadoVariables.x[ i ] = 0.0; + for (i = 0; i < NU * N; ++i) acadoVariables.u[ i ] = 0.1; + + /* Initialize the measurements/reference. */ + for (i = 0; i < NY * N; ++i) acadoVariables.y[ i ] = 0.0; + for (i = 0; i < NYN; ++i) acadoVariables.yN[ i ] = 0.0; + + /* MPC: initialize the current state feedback. */ + for (i = 0; i < NX; ++i) acadoVariables.x0[ i ] = 0.0; + + init_weights(pathCost, laneCost, headingCost, steerRateCost); +} + int run_mpc(state_t * x0, log_t * solution, double l_poly[4], double r_poly[4], double d_poly[4], double l_prob, double r_prob, double curvature_factor, double v_ref, double lane_width){ diff --git a/selfdrive/controls/lib/lateral_mpc/libmpc_py.py b/selfdrive/controls/lib/lateral_mpc/libmpc_py.py index 92c0df8da4b729..9fc3a6c40b3c39 100644 --- a/selfdrive/controls/lib/lateral_mpc/libmpc_py.py +++ b/selfdrive/controls/lib/lateral_mpc/libmpc_py.py @@ -1,11 +1,10 @@ import os -import subprocess from cffi import FFI +from common.ffi_wrapper import suffix mpc_dir = os.path.dirname(os.path.abspath(__file__)) -libmpc_fn = os.path.join(mpc_dir, "libmpc.so") -subprocess.check_call(["make", "-j4"], cwd=mpc_dir) +libmpc_fn = os.path.join(mpc_dir, "libmpc"+suffix()) ffi = FFI() ffi.cdef(""" @@ -23,6 +22,7 @@ } log_t; void init(double pathCost, double laneCost, double headingCost, double steerRateCost); +void init_weights(double pathCost, double laneCost, double headingCost, double steerRateCost); int run_mpc(state_t * x0, log_t * solution, double l_poly[4], double r_poly[4], double d_poly[4], double l_prob, double r_prob, double curvature_factor, double v_ref, double lane_width); diff --git a/selfdrive/controls/lib/long_mpc.py b/selfdrive/controls/lib/long_mpc.py index 9d43e97f26b5fd..f9bf15cc048067 100644 --- a/selfdrive/controls/lib/long_mpc.py +++ b/selfdrive/controls/lib/long_mpc.py @@ -1,7 +1,7 @@ import os -import numpy as np +import math -import selfdrive.messaging as messaging +import cereal.messaging as messaging from selfdrive.swaglog import cloudlog from common.realtime import sec_since_boot from selfdrive.controls.lib.radar_helpers import _LEAD_ACCEL_TAU @@ -11,9 +11,8 @@ LOG_MPC = os.environ.get('LOG_MPC', False) -class LongitudinalMpc(object): - def __init__(self, mpc_id, live_longitudinal_mpc): - self.live_longitudinal_mpc = live_longitudinal_mpc +class LongitudinalMpc(): + def __init__(self, mpc_id): self.mpc_id = mpc_id self.setup_mpc() @@ -27,10 +26,9 @@ def __init__(self, mpc_id, live_longitudinal_mpc): self.last_cloudlog_t = 0.0 - def send_mpc_solution(self, qp_iterations, calculation_time): + def send_mpc_solution(self, pm, qp_iterations, calculation_time): qp_iterations = max(0, qp_iterations) - dat = messaging.new_message() - dat.init('liveLongitudinalMpc') + dat = messaging.new_message('liveLongitudinalMpc') dat.liveLongitudinalMpc.xEgo = list(self.mpc_solution[0].x_ego) dat.liveLongitudinalMpc.vEgo = list(self.mpc_solution[0].v_ego) dat.liveLongitudinalMpc.aEgo = list(self.mpc_solution[0].a_ego) @@ -41,7 +39,7 @@ def send_mpc_solution(self, qp_iterations, calculation_time): dat.liveLongitudinalMpc.qpIterations = qp_iterations dat.liveLongitudinalMpc.mpcId = self.mpc_id dat.liveLongitudinalMpc.calculationTime = calculation_time - self.live_longitudinal_mpc.send(dat.to_bytes()) + pm.send('liveLongitudinalMpc', dat) def setup_mpc(self): ffi, self.libmpc = libmpc_py.get_libmpc(self.mpc_id) @@ -58,7 +56,7 @@ def set_cur_state(self, v, a): self.cur_state[0].v_ego = v self.cur_state[0].a_ego = a - def update(self, CS, lead, v_cruise_setpoint): + def update(self, pm, CS, lead): v_ego = CS.vEgo # Setup current mpc state @@ -97,7 +95,7 @@ def update(self, CS, lead, v_cruise_setpoint): duration = int((sec_since_boot() - t) * 1e9) if LOG_MPC: - self.send_mpc_solution(n_its, duration) + self.send_mpc_solution(pm, n_its, duration) # Get solution. MPC timestep is 0.2 s, so interpolation to 0.05 s is needed self.v_mpc = self.mpc_solution[0].v_ego[1] @@ -105,10 +103,9 @@ def update(self, CS, lead, v_cruise_setpoint): self.v_mpc_future = self.mpc_solution[0].v_ego[10] # Reset if NaN or goes through lead car - dls = np.array(list(self.mpc_solution[0].x_l)) - np.array(list(self.mpc_solution[0].x_ego)) - crashing = min(dls) < -50.0 - nans = np.any(np.isnan(list(self.mpc_solution[0].v_ego))) - backwards = min(list(self.mpc_solution[0].v_ego)) < -0.01 + crashing = any(lead - ego < -50 for (lead, ego) in zip(self.mpc_solution[0].x_l, self.mpc_solution[0].x_ego)) + nans = any(math.isnan(x) for x in self.mpc_solution[0].v_ego) + backwards = min(self.mpc_solution[0].v_ego) < -0.01 if ((backwards or crashing) and self.prev_lead_status) or nans: if t > self.last_cloudlog_t + 5.0: diff --git a/selfdrive/controls/lib/long_mpc_model.py b/selfdrive/controls/lib/long_mpc_model.py new file mode 100644 index 00000000000000..b3a55b8f097f47 --- /dev/null +++ b/selfdrive/controls/lib/long_mpc_model.py @@ -0,0 +1,73 @@ +import numpy as np +import math + +from selfdrive.swaglog import cloudlog +from common.realtime import sec_since_boot +from selfdrive.controls.lib.longitudinal_mpc_model import libmpc_py + + +class LongitudinalMpcModel(): + def __init__(self): + + self.setup_mpc() + self.v_mpc = 0.0 + self.v_mpc_future = 0.0 + self.a_mpc = 0.0 + self.last_cloudlog_t = 0.0 + self.ts = list(range(10)) + + self.valid = False + + def setup_mpc(self, v_ego=0.0): + self.libmpc = libmpc_py.libmpc + self.libmpc.init(1.0, 1.0, 1.0, 1.0, 1.0) + self.libmpc.init_with_simulation(v_ego) + + self.mpc_solution = libmpc_py.ffi.new("log_t *") + self.cur_state = libmpc_py.ffi.new("state_t *") + + self.cur_state[0].x_ego = 0 + self.cur_state[0].v_ego = 0 + self.cur_state[0].a_ego = 0 + + def set_cur_state(self, v, a): + self.cur_state[0].x_ego = 0.0 + self.cur_state[0].v_ego = v + self.cur_state[0].a_ego = a + + def update(self, v_ego, a_ego, poss, speeds, accels): + if len(poss) == 0: + self.valid = False + return + + x_poly = list(map(float, np.polyfit(self.ts, poss, 3))) + v_poly = list(map(float, np.polyfit(self.ts, speeds, 3))) + a_poly = list(map(float, np.polyfit(self.ts, accels, 3))) + + # Calculate mpc + self.libmpc.run_mpc(self.cur_state, self.mpc_solution, x_poly, v_poly, a_poly) + + # Get solution. MPC timestep is 0.2 s, so interpolation to 0.05 s is needed + self.v_mpc = self.mpc_solution[0].v_ego[1] + self.a_mpc = self.mpc_solution[0].a_ego[1] + self.v_mpc_future = self.mpc_solution[0].v_ego[10] + self.valid = True + + # Reset if NaN or goes through lead car + nans = any(math.isnan(x) for x in self.mpc_solution[0].v_ego) + + t = sec_since_boot() + if nans: + if t > self.last_cloudlog_t + 5.0: + self.last_cloudlog_t = t + cloudlog.warning("Longitudinal model mpc reset - backwards") + + self.libmpc.init(1.0, 1.0, 1.0, 1.0, 1.0) + self.libmpc.init_with_simulation(v_ego) + + self.cur_state[0].v_ego = v_ego + self.cur_state[0].a_ego = 0.0 + + self.v_mpc = v_ego + self.a_mpc = a_ego + self.valid = False diff --git a/selfdrive/controls/lib/longcontrol.py b/selfdrive/controls/lib/longcontrol.py index bd934727d02c98..9de413927c06fb 100644 --- a/selfdrive/controls/lib/longcontrol.py +++ b/selfdrive/controls/lib/longcontrol.py @@ -1,32 +1,28 @@ from cereal import log from common.numpy_fast import clip, interp from selfdrive.controls.lib.pid import PIController +from selfdrive.controls.lib.pid_real import PIDController LongCtrlState = log.ControlsState.LongControlState STOPPING_EGO_SPEED = 0.5 -MIN_CAN_SPEED = 0.3 # TODO: parametrize this in car interface -STOPPING_TARGET_SPEED = MIN_CAN_SPEED + 0.01 +STOPPING_TARGET_SPEED_OFFSET = 0.01 STARTING_TARGET_SPEED = 0.5 BRAKE_THRESHOLD_TO_PID = 0.2 -STOPPING_BRAKE_RATE = 0.2 # brake_travel/s while trying to stop -STARTING_BRAKE_RATE = 0.8 # brake_travel/s while releasing on restart BRAKE_STOPPING_TARGET = 0.5 # apply at least this amount of brake to maintain the vehicle stationary -_MAX_SPEED_ERROR_BP = [0., 30.] # speed breakpoints -_MAX_SPEED_ERROR_V = [1.5, .8] # max positive v_pid error VS actual speed; this avoids controls windup due to slow pedal resp - RATE = 100.0 def long_control_state_trans(active, long_control_state, v_ego, v_target, v_pid, - output_gb, brake_pressed, cruise_standstill): + output_gb, brake_pressed, cruise_standstill, min_speed_can): """Update longitudinal control state machine""" + stopping_target_speed = min_speed_can + STOPPING_TARGET_SPEED_OFFSET stopping_condition = (v_ego < 2.0 and cruise_standstill) or \ - (v_ego < STOPPING_EGO_SPEED and \ - ((v_pid < STOPPING_TARGET_SPEED and v_target < STOPPING_TARGET_SPEED) or - brake_pressed)) + (v_ego < STOPPING_EGO_SPEED and + ((v_pid < stopping_target_speed and v_target < stopping_target_speed) or + brake_pressed)) starting_condition = v_target > STARTING_TARGET_SPEED and not cruise_standstill @@ -55,14 +51,27 @@ def long_control_state_trans(active, long_control_state, v_ego, v_target, v_pid, return long_control_state -class LongControl(object): +class LongControl(): def __init__(self, CP, compute_gb): + + kdBp = [0, 5., 22.,35.] + kdV = [0.02, 0.02, 0.022, 0.025] + self.long_control_state = LongCtrlState.off # initialized to off - self.pid = PIController((CP.longitudinalTuning.kpBP, CP.longitudinalTuning.kpV), + if CP.carName == "tesla": + self.pid = PIDController((CP.longitudinalTuning.kpBP, CP.longitudinalTuning.kpV), + (CP.longitudinalTuning.kiBP, CP.longitudinalTuning.kiV), + (kdBp,kdV), + rate=RATE, + sat_limit=0.8, + convert=compute_gb) + else: + self.pid = PIController((CP.longitudinalTuning.kpBP, CP.longitudinalTuning.kpV), (CP.longitudinalTuning.kiBP, CP.longitudinalTuning.kiV), rate=RATE, sat_limit=0.8, convert=compute_gb) + self.v_pid = 0.0 self.last_output_gb = 0.0 @@ -71,23 +80,22 @@ def reset(self, v_pid): self.pid.reset() self.v_pid = v_pid - def update(self, active, v_ego, brake_pressed, standstill, cruise_standstill, v_cruise, v_target, v_target_future, a_target, CP): + def update(self, active, CS, v_target, v_target_future, a_target, CP): """Update longitudinal control. This updates the state machine and runs a PID loop""" # Actuation limits - gas_max = interp(v_ego, CP.gasMaxBP, CP.gasMaxV) - brake_max = interp(v_ego, CP.brakeMaxBP, CP.brakeMaxV) + gas_max = interp(CS.vEgo, CP.gasMaxBP, CP.gasMaxV) + brake_max = interp(CS.vEgo, CP.brakeMaxBP, CP.brakeMaxV) # Update state machine output_gb = self.last_output_gb - self.long_control_state = long_control_state_trans(active, self.long_control_state, v_ego, + self.long_control_state = long_control_state_trans(active, self.long_control_state, CS.vEgo, v_target_future, self.v_pid, output_gb, - brake_pressed, cruise_standstill) + CS.brakePressed, CS.cruiseState.standstill, CP.minSpeedCan) - v_ego_pid = max(v_ego, MIN_CAN_SPEED) # Without this we get jumps, CAN bus reports 0 when speed < 0.3 + v_ego_pid = max(CS.vEgo, CP.minSpeedCan) # Without this we get jumps, CAN bus reports 0 when speed < 0.3 - if self.long_control_state == LongCtrlState.off: - self.v_pid = v_ego_pid - self.pid.reset() + if self.long_control_state == LongCtrlState.off or CS.gasPressed: + self.reset(v_ego_pid) output_gb = 0. # tracking objects and driving @@ -98,7 +106,7 @@ def update(self, active, v_ego, brake_pressed, standstill, cruise_standstill, v_ # Toyota starts braking more when it thinks you want to stop # Freeze the integrator so we don't accelerate to compensate, and don't allow positive acceleration - prevent_overshoot = not CP.stoppingControl and v_ego < 1.5 and v_target_future < 0.7 + prevent_overshoot = not CP.stoppingControl and CS.vEgo < 1.5 and v_target_future < 0.7 deadzone = interp(v_ego_pid, CP.longitudinalTuning.deadzoneBP, CP.longitudinalTuning.deadzoneV) output_gb = self.pid.update(self.v_pid, v_ego_pid, speed=v_ego_pid, deadzone=deadzone, feedforward=a_target, freeze_integrator=prevent_overshoot) @@ -109,22 +117,20 @@ def update(self, active, v_ego, brake_pressed, standstill, cruise_standstill, v_ # Intention is to stop, switch to a different brake control until we stop elif self.long_control_state == LongCtrlState.stopping: # Keep applying brakes until the car is stopped - if not standstill or output_gb > -BRAKE_STOPPING_TARGET: - output_gb -= STOPPING_BRAKE_RATE / RATE + if not CS.standstill or output_gb > -BRAKE_STOPPING_TARGET: + output_gb -= CP.stoppingBrakeRate / RATE output_gb = clip(output_gb, -brake_max, gas_max) - self.v_pid = v_ego - self.pid.reset() + self.reset(CS.vEgo) # Intention is to move again, release brake fast before handing control to PID elif self.long_control_state == LongCtrlState.starting: if output_gb < -0.2: - output_gb += STARTING_BRAKE_RATE / RATE - self.v_pid = v_ego - self.pid.reset() + output_gb += CP.startingBrakeRate / RATE + self.reset(CS.vEgo) self.last_output_gb = output_gb final_gas = clip(output_gb, 0., gas_max) final_brake = -clip(output_gb, -brake_max, 0.) - return final_gas, final_brake \ No newline at end of file + return final_gas, final_brake diff --git a/selfdrive/controls/lib/longitudinal_mpc/.gitignore b/selfdrive/controls/lib/longitudinal_mpc/.gitignore new file mode 100644 index 00000000000000..f61a939cdaa77e --- /dev/null +++ b/selfdrive/controls/lib/longitudinal_mpc/.gitignore @@ -0,0 +1,2 @@ +generator +lib_qp/ diff --git a/selfdrive/controls/lib/longitudinal_mpc/Makefile b/selfdrive/controls/lib/longitudinal_mpc/Makefile deleted file mode 100644 index e00914c2147005..00000000000000 --- a/selfdrive/controls/lib/longitudinal_mpc/Makefile +++ /dev/null @@ -1,91 +0,0 @@ -CC = clang -CXX = clang++ - -PHONELIBS = ../../../../phonelibs - -UNAME_S := $(shell uname -s) -UNAME_M := $(shell uname -m) - -CFLAGS = -O3 -fPIC -I. -CXXFLAGS = -O3 -fPIC -I. - -QPOASES_FLAGS = -I$(PHONELIBS)/qpoases -I$(PHONELIBS)/qpoases/INCLUDE -I$(PHONELIBS)/qpoases/SRC - -ACADO_FLAGS = -I$(PHONELIBS)/acado/include -I$(PHONELIBS)/acado/include/acado - -ifeq ($(UNAME_S),Darwin) -ACADO_LIBS := -lacado_toolkit_s -else ifeq ($(UNAME_M),aarch64) -ACADO_LIBS := -L $(PHONELIBS)/acado/aarch64/lib -l:libacado_toolkit.a -l:libacado_casadi.a -l:libacado_csparse.a -CFLAGS += -mcpu=cortex-a57 -CXXFLAGS += -mcpu=cortex-a57 -else -ACADO_LIBS := -L $(PHONELIBS)/acado/x64/lib -l:libacado_toolkit.a -l:libacado_casadi.a -l:libacado_csparse.a -endif - -OBJS = \ - lib_qp/Bounds.o \ - lib_qp/Constraints.o \ - lib_qp/CyclingManager.o \ - lib_qp/Indexlist.o \ - lib_qp/MessageHandling.o \ - lib_qp/QProblem.o \ - lib_qp/QProblemB.o \ - lib_qp/SubjectTo.o \ - lib_qp/Utils.o \ - lib_qp/EXTRAS/SolutionAnalysis.o \ - lib_mpc_export/acado_qpoases_interface.o \ - lib_mpc_export/acado_integrator.o \ - lib_mpc_export/acado_solver.o \ - lib_mpc_export/acado_auxiliary_functions.o \ - longitudinal_mpc.o - -DEPS := $(OBJS:.o=.d) - -.PHONY: all -all: libmpc1.so libmpc2.so - -libmpc1.so: $(OBJS) - $(CXX) -shared -o '$@' $^ -lm - -libmpc2.so: libmpc1.so - cp libmpc1.so libmpc2.so - -lib_qp/%.o: $(PHONELIBS)/qpoases/SRC/%.cpp - @echo "[ CXX ] $@" - mkdir -p lib_qp/EXTRAS - $(CXX) $(CXXFLAGS) -MMD \ - -I lib_mpc_export/ \ - $(QPOASES_FLAGS) \ - -c -o '$@' '$<' - -%.o: %.cpp - @echo "[ CXX ] $@" - $(CXX) $(CXXFLAGS) -MMD \ - -I lib_mpc_export/ \ - $(QPOASES_FLAGS) \ - -c -o '$@' '$<' - -%.o: %.c - @echo "[ CC ] $@" - $(CC) $(CFLAGS) -MMD \ - -I lib_mpc_export/ \ - $(QPOASES_FLAGS) \ - -c -o '$@' '$<' - -generator: generator.cpp - $(CXX) -Wall -std=c++11 \ - generator.cpp \ - -o generator \ - $(ACADO_FLAGS) \ - $(ACADO_LIBS) - -.PHONY: generate -generate: generator - ./generator - -.PHONY: clean -clean: - rm -f *.so generator $(OBJS) $(DEPS) - --include $(DEPS) diff --git a/selfdrive/controls/lib/longitudinal_mpc/SConscript b/selfdrive/controls/lib/longitudinal_mpc/SConscript new file mode 100644 index 00000000000000..072ff646ae7fe5 --- /dev/null +++ b/selfdrive/controls/lib/longitudinal_mpc/SConscript @@ -0,0 +1,32 @@ +Import('env', 'arch') + + +cpp_path = [ + "#phonelibs/acado/include", + "#phonelibs/acado/include/acado", + "#phonelibs/qpoases/INCLUDE", + "#phonelibs/qpoases/INCLUDE/EXTRAS", + "#phonelibs/qpoases/SRC/", + "#phonelibs/qpoases", + "lib_mpc_export" + +] + +mpc_files = [ + "longitudinal_mpc.c", + Glob("lib_mpc_export/*.c"), + Glob("lib_mpc_export/*.cpp"), +] + +interface_dir = Dir('lib_mpc_export') + +SConscript(['#phonelibs/qpoases/SConscript'], variant_dir='lib_qp', exports=['interface_dir']) + +env.SharedLibrary('mpc1', mpc_files, LIBS=['m', 'qpoases'], LIBPATH=['lib_qp'], CPPPATH=cpp_path) +env.SharedLibrary('mpc2', mpc_files, LIBS=['m', 'qpoases'], LIBPATH=['lib_qp'], CPPPATH=cpp_path) + +# if arch != "aarch64": +# acado_libs = [File("#phonelibs/acado/x64/lib/libacado_toolkit.a"), +# File("#phonelibs/acado/x64/lib/libacado_casadi.a"), +# File("#phonelibs/acado/x64/lib/libacado_csparse.a")] +# env.Program('generator', 'generator.cpp', LIBS=acado_libs, CPPPATH=cpp_path) diff --git a/selfdrive/controls/lib/longitudinal_mpc/libmpc_py.py b/selfdrive/controls/lib/longitudinal_mpc/libmpc_py.py index 95e9135a813770..c40b4e071eb640 100644 --- a/selfdrive/controls/lib/longitudinal_mpc/libmpc_py.py +++ b/selfdrive/controls/lib/longitudinal_mpc/libmpc_py.py @@ -1,22 +1,12 @@ import os -import platform -import subprocess from cffi import FFI +from common.ffi_wrapper import suffix mpc_dir = os.path.join(os.path.dirname(os.path.abspath(__file__))) -if platform.machine() == "x86_64": - try: - FFI().dlopen(os.path.join(mpc_dir, "libmpc1.so")) - except OSError: - # libmpc1.so is likely built for aarch64. cleaning... - subprocess.check_call(["make", "clean"], cwd=mpc_dir) - -subprocess.check_call(["make", "-j4"], cwd=mpc_dir) - def _get_libmpc(mpc_id): - libmpc_fn = os.path.join(mpc_dir, "libmpc%d.so" % mpc_id) + libmpc_fn = os.path.join(mpc_dir, "libmpc%d%s" % (mpc_id, suffix())) ffi = FFI() ffi.cdef(""" diff --git a/selfdrive/controls/lib/longitudinal_mpc_model/.gitignore b/selfdrive/controls/lib/longitudinal_mpc_model/.gitignore new file mode 100644 index 00000000000000..f61a939cdaa77e --- /dev/null +++ b/selfdrive/controls/lib/longitudinal_mpc_model/.gitignore @@ -0,0 +1,2 @@ +generator +lib_qp/ diff --git a/selfdrive/controls/lib/longitudinal_mpc_model/SConscript b/selfdrive/controls/lib/longitudinal_mpc_model/SConscript new file mode 100644 index 00000000000000..f474bf798fe505 --- /dev/null +++ b/selfdrive/controls/lib/longitudinal_mpc_model/SConscript @@ -0,0 +1,31 @@ +Import('env', 'arch') + + +cpp_path = [ + "#phonelibs/acado/include", + "#phonelibs/acado/include/acado", + "#phonelibs/qpoases/INCLUDE", + "#phonelibs/qpoases/INCLUDE/EXTRAS", + "#phonelibs/qpoases/SRC/", + "#phonelibs/qpoases", + "lib_mpc_export" + +] + +mpc_files = [ + "longitudinal_mpc.c", + Glob("lib_mpc_export/*.c"), + Glob("lib_mpc_export/*.cpp"), +] + +interface_dir = Dir('lib_mpc_export') + +SConscript(['#phonelibs/qpoases/SConscript'], variant_dir='lib_qp', exports=['interface_dir']) + +env.SharedLibrary('mpc', mpc_files, LIBS=['m', 'qpoases'], LIBPATH=['lib_qp'], CPPPATH=cpp_path) + +# if arch != "aarch64": +# acado_libs = [File("#phonelibs/acado/x64/lib/libacado_toolkit.a"), +# File("#phonelibs/acado/x64/lib/libacado_casadi.a"), +# File("#phonelibs/acado/x64/lib/libacado_csparse.a")] +# env.Program('generator', 'generator.cpp', LIBS=acado_libs, CPPPATH=cpp_path) diff --git a/selfdrive/can/tests/__init__.py b/selfdrive/controls/lib/longitudinal_mpc_model/__init__.py similarity index 100% rename from selfdrive/can/tests/__init__.py rename to selfdrive/controls/lib/longitudinal_mpc_model/__init__.py diff --git a/selfdrive/controls/lib/longitudinal_mpc_model/generator.cpp b/selfdrive/controls/lib/longitudinal_mpc_model/generator.cpp new file mode 100644 index 00000000000000..129b52a7604208 --- /dev/null +++ b/selfdrive/controls/lib/longitudinal_mpc_model/generator.cpp @@ -0,0 +1,99 @@ +#include + +const int controlHorizon = 50; + +using namespace std; + + +int main( ) +{ + USING_NAMESPACE_ACADO + + + DifferentialEquation f; + + DifferentialState x_ego, v_ego, a_ego, t; + + OnlineData x_poly_r0, x_poly_r1, x_poly_r2, x_poly_r3; + OnlineData v_poly_r0, v_poly_r1, v_poly_r2, v_poly_r3; + OnlineData a_poly_r0, a_poly_r1, a_poly_r2, a_poly_r3; + + Control j_ego; + + // Equations of motion + f << dot(x_ego) == v_ego; + f << dot(v_ego) == a_ego; + f << dot(a_ego) == j_ego; + f << dot(t) == 1; + + auto poly_x = x_poly_r0*(t*t*t) + x_poly_r1*(t*t) + x_poly_r2*t + x_poly_r3; + auto poly_v = v_poly_r0*(t*t*t) + v_poly_r1*(t*t) + v_poly_r2*t + v_poly_r3; + auto poly_a = a_poly_r0*(t*t*t) + a_poly_r1*(t*t) + a_poly_r2*t + a_poly_r3; + + // Running cost + Function h; + h << x_ego - poly_x; + h << v_ego - poly_v; + h << a_ego - poly_a; + h << a_ego * (0.1 * v_ego + 1.0); + h << j_ego * (0.1 * v_ego + 1.0); + + // Weights are defined in mpc. + BMatrix Q(5,5); Q.setAll(true); + + // Terminal cost + Function hN; + hN << x_ego - poly_x; + hN << v_ego - poly_v; + hN << a_ego - poly_a; + hN << a_ego * (0.1 * v_ego + 1.0); + + // Weights are defined in mpc. + BMatrix QN(4,4); QN.setAll(true); + + // Non uniform time grid + // First 5 timesteps are 0.2, after that it's 0.6 + DMatrix numSteps(20, 1); + for (int i = 0; i < 5; i++){ + numSteps(i) = 1; + } + for (int i = 5; i < 20; i++){ + numSteps(i) = 3; + } + + // Setup Optimal Control Problem + const double tStart = 0.0; + const double tEnd = 10.0; + + OCP ocp( tStart, tEnd, numSteps); + ocp.subjectTo(f); + + ocp.minimizeLSQ(Q, h); + ocp.minimizeLSQEndTerm(QN, hN); + + //ocp.subjectTo( 0.0 <= v_ego); + ocp.setNOD(12); + + OCPexport mpc(ocp); + mpc.set( HESSIAN_APPROXIMATION, GAUSS_NEWTON ); + mpc.set( DISCRETIZATION_TYPE, MULTIPLE_SHOOTING ); + mpc.set( INTEGRATOR_TYPE, INT_RK4 ); + mpc.set( NUM_INTEGRATOR_STEPS, controlHorizon); + mpc.set( MAX_NUM_QP_ITERATIONS, 500); + mpc.set( CG_USE_VARIABLE_WEIGHTING_MATRIX, YES); + + mpc.set( SPARSE_QP_SOLUTION, CONDENSING ); + mpc.set( QP_SOLVER, QP_QPOASES ); + mpc.set( HOTSTART_QP, YES ); + mpc.set( GENERATE_TEST_FILE, NO); + mpc.set( GENERATE_MAKE_FILE, NO ); + mpc.set( GENERATE_MATLAB_INTERFACE, NO ); + mpc.set( GENERATE_SIMULINK_INTERFACE, NO ); + + if (mpc.exportCode( "lib_mpc_export" ) != SUCCESSFUL_RETURN) + exit( EXIT_FAILURE ); + + mpc.printDimensionsQP( ); + + return EXIT_SUCCESS; +} diff --git a/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_auxiliary_functions.c b/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_auxiliary_functions.c new file mode 100644 index 00000000000000..6f0bb705c8a897 --- /dev/null +++ b/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_auxiliary_functions.c @@ -0,0 +1,212 @@ +/* + * This file was auto-generated using the ACADO Toolkit. + * + * While ACADO Toolkit is free software released under the terms of + * the GNU Lesser General Public License (LGPL), the generated code + * as such remains the property of the user who used ACADO Toolkit + * to generate this code. In particular, user dependent data of the code + * do not inherit the GNU LGPL license. On the other hand, parts of the + * generated code that are a direct copy of source code from the + * ACADO Toolkit or the software tools it is based on, remain, as derived + * work, automatically covered by the LGPL license. + * + * ACADO Toolkit is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + + +#include "acado_auxiliary_functions.h" + +#include + +real_t* acado_getVariablesX( ) +{ + return acadoVariables.x; +} + +real_t* acado_getVariablesU( ) +{ + return acadoVariables.u; +} + +#if ACADO_NY > 0 +real_t* acado_getVariablesY( ) +{ + return acadoVariables.y; +} +#endif + +#if ACADO_NYN > 0 +real_t* acado_getVariablesYN( ) +{ + return acadoVariables.yN; +} +#endif + +real_t* acado_getVariablesX0( ) +{ +#if ACADO_INITIAL_VALUE_FIXED + return acadoVariables.x0; +#else + return 0; +#endif +} + +/** Print differential variables. */ +void acado_printDifferentialVariables( ) +{ + int i, j; + printf("\nDifferential variables:\n[\n"); + for (i = 0; i < ACADO_N + 1; ++i) + { + for (j = 0; j < ACADO_NX; ++j) + printf("\t%e", acadoVariables.x[i * ACADO_NX + j]); + printf("\n"); + } + printf("]\n\n"); +} + +/** Print control variables. */ +void acado_printControlVariables( ) +{ + int i, j; + printf("\nControl variables:\n[\n"); + for (i = 0; i < ACADO_N; ++i) + { + for (j = 0; j < ACADO_NU; ++j) + printf("\t%e", acadoVariables.u[i * ACADO_NU + j]); + printf("\n"); + } + printf("]\n\n"); +} + +/** Print ACADO code generation notice. */ +void acado_printHeader( ) +{ + printf( + "\nACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.\n" + "Copyright (C) 2008-2015 by Boris Houska, Hans Joachim Ferreau,\n" + "Milan Vukov and Rien Quirynen, KU Leuven.\n" + ); + + printf( + "Developed within the Optimization in Engineering Center (OPTEC) under\n" + "supervision of Moritz Diehl. All rights reserved.\n\n" + "ACADO Toolkit is distributed under the terms of the GNU Lesser\n" + "General Public License 3 in the hope that it will be useful,\n" + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + "GNU Lesser General Public License for more details.\n\n" + ); +} + +#if !(defined _DSPACE) +#if (defined _WIN32 || defined _WIN64) && !(defined __MINGW32__ || defined __MINGW64__) + +void acado_tic( acado_timer* t ) +{ + QueryPerformanceFrequency(&t->freq); + QueryPerformanceCounter(&t->tic); +} + +real_t acado_toc( acado_timer* t ) +{ + QueryPerformanceCounter(&t->toc); + return ((t->toc.QuadPart - t->tic.QuadPart) / (real_t)t->freq.QuadPart); +} + + +#elif (defined __APPLE__) + +void acado_tic( acado_timer* t ) +{ + /* read current clock cycles */ + t->tic = mach_absolute_time(); +} + +real_t acado_toc( acado_timer* t ) +{ + + uint64_t duration; /* elapsed time in clock cycles*/ + + t->toc = mach_absolute_time(); + duration = t->toc - t->tic; + + /*conversion from clock cycles to nanoseconds*/ + mach_timebase_info(&(t->tinfo)); + duration *= t->tinfo.numer; + duration /= t->tinfo.denom; + + return (real_t)duration / 1e9; +} + +#else + +#if __STDC_VERSION__ >= 199901L +/* C99 mode */ + +/* read current time */ +void acado_tic( acado_timer* t ) +{ + gettimeofday(&t->tic, 0); +} + +/* return time passed since last call to tic on this timer */ +real_t acado_toc( acado_timer* t ) +{ + struct timeval temp; + + gettimeofday(&t->toc, 0); + + if ((t->toc.tv_usec - t->tic.tv_usec) < 0) + { + temp.tv_sec = t->toc.tv_sec - t->tic.tv_sec - 1; + temp.tv_usec = 1000000 + t->toc.tv_usec - t->tic.tv_usec; + } + else + { + temp.tv_sec = t->toc.tv_sec - t->tic.tv_sec; + temp.tv_usec = t->toc.tv_usec - t->tic.tv_usec; + } + + return (real_t)temp.tv_sec + (real_t)temp.tv_usec / 1e6; +} + +#else +/* ANSI */ + +/* read current time */ +void acado_tic( acado_timer* t ) +{ + clock_gettime(CLOCK_MONOTONIC, &t->tic); +} + + +/* return time passed since last call to tic on this timer */ +real_t acado_toc( acado_timer* t ) +{ + struct timespec temp; + + clock_gettime(CLOCK_MONOTONIC, &t->toc); + + if ((t->toc.tv_nsec - t->tic.tv_nsec) < 0) + { + temp.tv_sec = t->toc.tv_sec - t->tic.tv_sec - 1; + temp.tv_nsec = 1000000000+t->toc.tv_nsec - t->tic.tv_nsec; + } + else + { + temp.tv_sec = t->toc.tv_sec - t->tic.tv_sec; + temp.tv_nsec = t->toc.tv_nsec - t->tic.tv_nsec; + } + + return (real_t)temp.tv_sec + (real_t)temp.tv_nsec / 1e9; +} + +#endif /* __STDC_VERSION__ >= 199901L */ + +#endif /* (defined _WIN32 || _WIN64) */ + +#endif diff --git a/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_auxiliary_functions.h b/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_auxiliary_functions.h new file mode 100644 index 00000000000000..b1be0a661c0125 --- /dev/null +++ b/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_auxiliary_functions.h @@ -0,0 +1,138 @@ +/* + * This file was auto-generated using the ACADO Toolkit. + * + * While ACADO Toolkit is free software released under the terms of + * the GNU Lesser General Public License (LGPL), the generated code + * as such remains the property of the user who used ACADO Toolkit + * to generate this code. In particular, user dependent data of the code + * do not inherit the GNU LGPL license. On the other hand, parts of the + * generated code that are a direct copy of source code from the + * ACADO Toolkit or the software tools it is based on, remain, as derived + * work, automatically covered by the LGPL license. + * + * ACADO Toolkit is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + + +#ifndef ACADO_AUXILIARY_FUNCTIONS_H +#define ACADO_AUXILIARY_FUNCTIONS_H + +#include "acado_common.h" + +#ifndef __MATLAB__ +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ +#endif /* __MATLAB__ */ + +/** Get pointer to the matrix with differential variables. */ +real_t* acado_getVariablesX( ); + +/** Get pointer to the matrix with control variables. */ +real_t* acado_getVariablesU( ); + +#if ACADO_NY > 0 +/** Get pointer to the matrix with references/measurements. */ +real_t* acado_getVariablesY( ); +#endif + +#if ACADO_NYN > 0 +/** Get pointer to the vector with references/measurement on the last node. */ +real_t* acado_getVariablesYN( ); +#endif + +/** Get pointer to the current state feedback vector. Only applicable for NMPC. */ +real_t* acado_getVariablesX0( ); + +/** Print differential variables. */ +void acado_printDifferentialVariables( ); + +/** Print control variables. */ +void acado_printControlVariables( ); + +/** Print ACADO code generation notice. */ +void acado_printHeader( ); + +/* + * A huge thanks goes to Alexander Domahidi from ETHZ, Switzerland, for + * providing us with the following timing routines. + */ + +#if !(defined _DSPACE) +#if (defined _WIN32 || defined _WIN64) && !(defined __MINGW32__ || defined __MINGW64__) + +/* Use Windows QueryPerformanceCounter for timing. */ +#include + +/** A structure for keeping internal timer data. */ +typedef struct acado_timer_ +{ + LARGE_INTEGER tic; + LARGE_INTEGER toc; + LARGE_INTEGER freq; +} acado_timer; + + +#elif (defined __APPLE__) + +#include "unistd.h" +#include + +/** A structure for keeping internal timer data. */ +typedef struct acado_timer_ +{ + uint64_t tic; + uint64_t toc; + mach_timebase_info_data_t tinfo; +} acado_timer; + +#else + +/* Use POSIX clock_gettime() for timing on non-Windows machines. */ +#include + +#if __STDC_VERSION__ >= 199901L +/* C99 mode of operation. */ + +#include +#include + +typedef struct acado_timer_ +{ + struct timeval tic; + struct timeval toc; +} acado_timer; + +#else +/* ANSI C */ + +/** A structure for keeping internal timer data. */ +typedef struct acado_timer_ +{ + struct timespec tic; + struct timespec toc; +} acado_timer; + +#endif /* __STDC_VERSION__ >= 199901L */ + +#endif /* (defined _WIN32 || defined _WIN64) */ + +/** A function for measurement of the current time. */ +void acado_tic( acado_timer* t ); + +/** A function which returns the elapsed time. */ +real_t acado_toc( acado_timer* t ); + +#endif + +#ifndef __MATLAB__ +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ +#endif /* __MATLAB__ */ + +#endif /* ACADO_AUXILIARY_FUNCTIONS_H */ diff --git a/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_common.h b/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_common.h new file mode 100644 index 00000000000000..cf8c42478ca920 --- /dev/null +++ b/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_common.h @@ -0,0 +1,342 @@ +/* + * This file was auto-generated using the ACADO Toolkit. + * + * While ACADO Toolkit is free software released under the terms of + * the GNU Lesser General Public License (LGPL), the generated code + * as such remains the property of the user who used ACADO Toolkit + * to generate this code. In particular, user dependent data of the code + * do not inherit the GNU LGPL license. On the other hand, parts of the + * generated code that are a direct copy of source code from the + * ACADO Toolkit or the software tools it is based on, remain, as derived + * work, automatically covered by the LGPL license. + * + * ACADO Toolkit is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + + +#ifndef ACADO_COMMON_H +#define ACADO_COMMON_H + +#include +#include + +#ifndef __MATLAB__ +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ +#endif /* __MATLAB__ */ + +/** \defgroup ACADO ACADO CGT generated module. */ +/** @{ */ + +/** qpOASES QP solver indicator. */ +#define ACADO_QPOASES 0 +#define ACADO_QPOASES3 1 +/** FORCES QP solver indicator.*/ +#define ACADO_FORCES 2 +/** qpDUNES QP solver indicator.*/ +#define ACADO_QPDUNES 3 +/** HPMPC QP solver indicator. */ +#define ACADO_HPMPC 4 +#define ACADO_GENERIC 5 + +/** Indicator for determining the QP solver used by the ACADO solver code. */ +#define ACADO_QP_SOLVER ACADO_QPOASES + +#include "acado_qpoases_interface.hpp" + + +/* + * Common definitions + */ +/** User defined block based condensing. */ +#define ACADO_BLOCK_CONDENSING 0 +/** Compute covariance matrix of the last state estimate. */ +#define ACADO_COMPUTE_COVARIANCE_MATRIX 0 +/** Flag indicating whether constraint values are hard-coded or not. */ +#define ACADO_HARDCODED_CONSTRAINT_VALUES 1 +/** Indicator for fixed initial state. */ +#define ACADO_INITIAL_STATE_FIXED 1 +/** Number of control/estimation intervals. */ +#define ACADO_N 20 +/** Number of online data values. */ +#define ACADO_NOD 12 +/** Number of path constraints. */ +#define ACADO_NPAC 0 +/** Number of control variables. */ +#define ACADO_NU 1 +/** Number of differential variables. */ +#define ACADO_NX 4 +/** Number of algebraic variables. */ +#define ACADO_NXA 0 +/** Number of differential derivative variables. */ +#define ACADO_NXD 0 +/** Number of references/measurements per node on the first N nodes. */ +#define ACADO_NY 5 +/** Number of references/measurements on the last (N + 1)st node. */ +#define ACADO_NYN 4 +/** Total number of QP optimization variables. */ +#define ACADO_QP_NV 24 +/** Number of Runge-Kutta stages per integration step. */ +#define ACADO_RK_NSTAGES 4 +/** Providing interface for arrival cost. */ +#define ACADO_USE_ARRIVAL_COST 0 +/** Indicator for usage of non-hard-coded linear terms in the objective. */ +#define ACADO_USE_LINEAR_TERMS 0 +/** Indicator for type of fixed weighting matrices. */ +#define ACADO_WEIGHTING_MATRICES_TYPE 2 + + +/* + * Globally used structure definitions + */ + +/** The structure containing the user data. + * + * Via this structure the user "communicates" with the solver code. + */ +typedef struct ACADOvariables_ +{ +int dummy; +/** Matrix of size: 21 x 4 (row major format) + * + * Matrix containing 21 differential variable vectors. + */ +real_t x[ 84 ]; + +/** Column vector of size: 20 + * + * Matrix containing 20 control variable vectors. + */ +real_t u[ 20 ]; + +/** Matrix of size: 21 x 12 (row major format) + * + * Matrix containing 21 online data vectors. + */ +real_t od[ 252 ]; + +/** Column vector of size: 100 + * + * Matrix containing 20 reference/measurement vectors of size 5 for first 20 nodes. + */ +real_t y[ 100 ]; + +/** Column vector of size: 4 + * + * Reference/measurement vector for the 21. node. + */ +real_t yN[ 4 ]; + +/** Matrix of size: 100 x 5 (row major format) */ +real_t W[ 500 ]; + +/** Matrix of size: 4 x 4 (row major format) */ +real_t WN[ 16 ]; + +/** Column vector of size: 4 + * + * Current state feedback vector. + */ +real_t x0[ 4 ]; + + +} ACADOvariables; + +/** Private workspace used by the auto-generated code. + * + * Data members of this structure are private to the solver. + * In other words, the user code should not modify values of this + * structure. + */ +typedef struct ACADOworkspace_ +{ +real_t rk_ttt; + +/** Row vector of size: 37 */ +real_t rk_xxx[ 37 ]; + +/** Matrix of size: 4 x 24 (row major format) */ +real_t rk_kkk[ 96 ]; + +/** Row vector of size: 37 */ +real_t state[ 37 ]; + +/** Column vector of size: 80 */ +real_t d[ 80 ]; + +/** Column vector of size: 100 */ +real_t Dy[ 100 ]; + +/** Column vector of size: 4 */ +real_t DyN[ 4 ]; + +/** Matrix of size: 80 x 4 (row major format) */ +real_t evGx[ 320 ]; + +/** Column vector of size: 80 */ +real_t evGu[ 80 ]; + +/** Row vector of size: 17 */ +real_t objValueIn[ 17 ]; + +/** Row vector of size: 30 */ +real_t objValueOut[ 30 ]; + +/** Matrix of size: 80 x 4 (row major format) */ +real_t Q1[ 320 ]; + +/** Matrix of size: 80 x 5 (row major format) */ +real_t Q2[ 400 ]; + +/** Column vector of size: 20 */ +real_t R1[ 20 ]; + +/** Matrix of size: 20 x 5 (row major format) */ +real_t R2[ 100 ]; + +/** Column vector of size: 80 */ +real_t S1[ 80 ]; + +/** Matrix of size: 4 x 4 (row major format) */ +real_t QN1[ 16 ]; + +/** Matrix of size: 4 x 4 (row major format) */ +real_t QN2[ 16 ]; + +/** Column vector of size: 4 */ +real_t Dx0[ 4 ]; + +/** Matrix of size: 4 x 4 (row major format) */ +real_t T[ 16 ]; + +/** Column vector of size: 840 */ +real_t E[ 840 ]; + +/** Column vector of size: 840 */ +real_t QE[ 840 ]; + +/** Matrix of size: 80 x 4 (row major format) */ +real_t QGx[ 320 ]; + +/** Column vector of size: 80 */ +real_t Qd[ 80 ]; + +/** Column vector of size: 84 */ +real_t QDy[ 84 ]; + +/** Matrix of size: 20 x 4 (row major format) */ +real_t H10[ 80 ]; + +/** Matrix of size: 24 x 24 (row major format) */ +real_t H[ 576 ]; + +/** Column vector of size: 24 */ +real_t g[ 24 ]; + +/** Column vector of size: 24 */ +real_t lb[ 24 ]; + +/** Column vector of size: 24 */ +real_t ub[ 24 ]; + +/** Column vector of size: 24 */ +real_t x[ 24 ]; + +/** Column vector of size: 24 */ +real_t y[ 24 ]; + + +} ACADOworkspace; + +/* + * Forward function declarations. + */ + + +/** Performs the integration and sensitivity propagation for one shooting interval. + * + * \param rk_eta Working array to pass the input values and return the results. + * \param resetIntegrator The internal memory of the integrator can be reset. + * \param rk_index Number of the shooting interval. + * + * \return Status code of the integrator. + */ +int acado_integrate( real_t* const rk_eta, int resetIntegrator, int rk_index ); + +/** Export of an ACADO symbolic function. + * + * \param in Input to the exported function. + * \param out Output of the exported function. + */ +void acado_rhs_forw(const real_t* in, real_t* out); + +/** Preparation step of the RTI scheme. + * + * \return Status of the integration module. =0: OK, otherwise the error code. + */ +int acado_preparationStep( ); + +/** Feedback/estimation step of the RTI scheme. + * + * \return Status code of the qpOASES QP solver. + */ +int acado_feedbackStep( ); + +/** Solver initialization. Must be called once before any other function call. + * + * \return =0: OK, otherwise an error code of a QP solver. + */ +int acado_initializeSolver( ); + +/** Initialize shooting nodes by a forward simulation starting from the first node. + */ +void acado_initializeNodesByForwardSimulation( ); + +/** Shift differential variables vector by one interval. + * + * \param strategy Shifting strategy: 1. Initialize node 21 with xEnd. 2. Initialize node 21 by forward simulation. + * \param xEnd Value for the x vector on the last node. If =0 the old value is used. + * \param uEnd Value for the u vector on the second to last node. If =0 the old value is used. + */ +void acado_shiftStates( int strategy, real_t* const xEnd, real_t* const uEnd ); + +/** Shift controls vector by one interval. + * + * \param uEnd Value for the u vector on the second to last node. If =0 the old value is used. + */ +void acado_shiftControls( real_t* const uEnd ); + +/** Get the KKT tolerance of the current iterate. + * + * \return The KKT tolerance value. + */ +real_t acado_getKKT( ); + +/** Calculate the objective value. + * + * \return Value of the objective function. + */ +real_t acado_getObjective( ); + + +/* + * Extern declarations. + */ + +extern ACADOworkspace acadoWorkspace; +extern ACADOvariables acadoVariables; + +/** @} */ + +#ifndef __MATLAB__ +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ +#endif /* __MATLAB__ */ + +#endif /* ACADO_COMMON_H */ diff --git a/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_integrator.c b/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_integrator.c new file mode 100644 index 00000000000000..7212295f989b18 --- /dev/null +++ b/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_integrator.c @@ -0,0 +1,231 @@ +/* + * This file was auto-generated using the ACADO Toolkit. + * + * While ACADO Toolkit is free software released under the terms of + * the GNU Lesser General Public License (LGPL), the generated code + * as such remains the property of the user who used ACADO Toolkit + * to generate this code. In particular, user dependent data of the code + * do not inherit the GNU LGPL license. On the other hand, parts of the + * generated code that are a direct copy of source code from the + * ACADO Toolkit or the software tools it is based on, remain, as derived + * work, automatically covered by the LGPL license. + * + * ACADO Toolkit is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + + +#include "acado_common.h" + + +void acado_rhs_forw(const real_t* in, real_t* out) +{ +const real_t* xd = in; +const real_t* u = in + 24; + +/* Compute outputs: */ +out[0] = xd[1]; +out[1] = xd[2]; +out[2] = u[0]; +out[3] = (real_t)(1.0000000000000000e+00); +out[4] = xd[8]; +out[5] = xd[9]; +out[6] = xd[10]; +out[7] = xd[11]; +out[8] = xd[12]; +out[9] = xd[13]; +out[10] = xd[14]; +out[11] = xd[15]; +out[12] = (real_t)(0.0000000000000000e+00); +out[13] = (real_t)(0.0000000000000000e+00); +out[14] = (real_t)(0.0000000000000000e+00); +out[15] = (real_t)(0.0000000000000000e+00); +out[16] = (real_t)(0.0000000000000000e+00); +out[17] = (real_t)(0.0000000000000000e+00); +out[18] = (real_t)(0.0000000000000000e+00); +out[19] = (real_t)(0.0000000000000000e+00); +out[20] = xd[21]; +out[21] = xd[22]; +out[22] = (real_t)(1.0000000000000000e+00); +out[23] = (real_t)(0.0000000000000000e+00); +} + +/* Fixed step size:0.2 */ +int acado_integrate( real_t* const rk_eta, int resetIntegrator, int rk_index ) +{ +int error; + +int run1; +int numSteps[20] = {1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}; +int numInts = numSteps[rk_index]; +acadoWorkspace.rk_ttt = 0.0000000000000000e+00; +rk_eta[4] = 1.0000000000000000e+00; +rk_eta[5] = 0.0000000000000000e+00; +rk_eta[6] = 0.0000000000000000e+00; +rk_eta[7] = 0.0000000000000000e+00; +rk_eta[8] = 0.0000000000000000e+00; +rk_eta[9] = 1.0000000000000000e+00; +rk_eta[10] = 0.0000000000000000e+00; +rk_eta[11] = 0.0000000000000000e+00; +rk_eta[12] = 0.0000000000000000e+00; +rk_eta[13] = 0.0000000000000000e+00; +rk_eta[14] = 1.0000000000000000e+00; +rk_eta[15] = 0.0000000000000000e+00; +rk_eta[16] = 0.0000000000000000e+00; +rk_eta[17] = 0.0000000000000000e+00; +rk_eta[18] = 0.0000000000000000e+00; +rk_eta[19] = 1.0000000000000000e+00; +rk_eta[20] = 0.0000000000000000e+00; +rk_eta[21] = 0.0000000000000000e+00; +rk_eta[22] = 0.0000000000000000e+00; +rk_eta[23] = 0.0000000000000000e+00; +acadoWorkspace.rk_xxx[24] = rk_eta[24]; +acadoWorkspace.rk_xxx[25] = rk_eta[25]; +acadoWorkspace.rk_xxx[26] = rk_eta[26]; +acadoWorkspace.rk_xxx[27] = rk_eta[27]; +acadoWorkspace.rk_xxx[28] = rk_eta[28]; +acadoWorkspace.rk_xxx[29] = rk_eta[29]; +acadoWorkspace.rk_xxx[30] = rk_eta[30]; +acadoWorkspace.rk_xxx[31] = rk_eta[31]; +acadoWorkspace.rk_xxx[32] = rk_eta[32]; +acadoWorkspace.rk_xxx[33] = rk_eta[33]; +acadoWorkspace.rk_xxx[34] = rk_eta[34]; +acadoWorkspace.rk_xxx[35] = rk_eta[35]; +acadoWorkspace.rk_xxx[36] = rk_eta[36]; + +for (run1 = 0; run1 < 1; ++run1) +{ +for(run1 = 0; run1 < numInts; run1++ ) { +acadoWorkspace.rk_xxx[0] = + rk_eta[0]; +acadoWorkspace.rk_xxx[1] = + rk_eta[1]; +acadoWorkspace.rk_xxx[2] = + rk_eta[2]; +acadoWorkspace.rk_xxx[3] = + rk_eta[3]; +acadoWorkspace.rk_xxx[4] = + rk_eta[4]; +acadoWorkspace.rk_xxx[5] = + rk_eta[5]; +acadoWorkspace.rk_xxx[6] = + rk_eta[6]; +acadoWorkspace.rk_xxx[7] = + rk_eta[7]; +acadoWorkspace.rk_xxx[8] = + rk_eta[8]; +acadoWorkspace.rk_xxx[9] = + rk_eta[9]; +acadoWorkspace.rk_xxx[10] = + rk_eta[10]; +acadoWorkspace.rk_xxx[11] = + rk_eta[11]; +acadoWorkspace.rk_xxx[12] = + rk_eta[12]; +acadoWorkspace.rk_xxx[13] = + rk_eta[13]; +acadoWorkspace.rk_xxx[14] = + rk_eta[14]; +acadoWorkspace.rk_xxx[15] = + rk_eta[15]; +acadoWorkspace.rk_xxx[16] = + rk_eta[16]; +acadoWorkspace.rk_xxx[17] = + rk_eta[17]; +acadoWorkspace.rk_xxx[18] = + rk_eta[18]; +acadoWorkspace.rk_xxx[19] = + rk_eta[19]; +acadoWorkspace.rk_xxx[20] = + rk_eta[20]; +acadoWorkspace.rk_xxx[21] = + rk_eta[21]; +acadoWorkspace.rk_xxx[22] = + rk_eta[22]; +acadoWorkspace.rk_xxx[23] = + rk_eta[23]; +acado_rhs_forw( acadoWorkspace.rk_xxx, acadoWorkspace.rk_kkk ); +acadoWorkspace.rk_xxx[0] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[0] + rk_eta[0]; +acadoWorkspace.rk_xxx[1] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[1] + rk_eta[1]; +acadoWorkspace.rk_xxx[2] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[2] + rk_eta[2]; +acadoWorkspace.rk_xxx[3] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[3] + rk_eta[3]; +acadoWorkspace.rk_xxx[4] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[4] + rk_eta[4]; +acadoWorkspace.rk_xxx[5] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[5] + rk_eta[5]; +acadoWorkspace.rk_xxx[6] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[6] + rk_eta[6]; +acadoWorkspace.rk_xxx[7] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[7] + rk_eta[7]; +acadoWorkspace.rk_xxx[8] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[8] + rk_eta[8]; +acadoWorkspace.rk_xxx[9] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[9] + rk_eta[9]; +acadoWorkspace.rk_xxx[10] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[10] + rk_eta[10]; +acadoWorkspace.rk_xxx[11] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[11] + rk_eta[11]; +acadoWorkspace.rk_xxx[12] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[12] + rk_eta[12]; +acadoWorkspace.rk_xxx[13] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[13] + rk_eta[13]; +acadoWorkspace.rk_xxx[14] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[14] + rk_eta[14]; +acadoWorkspace.rk_xxx[15] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[15] + rk_eta[15]; +acadoWorkspace.rk_xxx[16] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[16] + rk_eta[16]; +acadoWorkspace.rk_xxx[17] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[17] + rk_eta[17]; +acadoWorkspace.rk_xxx[18] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[18] + rk_eta[18]; +acadoWorkspace.rk_xxx[19] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[19] + rk_eta[19]; +acadoWorkspace.rk_xxx[20] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[20] + rk_eta[20]; +acadoWorkspace.rk_xxx[21] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[21] + rk_eta[21]; +acadoWorkspace.rk_xxx[22] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[22] + rk_eta[22]; +acadoWorkspace.rk_xxx[23] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[23] + rk_eta[23]; +acado_rhs_forw( acadoWorkspace.rk_xxx, &(acadoWorkspace.rk_kkk[ 24 ]) ); +acadoWorkspace.rk_xxx[0] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[24] + rk_eta[0]; +acadoWorkspace.rk_xxx[1] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[25] + rk_eta[1]; +acadoWorkspace.rk_xxx[2] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[26] + rk_eta[2]; +acadoWorkspace.rk_xxx[3] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[27] + rk_eta[3]; +acadoWorkspace.rk_xxx[4] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[28] + rk_eta[4]; +acadoWorkspace.rk_xxx[5] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[29] + rk_eta[5]; +acadoWorkspace.rk_xxx[6] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[30] + rk_eta[6]; +acadoWorkspace.rk_xxx[7] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[31] + rk_eta[7]; +acadoWorkspace.rk_xxx[8] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[32] + rk_eta[8]; +acadoWorkspace.rk_xxx[9] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[33] + rk_eta[9]; +acadoWorkspace.rk_xxx[10] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[34] + rk_eta[10]; +acadoWorkspace.rk_xxx[11] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[35] + rk_eta[11]; +acadoWorkspace.rk_xxx[12] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[36] + rk_eta[12]; +acadoWorkspace.rk_xxx[13] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[37] + rk_eta[13]; +acadoWorkspace.rk_xxx[14] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[38] + rk_eta[14]; +acadoWorkspace.rk_xxx[15] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[39] + rk_eta[15]; +acadoWorkspace.rk_xxx[16] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[40] + rk_eta[16]; +acadoWorkspace.rk_xxx[17] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[41] + rk_eta[17]; +acadoWorkspace.rk_xxx[18] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[42] + rk_eta[18]; +acadoWorkspace.rk_xxx[19] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[43] + rk_eta[19]; +acadoWorkspace.rk_xxx[20] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[44] + rk_eta[20]; +acadoWorkspace.rk_xxx[21] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[45] + rk_eta[21]; +acadoWorkspace.rk_xxx[22] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[46] + rk_eta[22]; +acadoWorkspace.rk_xxx[23] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[47] + rk_eta[23]; +acado_rhs_forw( acadoWorkspace.rk_xxx, &(acadoWorkspace.rk_kkk[ 48 ]) ); +acadoWorkspace.rk_xxx[0] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[48] + rk_eta[0]; +acadoWorkspace.rk_xxx[1] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[49] + rk_eta[1]; +acadoWorkspace.rk_xxx[2] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[50] + rk_eta[2]; +acadoWorkspace.rk_xxx[3] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[51] + rk_eta[3]; +acadoWorkspace.rk_xxx[4] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[52] + rk_eta[4]; +acadoWorkspace.rk_xxx[5] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[53] + rk_eta[5]; +acadoWorkspace.rk_xxx[6] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[54] + rk_eta[6]; +acadoWorkspace.rk_xxx[7] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[55] + rk_eta[7]; +acadoWorkspace.rk_xxx[8] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[56] + rk_eta[8]; +acadoWorkspace.rk_xxx[9] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[57] + rk_eta[9]; +acadoWorkspace.rk_xxx[10] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[58] + rk_eta[10]; +acadoWorkspace.rk_xxx[11] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[59] + rk_eta[11]; +acadoWorkspace.rk_xxx[12] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[60] + rk_eta[12]; +acadoWorkspace.rk_xxx[13] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[61] + rk_eta[13]; +acadoWorkspace.rk_xxx[14] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[62] + rk_eta[14]; +acadoWorkspace.rk_xxx[15] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[63] + rk_eta[15]; +acadoWorkspace.rk_xxx[16] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[64] + rk_eta[16]; +acadoWorkspace.rk_xxx[17] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[65] + rk_eta[17]; +acadoWorkspace.rk_xxx[18] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[66] + rk_eta[18]; +acadoWorkspace.rk_xxx[19] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[67] + rk_eta[19]; +acadoWorkspace.rk_xxx[20] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[68] + rk_eta[20]; +acadoWorkspace.rk_xxx[21] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[69] + rk_eta[21]; +acadoWorkspace.rk_xxx[22] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[70] + rk_eta[22]; +acadoWorkspace.rk_xxx[23] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[71] + rk_eta[23]; +acado_rhs_forw( acadoWorkspace.rk_xxx, &(acadoWorkspace.rk_kkk[ 72 ]) ); +rk_eta[0] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[0] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[24] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[48] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[72]; +rk_eta[1] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[1] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[25] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[49] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[73]; +rk_eta[2] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[2] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[26] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[50] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[74]; +rk_eta[3] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[3] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[27] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[51] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[75]; +rk_eta[4] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[4] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[28] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[52] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[76]; +rk_eta[5] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[5] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[29] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[53] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[77]; +rk_eta[6] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[6] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[30] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[54] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[78]; +rk_eta[7] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[7] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[31] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[55] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[79]; +rk_eta[8] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[8] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[32] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[56] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[80]; +rk_eta[9] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[9] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[33] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[57] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[81]; +rk_eta[10] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[10] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[34] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[58] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[82]; +rk_eta[11] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[11] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[35] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[59] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[83]; +rk_eta[12] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[12] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[36] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[60] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[84]; +rk_eta[13] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[13] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[37] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[61] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[85]; +rk_eta[14] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[14] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[38] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[62] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[86]; +rk_eta[15] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[15] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[39] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[63] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[87]; +rk_eta[16] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[16] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[40] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[64] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[88]; +rk_eta[17] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[17] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[41] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[65] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[89]; +rk_eta[18] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[18] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[42] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[66] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[90]; +rk_eta[19] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[19] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[43] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[67] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[91]; +rk_eta[20] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[20] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[44] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[68] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[92]; +rk_eta[21] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[21] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[45] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[69] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[93]; +rk_eta[22] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[22] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[46] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[70] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[94]; +rk_eta[23] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[23] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[47] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[71] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[95]; +acadoWorkspace.rk_ttt += 1.0000000000000000e+00; +} +} +error = 0; +return error; +} + diff --git a/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_qpoases_interface.cpp b/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_qpoases_interface.cpp new file mode 100644 index 00000000000000..dd6fada46087da --- /dev/null +++ b/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_qpoases_interface.cpp @@ -0,0 +1,70 @@ +/* + * This file was auto-generated using the ACADO Toolkit. + * + * While ACADO Toolkit is free software released under the terms of + * the GNU Lesser General Public License (LGPL), the generated code + * as such remains the property of the user who used ACADO Toolkit + * to generate this code. In particular, user dependent data of the code + * do not inherit the GNU LGPL license. On the other hand, parts of the + * generated code that are a direct copy of source code from the + * ACADO Toolkit or the software tools it is based on, remain, as derived + * work, automatically covered by the LGPL license. + * + * ACADO Toolkit is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + + +extern "C" +{ +#include "acado_common.h" +} + +#include "INCLUDE/QProblemB.hpp" + +#if ACADO_COMPUTE_COVARIANCE_MATRIX == 1 +#include "INCLUDE/EXTRAS/SolutionAnalysis.hpp" +#endif /* ACADO_COMPUTE_COVARIANCE_MATRIX */ + +static int acado_nWSR; + + + +#if ACADO_COMPUTE_COVARIANCE_MATRIX == 1 +static SolutionAnalysis acado_sa; +#endif /* ACADO_COMPUTE_COVARIANCE_MATRIX */ + +int acado_solve( void ) +{ + acado_nWSR = QPOASES_NWSRMAX; + + QProblemB qp( 24 ); + + returnValue retVal = qp.init(acadoWorkspace.H, acadoWorkspace.g, acadoWorkspace.lb, acadoWorkspace.ub, acado_nWSR, acadoWorkspace.y); + + qp.getPrimalSolution( acadoWorkspace.x ); + qp.getDualSolution( acadoWorkspace.y ); + +#if ACADO_COMPUTE_COVARIANCE_MATRIX == 1 + + if (retVal != SUCCESSFUL_RETURN) + return (int)retVal; + + retVal = acado_sa.getHessianInverse( &qp,var ); + +#endif /* ACADO_COMPUTE_COVARIANCE_MATRIX */ + + return (int)retVal; +} + +int acado_getNWSR( void ) +{ + return acado_nWSR; +} + +const char* acado_getErrorString( int error ) +{ + return MessageHandling::getErrorString( error ); +} diff --git a/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_qpoases_interface.hpp b/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_qpoases_interface.hpp new file mode 100644 index 00000000000000..cc7d1e1c00d06b --- /dev/null +++ b/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_qpoases_interface.hpp @@ -0,0 +1,65 @@ +/* + * This file was auto-generated using the ACADO Toolkit. + * + * While ACADO Toolkit is free software released under the terms of + * the GNU Lesser General Public License (LGPL), the generated code + * as such remains the property of the user who used ACADO Toolkit + * to generate this code. In particular, user dependent data of the code + * do not inherit the GNU LGPL license. On the other hand, parts of the + * generated code that are a direct copy of source code from the + * ACADO Toolkit or the software tools it is based on, remain, as derived + * work, automatically covered by the LGPL license. + * + * ACADO Toolkit is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + + +#ifndef QPOASES_HEADER +#define QPOASES_HEADER + +#ifdef PC_DEBUG +#include +#endif /* PC_DEBUG */ + +#include + +#ifdef __cplusplus +#define EXTERNC extern "C" +#else +#define EXTERNC +#endif + +/* + * A set of options for qpOASES + */ + +/** Maximum number of optimization variables. */ +#define QPOASES_NVMAX 24 +/** Maximum number of constraints. */ +#define QPOASES_NCMAX 0 +/** Maximum number of working set recalculations. */ +#define QPOASES_NWSRMAX 500 +/** Print level for qpOASES. */ +#define QPOASES_PRINTLEVEL PL_NONE +/** The value of EPS */ +#define QPOASES_EPS 2.221e-16 +/** Internally used floating point type */ +typedef double real_t; + +/* + * Forward function declarations + */ + +/** A function that calls the QP solver */ +EXTERNC int acado_solve( void ); + +/** Get the number of active set changes */ +EXTERNC int acado_getNWSR( void ); + +/** Get the error string. */ +const char* acado_getErrorString( int error ); + +#endif /* QPOASES_HEADER */ diff --git a/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_solver.c b/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_solver.c new file mode 100644 index 00000000000000..411d47b603b81a --- /dev/null +++ b/selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/acado_solver.c @@ -0,0 +1,4944 @@ +/* + * This file was auto-generated using the ACADO Toolkit. + * + * While ACADO Toolkit is free software released under the terms of + * the GNU Lesser General Public License (LGPL), the generated code + * as such remains the property of the user who used ACADO Toolkit + * to generate this code. In particular, user dependent data of the code + * do not inherit the GNU LGPL license. On the other hand, parts of the + * generated code that are a direct copy of source code from the + * ACADO Toolkit or the software tools it is based on, remain, as derived + * work, automatically covered by the LGPL license. + * + * ACADO Toolkit is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + + +#include "acado_common.h" + + + + +/******************************************************************************/ +/* */ +/* ACADO code generation */ +/* */ +/******************************************************************************/ + + +int acado_modelSimulation( ) +{ +int ret; + +int lRun1; +ret = 0; +for (lRun1 = 0; lRun1 < 20; ++lRun1) +{ +acadoWorkspace.state[0] = acadoVariables.x[lRun1 * 4]; +acadoWorkspace.state[1] = acadoVariables.x[lRun1 * 4 + 1]; +acadoWorkspace.state[2] = acadoVariables.x[lRun1 * 4 + 2]; +acadoWorkspace.state[3] = acadoVariables.x[lRun1 * 4 + 3]; + +acadoWorkspace.state[24] = acadoVariables.u[lRun1]; +acadoWorkspace.state[25] = acadoVariables.od[lRun1 * 12]; +acadoWorkspace.state[26] = acadoVariables.od[lRun1 * 12 + 1]; +acadoWorkspace.state[27] = acadoVariables.od[lRun1 * 12 + 2]; +acadoWorkspace.state[28] = acadoVariables.od[lRun1 * 12 + 3]; +acadoWorkspace.state[29] = acadoVariables.od[lRun1 * 12 + 4]; +acadoWorkspace.state[30] = acadoVariables.od[lRun1 * 12 + 5]; +acadoWorkspace.state[31] = acadoVariables.od[lRun1 * 12 + 6]; +acadoWorkspace.state[32] = acadoVariables.od[lRun1 * 12 + 7]; +acadoWorkspace.state[33] = acadoVariables.od[lRun1 * 12 + 8]; +acadoWorkspace.state[34] = acadoVariables.od[lRun1 * 12 + 9]; +acadoWorkspace.state[35] = acadoVariables.od[lRun1 * 12 + 10]; +acadoWorkspace.state[36] = acadoVariables.od[lRun1 * 12 + 11]; + +ret = acado_integrate(acadoWorkspace.state, 1, lRun1); + +acadoWorkspace.d[lRun1 * 4] = acadoWorkspace.state[0] - acadoVariables.x[lRun1 * 4 + 4]; +acadoWorkspace.d[lRun1 * 4 + 1] = acadoWorkspace.state[1] - acadoVariables.x[lRun1 * 4 + 5]; +acadoWorkspace.d[lRun1 * 4 + 2] = acadoWorkspace.state[2] - acadoVariables.x[lRun1 * 4 + 6]; +acadoWorkspace.d[lRun1 * 4 + 3] = acadoWorkspace.state[3] - acadoVariables.x[lRun1 * 4 + 7]; + +acadoWorkspace.evGx[lRun1 * 16] = acadoWorkspace.state[4]; +acadoWorkspace.evGx[lRun1 * 16 + 1] = acadoWorkspace.state[5]; +acadoWorkspace.evGx[lRun1 * 16 + 2] = acadoWorkspace.state[6]; +acadoWorkspace.evGx[lRun1 * 16 + 3] = acadoWorkspace.state[7]; +acadoWorkspace.evGx[lRun1 * 16 + 4] = acadoWorkspace.state[8]; +acadoWorkspace.evGx[lRun1 * 16 + 5] = acadoWorkspace.state[9]; +acadoWorkspace.evGx[lRun1 * 16 + 6] = acadoWorkspace.state[10]; +acadoWorkspace.evGx[lRun1 * 16 + 7] = acadoWorkspace.state[11]; +acadoWorkspace.evGx[lRun1 * 16 + 8] = acadoWorkspace.state[12]; +acadoWorkspace.evGx[lRun1 * 16 + 9] = acadoWorkspace.state[13]; +acadoWorkspace.evGx[lRun1 * 16 + 10] = acadoWorkspace.state[14]; +acadoWorkspace.evGx[lRun1 * 16 + 11] = acadoWorkspace.state[15]; +acadoWorkspace.evGx[lRun1 * 16 + 12] = acadoWorkspace.state[16]; +acadoWorkspace.evGx[lRun1 * 16 + 13] = acadoWorkspace.state[17]; +acadoWorkspace.evGx[lRun1 * 16 + 14] = acadoWorkspace.state[18]; +acadoWorkspace.evGx[lRun1 * 16 + 15] = acadoWorkspace.state[19]; + +acadoWorkspace.evGu[lRun1 * 4] = acadoWorkspace.state[20]; +acadoWorkspace.evGu[lRun1 * 4 + 1] = acadoWorkspace.state[21]; +acadoWorkspace.evGu[lRun1 * 4 + 2] = acadoWorkspace.state[22]; +acadoWorkspace.evGu[lRun1 * 4 + 3] = acadoWorkspace.state[23]; +} +return ret; +} + +void acado_evaluateLSQ(const real_t* in, real_t* out) +{ +const real_t* xd = in; +const real_t* u = in + 4; +const real_t* od = in + 5; + +/* Compute outputs: */ +out[0] = (xd[0]-((((od[0]*((xd[3]*xd[3])*xd[3]))+(od[1]*(xd[3]*xd[3])))+(od[2]*xd[3]))+od[3])); +out[1] = (xd[1]-((((od[4]*((xd[3]*xd[3])*xd[3]))+(od[5]*(xd[3]*xd[3])))+(od[6]*xd[3]))+od[7])); +out[2] = (xd[2]-((((od[8]*((xd[3]*xd[3])*xd[3]))+(od[9]*(xd[3]*xd[3])))+(od[10]*xd[3]))+od[11])); +out[3] = (xd[2]*(((real_t)(1.0000000000000001e-01)*xd[1])+(real_t)(1.0000000000000000e+00))); +out[4] = (u[0]*(((real_t)(1.0000000000000001e-01)*xd[1])+(real_t)(1.0000000000000000e+00))); +out[5] = (real_t)(1.0000000000000000e+00); +out[6] = (real_t)(0.0000000000000000e+00); +out[7] = (real_t)(0.0000000000000000e+00); +out[8] = ((real_t)(0.0000000000000000e+00)-(((od[0]*(((xd[3]+xd[3])*xd[3])+(xd[3]*xd[3])))+(od[1]*(xd[3]+xd[3])))+od[2])); +out[9] = (real_t)(0.0000000000000000e+00); +out[10] = (real_t)(1.0000000000000000e+00); +out[11] = (real_t)(0.0000000000000000e+00); +out[12] = ((real_t)(0.0000000000000000e+00)-(((od[4]*(((xd[3]+xd[3])*xd[3])+(xd[3]*xd[3])))+(od[5]*(xd[3]+xd[3])))+od[6])); +out[13] = (real_t)(0.0000000000000000e+00); +out[14] = (real_t)(0.0000000000000000e+00); +out[15] = (real_t)(1.0000000000000000e+00); +out[16] = ((real_t)(0.0000000000000000e+00)-(((od[8]*(((xd[3]+xd[3])*xd[3])+(xd[3]*xd[3])))+(od[9]*(xd[3]+xd[3])))+od[10])); +out[17] = (real_t)(0.0000000000000000e+00); +out[18] = (xd[2]*(real_t)(1.0000000000000001e-01)); +out[19] = (((real_t)(1.0000000000000001e-01)*xd[1])+(real_t)(1.0000000000000000e+00)); +out[20] = (real_t)(0.0000000000000000e+00); +out[21] = (real_t)(0.0000000000000000e+00); +out[22] = (u[0]*(real_t)(1.0000000000000001e-01)); +out[23] = (real_t)(0.0000000000000000e+00); +out[24] = (real_t)(0.0000000000000000e+00); +out[25] = (real_t)(0.0000000000000000e+00); +out[26] = (real_t)(0.0000000000000000e+00); +out[27] = (real_t)(0.0000000000000000e+00); +out[28] = (real_t)(0.0000000000000000e+00); +out[29] = (((real_t)(1.0000000000000001e-01)*xd[1])+(real_t)(1.0000000000000000e+00)); +} + +void acado_evaluateLSQEndTerm(const real_t* in, real_t* out) +{ +const real_t* xd = in; +const real_t* od = in + 4; + +/* Compute outputs: */ +out[0] = (xd[0]-((((od[0]*((xd[3]*xd[3])*xd[3]))+(od[1]*(xd[3]*xd[3])))+(od[2]*xd[3]))+od[3])); +out[1] = (xd[1]-((((od[4]*((xd[3]*xd[3])*xd[3]))+(od[5]*(xd[3]*xd[3])))+(od[6]*xd[3]))+od[7])); +out[2] = (xd[2]-((((od[8]*((xd[3]*xd[3])*xd[3]))+(od[9]*(xd[3]*xd[3])))+(od[10]*xd[3]))+od[11])); +out[3] = (xd[2]*(((real_t)(1.0000000000000001e-01)*xd[1])+(real_t)(1.0000000000000000e+00))); +out[4] = (real_t)(1.0000000000000000e+00); +out[5] = (real_t)(0.0000000000000000e+00); +out[6] = (real_t)(0.0000000000000000e+00); +out[7] = ((real_t)(0.0000000000000000e+00)-(((od[0]*(((xd[3]+xd[3])*xd[3])+(xd[3]*xd[3])))+(od[1]*(xd[3]+xd[3])))+od[2])); +out[8] = (real_t)(0.0000000000000000e+00); +out[9] = (real_t)(1.0000000000000000e+00); +out[10] = (real_t)(0.0000000000000000e+00); +out[11] = ((real_t)(0.0000000000000000e+00)-(((od[4]*(((xd[3]+xd[3])*xd[3])+(xd[3]*xd[3])))+(od[5]*(xd[3]+xd[3])))+od[6])); +out[12] = (real_t)(0.0000000000000000e+00); +out[13] = (real_t)(0.0000000000000000e+00); +out[14] = (real_t)(1.0000000000000000e+00); +out[15] = ((real_t)(0.0000000000000000e+00)-(((od[8]*(((xd[3]+xd[3])*xd[3])+(xd[3]*xd[3])))+(od[9]*(xd[3]+xd[3])))+od[10])); +out[16] = (real_t)(0.0000000000000000e+00); +out[17] = (xd[2]*(real_t)(1.0000000000000001e-01)); +out[18] = (((real_t)(1.0000000000000001e-01)*xd[1])+(real_t)(1.0000000000000000e+00)); +out[19] = (real_t)(0.0000000000000000e+00); +} + +void acado_setObjQ1Q2( real_t* const tmpFx, real_t* const tmpObjS, real_t* const tmpQ1, real_t* const tmpQ2 ) +{ +tmpQ2[0] = + tmpFx[0]*tmpObjS[0] + tmpFx[4]*tmpObjS[5] + tmpFx[8]*tmpObjS[10] + tmpFx[12]*tmpObjS[15] + tmpFx[16]*tmpObjS[20]; +tmpQ2[1] = + tmpFx[0]*tmpObjS[1] + tmpFx[4]*tmpObjS[6] + tmpFx[8]*tmpObjS[11] + tmpFx[12]*tmpObjS[16] + tmpFx[16]*tmpObjS[21]; +tmpQ2[2] = + tmpFx[0]*tmpObjS[2] + tmpFx[4]*tmpObjS[7] + tmpFx[8]*tmpObjS[12] + tmpFx[12]*tmpObjS[17] + tmpFx[16]*tmpObjS[22]; +tmpQ2[3] = + tmpFx[0]*tmpObjS[3] + tmpFx[4]*tmpObjS[8] + tmpFx[8]*tmpObjS[13] + tmpFx[12]*tmpObjS[18] + tmpFx[16]*tmpObjS[23]; +tmpQ2[4] = + tmpFx[0]*tmpObjS[4] + tmpFx[4]*tmpObjS[9] + tmpFx[8]*tmpObjS[14] + tmpFx[12]*tmpObjS[19] + tmpFx[16]*tmpObjS[24]; +tmpQ2[5] = + tmpFx[1]*tmpObjS[0] + tmpFx[5]*tmpObjS[5] + tmpFx[9]*tmpObjS[10] + tmpFx[13]*tmpObjS[15] + tmpFx[17]*tmpObjS[20]; +tmpQ2[6] = + tmpFx[1]*tmpObjS[1] + tmpFx[5]*tmpObjS[6] + tmpFx[9]*tmpObjS[11] + tmpFx[13]*tmpObjS[16] + tmpFx[17]*tmpObjS[21]; +tmpQ2[7] = + tmpFx[1]*tmpObjS[2] + tmpFx[5]*tmpObjS[7] + tmpFx[9]*tmpObjS[12] + tmpFx[13]*tmpObjS[17] + tmpFx[17]*tmpObjS[22]; +tmpQ2[8] = + tmpFx[1]*tmpObjS[3] + tmpFx[5]*tmpObjS[8] + tmpFx[9]*tmpObjS[13] + tmpFx[13]*tmpObjS[18] + tmpFx[17]*tmpObjS[23]; +tmpQ2[9] = + tmpFx[1]*tmpObjS[4] + tmpFx[5]*tmpObjS[9] + tmpFx[9]*tmpObjS[14] + tmpFx[13]*tmpObjS[19] + tmpFx[17]*tmpObjS[24]; +tmpQ2[10] = + tmpFx[2]*tmpObjS[0] + tmpFx[6]*tmpObjS[5] + tmpFx[10]*tmpObjS[10] + tmpFx[14]*tmpObjS[15] + tmpFx[18]*tmpObjS[20]; +tmpQ2[11] = + tmpFx[2]*tmpObjS[1] + tmpFx[6]*tmpObjS[6] + tmpFx[10]*tmpObjS[11] + tmpFx[14]*tmpObjS[16] + tmpFx[18]*tmpObjS[21]; +tmpQ2[12] = + tmpFx[2]*tmpObjS[2] + tmpFx[6]*tmpObjS[7] + tmpFx[10]*tmpObjS[12] + tmpFx[14]*tmpObjS[17] + tmpFx[18]*tmpObjS[22]; +tmpQ2[13] = + tmpFx[2]*tmpObjS[3] + tmpFx[6]*tmpObjS[8] + tmpFx[10]*tmpObjS[13] + tmpFx[14]*tmpObjS[18] + tmpFx[18]*tmpObjS[23]; +tmpQ2[14] = + tmpFx[2]*tmpObjS[4] + tmpFx[6]*tmpObjS[9] + tmpFx[10]*tmpObjS[14] + tmpFx[14]*tmpObjS[19] + tmpFx[18]*tmpObjS[24]; +tmpQ2[15] = + tmpFx[3]*tmpObjS[0] + tmpFx[7]*tmpObjS[5] + tmpFx[11]*tmpObjS[10] + tmpFx[15]*tmpObjS[15] + tmpFx[19]*tmpObjS[20]; +tmpQ2[16] = + tmpFx[3]*tmpObjS[1] + tmpFx[7]*tmpObjS[6] + tmpFx[11]*tmpObjS[11] + tmpFx[15]*tmpObjS[16] + tmpFx[19]*tmpObjS[21]; +tmpQ2[17] = + tmpFx[3]*tmpObjS[2] + tmpFx[7]*tmpObjS[7] + tmpFx[11]*tmpObjS[12] + tmpFx[15]*tmpObjS[17] + tmpFx[19]*tmpObjS[22]; +tmpQ2[18] = + tmpFx[3]*tmpObjS[3] + tmpFx[7]*tmpObjS[8] + tmpFx[11]*tmpObjS[13] + tmpFx[15]*tmpObjS[18] + tmpFx[19]*tmpObjS[23]; +tmpQ2[19] = + tmpFx[3]*tmpObjS[4] + tmpFx[7]*tmpObjS[9] + tmpFx[11]*tmpObjS[14] + tmpFx[15]*tmpObjS[19] + tmpFx[19]*tmpObjS[24]; +tmpQ1[0] = + tmpQ2[0]*tmpFx[0] + tmpQ2[1]*tmpFx[4] + tmpQ2[2]*tmpFx[8] + tmpQ2[3]*tmpFx[12] + tmpQ2[4]*tmpFx[16]; +tmpQ1[1] = + tmpQ2[0]*tmpFx[1] + tmpQ2[1]*tmpFx[5] + tmpQ2[2]*tmpFx[9] + tmpQ2[3]*tmpFx[13] + tmpQ2[4]*tmpFx[17]; +tmpQ1[2] = + tmpQ2[0]*tmpFx[2] + tmpQ2[1]*tmpFx[6] + tmpQ2[2]*tmpFx[10] + tmpQ2[3]*tmpFx[14] + tmpQ2[4]*tmpFx[18]; +tmpQ1[3] = + tmpQ2[0]*tmpFx[3] + tmpQ2[1]*tmpFx[7] + tmpQ2[2]*tmpFx[11] + tmpQ2[3]*tmpFx[15] + tmpQ2[4]*tmpFx[19]; +tmpQ1[4] = + tmpQ2[5]*tmpFx[0] + tmpQ2[6]*tmpFx[4] + tmpQ2[7]*tmpFx[8] + tmpQ2[8]*tmpFx[12] + tmpQ2[9]*tmpFx[16]; +tmpQ1[5] = + tmpQ2[5]*tmpFx[1] + tmpQ2[6]*tmpFx[5] + tmpQ2[7]*tmpFx[9] + tmpQ2[8]*tmpFx[13] + tmpQ2[9]*tmpFx[17]; +tmpQ1[6] = + tmpQ2[5]*tmpFx[2] + tmpQ2[6]*tmpFx[6] + tmpQ2[7]*tmpFx[10] + tmpQ2[8]*tmpFx[14] + tmpQ2[9]*tmpFx[18]; +tmpQ1[7] = + tmpQ2[5]*tmpFx[3] + tmpQ2[6]*tmpFx[7] + tmpQ2[7]*tmpFx[11] + tmpQ2[8]*tmpFx[15] + tmpQ2[9]*tmpFx[19]; +tmpQ1[8] = + tmpQ2[10]*tmpFx[0] + tmpQ2[11]*tmpFx[4] + tmpQ2[12]*tmpFx[8] + tmpQ2[13]*tmpFx[12] + tmpQ2[14]*tmpFx[16]; +tmpQ1[9] = + tmpQ2[10]*tmpFx[1] + tmpQ2[11]*tmpFx[5] + tmpQ2[12]*tmpFx[9] + tmpQ2[13]*tmpFx[13] + tmpQ2[14]*tmpFx[17]; +tmpQ1[10] = + tmpQ2[10]*tmpFx[2] + tmpQ2[11]*tmpFx[6] + tmpQ2[12]*tmpFx[10] + tmpQ2[13]*tmpFx[14] + tmpQ2[14]*tmpFx[18]; +tmpQ1[11] = + tmpQ2[10]*tmpFx[3] + tmpQ2[11]*tmpFx[7] + tmpQ2[12]*tmpFx[11] + tmpQ2[13]*tmpFx[15] + tmpQ2[14]*tmpFx[19]; +tmpQ1[12] = + tmpQ2[15]*tmpFx[0] + tmpQ2[16]*tmpFx[4] + tmpQ2[17]*tmpFx[8] + tmpQ2[18]*tmpFx[12] + tmpQ2[19]*tmpFx[16]; +tmpQ1[13] = + tmpQ2[15]*tmpFx[1] + tmpQ2[16]*tmpFx[5] + tmpQ2[17]*tmpFx[9] + tmpQ2[18]*tmpFx[13] + tmpQ2[19]*tmpFx[17]; +tmpQ1[14] = + tmpQ2[15]*tmpFx[2] + tmpQ2[16]*tmpFx[6] + tmpQ2[17]*tmpFx[10] + tmpQ2[18]*tmpFx[14] + tmpQ2[19]*tmpFx[18]; +tmpQ1[15] = + tmpQ2[15]*tmpFx[3] + tmpQ2[16]*tmpFx[7] + tmpQ2[17]*tmpFx[11] + tmpQ2[18]*tmpFx[15] + tmpQ2[19]*tmpFx[19]; +} + +void acado_setObjR1R2( real_t* const tmpFu, real_t* const tmpObjS, real_t* const tmpR1, real_t* const tmpR2 ) +{ +tmpR2[0] = + tmpFu[0]*tmpObjS[0] + tmpFu[1]*tmpObjS[5] + tmpFu[2]*tmpObjS[10] + tmpFu[3]*tmpObjS[15] + tmpFu[4]*tmpObjS[20]; +tmpR2[1] = + tmpFu[0]*tmpObjS[1] + tmpFu[1]*tmpObjS[6] + tmpFu[2]*tmpObjS[11] + tmpFu[3]*tmpObjS[16] + tmpFu[4]*tmpObjS[21]; +tmpR2[2] = + tmpFu[0]*tmpObjS[2] + tmpFu[1]*tmpObjS[7] + tmpFu[2]*tmpObjS[12] + tmpFu[3]*tmpObjS[17] + tmpFu[4]*tmpObjS[22]; +tmpR2[3] = + tmpFu[0]*tmpObjS[3] + tmpFu[1]*tmpObjS[8] + tmpFu[2]*tmpObjS[13] + tmpFu[3]*tmpObjS[18] + tmpFu[4]*tmpObjS[23]; +tmpR2[4] = + tmpFu[0]*tmpObjS[4] + tmpFu[1]*tmpObjS[9] + tmpFu[2]*tmpObjS[14] + tmpFu[3]*tmpObjS[19] + tmpFu[4]*tmpObjS[24]; +tmpR1[0] = + tmpR2[0]*tmpFu[0] + tmpR2[1]*tmpFu[1] + tmpR2[2]*tmpFu[2] + tmpR2[3]*tmpFu[3] + tmpR2[4]*tmpFu[4]; +} + +void acado_setObjQN1QN2( real_t* const tmpFx, real_t* const tmpObjSEndTerm, real_t* const tmpQN1, real_t* const tmpQN2 ) +{ +tmpQN2[0] = + tmpFx[0]*tmpObjSEndTerm[0] + tmpFx[4]*tmpObjSEndTerm[4] + tmpFx[8]*tmpObjSEndTerm[8] + tmpFx[12]*tmpObjSEndTerm[12]; +tmpQN2[1] = + tmpFx[0]*tmpObjSEndTerm[1] + tmpFx[4]*tmpObjSEndTerm[5] + tmpFx[8]*tmpObjSEndTerm[9] + tmpFx[12]*tmpObjSEndTerm[13]; +tmpQN2[2] = + tmpFx[0]*tmpObjSEndTerm[2] + tmpFx[4]*tmpObjSEndTerm[6] + tmpFx[8]*tmpObjSEndTerm[10] + tmpFx[12]*tmpObjSEndTerm[14]; +tmpQN2[3] = + tmpFx[0]*tmpObjSEndTerm[3] + tmpFx[4]*tmpObjSEndTerm[7] + tmpFx[8]*tmpObjSEndTerm[11] + tmpFx[12]*tmpObjSEndTerm[15]; +tmpQN2[4] = + tmpFx[1]*tmpObjSEndTerm[0] + tmpFx[5]*tmpObjSEndTerm[4] + tmpFx[9]*tmpObjSEndTerm[8] + tmpFx[13]*tmpObjSEndTerm[12]; +tmpQN2[5] = + tmpFx[1]*tmpObjSEndTerm[1] + tmpFx[5]*tmpObjSEndTerm[5] + tmpFx[9]*tmpObjSEndTerm[9] + tmpFx[13]*tmpObjSEndTerm[13]; +tmpQN2[6] = + tmpFx[1]*tmpObjSEndTerm[2] + tmpFx[5]*tmpObjSEndTerm[6] + tmpFx[9]*tmpObjSEndTerm[10] + tmpFx[13]*tmpObjSEndTerm[14]; +tmpQN2[7] = + tmpFx[1]*tmpObjSEndTerm[3] + tmpFx[5]*tmpObjSEndTerm[7] + tmpFx[9]*tmpObjSEndTerm[11] + tmpFx[13]*tmpObjSEndTerm[15]; +tmpQN2[8] = + tmpFx[2]*tmpObjSEndTerm[0] + tmpFx[6]*tmpObjSEndTerm[4] + tmpFx[10]*tmpObjSEndTerm[8] + tmpFx[14]*tmpObjSEndTerm[12]; +tmpQN2[9] = + tmpFx[2]*tmpObjSEndTerm[1] + tmpFx[6]*tmpObjSEndTerm[5] + tmpFx[10]*tmpObjSEndTerm[9] + tmpFx[14]*tmpObjSEndTerm[13]; +tmpQN2[10] = + tmpFx[2]*tmpObjSEndTerm[2] + tmpFx[6]*tmpObjSEndTerm[6] + tmpFx[10]*tmpObjSEndTerm[10] + tmpFx[14]*tmpObjSEndTerm[14]; +tmpQN2[11] = + tmpFx[2]*tmpObjSEndTerm[3] + tmpFx[6]*tmpObjSEndTerm[7] + tmpFx[10]*tmpObjSEndTerm[11] + tmpFx[14]*tmpObjSEndTerm[15]; +tmpQN2[12] = + tmpFx[3]*tmpObjSEndTerm[0] + tmpFx[7]*tmpObjSEndTerm[4] + tmpFx[11]*tmpObjSEndTerm[8] + tmpFx[15]*tmpObjSEndTerm[12]; +tmpQN2[13] = + tmpFx[3]*tmpObjSEndTerm[1] + tmpFx[7]*tmpObjSEndTerm[5] + tmpFx[11]*tmpObjSEndTerm[9] + tmpFx[15]*tmpObjSEndTerm[13]; +tmpQN2[14] = + tmpFx[3]*tmpObjSEndTerm[2] + tmpFx[7]*tmpObjSEndTerm[6] + tmpFx[11]*tmpObjSEndTerm[10] + tmpFx[15]*tmpObjSEndTerm[14]; +tmpQN2[15] = + tmpFx[3]*tmpObjSEndTerm[3] + tmpFx[7]*tmpObjSEndTerm[7] + tmpFx[11]*tmpObjSEndTerm[11] + tmpFx[15]*tmpObjSEndTerm[15]; +tmpQN1[0] = + tmpQN2[0]*tmpFx[0] + tmpQN2[1]*tmpFx[4] + tmpQN2[2]*tmpFx[8] + tmpQN2[3]*tmpFx[12]; +tmpQN1[1] = + tmpQN2[0]*tmpFx[1] + tmpQN2[1]*tmpFx[5] + tmpQN2[2]*tmpFx[9] + tmpQN2[3]*tmpFx[13]; +tmpQN1[2] = + tmpQN2[0]*tmpFx[2] + tmpQN2[1]*tmpFx[6] + tmpQN2[2]*tmpFx[10] + tmpQN2[3]*tmpFx[14]; +tmpQN1[3] = + tmpQN2[0]*tmpFx[3] + tmpQN2[1]*tmpFx[7] + tmpQN2[2]*tmpFx[11] + tmpQN2[3]*tmpFx[15]; +tmpQN1[4] = + tmpQN2[4]*tmpFx[0] + tmpQN2[5]*tmpFx[4] + tmpQN2[6]*tmpFx[8] + tmpQN2[7]*tmpFx[12]; +tmpQN1[5] = + tmpQN2[4]*tmpFx[1] + tmpQN2[5]*tmpFx[5] + tmpQN2[6]*tmpFx[9] + tmpQN2[7]*tmpFx[13]; +tmpQN1[6] = + tmpQN2[4]*tmpFx[2] + tmpQN2[5]*tmpFx[6] + tmpQN2[6]*tmpFx[10] + tmpQN2[7]*tmpFx[14]; +tmpQN1[7] = + tmpQN2[4]*tmpFx[3] + tmpQN2[5]*tmpFx[7] + tmpQN2[6]*tmpFx[11] + tmpQN2[7]*tmpFx[15]; +tmpQN1[8] = + tmpQN2[8]*tmpFx[0] + tmpQN2[9]*tmpFx[4] + tmpQN2[10]*tmpFx[8] + tmpQN2[11]*tmpFx[12]; +tmpQN1[9] = + tmpQN2[8]*tmpFx[1] + tmpQN2[9]*tmpFx[5] + tmpQN2[10]*tmpFx[9] + tmpQN2[11]*tmpFx[13]; +tmpQN1[10] = + tmpQN2[8]*tmpFx[2] + tmpQN2[9]*tmpFx[6] + tmpQN2[10]*tmpFx[10] + tmpQN2[11]*tmpFx[14]; +tmpQN1[11] = + tmpQN2[8]*tmpFx[3] + tmpQN2[9]*tmpFx[7] + tmpQN2[10]*tmpFx[11] + tmpQN2[11]*tmpFx[15]; +tmpQN1[12] = + tmpQN2[12]*tmpFx[0] + tmpQN2[13]*tmpFx[4] + tmpQN2[14]*tmpFx[8] + tmpQN2[15]*tmpFx[12]; +tmpQN1[13] = + tmpQN2[12]*tmpFx[1] + tmpQN2[13]*tmpFx[5] + tmpQN2[14]*tmpFx[9] + tmpQN2[15]*tmpFx[13]; +tmpQN1[14] = + tmpQN2[12]*tmpFx[2] + tmpQN2[13]*tmpFx[6] + tmpQN2[14]*tmpFx[10] + tmpQN2[15]*tmpFx[14]; +tmpQN1[15] = + tmpQN2[12]*tmpFx[3] + tmpQN2[13]*tmpFx[7] + tmpQN2[14]*tmpFx[11] + tmpQN2[15]*tmpFx[15]; +} + +void acado_evaluateObjective( ) +{ +int runObj; +for (runObj = 0; runObj < 20; ++runObj) +{ +acadoWorkspace.objValueIn[0] = acadoVariables.x[runObj * 4]; +acadoWorkspace.objValueIn[1] = acadoVariables.x[runObj * 4 + 1]; +acadoWorkspace.objValueIn[2] = acadoVariables.x[runObj * 4 + 2]; +acadoWorkspace.objValueIn[3] = acadoVariables.x[runObj * 4 + 3]; +acadoWorkspace.objValueIn[4] = acadoVariables.u[runObj]; +acadoWorkspace.objValueIn[5] = acadoVariables.od[runObj * 12]; +acadoWorkspace.objValueIn[6] = acadoVariables.od[runObj * 12 + 1]; +acadoWorkspace.objValueIn[7] = acadoVariables.od[runObj * 12 + 2]; +acadoWorkspace.objValueIn[8] = acadoVariables.od[runObj * 12 + 3]; +acadoWorkspace.objValueIn[9] = acadoVariables.od[runObj * 12 + 4]; +acadoWorkspace.objValueIn[10] = acadoVariables.od[runObj * 12 + 5]; +acadoWorkspace.objValueIn[11] = acadoVariables.od[runObj * 12 + 6]; +acadoWorkspace.objValueIn[12] = acadoVariables.od[runObj * 12 + 7]; +acadoWorkspace.objValueIn[13] = acadoVariables.od[runObj * 12 + 8]; +acadoWorkspace.objValueIn[14] = acadoVariables.od[runObj * 12 + 9]; +acadoWorkspace.objValueIn[15] = acadoVariables.od[runObj * 12 + 10]; +acadoWorkspace.objValueIn[16] = acadoVariables.od[runObj * 12 + 11]; + +acado_evaluateLSQ( acadoWorkspace.objValueIn, acadoWorkspace.objValueOut ); +acadoWorkspace.Dy[runObj * 5] = acadoWorkspace.objValueOut[0]; +acadoWorkspace.Dy[runObj * 5 + 1] = acadoWorkspace.objValueOut[1]; +acadoWorkspace.Dy[runObj * 5 + 2] = acadoWorkspace.objValueOut[2]; +acadoWorkspace.Dy[runObj * 5 + 3] = acadoWorkspace.objValueOut[3]; +acadoWorkspace.Dy[runObj * 5 + 4] = acadoWorkspace.objValueOut[4]; + +acado_setObjQ1Q2( &(acadoWorkspace.objValueOut[ 5 ]), &(acadoVariables.W[ runObj * 25 ]), &(acadoWorkspace.Q1[ runObj * 16 ]), &(acadoWorkspace.Q2[ runObj * 20 ]) ); + +acado_setObjR1R2( &(acadoWorkspace.objValueOut[ 25 ]), &(acadoVariables.W[ runObj * 25 ]), &(acadoWorkspace.R1[ runObj ]), &(acadoWorkspace.R2[ runObj * 5 ]) ); + +} +acadoWorkspace.objValueIn[0] = acadoVariables.x[80]; +acadoWorkspace.objValueIn[1] = acadoVariables.x[81]; +acadoWorkspace.objValueIn[2] = acadoVariables.x[82]; +acadoWorkspace.objValueIn[3] = acadoVariables.x[83]; +acadoWorkspace.objValueIn[4] = acadoVariables.od[240]; +acadoWorkspace.objValueIn[5] = acadoVariables.od[241]; +acadoWorkspace.objValueIn[6] = acadoVariables.od[242]; +acadoWorkspace.objValueIn[7] = acadoVariables.od[243]; +acadoWorkspace.objValueIn[8] = acadoVariables.od[244]; +acadoWorkspace.objValueIn[9] = acadoVariables.od[245]; +acadoWorkspace.objValueIn[10] = acadoVariables.od[246]; +acadoWorkspace.objValueIn[11] = acadoVariables.od[247]; +acadoWorkspace.objValueIn[12] = acadoVariables.od[248]; +acadoWorkspace.objValueIn[13] = acadoVariables.od[249]; +acadoWorkspace.objValueIn[14] = acadoVariables.od[250]; +acadoWorkspace.objValueIn[15] = acadoVariables.od[251]; +acado_evaluateLSQEndTerm( acadoWorkspace.objValueIn, acadoWorkspace.objValueOut ); + +acadoWorkspace.DyN[0] = acadoWorkspace.objValueOut[0]; +acadoWorkspace.DyN[1] = acadoWorkspace.objValueOut[1]; +acadoWorkspace.DyN[2] = acadoWorkspace.objValueOut[2]; +acadoWorkspace.DyN[3] = acadoWorkspace.objValueOut[3]; + +acado_setObjQN1QN2( &(acadoWorkspace.objValueOut[ 4 ]), acadoVariables.WN, acadoWorkspace.QN1, acadoWorkspace.QN2 ); + +} + +void acado_multGxd( real_t* const dOld, real_t* const Gx1, real_t* const dNew ) +{ +dNew[0] += + Gx1[0]*dOld[0] + Gx1[1]*dOld[1] + Gx1[2]*dOld[2] + Gx1[3]*dOld[3]; +dNew[1] += + Gx1[4]*dOld[0] + Gx1[5]*dOld[1] + Gx1[6]*dOld[2] + Gx1[7]*dOld[3]; +dNew[2] += + Gx1[8]*dOld[0] + Gx1[9]*dOld[1] + Gx1[10]*dOld[2] + Gx1[11]*dOld[3]; +dNew[3] += + Gx1[12]*dOld[0] + Gx1[13]*dOld[1] + Gx1[14]*dOld[2] + Gx1[15]*dOld[3]; +} + +void acado_moveGxT( real_t* const Gx1, real_t* const Gx2 ) +{ +Gx2[0] = Gx1[0]; +Gx2[1] = Gx1[1]; +Gx2[2] = Gx1[2]; +Gx2[3] = Gx1[3]; +Gx2[4] = Gx1[4]; +Gx2[5] = Gx1[5]; +Gx2[6] = Gx1[6]; +Gx2[7] = Gx1[7]; +Gx2[8] = Gx1[8]; +Gx2[9] = Gx1[9]; +Gx2[10] = Gx1[10]; +Gx2[11] = Gx1[11]; +Gx2[12] = Gx1[12]; +Gx2[13] = Gx1[13]; +Gx2[14] = Gx1[14]; +Gx2[15] = Gx1[15]; +} + +void acado_multGxGx( real_t* const Gx1, real_t* const Gx2, real_t* const Gx3 ) +{ +Gx3[0] = + Gx1[0]*Gx2[0] + Gx1[1]*Gx2[4] + Gx1[2]*Gx2[8] + Gx1[3]*Gx2[12]; +Gx3[1] = + Gx1[0]*Gx2[1] + Gx1[1]*Gx2[5] + Gx1[2]*Gx2[9] + Gx1[3]*Gx2[13]; +Gx3[2] = + Gx1[0]*Gx2[2] + Gx1[1]*Gx2[6] + Gx1[2]*Gx2[10] + Gx1[3]*Gx2[14]; +Gx3[3] = + Gx1[0]*Gx2[3] + Gx1[1]*Gx2[7] + Gx1[2]*Gx2[11] + Gx1[3]*Gx2[15]; +Gx3[4] = + Gx1[4]*Gx2[0] + Gx1[5]*Gx2[4] + Gx1[6]*Gx2[8] + Gx1[7]*Gx2[12]; +Gx3[5] = + Gx1[4]*Gx2[1] + Gx1[5]*Gx2[5] + Gx1[6]*Gx2[9] + Gx1[7]*Gx2[13]; +Gx3[6] = + Gx1[4]*Gx2[2] + Gx1[5]*Gx2[6] + Gx1[6]*Gx2[10] + Gx1[7]*Gx2[14]; +Gx3[7] = + Gx1[4]*Gx2[3] + Gx1[5]*Gx2[7] + Gx1[6]*Gx2[11] + Gx1[7]*Gx2[15]; +Gx3[8] = + Gx1[8]*Gx2[0] + Gx1[9]*Gx2[4] + Gx1[10]*Gx2[8] + Gx1[11]*Gx2[12]; +Gx3[9] = + Gx1[8]*Gx2[1] + Gx1[9]*Gx2[5] + Gx1[10]*Gx2[9] + Gx1[11]*Gx2[13]; +Gx3[10] = + Gx1[8]*Gx2[2] + Gx1[9]*Gx2[6] + Gx1[10]*Gx2[10] + Gx1[11]*Gx2[14]; +Gx3[11] = + Gx1[8]*Gx2[3] + Gx1[9]*Gx2[7] + Gx1[10]*Gx2[11] + Gx1[11]*Gx2[15]; +Gx3[12] = + Gx1[12]*Gx2[0] + Gx1[13]*Gx2[4] + Gx1[14]*Gx2[8] + Gx1[15]*Gx2[12]; +Gx3[13] = + Gx1[12]*Gx2[1] + Gx1[13]*Gx2[5] + Gx1[14]*Gx2[9] + Gx1[15]*Gx2[13]; +Gx3[14] = + Gx1[12]*Gx2[2] + Gx1[13]*Gx2[6] + Gx1[14]*Gx2[10] + Gx1[15]*Gx2[14]; +Gx3[15] = + Gx1[12]*Gx2[3] + Gx1[13]*Gx2[7] + Gx1[14]*Gx2[11] + Gx1[15]*Gx2[15]; +} + +void acado_multGxGu( real_t* const Gx1, real_t* const Gu1, real_t* const Gu2 ) +{ +Gu2[0] = + Gx1[0]*Gu1[0] + Gx1[1]*Gu1[1] + Gx1[2]*Gu1[2] + Gx1[3]*Gu1[3]; +Gu2[1] = + Gx1[4]*Gu1[0] + Gx1[5]*Gu1[1] + Gx1[6]*Gu1[2] + Gx1[7]*Gu1[3]; +Gu2[2] = + Gx1[8]*Gu1[0] + Gx1[9]*Gu1[1] + Gx1[10]*Gu1[2] + Gx1[11]*Gu1[3]; +Gu2[3] = + Gx1[12]*Gu1[0] + Gx1[13]*Gu1[1] + Gx1[14]*Gu1[2] + Gx1[15]*Gu1[3]; +} + +void acado_moveGuE( real_t* const Gu1, real_t* const Gu2 ) +{ +Gu2[0] = Gu1[0]; +Gu2[1] = Gu1[1]; +Gu2[2] = Gu1[2]; +Gu2[3] = Gu1[3]; +} + +void acado_setBlockH11( int iRow, int iCol, real_t* const Gu1, real_t* const Gu2 ) +{ +acadoWorkspace.H[(iRow * 24 + 96) + (iCol + 4)] += + Gu1[0]*Gu2[0] + Gu1[1]*Gu2[1] + Gu1[2]*Gu2[2] + Gu1[3]*Gu2[3]; +} + +void acado_setBlockH11_R1( int iRow, int iCol, real_t* const R11 ) +{ +acadoWorkspace.H[(iRow * 24 + 96) + (iCol + 4)] = R11[0]; +} + +void acado_zeroBlockH11( int iRow, int iCol ) +{ +acadoWorkspace.H[(iRow * 24 + 96) + (iCol + 4)] = 0.0000000000000000e+00; +} + +void acado_copyHTH( int iRow, int iCol ) +{ +acadoWorkspace.H[(iRow * 24 + 96) + (iCol + 4)] = acadoWorkspace.H[(iCol * 24 + 96) + (iRow + 4)]; +} + +void acado_multQ1d( real_t* const Gx1, real_t* const dOld, real_t* const dNew ) +{ +dNew[0] = + Gx1[0]*dOld[0] + Gx1[1]*dOld[1] + Gx1[2]*dOld[2] + Gx1[3]*dOld[3]; +dNew[1] = + Gx1[4]*dOld[0] + Gx1[5]*dOld[1] + Gx1[6]*dOld[2] + Gx1[7]*dOld[3]; +dNew[2] = + Gx1[8]*dOld[0] + Gx1[9]*dOld[1] + Gx1[10]*dOld[2] + Gx1[11]*dOld[3]; +dNew[3] = + Gx1[12]*dOld[0] + Gx1[13]*dOld[1] + Gx1[14]*dOld[2] + Gx1[15]*dOld[3]; +} + +void acado_multQN1d( real_t* const QN1, real_t* const dOld, real_t* const dNew ) +{ +dNew[0] = + acadoWorkspace.QN1[0]*dOld[0] + acadoWorkspace.QN1[1]*dOld[1] + acadoWorkspace.QN1[2]*dOld[2] + acadoWorkspace.QN1[3]*dOld[3]; +dNew[1] = + acadoWorkspace.QN1[4]*dOld[0] + acadoWorkspace.QN1[5]*dOld[1] + acadoWorkspace.QN1[6]*dOld[2] + acadoWorkspace.QN1[7]*dOld[3]; +dNew[2] = + acadoWorkspace.QN1[8]*dOld[0] + acadoWorkspace.QN1[9]*dOld[1] + acadoWorkspace.QN1[10]*dOld[2] + acadoWorkspace.QN1[11]*dOld[3]; +dNew[3] = + acadoWorkspace.QN1[12]*dOld[0] + acadoWorkspace.QN1[13]*dOld[1] + acadoWorkspace.QN1[14]*dOld[2] + acadoWorkspace.QN1[15]*dOld[3]; +} + +void acado_multRDy( real_t* const R2, real_t* const Dy1, real_t* const RDy1 ) +{ +RDy1[0] = + R2[0]*Dy1[0] + R2[1]*Dy1[1] + R2[2]*Dy1[2] + R2[3]*Dy1[3] + R2[4]*Dy1[4]; +} + +void acado_multQDy( real_t* const Q2, real_t* const Dy1, real_t* const QDy1 ) +{ +QDy1[0] = + Q2[0]*Dy1[0] + Q2[1]*Dy1[1] + Q2[2]*Dy1[2] + Q2[3]*Dy1[3] + Q2[4]*Dy1[4]; +QDy1[1] = + Q2[5]*Dy1[0] + Q2[6]*Dy1[1] + Q2[7]*Dy1[2] + Q2[8]*Dy1[3] + Q2[9]*Dy1[4]; +QDy1[2] = + Q2[10]*Dy1[0] + Q2[11]*Dy1[1] + Q2[12]*Dy1[2] + Q2[13]*Dy1[3] + Q2[14]*Dy1[4]; +QDy1[3] = + Q2[15]*Dy1[0] + Q2[16]*Dy1[1] + Q2[17]*Dy1[2] + Q2[18]*Dy1[3] + Q2[19]*Dy1[4]; +} + +void acado_multEQDy( real_t* const E1, real_t* const QDy1, real_t* const U1 ) +{ +U1[0] += + E1[0]*QDy1[0] + E1[1]*QDy1[1] + E1[2]*QDy1[2] + E1[3]*QDy1[3]; +} + +void acado_multQETGx( real_t* const E1, real_t* const Gx1, real_t* const H101 ) +{ +H101[0] += + E1[0]*Gx1[0] + E1[1]*Gx1[4] + E1[2]*Gx1[8] + E1[3]*Gx1[12]; +H101[1] += + E1[0]*Gx1[1] + E1[1]*Gx1[5] + E1[2]*Gx1[9] + E1[3]*Gx1[13]; +H101[2] += + E1[0]*Gx1[2] + E1[1]*Gx1[6] + E1[2]*Gx1[10] + E1[3]*Gx1[14]; +H101[3] += + E1[0]*Gx1[3] + E1[1]*Gx1[7] + E1[2]*Gx1[11] + E1[3]*Gx1[15]; +} + +void acado_zeroBlockH10( real_t* const H101 ) +{ +{ int lCopy; for (lCopy = 0; lCopy < 4; lCopy++) H101[ lCopy ] = 0; } +} + +void acado_multEDu( real_t* const E1, real_t* const U1, real_t* const dNew ) +{ +dNew[0] += + E1[0]*U1[0]; +dNew[1] += + E1[1]*U1[0]; +dNew[2] += + E1[2]*U1[0]; +dNew[3] += + E1[3]*U1[0]; +} + +void acado_zeroBlockH00( ) +{ +acadoWorkspace.H[0] = 0.0000000000000000e+00; +acadoWorkspace.H[1] = 0.0000000000000000e+00; +acadoWorkspace.H[2] = 0.0000000000000000e+00; +acadoWorkspace.H[3] = 0.0000000000000000e+00; +acadoWorkspace.H[24] = 0.0000000000000000e+00; +acadoWorkspace.H[25] = 0.0000000000000000e+00; +acadoWorkspace.H[26] = 0.0000000000000000e+00; +acadoWorkspace.H[27] = 0.0000000000000000e+00; +acadoWorkspace.H[48] = 0.0000000000000000e+00; +acadoWorkspace.H[49] = 0.0000000000000000e+00; +acadoWorkspace.H[50] = 0.0000000000000000e+00; +acadoWorkspace.H[51] = 0.0000000000000000e+00; +acadoWorkspace.H[72] = 0.0000000000000000e+00; +acadoWorkspace.H[73] = 0.0000000000000000e+00; +acadoWorkspace.H[74] = 0.0000000000000000e+00; +acadoWorkspace.H[75] = 0.0000000000000000e+00; +} + +void acado_multCTQC( real_t* const Gx1, real_t* const Gx2 ) +{ +acadoWorkspace.H[0] += + Gx1[0]*Gx2[0] + Gx1[4]*Gx2[4] + Gx1[8]*Gx2[8] + Gx1[12]*Gx2[12]; +acadoWorkspace.H[1] += + Gx1[0]*Gx2[1] + Gx1[4]*Gx2[5] + Gx1[8]*Gx2[9] + Gx1[12]*Gx2[13]; +acadoWorkspace.H[2] += + Gx1[0]*Gx2[2] + Gx1[4]*Gx2[6] + Gx1[8]*Gx2[10] + Gx1[12]*Gx2[14]; +acadoWorkspace.H[3] += + Gx1[0]*Gx2[3] + Gx1[4]*Gx2[7] + Gx1[8]*Gx2[11] + Gx1[12]*Gx2[15]; +acadoWorkspace.H[24] += + Gx1[1]*Gx2[0] + Gx1[5]*Gx2[4] + Gx1[9]*Gx2[8] + Gx1[13]*Gx2[12]; +acadoWorkspace.H[25] += + Gx1[1]*Gx2[1] + Gx1[5]*Gx2[5] + Gx1[9]*Gx2[9] + Gx1[13]*Gx2[13]; +acadoWorkspace.H[26] += + Gx1[1]*Gx2[2] + Gx1[5]*Gx2[6] + Gx1[9]*Gx2[10] + Gx1[13]*Gx2[14]; +acadoWorkspace.H[27] += + Gx1[1]*Gx2[3] + Gx1[5]*Gx2[7] + Gx1[9]*Gx2[11] + Gx1[13]*Gx2[15]; +acadoWorkspace.H[48] += + Gx1[2]*Gx2[0] + Gx1[6]*Gx2[4] + Gx1[10]*Gx2[8] + Gx1[14]*Gx2[12]; +acadoWorkspace.H[49] += + Gx1[2]*Gx2[1] + Gx1[6]*Gx2[5] + Gx1[10]*Gx2[9] + Gx1[14]*Gx2[13]; +acadoWorkspace.H[50] += + Gx1[2]*Gx2[2] + Gx1[6]*Gx2[6] + Gx1[10]*Gx2[10] + Gx1[14]*Gx2[14]; +acadoWorkspace.H[51] += + Gx1[2]*Gx2[3] + Gx1[6]*Gx2[7] + Gx1[10]*Gx2[11] + Gx1[14]*Gx2[15]; +acadoWorkspace.H[72] += + Gx1[3]*Gx2[0] + Gx1[7]*Gx2[4] + Gx1[11]*Gx2[8] + Gx1[15]*Gx2[12]; +acadoWorkspace.H[73] += + Gx1[3]*Gx2[1] + Gx1[7]*Gx2[5] + Gx1[11]*Gx2[9] + Gx1[15]*Gx2[13]; +acadoWorkspace.H[74] += + Gx1[3]*Gx2[2] + Gx1[7]*Gx2[6] + Gx1[11]*Gx2[10] + Gx1[15]*Gx2[14]; +acadoWorkspace.H[75] += + Gx1[3]*Gx2[3] + Gx1[7]*Gx2[7] + Gx1[11]*Gx2[11] + Gx1[15]*Gx2[15]; +} + +void acado_macCTSlx( real_t* const C0, real_t* const g0 ) +{ +g0[0] += 0.0; +; +g0[1] += 0.0; +; +g0[2] += 0.0; +; +g0[3] += 0.0; +; +} + +void acado_macETSlu( real_t* const E0, real_t* const g1 ) +{ +g1[0] += 0.0; +; +} + +void acado_condensePrep( ) +{ +acado_moveGuE( acadoWorkspace.evGu, acadoWorkspace.E ); +acado_moveGxT( &(acadoWorkspace.evGx[ 16 ]), acadoWorkspace.T ); +acado_multGxd( acadoWorkspace.d, &(acadoWorkspace.evGx[ 16 ]), &(acadoWorkspace.d[ 4 ]) ); +acado_multGxGx( acadoWorkspace.T, acadoWorkspace.evGx, &(acadoWorkspace.evGx[ 16 ]) ); + +acado_multGxGu( acadoWorkspace.T, acadoWorkspace.E, &(acadoWorkspace.E[ 4 ]) ); + +acado_moveGuE( &(acadoWorkspace.evGu[ 4 ]), &(acadoWorkspace.E[ 8 ]) ); + +acado_moveGxT( &(acadoWorkspace.evGx[ 32 ]), acadoWorkspace.T ); +acado_multGxd( &(acadoWorkspace.d[ 4 ]), &(acadoWorkspace.evGx[ 32 ]), &(acadoWorkspace.d[ 8 ]) ); +acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 16 ]), &(acadoWorkspace.evGx[ 32 ]) ); + +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 4 ]), &(acadoWorkspace.E[ 12 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 8 ]), &(acadoWorkspace.E[ 16 ]) ); + +acado_moveGuE( &(acadoWorkspace.evGu[ 8 ]), &(acadoWorkspace.E[ 20 ]) ); + +acado_moveGxT( &(acadoWorkspace.evGx[ 48 ]), acadoWorkspace.T ); +acado_multGxd( &(acadoWorkspace.d[ 8 ]), &(acadoWorkspace.evGx[ 48 ]), &(acadoWorkspace.d[ 12 ]) ); +acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 32 ]), &(acadoWorkspace.evGx[ 48 ]) ); + +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.E[ 24 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 16 ]), &(acadoWorkspace.E[ 28 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 20 ]), &(acadoWorkspace.E[ 32 ]) ); + +acado_moveGuE( &(acadoWorkspace.evGu[ 12 ]), &(acadoWorkspace.E[ 36 ]) ); + +acado_moveGxT( &(acadoWorkspace.evGx[ 64 ]), acadoWorkspace.T ); +acado_multGxd( &(acadoWorkspace.d[ 12 ]), &(acadoWorkspace.evGx[ 64 ]), &(acadoWorkspace.d[ 16 ]) ); +acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 48 ]), &(acadoWorkspace.evGx[ 64 ]) ); + +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.E[ 40 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 28 ]), &(acadoWorkspace.E[ 44 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 32 ]), &(acadoWorkspace.E[ 48 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.E[ 52 ]) ); + +acado_moveGuE( &(acadoWorkspace.evGu[ 16 ]), &(acadoWorkspace.E[ 56 ]) ); + +acado_moveGxT( &(acadoWorkspace.evGx[ 80 ]), acadoWorkspace.T ); +acado_multGxd( &(acadoWorkspace.d[ 16 ]), &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.d[ 20 ]) ); +acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 64 ]), &(acadoWorkspace.evGx[ 80 ]) ); + +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 40 ]), &(acadoWorkspace.E[ 60 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 44 ]), &(acadoWorkspace.E[ 64 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.E[ 68 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 52 ]), &(acadoWorkspace.E[ 72 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 56 ]), &(acadoWorkspace.E[ 76 ]) ); + +acado_moveGuE( &(acadoWorkspace.evGu[ 20 ]), &(acadoWorkspace.E[ 80 ]) ); + +acado_moveGxT( &(acadoWorkspace.evGx[ 96 ]), acadoWorkspace.T ); +acado_multGxd( &(acadoWorkspace.d[ 20 ]), &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.d[ 24 ]) ); +acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.evGx[ 96 ]) ); + +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.E[ 84 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 64 ]), &(acadoWorkspace.E[ 88 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 68 ]), &(acadoWorkspace.E[ 92 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.E[ 96 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 76 ]), &(acadoWorkspace.E[ 100 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 80 ]), &(acadoWorkspace.E[ 104 ]) ); + +acado_moveGuE( &(acadoWorkspace.evGu[ 24 ]), &(acadoWorkspace.E[ 108 ]) ); + +acado_moveGxT( &(acadoWorkspace.evGx[ 112 ]), acadoWorkspace.T ); +acado_multGxd( &(acadoWorkspace.d[ 24 ]), &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.d[ 28 ]) ); +acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.evGx[ 112 ]) ); + +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.E[ 112 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 88 ]), &(acadoWorkspace.E[ 116 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 92 ]), &(acadoWorkspace.E[ 120 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.E[ 124 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 100 ]), &(acadoWorkspace.E[ 128 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 104 ]), &(acadoWorkspace.E[ 132 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.E[ 136 ]) ); + +acado_moveGuE( &(acadoWorkspace.evGu[ 28 ]), &(acadoWorkspace.E[ 140 ]) ); + +acado_moveGxT( &(acadoWorkspace.evGx[ 128 ]), acadoWorkspace.T ); +acado_multGxd( &(acadoWorkspace.d[ 28 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.d[ 32 ]) ); +acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.evGx[ 128 ]) ); + +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.E[ 144 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.E[ 148 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.E[ 152 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 124 ]), &(acadoWorkspace.E[ 156 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 128 ]), &(acadoWorkspace.E[ 160 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.E[ 164 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 136 ]), &(acadoWorkspace.E[ 168 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 140 ]), &(acadoWorkspace.E[ 172 ]) ); + +acado_moveGuE( &(acadoWorkspace.evGu[ 32 ]), &(acadoWorkspace.E[ 176 ]) ); + +acado_moveGxT( &(acadoWorkspace.evGx[ 144 ]), acadoWorkspace.T ); +acado_multGxd( &(acadoWorkspace.d[ 32 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.d[ 36 ]) ); +acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.evGx[ 144 ]) ); + +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.E[ 180 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.E[ 184 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.E[ 188 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.E[ 192 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 160 ]), &(acadoWorkspace.E[ 196 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 164 ]), &(acadoWorkspace.E[ 200 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.E[ 204 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 172 ]), &(acadoWorkspace.E[ 208 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 176 ]), &(acadoWorkspace.E[ 212 ]) ); + +acado_moveGuE( &(acadoWorkspace.evGu[ 36 ]), &(acadoWorkspace.E[ 216 ]) ); + +acado_moveGxT( &(acadoWorkspace.evGx[ 160 ]), acadoWorkspace.T ); +acado_multGxd( &(acadoWorkspace.d[ 36 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.d[ 40 ]) ); +acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.evGx[ 160 ]) ); + +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.E[ 220 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.E[ 224 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.E[ 228 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.E[ 232 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 196 ]), &(acadoWorkspace.E[ 236 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 200 ]), &(acadoWorkspace.E[ 240 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.E[ 244 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 208 ]), &(acadoWorkspace.E[ 248 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 212 ]), &(acadoWorkspace.E[ 252 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.E[ 256 ]) ); + +acado_moveGuE( &(acadoWorkspace.evGu[ 40 ]), &(acadoWorkspace.E[ 260 ]) ); + +acado_moveGxT( &(acadoWorkspace.evGx[ 176 ]), acadoWorkspace.T ); +acado_multGxd( &(acadoWorkspace.d[ 40 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.d[ 44 ]) ); +acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.evGx[ 176 ]) ); + +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.E[ 264 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.E[ 268 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.E[ 272 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.E[ 276 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.E[ 280 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.E[ 284 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 244 ]), &(acadoWorkspace.E[ 288 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 248 ]), &(acadoWorkspace.E[ 292 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.E[ 296 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 256 ]), &(acadoWorkspace.E[ 300 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 260 ]), &(acadoWorkspace.E[ 304 ]) ); + +acado_moveGuE( &(acadoWorkspace.evGu[ 44 ]), &(acadoWorkspace.E[ 308 ]) ); + +acado_moveGxT( &(acadoWorkspace.evGx[ 192 ]), acadoWorkspace.T ); +acado_multGxd( &(acadoWorkspace.d[ 44 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.d[ 48 ]) ); +acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.evGx[ 192 ]) ); + +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.E[ 312 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.E[ 316 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.E[ 320 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.E[ 324 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.E[ 328 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.E[ 332 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.E[ 336 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 292 ]), &(acadoWorkspace.E[ 340 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 296 ]), &(acadoWorkspace.E[ 344 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.E[ 348 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 304 ]), &(acadoWorkspace.E[ 352 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 308 ]), &(acadoWorkspace.E[ 356 ]) ); + +acado_moveGuE( &(acadoWorkspace.evGu[ 48 ]), &(acadoWorkspace.E[ 360 ]) ); + +acado_moveGxT( &(acadoWorkspace.evGx[ 208 ]), acadoWorkspace.T ); +acado_multGxd( &(acadoWorkspace.d[ 48 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.d[ 52 ]) ); +acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.evGx[ 208 ]) ); + +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.E[ 364 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.E[ 368 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.E[ 372 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.E[ 376 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.E[ 380 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.E[ 384 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.E[ 388 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 340 ]), &(acadoWorkspace.E[ 392 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 344 ]), &(acadoWorkspace.E[ 396 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.E[ 400 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 352 ]), &(acadoWorkspace.E[ 404 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 356 ]), &(acadoWorkspace.E[ 408 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.E[ 412 ]) ); + +acado_moveGuE( &(acadoWorkspace.evGu[ 52 ]), &(acadoWorkspace.E[ 416 ]) ); + +acado_moveGxT( &(acadoWorkspace.evGx[ 224 ]), acadoWorkspace.T ); +acado_multGxd( &(acadoWorkspace.d[ 52 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.d[ 56 ]) ); +acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.evGx[ 224 ]) ); + +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.E[ 420 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.E[ 424 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.E[ 428 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.E[ 432 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.E[ 436 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.E[ 440 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.E[ 444 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.E[ 448 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.E[ 452 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 400 ]), &(acadoWorkspace.E[ 456 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 404 ]), &(acadoWorkspace.E[ 460 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.E[ 464 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 412 ]), &(acadoWorkspace.E[ 468 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 416 ]), &(acadoWorkspace.E[ 472 ]) ); + +acado_moveGuE( &(acadoWorkspace.evGu[ 56 ]), &(acadoWorkspace.E[ 476 ]) ); + +acado_moveGxT( &(acadoWorkspace.evGx[ 240 ]), acadoWorkspace.T ); +acado_multGxd( &(acadoWorkspace.d[ 56 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.d[ 60 ]) ); +acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.evGx[ 240 ]) ); + +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.E[ 480 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.E[ 484 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.E[ 488 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.E[ 492 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.E[ 496 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.E[ 500 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.E[ 504 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.E[ 508 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.E[ 512 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.E[ 516 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 460 ]), &(acadoWorkspace.E[ 520 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 464 ]), &(acadoWorkspace.E[ 524 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.E[ 528 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 472 ]), &(acadoWorkspace.E[ 532 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 476 ]), &(acadoWorkspace.E[ 536 ]) ); + +acado_moveGuE( &(acadoWorkspace.evGu[ 60 ]), &(acadoWorkspace.E[ 540 ]) ); + +acado_moveGxT( &(acadoWorkspace.evGx[ 256 ]), acadoWorkspace.T ); +acado_multGxd( &(acadoWorkspace.d[ 60 ]), &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.d[ 64 ]) ); +acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.evGx[ 256 ]) ); + +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.E[ 544 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.E[ 548 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.E[ 552 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.E[ 556 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.E[ 560 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.E[ 564 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.E[ 568 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.E[ 572 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.E[ 576 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.E[ 580 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 520 ]), &(acadoWorkspace.E[ 584 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 524 ]), &(acadoWorkspace.E[ 588 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.E[ 592 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 532 ]), &(acadoWorkspace.E[ 596 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 536 ]), &(acadoWorkspace.E[ 600 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.E[ 604 ]) ); + +acado_moveGuE( &(acadoWorkspace.evGu[ 64 ]), &(acadoWorkspace.E[ 608 ]) ); + +acado_moveGxT( &(acadoWorkspace.evGx[ 272 ]), acadoWorkspace.T ); +acado_multGxd( &(acadoWorkspace.d[ 64 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.d[ 68 ]) ); +acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.evGx[ 272 ]) ); + +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.E[ 612 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 548 ]), &(acadoWorkspace.E[ 616 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.E[ 620 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 556 ]), &(acadoWorkspace.E[ 624 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 560 ]), &(acadoWorkspace.E[ 628 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.E[ 632 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 568 ]), &(acadoWorkspace.E[ 636 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 572 ]), &(acadoWorkspace.E[ 640 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.E[ 644 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 580 ]), &(acadoWorkspace.E[ 648 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 584 ]), &(acadoWorkspace.E[ 652 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.E[ 656 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 592 ]), &(acadoWorkspace.E[ 660 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 596 ]), &(acadoWorkspace.E[ 664 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.E[ 668 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 604 ]), &(acadoWorkspace.E[ 672 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 608 ]), &(acadoWorkspace.E[ 676 ]) ); + +acado_moveGuE( &(acadoWorkspace.evGu[ 68 ]), &(acadoWorkspace.E[ 680 ]) ); + +acado_moveGxT( &(acadoWorkspace.evGx[ 288 ]), acadoWorkspace.T ); +acado_multGxd( &(acadoWorkspace.d[ 68 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.d[ 72 ]) ); +acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.evGx[ 288 ]) ); + +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.E[ 684 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.E[ 688 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 620 ]), &(acadoWorkspace.E[ 692 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.E[ 696 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 628 ]), &(acadoWorkspace.E[ 700 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 632 ]), &(acadoWorkspace.E[ 704 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 636 ]), &(acadoWorkspace.E[ 708 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 640 ]), &(acadoWorkspace.E[ 712 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 644 ]), &(acadoWorkspace.E[ 716 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 648 ]), &(acadoWorkspace.E[ 720 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 652 ]), &(acadoWorkspace.E[ 724 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 656 ]), &(acadoWorkspace.E[ 728 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 660 ]), &(acadoWorkspace.E[ 732 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 664 ]), &(acadoWorkspace.E[ 736 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 668 ]), &(acadoWorkspace.E[ 740 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 672 ]), &(acadoWorkspace.E[ 744 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 676 ]), &(acadoWorkspace.E[ 748 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 680 ]), &(acadoWorkspace.E[ 752 ]) ); + +acado_moveGuE( &(acadoWorkspace.evGu[ 72 ]), &(acadoWorkspace.E[ 756 ]) ); + +acado_moveGxT( &(acadoWorkspace.evGx[ 304 ]), acadoWorkspace.T ); +acado_multGxd( &(acadoWorkspace.d[ 72 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.d[ 76 ]) ); +acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.evGx[ 304 ]) ); + +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.E[ 760 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.E[ 764 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.E[ 768 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 696 ]), &(acadoWorkspace.E[ 772 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 700 ]), &(acadoWorkspace.E[ 776 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 704 ]), &(acadoWorkspace.E[ 780 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 708 ]), &(acadoWorkspace.E[ 784 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 712 ]), &(acadoWorkspace.E[ 788 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 716 ]), &(acadoWorkspace.E[ 792 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 720 ]), &(acadoWorkspace.E[ 796 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 724 ]), &(acadoWorkspace.E[ 800 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 728 ]), &(acadoWorkspace.E[ 804 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 732 ]), &(acadoWorkspace.E[ 808 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 736 ]), &(acadoWorkspace.E[ 812 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 740 ]), &(acadoWorkspace.E[ 816 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 744 ]), &(acadoWorkspace.E[ 820 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 748 ]), &(acadoWorkspace.E[ 824 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 752 ]), &(acadoWorkspace.E[ 828 ]) ); +acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 756 ]), &(acadoWorkspace.E[ 832 ]) ); + +acado_moveGuE( &(acadoWorkspace.evGu[ 76 ]), &(acadoWorkspace.E[ 836 ]) ); + +acado_multGxGx( &(acadoWorkspace.Q1[ 16 ]), acadoWorkspace.evGx, acadoWorkspace.QGx ); +acado_multGxGx( &(acadoWorkspace.Q1[ 32 ]), &(acadoWorkspace.evGx[ 16 ]), &(acadoWorkspace.QGx[ 16 ]) ); +acado_multGxGx( &(acadoWorkspace.Q1[ 48 ]), &(acadoWorkspace.evGx[ 32 ]), &(acadoWorkspace.QGx[ 32 ]) ); +acado_multGxGx( &(acadoWorkspace.Q1[ 64 ]), &(acadoWorkspace.evGx[ 48 ]), &(acadoWorkspace.QGx[ 48 ]) ); +acado_multGxGx( &(acadoWorkspace.Q1[ 80 ]), &(acadoWorkspace.evGx[ 64 ]), &(acadoWorkspace.QGx[ 64 ]) ); +acado_multGxGx( &(acadoWorkspace.Q1[ 96 ]), &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.QGx[ 80 ]) ); +acado_multGxGx( &(acadoWorkspace.Q1[ 112 ]), &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.QGx[ 96 ]) ); +acado_multGxGx( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.QGx[ 112 ]) ); +acado_multGxGx( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.QGx[ 128 ]) ); +acado_multGxGx( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.QGx[ 144 ]) ); +acado_multGxGx( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.QGx[ 160 ]) ); +acado_multGxGx( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.QGx[ 176 ]) ); +acado_multGxGx( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.QGx[ 192 ]) ); +acado_multGxGx( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.QGx[ 208 ]) ); +acado_multGxGx( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.QGx[ 224 ]) ); +acado_multGxGx( &(acadoWorkspace.Q1[ 256 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.QGx[ 240 ]) ); +acado_multGxGx( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.QGx[ 256 ]) ); +acado_multGxGx( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.QGx[ 272 ]) ); +acado_multGxGx( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.QGx[ 288 ]) ); +acado_multGxGx( acadoWorkspace.QN1, &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.QGx[ 304 ]) ); + +acado_multGxGu( &(acadoWorkspace.Q1[ 16 ]), acadoWorkspace.E, acadoWorkspace.QE ); +acado_multGxGu( &(acadoWorkspace.Q1[ 32 ]), &(acadoWorkspace.E[ 4 ]), &(acadoWorkspace.QE[ 4 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 32 ]), &(acadoWorkspace.E[ 8 ]), &(acadoWorkspace.QE[ 8 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 48 ]), &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.QE[ 12 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 48 ]), &(acadoWorkspace.E[ 16 ]), &(acadoWorkspace.QE[ 16 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 48 ]), &(acadoWorkspace.E[ 20 ]), &(acadoWorkspace.QE[ 20 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 64 ]), &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.QE[ 24 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 64 ]), &(acadoWorkspace.E[ 28 ]), &(acadoWorkspace.QE[ 28 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 64 ]), &(acadoWorkspace.E[ 32 ]), &(acadoWorkspace.QE[ 32 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 64 ]), &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.QE[ 36 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 80 ]), &(acadoWorkspace.E[ 40 ]), &(acadoWorkspace.QE[ 40 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 80 ]), &(acadoWorkspace.E[ 44 ]), &(acadoWorkspace.QE[ 44 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 80 ]), &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QE[ 48 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 80 ]), &(acadoWorkspace.E[ 52 ]), &(acadoWorkspace.QE[ 52 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 80 ]), &(acadoWorkspace.E[ 56 ]), &(acadoWorkspace.QE[ 56 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 96 ]), &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QE[ 60 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 96 ]), &(acadoWorkspace.E[ 64 ]), &(acadoWorkspace.QE[ 64 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 96 ]), &(acadoWorkspace.E[ 68 ]), &(acadoWorkspace.QE[ 68 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 96 ]), &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QE[ 72 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 96 ]), &(acadoWorkspace.E[ 76 ]), &(acadoWorkspace.QE[ 76 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 96 ]), &(acadoWorkspace.E[ 80 ]), &(acadoWorkspace.QE[ 80 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 112 ]), &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 84 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 112 ]), &(acadoWorkspace.E[ 88 ]), &(acadoWorkspace.QE[ 88 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 112 ]), &(acadoWorkspace.E[ 92 ]), &(acadoWorkspace.QE[ 92 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 112 ]), &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QE[ 96 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 112 ]), &(acadoWorkspace.E[ 100 ]), &(acadoWorkspace.QE[ 100 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 112 ]), &(acadoWorkspace.E[ 104 ]), &(acadoWorkspace.QE[ 104 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 112 ]), &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 108 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.QE[ 112 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.QE[ 116 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 120 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.E[ 124 ]), &(acadoWorkspace.QE[ 124 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.E[ 128 ]), &(acadoWorkspace.QE[ 128 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.QE[ 132 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.E[ 136 ]), &(acadoWorkspace.QE[ 136 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.E[ 140 ]), &(acadoWorkspace.QE[ 140 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 144 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.QE[ 148 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.QE[ 152 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 156 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 160 ]), &(acadoWorkspace.QE[ 160 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 164 ]), &(acadoWorkspace.QE[ 164 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 168 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 172 ]), &(acadoWorkspace.QE[ 172 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 176 ]), &(acadoWorkspace.QE[ 176 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 180 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QE[ 184 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.QE[ 188 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 192 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.E[ 196 ]), &(acadoWorkspace.QE[ 196 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.E[ 200 ]), &(acadoWorkspace.QE[ 200 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 204 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.E[ 208 ]), &(acadoWorkspace.QE[ 208 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.E[ 212 ]), &(acadoWorkspace.QE[ 212 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QE[ 216 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 220 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 224 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 228 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.QE[ 232 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.QE[ 236 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 240 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 244 ]), &(acadoWorkspace.QE[ 244 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 248 ]), &(acadoWorkspace.QE[ 248 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 252 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 256 ]), &(acadoWorkspace.QE[ 256 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 260 ]), &(acadoWorkspace.QE[ 260 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 264 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 268 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 272 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 276 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.QE[ 280 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.QE[ 284 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 288 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 292 ]), &(acadoWorkspace.QE[ 292 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 296 ]), &(acadoWorkspace.QE[ 296 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QE[ 300 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 304 ]), &(acadoWorkspace.QE[ 304 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 308 ]), &(acadoWorkspace.QE[ 308 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 312 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 316 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 320 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 324 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QE[ 328 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.QE[ 332 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 336 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 340 ]), &(acadoWorkspace.QE[ 340 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 344 ]), &(acadoWorkspace.QE[ 344 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QE[ 348 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 352 ]), &(acadoWorkspace.QE[ 352 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 356 ]), &(acadoWorkspace.QE[ 356 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 360 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 364 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 368 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 372 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 376 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 380 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 384 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.QE[ 388 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.QE[ 392 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 396 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 400 ]), &(acadoWorkspace.QE[ 400 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 404 ]), &(acadoWorkspace.QE[ 404 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 408 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 412 ]), &(acadoWorkspace.QE[ 412 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 416 ]), &(acadoWorkspace.QE[ 416 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 420 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 424 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 428 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 432 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 436 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 440 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 444 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.QE[ 448 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.QE[ 452 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QE[ 456 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 460 ]), &(acadoWorkspace.QE[ 460 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 464 ]), &(acadoWorkspace.QE[ 464 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 468 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 472 ]), &(acadoWorkspace.QE[ 472 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 476 ]), &(acadoWorkspace.QE[ 476 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 256 ]), &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 480 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 256 ]), &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 484 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 256 ]), &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 488 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 256 ]), &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 492 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 256 ]), &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 496 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 256 ]), &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 500 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 256 ]), &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 504 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 256 ]), &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QE[ 508 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 256 ]), &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.QE[ 512 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 256 ]), &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 516 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 256 ]), &(acadoWorkspace.E[ 520 ]), &(acadoWorkspace.QE[ 520 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 256 ]), &(acadoWorkspace.E[ 524 ]), &(acadoWorkspace.QE[ 524 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 256 ]), &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 528 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 256 ]), &(acadoWorkspace.E[ 532 ]), &(acadoWorkspace.QE[ 532 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 256 ]), &(acadoWorkspace.E[ 536 ]), &(acadoWorkspace.QE[ 536 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 256 ]), &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 540 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.QE[ 544 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.E[ 548 ]), &(acadoWorkspace.QE[ 548 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 552 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.E[ 556 ]), &(acadoWorkspace.QE[ 556 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.E[ 560 ]), &(acadoWorkspace.QE[ 560 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QE[ 564 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.E[ 568 ]), &(acadoWorkspace.QE[ 568 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.E[ 572 ]), &(acadoWorkspace.QE[ 572 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 576 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.E[ 580 ]), &(acadoWorkspace.QE[ 580 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.E[ 584 ]), &(acadoWorkspace.QE[ 584 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 588 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.E[ 592 ]), &(acadoWorkspace.QE[ 592 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.E[ 596 ]), &(acadoWorkspace.QE[ 596 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 600 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.E[ 604 ]), &(acadoWorkspace.QE[ 604 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.E[ 608 ]), &(acadoWorkspace.QE[ 608 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 612 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.QE[ 616 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.E[ 620 ]), &(acadoWorkspace.QE[ 620 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 624 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.E[ 628 ]), &(acadoWorkspace.QE[ 628 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.E[ 632 ]), &(acadoWorkspace.QE[ 632 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.E[ 636 ]), &(acadoWorkspace.QE[ 636 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.E[ 640 ]), &(acadoWorkspace.QE[ 640 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.E[ 644 ]), &(acadoWorkspace.QE[ 644 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.E[ 648 ]), &(acadoWorkspace.QE[ 648 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.E[ 652 ]), &(acadoWorkspace.QE[ 652 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.E[ 656 ]), &(acadoWorkspace.QE[ 656 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.E[ 660 ]), &(acadoWorkspace.QE[ 660 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.E[ 664 ]), &(acadoWorkspace.QE[ 664 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.E[ 668 ]), &(acadoWorkspace.QE[ 668 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.E[ 672 ]), &(acadoWorkspace.QE[ 672 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.E[ 676 ]), &(acadoWorkspace.QE[ 676 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.E[ 680 ]), &(acadoWorkspace.QE[ 680 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QE[ 684 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.QE[ 688 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.QE[ 692 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.E[ 696 ]), &(acadoWorkspace.QE[ 696 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.E[ 700 ]), &(acadoWorkspace.QE[ 700 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.E[ 704 ]), &(acadoWorkspace.QE[ 704 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.E[ 708 ]), &(acadoWorkspace.QE[ 708 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.E[ 712 ]), &(acadoWorkspace.QE[ 712 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.E[ 716 ]), &(acadoWorkspace.QE[ 716 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.E[ 720 ]), &(acadoWorkspace.QE[ 720 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.E[ 724 ]), &(acadoWorkspace.QE[ 724 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.E[ 728 ]), &(acadoWorkspace.QE[ 728 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.E[ 732 ]), &(acadoWorkspace.QE[ 732 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.E[ 736 ]), &(acadoWorkspace.QE[ 736 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.E[ 740 ]), &(acadoWorkspace.QE[ 740 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.E[ 744 ]), &(acadoWorkspace.QE[ 744 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.E[ 748 ]), &(acadoWorkspace.QE[ 748 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.E[ 752 ]), &(acadoWorkspace.QE[ 752 ]) ); +acado_multGxGu( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.E[ 756 ]), &(acadoWorkspace.QE[ 756 ]) ); +acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 760 ]) ); +acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QE[ 764 ]) ); +acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.QE[ 768 ]) ); +acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 772 ]), &(acadoWorkspace.QE[ 772 ]) ); +acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 776 ]), &(acadoWorkspace.QE[ 776 ]) ); +acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 780 ]), &(acadoWorkspace.QE[ 780 ]) ); +acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 784 ]), &(acadoWorkspace.QE[ 784 ]) ); +acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 788 ]), &(acadoWorkspace.QE[ 788 ]) ); +acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 792 ]), &(acadoWorkspace.QE[ 792 ]) ); +acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 796 ]), &(acadoWorkspace.QE[ 796 ]) ); +acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 800 ]), &(acadoWorkspace.QE[ 800 ]) ); +acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 804 ]), &(acadoWorkspace.QE[ 804 ]) ); +acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 808 ]), &(acadoWorkspace.QE[ 808 ]) ); +acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 812 ]), &(acadoWorkspace.QE[ 812 ]) ); +acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 816 ]), &(acadoWorkspace.QE[ 816 ]) ); +acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 820 ]), &(acadoWorkspace.QE[ 820 ]) ); +acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 824 ]), &(acadoWorkspace.QE[ 824 ]) ); +acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 828 ]), &(acadoWorkspace.QE[ 828 ]) ); +acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 832 ]), &(acadoWorkspace.QE[ 832 ]) ); +acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 836 ]), &(acadoWorkspace.QE[ 836 ]) ); + +acado_zeroBlockH00( ); +acado_multCTQC( acadoWorkspace.evGx, acadoWorkspace.QGx ); +acado_multCTQC( &(acadoWorkspace.evGx[ 16 ]), &(acadoWorkspace.QGx[ 16 ]) ); +acado_multCTQC( &(acadoWorkspace.evGx[ 32 ]), &(acadoWorkspace.QGx[ 32 ]) ); +acado_multCTQC( &(acadoWorkspace.evGx[ 48 ]), &(acadoWorkspace.QGx[ 48 ]) ); +acado_multCTQC( &(acadoWorkspace.evGx[ 64 ]), &(acadoWorkspace.QGx[ 64 ]) ); +acado_multCTQC( &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.QGx[ 80 ]) ); +acado_multCTQC( &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.QGx[ 96 ]) ); +acado_multCTQC( &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.QGx[ 112 ]) ); +acado_multCTQC( &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.QGx[ 128 ]) ); +acado_multCTQC( &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.QGx[ 144 ]) ); +acado_multCTQC( &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.QGx[ 160 ]) ); +acado_multCTQC( &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.QGx[ 176 ]) ); +acado_multCTQC( &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.QGx[ 192 ]) ); +acado_multCTQC( &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.QGx[ 208 ]) ); +acado_multCTQC( &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.QGx[ 224 ]) ); +acado_multCTQC( &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.QGx[ 240 ]) ); +acado_multCTQC( &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.QGx[ 256 ]) ); +acado_multCTQC( &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.QGx[ 272 ]) ); +acado_multCTQC( &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.QGx[ 288 ]) ); +acado_multCTQC( &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.QGx[ 304 ]) ); + +acado_zeroBlockH10( acadoWorkspace.H10 ); +acado_multQETGx( acadoWorkspace.QE, acadoWorkspace.evGx, acadoWorkspace.H10 ); +acado_multQETGx( &(acadoWorkspace.QE[ 4 ]), &(acadoWorkspace.evGx[ 16 ]), acadoWorkspace.H10 ); +acado_multQETGx( &(acadoWorkspace.QE[ 12 ]), &(acadoWorkspace.evGx[ 32 ]), acadoWorkspace.H10 ); +acado_multQETGx( &(acadoWorkspace.QE[ 24 ]), &(acadoWorkspace.evGx[ 48 ]), acadoWorkspace.H10 ); +acado_multQETGx( &(acadoWorkspace.QE[ 40 ]), &(acadoWorkspace.evGx[ 64 ]), acadoWorkspace.H10 ); +acado_multQETGx( &(acadoWorkspace.QE[ 60 ]), &(acadoWorkspace.evGx[ 80 ]), acadoWorkspace.H10 ); +acado_multQETGx( &(acadoWorkspace.QE[ 84 ]), &(acadoWorkspace.evGx[ 96 ]), acadoWorkspace.H10 ); +acado_multQETGx( &(acadoWorkspace.QE[ 112 ]), &(acadoWorkspace.evGx[ 112 ]), acadoWorkspace.H10 ); +acado_multQETGx( &(acadoWorkspace.QE[ 144 ]), &(acadoWorkspace.evGx[ 128 ]), acadoWorkspace.H10 ); +acado_multQETGx( &(acadoWorkspace.QE[ 180 ]), &(acadoWorkspace.evGx[ 144 ]), acadoWorkspace.H10 ); +acado_multQETGx( &(acadoWorkspace.QE[ 220 ]), &(acadoWorkspace.evGx[ 160 ]), acadoWorkspace.H10 ); +acado_multQETGx( &(acadoWorkspace.QE[ 264 ]), &(acadoWorkspace.evGx[ 176 ]), acadoWorkspace.H10 ); +acado_multQETGx( &(acadoWorkspace.QE[ 312 ]), &(acadoWorkspace.evGx[ 192 ]), acadoWorkspace.H10 ); +acado_multQETGx( &(acadoWorkspace.QE[ 364 ]), &(acadoWorkspace.evGx[ 208 ]), acadoWorkspace.H10 ); +acado_multQETGx( &(acadoWorkspace.QE[ 420 ]), &(acadoWorkspace.evGx[ 224 ]), acadoWorkspace.H10 ); +acado_multQETGx( &(acadoWorkspace.QE[ 480 ]), &(acadoWorkspace.evGx[ 240 ]), acadoWorkspace.H10 ); +acado_multQETGx( &(acadoWorkspace.QE[ 544 ]), &(acadoWorkspace.evGx[ 256 ]), acadoWorkspace.H10 ); +acado_multQETGx( &(acadoWorkspace.QE[ 612 ]), &(acadoWorkspace.evGx[ 272 ]), acadoWorkspace.H10 ); +acado_multQETGx( &(acadoWorkspace.QE[ 684 ]), &(acadoWorkspace.evGx[ 288 ]), acadoWorkspace.H10 ); +acado_multQETGx( &(acadoWorkspace.QE[ 760 ]), &(acadoWorkspace.evGx[ 304 ]), acadoWorkspace.H10 ); +acado_zeroBlockH10( &(acadoWorkspace.H10[ 4 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 8 ]), &(acadoWorkspace.evGx[ 16 ]), &(acadoWorkspace.H10[ 4 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 16 ]), &(acadoWorkspace.evGx[ 32 ]), &(acadoWorkspace.H10[ 4 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 28 ]), &(acadoWorkspace.evGx[ 48 ]), &(acadoWorkspace.H10[ 4 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 44 ]), &(acadoWorkspace.evGx[ 64 ]), &(acadoWorkspace.H10[ 4 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 64 ]), &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.H10[ 4 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 88 ]), &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.H10[ 4 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 116 ]), &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.H10[ 4 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 148 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.H10[ 4 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 184 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 4 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 224 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.H10[ 4 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 268 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 4 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 316 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 4 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 368 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 4 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 424 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 4 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 484 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 4 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 548 ]), &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.H10[ 4 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 616 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.H10[ 4 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 688 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.H10[ 4 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 764 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.H10[ 4 ]) ); +acado_zeroBlockH10( &(acadoWorkspace.H10[ 8 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 20 ]), &(acadoWorkspace.evGx[ 32 ]), &(acadoWorkspace.H10[ 8 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 32 ]), &(acadoWorkspace.evGx[ 48 ]), &(acadoWorkspace.H10[ 8 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 48 ]), &(acadoWorkspace.evGx[ 64 ]), &(acadoWorkspace.H10[ 8 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 68 ]), &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.H10[ 8 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 92 ]), &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.H10[ 8 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 120 ]), &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.H10[ 8 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 152 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.H10[ 8 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 188 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 8 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 228 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.H10[ 8 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 272 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 8 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 320 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 8 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 372 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 8 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 428 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 8 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 488 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 8 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 552 ]), &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.H10[ 8 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 620 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.H10[ 8 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 692 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.H10[ 8 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 768 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.H10[ 8 ]) ); +acado_zeroBlockH10( &(acadoWorkspace.H10[ 12 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 36 ]), &(acadoWorkspace.evGx[ 48 ]), &(acadoWorkspace.H10[ 12 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 52 ]), &(acadoWorkspace.evGx[ 64 ]), &(acadoWorkspace.H10[ 12 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 72 ]), &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.H10[ 12 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 96 ]), &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.H10[ 12 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 124 ]), &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.H10[ 12 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 156 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.H10[ 12 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 192 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 12 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 232 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.H10[ 12 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 276 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 12 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 324 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 12 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 376 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 12 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 432 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 12 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 492 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 12 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 556 ]), &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.H10[ 12 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 624 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.H10[ 12 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 696 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.H10[ 12 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 772 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.H10[ 12 ]) ); +acado_zeroBlockH10( &(acadoWorkspace.H10[ 16 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 56 ]), &(acadoWorkspace.evGx[ 64 ]), &(acadoWorkspace.H10[ 16 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 76 ]), &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.H10[ 16 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 100 ]), &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.H10[ 16 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 128 ]), &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.H10[ 16 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 160 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.H10[ 16 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 196 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 16 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 236 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.H10[ 16 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 280 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 16 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 328 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 16 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 380 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 16 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 436 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 16 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 496 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 16 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 560 ]), &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.H10[ 16 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 628 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.H10[ 16 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 700 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.H10[ 16 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 776 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.H10[ 16 ]) ); +acado_zeroBlockH10( &(acadoWorkspace.H10[ 20 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 80 ]), &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.H10[ 20 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 104 ]), &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.H10[ 20 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 132 ]), &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.H10[ 20 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 164 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.H10[ 20 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 200 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 20 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 240 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.H10[ 20 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 284 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 20 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 332 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 20 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 384 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 20 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 440 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 20 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 500 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 20 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 564 ]), &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.H10[ 20 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 632 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.H10[ 20 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 704 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.H10[ 20 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 780 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.H10[ 20 ]) ); +acado_zeroBlockH10( &(acadoWorkspace.H10[ 24 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 108 ]), &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.H10[ 24 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 136 ]), &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.H10[ 24 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 168 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.H10[ 24 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 204 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 24 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 244 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.H10[ 24 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 288 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 24 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 336 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 24 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 388 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 24 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 444 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 24 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 504 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 24 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 568 ]), &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.H10[ 24 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 636 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.H10[ 24 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 708 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.H10[ 24 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 784 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.H10[ 24 ]) ); +acado_zeroBlockH10( &(acadoWorkspace.H10[ 28 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 140 ]), &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.H10[ 28 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 172 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.H10[ 28 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 208 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 28 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 248 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.H10[ 28 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 292 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 28 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 340 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 28 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 392 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 28 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 448 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 28 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 508 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 28 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 572 ]), &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.H10[ 28 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 640 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.H10[ 28 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 712 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.H10[ 28 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 788 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.H10[ 28 ]) ); +acado_zeroBlockH10( &(acadoWorkspace.H10[ 32 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 176 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.H10[ 32 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 212 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 32 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 252 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.H10[ 32 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 296 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 32 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 344 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 32 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 396 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 32 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 452 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 32 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 512 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 32 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 576 ]), &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.H10[ 32 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 644 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.H10[ 32 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 716 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.H10[ 32 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 792 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.H10[ 32 ]) ); +acado_zeroBlockH10( &(acadoWorkspace.H10[ 36 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 216 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 36 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 256 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.H10[ 36 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 300 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 36 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 348 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 36 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 400 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 36 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 456 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 36 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 516 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 36 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 580 ]), &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.H10[ 36 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 648 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.H10[ 36 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 720 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.H10[ 36 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 796 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.H10[ 36 ]) ); +acado_zeroBlockH10( &(acadoWorkspace.H10[ 40 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 260 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.H10[ 40 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 304 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 40 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 352 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 40 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 404 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 40 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 460 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 40 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 520 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 40 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 584 ]), &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.H10[ 40 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 652 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.H10[ 40 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 724 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.H10[ 40 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 800 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.H10[ 40 ]) ); +acado_zeroBlockH10( &(acadoWorkspace.H10[ 44 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 308 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 44 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 356 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 44 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 408 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 44 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 464 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 44 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 524 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 44 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 588 ]), &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.H10[ 44 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 656 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.H10[ 44 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 728 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.H10[ 44 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 804 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.H10[ 44 ]) ); +acado_zeroBlockH10( &(acadoWorkspace.H10[ 48 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 360 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 48 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 412 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 48 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 468 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 48 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 528 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 48 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 592 ]), &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.H10[ 48 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 660 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.H10[ 48 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 732 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.H10[ 48 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 808 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.H10[ 48 ]) ); +acado_zeroBlockH10( &(acadoWorkspace.H10[ 52 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 416 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 52 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 472 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 52 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 532 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 52 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 596 ]), &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.H10[ 52 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 664 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.H10[ 52 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 736 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.H10[ 52 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 812 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.H10[ 52 ]) ); +acado_zeroBlockH10( &(acadoWorkspace.H10[ 56 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 476 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 56 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 536 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 56 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 600 ]), &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.H10[ 56 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 668 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.H10[ 56 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 740 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.H10[ 56 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 816 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.H10[ 56 ]) ); +acado_zeroBlockH10( &(acadoWorkspace.H10[ 60 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 540 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 60 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 604 ]), &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.H10[ 60 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 672 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.H10[ 60 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 744 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.H10[ 60 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 820 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.H10[ 60 ]) ); +acado_zeroBlockH10( &(acadoWorkspace.H10[ 64 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 608 ]), &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.H10[ 64 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 676 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.H10[ 64 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 748 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.H10[ 64 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 824 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.H10[ 64 ]) ); +acado_zeroBlockH10( &(acadoWorkspace.H10[ 68 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 680 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.H10[ 68 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 752 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.H10[ 68 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 828 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.H10[ 68 ]) ); +acado_zeroBlockH10( &(acadoWorkspace.H10[ 72 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 756 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.H10[ 72 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 832 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.H10[ 72 ]) ); +acado_zeroBlockH10( &(acadoWorkspace.H10[ 76 ]) ); +acado_multQETGx( &(acadoWorkspace.QE[ 836 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.H10[ 76 ]) ); + +acadoWorkspace.H[4] = acadoWorkspace.H10[0]; +acadoWorkspace.H[5] = acadoWorkspace.H10[4]; +acadoWorkspace.H[6] = acadoWorkspace.H10[8]; +acadoWorkspace.H[7] = acadoWorkspace.H10[12]; +acadoWorkspace.H[8] = acadoWorkspace.H10[16]; +acadoWorkspace.H[9] = acadoWorkspace.H10[20]; +acadoWorkspace.H[10] = acadoWorkspace.H10[24]; +acadoWorkspace.H[11] = acadoWorkspace.H10[28]; +acadoWorkspace.H[12] = acadoWorkspace.H10[32]; +acadoWorkspace.H[13] = acadoWorkspace.H10[36]; +acadoWorkspace.H[14] = acadoWorkspace.H10[40]; +acadoWorkspace.H[15] = acadoWorkspace.H10[44]; +acadoWorkspace.H[16] = acadoWorkspace.H10[48]; +acadoWorkspace.H[17] = acadoWorkspace.H10[52]; +acadoWorkspace.H[18] = acadoWorkspace.H10[56]; +acadoWorkspace.H[19] = acadoWorkspace.H10[60]; +acadoWorkspace.H[20] = acadoWorkspace.H10[64]; +acadoWorkspace.H[21] = acadoWorkspace.H10[68]; +acadoWorkspace.H[22] = acadoWorkspace.H10[72]; +acadoWorkspace.H[23] = acadoWorkspace.H10[76]; +acadoWorkspace.H[28] = acadoWorkspace.H10[1]; +acadoWorkspace.H[29] = acadoWorkspace.H10[5]; +acadoWorkspace.H[30] = acadoWorkspace.H10[9]; +acadoWorkspace.H[31] = acadoWorkspace.H10[13]; +acadoWorkspace.H[32] = acadoWorkspace.H10[17]; +acadoWorkspace.H[33] = acadoWorkspace.H10[21]; +acadoWorkspace.H[34] = acadoWorkspace.H10[25]; +acadoWorkspace.H[35] = acadoWorkspace.H10[29]; +acadoWorkspace.H[36] = acadoWorkspace.H10[33]; +acadoWorkspace.H[37] = acadoWorkspace.H10[37]; +acadoWorkspace.H[38] = acadoWorkspace.H10[41]; +acadoWorkspace.H[39] = acadoWorkspace.H10[45]; +acadoWorkspace.H[40] = acadoWorkspace.H10[49]; +acadoWorkspace.H[41] = acadoWorkspace.H10[53]; +acadoWorkspace.H[42] = acadoWorkspace.H10[57]; +acadoWorkspace.H[43] = acadoWorkspace.H10[61]; +acadoWorkspace.H[44] = acadoWorkspace.H10[65]; +acadoWorkspace.H[45] = acadoWorkspace.H10[69]; +acadoWorkspace.H[46] = acadoWorkspace.H10[73]; +acadoWorkspace.H[47] = acadoWorkspace.H10[77]; +acadoWorkspace.H[52] = acadoWorkspace.H10[2]; +acadoWorkspace.H[53] = acadoWorkspace.H10[6]; +acadoWorkspace.H[54] = acadoWorkspace.H10[10]; +acadoWorkspace.H[55] = acadoWorkspace.H10[14]; +acadoWorkspace.H[56] = acadoWorkspace.H10[18]; +acadoWorkspace.H[57] = acadoWorkspace.H10[22]; +acadoWorkspace.H[58] = acadoWorkspace.H10[26]; +acadoWorkspace.H[59] = acadoWorkspace.H10[30]; +acadoWorkspace.H[60] = acadoWorkspace.H10[34]; +acadoWorkspace.H[61] = acadoWorkspace.H10[38]; +acadoWorkspace.H[62] = acadoWorkspace.H10[42]; +acadoWorkspace.H[63] = acadoWorkspace.H10[46]; +acadoWorkspace.H[64] = acadoWorkspace.H10[50]; +acadoWorkspace.H[65] = acadoWorkspace.H10[54]; +acadoWorkspace.H[66] = acadoWorkspace.H10[58]; +acadoWorkspace.H[67] = acadoWorkspace.H10[62]; +acadoWorkspace.H[68] = acadoWorkspace.H10[66]; +acadoWorkspace.H[69] = acadoWorkspace.H10[70]; +acadoWorkspace.H[70] = acadoWorkspace.H10[74]; +acadoWorkspace.H[71] = acadoWorkspace.H10[78]; +acadoWorkspace.H[76] = acadoWorkspace.H10[3]; +acadoWorkspace.H[77] = acadoWorkspace.H10[7]; +acadoWorkspace.H[78] = acadoWorkspace.H10[11]; +acadoWorkspace.H[79] = acadoWorkspace.H10[15]; +acadoWorkspace.H[80] = acadoWorkspace.H10[19]; +acadoWorkspace.H[81] = acadoWorkspace.H10[23]; +acadoWorkspace.H[82] = acadoWorkspace.H10[27]; +acadoWorkspace.H[83] = acadoWorkspace.H10[31]; +acadoWorkspace.H[84] = acadoWorkspace.H10[35]; +acadoWorkspace.H[85] = acadoWorkspace.H10[39]; +acadoWorkspace.H[86] = acadoWorkspace.H10[43]; +acadoWorkspace.H[87] = acadoWorkspace.H10[47]; +acadoWorkspace.H[88] = acadoWorkspace.H10[51]; +acadoWorkspace.H[89] = acadoWorkspace.H10[55]; +acadoWorkspace.H[90] = acadoWorkspace.H10[59]; +acadoWorkspace.H[91] = acadoWorkspace.H10[63]; +acadoWorkspace.H[92] = acadoWorkspace.H10[67]; +acadoWorkspace.H[93] = acadoWorkspace.H10[71]; +acadoWorkspace.H[94] = acadoWorkspace.H10[75]; +acadoWorkspace.H[95] = acadoWorkspace.H10[79]; + +acado_setBlockH11_R1( 0, 0, acadoWorkspace.R1 ); +acado_setBlockH11( 0, 0, acadoWorkspace.E, acadoWorkspace.QE ); +acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 4 ]), &(acadoWorkspace.QE[ 4 ]) ); +acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.QE[ 12 ]) ); +acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.QE[ 24 ]) ); +acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 40 ]), &(acadoWorkspace.QE[ 40 ]) ); +acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QE[ 60 ]) ); +acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 84 ]) ); +acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.QE[ 112 ]) ); +acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 144 ]) ); +acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 180 ]) ); +acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 220 ]) ); +acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 264 ]) ); +acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 312 ]) ); +acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 364 ]) ); +acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 420 ]) ); +acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 480 ]) ); +acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.QE[ 544 ]) ); +acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 612 ]) ); +acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QE[ 684 ]) ); +acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 760 ]) ); + +acado_zeroBlockH11( 0, 1 ); +acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 4 ]), &(acadoWorkspace.QE[ 8 ]) ); +acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.QE[ 16 ]) ); +acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.QE[ 28 ]) ); +acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 40 ]), &(acadoWorkspace.QE[ 44 ]) ); +acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QE[ 64 ]) ); +acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 88 ]) ); +acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.QE[ 116 ]) ); +acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 148 ]) ); +acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 184 ]) ); +acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 224 ]) ); +acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 268 ]) ); +acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 316 ]) ); +acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 368 ]) ); +acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 424 ]) ); +acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 484 ]) ); +acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.QE[ 548 ]) ); +acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 616 ]) ); +acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QE[ 688 ]) ); +acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 764 ]) ); + +acado_zeroBlockH11( 0, 2 ); +acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.QE[ 20 ]) ); +acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.QE[ 32 ]) ); +acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 40 ]), &(acadoWorkspace.QE[ 48 ]) ); +acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QE[ 68 ]) ); +acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 92 ]) ); +acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.QE[ 120 ]) ); +acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 152 ]) ); +acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 188 ]) ); +acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 228 ]) ); +acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 272 ]) ); +acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 320 ]) ); +acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 372 ]) ); +acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 428 ]) ); +acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 488 ]) ); +acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.QE[ 552 ]) ); +acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 620 ]) ); +acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QE[ 692 ]) ); +acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 768 ]) ); + +acado_zeroBlockH11( 0, 3 ); +acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.QE[ 36 ]) ); +acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 40 ]), &(acadoWorkspace.QE[ 52 ]) ); +acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QE[ 72 ]) ); +acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 96 ]) ); +acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.QE[ 124 ]) ); +acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 156 ]) ); +acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 192 ]) ); +acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 232 ]) ); +acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 276 ]) ); +acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 324 ]) ); +acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 376 ]) ); +acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 432 ]) ); +acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 492 ]) ); +acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.QE[ 556 ]) ); +acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 624 ]) ); +acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QE[ 696 ]) ); +acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 772 ]) ); + +acado_zeroBlockH11( 0, 4 ); +acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 40 ]), &(acadoWorkspace.QE[ 56 ]) ); +acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QE[ 76 ]) ); +acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 100 ]) ); +acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.QE[ 128 ]) ); +acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 160 ]) ); +acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 196 ]) ); +acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 236 ]) ); +acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 280 ]) ); +acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 328 ]) ); +acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 380 ]) ); +acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 436 ]) ); +acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 496 ]) ); +acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.QE[ 560 ]) ); +acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 628 ]) ); +acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QE[ 700 ]) ); +acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 776 ]) ); + +acado_zeroBlockH11( 0, 5 ); +acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QE[ 80 ]) ); +acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 104 ]) ); +acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.QE[ 132 ]) ); +acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 164 ]) ); +acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 200 ]) ); +acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 240 ]) ); +acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 284 ]) ); +acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 332 ]) ); +acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 384 ]) ); +acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 440 ]) ); +acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 500 ]) ); +acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.QE[ 564 ]) ); +acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 632 ]) ); +acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QE[ 704 ]) ); +acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 780 ]) ); + +acado_zeroBlockH11( 0, 6 ); +acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 108 ]) ); +acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.QE[ 136 ]) ); +acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 168 ]) ); +acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 204 ]) ); +acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 244 ]) ); +acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 288 ]) ); +acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 336 ]) ); +acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 388 ]) ); +acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 444 ]) ); +acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 504 ]) ); +acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.QE[ 568 ]) ); +acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 636 ]) ); +acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QE[ 708 ]) ); +acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 784 ]) ); + +acado_zeroBlockH11( 0, 7 ); +acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.QE[ 140 ]) ); +acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 172 ]) ); +acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 208 ]) ); +acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 248 ]) ); +acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 292 ]) ); +acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 340 ]) ); +acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 392 ]) ); +acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 448 ]) ); +acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 508 ]) ); +acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.QE[ 572 ]) ); +acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 640 ]) ); +acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QE[ 712 ]) ); +acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 788 ]) ); + +acado_zeroBlockH11( 0, 8 ); +acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 176 ]) ); +acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 212 ]) ); +acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 252 ]) ); +acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 296 ]) ); +acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 344 ]) ); +acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 396 ]) ); +acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 452 ]) ); +acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 512 ]) ); +acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.QE[ 576 ]) ); +acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 644 ]) ); +acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QE[ 716 ]) ); +acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 792 ]) ); + +acado_zeroBlockH11( 0, 9 ); +acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 216 ]) ); +acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 256 ]) ); +acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 300 ]) ); +acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 348 ]) ); +acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 400 ]) ); +acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 456 ]) ); +acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 516 ]) ); +acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.QE[ 580 ]) ); +acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 648 ]) ); +acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QE[ 720 ]) ); +acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 796 ]) ); + +acado_zeroBlockH11( 0, 10 ); +acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 260 ]) ); +acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 304 ]) ); +acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 352 ]) ); +acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 404 ]) ); +acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 460 ]) ); +acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 520 ]) ); +acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.QE[ 584 ]) ); +acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 652 ]) ); +acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QE[ 724 ]) ); +acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 800 ]) ); + +acado_zeroBlockH11( 0, 11 ); +acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 308 ]) ); +acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 356 ]) ); +acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 408 ]) ); +acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 464 ]) ); +acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 524 ]) ); +acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.QE[ 588 ]) ); +acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 656 ]) ); +acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QE[ 728 ]) ); +acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 804 ]) ); + +acado_zeroBlockH11( 0, 12 ); +acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 360 ]) ); +acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 412 ]) ); +acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 468 ]) ); +acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 528 ]) ); +acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.QE[ 592 ]) ); +acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 660 ]) ); +acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QE[ 732 ]) ); +acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 808 ]) ); + +acado_zeroBlockH11( 0, 13 ); +acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 416 ]) ); +acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 472 ]) ); +acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 532 ]) ); +acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.QE[ 596 ]) ); +acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 664 ]) ); +acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QE[ 736 ]) ); +acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 812 ]) ); + +acado_zeroBlockH11( 0, 14 ); +acado_setBlockH11( 0, 14, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 476 ]) ); +acado_setBlockH11( 0, 14, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 536 ]) ); +acado_setBlockH11( 0, 14, &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.QE[ 600 ]) ); +acado_setBlockH11( 0, 14, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 668 ]) ); +acado_setBlockH11( 0, 14, &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QE[ 740 ]) ); +acado_setBlockH11( 0, 14, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 816 ]) ); + +acado_zeroBlockH11( 0, 15 ); +acado_setBlockH11( 0, 15, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 540 ]) ); +acado_setBlockH11( 0, 15, &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.QE[ 604 ]) ); +acado_setBlockH11( 0, 15, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 672 ]) ); +acado_setBlockH11( 0, 15, &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QE[ 744 ]) ); +acado_setBlockH11( 0, 15, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 820 ]) ); + +acado_zeroBlockH11( 0, 16 ); +acado_setBlockH11( 0, 16, &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.QE[ 608 ]) ); +acado_setBlockH11( 0, 16, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 676 ]) ); +acado_setBlockH11( 0, 16, &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QE[ 748 ]) ); +acado_setBlockH11( 0, 16, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 824 ]) ); + +acado_zeroBlockH11( 0, 17 ); +acado_setBlockH11( 0, 17, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 680 ]) ); +acado_setBlockH11( 0, 17, &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QE[ 752 ]) ); +acado_setBlockH11( 0, 17, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 828 ]) ); + +acado_zeroBlockH11( 0, 18 ); +acado_setBlockH11( 0, 18, &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QE[ 756 ]) ); +acado_setBlockH11( 0, 18, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 832 ]) ); + +acado_zeroBlockH11( 0, 19 ); +acado_setBlockH11( 0, 19, &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QE[ 836 ]) ); + +acado_setBlockH11_R1( 1, 1, &(acadoWorkspace.R1[ 1 ]) ); +acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 8 ]), &(acadoWorkspace.QE[ 8 ]) ); +acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 16 ]), &(acadoWorkspace.QE[ 16 ]) ); +acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 28 ]), &(acadoWorkspace.QE[ 28 ]) ); +acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 44 ]), &(acadoWorkspace.QE[ 44 ]) ); +acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 64 ]), &(acadoWorkspace.QE[ 64 ]) ); +acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 88 ]), &(acadoWorkspace.QE[ 88 ]) ); +acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.QE[ 116 ]) ); +acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.QE[ 148 ]) ); +acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QE[ 184 ]) ); +acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 224 ]) ); +acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 268 ]) ); +acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 316 ]) ); +acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 368 ]) ); +acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 424 ]) ); +acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 484 ]) ); +acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 548 ]), &(acadoWorkspace.QE[ 548 ]) ); +acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.QE[ 616 ]) ); +acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.QE[ 688 ]) ); +acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QE[ 764 ]) ); + +acado_zeroBlockH11( 1, 2 ); +acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 16 ]), &(acadoWorkspace.QE[ 20 ]) ); +acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 28 ]), &(acadoWorkspace.QE[ 32 ]) ); +acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 44 ]), &(acadoWorkspace.QE[ 48 ]) ); +acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 64 ]), &(acadoWorkspace.QE[ 68 ]) ); +acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 88 ]), &(acadoWorkspace.QE[ 92 ]) ); +acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.QE[ 120 ]) ); +acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.QE[ 152 ]) ); +acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QE[ 188 ]) ); +acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 228 ]) ); +acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 272 ]) ); +acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 320 ]) ); +acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 372 ]) ); +acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 428 ]) ); +acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 488 ]) ); +acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 548 ]), &(acadoWorkspace.QE[ 552 ]) ); +acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.QE[ 620 ]) ); +acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.QE[ 692 ]) ); +acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QE[ 768 ]) ); + +acado_zeroBlockH11( 1, 3 ); +acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 28 ]), &(acadoWorkspace.QE[ 36 ]) ); +acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 44 ]), &(acadoWorkspace.QE[ 52 ]) ); +acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 64 ]), &(acadoWorkspace.QE[ 72 ]) ); +acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 88 ]), &(acadoWorkspace.QE[ 96 ]) ); +acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.QE[ 124 ]) ); +acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.QE[ 156 ]) ); +acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QE[ 192 ]) ); +acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 232 ]) ); +acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 276 ]) ); +acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 324 ]) ); +acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 376 ]) ); +acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 432 ]) ); +acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 492 ]) ); +acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 548 ]), &(acadoWorkspace.QE[ 556 ]) ); +acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.QE[ 624 ]) ); +acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.QE[ 696 ]) ); +acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QE[ 772 ]) ); + +acado_zeroBlockH11( 1, 4 ); +acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 44 ]), &(acadoWorkspace.QE[ 56 ]) ); +acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 64 ]), &(acadoWorkspace.QE[ 76 ]) ); +acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 88 ]), &(acadoWorkspace.QE[ 100 ]) ); +acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.QE[ 128 ]) ); +acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.QE[ 160 ]) ); +acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QE[ 196 ]) ); +acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 236 ]) ); +acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 280 ]) ); +acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 328 ]) ); +acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 380 ]) ); +acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 436 ]) ); +acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 496 ]) ); +acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 548 ]), &(acadoWorkspace.QE[ 560 ]) ); +acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.QE[ 628 ]) ); +acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.QE[ 700 ]) ); +acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QE[ 776 ]) ); + +acado_zeroBlockH11( 1, 5 ); +acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 64 ]), &(acadoWorkspace.QE[ 80 ]) ); +acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 88 ]), &(acadoWorkspace.QE[ 104 ]) ); +acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.QE[ 132 ]) ); +acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.QE[ 164 ]) ); +acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QE[ 200 ]) ); +acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 240 ]) ); +acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 284 ]) ); +acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 332 ]) ); +acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 384 ]) ); +acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 440 ]) ); +acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 500 ]) ); +acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 548 ]), &(acadoWorkspace.QE[ 564 ]) ); +acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.QE[ 632 ]) ); +acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.QE[ 704 ]) ); +acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QE[ 780 ]) ); + +acado_zeroBlockH11( 1, 6 ); +acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 88 ]), &(acadoWorkspace.QE[ 108 ]) ); +acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.QE[ 136 ]) ); +acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.QE[ 168 ]) ); +acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QE[ 204 ]) ); +acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 244 ]) ); +acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 288 ]) ); +acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 336 ]) ); +acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 388 ]) ); +acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 444 ]) ); +acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 504 ]) ); +acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 548 ]), &(acadoWorkspace.QE[ 568 ]) ); +acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.QE[ 636 ]) ); +acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.QE[ 708 ]) ); +acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QE[ 784 ]) ); + +acado_zeroBlockH11( 1, 7 ); +acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.QE[ 140 ]) ); +acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.QE[ 172 ]) ); +acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QE[ 208 ]) ); +acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 248 ]) ); +acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 292 ]) ); +acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 340 ]) ); +acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 392 ]) ); +acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 448 ]) ); +acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 508 ]) ); +acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 548 ]), &(acadoWorkspace.QE[ 572 ]) ); +acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.QE[ 640 ]) ); +acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.QE[ 712 ]) ); +acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QE[ 788 ]) ); + +acado_zeroBlockH11( 1, 8 ); +acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.QE[ 176 ]) ); +acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QE[ 212 ]) ); +acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 252 ]) ); +acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 296 ]) ); +acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 344 ]) ); +acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 396 ]) ); +acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 452 ]) ); +acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 512 ]) ); +acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 548 ]), &(acadoWorkspace.QE[ 576 ]) ); +acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.QE[ 644 ]) ); +acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.QE[ 716 ]) ); +acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QE[ 792 ]) ); + +acado_zeroBlockH11( 1, 9 ); +acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QE[ 216 ]) ); +acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 256 ]) ); +acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 300 ]) ); +acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 348 ]) ); +acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 400 ]) ); +acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 456 ]) ); +acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 516 ]) ); +acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 548 ]), &(acadoWorkspace.QE[ 580 ]) ); +acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.QE[ 648 ]) ); +acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.QE[ 720 ]) ); +acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QE[ 796 ]) ); + +acado_zeroBlockH11( 1, 10 ); +acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 260 ]) ); +acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 304 ]) ); +acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 352 ]) ); +acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 404 ]) ); +acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 460 ]) ); +acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 520 ]) ); +acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 548 ]), &(acadoWorkspace.QE[ 584 ]) ); +acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.QE[ 652 ]) ); +acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.QE[ 724 ]) ); +acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QE[ 800 ]) ); + +acado_zeroBlockH11( 1, 11 ); +acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 308 ]) ); +acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 356 ]) ); +acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 408 ]) ); +acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 464 ]) ); +acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 524 ]) ); +acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 548 ]), &(acadoWorkspace.QE[ 588 ]) ); +acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.QE[ 656 ]) ); +acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.QE[ 728 ]) ); +acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QE[ 804 ]) ); + +acado_zeroBlockH11( 1, 12 ); +acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 360 ]) ); +acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 412 ]) ); +acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 468 ]) ); +acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 528 ]) ); +acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 548 ]), &(acadoWorkspace.QE[ 592 ]) ); +acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.QE[ 660 ]) ); +acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.QE[ 732 ]) ); +acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QE[ 808 ]) ); + +acado_zeroBlockH11( 1, 13 ); +acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 416 ]) ); +acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 472 ]) ); +acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 532 ]) ); +acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 548 ]), &(acadoWorkspace.QE[ 596 ]) ); +acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.QE[ 664 ]) ); +acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.QE[ 736 ]) ); +acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QE[ 812 ]) ); + +acado_zeroBlockH11( 1, 14 ); +acado_setBlockH11( 1, 14, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 476 ]) ); +acado_setBlockH11( 1, 14, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 536 ]) ); +acado_setBlockH11( 1, 14, &(acadoWorkspace.E[ 548 ]), &(acadoWorkspace.QE[ 600 ]) ); +acado_setBlockH11( 1, 14, &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.QE[ 668 ]) ); +acado_setBlockH11( 1, 14, &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.QE[ 740 ]) ); +acado_setBlockH11( 1, 14, &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QE[ 816 ]) ); + +acado_zeroBlockH11( 1, 15 ); +acado_setBlockH11( 1, 15, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 540 ]) ); +acado_setBlockH11( 1, 15, &(acadoWorkspace.E[ 548 ]), &(acadoWorkspace.QE[ 604 ]) ); +acado_setBlockH11( 1, 15, &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.QE[ 672 ]) ); +acado_setBlockH11( 1, 15, &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.QE[ 744 ]) ); +acado_setBlockH11( 1, 15, &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QE[ 820 ]) ); + +acado_zeroBlockH11( 1, 16 ); +acado_setBlockH11( 1, 16, &(acadoWorkspace.E[ 548 ]), &(acadoWorkspace.QE[ 608 ]) ); +acado_setBlockH11( 1, 16, &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.QE[ 676 ]) ); +acado_setBlockH11( 1, 16, &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.QE[ 748 ]) ); +acado_setBlockH11( 1, 16, &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QE[ 824 ]) ); + +acado_zeroBlockH11( 1, 17 ); +acado_setBlockH11( 1, 17, &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.QE[ 680 ]) ); +acado_setBlockH11( 1, 17, &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.QE[ 752 ]) ); +acado_setBlockH11( 1, 17, &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QE[ 828 ]) ); + +acado_zeroBlockH11( 1, 18 ); +acado_setBlockH11( 1, 18, &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.QE[ 756 ]) ); +acado_setBlockH11( 1, 18, &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QE[ 832 ]) ); + +acado_zeroBlockH11( 1, 19 ); +acado_setBlockH11( 1, 19, &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QE[ 836 ]) ); + +acado_setBlockH11_R1( 2, 2, &(acadoWorkspace.R1[ 2 ]) ); +acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 20 ]), &(acadoWorkspace.QE[ 20 ]) ); +acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 32 ]), &(acadoWorkspace.QE[ 32 ]) ); +acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QE[ 48 ]) ); +acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 68 ]), &(acadoWorkspace.QE[ 68 ]) ); +acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 92 ]), &(acadoWorkspace.QE[ 92 ]) ); +acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 120 ]) ); +acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.QE[ 152 ]) ); +acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.QE[ 188 ]) ); +acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 228 ]) ); +acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 272 ]) ); +acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 320 ]) ); +acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 372 ]) ); +acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 428 ]) ); +acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 488 ]) ); +acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 552 ]) ); +acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 620 ]), &(acadoWorkspace.QE[ 620 ]) ); +acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.QE[ 692 ]) ); +acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.QE[ 768 ]) ); + +acado_zeroBlockH11( 2, 3 ); +acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 32 ]), &(acadoWorkspace.QE[ 36 ]) ); +acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QE[ 52 ]) ); +acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 68 ]), &(acadoWorkspace.QE[ 72 ]) ); +acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 92 ]), &(acadoWorkspace.QE[ 96 ]) ); +acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 124 ]) ); +acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.QE[ 156 ]) ); +acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.QE[ 192 ]) ); +acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 232 ]) ); +acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 276 ]) ); +acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 324 ]) ); +acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 376 ]) ); +acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 432 ]) ); +acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 492 ]) ); +acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 556 ]) ); +acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 620 ]), &(acadoWorkspace.QE[ 624 ]) ); +acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.QE[ 696 ]) ); +acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.QE[ 772 ]) ); + +acado_zeroBlockH11( 2, 4 ); +acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QE[ 56 ]) ); +acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 68 ]), &(acadoWorkspace.QE[ 76 ]) ); +acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 92 ]), &(acadoWorkspace.QE[ 100 ]) ); +acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 128 ]) ); +acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.QE[ 160 ]) ); +acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.QE[ 196 ]) ); +acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 236 ]) ); +acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 280 ]) ); +acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 328 ]) ); +acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 380 ]) ); +acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 436 ]) ); +acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 496 ]) ); +acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 560 ]) ); +acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 620 ]), &(acadoWorkspace.QE[ 628 ]) ); +acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.QE[ 700 ]) ); +acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.QE[ 776 ]) ); + +acado_zeroBlockH11( 2, 5 ); +acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 68 ]), &(acadoWorkspace.QE[ 80 ]) ); +acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 92 ]), &(acadoWorkspace.QE[ 104 ]) ); +acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 132 ]) ); +acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.QE[ 164 ]) ); +acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.QE[ 200 ]) ); +acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 240 ]) ); +acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 284 ]) ); +acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 332 ]) ); +acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 384 ]) ); +acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 440 ]) ); +acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 500 ]) ); +acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 564 ]) ); +acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 620 ]), &(acadoWorkspace.QE[ 632 ]) ); +acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.QE[ 704 ]) ); +acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.QE[ 780 ]) ); + +acado_zeroBlockH11( 2, 6 ); +acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 92 ]), &(acadoWorkspace.QE[ 108 ]) ); +acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 136 ]) ); +acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.QE[ 168 ]) ); +acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.QE[ 204 ]) ); +acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 244 ]) ); +acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 288 ]) ); +acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 336 ]) ); +acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 388 ]) ); +acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 444 ]) ); +acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 504 ]) ); +acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 568 ]) ); +acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 620 ]), &(acadoWorkspace.QE[ 636 ]) ); +acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.QE[ 708 ]) ); +acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.QE[ 784 ]) ); + +acado_zeroBlockH11( 2, 7 ); +acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 140 ]) ); +acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.QE[ 172 ]) ); +acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.QE[ 208 ]) ); +acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 248 ]) ); +acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 292 ]) ); +acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 340 ]) ); +acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 392 ]) ); +acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 448 ]) ); +acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 508 ]) ); +acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 572 ]) ); +acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 620 ]), &(acadoWorkspace.QE[ 640 ]) ); +acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.QE[ 712 ]) ); +acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.QE[ 788 ]) ); + +acado_zeroBlockH11( 2, 8 ); +acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.QE[ 176 ]) ); +acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.QE[ 212 ]) ); +acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 252 ]) ); +acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 296 ]) ); +acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 344 ]) ); +acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 396 ]) ); +acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 452 ]) ); +acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 512 ]) ); +acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 576 ]) ); +acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 620 ]), &(acadoWorkspace.QE[ 644 ]) ); +acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.QE[ 716 ]) ); +acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.QE[ 792 ]) ); + +acado_zeroBlockH11( 2, 9 ); +acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.QE[ 216 ]) ); +acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 256 ]) ); +acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 300 ]) ); +acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 348 ]) ); +acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 400 ]) ); +acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 456 ]) ); +acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 516 ]) ); +acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 580 ]) ); +acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 620 ]), &(acadoWorkspace.QE[ 648 ]) ); +acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.QE[ 720 ]) ); +acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.QE[ 796 ]) ); + +acado_zeroBlockH11( 2, 10 ); +acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 260 ]) ); +acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 304 ]) ); +acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 352 ]) ); +acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 404 ]) ); +acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 460 ]) ); +acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 520 ]) ); +acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 584 ]) ); +acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 620 ]), &(acadoWorkspace.QE[ 652 ]) ); +acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.QE[ 724 ]) ); +acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.QE[ 800 ]) ); + +acado_zeroBlockH11( 2, 11 ); +acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 308 ]) ); +acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 356 ]) ); +acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 408 ]) ); +acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 464 ]) ); +acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 524 ]) ); +acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 588 ]) ); +acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 620 ]), &(acadoWorkspace.QE[ 656 ]) ); +acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.QE[ 728 ]) ); +acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.QE[ 804 ]) ); + +acado_zeroBlockH11( 2, 12 ); +acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 360 ]) ); +acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 412 ]) ); +acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 468 ]) ); +acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 528 ]) ); +acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 592 ]) ); +acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 620 ]), &(acadoWorkspace.QE[ 660 ]) ); +acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.QE[ 732 ]) ); +acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.QE[ 808 ]) ); + +acado_zeroBlockH11( 2, 13 ); +acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 416 ]) ); +acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 472 ]) ); +acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 532 ]) ); +acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 596 ]) ); +acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 620 ]), &(acadoWorkspace.QE[ 664 ]) ); +acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.QE[ 736 ]) ); +acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.QE[ 812 ]) ); + +acado_zeroBlockH11( 2, 14 ); +acado_setBlockH11( 2, 14, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 476 ]) ); +acado_setBlockH11( 2, 14, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 536 ]) ); +acado_setBlockH11( 2, 14, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 600 ]) ); +acado_setBlockH11( 2, 14, &(acadoWorkspace.E[ 620 ]), &(acadoWorkspace.QE[ 668 ]) ); +acado_setBlockH11( 2, 14, &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.QE[ 740 ]) ); +acado_setBlockH11( 2, 14, &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.QE[ 816 ]) ); + +acado_zeroBlockH11( 2, 15 ); +acado_setBlockH11( 2, 15, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 540 ]) ); +acado_setBlockH11( 2, 15, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 604 ]) ); +acado_setBlockH11( 2, 15, &(acadoWorkspace.E[ 620 ]), &(acadoWorkspace.QE[ 672 ]) ); +acado_setBlockH11( 2, 15, &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.QE[ 744 ]) ); +acado_setBlockH11( 2, 15, &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.QE[ 820 ]) ); + +acado_zeroBlockH11( 2, 16 ); +acado_setBlockH11( 2, 16, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 608 ]) ); +acado_setBlockH11( 2, 16, &(acadoWorkspace.E[ 620 ]), &(acadoWorkspace.QE[ 676 ]) ); +acado_setBlockH11( 2, 16, &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.QE[ 748 ]) ); +acado_setBlockH11( 2, 16, &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.QE[ 824 ]) ); + +acado_zeroBlockH11( 2, 17 ); +acado_setBlockH11( 2, 17, &(acadoWorkspace.E[ 620 ]), &(acadoWorkspace.QE[ 680 ]) ); +acado_setBlockH11( 2, 17, &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.QE[ 752 ]) ); +acado_setBlockH11( 2, 17, &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.QE[ 828 ]) ); + +acado_zeroBlockH11( 2, 18 ); +acado_setBlockH11( 2, 18, &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.QE[ 756 ]) ); +acado_setBlockH11( 2, 18, &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.QE[ 832 ]) ); + +acado_zeroBlockH11( 2, 19 ); +acado_setBlockH11( 2, 19, &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.QE[ 836 ]) ); + +acado_setBlockH11_R1( 3, 3, &(acadoWorkspace.R1[ 3 ]) ); +acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.QE[ 36 ]) ); +acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 52 ]), &(acadoWorkspace.QE[ 52 ]) ); +acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QE[ 72 ]) ); +acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QE[ 96 ]) ); +acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 124 ]), &(acadoWorkspace.QE[ 124 ]) ); +acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 156 ]) ); +acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 192 ]) ); +acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.QE[ 232 ]) ); +acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 276 ]) ); +acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 324 ]) ); +acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 376 ]) ); +acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 432 ]) ); +acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 492 ]) ); +acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 556 ]), &(acadoWorkspace.QE[ 556 ]) ); +acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 624 ]) ); +acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 696 ]), &(acadoWorkspace.QE[ 696 ]) ); +acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 772 ]), &(acadoWorkspace.QE[ 772 ]) ); + +acado_zeroBlockH11( 3, 4 ); +acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 52 ]), &(acadoWorkspace.QE[ 56 ]) ); +acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QE[ 76 ]) ); +acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QE[ 100 ]) ); +acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 124 ]), &(acadoWorkspace.QE[ 128 ]) ); +acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 160 ]) ); +acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 196 ]) ); +acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.QE[ 236 ]) ); +acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 280 ]) ); +acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 328 ]) ); +acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 380 ]) ); +acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 436 ]) ); +acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 496 ]) ); +acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 556 ]), &(acadoWorkspace.QE[ 560 ]) ); +acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 628 ]) ); +acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 696 ]), &(acadoWorkspace.QE[ 700 ]) ); +acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 772 ]), &(acadoWorkspace.QE[ 776 ]) ); + +acado_zeroBlockH11( 3, 5 ); +acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QE[ 80 ]) ); +acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QE[ 104 ]) ); +acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 124 ]), &(acadoWorkspace.QE[ 132 ]) ); +acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 164 ]) ); +acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 200 ]) ); +acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.QE[ 240 ]) ); +acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 284 ]) ); +acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 332 ]) ); +acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 384 ]) ); +acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 440 ]) ); +acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 500 ]) ); +acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 556 ]), &(acadoWorkspace.QE[ 564 ]) ); +acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 632 ]) ); +acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 696 ]), &(acadoWorkspace.QE[ 704 ]) ); +acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 772 ]), &(acadoWorkspace.QE[ 780 ]) ); + +acado_zeroBlockH11( 3, 6 ); +acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QE[ 108 ]) ); +acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 124 ]), &(acadoWorkspace.QE[ 136 ]) ); +acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 168 ]) ); +acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 204 ]) ); +acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.QE[ 244 ]) ); +acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 288 ]) ); +acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 336 ]) ); +acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 388 ]) ); +acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 444 ]) ); +acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 504 ]) ); +acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 556 ]), &(acadoWorkspace.QE[ 568 ]) ); +acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 636 ]) ); +acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 696 ]), &(acadoWorkspace.QE[ 708 ]) ); +acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 772 ]), &(acadoWorkspace.QE[ 784 ]) ); + +acado_zeroBlockH11( 3, 7 ); +acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 124 ]), &(acadoWorkspace.QE[ 140 ]) ); +acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 172 ]) ); +acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 208 ]) ); +acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.QE[ 248 ]) ); +acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 292 ]) ); +acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 340 ]) ); +acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 392 ]) ); +acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 448 ]) ); +acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 508 ]) ); +acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 556 ]), &(acadoWorkspace.QE[ 572 ]) ); +acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 640 ]) ); +acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 696 ]), &(acadoWorkspace.QE[ 712 ]) ); +acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 772 ]), &(acadoWorkspace.QE[ 788 ]) ); + +acado_zeroBlockH11( 3, 8 ); +acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 176 ]) ); +acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 212 ]) ); +acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.QE[ 252 ]) ); +acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 296 ]) ); +acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 344 ]) ); +acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 396 ]) ); +acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 452 ]) ); +acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 512 ]) ); +acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 556 ]), &(acadoWorkspace.QE[ 576 ]) ); +acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 644 ]) ); +acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 696 ]), &(acadoWorkspace.QE[ 716 ]) ); +acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 772 ]), &(acadoWorkspace.QE[ 792 ]) ); + +acado_zeroBlockH11( 3, 9 ); +acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 216 ]) ); +acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.QE[ 256 ]) ); +acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 300 ]) ); +acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 348 ]) ); +acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 400 ]) ); +acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 456 ]) ); +acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 516 ]) ); +acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 556 ]), &(acadoWorkspace.QE[ 580 ]) ); +acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 648 ]) ); +acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 696 ]), &(acadoWorkspace.QE[ 720 ]) ); +acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 772 ]), &(acadoWorkspace.QE[ 796 ]) ); + +acado_zeroBlockH11( 3, 10 ); +acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.QE[ 260 ]) ); +acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 304 ]) ); +acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 352 ]) ); +acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 404 ]) ); +acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 460 ]) ); +acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 520 ]) ); +acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 556 ]), &(acadoWorkspace.QE[ 584 ]) ); +acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 652 ]) ); +acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 696 ]), &(acadoWorkspace.QE[ 724 ]) ); +acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 772 ]), &(acadoWorkspace.QE[ 800 ]) ); + +acado_zeroBlockH11( 3, 11 ); +acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 308 ]) ); +acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 356 ]) ); +acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 408 ]) ); +acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 464 ]) ); +acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 524 ]) ); +acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 556 ]), &(acadoWorkspace.QE[ 588 ]) ); +acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 656 ]) ); +acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 696 ]), &(acadoWorkspace.QE[ 728 ]) ); +acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 772 ]), &(acadoWorkspace.QE[ 804 ]) ); + +acado_zeroBlockH11( 3, 12 ); +acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 360 ]) ); +acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 412 ]) ); +acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 468 ]) ); +acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 528 ]) ); +acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 556 ]), &(acadoWorkspace.QE[ 592 ]) ); +acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 660 ]) ); +acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 696 ]), &(acadoWorkspace.QE[ 732 ]) ); +acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 772 ]), &(acadoWorkspace.QE[ 808 ]) ); + +acado_zeroBlockH11( 3, 13 ); +acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 416 ]) ); +acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 472 ]) ); +acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 532 ]) ); +acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 556 ]), &(acadoWorkspace.QE[ 596 ]) ); +acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 664 ]) ); +acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 696 ]), &(acadoWorkspace.QE[ 736 ]) ); +acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 772 ]), &(acadoWorkspace.QE[ 812 ]) ); + +acado_zeroBlockH11( 3, 14 ); +acado_setBlockH11( 3, 14, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 476 ]) ); +acado_setBlockH11( 3, 14, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 536 ]) ); +acado_setBlockH11( 3, 14, &(acadoWorkspace.E[ 556 ]), &(acadoWorkspace.QE[ 600 ]) ); +acado_setBlockH11( 3, 14, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 668 ]) ); +acado_setBlockH11( 3, 14, &(acadoWorkspace.E[ 696 ]), &(acadoWorkspace.QE[ 740 ]) ); +acado_setBlockH11( 3, 14, &(acadoWorkspace.E[ 772 ]), &(acadoWorkspace.QE[ 816 ]) ); + +acado_zeroBlockH11( 3, 15 ); +acado_setBlockH11( 3, 15, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 540 ]) ); +acado_setBlockH11( 3, 15, &(acadoWorkspace.E[ 556 ]), &(acadoWorkspace.QE[ 604 ]) ); +acado_setBlockH11( 3, 15, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 672 ]) ); +acado_setBlockH11( 3, 15, &(acadoWorkspace.E[ 696 ]), &(acadoWorkspace.QE[ 744 ]) ); +acado_setBlockH11( 3, 15, &(acadoWorkspace.E[ 772 ]), &(acadoWorkspace.QE[ 820 ]) ); + +acado_zeroBlockH11( 3, 16 ); +acado_setBlockH11( 3, 16, &(acadoWorkspace.E[ 556 ]), &(acadoWorkspace.QE[ 608 ]) ); +acado_setBlockH11( 3, 16, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 676 ]) ); +acado_setBlockH11( 3, 16, &(acadoWorkspace.E[ 696 ]), &(acadoWorkspace.QE[ 748 ]) ); +acado_setBlockH11( 3, 16, &(acadoWorkspace.E[ 772 ]), &(acadoWorkspace.QE[ 824 ]) ); + +acado_zeroBlockH11( 3, 17 ); +acado_setBlockH11( 3, 17, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 680 ]) ); +acado_setBlockH11( 3, 17, &(acadoWorkspace.E[ 696 ]), &(acadoWorkspace.QE[ 752 ]) ); +acado_setBlockH11( 3, 17, &(acadoWorkspace.E[ 772 ]), &(acadoWorkspace.QE[ 828 ]) ); + +acado_zeroBlockH11( 3, 18 ); +acado_setBlockH11( 3, 18, &(acadoWorkspace.E[ 696 ]), &(acadoWorkspace.QE[ 756 ]) ); +acado_setBlockH11( 3, 18, &(acadoWorkspace.E[ 772 ]), &(acadoWorkspace.QE[ 832 ]) ); + +acado_zeroBlockH11( 3, 19 ); +acado_setBlockH11( 3, 19, &(acadoWorkspace.E[ 772 ]), &(acadoWorkspace.QE[ 836 ]) ); + +acado_setBlockH11_R1( 4, 4, &(acadoWorkspace.R1[ 4 ]) ); +acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 56 ]), &(acadoWorkspace.QE[ 56 ]) ); +acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 76 ]), &(acadoWorkspace.QE[ 76 ]) ); +acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 100 ]), &(acadoWorkspace.QE[ 100 ]) ); +acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 128 ]), &(acadoWorkspace.QE[ 128 ]) ); +acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 160 ]), &(acadoWorkspace.QE[ 160 ]) ); +acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 196 ]), &(acadoWorkspace.QE[ 196 ]) ); +acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.QE[ 236 ]) ); +acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.QE[ 280 ]) ); +acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QE[ 328 ]) ); +acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 380 ]) ); +acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 436 ]) ); +acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 496 ]) ); +acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 560 ]), &(acadoWorkspace.QE[ 560 ]) ); +acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 628 ]), &(acadoWorkspace.QE[ 628 ]) ); +acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 700 ]), &(acadoWorkspace.QE[ 700 ]) ); +acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 776 ]), &(acadoWorkspace.QE[ 776 ]) ); + +acado_zeroBlockH11( 4, 5 ); +acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 76 ]), &(acadoWorkspace.QE[ 80 ]) ); +acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 100 ]), &(acadoWorkspace.QE[ 104 ]) ); +acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 128 ]), &(acadoWorkspace.QE[ 132 ]) ); +acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 160 ]), &(acadoWorkspace.QE[ 164 ]) ); +acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 196 ]), &(acadoWorkspace.QE[ 200 ]) ); +acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.QE[ 240 ]) ); +acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.QE[ 284 ]) ); +acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QE[ 332 ]) ); +acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 384 ]) ); +acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 440 ]) ); +acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 500 ]) ); +acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 560 ]), &(acadoWorkspace.QE[ 564 ]) ); +acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 628 ]), &(acadoWorkspace.QE[ 632 ]) ); +acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 700 ]), &(acadoWorkspace.QE[ 704 ]) ); +acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 776 ]), &(acadoWorkspace.QE[ 780 ]) ); + +acado_zeroBlockH11( 4, 6 ); +acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 100 ]), &(acadoWorkspace.QE[ 108 ]) ); +acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 128 ]), &(acadoWorkspace.QE[ 136 ]) ); +acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 160 ]), &(acadoWorkspace.QE[ 168 ]) ); +acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 196 ]), &(acadoWorkspace.QE[ 204 ]) ); +acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.QE[ 244 ]) ); +acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.QE[ 288 ]) ); +acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QE[ 336 ]) ); +acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 388 ]) ); +acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 444 ]) ); +acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 504 ]) ); +acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 560 ]), &(acadoWorkspace.QE[ 568 ]) ); +acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 628 ]), &(acadoWorkspace.QE[ 636 ]) ); +acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 700 ]), &(acadoWorkspace.QE[ 708 ]) ); +acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 776 ]), &(acadoWorkspace.QE[ 784 ]) ); + +acado_zeroBlockH11( 4, 7 ); +acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 128 ]), &(acadoWorkspace.QE[ 140 ]) ); +acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 160 ]), &(acadoWorkspace.QE[ 172 ]) ); +acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 196 ]), &(acadoWorkspace.QE[ 208 ]) ); +acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.QE[ 248 ]) ); +acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.QE[ 292 ]) ); +acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QE[ 340 ]) ); +acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 392 ]) ); +acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 448 ]) ); +acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 508 ]) ); +acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 560 ]), &(acadoWorkspace.QE[ 572 ]) ); +acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 628 ]), &(acadoWorkspace.QE[ 640 ]) ); +acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 700 ]), &(acadoWorkspace.QE[ 712 ]) ); +acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 776 ]), &(acadoWorkspace.QE[ 788 ]) ); + +acado_zeroBlockH11( 4, 8 ); +acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 160 ]), &(acadoWorkspace.QE[ 176 ]) ); +acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 196 ]), &(acadoWorkspace.QE[ 212 ]) ); +acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.QE[ 252 ]) ); +acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.QE[ 296 ]) ); +acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QE[ 344 ]) ); +acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 396 ]) ); +acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 452 ]) ); +acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 512 ]) ); +acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 560 ]), &(acadoWorkspace.QE[ 576 ]) ); +acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 628 ]), &(acadoWorkspace.QE[ 644 ]) ); +acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 700 ]), &(acadoWorkspace.QE[ 716 ]) ); +acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 776 ]), &(acadoWorkspace.QE[ 792 ]) ); + +acado_zeroBlockH11( 4, 9 ); +acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 196 ]), &(acadoWorkspace.QE[ 216 ]) ); +acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.QE[ 256 ]) ); +acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.QE[ 300 ]) ); +acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QE[ 348 ]) ); +acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 400 ]) ); +acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 456 ]) ); +acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 516 ]) ); +acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 560 ]), &(acadoWorkspace.QE[ 580 ]) ); +acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 628 ]), &(acadoWorkspace.QE[ 648 ]) ); +acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 700 ]), &(acadoWorkspace.QE[ 720 ]) ); +acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 776 ]), &(acadoWorkspace.QE[ 796 ]) ); + +acado_zeroBlockH11( 4, 10 ); +acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.QE[ 260 ]) ); +acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.QE[ 304 ]) ); +acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QE[ 352 ]) ); +acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 404 ]) ); +acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 460 ]) ); +acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 520 ]) ); +acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 560 ]), &(acadoWorkspace.QE[ 584 ]) ); +acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 628 ]), &(acadoWorkspace.QE[ 652 ]) ); +acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 700 ]), &(acadoWorkspace.QE[ 724 ]) ); +acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 776 ]), &(acadoWorkspace.QE[ 800 ]) ); + +acado_zeroBlockH11( 4, 11 ); +acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.QE[ 308 ]) ); +acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QE[ 356 ]) ); +acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 408 ]) ); +acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 464 ]) ); +acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 524 ]) ); +acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 560 ]), &(acadoWorkspace.QE[ 588 ]) ); +acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 628 ]), &(acadoWorkspace.QE[ 656 ]) ); +acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 700 ]), &(acadoWorkspace.QE[ 728 ]) ); +acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 776 ]), &(acadoWorkspace.QE[ 804 ]) ); + +acado_zeroBlockH11( 4, 12 ); +acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QE[ 360 ]) ); +acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 412 ]) ); +acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 468 ]) ); +acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 528 ]) ); +acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 560 ]), &(acadoWorkspace.QE[ 592 ]) ); +acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 628 ]), &(acadoWorkspace.QE[ 660 ]) ); +acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 700 ]), &(acadoWorkspace.QE[ 732 ]) ); +acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 776 ]), &(acadoWorkspace.QE[ 808 ]) ); + +acado_zeroBlockH11( 4, 13 ); +acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 416 ]) ); +acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 472 ]) ); +acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 532 ]) ); +acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 560 ]), &(acadoWorkspace.QE[ 596 ]) ); +acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 628 ]), &(acadoWorkspace.QE[ 664 ]) ); +acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 700 ]), &(acadoWorkspace.QE[ 736 ]) ); +acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 776 ]), &(acadoWorkspace.QE[ 812 ]) ); + +acado_zeroBlockH11( 4, 14 ); +acado_setBlockH11( 4, 14, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 476 ]) ); +acado_setBlockH11( 4, 14, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 536 ]) ); +acado_setBlockH11( 4, 14, &(acadoWorkspace.E[ 560 ]), &(acadoWorkspace.QE[ 600 ]) ); +acado_setBlockH11( 4, 14, &(acadoWorkspace.E[ 628 ]), &(acadoWorkspace.QE[ 668 ]) ); +acado_setBlockH11( 4, 14, &(acadoWorkspace.E[ 700 ]), &(acadoWorkspace.QE[ 740 ]) ); +acado_setBlockH11( 4, 14, &(acadoWorkspace.E[ 776 ]), &(acadoWorkspace.QE[ 816 ]) ); + +acado_zeroBlockH11( 4, 15 ); +acado_setBlockH11( 4, 15, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 540 ]) ); +acado_setBlockH11( 4, 15, &(acadoWorkspace.E[ 560 ]), &(acadoWorkspace.QE[ 604 ]) ); +acado_setBlockH11( 4, 15, &(acadoWorkspace.E[ 628 ]), &(acadoWorkspace.QE[ 672 ]) ); +acado_setBlockH11( 4, 15, &(acadoWorkspace.E[ 700 ]), &(acadoWorkspace.QE[ 744 ]) ); +acado_setBlockH11( 4, 15, &(acadoWorkspace.E[ 776 ]), &(acadoWorkspace.QE[ 820 ]) ); + +acado_zeroBlockH11( 4, 16 ); +acado_setBlockH11( 4, 16, &(acadoWorkspace.E[ 560 ]), &(acadoWorkspace.QE[ 608 ]) ); +acado_setBlockH11( 4, 16, &(acadoWorkspace.E[ 628 ]), &(acadoWorkspace.QE[ 676 ]) ); +acado_setBlockH11( 4, 16, &(acadoWorkspace.E[ 700 ]), &(acadoWorkspace.QE[ 748 ]) ); +acado_setBlockH11( 4, 16, &(acadoWorkspace.E[ 776 ]), &(acadoWorkspace.QE[ 824 ]) ); + +acado_zeroBlockH11( 4, 17 ); +acado_setBlockH11( 4, 17, &(acadoWorkspace.E[ 628 ]), &(acadoWorkspace.QE[ 680 ]) ); +acado_setBlockH11( 4, 17, &(acadoWorkspace.E[ 700 ]), &(acadoWorkspace.QE[ 752 ]) ); +acado_setBlockH11( 4, 17, &(acadoWorkspace.E[ 776 ]), &(acadoWorkspace.QE[ 828 ]) ); + +acado_zeroBlockH11( 4, 18 ); +acado_setBlockH11( 4, 18, &(acadoWorkspace.E[ 700 ]), &(acadoWorkspace.QE[ 756 ]) ); +acado_setBlockH11( 4, 18, &(acadoWorkspace.E[ 776 ]), &(acadoWorkspace.QE[ 832 ]) ); + +acado_zeroBlockH11( 4, 19 ); +acado_setBlockH11( 4, 19, &(acadoWorkspace.E[ 776 ]), &(acadoWorkspace.QE[ 836 ]) ); + +acado_setBlockH11_R1( 5, 5, &(acadoWorkspace.R1[ 5 ]) ); +acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 80 ]), &(acadoWorkspace.QE[ 80 ]) ); +acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 104 ]), &(acadoWorkspace.QE[ 104 ]) ); +acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.QE[ 132 ]) ); +acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 164 ]), &(acadoWorkspace.QE[ 164 ]) ); +acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 200 ]), &(acadoWorkspace.QE[ 200 ]) ); +acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 240 ]) ); +acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.QE[ 284 ]) ); +acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.QE[ 332 ]) ); +acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 384 ]) ); +acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 440 ]) ); +acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 500 ]) ); +acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QE[ 564 ]) ); +acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 632 ]), &(acadoWorkspace.QE[ 632 ]) ); +acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 704 ]), &(acadoWorkspace.QE[ 704 ]) ); +acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 780 ]), &(acadoWorkspace.QE[ 780 ]) ); + +acado_zeroBlockH11( 5, 6 ); +acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 104 ]), &(acadoWorkspace.QE[ 108 ]) ); +acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.QE[ 136 ]) ); +acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 164 ]), &(acadoWorkspace.QE[ 168 ]) ); +acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 200 ]), &(acadoWorkspace.QE[ 204 ]) ); +acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 244 ]) ); +acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.QE[ 288 ]) ); +acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.QE[ 336 ]) ); +acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 388 ]) ); +acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 444 ]) ); +acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 504 ]) ); +acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QE[ 568 ]) ); +acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 632 ]), &(acadoWorkspace.QE[ 636 ]) ); +acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 704 ]), &(acadoWorkspace.QE[ 708 ]) ); +acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 780 ]), &(acadoWorkspace.QE[ 784 ]) ); + +acado_zeroBlockH11( 5, 7 ); +acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.QE[ 140 ]) ); +acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 164 ]), &(acadoWorkspace.QE[ 172 ]) ); +acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 200 ]), &(acadoWorkspace.QE[ 208 ]) ); +acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 248 ]) ); +acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.QE[ 292 ]) ); +acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.QE[ 340 ]) ); +acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 392 ]) ); +acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 448 ]) ); +acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 508 ]) ); +acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QE[ 572 ]) ); +acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 632 ]), &(acadoWorkspace.QE[ 640 ]) ); +acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 704 ]), &(acadoWorkspace.QE[ 712 ]) ); +acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 780 ]), &(acadoWorkspace.QE[ 788 ]) ); + +acado_zeroBlockH11( 5, 8 ); +acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 164 ]), &(acadoWorkspace.QE[ 176 ]) ); +acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 200 ]), &(acadoWorkspace.QE[ 212 ]) ); +acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 252 ]) ); +acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.QE[ 296 ]) ); +acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.QE[ 344 ]) ); +acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 396 ]) ); +acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 452 ]) ); +acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 512 ]) ); +acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QE[ 576 ]) ); +acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 632 ]), &(acadoWorkspace.QE[ 644 ]) ); +acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 704 ]), &(acadoWorkspace.QE[ 716 ]) ); +acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 780 ]), &(acadoWorkspace.QE[ 792 ]) ); + +acado_zeroBlockH11( 5, 9 ); +acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 200 ]), &(acadoWorkspace.QE[ 216 ]) ); +acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 256 ]) ); +acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.QE[ 300 ]) ); +acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.QE[ 348 ]) ); +acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 400 ]) ); +acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 456 ]) ); +acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 516 ]) ); +acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QE[ 580 ]) ); +acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 632 ]), &(acadoWorkspace.QE[ 648 ]) ); +acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 704 ]), &(acadoWorkspace.QE[ 720 ]) ); +acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 780 ]), &(acadoWorkspace.QE[ 796 ]) ); + +acado_zeroBlockH11( 5, 10 ); +acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 260 ]) ); +acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.QE[ 304 ]) ); +acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.QE[ 352 ]) ); +acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 404 ]) ); +acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 460 ]) ); +acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 520 ]) ); +acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QE[ 584 ]) ); +acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 632 ]), &(acadoWorkspace.QE[ 652 ]) ); +acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 704 ]), &(acadoWorkspace.QE[ 724 ]) ); +acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 780 ]), &(acadoWorkspace.QE[ 800 ]) ); + +acado_zeroBlockH11( 5, 11 ); +acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.QE[ 308 ]) ); +acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.QE[ 356 ]) ); +acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 408 ]) ); +acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 464 ]) ); +acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 524 ]) ); +acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QE[ 588 ]) ); +acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 632 ]), &(acadoWorkspace.QE[ 656 ]) ); +acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 704 ]), &(acadoWorkspace.QE[ 728 ]) ); +acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 780 ]), &(acadoWorkspace.QE[ 804 ]) ); + +acado_zeroBlockH11( 5, 12 ); +acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.QE[ 360 ]) ); +acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 412 ]) ); +acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 468 ]) ); +acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 528 ]) ); +acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QE[ 592 ]) ); +acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 632 ]), &(acadoWorkspace.QE[ 660 ]) ); +acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 704 ]), &(acadoWorkspace.QE[ 732 ]) ); +acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 780 ]), &(acadoWorkspace.QE[ 808 ]) ); + +acado_zeroBlockH11( 5, 13 ); +acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 416 ]) ); +acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 472 ]) ); +acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 532 ]) ); +acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QE[ 596 ]) ); +acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 632 ]), &(acadoWorkspace.QE[ 664 ]) ); +acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 704 ]), &(acadoWorkspace.QE[ 736 ]) ); +acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 780 ]), &(acadoWorkspace.QE[ 812 ]) ); + +acado_zeroBlockH11( 5, 14 ); +acado_setBlockH11( 5, 14, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 476 ]) ); +acado_setBlockH11( 5, 14, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 536 ]) ); +acado_setBlockH11( 5, 14, &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QE[ 600 ]) ); +acado_setBlockH11( 5, 14, &(acadoWorkspace.E[ 632 ]), &(acadoWorkspace.QE[ 668 ]) ); +acado_setBlockH11( 5, 14, &(acadoWorkspace.E[ 704 ]), &(acadoWorkspace.QE[ 740 ]) ); +acado_setBlockH11( 5, 14, &(acadoWorkspace.E[ 780 ]), &(acadoWorkspace.QE[ 816 ]) ); + +acado_zeroBlockH11( 5, 15 ); +acado_setBlockH11( 5, 15, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 540 ]) ); +acado_setBlockH11( 5, 15, &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QE[ 604 ]) ); +acado_setBlockH11( 5, 15, &(acadoWorkspace.E[ 632 ]), &(acadoWorkspace.QE[ 672 ]) ); +acado_setBlockH11( 5, 15, &(acadoWorkspace.E[ 704 ]), &(acadoWorkspace.QE[ 744 ]) ); +acado_setBlockH11( 5, 15, &(acadoWorkspace.E[ 780 ]), &(acadoWorkspace.QE[ 820 ]) ); + +acado_zeroBlockH11( 5, 16 ); +acado_setBlockH11( 5, 16, &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QE[ 608 ]) ); +acado_setBlockH11( 5, 16, &(acadoWorkspace.E[ 632 ]), &(acadoWorkspace.QE[ 676 ]) ); +acado_setBlockH11( 5, 16, &(acadoWorkspace.E[ 704 ]), &(acadoWorkspace.QE[ 748 ]) ); +acado_setBlockH11( 5, 16, &(acadoWorkspace.E[ 780 ]), &(acadoWorkspace.QE[ 824 ]) ); + +acado_zeroBlockH11( 5, 17 ); +acado_setBlockH11( 5, 17, &(acadoWorkspace.E[ 632 ]), &(acadoWorkspace.QE[ 680 ]) ); +acado_setBlockH11( 5, 17, &(acadoWorkspace.E[ 704 ]), &(acadoWorkspace.QE[ 752 ]) ); +acado_setBlockH11( 5, 17, &(acadoWorkspace.E[ 780 ]), &(acadoWorkspace.QE[ 828 ]) ); + +acado_zeroBlockH11( 5, 18 ); +acado_setBlockH11( 5, 18, &(acadoWorkspace.E[ 704 ]), &(acadoWorkspace.QE[ 756 ]) ); +acado_setBlockH11( 5, 18, &(acadoWorkspace.E[ 780 ]), &(acadoWorkspace.QE[ 832 ]) ); + +acado_zeroBlockH11( 5, 19 ); +acado_setBlockH11( 5, 19, &(acadoWorkspace.E[ 780 ]), &(acadoWorkspace.QE[ 836 ]) ); + +acado_setBlockH11_R1( 6, 6, &(acadoWorkspace.R1[ 6 ]) ); +acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 108 ]) ); +acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 136 ]), &(acadoWorkspace.QE[ 136 ]) ); +acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 168 ]) ); +acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 204 ]) ); +acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 244 ]), &(acadoWorkspace.QE[ 244 ]) ); +acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 288 ]) ); +acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 336 ]) ); +acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.QE[ 388 ]) ); +acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 444 ]) ); +acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 504 ]) ); +acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 568 ]), &(acadoWorkspace.QE[ 568 ]) ); +acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 636 ]), &(acadoWorkspace.QE[ 636 ]) ); +acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 708 ]), &(acadoWorkspace.QE[ 708 ]) ); +acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 784 ]), &(acadoWorkspace.QE[ 784 ]) ); + +acado_zeroBlockH11( 6, 7 ); +acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 136 ]), &(acadoWorkspace.QE[ 140 ]) ); +acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 172 ]) ); +acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 208 ]) ); +acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 244 ]), &(acadoWorkspace.QE[ 248 ]) ); +acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 292 ]) ); +acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 340 ]) ); +acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.QE[ 392 ]) ); +acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 448 ]) ); +acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 508 ]) ); +acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 568 ]), &(acadoWorkspace.QE[ 572 ]) ); +acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 636 ]), &(acadoWorkspace.QE[ 640 ]) ); +acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 708 ]), &(acadoWorkspace.QE[ 712 ]) ); +acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 784 ]), &(acadoWorkspace.QE[ 788 ]) ); + +acado_zeroBlockH11( 6, 8 ); +acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 176 ]) ); +acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 212 ]) ); +acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 244 ]), &(acadoWorkspace.QE[ 252 ]) ); +acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 296 ]) ); +acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 344 ]) ); +acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.QE[ 396 ]) ); +acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 452 ]) ); +acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 512 ]) ); +acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 568 ]), &(acadoWorkspace.QE[ 576 ]) ); +acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 636 ]), &(acadoWorkspace.QE[ 644 ]) ); +acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 708 ]), &(acadoWorkspace.QE[ 716 ]) ); +acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 784 ]), &(acadoWorkspace.QE[ 792 ]) ); + +acado_zeroBlockH11( 6, 9 ); +acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 216 ]) ); +acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 244 ]), &(acadoWorkspace.QE[ 256 ]) ); +acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 300 ]) ); +acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 348 ]) ); +acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.QE[ 400 ]) ); +acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 456 ]) ); +acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 516 ]) ); +acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 568 ]), &(acadoWorkspace.QE[ 580 ]) ); +acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 636 ]), &(acadoWorkspace.QE[ 648 ]) ); +acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 708 ]), &(acadoWorkspace.QE[ 720 ]) ); +acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 784 ]), &(acadoWorkspace.QE[ 796 ]) ); + +acado_zeroBlockH11( 6, 10 ); +acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 244 ]), &(acadoWorkspace.QE[ 260 ]) ); +acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 304 ]) ); +acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 352 ]) ); +acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.QE[ 404 ]) ); +acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 460 ]) ); +acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 520 ]) ); +acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 568 ]), &(acadoWorkspace.QE[ 584 ]) ); +acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 636 ]), &(acadoWorkspace.QE[ 652 ]) ); +acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 708 ]), &(acadoWorkspace.QE[ 724 ]) ); +acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 784 ]), &(acadoWorkspace.QE[ 800 ]) ); + +acado_zeroBlockH11( 6, 11 ); +acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 308 ]) ); +acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 356 ]) ); +acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.QE[ 408 ]) ); +acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 464 ]) ); +acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 524 ]) ); +acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 568 ]), &(acadoWorkspace.QE[ 588 ]) ); +acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 636 ]), &(acadoWorkspace.QE[ 656 ]) ); +acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 708 ]), &(acadoWorkspace.QE[ 728 ]) ); +acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 784 ]), &(acadoWorkspace.QE[ 804 ]) ); + +acado_zeroBlockH11( 6, 12 ); +acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 360 ]) ); +acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.QE[ 412 ]) ); +acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 468 ]) ); +acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 528 ]) ); +acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 568 ]), &(acadoWorkspace.QE[ 592 ]) ); +acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 636 ]), &(acadoWorkspace.QE[ 660 ]) ); +acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 708 ]), &(acadoWorkspace.QE[ 732 ]) ); +acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 784 ]), &(acadoWorkspace.QE[ 808 ]) ); + +acado_zeroBlockH11( 6, 13 ); +acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.QE[ 416 ]) ); +acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 472 ]) ); +acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 532 ]) ); +acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 568 ]), &(acadoWorkspace.QE[ 596 ]) ); +acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 636 ]), &(acadoWorkspace.QE[ 664 ]) ); +acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 708 ]), &(acadoWorkspace.QE[ 736 ]) ); +acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 784 ]), &(acadoWorkspace.QE[ 812 ]) ); + +acado_zeroBlockH11( 6, 14 ); +acado_setBlockH11( 6, 14, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 476 ]) ); +acado_setBlockH11( 6, 14, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 536 ]) ); +acado_setBlockH11( 6, 14, &(acadoWorkspace.E[ 568 ]), &(acadoWorkspace.QE[ 600 ]) ); +acado_setBlockH11( 6, 14, &(acadoWorkspace.E[ 636 ]), &(acadoWorkspace.QE[ 668 ]) ); +acado_setBlockH11( 6, 14, &(acadoWorkspace.E[ 708 ]), &(acadoWorkspace.QE[ 740 ]) ); +acado_setBlockH11( 6, 14, &(acadoWorkspace.E[ 784 ]), &(acadoWorkspace.QE[ 816 ]) ); + +acado_zeroBlockH11( 6, 15 ); +acado_setBlockH11( 6, 15, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 540 ]) ); +acado_setBlockH11( 6, 15, &(acadoWorkspace.E[ 568 ]), &(acadoWorkspace.QE[ 604 ]) ); +acado_setBlockH11( 6, 15, &(acadoWorkspace.E[ 636 ]), &(acadoWorkspace.QE[ 672 ]) ); +acado_setBlockH11( 6, 15, &(acadoWorkspace.E[ 708 ]), &(acadoWorkspace.QE[ 744 ]) ); +acado_setBlockH11( 6, 15, &(acadoWorkspace.E[ 784 ]), &(acadoWorkspace.QE[ 820 ]) ); + +acado_zeroBlockH11( 6, 16 ); +acado_setBlockH11( 6, 16, &(acadoWorkspace.E[ 568 ]), &(acadoWorkspace.QE[ 608 ]) ); +acado_setBlockH11( 6, 16, &(acadoWorkspace.E[ 636 ]), &(acadoWorkspace.QE[ 676 ]) ); +acado_setBlockH11( 6, 16, &(acadoWorkspace.E[ 708 ]), &(acadoWorkspace.QE[ 748 ]) ); +acado_setBlockH11( 6, 16, &(acadoWorkspace.E[ 784 ]), &(acadoWorkspace.QE[ 824 ]) ); + +acado_zeroBlockH11( 6, 17 ); +acado_setBlockH11( 6, 17, &(acadoWorkspace.E[ 636 ]), &(acadoWorkspace.QE[ 680 ]) ); +acado_setBlockH11( 6, 17, &(acadoWorkspace.E[ 708 ]), &(acadoWorkspace.QE[ 752 ]) ); +acado_setBlockH11( 6, 17, &(acadoWorkspace.E[ 784 ]), &(acadoWorkspace.QE[ 828 ]) ); + +acado_zeroBlockH11( 6, 18 ); +acado_setBlockH11( 6, 18, &(acadoWorkspace.E[ 708 ]), &(acadoWorkspace.QE[ 756 ]) ); +acado_setBlockH11( 6, 18, &(acadoWorkspace.E[ 784 ]), &(acadoWorkspace.QE[ 832 ]) ); + +acado_zeroBlockH11( 6, 19 ); +acado_setBlockH11( 6, 19, &(acadoWorkspace.E[ 784 ]), &(acadoWorkspace.QE[ 836 ]) ); + +acado_setBlockH11_R1( 7, 7, &(acadoWorkspace.R1[ 7 ]) ); +acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 140 ]), &(acadoWorkspace.QE[ 140 ]) ); +acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 172 ]), &(acadoWorkspace.QE[ 172 ]) ); +acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 208 ]), &(acadoWorkspace.QE[ 208 ]) ); +acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 248 ]), &(acadoWorkspace.QE[ 248 ]) ); +acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 292 ]), &(acadoWorkspace.QE[ 292 ]) ); +acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 340 ]), &(acadoWorkspace.QE[ 340 ]) ); +acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.QE[ 392 ]) ); +acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.QE[ 448 ]) ); +acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QE[ 508 ]) ); +acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 572 ]), &(acadoWorkspace.QE[ 572 ]) ); +acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 640 ]), &(acadoWorkspace.QE[ 640 ]) ); +acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 712 ]), &(acadoWorkspace.QE[ 712 ]) ); +acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 788 ]), &(acadoWorkspace.QE[ 788 ]) ); + +acado_zeroBlockH11( 7, 8 ); +acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 172 ]), &(acadoWorkspace.QE[ 176 ]) ); +acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 208 ]), &(acadoWorkspace.QE[ 212 ]) ); +acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 248 ]), &(acadoWorkspace.QE[ 252 ]) ); +acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 292 ]), &(acadoWorkspace.QE[ 296 ]) ); +acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 340 ]), &(acadoWorkspace.QE[ 344 ]) ); +acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.QE[ 396 ]) ); +acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.QE[ 452 ]) ); +acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QE[ 512 ]) ); +acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 572 ]), &(acadoWorkspace.QE[ 576 ]) ); +acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 640 ]), &(acadoWorkspace.QE[ 644 ]) ); +acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 712 ]), &(acadoWorkspace.QE[ 716 ]) ); +acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 788 ]), &(acadoWorkspace.QE[ 792 ]) ); + +acado_zeroBlockH11( 7, 9 ); +acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 208 ]), &(acadoWorkspace.QE[ 216 ]) ); +acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 248 ]), &(acadoWorkspace.QE[ 256 ]) ); +acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 292 ]), &(acadoWorkspace.QE[ 300 ]) ); +acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 340 ]), &(acadoWorkspace.QE[ 348 ]) ); +acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.QE[ 400 ]) ); +acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.QE[ 456 ]) ); +acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QE[ 516 ]) ); +acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 572 ]), &(acadoWorkspace.QE[ 580 ]) ); +acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 640 ]), &(acadoWorkspace.QE[ 648 ]) ); +acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 712 ]), &(acadoWorkspace.QE[ 720 ]) ); +acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 788 ]), &(acadoWorkspace.QE[ 796 ]) ); + +acado_zeroBlockH11( 7, 10 ); +acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 248 ]), &(acadoWorkspace.QE[ 260 ]) ); +acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 292 ]), &(acadoWorkspace.QE[ 304 ]) ); +acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 340 ]), &(acadoWorkspace.QE[ 352 ]) ); +acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.QE[ 404 ]) ); +acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.QE[ 460 ]) ); +acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QE[ 520 ]) ); +acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 572 ]), &(acadoWorkspace.QE[ 584 ]) ); +acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 640 ]), &(acadoWorkspace.QE[ 652 ]) ); +acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 712 ]), &(acadoWorkspace.QE[ 724 ]) ); +acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 788 ]), &(acadoWorkspace.QE[ 800 ]) ); + +acado_zeroBlockH11( 7, 11 ); +acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 292 ]), &(acadoWorkspace.QE[ 308 ]) ); +acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 340 ]), &(acadoWorkspace.QE[ 356 ]) ); +acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.QE[ 408 ]) ); +acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.QE[ 464 ]) ); +acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QE[ 524 ]) ); +acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 572 ]), &(acadoWorkspace.QE[ 588 ]) ); +acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 640 ]), &(acadoWorkspace.QE[ 656 ]) ); +acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 712 ]), &(acadoWorkspace.QE[ 728 ]) ); +acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 788 ]), &(acadoWorkspace.QE[ 804 ]) ); + +acado_zeroBlockH11( 7, 12 ); +acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 340 ]), &(acadoWorkspace.QE[ 360 ]) ); +acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.QE[ 412 ]) ); +acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.QE[ 468 ]) ); +acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QE[ 528 ]) ); +acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 572 ]), &(acadoWorkspace.QE[ 592 ]) ); +acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 640 ]), &(acadoWorkspace.QE[ 660 ]) ); +acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 712 ]), &(acadoWorkspace.QE[ 732 ]) ); +acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 788 ]), &(acadoWorkspace.QE[ 808 ]) ); + +acado_zeroBlockH11( 7, 13 ); +acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.QE[ 416 ]) ); +acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.QE[ 472 ]) ); +acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QE[ 532 ]) ); +acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 572 ]), &(acadoWorkspace.QE[ 596 ]) ); +acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 640 ]), &(acadoWorkspace.QE[ 664 ]) ); +acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 712 ]), &(acadoWorkspace.QE[ 736 ]) ); +acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 788 ]), &(acadoWorkspace.QE[ 812 ]) ); + +acado_zeroBlockH11( 7, 14 ); +acado_setBlockH11( 7, 14, &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.QE[ 476 ]) ); +acado_setBlockH11( 7, 14, &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QE[ 536 ]) ); +acado_setBlockH11( 7, 14, &(acadoWorkspace.E[ 572 ]), &(acadoWorkspace.QE[ 600 ]) ); +acado_setBlockH11( 7, 14, &(acadoWorkspace.E[ 640 ]), &(acadoWorkspace.QE[ 668 ]) ); +acado_setBlockH11( 7, 14, &(acadoWorkspace.E[ 712 ]), &(acadoWorkspace.QE[ 740 ]) ); +acado_setBlockH11( 7, 14, &(acadoWorkspace.E[ 788 ]), &(acadoWorkspace.QE[ 816 ]) ); + +acado_zeroBlockH11( 7, 15 ); +acado_setBlockH11( 7, 15, &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QE[ 540 ]) ); +acado_setBlockH11( 7, 15, &(acadoWorkspace.E[ 572 ]), &(acadoWorkspace.QE[ 604 ]) ); +acado_setBlockH11( 7, 15, &(acadoWorkspace.E[ 640 ]), &(acadoWorkspace.QE[ 672 ]) ); +acado_setBlockH11( 7, 15, &(acadoWorkspace.E[ 712 ]), &(acadoWorkspace.QE[ 744 ]) ); +acado_setBlockH11( 7, 15, &(acadoWorkspace.E[ 788 ]), &(acadoWorkspace.QE[ 820 ]) ); + +acado_zeroBlockH11( 7, 16 ); +acado_setBlockH11( 7, 16, &(acadoWorkspace.E[ 572 ]), &(acadoWorkspace.QE[ 608 ]) ); +acado_setBlockH11( 7, 16, &(acadoWorkspace.E[ 640 ]), &(acadoWorkspace.QE[ 676 ]) ); +acado_setBlockH11( 7, 16, &(acadoWorkspace.E[ 712 ]), &(acadoWorkspace.QE[ 748 ]) ); +acado_setBlockH11( 7, 16, &(acadoWorkspace.E[ 788 ]), &(acadoWorkspace.QE[ 824 ]) ); + +acado_zeroBlockH11( 7, 17 ); +acado_setBlockH11( 7, 17, &(acadoWorkspace.E[ 640 ]), &(acadoWorkspace.QE[ 680 ]) ); +acado_setBlockH11( 7, 17, &(acadoWorkspace.E[ 712 ]), &(acadoWorkspace.QE[ 752 ]) ); +acado_setBlockH11( 7, 17, &(acadoWorkspace.E[ 788 ]), &(acadoWorkspace.QE[ 828 ]) ); + +acado_zeroBlockH11( 7, 18 ); +acado_setBlockH11( 7, 18, &(acadoWorkspace.E[ 712 ]), &(acadoWorkspace.QE[ 756 ]) ); +acado_setBlockH11( 7, 18, &(acadoWorkspace.E[ 788 ]), &(acadoWorkspace.QE[ 832 ]) ); + +acado_zeroBlockH11( 7, 19 ); +acado_setBlockH11( 7, 19, &(acadoWorkspace.E[ 788 ]), &(acadoWorkspace.QE[ 836 ]) ); + +acado_setBlockH11_R1( 8, 8, &(acadoWorkspace.R1[ 8 ]) ); +acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 176 ]), &(acadoWorkspace.QE[ 176 ]) ); +acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 212 ]), &(acadoWorkspace.QE[ 212 ]) ); +acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 252 ]) ); +acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 296 ]), &(acadoWorkspace.QE[ 296 ]) ); +acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 344 ]), &(acadoWorkspace.QE[ 344 ]) ); +acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 396 ]) ); +acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.QE[ 452 ]) ); +acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.QE[ 512 ]) ); +acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 576 ]) ); +acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 644 ]), &(acadoWorkspace.QE[ 644 ]) ); +acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 716 ]), &(acadoWorkspace.QE[ 716 ]) ); +acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 792 ]), &(acadoWorkspace.QE[ 792 ]) ); + +acado_zeroBlockH11( 8, 9 ); +acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 212 ]), &(acadoWorkspace.QE[ 216 ]) ); +acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 256 ]) ); +acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 296 ]), &(acadoWorkspace.QE[ 300 ]) ); +acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 344 ]), &(acadoWorkspace.QE[ 348 ]) ); +acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 400 ]) ); +acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.QE[ 456 ]) ); +acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.QE[ 516 ]) ); +acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 580 ]) ); +acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 644 ]), &(acadoWorkspace.QE[ 648 ]) ); +acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 716 ]), &(acadoWorkspace.QE[ 720 ]) ); +acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 792 ]), &(acadoWorkspace.QE[ 796 ]) ); + +acado_zeroBlockH11( 8, 10 ); +acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 260 ]) ); +acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 296 ]), &(acadoWorkspace.QE[ 304 ]) ); +acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 344 ]), &(acadoWorkspace.QE[ 352 ]) ); +acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 404 ]) ); +acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.QE[ 460 ]) ); +acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.QE[ 520 ]) ); +acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 584 ]) ); +acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 644 ]), &(acadoWorkspace.QE[ 652 ]) ); +acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 716 ]), &(acadoWorkspace.QE[ 724 ]) ); +acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 792 ]), &(acadoWorkspace.QE[ 800 ]) ); + +acado_zeroBlockH11( 8, 11 ); +acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 296 ]), &(acadoWorkspace.QE[ 308 ]) ); +acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 344 ]), &(acadoWorkspace.QE[ 356 ]) ); +acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 408 ]) ); +acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.QE[ 464 ]) ); +acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.QE[ 524 ]) ); +acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 588 ]) ); +acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 644 ]), &(acadoWorkspace.QE[ 656 ]) ); +acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 716 ]), &(acadoWorkspace.QE[ 728 ]) ); +acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 792 ]), &(acadoWorkspace.QE[ 804 ]) ); + +acado_zeroBlockH11( 8, 12 ); +acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 344 ]), &(acadoWorkspace.QE[ 360 ]) ); +acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 412 ]) ); +acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.QE[ 468 ]) ); +acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.QE[ 528 ]) ); +acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 592 ]) ); +acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 644 ]), &(acadoWorkspace.QE[ 660 ]) ); +acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 716 ]), &(acadoWorkspace.QE[ 732 ]) ); +acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 792 ]), &(acadoWorkspace.QE[ 808 ]) ); + +acado_zeroBlockH11( 8, 13 ); +acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 416 ]) ); +acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.QE[ 472 ]) ); +acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.QE[ 532 ]) ); +acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 596 ]) ); +acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 644 ]), &(acadoWorkspace.QE[ 664 ]) ); +acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 716 ]), &(acadoWorkspace.QE[ 736 ]) ); +acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 792 ]), &(acadoWorkspace.QE[ 812 ]) ); + +acado_zeroBlockH11( 8, 14 ); +acado_setBlockH11( 8, 14, &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.QE[ 476 ]) ); +acado_setBlockH11( 8, 14, &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.QE[ 536 ]) ); +acado_setBlockH11( 8, 14, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 600 ]) ); +acado_setBlockH11( 8, 14, &(acadoWorkspace.E[ 644 ]), &(acadoWorkspace.QE[ 668 ]) ); +acado_setBlockH11( 8, 14, &(acadoWorkspace.E[ 716 ]), &(acadoWorkspace.QE[ 740 ]) ); +acado_setBlockH11( 8, 14, &(acadoWorkspace.E[ 792 ]), &(acadoWorkspace.QE[ 816 ]) ); + +acado_zeroBlockH11( 8, 15 ); +acado_setBlockH11( 8, 15, &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.QE[ 540 ]) ); +acado_setBlockH11( 8, 15, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 604 ]) ); +acado_setBlockH11( 8, 15, &(acadoWorkspace.E[ 644 ]), &(acadoWorkspace.QE[ 672 ]) ); +acado_setBlockH11( 8, 15, &(acadoWorkspace.E[ 716 ]), &(acadoWorkspace.QE[ 744 ]) ); +acado_setBlockH11( 8, 15, &(acadoWorkspace.E[ 792 ]), &(acadoWorkspace.QE[ 820 ]) ); + +acado_zeroBlockH11( 8, 16 ); +acado_setBlockH11( 8, 16, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 608 ]) ); +acado_setBlockH11( 8, 16, &(acadoWorkspace.E[ 644 ]), &(acadoWorkspace.QE[ 676 ]) ); +acado_setBlockH11( 8, 16, &(acadoWorkspace.E[ 716 ]), &(acadoWorkspace.QE[ 748 ]) ); +acado_setBlockH11( 8, 16, &(acadoWorkspace.E[ 792 ]), &(acadoWorkspace.QE[ 824 ]) ); + +acado_zeroBlockH11( 8, 17 ); +acado_setBlockH11( 8, 17, &(acadoWorkspace.E[ 644 ]), &(acadoWorkspace.QE[ 680 ]) ); +acado_setBlockH11( 8, 17, &(acadoWorkspace.E[ 716 ]), &(acadoWorkspace.QE[ 752 ]) ); +acado_setBlockH11( 8, 17, &(acadoWorkspace.E[ 792 ]), &(acadoWorkspace.QE[ 828 ]) ); + +acado_zeroBlockH11( 8, 18 ); +acado_setBlockH11( 8, 18, &(acadoWorkspace.E[ 716 ]), &(acadoWorkspace.QE[ 756 ]) ); +acado_setBlockH11( 8, 18, &(acadoWorkspace.E[ 792 ]), &(acadoWorkspace.QE[ 832 ]) ); + +acado_zeroBlockH11( 8, 19 ); +acado_setBlockH11( 8, 19, &(acadoWorkspace.E[ 792 ]), &(acadoWorkspace.QE[ 836 ]) ); + +acado_setBlockH11_R1( 9, 9, &(acadoWorkspace.R1[ 9 ]) ); +acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QE[ 216 ]) ); +acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 256 ]), &(acadoWorkspace.QE[ 256 ]) ); +acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QE[ 300 ]) ); +acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QE[ 348 ]) ); +acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 400 ]), &(acadoWorkspace.QE[ 400 ]) ); +acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QE[ 456 ]) ); +acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 516 ]) ); +acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 580 ]), &(acadoWorkspace.QE[ 580 ]) ); +acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 648 ]), &(acadoWorkspace.QE[ 648 ]) ); +acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 720 ]), &(acadoWorkspace.QE[ 720 ]) ); +acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 796 ]), &(acadoWorkspace.QE[ 796 ]) ); + +acado_zeroBlockH11( 9, 10 ); +acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 256 ]), &(acadoWorkspace.QE[ 260 ]) ); +acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QE[ 304 ]) ); +acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QE[ 352 ]) ); +acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 400 ]), &(acadoWorkspace.QE[ 404 ]) ); +acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QE[ 460 ]) ); +acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 520 ]) ); +acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 580 ]), &(acadoWorkspace.QE[ 584 ]) ); +acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 648 ]), &(acadoWorkspace.QE[ 652 ]) ); +acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 720 ]), &(acadoWorkspace.QE[ 724 ]) ); +acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 796 ]), &(acadoWorkspace.QE[ 800 ]) ); + +acado_zeroBlockH11( 9, 11 ); +acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QE[ 308 ]) ); +acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QE[ 356 ]) ); +acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 400 ]), &(acadoWorkspace.QE[ 408 ]) ); +acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QE[ 464 ]) ); +acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 524 ]) ); +acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 580 ]), &(acadoWorkspace.QE[ 588 ]) ); +acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 648 ]), &(acadoWorkspace.QE[ 656 ]) ); +acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 720 ]), &(acadoWorkspace.QE[ 728 ]) ); +acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 796 ]), &(acadoWorkspace.QE[ 804 ]) ); + +acado_zeroBlockH11( 9, 12 ); +acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QE[ 360 ]) ); +acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 400 ]), &(acadoWorkspace.QE[ 412 ]) ); +acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QE[ 468 ]) ); +acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 528 ]) ); +acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 580 ]), &(acadoWorkspace.QE[ 592 ]) ); +acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 648 ]), &(acadoWorkspace.QE[ 660 ]) ); +acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 720 ]), &(acadoWorkspace.QE[ 732 ]) ); +acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 796 ]), &(acadoWorkspace.QE[ 808 ]) ); + +acado_zeroBlockH11( 9, 13 ); +acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 400 ]), &(acadoWorkspace.QE[ 416 ]) ); +acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QE[ 472 ]) ); +acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 532 ]) ); +acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 580 ]), &(acadoWorkspace.QE[ 596 ]) ); +acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 648 ]), &(acadoWorkspace.QE[ 664 ]) ); +acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 720 ]), &(acadoWorkspace.QE[ 736 ]) ); +acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 796 ]), &(acadoWorkspace.QE[ 812 ]) ); + +acado_zeroBlockH11( 9, 14 ); +acado_setBlockH11( 9, 14, &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QE[ 476 ]) ); +acado_setBlockH11( 9, 14, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 536 ]) ); +acado_setBlockH11( 9, 14, &(acadoWorkspace.E[ 580 ]), &(acadoWorkspace.QE[ 600 ]) ); +acado_setBlockH11( 9, 14, &(acadoWorkspace.E[ 648 ]), &(acadoWorkspace.QE[ 668 ]) ); +acado_setBlockH11( 9, 14, &(acadoWorkspace.E[ 720 ]), &(acadoWorkspace.QE[ 740 ]) ); +acado_setBlockH11( 9, 14, &(acadoWorkspace.E[ 796 ]), &(acadoWorkspace.QE[ 816 ]) ); + +acado_zeroBlockH11( 9, 15 ); +acado_setBlockH11( 9, 15, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 540 ]) ); +acado_setBlockH11( 9, 15, &(acadoWorkspace.E[ 580 ]), &(acadoWorkspace.QE[ 604 ]) ); +acado_setBlockH11( 9, 15, &(acadoWorkspace.E[ 648 ]), &(acadoWorkspace.QE[ 672 ]) ); +acado_setBlockH11( 9, 15, &(acadoWorkspace.E[ 720 ]), &(acadoWorkspace.QE[ 744 ]) ); +acado_setBlockH11( 9, 15, &(acadoWorkspace.E[ 796 ]), &(acadoWorkspace.QE[ 820 ]) ); + +acado_zeroBlockH11( 9, 16 ); +acado_setBlockH11( 9, 16, &(acadoWorkspace.E[ 580 ]), &(acadoWorkspace.QE[ 608 ]) ); +acado_setBlockH11( 9, 16, &(acadoWorkspace.E[ 648 ]), &(acadoWorkspace.QE[ 676 ]) ); +acado_setBlockH11( 9, 16, &(acadoWorkspace.E[ 720 ]), &(acadoWorkspace.QE[ 748 ]) ); +acado_setBlockH11( 9, 16, &(acadoWorkspace.E[ 796 ]), &(acadoWorkspace.QE[ 824 ]) ); + +acado_zeroBlockH11( 9, 17 ); +acado_setBlockH11( 9, 17, &(acadoWorkspace.E[ 648 ]), &(acadoWorkspace.QE[ 680 ]) ); +acado_setBlockH11( 9, 17, &(acadoWorkspace.E[ 720 ]), &(acadoWorkspace.QE[ 752 ]) ); +acado_setBlockH11( 9, 17, &(acadoWorkspace.E[ 796 ]), &(acadoWorkspace.QE[ 828 ]) ); + +acado_zeroBlockH11( 9, 18 ); +acado_setBlockH11( 9, 18, &(acadoWorkspace.E[ 720 ]), &(acadoWorkspace.QE[ 756 ]) ); +acado_setBlockH11( 9, 18, &(acadoWorkspace.E[ 796 ]), &(acadoWorkspace.QE[ 832 ]) ); + +acado_zeroBlockH11( 9, 19 ); +acado_setBlockH11( 9, 19, &(acadoWorkspace.E[ 796 ]), &(acadoWorkspace.QE[ 836 ]) ); + +acado_setBlockH11_R1( 10, 10, &(acadoWorkspace.R1[ 10 ]) ); +acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 260 ]), &(acadoWorkspace.QE[ 260 ]) ); +acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 304 ]), &(acadoWorkspace.QE[ 304 ]) ); +acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 352 ]), &(acadoWorkspace.QE[ 352 ]) ); +acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 404 ]), &(acadoWorkspace.QE[ 404 ]) ); +acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 460 ]), &(acadoWorkspace.QE[ 460 ]) ); +acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 520 ]), &(acadoWorkspace.QE[ 520 ]) ); +acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 584 ]), &(acadoWorkspace.QE[ 584 ]) ); +acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 652 ]), &(acadoWorkspace.QE[ 652 ]) ); +acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 724 ]), &(acadoWorkspace.QE[ 724 ]) ); +acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 800 ]), &(acadoWorkspace.QE[ 800 ]) ); + +acado_zeroBlockH11( 10, 11 ); +acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 304 ]), &(acadoWorkspace.QE[ 308 ]) ); +acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 352 ]), &(acadoWorkspace.QE[ 356 ]) ); +acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 404 ]), &(acadoWorkspace.QE[ 408 ]) ); +acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 460 ]), &(acadoWorkspace.QE[ 464 ]) ); +acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 520 ]), &(acadoWorkspace.QE[ 524 ]) ); +acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 584 ]), &(acadoWorkspace.QE[ 588 ]) ); +acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 652 ]), &(acadoWorkspace.QE[ 656 ]) ); +acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 724 ]), &(acadoWorkspace.QE[ 728 ]) ); +acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 800 ]), &(acadoWorkspace.QE[ 804 ]) ); + +acado_zeroBlockH11( 10, 12 ); +acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 352 ]), &(acadoWorkspace.QE[ 360 ]) ); +acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 404 ]), &(acadoWorkspace.QE[ 412 ]) ); +acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 460 ]), &(acadoWorkspace.QE[ 468 ]) ); +acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 520 ]), &(acadoWorkspace.QE[ 528 ]) ); +acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 584 ]), &(acadoWorkspace.QE[ 592 ]) ); +acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 652 ]), &(acadoWorkspace.QE[ 660 ]) ); +acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 724 ]), &(acadoWorkspace.QE[ 732 ]) ); +acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 800 ]), &(acadoWorkspace.QE[ 808 ]) ); + +acado_zeroBlockH11( 10, 13 ); +acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 404 ]), &(acadoWorkspace.QE[ 416 ]) ); +acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 460 ]), &(acadoWorkspace.QE[ 472 ]) ); +acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 520 ]), &(acadoWorkspace.QE[ 532 ]) ); +acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 584 ]), &(acadoWorkspace.QE[ 596 ]) ); +acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 652 ]), &(acadoWorkspace.QE[ 664 ]) ); +acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 724 ]), &(acadoWorkspace.QE[ 736 ]) ); +acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 800 ]), &(acadoWorkspace.QE[ 812 ]) ); + +acado_zeroBlockH11( 10, 14 ); +acado_setBlockH11( 10, 14, &(acadoWorkspace.E[ 460 ]), &(acadoWorkspace.QE[ 476 ]) ); +acado_setBlockH11( 10, 14, &(acadoWorkspace.E[ 520 ]), &(acadoWorkspace.QE[ 536 ]) ); +acado_setBlockH11( 10, 14, &(acadoWorkspace.E[ 584 ]), &(acadoWorkspace.QE[ 600 ]) ); +acado_setBlockH11( 10, 14, &(acadoWorkspace.E[ 652 ]), &(acadoWorkspace.QE[ 668 ]) ); +acado_setBlockH11( 10, 14, &(acadoWorkspace.E[ 724 ]), &(acadoWorkspace.QE[ 740 ]) ); +acado_setBlockH11( 10, 14, &(acadoWorkspace.E[ 800 ]), &(acadoWorkspace.QE[ 816 ]) ); + +acado_zeroBlockH11( 10, 15 ); +acado_setBlockH11( 10, 15, &(acadoWorkspace.E[ 520 ]), &(acadoWorkspace.QE[ 540 ]) ); +acado_setBlockH11( 10, 15, &(acadoWorkspace.E[ 584 ]), &(acadoWorkspace.QE[ 604 ]) ); +acado_setBlockH11( 10, 15, &(acadoWorkspace.E[ 652 ]), &(acadoWorkspace.QE[ 672 ]) ); +acado_setBlockH11( 10, 15, &(acadoWorkspace.E[ 724 ]), &(acadoWorkspace.QE[ 744 ]) ); +acado_setBlockH11( 10, 15, &(acadoWorkspace.E[ 800 ]), &(acadoWorkspace.QE[ 820 ]) ); + +acado_zeroBlockH11( 10, 16 ); +acado_setBlockH11( 10, 16, &(acadoWorkspace.E[ 584 ]), &(acadoWorkspace.QE[ 608 ]) ); +acado_setBlockH11( 10, 16, &(acadoWorkspace.E[ 652 ]), &(acadoWorkspace.QE[ 676 ]) ); +acado_setBlockH11( 10, 16, &(acadoWorkspace.E[ 724 ]), &(acadoWorkspace.QE[ 748 ]) ); +acado_setBlockH11( 10, 16, &(acadoWorkspace.E[ 800 ]), &(acadoWorkspace.QE[ 824 ]) ); + +acado_zeroBlockH11( 10, 17 ); +acado_setBlockH11( 10, 17, &(acadoWorkspace.E[ 652 ]), &(acadoWorkspace.QE[ 680 ]) ); +acado_setBlockH11( 10, 17, &(acadoWorkspace.E[ 724 ]), &(acadoWorkspace.QE[ 752 ]) ); +acado_setBlockH11( 10, 17, &(acadoWorkspace.E[ 800 ]), &(acadoWorkspace.QE[ 828 ]) ); + +acado_zeroBlockH11( 10, 18 ); +acado_setBlockH11( 10, 18, &(acadoWorkspace.E[ 724 ]), &(acadoWorkspace.QE[ 756 ]) ); +acado_setBlockH11( 10, 18, &(acadoWorkspace.E[ 800 ]), &(acadoWorkspace.QE[ 832 ]) ); + +acado_zeroBlockH11( 10, 19 ); +acado_setBlockH11( 10, 19, &(acadoWorkspace.E[ 800 ]), &(acadoWorkspace.QE[ 836 ]) ); + +acado_setBlockH11_R1( 11, 11, &(acadoWorkspace.R1[ 11 ]) ); +acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 308 ]), &(acadoWorkspace.QE[ 308 ]) ); +acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 356 ]), &(acadoWorkspace.QE[ 356 ]) ); +acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 408 ]) ); +acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 464 ]), &(acadoWorkspace.QE[ 464 ]) ); +acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 524 ]), &(acadoWorkspace.QE[ 524 ]) ); +acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 588 ]) ); +acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 656 ]), &(acadoWorkspace.QE[ 656 ]) ); +acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 728 ]), &(acadoWorkspace.QE[ 728 ]) ); +acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 804 ]), &(acadoWorkspace.QE[ 804 ]) ); + +acado_zeroBlockH11( 11, 12 ); +acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 356 ]), &(acadoWorkspace.QE[ 360 ]) ); +acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 412 ]) ); +acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 464 ]), &(acadoWorkspace.QE[ 468 ]) ); +acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 524 ]), &(acadoWorkspace.QE[ 528 ]) ); +acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 592 ]) ); +acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 656 ]), &(acadoWorkspace.QE[ 660 ]) ); +acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 728 ]), &(acadoWorkspace.QE[ 732 ]) ); +acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 804 ]), &(acadoWorkspace.QE[ 808 ]) ); + +acado_zeroBlockH11( 11, 13 ); +acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 416 ]) ); +acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 464 ]), &(acadoWorkspace.QE[ 472 ]) ); +acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 524 ]), &(acadoWorkspace.QE[ 532 ]) ); +acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 596 ]) ); +acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 656 ]), &(acadoWorkspace.QE[ 664 ]) ); +acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 728 ]), &(acadoWorkspace.QE[ 736 ]) ); +acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 804 ]), &(acadoWorkspace.QE[ 812 ]) ); + +acado_zeroBlockH11( 11, 14 ); +acado_setBlockH11( 11, 14, &(acadoWorkspace.E[ 464 ]), &(acadoWorkspace.QE[ 476 ]) ); +acado_setBlockH11( 11, 14, &(acadoWorkspace.E[ 524 ]), &(acadoWorkspace.QE[ 536 ]) ); +acado_setBlockH11( 11, 14, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 600 ]) ); +acado_setBlockH11( 11, 14, &(acadoWorkspace.E[ 656 ]), &(acadoWorkspace.QE[ 668 ]) ); +acado_setBlockH11( 11, 14, &(acadoWorkspace.E[ 728 ]), &(acadoWorkspace.QE[ 740 ]) ); +acado_setBlockH11( 11, 14, &(acadoWorkspace.E[ 804 ]), &(acadoWorkspace.QE[ 816 ]) ); + +acado_zeroBlockH11( 11, 15 ); +acado_setBlockH11( 11, 15, &(acadoWorkspace.E[ 524 ]), &(acadoWorkspace.QE[ 540 ]) ); +acado_setBlockH11( 11, 15, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 604 ]) ); +acado_setBlockH11( 11, 15, &(acadoWorkspace.E[ 656 ]), &(acadoWorkspace.QE[ 672 ]) ); +acado_setBlockH11( 11, 15, &(acadoWorkspace.E[ 728 ]), &(acadoWorkspace.QE[ 744 ]) ); +acado_setBlockH11( 11, 15, &(acadoWorkspace.E[ 804 ]), &(acadoWorkspace.QE[ 820 ]) ); + +acado_zeroBlockH11( 11, 16 ); +acado_setBlockH11( 11, 16, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 608 ]) ); +acado_setBlockH11( 11, 16, &(acadoWorkspace.E[ 656 ]), &(acadoWorkspace.QE[ 676 ]) ); +acado_setBlockH11( 11, 16, &(acadoWorkspace.E[ 728 ]), &(acadoWorkspace.QE[ 748 ]) ); +acado_setBlockH11( 11, 16, &(acadoWorkspace.E[ 804 ]), &(acadoWorkspace.QE[ 824 ]) ); + +acado_zeroBlockH11( 11, 17 ); +acado_setBlockH11( 11, 17, &(acadoWorkspace.E[ 656 ]), &(acadoWorkspace.QE[ 680 ]) ); +acado_setBlockH11( 11, 17, &(acadoWorkspace.E[ 728 ]), &(acadoWorkspace.QE[ 752 ]) ); +acado_setBlockH11( 11, 17, &(acadoWorkspace.E[ 804 ]), &(acadoWorkspace.QE[ 828 ]) ); + +acado_zeroBlockH11( 11, 18 ); +acado_setBlockH11( 11, 18, &(acadoWorkspace.E[ 728 ]), &(acadoWorkspace.QE[ 756 ]) ); +acado_setBlockH11( 11, 18, &(acadoWorkspace.E[ 804 ]), &(acadoWorkspace.QE[ 832 ]) ); + +acado_zeroBlockH11( 11, 19 ); +acado_setBlockH11( 11, 19, &(acadoWorkspace.E[ 804 ]), &(acadoWorkspace.QE[ 836 ]) ); + +acado_setBlockH11_R1( 12, 12, &(acadoWorkspace.R1[ 12 ]) ); +acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 360 ]) ); +acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 412 ]), &(acadoWorkspace.QE[ 412 ]) ); +acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 468 ]) ); +acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 528 ]) ); +acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 592 ]), &(acadoWorkspace.QE[ 592 ]) ); +acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 660 ]), &(acadoWorkspace.QE[ 660 ]) ); +acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 732 ]), &(acadoWorkspace.QE[ 732 ]) ); +acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 808 ]), &(acadoWorkspace.QE[ 808 ]) ); + +acado_zeroBlockH11( 12, 13 ); +acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 412 ]), &(acadoWorkspace.QE[ 416 ]) ); +acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 472 ]) ); +acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 532 ]) ); +acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 592 ]), &(acadoWorkspace.QE[ 596 ]) ); +acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 660 ]), &(acadoWorkspace.QE[ 664 ]) ); +acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 732 ]), &(acadoWorkspace.QE[ 736 ]) ); +acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 808 ]), &(acadoWorkspace.QE[ 812 ]) ); + +acado_zeroBlockH11( 12, 14 ); +acado_setBlockH11( 12, 14, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 476 ]) ); +acado_setBlockH11( 12, 14, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 536 ]) ); +acado_setBlockH11( 12, 14, &(acadoWorkspace.E[ 592 ]), &(acadoWorkspace.QE[ 600 ]) ); +acado_setBlockH11( 12, 14, &(acadoWorkspace.E[ 660 ]), &(acadoWorkspace.QE[ 668 ]) ); +acado_setBlockH11( 12, 14, &(acadoWorkspace.E[ 732 ]), &(acadoWorkspace.QE[ 740 ]) ); +acado_setBlockH11( 12, 14, &(acadoWorkspace.E[ 808 ]), &(acadoWorkspace.QE[ 816 ]) ); + +acado_zeroBlockH11( 12, 15 ); +acado_setBlockH11( 12, 15, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 540 ]) ); +acado_setBlockH11( 12, 15, &(acadoWorkspace.E[ 592 ]), &(acadoWorkspace.QE[ 604 ]) ); +acado_setBlockH11( 12, 15, &(acadoWorkspace.E[ 660 ]), &(acadoWorkspace.QE[ 672 ]) ); +acado_setBlockH11( 12, 15, &(acadoWorkspace.E[ 732 ]), &(acadoWorkspace.QE[ 744 ]) ); +acado_setBlockH11( 12, 15, &(acadoWorkspace.E[ 808 ]), &(acadoWorkspace.QE[ 820 ]) ); + +acado_zeroBlockH11( 12, 16 ); +acado_setBlockH11( 12, 16, &(acadoWorkspace.E[ 592 ]), &(acadoWorkspace.QE[ 608 ]) ); +acado_setBlockH11( 12, 16, &(acadoWorkspace.E[ 660 ]), &(acadoWorkspace.QE[ 676 ]) ); +acado_setBlockH11( 12, 16, &(acadoWorkspace.E[ 732 ]), &(acadoWorkspace.QE[ 748 ]) ); +acado_setBlockH11( 12, 16, &(acadoWorkspace.E[ 808 ]), &(acadoWorkspace.QE[ 824 ]) ); + +acado_zeroBlockH11( 12, 17 ); +acado_setBlockH11( 12, 17, &(acadoWorkspace.E[ 660 ]), &(acadoWorkspace.QE[ 680 ]) ); +acado_setBlockH11( 12, 17, &(acadoWorkspace.E[ 732 ]), &(acadoWorkspace.QE[ 752 ]) ); +acado_setBlockH11( 12, 17, &(acadoWorkspace.E[ 808 ]), &(acadoWorkspace.QE[ 828 ]) ); + +acado_zeroBlockH11( 12, 18 ); +acado_setBlockH11( 12, 18, &(acadoWorkspace.E[ 732 ]), &(acadoWorkspace.QE[ 756 ]) ); +acado_setBlockH11( 12, 18, &(acadoWorkspace.E[ 808 ]), &(acadoWorkspace.QE[ 832 ]) ); + +acado_zeroBlockH11( 12, 19 ); +acado_setBlockH11( 12, 19, &(acadoWorkspace.E[ 808 ]), &(acadoWorkspace.QE[ 836 ]) ); + +acado_setBlockH11_R1( 13, 13, &(acadoWorkspace.R1[ 13 ]) ); +acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 416 ]), &(acadoWorkspace.QE[ 416 ]) ); +acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 472 ]), &(acadoWorkspace.QE[ 472 ]) ); +acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 532 ]), &(acadoWorkspace.QE[ 532 ]) ); +acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 596 ]), &(acadoWorkspace.QE[ 596 ]) ); +acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 664 ]), &(acadoWorkspace.QE[ 664 ]) ); +acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 736 ]), &(acadoWorkspace.QE[ 736 ]) ); +acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 812 ]), &(acadoWorkspace.QE[ 812 ]) ); + +acado_zeroBlockH11( 13, 14 ); +acado_setBlockH11( 13, 14, &(acadoWorkspace.E[ 472 ]), &(acadoWorkspace.QE[ 476 ]) ); +acado_setBlockH11( 13, 14, &(acadoWorkspace.E[ 532 ]), &(acadoWorkspace.QE[ 536 ]) ); +acado_setBlockH11( 13, 14, &(acadoWorkspace.E[ 596 ]), &(acadoWorkspace.QE[ 600 ]) ); +acado_setBlockH11( 13, 14, &(acadoWorkspace.E[ 664 ]), &(acadoWorkspace.QE[ 668 ]) ); +acado_setBlockH11( 13, 14, &(acadoWorkspace.E[ 736 ]), &(acadoWorkspace.QE[ 740 ]) ); +acado_setBlockH11( 13, 14, &(acadoWorkspace.E[ 812 ]), &(acadoWorkspace.QE[ 816 ]) ); + +acado_zeroBlockH11( 13, 15 ); +acado_setBlockH11( 13, 15, &(acadoWorkspace.E[ 532 ]), &(acadoWorkspace.QE[ 540 ]) ); +acado_setBlockH11( 13, 15, &(acadoWorkspace.E[ 596 ]), &(acadoWorkspace.QE[ 604 ]) ); +acado_setBlockH11( 13, 15, &(acadoWorkspace.E[ 664 ]), &(acadoWorkspace.QE[ 672 ]) ); +acado_setBlockH11( 13, 15, &(acadoWorkspace.E[ 736 ]), &(acadoWorkspace.QE[ 744 ]) ); +acado_setBlockH11( 13, 15, &(acadoWorkspace.E[ 812 ]), &(acadoWorkspace.QE[ 820 ]) ); + +acado_zeroBlockH11( 13, 16 ); +acado_setBlockH11( 13, 16, &(acadoWorkspace.E[ 596 ]), &(acadoWorkspace.QE[ 608 ]) ); +acado_setBlockH11( 13, 16, &(acadoWorkspace.E[ 664 ]), &(acadoWorkspace.QE[ 676 ]) ); +acado_setBlockH11( 13, 16, &(acadoWorkspace.E[ 736 ]), &(acadoWorkspace.QE[ 748 ]) ); +acado_setBlockH11( 13, 16, &(acadoWorkspace.E[ 812 ]), &(acadoWorkspace.QE[ 824 ]) ); + +acado_zeroBlockH11( 13, 17 ); +acado_setBlockH11( 13, 17, &(acadoWorkspace.E[ 664 ]), &(acadoWorkspace.QE[ 680 ]) ); +acado_setBlockH11( 13, 17, &(acadoWorkspace.E[ 736 ]), &(acadoWorkspace.QE[ 752 ]) ); +acado_setBlockH11( 13, 17, &(acadoWorkspace.E[ 812 ]), &(acadoWorkspace.QE[ 828 ]) ); + +acado_zeroBlockH11( 13, 18 ); +acado_setBlockH11( 13, 18, &(acadoWorkspace.E[ 736 ]), &(acadoWorkspace.QE[ 756 ]) ); +acado_setBlockH11( 13, 18, &(acadoWorkspace.E[ 812 ]), &(acadoWorkspace.QE[ 832 ]) ); + +acado_zeroBlockH11( 13, 19 ); +acado_setBlockH11( 13, 19, &(acadoWorkspace.E[ 812 ]), &(acadoWorkspace.QE[ 836 ]) ); + +acado_setBlockH11_R1( 14, 14, &(acadoWorkspace.R1[ 14 ]) ); +acado_setBlockH11( 14, 14, &(acadoWorkspace.E[ 476 ]), &(acadoWorkspace.QE[ 476 ]) ); +acado_setBlockH11( 14, 14, &(acadoWorkspace.E[ 536 ]), &(acadoWorkspace.QE[ 536 ]) ); +acado_setBlockH11( 14, 14, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 600 ]) ); +acado_setBlockH11( 14, 14, &(acadoWorkspace.E[ 668 ]), &(acadoWorkspace.QE[ 668 ]) ); +acado_setBlockH11( 14, 14, &(acadoWorkspace.E[ 740 ]), &(acadoWorkspace.QE[ 740 ]) ); +acado_setBlockH11( 14, 14, &(acadoWorkspace.E[ 816 ]), &(acadoWorkspace.QE[ 816 ]) ); + +acado_zeroBlockH11( 14, 15 ); +acado_setBlockH11( 14, 15, &(acadoWorkspace.E[ 536 ]), &(acadoWorkspace.QE[ 540 ]) ); +acado_setBlockH11( 14, 15, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 604 ]) ); +acado_setBlockH11( 14, 15, &(acadoWorkspace.E[ 668 ]), &(acadoWorkspace.QE[ 672 ]) ); +acado_setBlockH11( 14, 15, &(acadoWorkspace.E[ 740 ]), &(acadoWorkspace.QE[ 744 ]) ); +acado_setBlockH11( 14, 15, &(acadoWorkspace.E[ 816 ]), &(acadoWorkspace.QE[ 820 ]) ); + +acado_zeroBlockH11( 14, 16 ); +acado_setBlockH11( 14, 16, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 608 ]) ); +acado_setBlockH11( 14, 16, &(acadoWorkspace.E[ 668 ]), &(acadoWorkspace.QE[ 676 ]) ); +acado_setBlockH11( 14, 16, &(acadoWorkspace.E[ 740 ]), &(acadoWorkspace.QE[ 748 ]) ); +acado_setBlockH11( 14, 16, &(acadoWorkspace.E[ 816 ]), &(acadoWorkspace.QE[ 824 ]) ); + +acado_zeroBlockH11( 14, 17 ); +acado_setBlockH11( 14, 17, &(acadoWorkspace.E[ 668 ]), &(acadoWorkspace.QE[ 680 ]) ); +acado_setBlockH11( 14, 17, &(acadoWorkspace.E[ 740 ]), &(acadoWorkspace.QE[ 752 ]) ); +acado_setBlockH11( 14, 17, &(acadoWorkspace.E[ 816 ]), &(acadoWorkspace.QE[ 828 ]) ); + +acado_zeroBlockH11( 14, 18 ); +acado_setBlockH11( 14, 18, &(acadoWorkspace.E[ 740 ]), &(acadoWorkspace.QE[ 756 ]) ); +acado_setBlockH11( 14, 18, &(acadoWorkspace.E[ 816 ]), &(acadoWorkspace.QE[ 832 ]) ); + +acado_zeroBlockH11( 14, 19 ); +acado_setBlockH11( 14, 19, &(acadoWorkspace.E[ 816 ]), &(acadoWorkspace.QE[ 836 ]) ); + +acado_setBlockH11_R1( 15, 15, &(acadoWorkspace.R1[ 15 ]) ); +acado_setBlockH11( 15, 15, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 540 ]) ); +acado_setBlockH11( 15, 15, &(acadoWorkspace.E[ 604 ]), &(acadoWorkspace.QE[ 604 ]) ); +acado_setBlockH11( 15, 15, &(acadoWorkspace.E[ 672 ]), &(acadoWorkspace.QE[ 672 ]) ); +acado_setBlockH11( 15, 15, &(acadoWorkspace.E[ 744 ]), &(acadoWorkspace.QE[ 744 ]) ); +acado_setBlockH11( 15, 15, &(acadoWorkspace.E[ 820 ]), &(acadoWorkspace.QE[ 820 ]) ); + +acado_zeroBlockH11( 15, 16 ); +acado_setBlockH11( 15, 16, &(acadoWorkspace.E[ 604 ]), &(acadoWorkspace.QE[ 608 ]) ); +acado_setBlockH11( 15, 16, &(acadoWorkspace.E[ 672 ]), &(acadoWorkspace.QE[ 676 ]) ); +acado_setBlockH11( 15, 16, &(acadoWorkspace.E[ 744 ]), &(acadoWorkspace.QE[ 748 ]) ); +acado_setBlockH11( 15, 16, &(acadoWorkspace.E[ 820 ]), &(acadoWorkspace.QE[ 824 ]) ); + +acado_zeroBlockH11( 15, 17 ); +acado_setBlockH11( 15, 17, &(acadoWorkspace.E[ 672 ]), &(acadoWorkspace.QE[ 680 ]) ); +acado_setBlockH11( 15, 17, &(acadoWorkspace.E[ 744 ]), &(acadoWorkspace.QE[ 752 ]) ); +acado_setBlockH11( 15, 17, &(acadoWorkspace.E[ 820 ]), &(acadoWorkspace.QE[ 828 ]) ); + +acado_zeroBlockH11( 15, 18 ); +acado_setBlockH11( 15, 18, &(acadoWorkspace.E[ 744 ]), &(acadoWorkspace.QE[ 756 ]) ); +acado_setBlockH11( 15, 18, &(acadoWorkspace.E[ 820 ]), &(acadoWorkspace.QE[ 832 ]) ); + +acado_zeroBlockH11( 15, 19 ); +acado_setBlockH11( 15, 19, &(acadoWorkspace.E[ 820 ]), &(acadoWorkspace.QE[ 836 ]) ); + +acado_setBlockH11_R1( 16, 16, &(acadoWorkspace.R1[ 16 ]) ); +acado_setBlockH11( 16, 16, &(acadoWorkspace.E[ 608 ]), &(acadoWorkspace.QE[ 608 ]) ); +acado_setBlockH11( 16, 16, &(acadoWorkspace.E[ 676 ]), &(acadoWorkspace.QE[ 676 ]) ); +acado_setBlockH11( 16, 16, &(acadoWorkspace.E[ 748 ]), &(acadoWorkspace.QE[ 748 ]) ); +acado_setBlockH11( 16, 16, &(acadoWorkspace.E[ 824 ]), &(acadoWorkspace.QE[ 824 ]) ); + +acado_zeroBlockH11( 16, 17 ); +acado_setBlockH11( 16, 17, &(acadoWorkspace.E[ 676 ]), &(acadoWorkspace.QE[ 680 ]) ); +acado_setBlockH11( 16, 17, &(acadoWorkspace.E[ 748 ]), &(acadoWorkspace.QE[ 752 ]) ); +acado_setBlockH11( 16, 17, &(acadoWorkspace.E[ 824 ]), &(acadoWorkspace.QE[ 828 ]) ); + +acado_zeroBlockH11( 16, 18 ); +acado_setBlockH11( 16, 18, &(acadoWorkspace.E[ 748 ]), &(acadoWorkspace.QE[ 756 ]) ); +acado_setBlockH11( 16, 18, &(acadoWorkspace.E[ 824 ]), &(acadoWorkspace.QE[ 832 ]) ); + +acado_zeroBlockH11( 16, 19 ); +acado_setBlockH11( 16, 19, &(acadoWorkspace.E[ 824 ]), &(acadoWorkspace.QE[ 836 ]) ); + +acado_setBlockH11_R1( 17, 17, &(acadoWorkspace.R1[ 17 ]) ); +acado_setBlockH11( 17, 17, &(acadoWorkspace.E[ 680 ]), &(acadoWorkspace.QE[ 680 ]) ); +acado_setBlockH11( 17, 17, &(acadoWorkspace.E[ 752 ]), &(acadoWorkspace.QE[ 752 ]) ); +acado_setBlockH11( 17, 17, &(acadoWorkspace.E[ 828 ]), &(acadoWorkspace.QE[ 828 ]) ); + +acado_zeroBlockH11( 17, 18 ); +acado_setBlockH11( 17, 18, &(acadoWorkspace.E[ 752 ]), &(acadoWorkspace.QE[ 756 ]) ); +acado_setBlockH11( 17, 18, &(acadoWorkspace.E[ 828 ]), &(acadoWorkspace.QE[ 832 ]) ); + +acado_zeroBlockH11( 17, 19 ); +acado_setBlockH11( 17, 19, &(acadoWorkspace.E[ 828 ]), &(acadoWorkspace.QE[ 836 ]) ); + +acado_setBlockH11_R1( 18, 18, &(acadoWorkspace.R1[ 18 ]) ); +acado_setBlockH11( 18, 18, &(acadoWorkspace.E[ 756 ]), &(acadoWorkspace.QE[ 756 ]) ); +acado_setBlockH11( 18, 18, &(acadoWorkspace.E[ 832 ]), &(acadoWorkspace.QE[ 832 ]) ); + +acado_zeroBlockH11( 18, 19 ); +acado_setBlockH11( 18, 19, &(acadoWorkspace.E[ 832 ]), &(acadoWorkspace.QE[ 836 ]) ); + +acado_setBlockH11_R1( 19, 19, &(acadoWorkspace.R1[ 19 ]) ); +acado_setBlockH11( 19, 19, &(acadoWorkspace.E[ 836 ]), &(acadoWorkspace.QE[ 836 ]) ); + + +acado_copyHTH( 1, 0 ); +acado_copyHTH( 2, 0 ); +acado_copyHTH( 2, 1 ); +acado_copyHTH( 3, 0 ); +acado_copyHTH( 3, 1 ); +acado_copyHTH( 3, 2 ); +acado_copyHTH( 4, 0 ); +acado_copyHTH( 4, 1 ); +acado_copyHTH( 4, 2 ); +acado_copyHTH( 4, 3 ); +acado_copyHTH( 5, 0 ); +acado_copyHTH( 5, 1 ); +acado_copyHTH( 5, 2 ); +acado_copyHTH( 5, 3 ); +acado_copyHTH( 5, 4 ); +acado_copyHTH( 6, 0 ); +acado_copyHTH( 6, 1 ); +acado_copyHTH( 6, 2 ); +acado_copyHTH( 6, 3 ); +acado_copyHTH( 6, 4 ); +acado_copyHTH( 6, 5 ); +acado_copyHTH( 7, 0 ); +acado_copyHTH( 7, 1 ); +acado_copyHTH( 7, 2 ); +acado_copyHTH( 7, 3 ); +acado_copyHTH( 7, 4 ); +acado_copyHTH( 7, 5 ); +acado_copyHTH( 7, 6 ); +acado_copyHTH( 8, 0 ); +acado_copyHTH( 8, 1 ); +acado_copyHTH( 8, 2 ); +acado_copyHTH( 8, 3 ); +acado_copyHTH( 8, 4 ); +acado_copyHTH( 8, 5 ); +acado_copyHTH( 8, 6 ); +acado_copyHTH( 8, 7 ); +acado_copyHTH( 9, 0 ); +acado_copyHTH( 9, 1 ); +acado_copyHTH( 9, 2 ); +acado_copyHTH( 9, 3 ); +acado_copyHTH( 9, 4 ); +acado_copyHTH( 9, 5 ); +acado_copyHTH( 9, 6 ); +acado_copyHTH( 9, 7 ); +acado_copyHTH( 9, 8 ); +acado_copyHTH( 10, 0 ); +acado_copyHTH( 10, 1 ); +acado_copyHTH( 10, 2 ); +acado_copyHTH( 10, 3 ); +acado_copyHTH( 10, 4 ); +acado_copyHTH( 10, 5 ); +acado_copyHTH( 10, 6 ); +acado_copyHTH( 10, 7 ); +acado_copyHTH( 10, 8 ); +acado_copyHTH( 10, 9 ); +acado_copyHTH( 11, 0 ); +acado_copyHTH( 11, 1 ); +acado_copyHTH( 11, 2 ); +acado_copyHTH( 11, 3 ); +acado_copyHTH( 11, 4 ); +acado_copyHTH( 11, 5 ); +acado_copyHTH( 11, 6 ); +acado_copyHTH( 11, 7 ); +acado_copyHTH( 11, 8 ); +acado_copyHTH( 11, 9 ); +acado_copyHTH( 11, 10 ); +acado_copyHTH( 12, 0 ); +acado_copyHTH( 12, 1 ); +acado_copyHTH( 12, 2 ); +acado_copyHTH( 12, 3 ); +acado_copyHTH( 12, 4 ); +acado_copyHTH( 12, 5 ); +acado_copyHTH( 12, 6 ); +acado_copyHTH( 12, 7 ); +acado_copyHTH( 12, 8 ); +acado_copyHTH( 12, 9 ); +acado_copyHTH( 12, 10 ); +acado_copyHTH( 12, 11 ); +acado_copyHTH( 13, 0 ); +acado_copyHTH( 13, 1 ); +acado_copyHTH( 13, 2 ); +acado_copyHTH( 13, 3 ); +acado_copyHTH( 13, 4 ); +acado_copyHTH( 13, 5 ); +acado_copyHTH( 13, 6 ); +acado_copyHTH( 13, 7 ); +acado_copyHTH( 13, 8 ); +acado_copyHTH( 13, 9 ); +acado_copyHTH( 13, 10 ); +acado_copyHTH( 13, 11 ); +acado_copyHTH( 13, 12 ); +acado_copyHTH( 14, 0 ); +acado_copyHTH( 14, 1 ); +acado_copyHTH( 14, 2 ); +acado_copyHTH( 14, 3 ); +acado_copyHTH( 14, 4 ); +acado_copyHTH( 14, 5 ); +acado_copyHTH( 14, 6 ); +acado_copyHTH( 14, 7 ); +acado_copyHTH( 14, 8 ); +acado_copyHTH( 14, 9 ); +acado_copyHTH( 14, 10 ); +acado_copyHTH( 14, 11 ); +acado_copyHTH( 14, 12 ); +acado_copyHTH( 14, 13 ); +acado_copyHTH( 15, 0 ); +acado_copyHTH( 15, 1 ); +acado_copyHTH( 15, 2 ); +acado_copyHTH( 15, 3 ); +acado_copyHTH( 15, 4 ); +acado_copyHTH( 15, 5 ); +acado_copyHTH( 15, 6 ); +acado_copyHTH( 15, 7 ); +acado_copyHTH( 15, 8 ); +acado_copyHTH( 15, 9 ); +acado_copyHTH( 15, 10 ); +acado_copyHTH( 15, 11 ); +acado_copyHTH( 15, 12 ); +acado_copyHTH( 15, 13 ); +acado_copyHTH( 15, 14 ); +acado_copyHTH( 16, 0 ); +acado_copyHTH( 16, 1 ); +acado_copyHTH( 16, 2 ); +acado_copyHTH( 16, 3 ); +acado_copyHTH( 16, 4 ); +acado_copyHTH( 16, 5 ); +acado_copyHTH( 16, 6 ); +acado_copyHTH( 16, 7 ); +acado_copyHTH( 16, 8 ); +acado_copyHTH( 16, 9 ); +acado_copyHTH( 16, 10 ); +acado_copyHTH( 16, 11 ); +acado_copyHTH( 16, 12 ); +acado_copyHTH( 16, 13 ); +acado_copyHTH( 16, 14 ); +acado_copyHTH( 16, 15 ); +acado_copyHTH( 17, 0 ); +acado_copyHTH( 17, 1 ); +acado_copyHTH( 17, 2 ); +acado_copyHTH( 17, 3 ); +acado_copyHTH( 17, 4 ); +acado_copyHTH( 17, 5 ); +acado_copyHTH( 17, 6 ); +acado_copyHTH( 17, 7 ); +acado_copyHTH( 17, 8 ); +acado_copyHTH( 17, 9 ); +acado_copyHTH( 17, 10 ); +acado_copyHTH( 17, 11 ); +acado_copyHTH( 17, 12 ); +acado_copyHTH( 17, 13 ); +acado_copyHTH( 17, 14 ); +acado_copyHTH( 17, 15 ); +acado_copyHTH( 17, 16 ); +acado_copyHTH( 18, 0 ); +acado_copyHTH( 18, 1 ); +acado_copyHTH( 18, 2 ); +acado_copyHTH( 18, 3 ); +acado_copyHTH( 18, 4 ); +acado_copyHTH( 18, 5 ); +acado_copyHTH( 18, 6 ); +acado_copyHTH( 18, 7 ); +acado_copyHTH( 18, 8 ); +acado_copyHTH( 18, 9 ); +acado_copyHTH( 18, 10 ); +acado_copyHTH( 18, 11 ); +acado_copyHTH( 18, 12 ); +acado_copyHTH( 18, 13 ); +acado_copyHTH( 18, 14 ); +acado_copyHTH( 18, 15 ); +acado_copyHTH( 18, 16 ); +acado_copyHTH( 18, 17 ); +acado_copyHTH( 19, 0 ); +acado_copyHTH( 19, 1 ); +acado_copyHTH( 19, 2 ); +acado_copyHTH( 19, 3 ); +acado_copyHTH( 19, 4 ); +acado_copyHTH( 19, 5 ); +acado_copyHTH( 19, 6 ); +acado_copyHTH( 19, 7 ); +acado_copyHTH( 19, 8 ); +acado_copyHTH( 19, 9 ); +acado_copyHTH( 19, 10 ); +acado_copyHTH( 19, 11 ); +acado_copyHTH( 19, 12 ); +acado_copyHTH( 19, 13 ); +acado_copyHTH( 19, 14 ); +acado_copyHTH( 19, 15 ); +acado_copyHTH( 19, 16 ); +acado_copyHTH( 19, 17 ); +acado_copyHTH( 19, 18 ); + +acadoWorkspace.H[96] = acadoWorkspace.H10[0]; +acadoWorkspace.H[97] = acadoWorkspace.H10[1]; +acadoWorkspace.H[98] = acadoWorkspace.H10[2]; +acadoWorkspace.H[99] = acadoWorkspace.H10[3]; +acadoWorkspace.H[120] = acadoWorkspace.H10[4]; +acadoWorkspace.H[121] = acadoWorkspace.H10[5]; +acadoWorkspace.H[122] = acadoWorkspace.H10[6]; +acadoWorkspace.H[123] = acadoWorkspace.H10[7]; +acadoWorkspace.H[144] = acadoWorkspace.H10[8]; +acadoWorkspace.H[145] = acadoWorkspace.H10[9]; +acadoWorkspace.H[146] = acadoWorkspace.H10[10]; +acadoWorkspace.H[147] = acadoWorkspace.H10[11]; +acadoWorkspace.H[168] = acadoWorkspace.H10[12]; +acadoWorkspace.H[169] = acadoWorkspace.H10[13]; +acadoWorkspace.H[170] = acadoWorkspace.H10[14]; +acadoWorkspace.H[171] = acadoWorkspace.H10[15]; +acadoWorkspace.H[192] = acadoWorkspace.H10[16]; +acadoWorkspace.H[193] = acadoWorkspace.H10[17]; +acadoWorkspace.H[194] = acadoWorkspace.H10[18]; +acadoWorkspace.H[195] = acadoWorkspace.H10[19]; +acadoWorkspace.H[216] = acadoWorkspace.H10[20]; +acadoWorkspace.H[217] = acadoWorkspace.H10[21]; +acadoWorkspace.H[218] = acadoWorkspace.H10[22]; +acadoWorkspace.H[219] = acadoWorkspace.H10[23]; +acadoWorkspace.H[240] = acadoWorkspace.H10[24]; +acadoWorkspace.H[241] = acadoWorkspace.H10[25]; +acadoWorkspace.H[242] = acadoWorkspace.H10[26]; +acadoWorkspace.H[243] = acadoWorkspace.H10[27]; +acadoWorkspace.H[264] = acadoWorkspace.H10[28]; +acadoWorkspace.H[265] = acadoWorkspace.H10[29]; +acadoWorkspace.H[266] = acadoWorkspace.H10[30]; +acadoWorkspace.H[267] = acadoWorkspace.H10[31]; +acadoWorkspace.H[288] = acadoWorkspace.H10[32]; +acadoWorkspace.H[289] = acadoWorkspace.H10[33]; +acadoWorkspace.H[290] = acadoWorkspace.H10[34]; +acadoWorkspace.H[291] = acadoWorkspace.H10[35]; +acadoWorkspace.H[312] = acadoWorkspace.H10[36]; +acadoWorkspace.H[313] = acadoWorkspace.H10[37]; +acadoWorkspace.H[314] = acadoWorkspace.H10[38]; +acadoWorkspace.H[315] = acadoWorkspace.H10[39]; +acadoWorkspace.H[336] = acadoWorkspace.H10[40]; +acadoWorkspace.H[337] = acadoWorkspace.H10[41]; +acadoWorkspace.H[338] = acadoWorkspace.H10[42]; +acadoWorkspace.H[339] = acadoWorkspace.H10[43]; +acadoWorkspace.H[360] = acadoWorkspace.H10[44]; +acadoWorkspace.H[361] = acadoWorkspace.H10[45]; +acadoWorkspace.H[362] = acadoWorkspace.H10[46]; +acadoWorkspace.H[363] = acadoWorkspace.H10[47]; +acadoWorkspace.H[384] = acadoWorkspace.H10[48]; +acadoWorkspace.H[385] = acadoWorkspace.H10[49]; +acadoWorkspace.H[386] = acadoWorkspace.H10[50]; +acadoWorkspace.H[387] = acadoWorkspace.H10[51]; +acadoWorkspace.H[408] = acadoWorkspace.H10[52]; +acadoWorkspace.H[409] = acadoWorkspace.H10[53]; +acadoWorkspace.H[410] = acadoWorkspace.H10[54]; +acadoWorkspace.H[411] = acadoWorkspace.H10[55]; +acadoWorkspace.H[432] = acadoWorkspace.H10[56]; +acadoWorkspace.H[433] = acadoWorkspace.H10[57]; +acadoWorkspace.H[434] = acadoWorkspace.H10[58]; +acadoWorkspace.H[435] = acadoWorkspace.H10[59]; +acadoWorkspace.H[456] = acadoWorkspace.H10[60]; +acadoWorkspace.H[457] = acadoWorkspace.H10[61]; +acadoWorkspace.H[458] = acadoWorkspace.H10[62]; +acadoWorkspace.H[459] = acadoWorkspace.H10[63]; +acadoWorkspace.H[480] = acadoWorkspace.H10[64]; +acadoWorkspace.H[481] = acadoWorkspace.H10[65]; +acadoWorkspace.H[482] = acadoWorkspace.H10[66]; +acadoWorkspace.H[483] = acadoWorkspace.H10[67]; +acadoWorkspace.H[504] = acadoWorkspace.H10[68]; +acadoWorkspace.H[505] = acadoWorkspace.H10[69]; +acadoWorkspace.H[506] = acadoWorkspace.H10[70]; +acadoWorkspace.H[507] = acadoWorkspace.H10[71]; +acadoWorkspace.H[528] = acadoWorkspace.H10[72]; +acadoWorkspace.H[529] = acadoWorkspace.H10[73]; +acadoWorkspace.H[530] = acadoWorkspace.H10[74]; +acadoWorkspace.H[531] = acadoWorkspace.H10[75]; +acadoWorkspace.H[552] = acadoWorkspace.H10[76]; +acadoWorkspace.H[553] = acadoWorkspace.H10[77]; +acadoWorkspace.H[554] = acadoWorkspace.H10[78]; +acadoWorkspace.H[555] = acadoWorkspace.H10[79]; + +acado_multQ1d( &(acadoWorkspace.Q1[ 16 ]), acadoWorkspace.d, acadoWorkspace.Qd ); +acado_multQ1d( &(acadoWorkspace.Q1[ 32 ]), &(acadoWorkspace.d[ 4 ]), &(acadoWorkspace.Qd[ 4 ]) ); +acado_multQ1d( &(acadoWorkspace.Q1[ 48 ]), &(acadoWorkspace.d[ 8 ]), &(acadoWorkspace.Qd[ 8 ]) ); +acado_multQ1d( &(acadoWorkspace.Q1[ 64 ]), &(acadoWorkspace.d[ 12 ]), &(acadoWorkspace.Qd[ 12 ]) ); +acado_multQ1d( &(acadoWorkspace.Q1[ 80 ]), &(acadoWorkspace.d[ 16 ]), &(acadoWorkspace.Qd[ 16 ]) ); +acado_multQ1d( &(acadoWorkspace.Q1[ 96 ]), &(acadoWorkspace.d[ 20 ]), &(acadoWorkspace.Qd[ 20 ]) ); +acado_multQ1d( &(acadoWorkspace.Q1[ 112 ]), &(acadoWorkspace.d[ 24 ]), &(acadoWorkspace.Qd[ 24 ]) ); +acado_multQ1d( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.d[ 28 ]), &(acadoWorkspace.Qd[ 28 ]) ); +acado_multQ1d( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.d[ 32 ]), &(acadoWorkspace.Qd[ 32 ]) ); +acado_multQ1d( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.d[ 36 ]), &(acadoWorkspace.Qd[ 36 ]) ); +acado_multQ1d( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.d[ 40 ]), &(acadoWorkspace.Qd[ 40 ]) ); +acado_multQ1d( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.d[ 44 ]), &(acadoWorkspace.Qd[ 44 ]) ); +acado_multQ1d( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.d[ 48 ]), &(acadoWorkspace.Qd[ 48 ]) ); +acado_multQ1d( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.d[ 52 ]), &(acadoWorkspace.Qd[ 52 ]) ); +acado_multQ1d( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.d[ 56 ]), &(acadoWorkspace.Qd[ 56 ]) ); +acado_multQ1d( &(acadoWorkspace.Q1[ 256 ]), &(acadoWorkspace.d[ 60 ]), &(acadoWorkspace.Qd[ 60 ]) ); +acado_multQ1d( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.d[ 64 ]), &(acadoWorkspace.Qd[ 64 ]) ); +acado_multQ1d( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.d[ 68 ]), &(acadoWorkspace.Qd[ 68 ]) ); +acado_multQ1d( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.d[ 72 ]), &(acadoWorkspace.Qd[ 72 ]) ); +acado_multQN1d( acadoWorkspace.QN1, &(acadoWorkspace.d[ 76 ]), &(acadoWorkspace.Qd[ 76 ]) ); + +acado_macCTSlx( acadoWorkspace.evGx, acadoWorkspace.g ); +acado_macCTSlx( &(acadoWorkspace.evGx[ 16 ]), acadoWorkspace.g ); +acado_macCTSlx( &(acadoWorkspace.evGx[ 32 ]), acadoWorkspace.g ); +acado_macCTSlx( &(acadoWorkspace.evGx[ 48 ]), acadoWorkspace.g ); +acado_macCTSlx( &(acadoWorkspace.evGx[ 64 ]), acadoWorkspace.g ); +acado_macCTSlx( &(acadoWorkspace.evGx[ 80 ]), acadoWorkspace.g ); +acado_macCTSlx( &(acadoWorkspace.evGx[ 96 ]), acadoWorkspace.g ); +acado_macCTSlx( &(acadoWorkspace.evGx[ 112 ]), acadoWorkspace.g ); +acado_macCTSlx( &(acadoWorkspace.evGx[ 128 ]), acadoWorkspace.g ); +acado_macCTSlx( &(acadoWorkspace.evGx[ 144 ]), acadoWorkspace.g ); +acado_macCTSlx( &(acadoWorkspace.evGx[ 160 ]), acadoWorkspace.g ); +acado_macCTSlx( &(acadoWorkspace.evGx[ 176 ]), acadoWorkspace.g ); +acado_macCTSlx( &(acadoWorkspace.evGx[ 192 ]), acadoWorkspace.g ); +acado_macCTSlx( &(acadoWorkspace.evGx[ 208 ]), acadoWorkspace.g ); +acado_macCTSlx( &(acadoWorkspace.evGx[ 224 ]), acadoWorkspace.g ); +acado_macCTSlx( &(acadoWorkspace.evGx[ 240 ]), acadoWorkspace.g ); +acado_macCTSlx( &(acadoWorkspace.evGx[ 256 ]), acadoWorkspace.g ); +acado_macCTSlx( &(acadoWorkspace.evGx[ 272 ]), acadoWorkspace.g ); +acado_macCTSlx( &(acadoWorkspace.evGx[ 288 ]), acadoWorkspace.g ); +acado_macCTSlx( &(acadoWorkspace.evGx[ 304 ]), acadoWorkspace.g ); +acado_macETSlu( acadoWorkspace.QE, &(acadoWorkspace.g[ 4 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 4 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 12 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 24 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 40 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 60 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 84 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 112 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 144 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 180 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 220 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 264 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 312 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 364 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 420 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 480 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 544 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 612 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 684 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 760 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 8 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 16 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 28 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 44 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 64 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 88 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 116 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 148 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 184 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 224 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 268 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 316 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 368 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 424 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 484 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 548 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 616 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 688 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 764 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 20 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 32 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 48 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 68 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 92 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 120 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 152 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 188 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 228 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 272 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 320 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 372 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 428 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 488 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 552 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 620 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 692 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 768 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 36 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 52 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 72 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 96 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 124 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 156 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 192 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 232 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 276 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 324 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 376 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 432 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 492 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 556 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 624 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 696 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 772 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 56 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 76 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 100 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 128 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 160 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 196 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 236 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 280 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 328 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 380 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 436 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 496 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 560 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 628 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 700 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 776 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 80 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 104 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 132 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 164 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 200 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 240 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 284 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 332 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 384 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 440 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 500 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 564 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 632 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 704 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 780 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 108 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 136 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 168 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 204 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 244 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 288 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 336 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 388 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 444 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 504 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 568 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 636 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 708 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 784 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 140 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 172 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 208 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 248 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 292 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 340 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 392 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 448 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 508 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 572 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 640 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 712 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 788 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 176 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 212 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 252 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 296 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 344 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 396 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 452 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 512 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 576 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 644 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 716 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 792 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 216 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 256 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 300 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 348 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 400 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 456 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 516 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 580 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 648 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 720 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 796 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 260 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 304 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 352 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 404 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 460 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 520 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 584 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 652 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 724 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 800 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 308 ]), &(acadoWorkspace.g[ 15 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 356 ]), &(acadoWorkspace.g[ 15 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 408 ]), &(acadoWorkspace.g[ 15 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 464 ]), &(acadoWorkspace.g[ 15 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 524 ]), &(acadoWorkspace.g[ 15 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 588 ]), &(acadoWorkspace.g[ 15 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 656 ]), &(acadoWorkspace.g[ 15 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 728 ]), &(acadoWorkspace.g[ 15 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 804 ]), &(acadoWorkspace.g[ 15 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 360 ]), &(acadoWorkspace.g[ 16 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 412 ]), &(acadoWorkspace.g[ 16 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 468 ]), &(acadoWorkspace.g[ 16 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 528 ]), &(acadoWorkspace.g[ 16 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 592 ]), &(acadoWorkspace.g[ 16 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 660 ]), &(acadoWorkspace.g[ 16 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 732 ]), &(acadoWorkspace.g[ 16 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 808 ]), &(acadoWorkspace.g[ 16 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 416 ]), &(acadoWorkspace.g[ 17 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 472 ]), &(acadoWorkspace.g[ 17 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 532 ]), &(acadoWorkspace.g[ 17 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 596 ]), &(acadoWorkspace.g[ 17 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 664 ]), &(acadoWorkspace.g[ 17 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 736 ]), &(acadoWorkspace.g[ 17 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 812 ]), &(acadoWorkspace.g[ 17 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 476 ]), &(acadoWorkspace.g[ 18 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 536 ]), &(acadoWorkspace.g[ 18 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 600 ]), &(acadoWorkspace.g[ 18 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 668 ]), &(acadoWorkspace.g[ 18 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 740 ]), &(acadoWorkspace.g[ 18 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 816 ]), &(acadoWorkspace.g[ 18 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 540 ]), &(acadoWorkspace.g[ 19 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 604 ]), &(acadoWorkspace.g[ 19 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 672 ]), &(acadoWorkspace.g[ 19 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 744 ]), &(acadoWorkspace.g[ 19 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 820 ]), &(acadoWorkspace.g[ 19 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 608 ]), &(acadoWorkspace.g[ 20 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 676 ]), &(acadoWorkspace.g[ 20 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 748 ]), &(acadoWorkspace.g[ 20 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 824 ]), &(acadoWorkspace.g[ 20 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 680 ]), &(acadoWorkspace.g[ 21 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 752 ]), &(acadoWorkspace.g[ 21 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 828 ]), &(acadoWorkspace.g[ 21 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 756 ]), &(acadoWorkspace.g[ 22 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 832 ]), &(acadoWorkspace.g[ 22 ]) ); +acado_macETSlu( &(acadoWorkspace.QE[ 836 ]), &(acadoWorkspace.g[ 23 ]) ); +acadoWorkspace.lb[4] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[0]; +acadoWorkspace.lb[5] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[1]; +acadoWorkspace.lb[6] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[2]; +acadoWorkspace.lb[7] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[3]; +acadoWorkspace.lb[8] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[4]; +acadoWorkspace.lb[9] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[5]; +acadoWorkspace.lb[10] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[6]; +acadoWorkspace.lb[11] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[7]; +acadoWorkspace.lb[12] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[8]; +acadoWorkspace.lb[13] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[9]; +acadoWorkspace.lb[14] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[10]; +acadoWorkspace.lb[15] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[11]; +acadoWorkspace.lb[16] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[12]; +acadoWorkspace.lb[17] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[13]; +acadoWorkspace.lb[18] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[14]; +acadoWorkspace.lb[19] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[15]; +acadoWorkspace.lb[20] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[16]; +acadoWorkspace.lb[21] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[17]; +acadoWorkspace.lb[22] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[18]; +acadoWorkspace.lb[23] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[19]; +acadoWorkspace.ub[4] = (real_t)1.0000000000000000e+12 - acadoVariables.u[0]; +acadoWorkspace.ub[5] = (real_t)1.0000000000000000e+12 - acadoVariables.u[1]; +acadoWorkspace.ub[6] = (real_t)1.0000000000000000e+12 - acadoVariables.u[2]; +acadoWorkspace.ub[7] = (real_t)1.0000000000000000e+12 - acadoVariables.u[3]; +acadoWorkspace.ub[8] = (real_t)1.0000000000000000e+12 - acadoVariables.u[4]; +acadoWorkspace.ub[9] = (real_t)1.0000000000000000e+12 - acadoVariables.u[5]; +acadoWorkspace.ub[10] = (real_t)1.0000000000000000e+12 - acadoVariables.u[6]; +acadoWorkspace.ub[11] = (real_t)1.0000000000000000e+12 - acadoVariables.u[7]; +acadoWorkspace.ub[12] = (real_t)1.0000000000000000e+12 - acadoVariables.u[8]; +acadoWorkspace.ub[13] = (real_t)1.0000000000000000e+12 - acadoVariables.u[9]; +acadoWorkspace.ub[14] = (real_t)1.0000000000000000e+12 - acadoVariables.u[10]; +acadoWorkspace.ub[15] = (real_t)1.0000000000000000e+12 - acadoVariables.u[11]; +acadoWorkspace.ub[16] = (real_t)1.0000000000000000e+12 - acadoVariables.u[12]; +acadoWorkspace.ub[17] = (real_t)1.0000000000000000e+12 - acadoVariables.u[13]; +acadoWorkspace.ub[18] = (real_t)1.0000000000000000e+12 - acadoVariables.u[14]; +acadoWorkspace.ub[19] = (real_t)1.0000000000000000e+12 - acadoVariables.u[15]; +acadoWorkspace.ub[20] = (real_t)1.0000000000000000e+12 - acadoVariables.u[16]; +acadoWorkspace.ub[21] = (real_t)1.0000000000000000e+12 - acadoVariables.u[17]; +acadoWorkspace.ub[22] = (real_t)1.0000000000000000e+12 - acadoVariables.u[18]; +acadoWorkspace.ub[23] = (real_t)1.0000000000000000e+12 - acadoVariables.u[19]; + +} + +void acado_condenseFdb( ) +{ +acadoWorkspace.Dx0[0] = acadoVariables.x0[0] - acadoVariables.x[0]; +acadoWorkspace.Dx0[1] = acadoVariables.x0[1] - acadoVariables.x[1]; +acadoWorkspace.Dx0[2] = acadoVariables.x0[2] - acadoVariables.x[2]; +acadoWorkspace.Dx0[3] = acadoVariables.x0[3] - acadoVariables.x[3]; + +acadoWorkspace.Dy[0] -= acadoVariables.y[0]; +acadoWorkspace.Dy[1] -= acadoVariables.y[1]; +acadoWorkspace.Dy[2] -= acadoVariables.y[2]; +acadoWorkspace.Dy[3] -= acadoVariables.y[3]; +acadoWorkspace.Dy[4] -= acadoVariables.y[4]; +acadoWorkspace.Dy[5] -= acadoVariables.y[5]; +acadoWorkspace.Dy[6] -= acadoVariables.y[6]; +acadoWorkspace.Dy[7] -= acadoVariables.y[7]; +acadoWorkspace.Dy[8] -= acadoVariables.y[8]; +acadoWorkspace.Dy[9] -= acadoVariables.y[9]; +acadoWorkspace.Dy[10] -= acadoVariables.y[10]; +acadoWorkspace.Dy[11] -= acadoVariables.y[11]; +acadoWorkspace.Dy[12] -= acadoVariables.y[12]; +acadoWorkspace.Dy[13] -= acadoVariables.y[13]; +acadoWorkspace.Dy[14] -= acadoVariables.y[14]; +acadoWorkspace.Dy[15] -= acadoVariables.y[15]; +acadoWorkspace.Dy[16] -= acadoVariables.y[16]; +acadoWorkspace.Dy[17] -= acadoVariables.y[17]; +acadoWorkspace.Dy[18] -= acadoVariables.y[18]; +acadoWorkspace.Dy[19] -= acadoVariables.y[19]; +acadoWorkspace.Dy[20] -= acadoVariables.y[20]; +acadoWorkspace.Dy[21] -= acadoVariables.y[21]; +acadoWorkspace.Dy[22] -= acadoVariables.y[22]; +acadoWorkspace.Dy[23] -= acadoVariables.y[23]; +acadoWorkspace.Dy[24] -= acadoVariables.y[24]; +acadoWorkspace.Dy[25] -= acadoVariables.y[25]; +acadoWorkspace.Dy[26] -= acadoVariables.y[26]; +acadoWorkspace.Dy[27] -= acadoVariables.y[27]; +acadoWorkspace.Dy[28] -= acadoVariables.y[28]; +acadoWorkspace.Dy[29] -= acadoVariables.y[29]; +acadoWorkspace.Dy[30] -= acadoVariables.y[30]; +acadoWorkspace.Dy[31] -= acadoVariables.y[31]; +acadoWorkspace.Dy[32] -= acadoVariables.y[32]; +acadoWorkspace.Dy[33] -= acadoVariables.y[33]; +acadoWorkspace.Dy[34] -= acadoVariables.y[34]; +acadoWorkspace.Dy[35] -= acadoVariables.y[35]; +acadoWorkspace.Dy[36] -= acadoVariables.y[36]; +acadoWorkspace.Dy[37] -= acadoVariables.y[37]; +acadoWorkspace.Dy[38] -= acadoVariables.y[38]; +acadoWorkspace.Dy[39] -= acadoVariables.y[39]; +acadoWorkspace.Dy[40] -= acadoVariables.y[40]; +acadoWorkspace.Dy[41] -= acadoVariables.y[41]; +acadoWorkspace.Dy[42] -= acadoVariables.y[42]; +acadoWorkspace.Dy[43] -= acadoVariables.y[43]; +acadoWorkspace.Dy[44] -= acadoVariables.y[44]; +acadoWorkspace.Dy[45] -= acadoVariables.y[45]; +acadoWorkspace.Dy[46] -= acadoVariables.y[46]; +acadoWorkspace.Dy[47] -= acadoVariables.y[47]; +acadoWorkspace.Dy[48] -= acadoVariables.y[48]; +acadoWorkspace.Dy[49] -= acadoVariables.y[49]; +acadoWorkspace.Dy[50] -= acadoVariables.y[50]; +acadoWorkspace.Dy[51] -= acadoVariables.y[51]; +acadoWorkspace.Dy[52] -= acadoVariables.y[52]; +acadoWorkspace.Dy[53] -= acadoVariables.y[53]; +acadoWorkspace.Dy[54] -= acadoVariables.y[54]; +acadoWorkspace.Dy[55] -= acadoVariables.y[55]; +acadoWorkspace.Dy[56] -= acadoVariables.y[56]; +acadoWorkspace.Dy[57] -= acadoVariables.y[57]; +acadoWorkspace.Dy[58] -= acadoVariables.y[58]; +acadoWorkspace.Dy[59] -= acadoVariables.y[59]; +acadoWorkspace.Dy[60] -= acadoVariables.y[60]; +acadoWorkspace.Dy[61] -= acadoVariables.y[61]; +acadoWorkspace.Dy[62] -= acadoVariables.y[62]; +acadoWorkspace.Dy[63] -= acadoVariables.y[63]; +acadoWorkspace.Dy[64] -= acadoVariables.y[64]; +acadoWorkspace.Dy[65] -= acadoVariables.y[65]; +acadoWorkspace.Dy[66] -= acadoVariables.y[66]; +acadoWorkspace.Dy[67] -= acadoVariables.y[67]; +acadoWorkspace.Dy[68] -= acadoVariables.y[68]; +acadoWorkspace.Dy[69] -= acadoVariables.y[69]; +acadoWorkspace.Dy[70] -= acadoVariables.y[70]; +acadoWorkspace.Dy[71] -= acadoVariables.y[71]; +acadoWorkspace.Dy[72] -= acadoVariables.y[72]; +acadoWorkspace.Dy[73] -= acadoVariables.y[73]; +acadoWorkspace.Dy[74] -= acadoVariables.y[74]; +acadoWorkspace.Dy[75] -= acadoVariables.y[75]; +acadoWorkspace.Dy[76] -= acadoVariables.y[76]; +acadoWorkspace.Dy[77] -= acadoVariables.y[77]; +acadoWorkspace.Dy[78] -= acadoVariables.y[78]; +acadoWorkspace.Dy[79] -= acadoVariables.y[79]; +acadoWorkspace.Dy[80] -= acadoVariables.y[80]; +acadoWorkspace.Dy[81] -= acadoVariables.y[81]; +acadoWorkspace.Dy[82] -= acadoVariables.y[82]; +acadoWorkspace.Dy[83] -= acadoVariables.y[83]; +acadoWorkspace.Dy[84] -= acadoVariables.y[84]; +acadoWorkspace.Dy[85] -= acadoVariables.y[85]; +acadoWorkspace.Dy[86] -= acadoVariables.y[86]; +acadoWorkspace.Dy[87] -= acadoVariables.y[87]; +acadoWorkspace.Dy[88] -= acadoVariables.y[88]; +acadoWorkspace.Dy[89] -= acadoVariables.y[89]; +acadoWorkspace.Dy[90] -= acadoVariables.y[90]; +acadoWorkspace.Dy[91] -= acadoVariables.y[91]; +acadoWorkspace.Dy[92] -= acadoVariables.y[92]; +acadoWorkspace.Dy[93] -= acadoVariables.y[93]; +acadoWorkspace.Dy[94] -= acadoVariables.y[94]; +acadoWorkspace.Dy[95] -= acadoVariables.y[95]; +acadoWorkspace.Dy[96] -= acadoVariables.y[96]; +acadoWorkspace.Dy[97] -= acadoVariables.y[97]; +acadoWorkspace.Dy[98] -= acadoVariables.y[98]; +acadoWorkspace.Dy[99] -= acadoVariables.y[99]; +acadoWorkspace.DyN[0] -= acadoVariables.yN[0]; +acadoWorkspace.DyN[1] -= acadoVariables.yN[1]; +acadoWorkspace.DyN[2] -= acadoVariables.yN[2]; +acadoWorkspace.DyN[3] -= acadoVariables.yN[3]; + +acado_multRDy( acadoWorkspace.R2, acadoWorkspace.Dy, &(acadoWorkspace.g[ 4 ]) ); +acado_multRDy( &(acadoWorkspace.R2[ 5 ]), &(acadoWorkspace.Dy[ 5 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_multRDy( &(acadoWorkspace.R2[ 10 ]), &(acadoWorkspace.Dy[ 10 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_multRDy( &(acadoWorkspace.R2[ 15 ]), &(acadoWorkspace.Dy[ 15 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_multRDy( &(acadoWorkspace.R2[ 20 ]), &(acadoWorkspace.Dy[ 20 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_multRDy( &(acadoWorkspace.R2[ 25 ]), &(acadoWorkspace.Dy[ 25 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_multRDy( &(acadoWorkspace.R2[ 30 ]), &(acadoWorkspace.Dy[ 30 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_multRDy( &(acadoWorkspace.R2[ 35 ]), &(acadoWorkspace.Dy[ 35 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_multRDy( &(acadoWorkspace.R2[ 40 ]), &(acadoWorkspace.Dy[ 40 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_multRDy( &(acadoWorkspace.R2[ 45 ]), &(acadoWorkspace.Dy[ 45 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_multRDy( &(acadoWorkspace.R2[ 50 ]), &(acadoWorkspace.Dy[ 50 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_multRDy( &(acadoWorkspace.R2[ 55 ]), &(acadoWorkspace.Dy[ 55 ]), &(acadoWorkspace.g[ 15 ]) ); +acado_multRDy( &(acadoWorkspace.R2[ 60 ]), &(acadoWorkspace.Dy[ 60 ]), &(acadoWorkspace.g[ 16 ]) ); +acado_multRDy( &(acadoWorkspace.R2[ 65 ]), &(acadoWorkspace.Dy[ 65 ]), &(acadoWorkspace.g[ 17 ]) ); +acado_multRDy( &(acadoWorkspace.R2[ 70 ]), &(acadoWorkspace.Dy[ 70 ]), &(acadoWorkspace.g[ 18 ]) ); +acado_multRDy( &(acadoWorkspace.R2[ 75 ]), &(acadoWorkspace.Dy[ 75 ]), &(acadoWorkspace.g[ 19 ]) ); +acado_multRDy( &(acadoWorkspace.R2[ 80 ]), &(acadoWorkspace.Dy[ 80 ]), &(acadoWorkspace.g[ 20 ]) ); +acado_multRDy( &(acadoWorkspace.R2[ 85 ]), &(acadoWorkspace.Dy[ 85 ]), &(acadoWorkspace.g[ 21 ]) ); +acado_multRDy( &(acadoWorkspace.R2[ 90 ]), &(acadoWorkspace.Dy[ 90 ]), &(acadoWorkspace.g[ 22 ]) ); +acado_multRDy( &(acadoWorkspace.R2[ 95 ]), &(acadoWorkspace.Dy[ 95 ]), &(acadoWorkspace.g[ 23 ]) ); + +acado_multQDy( acadoWorkspace.Q2, acadoWorkspace.Dy, acadoWorkspace.QDy ); +acado_multQDy( &(acadoWorkspace.Q2[ 20 ]), &(acadoWorkspace.Dy[ 5 ]), &(acadoWorkspace.QDy[ 4 ]) ); +acado_multQDy( &(acadoWorkspace.Q2[ 40 ]), &(acadoWorkspace.Dy[ 10 ]), &(acadoWorkspace.QDy[ 8 ]) ); +acado_multQDy( &(acadoWorkspace.Q2[ 60 ]), &(acadoWorkspace.Dy[ 15 ]), &(acadoWorkspace.QDy[ 12 ]) ); +acado_multQDy( &(acadoWorkspace.Q2[ 80 ]), &(acadoWorkspace.Dy[ 20 ]), &(acadoWorkspace.QDy[ 16 ]) ); +acado_multQDy( &(acadoWorkspace.Q2[ 100 ]), &(acadoWorkspace.Dy[ 25 ]), &(acadoWorkspace.QDy[ 20 ]) ); +acado_multQDy( &(acadoWorkspace.Q2[ 120 ]), &(acadoWorkspace.Dy[ 30 ]), &(acadoWorkspace.QDy[ 24 ]) ); +acado_multQDy( &(acadoWorkspace.Q2[ 140 ]), &(acadoWorkspace.Dy[ 35 ]), &(acadoWorkspace.QDy[ 28 ]) ); +acado_multQDy( &(acadoWorkspace.Q2[ 160 ]), &(acadoWorkspace.Dy[ 40 ]), &(acadoWorkspace.QDy[ 32 ]) ); +acado_multQDy( &(acadoWorkspace.Q2[ 180 ]), &(acadoWorkspace.Dy[ 45 ]), &(acadoWorkspace.QDy[ 36 ]) ); +acado_multQDy( &(acadoWorkspace.Q2[ 200 ]), &(acadoWorkspace.Dy[ 50 ]), &(acadoWorkspace.QDy[ 40 ]) ); +acado_multQDy( &(acadoWorkspace.Q2[ 220 ]), &(acadoWorkspace.Dy[ 55 ]), &(acadoWorkspace.QDy[ 44 ]) ); +acado_multQDy( &(acadoWorkspace.Q2[ 240 ]), &(acadoWorkspace.Dy[ 60 ]), &(acadoWorkspace.QDy[ 48 ]) ); +acado_multQDy( &(acadoWorkspace.Q2[ 260 ]), &(acadoWorkspace.Dy[ 65 ]), &(acadoWorkspace.QDy[ 52 ]) ); +acado_multQDy( &(acadoWorkspace.Q2[ 280 ]), &(acadoWorkspace.Dy[ 70 ]), &(acadoWorkspace.QDy[ 56 ]) ); +acado_multQDy( &(acadoWorkspace.Q2[ 300 ]), &(acadoWorkspace.Dy[ 75 ]), &(acadoWorkspace.QDy[ 60 ]) ); +acado_multQDy( &(acadoWorkspace.Q2[ 320 ]), &(acadoWorkspace.Dy[ 80 ]), &(acadoWorkspace.QDy[ 64 ]) ); +acado_multQDy( &(acadoWorkspace.Q2[ 340 ]), &(acadoWorkspace.Dy[ 85 ]), &(acadoWorkspace.QDy[ 68 ]) ); +acado_multQDy( &(acadoWorkspace.Q2[ 360 ]), &(acadoWorkspace.Dy[ 90 ]), &(acadoWorkspace.QDy[ 72 ]) ); +acado_multQDy( &(acadoWorkspace.Q2[ 380 ]), &(acadoWorkspace.Dy[ 95 ]), &(acadoWorkspace.QDy[ 76 ]) ); + +acadoWorkspace.QDy[80] = + acadoWorkspace.QN2[0]*acadoWorkspace.DyN[0] + acadoWorkspace.QN2[1]*acadoWorkspace.DyN[1] + acadoWorkspace.QN2[2]*acadoWorkspace.DyN[2] + acadoWorkspace.QN2[3]*acadoWorkspace.DyN[3]; +acadoWorkspace.QDy[81] = + acadoWorkspace.QN2[4]*acadoWorkspace.DyN[0] + acadoWorkspace.QN2[5]*acadoWorkspace.DyN[1] + acadoWorkspace.QN2[6]*acadoWorkspace.DyN[2] + acadoWorkspace.QN2[7]*acadoWorkspace.DyN[3]; +acadoWorkspace.QDy[82] = + acadoWorkspace.QN2[8]*acadoWorkspace.DyN[0] + acadoWorkspace.QN2[9]*acadoWorkspace.DyN[1] + acadoWorkspace.QN2[10]*acadoWorkspace.DyN[2] + acadoWorkspace.QN2[11]*acadoWorkspace.DyN[3]; +acadoWorkspace.QDy[83] = + acadoWorkspace.QN2[12]*acadoWorkspace.DyN[0] + acadoWorkspace.QN2[13]*acadoWorkspace.DyN[1] + acadoWorkspace.QN2[14]*acadoWorkspace.DyN[2] + acadoWorkspace.QN2[15]*acadoWorkspace.DyN[3]; + +acadoWorkspace.QDy[4] += acadoWorkspace.Qd[0]; +acadoWorkspace.QDy[5] += acadoWorkspace.Qd[1]; +acadoWorkspace.QDy[6] += acadoWorkspace.Qd[2]; +acadoWorkspace.QDy[7] += acadoWorkspace.Qd[3]; +acadoWorkspace.QDy[8] += acadoWorkspace.Qd[4]; +acadoWorkspace.QDy[9] += acadoWorkspace.Qd[5]; +acadoWorkspace.QDy[10] += acadoWorkspace.Qd[6]; +acadoWorkspace.QDy[11] += acadoWorkspace.Qd[7]; +acadoWorkspace.QDy[12] += acadoWorkspace.Qd[8]; +acadoWorkspace.QDy[13] += acadoWorkspace.Qd[9]; +acadoWorkspace.QDy[14] += acadoWorkspace.Qd[10]; +acadoWorkspace.QDy[15] += acadoWorkspace.Qd[11]; +acadoWorkspace.QDy[16] += acadoWorkspace.Qd[12]; +acadoWorkspace.QDy[17] += acadoWorkspace.Qd[13]; +acadoWorkspace.QDy[18] += acadoWorkspace.Qd[14]; +acadoWorkspace.QDy[19] += acadoWorkspace.Qd[15]; +acadoWorkspace.QDy[20] += acadoWorkspace.Qd[16]; +acadoWorkspace.QDy[21] += acadoWorkspace.Qd[17]; +acadoWorkspace.QDy[22] += acadoWorkspace.Qd[18]; +acadoWorkspace.QDy[23] += acadoWorkspace.Qd[19]; +acadoWorkspace.QDy[24] += acadoWorkspace.Qd[20]; +acadoWorkspace.QDy[25] += acadoWorkspace.Qd[21]; +acadoWorkspace.QDy[26] += acadoWorkspace.Qd[22]; +acadoWorkspace.QDy[27] += acadoWorkspace.Qd[23]; +acadoWorkspace.QDy[28] += acadoWorkspace.Qd[24]; +acadoWorkspace.QDy[29] += acadoWorkspace.Qd[25]; +acadoWorkspace.QDy[30] += acadoWorkspace.Qd[26]; +acadoWorkspace.QDy[31] += acadoWorkspace.Qd[27]; +acadoWorkspace.QDy[32] += acadoWorkspace.Qd[28]; +acadoWorkspace.QDy[33] += acadoWorkspace.Qd[29]; +acadoWorkspace.QDy[34] += acadoWorkspace.Qd[30]; +acadoWorkspace.QDy[35] += acadoWorkspace.Qd[31]; +acadoWorkspace.QDy[36] += acadoWorkspace.Qd[32]; +acadoWorkspace.QDy[37] += acadoWorkspace.Qd[33]; +acadoWorkspace.QDy[38] += acadoWorkspace.Qd[34]; +acadoWorkspace.QDy[39] += acadoWorkspace.Qd[35]; +acadoWorkspace.QDy[40] += acadoWorkspace.Qd[36]; +acadoWorkspace.QDy[41] += acadoWorkspace.Qd[37]; +acadoWorkspace.QDy[42] += acadoWorkspace.Qd[38]; +acadoWorkspace.QDy[43] += acadoWorkspace.Qd[39]; +acadoWorkspace.QDy[44] += acadoWorkspace.Qd[40]; +acadoWorkspace.QDy[45] += acadoWorkspace.Qd[41]; +acadoWorkspace.QDy[46] += acadoWorkspace.Qd[42]; +acadoWorkspace.QDy[47] += acadoWorkspace.Qd[43]; +acadoWorkspace.QDy[48] += acadoWorkspace.Qd[44]; +acadoWorkspace.QDy[49] += acadoWorkspace.Qd[45]; +acadoWorkspace.QDy[50] += acadoWorkspace.Qd[46]; +acadoWorkspace.QDy[51] += acadoWorkspace.Qd[47]; +acadoWorkspace.QDy[52] += acadoWorkspace.Qd[48]; +acadoWorkspace.QDy[53] += acadoWorkspace.Qd[49]; +acadoWorkspace.QDy[54] += acadoWorkspace.Qd[50]; +acadoWorkspace.QDy[55] += acadoWorkspace.Qd[51]; +acadoWorkspace.QDy[56] += acadoWorkspace.Qd[52]; +acadoWorkspace.QDy[57] += acadoWorkspace.Qd[53]; +acadoWorkspace.QDy[58] += acadoWorkspace.Qd[54]; +acadoWorkspace.QDy[59] += acadoWorkspace.Qd[55]; +acadoWorkspace.QDy[60] += acadoWorkspace.Qd[56]; +acadoWorkspace.QDy[61] += acadoWorkspace.Qd[57]; +acadoWorkspace.QDy[62] += acadoWorkspace.Qd[58]; +acadoWorkspace.QDy[63] += acadoWorkspace.Qd[59]; +acadoWorkspace.QDy[64] += acadoWorkspace.Qd[60]; +acadoWorkspace.QDy[65] += acadoWorkspace.Qd[61]; +acadoWorkspace.QDy[66] += acadoWorkspace.Qd[62]; +acadoWorkspace.QDy[67] += acadoWorkspace.Qd[63]; +acadoWorkspace.QDy[68] += acadoWorkspace.Qd[64]; +acadoWorkspace.QDy[69] += acadoWorkspace.Qd[65]; +acadoWorkspace.QDy[70] += acadoWorkspace.Qd[66]; +acadoWorkspace.QDy[71] += acadoWorkspace.Qd[67]; +acadoWorkspace.QDy[72] += acadoWorkspace.Qd[68]; +acadoWorkspace.QDy[73] += acadoWorkspace.Qd[69]; +acadoWorkspace.QDy[74] += acadoWorkspace.Qd[70]; +acadoWorkspace.QDy[75] += acadoWorkspace.Qd[71]; +acadoWorkspace.QDy[76] += acadoWorkspace.Qd[72]; +acadoWorkspace.QDy[77] += acadoWorkspace.Qd[73]; +acadoWorkspace.QDy[78] += acadoWorkspace.Qd[74]; +acadoWorkspace.QDy[79] += acadoWorkspace.Qd[75]; +acadoWorkspace.QDy[80] += acadoWorkspace.Qd[76]; +acadoWorkspace.QDy[81] += acadoWorkspace.Qd[77]; +acadoWorkspace.QDy[82] += acadoWorkspace.Qd[78]; +acadoWorkspace.QDy[83] += acadoWorkspace.Qd[79]; + +acadoWorkspace.g[0] = + acadoWorkspace.evGx[0]*acadoWorkspace.QDy[4] + acadoWorkspace.evGx[4]*acadoWorkspace.QDy[5] + acadoWorkspace.evGx[8]*acadoWorkspace.QDy[6] + acadoWorkspace.evGx[12]*acadoWorkspace.QDy[7] + acadoWorkspace.evGx[16]*acadoWorkspace.QDy[8] + acadoWorkspace.evGx[20]*acadoWorkspace.QDy[9] + acadoWorkspace.evGx[24]*acadoWorkspace.QDy[10] + acadoWorkspace.evGx[28]*acadoWorkspace.QDy[11] + acadoWorkspace.evGx[32]*acadoWorkspace.QDy[12] + acadoWorkspace.evGx[36]*acadoWorkspace.QDy[13] + acadoWorkspace.evGx[40]*acadoWorkspace.QDy[14] + acadoWorkspace.evGx[44]*acadoWorkspace.QDy[15] + acadoWorkspace.evGx[48]*acadoWorkspace.QDy[16] + acadoWorkspace.evGx[52]*acadoWorkspace.QDy[17] + acadoWorkspace.evGx[56]*acadoWorkspace.QDy[18] + acadoWorkspace.evGx[60]*acadoWorkspace.QDy[19] + acadoWorkspace.evGx[64]*acadoWorkspace.QDy[20] + acadoWorkspace.evGx[68]*acadoWorkspace.QDy[21] + acadoWorkspace.evGx[72]*acadoWorkspace.QDy[22] + acadoWorkspace.evGx[76]*acadoWorkspace.QDy[23] + acadoWorkspace.evGx[80]*acadoWorkspace.QDy[24] + acadoWorkspace.evGx[84]*acadoWorkspace.QDy[25] + acadoWorkspace.evGx[88]*acadoWorkspace.QDy[26] + acadoWorkspace.evGx[92]*acadoWorkspace.QDy[27] + acadoWorkspace.evGx[96]*acadoWorkspace.QDy[28] + acadoWorkspace.evGx[100]*acadoWorkspace.QDy[29] + acadoWorkspace.evGx[104]*acadoWorkspace.QDy[30] + acadoWorkspace.evGx[108]*acadoWorkspace.QDy[31] + acadoWorkspace.evGx[112]*acadoWorkspace.QDy[32] + acadoWorkspace.evGx[116]*acadoWorkspace.QDy[33] + acadoWorkspace.evGx[120]*acadoWorkspace.QDy[34] + acadoWorkspace.evGx[124]*acadoWorkspace.QDy[35] + acadoWorkspace.evGx[128]*acadoWorkspace.QDy[36] + acadoWorkspace.evGx[132]*acadoWorkspace.QDy[37] + acadoWorkspace.evGx[136]*acadoWorkspace.QDy[38] + acadoWorkspace.evGx[140]*acadoWorkspace.QDy[39] + acadoWorkspace.evGx[144]*acadoWorkspace.QDy[40] + acadoWorkspace.evGx[148]*acadoWorkspace.QDy[41] + acadoWorkspace.evGx[152]*acadoWorkspace.QDy[42] + acadoWorkspace.evGx[156]*acadoWorkspace.QDy[43] + acadoWorkspace.evGx[160]*acadoWorkspace.QDy[44] + acadoWorkspace.evGx[164]*acadoWorkspace.QDy[45] + acadoWorkspace.evGx[168]*acadoWorkspace.QDy[46] + acadoWorkspace.evGx[172]*acadoWorkspace.QDy[47] + acadoWorkspace.evGx[176]*acadoWorkspace.QDy[48] + acadoWorkspace.evGx[180]*acadoWorkspace.QDy[49] + acadoWorkspace.evGx[184]*acadoWorkspace.QDy[50] + acadoWorkspace.evGx[188]*acadoWorkspace.QDy[51] + acadoWorkspace.evGx[192]*acadoWorkspace.QDy[52] + acadoWorkspace.evGx[196]*acadoWorkspace.QDy[53] + acadoWorkspace.evGx[200]*acadoWorkspace.QDy[54] + acadoWorkspace.evGx[204]*acadoWorkspace.QDy[55] + acadoWorkspace.evGx[208]*acadoWorkspace.QDy[56] + acadoWorkspace.evGx[212]*acadoWorkspace.QDy[57] + acadoWorkspace.evGx[216]*acadoWorkspace.QDy[58] + acadoWorkspace.evGx[220]*acadoWorkspace.QDy[59] + acadoWorkspace.evGx[224]*acadoWorkspace.QDy[60] + acadoWorkspace.evGx[228]*acadoWorkspace.QDy[61] + acadoWorkspace.evGx[232]*acadoWorkspace.QDy[62] + acadoWorkspace.evGx[236]*acadoWorkspace.QDy[63] + acadoWorkspace.evGx[240]*acadoWorkspace.QDy[64] + acadoWorkspace.evGx[244]*acadoWorkspace.QDy[65] + acadoWorkspace.evGx[248]*acadoWorkspace.QDy[66] + acadoWorkspace.evGx[252]*acadoWorkspace.QDy[67] + acadoWorkspace.evGx[256]*acadoWorkspace.QDy[68] + acadoWorkspace.evGx[260]*acadoWorkspace.QDy[69] + acadoWorkspace.evGx[264]*acadoWorkspace.QDy[70] + acadoWorkspace.evGx[268]*acadoWorkspace.QDy[71] + acadoWorkspace.evGx[272]*acadoWorkspace.QDy[72] + acadoWorkspace.evGx[276]*acadoWorkspace.QDy[73] + acadoWorkspace.evGx[280]*acadoWorkspace.QDy[74] + acadoWorkspace.evGx[284]*acadoWorkspace.QDy[75] + acadoWorkspace.evGx[288]*acadoWorkspace.QDy[76] + acadoWorkspace.evGx[292]*acadoWorkspace.QDy[77] + acadoWorkspace.evGx[296]*acadoWorkspace.QDy[78] + acadoWorkspace.evGx[300]*acadoWorkspace.QDy[79] + acadoWorkspace.evGx[304]*acadoWorkspace.QDy[80] + acadoWorkspace.evGx[308]*acadoWorkspace.QDy[81] + acadoWorkspace.evGx[312]*acadoWorkspace.QDy[82] + acadoWorkspace.evGx[316]*acadoWorkspace.QDy[83]; +acadoWorkspace.g[1] = + acadoWorkspace.evGx[1]*acadoWorkspace.QDy[4] + acadoWorkspace.evGx[5]*acadoWorkspace.QDy[5] + acadoWorkspace.evGx[9]*acadoWorkspace.QDy[6] + acadoWorkspace.evGx[13]*acadoWorkspace.QDy[7] + acadoWorkspace.evGx[17]*acadoWorkspace.QDy[8] + acadoWorkspace.evGx[21]*acadoWorkspace.QDy[9] + acadoWorkspace.evGx[25]*acadoWorkspace.QDy[10] + acadoWorkspace.evGx[29]*acadoWorkspace.QDy[11] + acadoWorkspace.evGx[33]*acadoWorkspace.QDy[12] + acadoWorkspace.evGx[37]*acadoWorkspace.QDy[13] + acadoWorkspace.evGx[41]*acadoWorkspace.QDy[14] + acadoWorkspace.evGx[45]*acadoWorkspace.QDy[15] + acadoWorkspace.evGx[49]*acadoWorkspace.QDy[16] + acadoWorkspace.evGx[53]*acadoWorkspace.QDy[17] + acadoWorkspace.evGx[57]*acadoWorkspace.QDy[18] + acadoWorkspace.evGx[61]*acadoWorkspace.QDy[19] + acadoWorkspace.evGx[65]*acadoWorkspace.QDy[20] + acadoWorkspace.evGx[69]*acadoWorkspace.QDy[21] + acadoWorkspace.evGx[73]*acadoWorkspace.QDy[22] + acadoWorkspace.evGx[77]*acadoWorkspace.QDy[23] + acadoWorkspace.evGx[81]*acadoWorkspace.QDy[24] + acadoWorkspace.evGx[85]*acadoWorkspace.QDy[25] + acadoWorkspace.evGx[89]*acadoWorkspace.QDy[26] + acadoWorkspace.evGx[93]*acadoWorkspace.QDy[27] + acadoWorkspace.evGx[97]*acadoWorkspace.QDy[28] + acadoWorkspace.evGx[101]*acadoWorkspace.QDy[29] + acadoWorkspace.evGx[105]*acadoWorkspace.QDy[30] + acadoWorkspace.evGx[109]*acadoWorkspace.QDy[31] + acadoWorkspace.evGx[113]*acadoWorkspace.QDy[32] + acadoWorkspace.evGx[117]*acadoWorkspace.QDy[33] + acadoWorkspace.evGx[121]*acadoWorkspace.QDy[34] + acadoWorkspace.evGx[125]*acadoWorkspace.QDy[35] + acadoWorkspace.evGx[129]*acadoWorkspace.QDy[36] + acadoWorkspace.evGx[133]*acadoWorkspace.QDy[37] + acadoWorkspace.evGx[137]*acadoWorkspace.QDy[38] + acadoWorkspace.evGx[141]*acadoWorkspace.QDy[39] + acadoWorkspace.evGx[145]*acadoWorkspace.QDy[40] + acadoWorkspace.evGx[149]*acadoWorkspace.QDy[41] + acadoWorkspace.evGx[153]*acadoWorkspace.QDy[42] + acadoWorkspace.evGx[157]*acadoWorkspace.QDy[43] + acadoWorkspace.evGx[161]*acadoWorkspace.QDy[44] + acadoWorkspace.evGx[165]*acadoWorkspace.QDy[45] + acadoWorkspace.evGx[169]*acadoWorkspace.QDy[46] + acadoWorkspace.evGx[173]*acadoWorkspace.QDy[47] + acadoWorkspace.evGx[177]*acadoWorkspace.QDy[48] + acadoWorkspace.evGx[181]*acadoWorkspace.QDy[49] + acadoWorkspace.evGx[185]*acadoWorkspace.QDy[50] + acadoWorkspace.evGx[189]*acadoWorkspace.QDy[51] + acadoWorkspace.evGx[193]*acadoWorkspace.QDy[52] + acadoWorkspace.evGx[197]*acadoWorkspace.QDy[53] + acadoWorkspace.evGx[201]*acadoWorkspace.QDy[54] + acadoWorkspace.evGx[205]*acadoWorkspace.QDy[55] + acadoWorkspace.evGx[209]*acadoWorkspace.QDy[56] + acadoWorkspace.evGx[213]*acadoWorkspace.QDy[57] + acadoWorkspace.evGx[217]*acadoWorkspace.QDy[58] + acadoWorkspace.evGx[221]*acadoWorkspace.QDy[59] + acadoWorkspace.evGx[225]*acadoWorkspace.QDy[60] + acadoWorkspace.evGx[229]*acadoWorkspace.QDy[61] + acadoWorkspace.evGx[233]*acadoWorkspace.QDy[62] + acadoWorkspace.evGx[237]*acadoWorkspace.QDy[63] + acadoWorkspace.evGx[241]*acadoWorkspace.QDy[64] + acadoWorkspace.evGx[245]*acadoWorkspace.QDy[65] + acadoWorkspace.evGx[249]*acadoWorkspace.QDy[66] + acadoWorkspace.evGx[253]*acadoWorkspace.QDy[67] + acadoWorkspace.evGx[257]*acadoWorkspace.QDy[68] + acadoWorkspace.evGx[261]*acadoWorkspace.QDy[69] + acadoWorkspace.evGx[265]*acadoWorkspace.QDy[70] + acadoWorkspace.evGx[269]*acadoWorkspace.QDy[71] + acadoWorkspace.evGx[273]*acadoWorkspace.QDy[72] + acadoWorkspace.evGx[277]*acadoWorkspace.QDy[73] + acadoWorkspace.evGx[281]*acadoWorkspace.QDy[74] + acadoWorkspace.evGx[285]*acadoWorkspace.QDy[75] + acadoWorkspace.evGx[289]*acadoWorkspace.QDy[76] + acadoWorkspace.evGx[293]*acadoWorkspace.QDy[77] + acadoWorkspace.evGx[297]*acadoWorkspace.QDy[78] + acadoWorkspace.evGx[301]*acadoWorkspace.QDy[79] + acadoWorkspace.evGx[305]*acadoWorkspace.QDy[80] + acadoWorkspace.evGx[309]*acadoWorkspace.QDy[81] + acadoWorkspace.evGx[313]*acadoWorkspace.QDy[82] + acadoWorkspace.evGx[317]*acadoWorkspace.QDy[83]; +acadoWorkspace.g[2] = + acadoWorkspace.evGx[2]*acadoWorkspace.QDy[4] + acadoWorkspace.evGx[6]*acadoWorkspace.QDy[5] + acadoWorkspace.evGx[10]*acadoWorkspace.QDy[6] + acadoWorkspace.evGx[14]*acadoWorkspace.QDy[7] + acadoWorkspace.evGx[18]*acadoWorkspace.QDy[8] + acadoWorkspace.evGx[22]*acadoWorkspace.QDy[9] + acadoWorkspace.evGx[26]*acadoWorkspace.QDy[10] + acadoWorkspace.evGx[30]*acadoWorkspace.QDy[11] + acadoWorkspace.evGx[34]*acadoWorkspace.QDy[12] + acadoWorkspace.evGx[38]*acadoWorkspace.QDy[13] + acadoWorkspace.evGx[42]*acadoWorkspace.QDy[14] + acadoWorkspace.evGx[46]*acadoWorkspace.QDy[15] + acadoWorkspace.evGx[50]*acadoWorkspace.QDy[16] + acadoWorkspace.evGx[54]*acadoWorkspace.QDy[17] + acadoWorkspace.evGx[58]*acadoWorkspace.QDy[18] + acadoWorkspace.evGx[62]*acadoWorkspace.QDy[19] + acadoWorkspace.evGx[66]*acadoWorkspace.QDy[20] + acadoWorkspace.evGx[70]*acadoWorkspace.QDy[21] + acadoWorkspace.evGx[74]*acadoWorkspace.QDy[22] + acadoWorkspace.evGx[78]*acadoWorkspace.QDy[23] + acadoWorkspace.evGx[82]*acadoWorkspace.QDy[24] + acadoWorkspace.evGx[86]*acadoWorkspace.QDy[25] + acadoWorkspace.evGx[90]*acadoWorkspace.QDy[26] + acadoWorkspace.evGx[94]*acadoWorkspace.QDy[27] + acadoWorkspace.evGx[98]*acadoWorkspace.QDy[28] + acadoWorkspace.evGx[102]*acadoWorkspace.QDy[29] + acadoWorkspace.evGx[106]*acadoWorkspace.QDy[30] + acadoWorkspace.evGx[110]*acadoWorkspace.QDy[31] + acadoWorkspace.evGx[114]*acadoWorkspace.QDy[32] + acadoWorkspace.evGx[118]*acadoWorkspace.QDy[33] + acadoWorkspace.evGx[122]*acadoWorkspace.QDy[34] + acadoWorkspace.evGx[126]*acadoWorkspace.QDy[35] + acadoWorkspace.evGx[130]*acadoWorkspace.QDy[36] + acadoWorkspace.evGx[134]*acadoWorkspace.QDy[37] + acadoWorkspace.evGx[138]*acadoWorkspace.QDy[38] + acadoWorkspace.evGx[142]*acadoWorkspace.QDy[39] + acadoWorkspace.evGx[146]*acadoWorkspace.QDy[40] + acadoWorkspace.evGx[150]*acadoWorkspace.QDy[41] + acadoWorkspace.evGx[154]*acadoWorkspace.QDy[42] + acadoWorkspace.evGx[158]*acadoWorkspace.QDy[43] + acadoWorkspace.evGx[162]*acadoWorkspace.QDy[44] + acadoWorkspace.evGx[166]*acadoWorkspace.QDy[45] + acadoWorkspace.evGx[170]*acadoWorkspace.QDy[46] + acadoWorkspace.evGx[174]*acadoWorkspace.QDy[47] + acadoWorkspace.evGx[178]*acadoWorkspace.QDy[48] + acadoWorkspace.evGx[182]*acadoWorkspace.QDy[49] + acadoWorkspace.evGx[186]*acadoWorkspace.QDy[50] + acadoWorkspace.evGx[190]*acadoWorkspace.QDy[51] + acadoWorkspace.evGx[194]*acadoWorkspace.QDy[52] + acadoWorkspace.evGx[198]*acadoWorkspace.QDy[53] + acadoWorkspace.evGx[202]*acadoWorkspace.QDy[54] + acadoWorkspace.evGx[206]*acadoWorkspace.QDy[55] + acadoWorkspace.evGx[210]*acadoWorkspace.QDy[56] + acadoWorkspace.evGx[214]*acadoWorkspace.QDy[57] + acadoWorkspace.evGx[218]*acadoWorkspace.QDy[58] + acadoWorkspace.evGx[222]*acadoWorkspace.QDy[59] + acadoWorkspace.evGx[226]*acadoWorkspace.QDy[60] + acadoWorkspace.evGx[230]*acadoWorkspace.QDy[61] + acadoWorkspace.evGx[234]*acadoWorkspace.QDy[62] + acadoWorkspace.evGx[238]*acadoWorkspace.QDy[63] + acadoWorkspace.evGx[242]*acadoWorkspace.QDy[64] + acadoWorkspace.evGx[246]*acadoWorkspace.QDy[65] + acadoWorkspace.evGx[250]*acadoWorkspace.QDy[66] + acadoWorkspace.evGx[254]*acadoWorkspace.QDy[67] + acadoWorkspace.evGx[258]*acadoWorkspace.QDy[68] + acadoWorkspace.evGx[262]*acadoWorkspace.QDy[69] + acadoWorkspace.evGx[266]*acadoWorkspace.QDy[70] + acadoWorkspace.evGx[270]*acadoWorkspace.QDy[71] + acadoWorkspace.evGx[274]*acadoWorkspace.QDy[72] + acadoWorkspace.evGx[278]*acadoWorkspace.QDy[73] + acadoWorkspace.evGx[282]*acadoWorkspace.QDy[74] + acadoWorkspace.evGx[286]*acadoWorkspace.QDy[75] + acadoWorkspace.evGx[290]*acadoWorkspace.QDy[76] + acadoWorkspace.evGx[294]*acadoWorkspace.QDy[77] + acadoWorkspace.evGx[298]*acadoWorkspace.QDy[78] + acadoWorkspace.evGx[302]*acadoWorkspace.QDy[79] + acadoWorkspace.evGx[306]*acadoWorkspace.QDy[80] + acadoWorkspace.evGx[310]*acadoWorkspace.QDy[81] + acadoWorkspace.evGx[314]*acadoWorkspace.QDy[82] + acadoWorkspace.evGx[318]*acadoWorkspace.QDy[83]; +acadoWorkspace.g[3] = + acadoWorkspace.evGx[3]*acadoWorkspace.QDy[4] + acadoWorkspace.evGx[7]*acadoWorkspace.QDy[5] + acadoWorkspace.evGx[11]*acadoWorkspace.QDy[6] + acadoWorkspace.evGx[15]*acadoWorkspace.QDy[7] + acadoWorkspace.evGx[19]*acadoWorkspace.QDy[8] + acadoWorkspace.evGx[23]*acadoWorkspace.QDy[9] + acadoWorkspace.evGx[27]*acadoWorkspace.QDy[10] + acadoWorkspace.evGx[31]*acadoWorkspace.QDy[11] + acadoWorkspace.evGx[35]*acadoWorkspace.QDy[12] + acadoWorkspace.evGx[39]*acadoWorkspace.QDy[13] + acadoWorkspace.evGx[43]*acadoWorkspace.QDy[14] + acadoWorkspace.evGx[47]*acadoWorkspace.QDy[15] + acadoWorkspace.evGx[51]*acadoWorkspace.QDy[16] + acadoWorkspace.evGx[55]*acadoWorkspace.QDy[17] + acadoWorkspace.evGx[59]*acadoWorkspace.QDy[18] + acadoWorkspace.evGx[63]*acadoWorkspace.QDy[19] + acadoWorkspace.evGx[67]*acadoWorkspace.QDy[20] + acadoWorkspace.evGx[71]*acadoWorkspace.QDy[21] + acadoWorkspace.evGx[75]*acadoWorkspace.QDy[22] + acadoWorkspace.evGx[79]*acadoWorkspace.QDy[23] + acadoWorkspace.evGx[83]*acadoWorkspace.QDy[24] + acadoWorkspace.evGx[87]*acadoWorkspace.QDy[25] + acadoWorkspace.evGx[91]*acadoWorkspace.QDy[26] + acadoWorkspace.evGx[95]*acadoWorkspace.QDy[27] + acadoWorkspace.evGx[99]*acadoWorkspace.QDy[28] + acadoWorkspace.evGx[103]*acadoWorkspace.QDy[29] + acadoWorkspace.evGx[107]*acadoWorkspace.QDy[30] + acadoWorkspace.evGx[111]*acadoWorkspace.QDy[31] + acadoWorkspace.evGx[115]*acadoWorkspace.QDy[32] + acadoWorkspace.evGx[119]*acadoWorkspace.QDy[33] + acadoWorkspace.evGx[123]*acadoWorkspace.QDy[34] + acadoWorkspace.evGx[127]*acadoWorkspace.QDy[35] + acadoWorkspace.evGx[131]*acadoWorkspace.QDy[36] + acadoWorkspace.evGx[135]*acadoWorkspace.QDy[37] + acadoWorkspace.evGx[139]*acadoWorkspace.QDy[38] + acadoWorkspace.evGx[143]*acadoWorkspace.QDy[39] + acadoWorkspace.evGx[147]*acadoWorkspace.QDy[40] + acadoWorkspace.evGx[151]*acadoWorkspace.QDy[41] + acadoWorkspace.evGx[155]*acadoWorkspace.QDy[42] + acadoWorkspace.evGx[159]*acadoWorkspace.QDy[43] + acadoWorkspace.evGx[163]*acadoWorkspace.QDy[44] + acadoWorkspace.evGx[167]*acadoWorkspace.QDy[45] + acadoWorkspace.evGx[171]*acadoWorkspace.QDy[46] + acadoWorkspace.evGx[175]*acadoWorkspace.QDy[47] + acadoWorkspace.evGx[179]*acadoWorkspace.QDy[48] + acadoWorkspace.evGx[183]*acadoWorkspace.QDy[49] + acadoWorkspace.evGx[187]*acadoWorkspace.QDy[50] + acadoWorkspace.evGx[191]*acadoWorkspace.QDy[51] + acadoWorkspace.evGx[195]*acadoWorkspace.QDy[52] + acadoWorkspace.evGx[199]*acadoWorkspace.QDy[53] + acadoWorkspace.evGx[203]*acadoWorkspace.QDy[54] + acadoWorkspace.evGx[207]*acadoWorkspace.QDy[55] + acadoWorkspace.evGx[211]*acadoWorkspace.QDy[56] + acadoWorkspace.evGx[215]*acadoWorkspace.QDy[57] + acadoWorkspace.evGx[219]*acadoWorkspace.QDy[58] + acadoWorkspace.evGx[223]*acadoWorkspace.QDy[59] + acadoWorkspace.evGx[227]*acadoWorkspace.QDy[60] + acadoWorkspace.evGx[231]*acadoWorkspace.QDy[61] + acadoWorkspace.evGx[235]*acadoWorkspace.QDy[62] + acadoWorkspace.evGx[239]*acadoWorkspace.QDy[63] + acadoWorkspace.evGx[243]*acadoWorkspace.QDy[64] + acadoWorkspace.evGx[247]*acadoWorkspace.QDy[65] + acadoWorkspace.evGx[251]*acadoWorkspace.QDy[66] + acadoWorkspace.evGx[255]*acadoWorkspace.QDy[67] + acadoWorkspace.evGx[259]*acadoWorkspace.QDy[68] + acadoWorkspace.evGx[263]*acadoWorkspace.QDy[69] + acadoWorkspace.evGx[267]*acadoWorkspace.QDy[70] + acadoWorkspace.evGx[271]*acadoWorkspace.QDy[71] + acadoWorkspace.evGx[275]*acadoWorkspace.QDy[72] + acadoWorkspace.evGx[279]*acadoWorkspace.QDy[73] + acadoWorkspace.evGx[283]*acadoWorkspace.QDy[74] + acadoWorkspace.evGx[287]*acadoWorkspace.QDy[75] + acadoWorkspace.evGx[291]*acadoWorkspace.QDy[76] + acadoWorkspace.evGx[295]*acadoWorkspace.QDy[77] + acadoWorkspace.evGx[299]*acadoWorkspace.QDy[78] + acadoWorkspace.evGx[303]*acadoWorkspace.QDy[79] + acadoWorkspace.evGx[307]*acadoWorkspace.QDy[80] + acadoWorkspace.evGx[311]*acadoWorkspace.QDy[81] + acadoWorkspace.evGx[315]*acadoWorkspace.QDy[82] + acadoWorkspace.evGx[319]*acadoWorkspace.QDy[83]; + + +acado_multEQDy( acadoWorkspace.E, &(acadoWorkspace.QDy[ 4 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 4 ]), &(acadoWorkspace.QDy[ 8 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.QDy[ 12 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.QDy[ 16 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 40 ]), &(acadoWorkspace.QDy[ 20 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QDy[ 28 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.QDy[ 32 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QDy[ 40 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.QDy[ 68 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QDy[ 72 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.QDy[ 76 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.QDy[ 80 ]), &(acadoWorkspace.g[ 4 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 8 ]), &(acadoWorkspace.QDy[ 8 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 16 ]), &(acadoWorkspace.QDy[ 12 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 28 ]), &(acadoWorkspace.QDy[ 16 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 44 ]), &(acadoWorkspace.QDy[ 20 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 64 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 88 ]), &(acadoWorkspace.QDy[ 28 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.QDy[ 32 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QDy[ 40 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 548 ]), &(acadoWorkspace.QDy[ 68 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.QDy[ 72 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.QDy[ 76 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.QDy[ 80 ]), &(acadoWorkspace.g[ 5 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 20 ]), &(acadoWorkspace.QDy[ 12 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 32 ]), &(acadoWorkspace.QDy[ 16 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QDy[ 20 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 68 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 92 ]), &(acadoWorkspace.QDy[ 28 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QDy[ 32 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.QDy[ 40 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QDy[ 68 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 620 ]), &(acadoWorkspace.QDy[ 72 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.QDy[ 76 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.QDy[ 80 ]), &(acadoWorkspace.g[ 6 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.QDy[ 16 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 52 ]), &(acadoWorkspace.QDy[ 20 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QDy[ 28 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 124 ]), &(acadoWorkspace.QDy[ 32 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QDy[ 40 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 556 ]), &(acadoWorkspace.QDy[ 68 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QDy[ 72 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 696 ]), &(acadoWorkspace.QDy[ 76 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 772 ]), &(acadoWorkspace.QDy[ 80 ]), &(acadoWorkspace.g[ 7 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 56 ]), &(acadoWorkspace.QDy[ 20 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 76 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 100 ]), &(acadoWorkspace.QDy[ 28 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 128 ]), &(acadoWorkspace.QDy[ 32 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 160 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 196 ]), &(acadoWorkspace.QDy[ 40 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 560 ]), &(acadoWorkspace.QDy[ 68 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 628 ]), &(acadoWorkspace.QDy[ 72 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 700 ]), &(acadoWorkspace.QDy[ 76 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 776 ]), &(acadoWorkspace.QDy[ 80 ]), &(acadoWorkspace.g[ 8 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 80 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 104 ]), &(acadoWorkspace.QDy[ 28 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.QDy[ 32 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 164 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 200 ]), &(acadoWorkspace.QDy[ 40 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QDy[ 68 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 632 ]), &(acadoWorkspace.QDy[ 72 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 704 ]), &(acadoWorkspace.QDy[ 76 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 780 ]), &(acadoWorkspace.QDy[ 80 ]), &(acadoWorkspace.g[ 9 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QDy[ 28 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 136 ]), &(acadoWorkspace.QDy[ 32 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QDy[ 40 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 244 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 568 ]), &(acadoWorkspace.QDy[ 68 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 636 ]), &(acadoWorkspace.QDy[ 72 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 708 ]), &(acadoWorkspace.QDy[ 76 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 784 ]), &(acadoWorkspace.QDy[ 80 ]), &(acadoWorkspace.g[ 10 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 140 ]), &(acadoWorkspace.QDy[ 32 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 172 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 208 ]), &(acadoWorkspace.QDy[ 40 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 248 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 292 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 340 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 572 ]), &(acadoWorkspace.QDy[ 68 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 640 ]), &(acadoWorkspace.QDy[ 72 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 712 ]), &(acadoWorkspace.QDy[ 76 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 788 ]), &(acadoWorkspace.QDy[ 80 ]), &(acadoWorkspace.g[ 11 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 176 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 212 ]), &(acadoWorkspace.QDy[ 40 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 296 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 344 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QDy[ 68 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 644 ]), &(acadoWorkspace.QDy[ 72 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 716 ]), &(acadoWorkspace.QDy[ 76 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 792 ]), &(acadoWorkspace.QDy[ 80 ]), &(acadoWorkspace.g[ 12 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QDy[ 40 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 256 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 400 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 580 ]), &(acadoWorkspace.QDy[ 68 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 648 ]), &(acadoWorkspace.QDy[ 72 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 720 ]), &(acadoWorkspace.QDy[ 76 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 796 ]), &(acadoWorkspace.QDy[ 80 ]), &(acadoWorkspace.g[ 13 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 260 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 304 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 352 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 404 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 460 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 520 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 584 ]), &(acadoWorkspace.QDy[ 68 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 652 ]), &(acadoWorkspace.QDy[ 72 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 724 ]), &(acadoWorkspace.QDy[ 76 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 800 ]), &(acadoWorkspace.QDy[ 80 ]), &(acadoWorkspace.g[ 14 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 308 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 15 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 356 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 15 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 15 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 464 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 15 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 524 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 15 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QDy[ 68 ]), &(acadoWorkspace.g[ 15 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 656 ]), &(acadoWorkspace.QDy[ 72 ]), &(acadoWorkspace.g[ 15 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 728 ]), &(acadoWorkspace.QDy[ 76 ]), &(acadoWorkspace.g[ 15 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 804 ]), &(acadoWorkspace.QDy[ 80 ]), &(acadoWorkspace.g[ 15 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 16 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 412 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 16 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 16 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 16 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 592 ]), &(acadoWorkspace.QDy[ 68 ]), &(acadoWorkspace.g[ 16 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 660 ]), &(acadoWorkspace.QDy[ 72 ]), &(acadoWorkspace.g[ 16 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 732 ]), &(acadoWorkspace.QDy[ 76 ]), &(acadoWorkspace.g[ 16 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 808 ]), &(acadoWorkspace.QDy[ 80 ]), &(acadoWorkspace.g[ 16 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 416 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 17 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 472 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 17 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 532 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 17 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 596 ]), &(acadoWorkspace.QDy[ 68 ]), &(acadoWorkspace.g[ 17 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 664 ]), &(acadoWorkspace.QDy[ 72 ]), &(acadoWorkspace.g[ 17 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 736 ]), &(acadoWorkspace.QDy[ 76 ]), &(acadoWorkspace.g[ 17 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 812 ]), &(acadoWorkspace.QDy[ 80 ]), &(acadoWorkspace.g[ 17 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 476 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 18 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 536 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 18 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QDy[ 68 ]), &(acadoWorkspace.g[ 18 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 668 ]), &(acadoWorkspace.QDy[ 72 ]), &(acadoWorkspace.g[ 18 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 740 ]), &(acadoWorkspace.QDy[ 76 ]), &(acadoWorkspace.g[ 18 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 816 ]), &(acadoWorkspace.QDy[ 80 ]), &(acadoWorkspace.g[ 18 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 19 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 604 ]), &(acadoWorkspace.QDy[ 68 ]), &(acadoWorkspace.g[ 19 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 672 ]), &(acadoWorkspace.QDy[ 72 ]), &(acadoWorkspace.g[ 19 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 744 ]), &(acadoWorkspace.QDy[ 76 ]), &(acadoWorkspace.g[ 19 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 820 ]), &(acadoWorkspace.QDy[ 80 ]), &(acadoWorkspace.g[ 19 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 608 ]), &(acadoWorkspace.QDy[ 68 ]), &(acadoWorkspace.g[ 20 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 676 ]), &(acadoWorkspace.QDy[ 72 ]), &(acadoWorkspace.g[ 20 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 748 ]), &(acadoWorkspace.QDy[ 76 ]), &(acadoWorkspace.g[ 20 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 824 ]), &(acadoWorkspace.QDy[ 80 ]), &(acadoWorkspace.g[ 20 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 680 ]), &(acadoWorkspace.QDy[ 72 ]), &(acadoWorkspace.g[ 21 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 752 ]), &(acadoWorkspace.QDy[ 76 ]), &(acadoWorkspace.g[ 21 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 828 ]), &(acadoWorkspace.QDy[ 80 ]), &(acadoWorkspace.g[ 21 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 756 ]), &(acadoWorkspace.QDy[ 76 ]), &(acadoWorkspace.g[ 22 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 832 ]), &(acadoWorkspace.QDy[ 80 ]), &(acadoWorkspace.g[ 22 ]) ); +acado_multEQDy( &(acadoWorkspace.E[ 836 ]), &(acadoWorkspace.QDy[ 80 ]), &(acadoWorkspace.g[ 23 ]) ); + +acadoWorkspace.lb[0] = acadoWorkspace.Dx0[0]; +acadoWorkspace.lb[1] = acadoWorkspace.Dx0[1]; +acadoWorkspace.lb[2] = acadoWorkspace.Dx0[2]; +acadoWorkspace.lb[3] = acadoWorkspace.Dx0[3]; +acadoWorkspace.ub[0] = acadoWorkspace.Dx0[0]; +acadoWorkspace.ub[1] = acadoWorkspace.Dx0[1]; +acadoWorkspace.ub[2] = acadoWorkspace.Dx0[2]; +acadoWorkspace.ub[3] = acadoWorkspace.Dx0[3]; +} + +void acado_expand( ) +{ +acadoVariables.x[0] += acadoWorkspace.x[0]; +acadoVariables.x[1] += acadoWorkspace.x[1]; +acadoVariables.x[2] += acadoWorkspace.x[2]; +acadoVariables.x[3] += acadoWorkspace.x[3]; + +acadoVariables.u[0] += acadoWorkspace.x[4]; +acadoVariables.u[1] += acadoWorkspace.x[5]; +acadoVariables.u[2] += acadoWorkspace.x[6]; +acadoVariables.u[3] += acadoWorkspace.x[7]; +acadoVariables.u[4] += acadoWorkspace.x[8]; +acadoVariables.u[5] += acadoWorkspace.x[9]; +acadoVariables.u[6] += acadoWorkspace.x[10]; +acadoVariables.u[7] += acadoWorkspace.x[11]; +acadoVariables.u[8] += acadoWorkspace.x[12]; +acadoVariables.u[9] += acadoWorkspace.x[13]; +acadoVariables.u[10] += acadoWorkspace.x[14]; +acadoVariables.u[11] += acadoWorkspace.x[15]; +acadoVariables.u[12] += acadoWorkspace.x[16]; +acadoVariables.u[13] += acadoWorkspace.x[17]; +acadoVariables.u[14] += acadoWorkspace.x[18]; +acadoVariables.u[15] += acadoWorkspace.x[19]; +acadoVariables.u[16] += acadoWorkspace.x[20]; +acadoVariables.u[17] += acadoWorkspace.x[21]; +acadoVariables.u[18] += acadoWorkspace.x[22]; +acadoVariables.u[19] += acadoWorkspace.x[23]; + +acadoVariables.x[4] += + acadoWorkspace.evGx[0]*acadoWorkspace.x[0] + acadoWorkspace.evGx[1]*acadoWorkspace.x[1] + acadoWorkspace.evGx[2]*acadoWorkspace.x[2] + acadoWorkspace.evGx[3]*acadoWorkspace.x[3] + acadoWorkspace.d[0]; +acadoVariables.x[5] += + acadoWorkspace.evGx[4]*acadoWorkspace.x[0] + acadoWorkspace.evGx[5]*acadoWorkspace.x[1] + acadoWorkspace.evGx[6]*acadoWorkspace.x[2] + acadoWorkspace.evGx[7]*acadoWorkspace.x[3] + acadoWorkspace.d[1]; +acadoVariables.x[6] += + acadoWorkspace.evGx[8]*acadoWorkspace.x[0] + acadoWorkspace.evGx[9]*acadoWorkspace.x[1] + acadoWorkspace.evGx[10]*acadoWorkspace.x[2] + acadoWorkspace.evGx[11]*acadoWorkspace.x[3] + acadoWorkspace.d[2]; +acadoVariables.x[7] += + acadoWorkspace.evGx[12]*acadoWorkspace.x[0] + acadoWorkspace.evGx[13]*acadoWorkspace.x[1] + acadoWorkspace.evGx[14]*acadoWorkspace.x[2] + acadoWorkspace.evGx[15]*acadoWorkspace.x[3] + acadoWorkspace.d[3]; +acadoVariables.x[8] += + acadoWorkspace.evGx[16]*acadoWorkspace.x[0] + acadoWorkspace.evGx[17]*acadoWorkspace.x[1] + acadoWorkspace.evGx[18]*acadoWorkspace.x[2] + acadoWorkspace.evGx[19]*acadoWorkspace.x[3] + acadoWorkspace.d[4]; +acadoVariables.x[9] += + acadoWorkspace.evGx[20]*acadoWorkspace.x[0] + acadoWorkspace.evGx[21]*acadoWorkspace.x[1] + acadoWorkspace.evGx[22]*acadoWorkspace.x[2] + acadoWorkspace.evGx[23]*acadoWorkspace.x[3] + acadoWorkspace.d[5]; +acadoVariables.x[10] += + acadoWorkspace.evGx[24]*acadoWorkspace.x[0] + acadoWorkspace.evGx[25]*acadoWorkspace.x[1] + acadoWorkspace.evGx[26]*acadoWorkspace.x[2] + acadoWorkspace.evGx[27]*acadoWorkspace.x[3] + acadoWorkspace.d[6]; +acadoVariables.x[11] += + acadoWorkspace.evGx[28]*acadoWorkspace.x[0] + acadoWorkspace.evGx[29]*acadoWorkspace.x[1] + acadoWorkspace.evGx[30]*acadoWorkspace.x[2] + acadoWorkspace.evGx[31]*acadoWorkspace.x[3] + acadoWorkspace.d[7]; +acadoVariables.x[12] += + acadoWorkspace.evGx[32]*acadoWorkspace.x[0] + acadoWorkspace.evGx[33]*acadoWorkspace.x[1] + acadoWorkspace.evGx[34]*acadoWorkspace.x[2] + acadoWorkspace.evGx[35]*acadoWorkspace.x[3] + acadoWorkspace.d[8]; +acadoVariables.x[13] += + acadoWorkspace.evGx[36]*acadoWorkspace.x[0] + acadoWorkspace.evGx[37]*acadoWorkspace.x[1] + acadoWorkspace.evGx[38]*acadoWorkspace.x[2] + acadoWorkspace.evGx[39]*acadoWorkspace.x[3] + acadoWorkspace.d[9]; +acadoVariables.x[14] += + acadoWorkspace.evGx[40]*acadoWorkspace.x[0] + acadoWorkspace.evGx[41]*acadoWorkspace.x[1] + acadoWorkspace.evGx[42]*acadoWorkspace.x[2] + acadoWorkspace.evGx[43]*acadoWorkspace.x[3] + acadoWorkspace.d[10]; +acadoVariables.x[15] += + acadoWorkspace.evGx[44]*acadoWorkspace.x[0] + acadoWorkspace.evGx[45]*acadoWorkspace.x[1] + acadoWorkspace.evGx[46]*acadoWorkspace.x[2] + acadoWorkspace.evGx[47]*acadoWorkspace.x[3] + acadoWorkspace.d[11]; +acadoVariables.x[16] += + acadoWorkspace.evGx[48]*acadoWorkspace.x[0] + acadoWorkspace.evGx[49]*acadoWorkspace.x[1] + acadoWorkspace.evGx[50]*acadoWorkspace.x[2] + acadoWorkspace.evGx[51]*acadoWorkspace.x[3] + acadoWorkspace.d[12]; +acadoVariables.x[17] += + acadoWorkspace.evGx[52]*acadoWorkspace.x[0] + acadoWorkspace.evGx[53]*acadoWorkspace.x[1] + acadoWorkspace.evGx[54]*acadoWorkspace.x[2] + acadoWorkspace.evGx[55]*acadoWorkspace.x[3] + acadoWorkspace.d[13]; +acadoVariables.x[18] += + acadoWorkspace.evGx[56]*acadoWorkspace.x[0] + acadoWorkspace.evGx[57]*acadoWorkspace.x[1] + acadoWorkspace.evGx[58]*acadoWorkspace.x[2] + acadoWorkspace.evGx[59]*acadoWorkspace.x[3] + acadoWorkspace.d[14]; +acadoVariables.x[19] += + acadoWorkspace.evGx[60]*acadoWorkspace.x[0] + acadoWorkspace.evGx[61]*acadoWorkspace.x[1] + acadoWorkspace.evGx[62]*acadoWorkspace.x[2] + acadoWorkspace.evGx[63]*acadoWorkspace.x[3] + acadoWorkspace.d[15]; +acadoVariables.x[20] += + acadoWorkspace.evGx[64]*acadoWorkspace.x[0] + acadoWorkspace.evGx[65]*acadoWorkspace.x[1] + acadoWorkspace.evGx[66]*acadoWorkspace.x[2] + acadoWorkspace.evGx[67]*acadoWorkspace.x[3] + acadoWorkspace.d[16]; +acadoVariables.x[21] += + acadoWorkspace.evGx[68]*acadoWorkspace.x[0] + acadoWorkspace.evGx[69]*acadoWorkspace.x[1] + acadoWorkspace.evGx[70]*acadoWorkspace.x[2] + acadoWorkspace.evGx[71]*acadoWorkspace.x[3] + acadoWorkspace.d[17]; +acadoVariables.x[22] += + acadoWorkspace.evGx[72]*acadoWorkspace.x[0] + acadoWorkspace.evGx[73]*acadoWorkspace.x[1] + acadoWorkspace.evGx[74]*acadoWorkspace.x[2] + acadoWorkspace.evGx[75]*acadoWorkspace.x[3] + acadoWorkspace.d[18]; +acadoVariables.x[23] += + acadoWorkspace.evGx[76]*acadoWorkspace.x[0] + acadoWorkspace.evGx[77]*acadoWorkspace.x[1] + acadoWorkspace.evGx[78]*acadoWorkspace.x[2] + acadoWorkspace.evGx[79]*acadoWorkspace.x[3] + acadoWorkspace.d[19]; +acadoVariables.x[24] += + acadoWorkspace.evGx[80]*acadoWorkspace.x[0] + acadoWorkspace.evGx[81]*acadoWorkspace.x[1] + acadoWorkspace.evGx[82]*acadoWorkspace.x[2] + acadoWorkspace.evGx[83]*acadoWorkspace.x[3] + acadoWorkspace.d[20]; +acadoVariables.x[25] += + acadoWorkspace.evGx[84]*acadoWorkspace.x[0] + acadoWorkspace.evGx[85]*acadoWorkspace.x[1] + acadoWorkspace.evGx[86]*acadoWorkspace.x[2] + acadoWorkspace.evGx[87]*acadoWorkspace.x[3] + acadoWorkspace.d[21]; +acadoVariables.x[26] += + acadoWorkspace.evGx[88]*acadoWorkspace.x[0] + acadoWorkspace.evGx[89]*acadoWorkspace.x[1] + acadoWorkspace.evGx[90]*acadoWorkspace.x[2] + acadoWorkspace.evGx[91]*acadoWorkspace.x[3] + acadoWorkspace.d[22]; +acadoVariables.x[27] += + acadoWorkspace.evGx[92]*acadoWorkspace.x[0] + acadoWorkspace.evGx[93]*acadoWorkspace.x[1] + acadoWorkspace.evGx[94]*acadoWorkspace.x[2] + acadoWorkspace.evGx[95]*acadoWorkspace.x[3] + acadoWorkspace.d[23]; +acadoVariables.x[28] += + acadoWorkspace.evGx[96]*acadoWorkspace.x[0] + acadoWorkspace.evGx[97]*acadoWorkspace.x[1] + acadoWorkspace.evGx[98]*acadoWorkspace.x[2] + acadoWorkspace.evGx[99]*acadoWorkspace.x[3] + acadoWorkspace.d[24]; +acadoVariables.x[29] += + acadoWorkspace.evGx[100]*acadoWorkspace.x[0] + acadoWorkspace.evGx[101]*acadoWorkspace.x[1] + acadoWorkspace.evGx[102]*acadoWorkspace.x[2] + acadoWorkspace.evGx[103]*acadoWorkspace.x[3] + acadoWorkspace.d[25]; +acadoVariables.x[30] += + acadoWorkspace.evGx[104]*acadoWorkspace.x[0] + acadoWorkspace.evGx[105]*acadoWorkspace.x[1] + acadoWorkspace.evGx[106]*acadoWorkspace.x[2] + acadoWorkspace.evGx[107]*acadoWorkspace.x[3] + acadoWorkspace.d[26]; +acadoVariables.x[31] += + acadoWorkspace.evGx[108]*acadoWorkspace.x[0] + acadoWorkspace.evGx[109]*acadoWorkspace.x[1] + acadoWorkspace.evGx[110]*acadoWorkspace.x[2] + acadoWorkspace.evGx[111]*acadoWorkspace.x[3] + acadoWorkspace.d[27]; +acadoVariables.x[32] += + acadoWorkspace.evGx[112]*acadoWorkspace.x[0] + acadoWorkspace.evGx[113]*acadoWorkspace.x[1] + acadoWorkspace.evGx[114]*acadoWorkspace.x[2] + acadoWorkspace.evGx[115]*acadoWorkspace.x[3] + acadoWorkspace.d[28]; +acadoVariables.x[33] += + acadoWorkspace.evGx[116]*acadoWorkspace.x[0] + acadoWorkspace.evGx[117]*acadoWorkspace.x[1] + acadoWorkspace.evGx[118]*acadoWorkspace.x[2] + acadoWorkspace.evGx[119]*acadoWorkspace.x[3] + acadoWorkspace.d[29]; +acadoVariables.x[34] += + acadoWorkspace.evGx[120]*acadoWorkspace.x[0] + acadoWorkspace.evGx[121]*acadoWorkspace.x[1] + acadoWorkspace.evGx[122]*acadoWorkspace.x[2] + acadoWorkspace.evGx[123]*acadoWorkspace.x[3] + acadoWorkspace.d[30]; +acadoVariables.x[35] += + acadoWorkspace.evGx[124]*acadoWorkspace.x[0] + acadoWorkspace.evGx[125]*acadoWorkspace.x[1] + acadoWorkspace.evGx[126]*acadoWorkspace.x[2] + acadoWorkspace.evGx[127]*acadoWorkspace.x[3] + acadoWorkspace.d[31]; +acadoVariables.x[36] += + acadoWorkspace.evGx[128]*acadoWorkspace.x[0] + acadoWorkspace.evGx[129]*acadoWorkspace.x[1] + acadoWorkspace.evGx[130]*acadoWorkspace.x[2] + acadoWorkspace.evGx[131]*acadoWorkspace.x[3] + acadoWorkspace.d[32]; +acadoVariables.x[37] += + acadoWorkspace.evGx[132]*acadoWorkspace.x[0] + acadoWorkspace.evGx[133]*acadoWorkspace.x[1] + acadoWorkspace.evGx[134]*acadoWorkspace.x[2] + acadoWorkspace.evGx[135]*acadoWorkspace.x[3] + acadoWorkspace.d[33]; +acadoVariables.x[38] += + acadoWorkspace.evGx[136]*acadoWorkspace.x[0] + acadoWorkspace.evGx[137]*acadoWorkspace.x[1] + acadoWorkspace.evGx[138]*acadoWorkspace.x[2] + acadoWorkspace.evGx[139]*acadoWorkspace.x[3] + acadoWorkspace.d[34]; +acadoVariables.x[39] += + acadoWorkspace.evGx[140]*acadoWorkspace.x[0] + acadoWorkspace.evGx[141]*acadoWorkspace.x[1] + acadoWorkspace.evGx[142]*acadoWorkspace.x[2] + acadoWorkspace.evGx[143]*acadoWorkspace.x[3] + acadoWorkspace.d[35]; +acadoVariables.x[40] += + acadoWorkspace.evGx[144]*acadoWorkspace.x[0] + acadoWorkspace.evGx[145]*acadoWorkspace.x[1] + acadoWorkspace.evGx[146]*acadoWorkspace.x[2] + acadoWorkspace.evGx[147]*acadoWorkspace.x[3] + acadoWorkspace.d[36]; +acadoVariables.x[41] += + acadoWorkspace.evGx[148]*acadoWorkspace.x[0] + acadoWorkspace.evGx[149]*acadoWorkspace.x[1] + acadoWorkspace.evGx[150]*acadoWorkspace.x[2] + acadoWorkspace.evGx[151]*acadoWorkspace.x[3] + acadoWorkspace.d[37]; +acadoVariables.x[42] += + acadoWorkspace.evGx[152]*acadoWorkspace.x[0] + acadoWorkspace.evGx[153]*acadoWorkspace.x[1] + acadoWorkspace.evGx[154]*acadoWorkspace.x[2] + acadoWorkspace.evGx[155]*acadoWorkspace.x[3] + acadoWorkspace.d[38]; +acadoVariables.x[43] += + acadoWorkspace.evGx[156]*acadoWorkspace.x[0] + acadoWorkspace.evGx[157]*acadoWorkspace.x[1] + acadoWorkspace.evGx[158]*acadoWorkspace.x[2] + acadoWorkspace.evGx[159]*acadoWorkspace.x[3] + acadoWorkspace.d[39]; +acadoVariables.x[44] += + acadoWorkspace.evGx[160]*acadoWorkspace.x[0] + acadoWorkspace.evGx[161]*acadoWorkspace.x[1] + acadoWorkspace.evGx[162]*acadoWorkspace.x[2] + acadoWorkspace.evGx[163]*acadoWorkspace.x[3] + acadoWorkspace.d[40]; +acadoVariables.x[45] += + acadoWorkspace.evGx[164]*acadoWorkspace.x[0] + acadoWorkspace.evGx[165]*acadoWorkspace.x[1] + acadoWorkspace.evGx[166]*acadoWorkspace.x[2] + acadoWorkspace.evGx[167]*acadoWorkspace.x[3] + acadoWorkspace.d[41]; +acadoVariables.x[46] += + acadoWorkspace.evGx[168]*acadoWorkspace.x[0] + acadoWorkspace.evGx[169]*acadoWorkspace.x[1] + acadoWorkspace.evGx[170]*acadoWorkspace.x[2] + acadoWorkspace.evGx[171]*acadoWorkspace.x[3] + acadoWorkspace.d[42]; +acadoVariables.x[47] += + acadoWorkspace.evGx[172]*acadoWorkspace.x[0] + acadoWorkspace.evGx[173]*acadoWorkspace.x[1] + acadoWorkspace.evGx[174]*acadoWorkspace.x[2] + acadoWorkspace.evGx[175]*acadoWorkspace.x[3] + acadoWorkspace.d[43]; +acadoVariables.x[48] += + acadoWorkspace.evGx[176]*acadoWorkspace.x[0] + acadoWorkspace.evGx[177]*acadoWorkspace.x[1] + acadoWorkspace.evGx[178]*acadoWorkspace.x[2] + acadoWorkspace.evGx[179]*acadoWorkspace.x[3] + acadoWorkspace.d[44]; +acadoVariables.x[49] += + acadoWorkspace.evGx[180]*acadoWorkspace.x[0] + acadoWorkspace.evGx[181]*acadoWorkspace.x[1] + acadoWorkspace.evGx[182]*acadoWorkspace.x[2] + acadoWorkspace.evGx[183]*acadoWorkspace.x[3] + acadoWorkspace.d[45]; +acadoVariables.x[50] += + acadoWorkspace.evGx[184]*acadoWorkspace.x[0] + acadoWorkspace.evGx[185]*acadoWorkspace.x[1] + acadoWorkspace.evGx[186]*acadoWorkspace.x[2] + acadoWorkspace.evGx[187]*acadoWorkspace.x[3] + acadoWorkspace.d[46]; +acadoVariables.x[51] += + acadoWorkspace.evGx[188]*acadoWorkspace.x[0] + acadoWorkspace.evGx[189]*acadoWorkspace.x[1] + acadoWorkspace.evGx[190]*acadoWorkspace.x[2] + acadoWorkspace.evGx[191]*acadoWorkspace.x[3] + acadoWorkspace.d[47]; +acadoVariables.x[52] += + acadoWorkspace.evGx[192]*acadoWorkspace.x[0] + acadoWorkspace.evGx[193]*acadoWorkspace.x[1] + acadoWorkspace.evGx[194]*acadoWorkspace.x[2] + acadoWorkspace.evGx[195]*acadoWorkspace.x[3] + acadoWorkspace.d[48]; +acadoVariables.x[53] += + acadoWorkspace.evGx[196]*acadoWorkspace.x[0] + acadoWorkspace.evGx[197]*acadoWorkspace.x[1] + acadoWorkspace.evGx[198]*acadoWorkspace.x[2] + acadoWorkspace.evGx[199]*acadoWorkspace.x[3] + acadoWorkspace.d[49]; +acadoVariables.x[54] += + acadoWorkspace.evGx[200]*acadoWorkspace.x[0] + acadoWorkspace.evGx[201]*acadoWorkspace.x[1] + acadoWorkspace.evGx[202]*acadoWorkspace.x[2] + acadoWorkspace.evGx[203]*acadoWorkspace.x[3] + acadoWorkspace.d[50]; +acadoVariables.x[55] += + acadoWorkspace.evGx[204]*acadoWorkspace.x[0] + acadoWorkspace.evGx[205]*acadoWorkspace.x[1] + acadoWorkspace.evGx[206]*acadoWorkspace.x[2] + acadoWorkspace.evGx[207]*acadoWorkspace.x[3] + acadoWorkspace.d[51]; +acadoVariables.x[56] += + acadoWorkspace.evGx[208]*acadoWorkspace.x[0] + acadoWorkspace.evGx[209]*acadoWorkspace.x[1] + acadoWorkspace.evGx[210]*acadoWorkspace.x[2] + acadoWorkspace.evGx[211]*acadoWorkspace.x[3] + acadoWorkspace.d[52]; +acadoVariables.x[57] += + acadoWorkspace.evGx[212]*acadoWorkspace.x[0] + acadoWorkspace.evGx[213]*acadoWorkspace.x[1] + acadoWorkspace.evGx[214]*acadoWorkspace.x[2] + acadoWorkspace.evGx[215]*acadoWorkspace.x[3] + acadoWorkspace.d[53]; +acadoVariables.x[58] += + acadoWorkspace.evGx[216]*acadoWorkspace.x[0] + acadoWorkspace.evGx[217]*acadoWorkspace.x[1] + acadoWorkspace.evGx[218]*acadoWorkspace.x[2] + acadoWorkspace.evGx[219]*acadoWorkspace.x[3] + acadoWorkspace.d[54]; +acadoVariables.x[59] += + acadoWorkspace.evGx[220]*acadoWorkspace.x[0] + acadoWorkspace.evGx[221]*acadoWorkspace.x[1] + acadoWorkspace.evGx[222]*acadoWorkspace.x[2] + acadoWorkspace.evGx[223]*acadoWorkspace.x[3] + acadoWorkspace.d[55]; +acadoVariables.x[60] += + acadoWorkspace.evGx[224]*acadoWorkspace.x[0] + acadoWorkspace.evGx[225]*acadoWorkspace.x[1] + acadoWorkspace.evGx[226]*acadoWorkspace.x[2] + acadoWorkspace.evGx[227]*acadoWorkspace.x[3] + acadoWorkspace.d[56]; +acadoVariables.x[61] += + acadoWorkspace.evGx[228]*acadoWorkspace.x[0] + acadoWorkspace.evGx[229]*acadoWorkspace.x[1] + acadoWorkspace.evGx[230]*acadoWorkspace.x[2] + acadoWorkspace.evGx[231]*acadoWorkspace.x[3] + acadoWorkspace.d[57]; +acadoVariables.x[62] += + acadoWorkspace.evGx[232]*acadoWorkspace.x[0] + acadoWorkspace.evGx[233]*acadoWorkspace.x[1] + acadoWorkspace.evGx[234]*acadoWorkspace.x[2] + acadoWorkspace.evGx[235]*acadoWorkspace.x[3] + acadoWorkspace.d[58]; +acadoVariables.x[63] += + acadoWorkspace.evGx[236]*acadoWorkspace.x[0] + acadoWorkspace.evGx[237]*acadoWorkspace.x[1] + acadoWorkspace.evGx[238]*acadoWorkspace.x[2] + acadoWorkspace.evGx[239]*acadoWorkspace.x[3] + acadoWorkspace.d[59]; +acadoVariables.x[64] += + acadoWorkspace.evGx[240]*acadoWorkspace.x[0] + acadoWorkspace.evGx[241]*acadoWorkspace.x[1] + acadoWorkspace.evGx[242]*acadoWorkspace.x[2] + acadoWorkspace.evGx[243]*acadoWorkspace.x[3] + acadoWorkspace.d[60]; +acadoVariables.x[65] += + acadoWorkspace.evGx[244]*acadoWorkspace.x[0] + acadoWorkspace.evGx[245]*acadoWorkspace.x[1] + acadoWorkspace.evGx[246]*acadoWorkspace.x[2] + acadoWorkspace.evGx[247]*acadoWorkspace.x[3] + acadoWorkspace.d[61]; +acadoVariables.x[66] += + acadoWorkspace.evGx[248]*acadoWorkspace.x[0] + acadoWorkspace.evGx[249]*acadoWorkspace.x[1] + acadoWorkspace.evGx[250]*acadoWorkspace.x[2] + acadoWorkspace.evGx[251]*acadoWorkspace.x[3] + acadoWorkspace.d[62]; +acadoVariables.x[67] += + acadoWorkspace.evGx[252]*acadoWorkspace.x[0] + acadoWorkspace.evGx[253]*acadoWorkspace.x[1] + acadoWorkspace.evGx[254]*acadoWorkspace.x[2] + acadoWorkspace.evGx[255]*acadoWorkspace.x[3] + acadoWorkspace.d[63]; +acadoVariables.x[68] += + acadoWorkspace.evGx[256]*acadoWorkspace.x[0] + acadoWorkspace.evGx[257]*acadoWorkspace.x[1] + acadoWorkspace.evGx[258]*acadoWorkspace.x[2] + acadoWorkspace.evGx[259]*acadoWorkspace.x[3] + acadoWorkspace.d[64]; +acadoVariables.x[69] += + acadoWorkspace.evGx[260]*acadoWorkspace.x[0] + acadoWorkspace.evGx[261]*acadoWorkspace.x[1] + acadoWorkspace.evGx[262]*acadoWorkspace.x[2] + acadoWorkspace.evGx[263]*acadoWorkspace.x[3] + acadoWorkspace.d[65]; +acadoVariables.x[70] += + acadoWorkspace.evGx[264]*acadoWorkspace.x[0] + acadoWorkspace.evGx[265]*acadoWorkspace.x[1] + acadoWorkspace.evGx[266]*acadoWorkspace.x[2] + acadoWorkspace.evGx[267]*acadoWorkspace.x[3] + acadoWorkspace.d[66]; +acadoVariables.x[71] += + acadoWorkspace.evGx[268]*acadoWorkspace.x[0] + acadoWorkspace.evGx[269]*acadoWorkspace.x[1] + acadoWorkspace.evGx[270]*acadoWorkspace.x[2] + acadoWorkspace.evGx[271]*acadoWorkspace.x[3] + acadoWorkspace.d[67]; +acadoVariables.x[72] += + acadoWorkspace.evGx[272]*acadoWorkspace.x[0] + acadoWorkspace.evGx[273]*acadoWorkspace.x[1] + acadoWorkspace.evGx[274]*acadoWorkspace.x[2] + acadoWorkspace.evGx[275]*acadoWorkspace.x[3] + acadoWorkspace.d[68]; +acadoVariables.x[73] += + acadoWorkspace.evGx[276]*acadoWorkspace.x[0] + acadoWorkspace.evGx[277]*acadoWorkspace.x[1] + acadoWorkspace.evGx[278]*acadoWorkspace.x[2] + acadoWorkspace.evGx[279]*acadoWorkspace.x[3] + acadoWorkspace.d[69]; +acadoVariables.x[74] += + acadoWorkspace.evGx[280]*acadoWorkspace.x[0] + acadoWorkspace.evGx[281]*acadoWorkspace.x[1] + acadoWorkspace.evGx[282]*acadoWorkspace.x[2] + acadoWorkspace.evGx[283]*acadoWorkspace.x[3] + acadoWorkspace.d[70]; +acadoVariables.x[75] += + acadoWorkspace.evGx[284]*acadoWorkspace.x[0] + acadoWorkspace.evGx[285]*acadoWorkspace.x[1] + acadoWorkspace.evGx[286]*acadoWorkspace.x[2] + acadoWorkspace.evGx[287]*acadoWorkspace.x[3] + acadoWorkspace.d[71]; +acadoVariables.x[76] += + acadoWorkspace.evGx[288]*acadoWorkspace.x[0] + acadoWorkspace.evGx[289]*acadoWorkspace.x[1] + acadoWorkspace.evGx[290]*acadoWorkspace.x[2] + acadoWorkspace.evGx[291]*acadoWorkspace.x[3] + acadoWorkspace.d[72]; +acadoVariables.x[77] += + acadoWorkspace.evGx[292]*acadoWorkspace.x[0] + acadoWorkspace.evGx[293]*acadoWorkspace.x[1] + acadoWorkspace.evGx[294]*acadoWorkspace.x[2] + acadoWorkspace.evGx[295]*acadoWorkspace.x[3] + acadoWorkspace.d[73]; +acadoVariables.x[78] += + acadoWorkspace.evGx[296]*acadoWorkspace.x[0] + acadoWorkspace.evGx[297]*acadoWorkspace.x[1] + acadoWorkspace.evGx[298]*acadoWorkspace.x[2] + acadoWorkspace.evGx[299]*acadoWorkspace.x[3] + acadoWorkspace.d[74]; +acadoVariables.x[79] += + acadoWorkspace.evGx[300]*acadoWorkspace.x[0] + acadoWorkspace.evGx[301]*acadoWorkspace.x[1] + acadoWorkspace.evGx[302]*acadoWorkspace.x[2] + acadoWorkspace.evGx[303]*acadoWorkspace.x[3] + acadoWorkspace.d[75]; +acadoVariables.x[80] += + acadoWorkspace.evGx[304]*acadoWorkspace.x[0] + acadoWorkspace.evGx[305]*acadoWorkspace.x[1] + acadoWorkspace.evGx[306]*acadoWorkspace.x[2] + acadoWorkspace.evGx[307]*acadoWorkspace.x[3] + acadoWorkspace.d[76]; +acadoVariables.x[81] += + acadoWorkspace.evGx[308]*acadoWorkspace.x[0] + acadoWorkspace.evGx[309]*acadoWorkspace.x[1] + acadoWorkspace.evGx[310]*acadoWorkspace.x[2] + acadoWorkspace.evGx[311]*acadoWorkspace.x[3] + acadoWorkspace.d[77]; +acadoVariables.x[82] += + acadoWorkspace.evGx[312]*acadoWorkspace.x[0] + acadoWorkspace.evGx[313]*acadoWorkspace.x[1] + acadoWorkspace.evGx[314]*acadoWorkspace.x[2] + acadoWorkspace.evGx[315]*acadoWorkspace.x[3] + acadoWorkspace.d[78]; +acadoVariables.x[83] += + acadoWorkspace.evGx[316]*acadoWorkspace.x[0] + acadoWorkspace.evGx[317]*acadoWorkspace.x[1] + acadoWorkspace.evGx[318]*acadoWorkspace.x[2] + acadoWorkspace.evGx[319]*acadoWorkspace.x[3] + acadoWorkspace.d[79]; + +acado_multEDu( acadoWorkspace.E, &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 4 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 4 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 8 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 8 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 8 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 12 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 16 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 12 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 20 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 12 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 16 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 28 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 16 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 32 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 16 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 16 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 40 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 20 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 44 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 20 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 20 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 52 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 20 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 56 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 20 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 24 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 64 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 24 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 68 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 24 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 24 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 76 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 24 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 80 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 24 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 28 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 88 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 28 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 92 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 28 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 28 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 100 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 28 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 104 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 28 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 28 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 32 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 32 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 32 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 124 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 32 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 128 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 32 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 32 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 136 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 32 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 140 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 32 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 36 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 36 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 36 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 36 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 160 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 36 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 164 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 36 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 36 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 172 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 36 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 176 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 36 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 40 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 40 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 40 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 40 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 196 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 40 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 200 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 40 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 40 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 208 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 40 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 212 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 40 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 40 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 44 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 44 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 44 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 44 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 44 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 44 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 244 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 44 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 248 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 44 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 44 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 256 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 44 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 260 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 44 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 48 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 48 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 48 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 48 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 48 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 48 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 48 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 292 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 48 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 296 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 48 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 48 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 304 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 48 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 308 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 48 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 52 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 52 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 52 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 52 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 52 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 52 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 52 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 340 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 52 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 344 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 52 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 52 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 352 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 52 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 356 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 52 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 52 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 56 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 56 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 56 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 56 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 56 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 56 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 56 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 56 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 56 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 400 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 56 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 404 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 56 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 56 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 412 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 56 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 416 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 56 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 60 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 60 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 60 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 60 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 60 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 60 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 60 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 60 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 60 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 60 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 460 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 60 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 464 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 60 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 60 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 472 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 60 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 476 ]), &(acadoWorkspace.x[ 18 ]), &(acadoVariables.x[ 60 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 64 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 64 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 64 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 64 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 64 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 64 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 64 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 64 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 64 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 64 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 520 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 64 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 524 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 64 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 64 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 532 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 64 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 536 ]), &(acadoWorkspace.x[ 18 ]), &(acadoVariables.x[ 64 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.x[ 19 ]), &(acadoVariables.x[ 64 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 544 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 68 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 548 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 68 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 68 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 556 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 68 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 560 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 68 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 68 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 568 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 68 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 572 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 68 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 68 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 580 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 68 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 584 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 68 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 68 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 592 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 68 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 596 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 68 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.x[ 18 ]), &(acadoVariables.x[ 68 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 604 ]), &(acadoWorkspace.x[ 19 ]), &(acadoVariables.x[ 68 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 608 ]), &(acadoWorkspace.x[ 20 ]), &(acadoVariables.x[ 68 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 72 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 616 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 72 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 620 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 72 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 72 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 628 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 72 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 632 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 72 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 636 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 72 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 640 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 72 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 644 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 72 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 648 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 72 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 652 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 72 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 656 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 72 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 660 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 72 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 664 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 72 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 668 ]), &(acadoWorkspace.x[ 18 ]), &(acadoVariables.x[ 72 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 672 ]), &(acadoWorkspace.x[ 19 ]), &(acadoVariables.x[ 72 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 676 ]), &(acadoWorkspace.x[ 20 ]), &(acadoVariables.x[ 72 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 680 ]), &(acadoWorkspace.x[ 21 ]), &(acadoVariables.x[ 72 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 684 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 76 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 688 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 76 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 692 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 76 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 696 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 76 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 700 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 76 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 704 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 76 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 708 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 76 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 712 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 76 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 716 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 76 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 720 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 76 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 724 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 76 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 728 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 76 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 732 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 76 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 736 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 76 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 740 ]), &(acadoWorkspace.x[ 18 ]), &(acadoVariables.x[ 76 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 744 ]), &(acadoWorkspace.x[ 19 ]), &(acadoVariables.x[ 76 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 748 ]), &(acadoWorkspace.x[ 20 ]), &(acadoVariables.x[ 76 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 752 ]), &(acadoWorkspace.x[ 21 ]), &(acadoVariables.x[ 76 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 756 ]), &(acadoWorkspace.x[ 22 ]), &(acadoVariables.x[ 76 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 760 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 80 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 764 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 80 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 768 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 80 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 772 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 80 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 776 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 80 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 780 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 80 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 784 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 80 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 788 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 80 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 792 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 80 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 796 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 80 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 800 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 80 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 804 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 80 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 808 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 80 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 812 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 80 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 816 ]), &(acadoWorkspace.x[ 18 ]), &(acadoVariables.x[ 80 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 820 ]), &(acadoWorkspace.x[ 19 ]), &(acadoVariables.x[ 80 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 824 ]), &(acadoWorkspace.x[ 20 ]), &(acadoVariables.x[ 80 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 828 ]), &(acadoWorkspace.x[ 21 ]), &(acadoVariables.x[ 80 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 832 ]), &(acadoWorkspace.x[ 22 ]), &(acadoVariables.x[ 80 ]) ); +acado_multEDu( &(acadoWorkspace.E[ 836 ]), &(acadoWorkspace.x[ 23 ]), &(acadoVariables.x[ 80 ]) ); +} + +int acado_preparationStep( ) +{ +int ret; + +ret = acado_modelSimulation(); +acado_evaluateObjective( ); +acado_condensePrep( ); +return ret; +} + +int acado_feedbackStep( ) +{ +int tmp; + +acado_condenseFdb( ); + +tmp = acado_solve( ); + +acado_expand( ); +return tmp; +} + +int acado_initializeSolver( ) +{ +int ret; + +/* This is a function which must be called once before any other function call! */ + + +ret = 0; + +memset(&acadoWorkspace, 0, sizeof( acadoWorkspace )); +return ret; +} + +void acado_initializeNodesByForwardSimulation( ) +{ +int index; +for (index = 0; index < 20; ++index) +{ +acadoWorkspace.state[0] = acadoVariables.x[index * 4]; +acadoWorkspace.state[1] = acadoVariables.x[index * 4 + 1]; +acadoWorkspace.state[2] = acadoVariables.x[index * 4 + 2]; +acadoWorkspace.state[3] = acadoVariables.x[index * 4 + 3]; +acadoWorkspace.state[24] = acadoVariables.u[index]; +acadoWorkspace.state[25] = acadoVariables.od[index * 12]; +acadoWorkspace.state[26] = acadoVariables.od[index * 12 + 1]; +acadoWorkspace.state[27] = acadoVariables.od[index * 12 + 2]; +acadoWorkspace.state[28] = acadoVariables.od[index * 12 + 3]; +acadoWorkspace.state[29] = acadoVariables.od[index * 12 + 4]; +acadoWorkspace.state[30] = acadoVariables.od[index * 12 + 5]; +acadoWorkspace.state[31] = acadoVariables.od[index * 12 + 6]; +acadoWorkspace.state[32] = acadoVariables.od[index * 12 + 7]; +acadoWorkspace.state[33] = acadoVariables.od[index * 12 + 8]; +acadoWorkspace.state[34] = acadoVariables.od[index * 12 + 9]; +acadoWorkspace.state[35] = acadoVariables.od[index * 12 + 10]; +acadoWorkspace.state[36] = acadoVariables.od[index * 12 + 11]; + +acado_integrate(acadoWorkspace.state, index == 0, index); + +acadoVariables.x[index * 4 + 4] = acadoWorkspace.state[0]; +acadoVariables.x[index * 4 + 5] = acadoWorkspace.state[1]; +acadoVariables.x[index * 4 + 6] = acadoWorkspace.state[2]; +acadoVariables.x[index * 4 + 7] = acadoWorkspace.state[3]; +} +} + +void acado_shiftStates( int strategy, real_t* const xEnd, real_t* const uEnd ) +{ +int index; +for (index = 0; index < 20; ++index) +{ +acadoVariables.x[index * 4] = acadoVariables.x[index * 4 + 4]; +acadoVariables.x[index * 4 + 1] = acadoVariables.x[index * 4 + 5]; +acadoVariables.x[index * 4 + 2] = acadoVariables.x[index * 4 + 6]; +acadoVariables.x[index * 4 + 3] = acadoVariables.x[index * 4 + 7]; +} + +if (strategy == 1 && xEnd != 0) +{ +acadoVariables.x[80] = xEnd[0]; +acadoVariables.x[81] = xEnd[1]; +acadoVariables.x[82] = xEnd[2]; +acadoVariables.x[83] = xEnd[3]; +} +else if (strategy == 2) +{ +acadoWorkspace.state[0] = acadoVariables.x[80]; +acadoWorkspace.state[1] = acadoVariables.x[81]; +acadoWorkspace.state[2] = acadoVariables.x[82]; +acadoWorkspace.state[3] = acadoVariables.x[83]; +if (uEnd != 0) +{ +acadoWorkspace.state[24] = uEnd[0]; +} +else +{ +acadoWorkspace.state[24] = acadoVariables.u[19]; +} +acadoWorkspace.state[25] = acadoVariables.od[240]; +acadoWorkspace.state[26] = acadoVariables.od[241]; +acadoWorkspace.state[27] = acadoVariables.od[242]; +acadoWorkspace.state[28] = acadoVariables.od[243]; +acadoWorkspace.state[29] = acadoVariables.od[244]; +acadoWorkspace.state[30] = acadoVariables.od[245]; +acadoWorkspace.state[31] = acadoVariables.od[246]; +acadoWorkspace.state[32] = acadoVariables.od[247]; +acadoWorkspace.state[33] = acadoVariables.od[248]; +acadoWorkspace.state[34] = acadoVariables.od[249]; +acadoWorkspace.state[35] = acadoVariables.od[250]; +acadoWorkspace.state[36] = acadoVariables.od[251]; + +acado_integrate(acadoWorkspace.state, 1, 19); + +acadoVariables.x[80] = acadoWorkspace.state[0]; +acadoVariables.x[81] = acadoWorkspace.state[1]; +acadoVariables.x[82] = acadoWorkspace.state[2]; +acadoVariables.x[83] = acadoWorkspace.state[3]; +} +} + +void acado_shiftControls( real_t* const uEnd ) +{ +int index; +for (index = 0; index < 19; ++index) +{ +acadoVariables.u[index] = acadoVariables.u[index + 1]; +} + +if (uEnd != 0) +{ +acadoVariables.u[19] = uEnd[0]; +} +} + +real_t acado_getKKT( ) +{ +real_t kkt; + +int index; +real_t prd; + +kkt = + acadoWorkspace.g[0]*acadoWorkspace.x[0] + acadoWorkspace.g[1]*acadoWorkspace.x[1] + acadoWorkspace.g[2]*acadoWorkspace.x[2] + acadoWorkspace.g[3]*acadoWorkspace.x[3] + acadoWorkspace.g[4]*acadoWorkspace.x[4] + acadoWorkspace.g[5]*acadoWorkspace.x[5] + acadoWorkspace.g[6]*acadoWorkspace.x[6] + acadoWorkspace.g[7]*acadoWorkspace.x[7] + acadoWorkspace.g[8]*acadoWorkspace.x[8] + acadoWorkspace.g[9]*acadoWorkspace.x[9] + acadoWorkspace.g[10]*acadoWorkspace.x[10] + acadoWorkspace.g[11]*acadoWorkspace.x[11] + acadoWorkspace.g[12]*acadoWorkspace.x[12] + acadoWorkspace.g[13]*acadoWorkspace.x[13] + acadoWorkspace.g[14]*acadoWorkspace.x[14] + acadoWorkspace.g[15]*acadoWorkspace.x[15] + acadoWorkspace.g[16]*acadoWorkspace.x[16] + acadoWorkspace.g[17]*acadoWorkspace.x[17] + acadoWorkspace.g[18]*acadoWorkspace.x[18] + acadoWorkspace.g[19]*acadoWorkspace.x[19] + acadoWorkspace.g[20]*acadoWorkspace.x[20] + acadoWorkspace.g[21]*acadoWorkspace.x[21] + acadoWorkspace.g[22]*acadoWorkspace.x[22] + acadoWorkspace.g[23]*acadoWorkspace.x[23]; +kkt = fabs( kkt ); +for (index = 0; index < 24; ++index) +{ +prd = acadoWorkspace.y[index]; +if (prd > 1e-12) +kkt += fabs(acadoWorkspace.lb[index] * prd); +else if (prd < -1e-12) +kkt += fabs(acadoWorkspace.ub[index] * prd); +} +return kkt; +} + +real_t acado_getObjective( ) +{ +real_t objVal; + +int lRun1; +/** Row vector of size: 5 */ +real_t tmpDy[ 5 ]; + +/** Row vector of size: 4 */ +real_t tmpDyN[ 4 ]; + +for (lRun1 = 0; lRun1 < 20; ++lRun1) +{ +acadoWorkspace.objValueIn[0] = acadoVariables.x[lRun1 * 4]; +acadoWorkspace.objValueIn[1] = acadoVariables.x[lRun1 * 4 + 1]; +acadoWorkspace.objValueIn[2] = acadoVariables.x[lRun1 * 4 + 2]; +acadoWorkspace.objValueIn[3] = acadoVariables.x[lRun1 * 4 + 3]; +acadoWorkspace.objValueIn[4] = acadoVariables.u[lRun1]; +acadoWorkspace.objValueIn[5] = acadoVariables.od[lRun1 * 12]; +acadoWorkspace.objValueIn[6] = acadoVariables.od[lRun1 * 12 + 1]; +acadoWorkspace.objValueIn[7] = acadoVariables.od[lRun1 * 12 + 2]; +acadoWorkspace.objValueIn[8] = acadoVariables.od[lRun1 * 12 + 3]; +acadoWorkspace.objValueIn[9] = acadoVariables.od[lRun1 * 12 + 4]; +acadoWorkspace.objValueIn[10] = acadoVariables.od[lRun1 * 12 + 5]; +acadoWorkspace.objValueIn[11] = acadoVariables.od[lRun1 * 12 + 6]; +acadoWorkspace.objValueIn[12] = acadoVariables.od[lRun1 * 12 + 7]; +acadoWorkspace.objValueIn[13] = acadoVariables.od[lRun1 * 12 + 8]; +acadoWorkspace.objValueIn[14] = acadoVariables.od[lRun1 * 12 + 9]; +acadoWorkspace.objValueIn[15] = acadoVariables.od[lRun1 * 12 + 10]; +acadoWorkspace.objValueIn[16] = acadoVariables.od[lRun1 * 12 + 11]; + +acado_evaluateLSQ( acadoWorkspace.objValueIn, acadoWorkspace.objValueOut ); +acadoWorkspace.Dy[lRun1 * 5] = acadoWorkspace.objValueOut[0] - acadoVariables.y[lRun1 * 5]; +acadoWorkspace.Dy[lRun1 * 5 + 1] = acadoWorkspace.objValueOut[1] - acadoVariables.y[lRun1 * 5 + 1]; +acadoWorkspace.Dy[lRun1 * 5 + 2] = acadoWorkspace.objValueOut[2] - acadoVariables.y[lRun1 * 5 + 2]; +acadoWorkspace.Dy[lRun1 * 5 + 3] = acadoWorkspace.objValueOut[3] - acadoVariables.y[lRun1 * 5 + 3]; +acadoWorkspace.Dy[lRun1 * 5 + 4] = acadoWorkspace.objValueOut[4] - acadoVariables.y[lRun1 * 5 + 4]; +} +acadoWorkspace.objValueIn[0] = acadoVariables.x[80]; +acadoWorkspace.objValueIn[1] = acadoVariables.x[81]; +acadoWorkspace.objValueIn[2] = acadoVariables.x[82]; +acadoWorkspace.objValueIn[3] = acadoVariables.x[83]; +acadoWorkspace.objValueIn[4] = acadoVariables.od[240]; +acadoWorkspace.objValueIn[5] = acadoVariables.od[241]; +acadoWorkspace.objValueIn[6] = acadoVariables.od[242]; +acadoWorkspace.objValueIn[7] = acadoVariables.od[243]; +acadoWorkspace.objValueIn[8] = acadoVariables.od[244]; +acadoWorkspace.objValueIn[9] = acadoVariables.od[245]; +acadoWorkspace.objValueIn[10] = acadoVariables.od[246]; +acadoWorkspace.objValueIn[11] = acadoVariables.od[247]; +acadoWorkspace.objValueIn[12] = acadoVariables.od[248]; +acadoWorkspace.objValueIn[13] = acadoVariables.od[249]; +acadoWorkspace.objValueIn[14] = acadoVariables.od[250]; +acadoWorkspace.objValueIn[15] = acadoVariables.od[251]; +acado_evaluateLSQEndTerm( acadoWorkspace.objValueIn, acadoWorkspace.objValueOut ); +acadoWorkspace.DyN[0] = acadoWorkspace.objValueOut[0] - acadoVariables.yN[0]; +acadoWorkspace.DyN[1] = acadoWorkspace.objValueOut[1] - acadoVariables.yN[1]; +acadoWorkspace.DyN[2] = acadoWorkspace.objValueOut[2] - acadoVariables.yN[2]; +acadoWorkspace.DyN[3] = acadoWorkspace.objValueOut[3] - acadoVariables.yN[3]; +objVal = 0.0000000000000000e+00; +for (lRun1 = 0; lRun1 < 20; ++lRun1) +{ +tmpDy[0] = + acadoWorkspace.Dy[lRun1 * 5]*acadoVariables.W[lRun1 * 25] + acadoWorkspace.Dy[lRun1 * 5 + 1]*acadoVariables.W[lRun1 * 25 + 5] + acadoWorkspace.Dy[lRun1 * 5 + 2]*acadoVariables.W[lRun1 * 25 + 10] + acadoWorkspace.Dy[lRun1 * 5 + 3]*acadoVariables.W[lRun1 * 25 + 15] + acadoWorkspace.Dy[lRun1 * 5 + 4]*acadoVariables.W[lRun1 * 25 + 20]; +tmpDy[1] = + acadoWorkspace.Dy[lRun1 * 5]*acadoVariables.W[lRun1 * 25 + 1] + acadoWorkspace.Dy[lRun1 * 5 + 1]*acadoVariables.W[lRun1 * 25 + 6] + acadoWorkspace.Dy[lRun1 * 5 + 2]*acadoVariables.W[lRun1 * 25 + 11] + acadoWorkspace.Dy[lRun1 * 5 + 3]*acadoVariables.W[lRun1 * 25 + 16] + acadoWorkspace.Dy[lRun1 * 5 + 4]*acadoVariables.W[lRun1 * 25 + 21]; +tmpDy[2] = + acadoWorkspace.Dy[lRun1 * 5]*acadoVariables.W[lRun1 * 25 + 2] + acadoWorkspace.Dy[lRun1 * 5 + 1]*acadoVariables.W[lRun1 * 25 + 7] + acadoWorkspace.Dy[lRun1 * 5 + 2]*acadoVariables.W[lRun1 * 25 + 12] + acadoWorkspace.Dy[lRun1 * 5 + 3]*acadoVariables.W[lRun1 * 25 + 17] + acadoWorkspace.Dy[lRun1 * 5 + 4]*acadoVariables.W[lRun1 * 25 + 22]; +tmpDy[3] = + acadoWorkspace.Dy[lRun1 * 5]*acadoVariables.W[lRun1 * 25 + 3] + acadoWorkspace.Dy[lRun1 * 5 + 1]*acadoVariables.W[lRun1 * 25 + 8] + acadoWorkspace.Dy[lRun1 * 5 + 2]*acadoVariables.W[lRun1 * 25 + 13] + acadoWorkspace.Dy[lRun1 * 5 + 3]*acadoVariables.W[lRun1 * 25 + 18] + acadoWorkspace.Dy[lRun1 * 5 + 4]*acadoVariables.W[lRun1 * 25 + 23]; +tmpDy[4] = + acadoWorkspace.Dy[lRun1 * 5]*acadoVariables.W[lRun1 * 25 + 4] + acadoWorkspace.Dy[lRun1 * 5 + 1]*acadoVariables.W[lRun1 * 25 + 9] + acadoWorkspace.Dy[lRun1 * 5 + 2]*acadoVariables.W[lRun1 * 25 + 14] + acadoWorkspace.Dy[lRun1 * 5 + 3]*acadoVariables.W[lRun1 * 25 + 19] + acadoWorkspace.Dy[lRun1 * 5 + 4]*acadoVariables.W[lRun1 * 25 + 24]; +objVal += + acadoWorkspace.Dy[lRun1 * 5]*tmpDy[0] + acadoWorkspace.Dy[lRun1 * 5 + 1]*tmpDy[1] + acadoWorkspace.Dy[lRun1 * 5 + 2]*tmpDy[2] + acadoWorkspace.Dy[lRun1 * 5 + 3]*tmpDy[3] + acadoWorkspace.Dy[lRun1 * 5 + 4]*tmpDy[4]; +} + +tmpDyN[0] = + acadoWorkspace.DyN[0]*acadoVariables.WN[0] + acadoWorkspace.DyN[1]*acadoVariables.WN[4] + acadoWorkspace.DyN[2]*acadoVariables.WN[8] + acadoWorkspace.DyN[3]*acadoVariables.WN[12]; +tmpDyN[1] = + acadoWorkspace.DyN[0]*acadoVariables.WN[1] + acadoWorkspace.DyN[1]*acadoVariables.WN[5] + acadoWorkspace.DyN[2]*acadoVariables.WN[9] + acadoWorkspace.DyN[3]*acadoVariables.WN[13]; +tmpDyN[2] = + acadoWorkspace.DyN[0]*acadoVariables.WN[2] + acadoWorkspace.DyN[1]*acadoVariables.WN[6] + acadoWorkspace.DyN[2]*acadoVariables.WN[10] + acadoWorkspace.DyN[3]*acadoVariables.WN[14]; +tmpDyN[3] = + acadoWorkspace.DyN[0]*acadoVariables.WN[3] + acadoWorkspace.DyN[1]*acadoVariables.WN[7] + acadoWorkspace.DyN[2]*acadoVariables.WN[11] + acadoWorkspace.DyN[3]*acadoVariables.WN[15]; +objVal += + acadoWorkspace.DyN[0]*tmpDyN[0] + acadoWorkspace.DyN[1]*tmpDyN[1] + acadoWorkspace.DyN[2]*tmpDyN[2] + acadoWorkspace.DyN[3]*tmpDyN[3]; + +objVal *= 0.5; +return objVal; +} + diff --git a/selfdrive/controls/lib/longitudinal_mpc_model/libmpc_py.py b/selfdrive/controls/lib/longitudinal_mpc_model/libmpc_py.py new file mode 100644 index 00000000000000..a25dbb66d562f0 --- /dev/null +++ b/selfdrive/controls/lib/longitudinal_mpc_model/libmpc_py.py @@ -0,0 +1,32 @@ +import os + +from cffi import FFI +from common.ffi_wrapper import suffix + +mpc_dir = os.path.join(os.path.dirname(os.path.abspath(__file__))) +libmpc_fn = os.path.join(mpc_dir, "libmpc"+suffix()) + +ffi = FFI() +ffi.cdef(""" + +typedef struct { +double x_ego, v_ego, a_ego; +} state_t; + + +typedef struct { +double x_ego[21]; +double v_ego[21]; +double a_ego[21]; +double t[21]; +double j_ego[20]; +double cost; +} log_t; + + +void init(double xCost, double vCost, double aCost, double accelCost, double jerkCost); +void init_with_simulation(double v_ego); +int run_mpc(state_t * x0, log_t * solution, double x_poly[4], double v_poly[4], double a_poly[4]); +""") + +libmpc = ffi.dlopen(libmpc_fn) diff --git a/selfdrive/controls/lib/longitudinal_mpc_model/longitudinal_mpc.c b/selfdrive/controls/lib/longitudinal_mpc_model/longitudinal_mpc.c new file mode 100644 index 00000000000000..39cff8f2a8650a --- /dev/null +++ b/selfdrive/controls/lib/longitudinal_mpc_model/longitudinal_mpc.c @@ -0,0 +1,141 @@ +#include "acado_common.h" +#include "acado_auxiliary_functions.h" + +#include +#include + +#define NX ACADO_NX /* Number of differential state variables. */ +#define NXA ACADO_NXA /* Number of algebraic variables. */ +#define NU ACADO_NU /* Number of control inputs. */ +#define NOD ACADO_NOD /* Number of online data values. */ + +#define NY ACADO_NY /* Number of measurements/references on nodes 0..N - 1. */ +#define NYN ACADO_NYN /* Number of measurements/references on node N. */ + +#define N ACADO_N /* Number of intervals in the horizon. */ + +ACADOvariables acadoVariables; +ACADOworkspace acadoWorkspace; + +typedef struct { + double x_ego, v_ego, a_ego; +} state_t; + + +typedef struct { + double x_ego[N+1]; + double v_ego[N+1]; + double a_ego[N+1]; + double t[N+1]; + double j_ego[N]; + double cost; +} log_t; + +void init(double xCost, double vCost, double aCost, double accelCost, double jerkCost){ + acado_initializeSolver(); + int i; + const int STEP_MULTIPLIER = 3; + + /* Initialize the states and controls. */ + for (i = 0; i < NX * (N + 1); ++i) acadoVariables.x[ i ] = 0.0; + for (i = 0; i < NU * N; ++i) acadoVariables.u[ i ] = 0.0; + + /* Initialize the measurements/reference. */ + for (i = 0; i < NY * N; ++i) acadoVariables.y[ i ] = 0.0; + for (i = 0; i < NYN; ++i) acadoVariables.yN[ i ] = 0.0; + + /* MPC: initialize the current state feedback. */ + for (i = 0; i < NX; ++i) acadoVariables.x0[ i ] = 0.0; + // Set weights + + for (i = 0; i < N; i++) { + int f = 1; + if (i > 4){ + f = STEP_MULTIPLIER; + } + // Setup diagonal entries + acadoVariables.W[NY*NY*i + (NY+1)*0] = xCost * f; + acadoVariables.W[NY*NY*i + (NY+1)*1] = vCost * f; + acadoVariables.W[NY*NY*i + (NY+1)*2] = aCost * f; + acadoVariables.W[NY*NY*i + (NY+1)*3] = accelCost * f; + acadoVariables.W[NY*NY*i + (NY+1)*4] = jerkCost * f; + } + acadoVariables.WN[(NYN+1)*0] = xCost * STEP_MULTIPLIER; + acadoVariables.WN[(NYN+1)*1] = vCost * STEP_MULTIPLIER; + acadoVariables.WN[(NYN+1)*2] = aCost * STEP_MULTIPLIER; + acadoVariables.WN[(NYN+1)*3] = accelCost * STEP_MULTIPLIER; + +} + +void init_with_simulation(double v_ego){ + int i; + + double x_ego = 0.0; + + double dt = 0.2; + double t = 0.0; + + for (i = 0; i < N + 1; ++i){ + if (i > 4){ + dt = 0.6; + } + + acadoVariables.x[i*NX] = x_ego; + acadoVariables.x[i*NX+1] = v_ego; + acadoVariables.x[i*NX+2] = 0; + acadoVariables.x[i*NX+3] = t; + + x_ego += v_ego * dt; + t += dt; + } + + for (i = 0; i < NU * N; ++i) acadoVariables.u[ i ] = 0.0; + for (i = 0; i < NY * N; ++i) acadoVariables.y[ i ] = 0.0; + for (i = 0; i < NYN; ++i) acadoVariables.yN[ i ] = 0.0; +} + +int run_mpc(state_t * x0, log_t * solution, + double x_poly[4], double v_poly[4], double a_poly[4]){ + int i; + + for (i = 0; i < N + 1; ++i){ + acadoVariables.od[i*NOD+0] = x_poly[0]; + acadoVariables.od[i*NOD+1] = x_poly[1]; + acadoVariables.od[i*NOD+2] = x_poly[2]; + acadoVariables.od[i*NOD+3] = x_poly[3]; + + acadoVariables.od[i*NOD+4] = v_poly[0]; + acadoVariables.od[i*NOD+5] = v_poly[1]; + acadoVariables.od[i*NOD+6] = v_poly[2]; + acadoVariables.od[i*NOD+7] = v_poly[3]; + + acadoVariables.od[i*NOD+8] = a_poly[0]; + acadoVariables.od[i*NOD+9] = a_poly[1]; + acadoVariables.od[i*NOD+10] = a_poly[2]; + acadoVariables.od[i*NOD+11] = a_poly[3]; + } + + acadoVariables.x[0] = acadoVariables.x0[0] = x0->x_ego; + acadoVariables.x[1] = acadoVariables.x0[1] = x0->v_ego; + acadoVariables.x[2] = acadoVariables.x0[2] = x0->a_ego; + acadoVariables.x[3] = acadoVariables.x0[3] = 0; + + acado_preparationStep(); + acado_feedbackStep(); + + for (i = 0; i <= N; i++){ + solution->x_ego[i] = acadoVariables.x[i*NX]; + solution->v_ego[i] = acadoVariables.x[i*NX+1]; + solution->a_ego[i] = acadoVariables.x[i*NX+2]; + solution->t[i] = acadoVariables.x[i*NX+3]; + + if (i < N){ + solution->j_ego[i] = acadoVariables.u[i]; + } + } + solution->cost = acado_getObjective(); + + // Dont shift states here. Current solution is closer to next timestep than if + // we shift by 0.1 seconds. + return acado_getNWSR(); +} diff --git a/selfdrive/controls/lib/pathplanner.py b/selfdrive/controls/lib/pathplanner.py index ab1bcae591851d..524bee8ba2e1ab 100644 --- a/selfdrive/controls/lib/pathplanner.py +++ b/selfdrive/controls/lib/pathplanner.py @@ -1,44 +1,71 @@ import os import math -import numpy as np - -# from common.numpy_fast import clip -from common.realtime import sec_since_boot -from selfdrive.services import service_list +from common.realtime import sec_since_boot, DT_MDL from selfdrive.swaglog import cloudlog from selfdrive.controls.lib.lateral_mpc import libmpc_py from selfdrive.controls.lib.drive_helpers import MPC_COST_LAT from selfdrive.controls.lib.lane_planner import LanePlanner -import selfdrive.messaging as messaging -from selfdrive.car.tesla.readconfig import CarSettings -from cereal import tesla +from selfdrive.config import Conversions as CV +from common.params import Params +import cereal.messaging as messaging +from cereal import log -LOG_MPC = os.environ.get('LOG_MPC', False) +LaneChangeState = log.PathPlan.LaneChangeState +LaneChangeDirection = log.PathPlan.LaneChangeDirection +LOG_MPC = os.environ.get('LOG_MPC', False) -def calc_states_after_delay(states, v_ego, steer_angle, curvature_factor, steer_ratio, delay, long_camera_offset): - states[0].x = max(v_ego * delay + long_camera_offset, 0.0) +LANE_CHANGE_SPEED_MIN = 45 * CV.MPH_TO_MS +LANE_CHANGE_TIME_MAX = 10. + +DESIRES = { + LaneChangeDirection.none: { + LaneChangeState.off: log.PathPlan.Desire.none, + LaneChangeState.preLaneChange: log.PathPlan.Desire.none, + LaneChangeState.laneChangeStarting: log.PathPlan.Desire.none, + LaneChangeState.laneChangeFinishing: log.PathPlan.Desire.none, + }, + LaneChangeDirection.left: { + LaneChangeState.off: log.PathPlan.Desire.none, + LaneChangeState.preLaneChange: log.PathPlan.Desire.none, + LaneChangeState.laneChangeStarting: log.PathPlan.Desire.laneChangeLeft, + LaneChangeState.laneChangeFinishing: log.PathPlan.Desire.laneChangeLeft, + }, + LaneChangeDirection.right: { + LaneChangeState.off: log.PathPlan.Desire.none, + LaneChangeState.preLaneChange: log.PathPlan.Desire.none, + LaneChangeState.laneChangeStarting: log.PathPlan.Desire.laneChangeRight, + LaneChangeState.laneChangeFinishing: log.PathPlan.Desire.laneChangeRight, + }, +} + + +def calc_states_after_delay(states, v_ego, steer_angle, curvature_factor, steer_ratio, delay): + states[0].x = max(v_ego * delay, 0.0) states[0].psi = v_ego * curvature_factor * math.radians(steer_angle) / steer_ratio * delay + states[0].y = states[0].x * math.sin(states[0].psi / 2) return states -class PathPlanner(object): +class PathPlanner(): def __init__(self, CP): - self.LP = LanePlanner() + self.LP = LanePlanner(shouldUseAlca=(CP.carName=="tesla")) self.last_cloudlog_t = 0 + self.steer_rate_cost = CP.steerRateCost - self.plan = messaging.pub_sock(service_list['pathPlan'].port) - self.livempc = messaging.pub_sock(service_list['liveMpc'].port) - self.alca = messaging.pub_sock(service_list['alcaState'].port) - - self.setup_mpc(CP.steerRateCost) + self.setup_mpc() self.solution_invalid_cnt = 0 - self.path_offset_i = 0.0 - - def setup_mpc(self, steer_rate_cost): + self.lane_change_enabled = Params().get('LaneChangeEnabled') == b'1' + self.lane_change_state = LaneChangeState.off + self.lane_change_direction = LaneChangeDirection.none + self.lane_change_timer = 0.0 + self.lane_change_ll_prob = 1.0 + self.prev_one_blinker = False + + def setup_mpc(self): self.libmpc = libmpc_py.libmpc - self.libmpc.init(MPC_COST_LAT.PATH, MPC_COST_LAT.LANE, MPC_COST_LAT.HEADING, steer_rate_cost) + self.libmpc.init(MPC_COST_LAT.PATH, MPC_COST_LAT.LANE, MPC_COST_LAT.HEADING, self.steer_rate_cost) self.mpc_solution = libmpc_py.ffi.new("log_t *") self.cur_state = libmpc_py.ffi.new("state_t *") @@ -52,34 +79,103 @@ def setup_mpc(self, steer_rate_cost): self.angle_steers_des_prev = 0.0 self.angle_steers_des_time = 0.0 - def update(self, sm, CP, VM): + def update(self, sm, pm, CP, VM): v_ego = sm['carState'].vEgo angle_steers = sm['carState'].steeringAngle #angle_steers_des = sm['controlsState'].angleSteersDes active = sm['controlsState'].active - angle_offset_average = sm['liveParameters'].angleOffsetAverage angle_offset = sm['liveParameters'].angleOffset - self.LP.update(v_ego, sm['model'],True) - # Run MPC self.angle_steers_des_prev = self.angle_steers_des_mpc - VM.update_params(sm['liveParameters'].stiffnessFactor, sm['liveParameters'].steerRatio) + + # Update vehicle model + x = max(sm['liveParameters'].stiffnessFactor, 0.1) + sr = max(sm['liveParameters'].steerRatio, 0.1) + VM.update_params(x, sr) + curvature_factor = VM.curvature_factor(v_ego) - # TODO: Check for active, override, and saturation - # if active: - # self.path_offset_i += self.LP.d_poly[3] / (60.0 * 20.0) - # self.path_offset_i = clip(self.path_offset_i, -0.5, 0.5) - # self.LP.d_poly[3] += self.path_offset_i - # else: - # self.path_offset_i = 0.0 + self.LP.parse_model(sm['model']) + + # Lane change logic + one_blinker = sm['carState'].leftBlinker != sm['carState'].rightBlinker + below_lane_change_speed = v_ego < LANE_CHANGE_SPEED_MIN + + if sm['carState'].leftBlinker: + self.lane_change_direction = LaneChangeDirection.left + elif sm['carState'].rightBlinker: + self.lane_change_direction = LaneChangeDirection.right + + + #BB blocking comma ALCA for now + if (CP.carName == "tesla") or (not active) or (self.lane_change_timer > LANE_CHANGE_TIME_MAX) or (not one_blinker) or (not self.lane_change_enabled): + self.lane_change_state = LaneChangeState.off + self.lane_change_direction = LaneChangeDirection.none + else: + torque_applied = sm['carState'].steeringPressed and \ + ((sm['carState'].steeringTorque > 0 and self.lane_change_direction == LaneChangeDirection.left) or + (sm['carState'].steeringTorque < 0 and self.lane_change_direction == LaneChangeDirection.right)) + + blindspot_detected = ((sm['carState'].leftBlindspot and self.lane_change_direction == LaneChangeDirection.left) or + (sm['carState'].rightBlindspot and self.lane_change_direction == LaneChangeDirection.right)) + + lane_change_prob = self.LP.l_lane_change_prob + self.LP.r_lane_change_prob + + # State transitions + # off + if self.lane_change_state == LaneChangeState.off and one_blinker and not self.prev_one_blinker and not below_lane_change_speed: + self.lane_change_state = LaneChangeState.preLaneChange + self.lane_change_ll_prob = 1.0 + + # pre + elif self.lane_change_state == LaneChangeState.preLaneChange: + if not one_blinker or below_lane_change_speed: + self.lane_change_state = LaneChangeState.off + elif torque_applied and not blindspot_detected: + self.lane_change_state = LaneChangeState.laneChangeStarting + + # starting + elif self.lane_change_state == LaneChangeState.laneChangeStarting: + # fade out over .5s + self.lane_change_ll_prob = max(self.lane_change_ll_prob - 2*DT_MDL, 0.0) + # 98% certainty + if lane_change_prob < 0.02 and self.lane_change_ll_prob < 0.01: + self.lane_change_state = LaneChangeState.laneChangeFinishing + + # finishing + elif self.lane_change_state == LaneChangeState.laneChangeFinishing: + # fade in laneline over 1s + self.lane_change_ll_prob = min(self.lane_change_ll_prob + DT_MDL, 1.0) + if one_blinker and self.lane_change_ll_prob > 0.99: + self.lane_change_state = LaneChangeState.preLaneChange + elif self.lane_change_ll_prob > 0.99: + self.lane_change_state = LaneChangeState.off + + if self.lane_change_state in [LaneChangeState.off, LaneChangeState.preLaneChange]: + self.lane_change_timer = 0.0 + else: + self.lane_change_timer += DT_MDL + + self.prev_one_blinker = one_blinker + + desire = DESIRES[self.lane_change_direction][self.lane_change_state] + + # Turn off lanes during lane change + if desire == log.PathPlan.Desire.laneChangeRight or desire == log.PathPlan.Desire.laneChangeLeft: + self.LP.l_prob *= self.lane_change_ll_prob + self.LP.r_prob *= self.lane_change_ll_prob + self.libmpc.init_weights(MPC_COST_LAT.PATH / 3.0, MPC_COST_LAT.LANE, MPC_COST_LAT.HEADING, self.steer_rate_cost) + else: + self.libmpc.init_weights(MPC_COST_LAT.PATH, MPC_COST_LAT.LANE, MPC_COST_LAT.HEADING, self.steer_rate_cost) + + self.LP.update_d_poly(v_ego, sm['model'],True) # account for actuation delay - eonToFront = CarSettings().get_value("eonToFront") + - self.cur_state = calc_states_after_delay(self.cur_state, v_ego, angle_steers - angle_offset, curvature_factor, VM.sR, CP.steerActuatorDelay, eonToFront) + self.cur_state = calc_states_after_delay(self.cur_state, v_ego, angle_steers - angle_offset, curvature_factor, VM.sR, CP.steerActuatorDelay) v_ego_mpc = max(v_ego, 5.0) # avoid mpc roughness due to low speed self.libmpc.run_mpc(self.cur_state, self.mpc_solution, @@ -96,10 +192,10 @@ def update(self, sm, CP, VM): self.cur_state[0].delta = delta_desired - self.angle_steers_des_mpc = float(math.degrees(delta_desired * VM.sR) + angle_offset_average) + self.angle_steers_des_mpc = float(math.degrees(delta_desired * VM.sR) + angle_offset) # Check for infeasable MPC solution - mpc_nans = np.any(np.isnan(list(self.mpc_solution[0].delta))) + mpc_nans = any(math.isnan(x) for x in self.mpc_solution[0].delta) t = sec_since_boot() if mpc_nans: self.libmpc.init(MPC_COST_LAT.PATH, MPC_COST_LAT.LANE, MPC_COST_LAT.HEADING, CP.steerRateCost) @@ -115,8 +211,7 @@ def update(self, sm, CP, VM): self.solution_invalid_cnt = 0 plan_solution_valid = self.solution_invalid_cnt < 2 - plan_send = messaging.new_message() - plan_send.init('pathPlan') + plan_send = messaging.new_message('pathPlan') plan_send.valid = sm.all_alive_and_valid(service_list=['carState', 'controlsState', 'liveParameters', 'model']) plan_send.pathPlan.laneWidth = float(self.LP.lane_width) plan_send.pathPlan.dPoly = [float(x) for x in self.LP.d_poly] @@ -127,32 +222,21 @@ def update(self, sm, CP, VM): plan_send.pathPlan.angleSteers = float(self.angle_steers_des_mpc) plan_send.pathPlan.rateSteers = float(rate_desired) - plan_send.pathPlan.angleOffset = float(self.path_offset_i) + plan_send.pathPlan.angleOffset = float(sm['liveParameters'].angleOffsetAverage) plan_send.pathPlan.mpcSolutionValid = bool(plan_solution_valid) plan_send.pathPlan.paramsValid = bool(sm['liveParameters'].valid) - plan_send.pathPlan.sensorValid = bool(sm['liveParameters'].sensorValid) - plan_send.pathPlan.posenetValid = bool(sm['liveParameters'].posenetValid) - - self.plan.send(plan_send.to_bytes()) - alca_state = tesla.ALCAState.new_message() - #ALCA params - alca_state.alcaDirection = int(self.LP.ALCAMP.ALCA_direction) - alca_state.alcaError = bool(self.LP.ALCAMP.ALCA_error) - alca_state.alcaCancelling = bool(self.LP.ALCAMP.ALCA_cancelling) - alca_state.alcaEnabled = bool(self.LP.ALCAMP.ALCA_enabled) - alca_state.alcaLaneWidth = float(self.LP.ALCAMP.ALCA_lane_width) - alca_state.alcaStep = int(self.LP.ALCAMP.ALCA_step) - alca_state.alcaTotalSteps = int(self.LP.ALCAMP.ALCA_total_steps) + plan_send.pathPlan.desire = desire + plan_send.pathPlan.laneChangeState = self.lane_change_state + plan_send.pathPlan.laneChangeDirection = self.lane_change_direction - self.alca.send(alca_state.to_bytes()) + pm.send('pathPlan', plan_send) if LOG_MPC: - dat = messaging.new_message() - dat.init('liveMpc') + dat = messaging.new_message('liveMpc') dat.liveMpc.x = list(self.mpc_solution[0].x) dat.liveMpc.y = list(self.mpc_solution[0].y) dat.liveMpc.psi = list(self.mpc_solution[0].psi) dat.liveMpc.delta = list(self.mpc_solution[0].delta) dat.liveMpc.cost = self.mpc_solution[0].cost - self.livempc.send(dat.to_bytes()) + pm.send('liveMpc', dat) diff --git a/selfdrive/controls/lib/pid.py b/selfdrive/controls/lib/pid.py index 57289bb021c8de..916b95c9ea0c4b 100644 --- a/selfdrive/controls/lib/pid.py +++ b/selfdrive/controls/lib/pid.py @@ -10,10 +10,10 @@ def apply_deadzone(error, deadzone): error = 0. return error -class PIController(object): +class PIController(): def __init__(self, k_p, k_i, k_f=1., pos_limit=None, neg_limit=None, rate=100, sat_limit=0.8, convert=None): - self._k_p = k_p # proportional gain - self._k_i = k_i # integral gain + self._k_p = k_p # proportional gain + self._k_i = k_i # integral gain self.k_f = k_f # feedforward gain self.pos_limit = pos_limit @@ -35,10 +35,10 @@ def k_p(self): def k_i(self): return interp(self.speed, self._k_i[0], self._k_i[1]) - def _check_saturation(self, control, override, error): + def _check_saturation(self, control, check_saturation, error): saturated = (control < self.neg_limit) or (control > self.pos_limit) - if saturated and not override and abs(error) > 0.1: + if saturated and check_saturation and abs(error) > 0.1: self.sat_count += self.sat_count_rate else: self.sat_count -= self.sat_count_rate @@ -73,7 +73,7 @@ def update(self, setpoint, measurement, speed=0.0, check_saturation=True, overri # Update when changing i will move the control away from the limits # or when i will move towards the sign of the error - if ((error >= 0 and (control <= self.pos_limit or i < 0.0)) or \ + if ((error >= 0 and (control <= self.pos_limit or i < 0.0)) or (error <= 0 and (control >= self.neg_limit or i > 0.0))) and \ not freeze_integrator: self.i = i @@ -82,10 +82,7 @@ def update(self, setpoint, measurement, speed=0.0, check_saturation=True, overri if self.convert is not None: control = self.convert(control, speed=self.speed) - if check_saturation: - self.saturated = self._check_saturation(control, override, error) - else: - self.saturated = False + self.saturated = self._check_saturation(control, check_saturation, error) self.control = clip(control, self.neg_limit, self.pos_limit) - return self.control \ No newline at end of file + return self.control diff --git a/selfdrive/controls/lib/pid_real.py b/selfdrive/controls/lib/pid_real.py new file mode 100644 index 00000000000000..76f9652aa13177 --- /dev/null +++ b/selfdrive/controls/lib/pid_real.py @@ -0,0 +1,113 @@ +import numpy as np +from common.numpy_fast import clip, interp +from selfdrive.car.tesla.speed_utils.movingaverage import MovingAverage + + +def apply_deadzone(error, deadzone): + if error > deadzone: + error -= deadzone + elif error < - deadzone: + error += deadzone + else: + error = 0. + return error + +class PIDController(): + def __init__(self, k_p, k_i, k_d, k_f=0.85, pos_limit=None, neg_limit=None, rate=100, sat_limit=0.8, convert=None): + self._k_p = k_p # proportional gain + self._k_i = k_i # integral gain + self._k_d = k_d # derivative gain + self.k_f = k_f # feedforward gain + + self.pos_limit = pos_limit + self.neg_limit = neg_limit + + self.sat_count_rate = 1.0 / rate + self.i_unwind_rate = 0.3 / rate + self.i_rate = 1.0 / rate + self.rate = 1.0 / rate + self.d_rate = 7.0 / rate + self.sat_limit = sat_limit + self.convert = convert + self.past_errors_avg = 0 + self.past_errors = MovingAverage(3) + + self.reset() + + @property + def k_p(self): + return interp(self.speed, self._k_p[0], self._k_p[1]) + + @property + def k_i(self): + return interp(self.speed, self._k_i[0], self._k_i[1]) + + @property + def k_d(self): + return interp(self.speed, self._k_d[0], self._k_d[1]) + + + def _check_saturation(self, control, override, error): + saturated = (control < self.neg_limit) or (control > self.pos_limit) + + if saturated and not override and abs(error) > 0.1: + self.sat_count += self.sat_count_rate + else: + self.sat_count -= self.sat_count_rate + + self.sat_count = clip(self.sat_count, 0.0, 1.0) + + return self.sat_count > self.sat_limit + + def reset(self): + self.p = 0.0 + self.i = 0.0 + self.f = 0.0 + self.d = 0.0 + self.sat_count = 0.0 + self.saturated = False + self.control = 0 + self.past_errors_avg = 0 + self.past_errors.reset() + + def update(self, setpoint, measurement, speed=0.0, check_saturation=True, override=False, feedforward=0., deadzone=0., freeze_integrator=False): + self.speed = speed + + error = float(apply_deadzone(setpoint - measurement, deadzone)) + self.p = error * self.k_p + + #clip the feedforward during the last 5 kmh for smooth transition + clipped_error = clip(error,0,5) + self.k_f = clipped_error * 0.2 + + self.f = feedforward * self.k_f + self.d = 0.0 + if self.past_errors.full(): + self.d = self.k_d * ((error - self.past_errors_avg) / self.d_rate) + self.past_errors_avg = self.past_errors.add(error) + + if override: + self.i -= self.i_unwind_rate * float(np.sign(self.i)) + else: + i = self.i + error * self.k_i * self.i_rate + control = self.p + self.f + i + self.d + + if self.convert is not None: + control = self.convert(control, speed=self.speed) + + if ((error >= 0 and (control <= self.pos_limit or i < 0.0)) or \ + (error <= 0 and (control >= self.neg_limit or i > 0.0))) and \ + not freeze_integrator: + self.i = i + else: + control = self.p + self.f + self.i + self.d + if self.convert is not None: + control = self.convert(control, speed=self.speed) + + if check_saturation: + self.saturated = self._check_saturation(control, override, error) + else: + self.saturated = False + + self.control = clip(control, self.neg_limit, self.pos_limit) + return self.control diff --git a/selfdrive/controls/lib/planner.py b/selfdrive/controls/lib/planner.py index d6ef03a0f0e1c9..85964d8b5df259 100755 --- a/selfdrive/controls/lib/planner.py +++ b/selfdrive/controls/lib/planner.py @@ -1,88 +1,87 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import math import numpy as np from common.params import Params from common.numpy_fast import interp -import selfdrive.messaging as messaging +import cereal.messaging as messaging from cereal import car -from common.realtime import sec_since_boot, DT_PLAN +from common.realtime import sec_since_boot from selfdrive.swaglog import cloudlog from selfdrive.config import Conversions as CV -from selfdrive.services import service_list from selfdrive.controls.lib.speed_smoother import speed_smoother -from selfdrive.controls.lib.longcontrol import LongCtrlState, MIN_CAN_SPEED +from selfdrive.controls.lib.longcontrol import LongCtrlState from selfdrive.controls.lib.fcw import FCWChecker from selfdrive.controls.lib.long_mpc import LongitudinalMpc - -MAX_SPEED = 255.0 +from selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX LON_MPC_STEP = 0.2 # first step is 0.2s -MAX_SPEED_ERROR = 2.0 AWARENESS_DECEL = -0.2 # car smoothly decel at .2m/s^2 when user is distracted # lookup tables VS speed to determine min and max accels in cruise # make sure these accelerations are smaller than mpc limits #BB editing for TESLA only -_A_CRUISE_MIN_V = [-4.0, -4.0, -4.0, -4.0, -4.0] -_A_CRUISE_MIN_BP = [ 0., 5., 10., 20., 40.] +_A_CRUISE_MIN_V_TESLA = [-4.0, -4.0, -4.0, -4.0, -4.0] +_A_CRUISE_MIN_V = [-1.0, -.8, -.67, -.5, -.30] +_A_CRUISE_MIN_BP = [ 0., 5., 10., 20., 40.] # need fast accel at very low speed for stop and go # make sure these accelerations are smaller than mpc limits -#BB editing for TESLA only -#_A_CRUISE_MAX_V = [2.7, 2., 1.9, 1.75, 1.5] -_A_CRUISE_MAX_V = [2.7, 2.7, 2.0, 2.0, 2.0] -#_A_CRUISE_MAX_V_FOLLOWING = [2.7, 2., 1.9, 1.75, 1.5] -_A_CRUISE_MAX_V_FOLLOWING = [2.7, 2.7, 2.7, 2.7, 2.7] -_A_CRUISE_MAX_BP = [0., 5., 10., 20., 40.] - -# Lookup table for turns -_A_TOTAL_MAX_V = [1.5, 1.9, 2.5] -_A_TOTAL_MAX_BP = [0., 20., 40.] - -# Model speed kalman stuff -_MODEL_V_A = [[1.0, DT_PLAN], [0.0, 1.0]] -_MODEL_V_C = [1.0, 0] -# calculated with observation std of 2m/s and accel proc noise of 2m/s**2 -_MODEL_V_K = [[0.07068858], [0.04826294]] +_A_CRUISE_MAX_V_TESLA = [1.775, 1.85, 1.325, 1.25] +_A_CRUISE_MAX_V = [1.2, 1.2, 0.65, .4] +_A_CRUISE_MAX_V_FOLLOWING_TESLA = [1.6, 1.6, 0.65, .4] +_A_CRUISE_MAX_V_FOLLOWING = [1.6, 1.6, 0.65, .4] +_A_CRUISE_MAX_BP = [0., 6.4, 22.5, 40.] -# 75th percentile -SPEED_PERCENTILE_IDX = 7 +# Lookup table for turns +_A_TOTAL_MAX_V_TESLA = [1.7, 3.2] +_A_TOTAL_MAX_V = [1.7, 3.2] +_A_TOTAL_MAX_BP = [20., 40.] -def calc_cruise_accel_limits(v_ego, following): - a_cruise_min = interp(v_ego, _A_CRUISE_MIN_BP, _A_CRUISE_MIN_V) - if following: - a_cruise_max = interp(v_ego, _A_CRUISE_MAX_BP, _A_CRUISE_MAX_V_FOLLOWING) +def calc_cruise_accel_limits(v_ego, following, is_tesla = False): + if is_tesla: + a_cruise_min = interp(v_ego, _A_CRUISE_MIN_BP, _A_CRUISE_MIN_V_TESLA) + + if following: + a_cruise_max = interp(v_ego, _A_CRUISE_MAX_BP, _A_CRUISE_MAX_V_FOLLOWING_TESLA) + else: + a_cruise_max = interp(v_ego, _A_CRUISE_MAX_BP, _A_CRUISE_MAX_V_TESLA) else: - a_cruise_max = interp(v_ego, _A_CRUISE_MAX_BP, _A_CRUISE_MAX_V) - return np.vstack([a_cruise_min, a_cruise_max]) + a_cruise_min = interp(v_ego, _A_CRUISE_MIN_BP, _A_CRUISE_MIN_V) + + if following: + a_cruise_max = interp(v_ego, _A_CRUISE_MAX_BP, _A_CRUISE_MAX_V_FOLLOWING) + else: + a_cruise_max = interp(v_ego, _A_CRUISE_MAX_BP, _A_CRUISE_MAX_V) + return np.vstack([a_cruise_min, a_cruise_max]) def limit_accel_in_turns(v_ego, angle_steers, a_target, CP): """ This function returns a limited long acceleration allowed, depending on the existing lateral acceleration this should avoid accelerating when losing the target in turns """ - - a_total_max = interp(v_ego, _A_TOTAL_MAX_BP, _A_TOTAL_MAX_V) - a_y = v_ego**2 * angle_steers * CV.DEG_TO_RAD / (CP.steerRatio * CP.wheelbase) - a_x_allowed = math.sqrt(max(a_total_max**2 - a_y**2, 0.)) + if CP.carName == "tesla": + a_total_max = interp(v_ego, _A_TOTAL_MAX_BP, _A_TOTAL_MAX_V_TESLA) + a_y = v_ego**2 * angle_steers * CV.DEG_TO_RAD / (CP.steerRatio * CP.wheelbase) + a_x_allowed = math.sqrt(max(a_total_max**2 - a_y**2, 0.)) + else: + a_total_max = interp(v_ego, _A_TOTAL_MAX_BP, _A_TOTAL_MAX_V) + a_y = v_ego**2 * angle_steers * CV.DEG_TO_RAD / (CP.steerRatio * CP.wheelbase) + a_x_allowed = math.sqrt(max(a_total_max**2 - a_y**2, 0.)) return [a_target[0], min(a_target[1], a_x_allowed)] -class Planner(object): - def __init__(self, CP, fcw_enabled): +class Planner(): + def __init__(self, CP): self.CP = CP - self.plan = messaging.pub_sock(service_list['plan'].port) - self.live_longitudinal_mpc = messaging.pub_sock(service_list['liveLongitudinalMpc'].port) - - self.mpc1 = LongitudinalMpc(1, self.live_longitudinal_mpc) - self.mpc2 = LongitudinalMpc(2, self.live_longitudinal_mpc) + self.mpc1 = LongitudinalMpc(1) + self.mpc2 = LongitudinalMpc(2) self.v_acc_start = 0.0 self.a_acc_start = 0.0 @@ -92,19 +91,17 @@ def __init__(self, CP, fcw_enabled): self.a_acc = 0.0 self.v_cruise = 0.0 self.a_cruise = 0.0 - self.v_model = 0.0 - self.a_model = 0.0 self.longitudinalPlanSource = 'cruise' self.fcw_checker = FCWChecker() - self.fcw_enabled = fcw_enabled self.path_x = np.arange(192) self.params = Params() + self.first_loop = True def choose_solution(self, v_cruise_setpoint, enabled): if enabled: - solutions = {'cruise': self.v_cruise, 'model': self.v_model} + solutions = {'cruise': self.v_cruise} if self.mpc1.prev_lead_status: solutions['mpc1'] = self.mpc1.v_mpc if self.mpc2.prev_lead_status: @@ -123,13 +120,10 @@ def choose_solution(self, v_cruise_setpoint, enabled): elif slowest == 'cruise': self.v_acc = self.v_cruise self.a_acc = self.a_cruise - elif slowest == 'model': - self.v_acc = self.v_model - self.a_acc = self.a_model self.v_acc_future = min([self.mpc1.v_mpc_future, self.mpc2.v_mpc_future, v_cruise_setpoint]) - def update(self, sm, CP, VM, PP): + def update(self, sm, pm, CP, VM, PP): """Gets called when new radarState is available""" cur_time = sec_since_boot() v_ego = sm['carState'].vEgo @@ -137,6 +131,8 @@ def update(self, sm, CP, VM, PP): long_control_state = sm['controlsState'].longControlState v_cruise_kph = sm['controlsState'].vCruise force_slow_decel = sm['controlsState'].forceDecel + + v_cruise_kph = min(v_cruise_kph, V_CRUISE_MAX) v_cruise_setpoint = v_cruise_kph * CV.KPH_TO_MS lead_1 = sm['radarState'].leadOne @@ -145,27 +141,10 @@ def update(self, sm, CP, VM, PP): enabled = (long_control_state == LongCtrlState.pid) or (long_control_state == LongCtrlState.stopping) following = lead_1.status and lead_1.dRel < 45.0 and lead_1.vLeadK > v_ego and lead_1.aLeadK > 0.0 - if len(sm['model'].path.poly): - path = list(sm['model'].path.poly) - - # Curvature of polynomial https://en.wikipedia.org/wiki/Curvature#Curvature_of_the_graph_of_a_function - # y = a x^3 + b x^2 + c x + d, y' = 3 a x^2 + 2 b x + c, y'' = 6 a x + 2 b - # k = y'' / (1 + y'^2)^1.5 - y_p = 3 * path[0] * self.path_x**2 + 2 * path[1] * self.path_x + path[2] - y_pp = 6 * path[0] * self.path_x + 2 * path[1] - curv = y_pp / (1. + y_p**2)**1.5 - - a_y_max = 2.975 - v_ego * 0.0375 # ~1.85 @ 75mph, ~2.6 @ 25mph - v_curvature = np.sqrt(a_y_max / np.clip(np.abs(curv), 1e-4, None)) - model_speed = np.min(v_curvature) - # print(model_speed * CV.MS_TO_MPH, model_speed) - model_speed = max(20.0 * CV.MPH_TO_MS, model_speed) # Don't slow down below 20mph - else: - model_speed = MAX_SPEED - # Calculate speed for normal cruise control - if enabled: - accel_limits = [float(x) for x in calc_cruise_accel_limits(v_ego, following)] + if enabled and not self.first_loop and not sm['carState'].gasPressed: + is_tesla = (CP.carName == "tesla") + accel_limits = [float(x) for x in calc_cruise_accel_limits(v_ego, following,is_tesla)] jerk_limits = [min(-0.1, accel_limits[0]), max(0.1, accel_limits[1])] # TODO: make a separate lookup for jerk tuning accel_limits_turns = limit_accel_in_turns(v_ego, sm['carState'].steeringAngle, accel_limits, self.CP) @@ -180,18 +159,12 @@ def update(self, sm, CP, VM, PP): jerk_limits[1], jerk_limits[0], LON_MPC_STEP) - self.v_model, self.a_model = speed_smoother(self.v_acc_start, self.a_acc_start, - model_speed, - 2*accel_limits[1], accel_limits[0], - 2*jerk_limits[1], jerk_limits[0], - LON_MPC_STEP) - # cruise speed can't be negative even is user is distracted self.v_cruise = max(self.v_cruise, 0.) else: starting = long_control_state == LongCtrlState.starting a_ego = min(sm['carState'].aEgo, 0.0) - reset_speed = MIN_CAN_SPEED if starting else v_ego + reset_speed = self.CP.minSpeedCan if starting else v_ego reset_accel = self.CP.startAccel if starting else a_ego self.v_acc = reset_speed self.a_acc = reset_accel @@ -203,8 +176,8 @@ def update(self, sm, CP, VM, PP): self.mpc1.set_cur_state(self.v_acc_start, self.a_acc_start) self.mpc2.set_cur_state(self.v_acc_start, self.a_acc_start) - self.mpc1.update(sm['carState'], lead_1, v_cruise_setpoint) - self.mpc2.update(sm['carState'], lead_2, v_cruise_setpoint) + self.mpc1.update(pm, sm['carState'], lead_1) + self.mpc2.update(pm, sm['carState'], lead_2) self.choose_solution(v_cruise_setpoint, enabled) @@ -229,8 +202,7 @@ def update(self, sm, CP, VM, PP): radar_can_error = car.RadarData.Error.canError in radar_errors # **** send the plan **** - plan_send = messaging.new_message() - plan_send.init('plan') + plan_send = messaging.new_message('plan') plan_send.valid = sm.all_alive_and_valid(service_list=['carState', 'controlsState', 'radarState']) @@ -255,15 +227,14 @@ def update(self, sm, CP, VM, PP): plan_send.plan.processingDelay = (plan_send.logMonoTime / 1e9) - sm.rcv_time['radarState'] # Send out fcw - fcw = fcw and (self.fcw_enabled or long_control_state != LongCtrlState.off) plan_send.plan.fcw = fcw - self.plan.send(plan_send.to_bytes()) + pm.send('plan', plan_send) # Interpolate 0.05 seconds and save as starting point for next iteration - a_acc_sol = self.a_acc_start + (DT_PLAN / LON_MPC_STEP) * (self.a_acc - self.a_acc_start) - v_acc_sol = self.v_acc_start + DT_PLAN * (a_acc_sol + self.a_acc_start) / 2.0 + a_acc_sol = self.a_acc_start + (CP.radarTimeStep / LON_MPC_STEP) * (self.a_acc - self.a_acc_start) + v_acc_sol = self.v_acc_start + CP.radarTimeStep * (a_acc_sol + self.a_acc_start) / 2.0 self.v_acc_start = v_acc_sol self.a_acc_start = a_acc_sol - #return plan_send + self.first_loop = False diff --git a/selfdrive/controls/lib/radar_helpers.py b/selfdrive/controls/lib/radar_helpers.py index 31deb329b58dfb..a0f4336b8e0d89 100644 --- a/selfdrive/controls/lib/radar_helpers.py +++ b/selfdrive/controls/lib/radar_helpers.py @@ -1,7 +1,6 @@ -from common.realtime import DT_MDL +from common.numpy_fast import mean from common.kalman.simple_kalman import KF1D -from selfdrive.car.tesla.readconfig import CarSettings -from selfdrive.config import RADAR_TO_CENTER +from selfdrive.config import RADAR_TO_CAMERA from common.numpy_fast import clip, interp # the longer lead decels, the more likely it will keep decelerating @@ -14,45 +13,45 @@ # stationary qualification parameters v_ego_stationary = 4. # no stationary object flag below this speed -# Lead Kalman Filter params -_VLEAD_A = [[1.0, DT_MDL], [0.0, 1.0]] -_VLEAD_C = [1.0, 0.0] -#_VLEAD_Q = np.matrix([[10., 0.0], [0.0, 100.]]) -#_VLEAD_R = 1e3 -#_VLEAD_K = np.matrix([[ 0.05705578], [ 0.03073241]]) -_VLEAD_K = [[0.1988689], [0.28555364]] - -class Track(object): - def __init__(self): - self.ekf = None + +class Track(): + def __init__(self, v_lead, kalman_params): self.cnt = 0 + self.aLeadTau = _LEAD_ACCEL_TAU + self.K_A = kalman_params.A + self.K_C = kalman_params.C + self.K_K = kalman_params.K + self.kf = KF1D([[v_lead], [0.0]], self.K_A, self.K_C, self.K_K) - def update(self, d_rel, y_rel, v_rel,measured, a_rel, vy_rel, oClass, length, track_id,movingState, d_path, v_ego_t_aligned,use_tesla_radar): + def update(self, d_rel, y_rel, v_rel,measured, a_rel, vy_rel, oClass, length, track_id,movingState, d_path, v_ego_t_aligned,v_lead,use_tesla_radar): # relative values, copy self.dRel = d_rel # LONG_DIST self.yRel = y_rel # -LAT_DIST self.vRel = v_rel # REL_SPEED - self.aRel = a_rel # rel acceleration - self.vLat = vy_rel # rel lateral speed - self.oClass = oClass # object class - self.length = length #length + self.vLead = v_lead self.measured = measured # measured or estimate self.track_id = track_id - self.dPath = d_path - self.stationary = (movingState == 3) + self.oClass = oClass # object class - # computed velocity and accelerations - self.vLead = self.vRel + v_ego_t_aligned + if use_tesla_radar: + self.aRel = a_rel # rel acceleration + self.vLat = vy_rel # rel lateral speed + self.length = length #length + self.measured = measured # measured or estimate + self.dPath = d_path + self.stationary = (movingState == 3) + else: + self.aRel = float('nan') # rel acceleration + self.vLat = float('nan') # rel lateral speed + self.length = 0. #length + self.dPath = 0. + self.stationary = False - if self.cnt == 0: - self.kf = KF1D([[self.vLead], [0.0]], _VLEAD_A, _VLEAD_C, _VLEAD_K) - else: + if self.cnt > 0: self.kf.update(self.vLead) - self.cnt += 1 - self.vLeadK = float(self.kf.x[SPEED][0]) self.aLeadK = float(self.kf.x[ACCEL][0]) @@ -62,6 +61,8 @@ def update(self, d_rel, y_rel, v_rel,measured, a_rel, vy_rel, oClass, length, tr else: self.aLeadTau *= 0.9 + self.cnt += 1 + def get_key_for_cluster(self): # Weigh y higher since radar is inaccurate in this dimension return [self.dRel, self.yRel*2, self.vRel] @@ -71,20 +72,17 @@ def get_key_for_cluster_dy(self, dy): return [self.dRel, (self.yRel-dy)*2, self.vRel] def reset_a_lead(self, aLeadK, aLeadTau): - self.kf = KF1D([[self.vLead], [aLeadK]], _VLEAD_A, _VLEAD_C, _VLEAD_K) + self.kf = KF1D([[self.vLead], [aLeadK]], self.K_A, self.K_C, self.K_K) self.aLeadK = aLeadK self.aLeadTau = aLeadTau -def mean(l): - return sum(l) / len(l) - -class Cluster(object): - def __init__(self): +class Cluster(): + def __init__(self,use_tesla_radar): self.tracks = set() #BB frame delay for dRel calculation, in seconds self.frame_delay = 0.2 - self.useTeslaRadar = CarSettings().get_value("useTeslaRadar") + self.useTeslaRadar = use_tesla_radar def add(self, t): # add the first track @@ -139,11 +137,11 @@ def aLeadTau(self): @property def measured(self): - return any([t.measured for t in self.tracks]) + return any(t.measured for t in self.tracks) @property def oClass(self): - return all([t.oClass for t in self.tracks]) + return min([t.oClass for t in self.tracks]) @property def length(self): @@ -151,7 +149,7 @@ def length(self): @property def track_id(self): - return mean([t.track_id for t in self.tracks]) + return max([t.track_id for t in self.tracks]) @property def stationary(self): @@ -181,7 +179,7 @@ def get_RadarState(self, model_prob=0.0): def get_RadarState_from_vision(self, lead_msg, v_ego): return { - "dRel": float(lead_msg.dist - RADAR_TO_CENTER), + "dRel": float(lead_msg.dist - RADAR_TO_CAMERA), "yRel": float(lead_msg.relY), "vRel": float(lead_msg.relVel), "vLead": float(v_ego + lead_msg.relVel), @@ -203,25 +201,16 @@ def is_potential_lead(self, v_ego): # lookahead time depends on cut-in distance. more attentive for close cut-ins # also, above 50 meters the predicted path isn't very reliable - # the distance at which v_lat matters is higher at higher speed - lookahead_dist = 40. + v_ego/1.2 #40m at 0mph, ~70m at 80mph - - t_lookahead_v = [1., 0.] - t_lookahead_bp = [10., lookahead_dist] - # average dist d_path = self.dPath - # lat_corr used to be gated on enabled, now always running - t_lookahead = interp(self.dRel, t_lookahead_bp, t_lookahead_v) - # correct d_path for lookahead time, considering only cut-ins and no more than 1m impact. lat_corr = 0. # BB disables for now : clip(t_lookahead * self.vLat, -1., 1.) if self.measured else 0. # consider only cut-ins d_path = clip(d_path + lat_corr, min(0., d_path), max(0.,d_path)) - return abs(d_path) < 1.5 and not self.stationary and not self.oncoming + return abs(d_path) < 1.5 and not self.stationary #and not self.oncoming def is_potential_lead_dy(self, v_ego,dy): # predict cut-ins by extrapolating lateral speed by a lookahead time diff --git a/selfdrive/controls/lib/speed_smoother.py b/selfdrive/controls/lib/speed_smoother.py index 1ee7ec6b18cb5d..431822dd9f0627 100644 --- a/selfdrive/controls/lib/speed_smoother.py +++ b/selfdrive/controls/lib/speed_smoother.py @@ -67,7 +67,7 @@ def speed_smoother(vEgo, aEgo, vT, aMax, aMin, jMax, jMin, ts): if aPeak > aMax: aPeak = aMax t1 = (aPeak - aEgo) / jMax - if aPeak <= 0: # there is no solution, so stop after t1 + if aPeak <= 0: # there is no solution, so stop after t1 t2 = t1 + ts + 1e-9 t3 = t2 else: diff --git a/selfdrive/controls/lib/vehicle_model.py b/selfdrive/controls/lib/vehicle_model.py index 1dc77bf375afb6..238550dca4022c 100755 --- a/selfdrive/controls/lib/vehicle_model.py +++ b/selfdrive/controls/lib/vehicle_model.py @@ -1,7 +1,4 @@ -#!/usr/bin/env python -import numpy as np -from numpy.linalg import solve - +#!/usr/bin/env python3 """ Dynamic bycicle model from "The Science of Vehicle Dynamics (2014), M. Guiggiani" @@ -15,83 +12,15 @@ A depends on longitudinal speed, u [m/s], and vehicle parameters CP """ +from typing import Tuple +import numpy as np +from numpy.linalg import solve -def create_dyn_state_matrices(u, VM): - """Returns the A and B matrix for the dynamics system - - Args: - u: Vehicle speed [m/s] - VM: Vehicle model - - Returns: - A tuple with the 2x2 A matrix, and 2x1 B matrix - - Parameters in the vehicle model: - cF: Tire stiffnes Front [N/rad] - cR: Tire stiffnes Front [N/rad] - aF: Distance from CG to front wheels [m] - aR: Distance from CG to rear wheels [m] - m: Mass [kg] - j: Rotational inertia [kg m^2] - sR: Steering ratio [-] - chi: Steer ratio rear [-] - """ - A = np.zeros((2, 2)) - B = np.zeros((2, 1)) - A[0, 0] = - (VM.cF + VM.cR) / (VM.m * u) - A[0, 1] = - (VM.cF * VM.aF - VM.cR * VM.aR) / (VM.m * u) - u - A[1, 0] = - (VM.cF * VM.aF - VM.cR * VM.aR) / (VM.j * u) - A[1, 1] = - (VM.cF * VM.aF**2 + VM.cR * VM.aR**2) / (VM.j * u) - B[0, 0] = (VM.cF + VM.chi * VM.cR) / VM.m / VM.sR - B[1, 0] = (VM.cF * VM.aF - VM.chi * VM.cR * VM.aR) / VM.j / VM.sR - return A, B - - -def kin_ss_sol(sa, u, VM): - """Calculate the steady state solution at low speeds - At low speeds the tire slip is undefined, so a kinematic - model is used. - - Args: - sa: Steering angle [rad] - u: Speed [m/s] - VM: Vehicle model - - Returns: - 2x1 matrix with steady state solution - """ - K = np.zeros((2, 1)) - K[0, 0] = VM.aR / VM.sR / VM.l * u - K[1, 0] = 1. / VM.sR / VM.l * u - return K * sa - - -def dyn_ss_sol(sa, u, VM): - """Calculate the steady state solution when x_dot = 0, - Ax + Bu = 0 => x = A^{-1} B u - - Args: - sa: Steering angle [rad] - u: Speed [m/s] - VM: Vehicle model - - Returns: - 2x1 matrix with steady state solution - """ - A, B = create_dyn_state_matrices(u, VM) - return -solve(A, B) * sa - - -def calc_slip_factor(VM): - """The slip factor is a measure of how the curvature changes with speed - it's positive for Oversteering vehicle, negative (usual case) otherwise. - """ - return VM.m * (VM.cF * VM.aF - VM.cR * VM.aR) / (VM.l**2 * VM.cF * VM.cR) - +from cereal import car -class VehicleModel(object): - def __init__(self, CP): +class VehicleModel: + def __init__(self, CP: car.CarParams): """ Args: CP: Car Parameters @@ -108,13 +37,13 @@ def __init__(self, CP): self.cR_orig = CP.tireStiffnessRear self.update_params(1.0, CP.steerRatio) - def update_params(self, stiffness_factor, steer_ratio): + def update_params(self, stiffness_factor: float, steer_ratio: float) -> None: """Update the vehicle model with a new stiffness factor and steer ratio""" self.cF = stiffness_factor * self.cF_orig self.cR = stiffness_factor * self.cR_orig self.sR = steer_ratio - def steady_state_sol(self, sa, u): + def steady_state_sol(self, sa: float, u: float) -> np.ndarray: """Returns the steady state solution. If the speed is too small we can't use the dynamic model (tire slip is undefined), @@ -132,7 +61,7 @@ def steady_state_sol(self, sa, u): else: return kin_ss_sol(sa, u, self) - def calc_curvature(self, sa, u): + def calc_curvature(self, sa: float, u: float) -> float: """Returns the curvature. Multiplied by the speed this will give the yaw rate. Args: @@ -140,11 +69,11 @@ def calc_curvature(self, sa, u): u: Speed [m/s] Returns: - Curvature factor [rad/m] + Curvature factor [1/m] """ return self.curvature_factor(u) * sa / self.sR - def curvature_factor(self, u): + def curvature_factor(self, u: float) -> float: """Returns the curvature factor. Multiplied by wheel angle (not steering wheel angle) this will give the curvature. @@ -157,11 +86,11 @@ def curvature_factor(self, u): sf = calc_slip_factor(self) return (1. - self.chi) / (1. - sf * u**2) / self.l - def get_steer_from_curvature(self, curv, u): + def get_steer_from_curvature(self, curv: float, u: float) -> float: """Calculates the required steering wheel angle for a given curvature Args: - curv: Desired curvature [rad/s] + curv: Desired curvature [1/m] u: Speed [m/s] Returns: @@ -170,7 +99,20 @@ def get_steer_from_curvature(self, curv, u): return curv * self.sR * 1.0 / self.curvature_factor(u) - def yaw_rate(self, sa, u): + def get_steer_from_yaw_rate(self, yaw_rate: float, u: float) -> float: + """Calculates the required steering wheel angle for a given yaw_rate + + Args: + yaw_rate: Desired yaw rate [rad/s] + u: Speed [m/s] + + Returns: + Steering wheel angle [rad] + """ + curv = yaw_rate / u + return self.get_steer_from_curvature(curv, u) + + def yaw_rate(self, sa: float, u: float) -> float: """Calculate yaw rate Args: @@ -183,11 +125,74 @@ def yaw_rate(self, sa, u): return self.calc_curvature(sa, u) * u -if __name__ == '__main__': - import math - from selfdrive.car.honda.interface import CarInterface - from selfdrive.car.honda.values import CAR +def kin_ss_sol(sa: float, u: float, VM: VehicleModel) -> np.ndarray: + """Calculate the steady state solution at low speeds + At low speeds the tire slip is undefined, so a kinematic + model is used. + + Args: + sa: Steering angle [rad] + u: Speed [m/s] + VM: Vehicle model + + Returns: + 2x1 matrix with steady state solution + """ + K = np.zeros((2, 1)) + K[0, 0] = VM.aR / VM.sR / VM.l * u + K[1, 0] = 1. / VM.sR / VM.l * u + return K * sa + + +def create_dyn_state_matrices(u: float, VM: VehicleModel) -> Tuple[np.ndarray, np.ndarray]: + """Returns the A and B matrix for the dynamics system - CP = CarInterface.get_params(CAR.CIVIC, {}) - VM = VehicleModel(CP) - print(VM.yaw_rate(math.radians(20), 10.)) + Args: + u: Vehicle speed [m/s] + VM: Vehicle model + + Returns: + A tuple with the 2x2 A matrix, and 2x1 B matrix + + Parameters in the vehicle model: + cF: Tire stiffnes Front [N/rad] + cR: Tire stiffnes Front [N/rad] + aF: Distance from CG to front wheels [m] + aR: Distance from CG to rear wheels [m] + m: Mass [kg] + j: Rotational inertia [kg m^2] + sR: Steering ratio [-] + chi: Steer ratio rear [-] + """ + A = np.zeros((2, 2)) + B = np.zeros((2, 1)) + A[0, 0] = - (VM.cF + VM.cR) / (VM.m * u) + A[0, 1] = - (VM.cF * VM.aF - VM.cR * VM.aR) / (VM.m * u) - u + A[1, 0] = - (VM.cF * VM.aF - VM.cR * VM.aR) / (VM.j * u) + A[1, 1] = - (VM.cF * VM.aF**2 + VM.cR * VM.aR**2) / (VM.j * u) + B[0, 0] = (VM.cF + VM.chi * VM.cR) / VM.m / VM.sR + B[1, 0] = (VM.cF * VM.aF - VM.chi * VM.cR * VM.aR) / VM.j / VM.sR + return A, B + + +def dyn_ss_sol(sa: float, u: float, VM: VehicleModel) -> np.ndarray: + """Calculate the steady state solution when x_dot = 0, + Ax + Bu = 0 => x = A^{-1} B u + + Args: + sa: Steering angle [rad] + u: Speed [m/s] + VM: Vehicle model + + Returns: + 2x1 matrix with steady state solution + """ + A, B = create_dyn_state_matrices(u, VM) + return -solve(A, B) * sa + + +def calc_slip_factor(VM): + """The slip factor is a measure of how the curvature changes with speed + it's positive for Oversteering vehicle, negative (usual case) otherwise. + """ + return VM.m * (VM.cF * VM.aF - VM.cR * VM.aR) / (VM.l**2 * VM.cF * VM.cR) diff --git a/selfdrive/controls/plannerd.py b/selfdrive/controls/plannerd.py index 9286ea0588ea1d..1f19266f1bad4b 100755 --- a/selfdrive/controls/plannerd.py +++ b/selfdrive/controls/plannerd.py @@ -1,37 +1,33 @@ -#!/usr/bin/env python -import gc - +#!/usr/bin/env python3 from cereal import car from common.params import Params -from common.realtime import set_realtime_priority +from common.realtime import Priority, config_realtime_process from selfdrive.swaglog import cloudlog from selfdrive.controls.lib.planner import Planner from selfdrive.controls.lib.vehicle_model import VehicleModel from selfdrive.controls.lib.pathplanner import PathPlanner -import selfdrive.messaging as messaging - +import cereal.messaging as messaging -def plannerd_thread(): - gc.disable() - # start the loop - set_realtime_priority(2) +def plannerd_thread(sm=None, pm=None): - params = Params() - - # Get FCW toggle from settings - fcw_enabled = params.get("IsFcwEnabled") == "1" + config_realtime_process(2, Priority.CTRL_LOW) cloudlog.info("plannerd is waiting for CarParams") CP = car.CarParams.from_bytes(Params().get("CarParams", block=True)) cloudlog.info("plannerd got CarParams: %s", CP.carName) - PL = Planner(CP, fcw_enabled) + PL = Planner(CP) PP = PathPlanner(CP) VM = VehicleModel(CP) - sm = messaging.SubMaster(['carState', 'controlsState', 'radarState', 'model', 'liveParameters']) + if sm is None: + sm = messaging.SubMaster(['carState', 'controlsState', 'radarState', 'model', 'liveParameters'], + poll=['radarState', 'model']) + + if pm is None: + pm = messaging.PubMaster(['plan', 'liveLongitudinalMpc', 'pathPlan', 'liveMpc']) sm['liveParameters'].valid = True sm['liveParameters'].sensorValid = True @@ -42,13 +38,13 @@ def plannerd_thread(): sm.update() if sm.updated['model']: - PP.update(sm, CP, VM) + PP.update(sm, pm, CP, VM) if sm.updated['radarState']: - PL.update(sm, CP, VM, PP) + PL.update(sm, pm, CP, VM, PP) -def main(gctx=None): - plannerd_thread() +def main(sm=None, pm=None): + plannerd_thread(sm, pm) if __name__ == "__main__": diff --git a/selfdrive/controls/radard.py b/selfdrive/controls/radard.py index 03abcf461149be..624e3350ea69fc 100755 --- a/selfdrive/controls/radard.py +++ b/selfdrive/controls/radard.py @@ -1,57 +1,64 @@ -#!/usr/bin/env python -import numpy as np -import numpy.matlib +#!/usr/bin/env python3 import importlib +import math from collections import defaultdict, deque +import numpy as np -import selfdrive.messaging as messaging -from selfdrive.services import service_list -from selfdrive.controls.lib.radar_helpers import Track, Cluster -from selfdrive.config import RADAR_TO_CENTER -from selfdrive.controls.lib.cluster.fastcluster_py import cluster_points_centroid -from selfdrive.swaglog import cloudlog +import cereal.messaging as messaging from cereal import car,tesla +from common.numpy_fast import interp from common.params import Params -from common.realtime import set_realtime_priority, Ratekeeper, DT_MDL -from selfdrive.car.tesla.readconfig import read_config_file,CarSettings -from selfdrive.controls.lib.lane_planner import LanePlanner +from common.realtime import Ratekeeper, Priority, config_realtime_process +from selfdrive.config import RADAR_TO_CAMERA +from selfdrive.controls.lib.cluster.fastcluster_py import cluster_points_centroid +from selfdrive.controls.lib.radar_helpers import Cluster, Track +from selfdrive.swaglog import cloudlog +from selfdrive.car.tesla.readconfig import CarSettings DEBUG = False - -#vision point -DIMSV = 2 -XV, SPEEDV = 0, 1 -VISION_POINT = -1 -RDR_TO_LDR = 0. - -# Time-alignment -rate = 1. / DT_MDL # model and radar are both at 20Hz -v_len = 20 # how many speed data points to remember for t alignment with rdr data +RDR_TO_LDR = 0 + +class KalmanParams(): + def __init__(self, dt): + # Lead Kalman Filter params, calculating K from A, C, Q, R requires the control library. + # hardcoding a lookup table to compute K for values of radar_ts between 0.1s and 1.0s + assert dt > .01 and dt < .1, "Radar time step must be between .01s and 0.1s" + self.A = [[1.0, dt], [0.0, 1.0]] + self.C = [1.0, 0.0] + #Q = np.matrix([[10., 0.0], [0.0, 100.]]) + #R = 1e3 + #K = np.matrix([[ 0.05705578], [ 0.03073241]]) + dts = [dt * 0.01 for dt in range(1, 11)] + K0 = [0.12288, 0.14557, 0.16523, 0.18282, 0.19887, 0.21372, 0.22761, 0.24069, 0.2531, 0.26491] + K1 = [0.29666, 0.29331, 0.29043, 0.28787, 0.28555, 0.28342, 0.28144, 0.27958, 0.27783, 0.27617] + self.K = [[interp(dt, dts, K0)], [interp(dt, dts, K1)]] def laplacian_cdf(x, mu, b): - b = np.max([b, 1e-4]) - return np.exp(-abs(x-mu)/b) + b = max(b, 1e-4) + return math.exp(-abs(x-mu)/b) def match_vision_to_cluster(v_ego, lead, clusters): # match vision point to best statistical cluster match - probs = [] - offset_vision_dist = lead.dist - RADAR_TO_CENTER - for c in clusters: + offset_vision_dist = lead.dist - RADAR_TO_CAMERA + + def prob(c): prob_d = laplacian_cdf(c.dRel, offset_vision_dist, lead.std) prob_y = laplacian_cdf(c.yRel, lead.relY, lead.relYStd) prob_v = laplacian_cdf(c.vRel, lead.relVel, lead.relVelStd) + # This is isn't exactly right, but good heuristic - combined_prob = prob_d * prob_y * prob_v - probs.append(combined_prob) - idx = np.argmax(probs) + return prob_d * prob_y * prob_v + + cluster = max(clusters, key=prob) + # if no 'sane' match is found return -1 # stationary radar points can be false positives - dist_sane = abs(clusters[idx].dRel - offset_vision_dist) < max([(offset_vision_dist)*.25, 5.0]) - vel_sane = (abs(clusters[idx].vRel - lead.relVel) < 10) or (v_ego + clusters[idx].vRel > 2) + dist_sane = abs(cluster.dRel - offset_vision_dist) < max([(offset_vision_dist)*.25, 5.0]) + vel_sane = (abs(cluster.vRel - lead.relVel) < 10) or (v_ego + cluster.vRel > 3) if dist_sane and vel_sane: - return idx + return cluster else: return None @@ -62,75 +69,83 @@ def get_rrext_by_trackId(rrext,trackId): return p return None -def get_lead(v_ego, ready, clusters, lead_msg, low_speed_override=True): +def get_lead(v_ego, ready, clusters, lead_msg, low_speed_override=True,use_tesla_radar=False): # Determine leads, this is where the essential logic happens if len(clusters) > 0 and ready and lead_msg.prob > .5: - lead_idx = match_vision_to_cluster(v_ego, lead_msg, clusters) + cluster = match_vision_to_cluster(v_ego, lead_msg, clusters) else: - lead_idx = None + cluster = None lead_dict = {'status': False} - lead_dict_ext = {'trackId': 1, 'oClass': 0, 'length': 0.} - if lead_idx is not None: - lead_dict,lead_dict_ext = clusters[lead_idx].get_RadarState(lead_msg.prob) - elif (lead_idx is None) and ready and (lead_msg.prob > .5): - lead_dict = Cluster().get_RadarState_from_vision(lead_msg, v_ego) + lead_dict_ext = {'trackId': 1, 'oClass': 1, 'length': 0.} + # temporary for development purposes: we set the default lead vehicle type to truck (=0) to distinguish between vision (truck) and radar leads (car) in IC + if use_tesla_radar: + lead_dict_ext['oClass'] = 0 + if cluster is not None: + lead_dict,lead_dict_ext = cluster.get_RadarState(lead_msg.prob) + elif (cluster is None) and ready and (lead_msg.prob > .5): + lead_dict = Cluster(use_tesla_radar).get_RadarState_from_vision(lead_msg, v_ego) if low_speed_override: low_speed_clusters = [c for c in clusters if c.potential_low_speed_lead(v_ego)] if len(low_speed_clusters) > 0: - lead_idx = np.argmin([c.dRel for c in low_speed_clusters]) - if (not lead_dict['status']) or (low_speed_clusters[lead_idx].dRel < lead_dict['dRel']): - lead_dict,lead_dict_ext = low_speed_clusters[lead_idx].get_RadarState() + closest_cluster = min(low_speed_clusters, key=lambda c: c.dRel) + + # Only choose new cluster if it is actually closer than the previous one + if (not lead_dict['status']) or (closest_cluster.dRel < lead_dict['dRel']): + lead_dict,lead_dict_ext = closest_cluster.get_RadarState() return lead_dict,lead_dict_ext -class RadarD(object): - def __init__(self, mocked, RI): +class RadarD(): + def __init__(self, radar_ts, RI,use_tesla_radar, delay=0): self.current_time = 0 - self.mocked = mocked self.RI = RI self.tracks = defaultdict(dict) - - self.last_md_ts = 0 - self.last_controls_state_ts = 0 - - self.active = 0 + self.kalman_params = KalmanParams(radar_ts) # v_ego self.v_ego = 0. - self.v_ego_hist_t = deque([0], maxlen=v_len) - self.v_ego_hist_v = deque([0], maxlen=v_len) - self.v_ego_t_aligned = 0. + self.v_ego_hist = deque([0], maxlen=delay+1) + self.ready = False self.icCarLR = None - if (RI.TRACK_RIGHT_LANE or RI.TRACK_LEFT_LANE) and CarSettings().get_value("useTeslaRadar"): - self.icCarLR = messaging.pub_sock(service_list['uiIcCarLR'].port) + self.use_tesla_radar = use_tesla_radar + if self.use_tesla_radar: + if (RI.TRACK_RIGHT_LANE or RI.TRACK_LEFT_LANE): + self.icCarLR = messaging.pub_sock('uiIcCarLR') - + self.lane_width = 3.0 #only used for left and right lanes self.path_x = np.arange(0.0, 160.0, 0.1) # 160 meters is max + self.dPoly = [0.,0.,0.,0.] - def update(self, frame, delay, sm, rr, has_radar,MP,rrext): - self.current_time = 1e-9*max([sm.logMonoTime[key] for key in sm.logMonoTime.keys()]) - use_tesla_radar = CarSettings().get_value("useTeslaRadar") + def update(self, frame, sm, rr, enable_lead, rrext): + self.current_time = 1e-9*max(sm.logMonoTime.values()) + if sm.updated['controlsState']: - self.active = sm['controlsState'].active self.v_ego = sm['controlsState'].vEgo - self.v_ego_hist_v.append(self.v_ego) - self.v_ego_hist_t.append(float(frame)/rate) + self.v_ego_hist.append(self.v_ego) if sm.updated['model']: self.ready = True + if self.use_tesla_radar: + if sm.updated['pathPlan']: + self.lane_width = sm['pathPlan'].laneWidth + self.dPoly = sm['pathPlan'].dPoly - path_y = np.polyval(MP.d_poly, self.path_x) + path_y = np.polyval(self.dPoly, self.path_x) ar_pts = {} for pt in rr.points: - extpt = get_rrext_by_trackId(rrext,pt.trackId) - ar_pts[pt.trackId] = [pt.dRel + RDR_TO_LDR, pt.yRel, pt.vRel, pt.measured, pt.aRel, pt.yvRel, extpt.objectClass, extpt.length, pt.trackId+2, extpt.movingState] + if rrext: + extpt = get_rrext_by_trackId(rrext,pt.trackId) + ar_pts[pt.trackId] = [pt.dRel, pt.yRel, pt.vRel, pt.measured, pt.aRel, pt.yvRel, extpt.objectClass, extpt.length, pt.trackId+2, extpt.movingState] + else: + ar_pts[pt.trackId] = [pt.dRel, pt.yRel, pt.vRel, pt.measured, pt.aRel, pt.yvRel, 1, 0, pt.trackId+2, 1] + # *** remove missing points from meta data *** - for ids in self.tracks.keys(): + for ids in list(self.tracks.keys()): if ids not in ar_pts: self.tracks.pop(ids, None) @@ -139,8 +154,7 @@ def update(self, frame, delay, sm, rr, has_radar,MP,rrext): rpt = ar_pts[ids] # align v_ego by a fixed time to align it with the radar measurement - cur_time = float(frame)/rate - self.v_ego_t_aligned = np.interp(cur_time - delay, self.v_ego_hist_t, self.v_ego_hist_v) + v_lead = rpt[2] + self.v_ego_hist[0] # distance relative to path d_path = np.sqrt(np.amin((self.path_x - rpt[0]) ** 2 + (path_y - rpt[1]) ** 2)) @@ -149,33 +163,32 @@ def update(self, frame, delay, sm, rr, has_radar,MP,rrext): # create the track if it doesn't exist or it's a new track if ids not in self.tracks: - self.tracks[ids] = Track() - self.tracks[ids].update(rpt[0], rpt[1], rpt[2], rpt[3], rpt[4],rpt[5],rpt[6],rpt[7],rpt[8],rpt[9], d_path, self.v_ego_t_aligned,use_tesla_radar) - - idens = list(self.tracks.keys()) - track_pts = np.array([self.tracks[iden].get_key_for_cluster() for iden in idens]) + self.tracks[ids] = Track(v_lead, self.kalman_params) + self.tracks[ids].update(rpt[0], rpt[1], rpt[2], rpt[3], rpt[4],rpt[5],rpt[6],rpt[7],rpt[8],rpt[9], d_path, self.v_ego,v_lead,self.use_tesla_radar) + idens = list(sorted(self.tracks.keys())) + track_pts = list([self.tracks[iden].get_key_for_cluster() for iden in idens]) # If we have multiple points, cluster them if len(track_pts) > 1: cluster_idxs = cluster_points_centroid(track_pts, 2.5) clusters = [None] * (max(cluster_idxs) + 1) - for idx in xrange(len(track_pts)): + for idx in range(len(track_pts)): cluster_i = cluster_idxs[idx] if clusters[cluster_i] is None: - clusters[cluster_i] = Cluster() + clusters[cluster_i] = Cluster(self.use_tesla_radar) clusters[cluster_i].add(self.tracks[idens[idx]]) elif len(track_pts) == 1: # FIXME: cluster_point_centroid hangs forever if len(track_pts) == 1 cluster_idxs = [0] - clusters = [Cluster()] + clusters = [Cluster(self.use_tesla_radar)] clusters[0].add(self.tracks[idens[0]]) else: clusters = [] # if a new point, reset accel to the rest of the cluster - for idx in xrange(len(track_pts)): + for idx in range(len(track_pts)): if self.tracks[idens[idx]].cnt <= 1: aLeadK = clusters[cluster_idxs[idx]].aLeadK aLeadTau = clusters[cluster_idxs[idx]].aLeadTau @@ -186,215 +199,218 @@ def update(self, frame, delay, sm, rr, has_radar,MP,rrext): ################################################################# #BB For Tesla integration we will also track Left and Right lanes ################################################################# - if (self.RI.TRACK_RIGHT_LANE or self.RI.TRACK_LEFT_LANE) and use_tesla_radar: - datrl = tesla.ICCarsLR.new_message() - datrl.v1Type = int(0) - datrl.v1Dx = float(0.) - datrl.v1Vrel = float(0.) - datrl.v1Dy = float(0.) - datrl.v1Id = int(0) - datrl.v2Type = int(0) - datrl.v2Dx = float(0.) - datrl.v2Vrel = float(0.) - datrl.v2Dy = float(0.) - datrl.v2Id = int(0) - datrl.v3Type = int(0) - datrl.v3Dx = float(0.) - datrl.v3Vrel = float(0.) - datrl.v3Dy = float(0.) - datrl.v3Id = int(0) - datrl.v4Type = int(0) - datrl.v4Dx = float(0.) - datrl.v4Vrel = float(0.) - datrl.v4Dy = float(0.) - datrl.v4Id = int(0) - lane_offset = 0. #MP.lane_width - lane_width = 3. #BB: static for now, needs to be computed - #LEFT LANE - if self.RI.TRACK_LEFT_LANE and use_tesla_radar: - ll_track_pts = np.array([self.tracks[iden].get_key_for_cluster_dy(-lane_width) for iden in idens]) - # If we have multiple points, cluster them - if len(ll_track_pts) > 1: - ll_cluster_idxs = cluster_points_centroid(ll_track_pts, 2.5) - ll_clusters = [None] * (max(ll_cluster_idxs) + 1) - - for idx in xrange(len(ll_track_pts)): - ll_cluster_i = ll_cluster_idxs[idx] - - if ll_clusters[ll_cluster_i] == None: - ll_clusters[ll_cluster_i] = Cluster() - ll_clusters[ll_cluster_i].add(self.tracks[idens[idx]]) - elif len(ll_track_pts) == 1: - # TODO: why do we need this? - ll_clusters = [Cluster()] - ll_clusters[0].add(self.tracks[idens[0]]) - else: - ll_clusters = [] - if DEBUG: - for i in ll_clusters: - print(i) - # *** extract the lead car *** - ll_lead_clusters = [c for c in ll_clusters - if c.is_potential_lead_dy(self.v_ego,-lane_width)] - ll_lead_clusters.sort(key=lambda x: x.dRel) - ll_lead_len = len(ll_lead_clusters) - ll_lead1_truck = (len([c for c in ll_lead_clusters - if c.is_truck(ll_lead_clusters)]) > 0) - - # *** extract the second lead from the whole set of leads *** - ll_lead2_clusters = [c for c in ll_lead_clusters - if c.is_potential_lead2(ll_lead_clusters)] - ll_lead2_clusters.sort(key=lambda x: x.dRel) - ll_lead2_len = len(ll_lead2_clusters) - ll_lead2_truck = (len([c for c in ll_lead_clusters - if c.is_truck(ll_lead2_clusters)]) > 0) - # publish data - if ll_lead_len > 0: - datrl.v1Type = int(ll_lead_clusters[0].oClass) - if datrl.v1Type == 1 and ll_lead1_truck: - datrl.v1Type = 0 - datrl.v1Dx = float(ll_lead_clusters[0].dRel) - datrl.v1Vrel = float(ll_lead_clusters[0].vRel) - datrl.v1Dy = float(-ll_lead_clusters[0].yRel - lane_offset) - datrl.v1Id = int(ll_lead_clusters[0].track_id % 32) - if ll_lead2_len > 0: - datrl.v2Type = int(ll_lead2_clusters[0].oClass) - if datrl.v2Type == 1 and ll_lead2_truck: - datrl.v2Type = 0 - datrl.v2Dx = float(ll_lead2_clusters[0].dRel) - datrl.v2Vrel = float(ll_lead2_clusters[0].vRel) - datrl.v2Dy = float(-ll_lead2_clusters[0].yRel - lane_offset) - datrl.v2Id = int(ll_lead2_clusters[0].track_id % 32) - #RIGHT LANE - if self.RI.TRACK_RIGHT_LANE and use_tesla_radar: - rl_track_pts = np.array([self.tracks[iden].get_key_for_cluster_dy(lane_width) for iden in idens]) - # If we have multiple points, cluster them - if len(rl_track_pts) > 1: - rl_cluster_idxs = cluster_points_centroid(rl_track_pts, 2.5) - rl_clusters = [None] * (max(rl_cluster_idxs) + 1) - - for idx in xrange(len(rl_track_pts)): - rl_cluster_i = rl_cluster_idxs[idx] - - if rl_clusters[rl_cluster_i] == None: - rl_clusters[rl_cluster_i] = Cluster() - rl_clusters[rl_cluster_i].add(self.tracks[idens[idx]]) - elif len(rl_track_pts) == 1: - # TODO: why do we need this? - rl_clusters = [Cluster()] - rl_clusters[0].add(self.tracks[idens[0]]) - else: - rl_clusters = [] - if DEBUG: - for i in rl_clusters: - print(i) - # *** extract the lead car *** - rl_lead_clusters = [c for c in rl_clusters - if c.is_potential_lead_dy(self.v_ego,lane_width)] - rl_lead_clusters.sort(key=lambda x: x.dRel) - rl_lead_len = len(rl_lead_clusters) - rl_lead1_truck = (len([c for c in rl_lead_clusters - if c.is_truck(rl_lead_clusters)]) > 0) - # *** extract the second lead from the whole set of leads *** - rl_lead2_clusters = [c for c in rl_lead_clusters - if c.is_potential_lead2(rl_lead_clusters)] - rl_lead2_clusters.sort(key=lambda x: x.dRel) - rl_lead2_len = len(rl_lead2_clusters) - rl_lead2_truck = (len([c for c in rl_lead_clusters - if c.is_truck(rl_lead2_clusters)]) > 0) - # publish data - if rl_lead_len > 0: - datrl.v3Type = int(rl_lead_clusters[0].oClass) - if datrl.v3Type == 1 and rl_lead1_truck: - datrl.v3Type = 0 - datrl.v3Dx = float(rl_lead_clusters[0].dRel) - datrl.v3Vrel = float(rl_lead_clusters[0].vRel) - datrl.v3Dy = float(-rl_lead_clusters[0].yRel+ lane_offset) - datrl.v3Id = int(rl_lead_clusters[0].track_id % 32) - if rl_lead2_len > 0: - datrl.v4Type = int(rl_lead2_clusters[0].oClass) - if datrl.v4Type == 1 and rl_lead2_truck: - datrl.v4Type = 0 - datrl.v4Dx = float(rl_lead2_clusters[0].dRel) - datrl.v4Vrel = float(rl_lead2_clusters[0].vRel) - datrl.v4Dy = float(-rl_lead2_clusters[0].yRel + lane_offset) - datrl.v4Id = int(rl_lead2_clusters[0].track_id % 32) - if (self.RI.TRACK_RIGHT_LANE or self.RI.TRACK_LEFT_LANE) and use_tesla_radar: - self.icCarLR.send(datrl.to_bytes()) - - ### END REVIEW SECTION + if self.use_tesla_radar: + if (self.RI.TRACK_RIGHT_LANE or self.RI.TRACK_LEFT_LANE): + datrl = tesla.ICCarsLR.new_message() + datrl.v1Type = int(0) + datrl.v1Dx = float(0.) + datrl.v1Vrel = float(0.) + datrl.v1Dy = float(0.) + datrl.v1Id = int(0) + datrl.v2Type = int(0) + datrl.v2Dx = float(0.) + datrl.v2Vrel = float(0.) + datrl.v2Dy = float(0.) + datrl.v2Id = int(0) + datrl.v3Type = int(0) + datrl.v3Dx = float(0.) + datrl.v3Vrel = float(0.) + datrl.v3Dy = float(0.) + datrl.v3Id = int(0) + datrl.v4Type = int(0) + datrl.v4Dx = float(0.) + datrl.v4Vrel = float(0.) + datrl.v4Dy = float(0.) + datrl.v4Id = int(0) + lane_offset = 0. + #LEFT LANE + if self.RI.TRACK_LEFT_LANE: + ll_track_pts = np.array([self.tracks[iden].get_key_for_cluster_dy(-self.lane_width) for iden in idens]) + # If we have multiple points, cluster them + if len(ll_track_pts) > 1: + ll_cluster_idxs = cluster_points_centroid(ll_track_pts, 2.5) + ll_clusters = [None] * (max(ll_cluster_idxs) + 1) + + for idx in range(len(ll_track_pts)): + ll_cluster_i = ll_cluster_idxs[idx] + + if ll_clusters[ll_cluster_i] == None: + ll_clusters[ll_cluster_i] = Cluster(self.use_tesla_radar) + ll_clusters[ll_cluster_i].add(self.tracks[idens[idx]]) + elif len(ll_track_pts) == 1: + # TODO: why do we need this? + ll_clusters = [Cluster(self.use_tesla_radar)] + ll_clusters[0].add(self.tracks[idens[0]]) + else: + ll_clusters = [] + if DEBUG: + for i in ll_clusters: + print(i) + # *** extract the lead car *** + ll_lead_clusters = [c for c in ll_clusters + if c.is_potential_lead_dy(self.v_ego,-self.lane_width)] + ll_lead_clusters.sort(key=lambda x: x.dRel) + ll_lead_len = len(ll_lead_clusters) + ll_lead1_truck = (len([c for c in ll_lead_clusters + if c.is_truck(ll_lead_clusters)]) > 0) + + # *** extract the second lead from the whole set of leads *** + ll_lead2_clusters = [c for c in ll_lead_clusters + if c.is_potential_lead2(ll_lead_clusters)] + ll_lead2_clusters.sort(key=lambda x: x.dRel) + ll_lead2_len = len(ll_lead2_clusters) + ll_lead2_truck = (len([c for c in ll_lead_clusters + if c.is_truck(ll_lead2_clusters)]) > 0) + # publish data + if ll_lead_len > 0: + datrl.v1Type = int(ll_lead_clusters[0].oClass) + if datrl.v1Type == 1 and ll_lead1_truck: + datrl.v1Type = 0 + datrl.v1Dx = float(ll_lead_clusters[0].dRel) + datrl.v1Vrel = float(ll_lead_clusters[0].vRel) + datrl.v1Dy = float(-ll_lead_clusters[0].yRel - lane_offset) + datrl.v1Id = int(ll_lead_clusters[0].track_id % 32) + if ll_lead2_len > 0: + datrl.v2Type = int(ll_lead2_clusters[0].oClass) + if datrl.v2Type == 1 and ll_lead2_truck: + datrl.v2Type = 0 + datrl.v2Dx = float(ll_lead2_clusters[0].dRel) + datrl.v2Vrel = float(ll_lead2_clusters[0].vRel) + datrl.v2Dy = float(-ll_lead2_clusters[0].yRel - lane_offset) + datrl.v2Id = int(ll_lead2_clusters[0].track_id % 32) + #RIGHT LANE + if self.RI.TRACK_RIGHT_LANE: + rl_track_pts = np.array([self.tracks[iden].get_key_for_cluster_dy(self.lane_width) for iden in idens]) + # If we have multiple points, cluster them + if len(rl_track_pts) > 1: + rl_cluster_idxs = cluster_points_centroid(rl_track_pts, 2.5) + rl_clusters = [None] * (max(rl_cluster_idxs) + 1) + + for idx in range(len(rl_track_pts)): + rl_cluster_i = rl_cluster_idxs[idx] + + if rl_clusters[rl_cluster_i] == None: + rl_clusters[rl_cluster_i] = Cluster(self.use_tesla_radar) + rl_clusters[rl_cluster_i].add(self.tracks[idens[idx]]) + elif len(rl_track_pts) == 1: + # TODO: why do we need this? + rl_clusters = [Cluster(self.use_tesla_radar)] + rl_clusters[0].add(self.tracks[idens[0]]) + else: + rl_clusters = [] + if DEBUG: + for i in rl_clusters: + print(i) + # *** extract the lead car *** + rl_lead_clusters = [c for c in rl_clusters + if c.is_potential_lead_dy(self.v_ego,self.lane_width)] + rl_lead_clusters.sort(key=lambda x: x.dRel) + rl_lead_len = len(rl_lead_clusters) + rl_lead1_truck = (len([c for c in rl_lead_clusters + if c.is_truck(rl_lead_clusters)]) > 0) + # *** extract the second lead from the whole set of leads *** + rl_lead2_clusters = [c for c in rl_lead_clusters + if c.is_potential_lead2(rl_lead_clusters)] + rl_lead2_clusters.sort(key=lambda x: x.dRel) + rl_lead2_len = len(rl_lead2_clusters) + rl_lead2_truck = (len([c for c in rl_lead_clusters + if c.is_truck(rl_lead2_clusters)]) > 0) + # publish data + if rl_lead_len > 0: + datrl.v3Type = int(rl_lead_clusters[0].oClass) + if datrl.v3Type == 1 and rl_lead1_truck: + datrl.v3Type = 0 + datrl.v3Dx = float(rl_lead_clusters[0].dRel) + datrl.v3Vrel = float(rl_lead_clusters[0].vRel) + datrl.v3Dy = float(-rl_lead_clusters[0].yRel+ lane_offset) + datrl.v3Id = int(rl_lead_clusters[0].track_id % 32) + if rl_lead2_len > 0: + datrl.v4Type = int(rl_lead2_clusters[0].oClass) + if datrl.v4Type == 1 and rl_lead2_truck: + datrl.v4Type = 0 + datrl.v4Dx = float(rl_lead2_clusters[0].dRel) + datrl.v4Vrel = float(rl_lead2_clusters[0].vRel) + datrl.v4Dy = float(-rl_lead2_clusters[0].yRel + lane_offset) + datrl.v4Id = int(rl_lead2_clusters[0].track_id % 32) + if (self.RI.TRACK_RIGHT_LANE or self.RI.TRACK_LEFT_LANE): + self.icCarLR.send(datrl.to_bytes()) + + ### END REVIEW SECTION # *** publish radarState *** - dat = messaging.new_message() - dat.init('radarState') - dat.valid = sm.all_alive_and_valid(service_list=['controlsState', 'model']) - dat.radarState.mdMonoTime = self.last_md_ts - dat.radarState.canMonoTimes = list(rr.canMonoTimes) - dat.radarState.radarErrors = list(rr.errors) - dat.radarState.controlsStateMonoTime = self.last_controls_state_ts + dat = messaging.new_message('radarState') + dat.valid = sm.all_alive_and_valid() + radarState = dat.radarState + radarState.mdMonoTime = sm.logMonoTime['model'] + radarState.canMonoTimes = list(rr.canMonoTimes) + radarState.radarErrors = list(rr.errors) + radarState.controlsStateMonoTime = sm.logMonoTime['controlsState'] datext = tesla.ICLeads.new_message() - l1x = tesla.TeslaLeadPoint.new_message() - l2x = tesla.TeslaLeadPoint.new_message() - if has_radar: - l1d,l1x = get_lead(self.v_ego, self.ready, clusters, sm['model'].lead, low_speed_override=True) - l2d,l2x = get_lead(self.v_ego, self.ready, clusters, sm['model'].leadFuture, low_speed_override=False) + if enable_lead: + l1d,l1x = get_lead(self.v_ego, self.ready, clusters, sm['model'].lead, low_speed_override=True,use_tesla_radar=self.use_tesla_radar) + l2d,l2x = get_lead(self.v_ego, self.ready, clusters, sm['model'].leadFuture, low_speed_override=False, use_tesla_radar=self.use_tesla_radar) dat.radarState.leadOne = l1d dat.radarState.leadTwo = l2d - datext.lead1trackId = l1x['trackId'] - datext.lead1oClass = l1x['oClass'] - datext.lead1length = l1x['length'] - datext.lead2trackId = l2x['trackId'] - datext.lead2oClass = l2x['oClass'] - datext.lead2length = l2x['length'] - #datext.lead1trackId = l1x.trackId - #datext.lead1oClass = l1x.oClass - #datext.lead1length = l1x.length - #datext.lead2trackId = l2x.trackId - #datext.lead2oClass = l2x.oClass - #datext.lead2length = l2x.length + datext.lead1trackId = l1x['trackId'] + datext.lead1oClass = l1x['oClass'] + datext.lead1length = l1x['length'] + datext.lead2trackId = l2x['trackId'] + datext.lead2oClass = l2x['oClass'] + datext.lead2length = l2x['length'] return dat, datext # fuses camera and radar data for best lead detection -def radard_thread(gctx=None): - set_realtime_priority(2) +def radard_thread(sm=None, pm=None, can_sock=None): + config_realtime_process(2, Priority.CTRL_LOW) # wait for stats about the car to come in from controls cloudlog.info("radard is waiting for CarParams") CP = car.CarParams.from_bytes(Params().get("CarParams", block=True)) use_tesla_radar = CarSettings().get_value("useTeslaRadar") - mocked = (CP.carName == "mock") or ((CP.carName == "tesla") and not use_tesla_radar) cloudlog.info("radard got CarParams") # import the radar from the fingerprint cloudlog.info("radard is importing %s", CP.carName) RadarInterface = importlib.import_module('selfdrive.car.%s.radar_interface' % CP.carName).RadarInterface - can_sock = messaging.sub_sock(service_list['can'].port) - sm = messaging.SubMaster(['model', 'controlsState', 'liveParameters']) + # *** setup messaging + if can_sock is None: + can_sock = messaging.sub_sock('can') + if sm is None: + if CP.carName == "tesla": + sm = messaging.SubMaster(['model', 'controlsState', 'liveParameters', 'pathPlan']) + else: + sm = messaging.SubMaster(['model', 'controlsState']) + if pm is None: + pm = messaging.PubMaster(['radarState', 'liveTracks']) + if CP.carName == "tesla": + icLeads = messaging.pub_sock('uiIcLeads') + ahbInfo = messaging.pub_sock('ahbInfo') RI = RadarInterface(CP) - # *** publish radarState and liveTracks - radarState = messaging.pub_sock(service_list['radarState'].port) - liveTracks = messaging.pub_sock(service_list['liveTracks'].port) - icLeads = messaging.pub_sock(service_list['uiIcLeads'].port) + rk = Ratekeeper(1.0 / CP.radarTimeStep, print_delay_threshold=None) + RD = RadarD(CP.radarTimeStep, RI, use_tesla_radar,RI.delay) - rk = Ratekeeper(rate, print_delay_threshold=None) - RD = RadarD(mocked, RI) - MP = LanePlanner() + # TODO: always log leads once we can hide them conditionally + enable_lead = CP.openpilotLongitudinalControl or not CP.radarOffCan - has_radar = not CP.radarOffCan or mocked - last_md_ts = 0. + has_radar = not CP.radarOffCan v_ego = 0. - + print("Working with ",CP.carName," with radarOffCan=",CP.radarOffCan) while 1: can_strings = messaging.drain_sock_raw(can_sock, wait_for_one=True) - rr,rrext = RI.update(can_strings) + if CP.carName == "tesla": + rr,rrext,ahbCarDetected = RI.update(can_strings,v_ego) + else: + rr = RI.update(can_strings) + rrext = None + ahbCarDetected = False if rr is None: continue @@ -403,35 +419,37 @@ def radard_thread(gctx=None): if sm.updated['controlsState']: v_ego = sm['controlsState'].vEgo - if sm.updated['model']: - MP.update(v_ego, sm['model'], False) - - - dat,datext = RD.update(rk.frame, RI.delay, sm, rr, has_radar, MP, rrext) + dat, datext = RD.update(rk.frame, sm, rr, enable_lead, rrext) dat.radarState.cumLagMs = -rk.remaining*1000. - radarState.send(dat.to_bytes()) - icLeads.send(datext.to_bytes()) + pm.send('radarState', dat) + + if CP.carName == "tesla": + icLeads.send(datext.to_bytes()) + ahbInfoMsg = tesla.AHBinfo.new_message() + ahbInfoMsg.source = 0 + ahbInfoMsg.radarCarDetected = ahbCarDetected + ahbInfoMsg.cameraCarDetected = False + ahbInfo.send(ahbInfoMsg.to_bytes()) # *** publish tracks for UI debugging (keep last) *** tracks = RD.tracks - dat = messaging.new_message() - dat.init('liveTracks', len(tracks)) + dat = messaging.new_message('liveTracks', len(tracks)) - for cnt, ids in enumerate(tracks.keys()): + for cnt, ids in enumerate(sorted(tracks.keys())): dat.liveTracks[cnt] = { "trackId": ids, "dRel": float(tracks[ids].dRel), "yRel": float(tracks[ids].yRel), "vRel": float(tracks[ids].vRel), } - liveTracks.send(dat.to_bytes()) + pm.send('liveTracks', dat) rk.monitor_time() -def main(gctx=None): - radard_thread(gctx) +def main(sm=None, pm=None, can_sock=None): + radard_thread(sm, pm, can_sock) if __name__ == "__main__": diff --git a/selfdrive/controls/tests/test_clustering.py b/selfdrive/controls/tests/test_clustering.py deleted file mode 100644 index 14c0e23fe335ce..00000000000000 --- a/selfdrive/controls/tests/test_clustering.py +++ /dev/null @@ -1,138 +0,0 @@ -import time -import unittest -import numpy as np -from fastcluster import linkage_vector -from scipy.cluster import _hierarchy -from scipy.spatial.distance import pdist - -from selfdrive.controls.lib.cluster.fastcluster_py import hclust, ffi -from selfdrive.controls.lib.cluster.fastcluster_py import cluster_points_centroid - - -def fcluster(Z, t, criterion='inconsistent', depth=2, R=None, monocrit=None): - # supersimplified function to get fast clustering. Got it from scipy - Z = np.asarray(Z, order='c') - n = Z.shape[0] + 1 - T = np.zeros((n,), dtype='i') - _hierarchy.cluster_dist(Z, T, float(t), int(n)) - return T - - -TRACK_PTS = np.array([[59.26000137, -9.35999966, -5.42500019], - [91.61999817, -0.31999999, -2.75], - [31.38000031, 0.40000001, -0.2], - [89.57999725, -8.07999992, -18.04999924], - [53.42000122, 0.63999999, -0.175], - [31.38000031, 0.47999999, -0.2], - [36.33999939, 0.16, -0.2], - [53.33999939, 0.95999998, -0.175], - [59.26000137, -9.76000023, -5.44999981], - [33.93999977, 0.40000001, -0.22499999], - [106.74000092, -5.76000023, -18.04999924]]) - -CORRECT_LINK = np.array([[2., 5., 0.07999998, 2.], - [4., 7., 0.32984889, 2.], - [0., 8., 0.40078104, 2.], - [6., 9., 2.41209933, 2.], - [11., 14., 3.76342275, 4.], - [12., 13., 13.02297651, 4.], - [1., 3., 17.27626057, 2.], - [10., 17., 17.92918845, 3.], - [15., 16., 23.68525366, 8.], - [18., 19., 52.52351319, 11.]]) - -CORRECT_LABELS = np.array([7, 1, 4, 2, 6, 4, 5, 6, 7, 5, 3], dtype=np.int32) - - -def plot_cluster(pts, idx_old, idx_new): - import matplotlib.pyplot as plt - m = 'Set1' - - plt.figure() - plt.subplot(1, 2, 1) - plt.scatter(pts[:, 0], pts[:, 1], c=idx_old, cmap=m) - plt.title("Old") - plt.colorbar() - plt.subplot(1, 2, 2) - plt.scatter(pts[:, 0], pts[:, 1], c=idx_new, cmap=m) - plt.title("New") - plt.colorbar() - - plt.show() - - -def same_clusters(correct, other): - correct = np.asarray(correct) - other = np.asarray(other) - if len(correct) != len(other): - return False - - for i in range(len(correct)): - c = np.where(correct == correct[i]) - o = np.where(other == other[i]) - if not np.array_equal(c, o): - return False - return True - - -class TestClustering(unittest.TestCase): - def test_scipy_clustering(self): - old_link = linkage_vector(TRACK_PTS, method='centroid') - old_cluster_idxs = fcluster(old_link, 2.5, criterion='distance') - - np.testing.assert_allclose(old_link, CORRECT_LINK) - np.testing.assert_allclose(old_cluster_idxs, CORRECT_LABELS) - - def test_pdist(self): - pts = np.ascontiguousarray(TRACK_PTS, dtype=np.float64) - pts_ptr = ffi.cast("double *", pts.ctypes.data) - - n, m = pts.shape - out = np.zeros((n * (n - 1) / 2, ), dtype=np.float64) - out_ptr = ffi.cast("double *", out.ctypes.data) - hclust.hclust_pdist(n, m, pts_ptr, out_ptr) - - np.testing.assert_allclose(out, np.power(pdist(TRACK_PTS), 2)) - - def test_cpp_clustering(self): - pts = np.ascontiguousarray(TRACK_PTS, dtype=np.float64) - pts_ptr = ffi.cast("double *", pts.ctypes.data) - n, m = pts.shape - - labels = np.zeros((n, ), dtype=np.int32) - labels_ptr = ffi.cast("int *", labels.ctypes.data) - hclust.cluster_points_centroid(n, m, pts_ptr, 2.5**2, labels_ptr) - self.assertTrue(same_clusters(CORRECT_LABELS, labels)) - - def test_cpp_wrapper_clustering(self): - labels = cluster_points_centroid(TRACK_PTS, 2.5) - self.assertTrue(same_clusters(CORRECT_LABELS, labels)) - - def test_random_cluster(self): - np.random.seed(1337) - N = 1000 - - t_old = 0. - t_new = 0. - - for _ in range(N): - n = int(np.random.uniform(2, 32)) - x = np.random.uniform(-10, 50, (n, 1)) - y = np.random.uniform(-5, 5, (n, 1)) - vrel = np.random.uniform(-5, 5, (n, 1)) - pts = np.hstack([x, y, vrel]) - - t = time.time() - old_link = linkage_vector(pts, method='centroid') - old_cluster_idx = fcluster(old_link, 2.5, criterion='distance') - t_old += time.time() - t - - t = time.time() - cluster_idx = cluster_points_centroid(pts, 2.5) - t_new += time.time() - t - - self.assertTrue(same_clusters(old_cluster_idx, cluster_idx)) - - -if __name__ == "__main__": - unittest.main() diff --git a/selfdrive/controls/tests/test_following_distance.py b/selfdrive/controls/tests/test_following_distance.py deleted file mode 100644 index 994ea7ea5d18b1..00000000000000 --- a/selfdrive/controls/tests/test_following_distance.py +++ /dev/null @@ -1,90 +0,0 @@ -import unittest -import numpy as np - -from cereal import log -import selfdrive.messaging as messaging -from selfdrive.config import Conversions as CV -from selfdrive.controls.lib.planner import calc_cruise_accel_limits -from selfdrive.controls.lib.speed_smoother import speed_smoother -from selfdrive.controls.lib.long_mpc import LongitudinalMpc - - -def RW(v_ego, v_l): - TR = 1.8 - G = 9.81 - return (v_ego * TR - (v_l - v_ego) * TR + v_ego * v_ego / (2 * G) - v_l * v_l / (2 * G)) - - -class FakeSocket(object): - def send(self, data): - assert data - - -def run_following_distance_simulation(v_lead, t_end=200.0): - dt = 0.2 - t = 0. - - x_lead = 200.0 - - x_ego = 0.0 - v_ego = v_lead - a_ego = 0.0 - - v_cruise_setpoint = v_lead + 10. - - mpc = LongitudinalMpc(1, FakeSocket()) - - first = True - while t < t_end: - # Run cruise control - accel_limits = [float(x) for x in calc_cruise_accel_limits(v_ego, False)] - jerk_limits = [min(-0.1, accel_limits[0]), max(0.1, accel_limits[1])] - v_cruise, a_cruise = speed_smoother(v_ego, a_ego, v_cruise_setpoint, - accel_limits[1], accel_limits[0], - jerk_limits[1], jerk_limits[0], - dt) - - # Setup CarState - CS = messaging.new_message() - CS.init('carState') - CS.carState.vEgo = v_ego - CS.carState.aEgo = a_ego - - # Setup lead packet - lead = log.RadarState.LeadData.new_message() - lead.status = True - lead.dRel = x_lead - x_ego - lead.vLead = v_lead - lead.aLeadK = 0.0 - - # Run MPC - mpc.set_cur_state(v_ego, a_ego) - if first: # Make sure MPC is converged on first timestep - for _ in range(20): - mpc.update(CS.carState, lead, v_cruise_setpoint) - mpc.update(CS.carState, lead, v_cruise_setpoint) - - # Choose slowest of two solutions - if v_cruise < mpc.v_mpc: - v_ego, a_ego = v_cruise, a_cruise - else: - v_ego, a_ego = mpc.v_mpc, mpc.a_mpc - - # Update state - x_lead += v_lead * dt - x_ego += v_ego * dt - t += dt - first = False - - return x_lead - x_ego - - -class TestFollowingDistance(unittest.TestCase): - def test_following_distanc(self): - for speed_mph in np.linspace(10, 100, num=10): - v_lead = float(speed_mph * CV.MPH_TO_MS) - - simulation_steady_state = run_following_distance_simulation(v_lead) - correct_steady_state = RW(v_lead, v_lead) + 4.0 - - self.assertAlmostEqual(simulation_steady_state, correct_steady_state, delta=0.1) diff --git a/selfdrive/controls/tests/test_lateral_mpc.py b/selfdrive/controls/tests/test_lateral_mpc.py deleted file mode 100644 index 4bd65713485156..00000000000000 --- a/selfdrive/controls/tests/test_lateral_mpc.py +++ /dev/null @@ -1,129 +0,0 @@ -import unittest -import numpy as np -from selfdrive.car.honda.interface import CarInterface -from selfdrive.controls.lib.lateral_mpc import libmpc_py -from selfdrive.controls.lib.vehicle_model import VehicleModel -from selfdrive.controls.lib.lane_planner import calc_d_poly - - -def run_mpc(v_ref=30., x_init=0., y_init=0., psi_init=0., delta_init=0., - l_prob=1., r_prob=1., p_prob=1., - poly_l=np.array([0., 0., 0., 1.8]), poly_r=np.array([0., 0., 0., -1.8]), poly_p=np.array([0., 0., 0., 0.]), - lane_width=3.6, poly_shift=0.): - - libmpc = libmpc_py.libmpc - libmpc.init(1.0, 3.0, 1.0, 1.0) - - mpc_solution = libmpc_py.ffi.new("log_t *") - - p_l = poly_l.copy() - p_l[3] += poly_shift - - p_r = poly_r.copy() - p_r[3] += poly_shift - - p_p = poly_p.copy() - p_p[3] += poly_shift - - d_poly = calc_d_poly(p_l, p_r, p_p, l_prob, r_prob, lane_width) - - CP = CarInterface.get_params("HONDA CIVIC 2016 TOURING", {}) - VM = VehicleModel(CP) - - v_ref = v_ref - curvature_factor = VM.curvature_factor(v_ref) - - l_poly = libmpc_py.ffi.new("double[4]", map(float, p_l)) - r_poly = libmpc_py.ffi.new("double[4]", map(float, p_r)) - d_poly = libmpc_py.ffi.new("double[4]", map(float, d_poly)) - - cur_state = libmpc_py.ffi.new("state_t *") - cur_state[0].x = x_init - cur_state[0].y = y_init - cur_state[0].psi = psi_init - cur_state[0].delta = delta_init - - # converge in no more than 20 iterations - for _ in range(20): - libmpc.run_mpc(cur_state, mpc_solution, l_poly, r_poly, d_poly, l_prob, r_prob, - curvature_factor, v_ref, lane_width) - - return mpc_solution - - -class TestLateralMpc(unittest.TestCase): - - def _assert_null(self, sol, delta=1e-6): - for i in range(len(sol[0].y)): - self.assertAlmostEqual(sol[0].y[i], 0., delta=delta) - self.assertAlmostEqual(sol[0].psi[i], 0., delta=delta) - self.assertAlmostEqual(sol[0].delta[i], 0., delta=delta) - - def _assert_simmetry(self, sol, delta=1e-6): - for i in range(len(sol[0][0].y)): - self.assertAlmostEqual(sol[0][0].y[i], -sol[1][0].y[i], delta=delta) - self.assertAlmostEqual(sol[0][0].psi[i], -sol[1][0].psi[i], delta=delta) - self.assertAlmostEqual(sol[0][0].delta[i], -sol[1][0].delta[i], delta=delta) - self.assertAlmostEqual(sol[0][0].x[i], sol[1][0].x[i], delta=delta) - - def _assert_identity(self, sol, ignore_y=False, delta=1e-6): - for i in range(len(sol[0][0].y)): - self.assertAlmostEqual(sol[0][0].psi[i], sol[1][0].psi[i], delta=delta) - self.assertAlmostEqual(sol[0][0].delta[i], sol[1][0].delta[i], delta=delta) - self.assertAlmostEqual(sol[0][0].x[i], sol[1][0].x[i], delta=delta) - if not ignore_y: - self.assertAlmostEqual(sol[0][0].y[i], sol[1][0].y[i], delta=delta) - - def test_straight(self): - sol = run_mpc() - self._assert_null(sol) - - def test_y_symmetry(self): - sol = [] - for y_init in [-0.5, 0.5]: - sol.append(run_mpc(y_init=y_init)) - self._assert_simmetry(sol) - - def test_poly_symmetry(self): - sol = [] - for poly_shift in [-1., 1.]: - sol.append(run_mpc(poly_shift=poly_shift)) - self._assert_simmetry(sol) - - def test_delta_symmetry(self): - sol = [] - for delta_init in [-0.1, 0.1]: - sol.append(run_mpc(delta_init=delta_init)) - self._assert_simmetry(sol) - - def test_psi_symmetry(self): - sol = [] - for psi_init in [-0.1, 0.1]: - sol.append(run_mpc(psi_init=psi_init)) - self._assert_simmetry(sol) - - def test_prob_symmetry(self): - sol = [] - lane_width = 3. - for r_prob in [0., 1.]: - sol.append(run_mpc(r_prob=r_prob, l_prob=1.-r_prob, lane_width=lane_width)) - self._assert_simmetry(sol) - - def test_y_shift_vs_poly_shift(self): - shift = 1. - sol = [] - sol.append(run_mpc(y_init=shift)) - sol.append(run_mpc(poly_shift=-shift)) - # need larger delta than standard, otherwise it false triggers. - # this is acceptable because the 2 cases are very different from the optimizer standpoint - self._assert_identity(sol, ignore_y=True, delta=1e-5) - - def test_no_overshoot(self): - y_init = 1. - sol = run_mpc(y_init=y_init) - for y in list(sol[0].y): - self.assertGreaterEqual(y_init, abs(y)) - - -if __name__ == "__main__": - unittest.main() diff --git a/selfdrive/crash.py b/selfdrive/crash.py index 743824ed76dec1..36d2f67ff828f9 100644 --- a/selfdrive/crash.py +++ b/selfdrive/crash.py @@ -3,24 +3,36 @@ import sys import threading import capnp -from selfdrive.version import version, dirty +from selfdrive.version import version, dirty, origin, branch + +from selfdrive.hardware import PC from selfdrive.swaglog import cloudlog + from selfdrive.tinklad.tinkla_interface import TinklaClient -if os.getenv("NOLOG") or os.getenv("NOCRASH"): - def capture_exception(*exc_info): +if os.getenv("NOLOG") or os.getenv("NOCRASH") or PC: + def capture_exception(*args, **kwargs): pass + def bind_user(**kwargs): pass + def bind_extra(**kwargs): pass + def install(): pass else: from raven import Client from raven.transport.http import HTTPTransport + + tags = { + 'dirty': dirty, + 'origin': origin, + 'branch': branch + } client = Client('https://1994756b5e6f41cf939a4c65de45f4f2:cefebaf3a8aa40d182609785f7189bd7@app.getsentry.com/77924', - install_sys_hook=False, transport=HTTPTransport, release=version, tags={'dirty': dirty}) + install_sys_hook=False, transport=HTTPTransport, release=version, tags=tags) def sendCrashInfoToTinklad(): tinklaClient = TinklaClient() @@ -40,20 +52,21 @@ def bind_extra(**kwargs): client.extra_context(kwargs) def install(): + """ + Workaround for `sys.excepthook` thread bug from: + http://bugs.python.org/issue1230540 + Call once from the main thread before creating any threads. + Source: https://stackoverflow.com/a/31622038 + """ # installs a sys.excepthook __excepthook__ = sys.excepthook + def handle_exception(*exc_info): if exc_info[0] not in (KeyboardInterrupt, SystemExit): - capture_exception(exc_info=exc_info) + capture_exception() __excepthook__(*exc_info) sys.excepthook = handle_exception - """ - Workaround for `sys.excepthook` thread bug from: - http://bugs.python.org/issue1230540 - Call once from the main thread before creating any threads. - Source: https://stackoverflow.com/a/31622038 - """ init_original = threading.Thread.__init__ def init(self, *args, **kwargs): diff --git a/selfdrive/controls/tests/__init__.py b/selfdrive/debug/__init__.py similarity index 100% rename from selfdrive/controls/tests/__init__.py rename to selfdrive/debug/__init__.py diff --git a/selfdrive/debug/can_printer.py b/selfdrive/debug/can_printer.py index daa0500b2f20e6..7ea26d62fc5e29 100755 --- a/selfdrive/debug/can_printer.py +++ b/selfdrive/debug/can_printer.py @@ -1,14 +1,15 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +import binascii import os import sys from collections import defaultdict + +import cereal.messaging as messaging from common.realtime import sec_since_boot -import selfdrive.messaging as messaging -from selfdrive.services import service_list def can_printer(bus=0, max_msg=None, addr="127.0.0.1"): - logcan = messaging.sub_sock(service_list['can'].port, addr=addr) + logcan = messaging.sub_sock('can', addr=addr) start = sec_since_boot() lp = sec_since_boot() @@ -24,9 +25,9 @@ def can_printer(bus=0, max_msg=None, addr="127.0.0.1"): if sec_since_boot() - lp > 0.1: dd = chr(27) + "[2J" dd += "%5.2f\n" % (sec_since_boot() - start) - for k,v in sorted(zip(msgs.keys(), map(lambda x: x[-1].encode("hex"), msgs.values()))): + for k, v in sorted(zip(msgs.keys(), map(lambda x: binascii.hexlify(x[-1]), msgs.values()))): if max_msg is None or k < max_msg: - dd += "%s(%6d) %s\n" % ("%04X(%4d)" % (k,k),len(msgs[k]), v) + dd += "%s(%6d) %s\n" % ("%04X(%4d)" % (k, k), len(msgs[k]), v.decode('ascii')) print(dd) lp = sec_since_boot() @@ -39,4 +40,3 @@ def can_printer(bus=0, max_msg=None, addr="127.0.0.1"): can_printer(int(sys.argv[1])) else: can_printer() - diff --git a/selfdrive/debug/check_freq.py b/selfdrive/debug/check_freq.py new file mode 100755 index 00000000000000..fd4f510c2bcef9 --- /dev/null +++ b/selfdrive/debug/check_freq.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +# type: ignore + +import argparse +import numpy as np +from collections import defaultdict, deque +from common.realtime import sec_since_boot +import cereal.messaging as messaging + + +if __name__ == "__main__": + context = messaging.Context() + poller = messaging.Poller() + + parser = argparse.ArgumentParser() + parser.add_argument("socket", type=str, nargs='*', help="socket name") + args = parser.parse_args() + + socket_names = args.socket + sockets = {} + + rcv_times = defaultdict(lambda: deque(maxlen=100)) + + t = sec_since_boot() + for name in socket_names: + sock = messaging.sub_sock(name, poller=poller) + sockets[sock] = name + + prev_print = t + while True: + for socket in poller.poll(100): + msg = messaging.recv_one(socket) + name = msg.which() + + t = sec_since_boot() + rcv_times[name].append(msg.logMonoTime / 1e9) + + if t - prev_print > 1: + print() + for name in socket_names: + dts = np.diff(rcv_times[name]) + mean = np.mean(dts) + print("%s: Freq %.2f Hz, Min %.2f%%, Max %.2f%%" % (name, 1.0 / mean, np.min(dts) / mean * 100, np.max(dts) / mean * 100)) + + prev_print = t diff --git a/selfdrive/debug/check_lag.py b/selfdrive/debug/check_lag.py new file mode 100755 index 00000000000000..c922642982aa06 --- /dev/null +++ b/selfdrive/debug/check_lag.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +# type: ignore + +import cereal.messaging as messaging +from cereal.services import service_list + +TO_CHECK = ['carState'] + + +if __name__ == "__main__": + sm = messaging.SubMaster(TO_CHECK) + + prev_t = {} + + while True: + sm.update() + + for s in TO_CHECK: + if sm.updated[s]: + t = sm.logMonoTime[s] / 1e9 + + if s in prev_t: + expected = 1.0 / (service_list[s].frequency) + dt = t - prev_t[s] + if dt > 10 * expected: + print(t, s, dt) + + prev_t[s] = t diff --git a/selfdrive/debug/compare_fingerprints.py b/selfdrive/debug/compare_fingerprints.py new file mode 100755 index 00000000000000..5b7ba58b1e4685 --- /dev/null +++ b/selfdrive/debug/compare_fingerprints.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +# flake8: noqa + +# put 2 fingeprints and print the diffs +f1 = { +168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 528: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 701: 8, 703: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 746: 5, 752: 2, 754: 8, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 906: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 962: 8, 969: 4, 973: 8, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8, 1537: 8, 1538: 8, 1562: 8 +} + +f2 = { +168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 515: 7, 516: 7, 517: 7, 518: 7, 520: 8, 528: 8, 532: 8, 542: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 701: 8, 703: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 746: 5, 752: 2, 754: 8, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 906: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 962: 8, 969: 4, 973: 8, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8 +} + +for k in f1: + if k not in f2 or f1[k] != f2[k]: + print(k, "not in f2") + +for k in f2: + if k not in f1 or f2[k] != f1[k]: + print(k, "not in f1") diff --git a/selfdrive/debug/cpu_usage_stat.py b/selfdrive/debug/cpu_usage_stat.py index 7adf7ef78ee02f..76f14afa0a475a 100755 --- a/selfdrive/debug/cpu_usage_stat.py +++ b/selfdrive/debug/cpu_usage_stat.py @@ -1,17 +1,9 @@ -#!/usr/bin/env python2 -import psutil -import time -import os -import sys -import numpy as np -import argparse -import re -from collections import defaultdict - +#!/usr/bin/env python3 +# type: ignore ''' System tools like top/htop can only show current cpu usage values, so I write this script to do statistics jobs. Features: - Use psutil library to sample cpu usage(avergage for all cores) of OpenPilot processes, at a rate of 5 samples/sec. + Use psutil library to sample cpu usage(avergage for all cores) of openpilot processes, at a rate of 5 samples/sec. Do cpu usage statistics periodically, 5 seconds as a cycle. Caculate the average cpu usage within this cycle. Caculate minumium/maximium/accumulated_average cpu usage as long term inspections. @@ -23,18 +15,38 @@ boardd: 1.96%, min: 1.96%, max: 1.96%, acc: 1.96% ubloxd.py: 0.39%, min: 0.39%, max: 0.39%, acc: 0.39% ''' +import psutil +import time +import os +import sys +import numpy as np +import argparse +import re +from collections import defaultdict + # Do statistics every 5 seconds PRINT_INTERVAL = 5 SLEEP_INTERVAL = 0.2 monitored_proc_names = [ - 'ubloxd', 'thermald', 'uploader', 'deleter', 'controlsd', 'plannerd', 'radard', 'mapd', 'loggerd' , 'logmessaged', 'tombstoned', - 'logcatd', 'proclogd', 'boardd', 'pandad', './ui', 'calibrationd', 'params_learner', 'visiond', 'sensord', 'updated', 'gpsd', 'athena'] + # openpilot procs + 'controlsd', 'locationd', 'loggerd','plannerd', + 'ubloxd', 'thermald', 'uploader', 'deleter', 'radard', 'logmessaged', 'tombstoned', + 'logcatd', 'proclogd', 'boardd', 'pandad', './ui', 'ui', 'calibrationd', 'params_learner', 'modeld', 'dmonitoringd', + 'dmonitoringmodeld', 'camerad', 'sensord', 'updated', 'gpsd', 'athena', 'locationd', 'paramsd', + + 'ai.comma.plus.offroad', + + # android procs + 'SurfaceFlinger', 'sensors.qcom' +] + cpu_time_names = ['user', 'system', 'children_user', 'children_system'] timer = getattr(time, 'monotonic', time.time) + def get_arg_parser(): parser = argparse.ArgumentParser( description="Unlogger and UI", @@ -68,7 +80,7 @@ def get_arg_parser(): k = ' '.join(p.cmdline()) print('Add monitored proc:', k) stats[k] = {'cpu_samples': defaultdict(list), 'min': defaultdict(lambda: None), 'max': defaultdict(lambda: None), - 'avg': defaultdict(lambda: 0.0), 'last_cpu_times': None, 'last_sys_time':None} + 'avg': defaultdict(lambda: 0.0), 'last_cpu_times': None, 'last_sys_time': None} stats[k]['last_sys_time'] = timer() stats[k]['last_cpu_times'] = p.cpu_times() monitored_procs.append(p) @@ -94,7 +106,7 @@ def get_arg_parser(): for k, stat in stats.items(): if len(stat['cpu_samples']) <= 0: continue - for name, samples in stat['cpu_samples'].iteritems(): + for name, samples in stat['cpu_samples'].items(): samples = np.array(samples) avg = samples.mean() c = samples.size @@ -112,7 +124,7 @@ def get_arg_parser(): for stat_type in ['avg', 'min', 'max']: msg += '\n {}: {}'.format(stat_type, [name + ':' + str(round(stat[stat_type][name]*100, 2)) for name in cpu_time_names]) l.append((os.path.basename(k), stat['avg']['total'], msg)) - l.sort(key= lambda x: -x[1]) + l.sort(key=lambda x: -x[1]) for x in l: print(x[2]) print('avg sum: {0:.2%} over {1} samples {2} seconds\n'.format( diff --git a/selfdrive/debug/cycle_alerts.py b/selfdrive/debug/cycle_alerts.py new file mode 100755 index 00000000000000..45bc8984c215c6 --- /dev/null +++ b/selfdrive/debug/cycle_alerts.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 +# flake8: noqa +# pylint: skip-file +# type: ignore + +import time + +import cereal.messaging as messaging +from selfdrive.car.honda.interface import CarInterface +from selfdrive.controls.lib.events import ET, EVENTS, Events +from selfdrive.controls.lib.alertmanager import AlertManager + + +def cycle_alerts(duration=200, is_metric=False): + alerts = list(EVENTS.keys()) + print(alerts) + + CP = CarInterface.get_params("HONDA CIVIC 2016 TOURING") + sm = messaging.SubMaster(['thermal', 'health', 'frame', 'model', 'liveCalibration', + 'dMonitoringState', 'plan', 'pathPlan', 'liveLocationKalman']) + + controls_state = messaging.pub_sock('controlsState') + thermal = messaging.pub_sock('thermal') + + idx, last_alert_millis = 0, 0 + + events = Events() + AM = AlertManager() + + frame = 0 + + while 1: + if frame % duration == 0: + idx = (idx + 1) % len(alerts) + events.clear() + events.add(alerts[idx]) + + + current_alert_types = [ET.PERMANENT, ET.USER_DISABLE, ET.IMMEDIATE_DISABLE, + ET.SOFT_DISABLE, ET.PRE_ENABLE, ET.NO_ENTRY, + ET.ENABLE, ET.WARNING] + a = events.create_alerts(current_alert_types, [CP, sm, is_metric]) + AM.add_many(frame, a) + AM.process_alerts(frame) + + dat = messaging.new_message() + dat.init('controlsState') + + dat.controlsState.alertText1 = AM.alert_text_1 + dat.controlsState.alertText2 = AM.alert_text_2 + dat.controlsState.alertSize = AM.alert_size + dat.controlsState.alertStatus = AM.alert_status + dat.controlsState.alertBlinkingRate = AM.alert_rate + dat.controlsState.alertType = AM.alert_type + dat.controlsState.alertSound = AM.audible_alert + controls_state.send(dat.to_bytes()) + + dat = messaging.new_message() + dat.init('thermal') + dat.thermal.started = True + thermal.send(dat.to_bytes()) + + frame += 1 + time.sleep(0.01) + +if __name__ == '__main__': + cycle_alerts() diff --git a/selfdrive/debug/disable_ecu.py b/selfdrive/debug/disable_ecu.py new file mode 100644 index 00000000000000..9dace9a6858f97 --- /dev/null +++ b/selfdrive/debug/disable_ecu.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +import traceback + +import cereal.messaging as messaging +from selfdrive.car.isotp_parallel_query import IsoTpParallelQuery +from selfdrive.swaglog import cloudlog + +EXT_DIAG_REQUEST = b'\x10\x03' +EXT_DIAG_RESPONSE = b'\x50\x03' +COM_CONT_REQUEST = b'\x28\x83\x03' +COM_CONT_RESPONSE = b'' + +def disable_ecu(ecu_addr, logcan, sendcan, bus, timeout=0.1, retry=5, debug=False): + print(f"ecu disable {hex(ecu_addr)} ...") + for i in range(retry): + try: + # enter extended diagnostic session + query = IsoTpParallelQuery(sendcan, logcan, bus, [ecu_addr], [EXT_DIAG_REQUEST], [EXT_DIAG_RESPONSE], debug=debug) + for addr, dat in query.get_data(timeout).items(): # pylint: disable=unused-variable + print("ecu communication control disable tx/rx ...") + # communication control disable tx and rx + query = IsoTpParallelQuery(sendcan, logcan, bus, [ecu_addr], [COM_CONT_REQUEST], [COM_CONT_RESPONSE], debug=debug) + query.get_data(0) + return True + print(f"ecu disable retry ({i+1}) ...") + except Exception: + cloudlog.warning(f"ecu disable exception: {traceback.format_exc()}") + + return False + + +if __name__ == "__main__": + import time + sendcan = messaging.pub_sock('sendcan') + logcan = messaging.sub_sock('can') + time.sleep(1) + + # honda bosch radar disable + disabled = disable_ecu(0x18DAB0F1, logcan, sendcan, 1, debug=False) + print(f"disabled: {disabled}") diff --git a/selfdrive/debug/dump.py b/selfdrive/debug/dump.py index 7fd8a7cf4fc8b2..112ca96a93aa36 100755 --- a/selfdrive/debug/dump.py +++ b/selfdrive/debug/dump.py @@ -1,20 +1,15 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 +import os import sys import argparse -import zmq import json from hexdump import hexdump -from threading import Thread from cereal import log -import selfdrive.messaging as messaging -from selfdrive.services import service_list - -def run_server(socketio): - socketio.run(app, host='0.0.0.0', port=4000) +import cereal.messaging as messaging +from cereal.services import service_list if __name__ == "__main__": - poller = zmq.Poller() parser = argparse.ArgumentParser(description='Sniff a communcation socket') parser.add_argument('--pipe', action='store_true') @@ -22,57 +17,30 @@ def run_server(socketio): parser.add_argument('--json', action='store_true') parser.add_argument('--dump-json', action='store_true') parser.add_argument('--no-print', action='store_true') - parser.add_argument('--proxy', action='store_true', help='republish on localhost') - parser.add_argument('--map', action='store_true') parser.add_argument('--addr', default='127.0.0.1') parser.add_argument('--values', help='values to monitor (instead of entire event)') parser.add_argument("socket", type=str, nargs='*', help="socket name") args = parser.parse_args() - republish_socks = {} + if args.addr != "127.0.0.1": + os.environ["ZMQ"] = "1" + messaging.context = messaging.Context() - for m in args.socket if len(args.socket) > 0 else service_list: - if m in service_list: - port = service_list[m].port - elif m.isdigit(): - port = int(m) - else: - print("service not found") - sys.exit(-1) - sock = messaging.sub_sock(port, poller, addr=args.addr) - if args.proxy: - republish_socks[sock] = messaging.pub_sock(port) + poller = messaging.Poller() - if args.map: - from flask.ext.socketio import SocketIO #pylint: disable=no-name-in-module, import-error - from flask import Flask - app = Flask(__name__) - socketio = SocketIO(app, async_mode='threading') - server_thread = Thread(target=run_server, args=(socketio,)) - server_thread.daemon = True - server_thread.start() - print('server running') + for m in args.socket if len(args.socket) > 0 else service_list: + messaging.sub_sock(m, poller, addr=args.addr) values = None if args.values: values = [s.strip().split(".") for s in args.values.split(",")] while 1: - polld = poller.poll(timeout=1000) - for sock, mode in polld: - if mode != zmq.POLLIN: - continue - msg = sock.recv() + polld = poller.poll(1000) + for sock in polld: + msg = sock.receive() evt = log.Event.from_bytes(msg) - if sock in republish_socks: - republish_socks[sock].send(msg) - if args.map and evt.which() == 'liveLocation': - print('send loc') - socketio.emit('location', { - 'lat': evt.liveLocation.lat, - 'lon': evt.liveLocation.lon, - 'alt': evt.liveLocation.alt, - }) + if not args.no_print: if args.pipe: sys.stdout.write(msg) @@ -93,4 +61,11 @@ def run_server(socketio): print("{} = {}".format(".".join(value), item)) print("") else: - print(evt) + try: + print(evt) + except UnicodeDecodeError: + w = evt.which() + s = f"( logMonoTime {evt.logMonoTime} \n {w} = " + s += str(evt.__getattr__(w)) + s += f"\n valid = {evt.valid} )" + print(s) diff --git a/selfdrive/debug/filter_log_message.py b/selfdrive/debug/filter_log_message.py new file mode 100755 index 00000000000000..a619e5df5ae2e2 --- /dev/null +++ b/selfdrive/debug/filter_log_message.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +import argparse +import json + +import cereal.messaging as messaging + + +LEVELS = { + "DEBUG": 10, + "INFO": 20, + "WARNING": 30, + "ERROR": 40, + "CRITICAL": 50, +} + +ANDROID_LOG_SOURCE = { + 0: "MAIN", + 1: "RADIO", + 2: "EVENTS", + 3: "SYSTEM", + 4: "CRASH", + 5: "KERNEL", +} + + +if __name__ == "__main__": + + parser = argparse.ArgumentParser() + parser.add_argument('--level', default='DEBUG') + parser.add_argument('--addr', default='127.0.0.1') + parser.add_argument("socket", type=str, nargs='*', help="socket name") + args = parser.parse_args() + + sm = messaging.SubMaster(['logMessage', 'androidLog'], addr=args.addr) + + min_level = LEVELS[args.level] + + while True: + sm.update() + + if sm.updated['logMessage']: + t = sm.logMonoTime['logMessage'] + try: + log = json.loads(sm['logMessage']) + if log['levelnum'] >= min_level: + print(f"[{t / 1e9:.6f}] {log['filename']}:{log.get('lineno', '')} - {log.get('funcname', '')}: {log['msg']}") + except json.decoder.JSONDecodeError: + print(f"[{t / 1e9:.6f}] decode error: {sm['logMessage']}") + if log['levelnum'] >= min_level: + print(f"{log['filename']}:{log.get('lineno', '')} - {log.get('funcname', '')}: {log['msg']}") + + if sm.updated['androidLog']: + t = sm.logMonoTime['androidLog'] + m = sm['androidLog'] + source = ANDROID_LOG_SOURCE[m.id] + print(f"[{t / 1e9:.6f}] {source} {m.pid} {m.tag} - {m.message}") diff --git a/selfdrive/debug/fingerprint_from_route.py b/selfdrive/debug/fingerprint_from_route.py new file mode 100755 index 00000000000000..a06dfe18016a0b --- /dev/null +++ b/selfdrive/debug/fingerprint_from_route.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 + +import sys +from tools.lib.route import Route +from tools.lib.logreader import MultiLogIterator + + +def get_fingerprint(lr): + # TODO: make this a nice tool for car ports. should also work with qlogs for FW + + fw = None + msgs = {} + for msg in lr: + if msg.which() == 'carParams': + fw = msg.carParams.carFw + elif msg.which() == 'can': + for c in msg.can: + # read also msgs sent by EON on CAN bus 0x80 and filter out the + # addr with more than 11 bits + if c.src % 0x80 == 0 and c.address < 0x800: + msgs[c.address] = len(c.dat) + + # show CAN fingerprint + fingerprint = ', '.join("%d: %d" % v for v in sorted(msgs.items())) + print(f"\nfound {len(msgs)} messages. CAN fingerprint:\n") + print(fingerprint) + + # TODO: also print the fw fingerprint merged with the existing ones + # show FW fingerprint + print("\nFW fingerprint:\n") + for f in fw: + print(f" (Ecu.{f.ecu}, {hex(f.address)}, {None if f.subAddress == 0 else f.subAddress}): [") + print(f" {f.fwVersion},") + print(" ],") + print() + + +if __name__ == "__main__": + if len(sys.argv) < 2: + print("Usage: ./get_fingerprint_internal.py ") + sys.exit(1) + + route = Route(sys.argv[1]) + lr = MultiLogIterator(route.log_paths()[:5], wraparound=False) + get_fingerprint(lr) diff --git a/selfdrive/debug/get_fingerprint.py b/selfdrive/debug/get_fingerprint.py index e528d9826c3734..6c38957be32032 100755 --- a/selfdrive/debug/get_fingerprint.py +++ b/selfdrive/debug/get_fingerprint.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # simple script to get a vehicle fingerprint. @@ -6,22 +6,23 @@ # - connect to a Panda # - run selfdrive/boardd/boardd # - launching this script -# - turn on the car in STOCK MODE (set giraffe switches properly). # Note: it's very important that the car is in stock mode, in order to collect a complete fingerprint # - since some messages are published at low frequency, keep this script running for at least 30s, # until all messages are received at least once -import selfdrive.messaging as messaging -from selfdrive.services import service_list +import cereal.messaging as messaging -logcan = messaging.sub_sock(service_list['can'].port) +logcan = messaging.sub_sock('can') msgs = {} while True: lc = messaging.recv_sock(logcan, True) + if lc is None: + continue + for c in lc.can: # read also msgs sent by EON on CAN bus 0x80 and filter out the # addr with more than 11 bits - if c.src%0x80 == 0 and c.address < 0x800: + if c.src in [0, 2] and c.address < 0x800: msgs[c.address] = len(c.dat) fingerprint = ', '.join("%d: %d" % v for v in sorted(msgs.items())) diff --git a/selfdrive/debug/getframes/Makefile b/selfdrive/debug/getframes/Makefile deleted file mode 100644 index 932673e208d116..00000000000000 --- a/selfdrive/debug/getframes/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -CC = clang -CXX = clang++ - -WARN_FLAGS = -Werror=implicit-function-declaration \ - -Werror=incompatible-pointer-types \ - -Werror=int-conversion \ - -Werror=return-type \ - -Werror=format-extra-args - -CFLAGS = -std=gnu11 -g -fPIC -O2 $(WARN_FLAGS) - -.PHONY: all -all: libvisionipc.so - -visionipc.o: ../../common/visionipc.c ../../common/visionipc.h - @echo "[ CC ] $@" - $(CC) $(CFLAGS) -MMD \ - -I../.. -I../../.. \ - -c -o '$@' ../../common/visionipc.c - -libvisionipc.so: visionipc.o - $(CC) -shared -fPIC -o '$@' visionipc.o - -.PHONY: clean -clean: - rm visionipc.o libvisionipc.so diff --git a/selfdrive/debug/getframes/getframes.py b/selfdrive/debug/getframes/getframes.py deleted file mode 100755 index 4964841750d339..00000000000000 --- a/selfdrive/debug/getframes/getframes.py +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/env python -import os -import subprocess -from cffi import FFI - -import numpy as np - -gf_dir = os.path.dirname(os.path.abspath(__file__)) - -subprocess.check_call(["make"], cwd=gf_dir) - - -ffi = FFI() -ffi.cdef(""" - -typedef enum VisionStreamType { - VISION_STREAM_RGB_BACK, - VISION_STREAM_RGB_FRONT, - VISION_STREAM_YUV, - VISION_STREAM_YUV_FRONT, - VISION_STREAM_MAX, -} VisionStreamType; - -typedef struct VisionUIInfo { - int big_box_x, big_box_y; - int big_box_width, big_box_height; - int transformed_width, transformed_height; - - int front_box_x, front_box_y; - int front_box_width, front_box_height; -} VisionUIInfo; - -typedef struct VisionStreamBufs { - VisionStreamType type; - - int width, height, stride; - size_t buf_len; - - union { - VisionUIInfo ui_info; - } buf_info; -} VisionStreamBufs; - -typedef struct VIPCBuf { - int fd; - size_t len; - void* addr; -} VIPCBuf; - -typedef struct VIPCBufExtra { - // only for yuv - uint32_t frame_id; - uint64_t timestamp_eof; -} VIPCBufExtra; - -typedef struct VisionStream { - int ipc_fd; - int last_idx; - int last_type; - int num_bufs; - VisionStreamBufs bufs_info; - VIPCBuf *bufs; -} VisionStream; - -int visionstream_init(VisionStream *s, VisionStreamType type, bool tbuffer, VisionStreamBufs *out_bufs_info); -VIPCBuf* visionstream_get(VisionStream *s, VIPCBufExtra *out_extra); -void visionstream_destroy(VisionStream *s); - -""" -) - -clib = ffi.dlopen(os.path.join(gf_dir, "libvisionipc.so")) - - -def getframes(front=False): - s = ffi.new("VisionStream*") - buf_info = ffi.new("VisionStreamBufs*") - - if front: - stream_type = clib.VISION_STREAM_RGB_FRONT - else: - stream_type = clib.VISION_STREAM_RGB_BACK - - err = clib.visionstream_init(s, stream_type, True, buf_info) - assert err == 0 - - w = buf_info.width - h = buf_info.height - assert buf_info.stride == w*3 - assert buf_info.buf_len == w*h*3 - - while True: - buf = clib.visionstream_get(s, ffi.NULL) - - pbuf = ffi.buffer(buf.addr, buf.len) - yield np.frombuffer(pbuf, dtype=np.uint8).reshape((h, w, 3)) - - -if __name__ == "__main__": - for buf in getframes(): - print("{0} {1}".format(buf.shape, buf[101, 101])) diff --git a/selfdrive/debug/live_cpu_and_temp.py b/selfdrive/debug/live_cpu_and_temp.py new file mode 100755 index 00000000000000..8322e9108c42c8 --- /dev/null +++ b/selfdrive/debug/live_cpu_and_temp.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python3 +import argparse + +import numpy as np + +from cereal.messaging import SubMaster + + +def cputime_total(ct): + return ct.user + ct.nice + ct.system + ct.idle + ct.iowait + ct.irq + ct.softirq + + +def cputime_busy(ct): + return ct.user + ct.nice + ct.system + ct.irq + ct.softirq + + +def proc_cputime_total(ct): + return ct.cpuUser + ct.cpuSystem + ct.cpuChildrenUser + ct.cpuChildrenSystem + + +def proc_name(proc): + name = proc.name + if len(proc.cmdline): + name = proc.cmdline[0] + if len(proc.exe): + name = proc.exe + " - " + name + + return name + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument('--mem', action='store_true') + parser.add_argument('--cpu', action='store_true') + args = parser.parse_args() + + sm = SubMaster(['thermal', 'procLog']) + + last_temp = 0.0 + last_mem = 0.0 + total_times = [0., 0., 0., 0.] + busy_times = [0., 0., 0.0, 0.] + + prev_proclog = None + prev_proclog_t = None + + while True: + sm.update() + + if sm.updated['thermal']: + t = sm['thermal'] + last_temp = np.mean(t.cpu) + last_mem = t.memUsedPercent + + if sm.updated['procLog']: + m = sm['procLog'] + + cores = [0., 0., 0., 0.] + total_times_new = [0., 0., 0., 0.] + busy_times_new = [0., 0., 0.0, 0.] + + for c in m.cpuTimes: + n = c.cpuNum + total_times_new[n] = cputime_total(c) + busy_times_new[n] = cputime_busy(c) + + for n in range(4): + t_busy = busy_times_new[n] - busy_times[n] + t_total = total_times_new[n] - total_times[n] + cores[n] = t_busy / t_total + + total_times = total_times_new[:] + busy_times = busy_times_new[:] + + print("CPU %.2f%% - RAM: %.2f - Temp %.2f" % (100. * np.mean(cores), last_mem, last_temp)) + + if args.cpu and prev_proclog is not None: + procs = {} + dt = (sm.logMonoTime['procLog'] - prev_proclog_t) / 1e9 + for proc in m.procs: + try: + name = proc_name(proc) + prev_proc = [p for p in prev_proclog.procs if proc.pid == p.pid][0] + cpu_time = proc_cputime_total(proc) - proc_cputime_total(prev_proc) + cpu_usage = cpu_time / dt * 100. + procs[name] = cpu_usage + except IndexError: + pass + + print("Top CPU usage:") + for k, v in sorted(procs.items(), key=lambda item: item[1], reverse=True)[:10]: + print(f"{k.rjust(70)} {v:.2f} %") + print() + + if args.mem: + mems = {} + for proc in m.procs: + name = proc_name(proc) + mems[name] = float(proc.memRss) / 1e6 + print("Top memory usage:") + for k, v in sorted(mems.items(), key=lambda item: item[1], reverse=True)[:10]: + print(f"{k.rjust(70)} {v:.2f} MB") + print() + + prev_proclog = m + prev_proclog_t = sm.logMonoTime['procLog'] diff --git a/selfdrive/debug/show_matching_cars.py b/selfdrive/debug/show_matching_cars.py new file mode 100755 index 00000000000000..81dff1f0602d57 --- /dev/null +++ b/selfdrive/debug/show_matching_cars.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +from selfdrive.car.fingerprints import eliminate_incompatible_cars, all_known_cars +import cereal.messaging as messaging + + +# rav4 2019 and corolla tss2 +fingerprint = {896: 8, 898: 8, 900: 6, 976: 1, 1541: 8, 902: 6, 905: 8, 810: 2, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1552: 8, 1553: 8, 1556: 8, 1571: 8, 921: 8, 1056: 8, 544: 4, 1570: 8, 1059: 1, 36: 8, 37: 8, 550: 8, 935: 8, 552: 4, 170: 8, 812: 8, 944: 8, 945: 8, 562: 6, 180: 8, 1077: 8, 951: 8, 1592: 8, 1076: 8, 186: 4, 955: 8, 956: 8, 1001: 8, 705: 8, 452: 8, 1788: 8, 464: 8, 824: 8, 466: 8, 467: 8, 761: 8, 728: 8, 1572: 8, 1114: 8, 933: 8, 800: 8, 608: 8, 865: 8, 610: 8, 1595: 8, 934: 8, 998: 5, 1745: 8, 1000: 8, 764: 8, 1002: 8, 999: 7, 1789: 8, 1649: 8, 1779: 8, 1568: 8, 1017: 8, 1786: 8, 1787: 8, 1020: 8, 426: 6, 1279: 8} + +candidate_cars = all_known_cars() + + +for addr, l in fingerprint.items(): + dat = messaging.new_message('can', 1) + + msg = dat.can[0] + msg.address = addr + msg.dat = " " * l + + candidate_cars = eliminate_incompatible_cars(msg, candidate_cars) + print(candidate_cars) diff --git a/selfdrive/debug/test_fw_query_on_routes.py b/selfdrive/debug/test_fw_query_on_routes.py new file mode 100755 index 00000000000000..90346d524190d3 --- /dev/null +++ b/selfdrive/debug/test_fw_query_on_routes.py @@ -0,0 +1,137 @@ +#!/usr/bin/env python3 +# type: ignore + +from collections import defaultdict +import argparse +import os +import traceback +from tqdm import tqdm +from tools.lib.logreader import LogReader +from selfdrive.car.fw_versions import match_fw_to_car +from selfdrive.car.toyota.values import FW_VERSIONS as TOYOTA_FW_VERSIONS +from selfdrive.car.honda.values import FW_VERSIONS as HONDA_FW_VERSIONS +from selfdrive.car.hyundai.values import FW_VERSIONS as HYUNDAI_FW_VERSIONS + +from selfdrive.car.toyota.values import FINGERPRINTS as TOYOTA_FINGERPRINTS +from selfdrive.car.honda.values import FINGERPRINTS as HONDA_FINGERPRINTS +from selfdrive.car.hyundai.values import FINGERPRINTS as HYUNDAI_FINGERPRINTS + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Run FW fingerprint on Qlog of route or list of routes') + parser.add_argument('route', help='Route or file with list of routes') + parser.add_argument('--car', help='Force comparison fingerprint to known car') + args = parser.parse_args() + + if os.path.exists(args.route): + routes = list(open(args.route)) + else: + routes = [args.route] + + mismatches = defaultdict(list) + + wrong = 0 + good = 0 + + dongles = [] + for route in tqdm(routes): + route = route.rstrip() + dongle_id, time = route.split('|') + qlog_path = f"cd:/{dongle_id}/{time}/0/qlog.bz2" + + if dongle_id in dongles: + continue + + try: + lr = LogReader(qlog_path) + + for msg in lr: + if msg.which() == "health": + if msg.health.hwType not in ['uno', 'blackPanda']: + dongles.append(dongle_id) + break + + elif msg.which() == "carParams": + bts = msg.carParams.as_builder().to_bytes() + + car_fw = msg.carParams.carFw + if len(car_fw) == 0: + break + + dongles.append(dongle_id) + live_fingerprint = msg.carParams.carFingerprint + + if args.car is not None: + live_fingerprint = args.car + + if live_fingerprint not in list(TOYOTA_FINGERPRINTS.keys()) + list(HONDA_FINGERPRINTS.keys()) + list(HYUNDAI_FINGERPRINTS.keys()): + break + + candidates = match_fw_to_car(car_fw) + if (len(candidates) == 1) and (list(candidates)[0] == live_fingerprint): + good += 1 + print("Correct", live_fingerprint, dongle_id) + break + + print(f"{dongle_id}|{time}") + print("Old style:", live_fingerprint, "Vin", msg.carParams.carVin) + print("New style:", candidates) + + for version in car_fw: + subaddr = None if version.subAddress == 0 else hex(version.subAddress) + print(f" (Ecu.{version.ecu}, {hex(version.address)}, {subaddr}): [{version.fwVersion}],") + + print("Mismatches") + found = False + for car_fws in [TOYOTA_FW_VERSIONS, HONDA_FW_VERSIONS, HYUNDAI_FW_VERSIONS]: + if live_fingerprint in car_fws: + found = True + expected = car_fws[live_fingerprint] + for (_, expected_addr, expected_sub_addr), v in expected.items(): + for version in car_fw: + sub_addr = None if version.subAddress == 0 else version.subAddress + addr = version.address + + if (addr, sub_addr) == (expected_addr, expected_sub_addr): + if version.fwVersion not in v: + print(f"({hex(addr)}, {'None' if sub_addr is None else hex(sub_addr)}) - {version.fwVersion}") + + # Add to global list of mismatches + mismatch = (addr, sub_addr, version.fwVersion) + if mismatch not in mismatches[live_fingerprint]: + mismatches[live_fingerprint].append(mismatch) + + # No FW versions for this car yet, add them all to mismatch list + if not found: + for version in car_fw: + sub_addr = None if version.subAddress == 0 else version.subAddress + addr = version.address + mismatch = (addr, sub_addr, version.fwVersion) + if mismatch not in mismatches[live_fingerprint]: + mismatches[live_fingerprint].append(mismatch) + + print() + wrong += 1 + break + except Exception: + traceback.print_exc() + except KeyboardInterrupt: + break + + print(f"Fingerprinted: {good} - Not fingerprinted: {wrong}") + print(f"Number of dongle ids checked: {len(dongles)}") + print() + + # Print FW versions that need to be added seperated out by car and address + for car, m in mismatches.items(): + print(car) + addrs = defaultdict(list) + for (addr, sub_addr, version) in m: + addrs[(addr, sub_addr)].append(version) + + for (addr, sub_addr), versions in addrs.items(): + print(f" ({hex(addr)}, {'None' if sub_addr is None else hex(sub_addr)}): [") + for v in versions: + print(f" {v},") + print(" ]") + print() diff --git a/selfdrive/debug/toyota_eps_factor.py b/selfdrive/debug/toyota_eps_factor.py new file mode 100755 index 00000000000000..e63122b6a20613 --- /dev/null +++ b/selfdrive/debug/toyota_eps_factor.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 +import sys +import numpy as np +import matplotlib.pyplot as plt +from sklearn import linear_model # pylint: disable=import-error +from selfdrive.car.toyota.values import STEER_THRESHOLD + +from tools.lib.route import Route +from tools.lib.logreader import MultiLogIterator + +MIN_SAMPLES = 30 * 100 + + +def to_signed(n, bits): + if n >= (1 << max((bits - 1), 0)): + n = n - (1 << max(bits, 0)) + return n + + +def get_eps_factor(lr, plot=False): + engaged = False + steering_pressed = False + torque_cmd, eps_torque = None, None + cmds, eps = [], [] + + for msg in lr: + if msg.which() != 'can': + continue + + for m in msg.can: + if m.address == 0x2e4 and m.src == 128: + engaged = bool(m.dat[0] & 1) + torque_cmd = to_signed((m.dat[1] << 8) | m.dat[2], 16) + elif m.address == 0x260 and m.src == 0: + eps_torque = to_signed((m.dat[5] << 8) | m.dat[6], 16) + steering_pressed = abs(to_signed((m.dat[1] << 8) | m.dat[2], 16)) > STEER_THRESHOLD + + if engaged and torque_cmd is not None and eps_torque is not None and not steering_pressed: + cmds.append(torque_cmd) + eps.append(eps_torque) + else: + if len(cmds) > MIN_SAMPLES: + break + cmds, eps = [], [] + + if len(cmds) < MIN_SAMPLES: + raise Exception("too few samples found in route") + + lm = linear_model.LinearRegression(fit_intercept=False) + lm.fit(np.array(cmds).reshape(-1, 1), eps) + scale_factor = 1. / lm.coef_[0] + + if plot: + plt.plot(np.array(eps) * scale_factor) + plt.plot(cmds) + plt.show() + return scale_factor + + +if __name__ == "__main__": + r = Route(sys.argv[1]) + lr = MultiLogIterator(r.log_paths(), wraparound=False) + n = get_eps_factor(lr, plot="--plot" in sys.argv) + print("EPS torque factor: ", n) diff --git a/selfdrive/debug/tuner.py b/selfdrive/debug/tuner.py deleted file mode 100755 index 066b0841aba5bc..00000000000000 --- a/selfdrive/debug/tuner.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python -""" -This tool can be used to quickly changes the values in a JSON file used for tuning -Keys like in vim: - - h: decrease by 0.05 - - l: increase by 0.05 - - k: move pointer up - - j: move pointer down -""" - -import tty -import sys -import json -import termios -from collections import OrderedDict - -FILENAME = '/data/tuning.json' - -def read_tuning(): - while True: - try: - return json.loads(open(FILENAME).read()) - except: - pass - -def main(): - dat = json.loads(open(FILENAME, 'r').read()) - dat = OrderedDict(sorted(dat.items(), key=lambda i: i[0])) - - cur = 0 - while True: - sys.stdout.write("\x1Bc") - - for i, (k, v) in enumerate(dat.items()): - prefix = "> " if cur == i else " " - print((prefix + k).ljust(20) + "%.2f" % v) - - key = sys.stdin.read(1)[0] - - write = False - if key == "k": - cur = max(0, cur - 1) - elif key == "j": - cur = min(len(dat.keys()) - 1, cur + 1) - elif key == "l": - dat[dat.keys()[cur]] += 0.05 - write = True - elif key == "h": - dat[dat.keys()[cur]] -= 0.05 - write = True - elif key == "q": - break - - if write: - open(FILENAME, 'w').write(json.dumps(dat)) - - -if __name__ == "__main__": - orig_settings = termios.tcgetattr(sys.stdin) - tty.setcbreak(sys.stdin) - - try: - main() - termios.tcsetattr(sys.stdin, termios.TCSADRAIN, orig_settings) - except: - termios.tcsetattr(sys.stdin, termios.TCSADRAIN, orig_settings) - raise diff --git a/selfdrive/debug/uiview.py b/selfdrive/debug/uiview.py new file mode 100755 index 00000000000000..e31d6cf3c399cc --- /dev/null +++ b/selfdrive/debug/uiview.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +import time +import cereal.messaging as messaging +from selfdrive.manager import start_managed_process, kill_managed_process + +services = ['controlsState', 'thermal', 'radarState'] # the services needed to be spoofed to start ui offroad +procs = ['camerad', 'ui', 'modeld', 'calibrationd'] +[start_managed_process(p) for p in procs] # start needed processes +pm = messaging.PubMaster(services) + +dat_cs, dat_thermal, dat_radar = [messaging.new_message(s) for s in services] +dat_cs.controlsState.rearViewCam = False # ui checks for these two messages +dat_thermal.thermal.started = True + +try: + while True: + pm.send('controlsState', dat_cs) + pm.send('thermal', dat_thermal) + pm.send('radarState', dat_radar) + time.sleep(1 / 100) # continually send, rate doesn't matter for thermal +except KeyboardInterrupt: + [kill_managed_process(p) for p in procs] diff --git a/selfdrive/hardware/__init__.py b/selfdrive/hardware/__init__.py new file mode 100644 index 00000000000000..3babf1bb5d3abb --- /dev/null +++ b/selfdrive/hardware/__init__.py @@ -0,0 +1,19 @@ +import os +from typing import cast + +from selfdrive.hardware.base import HardwareBase +from selfdrive.hardware.eon.hardware import Android +from selfdrive.hardware.tici.hardware import Tici +from selfdrive.hardware.pc.hardware import Pc + +EON = os.path.isfile('/EON') +TICI = os.path.isfile('/TICI') +PC = not (EON or TICI) + + +if EON: + HARDWARE = cast(HardwareBase, Android()) +elif TICI: + HARDWARE = cast(HardwareBase, Tici()) +else: + HARDWARE = cast(HardwareBase, Pc()) diff --git a/selfdrive/hardware/base.py b/selfdrive/hardware/base.py new file mode 100644 index 00000000000000..24163a128e934a --- /dev/null +++ b/selfdrive/hardware/base.py @@ -0,0 +1,85 @@ +from abc import abstractmethod + + +class HardwareBase: + @staticmethod + def get_cmdline(): + with open('/proc/cmdline') as f: + cmdline = f.read() + return {kv[0]: kv[1] for kv in [s.split('=') for s in cmdline.split(' ')] if len(kv) == 2} + + @staticmethod + def read_param_file(path, parser, default=0): + try: + with open(path) as f: + return parser(f.read()) + except Exception: + return default + + @abstractmethod + def reboot(self, reason=None): + pass + + @abstractmethod + def uninstall(self): + pass + + @abstractmethod + def get_sound_card_online(self): + pass + + @abstractmethod + def get_imei(self, slot): + pass + + @abstractmethod + def get_serial(self): + pass + + @abstractmethod + def get_subscriber_info(self): + pass + + @abstractmethod + def get_network_type(self): + pass + + @abstractmethod + def get_sim_info(self): + pass + + @abstractmethod + def get_network_strength(self, network_type): + pass + + @abstractmethod + def get_battery_capacity(self): + pass + + @abstractmethod + def get_battery_status(self): + pass + + @abstractmethod + def get_battery_current(self): + pass + + @abstractmethod + def get_battery_voltage(self): + pass + + @abstractmethod + def get_battery_charging(self): + pass + + @abstractmethod + def set_battery_charging(self, on): + pass + + @abstractmethod + def get_usb_present(self): + pass + + @abstractmethod + def get_current_power_draw(self): + pass diff --git a/selfdrive/debug/getframes/__init__.py b/selfdrive/hardware/eon/__init__.py similarity index 100% rename from selfdrive/debug/getframes/__init__.py rename to selfdrive/hardware/eon/__init__.py diff --git a/selfdrive/hardware/eon/apk.py b/selfdrive/hardware/eon/apk.py new file mode 100644 index 00000000000000..275cdefedbde69 --- /dev/null +++ b/selfdrive/hardware/eon/apk.py @@ -0,0 +1,105 @@ +import os +import subprocess +import glob +import hashlib +import shutil +from common.basedir import BASEDIR +from selfdrive.swaglog import cloudlog + +android_packages = ("ai.comma.plus.offroad",) + +def get_installed_apks(): + dat = subprocess.check_output(["pm", "list", "packages", "-f"], encoding='utf8').strip().split("\n") + ret = {} + for x in dat: + if x.startswith("package:"): + v, k = x.split("package:")[1].split("=") + ret[k] = v + return ret + +def install_apk(path): + # can only install from world readable path + install_path = "/sdcard/%s" % os.path.basename(path) + shutil.copyfile(path, install_path) + + ret = subprocess.call(["pm", "install", "-r", install_path]) + os.remove(install_path) + return ret == 0 + +def start_offroad(): + set_package_permissions() + system("am start -n ai.comma.plus.offroad/.MainActivity") + +def set_package_permissions(): + try: + output = subprocess.check_output(['dumpsys', 'package', 'ai.comma.plus.offroad'], encoding="utf-8") + given_permissions = output.split("runtime permissions")[1] + except Exception: + given_permissions = "" + + wanted_permissions = ["ACCESS_FINE_LOCATION", "READ_PHONE_STATE", "READ_EXTERNAL_STORAGE"] + for permission in wanted_permissions: + if permission not in given_permissions: + pm_grant("ai.comma.plus.offroad", "android.permission."+permission) + + appops_set("ai.comma.plus.offroad", "SU", "allow") + appops_set("ai.comma.plus.offroad", "WIFI_SCAN", "allow") + +def appops_set(package, op, mode): + system(f"LD_LIBRARY_PATH= appops set {package} {op} {mode}") + +def pm_grant(package, permission): + system(f"pm grant {package} {permission}") + +def system(cmd): + try: + cloudlog.info("running %s" % cmd) + subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) + except subprocess.CalledProcessError as e: + cloudlog.event("running failed", + cmd=e.cmd, + output=e.output[-1024:], + returncode=e.returncode) + +# *** external functions *** + +def update_apks(): + # install apks + installed = get_installed_apks() + + install_apks = glob.glob(os.path.join(BASEDIR, "apk/*.apk")) + for apk in install_apks: + app = os.path.basename(apk)[:-4] + if app not in installed: + installed[app] = None + + cloudlog.info("installed apks %s" % (str(installed), )) + + for app in installed.keys(): + apk_path = os.path.join(BASEDIR, "apk/"+app+".apk") + if not os.path.exists(apk_path): + continue + + h1 = hashlib.sha1(open(apk_path, 'rb').read()).hexdigest() + h2 = None + if installed[app] is not None: + h2 = hashlib.sha1(open(installed[app], 'rb').read()).hexdigest() + cloudlog.info("comparing version of %s %s vs %s" % (app, h1, h2)) + + if h2 is None or h1 != h2: + cloudlog.info("installing %s" % app) + + success = install_apk(apk_path) + if not success: + cloudlog.info("needing to uninstall %s" % app) + system("pm uninstall %s" % app) + success = install_apk(apk_path) + + assert success + +def pm_apply_packages(cmd): + for p in android_packages: + system("pm %s %s" % (cmd, p)) + +if __name__ == "__main__": + update_apks() diff --git a/selfdrive/hardware/eon/hardware.py b/selfdrive/hardware/eon/hardware.py new file mode 100644 index 00000000000000..231b5ba6b02551 --- /dev/null +++ b/selfdrive/hardware/eon/hardware.py @@ -0,0 +1,337 @@ +import binascii +import itertools +import os +import re +import struct +import subprocess + +from cereal import log +from selfdrive.hardware.base import HardwareBase + +NetworkType = log.ThermalData.NetworkType +NetworkStrength = log.ThermalData.NetworkStrength + + +def service_call(call): + try: + ret = subprocess.check_output(["service", "call", *call], encoding='utf8').strip() + if 'Parcel' not in ret: + return None + return parse_service_call_bytes(ret) + except subprocess.CalledProcessError: + return None + + +def parse_service_call_unpack(r, fmt): + try: + return struct.unpack(fmt, r)[0] + except Exception: + return None + + +def parse_service_call_string(r): + try: + r = r[8:] # Cut off length field + r = r.decode('utf_16_be') + + # All pairs of two characters seem to be swapped. Not sure why + result = "" + for a, b, in itertools.zip_longest(r[::2], r[1::2], fillvalue='\x00'): + result += b + a + + result = result.replace('\x00', '') + + return result + except Exception: + return None + + +def parse_service_call_bytes(ret): + try: + r = b"" + for hex_part in re.findall(r'[ (]([0-9a-f]{8})', ret): + r += binascii.unhexlify(hex_part) + return r + except Exception: + return None + + +def getprop(key): + return subprocess.check_output(["getprop", key], encoding='utf8').strip() + + +class Android(HardwareBase): + def get_sound_card_online(self): + return (os.path.isfile('/proc/asound/card0/state') and + open('/proc/asound/card0/state').read().strip() == 'ONLINE') + + def get_imei(self, slot): + slot = str(slot) + if slot not in ("0", "1"): + raise ValueError("SIM slot must be 0 or 1") + + return parse_service_call_string(service_call(["iphonesubinfo", "3", "i32", str(slot)])) + + def get_serial(self): + ret = getprop("ro.serialno") + if ret == "": + ret = "cccccccc" + return ret + + def get_subscriber_info(self): + ret = parse_service_call_string(service_call(["iphonesubinfo", "7"])) + if ret is None or len(ret) < 8: + return "" + return ret + + def reboot(self, reason=None): + # e.g. reason="recovery" to go into recover mode + if reason is None: + reason_args = ["null"] + else: + reason_args = ["s16", reason] + + subprocess.check_output([ + "service", "call", "power", "16", # IPowerManager.reboot + "i32", "0", # no confirmation, + *reason_args, + "i32", "1" # wait + ]) + + def uninstall(self): + with open('/cache/recovery/command', 'w') as f: + f.write('--wipe_data\n') + # IPowerManager.reboot(confirm=false, reason="recovery", wait=true) + self.reboot(reason="recovery") + + def get_sim_info(self): + # Used for athena + # TODO: build using methods from this class + sim_state = getprop("gsm.sim.state").split(",") + network_type = getprop("gsm.network.type").split(',') + mcc_mnc = getprop("gsm.sim.operator.numeric") or None + + sim_id = parse_service_call_string(service_call(['iphonesubinfo', '11'])) + cell_data_state = parse_service_call_unpack(service_call(['phone', '46']), ">q") + cell_data_connected = (cell_data_state == 2) + + return { + 'sim_id': sim_id, + 'mcc_mnc': mcc_mnc, + 'network_type': network_type, + 'sim_state': sim_state, + 'data_connected': cell_data_connected + } + + def get_network_type(self): + wifi_check = parse_service_call_string(service_call(["connectivity", "2"])) + if wifi_check is None: + return NetworkType.none + elif 'WIFI' in wifi_check: + return NetworkType.wifi + else: + cell_check = parse_service_call_unpack(service_call(['phone', '59']), ">q") + # from TelephonyManager.java + cell_networks = { + 0: NetworkType.none, + 1: NetworkType.cell2G, + 2: NetworkType.cell2G, + 3: NetworkType.cell3G, + 4: NetworkType.cell2G, + 5: NetworkType.cell3G, + 6: NetworkType.cell3G, + 7: NetworkType.cell3G, + 8: NetworkType.cell3G, + 9: NetworkType.cell3G, + 10: NetworkType.cell3G, + 11: NetworkType.cell2G, + 12: NetworkType.cell3G, + 13: NetworkType.cell4G, + 14: NetworkType.cell4G, + 15: NetworkType.cell3G, + 16: NetworkType.cell2G, + 17: NetworkType.cell3G, + 18: NetworkType.cell4G, + 19: NetworkType.cell4G + } + return cell_networks.get(cell_check, NetworkType.none) + + def get_network_strength(self, network_type): + network_strength = NetworkStrength.unknown + + # from SignalStrength.java + def get_lte_level(rsrp, rssnr): + INT_MAX = 2147483647 + if rsrp == INT_MAX: + lvl_rsrp = NetworkStrength.unknown + elif rsrp >= -95: + lvl_rsrp = NetworkStrength.great + elif rsrp >= -105: + lvl_rsrp = NetworkStrength.good + elif rsrp >= -115: + lvl_rsrp = NetworkStrength.moderate + else: + lvl_rsrp = NetworkStrength.poor + if rssnr == INT_MAX: + lvl_rssnr = NetworkStrength.unknown + elif rssnr >= 45: + lvl_rssnr = NetworkStrength.great + elif rssnr >= 10: + lvl_rssnr = NetworkStrength.good + elif rssnr >= -30: + lvl_rssnr = NetworkStrength.moderate + else: + lvl_rssnr = NetworkStrength.poor + return max(lvl_rsrp, lvl_rssnr) + + def get_tdscdma_level(tdscmadbm): + lvl = NetworkStrength.unknown + if tdscmadbm > -25: + lvl = NetworkStrength.unknown + elif tdscmadbm >= -49: + lvl = NetworkStrength.great + elif tdscmadbm >= -73: + lvl = NetworkStrength.good + elif tdscmadbm >= -97: + lvl = NetworkStrength.moderate + elif tdscmadbm >= -110: + lvl = NetworkStrength.poor + return lvl + + def get_gsm_level(asu): + if asu <= 2 or asu == 99: + lvl = NetworkStrength.unknown + elif asu >= 12: + lvl = NetworkStrength.great + elif asu >= 8: + lvl = NetworkStrength.good + elif asu >= 5: + lvl = NetworkStrength.moderate + else: + lvl = NetworkStrength.poor + return lvl + + def get_evdo_level(evdodbm, evdosnr): + lvl_evdodbm = NetworkStrength.unknown + lvl_evdosnr = NetworkStrength.unknown + if evdodbm >= -65: + lvl_evdodbm = NetworkStrength.great + elif evdodbm >= -75: + lvl_evdodbm = NetworkStrength.good + elif evdodbm >= -90: + lvl_evdodbm = NetworkStrength.moderate + elif evdodbm >= -105: + lvl_evdodbm = NetworkStrength.poor + if evdosnr >= 7: + lvl_evdosnr = NetworkStrength.great + elif evdosnr >= 5: + lvl_evdosnr = NetworkStrength.good + elif evdosnr >= 3: + lvl_evdosnr = NetworkStrength.moderate + elif evdosnr >= 1: + lvl_evdosnr = NetworkStrength.poor + return max(lvl_evdodbm, lvl_evdosnr) + + def get_cdma_level(cdmadbm, cdmaecio): + lvl_cdmadbm = NetworkStrength.unknown + lvl_cdmaecio = NetworkStrength.unknown + if cdmadbm >= -75: + lvl_cdmadbm = NetworkStrength.great + elif cdmadbm >= -85: + lvl_cdmadbm = NetworkStrength.good + elif cdmadbm >= -95: + lvl_cdmadbm = NetworkStrength.moderate + elif cdmadbm >= -100: + lvl_cdmadbm = NetworkStrength.poor + if cdmaecio >= -90: + lvl_cdmaecio = NetworkStrength.great + elif cdmaecio >= -110: + lvl_cdmaecio = NetworkStrength.good + elif cdmaecio >= -130: + lvl_cdmaecio = NetworkStrength.moderate + elif cdmaecio >= -150: + lvl_cdmaecio = NetworkStrength.poor + return max(lvl_cdmadbm, lvl_cdmaecio) + + if network_type == NetworkType.none: + return network_strength + if network_type == NetworkType.wifi: + out = subprocess.check_output('dumpsys connectivity', shell=True).decode('utf-8') + network_strength = NetworkStrength.unknown + for line in out.split('\n'): + signal_str = "SignalStrength: " + if signal_str in line: + lvl_idx_start = line.find(signal_str) + len(signal_str) + lvl_idx_end = line.find(']', lvl_idx_start) + lvl = int(line[lvl_idx_start : lvl_idx_end]) + if lvl >= -50: + network_strength = NetworkStrength.great + elif lvl >= -60: + network_strength = NetworkStrength.good + elif lvl >= -70: + network_strength = NetworkStrength.moderate + else: + network_strength = NetworkStrength.poor + return network_strength + else: + # check cell strength + out = subprocess.check_output('dumpsys telephony.registry', shell=True).decode('utf-8') + for line in out.split('\n'): + if "mSignalStrength" in line: + arr = line.split(' ') + ns = 0 + if ("gsm" in arr[14]): + rsrp = int(arr[9]) + rssnr = int(arr[11]) + ns = get_lte_level(rsrp, rssnr) + if ns == NetworkStrength.unknown: + tdscmadbm = int(arr[13]) + ns = get_tdscdma_level(tdscmadbm) + if ns == NetworkStrength.unknown: + asu = int(arr[1]) + ns = get_gsm_level(asu) + else: + cdmadbm = int(arr[3]) + cdmaecio = int(arr[4]) + evdodbm = int(arr[5]) + evdosnr = int(arr[7]) + lvl_cdma = get_cdma_level(cdmadbm, cdmaecio) + lvl_edmo = get_evdo_level(evdodbm, evdosnr) + if lvl_edmo == NetworkStrength.unknown: + ns = lvl_cdma + elif lvl_cdma == NetworkStrength.unknown: + ns = lvl_edmo + else: + ns = min(lvl_cdma, lvl_edmo) + network_strength = max(network_strength, ns) + + return network_strength + + def get_battery_capacity(self): + return self.read_param_file("/sys/class/power_supply/battery/capacity", int, 100) + + def get_battery_status(self): + # This does not correspond with actual charging or not. + # If a USB cable is plugged in, it responds with 'Charging', even when charging is disabled + return self.read_param_file("/sys/class/power_supply/battery/status", lambda x: x.strip(), '') + + def get_battery_current(self): + return self.read_param_file("/sys/class/power_supply/battery/current_now", int) + + def get_battery_voltage(self): + return self.read_param_file("/sys/class/power_supply/battery/voltage_now", int) + + def get_battery_charging(self): + # This does correspond with actually charging + return self.read_param_file("/sys/class/power_supply/battery/charge_type", lambda x: x.strip() != "N/A", True) + + def set_battery_charging(self, on): + with open('/sys/class/power_supply/battery/charging_enabled', 'w') as f: + f.write(f"{1 if on else 0}\n") + + def get_usb_present(self): + return self.read_param_file("/sys/class/power_supply/usb/present", lambda x: bool(int(x)), False) + + def get_current_power_draw(self): + # We don't have a good direct way to measure this on android + return None diff --git a/selfdrive/locationd/test/__init__.py b/selfdrive/hardware/pc/__init__.py similarity index 100% rename from selfdrive/locationd/test/__init__.py rename to selfdrive/hardware/pc/__init__.py diff --git a/selfdrive/hardware/pc/hardware.py b/selfdrive/hardware/pc/hardware.py new file mode 100644 index 00000000000000..181de1103f1b08 --- /dev/null +++ b/selfdrive/hardware/pc/hardware.py @@ -0,0 +1,66 @@ +import random + +from cereal import log +from selfdrive.hardware.base import HardwareBase + +NetworkType = log.ThermalData.NetworkType +NetworkStrength = log.ThermalData.NetworkStrength + + +class Pc(HardwareBase): + def get_sound_card_online(self): + return True + + def reboot(self, reason=None): + print("REBOOT!") + + def uninstall(self): + print("uninstall") + + def get_imei(self, slot): + return "%015d" % random.randint(0, 1 << 32) + + def get_serial(self): + return "cccccccc" + + def get_subscriber_info(self): + return "" + + def get_network_type(self): + return NetworkType.wifi + + def get_sim_info(self): + return { + 'sim_id': '', + 'mcc_mnc': None, + 'network_type': ["Unknown"], + 'sim_state': ["ABSENT"], + 'data_connected': False + } + + def get_network_strength(self, network_type): + return NetworkStrength.unknown + + def get_battery_capacity(self): + return 100 + + def get_battery_status(self): + return "" + + def get_battery_current(self): + return 0 + + def get_battery_voltage(self): + return 0 + + def get_battery_charging(self): + return True + + def set_battery_charging(self, on): + pass + + def get_usb_present(self): + return False + + def get_current_power_draw(self): + return 0 diff --git a/selfdrive/loggerd/tests/__init__.py b/selfdrive/hardware/tici/__init__.py similarity index 100% rename from selfdrive/loggerd/tests/__init__.py rename to selfdrive/hardware/tici/__init__.py diff --git a/selfdrive/hardware/tici/hardware.py b/selfdrive/hardware/tici/hardware.py new file mode 100644 index 00000000000000..4c2e7178f72d16 --- /dev/null +++ b/selfdrive/hardware/tici/hardware.py @@ -0,0 +1,160 @@ +import subprocess + +from cereal import log +from selfdrive.hardware.base import HardwareBase + +NM = 'org.freedesktop.NetworkManager' +NM_CON_ACT = NM + '.Connection.Active' +NM_DEV_WL = NM + '.Device.Wireless' +NM_AP = NM + '.AccessPoint' +DBUS_PROPS = 'org.freedesktop.DBus.Properties' + +MM = 'org.freedesktop.ModemManager1' +MM_MODEM = MM + ".Modem" +MM_MODEM_SIMPLE = MM + ".Modem.Simple" +MM_SIM = MM + ".Sim" + +MM_MODEM_STATE_CONNECTED = 11 + +NetworkType = log.ThermalData.NetworkType +NetworkStrength = log.ThermalData.NetworkStrength + +# https://developer.gnome.org/ModemManager/unstable/ModemManager-Flags-and-Enumerations.html#MMModemAccessTechnology +MM_MODEM_ACCESS_TECHNOLOGY_UMTS = 1 << 5 +MM_MODEM_ACCESS_TECHNOLOGY_LTE = 1 << 14 + + +class Tici(HardwareBase): + def __init__(self): + import dbus # pylint: disable=import-error + + self.bus = dbus.SystemBus() + self.nm = self.bus.get_object(NM, '/org/freedesktop/NetworkManager') + self.mm = self.bus.get_object(MM, '/org/freedesktop/ModemManager1') + + def get_sound_card_online(self): + return True + + def reboot(self, reason=None): + subprocess.check_output(["sudo", "reboot"]) + + def uninstall(self): + # TODO: implement uninstall. reboot to factory reset? + pass + + def get_serial(self): + return self.get_cmdline()['androidboot.serialno'] + + def get_network_type(self): + primary_connection = self.nm.Get(NM, 'PrimaryConnection', dbus_interface=DBUS_PROPS) + primary_connection = self.bus.get_object(NM, primary_connection) + tp = primary_connection.Get(NM_CON_ACT, 'Type', dbus_interface=DBUS_PROPS) + + if tp in ['802-3-ethernet', '802-11-wireless']: + return NetworkType.wifi + elif tp in ['gsm']: + modem = self.get_modem() + access_t = modem.Get(MM_MODEM, 'AccessTechnologies', dbus_interface=DBUS_PROPS) + if access_t >= MM_MODEM_ACCESS_TECHNOLOGY_LTE: + return NetworkType.cell4G + elif access_t >= MM_MODEM_ACCESS_TECHNOLOGY_UMTS: + return NetworkType.cell3G + else: + return NetworkType.cell2G + + return NetworkType.none + + def get_modem(self): + objects = self.mm.GetManagedObjects(dbus_interface="org.freedesktop.DBus.ObjectManager") + modem_path = list(objects.keys())[0] + return self.bus.get_object(MM, modem_path) + + def get_wlan(self): + wlan_path = self.nm.GetDeviceByIpIface('wlan0', dbus_interface=NM) + return self.bus.get_object(NM, wlan_path) + + def get_sim_info(self): + modem = self.get_modem() + sim_path = modem.Get(MM_MODEM, 'Sim', dbus_interface=DBUS_PROPS) + + if sim_path == "/": + return { + 'sim_id': '', + 'mcc_mnc': None, + 'network_type': ["Unknown"], + 'sim_state': ["ABSENT"], + 'data_connected': False + } + else: + sim = self.bus.get_object(MM, sim_path) + return { + 'sim_id': str(sim.Get(MM_SIM, 'SimIdentifier', dbus_interface=DBUS_PROPS)), + 'mcc_mnc': str(sim.Get(MM_SIM, 'OperatorIdentifier', dbus_interface=DBUS_PROPS)), + 'network_type': ["Unknown"], + 'sim_state': ["READY"], + 'data_connected': modem.Get(MM_MODEM, 'State', dbus_interface=DBUS_PROPS) == MM_MODEM_STATE_CONNECTED, + } + + def get_subscriber_info(self): + return "" + + def get_imei(self, slot): + if slot != 0: + return "" + + return str(self.get_modem().Get(MM_MODEM, 'EquipmentIdentifier', dbus_interface=DBUS_PROPS)) + + def parse_strength(self, percentage): + if percentage < 25: + return NetworkStrength.poor + elif percentage < 50: + return NetworkStrength.moderate + elif percentage < 75: + return NetworkStrength.good + else: + return NetworkStrength.great + + def get_network_strength(self, network_type): + network_strength = NetworkStrength.unknown + + if network_type == NetworkType.none: + pass + elif network_type == NetworkType.wifi: + wlan = self.get_wlan() + active_ap_path = wlan.Get(NM_DEV_WL, 'ActiveAccessPoint', dbus_interface=DBUS_PROPS) + if active_ap_path != "/": + active_ap = self.bus.get_object(NM, active_ap_path) + strength = int(active_ap.Get(NM_AP, 'Strength', dbus_interface=DBUS_PROPS)) + network_strength = self.parse_strength(strength) + else: # Cellular + modem = self.get_modem() + strength = int(modem.Get(MM_MODEM, 'SignalQuality', dbus_interface=DBUS_PROPS)[0]) + network_strength = self.parse_strength(strength) + + return network_strength + + # We don't have a battery, so let's use some sane constants + def get_battery_capacity(self): + return 100 + + def get_battery_status(self): + return "" + + def get_battery_current(self): + return 0 + + def get_battery_voltage(self): + return 0 + + def get_battery_charging(self): + return True + + def set_battery_charging(self, on): + pass + + def get_usb_present(self): + # Not sure if relevant on tici, but the file exists + return self.read_param_file("/sys/class/power_supply/usb/present", lambda x: bool(int(x)), False) + + def get_current_power_draw(self): + return (self.read_param_file("/sys/class/hwmon/hwmon1/power1_input", int) / 1e6) diff --git a/selfdrive/hardware/tici/pins.py b/selfdrive/hardware/tici/pins.py new file mode 100644 index 00000000000000..7139f5e955fdf8 --- /dev/null +++ b/selfdrive/hardware/tici/pins.py @@ -0,0 +1,8 @@ +# TODO: these are also defined in a header +# GPIO pin definitions +GPIO_HUB_RST_N = 30 +GPIO_UBLOX_RST_N = 32 +GPIO_UBLOX_SAFEBOOT_N = 33 +GPIO_UBLOX_PWR_EN = 34 +GPIO_STM_RST_N = 124 +GPIO_STM_BOOT0 = 134 diff --git a/selfdrive/launcher.py b/selfdrive/launcher.py new file mode 100644 index 00000000000000..dcedf07167b002 --- /dev/null +++ b/selfdrive/launcher.py @@ -0,0 +1,27 @@ +import importlib +from setproctitle import setproctitle # pylint: disable=no-name-in-module + +import cereal.messaging as messaging +import selfdrive.crash as crash +from selfdrive.swaglog import cloudlog + +def launcher(proc): + try: + # import the process + mod = importlib.import_module(proc) + + # rename the process + setproctitle(proc) + + # create new context since we forked + messaging.context = messaging.Context() + + # exec the process + mod.main() + except KeyboardInterrupt: + cloudlog.warning("child %s got SIGINT" % proc) + except Exception: + # can't install the crash handler becuase sys.excepthook doesn't play nice + # with threads, so catch it here. + crash.capture_exception() + raise diff --git a/selfdrive/locationd/Makefile b/selfdrive/locationd/Makefile deleted file mode 100644 index ff46847689c805..00000000000000 --- a/selfdrive/locationd/Makefile +++ /dev/null @@ -1,121 +0,0 @@ -CC = clang -CXX = clang++ - -ARCH := $(shell uname -m) -OS := $(shell uname -o) - -BASEDIR = ../.. -PHONELIBS = ../../phonelibs - -WARN_FLAGS = -Werror=implicit-function-declaration \ - -Werror=incompatible-pointer-types \ - -Werror=int-conversion \ - -Werror=return-type \ - -Werror=format-extra-args - -CFLAGS = -std=gnu11 -g -fPIC -I../ -I../../ -O2 $(WARN_FLAGS) -Wall -CXXFLAGS = -std=c++11 -g -fPIC -I../ -I../../ -O2 $(WARN_FLAGS) -Wall -ZMQ_LIBS = -l:libczmq.a -l:libzmq.a - -ifeq ($(ARCH),aarch64) -CFLAGS += -mcpu=cortex-a57 -CXXFLAGS += -mcpu=cortex-a57 -ZMQ_LIBS += -lgnustl_shared -endif - - -JSON_FLAGS = -I$(PHONELIBS)/json/src -JSON11_FLAGS = -I$(PHONELIBS)/json11 - -EXTRA_LIBS = -lpthread - -ifeq ($(ARCH),x86_64) -ZMQ_FLAGS = -I$(BASEDIR)/phonelibs/zmq/x64/include -ZMQ_LIBS = -L$(BASEDIR)/external/zmq/lib \ - -l:libczmq.a -l:libzmq.a -ZMQ_SHARED_LIBS = -L$(BASEDIR)/external/zmq/lib \ - -lczmq -lzmq -else -EXTRA_LIBS += -llog -luuid -endif - -.PHONY: all -all: ubloxd paramsd - -include ../common/cereal.mk - -LOC_OBJS = locationd_yawrate.o params_learner.o paramsd.o \ - ../common/swaglog.o \ - ../common/params.o \ - ../common/util.o \ - $(PHONELIBS)/json11/json11.o \ - $(PHONELIBS)/json/src/json.o \ - $(CEREAL_OBJS) - -LOC_DEPS := $(LOC_OBJS:.o=.d) - -OBJS = ublox_msg.o \ - ubloxd_main.o \ - ../common/swaglog.o \ - ../common/params.o \ - ../common/util.o \ - $(PHONELIBS)/json/src/json.o \ - $(CEREAL_OBJS) - -DEPS := $(OBJS:.o=.d) ubloxd.d ubloxd_test.d - -liblocationd.so: $(LOC_OBJS) - @echo "[ LINK ] $@" - $(CXX) -shared -o '$@' $^ \ - $(CEREAL_LIBS) \ - $(ZMQ_SHARED_LIBS) \ - $(EXTRA_LIBS) - -paramsd: $(LOC_OBJS) - @echo "[ LINK ] $@" - $(CXX) -fPIC -o '$@' $^ \ - $(CEREAL_LIBS) \ - $(ZMQ_LIBS) \ - $(EXTRA_LIBS) - -ubloxd: ubloxd.o $(OBJS) - @echo "[ LINK ] $@" - $(CXX) -fPIC -o '$@' $^ \ - $(CEREAL_LIBS) \ - $(ZMQ_LIBS) \ - $(EXTRA_LIBS) - -ubloxd_test: ubloxd_test.o $(OBJS) - @echo "[ LINK ] $@" - $(CXX) -fPIC -o '$@' $^ \ - $(CEREAL_LIBS) \ - $(ZMQ_LIBS) \ - $(EXTRA_LIBS) - -%.o: %.cc - @echo "[ CXX ] $@" - $(CXX) $(CXXFLAGS) -MMD \ - -Iinclude -I.. -I../.. \ - $(CEREAL_CXXFLAGS) \ - $(ZMQ_FLAGS) \ - $(JSON11_FLAGS) \ - $(JSON_FLAGS) \ - -I../ \ - -I../../ \ - -c -o '$@' '$<' - -%.o: %.c - @echo "[ CC ] $@" - $(CC) $(CFLAGS) -MMD \ - -Iinclude -I.. -I../.. \ - $(CEREAL_CFLAGS) \ - $(ZMQ_FLAGS) \ - $(JSON_FLAGS) \ - -c -o '$@' '$<' - -.PHONY: clean -clean: - rm -f ubloxd paramsd liblocationd.so ubloxd.d ubloxd.o ubloxd_test ubloxd_test.o ubloxd_test.d $(OBJS) $(LOC_OBJS) $(DEPS) - --include $(DEPS) --include $(LOC_DEPS) diff --git a/selfdrive/locationd/SConscript b/selfdrive/locationd/SConscript new file mode 100644 index 00000000000000..59516574d8ffca --- /dev/null +++ b/selfdrive/locationd/SConscript @@ -0,0 +1,15 @@ +Import('env', 'common', 'cereal', 'messaging') + +loc_libs = [cereal, messaging, 'zmq', common, 'capnp', 'kj', 'pthread'] + +env.Program("ubloxd", [ + "ubloxd.cc", + "ublox_msg.cc", + "ubloxd_main.cc"], + LIBS=loc_libs) + +env.Program("ubloxd_test", [ + "ubloxd_test.cc", + "ublox_msg.cc", + "ubloxd_main.cc"], + LIBS=loc_libs) diff --git a/selfdrive/locationd/calibration_helpers.py b/selfdrive/locationd/calibration_helpers.py deleted file mode 100644 index f2909007594924..00000000000000 --- a/selfdrive/locationd/calibration_helpers.py +++ /dev/null @@ -1,11 +0,0 @@ -import math - -class Filter: - MIN_SPEED = 7 # m/s (~15.5mph) - MAX_YAW_RATE = math.radians(3) # per second - -class Calibration: - UNCALIBRATED = 0 - CALIBRATED = 1 - INVALID = 2 - diff --git a/selfdrive/locationd/calibrationd.py b/selfdrive/locationd/calibrationd.py index 2890b0f61d87ff..f9b857fbc42ca7 100755 --- a/selfdrive/locationd/calibrationd.py +++ b/selfdrive/locationd/calibrationd.py @@ -1,118 +1,229 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +''' +This process finds calibration values. More info on what these calibration values +are can be found here https://github.com/commaai/openpilot/tree/master/common/transformations +While the roll calibration is a real value that can be estimated, here we assume it's zero, +and the image input into the neural network is not corrected for roll. +''' + import os +import capnp import copy import json import numpy as np -import selfdrive.messaging as messaging -from selfdrive.locationd.calibration_helpers import Calibration -from selfdrive.swaglog import cloudlog -from selfdrive.services import service_list -from common.params import Params +import cereal.messaging as messaging +from cereal import car, log +from common.params import Params, put_nonblocking from common.transformations.model import model_height -from common.transformations.camera import view_frame_from_device_frame, get_view_frame_from_road_frame, \ - eon_intrinsics, get_calib_from_vp, H, W +from common.transformations.camera import get_view_frame_from_road_frame +from common.transformations.orientation import rot_from_euler, euler_from_rot +from selfdrive.config import Conversions as CV +from selfdrive.swaglog import cloudlog -MPH_TO_MS = 0.44704 -MIN_SPEED_FILTER = 15 * MPH_TO_MS +MIN_SPEED_FILTER = 15 * CV.MPH_TO_MS +MAX_VEL_ANGLE_STD = np.radians(0.25) MAX_YAW_RATE_FILTER = np.radians(2) # per second -INPUTS_NEEDED = 300 # allow to update VP every so many frames -INPUTS_WANTED = 600 # We want a little bit more than we need for stability -WRITE_CYCLES = 400 # write every 400 cycles -VP_INIT = np.array([W/2., H/2.]) - -# These validity corners were chosen by looking at 1000 -# and taking most extreme cases with some margin. -VP_VALIDITY_CORNERS = np.array([[W//2 - 150, 280], [W//2 + 150, 540]]) + +# This is at model frequency, blocks needed for efficiency +SMOOTH_CYCLES = 400 +BLOCK_SIZE = 100 +INPUTS_NEEDED = 5 # Minimum blocks needed for valid calibration +INPUTS_WANTED = 50 # We want a little bit more than we need for stability +MAX_ALLOWED_SPREAD = np.radians(2) +RPY_INIT = np.array([0.0,0.0,0.0]) + +# These values are needed to accomodate biggest modelframe +PITCH_LIMITS = np.array([-0.09074112085129739, 0.14907572052989657]) +YAW_LIMITS = np.array([-0.06912048084718224, 0.06912048084718235]) DEBUG = os.getenv("DEBUG") is not None -def is_calibration_valid(vp): - return vp[0] > VP_VALIDITY_CORNERS[0,0] and vp[0] < VP_VALIDITY_CORNERS[1,0] and \ - vp[1] > VP_VALIDITY_CORNERS[0,1] and vp[1] < VP_VALIDITY_CORNERS[1,1] +class Calibration: + UNCALIBRATED = 0 + CALIBRATED = 1 + INVALID = 2 + + +def is_calibration_valid(rpy): + return (PITCH_LIMITS[0] < rpy[1] < PITCH_LIMITS[1]) and (YAW_LIMITS[0] < rpy[2] < YAW_LIMITS[1]) + + +def sanity_clip(rpy): + if np.isnan(rpy).any(): + rpy = RPY_INIT + return np.array([rpy[0], + np.clip(rpy[1], PITCH_LIMITS[0] - .005, PITCH_LIMITS[1] + .005), + np.clip(rpy[2], YAW_LIMITS[0] - .005, YAW_LIMITS[1] + .005)]) -class Calibrator(object): +class Calibrator(): def __init__(self, param_put=False): self.param_put = param_put - self.vp = copy.copy(VP_INIT) - self.vps = [] - self.cal_status = Calibration.UNCALIBRATED - self.write_counter = 0 - self.just_calibrated = False - self.params = Params() - calibration_params = self.params.get("CalibrationParams") - if calibration_params: + + # Read saved calibration + params = Params() + calibration_params = params.get("CalibrationParams") + + rpy_init = RPY_INIT + valid_blocks = 0 + + cached_params = params.get("CarParamsCache") + if cached_params is not None: + CP = car.CarParams.from_bytes(params.get("CarParams", block=True)) + cached_params = car.CarParams.from_bytes(cached_params) + if cached_params.carFingerprint != CP.carFingerprint: + calibration_params = None + + if param_put and calibration_params: try: + msg = log.Event.from_bytes(calibration_params) + rpy_init = list(msg.liveCalibration.rpyCalib) + valid_blocks = msg.liveCalibration.validBlocks + except (ValueError, capnp.lib.capnp.KjException): + # TODO: remove this when offroad can read capnp calibration_params = json.loads(calibration_params) - self.vp = np.array(calibration_params["vanishing_point"]) - self.vps = np.tile(self.vp, (calibration_params['valid_points'], 1)).tolist() - self.update_status() + rpy_init = calibration_params["calib_radians"] + valid_blocks = calibration_params['valid_blocks'] except Exception: cloudlog.exception("CalibrationParams file found but error encountered") + self.reset(rpy_init, valid_blocks) + self.update_status() + + def reset(self, rpy_init=RPY_INIT, valid_blocks=0, smooth_from=None): + if not np.isfinite(rpy_init).all(): + self.rpy = copy.copy(RPY_INIT) + else: + self.rpy = rpy_init + if not np.isfinite(valid_blocks) or valid_blocks < 0: + self.valid_blocks = 0 + else: + self.valid_blocks = valid_blocks + self.rpys = np.tile(self.rpy, (INPUTS_WANTED, 1)) + + self.idx = 0 + self.block_idx = 0 + self.v_ego = 0 + + if smooth_from is None: + self.old_rpy = RPY_INIT + self.old_rpy_weight = 0.0 + else: + self.old_rpy = smooth_from + self.old_rpy_weight = 1.0 def update_status(self): - start_status = self.cal_status - if len(self.vps) < INPUTS_NEEDED: + if self.valid_blocks > 0: + max_rpy_calib = np.array(np.max(self.rpys[:self.valid_blocks], axis=0)) + min_rpy_calib = np.array(np.min(self.rpys[:self.valid_blocks], axis=0)) + self.calib_spread = np.abs(max_rpy_calib - min_rpy_calib) + else: + self.calib_spread = np.zeros(3) + + if self.valid_blocks < INPUTS_NEEDED: self.cal_status = Calibration.UNCALIBRATED + elif is_calibration_valid(self.rpy): + self.cal_status = Calibration.CALIBRATED else: - self.cal_status = Calibration.CALIBRATED if is_calibration_valid(self.vp) else Calibration.INVALID - end_status = self.cal_status - - self.just_calibrated = False - if start_status == Calibration.UNCALIBRATED and end_status == Calibration.CALIBRATED: - self.just_calibrated = True - - def handle_cam_odom(self, log): - trans, rot = log.cameraOdometry.trans, log.cameraOdometry.rot - if np.linalg.norm(trans) > MIN_SPEED_FILTER and abs(rot[2]) < MAX_YAW_RATE_FILTER: - new_vp = eon_intrinsics.dot(view_frame_from_device_frame.dot(trans)) - new_vp = new_vp[:2]/new_vp[2] - self.vps.append(new_vp) - self.vps = self.vps[-INPUTS_WANTED:] - self.vp = np.mean(self.vps, axis=0) - self.update_status() - self.write_counter += 1 - if self.param_put and (self.write_counter % WRITE_CYCLES == 0 or self.just_calibrated): - cal_params = {"vanishing_point": list(self.vp), - "valid_points": len(self.vps)} - self.params.put("CalibrationParams", json.dumps(cal_params)) - return new_vp + self.cal_status = Calibration.INVALID + + # If spread is too high, assume mounting was changed and reset to last block. + # Make the transition smooth. Abrupt transistion are not good foor feedback loop through supercombo model. + if max(self.calib_spread) > MAX_ALLOWED_SPREAD and self.cal_status == Calibration.CALIBRATED: + self.reset(self.rpys[self.block_idx - 1], valid_blocks=INPUTS_NEEDED, smooth_from=self.rpy) + + write_this_cycle = (self.idx == 0) and (self.block_idx % (INPUTS_WANTED//5) == 5) + if self.param_put and write_this_cycle: + # TODO: change to raw bytes when offroad can read capnp + cal_params = {"calib_radians": list(self.rpy), + "valid_blocks": int(self.valid_blocks)} + put_nonblocking("CalibrationParams", json.dumps(cal_params).encode('utf8')) + + def handle_v_ego(self, v_ego): + self.v_ego = v_ego + + def get_smooth_rpy(self): + if self.old_rpy_weight > 0: + return self.old_rpy_weight * self.old_rpy + (1.0 - self.old_rpy_weight) * self.rpy else: + return self.rpy + + def handle_cam_odom(self, trans, rot, trans_std, rot_std): + self.old_rpy_weight = min(0.0, self.old_rpy_weight - 1/SMOOTH_CYCLES) + + straight_and_fast = ((self.v_ego > MIN_SPEED_FILTER) and (trans[0] > MIN_SPEED_FILTER) and (abs(rot[2]) < MAX_YAW_RATE_FILTER)) + certain_if_calib = ((np.arctan2(trans_std[1], trans[0]) < MAX_VEL_ANGLE_STD) or + (self.valid_blocks < INPUTS_NEEDED)) + + if not (straight_and_fast and certain_if_calib): return None - def send_data(self, livecalibration): - calib = get_calib_from_vp(self.vp) - extrinsic_matrix = get_view_frame_from_road_frame(0, calib[1], calib[2], model_height) + observed_rpy = np.array([0, + -np.arctan2(trans[2], trans[0]), + np.arctan2(trans[1], trans[0])]) + new_rpy = euler_from_rot(rot_from_euler(self.get_smooth_rpy()).dot(rot_from_euler(observed_rpy))) + new_rpy = sanity_clip(new_rpy) - cal_send = messaging.new_message() - cal_send.init('liveCalibration') - cal_send.liveCalibration.calStatus = self.cal_status - cal_send.liveCalibration.calPerc = min(len(self.vps) * 100 // INPUTS_NEEDED, 100) - cal_send.liveCalibration.extrinsicMatrix = [float(x) for x in extrinsic_matrix.flatten()] - cal_send.liveCalibration.rpyCalib = [float(x) for x in calib] + self.rpys[self.block_idx] = (self.idx*self.rpys[self.block_idx] + (BLOCK_SIZE - self.idx) * new_rpy) / float(BLOCK_SIZE) + self.idx = (self.idx + 1) % BLOCK_SIZE + if self.idx == 0: + self.block_idx += 1 + self.valid_blocks = max(self.block_idx, self.valid_blocks) + self.block_idx = self.block_idx % INPUTS_WANTED + if self.valid_blocks > 0: + self.rpy = np.mean(self.rpys[:self.valid_blocks], axis=0) - livecalibration.send(cal_send.to_bytes()) + self.update_status() + return new_rpy + + def get_msg(self): + smooth_rpy = self.get_smooth_rpy() + extrinsic_matrix = get_view_frame_from_road_frame(0, smooth_rpy[1], smooth_rpy[2], model_height) + + msg = messaging.new_message('liveCalibration') + msg.liveCalibration.validBlocks = self.valid_blocks + msg.liveCalibration.calStatus = self.cal_status + msg.liveCalibration.calPerc = min(100 * (self.valid_blocks * BLOCK_SIZE + self.idx) // (INPUTS_NEEDED * BLOCK_SIZE), 100) + msg.liveCalibration.extrinsicMatrix = [float(x) for x in extrinsic_matrix.flatten()] + msg.liveCalibration.rpyCalib = [float(x) for x in smooth_rpy] + msg.liveCalibration.rpyCalibSpread = [float(x) for x in self.calib_spread] + return msg + + def send_data(self, pm): + pm.send('liveCalibration', self.get_msg()) + + +def calibrationd_thread(sm=None, pm=None): + if sm is None: + sm = messaging.SubMaster(['cameraOdometry', 'carState'], poll=['cameraOdometry']) + + if pm is None: + pm = messaging.PubMaster(['liveCalibration']) -def calibrationd_thread(gctx=None, addr="127.0.0.1"): - cameraodometry = messaging.sub_sock(service_list['cameraOdometry'].port, addr=addr, conflate=True) - livecalibration = messaging.pub_sock(service_list['liveCalibration'].port) calibrator = Calibrator(param_put=True) - # buffer with all the messages that still need to be input into the kalman while 1: - co = messaging.recv_one(cameraodometry) + timeout = 0 if sm.frame == -1 else 100 + sm.update(timeout) + + if sm.updated['cameraOdometry']: + calibrator.handle_v_ego(sm['carState'].vEgo) + new_rpy = calibrator.handle_cam_odom(sm['cameraOdometry'].trans, + sm['cameraOdometry'].rot, + sm['cameraOdometry'].transStd, + sm['cameraOdometry'].rotStd) - new_vp = calibrator.handle_cam_odom(co) - if DEBUG and new_vp is not None: - print 'got new vp', new_vp + if DEBUG and new_rpy is not None: + print('got new rpy', new_rpy) - calibrator.send_data(livecalibration) + # 4Hz driven by cameraOdometry + if sm.frame % 5 == 0: + calibrator.send_data(pm) -def main(gctx=None, addr="127.0.0.1"): - calibrationd_thread(gctx, addr) +def main(sm=None, pm=None): + calibrationd_thread(sm, pm) if __name__ == "__main__": diff --git a/selfdrive/locationd/get_vp.c b/selfdrive/locationd/get_vp.c deleted file mode 100644 index 8a48c88150b4cb..00000000000000 --- a/selfdrive/locationd/get_vp.c +++ /dev/null @@ -1,41 +0,0 @@ -int get_intersections(double *lines, double *intersections, long long n) { - double D, Dx, Dy; - double x, y; - double *L1, *L2; - int k = 0; - for (int i=0; i < n; i++) { - for (int j=0; j < n; j++) { - L1 = lines + i*3; - L2 = lines + j*3; - D = L1[0] * L2[1] - L1[1] * L2[0]; - Dx = L1[2] * L2[1] - L1[1] * L2[2]; - Dy = L1[0] * L2[2] - L1[2] * L2[0]; - // only intersect lines from different quadrants and only left-right crossing - if ((D != 0) && (L1[0]*L2[0]*L1[1]*L2[1] < 0) && (L1[1]*L2[1] < 0)){ - x = Dx / D; - y = Dy / D; - if ((0 < x) && - (x < W) && - (0 < y) && - (y < H)){ - intersections[k*2 + 0] = x; - intersections[k*2 + 1] = y; - k++; - } - } - } - } - return k; -} - -void increment_grid(double *grid, double *lines, long long n) { - double *intersections = (double*) malloc(n*n*2*sizeof(double)); - int y, x, k; - k = get_intersections(lines, intersections, n); - for (int i=0; i < k; i++) { - x = (int) (intersections[i*2 + 0] + 0.5); - y = (int) (intersections[i*2 + 1] + 0.5); - grid[y*(W+1) + x] += 1.; - } - free(intersections); -} diff --git a/selfdrive/locationd/kalman/loc_local.cpp b/selfdrive/locationd/kalman/loc_local.cpp deleted file mode 100644 index b8f4acaa2d0428..00000000000000 --- a/selfdrive/locationd/kalman/loc_local.cpp +++ /dev/null @@ -1,2922 +0,0 @@ -#define _CFFI_ - -/* We try to define Py_LIMITED_API before including Python.h. - - Mess: we can only define it if Py_DEBUG, Py_TRACE_REFS and - Py_REF_DEBUG are not defined. This is a best-effort approximation: - we can learn about Py_DEBUG from pyconfig.h, but it is unclear if - the same works for the other two macros. Py_DEBUG implies them, - but not the other way around. - - Issue #350 is still open: on Windows, the code here causes it to link - with PYTHON36.DLL (for example) instead of PYTHON3.DLL. A fix was - attempted in 164e526a5515 and 14ce6985e1c3, but reverted: virtualenv - does not make PYTHON3.DLL available, and so the "correctly" compiled - version would not run inside a virtualenv. We will re-apply the fix - after virtualenv has been fixed for some time. For explanation, see - issue #355. For a workaround if you want PYTHON3.DLL and don't worry - about virtualenv, see issue #350. See also 'py_limited_api' in - setuptools_ext.py. -*/ -#if !defined(_CFFI_USE_EMBEDDING) && !defined(Py_LIMITED_API) -# include -# if !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG) -# define Py_LIMITED_API -# endif -#endif - -#include -#ifdef __cplusplus -extern "C" { -#endif -#include - -/* This part is from file 'cffi/parse_c_type.h'. It is copied at the - beginning of C sources generated by CFFI's ffi.set_source(). */ - -typedef void *_cffi_opcode_t; - -#define _CFFI_OP(opcode, arg) (_cffi_opcode_t)(opcode | (((uintptr_t)(arg)) << 8)) -#define _CFFI_GETOP(cffi_opcode) ((unsigned char)(uintptr_t)cffi_opcode) -#define _CFFI_GETARG(cffi_opcode) (((intptr_t)cffi_opcode) >> 8) - -#define _CFFI_OP_PRIMITIVE 1 -#define _CFFI_OP_POINTER 3 -#define _CFFI_OP_ARRAY 5 -#define _CFFI_OP_OPEN_ARRAY 7 -#define _CFFI_OP_STRUCT_UNION 9 -#define _CFFI_OP_ENUM 11 -#define _CFFI_OP_FUNCTION 13 -#define _CFFI_OP_FUNCTION_END 15 -#define _CFFI_OP_NOOP 17 -#define _CFFI_OP_BITFIELD 19 -#define _CFFI_OP_TYPENAME 21 -#define _CFFI_OP_CPYTHON_BLTN_V 23 // varargs -#define _CFFI_OP_CPYTHON_BLTN_N 25 // noargs -#define _CFFI_OP_CPYTHON_BLTN_O 27 // O (i.e. a single arg) -#define _CFFI_OP_CONSTANT 29 -#define _CFFI_OP_CONSTANT_INT 31 -#define _CFFI_OP_GLOBAL_VAR 33 -#define _CFFI_OP_DLOPEN_FUNC 35 -#define _CFFI_OP_DLOPEN_CONST 37 -#define _CFFI_OP_GLOBAL_VAR_F 39 -#define _CFFI_OP_EXTERN_PYTHON 41 - -#define _CFFI_PRIM_VOID 0 -#define _CFFI_PRIM_BOOL 1 -#define _CFFI_PRIM_CHAR 2 -#define _CFFI_PRIM_SCHAR 3 -#define _CFFI_PRIM_UCHAR 4 -#define _CFFI_PRIM_SHORT 5 -#define _CFFI_PRIM_USHORT 6 -#define _CFFI_PRIM_INT 7 -#define _CFFI_PRIM_UINT 8 -#define _CFFI_PRIM_LONG 9 -#define _CFFI_PRIM_ULONG 10 -#define _CFFI_PRIM_LONGLONG 11 -#define _CFFI_PRIM_ULONGLONG 12 -#define _CFFI_PRIM_FLOAT 13 -#define _CFFI_PRIM_DOUBLE 14 -#define _CFFI_PRIM_LONGDOUBLE 15 - -#define _CFFI_PRIM_WCHAR 16 -#define _CFFI_PRIM_INT8 17 -#define _CFFI_PRIM_UINT8 18 -#define _CFFI_PRIM_INT16 19 -#define _CFFI_PRIM_UINT16 20 -#define _CFFI_PRIM_INT32 21 -#define _CFFI_PRIM_UINT32 22 -#define _CFFI_PRIM_INT64 23 -#define _CFFI_PRIM_UINT64 24 -#define _CFFI_PRIM_INTPTR 25 -#define _CFFI_PRIM_UINTPTR 26 -#define _CFFI_PRIM_PTRDIFF 27 -#define _CFFI_PRIM_SIZE 28 -#define _CFFI_PRIM_SSIZE 29 -#define _CFFI_PRIM_INT_LEAST8 30 -#define _CFFI_PRIM_UINT_LEAST8 31 -#define _CFFI_PRIM_INT_LEAST16 32 -#define _CFFI_PRIM_UINT_LEAST16 33 -#define _CFFI_PRIM_INT_LEAST32 34 -#define _CFFI_PRIM_UINT_LEAST32 35 -#define _CFFI_PRIM_INT_LEAST64 36 -#define _CFFI_PRIM_UINT_LEAST64 37 -#define _CFFI_PRIM_INT_FAST8 38 -#define _CFFI_PRIM_UINT_FAST8 39 -#define _CFFI_PRIM_INT_FAST16 40 -#define _CFFI_PRIM_UINT_FAST16 41 -#define _CFFI_PRIM_INT_FAST32 42 -#define _CFFI_PRIM_UINT_FAST32 43 -#define _CFFI_PRIM_INT_FAST64 44 -#define _CFFI_PRIM_UINT_FAST64 45 -#define _CFFI_PRIM_INTMAX 46 -#define _CFFI_PRIM_UINTMAX 47 -#define _CFFI_PRIM_FLOATCOMPLEX 48 -#define _CFFI_PRIM_DOUBLECOMPLEX 49 -#define _CFFI_PRIM_CHAR16 50 -#define _CFFI_PRIM_CHAR32 51 - -#define _CFFI__NUM_PRIM 52 -#define _CFFI__UNKNOWN_PRIM (-1) -#define _CFFI__UNKNOWN_FLOAT_PRIM (-2) -#define _CFFI__UNKNOWN_LONG_DOUBLE (-3) - -#define _CFFI__IO_FILE_STRUCT (-1) - - -struct _cffi_global_s { - const char *name; - void *address; - _cffi_opcode_t type_op; - void *size_or_direct_fn; // OP_GLOBAL_VAR: size, or 0 if unknown - // OP_CPYTHON_BLTN_*: addr of direct function -}; - -struct _cffi_getconst_s { - unsigned long long value; - const struct _cffi_type_context_s *ctx; - int gindex; -}; - -struct _cffi_struct_union_s { - const char *name; - int type_index; // -> _cffi_types, on a OP_STRUCT_UNION - int flags; // _CFFI_F_* flags below - size_t size; - int alignment; - int first_field_index; // -> _cffi_fields array - int num_fields; -}; -#define _CFFI_F_UNION 0x01 // is a union, not a struct -#define _CFFI_F_CHECK_FIELDS 0x02 // complain if fields are not in the - // "standard layout" or if some are missing -#define _CFFI_F_PACKED 0x04 // for CHECK_FIELDS, assume a packed struct -#define _CFFI_F_EXTERNAL 0x08 // in some other ffi.include() -#define _CFFI_F_OPAQUE 0x10 // opaque - -struct _cffi_field_s { - const char *name; - size_t field_offset; - size_t field_size; - _cffi_opcode_t field_type_op; -}; - -struct _cffi_enum_s { - const char *name; - int type_index; // -> _cffi_types, on a OP_ENUM - int type_prim; // _CFFI_PRIM_xxx - const char *enumerators; // comma-delimited string -}; - -struct _cffi_typename_s { - const char *name; - int type_index; /* if opaque, points to a possibly artificial - OP_STRUCT which is itself opaque */ -}; - -struct _cffi_type_context_s { - _cffi_opcode_t *types; - const struct _cffi_global_s *globals; - const struct _cffi_field_s *fields; - const struct _cffi_struct_union_s *struct_unions; - const struct _cffi_enum_s *enums; - const struct _cffi_typename_s *typenames; - int num_globals; - int num_struct_unions; - int num_enums; - int num_typenames; - const char *const *includes; - int num_types; - int flags; /* future extension */ -}; - -struct _cffi_parse_info_s { - const struct _cffi_type_context_s *ctx; - _cffi_opcode_t *output; - unsigned int output_size; - size_t error_location; - const char *error_message; -}; - -struct _cffi_externpy_s { - const char *name; - size_t size_of_result; - void *reserved1, *reserved2; -}; - -#ifdef _CFFI_INTERNAL -static int parse_c_type(struct _cffi_parse_info_s *info, const char *input); -static int search_in_globals(const struct _cffi_type_context_s *ctx, - const char *search, size_t search_len); -static int search_in_struct_unions(const struct _cffi_type_context_s *ctx, - const char *search, size_t search_len); -#endif - -/* this block of #ifs should be kept exactly identical between - c/_cffi_backend.c, cffi/vengine_cpy.py, cffi/vengine_gen.py - and cffi/_cffi_include.h */ -#if defined(_MSC_VER) -# include /* for alloca() */ -# if _MSC_VER < 1600 /* MSVC < 2010 */ - typedef __int8 int8_t; - typedef __int16 int16_t; - typedef __int32 int32_t; - typedef __int64 int64_t; - typedef unsigned __int8 uint8_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int32 uint32_t; - typedef unsigned __int64 uint64_t; - typedef __int8 int_least8_t; - typedef __int16 int_least16_t; - typedef __int32 int_least32_t; - typedef __int64 int_least64_t; - typedef unsigned __int8 uint_least8_t; - typedef unsigned __int16 uint_least16_t; - typedef unsigned __int32 uint_least32_t; - typedef unsigned __int64 uint_least64_t; - typedef __int8 int_fast8_t; - typedef __int16 int_fast16_t; - typedef __int32 int_fast32_t; - typedef __int64 int_fast64_t; - typedef unsigned __int8 uint_fast8_t; - typedef unsigned __int16 uint_fast16_t; - typedef unsigned __int32 uint_fast32_t; - typedef unsigned __int64 uint_fast64_t; - typedef __int64 intmax_t; - typedef unsigned __int64 uintmax_t; -# else -# include -# endif -# if _MSC_VER < 1800 /* MSVC < 2013 */ -# ifndef __cplusplus - typedef unsigned char _Bool; -# endif -# endif -#else -# include -# if (defined (__SVR4) && defined (__sun)) || defined(_AIX) || defined(__hpux) -# include -# endif -#endif - -#ifdef __GNUC__ -# define _CFFI_UNUSED_FN __attribute__((unused)) -#else -# define _CFFI_UNUSED_FN /* nothing */ -#endif - -#ifdef __cplusplus -# ifndef _Bool - typedef bool _Bool; /* semi-hackish: C++ has no _Bool; bool is builtin */ -# endif -#endif - -/********** CPython-specific section **********/ -#ifndef PYPY_VERSION - - -#if PY_MAJOR_VERSION >= 3 -# define PyInt_FromLong PyLong_FromLong -#endif - -#define _cffi_from_c_double PyFloat_FromDouble -#define _cffi_from_c_float PyFloat_FromDouble -#define _cffi_from_c_long PyInt_FromLong -#define _cffi_from_c_ulong PyLong_FromUnsignedLong -#define _cffi_from_c_longlong PyLong_FromLongLong -#define _cffi_from_c_ulonglong PyLong_FromUnsignedLongLong -#define _cffi_from_c__Bool PyBool_FromLong - -#define _cffi_to_c_double PyFloat_AsDouble -#define _cffi_to_c_float PyFloat_AsDouble - -#define _cffi_from_c_int(x, type) \ - (((type)-1) > 0 ? /* unsigned */ \ - (sizeof(type) < sizeof(long) ? \ - PyInt_FromLong((long)x) : \ - sizeof(type) == sizeof(long) ? \ - PyLong_FromUnsignedLong((unsigned long)x) : \ - PyLong_FromUnsignedLongLong((unsigned long long)x)) : \ - (sizeof(type) <= sizeof(long) ? \ - PyInt_FromLong((long)x) : \ - PyLong_FromLongLong((long long)x))) - -#define _cffi_to_c_int(o, type) \ - ((type)( \ - sizeof(type) == 1 ? (((type)-1) > 0 ? (type)_cffi_to_c_u8(o) \ - : (type)_cffi_to_c_i8(o)) : \ - sizeof(type) == 2 ? (((type)-1) > 0 ? (type)_cffi_to_c_u16(o) \ - : (type)_cffi_to_c_i16(o)) : \ - sizeof(type) == 4 ? (((type)-1) > 0 ? (type)_cffi_to_c_u32(o) \ - : (type)_cffi_to_c_i32(o)) : \ - sizeof(type) == 8 ? (((type)-1) > 0 ? (type)_cffi_to_c_u64(o) \ - : (type)_cffi_to_c_i64(o)) : \ - (Py_FatalError("unsupported size for type " #type), (type)0))) - -#define _cffi_to_c_i8 \ - ((int(*)(PyObject *))_cffi_exports[1]) -#define _cffi_to_c_u8 \ - ((int(*)(PyObject *))_cffi_exports[2]) -#define _cffi_to_c_i16 \ - ((int(*)(PyObject *))_cffi_exports[3]) -#define _cffi_to_c_u16 \ - ((int(*)(PyObject *))_cffi_exports[4]) -#define _cffi_to_c_i32 \ - ((int(*)(PyObject *))_cffi_exports[5]) -#define _cffi_to_c_u32 \ - ((unsigned int(*)(PyObject *))_cffi_exports[6]) -#define _cffi_to_c_i64 \ - ((long long(*)(PyObject *))_cffi_exports[7]) -#define _cffi_to_c_u64 \ - ((unsigned long long(*)(PyObject *))_cffi_exports[8]) -#define _cffi_to_c_char \ - ((int(*)(PyObject *))_cffi_exports[9]) -#define _cffi_from_c_pointer \ - ((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[10]) -#define _cffi_to_c_pointer \ - ((char *(*)(PyObject *, struct _cffi_ctypedescr *))_cffi_exports[11]) -#define _cffi_get_struct_layout \ - not used any more -#define _cffi_restore_errno \ - ((void(*)(void))_cffi_exports[13]) -#define _cffi_save_errno \ - ((void(*)(void))_cffi_exports[14]) -#define _cffi_from_c_char \ - ((PyObject *(*)(char))_cffi_exports[15]) -#define _cffi_from_c_deref \ - ((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[16]) -#define _cffi_to_c \ - ((int(*)(char *, struct _cffi_ctypedescr *, PyObject *))_cffi_exports[17]) -#define _cffi_from_c_struct \ - ((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[18]) -#define _cffi_to_c_wchar_t \ - ((_cffi_wchar_t(*)(PyObject *))_cffi_exports[19]) -#define _cffi_from_c_wchar_t \ - ((PyObject *(*)(_cffi_wchar_t))_cffi_exports[20]) -#define _cffi_to_c_long_double \ - ((long double(*)(PyObject *))_cffi_exports[21]) -#define _cffi_to_c__Bool \ - ((_Bool(*)(PyObject *))_cffi_exports[22]) -#define _cffi_prepare_pointer_call_argument \ - ((Py_ssize_t(*)(struct _cffi_ctypedescr *, \ - PyObject *, char **))_cffi_exports[23]) -#define _cffi_convert_array_from_object \ - ((int(*)(char *, struct _cffi_ctypedescr *, PyObject *))_cffi_exports[24]) -#define _CFFI_CPIDX 25 -#define _cffi_call_python \ - ((void(*)(struct _cffi_externpy_s *, char *))_cffi_exports[_CFFI_CPIDX]) -#define _cffi_to_c_wchar3216_t \ - ((int(*)(PyObject *))_cffi_exports[26]) -#define _cffi_from_c_wchar3216_t \ - ((PyObject *(*)(int))_cffi_exports[27]) -#define _CFFI_NUM_EXPORTS 28 - -struct _cffi_ctypedescr; - -static void *_cffi_exports[_CFFI_NUM_EXPORTS]; - -#define _cffi_type(index) ( \ - assert((((uintptr_t)_cffi_types[index]) & 1) == 0), \ - (struct _cffi_ctypedescr *)_cffi_types[index]) - -static PyObject *_cffi_init(const char *module_name, Py_ssize_t version, - const struct _cffi_type_context_s *ctx) -{ - PyObject *module, *o_arg, *new_module; - void *raw[] = { - (void *)module_name, - (void *)version, - (void *)_cffi_exports, - (void *)ctx, - }; - - module = PyImport_ImportModule("_cffi_backend"); - if (module == NULL) - goto failure; - - o_arg = PyLong_FromVoidPtr((void *)raw); - if (o_arg == NULL) - goto failure; - - new_module = PyObject_CallMethod( - module, (char *)"_init_cffi_1_0_external_module", (char *)"O", o_arg); - - Py_DECREF(o_arg); - Py_DECREF(module); - return new_module; - - failure: - Py_XDECREF(module); - return NULL; -} - - -#ifdef HAVE_WCHAR_H -typedef wchar_t _cffi_wchar_t; -#else -typedef uint16_t _cffi_wchar_t; /* same random pick as _cffi_backend.c */ -#endif - -_CFFI_UNUSED_FN static uint16_t _cffi_to_c_char16_t(PyObject *o) -{ - if (sizeof(_cffi_wchar_t) == 2) - return (uint16_t)_cffi_to_c_wchar_t(o); - else - return (uint16_t)_cffi_to_c_wchar3216_t(o); -} - -_CFFI_UNUSED_FN static PyObject *_cffi_from_c_char16_t(uint16_t x) -{ - if (sizeof(_cffi_wchar_t) == 2) - return _cffi_from_c_wchar_t((_cffi_wchar_t)x); - else - return _cffi_from_c_wchar3216_t((int)x); -} - -_CFFI_UNUSED_FN static int _cffi_to_c_char32_t(PyObject *o) -{ - if (sizeof(_cffi_wchar_t) == 4) - return (int)_cffi_to_c_wchar_t(o); - else - return (int)_cffi_to_c_wchar3216_t(o); -} - -_CFFI_UNUSED_FN static PyObject *_cffi_from_c_char32_t(int x) -{ - if (sizeof(_cffi_wchar_t) == 4) - return _cffi_from_c_wchar_t((_cffi_wchar_t)x); - else - return _cffi_from_c_wchar3216_t(x); -} - - -/********** end CPython-specific section **********/ -#else -_CFFI_UNUSED_FN -static void (*_cffi_call_python_org)(struct _cffi_externpy_s *, char *); -# define _cffi_call_python _cffi_call_python_org -#endif - - -#define _cffi_array_len(array) (sizeof(array) / sizeof((array)[0])) - -#define _cffi_prim_int(size, sign) \ - ((size) == 1 ? ((sign) ? _CFFI_PRIM_INT8 : _CFFI_PRIM_UINT8) : \ - (size) == 2 ? ((sign) ? _CFFI_PRIM_INT16 : _CFFI_PRIM_UINT16) : \ - (size) == 4 ? ((sign) ? _CFFI_PRIM_INT32 : _CFFI_PRIM_UINT32) : \ - (size) == 8 ? ((sign) ? _CFFI_PRIM_INT64 : _CFFI_PRIM_UINT64) : \ - _CFFI__UNKNOWN_PRIM) - -#define _cffi_prim_float(size) \ - ((size) == sizeof(float) ? _CFFI_PRIM_FLOAT : \ - (size) == sizeof(double) ? _CFFI_PRIM_DOUBLE : \ - (size) == sizeof(long double) ? _CFFI__UNKNOWN_LONG_DOUBLE : \ - _CFFI__UNKNOWN_FLOAT_PRIM) - -#define _cffi_check_int(got, got_nonpos, expected) \ - ((got_nonpos) == (expected <= 0) && \ - (got) == (unsigned long long)expected) - -#ifdef MS_WIN32 -# define _cffi_stdcall __stdcall -#else -# define _cffi_stdcall /* nothing */ -#endif - -#ifdef __cplusplus -} -#endif - -/************************************************************/ - -/****************************************************************************** - * Code generated with sympy 1.1.1 * - * * - * See http://www.sympy.org/ for more information. * - * * - * This file is part of 'ekf' * - ******************************************************************************/ -void err_fun(double *nom_x, double *delta_x, double *out_3826149132230839283) { - out_3826149132230839283[0] = delta_x[0] + nom_x[0]; - out_3826149132230839283[1] = delta_x[1] + nom_x[1]; - out_3826149132230839283[2] = delta_x[2] + nom_x[2]; - out_3826149132230839283[3] = delta_x[3] + nom_x[3]; - out_3826149132230839283[4] = delta_x[4] + nom_x[4]; - out_3826149132230839283[5] = delta_x[5] + nom_x[5]; - out_3826149132230839283[6] = delta_x[6] + nom_x[6]; - out_3826149132230839283[7] = delta_x[7] + nom_x[7]; - out_3826149132230839283[8] = delta_x[8] + nom_x[8]; - out_3826149132230839283[9] = delta_x[9] + nom_x[9]; - out_3826149132230839283[10] = delta_x[10] + nom_x[10]; - out_3826149132230839283[11] = delta_x[11] + nom_x[11]; - out_3826149132230839283[12] = delta_x[12] + nom_x[12]; -} -void inv_err_fun(double *nom_x, double *true_x, double *out_8151328542980574746) { - out_8151328542980574746[0] = -nom_x[0] + true_x[0]; - out_8151328542980574746[1] = -nom_x[1] + true_x[1]; - out_8151328542980574746[2] = -nom_x[2] + true_x[2]; - out_8151328542980574746[3] = -nom_x[3] + true_x[3]; - out_8151328542980574746[4] = -nom_x[4] + true_x[4]; - out_8151328542980574746[5] = -nom_x[5] + true_x[5]; - out_8151328542980574746[6] = -nom_x[6] + true_x[6]; - out_8151328542980574746[7] = -nom_x[7] + true_x[7]; - out_8151328542980574746[8] = -nom_x[8] + true_x[8]; - out_8151328542980574746[9] = -nom_x[9] + true_x[9]; - out_8151328542980574746[10] = -nom_x[10] + true_x[10]; - out_8151328542980574746[11] = -nom_x[11] + true_x[11]; - out_8151328542980574746[12] = -nom_x[12] + true_x[12]; -} -void H_mod_fun(double *state, double *out_5655986027143292857) { - out_5655986027143292857[0] = 1.0; - out_5655986027143292857[1] = 0.0; - out_5655986027143292857[2] = 0.0; - out_5655986027143292857[3] = 0.0; - out_5655986027143292857[4] = 0.0; - out_5655986027143292857[5] = 0.0; - out_5655986027143292857[6] = 0.0; - out_5655986027143292857[7] = 0.0; - out_5655986027143292857[8] = 0.0; - out_5655986027143292857[9] = 0.0; - out_5655986027143292857[10] = 0.0; - out_5655986027143292857[11] = 0.0; - out_5655986027143292857[12] = 0.0; - out_5655986027143292857[13] = 0.0; - out_5655986027143292857[14] = 1.0; - out_5655986027143292857[15] = 0.0; - out_5655986027143292857[16] = 0.0; - out_5655986027143292857[17] = 0.0; - out_5655986027143292857[18] = 0.0; - out_5655986027143292857[19] = 0.0; - out_5655986027143292857[20] = 0.0; - out_5655986027143292857[21] = 0.0; - out_5655986027143292857[22] = 0.0; - out_5655986027143292857[23] = 0.0; - out_5655986027143292857[24] = 0.0; - out_5655986027143292857[25] = 0.0; - out_5655986027143292857[26] = 0.0; - out_5655986027143292857[27] = 0.0; - out_5655986027143292857[28] = 1.0; - out_5655986027143292857[29] = 0.0; - out_5655986027143292857[30] = 0.0; - out_5655986027143292857[31] = 0.0; - out_5655986027143292857[32] = 0.0; - out_5655986027143292857[33] = 0.0; - out_5655986027143292857[34] = 0.0; - out_5655986027143292857[35] = 0.0; - out_5655986027143292857[36] = 0.0; - out_5655986027143292857[37] = 0.0; - out_5655986027143292857[38] = 0.0; - out_5655986027143292857[39] = 0.0; - out_5655986027143292857[40] = 0.0; - out_5655986027143292857[41] = 0.0; - out_5655986027143292857[42] = 1.0; - out_5655986027143292857[43] = 0.0; - out_5655986027143292857[44] = 0.0; - out_5655986027143292857[45] = 0.0; - out_5655986027143292857[46] = 0.0; - out_5655986027143292857[47] = 0.0; - out_5655986027143292857[48] = 0.0; - out_5655986027143292857[49] = 0.0; - out_5655986027143292857[50] = 0.0; - out_5655986027143292857[51] = 0.0; - out_5655986027143292857[52] = 0.0; - out_5655986027143292857[53] = 0.0; - out_5655986027143292857[54] = 0.0; - out_5655986027143292857[55] = 0.0; - out_5655986027143292857[56] = 1.0; - out_5655986027143292857[57] = 0.0; - out_5655986027143292857[58] = 0.0; - out_5655986027143292857[59] = 0.0; - out_5655986027143292857[60] = 0.0; - out_5655986027143292857[61] = 0.0; - out_5655986027143292857[62] = 0.0; - out_5655986027143292857[63] = 0.0; - out_5655986027143292857[64] = 0.0; - out_5655986027143292857[65] = 0.0; - out_5655986027143292857[66] = 0.0; - out_5655986027143292857[67] = 0.0; - out_5655986027143292857[68] = 0.0; - out_5655986027143292857[69] = 0.0; - out_5655986027143292857[70] = 1.0; - out_5655986027143292857[71] = 0.0; - out_5655986027143292857[72] = 0.0; - out_5655986027143292857[73] = 0.0; - out_5655986027143292857[74] = 0.0; - out_5655986027143292857[75] = 0.0; - out_5655986027143292857[76] = 0.0; - out_5655986027143292857[77] = 0.0; - out_5655986027143292857[78] = 0.0; - out_5655986027143292857[79] = 0.0; - out_5655986027143292857[80] = 0.0; - out_5655986027143292857[81] = 0.0; - out_5655986027143292857[82] = 0.0; - out_5655986027143292857[83] = 0.0; - out_5655986027143292857[84] = 1.0; - out_5655986027143292857[85] = 0.0; - out_5655986027143292857[86] = 0.0; - out_5655986027143292857[87] = 0.0; - out_5655986027143292857[88] = 0.0; - out_5655986027143292857[89] = 0.0; - out_5655986027143292857[90] = 0.0; - out_5655986027143292857[91] = 0.0; - out_5655986027143292857[92] = 0.0; - out_5655986027143292857[93] = 0.0; - out_5655986027143292857[94] = 0.0; - out_5655986027143292857[95] = 0.0; - out_5655986027143292857[96] = 0.0; - out_5655986027143292857[97] = 0.0; - out_5655986027143292857[98] = 1.0; - out_5655986027143292857[99] = 0.0; - out_5655986027143292857[100] = 0.0; - out_5655986027143292857[101] = 0.0; - out_5655986027143292857[102] = 0.0; - out_5655986027143292857[103] = 0.0; - out_5655986027143292857[104] = 0.0; - out_5655986027143292857[105] = 0.0; - out_5655986027143292857[106] = 0.0; - out_5655986027143292857[107] = 0.0; - out_5655986027143292857[108] = 0.0; - out_5655986027143292857[109] = 0.0; - out_5655986027143292857[110] = 0.0; - out_5655986027143292857[111] = 0.0; - out_5655986027143292857[112] = 1.0; - out_5655986027143292857[113] = 0.0; - out_5655986027143292857[114] = 0.0; - out_5655986027143292857[115] = 0.0; - out_5655986027143292857[116] = 0.0; - out_5655986027143292857[117] = 0.0; - out_5655986027143292857[118] = 0.0; - out_5655986027143292857[119] = 0.0; - out_5655986027143292857[120] = 0.0; - out_5655986027143292857[121] = 0.0; - out_5655986027143292857[122] = 0.0; - out_5655986027143292857[123] = 0.0; - out_5655986027143292857[124] = 0.0; - out_5655986027143292857[125] = 0.0; - out_5655986027143292857[126] = 1.0; - out_5655986027143292857[127] = 0.0; - out_5655986027143292857[128] = 0.0; - out_5655986027143292857[129] = 0.0; - out_5655986027143292857[130] = 0.0; - out_5655986027143292857[131] = 0.0; - out_5655986027143292857[132] = 0.0; - out_5655986027143292857[133] = 0.0; - out_5655986027143292857[134] = 0.0; - out_5655986027143292857[135] = 0.0; - out_5655986027143292857[136] = 0.0; - out_5655986027143292857[137] = 0.0; - out_5655986027143292857[138] = 0.0; - out_5655986027143292857[139] = 0.0; - out_5655986027143292857[140] = 1.0; - out_5655986027143292857[141] = 0.0; - out_5655986027143292857[142] = 0.0; - out_5655986027143292857[143] = 0.0; - out_5655986027143292857[144] = 0.0; - out_5655986027143292857[145] = 0.0; - out_5655986027143292857[146] = 0.0; - out_5655986027143292857[147] = 0.0; - out_5655986027143292857[148] = 0.0; - out_5655986027143292857[149] = 0.0; - out_5655986027143292857[150] = 0.0; - out_5655986027143292857[151] = 0.0; - out_5655986027143292857[152] = 0.0; - out_5655986027143292857[153] = 0.0; - out_5655986027143292857[154] = 1.0; - out_5655986027143292857[155] = 0.0; - out_5655986027143292857[156] = 0.0; - out_5655986027143292857[157] = 0.0; - out_5655986027143292857[158] = 0.0; - out_5655986027143292857[159] = 0.0; - out_5655986027143292857[160] = 0.0; - out_5655986027143292857[161] = 0.0; - out_5655986027143292857[162] = 0.0; - out_5655986027143292857[163] = 0.0; - out_5655986027143292857[164] = 0.0; - out_5655986027143292857[165] = 0.0; - out_5655986027143292857[166] = 0.0; - out_5655986027143292857[167] = 0.0; - out_5655986027143292857[168] = 1.0; -} -void f_fun(double *state, double dt, double *out_2426912954331896736) { - out_2426912954331896736[0] = dt*state[10] + state[0]; - out_2426912954331896736[1] = dt*state[11] + state[1]; - out_2426912954331896736[2] = dt*state[12] + state[2]; - out_2426912954331896736[3] = state[3]; - out_2426912954331896736[4] = state[4]; - out_2426912954331896736[5] = state[5]; - out_2426912954331896736[6] = state[6]; - out_2426912954331896736[7] = state[7]; - out_2426912954331896736[8] = state[8]; - out_2426912954331896736[9] = state[9]; - out_2426912954331896736[10] = state[10]; - out_2426912954331896736[11] = state[11]; - out_2426912954331896736[12] = state[12]; -} -void F_fun(double *state, double dt, double *out_1828163745478812813) { - out_1828163745478812813[0] = 1; - out_1828163745478812813[1] = 0; - out_1828163745478812813[2] = 0; - out_1828163745478812813[3] = 0; - out_1828163745478812813[4] = 0; - out_1828163745478812813[5] = 0; - out_1828163745478812813[6] = 0; - out_1828163745478812813[7] = 0; - out_1828163745478812813[8] = 0; - out_1828163745478812813[9] = 0; - out_1828163745478812813[10] = dt; - out_1828163745478812813[11] = 0; - out_1828163745478812813[12] = 0; - out_1828163745478812813[13] = 0; - out_1828163745478812813[14] = 1; - out_1828163745478812813[15] = 0; - out_1828163745478812813[16] = 0; - out_1828163745478812813[17] = 0; - out_1828163745478812813[18] = 0; - out_1828163745478812813[19] = 0; - out_1828163745478812813[20] = 0; - out_1828163745478812813[21] = 0; - out_1828163745478812813[22] = 0; - out_1828163745478812813[23] = 0; - out_1828163745478812813[24] = dt; - out_1828163745478812813[25] = 0; - out_1828163745478812813[26] = 0; - out_1828163745478812813[27] = 0; - out_1828163745478812813[28] = 1; - out_1828163745478812813[29] = 0; - out_1828163745478812813[30] = 0; - out_1828163745478812813[31] = 0; - out_1828163745478812813[32] = 0; - out_1828163745478812813[33] = 0; - out_1828163745478812813[34] = 0; - out_1828163745478812813[35] = 0; - out_1828163745478812813[36] = 0; - out_1828163745478812813[37] = 0; - out_1828163745478812813[38] = dt; - out_1828163745478812813[39] = 0; - out_1828163745478812813[40] = 0; - out_1828163745478812813[41] = 0; - out_1828163745478812813[42] = 1; - out_1828163745478812813[43] = 0; - out_1828163745478812813[44] = 0; - out_1828163745478812813[45] = 0; - out_1828163745478812813[46] = 0; - out_1828163745478812813[47] = 0; - out_1828163745478812813[48] = 0; - out_1828163745478812813[49] = 0; - out_1828163745478812813[50] = 0; - out_1828163745478812813[51] = 0; - out_1828163745478812813[52] = 0; - out_1828163745478812813[53] = 0; - out_1828163745478812813[54] = 0; - out_1828163745478812813[55] = 0; - out_1828163745478812813[56] = 1; - out_1828163745478812813[57] = 0; - out_1828163745478812813[58] = 0; - out_1828163745478812813[59] = 0; - out_1828163745478812813[60] = 0; - out_1828163745478812813[61] = 0; - out_1828163745478812813[62] = 0; - out_1828163745478812813[63] = 0; - out_1828163745478812813[64] = 0; - out_1828163745478812813[65] = 0; - out_1828163745478812813[66] = 0; - out_1828163745478812813[67] = 0; - out_1828163745478812813[68] = 0; - out_1828163745478812813[69] = 0; - out_1828163745478812813[70] = 1; - out_1828163745478812813[71] = 0; - out_1828163745478812813[72] = 0; - out_1828163745478812813[73] = 0; - out_1828163745478812813[74] = 0; - out_1828163745478812813[75] = 0; - out_1828163745478812813[76] = 0; - out_1828163745478812813[77] = 0; - out_1828163745478812813[78] = 0; - out_1828163745478812813[79] = 0; - out_1828163745478812813[80] = 0; - out_1828163745478812813[81] = 0; - out_1828163745478812813[82] = 0; - out_1828163745478812813[83] = 0; - out_1828163745478812813[84] = 1; - out_1828163745478812813[85] = 0; - out_1828163745478812813[86] = 0; - out_1828163745478812813[87] = 0; - out_1828163745478812813[88] = 0; - out_1828163745478812813[89] = 0; - out_1828163745478812813[90] = 0; - out_1828163745478812813[91] = 0; - out_1828163745478812813[92] = 0; - out_1828163745478812813[93] = 0; - out_1828163745478812813[94] = 0; - out_1828163745478812813[95] = 0; - out_1828163745478812813[96] = 0; - out_1828163745478812813[97] = 0; - out_1828163745478812813[98] = 1; - out_1828163745478812813[99] = 0; - out_1828163745478812813[100] = 0; - out_1828163745478812813[101] = 0; - out_1828163745478812813[102] = 0; - out_1828163745478812813[103] = 0; - out_1828163745478812813[104] = 0; - out_1828163745478812813[105] = 0; - out_1828163745478812813[106] = 0; - out_1828163745478812813[107] = 0; - out_1828163745478812813[108] = 0; - out_1828163745478812813[109] = 0; - out_1828163745478812813[110] = 0; - out_1828163745478812813[111] = 0; - out_1828163745478812813[112] = 1; - out_1828163745478812813[113] = 0; - out_1828163745478812813[114] = 0; - out_1828163745478812813[115] = 0; - out_1828163745478812813[116] = 0; - out_1828163745478812813[117] = 0; - out_1828163745478812813[118] = 0; - out_1828163745478812813[119] = 0; - out_1828163745478812813[120] = 0; - out_1828163745478812813[121] = 0; - out_1828163745478812813[122] = 0; - out_1828163745478812813[123] = 0; - out_1828163745478812813[124] = 0; - out_1828163745478812813[125] = 0; - out_1828163745478812813[126] = 1; - out_1828163745478812813[127] = 0; - out_1828163745478812813[128] = 0; - out_1828163745478812813[129] = 0; - out_1828163745478812813[130] = 0; - out_1828163745478812813[131] = 0; - out_1828163745478812813[132] = 0; - out_1828163745478812813[133] = 0; - out_1828163745478812813[134] = 0; - out_1828163745478812813[135] = 0; - out_1828163745478812813[136] = 0; - out_1828163745478812813[137] = 0; - out_1828163745478812813[138] = 0; - out_1828163745478812813[139] = 0; - out_1828163745478812813[140] = 1; - out_1828163745478812813[141] = 0; - out_1828163745478812813[142] = 0; - out_1828163745478812813[143] = 0; - out_1828163745478812813[144] = 0; - out_1828163745478812813[145] = 0; - out_1828163745478812813[146] = 0; - out_1828163745478812813[147] = 0; - out_1828163745478812813[148] = 0; - out_1828163745478812813[149] = 0; - out_1828163745478812813[150] = 0; - out_1828163745478812813[151] = 0; - out_1828163745478812813[152] = 0; - out_1828163745478812813[153] = 0; - out_1828163745478812813[154] = 1; - out_1828163745478812813[155] = 0; - out_1828163745478812813[156] = 0; - out_1828163745478812813[157] = 0; - out_1828163745478812813[158] = 0; - out_1828163745478812813[159] = 0; - out_1828163745478812813[160] = 0; - out_1828163745478812813[161] = 0; - out_1828163745478812813[162] = 0; - out_1828163745478812813[163] = 0; - out_1828163745478812813[164] = 0; - out_1828163745478812813[165] = 0; - out_1828163745478812813[166] = 0; - out_1828163745478812813[167] = 0; - out_1828163745478812813[168] = 1; -} -void h_3(double *state, double *unused, double *out_4528959146572613286) { - out_4528959146572613286[0] = sqrt(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2))*state[9]; -} -void H_3(double *state, double *unused, double *out_4776213603435969308) { - out_4776213603435969308[0] = state[0]*state[9]/sqrt(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2)); - out_4776213603435969308[1] = state[1]*state[9]/sqrt(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2)); - out_4776213603435969308[2] = state[2]*state[9]/sqrt(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2)); - out_4776213603435969308[3] = 0; - out_4776213603435969308[4] = 0; - out_4776213603435969308[5] = 0; - out_4776213603435969308[6] = 0; - out_4776213603435969308[7] = 0; - out_4776213603435969308[8] = 0; - out_4776213603435969308[9] = sqrt(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2)); - out_4776213603435969308[10] = 0; - out_4776213603435969308[11] = 0; - out_4776213603435969308[12] = 0; -} -void h_4(double *state, double *unused, double *out_7897607812907042004) { - out_7897607812907042004[0] = state[3] + state[6]; - out_7897607812907042004[1] = state[4] + state[7]; - out_7897607812907042004[2] = state[5] + state[8]; -} -void H_4(double *state, double *unused, double *out_7822787049155785962) { - out_7822787049155785962[0] = 0; - out_7822787049155785962[1] = 0; - out_7822787049155785962[2] = 0; - out_7822787049155785962[3] = 1; - out_7822787049155785962[4] = 0; - out_7822787049155785962[5] = 0; - out_7822787049155785962[6] = 1; - out_7822787049155785962[7] = 0; - out_7822787049155785962[8] = 0; - out_7822787049155785962[9] = 0; - out_7822787049155785962[10] = 0; - out_7822787049155785962[11] = 0; - out_7822787049155785962[12] = 0; - out_7822787049155785962[13] = 0; - out_7822787049155785962[14] = 0; - out_7822787049155785962[15] = 0; - out_7822787049155785962[16] = 0; - out_7822787049155785962[17] = 1; - out_7822787049155785962[18] = 0; - out_7822787049155785962[19] = 0; - out_7822787049155785962[20] = 1; - out_7822787049155785962[21] = 0; - out_7822787049155785962[22] = 0; - out_7822787049155785962[23] = 0; - out_7822787049155785962[24] = 0; - out_7822787049155785962[25] = 0; - out_7822787049155785962[26] = 0; - out_7822787049155785962[27] = 0; - out_7822787049155785962[28] = 0; - out_7822787049155785962[29] = 0; - out_7822787049155785962[30] = 0; - out_7822787049155785962[31] = 1; - out_7822787049155785962[32] = 0; - out_7822787049155785962[33] = 0; - out_7822787049155785962[34] = 1; - out_7822787049155785962[35] = 0; - out_7822787049155785962[36] = 0; - out_7822787049155785962[37] = 0; - out_7822787049155785962[38] = 0; -} -void h_9(double *state, double *unused, double *out_5299392560341573238) { - out_5299392560341573238[0] = state[3]; - out_5299392560341573238[1] = state[4]; - out_5299392560341573238[2] = state[5]; -} -void H_9(double *state, double *unused, double *out_2816358492518891651) { - out_2816358492518891651[0] = 0; - out_2816358492518891651[1] = 0; - out_2816358492518891651[2] = 0; - out_2816358492518891651[3] = 1; - out_2816358492518891651[4] = 0; - out_2816358492518891651[5] = 0; - out_2816358492518891651[6] = 0; - out_2816358492518891651[7] = 0; - out_2816358492518891651[8] = 0; - out_2816358492518891651[9] = 0; - out_2816358492518891651[10] = 0; - out_2816358492518891651[11] = 0; - out_2816358492518891651[12] = 0; - out_2816358492518891651[13] = 0; - out_2816358492518891651[14] = 0; - out_2816358492518891651[15] = 0; - out_2816358492518891651[16] = 0; - out_2816358492518891651[17] = 1; - out_2816358492518891651[18] = 0; - out_2816358492518891651[19] = 0; - out_2816358492518891651[20] = 0; - out_2816358492518891651[21] = 0; - out_2816358492518891651[22] = 0; - out_2816358492518891651[23] = 0; - out_2816358492518891651[24] = 0; - out_2816358492518891651[25] = 0; - out_2816358492518891651[26] = 0; - out_2816358492518891651[27] = 0; - out_2816358492518891651[28] = 0; - out_2816358492518891651[29] = 0; - out_2816358492518891651[30] = 0; - out_2816358492518891651[31] = 1; - out_2816358492518891651[32] = 0; - out_2816358492518891651[33] = 0; - out_2816358492518891651[34] = 0; - out_2816358492518891651[35] = 0; - out_2816358492518891651[36] = 0; - out_2816358492518891651[37] = 0; - out_2816358492518891651[38] = 0; -} -void h_13(double *state, double *unused, double *out_4549566257314944719) { - out_4549566257314944719[0] = state[0]; - out_4549566257314944719[1] = state[1]; - out_4549566257314944719[2] = state[2]; -} -void H_13(double *state, double *unused, double *out_3504968933202572761) { - out_3504968933202572761[0] = 1; - out_3504968933202572761[1] = 0; - out_3504968933202572761[2] = 0; - out_3504968933202572761[3] = 0; - out_3504968933202572761[4] = 0; - out_3504968933202572761[5] = 0; - out_3504968933202572761[6] = 0; - out_3504968933202572761[7] = 0; - out_3504968933202572761[8] = 0; - out_3504968933202572761[9] = 0; - out_3504968933202572761[10] = 0; - out_3504968933202572761[11] = 0; - out_3504968933202572761[12] = 0; - out_3504968933202572761[13] = 0; - out_3504968933202572761[14] = 1; - out_3504968933202572761[15] = 0; - out_3504968933202572761[16] = 0; - out_3504968933202572761[17] = 0; - out_3504968933202572761[18] = 0; - out_3504968933202572761[19] = 0; - out_3504968933202572761[20] = 0; - out_3504968933202572761[21] = 0; - out_3504968933202572761[22] = 0; - out_3504968933202572761[23] = 0; - out_3504968933202572761[24] = 0; - out_3504968933202572761[25] = 0; - out_3504968933202572761[26] = 0; - out_3504968933202572761[27] = 0; - out_3504968933202572761[28] = 1; - out_3504968933202572761[29] = 0; - out_3504968933202572761[30] = 0; - out_3504968933202572761[31] = 0; - out_3504968933202572761[32] = 0; - out_3504968933202572761[33] = 0; - out_3504968933202572761[34] = 0; - out_3504968933202572761[35] = 0; - out_3504968933202572761[36] = 0; - out_3504968933202572761[37] = 0; - out_3504968933202572761[38] = 0; -} -void h_14(double *state, double *unused, double *out_5299392560341573238) { - out_5299392560341573238[0] = state[3]; - out_5299392560341573238[1] = state[4]; - out_5299392560341573238[2] = state[5]; -} -void H_14(double *state, double *unused, double *out_2816358492518891651) { - out_2816358492518891651[0] = 0; - out_2816358492518891651[1] = 0; - out_2816358492518891651[2] = 0; - out_2816358492518891651[3] = 1; - out_2816358492518891651[4] = 0; - out_2816358492518891651[5] = 0; - out_2816358492518891651[6] = 0; - out_2816358492518891651[7] = 0; - out_2816358492518891651[8] = 0; - out_2816358492518891651[9] = 0; - out_2816358492518891651[10] = 0; - out_2816358492518891651[11] = 0; - out_2816358492518891651[12] = 0; - out_2816358492518891651[13] = 0; - out_2816358492518891651[14] = 0; - out_2816358492518891651[15] = 0; - out_2816358492518891651[16] = 0; - out_2816358492518891651[17] = 1; - out_2816358492518891651[18] = 0; - out_2816358492518891651[19] = 0; - out_2816358492518891651[20] = 0; - out_2816358492518891651[21] = 0; - out_2816358492518891651[22] = 0; - out_2816358492518891651[23] = 0; - out_2816358492518891651[24] = 0; - out_2816358492518891651[25] = 0; - out_2816358492518891651[26] = 0; - out_2816358492518891651[27] = 0; - out_2816358492518891651[28] = 0; - out_2816358492518891651[29] = 0; - out_2816358492518891651[30] = 0; - out_2816358492518891651[31] = 1; - out_2816358492518891651[32] = 0; - out_2816358492518891651[33] = 0; - out_2816358492518891651[34] = 0; - out_2816358492518891651[35] = 0; - out_2816358492518891651[36] = 0; - out_2816358492518891651[37] = 0; - out_2816358492518891651[38] = 0; -} -#define DIM 13 -#define EDIM 13 -#define MEDIM 13 -typedef void (*Hfun)(double *, double *, double *); - -void predict(double *x, double *P, double *Q, double dt); -const static double MAHA_THRESH_3 = 3.841459; -void update_3(double *, double *, double *, double *, double *); -const static double MAHA_THRESH_4 = 7.814728; -void update_4(double *, double *, double *, double *, double *); -const static double MAHA_THRESH_9 = 7.814728; -void update_9(double *, double *, double *, double *, double *); -const static double MAHA_THRESH_13 = 7.814728; -void update_13(double *, double *, double *, double *, double *); -const static double MAHA_THRESH_14 = 7.814728; -void update_14(double *, double *, double *, double *, double *); -#include -#include - -typedef Eigen::Matrix DDM; -typedef Eigen::Matrix EEM; -typedef Eigen::Matrix DEM; - -void predict(double *in_x, double *in_P, double *in_Q, double dt) { - typedef Eigen::Matrix RRM; - - double nx[DIM] = {0}; - double in_F[EDIM*EDIM] = {0}; - - // functions from sympy - f_fun(in_x, dt, nx); - F_fun(in_x, dt, in_F); - - - EEM F(in_F); - EEM P(in_P); - EEM Q(in_Q); - - RRM F_main = F.topLeftCorner(MEDIM, MEDIM); - P.topLeftCorner(MEDIM, MEDIM) = (F_main * P.topLeftCorner(MEDIM, MEDIM)) * F_main.transpose(); - P.topRightCorner(MEDIM, EDIM - MEDIM) = F_main * P.topRightCorner(MEDIM, EDIM - MEDIM); - P.bottomLeftCorner(EDIM - MEDIM, MEDIM) = P.bottomLeftCorner(EDIM - MEDIM, MEDIM) * F_main.transpose(); - - P = P + dt*Q; - - // copy out state - memcpy(in_x, nx, DIM * sizeof(double)); - memcpy(in_P, P.data(), EDIM * EDIM * sizeof(double)); -} - -// note: extra_args dim only correct when null space projecting -// otherwise 1 -template -void update(double *in_x, double *in_P, Hfun h_fun, Hfun H_fun, Hfun Hea_fun, double *in_z, double *in_R, double *in_ea, double MAHA_THRESHOLD) { - typedef Eigen::Matrix ZZM; - typedef Eigen::Matrix ZDM; - typedef Eigen::Matrix ZEM; - typedef Eigen::Matrix XEM; - typedef Eigen::Matrix EZM; - typedef Eigen::Matrix X1M; - typedef Eigen::Matrix XXM; - - double in_hx[ZDIM] = {0}; - double in_H[ZDIM * DIM] = {0}; - double in_H_mod[EDIM * DIM] = {0}; - double delta_x[EDIM] = {0}; - double x_new[DIM] = {0}; - - - // state x, P - Eigen::Matrix z(in_z); - EEM P(in_P); - ZZM pre_R(in_R); - - // functions from sympy - h_fun(in_x, in_ea, in_hx); - H_fun(in_x, in_ea, in_H); - ZDM pre_H(in_H); - - // get y (y = z - hx) - Eigen::Matrix pre_y(in_hx); pre_y = z - pre_y; - X1M y; XXM H; XXM R; - if (Hea_fun){ - typedef Eigen::Matrix ZAM; - double in_Hea[ZDIM * EADIM] = {0}; - Hea_fun(in_x, in_ea, in_Hea); - ZAM Hea(in_Hea); - XXM A = Hea.transpose().fullPivLu().kernel(); - - - y = A.transpose() * pre_y; - H = A.transpose() * pre_H; - R = A.transpose() * pre_R * A; - } else { - y = pre_y; - H = pre_H; - R = pre_R; - } - // get modified H - H_mod_fun(in_x, in_H_mod); - DEM H_mod(in_H_mod); - XEM H_err = H * H_mod; - - // Do mahalobis distance test - if (MAHA_TEST){ - XXM a = (H_err * P * H_err.transpose() + R).inverse(); - double maha_dist = y.transpose() * a * y; - if (maha_dist > MAHA_THRESHOLD){ - R = 1.0e16 * R; - } - } - - // Outlier resilient weighting - double weight = 1;//(1.5)/(1 + y.squaredNorm()/R.sum()); - - // kalman gains and I_KH - XXM S = ((H_err * P) * H_err.transpose()) + R/weight; - XEM KT = S.fullPivLu().solve(H_err * P.transpose()); - //EZM K = KT.transpose(); TODO: WHY DOES THIS NOT COMPILE? - //EZM K = S.fullPivLu().solve(H_err * P.transpose()).transpose(); - //std::cout << "Here is the matrix rot:\n" << K << std::endl; - EEM I_KH = Eigen::Matrix::Identity() - (KT.transpose() * H_err); - - // update state by injecting dx - Eigen::Matrix dx(delta_x); - dx = (KT.transpose() * y); - memcpy(delta_x, dx.data(), EDIM * sizeof(double)); - err_fun(in_x, delta_x, x_new); - Eigen::Matrix x(x_new); - - // update cov - P = ((I_KH * P) * I_KH.transpose()) + ((KT.transpose() * R) * KT); - - // copy out state - memcpy(in_x, x.data(), DIM * sizeof(double)); - memcpy(in_P, P.data(), EDIM * EDIM * sizeof(double)); - memcpy(in_z, y.data(), y.rows() * sizeof(double)); -} - - - - - void update_3(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) { - update<1,3,0>(in_x, in_P, h_3, H_3, NULL, in_z, in_R, in_ea, MAHA_THRESH_3); - } - - void update_4(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) { - update<3,3,0>(in_x, in_P, h_4, H_4, NULL, in_z, in_R, in_ea, MAHA_THRESH_4); - } - - void update_9(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) { - update<3,3,0>(in_x, in_P, h_9, H_9, NULL, in_z, in_R, in_ea, MAHA_THRESH_9); - } - - void update_13(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) { - update<3,3,0>(in_x, in_P, h_13, H_13, NULL, in_z, in_R, in_ea, MAHA_THRESH_13); - } - - void update_14(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) { - update<3,3,0>(in_x, in_P, h_14, H_14, NULL, in_z, in_R, in_ea, MAHA_THRESH_14); - } - - -/************************************************************/ - -static void *_cffi_types[] = { -/* 0 */ _CFFI_OP(_CFFI_OP_FUNCTION, 28), // void()(double *, double *) -/* 1 */ _CFFI_OP(_CFFI_OP_POINTER, 20), // double * -/* 2 */ _CFFI_OP(_CFFI_OP_NOOP, 1), -/* 3 */ _CFFI_OP(_CFFI_OP_FUNCTION_END, 0), -/* 4 */ _CFFI_OP(_CFFI_OP_FUNCTION, 28), // void()(double *, double *, double *) -/* 5 */ _CFFI_OP(_CFFI_OP_NOOP, 1), -/* 6 */ _CFFI_OP(_CFFI_OP_NOOP, 1), -/* 7 */ _CFFI_OP(_CFFI_OP_NOOP, 1), -/* 8 */ _CFFI_OP(_CFFI_OP_FUNCTION_END, 0), -/* 9 */ _CFFI_OP(_CFFI_OP_FUNCTION, 28), // void()(double *, double *, double *, double *, double *) -/* 10 */ _CFFI_OP(_CFFI_OP_NOOP, 1), -/* 11 */ _CFFI_OP(_CFFI_OP_NOOP, 1), -/* 12 */ _CFFI_OP(_CFFI_OP_NOOP, 1), -/* 13 */ _CFFI_OP(_CFFI_OP_NOOP, 1), -/* 14 */ _CFFI_OP(_CFFI_OP_NOOP, 1), -/* 15 */ _CFFI_OP(_CFFI_OP_FUNCTION_END, 0), -/* 16 */ _CFFI_OP(_CFFI_OP_FUNCTION, 28), // void()(double *, double *, double *, double) -/* 17 */ _CFFI_OP(_CFFI_OP_NOOP, 1), -/* 18 */ _CFFI_OP(_CFFI_OP_NOOP, 1), -/* 19 */ _CFFI_OP(_CFFI_OP_NOOP, 1), -/* 20 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 14), // double -/* 21 */ _CFFI_OP(_CFFI_OP_FUNCTION_END, 0), -/* 22 */ _CFFI_OP(_CFFI_OP_FUNCTION, 28), // void()(double *, double, double *) -/* 23 */ _CFFI_OP(_CFFI_OP_NOOP, 1), -/* 24 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 14), -/* 25 */ _CFFI_OP(_CFFI_OP_NOOP, 1), -/* 26 */ _CFFI_OP(_CFFI_OP_FUNCTION_END, 0), -/* 27 */ _CFFI_OP(_CFFI_OP_POINTER, 4), // void(*)(double *, double *, double *) -/* 28 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 0), // void -}; - -static void _cffi_const_MAHA_THRESH_13(char *o) -{ - *(double *)o = MAHA_THRESH_13; -} - -static void _cffi_const_MAHA_THRESH_14(char *o) -{ - *(double *)o = MAHA_THRESH_14; -} - -static void _cffi_const_MAHA_THRESH_3(char *o) -{ - *(double *)o = MAHA_THRESH_3; -} - -static void _cffi_const_MAHA_THRESH_4(char *o) -{ - *(double *)o = MAHA_THRESH_4; -} - -static void _cffi_const_MAHA_THRESH_9(char *o) -{ - *(double *)o = MAHA_THRESH_9; -} - -static void _cffi_d_F_fun(double * x0, double x1, double * x2) -{ - F_fun(x0, x1, x2); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_F_fun(PyObject *self, PyObject *args) -{ - double * x0; - double x1; - double * x2; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - PyObject *arg2; - - if (!PyArg_UnpackTuple(args, "F_fun", 3, 3, &arg0, &arg1, &arg2)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - x1 = (double)_cffi_to_c_double(arg1); - if (x1 == (double)-1 && PyErr_Occurred()) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg2, (char **)&x2); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x2 = (double *)alloca((size_t)datasize); - memset((void *)x2, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x2, _cffi_type(1), arg2) < 0) - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { F_fun(x0, x1, x2); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_F_fun _cffi_d_F_fun -#endif - -static void _cffi_d_H_13(double * x0, double * x1, double * x2) -{ - H_13(x0, x1, x2); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_H_13(PyObject *self, PyObject *args) -{ - double * x0; - double * x1; - double * x2; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - PyObject *arg2; - - if (!PyArg_UnpackTuple(args, "H_13", 3, 3, &arg0, &arg1, &arg2)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg1, (char **)&x1); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x1 = (double *)alloca((size_t)datasize); - memset((void *)x1, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x1, _cffi_type(1), arg1) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg2, (char **)&x2); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x2 = (double *)alloca((size_t)datasize); - memset((void *)x2, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x2, _cffi_type(1), arg2) < 0) - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { H_13(x0, x1, x2); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_H_13 _cffi_d_H_13 -#endif - -static void _cffi_d_H_14(double * x0, double * x1, double * x2) -{ - H_14(x0, x1, x2); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_H_14(PyObject *self, PyObject *args) -{ - double * x0; - double * x1; - double * x2; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - PyObject *arg2; - - if (!PyArg_UnpackTuple(args, "H_14", 3, 3, &arg0, &arg1, &arg2)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg1, (char **)&x1); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x1 = (double *)alloca((size_t)datasize); - memset((void *)x1, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x1, _cffi_type(1), arg1) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg2, (char **)&x2); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x2 = (double *)alloca((size_t)datasize); - memset((void *)x2, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x2, _cffi_type(1), arg2) < 0) - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { H_14(x0, x1, x2); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_H_14 _cffi_d_H_14 -#endif - -static void _cffi_d_H_3(double * x0, double * x1, double * x2) -{ - H_3(x0, x1, x2); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_H_3(PyObject *self, PyObject *args) -{ - double * x0; - double * x1; - double * x2; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - PyObject *arg2; - - if (!PyArg_UnpackTuple(args, "H_3", 3, 3, &arg0, &arg1, &arg2)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg1, (char **)&x1); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x1 = (double *)alloca((size_t)datasize); - memset((void *)x1, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x1, _cffi_type(1), arg1) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg2, (char **)&x2); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x2 = (double *)alloca((size_t)datasize); - memset((void *)x2, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x2, _cffi_type(1), arg2) < 0) - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { H_3(x0, x1, x2); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_H_3 _cffi_d_H_3 -#endif - -static void _cffi_d_H_4(double * x0, double * x1, double * x2) -{ - H_4(x0, x1, x2); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_H_4(PyObject *self, PyObject *args) -{ - double * x0; - double * x1; - double * x2; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - PyObject *arg2; - - if (!PyArg_UnpackTuple(args, "H_4", 3, 3, &arg0, &arg1, &arg2)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg1, (char **)&x1); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x1 = (double *)alloca((size_t)datasize); - memset((void *)x1, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x1, _cffi_type(1), arg1) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg2, (char **)&x2); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x2 = (double *)alloca((size_t)datasize); - memset((void *)x2, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x2, _cffi_type(1), arg2) < 0) - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { H_4(x0, x1, x2); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_H_4 _cffi_d_H_4 -#endif - -static void _cffi_d_H_9(double * x0, double * x1, double * x2) -{ - H_9(x0, x1, x2); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_H_9(PyObject *self, PyObject *args) -{ - double * x0; - double * x1; - double * x2; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - PyObject *arg2; - - if (!PyArg_UnpackTuple(args, "H_9", 3, 3, &arg0, &arg1, &arg2)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg1, (char **)&x1); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x1 = (double *)alloca((size_t)datasize); - memset((void *)x1, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x1, _cffi_type(1), arg1) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg2, (char **)&x2); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x2 = (double *)alloca((size_t)datasize); - memset((void *)x2, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x2, _cffi_type(1), arg2) < 0) - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { H_9(x0, x1, x2); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_H_9 _cffi_d_H_9 -#endif - -static void _cffi_d_H_mod_fun(double * x0, double * x1) -{ - H_mod_fun(x0, x1); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_H_mod_fun(PyObject *self, PyObject *args) -{ - double * x0; - double * x1; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - - if (!PyArg_UnpackTuple(args, "H_mod_fun", 2, 2, &arg0, &arg1)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg1, (char **)&x1); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x1 = (double *)alloca((size_t)datasize); - memset((void *)x1, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x1, _cffi_type(1), arg1) < 0) - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { H_mod_fun(x0, x1); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_H_mod_fun _cffi_d_H_mod_fun -#endif - -static void _cffi_d_err_fun(double * x0, double * x1, double * x2) -{ - err_fun(x0, x1, x2); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_err_fun(PyObject *self, PyObject *args) -{ - double * x0; - double * x1; - double * x2; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - PyObject *arg2; - - if (!PyArg_UnpackTuple(args, "err_fun", 3, 3, &arg0, &arg1, &arg2)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg1, (char **)&x1); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x1 = (double *)alloca((size_t)datasize); - memset((void *)x1, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x1, _cffi_type(1), arg1) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg2, (char **)&x2); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x2 = (double *)alloca((size_t)datasize); - memset((void *)x2, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x2, _cffi_type(1), arg2) < 0) - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { err_fun(x0, x1, x2); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_err_fun _cffi_d_err_fun -#endif - -static void _cffi_d_f_fun(double * x0, double x1, double * x2) -{ - f_fun(x0, x1, x2); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_f_fun(PyObject *self, PyObject *args) -{ - double * x0; - double x1; - double * x2; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - PyObject *arg2; - - if (!PyArg_UnpackTuple(args, "f_fun", 3, 3, &arg0, &arg1, &arg2)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - x1 = (double)_cffi_to_c_double(arg1); - if (x1 == (double)-1 && PyErr_Occurred()) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg2, (char **)&x2); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x2 = (double *)alloca((size_t)datasize); - memset((void *)x2, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x2, _cffi_type(1), arg2) < 0) - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { f_fun(x0, x1, x2); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_f_fun _cffi_d_f_fun -#endif - -static void _cffi_d_h_13(double * x0, double * x1, double * x2) -{ - h_13(x0, x1, x2); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_h_13(PyObject *self, PyObject *args) -{ - double * x0; - double * x1; - double * x2; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - PyObject *arg2; - - if (!PyArg_UnpackTuple(args, "h_13", 3, 3, &arg0, &arg1, &arg2)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg1, (char **)&x1); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x1 = (double *)alloca((size_t)datasize); - memset((void *)x1, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x1, _cffi_type(1), arg1) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg2, (char **)&x2); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x2 = (double *)alloca((size_t)datasize); - memset((void *)x2, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x2, _cffi_type(1), arg2) < 0) - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { h_13(x0, x1, x2); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_h_13 _cffi_d_h_13 -#endif - -static void _cffi_d_h_14(double * x0, double * x1, double * x2) -{ - h_14(x0, x1, x2); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_h_14(PyObject *self, PyObject *args) -{ - double * x0; - double * x1; - double * x2; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - PyObject *arg2; - - if (!PyArg_UnpackTuple(args, "h_14", 3, 3, &arg0, &arg1, &arg2)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg1, (char **)&x1); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x1 = (double *)alloca((size_t)datasize); - memset((void *)x1, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x1, _cffi_type(1), arg1) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg2, (char **)&x2); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x2 = (double *)alloca((size_t)datasize); - memset((void *)x2, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x2, _cffi_type(1), arg2) < 0) - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { h_14(x0, x1, x2); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_h_14 _cffi_d_h_14 -#endif - -static void _cffi_d_h_3(double * x0, double * x1, double * x2) -{ - h_3(x0, x1, x2); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_h_3(PyObject *self, PyObject *args) -{ - double * x0; - double * x1; - double * x2; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - PyObject *arg2; - - if (!PyArg_UnpackTuple(args, "h_3", 3, 3, &arg0, &arg1, &arg2)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg1, (char **)&x1); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x1 = (double *)alloca((size_t)datasize); - memset((void *)x1, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x1, _cffi_type(1), arg1) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg2, (char **)&x2); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x2 = (double *)alloca((size_t)datasize); - memset((void *)x2, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x2, _cffi_type(1), arg2) < 0) - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { h_3(x0, x1, x2); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_h_3 _cffi_d_h_3 -#endif - -static void _cffi_d_h_4(double * x0, double * x1, double * x2) -{ - h_4(x0, x1, x2); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_h_4(PyObject *self, PyObject *args) -{ - double * x0; - double * x1; - double * x2; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - PyObject *arg2; - - if (!PyArg_UnpackTuple(args, "h_4", 3, 3, &arg0, &arg1, &arg2)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg1, (char **)&x1); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x1 = (double *)alloca((size_t)datasize); - memset((void *)x1, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x1, _cffi_type(1), arg1) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg2, (char **)&x2); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x2 = (double *)alloca((size_t)datasize); - memset((void *)x2, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x2, _cffi_type(1), arg2) < 0) - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { h_4(x0, x1, x2); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_h_4 _cffi_d_h_4 -#endif - -static void _cffi_d_h_9(double * x0, double * x1, double * x2) -{ - h_9(x0, x1, x2); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_h_9(PyObject *self, PyObject *args) -{ - double * x0; - double * x1; - double * x2; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - PyObject *arg2; - - if (!PyArg_UnpackTuple(args, "h_9", 3, 3, &arg0, &arg1, &arg2)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg1, (char **)&x1); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x1 = (double *)alloca((size_t)datasize); - memset((void *)x1, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x1, _cffi_type(1), arg1) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg2, (char **)&x2); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x2 = (double *)alloca((size_t)datasize); - memset((void *)x2, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x2, _cffi_type(1), arg2) < 0) - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { h_9(x0, x1, x2); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_h_9 _cffi_d_h_9 -#endif - -static void _cffi_d_inv_err_fun(double * x0, double * x1, double * x2) -{ - inv_err_fun(x0, x1, x2); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_inv_err_fun(PyObject *self, PyObject *args) -{ - double * x0; - double * x1; - double * x2; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - PyObject *arg2; - - if (!PyArg_UnpackTuple(args, "inv_err_fun", 3, 3, &arg0, &arg1, &arg2)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg1, (char **)&x1); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x1 = (double *)alloca((size_t)datasize); - memset((void *)x1, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x1, _cffi_type(1), arg1) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg2, (char **)&x2); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x2 = (double *)alloca((size_t)datasize); - memset((void *)x2, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x2, _cffi_type(1), arg2) < 0) - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { inv_err_fun(x0, x1, x2); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_inv_err_fun _cffi_d_inv_err_fun -#endif - -static void _cffi_d_predict(double * x0, double * x1, double * x2, double x3) -{ - predict(x0, x1, x2, x3); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_predict(PyObject *self, PyObject *args) -{ - double * x0; - double * x1; - double * x2; - double x3; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - PyObject *arg2; - PyObject *arg3; - - if (!PyArg_UnpackTuple(args, "predict", 4, 4, &arg0, &arg1, &arg2, &arg3)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg1, (char **)&x1); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x1 = (double *)alloca((size_t)datasize); - memset((void *)x1, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x1, _cffi_type(1), arg1) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg2, (char **)&x2); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x2 = (double *)alloca((size_t)datasize); - memset((void *)x2, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x2, _cffi_type(1), arg2) < 0) - return NULL; - } - - x3 = (double)_cffi_to_c_double(arg3); - if (x3 == (double)-1 && PyErr_Occurred()) - return NULL; - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { predict(x0, x1, x2, x3); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_predict _cffi_d_predict -#endif - -static void _cffi_d_update_13(double * x0, double * x1, double * x2, double * x3, double * x4) -{ - update_13(x0, x1, x2, x3, x4); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_update_13(PyObject *self, PyObject *args) -{ - double * x0; - double * x1; - double * x2; - double * x3; - double * x4; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - PyObject *arg2; - PyObject *arg3; - PyObject *arg4; - - if (!PyArg_UnpackTuple(args, "update_13", 5, 5, &arg0, &arg1, &arg2, &arg3, &arg4)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg1, (char **)&x1); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x1 = (double *)alloca((size_t)datasize); - memset((void *)x1, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x1, _cffi_type(1), arg1) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg2, (char **)&x2); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x2 = (double *)alloca((size_t)datasize); - memset((void *)x2, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x2, _cffi_type(1), arg2) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg3, (char **)&x3); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x3 = (double *)alloca((size_t)datasize); - memset((void *)x3, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x3, _cffi_type(1), arg3) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg4, (char **)&x4); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x4 = (double *)alloca((size_t)datasize); - memset((void *)x4, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x4, _cffi_type(1), arg4) < 0) - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { update_13(x0, x1, x2, x3, x4); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_update_13 _cffi_d_update_13 -#endif - -static void _cffi_d_update_14(double * x0, double * x1, double * x2, double * x3, double * x4) -{ - update_14(x0, x1, x2, x3, x4); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_update_14(PyObject *self, PyObject *args) -{ - double * x0; - double * x1; - double * x2; - double * x3; - double * x4; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - PyObject *arg2; - PyObject *arg3; - PyObject *arg4; - - if (!PyArg_UnpackTuple(args, "update_14", 5, 5, &arg0, &arg1, &arg2, &arg3, &arg4)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg1, (char **)&x1); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x1 = (double *)alloca((size_t)datasize); - memset((void *)x1, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x1, _cffi_type(1), arg1) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg2, (char **)&x2); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x2 = (double *)alloca((size_t)datasize); - memset((void *)x2, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x2, _cffi_type(1), arg2) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg3, (char **)&x3); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x3 = (double *)alloca((size_t)datasize); - memset((void *)x3, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x3, _cffi_type(1), arg3) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg4, (char **)&x4); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x4 = (double *)alloca((size_t)datasize); - memset((void *)x4, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x4, _cffi_type(1), arg4) < 0) - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { update_14(x0, x1, x2, x3, x4); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_update_14 _cffi_d_update_14 -#endif - -static void _cffi_d_update_3(double * x0, double * x1, double * x2, double * x3, double * x4) -{ - update_3(x0, x1, x2, x3, x4); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_update_3(PyObject *self, PyObject *args) -{ - double * x0; - double * x1; - double * x2; - double * x3; - double * x4; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - PyObject *arg2; - PyObject *arg3; - PyObject *arg4; - - if (!PyArg_UnpackTuple(args, "update_3", 5, 5, &arg0, &arg1, &arg2, &arg3, &arg4)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg1, (char **)&x1); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x1 = (double *)alloca((size_t)datasize); - memset((void *)x1, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x1, _cffi_type(1), arg1) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg2, (char **)&x2); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x2 = (double *)alloca((size_t)datasize); - memset((void *)x2, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x2, _cffi_type(1), arg2) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg3, (char **)&x3); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x3 = (double *)alloca((size_t)datasize); - memset((void *)x3, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x3, _cffi_type(1), arg3) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg4, (char **)&x4); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x4 = (double *)alloca((size_t)datasize); - memset((void *)x4, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x4, _cffi_type(1), arg4) < 0) - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { update_3(x0, x1, x2, x3, x4); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_update_3 _cffi_d_update_3 -#endif - -static void _cffi_d_update_4(double * x0, double * x1, double * x2, double * x3, double * x4) -{ - update_4(x0, x1, x2, x3, x4); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_update_4(PyObject *self, PyObject *args) -{ - double * x0; - double * x1; - double * x2; - double * x3; - double * x4; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - PyObject *arg2; - PyObject *arg3; - PyObject *arg4; - - if (!PyArg_UnpackTuple(args, "update_4", 5, 5, &arg0, &arg1, &arg2, &arg3, &arg4)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg1, (char **)&x1); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x1 = (double *)alloca((size_t)datasize); - memset((void *)x1, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x1, _cffi_type(1), arg1) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg2, (char **)&x2); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x2 = (double *)alloca((size_t)datasize); - memset((void *)x2, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x2, _cffi_type(1), arg2) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg3, (char **)&x3); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x3 = (double *)alloca((size_t)datasize); - memset((void *)x3, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x3, _cffi_type(1), arg3) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg4, (char **)&x4); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x4 = (double *)alloca((size_t)datasize); - memset((void *)x4, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x4, _cffi_type(1), arg4) < 0) - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { update_4(x0, x1, x2, x3, x4); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_update_4 _cffi_d_update_4 -#endif - -static void _cffi_d_update_9(double * x0, double * x1, double * x2, double * x3, double * x4) -{ - update_9(x0, x1, x2, x3, x4); -} -#ifndef PYPY_VERSION -static PyObject * -_cffi_f_update_9(PyObject *self, PyObject *args) -{ - double * x0; - double * x1; - double * x2; - double * x3; - double * x4; - Py_ssize_t datasize; - PyObject *arg0; - PyObject *arg1; - PyObject *arg2; - PyObject *arg3; - PyObject *arg4; - - if (!PyArg_UnpackTuple(args, "update_9", 5, 5, &arg0, &arg1, &arg2, &arg3, &arg4)) - return NULL; - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg0, (char **)&x0); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x0 = (double *)alloca((size_t)datasize); - memset((void *)x0, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg1, (char **)&x1); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x1 = (double *)alloca((size_t)datasize); - memset((void *)x1, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x1, _cffi_type(1), arg1) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg2, (char **)&x2); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x2 = (double *)alloca((size_t)datasize); - memset((void *)x2, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x2, _cffi_type(1), arg2) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg3, (char **)&x3); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x3 = (double *)alloca((size_t)datasize); - memset((void *)x3, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x3, _cffi_type(1), arg3) < 0) - return NULL; - } - - datasize = _cffi_prepare_pointer_call_argument( - _cffi_type(1), arg4, (char **)&x4); - if (datasize != 0) { - if (datasize < 0) - return NULL; - x4 = (double *)alloca((size_t)datasize); - memset((void *)x4, 0, (size_t)datasize); - if (_cffi_convert_array_from_object((char *)x4, _cffi_type(1), arg4) < 0) - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _cffi_restore_errno(); - { update_9(x0, x1, x2, x3, x4); } - _cffi_save_errno(); - Py_END_ALLOW_THREADS - - (void)self; /* unused */ - Py_INCREF(Py_None); - return Py_None; -} -#else -# define _cffi_f_update_9 _cffi_d_update_9 -#endif - -static int _cffi_const_DIM(unsigned long long *o) -{ - int n = (DIM) <= 0; - *o = (unsigned long long)((DIM) | 0); /* check that DIM is an integer */ - if (!_cffi_check_int(*o, n, 13U)) - n |= 2; - return n; -} - -static int _cffi_const_EDIM(unsigned long long *o) -{ - int n = (EDIM) <= 0; - *o = (unsigned long long)((EDIM) | 0); /* check that EDIM is an integer */ - if (!_cffi_check_int(*o, n, 13U)) - n |= 2; - return n; -} - -static int _cffi_const_MEDIM(unsigned long long *o) -{ - int n = (MEDIM) <= 0; - *o = (unsigned long long)((MEDIM) | 0); /* check that MEDIM is an integer */ - if (!_cffi_check_int(*o, n, 13U)) - n |= 2; - return n; -} - -static const struct _cffi_global_s _cffi_globals[] = { - { "DIM", (void *)_cffi_const_DIM, _CFFI_OP(_CFFI_OP_CONSTANT_INT, -1), (void *)0 }, - { "EDIM", (void *)_cffi_const_EDIM, _CFFI_OP(_CFFI_OP_CONSTANT_INT, -1), (void *)0 }, - { "F_fun", (void *)_cffi_f_F_fun, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 22), (void *)_cffi_d_F_fun }, - { "H_13", (void *)_cffi_f_H_13, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 4), (void *)_cffi_d_H_13 }, - { "H_14", (void *)_cffi_f_H_14, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 4), (void *)_cffi_d_H_14 }, - { "H_3", (void *)_cffi_f_H_3, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 4), (void *)_cffi_d_H_3 }, - { "H_4", (void *)_cffi_f_H_4, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 4), (void *)_cffi_d_H_4 }, - { "H_9", (void *)_cffi_f_H_9, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 4), (void *)_cffi_d_H_9 }, - { "H_mod_fun", (void *)_cffi_f_H_mod_fun, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 0), (void *)_cffi_d_H_mod_fun }, - { "MAHA_THRESH_13", (void *)_cffi_const_MAHA_THRESH_13, _CFFI_OP(_CFFI_OP_CONSTANT, 20), (void *)0 }, - { "MAHA_THRESH_14", (void *)_cffi_const_MAHA_THRESH_14, _CFFI_OP(_CFFI_OP_CONSTANT, 20), (void *)0 }, - { "MAHA_THRESH_3", (void *)_cffi_const_MAHA_THRESH_3, _CFFI_OP(_CFFI_OP_CONSTANT, 20), (void *)0 }, - { "MAHA_THRESH_4", (void *)_cffi_const_MAHA_THRESH_4, _CFFI_OP(_CFFI_OP_CONSTANT, 20), (void *)0 }, - { "MAHA_THRESH_9", (void *)_cffi_const_MAHA_THRESH_9, _CFFI_OP(_CFFI_OP_CONSTANT, 20), (void *)0 }, - { "MEDIM", (void *)_cffi_const_MEDIM, _CFFI_OP(_CFFI_OP_CONSTANT_INT, -1), (void *)0 }, - { "err_fun", (void *)_cffi_f_err_fun, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 4), (void *)_cffi_d_err_fun }, - { "f_fun", (void *)_cffi_f_f_fun, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 22), (void *)_cffi_d_f_fun }, - { "h_13", (void *)_cffi_f_h_13, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 4), (void *)_cffi_d_h_13 }, - { "h_14", (void *)_cffi_f_h_14, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 4), (void *)_cffi_d_h_14 }, - { "h_3", (void *)_cffi_f_h_3, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 4), (void *)_cffi_d_h_3 }, - { "h_4", (void *)_cffi_f_h_4, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 4), (void *)_cffi_d_h_4 }, - { "h_9", (void *)_cffi_f_h_9, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 4), (void *)_cffi_d_h_9 }, - { "inv_err_fun", (void *)_cffi_f_inv_err_fun, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 4), (void *)_cffi_d_inv_err_fun }, - { "predict", (void *)_cffi_f_predict, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 16), (void *)_cffi_d_predict }, - { "update_13", (void *)_cffi_f_update_13, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 9), (void *)_cffi_d_update_13 }, - { "update_14", (void *)_cffi_f_update_14, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 9), (void *)_cffi_d_update_14 }, - { "update_3", (void *)_cffi_f_update_3, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 9), (void *)_cffi_d_update_3 }, - { "update_4", (void *)_cffi_f_update_4, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 9), (void *)_cffi_d_update_4 }, - { "update_9", (void *)_cffi_f_update_9, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 9), (void *)_cffi_d_update_9 }, -}; - -static const struct _cffi_typename_s _cffi_typenames[] = { - { "Hfun", 27 }, -}; - -static const struct _cffi_type_context_s _cffi_type_context = { - _cffi_types, - _cffi_globals, - NULL, /* no fields */ - NULL, /* no struct_unions */ - NULL, /* no enums */ - _cffi_typenames, - 29, /* num_globals */ - 0, /* num_struct_unions */ - 0, /* num_enums */ - 1, /* num_typenames */ - NULL, /* no includes */ - 29, /* num_types */ - 0, /* flags */ -}; - -#ifdef __GNUC__ -# pragma GCC visibility push(default) /* for -fvisibility= */ -#endif - -#ifdef PYPY_VERSION -PyMODINIT_FUNC -_cffi_pypyinit_loc_local(const void *p[]) -{ - p[0] = (const void *)0x2601; - p[1] = &_cffi_type_context; -#if PY_MAJOR_VERSION >= 3 - return NULL; -#endif -} -# ifdef _MSC_VER - PyMODINIT_FUNC -# if PY_MAJOR_VERSION >= 3 - PyInit_loc_local(void) { return NULL; } -# else - initloc_local(void) { } -# endif -# endif -#elif PY_MAJOR_VERSION >= 3 -PyMODINIT_FUNC -PyInit_loc_local(void) -{ - return _cffi_init("loc_local", 0x2601, &_cffi_type_context); -} -#else -PyMODINIT_FUNC -initloc_local(void) -{ - _cffi_init("loc_local", 0x2601, &_cffi_type_context); -} -#endif - -#ifdef __GNUC__ -# pragma GCC visibility pop -#endif diff --git a/selfdrive/locationd/locationd.py b/selfdrive/locationd/locationd.py new file mode 100755 index 00000000000000..9026fc3394bd02 --- /dev/null +++ b/selfdrive/locationd/locationd.py @@ -0,0 +1,338 @@ +#!/usr/bin/env python3 +import numpy as np +import sympy as sp +import cereal.messaging as messaging +from cereal import log +import common.transformations.coordinates as coord +from common.transformations.orientation import ecef_euler_from_ned, \ + euler_from_quat, \ + ned_euler_from_ecef, \ + quat_from_euler, euler_from_rot, \ + rot_from_quat, rot_from_euler +from rednose.helpers import KalmanError +from selfdrive.locationd.models.live_kf import LiveKalman, States, ObservationKind +from selfdrive.locationd.models.constants import GENERATED_DIR +from selfdrive.swaglog import cloudlog + +#from datetime import datetime +#from laika.gps_time import GPSTime + +from sympy.utilities.lambdify import lambdify +from rednose.helpers.sympy_helpers import euler_rotate + +SensorSource = log.SensorEventData.SensorSource + + +VISION_DECIMATION = 2 +SENSOR_DECIMATION = 10 +POSENET_STD_HIST = 40 + + +def to_float(arr): + return [float(arr[0]), float(arr[1]), float(arr[2])] + + +def get_H(): + # this returns a function to eval the jacobian + # of the observation function of the local vel + roll = sp.Symbol('roll') + pitch = sp.Symbol('pitch') + yaw = sp.Symbol('yaw') + vx = sp.Symbol('vx') + vy = sp.Symbol('vy') + vz = sp.Symbol('vz') + + h = euler_rotate(roll, pitch, yaw).T*(sp.Matrix([vx, vy, vz])) + H = h.jacobian(sp.Matrix([roll, pitch, yaw, vx, vy, vz])) + H_f = lambdify([roll, pitch, yaw, vx, vy, vz], H) + return H_f + + +class Localizer(): + def __init__(self, disabled_logs=None, dog=None): + if disabled_logs is None: + disabled_logs = [] + + self.kf = LiveKalman(GENERATED_DIR) + self.reset_kalman() + self.max_age = .1 # seconds + self.disabled_logs = disabled_logs + self.calib = np.zeros(3) + self.device_from_calib = np.eye(3) + self.calib_from_device = np.eye(3) + self.calibrated = 0 + self.H = get_H() + + self.posenet_invalid_count = 0 + self.posenet_speed = 0 + self.car_speed = 0 + self.posenet_stds = 10*np.ones((POSENET_STD_HIST)) + + self.converter = coord.LocalCoord.from_ecef(self.kf.x[States.ECEF_POS]) + + self.unix_timestamp_millis = 0 + self.last_gps_fix = 0 + self.device_fell = False + + @staticmethod + def msg_from_state(converter, calib_from_device, H, predicted_state, predicted_cov): + predicted_std = np.sqrt(np.diagonal(predicted_cov)) + + fix_ecef = predicted_state[States.ECEF_POS] + fix_ecef_std = predicted_std[States.ECEF_POS_ERR] + vel_ecef = predicted_state[States.ECEF_VELOCITY] + vel_ecef_std = predicted_std[States.ECEF_VELOCITY_ERR] + fix_pos_geo = coord.ecef2geodetic(fix_ecef) + #fix_pos_geo_std = np.abs(coord.ecef2geodetic(fix_ecef + fix_ecef_std) - fix_pos_geo) + orientation_ecef = euler_from_quat(predicted_state[States.ECEF_ORIENTATION]) + orientation_ecef_std = predicted_std[States.ECEF_ORIENTATION_ERR] + device_from_ecef = rot_from_quat(predicted_state[States.ECEF_ORIENTATION]).T + calibrated_orientation_ecef = euler_from_rot(calib_from_device.dot(device_from_ecef)) + + acc_calib = calib_from_device.dot(predicted_state[States.ACCELERATION]) + acc_calib_std = np.sqrt(np.diagonal(calib_from_device.dot( + predicted_cov[States.ACCELERATION_ERR, States.ACCELERATION_ERR]).dot( + calib_from_device.T))) + ang_vel_calib = calib_from_device.dot(predicted_state[States.ANGULAR_VELOCITY]) + ang_vel_calib_std = np.sqrt(np.diagonal(calib_from_device.dot( + predicted_cov[States.ANGULAR_VELOCITY_ERR, States.ANGULAR_VELOCITY_ERR]).dot( + calib_from_device.T))) + + vel_device = device_from_ecef.dot(vel_ecef) + device_from_ecef_eul = euler_from_quat(predicted_state[States.ECEF_ORIENTATION]).T + idxs = list(range(States.ECEF_ORIENTATION_ERR.start, States.ECEF_ORIENTATION_ERR.stop)) + \ + list(range(States.ECEF_VELOCITY_ERR.start, States.ECEF_VELOCITY_ERR.stop)) + condensed_cov = predicted_cov[idxs][:, idxs] + HH = H(*list(np.concatenate([device_from_ecef_eul, vel_ecef]))) + vel_device_cov = HH.dot(condensed_cov).dot(HH.T) + vel_device_std = np.sqrt(np.diagonal(vel_device_cov)) + + vel_calib = calib_from_device.dot(vel_device) + vel_calib_std = np.sqrt(np.diagonal(calib_from_device.dot( + vel_device_cov).dot(calib_from_device.T))) + + orientation_ned = ned_euler_from_ecef(fix_ecef, orientation_ecef) + #orientation_ned_std = ned_euler_from_ecef(fix_ecef, orientation_ecef + orientation_ecef_std) - orientation_ned + ned_vel = converter.ecef2ned(fix_ecef + vel_ecef) - converter.ecef2ned(fix_ecef) + #ned_vel_std = self.converter.ecef2ned(fix_ecef + vel_ecef + vel_ecef_std) - self.converter.ecef2ned(fix_ecef + vel_ecef) + + fix = messaging.log.LiveLocationKalman.new_message() + + # write measurements to msg + measurements = [ + # measurement field, value, std, valid + (fix.positionGeodetic, fix_pos_geo, np.nan*np.zeros(3), True), + (fix.positionECEF, fix_ecef, fix_ecef_std, True), + (fix.velocityECEF, vel_ecef, vel_ecef_std, True), + (fix.velocityNED, ned_vel, np.nan*np.zeros(3), True), + (fix.velocityDevice, vel_device, vel_device_std, True), + (fix.accelerationDevice, predicted_state[States.ACCELERATION], predicted_std[States.ACCELERATION_ERR], True), + (fix.orientationECEF, orientation_ecef, orientation_ecef_std, True), + (fix.calibratedOrientationECEF, calibrated_orientation_ecef, np.nan*np.zeros(3), True), + (fix.orientationNED, orientation_ned, np.nan*np.zeros(3), True), + (fix.angularVelocityDevice, predicted_state[States.ANGULAR_VELOCITY], predicted_std[States.ANGULAR_VELOCITY_ERR], True), + (fix.velocityCalibrated, vel_calib, vel_calib_std, True), + (fix.angularVelocityCalibrated, ang_vel_calib, ang_vel_calib_std, True), + (fix.accelerationCalibrated, acc_calib, acc_calib_std, True), + ] + + for field, value, std, valid in measurements: + # TODO: can we write the lists faster? + field.value = to_float(value) + field.std = to_float(std) + field.valid = valid + + return fix + + def liveLocationMsg(self): + fix = self.msg_from_state(self.converter, self.calib_from_device, self.H, self.kf.x, self.kf.P) + # experimentally found these values, no false positives in 20k minutes of driving + old_mean, new_mean = np.mean(self.posenet_stds[:POSENET_STD_HIST//2]), np.mean(self.posenet_stds[POSENET_STD_HIST//2:]) + std_spike = new_mean/old_mean > 4 and new_mean > 7 + + fix.posenetOK = not (std_spike and self.car_speed > 5) + fix.deviceStable = not self.device_fell + self.device_fell = False + + #fix.gpsWeek = self.time.week + #fix.gpsTimeOfWeek = self.time.tow + fix.unixTimestampMillis = self.unix_timestamp_millis + + if np.linalg.norm(fix.positionECEF.std) < 50 and self.calibrated: + fix.status = 'valid' + elif np.linalg.norm(fix.positionECEF.std) < 50: + fix.status = 'uncalibrated' + else: + fix.status = 'uninitialized' + return fix + + def update_kalman(self, time, kind, meas, R=None): + try: + self.kf.predict_and_observe(time, kind, meas, R) + except KalmanError: + cloudlog.error("Error in predict and observe, kalman reset") + self.reset_kalman() + + def handle_gps(self, current_time, log): + # ignore the message if the fix is invalid + if log.flags % 2 == 0: + return + + self.last_gps_fix = current_time + + self.converter = coord.LocalCoord.from_geodetic([log.latitude, log.longitude, log.altitude]) + ecef_pos = self.converter.ned2ecef([0, 0, 0]) + ecef_vel = self.converter.ned2ecef(np.array(log.vNED)) - ecef_pos + ecef_pos_R = np.diag([(3*log.verticalAccuracy)**2]*3) + ecef_vel_R = np.diag([(log.speedAccuracy)**2]*3) + + #self.time = GPSTime.from_datetime(datetime.utcfromtimestamp(log.timestamp*1e-3)) + self.unix_timestamp_millis = log.timestamp + gps_est_error = np.sqrt((self.kf.x[0] - ecef_pos[0])**2 + + (self.kf.x[1] - ecef_pos[1])**2 + + (self.kf.x[2] - ecef_pos[2])**2) + + orientation_ecef = euler_from_quat(self.kf.x[States.ECEF_ORIENTATION]) + orientation_ned = ned_euler_from_ecef(ecef_pos, orientation_ecef) + orientation_ned_gps = np.array([0, 0, np.radians(log.bearing)]) + orientation_error = np.mod(orientation_ned - orientation_ned_gps - np.pi, 2*np.pi) - np.pi + initial_pose_ecef_quat = quat_from_euler(ecef_euler_from_ned(ecef_pos, orientation_ned_gps)) + if np.linalg.norm(ecef_vel) > 5 and np.linalg.norm(orientation_error) > 1: + cloudlog.error("Locationd vs ubloxLocation orientation difference too large, kalman reset") + self.reset_kalman(init_pos=ecef_pos, init_orient=initial_pose_ecef_quat) + self.update_kalman(current_time, ObservationKind.ECEF_ORIENTATION_FROM_GPS, initial_pose_ecef_quat) + elif gps_est_error > 50: + cloudlog.error("Locationd vs ubloxLocation position difference too large, kalman reset") + self.reset_kalman(init_pos=ecef_pos, init_orient=initial_pose_ecef_quat) + + self.update_kalman(current_time, ObservationKind.ECEF_POS, ecef_pos, R=ecef_pos_R) + self.update_kalman(current_time, ObservationKind.ECEF_VEL, ecef_vel, R=ecef_vel_R) + + def handle_car_state(self, current_time, log): + self.speed_counter += 1 + + if self.speed_counter % SENSOR_DECIMATION == 0: + self.update_kalman(current_time, ObservationKind.ODOMETRIC_SPEED, [log.vEgo]) + self.car_speed = abs(log.vEgo) + if log.vEgo == 0: + self.update_kalman(current_time, ObservationKind.NO_ROT, [0, 0, 0]) + + def handle_cam_odo(self, current_time, log): + self.cam_counter += 1 + + if self.cam_counter % VISION_DECIMATION == 0: + rot_device = self.device_from_calib.dot(log.rot) + rot_device_std = self.device_from_calib.dot(log.rotStd) + self.update_kalman(current_time, + ObservationKind.CAMERA_ODO_ROTATION, + np.concatenate([rot_device, 10*rot_device_std])) + trans_device = self.device_from_calib.dot(log.trans) + trans_device_std = self.device_from_calib.dot(log.transStd) + self.posenet_speed = np.linalg.norm(trans_device) + self.posenet_stds[:-1] = self.posenet_stds[1:] + self.posenet_stds[-1] = trans_device_std[0] + self.update_kalman(current_time, + ObservationKind.CAMERA_ODO_TRANSLATION, + np.concatenate([trans_device, 10*trans_device_std])) + + def handle_sensors(self, current_time, log): + # TODO does not yet account for double sensor readings in the log + for sensor_reading in log: + # TODO: handle messages from two IMUs at the same time + if sensor_reading.source == SensorSource.lsm6ds3: + continue + + # Gyro Uncalibrated + if sensor_reading.sensor == 5 and sensor_reading.type == 16: + self.gyro_counter += 1 + if self.gyro_counter % SENSOR_DECIMATION == 0: + v = sensor_reading.gyroUncalibrated.v + self.update_kalman(current_time, ObservationKind.PHONE_GYRO, [-v[2], -v[1], -v[0]]) + + # Accelerometer + if sensor_reading.sensor == 1 and sensor_reading.type == 1: + # check if device fell, estimate 10 for g + # 40m/s**2 is a good filter for falling detection, no false positives in 20k minutes of driving + self.device_fell = self.device_fell or (np.linalg.norm(np.array(sensor_reading.acceleration.v) - np.array([10, 0, 0])) > 40) + + self.acc_counter += 1 + if self.acc_counter % SENSOR_DECIMATION == 0: + v = sensor_reading.acceleration.v + self.update_kalman(current_time, ObservationKind.PHONE_ACCEL, [-v[2], -v[1], -v[0]]) + + def handle_live_calib(self, current_time, log): + if len(log.rpyCalib): + self.calib = log.rpyCalib + self.device_from_calib = rot_from_euler(self.calib) + self.calib_from_device = self.device_from_calib.T + self.calibrated = log.calStatus == 1 + + def reset_kalman(self, current_time=None, init_orient=None, init_pos=None): + self.filter_time = current_time + init_x = LiveKalman.initial_x.copy() + # too nonlinear to init on completely wrong + if init_orient is not None: + init_x[3:7] = init_orient + if init_pos is not None: + init_x[:3] = init_pos + self.kf.init_state(init_x, covs=np.diag(LiveKalman.initial_P_diag), filter_time=current_time) + + self.observation_buffer = [] + + self.gyro_counter = 0 + self.acc_counter = 0 + self.speed_counter = 0 + self.cam_counter = 0 + + +def locationd_thread(sm, pm, disabled_logs=None): + if disabled_logs is None: + disabled_logs = [] + + if sm is None: + socks = ['gpsLocationExternal', 'sensorEvents', 'cameraOdometry', 'liveCalibration', 'carState'] + sm = messaging.SubMaster(socks, ignore_alive=['gpsLocationExternal']) + if pm is None: + pm = messaging.PubMaster(['liveLocationKalman']) + + localizer = Localizer(disabled_logs=disabled_logs) + + while True: + sm.update() + + for sock, updated in sm.updated.items(): + if updated and sm.valid[sock]: + t = sm.logMonoTime[sock] * 1e-9 + if sock == "sensorEvents": + localizer.handle_sensors(t, sm[sock]) + elif sock == "gpsLocationExternal": + localizer.handle_gps(t, sm[sock]) + elif sock == "carState": + localizer.handle_car_state(t, sm[sock]) + elif sock == "cameraOdometry": + localizer.handle_cam_odo(t, sm[sock]) + elif sock == "liveCalibration": + localizer.handle_live_calib(t, sm[sock]) + + if sm.updated['cameraOdometry']: + t = sm.logMonoTime['cameraOdometry'] + msg = messaging.new_message('liveLocationKalman') + msg.logMonoTime = t + + msg.liveLocationKalman = localizer.liveLocationMsg() + msg.liveLocationKalman.inputsOK = sm.all_alive_and_valid() + msg.liveLocationKalman.sensorsOK = sm.alive['sensorEvents'] and sm.valid['sensorEvents'] + + gps_age = (t / 1e9) - localizer.last_gps_fix + msg.liveLocationKalman.gpsOK = gps_age < 1.0 + pm.send('liveLocationKalman', msg) + + +def main(sm=None, pm=None): + locationd_thread(sm, pm) + + +if __name__ == "__main__": + import os + os.environ["OMP_NUM_THREADS"] = "1" + main() diff --git a/selfdrive/locationd/locationd_yawrate.cc b/selfdrive/locationd/locationd_yawrate.cc deleted file mode 100644 index 93e706499a715c..00000000000000 --- a/selfdrive/locationd/locationd_yawrate.cc +++ /dev/null @@ -1,137 +0,0 @@ -#include -#include - -#include -#include -#include - -#include "cereal/gen/cpp/log.capnp.h" - -#include "locationd_yawrate.h" - - -void Localizer::update_state(const Eigen::Matrix &C, const double R, double current_time, double meas) { - double dt = current_time - prev_update_time; - - if (dt < 0) { - dt = 0; - } else { - prev_update_time = current_time; - } - - // x = A * x; - // P = A * P * A.transpose() + dt * Q; - // Simplify because A is unity - P = P + dt * Q; - - double y = meas - C * x; - double S = R + C * P * C.transpose(); - Eigen::Vector2d K = P * C.transpose() * (1.0 / S); - x = x + K * y; - P = (I - K * C) * P; -} - -void Localizer::handle_sensor_events(capnp::List::Reader sensor_events, double current_time) { - for (cereal::SensorEventData::Reader sensor_event : sensor_events){ - if (sensor_event.getType() == 4) { - sensor_data_time = current_time; - - double meas = -sensor_event.getGyro().getV()[0]; - update_state(C_gyro, R_gyro, current_time, meas); - } - } -} - -void Localizer::handle_camera_odometry(cereal::CameraOdometry::Reader camera_odometry, double current_time) { - double R = 250.0 * pow(camera_odometry.getRotStd()[2], 2); - double meas = camera_odometry.getRot()[2]; - update_state(C_posenet, R, current_time, meas); - - auto trans = camera_odometry.getTrans(); - posenet_speed = sqrt(trans[0]*trans[0] + trans[1]*trans[1] + trans[2]*trans[2]); -} - -void Localizer::handle_controls_state(cereal::ControlsState::Reader controls_state, double current_time) { - steering_angle = controls_state.getAngleSteers() * DEGREES_TO_RADIANS; - car_speed = controls_state.getVEgo(); - controls_state_time = current_time; -} - - -Localizer::Localizer() { - A << 1, 0, 0, 1; - I << 1, 0, 0, 1; - - Q << pow(0.1, 2.0), 0, 0, pow(0.005 / 100.0, 2.0); - P << pow(1.0, 2.0), 0, 0, pow(0.05, 2.0); - - C_posenet << 1, 0; - C_gyro << 1, 1; - x << 0, 0; - - R_gyro = pow(0.05, 2.0); -} - -void Localizer::handle_log(cereal::Event::Reader event) { - double current_time = event.getLogMonoTime() / 1.0e9; - - // Initialize update_time on first update - if (prev_update_time < 0) { - prev_update_time = current_time; - } - - auto type = event.which(); - switch(type) { - case cereal::Event::CONTROLS_STATE: - handle_controls_state(event.getControlsState(), current_time); - break; - case cereal::Event::CAMERA_ODOMETRY: - handle_camera_odometry(event.getCameraOdometry(), current_time); - break; - case cereal::Event::SENSOR_EVENTS: - handle_sensor_events(event.getSensorEvents(), current_time); - break; - default: - break; - } -} - - -extern "C" { - void *localizer_init(void) { - Localizer * localizer = new Localizer; - return (void*)localizer; - } - - void localizer_handle_log(void * localizer, const unsigned char * data, size_t len) { - const kj::ArrayPtr view((const capnp::word*)data, len); - capnp::FlatArrayMessageReader msg(view); - cereal::Event::Reader event = msg.getRoot(); - - Localizer * loc = (Localizer*) localizer; - loc->handle_log(event); - } - - double localizer_get_yaw(void * localizer) { - Localizer * loc = (Localizer*) localizer; - return loc->x[0]; - } - double localizer_get_bias(void * localizer) { - Localizer * loc = (Localizer*) localizer; - return loc->x[1]; - } - - void localizer_set_yaw(void * localizer, double yaw) { - Localizer * loc = (Localizer*) localizer; - loc->x[0] = yaw; - } - void localizer_set_bias(void * localizer, double bias) { - Localizer * loc = (Localizer*) localizer; - loc->x[1] = bias; - } - - double localizer_get_t(void * localizer) { - Localizer * loc = (Localizer*) localizer; - return loc->prev_update_time; - } -} diff --git a/selfdrive/locationd/locationd_yawrate.h b/selfdrive/locationd/locationd_yawrate.h deleted file mode 100644 index d5db91e7909950..00000000000000 --- a/selfdrive/locationd/locationd_yawrate.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include -#include "cereal/gen/cpp/log.capnp.h" - -#define DEGREES_TO_RADIANS 0.017453292519943295 - -class Localizer -{ - Eigen::Matrix2d A; - Eigen::Matrix2d I; - Eigen::Matrix2d Q; - Eigen::Matrix2d P; - Eigen::Matrix C_posenet; - Eigen::Matrix C_gyro; - - double R_gyro; - - void update_state(const Eigen::Matrix &C, const double R, double current_time, double meas); - void handle_sensor_events(capnp::List::Reader sensor_events, double current_time); - void handle_camera_odometry(cereal::CameraOdometry::Reader camera_odometry, double current_time); - void handle_controls_state(cereal::ControlsState::Reader controls_state, double current_time); - -public: - Eigen::Vector2d x; - double steering_angle = 0; - double car_speed = 0; - double posenet_speed = 0; - double prev_update_time = -1; - double controls_state_time = -1; - double sensor_data_time = -1; - - Localizer(); - void handle_log(cereal::Event::Reader event); - -}; diff --git a/selfdrive/locationd/models/.gitignore b/selfdrive/locationd/models/.gitignore new file mode 100644 index 00000000000000..9ab870da897d66 --- /dev/null +++ b/selfdrive/locationd/models/.gitignore @@ -0,0 +1 @@ +generated/ diff --git a/selfdrive/locationd/models/SConscript b/selfdrive/locationd/models/SConscript new file mode 100644 index 00000000000000..0a197ffda87397 --- /dev/null +++ b/selfdrive/locationd/models/SConscript @@ -0,0 +1,37 @@ +Import('env', 'arch') + +templates = Glob('#rednose/templates/*') + +sympy_helpers = "#rednose/helpers/sympy_helpers.py" +ekf_sym = "#rednose/helpers/ekf_sym.py" + +to_build = { + 'live': ('live_kf.py', 'generated'), + 'car': ('car_kf.py', 'generated'), +} + +if arch != "aarch64": + to_build.update({ + 'gnss': ('gnss_kf.py', 'generated'), + 'loc_4': ('loc_kf.py', 'generated'), + 'pos_computer_4': ('#rednose/helpers/lst_sq_computer.py', 'generated'), + 'pos_computer_5': ('#rednose/helpers/lst_sq_computer.py', 'generated'), + 'feature_handler_5': ('#rednose/helpers/feature_handler.py', 'generated'), + 'lane': ('#xx/pipeline/lib/ekf/lane_kf.py', 'generated'), + }) + +found = {} + +for target, (command, generated_folder) in to_build.items(): + if File(command).exists(): + found[target] = (command, generated_folder) + +for target, (command, generated_folder) in found.items(): + target_files = File([f'{generated_folder}/{target}.cpp', f'{generated_folder}/{target}.h']) + command_file = File(command) + + env.Command(target_files, + [templates, command_file, sympy_helpers, ekf_sym], + command_file.get_abspath() + " " + target + " " + Dir(generated_folder).get_abspath()) + + env.SharedLibrary(f'{generated_folder}/' + target, target_files[0]) diff --git a/selfdrive/locationd/models/car_kf.py b/selfdrive/locationd/models/car_kf.py new file mode 100755 index 00000000000000..ee409ecebc6168 --- /dev/null +++ b/selfdrive/locationd/models/car_kf.py @@ -0,0 +1,156 @@ +#!/usr/bin/env python3 +import math +import sys +from typing import Any, Dict + +import numpy as np +import sympy as sp + +from rednose import KalmanFilter +from rednose.helpers.ekf_sym import EKF_sym, gen_code +from selfdrive.locationd.models.constants import ObservationKind + +i = 0 + + +def _slice(n): + global i + s = slice(i, i + n) + i += n + + return s + + +class States(): + # Vehicle model params + STIFFNESS = _slice(1) # [-] + STEER_RATIO = _slice(1) # [-] + ANGLE_OFFSET = _slice(1) # [rad] + ANGLE_OFFSET_FAST = _slice(1) # [rad] + + VELOCITY = _slice(2) # (x, y) [m/s] + YAW_RATE = _slice(1) # [rad/s] + STEER_ANGLE = _slice(1) # [rad] + + +class CarKalman(KalmanFilter): + name = 'car' + + initial_x = np.array([ + 1.0, + 15.0, + 0.0, + 0.0, + + 10.0, 0.0, + 0.0, + 0.0, + ]) + + # process noise + Q = np.diag([ + (.05 / 100)**2, + .01**2, + math.radians(0.02)**2, + math.radians(0.25)**2, + + .1**2, .01**2, + math.radians(0.1)**2, + math.radians(0.1)**2, + ]) + P_initial = Q.copy() + + obs_noise: Dict[int, Any] = { + ObservationKind.STEER_ANGLE: np.atleast_2d(math.radians(0.01)**2), + ObservationKind.ANGLE_OFFSET_FAST: np.atleast_2d(math.radians(10.0)**2), + ObservationKind.STEER_RATIO: np.atleast_2d(5.0**2), + ObservationKind.STIFFNESS: np.atleast_2d(5.0**2), + ObservationKind.ROAD_FRAME_X_SPEED: np.atleast_2d(0.1**2), + } + + global_vars = [ + sp.Symbol('mass'), + sp.Symbol('rotational_inertia'), + sp.Symbol('center_to_front'), + sp.Symbol('center_to_rear'), + sp.Symbol('stiffness_front'), + sp.Symbol('stiffness_rear'), + ] + + @staticmethod + def generate_code(generated_dir): + dim_state = CarKalman.initial_x.shape[0] + name = CarKalman.name + + # globals + m, j, aF, aR, cF_orig, cR_orig = CarKalman.global_vars + + # make functions and jacobians with sympy + # state variables + state_sym = sp.MatrixSymbol('state', dim_state, 1) + state = sp.Matrix(state_sym) + + # Vehicle model constants + x = state[States.STIFFNESS, :][0, 0] + + cF, cR = x * cF_orig, x * cR_orig + angle_offset = state[States.ANGLE_OFFSET, :][0, 0] + angle_offset_fast = state[States.ANGLE_OFFSET_FAST, :][0, 0] + sa = state[States.STEER_ANGLE, :][0, 0] + + sR = state[States.STEER_RATIO, :][0, 0] + u, v = state[States.VELOCITY, :] + r = state[States.YAW_RATE, :][0, 0] + + A = sp.Matrix(np.zeros((2, 2))) + A[0, 0] = -(cF + cR) / (m * u) + A[0, 1] = -(cF * aF - cR * aR) / (m * u) - u + A[1, 0] = -(cF * aF - cR * aR) / (j * u) + A[1, 1] = -(cF * aF**2 + cR * aR**2) / (j * u) + + B = sp.Matrix(np.zeros((2, 1))) + B[0, 0] = cF / m / sR + B[1, 0] = (cF * aF) / j / sR + + x = sp.Matrix([v, r]) # lateral velocity, yaw rate + x_dot = A * x + B * (sa - angle_offset - angle_offset_fast) + + dt = sp.Symbol('dt') + state_dot = sp.Matrix(np.zeros((dim_state, 1))) + state_dot[States.VELOCITY.start + 1, 0] = x_dot[0] + state_dot[States.YAW_RATE.start, 0] = x_dot[1] + + # Basic descretization, 1st order integrator + # Can be pretty bad if dt is big + f_sym = state + dt * state_dot + + # + # Observation functions + # + obs_eqs = [ + [sp.Matrix([r]), ObservationKind.ROAD_FRAME_YAW_RATE, None], + [sp.Matrix([u, v]), ObservationKind.ROAD_FRAME_XY_SPEED, None], + [sp.Matrix([u]), ObservationKind.ROAD_FRAME_X_SPEED, None], + [sp.Matrix([sa]), ObservationKind.STEER_ANGLE, None], + [sp.Matrix([angle_offset_fast]), ObservationKind.ANGLE_OFFSET_FAST, None], + [sp.Matrix([sR]), ObservationKind.STEER_RATIO, None], + [sp.Matrix([x]), ObservationKind.STIFFNESS, None], + ] + + gen_code(generated_dir, name, f_sym, dt, state_sym, obs_eqs, dim_state, dim_state, global_vars=CarKalman.global_vars) + + def __init__(self, generated_dir, steer_ratio=15, stiffness_factor=1, angle_offset=0): # pylint: disable=super-init-not-called + dim_state = self.initial_x.shape[0] + dim_state_err = self.P_initial.shape[0] + x_init = self.initial_x + x_init[States.STEER_RATIO] = steer_ratio + x_init[States.STIFFNESS] = stiffness_factor + x_init[States.ANGLE_OFFSET] = angle_offset + + # init filter + self.filter = EKF_sym(generated_dir, self.name, self.Q, self.initial_x, self.P_initial, dim_state, dim_state_err, global_vars=self.global_vars) + + +if __name__ == "__main__": + generated_dir = sys.argv[2] + CarKalman.generate_code(generated_dir) diff --git a/selfdrive/locationd/models/constants.py b/selfdrive/locationd/models/constants.py new file mode 100644 index 00000000000000..ebe83186e4c67f --- /dev/null +++ b/selfdrive/locationd/models/constants.py @@ -0,0 +1,81 @@ +import os + +GENERATED_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), 'generated')) + +class ObservationKind: + UNKNOWN = 0 + NO_OBSERVATION = 1 + GPS_NED = 2 + ODOMETRIC_SPEED = 3 + PHONE_GYRO = 4 + GPS_VEL = 5 + PSEUDORANGE_GPS = 6 + PSEUDORANGE_RATE_GPS = 7 + SPEED = 8 + NO_ROT = 9 + PHONE_ACCEL = 10 + ORB_POINT = 11 + ECEF_POS = 12 + CAMERA_ODO_TRANSLATION = 13 + CAMERA_ODO_ROTATION = 14 + ORB_FEATURES = 15 + MSCKF_TEST = 16 + FEATURE_TRACK_TEST = 17 + LANE_PT = 18 + IMU_FRAME = 19 + PSEUDORANGE_GLONASS = 20 + PSEUDORANGE_RATE_GLONASS = 21 + PSEUDORANGE = 22 + PSEUDORANGE_RATE = 23 + ECEF_VEL = 31 + ECEF_ORIENTATION_FROM_GPS = 32 + + ROAD_FRAME_XY_SPEED = 24 # (x, y) [m/s] + ROAD_FRAME_YAW_RATE = 25 # [rad/s] + STEER_ANGLE = 26 # [rad] + ANGLE_OFFSET_FAST = 27 # [rad] + STIFFNESS = 28 # [-] + STEER_RATIO = 29 # [-] + ROAD_FRAME_X_SPEED = 30 # (x) [m/s] + + names = [ + 'Unknown', + 'No observation', + 'GPS NED', + 'Odometric speed', + 'Phone gyro', + 'GPS velocity', + 'GPS pseudorange', + 'GPS pseudorange rate', + 'Speed', + 'No rotation', + 'Phone acceleration', + 'ORB point', + 'ECEF pos', + 'camera odometric translation', + 'camera odometric rotation', + 'ORB features', + 'MSCKF test', + 'Feature track test', + 'Lane ecef point', + 'imu frame eulers', + 'GLONASS pseudorange', + 'GLONASS pseudorange rate', + + 'Road Frame x,y speed', + 'Road Frame yaw rate', + 'Steer Angle', + 'Fast Angle Offset', + 'Stiffness', + 'Steer Ratio', + ] + + @classmethod + def to_string(cls, kind): + return cls.names[kind] + + +SAT_OBS = [ObservationKind.PSEUDORANGE_GPS, + ObservationKind.PSEUDORANGE_RATE_GPS, + ObservationKind.PSEUDORANGE_GLONASS, + ObservationKind.PSEUDORANGE_RATE_GLONASS] diff --git a/selfdrive/locationd/models/live_kf.py b/selfdrive/locationd/models/live_kf.py new file mode 100755 index 00000000000000..d2153487b2fc79 --- /dev/null +++ b/selfdrive/locationd/models/live_kf.py @@ -0,0 +1,289 @@ +#!/usr/bin/env python3 + +import sys + +import numpy as np +import sympy as sp + +from selfdrive.locationd.models.constants import ObservationKind +from rednose.helpers.ekf_sym import EKF_sym, gen_code +from rednose.helpers.sympy_helpers import euler_rotate, quat_matrix_r, quat_rotate + +EARTH_GM = 3.986005e14 # m^3/s^2 (gravitational constant * mass of earth) + + +class States(): + ECEF_POS = slice(0, 3) # x, y and z in ECEF in meters + ECEF_ORIENTATION = slice(3, 7) # quat for pose of phone in ecef + ECEF_VELOCITY = slice(7, 10) # ecef velocity in m/s + ANGULAR_VELOCITY = slice(10, 13) # roll, pitch and yaw rates in device frame in radians/s + GYRO_BIAS = slice(13, 16) # roll, pitch and yaw biases + ODO_SCALE = slice(16, 17) # odometer scale + ACCELERATION = slice(17, 20) # Acceleration in device frame in m/s**2 + IMU_OFFSET = slice(20, 23) # imu offset angles in radians + + # Error-state has different slices because it is an ESKF + ECEF_POS_ERR = slice(0, 3) + ECEF_ORIENTATION_ERR = slice(3, 6) # euler angles for orientation error + ECEF_VELOCITY_ERR = slice(6, 9) + ANGULAR_VELOCITY_ERR = slice(9, 12) + GYRO_BIAS_ERR = slice(12, 15) + ODO_SCALE_ERR = slice(15, 16) + ACCELERATION_ERR = slice(16, 19) + IMU_OFFSET_ERR = slice(19, 22) + + +class LiveKalman(): + name = 'live' + + initial_x = np.array([-2.7e6, 4.2e6, 3.8e6, + 1, 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 1, + 0, 0, 0, + 0, 0, 0]) + + # state covariance + initial_P_diag = np.array([1e16, 1e16, 1e16, + 1e6, 1e6, 1e6, + 1e4, 1e4, 1e4, + 1**2, 1**2, 1**2, + 0.05**2, 0.05**2, 0.05**2, + 0.02**2, + 1**2, 1**2, 1**2, + (0.01)**2, (0.01)**2, (0.01)**2]) + + # process noise + Q = np.diag([0.03**2, 0.03**2, 0.03**2, + 0.001**2, 0.001*2, 0.001**2, + 0.01**2, 0.01**2, 0.01**2, + 0.1**2, 0.1**2, 0.1**2, + (0.005 / 100)**2, (0.005 / 100)**2, (0.005 / 100)**2, + (0.02 / 100)**2, + 3**2, 3**2, 3**2, + (0.05 / 60)**2, (0.05 / 60)**2, (0.05 / 60)**2]) + + @staticmethod + def generate_code(generated_dir): + name = LiveKalman.name + dim_state = LiveKalman.initial_x.shape[0] + dim_state_err = LiveKalman.initial_P_diag.shape[0] + + state_sym = sp.MatrixSymbol('state', dim_state, 1) + state = sp.Matrix(state_sym) + x, y, z = state[States.ECEF_POS, :] + q = state[States.ECEF_ORIENTATION, :] + v = state[States.ECEF_VELOCITY, :] + vx, vy, vz = v + omega = state[States.ANGULAR_VELOCITY, :] + vroll, vpitch, vyaw = omega + roll_bias, pitch_bias, yaw_bias = state[States.GYRO_BIAS, :] + odo_scale = state[States.ODO_SCALE, :][0, :] + acceleration = state[States.ACCELERATION, :] + imu_angles = state[States.IMU_OFFSET, :] + + dt = sp.Symbol('dt') + + # calibration and attitude rotation matrices + quat_rot = quat_rotate(*q) + + # Got the quat predict equations from here + # A New Quaternion-Based Kalman Filter for + # Real-Time Attitude Estimation Using the Two-Step + # Geometrically-Intuitive Correction Algorithm + A = 0.5 * sp.Matrix([[0, -vroll, -vpitch, -vyaw], + [vroll, 0, vyaw, -vpitch], + [vpitch, -vyaw, 0, vroll], + [vyaw, vpitch, -vroll, 0]]) + q_dot = A * q + + # Time derivative of the state as a function of state + state_dot = sp.Matrix(np.zeros((dim_state, 1))) + state_dot[States.ECEF_POS, :] = v + state_dot[States.ECEF_ORIENTATION, :] = q_dot + state_dot[States.ECEF_VELOCITY, 0] = quat_rot * acceleration + + # Basic descretization, 1st order intergrator + # Can be pretty bad if dt is big + f_sym = state + dt * state_dot + + state_err_sym = sp.MatrixSymbol('state_err', dim_state_err, 1) + state_err = sp.Matrix(state_err_sym) + quat_err = state_err[States.ECEF_ORIENTATION_ERR, :] + v_err = state_err[States.ECEF_VELOCITY_ERR, :] + omega_err = state_err[States.ANGULAR_VELOCITY_ERR, :] + acceleration_err = state_err[States.ACCELERATION_ERR, :] + + # Time derivative of the state error as a function of state error and state + quat_err_matrix = euler_rotate(quat_err[0], quat_err[1], quat_err[2]) + q_err_dot = quat_err_matrix * quat_rot * (omega + omega_err) + state_err_dot = sp.Matrix(np.zeros((dim_state_err, 1))) + state_err_dot[States.ECEF_POS_ERR, :] = v_err + state_err_dot[States.ECEF_ORIENTATION_ERR, :] = q_err_dot + state_err_dot[States.ECEF_VELOCITY_ERR, :] = quat_err_matrix * quat_rot * (acceleration + acceleration_err) + f_err_sym = state_err + dt * state_err_dot + + # Observation matrix modifier + H_mod_sym = sp.Matrix(np.zeros((dim_state, dim_state_err))) + H_mod_sym[States.ECEF_POS, States.ECEF_POS_ERR] = np.eye(States.ECEF_POS.stop - States.ECEF_POS.start) + H_mod_sym[States.ECEF_ORIENTATION, States.ECEF_ORIENTATION_ERR] = 0.5 * quat_matrix_r(state[3:7])[:, 1:] + H_mod_sym[States.ECEF_ORIENTATION.stop:, States.ECEF_ORIENTATION_ERR.stop:] = np.eye(dim_state - States.ECEF_ORIENTATION.stop) + + # these error functions are defined so that say there + # is a nominal x and true x: + # true x = err_function(nominal x, delta x) + # delta x = inv_err_function(nominal x, true x) + nom_x = sp.MatrixSymbol('nom_x', dim_state, 1) + true_x = sp.MatrixSymbol('true_x', dim_state, 1) + delta_x = sp.MatrixSymbol('delta_x', dim_state_err, 1) + + err_function_sym = sp.Matrix(np.zeros((dim_state, 1))) + delta_quat = sp.Matrix(np.ones((4))) + delta_quat[1:, :] = sp.Matrix(0.5 * delta_x[States.ECEF_ORIENTATION_ERR, :]) + err_function_sym[States.ECEF_POS, :] = sp.Matrix(nom_x[States.ECEF_POS, :] + delta_x[States.ECEF_POS_ERR, :]) + err_function_sym[States.ECEF_ORIENTATION, 0] = quat_matrix_r(nom_x[States.ECEF_ORIENTATION, 0]) * delta_quat + err_function_sym[States.ECEF_ORIENTATION.stop:, :] = sp.Matrix(nom_x[States.ECEF_ORIENTATION.stop:, :] + delta_x[States.ECEF_ORIENTATION_ERR.stop:, :]) + + inv_err_function_sym = sp.Matrix(np.zeros((dim_state_err, 1))) + inv_err_function_sym[States.ECEF_POS_ERR, 0] = sp.Matrix(-nom_x[States.ECEF_POS, 0] + true_x[States.ECEF_POS, 0]) + delta_quat = quat_matrix_r(nom_x[States.ECEF_ORIENTATION, 0]).T * true_x[States.ECEF_ORIENTATION, 0] + inv_err_function_sym[States.ECEF_ORIENTATION_ERR, 0] = sp.Matrix(2 * delta_quat[1:]) + inv_err_function_sym[States.ECEF_ORIENTATION_ERR.stop:, 0] = sp.Matrix(-nom_x[States.ECEF_ORIENTATION.stop:, 0] + true_x[States.ECEF_ORIENTATION.stop:, 0]) + + eskf_params = [[err_function_sym, nom_x, delta_x], + [inv_err_function_sym, nom_x, true_x], + H_mod_sym, f_err_sym, state_err_sym] + # + # Observation functions + # + #imu_rot = euler_rotate(*imu_angles) + h_gyro_sym = sp.Matrix([vroll + roll_bias, + vpitch + pitch_bias, + vyaw + yaw_bias]) + + pos = sp.Matrix([x, y, z]) + gravity = quat_rot.T * ((EARTH_GM / ((x**2 + y**2 + z**2)**(3.0 / 2.0))) * pos) + h_acc_sym = (gravity + acceleration) + h_phone_rot_sym = sp.Matrix([vroll, vpitch, vyaw]) + + speed = sp.sqrt(vx**2 + vy**2 + vz**2 + 1e-6) + h_speed_sym = sp.Matrix([speed * odo_scale]) + + h_pos_sym = sp.Matrix([x, y, z]) + h_vel_sym = sp.Matrix([vx, vy, vz]) + h_orientation_sym = q + h_imu_frame_sym = sp.Matrix(imu_angles) + + h_relative_motion = sp.Matrix(quat_rot.T * v) + + obs_eqs = [[h_speed_sym, ObservationKind.ODOMETRIC_SPEED, None], + [h_gyro_sym, ObservationKind.PHONE_GYRO, None], + [h_phone_rot_sym, ObservationKind.NO_ROT, None], + [h_acc_sym, ObservationKind.PHONE_ACCEL, None], + [h_pos_sym, ObservationKind.ECEF_POS, None], + [h_vel_sym, ObservationKind.ECEF_VEL, None], + [h_orientation_sym, ObservationKind.ECEF_ORIENTATION_FROM_GPS, None], + [h_relative_motion, ObservationKind.CAMERA_ODO_TRANSLATION, None], + [h_phone_rot_sym, ObservationKind.CAMERA_ODO_ROTATION, None], + [h_imu_frame_sym, ObservationKind.IMU_FRAME, None]] + + gen_code(generated_dir, name, f_sym, dt, state_sym, obs_eqs, dim_state, dim_state_err, eskf_params) + + def __init__(self, generated_dir): + self.dim_state = self.initial_x.shape[0] + self.dim_state_err = self.initial_P_diag.shape[0] + + self.obs_noise = {ObservationKind.ODOMETRIC_SPEED: np.atleast_2d(0.2**2), + ObservationKind.PHONE_GYRO: np.diag([0.025**2, 0.025**2, 0.025**2]), + ObservationKind.PHONE_ACCEL: np.diag([.5**2, .5**2, .5**2]), + ObservationKind.CAMERA_ODO_ROTATION: np.diag([0.05**2, 0.05**2, 0.05**2]), + ObservationKind.IMU_FRAME: np.diag([0.05**2, 0.05**2, 0.05**2]), + ObservationKind.NO_ROT: np.diag([0.00025**2, 0.00025**2, 0.00025**2]), + ObservationKind.ECEF_POS: np.diag([5**2, 5**2, 5**2]), + ObservationKind.ECEF_VEL: np.diag([.5**2, .5**2, .5**2]), + ObservationKind.ECEF_ORIENTATION_FROM_GPS: np.diag([.2**2, .2**2, .2**2, .2**2])} + + # init filter + self.filter = EKF_sym(generated_dir, self.name, self.Q, self.initial_x, np.diag(self.initial_P_diag), self.dim_state, self.dim_state_err, max_rewind_age=0.2) + + @property + def x(self): + return self.filter.state() + + @property + def t(self): + return self.filter.filter_time + + @property + def P(self): + return self.filter.covs() + + def rts_smooth(self, estimates): + return self.filter.rts_smooth(estimates, norm_quats=True) + + def init_state(self, state, covs_diag=None, covs=None, filter_time=None): + if covs_diag is not None: + P = np.diag(covs_diag) + elif covs is not None: + P = covs + else: + P = self.filter.covs() + self.filter.init_state(state, P, filter_time) + + def predict_and_observe(self, t, kind, meas, R=None): + if len(meas) > 0: + meas = np.atleast_2d(meas) + if kind == ObservationKind.CAMERA_ODO_TRANSLATION: + r = self.predict_and_update_odo_trans(meas, t, kind) + elif kind == ObservationKind.CAMERA_ODO_ROTATION: + r = self.predict_and_update_odo_rot(meas, t, kind) + elif kind == ObservationKind.ODOMETRIC_SPEED: + r = self.predict_and_update_odo_speed(meas, t, kind) + else: + if R is None: + R = self.get_R(kind, len(meas)) + elif len(R.shape) == 2: + R = R[None] + r = self.filter.predict_and_update_batch(t, kind, meas, R) + + # Normalize quats + quat_norm = np.linalg.norm(self.filter.x[3:7, 0]) + self.filter.x[States.ECEF_ORIENTATION, 0] = self.filter.x[States.ECEF_ORIENTATION, 0] / quat_norm + + return r + + def get_R(self, kind, n): + obs_noise = self.obs_noise[kind] + dim = obs_noise.shape[0] + R = np.zeros((n, dim, dim)) + for i in range(n): + R[i, :, :] = obs_noise + return R + + def predict_and_update_odo_speed(self, speed, t, kind): + z = np.array(speed) + R = np.zeros((len(speed), 1, 1)) + for i, _ in enumerate(z): + R[i, :, :] = np.diag([0.2**2]) + return self.filter.predict_and_update_batch(t, kind, z, R) + + def predict_and_update_odo_trans(self, trans, t, kind): + z = trans[:, :3] + R = np.zeros((len(trans), 3, 3)) + for i, _ in enumerate(z): + R[i, :, :] = np.diag(trans[i, 3:]**2) + return self.filter.predict_and_update_batch(t, kind, z, R) + + def predict_and_update_odo_rot(self, rot, t, kind): + z = rot[:, :3] + R = np.zeros((len(rot), 3, 3)) + for i, _ in enumerate(z): + R[i, :, :] = np.diag(rot[i, 3:]**2) + return self.filter.predict_and_update_batch(t, kind, z, R) + + +if __name__ == "__main__": + generated_dir = sys.argv[2] + LiveKalman.generate_code(generated_dir) diff --git a/selfdrive/locationd/params_learner.cc b/selfdrive/locationd/params_learner.cc deleted file mode 100644 index 1fc9061f1d33a8..00000000000000 --- a/selfdrive/locationd/params_learner.cc +++ /dev/null @@ -1,118 +0,0 @@ -#include -#include -#include - -#include -#include -#include "cereal/gen/cpp/log.capnp.h" -#include "cereal/gen/cpp/car.capnp.h" -#include "params_learner.h" - -// #define DEBUG - -template -T clip(const T& n, const T& lower, const T& upper) { - return std::max(lower, std::min(n, upper)); -} - -ParamsLearner::ParamsLearner(cereal::CarParams::Reader car_params, - double angle_offset, - double stiffness_factor, - double steer_ratio, - double learning_rate) : - ao(angle_offset * DEGREES_TO_RADIANS), - slow_ao(angle_offset * DEGREES_TO_RADIANS), - x(stiffness_factor), - sR(steer_ratio) { - - cF0 = car_params.getTireStiffnessFront(); - cR0 = car_params.getTireStiffnessRear(); - - l = car_params.getWheelbase(); - m = car_params.getMass(); - - aF = car_params.getCenterToFront(); - aR = l - aF; - - min_sr = MIN_SR * car_params.getSteerRatio(); - max_sr = MAX_SR * car_params.getSteerRatio(); - min_sr_th = MIN_SR_TH * car_params.getSteerRatio(); - max_sr_th = MAX_SR_TH * car_params.getSteerRatio(); - alpha1 = 0.01 * learning_rate; - alpha2 = 0.0005 * learning_rate; - alpha3 = 0.1 * learning_rate; - alpha4 = 1.0 * learning_rate; -} - -bool ParamsLearner::update(double psi, double u, double sa) { - if (u > 10.0 && fabs(sa) < (DEGREES_TO_RADIANS * 15.)) { - double ao_diff = 2.0*cF0*cR0*l*u*x*(1.0*cF0*cR0*l*u*x*(ao - sa) + psi*sR*(cF0*cR0*pow(l, 2)*x - m*pow(u, 2)*(aF*cF0 - aR*cR0)))/(pow(sR, 2)*pow(cF0*cR0*pow(l, 2)*x - m*pow(u, 2)*(aF*cF0 - aR*cR0), 2)); - double new_ao = ao - alpha1 * ao_diff; - - double slow_ao_diff = 2.0*cF0*cR0*l*u*x*(1.0*cF0*cR0*l*u*x*(slow_ao - sa) + psi*sR*(cF0*cR0*pow(l, 2)*x - m*pow(u, 2)*(aF*cF0 - aR*cR0)))/(pow(sR, 2)*pow(cF0*cR0*pow(l, 2)*x - m*pow(u, 2)*(aF*cF0 - aR*cR0), 2)); - double new_slow_ao = slow_ao - alpha2 * slow_ao_diff; - - double new_x = x - alpha3 * (-2.0*cF0*cR0*l*m*pow(u, 3)*(slow_ao - sa)*(aF*cF0 - aR*cR0)*(1.0*cF0*cR0*l*u*x*(slow_ao - sa) + psi*sR*(cF0*cR0*pow(l, 2)*x - m*pow(u, 2)*(aF*cF0 - aR*cR0)))/(pow(sR, 2)*pow(cF0*cR0*pow(l, 2)*x - m*pow(u, 2)*(aF*cF0 - aR*cR0), 3))); - double new_sR = sR - alpha4 * (-2.0*cF0*cR0*l*u*x*(slow_ao - sa)*(1.0*cF0*cR0*l*u*x*(slow_ao - sa) + psi*sR*(cF0*cR0*pow(l, 2)*x - m*pow(u, 2)*(aF*cF0 - aR*cR0)))/(pow(sR, 3)*pow(cF0*cR0*pow(l, 2)*x - m*pow(u, 2)*(aF*cF0 - aR*cR0), 2))); - - ao = new_ao; - slow_ao = new_slow_ao; - x = new_x; - //sR = new_sR; - } - -#ifdef DEBUG - std::cout << "Instant AO: " << (RADIANS_TO_DEGREES * ao) << "\tAverage AO: " << (RADIANS_TO_DEGREES * slow_ao); - std::cout << "\tStiffness: " << x << "\t sR: " << sR << std::endl; -#endif - - ao = clip(ao, -MAX_ANGLE_OFFSET, MAX_ANGLE_OFFSET); - slow_ao = clip(slow_ao, -MAX_ANGLE_OFFSET, MAX_ANGLE_OFFSET); - x = clip(x, MIN_STIFFNESS, MAX_STIFFNESS); - sR = clip(sR, min_sr, max_sr); - - bool valid = fabs(slow_ao) < MAX_ANGLE_OFFSET_TH; - valid = valid && sR > min_sr_th; - valid = valid && sR < max_sr_th; - return valid; -} - - -extern "C" { - void *params_learner_init(size_t len, char * params, double angle_offset, double stiffness_factor, double steer_ratio, double learning_rate) { - - auto amsg = kj::heapArray((len / sizeof(capnp::word)) + 1); - memcpy(amsg.begin(), params, len); - - capnp::FlatArrayMessageReader cmsg(amsg); - cereal::CarParams::Reader car_params = cmsg.getRoot(); - - ParamsLearner * p = new ParamsLearner(car_params, angle_offset, stiffness_factor, steer_ratio, learning_rate); - return (void*)p; - } - - bool params_learner_update(void * params_learner, double psi, double u, double sa) { - ParamsLearner * p = (ParamsLearner*) params_learner; - return p->update(psi, u, sa); - } - - double params_learner_get_ao(void * params_learner){ - ParamsLearner * p = (ParamsLearner*) params_learner; - return p->ao; - } - - double params_learner_get_x(void * params_learner){ - ParamsLearner * p = (ParamsLearner*) params_learner; - return p->x; - } - - double params_learner_get_slow_ao(void * params_learner){ - ParamsLearner * p = (ParamsLearner*) params_learner; - return p->slow_ao; - } - - double params_learner_get_sR(void * params_learner){ - ParamsLearner * p = (ParamsLearner*) params_learner; - return p->sR; - } -} diff --git a/selfdrive/locationd/params_learner.h b/selfdrive/locationd/params_learner.h deleted file mode 100644 index 4d97551b3b3a70..00000000000000 --- a/selfdrive/locationd/params_learner.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#define DEGREES_TO_RADIANS 0.017453292519943295 -#define RADIANS_TO_DEGREES (1.0 / DEGREES_TO_RADIANS) - -#define MAX_ANGLE_OFFSET (10.0 * DEGREES_TO_RADIANS) -#define MAX_ANGLE_OFFSET_TH (9.0 * DEGREES_TO_RADIANS) -#define MIN_STIFFNESS 0.5 -#define MAX_STIFFNESS 2.0 -#define MIN_SR 0.5 -#define MAX_SR 2.0 -#define MIN_SR_TH 0.55 -#define MAX_SR_TH 1.9 - -class ParamsLearner { - double cF0, cR0; - double aR, aF; - double l, m; - - double min_sr, max_sr, min_sr_th, max_sr_th; - double alpha1, alpha2, alpha3, alpha4; - -public: - double ao; - double slow_ao; - double x, sR; - - ParamsLearner(cereal::CarParams::Reader car_params, - double angle_offset, - double stiffness_factor, - double steer_ratio, - double learning_rate); - - bool update(double psi, double u, double sa); -}; diff --git a/selfdrive/locationd/paramsd.cc b/selfdrive/locationd/paramsd.cc deleted file mode 100644 index 5b71d8833df8c5..00000000000000 --- a/selfdrive/locationd/paramsd.cc +++ /dev/null @@ -1,189 +0,0 @@ -#include -#include -#include -#include - -#include "locationd_yawrate.h" -#include "cereal/gen/cpp/log.capnp.h" - -#include "common/swaglog.h" -#include "common/messaging.h" -#include "common/params.h" -#include "common/timing.h" -#include "params_learner.h" -#include "json11.hpp" - -const int num_polls = 3; - -int main(int argc, char *argv[]) { - auto ctx = zmq_ctx_new(); - auto controls_state_sock = sub_sock(ctx, "tcp://127.0.0.1:8007"); - auto sensor_events_sock = sub_sock(ctx, "tcp://127.0.0.1:8003"); - auto camera_odometry_sock = sub_sock(ctx, "tcp://127.0.0.1:8066"); - - auto live_parameters_sock = zsock_new_pub("@tcp://*:8064"); - assert(live_parameters_sock); - auto live_parameters_sock_raw = zsock_resolve(live_parameters_sock); - - int err; - Localizer localizer; - - zmq_pollitem_t polls[num_polls] = {{0}}; - polls[0].socket = controls_state_sock; - polls[0].events = ZMQ_POLLIN; - polls[1].socket = camera_odometry_sock; - polls[1].events = ZMQ_POLLIN; - polls[2].socket = sensor_events_sock; - polls[2].events = ZMQ_POLLIN; - - // Read car params - char *value; - size_t value_sz = 0; - - LOGW("waiting for params to set vehicle model"); - while (true) { - read_db_value(NULL, "CarParams", &value, &value_sz); - if (value_sz > 0) break; - usleep(100*1000); - } - LOGW("got %d bytes CarParams", value_sz); - - // make copy due to alignment issues - auto amsg = kj::heapArray((value_sz / sizeof(capnp::word)) + 1); - memcpy(amsg.begin(), value, value_sz); - free(value); - - capnp::FlatArrayMessageReader cmsg(amsg); - cereal::CarParams::Reader car_params = cmsg.getRoot(); - - // Read params from previous run - const int result = read_db_value(NULL, "LiveParameters", &value, &value_sz); - - std::string fingerprint = car_params.getCarFingerprint(); - std::string vin = car_params.getCarVin(); - double sR = car_params.getSteerRatio(); - double x = 1.0; - double ao = 0.0; - double posenet_invalid_count = 0; - - if (result == 0){ - auto str = std::string(value, value_sz); - free(value); - - std::string err; - auto json = json11::Json::parse(str, err); - if (json.is_null() || !err.empty()) { - std::string log = "Error parsing json: " + err; - LOGW(log.c_str()); - } else { - std::string new_fingerprint = json["carFingerprint"].string_value(); - std::string new_vin = json["carVin"].string_value(); - - if (fingerprint == new_fingerprint && vin == new_vin) { - std::string log = "Parameter starting with: " + str; - LOGW(log.c_str()); - - sR = json["steerRatio"].number_value(); - x = json["stiffnessFactor"].number_value(); - ao = json["angleOffsetAverage"].number_value(); - } - } - } - - ParamsLearner learner(car_params, ao, x, sR, 1.0); - - // Main loop - int save_counter = 0; - while (true){ - int ret = zmq_poll(polls, num_polls, 100); - - if (ret == 0){ - continue; - } else if (ret < 0){ - break; - } - - for (int i=0; i < num_polls; i++) { - if (polls[i].revents) { - zmq_msg_t msg; - err = zmq_msg_init(&msg); - assert(err == 0); - err = zmq_msg_recv(&msg, polls[i].socket, 0); - assert(err >= 0); - - // make copy due to alignment issues, will be freed on out of scope - auto amsg = kj::heapArray((zmq_msg_size(&msg) / sizeof(capnp::word)) + 1); - memcpy(amsg.begin(), zmq_msg_data(&msg), zmq_msg_size(&msg)); - zmq_msg_close(&msg); - - capnp::FlatArrayMessageReader capnp_msg(amsg); - cereal::Event::Reader event = capnp_msg.getRoot(); - - localizer.handle_log(event); - - auto which = event.which(); - // Throw vision failure if posenet and odometric speed too different - if (which == cereal::Event::CAMERA_ODOMETRY){ - if (std::abs(localizer.posenet_speed - localizer.car_speed) > std::max(0.4 * localizer.car_speed, 5.0)) { - posenet_invalid_count++; - } else { - posenet_invalid_count = 0; - } - } else if (which == cereal::Event::CONTROLS_STATE){ - save_counter++; - - double yaw_rate = -localizer.x[0]; - bool valid = learner.update(yaw_rate, localizer.car_speed, localizer.steering_angle); - - // TODO: Fix in replay - double sensor_data_age = localizer.controls_state_time - localizer.sensor_data_time; - - double angle_offset_degrees = RADIANS_TO_DEGREES * learner.ao; - double angle_offset_average_degrees = RADIANS_TO_DEGREES * learner.slow_ao; - - // Send parameters at 100 Hz - if (save_counter % 1 == 0){ - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto live_params = event.initLiveParameters(); - live_params.setValid(valid); - live_params.setYawRate(localizer.x[0]); - live_params.setGyroBias(localizer.x[1]); - live_params.setSensorValid(sensor_data_age < 5.0); - live_params.setAngleOffset(angle_offset_degrees); - live_params.setAngleOffsetAverage(angle_offset_average_degrees); - live_params.setStiffnessFactor(learner.x); - live_params.setSteerRatio(learner.sR); - live_params.setPosenetSpeed(localizer.posenet_speed); - live_params.setPosenetValid(posenet_invalid_count < 4); - - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - zmq_send(live_parameters_sock_raw, bytes.begin(), bytes.size(), ZMQ_DONTWAIT); - } - - // Save parameters every minute - if (save_counter % 6000 == 0) { - json11::Json json = json11::Json::object { - {"carVin", vin}, - {"carFingerprint", fingerprint}, - {"steerRatio", learner.sR}, - {"stiffnessFactor", learner.x}, - {"angleOffsetAverage", angle_offset_average_degrees}, - }; - - std::string out = json.dump(); - write_db_value(NULL, "LiveParameters", out.c_str(), out.length()); - } - } - } - } - } - - zmq_close(controls_state_sock); - zmq_close(sensor_events_sock); - zmq_close(camera_odometry_sock); - zmq_close(live_parameters_sock_raw); - return 0; -} diff --git a/selfdrive/locationd/paramsd.py b/selfdrive/locationd/paramsd.py new file mode 100755 index 00000000000000..c0afe169740d30 --- /dev/null +++ b/selfdrive/locationd/paramsd.py @@ -0,0 +1,152 @@ +#!/usr/bin/env python3 +import math + +import json +import numpy as np + +import cereal.messaging as messaging +from cereal import car, log +from common.params import Params, put_nonblocking +from selfdrive.locationd.models.car_kf import CarKalman, ObservationKind, States +from selfdrive.locationd.models.constants import GENERATED_DIR +from selfdrive.swaglog import cloudlog + +KalmanStatus = log.LiveLocationKalman.Status + + +class ParamsLearner: + def __init__(self, CP, steer_ratio, stiffness_factor, angle_offset): + self.kf = CarKalman(GENERATED_DIR, steer_ratio, stiffness_factor, angle_offset) + + self.kf.filter.set_mass(CP.mass) # pylint: disable=no-member + self.kf.filter.set_rotational_inertia(CP.rotationalInertia) # pylint: disable=no-member + self.kf.filter.set_center_to_front(CP.centerToFront) # pylint: disable=no-member + self.kf.filter.set_center_to_rear(CP.wheelbase - CP.centerToFront) # pylint: disable=no-member + self.kf.filter.set_stiffness_front(CP.tireStiffnessFront) # pylint: disable=no-member + self.kf.filter.set_stiffness_rear(CP.tireStiffnessRear) # pylint: disable=no-member + + self.active = False + + self.speed = 0 + self.steering_pressed = False + self.steering_angle = 0 + + self.valid = True + + def handle_log(self, t, which, msg): + if which == 'liveLocationKalman': + + yaw_rate = msg.angularVelocityCalibrated.value[2] + yaw_rate_std = msg.angularVelocityCalibrated.std[2] + + if self.active: + if msg.inputsOK and msg.posenetOK and msg.status == KalmanStatus.valid: + self.kf.predict_and_observe(t, + ObservationKind.ROAD_FRAME_YAW_RATE, + np.array([[[-yaw_rate]]]), + np.array([np.atleast_2d(yaw_rate_std**2)])) + self.kf.predict_and_observe(t, ObservationKind.ANGLE_OFFSET_FAST, np.array([[[0]]])) + + elif which == 'carState': + self.steering_angle = msg.steeringAngle + self.steering_pressed = msg.steeringPressed + self.speed = msg.vEgo + + in_linear_region = abs(self.steering_angle) < 45 or not self.steering_pressed + self.active = self.speed > 5 and in_linear_region + + if self.active: + self.kf.predict_and_observe(t, ObservationKind.STEER_ANGLE, np.array([[[math.radians(msg.steeringAngle)]]])) + self.kf.predict_and_observe(t, ObservationKind.ROAD_FRAME_X_SPEED, np.array([[[self.speed]]])) + + if not self.active: + # Reset time when stopped so uncertainty doesn't grow + self.kf.filter.filter_time = t + self.kf.filter.reset_rewind() + + +def main(sm=None, pm=None): + if sm is None: + sm = messaging.SubMaster(['liveLocationKalman', 'carState'], poll=['liveLocationKalman']) + if pm is None: + pm = messaging.PubMaster(['liveParameters']) + + params_reader = Params() + # wait for stats about the car to come in from controls + cloudlog.info("paramsd is waiting for CarParams") + CP = car.CarParams.from_bytes(params_reader.get("CarParams", block=True)) + cloudlog.info("paramsd got CarParams") + + min_sr, max_sr = 0.5 * CP.steerRatio, 2.0 * CP.steerRatio + + params = params_reader.get("LiveParameters") + + # Check if car model matches + if params is not None: + params = json.loads(params) + if params.get('carFingerprint', None) != CP.carFingerprint: + cloudlog.info("Parameter learner found parameters for wrong car.") + params = None + + if (params is not None) and not all(( + abs(params['angleOffsetAverage']) < 10.0, + min_sr <= params['steerRatio'] <= max_sr)): + cloudlog.info(f"Invalid starting values found {params}") + params = None + + if params is None: + params = { + 'carFingerprint': CP.carFingerprint, + 'steerRatio': CP.steerRatio, + 'stiffnessFactor': 1.0, + 'angleOffsetAverage': 0.0, + } + cloudlog.info("Parameter learner resetting to default values") + + # When driving in wet conditions the stiffness can go down, and then be too low on the next drive + # Without a way to detect this we have to reset the stiffness every drive + params['stiffnessFactor'] = 1.0 + + learner = ParamsLearner(CP, params['steerRatio'], params['stiffnessFactor'], math.radians(params['angleOffsetAverage'])) + + while True: + sm.update() + + for which, updated in sm.updated.items(): + if updated: + t = sm.logMonoTime[which] * 1e-9 + learner.handle_log(t, which, sm[which]) + + if sm.updated['liveLocationKalman']: + msg = messaging.new_message('liveParameters') + msg.logMonoTime = sm.logMonoTime['carState'] + + msg.liveParameters.posenetValid = True + msg.liveParameters.sensorValid = True + + x = learner.kf.x + msg.liveParameters.steerRatio = float(x[States.STEER_RATIO]) + msg.liveParameters.stiffnessFactor = float(x[States.STIFFNESS]) + msg.liveParameters.angleOffsetAverage = math.degrees(x[States.ANGLE_OFFSET]) + msg.liveParameters.angleOffset = msg.liveParameters.angleOffsetAverage + math.degrees(x[States.ANGLE_OFFSET_FAST]) + msg.liveParameters.valid = all(( + abs(msg.liveParameters.angleOffsetAverage) < 10.0, + abs(msg.liveParameters.angleOffset) < 10.0, + 0.2 <= msg.liveParameters.stiffnessFactor <= 5.0, + min_sr <= msg.liveParameters.steerRatio <= max_sr, + )) + + if sm.frame % 1200 == 0: # once a minute + params = { + 'carFingerprint': CP.carFingerprint, + 'steerRatio': msg.liveParameters.steerRatio, + 'stiffnessFactor': msg.liveParameters.stiffnessFactor, + 'angleOffsetAverage': msg.liveParameters.angleOffsetAverage, + } + put_nonblocking("LiveParameters", json.dumps(params)) + + pm.send('liveParameters', msg) + + +if __name__ == "__main__": + main() diff --git a/selfdrive/locationd/test/ci_test.py b/selfdrive/locationd/test/ci_test.py deleted file mode 100755 index 7e151093b4a73c..00000000000000 --- a/selfdrive/locationd/test/ci_test.py +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env python2 -import subprocess -import os -import sys -import argparse -import tempfile - -from selfdrive.locationd.test.ubloxd_py_test import parser_test -from selfdrive.locationd.test.ubloxd_regression_test import compare_results - - -def mkdirs_exists_ok(path): - try: - os.makedirs(path) - except OSError: - if not os.path.isdir(path): - raise - - -def main(args): - cur_dir = os.path.dirname(os.path.realpath(__file__)) - ubloxd_dir = os.path.join(cur_dir, '../') - - cc_output_dir = os.path.join(args.output_dir, 'cc') - mkdirs_exists_ok(cc_output_dir) - - py_output_dir = os.path.join(args.output_dir, 'py') - mkdirs_exists_ok(py_output_dir) - - archive_file = os.path.join(cur_dir, args.stream_gz_file) - - try: - print('Extracting stream file') - subprocess.check_call(['tar', 'zxf', archive_file], cwd=tempfile.gettempdir()) - stream_file_path = os.path.join(tempfile.gettempdir(), 'ubloxRaw.stream') - - if not os.path.isfile(stream_file_path): - print('Extract file failed') - sys.exit(-3) - - print('Compiling test app...') - subprocess.check_call(["make", "ubloxd_test"], cwd=ubloxd_dir) - - print('Run regression test - CC parser...') - if args.valgrind: - subprocess.check_call(["valgrind", "--leak-check=full", os.path.join(ubloxd_dir, 'ubloxd_test'), stream_file_path, cc_output_dir]) - else: - subprocess.check_call([os.path.join(ubloxd_dir, 'ubloxd_test'), stream_file_path, cc_output_dir]) - - print('Running regression test - py parser...') - parser_test(stream_file_path, py_output_dir) - - print('Running regression test - compare result...') - r = compare_results(cc_output_dir, py_output_dir) - - print('All done!') - - subprocess.check_call(["rm", stream_file_path]) - subprocess.check_call(["rm", '-rf', cc_output_dir]) - subprocess.check_call(["rm", '-rf', py_output_dir]) - sys.exit(r) - - except subprocess.CalledProcessError as e: - print('CI test failed with {}'.format(e.returncode)) - sys.exit(e.returncode) - - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Ubloxd CI test", - formatter_class=argparse.ArgumentDefaultsHelpFormatter) - - parser.add_argument("stream_gz_file", nargs='?', default='ubloxRaw.tar.gz', - help="UbloxRaw data stream zip file") - - parser.add_argument("output_dir", nargs='?', default='out', - help="Output events temp directory") - - parser.add_argument("--valgrind", default=False, action='store_true', - help="Run in valgrind") - - args = parser.parse_args() - main(args) diff --git a/selfdrive/locationd/test/ephemeris.py b/selfdrive/locationd/test/ephemeris.py deleted file mode 100644 index dd8155e19a4507..00000000000000 --- a/selfdrive/locationd/test/ephemeris.py +++ /dev/null @@ -1,137 +0,0 @@ -def GET_FIELD_U(w, nb, pos): - return (((w) >> (pos)) & ((1 << (nb)) - 1)) - - -def twos_complement(v, nb): - sign = v >> (nb - 1) - value = v - if sign != 0: - value = value - (1 << nb) - return value - - -def GET_FIELD_S(w, nb, pos): - v = GET_FIELD_U(w, nb, pos) - return twos_complement(v, nb) - - -def extract_uint8(v, b): - return (v >> (8 * (3 - b))) & 255 - -def extract_int8(v, b): - value = extract_uint8(v, b) - if value > 127: - value -= 256 - return value - -class EphemerisData: - '''container for parsing a AID_EPH message - Thanks to Sylvain Munaut - http://cgit.osmocom.org/cgit/osmocom-lcs/tree/gps.c -on of this parser - - See IS-GPS-200F.pdf Table 20-III for the field meanings, scaling factors and - field widths - ''' - - def __init__(self, svId, subframes): - from math import pow - self.svId = svId - week_no = GET_FIELD_U(subframes[1][2+0], 10, 20) - # code_on_l2 = GET_FIELD_U(subframes[1][0], 2, 12) - # sv_ura = GET_FIELD_U(subframes[1][0], 4, 8) - # sv_health = GET_FIELD_U(subframes[1][0], 6, 2) - # l2_p_flag = GET_FIELD_U(subframes[1][1], 1, 23) - t_gd = GET_FIELD_S(subframes[1][2+4], 8, 6) - iodc = (GET_FIELD_U(subframes[1][2+0], 2, 6) << 8) | GET_FIELD_U( - subframes[1][2+5], 8, 22) - - t_oc = GET_FIELD_U(subframes[1][2+5], 16, 6) - a_f2 = GET_FIELD_S(subframes[1][2+6], 8, 22) - a_f1 = GET_FIELD_S(subframes[1][2+6], 16, 6) - a_f0 = GET_FIELD_S(subframes[1][2+7], 22, 8) - - c_rs = GET_FIELD_S(subframes[2][2+0], 16, 6) - delta_n = GET_FIELD_S(subframes[2][2+1], 16, 14) - m_0 = (GET_FIELD_S(subframes[2][2+1], 8, 6) << 24) | GET_FIELD_U( - subframes[2][2+2], 24, 6) - c_uc = GET_FIELD_S(subframes[2][2+3], 16, 14) - e = (GET_FIELD_U(subframes[2][2+3], 8, 6) << 24) | GET_FIELD_U(subframes[2][2+4], 24, 6) - c_us = GET_FIELD_S(subframes[2][2+5], 16, 14) - a_powhalf = (GET_FIELD_U(subframes[2][2+5], 8, 6) << 24) | GET_FIELD_U( - subframes[2][2+6], 24, 6) - t_oe = GET_FIELD_U(subframes[2][2+7], 16, 14) - # fit_flag = GET_FIELD_U(subframes[2][7], 1, 7) - - c_ic = GET_FIELD_S(subframes[3][2+0], 16, 14) - omega_0 = (GET_FIELD_S(subframes[3][2+0], 8, 6) << 24) | GET_FIELD_U( - subframes[3][2+1], 24, 6) - c_is = GET_FIELD_S(subframes[3][2+2], 16, 14) - i_0 = (GET_FIELD_S(subframes[3][2+2], 8, 6) << 24) | GET_FIELD_U( - subframes[3][2+3], 24, 6) - c_rc = GET_FIELD_S(subframes[3][2+4], 16, 14) - w = (GET_FIELD_S(subframes[3][2+4], 8, 6) << 24) | GET_FIELD_U(subframes[3][5], 24, 6) - omega_dot = GET_FIELD_S(subframes[3][2+6], 24, 6) - idot = GET_FIELD_S(subframes[3][2+7], 14, 8) - - self._rsvd1 = GET_FIELD_U(subframes[1][2+1], 23, 6) - self._rsvd2 = GET_FIELD_U(subframes[1][2+2], 24, 6) - self._rsvd3 = GET_FIELD_U(subframes[1][2+3], 24, 6) - self._rsvd4 = GET_FIELD_U(subframes[1][2+4], 16, 14) - self.aodo = GET_FIELD_U(subframes[2][2+7], 5, 8) - - # Definition of Pi used in the GPS coordinate system - gpsPi = 3.1415926535898 - - # now form variables in radians, meters and seconds etc - self.Tgd = t_gd * pow(2, -31) - self.A = pow(a_powhalf * pow(2, -19), 2.0) - self.cic = c_ic * pow(2, -29) - self.cis = c_is * pow(2, -29) - self.crc = c_rc * pow(2, -5) - self.crs = c_rs * pow(2, -5) - self.cuc = c_uc * pow(2, -29) - self.cus = c_us * pow(2, -29) - self.deltaN = delta_n * pow(2, -43) * gpsPi - self.ecc = e * pow(2, -33) - self.i0 = i_0 * pow(2, -31) * gpsPi - self.idot = idot * pow(2, -43) * gpsPi - self.M0 = m_0 * pow(2, -31) * gpsPi - self.omega = w * pow(2, -31) * gpsPi - self.omega_dot = omega_dot * pow(2, -43) * gpsPi - self.omega0 = omega_0 * pow(2, -31) * gpsPi - self.toe = t_oe * pow(2, 4) - - # clock correction information - self.toc = t_oc * pow(2, 4) - self.gpsWeek = week_no - self.af0 = a_f0 * pow(2, -31) - self.af1 = a_f1 * pow(2, -43) - self.af2 = a_f2 * pow(2, -55) - - iode1 = GET_FIELD_U(subframes[2][2+0], 8, 22) - iode2 = GET_FIELD_U(subframes[3][2+7], 8, 22) - self.valid = (iode1 == iode2) and (iode1 == (iodc & 0xff)) - self.iode = iode1 - - if GET_FIELD_U(subframes[4][2+0], 6, 22) == 56 and \ - GET_FIELD_U(subframes[4][2+0], 2, 28) == 1 and \ - GET_FIELD_U(subframes[5][2+0], 2, 28) == 1: - a0 = GET_FIELD_S(subframes[4][2], 8, 14) * pow(2, -30) - a1 = GET_FIELD_S(subframes[4][2], 8, 6) * pow(2, -27) - a2 = GET_FIELD_S(subframes[4][3], 8, 22) * pow(2, -24) - a3 = GET_FIELD_S(subframes[4][3], 8, 14) * pow(2, -24) - b0 = GET_FIELD_S(subframes[4][3], 8, 6) * pow(2, 11) - b1 = GET_FIELD_S(subframes[4][4], 8, 22) * pow(2, 14) - b2 = GET_FIELD_S(subframes[4][4], 8, 14) * pow(2, 16) - b3 = GET_FIELD_S(subframes[4][4], 8, 6) * pow(2, 16) - - self.ionoAlpha = [a0, a1, a2, a3] - self.ionoBeta = [b0, b1, b2, b3] - self.ionoCoeffsValid = True - else: - self.ionoAlpha = [] - self.ionoBeta = [] - self.ionoCoeffsValid = False - - diff --git a/selfdrive/locationd/test/test_params_learner.py b/selfdrive/locationd/test/test_params_learner.py deleted file mode 100755 index b29f591e7e57bd..00000000000000 --- a/selfdrive/locationd/test/test_params_learner.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env python - -import numpy as np -import unittest - -from selfdrive.car.honda.interface import CarInterface -from selfdrive.car.honda.values import CAR -from selfdrive.controls.lib.vehicle_model import VehicleModel -from selfdrive.locationd.liblocationd_py import liblocationd # pylint: disable=no-name-in-module, import-error - - -class TestParamsLearner(unittest.TestCase): - def setUp(self): - - self.CP = CarInterface.get_params(CAR.CIVIC, {}) - bts = self.CP.to_bytes() - - self.params_learner = liblocationd.params_learner_init(len(bts), bts, 0.0, 1.0, self.CP.steerRatio, 1.0) - - def test_convergence(self): - # Setup vehicle model with wrong parameters - VM_sim = VehicleModel(self.CP) - x_target = 0.75 - sr_target = self.CP.steerRatio - 0.5 - ao_target = -1.0 - VM_sim.update_params(x_target, sr_target) - - # Run simulation - times = np.arange(0, 15*3600, 0.01) - angle_offset = np.radians(ao_target) - steering_angles = np.radians(10 * np.sin(2 * np.pi * times / 100.)) + angle_offset - speeds = 10 * np.sin(2 * np.pi * times / 1000.) + 25 - - for i, t in enumerate(times): - u = speeds[i] - sa = steering_angles[i] - psi = VM_sim.yaw_rate(sa - angle_offset, u) - liblocationd.params_learner_update(self.params_learner, psi, u, sa) - - # Verify learned parameters - sr = liblocationd.params_learner_get_sR(self.params_learner) - ao_slow = np.degrees(liblocationd.params_learner_get_slow_ao(self.params_learner)) - x = liblocationd.params_learner_get_x(self.params_learner) - self.assertAlmostEqual(x_target, x, places=1) - self.assertAlmostEqual(ao_target, ao_slow, places=1) - self.assertAlmostEqual(sr_target, sr, places=1) - - - - - -if __name__ == "__main__": - unittest.main() diff --git a/selfdrive/locationd/test/ublox.py b/selfdrive/locationd/test/ublox.py deleted file mode 100644 index 175316fd8144d6..00000000000000 --- a/selfdrive/locationd/test/ublox.py +++ /dev/null @@ -1,996 +0,0 @@ -#!/usr/bin/env python -''' -UBlox binary protocol handling - -Copyright Andrew Tridgell, October 2012 -Released under GNU GPL version 3 or later - -WARNING: This code has originally intended for -ublox version 7, it has been adapted to work -for ublox version 8, not all functions may work. -''' - -import struct -import time, os - -# protocol constants -PREAMBLE1 = 0xb5 -PREAMBLE2 = 0x62 - -# message classes -CLASS_NAV = 0x01 -CLASS_RXM = 0x02 -CLASS_INF = 0x04 -CLASS_ACK = 0x05 -CLASS_CFG = 0x06 -CLASS_MON = 0x0A -CLASS_AID = 0x0B -CLASS_TIM = 0x0D -CLASS_ESF = 0x10 - -# ACK messages -MSG_ACK_NACK = 0x00 -MSG_ACK_ACK = 0x01 - -# NAV messages -MSG_NAV_POSECEF = 0x1 -MSG_NAV_POSLLH = 0x2 -MSG_NAV_STATUS = 0x3 -MSG_NAV_DOP = 0x4 -MSG_NAV_SOL = 0x6 -MSG_NAV_PVT = 0x7 -MSG_NAV_POSUTM = 0x8 -MSG_NAV_VELNED = 0x12 -MSG_NAV_VELECEF = 0x11 -MSG_NAV_TIMEGPS = 0x20 -MSG_NAV_TIMEUTC = 0x21 -MSG_NAV_CLOCK = 0x22 -MSG_NAV_SVINFO = 0x30 -MSG_NAV_AOPSTATUS = 0x60 -MSG_NAV_DGPS = 0x31 -MSG_NAV_DOP = 0x04 -MSG_NAV_EKFSTATUS = 0x40 -MSG_NAV_SBAS = 0x32 -MSG_NAV_SOL = 0x06 - -# RXM messages -MSG_RXM_RAW = 0x15 -MSG_RXM_SFRB = 0x11 -MSG_RXM_SFRBX = 0x13 -MSG_RXM_SVSI = 0x20 -MSG_RXM_EPH = 0x31 -MSG_RXM_ALM = 0x30 -MSG_RXM_PMREQ = 0x41 - -# AID messages -MSG_AID_ALM = 0x30 -MSG_AID_EPH = 0x31 -MSG_AID_ALPSRV = 0x32 -MSG_AID_AOP = 0x33 -MSG_AID_DATA = 0x10 -MSG_AID_ALP = 0x50 -MSG_AID_DATA = 0x10 -MSG_AID_HUI = 0x02 -MSG_AID_INI = 0x01 -MSG_AID_REQ = 0x00 - -# CFG messages -MSG_CFG_PRT = 0x00 -MSG_CFG_ANT = 0x13 -MSG_CFG_DAT = 0x06 -MSG_CFG_EKF = 0x12 -MSG_CFG_ESFGWT = 0x29 -MSG_CFG_CFG = 0x09 -MSG_CFG_USB = 0x1b -MSG_CFG_RATE = 0x08 -MSG_CFG_SET_RATE = 0x01 -MSG_CFG_NAV5 = 0x24 -MSG_CFG_FXN = 0x0E -MSG_CFG_INF = 0x02 -MSG_CFG_ITFM = 0x39 -MSG_CFG_MSG = 0x01 -MSG_CFG_NAVX5 = 0x23 -MSG_CFG_NMEA = 0x17 -MSG_CFG_NVS = 0x22 -MSG_CFG_PM2 = 0x3B -MSG_CFG_PM = 0x32 -MSG_CFG_RINV = 0x34 -MSG_CFG_RST = 0x04 -MSG_CFG_RXM = 0x11 -MSG_CFG_SBAS = 0x16 -MSG_CFG_TMODE2 = 0x3D -MSG_CFG_TMODE = 0x1D -MSG_CFG_TPS = 0x31 -MSG_CFG_TP = 0x07 -MSG_CFG_GNSS = 0x3E -MSG_CFG_ODO = 0x1E - -# ESF messages -MSG_ESF_MEAS = 0x02 -MSG_ESF_STATUS = 0x10 - -# INF messages -MSG_INF_DEBUG = 0x04 -MSG_INF_ERROR = 0x00 -MSG_INF_NOTICE = 0x02 -MSG_INF_TEST = 0x03 -MSG_INF_WARNING = 0x01 - -# MON messages -MSG_MON_SCHD = 0x01 -MSG_MON_HW = 0x09 -MSG_MON_HW2 = 0x0B -MSG_MON_IO = 0x02 -MSG_MON_MSGPP = 0x06 -MSG_MON_RXBUF = 0x07 -MSG_MON_RXR = 0x21 -MSG_MON_TXBUF = 0x08 -MSG_MON_VER = 0x04 - -# TIM messages -MSG_TIM_TP = 0x01 -MSG_TIM_TM2 = 0x03 -MSG_TIM_SVIN = 0x04 -MSG_TIM_VRFY = 0x06 - -# port IDs -PORT_DDC = 0 -PORT_SERIAL1 = 1 -PORT_SERIAL2 = 2 -PORT_USB = 3 -PORT_SPI = 4 - -# dynamic models -DYNAMIC_MODEL_PORTABLE = 0 -DYNAMIC_MODEL_STATIONARY = 2 -DYNAMIC_MODEL_PEDESTRIAN = 3 -DYNAMIC_MODEL_AUTOMOTIVE = 4 -DYNAMIC_MODEL_SEA = 5 -DYNAMIC_MODEL_AIRBORNE1G = 6 -DYNAMIC_MODEL_AIRBORNE2G = 7 -DYNAMIC_MODEL_AIRBORNE4G = 8 - -#reset items -RESET_HOT = 0 -RESET_WARM = 1 -RESET_COLD = 0xFFFF - -RESET_HW = 0 -RESET_SW = 1 -RESET_SW_GPS = 2 -RESET_HW_GRACEFUL = 4 -RESET_GPS_STOP = 8 -RESET_GPS_START = 9 - - -class UBloxError(Exception): - '''Ublox error class''' - - def __init__(self, msg): - Exception.__init__(self, msg) - self.message = msg - - -class UBloxAttrDict(dict): - '''allow dictionary members as attributes''' - - def __init__(self): - dict.__init__(self) - - def __getattr__(self, name): - try: - return self.__getitem__(name) - except KeyError: - raise AttributeError(name) - - def __setattr__(self, name, value): - if name in self.__dict__: - # allow set on normal attributes - dict.__setattr__(self, name, value) - else: - self.__setitem__(name, value) - - -def ArrayParse(field): - '''parse an array descriptor''' - arridx = field.find('[') - if arridx == -1: - return (field, -1) - alen = int(field[arridx + 1:-1]) - fieldname = field[:arridx] - return (fieldname, alen) - - -class UBloxDescriptor: - '''class used to describe the layout of a UBlox message''' - - def __init__(self, - name, - msg_format, - fields=None, - count_field=None, - format2=None, - fields2=None): - if fields is None: - fields = [] - - self.name = name - self.msg_format = msg_format - self.fields = fields - self.count_field = count_field - self.format2 = format2 - self.fields2 = fields2 - - def unpack(self, msg): - '''unpack a UBloxMessage, creating the .fields and ._recs attributes in msg''' - msg._fields = {} - - # unpack main message blocks. A comm - formats = self.msg_format.split(',') - buf = msg._buf[6:-2] - count = 0 - msg._recs = [] - fields = self.fields[:] - - for fmt in formats: - size1 = struct.calcsize(fmt) - if size1 > len(buf): - raise UBloxError("%s INVALID_SIZE1=%u" % (self.name, len(buf))) - f1 = list(struct.unpack(fmt, buf[:size1])) - i = 0 - while i < len(f1): - field = fields.pop(0) - (fieldname, alen) = ArrayParse(field) - if alen == -1: - msg._fields[fieldname] = f1[i] - if self.count_field == fieldname: - count = int(f1[i]) - i += 1 - else: - msg._fields[fieldname] = [0] * alen - for a in range(alen): - msg._fields[fieldname][a] = f1[i] - i += 1 - buf = buf[size1:] - if len(buf) == 0: - break - - if self.count_field == '_remaining': - count = len(buf) // struct.calcsize(self.format2) - - if count == 0: - msg._unpacked = True - if len(buf) != 0: - raise UBloxError("EXTRA_BYTES=%u" % len(buf)) - return - - size2 = struct.calcsize(self.format2) - for c in range(count): - r = UBloxAttrDict() - if size2 > len(buf): - raise UBloxError("INVALID_SIZE=%u, " % len(buf)) - f2 = list(struct.unpack(self.format2, buf[:size2])) - for i in range(len(self.fields2)): - r[self.fields2[i]] = f2[i] - buf = buf[size2:] - msg._recs.append(r) - if len(buf) != 0: - raise UBloxError("EXTRA_BYTES=%u" % len(buf)) - msg._unpacked = True - - def pack(self, msg, msg_class=None, msg_id=None): - '''pack a UBloxMessage from the .fields and ._recs attributes in msg''' - f1 = [] - if msg_class is None: - msg_class = msg.msg_class() - if msg_id is None: - msg_id = msg.msg_id() - msg._buf = '' - - fields = self.fields[:] - for f in fields: - (fieldname, alen) = ArrayParse(f) - if not fieldname in msg._fields: - break - if alen == -1: - f1.append(msg._fields[fieldname]) - else: - for a in range(alen): - f1.append(msg._fields[fieldname][a]) - try: - # try full length message - fmt = self.msg_format.replace(',', '') - msg._buf = struct.pack(fmt, *tuple(f1)) - except Exception: - # try without optional part - fmt = self.msg_format.split(',')[0] - msg._buf = struct.pack(fmt, *tuple(f1)) - - length = len(msg._buf) - if msg._recs: - length += len(msg._recs) * struct.calcsize(self.format2) - header = struct.pack('= level: - print(msg) - - def unpack(self): - '''unpack a message''' - if not self.valid(): - raise UBloxError('INVALID MESSAGE') - type = self.msg_type() - if not type in msg_types: - raise UBloxError('Unknown message %s length=%u' % (str(type), len(self._buf))) - msg_types[type].unpack(self) - return self._fields, self._recs - - def pack(self): - '''pack a message''' - if not self.valid(): - raise UBloxError('INVALID MESSAGE') - type = self.msg_type() - if not type in msg_types: - raise UBloxError('Unknown message %s' % str(type)) - msg_types[type].pack(self) - - def name(self): - '''return the short string name for a message''' - if not self.valid(): - raise UBloxError('INVALID MESSAGE') - type = self.msg_type() - if not type in msg_types: - raise UBloxError('Unknown message %s length=%u' % (str(type), len(self._buf))) - return msg_types[type].name - - def msg_class(self): - '''return the message class''' - return ord(self._buf[2]) - - def msg_id(self): - '''return the message id within the class''' - return ord(self._buf[3]) - - def msg_type(self): - '''return the message type tuple (class, id)''' - return (self.msg_class(), self.msg_id()) - - def msg_length(self): - '''return the payload length''' - (payload_length, ) = struct.unpack(' 0 and ord(self._buf[0]) != PREAMBLE1: - return False - if len(self._buf) > 1 and ord(self._buf[1]) != PREAMBLE2: - self.debug(1, "bad pre2") - return False - if self.needed_bytes() == 0 and not self.valid(): - if len(self._buf) > 8: - self.debug(1, "bad checksum len=%u needed=%u" % (len(self._buf), - self.needed_bytes())) - else: - self.debug(1, "bad len len=%u needed=%u" % (len(self._buf), self.needed_bytes())) - return False - return True - - def add(self, bytes): - '''add some bytes to a message''' - self._buf += bytes - while not self.valid_so_far() and len(self._buf) > 0: - '''handle corrupted streams''' - self._buf = self._buf[1:] - if self.needed_bytes() < 0: - self._buf = "" - - def checksum(self, data=None): - '''return a checksum tuple for a message''' - if data is None: - data = self._buf[2:-2] - #cs = 0 - ck_a = 0 - ck_b = 0 - for i in data: - ck_a = (ck_a + ord(i)) & 0xFF - ck_b = (ck_b + ck_a) & 0xFF - return (ck_a, ck_b) - - def valid_checksum(self): - '''check if the checksum is OK''' - (ck_a, ck_b) = self.checksum() - #d = self._buf[2:-2] - (ck_a2, ck_b2) = struct.unpack('= 8 and self.needed_bytes() == 0 and self.valid_checksum() - - -class UBlox: - '''main UBlox control class. - - port can be a file (for reading only) or a serial device - ''' - - def __init__(self, port, baudrate=115200, timeout=0, panda=False, grey=False): - - self.serial_device = port - self.baudrate = baudrate - self.use_sendrecv = False - self.read_only = False - self.debug_level = 0 - - if panda: - from panda import Panda, PandaSerial - - self.panda = Panda() - - # resetting U-Blox module - self.panda.set_esp_power(0) - time.sleep(0.1) - self.panda.set_esp_power(1) - time.sleep(0.5) - - # can't set above 9600 now... - self.baudrate = 9600 - self.dev = PandaSerial(self.panda, 1, self.baudrate) - - self.baudrate = 460800 - print "upping baud:",self.baudrate - self.send_nmea("$PUBX,41,1,0007,0003,%u,0" % self.baudrate) - time.sleep(0.1) - - self.dev = PandaSerial(self.panda, 1, self.baudrate) - elif grey: - from selfdrive.services import service_list - import selfdrive.messaging as messaging - - class BoarddSerial(object): - def __init__(self): - self.ubloxRaw = messaging.sub_sock(service_list['ubloxRaw'].port) - self.buf = "" - - def read(self, n): - for msg in messaging.drain_sock(self.ubloxRaw, len(self.buf) < n): - self.buf += msg.ubloxRaw - ret = self.buf[:n] - self.buf = self.buf[n:] - return ret - - - def write(self, dat): - pass - - self.dev = BoarddSerial() - else: - if self.serial_device.startswith("tcp:"): - import socket - a = self.serial_device.split(':') - destination_addr = (a[1], int(a[2])) - self.dev = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.dev.connect(destination_addr) - self.dev.setblocking(1) - self.dev.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1) - self.use_sendrecv = True - elif os.path.isfile(self.serial_device): - self.read_only = True - self.dev = open(self.serial_device, mode='rb') - else: - import serial - self.dev = serial.Serial( - self.serial_device, - baudrate=self.baudrate, - dsrdtr=False, - rtscts=False, - xonxoff=False, - timeout=timeout) - - self.logfile = None - self.log = None - self.preferred_dynamic_model = None - self.preferred_usePPP = None - self.preferred_dgps_timeout = None - - def close(self): - '''close the device''' - self.dev.close() - self.dev = None - - def set_debug(self, debug_level): - '''set debug level''' - self.debug_level = debug_level - - def debug(self, level, msg): - '''write a debug message''' - if self.debug_level >= level: - print(msg) - - def set_logfile(self, logfile, append=False): - '''setup logging to a file''' - if self.log is not None: - self.log.close() - self.log = None - self.logfile = logfile - if self.logfile is not None: - if append: - mode = 'ab' - else: - mode = 'wb' - self.log = open(self.logfile, mode=mode) - - def set_preferred_dynamic_model(self, model): - '''set the preferred dynamic model for receiver''' - self.preferred_dynamic_model = model - if model is not None: - self.configure_poll(CLASS_CFG, MSG_CFG_NAV5) - - def set_preferred_dgps_timeout(self, timeout): - '''set the preferred DGPS timeout for receiver''' - self.preferred_dgps_timeout = timeout - if timeout is not None: - self.configure_poll(CLASS_CFG, MSG_CFG_NAV5) - - def set_preferred_usePPP(self, usePPP): - '''set the preferred usePPP setting for the receiver''' - if usePPP is None: - self.preferred_usePPP = None - return - self.preferred_usePPP = int(usePPP) - self.configure_poll(CLASS_CFG, MSG_CFG_NAVX5) - - def nmea_checksum(self, msg): - d = msg[1:] - cs = 0 - for i in d: - cs ^= ord(i) - return cs - - def write(self, buf): - '''write some bytes''' - if not self.read_only: - if self.use_sendrecv: - return self.dev.send(buf) - return self.dev.write(buf) - - def read(self, n): - '''read some bytes''' - if self.use_sendrecv: - import socket - try: - return self.dev.recv(n) - except socket.error: - return '' - return self.dev.read(n) - - def send_nmea(self, msg): - if not self.read_only: - s = msg + "*%02X" % self.nmea_checksum(msg) + "\r\n" - self.write(s) - - def set_binary(self): - '''put a UBlox into binary mode using a NMEA string''' - if not self.read_only: - print("try set binary at %u" % self.baudrate) - self.send_nmea("$PUBX,41,0,0007,0001,%u,0" % self.baudrate) - self.send_nmea("$PUBX,41,1,0007,0001,%u,0" % self.baudrate) - self.send_nmea("$PUBX,41,2,0007,0001,%u,0" % self.baudrate) - self.send_nmea("$PUBX,41,3,0007,0001,%u,0" % self.baudrate) - self.send_nmea("$PUBX,41,4,0007,0001,%u,0" % self.baudrate) - self.send_nmea("$PUBX,41,5,0007,0001,%u,0" % self.baudrate) - - def disable_nmea(self): - ''' stop sending all types of nmea messages ''' - self.send_nmea("$PUBX,40,GSV,1,1,1,1,1,0") - self.send_nmea("$PUBX,40,GGA,0,0,0,0,0,0") - self.send_nmea("$PUBX,40,GSA,0,0,0,0,0,0") - self.send_nmea("$PUBX,40,VTG,0,0,0,0,0,0") - self.send_nmea("$PUBX,40,TXT,0,0,0,0,0,0") - self.send_nmea("$PUBX,40,RMC,0,0,0,0,0,0") - - def seek_percent(self, pct): - '''seek to the given percentage of a file''' - self.dev.seek(0, 2) - filesize = self.dev.tell() - self.dev.seek(pct * 0.01 * filesize) - - def special_handling(self, msg): - '''handle automatic configuration changes''' - if msg.name() == 'CFG_NAV5': - msg.unpack() - sendit = False - pollit = False - if self.preferred_dynamic_model is not None and msg.dynModel != self.preferred_dynamic_model: - msg.dynModel = self.preferred_dynamic_model - sendit = True - pollit = True - if self.preferred_dgps_timeout is not None and msg.dgpsTimeOut != self.preferred_dgps_timeout: - msg.dgpsTimeOut = self.preferred_dgps_timeout - self.debug(2, "Setting dgpsTimeOut=%u" % msg.dgpsTimeOut) - sendit = True - # we don't re-poll for this one, as some receivers refuse to set it - if sendit: - msg.pack() - self.send(msg) - if pollit: - self.configure_poll(CLASS_CFG, MSG_CFG_NAV5) - if msg.name() == 'CFG_NAVX5' and self.preferred_usePPP is not None: - msg.unpack() - if msg.usePPP != self.preferred_usePPP: - msg.usePPP = self.preferred_usePPP - msg.mask = 1 << 13 - msg.pack() - self.send(msg) - self.configure_poll(CLASS_CFG, MSG_CFG_NAVX5) - - def receive_message(self, ignore_eof=False): - '''blocking receive of one ublox message''' - msg = UBloxMessage() - while True: - n = msg.needed_bytes() - b = self.read(n) - if not b: - if ignore_eof: - time.sleep(0.01) - continue - if len(msg._buf) > 0: - self.debug(1, "dropping %d bytes" % len(msg._buf)) - return None - msg.add(b) - if self.log is not None: - self.log.write(b) - self.log.flush() - if msg.valid(): - self.special_handling(msg) - return msg - - def receive_message_noerror(self, ignore_eof=False): - '''blocking receive of one ublox message, ignoring errors''' - try: - return self.receive_message(ignore_eof=ignore_eof) - except UBloxError as e: - print(e) - return None - except OSError as e: - # Occasionally we get hit with 'resource temporarily unavailable' - # messages here on the serial device, catch them too. - print(e) - return None - - def send(self, msg): - '''send a preformatted ublox message''' - if not msg.valid(): - self.debug(1, "invalid send") - return - if not self.read_only: - self.write(msg._buf) - - def send_message(self, msg_class, msg_id, payload): - '''send a ublox message with class, id and payload''' - msg = UBloxMessage() - msg._buf = struct.pack(' 1e-3: - print('Gps vNED mismatch', o, n) - return - elif o != n: - print('Gps mismatch', attr, o, n) - return -4 - elif events1[i].which() == 'ubloxGnss': - old_gnss = events1[i].ubloxGnss - gnss = events2[i].ubloxGnss - if old_gnss.which() == 'measurementReport' and gnss.which() == 'measurementReport': - attrs = ['gpsWeek', 'leapSeconds', 'measurements', 'numMeas', 'rcvTow', 'receiverStatus', 'schema'] - for attr in attrs: - o = getattr(old_gnss.measurementReport, attr) - n = getattr(gnss.measurementReport, attr) - if str(o) != str(n): - print('measurementReport {} mismatched'.format(attr)) - return -5 - if not (str(old_gnss.measurementReport) == str(gnss.measurementReport)): - print('Gnss measurementReport mismatched!') - print('gnss measurementReport old', old_gnss.measurementReport.measurements) - print('gnss measurementReport new', gnss.measurementReport.measurements) - return -6 - elif old_gnss.which() == 'ephemeris' and gnss.which() == 'ephemeris': - if not (str(old_gnss.ephemeris) == str(gnss.ephemeris)): - print('Gnss ephemeris mismatched!') - print('gnss ephemeris old', old_gnss.ephemeris) - print('gnss ephemeris new', gnss.ephemeris) - return -7 - print('All {} events matched!'.format(len(events1))) - return 0 - - -if __name__ == "__main__": - args = get_arg_parser().parse_args(sys.argv[1:]) - compare_results(args.dir1, args.dir2) diff --git a/selfdrive/locationd/ublox_msg.cc b/selfdrive/locationd/ublox_msg.cc index ef523b8870e4fc..74d56ed3443f65 100644 --- a/selfdrive/locationd/ublox_msg.cc +++ b/selfdrive/locationd/ublox_msg.cc @@ -1,25 +1,17 @@ #include #include -#include #include #include #include #include #include #include -#include #include #include #include #include -#include -#include #include -#include -#include -#include "cereal/gen/cpp/log.capnp.h" - #include "common/params.h" #include "common/swaglog.h" #include "common/timing.h" @@ -46,7 +38,7 @@ inline int GET_FIELD_S(uint32_t w, uint32_t nb, uint32_t pos) { class EphemerisData { public: - EphemerisData(uint8_t svId, subframes_map subframes) { + EphemerisData(uint8_t svId, subframes_map &subframes) { this->svId = svId; int week_no = GET_FIELD_U(subframes[1][2+0], 10, 20); int t_gd = GET_FIELD_S(subframes[1][2+4], 8, 6); @@ -201,10 +193,8 @@ inline bool UbloxMsgParser::valid_so_far() { kj::Array UbloxMsgParser::gen_solution() { nav_pvt_msg *msg = (nav_pvt_msg *)&msg_parse_buf[UBLOX_HEADER_SIZE]; - capnp::MallocMessageBuilder msg_builder; - cereal::Event::Builder event = msg_builder.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto gpsLoc = event.initGpsLocationExternal(); + MessageBuilder msg_builder; + auto gpsLoc = msg_builder.initEvent().initGpsLocationExternal(); gpsLoc.setSource(cereal::GpsLocationData::SensorSource::UBLOX); gpsLoc.setFlags(msg->flags); gpsLoc.setLatitude(msg->lat * 1e-07); @@ -223,8 +213,7 @@ kj::Array UbloxMsgParser::gen_solution() { std::time_t utc_tt = timegm(&timeinfo); gpsLoc.setTimestamp(utc_tt * 1e+03 + msg->nano * 1e-06); float f[] = { msg->velN * 1e-03f, msg->velE * 1e-03f, msg->velD * 1e-03f }; - kj::ArrayPtr ap(&f[0], sizeof(f) / sizeof(f[0])); - gpsLoc.setVNED(ap); + gpsLoc.setVNED(f); gpsLoc.setVerticalAccuracy(msg->vAcc * 1e-03); gpsLoc.setSpeedAccuracy(msg->sAcc * 1e-03); gpsLoc.setBearingAccuracy(msg->headAcc * 1e-05); @@ -244,11 +233,8 @@ kj::Array UbloxMsgParser::gen_raw() { return kj::Array(); } rxm_raw_msg_extra *measurements = (rxm_raw_msg_extra *)&msg_parse_buf[UBLOX_HEADER_SIZE + sizeof(rxm_raw_msg)]; - capnp::MallocMessageBuilder msg_builder; - cereal::Event::Builder event = msg_builder.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto gnss = event.initUbloxGnss(); - auto mr = gnss.initMeasurementReport(); + MessageBuilder msg_builder; + auto mr = msg_builder.initEvent().initUbloxGnss().initMeasurementReport(); mr.setRcvTow(msg->rcvTow); mr.setGpsWeek(msg->week); mr.setLeapSeconds(msg->leapS); @@ -303,11 +289,8 @@ kj::Array UbloxMsgParser::gen_nav_data() { nav_frame_buffer[msg->gnssId][msg->svid][subframeId] = words; if(nav_frame_buffer[msg->gnssId][msg->svid].size() == 5) { EphemerisData ephem_data(msg->svid, nav_frame_buffer[msg->gnssId][msg->svid]); - capnp::MallocMessageBuilder msg_builder; - cereal::Event::Builder event = msg_builder.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto gnss = event.initUbloxGnss(); - auto eph = gnss.initEphemeris(); + MessageBuilder msg_builder; + auto eph = msg_builder.initEvent().initUbloxGnss().initEphemeris(); eph.setSvId(ephem_data.svId); eph.setToc(ephem_data.toc); eph.setGpsWeek(ephem_data.gpsWeek); @@ -334,10 +317,8 @@ kj::Array UbloxMsgParser::gen_nav_data() { eph.setTgd(ephem_data.Tgd); eph.setIonoCoeffsValid(ephem_data.ionoCoeffsValid); if(ephem_data.ionoCoeffsValid) { - kj::ArrayPtr apa(&ephem_data.ionoAlpha[0], sizeof(ephem_data.ionoAlpha) / sizeof(ephem_data.ionoAlpha[0])); - eph.setIonoAlpha(apa); - kj::ArrayPtr apb(&ephem_data.ionoBeta[0], sizeof(ephem_data.ionoBeta) / sizeof(ephem_data.ionoBeta[0])); - eph.setIonoBeta(apb); + eph.setIonoAlpha(ephem_data.ionoAlpha); + eph.setIonoBeta(ephem_data.ionoBeta); } else { eph.setIonoAlpha(kj::ArrayPtr()); eph.setIonoBeta(kj::ArrayPtr()); @@ -348,6 +329,19 @@ kj::Array UbloxMsgParser::gen_nav_data() { return kj::Array(); } +kj::Array UbloxMsgParser::gen_mon_hw() { + mon_hw_msg *msg = (mon_hw_msg *)&msg_parse_buf[UBLOX_HEADER_SIZE]; + + MessageBuilder msg_builder; + auto hwStatus = msg_builder.initEvent().initUbloxGnss().initHwStatus(); + hwStatus.setNoisePerMS(msg->noisePerMS); + hwStatus.setAgcCnt(msg->agcCnt); + hwStatus.setAStatus((cereal::UbloxGnss::HwStatus::AntennaSupervisorState) msg->aStatus); + hwStatus.setAPower((cereal::UbloxGnss::HwStatus::AntennaPowerStatus) msg->aPower); + hwStatus.setJamInd(msg->jamInd); + return capnp::messageToFlatArray(msg_builder); +} + bool UbloxMsgParser::add_data(const uint8_t *incoming_data, uint32_t incoming_data_len, size_t &bytes_consumed) { int needed = needed_bytes(); if(needed > 0) { diff --git a/selfdrive/locationd/ublox_msg.h b/selfdrive/locationd/ublox_msg.h index c7860f14cf4e5a..4bb103bb508e4e 100644 --- a/selfdrive/locationd/ublox_msg.h +++ b/selfdrive/locationd/ublox_msg.h @@ -1,6 +1,7 @@ #pragma once #include +#include "messaging.hpp" #define min(x, y) ((x) <= (y) ? (x) : (y)) @@ -84,6 +85,27 @@ typedef struct __attribute__((packed)) { uint32_t dwrd; } rxm_sfrbx_msg_extra; +// MON_HW +typedef struct __attribute__((packed)) { + uint32_t pinSel; + uint32_t pinBank; + uint32_t pinDir; + uint32_t pinVal; + uint16_t noisePerMS; + uint16_t agcCnt; + uint8_t aStatus; + uint8_t aPower; + uint8_t flags; + uint8_t reserved1; + uint32_t usedMask; + uint8_t VP[17]; + uint8_t jamInd; + uint8_t reserved2[2]; + uint32_t pinIrq; + uint32_t pullH; + uint32_t pullL; +} mon_hw_msg; + namespace ublox { // protocol constants const uint8_t PREAMBLE1 = 0xb5; @@ -92,6 +114,7 @@ namespace ublox { // message classes const uint8_t CLASS_NAV = 0x01; const uint8_t CLASS_RXM = 0x02; + const uint8_t CLASS_MON = 0x0A; // NAV messages const uint8_t MSG_NAV_PVT = 0x7; @@ -100,6 +123,9 @@ namespace ublox { const uint8_t MSG_RXM_RAW = 0x15; const uint8_t MSG_RXM_SFRBX = 0x13; + // MON messages + const uint8_t MSG_MON_HW = 0x09; + const int UBLOX_HEADER_SIZE = 6; const int UBLOX_CHECKSUM_SIZE = 2; const int UBLOX_MAX_MSG_SIZE = 65536; @@ -112,6 +138,7 @@ namespace ublox { UbloxMsgParser(); kj::Array gen_solution(); kj::Array gen_raw(); + kj::Array gen_mon_hw(); kj::Array gen_nav_data(); bool add_data(const uint8_t *incoming_data, uint32_t incoming_data_len, size_t &bytes_consumed); @@ -144,6 +171,6 @@ namespace ublox { } -typedef int (*poll_ubloxraw_msg_func)(void *gpsLocationExternal, void *ubloxGnss, void *subscriber, zmq_msg_t *msg); -typedef int (*send_gps_event_func)(uint8_t msg_cls, uint8_t msg_id, void *s, const void *buf, size_t len, int flags); +typedef Message * (*poll_ubloxraw_msg_func)(Poller *poller); +typedef int (*send_gps_event_func)(PubSocket *s, const void *buf, size_t len); int ubloxd_main(poll_ubloxraw_msg_func poll_func, send_gps_event_func send_func); diff --git a/selfdrive/locationd/ubloxd.cc b/selfdrive/locationd/ubloxd.cc index 82853f132858c8..4ffc010f3e5a89 100644 --- a/selfdrive/locationd/ubloxd.cc +++ b/selfdrive/locationd/ubloxd.cc @@ -7,17 +7,12 @@ #include #include #include -#include #include #include #include #include -#include -#include -#include -#include -#include "cereal/gen/cpp/log.capnp.h" +#include "messaging.hpp" #include "common/params.h" #include "common/swaglog.h" @@ -27,17 +22,19 @@ const long ZMQ_POLL_TIMEOUT = 1000; // In miliseconds -int poll_ubloxraw_msg(void *gpsLocationExternal, void *ubloxGnss, void *subscriber, zmq_msg_t *msg) { - int err; - zmq_pollitem_t item = {.socket = subscriber, .events = ZMQ_POLLIN}; - err = zmq_poll (&item, 1, ZMQ_POLL_TIMEOUT); - if(err <= 0) - return err; - return zmq_msg_recv(msg, subscriber, 0); +Message * poll_ubloxraw_msg(Poller * poller) { + auto p = poller->poll(ZMQ_POLL_TIMEOUT); + + if (p.size()) { + return p[0]->receive(); + } else { + return NULL; + } } -int send_gps_event(uint8_t msg_cls, uint8_t msg_id, void *s, const void *buf, size_t len, int flags) { - return zmq_send(s, buf, len, flags); + +int send_gps_event(PubSocket *s, const void *buf, size_t len) { + return s->send((char*)buf, len); } int main() { diff --git a/selfdrive/locationd/ubloxd_main.cc b/selfdrive/locationd/ubloxd_main.cc index ec2b83cfcb5d06..4686cc0ee9e931 100644 --- a/selfdrive/locationd/ubloxd_main.cc +++ b/selfdrive/locationd/ubloxd_main.cc @@ -4,48 +4,37 @@ #include #include #include +#include #include #include #include -#include #include #include #include #include -#include -#include - -#include -#include -#include "cereal/gen/cpp/log.capnp.h" +#include "messaging.hpp" +#include "common/util.h" #include "common/params.h" #include "common/swaglog.h" #include "common/timing.h" #include "ublox_msg.h" -volatile int do_exit = 0; // Flag for process exit on signal +volatile sig_atomic_t do_exit = 0; // Flag for process exit on signal void set_do_exit(int sig) { do_exit = 1; } -using namespace ublox; - -int ubloxd_main(poll_ubloxraw_msg_func poll_func, send_gps_event_func send_func) { - LOGW("starting ubloxd"); - signal(SIGINT, (sighandler_t) set_do_exit); - signal(SIGTERM, (sighandler_t) set_do_exit); - int useTeslaGps = 0; +bool is_tesla_gps_enabled() { char line[500]; - int linenum=0; + int linenum = 0; FILE *stream; stream = fopen("/data/bb_openpilot.cfg","r"); while(fgets(line, 500, stream) != NULL) { char setting[256], value[256], oper[10]; - linenum++; if(line[0] == '#') continue; if(sscanf(line, "%s %s %s", setting, oper , value) != 3) @@ -55,88 +44,110 @@ int ubloxd_main(poll_ubloxraw_msg_func poll_func, send_gps_event_func send_func) } //printf("Found [%s] %s [%s]\n", setting, oper, value); if ((strcmp("use_tesla_gps",setting) == 0) && (strcmp("True",value) == 0)) { - useTeslaGps = 1; + fclose(stream); + return true; } } fclose(stream); - if (useTeslaGps == 0) { - UbloxMsgParser parser; - void *context = zmq_ctx_new(); - void *gpsLocationExternal = zmq_socket(context, ZMQ_PUB); - zmq_bind(gpsLocationExternal, "tcp://*:8032"); - void *ubloxGnss = zmq_socket(context, ZMQ_PUB); - zmq_bind(ubloxGnss, "tcp://*:8033"); - // ubloxRaw = 8042 - void *subscriber = zmq_socket(context, ZMQ_SUB); - zmq_setsockopt(subscriber, ZMQ_SUBSCRIBE, "", 0); - zmq_connect(subscriber, "tcp://127.0.0.1:8042"); - while (!do_exit) { - zmq_msg_t msg; - zmq_msg_init(&msg); - int err = poll_func(gpsLocationExternal, ubloxGnss, subscriber, &msg); - if(err < 0) { - LOGE_100("zmq_poll error %s in %s", strerror(errno ), __FUNCTION__); - break; - } else if(err == 0) { - continue; - } - // format for board, make copy due to alignment issues, will be freed on out of scope - auto amsg = kj::heapArray((zmq_msg_size(&msg) / sizeof(capnp::word)) + 1); - memcpy(amsg.begin(), zmq_msg_data(&msg), zmq_msg_size(&msg)); - capnp::FlatArrayMessageReader cmsg(amsg); - cereal::Event::Reader event = cmsg.getRoot(); - const uint8_t *data = event.getUbloxRaw().begin(); - size_t len = event.getUbloxRaw().size(); - size_t bytes_consumed = 0; - while(bytes_consumed < len && !do_exit) { - size_t bytes_consumed_this_time = 0U; - if(parser.add_data(data + bytes_consumed, (uint32_t)(len - bytes_consumed), bytes_consumed_this_time)) { - // New message available - if(parser.msg_class() == CLASS_NAV) { - if(parser.msg_id() == MSG_NAV_PVT) { - //LOGD("MSG_NAV_PVT"); - auto words = parser.gen_solution(); - if(words.size() > 0) { - auto bytes = words.asBytes(); - send_func(parser.msg_class(), parser.msg_id(), gpsLocationExternal, bytes.begin(), bytes.size(), 0); - } - } else - LOGW("Unknown nav msg id: 0x%02X", parser.msg_id()); - } else if(parser.msg_class() == CLASS_RXM) { - if(parser.msg_id() == MSG_RXM_RAW) { - //LOGD("MSG_RXM_RAW"); - auto words = parser.gen_raw(); - if(words.size() > 0) { - auto bytes = words.asBytes(); - send_func(parser.msg_class(), parser.msg_id(), ubloxGnss, bytes.begin(), bytes.size(), 0); - } - } else if(parser.msg_id() == MSG_RXM_SFRBX) { - //LOGD("MSG_RXM_SFRBX"); - auto words = parser.gen_nav_data(); - if(words.size() > 0) { - auto bytes = words.asBytes(); - send_func(parser.msg_class(), parser.msg_id(), ubloxGnss, bytes.begin(), bytes.size(), 0); - } - } else - LOGW("Unknown rxm msg id: 0x%02X", parser.msg_id()); - } else - LOGW("Unknown msg class: 0x%02X", parser.msg_class()); - parser.reset(); - } - bytes_consumed += bytes_consumed_this_time; - } - zmq_msg_close(&msg); - } - zmq_close(subscriber); - zmq_close(gpsLocationExternal); - zmq_close(ubloxGnss); - zmq_ctx_destroy(context); - return 0; - } else { + return false; +} + +using namespace ublox; +int ubloxd_main(poll_ubloxraw_msg_func poll_func, send_gps_event_func send_func) { + LOGW("starting ubloxd"); + signal(SIGINT, (sighandler_t) set_do_exit); + signal(SIGTERM, (sighandler_t) set_do_exit); + + if (is_tesla_gps_enabled()) { LOGW("Using tesla gps..."); while (!do_exit) { sleep(1); } return 0; } + + UbloxMsgParser parser; + + Context * context = Context::create(); + SubSocket * subscriber = SubSocket::create(context, "ubloxRaw"); + assert(subscriber != NULL); + subscriber->setTimeout(100); + + PubMaster pm({"ubloxGnss", "gpsLocationExternal"}); + + while (!do_exit) { + Message * msg = subscriber->receive(); + if (!msg){ + if (errno == EINTR) { + do_exit = true; + } + continue; + } + + auto amsg = kj::heapArray((msg->getSize() / sizeof(capnp::word)) + 1); + memcpy(amsg.begin(), msg->getData(), msg->getSize()); + + capnp::FlatArrayMessageReader cmsg(amsg); + cereal::Event::Reader event = cmsg.getRoot(); + auto ubloxRaw = event.getUbloxRaw(); + + const uint8_t *data = ubloxRaw.begin(); + size_t len = ubloxRaw.size(); + size_t bytes_consumed = 0; + while(bytes_consumed < len && !do_exit) { + size_t bytes_consumed_this_time = 0U; + if(parser.add_data(data + bytes_consumed, (uint32_t)(len - bytes_consumed), bytes_consumed_this_time)) { + // New message available + if(parser.msg_class() == CLASS_NAV) { + if(parser.msg_id() == MSG_NAV_PVT) { + //LOGD("MSG_NAV_PVT"); + auto words = parser.gen_solution(); + if(words.size() > 0) { + auto bytes = words.asBytes(); + pm.send("gpsLocationExternal", bytes.begin(), bytes.size()); + } + } else + LOGW("Unknown nav msg id: 0x%02X", parser.msg_id()); + } else if(parser.msg_class() == CLASS_RXM) { + if(parser.msg_id() == MSG_RXM_RAW) { + //LOGD("MSG_RXM_RAW"); + auto words = parser.gen_raw(); + if(words.size() > 0) { + auto bytes = words.asBytes(); + pm.send("ubloxGnss", bytes.begin(), bytes.size()); + } + } else if(parser.msg_id() == MSG_RXM_SFRBX) { + //LOGD("MSG_RXM_SFRBX"); + auto words = parser.gen_nav_data(); + if(words.size() > 0) { + auto bytes = words.asBytes(); + pm.send("ubloxGnss", bytes.begin(), bytes.size()); + } + } else + LOGW("Unknown rxm msg id: 0x%02X", parser.msg_id()); + } else if(parser.msg_class() == CLASS_MON) { + if(parser.msg_id() == MSG_MON_HW) { + //LOGD("MSG_MON_HW"); + auto words = parser.gen_mon_hw(); + if(words.size() > 0) { + auto bytes = words.asBytes(); + pm.send("ubloxGnss", bytes.begin(), bytes.size()); + } + } else { + LOGW("Unknown mon msg id: 0x%02X", parser.msg_id()); + } + } else + LOGW("Unknown msg class: 0x%02X", parser.msg_class()); + parser.reset(); + } + bytes_consumed += bytes_consumed_this_time; + } + delete msg; + } + + delete subscriber; + delete context; + + return 0; } + diff --git a/selfdrive/locationd/ubloxd_test.cc b/selfdrive/locationd/ubloxd_test.cc index a1395fa5960d13..d1118e4d29737c 100644 --- a/selfdrive/locationd/ubloxd_test.cc +++ b/selfdrive/locationd/ubloxd_test.cc @@ -7,18 +7,14 @@ #include #include #include -#include #include #include #include #include -#include -#include #include -#include -#include -#include "cereal/gen/cpp/log.capnp.h" +#include "messaging.hpp" +#include "impl_zmq.hpp" #include "common/params.h" #include "common/swaglog.h" @@ -27,14 +23,15 @@ #include "ublox_msg.h" using namespace ublox; +extern volatile sig_atomic_t do_exit; -void write_file(std::string fpath, uint8_t *data, int len) { +void write_file(std::string fpath, uint8_t *to_write, int length) { FILE* f = fopen(fpath.c_str(), "wb"); if (!f) { std::cout << "Open " << fpath << " failed" << std::endl; return; } - fwrite(data, len, 1, f); + fwrite(to_write, length, 1, f); fclose(f); } @@ -43,41 +40,34 @@ static size_t consumed = 0U; static uint8_t *data = NULL; static int save_idx = 0; static std::string prefix; -static void *gps_sock, *ublox_gnss_sock; -int poll_ubloxraw_msg(void *gpsLocationExternal, void *ubloxGnss, void *subscriber, zmq_msg_t *msg) { - gps_sock = gpsLocationExternal; - ublox_gnss_sock = ubloxGnss; +Message * poll_ubloxraw_msg(Poller * poller) { + assert(poller); + size_t consuming = min(len - consumed, 128); if(consumed < len) { // create message - capnp::MallocMessageBuilder msg_builder; - cereal::Event::Builder event = msg_builder.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto ublox_raw = event.initUbloxRaw(consuming); + MessageBuilder msg_builder; + auto ublox_raw = msg_builder.initEvent().initUbloxRaw(consuming); memcpy(ublox_raw.begin(), (void *)(data + consumed), consuming); - auto words = capnp::messageToFlatArray(msg_builder); - auto bytes = words.asBytes(); - zmq_msg_init_size (msg, bytes.size()); - memcpy (zmq_msg_data(msg), (void *)bytes.begin(), bytes.size()); + + auto bytes = msg_builder.toBytes(); + + Message * msg = new ZMQMessage(); + msg->init((char*)bytes.begin(), bytes.size()); consumed += consuming; - return 1; - } else - return -1; + return msg; + } else { + do_exit = 1; + return NULL; + } } -int send_gps_event(uint8_t msg_cls, uint8_t msg_id, void *s, const void *buf, size_t len, int flags) { - if(msg_cls == CLASS_NAV && msg_id == MSG_NAV_PVT) - assert(s == gps_sock); - else if(msg_cls == CLASS_RXM && msg_id == MSG_RXM_RAW) - assert(s == ublox_gnss_sock); - else if(msg_cls == CLASS_RXM && msg_id == MSG_RXM_SFRBX) - assert(s == ublox_gnss_sock); - else - assert(0); - write_file(prefix + "/" + std::to_string(save_idx), (uint8_t *)buf, len); - save_idx ++; - return len; +int send_gps_event(PubSocket *s, const void *buf, size_t length) { + assert(s); + write_file(prefix + "/" + std::to_string(save_idx), (uint8_t *)buf, length); + save_idx++; + return length; } int main(int argc, char** argv) { diff --git a/selfdrive/logcatd/Makefile b/selfdrive/logcatd/Makefile deleted file mode 100644 index fff9220dd303a0..00000000000000 --- a/selfdrive/logcatd/Makefile +++ /dev/null @@ -1,57 +0,0 @@ -CC = clang -CXX = clang++ - -ARCH := $(shell uname -m) - -PHONELIBS = ../../phonelibs -BASEDIR = ../.. - -WARN_FLAGS = -Werror=implicit-function-declaration \ - -Werror=incompatible-pointer-types \ - -Werror=int-conversion \ - -Werror=return-type \ - -Werror=format-extra-args - -CFLAGS = -std=gnu11 -g -fPIC -O2 $(WARN_FLAGS) -CXXFLAGS = -std=c++11 -g -fPIC -O2 $(WARN_FLAGS) -ZMQ_LIBS = -l:libczmq.a -l:libzmq.a - -ifeq ($(ARCH),aarch64) -CFLAGS += -mcpu=cortex-a57 -CXXFLAGS += -mcpu=cortex-a57 -ZMQ_LIBS += -lgnustl_shared -endif - - -.PHONY: all -all: logcatd - -include ../common/cereal.mk - -OBJS = logcatd.o \ - $(CEREAL_OBJS) - -DEPS := $(OBJS:.o=.d) - -logcatd: $(OBJS) - @echo "[ LINK ] $@" - $(CXX) -fPIC -o '$@' $^ \ - $(CEREAL_LIBS) \ - $(ZMQ_LIBS) \ - -llog - -%.o: %.cc - @echo "[ CXX ] $@" - $(CXX) $(CXXFLAGS) \ - -I$(PHONELIBS)/android_system_core/include \ - $(CEREAL_CXXFLAGS) \ - $(ZMQ_FLAGS) \ - -I../ \ - -I../../ \ - -c -o '$@' '$<' - -.PHONY: clean -clean: - rm -f logcatd $(OBJS) $(DEPS) - --include $(DEPS) diff --git a/selfdrive/logcatd/SConscript b/selfdrive/logcatd/SConscript new file mode 100644 index 00000000000000..2646537adf773d --- /dev/null +++ b/selfdrive/logcatd/SConscript @@ -0,0 +1,6 @@ +Import('env', 'cereal', 'messaging', 'arch') + +if arch == "aarch64": + env.Program('logcatd', 'logcatd_android.cc', LIBS=[cereal, messaging, 'cutils', 'zmq', 'capnp', 'kj']) +else: + env.Program('logcatd', 'logcatd_systemd.cc', LIBS=[cereal, messaging, 'zmq', 'capnp', 'kj', 'systemd', 'json11']) diff --git a/selfdrive/logcatd/logcatd.cc b/selfdrive/logcatd/logcatd.cc deleted file mode 100644 index 637c5e6c0a47ac..00000000000000 --- a/selfdrive/logcatd/logcatd.cc +++ /dev/null @@ -1,69 +0,0 @@ -#include -#include -#include -#include - -//#include -#include -#include - -#include -#include -#include "common/timing.h" -#include "cereal/gen/cpp/log.capnp.h" - -int main() { - int err; - - struct logger_list *logger_list = android_logger_list_alloc(ANDROID_LOG_RDONLY, 0, 0); - assert(logger_list); - struct logger *main_logger = android_logger_open(logger_list, LOG_ID_MAIN); - assert(main_logger); - struct logger *radio_logger = android_logger_open(logger_list, LOG_ID_RADIO); - assert(radio_logger); - struct logger *system_logger = android_logger_open(logger_list, LOG_ID_SYSTEM); - assert(system_logger); - struct logger *crash_logger = android_logger_open(logger_list, LOG_ID_CRASH); - assert(crash_logger); -// struct logger *kernel_logger = android_logger_open(logger_list, LOG_ID_KERNEL); -// assert(kernel_logger); - - void *context = zmq_ctx_new(); - void *publisher = zmq_socket(context, ZMQ_PUB); - err = zmq_bind(publisher, "tcp://*:8020"); - assert(err == 0); - - while (1) { - log_msg log_msg; - err = android_logger_list_read(logger_list, &log_msg); - if (err <= 0) { - break; - } - - AndroidLogEntry entry; - err = android_log_processLogBuffer(&log_msg.entry_v1, &entry); - if (err < 0) { - continue; - } - - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto androidEntry = event.initAndroidLogEntry(); - androidEntry.setId(log_msg.id()); - androidEntry.setTs(entry.tv_sec * 1000000000ULL + entry.tv_nsec); - androidEntry.setPriority(entry.priority); - androidEntry.setPid(entry.pid); - androidEntry.setTid(entry.tid); - androidEntry.setTag(entry.tag); - androidEntry.setMessage(entry.message); - - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - zmq_send(publisher, bytes.begin(), bytes.size(), 0); - } - - android_logger_list_close(logger_list); - - return 0; -} diff --git a/selfdrive/logcatd/logcatd_android.cc b/selfdrive/logcatd/logcatd_android.cc new file mode 100644 index 00000000000000..9a1753b1d67c6b --- /dev/null +++ b/selfdrive/logcatd/logcatd_android.cc @@ -0,0 +1,58 @@ +#include +#include +#include +#include + +//#include +#include +#include + +#include "common/timing.h" +#include "messaging.hpp" + +int main() { + int err; + + struct logger_list *logger_list = android_logger_list_alloc(ANDROID_LOG_RDONLY, 0, 0); + assert(logger_list); + struct logger *main_logger = android_logger_open(logger_list, LOG_ID_MAIN); + assert(main_logger); + struct logger *radio_logger = android_logger_open(logger_list, LOG_ID_RADIO); + assert(radio_logger); + struct logger *system_logger = android_logger_open(logger_list, LOG_ID_SYSTEM); + assert(system_logger); + struct logger *crash_logger = android_logger_open(logger_list, LOG_ID_CRASH); + assert(crash_logger); + struct logger *kernel_logger = android_logger_open(logger_list, (log_id_t)5); // LOG_ID_KERNEL + assert(kernel_logger); + PubMaster pm({"androidLog"}); + + while (1) { + log_msg log_msg; + err = android_logger_list_read(logger_list, &log_msg); + if (err <= 0) { + break; + } + + AndroidLogEntry entry; + err = android_log_processLogBuffer(&log_msg.entry_v1, &entry); + if (err < 0) { + continue; + } + + MessageBuilder msg; + auto androidEntry = msg.initEvent().initAndroidLog(); + androidEntry.setId(log_msg.id()); + androidEntry.setTs(entry.tv_sec * 1000000000ULL + entry.tv_nsec); + androidEntry.setPriority(entry.priority); + androidEntry.setPid(entry.pid); + androidEntry.setTid(entry.tid); + androidEntry.setTag(entry.tag); + androidEntry.setMessage(entry.message); + + pm.send("androidLog", msg); + } + + android_logger_list_close(logger_list); + return 0; +} diff --git a/selfdrive/logcatd/logcatd_systemd.cc b/selfdrive/logcatd/logcatd_systemd.cc new file mode 100644 index 00000000000000..adc18791418742 --- /dev/null +++ b/selfdrive/logcatd/logcatd_systemd.cc @@ -0,0 +1,71 @@ +#include +#include +#include +#include + +#include "json11.hpp" +#include + +#include "common/timing.h" +#include "messaging.hpp" + +int main(int argc, char *argv[]) { + PubMaster pm({"androidLog"}); + + sd_journal *journal; + assert(sd_journal_open(&journal, 0) >= 0); + assert(sd_journal_get_fd(journal) >= 0); // needed so sd_journal_wait() works properly if files rotate + assert(sd_journal_seek_tail(journal) >= 0); + + int r; + while (true) { + r = sd_journal_next(journal); + assert(r >= 0); + + // Wait for new message if we didn't receive anything + if (r == 0){ + do { + r = sd_journal_wait(journal, (uint64_t)-1); + assert(r >= 0); + } while (r == SD_JOURNAL_NOP); + + r = sd_journal_next(journal); + assert(r >= 0); + + if (r == 0) continue; // Try again if we still didn't get anything + } + + uint64_t timestamp = 0; + r = sd_journal_get_realtime_usec(journal, ×tamp); + assert(r >= 0); + + const void *data; + size_t length; + std::map kv; + + SD_JOURNAL_FOREACH_DATA(journal, data, length){ + std::string str((char*)data, length); + + // Split "KEY=VALUE"" on "=" and put in map + std::size_t found = str.find("="); + if (found != std::string::npos){ + kv[str.substr(0, found)] = str.substr(found + 1, std::string::npos); + } + } + + MessageBuilder msg; + + // Build message + auto androidEntry = msg.initEvent().initAndroidLog(); + androidEntry.setTs(timestamp); + androidEntry.setMessage(json11::Json(kv).dump()); + if (kv.count("_PID")) androidEntry.setPid(std::atoi(kv["_PID"].c_str())); + if (kv.count("PRIORITY")) androidEntry.setPriority(std::atoi(kv["PRIORITY"].c_str())); + if (kv.count("SYSLOG_IDENTIFIER")) androidEntry.setTag(kv["SYSLOG_IDENTIFIER"]); + + pm.send("androidLog", msg); + } + + sd_journal_close(journal); + return 0; +} diff --git a/selfdrive/loggerd/Makefile b/selfdrive/loggerd/Makefile deleted file mode 100644 index bd3038ad7a84c5..00000000000000 --- a/selfdrive/loggerd/Makefile +++ /dev/null @@ -1,4 +0,0 @@ --include build_from_src.mk - -release: - @echo "loggerd: this is a release" diff --git a/selfdrive/loggerd/SConscript b/selfdrive/loggerd/SConscript new file mode 100644 index 00000000000000..f0577ec11c3098 --- /dev/null +++ b/selfdrive/loggerd/SConscript @@ -0,0 +1,18 @@ +Import('env', 'arch', 'cereal', 'messaging', 'common', 'visionipc') + +src = ['loggerd.cc', 'logger.cc'] +libs = ['zmq', 'capnp', 'kj', 'z', + 'avformat', 'avcodec', 'swscale', 'avutil', + 'yuv', 'bz2', common, cereal, messaging, visionipc] + +if arch in ["aarch64", "larch64"]: + src += ['encoder.c'] + libs += ['OmxVenc', 'OmxCore'] + if arch == "aarch64": + libs += ['cutils'] + else: + libs += ['pthread'] +else: + libs += ['pthread'] + +env.Program(src, LIBS=libs) diff --git a/selfdrive/loggerd/build_from_src.mk b/selfdrive/loggerd/build_from_src.mk deleted file mode 100644 index 47f4f9b265fa7a..00000000000000 --- a/selfdrive/loggerd/build_from_src.mk +++ /dev/null @@ -1,132 +0,0 @@ -CC = clang -CXX = clang++ - -ARCH := $(shell uname -m) - -PHONELIBS = ../../phonelibs -BASEDIR = ../.. - -WARN_FLAGS = -Werror=implicit-function-declaration \ - -Werror=incompatible-pointer-types \ - -Werror=int-conversion \ - -Werror=return-type \ - -Werror=format-extra-args \ - -Wno-deprecated-declarations - -CFLAGS = -std=gnu11 -g -fPIC -O2 $(WARN_FLAGS) \ - -I$(PHONELIBS)/android_frameworks_native/include \ - -I$(PHONELIBS)/android_system_core/include \ - -I$(PHONELIBS)/android_hardware_libhardware/include -CXXFLAGS = -std=c++11 -g -fPIC -O2 $(WARN_FLAGS) \ - -I$(PHONELIBS)/android_frameworks_native/include \ - -I$(PHONELIBS)/android_system_core/include \ - -I$(PHONELIBS)/android_hardware_libhardware/include - -ZMQ_LIBS = -l:libczmq.a -l:libzmq.a - -ifeq ($(ARCH),aarch64) -CFLAGS += -mcpu=cortex-a57 -CXXFLAGS += -mcpu=cortex-a57 -ZMQ_LIBS += -lgnustl_shared -endif - - -BZIP_FLAGS = -I$(PHONELIBS)/bzip2/ -BZIP_LIBS = -L$(PHONELIBS)/bzip2/ \ - -l:libbz2.a - -# todo: dont use system ffmpeg libs -FFMPEG_LIBS = -lavformat \ - -lavcodec \ - -lswscale \ - -lavutil \ - -lz - -LIBYUV_FLAGS = -I$(PHONELIBS)/libyuv/include -LIBYUV_LIBS = $(PHONELIBS)/libyuv/lib/libyuv.a - -OPENMAX_FLAGS = -I$(PHONELIBS)/openmax/include -OPENMAX_LIBS = -lOmxVenc -lOmxCore - -JSON_FLAGS = -I$(PHONELIBS)/json/src - -YAML_FLAGS = -I$(PHONELIBS)/yaml-cpp/include -YAML_LIBS = $(PHONELIBS)/yaml-cpp/lib/libyaml-cpp.a - -.PHONY: all -all: loggerd - -include ../common/cereal.mk - -OBJS += loggerd.o \ - logger.o \ - ../common/util.o \ - ../common/params.o \ - ../common/cqueue.o \ - ../common/swaglog.o \ - ../common/visionipc.o \ - ../common/ipc.o \ - $(PHONELIBS)/json/src/json.o - -ifeq ($(ARCH),x86_64) -CXXFLAGS += "-DDISABLE_ENCODER" -ZMQ_LIBS = -L$(BASEDIR)/external/zmq/lib/ \ - -l:libczmq.a -l:libzmq.a -EXTRA_LIBS = -lpthread -OPENMAX_LIBS = "" -YAML_LIBS = $(PHONELIBS)/yaml-cpp/x64/lib/libyaml-cpp.a -else -OBJS += encoder.o \ - raw_logger.o -EXTRA_LIBS = -lcutils -llog -endif - -DEPS := $(OBJS:.o=.d) - -loggerd: $(OBJS) - @echo "[ LINK ] $@" - $(CXX) -fPIC -o '$@' $^ \ - $(LIBYUV_LIBS) \ - $(CEREAL_LIBS) \ - $(ZMQ_LIBS) \ - -L/usr/lib \ - $(FFMPEG_LIBS) \ - -L/system/vendor/lib64 \ - $(OPENMAX_LIBS) \ - $(YAML_LIBS) \ - $(EXTRA_LIBS) \ - $(BZIP_LIBS) \ - -lm - -%.o: %.cc - @echo "[ CXX ] $@" - $(CXX) $(CXXFLAGS) -MMD \ - $(CEREAL_CXXFLAGS) \ - $(LIBYUV_FLAGS) \ - $(ZMQ_FLAGS) \ - $(OPENMAX_FLAGS) \ - $(YAML_FLAGS) \ - $(BZIP_FLAGS) \ - -Iinclude \ - -I../ \ - -I../../ \ - -c -o '$@' '$<' - -%.o: %.c - @echo "[ CC ] $@" - $(CC) $(CFLAGS) -MMD \ - $(LIBYUV_FLAGS) \ - $(ZMQ_FLAGS) \ - $(OPENMAX_FLAGS) \ - $(JSON_FLAGS) \ - $(BZIP_FLAGS) \ - -Iinclude \ - -I../ \ - -I../../ \ - -c -o '$@' '$<' - -.PHONY: clean -clean: - rm -f loggerd $(OBJS) $(DEPS) - --include $(DEPS) diff --git a/selfdrive/loggerd/config.py b/selfdrive/loggerd/config.py index 14e1e67a9eb44d..f859e8cb4acb61 100644 --- a/selfdrive/loggerd/config.py +++ b/selfdrive/loggerd/config.py @@ -6,14 +6,26 @@ else: ROOT = '/data/media/0/realdata/' + +CAMERA_FPS = 20 SEGMENT_LENGTH = 60 -def get_available_percent(): - try: - statvfs = os.statvfs(ROOT) - available_percent = 100.0 * statvfs.f_bavail / statvfs.f_blocks - except OSError: - available_percent = 100.0 +def get_available_percent(default=None): + try: + statvfs = os.statvfs(ROOT) + available_percent = 100.0 * statvfs.f_bavail / statvfs.f_blocks + except OSError: + available_percent = default + + return available_percent + + +def get_available_bytes(default=None): + try: + statvfs = os.statvfs(ROOT) + available_bytes = statvfs.f_bavail * statvfs.f_frsize + except OSError: + available_bytes = default - return available_percent + return available_bytes diff --git a/selfdrive/loggerd/deleter.py b/selfdrive/loggerd/deleter.py index b1e1ffcd04a5ca..27c40e835d39ee 100644 --- a/selfdrive/loggerd/deleter.py +++ b/selfdrive/loggerd/deleter.py @@ -1,19 +1,23 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import os import shutil import threading from selfdrive.swaglog import cloudlog -from selfdrive.loggerd.config import ROOT, get_available_percent -from selfdrive.loggerd.uploader import listdir_by_creation_date +from selfdrive.loggerd.config import ROOT, get_available_bytes, get_available_percent +from selfdrive.loggerd.uploader import listdir_by_creation + +MIN_BYTES = 5 * 1024 * 1024 * 1024 +MIN_PERCENT = 10 def deleter_thread(exit_event): while not exit_event.is_set(): - available_percent = get_available_percent() + out_of_bytes = get_available_bytes(default=MIN_BYTES + 1) < MIN_BYTES + out_of_percent = get_available_percent(default=MIN_PERCENT + 1) < MIN_PERCENT - if available_percent < 10.0: + if out_of_percent or out_of_bytes: # remove the earliest directory we can - dirs = listdir_by_creation_date(ROOT) + dirs = listdir_by_creation(ROOT) for delete_dir in dirs: delete_path = os.path.join(ROOT, delete_dir) @@ -31,7 +35,7 @@ def deleter_thread(exit_event): exit_event.wait(30) -def main(gctx=None): +def main(): deleter_thread(threading.Event()) diff --git a/selfdrive/loggerd/encoder.c b/selfdrive/loggerd/encoder.c index 1b85ad263deb9d..1ebb1dd331b7d2 100644 --- a/selfdrive/loggerd/encoder.c +++ b/selfdrive/loggerd/encoder.c @@ -1,10 +1,12 @@ +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + #include #include #include #include #include - -#include +#include +#include #include @@ -15,7 +17,7 @@ #include -#include +//#include #include @@ -24,10 +26,10 @@ #include "encoder.h" -#define ALOG(...) __android_log_print(ANDROID_LOG_VERBOSE, "omxapp", ##__VA_ARGS__) -// encoder: lossey codec using hardware hevc +//#define ALOG(...) __android_log_print(ANDROID_LOG_VERBOSE, "omxapp", ##__VA_ARGS__) +// encoder: lossey codec using hardware hevc static void wait_for_state(EncoderState *s, OMX_STATETYPE state) { pthread_mutex_lock(&s->state_lock); while (s->state != state) { @@ -59,8 +61,6 @@ static OMX_ERRORTYPE event_handler(OMX_HANDLETYPE component, OMX_PTR app_data, O break; } - pthread_mutex_unlock(&s->state_lock); - return OMX_ErrorNone; } @@ -96,6 +96,7 @@ static OMX_CALLBACKTYPE omx_callbacks = { #define PORT_INDEX_IN 0 #define PORT_INDEX_OUT 1 +static const char* omx_color_fomat_name(uint32_t format) __attribute__((unused)); static const char* omx_color_fomat_name(uint32_t format) { switch (format) { case OMX_COLOR_FormatUnused: return "OMX_COLOR_FormatUnused"; @@ -108,7 +109,7 @@ static const char* omx_color_fomat_name(uint32_t format) { case OMX_COLOR_Format16bitBGR565: return "OMX_COLOR_Format16bitBGR565"; case OMX_COLOR_Format18bitRGB666: return "OMX_COLOR_Format18bitRGB666"; case OMX_COLOR_Format18bitARGB1665: return "OMX_COLOR_Format18bitARGB1665"; - case OMX_COLOR_Format19bitARGB1666: return "OMX_COLOR_Format19bitARGB1666"; + case OMX_COLOR_Format19bitARGB1666: return "OMX_COLOR_Format19bitARGB1666"; case OMX_COLOR_Format24bitRGB888: return "OMX_COLOR_Format24bitRGB888"; case OMX_COLOR_Format24bitBGR888: return "OMX_COLOR_Format24bitBGR888"; case OMX_COLOR_Format24bitARGB1887: return "OMX_COLOR_Format24bitARGB1887"; @@ -131,11 +132,11 @@ static const char* omx_color_fomat_name(uint32_t format) { case OMX_COLOR_FormatRawBayer8bit: return "OMX_COLOR_FormatRawBayer8bit"; case OMX_COLOR_FormatRawBayer10bit: return "OMX_COLOR_FormatRawBayer10bit"; case OMX_COLOR_FormatRawBayer8bitcompressed: return "OMX_COLOR_FormatRawBayer8bitcompressed"; - case OMX_COLOR_FormatL2: return "OMX_COLOR_FormatL2"; - case OMX_COLOR_FormatL4: return "OMX_COLOR_FormatL4"; - case OMX_COLOR_FormatL8: return "OMX_COLOR_FormatL8"; - case OMX_COLOR_FormatL16: return "OMX_COLOR_FormatL16"; - case OMX_COLOR_FormatL24: return "OMX_COLOR_FormatL24"; + case OMX_COLOR_FormatL2: return "OMX_COLOR_FormatL2"; + case OMX_COLOR_FormatL4: return "OMX_COLOR_FormatL4"; + case OMX_COLOR_FormatL8: return "OMX_COLOR_FormatL8"; + case OMX_COLOR_FormatL16: return "OMX_COLOR_FormatL16"; + case OMX_COLOR_FormatL24: return "OMX_COLOR_FormatL24"; case OMX_COLOR_FormatL32: return "OMX_COLOR_FormatL32"; case OMX_COLOR_FormatYUV420PackedSemiPlanar: return "OMX_COLOR_FormatYUV420PackedSemiPlanar"; case OMX_COLOR_FormatYUV422PackedSemiPlanar: return "OMX_COLOR_FormatYUV422PackedSemiPlanar"; @@ -165,8 +166,7 @@ static const char* omx_color_fomat_name(uint32_t format) { } } - -void encoder_init(EncoderState *s, const char* filename, int width, int height, int fps, int bitrate) { +void encoder_init(EncoderState *s, const char* filename, int width, int height, int fps, int bitrate, bool h265, bool downscale) { int err; memset(s, 0, sizeof(*s)); @@ -176,6 +176,17 @@ void encoder_init(EncoderState *s, const char* filename, int width, int height, s->fps = fps; mutex_init_reentrant(&s->lock); + if (!h265) { + s->remuxing = true; + } + + if (downscale) { + s->downscale = true; + s->y_ptr2 = malloc(s->width*s->height); + s->u_ptr2 = malloc(s->width*s->height/4); + s->v_ptr2 = malloc(s->width*s->height/4); + } + s->segment = -1; s->state = OMX_StateLoaded; @@ -188,10 +199,16 @@ void encoder_init(EncoderState *s, const char* filename, int width, int height, pthread_mutex_init(&s->state_lock, NULL); pthread_cond_init(&s->state_cv, NULL); - err = OMX_GetHandle(&s->handle, (OMX_STRING)"OMX.qcom.video.encoder.hevc", - s, &omx_callbacks); - // err = OMX_GetHandle(&s->handle, (OMX_STRING)"OMX.qcom.video.encoder.avc", - // s, &omx_callbacks); + if (h265) { + err = OMX_GetHandle(&s->handle, (OMX_STRING)"OMX.qcom.video.encoder.hevc", + s, &omx_callbacks); + } else { + err = OMX_GetHandle(&s->handle, (OMX_STRING)"OMX.qcom.video.encoder.avc", + s, &omx_callbacks); + } + if (err != OMX_ErrorNone) { + LOGE("error getting codec: %x", err); + } assert(err == OMX_ErrorNone); // printf("handle: %p\n", s->handle); @@ -204,7 +221,6 @@ void encoder_init(EncoderState *s, const char* filename, int width, int height, (OMX_PTR) &in_port); assert(err == OMX_ErrorNone); - in_port.format.video.nFrameWidth = s->width; in_port.format.video.nFrameHeight = s->height; in_port.format.video.nStride = VENUS_Y_STRIDE(COLOR_FMT_NV12, s->width); @@ -214,7 +230,7 @@ void encoder_init(EncoderState *s, const char* filename, int width, int height, in_port.format.video.xFramerate = (s->fps * 65536); in_port.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; // in_port.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; - in_port.format.video.eColorFormat = QOMX_COLOR_FORMATYUV420PackedSemiPlanar32m; + in_port.format.video.eColorFormat = (OMX_COLOR_FORMATTYPE)QOMX_COLOR_FORMATYUV420PackedSemiPlanar32m; err = OMX_SetParameter(s->handle, OMX_IndexParamPortDefinition, (OMX_PTR) &in_port); @@ -237,45 +253,26 @@ void encoder_init(EncoderState *s, const char* filename, int width, int height, err = OMX_GetParameter(s->handle, OMX_IndexParamPortDefinition, (OMX_PTR)&out_port); assert(err == OMX_ErrorNone); - out_port.format.video.nFrameWidth = s->width; out_port.format.video.nFrameHeight = s->height; out_port.format.video.xFramerate = 0; out_port.format.video.nBitrate = bitrate; - out_port.format.video.eCompressionFormat = OMX_VIDEO_CodingHEVC; - // out_port.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; + if (h265) { + out_port.format.video.eCompressionFormat = OMX_VIDEO_CodingHEVC; + } else { + out_port.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; + } out_port.format.video.eColorFormat = OMX_COLOR_FormatUnused; err = OMX_SetParameter(s->handle, OMX_IndexParamPortDefinition, (OMX_PTR) &out_port); assert(err == OMX_ErrorNone); - err = OMX_GetParameter(s->handle, OMX_IndexParamPortDefinition, (OMX_PTR) &out_port); assert(err == OMX_ErrorNone); s->num_out_bufs = out_port.nBufferCountActual; - // printf("out buf num %d\n", out_port.nBufferSize); - - - // setup HEVC - - OMX_VIDEO_PARAM_HEVCTYPE hecv_type = {0}; - hecv_type.nSize = sizeof(hecv_type); - hecv_type.nPortIndex = (OMX_U32) PORT_INDEX_OUT; - err = OMX_GetParameter(s->handle, (OMX_INDEXTYPE)OMX_IndexParamVideoHevc, - (OMX_PTR) &hecv_type); - assert(err == OMX_ErrorNone); - - hecv_type.eProfile = OMX_VIDEO_HEVCProfileMain; - hecv_type.eLevel = OMX_VIDEO_HEVCHighTierLevel5; - - err = OMX_SetParameter(s->handle, (OMX_INDEXTYPE)OMX_IndexParamVideoHevc, - (OMX_PTR) &hecv_type); - assert(err == OMX_ErrorNone); - - OMX_VIDEO_PARAM_BITRATETYPE bitrate_type = {0}; bitrate_type.nSize = sizeof(bitrate_type); bitrate_type.nPortIndex = (OMX_U32) PORT_INDEX_OUT; @@ -290,42 +287,47 @@ void encoder_init(EncoderState *s, const char* filename, int width, int height, (OMX_PTR) &bitrate_type); assert(err == OMX_ErrorNone); + if (h265) { + // setup HEVC + #ifndef QCOM2 + OMX_VIDEO_PARAM_HEVCTYPE hecv_type = {0}; + OMX_INDEXTYPE index_type = (OMX_INDEXTYPE) OMX_IndexParamVideoHevc; + #else + OMX_VIDEO_PARAM_PROFILELEVELTYPE hecv_type = {0}; + OMX_INDEXTYPE index_type = OMX_IndexParamVideoProfileLevelCurrent; + #endif + hecv_type.nSize = sizeof(hecv_type); + hecv_type.nPortIndex = (OMX_U32) PORT_INDEX_OUT; + err = OMX_GetParameter(s->handle, index_type, + (OMX_PTR) &hecv_type); + assert(err == OMX_ErrorNone); -#if 0 - // setup h264 - OMX_VIDEO_PARAM_BITRATETYPE bitrate_type = {0}; - bitrate_type.nSize = sizeof(bitrate_type); - bitrate_type.nPortIndex = (OMX_U32) PORT_INDEX_OUT; - err = OMX_GetParameter(s->handle, OMX_IndexParamVideoBitrate, - (OMX_PTR) &bitrate_type); - assert(err == OMX_ErrorNone); - - bitrate_type.eControlRate = OMX_Video_ControlRateVariable; - bitrate_type.nTargetBitrate = 2000000; - - err = OMX_SetParameter(s->handle, OMX_IndexParamVideoBitrate, - (OMX_PTR) &bitrate_type); - assert(err == OMX_ErrorNone); - + hecv_type.eProfile = OMX_VIDEO_HEVCProfileMain; + hecv_type.eLevel = OMX_VIDEO_HEVCHighTierLevel5; - OMX_VIDEO_PARAM_AVCTYPE avc = { 0 }; - avc.nSize = sizeof(avc); - avc.nPortIndex = (OMX_U32) PORT_INDEX_OUT; - err = OMX_GetParameter(s->handle, OMX_IndexParamVideoAvc, &avc); - assert(err == OMX_ErrorNone); + err = OMX_SetParameter(s->handle, index_type, + (OMX_PTR) &hecv_type); + assert(err == OMX_ErrorNone); + } else { + // setup h264 + OMX_VIDEO_PARAM_AVCTYPE avc = { 0 }; + avc.nSize = sizeof(avc); + avc.nPortIndex = (OMX_U32) PORT_INDEX_OUT; + err = OMX_GetParameter(s->handle, OMX_IndexParamVideoAvc, &avc); + assert(err == OMX_ErrorNone); - avc.nBFrames = 0; - avc.nPFrames = 20;//avctx->gop_size - 1; + avc.nBFrames = 0; + avc.nPFrames = 15; - avc.eProfile = OMX_VIDEO_AVCProfileBaseline; - avc.eLevel = OMX_VIDEO_AVCLevel31; + avc.eProfile = OMX_VIDEO_AVCProfileBaseline; + avc.eLevel = OMX_VIDEO_AVCLevel31; - avc.nAllowedPictureTypes |= OMX_VIDEO_PictureTypeB; - avc.eLoopFilterMode = OMX_VIDEO_AVCLoopFilterEnable; + avc.nAllowedPictureTypes |= OMX_VIDEO_PictureTypeB; + avc.eLoopFilterMode = OMX_VIDEO_AVCLoopFilterEnable; - err = OMX_SetParameter(s->handle, OMX_IndexParamVideoAvc, &avc); - assert(err == OMX_ErrorNone); -#endif + err = OMX_SetParameter(s->handle, OMX_IndexParamVideoAvc, &avc); + assert(err == OMX_ErrorNone); + } // for (int i = 0; ; i++) { @@ -389,7 +391,6 @@ void encoder_init(EncoderState *s, const char* filename, int width, int height, static void handle_out_buf(EncoderState *s, OMX_BUFFERHEADERTYPE *out_buf) { int err; - uint8_t *buf_data = out_buf->pBuffer + out_buf->nOffset; if (out_buf->nFlags & OMX_BUFFERFLAG_CODECCONFIG) { @@ -398,32 +399,70 @@ static void handle_out_buf(EncoderState *s, OMX_BUFFERHEADERTYPE *out_buf) { } s->codec_config_len = out_buf->nFilledLen; memcpy(s->codec_config, buf_data, out_buf->nFilledLen); - } - - if (s->stream_sock_raw) { - uint64_t current_time = nanos_since_boot(); - uint64_t diff = current_time - out_buf->nTimeStamp*1000LL; - double msdiff = (double) diff / 1000000.0; - // printf("encoded latency to tsEof: %f\n", msdiff); - zmq_send(s->stream_sock_raw, &out_buf->nTimeStamp, sizeof(out_buf->nTimeStamp), ZMQ_SNDMORE); - zmq_send(s->stream_sock_raw, buf_data, out_buf->nFilledLen, 0); +#ifdef QCOM2 + out_buf->nTimeStamp = 0; +#endif } if (s->of) { - // printf("write %d flags 0x%x\n", out_buf->nFilledLen, out_buf->nFlags); + //printf("write %d flags 0x%x\n", out_buf->nFilledLen, out_buf->nFlags); fwrite(buf_data, out_buf->nFilledLen, 1, s->of); } + if (s->remuxing) { + if (!s->wrote_codec_config && s->codec_config_len > 0) { + if (s->codec_ctx->extradata_size < s->codec_config_len) { + s->codec_ctx->extradata = realloc(s->codec_ctx->extradata, s->codec_config_len + AV_INPUT_BUFFER_PADDING_SIZE); + } + s->codec_ctx->extradata_size = s->codec_config_len; + memcpy(s->codec_ctx->extradata, s->codec_config, s->codec_config_len); + memset(s->codec_ctx->extradata + s->codec_ctx->extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); + + err = avcodec_parameters_from_context(s->out_stream->codecpar, s->codec_ctx); + assert(err >= 0); + err = avformat_write_header(s->ofmt_ctx, NULL); + assert(err >= 0); + + s->wrote_codec_config = true; + } + + if (out_buf->nTimeStamp > 0) { + // input timestamps are in microseconds + AVRational in_timebase = {1, 1000000}; + + AVPacket pkt; + av_init_packet(&pkt); + pkt.data = buf_data; + pkt.size = out_buf->nFilledLen; + pkt.pts = pkt.dts = av_rescale_q_rnd(out_buf->nTimeStamp, in_timebase, s->ofmt_ctx->streams[0]->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); + pkt.duration = av_rescale_q(50*1000, in_timebase, s->ofmt_ctx->streams[0]->time_base); + + if (out_buf->nFlags & OMX_BUFFERFLAG_SYNCFRAME) { + pkt.flags |= AV_PKT_FLAG_KEY; + } + + err = av_write_frame(s->ofmt_ctx, &pkt); + if (err < 0) { LOGW("ts encoder write issue"); } + + av_free_packet(&pkt); + } + } + // give omx back the buffer +#ifdef QCOM2 + if (out_buf->nFlags & OMX_BUFFERFLAG_EOS) { + out_buf->nTimeStamp = 0; + } +#endif err = OMX_FillThisBuffer(s->handle, out_buf); assert(err == OMX_ErrorNone); } -int encoder_encode_frame(EncoderState *s, uint64_t ts, +int encoder_encode_frame(EncoderState *s, const uint8_t *y_ptr, const uint8_t *u_ptr, const uint8_t *v_ptr, + int in_width, int in_height, int *frame_segment, VIPCBufExtra *extra) { int err; - pthread_mutex_lock(&s->lock); if (s->opening) { @@ -438,17 +477,16 @@ int encoder_encode_frame(EncoderState *s, uint64_t ts, // this sometimes freezes... put it outside the encoder lock so we can still trigger rotates... // THIS IS A REALLY BAD IDEA, but apparently the race has to happen 30 times to trigger this - pthread_mutex_unlock(&s->lock); + //pthread_mutex_unlock(&s->lock); OMX_BUFFERHEADERTYPE* in_buf = queue_pop(&s->free_in); - pthread_mutex_lock(&s->lock); - - if (s->rotating) { - encoder_close(s); - encoder_open(s, s->next_path); - s->segment = s->next_segment; - s->rotating = false; - } + //pthread_mutex_lock(&s->lock); + // if (s->rotating) { + // encoder_close(s); + // encoder_open(s, s->next_path); + // s->segment = s->next_segment; + // s->rotating = false; + // } int ret = s->counter; uint8_t *in_buf_ptr = in_buf->pBuffer; @@ -456,10 +494,24 @@ int encoder_encode_frame(EncoderState *s, uint64_t ts, uint8_t *in_y_ptr = in_buf_ptr; int in_y_stride = VENUS_Y_STRIDE(COLOR_FMT_NV12, s->width); - int in_uv_stride = VENUS_UV_STRIDE(COLOR_FMT_NV12, s->width); + int in_uv_stride = VENUS_UV_STRIDE(COLOR_FMT_NV12, s->width); // uint8_t *in_uv_ptr = in_buf_ptr + (s->width * s->height); uint8_t *in_uv_ptr = in_buf_ptr + (in_y_stride * VENUS_Y_SCANLINES(COLOR_FMT_NV12, s->height)); + if (s->downscale) { + I420Scale(y_ptr, in_width, + u_ptr, in_width/2, + v_ptr, in_width/2, + in_width, in_height, + s->y_ptr2, s->width, + s->u_ptr2, s->width/2, + s->v_ptr2, s->width/2, + s->width, s->height, + kFilterNone); + y_ptr = s->y_ptr2; + u_ptr = s->u_ptr2; + v_ptr = s->v_ptr2; + } err = I420ToNV12(y_ptr, s->width, u_ptr, s->width/2, v_ptr, s->width/2, @@ -472,7 +524,8 @@ int encoder_encode_frame(EncoderState *s, uint64_t ts, in_buf->nFilledLen = VENUS_BUFFER_SIZE(COLOR_FMT_NV12, s->width, s->height); in_buf->nFlags = OMX_BUFFERFLAG_ENDOFFRAME; in_buf->nOffset = 0; - in_buf->nTimeStamp = extra->timestamp_eof/1000LL; + in_buf->nTimeStamp = extra->timestamp_eof/1000LL; // OMX_TICKS, in microseconds + s->last_t = in_buf->nTimeStamp; err = OMX_EmptyThisBuffer(s->handle, in_buf); assert(err == OMX_ErrorNone); @@ -508,12 +561,42 @@ void encoder_open(EncoderState *s, const char* path) { pthread_mutex_lock(&s->lock); - snprintf(s->vid_path, sizeof(s->vid_path), "%s/%s.hevc", path, s->filename); - s->of = fopen(s->vid_path, "wb"); - assert(s->of); + snprintf(s->vid_path, sizeof(s->vid_path), "%s/%s", path, s->filename); + LOGD("encoder_open %s remuxing:%d", s->vid_path, s->remuxing); + + if (s->remuxing) { + avformat_alloc_output_context2(&s->ofmt_ctx, NULL, NULL, s->vid_path); + assert(s->ofmt_ctx); + + s->out_stream = avformat_new_stream(s->ofmt_ctx, NULL); + assert(s->out_stream); + + // set codec correctly + av_register_all(); - if (s->codec_config_len > 0) { - fwrite(s->codec_config, s->codec_config_len, 1, s->of); + AVCodec *codec = NULL; + codec = avcodec_find_encoder(AV_CODEC_ID_H264); + assert(codec); + + s->codec_ctx = avcodec_alloc_context3(codec); + assert(s->codec_ctx); + s->codec_ctx->width = s->width; + s->codec_ctx->height = s->height; + s->codec_ctx->pix_fmt = AV_PIX_FMT_YUV420P; + s->codec_ctx->time_base = (AVRational){ 1, s->fps }; + + err = avio_open(&s->ofmt_ctx->pb, s->vid_path, AVIO_FLAG_WRITE); + assert(err >= 0); + + s->wrote_codec_config = false; + } else { + s->of = fopen(s->vid_path, "wb"); + assert(s->of); + if (s->codec_config_len > 0) { +#ifndef QCOM2 + fwrite(s->codec_config, s->codec_config_len, 1, s->of); +#endif + } } // create camera lock file @@ -541,7 +624,7 @@ void encoder_close(EncoderState *s) { in_buf->nFilledLen = 0; in_buf->nOffset = 0; in_buf->nFlags = OMX_BUFFERFLAG_EOS; - in_buf->nTimeStamp = 0; + in_buf->nTimeStamp = s->last_t + 1000000LL/s->fps; err = OMX_EmptyThisBuffer(s->handle, in_buf); assert(err == OMX_ErrorNone); @@ -558,7 +641,14 @@ void encoder_close(EncoderState *s) { s->dirty = false; } - fclose(s->of); + if (s->remuxing) { + av_write_trailer(s->ofmt_ctx); + avcodec_free_context(&s->codec_ctx); + avio_closep(&s->ofmt_ctx->pb); + avformat_free_context(s->ofmt_ctx); + } else { + fclose(s->of); + } unlink(s->lock_path); } s->open = false; @@ -612,6 +702,12 @@ void encoder_destroy(EncoderState *s) { err = OMX_FreeHandle(s->handle); assert(err == OMX_ErrorNone); + + if (s->downscale) { + free(s->y_ptr2); + free(s->u_ptr2); + free(s->v_ptr2); + } } #if 0 @@ -658,7 +754,7 @@ int main() { memset(inbuf, 0, w*h*3/2); for (int i=0; i<20*3+5; i++) { - + // fread(inbuf, w*h*3/2, 1, infile); uint8_t *tmpy = inbuf; @@ -692,7 +788,7 @@ int main() { encoder_rotate(s, "/sdcard/t2"); for (int i=0; i<20*3+5; i++) { - + // fread(inbuf, w*h*3/2, 1, infile); uint8_t *tmpy = inbuf; diff --git a/selfdrive/loggerd/encoder.h b/selfdrive/loggerd/encoder.h index 617dee28bd4629..8036162b2416bd 100644 --- a/selfdrive/loggerd/encoder.h +++ b/selfdrive/loggerd/encoder.h @@ -8,6 +8,7 @@ #include #include +#include #include "common/cqueue.h" #include "common/visionipc.h" @@ -38,6 +39,7 @@ typedef struct EncoderState { size_t codec_config_len; uint8_t *codec_config; + bool wrote_codec_config; pthread_mutex_t state_lock; pthread_cond_t state_cv; @@ -47,19 +49,28 @@ typedef struct EncoderState { int num_in_bufs; OMX_BUFFERHEADERTYPE** in_buf_headers; - + int num_out_bufs; OMX_BUFFERHEADERTYPE** out_buf_headers; + uint64_t last_t; + Queue free_in; Queue done_out; - void *stream_sock_raw; + AVFormatContext *ofmt_ctx; + AVCodecContext *codec_ctx; + AVStream *out_stream; + bool remuxing; + + bool downscale; + uint8_t *y_ptr2, *u_ptr2, *v_ptr2; } EncoderState; -void encoder_init(EncoderState *s, const char* filename, int width, int height, int fps, int bitrate); -int encoder_encode_frame(EncoderState *s, uint64_t ts, +void encoder_init(EncoderState *s, const char* filename, int width, int height, int fps, int bitrate, bool h265, bool downscale); +int encoder_encode_frame(EncoderState *s, const uint8_t *y_ptr, const uint8_t *u_ptr, const uint8_t *v_ptr, + int in_width, int in_height, int *frame_segment, VIPCBufExtra *extra); void encoder_open(EncoderState *s, const char* path); void encoder_rotate(EncoderState *s, const char* new_path, int new_segment); diff --git a/selfdrive/loggerd/frame_logger.h b/selfdrive/loggerd/frame_logger.h index bfc0681b756af0..85ddabafdc6f2e 100644 --- a/selfdrive/loggerd/frame_logger.h +++ b/selfdrive/loggerd/frame_logger.h @@ -15,7 +15,7 @@ class FrameLogger { int LogFrame(uint64_t ts, const uint8_t *y_ptr, const uint8_t *u_ptr, const uint8_t *v_ptr, int *frame_segment) { std::lock_guard guard(lock); - + if (opening) { Open(next_path); opening = false; diff --git a/selfdrive/loggerd/logger.c b/selfdrive/loggerd/logger.c deleted file mode 100644 index 7dfb610badd35c..00000000000000 --- a/selfdrive/loggerd/logger.c +++ /dev/null @@ -1,217 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "common/swaglog.h" - -#include "logger.h" - -static int mkpath(char* file_path) { - assert(file_path && *file_path); - char* p; - for (p=strchr(file_path+1, '/'); p; p=strchr(p+1, '/')) { - *p = '\0'; - if (mkdir(file_path, 0777)==-1) { - if (errno != EEXIST) { - *p = '/'; - return -1; - } - } - *p = '/'; - } - return 0; -} - -void logger_init(LoggerState *s, const char* log_name, const uint8_t* init_data, size_t init_data_len, bool has_qlog) { - memset(s, 0, sizeof(*s)); - if (init_data) { - s->init_data = (uint8_t*)malloc(init_data_len); - assert(s->init_data); - memcpy(s->init_data, init_data, init_data_len); - s->init_data_len = init_data_len; - } - - umask(0); - - pthread_mutex_init(&s->lock, NULL); - - s->part = -1; - s->has_qlog = has_qlog; - - time_t rawtime = time(NULL); - struct tm timeinfo; - localtime_r(&rawtime, &timeinfo); - - strftime(s->route_name, sizeof(s->route_name), - "%Y-%m-%d--%H-%M-%S", &timeinfo); - snprintf(s->log_name, sizeof(s->log_name), "%s", log_name); -} - -static LoggerHandle* logger_open(LoggerState *s, const char* root_path) { - int err; - - LoggerHandle *h = NULL; - for (int i=0; ihandles[i].refcnt == 0) { - h = &s->handles[i]; - break; - } - } - assert(h); - - snprintf(h->segment_path, sizeof(h->segment_path), - "%s/%s--%d", root_path, s->route_name, s->part); - - snprintf(h->log_path, sizeof(h->log_path), "%s/%s.bz2", h->segment_path, s->log_name); - snprintf(h->qlog_path, sizeof(h->qlog_path), "%s/qlog.bz2", h->segment_path); - snprintf(h->lock_path, sizeof(h->lock_path), "%s.lock", h->log_path); - - err = mkpath(h->log_path); - if (err) return NULL; - - FILE* lock_file = fopen(h->lock_path, "wb"); - if (lock_file == NULL) return NULL; - fclose(lock_file); - - h->log_file = fopen(h->log_path, "wb"); - if (h->log_file == NULL) goto fail; - - if (s->has_qlog) { - h->qlog_file = fopen(h->qlog_path, "wb"); - if (h->qlog_file == NULL) goto fail; - } - - int bzerror; - h->bz_file = BZ2_bzWriteOpen(&bzerror, h->log_file, 9, 0, 30); - if (bzerror != BZ_OK) goto fail; - - if (s->has_qlog) { - h->bz_qlog = BZ2_bzWriteOpen(&bzerror, h->qlog_file, 9, 0, 30); - if (bzerror != BZ_OK) goto fail; - } - - if (s->init_data) { - BZ2_bzWrite(&bzerror, h->bz_file, s->init_data, s->init_data_len); - if (bzerror != BZ_OK) goto fail; - - if (s->has_qlog) { - // init data goes in the qlog too - BZ2_bzWrite(&bzerror, h->bz_qlog, s->init_data, s->init_data_len); - if (bzerror != BZ_OK) goto fail; - } - } - - pthread_mutex_init(&h->lock, NULL); - h->refcnt++; - return h; -fail: - LOGE("logger failed to open files"); - if (h->qlog_file) fclose(h->qlog_file); - if (h->log_file) fclose(h->log_file); - return NULL; -} - -int logger_next(LoggerState *s, const char* root_path, - char* out_segment_path, size_t out_segment_path_len, - int* out_part) { - pthread_mutex_lock(&s->lock); - s->part++; - - LoggerHandle* next_h = logger_open(s, root_path); - if (!next_h) { - pthread_mutex_unlock(&s->lock); - return -1; - } - - if (s->cur_handle) { - lh_close(s->cur_handle); - } - s->cur_handle = next_h; - - if (out_segment_path) { - snprintf(out_segment_path, out_segment_path_len, "%s", next_h->segment_path); - } - if (out_part) { - *out_part = s->part; - } - - pthread_mutex_unlock(&s->lock); - return 0; -} - -LoggerHandle* logger_get_handle(LoggerState *s) { - pthread_mutex_lock(&s->lock); - LoggerHandle* h = s->cur_handle; - if (h) { - pthread_mutex_lock(&h->lock); - h->refcnt++; - pthread_mutex_unlock(&h->lock); - } - pthread_mutex_unlock(&s->lock); - return h; -} - -void logger_log(LoggerState *s, uint8_t* data, size_t data_size, bool in_qlog) { - pthread_mutex_lock(&s->lock); - if (s->cur_handle) { - lh_log(s->cur_handle, data, data_size, in_qlog); - } - pthread_mutex_unlock(&s->lock); -} - -void logger_close(LoggerState *s) { - pthread_mutex_lock(&s->lock); - free(s->init_data); - if (s->cur_handle) { - lh_close(s->cur_handle); - } - pthread_mutex_unlock(&s->lock); -} - -void lh_log(LoggerHandle* h, uint8_t* data, size_t data_size, bool in_qlog) { - pthread_mutex_lock(&h->lock); - assert(h->refcnt > 0); - int bzerror; - BZ2_bzWrite(&bzerror, h->bz_file, data, data_size); - - if (in_qlog && h->bz_qlog != NULL) { - BZ2_bzWrite(&bzerror, h->bz_qlog, data, data_size); - } - pthread_mutex_unlock(&h->lock); -} - -void lh_close(LoggerHandle* h) { - pthread_mutex_lock(&h->lock); - assert(h->refcnt > 0); - h->refcnt--; - if (h->refcnt == 0) { - if (h->bz_file){ - int bzerror; - BZ2_bzWriteClose(&bzerror, h->bz_file, 0, NULL, NULL); - h->bz_file = NULL; - } - if (h->bz_qlog){ - int bzerror; - BZ2_bzWriteClose(&bzerror, h->bz_qlog, 0, NULL, NULL); - h->bz_qlog = NULL; - } - if (h->qlog_file) fclose(h->qlog_file); - fclose(h->log_file); - unlink(h->lock_path); - pthread_mutex_unlock(&h->lock); - pthread_mutex_destroy(&h->lock); - return; - } - pthread_mutex_unlock(&h->lock); -} diff --git a/selfdrive/loggerd/logger.cc b/selfdrive/loggerd/logger.cc new file mode 100644 index 00000000000000..0cec20f68006ed --- /dev/null +++ b/selfdrive/loggerd/logger.cc @@ -0,0 +1,252 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include "messaging.hpp" + +#include "common/swaglog.h" + +#include "logger.h" + +static void log_sentinel(LoggerState *s, cereal::Sentinel::SentinelType type) { + MessageBuilder msg; + auto sen = msg.initEvent().initSentinel(); + sen.setType(type); + auto bytes = msg.toBytes(); + + logger_log(s, bytes.begin(), bytes.size(), true); +} + +static int mkpath(char* file_path) { + assert(file_path && *file_path); + char* p; + for (p=strchr(file_path+1, '/'); p; p=strchr(p+1, '/')) { + *p = '\0'; + if (mkdir(file_path, 0777)==-1) { + if (errno != EEXIST) { + *p = '/'; + return -1; + } + } + *p = '/'; + } + return 0; +} + +void logger_init(LoggerState *s, const char* log_name, const uint8_t* init_data, size_t init_data_len, bool has_qlog) { + memset(s, 0, sizeof(*s)); + if (init_data) { + s->init_data = (uint8_t*)malloc(init_data_len); + assert(s->init_data); + memcpy(s->init_data, init_data, init_data_len); + s->init_data_len = init_data_len; + } + + umask(0); + + pthread_mutex_init(&s->lock, NULL); + + s->part = -1; + s->has_qlog = has_qlog; + + time_t rawtime = time(NULL); + struct tm timeinfo; + localtime_r(&rawtime, &timeinfo); + + strftime(s->route_name, sizeof(s->route_name), + "%Y-%m-%d--%H-%M-%S", &timeinfo); + snprintf(s->log_name, sizeof(s->log_name), "%s", log_name); +} + +static LoggerHandle* logger_open(LoggerState *s, const char* root_path) { + int err; + + LoggerHandle *h = NULL; + for (int i=0; ihandles[i].refcnt == 0) { + h = &s->handles[i]; + break; + } + } + assert(h); + + snprintf(h->segment_path, sizeof(h->segment_path), + "%s/%s--%d", root_path, s->route_name, s->part); + + snprintf(h->log_path, sizeof(h->log_path), "%s/%s.bz2", h->segment_path, s->log_name); + snprintf(h->qlog_path, sizeof(h->qlog_path), "%s/qlog.bz2", h->segment_path); + snprintf(h->lock_path, sizeof(h->lock_path), "%s.lock", h->log_path); + + err = mkpath(h->log_path); + if (err) return NULL; + + FILE* lock_file = fopen(h->lock_path, "wb"); + if (lock_file == NULL) return NULL; + fclose(lock_file); + + h->log_file = fopen(h->log_path, "wb"); + if (h->log_file == NULL) goto fail; + + if (s->has_qlog) { + h->qlog_file = fopen(h->qlog_path, "wb"); + if (h->qlog_file == NULL) goto fail; + } + + int bzerror; + h->bz_file = BZ2_bzWriteOpen(&bzerror, h->log_file, 9, 0, 30); + if (bzerror != BZ_OK) goto fail; + + if (s->has_qlog) { + h->bz_qlog = BZ2_bzWriteOpen(&bzerror, h->qlog_file, 9, 0, 30); + if (bzerror != BZ_OK) goto fail; + } + + if (s->init_data) { + BZ2_bzWrite(&bzerror, h->bz_file, s->init_data, s->init_data_len); + if (bzerror != BZ_OK) goto fail; + + if (s->has_qlog) { + // init data goes in the qlog too + BZ2_bzWrite(&bzerror, h->bz_qlog, s->init_data, s->init_data_len); + if (bzerror != BZ_OK) goto fail; + } + } + + pthread_mutex_init(&h->lock, NULL); + h->refcnt++; + return h; +fail: + LOGE("logger failed to open files"); + if (h->bz_file) { + BZ2_bzWriteClose(&bzerror, h->bz_file, 0, NULL, NULL); + h->bz_file = NULL; + } + if (h->bz_qlog) { + BZ2_bzWriteClose(&bzerror, h->bz_qlog, 0, NULL, NULL); + h->bz_qlog = NULL; + } + if (h->qlog_file) { + fclose(h->qlog_file); + h->qlog_file = NULL; + } + if (h->log_file) { + fclose(h->log_file); + h->log_file = NULL; + } + return NULL; +} + +int logger_next(LoggerState *s, const char* root_path, + char* out_segment_path, size_t out_segment_path_len, + int* out_part) { + bool is_start_of_route = !s->cur_handle; + if (!is_start_of_route) log_sentinel(s, cereal::Sentinel::SentinelType::END_OF_SEGMENT); + + pthread_mutex_lock(&s->lock); + s->part++; + + LoggerHandle* next_h = logger_open(s, root_path); + if (!next_h) { + pthread_mutex_unlock(&s->lock); + return -1; + } + + if (s->cur_handle) { + lh_close(s->cur_handle); + } + s->cur_handle = next_h; + + if (out_segment_path) { + snprintf(out_segment_path, out_segment_path_len, "%s", next_h->segment_path); + } + if (out_part) { + *out_part = s->part; + } + + pthread_mutex_unlock(&s->lock); + + log_sentinel(s, is_start_of_route ? cereal::Sentinel::SentinelType::START_OF_ROUTE : cereal::Sentinel::SentinelType::START_OF_SEGMENT); + return 0; +} + +LoggerHandle* logger_get_handle(LoggerState *s) { + pthread_mutex_lock(&s->lock); + LoggerHandle* h = s->cur_handle; + if (h) { + pthread_mutex_lock(&h->lock); + h->refcnt++; + pthread_mutex_unlock(&h->lock); + } + pthread_mutex_unlock(&s->lock); + return h; +} + +void logger_log(LoggerState *s, uint8_t* data, size_t data_size, bool in_qlog) { + pthread_mutex_lock(&s->lock); + if (s->cur_handle) { + lh_log(s->cur_handle, data, data_size, in_qlog); + } + pthread_mutex_unlock(&s->lock); +} + +void logger_close(LoggerState *s) { + log_sentinel(s, cereal::Sentinel::SentinelType::END_OF_ROUTE); + + pthread_mutex_lock(&s->lock); + free(s->init_data); + if (s->cur_handle) { + lh_close(s->cur_handle); + } + pthread_mutex_unlock(&s->lock); +} + +void lh_log(LoggerHandle* h, uint8_t* data, size_t data_size, bool in_qlog) { + pthread_mutex_lock(&h->lock); + assert(h->refcnt > 0); + int bzerror; + BZ2_bzWrite(&bzerror, h->bz_file, data, data_size); + + if (in_qlog && h->bz_qlog != NULL) { + BZ2_bzWrite(&bzerror, h->bz_qlog, data, data_size); + } + pthread_mutex_unlock(&h->lock); +} + +void lh_close(LoggerHandle* h) { + pthread_mutex_lock(&h->lock); + assert(h->refcnt > 0); + h->refcnt--; + if (h->refcnt == 0) { + if (h->bz_file){ + int bzerror; + BZ2_bzWriteClose(&bzerror, h->bz_file, 0, NULL, NULL); + h->bz_file = NULL; + } + if (h->bz_qlog){ + int bzerror; + BZ2_bzWriteClose(&bzerror, h->bz_qlog, 0, NULL, NULL); + h->bz_qlog = NULL; + } + if (h->qlog_file) { + fclose(h->qlog_file); + h->qlog_file = NULL; + } + fclose(h->log_file); + h->log_file = NULL; + unlink(h->lock_path); + pthread_mutex_unlock(&h->lock); + pthread_mutex_destroy(&h->lock); + return; + } + pthread_mutex_unlock(&h->lock); +} diff --git a/selfdrive/loggerd/loggerd.cc b/selfdrive/loggerd/loggerd.cc index db59780f0b3bba..8dd328df704ebd 100644 --- a/selfdrive/loggerd/loggerd.cc +++ b/selfdrive/loggerd/loggerd.cc @@ -10,22 +10,23 @@ #include #include #include +#include #include #include #include +#include #include #include #include #include +#include #include #include - -#include -#include -#include +#ifdef QCOM #include +#endif #include "common/version.h" #include "common/timing.h" @@ -34,27 +35,85 @@ #include "common/visionipc.h" #include "common/utilpp.h" #include "common/util.h" - +#include "camerad/cameras/camera_common.h" #include "logger.h" +#include "messaging.hpp" +#include "services.h" +#if !(defined(QCOM) || defined(QCOM2)) +// no encoder on PC +#define DISABLE_ENCODER +#endif #ifndef DISABLE_ENCODER #include "encoder.h" -#include "raw_logger.h" #endif -#include "cereal/gen/cpp/log.capnp.h" +#define MAIN_BITRATE 5000000 +#define QCAM_BITRATE 128000 +#define MAIN_FPS 20 +#ifndef QCOM2 +#define MAX_CAM_IDX LOG_CAMERA_ID_DCAMERA +#define DCAM_BITRATE 2500000 +#else +#define MAX_CAM_IDX LOG_CAMERA_ID_ECAMERA +#define DCAM_BITRATE MAIN_BITRATE +#endif -#define CAMERA_FPS 20 +#define NO_CAMERA_PATIENCE 500 // fall back to time-based rotation if all cameras are dead + +LogCameraInfo cameras_logged[LOG_CAMERA_ID_MAX] = { + [LOG_CAMERA_ID_FCAMERA] = { + .stream_type = VISION_STREAM_YUV, + .filename = "fcamera.hevc", + .frame_packet_name = "frame", + .fps = MAIN_FPS, + .bitrate = MAIN_BITRATE, + .is_h265 = true, + .downscale = false, + .has_qcamera = true + }, + [LOG_CAMERA_ID_DCAMERA] = { + .stream_type = VISION_STREAM_YUV_FRONT, + .filename = "dcamera.hevc", + .frame_packet_name = "frontFrame", + .fps = MAIN_FPS, // on EONs, more compressed this way + .bitrate = DCAM_BITRATE, + .is_h265 = true, + .downscale = false, + .has_qcamera = false + }, + [LOG_CAMERA_ID_ECAMERA] = { + .stream_type = VISION_STREAM_YUV_WIDE, + .filename = "ecamera.hevc", + .frame_packet_name = "wideFrame", + .fps = MAIN_FPS, + .bitrate = MAIN_BITRATE, + .is_h265 = true, + .downscale = false, + .has_qcamera = false + }, + [LOG_CAMERA_ID_QCAMERA] = { + .filename = "qcamera.ts", + .fps = MAIN_FPS, + .bitrate = QCAM_BITRATE, + .is_h265 = false, + .downscale = true, +#ifndef QCOM2 + .frame_width = 480, .frame_height = 360 +#else + .frame_width = 526, .frame_height = 330 // keep pixel count the same? +#endif + }, +}; #define SEGMENT_LENGTH 60 + #define LOG_ROOT "/data/media/0/realdata" -#define ENABLE_LIDAR 0 -#define RAW_CLIP_LENGTH 100 // 5 seconds at 20fps -#define RAW_CLIP_FREQUENCY (randrange(61, 8*60)) // once every ~4 minutes namespace { +double randrange(double a, double b) __attribute__((unused)); double randrange(double a, double b) { static std::mt19937 gen(millis_since_boot()); @@ -63,61 +122,124 @@ double randrange(double a, double b) { } -volatile int do_exit = 0; +volatile sig_atomic_t do_exit = 0; static void set_do_exit(int sig) { do_exit = 1; } -struct LoggerdState { - void *ctx; - LoggerState logger; - std::mutex lock; +static bool file_exists (const std::string& fn) { + std::ifstream f(fn); + return f.good(); +} + +class RotateState { +public: + SubSocket* fpkt_sock; + uint32_t stream_frame_id, log_frame_id, last_rotate_frame_id; + bool enabled, should_rotate, initialized; + + RotateState() : fpkt_sock(nullptr), stream_frame_id(0), log_frame_id(0), + last_rotate_frame_id(UINT32_MAX), enabled(false), should_rotate(false), initialized(false) {}; + + void waitLogThread() { + std::unique_lock lk(fid_lock); + while (stream_frame_id > log_frame_id //if the log camera is older, wait for it to catch up. + && (stream_frame_id - log_frame_id) < 8 // but if its too old then there probably was a discontinuity (visiond restarted) + && !do_exit) { + cv.wait(lk); + } + } + + void cancelWait() { cv.notify_one(); } + + void setStreamFrameId(uint32_t frame_id) { + fid_lock.lock(); + stream_frame_id = frame_id; + fid_lock.unlock(); + cv.notify_one(); + } + + void setLogFrameId(uint32_t frame_id) { + fid_lock.lock(); + log_frame_id = frame_id; + fid_lock.unlock(); + cv.notify_one(); + } + + void rotate() { + if (!enabled) { return; } + std::unique_lock lk(fid_lock); + should_rotate = true; + last_rotate_frame_id = stream_frame_id; + } + + void finish_rotate() { + std::unique_lock lk(fid_lock); + should_rotate = false; + } + +private: + std::mutex fid_lock; std::condition_variable cv; +}; + +struct LoggerdState { + Context *ctx; + LoggerState logger; char segment_path[4096]; - uint32_t last_frame_id; - uint32_t rotate_last_frame_id; int rotate_segment; + pthread_mutex_t rotate_lock; + int num_encoder; + std::atomic rotate_seq_id; + std::atomic should_close; + std::atomic finish_close; + + RotateState rotate_state[LOG_CAMERA_ID_MAX-1]; }; LoggerdState s; #ifndef DISABLE_ENCODER -void encoder_thread(bool is_streaming, bool raw_clips, bool front) { - int err; - - if (front) { - char *value; - const int result = read_db_value(NULL, "RecordFront", &value, NULL); - if (result != 0) return; - if (value[0] != '1') { free(value); return; } - free(value); - LOGW("recording front camera"); +void encoder_thread(RotateState *rotate_state, int cam_idx) { - set_thread_name("FrontCameraEncoder"); - } else { - set_thread_name("RearCameraEncoder"); + switch (cam_idx) { + case LOG_CAMERA_ID_DCAMERA: { + LOGW("recording front camera"); + set_thread_name("FrontCameraEncoder"); + break; + } + case LOG_CAMERA_ID_FCAMERA: { + set_thread_name("RearCameraEncoder"); + break; + } + case LOG_CAMERA_ID_ECAMERA: { + set_thread_name("WideCameraEncoder"); + break; + } + default: { + LOGE("unexpected camera index provided"); + assert(false); + } } VisionStream stream; bool encoder_inited = false; EncoderState encoder; + EncoderState encoder_alt; + bool has_encoder_alt = cameras_logged[cam_idx].has_qcamera; int encoder_segment = -1; int cnt = 0; - - void *idx_sock = zmq_socket(s.ctx, ZMQ_PUB); - assert(idx_sock); - zmq_bind(idx_sock, front ? "tcp://*:8061" : "tcp://*:8015"); + pthread_mutex_lock(&s.rotate_lock); + int my_idx = s.num_encoder; + s.num_encoder += 1; + pthread_mutex_unlock(&s.rotate_lock); LoggerHandle *lh = NULL; while (!do_exit) { VisionStreamBufs buf_info; - if (front) { - err = visionstream_init(&stream, VISION_STREAM_YUV_FRONT, false, &buf_info); - } else { - err = visionstream_init(&stream, VISION_STREAM_YUV, false, &buf_info); - } + int err = visionstream_init(&stream, cameras_logged[cam_idx].stream_type, false, &buf_info); if (err != 0) { LOGD("visionstream connect fail"); usleep(100000); @@ -126,22 +248,25 @@ void encoder_thread(bool is_streaming, bool raw_clips, bool front) { if (!encoder_inited) { LOGD("encoder init %dx%d", buf_info.width, buf_info.height); - encoder_init(&encoder, front ? "dcamera" : "fcamera", buf_info.width, buf_info.height, CAMERA_FPS, front ? 1000000 : 5000000); - encoder_inited = true; - if (is_streaming) { - encoder.stream_sock_raw = zmq_socket(s.ctx, ZMQ_PUB); - assert(encoder.stream_sock_raw); - zmq_bind(encoder.stream_sock_raw, "tcp://*:9002"); + encoder_init(&encoder, cameras_logged[cam_idx].filename, + buf_info.width, + buf_info.height, + cameras_logged[cam_idx].fps, + cameras_logged[cam_idx].bitrate, + cameras_logged[cam_idx].is_h265, + cameras_logged[cam_idx].downscale); + + if (has_encoder_alt) { + encoder_init(&encoder_alt, cameras_logged[LOG_CAMERA_ID_QCAMERA].filename, + cameras_logged[LOG_CAMERA_ID_QCAMERA].frame_width, + cameras_logged[LOG_CAMERA_ID_QCAMERA].frame_height, + cameras_logged[LOG_CAMERA_ID_QCAMERA].fps, + cameras_logged[LOG_CAMERA_ID_QCAMERA].bitrate, + cameras_logged[LOG_CAMERA_ID_QCAMERA].is_h265, + cameras_logged[LOG_CAMERA_ID_QCAMERA].downscale); } - } - - // dont log a raw clip in the first minute - double rawlogger_start_time = seconds_since_boot()+RAW_CLIP_FREQUENCY; - int rawlogger_clip_cnt = 0; - RawLogger *rawlogger = NULL; - if (raw_clips) { - rawlogger = new RawLogger("prcamera", buf_info.width, buf_info.height, CAMERA_FPS); + encoder_inited = true; } while (!do_exit) { @@ -152,118 +277,113 @@ void encoder_thread(bool is_streaming, bool raw_clips, bool front) { break; } - uint64_t current_time = nanos_since_boot(); - uint64_t diff = current_time - extra.timestamp_eof; - double msdiff = (double) diff / 1000000.0; + //uint64_t current_time = nanos_since_boot(); + //uint64_t diff = current_time - extra.timestamp_eof; + //double msdiff = (double) diff / 1000000.0; // printf("logger latency to tsEof: %f\n", msdiff); - uint8_t *y = (uint8_t*)buf->addr; - uint8_t *u = y + (buf_info.width*buf_info.height); - uint8_t *v = u + (buf_info.width/2)*(buf_info.height/2); + { // all the rotation stuff + + pthread_mutex_lock(&s.rotate_lock); + pthread_mutex_unlock(&s.rotate_lock); + + // wait if camera pkt id is older than stream + rotate_state->waitLogThread(); - { - bool should_rotate = false; - std::unique_lock lk(s.lock); - if (!front) { - // wait if log camera is older on back camera - while ( extra.frame_id > s.last_frame_id //if the log camera is older, wait for it to catch up. - && (extra.frame_id-s.last_frame_id) < 8 // but if its too old then there probably was a discontinuity (visiond restarted) - && !do_exit) { - s.cv.wait(lk); - } - should_rotate = extra.frame_id > s.rotate_last_frame_id && encoder_segment < s.rotate_segment; - } else { - // front camera is best effort - should_rotate = encoder_segment < s.rotate_segment; - } if (do_exit) break; // rotate the encoder if the logger is on a newer segment - if (should_rotate) { - LOG("rotate encoder to %s", s.segment_path); - + if (rotate_state->should_rotate) { + if (!rotate_state->initialized) { + rotate_state->last_rotate_frame_id = extra.frame_id - 1; + rotate_state->initialized = true; + } + while (s.rotate_seq_id != my_idx && !do_exit) { usleep(1000); } + LOGW("camera %d rotate encoder to %s.", cam_idx, s.segment_path); encoder_rotate(&encoder, s.segment_path, s.rotate_segment); - - if (raw_clips) { - rawlogger->Rotate(s.segment_path, s.rotate_segment); + s.rotate_seq_id = (my_idx + 1) % s.num_encoder; + if (has_encoder_alt) { + encoder_rotate(&encoder_alt, s.segment_path, s.rotate_segment); } - encoder_segment = s.rotate_segment; if (lh) { lh_close(lh); } lh = logger_get_handle(&s.logger); + + pthread_mutex_lock(&s.rotate_lock); + s.should_close += 1; + pthread_mutex_unlock(&s.rotate_lock); + + while(s.should_close > 0 && s.should_close < s.num_encoder && !do_exit) { usleep(1000); } + + pthread_mutex_lock(&s.rotate_lock); + s.should_close = s.should_close == s.num_encoder ? 1 - s.num_encoder : s.should_close + 1; + + encoder_close(&encoder); + encoder_open(&encoder, encoder.next_path); + encoder.segment = encoder.next_segment; + encoder.rotating = false; + if (has_encoder_alt) { + encoder_close(&encoder_alt); + encoder_open(&encoder_alt, encoder_alt.next_path); + encoder_alt.segment = encoder_alt.next_segment; + encoder_alt.rotating = false; + } + s.finish_close += 1; + pthread_mutex_unlock(&s.rotate_lock); + + while(s.finish_close > 0 && s.finish_close < s.num_encoder && !do_exit) { usleep(1000); } + s.finish_close = 0; + + rotate_state->finish_rotate(); } } + rotate_state->setStreamFrameId(extra.frame_id); + + uint8_t *y = (uint8_t*)buf->addr; + uint8_t *u = y + (buf_info.width*buf_info.height); + uint8_t *v = u + (buf_info.width/2)*(buf_info.height/2); { // encode hevc int out_segment = -1; - int out_id = encoder_encode_frame(&encoder, cnt*50000ULL, - y, u, v, &out_segment, &extra); + int out_id = encoder_encode_frame(&encoder, + y, u, v, + buf_info.width, buf_info.height, + &out_segment, &extra); + if (has_encoder_alt) { + int out_segment_alt = -1; + encoder_encode_frame(&encoder_alt, + y, u, v, + buf_info.width, buf_info.height, + &out_segment_alt, &extra); + } // publish encode index - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto eidx = event.initEncodeIdx(); + MessageBuilder msg; + // this is really ugly + auto eidx = cam_idx == LOG_CAMERA_ID_DCAMERA ? msg.initEvent().initFrontEncodeIdx() : + (cam_idx == LOG_CAMERA_ID_ECAMERA ? msg.initEvent().initWideEncodeIdx() : msg.initEvent().initEncodeIdx()); eidx.setFrameId(extra.frame_id); - eidx.setType(front ? cereal::EncodeIndex::Type::FRONT : cereal::EncodeIndex::Type::FULL_H_E_V_C); + eidx.setTimestampSof(extra.timestamp_sof); + eidx.setTimestampEof(extra.timestamp_eof); + #ifdef QCOM2 + eidx.setType(cereal::EncodeIndex::Type::FULL_H_E_V_C); + #else + eidx.setType(cam_idx == LOG_CAMERA_ID_DCAMERA ? cereal::EncodeIndex::Type::FRONT:cereal::EncodeIndex::Type::FULL_H_E_V_C); + #endif + eidx.setEncodeId(cnt); eidx.setSegmentNum(out_segment); eidx.setSegmentId(out_id); - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - if (zmq_send(idx_sock, bytes.begin(), bytes.size(), 0) < 0) { - printf("err sending encodeIdx pkt: %s\n", strerror(errno)); - } + auto bytes = msg.toBytes(); if (lh) { lh_log(lh, bytes.begin(), bytes.size(), false); } } - if (raw_clips) { - double ts = seconds_since_boot(); - if (ts > rawlogger_start_time) { - // encode raw if in clip - int out_segment = -1; - int out_id = rawlogger->LogFrame(cnt, y, u, v, &out_segment); - - if (rawlogger_clip_cnt == 0) { - LOG("starting raw clip in seg %d", out_segment); - } - - // publish encode index - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto eidx = event.initEncodeIdx(); - eidx.setFrameId(extra.frame_id); - eidx.setType(cereal::EncodeIndex::Type::FULL_LOSSLESS_CLIP); - eidx.setEncodeId(cnt); - eidx.setSegmentNum(out_segment); - eidx.setSegmentId(out_id); - - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - if (lh) { - lh_log(lh, bytes.begin(), bytes.size(), false); - } - - // close rawlogger if clip ended - rawlogger_clip_cnt++; - if (rawlogger_clip_cnt >= RAW_CLIP_LENGTH) { - rawlogger->Close(); - - rawlogger_clip_cnt = 0; - rawlogger_start_time = ts+RAW_CLIP_FREQUENCY; - - LOG("ending raw clip in seg %d, next in %.1f sec", out_segment, rawlogger_start_time-ts); - } - } - } - cnt++; } @@ -272,11 +392,6 @@ void encoder_thread(bool is_streaming, bool raw_clips, bool front) { lh = NULL; } - if (raw_clips) { - rawlogger->Close(); - delete rawlogger; - } - visionstream_destroy(&stream); } @@ -285,78 +400,12 @@ void encoder_thread(bool is_streaming, bool raw_clips, bool front) { encoder_close(&encoder); encoder_destroy(&encoder); } -} -#endif - -#if ENABLE_LIDAR - -#include -#include -#include -#include - -#define VELODYNE_DATA_PORT 2368 -#define VELODYNE_TELEMETRY_PORT 8308 - -#define MAX_LIDAR_PACKET 2048 - -int lidar_thread() { - // increase kernel max buffer size - system("sysctl -w net.core.rmem_max=26214400"); - set_thread_name("lidar"); - - int sock; - if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - perror("cannot create socket"); - return -1; - } - - int a = 26214400; - if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &a, sizeof(int)) == -1) { - perror("cannot set socket opts"); - return -1; - } - - struct sockaddr_in addr; - memset(&addr, 0, sizeof(struct sockaddr_in)); - addr.sin_family = AF_INET; - addr.sin_port = htons(VELODYNE_DATA_PORT); - inet_aton("192.168.5.11", &(addr.sin_addr)); - - if (bind(sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { - perror("cannot bind LIDAR socket"); - return -1; - } - - capnp::byte buf[MAX_LIDAR_PACKET]; - - while (!do_exit) { - // receive message - struct sockaddr from; - socklen_t fromlen = sizeof(from); - int cnt = recvfrom(sock, (void *)buf, MAX_LIDAR_PACKET, 0, &from, &fromlen); - if (cnt <= 0) { - printf("bug in lidar recieve!\n"); - continue; - } - // create message for log - capnp::MallocMessageBuilder msg; - auto event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto lidar_pts = event.initLidarPts(); - - // copy in the buffer - // TODO: can we remove this copy? does it matter? - kj::ArrayPtr bufferPtr = kj::arrayPtr(buf, cnt); - lidar_pts.setPkt(bufferPtr); - - // log it - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - logger_log(&s.logger, bytes.begin(), bytes.size()); + if (has_encoder_alt) { + LOG("encoder alt destroy"); + encoder_close(&encoder_alt); + encoder_destroy(&encoder_alt); } - return 0; } #endif @@ -370,12 +419,17 @@ void append_property(const char* key, const char* value, void *cookie) { } kj::Array gen_init_data() { - capnp::MallocMessageBuilder msg; - auto event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto init = event.initInitData(); + MessageBuilder msg; + auto init = msg.initEvent().initInitData(); + + if (file_exists("/EON")) + init.setDeviceType(cereal::InitData::DeviceType::NEO); + else if (file_exists("/TICI")) { + init.setDeviceType(cereal::InitData::DeviceType::TICI); + } else { + init.setDeviceType(cereal::InitData::DeviceType::PC); + } - init.setDeviceType(cereal::InitData::DeviceType::NEO); init.setVersion(capnp::Text::Reader(COMMA_VERSION)); std::ifstream cmdline_stream("/proc/cmdline"); @@ -392,6 +446,7 @@ kj::Array gen_init_data() { init.setKernelVersion(util::read_file("/proc/version")); +#ifdef QCOM { std::vector > properties; property_list(append_property, (void*)&properties); @@ -403,6 +458,7 @@ kj::Array gen_init_data() { lentry.setValue(properties[i].second); } } +#endif const char* dongle_id = getenv("DONGLE_ID"); if (dongle_id) { @@ -413,64 +469,38 @@ kj::Array gen_init_data() { if (!clean) { init.setDirty(true); } + Params params = Params(); - char* git_commit = NULL; - read_db_value(NULL, "GitCommit", &git_commit, NULL); - if (git_commit) { - init.setGitCommit(capnp::Text::Reader(git_commit)); + std::vector git_commit = params.read_db_bytes("GitCommit"); + if (git_commit.size() > 0) { + init.setGitCommit(capnp::Text::Reader(git_commit.data(), git_commit.size())); } - char* git_branch = NULL; - read_db_value(NULL, "GitBranch", &git_branch, NULL); - if (git_branch) { - init.setGitBranch(capnp::Text::Reader(git_branch)); + std::vector git_branch = params.read_db_bytes("GitBranch"); + if (git_branch.size() > 0) { + init.setGitBranch(capnp::Text::Reader(git_branch.data(), git_branch.size())); } - char* git_remote = NULL; - read_db_value(NULL, "GitRemote", &git_remote, NULL); - if (git_remote) { - init.setGitRemote(capnp::Text::Reader(git_remote)); + std::vector git_remote = params.read_db_bytes("GitRemote"); + if (git_remote.size() > 0) { + init.setGitRemote(capnp::Text::Reader(git_remote.data(), git_remote.size())); } - char* passive = NULL; - read_db_value(NULL, "Passive", &passive, NULL); - init.setPassive(passive && strlen(passive) && passive[0] == '1'); - - + init.setPassive(params.read_db_bool("Passive")); { // log params - std::map params; - read_db_all(NULL, ¶ms); - auto lparams = init.initParams().initEntries(params.size()); + std::map params_map; + params.read_db_all(¶ms_map); + auto lparams = init.initParams().initEntries(params_map.size()); int i = 0; - for (auto& kv : params) { + for (auto& kv : params_map) { auto lentry = lparams[i]; lentry.setKey(kv.first); lentry.setValue(kv.second); i++; } } - - - auto words = capnp::messageToFlatArray(msg); - - if (git_commit) { - free((void*)git_commit); - } - - if (git_branch) { - free((void*)git_branch); - } - - if (git_remote) { - free((void*)git_remote); - } - - if (passive) { - free((void*)passive); - } - - return words; + return capnp::messageToFlatArray(msg); } static int clear_locks_fn(const char* fpath, const struct stat *sb, int tyupeflag) { @@ -499,11 +529,8 @@ static void bootlog() { LOGW("bootlog to %s", s.segment_path); { - capnp::MallocMessageBuilder msg; - auto event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - - auto boot = event.initBoot(); + MessageBuilder msg; + auto boot = msg.initEvent().initBoot(); boot.setWallTimeNanos(nanos_since_epoch()); @@ -513,8 +540,10 @@ static void bootlog() { std::string lastPmsg = util::read_file("/sys/fs/pstore/pmsg-ramoops-0"); boot.setLastPmsg(capnp::Data::Reader((const kj::byte*)lastPmsg.data(), lastPmsg.size())); - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); + std::string launchLog = util::read_file("/tmp/launch_log"); + boot.setLaunchLog(capnp::Text::Reader(launchLog.data(), launchLog.size())); + + auto bytes = msg.toBytes(); logger_log(&s.logger, bytes.begin(), bytes.size(), false); } @@ -524,225 +553,184 @@ static void bootlog() { int main(int argc, char** argv) { int err; +#ifdef QCOM + setpriority(PRIO_PROCESS, 0, -12); +#endif + if (argc > 1 && strcmp(argv[1], "--bootlog") == 0) { bootlog(); return 0; } - setpriority(PRIO_PROCESS, 0, -12); + int segment_length = SEGMENT_LENGTH; + if (getenv("LOGGERD_TEST")) { + segment_length = atoi(getenv("LOGGERD_SEGMENT_LENGTH")); + } + bool record_front = true; +#ifndef QCOM2 + record_front = Params().read_db_bool("RecordFront"); +#endif clear_locks(); signal(SIGINT, (sighandler_t)set_do_exit); signal(SIGTERM, (sighandler_t)set_do_exit); - s.ctx = zmq_ctx_new(); - assert(s.ctx); - - std::set ts_replace_sock; - - std::string exe_dir = util::dir_name(util::readlink("/proc/self/exe")); - std::string service_list_path = exe_dir + "/../service_list.yaml"; + s.ctx = Context::create(); + Poller * poller = Poller::create(); // subscribe to all services - void *frame_sock = NULL; - - // zmq_poll is slow because it has to be careful because the signaling - // fd is edge-triggered. we can be faster by knowing that we're not messing with it - // other than draining and polling - std::vector polls; - std::vector socks; - - std::map qlog_counter; - std::map qlog_freqs; - - YAML::Node service_list = YAML::LoadFile(service_list_path); - for (const auto& it : service_list) { - auto name = it.first.as(); - int port = it.second[0].as(); - bool should_log = it.second[1].as(); - int qlog_freq = it.second[3] ? it.second[3].as() : 0; - - if (should_log) { - void* sock = zmq_socket(s.ctx, ZMQ_SUB); - zmq_setsockopt(sock, ZMQ_SUBSCRIBE, "", 0); - - // make zmq will do exponential backoff from 100ms to 500ms for socket reconnects - int reconnect_ivl = 500; - zmq_setsockopt(sock, ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl, sizeof(reconnect_ivl)); - - std::stringstream ss; - ss << "tcp://"; - if (it.second[4]) { - ss << it.second[4].as(); - ts_replace_sock.insert(sock); - } else{ - ss << "127.0.0.1"; - } - ss << ":" << port; + std::vector socks; - zmq_connect(sock, ss.str().c_str()); + std::map qlog_counter; + std::map qlog_freqs; - struct pollfd pfd = {0}; - size_t fd_size = sizeof(pfd.fd); - err = zmq_getsockopt(sock, ZMQ_FD, &pfd.fd, &fd_size); - assert(err == 0); - pfd.events = POLLIN; - polls.push_back(pfd); + for (const auto& it : services) { + std::string name = it.name; + + if (it.should_log) { + SubSocket * sock = SubSocket::create(s.ctx, name); + assert(sock != NULL); + poller->registerSocket(sock); socks.push_back(sock); - if (name == "frame") { - LOGD("found frame sock at port %d", port); - frame_sock = sock; + for (int cid=0;cid<=MAX_CAM_IDX;cid++) { + if (name == cameras_logged[cid].frame_packet_name) { s.rotate_state[cid].fpkt_sock = sock; } } - qlog_counter[sock] = (qlog_freq == 0) ? -1 : 0; - qlog_freqs[sock] = qlog_freq; + qlog_counter[sock] = (it.decimation == -1) ? -1 : 0; + qlog_freqs[sock] = it.decimation; } } - { auto words = gen_init_data(); auto bytes = words.asBytes(); logger_init(&s.logger, "rlog", bytes.begin(), bytes.size(), true); } - bool is_streaming = false; - bool is_logging = true; - - if (argc > 1 && strcmp(argv[1], "--stream") == 0) { - is_streaming = true; - } else if (argc > 1 && strcmp(argv[1], "--only-stream") == 0) { - is_streaming = true; - is_logging = false; - } - - if (is_logging) { - err = logger_next(&s.logger, LOG_ROOT, s.segment_path, sizeof(s.segment_path), &s.rotate_segment); - assert(err == 0); - LOGW("logging to %s", s.segment_path); - } - - double start_ts = seconds_since_boot(); - double last_rotate_ts = start_ts; - + s.rotate_seq_id = 0; + s.should_close = 0; + s.finish_close = 0; + s.num_encoder = 0; + pthread_mutex_init(&s.rotate_lock, NULL); #ifndef DISABLE_ENCODER // rear camera - std::thread encoder_thread_handle(encoder_thread, is_streaming, false, false); - + std::thread encoder_thread_handle(encoder_thread, &s.rotate_state[LOG_CAMERA_ID_FCAMERA], LOG_CAMERA_ID_FCAMERA); + s.rotate_state[LOG_CAMERA_ID_FCAMERA].enabled = true; // front camera - std::thread front_encoder_thread_handle(encoder_thread, false, false, true); -#endif - -#if ENABLE_LIDAR - std::thread lidar_thread_handle(lidar_thread); + std::thread front_encoder_thread_handle; + if (record_front) { + front_encoder_thread_handle = std::thread(encoder_thread, &s.rotate_state[LOG_CAMERA_ID_DCAMERA], LOG_CAMERA_ID_DCAMERA); + s.rotate_state[LOG_CAMERA_ID_DCAMERA].enabled = true; + } + #ifdef QCOM2 + // wide camera + std::thread wide_encoder_thread_handle(encoder_thread, &s.rotate_state[LOG_CAMERA_ID_ECAMERA], LOG_CAMERA_ID_ECAMERA); + s.rotate_state[LOG_CAMERA_ID_ECAMERA].enabled = true; + #endif #endif uint64_t msg_count = 0; uint64_t bytes_count = 0; + kj::Array buf = kj::heapArray(1024); + double start_ts = seconds_since_boot(); + double last_rotate_tms = millis_since_boot(); + double last_camera_seen_tms = millis_since_boot(); while (!do_exit) { - // err = zmq_poll(polls.data(), polls.size(), 100 * 1000); - err = poll(polls.data(), polls.size(), 100*1000); - if (err < 0) break; - - for (int i=0; ipoll(100 * 1000)) { + Message * last_msg = nullptr; while (true) { - zmq_msg_t msg; - zmq_msg_init(&msg); - - err = zmq_msg_recv(&msg, socks[i], ZMQ_DONTWAIT); - if (err < 0) { - zmq_msg_close(&msg); + Message * msg = sock->receive(true); + if (msg == NULL){ break; } + delete last_msg; + last_msg = msg; - uint8_t* data = (uint8_t*)zmq_msg_data(&msg); - size_t len = zmq_msg_size(&msg); - - if (socks[i] == frame_sock) { - // make copy due to alignment issues, will be freed on out of scope - auto amsg = kj::heapArray((len / sizeof(capnp::word)) + 1); - memcpy(amsg.begin(), data, len); + logger_log(&s.logger, (uint8_t*)msg->getData(), msg->getSize(), qlog_counter[sock] == 0); - // track camera frames to sync to encoder - capnp::FlatArrayMessageReader cmsg(amsg); - cereal::Event::Reader event = cmsg.getRoot(); - if (event.isFrame()) { - std::unique_lock lk(s.lock); - s.last_frame_id = event.getFrame().getFrameId(); - lk.unlock(); - s.cv.notify_all(); - } + if (qlog_counter[sock] != -1) { + //printf("%p: %d/%d\n", socks[i], qlog_counter[socks[i]], qlog_freqs[socks[i]]); + qlog_counter[sock]++; + qlog_counter[sock] %= qlog_freqs[sock]; } + bytes_count += msg->getSize(); + msg_count++; + } - if (ts_replace_sock.find(socks[i]) != ts_replace_sock.end()) { - // get new time - uint64_t current_time = nanos_since_boot(); - - // read out the current message - /*auto amsg = kj::heapArray((len / sizeof(capnp::word)) + 1); - memcpy(amsg.begin(), data, len); - capnp::FlatArrayMessageReader cmsg(amsg); - cereal::Event::Reader revent = cmsg.getRoot(); - - // create a copy, ugh - capnp::MallocMessageBuilder msg; - msg.setRoot(revent); - - // replace the timestamp with the current timestamp on the phone - cereal::Event::Builder event = msg.getRoot(); - - // test it's correct - auto twords = capnp::messageToFlatArray(msg); - auto tbytes = twords.asBytes(); - assert(memcmp(data, tbytes.begin(), len) == 0); - - // modify it - event.setLogMonoTime(current_time); - - // put it back - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - memcpy(data, bytes.begin(), len);*/ - - // binary patching HACK! - assert(memcmp(data+0xC, "\x02\x00\x01\x00", 4) == 0); - memcpy(data+0x10, ¤t_time, sizeof(current_time)); + if (last_msg) { + int fpkt_id = -1; + for (int cid=0;cid<=MAX_CAM_IDX;cid++) { + if (sock == s.rotate_state[cid].fpkt_sock) {fpkt_id=cid; break;} } + if (fpkt_id>=0) { + // track camera frames to sync to encoder + // only process last frame + const uint8_t* data = (uint8_t*)last_msg->getData(); + const size_t len = last_msg->getSize(); + const size_t size = len / sizeof(capnp::word) + 1; + if (buf.size() < size) { + buf = kj::heapArray(size); + } + memcpy(buf.begin(), data, len); - logger_log(&s.logger, data, len, qlog_counter[socks[i]] == 0); - zmq_msg_close(&msg); + capnp::FlatArrayMessageReader cmsg(buf); + cereal::Event::Reader event = cmsg.getRoot(); - if (qlog_counter[socks[i]] != -1) { - //printf("%p: %d/%d\n", socks[i], qlog_counter[socks[i]], qlog_freqs[socks[i]]); - qlog_counter[socks[i]]++; - qlog_counter[socks[i]] %= qlog_freqs[socks[i]]; + if (fpkt_id == LOG_CAMERA_ID_FCAMERA) { + s.rotate_state[fpkt_id].setLogFrameId(event.getFrame().getFrameId()); + } else if (fpkt_id == LOG_CAMERA_ID_DCAMERA) { + s.rotate_state[fpkt_id].setLogFrameId(event.getFrontFrame().getFrameId()); + } else if (fpkt_id == LOG_CAMERA_ID_ECAMERA) { + s.rotate_state[fpkt_id].setLogFrameId(event.getWideFrame().getFrameId()); + } + last_camera_seen_tms = millis_since_boot(); } - - bytes_count += len; - msg_count++; + delete last_msg; } } double ts = seconds_since_boot(); - if (ts - last_rotate_ts > SEGMENT_LENGTH) { - // rotate the log + double tms = millis_since_boot(); + + bool new_segment = false; + + if (s.logger.part > -1) { + new_segment = true; + if (tms - last_camera_seen_tms <= NO_CAMERA_PATIENCE && s.num_encoder > 0) { + for (int cid=0;cid<=MAX_CAM_IDX;cid++) { + // this *should* be redundant on tici since all camera frames are synced + new_segment &= (((s.rotate_state[cid].stream_frame_id >= s.rotate_state[cid].last_rotate_frame_id + segment_length * MAIN_FPS) && + (!s.rotate_state[cid].should_rotate) && (s.rotate_state[cid].initialized)) || + (!s.rotate_state[cid].enabled)); +#ifndef QCOM2 + break; // only look at fcamera frame id if not QCOM2 +#endif + } + } else { + new_segment &= tms - last_rotate_tms > segment_length * 1000; + if (new_segment) { LOGW("no camera packet seen. auto rotated"); } + } + } else if (s.logger.part == -1) { + // always starts first segment immediately + new_segment = true; + } - last_rotate_ts += SEGMENT_LENGTH; + if (new_segment) { + pthread_mutex_lock(&s.rotate_lock); + last_rotate_tms = millis_since_boot(); - std::lock_guard guard(s.lock); - s.rotate_last_frame_id = s.last_frame_id; + err = logger_next(&s.logger, LOG_ROOT, s.segment_path, sizeof(s.segment_path), &s.rotate_segment); + assert(err == 0); + if (s.logger.part == 0) { LOGW("logging to %s", s.segment_path); } + LOGW("rotated to %s", s.segment_path); - if (is_logging) { - err = logger_next(&s.logger, LOG_ROOT, s.segment_path, sizeof(s.segment_path), &s.rotate_segment); - assert(err == 0); - LOGW("rotated to %s", s.segment_path); - } + // rotate the encoders + for (int cid=0;cid<=MAX_CAM_IDX;cid++) { s.rotate_state[cid].rotate(); } + pthread_mutex_unlock(&s.rotate_lock); } if ((msg_count%1000) == 0) { @@ -751,20 +739,27 @@ int main(int argc, char** argv) { } LOGW("joining threads"); - s.cv.notify_all(); + for (int cid=0;cid<=MAX_CAM_IDX;cid++) { s.rotate_state[cid].cancelWait(); } #ifndef DISABLE_ENCODER - front_encoder_thread_handle.join(); +#ifdef QCOM2 + wide_encoder_thread_handle.join(); +#endif + if (record_front) { + front_encoder_thread_handle.join(); + } encoder_thread_handle.join(); LOGW("encoder joined"); #endif -#if ENABLE_LIDAR - lidar_thread_handle.join(); - LOGW("lidar joined"); -#endif - logger_close(&s.logger); + LOGW("logger closed"); + + for (auto s : socks){ + delete s; + } + delete poller; + delete s.ctx; return 0; } diff --git a/selfdrive/loggerd/raw_logger.cc b/selfdrive/loggerd/raw_logger.cc index 37b3f284287bc9..d9fc289ded3621 100644 --- a/selfdrive/loggerd/raw_logger.cc +++ b/selfdrive/loggerd/raw_logger.cc @@ -1,3 +1,5 @@ +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + #include #include #include diff --git a/selfdrive/loggerd/tests/Makefile b/selfdrive/loggerd/tests/Makefile deleted file mode 100644 index d05d549170d4fc..00000000000000 --- a/selfdrive/loggerd/tests/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -CC = clang -CXX = clang++ - -PHONELIBS = ../../../phonelibs - -WARN_FLAGS = -Werror=implicit-function-declaration \ - -Werror=incompatible-pointer-types \ - -Werror=int-conversion \ - -Werror=return-type \ - -Werror=format-extra-args \ - -Wno-deprecated-declarations - -CFLAGS = -std=gnu11 -g -fPIC -O2 $(WARN_FLAGS) -CXXFLAGS = -std=c++11 -g -fPIC -O2 $(WARN_FLAGS) - -FFMPEG_LIBS = -lavformat \ - -lavcodec \ - -lswscale \ - -lavutil \ - -lz - -OBJS = testraw.o \ - ../RawLogger.o \ - ../../common/visionipc.o - -testraw: $(OBJS) - $(CXX) -fPIC -o '$@' $^ -L/usr/lib $(FFMPEG_LIBS) - -%.o: %.cc - @echo "[ CXX ] $@" - $(CXX) $(CXXFLAGS) \ - -I../ \ - -I../../ \ - -I../../../ \ - -c -o '$@' '$<' diff --git a/selfdrive/loggerd/tests/fill_eon.py b/selfdrive/loggerd/tests/fill_eon.py deleted file mode 100755 index 8ebc5ceb2a82d3..00000000000000 --- a/selfdrive/loggerd/tests/fill_eon.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -"""Script to fill up EON with fake data""" - -import os - -from selfdrive.loggerd.config import ROOT, get_available_percent -from selfdrive.loggerd.tests.loggerd_tests_common import create_random_file - - -if __name__ == "__main__": - segment_idx = 0 - while True: - seg_name = "1970-01-01--00-00-00--%d" % segment_idx - seg_path = os.path.join(ROOT, seg_name) - - print(seg_path) - - create_random_file(os.path.join(seg_path, 'fcamera.hevc'), 36) - create_random_file(os.path.join(seg_path, 'rlog.bz2'), 2) - - segment_idx += 1 - - # Fill up to 99 percent - available_percent = get_available_percent() - if available_percent < 1.0: - break diff --git a/selfdrive/loggerd/tests/loggerd_tests_common.py b/selfdrive/loggerd/tests/loggerd_tests_common.py deleted file mode 100644 index dd48381d8efecd..00000000000000 --- a/selfdrive/loggerd/tests/loggerd_tests_common.py +++ /dev/null @@ -1,53 +0,0 @@ -import os -import errno -import shutil -import random -import tempfile -import unittest - -import selfdrive.loggerd.uploader as uploader - - -def create_random_file(file_path, size_mb, lock=False): - try: - os.mkdir(os.path.dirname(file_path)) - except OSError: - pass - - lock_path = file_path + ".lock" - os.close(os.open(lock_path, os.O_CREAT | os.O_EXCL)) - - chunks = 128 - chunk_bytes = int(size_mb * 1024 * 1024 / chunks) - data = os.urandom(chunk_bytes) - - with open(file_path, 'wb') as f: - for _ in range(chunks): - f.write(data) - - if not lock: - os.remove(lock_path) - - -class UploaderTestCase(unittest.TestCase): - f_type = "UNKNOWN" - - def setUp(self): - self.root = tempfile.mkdtemp() - uploader.ROOT = self.root # Monkey patch root dir - self.seg_num = random.randint(1, 300) - self.seg_format = "2019-04-18--12-52-54--{}" - self.seg_dir = self.seg_format.format(self.seg_num) - - def tearDown(self): - try: - shutil.rmtree(self.root) - except OSError as e: - if e.errno != errno.ENOENT: - raise - - def make_file_with_data(self, f_dir, fn, size_mb=.1, lock=False): - file_path = os.path.join(self.root, f_dir, fn) - create_random_file(file_path, size_mb) - - return file_path diff --git a/selfdrive/loggerd/tests/test_deleter.py b/selfdrive/loggerd/tests/test_deleter.py deleted file mode 100644 index 6e62db600f5b01..00000000000000 --- a/selfdrive/loggerd/tests/test_deleter.py +++ /dev/null @@ -1,104 +0,0 @@ -import os -import time -import threading -from collections import namedtuple - -import selfdrive.loggerd.deleter as deleter -from common.timeout import Timeout, TimeoutException - -from loggerd_tests_common import UploaderTestCase - -Stats = namedtuple("Stats", ['f_bavail', 'f_blocks']) - -fake_stats = Stats(f_bavail=0, f_blocks=10) - - -def fake_statvfs(d): - return fake_stats - - -class TestDeleter(UploaderTestCase): - def setUp(self): - self.f_type = "fcamera.hevc" - super(TestDeleter, self).setUp() - deleter.os.statvfs = fake_statvfs - deleter.ROOT = self.root - - def tearDown(self): - super(TestDeleter, self).tearDown() - - def start_thread(self): - self.end_event = threading.Event() - self.del_thread = threading.Thread(target=deleter.deleter_thread, args=[self.end_event]) - self.del_thread.daemon = True - self.del_thread.start() - - def join_thread(self): - self.end_event.set() - self.del_thread.join() - - def test_delete(self): - f_path = self.make_file_with_data(self.seg_dir, self.f_type, 1) - - self.start_thread() - - with Timeout(5, "Timeout waiting for file to be deleted"): - while os.path.exists(f_path): - time.sleep(0.01) - self.join_thread() - - self.assertFalse(os.path.exists(f_path), "File not deleted") - - def test_delete_files_in_create_order(self): - f_path_1 = self.make_file_with_data(self.seg_dir, self.f_type) - time.sleep(1) - self.seg_num += 1 - self.seg_dir = self.seg_format.format(self.seg_num) - f_path_2 = self.make_file_with_data(self.seg_dir, self.f_type) - - self.start_thread() - - with Timeout(5, "Timeout waiting for file to be deleted"): - while os.path.exists(f_path_1) and os.path.exists(f_path_2): - time.sleep(0.01) - - self.join_thread() - - self.assertFalse(os.path.exists(f_path_1), "Older file not deleted") - - self.assertTrue(os.path.exists(f_path_2), "Newer file deleted before older file") - - def test_no_delete_when_available_space(self): - global fake_stats - f_path = self.make_file_with_data(self.seg_dir, self.f_type) - - fake_stats = Stats(f_bavail=10, f_blocks=10) - - self.start_thread() - - try: - with Timeout(2, "Timeout waiting for file to be deleted"): - while os.path.exists(f_path): - time.sleep(0.01) - except TimeoutException: - pass - finally: - self.join_thread() - - self.assertTrue(os.path.exists(f_path), "File deleted with available space") - - def test_no_delete_with_lock_file(self): - f_path = self.make_file_with_data(self.seg_dir, self.f_type, lock=True) - - self.start_thread() - - try: - with Timeout(2, "Timeout waiting for file to be deleted"): - while os.path.exists(f_path): - time.sleep(0.01) - except TimeoutException: - pass - finally: - self.join_thread() - - self.assertTrue(os.path.exists(f_path), "File deleted when locked") diff --git a/selfdrive/loggerd/tests/testraw.cc b/selfdrive/loggerd/tests/testraw.cc deleted file mode 100644 index 80858e6f283c92..00000000000000 --- a/selfdrive/loggerd/tests/testraw.cc +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include -#include - -#include - -#include "common/visionipc.h" -#include "common/timing.h" - -#include "RawLogger.h" - -int main() { - int err; - - VisionStream stream; - - VisionStreamBufs buf_info; - while (true) { - err = visionstream_init(&stream, VISION_STREAM_YUV, false, &buf_info); - if (err != 0) { - printf("visionstream fail\n"); - usleep(100000); - } - break; - } - - RawLogger vidlogger("prcamera", buf_info.width, buf_info.height, 20); - vidlogger.Open("o1"); - - for (int cnt=0; cnt<200; cnt++) { - VIPCBufExtra extra; - VIPSBuf* buf = visionstream_get(&stream, &extra); - if (buf == NULL) { - printf("visionstream get failed\n"); - break; - } - - if (cnt == 100) { - vidlogger.Rotate("o2", 2); - } - - uint8_t *y = (uint8_t*)buf->addr; - uint8_t *u = y + (buf_info.width*buf_info.height); - uint8_t *v = u + (buf_info.width/2)*(buf_info.height/2); - - double t1 = millis_since_boot(); - vidlogger.LogFrame(cnt, y, u, v, NULL); - double t2 = millis_since_boot(); - printf("%d %.2f\n", cnt, (t2-t1)); - } - - vidlogger.Close(); - - visionstream_destroy(&stream); - - return 0; -} diff --git a/selfdrive/loggerd/uploader.py b/selfdrive/loggerd/uploader.py index 9e5dca76e455ab..5257a3ae7206f9 100644 --- a/selfdrive/loggerd/uploader.py +++ b/selfdrive/loggerd/uploader.py @@ -1,30 +1,34 @@ -#!/usr/bin/env python -import os -import re -import time -import stat -import json -import random +#!/usr/bin/env python3 import ctypes import inspect +import json +import os +import random import requests -import traceback import threading -import subprocess - -from collections import Counter -from selfdrive.swaglog import cloudlog -from selfdrive.loggerd.config import ROOT +import time +import traceback +from cereal import log +from common.api import Api from common.params import Params +from selfdrive.hardware import HARDWARE +from selfdrive.loggerd.xattr_cache import getxattr, setxattr +from selfdrive.loggerd.config import ROOT +from selfdrive.swaglog import cloudlog -from common.api import Api from selfdrive.car.tesla.readconfig import read_config_file,CarSettings +NetworkType = log.ThermalData.NetworkType + +UPLOAD_ATTR_NAME = 'user.upload' +UPLOAD_ATTR_VALUE = b'1' fake_upload = os.getenv("FAKEUPLOAD") is not None + def raise_on_thread(t, exctype): + '''Raises an exception in the threads with id tid''' for ctid, tobj in threading._active.items(): if tobj is t: tid = ctid @@ -32,7 +36,6 @@ def raise_on_thread(t, exctype): else: raise Exception("Could not find thread") - '''Raises an exception in the threads with id tid''' if not inspect.isclass(exctype): raise TypeError("Only types can be raised (not instances)") @@ -46,20 +49,17 @@ def raise_on_thread(t, exctype): ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, 0) raise SystemError("PyThreadState_SetAsyncExc failed") -def listdir_with_creation_date(d): - lst = os.listdir(d) - for fn in lst: - try: - st = os.stat(os.path.join(d, fn)) - ctime = st[stat.ST_CTIME] - yield (ctime, fn) - except OSError: - cloudlog.exception("listdir_with_creation_date: stat failed?") - yield (None, fn) +def get_directory_sort(d): + return list(map(lambda s: s.rjust(10, '0'), d.rsplit('--', 1))) -def listdir_by_creation_date(d): - times_and_paths = list(listdir_with_creation_date(d)) - return [path for _, path in sorted(times_and_paths)] +def listdir_by_creation(d): + try: + paths = os.listdir(d) + paths = sorted(paths, key=get_directory_sort) + return paths + except OSError: + cloudlog.exception("listdir_by_creation failed") + return list() def clear_locks(root): for logname in os.listdir(root): @@ -72,19 +72,11 @@ def clear_locks(root): cloudlog.exception("clear_locks failed") def is_on_wifi(): - # ConnectivityManager.getActiveNetworkInfo() - try: - result = subprocess.check_output(["service", "call", "connectivity", "2"]).strip().split("\n") - except subprocess.CalledProcessError: - return False - - data = ''.join(''.join(w.decode("hex")[::-1] for w in l[14:49].split()) for l in result[1:]) - - return "\x00".join("WIFI") in data + return HARDWARE.get_network_type() == NetworkType.wifi def is_on_hotspot(): try: - result = subprocess.check_output(["ifconfig", "wlan0"]) + result = subprocess.check_output(["ifconfig", "wlan0"], stderr=subprocess.STDOUT, encoding='utf8') result = re.findall(r"inet addr:((\d+\.){3}\d+)", result)[0][0] is_android = result.startswith('192.168.43.') @@ -95,13 +87,13 @@ def is_on_hotspot(): is_other_tether = blockUploadWhileTethering and result.startswith(tetherIP) is_entune = result.startswith('10.0.2.') return (is_android or is_ios or is_other_tether or is_entune) - except: + except Exception: return False -class Uploader(object): - def __init__(self, dongle_id, private_key, root): +class Uploader(): + def __init__(self, dongle_id, root): self.dongle_id = dongle_id - self.api = Api(dongle_id, private_key) + self.api = Api(dongle_id) self.root = root self.upload_thread = None @@ -109,6 +101,9 @@ def __init__(self, dongle_id, private_key, root): self.last_resp = None self.last_exc = None + self.immediate_priority = {"qlog.bz2": 0, "qcamera.ts": 1} + self.high_priority = {"rlog.bz2": 0, "fcamera.hevc": 1, "dcamera.hevc": 2, "ecamera.hevc": 3} + def clean_dirs(self): try: for logname in os.listdir(self.root): @@ -119,10 +114,17 @@ def clean_dirs(self): except OSError: cloudlog.exception("clean_dirs failed") + def get_upload_sort(self, name): + if name in self.immediate_priority: + return self.immediate_priority[name] + if name in self.high_priority: + return self.high_priority[name] + 100 + return 1000 + def gen_upload_files(self): if not os.path.isdir(self.root): return - for logname in listdir_by_creation_date(self.root): + for logname in listdir_by_creation(self.root): path = os.path.join(self.root, logname) try: names = os.listdir(path) @@ -131,50 +133,47 @@ def gen_upload_files(self): if any(name.endswith(".lock") for name in names): continue - for name in names: + for name in sorted(names, key=self.get_upload_sort): key = os.path.join(logname, name) fn = os.path.join(path, name) - + # skip files already uploaded + try: + is_uploaded = getxattr(fn, UPLOAD_ATTR_NAME) + except OSError: + cloudlog.event("uploader_getxattr_failed", exc=self.last_exc, key=key, fn=fn) + is_uploaded = True # deleter could have deleted + if is_uploaded: + continue yield (name, key, fn) - def get_data_stats(self): - name_counts = Counter() - total_size = 0 - for name, key, fn in self.gen_upload_files(): - name_counts[name] += 1 - total_size += os.stat(fn).st_size - return dict(name_counts), total_size - def next_file_to_upload(self, with_raw): + upload_files = list(self.gen_upload_files()) + # try to upload qlog files first - for name, key, fn in self.gen_upload_files(): - if name == "qlog.bz2": - return (key, fn, 0) + for name, key, fn in upload_files: + if name in self.immediate_priority: + return (key, fn) if with_raw: - # then upload log files - for name, key, fn in self.gen_upload_files(): - if name == "rlog.bz2": - return (key, fn, 1) - - # then upload rear and front camera files - for name, key, fn in self.gen_upload_files(): - if name == "fcamera.hevc": - return (key, fn, 2) - elif name == "dcamera.hevc": - return (key, fn, 3) + # then upload the full log files, rear and front camera files + for name, key, fn in upload_files: + if name in self.high_priority: + return (key, fn) # then upload other files - for name, key, fn in self.gen_upload_files(): + for name, key, fn in upload_files: if not name.endswith('.lock') and not name.endswith(".tmp"): - return (key, fn, 4) + return (key, fn) return None - def do_upload(self, key, fn): try: url_resp = self.api.get("v1.3/"+self.dongle_id+"/upload_url/", timeout=10, path=key, access_token=self.api.get_token()) + if url_resp.status_code == 412: + self.last_resp = url_resp + return + url_resp_json = json.loads(url_resp.text) url = url_resp_json['url'] headers = url_resp_json['headers'] @@ -182,9 +181,11 @@ def do_upload(self, key, fn): if fake_upload: cloudlog.info("*** WARNING, THIS IS A FAKE UPLOAD TO %s ***" % url) - class FakeResponse(object): + + class FakeResponse(): def __init__(self): self.status_code = 200 + self.last_resp = FakeResponse() else: with open(fn, "rb") as f: @@ -216,64 +217,59 @@ def upload(self, key, fn): cloudlog.info("checking %r with size %r", key, sz) if sz == 0: - # can't upload files of 0 size - os.unlink(fn) # delete the file + try: + # tag files of 0 size as uploaded + setxattr(fn, UPLOAD_ATTR_NAME, UPLOAD_ATTR_VALUE) + except OSError: + cloudlog.event("uploader_setxattr_failed", exc=self.last_exc, key=key, fn=fn, sz=sz) success = True else: cloudlog.info("uploading %r", fn) stat = self.normal_upload(key, fn) - if stat is not None and stat.status_code in (200, 201): - cloudlog.event("upload_success", key=key, fn=fn, sz=sz) - - # delete the file + if stat is not None and stat.status_code in (200, 201, 412): + cloudlog.event("upload_success" if stat.status_code != 412 else "upload_ignored", key=key, fn=fn, sz=sz) try: - os.unlink(fn) + # tag file as uploaded + setxattr(fn, UPLOAD_ATTR_NAME, UPLOAD_ATTR_VALUE) except OSError: - cloudlog.event("delete_failed", stat=stat, exc=self.last_exc, key=key, fn=fn, sz=sz) - + cloudlog.event("uploader_setxattr_failed", exc=self.last_exc, key=key, fn=fn, sz=sz) success = True else: cloudlog.event("upload_failed", stat=stat, exc=self.last_exc, key=key, fn=fn, sz=sz) success = False - self.clean_dirs() - return success - - def uploader_fn(exit_event): cloudlog.info("uploader_fn") params = Params() - dongle_id = params.get("DongleId") - private_key = open("/persist/comma/id_rsa").read() + dongle_id = params.get("DongleId").decode('utf8') - if dongle_id is None or private_key is None: - cloudlog.info("uploader missing dongle_id or private_key") - raise Exception("uploader can't start without dongle id and private key") + if dongle_id is None: + cloudlog.info("uploader missing dongle_id") + raise Exception("uploader can't start without dongle id") - uploader = Uploader(dongle_id, private_key, ROOT) + uploader = Uploader(dongle_id, ROOT) backoff = 0.1 - while True: - allow_raw_upload = (params.get("IsUploadRawEnabled") != "0") - allow_cellular = (params.get("IsUploadVideoOverCellularEnabled") != "0") - on_hotspot = is_on_hotspot() - on_wifi = is_on_wifi() - should_upload = allow_cellular or (on_wifi and not on_hotspot) - - if exit_event.is_set(): - return - - d = uploader.next_file_to_upload(with_raw=allow_raw_upload and should_upload) - if d is None: - time.sleep(5) + counter = 0 + on_wifi = False + while not exit_event.is_set(): + offroad = params.get("IsOffroad") == b'1' + allow_raw_upload = (params.get("IsUploadRawEnabled") != b"0") and offroad + if offroad and counter % 12 == 0: + on_wifi = is_on_wifi() + counter += 1 + + d = uploader.next_file_to_upload(with_raw=allow_raw_upload and on_wifi and offroad) + if d is None: # Nothing to upload + time.sleep(60 if offroad else 5) continue - key, fn, _ = d + key, fn = d - cloudlog.event("uploader_netcheck", allow_cellular=allow_cellular, is_on_hotspot=on_hotspot, is_on_wifi=on_wifi) + cloudlog.event("uploader_netcheck", is_on_wifi=on_wifi) cloudlog.info("to upload %r", d) success = uploader.upload(key, fn) if success: @@ -284,8 +280,9 @@ def uploader_fn(exit_event): backoff = min(backoff*2, 120) cloudlog.info("upload done, success=%r", success) -def main(gctx=None): +def main(): uploader_fn(threading.Event()) + if __name__ == "__main__": main() diff --git a/selfdrive/loggerd/xattr_cache.py b/selfdrive/loggerd/xattr_cache.py new file mode 100644 index 00000000000000..aa97f0c777084c --- /dev/null +++ b/selfdrive/loggerd/xattr_cache.py @@ -0,0 +1,13 @@ +from common.xattr import getxattr as getattr1 +from common.xattr import setxattr as setattr1 + +cached_attributes = {} +def getxattr(path, attr_name): + if (path, attr_name) not in cached_attributes: + response = getattr1(path, attr_name) + cached_attributes[(path, attr_name)] = response + return cached_attributes[(path, attr_name)] + +def setxattr(path, attr_name, attr_value): + cached_attributes.pop((path, attr_name), None) + return setattr1(path, attr_name, attr_value) diff --git a/selfdrive/logmessaged.py b/selfdrive/logmessaged.py index c2c583dfc55444..91dcbb7e0456a8 100755 --- a/selfdrive/logmessaged.py +++ b/selfdrive/logmessaged.py @@ -1,25 +1,23 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import zmq -from logentries import LogentriesHandler -from selfdrive.services import service_list -import selfdrive.messaging as messaging +import cereal.messaging as messaging +from selfdrive.swaglog import get_le_handler -def main(gctx=None): - # setup logentries. we forward log messages to it - le_token = "e8549616-0798-4d7e-a2ca-2513ae81fa17" - le_handler = LogentriesHandler(le_token, use_tls=False, verbose=False) - le_level = 20 #logging.INFO +def main(): + le_handler = get_le_handler() + le_level = 20 # logging.INFO ctx = zmq.Context().instance() sock = ctx.socket(zmq.PULL) sock.bind("ipc:///tmp/logmessage") # and we publish them - pub_sock = messaging.pub_sock(service_list['logMessage'].port) + pub_sock = messaging.pub_sock('logMessage') while True: - dat = ''.join(sock.recv_multipart()) + dat = b''.join(sock.recv_multipart()) + dat = dat.decode('utf8') # print "RECV", repr(dat) @@ -36,5 +34,6 @@ def main(gctx=None): msg.logMessage = dat pub_sock.send(msg.to_bytes()) + if __name__ == "__main__": main() diff --git a/selfdrive/manager.py b/selfdrive/manager.py index 7d3024574a02de..91fa1aaf5e39f3 100755 --- a/selfdrive/manager.py +++ b/selfdrive/manager.py @@ -1,29 +1,46 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python3 +import datetime +import importlib import os import sys import fcntl import errno import signal +import shutil import subprocess -from selfdrive.tinklad.tinkla_interface import TinklaClient from cereal import tinkla -from selfdrive.car.tesla.readconfig import CarSettings +import datetime +import textwrap +import time +import traceback + +from multiprocessing import Process +from typing import Dict, List from common.basedir import BASEDIR -sys.path.append(os.path.join(BASEDIR, "pyextra")) +from common.spinner import Spinner +from common.text_window import TextWindow +from selfdrive.hardware import HARDWARE, EON, PC +from selfdrive.swaglog import cloudlog, add_logentries_handler + os.environ['BASEDIR'] = BASEDIR +sys.path.append(os.path.join(BASEDIR, "pyextra")) + +TOTAL_SCONS_NODES = 1040 +WEBCAM = os.getenv("WEBCAM") is not None +PREBUILT = os.path.exists(os.path.join(BASEDIR, 'prebuilt')) + def unblock_stdout(): # get a non-blocking stdout child_pid, child_pty = os.forkpty() - if child_pid != 0: # parent + if child_pid != 0: # parent # child is in its own process group, manually pass kill signals signal.signal(signal.SIGINT, lambda signum, frame: os.kill(child_pid, signal.SIGINT)) signal.signal(signal.SIGTERM, lambda signum, frame: os.kill(child_pid, signal.SIGTERM)) - fcntl.fcntl(sys.stdout, fcntl.F_SETFL, - fcntl.fcntl(sys.stdout, fcntl.F_GETFL) | os.O_NONBLOCK) + fcntl.fcntl(sys.stdout, fcntl.F_SETFL, fcntl.fcntl(sys.stdout, fcntl.F_GETFL) | os.O_NONBLOCK) while True: try: @@ -37,106 +54,153 @@ def unblock_stdout(): break try: - sys.stdout.write(dat) - except (OSError, IOError): + sys.stdout.write(dat.decode('utf8')) + except (OSError, IOError, UnicodeDecodeError): pass - os._exit(os.wait()[1]) + # os.wait() returns a tuple with the pid and a 16 bit value + # whose low byte is the signal number and whose high byte is the exit satus + exit_status = os.wait()[1] >> 8 + os._exit(exit_status) -if __name__ == "__main__": - is_neos = os.path.isfile("/init.qcom.rc") - neos_update_required = False - - if is_neos: - version = int(open("/VERSION").read()) if os.path.isfile("/VERSION") else 0 - revision = int(open("/REVISION").read()) if version >= 10 else 0 # Revision only present in NEOS 10 and up - neos_update_required = version < 10 or (version == 10 and revision != 4) - - if neos_update_required: - # update continue.sh before updating NEOS - if os.path.isfile(os.path.join(BASEDIR, "scripts", "continue.sh")): - from shutil import copyfile - copyfile(os.path.join(BASEDIR, "scripts", "continue.sh"), "/data/data/com.termux/files/continue.sh") - - # run the updater - print("Starting NEOS updater") - subprocess.check_call(["git", "clean", "-xdf"], cwd=BASEDIR) - updater_dir = os.path.join(BASEDIR, "installer", "updater") - manifest_path = os.path.realpath(os.path.join(updater_dir, "update.json")) - os.system(os.path.join(updater_dir, "updater") + " file://" + manifest_path) - raise Exception("NEOS outdated") - elif os.path.isdir("/data/neoupdate"): - from shutil import rmtree - rmtree("/data/neoupdate") +if __name__ == "__main__": unblock_stdout() -import glob -import shutil -import hashlib -import importlib -import re -import stat -import subprocess -import traceback -from multiprocessing import Process -from setproctitle import setproctitle #pylint: disable=no-name-in-module +# Run scons +spinner = Spinner() +spinner.update("0") +if __name__ != "__main__": + spinner.close() -from common.file_helpers import atomic_write_in_dir_neos -from common.params import Params -import cereal -ThermalStatus = cereal.log.ThermalData.ThermalStatus +def build(): + for retry in [True, False]: + # run scons + env = os.environ.copy() + env['SCONS_PROGRESS'] = "1" + env['SCONS_CACHE'] = "1" + + nproc = os.cpu_count() + j_flag = "" if nproc is None else f"-j{nproc - 1}" + scons = subprocess.Popen(["scons", j_flag], cwd=BASEDIR, env=env, stderr=subprocess.PIPE) + + compile_output = [] + + # Read progress from stderr and update spinner + while scons.poll() is None: + try: + line = scons.stderr.readline() # type: ignore + if line is None: + continue + line = line.rstrip() + + prefix = b'progress: ' + if line.startswith(prefix): + i = int(line[len(prefix):]) + spinner.update("%d" % (70.0 * (i / TOTAL_SCONS_NODES))) + elif len(line): + compile_output.append(line) + print(line.decode('utf8', 'replace')) + except Exception: + pass + + if scons.returncode != 0: + # Read remaining output + r = scons.stderr.read().split(b'\n') # type: ignore + compile_output += r + + if retry: + if not os.getenv("CI"): + print("scons build failed, cleaning in") + for i in range(3, -1, -1): + print("....%d" % i) + time.sleep(1) + #Raf: Commented out while merging/compiling + #subprocess.check_call(["scons", "-c"], cwd=BASEDIR, env=env) + #shutil.rmtree("/tmp/scons_cache", ignore_errors=True) + #shutil.rmtree("/data/scons_cache", ignore_errors=True) + else: + print("scons build failed after retry") + sys.exit(1) + else: + # Build failed log errors + errors = [line.decode('utf8', 'replace') for line in compile_output + if any([err in line for err in [b'error: ', b'not found, needed by target']])] + error_s = "\n".join(errors) + add_logentries_handler(cloudlog) + cloudlog.error("scons build failed\n" + error_s) + + # Show TextWindow + spinner.close() + error_s = "\n \n".join(["\n".join(textwrap.wrap(e, 65)) for e in errors]) + with TextWindow("openpilot failed to build\n \n" + error_s) as t: + t.wait_for_exit() + exit(1) + else: + break -from selfdrive.services import service_list -from selfdrive.swaglog import cloudlog -import selfdrive.messaging as messaging +if __name__ == "__main__" and not PREBUILT: + build() + +import cereal.messaging as messaging + +from common.params import Params +import selfdrive.crash as crash from selfdrive.registration import register from selfdrive.version import version, dirty -import selfdrive.crash as crash - from selfdrive.loggerd.config import ROOT +from selfdrive.launcher import launcher +from selfdrive.hardware.eon.apk import update_apks, pm_apply_packages, start_offroad +from selfdrive.car.tesla.readconfig import CarSettings +from selfdrive.tinklad.tinkla_interface import TinklaClient + # comment out anything you don't want to run managed_processes = { "tinklad": "selfdrive.tinklad.tinklad", - "thermald": "selfdrive.thermald", + "thermald": "selfdrive.thermald.thermald", "uploader": "selfdrive.loggerd.uploader", "deleter": "selfdrive.loggerd.deleter", "controlsd": "selfdrive.controls.controlsd", "plannerd": "selfdrive.controls.plannerd", "radard": "selfdrive.controls.radard", + "dmonitoringd": "selfdrive.monitoring.dmonitoringd", "ubloxd": ("selfdrive/locationd", ["./ubloxd"]), "loggerd": ("selfdrive/loggerd", ["./loggerd"]), "logmessaged": "selfdrive.logmessaged", + "locationd": "selfdrive.locationd.locationd", "tombstoned": "selfdrive.tombstoned", "logcatd": ("selfdrive/logcatd", ["./logcatd"]), "proclogd": ("selfdrive/proclogd", ["./proclogd"]), "boardd": ("selfdrive/boardd", ["./boardd"]), # not used directly "pandad": "selfdrive.pandad", - "ui": ("selfdrive/ui", ["./start.py"]), + "ui": ("selfdrive/ui", ["./ui"]), "calibrationd": "selfdrive.locationd.calibrationd", - "paramsd": ("selfdrive/locationd", ["./paramsd"]), - "visiond": ("selfdrive/visiond", ["./visiond"]), - "sensord": ("selfdrive/sensord", ["./start_sensord.py"]), - "gpsd": ("selfdrive/sensord", ["./start_gpsd.py"]), - #"updated": "selfdrive.updated", + "paramsd": "selfdrive.locationd.paramsd", + "camerad": ("selfdrive/camerad", ["./camerad"]), + "sensord": ("selfdrive/sensord", ["./sensord"]), + "clocksd": ("selfdrive/clocksd", ["./clocksd"]), + "gpsd": ("selfdrive/sensord", ["./gpsd"]), + "updated": "selfdrive.updated", + "dmonitoringmodeld": ("selfdrive/modeld", ["./dmonitoringmodeld"]), + "modeld": ("selfdrive/modeld", ["./modeld"]), + "rtshield": "selfdrive.rtshield", } daemon_processes = { - "athenad": "selfdrive.athena.athenad", + "manage_athenad": ("selfdrive.athena.manage_athenad", "AthenadPid"), } -android_packages = ("ai.comma.plus.offroad", "ai.comma.plus.frame") -running = {} +running: Dict[str, Process] = {} def get_running(): return running -# due to qualcomm kernel bugs SIGKILLing visiond sometimes causes page table corruption -unkillable_processes = ['visiond'] +# due to qualcomm kernel bugs SIGKILLing camerad sometimes causes page table corruption +unkillable_processes = ['camerad'] # processes to end with SIGINT instead of SIGTERM -interrupt_processes = [] +interrupt_processes: List[str] = [] # processes to end with SIGKILL instead of SIGTERM kill_processes = ['sensord'] @@ -144,32 +208,60 @@ def get_running(): persistent_processes = [ 'tinklad', 'thermald', - 'logmessaged', - 'logcatd', - 'tombstoned', - 'uploader', 'ui', - 'updated', + 'deleter', ] +if not WEBCAM: + persistent_processes += [ + 'logmessaged', + 'uploader', + ] + +if not PC: + persistent_processes += [ + 'updated', + 'logcatd', + 'tombstoned', + 'sensord', + ] + car_started_processes = [ 'controlsd', 'plannerd', 'loggerd', - 'sensord', 'radard', 'calibrationd', 'paramsd', - 'visiond', + 'camerad', + 'modeld', 'proclogd', - 'ubloxd', - 'gpsd', - 'deleter', + 'locationd', + 'clocksd', +] + +driver_view_processes = [ + 'camerad', + 'dmonitoringd', + 'dmonitoringmodeld' ] +if not PC or WEBCAM: + car_started_processes += [ + 'ubloxd', + 'dmonitoringd', + 'dmonitoringmodeld', + ] + +if EON: + car_started_processes += [ + 'gpsd', + 'rtshield', + ] + + def register_managed_process(name, desc, car_started=False): global managed_processes, car_started_processes, persistent_processes - print("registering %s" % name) managed_processes[name] = desc if car_started: car_started_processes.append(name) @@ -177,28 +269,6 @@ def register_managed_process(name, desc, car_started=False): persistent_processes.append(name) # ****************** process management functions ****************** -def launcher(proc): - try: - # import the process - mod = importlib.import_module(proc) - - # rename the process - setproctitle(proc) - - # terminate the zmq context since we forked - import zmq - zmq.Context.instance().term() - - # exec the process - mod.main() - except KeyboardInterrupt: - cloudlog.warning("child %s got SIGINT" % proc) - except Exception: - # can't install the crash handler becuase sys.excepthook doesn't play nice - # with threads, so catch it here. - crash.capture_exception() - raise - def nativelauncher(pargs, cwd): # exec the process os.chdir(cwd) @@ -222,45 +292,56 @@ def start_managed_process(name): running[name] = Process(name=name, target=nativelauncher, args=(pargs, cwd)) running[name].start() -def start_daemon_process(name, params): - proc = daemon_processes[name] - pid_param = name.capitalize() + 'Pid' - pid = params.get(pid_param) +def start_daemon_process(name): + params = Params() + proc, pid_param = daemon_processes[name] + pid = params.get(pid_param, encoding='utf-8') if pid is not None: try: os.kill(int(pid), 0) - # process is running (kill is a poorly-named system call) - return - except OSError: + with open(f'/proc/{pid}/cmdline') as f: + if proc in f.read(): + # daemon is running + return + except (OSError, FileNotFoundError): # process is dead pass cloudlog.info("starting daemon %s" % name) - proc = subprocess.Popen(['python', '-m', proc], - cwd='/', - stdout=open('/dev/null', 'w'), - stderr=open('/dev/null', 'w'), - preexec_fn=os.setpgrp) + proc = subprocess.Popen(['python', '-m', proc], # pylint: disable=subprocess-popen-preexec-fn + stdin=open('/dev/null', 'r'), + stdout=open('/dev/null', 'w'), + stderr=open('/dev/null', 'w'), + preexec_fn=os.setpgrp) params.put(pid_param, str(proc.pid)) -def prepare_managed_process(p): +def prepare_managed_process(p, build=False): proc = managed_processes[p] if isinstance(proc, str): # import this python cloudlog.info("preimporting %s" % proc) importlib.import_module(proc) - else: + elif os.path.isfile(os.path.join(BASEDIR, proc[0], "SConscript")) and build: # build this process cloudlog.info("building %s" % (proc,)) try: - subprocess.check_call(["make", "-j4"], cwd=os.path.join(BASEDIR, proc[0])) + subprocess.check_call(["scons", "u", "-j4", "."], cwd=os.path.join(BASEDIR, proc[0])) except subprocess.CalledProcessError: - # make clean if the build failed - cloudlog.warning("building %s failed, make clean" % (proc, )) - subprocess.check_call(["make", "clean"], cwd=os.path.join(BASEDIR, proc[0])) - subprocess.check_call(["make", "-j4"], cwd=os.path.join(BASEDIR, proc[0])) + # clean and retry if the build failed + cloudlog.warning("building %s failed, cleaning and retrying" % (proc, )) + subprocess.check_call(["scons", "-u", "-c", "."], cwd=os.path.join(BASEDIR, proc[0])) + subprocess.check_call(["scons", "-u", "-j4", "."], cwd=os.path.join(BASEDIR, proc[0])) + + +def join_process(process, timeout): + # Process().join(timeout) will hang due to a python 3 bug: https://bugs.python.org/issue28382 + # We have to poll the exitcode instead + t = time.time() + while time.time() - t < timeout and process.exitcode is None: + time.sleep(0.001) + def kill_managed_process(name): if name not in running or name not in managed_processes: @@ -275,16 +356,17 @@ def kill_managed_process(name): else: running[name].terminate() - # give it 5 seconds to die - running[name].join(5.0) + join_process(running[name], 5) + if running[name].exitcode is None: if name in unkillable_processes: cloudlog.critical("unkillable process %s failed to exit! rebooting in 15 if it doesn't die" % name) - running[name].join(15.0) + join_process(running[name], 15) if running[name].exitcode is None: - cloudlog.critical("FORCE REBOOTING PHONE!") - os.system("date >> /sdcard/unkillable_reboot") - os.system("reboot") + cloudlog.critical("unkillable process %s failed to die!" % name) + os.system("date >> /data/unkillable_reboot") + os.sync() + HARDWARE.reboot() raise RuntimeError else: cloudlog.info("killing %s with SIGKILL" % name) @@ -294,37 +376,49 @@ def kill_managed_process(name): cloudlog.info("%s is dead with %d" % (name, running[name].exitcode)) del running[name] -def pm_apply_packages(cmd): - for p in android_packages: - system("pm %s %s" % (cmd, p)) def cleanup_all_processes(signal, frame): cloudlog.info("caught ctrl-c %s %s" % (signal, frame)) - pm_apply_packages('disable') + if EON: + pm_apply_packages('disable') for name in list(running.keys()): kill_managed_process(name) cloudlog.info("everything is dead") +def send_managed_process_signal(name, sig): + if name not in running or name not in managed_processes or \ + running[name].exitcode is not None: + return + + cloudlog.info(f"sending signal {sig} to {name}") + os.kill(running[name].pid, sig) + + # ****************** run loop ****************** -def manager_init(should_register=True): - if should_register: - reg_res = register() - if reg_res: - dongle_id, dongle_secret = reg_res - else: - raise Exception("server registration failed") - else: - dongle_id = "c"*16 +def manager_init(): + # Create folders needed for msgq + try: + os.mkdir("/dev/shm") + except FileExistsError: + pass + except PermissionError: + print("WARNING: failed to make /dev/shm") # set dongle id - cloudlog.info("dongle id is " + dongle_id) + reg_res = register() + if reg_res: + dongle_id = reg_res + else: + raise Exception("server registration failed") + #BB + if not dongle_id: + dongle_id = "nada" os.environ['DONGLE_ID'] = dongle_id - cloudlog.info("dirty is %d" % dirty) if not dirty: os.environ['CLEAN'] = '1' @@ -338,17 +432,14 @@ def manager_init(should_register=True): except OSError: pass -def system(cmd): - try: - cloudlog.info("running %s" % cmd) - subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) - except subprocess.CalledProcessError as e: - cloudlog.event("running failed", - cmd=e.cmd, - output=e.output[-1024:], - returncode=e.returncode) - -def sendUserInfoToTinkla(params): + # ensure shared libraries are readable by apks + if EON: + os.chmod(BASEDIR, 0o755) + os.chmod("/dev/shm", 0o777) + os.chmod(os.path.join(BASEDIR, "cereal"), 0o755) + os.chmod(os.path.join(BASEDIR, "cereal", "libmessaging_shared.so"), 0o755) + +def sendUserInfoToTinkla(params, tinklaClient): carSettings = CarSettings() gitRemote = params.get("GitRemote") gitBranch = params.get("GitBranch") @@ -365,8 +456,6 @@ def sendUserInfoToTinkla(params): tinklaClient.setUserInfo(info) def manager_thread(): - # now loop - thermal_sock = messaging.sub_sock(service_list['thermal'].port) cloudlog.info("manager start") cloudlog.info({"environ": os.environ}) @@ -374,41 +463,47 @@ def manager_thread(): # save boot log subprocess.call(["./loggerd", "--bootlog"], cwd=os.path.join(BASEDIR, "selfdrive/loggerd")) - params = Params() - # start daemon processes for p in daemon_processes: - start_daemon_process(p, params) + start_daemon_process(p) # start persistent processes for p in persistent_processes: start_managed_process(p) - # start frame - pm_apply_packages('enable') - system("am start -n ai.comma.plus.frame/.MainActivity") + # start offroad + if EON: + pm_apply_packages('enable') + start_offroad() if os.getenv("NOBOARD") is None: start_managed_process("pandad") + if os.getenv("BLOCK") is not None: + for k in os.getenv("BLOCK").split(","): + del managed_processes[k] + + started_prev = False logger_dead = False + params = Params() + thermal_sock = messaging.sub_sock('thermal') # Tinkla interface - global tinklaClient + last_tinklad_send_attempt_time = 0 tinklaClient = TinklaClient() - sendUserInfoToTinkla(params) + sendUserInfoToTinkla(params=params, tinklaClient=tinklaClient) + start_t = time.time() + first_proc = None while 1: msg = messaging.recv_sock(thermal_sock, wait=True) - # uploader is gated based on the phone temperature - if msg.thermal.thermalStatus >= ThermalStatus.yellow: - kill_managed_process("uploader") - else: - start_managed_process("uploader") - # Attempt to send pending messages if there's any that queued while offline - tinklaClient.attemptToSendPendingMessages() + # Seems this loop runs every second or so, throttle to once every 30s + now = time.time() + if now - last_tinklad_send_attempt_time >= 30: + tinklaClient.attemptToSendPendingMessages() + last_tinklad_send_attempt_time = now if msg.thermal.freeSpace < 0.05: logger_dead = True @@ -421,213 +516,92 @@ def manager_thread(): start_managed_process(p) else: logger_dead = False - # print "msg.thermal.started is False" - for p in car_started_processes: - kill_managed_process(p) - - # check the status of all processes, did any of them die? - running_list = [" running %s %s" % (p, running[p]) for p in running] - #cloudlog.debug('\n'.join(running_list)) + driver_view = params.get("IsDriverViewEnabled") == b"1" - # is this still needed? - if params.get("DoUninstall") == "1": - break - -def get_installed_apks(): - dat = subprocess.check_output(["pm", "list", "packages", "-f"]).strip().split("\n") - ret = {} - for x in dat: - if x.startswith("package:"): - v,k = x.split("package:")[1].split("=") - ret[k] = v - return ret - -def install_apk(path): - # can only install from world readable path - install_path = "/sdcard/%s" % os.path.basename(path) - shutil.copyfile(path, install_path) - - ret = subprocess.call(["pm", "install", "-r", install_path]) - os.remove(install_path) - return ret == 0 - -def update_apks(): - # install apks - installed = get_installed_apks() - - install_apks = glob.glob(os.path.join(BASEDIR, "apk/*.apk")) - for apk in install_apks: - app = os.path.basename(apk)[:-4] - if app not in installed: - installed[app] = None - - cloudlog.info("installed apks %s" % (str(installed), )) - - for app in installed.keys(): - - apk_path = os.path.join(BASEDIR, "apk/"+app+".apk") - if not os.path.exists(apk_path): - continue - - h1 = hashlib.sha1(open(apk_path).read()).hexdigest() - h2 = None - if installed[app] is not None: - h2 = hashlib.sha1(open(installed[app]).read()).hexdigest() - cloudlog.info("comparing version of %s %s vs %s" % (app, h1, h2)) - - if h2 is None or h1 != h2: - cloudlog.info("installing %s" % app) - - success = install_apk(apk_path) - if not success: - cloudlog.info("needing to uninstall %s" % app) - system("pm uninstall %s" % app) - success = install_apk(apk_path) - - assert success - -def update_ssh(): - ssh_home_dirpath = "/system/comma/home/.ssh/" - auth_keys_path = os.path.join(ssh_home_dirpath, "authorized_keys") - auth_keys_persist_path = os.path.join(ssh_home_dirpath, "authorized_keys.persist") - auth_keys_mode = stat.S_IREAD | stat.S_IWRITE - - params = Params() - github_keys = params.get("GithubSshKeys") or '' - - old_keys = open(auth_keys_path).read() - has_persisted_keys = os.path.exists(auth_keys_persist_path) - if has_persisted_keys: - persisted_keys = open(auth_keys_persist_path).read() - else: - # add host filter - persisted_keys = re.sub(r'^(?!.+?from.+? )(ssh|ecdsa)', 'from="10.0.0.0/8,172.16.0.0/12,192.168.0.0/16" \\1', old_keys, flags=re.MULTILINE) + # TODO: refactor how manager manages processes + for p in reversed(car_started_processes): + if p not in driver_view_processes or not driver_view: + kill_managed_process(p) - new_keys = persisted_keys + '\n' + github_keys + for p in driver_view_processes: + if driver_view: + start_managed_process(p) + else: + kill_managed_process(p) - if has_persisted_keys and new_keys == old_keys and os.stat(auth_keys_path)[stat.ST_MODE] == auth_keys_mode: - # nothing to do - let's avoid remount - return + # trigger an update after going offroad + if started_prev: + os.sync() + send_managed_process_signal("updated", signal.SIGHUP) - try: - subprocess.check_call(["mount", "-o", "rw,remount", "/system"]) - if not has_persisted_keys: - atomic_write_in_dir_neos(auth_keys_persist_path, persisted_keys, mode=auth_keys_mode) + started_prev = msg.thermal.started - atomic_write_in_dir_neos(auth_keys_path, new_keys, mode=auth_keys_mode) - finally: - try: - subprocess.check_call(["mount", "-o", "ro,remount", "/system"]) - except: - cloudlog.exception("Failed to remount as read-only") - # this can fail due to "Device busy" - reboot if so - os.system("reboot") - raise RuntimeError + # check the status of all processes, did any of them die? + # running_list = ["%s%s\u001b[0m" % ("\u001b[32m" if running[p].is_alive() else "\u001b[31m", p) for p in running] + #cloudlog.debug(' '.join(running_list)) -def manager_update(): - update_ssh() - update_apks() + # Exit main loop when uninstall is needed + if params.get("DoUninstall", encoding='utf8') == "1": + break def manager_prepare(): - # build cereal first - subprocess.check_call(["make", "-j4"], cwd=os.path.join(BASEDIR, "cereal")) + carSettings = CarSettings() # build all processes os.chdir(os.path.dirname(os.path.abspath(__file__))) - for p in managed_processes: - prepare_managed_process(p) -def uninstall(): - cloudlog.warning("uninstalling") - with open('/cache/recovery/command', 'w') as f: - f.write('--wipe_data\n') - # IPowerManager.reboot(confirm=false, reason="recovery", wait=true) - os.system("service call power 16 i32 0 s16 recovery i32 1") + # Spinner has to start from 70 here + total = 100.0 if PREBUILT else 30.0 -def main(): - # the flippening! - os.system('LD_LIBRARY_PATH="" content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1') - - # disable bluetooth - os.system('service call bluetooth_manager 8') - - if os.getenv("NOLOG") is not None: - del managed_processes['loggerd'] - del managed_processes['tombstoned'] - if os.getenv("NOUPLOAD") is not None: - del managed_processes['uploader'] - if os.getenv("NOVISION") is not None: - del managed_processes['visiond'] - if os.getenv("LEAN") is not None: - del managed_processes['uploader'] - del managed_processes['loggerd'] - del managed_processes['logmessaged'] - del managed_processes['logcatd'] - del managed_processes['tombstoned'] - del managed_processes['proclogd'] - if os.getenv("NOCONTROL") is not None: - del managed_processes['controlsd'] - del managed_processes['plannerd'] - del managed_processes['radard'] - - # support additional internal only extensions - try: - import selfdrive.manager_extensions - selfdrive.manager_extensions.register(register_managed_process) # pylint: disable=no-member - except ImportError: - pass + spinText = "" + if spinner is not None: + spinText = carSettings.spinnerText + + for i, p in enumerate(managed_processes): + perc = (100.0 - total) + total * (i + 1) / len(managed_processes) + spinner.update(spinText + str(int(perc))) + prepare_managed_process(p) +def main(): params = Params() params.manager_start() + default_params = [ + ("CommunityFeaturesToggle", "0"), + ("CompletedTrainingVersion", "0"), + ("IsRHD", "0"), + ("IsMetric", "0"), + ("RecordFront", "0"), + ("HasAcceptedTerms", "0"), + ("HasCompletedSetup", "0"), + ("IsUploadRawEnabled", "1"), + ("IsLdwEnabled", "1"), + ("LastUpdateTime", datetime.datetime.utcnow().isoformat().encode('utf8')), + ("OpenpilotEnabledToggle", "1"), + ("LaneChangeEnabled", "1"), + ("IsDriverViewEnabled", "0"), + #Tesla + ("SpeedLimitOffset", "0"), + ("LimitSetSpeed", "0"), + ] + # set unset params - if params.get("IsMetric") is None: - params.put("IsMetric", "0") - if params.get("RecordFront") is None: - params.put("RecordFront", "0") - if params.get("IsFcwEnabled") is None: - params.put("IsFcwEnabled", "1") - if params.get("HasAcceptedTerms") is None: - params.put("HasAcceptedTerms", "0") - if params.get("IsUploadRawEnabled") is None: - params.put("IsUploadRawEnabled", "1") - if params.get("IsUploadVideoOverCellularEnabled") is None: - params.put("IsUploadVideoOverCellularEnabled", "1") - if params.get("IsDriverMonitoringEnabled") is None: - params.put("IsDriverMonitoringEnabled", "1") - if params.get("IsGeofenceEnabled") is None: - params.put("IsGeofenceEnabled", "-1") - if params.get("SpeedLimitOffset") is None: - params.put("SpeedLimitOffset", "0") - if params.get("LongitudinalControl") is None: - params.put("LongitudinalControl", "0") - if params.get("LimitSetSpeed") is None: - params.put("LimitSetSpeed", "0") - if params.get("LimitSetSpeedNeural") is None: - params.put("LimitSetSpeedNeural", "0") - - # is this chffrplus? + for k, v in default_params: + if params.get(k) is None: + params.put(k, v) + + # is this dashcam? if os.getenv("PASSIVE") is not None: params.put("Passive", str(int(os.getenv("PASSIVE")))) if params.get("Passive") is None: raise Exception("Passive must be set to continue") - # put something on screen while we set things up - if os.getenv("PREPAREONLY") is not None: - spinner_proc = None - else: - spinner_text = "chffrplus" if params.get("Passive")=="1" else "openpilot" - spinner_proc = subprocess.Popen(["./spinner", "Loading %s"%spinner_text], - cwd=os.path.join(BASEDIR, "selfdrive", "ui", "spinner"), - close_fds=True) - try: - manager_update() - manager_init() - manager_prepare() - finally: - if spinner_proc: - spinner_proc.terminate() + if EON: + update_apks() + manager_init() + manager_prepare() + spinner.close() if os.getenv("PREPAREONLY") is not None: return @@ -640,14 +614,30 @@ def main(): except Exception: traceback.print_exc() crash.capture_exception() - print "EXIT ON EXCEPTION" + print ("EXIT ON EXCEPTION") finally: cleanup_all_processes(None, None) - if params.get("DoUninstall") == "1": - uninstall() + if params.get("DoUninstall", encoding='utf8') == "1": + cloudlog.warning("uninstalling") + HARDWARE.uninstall() + if __name__ == "__main__": - main() + try: + main() + except Exception: + add_logentries_handler(cloudlog) + cloudlog.exception("Manager failed to start") + + # Show last 3 lines of traceback + error = traceback.format_exc(-3) + error = "Manager failed to start\n\n" + error + spinner.close() + with TextWindow(error) as t: + t.wait_for_exit() + + raise + # manual exit because we are forked sys.exit(0) diff --git a/selfdrive/messaging.py b/selfdrive/messaging.py deleted file mode 100644 index c4929599a38504..00000000000000 --- a/selfdrive/messaging.py +++ /dev/null @@ -1,177 +0,0 @@ -import zmq - -from cereal import log -from common.realtime import sec_since_boot -from selfdrive.services import service_list - -MSG_ERROR_LVL = 2 - -def new_message(): - dat = log.Event.new_message() - dat.logMonoTime = int(sec_since_boot() * 1e9) - dat.valid = True - return dat - -def pub_sock(port, addr="*"): - context = zmq.Context.instance() - sock = context.socket(zmq.PUB) - sock.bind("tcp://%s:%d" % (addr, port)) - return sock - -def sub_sock(port, poller=None, addr="127.0.0.1", conflate=False, timeout=None): - context = zmq.Context.instance() - sock = context.socket(zmq.SUB) - if conflate: - sock.setsockopt(zmq.CONFLATE, 1) - sock.connect("tcp://%s:%d" % (addr, port)) - sock.setsockopt(zmq.SUBSCRIBE, b"") - - if timeout is not None: - sock.RCVTIMEO = timeout - - if poller is not None: - poller.register(sock, zmq.POLLIN) - return sock - -def drain_sock_raw(sock, wait_for_one=False): - ret = [] - while 1: - try: - if wait_for_one and len(ret) == 0: - dat = sock.recv() - else: - dat = sock.recv(zmq.NOBLOCK) - ret.append(dat) - except zmq.error.Again: - break - return ret - -def drain_sock(sock, wait_for_one=False): - ret = [] - while 1: - try: - if wait_for_one and len(ret) == 0: - dat = sock.recv() - else: - dat = sock.recv(zmq.NOBLOCK) - dat = log.Event.from_bytes(dat) - ret.append(dat) - except zmq.error.Again: - break - return ret - - -# TODO: print when we drop packets? -def recv_sock(sock, wait=False): - dat = None - while 1: - try: - if wait and dat is None: - dat = sock.recv() - else: - dat = sock.recv(zmq.NOBLOCK) - except zmq.error.Again: - break - if dat is not None: - dat = log.Event.from_bytes(dat) - return dat - -def recv_one(sock): - return log.Event.from_bytes(sock.recv()) - -def recv_one_or_none(sock): - try: - return log.Event.from_bytes(sock.recv(zmq.NOBLOCK)) - except zmq.error.Again: - return None - - -class SubMaster(): - def __init__(self, services, addr="127.0.0.1"): - self.poller = zmq.Poller() - self.frame = -1 - self.updated = {s : False for s in services} - self.rcv_time = {s : 0. for s in services} - self.rcv_frame = {s : 0 for s in services} - self.alive = {s : False for s in services} - self.alive_cnt = {s: 0 for s in services} - self.sock = {} - self.freq = {} - self.data = {} - self.logMonoTime = {} - self.valid = {} - self.valid_cnt = {s: 0 for s in services} - for s in services: - # TODO: get address automatically from service_list - if addr is not None: - self.sock[s] = sub_sock(service_list[s].port, poller=self.poller, addr=addr, conflate=True) - self.freq[s] = service_list[s].frequency - data = new_message() - data.init(s) - self.data[s] = getattr(data, s) - self.logMonoTime[s] = 0 - if data.valid: - self.valid_cnt[s] = 0 - self.valid[s] = True - else: - self.valid_cnt[s] += 1 - if self.valid_cnt[s] >= MSG_ERROR_LVL: - self.valid[s] = False - - def __getitem__(self, s): - return self.data[s] - - def update(self, timeout=-1): - msgs = [] - for sock, _ in self.poller.poll(timeout): - msgs.append(recv_one(sock)) - self.update_msgs(sec_since_boot(), msgs) - - def update_msgs(self, cur_time, msgs): - # TODO: add optional input that specify the service to wait for - self.frame += 1 - self.updated = dict.fromkeys(self.updated, False) - for msg in msgs: - s = msg.which() - self.updated[s] = True - self.rcv_time[s] = cur_time - self.rcv_frame[s] = self.frame - self.data[s] = getattr(msg, s) - self.logMonoTime[s] = msg.logMonoTime - if msg.valid: - self.valid_cnt[s] = 0 - self.valid[s] = True - else: - self.valid_cnt[s] += 1 - if self.valid_cnt[s] >= MSG_ERROR_LVL: - self.valid[s] = False - - for s in self.data: - # arbitrary small number to avoid float comparison. If freq is 0, we can skip the check - if self.freq[s] > 1e-5: - # alive if delay is within 10x the expected frequency - if (cur_time - self.rcv_time[s]) < (10. / self.freq[s]): - self.alive_cnt[s] = 0 - self.alive[s] = True - else: - self.alive_cnt[s] += 1 - if self.alive_cnt[s] >= MSG_ERROR_LVL: - self.alive[s] = False - else: - self.alive_cnt[s] = 0 - self.alive[s] = True - - def all_alive(self, service_list=None): - if service_list is None: # check all - service_list = self.alive.keys() - return all(self.alive[s] for s in service_list) - - def all_valid(self, service_list=None): - if service_list is None: # check all - service_list = self.valid.keys() - return all(self.valid[s] for s in service_list) - - def all_alive_and_valid(self, service_list=None): - if service_list is None: # check all - service_list = self.alive.keys() - return self.all_alive(service_list=service_list) and self.all_valid(service_list=service_list) diff --git a/selfdrive/modeld/SConscript b/selfdrive/modeld/SConscript new file mode 100644 index 00000000000000..4fcded106c0e8d --- /dev/null +++ b/selfdrive/modeld/SConscript @@ -0,0 +1,54 @@ +Import('env', 'arch', 'cereal', 'messaging', 'common', 'gpucommon', 'visionipc') +lenv = env.Clone() + +libs = [cereal, messaging, common, 'OpenCL', 'SNPE', 'symphony-cpu', 'capnp', 'zmq', 'kj', 'yuv', gpucommon, visionipc] + +common_src = [ + "models/commonmodel.cc", + "runners/snpemodel.cc", + "transforms/loadyuv.cc", + "transforms/transform.cc" +] + +if arch == "aarch64": + libs += ['gsl', 'CB', 'gnustl_shared'] + common_src += ["thneed/thneed.cc"] + lenv['CFLAGS'].append("-DUSE_THNEED") + lenv['CXXFLAGS'].append("-DUSE_THNEED") +elif arch == "larch64": + libs += ['gsl', 'CB', 'pthread', 'dl'] + common_src += ["thneed/thneed.cc"] + lenv['CFLAGS'].append("-DUSE_THNEED") + lenv['CXXFLAGS'].append("-DUSE_THNEED") +else: + libs += ['pthread'] + + # for onnx support + common_src += ['runners/onnxmodel.cc'] + + # tell runners to use onnx + lenv['CFLAGS'].append("-DUSE_ONNX_MODEL") + lenv['CXXFLAGS'].append("-DUSE_ONNX_MODEL") + + if arch == "Darwin": + # fix OpenCL + del libs[libs.index('OpenCL')] + lenv['FRAMEWORKS'] = ['OpenCL'] + + # no SNPE on Mac + del libs[libs.index('SNPE')] + del libs[libs.index('symphony-cpu')] + del common_src[common_src.index('runners/snpemodel.cc')] + +common = lenv.Object(common_src) + +lenv.Program('_dmonitoringmodeld', [ + "dmonitoringmodeld.cc", + "models/dmonitoring.cc", + ]+common, LIBS=libs) + +lenv.Program('_modeld', [ + "modeld.cc", + "models/driving.cc", + ]+common, LIBS=libs) + diff --git a/selfdrive/modeld/constants.py b/selfdrive/modeld/constants.py new file mode 100644 index 00000000000000..2bf48574f8d6f4 --- /dev/null +++ b/selfdrive/modeld/constants.py @@ -0,0 +1,6 @@ +MAX_DISTANCE = 140. +LANE_OFFSET = 1.8 +MAX_REL_V = 10. + +LEAD_X_SCALE = 10 +LEAD_Y_SCALE = 10 diff --git a/selfdrive/modeld/dmonitoringmodeld b/selfdrive/modeld/dmonitoringmodeld new file mode 100755 index 00000000000000..e84bbbf3730328 --- /dev/null +++ b/selfdrive/modeld/dmonitoringmodeld @@ -0,0 +1,15 @@ +#!/bin/sh + +if [ -d /system ]; then + if [ -f /TICI ]; then # QCOM2 + export LD_LIBRARY_PATH="/usr/lib/aarch64-linux-gnu:/data/pythonpath/phonelibs/snpe/larch64:$LD_LIBRARY_PATH" + else # QCOM + export LD_LIBRARY_PATH="/data/pythonpath/phonelibs/snpe/aarch64/:$LD_LIBRARY_PATH" + fi + export ADSP_LIBRARY_PATH="/data/pythonpath/phonelibs/snpe/dsp/" +else + # PC + export LD_LIBRARY_PATH="$HOME/openpilot/phonelibs/snpe/x86_64-linux-clang:/openpilot/phonelibs/snpe/x86_64:$HOME/openpilot/phonelibs/snpe/x86_64:$LD_LIBRARY_PATH" +fi + +exec ./_dmonitoringmodeld diff --git a/selfdrive/modeld/dmonitoringmodeld.cc b/selfdrive/modeld/dmonitoringmodeld.cc new file mode 100644 index 00000000000000..1da4b6138db455 --- /dev/null +++ b/selfdrive/modeld/dmonitoringmodeld.cc @@ -0,0 +1,109 @@ +#include +#include +#include +#include +#include +#include + +#include "common/visionbuf.h" +#include "common/visionipc.h" +#include "common/swaglog.h" + +#include "models/dmonitoring.h" + +#ifndef PATH_MAX +#include +#endif + +bool get_bool_config_option(const char *key) { + char line[500]; + FILE *stream; + stream = fopen("/data/bb_openpilot.cfg", "r"); + while(fgets(line, 500, stream) != NULL) + { + char setting[256], value[256], oper[10]; + if(line[0] == '#') continue; + if(sscanf(line, "%s %s %s", setting, oper, value) != 3) { + continue; + } + if ((strcmp(key, setting) == 0) && (strcmp("True", value) == 0)) { + fclose(stream); + return true; + } + } + fclose(stream); + return false; +} + +volatile sig_atomic_t do_exit = 0; + +static void set_do_exit(int sig) { + do_exit = 1; +} + +int main(int argc, char **argv) { + int err; + setpriority(PRIO_PROCESS, 0, -15); + + signal(SIGINT, (sighandler_t)set_do_exit); + signal(SIGTERM, (sighandler_t)set_do_exit); + + PubMaster pm({"driverState"}); + + // init the models + DMonitoringModelState dmonitoringmodel; + dmonitoring_init(&dmonitoringmodel); + + // loop + VisionStream stream; + while (!do_exit) { + VisionStreamBufs buf_info; + err = visionstream_init(&stream, VISION_STREAM_YUV_FRONT, true, &buf_info); + if (err) { + printf("visionstream connect fail\n"); + usleep(100000); + continue; + } + LOGW("connected with buffer size: %d", buf_info.buf_len); + + bool is_dm_throttled = get_bool_config_option("throttle_driver_monitor"); + bool is_dm_disabled = !get_bool_config_option("enable_driver_monitor"); + double last = 0; + while (!do_exit) { + VIPCBuf *buf; + VIPCBufExtra extra; + buf = visionstream_get(&stream, &extra); + if (buf == NULL) { + printf("visionstream get failed\n"); + break; + } + + double t1 = millis_since_boot(); + DMonitoringResult res = dmonitoring_eval_frame(&dmonitoringmodel, buf->addr, buf_info.width, buf_info.height); + double t2 = millis_since_boot(); + + // send dm packet + const float* raw_pred_ptr = send_raw_pred ? (const float *)dmonitoringmodel.output : nullptr; + dmonitoring_publish(pm, extra.frame_id, res, raw_pred_ptr, (t2-t1)/1000.0); + + LOGD("dmonitoring process: %.2fms, from last %.2fms", t2-t1, t1-last); + last = t1; + if (is_dm_disabled) { + usleep(1*1000*1000); + } else if (is_dm_throttled) { + usleep(250*1000); + } else { +#ifdef QCOM2 + // this makes it run at about 2.7Hz on tici CPU to deal with modeld lags + // TODO: DSP needs to be freed (again) + usleep(250000); +#endif + } + } + visionstream_destroy(&stream); + } + + dmonitoring_free(&dmonitoringmodel); + + return 0; +} diff --git a/selfdrive/modeld/modeld b/selfdrive/modeld/modeld new file mode 100755 index 00000000000000..66868595723991 --- /dev/null +++ b/selfdrive/modeld/modeld @@ -0,0 +1,12 @@ +#!/bin/sh +if [ -d /system ]; then + if [ -f /TICI ]; then # QCOM2 + export LD_LIBRARY_PATH="/usr/lib/aarch64-linux-gnu:/data/pythonpath/phonelibs/snpe/larch64:$LD_LIBRARY_PATH" + else # QCOM + export LD_LIBRARY_PATH="/data/pythonpath/phonelibs/snpe/aarch64/:$LD_LIBRARY_PATH" + fi +else + # PC + export LD_LIBRARY_PATH="$HOME/openpilot/phonelibs/snpe/x86_64-linux-clang:/openpilot/phonelibs/snpe/x86_64:$HOME/openpilot/phonelibs/snpe/x86_64:$LD_LIBRARY_PATH" +fi +exec ./_modeld diff --git a/selfdrive/modeld/modeld.cc b/selfdrive/modeld/modeld.cc new file mode 100644 index 00000000000000..2febb42ada0b41 --- /dev/null +++ b/selfdrive/modeld/modeld.cc @@ -0,0 +1,222 @@ +#include +#include +#include +#include +#include + +#include "common/visionbuf.h" +#include "common/visionipc.h" +#include "common/swaglog.h" +#include "common/clutil.h" + +#include "models/driving.h" +#include "messaging.hpp" +volatile sig_atomic_t do_exit = 0; + +static void set_do_exit(int sig) { + do_exit = 1; +} + +// globals +bool run_model; +mat3 cur_transform; +pthread_mutex_t transform_lock; + +void* live_thread(void *arg) { + set_thread_name("live"); + set_realtime_priority(50); + + SubMaster sm({"liveCalibration"}); + + /* + import numpy as np + from common.transformations.model import medmodel_frame_from_road_frame + medmodel_frame_from_ground = medmodel_frame_from_road_frame[:, (0, 1, 3)] + ground_from_medmodel_frame = np.linalg.inv(medmodel_frame_from_ground) + */ + Eigen::Matrix ground_from_medmodel_frame; + ground_from_medmodel_frame << + 0.00000000e+00, 0.00000000e+00, 1.00000000e+00, + -1.09890110e-03, 0.00000000e+00, 2.81318681e-01, + -1.84808520e-20, 9.00738606e-04,-4.28751576e-02; + + Eigen::Matrix fcam_intrinsics; +#ifndef QCOM2 + fcam_intrinsics << + 910.0, 0.0, 582.0, + 0.0, 910.0, 437.0, + 0.0, 0.0, 1.0; + float db_s = 0.5; // debayering does a 2x downscale +#else + fcam_intrinsics << + 2648.0, 0.0, 1928.0/2, + 0.0, 2648.0, 1208.0/2, + 0.0, 0.0, 1.0; + float db_s = 1.0; +#endif + + mat3 yuv_transform = transform_scale_buffer((mat3){{ + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0, + }}, db_s); + + while (!do_exit) { + if (sm.update(100) > 0){ + + auto extrinsic_matrix = sm["liveCalibration"].getLiveCalibration().getExtrinsicMatrix(); + Eigen::Matrix extrinsic_matrix_eigen; + for (int i = 0; i < 4*3; i++){ + extrinsic_matrix_eigen(i / 4, i % 4) = extrinsic_matrix[i]; + } + + auto camera_frame_from_road_frame = fcam_intrinsics * extrinsic_matrix_eigen; + Eigen::Matrix camera_frame_from_ground; + camera_frame_from_ground.col(0) = camera_frame_from_road_frame.col(0); + camera_frame_from_ground.col(1) = camera_frame_from_road_frame.col(1); + camera_frame_from_ground.col(2) = camera_frame_from_road_frame.col(3); + + auto warp_matrix = camera_frame_from_ground * ground_from_medmodel_frame; + mat3 transform = {}; + for (int i=0; i<3*3; i++) { + transform.v[i] = warp_matrix(i / 3, i % 3); + } + mat3 model_transform = matmul3(yuv_transform, transform); + pthread_mutex_lock(&transform_lock); + cur_transform = model_transform; + run_model = true; + pthread_mutex_unlock(&transform_lock); + } + } + return NULL; +} + +int main(int argc, char **argv) { + int err; + set_realtime_priority(54); + +#ifdef QCOM + set_core_affinity(2); +#elif QCOM2 + // CPU usage is much lower when pinned to a single big core + set_core_affinity(4); +#endif + + signal(SIGINT, (sighandler_t)set_do_exit); + signal(SIGTERM, (sighandler_t)set_do_exit); + + pthread_mutex_init(&transform_lock, NULL); + + // start calibration thread + pthread_t live_thread_handle; + err = pthread_create(&live_thread_handle, NULL, live_thread, NULL); + assert(err == 0); + + // messaging + PubMaster pm({"modelV2", "model", "cameraOdometry"}); + SubMaster sm({"pathPlan", "frame"}); + + // cl init + cl_device_id device_id = cl_get_device_id(CL_DEVICE_TYPE_DEFAULT); + cl_context context = CL_CHECK_ERR(clCreateContext(NULL, 1, &device_id, NULL, NULL, &err)); + + // init the models + ModelState model; + model_init(&model, device_id, context); + LOGW("models loaded, modeld starting"); + + // loop + VisionStream stream; + while (!do_exit) { + VisionStreamBufs buf_info; + err = visionstream_init(&stream, VISION_STREAM_YUV, true, &buf_info); + if (err) { + LOGW("visionstream connect failed"); + usleep(100000); + continue; + } + LOGW("connected with buffer size: %d", buf_info.buf_len); + + // setup filter to track dropped frames + const float dt = 1. / MODEL_FREQ; + const float ts = 10.0; // filter time constant (s) + const float frame_filter_k = (dt / ts) / (1. + dt / ts); + float frames_dropped = 0; + + // one frame in memory + VisionBuf yuv_ion = visionbuf_allocate_cl(buf_info.buf_len, device_id, context); + + uint32_t frame_id = 0, last_vipc_frame_id = 0; + double last = 0; + int desire = -1; + uint32_t run_count = 0; + while (!do_exit) { + VIPCBuf *buf; + VIPCBufExtra extra; + buf = visionstream_get(&stream, &extra); + if (buf == NULL) { + LOGW("visionstream get failed"); + break; + } + + pthread_mutex_lock(&transform_lock); + mat3 model_transform = cur_transform; + const bool run_model_this_iter = run_model; + pthread_mutex_unlock(&transform_lock); + + if (sm.update(0) > 0){ + // TODO: path planner timeout? + desire = ((int)sm["pathPlan"].getPathPlan().getDesire()); + frame_id = sm["frame"].getFrame().getFrameId(); + } + + double mt1 = 0, mt2 = 0; + if (run_model_this_iter) { + run_count++; + + float vec_desire[DESIRE_LEN] = {0}; + if (desire >= 0 && desire < DESIRE_LEN) { + vec_desire[desire] = 1.0; + } + + mt1 = millis_since_boot(); + + // TODO: don't make copies! + memcpy(yuv_ion.addr, buf->addr, buf_info.buf_len); + visionbuf_sync(&yuv_ion, VISIONBUF_SYNC_TO_DEVICE); + + ModelDataRaw model_buf = + model_eval_frame(&model, yuv_ion.buf_cl, buf_info.width, buf_info.height, + model_transform, vec_desire); + mt2 = millis_since_boot(); + float model_execution_time = (mt2 - mt1) / 1000.0; + + // tracked dropped frames + uint32_t vipc_dropped_frames = extra.frame_id - last_vipc_frame_id - 1; + frames_dropped = (1. - frame_filter_k) * frames_dropped + frame_filter_k * (float)std::min(vipc_dropped_frames, 10U); + if (run_count < 10) frames_dropped = 0; // let frame drops warm up + float frame_drop_ratio = frames_dropped / (1 + frames_dropped); + + const float *raw_pred_ptr = send_raw_pred ? &model.output[0] : nullptr; + model_publish(pm, extra.frame_id, frame_id, frame_drop_ratio, model_buf, raw_pred_ptr, extra.timestamp_eof, model_execution_time); + posenet_publish(pm, extra.frame_id, vipc_dropped_frames, model_buf, extra.timestamp_eof); + + LOGD("model process: %.2fms, from last %.2fms, vipc_frame_id %zu, frame_id, %zu, frame_drop %.3f", mt2-mt1, mt1-last, extra.frame_id, frame_id, frame_drop_ratio); + last = mt1; + last_vipc_frame_id = extra.frame_id; + } + + } + visionbuf_free(&yuv_ion); + visionstream_destroy(&stream); + } + + model_free(&model); + + LOG("joining live_thread"); + err = pthread_join(live_thread_handle, NULL); + assert(err == 0); + CL_CHECK(clReleaseContext(context)); + pthread_mutex_destroy(&transform_lock); + return 0; +} diff --git a/selfdrive/modeld/models/commonmodel.cc b/selfdrive/modeld/models/commonmodel.cc new file mode 100644 index 00000000000000..cc7d4b157eafc1 --- /dev/null +++ b/selfdrive/modeld/models/commonmodel.cc @@ -0,0 +1,83 @@ +#include +#include +#include "commonmodel.h" +#include "common/clutil.h" +#include "common/mat.h" +#include "common/timing.h" + +void frame_init(ModelFrame* frame, int width, int height, + cl_device_id device_id, cl_context context) { + transform_init(&frame->transform, context, device_id); + frame->transformed_width = width; + frame->transformed_height = height; + + frame->transformed_y_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, + (size_t)frame->transformed_width*frame->transformed_height, NULL, &err)); + frame->transformed_u_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, + (size_t)(frame->transformed_width/2)*(frame->transformed_height/2), NULL, &err)); + frame->transformed_v_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, + (size_t)(frame->transformed_width/2)*(frame->transformed_height/2), NULL, &err)); + frame->net_input_size = ((width*height*3)/2)*sizeof(float); + frame->net_input = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, + frame->net_input_size, (void*)NULL, &err)); + loadyuv_init(&frame->loadyuv, context, device_id, frame->transformed_width, frame->transformed_height); +} + +float *frame_prepare(ModelFrame* frame, cl_command_queue q, + cl_mem yuv_cl, int width, int height, + const mat3 &transform) { + transform_queue(&frame->transform, q, + yuv_cl, width, height, + frame->transformed_y_cl, frame->transformed_u_cl, frame->transformed_v_cl, + frame->transformed_width, frame->transformed_height, + transform); + loadyuv_queue(&frame->loadyuv, q, + frame->transformed_y_cl, frame->transformed_u_cl, frame->transformed_v_cl, + frame->net_input); + float *net_input_buf = (float *)CL_CHECK_ERR(clEnqueueMapBuffer(q, frame->net_input, CL_TRUE, + CL_MAP_READ, 0, frame->net_input_size, + 0, NULL, NULL, &err)); + clFinish(q); + return net_input_buf; +} + +void frame_free(ModelFrame* frame) { + transform_destroy(&frame->transform); + loadyuv_destroy(&frame->loadyuv); + CL_CHECK(clReleaseMemObject(frame->net_input)); + CL_CHECK(clReleaseMemObject(frame->transformed_v_cl)); + CL_CHECK(clReleaseMemObject(frame->transformed_u_cl)); + CL_CHECK(clReleaseMemObject(frame->transformed_y_cl)); +} + +void softmax(const float* input, float* output, size_t len) { + float max_val = -FLT_MAX; + for(int i = 0; i < len; i++) { + const float v = input[i]; + if( v > max_val ) { + max_val = v; + } + } + + float denominator = 0; + for(int i = 0; i < len; i++) { + float const v = input[i]; + float const v_exp = expf(v - max_val); + denominator += v_exp; + output[i] = v_exp; + } + + const float inv_denominator = 1. / denominator; + for(int i = 0; i < len; i++) { + output[i] *= inv_denominator; + } + +} + +float sigmoid(float input) { + return 1 / (1 + expf(-input)); +} + +float softplus(float input) { + return log1p(expf(input)); +} diff --git a/selfdrive/modeld/models/commonmodel.h b/selfdrive/modeld/models/commonmodel.h new file mode 100644 index 00000000000000..1e1200db6dd1f8 --- /dev/null +++ b/selfdrive/modeld/models/commonmodel.h @@ -0,0 +1,35 @@ +#pragma once +#define CL_USE_DEPRECATED_OPENCL_1_2_APIS +#ifdef __APPLE__ +#include +#else +#include +#endif + +#include +#include +#include "common/mat.h" +#include "transforms/transform.h" +#include "transforms/loadyuv.h" + +const bool send_raw_pred = getenv("SEND_RAW_PRED") != NULL; + +void softmax(const float* input, float* output, size_t len); +float softplus(float input); +float sigmoid(float input); + +typedef struct ModelFrame { + Transform transform; + int transformed_width, transformed_height; + cl_mem transformed_y_cl, transformed_u_cl, transformed_v_cl; + LoadYUVState loadyuv; + cl_mem net_input; + size_t net_input_size; +} ModelFrame; + +void frame_init(ModelFrame* frame, int width, int height, + cl_device_id device_id, cl_context context); +float *frame_prepare(ModelFrame* frame, cl_command_queue q, + cl_mem yuv_cl, int width, int height, + const mat3 &transform); +void frame_free(ModelFrame* frame); diff --git a/selfdrive/modeld/models/dmonitoring.cc b/selfdrive/modeld/models/dmonitoring.cc new file mode 100644 index 00000000000000..f13287f03c04a4 --- /dev/null +++ b/selfdrive/modeld/models/dmonitoring.cc @@ -0,0 +1,214 @@ +#include +#include "dmonitoring.h" +#include "common/mat.h" +#include "common/timing.h" +#include "common/params.h" + +#include + +#define MODEL_WIDTH 320 +#define MODEL_HEIGHT 640 +#define FULL_W 852 // should get these numbers from camerad + +#if defined(QCOM) || defined(QCOM2) +#define input_lambda(x) (x - 128.f) * 0.0078125f +#else +#define input_lambda(x) x // for non SNPE running platforms, assume keras model instead has lambda layer +#endif + +void dmonitoring_init(DMonitoringModelState* s) { +#if defined(QCOM) || defined(QCOM2) + const char* model_path = "../../models/dmonitoring_model_q.dlc"; +#else + const char* model_path = "../../models/dmonitoring_model.dlc"; +#endif + + int runtime = USE_DSP_RUNTIME; + s->m = new DefaultRunModel(model_path, (float*)&s->output, OUTPUT_SIZE, runtime); + s->is_rhd = Params().read_db_bool("IsRHD"); +} + +template +static inline T *get_buffer(std::vector &buf, const size_t size) { + if (buf.size() < size) { + buf.resize(size); + } + return buf.data(); +} + +DMonitoringResult dmonitoring_eval_frame(DMonitoringModelState* s, void* stream_buf, int width, int height) { + uint8_t *raw_buf = (uint8_t*) stream_buf; + uint8_t *raw_y_buf = raw_buf; + uint8_t *raw_u_buf = raw_y_buf + (width * height); + uint8_t *raw_v_buf = raw_u_buf + ((width/2) * (height/2)); + +#ifndef QCOM2 + const int cropped_width = height/2; + const int cropped_height = height; + const int global_x_offset = 0; + const int global_y_offset = 0; + const int crop_x_offset = width - cropped_width; + const int crop_y_offset = 0; +#else + const int full_width_tici = 1928; + const int full_height_tici = 1208; + const int adapt_width_tici = 636; + + const int cropped_height = adapt_width_tici / 1.33; + const int cropped_width = cropped_height / 2; + const int global_x_offset = full_width_tici / 2 - adapt_width_tici / 2; + const int global_y_offset = full_height_tici / 2 - cropped_height / 2; + const int crop_x_offset = adapt_width_tici - cropped_width; + const int crop_y_offset = 0; +#endif + + int resized_width = MODEL_WIDTH; + int resized_height = MODEL_HEIGHT; + + uint8_t *cropped_y_buf = get_buffer(s->cropped_buf, cropped_width*cropped_height*3/2); + uint8_t *cropped_u_buf = cropped_y_buf + (cropped_width * cropped_height); + uint8_t *cropped_v_buf = cropped_u_buf + ((cropped_width/2) * (cropped_height/2)); + + if (!s->is_rhd) { + for (int r = 0; r < cropped_height/2; r++) { + memcpy(cropped_y_buf + 2*r*cropped_width, raw_y_buf + (2*r + global_y_offset + crop_y_offset)*width + global_x_offset + crop_x_offset, cropped_width); + memcpy(cropped_y_buf + (2*r+1)*cropped_width, raw_y_buf + (2*r + global_y_offset + crop_y_offset + 1)*width + global_x_offset + crop_x_offset, cropped_width); + memcpy(cropped_u_buf + r*cropped_width/2, raw_u_buf + (r + (global_y_offset + crop_y_offset)/2)*width/2 + (global_x_offset + crop_x_offset)/2, cropped_width/2); + memcpy(cropped_v_buf + r*cropped_width/2, raw_v_buf + (r + (global_y_offset + crop_y_offset)/2)*width/2 + (global_x_offset + crop_x_offset)/2, cropped_width/2); + } + } else { + uint8_t *premirror_cropped_y_buf = get_buffer(s->premirror_cropped_buf, cropped_width*cropped_height*3/2); + uint8_t *premirror_cropped_u_buf = premirror_cropped_y_buf + (cropped_width * cropped_height); + uint8_t *premirror_cropped_v_buf = premirror_cropped_u_buf + ((cropped_width/2) * (cropped_height/2)); + for (int r = 0; r < cropped_height/2; r++) { + memcpy(premirror_cropped_y_buf + (2*r)*cropped_width, raw_y_buf + (2*r + global_y_offset + crop_y_offset)*width + global_x_offset, cropped_width); + memcpy(premirror_cropped_y_buf + (2*r+1)*cropped_width, raw_y_buf + (2*r + global_y_offset + crop_y_offset + 1)*width + global_x_offset, cropped_width); + memcpy(premirror_cropped_u_buf + r*cropped_width/2, raw_u_buf + (r + (global_y_offset + crop_y_offset)/2)*width/2 + global_x_offset/2, cropped_width/2); + memcpy(premirror_cropped_v_buf + r*cropped_width/2, raw_v_buf + (r + (global_y_offset + crop_y_offset)/2)*width/2 + global_x_offset/2, cropped_width/2); + } + libyuv::I420Mirror(premirror_cropped_y_buf, cropped_width, + premirror_cropped_u_buf, cropped_width/2, + premirror_cropped_v_buf, cropped_width/2, + cropped_y_buf, cropped_width, + cropped_u_buf, cropped_width/2, + cropped_v_buf, cropped_width/2, + cropped_width, cropped_height); + } + + uint8_t *resized_buf = get_buffer(s->resized_buf, resized_width*resized_height*3/2); + uint8_t *resized_y_buf = resized_buf; + uint8_t *resized_u_buf = resized_y_buf + (resized_width * resized_height); + uint8_t *resized_v_buf = resized_u_buf + ((resized_width/2) * (resized_height/2)); + + libyuv::FilterMode mode = libyuv::FilterModeEnum::kFilterBilinear; + libyuv::I420Scale(cropped_y_buf, cropped_width, + cropped_u_buf, cropped_width/2, + cropped_v_buf, cropped_width/2, + cropped_width, cropped_height, + resized_y_buf, resized_width, + resized_u_buf, resized_width/2, + resized_v_buf, resized_width/2, + resized_width, resized_height, + mode); + + // prerotate to be cache aware + uint8_t *resized_buf_rot = get_buffer(s->resized_buf_rot, resized_width*resized_height*3/2); + uint8_t *resized_y_buf_rot = resized_buf_rot; + uint8_t *resized_u_buf_rot = resized_y_buf_rot + (resized_width * resized_height); + uint8_t *resized_v_buf_rot = resized_u_buf_rot + ((resized_width/2) * (resized_height/2)); + + libyuv::I420Rotate(resized_y_buf, resized_width, + resized_u_buf, resized_width/2, + resized_v_buf, resized_width/2, + resized_y_buf_rot, resized_height, + resized_u_buf_rot, resized_height/2, + resized_v_buf_rot, resized_height/2, + // negative height causes a vertical flip to match previous + resized_width, -resized_height, libyuv::kRotate90); + + int yuv_buf_len = (MODEL_WIDTH/2) * (MODEL_HEIGHT/2) * 6; // Y|u|v -> y|y|y|y|u|v + float *net_input_buf = get_buffer(s->net_input_buf, yuv_buf_len); + // one shot conversion, O(n) anyway + // yuvframe2tensor, normalize + for (int c = 0; c < MODEL_WIDTH/2; c++) { + for (int r = 0; r < MODEL_HEIGHT/2; r++) { + // Y_ul + net_input_buf[(c*MODEL_HEIGHT/2) + r + (0*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = input_lambda(resized_buf_rot[(2*r) + (2*c)*resized_height]); + // Y_dl + net_input_buf[(c*MODEL_HEIGHT/2) + r + (1*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = input_lambda(resized_buf_rot[(2*r+1) + (2*c)*resized_height]); + // Y_ur + net_input_buf[(c*MODEL_HEIGHT/2) + r + (2*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = input_lambda(resized_buf_rot[(2*r) + (2*c+1)*resized_height]); + // Y_dr + net_input_buf[(c*MODEL_HEIGHT/2) + r + (3*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = input_lambda(resized_buf_rot[(2*r+1) + (2*c+1)*resized_height]); + // U + net_input_buf[(c*MODEL_HEIGHT/2) + r + (4*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = input_lambda(resized_buf_rot[(resized_width*resized_height) + r + (c*resized_height/2)]); + // V + net_input_buf[(c*MODEL_HEIGHT/2) + r + (5*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = input_lambda(resized_buf_rot[(resized_width*resized_height) + ((resized_width/2)*(resized_height/2)) + r + (c*resized_height/2)]); + } + } + + //printf("preprocess completed. %d \n", yuv_buf_len); + //FILE *dump_yuv_file = fopen("/tmp/rawdump.yuv", "wb"); + //fwrite(raw_buf, height*width*3/2, sizeof(uint8_t), dump_yuv_file); + //fclose(dump_yuv_file); + + // *** testing *** + // idat = np.frombuffer(open("/tmp/inputdump.yuv", "rb").read(), np.float32).reshape(6, 160, 320) + // imshow(cv2.cvtColor(tensor_to_frames(idat[None]/0.0078125+128)[0], cv2.COLOR_YUV2RGB_I420)) + + //FILE *dump_yuv_file2 = fopen("/tmp/inputdump.yuv", "wb"); + //fwrite(net_input_buf, MODEL_HEIGHT*MODEL_WIDTH*3/2, sizeof(float), dump_yuv_file2); + //fclose(dump_yuv_file2); + + double t1 = millis_since_boot(); + s->m->execute(net_input_buf, yuv_buf_len); + double t2 = millis_since_boot(); + + DMonitoringResult ret = {0}; + memcpy(&ret.face_orientation, &s->output[0], sizeof ret.face_orientation); + memcpy(&ret.face_orientation_meta, &s->output[6], sizeof ret.face_orientation_meta); + memcpy(&ret.face_position, &s->output[3], sizeof ret.face_position); + memcpy(&ret.face_position_meta, &s->output[9], sizeof ret.face_position_meta); + memcpy(&ret.face_prob, &s->output[12], sizeof ret.face_prob); + memcpy(&ret.left_eye_prob, &s->output[21], sizeof ret.left_eye_prob); + memcpy(&ret.right_eye_prob, &s->output[30], sizeof ret.right_eye_prob); + memcpy(&ret.left_blink_prob, &s->output[31], sizeof ret.right_eye_prob); + memcpy(&ret.right_blink_prob, &s->output[32], sizeof ret.right_eye_prob); + memcpy(&ret.sg_prob, &s->output[33], sizeof ret.sg_prob); + ret.face_orientation_meta[0] = softplus(ret.face_orientation_meta[0]); + ret.face_orientation_meta[1] = softplus(ret.face_orientation_meta[1]); + ret.face_orientation_meta[2] = softplus(ret.face_orientation_meta[2]); + ret.face_position_meta[0] = softplus(ret.face_position_meta[0]); + ret.face_position_meta[1] = softplus(ret.face_position_meta[1]); + ret.dsp_execution_time = (t2 - t1) / 1000.; + return ret; +} + +void dmonitoring_publish(PubMaster &pm, uint32_t frame_id, const DMonitoringResult &res, const float* raw_pred, float execution_time){ + // make msg + MessageBuilder msg; + auto framed = msg.initEvent().initDriverState(); + framed.setFrameId(frame_id); + framed.setModelExecutionTime(execution_time); + framed.setDspExecutionTime(res.dsp_execution_time); + + framed.setFaceOrientation(res.face_orientation); + framed.setFaceOrientationStd(res.face_orientation_meta); + framed.setFacePosition(res.face_position); + framed.setFacePositionStd(res.face_position_meta); + framed.setFaceProb(res.face_prob); + framed.setLeftEyeProb(res.left_eye_prob); + framed.setRightEyeProb(res.right_eye_prob); + framed.setLeftBlinkProb(res.left_blink_prob); + framed.setRightBlinkProb(res.right_blink_prob); + framed.setSgProb(res.sg_prob); + if (send_raw_pred) { + framed.setRawPred(kj::arrayPtr((const uint8_t*)raw_pred, OUTPUT_SIZE*sizeof(float))); + } + + pm.send("driverState", msg); +} + +void dmonitoring_free(DMonitoringModelState* s) { + delete s->m; +} diff --git a/selfdrive/modeld/models/dmonitoring.h b/selfdrive/modeld/models/dmonitoring.h new file mode 100644 index 00000000000000..7df3355bbcd124 --- /dev/null +++ b/selfdrive/modeld/models/dmonitoring.h @@ -0,0 +1,39 @@ +#pragma once +#include +#include "common/util.h" +#include "commonmodel.h" +#include "runners/run.h" +#include "messaging.hpp" + +#define OUTPUT_SIZE 34 + +typedef struct DMonitoringResult { + float face_orientation[3]; + float face_orientation_meta[3]; + float face_position[2]; + float face_position_meta[2]; + float face_prob; + float left_eye_prob; + float right_eye_prob; + float left_blink_prob; + float right_blink_prob; + float sg_prob; + float dsp_execution_time; +} DMonitoringResult; + +typedef struct DMonitoringModelState { + RunModel *m; + bool is_rhd; + float output[OUTPUT_SIZE]; + std::vector resized_buf; + std::vector resized_buf_rot; + std::vector cropped_buf; + std::vector premirror_cropped_buf; + std::vector net_input_buf; +} DMonitoringModelState; + +void dmonitoring_init(DMonitoringModelState* s); +DMonitoringResult dmonitoring_eval_frame(DMonitoringModelState* s, void* stream_buf, int width, int height); +void dmonitoring_publish(PubMaster &pm, uint32_t frame_id, const DMonitoringResult &res, const float* raw_pred, float execution_time); +void dmonitoring_free(DMonitoringModelState* s); + diff --git a/selfdrive/modeld/models/driving.cc b/selfdrive/modeld/models/driving.cc new file mode 100644 index 00000000000000..ae4b7f9e903129 --- /dev/null +++ b/selfdrive/modeld/models/driving.cc @@ -0,0 +1,412 @@ + +#include +#include +#include +#include +#include + +#include "common/timing.h" +#include "common/params.h" +#include "driving.h" +#include "clutil.h" + +constexpr int MODEL_WIDTH = 512; +constexpr int MODEL_HEIGHT = 256; +constexpr int MODEL_FRAME_SIZE = MODEL_WIDTH * MODEL_HEIGHT * 3 / 2; + +constexpr int PLAN_MHP_N = 5; +constexpr int PLAN_MHP_COLUMNS = 30; +constexpr int PLAN_MHP_VALS = 30*33; +constexpr int PLAN_MHP_SELECTION = 1; +constexpr int PLAN_MHP_GROUP_SIZE = (2*PLAN_MHP_VALS + PLAN_MHP_SELECTION); + +constexpr int LEAD_MHP_N = 5; +constexpr int LEAD_MHP_VALS = 4; +constexpr int LEAD_MHP_SELECTION = 3; +constexpr int LEAD_MHP_GROUP_SIZE = (2*LEAD_MHP_VALS + LEAD_MHP_SELECTION); + +constexpr int POSE_SIZE = 12; + +constexpr int MIN_VALID_LEN = 10; +constexpr int TRAJECTORY_TIME = 10; +constexpr float TRAJECTORY_DISTANCE = 192.0; +constexpr int PLAN_IDX = 0; +constexpr int LL_IDX = PLAN_IDX + PLAN_MHP_N*PLAN_MHP_GROUP_SIZE; +constexpr int LL_PROB_IDX = LL_IDX + 4*2*2*33; +constexpr int RE_IDX = LL_PROB_IDX + 4; +constexpr int LEAD_IDX = RE_IDX + 2*2*2*33; +constexpr int LEAD_PROB_IDX = LEAD_IDX + LEAD_MHP_N*(LEAD_MHP_GROUP_SIZE); +constexpr int DESIRE_STATE_IDX = LEAD_PROB_IDX + 3; +constexpr int META_IDX = DESIRE_STATE_IDX + DESIRE_LEN; +constexpr int POSE_IDX = META_IDX + OTHER_META_SIZE + DESIRE_PRED_SIZE; +constexpr int OUTPUT_SIZE = POSE_IDX + POSE_SIZE; +#ifdef TEMPORAL + constexpr int TEMPORAL_SIZE = 512; +#else + constexpr int TEMPORAL_SIZE = 0; +#endif + +// #define DUMP_YUV + +Eigen::Matrix vander; +float X_IDXS[TRAJECTORY_SIZE]; +float T_IDXS[TRAJECTORY_SIZE]; + +void model_init(ModelState* s, cl_device_id device_id, cl_context context) { + frame_init(&s->frame, MODEL_WIDTH, MODEL_HEIGHT, device_id, context); + s->input_frames = std::make_unique(MODEL_FRAME_SIZE * 2); + + constexpr int output_size = OUTPUT_SIZE + TEMPORAL_SIZE; + s->output = std::make_unique(output_size); + s->m = std::make_unique("../../models/supercombo.dlc", &s->output[0], output_size, USE_GPU_RUNTIME); + +#ifdef TEMPORAL + s->m->addRecurrent(&s->output[OUTPUT_SIZE], TEMPORAL_SIZE); +#endif + +#ifdef DESIRE + s->m->addDesire(s->pulse_desire, DESIRE_LEN); +#endif + +#ifdef TRAFFIC_CONVENTION + const int idx = Params().read_db_bool("IsRHD") ? 1 : 0; + s->traffic_convention[idx] = 1.0; + s->m->addTrafficConvention(s->traffic_convention, TRAFFIC_CONVENTION_LEN); +#endif + + // Build Vandermonde matrix + for(int i = 0; i < TRAJECTORY_SIZE; i++) { + for(int j = 0; j < POLYFIT_DEGREE - 1; j++) { + X_IDXS[i] = (TRAJECTORY_DISTANCE/1024.0) * (pow(i,2)); + T_IDXS[i] = (TRAJECTORY_TIME/1024.0) * (pow(i,2)); + vander(i, j) = pow(X_IDXS[i], POLYFIT_DEGREE-j-1); + } + } + + s->q = CL_CHECK_ERR(clCreateCommandQueue(context, device_id, 0, &err)); +} + +ModelDataRaw model_eval_frame(ModelState* s, cl_mem yuv_cl, int width, int height, + const mat3 &transform, float *desire_in) { +#ifdef DESIRE + if (desire_in != NULL) { + for (int i = 1; i < DESIRE_LEN; i++) { + // Model decides when action is completed + // so desire input is just a pulse triggered on rising edge + if (desire_in[i] - s->prev_desire[i] > .99) { + s->pulse_desire[i] = desire_in[i]; + } else { + s->pulse_desire[i] = 0.0; + } + s->prev_desire[i] = desire_in[i]; + } + } +#endif + + //for (int i = 0; i < OUTPUT_SIZE + TEMPORAL_SIZE; i++) { printf("%f ", s->output[i]); } printf("\n"); + + float *new_frame_buf = frame_prepare(&s->frame, s->q, yuv_cl, width, height, transform); + memmove(&s->input_frames[0], &s->input_frames[MODEL_FRAME_SIZE], sizeof(float)*MODEL_FRAME_SIZE); + memmove(&s->input_frames[MODEL_FRAME_SIZE], new_frame_buf, sizeof(float)*MODEL_FRAME_SIZE); + s->m->execute(&s->input_frames[0], MODEL_FRAME_SIZE*2); + + #ifdef DUMP_YUV + FILE *dump_yuv_file = fopen("/sdcard/dump.yuv", "wb"); + fwrite(new_frame_buf, MODEL_HEIGHT*MODEL_WIDTH*3/2, sizeof(float), dump_yuv_file); + fclose(dump_yuv_file); + assert(1==2); + #endif + + clEnqueueUnmapMemObject(s->q, s->frame.net_input, (void*)new_frame_buf, 0, NULL, NULL); + + // net outputs + ModelDataRaw net_outputs; + net_outputs.plan = &s->output[PLAN_IDX]; + net_outputs.lane_lines = &s->output[LL_IDX]; + net_outputs.lane_lines_prob = &s->output[LL_PROB_IDX]; + net_outputs.road_edges = &s->output[RE_IDX]; + net_outputs.lead = &s->output[LEAD_IDX]; + net_outputs.lead_prob = &s->output[LEAD_PROB_IDX]; + net_outputs.meta = &s->output[DESIRE_STATE_IDX]; + net_outputs.pose = &s->output[POSE_IDX]; + return net_outputs; +} + +void model_free(ModelState* s) { + frame_free(&s->frame); + CL_CHECK(clReleaseCommandQueue(s->q)); +} + +void poly_fit(float *in_pts, float *in_stds, float *out, int valid_len) { + // References to inputs + Eigen::Map > pts(in_pts, valid_len); + Eigen::Map > std(in_stds, valid_len); + Eigen::Map > p(out, POLYFIT_DEGREE - 1); + + float y0 = pts[0]; + pts = pts.array() - y0; + + // Build Least Squares equations + Eigen::Matrix lhs = vander.topRows(valid_len).array().colwise() / std.array(); + Eigen::Matrix rhs = pts.array() / std.array(); + + // Improve numerical stability + Eigen::Matrix scale = 1. / (lhs.array()*lhs.array()).sqrt().colwise().sum(); + lhs = lhs * scale.asDiagonal(); + + // Solve inplace + p = lhs.colPivHouseholderQr().solve(rhs); + + // Apply scale to output + p = p.transpose() * scale.asDiagonal(); + out[3] = y0; +} + +static const float *get_best_data(const float *data, int size, int group_size, int offset) { + int max_idx = 0; + for (int i = 1; i < size; i++) { + if (data[(i + 1) * group_size + offset] > + data[(max_idx + 1) * group_size + offset]) { + max_idx = i; + } + } + return &data[max_idx * group_size]; +} + +static const float *get_plan_data(float *plan) { + return get_best_data(plan, PLAN_MHP_N, PLAN_MHP_GROUP_SIZE, -1); +} + +static const float *get_lead_data(const float *lead, int t_offset) { + return get_best_data(lead, LEAD_MHP_N, LEAD_MHP_GROUP_SIZE, t_offset - LEAD_MHP_SELECTION); +} + +void fill_path(cereal::ModelData::PathData::Builder path, const float *data, const float prob, + float valid_len, int valid_len_idx, int ll_idx) { + float points[TRAJECTORY_SIZE] = {}; + float stds[TRAJECTORY_SIZE] = {}; + float poly[POLYFIT_DEGREE] = {}; + + for (int i=0; i +void fill_meta(MetaBuilder meta, const float *meta_data) { + float desire_state_softmax[DESIRE_LEN]; + float desire_pred_softmax[4*DESIRE_LEN]; + softmax(&meta_data[0], desire_state_softmax, DESIRE_LEN); + for (int i=0; i<4; i++) { + softmax(&meta_data[DESIRE_LEN + OTHER_META_SIZE + i*DESIRE_LEN], + &desire_pred_softmax[i*DESIRE_LEN], DESIRE_LEN); + } + meta.setDesireState(desire_state_softmax); + meta.setEngagedProb(sigmoid(meta_data[DESIRE_LEN])); + meta.setGasDisengageProb(sigmoid(meta_data[DESIRE_LEN + 1])); + meta.setBrakeDisengageProb(sigmoid(meta_data[DESIRE_LEN + 2])); + meta.setSteerOverrideProb(sigmoid(meta_data[DESIRE_LEN + 3])); + meta.setDesirePrediction(desire_pred_softmax); +} + +void fill_xyzt(cereal::ModelDataV2::XYZTData::Builder xyzt, const float * data, + int columns, int column_offset, float * plan_t_arr) { + float x_arr[TRAJECTORY_SIZE] = {}; + float y_arr[TRAJECTORY_SIZE] = {}; + float z_arr[TRAJECTORY_SIZE] = {}; + //float x_std_arr[TRAJECTORY_SIZE]; + //float y_std_arr[TRAJECTORY_SIZE]; + //float z_std_arr[TRAJECTORY_SIZE]; + float t_arr[TRAJECTORY_SIZE]; + for (int i=0; i= 0) { + t_arr[i] = T_IDXS[i]; + x_arr[i] = data[i*columns + 0 + column_offset]; + //x_std_arr[i] = data[columns*(TRAJECTORY_SIZE + i) + 0 + column_offset]; + } else { + t_arr[i] = plan_t_arr[i]; + x_arr[i] = X_IDXS[i]; + //x_std_arr[i] = NAN; + } + y_arr[i] = data[i*columns + 1 + column_offset]; + //y_std_arr[i] = data[columns*(TRAJECTORY_SIZE + i) + 1 + column_offset]; + z_arr[i] = data[i*columns + 2 + column_offset]; + //z_std_arr[i] = data[columns*(TRAJECTORY_SIZE + i) + 2 + column_offset]; + } + //kj::ArrayPtr x_std(x_std_arr, TRAJECTORY_SIZE); + //kj::ArrayPtr y_std(y_std_arr, TRAJECTORY_SIZE); + //kj::ArrayPtr z_std(z_std_arr, TRAJECTORY_SIZE); + xyzt.setX(x_arr); + xyzt.setY(y_arr); + xyzt.setZ(z_arr); + //xyzt.setXStd(x_std); + //xyzt.setYStd(y_std); + //xyzt.setZStd(z_std); + xyzt.setT(t_arr); +} + +void fill_model(cereal::ModelDataV2::Builder &framed, const ModelDataRaw &net_outputs) { + // plan + const float *best_plan = get_plan_data(net_outputs.plan); + float plan_t_arr[TRAJECTORY_SIZE]; + for (int i=0; i= valid_len){ + valid_len = len; + } + } + // clamp to 10 and MODEL_PATH_DISTANCE + valid_len = fmin(MODEL_PATH_DISTANCE, fmax(MIN_VALID_LEN, valid_len)); + int valid_len_idx = 0; + for (int i=1; i= X_IDXS[valid_len_idx]){ + valid_len_idx = i; + } + } + fill_path(framed.initPath(), best_plan, 1.0, valid_len, valid_len_idx, 0); + fill_path(framed.initLeftLane(), net_outputs.lane_lines, sigmoid(net_outputs.lane_lines_prob[1]), valid_len, valid_len_idx, 1); + fill_path(framed.initRightLane(), net_outputs.lane_lines, sigmoid(net_outputs.lane_lines_prob[2]), valid_len, valid_len_idx, 2); + + fill_lead(framed.initLead(), net_outputs.lead, net_outputs.lead_prob, 0); + fill_lead(framed.initLeadFuture(), net_outputs.lead, net_outputs.lead_prob, 1); + + fill_meta(framed.initMeta(), net_outputs.meta); +} + +void model_publish(PubMaster &pm, uint32_t vipc_frame_id, uint32_t frame_id, float frame_drop, + const ModelDataRaw &net_outputs, const float *raw_pred, uint64_t timestamp_eof, + float model_execution_time) { + const uint32_t frame_age = (frame_id > vipc_frame_id) ? (frame_id - vipc_frame_id) : 0; + auto do_publish = [&](auto init_model_func, const char *pub_name) { + MessageBuilder msg; + auto framed = (msg.initEvent().*(init_model_func))(); + framed.setFrameId(vipc_frame_id); + framed.setFrameAge(frame_age); + framed.setFrameDropPerc(frame_drop * 100); + framed.setTimestampEof(timestamp_eof); + framed.setModelExecutionTime(model_execution_time); + if (send_raw_pred) { + framed.setRawPred(kj::arrayPtr((const uint8_t *)raw_pred, (OUTPUT_SIZE + TEMPORAL_SIZE) * sizeof(float))); + } + fill_model(framed, net_outputs); + pm.send(pub_name, msg); + }; + do_publish(&cereal::Event::Builder::initModel, "model"); + do_publish(&cereal::Event::Builder::initModelV2, "modelV2"); +} + +void posenet_publish(PubMaster &pm, uint32_t vipc_frame_id, uint32_t vipc_dropped_frames, + const ModelDataRaw &net_outputs, uint64_t timestamp_eof) { + float trans_arr[3]; + float trans_std_arr[3]; + float rot_arr[3]; + float rot_std_arr[3]; + + for (int i =0; i < 3; i++) { + trans_arr[i] = net_outputs.pose[i]; + trans_std_arr[i] = exp(net_outputs.pose[6 + i]); + + rot_arr[i] = net_outputs.pose[3 + i]; + rot_std_arr[i] = exp(net_outputs.pose[9 + i]); + } + + MessageBuilder msg; + auto posenetd = msg.initEvent(vipc_dropped_frames < 1).initCameraOdometry(); + posenetd.setTrans(trans_arr); + posenetd.setRot(rot_arr); + posenetd.setTransStd(trans_std_arr); + posenetd.setRotStd(rot_std_arr); + + posenetd.setTimestampEof(timestamp_eof); + posenetd.setFrameId(vipc_frame_id); + + pm.send("cameraOdometry", msg); +} diff --git a/selfdrive/modeld/models/driving.h b/selfdrive/modeld/models/driving.h new file mode 100644 index 00000000000000..c5891013b42616 --- /dev/null +++ b/selfdrive/modeld/models/driving.h @@ -0,0 +1,59 @@ +#pragma once + +// gate this here +#define TEMPORAL +#define DESIRE +#define TRAFFIC_CONVENTION + +#include "common/mat.h" +#include "common/util.h" +#include "common/modeldata.h" + +#include "commonmodel.h" +#include "runners/run.h" + +#include +#include "messaging.hpp" + +constexpr int DESIRE_LEN = 8; +constexpr int TRAFFIC_CONVENTION_LEN = 2; +constexpr int MODEL_FREQ = 20; +struct ModelDataRaw { + float *plan; + float *lane_lines; + float *lane_lines_prob; + float *road_edges; + float *lead; + float *lead_prob; + float *desire_state; + float *meta; + float *desire_pred; + float *pose; + }; + + +typedef struct ModelState { + ModelFrame frame; + std::unique_ptr output; + std::unique_ptr input_frames; + std::unique_ptr m; + cl_command_queue q; +#ifdef DESIRE + float prev_desire[DESIRE_LEN] = {}; + float pulse_desire[DESIRE_LEN] = {}; +#endif +#ifdef TRAFFIC_CONVENTION + float traffic_convention[TRAFFIC_CONVENTION_LEN] = {}; +#endif +} ModelState; + +void model_init(ModelState* s, cl_device_id device_id, cl_context context); +ModelDataRaw model_eval_frame(ModelState* s, cl_mem yuv_cl, int width, int height, + const mat3 &transform, float *desire_in); +void model_free(ModelState* s); +void poly_fit(float *in_pts, float *in_stds, float *out); +void model_publish(PubMaster &pm, uint32_t vipc_frame_id, uint32_t frame_id, float frame_drop, + const ModelDataRaw &net_outputs, const float *raw_pred, uint64_t timestamp_eof, + float model_execution_time); +void posenet_publish(PubMaster &pm, uint32_t vipc_frame_id, uint32_t vipc_dropped_frames, + const ModelDataRaw &net_outputs, uint64_t timestamp_eof); diff --git a/selfdrive/modeld/runners/run.h b/selfdrive/modeld/runners/run.h new file mode 100644 index 00000000000000..dea340a0afa41c --- /dev/null +++ b/selfdrive/modeld/runners/run.h @@ -0,0 +1,18 @@ +#ifndef RUN_H +#define RUN_H + +#include "runmodel.h" +#include "snpemodel.h" + +#ifdef QCOM + #define DefaultRunModel SNPEModel +#else + #ifdef USE_ONNX_MODEL + #include "onnxmodel.h" + #define DefaultRunModel ONNXModel + #else + #define DefaultRunModel SNPEModel + #endif +#endif + +#endif diff --git a/selfdrive/modeld/runners/runmodel.h b/selfdrive/modeld/runners/runmodel.h new file mode 100644 index 00000000000000..d3889aaaabc162 --- /dev/null +++ b/selfdrive/modeld/runners/runmodel.h @@ -0,0 +1,13 @@ +#ifndef RUNMODEL_H +#define RUNMODEL_H + +class RunModel { +public: + virtual void addRecurrent(float *state, int state_size) {} + virtual void addDesire(float *state, int state_size) {} + virtual void addTrafficConvention(float *state, int state_size) {} + virtual void execute(float *net_input_buf, int buf_size) {} +}; + +#endif + diff --git a/selfdrive/modeld/runners/snpemodel.cc b/selfdrive/modeld/runners/snpemodel.cc new file mode 100644 index 00000000000000..2197c24cd41257 --- /dev/null +++ b/selfdrive/modeld/runners/snpemodel.cc @@ -0,0 +1,184 @@ +#pragma clang diagnostic ignored "-Wexceptions" + +#include +#include +#include +#include "common/util.h" +#include "snpemodel.h" + +void PrintErrorStringAndExit() { + std::cerr << zdl::DlSystem::getLastErrorString() << std::endl; + std::exit(EXIT_FAILURE); +} + +SNPEModel::SNPEModel(const char *path, float *loutput, size_t loutput_size, int runtime) { + output = loutput; + output_size = loutput_size; +#if defined(QCOM) || defined(QCOM2) + if (runtime==USE_GPU_RUNTIME) { + Runtime = zdl::DlSystem::Runtime_t::GPU; + } else if (runtime==USE_DSP_RUNTIME) { + Runtime = zdl::DlSystem::Runtime_t::DSP; + } else { + Runtime = zdl::DlSystem::Runtime_t::CPU; + } + assert(zdl::SNPE::SNPEFactory::isRuntimeAvailable(Runtime)); +#endif + size_t model_size; + model_data = (uint8_t *)read_file(path, &model_size); + assert(model_data); + + // load model + std::unique_ptr container = zdl::DlContainer::IDlContainer::open(model_data, model_size); + if (!container) { PrintErrorStringAndExit(); } + printf("loaded model with size: %lu\n", model_size); + + // create model runner + zdl::SNPE::SNPEBuilder snpeBuilder(container.get()); + while (!snpe) { +#if defined(QCOM) || defined(QCOM2) + snpe = snpeBuilder.setOutputLayers({}) + .setRuntimeProcessor(Runtime) + .setUseUserSuppliedBuffers(true) + .setPerformanceProfile(zdl::DlSystem::PerformanceProfile_t::HIGH_PERFORMANCE) + .build(); +#else + snpe = snpeBuilder.setOutputLayers({}) + .setUseUserSuppliedBuffers(true) + .setPerformanceProfile(zdl::DlSystem::PerformanceProfile_t::HIGH_PERFORMANCE) + .build(); +#endif + if (!snpe) std::cerr << zdl::DlSystem::getLastErrorString() << std::endl; + } + + // get input and output names + const auto &strListi_opt = snpe->getInputTensorNames(); + if (!strListi_opt) throw std::runtime_error("Error obtaining Input tensor names"); + const auto &strListi = *strListi_opt; + //assert(strListi.size() == 1); + const char *input_tensor_name = strListi.at(0); + + const auto &strListo_opt = snpe->getOutputTensorNames(); + if (!strListo_opt) throw std::runtime_error("Error obtaining Output tensor names"); + const auto &strListo = *strListo_opt; + assert(strListo.size() == 1); + const char *output_tensor_name = strListo.at(0); + + printf("model: %s -> %s\n", input_tensor_name, output_tensor_name); + + zdl::DlSystem::UserBufferEncodingFloat userBufferEncodingFloat; + zdl::DlSystem::IUserBufferFactory& ubFactory = zdl::SNPE::SNPEFactory::getUserBufferFactory(); + + // create input buffer + { + const auto &inputDims_opt = snpe->getInputDimensions(input_tensor_name); + const zdl::DlSystem::TensorShape& bufferShape = *inputDims_opt; + std::vector strides(bufferShape.rank()); + strides[strides.size() - 1] = sizeof(float); + size_t product = 1; + for (size_t i = 0; i < bufferShape.rank(); i++) product *= bufferShape[i]; + size_t stride = strides[strides.size() - 1]; + for (size_t i = bufferShape.rank() - 1; i > 0; i--) { + stride *= bufferShape[i]; + strides[i-1] = stride; + } + printf("input product is %lu\n", product); + inputBuffer = ubFactory.createUserBuffer(NULL, product*sizeof(float), strides, &userBufferEncodingFloat); + + inputMap.add(input_tensor_name, inputBuffer.get()); + } + + // create output buffer + { + const zdl::DlSystem::TensorShape& bufferShape = snpe->getInputOutputBufferAttributes(output_tensor_name)->getDims(); + if (output_size != 0) { + assert(output_size == bufferShape[1]); + } else { + output_size = bufferShape[1]; + } + + std::vector outputStrides = {output_size * sizeof(float), sizeof(float)}; + outputBuffer = ubFactory.createUserBuffer(output, output_size * sizeof(float), outputStrides, &userBufferEncodingFloat); + outputMap.add(output_tensor_name, outputBuffer.get()); + } +} + +void SNPEModel::addRecurrent(float *state, int state_size) { + recurrent = state; + recurrent_size = state_size; + recurrentBuffer = this->addExtra(state, state_size, 3); +} + +void SNPEModel::addTrafficConvention(float *state, int state_size) { + trafficConvention = state; + trafficConventionBuffer = this->addExtra(state, state_size, 2); +} + +void SNPEModel::addDesire(float *state, int state_size) { + desire = state; + desireBuffer = this->addExtra(state, state_size, 1); +} + +std::unique_ptr SNPEModel::addExtra(float *state, int state_size, int idx) { + // get input and output names + const auto &strListi_opt = snpe->getInputTensorNames(); + if (!strListi_opt) throw std::runtime_error("Error obtaining Input tensor names"); + const auto &strListi = *strListi_opt; + const char *input_tensor_name = strListi.at(idx); + printf("adding index %d: %s\n", idx, input_tensor_name); + + zdl::DlSystem::UserBufferEncodingFloat userBufferEncodingFloat; + zdl::DlSystem::IUserBufferFactory& ubFactory = zdl::SNPE::SNPEFactory::getUserBufferFactory(); + std::vector retStrides = {state_size * sizeof(float), sizeof(float)}; + auto ret = ubFactory.createUserBuffer(state, state_size * sizeof(float), retStrides, &userBufferEncodingFloat); + inputMap.add(input_tensor_name, ret.get()); + return ret; +} + +void SNPEModel::execute(float *net_input_buf, int buf_size) { +#ifdef USE_THNEED + if (Runtime == zdl::DlSystem::Runtime_t::GPU) { + float *inputs[4] = {recurrent, trafficConvention, desire, net_input_buf}; + if (thneed == NULL) { + assert(inputBuffer->setBufferAddress(net_input_buf)); + if (!snpe->execute(inputMap, outputMap)) { + PrintErrorStringAndExit(); + } + memset(recurrent, 0, recurrent_size*sizeof(float)); + thneed = new Thneed(); + if (!snpe->execute(inputMap, outputMap)) { + PrintErrorStringAndExit(); + } + thneed->stop(); + printf("thneed cached\n"); + + // doing self test + float *outputs_golden = (float *)malloc(output_size*sizeof(float)); + memcpy(outputs_golden, output, output_size*sizeof(float)); + memset(output, 0, output_size*sizeof(float)); + memset(recurrent, 0, recurrent_size*sizeof(float)); + thneed->execute(inputs, output); + + if (memcmp(output, outputs_golden, output_size*sizeof(float)) == 0) { + printf("thneed selftest passed\n"); + } else { + for (int i = 0; i < output_size; i++) { + printf("mismatch %3d: %f %f\n", i, output[i], outputs_golden[i]); + } + assert(false); + } + free(outputs_golden); + } else { + thneed->execute(inputs, output); + } + } else { +#endif + assert(inputBuffer->setBufferAddress(net_input_buf)); + if (!snpe->execute(inputMap, outputMap)) { + PrintErrorStringAndExit(); + } +#ifdef USE_THNEED + } +#endif +} + diff --git a/selfdrive/modeld/runners/snpemodel.h b/selfdrive/modeld/runners/snpemodel.h new file mode 100644 index 00000000000000..90c26664f62bc0 --- /dev/null +++ b/selfdrive/modeld/runners/snpemodel.h @@ -0,0 +1,70 @@ +#ifndef SNPEMODEL_H +#define SNPEMODEL_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "runmodel.h" + +#define USE_CPU_RUNTIME 0 +#define USE_GPU_RUNTIME 1 +#define USE_DSP_RUNTIME 2 + +#ifdef USE_THNEED +#include "thneed/thneed.h" +#endif + +class SNPEModel : public RunModel { +public: + SNPEModel(const char *path, float *loutput, size_t loutput_size, int runtime); + ~SNPEModel() { + if (model_data) free(model_data); + } + void addRecurrent(float *state, int state_size); + void addTrafficConvention(float *state, int state_size); + void addDesire(float *state, int state_size); + void execute(float *net_input_buf, int buf_size); +private: + uint8_t *model_data = NULL; + +#ifdef USE_THNEED + Thneed *thneed = NULL; +#endif + +#if defined(QCOM) || defined(QCOM2) + zdl::DlSystem::Runtime_t Runtime; +#endif + + // snpe model stuff + std::unique_ptr snpe; + + // snpe input stuff + zdl::DlSystem::UserBufferMap inputMap; + std::unique_ptr inputBuffer; + + // snpe output stuff + zdl::DlSystem::UserBufferMap outputMap; + std::unique_ptr outputBuffer; + float *output; + size_t output_size; + + // recurrent and desire + std::unique_ptr addExtra(float *state, int state_size, int idx); + float *recurrent; + size_t recurrent_size; + std::unique_ptr recurrentBuffer; + float *trafficConvention; + std::unique_ptr trafficConventionBuffer; + float *desire; + std::unique_ptr desireBuffer; +}; + +#endif + diff --git a/selfdrive/modeld/thneed/include/msm_kgsl.h b/selfdrive/modeld/thneed/include/msm_kgsl.h new file mode 100644 index 00000000000000..93582eb066db77 --- /dev/null +++ b/selfdrive/modeld/thneed/include/msm_kgsl.h @@ -0,0 +1,1449 @@ +#ifndef _UAPI_MSM_KGSL_H +#define _UAPI_MSM_KGSL_H + +#include +#include + +/* + * The KGSL version has proven not to be very useful in userspace if features + * are cherry picked into other trees out of order so it is frozen as of 3.14. + * It is left here for backwards compatabilty and as a reminder that + * software releases are never linear. Also, I like pie. + */ + +#define KGSL_VERSION_MAJOR 3 +#define KGSL_VERSION_MINOR 14 + +/* + * We have traditionally mixed context and issueibcmds / command batch flags + * together into a big flag stew. This worked fine until we started adding a + * lot more command batch flags and we started running out of bits. Turns out + * we have a bit of room in the context type / priority mask that we could use + * for command batches, but that means we need to split out the flags into two + * coherent sets. + * + * If any future definitions are for both context and cmdbatch add both defines + * and link the cmdbatch to the context define as we do below. Otherwise feel + * free to add exclusive bits to either set. + */ + +/* --- context flags --- */ +#define KGSL_CONTEXT_SAVE_GMEM 0x00000001 +#define KGSL_CONTEXT_NO_GMEM_ALLOC 0x00000002 +/* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */ +#define KGSL_CONTEXT_SUBMIT_IB_LIST 0x00000004 +#define KGSL_CONTEXT_CTX_SWITCH 0x00000008 +#define KGSL_CONTEXT_PREAMBLE 0x00000010 +#define KGSL_CONTEXT_TRASH_STATE 0x00000020 +#define KGSL_CONTEXT_PER_CONTEXT_TS 0x00000040 +#define KGSL_CONTEXT_USER_GENERATED_TS 0x00000080 +/* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */ +#define KGSL_CONTEXT_END_OF_FRAME 0x00000100 +#define KGSL_CONTEXT_NO_FAULT_TOLERANCE 0x00000200 +/* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */ +#define KGSL_CONTEXT_SYNC 0x00000400 +#define KGSL_CONTEXT_PWR_CONSTRAINT 0x00000800 + +#define KGSL_CONTEXT_PRIORITY_MASK 0x0000F000 +#define KGSL_CONTEXT_PRIORITY_SHIFT 12 +#define KGSL_CONTEXT_PRIORITY_UNDEF 0 + +#define KGSL_CONTEXT_IFH_NOP 0x00010000 +#define KGSL_CONTEXT_SECURE 0x00020000 + +#define KGSL_CONTEXT_PREEMPT_STYLE_MASK 0x0E000000 +#define KGSL_CONTEXT_PREEMPT_STYLE_SHIFT 25 +#define KGSL_CONTEXT_PREEMPT_STYLE_DEFAULT 0x0 +#define KGSL_CONTEXT_PREEMPT_STYLE_RINGBUFFER 0x1 +#define KGSL_CONTEXT_PREEMPT_STYLE_FINEGRAIN 0x2 + +#define KGSL_CONTEXT_TYPE_MASK 0x01F00000 +#define KGSL_CONTEXT_TYPE_SHIFT 20 +#define KGSL_CONTEXT_TYPE_ANY 0 +#define KGSL_CONTEXT_TYPE_GL 1 +#define KGSL_CONTEXT_TYPE_CL 2 +#define KGSL_CONTEXT_TYPE_C2D 3 +#define KGSL_CONTEXT_TYPE_RS 4 +#define KGSL_CONTEXT_TYPE_UNKNOWN 0x1E + +#define KGSL_CONTEXT_INVALID 0xffffffff + +/* + * --- command batch flags --- + * The bits that are linked to a KGSL_CONTEXT equivalent are either legacy + * definitions or bits that are valid for both contexts and cmdbatches. To be + * safe the other 8 bits that are still available in the context field should be + * omitted here in case we need to share - the other bits are available for + * cmdbatch only flags as needed + */ +#define KGSL_CMDBATCH_MEMLIST 0x00000001 +#define KGSL_CMDBATCH_MARKER 0x00000002 +#define KGSL_CMDBATCH_SUBMIT_IB_LIST KGSL_CONTEXT_SUBMIT_IB_LIST /* 0x004 */ +#define KGSL_CMDBATCH_CTX_SWITCH KGSL_CONTEXT_CTX_SWITCH /* 0x008 */ +#define KGSL_CMDBATCH_PROFILING 0x00000010 +#define KGSL_CMDBATCH_PROFILING_KTIME 0x00000020 +#define KGSL_CMDBATCH_END_OF_FRAME KGSL_CONTEXT_END_OF_FRAME /* 0x100 */ +#define KGSL_CMDBATCH_SYNC KGSL_CONTEXT_SYNC /* 0x400 */ +#define KGSL_CMDBATCH_PWR_CONSTRAINT KGSL_CONTEXT_PWR_CONSTRAINT /* 0x800 */ + +/* + * Reserve bits [16:19] and bits [28:31] for possible bits shared between + * contexts and command batches. Update this comment as new flags are added. + */ + +/* + * gpu_command_object flags - these flags communicate the type of command or + * memory object being submitted for a GPU command + */ + +/* Flags for GPU command objects */ +#define KGSL_CMDLIST_IB 0x00000001U +#define KGSL_CMDLIST_CTXTSWITCH_PREAMBLE 0x00000002U +#define KGSL_CMDLIST_IB_PREAMBLE 0x00000004U + +/* Flags for GPU command memory objects */ +#define KGSL_OBJLIST_MEMOBJ 0x00000008U +#define KGSL_OBJLIST_PROFILE 0x00000010U + +/* Flags for GPU command sync points */ +#define KGSL_CMD_SYNCPOINT_TYPE_TIMESTAMP 0 +#define KGSL_CMD_SYNCPOINT_TYPE_FENCE 1 + +/* --- Memory allocation flags --- */ + +/* General allocation hints */ +#define KGSL_MEMFLAGS_SECURE 0x00000008ULL +#define KGSL_MEMFLAGS_GPUREADONLY 0x01000000U +#define KGSL_MEMFLAGS_GPUWRITEONLY 0x02000000U +#define KGSL_MEMFLAGS_FORCE_32BIT 0x100000000ULL + +/* Memory caching hints */ +#define KGSL_CACHEMODE_MASK 0x0C000000U +#define KGSL_CACHEMODE_SHIFT 26 + +#define KGSL_CACHEMODE_WRITECOMBINE 0 +#define KGSL_CACHEMODE_UNCACHED 1 +#define KGSL_CACHEMODE_WRITETHROUGH 2 +#define KGSL_CACHEMODE_WRITEBACK 3 + +#define KGSL_MEMFLAGS_USE_CPU_MAP 0x10000000ULL + +/* Memory types for which allocations are made */ +#define KGSL_MEMTYPE_MASK 0x0000FF00 +#define KGSL_MEMTYPE_SHIFT 8 + +#define KGSL_MEMTYPE_OBJECTANY 0 +#define KGSL_MEMTYPE_FRAMEBUFFER 1 +#define KGSL_MEMTYPE_RENDERBUFFER 2 +#define KGSL_MEMTYPE_ARRAYBUFFER 3 +#define KGSL_MEMTYPE_ELEMENTARRAYBUFFER 4 +#define KGSL_MEMTYPE_VERTEXARRAYBUFFER 5 +#define KGSL_MEMTYPE_TEXTURE 6 +#define KGSL_MEMTYPE_SURFACE 7 +#define KGSL_MEMTYPE_EGL_SURFACE 8 +#define KGSL_MEMTYPE_GL 9 +#define KGSL_MEMTYPE_CL 10 +#define KGSL_MEMTYPE_CL_BUFFER_MAP 11 +#define KGSL_MEMTYPE_CL_BUFFER_NOMAP 12 +#define KGSL_MEMTYPE_CL_IMAGE_MAP 13 +#define KGSL_MEMTYPE_CL_IMAGE_NOMAP 14 +#define KGSL_MEMTYPE_CL_KERNEL_STACK 15 +#define KGSL_MEMTYPE_COMMAND 16 +#define KGSL_MEMTYPE_2D 17 +#define KGSL_MEMTYPE_EGL_IMAGE 18 +#define KGSL_MEMTYPE_EGL_SHADOW 19 +#define KGSL_MEMTYPE_MULTISAMPLE 20 +#define KGSL_MEMTYPE_KERNEL 255 + +/* + * Alignment hint, passed as the power of 2 exponent. + * i.e 4k (2^12) would be 12, 64k (2^16)would be 16. + */ +#define KGSL_MEMALIGN_MASK 0x00FF0000 +#define KGSL_MEMALIGN_SHIFT 16 + +enum kgsl_user_mem_type { + KGSL_USER_MEM_TYPE_PMEM = 0x00000000, + KGSL_USER_MEM_TYPE_ASHMEM = 0x00000001, + KGSL_USER_MEM_TYPE_ADDR = 0x00000002, + KGSL_USER_MEM_TYPE_ION = 0x00000003, + /* + * ION type is retained for backwards compatibilty but Ion buffers are + * dma-bufs so try to use that naming if we can + */ + KGSL_USER_MEM_TYPE_DMABUF = 0x00000003, + KGSL_USER_MEM_TYPE_MAX = 0x00000007, +}; +#define KGSL_MEMFLAGS_USERMEM_MASK 0x000000e0 +#define KGSL_MEMFLAGS_USERMEM_SHIFT 5 + +/* + * Unfortunately, enum kgsl_user_mem_type starts at 0 which does not + * leave a good value for allocated memory. In the flags we use + * 0 to indicate allocated memory and thus need to add 1 to the enum + * values. + */ +#define KGSL_USERMEM_FLAG(x) (((x) + 1) << KGSL_MEMFLAGS_USERMEM_SHIFT) + +#define KGSL_MEMFLAGS_NOT_USERMEM 0 +#define KGSL_MEMFLAGS_USERMEM_PMEM KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_PMEM) +#define KGSL_MEMFLAGS_USERMEM_ASHMEM \ + KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_ASHMEM) +#define KGSL_MEMFLAGS_USERMEM_ADDR KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_ADDR) +#define KGSL_MEMFLAGS_USERMEM_ION KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_ION) + +/* --- generic KGSL flag values --- */ + +#define KGSL_FLAGS_NORMALMODE 0x00000000 +#define KGSL_FLAGS_SAFEMODE 0x00000001 +#define KGSL_FLAGS_INITIALIZED0 0x00000002 +#define KGSL_FLAGS_INITIALIZED 0x00000004 +#define KGSL_FLAGS_STARTED 0x00000008 +#define KGSL_FLAGS_ACTIVE 0x00000010 +#define KGSL_FLAGS_RESERVED0 0x00000020 +#define KGSL_FLAGS_RESERVED1 0x00000040 +#define KGSL_FLAGS_RESERVED2 0x00000080 +#define KGSL_FLAGS_SOFT_RESET 0x00000100 +#define KGSL_FLAGS_PER_CONTEXT_TIMESTAMPS 0x00000200 + +/* Server Side Sync Timeout in milliseconds */ +#define KGSL_SYNCOBJ_SERVER_TIMEOUT 2000 + +/* + * Reset status values for context + */ +enum kgsl_ctx_reset_stat { + KGSL_CTX_STAT_NO_ERROR = 0x00000000, + KGSL_CTX_STAT_GUILTY_CONTEXT_RESET_EXT = 0x00000001, + KGSL_CTX_STAT_INNOCENT_CONTEXT_RESET_EXT = 0x00000002, + KGSL_CTX_STAT_UNKNOWN_CONTEXT_RESET_EXT = 0x00000003 +}; + +#define KGSL_CONVERT_TO_MBPS(val) \ + (val*1000*1000U) + +/* device id */ +enum kgsl_deviceid { + KGSL_DEVICE_3D0 = 0x00000000, + KGSL_DEVICE_MAX +}; + +struct kgsl_devinfo { + + unsigned int device_id; + /* chip revision id + * coreid:8 majorrev:8 minorrev:8 patch:8 + */ + unsigned int chip_id; + unsigned int mmu_enabled; + unsigned long gmem_gpubaseaddr; + /* + * This field contains the adreno revision + * number 200, 205, 220, etc... + */ + unsigned int gpu_id; + size_t gmem_sizebytes; +}; + +/* + * struct kgsl_devmemstore - this structure defines the region of memory + * that can be mmap()ed from this driver. The timestamp fields are volatile + * because they are written by the GPU + * @soptimestamp: Start of pipeline timestamp written by GPU before the + * commands in concern are processed + * @sbz: Unused, kept for 8 byte alignment + * @eoptimestamp: End of pipeline timestamp written by GPU after the + * commands in concern are processed + * @sbz2: Unused, kept for 8 byte alignment + * @preempted: Indicates if the context was preempted + * @sbz3: Unused, kept for 8 byte alignment + * @ref_wait_ts: Timestamp on which to generate interrupt, unused now. + * @sbz4: Unused, kept for 8 byte alignment + * @current_context: The current context the GPU is working on + * @sbz5: Unused, kept for 8 byte alignment + */ +struct kgsl_devmemstore { + volatile unsigned int soptimestamp; + unsigned int sbz; + volatile unsigned int eoptimestamp; + unsigned int sbz2; + volatile unsigned int preempted; + unsigned int sbz3; + volatile unsigned int ref_wait_ts; + unsigned int sbz4; + unsigned int current_context; + unsigned int sbz5; +}; + +#define KGSL_MEMSTORE_OFFSET(ctxt_id, field) \ + ((ctxt_id)*sizeof(struct kgsl_devmemstore) + \ + offsetof(struct kgsl_devmemstore, field)) + +/* timestamp id*/ +enum kgsl_timestamp_type { + KGSL_TIMESTAMP_CONSUMED = 0x00000001, /* start-of-pipeline timestamp */ + KGSL_TIMESTAMP_RETIRED = 0x00000002, /* end-of-pipeline timestamp*/ + KGSL_TIMESTAMP_QUEUED = 0x00000003, +}; + +/* property types - used with kgsl_device_getproperty */ +#define KGSL_PROP_DEVICE_INFO 0x1 +#define KGSL_PROP_DEVICE_SHADOW 0x2 +#define KGSL_PROP_DEVICE_POWER 0x3 +#define KGSL_PROP_SHMEM 0x4 +#define KGSL_PROP_SHMEM_APERTURES 0x5 +#define KGSL_PROP_MMU_ENABLE 0x6 +#define KGSL_PROP_INTERRUPT_WAITS 0x7 +#define KGSL_PROP_VERSION 0x8 +#define KGSL_PROP_GPU_RESET_STAT 0x9 +#define KGSL_PROP_PWRCTRL 0xE +#define KGSL_PROP_PWR_CONSTRAINT 0x12 +#define KGSL_PROP_UCHE_GMEM_VADDR 0x13 +#define KGSL_PROP_SP_GENERIC_MEM 0x14 +#define KGSL_PROP_UCODE_VERSION 0x15 +#define KGSL_PROP_GPMU_VERSION 0x16 +#define KGSL_PROP_DEVICE_BITNESS 0x18 + +struct kgsl_shadowprop { + unsigned long gpuaddr; + size_t size; + unsigned int flags; /* contains KGSL_FLAGS_ values */ +}; + +struct kgsl_version { + unsigned int drv_major; + unsigned int drv_minor; + unsigned int dev_major; + unsigned int dev_minor; +}; + +struct kgsl_sp_generic_mem { + uint64_t local; + uint64_t pvt; +}; + +struct kgsl_ucode_version { + unsigned int pfp; + unsigned int pm4; +}; + +struct kgsl_gpmu_version { + unsigned int major; + unsigned int minor; + unsigned int features; +}; + +/* Performance counter groups */ + +#define KGSL_PERFCOUNTER_GROUP_CP 0x0 +#define KGSL_PERFCOUNTER_GROUP_RBBM 0x1 +#define KGSL_PERFCOUNTER_GROUP_PC 0x2 +#define KGSL_PERFCOUNTER_GROUP_VFD 0x3 +#define KGSL_PERFCOUNTER_GROUP_HLSQ 0x4 +#define KGSL_PERFCOUNTER_GROUP_VPC 0x5 +#define KGSL_PERFCOUNTER_GROUP_TSE 0x6 +#define KGSL_PERFCOUNTER_GROUP_RAS 0x7 +#define KGSL_PERFCOUNTER_GROUP_UCHE 0x8 +#define KGSL_PERFCOUNTER_GROUP_TP 0x9 +#define KGSL_PERFCOUNTER_GROUP_SP 0xA +#define KGSL_PERFCOUNTER_GROUP_RB 0xB +#define KGSL_PERFCOUNTER_GROUP_PWR 0xC +#define KGSL_PERFCOUNTER_GROUP_VBIF 0xD +#define KGSL_PERFCOUNTER_GROUP_VBIF_PWR 0xE +#define KGSL_PERFCOUNTER_GROUP_MH 0xF +#define KGSL_PERFCOUNTER_GROUP_PA_SU 0x10 +#define KGSL_PERFCOUNTER_GROUP_SQ 0x11 +#define KGSL_PERFCOUNTER_GROUP_SX 0x12 +#define KGSL_PERFCOUNTER_GROUP_TCF 0x13 +#define KGSL_PERFCOUNTER_GROUP_TCM 0x14 +#define KGSL_PERFCOUNTER_GROUP_TCR 0x15 +#define KGSL_PERFCOUNTER_GROUP_L2 0x16 +#define KGSL_PERFCOUNTER_GROUP_VSC 0x17 +#define KGSL_PERFCOUNTER_GROUP_CCU 0x18 +#define KGSL_PERFCOUNTER_GROUP_LRZ 0x19 +#define KGSL_PERFCOUNTER_GROUP_CMP 0x1A +#define KGSL_PERFCOUNTER_GROUP_ALWAYSON 0x1B +#define KGSL_PERFCOUNTER_GROUP_SP_PWR 0x1C +#define KGSL_PERFCOUNTER_GROUP_TP_PWR 0x1D +#define KGSL_PERFCOUNTER_GROUP_RB_PWR 0x1E +#define KGSL_PERFCOUNTER_GROUP_CCU_PWR 0x1F +#define KGSL_PERFCOUNTER_GROUP_UCHE_PWR 0x20 +#define KGSL_PERFCOUNTER_GROUP_CP_PWR 0x21 +#define KGSL_PERFCOUNTER_GROUP_GPMU_PWR 0x22 +#define KGSL_PERFCOUNTER_GROUP_ALWAYSON_PWR 0x23 +#define KGSL_PERFCOUNTER_GROUP_MAX 0x24 + +#define KGSL_PERFCOUNTER_NOT_USED 0xFFFFFFFF +#define KGSL_PERFCOUNTER_BROKEN 0xFFFFFFFE + +/* structure holds list of ibs */ +struct kgsl_ibdesc { + unsigned long gpuaddr; + unsigned long __pad; + size_t sizedwords; + unsigned int ctrl; +}; + +/** + * struct kgsl_cmdbatch_profiling_buffer + * @wall_clock_s: Ringbuffer submission time (seconds). + * If KGSL_CMDBATCH_PROFILING_KTIME is set, time is provided + * in kernel clocks, otherwise wall clock time is used. + * @wall_clock_ns: Ringbuffer submission time (nanoseconds). + * If KGSL_CMDBATCH_PROFILING_KTIME is set time is provided + * in kernel clocks, otherwise wall clock time is used. + * @gpu_ticks_queued: GPU ticks at ringbuffer submission + * @gpu_ticks_submitted: GPU ticks when starting cmdbatch execution + * @gpu_ticks_retired: GPU ticks when finishing cmdbatch execution + * + * This structure defines the profiling buffer used to measure cmdbatch + * execution time + */ +struct kgsl_cmdbatch_profiling_buffer { + uint64_t wall_clock_s; + uint64_t wall_clock_ns; + uint64_t gpu_ticks_queued; + uint64_t gpu_ticks_submitted; + uint64_t gpu_ticks_retired; +}; + +/* ioctls */ +#define KGSL_IOC_TYPE 0x09 + +/* get misc info about the GPU + type should be a value from enum kgsl_property_type + value points to a structure that varies based on type + sizebytes is sizeof() that structure + for KGSL_PROP_DEVICE_INFO, use struct kgsl_devinfo + this structure contaings hardware versioning info. + for KGSL_PROP_DEVICE_SHADOW, use struct kgsl_shadowprop + this is used to find mmap() offset and sizes for mapping + struct kgsl_memstore into userspace. +*/ +struct kgsl_device_getproperty { + unsigned int type; + void __user *value; + size_t sizebytes; +}; + +#define IOCTL_KGSL_DEVICE_GETPROPERTY \ + _IOWR(KGSL_IOC_TYPE, 0x2, struct kgsl_device_getproperty) + +/* IOCTL_KGSL_DEVICE_READ (0x3) - removed 03/2012 + */ + +/* block until the GPU has executed past a given timestamp + * timeout is in milliseconds. + */ +struct kgsl_device_waittimestamp { + unsigned int timestamp; + unsigned int timeout; +}; + +#define IOCTL_KGSL_DEVICE_WAITTIMESTAMP \ + _IOW(KGSL_IOC_TYPE, 0x6, struct kgsl_device_waittimestamp) + +struct kgsl_device_waittimestamp_ctxtid { + unsigned int context_id; + unsigned int timestamp; + unsigned int timeout; +}; + +#define IOCTL_KGSL_DEVICE_WAITTIMESTAMP_CTXTID \ + _IOW(KGSL_IOC_TYPE, 0x7, struct kgsl_device_waittimestamp_ctxtid) + +/* DEPRECATED: issue indirect commands to the GPU. + * drawctxt_id must have been created with IOCTL_KGSL_DRAWCTXT_CREATE + * ibaddr and sizedwords must specify a subset of a buffer created + * with IOCTL_KGSL_SHAREDMEM_FROM_PMEM + * flags may be a mask of KGSL_CONTEXT_ values + * timestamp is a returned counter value which can be passed to + * other ioctls to determine when the commands have been executed by + * the GPU. + * + * This fucntion is deprecated - consider using IOCTL_KGSL_SUBMIT_COMMANDS + * instead + */ +struct kgsl_ringbuffer_issueibcmds { + unsigned int drawctxt_id; + unsigned long ibdesc_addr; + unsigned int numibs; + unsigned int timestamp; /*output param */ + unsigned int flags; +}; + +#define IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS \ + _IOWR(KGSL_IOC_TYPE, 0x10, struct kgsl_ringbuffer_issueibcmds) + +/* read the most recently executed timestamp value + * type should be a value from enum kgsl_timestamp_type + */ +struct kgsl_cmdstream_readtimestamp { + unsigned int type; + unsigned int timestamp; /*output param */ +}; + +#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP_OLD \ + _IOR(KGSL_IOC_TYPE, 0x11, struct kgsl_cmdstream_readtimestamp) + +#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP \ + _IOWR(KGSL_IOC_TYPE, 0x11, struct kgsl_cmdstream_readtimestamp) + +/* free memory when the GPU reaches a given timestamp. + * gpuaddr specify a memory region created by a + * IOCTL_KGSL_SHAREDMEM_FROM_PMEM call + * type should be a value from enum kgsl_timestamp_type + */ +struct kgsl_cmdstream_freememontimestamp { + unsigned long gpuaddr; + unsigned int type; + unsigned int timestamp; +}; + +#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP \ + _IOW(KGSL_IOC_TYPE, 0x12, struct kgsl_cmdstream_freememontimestamp) + +/* Previous versions of this header had incorrectly defined + IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP as a read-only ioctl instead + of a write only ioctl. To ensure binary compatability, the following + #define will be used to intercept the incorrect ioctl +*/ + +#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP_OLD \ + _IOR(KGSL_IOC_TYPE, 0x12, struct kgsl_cmdstream_freememontimestamp) + +/* create a draw context, which is used to preserve GPU state. + * The flags field may contain a mask KGSL_CONTEXT_* values + */ +struct kgsl_drawctxt_create { + unsigned int flags; + unsigned int drawctxt_id; /*output param */ +}; + +#define IOCTL_KGSL_DRAWCTXT_CREATE \ + _IOWR(KGSL_IOC_TYPE, 0x13, struct kgsl_drawctxt_create) + +/* destroy a draw context */ +struct kgsl_drawctxt_destroy { + unsigned int drawctxt_id; +}; + +#define IOCTL_KGSL_DRAWCTXT_DESTROY \ + _IOW(KGSL_IOC_TYPE, 0x14, struct kgsl_drawctxt_destroy) + +/* add a block of pmem, fb, ashmem or user allocated address + * into the GPU address space */ +struct kgsl_map_user_mem { + int fd; + unsigned long gpuaddr; /*output param */ + size_t len; + size_t offset; + unsigned long hostptr; /*input param */ + enum kgsl_user_mem_type memtype; + unsigned int flags; +}; + +#define IOCTL_KGSL_MAP_USER_MEM \ + _IOWR(KGSL_IOC_TYPE, 0x15, struct kgsl_map_user_mem) + +struct kgsl_cmdstream_readtimestamp_ctxtid { + unsigned int context_id; + unsigned int type; + unsigned int timestamp; /*output param */ +}; + +#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP_CTXTID \ + _IOWR(KGSL_IOC_TYPE, 0x16, struct kgsl_cmdstream_readtimestamp_ctxtid) + +struct kgsl_cmdstream_freememontimestamp_ctxtid { + unsigned int context_id; + unsigned long gpuaddr; + unsigned int type; + unsigned int timestamp; +}; + +#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP_CTXTID \ + _IOW(KGSL_IOC_TYPE, 0x17, \ + struct kgsl_cmdstream_freememontimestamp_ctxtid) + +/* add a block of pmem or fb into the GPU address space */ +struct kgsl_sharedmem_from_pmem { + int pmem_fd; + unsigned long gpuaddr; /*output param */ + unsigned int len; + unsigned int offset; +}; + +#define IOCTL_KGSL_SHAREDMEM_FROM_PMEM \ + _IOWR(KGSL_IOC_TYPE, 0x20, struct kgsl_sharedmem_from_pmem) + +/* remove memory from the GPU's address space */ +struct kgsl_sharedmem_free { + unsigned long gpuaddr; +}; + +#define IOCTL_KGSL_SHAREDMEM_FREE \ + _IOW(KGSL_IOC_TYPE, 0x21, struct kgsl_sharedmem_free) + +struct kgsl_cff_user_event { + unsigned char cff_opcode; + unsigned int op1; + unsigned int op2; + unsigned int op3; + unsigned int op4; + unsigned int op5; + unsigned int __pad[2]; +}; + +#define IOCTL_KGSL_CFF_USER_EVENT \ + _IOW(KGSL_IOC_TYPE, 0x31, struct kgsl_cff_user_event) + +struct kgsl_gmem_desc { + unsigned int x; + unsigned int y; + unsigned int width; + unsigned int height; + unsigned int pitch; +}; + +struct kgsl_buffer_desc { + void *hostptr; + unsigned long gpuaddr; + int size; + unsigned int format; + unsigned int pitch; + unsigned int enabled; +}; + +struct kgsl_bind_gmem_shadow { + unsigned int drawctxt_id; + struct kgsl_gmem_desc gmem_desc; + unsigned int shadow_x; + unsigned int shadow_y; + struct kgsl_buffer_desc shadow_buffer; + unsigned int buffer_id; +}; + +#define IOCTL_KGSL_DRAWCTXT_BIND_GMEM_SHADOW \ + _IOW(KGSL_IOC_TYPE, 0x22, struct kgsl_bind_gmem_shadow) + +/* add a block of memory into the GPU address space */ + +/* + * IOCTL_KGSL_SHAREDMEM_FROM_VMALLOC deprecated 09/2012 + * use IOCTL_KGSL_GPUMEM_ALLOC instead + */ + +struct kgsl_sharedmem_from_vmalloc { + unsigned long gpuaddr; /*output param */ + unsigned int hostptr; + unsigned int flags; +}; + +#define IOCTL_KGSL_SHAREDMEM_FROM_VMALLOC \ + _IOWR(KGSL_IOC_TYPE, 0x23, struct kgsl_sharedmem_from_vmalloc) + +/* + * This is being deprecated in favor of IOCTL_KGSL_GPUMEM_CACHE_SYNC which + * supports both directions (flush and invalidate). This code will still + * work, but by definition it will do a flush of the cache which might not be + * what you want to have happen on a buffer following a GPU operation. It is + * safer to go with IOCTL_KGSL_GPUMEM_CACHE_SYNC + */ + +#define IOCTL_KGSL_SHAREDMEM_FLUSH_CACHE \ + _IOW(KGSL_IOC_TYPE, 0x24, struct kgsl_sharedmem_free) + +struct kgsl_drawctxt_set_bin_base_offset { + unsigned int drawctxt_id; + unsigned int offset; +}; + +#define IOCTL_KGSL_DRAWCTXT_SET_BIN_BASE_OFFSET \ + _IOW(KGSL_IOC_TYPE, 0x25, struct kgsl_drawctxt_set_bin_base_offset) + +enum kgsl_cmdwindow_type { + KGSL_CMDWINDOW_MIN = 0x00000000, + KGSL_CMDWINDOW_2D = 0x00000000, + KGSL_CMDWINDOW_3D = 0x00000001, /* legacy */ + KGSL_CMDWINDOW_MMU = 0x00000002, + KGSL_CMDWINDOW_ARBITER = 0x000000FF, + KGSL_CMDWINDOW_MAX = 0x000000FF, +}; + +/* write to the command window */ +struct kgsl_cmdwindow_write { + enum kgsl_cmdwindow_type target; + unsigned int addr; + unsigned int data; +}; + +#define IOCTL_KGSL_CMDWINDOW_WRITE \ + _IOW(KGSL_IOC_TYPE, 0x2e, struct kgsl_cmdwindow_write) + +struct kgsl_gpumem_alloc { + unsigned long gpuaddr; /* output param */ + size_t size; + unsigned int flags; +}; + +#define IOCTL_KGSL_GPUMEM_ALLOC \ + _IOWR(KGSL_IOC_TYPE, 0x2f, struct kgsl_gpumem_alloc) + +struct kgsl_cff_syncmem { + unsigned long gpuaddr; + size_t len; + unsigned int __pad[2]; /* For future binary compatibility */ +}; + +#define IOCTL_KGSL_CFF_SYNCMEM \ + _IOW(KGSL_IOC_TYPE, 0x30, struct kgsl_cff_syncmem) + +/* + * A timestamp event allows the user space to register an action following an + * expired timestamp. Note IOCTL_KGSL_TIMESTAMP_EVENT has been redefined to + * _IOWR to support fences which need to return a fd for the priv parameter. + */ + +struct kgsl_timestamp_event { + int type; /* Type of event (see list below) */ + unsigned int timestamp; /* Timestamp to trigger event on */ + unsigned int context_id; /* Context for the timestamp */ + void __user *priv; /* Pointer to the event specific blob */ + size_t len; /* Size of the event specific blob */ +}; + +#define IOCTL_KGSL_TIMESTAMP_EVENT_OLD \ + _IOW(KGSL_IOC_TYPE, 0x31, struct kgsl_timestamp_event) + +/* A genlock timestamp event releases an existing lock on timestamp expire */ + +#define KGSL_TIMESTAMP_EVENT_GENLOCK 1 + +struct kgsl_timestamp_event_genlock { + int handle; /* Handle of the genlock lock to release */ +}; + +/* A fence timestamp event releases an existing lock on timestamp expire */ + +#define KGSL_TIMESTAMP_EVENT_FENCE 2 + +struct kgsl_timestamp_event_fence { + int fence_fd; /* Fence to signal */ +}; + +/* + * Set a property within the kernel. Uses the same structure as + * IOCTL_KGSL_GETPROPERTY + */ + +#define IOCTL_KGSL_SETPROPERTY \ + _IOW(KGSL_IOC_TYPE, 0x32, struct kgsl_device_getproperty) + +#define IOCTL_KGSL_TIMESTAMP_EVENT \ + _IOWR(KGSL_IOC_TYPE, 0x33, struct kgsl_timestamp_event) + +/** + * struct kgsl_gpumem_alloc_id - argument to IOCTL_KGSL_GPUMEM_ALLOC_ID + * @id: returned id value for this allocation. + * @flags: mask of KGSL_MEM* values requested and actual flags on return. + * @size: requested size of the allocation and actual size on return. + * @mmapsize: returned size to pass to mmap() which may be larger than 'size' + * @gpuaddr: returned GPU address for the allocation + * + * Allocate memory for access by the GPU. The flags and size fields are echoed + * back by the kernel, so that the caller can know if the request was + * adjusted. + * + * Supported flags: + * KGSL_MEMFLAGS_GPUREADONLY: the GPU will be unable to write to the buffer + * KGSL_MEMTYPE*: usage hint for debugging aid + * KGSL_MEMALIGN*: alignment hint, may be ignored or adjusted by the kernel. + * KGSL_MEMFLAGS_USE_CPU_MAP: If set on call and return, the returned GPU + * address will be 0. Calling mmap() will set the GPU address. + */ +struct kgsl_gpumem_alloc_id { + unsigned int id; + unsigned int flags; + size_t size; + size_t mmapsize; + unsigned long gpuaddr; +/* private: reserved for future use*/ + unsigned long __pad[2]; +}; + +#define IOCTL_KGSL_GPUMEM_ALLOC_ID \ + _IOWR(KGSL_IOC_TYPE, 0x34, struct kgsl_gpumem_alloc_id) + +/** + * struct kgsl_gpumem_free_id - argument to IOCTL_KGSL_GPUMEM_FREE_ID + * @id: GPU allocation id to free + * + * Free an allocation by id, in case a GPU address has not been assigned or + * is unknown. Freeing an allocation by id with this ioctl or by GPU address + * with IOCTL_KGSL_SHAREDMEM_FREE are equivalent. + */ +struct kgsl_gpumem_free_id { + unsigned int id; +/* private: reserved for future use*/ + unsigned int __pad; +}; + +#define IOCTL_KGSL_GPUMEM_FREE_ID \ + _IOWR(KGSL_IOC_TYPE, 0x35, struct kgsl_gpumem_free_id) + +/** + * struct kgsl_gpumem_get_info - argument to IOCTL_KGSL_GPUMEM_GET_INFO + * @gpuaddr: GPU address to query. Also set on return. + * @id: GPU allocation id to query. Also set on return. + * @flags: returned mask of KGSL_MEM* values. + * @size: returned size of the allocation. + * @mmapsize: returned size to pass mmap(), which may be larger than 'size' + * @useraddr: returned address of the userspace mapping for this buffer + * + * This ioctl allows querying of all user visible attributes of an existing + * allocation, by either the GPU address or the id returned by a previous + * call to IOCTL_KGSL_GPUMEM_ALLOC_ID. Legacy allocation ioctls may not + * return all attributes so this ioctl can be used to look them up if needed. + * + */ +struct kgsl_gpumem_get_info { + unsigned long gpuaddr; + unsigned int id; + unsigned int flags; + size_t size; + size_t mmapsize; + unsigned long useraddr; +/* private: reserved for future use*/ + unsigned long __pad[4]; +}; + +#define IOCTL_KGSL_GPUMEM_GET_INFO\ + _IOWR(KGSL_IOC_TYPE, 0x36, struct kgsl_gpumem_get_info) + +/** + * struct kgsl_gpumem_sync_cache - argument to IOCTL_KGSL_GPUMEM_SYNC_CACHE + * @gpuaddr: GPU address of the buffer to sync. + * @id: id of the buffer to sync. Either gpuaddr or id is sufficient. + * @op: a mask of KGSL_GPUMEM_CACHE_* values + * @offset: offset into the buffer + * @length: number of bytes starting from offset to perform + * the cache operation on + * + * Sync the L2 cache for memory headed to and from the GPU - this replaces + * KGSL_SHAREDMEM_FLUSH_CACHE since it can handle cache management for both + * directions + * + */ +struct kgsl_gpumem_sync_cache { + unsigned long gpuaddr; + unsigned int id; + unsigned int op; + size_t offset; + size_t length; +}; + +#define KGSL_GPUMEM_CACHE_CLEAN (1 << 0) +#define KGSL_GPUMEM_CACHE_TO_GPU KGSL_GPUMEM_CACHE_CLEAN + +#define KGSL_GPUMEM_CACHE_INV (1 << 1) +#define KGSL_GPUMEM_CACHE_FROM_GPU KGSL_GPUMEM_CACHE_INV + +#define KGSL_GPUMEM_CACHE_FLUSH \ + (KGSL_GPUMEM_CACHE_CLEAN | KGSL_GPUMEM_CACHE_INV) + +/* Flag to ensure backwards compatibility of kgsl_gpumem_sync_cache struct */ +#define KGSL_GPUMEM_CACHE_RANGE (1 << 31U) + +#define IOCTL_KGSL_GPUMEM_SYNC_CACHE \ + _IOW(KGSL_IOC_TYPE, 0x37, struct kgsl_gpumem_sync_cache) + +/** + * struct kgsl_perfcounter_get - argument to IOCTL_KGSL_PERFCOUNTER_GET + * @groupid: Performance counter group ID + * @countable: Countable to select within the group + * @offset: Return offset of the reserved LO counter + * @offset_hi: Return offset of the reserved HI counter + * + * Get an available performance counter from a specified groupid. The offset + * of the performance counter will be returned after successfully assigning + * the countable to the counter for the specified group. An error will be + * returned and an offset of 0 if the groupid is invalid or there are no + * more counters left. After successfully getting a perfcounter, the user + * must call kgsl_perfcounter_put(groupid, contable) when finished with + * the perfcounter to clear up perfcounter resources. + * + */ +struct kgsl_perfcounter_get { + unsigned int groupid; + unsigned int countable; + unsigned int offset; + unsigned int offset_hi; +/* private: reserved for future use */ + unsigned int __pad; /* For future binary compatibility */ +}; + +#define IOCTL_KGSL_PERFCOUNTER_GET \ + _IOWR(KGSL_IOC_TYPE, 0x38, struct kgsl_perfcounter_get) + +/** + * struct kgsl_perfcounter_put - argument to IOCTL_KGSL_PERFCOUNTER_PUT + * @groupid: Performance counter group ID + * @countable: Countable to release within the group + * + * Put an allocated performance counter to allow others to have access to the + * resource that was previously taken. This is only to be called after + * successfully getting a performance counter from kgsl_perfcounter_get(). + * + */ +struct kgsl_perfcounter_put { + unsigned int groupid; + unsigned int countable; +/* private: reserved for future use */ + unsigned int __pad[2]; /* For future binary compatibility */ +}; + +#define IOCTL_KGSL_PERFCOUNTER_PUT \ + _IOW(KGSL_IOC_TYPE, 0x39, struct kgsl_perfcounter_put) + +/** + * struct kgsl_perfcounter_query - argument to IOCTL_KGSL_PERFCOUNTER_QUERY + * @groupid: Performance counter group ID + * @countable: Return active countables array + * @size: Size of active countables array + * @max_counters: Return total number counters for the group ID + * + * Query the available performance counters given a groupid. The array + * *countables is used to return the current active countables in counters. + * The size of the array is passed in so the kernel will only write at most + * size or counter->size for the group id. The total number of available + * counters for the group ID is returned in max_counters. + * If the array or size passed in are invalid, then only the maximum number + * of counters will be returned, no data will be written to *countables. + * If the groupid is invalid an error code will be returned. + * + */ +struct kgsl_perfcounter_query { + unsigned int groupid; + /* Array to return the current countable for up to size counters */ + unsigned int __user *countables; + unsigned int count; + unsigned int max_counters; +/* private: reserved for future use */ + unsigned int __pad[2]; /* For future binary compatibility */ +}; + +#define IOCTL_KGSL_PERFCOUNTER_QUERY \ + _IOWR(KGSL_IOC_TYPE, 0x3A, struct kgsl_perfcounter_query) + +/** + * struct kgsl_perfcounter_query - argument to IOCTL_KGSL_PERFCOUNTER_QUERY + * @groupid: Performance counter group IDs + * @countable: Performance counter countable IDs + * @value: Return performance counter reads + * @size: Size of all arrays (groupid/countable pair and return value) + * + * Read in the current value of a performance counter given by the groupid + * and countable. + * + */ + +struct kgsl_perfcounter_read_group { + unsigned int groupid; + unsigned int countable; + unsigned long long value; +}; + +struct kgsl_perfcounter_read { + struct kgsl_perfcounter_read_group __user *reads; + unsigned int count; +/* private: reserved for future use */ + unsigned int __pad[2]; /* For future binary compatibility */ +}; + +#define IOCTL_KGSL_PERFCOUNTER_READ \ + _IOWR(KGSL_IOC_TYPE, 0x3B, struct kgsl_perfcounter_read) +/* + * struct kgsl_gpumem_sync_cache_bulk - argument to + * IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK + * @id_list: list of GPU buffer ids of the buffers to sync + * @count: number of GPU buffer ids in id_list + * @op: a mask of KGSL_GPUMEM_CACHE_* values + * + * Sync the cache for memory headed to and from the GPU. Certain + * optimizations can be made on the cache operation based on the total + * size of the working set of memory to be managed. + */ +struct kgsl_gpumem_sync_cache_bulk { + unsigned int __user *id_list; + unsigned int count; + unsigned int op; +/* private: reserved for future use */ + unsigned int __pad[2]; /* For future binary compatibility */ +}; + +#define IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK \ + _IOWR(KGSL_IOC_TYPE, 0x3C, struct kgsl_gpumem_sync_cache_bulk) + +/* + * struct kgsl_cmd_syncpoint_timestamp + * @context_id: ID of a KGSL context + * @timestamp: GPU timestamp + * + * This structure defines a syncpoint comprising a context/timestamp pair. A + * list of these may be passed by IOCTL_KGSL_SUBMIT_COMMANDS to define + * dependencies that must be met before the command can be submitted to the + * hardware + */ +struct kgsl_cmd_syncpoint_timestamp { + unsigned int context_id; + unsigned int timestamp; +}; + +struct kgsl_cmd_syncpoint_fence { + int fd; +}; + +/** + * struct kgsl_cmd_syncpoint - Define a sync point for a command batch + * @type: type of sync point defined here + * @priv: Pointer to the type specific buffer + * @size: Size of the type specific buffer + * + * This structure contains pointers defining a specific command sync point. + * The pointer and size should point to a type appropriate structure. + */ +struct kgsl_cmd_syncpoint { + int type; + void __user *priv; + size_t size; +}; + +/* Flag to indicate that the cmdlist may contain memlists */ +#define KGSL_IBDESC_MEMLIST 0x1 + +/* Flag to point out the cmdbatch profiling buffer in the memlist */ +#define KGSL_IBDESC_PROFILING_BUFFER 0x2 + +/** + * struct kgsl_submit_commands - Argument to IOCTL_KGSL_SUBMIT_COMMANDS + * @context_id: KGSL context ID that owns the commands + * @flags: + * @cmdlist: User pointer to a list of kgsl_ibdesc structures + * @numcmds: Number of commands listed in cmdlist + * @synclist: User pointer to a list of kgsl_cmd_syncpoint structures + * @numsyncs: Number of sync points listed in synclist + * @timestamp: On entry the a user defined timestamp, on exist the timestamp + * assigned to the command batch + * + * This structure specifies a command to send to the GPU hardware. This is + * similar to kgsl_issueibcmds expect that it doesn't support the legacy way to + * submit IB lists and it adds sync points to block the IB until the + * dependencies are satisified. This entry point is the new and preferred way + * to submit commands to the GPU. The memory list can be used to specify all + * memory that is referrenced in the current set of commands. + */ + +struct kgsl_submit_commands { + unsigned int context_id; + unsigned int flags; + struct kgsl_ibdesc __user *cmdlist; + unsigned int numcmds; + struct kgsl_cmd_syncpoint __user *synclist; + unsigned int numsyncs; + unsigned int timestamp; +/* private: reserved for future use */ + unsigned int __pad[4]; +}; + +#define IOCTL_KGSL_SUBMIT_COMMANDS \ + _IOWR(KGSL_IOC_TYPE, 0x3D, struct kgsl_submit_commands) + +/** + * struct kgsl_device_constraint - device constraint argument + * @context_id: KGSL context ID + * @type: type of constraint i.e pwrlevel/none + * @data: constraint data + * @size: size of the constraint data + */ +struct kgsl_device_constraint { + unsigned int type; + unsigned int context_id; + void __user *data; + size_t size; +}; + +/* Constraint Type*/ +#define KGSL_CONSTRAINT_NONE 0 +#define KGSL_CONSTRAINT_PWRLEVEL 1 + +/* PWRLEVEL constraint level*/ +/* set to min frequency */ +#define KGSL_CONSTRAINT_PWR_MIN 0 +/* set to max frequency */ +#define KGSL_CONSTRAINT_PWR_MAX 1 + +struct kgsl_device_constraint_pwrlevel { + unsigned int level; +}; + +/** + * struct kgsl_syncsource_create - Argument to IOCTL_KGSL_SYNCSOURCE_CREATE + * @id: returned id for the syncsource that was created. + * + * This ioctl creates a userspace sync timeline. + */ + +struct kgsl_syncsource_create { + unsigned int id; +/* private: reserved for future use */ + unsigned int __pad[3]; +}; + +#define IOCTL_KGSL_SYNCSOURCE_CREATE \ + _IOWR(KGSL_IOC_TYPE, 0x40, struct kgsl_syncsource_create) + +/** + * struct kgsl_syncsource_destroy - Argument to IOCTL_KGSL_SYNCSOURCE_DESTROY + * @id: syncsource id to destroy + * + * This ioctl creates a userspace sync timeline. + */ + +struct kgsl_syncsource_destroy { + unsigned int id; +/* private: reserved for future use */ + unsigned int __pad[3]; +}; + +#define IOCTL_KGSL_SYNCSOURCE_DESTROY \ + _IOWR(KGSL_IOC_TYPE, 0x41, struct kgsl_syncsource_destroy) + +/** + * struct kgsl_syncsource_create_fence - Argument to + * IOCTL_KGSL_SYNCSOURCE_CREATE_FENCE + * @id: syncsource id + * @fence_fd: returned sync_fence fd + * + * Create a fence that may be signaled by userspace by calling + * IOCTL_KGSL_SYNCSOURCE_SIGNAL_FENCE. There are no order dependencies between + * these fences. + */ +struct kgsl_syncsource_create_fence { + unsigned int id; + int fence_fd; +/* private: reserved for future use */ + unsigned int __pad[4]; +}; + +/** + * struct kgsl_syncsource_signal_fence - Argument to + * IOCTL_KGSL_SYNCSOURCE_SIGNAL_FENCE + * @id: syncsource id + * @fence_fd: sync_fence fd to signal + * + * Signal a fence that was created by a IOCTL_KGSL_SYNCSOURCE_CREATE_FENCE + * call using the same syncsource id. This allows a fence to be shared + * to other processes but only signaled by the process owning the fd + * used to create the fence. + */ +#define IOCTL_KGSL_SYNCSOURCE_CREATE_FENCE \ + _IOWR(KGSL_IOC_TYPE, 0x42, struct kgsl_syncsource_create_fence) + +struct kgsl_syncsource_signal_fence { + unsigned int id; + int fence_fd; +/* private: reserved for future use */ + unsigned int __pad[4]; +}; + +#define IOCTL_KGSL_SYNCSOURCE_SIGNAL_FENCE \ + _IOWR(KGSL_IOC_TYPE, 0x43, struct kgsl_syncsource_signal_fence) + +/** + * struct kgsl_cff_sync_gpuobj - Argument to IOCTL_KGSL_CFF_SYNC_GPUOBJ + * @offset: Offset into the GPU object to sync + * @length: Number of bytes to sync + * @id: ID of the GPU object to sync + */ +struct kgsl_cff_sync_gpuobj { + uint64_t offset; + uint64_t length; + unsigned int id; +}; + +#define IOCTL_KGSL_CFF_SYNC_GPUOBJ \ + _IOW(KGSL_IOC_TYPE, 0x44, struct kgsl_cff_sync_gpuobj) + +/** + * struct kgsl_gpuobj_alloc - Argument to IOCTL_KGSL_GPUOBJ_ALLOC + * @size: Size in bytes of the object to allocate + * @flags: mask of KGSL_MEMFLAG_* bits + * @va_len: Size in bytes of the virtual region to allocate + * @mmapsize: Returns the mmap() size of the object + * @id: Returns the GPU object ID of the new object + * @metadata_len: Length of the metdata to copy from the user + * @metadata: Pointer to the user specified metadata to store for the object + */ +struct kgsl_gpuobj_alloc { + uint64_t size; + uint64_t flags; + uint64_t va_len; + uint64_t mmapsize; + unsigned int id; + unsigned int metadata_len; + uint64_t metadata; +}; + +/* Let the user know that this header supports the gpuobj metadata */ +#define KGSL_GPUOBJ_ALLOC_METADATA_MAX 64 + +#define IOCTL_KGSL_GPUOBJ_ALLOC \ + _IOWR(KGSL_IOC_TYPE, 0x45, struct kgsl_gpuobj_alloc) + +/** + * struct kgsl_gpuobj_free - Argument to IOCTL_KGLS_GPUOBJ_FREE + * @flags: Mask of: KGSL_GUPOBJ_FREE_ON_EVENT + * @priv: Pointer to the private object if KGSL_GPUOBJ_FREE_ON_EVENT is + * specified + * @id: ID of the GPU object to free + * @type: If KGSL_GPUOBJ_FREE_ON_EVENT is specified, the type of asynchronous + * event to free on + * @len: Length of the data passed in priv + */ +struct kgsl_gpuobj_free { + uint64_t flags; + uint64_t __user priv; + unsigned int id; + unsigned int type; + unsigned int len; +}; + +#define KGSL_GPUOBJ_FREE_ON_EVENT 1 + +#define KGSL_GPU_EVENT_TIMESTAMP 1 +#define KGSL_GPU_EVENT_FENCE 2 + +/** + * struct kgsl_gpu_event_timestamp - Specifies a timestamp event to free a GPU + * object on + * @context_id: ID of the timestamp event to wait for + * @timestamp: Timestamp of the timestamp event to wait for + */ +struct kgsl_gpu_event_timestamp { + unsigned int context_id; + unsigned int timestamp; +}; + +/** + * struct kgsl_gpu_event_fence - Specifies a fence ID to to free a GPU object on + * @fd: File descriptor for the fence + */ +struct kgsl_gpu_event_fence { + int fd; +}; + +#define IOCTL_KGSL_GPUOBJ_FREE \ + _IOW(KGSL_IOC_TYPE, 0x46, struct kgsl_gpuobj_free) + +/** + * struct kgsl_gpuobj_info - argument to IOCTL_KGSL_GPUOBJ_INFO + * @gpuaddr: GPU address of the object + * @flags: Current flags for the object + * @size: Size of the object + * @va_len: VA size of the object + * @va_addr: Virtual address of the object (if it is mapped) + * id - GPU object ID of the object to query + */ +struct kgsl_gpuobj_info { + uint64_t gpuaddr; + uint64_t flags; + uint64_t size; + uint64_t va_len; + uint64_t va_addr; + unsigned int id; +}; + +#define IOCTL_KGSL_GPUOBJ_INFO \ + _IOWR(KGSL_IOC_TYPE, 0x47, struct kgsl_gpuobj_info) + +/** + * struct kgsl_gpuobj_import - argument to IOCTL_KGSL_GPUOBJ_IMPORT + * @priv: Pointer to the private data for the import type + * @priv_len: Length of the private data + * @flags: Mask of KGSL_MEMFLAG_ flags + * @type: Type of the import (KGSL_USER_MEM_TYPE_*) + * @id: Returns the ID of the new GPU object + */ +struct kgsl_gpuobj_import { + uint64_t __user priv; + uint64_t priv_len; + uint64_t flags; + unsigned int type; + unsigned int id; +}; + +/** + * struct kgsl_gpuobj_import_dma_buf - import a dmabuf object + * @fd: File descriptor for the dma-buf object + */ +struct kgsl_gpuobj_import_dma_buf { + int fd; +}; + +/** + * struct kgsl_gpuobj_import_useraddr - import an object based on a useraddr + * @virtaddr: Virtual address of the object to import + */ +struct kgsl_gpuobj_import_useraddr { + uint64_t virtaddr; +}; + +#define IOCTL_KGSL_GPUOBJ_IMPORT \ + _IOWR(KGSL_IOC_TYPE, 0x48, struct kgsl_gpuobj_import) + +/** + * struct kgsl_gpuobj_sync_obj - Individual GPU object to sync + * @offset: Offset within the GPU object to sync + * @length: Number of bytes to sync + * @id: ID of the GPU object to sync + * @op: Cache operation to execute + */ + +struct kgsl_gpuobj_sync_obj { + uint64_t offset; + uint64_t length; + unsigned int id; + unsigned int op; +}; + +/** + * struct kgsl_gpuobj_sync - Argument for IOCTL_KGSL_GPUOBJ_SYNC + * @objs: Pointer to an array of kgsl_gpuobj_sync_obj structs + * @obj_len: Size of each item in the array + * @count: Number of items in the array + */ + +struct kgsl_gpuobj_sync { + uint64_t __user objs; + unsigned int obj_len; + unsigned int count; +}; + +#define IOCTL_KGSL_GPUOBJ_SYNC \ + _IOW(KGSL_IOC_TYPE, 0x49, struct kgsl_gpuobj_sync) + +/** + * struct kgsl_command_object - GPU command object + * @offset: GPU address offset of the object + * @gpuaddr: GPU address of the object + * @size: Size of the object + * @flags: Current flags for the object + * @id - GPU command object ID + */ +struct kgsl_command_object { + uint64_t offset; + uint64_t gpuaddr; + uint64_t size; + unsigned int flags; + unsigned int id; +}; + +/** + * struct kgsl_command_syncpoint - GPU syncpoint object + * @priv: Pointer to the type specific buffer + * @size: Size of the type specific buffer + * @type: type of sync point defined here + */ +struct kgsl_command_syncpoint { + uint64_t __user priv; + uint64_t size; + unsigned int type; +}; + +/** + * struct kgsl_command_object - Argument for IOCTL_KGSL_GPU_COMMAND + * @flags: Current flags for the object + * @cmdlist: List of kgsl_command_objects for submission + * @cmd_size: Size of kgsl_command_objects structure + * @numcmds: Number of kgsl_command_objects in command list + * @objlist: List of kgsl_command_objects for tracking + * @obj_size: Size of kgsl_command_objects structure + * @numobjs: Number of kgsl_command_objects in object list + * @synclist: List of kgsl_command_syncpoints + * @sync_size: Size of kgsl_command_syncpoint structure + * @numsyncs: Number of kgsl_command_syncpoints in syncpoint list + * @context_id: Context ID submittin ghte kgsl_gpu_command + * @timestamp: Timestamp for the submitted commands + */ +struct kgsl_gpu_command { + uint64_t flags; + uint64_t __user cmdlist; + unsigned int cmdsize; + unsigned int numcmds; + uint64_t __user objlist; + unsigned int objsize; + unsigned int numobjs; + uint64_t __user synclist; + unsigned int syncsize; + unsigned int numsyncs; + unsigned int context_id; + unsigned int timestamp; +}; + +#define IOCTL_KGSL_GPU_COMMAND \ + _IOWR(KGSL_IOC_TYPE, 0x4A, struct kgsl_gpu_command) + +/** + * struct kgsl_preemption_counters_query - argument to + * IOCTL_KGSL_PREEMPTIONCOUNTER_QUERY + * @counters: Return preemption counters array + * @size_user: Size allocated by userspace + * @size_priority_level: Size of preemption counters for each + * priority level + * @max_priority_level: Return max number of priority levels + * + * Query the available preemption counters. The array counters + * is used to return preemption counters. The size of the array + * is passed in so the kernel will only write at most size_user + * or max available preemption counters. The total number of + * preemption counters is returned in max_priority_level. If the + * array or size passed in are invalid, then an error is + * returned back. + */ +struct kgsl_preemption_counters_query { + uint64_t __user counters; + unsigned int size_user; + unsigned int size_priority_level; + unsigned int max_priority_level; +}; + +#define IOCTL_KGSL_PREEMPTIONCOUNTER_QUERY \ + _IOWR(KGSL_IOC_TYPE, 0x4B, struct kgsl_preemption_counters_query) + +/** + * struct kgsl_gpuobj_set_info - argument for IOCTL_KGSL_GPUOBJ_SET_INFO + * @flags: Flags to indicate which paramaters to change + * @metadata: If KGSL_GPUOBJ_SET_INFO_METADATA is set, a pointer to the new + * metadata + * @id: GPU memory object ID to change + * @metadata_len: If KGSL_GPUOBJ_SET_INFO_METADATA is set, the length of the + * new metadata string + * @type: If KGSL_GPUOBJ_SET_INFO_TYPE is set, the new type of the memory object + */ + +#define KGSL_GPUOBJ_SET_INFO_METADATA (1 << 0) +#define KGSL_GPUOBJ_SET_INFO_TYPE (1 << 1) + +struct kgsl_gpuobj_set_info { + uint64_t flags; + uint64_t metadata; + unsigned int id; + unsigned int metadata_len; + unsigned int type; +}; + +#define IOCTL_KGSL_GPUOBJ_SET_INFO \ + _IOW(KGSL_IOC_TYPE, 0x4C, struct kgsl_gpuobj_set_info) + +#endif /* _UAPI_MSM_KGSL_H */ diff --git a/selfdrive/modeld/thneed/thneed.cc b/selfdrive/modeld/thneed/thneed.cc new file mode 100644 index 00000000000000..44328565327e39 --- /dev/null +++ b/selfdrive/modeld/thneed/thneed.cc @@ -0,0 +1,581 @@ +#include +#include +#include +#include +#include +#include +#include +#include "thneed.h" + +//#define SAVE_KERNELS + +//#define RUN_DISASSEMBLER +//#define RUN_OPTIMIZER + +Thneed *g_thneed = NULL; +int g_fd = -1; +map, string> g_args; +map, int> g_args_size; +map g_program_source; + +static inline uint64_t nanos_since_boot() { + struct timespec t; + clock_gettime(CLOCK_BOOTTIME, &t); + return t.tv_sec * 1000000000ULL + t.tv_nsec; +} + +void hexdump(uint32_t *d, int len) { + assert((len%4) == 0); + printf(" dumping %p len 0x%x\n", d, len); + for (int i = 0; i < len/4; i++) { + if (i != 0 && (i%0x10) == 0) printf("\n"); + printf("%8x ", d[i]); + } + printf("\n"); +} + +// *********** ioctl interceptor *********** + +extern "C" { + +int (*my_ioctl)(int filedes, unsigned long request, void *argp) = NULL; +#undef ioctl +int ioctl(int filedes, unsigned long request, void *argp) { + request &= 0xFFFFFFFF; // needed on QCOM2 + if (my_ioctl == NULL) my_ioctl = reinterpret_cast(dlsym(RTLD_NEXT, "ioctl")); + Thneed *thneed = g_thneed; + + // save the fd + if (request == IOCTL_KGSL_GPUOBJ_ALLOC) g_fd = filedes; + + // note that this runs always, even without a thneed object + if (request == IOCTL_KGSL_DRAWCTXT_CREATE) { + struct kgsl_drawctxt_create *create = (struct kgsl_drawctxt_create *)argp; + create->flags &= ~KGSL_CONTEXT_PRIORITY_MASK; + create->flags |= 1 << KGSL_CONTEXT_PRIORITY_SHIFT; // priority from 1-15, 1 is max priority + printf("IOCTL_KGSL_DRAWCTXT_CREATE: creating context with flags 0x%x\n", create->flags); + } + + if (thneed != NULL) { + if (request == IOCTL_KGSL_GPU_COMMAND) { + struct kgsl_gpu_command *cmd = (struct kgsl_gpu_command *)argp; + if (thneed->record & THNEED_RECORD) { + thneed->timestamp = cmd->timestamp; + thneed->context_id = cmd->context_id; + thneed->cmds.push_back(unique_ptr(new CachedCommand(thneed, cmd))); + } + if (thneed->record & THNEED_DEBUG) { + printf("IOCTL_KGSL_GPU_COMMAND(%2zu): flags: 0x%lx context_id: %u timestamp: %u numcmds: %d numobjs: %d\n", + thneed->cmds.size(), + cmd->flags, + cmd->context_id, cmd->timestamp, cmd->numcmds, cmd->numobjs); + } + } else if (request == IOCTL_KGSL_GPUOBJ_SYNC) { + struct kgsl_gpuobj_sync *cmd = (struct kgsl_gpuobj_sync *)argp; + struct kgsl_gpuobj_sync_obj *objs = (struct kgsl_gpuobj_sync_obj *)(cmd->objs); + + if (thneed->record & THNEED_DEBUG) { + printf("IOCTL_KGSL_GPUOBJ_SYNC count:%d ", cmd->count); + for (int i = 0; i < cmd->count; i++) { + printf(" -- offset:0x%lx len:0x%lx id:%d op:%d ", objs[i].offset, objs[i].length, objs[i].id, objs[i].op); + } + printf("\n"); + } + + if (thneed->record & THNEED_RECORD) { + thneed->syncobjs.push_back(string((char *)objs, sizeof(struct kgsl_gpuobj_sync_obj)*cmd->count)); + } + } else if (request == IOCTL_KGSL_DEVICE_WAITTIMESTAMP_CTXTID) { + struct kgsl_device_waittimestamp_ctxtid *cmd = (struct kgsl_device_waittimestamp_ctxtid *)argp; + if (thneed->record & THNEED_DEBUG) { + printf("IOCTL_KGSL_DEVICE_WAITTIMESTAMP_CTXTID: context_id: %d timestamp: %d timeout: %d\n", + cmd->context_id, cmd->timestamp, cmd->timeout); + } + } else if (request == IOCTL_KGSL_SETPROPERTY) { + if (thneed->record & THNEED_DEBUG) { + struct kgsl_device_getproperty *prop = (struct kgsl_device_getproperty *)argp; + printf("IOCTL_KGSL_SETPROPERTY: 0x%x sizebytes:%zu\n", prop->type, prop->sizebytes); + if (thneed->record & THNEED_VERBOSE_DEBUG) { + hexdump((uint32_t *)prop->value, prop->sizebytes); + if (prop->type == KGSL_PROP_PWR_CONSTRAINT) { + struct kgsl_device_constraint *constraint = (struct kgsl_device_constraint *)prop->value; + hexdump((uint32_t *)constraint->data, constraint->size); + } + } + } + } + } + + int ret = my_ioctl(filedes, request, argp); + if (ret != 0) printf("ioctl returned %d with errno %d\n", ret, errno); + return ret; +} + +} + +// *********** GPUMalloc *********** + +GPUMalloc::GPUMalloc(int size, int fd) { + struct kgsl_gpuobj_alloc alloc; + memset(&alloc, 0, sizeof(alloc)); + alloc.size = size; + alloc.flags = 0x10000a00; + ioctl(fd, IOCTL_KGSL_GPUOBJ_ALLOC, &alloc); + void *addr = mmap64(NULL, alloc.mmapsize, 0x3, 0x1, fd, alloc.id*0x1000); + assert(addr != MAP_FAILED); + + base = (uint64_t)addr; + remaining = size; +} + +GPUMalloc::~GPUMalloc() { + // TODO: free the GPU malloced area +} + +void *GPUMalloc::alloc(int size) { + if (size > remaining) return NULL; + remaining -= size; + void *ret = (void*)base; + base += (size+0xff) & (~0xFF); + return ret; +} + +// *********** CachedCommand, at the ioctl layer *********** + +CachedCommand::CachedCommand(Thneed *lthneed, struct kgsl_gpu_command *cmd) { + thneed = lthneed; + assert(cmd->numsyncs == 0); + + memcpy(&cache, cmd, sizeof(cache)); + + if (cmd->numcmds > 0) { + cmds = make_unique(cmd->numcmds); + memcpy(cmds.get(), (void *)cmd->cmdlist, sizeof(struct kgsl_command_object)*cmd->numcmds); + cache.cmdlist = (uint64_t)cmds.get(); + for (int i = 0; i < cmd->numcmds; i++) { + void *nn = thneed->ram->alloc(cmds[i].size); + memcpy(nn, (void*)cmds[i].gpuaddr, cmds[i].size); + cmds[i].gpuaddr = (uint64_t)nn; + } + } + + if (cmd->numobjs > 0) { + objs = make_unique(cmd->numobjs); + memcpy(objs.get(), (void *)cmd->objlist, sizeof(struct kgsl_command_object)*cmd->numobjs); + cache.objlist = (uint64_t)objs.get(); + for (int i = 0; i < cmd->numobjs; i++) { + void *nn = thneed->ram->alloc(objs[i].size); + memset(nn, 0, objs[i].size); + objs[i].gpuaddr = (uint64_t)nn; + } + } + + kq = thneed->ckq; + thneed->ckq.clear(); +} + +void CachedCommand::exec(bool wait) { + cache.timestamp = ++thneed->timestamp; + int ret = ioctl(thneed->fd, IOCTL_KGSL_GPU_COMMAND, &cache); + + if (wait) { + struct kgsl_device_waittimestamp_ctxtid wait; + wait.context_id = cache.context_id; + wait.timestamp = cache.timestamp; + wait.timeout = -1; + + uint64_t tb = nanos_since_boot(); + int wret = ioctl(thneed->fd, IOCTL_KGSL_DEVICE_WAITTIMESTAMP_CTXTID, &wait); + uint64_t te = nanos_since_boot(); + + if (thneed->record & THNEED_DEBUG) printf("exec %d wait %d after %lu us\n", ret, wret, (te-tb)/1000); + } else { + if (thneed->record & THNEED_DEBUG) printf("CachedCommand::exec got %d\n", ret); + } + + if (thneed->record & THNEED_VERBOSE_DEBUG) { + for (auto &it : kq) { + it->debug_print(false); + } + #ifdef RUN_DISASSEMBLER + // assuming 2 commands + disassemble(0); + disassemble(1); + #endif + } + + assert(ret == 0); +} + +// *********** Thneed *********** + +Thneed::Thneed(bool do_clinit) { + if (do_clinit) clinit(); + assert(g_fd != -1); + fd = g_fd; + ram = make_unique(0x40000, fd); + record = THNEED_RECORD; + timestamp = -1; + g_thneed = this; +} + +void Thneed::stop() { + record = 0; +} + +void Thneed::execute(float **finputs, float *foutput, bool slow) { + int ret; + uint64_t tb, te; + if (record & THNEED_DEBUG) tb = nanos_since_boot(); + + // ****** copy inputs + for (int idx = 0; idx < inputs.size(); ++idx) { + size_t sz; + clGetMemObjectInfo(inputs[idx], CL_MEM_SIZE, sizeof(sz), &sz, NULL); + + if (record & THNEED_DEBUG) printf("copying %lu -- %p -> %p\n", sz, finputs[idx], inputs[idx]); + // TODO: This shouldn't have to block + clEnqueueWriteBuffer(command_queue, inputs[idx], CL_TRUE, 0, sz, finputs[idx], 0, NULL, NULL); + } + + // ****** set power constraint + struct kgsl_device_constraint_pwrlevel pwrlevel; + pwrlevel.level = KGSL_CONSTRAINT_PWR_MAX; + + struct kgsl_device_constraint constraint; + constraint.type = KGSL_CONSTRAINT_PWRLEVEL; + constraint.context_id = context_id; + constraint.data = (void*)&pwrlevel; + constraint.size = sizeof(pwrlevel); + + struct kgsl_device_getproperty prop; + prop.type = KGSL_PROP_PWR_CONSTRAINT; + prop.value = (void*)&constraint; + prop.sizebytes = sizeof(constraint); + ret = ioctl(fd, IOCTL_KGSL_SETPROPERTY, &prop); + assert(ret == 0); + + // ****** run commands + int i = 0; + for (auto &it : cmds) { + ++i; + if (record & THNEED_DEBUG) printf("run %2d @ %7lu us: ", i, (nanos_since_boot()-tb)/1000); + it->exec((i == cmds.size()) || slow); + } + + // ****** sync objects + for (auto &it : syncobjs) { + struct kgsl_gpuobj_sync cmd; + + cmd.objs = (uint64_t)it.data(); + cmd.obj_len = it.length(); + cmd.count = it.length() / sizeof(struct kgsl_gpuobj_sync_obj); + + ret = ioctl(fd, IOCTL_KGSL_GPUOBJ_SYNC, &cmd); + assert(ret == 0); + } + + // ****** copy outputs + if (output != NULL) { + size_t sz; + clGetMemObjectInfo(output, CL_MEM_SIZE, sizeof(sz), &sz, NULL); + if (record & THNEED_DEBUG) printf("copying %lu for output %p -> %p\n", sz, output, foutput); + clEnqueueReadBuffer(command_queue, output, CL_TRUE, 0, sz, foutput, 0, NULL, NULL); + } else { + printf("CAUTION: model output is NULL, does it have no outputs?\n"); + } + + // ****** unset power constraint + constraint.type = KGSL_CONSTRAINT_NONE; + constraint.data = NULL; + constraint.size = 0; + + ret = ioctl(fd, IOCTL_KGSL_SETPROPERTY, &prop); + assert(ret == 0); + + if (record & THNEED_DEBUG) { + te = nanos_since_boot(); + printf("model exec in %lu us\n", (te-tb)/1000); + } +} + +void Thneed::clinit() { + cl_int err; + + cl_platform_id platform_id[2]; + cl_uint num_devices; + cl_uint num_platforms; + + err = clGetPlatformIDs(sizeof(platform_id)/sizeof(cl_platform_id), platform_id, &num_platforms); + assert(err == 0); + + err = clGetDeviceIDs(platform_id[0], CL_DEVICE_TYPE_DEFAULT, 1, &device_id, &num_devices); + assert(err == 0); + + context = clCreateContext(NULL, 1, &device_id, NULL, NULL, &err); + assert(err == 0); + + //cl_command_queue_properties props[3] = {CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE, 0}; + cl_command_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; + command_queue = clCreateCommandQueueWithProperties(context, device_id, props, &err); + assert(err == 0); + + printf("Thneed::clinit done\n"); +} + +cl_int Thneed::clexec() { + printf("Thneed::clexec: running %lu queued kernels\n", kq.size()); + for (auto &k : kq) { + if (record & THNEED_RECORD) ckq.push_back(k); + cl_int ret = k->exec(); + assert(ret == CL_SUCCESS); + } + return clFinish(command_queue); +} + +// *********** OpenCL interceptor *********** + +cl_int thneed_clSetKernelArg(cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value) { + g_args_size[make_pair(kernel, arg_index)] = arg_size; + if (arg_value != NULL) { + g_args[make_pair(kernel, arg_index)] = string((char*)arg_value, arg_size); + } else { + g_args[make_pair(kernel, arg_index)] = string(""); + } + cl_int ret = clSetKernelArg(kernel, arg_index, arg_size, arg_value); + return ret; +} + +cl_int thneed_clEnqueueNDRangeKernel(cl_command_queue command_queue, + cl_kernel kernel, + cl_uint work_dim, + const size_t *global_work_offset, + const size_t *global_work_size, + const size_t *local_work_size, + cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) { + + Thneed *thneed = g_thneed; + + // SNPE doesn't use these + assert(num_events_in_wait_list == 0); + assert(global_work_offset == NULL); + assert(event_wait_list == NULL); + + cl_int ret = 0; + if (thneed != NULL && thneed->record & THNEED_RECORD) { + if (thneed->context == NULL) { + thneed->command_queue = command_queue; + clGetKernelInfo(kernel, CL_KERNEL_CONTEXT, sizeof(thneed->context), &thneed->context, NULL); + clGetContextInfo(thneed->context, CL_CONTEXT_DEVICES, sizeof(thneed->device_id), &thneed->device_id, NULL); + } + + // if we are recording, we don't actually enqueue the kernel + thneed->kq.push_back(unique_ptr(new CLQueuedKernel(thneed, kernel, work_dim, global_work_size, local_work_size))); + *event = NULL; + } else { + ret = clEnqueueNDRangeKernel(command_queue, kernel, work_dim, + global_work_offset, global_work_size, local_work_size, + num_events_in_wait_list, event_wait_list, event); + } + + return ret; +} + +cl_int thneed_clFinish(cl_command_queue command_queue) { + Thneed *thneed = g_thneed; + + if (thneed != NULL && thneed->record & THNEED_RECORD) { + #ifdef RUN_OPTIMIZER + thneed->optimize(); + #endif + return thneed->clexec(); + } else { + return clFinish(command_queue); + } +} + +cl_program thneed_clCreateProgramWithSource(cl_context context, cl_uint count, const char **strings, const size_t *lengths, cl_int *errcode_ret) { + assert(count == 1); + cl_program ret = clCreateProgramWithSource(context, count, strings, lengths, errcode_ret); + g_program_source[ret] = strings[0]; + return ret; +} + +void *dlsym(void *handle, const char *symbol) { + // TODO: Find dlsym in a better way. Currently this is hand looked up in libdl.so +#if defined QCOM + void *(*my_dlsym)(void *handle, const char *symbol) = (void *(*)(void *handle, const char *symbol))((uintptr_t)dlopen-0x2d4); +#elif defined QCOM2 + void *(*my_dlsym)(void *handle, const char *symbol) = (void *(*)(void *handle, const char *symbol))((uintptr_t)dlopen+0x138); +#else + #error "Unsupported platform for thneed" +#endif + if (memcmp("REAL_", symbol, 5) == 0) { + return my_dlsym(handle, symbol+5); + } else if (strcmp("clFinish", symbol) == 0) { + return (void*)thneed_clFinish; + } else if (strcmp("clEnqueueNDRangeKernel", symbol) == 0) { + return (void*)thneed_clEnqueueNDRangeKernel; + } else if (strcmp("clSetKernelArg", symbol) == 0) { + return (void*)thneed_clSetKernelArg; + } else if (strcmp("clCreateProgramWithSource", symbol) == 0) { + return (void*)thneed_clCreateProgramWithSource; + } else { + return my_dlsym(handle, symbol); + } +} + +// *********** CLQueuedKernel *********** + +CLQueuedKernel::CLQueuedKernel(Thneed *lthneed, + cl_kernel _kernel, + cl_uint _work_dim, + const size_t *_global_work_size, + const size_t *_local_work_size) { + thneed = lthneed; + kernel = _kernel; + work_dim = _work_dim; + assert(work_dim <= 3); + for (int i = 0; i < work_dim; i++) { + global_work_size[i] = _global_work_size[i]; + local_work_size[i] = _local_work_size[i]; + } + + char _name[0x100]; + clGetKernelInfo(kernel, CL_KERNEL_FUNCTION_NAME, sizeof(_name), _name, NULL); + name = string(_name); + clGetKernelInfo(kernel, CL_KERNEL_NUM_ARGS, sizeof(num_args), &num_args, NULL); + + // get args + for (int i = 0; i < num_args; i++) { + char arg_name[0x100]; + clGetKernelArgInfo(kernel, i, CL_KERNEL_ARG_NAME, sizeof(arg_name), arg_name, NULL); + arg_names.push_back(string(arg_name)); + args.push_back(g_args[make_pair(kernel, i)]); + args_size.push_back(g_args_size[make_pair(kernel, i)]); + } + + // get program + clGetKernelInfo(kernel, CL_KERNEL_PROGRAM, sizeof(program), &program, NULL); +} + +int CLQueuedKernel::get_arg_num(const char *search_arg_name) { + for (int i = 0; i < num_args; i++) { + if (arg_names[i] == search_arg_name) return i; + } + printf("failed to find %s in %s\n", search_arg_name, name.c_str()); + assert(false); +} + +cl_int CLQueuedKernel::exec() { + if (kernel == NULL) { + kernel = clCreateKernel(program, name.c_str(), NULL); + arg_names.clear(); + + for (int j = 0; j < num_args; j++) { + char arg_name[0x100]; + clGetKernelArgInfo(kernel, j, CL_KERNEL_ARG_NAME, sizeof(arg_name), arg_name, NULL); + arg_names.push_back(string(arg_name)); + + cl_int ret; + if (args[j].size() != 0) { + assert(args[j].size() == args_size[j]); + ret = thneed_clSetKernelArg(kernel, j, args[j].size(), args[j].data()); + } else { + ret = thneed_clSetKernelArg(kernel, j, args_size[j], NULL); + } + assert(ret == CL_SUCCESS); + } + } + + // save the global inputs/outputs + if (thneed->record & THNEED_RECORD) { + for (int i = 0; i < num_args; i++) { + if (name == "zero_pad_image_float" && arg_names[i] == "input") { + thneed->inputs.push_back(*(cl_mem*)(args[i].data())); + } + + if (name == "image2d_to_buffer_float" && arg_names[i] == "output") { + thneed->output = *(cl_mem*)(args[i].data()); + } + } + } + + if (thneed->record & THNEED_DEBUG) { + debug_print(thneed->record & THNEED_VERBOSE_DEBUG); + } + + return clEnqueueNDRangeKernel(thneed->command_queue, + kernel, work_dim, NULL, global_work_size, local_work_size, 0, NULL, NULL); +} + +void CLQueuedKernel::debug_print(bool verbose) { + printf("%p %56s -- ", kernel, name.c_str()); + for (int i = 0; i < work_dim; i++) { + printf("%4zu ", global_work_size[i]); + } + printf(" -- "); + for (int i = 0; i < work_dim; i++) { + printf("%4zu ", local_work_size[i]); + } + printf("\n"); + + if (verbose) { + for (int i = 0; i < num_args; i++) { + char arg_type[0x100]; + clGetKernelArgInfo(kernel, i, CL_KERNEL_ARG_TYPE_NAME, sizeof(arg_type), arg_type, NULL); + string arg = args[i]; + printf(" %s %s", arg_type, arg_names[i].c_str()); + void *arg_value = (void*)arg.data(); + int arg_size = arg.size(); + if (arg_size == 0) { + printf(" (size) %d", args_size[i]); + } else if (arg_size == 1) { + printf(" = %d", *((char*)arg_value)); + } else if (arg_size == 2) { + printf(" = %d", *((short*)arg_value)); + } else if (arg_size == 4) { + if (strcmp(arg_type, "float") == 0) { + printf(" = %f", *((float*)arg_value)); + } else { + printf(" = %d", *((int*)arg_value)); + } + } else if (arg_size == 8) { + cl_mem val = (cl_mem)(*((uintptr_t*)arg_value)); + printf(" = %p", val); + if (val != NULL) { + if (strcmp("image2d_t", arg_type) == 0 || strcmp("image1d_t", arg_type) == 0) { + cl_image_format format; + size_t width, height, depth, array_size, row_pitch, slice_pitch; + cl_mem buf; + clGetImageInfo(val, CL_IMAGE_FORMAT, sizeof(format), &format, NULL); + assert(format.image_channel_order == CL_RGBA); + assert(format.image_channel_data_type == CL_HALF_FLOAT); + clGetImageInfo(val, CL_IMAGE_WIDTH, sizeof(width), &width, NULL); + clGetImageInfo(val, CL_IMAGE_HEIGHT, sizeof(height), &height, NULL); + clGetImageInfo(val, CL_IMAGE_ROW_PITCH, sizeof(row_pitch), &row_pitch, NULL); + clGetImageInfo(val, CL_IMAGE_DEPTH, sizeof(depth), &depth, NULL); + clGetImageInfo(val, CL_IMAGE_ARRAY_SIZE, sizeof(array_size), &array_size, NULL); + clGetImageInfo(val, CL_IMAGE_SLICE_PITCH, sizeof(slice_pitch), &slice_pitch, NULL); + assert(depth == 0); + assert(array_size == 0); + assert(slice_pitch == 0); + + clGetImageInfo(val, CL_IMAGE_BUFFER, sizeof(buf), &buf, NULL); + size_t sz; + clGetMemObjectInfo(buf, CL_MEM_SIZE, sizeof(sz), &sz, NULL); + printf(" image %zu x %zu rp %zu @ %p buffer %zu", width, height, row_pitch, buf, sz); + } else { + size_t sz; + clGetMemObjectInfo(val, CL_MEM_SIZE, sizeof(sz), &sz, NULL); + printf(" buffer %zu", sz); + } + } + } + printf("\n"); + } + } +} + diff --git a/selfdrive/modeld/thneed/thneed.h b/selfdrive/modeld/thneed/thneed.h new file mode 100644 index 00000000000000..e1039efdff229d --- /dev/null +++ b/selfdrive/modeld/thneed/thneed.h @@ -0,0 +1,113 @@ +#pragma once + +#ifndef __user + #define __user __attribute__(()) +#endif + +#include +#include +#include "include/msm_kgsl.h" +#include +#include +#include +#include + +#define THNEED_RECORD 1 +#define THNEED_DEBUG 2 +#define THNEED_VERBOSE_DEBUG 4 + +using namespace std; + +namespace json11 { + class Json; +} +class Thneed; + +class GPUMalloc { + public: + GPUMalloc(int size, int fd); + ~GPUMalloc(); + void *alloc(int size); + private: + uint64_t base; + int remaining; +}; + +class CLQueuedKernel { + public: + CLQueuedKernel(Thneed *lthneed) { thneed = lthneed; } + CLQueuedKernel(Thneed *lthneed, + cl_kernel _kernel, + cl_uint _work_dim, + const size_t *_global_work_size, + const size_t *_local_work_size); + cl_int exec(); + void debug_print(bool verbose); + int get_arg_num(const char *search_arg_name); + cl_program program; + string name; + cl_uint num_args; + vector arg_names; + vector args; + vector args_size; + cl_kernel kernel = NULL; + json11::Json to_json() const; + + cl_uint work_dim; + size_t global_work_size[3] = {0}; + size_t local_work_size[3] = {0}; + private: + Thneed *thneed; +}; + +class CachedCommand { + public: + CachedCommand(Thneed *lthneed, struct kgsl_gpu_command *cmd); + void exec(bool wait); + void disassemble(int cmd_index); + private: + struct kgsl_gpu_command cache; + unique_ptr cmds; + unique_ptr objs; + Thneed *thneed; + vector > kq; +}; + +class Thneed { + public: + Thneed(bool do_clinit=false); + void stop(); + void execute(float **finputs, float *foutput, bool slow=false); + int optimize(); + + vector inputs; + cl_mem output = NULL; + + cl_context context = NULL; + cl_command_queue command_queue; + cl_device_id device_id; + int context_id; + + // protected? + int record; + int timestamp; + unique_ptr ram; + vector > cmds; + vector syncobjs; + int fd; + + // all CL kernels + cl_int clexec(); + vector > kq; + + // pending CL kernels + vector > ckq; + + // loading and saving + void load(const char *filename); + void save(const char *filename); + private: + void clinit(); + json11::Json to_json(); +}; + diff --git a/selfdrive/modeld/transforms/loadyuv.cc b/selfdrive/modeld/transforms/loadyuv.cc new file mode 100644 index 00000000000000..fe84e6d27ded9c --- /dev/null +++ b/selfdrive/modeld/transforms/loadyuv.cc @@ -0,0 +1,58 @@ +#include +#include +#include "loadyuv.h" + +void loadyuv_init(LoadYUVState* s, cl_context ctx, cl_device_id device_id, int width, int height) { + memset(s, 0, sizeof(*s)); + + s->width = width; + s->height = height; + + char args[1024]; + snprintf(args, sizeof(args), + "-cl-fast-relaxed-math -cl-denorms-are-zero " + "-DTRANSFORMED_WIDTH=%d -DTRANSFORMED_HEIGHT=%d", + width, height); + cl_program prg = cl_program_from_file(ctx, device_id, "transforms/loadyuv.cl", args); + + s->loadys_krnl = CL_CHECK_ERR(clCreateKernel(prg, "loadys", &err)); + s->loaduv_krnl = CL_CHECK_ERR(clCreateKernel(prg, "loaduv", &err)); + + // done with this + CL_CHECK(clReleaseProgram(prg)); +} + +void loadyuv_destroy(LoadYUVState* s) { + CL_CHECK(clReleaseKernel(s->loadys_krnl)); + CL_CHECK(clReleaseKernel(s->loaduv_krnl)); +} + +void loadyuv_queue(LoadYUVState* s, cl_command_queue q, + cl_mem y_cl, cl_mem u_cl, cl_mem v_cl, + cl_mem out_cl) { + CL_CHECK(clSetKernelArg(s->loadys_krnl, 0, sizeof(cl_mem), &y_cl)); + CL_CHECK(clSetKernelArg(s->loadys_krnl, 1, sizeof(cl_mem), &out_cl)); + + const size_t loadys_work_size = (s->width*s->height)/8; + CL_CHECK(clEnqueueNDRangeKernel(q, s->loadys_krnl, 1, NULL, + &loadys_work_size, NULL, 0, 0, NULL)); + + const size_t loaduv_work_size = ((s->width/2)*(s->height/2))/8; + cl_int loaduv_out_off = (s->width*s->height); + + CL_CHECK(clSetKernelArg(s->loaduv_krnl, 0, sizeof(cl_mem), &u_cl)); + CL_CHECK(clSetKernelArg(s->loaduv_krnl, 1, sizeof(cl_mem), &out_cl)); + CL_CHECK(clSetKernelArg(s->loaduv_krnl, 2, sizeof(cl_int), &loaduv_out_off)); + + CL_CHECK(clEnqueueNDRangeKernel(q, s->loaduv_krnl, 1, NULL, + &loaduv_work_size, NULL, 0, 0, NULL)); + + loaduv_out_off += (s->width/2)*(s->height/2); + + CL_CHECK(clSetKernelArg(s->loaduv_krnl, 0, sizeof(cl_mem), &v_cl)); + CL_CHECK(clSetKernelArg(s->loaduv_krnl, 1, sizeof(cl_mem), &out_cl)); + CL_CHECK(clSetKernelArg(s->loaduv_krnl, 2, sizeof(cl_int), &loaduv_out_off)); + + CL_CHECK(clEnqueueNDRangeKernel(q, s->loaduv_krnl, 1, NULL, + &loaduv_work_size, NULL, 0, 0, NULL)); +} diff --git a/selfdrive/visiond/transforms/loadyuv.cl b/selfdrive/modeld/transforms/loadyuv.cl similarity index 84% rename from selfdrive/visiond/transforms/loadyuv.cl rename to selfdrive/modeld/transforms/loadyuv.cl index e015429156ce91..fc7655b568347a 100644 --- a/selfdrive/visiond/transforms/loadyuv.cl +++ b/selfdrive/modeld/transforms/loadyuv.cl @@ -9,9 +9,7 @@ __kernel void loadys(__global uchar8 const * const Y, const int ox = ois % TRANSFORMED_WIDTH; const uchar8 ys = Y[gid]; - - // y = (x - 128) / 128 - const float8 ysf = (convert_float8(ys) - 128.f) * 0.0078125f; + const float8 ysf = convert_float8(ys); // 02 // 13 @@ -36,8 +34,6 @@ __kernel void loaduv(__global uchar8 const * const in, { const int gid = get_global_id(0); const uchar8 inv = in[gid]; - - // y = (x - 128) / 128 - const float8 outv = (convert_float8(inv) - 128.f) * 0.0078125f; + const float8 outv = convert_float8(inv); out[gid + out_offset / 8] = outv; } diff --git a/selfdrive/modeld/transforms/loadyuv.h b/selfdrive/modeld/transforms/loadyuv.h new file mode 100644 index 00000000000000..dbef4614944f27 --- /dev/null +++ b/selfdrive/modeld/transforms/loadyuv.h @@ -0,0 +1,18 @@ +#pragma once + +#include +#include +#include "clutil.h" + +typedef struct { + int width, height; + cl_kernel loadys_krnl, loaduv_krnl; +} LoadYUVState; + +void loadyuv_init(LoadYUVState* s, cl_context ctx, cl_device_id device_id, int width, int height); + +void loadyuv_destroy(LoadYUVState* s); + +void loadyuv_queue(LoadYUVState* s, cl_command_queue q, + cl_mem y_cl, cl_mem u_cl, cl_mem v_cl, + cl_mem out_cl); diff --git a/selfdrive/modeld/transforms/transform.cc b/selfdrive/modeld/transforms/transform.cc new file mode 100644 index 00000000000000..3ea799499fa3db --- /dev/null +++ b/selfdrive/modeld/transforms/transform.cc @@ -0,0 +1,95 @@ +#include +#include + +#include "clutil.h" + +#include "transform.h" + +void transform_init(Transform* s, cl_context ctx, cl_device_id device_id) { + memset(s, 0, sizeof(*s)); + + cl_program prg = cl_program_from_file(ctx, device_id, "transforms/transform.cl", ""); + s->krnl = CL_CHECK_ERR(clCreateKernel(prg, "warpPerspective", &err)); + // done with this + CL_CHECK(clReleaseProgram(prg)); + + s->m_y_cl = CL_CHECK_ERR(clCreateBuffer(ctx, CL_MEM_READ_WRITE, 3*3*sizeof(float), NULL, &err)); + s->m_uv_cl = CL_CHECK_ERR(clCreateBuffer(ctx, CL_MEM_READ_WRITE, 3*3*sizeof(float), NULL, &err)); +} + +void transform_destroy(Transform* s) { + CL_CHECK(clReleaseMemObject(s->m_y_cl)); + CL_CHECK(clReleaseMemObject(s->m_uv_cl)); + CL_CHECK(clReleaseKernel(s->krnl)); +} + +void transform_queue(Transform* s, + cl_command_queue q, + cl_mem in_yuv, int in_width, int in_height, + cl_mem out_y, cl_mem out_u, cl_mem out_v, + int out_width, int out_height, + mat3 projection) { + const int zero = 0; + + // sampled using pixel center origin + // (because thats how fastcv and opencv does it) + + mat3 projection_y = projection; + + // in and out uv is half the size of y. + mat3 projection_uv = transform_scale_buffer(projection, 0.5); + + CL_CHECK(clEnqueueWriteBuffer(q, s->m_y_cl, CL_TRUE, 0, 3*3*sizeof(float), (void*)projection_y.v, 0, NULL, NULL)); + CL_CHECK(clEnqueueWriteBuffer(q, s->m_uv_cl, CL_TRUE, 0, 3*3*sizeof(float), (void*)projection_uv.v, 0, NULL, NULL)); + + const int in_y_width = in_width; + const int in_y_height = in_height; + const int in_uv_width = in_width/2; + const int in_uv_height = in_height/2; + const int in_y_offset = 0; + const int in_u_offset = in_y_offset + in_y_width*in_y_height; + const int in_v_offset = in_u_offset + in_uv_width*in_uv_height; + + const int out_y_width = out_width; + const int out_y_height = out_height; + const int out_uv_width = out_width/2; + const int out_uv_height = out_height/2; + + CL_CHECK(clSetKernelArg(s->krnl, 0, sizeof(cl_mem), &in_yuv)); + CL_CHECK(clSetKernelArg(s->krnl, 1, sizeof(cl_int), &in_y_width)); + CL_CHECK(clSetKernelArg(s->krnl, 2, sizeof(cl_int), &in_y_offset)); + CL_CHECK(clSetKernelArg(s->krnl, 3, sizeof(cl_int), &in_y_height)); + CL_CHECK(clSetKernelArg(s->krnl, 4, sizeof(cl_int), &in_y_width)); + CL_CHECK(clSetKernelArg(s->krnl, 5, sizeof(cl_mem), &out_y)); + CL_CHECK(clSetKernelArg(s->krnl, 6, sizeof(cl_int), &out_y_width)); + CL_CHECK(clSetKernelArg(s->krnl, 7, sizeof(cl_int), &zero)); + CL_CHECK(clSetKernelArg(s->krnl, 8, sizeof(cl_int), &out_y_height)); + CL_CHECK(clSetKernelArg(s->krnl, 9, sizeof(cl_int), &out_y_width)); + CL_CHECK(clSetKernelArg(s->krnl, 10, sizeof(cl_mem), &s->m_y_cl)); + + const size_t work_size_y[2] = {(size_t)out_y_width, (size_t)out_y_height}; + + CL_CHECK(clEnqueueNDRangeKernel(q, s->krnl, 2, NULL, + (const size_t*)&work_size_y, NULL, 0, 0, NULL)); + + const size_t work_size_uv[2] = {(size_t)out_uv_width, (size_t)out_uv_height}; + + CL_CHECK(clSetKernelArg(s->krnl, 1, sizeof(cl_int), &in_uv_width)); + CL_CHECK(clSetKernelArg(s->krnl, 2, sizeof(cl_int), &in_u_offset)); + CL_CHECK(clSetKernelArg(s->krnl, 3, sizeof(cl_int), &in_uv_height)); + CL_CHECK(clSetKernelArg(s->krnl, 4, sizeof(cl_int), &in_uv_width)); + CL_CHECK(clSetKernelArg(s->krnl, 5, sizeof(cl_mem), &out_u)); + CL_CHECK(clSetKernelArg(s->krnl, 6, sizeof(cl_int), &out_uv_width)); + CL_CHECK(clSetKernelArg(s->krnl, 7, sizeof(cl_int), &zero)); + CL_CHECK(clSetKernelArg(s->krnl, 8, sizeof(cl_int), &out_uv_height)); + CL_CHECK(clSetKernelArg(s->krnl, 9, sizeof(cl_int), &out_uv_width)); + CL_CHECK(clSetKernelArg(s->krnl, 10, sizeof(cl_mem), &s->m_uv_cl)); + + CL_CHECK(clEnqueueNDRangeKernel(q, s->krnl, 2, NULL, + (const size_t*)&work_size_uv, NULL, 0, 0, NULL)); + CL_CHECK(clSetKernelArg(s->krnl, 2, sizeof(cl_int), &in_v_offset)); + CL_CHECK(clSetKernelArg(s->krnl, 5, sizeof(cl_mem), &out_v)); + + CL_CHECK(clEnqueueNDRangeKernel(q, s->krnl, 2, NULL, + (const size_t*)&work_size_uv, NULL, 0, 0, NULL)); +} diff --git a/selfdrive/visiond/transforms/transform.cl b/selfdrive/modeld/transforms/transform.cl similarity index 100% rename from selfdrive/visiond/transforms/transform.cl rename to selfdrive/modeld/transforms/transform.cl diff --git a/selfdrive/visiond/transforms/transform.h b/selfdrive/modeld/transforms/transform.h similarity index 82% rename from selfdrive/visiond/transforms/transform.h rename to selfdrive/modeld/transforms/transform.h index 3854be9da62db6..21933f4d1faa5b 100644 --- a/selfdrive/visiond/transforms/transform.h +++ b/selfdrive/modeld/transforms/transform.h @@ -1,9 +1,9 @@ -#ifndef TRANSFORM_H -#define TRANSFORM_H +#pragma once #include #include +#define CL_USE_DEPRECATED_OPENCL_1_2_APIS #ifdef __APPLE__ #include #else @@ -12,10 +12,6 @@ #include "common/mat.h" -#ifdef __cplusplus -extern "C" { -#endif - typedef struct { cl_kernel krnl; cl_mem m_y_cl, m_uv_cl; @@ -30,9 +26,3 @@ void transform_queue(Transform* s, cl_command_queue q, cl_mem out_y, cl_mem out_u, cl_mem out_v, int out_width, int out_height, mat3 projection); - -#ifdef __cplusplus -} -#endif - -#endif // TRANSFORM_H diff --git a/selfdrive/monitoring/dmonitoringd.py b/selfdrive/monitoring/dmonitoringd.py new file mode 100755 index 00000000000000..f60ad2624ec4f1 --- /dev/null +++ b/selfdrive/monitoring/dmonitoringd.py @@ -0,0 +1,124 @@ +#!/usr/bin/env python3 +from cereal import car +from common.params import Params +import cereal.messaging as messaging +from selfdrive.controls.lib.events import Events +from selfdrive.monitoring.driver_monitor import DriverStatus, MAX_TERMINAL_ALERTS, MAX_TERMINAL_DURATION +from selfdrive.locationd.calibrationd import Calibration + +from selfdrive.monitoring.driver_monitor import DriverPose, DriverBlink +from selfdrive.car.tesla.readconfig import CarSettings +from common.realtime import DT_DMON +class MockDriverStatus(): + def __init__(self): + self.pose = DriverPose() + self.blink = DriverBlink() + self.awareness = 1. + self.awareness_active = 1. + self.awareness_passive = 1. + self.driver_distracted = False + self.face_detected = True + self.terminal_alert_cnt = 0 + self.terminal_time = 0 + self.step_change = DT_DMON / 11. + self.hi_stds = 0 + self.is_rhd_region = False + def _set_timers(self, active_monitoring): + pass + def _is_driver_distracted(self, pose, blink): + return DistractedType.NOT_DISTRACTED + def set_policy(self, model_data): + pass + def get_pose(self, driver_state, cal_rpy, car_speed, op_engaged): + pass + def update(self, events, driver_engaged, ctrl_active, standstill): + pass + + +def dmonitoringd_thread(sm=None, pm=None): + if pm is None: + pm = messaging.PubMaster(['dMonitoringState']) + + if sm is None: + sm = messaging.SubMaster(['driverState', 'liveCalibration', 'carState', 'controlsState', 'model'], poll=['driverState']) + + is_dm_enabled = CarSettings().get_value("enableDriverMonitor") + if is_dm_enabled: + driver_status = DriverStatus() + driver_status.is_rhd_region = Params().get("IsRHD") == b"1" + else: + driver_status = MockDriverStatus() + + offroad = Params().get("IsOffroad") == b"1" + + sm['liveCalibration'].calStatus = Calibration.INVALID + sm['liveCalibration'].rpyCalib = [0, 0, 0] + sm['carState'].vEgo = 0. + sm['carState'].cruiseState.speed = 0. + sm['carState'].buttonEvents = [] + sm['carState'].steeringPressed = False + sm['carState'].gasPressed = False + sm['carState'].standstill = True + + v_cruise_last = 0 + driver_engaged = False + + # 10Hz <- dmonitoringmodeld + while True: + sm.update() + + if not sm.updated['driverState']: + continue + + # Get interaction + if sm.updated['carState']: + v_cruise = sm['carState'].cruiseState.speed + driver_engaged = len(sm['carState'].buttonEvents) > 0 or \ + v_cruise != v_cruise_last or \ + sm['carState'].steeringPressed or \ + sm['carState'].gasPressed or \ + not is_dm_enabled + if driver_engaged: + driver_status.update(Events(), True, sm['controlsState'].enabled, sm['carState'].standstill) + v_cruise_last = v_cruise + + if sm.updated['model']: + driver_status.set_policy(sm['model']) + + # Get data from dmonitoringmodeld + events = Events() + driver_status.get_pose(sm['driverState'], sm['liveCalibration'].rpyCalib, sm['carState'].vEgo, sm['controlsState'].enabled) + + # Block engaging after max number of distrations + if driver_status.terminal_alert_cnt >= MAX_TERMINAL_ALERTS or driver_status.terminal_time >= MAX_TERMINAL_DURATION: + events.add(car.CarEvent.EventName.tooDistracted) + + # Update events from driver state + driver_status.update(events, driver_engaged, sm['controlsState'].enabled, sm['carState'].standstill) + + # build dMonitoringState packet + dat = messaging.new_message('dMonitoringState') + dat.dMonitoringState = { + "events": events.to_msg(), + "faceDetected": driver_status.face_detected, + "isDistracted": driver_status.driver_distracted, + "awarenessStatus": driver_status.awareness, + "isRHD": driver_status.is_rhd_region, + "posePitchOffset": driver_status.pose.pitch_offseter.filtered_stat.mean(), + "posePitchValidCount": driver_status.pose.pitch_offseter.filtered_stat.n, + "poseYawOffset": driver_status.pose.yaw_offseter.filtered_stat.mean(), + "poseYawValidCount": driver_status.pose.yaw_offseter.filtered_stat.n, + "stepChange": driver_status.step_change, + "awarenessActive": driver_status.awareness_active, + "awarenessPassive": driver_status.awareness_passive, + "isLowStd": driver_status.pose.low_std, + "hiStdCount": driver_status.hi_stds, + "isPreview": offroad, + } + pm.send('dMonitoringState', dat) + +def main(sm=None, pm=None): + dmonitoringd_thread(sm, pm) + +if __name__ == '__main__': + main() diff --git a/selfdrive/monitoring/driver_monitor.py b/selfdrive/monitoring/driver_monitor.py new file mode 100644 index 00000000000000..33005e19c6eb00 --- /dev/null +++ b/selfdrive/monitoring/driver_monitor.py @@ -0,0 +1,266 @@ +from common.numpy_fast import interp +from math import atan2, sqrt +from common.realtime import DT_DMON +from common.filter_simple import FirstOrderFilter +from common.stat_live import RunningStatFilter + +from cereal import car + +EventName = car.CarEvent.EventName + +# ****************************************************************************************** +# NOTE: To fork maintainers. +# Disabling or nerfing safety features may get you and your users banned from our servers. +# We recommend that you do not change these numbers from the defaults. +# ****************************************************************************************** + +_AWARENESS_TIME = 35. # passive wheel touch total timeout +_AWARENESS_PRE_TIME_TILL_TERMINAL = 12. +_AWARENESS_PROMPT_TIME_TILL_TERMINAL = 6. +_DISTRACTED_TIME = 11. +_DISTRACTED_PRE_TIME_TILL_TERMINAL = 8. +_DISTRACTED_PROMPT_TIME_TILL_TERMINAL = 6. + +_FACE_THRESHOLD = 0.6 +_EYE_THRESHOLD = 0.6 +_SG_THRESHOLD = 0.5 +_BLINK_THRESHOLD = 0.5 +_BLINK_THRESHOLD_SLACK = 0.65 +_BLINK_THRESHOLD_STRICT = 0.5 +_PITCH_WEIGHT = 1.35 # pitch matters a lot more +_POSESTD_THRESHOLD = 0.14 +_METRIC_THRESHOLD = 0.4 +_METRIC_THRESHOLD_SLACK = 0.55 +_METRIC_THRESHOLD_STRICT = 0.4 +_PITCH_POS_ALLOWANCE = 0.12 # rad, to not be too sensitive on positive pitch +_PITCH_NATURAL_OFFSET = 0.02 # people don't seem to look straight when they drive relaxed, rather a bit up +_YAW_NATURAL_OFFSET = 0.08 # people don't seem to look straight when they drive relaxed, rather a bit to the right (center of car) + +_HI_STD_TIMEOUT = 5 +_HI_STD_FALLBACK_TIME = 10 # fall back to wheel touch if model is uncertain for a long time +_DISTRACTED_FILTER_TS = 0.25 # 0.6Hz + +_POSE_CALIB_MIN_SPEED = 13 # 30 mph +_POSE_OFFSET_MIN_COUNT = 600 # valid data counts before calibration completes, 1 seg is 600 counts +_POSE_OFFSET_MAX_COUNT = 3600 # stop deweighting new data after 6 min, aka "short term memory" + +_RECOVERY_FACTOR_MAX = 5. # relative to minus step change +_RECOVERY_FACTOR_MIN = 1.25 # relative to minus step change + +MAX_TERMINAL_ALERTS = 3 # not allowed to engage after 3 terminal alerts +MAX_TERMINAL_DURATION = 300 # 30s + +# model output refers to center of cropped image, so need to apply the x displacement offset +RESIZED_FOCAL = 320.0 +H, W, FULL_W = 320, 160, 426 + +class DistractedType(): + NOT_DISTRACTED = 0 + BAD_POSE = 1 + BAD_BLINK = 2 + +def face_orientation_from_net(angles_desc, pos_desc, rpy_calib, is_rhd): + # the output of these angles are in device frame + # so from driver's perspective, pitch is up and yaw is right + + pitch_net = angles_desc[0] + yaw_net = angles_desc[1] + roll_net = angles_desc[2] + + face_pixel_position = ((pos_desc[0] + .5)*W - W + FULL_W, (pos_desc[1]+.5)*H) + yaw_focal_angle = atan2(face_pixel_position[0] - FULL_W//2, RESIZED_FOCAL) + pitch_focal_angle = atan2(face_pixel_position[1] - H//2, RESIZED_FOCAL) + + roll = roll_net + pitch = pitch_net + pitch_focal_angle + yaw = -yaw_net + yaw_focal_angle + + # no calib for roll + pitch -= rpy_calib[1] + yaw -= rpy_calib[2] * (1 - 2 * int(is_rhd)) # lhd -> -=, rhd -> += + return roll, pitch, yaw + +class DriverPose(): + def __init__(self): + self.yaw = 0. + self.pitch = 0. + self.roll = 0. + self.yaw_std = 0. + self.pitch_std = 0. + self.roll_std = 0. + self.pitch_offseter = RunningStatFilter(max_trackable=_POSE_OFFSET_MAX_COUNT) + self.yaw_offseter = RunningStatFilter(max_trackable=_POSE_OFFSET_MAX_COUNT) + self.low_std = True + self.cfactor = 1. + +class DriverBlink(): + def __init__(self): + self.left_blink = 0. + self.right_blink = 0. + self.cfactor = 1. + +class DriverStatus(): + def __init__(self): + self.pose = DriverPose() + self.pose_calibrated = self.pose.pitch_offseter.filtered_stat.n > _POSE_OFFSET_MIN_COUNT and \ + self.pose.yaw_offseter.filtered_stat.n > _POSE_OFFSET_MIN_COUNT + self.blink = DriverBlink() + self.awareness = 1. + self.awareness_active = 1. + self.awareness_passive = 1. + self.driver_distracted = False + self.driver_distraction_filter = FirstOrderFilter(0., _DISTRACTED_FILTER_TS, DT_DMON) + self.face_detected = False + self.terminal_alert_cnt = 0 + self.terminal_time = 0 + self.step_change = 0. + self.active_monitoring_mode = True + self.hi_stds = 0 + self.hi_std_alert_enabled = True + self.threshold_prompt = _DISTRACTED_PROMPT_TIME_TILL_TERMINAL / _DISTRACTED_TIME + + self.is_rhd_region = False + self.is_rhd_region_checked = False + + self._set_timers(active_monitoring=True) + + def _set_timers(self, active_monitoring): + if self.active_monitoring_mode and self.awareness <= self.threshold_prompt: + if active_monitoring: + self.step_change = DT_DMON / _DISTRACTED_TIME + else: + self.step_change = 0. + return # no exploit after orange alert + elif self.awareness <= 0.: + return + + if active_monitoring: + # when falling back from passive mode to active mode, reset awareness to avoid false alert + if not self.active_monitoring_mode: + self.awareness_passive = self.awareness + self.awareness = self.awareness_active + + self.threshold_pre = _DISTRACTED_PRE_TIME_TILL_TERMINAL / _DISTRACTED_TIME + self.threshold_prompt = _DISTRACTED_PROMPT_TIME_TILL_TERMINAL / _DISTRACTED_TIME + self.step_change = DT_DMON / _DISTRACTED_TIME + self.active_monitoring_mode = True + else: + if self.active_monitoring_mode: + self.awareness_active = self.awareness + self.awareness = self.awareness_passive + + self.threshold_pre = _AWARENESS_PRE_TIME_TILL_TERMINAL / _AWARENESS_TIME + self.threshold_prompt = _AWARENESS_PROMPT_TIME_TILL_TERMINAL / _AWARENESS_TIME + self.step_change = DT_DMON / _AWARENESS_TIME + self.active_monitoring_mode = False + + def _is_driver_distracted(self, pose, blink): + if not self.pose_calibrated: + pitch_error = pose.pitch - _PITCH_NATURAL_OFFSET + yaw_error = pose.yaw - _YAW_NATURAL_OFFSET + else: + pitch_error = pose.pitch - self.pose.pitch_offseter.filtered_stat.mean() + yaw_error = pose.yaw - self.pose.yaw_offseter.filtered_stat.mean() + + # positive pitch allowance + if pitch_error > 0.: + pitch_error = max(pitch_error - _PITCH_POS_ALLOWANCE, 0.) + pitch_error *= _PITCH_WEIGHT + pose_metric = sqrt(yaw_error**2 + pitch_error**2) + + if pose_metric > _METRIC_THRESHOLD*pose.cfactor: + return DistractedType.BAD_POSE + elif (blink.left_blink + blink.right_blink)*0.5 > _BLINK_THRESHOLD*blink.cfactor: + return DistractedType.BAD_BLINK + else: + return DistractedType.NOT_DISTRACTED + + def set_policy(self, model_data): + ep = min(model_data.meta.engagedProb, 0.8) / 0.8 + self.pose.cfactor = interp(ep, [0, 0.5, 1], [_METRIC_THRESHOLD_STRICT, _METRIC_THRESHOLD, _METRIC_THRESHOLD_SLACK])/_METRIC_THRESHOLD + self.blink.cfactor = interp(ep, [0, 0.5, 1], [_BLINK_THRESHOLD_STRICT, _BLINK_THRESHOLD, _BLINK_THRESHOLD_SLACK])/_BLINK_THRESHOLD + + def get_pose(self, driver_state, cal_rpy, car_speed, op_engaged): + # 10 Hz + if len(driver_state.faceOrientation) == 0 or len(driver_state.facePosition) == 0 or len(driver_state.faceOrientationStd) == 0 or len(driver_state.facePositionStd) == 0: + return + + self.pose.roll, self.pose.pitch, self.pose.yaw = face_orientation_from_net(driver_state.faceOrientation, driver_state.facePosition, cal_rpy, self.is_rhd_region) + self.pose.pitch_std = driver_state.faceOrientationStd[0] + self.pose.yaw_std = driver_state.faceOrientationStd[1] + # self.pose.roll_std = driver_state.faceOrientationStd[2] + model_std_max = max(self.pose.pitch_std, self.pose.yaw_std) + self.pose.low_std = model_std_max < _POSESTD_THRESHOLD + self.blink.left_blink = driver_state.leftBlinkProb * (driver_state.leftEyeProb > _EYE_THRESHOLD) * (driver_state.sgProb < _SG_THRESHOLD) + self.blink.right_blink = driver_state.rightBlinkProb * (driver_state.rightEyeProb > _EYE_THRESHOLD) * (driver_state.sgProb < _SG_THRESHOLD) + self.face_detected = driver_state.faceProb > _FACE_THRESHOLD and \ + abs(driver_state.facePosition[0]) <= 0.4 and abs(driver_state.facePosition[1]) <= 0.45 + + self.driver_distracted = self._is_driver_distracted(self.pose, self.blink) > 0 + # first order filters + self.driver_distraction_filter.update(self.driver_distracted) + + # update offseter + # only update when driver is actively driving the car above a certain speed + if self.face_detected and car_speed > _POSE_CALIB_MIN_SPEED and self.pose.low_std and (not op_engaged or not self.driver_distracted): + self.pose.pitch_offseter.push_and_update(self.pose.pitch) + self.pose.yaw_offseter.push_and_update(self.pose.yaw) + + self.pose_calibrated = self.pose.pitch_offseter.filtered_stat.n > _POSE_OFFSET_MIN_COUNT and \ + self.pose.yaw_offseter.filtered_stat.n > _POSE_OFFSET_MIN_COUNT + + is_model_uncertain = self.hi_stds * DT_DMON > _HI_STD_FALLBACK_TIME + self._set_timers(self.face_detected and not is_model_uncertain) + if self.face_detected and not self.pose.low_std: + if not is_model_uncertain: + self.step_change *= min(1.0, max(0.6, 1.6*(model_std_max-0.5)*(model_std_max-2))) + self.hi_stds += 1 + elif self.face_detected and self.pose.low_std: + self.hi_stds = 0 + + def update(self, events, driver_engaged, ctrl_active, standstill): + if (driver_engaged and self.awareness > 0) or not ctrl_active: + # reset only when on disengagement if red reached + self.awareness = 1. + self.awareness_active = 1. + self.awareness_passive = 1. + return + + driver_attentive = self.driver_distraction_filter.x < 0.37 + awareness_prev = self.awareness + + if self.face_detected and self.hi_stds * DT_DMON > _HI_STD_TIMEOUT and self.hi_std_alert_enabled: + events.add(EventName.driverMonitorLowAcc) + self.hi_std_alert_enabled = False # only showed once until orange prompt resets it + + if (driver_attentive and self.face_detected and self.pose.low_std and self.awareness > 0): + # only restore awareness when paying attention and alert is not red + self.awareness = min(self.awareness + ((_RECOVERY_FACTOR_MAX-_RECOVERY_FACTOR_MIN)*(1.-self.awareness)+_RECOVERY_FACTOR_MIN)*self.step_change, 1.) + if self.awareness == 1.: + self.awareness_passive = min(self.awareness_passive + self.step_change, 1.) + # don't display alert banner when awareness is recovering and has cleared orange + if self.awareness > self.threshold_prompt: + return + + # should always be counting if distracted unless at standstill and reaching orange + if (not (self.face_detected and self.hi_stds * DT_DMON <= _HI_STD_FALLBACK_TIME) or (self.driver_distraction_filter.x > 0.63 and self.driver_distracted and self.face_detected)) and \ + not (standstill and self.awareness - self.step_change <= self.threshold_prompt): + self.awareness = max(self.awareness - self.step_change, -0.1) + + alert = None + if self.awareness <= 0.: + # terminal red alert: disengagement required + alert = EventName.driverDistracted if self.active_monitoring_mode else EventName.driverUnresponsive + self.hi_std_alert_enabled = True + self.terminal_time += 1 + if awareness_prev > 0.: + self.terminal_alert_cnt += 1 + elif self.awareness <= self.threshold_prompt: + # prompt orange alert + alert = EventName.promptDriverDistracted if self.active_monitoring_mode else EventName.promptDriverUnresponsive + elif self.awareness <= self.threshold_pre: + # pre green alert + alert = EventName.preDriverDistracted if self.active_monitoring_mode else EventName.preDriverUnresponsive + + if alert is not None: + events.add(alert) diff --git a/selfdrive/pandad.py b/selfdrive/pandad.py index 0f742bd2e22832..311b9a74fe4e4b 100755 --- a/selfdrive/pandad.py +++ b/selfdrive/pandad.py @@ -1,17 +1,56 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # simple boardd wrapper that updates the panda first import os import time +from panda import BASEDIR, Panda, PandaDFU, build_st +from common.gpio import gpio_init, gpio_set +from selfdrive.hardware import TICI +from selfdrive.hardware.tici.pins import GPIO_HUB_RST_N, GPIO_STM_BOOT0, GPIO_STM_RST_N from selfdrive.swaglog import cloudlog -from panda import Panda, PandaDFU, BASEDIR +def is_legacy_panda_reset(): + return os.path.isfile("/persist/LEGACY_PANDA_RESET") + +def set_panda_power(power=True): + if not TICI: + return + + gpio_init(GPIO_STM_RST_N, True) + gpio_init(GPIO_STM_BOOT0, True) + + gpio_set(GPIO_STM_RST_N, False if is_legacy_panda_reset() else True) + gpio_set(GPIO_HUB_RST_N, True) + + time.sleep(0.1) + + gpio_set(GPIO_STM_RST_N, power if is_legacy_panda_reset() else (not power)) + + +def get_firmware_fn(): + signed_fn = os.path.join(BASEDIR, "board", "obj", "panda.bin.signed") + if os.path.exists(signed_fn): + cloudlog.info("Using prebuilt signed firmware") + return signed_fn + else: + cloudlog.info("Building panda firmware") + fn = "obj/panda.bin" + build_st(fn, clean=False) + return os.path.join(BASEDIR, "board", fn) -def update_panda(): - with open(os.path.join(BASEDIR, "VERSION")) as f: - repo_version = f.read() - repo_version += "-EON" if os.path.isfile('/EON') else "-DEV" +def get_expected_signature(fw_fn=None): + if fw_fn is None: + fw_fn = get_firmware_fn() + + try: + return Panda.get_signature_from_firmware(fw_fn) + except Exception: + cloudlog.exception("Error computing expected signature") + return b"" + + +def update_panda(): panda = None panda_dfu = None @@ -32,27 +71,33 @@ def update_panda(): panda_dfu = PandaDFU(panda_dfu[0]) panda_dfu.recover() - print "waiting for board..." time.sleep(1) - current_version = "bootstub" if panda.bootstub else str(panda.get_version()) - cloudlog.info("Panda connected, version: %s, expected %s" % (current_version, repo_version)) + fw_fn = get_firmware_fn() + fw_signature = get_expected_signature(fw_fn) - if panda.bootstub or not current_version.startswith(repo_version): - cloudlog.info("Panda firmware out of date, update required") + try: + serial = panda.get_serial()[0].decode("utf-8") + except Exception: + serial = None - signed_fn = os.path.join(BASEDIR, "board", "obj", "panda.bin.signed") - if os.path.exists(signed_fn): - cloudlog.info("Flashing signed firmware") - panda.flash(fn=signed_fn) - else: - cloudlog.info("Building and flashing unsigned firmware") - panda.flash() + panda_version = "bootstub" if panda.bootstub else panda.get_version() + panda_signature = b"" if panda.bootstub else panda.get_signature() + cloudlog.warning("Panda %s connected, version: %s, signature %s, expected %s" % ( + serial, + panda_version, + panda_signature.hex(), + fw_signature.hex(), + )) + if panda.bootstub or panda_signature != fw_signature: + cloudlog.info("Panda firmware out of date, update required") + panda.flash(fw_fn) cloudlog.info("Done flashing") if panda.bootstub: - cloudlog.info("Flashed firmware not booting, flashing development bootloader") + bootstub_version = panda.get_version() + cloudlog.info(f"Flashed firmware not booting, flashing development bootloader. Bootstub version: {bootstub_version}") panda.recover() cloudlog.info("Done flashing bootloader") @@ -60,18 +105,20 @@ def update_panda(): cloudlog.info("Panda still not booting, exiting") raise AssertionError - version = str(panda.get_version()) - if not version.startswith(repo_version): + panda_signature = panda.get_signature() + if panda_signature != fw_signature: cloudlog.info("Version mismatch after flashing, exiting") raise AssertionError -def main(gctx=None): +def main(): + set_panda_power() #BB stop autoflashing of panda on reboot #update_panda() os.chdir("boardd") os.execvp("./boardd", ["./boardd"]) + if __name__ == "__main__": main() diff --git a/selfdrive/proclogd/Makefile b/selfdrive/proclogd/Makefile deleted file mode 100644 index 9939a715f3d104..00000000000000 --- a/selfdrive/proclogd/Makefile +++ /dev/null @@ -1,58 +0,0 @@ -ARCH := $(shell uname -m) - -CC = clang -CXX = clang++ - -PHONELIBS = ../../phonelibs -BASEDIR = ../.. - -WARN_FLAGS = -Werror=implicit-function-declaration \ - -Werror=incompatible-pointer-types \ - -Werror=int-conversion \ - -Werror=return-type \ - -Werror=format-extra-args - -CFLAGS = -std=gnu11 -g -fPIC -O2 $(WARN_FLAGS) -CXXFLAGS = -std=c++11 -g -fPIC -O2 $(WARN_FLAGS) - -ZMQ_LIBS = -l:libczmq.a -l:libzmq.a - -ifeq ($(ARCH),aarch64) -CFLAGS += -mcpu=cortex-a57 -CXXFLAGS += -mcpu=cortex-a57 -ZMQ_LIBS += -lgnustl_shared -endif - -#ZMQ_FLAGS = -I$(PHONELIBS)/zmq/aarch64/include - -.PHONY: all -all: proclogd - -include ../common/cereal.mk - -OBJS = proclogd.o \ - $(CEREAL_OBJS) - -DEPS := $(OBJS:.o=.d) - -proclogd: $(OBJS) - @echo "[ LINK ] $@" - $(CXX) -fPIC -o '$@' $^ \ - $(CEREAL_LIBS) \ - $(ZMQ_LIBS) \ - -llog - -%.o: %.cc - @echo "[ CXX ] $@" - $(CXX) $(CXXFLAGS) \ - $(CEREAL_CXXFLAGS) \ - $(ZMQ_FLAGS) \ - -I../ \ - -I../../ \ - -c -o '$@' '$<' - -.PHONY: clean -clean: - rm -f proclogd $(OBJS) $(DEPS) - --include $(DEPS) diff --git a/selfdrive/proclogd/SConscript b/selfdrive/proclogd/SConscript new file mode 100644 index 00000000000000..b80d17200d7221 --- /dev/null +++ b/selfdrive/proclogd/SConscript @@ -0,0 +1,2 @@ +Import('env', 'cereal', 'messaging') +env.Program('proclogd.cc', LIBS=[cereal, messaging, 'pthread', 'zmq', 'capnp', 'kj']) diff --git a/selfdrive/proclogd/proclogd.cc b/selfdrive/proclogd/proclogd.cc index fbb7704e0378e7..24b42c5bf4b8ba 100644 --- a/selfdrive/proclogd/proclogd.cc +++ b/selfdrive/proclogd/proclogd.cc @@ -5,9 +5,6 @@ #include #include - -#include -#include #include #include #include @@ -16,9 +13,7 @@ #include #include -#include -#include -#include "cereal/gen/cpp/log.capnp.h" +#include "messaging.hpp" #include "common/timing.h" #include "common/utilpp.h" @@ -34,12 +29,7 @@ struct ProcCache { } int main() { - int err; - - void *context = zmq_ctx_new(); - void *publisher = zmq_socket(context, ZMQ_PUB); - err = zmq_bind(publisher, "tcp://*:8031"); - assert(err == 0); + PubMaster publisher({"procLog"}); double jiffy = sysconf(_SC_CLK_TCK); size_t page_size = sysconf(_SC_PAGE_SIZE); @@ -48,11 +38,8 @@ int main() { while (1) { - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto procLog = event.initProcLog(); - + MessageBuilder msg; + auto procLog = msg.initEvent().initProcLog(); auto orphanage = msg.getOrphanage(); // stat @@ -70,8 +57,8 @@ int main() { unsigned long utime, ntime, stime, itime; unsigned long iowtime, irqtime, sirqtime; - int count = sscanf(stat_line.data(), "cpu%d %lu %lu %lu %lu %lu %lu %lu", - &id, &utime, &ntime, &stime, &itime, &iowtime, &irqtime, &sirqtime); + sscanf(stat_line.data(), "cpu%d %lu %lu %lu %lu %lu %lu %lu", + &id, &utime, &ntime, &stime, &itime, &iowtime, &irqtime, &sirqtime); auto ltimeo = orphanage.newOrphan(); auto ltime = ltimeo.get(); @@ -103,19 +90,19 @@ int main() { std::ifstream smem("/proc/meminfo"); std::string mem_line; - + uint64_t mem_total = 0, mem_free = 0, mem_available = 0, mem_buffers = 0; uint64_t mem_cached = 0, mem_active = 0, mem_inactive = 0, mem_shared = 0; while (std::getline(smem, mem_line)) { - if (util::starts_with(mem_line, "MemTotal:")) sscanf(mem_line.data(), "MemTotal: %lu kB", &mem_total); - else if (util::starts_with(mem_line, "MemFree:")) sscanf(mem_line.data(), "MemFree: %lu kB", &mem_free); - else if (util::starts_with(mem_line, "MemAvailable:")) sscanf(mem_line.data(), "MemAvailable: %lu kB", &mem_available); - else if (util::starts_with(mem_line, "Buffers:")) sscanf(mem_line.data(), "Buffers: %lu kB", &mem_buffers); - else if (util::starts_with(mem_line, "Cached:")) sscanf(mem_line.data(), "Cached: %lu kB", &mem_cached); - else if (util::starts_with(mem_line, "Active:")) sscanf(mem_line.data(), "Active: %lu kB", &mem_active); - else if (util::starts_with(mem_line, "Inactive:")) sscanf(mem_line.data(), "Inactive: %lu kB", &mem_inactive); - else if (util::starts_with(mem_line, "Shmem:")) sscanf(mem_line.data(), "Shmem: %lu kB", &mem_shared); + if (util::starts_with(mem_line, "MemTotal:")) sscanf(mem_line.data(), "MemTotal: %" SCNu64 " kB", &mem_total); + else if (util::starts_with(mem_line, "MemFree:")) sscanf(mem_line.data(), "MemFree: %" SCNu64 " kB", &mem_free); + else if (util::starts_with(mem_line, "MemAvailable:")) sscanf(mem_line.data(), "MemAvailable: %" SCNu64 " kB", &mem_available); + else if (util::starts_with(mem_line, "Buffers:")) sscanf(mem_line.data(), "Buffers: %" SCNu64 " kB", &mem_buffers); + else if (util::starts_with(mem_line, "Cached:")) sscanf(mem_line.data(), "Cached: %" SCNu64 " kB", &mem_cached); + else if (util::starts_with(mem_line, "Active:")) sscanf(mem_line.data(), "Active: %" SCNu64 " kB", &mem_active); + else if (util::starts_with(mem_line, "Inactive:")) sscanf(mem_line.data(), "Inactive: %" SCNu64 " kB", &mem_inactive); + else if (util::starts_with(mem_line, "Shmem:")) sscanf(mem_line.data(), "Shmem: %" SCNu64 " kB", &mem_shared); } mem.setTotal(mem_total * 1024); @@ -203,7 +190,7 @@ int main() { std::string cmdline_s = util::read_file(util::string_format("/proc/%d/cmdline", pid)); const char* cmdline_p = cmdline_s.c_str(); const char* cmdline_ep = cmdline_p + cmdline_s.size(); - + // strip trailing null bytes while ((cmdline_ep-1) > cmdline_p && *(cmdline_ep-1) == 0) { cmdline_ep--; @@ -234,9 +221,7 @@ int main() { } } - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - zmq_send(publisher, bytes.begin(), bytes.size(), 0); + publisher.send("procLog", msg); usleep(2000000); // 2 secs } diff --git a/selfdrive/registration.py b/selfdrive/registration.py index 6f5b9216d3ff42..07c1e374c8ddcd 100644 --- a/selfdrive/registration.py +++ b/selfdrive/registration.py @@ -1,115 +1,69 @@ import os import json -import subprocess -import struct from datetime import datetime, timedelta -from selfdrive.swaglog import cloudlog -from selfdrive.version import version, terms_version, training_version, get_git_commit, get_git_branch, get_git_remote from common.api import api_get from common.params import Params from common.file_helpers import mkdirs_exists_ok +from common.basedir import PERSIST +from selfdrive.hardware import HARDWARE +from selfdrive.swaglog import cloudlog +from selfdrive.version import version, terms_version, training_version, get_git_commit, \ + get_git_branch, get_git_remote -def get_imei(): - ret = subprocess.check_output(["getprop", "oem.device.imeicache"]).strip() - if ret == "": - ret = "000000000000000" - return ret - - -def get_serial(): - return subprocess.check_output(["getprop", "ro.serialno"]).strip() - - -# TODO: move this to a library -def parse_service_call(call): - ret = subprocess.check_output(call).strip() - if 'Parcel' not in ret: - return None - try: - def fh(x): - if len(x) != 8: - return [] - return [x[6:8], x[4:6], x[2:4], x[0:2]] - hd = [] - for x in ret.split("\n")[1:]: - for k in map(fh, x.split(": ")[1].split(" '")[0].split(" ")): - hd.extend(k) - return ''.join([chr(int(x, 16)) for x in hd]) - except Exception: - return None - - -def get_subscriber_info(): - ret = parse_service_call(["service", "call", "iphonesubinfo", "7"]) - if ret is None or len(ret) < 8: - return "" - if struct.unpack("I", ret[4:8]) == -1: - return "" - return ret[8:-2:2] - -def get_git_remote(): - try: - local_branch = subprocess.check_output(["git", "name-rev", "--name-only", "HEAD"]).strip() - tracking_remote = subprocess.check_output(["git", "config", "branch."+local_branch+".remote"]).strip() - return subprocess.check_output(["git", "config", "remote."+tracking_remote+".url"]).strip() - except subprocess.CalledProcessError: - return "" - def register(): params = Params() params.put("Version", version) params.put("TermsVersion", terms_version) params.put("TrainingVersion", training_version) - params.put("GitCommit", get_git_commit()) - params.put("GitBranch", get_git_branch()) - params.put("GitRemote", get_git_remote()) - params.put("SubscriberInfo", get_subscriber_info()) + + params.put("GitCommit", get_git_commit(default="")) + params.put("GitBranch", get_git_branch(default="")) + params.put("GitRemote", get_git_remote(default="")) + params.put("SubscriberInfo", HARDWARE.get_subscriber_info()) # create a key for auth # your private key is kept on your device persist partition and never sent to our servers # do not erase your persist partition - if not os.path.isfile("/persist/comma/id_rsa.pub"): + if not os.path.isfile(PERSIST+"/comma/id_rsa.pub"): cloudlog.warning("generating your personal RSA key") - mkdirs_exists_ok("/persist/comma") - assert os.system("openssl genrsa -out /persist/comma/id_rsa.tmp 2048") == 0 - assert os.system("openssl rsa -in /persist/comma/id_rsa.tmp -pubout -out /persist/comma/id_rsa.tmp.pub") == 0 - os.rename("/persist/comma/id_rsa.tmp", "/persist/comma/id_rsa") - os.rename("/persist/comma/id_rsa.tmp.pub", "/persist/comma/id_rsa.pub") + mkdirs_exists_ok(PERSIST+"/comma") + assert os.system("openssl genrsa -out "+PERSIST+"/comma/id_rsa.tmp 2048") == 0 + assert os.system("openssl rsa -in "+PERSIST+"/comma/id_rsa.tmp -pubout -out "+PERSIST+"/comma/id_rsa.tmp.pub") == 0 + os.rename(PERSIST+"/comma/id_rsa.tmp", PERSIST+"/comma/id_rsa") + os.rename(PERSIST+"/comma/id_rsa.tmp.pub", PERSIST+"/comma/id_rsa.pub") # make key readable by app users (ai.comma.plus.offroad) - os.chmod('/persist/comma/', 0o755) - os.chmod('/persist/comma/id_rsa', 0o744) + os.chmod(PERSIST+'/comma/', 0o755) + os.chmod(PERSIST+'/comma/id_rsa', 0o744) - dongle_id, access_token = params.get("DongleId"), params.get("AccessToken") - public_key = open("/persist/comma/id_rsa.pub").read() + dongle_id = params.get("DongleId", encoding='utf8') + public_key = open(PERSIST+"/comma/id_rsa.pub").read() # create registration token # in the future, this key will make JWTs directly - private_key = open("/persist/comma/id_rsa").read() + private_key = open(PERSIST+"/comma/id_rsa").read() # late import import jwt - register_token = jwt.encode({'register':True, 'exp': datetime.utcnow() + timedelta(hours=1)}, private_key, algorithm='RS256') + register_token = jwt.encode({'register': True, 'exp': datetime.utcnow() + timedelta(hours=1)}, private_key, algorithm='RS256') try: cloudlog.info("getting pilotauth") resp = api_get("v2/pilotauth/", method='POST', timeout=15, - imei=get_imei(), serial=get_serial(), public_key=public_key, register_token=register_token) + imei=HARDWARE.get_imei(0), imei2=HARDWARE.get_imei(1), serial=HARDWARE.get_serial(), public_key=public_key, register_token=register_token) dongleauth = json.loads(resp.text) - dongle_id, access_token = dongleauth["dongle_id"].encode('ascii'), dongleauth["access_token"].encode('ascii') + dongle_id = dongleauth["dongle_id"] params.put("DongleId", dongle_id) - params.put("AccessToken", access_token) - return dongle_id, access_token + return dongle_id except Exception: cloudlog.exception("failed to authenticate") - if dongle_id is not None and access_token is not None: - return dongle_id, access_token + if dongle_id is not None: + return dongle_id else: return None if __name__ == "__main__": - print(api_get("").text) print(register()) diff --git a/selfdrive/rtshield.py b/selfdrive/rtshield.py new file mode 100755 index 00000000000000..9a638c91697e36 --- /dev/null +++ b/selfdrive/rtshield.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +import os +import time +from common.realtime import set_core_affinity, set_realtime_priority + +# RT shield - ensure CPU 3 always remains available for RT processes +# runs as SCHED_FIFO with minimum priority to ensure kthreads don't +# get scheduled onto CPU 3, but it's always preemptible by realtime +# openpilot processes + +def main(): + set_core_affinity(int(os.getenv("CORE", "3"))) + set_realtime_priority(1) + + while True: + time.sleep(0.000001) + +if __name__ == "__main__": + main() + diff --git a/selfdrive/sensord/Makefile b/selfdrive/sensord/Makefile deleted file mode 100644 index 98508d8d1aad92..00000000000000 --- a/selfdrive/sensord/Makefile +++ /dev/null @@ -1,4 +0,0 @@ --include build_from_src.mk - -release: - @echo "sensord: this is a release" diff --git a/selfdrive/sensord/SConscript b/selfdrive/sensord/SConscript new file mode 100644 index 00000000000000..01b0eec844fc3b --- /dev/null +++ b/selfdrive/sensord/SConscript @@ -0,0 +1,23 @@ +Import('env', 'arch', 'common', 'cereal', 'messaging') +if arch == "aarch64": + env.Program('_sensord', 'sensors_qcom.cc', LIBS=['hardware', common, cereal, messaging, 'capnp', 'zmq', 'kj']) + lenv = env.Clone() + lenv['LIBPATH'] += ['/system/vendor/lib64'] + lenv.Program('_gpsd', ['gpsd.cc'], LIBS=['hardware', common, 'diag', 'time_genoff', cereal, messaging, 'capnp', 'zmq', 'kj']) +else: + sensors = [ + 'sensors/file_sensor.cc', + 'sensors/i2c_sensor.cc', + 'sensors/light_sensor.cc', + 'sensors/bmx055_accel.cc', + 'sensors/bmx055_gyro.cc', + 'sensors/bmx055_magn.cc', + 'sensors/bmx055_temp.cc', + 'sensors/lsm6ds3_accel.cc', + 'sensors/lsm6ds3_gyro.cc', + 'sensors/lsm6ds3_temp.cc', + ] + libs = [common, cereal, messaging, 'capnp', 'zmq', 'kj'] + if arch == "larch64": + libs.append('i2c') + env.Program('_sensord', ['sensors_qcom2.cc'] + sensors, LIBS=libs) diff --git a/selfdrive/sensord/build_from_src.mk b/selfdrive/sensord/build_from_src.mk deleted file mode 100644 index 8c71f5f96d06f0..00000000000000 --- a/selfdrive/sensord/build_from_src.mk +++ /dev/null @@ -1,88 +0,0 @@ -CC = clang -CXX = clang++ - -PHONELIBS = ../../phonelibs -BASEDIR = ../.. - -WARN_FLAGS = -Werror=implicit-function-declaration \ - -Werror=incompatible-pointer-types \ - -Werror=int-conversion \ - -Werror=return-type \ - -Werror=format-extra-args - -CFLAGS = -std=gnu11 -g -fPIC -O2 $(WARN_FLAGS) \ - -I$(PHONELIBS)/android_frameworks_native/include \ - -I$(PHONELIBS)/android_system_core/include \ - -I$(PHONELIBS)/android_hardware_libhardware/include -CXXFLAGS = -std=c++11 -g -fPIC -O2 $(WARN_FLAGS) \ - -I$(PHONELIBS)/android_frameworks_native/include \ - -I$(PHONELIBS)/android_system_core/include \ - -I$(PHONELIBS)/android_hardware_libhardware/include - -ZMQ_LIBS = -l:libczmq.a -l:libzmq.a -llog -luuid -lgnustl_shared - -ifeq ($(ARCH),aarch64) -CFLAGS += -mcpu=cortex-a57 -CXXFLAGS += -mcpu=cortex-a57 -endif - - -JSON_FLAGS = -I$(PHONELIBS)/json/src - -DIAG_LIBS = -L/system/vendor/lib64 -ldiag -ltime_genoff - -.PHONY: all -all: sensord gpsd - -include ../common/cereal.mk - -SENSORD_OBJS = sensors.o \ - ../common/swaglog.o \ - $(PHONELIBS)/json/src/json.o - -GPSD_OBJS = gpsd.o \ - rawgps.o \ - ../common/swaglog.o \ - $(PHONELIBS)/json/src/json.o - -DEPS := $(SENSORD_OBJS:.o=.d) $(GPSD_OBJS:.o=.d) - -sensord: $(SENSORD_OBJS) - @echo "[ LINK ] $@" - $(CXX) -fPIC -o '$@' $^ \ - $(CEREAL_LIBS) \ - $(ZMQ_LIBS) \ - -lhardware - -gpsd: $(GPSD_OBJS) - @echo "[ LINK ] $@" - $(CXX) -fPIC -o '$@' $^ \ - $(CEREAL_LIBS) \ - $(ZMQ_LIBS) \ - $(DIAG_LIBS) \ - -lhardware - -%.o: %.cc - @echo "[ CXX ] $@" - $(CXX) $(CXXFLAGS) \ - $(CEREAL_CXXFLAGS) \ - $(ZMQ_FLAGS) \ - $(JSON_FLAGS) \ - -I../ \ - -I../../ \ - -c -o '$@' '$<' - - -%.o: %.c - @echo "[ CC ] $@" - $(CC) $(CFLAGS) \ - $(JSON_FLAGS) \ - -I../ \ - -I../../ \ - -c -o '$@' '$<' - -.PHONY: clean -clean: - rm -f sensord gpsd $(OBJS) $(DEPS) - --include $(DEPS) diff --git a/selfdrive/sensord/gpsd b/selfdrive/sensord/gpsd new file mode 100755 index 00000000000000..c301082682cbc1 --- /dev/null +++ b/selfdrive/sensord/gpsd @@ -0,0 +1,3 @@ +#!/bin/sh +export LD_LIBRARY_PATH="/system/lib64:$LD_LIBRARY_PATH" +exec ./_gpsd diff --git a/selfdrive/sensord/gpsd.cc b/selfdrive/sensord/gpsd.cc index 6bf7a6a9e1861b..1978a239c8d7aa 100644 --- a/selfdrive/sensord/gpsd.cc +++ b/selfdrive/sensord/gpsd.cc @@ -7,7 +7,6 @@ #include #include #include -#include #include #include @@ -17,27 +16,15 @@ #include #include -#include - -#include - +#include "messaging.hpp" #include "common/timing.h" #include "common/swaglog.h" -#include "cereal/gen/cpp/log.capnp.h" - -#include "rawgps.h" - -volatile int do_exit = 0; +volatile sig_atomic_t do_exit = 0; namespace { -pthread_t clock_thread_handle; - -// zmq output -void *gps_context; -void *gps_publisher; -void *gps_location_publisher; +PubMaster *pm; const GpsInterface* gGpsInterface = NULL; const AGpsInterface* gAGpsInterface = NULL; @@ -48,33 +35,22 @@ void set_do_exit(int sig) { void nmea_callback(GpsUtcTime timestamp, const char* nmea, int length) { - uint64_t log_time = nanos_since_boot(); uint64_t log_time_wall = nanos_since_epoch(); - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(log_time); - - auto nmeaData = event.initGpsNMEA(); + MessageBuilder msg; + auto nmeaData = msg.initEvent().initGpsNMEA(); nmeaData.setTimestamp(timestamp); nmeaData.setLocalWallTime(log_time_wall); nmeaData.setNmea(nmea); - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - // printf("gps send %d\n", bytes.size()); - zmq_send(gps_publisher, bytes.begin(), bytes.size(), 0); + pm->send("gpsNMEA", msg); } void location_callback(GpsLocation* location) { //printf("got location callback\n"); - uint64_t log_time = nanos_since_boot(); - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(log_time); - - auto locationData = event.initGpsLocation(); + MessageBuilder msg; + auto locationData = msg.initEvent().initGpsLocation(); locationData.setFlags(location->flags); locationData.setLatitude(location->latitude); locationData.setLongitude(location->longitude); @@ -85,9 +61,7 @@ void location_callback(GpsLocation* location) { locationData.setTimestamp(location->timestamp); locationData.setSource(cereal::GpsLocationData::SensorSource::ANDROID); - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - zmq_send(gps_location_publisher, bytes.begin(), bytes.size(), 0); + pm->send("gpsLocation", msg); } pthread_t create_thread_callback(const char* name, void (*start)(void *), void* arg) { @@ -132,9 +106,8 @@ AGpsCallbacks agps_callbacks = { create_thread_callback, }; - - void gps_init() { + pm = new PubMaster({"gpsNMEA", "gpsLocation"}); LOG("*** init GPS"); hw_module_t* module = NULL; hw_get_module(GPS_HARDWARE_MODULE_ID, (hw_module_t const**)&module); @@ -163,105 +136,26 @@ void gps_init() { GPS_POSITION_RECURRENCE_PERIODIC, 100, 0, 0); - gps_context = zmq_ctx_new(); - gps_publisher = zmq_socket(gps_context, ZMQ_PUB); - zmq_bind(gps_publisher, "tcp://*:8004"); - - gps_location_publisher = zmq_socket(gps_context, ZMQ_PUB); - zmq_bind(gps_location_publisher, "tcp://*:8026"); } void gps_destroy() { + delete pm; gGpsInterface->stop(); gGpsInterface->cleanup(); } - -int64_t arm_cntpct() { - int64_t v; - asm volatile("mrs %0, cntpct_el0" : "=r"(v)); - return v; -} - -// TODO: move this out of here -void* clock_thread(void* args) { - int err = 0; - - void* clock_publisher = zmq_socket(gps_context, ZMQ_PUB); - zmq_bind(clock_publisher, "tcp://*:8034"); - - int timerfd = timerfd_create(CLOCK_BOOTTIME, 0); - assert(timerfd >= 0); - - struct itimerspec spec = {0}; - spec.it_interval.tv_sec = 1; - spec.it_interval.tv_nsec = 0; - spec.it_value.tv_sec = 1; - spec.it_value.tv_nsec = 0; - - err = timerfd_settime(timerfd, 0, &spec, 0); - assert(err == 0); - - uint64_t expirations = 0; - while ((err = read(timerfd, &expirations, sizeof(expirations)))) { - if (err < 0) break; - - if (do_exit) break; - - uint64_t boottime = nanos_since_boot(); - uint64_t monotonic = nanos_monotonic(); - uint64_t monotonic_raw = nanos_monotonic_raw(); - uint64_t wall_time = nanos_since_epoch(); - - uint64_t modem_uptime_v = arm_cntpct() / 19200ULL; // 19.2 mhz clock - - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(boottime); - auto clocks = event.initClocks(); - - clocks.setBootTimeNanos(boottime); - clocks.setMonotonicNanos(monotonic); - clocks.setMonotonicRawNanos(monotonic_raw); - clocks.setWallTimeNanos(wall_time); - clocks.setModemUptimeMillis(modem_uptime_v); - - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - zmq_send(clock_publisher, bytes.begin(), bytes.size(), 0); - } - - close(timerfd); - zmq_close(clock_publisher); - - return NULL; -} - - } int main() { - int err = 0; setpriority(PRIO_PROCESS, 0, -13); signal(SIGINT, (sighandler_t)set_do_exit); signal(SIGTERM, (sighandler_t)set_do_exit); gps_init(); - - rawgps_init(); - - err = pthread_create(&clock_thread_handle, NULL, - clock_thread, NULL); - assert(err == 0); while(!do_exit) pause(); - err = pthread_join(clock_thread_handle, NULL); - assert(err == 0); - - rawgps_destroy(); - gps_destroy(); return 0; diff --git a/selfdrive/sensord/rawgps.cc b/selfdrive/sensord/rawgps.cc deleted file mode 100644 index 91e5562c7df934..00000000000000 --- a/selfdrive/sensord/rawgps.cc +++ /dev/null @@ -1,1189 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "cereal/gen/cpp/log.capnp.h" - -#include "common/timing.h" -#include "common/util.h" -#include "common/swaglog.h" - -#include "libdiag.h" - -extern volatile int do_exit; - -#define NV_GNSS_OEM_FEATURE_MASK 7165 -# define NV_GNSS_OEM_FEATURE_MASK_OEMDRE 1 -#define NV_CGPS_DPO_CONTROL 5596 - -#define DIAG_NV_READ_F 38 -#define DIAG_NV_WRITE_F 39 - -#define DIAG_SUBSYS_CMD 75 -#define DIAG_SUBSYS_CMD_VER_2 128 - -#define DIAG_SUBSYS_GPS 13 -#define DIAG_SUBSYS_FS 19 - -#define CGPS_DIAG_PDAPI_CMD 100 -#define CGPS_OEM_CONTROL 202 - -#define GPSDIAG_OEMFEATURE_DRE 1 -#define GPSDIAG_OEM_DRE_ON 1 - -#define FEATURE_OEMDRE_NOT_SUPPORTED 1 -#define FEATURE_OEMDRE_ON 2 -#define FEATURE_OEMDRE_ALREADY_ON 4 - -#define TM_DIAG_NAV_CONFIG_CMD 0x6E - -#define EFS2_DIAG_SYNC_NO_WAIT 48 - -struct __attribute__((packed)) NvPacket { - uint8_t cmd_code; - uint16_t nv_id; - uint8_t data[128]; - uint16_t status; -}; - -enum NvStatus { - NV_DONE, - NV_BUSY, - NV_FULL, - NV_FAIL, - NV_NOTACTIVE, - NV_BADPARAM, - NV_READONLY, - NV_BADRG, - NV_NOMEM, - NV_NOTALLOC, -}; - -struct __attribute__((packed)) Efs2DiagSyncReq { - uint8_t cmd_code; - uint8_t subsys_id; - uint16_t subsys_cmd_code; - uint16_t sequence_num; - char path[8]; -}; - - -struct __attribute__((packed)) Efs2DiagSyncResp { - uint8_t cmd_code; - uint8_t subsys_id; - uint16_t subsys_cmd_code; - uint16_t sequence_num; - uint32_t sync_token; - int32_t diag_errno; -}; - - - -struct __attribute__((packed)) GpsOemControlReq { - uint8_t cmd_code; - uint8_t subsys_id; - uint16_t subsys_cmd_code; - uint8_t gps_cmd_code; - uint8_t version; - - uint32_t oem_feature; - uint32_t oem_command; - uint32_t reserved[2]; -}; - - -struct __attribute__((packed)) GpsOemControlResp { - uint8_t cmd_code; - uint8_t subsys_id; - uint16_t subsys_cmd_code; - uint8_t gps_cmd_code; - uint8_t version; - - uint32_t oem_feature; - uint32_t oem_command; - uint32_t resp_result; - uint32_t reserved[2]; -}; - -struct __attribute__((packed)) GpsNavConfigReq { - uint8_t cmd_code; - uint8_t subsys_id; - uint16_t subsys_cmd_code; - uint32_t subsys_status; - uint16_t subsys_delayed_resp_id; - uint16_t subsys_rsp_cnt; - - uint8_t desired_config; -}; - -struct __attribute__((packed)) GpsNavConfigResp { - uint8_t cmd_code; - uint8_t subsys_id; - uint16_t subsys_cmd_code; - uint32_t subsys_status; - uint16_t subsys_delayed_resp_id; - uint16_t subsys_rsp_cnt; - - uint8_t supported_config; - uint8_t actual_config; -}; - - -#define LOG_GNSS_POSITION_REPORT 0x1476 -#define LOG_GNSS_GPS_MEASUREMENT_REPORT 0x1477 -#define LOG_GNSS_CLOCK_REPORT 0x1478 -#define LOG_GNSS_GLONASS_MEASUREMENT_REPORT 0x1480 -#define LOG_GNSS_BDS_MEASUREMENT_REPORT 0x1756 -#define LOG_GNSS_GAL_MEASUREMENT_REPORT 0x1886 - -#define LOG_GNSS_OEMDRE_MEASUREMENMT_REPORT 0x14DE -#define LOG_GNSS_OEMDRE_SVPOLY_REPORT 0x14E1 - -#define LOG_GNSS_ME_DPO_STATUS 0x1838 -#define LOG_GNSS_CD_DB_REPORT 0x147B -#define LOG_GNSS_PRX_RF_HW_STATUS_REPORT 0x147E -#define LOG_CGPS_SLOW_CLOCK_CLIB_REPORT 0x1488 -#define LOG_GNSS_CONFIGURATION_STATE 0x1516 - -struct __attribute__((packed)) log_header_type { - uint16_t len; - uint16_t code; - uint64_t ts; -}; - - - -enum SVObservationStates { - SV_IDLE, - SV_SEARCH, - SV_SEACH_VERIFY, - SV_BIT_EDGE, - SV_TRACK_VERIFY, - SV_TRACK, - SV_RESTART, - SV_DPO, - SV_GLO_10ms_BE, - SV_GLO_10ms_AT, -}; - -struct __attribute__((packed)) GNSSGpsMeasurementReportv0_SV{ - uint8_t sv_id; - uint8_t observation_state; // SVObservationStates - uint8_t observations; - uint8_t good_observations; - uint16_t parity_error_count; - uint8_t filter_stages; - uint16_t carrier_noise; - int16_t latency; - uint8_t predetect_interval; - uint16_t postdetections; - uint32_t unfiltered_measurement_integral; - float unfiltered_measurement_fraction; - float unfiltered_time_uncertainty; - float unfiltered_speed; - float unfiltered_speed_uncertainty; - uint32_t measurement_status; - uint8_t misc_status; - uint32_t multipath_estimate; - float azimuth; - float elevation; - int32_t carrier_phase_cycles_integral; - uint16_t carrier_phase_cycles_fraction; - float fine_speed; - float fine_speed_uncertainty; - uint8_t cycle_slip_count; - uint32_t pad; -}; - -_Static_assert(sizeof(GNSSGpsMeasurementReportv0_SV) == 70, "error"); - -struct __attribute__((packed)) GNSSGpsMeasurementReportv0{ - log_header_type header; - uint8_t version; - uint32_t f_count; - uint16_t week; - uint32_t milliseconds; - float time_bias; - float clock_time_uncertainty; - float clock_frequency_bias; - float clock_frequency_uncertainty; - uint8_t sv_count; - GNSSGpsMeasurementReportv0_SV sv[]; -}; - - - -struct __attribute__((packed)) GNSSGlonassMeasurementReportv0_SV { - uint8_t sv_id; - int8_t frequency_index; - uint8_t observation_state; // SVObservationStates - uint8_t observations; - uint8_t good_observations; - uint8_t hemming_error_count; - uint8_t filter_stages; - uint16_t carrier_noise; - int16_t latency; - uint8_t predetect_interval; - uint16_t postdetections; - uint32_t unfiltered_measurement_integral; - float unfiltered_measurement_fraction; - float unfiltered_time_uncertainty; - float unfiltered_speed; - float unfiltered_speed_uncertainty; - uint32_t measurement_status; - uint8_t misc_status; - uint32_t multipath_estimate; - float azimuth; - float elevation; - int32_t carrier_phase_cycles_integral; - uint16_t carrier_phase_cycles_fraction; - float fine_speed; - float fine_speed_uncertainty; - uint8_t cycle_slip_count; - uint32_t pad; -}; - -_Static_assert(sizeof(GNSSGlonassMeasurementReportv0_SV) == 70, "error"); - -struct __attribute__((packed)) GNSSGlonassMeasurementReportv0 { - log_header_type header; - uint8_t version; - uint32_t f_count; - uint8_t glonass_cycle_number; - uint16_t glonass_number_of_days; - uint32_t milliseconds; - float time_bias; - float clock_time_uncertainty; - float clock_frequency_bias; - float clock_frequency_uncertainty; - uint8_t sv_count; - GNSSGlonassMeasurementReportv0_SV sv[]; -}; - - -struct __attribute__((packed)) GNSSClockReportv2 { - log_header_type header; - uint8_t version; - uint16_t valid_flags; - - uint32_t f_count; - - uint16_t gps_week; - uint32_t gps_milliseconds; - float gps_time_bias; - float gps_clock_time_uncertainty; - uint8_t gps_clock_source; - - uint8_t glonass_year; - uint16_t glonass_day; - uint32_t glonass_milliseconds; - float glonass_time_bias; - float glonass_clock_time_uncertainty; - uint8_t glonass_clock_source; - - uint16_t bds_week; - uint32_t bds_milliseconds; - float bds_time_bias; - float bds_clock_time_uncertainty; - uint8_t bds_clock_source; - - uint16_t gal_week; - uint32_t gal_milliseconds; - float gal_time_bias; - float gal_clock_time_uncertainty; - uint8_t gal_clock_source; - - float clock_frequency_bias; - float clock_frequency_uncertainty; - uint8_t frequency_source; - uint8_t gps_leap_seconds; - uint8_t gps_leap_seconds_uncertainty; - uint8_t gps_leap_seconds_source; - - float gps_to_glonass_time_bias_milliseconds; - float gps_to_glonass_time_bias_milliseconds_uncertainty; - float gps_to_bds_time_bias_milliseconds; - float gps_to_bds_time_bias_milliseconds_uncertainty; - float bds_to_glo_time_bias_milliseconds; - float bds_to_glo_time_bias_milliseconds_uncertainty; - float gps_to_gal_time_bias_milliseconds; - float gps_to_gal_time_bias_milliseconds_uncertainty; - float gal_to_glo_time_bias_milliseconds; - float gal_to_glo_time_bias_milliseconds_uncertainty; - float gal_to_bds_time_bias_milliseconds; - float gal_to_bds_time_bias_milliseconds_uncertainty; - - uint32_t system_rtc_time; - uint32_t f_count_offset; - uint32_t lpm_rtc_count; - uint32_t clock_resets; - - uint32_t reserved[3]; - -}; - - -enum GNSSMeasurementSource { - SOURCE_GPS, - SOURCE_GLONASS, - SOURCE_BEIDOU, -}; - -struct __attribute__((packed)) GNSSOemdreMeasurement { - uint8_t sv_id; - uint8_t unkn; - int8_t glonass_frequency_index; - uint32_t observation_state; - uint8_t observations; - uint8_t good_observations; - uint8_t filter_stages; - uint8_t predetect_interval; - uint8_t cycle_slip_count; - uint16_t postdetections; - - uint32_t measurement_status; - uint32_t measurement_status2; - - uint16_t carrier_noise; - uint16_t rf_loss; - int16_t latency; - - float filtered_measurement_fraction; - uint32_t filtered_measurement_integral; - float filtered_time_uncertainty; - float filtered_speed; - float filtered_speed_uncertainty; - - float unfiltered_measurement_fraction; - uint32_t unfiltered_measurement_integral; - float unfiltered_time_uncertainty; - float unfiltered_speed; - float unfiltered_speed_uncertainty; - - uint8_t multipath_estimate_valid; - uint32_t multipath_estimate; - uint8_t direction_valid; - float azimuth; - float elevation; - float doppler_acceleration; - float fine_speed; - float fine_speed_uncertainty; - - uint64_t carrier_phase; - uint32_t f_count; - - uint16_t parity_error_count; - uint8_t good_parity; - -}; - -_Static_assert(sizeof(GNSSOemdreMeasurement) == 109, "error"); - -struct __attribute__((packed)) GNSSOemdreMeasurementReportv2 { - log_header_type header; - uint8_t version; - uint8_t reason; - uint8_t sv_count; - uint8_t seq_num; - uint8_t seq_max; - uint16_t rf_loss; - - uint8_t system_rtc_valid; - uint32_t f_count; - uint32_t clock_resets; - uint64_t system_rtc_time; - - uint8_t gps_leap_seconds; - uint8_t gps_leap_seconds_uncertainty; - float gps_to_glonass_time_bias_milliseconds; - float gps_to_glonass_time_bias_milliseconds_uncertainty; - - uint16_t gps_week; - uint32_t gps_milliseconds; - uint32_t gps_time_bias; - uint32_t gps_clock_time_uncertainty; - uint8_t gps_clock_source; - - uint8_t glonass_clock_source; - uint8_t glonass_year; - uint16_t glonass_day; - uint32_t glonass_milliseconds; - float glonass_time_bias; - float glonass_clock_time_uncertainty; - - float clock_frequency_bias; - float clock_frequency_uncertainty; - uint8_t frequency_source; - - uint32_t cdma_clock_info[5]; - - uint8_t source; - - GNSSOemdreMeasurement measurements[16]; - -}; - -_Static_assert(sizeof(GNSSOemdreMeasurementReportv2) == 1851, "error"); - - -struct __attribute__((packed)) GNSSOemdreSVPolyReportv2 { - log_header_type header; - uint8_t version; - uint16_t sv_id; - int8_t frequency_index; - uint8_t flags; - uint16_t iode; - double t0; - double xyz0[3]; - double xyzN[9]; - float other[4]; - float position_uncertainty; - float iono_delay; - float iono_dot; - float sbas_iono_delay; - float sbas_iono_dot; - float tropo_delay; - float elevation; - float elevation_dot; - float elevation_uncertainty; - double velocity_coeff[12]; -}; - -_Static_assert(sizeof(GNSSOemdreSVPolyReportv2) == 271, "error"); - - -static void* rawgps_context; -static void *rawgps_publisher; -static int client_id = 0; - -static void hexdump(uint8_t* d, size_t len) { - for (int i=0; i= sizeof(log_header_type)+1); - log_header_type* log_header = (log_header_type*)ptr; - uint8_t* log_data = ptr + sizeof(log_header_type); - -#ifdef RAWGPS_TEST - printf("%04x\n", log_header->code); -#endif - - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto qcomGnss = event.initQcomGnss(); - qcomGnss.setLogTs(log_header->ts); - - switch (log_header->code) { - - case LOG_GNSS_CLOCK_REPORT: { - uint8_t version = log_data[0]; - assert(version == 2); - - assert(len >= sizeof(GNSSClockReportv2)); - const GNSSClockReportv2* report = (const GNSSClockReportv2*)ptr; - - auto lreport = qcomGnss.initClockReport(); - lreport.setHasFCount(report->valid_flags & (1 << 0)); - lreport.setFCount(report->f_count); - - lreport.setHasGpsWeek(report->valid_flags & (1 << 2)); - lreport.setGpsWeek(report->gps_week); - lreport.setHasGpsMilliseconds(report->valid_flags & (1 << 1)); - lreport.setGpsMilliseconds(report->gps_milliseconds); - lreport.setGpsTimeBias(report->gps_time_bias); - lreport.setGpsClockTimeUncertainty(report->gps_clock_time_uncertainty); - lreport.setGpsClockSource(report->gps_clock_source); - - lreport.setHasGlonassYear(report->valid_flags & (1 << 6)); - lreport.setGlonassYear(report->glonass_year); - lreport.setHasGlonassDay(report->valid_flags & (1 << 5)); - lreport.setGlonassDay(report->glonass_day); - lreport.setHasGlonassMilliseconds(report->valid_flags & (1 << 4)); - lreport.setGlonassMilliseconds(report->glonass_milliseconds); - lreport.setGlonassTimeBias(report->glonass_time_bias); - lreport.setGlonassClockTimeUncertainty(report->glonass_clock_time_uncertainty); - lreport.setGlonassClockSource(report->glonass_clock_source); - - lreport.setBdsWeek(report->bds_week); - lreport.setBdsMilliseconds(report->bds_milliseconds); - lreport.setBdsTimeBias(report->bds_time_bias); - lreport.setBdsClockTimeUncertainty(report->bds_clock_time_uncertainty); - lreport.setBdsClockSource(report->bds_clock_source); - - lreport.setGalWeek(report->gal_week); - lreport.setGalMilliseconds(report->gal_milliseconds); - lreport.setGalTimeBias(report->gal_time_bias); - lreport.setGalClockTimeUncertainty(report->gal_clock_time_uncertainty); - lreport.setGalClockSource(report->gal_clock_source); - - lreport.setClockFrequencyBias(report->clock_frequency_bias); - lreport.setClockFrequencyUncertainty(report->clock_frequency_uncertainty); - lreport.setFrequencySource(report->frequency_source); - lreport.setGpsLeapSeconds(report->gps_leap_seconds); - lreport.setGpsLeapSecondsUncertainty(report->gps_leap_seconds_uncertainty); - lreport.setGpsLeapSecondsSource(report->gps_leap_seconds_source); - - lreport.setGpsToGlonassTimeBiasMilliseconds(report->gps_to_glonass_time_bias_milliseconds); - lreport.setGpsToGlonassTimeBiasMillisecondsUncertainty(report->gps_to_glonass_time_bias_milliseconds_uncertainty); - lreport.setGpsToBdsTimeBiasMilliseconds(report->gps_to_bds_time_bias_milliseconds); - lreport.setGpsToBdsTimeBiasMillisecondsUncertainty(report->gps_to_bds_time_bias_milliseconds_uncertainty); - lreport.setBdsToGloTimeBiasMilliseconds(report->bds_to_glo_time_bias_milliseconds); - lreport.setBdsToGloTimeBiasMillisecondsUncertainty(report->bds_to_glo_time_bias_milliseconds_uncertainty); - lreport.setGpsToGalTimeBiasMilliseconds(report->gps_to_gal_time_bias_milliseconds); - lreport.setGpsToGalTimeBiasMillisecondsUncertainty(report->gps_to_gal_time_bias_milliseconds_uncertainty); - lreport.setGalToGloTimeBiasMilliseconds(report->gal_to_glo_time_bias_milliseconds); - lreport.setGalToGloTimeBiasMillisecondsUncertainty(report->gal_to_glo_time_bias_milliseconds_uncertainty); - lreport.setGalToBdsTimeBiasMilliseconds(report->gal_to_bds_time_bias_milliseconds); - lreport.setGalToBdsTimeBiasMillisecondsUncertainty(report->gal_to_bds_time_bias_milliseconds_uncertainty); - - lreport.setHasRtcTime(report->valid_flags & (1 << 3)); - lreport.setSystemRtcTime(report->system_rtc_time); - lreport.setFCountOffset(report->f_count_offset); - lreport.setLpmRtcCount(report->lpm_rtc_count); - lreport.setClockResets(report->clock_resets); - - break; - } - case LOG_GNSS_GPS_MEASUREMENT_REPORT: { - uint8_t version = log_data[0]; - assert(version == 0); - - assert(len >= sizeof(GNSSGpsMeasurementReportv0)); - const GNSSGpsMeasurementReportv0* report = (const GNSSGpsMeasurementReportv0*)ptr; - assert(len >= sizeof(sizeof(GNSSGpsMeasurementReportv0))+sizeof(GNSSGpsMeasurementReportv0_SV) * report->sv_count); - - auto lreport = qcomGnss.initMeasurementReport(); - lreport.setSource(cereal::QcomGnss::MeasurementSource::GPS); - lreport.setFCount(report->f_count); - lreport.setGpsWeek(report->week); - lreport.setMilliseconds(report->milliseconds); - lreport.setTimeBias(report->time_bias); - lreport.setClockTimeUncertainty(report->clock_time_uncertainty); - lreport.setClockFrequencyBias(report->clock_frequency_bias); - lreport.setClockFrequencyUncertainty(report->clock_frequency_uncertainty); - - auto lsvs = lreport.initSv(report->sv_count); - for (int i=0; isv_count; i++) { - auto lsv = lsvs[i]; - const GNSSGpsMeasurementReportv0_SV *sv = &report->sv[i]; - - lsv.setSvId(sv->sv_id); - lsv.setObservationState(cereal::QcomGnss::SVObservationState(sv->observation_state)); - lsv.setObservations(sv->observations); - lsv.setGoodObservations(sv->good_observations); - lsv.setGpsParityErrorCount(sv->parity_error_count); - lsv.setFilterStages(sv->filter_stages); - lsv.setCarrierNoise(sv->carrier_noise); - lsv.setLatency(sv->latency); - lsv.setPredetectInterval(sv->predetect_interval); - lsv.setPostdetections(sv->postdetections); - lsv.setUnfilteredMeasurementIntegral(sv->unfiltered_measurement_integral); - lsv.setUnfilteredMeasurementFraction(sv->unfiltered_measurement_fraction); - lsv.setUnfilteredTimeUncertainty(sv->unfiltered_time_uncertainty); - lsv.setUnfilteredSpeed(sv->unfiltered_speed); - lsv.setUnfilteredSpeedUncertainty(sv->unfiltered_speed_uncertainty); - - lsv.setMultipathEstimate(sv->multipath_estimate); - lsv.setAzimuth(sv->azimuth); - lsv.setElevation(sv->elevation); - lsv.setCarrierPhaseCyclesIntegral(sv->carrier_phase_cycles_integral); - lsv.setCarrierPhaseCyclesFraction(sv->carrier_phase_cycles_fraction); - lsv.setFineSpeed(sv->fine_speed); - lsv.setFineSpeedUncertainty(sv->fine_speed_uncertainty); - lsv.setCycleSlipCount(sv->cycle_slip_count); - - auto status = lsv.initMeasurementStatus(); - parse_measurement_status_common(sv->measurement_status, status); - - status.setGpsRoundRobinRxDiversity(sv->measurement_status & (1 << 18)); - status.setGpsRxDiversity(sv->measurement_status & (1 << 19)); - status.setGpsLowBandwidthRxDiversityCombined(sv->measurement_status & (1 << 20)); - status.setGpsHighBandwidthNu4(sv->measurement_status & (1 << 21)); - status.setGpsHighBandwidthNu8(sv->measurement_status & (1 << 22)); - status.setGpsHighBandwidthUniform(sv->measurement_status & (1 << 23)); - - status.setMultipathEstimateIsValid(sv->misc_status & (1 << 0)); - status.setDirectionIsValid(sv->misc_status & (1 << 1)); - -#ifdef RAWGPS_TEST - // if (sv->measurement_status & (1 << 27)) printf("%d\n", sv->unfiltered_measurement_integral); - printf("GPS %03d %d %d 0x%08X o: %02x go: %02x fs: %02x cn: %02x pd: %02x cs: %02x po: %02x ms: %08x ms2: %08x me: %08x az: %08x el: %08x fc: %08x\n", - sv->sv_id, - !!(sv->measurement_status & (1 << 27)), - sv->unfiltered_measurement_integral, sv->unfiltered_measurement_integral, - sv->observations, - sv->good_observations, - sv->filter_stages, - sv->carrier_noise, - sv->predetect_interval, - sv->cycle_slip_count, - sv->postdetections, - sv->measurement_status, - sv->misc_status, - sv->multipath_estimate, - *(uint32_t*)&sv->azimuth, - *(uint32_t*)&sv->elevation, - report->f_count - ); -#endif - - } - - break; - } - case LOG_GNSS_GLONASS_MEASUREMENT_REPORT: { - uint8_t version = log_data[0]; - assert(version == 0); - - assert(len >= sizeof(GNSSGlonassMeasurementReportv0)); - const GNSSGlonassMeasurementReportv0* report = (const GNSSGlonassMeasurementReportv0*)ptr; - - auto lreport = qcomGnss.initMeasurementReport(); - lreport.setSource(cereal::QcomGnss::MeasurementSource::GLONASS); - lreport.setFCount(report->f_count); - lreport.setGlonassCycleNumber(report->glonass_cycle_number); - lreport.setGlonassNumberOfDays(report->glonass_number_of_days); - lreport.setMilliseconds(report->milliseconds); - lreport.setTimeBias(report->time_bias); - lreport.setClockTimeUncertainty(report->clock_time_uncertainty); - lreport.setClockFrequencyBias(report->clock_frequency_bias); - lreport.setClockFrequencyUncertainty(report->clock_frequency_uncertainty); - - auto lsvs = lreport.initSv(report->sv_count); - for (int i=0; isv_count; i++) { - auto lsv = lsvs[i]; - const GNSSGlonassMeasurementReportv0_SV *sv = &report->sv[i]; - - lsv.setSvId(sv->sv_id); - lsv.setObservationState(cereal::QcomGnss::SVObservationState(sv->observation_state)); - lsv.setObservations(sv->observations); - lsv.setGoodObservations(sv->good_observations); - lsv.setGlonassFrequencyIndex(sv->frequency_index); - lsv.setGlonassHemmingErrorCount(sv->hemming_error_count); - lsv.setFilterStages(sv->filter_stages); - lsv.setCarrierNoise(sv->carrier_noise); - lsv.setLatency(sv->latency); - lsv.setPredetectInterval(sv->predetect_interval); - lsv.setPostdetections(sv->postdetections); - lsv.setUnfilteredMeasurementIntegral(sv->unfiltered_measurement_integral); - lsv.setUnfilteredMeasurementFraction(sv->unfiltered_measurement_fraction); - lsv.setUnfilteredTimeUncertainty(sv->unfiltered_time_uncertainty); - lsv.setUnfilteredSpeed(sv->unfiltered_speed); - lsv.setUnfilteredSpeedUncertainty(sv->unfiltered_speed_uncertainty); - - lsv.setMultipathEstimate(sv->multipath_estimate); - lsv.setAzimuth(sv->azimuth); - lsv.setElevation(sv->elevation); - lsv.setCarrierPhaseCyclesIntegral(sv->carrier_phase_cycles_integral); - lsv.setCarrierPhaseCyclesFraction(sv->carrier_phase_cycles_fraction); - lsv.setFineSpeed(sv->fine_speed); - lsv.setFineSpeedUncertainty(sv->fine_speed_uncertainty); - lsv.setCycleSlipCount(sv->cycle_slip_count); - - auto status = lsv.initMeasurementStatus(); - parse_measurement_status_common(sv->measurement_status, status); - - status.setGlonassMeanderBitEdgeValid(sv->measurement_status & (1 << 16)); - status.setGlonassTimeMarkValid(sv->measurement_status & (1 << 17)); - - status.setMultipathEstimateIsValid(sv->misc_status & (1 << 0)); - status.setDirectionIsValid(sv->misc_status & (1 << 1)); - - -#ifdef RAWGPS_TEST - // if (sv->measurement_status & (1 << 27)) printf("%d\n", sv->unfiltered_measurement_integral); - printf("GLO %03d %02x %d %d 0x%08X o: %02x go: %02x fs: %02x cn: %02x pd: %02x cs: %02x po: %02x ms: %08x ms2: %08x me: %08x az: %08x el: %08x fc: %08x\n", - sv->sv_id, sv->frequency_index & 0xff, - !!(sv->measurement_status & (1 << 27)), - sv->unfiltered_measurement_integral, sv->unfiltered_measurement_integral, - sv->observations, - sv->good_observations, - sv->filter_stages, - sv->carrier_noise, - sv->predetect_interval, - sv->cycle_slip_count, - sv->postdetections, - sv->measurement_status, - sv->misc_status, - sv->multipath_estimate, - *(uint32_t*)&sv->azimuth, - *(uint32_t*)&sv->elevation, - report->f_count - ); -#endif - - } - break; - } - case LOG_GNSS_OEMDRE_MEASUREMENMT_REPORT: { - // hexdump(ptr, len); - - uint8_t version = log_data[0]; - assert(version == 2); - - assert(len >= sizeof(GNSSOemdreMeasurementReportv2)); - const GNSSOemdreMeasurementReportv2* report = (const GNSSOemdreMeasurementReportv2*)ptr; - - - auto lreport = qcomGnss.initDrMeasurementReport(); - - lreport.setReason(report->reason); - lreport.setSeqNum(report->seq_num); - lreport.setSeqMax(report->seq_max); - lreport.setRfLoss(report->rf_loss); - lreport.setSystemRtcValid(report->system_rtc_valid); - lreport.setFCount(report->f_count); - lreport.setClockResets(report->clock_resets); - lreport.setSystemRtcTime(report->system_rtc_time); - - lreport.setGpsLeapSeconds(report->gps_leap_seconds); - lreport.setGpsLeapSecondsUncertainty(report->gps_leap_seconds_uncertainty); - lreport.setGpsToGlonassTimeBiasMilliseconds(report->gps_to_glonass_time_bias_milliseconds); - lreport.setGpsToGlonassTimeBiasMillisecondsUncertainty(report->gps_to_glonass_time_bias_milliseconds_uncertainty); - - lreport.setGpsWeek(report->gps_week); - lreport.setGpsMilliseconds(report->gps_milliseconds); - lreport.setGpsTimeBiasMs(report->gps_time_bias); - lreport.setGpsClockTimeUncertaintyMs(report->gps_clock_time_uncertainty); - lreport.setGpsClockSource(report->gps_clock_source); - - lreport.setGlonassClockSource(report->glonass_clock_source); - lreport.setGlonassYear(report->glonass_year); - lreport.setGlonassDay(report->glonass_day); - lreport.setGlonassMilliseconds(report->glonass_milliseconds); - lreport.setGlonassTimeBias(report->glonass_time_bias); - lreport.setGlonassClockTimeUncertainty(report->glonass_clock_time_uncertainty); - - lreport.setClockFrequencyBias(report->clock_frequency_bias); - lreport.setClockFrequencyUncertainty(report->clock_frequency_uncertainty); - lreport.setFrequencySource(report->frequency_source); - - lreport.setSource(cereal::QcomGnss::MeasurementSource(report->source)); - - auto lsvs = lreport.initSv(report->sv_count); - - // for (int i=0; isv_count; i++) { - // GNSSOemdreMeasurement *sv = &report->gps[i]; - // if (!(sv->measurement_status & (1 << 27))) continue; - // printf("oemdre %03d %d %f\n", sv->sv_id, sv->unfiltered_measurement_integral, sv->unfiltered_measurement_fraction); - // } - for (int i=0; isv_count; i++) { - auto lsv = lsvs[i]; - const GNSSOemdreMeasurement *sv = &report->measurements[i]; - - lsv.setSvId(sv->sv_id); - lsv.setGlonassFrequencyIndex(sv->glonass_frequency_index); - lsv.setObservationState(cereal::QcomGnss::SVObservationState(sv->observation_state)); - lsv.setObservations(sv->observations); - lsv.setGoodObservations(sv->good_observations); - lsv.setFilterStages(sv->filter_stages); - lsv.setPredetectInterval(sv->predetect_interval); - lsv.setCycleSlipCount(sv->cycle_slip_count); - lsv.setPostdetections(sv->postdetections); - - auto status = lsv.initMeasurementStatus(); - parse_measurement_status_common(sv->measurement_status, status); - - status.setMultipathEstimateIsValid(sv->multipath_estimate_valid); - status.setDirectionIsValid(sv->direction_valid); - - lsv.setCarrierNoise(sv->carrier_noise); - lsv.setRfLoss(sv->rf_loss); - lsv.setLatency(sv->latency); - - lsv.setFilteredMeasurementFraction(sv->filtered_measurement_fraction); - lsv.setFilteredMeasurementIntegral(sv->filtered_measurement_integral); - lsv.setFilteredTimeUncertainty(sv->filtered_time_uncertainty); - lsv.setFilteredSpeed(sv->filtered_speed); - lsv.setFilteredSpeedUncertainty(sv->filtered_speed_uncertainty); - - lsv.setUnfilteredMeasurementFraction(sv->unfiltered_measurement_fraction); - lsv.setUnfilteredMeasurementIntegral(sv->unfiltered_measurement_integral); - lsv.setUnfilteredTimeUncertainty(sv->unfiltered_time_uncertainty); - lsv.setUnfilteredSpeed(sv->unfiltered_speed); - lsv.setUnfilteredSpeedUncertainty(sv->unfiltered_speed_uncertainty); - - lsv.setMultipathEstimate(sv->multipath_estimate); - lsv.setAzimuth(sv->azimuth); - lsv.setElevation(sv->elevation); - lsv.setDopplerAcceleration(sv->doppler_acceleration); - lsv.setFineSpeed(sv->fine_speed); - lsv.setFineSpeedUncertainty(sv->fine_speed_uncertainty); - - lsv.setCarrierPhase(sv->carrier_phase); - lsv.setFCount(sv->f_count); - - lsv.setParityErrorCount(sv->parity_error_count); - lsv.setGoodParity(sv->good_parity); - - } - break; - } - case LOG_GNSS_OEMDRE_SVPOLY_REPORT: { - uint8_t version = log_data[0]; - assert(version == 2); - - assert(len >= sizeof(GNSSOemdreSVPolyReportv2)); - const GNSSOemdreSVPolyReportv2* report = (const GNSSOemdreSVPolyReportv2*)ptr; - - auto lreport = qcomGnss.initDrSvPoly(); - - lreport.setSvId(report->sv_id); - lreport.setFrequencyIndex(report->frequency_index); - - lreport.setHasPosition(report->flags & 1); - lreport.setHasIono(report->flags & 2); - lreport.setHasTropo(report->flags & 4); - lreport.setHasElevation(report->flags & 8); - lreport.setPolyFromXtra(report->flags & 16); - lreport.setHasSbasIono(report->flags & 32); - - lreport.setIode(report->iode); - lreport.setT0(report->t0); - - kj::ArrayPtr xyz0(report->xyz0, 3); - lreport.setXyz0(xyz0); - - kj::ArrayPtr xyzN(report->xyzN, 9); - lreport.setXyzN(xyzN); - - kj::ArrayPtr other(report->other, 4); - lreport.setOther(other); - - lreport.setPositionUncertainty(report->position_uncertainty); - lreport.setIonoDelay(report->iono_delay); - lreport.setIonoDot(report->iono_dot); - lreport.setSbasIonoDelay(report->sbas_iono_delay); - lreport.setSbasIonoDot(report->sbas_iono_dot); - lreport.setTropoDelay(report->tropo_delay); - lreport.setElevation(report->elevation); - lreport.setElevationDot(report->elevation_dot); - lreport.setElevationUncertainty(report->elevation_uncertainty); - - kj::ArrayPtr velocity_coeff(report->velocity_coeff, 12); - lreport.setVelocityCoeff(velocity_coeff); - - break; - } - default: - // printf("%04x\n", log_header->code); - // hexdump(ptr, len); - - qcomGnss.setRawLog(kj::arrayPtr(ptr, len)); - - break; - } - - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - zmq_send(rawgps_publisher, bytes.begin(), bytes.size(), 0); -} - -static void handle_event(unsigned char *ptr, int len) { - // printf("EVENT\n"); -} - -static uint16_t log_codes[] = { - LOG_GNSS_CLOCK_REPORT, - LOG_GNSS_GPS_MEASUREMENT_REPORT, - LOG_GNSS_GLONASS_MEASUREMENT_REPORT, - LOG_GNSS_OEMDRE_MEASUREMENMT_REPORT, - LOG_GNSS_OEMDRE_SVPOLY_REPORT, - - // unparsed: - LOG_GNSS_POSITION_REPORT, - - LOG_GNSS_BDS_MEASUREMENT_REPORT, // these are missing by might as well try to catch them anyway - LOG_GNSS_GAL_MEASUREMENT_REPORT, - - LOG_GNSS_ME_DPO_STATUS, - LOG_GNSS_CD_DB_REPORT, - LOG_GNSS_PRX_RF_HW_STATUS_REPORT, - LOG_CGPS_SLOW_CLOCK_CLIB_REPORT, - LOG_GNSS_CONFIGURATION_STATE, -}; - - -struct SendDiagSyncState { - sem_t sem; - int len; -}; - -static void diag_send_sync_cb(unsigned char *ptr, int len, void *data_ptr) { - SendDiagSyncState *s = (SendDiagSyncState*)data_ptr; - s->len = len; - sem_post(&s->sem); -} - -static int diag_send_sync(int client_id, unsigned char* req_pkt, size_t pkt_len, - unsigned char* res_pkt, size_t res_pkt_size) { - - SendDiagSyncState s = {0}; - sem_init(&s.sem, 0, 0); - - int err = diag_send_dci_async_req(client_id, req_pkt, pkt_len, res_pkt, res_pkt_size, - diag_send_sync_cb, &s); - assert(err == DIAG_DCI_NO_ERROR); - - sem_wait(&s.sem); - return s.len; -} - -static int oemdre_on(int client_id) { - // enable OEM DR - unsigned char res_pkt[DIAG_MAX_RX_PKT_SIZ]; - - GpsOemControlReq req_pkt = { - .cmd_code = DIAG_SUBSYS_CMD, - .subsys_id = DIAG_SUBSYS_GPS, - .subsys_cmd_code = CGPS_DIAG_PDAPI_CMD, - .gps_cmd_code = CGPS_OEM_CONTROL, - .version = 1, - - .oem_feature = GPSDIAG_OEMFEATURE_DRE, - .oem_command = GPSDIAG_OEM_DRE_ON, - }; - - int res_len = diag_send_sync(client_id, (unsigned char*)&req_pkt, sizeof(req_pkt), - res_pkt, sizeof(res_pkt)); - GpsOemControlResp *resp = (GpsOemControlResp*)res_pkt; - - if (res_len != sizeof(GpsOemControlResp) - || resp->cmd_code != DIAG_SUBSYS_CMD - || resp->subsys_id != DIAG_SUBSYS_GPS - || resp->subsys_cmd_code != CGPS_DIAG_PDAPI_CMD - || resp->gps_cmd_code != CGPS_OEM_CONTROL - || resp->oem_feature != GPSDIAG_OEMFEATURE_DRE - || resp->oem_command != GPSDIAG_OEM_DRE_ON) { - LOGW("oemdre_on: bad response!"); - return -1; - } - - return resp->resp_result; -} - -static void efs_sync(int client_id) { - unsigned char res_pkt[DIAG_MAX_RX_PKT_SIZ]; - - Efs2DiagSyncReq req_pkt = { - .cmd_code = DIAG_SUBSYS_CMD, - .subsys_id = DIAG_SUBSYS_FS, - .subsys_cmd_code = EFS2_DIAG_SYNC_NO_WAIT, - .sequence_num = (uint16_t)(rand() % 100), - }; - req_pkt.path[0] = '/'; - req_pkt.path[1] = 0; - - int res_len = diag_send_sync(client_id, (unsigned char*)&req_pkt, sizeof(req_pkt), - res_pkt, sizeof(res_pkt)); - Efs2DiagSyncResp *resp = (Efs2DiagSyncResp*)res_pkt; - - if (res_len != sizeof(Efs2DiagSyncResp) - || resp->cmd_code != DIAG_SUBSYS_CMD - || resp->subsys_id != DIAG_SUBSYS_FS - || resp->subsys_cmd_code != EFS2_DIAG_SYNC_NO_WAIT) { - LOGW("efs_sync: bad response!"); - return; - } - if (resp->diag_errno != 0) { - LOGW("efs_sync: error %d", resp->diag_errno); - } -} - -static uint32_t nv_read_u32(int client_id, uint16_t nv_id) { - NvPacket req = { - .cmd_code = DIAG_NV_READ_F, - .nv_id = nv_id, - }; - NvPacket resp = {0}; - - int res_len = diag_send_sync(client_id, (unsigned char*)&req, sizeof(req), - (unsigned char*)&resp, sizeof(resp)); - - // hexdump((uint8_t*)&resp, res_len); - - if (resp.cmd_code != DIAG_NV_READ_F - || resp.nv_id != nv_id) { - LOGW("nv_read_u32: diag command failed"); - return 0; - } - - if (resp.status != NV_DONE) { - LOGW("nv_read_u32: read failed: %d", resp.status); - return 0; - } - return *(uint32_t*)resp.data; -} - -static bool nv_write_u32(int client_id, uint16_t nv_id, uint32_t val) { - NvPacket req = { - .cmd_code = DIAG_NV_WRITE_F, - .nv_id = nv_id, - }; - *(uint32_t*)req.data = val; - - NvPacket resp = {0}; - int res_len = diag_send_sync(client_id, (unsigned char*)&req, sizeof(req), - (unsigned char*)&resp, sizeof(resp)); - - // hexdump((uint8_t*)&resp, res_len); - - if (resp.cmd_code != DIAG_NV_WRITE_F - || resp.nv_id != nv_id) { - LOGW("nv_write_u32: diag command failed"); - return false; - } - - if (resp.status != NV_DONE) { - LOGW("nv_write_u32: write failed: %d", resp.status); - return false; - } - - return true; -} - -static void nav_config(int client_id, uint8_t config) { - unsigned char res_pkt[DIAG_MAX_RX_PKT_SIZ]; - - GpsNavConfigReq req_pkt = { - .cmd_code = DIAG_SUBSYS_CMD_VER_2, - .subsys_id = DIAG_SUBSYS_GPS, - .subsys_cmd_code = TM_DIAG_NAV_CONFIG_CMD, - .desired_config = config, - }; - - int res_len = diag_send_sync(client_id, (unsigned char*)&req_pkt, sizeof(req_pkt), - res_pkt, sizeof(res_pkt)); - GpsNavConfigResp *resp = (GpsNavConfigResp*)res_pkt; - - if (res_len != sizeof(GpsNavConfigResp) - || resp->cmd_code != DIAG_SUBSYS_CMD_VER_2 - || resp->subsys_id != DIAG_SUBSYS_GPS - || resp->subsys_cmd_code != TM_DIAG_NAV_CONFIG_CMD) { - LOGW("nav_config: bad response!"); - return; - } - LOG("nav config: %04x %04x", resp->supported_config, resp->actual_config); -} - -void rawgps_init() { - int err; - - - rawgps_context = zmq_ctx_new(); - rawgps_publisher = zmq_socket(rawgps_context, ZMQ_PUB); - zmq_bind(rawgps_publisher, "tcp://*:8029"); - - - bool init_success = Diag_LSM_Init(NULL); - assert(init_success); - - uint16_t list = DIAG_CON_APSS | DIAG_CON_MPSS; - int signal_type = SIGCONT; - err = diag_register_dci_client(&client_id, &list, 0, &signal_type); - assert(err == DIAG_DCI_NO_ERROR); - - { - uint32_t oem_features = nv_read_u32(client_id, NV_GNSS_OEM_FEATURE_MASK); - LOG("oem features: %08x", oem_features); - - if (!(oem_features & NV_GNSS_OEM_FEATURE_MASK_OEMDRE)) { - LOG("OEMDRE feature disabled, enabling..."); - nv_write_u32(client_id, NV_GNSS_OEM_FEATURE_MASK, NV_GNSS_OEM_FEATURE_MASK_OEMDRE); - efs_sync(client_id); - } - - int oemdre_status = oemdre_on(client_id); - LOG("oemdre status: %d", oemdre_status); - } - - { - // make sure GNSS duty cycling is off - uint32_t dpo = nv_read_u32(client_id, NV_CGPS_DPO_CONTROL); - LOG("dpo: %d", dpo); - if (dpo != 0) { - nv_write_u32(client_id, NV_CGPS_DPO_CONTROL, 0); - efs_sync(client_id); - } - } - - // enable beidou - // nav_config(client_id, 0x13); // 0b10011 - - err = diag_register_dci_stream(handle_log, handle_event); - assert(err == DIAG_DCI_NO_ERROR); - - err = diag_log_stream_config(client_id, true, log_codes, ARRAYSIZE(log_codes)); - assert(err == DIAG_DCI_NO_ERROR); -} - -void rawgps_destroy() { - - int err; - - err = diag_log_stream_config(client_id, false, log_codes, ARRAYSIZE(log_codes)); - assert(err == DIAG_DCI_NO_ERROR); - - err = diag_release_dci_client(&client_id); - assert(err == DIAG_DCI_NO_ERROR); - - Diag_LSM_DeInit(); - - zmq_close(rawgps_publisher); - zmq_term(rawgps_context); - -} - - -#ifdef RAWGPS_TEST -int main() { - int err = 0; - rawgps_init(); - - while(1) { - usleep(100000); - } - - rawgps_destroy(); - return 0; -} -#endif \ No newline at end of file diff --git a/selfdrive/sensord/rawgps.h b/selfdrive/sensord/rawgps.h deleted file mode 100644 index 13d23cd28c9669..00000000000000 --- a/selfdrive/sensord/rawgps.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef RAWGPS_H -#define RAWGPS_H - -void rawgps_init(); -void rawgps_destroy(); - -#endif diff --git a/selfdrive/sensord/sensord b/selfdrive/sensord/sensord new file mode 100755 index 00000000000000..d2bffaa12179d2 --- /dev/null +++ b/selfdrive/sensord/sensord @@ -0,0 +1,3 @@ +#!/bin/sh +export LD_LIBRARY_PATH="/system/lib64:$LD_LIBRARY_PATH" +exec ./_sensord diff --git a/selfdrive/sensord/sensors.cc b/selfdrive/sensord/sensors.cc deleted file mode 100644 index 5717458f7215f4..00000000000000 --- a/selfdrive/sensord/sensors.cc +++ /dev/null @@ -1,232 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include - -#include - -#include - -#include "common/timing.h" -#include "common/swaglog.h" - -#include "cereal/gen/cpp/log.capnp.h" - -#define SENSOR_ACCELEROMETER 1 -#define SENSOR_MAGNETOMETER 2 -#define SENSOR_GYRO 4 - -// ACCELEROMETER_UNCALIBRATED is only in Android O -// https://developer.android.com/reference/android/hardware/Sensor.html#STRING_TYPE_ACCELEROMETER_UNCALIBRATED -#define SENSOR_MAGNETOMETER_UNCALIBRATED 3 -#define SENSOR_GYRO_UNCALIBRATED 5 - -#define SENSOR_PROXIMITY 6 -#define SENSOR_LIGHT 7 - -volatile int do_exit = 0; - -namespace { - -void set_do_exit(int sig) { - do_exit = 1; -} - -void sigpipe_handler(int sig) { - LOGE("SIGPIPE received"); -} - - -void sensor_loop() { - LOG("*** sensor loop"); - struct sensors_poll_device_t* device; - struct sensors_module_t* module; - - hw_get_module(SENSORS_HARDWARE_MODULE_ID, (hw_module_t const**)&module); - sensors_open(&module->common, &device); - - // required - struct sensor_t const* list; - int count = module->get_sensors_list(module, &list); - LOG("%d sensors found", count); - - if (getenv("SENSOR_TEST")) { - exit(count); - } - - for (int i = 0; i < count; i++) { - LOGD("sensor %4d: %4d %60s %d-%ld us", i, list[i].handle, list[i].name, list[i].minDelay, list[i].maxDelay); - } - - device->activate(device, SENSOR_MAGNETOMETER_UNCALIBRATED, 0); - device->activate(device, SENSOR_GYRO_UNCALIBRATED, 0); - device->activate(device, SENSOR_ACCELEROMETER, 0); - device->activate(device, SENSOR_MAGNETOMETER, 0); - device->activate(device, SENSOR_GYRO, 0); - device->activate(device, SENSOR_PROXIMITY, 0); - device->activate(device, SENSOR_LIGHT, 0); - - device->activate(device, SENSOR_MAGNETOMETER_UNCALIBRATED, 1); - device->activate(device, SENSOR_GYRO_UNCALIBRATED, 1); - device->activate(device, SENSOR_ACCELEROMETER, 1); - device->activate(device, SENSOR_MAGNETOMETER, 1); - device->activate(device, SENSOR_GYRO, 1); - device->activate(device, SENSOR_PROXIMITY, 1); - device->activate(device, SENSOR_LIGHT, 1); - - device->setDelay(device, SENSOR_GYRO_UNCALIBRATED, ms2ns(10)); - device->setDelay(device, SENSOR_MAGNETOMETER_UNCALIBRATED, ms2ns(100)); - device->setDelay(device, SENSOR_ACCELEROMETER, ms2ns(10)); - device->setDelay(device, SENSOR_GYRO, ms2ns(10)); - device->setDelay(device, SENSOR_MAGNETOMETER, ms2ns(100)); - device->setDelay(device, SENSOR_PROXIMITY, ms2ns(100)); - device->setDelay(device, SENSOR_LIGHT, ms2ns(100)); - - static const size_t numEvents = 16; - sensors_event_t buffer[numEvents]; - - auto sensor_events_sock = zsock_new_pub("@tcp://*:8003"); - assert(sensor_events_sock); - auto sensor_events_sock_raw = zsock_resolve(sensor_events_sock); - - while (!do_exit) { - int n = device->poll(device, buffer, numEvents); - if (n == 0) continue; - if (n < 0) { - LOG("sensor_loop poll failed: %d", n); - continue; - } - - int log_events = 0; - for (int i=0; i < n; i++) { - switch (buffer[i].type) { - case SENSOR_TYPE_ACCELEROMETER: - case SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED: - case SENSOR_TYPE_MAGNETIC_FIELD: - case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED: - case SENSOR_TYPE_GYROSCOPE: - case SENSOR_TYPE_PROXIMITY: - case SENSOR_TYPE_LIGHT: - log_events++; - break; - default: - continue; - } - } - - uint64_t log_time = nanos_since_boot(); - - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(log_time); - - auto sensor_events = event.initSensorEvents(log_events); - - int log_i = 0; - for (int i = 0; i < n; i++) { - - const sensors_event_t& data = buffer[i]; - - switch (data.type) { - case SENSOR_TYPE_ACCELEROMETER: - case SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED: - case SENSOR_TYPE_MAGNETIC_FIELD: - case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED: - case SENSOR_TYPE_GYROSCOPE: - case SENSOR_TYPE_PROXIMITY: - case SENSOR_TYPE_LIGHT: - break; - default: - continue; - } - - auto log_event = sensor_events[log_i]; - - log_event.setSource(cereal::SensorEventData::SensorSource::ANDROID); - log_event.setVersion(data.version); - log_event.setSensor(data.sensor); - log_event.setType(data.type); - log_event.setTimestamp(data.timestamp); - - switch (data.type) { - case SENSOR_TYPE_ACCELEROMETER: { - auto svec = log_event.initAcceleration(); - kj::ArrayPtr vs(&data.acceleration.v[0], 3); - svec.setV(vs); - svec.setStatus(data.acceleration.status); - break; - } - case SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED: { - auto svec = log_event.initMagneticUncalibrated(); - // assuming the uncalib and bias floats are contiguous in memory - kj::ArrayPtr vs(&data.uncalibrated_magnetic.uncalib[0], 6); - svec.setV(vs); - break; - } - case SENSOR_TYPE_MAGNETIC_FIELD: { - auto svec = log_event.initMagnetic(); - kj::ArrayPtr vs(&data.magnetic.v[0], 3); - svec.setV(vs); - svec.setStatus(data.magnetic.status); - break; - } - case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED: { - auto svec = log_event.initGyroUncalibrated(); - // assuming the uncalib and bias floats are contiguous in memory - kj::ArrayPtr vs(&data.uncalibrated_gyro.uncalib[0], 6); - svec.setV(vs); - break; - } - case SENSOR_TYPE_GYROSCOPE: { - auto svec = log_event.initGyro(); - kj::ArrayPtr vs(&data.gyro.v[0], 3); - svec.setV(vs); - svec.setStatus(data.gyro.status); - break; - } - case SENSOR_TYPE_PROXIMITY: { - log_event.setProximity(data.distance); - break; - } - case SENSOR_TYPE_LIGHT: - log_event.setLight(data.light); - break; - } - - log_i++; - } - - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - zmq_send(sensor_events_sock_raw, bytes.begin(), bytes.size(), ZMQ_DONTWAIT); - - } - LOG("bye"); -} - -} - -int main(int argc, char *argv[]) { - setpriority(PRIO_PROCESS, 0, -13); - signal(SIGINT, (sighandler_t)set_do_exit); - signal(SIGTERM, (sighandler_t)set_do_exit); - signal(SIGPIPE, (sighandler_t)sigpipe_handler); - - sensor_loop(); - - return 0; -} diff --git a/selfdrive/sensord/sensors/bmx055_accel.cc b/selfdrive/sensord/sensors/bmx055_accel.cc new file mode 100644 index 00000000000000..cb78ba0ad438db --- /dev/null +++ b/selfdrive/sensord/sensors/bmx055_accel.cc @@ -0,0 +1,69 @@ +#include +#include "common/swaglog.h" +#include "common/timing.h" + +#include "bmx055_accel.hpp" + + +BMX055_Accel::BMX055_Accel(I2CBus *bus) : I2CSensor(bus) {} + +int BMX055_Accel::init(){ + int ret = 0; + uint8_t buffer[1]; + + ret = read_register(BMX055_ACCEL_I2C_REG_ID, buffer, 1); + if(ret < 0){ + LOGE("Reading chip ID failed: %d", ret); + goto fail; + } + + if(buffer[0] != BMX055_ACCEL_CHIP_ID){ + LOGE("Chip ID wrong. Got: %d, Expected %d", buffer[0], BMX055_ACCEL_CHIP_ID); + ret = -1; + goto fail; + } + + // High bandwidth + // ret = set_register(BMX055_ACCEL_I2C_REG_HBW, BMX055_ACCEL_HBW_ENABLE); + // if (ret < 0){ + // goto fail; + // } + + // Low bandwidth + ret = set_register(BMX055_ACCEL_I2C_REG_HBW, BMX055_ACCEL_HBW_DISABLE); + if (ret < 0){ + goto fail; + } + ret = set_register(BMX055_ACCEL_I2C_REG_BW, BMX055_ACCEL_BW_125HZ); + if (ret < 0){ + goto fail; + } + +fail: + return ret; +} + +void BMX055_Accel::get_event(cereal::SensorEventData::Builder &event){ + uint64_t start_time = nanos_since_boot(); + uint8_t buffer[6]; + int len = read_register(BMX055_ACCEL_I2C_REG_FIFO, buffer, sizeof(buffer)); + assert(len == 6); + + // 12 bit = +-2g + float scale = 9.81 * 2.0f / (1 << 11); + float x = -read_12_bit(buffer[0], buffer[1]) * scale; + float y = -read_12_bit(buffer[2], buffer[3]) * scale; + float z = read_12_bit(buffer[4], buffer[5]) * scale; + + event.setSource(cereal::SensorEventData::SensorSource::BMX055); + event.setVersion(1); + event.setSensor(SENSOR_ACCELEROMETER); + event.setType(SENSOR_TYPE_ACCELEROMETER); + event.setTimestamp(start_time); + + float xyz[] = {x, y, z}; + auto svec = event.initAcceleration(); + svec.setV(xyz); + svec.setStatus(true); + +} diff --git a/selfdrive/sensord/sensors/bmx055_accel.hpp b/selfdrive/sensord/sensors/bmx055_accel.hpp new file mode 100644 index 00000000000000..4e613af7c98506 --- /dev/null +++ b/selfdrive/sensord/sensors/bmx055_accel.hpp @@ -0,0 +1,36 @@ +#pragma once + +#include "sensors/i2c_sensor.hpp" + +// Address of the chip on the bus +#define BMX055_ACCEL_I2C_ADDR 0x18 + +// Registers of the chip +#define BMX055_ACCEL_I2C_REG_ID 0x00 +#define BMX055_ACCEL_I2C_REG_TEMP 0x08 +#define BMX055_ACCEL_I2C_REG_BW 0x10 +#define BMX055_ACCEL_I2C_REG_HBW 0x13 +#define BMX055_ACCEL_I2C_REG_FIFO 0x3F + +// Constants +#define BMX055_ACCEL_CHIP_ID 0xFA + +#define BMX055_ACCEL_HBW_ENABLE 0b10000000 +#define BMX055_ACCEL_HBW_DISABLE 0b00000000 + +#define BMX055_ACCEL_BW_7_81HZ 0b01000 +#define BMX055_ACCEL_BW_15_63HZ 0b01001 +#define BMX055_ACCEL_BW_31_25HZ 0b01010 +#define BMX055_ACCEL_BW_62_5HZ 0b01011 +#define BMX055_ACCEL_BW_125HZ 0b01100 +#define BMX055_ACCEL_BW_250HZ 0b01101 +#define BMX055_ACCEL_BW_500HZ 0b01110 +#define BMX055_ACCEL_BW_1000HZ 0b01111 + +class BMX055_Accel : public I2CSensor { + uint8_t get_device_address() {return BMX055_ACCEL_I2C_ADDR;} +public: + BMX055_Accel(I2CBus *bus); + int init(); + void get_event(cereal::SensorEventData::Builder &event); +}; diff --git a/selfdrive/sensord/sensors/bmx055_gyro.cc b/selfdrive/sensord/sensors/bmx055_gyro.cc new file mode 100644 index 00000000000000..38a2ff427c0395 --- /dev/null +++ b/selfdrive/sensord/sensors/bmx055_gyro.cc @@ -0,0 +1,79 @@ +#include +#include +#include "common/swaglog.h" + +#include "bmx055_gyro.hpp" + +#define DEG2RAD(x) ((x) * M_PI / 180.0) + + +BMX055_Gyro::BMX055_Gyro(I2CBus *bus) : I2CSensor(bus) {} + +int BMX055_Gyro::init(){ + int ret = 0; + uint8_t buffer[1]; + + ret =read_register(BMX055_GYRO_I2C_REG_ID, buffer, 1); + if(ret < 0){ + LOGE("Reading chip ID failed: %d", ret); + goto fail; + } + + if(buffer[0] != BMX055_GYRO_CHIP_ID){ + LOGE("Chip ID wrong. Got: %d, Expected %d", buffer[0], BMX055_GYRO_CHIP_ID); + ret = -1; + goto fail; + } + + // High bandwidth + // ret = set_register(BMX055_GYRO_I2C_REG_HBW, BMX055_GYRO_HBW_ENABLE); + // if (ret < 0){ + // goto fail; + // } + + // Low bandwidth + ret = set_register(BMX055_GYRO_I2C_REG_HBW, BMX055_GYRO_HBW_DISABLE); + if (ret < 0){ + goto fail; + } + + // 116 Hz filter + ret = set_register(BMX055_GYRO_I2C_REG_BW, BMX055_GYRO_BW_116HZ); + if (ret < 0){ + goto fail; + } + + // +- 125 deg/s range + ret = set_register(BMX055_GYRO_I2C_REG_RANGE, BMX055_GYRO_RANGE_125); + if (ret < 0){ + goto fail; + } + +fail: + return ret; +} + +void BMX055_Gyro::get_event(cereal::SensorEventData::Builder &event){ + uint64_t start_time = nanos_since_boot(); + uint8_t buffer[6]; + int len = read_register(BMX055_GYRO_I2C_REG_FIFO, buffer, sizeof(buffer)); + assert(len == 6); + + // 16 bit = +- 125 deg/s + float scale = 125.0f / (1 << 15); + float x = -DEG2RAD(read_16_bit(buffer[0], buffer[1]) * scale); + float y = -DEG2RAD(read_16_bit(buffer[2], buffer[3]) * scale); + float z = DEG2RAD(read_16_bit(buffer[4], buffer[5]) * scale); + + event.setSource(cereal::SensorEventData::SensorSource::BMX055); + event.setVersion(1); + event.setSensor(SENSOR_GYRO_UNCALIBRATED); + event.setType(SENSOR_TYPE_GYROSCOPE_UNCALIBRATED); + event.setTimestamp(start_time); + + float xyz[] = {x, y, z}; + auto svec = event.initGyroUncalibrated(); + svec.setV(xyz); + svec.setStatus(true); + +} diff --git a/selfdrive/sensord/sensors/bmx055_gyro.hpp b/selfdrive/sensord/sensors/bmx055_gyro.hpp new file mode 100644 index 00000000000000..407ee1608eebd7 --- /dev/null +++ b/selfdrive/sensord/sensors/bmx055_gyro.hpp @@ -0,0 +1,36 @@ +#pragma once + +#include "sensors/i2c_sensor.hpp" + +// Address of the chip on the bus +#define BMX055_GYRO_I2C_ADDR 0x68 + +// Registers of the chip +#define BMX055_GYRO_I2C_REG_ID 0x00 +#define BMX055_GYRO_I2C_REG_RANGE 0x0F +#define BMX055_GYRO_I2C_REG_BW 0x10 +#define BMX055_GYRO_I2C_REG_HBW 0x13 +#define BMX055_GYRO_I2C_REG_FIFO 0x3F + +// Constants +#define BMX055_GYRO_CHIP_ID 0x0F + +#define BMX055_GYRO_HBW_ENABLE 0b10000000 +#define BMX055_GYRO_HBW_DISABLE 0b00000000 + +#define BMX055_GYRO_RANGE_2000 0b000 +#define BMX055_GYRO_RANGE_1000 0b001 +#define BMX055_GYRO_RANGE_500 0b010 +#define BMX055_GYRO_RANGE_250 0b011 +#define BMX055_GYRO_RANGE_125 0b100 + +#define BMX055_GYRO_BW_116HZ 0b0010 + + +class BMX055_Gyro : public I2CSensor { + uint8_t get_device_address() {return BMX055_GYRO_I2C_ADDR;} +public: + BMX055_Gyro(I2CBus *bus); + int init(); + void get_event(cereal::SensorEventData::Builder &event); +}; diff --git a/selfdrive/sensord/sensors/bmx055_magn.cc b/selfdrive/sensord/sensors/bmx055_magn.cc new file mode 100644 index 00000000000000..fbe43c206c705d --- /dev/null +++ b/selfdrive/sensord/sensors/bmx055_magn.cc @@ -0,0 +1,109 @@ +#include +#include +#include + +#include "common/swaglog.h" + +#include "bmx055_magn.hpp" + +static int16_t parse_xy(uint8_t lsb, uint8_t msb){ + // 13 bit + uint16_t combined = (uint16_t(msb) << 5) | uint16_t(lsb >> 3); + return int16_t(combined << 3) / (1 << 3); +} + +static int16_t parse_z(uint8_t lsb, uint8_t msb){ + // 15 bit + uint16_t combined = (uint16_t(msb) << 7) | uint16_t(lsb >> 1); + return int16_t(combined << 1) / (1 << 1); +} + +/* +static uint16_t parse_rhall(uint8_t lsb, uint8_t msb){ + // 14 bit + return (uint16_t(msb) << 6) | uint16_t(lsb >> 2); +} +*/ + +BMX055_Magn::BMX055_Magn(I2CBus *bus) : I2CSensor(bus) {} + +int BMX055_Magn::init(){ + int ret; + uint8_t buffer[1]; + + // suspend -> sleep + ret = set_register(BMX055_MAGN_I2C_REG_PWR_0, 0x01); + if(ret < 0){ + LOGE("Enabling power failed: %d", ret); + goto fail; + } + usleep(5 * 1000); // wait until the chip is powered on + + // read chip ID + ret = read_register(BMX055_MAGN_I2C_REG_ID, buffer, 1); + if(ret < 0){ + LOGE("Reading chip ID failed: %d", ret); + goto fail; + } + + if(buffer[0] != BMX055_MAGN_CHIP_ID){ + LOGE("Chip ID wrong. Got: %d, Expected %d", buffer[0], BMX055_MAGN_CHIP_ID); + return -1; + } + + // TODO: perform self-test + + // 9 REPXY and 15 REPZ for 100 Hz + // 3 REPXY and 3 REPZ for > 300 Hz + ret = set_register(BMX055_MAGN_I2C_REG_REPXY, (3 - 1) / 2); + if (ret < 0){ + goto fail; + } + + ret = set_register(BMX055_MAGN_I2C_REG_REPZ, 3 - 1); + if (ret < 0){ + goto fail; + } + + return 0; + + fail: + return ret; +} + + +void BMX055_Magn::get_event(cereal::SensorEventData::Builder &event){ + uint64_t start_time = nanos_since_boot(); + uint8_t buffer[8]; + + int len = read_register(BMX055_MAGN_I2C_REG_DATAX_LSB, buffer, sizeof(buffer)); + assert(len == sizeof(buffer)); + + bool ready = buffer[6] & 0x1; + if (ready){ + float x = parse_xy(buffer[0], buffer[1]); + float y = parse_xy(buffer[2], buffer[3]); + float z = parse_z(buffer[4], buffer[5]); + //uint16_t rhall = parse_rhall(buffer[5], buffer[6]); + + // TODO: convert to micro tesla: + // https://github.com/BoschSensortec/BMM150-Sensor-API/blob/master/bmm150.c#L1614 + + event.setSource(cereal::SensorEventData::SensorSource::BMX055); + event.setVersion(1); + event.setSensor(SENSOR_MAGNETOMETER_UNCALIBRATED); + event.setType(SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED); + event.setTimestamp(start_time); + + float xyz[] = {x, y, z}; + auto svec = event.initMagneticUncalibrated(); + svec.setV(xyz); + svec.setStatus(true); + } + + // The BMX055 Magnetometer has no FIFO mode. Self running mode only goes + // up to 30 Hz. Therefore we put in forced mode, and request measurements + // at a 100 Hz. When reading the registers we have to check the ready bit + // To verify the measurement was comleted this cycle. + set_register(BMX055_MAGN_I2C_REG_MAG, BMX055_MAGN_FORCED); +} diff --git a/selfdrive/sensord/sensors/bmx055_magn.hpp b/selfdrive/sensord/sensors/bmx055_magn.hpp new file mode 100644 index 00000000000000..ba4942d72fc5ee --- /dev/null +++ b/selfdrive/sensord/sensors/bmx055_magn.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include "sensors/i2c_sensor.hpp" + +// Address of the chip on the bus +#define BMX055_MAGN_I2C_ADDR 0x10 + +// Registers of the chip +#define BMX055_MAGN_I2C_REG_ID 0x40 +#define BMX055_MAGN_I2C_REG_PWR_0 0x4B +#define BMX055_MAGN_I2C_REG_MAG 0x4C +#define BMX055_MAGN_I2C_REG_DATAX_LSB 0x42 +#define BMX055_MAGN_I2C_REG_RHALL_LSB 0x48 +#define BMX055_MAGN_I2C_REG_REPXY 0x51 +#define BMX055_MAGN_I2C_REG_REPZ 0x52 + +// Constants +#define BMX055_MAGN_CHIP_ID 0x32 +#define BMX055_MAGN_FORCED (0b01 << 1) + +class BMX055_Magn : public I2CSensor{ + uint8_t get_device_address() {return BMX055_MAGN_I2C_ADDR;} +public: + BMX055_Magn(I2CBus *bus); + int init(); + void get_event(cereal::SensorEventData::Builder &event); +}; diff --git a/selfdrive/sensord/sensors/bmx055_temp.cc b/selfdrive/sensord/sensors/bmx055_temp.cc new file mode 100644 index 00000000000000..86f7d4f0c1ffee --- /dev/null +++ b/selfdrive/sensord/sensors/bmx055_temp.cc @@ -0,0 +1,44 @@ +#include +#include "common/swaglog.h" +#include "common/timing.h" + +#include "bmx055_temp.hpp" +#include "bmx055_accel.hpp" + + +BMX055_Temp::BMX055_Temp(I2CBus *bus) : I2CSensor(bus) {} + +int BMX055_Temp::init(){ + int ret = 0; + uint8_t buffer[1]; + + ret = read_register(BMX055_ACCEL_I2C_REG_ID, buffer, 1); + if(ret < 0){ + LOGE("Reading chip ID failed: %d", ret); + goto fail; + } + + if(buffer[0] != BMX055_ACCEL_CHIP_ID){ + LOGE("Chip ID wrong. Got: %d, Expected %d", buffer[0], BMX055_ACCEL_CHIP_ID); + ret = -1; + goto fail; + } + +fail: + return ret; +} + +void BMX055_Temp::get_event(cereal::SensorEventData::Builder &event){ + uint64_t start_time = nanos_since_boot(); + uint8_t buffer[1]; + int len = read_register(BMX055_ACCEL_I2C_REG_TEMP, buffer, sizeof(buffer)); + assert(len == sizeof(buffer)); + + float temp = 23.0f + int8_t(buffer[0]) / 2.0f; + + event.setSource(cereal::SensorEventData::SensorSource::BMX055); + event.setVersion(1); + event.setType(SENSOR_TYPE_AMBIENT_TEMPERATURE); + event.setTimestamp(start_time); + event.setTemperature(temp); +} diff --git a/selfdrive/sensord/sensors/bmx055_temp.hpp b/selfdrive/sensord/sensors/bmx055_temp.hpp new file mode 100644 index 00000000000000..8b7119a607d652 --- /dev/null +++ b/selfdrive/sensord/sensors/bmx055_temp.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "sensors/i2c_sensor.hpp" +#include "sensors/bmx055_accel.hpp" + + +class BMX055_Temp : public I2CSensor { + uint8_t get_device_address() {return BMX055_ACCEL_I2C_ADDR;} +public: + BMX055_Temp(I2CBus *bus); + int init(); + void get_event(cereal::SensorEventData::Builder &event); +}; diff --git a/selfdrive/sensord/sensors/constants.hpp b/selfdrive/sensord/sensors/constants.hpp new file mode 100644 index 00000000000000..c216f838a5ab0e --- /dev/null +++ b/selfdrive/sensord/sensors/constants.hpp @@ -0,0 +1,18 @@ +#pragma once + + +#define SENSOR_ACCELEROMETER 1 +#define SENSOR_MAGNETOMETER 2 +#define SENSOR_MAGNETOMETER_UNCALIBRATED 3 +#define SENSOR_GYRO 4 +#define SENSOR_GYRO_UNCALIBRATED 5 +#define SENSOR_LIGHT 7 + +#define SENSOR_TYPE_ACCELEROMETER 1 +#define SENSOR_TYPE_GEOMAGNETIC_FIELD 2 +#define SENSOR_TYPE_GYROSCOPE 4 +#define SENSOR_TYPE_LIGHT 5 +#define SENSOR_TYPE_AMBIENT_TEMPERATURE 13 +#define SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED 14 +#define SENSOR_TYPE_MAGNETIC_FIELD SENSOR_TYPE_GEOMAGNETIC_FIELD +#define SENSOR_TYPE_GYROSCOPE_UNCALIBRATED 16 diff --git a/selfdrive/sensord/sensors/file_sensor.cc b/selfdrive/sensord/sensors/file_sensor.cc new file mode 100644 index 00000000000000..6d03ef1b1f4a2b --- /dev/null +++ b/selfdrive/sensord/sensors/file_sensor.cc @@ -0,0 +1,15 @@ +#include +#include + +#include "file_sensor.hpp" + +FileSensor::FileSensor(std::string filename) : file(filename) { +} + +int FileSensor::init() { + return file.is_open() ? 0 : 1; +} + +FileSensor::~FileSensor(){ + file.close(); +} diff --git a/selfdrive/sensord/sensors/file_sensor.hpp b/selfdrive/sensord/sensors/file_sensor.hpp new file mode 100644 index 00000000000000..25a6f203c8cc3f --- /dev/null +++ b/selfdrive/sensord/sensors/file_sensor.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include +#include + +#include "cereal/gen/cpp/log.capnp.h" +#include "sensors/sensor.hpp" + + +class FileSensor : public Sensor { +protected: + std::ifstream file; + +public: + FileSensor(std::string filename); + ~FileSensor(); + int init(); + virtual void get_event(cereal::SensorEventData::Builder &event) = 0; +}; diff --git a/selfdrive/sensord/sensors/i2c_sensor.cc b/selfdrive/sensord/sensors/i2c_sensor.cc new file mode 100644 index 00000000000000..e3000c8b02ac48 --- /dev/null +++ b/selfdrive/sensord/sensors/i2c_sensor.cc @@ -0,0 +1,24 @@ +#include +#include "i2c_sensor.hpp" + +int16_t read_12_bit(uint8_t lsb, uint8_t msb){ + uint16_t combined = (uint16_t(msb) << 8) | uint16_t(lsb & 0xF0); + return int16_t(combined) / (1 << 4); +} + +int16_t read_16_bit(uint8_t lsb, uint8_t msb){ + uint16_t combined = (uint16_t(msb) << 8) | uint16_t(lsb); + return int16_t(combined); +} + + +I2CSensor::I2CSensor(I2CBus *bus) : bus(bus){ +} + +int I2CSensor::read_register(uint register_address, uint8_t *buffer, uint8_t len){ + return bus->read_register(get_device_address(), register_address, buffer, len); +} + +int I2CSensor::set_register(uint register_address, uint8_t data){ + return bus->set_register(get_device_address(), register_address, data); +} diff --git a/selfdrive/sensord/sensors/i2c_sensor.hpp b/selfdrive/sensord/sensors/i2c_sensor.hpp new file mode 100644 index 00000000000000..39ef79cf836828 --- /dev/null +++ b/selfdrive/sensord/sensors/i2c_sensor.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include +#include "cereal/gen/cpp/log.capnp.h" +#include "common/i2c.h" +#include "sensors/sensor.hpp" +#include "sensors/constants.hpp" + +int16_t read_12_bit(uint8_t lsb, uint8_t msb); +int16_t read_16_bit(uint8_t lsb, uint8_t msb); + + +class I2CSensor : public Sensor { +private: + I2CBus *bus; + virtual uint8_t get_device_address() = 0; + +public: + I2CSensor(I2CBus *bus); + int read_register(uint register_address, uint8_t *buffer, uint8_t len); + int set_register(uint register_address, uint8_t data); + virtual int init() = 0; + virtual void get_event(cereal::SensorEventData::Builder &event) = 0; +}; diff --git a/selfdrive/sensord/sensors/light_sensor.cc b/selfdrive/sensord/sensors/light_sensor.cc new file mode 100644 index 00000000000000..eb3eb05f17e30f --- /dev/null +++ b/selfdrive/sensord/sensors/light_sensor.cc @@ -0,0 +1,23 @@ +#include +#include + +#include "common/timing.h" + +#include "light_sensor.hpp" +#include "constants.hpp" + +void LightSensor::get_event(cereal::SensorEventData::Builder &event){ + uint64_t start_time = nanos_since_boot(); + file.clear(); + file.seekg(0); + + int value; + file >> value; + + event.setSource(cereal::SensorEventData::SensorSource::RPR0521); + event.setVersion(1); + event.setSensor(SENSOR_LIGHT); + event.setType(SENSOR_TYPE_LIGHT); + event.setTimestamp(start_time); + event.setLight(value); +} diff --git a/selfdrive/sensord/sensors/light_sensor.hpp b/selfdrive/sensord/sensors/light_sensor.hpp new file mode 100644 index 00000000000000..7c98cb29cf3d03 --- /dev/null +++ b/selfdrive/sensord/sensors/light_sensor.hpp @@ -0,0 +1,8 @@ +#pragma once +#include "file_sensor.hpp" + +class LightSensor : public FileSensor { +public: + LightSensor(std::string filename) : FileSensor(filename){}; + void get_event(cereal::SensorEventData::Builder &event); +}; diff --git a/selfdrive/sensord/sensors/lsm6ds3_accel.cc b/selfdrive/sensord/sensors/lsm6ds3_accel.cc new file mode 100644 index 00000000000000..15a186725996a0 --- /dev/null +++ b/selfdrive/sensord/sensors/lsm6ds3_accel.cc @@ -0,0 +1,60 @@ +#include +#include "common/swaglog.h" +#include "common/timing.h" + +#include "lsm6ds3_accel.hpp" + + +LSM6DS3_Accel::LSM6DS3_Accel(I2CBus *bus) : I2CSensor(bus) {} + +int LSM6DS3_Accel::init(){ + int ret = 0; + uint8_t buffer[1]; + + ret = read_register(LSM6DS3_ACCEL_I2C_REG_ID, buffer, 1); + if(ret < 0){ + LOGE("Reading chip ID failed: %d", ret); + goto fail; + } + + if(buffer[0] != LSM6DS3_ACCEL_CHIP_ID){ + LOGE("Chip ID wrong. Got: %d, Expected %d", buffer[0], LSM6DS3_ACCEL_CHIP_ID); + ret = -1; + goto fail; + } + + // TODO: set scale and bandwith. Default is +- 2G, 50 Hz + ret = set_register(LSM6DS3_ACCEL_I2C_REG_CTRL1_XL, LSM6DS3_ACCEL_ODR_104HZ); + if (ret < 0){ + goto fail; + } + + +fail: + return ret; +} + +void LSM6DS3_Accel::get_event(cereal::SensorEventData::Builder &event){ + + uint64_t start_time = nanos_since_boot(); + uint8_t buffer[6]; + int len = read_register(LSM6DS3_ACCEL_I2C_REG_OUTX_L_XL, buffer, sizeof(buffer)); + assert(len == sizeof(buffer)); + + float scale = 9.81 * 2.0f / (1 << 15); + float x = read_16_bit(buffer[0], buffer[1]) * scale; + float y = read_16_bit(buffer[2], buffer[3]) * scale; + float z = read_16_bit(buffer[4], buffer[5]) * scale; + + event.setSource(cereal::SensorEventData::SensorSource::LSM6DS3); + event.setVersion(1); + event.setSensor(SENSOR_ACCELEROMETER); + event.setType(SENSOR_TYPE_ACCELEROMETER); + event.setTimestamp(start_time); + + float xyz[] = {y, -x, z}; + auto svec = event.initAcceleration(); + svec.setV(xyz); + svec.setStatus(true); + +} diff --git a/selfdrive/sensord/sensors/lsm6ds3_accel.hpp b/selfdrive/sensord/sensors/lsm6ds3_accel.hpp new file mode 100644 index 00000000000000..314dcf8b52b034 --- /dev/null +++ b/selfdrive/sensord/sensors/lsm6ds3_accel.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include "sensors/i2c_sensor.hpp" + +// Address of the chip on the bus +#define LSM6DS3_ACCEL_I2C_ADDR 0x6A + +// Registers of the chip +#define LSM6DS3_ACCEL_I2C_REG_ID 0x0F +#define LSM6DS3_ACCEL_I2C_REG_CTRL1_XL 0x10 +#define LSM6DS3_ACCEL_I2C_REG_OUTX_L_XL 0x28 + +// Constants +#define LSM6DS3_ACCEL_CHIP_ID 0x69 +#define LSM6DS3_ACCEL_ODR_104HZ (0b0100 << 4) + + +class LSM6DS3_Accel : public I2CSensor { + uint8_t get_device_address() {return LSM6DS3_ACCEL_I2C_ADDR;} +public: + LSM6DS3_Accel(I2CBus *bus); + int init(); + void get_event(cereal::SensorEventData::Builder &event); +}; diff --git a/selfdrive/sensord/sensors/lsm6ds3_gyro.cc b/selfdrive/sensord/sensors/lsm6ds3_gyro.cc new file mode 100644 index 00000000000000..4c983e5448afea --- /dev/null +++ b/selfdrive/sensord/sensors/lsm6ds3_gyro.cc @@ -0,0 +1,63 @@ +#include +#include +#include "common/swaglog.h" +#include "common/timing.h" + +#include "lsm6ds3_gyro.hpp" + +#define DEG2RAD(x) ((x) * M_PI / 180.0) + + +LSM6DS3_Gyro::LSM6DS3_Gyro(I2CBus *bus) : I2CSensor(bus) {} + +int LSM6DS3_Gyro::init(){ + int ret = 0; + uint8_t buffer[1]; + + ret = read_register(LSM6DS3_GYRO_I2C_REG_ID, buffer, 1); + if(ret < 0){ + LOGE("Reading chip ID failed: %d", ret); + goto fail; + } + + if(buffer[0] != LSM6DS3_GYRO_CHIP_ID){ + LOGE("Chip ID wrong. Got: %d, Expected %d", buffer[0], LSM6DS3_GYRO_CHIP_ID); + ret = -1; + goto fail; + } + + // TODO: set scale. Default is +- 250 deg/s + ret = set_register(LSM6DS3_GYRO_I2C_REG_CTRL2_G, LSM6DS3_GYRO_ODR_104HZ); + if (ret < 0){ + goto fail; + } + + +fail: + return ret; +} + +void LSM6DS3_Gyro::get_event(cereal::SensorEventData::Builder &event){ + + uint64_t start_time = nanos_since_boot(); + uint8_t buffer[6]; + int len = read_register(LSM6DS3_GYRO_I2C_REG_OUTX_L_G, buffer, sizeof(buffer)); + assert(len == sizeof(buffer)); + + float scale = 250.0f / (1 << 15); + float x = DEG2RAD(read_16_bit(buffer[0], buffer[1]) * scale); + float y = DEG2RAD(read_16_bit(buffer[2], buffer[3]) * scale); + float z = DEG2RAD(read_16_bit(buffer[4], buffer[5]) * scale); + + event.setSource(cereal::SensorEventData::SensorSource::LSM6DS3); + event.setVersion(1); + event.setSensor(SENSOR_GYRO_UNCALIBRATED); + event.setType(SENSOR_TYPE_GYROSCOPE_UNCALIBRATED); + event.setTimestamp(start_time); + + float xyz[] = {y, -x, z}; + auto svec = event.initGyroUncalibrated(); + svec.setV(xyz); + svec.setStatus(true); + +} diff --git a/selfdrive/sensord/sensors/lsm6ds3_gyro.hpp b/selfdrive/sensord/sensors/lsm6ds3_gyro.hpp new file mode 100644 index 00000000000000..13cec204e9abb7 --- /dev/null +++ b/selfdrive/sensord/sensors/lsm6ds3_gyro.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include "sensors/i2c_sensor.hpp" + +// Address of the chip on the bus +#define LSM6DS3_GYRO_I2C_ADDR 0x6A + +// Registers of the chip +#define LSM6DS3_GYRO_I2C_REG_ID 0x0F +#define LSM6DS3_GYRO_I2C_REG_CTRL2_G 0x11 +#define LSM6DS3_GYRO_I2C_REG_OUTX_L_G 0x22 + +// Constants +#define LSM6DS3_GYRO_CHIP_ID 0x69 +#define LSM6DS3_GYRO_ODR_104HZ (0b0100 << 4) + + +class LSM6DS3_Gyro : public I2CSensor { + uint8_t get_device_address() {return LSM6DS3_GYRO_I2C_ADDR;} +public: + LSM6DS3_Gyro(I2CBus *bus); + int init(); + void get_event(cereal::SensorEventData::Builder &event); +}; diff --git a/selfdrive/sensord/sensors/lsm6ds3_temp.cc b/selfdrive/sensord/sensors/lsm6ds3_temp.cc new file mode 100644 index 00000000000000..04b0d3d4fae6e8 --- /dev/null +++ b/selfdrive/sensord/sensors/lsm6ds3_temp.cc @@ -0,0 +1,45 @@ +#include +#include "common/swaglog.h" +#include "common/timing.h" + +#include "lsm6ds3_temp.hpp" + + +LSM6DS3_Temp::LSM6DS3_Temp(I2CBus *bus) : I2CSensor(bus) {} + +int LSM6DS3_Temp::init(){ + int ret = 0; + uint8_t buffer[1]; + + ret = read_register(LSM6DS3_TEMP_I2C_REG_ID, buffer, 1); + if(ret < 0){ + LOGE("Reading chip ID failed: %d", ret); + goto fail; + } + + if(buffer[0] != LSM6DS3_TEMP_CHIP_ID){ + LOGE("Chip ID wrong. Got: %d, Expected %d", buffer[0], LSM6DS3_TEMP_CHIP_ID); + ret = -1; + goto fail; + } + +fail: + return ret; +} + +void LSM6DS3_Temp::get_event(cereal::SensorEventData::Builder &event){ + + uint64_t start_time = nanos_since_boot(); + uint8_t buffer[2]; + int len = read_register(LSM6DS3_TEMP_I2C_REG_OUT_TEMP_L, buffer, sizeof(buffer)); + assert(len == sizeof(buffer)); + + float temp = 25.0f + read_16_bit(buffer[0], buffer[1]) / 16.0f; + + event.setSource(cereal::SensorEventData::SensorSource::LSM6DS3); + event.setVersion(1); + event.setType(SENSOR_TYPE_AMBIENT_TEMPERATURE); + event.setTimestamp(start_time); + event.setTemperature(temp); + +} diff --git a/selfdrive/sensord/sensors/lsm6ds3_temp.hpp b/selfdrive/sensord/sensors/lsm6ds3_temp.hpp new file mode 100644 index 00000000000000..eea5ff4a6c3ee0 --- /dev/null +++ b/selfdrive/sensord/sensors/lsm6ds3_temp.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include "sensors/i2c_sensor.hpp" + +// Address of the chip on the bus +#define LSM6DS3_TEMP_I2C_ADDR 0x6A + +// Registers of the chip +#define LSM6DS3_TEMP_I2C_REG_ID 0x0F +#define LSM6DS3_TEMP_I2C_REG_OUT_TEMP_L 0x20 + +// Constants +#define LSM6DS3_TEMP_CHIP_ID 0x69 + + +class LSM6DS3_Temp : public I2CSensor { + uint8_t get_device_address() {return LSM6DS3_TEMP_I2C_ADDR;} +public: + LSM6DS3_Temp(I2CBus *bus); + int init(); + void get_event(cereal::SensorEventData::Builder &event); +}; diff --git a/selfdrive/sensord/sensors/sensor.hpp b/selfdrive/sensord/sensors/sensor.hpp new file mode 100644 index 00000000000000..91f41790815d8c --- /dev/null +++ b/selfdrive/sensord/sensors/sensor.hpp @@ -0,0 +1,9 @@ +#pragma once + +#include "cereal/gen/cpp/log.capnp.h" + +class Sensor { +public: + virtual int init() = 0; + virtual void get_event(cereal::SensorEventData::Builder &event) = 0; +}; diff --git a/selfdrive/sensord/sensors_qcom.cc b/selfdrive/sensord/sensors_qcom.cc new file mode 100644 index 00000000000000..16b7fc98bf6d51 --- /dev/null +++ b/selfdrive/sensord/sensors_qcom.cc @@ -0,0 +1,234 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include "messaging.hpp" +#include "common/timing.h" +#include "common/swaglog.h" + +// ACCELEROMETER_UNCALIBRATED is only in Android O +// https://developer.android.com/reference/android/hardware/Sensor.html#STRING_TYPE_ACCELEROMETER_UNCALIBRATED + +#define SENSOR_ACCELEROMETER 1 +#define SENSOR_MAGNETOMETER 2 +#define SENSOR_GYRO 4 +#define SENSOR_MAGNETOMETER_UNCALIBRATED 3 +#define SENSOR_GYRO_UNCALIBRATED 5 +#define SENSOR_PROXIMITY 6 +#define SENSOR_LIGHT 7 + +volatile sig_atomic_t do_exit = 0; +volatile sig_atomic_t re_init_sensors = 0; + +namespace { + +void set_do_exit(int sig) { + do_exit = 1; +} + +void sigpipe_handler(int sig) { + LOGE("SIGPIPE received"); + re_init_sensors = true; +} + +void sensor_loop() { + LOG("*** sensor loop"); + + uint64_t frame = 0; + bool low_power_mode = false; + + while (!do_exit) { + SubMaster sm({"thermal"}); + PubMaster pm({"sensorEvents"}); + + struct sensors_poll_device_t* device; + struct sensors_module_t* module; + + hw_get_module(SENSORS_HARDWARE_MODULE_ID, (hw_module_t const**)&module); + sensors_open(&module->common, &device); + + // required + struct sensor_t const* list; + int count = module->get_sensors_list(module, &list); + LOG("%d sensors found", count); + + if (getenv("SENSOR_TEST")) { + exit(count); + } + + for (int i = 0; i < count; i++) { + LOGD("sensor %4d: %4d %60s %d-%ld us", i, list[i].handle, list[i].name, list[i].minDelay, list[i].maxDelay); + } + + std::set sensor_types = { + SENSOR_TYPE_ACCELEROMETER, + SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED, + SENSOR_TYPE_MAGNETIC_FIELD, + SENSOR_TYPE_GYROSCOPE_UNCALIBRATED, + SENSOR_TYPE_GYROSCOPE, + SENSOR_TYPE_PROXIMITY, + SENSOR_TYPE_LIGHT, + }; + + std::map sensors = { + {SENSOR_GYRO_UNCALIBRATED, ms2ns(10)}, + {SENSOR_MAGNETOMETER_UNCALIBRATED, ms2ns(100)}, + {SENSOR_ACCELEROMETER, ms2ns(10)}, + {SENSOR_GYRO, ms2ns(10)}, + {SENSOR_MAGNETOMETER, ms2ns(100)}, + {SENSOR_PROXIMITY, ms2ns(100)}, + {SENSOR_LIGHT, ms2ns(100)} + }; + + // sensors needed while offroad + std::set offroad_sensors = { + SENSOR_LIGHT, + SENSOR_ACCELEROMETER, + SENSOR_GYRO_UNCALIBRATED, + }; + + // init all the sensors + for (auto &s : sensors) { + device->activate(device, s.first, 0); + device->activate(device, s.first, 1); + device->setDelay(device, s.first, s.second); + } + + // TODO: why is this 16? + static const size_t numEvents = 16; + sensors_event_t buffer[numEvents]; + + while (!do_exit) { + int n = device->poll(device, buffer, numEvents); + if (n == 0) continue; + if (n < 0) { + LOG("sensor_loop poll failed: %d", n); + continue; + } + + int log_events = 0; + for (int i=0; i < n; i++) { + if (sensor_types.find(buffer[i].type) != sensor_types.end()) { + log_events++; + } + } + + MessageBuilder msg; + auto sensor_events = msg.initEvent().initSensorEvents(log_events); + + int log_i = 0; + for (int i = 0; i < n; i++) { + + const sensors_event_t& data = buffer[i]; + + if (sensor_types.find(data.type) == sensor_types.end()) { + continue; + } + + auto log_event = sensor_events[log_i]; + log_event.setSource(cereal::SensorEventData::SensorSource::ANDROID); + log_event.setVersion(data.version); + log_event.setSensor(data.sensor); + log_event.setType(data.type); + log_event.setTimestamp(data.timestamp); + + switch (data.type) { + case SENSOR_TYPE_ACCELEROMETER: { + auto svec = log_event.initAcceleration(); + svec.setV(data.acceleration.v); + svec.setStatus(data.acceleration.status); + break; + } + case SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED: { + auto svec = log_event.initMagneticUncalibrated(); + // assuming the uncalib and bias floats are contiguous in memory + kj::ArrayPtr vs(&data.uncalibrated_magnetic.uncalib[0], 6); + svec.setV(vs); + break; + } + case SENSOR_TYPE_MAGNETIC_FIELD: { + auto svec = log_event.initMagnetic(); + svec.setV(data.magnetic.v); + svec.setStatus(data.magnetic.status); + break; + } + case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED: { + auto svec = log_event.initGyroUncalibrated(); + // assuming the uncalib and bias floats are contiguous in memory + kj::ArrayPtr vs(&data.uncalibrated_gyro.uncalib[0], 6); + svec.setV(vs); + break; + } + case SENSOR_TYPE_GYROSCOPE: { + auto svec = log_event.initGyro(); + svec.setV(data.gyro.v); + svec.setStatus(data.gyro.status); + break; + } + case SENSOR_TYPE_PROXIMITY: { + log_event.setProximity(data.distance); + break; + } + case SENSOR_TYPE_LIGHT: + log_event.setLight(data.light); + break; + } + + log_i++; + } + + pm.send("sensorEvents", msg); + + if (re_init_sensors){ + LOGE("Resetting sensors"); + re_init_sensors = false; + break; + } + + // Check whether to go into low power mode at 5Hz + if (frame % 20 == 0 && sm.update(0) > 0) { + bool offroad = !sm["thermal"].getThermal().getStarted(); + if (low_power_mode != offroad) { + for (auto &s : sensors) { + device->activate(device, s.first, 0); + if (!offroad || offroad_sensors.find(s.first) != offroad_sensors.end()) { + device->activate(device, s.first, 1); + } + } + low_power_mode = offroad; + } + } + + frame++; + } + sensors_close(device); + } +} + +}// Namespace end + +int main(int argc, char *argv[]) { + setpriority(PRIO_PROCESS, 0, -13); + signal(SIGINT, (sighandler_t)set_do_exit); + signal(SIGTERM, (sighandler_t)set_do_exit); + signal(SIGPIPE, (sighandler_t)sigpipe_handler); + + sensor_loop(); + + return 0; +} diff --git a/selfdrive/sensord/sensors_qcom2.cc b/selfdrive/sensord/sensors_qcom2.cc new file mode 100644 index 00000000000000..1dd5ed10a697ed --- /dev/null +++ b/selfdrive/sensord/sensors_qcom2.cc @@ -0,0 +1,106 @@ +#include +#include +#include +#include +#include + +#include "messaging.hpp" +#include "common/i2c.h" +#include "common/timing.h" +#include "common/swaglog.h" + +#include "sensors/sensor.hpp" +#include "sensors/constants.hpp" + +#include "sensors/bmx055_accel.hpp" +#include "sensors/bmx055_gyro.hpp" +#include "sensors/bmx055_magn.hpp" +#include "sensors/bmx055_temp.hpp" + +#include "sensors/lsm6ds3_accel.hpp" +#include "sensors/lsm6ds3_gyro.hpp" +#include "sensors/lsm6ds3_temp.hpp" + +#include "sensors/light_sensor.hpp" + +volatile sig_atomic_t do_exit = 0; + +#define I2C_BUS_IMU 1 + + +void set_do_exit(int sig) { + do_exit = 1; +} + +int sensor_loop() { + I2CBus *i2c_bus_imu; + + try { + i2c_bus_imu = new I2CBus(I2C_BUS_IMU); + } catch (std::exception &e) { + LOGE("I2CBus init failed"); + return -1; + } + + BMX055_Accel bmx055_accel(i2c_bus_imu); + BMX055_Gyro bmx055_gyro(i2c_bus_imu); + BMX055_Magn bmx055_magn(i2c_bus_imu); + BMX055_Temp bmx055_temp(i2c_bus_imu); + + LSM6DS3_Accel lsm6ds3_accel(i2c_bus_imu); + LSM6DS3_Gyro lsm6ds3_gyro(i2c_bus_imu); + LSM6DS3_Temp lsm6ds3_temp(i2c_bus_imu); + + LightSensor light("/sys/class/i2c-adapter/i2c-2/2-0038/iio:device1/in_intensity_both_raw"); + + // Sensor init + std::vector sensors; + sensors.push_back(&bmx055_accel); + sensors.push_back(&bmx055_gyro); + sensors.push_back(&bmx055_magn); + sensors.push_back(&bmx055_temp); + + sensors.push_back(&lsm6ds3_accel); + sensors.push_back(&lsm6ds3_gyro); + sensors.push_back(&lsm6ds3_temp); + + sensors.push_back(&light); + + + for (Sensor * sensor : sensors){ + int err = sensor->init(); + if (err < 0){ + LOGE("Error initializing sensors"); + return -1; + } + } + + PubMaster pm({"sensorEvents"}); + + while (!do_exit){ + std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now(); + + const int num_events = sensors.size(); + MessageBuilder msg; + auto sensor_events = msg.initEvent().initSensorEvents(num_events); + + for (int i = 0; i < num_events; i++){ + auto event = sensor_events[i]; + sensors[i]->get_event(event); + } + + pm.send("sensorEvents", msg); + + std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); + std::this_thread::sleep_for(std::chrono::milliseconds(10) - (end - begin)); + } + return 0; +} + +int main(int argc, char *argv[]) { + setpriority(PRIO_PROCESS, 0, -13); + signal(SIGINT, set_do_exit); + signal(SIGTERM, set_do_exit); + + return sensor_loop(); +} diff --git a/selfdrive/sensord/start_gpsd.py b/selfdrive/sensord/start_gpsd.py deleted file mode 100755 index ada2687158a4db..00000000000000 --- a/selfdrive/sensord/start_gpsd.py +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env python2 -import os - -assert os.system("make") == 0 -os.environ['LD_LIBRARY_PATH'] = "/system/lib64:" + os.environ['LD_LIBRARY_PATH'] -os.execv("./gpsd", ["gpsd"]) diff --git a/selfdrive/sensord/start_sensord.py b/selfdrive/sensord/start_sensord.py deleted file mode 100755 index d6d6564113a09e..00000000000000 --- a/selfdrive/sensord/start_sensord.py +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env python2 -import os - -assert os.system("make") == 0 -os.environ['LD_LIBRARY_PATH'] = "/system/lib64:" + os.environ['LD_LIBRARY_PATH'] -os.execv("./sensord", ["sensord"]) diff --git a/selfdrive/services.py b/selfdrive/services.py deleted file mode 100644 index 18d43ff76a3448..00000000000000 --- a/selfdrive/services.py +++ /dev/null @@ -1,15 +0,0 @@ -import os -import yaml - -class Service(object): - def __init__(self, port, should_log, frequency): - self.port = port - self.should_log = should_log - self.frequency = frequency - -service_list_path = os.path.join(os.path.dirname(__file__), "service_list.yaml") - -service_list = {} -with open(service_list_path, "r") as f: - for k, v in yaml.safe_load(f).items(): - service_list[k] = Service(v[0], v[1], v[2]) diff --git a/selfdrive/swaglog.py b/selfdrive/swaglog.py index 169898637a901f..48447527c68c5a 100644 --- a/selfdrive/swaglog.py +++ b/selfdrive/swaglog.py @@ -1,10 +1,18 @@ import os import logging +from logentries import LogentriesHandler import zmq from common.logging_extra import SwagLogger, SwagFormatter + +def get_le_handler(): + # setup logentries. we forward log messages to it + le_token = "e8549616-0798-4d7e-a2ca-2513ae81fa17" + return LogentriesHandler(le_token, use_tls=False, verbose=False) + + class LogMessageHandler(logging.Handler): def __init__(self, formatter): logging.Handler.__init__(self) @@ -14,6 +22,7 @@ def __init__(self, formatter): def connect(self): self.zctx = zmq.Context() self.sock = self.zctx.socket(zmq.PUSH) + self.sock.setsockopt(zmq.LINGER, 10) self.sock.connect("ipc:///tmp/logmessage") self.pid = os.getpid() @@ -24,15 +33,24 @@ def emit(self, record): msg = self.format(record).rstrip('\n') # print("SEND".format(repr(msg))) try: - self.sock.send(chr(record.levelno)+msg, zmq.NOBLOCK) + s = chr(record.levelno)+msg + self.sock.send(s.encode('utf8'), zmq.NOBLOCK) except zmq.error.Again: # drop :/ pass + +def add_logentries_handler(log): + """Function to add the logentries handler to swaglog. + This can be used to send logs when logmessaged is not running.""" + handler = get_le_handler() + handler.setFormatter(SwagFormatter(log)) + log.addHandler(handler) + + cloudlog = log = SwagLogger() log.setLevel(logging.DEBUG) outhandler = logging.StreamHandler() log.addHandler(outhandler) - log.addHandler(LogMessageHandler(SwagFormatter(log))) diff --git a/selfdrive/test/helpers.py b/selfdrive/test/helpers.py new file mode 100644 index 00000000000000..de8b15b3bde57c --- /dev/null +++ b/selfdrive/test/helpers.py @@ -0,0 +1,71 @@ +import time +import subprocess +from functools import wraps +from nose.tools import nottest + +from selfdrive.hardware.eon.apk import update_apks, start_offroad, pm_apply_packages, android_packages +from selfdrive.hardware import PC +from selfdrive.version import training_version, terms_version +from selfdrive.manager import start_managed_process, kill_managed_process, get_running + +def set_params_enabled(): + from common.params import Params + params = Params() + params.put("HasAcceptedTerms", terms_version) + params.put("HasCompletedSetup", "1") + params.put("OpenpilotEnabledToggle", "1") + params.put("CommunityFeaturesToggle", "1") + params.put("Passive", "0") + params.put("CompletedTrainingVersion", training_version) + +def phone_only(x): + if PC: + return nottest(x) + else: + return x + +def with_processes(processes, init_time=0): + def wrapper(func): + @wraps(func) + def wrap(*args, **kwargs): + # start and assert started + for n, p in enumerate(processes): + start_managed_process(p) + if n < len(processes)-1: + time.sleep(init_time) + assert all(get_running()[name].exitcode is None for name in processes) + + # call the function + try: + func(*args, **kwargs) + # assert processes are still started + assert all(get_running()[name].exitcode is None for name in processes) + finally: + # kill and assert all stopped + for p in processes: + kill_managed_process(p) + assert len(get_running()) == 0 + return wrap + return wrapper + +def with_apks(): + def wrapper(func): + @wraps(func) + def wrap(): + update_apks() + pm_apply_packages('enable') + start_offroad() + + func() + + try: + for package in android_packages: + apk_is_running = (subprocess.call(["pidof", package]) == 0) + assert apk_is_running, package + finally: + pm_apply_packages('disable') + for package in android_packages: + apk_is_not_running = (subprocess.call(["pidof", package]) == 1) + assert apk_is_not_running, package + return wrap + return wrapper diff --git a/selfdrive/test/openpilotci_upload.py b/selfdrive/test/openpilotci_upload.py deleted file mode 100755 index 85509851dee3c1..00000000000000 --- a/selfdrive/test/openpilotci_upload.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python2 -import os -import sys -import subprocess -from azure.storage.blob import BlockBlobService - -def upload_file(path, name): - sas_token = os.getenv("TOKEN", None) - if sas_token is not None: - service = BlockBlobService(account_name="commadataci", sas_token=sas_token) - else: - account_key = subprocess.check_output("az storage account keys list --account-name commadataci --output tsv --query '[0].value'", shell=True) - service = BlockBlobService(account_name="commadataci", account_key=account_key) - service.create_blob_from_path("openpilotci", name, path) - return "https://commadataci.blob.core.windows.net/openpilotci/" + name - -if __name__ == "__main__": - for f in sys.argv[1:]: - name = os.path.basename(f) - url = upload_file(f, name) - print url - diff --git a/selfdrive/test/plant/__init__.py b/selfdrive/test/plant/__init__.py deleted file mode 100644 index e69de29bb2d1d6..00000000000000 diff --git a/selfdrive/test/plant/maneuver.py b/selfdrive/test/plant/maneuver.py deleted file mode 100644 index ea5ebdd9ee2579..00000000000000 --- a/selfdrive/test/plant/maneuver.py +++ /dev/null @@ -1,86 +0,0 @@ -from collections import defaultdict -from selfdrive.test.plant.maneuverplots import ManeuverPlot -from selfdrive.test.plant.plant import Plant -import numpy as np - - -class Maneuver(object): - def __init__(self, title, duration, **kwargs): - # Was tempted to make a builder class - self.distance_lead = kwargs.get("initial_distance_lead", 200.0) - self.speed = kwargs.get("initial_speed", 0.0) - self.lead_relevancy = kwargs.get("lead_relevancy", 0) - - self.grade_values = kwargs.get("grade_values", [0.0, 0.0]) - self.grade_breakpoints = kwargs.get("grade_breakpoints", [0.0, duration]) - self.speed_lead_values = kwargs.get("speed_lead_values", [0.0, 0.0]) - self.speed_lead_breakpoints = kwargs.get("speed_lead_breakpoints", [0.0, duration]) - - self.cruise_button_presses = kwargs.get("cruise_button_presses", []) - self.checks = kwargs.get("checks", []) - - self.duration = duration - self.title = title - - def evaluate(self): - """runs the plant sim and returns (score, run_data)""" - plant = Plant( - lead_relevancy = self.lead_relevancy, - speed = self.speed, - distance_lead = self.distance_lead - ) - - logs = defaultdict(list) - last_controls_state = None - plot = ManeuverPlot(self.title) - - buttons_sorted = sorted(self.cruise_button_presses, key=lambda a: a[1]) - current_button = 0 - while plant.current_time() < self.duration: - while buttons_sorted and plant.current_time() >= buttons_sorted[0][1]: - current_button = buttons_sorted[0][0] - buttons_sorted = buttons_sorted[1:] - print("current button changed to {0}".format(current_button)) - - grade = np.interp(plant.current_time(), self.grade_breakpoints, self.grade_values) - speed_lead = np.interp(plant.current_time(), self.speed_lead_breakpoints, self.speed_lead_values) - - # distance, speed, acceleration, distance_lead, brake, gas, steer_torque, fcw, controls_state= plant.step(speed_lead, current_button, grade) - log = plant.step(speed_lead, current_button, grade) - - if log['controls_state_msgs']: - last_controls_state = log['controls_state_msgs'][-1] - - d_rel = log['distance_lead'] - log['distance'] if self.lead_relevancy else 200. - v_rel = speed_lead - log['speed'] if self.lead_relevancy else 0. - log['d_rel'] = d_rel - log['v_rel'] = v_rel - - if last_controls_state: - # print(last_controls_state) - #develop plots - plot.add_data( - time=plant.current_time(), - gas=log['gas'], brake=log['brake'], steer_torque=log['steer_torque'], - distance=log['distance'], speed=log['speed'], acceleration=log['acceleration'], - up_accel_cmd=last_controls_state.upAccelCmd, ui_accel_cmd=last_controls_state.uiAccelCmd, - uf_accel_cmd=last_controls_state.ufAccelCmd, - d_rel=d_rel, v_rel=v_rel, v_lead=speed_lead, - v_target_lead=last_controls_state.vTargetLead, pid_speed=last_controls_state.vPid, - cruise_speed=last_controls_state.vCruise, - jerk_factor=last_controls_state.jerkFactor, - a_target=last_controls_state.aTarget, - fcw=log['fcw']) - - for k, v in log.items(): - logs[k].append(v) - - valid = True - for check in self.checks: - c = check(logs) - if not c: - print check.__name__ + " not valid!" - valid = valid and c - - print("maneuver end", valid) - return (plot, valid) diff --git a/selfdrive/test/plant/maneuverplots.py b/selfdrive/test/plant/maneuverplots.py deleted file mode 100644 index 36b3e5bf8372e0..00000000000000 --- a/selfdrive/test/plant/maneuverplots.py +++ /dev/null @@ -1,143 +0,0 @@ -import os - -import numpy as np -import matplotlib.pyplot as plt -import pylab - -from selfdrive.config import Conversions as CV - -class ManeuverPlot(object): - def __init__(self, title = None): - self.time_array = [] - - self.gas_array = [] - self.brake_array = [] - self.steer_torque_array = [] - - self.distance_array = [] - self.speed_array = [] - self.acceleration_array = [] - - self.up_accel_cmd_array = [] - self.ui_accel_cmd_array = [] - self.uf_accel_cmd_array = [] - - self.d_rel_array = [] - self.v_rel_array = [] - self.v_lead_array = [] - self.v_target_lead_array = [] - self.pid_speed_array = [] - self.cruise_speed_array = [] - self.jerk_factor_array = [] - - self.a_target_array = [] - - self.v_target_array = [] - - self.fcw_array = [] - - self.title = title - - def add_data(self, time, gas, brake, steer_torque, distance, speed, - acceleration, up_accel_cmd, ui_accel_cmd, uf_accel_cmd, d_rel, v_rel, - v_lead, v_target_lead, pid_speed, cruise_speed, jerk_factor, a_target, fcw): - self.time_array.append(time) - self.gas_array.append(gas) - self.brake_array.append(brake) - self.steer_torque_array.append(steer_torque) - self.distance_array.append(distance) - self.speed_array.append(speed) - self.acceleration_array.append(acceleration) - self.up_accel_cmd_array.append(up_accel_cmd) - self.ui_accel_cmd_array.append(ui_accel_cmd) - self.uf_accel_cmd_array.append(uf_accel_cmd) - self.d_rel_array.append(d_rel) - self.v_rel_array.append(v_rel) - self.v_lead_array.append(v_lead) - self.v_target_lead_array.append(v_target_lead) - self.pid_speed_array.append(pid_speed) - self.cruise_speed_array.append(cruise_speed) - self.jerk_factor_array.append(jerk_factor) - self.a_target_array.append(a_target) - self.fcw_array.append(fcw) - - - def write_plot(self, path, maneuver_name): - # title = self.title or maneuver_name - # TODO: Missing plots from the old one: - # long_control_state - # proportional_gb, intergral_gb - if not os.path.exists(path + "/" + maneuver_name): - os.makedirs(path + "/" + maneuver_name) - plt_num = 0 - - # speed chart =================== - plt_num += 1 - plt.figure(plt_num) - plt.plot( - np.array(self.time_array), np.array(self.speed_array) * CV.MS_TO_MPH, 'r', - np.array(self.time_array), np.array(self.pid_speed_array) * CV.MS_TO_MPH, 'y--', - np.array(self.time_array), np.array(self.v_target_lead_array) * CV.MS_TO_MPH, 'b', - np.array(self.time_array), np.array(self.cruise_speed_array) * CV.KPH_TO_MPH, 'k', - np.array(self.time_array), np.array(self.v_lead_array) * CV.MS_TO_MPH, 'm' - ) - plt.xlabel('Time [s]') - plt.ylabel('Speed [mph]') - plt.legend(['speed', 'pid speed', 'Target (lead) speed', 'Cruise speed', 'Lead speed'], loc=0) - plt.grid() - pylab.savefig("/".join([path, maneuver_name, 'speeds.svg']), dpi=1000) - - # acceleration chart ============ - plt_num += 1 - plt.figure(plt_num) - plt.plot( - np.array(self.time_array), np.array(self.acceleration_array), 'g', - np.array(self.time_array), np.array(self.a_target_array), 'k--', - np.array(self.time_array), np.array(self.fcw_array), 'ro', - ) - plt.xlabel('Time [s]') - plt.ylabel('Acceleration [m/s^2]') - plt.legend(['ego-plant', 'target', 'fcw'], loc=0) - plt.grid() - pylab.savefig("/".join([path, maneuver_name, 'acceleration.svg']), dpi=1000) - - # pedal chart =================== - plt_num += 1 - plt.figure(plt_num) - plt.plot( - np.array(self.time_array), np.array(self.gas_array), 'g', - np.array(self.time_array), np.array(self.brake_array), 'r', - ) - plt.xlabel('Time [s]') - plt.ylabel('Pedal []') - plt.legend(['Gas pedal', 'Brake pedal'], loc=0) - plt.grid() - pylab.savefig("/".join([path, maneuver_name, 'pedals.svg']), dpi=1000) - - # pid chart ====================== - plt_num += 1 - plt.figure(plt_num) - plt.plot( - np.array(self.time_array), np.array(self.up_accel_cmd_array), 'g', - np.array(self.time_array), np.array(self.ui_accel_cmd_array), 'b', - np.array(self.time_array), np.array(self.uf_accel_cmd_array), 'r' - ) - plt.xlabel("Time, [s]") - plt.ylabel("Accel Cmd [m/s^2]") - plt.grid() - plt.legend(["Proportional", "Integral", "feedforward"], loc=0) - pylab.savefig("/".join([path, maneuver_name, "pid.svg"]), dpi=1000) - - # relative distances chart ======= - plt_num += 1 - plt.figure(plt_num) - plt.plot( - np.array(self.time_array), np.array(self.d_rel_array), 'g', - ) - plt.xlabel('Time [s]') - plt.ylabel('Relative Distance [m]') - plt.grid() - pylab.savefig("/".join([path, maneuver_name, 'distance.svg']), dpi=1000) - - plt.close("all") - diff --git a/selfdrive/test/plant/plant.py b/selfdrive/test/plant/plant.py deleted file mode 100755 index 531ad8ad269c39..00000000000000 --- a/selfdrive/test/plant/plant.py +++ /dev/null @@ -1,441 +0,0 @@ -#!/usr/bin/env python -import os -import struct -import time -from collections import namedtuple -import numpy as np - -from opendbc import DBC_PATH - -from common.realtime import Ratekeeper -from selfdrive.config import Conversions as CV -import selfdrive.messaging as messaging -from selfdrive.services import service_list -from selfdrive.car import crc8_pedal -from selfdrive.car.honda.hondacan import fix -from selfdrive.car.honda.values import CAR -from selfdrive.car.honda.carstate import get_can_signals -from selfdrive.boardd.boardd import can_capnp_to_can_list, can_list_to_can_capnp - -from selfdrive.can.plant_can_parser import CANParser -from selfdrive.car.honda.interface import CarInterface - -from common.dbc import dbc -honda = dbc(os.path.join(DBC_PATH, "honda_civic_touring_2016_can_generated.dbc")) - -# Trick: set 0x201 (interceptor) in fingerprints for gas is controlled like if there was an interceptor -CP = CarInterface.get_params(CAR.CIVIC, {0x201}) - - -def car_plant(pos, speed, grade, gas, brake): - # vehicle parameters - mass = 1700 - aero_cd = 0.3 - force_peak = mass*3. - force_brake_peak = -mass*10. #1g - power_peak = 100000 # 100kW - speed_base = power_peak/force_peak - rolling_res = 0.01 - g = 9.81 - frontal_area = 2.2 - air_density = 1.225 - gas_to_peak_linear_slope = 3.33 - brake_to_peak_linear_slope = 0.3 - creep_accel_v = [1., 0.] - creep_accel_bp = [0., 1.5] - - #*** longitudinal model *** - # find speed where peak torque meets peak power - force_brake = brake * force_brake_peak * brake_to_peak_linear_slope - if speed < speed_base: # torque control - force_gas = gas * force_peak * gas_to_peak_linear_slope - else: # power control - force_gas = gas * power_peak / speed * gas_to_peak_linear_slope - - force_grade = - grade * mass # positive grade means uphill - - creep_accel = np.interp(speed, creep_accel_bp, creep_accel_v) - force_creep = creep_accel * mass - - force_resistance = -(rolling_res * mass * g + 0.5 * speed**2 * aero_cd * air_density * frontal_area) - force = force_gas + force_brake + force_resistance + force_grade + force_creep - acceleration = force / mass - - # TODO: lateral model - return speed, acceleration - -def get_car_can_parser(): - dbc_f = 'honda_civic_touring_2016_can_generated.dbc' - signals = [ - ("STEER_TORQUE", 0xe4, 0), - ("STEER_TORQUE_REQUEST", 0xe4, 0), - ("COMPUTER_BRAKE", 0x1fa, 0), - ("COMPUTER_BRAKE_REQUEST", 0x1fa, 0), - ("GAS_COMMAND", 0x200, 0), - ] - checks = [ - (0xe4, 100), - (0x1fa, 50), - (0x200, 50), - ] - return CANParser(dbc_f, signals, checks) - -def to_3_byte(x): - return struct.pack("!H", int(x)).encode("hex")[1:] - -def to_3s_byte(x): - return struct.pack("!h", int(x)).encode("hex")[1:] - -class Plant(object): - messaging_initialized = False - - def __init__(self, lead_relevancy=False, rate=100, speed=0.0, distance_lead=2.0): - self.rate = rate - - if not Plant.messaging_initialized: - Plant.logcan = messaging.pub_sock(service_list['can'].port) - Plant.sendcan = messaging.sub_sock(service_list['sendcan'].port) - Plant.model = messaging.pub_sock(service_list['model'].port) - Plant.live_params = messaging.pub_sock(service_list['liveParameters'].port) - Plant.health = messaging.pub_sock(service_list['health'].port) - Plant.thermal = messaging.pub_sock(service_list['thermal'].port) - Plant.driverMonitoring = messaging.pub_sock(service_list['driverMonitoring'].port) - Plant.cal = messaging.pub_sock(service_list['liveCalibration'].port) - Plant.controls_state = messaging.sub_sock(service_list['controlsState'].port) - Plant.plan = messaging.sub_sock(service_list['plan'].port) - Plant.messaging_initialized = True - - self.angle_steer = 0. - self.gear_choice = 0 - self.speed, self.speed_prev = 0., 0. - - self.esp_disabled = 0 - self.main_on = 1 - self.user_gas = 0 - self.computer_brake,self.user_brake = 0,0 - self.brake_pressed = 0 - self.angle_steer_rate = 0 - self.distance, self.distance_prev = 0., 0. - self.speed, self.speed_prev = speed, speed - self.steer_error, self.brake_error, self.steer_not_allowed = 0, 0, 0 - self.gear_shifter = 8 # D gear - self.pedal_gas = 0 - self.cruise_setting = 0 - - self.seatbelt, self.door_all_closed = True, True - self.steer_torque, self.v_cruise, self.acc_status = 0, 0, 0 # v_cruise is reported from can, not the one used for controls - - self.lead_relevancy = lead_relevancy - - # lead car - self.distance_lead, self.distance_lead_prev = distance_lead , distance_lead - - self.rk = Ratekeeper(rate, print_delay_threshold=100) - self.ts = 1./rate - - self.cp = get_car_can_parser() - self.response_seen = False - - time.sleep(1) - messaging.drain_sock(Plant.sendcan) - messaging.drain_sock(Plant.controls_state) - - def close(self): - Plant.logcan.close() - Plant.model.close() - Plant.live_params.close() - - def speed_sensor(self, speed): - if speed<0.3: - return 0 - else: - return speed * CV.MS_TO_KPH - - def current_time(self): - return float(self.rk.frame) / self.rate - - def step(self, v_lead=0.0, cruise_buttons=None, grade=0.0, publish_model = True): - gen_signals, gen_checks = get_can_signals(CP) - sgs = [s[0] for s in gen_signals] - msgs = [s[1] for s in gen_signals] - cks_msgs = set(check[0] for check in gen_checks) - cks_msgs.add(0x18F) - cks_msgs.add(0x30C) - - # ******** get messages sent to the car ******** - can_msgs = [] - for a in messaging.drain_sock(Plant.sendcan, wait_for_one=self.response_seen): - can_msgs.extend(can_capnp_to_can_list(a.sendcan, [0,2])) - - # After the first response the car is done fingerprinting, so we can run in lockstep with controlsd - if can_msgs: - self.response_seen = True - - self.cp.update_can(can_msgs) - - # ******** get controlsState messages for plotting *** - controls_state_msgs = [] - for a in messaging.drain_sock(Plant.controls_state, wait_for_one=self.response_seen): - controls_state_msgs.append(a.controlsState) - - fcw = None - for a in messaging.drain_sock(Plant.plan): - if a.plan.fcw: - fcw = True - - if self.cp.vl[0x1fa]['COMPUTER_BRAKE_REQUEST']: - brake = self.cp.vl[0x1fa]['COMPUTER_BRAKE'] * 0.003906248 - else: - brake = 0.0 - - if self.cp.vl[0x200]['GAS_COMMAND'] > 0: - gas = self.cp.vl[0x200]['GAS_COMMAND'] / 256.0 - else: - gas = 0.0 - - if self.cp.vl[0xe4]['STEER_TORQUE_REQUEST']: - steer_torque = self.cp.vl[0xe4]['STEER_TORQUE']*1.0/0xf00 - else: - steer_torque = 0.0 - - distance_lead = self.distance_lead_prev + v_lead * self.ts - - # ******** run the car ******** - speed, acceleration = car_plant(self.distance_prev, self.speed_prev, grade, gas, brake) - distance = self.distance_prev + speed * self.ts - speed = self.speed_prev + self.ts * acceleration - if speed <= 0: - speed = 0 - acceleration = 0 - - # ******** lateral ******** - self.angle_steer -= (steer_torque/10.0) * self.ts - - # *** radar model *** - if self.lead_relevancy: - d_rel = np.maximum(0., distance_lead - distance) - v_rel = v_lead - speed - else: - d_rel = 200. - v_rel = 0. - lateral_pos_rel = 0. - - # print at 5hz - if (self.rk.frame % (self.rate//5)) == 0: - print("%6.2f m %6.2f m/s %6.2f m/s2 %.2f ang gas: %.2f brake: %.2f steer: %5.2f lead_rel: %6.2f m %6.2f m/s" % (distance, speed, acceleration, self.angle_steer, gas, brake, steer_torque, d_rel, v_rel)) - - # ******** publish the car ******** - vls_tuple = namedtuple('vls', [ - 'XMISSION_SPEED', - 'WHEEL_SPEED_FL', 'WHEEL_SPEED_FR', 'WHEEL_SPEED_RL', 'WHEEL_SPEED_RR', - 'STEER_ANGLE', 'STEER_ANGLE_RATE', 'STEER_TORQUE_SENSOR', 'STEER_TORQUE_MOTOR', - 'LEFT_BLINKER', 'RIGHT_BLINKER', - 'GEAR', - 'WHEELS_MOVING', - 'BRAKE_ERROR_1', 'BRAKE_ERROR_2', - 'SEATBELT_DRIVER_LAMP', 'SEATBELT_DRIVER_LATCHED', - 'BRAKE_PRESSED', 'BRAKE_SWITCH', - 'CRUISE_BUTTONS', - 'ESP_DISABLED', - 'HUD_LEAD', - 'USER_BRAKE', - 'STEER_STATUS', - 'GEAR_SHIFTER', - 'PEDAL_GAS', - 'CRUISE_SETTING', - 'ACC_STATUS', - - 'CRUISE_SPEED_PCM', - 'CRUISE_SPEED_OFFSET', - - 'DOOR_OPEN_FL', 'DOOR_OPEN_FR', 'DOOR_OPEN_RL', 'DOOR_OPEN_RR', - - 'CAR_GAS', - 'MAIN_ON', - 'EPB_STATE', - 'BRAKE_HOLD_ACTIVE', - 'INTERCEPTOR_GAS', - 'INTERCEPTOR_GAS2', - 'IMPERIAL_UNIT', - ]) - vls = vls_tuple( - self.speed_sensor(speed), - self.speed_sensor(speed), self.speed_sensor(speed), self.speed_sensor(speed), self.speed_sensor(speed), - self.angle_steer, self.angle_steer_rate, 0, 0,#Steer torque sensor - 0, 0, # Blinkers - self.gear_choice, - speed != 0, - self.brake_error, self.brake_error, - not self.seatbelt, self.seatbelt, # Seatbelt - self.brake_pressed, 0., #Brake pressed, Brake switch - cruise_buttons, - self.esp_disabled, - 0, # HUD lead - self.user_brake, - self.steer_error, - self.gear_shifter, - self.pedal_gas, - self.cruise_setting, - self.acc_status, - - self.v_cruise, - 0, # Cruise speed offset - - 0, 0, 0, 0, # Doors - - self.user_gas, - self.main_on, - 0, # EPB State - 0, # Brake hold - 0, # Interceptor feedback - 0, # Interceptor 2 feedback - False - ) - - # TODO: publish each message at proper frequency - can_msgs = [] - for msg in set(msgs): - msg_struct = {} - indxs = [i for i, x in enumerate(msgs) if msg == msgs[i]] - for i in indxs: - msg_struct[sgs[i]] = getattr(vls, sgs[i]) - - if "COUNTER" in honda.get_signals(msg): - msg_struct["COUNTER"] = self.rk.frame % 4 - - if "COUNTER_PEDAL" in honda.get_signals(msg): - msg_struct["COUNTER_PEDAL"] = self.rk.frame % 0xf - - msg = honda.lookup_msg_id(msg) - msg_data = honda.encode(msg, msg_struct) - - if "CHECKSUM" in honda.get_signals(msg): - msg_data = fix(msg_data, msg) - - if "CHECKSUM_PEDAL" in honda.get_signals(msg): - msg_struct["CHECKSUM_PEDAL"] = crc8_pedal([ord(i) for i in msg_data][:-1]) - msg_data = honda.encode(msg, msg_struct) - - can_msgs.append([msg, 0, msg_data, 0]) - - # add the radar message - # TODO: use the DBC - if self.rk.frame % 5 == 0: - radar_state_msg = '\x79\x00\x00\x00\x00\x00\x00\x00' - radar_msg = to_3_byte(d_rel*16.0) + \ - to_3_byte(int(lateral_pos_rel*16.0)&0x3ff) + \ - to_3s_byte(int(v_rel*32.0)) + \ - "0f00000" - can_msgs.append([0x400, 0, radar_state_msg, 1]) - can_msgs.append([0x445, 0, radar_msg.decode("hex"), 1]) - - # add camera msg so controlsd thinks it's alive - msg_struct["COUNTER"] = self.rk.frame % 4 - msg = honda.lookup_msg_id(0xe4) - msg_data = honda.encode(msg, msg_struct) - msg_data = fix(msg_data, 0xe4) - can_msgs.append([0xe4, 0, msg_data, 2]) - - - # Fake sockets that controlsd subscribes to - live_parameters = messaging.new_message() - live_parameters.init('liveParameters') - live_parameters.liveParameters.valid = True - live_parameters.liveParameters.sensorValid = True - live_parameters.liveParameters.posenetValid = True - live_parameters.liveParameters.steerRatio = CP.steerRatio - live_parameters.liveParameters.stiffnessFactor = 1.0 - Plant.live_params.send(live_parameters.to_bytes()) - - driver_monitoring = messaging.new_message() - driver_monitoring.init('driverMonitoring') - driver_monitoring.driverMonitoring.faceOrientation = [0.] * 3 - driver_monitoring.driverMonitoring.facePosition = [0.] * 2 - Plant.driverMonitoring.send(driver_monitoring.to_bytes()) - - health = messaging.new_message() - health.init('health') - health.health.controlsAllowed = True - Plant.health.send(health.to_bytes()) - - thermal = messaging.new_message() - thermal.init('thermal') - thermal.thermal.freeSpace = 1. - thermal.thermal.batteryPercent = 100 - Plant.thermal.send(thermal.to_bytes()) - - # ******** publish a fake model going straight and fake calibration ******** - # note that this is worst case for MPC, since model will delay long mpc by one time step - if publish_model and self.rk.frame % 5 == 0: - md = messaging.new_message() - cal = messaging.new_message() - md.init('model') - cal.init('liveCalibration') - md.model.frameId = 0 - for x in [md.model.path, md.model.leftLane, md.model.rightLane]: - x.points = [0.0]*50 - x.prob = 1.0 - x.std = 1.0 - - if self.lead_relevancy: - d_rel = np.maximum(0., distance_lead - distance) - v_rel = v_lead - speed - prob = 1.0 - else: - d_rel = 200. - v_rel = 0. - prob = 0.0 - - md.model.lead.dist = float(d_rel) - md.model.lead.prob = prob - md.model.lead.relY = 0.0 - md.model.lead.relYStd = 1. - md.model.lead.relVel = float(v_rel) - md.model.lead.relVelStd = 1. - md.model.lead.relA = 0.0 - md.model.lead.relAStd = 10. - md.model.lead.std = 1.0 - - cal.liveCalibration.calStatus = 1 - cal.liveCalibration.calPerc = 100 - cal.liveCalibration.rpyCalib = [0.] * 3 - # fake values? - Plant.model.send(md.to_bytes()) - Plant.cal.send(cal.to_bytes()) - - Plant.logcan.send(can_list_to_can_capnp(can_msgs)) - - # ******** update prevs ******** - self.speed = speed - self.distance = distance - self.distance_lead = distance_lead - - self.speed_prev = speed - self.distance_prev = distance - self.distance_lead_prev = distance_lead - - if self.response_seen: - self.rk.monitor_time() - else: - self.rk.keep_time() - - return { - "distance": distance, - "speed": speed, - "acceleration": acceleration, - "distance_lead": distance_lead, - "brake": brake, - "gas": gas, - "steer_torque": steer_torque, - "fcw": fcw, - "controls_state_msgs": controls_state_msgs, - } - -# simple engage in standalone mode -def plant_thread(rate=100): - plant = Plant(rate) - while 1: - plant.step() - -if __name__ == "__main__": - plant_thread() diff --git a/selfdrive/test/plant/plant_ui.py b/selfdrive/test/plant/plant_ui.py deleted file mode 100755 index 5fa0ffad247301..00000000000000 --- a/selfdrive/test/plant/plant_ui.py +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/env python -import pygame # pylint: disable=import-error -from selfdrive.test.plant.plant import Plant -from selfdrive.car.honda.values import CruiseButtons -import numpy as np -import selfdrive.messaging as messaging -import math - -CAR_WIDTH = 2.0 -CAR_LENGTH = 4.5 - -METER = 8 - -def rot_center(image, angle): - """rotate an image while keeping its center and size""" - orig_rect = image.get_rect() - rot_image = pygame.transform.rotate(image, angle) - rot_rect = orig_rect.copy() - rot_rect.center = rot_image.get_rect().center - rot_image = rot_image.subsurface(rot_rect).copy() - return rot_image - -def car_w_color(c): - car = pygame.Surface((METER*CAR_LENGTH, METER*CAR_LENGTH)) # pylint: disable=too-many-function-args - car.set_alpha(0) - car.fill((10,10,10)) - car.set_alpha(128) - pygame.draw.rect(car, c, (METER*1.25, 0, METER*CAR_WIDTH, METER*CAR_LENGTH), 1) - return car - -if __name__ == "__main__": - pygame.init() - display = pygame.display.set_mode((1000, 1000)) - pygame.display.set_caption('Plant UI') - - car = car_w_color((255,0,255)) - leadcar = car_w_color((255,0,0)) - - carx, cary, heading = 10.0, 50.0, 0.0 - - plant = Plant(100, distance_lead = 40.0) - - control_offset = 2.0 - control_pts = list(zip(np.arange(0, 100.0, 10.0), [50.0 + control_offset]*10)) - - def pt_to_car(pt): - x,y = pt - x -= carx - y -= cary - rx = x * math.cos(-heading) + y * -math.sin(-heading) - ry = x * math.sin(-heading) + y * math.cos(-heading) - return rx, ry - - def pt_from_car(pt): - x,y = pt - rx = x * math.cos(heading) + y * -math.sin(heading) - ry = x * math.sin(heading) + y * math.cos(heading) - rx += carx - ry += cary - return rx, ry - - while 1: - if plant.rk.frame%100 >= 20 and plant.rk.frame%100 <= 25: - cruise_buttons = CruiseButtons.RES_ACCEL - else: - cruise_buttons = 0 - - md = messaging.new_message() - md.init('model') - md.model.frameId = 0 - for x in [md.model.path, md.model.leftLane, md.model.rightLane]: - x.points = [0.0]*50 - x.prob = 0.0 - x.std = 1.0 - - car_pts = [pt_to_car(pt) for pt in control_pts] - - print(car_pts) - - car_poly = np.polyfit([x[0] for x in car_pts], [x[1] for x in car_pts], 3) - md.model.path.points = np.polyval(car_poly, np.arange(0, 50)).tolist() - md.model.path.prob = 1.0 - Plant.model.send(md.to_bytes()) - - plant.step(cruise_buttons = cruise_buttons, v_lead = 2.0, publish_model = False) - - display.fill((10,10,10)) - - carx += plant.speed * plant.ts * math.cos(heading) - cary += plant.speed * plant.ts * math.sin(heading) - - # positive steering angle = steering right - print(plant.angle_steer) - heading += plant.angle_steer * plant.ts - print(heading) - - # draw my car - display.blit(pygame.transform.rotate(car, 90-math.degrees(heading)), (carx*METER, cary*METER)) - - # draw control pts - for x,y in control_pts: - pygame.draw.circle(display, (255,255,0), (int(x * METER),int(y * METER)), 2) - - # draw path - path_pts = zip(np.arange(0, 50), md.model.path.points) - - for x,y in path_pts: - x,y = pt_from_car((x,y)) - pygame.draw.circle(display, (0,255,0), (int(x * METER),int(y * METER)), 1) - - """ - # draw lead car - dl = (plant.distance_lead - plant.distance) + 4.5 - lx = carx + dl * math.cos(heading) - ly = cary + dl * math.sin(heading) - - display.blit(pygame.transform.rotate(leadcar, 90-math.degrees(heading)), (lx*METER, ly*METER)) - """ - - pygame.display.flip() diff --git a/selfdrive/test/setup_device_ci.sh b/selfdrive/test/setup_device_ci.sh new file mode 100755 index 00000000000000..d0140366fa6816 --- /dev/null +++ b/selfdrive/test/setup_device_ci.sh @@ -0,0 +1,38 @@ +#!/usr/bin/bash -e + +export SOURCE_DIR="/data/openpilot_source/" + +if [ -z "$GIT_COMMIT" ]; then + echo "GIT_COMMIT must be set" + exit 1 +fi + +if [ -z "$TEST_DIR" ]; then + + echo "TEST_DIR must be set" + exit 1 +fi + +# TODO: never clear qcom_replay cache +# clear scons cache dirs that haven't been written to in one day +cd /tmp && find -name 'scons_cache_*' -type d -maxdepth 1 -mtime +1 -exec rm -rf '{}' \; + +# this can get really big on the CI devices +rm -rf /data/core + +# set up environment +cd $SOURCE_DIR +git reset --hard +git fetch origin +find . -maxdepth 1 -not -path './.git' -not -name '.' -not -name '..' -exec rm -rf '{}' \; +git reset --hard $GIT_COMMIT +git checkout $GIT_COMMIT +git clean -xdf +git submodule update --init +git submodule foreach --recursive git reset --hard +git submodule foreach --recursive git clean -xdf +echo "git checkout took $SECONDS seconds" + +rsync -a --delete $SOURCE_DIR $TEST_DIR + +echo "$TEST_DIR synced with $GIT_COMMIT, took $SECONDS seconds" diff --git a/selfdrive/test/test_car_models_openpilot.py b/selfdrive/test/test_car_models_openpilot.py deleted file mode 100755 index 53184653c6021f..00000000000000 --- a/selfdrive/test/test_car_models_openpilot.py +++ /dev/null @@ -1,494 +0,0 @@ -#!/usr/bin/env python2 -import shutil -import time -import zmq -import os -import sys -import signal -import subprocess -import requests -from cereal import car - -import selfdrive.manager as manager -from selfdrive.services import service_list -import selfdrive.messaging as messaging -from common.params import Params -from common.basedir import BASEDIR -from selfdrive.car.honda.values import CAR as HONDA -from selfdrive.car.toyota.values import CAR as TOYOTA -from selfdrive.car.gm.values import CAR as GM -from selfdrive.car.ford.values import CAR as FORD -from selfdrive.car.hyundai.values import CAR as HYUNDAI -from selfdrive.car.chrysler.values import CAR as CHRYSLER -from selfdrive.car.subaru.values import CAR as SUBARU -from selfdrive.car.mock.values import CAR as MOCK - - -os.environ['NOCRASH'] = '1' - - -def wait_for_socket(name, timeout=10.0): - socket = messaging.sub_sock(service_list[name].port) - cur_time = time.time() - - r = None - while time.time() - cur_time < timeout: - print("waiting for %s" % name) - try: - r = socket.recv(zmq.NOBLOCK) - break - except zmq.error.Again: - pass - time.sleep(0.5) - return r - -def get_route_logs(route_name): - for log_f in ["rlog.bz2", "fcamera.hevc"]: - log_path = os.path.join("/tmp", "%s--0--%s" % (route_name.replace("|", "_"), log_f)) - - if not os.path.isfile(log_path): - log_url = "https://commadataci.blob.core.windows.net/openpilotci/%s/0/%s" % (route_name.replace("|", "/"), log_f) - r = requests.get(log_url) - - if r.status_code == 200: - with open(log_path, "w") as f: - f.write(r.content) - else: - sys.exit(-1) - -routes = { - - "975b26878285314d|2018-12-25--14-42-13": { - 'carFingerprint': CHRYSLER.PACIFICA_2018_HYBRID, - 'enableCamera': True, - }, - "b0c9d2329ad1606b|2019-01-06--10-11-23": { - 'carFingerprint': CHRYSLER.PACIFICA_2017_HYBRID, - 'enableCamera': True, - }, - "0607d2516fc2148f|2019-02-13--23-03-16": { - 'carFingerprint': CHRYSLER.PACIFICA_2019_HYBRID, - 'enableCamera': True, - }, - # This pacifica was removed because the fingerprint seemed from a Volt - #"9f7a7e50a51fb9db|2019-01-03--14-05-01": { - # 'carFingerprint': CHRYSLER.PACIFICA_2018, - # 'enableCamera': True, - #}, - "9f7a7e50a51fb9db|2019-01-17--18-34-21": { - 'carFingerprint': CHRYSLER.JEEP_CHEROKEE, - 'enableCamera': True, - }, - "192a598e34926b1e|2019-04-04--13-27-39": { - 'carFingerprint': CHRYSLER.JEEP_CHEROKEE_2019, - 'enableCamera': True, - }, - "f1b4c567731f4a1b|2018-04-18--11-29-37": { - 'carFingerprint': FORD.FUSION, - 'enableCamera': False, - }, - "f1b4c567731f4a1b|2018-04-30--10-15-35": { - 'carFingerprint': FORD.FUSION, - 'enableCamera': True, - }, - "7ed9cdf8d0c5f43e|2018-05-17--09-31-36": { - 'carFingerprint': GM.CADILLAC_CT6, - 'enableCamera': True, - }, - "265007255e794bce|2018-11-24--22-08-31": { - 'carFingerprint': GM.CADILLAC_ATS, - 'enableCamera': True, - }, - "c950e28c26b5b168|2018-05-30--22-03-41": { - 'carFingerprint': GM.VOLT, - 'enableCamera': True, - }, - # TODO: use another route that has radar data at start - "aadda448b49c99ad|2018-10-25--17-16-22": { - 'carFingerprint': GM.MALIBU, - 'enableCamera': True, - }, - "49c73650e65ff465|2018-11-19--16-58-04": { - 'carFingerprint': GM.HOLDEN_ASTRA, - 'enableCamera': True, - }, - "7cc2a8365b4dd8a9|2018-12-02--12-10-44": { - 'carFingerprint': GM.ACADIA, - 'enableCamera': True, - }, - "aa20e335f61ba898|2018-12-17--21-10-37": { - 'carFingerprint': GM.BUICK_REGAL, - 'enableCamera': False, - }, - "aa20e335f61ba898|2019-02-05--16-59-04": { - 'carFingerprint': GM.BUICK_REGAL, - 'enableCamera': True, - }, - "7d44af5b7a1b2c8e|2017-09-16--01-50-07": { - 'carFingerprint': HONDA.CIVIC, - 'enableCamera': True, - }, - "c9d60e5e02c04c5c|2018-01-08--16-01-49": { - 'carFingerprint': HONDA.CRV, - 'enableCamera': True, - }, - "1851183c395ef471|2018-05-31--18-07-21": { - 'carFingerprint': HONDA.CRV_5G, - 'enableCamera': True, - }, - "232585b7784c1af4|2019-04-08--14-12-14": { - 'carFingerprint': HONDA.CRV_HYBRID, - 'enableCamera': True, - }, - "2ac95059f70d76eb|2018-02-05--15-03-29": { - 'carFingerprint': HONDA.ACURA_ILX, - 'enableCamera': True, - }, - "21aa231dee2a68bd|2018-01-30--04-54-41": { - 'carFingerprint': HONDA.ODYSSEY, - 'enableCamera': True, - }, - "81722949a62ea724|2019-03-29--15-51-26": { - 'carFingerprint': HONDA.ODYSSEY_CHN, - 'enableCamera': False, - }, - "81722949a62ea724|2019-04-06--15-19-25": { - 'carFingerprint': HONDA.ODYSSEY_CHN, - 'enableCamera': True, - }, - "5a2cfe4bb362af9e|2018-02-02--23-41-07": { - 'carFingerprint': HONDA.ACURA_RDX, - 'enableCamera': True, - }, - "3e9592a1c78a3d63|2018-02-08--20-28-24": { - 'carFingerprint': HONDA.PILOT, - 'enableCamera': True, - }, - "34a84d2b765df688|2018-08-28--12-41-00": { - 'carFingerprint': HONDA.PILOT_2019, - 'enableCamera': True, - }, - "900ad17e536c3dc7|2018-04-12--22-02-36": { - 'carFingerprint': HONDA.RIDGELINE, - 'enableCamera': True, - }, - "f1b4c567731f4a1b|2018-06-06--14-43-46": { - 'carFingerprint': HONDA.ACCORD, - 'enableCamera': True, - }, - "1582e1dc57175194|2018-08-15--07-46-07": { - 'carFingerprint': HONDA.ACCORD_15, - 'enableCamera': True, - }, - # TODO: This doesnt fingerprint because the fingerprint overlaps with the Insight - # "690c4c9f9f2354c7|2018-09-15--17-36-05": { - # 'carFingerprint': HONDA.ACCORDH, - # 'enableCamera': True, - # }, - "1632088eda5e6c4d|2018-06-07--08-03-18": { - 'carFingerprint': HONDA.CIVIC_BOSCH, - 'enableCamera': True, - }, - #"18971a99f3f2b385|2018-11-14--19-09-31": { - # 'carFingerprint': HONDA.INSIGHT, - # 'enableCamera': True, - #}, - "38bfd238edecbcd7|2018-08-22--09-45-44": { - 'carFingerprint': HYUNDAI.SANTA_FE, - 'enableCamera': False, - }, - "38bfd238edecbcd7|2018-08-29--22-02-15": { - 'carFingerprint': HYUNDAI.SANTA_FE, - 'enableCamera': True, - }, - "a893a80e5c5f72c8|2019-01-14--20-02-59": { - 'carFingerprint': HYUNDAI.GENESIS, - 'enableCamera': True, - }, - "9d5fb4f0baa1b3e1|2019-01-14--17-45-59": { - 'carFingerprint': HYUNDAI.KIA_SORENTO, - 'enableCamera': True, - }, - "215cd70e9c349266|2018-11-25--22-22-12": { - 'carFingerprint': HYUNDAI.KIA_STINGER, - 'enableCamera': True, - }, - "31390e3eb6f7c29a|2019-01-23--08-56-00": { - 'carFingerprint': HYUNDAI.KIA_OPTIMA, - 'enableCamera': True, - }, - "53ac3251e03f95d7|2019-01-10--13-43-32": { - 'carFingerprint': HYUNDAI.ELANTRA, - 'enableCamera': True, - }, - "f7b6be73e3dfd36c|2019-05-12--18-07-16": { - 'carFingerprint': TOYOTA.AVALON, - 'enableCamera': False, - 'enableDsu': False, - }, - "f7b6be73e3dfd36c|2019-05-11--22-34-20": { - 'carFingerprint': TOYOTA.AVALON, - 'enableCamera': True, - 'enableDsu': False, - }, - "b0f5a01cf604185c|2018-01-26--00-54-32": { - 'carFingerprint': TOYOTA.COROLLA, - 'enableCamera': True, - 'enableDsu': True, - }, - "b0f5a01cf604185c|2018-01-26--10-54-38": { - 'carFingerprint': TOYOTA.COROLLA, - 'enableCamera': True, - 'enableDsu': False, - }, - "b0f5a01cf604185c|2018-01-26--10-59-31": { - 'carFingerprint': TOYOTA.COROLLA, - 'enableCamera': False, - 'enableDsu': False, - }, - "5f5afb36036506e4|2019-05-14--02-09-54": { - 'carFingerprint': TOYOTA.COROLLA_TSS2, - 'enableCamera': True, - 'enableDsu': True, - }, - "56fb1c86a9a86404|2017-11-10--10-18-43": { - 'carFingerprint': TOYOTA.PRIUS, - 'enableCamera': True, - 'enableDsu': True, - }, - "b0f5a01cf604185c|2017-12-18--20-32-32": { - 'carFingerprint': TOYOTA.RAV4, - 'enableCamera': True, - 'enableDsu': True, - 'enableGasInterceptor': False, - }, - "b0c9d2329ad1606b|2019-04-02--13-24-43": { - 'carFingerprint': TOYOTA.RAV4, - 'enableCamera': True, - 'enableDsu': True, - 'enableGasInterceptor': True, - }, - "cdf2f7de565d40ae|2019-04-25--03-53-41": { - 'carFingerprint': TOYOTA.RAV4_TSS2, - 'enableCamera': True, - 'enableDsu': True, - }, - "f49e8041283f2939|2019-05-29--13-48-33": { - 'carFingerprint': TOYOTA.LEXUS_ESH_TSS2, - 'enableCamera': False, - 'enableDsu': False, - }, - "f49e8041283f2939|2019-05-30--11-51-51": { - 'carFingerprint': TOYOTA.LEXUS_ESH_TSS2, - 'enableCamera': True, - 'enableDsu': True, - }, - "b0f5a01cf604185c|2018-02-01--21-12-28": { - 'carFingerprint': TOYOTA.LEXUS_RXH, - 'enableCamera': True, - 'enableDsu': True, - }, - #FIXME: This works sometimes locally, but never in CI. Timing issue? - #"b0f5a01cf604185c|2018-01-31--20-11-39": { - # 'carFingerprint': TOYOTA.LEXUS_RXH, - # 'enableCamera': False, - # 'enableDsu': False, - #}, - "8ae193ceb56a0efe|2018-06-18--20-07-32": { - 'carFingerprint': TOYOTA.RAV4H, - 'enableCamera': True, - 'enableDsu': True, - }, - "fd10b9a107bb2e49|2018-07-24--16-32-42": { - 'carFingerprint': TOYOTA.CHR, - 'enableCamera': True, - 'enableDsu': False, - }, - "fd10b9a107bb2e49|2018-07-24--20-32-08": { - 'carFingerprint': TOYOTA.CHR, - 'enableCamera': False, - 'enableDsu': False, - }, - "b4c18bf13d5955da|2018-07-29--13-39-46": { - 'carFingerprint': TOYOTA.CHRH, - 'enableCamera': True, - 'enableDsu': False, - }, - "d2d8152227f7cb82|2018-07-25--13-40-56": { - 'carFingerprint': TOYOTA.CAMRY, - 'enableCamera': True, - 'enableDsu': False, - }, - "fbd011384db5e669|2018-07-26--20-51-48": { - 'carFingerprint': TOYOTA.CAMRYH, - 'enableCamera': True, - 'enableDsu': False, - }, - # TODO: This replay has no good model/video - # "c9fa2dd0f76caf23|2018-02-10--13-40-28": { - # 'carFingerprint': TOYOTA.CAMRYH, - # 'enableCamera': False, - # 'enableDsu': False, - # }, - # TODO: missingsome combos for highlander - "aa659debdd1a7b54|2018-08-31--11-12-01": { - 'carFingerprint': TOYOTA.HIGHLANDER, - 'enableCamera': False, - 'enableDsu': False, - }, - "362d23d4d5bea2fa|2018-09-02--17-03-55": { - 'carFingerprint': TOYOTA.HIGHLANDERH, - 'enableCamera': True, - 'enableDsu': True, - }, - "eb6acd681135480d|2019-06-20--20-00-00": { - 'carFingerprint': TOYOTA.SIENNA, - 'enableCamera': True, - 'enableDsu': False, - }, - "362d23d4d5bea2fa|2018-08-10--13-31-40": { - 'carFingerprint': TOYOTA.HIGHLANDERH, - 'enableCamera': False, - 'enableDsu': False, - }, - "791340bc01ed993d|2019-03-10--16-28-08": { - 'carFingerprint': SUBARU.IMPREZA, - 'enableCamera': True, - }, - # Tesla route, should result in mock car - "07cb8a788c31f645|2018-06-17--18-50-29": { - 'carFingerprint': MOCK.MOCK, - }, - ## Route with no can data, should result in mock car. This is not supported anymore - #"bfa17080b080f3ec|2018-06-28--23-27-47": { - # 'carFingerprint': MOCK.MOCK, - #}, -} - -passive_routes = [ - "07cb8a788c31f645|2018-06-17--18-50-29", - #"bfa17080b080f3ec|2018-06-28--23-27-47", -] - -public_routes = [ - "f1b4c567731f4a1b|2018-06-06--14-43-46", - "f1b4c567731f4a1b|2018-04-18--11-29-37", - "f1b4c567731f4a1b|2018-04-18--11-29-37", - "7ed9cdf8d0c5f43e|2018-05-17--09-31-36", - "38bfd238edecbcd7|2018-08-22--09-45-44", - "38bfd238edecbcd7|2018-08-29--22-02-15", - "b0f5a01cf604185c|2018-01-26--00-54-32", - "b0f5a01cf604185c|2018-01-26--10-54-38", - "b0f5a01cf604185c|2018-01-26--10-59-31", - "56fb1c86a9a86404|2017-11-10--10-18-43", - "b0f5a01cf604185c|2017-12-18--20-32-32", - "b0c9d2329ad1606b|2019-04-02--13-24-43", - "791340bc01ed993d|2019-03-10--16-28-08", -] - -if __name__ == "__main__": - - results = {} - for route, checks in routes.items(): - - if route not in public_routes: - print "route not public", route - continue - - get_route_logs(route) - - for _ in range(3): - shutil.rmtree('/data/params') - manager.gctx = {} - params = Params() - params.manager_start() - if route in passive_routes: - params.put("Passive", "1") - else: - params.put("Passive", "0") - - print "testing ", route, " ", checks['carFingerprint'] - print "Preparing processes" - manager.prepare_managed_process("radard") - manager.prepare_managed_process("controlsd") - manager.prepare_managed_process("plannerd") - print "Starting processes" - manager.start_managed_process("radard") - manager.start_managed_process("controlsd") - manager.start_managed_process("plannerd") - time.sleep(2) - - # Start unlogger - print "Start unlogger" - unlogger_cmd = [os.path.join(BASEDIR, 'tools/replay/unlogger.py'), '%s' % route, '/tmp', '--disable', 'frame,plan,pathPlan,liveLongitudinalMpc,radarState,controlsState,liveTracks,liveMpc,sendcan,carState,carControl', '--no-interactive'] - unlogger = subprocess.Popen(unlogger_cmd, preexec_fn=os.setsid) - - print "Check sockets" - controls_state_result = wait_for_socket('controlsState', timeout=30) - radarstate_result = wait_for_socket('radarState', timeout=30) - plan_result = wait_for_socket('plan', timeout=30) - - if route not in passive_routes: # TODO The passive routes have very flaky models - path_plan_result = wait_for_socket('pathPlan', timeout=30) - else: - path_plan_result = True - - carstate_result = wait_for_socket('carState', timeout=30) - - print "Check if everything is running" - running = manager.get_running() - controlsd_running = running['controlsd'].is_alive() - radard_running = running['radard'].is_alive() - plannerd_running = running['plannerd'].is_alive() - - manager.kill_managed_process("controlsd") - manager.kill_managed_process("radard") - manager.kill_managed_process("plannerd") - os.killpg(os.getpgid(unlogger.pid), signal.SIGTERM) - - sockets_ok = all([ - controls_state_result, radarstate_result, plan_result, path_plan_result, carstate_result, - controlsd_running, radard_running, plannerd_running - ]) - params_ok = True - failures = [] - - if not controlsd_running: - failures.append('controlsd') - if not radard_running: - failures.append('radard') - if not radarstate_result: - failures.append('radarState') - if not controls_state_result: - failures.append('controlsState') - if not plan_result: - failures.append('plan') - if not path_plan_result: - failures.append('pathPlan') - - try: - car_params = car.CarParams.from_bytes(params.get("CarParams")) - for k, v in checks.items(): - if not v == getattr(car_params, k): - params_ok = False - failures.append(k) - except: - params_ok = False - - if sockets_ok and params_ok: - print "Success" - results[route] = True, failures - break - else: - print "Failure" - results[route] = False, failures - - time.sleep(2) - - print results - params.put("Passive", "0") # put back not passive to not leave the params in an unintended state - if not all(passed for passed, _ in results.values()): - print "TEST FAILED" - sys.exit(1) - else: - print "TEST SUCESSFUL" diff --git a/selfdrive/test/test_cpu_usage.py b/selfdrive/test/test_cpu_usage.py new file mode 100755 index 00000000000000..b6147d17966e39 --- /dev/null +++ b/selfdrive/test/test_cpu_usage.py @@ -0,0 +1,109 @@ +#!/usr/bin/env python3 +import os +import time +import sys +import subprocess + +import cereal.messaging as messaging +from common.basedir import BASEDIR +from selfdrive.test.helpers import set_params_enabled + +def cputime_total(ct): + return ct.cpuUser + ct.cpuSystem + ct.cpuChildrenUser + ct.cpuChildrenSystem + + +def print_cpu_usage(first_proc, last_proc): + procs = [ + ("selfdrive.controls.controlsd", 47.0), + ("./loggerd", 42.0), + ("selfdrive.locationd.locationd", 35.0), + ("selfdrive.locationd.paramsd", 12.0), + ("selfdrive.controls.plannerd", 10.0), + ("./_modeld", 7.12), + ("./camerad", 7.07), + ("./_sensord", 6.17), + ("./_ui", 5.82), + ("selfdrive.controls.radard", 5.67), + ("./boardd", 3.63), + ("./_dmonitoringmodeld", 2.67), + ("selfdrive.logmessaged", 1.7), + ("selfdrive.thermald.thermald", 2.41), + ("selfdrive.locationd.calibrationd", 2.0), + ("selfdrive.monitoring.dmonitoringd", 1.90), + ("./proclogd", 1.54), + ("./_gpsd", 0.09), + ("./clocksd", 0.02), + ("./ubloxd", 0.02), + ("selfdrive.tombstoned", 0), + ("./logcatd", 0), + ] + + r = True + dt = (last_proc.logMonoTime - first_proc.logMonoTime) / 1e9 + result = "------------------------------------------------\n" + for proc_name, normal_cpu_usage in procs: + try: + first = [p for p in first_proc.procLog.procs if proc_name in p.cmdline][0] + last = [p for p in last_proc.procLog.procs if proc_name in p.cmdline][0] + cpu_time = cputime_total(last) - cputime_total(first) + cpu_usage = cpu_time / dt * 100. + if cpu_usage > max(normal_cpu_usage * 1.1, normal_cpu_usage + 5.0): + result += f"Warning {proc_name} using more CPU than normal\n" + r = False + elif cpu_usage < min(normal_cpu_usage * 0.65, max(normal_cpu_usage - 1.0, 0.0)): + result += f"Warning {proc_name} using less CPU than normal\n" + r = False + result += f"{proc_name.ljust(35)} {cpu_usage:.2f}%\n" + except IndexError: + result += f"{proc_name.ljust(35)} NO METRICS FOUND\n" + r = False + result += "------------------------------------------------\n" + print(result) + return r + +def test_cpu_usage(): + cpu_ok = False + + # start manager + os.environ['SKIP_FW_QUERY'] = "1" + os.environ['FINGERPRINT'] = "TOYOTA COROLLA TSS2 2019" + manager_path = os.path.join(BASEDIR, "selfdrive/manager.py") + manager_proc = subprocess.Popen(["python", manager_path]) + try: + proc_sock = messaging.sub_sock('procLog', conflate=True, timeout=2000) + cs_sock = messaging.sub_sock('controlsState', conflate=True) + + # wait until everything's started + start_time = time.monotonic() + while time.monotonic() - start_time < 240: + msg = messaging.recv_sock(cs_sock, wait=True) + if msg is not None: + break + + # take first sample + time.sleep(15) + first_proc = messaging.recv_sock(proc_sock, wait=True) + if first_proc is None: + raise Exception("\n\nTEST FAILED: progLog recv timed out\n\n") + + # run for a minute and get last sample + time.sleep(60) + last_proc = messaging.recv_sock(proc_sock, wait=True) + cpu_ok = print_cpu_usage(first_proc, last_proc) + finally: + manager_proc.terminate() + ret = manager_proc.wait(20) + if ret is None: + manager_proc.kill() + return cpu_ok + +if __name__ == "__main__": + set_params_enabled() + + passed = False + try: + passed = test_cpu_usage() + except Exception as e: + print("\n\n\n", "TEST FAILED:", str(e), "\n\n\n") + finally: + sys.exit(int(not passed)) diff --git a/selfdrive/test/test_fingerprints.py b/selfdrive/test/test_fingerprints.py index 721ea163fcc8af..8877255c6b6cb4 100755 --- a/selfdrive/test/test_fingerprints.py +++ b/selfdrive/test/test_fingerprints.py @@ -1,7 +1,15 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 import os import sys from common.basedir import BASEDIR +from selfdrive.car.fingerprints import IGNORED_FINGERPRINTS + +# messages reserved for CAN based ignition (see can_ignition_hook function in panda/board/drivers/can) +# (addr, len) +CAN_IGNITION_MSGS = { + 'gm': [(0x1F1, 8), (0x160, 5)], + #'tesla' : [(0x348, 8)], +} def _get_fingerprints(): # read all the folders in selfdrive/car and return a dict where: @@ -20,9 +28,9 @@ def _get_fingerprints(): def check_fingerprint_consistency(f1, f2): # return false if it finds a fingerprint fully included in another - # max message worth checking is 1800, as above that they usually come too infrequently and not # usable for fingerprinting + max_msg = 1800 is_f1_in_f2 = True @@ -38,15 +46,36 @@ def check_fingerprint_consistency(f1, f2): return not is_f1_in_f2 and not is_f2_in_f1 +def check_can_ignition_conflicts(fingerprints, brands): + # loops through all the fingerprints and exits if CAN ignition dedicated messages + # are found in unexpected fingerprints + + for brand_can, msgs_can in CAN_IGNITION_MSGS.items(): + for i, f in enumerate(fingerprints): + for msg_can in msgs_can: + if brand_can != brands[i] and msg_can[0] in f and msg_can[1] == f[msg_can[0]]: + print("CAN ignition dedicated msg %d with len %d found in %s fingerprints!" % (msg_can[0], msg_can[1], brands[i])) + print("TEST FAILED") + sys.exit(1) + + fingerprints = _get_fingerprints() + fingerprints_flat = [] car_names = [] +brand_names = [] for brand in fingerprints: for car in fingerprints[brand]: + if car in IGNORED_FINGERPRINTS: + continue + fingerprints_flat += fingerprints[brand][car] for i in range(len(fingerprints[brand][car])): car_names.append(car) + brand_names.append(brand) +# first check if CAN ignition specific messages are unexpectedly included in other fingerprints +check_can_ignition_conflicts(fingerprints_flat, brand_names) valid = True for idx1, f1 in enumerate(fingerprints_flat): diff --git a/selfdrive/test/test_openpilot.py b/selfdrive/test/test_openpilot.py index 13770f50a5ff6b..75e8192f4cb7c0 100644 --- a/selfdrive/test/test_openpilot.py +++ b/selfdrive/test/test_openpilot.py @@ -1,64 +1,24 @@ +# flake8: noqa import os os.environ['FAKEUPLOAD'] = "1" -from common.testing import phone_only -from selfdrive.manager import manager_init, manager_prepare -from selfdrive.manager import start_managed_process, kill_managed_process, get_running -from functools import wraps +from common.params import Params +from common.realtime import sec_since_boot +from selfdrive.manager import manager_init, manager_prepare, start_daemon_process +from selfdrive.test.helpers import phone_only, with_processes, set_params_enabled +import json +import requests +import signal +import subprocess import time -DID_INIT = False # must run first @phone_only def test_manager_prepare(): - global DID_INIT + set_params_enabled() manager_init() manager_prepare() - DID_INIT = True - -def with_processes(processes): - def wrapper(func): - @wraps(func) - def wrap(): - if not DID_INIT: - test_manager_prepare() - - # start and assert started - [start_managed_process(p) for p in processes] - assert all(get_running()[name].exitcode is None for name in processes) - - # call the function - func() - - # assert processes are still started - assert all(get_running()[name].exitcode is None for name in processes) - - # kill and assert all stopped - [kill_managed_process(p) for p in processes] - assert len(get_running()) == 0 - return wrap - return wrapper - -#@phone_only -#@with_processes(['controlsd', 'radard']) -#def test_controls(): -# from selfdrive.test.plant.plant import Plant -# -# # start the fake car for 2 seconds -# plant = Plant(100) -# for i in range(200): -# if plant.rk.frame >= 20 and plant.rk.frame <= 25: -# cruise_buttons = CruiseButtons.RES_ACCEL -# # rolling forward -# assert plant.speed > 0 -# else: -# cruise_buttons = 0 -# plant.step(cruise_buttons = cruise_buttons) -# plant.close() -# -# # assert that we stopped -# assert plant.speed == 0.0 @phone_only @with_processes(['loggerd', 'logmessaged', 'tombstoned', 'proclogd', 'logcatd']) @@ -67,7 +27,7 @@ def test_logging(): time.sleep(1.0) @phone_only -@with_processes(['visiond']) +@with_processes(['camerad', 'modeld', 'dmonitoringmodeld']) def test_visiond(): print("VISIOND IS SET UP") time.sleep(5.0) @@ -91,3 +51,128 @@ def test_ui(): def test_uploader(): print("UPLOADER") time.sleep(10.0) + +@phone_only +def test_athena(): + print("ATHENA") + start = sec_since_boot() + start_daemon_process("manage_athenad") + params = Params() + manage_athenad_pid = params.get("AthenadPid") + assert manage_athenad_pid is not None + try: + os.kill(int(manage_athenad_pid), 0) + # process is running + except OSError: + assert False, "manage_athenad is dead" + + def expect_athena_starts(timeout=30): + now = time.time() + athenad_pid = None + while athenad_pid is None: + try: + athenad_pid = subprocess.check_output(["pgrep", "-P", manage_athenad_pid], encoding="utf-8").strip() + return athenad_pid + except subprocess.CalledProcessError: + if time.time() - now > timeout: + assert False, f"Athena did not start within {timeout} seconds" + time.sleep(0.5) + + def athena_post(payload, max_retries=5, wait=5): + tries = 0 + while 1: + try: + resp = requests.post( + "https://athena.comma.ai/" + params.get("DongleId", encoding="utf-8"), + headers={ + "Authorization": "JWT " + os.getenv("COMMA_JWT"), + "Content-Type": "application/json" + }, + data=json.dumps(payload), + timeout=30 + ) + resp_json = resp.json() + if resp_json.get('error'): + raise Exception(resp_json['error']) + return resp_json + except Exception as e: + time.sleep(wait) + tries += 1 + if tries == max_retries: + raise + else: + print(f'athena_post failed {e}. retrying...') + + def expect_athena_registers(test_t0): + resp = athena_post({ + "method": "echo", + "params": ["hello"], + "id": 0, + "jsonrpc": "2.0" + }, max_retries=12, wait=5) + assert resp.get('result') == "hello", f'Athena failed to register ({resp})' + + last_pingtime = params.get("LastAthenaPingTime", encoding='utf8') + assert last_pingtime, last_pingtime + assert ((int(last_pingtime)/1e9) - test_t0) < (sec_since_boot() - test_t0) + + try: + athenad_pid = expect_athena_starts() + # kill athenad and ensure it is restarted (check_output will throw if it is not) + os.kill(int(athenad_pid), signal.SIGINT) + expect_athena_starts() + + if not os.getenv('COMMA_JWT'): + print('WARNING: COMMA_JWT env not set, will not test requests to athena.comma.ai') + return + + expect_athena_registers(start) + + print("ATHENA: getSimInfo") + resp = athena_post({ + "method": "getSimInfo", + "id": 0, + "jsonrpc": "2.0" + }) + assert resp.get('result'), resp + assert 'sim_id' in resp['result'], resp['result'] + + print("ATHENA: takeSnapshot") + resp = athena_post({ + "method": "takeSnapshot", + "id": 0, + "jsonrpc": "2.0" + }) + assert resp.get('result'), resp + assert resp['result']['jpegBack'], resp['result'] + + @with_processes(["thermald"]) + def test_athena_thermal(): + print("ATHENA: getMessage(thermal)") + resp = athena_post({ + "method": "getMessage", + "params": {"service": "thermal", "timeout": 5000}, + "id": 0, + "jsonrpc": "2.0" + }) + assert resp.get('result'), resp + assert resp['result']['thermal'], resp['result'] + test_athena_thermal() + finally: + try: + athenad_pid = subprocess.check_output(["pgrep", "-P", manage_athenad_pid], encoding="utf-8").strip() + except subprocess.CalledProcessError: + athenad_pid = None + + try: + os.kill(int(manage_athenad_pid), signal.SIGINT) + os.kill(int(athenad_pid), signal.SIGINT) + except (OSError, TypeError): + pass + +# TODO: re-enable when jenkins test has /data/pythonpath -> /data/openpilot +# @phone_only +# @with_apks() +# def test_apks(): +# print("APKS") +# time.sleep(14.0) diff --git a/selfdrive/test/tests/__init__.py b/selfdrive/test/tests/__init__.py deleted file mode 100644 index e69de29bb2d1d6..00000000000000 diff --git a/selfdrive/test/tests/plant/__init__.py b/selfdrive/test/tests/plant/__init__.py deleted file mode 100644 index e69de29bb2d1d6..00000000000000 diff --git a/selfdrive/test/tests/plant/test_longitudinal.py b/selfdrive/test/tests/plant/test_longitudinal.py deleted file mode 100755 index 09e81b2a113772..00000000000000 --- a/selfdrive/test/tests/plant/test_longitudinal.py +++ /dev/null @@ -1,376 +0,0 @@ -#!/usr/bin/env python -import os -os.environ['OLD_CAN'] = '1' -os.environ['NOCRASH'] = '1' - -import time -import unittest -import shutil -import matplotlib -matplotlib.use('svg') - -from selfdrive.config import Conversions as CV -from selfdrive.car.honda.values import CruiseButtons as CB -from selfdrive.test.plant.maneuver import Maneuver -import selfdrive.manager as manager -from common.params import Params - - -def create_dir(path): - try: - os.makedirs(path) - except OSError: - pass - - -def check_no_collision(log): - return min(log['d_rel']) > 0 - -def check_fcw(log): - return any(log['fcw']) - -def check_engaged(log): - return log['controls_state_msgs'][-1][-1].active - -maneuvers = [ - Maneuver( - 'while cruising at 40 mph, change cruise speed to 50mph', - duration=30., - initial_speed = 40. * CV.MPH_TO_MS, - cruise_button_presses = [(CB.DECEL_SET, 2.), (0, 2.3), - (CB.RES_ACCEL, 10.), (0, 10.1), - (CB.RES_ACCEL, 10.2), (0, 10.3)], - checks=[check_engaged], - ), - Maneuver( - 'while cruising at 60 mph, change cruise speed to 50mph', - duration=30., - initial_speed=60. * CV.MPH_TO_MS, - cruise_button_presses = [(CB.DECEL_SET, 2.), (0, 2.3), - (CB.DECEL_SET, 10.), (0, 10.1), - (CB.DECEL_SET, 10.2), (0, 10.3)], - checks=[check_engaged], - ), - Maneuver( - 'while cruising at 20mph, grade change +10%', - duration=25., - initial_speed=20. * CV.MPH_TO_MS, - cruise_button_presses = [(CB.DECEL_SET, 1.2), (0, 1.3)], - grade_values = [0., 0., 1.0], - grade_breakpoints = [0., 10., 11.], - checks=[check_engaged], - ), - Maneuver( - 'while cruising at 20mph, grade change -10%', - duration=25., - initial_speed=20. * CV.MPH_TO_MS, - cruise_button_presses = [(CB.DECEL_SET, 1.2), (0, 1.3)], - grade_values = [0., 0., -1.0], - grade_breakpoints = [0., 10., 11.], - checks=[check_engaged], - ), - Maneuver( - 'approaching a 40mph car while cruising at 60mph from 100m away', - duration=30., - initial_speed = 60. * CV.MPH_TO_MS, - lead_relevancy=True, - initial_distance_lead=100., - speed_lead_values = [40.*CV.MPH_TO_MS, 40.*CV.MPH_TO_MS], - speed_lead_breakpoints = [0., 100.], - cruise_button_presses = [(CB.DECEL_SET, 1.2), (0, 1.3)], - checks=[check_engaged, check_no_collision], - ), - Maneuver( - 'approaching a 0mph car while cruising at 40mph from 150m away', - duration=30., - initial_speed = 40. * CV.MPH_TO_MS, - lead_relevancy=True, - initial_distance_lead=150., - speed_lead_values = [0.*CV.MPH_TO_MS, 0.*CV.MPH_TO_MS], - speed_lead_breakpoints = [0., 100.], - cruise_button_presses = [(CB.DECEL_SET, 1.2), (0, 1.3)], - checks=[check_engaged, check_no_collision], - ), - Maneuver( - 'steady state following a car at 20m/s, then lead decel to 0mph at 1m/s^2', - duration=50., - initial_speed = 20., - lead_relevancy=True, - initial_distance_lead=35., - speed_lead_values = [20., 20., 0.], - speed_lead_breakpoints = [0., 15., 35.0], - cruise_button_presses = [(CB.DECEL_SET, 1.2), (0, 1.3)], - checks=[check_engaged, check_no_collision], - ), - Maneuver( - 'steady state following a car at 20m/s, then lead decel to 0mph at 2m/s^2', - duration=50., - initial_speed = 20., - lead_relevancy=True, - initial_distance_lead=35., - speed_lead_values = [20., 20., 0.], - speed_lead_breakpoints = [0., 15., 25.0], - cruise_button_presses = [(CB.DECEL_SET, 1.2), (0, 1.3)], - checks=[check_engaged, check_no_collision], - ), - Maneuver( - 'steady state following a car at 20m/s, then lead decel to 0mph at 3m/s^2', - duration=50., - initial_speed = 20., - lead_relevancy=True, - initial_distance_lead=35., - speed_lead_values = [20., 20., 0.], - speed_lead_breakpoints = [0., 15., 21.66], - cruise_button_presses = [(CB.DECEL_SET, 1.2), (0, 1.3)], - checks=[check_engaged, check_fcw], - ), - Maneuver( - 'steady state following a car at 20m/s, then lead decel to 0mph at 5m/s^2', - duration=40., - initial_speed = 20., - lead_relevancy=True, - initial_distance_lead=35., - speed_lead_values = [20., 20., 0.], - speed_lead_breakpoints = [0., 15., 19.], - cruise_button_presses = [(CB.DECEL_SET, 1.2), (0, 1.3)], - checks=[check_engaged, check_fcw], - ), - Maneuver( - 'starting at 0mph, approaching a stopped car 100m away', - duration=30., - initial_speed = 0., - lead_relevancy=True, - initial_distance_lead=100., - cruise_button_presses = [(CB.DECEL_SET, 1.2), (0, 1.3), - (CB.RES_ACCEL, 1.4), (0.0, 1.5), - (CB.RES_ACCEL, 1.6), (0.0, 1.7), - (CB.RES_ACCEL, 1.8), (0.0, 1.9)], - checks=[check_engaged, check_no_collision], - ), - Maneuver( - "following a car at 60mph, lead accel and decel at 0.5m/s^2 every 2s", - duration=25., - initial_speed=30., - lead_relevancy=True, - initial_distance_lead=49., - speed_lead_values=[30.,30.,29.,31.,29.,31.,29.], - speed_lead_breakpoints=[0., 6., 8., 12.,16.,20.,24.], - cruise_button_presses = [(CB.DECEL_SET, 1.2), (0, 1.3), - (CB.RES_ACCEL, 1.4), (0.0, 1.5), - (CB.RES_ACCEL, 1.6), (0.0, 1.7)], - checks=[check_engaged, check_no_collision], - ), - Maneuver( - "following a car at 10mph, stop and go at 1m/s2 lead dece1 and accel", - duration=70., - initial_speed=10., - lead_relevancy=True, - initial_distance_lead=20., - speed_lead_values=[10., 0., 0., 10., 0.,10.], - speed_lead_breakpoints=[10., 20., 30., 40., 50., 60.], - cruise_button_presses = [(CB.DECEL_SET, 1.2), (0, 1.3), - (CB.RES_ACCEL, 1.4), (0.0, 1.5), - (CB.RES_ACCEL, 1.6), (0.0, 1.7)], - checks=[check_engaged, check_no_collision], - ), - Maneuver( - "green light: stopped behind lead car, lead car accelerates at 1.5 m/s", - duration=30., - initial_speed=0., - lead_relevancy=True, - initial_distance_lead=4., - speed_lead_values=[0, 0 , 45], - speed_lead_breakpoints=[0, 10., 40.], - cruise_button_presses = [(CB.DECEL_SET, 1.2), (0, 1.3), - (CB.RES_ACCEL, 1.4), (0.0, 1.5), - (CB.RES_ACCEL, 1.6), (0.0, 1.7), - (CB.RES_ACCEL, 1.8), (0.0, 1.9), - (CB.RES_ACCEL, 2.0), (0.0, 2.1), - (CB.RES_ACCEL, 2.2), (0.0, 2.3)], - checks=[check_engaged, check_no_collision], - ), - Maneuver( - "stop and go with 1m/s2 lead decel and accel, with full stops", - duration=70., - initial_speed=0., - lead_relevancy=True, - initial_distance_lead=20., - speed_lead_values=[10., 0., 0., 10., 0., 0.] , - speed_lead_breakpoints=[10., 20., 30., 40., 50., 60.], - cruise_button_presses = [(CB.DECEL_SET, 1.2), (0, 1.3), - (CB.RES_ACCEL, 1.4), (0.0, 1.5), - (CB.RES_ACCEL, 1.6), (0.0, 1.7)], - checks=[check_engaged, check_no_collision], - ), - Maneuver( - "stop and go with 1.5m/s2 lead accel and 3.3m/s^2 lead decel, with full stops", - duration=45., - initial_speed=0., - lead_relevancy=True, - initial_distance_lead=20., - speed_lead_values=[10., 0., 0., 10., 0., 0.] , - speed_lead_breakpoints=[10., 13., 26., 33., 36., 45.], - cruise_button_presses = [(CB.DECEL_SET, 1.2), (0, 1.3), - (CB.RES_ACCEL, 1.4), (0.0, 1.5), - (CB.RES_ACCEL, 1.6), (0.0, 1.7)], - checks=[check_engaged, check_no_collision], - ), - Maneuver( - "accelerate from 20 while lead vehicle decelerates from 40 to 20 at 1m/s2", - duration=30., - initial_speed=10., - lead_relevancy=True, - initial_distance_lead=10., - speed_lead_values=[20., 10.], - speed_lead_breakpoints=[1., 11.], - cruise_button_presses = [(CB.DECEL_SET, 1.2), (0, 1.3), - (CB.RES_ACCEL, 1.4), (0.0, 1.5), - (CB.RES_ACCEL, 1.6), (0.0, 1.7), - (CB.RES_ACCEL, 1.8), (0.0, 1.9), - (CB.RES_ACCEL, 2.0), (0.0, 2.1), - (CB.RES_ACCEL, 2.2), (0.0, 2.3)], - checks=[check_engaged, check_no_collision], - ), - Maneuver( - "accelerate from 20 while lead vehicle decelerates from 40 to 0 at 2m/s2", - duration=30., - initial_speed=10., - lead_relevancy=True, - initial_distance_lead=10., - speed_lead_values=[20., 0.], - speed_lead_breakpoints=[1., 11.], - cruise_button_presses = [(CB.DECEL_SET, 1.2), (0, 1.3), - (CB.RES_ACCEL, 1.4), (0.0, 1.5), - (CB.RES_ACCEL, 1.6), (0.0, 1.7), - (CB.RES_ACCEL, 1.8), (0.0, 1.9), - (CB.RES_ACCEL, 2.0), (0.0, 2.1), - (CB.RES_ACCEL, 2.2), (0.0, 2.3)], - checks=[check_engaged, check_no_collision], - ), - Maneuver( - "fcw: traveling at 30 m/s and approaching lead traveling at 20m/s", - duration=15., - initial_speed=30., - lead_relevancy=True, - initial_distance_lead=100., - speed_lead_values=[20.], - speed_lead_breakpoints=[1.], - cruise_button_presses = [], - checks=[check_fcw], - ), - Maneuver( - "fcw: traveling at 20 m/s following a lead that decels from 20m/s to 0 at 1m/s2", - duration=18., - initial_speed=20., - lead_relevancy=True, - initial_distance_lead=35., - speed_lead_values=[20., 0.], - speed_lead_breakpoints=[3., 23.], - cruise_button_presses = [], - checks=[check_fcw], - ), - Maneuver( - "fcw: traveling at 20 m/s following a lead that decels from 20m/s to 0 at 3m/s2", - duration=13., - initial_speed=20., - lead_relevancy=True, - initial_distance_lead=35., - speed_lead_values=[20., 0.], - speed_lead_breakpoints=[3., 9.6], - cruise_button_presses = [], - checks=[check_fcw], - ), - Maneuver( - "fcw: traveling at 20 m/s following a lead that decels from 20m/s to 0 at 5m/s2", - duration=8., - initial_speed=20., - lead_relevancy=True, - initial_distance_lead=35., - speed_lead_values=[20., 0.], - speed_lead_breakpoints=[3., 7.], - cruise_button_presses = [], - checks=[check_fcw], - ) -] - -# maneuvers = [maneuvers[-11]] -# maneuvers = [maneuvers[6]] - -def setup_output(): - output_dir = os.path.join(os.getcwd(), 'out/longitudinal') - if not os.path.exists(os.path.join(output_dir, "index.html")): - # write test output header - - css_style = """ - .maneuver_title { - font-size: 24px; - text-align: center; - } - .maneuver_graph { - width: 100%; - } - """ - - view_html = "" % (css_style,) - for i, man in enumerate(maneuvers): - view_html += "" % (man.title,) - for c in ['distance.svg', 'speeds.svg', 'acceleration.svg', 'pedals.svg', 'pid.svg']: - view_html += "" % (os.path.join("maneuver" + str(i+1).zfill(2), c), ) - view_html += "" - - create_dir(output_dir) - with open(os.path.join(output_dir, "index.html"), "w") as f: - f.write(view_html) - -class LongitudinalControl(unittest.TestCase): - @classmethod - def setUpClass(cls): - os.environ['NO_CAN_TIMEOUT'] = "1" - - setup_output() - - shutil.rmtree('/data/params', ignore_errors=True) - params = Params() - params.put("Passive", "1" if os.getenv("PASSIVE") else "0") - params.put("IsFcwEnabled", "1") - - manager.gctx = {} - manager.prepare_managed_process('radard') - manager.prepare_managed_process('controlsd') - manager.prepare_managed_process('plannerd') - - @classmethod - def tearDownClass(cls): - pass - - # hack - def test_longitudinal_setup(self): - pass - -def run_maneuver_worker(k): - man = maneuvers[k] - output_dir = os.path.join(os.getcwd(), 'out/longitudinal') - - def run(self): - print(man.title) - manager.start_managed_process('radard') - manager.start_managed_process('controlsd') - manager.start_managed_process('plannerd') - - plot, valid = man.evaluate() - plot.write_plot(output_dir, "maneuver" + str(k+1).zfill(2)) - - manager.kill_managed_process('radard') - manager.kill_managed_process('controlsd') - manager.kill_managed_process('plannerd') - time.sleep(5) - - self.assertTrue(valid) - - return run - -for k in range(len(maneuvers)): - setattr(LongitudinalControl, "test_longitudinal_maneuvers_%d" % (k+1), run_maneuver_worker(k)) - -if __name__ == "__main__": - unittest.main(failfast=True) diff --git a/selfdrive/test/tests/process_replay/.gitignore b/selfdrive/test/tests/process_replay/.gitignore deleted file mode 100644 index 6d339d54f69d21..00000000000000 --- a/selfdrive/test/tests/process_replay/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.bz2 -diff.txt diff --git a/selfdrive/test/tests/process_replay/README.md b/selfdrive/test/tests/process_replay/README.md deleted file mode 100644 index 639ca9051d0e08..00000000000000 --- a/selfdrive/test/tests/process_replay/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# process replay - -Process replay is a regression test designed to identify any changes in the output of a process. This test replays a segment through individual processes and compares the output to a known good replay. Each make is represented in the test with a segment. - -If the test fails, make sure that you didn't unintentionally change anything. If there are intentional changes, the reference logs will be updated. - -Use `test_processes.py` to run the test locally. - -Currently the following processes are tested: - -* controlsd -* radard -* plannerd -* calibrationd - diff --git a/selfdrive/test/tests/process_replay/__init__.py b/selfdrive/test/tests/process_replay/__init__.py deleted file mode 100644 index e69de29bb2d1d6..00000000000000 diff --git a/selfdrive/test/tests/process_replay/compare_logs.py b/selfdrive/test/tests/process_replay/compare_logs.py deleted file mode 100755 index 260e06c7716f05..00000000000000 --- a/selfdrive/test/tests/process_replay/compare_logs.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env python2 -import bz2 -import os -import sys - -import dictdiffer -if "CI" in os.environ: - tqdm = lambda x: x -else: - from tqdm import tqdm - -from tools.lib.logreader import LogReader - - -def save_log(dest, log_msgs): - dat = "" - for msg in log_msgs: - dat += msg.as_builder().to_bytes() - dat = bz2.compress(dat) - - with open(dest, "w") as f: - f.write(dat) - -def compare_logs(log1, log2, ignore=[]): - assert len(log1) == len(log2), "logs are not same length" - - diff = [] - for msg1, msg2 in tqdm(zip(log1, log2)): - assert msg1.which() == msg2.which(), "msgs not aligned between logs" - - msg1_bytes = msg1.as_builder().to_bytes() - msg2_bytes = msg2.as_builder().to_bytes() - - if msg1_bytes != msg2_bytes: - msg1_dict = msg1.to_dict(verbose=True) - msg2_dict = msg2.to_dict(verbose=True) - dd = dictdiffer.diff(msg1_dict, msg2_dict, ignore=ignore, tolerance=0) - diff.extend(dd) - return diff - -if __name__ == "__main__": - log1 = list(LogReader(sys.argv[1])) - log2 = list(LogReader(sys.argv[2])) - - compare_logs(log1, log2, sys.argv[3:]) diff --git a/selfdrive/test/tests/process_replay/process_replay.py b/selfdrive/test/tests/process_replay/process_replay.py deleted file mode 100755 index 66067b405d058c..00000000000000 --- a/selfdrive/test/tests/process_replay/process_replay.py +++ /dev/null @@ -1,185 +0,0 @@ -#!/usr/bin/env python2 -import gc -import os -import time - -if "CI" in os.environ: - tqdm = lambda x: x -else: - from tqdm import tqdm - -from cereal import car -from selfdrive.car.car_helpers import get_car -import selfdrive.manager as manager -import selfdrive.messaging as messaging -from common.params import Params -from selfdrive.services import service_list -from collections import namedtuple - -ProcessConfig = namedtuple('ProcessConfig', ['proc_name', 'pub_sub', 'ignore', 'init_callback', 'should_recv_callback']) - -def fingerprint(msgs, pub_socks, sub_socks): - print "start fingerprinting" - manager.prepare_managed_process("logmessaged") - manager.start_managed_process("logmessaged") - - can = pub_socks["can"] - logMessage = messaging.sub_sock(service_list["logMessage"].port) - - time.sleep(1) - messaging.drain_sock(logMessage) - - # controlsd waits for a health packet before fingerprinting - msg = messaging.new_message() - msg.init("health") - pub_socks["health"].send(msg.to_bytes()) - - canmsgs = filter(lambda msg: msg.which() == "can", msgs) - for msg in canmsgs[:200]: - can.send(msg.as_builder().to_bytes()) - - time.sleep(0.005) - log = messaging.recv_one_or_none(logMessage) - if log is not None and "fingerprinted" in log.logMessage: - break - manager.kill_managed_process("logmessaged") - print "finished fingerprinting" - -def get_car_params(msgs, pub_socks, sub_socks): - sendcan = pub_socks.get("sendcan", None) - if sendcan is None: - sendcan = messaging.pub_sock(service_list["sendcan"].port) - logcan = sub_socks.get("can", None) - if logcan is None: - logcan = messaging.sub_sock(service_list["can"].port) - can = pub_socks.get("can", None) - if can is None: - can = messaging.pub_sock(service_list["can"].port) - - time.sleep(0.5) - - canmsgs = filter(lambda msg: msg.which() == "can", msgs) - for m in canmsgs[:200]: - can.send(m.as_builder().to_bytes()) - _, CP = get_car(logcan, sendcan) - Params().put("CarParams", CP.to_bytes()) - time.sleep(0.5) - messaging.drain_sock(logcan) - -def radar_rcv_callback(msg, CP): - if msg.which() != "can": - return [] - - # hyundai and subaru don't have radar - radar_msgs = {"honda": [0x445], "toyota": [0x19f, 0x22f], "gm": [0x475], - "hyundai": [], "chrysler": [0x2d4], "subaru": []}.get(CP.carName, None) - - if radar_msgs is None: - raise NotImplementedError - - for m in msg.can: - if m.src == 1 and m.address in radar_msgs: - return ["radarState", "liveTracks"] - - return [] - -def plannerd_rcv_callback(msg, CP): - if msg.which() in ["model", "radarState"]: - time.sleep(0.005) - else: - time.sleep(0.002) - return {"model": ["pathPlan"], "radarState": ["plan"]}.get(msg.which(), []) - -CONFIGS = [ - ProcessConfig( - proc_name="controlsd", - pub_sub={ - "can": ["controlsState", "carState", "carControl", "sendcan"], - "thermal": [], "health": [], "liveCalibration": [], "driverMonitoring": [], "plan": [], "pathPlan": [] - }, - ignore=["logMonoTime", "controlsState.startMonoTime", "controlsState.cumLagMs"], - init_callback=fingerprint, - should_recv_callback=None, - ), - ProcessConfig( - proc_name="radard", - pub_sub={ - "can": ["radarState", "liveTracks"], - "liveParameters": [], "controlsState": [], "model": [], - }, - ignore=["logMonoTime", "radarState.cumLagMs"], - init_callback=get_car_params, - should_recv_callback=radar_rcv_callback, - ), - ProcessConfig( - proc_name="plannerd", - pub_sub={ - "model": ["pathPlan"], "radarState": ["plan"], - "carState": [], "controlsState": [], "liveParameters": [], - }, - ignore=["logMonoTime", "valid", "plan.processingDelay"], - init_callback=get_car_params, - should_recv_callback=plannerd_rcv_callback, - ), - ProcessConfig( - proc_name="calibrationd", - pub_sub={ - "cameraOdometry": ["liveCalibration"] - }, - ignore=["logMonoTime"], - init_callback=get_car_params, - should_recv_callback=None, - ), -] - -def replay_process(cfg, lr): - gc.disable() # gc can occasionally cause canparser to timeout - - pub_socks, sub_socks = {}, {} - for pub, sub in cfg.pub_sub.iteritems(): - pub_socks[pub] = messaging.pub_sock(service_list[pub].port) - - for s in sub: - sub_socks[s] = messaging.sub_sock(service_list[s].port) - - all_msgs = sorted(lr, key=lambda msg: msg.logMonoTime) - pub_msgs = filter(lambda msg: msg.which() in pub_socks.keys(), all_msgs) - - params = Params() - params.manager_start() - params.put("Passive", "0") - - manager.gctx = {} - manager.prepare_managed_process(cfg.proc_name) - manager.start_managed_process(cfg.proc_name) - time.sleep(3) # Wait for started process to be ready - - if cfg.init_callback is not None: - cfg.init_callback(all_msgs, pub_socks, sub_socks) - - CP = car.CarParams.from_bytes(params.get("CarParams", block=True)) - - log_msgs = [] - for msg in tqdm(pub_msgs): - if cfg.should_recv_callback is not None: - recv_socks = cfg.should_recv_callback(msg, CP) - else: - recv_socks = cfg.pub_sub[msg.which()] - - pub_socks[msg.which()].send(msg.as_builder().to_bytes()) - - if len(recv_socks): - # TODO: add timeout - for sock in recv_socks: - m = messaging.recv_one(sub_socks[sock]) - - # make these values fixed for faster comparison - m_builder = m.as_builder() - m_builder.logMonoTime = 0 - m_builder.valid = True - log_msgs.append(m_builder.as_reader()) - - gc.enable() - manager.kill_managed_process(cfg.proc_name) - return log_msgs - diff --git a/selfdrive/test/tests/process_replay/ref_commit b/selfdrive/test/tests/process_replay/ref_commit deleted file mode 100644 index 30a1a285389fbd..00000000000000 --- a/selfdrive/test/tests/process_replay/ref_commit +++ /dev/null @@ -1 +0,0 @@ -e3388c62ffb80f4b3ca8721da56a581a93c44e79 \ No newline at end of file diff --git a/selfdrive/test/tests/process_replay/test_processes.py b/selfdrive/test/tests/process_replay/test_processes.py deleted file mode 100755 index 8d70c80a2b0934..00000000000000 --- a/selfdrive/test/tests/process_replay/test_processes.py +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/env python2 -import os -import requests -import sys -import tempfile - -from selfdrive.test.tests.process_replay.compare_logs import compare_logs -from selfdrive.test.tests.process_replay.process_replay import replay_process, CONFIGS -from tools.lib.logreader import LogReader - -segments = [ - "0375fdf7b1ce594d|2019-06-13--08-32-25--3", # HONDA.ACCORD - "99c94dc769b5d96e|2019-08-03--14-19-59--2", # HONDA.CIVIC - "cce908f7eb8db67d|2019-08-02--15-09-51--3", # TOYOTA.COROLLA_TSS2 - "7ad88f53d406b787|2019-07-09--10-18-56--8", # GM.VOLT - "704b2230eb5190d6|2019-07-06--19-29-10--0", # HYUNDAI.KIA_SORENTO - "b6e1317e1bfbefa6|2019-07-06--04-05-26--5", # CHRYSLER.JEEP_CHEROKEE - "7873afaf022d36e2|2019-07-03--18-46-44--0", # SUBARU.IMPREZA -] - -def get_segment(segment_name): - route_name, segment_num = segment_name.rsplit("--", 1) - rlog_url = "https://commadataci.blob.core.windows.net/openpilotci/%s/%s/rlog.bz2" \ - % (route_name.replace("|", "/"), segment_num) - r = requests.get(rlog_url) - if r.status_code != 200: - return None - - with tempfile.NamedTemporaryFile(delete=False, suffix=".bz2") as f: - f.write(r.content) - return f.name - -if __name__ == "__main__": - - process_replay_dir = os.path.dirname(os.path.abspath(__file__)) - ref_commit_fn = os.path.join(process_replay_dir, "ref_commit") - - if not os.path.isfile(ref_commit_fn): - print "couldn't find reference commit" - sys.exit(1) - - ref_commit = open(ref_commit_fn).read().strip() - print "***** testing against commit %s *****" % ref_commit - - results = {} - for segment in segments: - print "***** testing route segment %s *****\n" % segment - - results[segment] = {} - - rlog_fn = get_segment(segment) - - if rlog_fn is None: - print "failed to get segment %s" % segment - sys.exit(1) - - lr = LogReader(rlog_fn) - - for cfg in CONFIGS: - log_msgs = replay_process(cfg, lr) - - log_fn = os.path.join(process_replay_dir, "%s_%s_%s.bz2" % (segment, cfg.proc_name, ref_commit)) - - if not os.path.isfile(log_fn): - url = "https://commadataci.blob.core.windows.net/openpilotci/" - req = requests.get(url + os.path.basename(log_fn)) - if req.status_code != 200: - results[segment][cfg.proc_name] = "failed to download comparison log" - continue - - with tempfile.NamedTemporaryFile(suffix=".bz2") as f: - f.write(req.content) - f.flush() - f.seek(0) - cmp_log_msgs = list(LogReader(f.name)) - else: - cmp_log_msgs = list(LogReader(log_fn)) - - diff = compare_logs(cmp_log_msgs, log_msgs, cfg.ignore) - results[segment][cfg.proc_name] = diff - os.remove(rlog_fn) - - failed = False - with open(os.path.join(process_replay_dir, "diff.txt"), "w") as f: - f.write("***** tested against commit %s *****\n" % ref_commit) - - for segment, result in results.items(): - f.write("***** differences for segment %s *****\n" % segment) - print "***** results for segment %s *****" % segment - - for proc, diff in result.items(): - f.write("*** process: %s ***\n" % proc) - print "\t%s" % proc - - if isinstance(diff, str): - print "\t\t%s" % diff - failed = True - elif len(diff): - cnt = {} - for d in diff: - f.write("\t%s\n" % str(d)) - - k = str(d[1]) - cnt[k] = 1 if k not in cnt else cnt[k] + 1 - - for k, v in sorted(cnt.items()): - print "\t\t%s: %s" % (k, v) - failed = True - - if failed: - print "TEST FAILED" - else: - print "TEST SUCCEEDED" - - print "\n\nTo update the reference logs for this test run:" - print "./update_refs.py" - - sys.exit(int(failed)) diff --git a/selfdrive/test/tests/process_replay/update_refs.py b/selfdrive/test/tests/process_replay/update_refs.py deleted file mode 100755 index 4bc2659391a304..00000000000000 --- a/selfdrive/test/tests/process_replay/update_refs.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python2 -import os -import sys - -from selfdrive.test.openpilotci_upload import upload_file -from selfdrive.test.tests.process_replay.compare_logs import save_log -from selfdrive.test.tests.process_replay.process_replay import replay_process, CONFIGS -from selfdrive.test.tests.process_replay.test_processes import segments, get_segment -from selfdrive.version import get_git_commit -from tools.lib.logreader import LogReader - -if __name__ == "__main__": - - no_upload = "--no-upload" in sys.argv - - process_replay_dir = os.path.dirname(os.path.abspath(__file__)) - ref_commit_fn = os.path.join(process_replay_dir, "ref_commit") - - ref_commit = get_git_commit() - with open(ref_commit_fn, "w") as f: - f.write(ref_commit) - - for segment in segments: - rlog_fn = get_segment(segment) - - if rlog_fn is None: - print "failed to get segment %s" % segment - sys.exit(1) - - lr = LogReader(rlog_fn) - - for cfg in CONFIGS: - log_msgs = replay_process(cfg, lr) - log_fn = os.path.join(process_replay_dir, "%s_%s_%s.bz2" % (segment, cfg.proc_name, ref_commit)) - save_log(log_fn, log_msgs) - - if not no_upload: - upload_file(log_fn, os.path.basename(log_fn)) - os.remove(log_fn) - os.remove(rlog_fn) - - print "done" diff --git a/selfdrive/thermald.py b/selfdrive/thermald.py deleted file mode 100755 index b8bf9d293f2268..00000000000000 --- a/selfdrive/thermald.py +++ /dev/null @@ -1,307 +0,0 @@ -#!/usr/bin/env python2.7 -import os -from smbus2 import SMBus -from cereal import log -from selfdrive.version import terms_version, training_version -from selfdrive.swaglog import cloudlog -import selfdrive.messaging as messaging -from selfdrive.services import service_list -from selfdrive.loggerd.config import get_available_percent -from common.params import Params -from common.realtime import sec_since_boot, DT_TRML -from common.numpy_fast import clip -from common.filter_simple import FirstOrderFilter -from selfdrive.car.tesla.readconfig import read_config_file,CarSettings - -ThermalStatus = log.ThermalData.ThermalStatus -CURRENT_TAU = 15. # 15s time constant - - -def read_tz(x): - with open("/sys/devices/virtual/thermal/thermal_zone%d/temp" % x) as f: - ret = max(0, int(f.read())) - return ret - -def read_thermal(): - dat = messaging.new_message() - dat.init('thermal') - dat.thermal.cpu0 = read_tz(5) - dat.thermal.cpu1 = read_tz(7) - dat.thermal.cpu2 = read_tz(10) - dat.thermal.cpu3 = read_tz(12) - dat.thermal.mem = read_tz(2) - dat.thermal.gpu = read_tz(16) - dat.thermal.bat = read_tz(29) - return dat - -LEON = False -def setup_eon_fan(): - global LEON - - os.system("echo 2 > /sys/module/dwc3_msm/parameters/otg_switch") - - bus = SMBus(7, force=True) - try: - bus.write_byte_data(0x21, 0x10, 0xf) # mask all interrupts - bus.write_byte_data(0x21, 0x03, 0x1) # set drive current and global interrupt disable - bus.write_byte_data(0x21, 0x02, 0x2) # needed? - bus.write_byte_data(0x21, 0x04, 0x4) # manual override source - except IOError: - print("LEON detected") - #os.system("echo 1 > /sys/devices/soc/6a00000.ssusb/power_supply/usb/usb_otg") - LEON = True - bus.close() - -last_eon_fan_val = None -def set_eon_fan(val): - global LEON, last_eon_fan_val - - if last_eon_fan_val is None or last_eon_fan_val != val: - bus = SMBus(7, force=True) - if LEON: - try: - i = [0x1, 0x3 | 0, 0x3 | 0x08, 0x3 | 0x10][val] - bus.write_i2c_block_data(0x3d, 0, [i]) - except IOError: - # tusb320 - if val == 0: - bus.write_i2c_block_data(0x67, 0xa, [0]) - else: - bus.write_i2c_block_data(0x67, 0xa, [0x20]) - bus.write_i2c_block_data(0x67, 0x8, [(val-1)<<6]) - else: - bus.write_byte_data(0x21, 0x04, 0x2) - bus.write_byte_data(0x21, 0x03, (val*2)+1) - bus.write_byte_data(0x21, 0x04, 0x4) - bus.close() - last_eon_fan_val = val - -# temp thresholds to control fan speed - high hysteresis -_TEMP_THRS_H = [50., 65., 80., 10000] -# temp thresholds to control fan speed - low hysteresis -_TEMP_THRS_L = [42.5, 57.5, 72.5, 10000] -# fan speed options -_FAN_SPEEDS = [0, 16384, 32768, 65535] -# max fan speed only allowed if battery is hot -_BAT_TEMP_THERSHOLD = 45. -if CarSettings().get_value("hasNoctuaFan"): - # fan speed options - _FAN_SPEEDS = [0, 65535, 65535, 65535] # Noctua fan is super quiet, so it can run on high most of the time. - # max fan speed only allowed if battery is hot - _BAT_TEMP_THERSHOLD = 20. # No need to wait for the battery to get hot, when you have a Notua fan. - -def handle_fan(max_cpu_temp, bat_temp, fan_speed): - new_speed_h = next(speed for speed, temp_h in zip(_FAN_SPEEDS, _TEMP_THRS_H) if temp_h > max_cpu_temp) - new_speed_l = next(speed for speed, temp_l in zip(_FAN_SPEEDS, _TEMP_THRS_L) if temp_l > max_cpu_temp) - - if new_speed_h > fan_speed: - # update speed if using the high thresholds results in fan speed increment - fan_speed = new_speed_h - elif new_speed_l < fan_speed: - # update speed if using the low thresholds results in fan speed decrement - fan_speed = new_speed_l - - if bat_temp < _BAT_TEMP_THERSHOLD: - # no max fan speed unless battery is hot - fan_speed = min(fan_speed, _FAN_SPEEDS[-2]) - - set_eon_fan(fan_speed/16384) - - return fan_speed - - -def check_car_battery_voltage(should_start, health, charging_disabled, msg, limitBatteryMinMax, batt_min, batt_max): - - # charging disallowed if: - # - there are health packets from panda, and; - # - 12V battery voltage is too low, and; - # - onroad isn't started - - limitBatteryMin = limitBatteryMinMax and (msg.thermal.batteryPercent < batt_min) - limitBatteryMax = limitBatteryMinMax and (msg.thermal.batteryPercent > batt_max) - #print limitBatteryMinMax,batt_min, batt_max, msg.thermal.batteryPercent - if charging_disabled and (health is None or health.health.voltage > 11800) and (limitBatteryMin or not limitBatteryMinMax): - charging_disabled = False - os.system('echo "1" > /sys/class/power_supply/battery/charging_enabled') - elif (not charging_disabled) and ((health is not None and health.health.voltage < 11500 and not should_start) or limitBatteryMax): - charging_disabled = True - os.system('echo "0" > /sys/class/power_supply/battery/charging_enabled') - - return charging_disabled - - -def thermald_thread(): - - # if limitting battery to Min-Max%. edit /data/bb_openpilot.cfg - car_set = CarSettings() - limitBatteryMinMax = car_set.get_value("limitBatteryMinMax") - batt_min = car_set.get_value("limitBattery_Min") - batt_max = car_set.get_value("limitBattery_Max") - - setup_eon_fan() - - # prevent LEECO from undervoltage - BATT_PERC_OFF = 10 if LEON else 3 - - # now loop - thermal_sock = messaging.pub_sock(service_list['thermal'].port) - health_sock = messaging.sub_sock(service_list['health'].port) - location_sock = messaging.sub_sock(service_list['gpsLocation'].port) - fan_speed = 0 - count = 0 - - off_ts = None - started_ts = None - ignition_seen = False - started_seen = False - thermal_status = ThermalStatus.green - health_sock.RCVTIMEO = int(1000 * 2 * DT_TRML) # 2x the expected health frequency - current_filter = FirstOrderFilter(0., CURRENT_TAU, DT_TRML) - health_prev = None - - # Make sure charging is enabled - charging_disabled = False - os.system('echo "1" > /sys/class/power_supply/battery/charging_enabled') - - params = Params() - - while 1: - health = messaging.recv_sock(health_sock, wait=True) - location = messaging.recv_sock(location_sock) - location = location.gpsLocation if location else None - msg = read_thermal() - - # clear car params when panda gets disconnected - if health is None and health_prev is not None: - params.panda_disconnect() - health_prev = health - - # loggerd is gated based on free space - avail = get_available_percent() / 100.0 - - # thermal message now also includes free space - msg.thermal.freeSpace = avail - charger_off = False - with open("/sys/class/power_supply/battery/capacity") as f: - msg.thermal.batteryPercent = int(f.read()) - with open("/sys/class/power_supply/battery/status") as f: - msg.thermal.batteryStatus = f.read().strip() - with open("/sys/class/power_supply/battery/current_now") as f: - msg.thermal.batteryCurrent = int(f.read()) - with open("/sys/class/power_supply/battery/voltage_now") as f: - msg.thermal.batteryVoltage = int(f.read()) - with open("/sys/class/power_supply/usb/present") as f: - msg.thermal.usbOnline = bool(int(f.read())) - with open("/sys/class/power_supply/battery/charge_type") as f: - charger_status = f.read().strip() - charger_off = (charger_status == "N/A") - current_filter.update(msg.thermal.batteryCurrent / 1e6) - - # TODO: add car battery voltage check - max_cpu_temp = max(msg.thermal.cpu0, msg.thermal.cpu1, - msg.thermal.cpu2, msg.thermal.cpu3) / 10.0 - max_comp_temp = max(max_cpu_temp, msg.thermal.mem / 10., msg.thermal.gpu / 10.) - bat_temp = msg.thermal.bat/1000. - fan_speed = handle_fan(max_cpu_temp, bat_temp, fan_speed) - msg.thermal.fanSpeed = fan_speed - - # thermal logic with hysterisis - if max_cpu_temp > 107. or bat_temp >= 63.: - # onroad not allowed - thermal_status = ThermalStatus.danger - elif max_comp_temp > 92.5 or bat_temp > 60.: # CPU throttling starts around ~90C - # hysteresis between onroad not allowed and engage not allowed - thermal_status = clip(thermal_status, ThermalStatus.red, ThermalStatus.danger) - elif max_cpu_temp > 87.5: - # hysteresis between engage not allowed and uploader not allowed - thermal_status = clip(thermal_status, ThermalStatus.yellow, ThermalStatus.red) - elif max_cpu_temp > 80.0: - # uploader not allowed - thermal_status = ThermalStatus.yellow - elif max_cpu_temp > 75.0: - # hysteresis between uploader not allowed and all good - thermal_status = clip(thermal_status, ThermalStatus.green, ThermalStatus.yellow) - else: - # all good - thermal_status = ThermalStatus.green - - # **** starting logic **** - - # start constellation of processes when the car starts - ignition = health is not None and health.health.started - # print "Ignition from panda: ", ignition - ignition_seen = ignition_seen or ignition - - # add voltage check for ignition - #if not ignition_seen and health is not None and health.health.voltage > 13500: - # ignition = True - - do_uninstall = params.get("DoUninstall") == "1" - accepted_terms = params.get("HasAcceptedTerms") == terms_version - completed_training = params.get("CompletedTrainingVersion") == training_version - - should_start = ignition - - # have we seen a panda? - passive = (params.get("Passive") == "1") - - # with 2% left, we killall, otherwise the phone will take a long time to boot - should_start = should_start and msg.thermal.freeSpace > 0.02 - - # confirm we have completed training and aren't uninstalling - should_start = should_start and accepted_terms and (passive or completed_training) and (not do_uninstall) - - # if any CPU gets above 107 or the battery gets above 63, kill all processes - # controls will warn with CPU above 95 or battery above 60 - if thermal_status >= ThermalStatus.danger: - # TODO: Add a better warning when this is happening - should_start = False - - if should_start: - off_ts = None - if started_ts is None: - params.car_start() - started_ts = sec_since_boot() - started_seen = True - os.system('echo performance > /sys/class/devfreq/soc:qcom,cpubw/governor') - else: - started_ts = None - if off_ts is None: - off_ts = sec_since_boot() - os.system('echo powersave > /sys/class/devfreq/soc:qcom,cpubw/governor') - - # shutdown if the battery gets lower than 3%, it's discharging, we aren't running for - # more than a minute but we were running - if msg.thermal.batteryPercent < BATT_PERC_OFF and msg.thermal.batteryStatus == "Discharging" and \ - started_seen and (sec_since_boot() - off_ts) > 60: - os.system('LD_LIBRARY_PATH="" svc power shutdown') - - charging_disabled = check_car_battery_voltage(should_start, health, charging_disabled, msg, limitBatteryMinMax, batt_min, batt_max) - - msg.thermal.chargingDisabled = charging_disabled - #BB added "and not charging_disabled" below so we don't show red LED when not charging - msg.thermal.chargingError = (current_filter.x > 0.) and (msg.thermal.batteryPercent < 90) and not charging_disabled # if current is > 1A out, then charger might be off - - msg.thermal.started = started_ts is not None - msg.thermal.startedTs = int(1e9*(started_ts or 0)) - - msg.thermal.thermalStatus = thermal_status - thermal_sock.send(msg.to_bytes()) - #print msg - - # report to server once per minute - if (count % int(60. / DT_TRML)) == 0: - cloudlog.event("STATUS_PACKET", - count=count, - health=(health.to_dict() if health else None), - location=(location.to_dict() if location else None), - thermal=msg.to_dict()) - - count += 1 - - -def main(gctx=None): - thermald_thread() - -if __name__ == "__main__": - main() diff --git a/selfdrive/thermald/power_monitoring.py b/selfdrive/thermald/power_monitoring.py new file mode 100644 index 00000000000000..51d5f33dee9ea5 --- /dev/null +++ b/selfdrive/thermald/power_monitoring.py @@ -0,0 +1,192 @@ +import random +import threading +import time +from statistics import mean + +from cereal import log +from common.params import Params, put_nonblocking +from common.realtime import sec_since_boot +from selfdrive.hardware import HARDWARE +from selfdrive.swaglog import cloudlog + +CAR_VOLTAGE_LOW_PASS_K = 0.091 # LPF gain for 5s tau (dt/tau / (dt/tau + 1)) + +# A C2 uses about 1W while idling, and 30h seens like a good shutoff for most cars +# While driving, a battery charges completely in about 30-60 minutes +CAR_BATTERY_CAPACITY_uWh = 30e6 +CAR_CHARGING_RATE_W = 45 + +VBATT_PAUSE_CHARGING = 11.0 +MAX_TIME_OFFROAD_S = 30*3600 + +class PowerMonitoring: + def __init__(self): + self.params = Params() + self.last_measurement_time = None # Used for integration delta + self.last_save_time = 0 # Used for saving current value in a param + self.power_used_uWh = 0 # Integrated power usage in uWh since going into offroad + self.next_pulsed_measurement_time = None + self.car_voltage_mV = 12e3 # Low-passed version of health voltage + self.integration_lock = threading.Lock() + + car_battery_capacity_uWh = self.params.get("CarBatteryCapacity") + if car_battery_capacity_uWh is None: + car_battery_capacity_uWh = 0 + + # Reset capacity if it's low + self.car_battery_capacity_uWh = max((CAR_BATTERY_CAPACITY_uWh / 10), int(car_battery_capacity_uWh)) + + + # Calculation tick + def calculate(self, health): + try: + now = sec_since_boot() + + # If health is None, we're probably not in a car, so we don't care + if health is None or health.health.hwType == log.HealthData.HwType.unknown: + with self.integration_lock: + self.last_measurement_time = None + self.next_pulsed_measurement_time = None + self.power_used_uWh = 0 + return + + # Low-pass battery voltage + self.car_voltage_mV = ((health.health.voltage * CAR_VOLTAGE_LOW_PASS_K) + (self.car_voltage_mV * (1 - CAR_VOLTAGE_LOW_PASS_K))) + + # Cap the car battery power and save it in a param every 10-ish seconds + self.car_battery_capacity_uWh = max(self.car_battery_capacity_uWh, 0) + self.car_battery_capacity_uWh = min(self.car_battery_capacity_uWh, CAR_BATTERY_CAPACITY_uWh) + if now - self.last_save_time >= 10: + put_nonblocking("CarBatteryCapacity", str(int(self.car_battery_capacity_uWh))) + self.last_save_time = now + + # First measurement, set integration time + with self.integration_lock: + if self.last_measurement_time is None: + self.last_measurement_time = now + return + + if (health.health.ignitionLine or health.health.ignitionCan): + # If there is ignition, we integrate the charging rate of the car + with self.integration_lock: + self.power_used_uWh = 0 + integration_time_h = (now - self.last_measurement_time) / 3600 + if integration_time_h < 0: + raise ValueError(f"Negative integration time: {integration_time_h}h") + self.car_battery_capacity_uWh += (CAR_CHARGING_RATE_W * 1e6 * integration_time_h) + self.last_measurement_time = now + else: + # No ignition, we integrate the offroad power used by the device + is_uno = health.health.hwType == log.HealthData.HwType.uno + # Get current power draw somehow + current_power = HARDWARE.get_current_power_draw() + if current_power is not None: + pass + elif HARDWARE.get_battery_status() == 'Discharging': + # If the battery is discharging, we can use this measurement + # On C2: this is low by about 10-15%, probably mostly due to UNO draw not being factored in + current_power = ((HARDWARE.get_battery_voltage() / 1000000) * (HARDWARE.get_battery_current() / 1000000)) + elif (self.next_pulsed_measurement_time is not None) and (self.next_pulsed_measurement_time <= now): + # TODO: Figure out why this is off by a factor of 3/4??? + FUDGE_FACTOR = 1.33 + + # Turn off charging for about 10 sec in a thread that does not get killed on SIGINT, and perform measurement here to avoid blocking thermal + def perform_pulse_measurement(now): + try: + HARDWARE.set_battery_charging(False) + time.sleep(5) + + # Measure for a few sec to get a good average + voltages = [] + currents = [] + for _ in range(6): + voltages.append(HARDWARE.get_battery_voltage()) + currents.append(HARDWARE.get_battery_current()) + time.sleep(1) + current_power = ((mean(voltages) / 1000000) * (mean(currents) / 1000000)) + + self._perform_integration(now, current_power * FUDGE_FACTOR) + + # Enable charging again + HARDWARE.set_battery_charging(True) + except Exception: + cloudlog.exception("Pulsed power measurement failed") + + # Start pulsed measurement and return + threading.Thread(target=perform_pulse_measurement, args=(now,)).start() + self.next_pulsed_measurement_time = None + return + + elif self.next_pulsed_measurement_time is None and not is_uno: + # On a charging EON with black panda, or drawing more than 400mA out of a white/grey one + # Only way to get the power draw is to turn off charging for a few sec and check what the discharging rate is + # We shouldn't do this very often, so make sure it has been some long-ish random time interval + self.next_pulsed_measurement_time = now + random.randint(120, 180) + return + else: + # Do nothing + return + + # Do the integration + self._perform_integration(now, current_power) + except Exception: + cloudlog.exception("Power monitoring calculation failed") + + def _perform_integration(self, t, current_power): + with self.integration_lock: + try: + if self.last_measurement_time: + integration_time_h = (t - self.last_measurement_time) / 3600 + power_used = (current_power * 1000000) * integration_time_h + if power_used < 0: + raise ValueError(f"Negative power used! Integration time: {integration_time_h} h Current Power: {power_used} uWh") + self.power_used_uWh += power_used + self.car_battery_capacity_uWh -= power_used + self.last_measurement_time = t + except Exception: + cloudlog.exception("Integration failed") + + # Get the power usage + def get_power_used(self): + return int(self.power_used_uWh) + + def get_car_battery_capacity(self): + return int(self.car_battery_capacity_uWh) + + # See if we need to disable charging + def should_disable_charging(self, health, offroad_timestamp): + if health is None or offroad_timestamp is None: + return False + + now = sec_since_boot() + disable_charging = False + disable_charging |= (now - offroad_timestamp) > MAX_TIME_OFFROAD_S + disable_charging |= (self.car_voltage_mV < (VBATT_PAUSE_CHARGING * 1e3)) + disable_charging |= (self.car_battery_capacity_uWh <= 0) + disable_charging &= (not health.health.ignitionLine and not health.health.ignitionCan) + disable_charging &= (self.params.get("DisablePowerDown") != b"1") + return disable_charging + + # See if we need to shutdown + def should_shutdown(self, health, offroad_timestamp, started_seen, LEON): + if health is None or offroad_timestamp is None: + return False + + now = sec_since_boot() + panda_charging = (health.health.usbPowerMode != log.HealthData.UsbPowerMode.client) + BATT_PERC_OFF = 10 if LEON else 3 + + should_shutdown = False + # Wait until we have shut down charging before powering down + should_shutdown |= (not panda_charging and self.should_disable_charging(health, offroad_timestamp)) + should_shutdown |= ((HARDWARE.get_battery_capacity() < BATT_PERC_OFF) and (not HARDWARE.get_battery_charging()) and ((now - offroad_timestamp) > 60)) + should_shutdown &= started_seen + return should_shutdown + +## Tesla branch version. +## We control EON charging in thermald, always power EON from Panda: +class PowerMonitoringTesla(PowerMonitoring): + def should_disable_charging(self, health, offroad_timestamp): + return False + def should_shutdown(self, health, offroad_timestamp, started_seen, LEON): + return False diff --git a/selfdrive/thermald/thermald.py b/selfdrive/thermald/thermald.py new file mode 100755 index 00000000000000..5253961c5c7e40 --- /dev/null +++ b/selfdrive/thermald/thermald.py @@ -0,0 +1,474 @@ +#!/usr/bin/env python3 +import datetime +import os +import time +from collections import namedtuple +from typing import Dict, Optional, Tuple + +import psutil +import sys +from smbus2 import SMBus + +import cereal.messaging as messaging +from cereal import log +from common.filter_simple import FirstOrderFilter +from common.numpy_fast import clip, interp +from common.params import Params +from common.realtime import DT_TRML, sec_since_boot +from selfdrive.controls.lib.alertmanager import set_offroad_alert +from selfdrive.hardware import EON, HARDWARE, TICI +from selfdrive.loggerd.config import get_available_percent +from selfdrive.pandad import get_expected_signature +from selfdrive.swaglog import cloudlog +from selfdrive.thermald.power_monitoring import PowerMonitoringTesla +from selfdrive.car.tesla.readconfig import CarSettings +from selfdrive.version import get_git_branch, terms_version, training_version + +ThermalConfig = namedtuple('ThermalConfig', ['cpu', 'gpu', 'mem', 'bat', 'ambient']) + +WEBCAM = os.getenv("WEBCAM") is not None +if WEBCAM and (sys.version_info.major == 3 and sys.version_info.minor == 6): + from backports.datetime_fromisoformat import MonkeyPatch + MonkeyPatch.patch_fromisoformat() + +FW_SIGNATURE = get_expected_signature() + +ThermalStatus = log.ThermalData.ThermalStatus +NetworkType = log.ThermalData.NetworkType +NetworkStrength = log.ThermalData.NetworkStrength +CURRENT_TAU = 15. # 15s time constant +CPU_TEMP_TAU = 5. # 5s time constant +DAYS_NO_CONNECTIVITY_MAX = 70 # do not allow to engage after a week without internet +DAYS_NO_CONNECTIVITY_PROMPT = 64 # send an offroad prompt after 4 days with no internet +DISCONNECT_TIMEOUT = 5. # wait 5 seconds before going offroad after disconnect so you get an alert + +prev_offroad_states: Dict[str, Tuple[bool, Optional[str]]] = {} + +LEON = False +last_eon_fan_val = None + + +def get_thermal_config(): + # (tz, scale) + if EON: + return ThermalConfig(cpu=((5, 7, 10, 12), 10), gpu=((16,), 10), mem=(2, 10), bat=(29, 1000), ambient=(25, 1)) + elif TICI: + return ThermalConfig(cpu=((1, 2, 3, 4, 5, 6, 7, 8), 1000), gpu=((48,49), 1000), mem=(15, 1000), bat=(None, 1), ambient=(70, 1000)) + else: + return ThermalConfig(cpu=((None,), 1), gpu=((None,), 1), mem=(None, 1), bat=(None, 1), ambient=(None, 1)) + + +def read_tz(x): + if x is None: + return 0 + + try: + with open("/sys/devices/virtual/thermal/thermal_zone%d/temp" % x) as f: + return int(f.read()) + except FileNotFoundError: + return 0 + + +def read_thermal(thermal_config): + dat = messaging.new_message('thermal') + dat.thermal.cpu = [read_tz(z) / thermal_config.cpu[1] for z in thermal_config.cpu[0]] + dat.thermal.gpu = [read_tz(z) / thermal_config.gpu[1] for z in thermal_config.gpu[0]] + dat.thermal.mem = read_tz(thermal_config.mem[0]) / thermal_config.mem[1] + dat.thermal.ambient = read_tz(thermal_config.ambient[0]) / thermal_config.ambient[1] + dat.thermal.bat = read_tz(thermal_config.bat[0]) / thermal_config.bat[1] + return dat + + +def setup_eon_fan(): + global LEON + + os.system("echo 2 > /sys/module/dwc3_msm/parameters/otg_switch") + + bus = SMBus(7, force=True) + try: + bus.write_byte_data(0x21, 0x10, 0xf) # mask all interrupts + bus.write_byte_data(0x21, 0x03, 0x1) # set drive current and global interrupt disable + bus.write_byte_data(0x21, 0x02, 0x2) # needed? + bus.write_byte_data(0x21, 0x04, 0x4) # manual override source + except IOError: + print("LEON detected") + LEON = True + bus.close() + + +def set_eon_fan(val): + global LEON, last_eon_fan_val + + if last_eon_fan_val is None or last_eon_fan_val != val: + bus = SMBus(7, force=True) + if LEON: + try: + i = [0x1, 0x3 | 0, 0x3 | 0x08, 0x3 | 0x10][val] + bus.write_i2c_block_data(0x3d, 0, [i]) + except IOError: + # tusb320 + if val == 0: + bus.write_i2c_block_data(0x67, 0xa, [0]) + #bus.write_i2c_block_data(0x67, 0x45, [1<<2]) + else: + #bus.write_i2c_block_data(0x67, 0x45, [0]) + bus.write_i2c_block_data(0x67, 0xa, [0x20]) + bus.write_i2c_block_data(0x67, 0x8, [(val - 1) << 6]) + else: + bus.write_byte_data(0x21, 0x04, 0x2) + bus.write_byte_data(0x21, 0x03, (val*2)+1) + bus.write_byte_data(0x21, 0x04, 0x4) + bus.close() + last_eon_fan_val = val + + +# temp thresholds to control fan speed - high hysteresis +_TEMP_THRS_H = [50., 65., 80., 10000] +# temp thresholds to control fan speed - low hysteresis +_TEMP_THRS_L = [42.5, 57.5, 72.5, 10000] +# fan speed options +_FAN_SPEEDS = [0, 16384, 32768, 65535] +# max fan speed only allowed if battery is hot +_BAT_TEMP_THRESHOLD = 45. +if CarSettings().get_value("hasNoctuaFan"): + # fan speed options + _FAN_SPEEDS = [0, 65535, 65535, 65535] # Noctua fan is super quiet, so it can run on high most of the time. + # max fan speed only allowed if battery is hot + _BAT_TEMP_THERSHOLD = 20. # No need to wait for the battery to get hot, when you have a Notua fan. + +def handle_fan_eon(max_cpu_temp, bat_temp, fan_speed, ignition): + new_speed_h = next(speed for speed, temp_h in zip(_FAN_SPEEDS, _TEMP_THRS_H) if temp_h > max_cpu_temp) + new_speed_l = next(speed for speed, temp_l in zip(_FAN_SPEEDS, _TEMP_THRS_L) if temp_l > max_cpu_temp) + + if new_speed_h > fan_speed: + # update speed if using the high thresholds results in fan speed increment + fan_speed = new_speed_h + elif new_speed_l < fan_speed: + # update speed if using the low thresholds results in fan speed decrement + fan_speed = new_speed_l + + if bat_temp < _BAT_TEMP_THRESHOLD: + # no max fan speed unless battery is hot + fan_speed = min(fan_speed, _FAN_SPEEDS[-2]) + + set_eon_fan(fan_speed // 16384) + + return fan_speed + + +def check_car_battery_voltage(should_start, health, charging_disabled, msg, limitBatteryMinMax, batt_min, batt_max): + + # charging disallowed if: + # - there are health packets from panda, and; + # - 12V battery voltage is too low, and; + # - onroad isn't started + + limitBatteryMin = limitBatteryMinMax and (msg.thermal.batteryPercent < batt_min) + limitBatteryMax = limitBatteryMinMax and (msg.thermal.batteryPercent > batt_max) + #print limitBatteryMinMax,batt_min, batt_max, msg.thermal.batteryPercent + if charging_disabled and (health is None or health.health.voltage > 11800) and (limitBatteryMin or not limitBatteryMinMax): + charging_disabled = False + os.system('echo "1" > /sys/class/power_supply/battery/charging_enabled') + elif (not charging_disabled) and ((health is not None and health.health.voltage < 11500 and not should_start) or limitBatteryMax): + charging_disabled = True + os.system('echo "0" > /sys/class/power_supply/battery/charging_enabled') + + return charging_disabled + +def handle_fan_uno(max_cpu_temp, bat_temp, fan_speed, ignition): + new_speed = int(interp(max_cpu_temp, [40.0, 80.0], [0, 80])) + + if not ignition: + new_speed = min(30, new_speed) + + return new_speed + + +def set_offroad_alert_if_changed(offroad_alert: str, show_alert: bool, extra_text: Optional[str]=None): + if prev_offroad_states.get(offroad_alert, None) == (show_alert, extra_text): + return + prev_offroad_states[offroad_alert] = (show_alert, extra_text) + set_offroad_alert(offroad_alert, show_alert, extra_text) + + +def thermald_thread(): + #BB + # if limitting battery to Min-Max%. edit /data/bb_openpilot.cfg + car_set = CarSettings() + limitBatteryMinMax = car_set.get_value("limitBatteryMinMax") + batt_min = car_set.get_value("limitBattery_Min") + batt_max = car_set.get_value("limitBattery_Max") + + # prevent LEECO from undervoltage + BATT_PERC_OFF = 10 if LEON else 3 + + health_timeout = int(1000 * 2.5 * DT_TRML) # 2.5x the expected health frequency + + # now loop + thermal_sock = messaging.pub_sock('thermal') + health_sock = messaging.sub_sock('health', timeout=health_timeout) + location_sock = messaging.sub_sock('gpsLocation') + + fan_speed = 0 + count = 0 + + startup_conditions = { + "ignition": False, + } + startup_conditions_prev = startup_conditions.copy() + + off_ts = None + started_ts = None + started_seen = False + thermal_status = ThermalStatus.green + usb_power = True + current_branch = get_git_branch() + + network_type = NetworkType.none + network_strength = NetworkStrength.unknown + + current_filter = FirstOrderFilter(0., CURRENT_TAU, DT_TRML) + cpu_temp_filter = FirstOrderFilter(0., CPU_TEMP_TAU, DT_TRML) + health_prev = None + should_start_prev = False + handle_fan = None + is_uno = False + + # Make sure charging is enabled + charging_disabled = False + + params = Params() + pm = PowerMonitoringTesla() + no_panda_cnt = 0 + + thermal_config = get_thermal_config() + + while 1: + health = messaging.recv_sock(health_sock, wait=True) + location = messaging.recv_sock(location_sock) + location = location.gpsLocation if location else None + msg = read_thermal(thermal_config) + + if health is not None: + usb_power = health.health.usbPowerMode != log.HealthData.UsbPowerMode.client + + # If we lose connection to the panda, wait 5 seconds before going offroad + if health.health.hwType == log.HealthData.HwType.unknown: + no_panda_cnt += 1 + if no_panda_cnt > DISCONNECT_TIMEOUT / DT_TRML: + if startup_conditions["ignition"]: + cloudlog.error("Lost panda connection while onroad") + startup_conditions["ignition"] = False + else: + no_panda_cnt = 0 + startup_conditions["ignition"] = health.health.ignitionLine or health.health.ignitionCan + + # Setup fan handler on first connect to panda + if handle_fan is None and health.health.hwType != log.HealthData.HwType.unknown: + is_uno = health.health.hwType == log.HealthData.HwType.uno + + if (not EON) or is_uno: + cloudlog.info("Setting up UNO fan handler") + handle_fan = handle_fan_uno + else: + cloudlog.info("Setting up EON fan handler") + setup_eon_fan() + handle_fan = handle_fan_eon + + # Handle disconnect + if health_prev is not None: + if health.health.hwType == log.HealthData.HwType.unknown and \ + health_prev.health.hwType != log.HealthData.HwType.unknown: + params.panda_disconnect() + health_prev = health + + # get_network_type is an expensive call. update every 10s + if (count % int(10. / DT_TRML)) == 0: + try: + network_type = HARDWARE.get_network_type() + network_strength = HARDWARE.get_network_strength(network_type) + except Exception: + cloudlog.exception("Error getting network status") + + msg.thermal.freeSpace = get_available_percent(default=100.0) / 100.0 + msg.thermal.memUsedPercent = int(round(psutil.virtual_memory().percent)) + msg.thermal.cpuPerc = int(round(psutil.cpu_percent())) + msg.thermal.networkType = network_type + msg.thermal.networkStrength = network_strength + msg.thermal.batteryPercent = HARDWARE.get_battery_capacity() + msg.thermal.batteryStatus = HARDWARE.get_battery_status() + msg.thermal.batteryCurrent = HARDWARE.get_battery_current() + msg.thermal.batteryVoltage = HARDWARE.get_battery_voltage() + msg.thermal.usbOnline = HARDWARE.get_usb_present() + + # Fake battery levels on uno for frame + if (not EON) or is_uno: + msg.thermal.batteryPercent = 100 + msg.thermal.batteryStatus = "Charging" + msg.thermal.bat = 0 + + current_filter.update(msg.thermal.batteryCurrent / 1e6) + + # TODO: add car battery voltage check + max_cpu_temp = cpu_temp_filter.update(max(msg.thermal.cpu)) + max_comp_temp = max(max_cpu_temp, msg.thermal.mem, max(msg.thermal.gpu)) + bat_temp = msg.thermal.bat + + if handle_fan is not None: + fan_speed = handle_fan(max_cpu_temp, bat_temp, fan_speed, startup_conditions["ignition"]) + msg.thermal.fanSpeed = fan_speed + + # If device is offroad we want to cool down before going onroad + # since going onroad increases load and can make temps go over 107 + # We only do this if there is a relay that prevents the car from faulting + is_offroad_for_5_min = (started_ts is None) and ((not started_seen) or (off_ts is None) or (sec_since_boot() - off_ts > 60 * 5)) + if max_cpu_temp > 107. or bat_temp >= 63. or (is_offroad_for_5_min and max_cpu_temp > 70.0): + # onroad not allowed + thermal_status = ThermalStatus.danger + elif max_comp_temp > 96.0 or bat_temp > 60.: + # hysteresis between onroad not allowed and engage not allowed + thermal_status = clip(thermal_status, ThermalStatus.red, ThermalStatus.danger) + elif max_cpu_temp > 94.0: + # hysteresis between engage not allowed and uploader not allowed + thermal_status = clip(thermal_status, ThermalStatus.yellow, ThermalStatus.red) + elif max_cpu_temp > 80.0: + # uploader not allowed + thermal_status = ThermalStatus.yellow + elif max_cpu_temp > 75.0: + # hysteresis between uploader not allowed and all good + thermal_status = clip(thermal_status, ThermalStatus.green, ThermalStatus.yellow) + else: + # all good + thermal_status = ThermalStatus.green + + # **** starting logic **** + + # Check for last update time and display alerts if needed + now = datetime.datetime.utcnow() + + # show invalid date/time alert + startup_conditions["time_valid"] = (now.year > 2020) or (now.year == 2020 and now.month >= 10) + set_offroad_alert_if_changed("Offroad_InvalidTime", (not startup_conditions["time_valid"])) + + # Show update prompt + try: + last_update = datetime.datetime.fromisoformat(params.get("LastUpdateTime", encoding='utf8')) + except (TypeError, ValueError): + last_update = now + dt = now - last_update + + update_failed_count = params.get("UpdateFailedCount") + update_failed_count = 0 if update_failed_count is None else int(update_failed_count) + last_update_exception = params.get("LastUpdateException", encoding='utf8') + + if update_failed_count > 15 and last_update_exception is not None: + if current_branch in ["release2", "dashcam"]: + extra_text = "Ensure the software is correctly installed" + else: + extra_text = last_update_exception + + set_offroad_alert_if_changed("Offroad_ConnectivityNeeded", False) + set_offroad_alert_if_changed("Offroad_ConnectivityNeededPrompt", False) + set_offroad_alert_if_changed("Offroad_UpdateFailed", True, extra_text=extra_text) + elif dt.days > DAYS_NO_CONNECTIVITY_MAX and update_failed_count > 1: + set_offroad_alert_if_changed("Offroad_UpdateFailed", False) + set_offroad_alert_if_changed("Offroad_ConnectivityNeededPrompt", False) + set_offroad_alert_if_changed("Offroad_ConnectivityNeeded", True) + elif dt.days > DAYS_NO_CONNECTIVITY_PROMPT: + remaining_time = str(max(DAYS_NO_CONNECTIVITY_MAX - dt.days, 0)) + set_offroad_alert_if_changed("Offroad_UpdateFailed", False) + set_offroad_alert_if_changed("Offroad_ConnectivityNeeded", False) + set_offroad_alert_if_changed("Offroad_ConnectivityNeededPrompt", True, extra_text=f"{remaining_time} days.") + else: + set_offroad_alert_if_changed("Offroad_UpdateFailed", False) + set_offroad_alert_if_changed("Offroad_ConnectivityNeeded", False) + set_offroad_alert_if_changed("Offroad_ConnectivityNeededPrompt", False) + + startup_conditions["not_uninstalling"] = not params.get("DoUninstall") == b"1" + startup_conditions["accepted_terms"] = params.get("HasAcceptedTerms") == terms_version + + panda_signature = params.get("PandaFirmware") + startup_conditions["fw_version_match"] = (panda_signature is None) or (panda_signature == FW_SIGNATURE) # don't show alert is no panda is connected (None) + set_offroad_alert_if_changed("Offroad_PandaFirmwareMismatch", (not startup_conditions["fw_version_match"])) + + # with 2% left, we killall, otherwise the phone will take a long time to boot + startup_conditions["free_space"] = msg.thermal.freeSpace > 0.02 + startup_conditions["completed_training"] = params.get("CompletedTrainingVersion") == training_version or \ + (current_branch in ['dashcam', 'dashcam-staging']) + startup_conditions["not_driver_view"] = not params.get("IsDriverViewEnabled") == b"1" + startup_conditions["not_taking_snapshot"] = not params.get("IsTakingSnapshot") == b"1" + # if any CPU gets above 107 or the battery gets above 63, kill all processes + # controls will warn with CPU above 95 or battery above 60 + startup_conditions["device_temp_good"] = thermal_status < ThermalStatus.danger + set_offroad_alert_if_changed("Offroad_TemperatureTooHigh", (not startup_conditions["device_temp_good"])) + should_start = all(startup_conditions.values()) + + startup_conditions["hardware_supported"] = health is not None# and health.health.hwType not in [log.HealthData.HwType.whitePanda, + # log.HealthData.HwType.greyPanda] + set_offroad_alert_if_changed("Offroad_HardwareUnsupported", health is not None and not startup_conditions["hardware_supported"]) + + if should_start: + if not should_start_prev: + params.delete("IsOffroad") + + off_ts = None + if started_ts is None: + started_ts = sec_since_boot() + started_seen = True + else: + if startup_conditions["ignition"] and (startup_conditions != startup_conditions_prev): + cloudlog.event("Startup blocked", startup_conditions=startup_conditions) + if should_start_prev or (count == 0): + params.put("IsOffroad", "1") + + started_ts = None + if off_ts is None: + off_ts = sec_since_boot() + + # Offroad power monitoring + pm.calculate(health) + msg.thermal.offroadPowerUsage = pm.get_power_used() + msg.thermal.carBatteryCapacity = max(0, pm.get_car_battery_capacity()) + + #BB have to figure how to disable charging now + charging_disabled = check_car_battery_voltage(should_start, health, charging_disabled, msg, limitBatteryMinMax, batt_min, batt_max) + + # Check if we need to disable charging (handled by boardd) + msg.thermal.chargingDisabled = pm.should_disable_charging(health, off_ts) + + # Check if we need to shut down + if pm.should_shutdown(health, off_ts, started_seen, LEON): + cloudlog.info(f"shutting device down, offroad since {off_ts}") + # TODO: add function for blocking cloudlog instead of sleep + time.sleep(10) + os.system('LD_LIBRARY_PATH="" svc power shutdown') + + msg.thermal.chargingError = current_filter.x > 0. and msg.thermal.batteryPercent < 90 and not charging_disabled # if current is positive, then battery is being discharged + msg.thermal.started = started_ts is not None + msg.thermal.startedTs = int(1e9*(started_ts or 0)) + + msg.thermal.thermalStatus = thermal_status + thermal_sock.send(msg.to_bytes()) + + #Tesla branch commented out: set_offroad_alert_if_changed("Offroad_ChargeDisabled", (not usb_power)) + + should_start_prev = should_start + startup_conditions_prev = startup_conditions.copy() + + # report to server once per minute + if (count % int(60. / DT_TRML)) == 0: + cloudlog.event("STATUS_PACKET", + count=count, + health=(health.to_dict() if health else None), + location=(location.to_dict() if location else None), + thermal=msg.to_dict()) + + count += 1 + + +def main(): + thermald_thread() + + +if __name__ == "__main__": + main() diff --git a/selfdrive/tinklad/airtable_publisher.py b/selfdrive/tinklad/airtable_publisher.py index 0d17224f37dba6..ddf8925594afb7 100644 --- a/selfdrive/tinklad/airtable_publisher.py +++ b/selfdrive/tinklad/airtable_publisher.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# Created by Raf 5/2019 + +import asyncio AIRTABLE_API_KEY = 'keyvqdsl2VIIr9Q2A' AIRTABLE_BASE_ID = 'appht7GB4aJS2A0LD' @@ -34,7 +38,7 @@ class Publisher(): latest_info_dict = None # current info published userRecordId = None - def send_info(self, info, isData= False): + async def send_info(self, info, isData= False): data_dict = None if isData: data_dict = info @@ -42,23 +46,23 @@ def send_info(self, info, isData= False): data_dict = self.__generate_airtable_user_info_dict(info) # Early return if no changes - if self.latest_info_dict != None: + if self.latest_info_dict is not None: print(LOG_PREFIX + "latest_info. data=%s" % (self.latest_info_dict)) if data_dict == self.latest_info_dict: print(LOG_PREFIX + "send_info no update necessary*") return print(LOG_PREFIX + "Sending info. data=%s" % (data_dict)) - if self.userRecordId != None: - self.__update_user(data_dict) + if self.userRecordId is not None: + await self.__update_user(data_dict) - if info.openPilotId != None and info.openPilotId != '': + if (info.openPilotId is not None) and info.openPilotId != '': self.openPilotId = info.openPilotId - response = self.at.get(USERS_TABLE, limit=1, filter_by_formula=("{openPilotId} = '%s'" % (self.openPilotId))) + response = await self.at.get(USERS_TABLE, limit=1, filter_by_formula=("{openPilotId} = '%s'" % (self.openPilotId))) if self.__is_notfound_response(response): # Not found, create: print(LOG_PREFIX + "Creating record for openPilotId='%s'" % (info.openPilotId)) - response = self.at.create(USERS_TABLE, data_dict) + response = await self.at.create(USERS_TABLE, data_dict) if self.__is_error_response(response): raise Exception(response) elif self.__is_error_response(response): #Unsupported error @@ -66,23 +70,22 @@ def send_info(self, info, isData= False): raise Exception(response) else: self.userRecordId = response["records"][0]["id"] - self.__update_user(data_dict) + await self.__update_user(data_dict) self.latest_info_dict = data_dict - print(LOG_PREFIX + "*send_info competed*") + print(LOG_PREFIX + "*send_info completed*") - def send_event(self, event): - if self.openPilotId is None and self.latest_info_dict != None: + async def send_event(self, event): + if self.openPilotId is None and self.latest_info_dict is not None: self.openPilotId = self.latest_info_dict[self.userKeys.openPilotId] event_dict = self.__generate_airtable_user_event_dict(event) print(LOG_PREFIX + "Sending event. data=%s" % (event_dict)) - response = self.at.create(EVENTS_TABLE, event_dict) + response = await self.at.create(EVENTS_TABLE, event_dict) if self.__is_error_response(response): print(LOG_PREFIX + "Error sending airtable event. %s" % (response)) raise Exception(response) - print(LOG_PREFIX + "*send_event competed*") - + print(LOG_PREFIX + "*send_event completed*") def __generate_airtable_user_info_dict(self, info): @@ -100,29 +103,29 @@ def __generate_airtable_user_event_dict(self, event): value = event.value.intValue elif value == self.eventValueTypes.floatValue: value = event.value.floatValue - openPilotId = self.openPilotId if (self.openPilotId != None) else "" + openPilotId = event.openPilotId if (event.openPilotId is not None) else (self.openPilotId if (self.openPilotId is not None) else "") dictionary = event.to_dict() dictionary[self.eventKeys.value] = value dictionary[self.eventKeys.openPilotId] = openPilotId # dictionary.pop("timestamp", None) return dictionary - def __update_user(self, data): + async def __update_user(self, data): print(LOG_PREFIX + "Updating userRecordId='%s'" % (self.userRecordId)) - response = self.at.update(USERS_TABLE, self.userRecordId, data) + response = await self.at.update(USERS_TABLE, self.userRecordId, data) if self.__is_error_response(response): raise Exception(response) def __is_notfound_response(self, response): try: - return response["error"] != None and response["error"]["code"] == 422 + return response["error"] is not None and response["error"]["code"] == 422 except: # pylint: disable=bare-except - count = response["records"].__len__() - return count == 0 + count = response["records"].__len__() + return count == 0 def __is_error_response(self, response): try: - return response["error"] != None + return response["error"] is not None except: # pylint: disable=bare-except return False @@ -176,7 +179,7 @@ def create_payload(data): return {'fields': data} -class Airtable(object): +class Airtable(): def __init__(self, base_id, api_key, dict_class=OrderedDict): """Create a client to connect to an Airtable Base. @@ -193,14 +196,28 @@ def __init__(self, base_id, api_key, dict_class=OrderedDict): self.headers = {'Authorization': 'Bearer %s' % api_key} self._dict_class = dict_class - def __request(self, method, url, params=None, payload=None): + def __perform_request(self, method, url, params, data, headers): + return requests.request( + method, + url, + params=params, + data=data, + headers=headers + ) + + async def __request(self, method, url, params=None, payload=None): if method in ['POST', 'PUT', 'PATCH']: self.headers.update({'Content-type': 'application/json'}) - r = requests.request(method, - posixpath.join(self.base_url, url), - params=params, - data=payload, - headers=self.headers) + loop = asyncio.get_event_loop() + r = await loop.run_in_executor( + None, + self.__perform_request, + method, + posixpath.join(self.base_url, url), + params, + payload, + self.headers + ) if r.status_code == requests.codes.ok: # pylint: disable=no-member return r.json(object_pairs_hook=self._dict_class) else: @@ -272,27 +289,27 @@ def iterate( # pylint: disable=dangerous-default-value else: break - def create(self, table_name, data): # pylint: disable=inconsistent-return-statements + async def create(self, table_name, data): # pylint: disable=inconsistent-return-statements if check_string(table_name): payload = create_payload(data) - return self.__request('POST', table_name, + return await self.__request('POST', table_name, payload=json.dumps(payload)) - def update(self, table_name, record_id, data): # pylint: disable=inconsistent-return-statements + async def update(self, table_name, record_id, data): # pylint: disable=inconsistent-return-statements if check_string(table_name) and check_string(record_id): url = posixpath.join(table_name, record_id) payload = create_payload(data) - return self.__request('PATCH', url, + return await self.__request('PATCH', url, payload=json.dumps(payload)) - def update_all(self, table_name, record_id, data): # pylint: disable=inconsistent-return-statements + async def update_all(self, table_name, record_id, data): # pylint: disable=inconsistent-return-statements if check_string(table_name) and check_string(record_id): url = posixpath.join(table_name, record_id) payload = create_payload(data) - return self.__request('PUT', url, + return await self.__request('PUT', url, payload=json.dumps(payload)) - def delete(self, table_name, record_id): # pylint: disable=inconsistent-return-statements + async def delete(self, table_name, record_id): # pylint: disable=inconsistent-return-statements if check_string(table_name) and check_string(record_id): url = posixpath.join(table_name, record_id) - return self.__request('DELETE', url) + return await self.__request('DELETE', url) diff --git a/selfdrive/tinklad/pqueue.py b/selfdrive/tinklad/pqueue.py index 8856e27fc1e935..de5c241e42931d 100644 --- a/selfdrive/tinklad/pqueue.py +++ b/selfdrive/tinklad/pqueue.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python3 # # https://github.com/balena/python-pqueue @@ -13,10 +13,8 @@ import tempfile import shutil -#python 2.7: -from Queue import Queue as SyncQ -#python 3: -#from queue import Queue as SyncQ + +from queue import Queue as SyncQ def _truncate(fn, length): @@ -75,7 +73,7 @@ def _destroy(self): shutil.rmtree(self.path) os.makedirs(self.path) - def _qsize(self, len=len): # pylint: disable=redefined-builtin + def _qsize(self, len=len): # pylint: disable=redefined-builtin,arguments-differ return self.info['size'] def _put(self, item): diff --git a/selfdrive/tinklad/tinkla_interface.py b/selfdrive/tinklad/tinkla_interface.py index 59efe5861aa16e..cc117bf4a37550 100644 --- a/selfdrive/tinklad/tinkla_interface.py +++ b/selfdrive/tinklad/tinkla_interface.py @@ -1,16 +1,19 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python3 +# Created by Raf 5/2019 from cereal import tinkla import os import zmq import datetime -import tinklad +from selfdrive.tinklad import tinklad +import time ## For helpers: import traceback from selfdrive.car.tesla.readconfig import CarSettings from common.params import Params +LOG_PREFIX = "tinklad client: " tinklaClient = None @@ -20,10 +23,20 @@ def now_iso8601(): class TinklaClient(): sock = None pid = None + lastCanErrorTimestamp = 0 + lastProcessErrorTimestamp = 0 eventCategoryKeys = tinklad.TinklaInterfaceEventCategoryKeys() messageTypeKeys = tinklad.TinklaInterfaceMessageKeys() actions = tinklad.TinklaInterfaceActions() + + # Configurable: + # Note: If throttling, events are dropped + shouldThrottleCanErrorEvents = True + shouldThrottleProcessCommErrorEvents = True + # Setting to every 30min for now, because we're getting a bunch of plan, pathPlan issues. + # Should change to around every 1min in the future when this is resolved + throttlingPeriodInSeconds = (60*30) # One event every `throttlingPeriodInSeconds` def start_client(self): if os.getpid() == self.pid: @@ -38,7 +51,6 @@ def start_client(self): print("Unable to connect to tinklad") self.sock = None - def setUserInfo(self, info): self.start_client() if self.sock is None: @@ -90,44 +102,81 @@ def attemptToSendPendingMessages(self): ## Helpers: - def logCrashStackTraceEvent(self, dongleId = None): - if dongleId is None: - dongleId = self.dongleId + def logCrashStackTraceEvent(self, openPilotId = None): + if openPilotId is None: + openPilotId = self.openPilotId event = tinkla.Interface.Event.new_message( - openPilotId=dongleId, + openPilotId=openPilotId, source="n/a", category=self.eventCategoryKeys.crash, name="crash", ) trace = traceback.format_exc().replace('"', '`').replace("'", '`') - userInfo = "User Handle: %s OpenPilotId: %s" % (self.userHandle, self.dongleId) + userInfo = "User Handle: %s \nOpenPilotId: %s" % (self.userHandle, self.openPilotId) gitInfo = "Git Remote: %s\nBranch: %s\nCommit: %s" % (self.gitRemote, self.gitBranch, self.gitHash) event.value.textValue="%s\n%s\n%s" % (userInfo, gitInfo, trace) self.logUserEvent(event) - def logCANErrorEvent(self, canMessage, additionalInformation, dongleId = None): - if dongleId is None: - dongleId = self.dongleId + def logCANErrorEvent(self, source, canMessage, additionalInformation, openPilotId = None): + if not self.carSettings.shouldLogCanErrors: + return + if self.shouldThrottleCanErrorEvents: + now = time.time() + if now - self.lastCanErrorTimestamp < self.throttlingPeriodInSeconds: + return + self.lastCanErrorTimestamp = now + + if openPilotId is None: + openPilotId = self.openPilotId event = tinkla.Interface.Event.new_message( - openPilotId=dongleId, - source=hex(canMessage), + openPilotId=openPilotId, + source=source, category=self.eventCategoryKeys.canError, name="CAN Error", ) canInfo = "Can Message: {0}".format(hex(canMessage)) - userInfo = "User Handle: %s OpenPilotId: %s" % (self.userHandle, self.dongleId) + userInfo = "User Handle: %s \nOpenPilotId: %s" % (self.userHandle, self.openPilotId) gitInfo = "Git Remote: %s\nBranch: %s\nCommit: %s" % (self.gitRemote, self.gitBranch, self.gitHash) event.value.textValue="%s\n%s\n%s\n%s" % (userInfo, gitInfo, canInfo, additionalInformation) self.logUserEvent(event) + def logProcessCommErrorEvent(self, source, processName, count, eventType, openPilotId = None): + if not self.carSettings.shouldLogProcessCommErrors: + return + if self.shouldThrottleProcessCommErrorEvents: + now = time.time() + if now - self.lastProcessErrorTimestamp < self.throttlingPeriodInSeconds: + return + self.lastProcessErrorTimestamp = now + + if openPilotId is None: + openPilotId = self.openPilotId + event = tinkla.Interface.Event.new_message( + openPilotId=openPilotId, + source=processName, + category=self.eventCategoryKeys.processCommError, + name="Process Comm Error", + ) + additionalInformation = "Process: '%s' \nType: '%s' \nCount: '%d' \nSource: '%s'" % (processName, eventType, count, source) + userInfo = "User Handle: %s \nOpenPilotId: %s" % (self.userHandle, self.openPilotId) + gitInfo = "Git Remote: %s\nBranch: %s\nCommit: %s" % (self.gitRemote, self.gitBranch, self.gitHash) + event.value.textValue="%s\n%s\n%s" % (userInfo, gitInfo, additionalInformation) + self.logUserEvent(event) + def print_msg(self, message): print(message) def __init__(self): - carSettings = CarSettings() - params = Params() - self.dongleId = params.get("DongleId") - self.userHandle = carSettings.userHandle + try: + params = Params() + except OSError: + params = Params(db="./params") + try: + self.carSettings = CarSettings() + except IOError: + self.carSettings = CarSettings(optional_config_file_path="./bb_openpilot.cfg") + self.openPilotId = params.get("DongleId") + self.userHandle = self.carSettings.userHandle self.gitRemote = params.get("GitRemote") self.gitBranch = params.get("GitBranch") self.gitHash = params.get("GitCommit") diff --git a/selfdrive/tinklad/tinklad.py b/selfdrive/tinklad/tinklad.py index d6aa04583c0891..6a046748be2101 100644 --- a/selfdrive/tinklad/tinklad.py +++ b/selfdrive/tinklad/tinklad.py @@ -1,23 +1,25 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python3 +# Created by Raf 5/2019 import zmq import cereal -from pqueue import Queue -from airtable_publisher import Publisher +from selfdrive.tinklad.pqueue import Queue +from selfdrive.tinklad.airtable_publisher import Publisher import requests import time -import os +import os +import asyncio LOG_PREFIX = "tinklad: " # This needs to match tinkla.capnp message keys -class TinklaInterfaceMessageKeys(): +class TinklaInterfaceMessageKeys: userInfo = 'userInfo' event = 'event' action = 'action' # This needs to match tinkla.capnp event category keys -class TinklaInterfaceEventCategoryKeys(): +class TinklaInterfaceEventCategoryKeys: general = 'general' userAction = 'userAction' openPilotAction = 'openPilotAction' @@ -26,7 +28,7 @@ class TinklaInterfaceEventCategoryKeys(): processCommError = 'processCommError' other = 'other' -class TinklaInterfaceActions(): +class TinklaInterfaceActions: attemptToSendPendingMessages = 'attemptToSendPendingMessages' class Cache(): @@ -73,7 +75,7 @@ class TinklaServer(): last_attempt_time = 0 - def attemptToSendPendingMessages(self): + async def attemptToSendPendingMessages(self): # Throttle to once per minute now = time.time() if now - self.last_attempt_time < 60: @@ -85,14 +87,15 @@ def attemptToSendPendingMessages(self): if not self.isOnline(): return print(LOG_PREFIX + "Attempting to send pending messages") - self.publish_pending_userinfo() - self.publish_pending_events() + await self.publish_pending_userinfo() + await self.publish_pending_events() - def setUserInfo(self, info, **kwargs): + async def setUserInfo(self, info, **kwargs): + print(LOG_PREFIX + "Pushing user info to cache") self.userInfoCache.push(info) - self.publish_pending_userinfo() + await self.publish_pending_userinfo() - def publish_pending_userinfo(self): + async def publish_pending_userinfo(self): if self.userInfoCache.count() == 0: return @@ -107,15 +110,17 @@ def publish_pending_userinfo(self): print(LOG_PREFIX + "Sending info to publisher: %s" % (info.to_dict())) self.info = info try: - self.publisher.send_info(info) + await self.publisher.send_info(info) + self.userInfoCache.task_done() except Exception as error: # pylint: disable=broad-except - print(LOG_PREFIX + "Error attempting to publish user info (%s)" % (error)) + self.userInfoCache.push(info) + print(LOG_PREFIX + "Error attempting to publish user info (%s) (Cache has %d elements)" % (error, self.userInfoCache.count())) - def logUserEvent(self, event, **kwargs): + async def logUserEvent(self, event, **kwargs): self.eventCache.push(event) - self.publish_pending_events() + await self.publish_pending_events() - def publish_pending_events(self): + async def publish_pending_events(self): if self.eventCache.count() > 0: print(LOG_PREFIX + 'Cache has %d elements, attempting to publish...' %(self.eventCache.count())) @@ -126,7 +131,7 @@ def publish_pending_events(self): return try: print(LOG_PREFIX + "Sending event to publisher: %s" % (event.to_dict())) - self.publisher.send_event(event) + await self.publisher.send_event(event) self.eventCache.task_done() except AssertionError as error: self.eventCache.push(event) @@ -147,41 +152,52 @@ def isOnline(self): return False return False - def __init__(self): - self.publisher = Publisher() - # set persitent cache for bad network / offline - self.eventCache = Cache("events") - self.userInfoCache = Cache("user_info") - self.publish_pending_userinfo() - self.publish_pending_events() + async def messageLoop(self, sock): messageKeys = TinklaInterfaceMessageKeys() actions = TinklaInterfaceActions() - # Start server: - ctx = zmq.Context() - sock = ctx.socket(zmq.PULL) - sock.bind("ipc:///tmp/tinklad") - context = zmq.Context() - while True: - data = ''.join(sock.recv_multipart()) + data = b''.join(sock.recv_multipart()) + #print(LOG_PREFIX + "Received Data: " + repr(data) + "'") tinklaInterface = cereal.tinkla.Interface.from_bytes(data) if tinklaInterface.version != cereal.tinkla.interfaceVersion: print(LOG_PREFIX + "Unsupported message version: %0.2f (supported version: %0.2f)" % (tinklaInterface.version, cereal.tinkla.interfaceVersion)) continue messageType = tinklaInterface.message.which() + #if messageType != messageKeys.action: + print(LOG_PREFIX + "> Received message. Type: '%s'" % messageType) if messageType == messageKeys.userInfo: info = tinklaInterface.message.userInfo - self.setUserInfo(info) + await self.setUserInfo(info) elif messageType == messageKeys.event: event = tinklaInterface.message.event - self.logUserEvent(event) + await self.logUserEvent(event) elif messageType == messageKeys.action: if tinklaInterface.message.action == actions.attemptToSendPendingMessages: - self.attemptToSendPendingMessages() + await self.attemptToSendPendingMessages() else: print(LOG_PREFIX + "Unsupported action: %s" % tinklaInterface.message.action) + def __init__(self): + loop = asyncio.get_event_loop() + self.publisher = Publisher() + # set persitent cache for bad network / offline + self.eventCache = Cache("events") + self.userInfoCache = Cache("user_info") + tasks = [ + self.publish_pending_userinfo(), + self.publish_pending_events() + ] + loop.run_until_complete(asyncio.wait(tasks)) + + # Start server: + ctx = zmq.Context() + sock = ctx.socket(zmq.PULL) + sock.bind("ipc:///tmp/tinklad") + context = zmq.Context() + + loop.run_until_complete(self.messageLoop(sock=sock)) + def main(gctx=None): print("Starting tinklad service ...") @@ -189,5 +205,4 @@ def main(gctx=None): if __name__ == "__main__": - main() - \ No newline at end of file + main() diff --git a/selfdrive/tinklad/tinkladTestClient.py b/selfdrive/tinklad/tinkladTestClient.py index baebd5151e59d4..6da4a4460890b8 100644 --- a/selfdrive/tinklad/tinkladTestClient.py +++ b/selfdrive/tinklad/tinkladTestClient.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python3 +# Created by Raf 5/2019 from cereal import tinkla from tinkla_interface import TinklaClient @@ -10,10 +11,13 @@ class TinklaTestClient(): def __init__(self): #self.start_server() self.tinklaClient = TinklaClient() + openPilotId = "test_openpilotId" + source = "tinkladTestClient" + userHandle = "test_user_handle" info = tinkla.Interface.UserInfo.new_message( - openPilotId="test_openpilotId", - userHandle="test_user_handle", + openPilotId=openPilotId, + userHandle=userHandle, gitRemote="test_github.com/something", gitBranch="test_gitbranch", gitHash="test_123456" @@ -24,8 +28,8 @@ def __init__(self): print("Info Time Elapsed = %d" % (elapsed_time_us)) event = tinkla.Interface.Event.new_message( - openPilotId="test_openpilotId", - source="unittest", + openPilotId=openPilotId, + source=source, category=self.tinklaClient.eventCategoryKeys.userAction, name="pull_stalk", ) @@ -36,18 +40,34 @@ def __init__(self): print("Event Time Elapsed = %d" % (elapsed_time_us)) carsettings = CarSettings("./bb_openpilot_config.cfg") - userHandle = carsettings.userHandle + carsettings.userHandle = userHandle print("userHandle = '%s'" % (userHandle)) print("attemptToSendPendingMessages") self.tinklaClient.attemptToSendPendingMessages() print("send crash log") - self.tinklaClient.logCrashStackTraceEvent(dongleId="test_openpilotId") + self.tinklaClient.logCrashStackTraceEvent(openPilotId=openPilotId) - print("send can error") - self.tinklaClient.logCANErrorEvent(canMessage=123, additionalInformation="test can error logging", dongleId="test_openpilotId") + print("send user info 2") + info = tinkla.Interface.UserInfo.new_message( + openPilotId=openPilotId, + userHandle=userHandle + "2", + gitRemote="test_github.com/something", + gitBranch="test_gitbranch", + gitHash="test_123456" + ) + self.tinklaClient.setUserInfo(info) + + #print("send can error") + #self.tinklaClient.logCANErrorEvent(source=source, canMessage=1, additionalInformation="test can error logging", openPilotId=openPilotId) + #time.sleep(1) + #self.tinklaClient.logCANErrorEvent(source=source, canMessage=2, additionalInformation="test can error logging", openPilotId=openPilotId) + + #print("send process comm error") + #self.tinklaClient.logProcessCommErrorEvent(source=source, processName="processNameWouldBeHere1", count=10, eventType="Not Alive", openPilotId=openPilotId) + #time.sleep(1) + #self.tinklaClient.logProcessCommErrorEvent(source=source, processName="processNameWouldBeHere2", count=10, eventType="Not Alive", openPilotId=openPilotId) if __name__ == "__main__": TinklaTestClient() - \ No newline at end of file diff --git a/selfdrive/tinklad/tinkladTestClient.sh b/selfdrive/tinklad/tinkladTestClient.sh index 3c26accdcae1eb..32f70dfd4936e3 100755 --- a/selfdrive/tinklad/tinkladTestClient.sh +++ b/selfdrive/tinklad/tinkladTestClient.sh @@ -1 +1 @@ -PYTHONPATH="../../" python2.7 tinkladTestClient.py +PYTHONPATH="../../" python3 tinkladTestClient.py diff --git a/selfdrive/tinklad/tinkladTestServer.sh b/selfdrive/tinklad/tinkladTestServer.sh index 4a7a9d1d071d82..57b366f9ea14a3 100755 --- a/selfdrive/tinklad/tinkladTestServer.sh +++ b/selfdrive/tinklad/tinkladTestServer.sh @@ -1,2 +1,2 @@ mkdir ./tinklad-cache 2> /dev/null -PYTHONPATH="../../" python2.7 tinklad.py +PYTHONPATH="../../" python3 tinklad.py diff --git a/selfdrive/tombstoned.py b/selfdrive/tombstoned.py old mode 100644 new mode 100755 index 3af76818d484cd..8ae0a147b85fe1 --- a/selfdrive/tombstoned.py +++ b/selfdrive/tombstoned.py @@ -1,122 +1,101 @@ +#!/usr/bin/env python3 import os -import re import time -import datetime from raven import Client from raven.transport.http import HTTPTransport -from selfdrive.version import version, dirty +from selfdrive.version import version, origin, branch, dirty from selfdrive.swaglog import cloudlog +MAX_SIZE = 100000 * 10 # Normal size is 40-100k, allow up to 1M + + def get_tombstones(): - DIR_DATA = "/data/tombstones/" - return [(DIR_DATA + fn, int(os.stat(DIR_DATA + fn).st_ctime) ) - for fn in os.listdir(DIR_DATA) if fn.startswith("tombstone")] + """Returns list of (filename, ctime) for all tombstones in /data/tombstones + and apport crashlogs in /var/crash""" + files = [] + for folder in ["/data/tombstones/", "/var/crash/"]: + if os.path.exists(folder): + with os.scandir(folder) as d: + + # Loop over first 1000 directory entries + for _, f in zip(range(1000), d): + if f.name.startswith("tombstone"): + files.append((f.path, int(f.stat().st_ctime))) + elif f.name.endswith(".crash") and f.stat().st_mode == 0o100640: + files.append((f.path, int(f.stat().st_ctime))) + return files -def report_tombstone(fn, client): - mtime = os.path.getmtime(fn) - with open(fn, "r") as f: - dat = f.read() - - # see system/core/debuggerd/tombstone.cpp - parsed = re.match(r"[* ]*\n" - r"(?P
CM Version:[\s\S]*?ABI:.*\n)" - r"(?Ppid:.*\n)" - r"(?Psignal.*\n)?" - r"(?PAbort.*\n)?" - r"(?P\s+x0[\s\S]*?\n)\n" - r"(?:backtrace:\n" - r"(?P[\s\S]*?\n)\n" - r"stack:\n" - r"(?P[\s\S]*?\n)\n" - r")?", dat) - - logtail = re.search(r"--------- tail end of.*\n([\s\S]*?\n)---", dat) - logtail = logtail and logtail.group(1) - - if parsed: - parsedict = parsed.groupdict() - else: - parsedict = {} - thread_line = parsedict.get('thread', '') - thread_parsed = re.match(r'pid: (?P\d+), tid: (?P\d+), name: (?P.*) >>> (?P.*) <<<', thread_line) - if thread_parsed: - thread_parseddict = thread_parsed.groupdict() - else: - thread_parseddict = {} - pid = thread_parseddict.get('pid', '') - tid = thread_parseddict.get('tid', '') - name = thread_parseddict.get('name', 'unknown') - cmd = thread_parseddict.get('cmd', 'unknown') - - signal_line = parsedict.get('signal', '') - signal_parsed = re.match(r'signal (?P.*?), code (?P.*?), fault addr (?P.*)\n', signal_line) - if signal_parsed: - signal_parseddict = signal_parsed.groupdict() +def report_tombstone(fn, client): + f_size = os.path.getsize(fn) + if f_size > MAX_SIZE: + cloudlog.error(f"Tombstone {fn} too big, {f_size}. Skipping...") + return + + with open(fn, encoding='ISO-8859-1') as f: + contents = f.read() + + # Get summary for sentry title + if fn.endswith(".crash"): + lines = contents.split('\n') + message = lines[6] + + status_idx = contents.find('ProcStatus') + if status_idx >= 0: + lines = contents[status_idx:].split('\n') + message += " " + lines[1] else: - signal_parseddict = {} - signal = signal_parseddict.get('signal', 'unknown') - code = signal_parseddict.get('code', 'unknown') - fault_addr = signal_parseddict.get('fault_addr', '') + message = " ".join(contents.split('\n')[5:7]) - abort_line = parsedict.get('abort', '') + # Cut off pid/tid, since that varies per run + name_idx = message.find('name') + if name_idx >= 0: + message = message[name_idx:] - if parsed: - message = 'Process {} ({}) got signal {} code {}'.format(name, cmd, signal, code) - if abort_line: - message += '\n'+abort_line - else: - message = fn+'\n'+dat[:1024] + # Cut off fault addr + fault_idx = message.find(', fault addr') + if fault_idx >= 0: + message = message[:fault_idx] + cloudlog.error({'tombstone': message}) client.captureMessage( message=message, - date=datetime.datetime.utcfromtimestamp(mtime), - data={ - 'logger':'tombstoned', - 'platform':'other', - }, sdk={'name': 'tombstoned', 'version': '0'}, extra={ - 'fault_addr': fault_addr, - 'abort_msg': abort_line, - 'pid': pid, - 'tid': tid, - 'name':'{} ({})'.format(name, cmd), 'tombstone_fn': fn, - 'header': parsedict.get('header'), - 'registers': parsedict.get('registers'), - 'backtrace': parsedict.get('backtrace'), - 'logtail': logtail, - }, - tags={ - 'name':'{} ({})'.format(name, cmd), - 'signal':signal, - 'code':code, - 'fault_addr':fault_addr, + 'tombstone': contents }, ) - cloudlog.error({'tombstone': message}) -def main(gctx=None): +def main(): initial_tombstones = set(get_tombstones()) + tags = { + 'dirty': dirty, + 'origin': origin, + 'branch': branch + } client = Client('https://d3b175702f62402c91ade04d1c547e68:b20d68c813c74f63a7cdf9c4039d8f56@sentry.io/157615', - install_sys_hook=False, transport=HTTPTransport, release=version, tags={'dirty': dirty}, string_max_length=10000) + install_sys_hook=False, transport=HTTPTransport, release=version, tags=tags, string_max_length=10000) client.user_context({'id': os.environ.get('DONGLE_ID')}) while True: now_tombstones = set(get_tombstones()) - for fn, ctime in (now_tombstones - initial_tombstones): - cloudlog.info("reporting new tombstone %s", fn) - report_tombstone(fn, client) + for fn, _ in (now_tombstones - initial_tombstones): + try: + cloudlog.info(f"reporting new tombstone {fn}") + report_tombstone(fn, client) + except Exception: + cloudlog.exception(f"Error reporting tombstone {fn}") initial_tombstones = now_tombstones time.sleep(5) + if __name__ == "__main__": main() diff --git a/selfdrive/ui/.gitignore b/selfdrive/ui/.gitignore deleted file mode 100644 index 2c850c209048d5..00000000000000 --- a/selfdrive/ui/.gitignore +++ /dev/null @@ -1 +0,0 @@ -ui diff --git a/selfdrive/ui/Makefile b/selfdrive/ui/Makefile deleted file mode 100644 index 5b5387aaa96a1f..00000000000000 --- a/selfdrive/ui/Makefile +++ /dev/null @@ -1,119 +0,0 @@ -CC = clang -CXX = clang++ - - -PHONELIBS = ../../phonelibs - -WARN_FLAGS = -Werror=implicit-function-declaration \ - -Werror=incompatible-pointer-types \ - -Werror=int-conversion \ - -Werror=return-type \ - -Werror=format-extra-args - -CFLAGS = -std=gnu11 -fPIC -O2 $(WARN_FLAGS) -CXXFLAGS = -std=c++11 -fPIC -O2 $(WARN_FLAGS) - -ZMQ_LIBS = -l:libczmq.a -l:libzmq.a -lgnustl_shared - -CEREAL_LIBS = -l:libcapn.a -CEREAL_OBJS = ../../cereal/gen/c/log.capnp.o ../../cereal/gen/c/ui.capnp.o - -NANOVG_FLAGS = -I$(PHONELIBS)/nanovg -JSON_FLAGS = -I$(PHONELIBS)/json/src - -OPENCL_FLAGS = -I$(PHONELIBS)/opencl/include -OPENCL_LIBS = -lgsl -lCB -lOpenCL - -OPENGL_LIBS = -lGLESv3 - -OPENSL_LIBS = -lOpenSLES - -UUID_LIBS = -luuid - -FRAMEBUFFER_LIBS = -lutils -lgui -lEGL - -CFLAGS += -DQCOM \ - -I$(PHONELIBS)/android_frameworks_native/include \ - -I$(PHONELIBS)/android_system_core/include \ - -I$(PHONELIBS)/android_hardware_libhardware/include -CXXFLAGS += -DQCOM \ - -I$(PHONELIBS)/android_frameworks_native/include \ - -I$(PHONELIBS)/android_system_core/include \ - -I$(PHONELIBS)/android_hardware_libhardware/include - -ifeq ($(ARCH),aarch64) -CFLAGS += -mcpu=cortex-a57 -CXXFLAGS += -mcpu=cortex-a57 -endif - -OBJS = slplay.o \ - ui.o \ - ../common/glutil.o \ - ../common/visionipc.o \ - ../common/ipc.o \ - ../common/visionimg.o \ - ../common/visionbuf_ion.o \ - ../common/framebuffer.o \ - ../common/params.o \ - ../common/util.o \ - ../common/touch.o \ - ../common/swaglog.o \ - $(PHONELIBS)/nanovg/nanovg.o \ - $(PHONELIBS)/json/src/json.o \ - $(CEREAL_OBJS) - -DEPS := $(OBJS:.o=.d) - -all: ui - -ui: $(OBJS) - @echo "[ LINK ] $@" - $(CXX) -fPIC -o '$@' $^ \ - $(FRAMEBUFFER_LIBS) \ - $(CEREAL_LIBS) \ - $(ZMQ_LIBS) \ - -L/system/vendor/lib64 \ - -lhardware -lui \ - $(OPENGL_LIBS) \ - $(OPENCL_LIBS) \ - ${OPENSL_LIBS} \ - ${UUID_LIBS} \ - -Wl,-rpath=/system/lib64,-rpath=/system/comma/usr/lib \ - -lcutils -lm -llog -lui -ladreno_utils - -slplay.o: slplay.c - @echo "[ CC ] $@" - $(CC) $(CFLAGS) -fPIC \ - -I../ \ - $(OPENSL_LIBS) \ - -c -o '$@' $^ - -%.o: %.cc - @echo "[ CXX ] $@" - $(CXX) $(CXXFLAGS) -MMD \ - -Iinclude -I.. -I../.. \ - $(OPENCL_FLAGS) \ - -I$(PHONELIBS)/android_frameworks_native/include \ - -I$(PHONELIBS)/android_system_core/include \ - -I$(PHONELIBS)/android_hardware_libhardware/include \ - -I$(PHONELIBS)/libgralloc/include \ - -I$(PHONELIBS)/linux/include \ - -c -o '$@' '$<' - -%.o: %.c - @echo "[ CC ] $@" - $(CC) $(CFLAGS) -MMD \ - -Iinclude -I.. -I../.. \ - $(NANOVG_FLAGS) \ - $(ZMQ_FLAGS) \ - $(CEREAL_CFLAGS) \ - $(JSON_FLAGS) \ - $(OPENCL_FLAGS) \ - -I$(PHONELIBS)/linux/include \ - -c -o '$@' '$<' - -.PHONY: clean -clean: - rm -f ui $(OBJS) $(DEPS) - --include $(DEPS) diff --git a/selfdrive/ui/SConscript b/selfdrive/ui/SConscript new file mode 100644 index 00000000000000..ba1968cc448653 --- /dev/null +++ b/selfdrive/ui/SConscript @@ -0,0 +1,101 @@ +import os +Import('env', 'arch', 'real_arch', 'common', 'messaging', 'gpucommon', 'visionipc', 'cereal') + +qt_env = None +if arch in ["x86_64", "Darwin", "larch64"]: + qt_env = env.Clone() + + if arch == "Darwin": + qt_env['QTDIR'] = "/usr/local/opt/qt" + QT_BASE = "/usr/local/opt/qt/" + qt_dirs = [ + QT_BASE + "include/", + QT_BASE + "include/QtWidgets", + QT_BASE + "include/QtGui", + QT_BASE + "include/QtCore", + QT_BASE + "include/QtDBus", + QT_BASE + "include/QtMultimedia", + ] + qt_env["LINKFLAGS"] += ["-F" + QT_BASE + "lib"] + else: + qt_env['QTDIR'] = "/usr" + qt_dirs = [ + f"/usr/include/{real_arch}-linux-gnu/qt5", + f"/usr/include/{real_arch}-linux-gnu/qt5/QtWidgets", + f"/usr/include/{real_arch}-linux-gnu/qt5/QtGui", + f"/usr/include/{real_arch}-linux-gnu/qt5/QtCore", + f"/usr/include/{real_arch}-linux-gnu/qt5/QtDBus", + f"/usr/include/{real_arch}-linux-gnu/qt5/QtMultimedia", + f"/usr/include/{real_arch}-linux-gnu/qt5/QtGui/5.5.1/QtGui", + f"/usr/include/{real_arch}-linux-gnu/qt5/QtGui/5.12.8/QtGui", + ] + + qt_env.Tool('qt') + qt_env['CPPPATH'] += qt_dirs + ["#selfdrive/ui/qt/"] + qt_flags = [ + "-D_REENTRANT", + "-DQT_NO_DEBUG", + "-DQT_WIDGETS_LIB", + "-DQT_GUI_LIB", + "-DQT_CORE_LIB" + ] + qt_env['CXXFLAGS'] += qt_flags + qt_env['LIBPATH'] += ['#selfdrive/ui'] + + +src = ['ui.cc', 'paint.cc', 'sidebar.cc', '#phonelibs/nanovg/nanovg.c', 'bbui.cc', 'tbui.cc', 'dashcam.cc'] +libs = [common, 'zmq', 'czmq', 'capnp', 'kj', 'm', cereal, messaging, gpucommon, visionipc] + + +if qt_env is None: + libs += ['EGL', 'GLESv3', 'gnustl_shared', 'log', 'utils', 'gui', 'hardware', + 'ui', 'CB', 'gsl', 'adreno_utils', 'OpenSLES', 'cutils', 'uuid', 'OpenCL'] + linkflags = ['-Wl,-rpath=/system/lib64,-rpath=/system/comma/usr/lib'] + + src += ["android/ui.cc", "android/sl_sound.cc"] + env.Program('_ui', src, + LINKFLAGS=linkflags, + LIBS=libs) +else: + qt_libs = ["pthread"] + + qt_modules = ["Widgets", "Gui", "Core", "DBus", "Multimedia"] + + if arch == "larch64": + qt_libs += ["GLESv2", "wayland-client"] + elif arch != "Darwin": + qt_libs += ["GL"] + + if arch == "Darwin": + qt_env["FRAMEWORKS"] += [f"Qt{m}" for m in qt_modules] + ["OpenGL"] + else: + qt_libs += [f"Qt5{m}" for m in qt_modules] + + + qt_env.Library("qt_widgets", + ["qt/qt_window.cc", "qt/qt_sound.cc", "qt/widgets/keyboard.cc", "qt/widgets/input_field.cc", + "qt/offroad/wifi.cc", "qt/offroad/wifiManager.cc", "qt/widgets/toggle.cc"], + LIBS=qt_libs) + qt_libs.append("qt_widgets") + + qt_src = ["qt/ui.cc", "qt/window.cc", "qt/home.cc", "qt/offroad/settings.cc", "qt/offroad/onboarding.cc", "qt/widgets/offroad_alerts.cc"] + src + qt_env.Program("_ui", qt_src, LIBS=qt_libs + libs) + + # spinner and text window + qt_env.Program("qt/text", ["qt/text.cc"], LIBS=qt_libs + libs) + qt_env.Program("qt/spinner", ["qt/spinner.cc"], LIBS=qt_libs + libs) + + # build setup, factory resetter, and installer + if "BUILD_SETUP" in os.environ: + qt_env.Program("qt/setup/reset", ["qt/setup/reset.cc"], LIBS=qt_libs) + qt_env.Program("qt/setup/setup", ["qt/setup/setup.cc"], LIBS=qt_libs + ['curl', 'common']) + + installers = [ + ("openpilot", "master"), + ("openpilot_test", "master"), + #("dashcam", "dashcam"), + #("dashcam_test", "dashcam"), + ] + for name, branch in installers: + flags = qt_env["CXXFLAGS"] + [f"-D{branch}"] + qt_env.Program(f"qt/setup/installer_{name}", ["qt/setup/installer.cc"], LIBS=qt_libs, CXXFLAGS=flags) diff --git a/selfdrive/ui/android/sl_sound.cc b/selfdrive/ui/android/sl_sound.cc new file mode 100644 index 00000000000000..52604df937ed63 --- /dev/null +++ b/selfdrive/ui/android/sl_sound.cc @@ -0,0 +1,125 @@ +#include +#include +#include +#include "common/swaglog.h" +#include "common/timing.h" + +#include "android/sl_sound.hpp" + +#define LogOnError(func, msg) \ + if ((func) != SL_RESULT_SUCCESS) { LOGW(msg); } + +#define ReturnOnError(func, msg) \ + if ((func) != SL_RESULT_SUCCESS) { LOGW(msg); return false; } + +struct SLSound::Player { + SLObjectItf player; + SLPlayItf playItf; + std::atomic repeat; +}; + +SLSound::SLSound() { + if (!init()){ + throw std::runtime_error("Failed to initialize sound"); + } +} + +bool SLSound::init() { + SLEngineOption engineOptions[] = {{SL_ENGINEOPTION_THREADSAFE, SL_BOOLEAN_TRUE}}; + const SLInterfaceID ids[1] = {SL_IID_VOLUME}; + const SLboolean req[1] = {SL_BOOLEAN_FALSE}; + SLEngineItf engineInterface = NULL; + ReturnOnError(slCreateEngine(&engine_, 1, engineOptions, 0, NULL, NULL), "Failed to create OpenSL engine"); + ReturnOnError((*engine_)->Realize(engine_, SL_BOOLEAN_FALSE), "Failed to realize OpenSL engine"); + ReturnOnError((*engine_)->GetInterface(engine_, SL_IID_ENGINE, &engineInterface), "Failed to get OpenSL engine interface"); + ReturnOnError((*engineInterface)->CreateOutputMix(engineInterface, &outputMix_, 1, ids, req), "Failed to create output mix"); + ReturnOnError((*outputMix_)->Realize(outputMix_, SL_BOOLEAN_FALSE), "Failed to realize output mix"); + + for (auto &kv : sound_map) { + SLDataLocator_URI locUri = {SL_DATALOCATOR_URI, (SLchar *)kv.second.first}; + SLDataFormat_MIME formatMime = {SL_DATAFORMAT_MIME, NULL, SL_CONTAINERTYPE_UNSPECIFIED}; + SLDataSource audioSrc = {&locUri, &formatMime}; + SLDataLocator_OutputMix outMix = {SL_DATALOCATOR_OUTPUTMIX, outputMix_}; + SLDataSink audioSnk = {&outMix, NULL}; + + SLObjectItf player = NULL; + SLPlayItf playItf = NULL; + ReturnOnError((*engineInterface)->CreateAudioPlayer(engineInterface, &player, &audioSrc, &audioSnk, 0, NULL, NULL), "Failed to create audio player"); + ReturnOnError((*player)->Realize(player, SL_BOOLEAN_FALSE), "Failed to realize audio player"); + ReturnOnError((*player)->GetInterface(player, SL_IID_PLAY, &playItf), "Failed to get player interface"); + ReturnOnError((*playItf)->SetPlayState(playItf, SL_PLAYSTATE_PAUSED), "Failed to initialize playstate to SL_PLAYSTATE_PAUSED"); + + player_[kv.first] = new SLSound::Player{player, playItf}; + } + return true; +} + +void SLAPIENTRY slplay_callback(SLPlayItf playItf, void *context, SLuint32 event) { + SLSound::Player *s = reinterpret_cast(context); + if (event == SL_PLAYEVENT_HEADATEND && s->repeat != 0) { + if (s->repeat > 0) --s->repeat; + (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED); + (*playItf)->SetMarkerPosition(playItf, 0); + (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_PLAYING); + } +} + +bool SLSound::play(AudibleAlert alert) { + if (currentSound_ != AudibleAlert::NONE) { + stop(); + } + + auto player = player_.at(alert); + SLPlayItf playItf = player->playItf; + + int loops = sound_map[alert].second; + player->repeat = loops > 0 ? loops - 1 : loops; + if (player->repeat != 0) { + ReturnOnError((*playItf)->RegisterCallback(playItf, slplay_callback, player), "Failed to register callback"); + ReturnOnError((*playItf)->SetCallbackEventsMask(playItf, SL_PLAYEVENT_HEADATEND), "Failed to set callback event mask"); + } + + // Reset the audio player + ReturnOnError((*playItf)->ClearMarkerPosition(playItf), "Failed to clear marker position"); + uint32_t states[] = {SL_PLAYSTATE_PAUSED, SL_PLAYSTATE_STOPPED, SL_PLAYSTATE_PLAYING}; + for (auto state : states) { + ReturnOnError((*playItf)->SetPlayState(playItf, state), "Failed to set SL_PLAYSTATE_PLAYING"); + } + currentSound_ = alert; + return true; +} + +void SLSound::stop() { + if (currentSound_ != AudibleAlert::NONE) { + auto player = player_.at(currentSound_); + player->repeat = 0; + LogOnError((*(player->playItf))->SetPlayState(player->playItf, SL_PLAYSTATE_PAUSED), "Failed to set SL_PLAYSTATE_PAUSED"); + currentSound_ = AudibleAlert::NONE; + } +} + +void SLSound::setVolume(int volume) { + if (last_volume_ == volume) return; + + double current_time = nanos_since_boot(); + if ((current_time - last_set_volume_time_) > (5 * (1e+9))) { // 5s timeout on updating the volume + char volume_change_cmd[64]; + snprintf(volume_change_cmd, sizeof(volume_change_cmd), "service call audio 3 i32 3 i32 %d i32 1 &", volume); + system(volume_change_cmd); + last_volume_ = volume; + last_set_volume_time_ = current_time; + } +} + +SLSound::~SLSound() { + for (auto &kv : player_) { + (*(kv.second->player))->Destroy(kv.second->player); + delete kv.second; + } + if (outputMix_) { + (*outputMix_)->Destroy(outputMix_); + } + if (engine_) { + (*engine_)->Destroy(engine_); + } +} diff --git a/selfdrive/ui/android/sl_sound.hpp b/selfdrive/ui/android/sl_sound.hpp new file mode 100644 index 00000000000000..7925277b9d80d3 --- /dev/null +++ b/selfdrive/ui/android/sl_sound.hpp @@ -0,0 +1,26 @@ +#pragma once +#include +#include + +#include "sound.hpp" + + +class SLSound : public Sound { +public: + SLSound(); + ~SLSound(); + bool play(AudibleAlert alert); + void stop(); + void setVolume(int volume); + +private: + bool init(); + SLObjectItf engine_ = nullptr; + SLObjectItf outputMix_ = nullptr; + int last_volume_ = 0; + double last_set_volume_time_ = 0.; + AudibleAlert currentSound_ = AudibleAlert::NONE; + struct Player; + std::map player_; + friend void SLAPIENTRY slplay_callback(SLPlayItf playItf, void *context, SLuint32 event); +}; diff --git a/selfdrive/ui/android/spinner/Makefile b/selfdrive/ui/android/spinner/Makefile new file mode 100644 index 00000000000000..7ceea5f61fcdc5 --- /dev/null +++ b/selfdrive/ui/android/spinner/Makefile @@ -0,0 +1,77 @@ +CC = clang +CXX = clang++ + +ROOT_DIR = ../../.. +PHONELIBS = $(ROOT_DIR)/phonelibs +COMMON = $(ROOT)/selfdrive/common + +WARN_FLAGS = -Werror=implicit-function-declaration \ + -Werror=incompatible-pointer-types \ + -Werror=int-conversion \ + -Werror=return-type \ + -Werror=format-extra-args + +CFLAGS = -std=gnu11 -fPIC -O2 $(WARN_FLAGS) +CXXFLAGS = -std=c++1z -fPIC -O2 $(WARN_FLAGS) + +NANOVG_FLAGS = -I$(PHONELIBS)/nanovg + +OPENGL_LIBS = -lGLESv3 + +FRAMEBUFFER_LIBS = -lutils -lgui -lEGL + +OBJS = spinner.o \ + $(COMMON)/framebuffer.o \ + $(COMMON)/util.o \ + $(PHONELIBS)/nanovg/nanovg.o \ + $(COMMON)/spinner.o \ + opensans_semibold.o \ + img_spinner_track.o \ + img_spinner_comma.o + +DEPS := $(OBJS:.o=.d) + +.PHONY: all +all: spinner + +spinner: $(OBJS) + @echo "[ LINK ] $@" + $(CXX) -fPIC -o '$@' $^ \ + -s \ + $(FRAMEBUFFER_LIBS) \ + -L/system/vendor/lib64 \ + $(OPENGL_LIBS) \ + -lm -llog + +$(COMMON)/framebuffer.o: $(COMMON)/framebuffer.cc + @echo "[ CXX ] $@" + $(CXX) $(CXXFLAGS) -MMD \ + -I$(PHONELIBS)/android_frameworks_native/include \ + -I$(PHONELIBS)/android_system_core/include \ + -I$(PHONELIBS)/android_hardware_libhardware/include \ + -c -o '$@' '$<' + +opensans_semibold.o: $(ROOT_DIR)/selfdrive/assets/fonts/opensans_semibold.ttf + @echo "[ bin2o ] $@" + cd '$(dir $<)' && ld -r -b binary '$(notdir $<)' -o '$(abspath $@)' + +img_spinner_track.o: $(ROOT_DIR)/selfdrive/assets/img_spinner_track.png + @echo "[ bin2o ] $@" + cd '$(dir $<)' && ld -r -b binary '$(notdir $<)' -o '$(abspath $@)' + +img_spinner_comma.o: $(ROOT_DIR)/selfdrive/assets/img_spinner_comma.png + @echo "[ bin2o ] $@" + cd '$(dir $<)' && ld -r -b binary '$(notdir $<)' -o '$(abspath $@)' + +%.o: %.c + @echo "[ CC ] $@" + $(CC) $(CFLAGS) -MMD \ + -I../.. \ + $(NANOVG_FLAGS) \ + -c -o '$@' '$<' + +.PHONY: clean +clean: + rm -f spinner $(OBJS) $(DEPS) + +-include $(DEPS) diff --git a/selfdrive/ui/android/spinner/spinner b/selfdrive/ui/android/spinner/spinner new file mode 100755 index 00000000000000..17b6491b142281 Binary files /dev/null and b/selfdrive/ui/android/spinner/spinner differ diff --git a/selfdrive/ui/android/spinner/spinner.c b/selfdrive/ui/android/spinner/spinner.c new file mode 100644 index 00000000000000..33ebf7cd38f3d1 --- /dev/null +++ b/selfdrive/ui/android/spinner/spinner.c @@ -0,0 +1,182 @@ +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "nanovg.h" +#define NANOVG_GLES3_IMPLEMENTATION +#include "nanovg_gl.h" +#include "nanovg_gl_utils.h" + +#include "framebuffer.h" +#include "spinner.h" + +#define SPINTEXT_LENGTH 128 + +// external resources linked in +extern const unsigned char _binary_opensans_semibold_ttf_start[]; +extern const unsigned char _binary_opensans_semibold_ttf_end[]; + +extern const unsigned char _binary_img_spinner_track_png_start[]; +extern const unsigned char _binary_img_spinner_track_png_end[]; + +extern const unsigned char _binary_img_spinner_comma_png_start[]; +extern const unsigned char _binary_img_spinner_comma_png_end[]; + +bool stdin_input_available() { + struct timeval timeout; + timeout.tv_sec = 0; + timeout.tv_usec = 0; + + fd_set fds; + FD_ZERO(&fds); + FD_SET(STDIN_FILENO, &fds); + select(STDIN_FILENO+1, &fds, NULL, NULL, &timeout); + return (FD_ISSET(0, &fds)); +} + +int main(int argc, char** argv) { + + bool draw_progress = false; + float progress_val = 0.0; + + char spintext[SPINTEXT_LENGTH]; + spintext[0] = 0; + + const char* spintext_arg = NULL; + if (argc >= 2) { + strncpy(spintext, argv[1], SPINTEXT_LENGTH); + } + + // spinner + int fb_w, fb_h; + FramebufferState *fb = framebuffer_init("spinner", 0x00001000, false, + &fb_w, &fb_h); + assert(fb); + framebuffer_set_power(fb, HWC_POWER_MODE_NORMAL); + + NVGcontext *vg = nvgCreateGLES3(NVG_ANTIALIAS | NVG_STENCIL_STROKES); + assert(vg); + + int font = nvgCreateFontMem(vg, "Bold", (unsigned char*)_binary_opensans_semibold_ttf_start, _binary_opensans_semibold_ttf_end-_binary_opensans_semibold_ttf_start, 0); + assert(font >= 0); + + int spinner_img = nvgCreateImageMem(vg, 0, (unsigned char*)_binary_img_spinner_track_png_start, _binary_img_spinner_track_png_end - _binary_img_spinner_track_png_start); + assert(spinner_img >= 0); + int spinner_img_s = 360; + int spinner_img_x = ((fb_w/2)-(spinner_img_s/2)); + int spinner_img_y = 260; + int spinner_img_xc = (fb_w/2); + int spinner_img_yc = (fb_h/2)-100; + int spinner_comma_img = nvgCreateImageMem(vg, 0, (unsigned char*)_binary_img_spinner_comma_png_start, _binary_img_spinner_comma_png_end - _binary_img_spinner_comma_png_start); + assert(spinner_comma_img >= 0); + + for (int cnt = 0; ; cnt++) { + // Check stdin for new text + if (stdin_input_available()){ + fgets(spintext, SPINTEXT_LENGTH, stdin); + spintext[strcspn(spintext, "\n")] = 0; + + // Check if number (update progress bar) + size_t len = strlen(spintext); + bool is_number = len > 0; + for (int i = 0; i < len; i++){ + if (!isdigit(spintext[i])){ + is_number = false; + break; + } + } + + if (is_number) { + progress_val = (float)(atoi(spintext)) / 100.0; + progress_val = fmin(1.0, progress_val); + progress_val = fmax(0.0, progress_val); + } + + draw_progress = is_number; + } + + glClearColor(0.1, 0.1, 0.1, 1.0); + glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + nvgBeginFrame(vg, fb_w, fb_h, 1.0f); + + // background + nvgBeginPath(vg); + NVGpaint bg = nvgLinearGradient(vg, fb_w, 0, fb_w, fb_h, + nvgRGBA(0, 0, 0, 175), nvgRGBA(0, 0, 0, 255)); + nvgFillPaint(vg, bg); + nvgRect(vg, 0, 0, fb_w, fb_h); + nvgFill(vg); + + // spin track + nvgSave(vg); + nvgTranslate(vg, spinner_img_xc, spinner_img_yc); + nvgRotate(vg, (3.75*M_PI * cnt/120.0)); + nvgTranslate(vg, -spinner_img_xc, -spinner_img_yc); + NVGpaint spinner_imgPaint = nvgImagePattern(vg, spinner_img_x, spinner_img_y, + spinner_img_s, spinner_img_s, 0, spinner_img, 0.6f); + nvgBeginPath(vg); + nvgFillPaint(vg, spinner_imgPaint); + nvgRect(vg, spinner_img_x, spinner_img_y, spinner_img_s, spinner_img_s); + nvgFill(vg); + nvgRestore(vg); + + // comma + NVGpaint comma_imgPaint = nvgImagePattern(vg, spinner_img_x, spinner_img_y, + spinner_img_s, spinner_img_s, 0, spinner_comma_img, 1.0f); + nvgBeginPath(vg); + nvgFillPaint(vg, comma_imgPaint); + nvgRect(vg, spinner_img_x, spinner_img_y, spinner_img_s, spinner_img_s); + nvgFill(vg); + + if (draw_progress){ + // draw progress bar + int progress_width = 1000; + int progress_x = fb_w/2-progress_width/2; + int progress_y = 775; + int progress_height = 25; + + NVGpaint paint = nvgBoxGradient( + vg, progress_x + 1, progress_y + 1, + progress_width - 2, progress_height, 3, 4, nvgRGB(27, 27, 27), nvgRGB(27, 27, 27)); + nvgBeginPath(vg); + nvgRoundedRect(vg, progress_x, progress_y, progress_width, progress_height, 12); + nvgFillPaint(vg, paint); + nvgFill(vg); + + int bar_pos = ((progress_width - 2) * progress_val); + + paint = nvgBoxGradient( + vg, progress_x, progress_y, + bar_pos+1.5f, progress_height-1, 3, 4, + nvgRGB(245, 245, 245), nvgRGB(105, 105, 105)); + + nvgBeginPath(vg); + nvgRoundedRect( + vg, progress_x+1, progress_y+1, + bar_pos, progress_height-2, 12); + nvgFillPaint(vg, paint); + nvgFill(vg); + } else { + // message + nvgTextAlign(vg, NVG_ALIGN_CENTER | NVG_ALIGN_TOP); + nvgFontSize(vg, 96.0f); + nvgText(vg, fb_w/2, (fb_h*2/3)+24, spintext, NULL); + } + + nvgEndFrame(vg); + framebuffer_swap(fb); + assert(glGetError() == GL_NO_ERROR); + } + + return 0; +} diff --git a/selfdrive/ui/android/text/Makefile b/selfdrive/ui/android/text/Makefile new file mode 100644 index 00000000000000..3401cae0ff7352 --- /dev/null +++ b/selfdrive/ui/android/text/Makefile @@ -0,0 +1,75 @@ +CC = clang +CXX = clang++ + +PHONELIBS = ../../../../phonelibs +COMMON = ../../../common + +WARN_FLAGS = -Werror=implicit-function-declaration \ + -Werror=incompatible-pointer-types \ + -Werror=int-conversion \ + -Werror=return-type \ + -Werror=format-extra-args + +CFLAGS = -std=gnu11 -fPIC -O2 $(WARN_FLAGS) +CXXFLAGS = -std=c++1z -fPIC -O2 $(WARN_FLAGS) + +NANOVG_FLAGS = -I$(PHONELIBS)/nanovg + +OPENGL_LIBS = -lGLESv3 + +FRAMEBUFFER_LIBS = -lutils -lgui -lEGL + +OBJS = text.o \ + $(COMMON)/framebuffer.o \ + $(COMMON)/util.o \ + $(COMMON)/touch.o \ + $(PHONELIBS)/nanovg/nanovg.o \ + opensans_regular.o \ + +DEPS := $(OBJS:.o=.d) + +.PHONY: all +all: text + +text: $(OBJS) + @echo "[ LINK ] $@" + $(CXX) -fPIC -o '$@' $^ \ + -s \ + $(FRAMEBUFFER_LIBS) \ + -L/system/vendor/lib64 \ + $(OPENGL_LIBS) \ + -lm -llog + +opensans_regular.o: ../../../assets/fonts/opensans_regular.ttf + @echo "[ bin2o ] $@" + cd '$(dir $<)' && ld -r -b binary '$(notdir $<)' -o '$(abspath $@)' + +%.o: %.c + mkdir -p $(@D) + @echo "[ CC ] $@" + $(CC) $(CPPFLAGS) $(CFLAGS) \ + -I../../.. \ + -I$(PHONELIBS)/android_frameworks_native/include \ + -I$(PHONELIBS)/android_system_core/include \ + -I$(PHONELIBS)/android_hardware_libhardware/include \ + $(NANOVG_FLAGS) \ + -c -o '$@' '$<' + +%.o: %.cc + mkdir -p $(@D) + @echo "[ CXX ] $@" + $(CXX) $(CPPFLAGS) $(CXXFLAGS) \ + -I../../../selfdrive \ + -I../../../ \ + -I$(PHONELIBS)/android_frameworks_native/include \ + -I$(PHONELIBS)/android_system_core/include \ + -I$(PHONELIBS)/android_hardware_libhardware/include \ + $(NANOVG_FLAGS) \ + -c -o '$@' '$<' + + +.PHONY: clean +clean: + rm -f text $(OBJS) $(DEPS) + +-include $(DEPS) diff --git a/selfdrive/ui/android/text/text b/selfdrive/ui/android/text/text new file mode 100755 index 00000000000000..fc0a176b8a8863 Binary files /dev/null and b/selfdrive/ui/android/text/text differ diff --git a/selfdrive/ui/android/text/text.c b/selfdrive/ui/android/text/text.c new file mode 100644 index 00000000000000..43c43e468937e8 --- /dev/null +++ b/selfdrive/ui/android/text/text.c @@ -0,0 +1,132 @@ +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "nanovg.h" +#define NANOVG_GLES3_IMPLEMENTATION +#include "nanovg_gl.h" +#include "nanovg_gl_utils.h" + +#include "common/framebuffer.h" +#include "common/touch.h" + + +#define COLOR_WHITE nvgRGBA(255, 255, 255, 255) +#define MAX_TEXT_SIZE 2048 + +extern const unsigned char _binary_opensans_regular_ttf_start[]; +extern const unsigned char _binary_opensans_regular_ttf_end[]; + +int main(int argc, char** argv) { + int err; + + // spinner + int fb_w, fb_h; + FramebufferState *fb = framebuffer_init("text", 0x00001000, false, + &fb_w, &fb_h); + assert(fb); + + NVGcontext *vg = nvgCreateGLES3(NVG_ANTIALIAS | NVG_STENCIL_STROKES); + assert(vg); + + int font = nvgCreateFontMem(vg, "regular", (unsigned char*)_binary_opensans_regular_ttf_start, _binary_opensans_regular_ttf_end-_binary_opensans_regular_ttf_start, 0); +assert(font >= 0); + + // Awake + framebuffer_set_power(fb, HWC_POWER_MODE_NORMAL); + set_brightness(255); + + glClearColor(0.1, 0.1, 0.1, 1.0); + glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + nvgBeginFrame(vg, fb_w, fb_h, 1.0f); + + // background + nvgBeginPath(vg); + NVGpaint bg = nvgLinearGradient(vg, fb_w, 0, fb_w, fb_h, + nvgRGBA(0, 0, 0, 175), nvgRGBA(0, 0, 0, 255)); + nvgFillPaint(vg, bg); + nvgRect(vg, 0, 0, fb_w, fb_h); + nvgFill(vg); + + + // Text + nvgFillColor(vg, COLOR_WHITE); + nvgFontSize(vg, 75.0f); + + if (argc >= 2) { + float x = 150; + float y = 150; + + // Copy text + char * text = malloc(MAX_TEXT_SIZE); + strncpy(text, argv[1], MAX_TEXT_SIZE); + + float lineh; + nvgTextMetrics(vg, NULL, NULL, &lineh); + + // nvgTextBox strips leading whitespace. We have to reimplement + char * next = strtok(text, "\n"); + while (next != NULL){ + nvgText(vg, x, y, next, NULL); + y += lineh; + next = strtok(NULL, "\n"); + } + } + + // Button + int b_x = 1500; + int b_y = 800; + int b_w = 300; + int b_h = 150; + + nvgBeginPath(vg); + nvgFillColor(vg, nvgRGBA(8, 8, 8, 255)); + nvgRoundedRect(vg, b_x, b_y, b_w, b_h, 20); + nvgFill(vg); + + nvgFillColor(vg, nvgRGBA(255, 255, 255, 255)); + nvgTextAlign(vg, NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE); + nvgText(vg, b_x+b_w/2, b_y+b_h/2, "Exit", NULL); + + nvgBeginPath(vg); + nvgStrokeColor(vg, nvgRGBA(255, 255, 255, 50)); + nvgStrokeWidth(vg, 5); + nvgRoundedRect(vg, b_x, b_y, b_w, b_h, 20); + nvgStroke(vg); + + // Draw to screen + nvgEndFrame(vg); + framebuffer_swap(fb); + assert(glGetError() == GL_NO_ERROR); + + + // Wait for button + TouchState touch; + touch_init(&touch); + + while (true){ + int touch_x = -1, touch_y = -1; + int res = touch_poll(&touch, &touch_x, &touch_y, 0); + if (res){ + + if (touch_x > b_x && touch_x < b_x + b_w){ + if (touch_y > b_y && touch_y < b_y + b_h){ + return 1; + } + } + } + + usleep(1000000 / 60); + } + + return 0; +} diff --git a/selfdrive/ui/android/ui.cc b/selfdrive/ui/android/ui.cc new file mode 100644 index 00000000000000..c422702e3625db --- /dev/null +++ b/selfdrive/ui/android/ui.cc @@ -0,0 +1,232 @@ +#include +#include +#include +#include + +#include + +#include "common/util.h" +#include "common/utilpp.h" +#include "common/params.h" +#include "common/touch.h" +#include "common/swaglog.h" + +#include "ui.hpp" +#include "paint.hpp" +#include "android/sl_sound.hpp" +#include "bbui.hpp" + +volatile sig_atomic_t do_exit = 0; +static void set_do_exit(int sig) { + do_exit = 1; +} + +static void ui_set_brightness(UIState *s, int brightness) { + static int last_brightness = -1; + if (last_brightness != brightness && (s->awake || brightness == 0)) { + if (set_brightness(brightness)) { + last_brightness = brightness; + } + } +} + +static void handle_display_state(UIState *s, bool user_input) { + + static int awake_timeout = 0; + awake_timeout = std::max(awake_timeout-1, 0); + + // tap detection while display is off + const float accel_samples = 5*UI_FREQ; + static float accel_prev, gyro_prev = 0; + + bool accel_trigger = abs(s->accel_sensor - accel_prev) > 0.2; + bool gyro_trigger = abs(s->gyro_sensor - gyro_prev) > 0.15; + user_input = user_input || (accel_trigger && gyro_trigger); + gyro_prev = s->gyro_sensor; + accel_prev = (accel_prev*(accel_samples - 1) + s->accel_sensor) / accel_samples; + + // determine desired state + bool should_wake = s->awake; + if (user_input || s->ignition || s->started) { + should_wake = true; + awake_timeout = 30*UI_FREQ; + } else if (awake_timeout == 0){ + should_wake = false; + } + + // handle state transition + if (s->awake != should_wake) { + s->awake = should_wake; + int display_mode = s->awake ? HWC_POWER_MODE_NORMAL : HWC_POWER_MODE_OFF; + LOGW("setting display mode %d", display_mode); + framebuffer_set_power(s->fb, display_mode); + + if (s->awake) { + system("service call window 18 i32 1"); + } + } +} + +static void handle_vision_touch(UIState *s, int touch_x, int touch_y) { + if (s->started && (touch_x >= s->scene.viz_rect.x - bdr_s) + && (s->active_app != cereal::UiLayoutState::App::SETTINGS)) { + if (!s->scene.frontview) { + s->scene.uilayout_sidebarcollapsed = !s->scene.uilayout_sidebarcollapsed; + } else { + Params().write_db_value("IsDriverViewEnabled", "0", 1); + } + } +} + +static void handle_sidebar_touch(UIState *s, int touch_x, int touch_y) { + if (!s->scene.uilayout_sidebarcollapsed && touch_x <= sbr_w) { + if (settings_btn.ptInRect(touch_x, touch_y)) { + s->active_app = cereal::UiLayoutState::App::SETTINGS; + } else if (home_btn.ptInRect(touch_x, touch_y)) { + if (s->started) { + s->active_app = cereal::UiLayoutState::App::NONE; + s->scene.uilayout_sidebarcollapsed = true; + } else { + s->active_app = cereal::UiLayoutState::App::HOME; + } + } + } +} + +static void update_offroad_layout_state(UIState *s, PubMaster *pm) { + static int timeout = 0; + static bool prev_collapsed = false; + static cereal::UiLayoutState::App prev_app = cereal::UiLayoutState::App::NONE; + if (timeout > 0) { + timeout--; + } + if (prev_collapsed != s->scene.uilayout_sidebarcollapsed || prev_app != s->active_app || timeout == 0) { + MessageBuilder msg; + auto layout = msg.initEvent().initUiLayoutState(); + layout.setActiveApp(s->active_app); + layout.setSidebarCollapsed(s->scene.uilayout_sidebarcollapsed); + pm->send("offroadLayout", msg); + LOGD("setting active app to %d with sidebar %d", (int)s->active_app, s->scene.uilayout_sidebarcollapsed); + prev_collapsed = s->scene.uilayout_sidebarcollapsed; + prev_app = s->active_app; + timeout = 2 * UI_FREQ; + } +} + +int main(int argc, char* argv[]) { + setpriority(PRIO_PROCESS, 0, -14); + signal(SIGINT, (sighandler_t)set_do_exit); + SLSound sound; + + UIState uistate = {}; + UIState *s = &uistate; + + bb_ui_preinit(s); + ui_init(s); + s->sound = &sound; + + //BB init our UI + bb_ui_init(s); + + s->b.touch_last_width = s->scene.viz_rect.w; + TouchState touch = {0}; + touch_init(&touch); + handle_display_state(s, true); + + PubMaster *pm = new PubMaster({"offroadLayout"}); + + // light sensor scaling and volume params + const bool LEON = util::read_file("/proc/cmdline").find("letv") != std::string::npos; + + float brightness_b = 0, brightness_m = 0; + int result = read_param(&brightness_b, "BRIGHTNESS_B", true); + result += read_param(&brightness_m, "BRIGHTNESS_M", true); + if (result != 0) { + brightness_b = LEON ? 10.0 : 5.0; + brightness_m = LEON ? 2.6 : 1.3; + write_param_float(brightness_b, "BRIGHTNESS_B", true); + write_param_float(brightness_m, "BRIGHTNESS_M", true); + } + float smooth_brightness = brightness_b; + + const int MIN_VOLUME = LEON ? 12 : 9; + const int MAX_VOLUME = LEON ? 15 : 12; + s->sound->setVolume(MIN_VOLUME); + + while (!do_exit) { + if (!s->started) { + usleep(50 * 1000); + } + double u1 = millis_since_boot(); + + ui_update(s); + + // poll for touch events + int touch_x = -1, touch_y = -1; + + s->b.touch_timeout --; + if (s->b.touch_timeout < 0) { + s->b.touch_timeout = 0; + } + + int touched = touch_poll(&touch, &touch_x, &touch_y, 0); + if (touched == 1) { + handle_sidebar_touch(s, touch_x, touch_y); + handle_vision_touch(s, touch_x, touch_y); + s->b.touch_last = true; + s->b.touch_last_x = touch_x; + s->b.touch_last_y = touch_y; + s->b.touch_timeout = touch_timeout; + } + //BB check touch + int dc_touch_x = -1, dc_touch_y = -1; + if ((s->b.touch_last) && (s->b.touch_last_width != s->scene.viz_rect.w)) { + s->b.touch_last_width=s->scene.viz_rect.w; + bb_handle_ui_touch(s,s->b.touch_last_x,s->b.touch_last_y); + dc_touch_x = s->b.touch_last_x; + dc_touch_y = s->b.touch_last_y; + s->b.touch_last = false; + s->b.touch_last_x = 0; + s->b.touch_last_y = 0; + } + + //s->b.touch_last_width = s->scene.viz_rect.w; + //BB Update our cereal polls + bool bb_ui_user_input = bb_ui_poll_update(s); + + // Don't waste resources on drawing in case screen is off + handle_display_state(s, touched == 1 || bb_ui_user_input); + if (!s->awake) { + continue; + } + + // up one notch every 5 m/s + s->sound->setVolume(fmin(MAX_VOLUME, MIN_VOLUME + s->scene.controls_state.getVEgo() / 5)); + + // set brightness + float clipped_brightness = fmin(512, (s->light_sensor*brightness_m) + brightness_b); + smooth_brightness = fmin(255, clipped_brightness * 0.01 + smooth_brightness * 0.99); + ui_set_brightness(s, (int)smooth_brightness); + + update_offroad_layout_state(s, pm); + + ui_draw(s); + if (s->vision_connected) { + nvgScale(s->vg,s->b.scr_scale_x,s->b.scr_scale_y); + dashcam(s, dc_touch_x, dc_touch_y); + bb_ui_draw_UI(s) ; + ui_draw_infobar(s); + } + double u2 = millis_since_boot(); + if (!s->scene.frontview && (u2-u1 > 66)) { + // warn on sub 15fps + LOGW("slow frame(%llu) time: %.2f", (s->sm)->frame, u2-u1); + } + framebuffer_swap(s->fb); + } + + handle_display_state(s, true); + delete s->sm; + delete pm; + return 0; +} diff --git a/selfdrive/ui/bbui.cc b/selfdrive/ui/bbui.cc new file mode 100644 index 00000000000000..cd0f6ba3f79b47 --- /dev/null +++ b/selfdrive/ui/bbui.cc @@ -0,0 +1,1362 @@ +#include +#include "cereal/gen/cpp/ui.capnp.h" + +#if !defined(QCOM) && !defined(QCOM2) +#ifndef __APPLE__ +#define GLFW_INCLUDE_ES2 +#else +#define GLFW_INCLUDE_GLCOREARB +#endif + +#define GLFW_INCLUDE_GLEXT +#include +int linux_abs_x = 0; +int linux_abs_y = 0; +UIState *mouse_ui_state; +#endif +// TODO: this is also hardcoded in common/transformations/camera.py + +#ifdef QCOM2 +const int vwp_w = 2160; +#else +const int vwp_w = 1920; +#endif +const int vwp_h = 1080; +#include "paint.hpp" + +void bb_ui_preinit(UIState *s) { + s->b.scr_w = vwp_w; + s->b.scr_h = vwp_h; + s->b.scr_scale_x = 1.0f; + s->b.scr_scale_y = 1.0f; + s->b.scr_device_factor = 1.0f; + s->b.scr_scissor_offset = 0.0f; +} + +vec3 bb_car_space_to_full_frame(const UIState *s, vec4 car_space_projective) { + const UIScene *scene = &s->scene; + + // We'll call the car space point p. + // First project into normalized image coordinates with the extrinsics matrix. + const vec4 Ep4 = matvecmul(scene->extrinsic_matrix, car_space_projective); + + // The last entry is zero because of how we store E (to use matvecmul). + const vec3 Ep = {{Ep4.v[0], Ep4.v[1], Ep4.v[2]}}; + const vec3 KEp = matvecmul3(intrinsic_matrix, Ep); + + // Project. + const vec3 p_image = {{KEp.v[0] / KEp.v[2], KEp.v[1] / KEp.v[2], 1.}}; + return p_image; +} + +void bb_ui_draw_car( UIState *s) { + // replaces the draw_chevron function when button in mid position + //static void draw_chevron(UIState *s, float x_in, float y_in, float sz, + // NVGcolor fillColor, NVGcolor glowColor) { + if (!s->scene.lead_data[0].getStatus()) { + //no lead car to draw + return; + } + if (!s->b.icShowCar) { + return; + } + const UIScene *scene = &s->scene; + float x_in = scene->lead_data[0].getDRel()+2.7; + float y_in = scene->lead_data[0].getYRel(); + + nvgSave(s->vg); + nvgTranslate(s->vg, 240.0f, 0.0); + nvgTranslate(s->vg, -1440.0f / 2, -1080.0f / 2); + nvgScale(s->vg, 2.0, 2.0); + nvgScale(s->vg, 1440.0f / s->stream.bufs_info.width, 1080.0f / s->stream.bufs_info.height); + + const vec4 p_car_space = (vec4){{x_in, y_in, 0., 1.}}; + const vec3 p_full_frame = bb_car_space_to_full_frame(s, p_car_space); + + float x = p_full_frame.v[0]; + float y = p_full_frame.v[1]; + + // glow + + float bbsz =0.1* 0.1 + 0.6 * (180-x_in*3.3-20)/180; + if (bbsz < 0.1) bbsz = 0.1; + if (bbsz > 0.6) bbsz = 0.6; + float car_alpha = .8; + float car_w = 750 * bbsz; + float car_h = 531 * bbsz; + float car_y = y - car_h/2; + float car_x = x - car_w/2; + + nvgBeginPath(s->vg); + NVGpaint imgPaint = nvgImagePattern(s->vg, car_x, car_y, + car_w, car_h, 0, s->b.img_car, car_alpha); + nvgRect(s->vg, car_x, car_y, car_w, car_h); + nvgFillPaint(s->vg, imgPaint); + nvgFill(s->vg); + nvgRestore(s->vg); +} + +void bb_draw_lane_fill ( UIState *s) { + + const UIScene *scene = &s->scene; + + nvgSave(s->vg); + nvgTranslate(s->vg, 240.0f, 0.0); // rgb-box space + nvgTranslate(s->vg, -1440.0f / 2, -1080.0f / 2); // zoom 2x + nvgScale(s->vg, 2.0, 2.0); + nvgScale(s->vg, 1440.0f / s->stream.bufs_info.width, 1080.0f / s->stream.bufs_info.height); + nvgBeginPath(s->vg); + + //BB let the magic begin + //define variables + float off; + NVGcolor bb_color = nvgRGBA(138, 140, 142,180); + bool started = false; + bool is_ghost = true; + //left lane, first init + auto path = scene->model.getLaneLines()[1]; + auto points = path.getY(); + off = 0.025*scene->model.getLaneLineProbs()[1]; + //draw left + float px = 0; + for (auto point = points.begin(); point != points.end(); point++) { + float py = *point - off; + vec4 p_car_space = (vec4){{px, py, 0., 1.}}; + vec3 p_full_frame = bb_car_space_to_full_frame(s, p_car_space); + float x = p_full_frame.v[0]; + float y = p_full_frame.v[1]; + if (x < 0 || y < 0.) { + px++; + continue; + } + if (!started) { + nvgMoveTo(s->vg, x, y); + started = true; + } else { + nvgLineTo(s->vg, x, y); + } + px++; + } + //right lane, first init + path = scene->model.getLaneLines()[2]; + points = path.getY(); + off = 0.025*scene->model.getLaneLineProbs()[2]; + //draw right + px = points.size(); + for (auto point = points.end(); point != points.begin();) { + --point; + px--; + float py = is_ghost?(*point- - off):(*point + off); + vec4 p_car_space = (vec4){{px, py, 0., 1.}}; + vec3 p_full_frame = bb_car_space_to_full_frame(s, p_car_space); + float x = p_full_frame.v[0]; + float y = p_full_frame.v[1]; + if (x < 0 || y < 0.) { + continue; + } + nvgLineTo(s->vg, x, y); + } + + nvgClosePath(s->vg); + nvgFillColor(s->vg, bb_color); + nvgFill(s->vg); + nvgRestore(s->vg); +} + + + + + +long bb_currentTimeInMilis() { + struct timespec res; + clock_gettime(CLOCK_MONOTONIC, &res); + return (res.tv_sec * 1000) + res.tv_nsec/1000000; +} + +int bb_get_status( UIState *s) { + //BB select status based on main s->status w/ priority over s->b.custom_message_status + int bb_status = -1; + if ((s->status == STATUS_ENGAGED) && (s->b.custom_message_status > STATUS_ENGAGED)) { + bb_status = s->b.custom_message_status; + } else { + bb_status = s->status; + } + return bb_status; +} + +int bb_ui_draw_measure( UIState *s, const char* bb_value, const char* bb_uom, const char* bb_label, + int bb_x, int bb_y, int bb_uom_dx, + NVGcolor bb_valueColor, NVGcolor bb_labelColor, NVGcolor bb_uomColor, + int bb_valueFontSize, int bb_labelFontSize, int bb_uomFontSize ) { + + nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_BASELINE); + int dx = 0; + if (strlen(bb_uom) > 0) { + dx = (int)(bb_uomFontSize*2.5/2); + } + //print value + nvgFontFace(s->vg, "sans-semibold"); + nvgFontSize(s->vg, bb_valueFontSize*2.5); + nvgFillColor(s->vg, bb_valueColor); + nvgText(s->vg, bb_x-dx/2, bb_y+ (int)(bb_valueFontSize*2.5)+5, bb_value, NULL); + //print label + nvgFontFace(s->vg, "sans-regular"); + nvgFontSize(s->vg, bb_labelFontSize*2.5); + nvgFillColor(s->vg, bb_labelColor); + nvgText(s->vg, bb_x, bb_y + (int)(bb_valueFontSize*2.5)+5 + (int)(bb_labelFontSize*2.5)+5, bb_label, NULL); + //print uom + if (strlen(bb_uom) > 0) { + nvgSave(s->vg); + int rx =bb_x + bb_uom_dx + bb_valueFontSize -3; + int ry = bb_y + (int)(bb_valueFontSize*2.5/2)+25; + nvgTranslate(s->vg,rx,ry); + nvgRotate(s->vg, -1.5708); //-90deg in radians + nvgFontFace(s->vg, "sans-regular"); + nvgFontSize(s->vg, (int)(bb_uomFontSize*2.5)); + nvgFillColor(s->vg, bb_uomColor); + nvgText(s->vg, 0, 0, bb_uom, NULL); + nvgRestore(s->vg); + } + return (int)((bb_valueFontSize + bb_labelFontSize)*2.5) + 5; +} + + + +bool bb_handle_ui_touch( UIState *s, int touch_x, int touch_y) { +#if !defined(QCOM) && !defined(QCOM2) + touch_x = (int)(vwp_w * touch_x / 1280); + touch_y = (int)(vwp_h * touch_y / 720); + printf("Linux mouse up at %d, %d ( %d, %d)\n",(int)touch_x, (int)touch_y, linux_abs_x, linux_abs_y); +#endif + for(int i=0; i<6; i++) { + if (s->b.btns_r[i] > 0) { + if ((abs(touch_x - s->b.btns_x[i]) < s->b.btns_r[i]) && (abs(touch_y - s->b.btns_y[i]) < s->b.btns_r[i])) { + //found it; change the status + if (s->b.btns_status[i] > 0) { + s->b.btns_status[i] = 0; + } else { + s->b.btns_status[i] = 1; + } + //now let's send the cereal + + ::capnp::MallocMessageBuilder message; + cereal::UIButtonStatus::Builder btn = message.initRoot(); + + btn.setBtnId(i); + btn.setBtnStatus(s->b.btns_status[i]); + + kj::Array words = messageToFlatArray(message); + kj::ArrayPtr bytes = words.asBytes(); + + s->b.uiButtonStatus_sock->send((char *)(bytes.begin()), bytes.size()); + + return true; + } + } + } + return false; +}; + +#if !defined(QCOM) && !defined(QCOM2) +void bb_mouse_event_handler(GLFWwindow* window, int button, int action, int mods) { + if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_RELEASE) { + + double xpos, ypos; + glfwGetCursorPos(window, &xpos, &ypos); + int w_width,w_height; + glfwGetWindowSize(window, &linux_abs_x, &linux_abs_y); + bb_handle_ui_touch(mouse_ui_state,(int) xpos, (int)ypos); + } +} +#endif + + +int bb_get_button_status(UIState *s, char *btn_name) { + int ret_status = -1; + for (int i = 0; i< 6; i++) { + if (strcmp(s->b.btns[i].btn_name,btn_name)==0) { + ret_status = s->b.btns_status[i]; + } + } + return ret_status; +} + +void bb_draw_button( UIState *s, int btn_id) { + const UIScene *scene = &s->scene; + + const Rect &viz_rect = s->scene.viz_rect; + const int box_y = viz_rect.y; + + int viz_button_x = 0; + int viz_button_y = (box_y + (bdr_s*1.5)) + 20; + int viz_button_w = 140; + int viz_button_h = 140; + + char *btn_text, *btn_text2; + + int delta_x = viz_button_w * 1.1; + int delta_y = 0; + int dx1 = 200; + int dx2 = 190; + int dy = 0; + + if (s->b.tri_state_switch ==2) { + delta_y = delta_x; + delta_x = 0; + dx1 = 20; + dx2 = 160; + dy = 200; + } + + if (btn_id >2) { + viz_button_x = scene->viz_rect.x + scene->viz_rect.w - (bdr_s*2) -dx2; + viz_button_x -= (6-btn_id) * delta_x ; + viz_button_y += (btn_id-3) * delta_y + dy; + + } else { + viz_button_x = scene->viz_rect.x + (bdr_s*2) + dx1; + viz_button_x += (btn_id) * delta_x; + viz_button_y += btn_id * delta_y + dy; + } + + + btn_text = s->b.btns[btn_id].btn_label; + btn_text2 = s->b.btns[btn_id].btn_label2; + + if (strcmp(btn_text,"")==0) { + s->b.btns_r[btn_id] = 0; + } else { + s->b.btns_r[btn_id]= (int)((viz_button_w + viz_button_h)/4); + } + s->b.btns_x[btn_id]=viz_button_x + s->b.btns_r[btn_id]; + s->b.btns_y[btn_id]=viz_button_y + s->b.btns_r[btn_id]; + if (s->b.btns_r[btn_id] == 0) { + return; + } + + nvgBeginPath(s->vg); + nvgRoundedRect(s->vg, viz_button_x, viz_button_y, viz_button_w, viz_button_h, 80); + nvgStrokeWidth(s->vg, 12); + + + if (s->b.btns_status[btn_id] ==0) { + //disabled - red + nvgStrokeColor(s->vg, nvgRGBA(255, 0, 0, 200)); + if (strcmp(btn_text2,"")==0) { + btn_text2 = (char *)"Off"; + } + } else + if (s->b.btns_status[btn_id] ==1) { + //enabled - white + nvgStrokeColor(s->vg, nvgRGBA(255,255,255,200)); + nvgStrokeWidth(s->vg, 4); + if (strcmp(btn_text2,"")==0) { + btn_text2 = (char *)"Ready"; + } + } else + if (s->b.btns_status[btn_id] ==2) { + //active - green + nvgStrokeColor(s->vg, nvgRGBA(28, 204,98,200)); + if (strcmp(btn_text2,"")==0) { + btn_text2 = (char *)"Active"; + } + } else + if (s->b.btns_status[btn_id] ==9) { + //available - thin white + nvgStrokeColor(s->vg, nvgRGBA(200,200,200,40)); + nvgStrokeWidth(s->vg, 4); + if (strcmp(btn_text2,"")==0) { + btn_text2 = (char *)""; + } + } else { + //others - orange + nvgStrokeColor(s->vg, nvgRGBA(255, 188, 3, 200)); + if (strcmp(btn_text2,"")==0) { + btn_text2 = (char *)"Alert"; + } + } + + nvgStroke(s->vg); + + nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_BASELINE); + nvgFontFace(s->vg, "sans-regular"); + nvgFontSize(s->vg, 14*2.5); + nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 200)); + nvgText(s->vg, viz_button_x+viz_button_w/2, viz_button_y + 112, btn_text2, NULL); + + nvgFontFace(s->vg, "sans-semibold"); + nvgFontSize(s->vg, 28*2.5); + nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); + nvgText(s->vg, viz_button_x+viz_button_w/2, viz_button_y + 85,btn_text, NULL); +} + +void bb_draw_buttons( UIState *s) { + for (int i = 0; i < 6; i++) { + bb_draw_button(s,i); + } +} + +void ui_draw_vision_alert_b(UIState *s); +void bb_ui_draw_custom_alert( UIState *s) { + if ((strlen(s->b.custom_message) > 0) && (s->scene.alert_text1.length()==0)){ + if ((!((bb_get_button_status(s,(char *)"msg") == 0) && (s->b.custom_message_status<=3))) && (s->vision_connected == true)) { + s->scene.alert_size = cereal::ControlsState::AlertSize::MID; + s->scene.alert_text1 = s->b.custom_message; + ui_draw_vision_alert_b(s); + } + } +} + +void bb_ui_draw_measures_left( UIState *s, int bb_x, int bb_y, int bb_w ) { + int bb_rx = bb_x + (int)(bb_w/2); + int bb_ry = bb_y; + int bb_h = 5; + NVGcolor lab_color = nvgRGBA(255, 255, 255, 200); + NVGcolor uom_color = nvgRGBA(255, 255, 255, 200); + int value_fontSize=30; + int label_fontSize=15; + int uom_fontSize = 15; + int bb_uom_dx = (int)(bb_w /2 - uom_fontSize*2.5) ; + + //add CPU temperature + if (true) { + char val_str[16]; + char uom_str[6]; + NVGcolor val_color = nvgRGBA(255, 255, 255, 200); + if((int)(s->b.maxCpuTemp/10) > 80) { + val_color = nvgRGBA(255, 188, 3, 200); + } + if((int)(s->b.maxCpuTemp/10) > 92) { + val_color = nvgRGBA(255, 0, 0, 200); + } + // temp is alway in C * 10 + if (s->is_metric) { + snprintf(val_str, sizeof(val_str), "%d C", (int)(s->b.maxCpuTemp/10)); + } else { + snprintf(val_str, sizeof(val_str), "%d F", (int)(32+9*(s->b.maxCpuTemp/10)/5)); + } + snprintf(uom_str, sizeof(uom_str), ""); + bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "CPU TEMP", + bb_rx, bb_ry, bb_uom_dx, + val_color, lab_color, uom_color, + value_fontSize, label_fontSize, uom_fontSize ); + bb_ry = bb_y + bb_h; + } + + //add battery temperature + if (true) { + char val_str[16]; + char uom_str[6]; + NVGcolor val_color = nvgRGBA(255, 255, 255, 200); + if((int)(s->b.maxBatTemp/1000) > 40) { + val_color = nvgRGBA(255, 188, 3, 200); + } + if((int)(s->b.maxBatTemp/1000) > 50) { + val_color = nvgRGBA(255, 0, 0, 200); + } + // temp is alway in C * 1000 + if (s->is_metric) { + snprintf(val_str, sizeof(val_str), "%d C", (int)(s->b.maxBatTemp/1000)); + } else { + snprintf(val_str, sizeof(val_str), "%d F", (int)(32+9*(s->b.maxBatTemp/1000)/5)); + } + snprintf(uom_str, sizeof(uom_str), ""); + bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "BAT TEMP", + bb_rx, bb_ry, bb_uom_dx, + val_color, lab_color, uom_color, + value_fontSize, label_fontSize, uom_fontSize ); + bb_ry = bb_y + bb_h; + } + + //add grey panda GPS accuracy + if (true) { + char val_str[16]; + char uom_str[3]; + NVGcolor val_color = nvgRGBA(255, 255, 255, 200); + //show red/orange if gps accuracy is high + if(s->b.gpsAccuracy > 0.59) { + val_color = nvgRGBA(255, 188, 3, 200); + } + if(s->b.gpsAccuracy > 0.8) { + val_color = nvgRGBA(255, 0, 0, 200); + } + + + // gps accuracy is always in meters + if (true) { + snprintf(val_str, sizeof(val_str), "%d", (int)(s->b.gpsAccuracy*100.0)); + } else { + snprintf(val_str, sizeof(val_str), "%.1f", s->b.gpsAccuracy * 3.28084 * 12); + } + if (true) { + snprintf(uom_str, sizeof(uom_str), "cm");; + } else { + snprintf(uom_str, sizeof(uom_str), "in"); + } + bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "GPS PREC", + bb_rx, bb_ry, bb_uom_dx, + val_color, lab_color, uom_color, + value_fontSize, label_fontSize, uom_fontSize ); + bb_ry = bb_y + bb_h; + } + //add free space - from bthaler1 + if (true) { + char val_str[16]; + char uom_str[3]; + NVGcolor val_color = nvgRGBA(255, 255, 255, 200); + + //show red/orange if free space is low + if(s->b.freeSpace < 0.4) { + val_color = nvgRGBA(255, 188, 3, 200); + } + if(s->b.freeSpace < 0.2) { + val_color = nvgRGBA(255, 0, 0, 200); + } + + snprintf(val_str, sizeof(val_str), "%.1f", s->b.freeSpace* 100); + snprintf(uom_str, sizeof(uom_str), "%%"); + + bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "FREE", + bb_rx, bb_ry, bb_uom_dx, + val_color, lab_color, uom_color, + value_fontSize, label_fontSize, uom_fontSize ); + bb_ry = bb_y + bb_h; + } + //finally draw the frame + bb_h += 20; + nvgBeginPath(s->vg); + nvgRoundedRect(s->vg, bb_x, bb_y, bb_w, bb_h, 20); + nvgStrokeColor(s->vg, nvgRGBA(255,255,255,80)); + nvgStrokeWidth(s->vg, 6); + nvgStroke(s->vg); +} + +void bb_ui_draw_measures_left2( UIState *s, int bb_x, int bb_y, int bb_w ) { + int bb_rx = bb_x + (int)(bb_w/2); + int bb_ry = bb_y; + int bb_h = 5; + NVGcolor lab_color = nvgRGBA(255, 255, 255, 200); + NVGcolor uom_color = nvgRGBA(255, 255, 255, 200); + int value_fontSize=30; + int label_fontSize=15; + int uom_fontSize = 15; + int bb_uom_dx = (int)(bb_w /2 - uom_fontSize*2.5) ; + + //add CPU temperature + if (true) { + char val_str[16]; + char uom_str[6]; + NVGcolor val_color = nvgRGBA(255, 255, 255, 200); + if((int)(s->b.maxCpuTemp/10) > 80) { + val_color = nvgRGBA(255, 188, 3, 200); + } + if((int)(s->b.maxCpuTemp/10) > 92) { + val_color = nvgRGBA(255, 0, 0, 200); + } + // temp is alway in C * 10 + if (s->is_metric) { + snprintf(val_str, sizeof(val_str), "%d C", (int)(s->b.maxCpuTemp/10)); + } else { + snprintf(val_str, sizeof(val_str), "%d F", (int)(32+9*(s->b.maxCpuTemp/10)/5)); + } + snprintf(uom_str, sizeof(uom_str), ""); + bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "CPU TEMP", + bb_rx, bb_ry, bb_uom_dx, + val_color, lab_color, uom_color, + value_fontSize, label_fontSize, uom_fontSize ); + bb_ry = bb_y + bb_h; + } + + //add battery temperature + if (true) { + char val_str[16]; + char uom_str[6]; + NVGcolor val_color = nvgRGBA(255, 255, 255, 200); + if((int)(s->b.maxBatTemp/1000) > 40) { + val_color = nvgRGBA(255, 188, 3, 200); + } + if((int)(s->b.maxBatTemp/1000) > 50) { + val_color = nvgRGBA(255, 0, 0, 200); + } + // temp is alway in C * 1000 + if (s->is_metric) { + snprintf(val_str, sizeof(val_str), "%d C", (int)(s->b.maxBatTemp/1000)); + } else { + snprintf(val_str, sizeof(val_str), "%d F", (int)(32+9*(s->b.maxBatTemp/1000)/5)); + } + snprintf(uom_str, sizeof(uom_str), ""); + bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "BAT TEMP", + bb_rx, bb_ry, bb_uom_dx, + val_color, lab_color, uom_color, + value_fontSize, label_fontSize, uom_fontSize ); + bb_ry = bb_y + bb_h; + } + + //add battery level (%) + if (true) { + char val_str[16]; + char uom_str[3]; + NVGcolor val_color = nvgRGBA(255, 255, 255, 200); + + //show red/orange if free space is low + if(s->b.batteryPercent < 40) { + val_color = nvgRGBA(255, 188, 3, 200); + } + if(s->b.batteryPercent < 20) { + val_color = nvgRGBA(255, 0, 0, 200); + } + + snprintf(val_str, sizeof(val_str), "%d", s->b.batteryPercent); + snprintf(uom_str, sizeof(uom_str), "%%"); + + bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "BAT LOAD", + bb_rx, bb_ry, bb_uom_dx, + val_color, lab_color, uom_color, + value_fontSize, label_fontSize, uom_fontSize ); + bb_ry = bb_y + bb_h; + } + + //add charger status + if (true) { + char val_str[16]; + char uom_str[3]; + NVGcolor val_color = nvgRGBA(255, 255, 255, 200); + //show orange if charger is off + if(!s->b.chargingEnabled) { + val_color = nvgRGBA(255, 188, 3, 200); + } + // gps accuracy is always in meters + if (s->b.chargingEnabled) { + snprintf(val_str, sizeof(val_str), "ON"); + } else { + snprintf(val_str, sizeof(val_str), "OFF"); + } + snprintf(uom_str, sizeof(uom_str), " "); + bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "CHARGER", + bb_rx, bb_ry, bb_uom_dx, + val_color, lab_color, uom_color, + value_fontSize, label_fontSize, uom_fontSize ); + bb_ry = bb_y + bb_h; + } + + //finally draw the frame + bb_h += 20; + nvgBeginPath(s->vg); + nvgRoundedRect(s->vg, bb_x, bb_y, bb_w, bb_h, 20); + nvgStrokeColor(s->vg, nvgRGBA(255,255,255,80)); + nvgStrokeWidth(s->vg, 6); + nvgStroke(s->vg); +} + + +void bb_ui_draw_measures_right( UIState *s, int bb_x, int bb_y, int bb_w ) { + const UIScene *scene = &s->scene; + int bb_rx = bb_x + (int)(bb_w/2); + int bb_ry = bb_y; + int bb_h = 5; + NVGcolor lab_color = nvgRGBA(255, 255, 255, 200); + NVGcolor uom_color = nvgRGBA(255, 255, 255, 200); + int value_fontSize=30; + int label_fontSize=15; + int uom_fontSize = 15; + int bb_uom_dx = (int)(bb_w /2 - uom_fontSize*2.5) ; + + //add visual radar relative distance + if (true) { + char val_str[16]; + char uom_str[6]; + NVGcolor val_color = nvgRGBA(255, 255, 255, 200); + if (scene->lead_data[0].getStatus()) { + //show RED if less than 5 meters + //show orange if less than 15 meters + if((int)(scene->lead_data[0].getDRel()) < 15) { + val_color = nvgRGBA(255, 188, 3, 200); + } + if((int)(scene->lead_data[0].getDRel()) < 5) { + val_color = nvgRGBA(255, 0, 0, 200); + } + // lead car relative distance is always in meters + if (s->is_metric) { + snprintf(val_str, sizeof(val_str), "%d", (int)scene->lead_data[0].getDRel()); + } else { + snprintf(val_str, sizeof(val_str), "%d", (int)(scene->lead_data[0].getDRel() * 3.28084)); + } + } else { + snprintf(val_str, sizeof(val_str), "-"); + } + if (s->is_metric) { + snprintf(uom_str, sizeof(uom_str), "m "); + } else { + snprintf(uom_str, sizeof(uom_str), "ft"); + } + bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "REL DIST", + bb_rx, bb_ry, bb_uom_dx, + val_color, lab_color, uom_color, + value_fontSize, label_fontSize, uom_fontSize ); + bb_ry = bb_y + bb_h; + } + + //add visual radar relative speed + if (true) { + char val_str[16]; + char uom_str[6]; + NVGcolor val_color = nvgRGBA(255, 255, 255, 200); + if (scene->lead_data[0].getStatus()) { + //show Orange if negative speed (approaching) + //show Orange if negative speed faster than 5mph (approaching fast) + if((int)(scene->lead_data[0].getVRel()) < 0) { + val_color = nvgRGBA(255, 188, 3, 200); + } + if((int)(scene->lead_data[0].getVRel()) < -5) { + val_color = nvgRGBA(255, 0, 0, 200); + } + // lead car relative speed is always in meters + if (s->is_metric) { + snprintf(val_str, sizeof(val_str), "%d", (int)(scene->lead_data[0].getVRel() * 3.6 + 0.5)); + } else { + snprintf(val_str, sizeof(val_str), "%d", (int)(scene->lead_data[0].getVRel() * 2.2374144 + 0.5)); + } + } else { + snprintf(val_str, sizeof(val_str), "-"); + } + if (s->is_metric) { + snprintf(uom_str, sizeof(uom_str), "km/h");; + } else { + snprintf(uom_str, sizeof(uom_str), "mph"); + } + bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "REL SPD", + bb_rx, bb_ry, bb_uom_dx, + val_color, lab_color, uom_color, + value_fontSize, label_fontSize, uom_fontSize ); + bb_ry = bb_y + bb_h; + } + + //add steering angle + if (true) { + char val_str[16]; + char uom_str[6]; + NVGcolor val_color = nvgRGBA(255, 255, 255, 200); + //show Orange if more than 6 degrees + //show red if more than 12 degrees + if(((int)(s->b.angleSteers) < -6) || ((int)(s->b.angleSteers) > 6)) { + val_color = nvgRGBA(255, 188, 3, 200); + } + if(((int)(s->b.angleSteers) < -12) || ((int)(s->b.angleSteers) > 12)) { + val_color = nvgRGBA(255, 0, 0, 200); + } + // steering is in degrees + snprintf(val_str, sizeof(val_str), "%.1f",(s->b.angleSteers)); + + snprintf(uom_str, sizeof(uom_str), "deg"); + bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "STEER", + bb_rx, bb_ry, bb_uom_dx, + val_color, lab_color, uom_color, + value_fontSize, label_fontSize, uom_fontSize ); + bb_ry = bb_y + bb_h; + } + + //add desired steering angle + if (true) { + char val_str[16]; + char uom_str[6]; + NVGcolor val_color = nvgRGBA(255, 255, 255, 200); + //show Orange if more than 6 degrees + //show red if more than 12 degrees + if(((int)(s->b.angleSteersDes) < -6) || ((int)(s->b.angleSteersDes) > 6)) { + val_color = nvgRGBA(255, 188, 3, 200); + } + if(((int)(s->b.angleSteersDes) < -12) || ((int)(s->b.angleSteersDes) > 12)) { + val_color = nvgRGBA(255, 0, 0, 200); + } + // steering is in degrees + snprintf(val_str, sizeof(val_str), "%.1f",(s->b.angleSteersDes)); + + snprintf(uom_str, sizeof(uom_str), "deg"); + bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "DES STEER", + bb_rx, bb_ry, bb_uom_dx, + val_color, lab_color, uom_color, + value_fontSize, label_fontSize, uom_fontSize ); + bb_ry = bb_y + bb_h; + } + + + //finally draw the frame + bb_h += 20; + nvgBeginPath(s->vg); + nvgRoundedRect(s->vg, bb_x, bb_y, bb_w, bb_h, 20); + nvgStrokeColor(s->vg, nvgRGBA(255,255,255,80)); + nvgStrokeWidth(s->vg, 6); + nvgStroke(s->vg); +} + +void bb_ui_draw_measures_right2( UIState *s, int bb_x, int bb_y, int bb_w ) { + int bb_rx = bb_x + (int)(bb_w/2); + int bb_ry = bb_y; + int bb_h = 5; + NVGcolor lab_color = nvgRGBA(255, 255, 255, 200); + NVGcolor uom_color = nvgRGBA(255, 255, 255, 200); + int value_fontSize=30; + int label_fontSize=15; + int uom_fontSize = 15; + int bb_uom_dx = (int)(bb_w /2 - uom_fontSize*2.5) ; + + //Fan speed + if (true) { + char val_str[16]; + char uom_str[6]; + NVGcolor val_color = nvgRGBA(255, 255, 255, 200); + //show RED if at max + //show orange if lower than 16000 + if (s->b.fanSpeed == 0) { + snprintf(val_str, sizeof(val_str), "OFF"); + } else { + if((int)(s->b.fanSpeed) < 12000) { + val_color = nvgRGBA(255, 188, 3, 200); + s->b.fanSpeed = 12000; + } + if((int)(s->b.fanSpeed) > 65000) { + val_color = nvgRGBA(255, 0, 0, 200); + } + snprintf(val_str, sizeof(val_str), "%d", (int)(s->b.fanSpeed * 4500.0 /65535.0)); + } + snprintf(uom_str, sizeof(uom_str), "RPM"); + bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "FAN SPEED", + bb_rx, bb_ry, bb_uom_dx, + val_color, lab_color, uom_color, + value_fontSize, label_fontSize, uom_fontSize ); + bb_ry = bb_y + bb_h; + } + + //add grey panda GPS accuracy + if (true) { + char val_str[16]; + char uom_str[3]; + NVGcolor val_color = nvgRGBA(255, 255, 255, 200); + //show red/orange if gps accuracy is high + if(s->b.gpsAccuracy > 0.59) { + val_color = nvgRGBA(255, 188, 3, 200); + } + if(s->b.gpsAccuracy > 0.8) { + val_color = nvgRGBA(255, 0, 0, 200); + } + + + // gps accuracy is always in meters + if (true) { + snprintf(val_str, sizeof(val_str), "%d", (int)(s->b.gpsAccuracy*100.0)); + } else { + snprintf(val_str, sizeof(val_str), "%.1f", s->b.gpsAccuracy * 3.28084 * 12); + } + if (true) { + snprintf(uom_str, sizeof(uom_str), "cm");; + } else { + snprintf(uom_str, sizeof(uom_str), "in"); + } + bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "GPS PREC", + bb_rx, bb_ry, bb_uom_dx, + val_color, lab_color, uom_color, + value_fontSize, label_fontSize, uom_fontSize ); + bb_ry = bb_y + bb_h; + } + + //add steering angle + if (true) { + char val_str[16]; + char uom_str[6]; + NVGcolor val_color = nvgRGBA(255, 255, 255, 200); + //show Orange if more than 6 degrees + //show red if more than 12 degrees + if(((int)(s->b.angleSteers) < -6) || ((int)(s->b.angleSteers) > 6)) { + val_color = nvgRGBA(255, 188, 3, 200); + } + if(((int)(s->b.angleSteers) < -12) || ((int)(s->b.angleSteers) > 12)) { + val_color = nvgRGBA(255, 0, 0, 200); + } + // steering is in degrees + snprintf(val_str, sizeof(val_str), "%.1f",(s->b.angleSteers)); + + snprintf(uom_str, sizeof(uom_str), "deg"); + bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "STEER", + bb_rx, bb_ry, bb_uom_dx, + val_color, lab_color, uom_color, + value_fontSize, label_fontSize, uom_fontSize ); + bb_ry = bb_y + bb_h; + } + + //add desired steering angle + if (true) { + char val_str[16]; + char uom_str[6]; + NVGcolor val_color = nvgRGBA(255, 255, 255, 200); + //show Orange if more than 6 degrees + //show red if more than 12 degrees + if(((int)(s->b.angleSteersDes) < -6) || ((int)(s->b.angleSteersDes) > 6)) { + val_color = nvgRGBA(255, 188, 3, 200); + } + if(((int)(s->b.angleSteersDes) < -12) || ((int)(s->b.angleSteersDes) > 12)) { + val_color = nvgRGBA(255, 0, 0, 200); + } + // steering is in degrees + snprintf(val_str, sizeof(val_str), "%.1f",(s->b.angleSteersDes)); + + snprintf(uom_str, sizeof(uom_str), "deg"); + bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "DES STEER", + bb_rx, bb_ry, bb_uom_dx, + val_color, lab_color, uom_color, + value_fontSize, label_fontSize, uom_fontSize ); + bb_ry = bb_y + bb_h; + } + + + //finally draw the frame + bb_h += 20; + nvgBeginPath(s->vg); + nvgRoundedRect(s->vg, bb_x, bb_y, bb_w, bb_h, 20); + nvgStrokeColor(s->vg, nvgRGBA(255,255,255,80)); + nvgStrokeWidth(s->vg, 6); + nvgStroke(s->vg); +} + +//draw grid from wiki +void ui_draw_vision_grid( UIState *s) { + const UIScene *scene = &s->scene; + bool is_cruise_set = false;//(s->scene.v_cruise != 0 && s->scene.v_cruise != 255); + if (!is_cruise_set) { + const int grid_spacing = 30; + + const Rect &viz_rect = s->scene.viz_rect; + const int box_y = viz_rect.y; + const int box_h = viz_rect.h; + int ui_viz_rx = scene->viz_rect.x; + int ui_viz_rw = scene->viz_rect.w; + + nvgSave(s->vg); + + // path coords are worked out in rgb-box space + nvgTranslate(s->vg, 240.0f, 0.0); + + // zooom in 2x + nvgTranslate(s->vg, -1440.0f / 2, -1080.0f / 2); + nvgScale(s->vg, 2.0, 2.0); + + nvgScale(s->vg, 1440.0f / s->stream.bufs_info.width, 1080.0f / s->stream.bufs_info.height); + + nvgBeginPath(s->vg); + nvgStrokeColor(s->vg, nvgRGBA(255,255,255,128)); + nvgStrokeWidth(s->vg, 1); + + for (int i=box_y; i < box_h; i+=grid_spacing) { + nvgMoveTo(s->vg, ui_viz_rx, i); + //nvgLineTo(s->vg, ui_viz_rx, i); + nvgLineTo(s->vg, ((ui_viz_rw + ui_viz_rx) / 2)+ 10, i); + } + + for (int i=ui_viz_rx + 12; i <= ui_viz_rw; i+=grid_spacing) { + nvgMoveTo(s->vg, i, 0); + nvgLineTo(s->vg, i, 1000); + } + nvgStroke(s->vg); + nvgRestore(s->vg); + } +} + +void bb_ui_draw_logo( UIState *s) { + if ((s->status != STATUS_DISENGAGED)) { //&& (s->status != STATUS_STOPPED)) { //(s->status != STATUS_DISENGAGED) {// + return; + } + if (!s->b.icShowLogo) { + return; + } + int rduration = 8000; + int logot = (bb_currentTimeInMilis() % rduration); + int logoi = s->b.img_logo; + if ((logot > (int)(rduration/4)) && (logot < (int)(3*rduration/4))) { + logoi = s->b.img_logo2; + } + if (logot < (int)(rduration/2)) { + logot = logot - (int)(rduration/4); + } else { + logot = logot - (int)(3*rduration/4); + } + float logop = fabs(4.0*logot/rduration); + const UIScene *scene = &s->scene; + const int ui_viz_rx = scene->viz_rect.x; + const int ui_viz_rw = scene->viz_rect.w; + const int viz_event_w = (int)(820 * logop); + const int viz_event_h = 820; + const int viz_event_x = (ui_viz_rx + (ui_viz_rw - viz_event_w - bdr_s*2)/2); + const int viz_event_y = 200; + // bool is_engageable = scene->controls_state.getEngageable(); + float viz_event_alpha = 1.0f; + nvgBeginPath(s->vg); + NVGpaint imgPaint = nvgImagePattern(s->vg, viz_event_x, viz_event_y, + viz_event_w, viz_event_h, 0, logoi, viz_event_alpha); + nvgRect(s->vg, viz_event_x, viz_event_y, (int)viz_event_w, viz_event_h); + nvgFillPaint(s->vg, imgPaint); + nvgFill(s->vg); +} + +void bb_ui_draw_gyro(UIState *s) { + //draw the gyro data + const UIScene *scene = &s->scene; + const float prc = 0.6; + const int sc_h = 820; + const int sc_w = scene->viz_rect.w; + const int sc_x = bdr_s + scene->viz_rect.x; + const int sc_y = 100; + const int sc_cx = (int)(sc_x + sc_w /2); + const int sc_cy = (int)(sc_y + sc_h/2); + const int l_w = (int)(sc_w * prc / 2); + + const int p_w = (int)((sc_cx - l_w - sc_x)*prc); + const int p_x = (int)(bdr_s +(sc_cx - l_w - p_w)/2); + const int p_max_h = (int)(sc_h * prc /2); + + nvgBeginPath(s->vg); + //white for the base line + nvgStrokeColor(s->vg, nvgRGBA(255,255,255,200)); + nvgStrokeWidth(s->vg, 4); + nvgMoveTo(s->vg, sc_cx - l_w, sc_cy); + nvgLineTo(s->vg, sc_cx +l_w, sc_cy); + nvgStroke(s->vg); + + //compute angle vs horizontal axis based on roll + const float r_ang_rad = -s->b.accRoll; + const float p_ang_rad = -s->b.accPitch; + + //roll + //acc roll - green + nvgSave(s->vg); + nvgTranslate(s->vg, sc_cx, sc_cy); + nvgRotate(s->vg, r_ang_rad); + nvgBeginPath(s->vg); + //green for the real horizontal line based on ACC + nvgStrokeColor(s->vg, nvgRGBA(28, 204,98,200)); + nvgStrokeWidth(s->vg, 4); + nvgMoveTo(s->vg, -l_w, 0); + nvgLineTo(s->vg, +l_w, 0); + nvgStroke(s->vg); + nvgRestore(s->vg); + //mag roll - yellow + nvgSave(s->vg); + nvgTranslate(s->vg, sc_cx, sc_cy); + nvgRotate(s->vg, -s->b.magRoll); + nvgBeginPath(s->vg); + //yellow for the real horizontal line based on MAG + nvgStrokeColor(s->vg, nvgRGBA(255, 255,0,200)); + nvgStrokeWidth(s->vg, 4); + nvgMoveTo(s->vg, -l_w, 0); + nvgLineTo(s->vg, +l_w, 0); + nvgStroke(s->vg); + nvgRestore(s->vg); + //gyro roll - red + nvgSave(s->vg); + nvgTranslate(s->vg, sc_cx, sc_cy); + nvgRotate(s->vg, -s->b.gyroRoll); + nvgBeginPath(s->vg); + //red for the real horizontal line based on GYRO + nvgStrokeColor(s->vg, nvgRGBA(255, 0,0,200)); + nvgStrokeWidth(s->vg, 4); + nvgMoveTo(s->vg, -l_w, 0); + nvgLineTo(s->vg, +l_w, 0); + nvgStroke(s->vg); + nvgRestore(s->vg); + + //pitch + const int p_y = sc_cy; + //double height to accentuate change + const int p_h = (int)(p_max_h * sin(p_ang_rad) ); + nvgBeginPath(s->vg); + //fill with red + nvgFillColor(s->vg, nvgRGBA(255, 0, 0, 200)); + nvgStrokeColor(s->vg, nvgRGBA(255, 0, 0, 200)); + nvgRect(s->vg, p_x, p_y, p_w, p_h); + nvgFill(s->vg); + nvgStroke(s->vg); + //draw middle line white + nvgBeginPath(s->vg); + nvgStrokeColor(s->vg, nvgRGBA(255,255,255,200)); + nvgStrokeWidth(s->vg, 4); + nvgMoveTo(s->vg, p_x,p_y); + nvgLineTo(s->vg, p_x + p_w, p_y); + nvgStroke(s->vg); + //draw horizon with green + nvgBeginPath(s->vg); + nvgStrokeColor(s->vg, nvgRGBA(28, 204,98,200)); + nvgMoveTo(s->vg, p_x,p_y+p_h); + nvgLineTo(s->vg, p_x + p_w, p_y+p_h); + nvgStroke(s->vg); +} + +/// returns true on user input +bool bb_ui_read_triState_switch( UIState *s) { + //get 3-state switch position + // int tri_state_fd; + // char buffer[10]; + if (bb_currentTimeInMilis() - s->b.tri_state_switch_last_read > 2000) { + //tri_stated_fd = open ("/sys/devices/virtual/switch/tri-state-key/state", O_RDONLY); + //if we can't open then switch should be considered in the middle, nothing done + /* if (tri_state_fd == -1) { + s->b.tri_state_switch = 3; + } else { + read (tri_state_fd, &buffer, 10); + s->b.tri_state_switch = buffer[0] -48; + close(tri_state_fd); + s->b.tri_state_switch_last_read = bb_currentTimeInMilis(); + }*/ + s->b.tri_state_switch_last_read = bb_currentTimeInMilis(); + s->b.tri_state_switch = 3; + if (strcmp(s->b.btns[2].btn_label2,"OP")==0) { + s->b.tri_state_switch = 1; + } + if (strcmp(s->b.btns[2].btn_label2,"MIN")==0) { + s->b.tri_state_switch = 2; + } + if (strcmp(s->b.btns[2].btn_label2,"OFF")==0) { + s->b.tri_state_switch = 3; + } + if (strcmp(s->b.btns[2].btn_label2,"GYRO")==0) { + s->b.tri_state_switch = 4; + } + int i = bb_get_button_status(s,(char *)"dsp"); + s->b.keepEonOff = (i==9); + return true; + } + return false; +} + +void bb_ui_draw_UI( UIState *s) { + + const UIScene *scene = &s->scene; + const Rect &viz_rect = s->scene.viz_rect; + const int box_y = viz_rect.y; + + if (s->b.tri_state_switch == 1) { + + const int bb_dml_w = 180; + const int bb_dml_x = (scene->viz_rect.x + (bdr_s*2)); + const int bb_dml_y = (box_y + (bdr_s*1.5))+220; + + const int bb_dmr_w = 180; + const int bb_dmr_x = scene->viz_rect.x + scene->viz_rect.w - bb_dmr_w - (bdr_s*2) ; + const int bb_dmr_y = (box_y + (bdr_s*1.5))+220; + bb_ui_draw_measures_left(s,bb_dml_x, bb_dml_y, bb_dml_w ); + bb_ui_draw_measures_right(s,bb_dmr_x, bb_dmr_y, bb_dmr_w ); + bb_draw_buttons(s); + bb_ui_draw_custom_alert(s); + bb_ui_draw_logo(s); + } + if (s->b.tri_state_switch ==2) { + // const UIScene *scene = &s->scene; + // const int bb_dml_w = 180; + // const int bb_dml_x = (scene->viz_rect.x + (bdr_s*2)); + // const int bb_dml_y = (box_y + (bdr_s*1.5))+220; + + // const int bb_dmr_w = 180; + // const int bb_dmr_x = scene->viz_rect.x + scene->viz_rect.w - bb_dmr_w - (bdr_s*2) ; + // const int bb_dmr_y = (box_y + (bdr_s*1.5))+220; + bb_draw_buttons(s); + bb_ui_draw_custom_alert(s); + bb_ui_draw_logo(s); + } + if (s->b.tri_state_switch ==3) { + //we now use the state 3 for minimalistic data alerts + const UIScene *scene = &s->scene; + const int bb_dml_w = 180; + const int bb_dml_x = (scene->viz_rect.x + (bdr_s*2)); + const int bb_dml_y = (box_y + (bdr_s*1.5))+220; + + const int bb_dmr_w = 180; + const int bb_dmr_x = scene->viz_rect.x + scene->viz_rect.w - bb_dmr_w - (bdr_s*2) ; + const int bb_dmr_y = (box_y + (bdr_s*1.5))+220; + bb_ui_draw_measures_left2(s,bb_dml_x, bb_dml_y, bb_dml_w ); + bb_ui_draw_measures_right2(s,bb_dmr_x, bb_dmr_y, bb_dmr_w ); + bb_draw_buttons(s); + bb_ui_draw_custom_alert(s); + } + if (s->b.tri_state_switch ==4) { + //we use the state 4 for gyro info + // const UIScene *scene = &s->scene; + // const int bb_dml_w = 180; + // const int bb_dml_x = (scene->viz_rect.x + (bdr_s*2)); + // const int bb_dml_y = (box_y + (bdr_s*1.5))+220; + + // const int bb_dmr_w = 180; + // const int bb_dmr_x = scene->viz_rect.x + scene->viz_rect.w - bb_dmr_w - (bdr_s*2) ; + // const int bb_dmr_y = (box_y + (bdr_s*1.5))+220; + bb_draw_buttons(s); + bb_ui_draw_custom_alert(s); + bb_ui_draw_gyro(s); + } +} + + + +void bb_ui_init(UIState *s) { + + //BB INIT + s->b.shouldDrawFrame = true; + s->status = STATUS_DISENGAGED; + strcpy(s->b.car_model,"Tesla"); + strcpy(s->b.car_folder,"tesla"); + s->b.tri_state_switch = -1; + s->b.tri_state_switch_last_read = 0; + s->b.touch_last = false; + s->b.touch_last_x = 0; + s->b.touch_last_y =0; + s->b.touch_last_width = s->scene.viz_rect.w; + + s->b.ctx = Context::create(); + + //BB Define CAPNP sock + s->b.uiButtonInfo_sock = SubSocket::create(s->b.ctx, "uiButtonInfo"); //zsock_new_sub(">tcp://127.0.0.1:8201", ""); + s->b.uiCustomAlert_sock = SubSocket::create(s->b.ctx, "uiCustomAlert"); //zsock_new_sub(">tcp://127.0.0.1:8202", ""); + s->b.uiSetCar_sock = SubSocket::create(s->b.ctx, "uiSetCar"); //zsock_new_sub(">tcp://127.0.0.1:8203", ""); + s->b.uiPlaySound_sock = SubSocket::create(s->b.ctx, "uiPlaySound"); //zsock_new_sub(">tcp://127.0.0.1:8205", ""); + s->b.uiButtonStatus_sock = PubSocket::create(s->b.ctx, "uiButtonStatus"); //zsock_new_pub("@tcp://127.0.0.1:8204"); + s->b.gps_sock = SubSocket::create(s->b.ctx, "gpsLocationExternal"); //zsock_new_sub(">tcp://127.0.0.1:8032",""); + s->b.uiGyroInfo_sock = SubSocket::create(s->b.ctx, "uiGyroInfo"); //zsock_new_sub(">tcp://127.0.0.1:8207", ""); + s->b.poller = Poller::create({ + s->b.uiButtonInfo_sock, + s->b.uiCustomAlert_sock, + s->b.uiSetCar_sock, + s->b.uiPlaySound_sock, + s->b.gps_sock, + s->b.uiGyroInfo_sock + }); + + //BB Load Images + s->b.img_logo = nvgCreateImage(s->vg, "../assets/img_spinner_comma.png", 1); + s->b.img_logo2 = nvgCreateImage(s->vg, "../assets/img_spinner_comma2.png", 1); + s->b.img_car = nvgCreateImage(s->vg, "../assets/img_car_tesla.png", 1); + + s->b.icShowCar = true; + s->b.icShowLogo = true; +} + +// void bb_ui_play_sound( UIState *s, int sound) { +// char* snd_command; +// int bts = bb_get_button_status(s,"sound"); +// if ((bts > 0) || (bts == -1)) { +// asprintf(&snd_command, "python /data/openpilot/selfdrive/car/modules/snd/playsound.py %d &", sound); +// system(snd_command); +// } +// } + +void bb_ui_set_car( UIState *s, char *model, char *folder) { + strcpy(s->b.car_model,model); + strcpy(s->b.car_folder, folder); +} + +bool bb_ui_poll_update(UIState* s) { + //check tri-state switch + bool user_input = bb_ui_read_triState_switch(s); + + while (true) { + auto polls = s->b.poller->poll(0); + if (polls.size() == 0) + return user_input; + + for (auto sock : polls) { + auto msg = sock->receive(); + if (!msg) { + continue; + } + auto amsg = kj::heapArray((msg->getSize() / sizeof(capnp::word)) + 1); + memcpy(amsg.begin(), msg->getData(), msg->getSize()); + capnp::FlatArrayMessageReader cmsg(amsg); + + if (sock == s->b.uiButtonInfo_sock) { + cereal::UIButtonInfo::Reader customButton = cmsg.getRoot(); + + int id = customButton.getBtnId(); + // printf("*** got button info: ID = (%d)\n", id); + // printf("*button name = '%s'**\n", (char *)customButton.getBtnName().cStr()); + strcpy(s->b.btns[id].btn_name, (char*)customButton.getBtnName().cStr()); + strcpy(s->b.btns[id].btn_label, (char*)customButton.getBtnLabel().cStr()); + strcpy(s->b.btns[id].btn_label2, (char*)customButton.getBtnLabel2().cStr()); + s->b.btns_status[id] = customButton.getBtnStatus(); + } + else if (sock == s->b.uiCustomAlert_sock) { + cereal::UICustomAlert::Reader data = cmsg.getRoot(); + + strcpy(s->b.custom_message, data.getCaText().cStr()); + s->b.custom_message_status = (UIStatus)data.getCaStatus(); + + if ((strlen(s->b.custom_message) > 0) && (s->scene.alert_text1.length() == 0)) { + if ((!((bb_get_button_status(s, (char*)"msg") == 0) && (s->b.custom_message_status <= 3))) && (s->vision_connected == true)) { + user_input |= true; + } + } + + if ((s->scene.alert_text1.length() > 0) || (s->scene.alert_text2.length() > 0)) { + user_input |= true; + } + } + else if (sock == s->b.uiSetCar_sock) { + //set car model socket + cereal::UISetCar::Reader data = cmsg.getRoot(); + + if ((strcmp(s->b.car_model, (char*)data.getIcCarName().cStr()) != 0) || (strcmp(s->b.car_folder, (char*)data.getIcCarFolder().cStr()) != 0)) { + strcpy(s->b.car_model, (char*)data.getIcCarName().cStr()); + strcpy(s->b.car_folder, (char*)data.getIcCarFolder().cStr()); + //LOGW("Car folder set (%s)", s->b.car_folder); + + if (strcmp(s->b.car_folder, "tesla") == 0) { + s->b.img_logo = nvgCreateImage(s->vg, "../assets/img_spinner_comma.png", 1); + s->b.img_logo2 = nvgCreateImage(s->vg, "../assets/img_spinner_comma2.png", 1); + //LOGW("Spinning logo set for Tesla"); + } + else if (strcmp(s->b.car_folder, "honda") == 0) { + s->b.img_logo = nvgCreateImage(s->vg, "../assets/img_spinner_comma.honda.png", 1); + s->b.img_logo2 = nvgCreateImage(s->vg, "../assets/img_spinner_comma.honda2.png", 1); + //LOGW("Spinning logo set for Honda"); + } + else if (strcmp(s->b.car_folder, "toyota") == 0) { + s->b.img_logo = nvgCreateImage(s->vg, "../assets/img_spinner_comma.toyota.png", 1); + s->b.img_logo2 = nvgCreateImage(s->vg, "../assets/img_spinner_comma.toyota2.png", 1); + //LOGW("Spinning logo set for Toyota"); + }; + } + s->b.icShowCar = (data.getIcShowCar() == 1); + s->b.icShowLogo = (data.getIcShowLogo() == 1); + } + else if (sock == s->b.uiPlaySound_sock) { + // play sound socket + // cereal::UIPlaySound::Reader data = cmsg.getRoot(); + + // int snd = data.getSndSound(); + // bb_ui_play_sound(s,snd); + } + else if (sock == s->b.gps_sock) { + // gps socket + cereal::Event::Reader event = cmsg.getRoot(); + auto data = event.getGpsLocationExternal(); + + s->b.gpsAccuracy = data.getAccuracy(); + if (s->b.gpsAccuracy > 100) { + s->b.gpsAccuracy = 99.99; + } + else if (s->b.gpsAccuracy == 0) { + s->b.gpsAccuracy = 99.8; + } + } + else if (sock == s->b.uiGyroInfo_sock) { + //gyro info socket + cereal::UIGyroInfo::Reader data = cmsg.getRoot(); + + s->b.accPitch = data.getAccPitch(); + s->b.accRoll = data.getAccRoll(); + s->b.accYaw = data.getAccYaw(); + s->b.magPitch = data.getMagPitch(); + s->b.magRoll = data.getMagRoll(); + s->b.magYaw = data.getMagYaw(); + s->b.gyroPitch = data.getGyroPitch(); + s->b.gyroRoll = data.getGyroRoll(); + s->b.gyroYaw = data.getGyroYaw(); + } + } + } + + return user_input; +} diff --git a/selfdrive/ui/bbui.h b/selfdrive/ui/bbui.h deleted file mode 100644 index ede27951c43bf2..00000000000000 --- a/selfdrive/ui/bbui.h +++ /dev/null @@ -1,1501 +0,0 @@ -#include "cereal/gen/c/ui.capnp.h" - - - - -vec3 bb_car_space_to_full_frame(const UIState *s, vec4 car_space_projective) { - const UIScene *scene = &s->scene; - - // We'll call the car space point p. - // First project into normalized image coordinates with the extrinsics matrix. - const vec4 Ep4 = matvecmul(scene->extrinsic_matrix, car_space_projective); - - // The last entry is zero because of how we store E (to use matvecmul). - const vec3 Ep = {{Ep4.v[0], Ep4.v[1], Ep4.v[2]}}; - const vec3 KEp = matvecmul3(intrinsic_matrix, Ep); - - // Project. - const vec3 p_image = {{KEp.v[0] / KEp.v[2], KEp.v[1] / KEp.v[2], 1.}}; - return p_image; -} - - - -void bb_ui_draw_vision_alert( UIState *s, int va_size, int va_color, - const char* va_text1, const char* va_text2) { - const UIScene *scene = &s->scene; - int ui_viz_rx = scene->ui_viz_rx; - int ui_viz_rw = scene->ui_viz_rw; - bool hasSidebar = !s->scene.uilayout_sidebarcollapsed; - bool mapEnabled = s->scene.uilayout_mapenabled; - bool longAlert1 = strlen(va_text1) > 15; - - const uint8_t *color = alert_colors[va_color]; - const int alr_s = alert_sizes[va_size]; - const int alr_x = ui_viz_rx-(mapEnabled?(hasSidebar?nav_w:(nav_ww)):0)-bdr_s; - const int alr_w = ui_viz_rw+(mapEnabled?(hasSidebar?nav_w:(nav_ww)):0)+(bdr_s*2); - const int alr_h = alr_s+(va_size==ALERTSIZE_NONE?0:bdr_s); - const int alr_y = vwp_h-alr_h; - - nvgBeginPath(s->vg); - nvgRect(s->vg, alr_x, alr_y, alr_w, alr_h); - nvgFillColor(s->vg, nvgRGBA(color[0],color[1],color[2],(color[3]*s->alert_blinking_alpha))); - nvgFill(s->vg); - - nvgBeginPath(s->vg); - NVGpaint gradient = nvgLinearGradient(s->vg, alr_x, alr_y, alr_x, alr_y+alr_h, - nvgRGBAf(0.0,0.0,0.0,0.05), nvgRGBAf(0.0,0.0,0.0,0.35)); - nvgFillPaint(s->vg, gradient); - nvgRect(s->vg, alr_x, alr_y, alr_w, alr_h); - nvgFill(s->vg); - - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); - nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_BASELINE); - - if (va_size == ALERTSIZE_SMALL) { - nvgFontFace(s->vg, "sans-semibold"); - nvgFontSize(s->vg, 40*2.5); - nvgText(s->vg, alr_x+alr_w/2, alr_y+alr_h/2+15, va_text1, NULL); - } else if (va_size== ALERTSIZE_MID) { - nvgFontFace(s->vg, "sans-bold"); - nvgFontSize(s->vg, 48*2.5); - nvgText(s->vg, alr_x+alr_w/2, alr_y+alr_h/2-45, va_text1, NULL); - nvgFontFace(s->vg, "sans-regular"); - nvgFontSize(s->vg, 36*2.5); - nvgText(s->vg, alr_x+alr_w/2, alr_y+alr_h/2+75, va_text2, NULL); - } else if (va_size== ALERTSIZE_FULL) { - nvgFontSize(s->vg, (longAlert1?72:96)*2.5); - nvgFontFace(s->vg, "sans-bold"); - nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE); - nvgTextBox(s->vg, alr_x, alr_y+(longAlert1?360:420), alr_w-60, va_text1, NULL); - nvgFontSize(s->vg, 48*2.5); - nvgFontFace(s->vg, "sans-regular"); - nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_BOTTOM); - nvgTextBox(s->vg, alr_x, alr_h-(longAlert1?300:360), alr_w-60, va_text2, NULL); - } -} - - - -void bb_ui_draw_car( UIState *s) { - // replaces the draw_chevron function when button in mid position - //static void draw_chevron(UIState *s, float x_in, float y_in, float sz, - // NVGcolor fillColor, NVGcolor glowColor) { - if (!s->scene.lead_status) { - //no lead car to draw - return; - } - if (!s->b.icShowCar) { - return; - } - const UIScene *scene = &s->scene; - float x_in = scene->lead_d_rel+2.7; - float y_in = scene->lead_y_rel; - float sz = 1.0; - - nvgSave(s->vg); - nvgTranslate(s->vg, 240.0f, 0.0); - nvgTranslate(s->vg, -1440.0f / 2, -1080.0f / 2); - nvgScale(s->vg, 2.0, 2.0); - nvgScale(s->vg, 1440.0f / s->rgb_width, 1080.0f / s->rgb_height); - - const vec4 p_car_space = (vec4){{x_in, y_in, 0., 1.}}; - const vec3 p_full_frame = bb_car_space_to_full_frame(s, p_car_space); - - float x = p_full_frame.v[0]; - float y = p_full_frame.v[1]; - - // glow - - float bbsz =0.1* 0.1 + 0.6 * (180-x_in*3.3-20)/180; - if (bbsz < 0.1) bbsz = 0.1; - if (bbsz > 0.6) bbsz = 0.6; - float car_alpha = .8; - float car_w = 750 * bbsz; - float car_h = 531 * bbsz; - float car_y = y - car_h/2; - float car_x = x - car_w/2; - - nvgBeginPath(s->vg); - NVGpaint imgPaint = nvgImagePattern(s->vg, car_x, car_y, - car_w, car_h, 0, s->b.img_car, car_alpha); - nvgRect(s->vg, car_x, car_y, car_w, car_h); - nvgFillPaint(s->vg, imgPaint); - nvgFill(s->vg); - nvgRestore(s->vg); -} - -void bb_draw_lane_fill ( UIState *s) { - - const UIScene *scene = &s->scene; - - nvgSave(s->vg); - nvgTranslate(s->vg, 240.0f, 0.0); // rgb-box space - nvgTranslate(s->vg, -1440.0f / 2, -1080.0f / 2); // zoom 2x - nvgScale(s->vg, 2.0, 2.0); - nvgScale(s->vg, 1440.0f / s->rgb_width, 1080.0f / s->rgb_height); - nvgBeginPath(s->vg); - - //BB let the magic begin - //define variables - PathData path; - float *points; - float off; - NVGcolor bb_color = nvgRGBA(138, 140, 142,180); - bool started = false; - bool is_ghost = true; - //left lane, first init - path = scene->model.left_lane; - points = path.points; - off = 0.025*path.prob; - //draw left - for (int i=0; i<49; i++) { - float px = (float)i; - float py = points[i] - off; - vec4 p_car_space = (vec4){{px, py, 0., 1.}}; - vec3 p_full_frame = bb_car_space_to_full_frame(s, p_car_space); - float x = p_full_frame.v[0]; - float y = p_full_frame.v[1]; - if (x < 0 || y < 0.) { - continue; - } - if (!started) { - nvgMoveTo(s->vg, x, y); - started = true; - } else { - nvgLineTo(s->vg, x, y); - } - } - //right lane, first init - path = scene->model.right_lane; - points = path.points; - off = 0.025*path.prob; - //draw right - for (int i=49; i>0; i--) { - float px = (float)i; - float py = is_ghost?(points[i]-off):(points[i]+off); - vec4 p_car_space = (vec4){{px, py, 0., 1.}}; - vec3 p_full_frame = bb_car_space_to_full_frame(s, p_car_space); - float x = p_full_frame.v[0]; - float y = p_full_frame.v[1]; - if (x < 0 || y < 0.) { - continue; - } - nvgLineTo(s->vg, x, y); - } - - nvgClosePath(s->vg); - nvgFillColor(s->vg, bb_color); - nvgFill(s->vg); - nvgRestore(s->vg); - -} - - - - - -long bb_currentTimeInMilis() { - struct timespec res; - clock_gettime(CLOCK_MONOTONIC, &res); - return (res.tv_sec * 1000) + res.tv_nsec/1000000; -} - -int bb_get_status( UIState *s) { - //BB select status based on main s->status w/ priority over s->b.custom_message_status - int bb_status = -1; - if ((s->status == STATUS_ENGAGED) && (s->b.custom_message_status > STATUS_ENGAGED)) { - bb_status = s->b.custom_message_status; - } else { - bb_status = s->status; - } - return bb_status; -} - -int bb_ui_draw_measure( UIState *s, const char* bb_value, const char* bb_uom, const char* bb_label, - int bb_x, int bb_y, int bb_uom_dx, - NVGcolor bb_valueColor, NVGcolor bb_labelColor, NVGcolor bb_uomColor, - int bb_valueFontSize, int bb_labelFontSize, int bb_uomFontSize ) { - const UIScene *scene = &s->scene; - nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_BASELINE); - int dx = 0; - if (strlen(bb_uom) > 0) { - dx = (int)(bb_uomFontSize*2.5/2); - } - //print value - nvgFontFace(s->vg, "sans-semibold"); - nvgFontSize(s->vg, bb_valueFontSize*2.5); - nvgFillColor(s->vg, bb_valueColor); - nvgText(s->vg, bb_x-dx/2, bb_y+ (int)(bb_valueFontSize*2.5)+5, bb_value, NULL); - //print label - nvgFontFace(s->vg, "sans-regular"); - nvgFontSize(s->vg, bb_labelFontSize*2.5); - nvgFillColor(s->vg, bb_labelColor); - nvgText(s->vg, bb_x, bb_y + (int)(bb_valueFontSize*2.5)+5 + (int)(bb_labelFontSize*2.5)+5, bb_label, NULL); - //print uom - if (strlen(bb_uom) > 0) { - nvgSave(s->vg); - int rx =bb_x + bb_uom_dx + bb_valueFontSize -3; - int ry = bb_y + (int)(bb_valueFontSize*2.5/2)+25; - nvgTranslate(s->vg,rx,ry); - nvgRotate(s->vg, -1.5708); //-90deg in radians - nvgFontFace(s->vg, "sans-regular"); - nvgFontSize(s->vg, (int)(bb_uomFontSize*2.5)); - nvgFillColor(s->vg, bb_uomColor); - nvgText(s->vg, 0, 0, bb_uom, NULL); - nvgRestore(s->vg); - } - return (int)((bb_valueFontSize + bb_labelFontSize)*2.5) + 5; -} - - -bool bb_handle_ui_touch( UIState *s, int touch_x, int touch_y) { - for(int i=0; i<6; i++) { - if (s->b.btns_r[i] > 0) { - if ((abs(touch_x - s->b.btns_x[i]) < s->b.btns_r[i]) && (abs(touch_y - s->b.btns_y[i]) < s->b.btns_r[i])) { - //found it; change the status - if (s->b.btns_status[i] > 0) { - s->b.btns_status[i] = 0; - } else { - s->b.btns_status[i] = 1; - } - //now let's send the cereal - - struct capn c; - capn_init_malloc(&c); - struct capn_ptr cr = capn_root(&c); - struct capn_segment *cs = cr.seg; - - struct cereal_UIButtonStatus btn_d; - btn_d.btnId = i; - btn_d.btnStatus = s->b.btns_status[i]; - - cereal_UIButtonStatus_ptr btn_p = cereal_new_UIButtonStatus(cs); - - cereal_write_UIButtonStatus(&btn_d, btn_p); - int setp_ret = capn_setp(capn_root(&c), 0, btn_p.p); - assert(setp_ret == 0); - - uint8_t buf[4096]; - ssize_t rs = capn_write_mem(&c, buf, sizeof(buf), 0); - - capn_free(&c); - - zmq_send(s->b.uiButtonStatus_sock_raw, buf,rs,0); - - return true; - } - } - } - return false; -}; - -int bb_get_button_status( UIState *s, char *btn_name) { - int ret_status = -1; - for (int i = 0; i< 6; i++) { - if (strcmp(s->b.btns[i].btn_name,btn_name)==0) { - ret_status = s->b.btns_status[i]; - } - } - return ret_status; -} - -void bb_draw_button( UIState *s, int btn_id) { - const UIScene *scene = &s->scene; - - int viz_button_x = 0; - int viz_button_y = (box_y + (bdr_s*1.5)) + 20; - int viz_button_w = 140; - int viz_button_h = 140; - - char *btn_text, *btn_text2; - - int delta_x = viz_button_w * 1.1; - int delta_y = 0; - int dx1 = 200; - int dx2 = 190; - int dy = 0; - - if (s->b.tri_state_switch ==2) { - delta_y = delta_x; - delta_x = 0; - dx1 = 20; - dx2 = 160; - dy = 200; - } - - if (btn_id >2) { - viz_button_x = scene->ui_viz_rx + scene->ui_viz_rw - (bdr_s*2) -dx2; - viz_button_x -= (6-btn_id) * delta_x ; - viz_button_y += (btn_id-3) * delta_y + dy; - - } else { - viz_button_x = scene->ui_viz_rx + (bdr_s*2) + dx1; - viz_button_x += (btn_id) * delta_x; - viz_button_y += btn_id * delta_y + dy; - } - - - btn_text = s->b.btns[btn_id].btn_label; - btn_text2 = s->b.btns[btn_id].btn_label2; - - if (strcmp(btn_text,"")==0) { - s->b.btns_r[btn_id] = 0; - } else { - s->b.btns_r[btn_id]= (int)((viz_button_w + viz_button_h)/4); - } - s->b.btns_x[btn_id]=viz_button_x + s->b.btns_r[btn_id]; - s->b.btns_y[btn_id]=viz_button_y + s->b.btns_r[btn_id]; - if (s->b.btns_r[btn_id] == 0) { - return; - } - - nvgBeginPath(s->vg); - nvgRoundedRect(s->vg, viz_button_x, viz_button_y, viz_button_w, viz_button_h, 80); - nvgStrokeWidth(s->vg, 12); - - - if (s->b.btns_status[btn_id] ==0) { - //disabled - red - nvgStrokeColor(s->vg, nvgRGBA(255, 0, 0, 200)); - if (strcmp(btn_text2,"")==0) { - btn_text2 = "Off"; - } - } else - if (s->b.btns_status[btn_id] ==1) { - //enabled - white - nvgStrokeColor(s->vg, nvgRGBA(255,255,255,200)); - nvgStrokeWidth(s->vg, 4); - if (strcmp(btn_text2,"")==0) { - btn_text2 = "Ready"; - } - } else - if (s->b.btns_status[btn_id] ==2) { - //active - green - nvgStrokeColor(s->vg, nvgRGBA(28, 204,98,200)); - if (strcmp(btn_text2,"")==0) { - btn_text2 = "Active"; - } - } else - if (s->b.btns_status[btn_id] ==9) { - //available - thin white - nvgStrokeColor(s->vg, nvgRGBA(200,200,200,40)); - nvgStrokeWidth(s->vg, 4); - if (strcmp(btn_text2,"")==0) { - btn_text2 = ""; - } - } else { - //others - orange - nvgStrokeColor(s->vg, nvgRGBA(255, 188, 3, 200)); - if (strcmp(btn_text2,"")==0) { - btn_text2 = "Alert"; - } - } - - nvgStroke(s->vg); - - nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_BASELINE); - nvgFontFace(s->vg, "sans-regular"); - nvgFontSize(s->vg, 14*2.5); - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 200)); - nvgText(s->vg, viz_button_x+viz_button_w/2, viz_button_y + 112, btn_text2, NULL); - - nvgFontFace(s->vg, "sans-semibold"); - nvgFontSize(s->vg, 28*2.5); - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); - nvgText(s->vg, viz_button_x+viz_button_w/2, viz_button_y + 85,btn_text, NULL); -} - -void bb_draw_buttons( UIState *s) { - for (int i = 0; i < 6; i++) { - bb_draw_button(s,i); - } -} - -void bb_ui_draw_custom_alert( UIState *s) { - if ((strlen(s->b.custom_message) > 0) && (strlen(s->scene.alert_text1)==0)){ - if ((!((bb_get_button_status(s,"msg") == 0) && (s->b.custom_message_status<=3))) && (s->vision_connected == true)) { - bb_ui_draw_vision_alert(s, ALERTSIZE_SMALL, s->b.custom_message_status, - s->b.custom_message,""); - } - } -} - - -void bb_ui_draw_measures_left( UIState *s, int bb_x, int bb_y, int bb_w ) { - const UIScene *scene = &s->scene; - int bb_rx = bb_x + (int)(bb_w/2); - int bb_ry = bb_y; - int bb_h = 5; - NVGcolor lab_color = nvgRGBA(255, 255, 255, 200); - NVGcolor uom_color = nvgRGBA(255, 255, 255, 200); - int value_fontSize=30; - int label_fontSize=15; - int uom_fontSize = 15; - int bb_uom_dx = (int)(bb_w /2 - uom_fontSize*2.5) ; - - //add CPU temperature - if (true) { - char val_str[16]; - char uom_str[6]; - NVGcolor val_color = nvgRGBA(255, 255, 255, 200); - if((int)(s->b.maxCpuTemp/10) > 80) { - val_color = nvgRGBA(255, 188, 3, 200); - } - if((int)(s->b.maxCpuTemp/10) > 92) { - val_color = nvgRGBA(255, 0, 0, 200); - } - // temp is alway in C * 10 - if (s->is_metric) { - snprintf(val_str, sizeof(val_str), "%d C", (int)(s->b.maxCpuTemp/10)); - } else { - snprintf(val_str, sizeof(val_str), "%d F", (int)(32+9*(s->b.maxCpuTemp/10)/5)); - } - snprintf(uom_str, sizeof(uom_str), ""); - bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "CPU TEMP", - bb_rx, bb_ry, bb_uom_dx, - val_color, lab_color, uom_color, - value_fontSize, label_fontSize, uom_fontSize ); - bb_ry = bb_y + bb_h; - } - - //add battery temperature - if (true) { - char val_str[16]; - char uom_str[6]; - NVGcolor val_color = nvgRGBA(255, 255, 255, 200); - if((int)(s->b.maxBatTemp/1000) > 40) { - val_color = nvgRGBA(255, 188, 3, 200); - } - if((int)(s->b.maxBatTemp/1000) > 50) { - val_color = nvgRGBA(255, 0, 0, 200); - } - // temp is alway in C * 1000 - if (s->is_metric) { - snprintf(val_str, sizeof(val_str), "%d C", (int)(s->b.maxBatTemp/1000)); - } else { - snprintf(val_str, sizeof(val_str), "%d F", (int)(32+9*(s->b.maxBatTemp/1000)/5)); - } - snprintf(uom_str, sizeof(uom_str), ""); - bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "BAT TEMP", - bb_rx, bb_ry, bb_uom_dx, - val_color, lab_color, uom_color, - value_fontSize, label_fontSize, uom_fontSize ); - bb_ry = bb_y + bb_h; - } - - //add grey panda GPS accuracy - if (true) { - char val_str[16]; - char uom_str[3]; - NVGcolor val_color = nvgRGBA(255, 255, 255, 200); - //show red/orange if gps accuracy is high - if(s->b.gpsAccuracy > 0.59) { - val_color = nvgRGBA(255, 188, 3, 200); - } - if(s->b.gpsAccuracy > 0.8) { - val_color = nvgRGBA(255, 0, 0, 200); - } - - - // gps accuracy is always in meters - if (true) { - snprintf(val_str, sizeof(val_str), "%d", (int)(s->b.gpsAccuracy*100.0)); - } else { - snprintf(val_str, sizeof(val_str), "%.1f", s->b.gpsAccuracy * 3.28084 * 12); - } - if (true) { - snprintf(uom_str, sizeof(uom_str), "cm");; - } else { - snprintf(uom_str, sizeof(uom_str), "in"); - } - bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "GPS PREC", - bb_rx, bb_ry, bb_uom_dx, - val_color, lab_color, uom_color, - value_fontSize, label_fontSize, uom_fontSize ); - bb_ry = bb_y + bb_h; - } - //add free space - from bthaler1 - if (true) { - char val_str[16]; - char uom_str[3]; - NVGcolor val_color = nvgRGBA(255, 255, 255, 200); - - //show red/orange if free space is low - if(s->b.freeSpace < 0.4) { - val_color = nvgRGBA(255, 188, 3, 200); - } - if(s->b.freeSpace < 0.2) { - val_color = nvgRGBA(255, 0, 0, 200); - } - - snprintf(val_str, sizeof(val_str), "%.1f", s->b.freeSpace* 100); - snprintf(uom_str, sizeof(uom_str), "%%"); - - bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "FREE", - bb_rx, bb_ry, bb_uom_dx, - val_color, lab_color, uom_color, - value_fontSize, label_fontSize, uom_fontSize ); - bb_ry = bb_y + bb_h; - } - //finally draw the frame - bb_h += 20; - nvgBeginPath(s->vg); - nvgRoundedRect(s->vg, bb_x, bb_y, bb_w, bb_h, 20); - nvgStrokeColor(s->vg, nvgRGBA(255,255,255,80)); - nvgStrokeWidth(s->vg, 6); - nvgStroke(s->vg); -} - -void bb_ui_draw_measures_left2( UIState *s, int bb_x, int bb_y, int bb_w ) { - const UIScene *scene = &s->scene; - int bb_rx = bb_x + (int)(bb_w/2); - int bb_ry = bb_y; - int bb_h = 5; - NVGcolor lab_color = nvgRGBA(255, 255, 255, 200); - NVGcolor uom_color = nvgRGBA(255, 255, 255, 200); - int value_fontSize=30; - int label_fontSize=15; - int uom_fontSize = 15; - int bb_uom_dx = (int)(bb_w /2 - uom_fontSize*2.5) ; - - //add CPU temperature - if (true) { - char val_str[16]; - char uom_str[6]; - NVGcolor val_color = nvgRGBA(255, 255, 255, 200); - if((int)(s->b.maxCpuTemp/10) > 80) { - val_color = nvgRGBA(255, 188, 3, 200); - } - if((int)(s->b.maxCpuTemp/10) > 92) { - val_color = nvgRGBA(255, 0, 0, 200); - } - // temp is alway in C * 10 - if (s->is_metric) { - snprintf(val_str, sizeof(val_str), "%d C", (int)(s->b.maxCpuTemp/10)); - } else { - snprintf(val_str, sizeof(val_str), "%d F", (int)(32+9*(s->b.maxCpuTemp/10)/5)); - } - snprintf(uom_str, sizeof(uom_str), ""); - bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "CPU TEMP", - bb_rx, bb_ry, bb_uom_dx, - val_color, lab_color, uom_color, - value_fontSize, label_fontSize, uom_fontSize ); - bb_ry = bb_y + bb_h; - } - - //add battery temperature - if (true) { - char val_str[16]; - char uom_str[6]; - NVGcolor val_color = nvgRGBA(255, 255, 255, 200); - if((int)(s->b.maxBatTemp/1000) > 40) { - val_color = nvgRGBA(255, 188, 3, 200); - } - if((int)(s->b.maxBatTemp/1000) > 50) { - val_color = nvgRGBA(255, 0, 0, 200); - } - // temp is alway in C * 1000 - if (s->is_metric) { - snprintf(val_str, sizeof(val_str), "%d C", (int)(s->b.maxBatTemp/1000)); - } else { - snprintf(val_str, sizeof(val_str), "%d F", (int)(32+9*(s->b.maxBatTemp/1000)/5)); - } - snprintf(uom_str, sizeof(uom_str), ""); - bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "BAT TEMP", - bb_rx, bb_ry, bb_uom_dx, - val_color, lab_color, uom_color, - value_fontSize, label_fontSize, uom_fontSize ); - bb_ry = bb_y + bb_h; - } - - //add battery level (%) - if (true) { - char val_str[16]; - char uom_str[3]; - NVGcolor val_color = nvgRGBA(255, 255, 255, 200); - - //show red/orange if free space is low - if(s->b.batteryPercent < 40) { - val_color = nvgRGBA(255, 188, 3, 200); - } - if(s->b.batteryPercent < 20) { - val_color = nvgRGBA(255, 0, 0, 200); - } - - snprintf(val_str, sizeof(val_str), "%d", s->b.batteryPercent); - snprintf(uom_str, sizeof(uom_str), "%%"); - - bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "BAT LOAD", - bb_rx, bb_ry, bb_uom_dx, - val_color, lab_color, uom_color, - value_fontSize, label_fontSize, uom_fontSize ); - bb_ry = bb_y + bb_h; - } - - //add charger status - if (true) { - char val_str[16]; - char uom_str[3]; - NVGcolor val_color = nvgRGBA(255, 255, 255, 200); - //show orange if charger is off - if(!s->b.chargingEnabled) { - val_color = nvgRGBA(255, 188, 3, 200); - } - // gps accuracy is always in meters - if (s->b.chargingEnabled) { - snprintf(val_str, sizeof(val_str), "ON"); - } else { - snprintf(val_str, sizeof(val_str), "OFF"); - } - snprintf(uom_str, sizeof(uom_str), " "); - bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "CHARGER", - bb_rx, bb_ry, bb_uom_dx, - val_color, lab_color, uom_color, - value_fontSize, label_fontSize, uom_fontSize ); - bb_ry = bb_y + bb_h; - } - - //finally draw the frame - bb_h += 20; - nvgBeginPath(s->vg); - nvgRoundedRect(s->vg, bb_x, bb_y, bb_w, bb_h, 20); - nvgStrokeColor(s->vg, nvgRGBA(255,255,255,80)); - nvgStrokeWidth(s->vg, 6); - nvgStroke(s->vg); -} - - -void bb_ui_draw_measures_right( UIState *s, int bb_x, int bb_y, int bb_w ) { - const UIScene *scene = &s->scene; - int bb_rx = bb_x + (int)(bb_w/2); - int bb_ry = bb_y; - int bb_h = 5; - NVGcolor lab_color = nvgRGBA(255, 255, 255, 200); - NVGcolor uom_color = nvgRGBA(255, 255, 255, 200); - int value_fontSize=30; - int label_fontSize=15; - int uom_fontSize = 15; - int bb_uom_dx = (int)(bb_w /2 - uom_fontSize*2.5) ; - - //add visual radar relative distance - if (true) { - char val_str[16]; - char uom_str[6]; - NVGcolor val_color = nvgRGBA(255, 255, 255, 200); - if (scene->lead_status) { - //show RED if less than 5 meters - //show orange if less than 15 meters - if((int)(scene->lead_d_rel) < 15) { - val_color = nvgRGBA(255, 188, 3, 200); - } - if((int)(scene->lead_d_rel) < 5) { - val_color = nvgRGBA(255, 0, 0, 200); - } - // lead car relative distance is always in meters - if (s->is_metric) { - snprintf(val_str, sizeof(val_str), "%d", (int)scene->lead_d_rel); - } else { - snprintf(val_str, sizeof(val_str), "%d", (int)(scene->lead_d_rel * 3.28084)); - } - } else { - snprintf(val_str, sizeof(val_str), "-"); - } - if (s->is_metric) { - snprintf(uom_str, sizeof(uom_str), "m "); - } else { - snprintf(uom_str, sizeof(uom_str), "ft"); - } - bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "REL DIST", - bb_rx, bb_ry, bb_uom_dx, - val_color, lab_color, uom_color, - value_fontSize, label_fontSize, uom_fontSize ); - bb_ry = bb_y + bb_h; - } - - //add visual radar relative speed - if (true) { - char val_str[16]; - char uom_str[6]; - NVGcolor val_color = nvgRGBA(255, 255, 255, 200); - if (scene->lead_status) { - //show Orange if negative speed (approaching) - //show Orange if negative speed faster than 5mph (approaching fast) - if((int)(scene->lead_v_rel) < 0) { - val_color = nvgRGBA(255, 188, 3, 200); - } - if((int)(scene->lead_v_rel) < -5) { - val_color = nvgRGBA(255, 0, 0, 200); - } - // lead car relative speed is always in meters - if (s->is_metric) { - snprintf(val_str, sizeof(val_str), "%d", (int)(scene->lead_v_rel * 3.6 + 0.5)); - } else { - snprintf(val_str, sizeof(val_str), "%d", (int)(scene->lead_v_rel * 2.2374144 + 0.5)); - } - } else { - snprintf(val_str, sizeof(val_str), "-"); - } - if (s->is_metric) { - snprintf(uom_str, sizeof(uom_str), "km/h");; - } else { - snprintf(uom_str, sizeof(uom_str), "mph"); - } - bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "REL SPD", - bb_rx, bb_ry, bb_uom_dx, - val_color, lab_color, uom_color, - value_fontSize, label_fontSize, uom_fontSize ); - bb_ry = bb_y + bb_h; - } - - //add steering angle - if (true) { - char val_str[16]; - char uom_str[6]; - NVGcolor val_color = nvgRGBA(255, 255, 255, 200); - //show Orange if more than 6 degrees - //show red if more than 12 degrees - if(((int)(s->b.angleSteers) < -6) || ((int)(s->b.angleSteers) > 6)) { - val_color = nvgRGBA(255, 188, 3, 200); - } - if(((int)(s->b.angleSteers) < -12) || ((int)(s->b.angleSteers) > 12)) { - val_color = nvgRGBA(255, 0, 0, 200); - } - // steering is in degrees - snprintf(val_str, sizeof(val_str), "%.1f",(s->b.angleSteers)); - - snprintf(uom_str, sizeof(uom_str), "deg"); - bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "STEER", - bb_rx, bb_ry, bb_uom_dx, - val_color, lab_color, uom_color, - value_fontSize, label_fontSize, uom_fontSize ); - bb_ry = bb_y + bb_h; - } - - //add desired steering angle - if (true) { - char val_str[16]; - char uom_str[6]; - NVGcolor val_color = nvgRGBA(255, 255, 255, 200); - //show Orange if more than 6 degrees - //show red if more than 12 degrees - if(((int)(s->b.angleSteersDes) < -6) || ((int)(s->b.angleSteersDes) > 6)) { - val_color = nvgRGBA(255, 188, 3, 200); - } - if(((int)(s->b.angleSteersDes) < -12) || ((int)(s->b.angleSteersDes) > 12)) { - val_color = nvgRGBA(255, 0, 0, 200); - } - // steering is in degrees - snprintf(val_str, sizeof(val_str), "%.1f",(s->b.angleSteersDes)); - - snprintf(uom_str, sizeof(uom_str), "deg"); - bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "DES STEER", - bb_rx, bb_ry, bb_uom_dx, - val_color, lab_color, uom_color, - value_fontSize, label_fontSize, uom_fontSize ); - bb_ry = bb_y + bb_h; - } - - - //finally draw the frame - bb_h += 20; - nvgBeginPath(s->vg); - nvgRoundedRect(s->vg, bb_x, bb_y, bb_w, bb_h, 20); - nvgStrokeColor(s->vg, nvgRGBA(255,255,255,80)); - nvgStrokeWidth(s->vg, 6); - nvgStroke(s->vg); -} - -void bb_ui_draw_measures_right2( UIState *s, int bb_x, int bb_y, int bb_w ) { - const UIScene *scene = &s->scene; - int bb_rx = bb_x + (int)(bb_w/2); - int bb_ry = bb_y; - int bb_h = 5; - NVGcolor lab_color = nvgRGBA(255, 255, 255, 200); - NVGcolor uom_color = nvgRGBA(255, 255, 255, 200); - int value_fontSize=30; - int label_fontSize=15; - int uom_fontSize = 15; - int bb_uom_dx = (int)(bb_w /2 - uom_fontSize*2.5) ; - - //Fan speed - if (true) { - char val_str[16]; - char uom_str[6]; - NVGcolor val_color = nvgRGBA(255, 255, 255, 200); - //show RED if at max - //show orange if lower than 16000 - if (s->b.fanSpeed == 0) { - snprintf(val_str, sizeof(val_str), "OFF"); - } else { - if((int)(s->b.fanSpeed) < 12000) { - val_color = nvgRGBA(255, 188, 3, 200); - s->b.fanSpeed = 12000; - } - if((int)(s->b.fanSpeed) > 65000) { - val_color = nvgRGBA(255, 0, 0, 200); - } - snprintf(val_str, sizeof(val_str), "%d", (int)(s->b.fanSpeed * 4500.0 /65535.0)); - } - snprintf(uom_str, sizeof(uom_str), "RPM"); - bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "FAN SPEED", - bb_rx, bb_ry, bb_uom_dx, - val_color, lab_color, uom_color, - value_fontSize, label_fontSize, uom_fontSize ); - bb_ry = bb_y + bb_h; - } - - //add grey panda GPS accuracy - if (true) { - char val_str[16]; - char uom_str[3]; - NVGcolor val_color = nvgRGBA(255, 255, 255, 200); - //show red/orange if gps accuracy is high - if(s->b.gpsAccuracy > 0.59) { - val_color = nvgRGBA(255, 188, 3, 200); - } - if(s->b.gpsAccuracy > 0.8) { - val_color = nvgRGBA(255, 0, 0, 200); - } - - - // gps accuracy is always in meters - if (true) { - snprintf(val_str, sizeof(val_str), "%d", (int)(s->b.gpsAccuracy*100.0)); - } else { - snprintf(val_str, sizeof(val_str), "%.1f", s->b.gpsAccuracy * 3.28084 * 12); - } - if (true) { - snprintf(uom_str, sizeof(uom_str), "cm");; - } else { - snprintf(uom_str, sizeof(uom_str), "in"); - } - bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "GPS PREC", - bb_rx, bb_ry, bb_uom_dx, - val_color, lab_color, uom_color, - value_fontSize, label_fontSize, uom_fontSize ); - bb_ry = bb_y + bb_h; - } - - //add steering angle - if (true) { - char val_str[16]; - char uom_str[6]; - NVGcolor val_color = nvgRGBA(255, 255, 255, 200); - //show Orange if more than 6 degrees - //show red if more than 12 degrees - if(((int)(s->b.angleSteers) < -6) || ((int)(s->b.angleSteers) > 6)) { - val_color = nvgRGBA(255, 188, 3, 200); - } - if(((int)(s->b.angleSteers) < -12) || ((int)(s->b.angleSteers) > 12)) { - val_color = nvgRGBA(255, 0, 0, 200); - } - // steering is in degrees - snprintf(val_str, sizeof(val_str), "%.1f",(s->b.angleSteers)); - - snprintf(uom_str, sizeof(uom_str), "deg"); - bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "STEER", - bb_rx, bb_ry, bb_uom_dx, - val_color, lab_color, uom_color, - value_fontSize, label_fontSize, uom_fontSize ); - bb_ry = bb_y + bb_h; - } - - //add desired steering angle - if (true) { - char val_str[16]; - char uom_str[6]; - NVGcolor val_color = nvgRGBA(255, 255, 255, 200); - //show Orange if more than 6 degrees - //show red if more than 12 degrees - if(((int)(s->b.angleSteersDes) < -6) || ((int)(s->b.angleSteersDes) > 6)) { - val_color = nvgRGBA(255, 188, 3, 200); - } - if(((int)(s->b.angleSteersDes) < -12) || ((int)(s->b.angleSteersDes) > 12)) { - val_color = nvgRGBA(255, 0, 0, 200); - } - // steering is in degrees - snprintf(val_str, sizeof(val_str), "%.1f",(s->b.angleSteersDes)); - - snprintf(uom_str, sizeof(uom_str), "deg"); - bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "DES STEER", - bb_rx, bb_ry, bb_uom_dx, - val_color, lab_color, uom_color, - value_fontSize, label_fontSize, uom_fontSize ); - bb_ry = bb_y + bb_h; - } - - - //finally draw the frame - bb_h += 20; - nvgBeginPath(s->vg); - nvgRoundedRect(s->vg, bb_x, bb_y, bb_w, bb_h, 20); - nvgStrokeColor(s->vg, nvgRGBA(255,255,255,80)); - nvgStrokeWidth(s->vg, 6); - nvgStroke(s->vg); -} - -//draw grid from wiki -void ui_draw_vision_grid( UIState *s) { - const UIScene *scene = &s->scene; - bool is_cruise_set = false;//(s->scene.v_cruise != 0 && s->scene.v_cruise != 255); - if (!is_cruise_set) { - const int grid_spacing = 30; - - int ui_viz_rx = scene->ui_viz_rx; - int ui_viz_rw = scene->ui_viz_rw; - - nvgSave(s->vg); - - // path coords are worked out in rgb-box space - nvgTranslate(s->vg, 240.0f, 0.0); - - // zooom in 2x - nvgTranslate(s->vg, -1440.0f / 2, -1080.0f / 2); - nvgScale(s->vg, 2.0, 2.0); - - nvgScale(s->vg, 1440.0f / s->rgb_width, 1080.0f / s->rgb_height); - - nvgBeginPath(s->vg); - nvgStrokeColor(s->vg, nvgRGBA(255,255,255,128)); - nvgStrokeWidth(s->vg, 1); - - for (int i=box_y; i < box_h; i+=grid_spacing) { - nvgMoveTo(s->vg, ui_viz_rx, i); - //nvgLineTo(s->vg, ui_viz_rx, i); - nvgLineTo(s->vg, ((ui_viz_rw + ui_viz_rx) / 2)+ 10, i); - } - - for (int i=ui_viz_rx + 12; i <= ui_viz_rw; i+=grid_spacing) { - nvgMoveTo(s->vg, i, 0); - nvgLineTo(s->vg, i, 1000); - } - nvgStroke(s->vg); - nvgRestore(s->vg); - } -} - -void bb_ui_draw_logo( UIState *s) { - if ((s->status != STATUS_DISENGAGED) && (s->status != STATUS_STOPPED)) { //(s->status != STATUS_DISENGAGED) {// - return; - } - if (!s->b.icShowLogo) { - return; - } - int rduration = 8000; - int logot = (bb_currentTimeInMilis() % rduration); - int logoi = s->b.img_logo; - if ((logot > (int)(rduration/4)) && (logot < (int)(3*rduration/4))) { - logoi = s->b.img_logo2; - } - if (logot < (int)(rduration/2)) { - logot = logot - (int)(rduration/4); - } else { - logot = logot - (int)(3*rduration/4); - } - float logop = fabs(4.0*logot/rduration); - const UIScene *scene = &s->scene; - const int ui_viz_rx = scene->ui_viz_rx; - const int ui_viz_rw = scene->ui_viz_rw; - const int viz_event_w = (int)(820 * logop); - const int viz_event_h = 820; - const int viz_event_x = (ui_viz_rx + (ui_viz_rw - viz_event_w - bdr_s*2)/2); - const int viz_event_y = 200; - bool is_engageable = scene->engageable; - float viz_event_alpha = 1.0f; - nvgBeginPath(s->vg); - NVGpaint imgPaint = nvgImagePattern(s->vg, viz_event_x, viz_event_y, - viz_event_w, viz_event_h, 0, logoi, viz_event_alpha); - nvgRect(s->vg, viz_event_x, viz_event_y, (int)viz_event_w, viz_event_h); - nvgFillPaint(s->vg, imgPaint); - nvgFill(s->vg); -} - -void bb_ui_draw_gyro(UIState *s) { - //draw the gyro data - const UIScene *scene = &s->scene; - const float prc = 0.6; - const int sc_h = 820; - const int sc_w = scene->ui_viz_rw; - const int sc_x = bdr_s + scene->ui_viz_rx; - const int sc_y = 100; - const int sc_cx = (int)(sc_x + sc_w /2); - const int sc_cy = (int)(sc_y + sc_h/2); - const int l_w = (int)(sc_w * prc / 2); - - const int p_w = (int)((sc_cx - l_w - sc_x)*prc); - const int p_x = (int)(bdr_s +(sc_cx - l_w - p_w)/2); - const int p_max_h = (int)(sc_h * prc /2); - - nvgBeginPath(s->vg); - //white for the base line - nvgStrokeColor(s->vg, nvgRGBA(255,255,255,200)); - nvgStrokeWidth(s->vg, 4); - nvgMoveTo(s->vg, sc_cx - l_w, sc_cy); - nvgLineTo(s->vg, sc_cx +l_w, sc_cy); - nvgStroke(s->vg); - - //compute angle vs horizontal axis based on roll - const float r_ang_rad = -s->b.accRoll; - const float p_ang_rad = -s->b.accPitch; - - //roll - //acc roll - green - nvgSave(s->vg); - nvgTranslate(s->vg, sc_cx, sc_cy); - nvgRotate(s->vg, r_ang_rad); - nvgBeginPath(s->vg); - //green for the real horizontal line based on ACC - nvgStrokeColor(s->vg, nvgRGBA(28, 204,98,200)); - nvgStrokeWidth(s->vg, 4); - nvgMoveTo(s->vg, -l_w, 0); - nvgLineTo(s->vg, +l_w, 0); - nvgStroke(s->vg); - nvgRestore(s->vg); - //mag roll - yellow - nvgSave(s->vg); - nvgTranslate(s->vg, sc_cx, sc_cy); - nvgRotate(s->vg, -s->b.magRoll); - nvgBeginPath(s->vg); - //yellow for the real horizontal line based on MAG - nvgStrokeColor(s->vg, nvgRGBA(255, 255,0,200)); - nvgStrokeWidth(s->vg, 4); - nvgMoveTo(s->vg, -l_w, 0); - nvgLineTo(s->vg, +l_w, 0); - nvgStroke(s->vg); - nvgRestore(s->vg); - //gyro roll - red - nvgSave(s->vg); - nvgTranslate(s->vg, sc_cx, sc_cy); - nvgRotate(s->vg, -s->b.gyroRoll); - nvgBeginPath(s->vg); - //red for the real horizontal line based on GYRO - nvgStrokeColor(s->vg, nvgRGBA(255, 0,0,200)); - nvgStrokeWidth(s->vg, 4); - nvgMoveTo(s->vg, -l_w, 0); - nvgLineTo(s->vg, +l_w, 0); - nvgStroke(s->vg); - nvgRestore(s->vg); - - //pitch - const int p_y = sc_cy; - //double height to accentuate change - const int p_h = (int)(p_max_h * sin(p_ang_rad) ); - nvgBeginPath(s->vg); - //fill with red - nvgFillColor(s->vg, nvgRGBA(255, 0, 0, 200)); - nvgStrokeColor(s->vg, nvgRGBA(255, 0, 0, 200)); - nvgRect(s->vg, p_x, p_y, p_w, p_h); - nvgFill(s->vg); - nvgStroke(s->vg); - //draw middle line white - nvgBeginPath(s->vg); - nvgStrokeColor(s->vg, nvgRGBA(255,255,255,200)); - nvgStrokeWidth(s->vg, 4); - nvgMoveTo(s->vg, p_x,p_y); - nvgLineTo(s->vg, p_x + p_w, p_y); - nvgStroke(s->vg); - //draw horizon with green - nvgBeginPath(s->vg); - nvgStrokeColor(s->vg, nvgRGBA(28, 204,98,200)); - nvgMoveTo(s->vg, p_x,p_y+p_h); - nvgLineTo(s->vg, p_x + p_w, p_y+p_h); - nvgStroke(s->vg); -} - -void bb_ui_read_triState_switch( UIState *s) { - //get 3-state switch position - int tri_state_fd; - char buffer[10]; - if (bb_currentTimeInMilis() - s->b.tri_state_switch_last_read > 2000) { - //tri_stated_fd = open ("/sys/devices/virtual/switch/tri-state-key/state", O_RDONLY); - //if we can't open then switch should be considered in the middle, nothing done - /* if (tri_state_fd == -1) { - s->b.tri_state_switch = 3; - } else { - read (tri_state_fd, &buffer, 10); - s->b.tri_state_switch = buffer[0] -48; - close(tri_state_fd); - s->b.tri_state_switch_last_read = bb_currentTimeInMilis(); - }*/ - s->b.tri_state_switch_last_read = bb_currentTimeInMilis(); - s->b.tri_state_switch = 3; - if (strcmp(s->b.btns[2].btn_label2,"OP")==0) { - s->b.tri_state_switch = 1; - } - if (strcmp(s->b.btns[2].btn_label2,"MIN")==0) { - s->b.tri_state_switch = 2; - } - if (strcmp(s->b.btns[2].btn_label2,"OFF")==0) { - s->b.tri_state_switch = 3; - } - if (strcmp(s->b.btns[2].btn_label2,"GYRO")==0) { - s->b.tri_state_switch = 4; - } - int i = bb_get_button_status(s,"dsp"); - if (i==9) { - s->b.keepEonOff = true; - s->awake_timeout = min(s->awake_timeout,3*30); - } else { - s->b.keepEonOff = false; - s->awake_timeout = min(s->awake_timeout,30*30); - } - } -} - -void bb_ui_draw_UI( UIState *s) { - - - if (s->b.tri_state_switch == 1) { - const UIScene *scene = &s->scene; - const int bb_dml_w = 180; - const int bb_dml_x = (scene->ui_viz_rx + (bdr_s*2)); - const int bb_dml_y = (box_y + (bdr_s*1.5))+220; - - const int bb_dmr_w = 180; - const int bb_dmr_x = scene->ui_viz_rx + scene->ui_viz_rw - bb_dmr_w - (bdr_s*2) ; - const int bb_dmr_y = (box_y + (bdr_s*1.5))+220; - bb_ui_draw_measures_left(s,bb_dml_x, bb_dml_y, bb_dml_w ); - bb_ui_draw_measures_right(s,bb_dmr_x, bb_dmr_y, bb_dmr_w ); - bb_draw_buttons(s); - bb_ui_draw_custom_alert(s); - bb_ui_draw_logo(s); - } - if (s->b.tri_state_switch ==2) { - const UIScene *scene = &s->scene; - const int bb_dml_w = 180; - const int bb_dml_x = (scene->ui_viz_rx + (bdr_s*2)); - const int bb_dml_y = (box_y + (bdr_s*1.5))+220; - - const int bb_dmr_w = 180; - const int bb_dmr_x = scene->ui_viz_rx + scene->ui_viz_rw - bb_dmr_w - (bdr_s*2) ; - const int bb_dmr_y = (box_y + (bdr_s*1.5))+220; - bb_draw_buttons(s); - bb_ui_draw_custom_alert(s); - bb_ui_draw_logo(s); - } - if (s->b.tri_state_switch ==3) { - //we now use the state 3 for minimalistic data alerts - const UIScene *scene = &s->scene; - const int bb_dml_w = 180; - const int bb_dml_x = (scene->ui_viz_rx + (bdr_s*2)); - const int bb_dml_y = (box_y + (bdr_s*1.5))+220; - - const int bb_dmr_w = 180; - const int bb_dmr_x = scene->ui_viz_rx + scene->ui_viz_rw - bb_dmr_w - (bdr_s*2) ; - const int bb_dmr_y = (box_y + (bdr_s*1.5))+220; - bb_ui_draw_measures_left2(s,bb_dml_x, bb_dml_y, bb_dml_w ); - bb_ui_draw_measures_right2(s,bb_dmr_x, bb_dmr_y, bb_dmr_w ); - bb_draw_buttons(s); - bb_ui_draw_custom_alert(s); - } - if (s->b.tri_state_switch ==4) { - //we use the state 4 for gyro info - const UIScene *scene = &s->scene; - const int bb_dml_w = 180; - const int bb_dml_x = (scene->ui_viz_rx + (bdr_s*2)); - const int bb_dml_y = (box_y + (bdr_s*1.5))+220; - - const int bb_dmr_w = 180; - const int bb_dmr_x = scene->ui_viz_rx + scene->ui_viz_rw - bb_dmr_w - (bdr_s*2) ; - const int bb_dmr_y = (box_y + (bdr_s*1.5))+220; - bb_draw_buttons(s); - bb_ui_draw_custom_alert(s); - bb_ui_draw_gyro(s); - } -} - - - -void bb_ui_init(UIState *s) { - - //BB INIT - s->b.shouldDrawFrame = true; - s->status = STATUS_DISENGAGED; - strcpy(s->b.car_model,"Tesla"); - strcpy(s->b.car_folder,"tesla"); - s->b.tri_state_switch = -1; - s->b.tri_state_switch_last_read = 0; - s->b.touch_last = false; - s->b.touch_last_x = 0; - s->b.touch_last_y =0; - s->b.touch_last_width = s->scene.ui_viz_rw; - - //BB Define CAPNP sock - s->b.uiButtonInfo_sock = zsock_new_sub(">tcp://127.0.0.1:8201", ""); - assert(s->b.uiButtonInfo_sock); - s->b.uiButtonInfo_sock_raw = zsock_resolve(s->b.uiButtonInfo_sock); - - s->b.uiCustomAlert_sock = zsock_new_sub(">tcp://127.0.0.1:8202", ""); - assert(s->b.uiCustomAlert_sock); - s->b.uiCustomAlert_sock_raw = zsock_resolve(s->b.uiCustomAlert_sock); - - s->b.uiSetCar_sock = zsock_new_sub(">tcp://127.0.0.1:8203", ""); - assert(s->b.uiSetCar_sock); - s->b.uiSetCar_sock_raw = zsock_resolve(s->b.uiSetCar_sock); - - s->b.uiPlaySound_sock = zsock_new_sub(">tcp://127.0.0.1:8205", ""); - assert(s->b.uiPlaySound_sock); - s->b.uiPlaySound_sock_raw = zsock_resolve(s->b.uiPlaySound_sock); - - s->b.uiButtonStatus_sock = zsock_new_pub("@tcp://127.0.0.1:8204"); - assert(s->b.uiButtonStatus_sock); - s->b.uiButtonStatus_sock_raw = zsock_resolve(s->b.uiButtonStatus_sock); - - s->b.gps_sock = zsock_new_sub(">tcp://127.0.0.1:8032",""); - assert(s->b.gps_sock); - s->b.gps_sock_raw = zsock_resolve(s->b.gps_sock); - - s->b.uiGyroInfo_sock = zsock_new_sub(">tcp://127.0.0.1:8207", ""); - assert(s->b.uiGyroInfo_sock); - s->b.uiGyroInfo_sock_raw = zsock_resolve(s->b.uiGyroInfo_sock); - - //BB Load Images - s->b.img_logo = nvgCreateImage(s->vg, "../assets/img_spinner_comma.png", 1); - s->b.img_logo2 = nvgCreateImage(s->vg, "../assets/img_spinner_comma2.png", 1); - s->b.img_car = nvgCreateImage(s->vg, "../assets/img_car_tesla.png", 1); - - s->b.icShowCar = true; - s->b.icShowLogo = true; -} - -// void bb_ui_play_sound( UIState *s, int sound) { -// char* snd_command; -// int bts = bb_get_button_status(s,"sound"); -// if ((bts > 0) || (bts == -1)) { -// asprintf(&snd_command, "python /data/openpilot/selfdrive/car/modules/snd/playsound.py %d &", sound); -// system(snd_command); -// } -// } - -void bb_ui_set_car( UIState *s, char *model, char *folder) { - strcpy(s->b.car_model,model); - strcpy(s->b.car_folder, folder); -} - -void bb_ui_poll_update( UIState *s) { - int err; - zmq_pollitem_t bb_polls[8] = {{0}}; - bb_polls[0].socket = s->b.uiButtonInfo_sock_raw; - bb_polls[0].events = ZMQ_POLLIN; - bb_polls[1].socket = s->b.uiCustomAlert_sock_raw; - bb_polls[1].events = ZMQ_POLLIN; - bb_polls[2].socket = s->b.uiSetCar_sock_raw; - bb_polls[2].events = ZMQ_POLLIN; - bb_polls[3].socket = s->b.uiPlaySound_sock_raw; - bb_polls[3].events = ZMQ_POLLIN; - bb_polls[4].socket = s->b.gps_sock_raw; - bb_polls[4].events = ZMQ_POLLIN; - bb_polls[5].socket = s->b.uiGyroInfo_sock_raw; - bb_polls[5].events = ZMQ_POLLIN; - - //check tri-state switch - bb_ui_read_triState_switch(s); - - while (true) { - - - int ret = zmq_poll(bb_polls, 6, 0); - if (ret < 0) { - LOGW("bb poll failed (%d)", ret); - break; - } - if (ret == 0) { - //LOGW("poll empty"); - break; - } - - if (bb_polls[0].revents) { - //button info socket - zmq_msg_t msg; - err = zmq_msg_init(&msg); - assert(err == 0); - err = zmq_msg_recv(&msg, s->b.uiButtonInfo_sock_raw, 0); - assert(err >= 0); - - struct capn ctx; - capn_init_mem(&ctx, zmq_msg_data(&msg), zmq_msg_size(&msg), 0); - - cereal_UIButtonInfo_ptr stp; - stp.p = capn_getp(capn_root(&ctx), 0, 1); - struct cereal_UIButtonInfo datad; - cereal_read_UIButtonInfo(&datad, stp); - - int id = datad.btnId; - //LOGW("got button info: ID = (%d)", id); - strcpy(s->b.btns[id].btn_name,(char *)datad.btnName.str); - strcpy(s->b.btns[id].btn_label, (char *)datad.btnLabel.str); - strcpy(s->b.btns[id].btn_label2, (char *)datad.btnLabel2.str); - s->b.btns_status[id] = datad.btnStatus; - - capn_free(&ctx); - zmq_msg_close(&msg); - } - if (bb_polls[1].revents) { - //custom alert socket - zmq_msg_t msg; - err = zmq_msg_init(&msg); - assert(err == 0); - err = zmq_msg_recv(&msg, s->b.uiCustomAlert_sock_raw, 0); - assert(err >= 0); - - struct capn ctx; - capn_init_mem(&ctx, zmq_msg_data(&msg), zmq_msg_size(&msg), 0); - - cereal_UICustomAlert_ptr stp; - stp.p = capn_getp(capn_root(&ctx), 0, 1); - struct cereal_UICustomAlert datad; - cereal_read_UICustomAlert(&datad, stp); - - strcpy(s->b.custom_message,datad.caText.str); - s->b.custom_message_status = datad.caStatus; - - if ((strlen(s->b.custom_message) > 0) && (strlen(s->scene.alert_text1)==0)){ - if ((!((bb_get_button_status(s,"msg") == 0) && (s->b.custom_message_status<=3))) && (s->vision_connected == true)) { - set_awake(s, true); - } - } - - if ((strlen(s->scene.alert_text1) > 0) || (strlen(s->scene.alert_text2) > 0) ) { - set_awake(s, true); - } - - capn_free(&ctx); - zmq_msg_close(&msg); - // wakeup bg thread since status changed - pthread_cond_signal(&s->bg_cond); - } - if (bb_polls[2].revents) { - //set car model socket - zmq_msg_t msg; - err = zmq_msg_init(&msg); - assert(err == 0); - err = zmq_msg_recv(&msg, s->b.uiSetCar_sock_raw, 0); - assert(err >= 0); - - struct capn ctx; - capn_init_mem(&ctx, zmq_msg_data(&msg), zmq_msg_size(&msg), 0); - - cereal_UISetCar_ptr stp; - stp.p = capn_getp(capn_root(&ctx), 0, 1); - struct cereal_UISetCar datad; - cereal_read_UISetCar(&datad, stp); - - if ((strcmp(s->b.car_model,(char *) datad.icCarName.str) != 0) || (strcmp(s->b.car_folder, (char *) datad.icCarFolder.str) !=0)) { - strcpy(s->b.car_model, (char *) datad.icCarName.str); - strcpy(s->b.car_folder, (char *) datad.icCarFolder.str); - LOGW("Car folder set (%s)", s->b.car_folder); - - if (strcmp(s->b.car_folder,"tesla")==0) { - s->b.img_logo = nvgCreateImage(s->vg, "../assets/img_spinner_comma.png", 1); - s->b.img_logo2 = nvgCreateImage(s->vg, "../assets/img_spinner_comma2.png", 1); - LOGW("Spinning logo set for Tesla"); - } else if (strcmp(s->b.car_folder,"honda")==0) { - s->b.img_logo = nvgCreateImage(s->vg, "../assets/img_spinner_comma.honda.png", 1); - s->b.img_logo2 = nvgCreateImage(s->vg, "../assets/img_spinner_comma.honda2.png", 1); - LOGW("Spinning logo set for Honda"); - } else if (strcmp(s->b.car_folder,"toyota")==0) { - s->b.img_logo = nvgCreateImage(s->vg, "../assets/img_spinner_comma.toyota.png", 1); - s->b.img_logo2 = nvgCreateImage(s->vg, "../assets/img_spinner_comma.toyota2.png", 1); - LOGW("Spinning logo set for Toyota"); - }; - } - if (datad.icShowCar == 1) { - s->b.icShowCar = true; - } else { - s->b.icShowCar = false; - } - if (datad.icShowLogo == 1) { - s->b.icShowLogo = true; - } else { - s->b.icShowLogo = false; - } - capn_free(&ctx); - zmq_msg_close(&msg); - } - if (bb_polls[3].revents) { - // play sound socket - zmq_msg_t msg; - err = zmq_msg_init(&msg); - assert(err == 0); - err = zmq_msg_recv(&msg, s->b.uiPlaySound_sock_raw, 0); - assert(err >= 0); - - struct capn ctx; - capn_init_mem(&ctx, zmq_msg_data(&msg), zmq_msg_size(&msg), 0); - - cereal_UIPlaySound_ptr stp; - stp.p = capn_getp(capn_root(&ctx), 0, 1); - struct cereal_UIPlaySound datad; - cereal_read_UIPlaySound(&datad, stp); - - int snd = datad.sndSound; - // bb_ui_play_sound(s,snd); - - capn_free(&ctx); - zmq_msg_close(&msg); - } - if (bb_polls[4].revents) { - // gps socket - zmq_msg_t msg; - err = zmq_msg_init(&msg); - assert(err == 0); - err = zmq_msg_recv(&msg, s->b.gps_sock_raw, 0); - assert(err >= 0); - - struct capn ctx; - capn_init_mem(&ctx, zmq_msg_data(&msg), zmq_msg_size(&msg), 0); - - cereal_Event_ptr eventp; - eventp.p = capn_getp(capn_root(&ctx), 0, 1); - struct cereal_Event eventd; - cereal_read_Event(&eventd, eventp); - - struct cereal_GpsLocationData datad; - cereal_read_GpsLocationData(&datad, eventd.gpsLocationExternal); - - s->b.gpsAccuracy = datad.accuracy; - if (s->b.gpsAccuracy>100) - { - s->b.gpsAccuracy=99.99; - } - else if (s->b.gpsAccuracy==0) - { - s->b.gpsAccuracy=99.8; - } - capn_free(&ctx); - zmq_msg_close(&msg); - } - if (bb_polls[5].revents) { - //gyro info socket - zmq_msg_t msg; - err = zmq_msg_init(&msg); - assert(err == 0); - err = zmq_msg_recv(&msg, s->b.uiGyroInfo_sock_raw, 0); - assert(err >= 0); - - struct capn ctx; - capn_init_mem(&ctx, zmq_msg_data(&msg), zmq_msg_size(&msg), 0); - - cereal_UIGyroInfo_ptr stp; - stp.p = capn_getp(capn_root(&ctx), 0, 1); - struct cereal_UIGyroInfo datad; - cereal_read_UIGyroInfo(&datad, stp); - s->b.accPitch = datad.accPitch; - s->b.accRoll = datad.accRoll; - s->b.accYaw = datad.accYaw; - s->b.magPitch = datad.magPitch; - s->b.magRoll = datad.magRoll; - s->b.magYaw = datad.magYaw; - s->b.gyroPitch = datad.gyroPitch; - s->b.gyroRoll = datad.gyroRoll; - s->b.gyroYaw = datad.gyroYaw; - - capn_free(&ctx); - zmq_msg_close(&msg); - } - - } -} - - diff --git a/selfdrive/ui/bbui.hpp b/selfdrive/ui/bbui.hpp new file mode 100644 index 00000000000000..1a3042c72f2214 --- /dev/null +++ b/selfdrive/ui/bbui.hpp @@ -0,0 +1,8 @@ +void bb_ui_init(UIState *s); +void bb_ui_preinit(UIState *s); +void ui_draw_infobar(UIState *s); +void bb_ui_draw_UI( UIState *s); +void dashcam( UIState *s, int touch_x, int touch_y ); +bool bb_ui_poll_update( UIState *s); +bool bb_handle_ui_touch( UIState *s, int touch_x, int touch_y); +int bb_get_button_status(UIState *s, char *btn_name); \ No newline at end of file diff --git a/selfdrive/ui/bbuistate.h b/selfdrive/ui/bbuistate.h index adee6c65076005..ac025bb30cdcae 100644 --- a/selfdrive/ui/bbuistate.h +++ b/selfdrive/ui/bbuistate.h @@ -1,3 +1,6 @@ +#pragma once +#include "ui.hpp" + const int touch_timeout = 25; typedef struct UICstmButton { @@ -7,6 +10,15 @@ typedef struct UICstmButton { } UICstmButton; typedef struct BBUIState { + float scr_scale_x; + float scr_scale_y; + int scr_w; + int scr_h; + float scr_device_factor; + float scr_scissor_offset; +#if !defined(QCOM) && !defined(QCOM2) + Display *scr_display; +#endif int touch_last_x; int touch_last_y; bool touch_last; @@ -17,24 +29,19 @@ typedef struct BBUIState { char btns_status[6]; char car_model[40]; char car_folder[20]; - zsock_t *uiButtonInfo_sock; - void *uiButtonInfo_sock_raw; - zsock_t *uiCustomAlert_sock; - void *uiCustomAlert_sock_raw; - zsock_t *uiSetCar_sock; - void *uiSetCar_sock_raw; - zsock_t *uiPlaySound_sock; - void *uiPlaySound_sock_raw; - zsock_t *uiButtonStatus_sock; - void *uiButtonStatus_sock_raw; - zsock_t *gps_sock; - void *gps_sock_raw; - zsock_t *uiGyroInfo_sock; - void *uiGyroInfo_sock_raw; + Context *ctx; + SubSocket *uiButtonInfo_sock; + SubSocket *uiCustomAlert_sock; + SubSocket *uiSetCar_sock; + SubSocket *uiPlaySound_sock; + PubSocket *uiButtonStatus_sock; + SubSocket *gps_sock; + SubSocket *uiGyroInfo_sock; + Poller * poller; int btns_x[6]; int btns_y[6]; int btns_r[6]; - int custom_message_status; + UIStatus custom_message_status; char custom_message[120]; int img_logo; int img_logo2; @@ -62,4 +69,5 @@ typedef struct BBUIState { bool chargingEnabled; uint16_t fanSpeed; bool keepEonOff; + bool recording; } BBUIState; diff --git a/selfdrive/ui/dashcam.cc b/selfdrive/ui/dashcam.cc new file mode 100644 index 00000000000000..4b95435897dc59 --- /dev/null +++ b/selfdrive/ui/dashcam.cc @@ -0,0 +1,330 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "common/util.h" +#include "common/swaglog.h" +#include "common/visionimg.h" +#include "common/utilpp.h" +#include "ui.hpp" +#include "paint.hpp" + +#define CAPTURE_STATE_NONE 0 +#define CAPTURE_STATE_CAPTURING 1 +#define CAPTURE_STATE_NOT_CAPTURING 2 +#define RECORD_INTERVAL 180 // Time in seconds to rotate recordings +#define RECORD_FILES 20 // Number of files to create before looping over + +typedef struct dashcam_element { + int pos_x; + int pos_y; + int width; + int height; +} dashcam_element; + +dashcam_element lock_button; + +int captureState = CAPTURE_STATE_NOT_CAPTURING; +int captureNum = 0; +int start_time = 0; +int elapsed_time = 0; // Time of current recording +char filenames[RECORD_FILES][50]; // Track the filenames so they can be deleted when rotating + +bool lock_current_video = true; // If true save the current video before rotating +bool locked_files[RECORD_FILES]; // Track which files are locked +int lock_image; // Stores reference to the PNG +int files_created = 0; + +void stop_capture() { + if (captureState == CAPTURE_STATE_CAPTURING) { + //printf("Stop capturing screen\n"); + system("killall -SIGINT screenrecord"); + captureState = CAPTURE_STATE_NOT_CAPTURING; + captureNum++; + + if (captureNum > RECORD_FILES-1) { + captureNum = 0; + } + } +} + +int get_time() { + // Get current time (in seconds) + + int iRet; + struct timeval tv; + int seconds = 0; + + iRet = gettimeofday(&tv,NULL); + if (iRet == 0) { + seconds = (int)tv.tv_sec; + } + return seconds; +} + +struct tm get_time_struct() { + time_t t = time(NULL); + struct tm tm = *localtime(&t); + return tm; +} + +void remove_file(char *videos_dir, char *filename) { + if (filename[0] == '\0') { + // Don't do anything if no filename is passed + return; + } + + int status; + char fullpath[64]; + snprintf(fullpath,sizeof(fullpath),"%s/%s", videos_dir, filename); + status = remove(fullpath); + if (status == 0) { + printf("Removed file: %s\n", fullpath); + } + else { + printf("Unable to remove file: %s\n", fullpath); + perror("Error message:"); + } +} + +void save_file(char *videos_dir, char *filename) { + if (!strlen(filename)) { + return; + } + + // Rename file to save it from being overwritten + char cmd[128]; + snprintf(cmd,sizeof(cmd), "mv %s/%s %s/saved_%s", videos_dir, filename, videos_dir, filename); + printf("save: %s\n",cmd); + system(cmd); +} + +void start_capture() { + captureState = CAPTURE_STATE_CAPTURING; + char cmd[50] = ""; + char videos_dir[50] = "/sdcard/videos"; + + ////////////////////////////////// + // NOTE: make sure videos_dir folder exists on the device! + ////////////////////////////////// + struct stat st = {0}; + if (stat(videos_dir, &st) == -1) { + mkdir(videos_dir,0700); + } + + if (strlen(filenames[captureNum]) && files_created >= RECORD_FILES) { + if (locked_files[captureNum] > 0) { + save_file(videos_dir, filenames[captureNum]); + } + else { + // remove the old file + remove_file(videos_dir, filenames[captureNum]); + } + locked_files[captureNum] = 0; + } + + char filename[64]; + struct tm tm = get_time_struct(); + snprintf(filename,sizeof(filename),"%04d%02d%02d-%02d%02d%02d.mp4", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); + snprintf(cmd,sizeof(cmd),"screenrecord %s/%s&",videos_dir,filename); + strcpy(filenames[captureNum],filename); + + printf("Capturing to file: %s\n",cmd); + start_time = get_time(); + system(cmd); + + if (lock_current_video) { + // Lock is still on so mark this file for saving + locked_files[captureNum] = 1; + } + else { + locked_files[captureNum] = 0; + } + + files_created++; +} + +bool screen_lock_button_clicked(int touch_x, int touch_y, dashcam_element el) { + if (captureState == CAPTURE_STATE_NOT_CAPTURING) { + // Don't register click if we're not recording + return false; + } + + if (touch_x >= el.pos_x && touch_x <= el.pos_x + el.width) { + if (touch_y >= el.pos_y && touch_y <= el.pos_y + el.height) { + return true; + } + } + return false; +} + +bool screen_button_clicked(int touch_x, int touch_y) { + if (touch_x >= 1660 && touch_x <= 1810) { + if (touch_y >= 885 && touch_y <= 1035) { + return true; + } + } + return false; +} + +void draw_date_time(UIState *s) { + if (captureState == CAPTURE_STATE_NOT_CAPTURING) { + // Don't draw if we're not recording + return; + } + + // Draw the current date/time + + int rect_w = 465; + int rect_h = 80; + int rect_x = (1920-rect_w)/2; + int rect_y = (1080-rect_h-10); + + // Get local time to display + char now[50]; + struct tm tm = get_time_struct(); + snprintf(now,sizeof(now),"%04d/%02d/%02d %02d:%02d:%02d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); + + nvgBeginPath(s->vg); + nvgRoundedRect(s->vg, rect_x, rect_y, rect_w, rect_h, 15); + nvgFillColor(s->vg, nvgRGBA(0, 0, 0, 100)); + nvgFill(s->vg); + nvgStrokeColor(s->vg, nvgRGBA(255,255,255,80)); + nvgStrokeWidth(s->vg, 6); + nvgStroke(s->vg); + + nvgFontSize(s->vg, 60); + nvgFontFace(s->vg, "sans-semibold"); + nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 200)); + nvgText(s->vg,rect_x+231,rect_y+55,now,NULL); +} + +static void rotate_video() { + // Overwrite the existing video (if needed) + elapsed_time = 0; + stop_capture(); + captureState = CAPTURE_STATE_CAPTURING; + start_capture(); +} + +void draw_lock_button(UIState *s) { + int btn_w = 150; + int btn_h = 150; + int btn_x = 1920 - btn_w - 150; + int btn_y = 1080 - btn_h; + // int imgw, imgh; + + float alpha = 0.3f; + + if (!lock_image) { + // Load the lock icon + lock_image = nvgCreateImage(s->vg, "../assets/lock_icon.png", 1); + } + + if (lock_current_video) { + alpha = 1.0f; + } + + nvgBeginPath(s->vg); + NVGpaint imgPaint = nvgImagePattern(s->vg, btn_x-125, btn_y-45, 150, 150, 0, lock_image, alpha); + nvgRoundedRect(s->vg, btn_x-125, btn_y-45, 150, 150, 100); + nvgFillPaint(s->vg, imgPaint); + nvgFill(s->vg); + + + lock_button = (dashcam_element){ + .pos_x = 1500, + .pos_y = 920, + .width = 150, + .height = 150 + }; +} + +static void screen_draw_button(UIState *s, int touch_x, int touch_y) { + // Set button to bottom left of screen + if (s->vision_connected && s->active_app == cereal::UiLayoutState::App::HOME) { + + if (captureState == CAPTURE_STATE_CAPTURING) { + draw_lock_button(s); + } + + int btn_w = 150; + int btn_h = 150; + int btn_x = 1920 - btn_w; + int btn_y = 1080 - btn_h; + nvgBeginPath(s->vg); + nvgRoundedRect(s->vg, btn_x-110, btn_y-45, btn_w, btn_h, 100); + nvgStrokeColor(s->vg, nvgRGBA(255,255,255,80)); + nvgStrokeWidth(s->vg, 6); + nvgStroke(s->vg); + + nvgFontSize(s->vg, 70); + + if (captureState == CAPTURE_STATE_CAPTURING) { + NVGcolor fillColor = nvgRGBA(255,0,0,150); + nvgFillColor(s->vg, fillColor); + nvgFill(s->vg); + nvgFillColor(s->vg, nvgRGBA(255,255,255,200)); + } + else { + nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 200)); + } + nvgText(s->vg,btn_x-88,btn_y+50,"REC",NULL); + } + + if (captureState == CAPTURE_STATE_CAPTURING) { + //draw_date_time(s); + + elapsed_time = get_time() - start_time; + + if (elapsed_time >= RECORD_INTERVAL) { + rotate_video(); + } + } +} + +void screen_toggle_record_state(UIState *s) { + if (captureState == CAPTURE_STATE_CAPTURING) { + s->b.recording = false; + stop_capture(); + lock_current_video = false; + } + else { + //captureState = CAPTURE_STATE_CAPTURING; + s->b.recording = true; + start_capture(); + } +} + +void screen_toggle_lock() { + if (lock_current_video) { + lock_current_video = false; + } + else { + lock_current_video = true; + locked_files[captureNum] = 1; + } +} + +void dashcam( UIState *s, int touch_x, int touch_y ) { + screen_draw_button(s, touch_x, touch_y); + if (screen_button_clicked(touch_x,touch_y)) { + screen_toggle_record_state(s); + } + if (screen_lock_button_clicked(touch_x,touch_y,lock_button)) { + screen_toggle_lock(); + } + if (!s->vision_connected) { + // Assume car is not in drive so stop recording + s->b.recording = false; + stop_capture(); + } +} diff --git a/selfdrive/ui/dashcam.h b/selfdrive/ui/dashcam.h deleted file mode 100644 index 0e9c40d77dd934..00000000000000 --- a/selfdrive/ui/dashcam.h +++ /dev/null @@ -1,310 +0,0 @@ -#include - -#define CAPTURE_STATE_NONE 0 -#define CAPTURE_STATE_CAPTURING 1 -#define CAPTURE_STATE_NOT_CAPTURING 2 -#define RECORD_INTERVAL 180 // Time in seconds to rotate recordings -#define RECORD_FILES 20 // Number of files to create before looping over - -typedef struct dashcam_element { - int pos_x; - int pos_y; - int width; - int height; -} dashcam_element; - -dashcam_element lock_button; - -int captureState = CAPTURE_STATE_NOT_CAPTURING; -int captureNum = 0; -int start_time = 0; -int elapsed_time = 0; // Time of current recording -char filenames[RECORD_FILES][50]; // Track the filenames so they can be deleted when rotating - -bool lock_current_video = true; // If true save the current video before rotating -bool locked_files[RECORD_FILES]; // Track which files are locked -int lock_image; // Stores reference to the PNG -int files_created = 0; - -void stop_capture() { - if (captureState == CAPTURE_STATE_CAPTURING) { - //printf("Stop capturing screen\n"); - system("killall -SIGINT screenrecord"); - captureState = CAPTURE_STATE_NOT_CAPTURING; - captureNum++; - - if (captureNum > RECORD_FILES-1) { - captureNum = 0; - } - } -} - -int get_time() { - // Get current time (in seconds) - - int iRet; - struct timeval tv; - int seconds = 0; - - iRet = gettimeofday(&tv,NULL); - if (iRet == 0) { - seconds = (int)tv.tv_sec; - } - return seconds; -} - -struct tm get_time_struct() { - time_t t = time(NULL); - struct tm tm = *localtime(&t); - return tm; -} - -void remove_file(char *videos_dir, char *filename) { - if (filename[0] == '\0') { - // Don't do anything if no filename is passed - return; - } - - int status; - char fullpath[64]; - snprintf(fullpath,sizeof(fullpath),"%s/%s", videos_dir, filename); - status = remove(fullpath); - if (status == 0) { - printf("Removed file: %s\n", fullpath); - } - else { - printf("Unable to remove file: %s\n", fullpath); - perror("Error message:"); - } -} - -void save_file(char *videos_dir, char *filename) { - if (!strlen(filename)) { - return; - } - - // Rename file to save it from being overwritten - char cmd[128]; - snprintf(cmd,sizeof(cmd), "mv %s/%s %s/saved_%s", videos_dir, filename, videos_dir, filename); - printf("save: %s\n",cmd); - system(cmd); -} - -void start_capture() { - captureState = CAPTURE_STATE_CAPTURING; - char cmd[50] = ""; - char videos_dir[50] = "/sdcard/videos"; - - ////////////////////////////////// - // NOTE: make sure videos_dir folder exists on the device! - ////////////////////////////////// - struct stat st = {0}; - if (stat(videos_dir, &st) == -1) { - mkdir(videos_dir,0700); - } - - if (strlen(filenames[captureNum]) && files_created >= RECORD_FILES) { - if (locked_files[captureNum] > 0) { - save_file(videos_dir, filenames[captureNum]); - } - else { - // remove the old file - remove_file(videos_dir, filenames[captureNum]); - } - locked_files[captureNum] = 0; - } - - char filename[64]; - struct tm tm = get_time_struct(); - snprintf(filename,sizeof(filename),"%04d%02d%02d-%02d%02d%02d.mp4", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); - snprintf(cmd,sizeof(cmd),"screenrecord %s/%s&",videos_dir,filename); - strcpy(filenames[captureNum],filename); - - printf("Capturing to file: %s\n",cmd); - start_time = get_time(); - system(cmd); - - if (lock_current_video) { - // Lock is still on so mark this file for saving - locked_files[captureNum] = 1; - } - else { - locked_files[captureNum] = 0; - } - - files_created++; -} - -bool screen_lock_button_clicked(int touch_x, int touch_y, dashcam_element el) { - if (captureState == CAPTURE_STATE_NOT_CAPTURING) { - // Don't register click if we're not recording - return false; - } - - if (touch_x >= el.pos_x && touch_x <= el.pos_x + el.width) { - if (touch_y >= el.pos_y && touch_y <= el.pos_y + el.height) { - return true; - } - } - return false; -} - -bool screen_button_clicked(int touch_x, int touch_y) { - if (touch_x >= 1660 && touch_x <= 1810) { - if (touch_y >= 885 && touch_y <= 1035) { - return true; - } - } - return false; -} - -void draw_date_time(UIState *s) { - if (captureState == CAPTURE_STATE_NOT_CAPTURING) { - // Don't draw if we're not recording - return; - } - - // Draw the current date/time - - int rect_w = 465; - int rect_h = 80; - int rect_x = (1920-rect_w)/2; - int rect_y = (1080-rect_h-10); - - // Get local time to display - char now[50]; - struct tm tm = get_time_struct(); - snprintf(now,sizeof(now),"%04d/%02d/%02d %02d:%02d:%02d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); - - nvgBeginPath(s->vg); - nvgRoundedRect(s->vg, rect_x, rect_y, rect_w, rect_h, 15); - nvgFillColor(s->vg, nvgRGBA(0, 0, 0, 100)); - nvgFill(s->vg); - nvgStrokeColor(s->vg, nvgRGBA(255,255,255,80)); - nvgStrokeWidth(s->vg, 6); - nvgStroke(s->vg); - - nvgFontSize(s->vg, 60); - nvgFontFace(s->vg, "sans-semibold"); - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 200)); - nvgText(s->vg,rect_x+231,rect_y+55,now,NULL); -} - -static void rotate_video() { - // Overwrite the existing video (if needed) - elapsed_time = 0; - stop_capture(); - captureState = CAPTURE_STATE_CAPTURING; - start_capture(); -} - -void draw_lock_button(UIState *s) { - int btn_w = 150; - int btn_h = 150; - int btn_x = 1920 - btn_w - 150; - int btn_y = 1080 - btn_h; - int imgw, imgh; - - float alpha = 0.3f; - - if (!lock_image) { - // Load the lock icon - lock_image = nvgCreateImage(s->vg, "../assets/lock_icon.png", 1); - } - - if (lock_current_video) { - alpha = 1.0f; - } - - nvgBeginPath(s->vg); - NVGpaint imgPaint = nvgImagePattern(s->vg, btn_x-125, btn_y-45, 150, 150, 0, lock_image, alpha); - nvgRoundedRect(s->vg, btn_x-125, btn_y-45, 150, 150, 100); - nvgFillPaint(s->vg, imgPaint); - nvgFill(s->vg); - - - lock_button = (dashcam_element){ - .pos_x = 1500, - .pos_y = 920, - .width = 150, - .height = 150 - }; -} - -static void screen_draw_button(UIState *s, int touch_x, int touch_y) { - // Set button to bottom left of screen - if (s->vision_connected && s->plus_state == 0) { - - if (captureState == CAPTURE_STATE_CAPTURING) { - draw_lock_button(s); - } - - int btn_w = 150; - int btn_h = 150; - int btn_x = 1920 - btn_w; - int btn_y = 1080 - btn_h; - nvgBeginPath(s->vg); - nvgRoundedRect(s->vg, btn_x-110, btn_y-45, btn_w, btn_h, 100); - nvgStrokeColor(s->vg, nvgRGBA(255,255,255,80)); - nvgStrokeWidth(s->vg, 6); - nvgStroke(s->vg); - - nvgFontSize(s->vg, 70); - - if (captureState == CAPTURE_STATE_CAPTURING) { - NVGcolor fillColor = nvgRGBA(255,0,0,150); - nvgFillColor(s->vg, fillColor); - nvgFill(s->vg); - nvgFillColor(s->vg, nvgRGBA(255,255,255,200)); - } - else { - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 200)); - } - nvgText(s->vg,btn_x-88,btn_y+50,"REC",NULL); - } - - if (captureState == CAPTURE_STATE_CAPTURING) { - //draw_date_time(s); - - elapsed_time = get_time() - start_time; - - if (elapsed_time >= RECORD_INTERVAL) { - rotate_video(); - } - } -} - -void screen_toggle_record_state() { - if (captureState == CAPTURE_STATE_CAPTURING) { - stop_capture(); - lock_current_video = false; - } - else { - //captureState = CAPTURE_STATE_CAPTURING; - start_capture(); - } -} - -void screen_toggle_lock() { - if (lock_current_video) { - lock_current_video = false; - } - else { - lock_current_video = true; - locked_files[captureNum] = 1; - } -} - -void dashcam( UIState *s, int touch_x, int touch_y ) { - screen_draw_button(s, touch_x, touch_y); - if (screen_button_clicked(touch_x,touch_y)) { - screen_toggle_record_state(); - } - if (screen_lock_button_clicked(touch_x,touch_y,lock_button)) { - screen_toggle_lock(); - } - if (!s->vision_connected) { - // Assume car is not in drive so stop recording - stop_capture(); - } -} \ No newline at end of file diff --git a/selfdrive/ui/dashcam.hpp b/selfdrive/ui/dashcam.hpp new file mode 100644 index 00000000000000..21417484663318 --- /dev/null +++ b/selfdrive/ui/dashcam.hpp @@ -0,0 +1,7 @@ +#pragma once + +void stop_capture(); +void save_file(char *videos_dir, char *filename); +void start_capture(); +void screen_toggle_lock(); +void dashcam( UIState *s, int touch_x, int touch_y ); diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc new file mode 100644 index 00000000000000..69a8ed4cdea9c7 --- /dev/null +++ b/selfdrive/ui/paint.cc @@ -0,0 +1,752 @@ +#include "ui.hpp" +#include +#include +#include +#include +#include "common/util.h" +#include + + +#define NANOVG_GLES3_IMPLEMENTATION +#include "nanovg_gl.h" +#include "nanovg_gl_utils.h" + +extern "C"{ +#include "common/glutil.h" +} + +#include "paint.hpp" +#include "sidebar.hpp" + +// Tesla branch: +static void ui_draw_vision_alert(UIState *s); +void ui_draw_vision_alert_b(UIState *s) { ui_draw_vision_alert(s); } +/* Tesla Branch commented out +// TODO: this is also hardcoded in common/transformations/camera.py +// TODO: choose based on frame input size +#ifdef QCOM2 +const float y_offset = 150.0; +const float zoom = 1.1; +const mat3 intrinsic_matrix = (mat3){{ + 2648.0, 0.0, 1928.0/2, + 0.0, 2648.0, 1208.0/2, + 0.0, 0.0, 1.0 +}}; +#else +const float y_offset = 0.0; +const float zoom = 2.35; +const mat3 intrinsic_matrix = (mat3){{ + 910., 0., 1164.0/2, + 0., 910., 874.0/2, + 0., 0., 1. +}}; +#endif +*/ + +// Projects a point in car to space to the corresponding point in full frame +// image space. +bool car_space_to_full_frame(const UIState *s, float in_x, float in_y, float in_z, float *out_x, float *out_y, float margin=0.0) { + const vec4 car_space_projective = (vec4){{in_x, in_y, in_z, 1.}}; + // We'll call the car space point p. + // First project into normalized image coordinates with the extrinsics matrix. + const vec4 Ep4 = matvecmul(s->scene.extrinsic_matrix, car_space_projective); + + // The last entry is zero because of how we store E (to use matvecmul). + const vec3 Ep = {{Ep4.v[0], Ep4.v[1], Ep4.v[2]}}; + const vec3 KEp = matvecmul3(intrinsic_matrix, Ep); + + // Project. + *out_x = KEp.v[0] / KEp.v[2]; + *out_y = KEp.v[1] / KEp.v[2]; + + return *out_x >= -margin && *out_x <= s->fb_w + margin && *out_y >= -margin && *out_y <= s->fb_h + margin; +} + + +static void ui_draw_text(NVGcontext *vg, float x, float y, const char* string, float size, NVGcolor color, int font){ + nvgFontFaceId(vg, font); + nvgFontSize(vg, size); + nvgFillColor(vg, color); + nvgText(vg, x, y, string, NULL); +} + +static void draw_chevron(UIState *s, float x_in, float y_in, float sz, + NVGcolor fillColor, NVGcolor glowColor) { + float x, y; + if (!car_space_to_full_frame(s, x_in, y_in, 0.0, &x, &y)) { + return; + } + + sz *= 30; + sz /= (x_in / 3 + 30); + if (sz > 30) sz = 30; + if (sz < 15) sz = 15; + + // glow + float g_xo = sz/5; + float g_yo = sz/10; + nvgBeginPath(s->vg); + nvgMoveTo(s->vg, x+(sz*1.35)+g_xo, y+sz+g_yo); + nvgLineTo(s->vg, x, y-g_xo); + nvgLineTo(s->vg, x-(sz*1.35)-g_xo, y+sz+g_yo); + nvgClosePath(s->vg); + nvgFillColor(s->vg, glowColor); + nvgFill(s->vg); + + // chevron + nvgBeginPath(s->vg); + nvgMoveTo(s->vg, x+(sz*1.25), y+sz); + nvgLineTo(s->vg, x, y); + nvgLineTo(s->vg, x-(sz*1.25), y+sz); + nvgClosePath(s->vg); + nvgFillColor(s->vg, fillColor); + nvgFill(s->vg); +} + +static void ui_draw_circle_image(NVGcontext *vg, float x, float y, int size, int image, NVGcolor color, float img_alpha, int img_y = 0) { + const int img_size = size * 1.5; + nvgBeginPath(vg); + nvgCircle(vg, x, y + (bdr_s * 1.5), size); + nvgFillColor(vg, color); + nvgFill(vg); + ui_draw_image(vg, x - (img_size / 2), img_y ? img_y : y - (size / 4), img_size, img_size, image, img_alpha); +} + +static void ui_draw_circle_image(NVGcontext *vg, float x, float y, int size, int image, bool active) { + float bg_alpha = active ? 0.3f : 0.1f; + float img_alpha = active ? 1.0f : 0.15f; + ui_draw_circle_image(vg, x, y, size, image, nvgRGBA(0, 0, 0, (255 * bg_alpha)), img_alpha); +} + +static void draw_lead(UIState *s, const cereal::RadarState::LeadData::Reader &lead){ + // Draw lead car indicator + float fillAlpha = 0; + float speedBuff = 10.; + float leadBuff = 40.; + float d_rel = lead.getDRel(); + float v_rel = lead.getVRel(); + if (d_rel < leadBuff) { + fillAlpha = 255*(1.0-(d_rel/leadBuff)); + if (v_rel < 0) { + fillAlpha += 255*(-1*(v_rel/speedBuff)); + } + fillAlpha = (int)(fmin(fillAlpha, 255)); + } + draw_chevron(s, d_rel, lead.getYRel(), 25, nvgRGBA(201, 34, 49, fillAlpha), COLOR_YELLOW); +} + +static void ui_draw_line(UIState *s, const vertex_data *v, const int cnt, NVGcolor *color, NVGpaint *paint) { + if (cnt == 0) return; + + nvgBeginPath(s->vg); + nvgMoveTo(s->vg, v[0].x, v[0].y); + for (int i = 1; i < cnt; i++) { + nvgLineTo(s->vg, v[i].x, v[i].y); + } + nvgClosePath(s->vg); + if (color) { + nvgFillColor(s->vg, *color); + } else if (paint) { + nvgFillPaint(s->vg, *paint); + } + nvgFill(s->vg); +} + +static void update_track_data(UIState *s, const cereal::ModelDataV2::XYZTData::Reader &line, track_vertices_data *pvd) { + const UIScene *scene = &s->scene; + const float off = 0.5; + int max_idx = 0; + float lead_d; + if (s->sm->updated("radarState")) { + lead_d = scene->lead_data[0].getDRel()*2.; + } else { + lead_d = MAX_DRAW_DISTANCE; + } + float path_length = (lead_d>0.)?lead_d-fmin(lead_d*0.35, 10.):MAX_DRAW_DISTANCE; + path_length = fmin(path_length, scene->max_distance); + + + vertex_data *v = &pvd->v[0]; + const float margin = 500.0f; + for (int i = 0; line.getX()[i] <= path_length and i < TRAJECTORY_SIZE; i++) { + v += car_space_to_full_frame(s, line.getX()[i], -line.getY()[i] - off, -line.getZ()[i], &v->x, &v->y, margin); + max_idx = i; + } + for (int i = max_idx; i >= 0; i--) { + v += car_space_to_full_frame(s, line.getX()[i], -line.getY()[i] + off, -line.getZ()[i], &v->x, &v->y, margin); + } + pvd->cnt = v - pvd->v; +} + +static void ui_draw_track(UIState *s, track_vertices_data *pvd) { + NVGpaint track_bg = nvgLinearGradient(s->vg, s->fb_w, s->fb_h, s->fb_w, s->fb_h * .4, + COLOR_WHITE, COLOR_WHITE_ALPHA(0)); + ui_draw_line(s, &pvd->v[0], pvd->cnt, nullptr, &track_bg); +} + +static void draw_frame(UIState *s) { + mat4 *out_mat; + if (s->scene.frontview) { + glBindVertexArray(s->frame_vao[1]); + out_mat = &s->front_frame_mat; + } else { + glBindVertexArray(s->frame_vao[0]); + out_mat = &s->rear_frame_mat; + } + glActiveTexture(GL_TEXTURE0); + + if (s->stream.last_idx >= 0) { + glBindTexture(GL_TEXTURE_2D, s->frame_texs[s->stream.last_idx]); +#ifndef QCOM + // this is handled in ion on QCOM + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, s->stream.bufs_info.width, s->stream.bufs_info.height, + 0, GL_RGB, GL_UNSIGNED_BYTE, s->priv_hnds[s->stream.last_idx]); +#endif + } + + glUseProgram(s->frame_program); + glUniform1i(s->frame_texture_loc, 0); + glUniformMatrix4fv(s->frame_transform_loc, 1, GL_TRUE, out_mat->v); + + assert(glGetError() == GL_NO_ERROR); + glEnableVertexAttribArray(0); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, (const void*)0); + glDisableVertexAttribArray(0); + glBindVertexArray(0); +} + +static void update_line_data(UIState *s, const cereal::ModelDataV2::XYZTData::Reader &line, float off, line_vertices_data *pvd, float max_distance) { + // TODO check that this doesn't overflow max vertex buffer + int max_idx; + vertex_data *v = &pvd->v[0]; + const float margin = 500.0f; + for (int i = 0; ((i < TRAJECTORY_SIZE) and (line.getX()[i] < fmax(MIN_DRAW_DISTANCE, max_distance))); i++) { + v += car_space_to_full_frame(s, line.getX()[i], -line.getY()[i] - off, -line.getZ()[i] + 1.22, &v->x, &v->y, margin); + max_idx = i; + } + for (int i = max_idx - 1; i > 0; i--) { + v += car_space_to_full_frame(s, line.getX()[i], -line.getY()[i] + off, -line.getZ()[i] + 1.22, &v->x, &v->y, margin); + } + pvd->cnt = v - pvd->v; +} + + +static void ui_draw_vision_lane_lines(UIState *s) { + const UIScene *scene = &s->scene; + + // paint lanelines + line_vertices_data *pvd_ll = &s->lane_line_vertices[0]; + for (int ll_idx = 0; ll_idx < 4; ll_idx++) { + if (s->sm->updated("modelV2")) { + update_line_data(s, scene->model.getLaneLines()[ll_idx], 0.025*scene->model.getLaneLineProbs()[ll_idx], pvd_ll + ll_idx, scene->max_distance); + } + NVGcolor color = nvgRGBAf(1.0, 1.0, 1.0, scene->lane_line_probs[ll_idx]); + ui_draw_line(s, (pvd_ll + ll_idx)->v, (pvd_ll + ll_idx)->cnt, &color, nullptr); + } + + // paint road edges + line_vertices_data *pvd_re = &s->road_edge_vertices[0]; + for (int re_idx = 0; re_idx < 2; re_idx++) { + if (s->sm->updated("modelV2")) { + update_line_data(s, scene->model.getRoadEdges()[re_idx], 0.025, pvd_re + re_idx, scene->max_distance); + } + NVGcolor color = nvgRGBAf(1.0, 0.0, 0.0, std::clamp(1.0-scene->road_edge_stds[re_idx], 0.0, 1.0)); + ui_draw_line(s, (pvd_re + re_idx)->v, (pvd_re + re_idx)->cnt, &color, nullptr); + } + + // paint path + if (s->sm->updated("modelV2")) { + update_track_data(s, scene->model.getPosition(), &s->track_vertices); + } + ui_draw_track(s, &s->track_vertices); +} + +// Draw all world space objects. +static void ui_draw_world(UIState *s) { + const UIScene *scene = &s->scene; + + nvgSave(s->vg); + + // Don't draw on top of sidebar + nvgScissor(s->vg, scene->viz_rect.x, scene->viz_rect.y, scene->viz_rect.w, scene->viz_rect.h); + + // Apply transformation such that video pixel coordinates match video + // 1) Put (0, 0) in the middle of the video + nvgTranslate(s->vg, s->video_rect.x + s->video_rect.w / 2, s->video_rect.y + s->video_rect.h / 2 + y_offset); + + // 2) Apply same scaling as video + nvgScale(s->vg, zoom, zoom); + + // 3) Put (0, 0) in top left corner of video + nvgTranslate(s->vg, -intrinsic_matrix.v[2], -intrinsic_matrix.v[5]); + + // Draw lane edges and vision/mpc tracks + ui_draw_vision_lane_lines(s); + + // Draw lead indicators if openpilot is handling longitudinal + if (s->longitudinal_control) { + if (scene->lead_data[0].getStatus()) { + draw_lead(s, scene->lead_data[0]); + } + if (scene->lead_data[1].getStatus() && (std::abs(scene->lead_data[0].getDRel() - scene->lead_data[1].getDRel()) > 3.0)) { + draw_lead(s, scene->lead_data[1]); + } + } + nvgRestore(s->vg); +} + +static void ui_draw_vision_maxspeed(UIState *s) { + char maxspeed_str[32]; + float maxspeed = s->scene.controls_state.getVCruise(); + int maxspeed_calc = maxspeed * 0.6225 + 0.5; + if (s->is_metric) { + maxspeed_calc = maxspeed + 0.5; + } + + bool is_cruise_set = (maxspeed != 0 && maxspeed != SET_SPEED_NA); + + int viz_maxspeed_w = 184; + int viz_maxspeed_h = 202; + int viz_maxspeed_x = s->scene.viz_rect.x + (bdr_s*2); + int viz_maxspeed_y = s->scene.viz_rect.y + (bdr_s*1.5); + int viz_maxspeed_xo = 180; + + viz_maxspeed_xo = 0; + + // Draw Background + ui_draw_rect(s->vg, viz_maxspeed_x, viz_maxspeed_y, viz_maxspeed_w, viz_maxspeed_h, COLOR_BLACK_ALPHA(100), 30); + + // Draw Border + NVGcolor color = COLOR_WHITE_ALPHA(100); + ui_draw_rect(s->vg, viz_maxspeed_x, viz_maxspeed_y, viz_maxspeed_w, viz_maxspeed_h, color, 20, 10); + + nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_BASELINE); + const int text_x = viz_maxspeed_x + (viz_maxspeed_xo / 2) + (viz_maxspeed_w / 2); + ui_draw_text(s->vg, text_x, 148, "MAX", 26 * 2.5, COLOR_WHITE_ALPHA(is_cruise_set ? 200 : 100), s->font_sans_regular); + + if (is_cruise_set) { + snprintf(maxspeed_str, sizeof(maxspeed_str), "%d", maxspeed_calc); + ui_draw_text(s->vg, text_x, 242, maxspeed_str, 48 * 2.5, COLOR_WHITE, s->font_sans_bold); + } else { + ui_draw_text(s->vg, text_x, 242, "N/A", 42 * 2.5, COLOR_WHITE_ALPHA(100), s->font_sans_semibold); + } +} + +static void ui_draw_vision_speed(UIState *s) { + const Rect &viz_rect = s->scene.viz_rect; + float v_ego = s->scene.controls_state.getVEgo(); + float speed = v_ego * 2.2369363 + 0.5; + if (s->is_metric){ + speed = v_ego * 3.6 + 0.5; + } + const int viz_speed_w = 280; + const int viz_speed_x = viz_rect.centerX() - viz_speed_w/2; + char speed_str[32]; + + nvgBeginPath(s->vg); + nvgRect(s->vg, viz_speed_x, viz_rect.y, viz_speed_w, header_h); + nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_BASELINE); + + snprintf(speed_str, sizeof(speed_str), "%d", (int)speed); + ui_draw_text(s->vg, viz_rect.centerX(), 240, speed_str, 96*2.5, COLOR_WHITE, s->font_sans_bold); + ui_draw_text(s->vg, viz_rect.centerX(), 320, s->is_metric?"km/h":"mph", 36*2.5, COLOR_WHITE_ALPHA(200), s->font_sans_regular); +} + +static void ui_draw_vision_event(UIState *s) { + const int viz_event_w = 220; + const int viz_event_x = s->scene.viz_rect.right() - (viz_event_w + bdr_s*2); + const int viz_event_y = s->scene.viz_rect.y + (bdr_s*1.5); + if (s->scene.controls_state.getDecelForModel() && s->scene.controls_state.getEnabled()) { + // draw winding road sign + const int img_turn_size = 160*1.5; + ui_draw_image(s->vg, viz_event_x - (img_turn_size / 4), viz_event_y + bdr_s - 25, img_turn_size, img_turn_size, s->img_turn, 1.0f); + } else if (s->scene.controls_state.getEngageable()) { + // draw steering wheel + const int bg_wheel_size = 96; + const int bg_wheel_x = viz_event_x + (viz_event_w-bg_wheel_size); + const int bg_wheel_y = viz_event_y + (bg_wheel_size/2); + const NVGcolor color = bg_colors[s->status]; + + ui_draw_circle_image(s->vg, bg_wheel_x, bg_wheel_y, bg_wheel_size, s->img_wheel, color, 1.0f, bg_wheel_y - 25); + } +} + +static void ui_draw_vision_face(UIState *s) { + const int face_size = 96; + const int face_x = (s->scene.viz_rect.x + face_size + (bdr_s * 2)); + const int face_y = (s->scene.viz_rect.bottom() - footer_h + ((footer_h - face_size) / 2)); + ui_draw_circle_image(s->vg, face_x, face_y, face_size, s->img_face, s->scene.dmonitoring_state.getFaceDetected()); +} + +static void ui_draw_driver_view(UIState *s) { + const UIScene *scene = &s->scene; + s->scene.uilayout_sidebarcollapsed = true; + const Rect &viz_rect = s->scene.viz_rect; + const int ff_xoffset = 32; + const int frame_x = viz_rect.x; + const int frame_w = viz_rect.w; + const int valid_frame_w = 4 * viz_rect.h / 3; + const int box_y = viz_rect.y; + const int box_h = viz_rect.h; + const int valid_frame_x = frame_x + (frame_w - valid_frame_w) / 2 + ff_xoffset; + + // blackout + NVGpaint gradient = nvgLinearGradient(s->vg, scene->is_rhd ? valid_frame_x : (valid_frame_x + valid_frame_w), + box_y, + scene->is_rhd ? (valid_frame_w - box_h / 2) : (valid_frame_x + box_h / 2), box_y, + COLOR_BLACK, COLOR_BLACK_ALPHA(0)); + ui_draw_rect(s->vg, scene->is_rhd ? valid_frame_x : (valid_frame_x + box_h / 2), box_y, valid_frame_w - box_h / 2, box_h, gradient); + ui_draw_rect(s->vg, scene->is_rhd ? valid_frame_x : valid_frame_x + box_h / 2, box_y, valid_frame_w - box_h / 2, box_h, COLOR_BLACK_ALPHA(144)); + + // borders + ui_draw_rect(s->vg, frame_x, box_y, valid_frame_x - frame_x, box_h, nvgRGBA(23, 51, 73, 255)); + ui_draw_rect(s->vg, valid_frame_x + valid_frame_w, box_y, frame_w - valid_frame_w - (valid_frame_x - frame_x), box_h, nvgRGBA(23, 51, 73, 255)); + + // draw face box + if (scene->dmonitoring_state.getFaceDetected()) { + auto fxy_list = scene->driver_state.getFacePosition(); + const float face_x = fxy_list[0]; + const float face_y = fxy_list[1]; + float fbox_x; + float fbox_y = box_y + (face_y + 0.5) * box_h - 0.5 * 0.6 * box_h / 2;; + if (!scene->is_rhd) { + fbox_x = valid_frame_x + (1 - (face_x + 0.5)) * (box_h / 2) - 0.5 * 0.6 * box_h / 2; + } else { + fbox_x = valid_frame_x + valid_frame_w - box_h / 2 + (face_x + 0.5) * (box_h / 2) - 0.5 * 0.6 * box_h / 2; + } + + if (std::abs(face_x) <= 0.35 && std::abs(face_y) <= 0.4) { + ui_draw_rect(s->vg, fbox_x, fbox_y, 0.6 * box_h / 2, 0.6 * box_h / 2, + nvgRGBAf(1.0, 1.0, 1.0, 0.8 - ((std::abs(face_x) > std::abs(face_y) ? std::abs(face_x) : std::abs(face_y))) * 0.6 / 0.375), + 35, 10); + } else { + ui_draw_rect(s->vg, fbox_x, fbox_y, 0.6 * box_h / 2, 0.6 * box_h / 2, nvgRGBAf(1.0, 1.0, 1.0, 0.2), 35, 10); + } + } + + // draw face icon + const int face_size = 85; + const int x = (valid_frame_x + face_size + (bdr_s * 2)) + (scene->is_rhd ? valid_frame_w - box_h / 2:0); + const int y = (box_y + box_h - face_size - bdr_s - (bdr_s * 1.5)); + ui_draw_circle_image(s->vg, x, y, face_size, s->img_face, scene->dmonitoring_state.getFaceDetected()); +} + +static void ui_draw_vision_header(UIState *s) { + const Rect &viz_rect = s->scene.viz_rect; + NVGpaint gradient = nvgLinearGradient(s->vg, viz_rect.x, + viz_rect.y+(header_h-(header_h/2.5)), + viz_rect.x, viz_rect.y+header_h, + nvgRGBAf(0,0,0,0.45), nvgRGBAf(0,0,0,0)); + + ui_draw_rect(s->vg, viz_rect.x, viz_rect.y, viz_rect.w, header_h, gradient); + + ui_draw_vision_maxspeed(s); + ui_draw_vision_speed(s); + ui_draw_vision_event(s); +} + +static void ui_draw_vision_footer(UIState *s) { + ui_draw_vision_face(s); +} + +static void ui_draw_vision_alert(UIState *s) { + static std::map alert_size_map = { + {cereal::ControlsState::AlertSize::NONE, 0}, + {cereal::ControlsState::AlertSize::SMALL, 241}, + {cereal::ControlsState::AlertSize::MID, 390}, + {cereal::ControlsState::AlertSize::FULL, s->fb_h}}; + const UIScene *scene = &s->scene; + bool longAlert1 = scene->alert_text1.length() > 15; + + NVGcolor color = bg_colors[s->status]; + color.a *= s->alert_blinking_alpha; + int alr_s = alert_size_map[scene->alert_size]; + + const int alr_x = scene->viz_rect.x - bdr_s; + const int alr_w = scene->viz_rect.w + (bdr_s*2); + const int alr_h = alr_s+(scene->alert_size==cereal::ControlsState::AlertSize::NONE?0:bdr_s); + const int alr_y = s->fb_h-alr_h; + + ui_draw_rect(s->vg, alr_x, alr_y, alr_w, alr_h, color); + + NVGpaint gradient = nvgLinearGradient(s->vg, alr_x, alr_y, alr_x, alr_y+alr_h, + nvgRGBAf(0.0,0.0,0.0,0.05), nvgRGBAf(0.0,0.0,0.0,0.35)); + ui_draw_rect(s->vg, alr_x, alr_y, alr_w, alr_h, gradient); + + nvgFillColor(s->vg, COLOR_WHITE); + nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_BASELINE); + + if (scene->alert_size == cereal::ControlsState::AlertSize::SMALL) { + ui_draw_text(s->vg, alr_x+alr_w/2, alr_y+alr_h/2+15, scene->alert_text1.c_str(), 40*2.5, COLOR_WHITE, s->font_sans_semibold); + } else if (scene->alert_size == cereal::ControlsState::AlertSize::MID) { + ui_draw_text(s->vg, alr_x+alr_w/2, alr_y+alr_h/2-45, scene->alert_text1.c_str(), 48*2.5, COLOR_WHITE, s->font_sans_bold); + ui_draw_text(s->vg, alr_x+alr_w/2, alr_y+alr_h/2+75, scene->alert_text2.c_str(), 36*2.5, COLOR_WHITE, s->font_sans_regular); + } else if (scene->alert_size == cereal::ControlsState::AlertSize::FULL) { + nvgFontSize(s->vg, (longAlert1?72:96)*2.5); + nvgFontFaceId(s->vg, s->font_sans_bold); + nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE); + nvgTextBox(s->vg, alr_x, alr_y+(longAlert1?360:420), alr_w-60, scene->alert_text1.c_str(), NULL); + nvgFontSize(s->vg, 48*2.5); + nvgFontFaceId(s->vg, s->font_sans_regular); + nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_BOTTOM); + nvgTextBox(s->vg, alr_x, alr_h-(longAlert1?300:360), alr_w-60, scene->alert_text2.c_str(), NULL); + } +} + +static void ui_draw_vision_frame(UIState *s) { + const UIScene *scene = &s->scene; + const Rect &viz_rect = scene->viz_rect; + + // Draw video frames + glEnable(GL_SCISSOR_TEST); + glViewport(s->video_rect.x, s->video_rect.y, s->video_rect.w, s->video_rect.h); + glScissor(viz_rect.x, viz_rect.y, viz_rect.w, viz_rect.h); + draw_frame(s); + glDisable(GL_SCISSOR_TEST); + + glViewport(0, 0, s->fb_w, s->fb_h); +} + +static void ui_draw_vision(UIState *s) { + const UIScene *scene = &s->scene; + if (!scene->frontview) { + // Draw augmented elements + if (scene->world_objects_visible) { + ui_draw_world(s); + } + // Set Speed, Current Speed, Status/Events + ui_draw_vision_header(s); + if (scene->alert_size == cereal::ControlsState::AlertSize::NONE) { + ui_draw_vision_footer(s); + } + } else { + ui_draw_driver_view(s); + } +} + +static void ui_draw_background(UIState *s) { + const NVGcolor color = bg_colors[s->status]; + glClearColor(color.r, color.g, color.b, 1.0); + glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); +} + +void ui_draw(UIState *s) { + s->scene.viz_rect = Rect{bdr_s, bdr_s, s->fb_w - 2 * bdr_s, s->fb_h - 2 * bdr_s}; + if (!s->scene.uilayout_sidebarcollapsed) { + s->scene.viz_rect.x += sbr_w; + s->scene.viz_rect.w -= sbr_w; + } + + const bool draw_vision = s->started && s->status != STATUS_OFFROAD && + s->active_app == cereal::UiLayoutState::App::NONE; + + // GL drawing functions + ui_draw_background(s); + if (draw_vision && s->vision_connected) { + ui_draw_vision_frame(s); + } + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glViewport(0, 0, s->fb_w, s->fb_h); + + // NVG drawing functions - should be no GL inside NVG frame + nvgBeginFrame(s->vg, s->fb_w, s->fb_h, 1.0f); + ui_draw_sidebar(s); + if (draw_vision && s->vision_connected) { + ui_draw_vision(s); + } + + if (draw_vision && s->scene.alert_size != cereal::ControlsState::AlertSize::NONE) { + ui_draw_vision_alert(s); + } + nvgEndFrame(s->vg); + glDisable(GL_BLEND); +} + +void ui_draw_image(NVGcontext *vg, float x, float y, float w, float h, int image, float alpha){ + nvgBeginPath(vg); + NVGpaint imgPaint = nvgImagePattern(vg, x, y, w, h, 0, image, alpha); + nvgRect(vg, x, y, w, h); + nvgFillPaint(vg, imgPaint); + nvgFill(vg); +} + +void ui_draw_rect(NVGcontext *vg, float x, float y, float w, float h, NVGcolor color, float r, int width) { + nvgBeginPath(vg); + r > 0 ? nvgRoundedRect(vg, x, y, w, h, r) : nvgRect(vg, x, y, w, h); + if (width) { + nvgStrokeColor(vg, color); + nvgStrokeWidth(vg, width); + nvgStroke(vg); + } else { + nvgFillColor(vg, color); + nvgFill(vg); + } +} + +void ui_draw_rect(NVGcontext *vg, float x, float y, float w, float h, NVGpaint &paint, float r){ + nvgBeginPath(vg); + r > 0? nvgRoundedRect(vg, x, y, w, h, r) : nvgRect(vg, x, y, w, h); + nvgFillPaint(vg, paint); + nvgFill(vg); +} + +static const char frame_vertex_shader[] = +#ifdef NANOVG_GL3_IMPLEMENTATION + "#version 150 core\n" +#else + "#version 300 es\n" +#endif + "in vec4 aPosition;\n" + "in vec4 aTexCoord;\n" + "uniform mat4 uTransform;\n" + "out vec4 vTexCoord;\n" + "void main() {\n" + " gl_Position = uTransform * aPosition;\n" + " vTexCoord = aTexCoord;\n" + "}\n"; + +static const char frame_fragment_shader[] = +#ifdef NANOVG_GL3_IMPLEMENTATION + "#version 150 core\n" +#else + "#version 300 es\n" +#endif + "precision mediump float;\n" + "uniform sampler2D uTexture;\n" + "in vec4 vTexCoord;\n" + "out vec4 colorOut;\n" + "void main() {\n" + " colorOut = texture(uTexture, vTexCoord.xy);\n" + "}\n"; + +static const mat4 device_transform = {{ + 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0, +}}; + +// frame from 4/3 to 16/9 display +static const mat4 full_to_wide_frame_transform = {{ + .75, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0, +}}; + +void ui_nvg_init(UIState *s) { + // init drawing +#ifdef QCOM + // on QCOM, we enable MSAA + s->vg = nvgCreate(0); +#else + s->vg = nvgCreate(NVG_ANTIALIAS | NVG_STENCIL_STROKES | NVG_DEBUG); +#endif + + assert(s->vg); + + s->font_sans_regular = nvgCreateFont(s->vg, "sans-regular", "../assets/fonts/opensans_regular.ttf"); + assert(s->font_sans_regular >= 0); + s->font_sans_semibold = nvgCreateFont(s->vg, "sans-semibold", "../assets/fonts/opensans_semibold.ttf"); + assert(s->font_sans_semibold >= 0); + s->font_sans_bold = nvgCreateFont(s->vg, "sans-bold", "../assets/fonts/opensans_bold.ttf"); + assert(s->font_sans_bold >= 0); + + s->img_wheel = nvgCreateImage(s->vg, "../assets/img_chffr_wheel.png", 1); + assert(s->img_wheel != 0); + s->img_turn = nvgCreateImage(s->vg, "../assets/img_trafficSign_turn.png", 1); + assert(s->img_turn != 0); + s->img_face = nvgCreateImage(s->vg, "../assets/img_driver_face.png", 1); + assert(s->img_face != 0); + s->img_button_settings = nvgCreateImage(s->vg, "../assets/images/button_settings.png", 1); + assert(s->img_button_settings != 0); + s->img_button_home = nvgCreateImage(s->vg, "../assets/images/button_home.png", 1); + assert(s->img_button_home != 0); + s->img_battery = nvgCreateImage(s->vg, "../assets/images/battery.png", 1); + assert(s->img_battery != 0); + s->img_battery_charging = nvgCreateImage(s->vg, "../assets/images/battery_charging.png", 1); + assert(s->img_battery_charging != 0); + + for(int i=0;i<=5;++i) { + char network_asset[32]; + snprintf(network_asset, sizeof(network_asset), "../assets/images/network_%d.png", i); + s->img_network[i] = nvgCreateImage(s->vg, network_asset, 1); + assert(s->img_network[i] != 0); + } + + // init gl + s->frame_program = load_program(frame_vertex_shader, frame_fragment_shader); + assert(s->frame_program); + + s->frame_pos_loc = glGetAttribLocation(s->frame_program, "aPosition"); + s->frame_texcoord_loc = glGetAttribLocation(s->frame_program, "aTexCoord"); + + s->frame_texture_loc = glGetUniformLocation(s->frame_program, "uTexture"); + s->frame_transform_loc = glGetUniformLocation(s->frame_program, "uTransform"); + + glViewport(0, 0, s->fb_w, s->fb_h); + + glDisable(GL_DEPTH_TEST); + + assert(glGetError() == GL_NO_ERROR); + + for(int i = 0; i < 2; i++) { + float x1, x2, y1, y2; + if (i == 1) { + // flip horizontally so it looks like a mirror + x1 = 0.0; + x2 = 1.0; + y1 = 1.0; + y2 = 0.0; + } else { + x1 = 1.0; + x2 = 0.0; + y1 = 1.0; + y2 = 0.0; + } + const uint8_t frame_indicies[] = {0, 1, 2, 0, 2, 3}; + const float frame_coords[4][4] = { + {-1.0, -1.0, x2, y1}, //bl + {-1.0, 1.0, x2, y2}, //tl + { 1.0, 1.0, x1, y2}, //tr + { 1.0, -1.0, x1, y1}, //br + }; + + glGenVertexArrays(1, &s->frame_vao[i]); + glBindVertexArray(s->frame_vao[i]); + glGenBuffers(1, &s->frame_vbo[i]); + glBindBuffer(GL_ARRAY_BUFFER, s->frame_vbo[i]); + glBufferData(GL_ARRAY_BUFFER, sizeof(frame_coords), frame_coords, GL_STATIC_DRAW); + glEnableVertexAttribArray(s->frame_pos_loc); + glVertexAttribPointer(s->frame_pos_loc, 2, GL_FLOAT, GL_FALSE, + sizeof(frame_coords[0]), (const void *)0); + glEnableVertexAttribArray(s->frame_texcoord_loc); + glVertexAttribPointer(s->frame_texcoord_loc, 2, GL_FLOAT, GL_FALSE, + sizeof(frame_coords[0]), (const void *)(sizeof(float) * 2)); + glGenBuffers(1, &s->frame_ibo[i]); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s->frame_ibo[i]); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(frame_indicies), frame_indicies, GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER,0); + glBindVertexArray(0); + } + + s->video_rect = Rect{bdr_s, bdr_s, s->fb_w - 2 * bdr_s, s->fb_h - 2 * bdr_s}; + float zx = zoom * 2 * intrinsic_matrix.v[2] / s->video_rect.w; + float zy = zoom * 2 * intrinsic_matrix.v[5] / s->video_rect.h; + + const mat4 frame_transform = {{ + zx, 0.0, 0.0, 0.0, + 0.0, zy, 0.0, -y_offset / s->video_rect.h * 2, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0, + }}; + + s->front_frame_mat = matmul(device_transform, full_to_wide_frame_transform); + s->rear_frame_mat = matmul(device_transform, frame_transform); + + for(int i = 0; i < UI_BUF_COUNT; i++) { + s->khr[i] = 0; + s->priv_hnds[i] = NULL; + } +} diff --git a/selfdrive/ui/paint.hpp b/selfdrive/ui/paint.hpp new file mode 100644 index 00000000000000..203beef1723686 --- /dev/null +++ b/selfdrive/ui/paint.hpp @@ -0,0 +1,8 @@ +#pragma once +#include "ui.hpp" + +void ui_draw(UIState *s); +void ui_draw_image(NVGcontext *vg, float x, float y, float w, float h, int image, float alpha); +void ui_draw_rect(NVGcontext *vg, float x, float y, float w, float h, NVGcolor color, float r = 0, int width = 0); +void ui_draw_rect(NVGcontext *vg, float x, float y, float w, float h, NVGpaint &paint, float r = 0); +void ui_nvg_init(UIState *s); diff --git a/selfdrive/ui/qt/home.cc b/selfdrive/ui/qt/home.cc new file mode 100644 index 00000000000000..bc402eec8ceb57 --- /dev/null +++ b/selfdrive/ui/qt/home.cc @@ -0,0 +1,288 @@ +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "common/params.h" + +#include "home.hpp" +#include "paint.hpp" +#include "qt_window.hpp" + +#define BACKLIGHT_DT 0.25 +#define BACKLIGHT_TS 2.00 + + +OffroadHome::OffroadHome(QWidget *parent) : QWidget(parent) { + QVBoxLayout *main_layout = new QVBoxLayout(); + main_layout->setContentsMargins(sbr_w + 50, 50, 50, 50); + + center_layout = new QStackedLayout(); + + // header + QHBoxLayout *header_layout = new QHBoxLayout(); + + date = new QLabel(); + date->setStyleSheet(R"(font-size: 55px;)"); + header_layout->addWidget(date, 0, Qt::AlignTop | Qt::AlignLeft); + + QLabel *version = new QLabel(QString::fromStdString("openpilot v" + Params().get("Version"))); + version->setStyleSheet(R"(font-size: 45px;)"); + header_layout->addWidget(version, 0, Qt::AlignTop | Qt::AlignRight); + + main_layout->addLayout(header_layout); + + alert_notification = new QPushButton(); + QObject::connect(alert_notification, SIGNAL(released()), this, SLOT(openAlerts())); + main_layout->addWidget(alert_notification, 0, Qt::AlignTop | Qt::AlignRight); + + // center + QLabel *drive = new QLabel("Drive me"); + drive->setStyleSheet(R"(font-size: 175px;)"); + center_layout->addWidget(drive); + + alerts_widget = new OffroadAlert(); + QObject::connect(alerts_widget, SIGNAL(closeAlerts()), this, SLOT(closeAlerts())); + center_layout->addWidget(alerts_widget); + center_layout->setAlignment(alerts_widget, Qt::AlignCenter); + + main_layout->addLayout(center_layout, 1); + + // set up refresh timer + timer = new QTimer(this); + QObject::connect(timer, SIGNAL(timeout()), this, SLOT(refresh())); + refresh(); + timer->start(10 * 1000); + + setLayout(main_layout); + setStyleSheet(R"(background-color: none;)"); +} + +void OffroadHome::openAlerts() { + center_layout->setCurrentIndex(1); +} + +void OffroadHome::closeAlerts() { + center_layout->setCurrentIndex(0); +} + +void OffroadHome::refresh() { + bool first_refresh = !date->text().size(); + if (!isVisible() && !first_refresh) { + return; + } + + date->setText(QDateTime::currentDateTime().toString("dddd, MMMM d")); + + // update alerts + + alerts_widget->refresh(); + if (!alerts_widget->alerts.size() && !alerts_widget->updateAvailable) { + alert_notification->setVisible(false); + return; + } + + if (alerts_widget->updateAvailable) { + // There is a new release + alert_notification->setText("UPDATE"); + } else { + int alerts = alerts_widget->alerts.size(); + alert_notification->setText(QString::number(alerts) + " ALERT" + (alerts == 1 ? "" : "S")); + } + + alert_notification->setVisible(true); + + // Red background for alerts, blue for update available + QString style = QString(R"( + padding: 15px; + padding-left: 30px; + padding-right: 30px; + border: 1px solid; + border-radius: 5px; + font-size: 40px; + font-weight: bold; + background-color: red; + )"); + if (alerts_widget->updateAvailable){ + style.replace("red", "blue"); + } + alert_notification->setStyleSheet(style); +} + + +HomeWindow::HomeWindow(QWidget *parent) : QWidget(parent) { + layout = new QGridLayout; + layout->setMargin(0); + + // onroad UI + glWindow = new GLWindow(this); + layout->addWidget(glWindow, 0, 0); + + // draw offroad UI on top of onroad UI + home = new OffroadHome(); + layout->addWidget(home, 0, 0); + QObject::connect(glWindow, SIGNAL(offroadTransition(bool)), this, SLOT(setVisibility(bool))); + QObject::connect(this, SIGNAL(openSettings()), home, SLOT(refresh())); + setLayout(layout); + setStyleSheet(R"( + * { + color: white; + } + )"); +} + +void HomeWindow::setVisibility(bool offroad) { + home->setVisible(offroad); +} + +void HomeWindow::mousePressEvent(QMouseEvent *e) { + UIState *ui_state = glWindow->ui_state; + + glWindow->wake(); + + // Settings button click + if (!ui_state->scene.uilayout_sidebarcollapsed && settings_btn.ptInRect(e->x(), e->y())) { + emit openSettings(); + } + + // Vision click + if (ui_state->started && (e->x() >= ui_state->scene.viz_rect.x - bdr_s)) { + ui_state->scene.uilayout_sidebarcollapsed = !ui_state->scene.uilayout_sidebarcollapsed; + } +} + + +static void handle_display_state(UIState *s, int dt, bool user_input) { + static int awake_timeout = 0; + awake_timeout = std::max(awake_timeout-dt, 0); + + if (user_input || s->ignition || s->started) { + s->awake = true; + awake_timeout = 30*UI_FREQ; + } else if (awake_timeout == 0) { + s->awake = false; + } +} + +static void set_backlight(int brightness) { + std::ofstream brightness_control("/sys/class/backlight/panel0-backlight/brightness"); + if (brightness_control.is_open()) { + brightness_control << brightness << "\n"; + brightness_control.close(); + } +} + + +GLWindow::GLWindow(QWidget *parent) : QOpenGLWidget(parent) { + timer = new QTimer(this); + QObject::connect(timer, SIGNAL(timeout()), this, SLOT(timerUpdate())); + + backlight_timer = new QTimer(this); + QObject::connect(backlight_timer, SIGNAL(timeout()), this, SLOT(backlightUpdate())); + + int result = read_param(&brightness_b, "BRIGHTNESS_B", true); + result += read_param(&brightness_m, "BRIGHTNESS_M", true); + if (result != 0) { + brightness_b = 200.0; + brightness_m = 10.0; + } + smooth_brightness = 512; +} + +GLWindow::~GLWindow() { + makeCurrent(); + doneCurrent(); +} + +void GLWindow::initializeGL() { + initializeOpenGLFunctions(); + std::cout << "OpenGL version: " << glGetString(GL_VERSION) << std::endl; + std::cout << "OpenGL vendor: " << glGetString(GL_VENDOR) << std::endl; + std::cout << "OpenGL renderer: " << glGetString(GL_RENDERER) << std::endl; + std::cout << "OpenGL language version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl; + + ui_state = new UIState(); + ui_state->sound = &sound; + ui_state->fb_w = vwp_w; + ui_state->fb_h = vwp_h; + ui_init(ui_state); + + wake(); + + timer->start(0); + backlight_timer->start(BACKLIGHT_DT * 100); +} + +void GLWindow::backlightUpdate() { + // Update brightness + float k = (BACKLIGHT_DT / BACKLIGHT_TS) / (1.0f + BACKLIGHT_DT / BACKLIGHT_TS); + + float clipped_brightness = std::min(1023.0f, (ui_state->light_sensor*brightness_m) + brightness_b); + smooth_brightness = clipped_brightness * k + smooth_brightness * (1.0f - k); + int brightness = smooth_brightness; + + if (!ui_state->awake) { + brightness = 0; + } + + std::thread{set_backlight, brightness}.detach(); +} + +void GLWindow::timerUpdate() { + if (ui_state->started != onroad) { + onroad = ui_state->started; + emit offroadTransition(!onroad); +#ifdef QCOM2 + timer->setInterval(onroad ? 0 : 1000); +#endif + } + + // Fix awake timeout if running 1 Hz when offroad + int dt = timer->interval() == 0 ? 1 : 20; + handle_display_state(ui_state, dt, false); + + ui_update(ui_state); + repaint(); +} + +void GLWindow::resizeGL(int w, int h) { + std::cout << "resize " << w << "x" << h << std::endl; +} + +void GLWindow::paintGL() { + ui_draw(ui_state); +} + +void GLWindow::wake() { + // UI state might not be initialized yet + if (ui_state != nullptr) { + handle_display_state(ui_state, 1, true); + } +} + +GLuint visionimg_to_gl(const VisionImg *img, EGLImageKHR *pkhr, void **pph) { + unsigned int texture; + glGenTextures(1, &texture); + glBindTexture(GL_TEXTURE_2D, texture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, img->width, img->height, 0, GL_RGB, GL_UNSIGNED_BYTE, *pph); + glGenerateMipmap(GL_TEXTURE_2D); + *pkhr = (EGLImageKHR)1; // not NULL + return texture; +} + +void visionimg_destroy_gl(EGLImageKHR khr, void *ph) { + // empty +} + +FramebufferState* framebuffer_init(const char* name, int32_t layer, int alpha, + int *out_w, int *out_h) { + return (FramebufferState*)1; // not null +} diff --git a/selfdrive/ui/qt/home.hpp b/selfdrive/ui/qt/home.hpp new file mode 100644 index 00000000000000..5f71e0e4f654ef --- /dev/null +++ b/selfdrive/ui/qt/home.hpp @@ -0,0 +1,99 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "qt_sound.hpp" +#include "widgets/offroad_alerts.hpp" +#include "ui/ui.hpp" + + +// container window for onroad NVG UI +class GLWindow : public QOpenGLWidget, protected QOpenGLFunctions { + Q_OBJECT + +public: + using QOpenGLWidget::QOpenGLWidget; + explicit GLWindow(QWidget *parent = 0); + void wake(); + ~GLWindow(); + + UIState *ui_state = nullptr; + +signals: + void offroadTransition(bool offroad); + +protected: + void initializeGL() override; + void resizeGL(int w, int h) override; + void paintGL() override; + +private: + QTimer *timer; + QTimer *backlight_timer; + + QtSound sound; + + bool onroad = true; + + // TODO: this shouldn't be here + float brightness_b = 0; + float brightness_m = 0; + float smooth_brightness = 0; + +public slots: + void timerUpdate(); + void backlightUpdate(); +}; + +// offroad home screen +class OffroadHome : public QWidget { + Q_OBJECT + +public: + explicit OffroadHome(QWidget *parent = 0); + +private: + QTimer *timer; + + // offroad home screen widgets + QLabel *date; + QStackedLayout *center_layout; + OffroadAlert *alerts_widget; + QPushButton *alert_notification; + +public slots: + void closeAlerts(); + void openAlerts(); + void refresh(); +}; + + +class HomeWindow : public QWidget { + Q_OBJECT + +public: + explicit HomeWindow(QWidget *parent = 0); + GLWindow *glWindow; + +signals: + void openSettings(); + +protected: + void mousePressEvent(QMouseEvent *e) override; + +private: + QGridLayout *layout; + OffroadHome *home; + +private slots: + void setVisibility(bool offroad); +}; + diff --git a/selfdrive/ui/qt/offroad/onboarding.cc b/selfdrive/ui/qt/offroad/onboarding.cc new file mode 100644 index 00000000000000..697dea4278fb09 --- /dev/null +++ b/selfdrive/ui/qt/offroad/onboarding.cc @@ -0,0 +1,112 @@ +#include +#include +#include +#include +#include + +#include "onboarding.hpp" +#include "common/params.h" + + +QLabel * title_label(QString text) { + QLabel *l = new QLabel(text); + l->setStyleSheet(R"(font-size: 100px;)"); + return l; +} + +QWidget * OnboardingWindow::terms_screen() { + + QGridLayout *main_layout = new QGridLayout(); + main_layout->setMargin(30); + main_layout->setSpacing(30); + + main_layout->addWidget(title_label("Review Terms"), 0, 0, 1, -1); + + QLabel *terms = new QLabel("See terms at https://my.comma.ai/terms"); + terms->setAlignment(Qt::AlignCenter); + terms->setStyleSheet(R"( + font-size: 75px; + border-radius: 10px; + background-color: #292929; + )"); + main_layout->addWidget(terms, 1, 0, 1, -1); + main_layout->setRowStretch(1, 1); + + QPushButton *accept_btn = new QPushButton("Accept"); + main_layout->addWidget(accept_btn, 2, 1); + QObject::connect(accept_btn, &QPushButton::released, [=]() { + Params().write_db_value("HasAcceptedTerms", LATEST_TERMS_VERSION); + updateActiveScreen(); + }); + + main_layout->addWidget(new QPushButton("Decline"), 2, 0); + + QWidget *widget = new QWidget; + widget->setLayout(main_layout); + widget->setStyleSheet(R"( + QPushButton { + font-size: 50px; + padding: 50px; + border-radius: 10px; + background-color: #292929; + } + )"); + + return widget; +} + +QWidget * OnboardingWindow::training_screen() { + + QVBoxLayout *main_layout = new QVBoxLayout(); + main_layout->setMargin(30); + main_layout->setSpacing(30); + + main_layout->addWidget(title_label("Training Guide")); + + main_layout->addWidget(new QLabel(), 1); // just a spacer + + QPushButton *btn = new QPushButton("Continue"); + main_layout->addWidget(btn); + QObject::connect(btn, &QPushButton::released, [=]() { + Params().write_db_value("CompletedTrainingVersion", LATEST_TRAINING_VERSION); + updateActiveScreen(); + }); + + QWidget *widget = new QWidget; + widget->setLayout(main_layout); + return widget; +} + +void OnboardingWindow::updateActiveScreen() { + + Params params = Params(); + bool accepted_terms = params.get("HasAcceptedTerms", false).compare(LATEST_TERMS_VERSION) == 0; + bool training_done = params.get("CompletedTrainingVersion", false).compare(LATEST_TRAINING_VERSION) == 0; + + if (!accepted_terms) { + setCurrentIndex(0); + } else if (!training_done) { + setCurrentIndex(1); + } else { + emit onboardingDone(); + } +} + +OnboardingWindow::OnboardingWindow(QWidget *parent) { + addWidget(terms_screen()); + addWidget(training_screen()); + + setStyleSheet(R"( + * { + background-color: black; + } + QPushButton { + font-size: 50px; + padding: 50px; + border-radius: 10px; + background-color: #292929; + } + )"); + + updateActiveScreen(); +} diff --git a/selfdrive/ui/qt/offroad/onboarding.hpp b/selfdrive/ui/qt/offroad/onboarding.hpp new file mode 100644 index 00000000000000..9e4aabeb750713 --- /dev/null +++ b/selfdrive/ui/qt/offroad/onboarding.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include +#include + +// TODO: this is defined in python too +#define LATEST_TERMS_VERSION "2" +#define LATEST_TRAINING_VERSION "0.2.0" + +class OnboardingWindow : public QStackedWidget { + Q_OBJECT + +public: + explicit OnboardingWindow(QWidget *parent = 0); + +private: + QWidget * terms_screen(); + QWidget * training_screen(); + +signals: + void onboardingDone(); + +public slots: + void updateActiveScreen(); +}; diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc new file mode 100644 index 00000000000000..4e650a0c4e1548 --- /dev/null +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -0,0 +1,283 @@ +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "wifi.hpp" +#include "settings.hpp" +#include "widgets/toggle.hpp" +#include "widgets/offroad_alerts.hpp" + +#include "common/params.h" +#include "common/utilpp.h" + + +ParamsToggle::ParamsToggle(QString param, QString title, QString description, QString icon_path, QWidget *parent): QFrame(parent) , param(param) { + QHBoxLayout *hlayout = new QHBoxLayout; + + // Parameter image + hlayout->addSpacing(25); + if (icon_path.length()) { + QPixmap pix(icon_path); + QLabel *icon = new QLabel(); + icon->setPixmap(pix.scaledToWidth(100, Qt::SmoothTransformation)); + icon->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + hlayout->addWidget(icon); + } else { + hlayout->addSpacing(100); + } + hlayout->addSpacing(25); + + // Name of the parameter + QLabel *label = new QLabel(title); + label->setWordWrap(true); + + // toggle switch + Toggle* toggle_switch = new Toggle(this); + toggle_switch->setFixedSize(150, 100); + + // TODO: show descriptions on tap + hlayout->addWidget(label); + hlayout->addSpacing(50); + hlayout->addWidget(toggle_switch); + hlayout->addSpacing(20); + + setLayout(hlayout); + if (Params().read_db_bool(param.toStdString().c_str())) { + toggle_switch->togglePosition(); + } + + setStyleSheet(R"( + QLabel { + font-size: 50px; + } + * { + background-color: #114265; + } + )"); + + QObject::connect(toggle_switch, SIGNAL(stateChanged(int)), this, SLOT(checkboxClicked(int))); +} + +void ParamsToggle::checkboxClicked(int state) { + char value = state ? '1': '0'; + Params().write_db_value(param.toStdString().c_str(), &value, 1); +} + +QWidget * toggles_panel() { + + QVBoxLayout *toggles_list = new QVBoxLayout(); + toggles_list->setSpacing(25); + + toggles_list->addWidget(new ParamsToggle("OpenpilotEnabledToggle", + "Enable Openpilot", + "Use the openpilot system for adaptive cruise control and lane keep driver assistance. Your attention is required at all times to use this feature. Changing this setting takes effect when the car is powered off.", + "../assets/offroad/icon_openpilot.png" + )); + toggles_list->addWidget(new ParamsToggle("LaneChangeEnabled", + "Enable Lane Change Assist", + "Perform assisted lane changes with openpilot by checking your surroundings for safety, activating the turn signal and gently nudging the steering wheel towards your desired lane. openpilot is not capable of checking if a lane change is safe. You must continuously observe your surroundings to use this feature.", + "../assets/offroad/icon_road.png" + )); + toggles_list->addWidget(new ParamsToggle("IsLdwEnabled", + "Enable Lane Departure Warnings", + "Receive alerts to steer back into the lane when your vehicle drifts over a detected lane line without a turn signal activated while driving over 31mph (50kph).", + "../assets/offroad/icon_warning.png" + )); + toggles_list->addWidget(new ParamsToggle("RecordFront", + "Record and Upload Driver Camera", + "Upload data from the driver facing camera and help improve the driver monitoring algorithm.", + "../assets/offroad/icon_network.png" + )); + toggles_list->addWidget(new ParamsToggle("IsRHD", + "Enable Right-Hand Drive", + "Allow openpilot to obey left-hand traffic conventions and perform driver monitoring on right driver seat.", + "../assets/offroad/icon_openpilot_mirrored.png" + )); + toggles_list->addWidget(new ParamsToggle("IsMetric", + "Use Metric System", + "Display speed in km/h instead of mp/h.", + "../assets/offroad/icon_metric.png" + )); + toggles_list->addWidget(new ParamsToggle("CommunityFeaturesToggle", + "Enable Community Features", + "Use features from the open source community that are not maintained or supported by comma.ai and have not been confirmed to meet the standard safety model. These features include community supported cars and community supported hardware. Be extra cautious when using these features", + "../assets/offroad/icon_shell.png" + )); + + QWidget *widget = new QWidget; + widget->setLayout(toggles_list); + return widget; +} + +QWidget * device_panel() { + + QVBoxLayout *device_layout = new QVBoxLayout; + device_layout->setSpacing(50); + + Params params = Params(); + std::vector> labels = { + {"Dongle ID", params.get("DongleId", false)}, + //{"Serial Number", "abcdefghijk"}, + }; + + for (auto l : labels) { + QString text = QString::fromStdString(l.first + ": " + l.second); + device_layout->addWidget(new QLabel(text)); + } + + QPushButton *clear_cal_btn = new QPushButton("Reset Calibration"); + device_layout->addWidget(clear_cal_btn); + QObject::connect(clear_cal_btn, &QPushButton::released, [=]() { + Params().delete_db_value("CalibrationParams"); + }); + + std::map power_btns = { + {"Power Off", "sudo poweroff"}, + {"Reboot", "sudo reboot"}, + }; + + for (auto b : power_btns) { + QPushButton *btn = new QPushButton(QString::fromStdString(b.first)); + device_layout->addWidget(btn); +#ifdef __aarch64__ + QObject::connect(btn, &QPushButton::released, + [=]() {std::system(b.second);}); +#endif + } + + QWidget *widget = new QWidget; + widget->setLayout(device_layout); + widget->setStyleSheet(R"( + QPushButton { + padding: 60px; + } + )"); + return widget; +} + +QWidget * developer_panel() { + QVBoxLayout *main_layout = new QVBoxLayout; + + // TODO: enable SSH toggle and github keys + + Params params = Params(); + std::string brand = params.read_db_bool("Passive") ? "dashcam" : "openpilot"; + std::vector> labels = { + {"Version", brand + " v" + params.get("Version", false)}, + {"Git Branch", params.get("GitBranch", false)}, + {"Git Commit", params.get("GitCommit", false).substr(0, 10)}, + {"Panda Firmware", params.get("PandaFirmwareHex", false)}, + }; + + std::string os_version = util::read_file("/VERSION"); + if (os_version.size()) { + labels.push_back({"OS Version", "AGNOS " + os_version}); + } + + for (auto l : labels) { + QString text = QString::fromStdString(l.first + ": " + l.second); + main_layout->addWidget(new QLabel(text)); + } + + QWidget *widget = new QWidget; + widget->setLayout(main_layout); + widget->setStyleSheet(R"( + QLabel { + font-size: 50px; + } + )"); + return widget; +} + +QWidget * network_panel(QWidget * parent) { + WifiUI *w = new WifiUI(); + QObject::connect(w, SIGNAL(openKeyboard()), parent, SLOT(closeSidebar())); + QObject::connect(w, SIGNAL(closeKeyboard()), parent, SLOT(openSidebar())); + return w; +} + + +void SettingsWindow::setActivePanel() { + QPushButton *btn = qobject_cast(sender()); + panel_layout->setCurrentWidget(panels[btn->text()]); +} + +SettingsWindow::SettingsWindow(QWidget *parent) : QWidget(parent) { + // sidebar + QVBoxLayout *sidebar_layout = new QVBoxLayout(); + panel_layout = new QStackedLayout(); + + // close button + QPushButton *close_button = new QPushButton("X"); + close_button->setStyleSheet(R"( + QPushButton { + padding: 50px; + font-weight: bold; + font-size: 100px; + } + )"); + sidebar_layout->addWidget(close_button); + QObject::connect(close_button, SIGNAL(released()), this, SIGNAL(closeSettings())); + + // setup panels + panels = { + {"developer", developer_panel()}, + {"device", device_panel()}, + {"network", network_panel(this)}, + {"toggles", toggles_panel()}, + }; + + for (auto &panel : panels) { + QPushButton *btn = new QPushButton(panel.first); + btn->setStyleSheet(R"( + QPushButton { + padding-top: 35px; + padding-bottom: 35px; + font-size: 60px; + text-align: right; + border: none; + background: none; + font-weight: bold; + } + )"); + + sidebar_layout->addWidget(btn); + panel_layout->addWidget(panel.second); + QObject::connect(btn, SIGNAL(released()), this, SLOT(setActivePanel())); + } + + QHBoxLayout *settings_layout = new QHBoxLayout(); + settings_layout->addSpacing(45); + + sidebar_widget = new QWidget; + sidebar_widget->setLayout(sidebar_layout); + settings_layout->addWidget(sidebar_widget); + + settings_layout->addSpacing(45); + settings_layout->addLayout(panel_layout); + settings_layout->addSpacing(45); + + setLayout(settings_layout); + setStyleSheet(R"( + * { + color: white; + font-size: 50px; + } + )"); +} + +void SettingsWindow::closeSidebar() { + sidebar_widget->setVisible(false); +} + +void SettingsWindow::openSidebar() { + sidebar_widget->setVisible(true); +} diff --git a/selfdrive/ui/qt/offroad/settings.hpp b/selfdrive/ui/qt/offroad/settings.hpp new file mode 100644 index 00000000000000..b2c0a911d75fee --- /dev/null +++ b/selfdrive/ui/qt/offroad/settings.hpp @@ -0,0 +1,49 @@ +#pragma once + +#include +#include +#include +#include +#include + +#include "wifi.hpp" + +// *** settings widgets *** + +class ParamsToggle : public QFrame { + Q_OBJECT + +public: + explicit ParamsToggle(QString param, QString title, QString description, + QString icon, QWidget *parent = 0); + +private: + QString param; + +public slots: + void checkboxClicked(int state); +}; + + +// *** settings window *** + +class SettingsWindow : public QWidget { + Q_OBJECT + +public: + explicit SettingsWindow(QWidget *parent = 0); + +signals: + void closeSettings(); + +private: + QPushButton *sidebar_alert_widget; + QWidget *sidebar_widget; + std::map panels; + QStackedLayout *panel_layout; + +public slots: + void setActivePanel(); + void closeSidebar(); + void openSidebar(); +}; diff --git a/selfdrive/ui/qt/offroad/wifi.cc b/selfdrive/ui/qt/offroad/wifi.cc new file mode 100644 index 00000000000000..ae641f5091b786 --- /dev/null +++ b/selfdrive/ui/qt/offroad/wifi.cc @@ -0,0 +1,267 @@ +#include +#include +#include +#include +#include +#include + +#include "wifi.hpp" +#include "widgets/toggle.hpp" + +void clearLayout(QLayout* layout) { + while (QLayoutItem* item = layout->takeAt(0)) { + if (QWidget* widget = item->widget()) { + widget->deleteLater(); + } + if (QLayout* childLayout = item->layout()) { + clearLayout(childLayout); + } + delete item; + } +} + +WifiUI::WifiUI(QWidget *parent, int page_length) : QWidget(parent), networks_per_page(page_length) { + try { + wifi = new WifiManager; + } catch (std::exception &e) { + QLabel* warning = new QLabel("Network manager is inactive!"); + warning->setStyleSheet(R"(font-size: 65px;)"); + + QVBoxLayout* warning_layout = new QVBoxLayout; + warning_layout->addWidget(warning, 0, Qt::AlignCenter); + setLayout(warning_layout); + return; + } + + QObject::connect(wifi, SIGNAL(wrongPassword(QString)), this, SLOT(wrongPassword(QString))); + + QVBoxLayout * top_layout = new QVBoxLayout; + top_layout->setSpacing(0); + swidget = new QStackedWidget; + + // Networks page + wifi_widget = new QWidget; + QVBoxLayout* networkLayout = new QVBoxLayout; + QHBoxLayout *tethering_field = new QHBoxLayout; + tethering_field->addSpacing(50); + + ipv4 = new QLabel(""); + tethering_field->addWidget(ipv4); + tethering_field->addWidget(new QLabel("Enable Tethering")); + + Toggle* toggle_switch = new Toggle(this); + toggle_switch->setFixedSize(150, 100); + tethering_field->addWidget(toggle_switch); + if (wifi->tetheringEnabled()) { + toggle_switch->togglePosition(); + } + QObject::connect(toggle_switch, SIGNAL(stateChanged(int)), this, SLOT(toggleTethering(int))); + + QWidget* tetheringWidget = new QWidget; + tetheringWidget->setLayout(tethering_field); + tetheringWidget->setFixedHeight(150); + networkLayout->addWidget(tetheringWidget); + + vlayout = new QVBoxLayout; + wifi_widget->setLayout(vlayout); + networkLayout->addWidget(wifi_widget); + + QWidget* networkWidget = new QWidget; + networkWidget->setLayout(networkLayout); + swidget->addWidget(networkWidget); + + // Keyboard page + input_field = new InputField(); + QObject::connect(input_field, SIGNAL(emitText(QString)), this, SLOT(receiveText(QString))); + swidget->addWidget(input_field); + swidget->setCurrentIndex(0); + + top_layout->addWidget(swidget); + setLayout(top_layout); + + // Update network list + timer = new QTimer(this); + QObject::connect(timer, SIGNAL(timeout()), this, SLOT(refresh())); + timer->start(2000); + + // Scan on startup + QLabel *scanning = new QLabel("Scanning for networks"); + scanning->setStyleSheet(R"(font-size: 65px;)"); + vlayout->addWidget(scanning, 0, Qt::AlignCenter); + vlayout->setSpacing(25); + + wifi->request_scan(); + refresh(); + page = 0; +} + +void WifiUI::refresh() { + if (!this->isVisible()) { + return; + } + + wifi->request_scan(); + wifi->refreshNetworks(); + ipv4->setText(wifi->ipv4_address); + clearLayout(vlayout); + + connectButtons = new QButtonGroup(this); + QObject::connect(connectButtons, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(handleButton(QAbstractButton*))); + + int i = 0; + int countWidgets = 0; + int button_height = static_cast(this->height() / (networks_per_page + 1) * 0.6); + for (Network &network : wifi->seen_networks) { + QHBoxLayout *hlayout = new QHBoxLayout; + if (page * networks_per_page <= i && i < (page + 1) * networks_per_page) { + // SSID + hlayout->addSpacing(50); + hlayout->addWidget(new QLabel(QString::fromUtf8(network.ssid))); + + // strength indicator + unsigned int strength_scale = network.strength / 17; + QPixmap pix("../assets/images/network_" + QString::number(strength_scale) + ".png"); + QLabel *icon = new QLabel(); + icon->setPixmap(pix.scaledToWidth(100, Qt::SmoothTransformation)); + icon->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + hlayout->addWidget(icon); + hlayout->addSpacing(20); + + // connect button + QPushButton* btn = new QPushButton(network.connected == ConnectedType::CONNECTED ? "Connected" : (network.connected == ConnectedType::CONNECTING ? "Connecting" : "Connect")); + btn->setFixedWidth(300); + btn->setFixedHeight(button_height); + btn->setDisabled(network.connected == ConnectedType::CONNECTED || network.connected == ConnectedType::CONNECTING || network.security_type == SecurityType::UNSUPPORTED); + hlayout->addWidget(btn); + hlayout->addSpacing(20); + + connectButtons->addButton(btn, i); + + QWidget * w = new QWidget; + w->setLayout(hlayout); + vlayout->addWidget(w); + w->setStyleSheet(R"( + QLabel { + font-size: 50px; + } + QPushButton { + padding: 0; + font-size: 50px; + background-color: #114265; + } + QPushButton:disabled { + background-color: #323C43; + } + * { + background-color: #114265; + } + )"); + countWidgets++; + } + i++; + } + + // Pad vlayout to prevert oversized network widgets in case of low visible network count + for (int i = countWidgets; i < networks_per_page; i++) { + QWidget *w = new QWidget; + vlayout->addWidget(w); + } + + QHBoxLayout *prev_next_buttons = new QHBoxLayout; + QPushButton* prev = new QPushButton("Previous"); + prev->setEnabled(page); + prev->setFixedHeight(button_height); + QPushButton* next = new QPushButton("Next"); + next->setFixedHeight(button_height); + + // If there are more visible networks then we can show, enable going to next page + next->setEnabled(wifi->seen_networks.size() > (page + 1) * networks_per_page); + + QObject::connect(prev, SIGNAL(released()), this, SLOT(prevPage())); + QObject::connect(next, SIGNAL(released()), this, SLOT(nextPage())); + prev_next_buttons->addWidget(prev); + prev_next_buttons->addWidget(next); + + QWidget *w = new QWidget; + w->setLayout(prev_next_buttons); + w->setStyleSheet(R"( + QPushButton { + padding: 0; + background-color: #114265; + } + QPushButton:disabled { + background-color: #323C43; + } + * { + background-color: #114265; + } + )"); + vlayout->addWidget(w); +} + + + +void WifiUI::toggleTethering(int enable) { + if (enable) { + wifi->enableTethering(); + } else { + wifi->disableTethering(); + } +} + +void WifiUI::handleButton(QAbstractButton* button) { + QPushButton* btn = static_cast(button); + Network n = wifi->seen_networks[connectButtons->id(btn)]; + connectToNetwork(n); +} + +void WifiUI::connectToNetwork(Network n) { + timer->stop(); + if (n.security_type == SecurityType::OPEN) { + wifi->connect(n); + } else if (n.security_type == SecurityType::WPA) { + input_field->setPromptText("Enter password for \"" + n.ssid + "\""); + QString password = getStringFromUser(); + if (password.size()) { + wifi->connect(n, password); + } + } + refresh(); + timer->start(); +} + +QString WifiUI::getStringFromUser() { + emit openKeyboard(); + swidget->setCurrentIndex(1); + loop.exec(); + emit closeKeyboard(); + swidget->setCurrentIndex(0); + return text; +} + +void WifiUI::receiveText(QString t) { + loop.quit(); + text = t; +} + + +void WifiUI::wrongPassword(QString ssid) { + if (loop.isRunning()) { + return; + } + for (Network n : wifi->seen_networks) { + if (n.ssid == ssid) { + input_field->setPromptText("Wrong password for \"" + n.ssid +"\""); + connectToNetwork(n); + } + } +} + +void WifiUI::prevPage() { + page--; + refresh(); +} +void WifiUI::nextPage() { + page++; + refresh(); +} diff --git a/selfdrive/ui/qt/offroad/wifi.hpp b/selfdrive/ui/qt/offroad/wifi.hpp new file mode 100644 index 00000000000000..bad8d9356c9337 --- /dev/null +++ b/selfdrive/ui/qt/offroad/wifi.hpp @@ -0,0 +1,52 @@ +#pragma once + +#include +#include +#include +#include +#include + +#include "wifiManager.hpp" +#include "widgets/input_field.hpp" + + +class WifiUI : public QWidget { + Q_OBJECT + +public: + int page; + explicit WifiUI(QWidget *parent = 0, int page_length = 5); + +private: + WifiManager *wifi = nullptr; + const int networks_per_page; + + QStackedWidget *swidget; + QVBoxLayout *vlayout; + QWidget *wifi_widget; + + InputField *input_field; + QEventLoop loop; + QTimer *timer; + QString text; + QButtonGroup *connectButtons; + bool tetheringEnabled; + QLabel *ipv4; + + void connectToNetwork(Network n); + QString getStringFromUser(); + +private slots: + void handleButton(QAbstractButton* m_button); + void toggleTethering(int enable); + void refresh(); + void receiveText(QString text); + void wrongPassword(QString ssid); + + void prevPage(); + void nextPage(); + +signals: + void openKeyboard(); + void closeKeyboard(); +}; diff --git a/selfdrive/ui/qt/offroad/wifiManager.cc b/selfdrive/ui/qt/offroad/wifiManager.cc new file mode 100644 index 00000000000000..ff8977c9a70fa4 --- /dev/null +++ b/selfdrive/ui/qt/offroad/wifiManager.cc @@ -0,0 +1,396 @@ +#include +#include +#include +#include +#include "wifiManager.hpp" +#include "common/params.h" + +/** + * We are using a NetworkManager DBUS API : https://developer.gnome.org/NetworkManager/1.26/spec.html + * */ + +// https://developer.gnome.org/NetworkManager/1.26/nm-dbus-types.html#NM80211ApFlags +const int NM_802_11_AP_FLAGS_PRIVACY = 0x00000001; + +// https://developer.gnome.org/NetworkManager/1.26/nm-dbus-types.html#NM80211ApSecurityFlags +const int NM_802_11_AP_SEC_PAIR_WEP40 = 0x00000001; +const int NM_802_11_AP_SEC_PAIR_WEP104 = 0x00000002; +const int NM_802_11_AP_SEC_GROUP_WEP40 = 0x00000010; +const int NM_802_11_AP_SEC_GROUP_WEP104 = 0x00000020; +const int NM_802_11_AP_SEC_KEY_MGMT_PSK = 0x00000100; +const int NM_802_11_AP_SEC_KEY_MGMT_802_1X = 0x00000200; + + +QString nm_path = "/org/freedesktop/NetworkManager"; +QString nm_settings_path = "/org/freedesktop/NetworkManager/Settings"; + +QString nm_iface = "org.freedesktop.NetworkManager"; +QString props_iface = "org.freedesktop.DBus.Properties"; +QString nm_settings_iface = "org.freedesktop.NetworkManager.Settings"; +QString nm_settings_conn_iface = "org.freedesktop.NetworkManager.Settings.Connection"; +QString device_iface = "org.freedesktop.NetworkManager.Device"; +QString wireless_device_iface = "org.freedesktop.NetworkManager.Device.Wireless"; +QString ap_iface = "org.freedesktop.NetworkManager.AccessPoint"; +QString connection_iface = "org.freedesktop.NetworkManager.Connection.Active"; +QString ipv4config_iface = "org.freedesktop.NetworkManager.IP4Config"; + +QString nm_service = "org.freedesktop.NetworkManager"; + +const int state_connected = 100; +const int state_need_auth = 60; +const int reason_wrong_password = 8; + +template +T get_response(QDBusMessage response) { + QVariant first = response.arguments().at(0); + QDBusVariant dbvFirst = first.value(); + QVariant vFirst = dbvFirst.variant(); + return vFirst.value(); +} + +bool compare_by_strength(const Network &a, const Network &b) { + if (a.connected == ConnectedType::CONNECTED) return true; + if (b.connected == ConnectedType::CONNECTED) return false; + if (a.connected == ConnectedType::CONNECTING) return true; + if (b.connected == ConnectedType::CONNECTING) return false; + return a.strength > b.strength; +} + + +WifiManager::WifiManager() { + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + connecting_to_network = ""; + adapter = get_adapter(); + + bool has_adapter = adapter != ""; + if (!has_adapter){ + throw std::runtime_error("Error connecting to panda"); + } + + QDBusInterface nm(nm_service, adapter, device_iface, bus); + bus.connect(nm_service, adapter, device_iface, "StateChanged", this, SLOT(change(unsigned int, unsigned int, unsigned int))); + + QDBusInterface device_props(nm_service, adapter, props_iface, bus); + QDBusMessage response = device_props.call("Get", device_iface, "State"); + raw_adapter_state = get_response(response); + change(raw_adapter_state, 0, 0); + + // Compute tethering ssid as "Weedle" + first 4 characters of a dongle id + tethering_ssid = "weedle"; + std::string bytes = Params().get("DongleId"); + if (bytes.length() >= 4) { + tethering_ssid+="-"+QString::fromStdString(bytes.substr(0,4)); + } +} + +void WifiManager::refreshNetworks() { + bus = QDBusConnection::systemBus(); + seen_networks.clear(); + seen_ssids.clear(); + ipv4_address = get_ipv4_address(); + for (Network &network : get_networks()) { + if (seen_ssids.count(network.ssid)) { + continue; + } + seen_ssids.push_back(network.ssid); + seen_networks.push_back(network); + } +} + +QString WifiManager::get_ipv4_address(){ + if (raw_adapter_state != state_connected){ + return ""; + } + QVector conns = get_active_connections(); + for (auto p : conns){ + QString active_connection = p.path(); + QDBusInterface nm(nm_service, active_connection, props_iface, bus); + QDBusObjectPath pth = get_response(nm.call("Get", connection_iface, "Ip4Config")); + QString ip4config = pth.path(); + + QDBusInterface nm2(nm_service, ip4config, props_iface, bus); + const QDBusArgument &arr = get_response(nm2.call("Get", ipv4config_iface, "AddressData")); + QMap pth2; + arr.beginArray(); + while (!arr.atEnd()){ + arr >> pth2; + QString ipv4 = pth2.value("address").value(); + arr.endArray(); + return ipv4; + } + arr.endArray(); + } + return ""; +} + +QList WifiManager::get_networks() { + QList r; + QDBusInterface nm(nm_service, adapter, wireless_device_iface, bus); + QDBusMessage response = nm.call("GetAllAccessPoints"); + QVariant first = response.arguments().at(0); + + QString active_ap = get_active_ap(); + const QDBusArgument &args = first.value(); + args.beginArray(); + while (!args.atEnd()) { + QDBusObjectPath path; + args >> path; + + QByteArray ssid = get_property(path.path(), "Ssid"); + unsigned int strength = get_ap_strength(path.path()); + SecurityType security = getSecurityType(path.path()); + ConnectedType ctype; + if (path.path() != active_ap) { + ctype = ConnectedType::DISCONNECTED; + } else { + if (ssid == connecting_to_network) { + ctype = ConnectedType::CONNECTING; + } else { + ctype = ConnectedType::CONNECTED; + } + } + Network network = {path.path(), ssid, strength, ctype, security}; + + if (ssid.length()) { + r.push_back(network); + } + } + args.endArray(); + + std::sort(r.begin(), r.end(), compare_by_strength); + return r; +} + +SecurityType WifiManager::getSecurityType(QString path) { + int sflag = get_property(path, "Flags").toInt(); + int wpaflag = get_property(path, "WpaFlags").toInt(); + int rsnflag = get_property(path, "RsnFlags").toInt(); + int wpa_props = wpaflag | rsnflag; + + // obtained by looking at flags of networks in the office as reported by an Android phone + const int supports_wpa = NM_802_11_AP_SEC_PAIR_WEP40 | NM_802_11_AP_SEC_PAIR_WEP104 | NM_802_11_AP_SEC_GROUP_WEP40 | NM_802_11_AP_SEC_GROUP_WEP104 | NM_802_11_AP_SEC_KEY_MGMT_PSK; + + if (sflag == 0) { + return SecurityType::OPEN; + } else if ((sflag & NM_802_11_AP_FLAGS_PRIVACY) && (wpa_props & supports_wpa) && !(wpa_props & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) { + return SecurityType::WPA; + } else { + return SecurityType::UNSUPPORTED; + } +} + +void WifiManager::connect(Network n) { + return connect(n, "", ""); +} + +void WifiManager::connect(Network n, QString password) { + return connect(n, "", password); +} + +void WifiManager::connect(Network n, QString username, QString password) { + connecting_to_network = n.ssid; + disconnect(); + clear_connections(n.ssid); //Clear all connections that may already exist to the network we are connecting + connect(n.ssid, username, password, n.security_type); +} + +void WifiManager::connect(QByteArray ssid, QString username, QString password, SecurityType security_type) { + Connection connection; + connection["connection"]["type"] = "802-11-wireless"; + connection["connection"]["uuid"] = QUuid::createUuid().toString().remove('{').remove('}'); + connection["connection"]["id"] = "OpenPilot connection "+QString::fromStdString(ssid.toStdString()); + connection["connection"]["autoconnect-retries"] = 0; + + connection["802-11-wireless"]["ssid"] = ssid; + connection["802-11-wireless"]["mode"] = "infrastructure"; + + if (security_type == SecurityType::WPA) { + connection["802-11-wireless-security"]["key-mgmt"] = "wpa-psk"; + connection["802-11-wireless-security"]["auth-alg"] = "open"; + connection["802-11-wireless-security"]["psk"] = password; + } + + connection["ipv4"]["method"] = "auto"; + connection["ipv6"]["method"] = "ignore"; + + QDBusInterface nm_settings(nm_service, nm_settings_path, nm_settings_iface, bus); + nm_settings.call("AddConnection", QVariant::fromValue(connection)); +} + +void WifiManager::deactivate_connections(QString ssid) { + for (QDBusObjectPath active_connection_raw : get_active_connections()) { + QString active_connection = active_connection_raw.path(); + QDBusInterface nm(nm_service, active_connection, props_iface, bus); + QDBusObjectPath pth = get_response(nm.call("Get", connection_iface, "SpecificObject")); + QString Ssid = get_property(pth.path(), "Ssid"); + if (Ssid == ssid) { + QDBusInterface nm2(nm_service, nm_path, nm_iface, bus); + nm2.call("DeactivateConnection", QVariant::fromValue(active_connection_raw)); + } + } +} + +QVector WifiManager::get_active_connections() { + QDBusInterface nm(nm_service, nm_path, props_iface, bus); + QDBusMessage response = nm.call("Get", nm_iface, "ActiveConnections"); + const QDBusArgument &arr = get_response(response); + QVector conns; + + QDBusObjectPath path; + arr.beginArray(); + while (!arr.atEnd()) { + arr >> path; + conns.push_back(path); + } + arr.endArray(); + return conns; +} + +void WifiManager::clear_connections(QString ssid) { + QDBusInterface nm(nm_service, nm_settings_path, nm_settings_iface, bus); + QDBusMessage response = nm.call("ListConnections"); + QVariant first = response.arguments().at(0); + const QDBusArgument &args = first.value(); + args.beginArray(); + while (!args.atEnd()) { + QDBusObjectPath path; + args >> path; + QDBusInterface nm2(nm_service, path.path(), nm_settings_conn_iface, bus); + QDBusMessage response = nm2.call("GetSettings"); + + const QDBusArgument &dbusArg = response.arguments().at(0).value(); + + QMap > map; + dbusArg >> map; + for (QString outer_key : map.keys()) { + QMap innerMap = map.value(outer_key); + for (QString inner_key : innerMap.keys()) { + if (inner_key == "ssid") { + QString value = innerMap.value(inner_key).value(); + if (value == ssid) { + nm2.call("Delete"); + } + } + } + } + } +} + +void WifiManager::request_scan() { + QDBusInterface nm(nm_service, adapter, wireless_device_iface, bus); + nm.call("RequestScan", QVariantMap()); +} + +uint WifiManager::get_wifi_device_state() { + QDBusInterface device_props(nm_service, adapter, props_iface, bus); + QDBusMessage response = device_props.call("Get", device_iface, "State"); + uint resp = get_response(response); + return resp; +} + +QString WifiManager::get_active_ap() { + QDBusInterface device_props(nm_service, adapter, props_iface, bus); + QDBusMessage response = device_props.call("Get", wireless_device_iface, "ActiveAccessPoint"); + QDBusObjectPath r = get_response(response); + return r.path(); +} + +QByteArray WifiManager::get_property(QString network_path ,QString property) { + QDBusInterface device_props(nm_service, network_path, props_iface, bus); + QDBusMessage response = device_props.call("Get", ap_iface, property); + return get_response(response); +} + +unsigned int WifiManager::get_ap_strength(QString network_path) { + QDBusInterface device_props(nm_service, network_path, props_iface, bus); + QDBusMessage response = device_props.call("Get", ap_iface, "Strength"); + return get_response(response); +} + +QString WifiManager::get_adapter() { + + QDBusInterface nm(nm_service, nm_path, nm_iface, bus); + QDBusMessage response = nm.call("GetDevices"); + QVariant first = response.arguments().at(0); + + QString adapter_path = ""; + + const QDBusArgument &args = first.value(); + args.beginArray(); + while (!args.atEnd()) { + QDBusObjectPath path; + args >> path; + + // Get device type + QDBusInterface device_props(nm_service, path.path(), props_iface, bus); + QDBusMessage response = device_props.call("Get", device_iface, "DeviceType"); + uint device_type = get_response(response); + + if (device_type == 2) { // Wireless + adapter_path = path.path(); + break; + } + } + args.endArray(); + + return adapter_path; +} + +void WifiManager::change(unsigned int new_state,unsigned int previous_state,unsigned int change_reason) { + raw_adapter_state = new_state; + if (new_state == state_need_auth && change_reason == reason_wrong_password) { + emit wrongPassword(connecting_to_network); + } else if (new_state == state_connected) { + connecting_to_network = ""; + } +} + +void WifiManager::disconnect() { + QString active_ap = get_active_ap(); + if (active_ap!="" && active_ap!="/") { + deactivate_connections(get_property(active_ap, "Ssid")); + } +} + +//Functions for tethering + +void WifiManager::enableTethering() { + disconnect(); + Connection connection; + connection["connection"]["id"] = "Hotspot"; + connection["connection"]["uuid"] = QUuid::createUuid().toString().remove('{').remove('}'); + connection["connection"]["type"] = "802-11-wireless"; + connection["connection"]["interface-name"] = "wlan0"; + + connection["802-11-wireless"]["band"] = "bg"; + connection["802-11-wireless"]["mode"] = "ap"; + connection["802-11-wireless"]["ssid"] = tethering_ssid.toUtf8(); + + connection["802-11-wireless-security"]["group"] = QStringList("ccmp"); + connection["802-11-wireless-security"]["key-mgmt"] = "wpa-psk"; + connection["802-11-wireless-security"]["pairwise"] = QStringList("ccmp"); + connection["802-11-wireless-security"]["proto"] = QStringList("rsn"); + connection["802-11-wireless-security"]["psk"] = "swagswagcomma"; + + connection["ipv4"]["method"] = "shared"; + QMap address; + address["address"] = "192.168.43.1"; + address["prefix"] = 24u; + connection["ipv4"]["address-data"] = QVariant::fromValue(IpConfig() << address); + connection["ipv4"]["gateway"] = "192.168.43.1"; + connection["ipv6"]["method"] = "ignore"; + + QDBusInterface nm_settings(nm_service, nm_settings_path, nm_settings_iface, bus); + nm_settings.call("AddConnection", QVariant::fromValue(connection)); + +} + +void WifiManager::disableTethering() { + clear_connections(tethering_ssid); +} + +bool WifiManager::tetheringEnabled() { + QString active_ap = get_active_ap(); + return get_property(active_ap, "Ssid") == tethering_ssid; +} diff --git a/selfdrive/ui/qt/offroad/wifiManager.hpp b/selfdrive/ui/qt/offroad/wifiManager.hpp new file mode 100644 index 00000000000000..13eb90f3fb352a --- /dev/null +++ b/selfdrive/ui/qt/offroad/wifiManager.hpp @@ -0,0 +1,74 @@ +#pragma once + +#include +#include + +enum class SecurityType { + OPEN, + WPA, + UNSUPPORTED +}; +enum class ConnectedType{ + DISCONNECTED, + CONNECTING, + CONNECTED +}; + +typedef QMap> Connection; +typedef QVector> IpConfig; + +struct Network { + QString path; + QByteArray ssid; + unsigned int strength; + ConnectedType connected; + SecurityType security_type; +}; + +class WifiManager : public QWidget { + Q_OBJECT +public: + explicit WifiManager(); + + void request_scan(); + QVector seen_networks; + QString ipv4_address; + + void refreshNetworks(); + void connect(Network ssid); + void connect(Network ssid, QString password); + void connect(Network ssid, QString username, QString password); + // Tethering functions + + void enableTethering(); + void disableTethering(); + bool tetheringEnabled(); + +private: + QVector seen_ssids; + QString adapter;//Path to network manager wifi-device + QDBusConnection bus = QDBusConnection::systemBus(); + unsigned int raw_adapter_state;//Connection status https://developer.gnome.org/NetworkManager/1.26/nm-dbus-types.html#NMDeviceState + QString connecting_to_network; + QString tethering_ssid; + + QString get_adapter(); + QString get_ipv4_address(); + QList get_networks(); + void connect(QByteArray ssid, QString username, QString password, SecurityType security_type); + QString get_active_ap(); + void deactivate_connections(QString ssid); + void clear_connections(QString ssid); + QVector get_active_connections(); + uint get_wifi_device_state(); + QByteArray get_property(QString network_path, QString property); + unsigned int get_ap_strength(QString network_path); + SecurityType getSecurityType(QString ssid); + void disconnect(); + +private slots: + void change(unsigned int new_state, unsigned int previous_state, unsigned int change_reason); +signals: + void wrongPassword(QString ssid); + void refresh(); +}; diff --git a/selfdrive/ui/qt/qt_sound.cc b/selfdrive/ui/qt/qt_sound.cc new file mode 100644 index 00000000000000..c18b2d585023a3 --- /dev/null +++ b/selfdrive/ui/qt/qt_sound.cc @@ -0,0 +1,30 @@ +#include +#include "qt_sound.hpp" + +QtSound::QtSound() { + for (auto &kv : sound_map) { + auto path = QUrl::fromLocalFile(kv.second.first); + sounds[kv.first].setSource(path); + } +} + +bool QtSound::play(AudibleAlert alert) { + int loops = sound_map[alert].second> - 1 ? sound_map[alert].second : QSoundEffect::Infinite; + sounds[alert].setLoopCount(loops); + sounds[alert].setVolume(0.7); + sounds[alert].play(); + return true; +} + +void QtSound::stop() { + for (auto &kv : sounds) { + // Only stop repeating sounds + if (sound_map[kv.first].second != 0) { + kv.second.stop(); + } + } +} + +void QtSound::setVolume(int volume) { + // TODO: implement this +} diff --git a/selfdrive/ui/qt/qt_sound.hpp b/selfdrive/ui/qt/qt_sound.hpp new file mode 100644 index 00000000000000..8c7f8aa348e963 --- /dev/null +++ b/selfdrive/ui/qt/qt_sound.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include +#include "sound.hpp" + +class QtSound : public Sound { +public: + QtSound(); + bool play(AudibleAlert alert); + void stop(); + void setVolume(int volume); + +private: + std::map sounds; +}; diff --git a/selfdrive/ui/qt/qt_window.cc b/selfdrive/ui/qt/qt_window.cc new file mode 100644 index 00000000000000..7f6b383bdd76b3 --- /dev/null +++ b/selfdrive/ui/qt/qt_window.cc @@ -0,0 +1,26 @@ +#include +#include + +#ifdef QCOM2 +#include +#include +#include +#endif + +#include "qt_window.hpp" + +void setMainWindow(QWidget *w) { + float scale = getenv("SCALE") != NULL ? std::stof(getenv("SCALE")) : 1.0; + w->setFixedSize(vwp_w*scale, vwp_h*scale); + w->show(); + +#ifdef QCOM2 + QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface(); + wl_surface *s = reinterpret_cast(native->nativeResourceForWindow("surface", w->windowHandle())); + wl_surface_set_buffer_transform(s, WL_OUTPUT_TRANSFORM_270); + wl_surface_commit(s); + w->showFullScreen(); +#endif +} + + diff --git a/selfdrive/ui/qt/qt_window.hpp b/selfdrive/ui/qt/qt_window.hpp new file mode 100644 index 00000000000000..a4485959bc645b --- /dev/null +++ b/selfdrive/ui/qt/qt_window.hpp @@ -0,0 +1,9 @@ +#include + +#ifdef QCOM2 + const int vwp_w = 2160, vwp_h = 1080; +#else + const int vwp_w = 1920, vwp_h = 1080; +#endif + +void setMainWindow(QWidget *w); diff --git a/selfdrive/ui/qt/spinner.cc b/selfdrive/ui/qt/spinner.cc new file mode 100644 index 00000000000000..77151f3bbad2cb --- /dev/null +++ b/selfdrive/ui/qt/spinner.cc @@ -0,0 +1,100 @@ +#include +#include +#include + +#include +#include +#include +#include + +#include "spinner.hpp" +#include "qt_window.hpp" + +Spinner::Spinner(QWidget *parent) { + QGridLayout *main_layout = new QGridLayout(); + main_layout->setSpacing(0); + main_layout->setContentsMargins(200, 200, 200, 200); + + const int img_size = 360; + + comma = new QLabel(); + comma->setPixmap(QPixmap("../assets/img_spinner_comma.png").scaled(img_size, img_size, Qt::KeepAspectRatio, Qt::SmoothTransformation)); + comma->setFixedSize(img_size, img_size); + main_layout->addWidget(comma, 0, 0, Qt::AlignHCenter | Qt::AlignVCenter); + + track_img = QPixmap("../assets/img_spinner_track.png").scaled(img_size, img_size, Qt::KeepAspectRatio, Qt::SmoothTransformation); + track = new QLabel(); + track->setPixmap(track_img); + track->setFixedSize(img_size, img_size); + main_layout->addWidget(track, 0, 0, Qt::AlignHCenter | Qt::AlignVCenter); + + text = new QLabel(); + text->setVisible(false); + main_layout->addWidget(text, 1, 0, Qt::AlignHCenter); + + progress_bar = new QProgressBar(); + progress_bar->setRange(5, 100); + progress_bar->setTextVisible(false); + progress_bar->setVisible(false); + main_layout->addWidget(progress_bar, 1, 0, Qt::AlignHCenter); + + setLayout(main_layout); + setStyleSheet(R"( + Spinner { + background-color: black; + } + QLabel { + color: white; + font-size: 80px; + } + QProgressBar { + background-color: #373737; + height: 20px; + width: 1000px; + border solid white; + border-radius: 10px; + } + QProgressBar::chunk { + border-radius: 10px; + background-color: white; + } + )"); + + rotate_timer = new QTimer(this); + rotate_timer->start(1000/30.); + QObject::connect(rotate_timer, SIGNAL(timeout()), this, SLOT(rotate())); + + notifier = new QSocketNotifier(fileno(stdin), QSocketNotifier::Read); + QObject::connect(notifier, SIGNAL(activated(int)), this, SLOT(update(int))); +}; + +void Spinner::rotate() { + transform.rotate(5); + + QPixmap r = track_img.transformed(transform.rotate(5), Qt::SmoothTransformation); + int x = (r.width() - track->width()) / 2; + int y = (r.height() - track->height()) / 2; + track->setPixmap(r.copy(x, y, track->width(), track->height())); +}; + +void Spinner::update(int n) { + std::string line; + std::getline(std::cin, line); + + if (line.length()) { + bool number = std::all_of(line.begin(), line.end(), ::isdigit); + text->setVisible(!number); + progress_bar->setVisible(number); + text->setText(QString::fromStdString(line)); + if (number) { + progress_bar->setValue(std::stoi(line)); + } + } +} + +int main(int argc, char *argv[]) { + QApplication a(argc, argv); + Spinner spinner; + setMainWindow(&spinner); + return a.exec(); +} diff --git a/selfdrive/ui/qt/spinner.hpp b/selfdrive/ui/qt/spinner.hpp new file mode 100644 index 00000000000000..ea0f8afdcf5ca8 --- /dev/null +++ b/selfdrive/ui/qt/spinner.hpp @@ -0,0 +1,27 @@ +#include +#include +#include +#include +#include +#include +#include + +class Spinner : public QWidget { + Q_OBJECT + +public: + explicit Spinner(QWidget *parent = 0); + +private: + QPixmap track_img; + QTimer *rotate_timer; + QLabel *comma, *track; + QLabel *text; + QProgressBar *progress_bar; + QTransform transform; + QSocketNotifier *notifier; + +public slots: + void rotate(); + void update(int n); +}; diff --git a/selfdrive/ui/qt/text.cc b/selfdrive/ui/qt/text.cc new file mode 100644 index 00000000000000..9af03a91b5369f --- /dev/null +++ b/selfdrive/ui/qt/text.cc @@ -0,0 +1,49 @@ +#include +#include +#include +#include +#include + +#include "qt_window.hpp" + +int main(int argc, char *argv[]) { + QApplication a(argc, argv); + QWidget window; + setMainWindow(&window); + + QVBoxLayout *layout = new QVBoxLayout(); + layout->setContentsMargins(125, 125, 125, 125); + + // TODO: make this scroll + layout->addWidget(new QLabel(argv[1]), 0, Qt::AlignTop); + + QPushButton *btn = new QPushButton(); +#ifdef __aarch64__ + btn->setText("Reboot"); + QObject::connect(btn, &QPushButton::released, [=]() { + std::system("sudo reboot"); + }); +#else + btn->setText("Exit"); + QObject::connect(btn, SIGNAL(released()), &a, SLOT(quit())); +#endif + layout->addWidget(btn, 0, Qt::AlignRight); + + window.setLayout(layout); + window.setStyleSheet(R"( + * { + color: white; + background-color: black; + font-size: 60px; + } + QPushButton { + padding: 50px; + padding-right: 100px; + padding-left: 100px; + border: 2px solid white; + border-radius: 20px; + } + )"); + + return a.exec(); +} diff --git a/selfdrive/ui/qt/ui.cc b/selfdrive/ui/qt/ui.cc new file mode 100644 index 00000000000000..93eb77f911ffb9 --- /dev/null +++ b/selfdrive/ui/qt/ui.cc @@ -0,0 +1,22 @@ +#include + +#include "window.hpp" +#include "qt_window.hpp" + +int main(int argc, char *argv[]) { + QSurfaceFormat fmt; +#ifdef __APPLE__ + fmt.setVersion(3, 2); + fmt.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile); + fmt.setRenderableType(QSurfaceFormat::OpenGL); +#else + fmt.setRenderableType(QSurfaceFormat::OpenGLES); +#endif + QSurfaceFormat::setDefaultFormat(fmt); + + QApplication a(argc, argv); + MainWindow w; + setMainWindow(&w); + a.installEventFilter(&w); + return a.exec(); +} diff --git a/selfdrive/ui/qt/widgets/input_field.cc b/selfdrive/ui/qt/widgets/input_field.cc new file mode 100644 index 00000000000000..858c1c75a261b3 --- /dev/null +++ b/selfdrive/ui/qt/widgets/input_field.cc @@ -0,0 +1,65 @@ +#include + +#include "input_field.hpp" + +InputField::InputField(QWidget *parent): QWidget(parent) { + layout = new QGridLayout(); + layout->setSpacing(30); + + label = new QLabel(this); + label->setStyleSheet(R"(font-size: 55px;)"); + layout->addWidget(label, 0, 0, Qt::AlignVCenter | Qt::AlignLeft); + layout->setColumnStretch(0, 1); + + QPushButton* cancel = new QPushButton("Cancel"); + cancel->setFixedSize(300, 150); + cancel->setStyleSheet(R"(padding: 0;)"); + layout->addWidget(cancel, 0, 1, Qt::AlignVCenter | Qt::AlignRight); + QObject::connect(cancel, SIGNAL(released()), this, SLOT(emitEmpty())); + + // text box + line = new QLineEdit(); + line->setStyleSheet(R"( + color: black; + background-color: white; + font-size: 45px; + padding: 25px; + )"); + layout->addWidget(line, 1, 0, 1, -1); + + k = new Keyboard(this); + QObject::connect(k, SIGNAL(emitButton(QString)), this, SLOT(getText(QString))); + layout->addWidget(k, 2, 0, 1, -1); + + setLayout(layout); +} + +void InputField::setPromptText(QString text) { + label->setText(text); +} + +void InputField::emitEmpty() { + emitText(""); + line->setText(""); +} + +void InputField::getText(QString s) { + if (!QString::compare(s,"⌫")) { + line->backspace(); + } + + if (!QString::compare(s,"âŽ")) { + emitText(line->text()); + line->setText(""); + } + + QVector control_buttons {"⇧", "↑", "ABC", "âŽ", "#+=", "⌫", "123"}; + for(QString c : control_buttons) { + if (!QString::compare(s, c)) { + return; + } + } + + line->insert(s.left(1)); +} + diff --git a/selfdrive/ui/qt/widgets/input_field.hpp b/selfdrive/ui/qt/widgets/input_field.hpp new file mode 100644 index 00000000000000..8dad0c0dda5607 --- /dev/null +++ b/selfdrive/ui/qt/widgets/input_field.hpp @@ -0,0 +1,30 @@ +#pragma once + +#include +#include +#include +#include +#include + +#include "keyboard.hpp" + +class InputField : public QWidget { + Q_OBJECT + +public: + explicit InputField(QWidget* parent = 0); + void setPromptText(QString text); + +private: + QLineEdit *line; + Keyboard *k; + QLabel *label; + QGridLayout *layout; + +public slots: + void emitEmpty(); + void getText(QString s); + +signals: + void emitText(QString s); +}; diff --git a/selfdrive/ui/qt/widgets/keyboard.cc b/selfdrive/ui/qt/widgets/keyboard.cc new file mode 100644 index 00000000000000..bf192aa5d3ae87 --- /dev/null +++ b/selfdrive/ui/qt/widgets/keyboard.cc @@ -0,0 +1,126 @@ +#include +#include +#include +#include +#include +#include + +#include "keyboard.hpp" + +const int DEFAULT_WIDTH = 1; +const int SPACEBAR_WIDTH = 3; + +KeyboardLayout::KeyboardLayout(QWidget *parent, std::vector> layout) : QWidget(parent) { + QVBoxLayout* vlayout = new QVBoxLayout; + QButtonGroup* btn_group = new QButtonGroup(this); + + QObject::connect(btn_group, SIGNAL(buttonClicked(QAbstractButton*)), parent, SLOT(handleButton(QAbstractButton*))); + + int i = 0; + for (auto s : layout) { + QHBoxLayout *hlayout = new QHBoxLayout; + + if (i == 1) { + hlayout->addSpacing(90); + } + + for (QString p : s) { + QPushButton* btn = new QPushButton(p); + btn->setFixedHeight(120); + btn_group->addButton(btn); + hlayout->addSpacing(10); + if (p == QString(" ")) { + hlayout->addWidget(btn, SPACEBAR_WIDTH); + } else { + hlayout->addWidget(btn, DEFAULT_WIDTH); + } + + } + + if (i == 1) { + hlayout->addSpacing(90); + } + + vlayout->addLayout(hlayout); + i++; + } + + setLayout(vlayout); +} + +Keyboard::Keyboard(QWidget *parent) : QWidget(parent) { + main_layout = new QStackedLayout; + + // lowercase + std::vector> lowercase = { + {"q","w","e","r","t","y","u","i","o","p"}, + {"a","s","d","f","g","h","j","k","l"}, + {"⇧","z","x","c","v","b","n","m","⌫"}, + {"123"," ","âŽ"}, + }; + main_layout->addWidget(new KeyboardLayout(this, lowercase)); + + // uppercase + std::vector> uppercase = { + {"Q","W","E","R","T","Y","U","I","O","P"}, + {"A","S","D","F","G","H","J","K","L"}, + {"↑","Z","X","C","V","B","N","M","⌫"}, + {"123"," ","âŽ"}, + }; + main_layout->addWidget(new KeyboardLayout(this, uppercase)); + + // 1234567890 + std::vector> numbers = { + {"1","2","3","4","5","6","7","8","9","0"}, + {"-","/",":",";","(",")","$","&&","@","\""}, + {"#+=",".",",","?","!","`","⌫"}, + {"ABC"," ","âŽ"}, + }; + main_layout->addWidget(new KeyboardLayout(this, numbers)); + + // Special characters + std::vector> specials = { + {"[","]","{","}","#","%","^","*","+","="}, + {"_","\\","|","~","<",">","€","£","Â¥"," "}, + {"123",".",",","?","!","`","⌫"}, + {"ABC"," ","âŽ"}, + }; + main_layout->addWidget(new KeyboardLayout(this, specials)); + + setLayout(main_layout); + main_layout->setCurrentIndex(0); + + setStyleSheet(R"( + QPushButton { + padding: 0; + font-size: 50px; + } + * { + background-color: #99777777; + } + )"); +} + + +void Keyboard::handleButton(QAbstractButton* m_button) { + QString id = m_button->text(); + if (!QString::compare(m_button->text(), "↑") || !QString::compare(m_button->text(), "ABC")) { + main_layout->setCurrentIndex(0); + } + if (!QString::compare(m_button->text(), "⇧")) { + main_layout->setCurrentIndex(1); + } + if (!QString::compare(m_button->text(), "123")) { + main_layout->setCurrentIndex(2); + } + if (!QString::compare(m_button->text(), "#+=")) { + main_layout->setCurrentIndex(3); + } + if (!QString::compare(m_button->text(), "âŽ")) { + main_layout->setCurrentIndex(0); + } + if ("A" <= id && id <= "Z") { + main_layout->setCurrentIndex(0); + } + emit emitButton(m_button->text()); +} diff --git a/selfdrive/ui/qt/widgets/keyboard.hpp b/selfdrive/ui/qt/widgets/keyboard.hpp new file mode 100644 index 00000000000000..f21d48700cf57d --- /dev/null +++ b/selfdrive/ui/qt/widgets/keyboard.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include + +#include +#include +#include +#include + +class KeyboardLayout : public QWidget { + Q_OBJECT + +public: + explicit KeyboardLayout(QWidget *parent, std::vector> layout); +}; + +class Keyboard : public QWidget { + Q_OBJECT + +public: + explicit Keyboard(QWidget *parent = 0); + +private: + QStackedLayout* main_layout; + +private slots: + void handleButton(QAbstractButton* m_button); + +signals: + void emitButton(QString s); +}; diff --git a/selfdrive/ui/qt/widgets/offroad_alerts.cc b/selfdrive/ui/qt/widgets/offroad_alerts.cc new file mode 100644 index 00000000000000..08c8bcde628265 --- /dev/null +++ b/selfdrive/ui/qt/widgets/offroad_alerts.cc @@ -0,0 +1,149 @@ +#include +#include +#include +#include +#include +#include + +#include "offroad_alerts.hpp" + +#include "common/params.h" + + +void cleanLayout(QLayout* layout) { + while (QLayoutItem* item = layout->takeAt(0)) { + if (QWidget* widget = item->widget()) { + widget->deleteLater(); + } + if (QLayout* childLayout = item->layout()) { + cleanLayout(childLayout); + } + delete item; + } +} + +QString vectorToQString(std::vector v) { + return QString::fromStdString(std::string(v.begin(), v.end())); +} + +OffroadAlert::OffroadAlert(QWidget* parent) { + vlayout = new QVBoxLayout; + refresh(); + setLayout(vlayout); +} + +void OffroadAlert::refresh() { + cleanLayout(vlayout); + parse_alerts(); + + updateAvailable = false; + std::vector bytes = Params().read_db_bytes("UpdateAvailable"); + if (bytes.size() && bytes[0] == '1') { + updateAvailable = true; + } + + if (updateAvailable) { + // If there is an update available, don't show alerts + alerts.clear(); + + QFrame *f = new QFrame(); + + QVBoxLayout *update_layout = new QVBoxLayout; + update_layout->setMargin(10); + update_layout->setSpacing(20); + + QLabel *title = new QLabel("Update available"); + title->setStyleSheet(R"( + font-size: 55px; + font-weight: bold; + )"); + update_layout->addWidget(title, 0, Qt::AlignTop); + + QString release_notes = QString::fromStdString(Params().get("ReleaseNotes")); + QLabel *notes_label = new QLabel(release_notes); + notes_label->setStyleSheet(R"(font-size: 40px;)"); + notes_label->setWordWrap(true); + update_layout->addWidget(notes_label, 1, Qt::AlignTop); + + QPushButton *update_button = new QPushButton("Reboot and Update"); + update_layout->addWidget(update_button); +#ifdef __aarch64__ + QObject::connect(update_button, &QPushButton::released, [=]() {std::system("sudo reboot");}); +#endif + + f->setLayout(update_layout); + f->setStyleSheet(R"( + .QFrame{ + border-radius: 20px; + border: 2px solid white; + background-color: #114267; + } + QPushButton { + padding: 20px; + font-size: 35px; + color: white; + background-color: blue; + } + )"); + + vlayout->addWidget(f); + vlayout->addSpacing(60); + } else { + vlayout->addSpacing(60); + + for (auto alert : alerts) { + QLabel *l = new QLabel(alert.text); + l->setWordWrap(true); + l->setMargin(60); + + QString style = R"( + font-size: 40px; + font-weight: bold; + border-radius: 30px; + border: 2px solid; + border-color: white; + )"; + style.append("background-color: " + QString(alert.severity ? "#971b1c" : "#114267")); + + l->setStyleSheet(style); + vlayout->addWidget(l); + vlayout->addSpacing(20); + } + } + + QPushButton *hide_btn = new QPushButton(updateAvailable ? "Later" : "Hide alerts"); + hide_btn->setStyleSheet(R"( + padding: 20px; + font-size: 35px; + color: white; + background-color: blue; + )"); + vlayout->addWidget(hide_btn); + QObject::connect(hide_btn, SIGNAL(released()), this, SIGNAL(closeAlerts())); +} + +void OffroadAlert::parse_alerts() { + alerts.clear(); + // We launch in selfdrive/ui + QFile inFile("../controls/lib/alerts_offroad.json"); + inFile.open(QIODevice::ReadOnly | QIODevice::Text); + QByteArray data = inFile.readAll(); + inFile.close(); + + QJsonDocument doc = QJsonDocument::fromJson(data); + if (doc.isNull()) { + qDebug() << "Parse failed"; + } + + QJsonObject json = doc.object(); + for (const QString& key : json.keys()) { + std::vector bytes = Params().read_db_bytes(key.toStdString().c_str()); + + if (bytes.size()) { + QJsonDocument doc_par = QJsonDocument::fromJson(QByteArray(bytes.data(), bytes.size())); + QJsonObject obj = doc_par.object(); + Alert alert = {obj.value("text").toString(), obj.value("severity").toInt()}; + alerts.push_back(alert); + } + } +} diff --git a/selfdrive/ui/qt/widgets/offroad_alerts.hpp b/selfdrive/ui/qt/widgets/offroad_alerts.hpp new file mode 100644 index 00000000000000..1e425158fd9d08 --- /dev/null +++ b/selfdrive/ui/qt/widgets/offroad_alerts.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include +#include + +struct Alert { + QString text; + int severity; +}; + +class OffroadAlert : public QWidget { + Q_OBJECT + +public: + explicit OffroadAlert(QWidget *parent = 0); + QVector alerts; + bool updateAvailable; + +private: + QVBoxLayout *vlayout; + + void parse_alerts(); + +signals: + void closeAlerts(); + +public slots: + void refresh(); +}; diff --git a/selfdrive/ui/qt/widgets/toggle.cc b/selfdrive/ui/qt/widgets/toggle.cc new file mode 100644 index 00000000000000..bf30309153be5c --- /dev/null +++ b/selfdrive/ui/qt/widgets/toggle.cc @@ -0,0 +1,52 @@ +#include "toggle.hpp" + +Toggle::Toggle(QWidget *parent) : QAbstractButton(parent), +_height(80), +_height_rect(60), +_on(false), +_anim(new QPropertyAnimation(this, "offset_circle", this)) +{ + _radius = _height / 2; + _x_circle = _radius; + _y_circle = _radius; + _y_rect = (_height - _height_rect)/2; +} + +void Toggle::paintEvent(QPaintEvent *e) { + this->setFixedHeight(_height); + QPainter p(this); + p.setPen(Qt::NoPen); + p.setRenderHint(QPainter::Antialiasing, true); + + // Draw toggle background left + p.setBrush(QColor("#33ab4c")); + p.drawRoundedRect(QRect(0, _y_rect, _x_circle + _radius, _height_rect), _height_rect/2, _height_rect/2); + // Draw toggle background right + p.setBrush(QColor("#0a1a26")); + p.drawRoundedRect(QRect(_x_circle - _radius, _y_rect, width() -(_x_circle - _radius), _height_rect), _height_rect/2, _height_rect/2); + + // Draw toggle circle + p.setBrush(QColor("#fafafa")); + p.drawEllipse(QRectF(_x_circle - _radius, _y_circle - _radius, 2 * _radius, 2 * _radius)); +} + +void Toggle::mouseReleaseEvent(QMouseEvent *e) { + if (e->button() & Qt::LeftButton) { + togglePosition(); + emit stateChanged(_on); + } +} + +void Toggle::togglePosition() { + _on = !_on; + const int left = _radius; + const int right = width() - _radius; + _anim->setStartValue(_on ? left : right); + _anim->setEndValue(_on ? right : left); + _anim->setDuration(120); + _anim->start(); +} + +void Toggle::enterEvent(QEvent *e) { + QAbstractButton::enterEvent(e); +} diff --git a/selfdrive/ui/qt/widgets/toggle.hpp b/selfdrive/ui/qt/widgets/toggle.hpp new file mode 100644 index 00000000000000..98215c25d20885 --- /dev/null +++ b/selfdrive/ui/qt/widgets/toggle.hpp @@ -0,0 +1,35 @@ +#pragma once +#include + +class Toggle : public QAbstractButton { + Q_OBJECT + Q_PROPERTY(int offset_circle READ offset_circle WRITE set_offset_circle) + +public: + Toggle(QWidget* parent = nullptr); + void togglePosition(); + + int offset_circle() const { + return _x_circle; + } + + void set_offset_circle(int o) { + _x_circle = o; + update(); + } + +protected: + void paintEvent(QPaintEvent*) override; + void mouseReleaseEvent(QMouseEvent*) override; + void enterEvent(QEvent*) override; + +private: + bool _on; + int _x_circle, _y_circle; + int _height, _radius; + int _height_rect, _y_rect; + QPropertyAnimation *_anim = nullptr; + +signals: + void stateChanged(int new_state); +}; diff --git a/selfdrive/ui/qt/window.cc b/selfdrive/ui/qt/window.cc new file mode 100644 index 00000000000000..8893ca367115b8 --- /dev/null +++ b/selfdrive/ui/qt/window.cc @@ -0,0 +1,46 @@ +#include "window.hpp" + +MainWindow::MainWindow(QWidget *parent) : QWidget(parent) { + main_layout = new QStackedLayout; + + homeWindow = new HomeWindow(this); + main_layout->addWidget(homeWindow); + + settingsWindow = new SettingsWindow(this); + main_layout->addWidget(settingsWindow); + + onboardingWindow = new OnboardingWindow(this); + main_layout->addWidget(onboardingWindow); + + main_layout->setMargin(0); + setLayout(main_layout); + QObject::connect(homeWindow, SIGNAL(openSettings()), this, SLOT(openSettings())); + QObject::connect(settingsWindow, SIGNAL(closeSettings()), this, SLOT(closeSettings())); + + // start at onboarding + main_layout->setCurrentWidget(onboardingWindow); + QObject::connect(onboardingWindow, SIGNAL(onboardingDone()), this, SLOT(closeSettings())); + onboardingWindow->updateActiveScreen(); + + setStyleSheet(R"( + * { + color: white; + background-color: #072339; + } + )"); +} + +void MainWindow::openSettings() { + main_layout->setCurrentWidget(settingsWindow); +} + +void MainWindow::closeSettings() { + main_layout->setCurrentWidget(homeWindow); +} + +bool MainWindow::eventFilter(QObject *obj, QEvent *event){ + if (event->type() == QEvent::MouseButtonPress) { + homeWindow->glWindow->wake(); + } + return false; +} diff --git a/selfdrive/ui/qt/window.hpp b/selfdrive/ui/qt/window.hpp new file mode 100644 index 00000000000000..10822f1fbc4657 --- /dev/null +++ b/selfdrive/ui/qt/window.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include +#include + +#include "offroad/settings.hpp" +#include "offroad/onboarding.hpp" +#include "home.hpp" + +class MainWindow : public QWidget { + Q_OBJECT + +protected: + bool eventFilter(QObject *obj, QEvent *event) override; + +public: + explicit MainWindow(QWidget *parent = 0); + +private: + QStackedLayout *main_layout; + HomeWindow *homeWindow; + SettingsWindow *settingsWindow; + OnboardingWindow *onboardingWindow; + +public slots: + void openSettings(); + void closeSettings(); +}; diff --git a/selfdrive/ui/sidebar.cc b/selfdrive/ui/sidebar.cc new file mode 100644 index 00000000000000..65b20bdac24c66 --- /dev/null +++ b/selfdrive/ui/sidebar.cc @@ -0,0 +1,169 @@ +#include +#include +#include +#include + +#include "paint.hpp" +#include "sidebar.hpp" + +static void ui_draw_sidebar_background(UIState *s) { + ui_draw_rect(s->vg, 0, 0, sbr_w, s->fb_h, COLOR_BLACK_ALPHA(85)); +} + +static void ui_draw_sidebar_settings_button(UIState *s) { + const float alpha = s->active_app == cereal::UiLayoutState::App::SETTINGS ? 1.0f : 0.65f; + ui_draw_image(s->vg, settings_btn.x, settings_btn.y, settings_btn.w, settings_btn.h, s->img_button_settings, alpha); +} + +static void ui_draw_sidebar_home_button(UIState *s) { + const float alpha = s->active_app == cereal::UiLayoutState::App::HOME ? 1.0f : 0.65f;; + ui_draw_image(s->vg, home_btn.x, home_btn.y, home_btn.w, home_btn.h, s->img_button_home, alpha); +} + +static void ui_draw_sidebar_network_strength(UIState *s) { + static std::map network_strength_map = { + {cereal::ThermalData::NetworkStrength::UNKNOWN, 1}, + {cereal::ThermalData::NetworkStrength::POOR, 2}, + {cereal::ThermalData::NetworkStrength::MODERATE, 3}, + {cereal::ThermalData::NetworkStrength::GOOD, 4}, + {cereal::ThermalData::NetworkStrength::GREAT, 5}}; + const int network_img_h = 27; + const int network_img_w = 176; + const int network_img_x = 58; + const int network_img_y = 196; + const int img_idx = s->scene.thermal.getNetworkType() == cereal::ThermalData::NetworkType::NONE ? 0 : network_strength_map[s->scene.thermal.getNetworkStrength()]; + ui_draw_image(s->vg, network_img_x, network_img_y, network_img_w, network_img_h, s->img_network[img_idx], 1.0f); +} + +static void ui_draw_sidebar_battery_icon(UIState *s) { + const int battery_img_h = 36; + const int battery_img_w = 76; + const int battery_img_x = 160; + const int battery_img_y = 255; + + int battery_img = s->scene.thermal.getBatteryStatus() == "Charging" ? s->img_battery_charging : s->img_battery; + + ui_draw_rect(s->vg, battery_img_x + 6, battery_img_y + 5, + ((battery_img_w - 19) * (s->scene.thermal.getBatteryPercent() * 0.01)), battery_img_h - 11, COLOR_WHITE); + + ui_draw_image(s->vg, battery_img_x, battery_img_y, battery_img_w, battery_img_h, battery_img, 1.0f); +} + +static void ui_draw_sidebar_network_type(UIState *s) { + static std::map network_type_map = { + {cereal::ThermalData::NetworkType::NONE, "--"}, + {cereal::ThermalData::NetworkType::WIFI, "WiFi"}, + {cereal::ThermalData::NetworkType::CELL2_G, "2G"}, + {cereal::ThermalData::NetworkType::CELL3_G, "3G"}, + {cereal::ThermalData::NetworkType::CELL4_G, "4G"}, + {cereal::ThermalData::NetworkType::CELL5_G, "5G"}}; + const int network_x = 50; + const int network_y = 273; + const int network_w = 100; + const char *network_type = network_type_map[s->scene.thermal.getNetworkType()]; + nvgFillColor(s->vg, COLOR_WHITE); + nvgFontSize(s->vg, 48); + nvgFontFaceId(s->vg, s->font_sans_regular); + nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE); + nvgTextBox(s->vg, network_x, network_y, network_w, network_type ? network_type : "--", NULL); +} + +static void ui_draw_sidebar_metric(UIState *s, const char* label_str, const char* value_str, const int severity, const int y_offset, const char* message_str) { + const int metric_x = 30; + const int metric_y = 338 + y_offset; + const int metric_w = 240; + const int metric_h = message_str ? strchr(message_str, '\n') ? 124 : 100 : 148; + + NVGcolor status_color; + + if (severity == 0) { + status_color = COLOR_WHITE; + } else if (severity == 1) { + status_color = COLOR_YELLOW; + } else if (severity > 1) { + status_color = COLOR_RED; + } + + ui_draw_rect(s->vg, metric_x, metric_y, metric_w, metric_h, + severity > 0 ? COLOR_WHITE : COLOR_WHITE_ALPHA(85), 20, 2); + + nvgBeginPath(s->vg); + nvgRoundedRectVarying(s->vg, metric_x + 6, metric_y + 6, 18, metric_h - 12, 25, 0, 0, 25); + nvgFillColor(s->vg, status_color); + nvgFill(s->vg); + + if (!message_str) { + nvgFillColor(s->vg, COLOR_WHITE); + nvgFontSize(s->vg, 78); + nvgFontFaceId(s->vg, s->font_sans_bold); + nvgTextAlign(s->vg, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE); + nvgTextBox(s->vg, metric_x + 50, metric_y + 50, metric_w - 60, value_str, NULL); + + nvgFillColor(s->vg, COLOR_WHITE); + nvgFontSize(s->vg, 48); + nvgFontFaceId(s->vg, s->font_sans_regular); + nvgTextAlign(s->vg, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE); + nvgTextBox(s->vg, metric_x + 50, metric_y + 50 + 66, metric_w - 60, label_str, NULL); + } else { + nvgFillColor(s->vg, COLOR_WHITE); + nvgFontSize(s->vg, 48); + nvgFontFaceId(s->vg, s->font_sans_bold); + nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE); + nvgTextBox(s->vg, metric_x + 35, metric_y + (strchr(message_str, '\n') ? 40 : 50), metric_w - 50, message_str, NULL); + } +} + +static void ui_draw_sidebar_temp_metric(UIState *s) { + static std::map temp_severity_map = { + {cereal::ThermalData::ThermalStatus::GREEN, 0}, + {cereal::ThermalData::ThermalStatus::YELLOW, 1}, + {cereal::ThermalData::ThermalStatus::RED, 2}, + {cereal::ThermalData::ThermalStatus::DANGER, 3}}; + std::string temp_val = std::to_string((int)s->scene.thermal.getAmbient()) + "°C"; + ui_draw_sidebar_metric(s, "TEMP", temp_val.c_str(), temp_severity_map[s->scene.thermal.getThermalStatus()], 0, NULL); +} + +static void ui_draw_sidebar_panda_metric(UIState *s) { + const int panda_y_offset = 32 + 148; + + int panda_severity = 0; + std::string panda_message = "VEHICLE\nONLINE"; + if (s->scene.hwType == cereal::HealthData::HwType::UNKNOWN) { + panda_severity = 2; + panda_message = "NO\nVEHICLE"; + } else if (s->started) { + if (s->scene.satelliteCount < 6) { + panda_severity = 1; + panda_message = "VEHICLE\nNO GPS"; + } else { + panda_severity = 0; + panda_message = "VEHICLE\nGOOD GPS"; + } + } + ui_draw_sidebar_metric(s, NULL, NULL, panda_severity, panda_y_offset, panda_message.c_str()); +} + +static void ui_draw_sidebar_connectivity(UIState *s) { + static std::map> connectivity_map = { + {NET_ERROR, {"CONNECT\nERROR", 2}}, + {NET_CONNECTED, {"CONNECT\nONLINE", 0}}, + {NET_DISCONNECTED, {"CONNECT\nOFFLINE", 1}}, + }; + auto net_params = connectivity_map[s->scene.athenaStatus]; + ui_draw_sidebar_metric(s, NULL, NULL, net_params.second, 180+158, net_params.first); +} + +void ui_draw_sidebar(UIState *s) { + if (s->scene.uilayout_sidebarcollapsed) { + return; + } + ui_draw_sidebar_background(s); + ui_draw_sidebar_settings_button(s); + ui_draw_sidebar_home_button(s); + ui_draw_sidebar_network_strength(s); + ui_draw_sidebar_battery_icon(s); + ui_draw_sidebar_network_type(s); + ui_draw_sidebar_temp_metric(s); + ui_draw_sidebar_panda_metric(s); + ui_draw_sidebar_connectivity(s); +} diff --git a/selfdrive/ui/sidebar.hpp b/selfdrive/ui/sidebar.hpp new file mode 100644 index 00000000000000..f273e16f8bff70 --- /dev/null +++ b/selfdrive/ui/sidebar.hpp @@ -0,0 +1,4 @@ +#pragma once +#include "ui.hpp" + +void ui_draw_sidebar(UIState *s); diff --git a/selfdrive/ui/slplay.c b/selfdrive/ui/slplay.c deleted file mode 100644 index ddfbad56c5e6ba..00000000000000 --- a/selfdrive/ui/slplay.c +++ /dev/null @@ -1,184 +0,0 @@ -#include -#include -#include -#include -#include - -#include "common/timing.h" -#include "slplay.h" - -SLEngineItf engineInterface = NULL; -SLObjectItf outputMix = NULL; -SLObjectItf engine = NULL; -uri_player players[32] = {{NULL, NULL, NULL}}; - -uint64_t loop_start = 0; -uint64_t loop_start_ctx = 0; - -uri_player* get_player_by_uri(const char* uri) { - for (uri_player *s = players; s->uri != NULL; s++) { - if (strcmp(s->uri, uri) == 0) { - return s; - } - } - - return NULL; -} - -uri_player* slplay_create_player_for_uri(const char* uri, char **error) { - uri_player player = { uri, NULL, NULL }; - - SLresult result; - SLDataLocator_URI locUri = {SL_DATALOCATOR_URI, (SLchar *) uri}; - SLDataFormat_MIME formatMime = {SL_DATAFORMAT_MIME, NULL, SL_CONTAINERTYPE_UNSPECIFIED}; - SLDataSource audioSrc = {&locUri, &formatMime}; - - SLDataLocator_OutputMix outMix = {SL_DATALOCATOR_OUTPUTMIX, outputMix}; - SLDataSink audioSnk = {&outMix, NULL}; - - result = (*engineInterface)->CreateAudioPlayer(engineInterface, &player.player, &audioSrc, &audioSnk, 0, NULL, NULL); - if (result != SL_RESULT_SUCCESS) { - *error = "Failed to create audio player"; - return NULL; - } - - result = (*(player.player))->Realize(player.player, SL_BOOLEAN_FALSE); - if (result != SL_RESULT_SUCCESS) { - *error = "Failed to realize audio player"; - return NULL; - } - - result = (*(player.player))->GetInterface(player.player, SL_IID_PLAY, &(player.playInterface)); - if (result != SL_RESULT_SUCCESS) { - *error = "Failed to get player interface"; - return NULL; - } - - result = (*(player.playInterface))->SetPlayState(player.playInterface, SL_PLAYSTATE_PAUSED); - if (result != SL_RESULT_SUCCESS) { - *error = "Failed to initialize playstate to SL_PLAYSTATE_PAUSED"; - return NULL; - } - - uri_player *p = players; - while (p->uri != NULL) { - p++; - } - *p = player; - - return p; -} - -void slplay_setup(char **error) { - SLresult result; - SLEngineOption engineOptions[] = {{SL_ENGINEOPTION_THREADSAFE, SL_BOOLEAN_TRUE}}; - result = slCreateEngine(&engine, 1, engineOptions, 0, NULL, NULL); - if (result != SL_RESULT_SUCCESS) { - *error = "Failed to create OpenSL engine"; - } - - result = (*engine)->Realize(engine, SL_BOOLEAN_FALSE); - if (result != SL_RESULT_SUCCESS) { - *error = "Failed to realize OpenSL engine"; - } - - result = (*engine)->GetInterface(engine, SL_IID_ENGINE, &engineInterface); - if (result != SL_RESULT_SUCCESS) { - *error = "Failed to realize OpenSL engine"; - } - - const SLInterfaceID ids[1] = {SL_IID_VOLUME}; - const SLboolean req[1] = {SL_BOOLEAN_FALSE}; - result = (*engineInterface)->CreateOutputMix(engineInterface, &outputMix, 1, ids, req); - if (result != SL_RESULT_SUCCESS) { - *error = "Failed to create output mix"; - } - - result = (*outputMix)->Realize(outputMix, SL_BOOLEAN_FALSE); - if (result != SL_RESULT_SUCCESS) { - *error = "Failed to realize output mix"; - } -} - -void slplay_destroy() { - for (uri_player *player = players; player->uri != NULL; player++) { - if (player->player) { - (*(player->player))->Destroy(player->player); - } - } - - (*outputMix)->Destroy(outputMix); - (*engine)->Destroy(engine); -} - -void slplay_stop(uri_player* player, char **error) { - SLPlayItf playInterface = player->playInterface; - SLresult result; - - // stop a loop - loop_start = 0; - - result = (*playInterface)->SetPlayState(playInterface, SL_PLAYSTATE_PAUSED); - if (result != SL_RESULT_SUCCESS) { - *error = "Failed to set SL_PLAYSTATE_STOPPED"; - return; - } -} - -void slplay_stop_uri(const char* uri, char **error) { - uri_player* player = get_player_by_uri(uri); - slplay_stop(player, error); -} - -void SLAPIENTRY slplay_callback(SLPlayItf playItf, void *context, SLuint32 event) { - uint64_t cb_loop_start = *((uint64_t*)context); - if (event == SL_PLAYEVENT_HEADATEND && cb_loop_start == loop_start) { - (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED); - (*playItf)->SetMarkerPosition(playItf, 0); - (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_PLAYING); - } -} - -void slplay_play (const char *uri, bool loop, char **error) { - SLresult result; - - uri_player* player = get_player_by_uri(uri); - if (player == NULL) { - player = slplay_create_player_for_uri(uri, error); - if (*error) { - return; - } - } - - SLPlayItf playInterface = player->playInterface; - if (loop) { - loop_start = nanos_since_boot(); - loop_start_ctx = loop_start; - result = (*playInterface)->RegisterCallback(playInterface, slplay_callback, &loop_start_ctx); - if (result != SL_RESULT_SUCCESS) { - char error[64]; - snprintf(error, sizeof(error), "Failed to register callback. %d", result); - *error = error[0]; - return; - } - - result = (*playInterface)->SetCallbackEventsMask(playInterface, SL_PLAYEVENT_HEADATEND); - if (result != SL_RESULT_SUCCESS) { - *error = "Failed to set callback event mask"; - return; - } - } - - // Reset the audio player - result = (*playInterface)->ClearMarkerPosition(playInterface); - if (result != SL_RESULT_SUCCESS) { - *error = "Failed to clear marker position"; - return; - } - result = (*playInterface)->SetPlayState(playInterface, SL_PLAYSTATE_PAUSED); - result = (*playInterface)->SetPlayState(playInterface, SL_PLAYSTATE_STOPPED); - result = (*playInterface)->SetPlayState(playInterface, SL_PLAYSTATE_PLAYING); - if (result != SL_RESULT_SUCCESS) { - *error = "Failed to set SL_PLAYSTATE_PLAYING"; - } -} diff --git a/selfdrive/ui/slplay.h b/selfdrive/ui/slplay.h deleted file mode 100644 index f8c39ceeb7cb2c..00000000000000 --- a/selfdrive/ui/slplay.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef SLPLAY_H -#define SLPLAY_H - -#include -#include -#include - -typedef struct { - const char* uri; - SLObjectItf player; - SLPlayItf playInterface; -} uri_player; - -void slplay_setup(char **error); -uri_player* slplay_create_player_for_uri(const char* uri, char **error); -void slplay_play (const char *uri, bool loop, char **error); -void slplay_stop_uri (const char* uri, char **error); -void slplay_destroy(); - -#endif - diff --git a/selfdrive/ui/sound.hpp b/selfdrive/ui/sound.hpp new file mode 100644 index 00000000000000..bdb85908018300 --- /dev/null +++ b/selfdrive/ui/sound.hpp @@ -0,0 +1,24 @@ +#pragma once +#include +#include "cereal/gen/cpp/log.capnp.h" + +typedef cereal::CarControl::HUDControl::AudibleAlert AudibleAlert; + +static std::map> sound_map { + // AudibleAlert, (file path, loop count) + {AudibleAlert::CHIME_DISENGAGE, {"../assets/sounds/disengaged.wav", 0}}, + {AudibleAlert::CHIME_ENGAGE, {"../assets/sounds/engaged.wav", 0}}, + {AudibleAlert::CHIME_WARNING1, {"../assets/sounds/warning_1.wav", 0}}, + {AudibleAlert::CHIME_WARNING2, {"../assets/sounds/warning_2.wav", 0}}, + {AudibleAlert::CHIME_WARNING2_REPEAT, {"../assets/sounds/warning_2.wav", 3}}, + {AudibleAlert::CHIME_WARNING_REPEAT, {"../assets/sounds/warning_repeat.wav", -1}}, + {AudibleAlert::CHIME_ERROR, {"../assets/sounds/error.wav", 0}}, + {AudibleAlert::CHIME_PROMPT, {"../assets/sounds/error.wav", 0}} +}; + +class Sound { +public: + virtual bool play(AudibleAlert alert) = 0; + virtual void stop() = 0; + virtual void setVolume(int volume) = 0; +}; diff --git a/selfdrive/ui/spinner b/selfdrive/ui/spinner new file mode 100755 index 00000000000000..c2ef33b7ec5c05 --- /dev/null +++ b/selfdrive/ui/spinner @@ -0,0 +1,12 @@ +#!/bin/sh + +if [ -f /EON ]; then + export LD_LIBRARY_PATH="/system/lib64:$LD_LIBRARY_PATH" + exec ./android/spinner/spinner "$1" +else + if [ -f /TICI ] && [ ! -f qt/spinner ]; then + cp qt/spinner_aarch64 qt/spinner + fi + + exec ./qt/spinner "$1" +fi diff --git a/selfdrive/ui/spinner/spinner b/selfdrive/ui/spinner/spinner deleted file mode 100755 index 65c198aabda3d2..00000000000000 Binary files a/selfdrive/ui/spinner/spinner and /dev/null differ diff --git a/selfdrive/ui/spinner/spinner.c b/selfdrive/ui/spinner/spinner.c deleted file mode 100644 index 3ec36e7403f3de..00000000000000 --- a/selfdrive/ui/spinner/spinner.c +++ /dev/null @@ -1,100 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "nanovg.h" -#define NANOVG_GLES3_IMPLEMENTATION -#include "nanovg_gl.h" -#include "nanovg_gl_utils.h" - -#include "common/framebuffer.h" - -int main(int argc, char** argv) { - int err; - - const char* spintext = NULL; - if (argc >= 2) { - spintext = argv[1]; - } - - // spinner - int fb_w, fb_h; - EGLDisplay display; - EGLSurface surface; - FramebufferState *fb = framebuffer_init("spinner", 0x00001000, false, - &display, &surface, &fb_w, &fb_h); - assert(fb); - - NVGcontext *vg = nvgCreateGLES3(NVG_ANTIALIAS | NVG_STENCIL_STROKES); - assert(vg); - - int font = nvgCreateFont(vg, "Bold", "../../assets/fonts/opensans_semibold.ttf"); - assert(font >= 0); - - int spinner_img = nvgCreateImage(vg, "../../assets/img_spinner_track.png", 0); - assert(spinner_img >= 0); - int spinner_img_s = 360; - int spinner_img_x = ((fb_w/2)-(spinner_img_s/2)); - int spinner_img_y = 260; - int spinner_img_xc = (fb_w/2); - int spinner_img_yc = (fb_h/2)-100; - int spinner_comma_img = nvgCreateImage(vg, "../../assets/img_spinner_comma.png", 0); - assert(spinner_comma_img >= 0); - - for (int cnt = 0; ; cnt++) { - glClearColor(0.1, 0.1, 0.1, 1.0); - glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - nvgBeginFrame(vg, fb_w, fb_h, 1.0f); - - // background - nvgBeginPath(vg); - NVGpaint bg = nvgLinearGradient(vg, fb_w, 0, fb_w, fb_h, - nvgRGBA(0, 0, 0, 175), nvgRGBA(0, 0, 0, 255)); - nvgFillPaint(vg, bg); - nvgRect(vg, 0, 0, fb_w, fb_h); - nvgFill(vg); - - // spin track - nvgSave(vg); - nvgTranslate(vg, spinner_img_xc, spinner_img_yc); - nvgRotate(vg, (3.75*M_PI * cnt/120.0)); - nvgTranslate(vg, -spinner_img_xc, -spinner_img_yc); - NVGpaint spinner_imgPaint = nvgImagePattern(vg, spinner_img_x, spinner_img_y, - spinner_img_s, spinner_img_s, 0, spinner_img, 0.6f); - nvgBeginPath(vg); - nvgFillPaint(vg, spinner_imgPaint); - nvgRect(vg, spinner_img_x, spinner_img_y, spinner_img_s, spinner_img_s); - nvgFill(vg); - nvgRestore(vg); - - // comma - NVGpaint comma_imgPaint = nvgImagePattern(vg, spinner_img_x, spinner_img_y, - spinner_img_s, spinner_img_s, 0, spinner_comma_img, 1.0f); - nvgBeginPath(vg); - nvgFillPaint(vg, comma_imgPaint); - nvgRect(vg, spinner_img_x, spinner_img_y, spinner_img_s, spinner_img_s); - nvgFill(vg); - - // message - if (spintext) { - nvgTextAlign(vg, NVG_ALIGN_CENTER | NVG_ALIGN_TOP); - nvgFontSize(vg, 96.0f); - nvgText(vg, fb_w/2, (fb_h*2/3)+24, spintext, NULL); - } - - nvgEndFrame(vg); - eglSwapBuffers(display, surface); - assert(glGetError() == GL_NO_ERROR); - } - - return 0; -} diff --git a/selfdrive/ui/start.py b/selfdrive/ui/start.py deleted file mode 100755 index e3e629b545d12c..00000000000000 --- a/selfdrive/ui/start.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python2 -import os - -assert os.system("make") == 0 -os.environ['LD_LIBRARY_PATH'] = "/system/lib64:"+os.environ['LD_LIBRARY_PATH'] -os.execv("./ui", ["ui"]) - diff --git a/selfdrive/ui/tbui.cc b/selfdrive/ui/tbui.cc new file mode 100644 index 00000000000000..e32f6ed7a9f100 --- /dev/null +++ b/selfdrive/ui/tbui.cc @@ -0,0 +1,78 @@ +#include +#include +#include +#include +#include "ui.hpp" +#include "paint.hpp" + +void ui_draw_infobar(UIState *s) { + const UIScene *scene = &s->scene; + int ui_viz_rx = scene->viz_rect.x; + bool hasSidebar = !s->scene.uilayout_sidebarcollapsed; + int rect_w = s->b.scr_w - ui_viz_rx - bdr_s; + int rect_h = 60; + int rect_x = 0; + // rect_y = screen height - board - background height + int rect_y = s->b.scr_h - bdr_s - (int) (rect_h/2) - 5; + rect_x = rect_x + ui_viz_rx; + + int text_x = rect_w / 2; + text_x = text_x + ui_viz_rx; + int text_y = rect_y + 45; + + // Get local time to display + char infobar[68]; + time_t t = time(NULL); + struct tm tm = *localtime(&t); + + char uom_str[5]; + snprintf(uom_str, sizeof(uom_str), s->is_metric ? "km/h" : "mph"); + char spd[6]; + float v_ego = s->scene.controls_state.getVEgo(); + snprintf(spd, sizeof(spd), "%.1f ", s->is_metric ? v_ego * 3.6 : v_ego * 2.2369363); + + char ang_steer[9]; + snprintf(ang_steer, sizeof(ang_steer), "%s%03.1f°", s->b.angleSteers < 0? "-" : "+", fabs(s->b.angleSteers)); + + char lead_dist[8]; + if (s->scene.lead_data[0].getStatus()) { + snprintf(lead_dist, sizeof(lead_dist), "%05.2fm", s->scene.lead_data[0].getDRel()); + } else { + snprintf(lead_dist, sizeof(lead_dist), "%3s", "N/A"); + } + + char maxspeed_str[7]; + float v_cruise = s->scene.controls_state.getVCruise(); + if (s->scene.controls_state.getEnabled() && v_cruise > 0) { + float maxspeed = s->is_metric ? v_cruise : v_cruise / 1.609; + snprintf(maxspeed_str, sizeof(maxspeed_str), "/%.1f", maxspeed); + } + + snprintf( + infobar, + sizeof(infobar), + "%04d/%02d/%02d %02d:%02d:%02d | %s%s %s | DST: %s | ANG: %s", + tm.tm_year + 1900, + tm.tm_mon + 1, + tm.tm_mday, + tm.tm_hour, + tm.tm_min, + tm.tm_sec, + spd, + maxspeed_str, + uom_str, + lead_dist, + ang_steer + ); + + nvgBeginPath(s->vg); + nvgRoundedRect(s->vg, rect_x, rect_y, rect_w, rect_h, 5); + nvgFillColor(s->vg, nvgRGBA(0, 0, 0, 180)); + nvgFill(s->vg); + + nvgFontSize(s->vg, hasSidebar? 40:50); + nvgFontFace(s->vg, "sans-regular"); + nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 180)); + nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_BASELINE); + nvgText(s->vg, text_x, text_y, infobar, NULL); +} diff --git a/selfdrive/ui/tbui.hpp b/selfdrive/ui/tbui.hpp new file mode 100644 index 00000000000000..1a2d4e0dc7993a --- /dev/null +++ b/selfdrive/ui/tbui.hpp @@ -0,0 +1 @@ +void ui_draw_infobar(UIState *s); \ No newline at end of file diff --git a/selfdrive/ui/text b/selfdrive/ui/text new file mode 100755 index 00000000000000..085425e8aca700 --- /dev/null +++ b/selfdrive/ui/text @@ -0,0 +1,12 @@ +#!/bin/sh + +if [ -f /EON ]; then + export LD_LIBRARY_PATH="/system/lib64:$LD_LIBRARY_PATH" + exec ./android/text/text "$1" +else + if [ -f /TICI ] && [ ! -f qt/text ]; then + cp qt/text_aarch64 qt/text + fi + + exec ./qt/text "$1" +fi diff --git a/selfdrive/ui/ui b/selfdrive/ui/ui new file mode 100755 index 00000000000000..c7eb6f9d210b69 --- /dev/null +++ b/selfdrive/ui/ui @@ -0,0 +1,9 @@ +#!/bin/sh +export LD_LIBRARY_PATH="/system/lib64:$LD_LIBRARY_PATH" +. /data/openpilot/selfdrive/car/tesla/readconfig.sh +TBP=/data/tinkla_buddy_pro +if test -f "$TBP"; then + exec /usr/bin/startx ./_ui $jetson_monitor_forced_resolution +else + exec ./_ui +fi diff --git a/selfdrive/ui/ui.c b/selfdrive/ui/ui.c deleted file mode 100644 index 689efaf2257408..00000000000000 --- a/selfdrive/ui/ui.c +++ /dev/null @@ -1,2474 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include - -#include "nanovg.h" -#define NANOVG_GLES3_IMPLEMENTATION -#include "nanovg_gl.h" -#include "nanovg_gl_utils.h" - -#include "common/messaging.h" -#include "common/timing.h" -#include "common/util.h" -#include "common/swaglog.h" -#include "common/mat.h" -#include "common/glutil.h" - -#include "common/touch.h" -#include "common/framebuffer.h" -#include "common/visionipc.h" -#include "common/visionimg.h" -#include "common/modeldata.h" -#include "common/params.h" - -#include "cereal/gen/c/log.capnp.h" -#include "slplay.h" - -//BB include BBUIState def -#include "bbuistate.h" -//BB end - - -#define STATUS_STOPPED 0 -#define STATUS_DISENGAGED 1 -#define STATUS_ENGAGED 2 -#define STATUS_WARNING 3 -#define STATUS_ALERT 4 -#define STATUS_MAX 5 - -#define ALERTSIZE_NONE 0 -#define ALERTSIZE_SMALL 1 -#define ALERTSIZE_MID 2 -#define ALERTSIZE_FULL 3 - -#define UI_BUF_COUNT 4 -//#define SHOW_SPEEDLIMIT 1 -//#define DEBUG_TURN - -//#define DEBUG_FPS - -const int vwp_w = 1920; -const int vwp_h = 1080; -const int nav_w = 640; -const int nav_ww= 760; -const int sbr_w = 300; -const int bdr_s = 30; -const int box_x = sbr_w+bdr_s; -const int box_y = bdr_s; -const int box_w = vwp_w-sbr_w-(bdr_s*2); -const int box_h = vwp_h-(bdr_s*2); -const int viz_w = vwp_w-(bdr_s*2); -const int header_h = 420; -const int footer_h = 280; -const int footer_y = vwp_h-bdr_s-footer_h; - -const int UI_FREQ = 30; // Hz - -const int MODEL_PATH_MAX_VERTICES_CNT = 98; -const int MODEL_LANE_PATH_CNT = 3; -const int TRACK_POINTS_MAX_CNT = 50 * 2; - -const uint8_t bg_colors[][4] = { - [STATUS_STOPPED] = {0x07, 0x23, 0x39, 0xff}, - [STATUS_DISENGAGED] = {0x17, 0x33, 0x49, 0xff}, - [STATUS_ENGAGED] = {0x17, 0x86, 0x44, 0xff}, - [STATUS_WARNING] = {0xDA, 0x6F, 0x25, 0xff}, - [STATUS_ALERT] = {0xC9, 0x22, 0x31, 0xff}, -}; - -const uint8_t alert_colors[][4] = { - [STATUS_STOPPED] = {0x07, 0x23, 0x39, 0xf1}, - [STATUS_DISENGAGED] = {0x17, 0x33, 0x49, 0xc8}, - [STATUS_ENGAGED] = {0x17, 0x86, 0x44, 0xf1}, - [STATUS_WARNING] = {0xDA, 0x6F, 0x25, 0xf1}, - [STATUS_ALERT] = {0xC9, 0x22, 0x31, 0xf1}, -}; - -const int alert_sizes[] = { - [ALERTSIZE_NONE] = 0, - [ALERTSIZE_SMALL] = 241, - [ALERTSIZE_MID] = 390, - [ALERTSIZE_FULL] = vwp_h, -}; - -const int SET_SPEED_NA = 255; - -// TODO: this is also hardcoded in common/transformations/camera.py -const mat3 intrinsic_matrix = (mat3){{ - 910., 0., 582., - 0., 910., 437., - 0., 0., 1. -}}; - -typedef enum cereal_CarControl_HUDControl_AudibleAlert AudibleAlert; - -typedef struct UIScene { - int frontview; - int fullview; - - int transformed_width, transformed_height; - - uint64_t model_ts; - ModelData model; - - float mpc_x[50]; - float mpc_y[50]; - - bool world_objects_visible; - mat3 warp_matrix; // transformed box -> frame. - mat4 extrinsic_matrix; // Last row is 0 so we can use mat4. - - float v_cruise; - uint64_t v_cruise_update_ts; - float v_ego; - bool decel_for_model; - - float speedlimit; - bool speedlimit_valid; - bool map_valid; - - float curvature; - int engaged; - bool engageable; - bool monitoring_active; - - bool uilayout_sidebarcollapsed; - bool uilayout_mapenabled; - // responsive layout - int ui_viz_rx; - int ui_viz_rw; - int ui_viz_ro; - - int lead_status; - float lead_d_rel, lead_y_rel, lead_v_rel; - - int front_box_x, front_box_y, front_box_width, front_box_height; - - uint64_t alert_ts; - char alert_text1[1024]; - char alert_text2[1024]; - uint8_t alert_size; - float alert_blinkingrate; - - float awareness_status; - - uint64_t started_ts; - - - // Used to show gps planner status - bool gps_planner_active; -} UIScene; - -typedef struct { - float x, y; -}vertex_data; - -typedef struct { - vertex_data v[MODEL_PATH_MAX_VERTICES_CNT]; - int cnt; -} model_path_vertices_data; - -typedef struct { - vertex_data v[TRACK_POINTS_MAX_CNT]; - int cnt; -} track_vertices_data; - - -typedef struct UIState { - //BB define BBUIState - BBUIState b; - //BB end - pthread_mutex_t lock; - pthread_cond_t bg_cond; - - FramebufferState *fb; - int fb_w, fb_h; - EGLDisplay display; - EGLSurface surface; - - NVGcontext *vg; - - int font_courbd; - int font_sans_regular; - int font_sans_semibold; - int font_sans_bold; - int img_wheel; - int img_turn; - int img_face; - int img_map; - - void *ctx; - - void *thermal_sock_raw; - void *model_sock_raw; - void *controlsstate_sock_raw; - void *livecalibration_sock_raw; - void *radarstate_sock_raw; - void *livempc_sock_raw; - void *plus_sock_raw; - void *map_data_sock_raw; - - void *uilayout_sock_raw; - - int plus_state; - - // vision state - bool vision_connected; - bool vision_connect_firstrun; - int ipc_fd; - - VIPCBuf bufs[UI_BUF_COUNT]; - VIPCBuf front_bufs[UI_BUF_COUNT]; - int cur_vision_idx; - int cur_vision_front_idx; - - GLuint frame_program; - GLuint frame_texs[UI_BUF_COUNT]; - EGLImageKHR khr[UI_BUF_COUNT]; - void *priv_hnds[UI_BUF_COUNT]; - GLuint frame_front_texs[UI_BUF_COUNT]; - EGLImageKHR khr_front[UI_BUF_COUNT]; - void *priv_hnds_front[UI_BUF_COUNT]; - - GLint frame_pos_loc, frame_texcoord_loc; - GLint frame_texture_loc, frame_transform_loc; - - GLuint line_program; - GLint line_pos_loc, line_color_loc; - GLint line_transform_loc; - - unsigned int rgb_width, rgb_height, rgb_stride; - size_t rgb_buf_len; - mat4 rgb_transform; - - unsigned int rgb_front_width, rgb_front_height, rgb_front_stride; - size_t rgb_front_buf_len; - - UIScene scene; - - bool awake; - int awake_timeout; - - int volume_timeout; - int alert_sound_timeout; - int speed_lim_off_timeout; - int is_metric_timeout; - int longitudinal_control_timeout; - int limit_set_speed_timeout; - - int status; - bool is_metric; - bool longitudinal_control; - bool limit_set_speed; - float speed_lim_off; - bool is_ego_over_limit; - char alert_type[64]; - AudibleAlert alert_sound; - int alert_size; - float alert_blinking_alpha; - bool alert_blinked; - - float light_sensor; - - int touch_fd; - - // Hints for re-calculations and redrawing - bool model_changed; - bool livempc_or_radarstate_changed; - - GLuint frame_vao[2], frame_vbo[2], frame_ibo[2]; - mat4 rear_frame_mat, front_frame_mat; - - model_path_vertices_data model_path_vertices[MODEL_LANE_PATH_CNT * 2]; - - track_vertices_data track_vertices[2]; -} UIState; - - - -static int last_brightness = -1; -static void set_brightness(UIState *s, int brightness) { - if (last_brightness != brightness && (s->awake || brightness == 0)) { - FILE *f = fopen("/sys/class/leds/lcd-backlight/brightness", "wb"); - if (f != NULL) { - fprintf(f, "%d", brightness); - fclose(f); - last_brightness = brightness; - } - } -} - -static void set_awake(UIState *s, bool awake) { - if (awake) { - // 30 second timeout at 30 fps - if ((s->b.tri_state_switch == 3) || (s->b.keepEonOff)) { - s->awake_timeout = 3*30; - } else { - s->awake_timeout = 30*30; - } - } - if (s->awake != awake) { - s->awake = awake; - - // TODO: replace command_awake and command_sleep with direct calls to android - if (awake) { - LOG("awake normal"); - set_brightness(s, 150); - system("service call window 18 i32 1"); // enable event processing - framebuffer_set_power(s->fb, HWC_POWER_MODE_NORMAL); - } else { - LOGW("awake off"); - set_brightness(s, 0); - system("service call window 18 i32 0"); // disable event processing - framebuffer_set_power(s->fb, HWC_POWER_MODE_OFF); - } - } -} - -#include "dashcam.h" -#include "bbui.h" - -static void set_volume(UIState *s, int volume) { - char volume_change_cmd[64]; - sprintf(volume_change_cmd, "service call audio 3 i32 3 i32 %d i32 1", volume); - - // 5 second timeout at 60fps - s->volume_timeout = 5 * UI_FREQ; - int volume_changed = system(volume_change_cmd); -} - -volatile int do_exit = 0; -static void set_do_exit(int sig) { - do_exit = 1; -} - -static void read_param_bool(bool* param, char* param_name) { - char *s; - const int result = read_db_value(NULL, param_name, &s, NULL); - if (result == 0) { - *param = s[0] == '1'; - free(s); - } -} - -static void read_param_float(float* param, char* param_name) { - char *s; - const int result = read_db_value(NULL, param_name, &s, NULL); - if (result == 0) { - *param = strtod(s, NULL); - free(s); - } -} - -static void read_param_bool_timeout(bool* param, char* param_name, int* timeout) { - if (*timeout > 0){ - (*timeout)--; - } else { - read_param_bool(param, param_name); - *timeout = 2 * UI_FREQ; // 0.5Hz - } -} - -static void read_param_float_timeout(float* param, char* param_name, int* timeout) { - if (*timeout > 0){ - (*timeout)--; - } else { - read_param_float(param, param_name); - *timeout = 2 * UI_FREQ; // 0.5Hz - } -} - -static const char frame_vertex_shader[] = - "attribute vec4 aPosition;\n" - "attribute vec4 aTexCoord;\n" - "uniform mat4 uTransform;\n" - "varying vec4 vTexCoord;\n" - "void main() {\n" - " gl_Position = uTransform * aPosition;\n" - " vTexCoord = aTexCoord;\n" - "}\n"; - -static const char frame_fragment_shader[] = - "precision mediump float;\n" - "uniform sampler2D uTexture;\n" - "varying vec4 vTexCoord;\n" - "void main() {\n" - " gl_FragColor = texture2D(uTexture, vTexCoord.xy);\n" - "}\n"; - -static const char line_vertex_shader[] = - "attribute vec4 aPosition;\n" - "attribute vec4 aColor;\n" - "uniform mat4 uTransform;\n" - "varying vec4 vColor;\n" - "void main() {\n" - " gl_Position = uTransform * aPosition;\n" - " vColor = aColor;\n" - "}\n"; - -static const char line_fragment_shader[] = - "precision mediump float;\n" - "uniform sampler2D uTexture;\n" - "varying vec4 vColor;\n" - "void main() {\n" - " gl_FragColor = vColor;\n" - "}\n"; - - -static const mat4 device_transform = {{ - 1.0, 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, 1.0, -}}; - -// frame from 4/3 to box size with a 2x zoom -static const mat4 frame_transform = {{ - 2*(4./3.)/((float)viz_w/box_h), 0.0, 0.0, 0.0, - 0.0, 2.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, 1.0, -}}; - -// frame from 4/3 to 16/9 display -static const mat4 full_to_wide_frame_transform = {{ - .75, 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, 1.0, -}}; - -typedef struct { - AudibleAlert alert; - const char* uri; - bool loop; -} sound_file; - -sound_file sound_table[] = { - { cereal_CarControl_HUDControl_AudibleAlert_chimeDisengage, "../assets/sounds/disengaged.wav", false }, - { cereal_CarControl_HUDControl_AudibleAlert_chimeEngage, "../assets/sounds/engaged.wav", false }, - { cereal_CarControl_HUDControl_AudibleAlert_chimeWarning1, "../assets/sounds/warning_1.wav", false }, - { cereal_CarControl_HUDControl_AudibleAlert_chimeWarning2, "../assets/sounds/warning_2.wav", false }, - { cereal_CarControl_HUDControl_AudibleAlert_chimeWarningRepeat, "../assets/sounds/warning_2.wav", true }, - { cereal_CarControl_HUDControl_AudibleAlert_chimeError, "../assets/sounds/error.wav", false }, - { cereal_CarControl_HUDControl_AudibleAlert_chimePrompt, "../assets/sounds/error.wav", false }, - { cereal_CarControl_HUDControl_AudibleAlert_none, NULL, false }, -}; - -sound_file* get_sound_file(AudibleAlert alert) { - for (sound_file *s = sound_table; s->alert != cereal_CarControl_HUDControl_AudibleAlert_none; s++) { - if (s->alert == alert) { - return s; - } - } - - return NULL; -} - - -void ui_sound_init(char **error) { - slplay_setup(error); - if (*error) return; - - for (sound_file *s = sound_table; s->alert != cereal_CarControl_HUDControl_AudibleAlert_none; s++) { - slplay_create_player_for_uri(s->uri, error); - if (*error) return; - } -} - -static void ui_init(UIState *s) { - memset(s, 0, sizeof(UIState)); - - pthread_mutex_init(&s->lock, NULL); - pthread_cond_init(&s->bg_cond, NULL); - - s->ctx = zmq_ctx_new(); - - s->thermal_sock_raw = sub_sock(s->ctx, "tcp://127.0.0.1:8005"); - s->model_sock_raw = sub_sock(s->ctx, "tcp://127.0.0.1:8009"); - s->controlsstate_sock_raw = sub_sock(s->ctx, "tcp://127.0.0.1:8007"); - s->uilayout_sock_raw = sub_sock(s->ctx, "tcp://127.0.0.1:8060"); - s->livecalibration_sock_raw = sub_sock(s->ctx, "tcp://127.0.0.1:8019"); - s->radarstate_sock_raw = sub_sock(s->ctx, "tcp://127.0.0.1:8012"); - s->livempc_sock_raw = sub_sock(s->ctx, "tcp://127.0.0.1:8035"); - s->plus_sock_raw = sub_sock(s->ctx, "tcp://127.0.0.1:8037"); - s->map_data_sock_raw = sub_sock(s->ctx, "tcp://127.0.0.1:8065"); - - s->ipc_fd = -1; - - // init display - s->fb = framebuffer_init("ui", 0x00010000, true, - &s->display, &s->surface, &s->fb_w, &s->fb_h); - assert(s->fb); - - set_awake(s, true); - - // init drawing - s->vg = nvgCreateGLES3(NVG_ANTIALIAS | NVG_STENCIL_STROKES | NVG_DEBUG); - assert(s->vg); - - s->font_courbd = nvgCreateFont(s->vg, "courbd", "../assets/fonts/courbd.ttf"); - assert(s->font_courbd >= 0); - s->font_sans_regular = nvgCreateFont(s->vg, "sans-regular", "../assets/fonts/opensans_regular.ttf"); - assert(s->font_sans_regular >= 0); - s->font_sans_semibold = nvgCreateFont(s->vg, "sans-semibold", "../assets/fonts/opensans_semibold.ttf"); - assert(s->font_sans_semibold >= 0); - s->font_sans_bold = nvgCreateFont(s->vg, "sans-bold", "../assets/fonts/opensans_bold.ttf"); - assert(s->font_sans_bold >= 0); - - assert(s->img_wheel >= 0); - s->img_wheel = nvgCreateImage(s->vg, "../assets/img_chffr_wheel.png", 1); - - assert(s->img_turn >= 0); - s->img_turn = nvgCreateImage(s->vg, "../assets/img_trafficSign_turn.png", 1); - - assert(s->img_face >= 0); - s->img_face = nvgCreateImage(s->vg, "../assets/img_driver_face.png", 1); - - assert(s->img_map >= 0); - s->img_map = nvgCreateImage(s->vg, "../assets/img_map.png", 1); - - // init gl - s->frame_program = load_program(frame_vertex_shader, frame_fragment_shader); - assert(s->frame_program); - - s->frame_pos_loc = glGetAttribLocation(s->frame_program, "aPosition"); - s->frame_texcoord_loc = glGetAttribLocation(s->frame_program, "aTexCoord"); - - s->frame_texture_loc = glGetUniformLocation(s->frame_program, "uTexture"); - s->frame_transform_loc = glGetUniformLocation(s->frame_program, "uTransform"); - - s->line_program = load_program(line_vertex_shader, line_fragment_shader); - assert(s->line_program); - - s->line_pos_loc = glGetAttribLocation(s->line_program, "aPosition"); - s->line_color_loc = glGetAttribLocation(s->line_program, "aColor"); - s->line_transform_loc = glGetUniformLocation(s->line_program, "uTransform"); - - glViewport(0, 0, s->fb_w, s->fb_h); - - glDisable(GL_DEPTH_TEST); - - assert(glGetError() == GL_NO_ERROR); - - for(int i = 0; i < 2; i++) { - float x1, x2, y1, y2; - if (i == 1) { - // flip horizontally so it looks like a mirror - x1 = 0.0; - x2 = 1.0; - y1 = 1.0; - y2 = 0.0; - } else { - x1 = 1.0; - x2 = 0.0; - y1 = 1.0; - y2 = 0.0; - } - const uint8_t frame_indicies[] = {0, 1, 2, 0, 2, 3}; - const float frame_coords[4][4] = { - {-1.0, -1.0, x2, y1}, //bl - {-1.0, 1.0, x2, y2}, //tl - { 1.0, 1.0, x1, y2}, //tr - { 1.0, -1.0, x1, y1}, //br - }; - - glGenVertexArrays(1,&s->frame_vao[i]); - glBindVertexArray(s->frame_vao[i]); - glGenBuffers(1, &s->frame_vbo[i]); - glBindBuffer(GL_ARRAY_BUFFER, s->frame_vbo[i]); - glBufferData(GL_ARRAY_BUFFER, sizeof(frame_coords), frame_coords, GL_STATIC_DRAW); - glEnableVertexAttribArray(s->frame_pos_loc); - glVertexAttribPointer(s->frame_pos_loc, 2, GL_FLOAT, GL_FALSE, - sizeof(frame_coords[0]), (const void *)0); - glEnableVertexAttribArray(s->frame_texcoord_loc); - glVertexAttribPointer(s->frame_texcoord_loc, 2, GL_FLOAT, GL_FALSE, - sizeof(frame_coords[0]), (const void *)(sizeof(float) * 2)); - glGenBuffers(1, &s->frame_ibo[i]); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s->frame_ibo[i]); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(frame_indicies), frame_indicies, GL_STATIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER,0); - glBindVertexArray(0); - } - - s->model_changed = false; - s->livempc_or_radarstate_changed = false; - - s->front_frame_mat = matmul(device_transform, full_to_wide_frame_transform); - s->rear_frame_mat = matmul(device_transform, frame_transform); - - for(int i = 0;i < UI_BUF_COUNT; i++) { - s->khr[i] = NULL; - s->priv_hnds[i] = NULL; - s->khr_front[i] = NULL; - s->priv_hnds_front[i] = NULL; - } -} - -static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs, - int num_back_fds, const int *back_fds, - const VisionStreamBufs front_bufs, int num_front_fds, - const int *front_fds) { - const VisionUIInfo ui_info = back_bufs.buf_info.ui_info; - - assert(num_back_fds == UI_BUF_COUNT); - assert(num_front_fds == UI_BUF_COUNT); - - vipc_bufs_load(s->bufs, &back_bufs, num_back_fds, back_fds); - vipc_bufs_load(s->front_bufs, &front_bufs, num_front_fds, front_fds); - - s->cur_vision_idx = -1; - s->cur_vision_front_idx = -1; - - s->scene = (UIScene){ - .frontview = getenv("FRONTVIEW") != NULL, - .fullview = getenv("FULLVIEW") != NULL, - .transformed_width = ui_info.transformed_width, - .transformed_height = ui_info.transformed_height, - .front_box_x = ui_info.front_box_x, - .front_box_y = ui_info.front_box_y, - .front_box_width = ui_info.front_box_width, - .front_box_height = ui_info.front_box_height, - .world_objects_visible = false, // Invisible until we receive a calibration message. - .gps_planner_active = false, - }; - - s->rgb_width = back_bufs.width; - s->rgb_height = back_bufs.height; - s->rgb_stride = back_bufs.stride; - s->rgb_buf_len = back_bufs.buf_len; - - s->rgb_front_width = front_bufs.width; - s->rgb_front_height = front_bufs.height; - s->rgb_front_stride = front_bufs.stride; - s->rgb_front_buf_len = front_bufs.buf_len; - - s->rgb_transform = (mat4){{ - 2.0/s->rgb_width, 0.0, 0.0, -1.0, - 0.0, 2.0/s->rgb_height, 0.0, -1.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, 1.0, - }}; - - read_param_float(&s->speed_lim_off, "SpeedLimitOffset"); - read_param_bool(&s->is_metric, "IsMetric"); - read_param_bool(&s->longitudinal_control, "LongitudinalControl"); - read_param_bool(&s->limit_set_speed, "LimitSetSpeed"); - - // Set offsets so params don't get read at the same time - s->longitudinal_control_timeout = UI_FREQ / 3; - s->is_metric_timeout = UI_FREQ / 2; - s->limit_set_speed_timeout = UI_FREQ; -} - -static void ui_draw_transformed_box(UIState *s, uint32_t color) { - const UIScene *scene = &s->scene; - - const mat3 bbt = scene->warp_matrix; - - struct { - vec3 pos; - uint32_t color; - } verts[] = { - {matvecmul3(bbt, (vec3){{0.0, 0.0, 1.0,}}), color}, - {matvecmul3(bbt, (vec3){{scene->transformed_width, 0.0, 1.0,}}), color}, - {matvecmul3(bbt, (vec3){{scene->transformed_width, scene->transformed_height, 1.0,}}), color}, - {matvecmul3(bbt, (vec3){{0.0, scene->transformed_height, 1.0,}}), color}, - {matvecmul3(bbt, (vec3){{0.0, 0.0, 1.0,}}), color}, - }; - - for (int i=0; irgb_height - verts[i].pos.v[1] / verts[i].pos.v[2]; - } - - glUseProgram(s->line_program); - - mat4 out_mat = matmul(device_transform, - matmul(frame_transform, s->rgb_transform)); - glUniformMatrix4fv(s->line_transform_loc, 1, GL_TRUE, out_mat.v); - - glEnableVertexAttribArray(s->line_pos_loc); - glVertexAttribPointer(s->line_pos_loc, 2, GL_FLOAT, GL_FALSE, sizeof(verts[0]), &verts[0].pos.v[0]); - - glEnableVertexAttribArray(s->line_color_loc); - glVertexAttribPointer(s->line_color_loc, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(verts[0]), &verts[0].color); - - assert(glGetError() == GL_NO_ERROR); - glDrawArrays(GL_LINE_STRIP, 0, ARRAYSIZE(verts)); -} - -// Projects a point in car to space to the corresponding point in full frame -// image space. -vec3 car_space_to_full_frame(const UIState *s, vec4 car_space_projective) { - const UIScene *scene = &s->scene; - - // We'll call the car space point p. - // First project into normalized image coordinates with the extrinsics matrix. - const vec4 Ep4 = matvecmul(scene->extrinsic_matrix, car_space_projective); - - // The last entry is zero because of how we store E (to use matvecmul). - const vec3 Ep = {{Ep4.v[0], Ep4.v[1], Ep4.v[2]}}; - const vec3 KEp = matvecmul3(intrinsic_matrix, Ep); - - // Project. - const vec3 p_image = {{KEp.v[0] / KEp.v[2], KEp.v[1] / KEp.v[2], 1.}}; - return p_image; -} - -// Calculate an interpolation between two numbers at a specific increment -static float lerp(float v0, float v1, float t) { - return (1 - t) * v0 + t * v1; -} - -static void draw_chevron(UIState *s, float x_in, float y_in, float sz, - NVGcolor fillColor, NVGcolor glowColor) { - const UIScene *scene = &s->scene; - - nvgSave(s->vg); - - nvgTranslate(s->vg, 240.0f, 0.0); - nvgTranslate(s->vg, -1440.0f / 2, -1080.0f / 2); - nvgScale(s->vg, 2.0, 2.0); - nvgScale(s->vg, 1440.0f / s->rgb_width, 1080.0f / s->rgb_height); - - const vec4 p_car_space = (vec4){{x_in, y_in, 0., 1.}}; - const vec3 p_full_frame = car_space_to_full_frame(s, p_car_space); - - sz *= 30; - sz /= (x_in / 3 + 30); - if (sz > 30) sz = 30; - if (sz < 15) sz = 15; - - float x = p_full_frame.v[0]; - float y = p_full_frame.v[1]; - - // glow - nvgBeginPath(s->vg); - float g_xo = sz/5; - float g_yo = sz/10; - //BB added for printing the car - //if position is 3 do nothing - if (s->b.tri_state_switch == 3) { - return; - } - if ((s->b.tri_state_switch == 2) && (s->b.icShowCar)) { - nvgRestore(s->vg); - bb_ui_draw_car(s); - } else { - if (x >= 0 && y >= 0.) { - nvgMoveTo(s->vg, x+(sz*1.35)+g_xo, y+sz+g_yo); - nvgLineTo(s->vg, x, y-g_xo); - nvgLineTo(s->vg, x-(sz*1.35)-g_xo, y+sz+g_yo); - nvgLineTo(s->vg, x+(sz*1.35)+g_xo, y+sz+g_yo); - nvgClosePath(s->vg); - } - nvgFillColor(s->vg, glowColor); - nvgFill(s->vg); - - // chevron - nvgBeginPath(s->vg); - if (x >= 0 && y >= 0.) { - nvgMoveTo(s->vg, x+(sz*1.25), y+sz); - nvgLineTo(s->vg, x, y); - nvgLineTo(s->vg, x-(sz*1.25), y+sz); - nvgLineTo(s->vg, x+(sz*1.25), y+sz); - nvgClosePath(s->vg); - } - nvgFillColor(s->vg, fillColor); - nvgFill(s->vg); - } - nvgRestore(s->vg); -} - -static void ui_draw_lane_line(UIState *s, const model_path_vertices_data *pvd, NVGcolor color) { - const UIScene *scene = &s->scene; - - nvgSave(s->vg); - nvgTranslate(s->vg, 240.0f, 0.0); // rgb-box space - nvgTranslate(s->vg, -1440.0f / 2, -1080.0f / 2); // zoom 2x - nvgScale(s->vg, 2.0, 2.0); - nvgScale(s->vg, 1440.0f / s->rgb_width, 1080.0f / s->rgb_height); - nvgBeginPath(s->vg); - - bool started = false; - for (int i=0; icnt; i++) { - if (pvd->v[i].x < 0 || pvd->v[i].y < 0.) { - continue; - } - if (!started) { - nvgMoveTo(s->vg, pvd->v[i].x, pvd->v[i].y); - started = true; - } else { - nvgLineTo(s->vg, pvd->v[i].x, pvd->v[i].y); - } - } - - nvgClosePath(s->vg); - nvgFillColor(s->vg, color); - nvgFill(s->vg); - nvgRestore(s->vg); -} - -static void update_track_data(UIState *s, bool is_mpc, track_vertices_data *pvd) { - const UIScene *scene = &s->scene; - const PathData path = scene->model.path; - const float *mpc_x_coords = &scene->mpc_x[0]; - const float *mpc_y_coords = &scene->mpc_y[0]; - - bool started = false; - float off = is_mpc?0.3:0.5; - float lead_d = scene->lead_d_rel*2.; - float path_height = is_mpc?(lead_d>5.)?min(lead_d, 25.)-min(lead_d*0.35, 10.):20. - :(lead_d>0.)?min(lead_d, 50.)-min(lead_d*0.35, 10.):49.; - pvd->cnt = 0; - // left side up - for (int i=0; i<=path_height; i++) { - float px, py, mpx; - if (is_mpc) { - mpx = i==0?0.0:mpc_x_coords[i]; - px = lerp(mpx+1.0, mpx, i/100.0); - py = mpc_y_coords[i] - off; - } else { - px = lerp(i+1.0, i, i/100.0); - py = path.points[i] - off; - } - - vec4 p_car_space = (vec4){{px, py, 0., 1.}}; - vec3 p_full_frame = car_space_to_full_frame(s, p_car_space); - if (p_full_frame.v[0] < 0. || p_full_frame.v[1] < 0.) { - continue; - } - pvd->v[pvd->cnt].x = p_full_frame.v[0]; - pvd->v[pvd->cnt].y = p_full_frame.v[1]; - pvd->cnt += 1; - } - - // right side down - for (int i=path_height; i>=0; i--) { - float px, py, mpx; - if (is_mpc) { - mpx = i==0?0.0:mpc_x_coords[i]; - px = lerp(mpx+1.0, mpx, i/100.0); - py = mpc_y_coords[i] + off; - } else { - px = lerp(i+1.0, i, i/100.0); - py = path.points[i] + off; - } - - vec4 p_car_space = (vec4){{px, py, 0., 1.}}; - vec3 p_full_frame = car_space_to_full_frame(s, p_car_space); - pvd->v[pvd->cnt].x = p_full_frame.v[0]; - pvd->v[pvd->cnt].y = p_full_frame.v[1]; - pvd->cnt += 1; - } -} - -static void update_all_track_data(UIState *s) { - const UIScene *scene = &s->scene; - // Draw vision path - update_track_data(s, false, &s->track_vertices[0]); - - if (scene->engaged) { - // Draw MPC path when engaged - update_track_data(s, true, &s->track_vertices[1]); - } -} - - -static void ui_draw_track(UIState *s, bool is_mpc, track_vertices_data *pvd) { -const UIScene *scene = &s->scene; - const PathData path = scene->model.path; - const float *mpc_x_coords = &scene->mpc_x[0]; - const float *mpc_y_coords = &scene->mpc_y[0]; - - nvgSave(s->vg); - nvgTranslate(s->vg, 240.0f, 0.0); // rgb-box space - nvgTranslate(s->vg, -1440.0f / 2, -1080.0f / 2); // zoom 2x - nvgScale(s->vg, 2.0, 2.0); - nvgScale(s->vg, 1440.0f / s->rgb_width, 1080.0f / s->rgb_height); - nvgBeginPath(s->vg); - - bool started = false; - float off = is_mpc?0.3:0.5; - float lead_d = scene->lead_d_rel*2.; - float path_height = is_mpc?(lead_d>5.)?min(lead_d, 25.)-min(lead_d*0.35, 10.):20. - :(lead_d>0.)?min(lead_d, 50.)-min(lead_d*0.35, 10.):49.; - int vi = 0; - for(int i = 0;i < pvd->cnt;i++) { - if (pvd->v[i].x < 0 || pvd->v[i].y < 0) { - continue; - } - - if (!started) { - nvgMoveTo(s->vg, pvd->v[i].x, pvd->v[i].y); - started = true; - } else { - nvgLineTo(s->vg, pvd->v[i].x, pvd->v[i].y); - } - } - - nvgClosePath(s->vg); - - NVGpaint track_bg; - if (is_mpc) { - // Draw colored MPC track - const uint8_t *clr = bg_colors[s->status]; - track_bg = nvgLinearGradient(s->vg, vwp_w, vwp_h, vwp_w, vwp_h*.4, - nvgRGBA(clr[0], clr[1], clr[2], 255), nvgRGBA(clr[0], clr[1], clr[2], 255/2)); - } else { - // Draw white vision track - track_bg = nvgLinearGradient(s->vg, vwp_w, vwp_h, vwp_w, vwp_h*.4, - nvgRGBA(255, 255, 255, 255), nvgRGBA(255, 255, 255, 0)); - } - - nvgFillPaint(s->vg, track_bg); - nvgFill(s->vg); - nvgRestore(s->vg); -} - -static void draw_steering(UIState *s, float curvature) { - float points[50]; - for (int i = 0; i < 50; i++) { - float y_actual = i * tan(asin(clamp(i * curvature, -0.999, 0.999)) / 2.); - points[i] = y_actual; - } - - // ui_draw_lane_edge(s, points, 0.0, nvgRGBA(0, 0, 255, 128), 5); -} - -static void draw_frame(UIState *s) { - const UIScene *scene = &s->scene; - - float x1, x2, y1, y2; - if (s->scene.frontview) { - glBindVertexArray(s->frame_vao[1]); - } else { - glBindVertexArray(s->frame_vao[0]); - } - - mat4 *out_mat; - if (s->scene.frontview || s->scene.fullview) { - out_mat = &s->front_frame_mat; - } else { - out_mat = &s->rear_frame_mat; - } - glActiveTexture(GL_TEXTURE0); - //BB added to suppress video printing - if ((s->b.tri_state_switch == 1) || (s->b.tri_state_switch == 4)) { - if (s->scene.frontview && s->cur_vision_front_idx >= 0) { - glBindTexture(GL_TEXTURE_2D, s->frame_front_texs[s->cur_vision_front_idx]); - } else if (!scene->frontview && s->cur_vision_idx >= 0) { - glBindTexture(GL_TEXTURE_2D, s->frame_texs[s->cur_vision_idx]); - } - } - //BB end - - glUseProgram(s->frame_program); - glUniform1i(s->frame_texture_loc, 0); - glUniformMatrix4fv(s->frame_transform_loc, 1, GL_TRUE, out_mat->v); - - assert(glGetError() == GL_NO_ERROR); - glEnableVertexAttribArray(0); - glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, (const void*)0); - glDisableVertexAttribArray(0); - glBindVertexArray(0); -} - -static inline bool valid_frame_pt(UIState *s, float x, float y) { - return x >= 0 && x <= s->rgb_width && y >= 0 && y <= s->rgb_height; - -} -static void update_lane_line_data(UIState *s, const float *points, float off, bool is_ghost, model_path_vertices_data *pvd) { - pvd->cnt = 0; - for (int i = 0; i < MODEL_PATH_MAX_VERTICES_CNT / 2; i++) { - float px = (float)i; - float py = points[i] - off; - const vec4 p_car_space = (vec4){{px, py, 0., 1.}}; - const vec3 p_full_frame = car_space_to_full_frame(s, p_car_space); - if(!valid_frame_pt(s, p_full_frame.v[0], p_full_frame.v[1])) - continue; - pvd->v[pvd->cnt].x = p_full_frame.v[0]; - pvd->v[pvd->cnt].y = p_full_frame.v[1]; - pvd->cnt += 1; - } - for (int i = MODEL_PATH_MAX_VERTICES_CNT / 2; i > 0; i--) { - float px = (float)i; - float py = is_ghost?(points[i]-off):(points[i]+off); - const vec4 p_car_space = (vec4){{px, py, 0., 1.}}; - const vec3 p_full_frame = car_space_to_full_frame(s, p_car_space); - if(!valid_frame_pt(s, p_full_frame.v[0], p_full_frame.v[1])) - continue; - pvd->v[pvd->cnt].x = p_full_frame.v[0]; - pvd->v[pvd->cnt].y = p_full_frame.v[1]; - pvd->cnt += 1; - } -} - -static void update_all_lane_lines_data(UIState *s, const PathData path, model_path_vertices_data *pstart) { - update_lane_line_data(s, path.points, 0.025*path.prob, false, pstart); - float var = min(path.std, 0.7); - update_lane_line_data(s, path.points, -var, true, pstart + 1); - update_lane_line_data(s, path.points, var, true, pstart + 2); -} - -static void ui_draw_lane(UIState *s, const PathData *path, model_path_vertices_data *pstart, NVGcolor color) { - ui_draw_lane_line(s, pstart, color); - float var = min(path->std, 0.7); - color.a /= 4; - ui_draw_lane_line(s, pstart + 1, color); - ui_draw_lane_line(s, pstart + 2, color); -} - -static void ui_draw_vision_lanes(UIState *s) { - const UIScene *scene = &s->scene; - //draw nothing if position is 3 - if (s->b.tri_state_switch == 3) { - return; - } - //BB add to draw our lanes - if (s->b.tri_state_switch == 2) { - bb_draw_lane_fill(s); - } - model_path_vertices_data *pvd = &s->model_path_vertices[0]; - if(s->model_changed) { - update_all_lane_lines_data(s, scene->model.left_lane, pvd); - update_all_lane_lines_data(s, scene->model.right_lane, pvd + MODEL_LANE_PATH_CNT); - s->model_changed = false; - } - // Draw left lane edge - ui_draw_lane( - s, &scene->model.left_lane, - pvd, - nvgRGBAf(1.0, 1.0, 1.0, scene->model.left_lane.prob)); - - // Draw right lane edge - ui_draw_lane( - s, &scene->model.right_lane, - pvd + MODEL_LANE_PATH_CNT, - nvgRGBAf(1.0, 1.0, 1.0, scene->model.right_lane.prob)); - - if(s->livempc_or_radarstate_changed) { - update_all_track_data(s); - s->livempc_or_radarstate_changed = false; - } - // Draw vision path - ui_draw_track(s, false, &s->track_vertices[0]); - if (scene->engaged) { - // Draw MPC path when engaged - ui_draw_track(s, true, &s->track_vertices[1]); - } -} - -// Draw all world space objects. -static void ui_draw_world(UIState *s) { - const UIScene *scene = &s->scene; - if (!scene->world_objects_visible) { - return; - } - - if ((nanos_since_boot() - scene->model_ts) < 1000000000ULL) { - // Draw lane edges and vision/mpc tracks - ui_draw_vision_lanes(s); - } - - if (scene->lead_status) { - // Draw lead car indicator - float fillAlpha = 0; - float speedBuff = 10.; - float leadBuff = 40.; - if (scene->lead_d_rel < leadBuff) { - fillAlpha = 255*(1.0-(scene->lead_d_rel/leadBuff)); - if (scene->lead_v_rel < 0) { - fillAlpha += 255*(-1*(scene->lead_v_rel/speedBuff)); - } - fillAlpha = (int)(min(fillAlpha, 255)); - } - draw_chevron(s, scene->lead_d_rel+2.7, scene->lead_y_rel, 25, - nvgRGBA(201, 34, 49, fillAlpha), nvgRGBA(218, 202, 37, 255)); - } -} - -static void ui_draw_vision_maxspeed(UIState *s) { - /*if (!s->longitudinal_control){ - return; - }*/ - - const UIScene *scene = &s->scene; - int ui_viz_rx = scene->ui_viz_rx; - int ui_viz_rw = scene->ui_viz_rw; - - char maxspeed_str[32]; - float maxspeed = s->scene.v_cruise; - int maxspeed_calc = maxspeed * 0.6225 + 0.5; - float speedlimit = s->scene.speedlimit; - int speedlim_calc = speedlimit * 2.2369363 + 0.5; - int speed_lim_off = s->speed_lim_off * 2.2369363 + 0.5; - if (s->is_metric) { - maxspeed_calc = maxspeed + 0.5; - speedlim_calc = speedlimit * 3.6 + 0.5; - speed_lim_off = s->speed_lim_off * 3.6 + 0.5; - } - - bool is_cruise_set = (maxspeed != 0 && maxspeed != SET_SPEED_NA); - bool is_speedlim_valid = s->scene.speedlimit_valid; - bool is_set_over_limit = is_speedlim_valid && s->scene.engaged && - is_cruise_set && maxspeed_calc > (speedlim_calc + speed_lim_off); - - int viz_maxspeed_w = 184; - int viz_maxspeed_h = 202; - int viz_maxspeed_x = (ui_viz_rx + (bdr_s*2)); - int viz_maxspeed_y = (box_y + (bdr_s*1.5)); - int viz_maxspeed_xo = 180; - if (s->b.tri_state_switch != 2) { - viz_maxspeed_xo = 0; - } - - if (s->b.tri_state_switch == 2) { - viz_maxspeed_w += viz_maxspeed_xo; - viz_maxspeed_x += viz_maxspeed_w - (viz_maxspeed_xo * 2); - } - - // Draw Background - nvgBeginPath(s->vg); - nvgRoundedRect(s->vg, viz_maxspeed_x, viz_maxspeed_y, viz_maxspeed_w, viz_maxspeed_h, 30); - if (is_set_over_limit) { - nvgFillColor(s->vg, nvgRGBA(218, 111, 37, 180)); - } else { - nvgFillColor(s->vg, nvgRGBA(0, 0, 0, 100)); - } - if (s->b.tri_state_switch != 2) { - nvgFill(s->vg); - } - - // Draw Border - nvgBeginPath(s->vg); - nvgRoundedRect(s->vg, viz_maxspeed_x, viz_maxspeed_y, viz_maxspeed_w, viz_maxspeed_h, 20); - if (s->b.tri_state_switch != 2) { - if (is_set_over_limit) { - nvgStrokeColor(s->vg, nvgRGBA(218, 111, 37, 255)); - } else if (is_speedlim_valid && !s->is_ego_over_limit) { - nvgStrokeColor(s->vg, nvgRGBA(255, 255, 255, 255)); - } else if (is_speedlim_valid && s->is_ego_over_limit) { - nvgStrokeColor(s->vg, nvgRGBA(255, 255, 255, 20)); - } else { - nvgStrokeColor(s->vg, nvgRGBA(255, 255, 255, 100)); - } - nvgStrokeWidth(s->vg, 10); - nvgStroke(s->vg); - } - // Draw "MAX" Text - nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_BASELINE); - nvgFontFace(s->vg, "sans-regular"); - nvgFontSize(s->vg, 26*2.5); - if (is_cruise_set) { - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 200)); - } else { - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 100)); - } - nvgText(s->vg, viz_maxspeed_x+(viz_maxspeed_xo/2)+(viz_maxspeed_w/2), 148, "MAX", NULL); - - // Draw Speed Text - nvgFontFace(s->vg, "sans-bold"); - nvgFontSize(s->vg, 48*2.5); - if (is_cruise_set) { - snprintf(maxspeed_str, sizeof(maxspeed_str), "%d", maxspeed_calc); - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); - nvgText(s->vg, viz_maxspeed_x+(viz_maxspeed_xo/2)+(viz_maxspeed_w/2), 242, maxspeed_str, NULL); - } else { - nvgFontFace(s->vg, "sans-semibold"); - nvgFontSize(s->vg, 42*2.5); - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 100)); - nvgText(s->vg, viz_maxspeed_x+(viz_maxspeed_xo/2)+(viz_maxspeed_w/2), 242, "N/A", NULL); - } - //BB START: add new measures panel const int bb_dml_w = 180; - bb_ui_draw_UI(s) ; - //BB END: add new measures panel - -} - -static void ui_draw_vision_speedlimit(UIState *s) { - const UIScene *scene = &s->scene; - int ui_viz_rx = scene->ui_viz_rx; - int ui_viz_rw = scene->ui_viz_rw; - - char speedlim_str[32]; - float speedlimit = s->scene.speedlimit; - int speedlim_calc = speedlimit * 2.2369363 + 0.5; - if (s->is_metric) { - speedlim_calc = speedlimit * 3.6 + 0.5; - } - - bool is_speedlim_valid = s->scene.speedlimit_valid; - float hysteresis_offset = 0.5; - if (s->is_ego_over_limit) { - hysteresis_offset = 0.0; - } - s->is_ego_over_limit = is_speedlim_valid && s->scene.v_ego > (speedlimit + s->speed_lim_off + hysteresis_offset); - - int viz_speedlim_w = 180; - int viz_speedlim_h = 202; - int viz_speedlim_x = (ui_viz_rx + (bdr_s*2)); - int viz_speedlim_y = (box_y + (bdr_s*1.5)); - if (!is_speedlim_valid) { - viz_speedlim_w -= 5; - viz_speedlim_h -= 10; - viz_speedlim_x += 9; - viz_speedlim_y += 5; - } - int viz_speedlim_bdr = is_speedlim_valid ? 30 : 15; - - // Draw Background - nvgBeginPath(s->vg); - nvgRoundedRect(s->vg, viz_speedlim_x, viz_speedlim_y, viz_speedlim_w, viz_speedlim_h, viz_speedlim_bdr); - if (is_speedlim_valid && s->is_ego_over_limit) { - nvgFillColor(s->vg, nvgRGBA(218, 111, 37, 180)); - } else if (is_speedlim_valid) { - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); - } else { - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 100)); - } - nvgFill(s->vg); - - // Draw Border - if (is_speedlim_valid) { - nvgStrokeWidth(s->vg, 10); - nvgStroke(s->vg); - nvgBeginPath(s->vg); - nvgRoundedRect(s->vg, viz_speedlim_x, viz_speedlim_y, viz_speedlim_w, viz_speedlim_h, 20); - if (s->is_ego_over_limit) { - nvgStrokeColor(s->vg, nvgRGBA(218, 111, 37, 255)); - } else if (is_speedlim_valid) { - nvgStrokeColor(s->vg, nvgRGBA(255, 255, 255, 255)); - } - } - - // Draw "Speed Limit" Text - nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_BASELINE); - nvgFontFace(s->vg, "sans-semibold"); - nvgFontSize(s->vg, 50); - nvgFillColor(s->vg, nvgRGBA(0, 0, 0, 255)); - if (is_speedlim_valid && s->is_ego_over_limit) { - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); - } - nvgText(s->vg, viz_speedlim_x+viz_speedlim_w/2 + (is_speedlim_valid ? 6 : 0), viz_speedlim_y + (is_speedlim_valid ? 50 : 45), "SMART", NULL); - nvgText(s->vg, viz_speedlim_x+viz_speedlim_w/2 + (is_speedlim_valid ? 6 : 0), viz_speedlim_y + (is_speedlim_valid ? 90 : 85), "SPEED", NULL); - - // Draw Speed Text - nvgFontFace(s->vg, "sans-bold"); - nvgFontSize(s->vg, 48*2.5); - if (s->is_ego_over_limit) { - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); - } else { - nvgFillColor(s->vg, nvgRGBA(0, 0, 0, 255)); - } - if (is_speedlim_valid) { - snprintf(speedlim_str, sizeof(speedlim_str), "%d", speedlim_calc); - nvgText(s->vg, viz_speedlim_x+viz_speedlim_w/2, viz_speedlim_y + (is_speedlim_valid ? 170 : 165), speedlim_str, NULL); - } else { - nvgFontFace(s->vg, "sans-semibold"); - nvgFontSize(s->vg, 42*2.5); - nvgText(s->vg, viz_speedlim_x+viz_speedlim_w/2, viz_speedlim_y + (is_speedlim_valid ? 170 : 165), "N/A", NULL); - } -} - -static void ui_draw_vision_speed(UIState *s) { - if (s->b.tri_state_switch == 3) { - return; - } - const UIScene *scene = &s->scene; - int ui_viz_rx = scene->ui_viz_rx; - int ui_viz_rw = scene->ui_viz_rw; - float speed = s->scene.v_ego; - - const int viz_speed_w = 280; - const int viz_speed_x = ui_viz_rx+((ui_viz_rw/2)-(viz_speed_w/2)); - char speed_str[32]; - - nvgBeginPath(s->vg); - nvgRect(s->vg, viz_speed_x, box_y, viz_speed_w, header_h); - nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_BASELINE); - - if (s->is_metric) { - snprintf(speed_str, sizeof(speed_str), "%d", (int)(speed * 3.6 + 0.5)); - } else { - snprintf(speed_str, sizeof(speed_str), "%d", (int)(speed * 2.2369363 + 0.5)); - } - nvgFontFace(s->vg, "sans-bold"); - nvgFontSize(s->vg, 96*2.5); - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); - nvgText(s->vg, viz_speed_x+viz_speed_w/2, 240, speed_str, NULL); - - nvgFontFace(s->vg, "sans-regular"); - nvgFontSize(s->vg, 36*2.5); - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 200)); - - if (s->is_metric) { - nvgText(s->vg, viz_speed_x+viz_speed_w/2, 320, "kph", NULL); - } else { - nvgText(s->vg, viz_speed_x+viz_speed_w/2, 320, "mph", NULL); - } -} - -static void ui_draw_vision_event(UIState *s) { - const UIScene *scene = &s->scene; - const int ui_viz_rx = scene->ui_viz_rx; - const int ui_viz_rw = scene->ui_viz_rw; - const int viz_event_w = 220; - const int viz_event_x = ((ui_viz_rx + ui_viz_rw) - (viz_event_w + (bdr_s*2))); - const int viz_event_y = (box_y + (bdr_s*1.5)); - const int viz_event_h = (header_h - (bdr_s*1.5)); - if (s->scene.decel_for_model && s->scene.engaged) { - // draw winding road sign - const int img_turn_size = 160*1.5; - const int img_turn_x = viz_event_x-(img_turn_size/4); - const int img_turn_y = viz_event_y+bdr_s-25; - float img_turn_alpha = 1.0f; - nvgBeginPath(s->vg); - NVGpaint imgPaint = nvgImagePattern(s->vg, img_turn_x, img_turn_y, - img_turn_size, img_turn_size, 0, s->img_turn, img_turn_alpha); - nvgRect(s->vg, img_turn_x, img_turn_y, img_turn_size, img_turn_size); - nvgFillPaint(s->vg, imgPaint); - nvgFill(s->vg); - } else { - // draw steering wheel - const int bg_wheel_size = 96; - const int bg_wheel_x = viz_event_x + (viz_event_w-bg_wheel_size); - const int bg_wheel_y = viz_event_y + (bg_wheel_size/2); - const int img_wheel_size = bg_wheel_size*1.5; - const int img_wheel_x = bg_wheel_x-(img_wheel_size/2); - const int img_wheel_y = bg_wheel_y-25; - float img_wheel_alpha = 0.1f; - bool is_engaged = (s->status == STATUS_ENGAGED); - bool is_warning = (s->status == STATUS_WARNING); - bool is_engageable = scene->engageable; - if (is_engaged || is_warning || is_engageable) { - nvgBeginPath(s->vg); - nvgCircle(s->vg, bg_wheel_x, (bg_wheel_y + (bdr_s*1.5)), bg_wheel_size); - if (is_engaged) { - nvgFillColor(s->vg, nvgRGBA(23, 134, 68, 255)); - } else if (is_warning) { - nvgFillColor(s->vg, nvgRGBA(218, 111, 37, 255)); - } else if (is_engageable) { - nvgFillColor(s->vg, nvgRGBA(23, 51, 73, 255)); - } - nvgFill(s->vg); - img_wheel_alpha = 1.0f; - } - nvgBeginPath(s->vg); - NVGpaint imgPaint = nvgImagePattern(s->vg, img_wheel_x, img_wheel_y, - img_wheel_size, img_wheel_size, 0, s->img_wheel, img_wheel_alpha); - nvgRect(s->vg, img_wheel_x, img_wheel_y, img_wheel_size, img_wheel_size); - nvgFillPaint(s->vg, imgPaint); - nvgFill(s->vg); - } -} - -static void ui_draw_vision_map(UIState *s) { - const UIScene *scene = &s->scene; - const int map_size = 96; - const int map_x = (scene->ui_viz_rx + (map_size * 3) + (bdr_s * 3)); - const int map_y = (footer_y + ((footer_h - map_size) / 2)); - const int map_img_size = (map_size * 1.5); - const int map_img_x = (map_x - (map_img_size / 2)); - const int map_img_y = (map_y - (map_size / 4)); - - bool map_valid = s->scene.map_valid; - float map_img_alpha = map_valid ? 1.0f : 0.15f; - float map_bg_alpha = map_valid ? 0.3f : 0.1f; - NVGcolor map_bg = nvgRGBA(0, 0, 0, (255 * map_bg_alpha)); - NVGpaint map_img = nvgImagePattern(s->vg, map_img_x, map_img_y, - map_img_size, map_img_size, 0, s->img_map, map_img_alpha); - - nvgBeginPath(s->vg); - nvgCircle(s->vg, map_x, (map_y + (bdr_s * 1.5)), map_size); - nvgFillColor(s->vg, map_bg); - nvgFill(s->vg); - - nvgBeginPath(s->vg); - nvgRect(s->vg, map_img_x, map_img_y, map_img_size, map_img_size); - nvgFillPaint(s->vg, map_img); - nvgFill(s->vg); -} - -static void ui_draw_vision_face(UIState *s) { - const UIScene *scene = &s->scene; - const int face_size = 96; - const int face_x = (scene->ui_viz_rx + face_size + (bdr_s * 2)); - const int face_y = (footer_y + ((footer_h - face_size) / 2)); - const int face_img_size = (face_size * 1.5); - const int face_img_x = (face_x - (face_img_size / 2)); - const int face_img_y = (face_y - (face_size / 4)); - float face_img_alpha = scene->monitoring_active ? 1.0f : 0.15f; - float face_bg_alpha = scene->monitoring_active ? 0.3f : 0.1f; - NVGcolor face_bg = nvgRGBA(0, 0, 0, (255 * face_bg_alpha)); - NVGpaint face_img = nvgImagePattern(s->vg, face_img_x, face_img_y, - face_img_size, face_img_size, 0, s->img_face, face_img_alpha); - - nvgBeginPath(s->vg); - nvgCircle(s->vg, face_x, (face_y + (bdr_s * 1.5)), face_size); - nvgFillColor(s->vg, face_bg); - nvgFill(s->vg); - - nvgBeginPath(s->vg); - nvgRect(s->vg, face_img_x, face_img_y, face_img_size, face_img_size); - nvgFillPaint(s->vg, face_img); - nvgFill(s->vg); -} - -static void ui_draw_vision_header(UIState *s) { - const UIScene *scene = &s->scene; - int ui_viz_rx = scene->ui_viz_rx; - int ui_viz_rw = scene->ui_viz_rw; - - nvgBeginPath(s->vg); - NVGpaint gradient = nvgLinearGradient(s->vg, ui_viz_rx, - (box_y+(header_h-(header_h/2.5))), - ui_viz_rx, box_y+header_h, - nvgRGBAf(0,0,0,0.45), nvgRGBAf(0,0,0,0)); - nvgFillPaint(s->vg, gradient); - nvgRect(s->vg, ui_viz_rx, box_y, ui_viz_rw, header_h); - nvgFill(s->vg); - - ui_draw_vision_maxspeed(s); - if (s->b.tri_state_switch == 2) { - ui_draw_vision_speedlimit(s); - } - ui_draw_vision_speed(s); - ui_draw_vision_event(s); -} - -static void ui_draw_vision_footer(UIState *s) { - const UIScene *scene = &s->scene; - int ui_viz_rx = scene->ui_viz_rx; - int ui_viz_rw = scene->ui_viz_rw; - - nvgBeginPath(s->vg); - nvgRect(s->vg, ui_viz_rx, footer_y, ui_viz_rw, footer_h); - - ui_draw_vision_face(s); - -#ifdef SHOW_SPEEDLIMIT - // ui_draw_vision_map(s); -#endif -} - -static void ui_draw_vision_alert(UIState *s, int va_size, int va_color, - const char* va_text1, const char* va_text2) { - const UIScene *scene = &s->scene; - int ui_viz_rx = scene->ui_viz_rx; - int ui_viz_rw = scene->ui_viz_rw; - bool hasSidebar = !s->scene.uilayout_sidebarcollapsed; - bool mapEnabled = s->scene.uilayout_mapenabled; - bool longAlert1 = strlen(va_text1) > 15; - - const uint8_t *color = alert_colors[va_color]; - const int alr_s = alert_sizes[va_size]; - const int alr_x = ui_viz_rx-(mapEnabled?(hasSidebar?nav_w:(nav_ww)):0)-bdr_s; - const int alr_w = ui_viz_rw+(mapEnabled?(hasSidebar?nav_w:(nav_ww)):0)+(bdr_s*2); - const int alr_h = alr_s+(va_size==ALERTSIZE_NONE?0:bdr_s); - const int alr_y = vwp_h-alr_h; - - nvgBeginPath(s->vg); - nvgRect(s->vg, alr_x, alr_y, alr_w, alr_h); - nvgFillColor(s->vg, nvgRGBA(color[0],color[1],color[2],(color[3]*s->alert_blinking_alpha))); - nvgFill(s->vg); - - nvgBeginPath(s->vg); - NVGpaint gradient = nvgLinearGradient(s->vg, alr_x, alr_y, alr_x, alr_y+alr_h, - nvgRGBAf(0.0,0.0,0.0,0.05), nvgRGBAf(0.0,0.0,0.0,0.35)); - nvgFillPaint(s->vg, gradient); - nvgRect(s->vg, alr_x, alr_y, alr_w, alr_h); - nvgFill(s->vg); - - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); - nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_BASELINE); - - if (va_size == ALERTSIZE_SMALL) { - nvgFontFace(s->vg, "sans-semibold"); - nvgFontSize(s->vg, 40*2.5); - nvgText(s->vg, alr_x+alr_w/2, alr_y+alr_h/2+15, va_text1, NULL); - } else if (va_size== ALERTSIZE_MID) { - nvgFontFace(s->vg, "sans-bold"); - nvgFontSize(s->vg, 48*2.5); - nvgText(s->vg, alr_x+alr_w/2, alr_y+alr_h/2-45, va_text1, NULL); - nvgFontFace(s->vg, "sans-regular"); - nvgFontSize(s->vg, 36*2.5); - nvgText(s->vg, alr_x+alr_w/2, alr_y+alr_h/2+75, va_text2, NULL); - } else if (va_size== ALERTSIZE_FULL) { - nvgFontSize(s->vg, (longAlert1?72:96)*2.5); - nvgFontFace(s->vg, "sans-bold"); - nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE); - nvgTextBox(s->vg, alr_x, alr_y+(longAlert1?360:420), alr_w-60, va_text1, NULL); - nvgFontSize(s->vg, 48*2.5); - nvgFontFace(s->vg, "sans-regular"); - nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_BOTTOM); - nvgTextBox(s->vg, alr_x, alr_h-(longAlert1?300:360), alr_w-60, va_text2, NULL); - } - -} - - -static void ui_draw_vision(UIState *s) { - //BB code added to only draw every other frame - if (!s->b.shouldDrawFrame) { - s->b.shouldDrawFrame = true; - //return; - } - s->b.shouldDrawFrame = false; - //BBEND - - const UIScene *scene = &s->scene; - int ui_viz_rx = scene->ui_viz_rx; - int ui_viz_rw = scene->ui_viz_rw; - int ui_viz_ro = scene->ui_viz_ro; - - glClearColor(0.0, 0.0, 0.0, 0.0); - glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); - - // Draw video frames - glEnable(GL_SCISSOR_TEST); - glViewport(ui_viz_rx+ui_viz_ro, s->fb_h-(box_y+box_h), viz_w, box_h); - glScissor(ui_viz_rx, s->fb_h-(box_y+box_h), ui_viz_rw, box_h); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - draw_frame(s); - glViewport(0, 0, s->fb_w, s->fb_h); - glDisable(GL_SCISSOR_TEST); - - glClear(GL_STENCIL_BUFFER_BIT); - - nvgBeginFrame(s->vg, s->fb_w, s->fb_h, 1.0f); - nvgSave(s->vg); - - // Draw augmented elements - const int inner_height = viz_w*9/16; - nvgScissor(s->vg, ui_viz_rx, box_y, ui_viz_rw, box_h); - nvgTranslate(s->vg, ui_viz_rx+ui_viz_ro, box_y + (box_h-inner_height)/2.0); - nvgScale(s->vg, (float)viz_w / s->fb_w, (float)inner_height / s->fb_h); - if (!scene->frontview && !scene->fullview) { - ui_draw_world(s); - } - - nvgRestore(s->vg); - - // Set Speed, Current Speed, Status/Events - ui_draw_vision_header(s); - - if (s->scene.alert_size != ALERTSIZE_NONE) { - // Controls Alerts - ui_draw_vision_alert(s, s->scene.alert_size, s->status, - s->scene.alert_text1, s->scene.alert_text2); - } else { - ui_draw_vision_footer(s); - } - - - nvgEndFrame(s->vg); - glDisable(GL_BLEND); -} - -static void ui_draw_blank(UIState *s) { - glClearColor(0.0, 0.0, 0.0, 0.0); - glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); -} - -static void ui_draw(UIState *s) { - if (s->vision_connected && s->plus_state == 0) { - ui_draw_vision(s); - } else { - ui_draw_blank(s); - } - - { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glClear(GL_STENCIL_BUFFER_BIT); - - nvgBeginFrame(s->vg, s->fb_w, s->fb_h, 1.0f); - - nvgEndFrame(s->vg); - glDisable(GL_BLEND); - } -} - -static PathData read_path(cereal_ModelData_PathData_ptr pathp) { - PathData ret = {0}; - - struct cereal_ModelData_PathData pathd; - cereal_read_ModelData_PathData(&pathd, pathp); - - ret.prob = pathd.prob; - ret.std = pathd.std; - - capn_list32 polyp = pathd.poly; - capn_resolve(&polyp.p); - for (int i = 0; i < POLYFIT_DEGREE; i++) { - ret.poly[i] = capn_to_f32(capn_get32(polyp, i)); - } - - // Compute points locations - for (int i = 0; i < MODEL_PATH_DISTANCE; i++) { - ret.points[i] = ret.poly[0] * (i*i*i) + ret.poly[1] * (i*i)+ ret.poly[2] * i + ret.poly[3]; - } - - return ret; -} - -static ModelData read_model(cereal_ModelData_ptr modelp) { - struct cereal_ModelData modeld; - cereal_read_ModelData(&modeld, modelp); - - ModelData d = {0}; - - d.path = read_path(modeld.path); - d.left_lane = read_path(modeld.leftLane); - d.right_lane = read_path(modeld.rightLane); - - struct cereal_ModelData_LeadData leadd; - cereal_read_ModelData_LeadData(&leadd, modeld.lead); - d.lead = (LeadData){ - .dist = leadd.dist, .prob = leadd.prob, .std = leadd.std, - }; - - return d; -} - -static void update_status(UIState *s, int status) { - //BB Variable for the old status - int old_status = s->status; - if (s->status != status) { - s->status = status; - set_awake(s, true); - // wake up bg thread to change - pthread_cond_signal(&s->bg_cond); - } -} - - -void handle_message(UIState *s, void *which) { - int err; - zmq_msg_t msg; - err = zmq_msg_init(&msg); - assert(err == 0); - err = zmq_msg_recv(&msg, which, 0); - assert(err >= 0); - - struct capn ctx; - capn_init_mem(&ctx, zmq_msg_data(&msg), zmq_msg_size(&msg), 0); - - cereal_Event_ptr eventp; - eventp.p = capn_getp(capn_root(&ctx), 0, 1); - struct cereal_Event eventd; - cereal_read_Event(&eventd, eventp); - double t = millis_since_boot(); - - int bts = bb_get_button_status(s,"sound"); - if (eventd.which == cereal_Event_controlsState) { - struct cereal_ControlsState datad; - cereal_read_ControlsState(&datad, eventd.controlsState); - - if (datad.vCruise != s->scene.v_cruise) { - s->scene.v_cruise_update_ts = eventd.logMonoTime; - } - s->scene.v_cruise = datad.vCruise; - s->scene.v_ego = datad.vEgo; - s->scene.curvature = datad.curvature; - //BB get angles - s->b.angleSteers = datad.angleSteers; - s->b.angleSteersDes = datad.angleSteersDes; - //BB END - s->scene.engaged = datad.enabled; - s->scene.engageable = datad.engageable; - s->scene.gps_planner_active = datad.gpsPlannerActive; - s->scene.monitoring_active = datad.driverMonitoringOn; - - s->scene.frontview = datad.rearViewCam; - - s->scene.decel_for_model = datad.decelForModel; - - s->alert_sound_timeout = 1 * UI_FREQ; - - if (datad.alertSound != cereal_CarControl_HUDControl_AudibleAlert_none && datad.alertSound != s->alert_sound && bts != 0) { - char* error = NULL; - if (s->alert_sound != cereal_CarControl_HUDControl_AudibleAlert_none) { - sound_file* active_sound = get_sound_file(s->alert_sound); - slplay_stop_uri(active_sound->uri, &error); - if (error) { - LOGW("error stopping active sound %s", error); - } - } - - sound_file* sound = get_sound_file(datad.alertSound); - slplay_play(sound->uri, sound->loop, &error); - - if(error) { - LOGW("error playing sound: %s", error); - } - - s->alert_sound = datad.alertSound; - snprintf(s->alert_type, sizeof(s->alert_type), "%s", datad.alertType.str); - } else if ((!datad.alertSound || datad.alertSound == cereal_CarControl_HUDControl_AudibleAlert_none) && s->alert_sound != cereal_CarControl_HUDControl_AudibleAlert_none && bts != 0) { - sound_file* sound = get_sound_file(s->alert_sound); - - char* error = NULL; - - slplay_stop_uri(sound->uri, &error); - if(error) { - LOGW("error stopping sound: %s", error); - } - s->alert_type[0] = '\0'; - s->alert_sound = cereal_CarControl_HUDControl_AudibleAlert_none; - } - - if (datad.alertText1.str) { - snprintf(s->scene.alert_text1, sizeof(s->scene.alert_text1), "%s", datad.alertText1.str); - } else { - s->scene.alert_text1[0] = '\0'; - } - if (datad.alertText2.str) { - snprintf(s->scene.alert_text2, sizeof(s->scene.alert_text2), "%s", datad.alertText2.str); - } else { - s->scene.alert_text2[0] = '\0'; - } - s->scene.awareness_status = datad.awarenessStatus; - - s->scene.alert_ts = eventd.logMonoTime; - - s->scene.alert_size = datad.alertSize; - if (datad.alertSize == cereal_ControlsState_AlertSize_none) { - s->alert_size = ALERTSIZE_NONE; - } else if (datad.alertSize == cereal_ControlsState_AlertSize_small) { - s->alert_size = ALERTSIZE_SMALL; - } else if (datad.alertSize == cereal_ControlsState_AlertSize_mid) { - s->alert_size = ALERTSIZE_MID; - } else if (datad.alertSize == cereal_ControlsState_AlertSize_full) { - s->alert_size = ALERTSIZE_FULL; - } - - if (datad.alertStatus == cereal_ControlsState_AlertStatus_userPrompt) { - update_status(s, STATUS_WARNING); - } else if (datad.alertStatus == cereal_ControlsState_AlertStatus_critical) { - update_status(s, STATUS_ALERT); - } else if (datad.enabled) { - update_status(s, STATUS_ENGAGED); - } else { - update_status(s, STATUS_DISENGAGED); - } - - s->scene.alert_blinkingrate = datad.alertBlinkingRate; - if (datad.alertBlinkingRate > 0.) { - if (s->alert_blinked) { - if (s->alert_blinking_alpha > 0.0 && s->alert_blinking_alpha < 1.0) { - s->alert_blinking_alpha += (0.05*datad.alertBlinkingRate); - } else { - s->alert_blinked = false; - } - } else { - if (s->alert_blinking_alpha > 0.25) { - s->alert_blinking_alpha -= (0.05*datad.alertBlinkingRate); - } else { - s->alert_blinking_alpha += 0.25; - s->alert_blinked = true; - } - } - } - } else if (eventd.which == cereal_Event_radarState) { - struct cereal_RadarState datad; - cereal_read_RadarState(&datad, eventd.radarState); - struct cereal_RadarState_LeadData leaddatad; - cereal_read_RadarState_LeadData(&leaddatad, datad.leadOne); - s->scene.lead_status = leaddatad.status; - s->scene.lead_d_rel = leaddatad.dRel; - s->scene.lead_y_rel = leaddatad.yRel; - s->scene.lead_v_rel = leaddatad.vRel; - s->livempc_or_radarstate_changed = true; - } else if (eventd.which == cereal_Event_liveCalibration) { - s->scene.world_objects_visible = true; - struct cereal_LiveCalibrationData datad; - cereal_read_LiveCalibrationData(&datad, eventd.liveCalibration); - - // should we still even have this? - capn_list32 warpl = datad.warpMatrix2; - capn_resolve(&warpl.p); // is this a bug? - for (int i = 0; i < 3 * 3; i++) { - s->scene.warp_matrix.v[i] = capn_to_f32(capn_get32(warpl, i)); - } - - capn_list32 extrinsicl = datad.extrinsicMatrix; - capn_resolve(&extrinsicl.p); // is this a bug? - for (int i = 0; i < 3 * 4; i++) { - s->scene.extrinsic_matrix.v[i] = - capn_to_f32(capn_get32(extrinsicl, i)); - } - } else if (eventd.which == cereal_Event_model) { - s->scene.model_ts = eventd.logMonoTime; - s->scene.model = read_model(eventd.model); - s->model_changed = true; - } else if (eventd.which == cereal_Event_liveMpc) { - struct cereal_LiveMpcData datad; - cereal_read_LiveMpcData(&datad, eventd.liveMpc); - - capn_list32 x_list = datad.x; - capn_resolve(&x_list.p); - - for (int i = 0; i < 50; i++){ - s->scene.mpc_x[i] = capn_to_f32(capn_get32(x_list, i)); - } - - capn_list32 y_list = datad.y; - capn_resolve(&y_list.p); - - for (int i = 0; i < 50; i++){ - s->scene.mpc_y[i] = capn_to_f32(capn_get32(y_list, i)); - } - s->livempc_or_radarstate_changed = true; - } else if (eventd.which == cereal_Event_thermal) { - struct cereal_ThermalData datad; - cereal_read_ThermalData(&datad, eventd.thermal); - - if (!datad.started) { - update_status(s, STATUS_STOPPED); - } else if (s->status == STATUS_STOPPED) { - // car is started but controls doesn't have fingerprint yet - update_status(s, STATUS_DISENGAGED); - } - - s->scene.started_ts = datad.startedTs; - - //BB CPU TEMP - s->b.maxCpuTemp=datad.cpu0; - if (s->b.maxCpuTempb.maxCpuTemp=datad.cpu1; - } - else if (s->b.maxCpuTempb.maxCpuTemp=datad.cpu2; - } - else if (s->b.maxCpuTempb.maxCpuTemp=datad.cpu3; - } - s->b.maxBatTemp=datad.bat; - s->b.freeSpace=datad.freeSpace; - s->b.batteryPercent=datad.batteryPercent; - s->b.chargingEnabled=!datad.chargingDisabled; - s->b.fanSpeed=datad.fanSpeed; - //BB END CPU TEMP - } else if (eventd.which == cereal_Event_uiLayoutState) { - struct cereal_UiLayoutState datad; - cereal_read_UiLayoutState(&datad, eventd.uiLayoutState); - s->scene.uilayout_sidebarcollapsed = datad.sidebarCollapsed; - s->scene.uilayout_mapenabled = datad.mapEnabled; - - bool hasSidebar = !s->scene.uilayout_sidebarcollapsed; - bool mapEnabled = s->scene.uilayout_mapenabled; - if (mapEnabled) { - s->scene.ui_viz_rx = hasSidebar ? (box_x+nav_w) : (box_x+nav_w-(bdr_s*4)); - s->scene.ui_viz_rw = hasSidebar ? (box_w-nav_w) : (box_w-nav_w+(bdr_s*4)); - s->scene.ui_viz_ro = -(sbr_w + 4*bdr_s); - } else { - s->scene.ui_viz_rx = hasSidebar ? box_x : (box_x-sbr_w+bdr_s*2); - s->scene.ui_viz_rw = hasSidebar ? box_w : (box_w+sbr_w-(bdr_s*2)); - s->scene.ui_viz_ro = hasSidebar ? -(sbr_w - 6*bdr_s) : 0; - } - } else if (eventd.which == cereal_Event_liveMapData) { - struct cereal_LiveMapData datad; - cereal_read_LiveMapData(&datad, eventd.liveMapData); - s->scene.map_valid = datad.mapValid; - } - capn_free(&ctx); - zmq_msg_close(&msg); -} - -static void ui_update(UIState *s) { - int err; - - if (s->vision_connect_firstrun) { - // cant run this in connector thread because opengl. - // do this here for now in lieu of a run_on_main_thread event - - for (int i=0; ikhr[i] != NULL) { - visionimg_destroy_gl(s->khr[i], s->priv_hnds[i]); - glDeleteTextures(1, &s->frame_texs[i]); - } - - VisionImg img = { - .fd = s->bufs[i].fd, - .format = VISIONIMG_FORMAT_RGB24, - .width = s->rgb_width, - .height = s->rgb_height, - .stride = s->rgb_stride, - .bpp = 3, - .size = s->rgb_buf_len, - }; - s->frame_texs[i] = visionimg_to_gl(&img, &s->khr[i], &s->priv_hnds[i]); - - glBindTexture(GL_TEXTURE_2D, s->frame_texs[i]); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - - // BGR - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_GREEN); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED); - } - - for (int i=0; ikhr_front[i] != NULL) { - visionimg_destroy_gl(s->khr_front[i], s->priv_hnds_front[i]); - glDeleteTextures(1, &s->frame_front_texs[i]); - } - - VisionImg img = { - .fd = s->front_bufs[i].fd, - .format = VISIONIMG_FORMAT_RGB24, - .width = s->rgb_front_width, - .height = s->rgb_front_height, - .stride = s->rgb_front_stride, - .bpp = 3, - .size = s->rgb_front_buf_len, - }; - s->frame_front_texs[i] = visionimg_to_gl(&img, &s->khr_front[i], &s->priv_hnds_front[i]); - - glBindTexture(GL_TEXTURE_2D, s->frame_front_texs[i]); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - - // BGR - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_GREEN); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED); - } - - assert(glGetError() == GL_NO_ERROR); - - // Default UI Measurements (Assumes sidebar collapsed) - s->scene.ui_viz_rx = (box_x-sbr_w+bdr_s*2); - s->scene.ui_viz_rw = (box_w+sbr_w-(bdr_s*2)); - s->scene.ui_viz_ro = 0; - - s->vision_connect_firstrun = false; - - s->alert_blinking_alpha = 1.0; - s->alert_blinked = false; - } - - zmq_pollitem_t polls[9] = {{0}}; - // Wait for next rgb image from visiond - while(true) { - assert(s->ipc_fd >= 0); - polls[0].fd = s->ipc_fd; - polls[0].events = ZMQ_POLLIN; - int ret = zmq_poll(polls, 1, 1000); - if (ret < 0) { - LOGW("poll failed (%d)", ret); - close(s->ipc_fd); - s->ipc_fd = -1; - s->vision_connected = false; - return; - } else if (ret == 0) - continue; - // vision ipc event - VisionPacket rp; - err = vipc_recv(s->ipc_fd, &rp); - if (err <= 0) { - LOGW("vision disconnected"); - close(s->ipc_fd); - s->ipc_fd = -1; - s->vision_connected = false; - return; - } - if (rp.type == VIPC_STREAM_ACQUIRE) { - bool front = rp.d.stream_acq.type == VISION_STREAM_RGB_FRONT; - int idx = rp.d.stream_acq.idx; - - int release_idx; - if (front) { - release_idx = s->cur_vision_front_idx; - } else { - release_idx = s->cur_vision_idx; - } - if (release_idx >= 0) { - VisionPacket rep = { - .type = VIPC_STREAM_RELEASE, - .d = { .stream_rel = { - .type = rp.d.stream_acq.type, - .idx = release_idx, - }}, - }; - vipc_send(s->ipc_fd, &rep); - } - - if (front) { - assert(idx < UI_BUF_COUNT); - s->cur_vision_front_idx = idx; - } else { - assert(idx < UI_BUF_COUNT); - s->cur_vision_idx = idx; - // printf("v %d\n", ((uint8_t*)s->bufs[idx].addr)[0]); - } - } else { - assert(false); - } - break; - } - // peek and consume all events in the zmq queue, then return. - while(true) { - int plus_sock_num = 7; - int num_polls = 8; - - polls[0].socket = s->controlsstate_sock_raw; - polls[0].events = ZMQ_POLLIN; - polls[1].socket = s->livecalibration_sock_raw; - polls[1].events = ZMQ_POLLIN; - polls[2].socket = s->model_sock_raw; - polls[2].events = ZMQ_POLLIN; - polls[3].socket = s->radarstate_sock_raw; - polls[3].events = ZMQ_POLLIN; - polls[4].socket = s->livempc_sock_raw; - polls[4].events = ZMQ_POLLIN; - polls[5].socket = s->thermal_sock_raw; - polls[5].events = ZMQ_POLLIN; - polls[6].socket = s->uilayout_sock_raw; - polls[6].events = ZMQ_POLLIN; - plus_sock_num++; - num_polls++; - polls[7].socket = s->map_data_sock_raw; - polls[7].events = ZMQ_POLLIN; - polls[plus_sock_num].socket = s->plus_sock_raw; // plus_sock should be last - polls[plus_sock_num].events = ZMQ_POLLIN; - - int ret = zmq_poll(polls, num_polls, 0); - if (ret < 0) { - LOGW("poll failed (%d)", ret); - return; - } - if (ret == 0) { - return; - } - - if (polls[0].revents || polls[1].revents || polls[2].revents || - polls[3].revents || polls[4].revents || polls[6].revents || - polls[7].revents || polls[plus_sock_num].revents) { - // awake on any (old) activity if tri-state in 1 or 2 position - if((s->b.tri_state_switch != 3) && (!s->b.keepEonOff)){ - set_awake(s, true); - } - } - - if (polls[plus_sock_num].revents) { - // plus socket - zmq_msg_t msg; - err = zmq_msg_init(&msg); - assert(err == 0); - err = zmq_msg_recv(&msg, s->plus_sock_raw, 0); - assert(err >= 0); - - assert(zmq_msg_size(&msg) == 1); - - s->plus_state = ((char*)zmq_msg_data(&msg))[0]; - - zmq_msg_close(&msg); - - } else { - // zmq messages - for (int i=0; itype == VIPC_STREAM_ACQUIRE) { - VisionPacket rep = { - .type = VIPC_STREAM_RELEASE, - .d = { .stream_rel = { - .type = rp->d.stream_acq.type, - .idx = rp->d.stream_acq.idx, - }}, - }; - vipc_send(fd, &rep); - } - } while (rp->type != VIPC_STREAM_BUFS || rp->d.stream_bufs.type != type); - - return 1; -} - -static void* vision_connect_thread(void *args) { - int err; - set_thread_name("vision_connect"); - - UIState *s = args; - while (!do_exit) { - usleep(100000); - pthread_mutex_lock(&s->lock); - bool connected = s->vision_connected; - pthread_mutex_unlock(&s->lock); - if (connected) continue; - - int fd = vipc_connect(); - if (fd < 0) continue; - - VisionPacket back_rp, front_rp; - if (!vision_subscribe(fd, &back_rp, VISION_STREAM_RGB_BACK)) continue; - if (!vision_subscribe(fd, &front_rp, VISION_STREAM_RGB_FRONT)) continue; - - pthread_mutex_lock(&s->lock); - assert(!s->vision_connected); - s->ipc_fd = fd; - - ui_init_vision(s, - back_rp.d.stream_bufs, back_rp.num_fds, back_rp.fds, - front_rp.d.stream_bufs, front_rp.num_fds, front_rp.fds); - - s->vision_connected = true; - s->vision_connect_firstrun = true; - pthread_mutex_unlock(&s->lock); - } - return NULL; -} - - -#include -#include - -static void* light_sensor_thread(void *args) { - int err; - set_thread_name("light_sensor"); - - UIState *s = args; - s->light_sensor = 0.0; - - struct sensors_poll_device_t* device; - struct sensors_module_t* module; - - hw_get_module(SENSORS_HARDWARE_MODULE_ID, (hw_module_t const**)&module); - sensors_open(&module->common, &device); - - // need to do this - struct sensor_t const* list; - int count = module->get_sensors_list(module, &list); - - int SENSOR_LIGHT = 7; - - err = device->activate(device, SENSOR_LIGHT, 0); - if (err != 0) goto fail; - err = device->activate(device, SENSOR_LIGHT, 1); - if (err != 0) goto fail; - - device->setDelay(device, SENSOR_LIGHT, ms2ns(100)); - - while (!do_exit) { - static const size_t numEvents = 1; - sensors_event_t buffer[numEvents]; - - int n = device->poll(device, buffer, numEvents); - if (n < 0) { - LOG_100("light_sensor_poll failed: %d", n); - } - if (n > 0) { - s->light_sensor = buffer[0].light; - } - } - - return NULL; - -fail: - LOGE("LIGHT SENSOR IS MISSING"); - s->light_sensor = 255; - return NULL; -} - - -static void* bg_thread(void* args) { - UIState *s = args; - set_thread_name("bg"); - - EGLDisplay bg_display; - EGLSurface bg_surface; - - FramebufferState *bg_fb = framebuffer_init("bg", 0x00001000, false, - &bg_display, &bg_surface, NULL, NULL); - assert(bg_fb); - - int bg_status = -1; - while(!do_exit) { - pthread_mutex_lock(&s->lock); - //BB Change of background based on our color - int actual_status = bb_get_status(s); - if (bg_status == actual_status) { - // will always be signaled if it changes? - pthread_cond_wait(&s->bg_cond, &s->lock); - } - bg_status = actual_status; - //BB End of background color change - pthread_mutex_unlock(&s->lock); - - assert(bg_status < ARRAYSIZE(bg_colors)); - const uint8_t *color = bg_colors[bg_status]; - - glClearColor(color[0]/256.0, color[1]/256.0, color[2]/256.0, 0.0); - glClear(GL_COLOR_BUFFER_BIT); - - eglSwapBuffers(bg_display, bg_surface); - assert(glGetError() == GL_NO_ERROR); - } - - return NULL; -} - -int is_leon() { - #define MAXCHAR 1000 - FILE *fp; - char str[MAXCHAR]; - char* filename = "/proc/cmdline"; - - fp = fopen(filename, "r"); - if (fp == NULL){ - printf("Could not open file %s",filename); - return 0; - } - fgets(str, MAXCHAR, fp); - fclose(fp); - return strstr(str, "letv") != NULL; -} - - - -int main(int argc, char* argv[]) { - int err; - setpriority(PRIO_PROCESS, 0, -14); - - zsys_handler_set(NULL); - signal(SIGINT, (sighandler_t)set_do_exit); - - UIState uistate; - UIState *s = &uistate; - ui_init(s); - //BB init our UI - bb_ui_init(s); - - pthread_t connect_thread_handle; - err = pthread_create(&connect_thread_handle, NULL, - vision_connect_thread, s); - assert(err == 0); - - pthread_t light_sensor_thread_handle; - err = pthread_create(&light_sensor_thread_handle, NULL, - light_sensor_thread, s); - assert(err == 0); - - pthread_t bg_thread_handle; - err = pthread_create(&bg_thread_handle, NULL, - bg_thread, s); - assert(err == 0); - s->b.touch_last_width = s->scene.ui_viz_rw; - TouchState touch = {0}; - touch_init(&touch); - s->touch_fd = touch.fd; - - char* error = NULL; - ui_sound_init(&error); - if (error) { - LOGW(error); - exit(1); - } - - // light sensor scaling params - const int LEON = is_leon(); - - const float BRIGHTNESS_B = LEON ? 10.0 : 5.0; - const float BRIGHTNESS_M = LEON ? 2.6 : 1.3; - - float smooth_brightness = BRIGHTNESS_B; - - const int MIN_VOLUME = LEON ? 12 : 8; - const int MAX_VOLUME = LEON ? 15 : 13; - - set_volume(s, MIN_VOLUME); -#ifdef DEBUG_FPS - vipc_t1 = millis_since_boot(); - double t1 = millis_since_boot(); - int draws = 0, old_draws = 0; -#endif //DEBUG_FPS - while (!do_exit) { - bool should_swap = false; - if (!s->vision_connected) { - // Delay a while to avoid 9% cpu usage while car is not started and user is keeping touching on the screen. - // Don't hold the lock while sleeping, so that vision_connect_thread have chances to get the lock. - usleep(30 * 1000); - } - pthread_mutex_lock(&s->lock); - - // light sensor is only exposed on EONs - float clipped_brightness = (s->light_sensor*BRIGHTNESS_M) + BRIGHTNESS_B; - if (clipped_brightness > 512) clipped_brightness = 512; - smooth_brightness = clipped_brightness * 0.01 + smooth_brightness * 0.99; - if (smooth_brightness > 255) smooth_brightness = 255; - set_brightness(s, (int)smooth_brightness); - - int touched = 0; - int touch_x = -1, touch_y = -1; - int dc_touch_x = -1, dc_touch_y = -1; - s->b.touch_timeout = max(s->b.touch_timeout -1,0); - if (!s->vision_connected) { - // Car is not started, keep in idle state and awake on touch events - zmq_pollitem_t polls[1] = {{0}}; - polls[0].fd = s->touch_fd; - polls[0].events = ZMQ_POLLIN; - int ret = zmq_poll(polls, 1, 0); - if (ret < 0) - LOGW("poll failed (%d)", ret); - else if (ret > 0) { - // awake on any touch - touched = touch_read(&touch, &touch_x, &touch_y); - } - } else { - // Car started, fetch a new rgb image from ipc and peek for zmq events. - touched = touch_poll(&touch, &touch_x, &touch_y, s->awake ? 2 : 500); - //touched = touch_read(&touch, &touch_x, &touch_y); - ui_update(s); - if(!s->vision_connected) { - // Visiond process is just stopped, force a redraw to make screen blank again. - ui_draw(s); - glFinish(); - should_swap = true; - } - } - if (touched == 1) { - set_awake(s, true); - s->b.touch_last = true; - s->b.touch_last_x = touch_x; - s->b.touch_last_y = touch_y; - s->b.touch_timeout = touch_timeout; - } - //BB check touch - if ((s->b.touch_last) && (s->b.touch_last_width != s->scene.ui_viz_rw)) { - s->b.touch_last_width=s->scene.ui_viz_rw; - bb_handle_ui_touch(s,s->b.touch_last_x,s->b.touch_last_y); - dc_touch_x = s->b.touch_last_x; - dc_touch_y = s->b.touch_last_y; - s->b.touch_last = false; - s->b.touch_last_x = 0; - s->b.touch_last_y = 0; - } - - //s->b.touch_last_width = s->scene.ui_viz_rw; - //BB Update our cereal polls - bb_ui_poll_update(s); - - - // manage wakefulness - if (s->awake_timeout > 0) { - s->awake_timeout--; - } else { - set_awake(s, false); - } - - if (s->awake && s->vision_connected) { - dashcam(s, dc_touch_x, dc_touch_y); - ui_draw(s); - glFinish(); - should_swap = true; -#ifdef DEBUG_FPS - draws++; - double t2 = millis_since_boot(); - const double interval = 30.; - if(t2 - t1 >= interval * 1000.) { - printf("ui draw fps: %.2f\n",((double)(draws - old_draws)) / interval) ; - t1 = t2; - old_draws = draws; - } -#endif - } - - if (s->volume_timeout > 0) { - s->volume_timeout--; - } else { - int volume = min(MAX_VOLUME, MIN_VOLUME + s->scene.v_ego / 5); // up one notch every 5 m/s - set_volume(s, volume); - } - - // stop playing alert sounds if no controlsState msg for 1 second - if (s->alert_sound_timeout > 0) { - s->alert_sound_timeout--; - } else if (s->alert_sound != cereal_CarControl_HUDControl_AudibleAlert_none){ - sound_file* sound = get_sound_file(s->alert_sound); - char* error = NULL; - - slplay_stop_uri(sound->uri, &error); - if(error) { - LOGW("error stopping sound: %s", error); - } - s->alert_sound = cereal_CarControl_HUDControl_AudibleAlert_none; - } - - read_param_bool_timeout(&s->is_metric, "IsMetric", &s->is_metric_timeout); - read_param_bool_timeout(&s->longitudinal_control, "LongitudinalControl", &s->longitudinal_control_timeout); - read_param_bool_timeout(&s->limit_set_speed, "LimitSetSpeed", &s->limit_set_speed_timeout); - read_param_float_timeout(&s->speed_lim_off, "SpeedLimitOffset", &s->limit_set_speed_timeout); - - pthread_mutex_unlock(&s->lock); - - // the bg thread needs to be scheduled, so the main thread needs time without the lock - // safe to do this outside the lock? - if (should_swap) { - eglSwapBuffers(s->display, s->surface); - } - } - - set_awake(s, true); - - slplay_destroy(); - - // wake up bg thread to exit - pthread_mutex_lock(&s->lock); - pthread_cond_signal(&s->bg_cond); - pthread_mutex_unlock(&s->lock); - err = pthread_join(bg_thread_handle, NULL); - assert(err == 0); - - err = pthread_join(connect_thread_handle, NULL); - assert(err == 0); - - return 0; -} diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc new file mode 100644 index 00000000000000..177ed83129020b --- /dev/null +++ b/selfdrive/ui/ui.cc @@ -0,0 +1,345 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "common/util.h" +#include "common/swaglog.h" +#include "common/visionimg.h" +#include "common/utilpp.h" +#include "ui.hpp" +#include "paint.hpp" + +#include "bbui.hpp" +#include "dashcam.hpp" + +extern volatile sig_atomic_t do_exit; + +int write_param_float(float param, const char* param_name, bool persistent_param) { + char s[16]; + int size = snprintf(s, sizeof(s), "%f", param); + return Params(persistent_param).write_db_value(param_name, s, size < sizeof(s) ? size : sizeof(s)); +} + +void ui_init(UIState *s) { + s->sm = new SubMaster({"modelV2", "controlsState", "uiLayoutState", "liveCalibration", "radarState", "thermal", "frame", + "health", "carParams", "ubloxGnss", "driverState", "dMonitoringState", "sensorEvents"}); + + s->started = false; + s->status = STATUS_OFFROAD; + s->scene.satelliteCount = -1; + read_param(&s->is_metric, "IsMetric"); + + // init display + s->fb = framebuffer_init("ui", 0, true, &s->fb_w, &s->fb_h); + + assert(s->fb); + + ui_nvg_init(s); +} + +static void ui_init_vision(UIState *s) { + // Invisible until we receive a calibration message. + s->scene.world_objects_visible = false; + + for (int i = 0; i < UI_BUF_COUNT; i++) { + if (s->khr[i] != 0) { + visionimg_destroy_gl(s->khr[i], s->priv_hnds[i]); + glDeleteTextures(1, &s->frame_texs[i]); + } + + VisionImg img = { + .fd = s->stream.bufs[i].fd, + .format = VISIONIMG_FORMAT_RGB24, + .width = s->stream.bufs_info.width, + .height = s->stream.bufs_info.height, + .stride = s->stream.bufs_info.stride, + .bpp = 3, + .size = s->stream.bufs_info.buf_len, + }; +#ifndef QCOM + s->priv_hnds[i] = s->stream.bufs[i].addr; +#endif + s->frame_texs[i] = visionimg_to_gl(&img, &s->khr[i], &s->priv_hnds[i]); + + glBindTexture(GL_TEXTURE_2D, s->frame_texs[i]); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + + // BGR + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_GREEN); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED); + } + assert(glGetError() == GL_NO_ERROR); +} + +void ui_update_vision(UIState *s) { + + if (!s->vision_connected && s->started) { + const VisionStreamType type = s->scene.frontview ? VISION_STREAM_RGB_FRONT : VISION_STREAM_RGB_BACK; + int err = visionstream_init(&s->stream, type, true, nullptr); + if (err == 0) { + ui_init_vision(s); + s->vision_connected = true; + } + } + + if (s->vision_connected) { + if (!s->started) goto destroy; + + // poll for a new frame + struct pollfd fds[1] = {{ + .fd = s->stream.ipc_fd, + .events = POLLOUT, + }}; + int ret = poll(fds, 1, 100); + if (ret > 0) { + if (!visionstream_get(&s->stream, nullptr)) goto destroy; + } + } + + return; + +destroy: + visionstream_destroy(&s->stream); + s->vision_connected = false; +} + +void update_sockets(UIState *s) { + + UIScene &scene = s->scene; + SubMaster &sm = *(s->sm); + + if (sm.update(0) == 0){ + return; + } + + if (s->started && sm.updated("controlsState")) { + auto event = sm["controlsState"]; + scene.controls_state = event.getControlsState(); + + //Tesla + s->b.angleSteers = scene.controls_state.getAngleSteers(); + s->b.angleSteersDes = scene.controls_state.getAngleSteersDes(); + int isSoundButtonEnabled = bb_get_button_status(s,(char *)"sound"); + // + + // TODO: the alert stuff shouldn't be handled here + auto alert_sound = scene.controls_state.getAlertSound(); + if (scene.alert_type.compare(scene.controls_state.getAlertType()) != 0) { + if (alert_sound == AudibleAlert::NONE) { + s->sound->stop(); + } else if (isSoundButtonEnabled) { + s->sound->play(alert_sound); + } + } + scene.alert_text1 = scene.controls_state.getAlertText1(); + scene.alert_text2 = scene.controls_state.getAlertText2(); + scene.alert_size = scene.controls_state.getAlertSize(); + scene.alert_type = scene.controls_state.getAlertType(); + auto alertStatus = scene.controls_state.getAlertStatus(); + if (alertStatus == cereal::ControlsState::AlertStatus::USER_PROMPT) { + s->status = STATUS_WARNING; + } else if (alertStatus == cereal::ControlsState::AlertStatus::CRITICAL) { + s->status = STATUS_ALERT; + } else { + s->status = scene.controls_state.getEnabled() ? STATUS_ENGAGED : STATUS_DISENGAGED; + } + + float alert_blinkingrate = scene.controls_state.getAlertBlinkingRate(); + if (alert_blinkingrate > 0.) { + if (s->alert_blinked) { + if (s->alert_blinking_alpha > 0.0 && s->alert_blinking_alpha < 1.0) { + s->alert_blinking_alpha += (0.05*alert_blinkingrate); + } else { + s->alert_blinked = false; + } + } else { + if (s->alert_blinking_alpha > 0.25) { + s->alert_blinking_alpha -= (0.05*alert_blinkingrate); + } else { + s->alert_blinking_alpha += 0.25; + s->alert_blinked = true; + } + } + } + } + if (sm.updated("radarState")) { + auto data = sm["radarState"].getRadarState(); + scene.lead_data[0] = data.getLeadOne(); + scene.lead_data[1] = data.getLeadTwo(); + } + if (sm.updated("liveCalibration")) { + scene.world_objects_visible = true; + auto extrinsicl = sm["liveCalibration"].getLiveCalibration().getExtrinsicMatrix(); + for (int i = 0; i < 3 * 4; i++) { + scene.extrinsic_matrix.v[i] = extrinsicl[i]; + } + } + if (sm.updated("modelV2")) { + scene.model = sm["modelV2"].getModelV2(); + scene.max_distance = fmin(scene.model.getPosition().getX()[TRAJECTORY_SIZE - 1], MAX_DRAW_DISTANCE); + for (int ll_idx = 0; ll_idx < 4; ll_idx++) { + if (scene.model.getLaneLineProbs().size() > ll_idx) { + scene.lane_line_probs[ll_idx] = scene.model.getLaneLineProbs()[ll_idx]; + } else { + scene.lane_line_probs[ll_idx] = 0.0; + } + } + + for (int re_idx = 0; re_idx < 2; re_idx++) { + if (scene.model.getRoadEdgeStds().size() > re_idx) { + scene.road_edge_stds[re_idx] = scene.model.getRoadEdgeStds()[re_idx]; + } else { + scene.road_edge_stds[re_idx] = 1.0; + } + } + } + if (sm.updated("uiLayoutState")) { + auto data = sm["uiLayoutState"].getUiLayoutState(); + s->active_app = data.getActiveApp(); + scene.uilayout_sidebarcollapsed = data.getSidebarCollapsed(); + } + if (sm.updated("thermal")) { + scene.thermal = sm["thermal"].getThermal(); + + //BB CPU TEMP + auto data = scene.thermal; + s->b.maxCpuTemp=data.getCpu0DEPRECATED(); + if (s->b.maxCpuTempb.maxCpuTemp=data.getCpu1DEPRECATED(); + } + else if (s->b.maxCpuTempb.maxCpuTemp=data.getCpu2DEPRECATED(); + } + else if (s->b.maxCpuTempb.maxCpuTemp=data.getCpu3DEPRECATED(); + } + s->b.maxBatTemp=data.getBat(); + s->b.freeSpace=data.getFreeSpace(); + s->b.batteryPercent=data.getBatteryPercent(); + s->b.chargingEnabled=!data.getChargingDisabled(); + s->b.fanSpeed=data.getFanSpeed(); + //BB END CPU TEMP + } + if (sm.updated("ubloxGnss")) { + auto data = sm["ubloxGnss"].getUbloxGnss(); + if (data.which() == cereal::UbloxGnss::MEASUREMENT_REPORT) { + scene.satelliteCount = data.getMeasurementReport().getNumMeas(); + } + } + if (sm.updated("health")) { + auto health = sm["health"].getHealth(); + scene.hwType = health.getHwType(); + s->ignition = health.getIgnitionLine() || health.getIgnitionCan(); + } else if ((s->sm->frame - s->sm->rcv_frame("health")) > 5*UI_FREQ) { + scene.hwType = cereal::HealthData::HwType::UNKNOWN; + } + if (sm.updated("carParams")) { + s->longitudinal_control = sm["carParams"].getCarParams().getOpenpilotLongitudinalControl(); + } + if (sm.updated("driverState")) { + scene.driver_state = sm["driverState"].getDriverState(); + } + if (sm.updated("dMonitoringState")) { + scene.dmonitoring_state = sm["dMonitoringState"].getDMonitoringState(); + scene.is_rhd = scene.dmonitoring_state.getIsRHD(); + scene.frontview = scene.dmonitoring_state.getIsPreview(); + } else if ((sm.frame - sm.rcv_frame("dMonitoringState")) > UI_FREQ/2) { + scene.frontview = false; + } + if (sm.updated("sensorEvents")) { + for (auto sensor : sm["sensorEvents"].getSensorEvents()) { + if (sensor.which() == cereal::SensorEventData::LIGHT) { + s->light_sensor = sensor.getLight(); + } else if (!s->started && sensor.which() == cereal::SensorEventData::ACCELERATION) { + s->accel_sensor = sensor.getAcceleration().getV()[2]; + } else if (!s->started && sensor.which() == cereal::SensorEventData::GYRO_UNCALIBRATED) { + s->gyro_sensor = sensor.getGyroUncalibrated().getV()[1]; + } + } + } + + s->started = scene.thermal.getStarted() || scene.frontview; +} + +void ui_update(UIState *s) { + + update_sockets(s); + ui_update_vision(s); + + // Handle onroad/offroad transition + if (!s->started && s->status != STATUS_OFFROAD) { + s->status = STATUS_OFFROAD; + s->active_app = cereal::UiLayoutState::App::HOME; + s->scene.uilayout_sidebarcollapsed = false; + s->sound->stop(); + } else if (s->started && s->status == STATUS_OFFROAD) { + s->status = STATUS_DISENGAGED; + s->started_frame = s->sm->frame; + + s->active_app = cereal::UiLayoutState::App::NONE; + s->scene.uilayout_sidebarcollapsed = true; + s->alert_blinked = false; + s->alert_blinking_alpha = 1.0; + s->scene.alert_size = cereal::ControlsState::AlertSize::NONE; + } + + // Handle controls/fcamera timeout + if (s->started && !s->scene.frontview && ((s->sm)->frame - s->started_frame) > 10*UI_FREQ) { + if ((s->sm)->rcv_frame("controlsState") < s->started_frame) { + // car is started, but controlsState hasn't been seen at all + s->scene.alert_text1 = "openpilot Unavailable"; + s->scene.alert_text2 = "Waiting for controls to start"; + s->scene.alert_size = cereal::ControlsState::AlertSize::MID; + } else if (((s->sm)->frame - (s->sm)->rcv_frame("controlsState")) > 5*UI_FREQ) { + // car is started, but controls is lagging or died + if (s->scene.alert_text2 != "Controls Unresponsive" && + s->scene.alert_text1 != "Camera Malfunction") { + s->sound->play(AudibleAlert::CHIME_WARNING_REPEAT); + LOGE("Controls unresponsive"); + } + + s->scene.alert_text1 = "TAKE CONTROL IMMEDIATELY"; + s->scene.alert_text2 = "Controls Unresponsive"; + s->scene.alert_size = cereal::ControlsState::AlertSize::FULL; + s->status = STATUS_ALERT; + } + + const uint64_t frame_pkt = (s->sm)->rcv_frame("frame"); + const uint64_t frame_delayed = (s->sm)->frame - frame_pkt; + const uint64_t since_started = (s->sm)->frame - s->started_frame; + if ((frame_pkt > s->started_frame || since_started > 15*UI_FREQ) && frame_delayed > 5*UI_FREQ) { + // controls is fine, but rear camera is lagging or died + s->scene.alert_text1 = "Camera Malfunction"; + s->scene.alert_text2 = "Contact Support"; + s->scene.alert_size = cereal::ControlsState::AlertSize::FULL; + s->status = STATUS_DISENGAGED; + s->sound->stop(); + } + } + + // Read params + if ((s->sm)->frame % (5*UI_FREQ) == 0) { + read_param(&s->is_metric, "IsMetric"); + } else if ((s->sm)->frame % (6*UI_FREQ) == 0) { + int param_read = read_param(&s->last_athena_ping, "LastAthenaPingTime"); + if (param_read != 0) { // Failed to read param + s->scene.athenaStatus = NET_DISCONNECTED; + } else if (nanos_since_boot() - s->last_athena_ping < 70e9) { + s->scene.athenaStatus = NET_CONNECTED; + } else { + s->scene.athenaStatus = NET_ERROR; + } + } +} diff --git a/selfdrive/ui/ui.hpp b/selfdrive/ui/ui.hpp new file mode 100644 index 00000000000000..1892694e567186 --- /dev/null +++ b/selfdrive/ui/ui.hpp @@ -0,0 +1,272 @@ +#pragma once +#ifndef _UI_H +#define _UI_H + +#include "messaging.hpp" + +#ifdef __APPLE__ +#include +#define NANOVG_GL3_IMPLEMENTATION +#define nvgCreate nvgCreateGL3 +#else +#include +#define NANOVG_GLES3_IMPLEMENTATION +#define nvgCreate nvgCreateGLES3 +#endif + +#include +#include +#include +#include + +#include "nanovg.h" + +#include "common/mat.h" +#include "common/visionipc.h" +#include "common/visionimg.h" +#include "common/framebuffer.h" +#include "common/modeldata.h" +#include "common/params.h" +#include "sound.hpp" + +#define COLOR_BLACK nvgRGBA(0, 0, 0, 255) +#define COLOR_BLACK_ALPHA(x) nvgRGBA(0, 0, 0, x) +#define COLOR_WHITE nvgRGBA(255, 255, 255, 255) +#define COLOR_WHITE_ALPHA(x) nvgRGBA(255, 255, 255, x) +#define COLOR_YELLOW nvgRGBA(218, 202, 37, 255) +#define COLOR_RED nvgRGBA(201, 34, 49, 255) + +#define UI_BUF_COUNT 4 + +typedef struct Rect { + int x, y, w, h; + int centerX() const { return x + w / 2; } + int right() const { return x + w; } + int bottom() const { return y + h; } + bool ptInRect(int px, int py) const { + return px >= x && px < (x + w) && py >= y && py < (y + h); + } +} Rect; + +const int sbr_w = 300; +const int bdr_s = 30; +const int header_h = 420; +const int footer_h = 280; +const Rect settings_btn = {50, 35, 200, 117}; +const Rect home_btn = {60, 1080 - 180 - 40, 180, 180}; + +const int UI_FREQ = 20; // Hz + +const int MODEL_PATH_MAX_VERTICES_CNT = TRAJECTORY_SIZE*2; +const int TRACK_POINTS_MAX_CNT = TRAJECTORY_SIZE*4; + +const int SET_SPEED_NA = 255; + +typedef enum NetStatus { + NET_CONNECTED, + NET_DISCONNECTED, + NET_ERROR, +} NetStatus; + +typedef enum UIStatus { + STATUS_OFFROAD, + STATUS_DISENGAGED, + STATUS_ENGAGED, + STATUS_WARNING, + STATUS_ALERT, +} UIStatus; + +static std::map bg_colors = { + {STATUS_OFFROAD, nvgRGBA(0x07, 0x23, 0x39, 0xf1)}, + {STATUS_DISENGAGED, nvgRGBA(0x17, 0x33, 0x49, 0xc8)}, + {STATUS_ENGAGED, nvgRGBA(0x17, 0x86, 0x44, 0xf1)}, + {STATUS_WARNING, nvgRGBA(0xDA, 0x6F, 0x25, 0xf1)}, + {STATUS_ALERT, nvgRGBA(0xC9, 0x22, 0x31, 0xf1)}, +}; + +typedef struct { + float x[TRAJECTORY_SIZE]; + float y[TRAJECTORY_SIZE]; + float z[TRAJECTORY_SIZE]; +} line; + + +typedef struct UIScene { + + mat4 extrinsic_matrix; // Last row is 0 so we can use mat4. + bool world_objects_visible; + + bool is_rhd; + bool frontview; + bool uilayout_sidebarcollapsed; + // responsive layout + Rect viz_rect; + + std::string alert_text1; + std::string alert_text2; + std::string alert_type; + cereal::ControlsState::AlertSize alert_size; + + cereal::HealthData::HwType hwType; + int satelliteCount; + NetStatus athenaStatus; + + cereal::ThermalData::Reader thermal; + cereal::RadarState::LeadData::Reader lead_data[2]; + cereal::ControlsState::Reader controls_state; + cereal::DriverState::Reader driver_state; + cereal::DMonitoringState::Reader dmonitoring_state; + cereal::ModelDataV2::Reader model; + line path; + line outer_left_lane_line; + line left_lane_line; + line right_lane_line; + line outer_right_lane_line; + line left_road_edge; + line right_road_edge; + float max_distance; + float lane_line_probs[4]; + float road_edge_stds[2]; +} UIScene; + +typedef struct { + float x, y; +} vertex_data; + +typedef struct { + vertex_data v[MODEL_PATH_MAX_VERTICES_CNT]; + int cnt; +} line_vertices_data; + +typedef struct { + vertex_data v[TRACK_POINTS_MAX_CNT]; + int cnt; +} track_vertices_data; + +#include "bbuistate.h" + +typedef struct UIState { + //BB define BBUIState + BBUIState b; + int plus_state; + //BB end + + // framebuffer + FramebufferState *fb; + int fb_w, fb_h; + + // NVG + NVGcontext *vg; + + // fonts and images + int font_sans_regular; + int font_sans_semibold; + int font_sans_bold; + int img_wheel; + int img_turn; + int img_face; + int img_button_settings; + int img_button_home; + int img_battery; + int img_battery_charging; + int img_network[6]; + + SubMaster *sm; + + Sound *sound; + UIStatus status; + UIScene scene; + cereal::UiLayoutState::App active_app; + + // vision state + bool vision_connected; + VisionStream stream; + + // graphics + GLuint frame_program; + GLuint frame_texs[UI_BUF_COUNT]; + EGLImageKHR khr[UI_BUF_COUNT]; + void *priv_hnds[UI_BUF_COUNT]; + + GLint frame_pos_loc, frame_texcoord_loc; + GLint frame_texture_loc, frame_transform_loc; + GLuint frame_vao[2], frame_vbo[2], frame_ibo[2]; + mat4 rear_frame_mat, front_frame_mat; + + // device state + bool awake; + float light_sensor, accel_sensor, gyro_sensor; + + bool started; + bool ignition; + bool is_metric; + bool longitudinal_control; + uint64_t last_athena_ping; + uint64_t started_frame; + + bool alert_blinked; + float alert_blinking_alpha; + + track_vertices_data track_vertices; + line_vertices_data lane_line_vertices[4]; + line_vertices_data road_edge_vertices[2]; + + Rect video_rect; +} UIState; + +void ui_init(UIState *s); +void ui_update(UIState *s); + +int write_param_float(float param, const char* param_name, bool persistent_param = false); +template +int read_param(T* param, const char *param_name, bool persistent_param = false){ + T param_orig = *param; + char *value; + size_t sz; + + int result = Params(persistent_param).read_db_value(param_name, &value, &sz); + if (result == 0){ + std::string s = std::string(value, sz); // value is not null terminated + free(value); + + // Parse result + std::istringstream iss(s); + iss >> *param; + + // Restore original value if parsing failed + if (iss.fail()) { + *param = param_orig; + result = -1; + } + } + return result; +} +#endif + +// TODO: this is also hardcoded in common/transformations/camera.py +// TODO: choose based on frame input size +#ifdef QCOM2 +const float y_offset = 150.0; +const float zoom = 1.1; +const mat3 intrinsic_matrix = (mat3){{ + 2648.0, 0.0, 1928.0/2, + 0.0, 2648.0, 1208.0/2, + 0.0, 0.0, 1.0 +}}; +#else +const float y_offset = 0.0; +const float zoom = 2.35; +const mat3 intrinsic_matrix = (mat3){{ + 910., 0., 1164.0/2, + 0., 910., 874.0/2, + 0., 0., 1. +}}; +#endif + +const uint8_t alert_colors[][4] = { + [STATUS_OFFROAD] = {0x07, 0x23, 0x39, 0xf1}, + [STATUS_DISENGAGED] = {0x17, 0x33, 0x49, 0xc8}, + [STATUS_ENGAGED] = {0x17, 0x86, 0x44, 0xf1}, + [STATUS_WARNING] = {0xDA, 0x6F, 0x25, 0xf1}, + [STATUS_ALERT] = {0xC9, 0x22, 0x31, 0xf1}, +}; diff --git a/selfdrive/updated.py b/selfdrive/updated.py index 743eb6f589a33b..6dc2190a7cf952 100755 --- a/selfdrive/updated.py +++ b/selfdrive/updated.py @@ -1,34 +1,403 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 -# simple service that waits for network access and tries to update every hour +# Safe Update: A simple service that waits for network access and tries to +# update every 10 minutes. It's intended to make the OP update process more +# robust against Git repository corruption. This service DOES NOT try to fix +# an already-corrupt BASEDIR Git repo, only prevent it from happening. +# +# During normal operation, both onroad and offroad, the update process makes +# no changes to the BASEDIR install of OP. All update attempts are performed +# in a disposable staging area provided by OverlayFS. It assumes the deleter +# process provides enough disk space to carry out the process. +# +# If an update succeeds, a flag is set, and the update is swapped in at the +# next reboot. If an update is interrupted or otherwise fails, the OverlayFS +# upper layer and metadata can be discarded before trying again. +# +# The swap on boot is triggered by launch_chffrplus.sh +# gated on the existence of $FINALIZED/.overlay_consistent and also the +# existence and mtime of $BASEDIR/.overlay_init. +# +# Other than build byproducts, BASEDIR should not be modified while this +# service is running. Developers modifying code directly in BASEDIR should +# disable this service. -import time +import os +import datetime import subprocess +import psutil +import shutil +import signal +import fcntl +import time +import threading +from pathlib import Path +from typing import List, Tuple, Optional + +from common.basedir import BASEDIR +from common.params import Params +from selfdrive.hardware import EON, TICI from selfdrive.swaglog import cloudlog +from selfdrive.controls.lib.alertmanager import set_offroad_alert + +from selfdrive.car.tesla.readconfig import CarSettings + +LOCK_FILE = os.getenv("UPDATER_LOCK_FILE", "/tmp/safe_staging_overlay.lock") +STAGING_ROOT = os.getenv("UPDATER_STAGING_ROOT", "/data/safe_staging") + +NEOS_VERSION = os.getenv("UPDATER_NEOS_VERSION", "/VERSION") +NEOSUPDATE_DIR = os.getenv("UPDATER_NEOSUPDATE_DIR", "/data/neoupdate") + +OVERLAY_UPPER = os.path.join(STAGING_ROOT, "upper") +OVERLAY_METADATA = os.path.join(STAGING_ROOT, "metadata") +OVERLAY_MERGED = os.path.join(STAGING_ROOT, "merged") +FINALIZED = os.path.join(STAGING_ROOT, "finalized") + + +class WaitTimeHelper: + def __init__(self, proc): + self.proc = proc + self.ready_event = threading.Event() + self.shutdown = False + signal.signal(signal.SIGTERM, self.graceful_shutdown) + signal.signal(signal.SIGINT, self.graceful_shutdown) + signal.signal(signal.SIGHUP, self.update_now) + + def graceful_shutdown(self, signum: int, frame) -> None: + # umount -f doesn't appear effective in avoiding "device busy" on NEOS, + # so don't actually die until the next convenient opportunity in main(). + cloudlog.info("caught SIGINT/SIGTERM, dismounting overlay at next opportunity") + + # forward the signal to all our child processes + child_procs = self.proc.children(recursive=True) + for p in child_procs: + p.send_signal(signum) + + self.shutdown = True + self.ready_event.set() + + def update_now(self, signum: int, frame) -> None: + cloudlog.info("caught SIGHUP, running update check immediately") + self.ready_event.set() + + def sleep(self, t: float) -> None: + self.ready_event.wait(timeout=t) + + +def run(cmd: List[str], cwd: Optional[str] = None, low_priority: bool = False): + if low_priority: + cmd = ["nice", "-n", "19"] + cmd + return subprocess.check_output(cmd, cwd=cwd, stderr=subprocess.STDOUT, encoding='utf8') + + +def set_consistent_flag(consistent: bool) -> None: + os.sync() + consistent_file = Path(os.path.join(FINALIZED, ".overlay_consistent")) + if consistent: + consistent_file.touch() + elif not consistent and consistent_file.exists(): + consistent_file.unlink() + os.sync() + + +def set_params(new_version: bool, failed_count: int, exception: Optional[str]) -> None: + params = Params() + + params.put("UpdateFailedCount", str(failed_count)) + if failed_count == 0: + t = datetime.datetime.utcnow().isoformat() + params.put("LastUpdateTime", t.encode('utf8')) + + if exception is None: + params.delete("LastUpdateException") + else: + params.put("LastUpdateException", exception) + + if new_version: + try: + with open(os.path.join(FINALIZED, "RELEASES.md"), "rb") as f: + r = f.read() + r = r[:r.find(b'\n\n')] # Slice latest release notes + params.put("ReleaseNotes", r + b"\n") + except Exception: + params.put("ReleaseNotes", "") + params.put("UpdateAvailable", "1") + + +def setup_git_options(cwd: str) -> None: + # We sync FS object atimes (which NEOS doesn't use) and mtimes, but ctimes + # are outside user control. Make sure Git is set up to ignore system ctimes, + # because they change when we make hard links during finalize. Otherwise, + # there is a lot of unnecessary churn. This appears to be a common need on + # OSX as well: https://www.git-tower.com/blog/make-git-rebase-safe-on-osx/ + + # We are using copytree to copy the directory, which also changes + # inode numbers. Ignore those changes too. + git_cfg = [ + ("core.trustctime", "false"), + ("core.checkStat", "minimal"), + ] + for option, value in git_cfg: + run(["git", "config", option, value], cwd) + + +def dismount_overlay() -> None: + if os.path.ismount(OVERLAY_MERGED): + cloudlog.info("unmounting existing overlay") + args = ["umount", "-l", OVERLAY_MERGED] + if TICI: + args = ["sudo"] + args + run(args) + + +def init_overlay() -> None: + + overlay_init_file = Path(os.path.join(BASEDIR, ".overlay_init")) + + # Re-create the overlay if BASEDIR/.git has changed since we created the overlay + if overlay_init_file.is_file(): + git_dir_path = os.path.join(BASEDIR, ".git") + new_files = run(["find", git_dir_path, "-newer", str(overlay_init_file)]) + if not len(new_files.splitlines()): + # A valid overlay already exists + return + else: + cloudlog.info(".git directory changed, recreating overlay") + + cloudlog.info("preparing new safe staging area") + + Params().put("UpdateAvailable", "0") + set_consistent_flag(False) + dismount_overlay() + if os.path.isdir(STAGING_ROOT): + shutil.rmtree(STAGING_ROOT) + + for dirname in [STAGING_ROOT, OVERLAY_UPPER, OVERLAY_METADATA, OVERLAY_MERGED]: + os.mkdir(dirname, 0o755) + + if os.lstat(BASEDIR).st_dev != os.lstat(OVERLAY_MERGED).st_dev: + raise RuntimeError("base and overlay merge directories are on different filesystems; not valid for overlay FS!") + + # Leave a timestamped canary in BASEDIR to check at startup. The device clock + # should be correct by the time we get here. If the init file disappears, or + # critical mtimes in BASEDIR are newer than .overlay_init, continue.sh can + # assume that BASEDIR has used for local development or otherwise modified, + # and skips the update activation attempt. + consistent_file = Path(os.path.join(BASEDIR, ".overlay_consistent")) + if consistent_file.is_file(): + consistent_file.unlink() + overlay_init_file.touch() + + os.sync() + overlay_opts = f"lowerdir={BASEDIR},upperdir={OVERLAY_UPPER},workdir={OVERLAY_METADATA}" + + mount_cmd = ["mount", "-t", "overlay", "-o", overlay_opts, "none", OVERLAY_MERGED] + if TICI: + run(["sudo"] + mount_cmd) + run(["sudo", "chmod", "755", os.path.join(OVERLAY_METADATA, "work")]) + else: + run(mount_cmd) + + +def finalize_update() -> None: + """Take the current OverlayFS merged view and finalize a copy outside of + OverlayFS, ready to be swapped-in at BASEDIR. Copy using shutil.copytree""" + + # Remove the update ready flag and any old updates + cloudlog.info("creating finalized version of the overlay") + set_consistent_flag(False) + + # Copy the merged overlay view and set the update ready flag + if os.path.exists(FINALIZED): + shutil.rmtree(FINALIZED) + shutil.copytree(OVERLAY_MERGED, FINALIZED, symlinks=True) -NICE_LOW_PRIORITY = ["nice", "-n", "19"] -def main(gctx=None): - while True: - # try network - ping_failed = subprocess.call(["ping", "-W", "4", "-c", "1", "8.8.8.8"]) - if ping_failed: - time.sleep(60) + set_consistent_flag(True) + cloudlog.info("done finalizing overlay") + + +def handle_neos_update(wait_helper: WaitTimeHelper) -> None: + with open(NEOS_VERSION, "r") as f: + cur_neos = f.read().strip() + + updated_neos = run(["bash", "-c", r"unset REQUIRED_NEOS_VERSION && source launch_env.sh && \ + echo -n $REQUIRED_NEOS_VERSION"], OVERLAY_MERGED).strip() + + cloudlog.info(f"NEOS version check: {cur_neos} vs {updated_neos}") + if cur_neos == updated_neos: + return + + cloudlog.info(f"Beginning background download for NEOS {updated_neos}") + set_offroad_alert("Offroad_NeosUpdate", True) + + updater_path = os.path.join(OVERLAY_MERGED, "installer/updater/updater") + update_manifest = f"file://{OVERLAY_MERGED}/installer/updater/update.json" + + neos_downloaded = False + start_time = time.monotonic() + # Try to download for one day + while not neos_downloaded and not wait_helper.shutdown and \ + (time.monotonic() - start_time < 60*60*24): + wait_helper.ready_event.clear() + try: + run([updater_path, "bgcache", update_manifest], OVERLAY_MERGED, low_priority=True) + neos_downloaded = True + except subprocess.CalledProcessError: + cloudlog.info("NEOS background download failed, retrying") + wait_helper.sleep(120) + + # If the download failed, we'll show the alert again when we retry + set_offroad_alert("Offroad_NeosUpdate", False) + if not neos_downloaded: + raise Exception("Failed to download NEOS update") + cloudlog.info(f"NEOS background download successful, took {time.monotonic() - start_time} seconds") + + +def check_git_fetch_result(fetch_txt): + err_msg = "Failed to add the host to the list of known hosts (/data/data/com.termux/files/home/.ssh/known_hosts).\n" + return len(fetch_txt) > 0 and (fetch_txt != err_msg) + + +def check_for_update() -> Tuple[bool, bool]: + setup_git_options(OVERLAY_MERGED) + try: + git_fetch_output = run(["git", "fetch", "--dry-run"], OVERLAY_MERGED, low_priority=True) + return True, check_git_fetch_result(git_fetch_output) + except subprocess.CalledProcessError: + return False, False + + +def fetch_update(wait_helper: WaitTimeHelper) -> bool: + cloudlog.info("attempting git fetch inside staging overlay") + + setup_git_options(OVERLAY_MERGED) + + git_fetch_output = run(["git", "fetch"], OVERLAY_MERGED, low_priority=True) + cloudlog.info("git fetch success: %s", git_fetch_output) + + cur_hash = run(["git", "rev-parse", "HEAD"], OVERLAY_MERGED).rstrip() + upstream_hash = run(["git", "rev-parse", "@{u}"], OVERLAY_MERGED).rstrip() + new_version = cur_hash != upstream_hash + git_fetch_result = check_git_fetch_result(git_fetch_output) + + cloudlog.info("comparing %s to %s" % (cur_hash, upstream_hash)) + if new_version or git_fetch_result: + cloudlog.info("Running update") + + if new_version: + cloudlog.info("git reset in progress") + r = [ + run(["git", "reset", "--hard", "@{u}"], OVERLAY_MERGED, low_priority=True), + run(["git", "clean", "-xdf"], OVERLAY_MERGED, low_priority=True ), + run(["git", "submodule", "init"], OVERLAY_MERGED, low_priority=True), + run(["git", "submodule", "update"], OVERLAY_MERGED, low_priority=True), + ] + cloudlog.info("git reset success: %s", '\n'.join(r)) + + if EON: + handle_neos_update(wait_helper) + + # Create the finalized, ready-to-swap update + finalize_update() + cloudlog.info("openpilot update successful!") + else: + cloudlog.info("nothing new from git at this time") + + return new_version + + +def main(): + params = Params() + carSettings = CarSettings() + doAutoUpdate = carSettings.doAutoUpdate + + if params.get("DisableUpdates") == b"1": + raise RuntimeError("updates are disabled by the DisableUpdates param") + + if not doAutoUpdate: + print("Updates are disabled by the doAutoUpdate configuration entry") + + if EON and os.geteuid() != 0: + raise RuntimeError("updated must be launched as root!") + + # Set low io priority + proc = psutil.Process() + if psutil.LINUX: + proc.ionice(psutil.IOPRIO_CLASS_BE, value=7) + + ov_lock_fd = open(LOCK_FILE, 'w') + try: + fcntl.flock(ov_lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB) + except IOError as e: + raise RuntimeError("couldn't get overlay lock; is another updated running?") from e + + # Wait for IsOffroad to be set before our first update attempt + wait_helper = WaitTimeHelper(proc) + wait_helper.sleep(30) + + overlay_init = Path(os.path.join(BASEDIR, ".overlay_init")) + if overlay_init.exists(): + overlay_init.unlink() + + first_run = True + last_fetch_time = 0 + update_failed_count = 0 + + # Run the update loop + # * every 1m, do a lightweight internet/update check + # * every 10m, do a full git fetch + while not wait_helper.shutdown: + update_now = wait_helper.ready_event.is_set() + wait_helper.ready_event.clear() + + if not doAutoUpdate: + wait_helper.sleep(30) continue - # download application update + # Don't run updater while onroad or if the time's wrong + time_wrong = datetime.datetime.utcnow().year < 2019 + is_onroad = params.get("IsOffroad") != b"1" + if is_onroad or time_wrong: + wait_helper.sleep(30) + cloudlog.info("not running updater, not offroad") + continue + + # Attempt an update + exception = None + new_version = False + update_failed_count += 1 try: - r = subprocess.check_output(NICE_LOW_PRIORITY + ["git", "fetch"], stderr=subprocess.STDOUT) + init_overlay() + + internet_ok, update_available = check_for_update() + if internet_ok and not update_available: + update_failed_count = 0 + + # Fetch updates at most every 10 minutes + if internet_ok and (update_now or time.monotonic() - last_fetch_time > 60*10): + new_version = fetch_update(wait_helper) + update_failed_count = 0 + last_fetch_time = time.monotonic() + + if first_run and not new_version and os.path.isdir(NEOSUPDATE_DIR): + shutil.rmtree(NEOSUPDATE_DIR) + first_run = False except subprocess.CalledProcessError as e: - cloudlog.event("git fetch failed", + cloudlog.event( + "update process failed", cmd=e.cmd, output=e.output, - returncode=e.returncode) - time.sleep(60) - continue - cloudlog.info("git fetch success: %s", r) + returncode=e.returncode + ) + exception = f"command failed: {e.cmd}\n{e.output}" + except Exception as e: + cloudlog.exception("uncaught updated exception, shouldn't happen") + exception = str(e) - time.sleep(60*60) + set_params(new_version, update_failed_count, exception) + wait_helper.sleep(60) + + dismount_overlay() if __name__ == "__main__": main() - diff --git a/selfdrive/version.py b/selfdrive/version.py index 2eb39dc9769826..ef975f8940b98e 100644 --- a/selfdrive/version.py +++ b/selfdrive/version.py @@ -1,72 +1,94 @@ +#!/usr/bin/env python3 import os import subprocess +from typing import List, Optional + +from common.basedir import BASEDIR from selfdrive.swaglog import cloudlog -def get_git_commit(): - return subprocess.check_output(["git", "rev-parse", "HEAD"]).strip() +def run_cmd(cmd: List[str]) -> str: + return subprocess.check_output(cmd, encoding='utf8').strip() + + +def run_cmd_default(cmd: List[str], default: Optional[str] = None) -> Optional[str]: + try: + return run_cmd(cmd) + except subprocess.CalledProcessError: + return default -def get_git_branch(): - return subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).strip() +def get_git_commit(branch: str = "HEAD", default: Optional[str] = None) -> Optional[str]: + return run_cmd_default(["git", "rev-parse", branch], default=default) -def get_git_full_branchname(): - return subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"]).strip() +def get_git_branch(default: Optional[str] = None) -> Optional[str]: + return run_cmd_default(["git", "rev-parse", "--abbrev-ref", "HEAD"], default=default) -def get_git_remote(): +def get_git_full_branchname(default: Optional[str] = None) -> Optional[str]: + return run_cmd_default(["git", "rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"], default=default) + + +def get_git_remote(default: Optional[str] = None) -> Optional[str]: try: - local_branch = subprocess.check_output(["git", "name-rev", "--name-only", "HEAD"]).strip() - tracking_remote = subprocess.check_output(["git", "config", "branch." + local_branch + ".remote"]).strip() - return subprocess.check_output(["git", "config", "remote." + tracking_remote + ".url"]).strip() - except subprocess.CalledProcessError: - # Not on a branch, fallback - return subprocess.check_output(["git", "config", "--get", "remote.origin.url"]).strip() + local_branch = run_cmd(["git", "name-rev", "--name-only", "HEAD"]) + tracking_remote = run_cmd(["git", "config", "branch." + local_branch + ".remote"]) + return run_cmd(["git", "config", "remote." + tracking_remote + ".url"]) + except subprocess.CalledProcessError: # Not on a branch, fallback + return run_cmd_default(["git", "config", "--get", "remote.origin.url"], default=default) with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "common", "version.h")) as _versionf: version = _versionf.read().split('"')[1] -try: - origin = get_git_remote() - if origin.startswith('git@github.com:commaai') or origin.startswith('https://github.com/commaai'): - if origin.endswith('/one.git'): - dirty = True - else: - branch = get_git_full_branchname() +prebuilt = os.path.exists(os.path.join(BASEDIR, 'prebuilt')) + +training_version: bytes = b"0.2.0" +terms_version: bytes = b"2" +dirty: bool = True +comma_remote: bool = False +tested_branch: bool = False +origin = get_git_remote() +branch = get_git_full_branchname() + +if (origin is not None) and (branch is not None): + try: + comma_remote = origin.startswith('git@github.com:commaai') or origin.startswith('https://github.com/commaai') + tested_branch = get_git_branch() in ['devel', 'release2-staging', 'dashcam-staging', 'release2', 'dashcam'] + + dirty = False + + # Actually check dirty files + if not prebuilt: # This is needed otherwise touched files might show up as modified try: subprocess.check_call(["git", "update-index", "--refresh"]) except subprocess.CalledProcessError: pass + dirty = (subprocess.call(["git", "diff-index", "--quiet", branch, "--"]) != 0) + + # Log dirty files + if dirty and comma_remote: + try: + dirty_files = run_cmd(["git", "diff-index", branch, "--"]) + cloudlog.event("dirty comma branch", version=version, dirty=dirty, origin=origin, branch=branch, + dirty_files=dirty_files, commit=get_git_commit(), origin_commit=get_git_commit(branch)) + except subprocess.CalledProcessError: + pass - dirty = subprocess.call(["git", "diff-index", "--quiet", branch, "--"]) != 0 - if dirty: - dirty_files = subprocess.check_output(["git", "diff-index", branch, "--"]) - commit = subprocess.check_output(["git", "rev-parse", "--verify", "HEAD"]).rstrip() - origin_commit = subprocess.check_output(["git", "rev-parse", "--verify", branch]).rstrip() - cloudlog.event("dirty comma branch", vesion=version, dirty=dirty, origin=origin, branch=branch, dirty_files=dirty_files, commit=commit, origin_commit=origin_commit) + dirty = dirty or (not comma_remote) + dirty = dirty or ('master' in branch) - else: + except subprocess.CalledProcessError: dirty = True -except subprocess.CalledProcessError: - try: - cloudlog.exception("git subprocess failed while finding version") - except: - pass - dirty = True + cloudlog.exception("git subprocess failed while checking dirty") -training_version = "0.1.0" -terms_version = "2" if __name__ == "__main__": print("Dirty: %s" % dirty) print("Version: %s" % version) print("Remote: %s" % origin) - - try: - print("Branch %s" % branch) - except NameError: - pass + print("Branch: %s" % branch) + print("Prebuilt: %s" % prebuilt) diff --git a/selfdrive/visiond/LICENSE.boringssl b/selfdrive/visiond/LICENSE.boringssl deleted file mode 100644 index 0b0b9b3292837f..00000000000000 --- a/selfdrive/visiond/LICENSE.boringssl +++ /dev/null @@ -1,192 +0,0 @@ -BoringSSL is a fork of OpenSSL. As such, large parts of it fall under OpenSSL -licensing. Files that are completely new have a Google copyright and an ISC -license. This license is reproduced at the bottom of this file. - -Contributors to BoringSSL are required to follow the CLA rules for Chromium: -https://cla.developers.google.com/clas - -Some files from Intel are under yet another license, which is also included -underneath. - -The OpenSSL toolkit stays under a dual license, i.e. both the conditions of the -OpenSSL License and the original SSLeay license apply to the toolkit. See below -for the actual license texts. Actually both licenses are BSD-style Open Source -licenses. In case of any license issues related to OpenSSL please contact -openssl-core@openssl.org. - -The following are Google-internal bug numbers where explicit permission from -some authors is recorded for use of their work. (This is purely for our own -record keeping.) - 27287199 - 27287880 - 27287883 - - OpenSSL License - --------------- - -/* ==================================================================== - * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - - Original SSLeay License - ----------------------- - -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - - -ISC license used for completely new code in BoringSSL: - -/* Copyright (c) 2015, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - - -Some files from Intel carry the following license: - -# Copyright (c) 2012, Intel Corporation -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the -# distribution. -# -# * Neither the name of the Intel Corporation nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# -# THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION ""AS IS"" AND ANY -# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/selfdrive/visiond/LICENSE.libyuv b/selfdrive/visiond/LICENSE.libyuv deleted file mode 100644 index c911747a6b53f0..00000000000000 --- a/selfdrive/visiond/LICENSE.libyuv +++ /dev/null @@ -1,29 +0,0 @@ -Copyright 2011 The LibYuv Project Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - * Neither the name of Google nor the names of its contributors may - be used to endorse or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/selfdrive/visiond/LICENSE.opencv b/selfdrive/visiond/LICENSE.opencv deleted file mode 100644 index fce70d71355380..00000000000000 --- a/selfdrive/visiond/LICENSE.opencv +++ /dev/null @@ -1,41 +0,0 @@ -By downloading, copying, installing or using the software you agree to this license. -If you do not agree to this license, do not download, install, -copy or use the software. - - - License Agreement - For Open Source Computer Vision Library - (3-clause BSD License) - -Copyright (C) 2000-2016, Intel Corporation, all rights reserved. -Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved. -Copyright (C) 2009-2016, NVIDIA Corporation, all rights reserved. -Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved. -Copyright (C) 2015-2016, OpenCV Foundation, all rights reserved. -Copyright (C) 2015-2016, Itseez Inc., all rights reserved. -Third party copyrights are property of their respective owners. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the names of the copyright holders nor the names of the contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - -This software is provided by the copyright holders and contributors "as is" and -any express or implied warranties, including, but not limited to, the implied -warranties of merchantability and fitness for a particular purpose are disclaimed. -In no event shall copyright holders or contributors be liable for any direct, -indirect, incidental, special, exemplary, or consequential damages -(including, but not limited to, procurement of substitute goods or services; -loss of use, data, or profits; or business interruption) however caused -and on any theory of liability, whether in contract, strict liability, -or tort (including negligence or otherwise) arising in any way out of -the use of this software, even if advised of the possibility of such damage. diff --git a/selfdrive/visiond/Makefile b/selfdrive/visiond/Makefile deleted file mode 100644 index 753c5e41ca3182..00000000000000 --- a/selfdrive/visiond/Makefile +++ /dev/null @@ -1,4 +0,0 @@ --include build_from_src.mk - -release: - @echo "visiond: this is a release" diff --git a/selfdrive/visiond/README b/selfdrive/visiond/README deleted file mode 100644 index 1b612afcece0ed..00000000000000 --- a/selfdrive/visiond/README +++ /dev/null @@ -1 +0,0 @@ -visiond runs the openpilot/chffrplus vision pipeline. Everything running between the camera hardware and model outputs lives here. diff --git a/selfdrive/visiond/__init__.py b/selfdrive/visiond/__init__.py deleted file mode 100644 index e69de29bb2d1d6..00000000000000 diff --git a/selfdrive/visiond/bufs.h b/selfdrive/visiond/bufs.h deleted file mode 100644 index 71930baede2cfe..00000000000000 --- a/selfdrive/visiond/bufs.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _SELFDRIVE_VISIOND_VISIOND_H_ -#define _SELFDRIVE_VISIOND_VISIOND_H_ - -#include - -typedef struct { uint8_t *y, *u, *v; } YUVBuf; - -#endif // _SELFDRIVE_VISIOND_VISIOND_H_ diff --git a/selfdrive/visiond/build_from_src.mk b/selfdrive/visiond/build_from_src.mk deleted file mode 100644 index 41e844fe1d8663..00000000000000 --- a/selfdrive/visiond/build_from_src.mk +++ /dev/null @@ -1,221 +0,0 @@ -CC = clang -CXX = clang++ - -BASEDIR = ../.. -EXTERNAL = ../../external -PHONELIBS = ../../phonelibs - -WARN_FLAGS = -Werror=implicit-function-declaration \ - -Werror=incompatible-pointer-types \ - -Werror=int-conversion \ - -Werror=return-type \ - -Werror=format-extra-args \ - -Wno-deprecated-declarations - -CFLAGS = -I. -std=gnu11 -fPIC -O2 $(WARN_FLAGS) -CXXFLAGS = -I. -std=c++14 -fPIC -O2 $(WARN_FLAGS) - -ifeq ($(ARCH),aarch64) -CFLAGS += -mcpu=cortex-a57 -CXXFLAGS += -mcpu=cortex-a57 -endif - -JSON_FLAGS = -I$(PHONELIBS)/json/src -JSON11_FLAGS = -I$(PHONELIBS)/json11/ -EIGEN_FLAGS = -I$(PHONELIBS)/eigen - -UNAME_M := $(shell uname -m) -UNAME_S := $(shell uname -s) - -ifeq ($(UNAME_M),x86_64) - -ifeq ($(UNAME_S),Darwin) - LIBYUV_FLAGS = -I$(PHONELIBS)/libyuv/include - LIBYUV_LIBS = $(PHONELIBS)/libyuv/mac/lib/libyuv.a - - ZMQ_FLAGS = -I$(EXTERNAL)/zmq/include - ZMQ_LIBS = $(PHONELIBS)/zmq/mac/lib/libczmq.a \ - $(PHONELIBS)/zmq/mac/lib/libzmq.a - - OPENCL_LIBS = -framework OpenCL - - PLATFORM_OBJS = cameras/camera_fake.o \ - ../common/visionbuf_cl.o -else - # assume x86_64 linux - LIBYUV_FLAGS = -I$(PHONELIBS)/libyuv/include - LIBYUV_LIBS = $(PHONELIBS)/libyuv/x64/lib/libyuv.a - - ZMQ_FLAGS = -I$(PHONELIBS)/zmq/x64/include - ZMQ_LIBS = -L$(PHONELIBS)/zmq/x64/lib/ -l:libczmq.a -l:libzmq.a - - OPENCL_LIBS = -lOpenCL - - TF_FLAGS = -I$(EXTERNAL)/tensorflow/include - TF_LIBS = -L$(EXTERNAL)/tensorflow/lib -ltensorflow \ - -Wl,-rpath $(EXTERNAL)/tensorflow/lib - - SNPE_FLAGS = -I$(PHONELIBS)/snpe/include/ - SNPE_LIBS = -L$(PHONELIBS)/snpe/x86_64-linux-clang/ \ - -lSNPE -lsymphony-cpu \ - -Wl,-rpath $(PHONELIBS)/snpe/x86_64-linux-clang/ - - CFLAGS += -g - CXXFLAGS += -g -I../common - - PLATFORM_OBJS = cameras/camera_frame_stream.o \ - ../common/visionbuf_cl.o \ - ../common/visionimg.o \ - runners/tfmodel.o -endif - - SSL_FLAGS = -I/usr/include/openssl/ - SSL_LIBS = -lssl -lcrypto - - OTHER_LIBS = -lz -lm -lpthread - - CFLAGS += -D_GNU_SOURCE \ - -DCLU_NO_CACHE - OBJS = visiond.o -else - # assume phone - - LIBYUV_FLAGS = -I$(PHONELIBS)/libyuv/include - LIBYUV_LIBS = $(PHONELIBS)/libyuv/lib/libyuv.a - - ZMQ_LIBS = -l:libczmq.a -l:libzmq.a -lgnustl_shared - - CURL_FLAGS = -I$(PHONELIBS)/curl/include - CURL_LIBS = $(PHONELIBS)/curl/lib/libcurl.a \ - $(PHONELIBS)/zlib/lib/libz.a - - SSL_FLAGS = -I$(PHONELIBS)/boringssl/include - SSL_LIBS = $(PHONELIBS)/boringssl/lib/libssl_static.a \ - $(PHONELIBS)/boringssl/lib/libcrypto_static.a - - OPENCL_FLAGS = -I$(PHONELIBS)/opencl/include - OPENCL_LIBS = -lgsl -lCB -lOpenCL - - OPENGL_LIBS = -lGLESv3 -lEGL - UUID_LIBS = -luuid - - SNPE_FLAGS = -I$(PHONELIBS)/snpe/include/ - SNPE_LIBS = -lSNPE -lsymphony-cpu -lsymphonypower - - OTHER_LIBS = -lz -lcutils -lm -llog -lui -ladreno_utils - - PLATFORM_OBJS = cameras/camera_qcom.o \ - ../common/visionbuf_ion.o \ - ../common/visionimg.o - - CFLAGS += -DQCOM \ - -I$(PHONELIBS)/android_system_core/include \ - -I$(PHONELIBS)/android_frameworks_native/include \ - -I$(PHONELIBS)/android_hardware_libhardware/include \ - -I$(PHONELIBS)/linux/include - CXXFLAGS += -DQCOM \ - -I$(PHONELIBS)/android_system_core/include \ - -I$(PHONELIBS)/android_frameworks_native/include \ - -I$(PHONELIBS)/android_hardware_libhardware/include \ - -I$(PHONELIBS)/linux/include - OBJS = visiond.o -endif - -OUTPUT = visiond - -.PHONY: all -all: $(OUTPUT) - -include ../common/cereal.mk - -OBJS += $(PLATFORM_OBJS) \ - ../common/swaglog.o \ - ../common/ipc.o \ - ../common/visionipc.o \ - ../common/util.o \ - ../common/params.o \ - ../common/efd.o \ - ../common/buffering.o \ - transforms/transform.o \ - transforms/loadyuv.o \ - transforms/rgb_to_yuv.o \ - models/commonmodel.o \ - runners/snpemodel.o \ - models/posenet.o \ - models/monitoring.o \ - models/driving.o \ - clutil.o \ - $(PHONELIBS)/json/src/json.o \ - $(PHONELIBS)/json11/json11.o \ - $(CEREAL_OBJS) - -DEPS := $(OBJS:.o=.d) - -rgb_to_yuv_test: transforms/rgb_to_yuv_test.o clutil.o transforms/rgb_to_yuv.o ../common/util.o - @echo "[ LINK ] $@" - $(CXX) -fPIC -o '$@' $^ \ - $(LIBYUV_LIBS) \ - $(LDFLAGS) \ - -L/usr/lib \ - -L/system/vendor/lib64 \ - $(OPENCL_LIBS) \ - - -$(OUTPUT): $(OBJS) - @echo "[ LINK ] $@" - $(CXX) -fPIC -o '$@' $^ \ - $(LDFLAGS) \ - $(LIBYUV_LIBS) \ - $(OPENGL_LIBS) \ - $(CEREAL_LIBS) \ - $(ZMQ_LIBS) \ - -ljpeg \ - -L/usr/lib \ - -L/system/vendor/lib64 \ - $(OPENCL_LIBS) \ - $(CURL_LIBS) \ - $(SSL_LIBS) \ - $(TF_LIBS) \ - $(SNPE_LIBS) \ - $(UUID_LIBS) \ - $(OTHER_LIBS) - -$(MODEL_OBJS): %.o: %.dlc - @echo "[ bin2o ] $@" - cd '$(dir $<)' && ld -r -b binary '$(notdir $<)' -o '$(abspath $@)' - -%.o: %.cc - @echo "[ CXX ] $@" - $(CXX) $(CXXFLAGS) -MMD \ - -Iinclude -I.. -I../.. \ - $(EIGEN_FLAGS) \ - $(ZMQ_FLAGS) \ - $(CEREAL_CXXFLAGS) \ - $(OPENCL_FLAGS) \ - $(LIBYUV_FLAGS) \ - $(TF_FLAGS) \ - $(SNPE_FLAGS) \ - $(JSON_FLAGS) \ - $(JSON11_FLAGS) $(CURL_FLAGS) \ - -I$(PHONELIBS)/libgralloc/include \ - -I$(PHONELIBS)/linux/include \ - -c -o '$@' '$<' - -%.o: %.c - @echo "[ CC ] $@" - $(CC) $(CFLAGS) -MMD \ - -Iinclude -I.. -I../.. \ - $(ZMQ_FLAGS) \ - $(CEREAL_CFLAGS) \ - $(OPENCL_FLAGS) \ - $(LIBYUV_FLAGS) \ - $(JSON_FLAGS) \ - -I$(PHONELIBS)/libgralloc/include \ - -I$(PHONELIBS)/linux/include \ - -c -o '$@' '$<' - -.PHONY: clean -clean: - rm -f visiond rgb_to_yuv_test rgb_to_yuv_test.o $(OBJS) $(DEPS) - --include $(DEPS) diff --git a/selfdrive/visiond/cameras/camera_common.h b/selfdrive/visiond/cameras/camera_common.h deleted file mode 100644 index cea6a9d125d3cd..00000000000000 --- a/selfdrive/visiond/cameras/camera_common.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef CAMERA_COMMON_H -#define CAMERA_COMMON_H - -#include -#include - -#define CAMERA_ID_IMX298 0 -#define CAMERA_ID_IMX179 1 -#define CAMERA_ID_S5K3P8SP 2 -#define CAMERA_ID_OV8865 3 -#define CAMERA_ID_IMX298_FLIPPED 4 -#define CAMERA_ID_OV10640 5 -#define CAMERA_ID_MAX 6 - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct CameraInfo { - const char* name; - int frame_width, frame_height; - int frame_stride; - bool bayer; - int bayer_flip; - bool hdr; -} CameraInfo; - -typedef struct FrameMetadata { - uint32_t frame_id; - uint64_t timestamp_eof; - unsigned int frame_length; - unsigned int integ_lines; - unsigned int global_gain; - unsigned int lens_pos; - float lens_sag; - float lens_err; - float lens_true_pos; -} FrameMetadata; - -extern CameraInfo cameras_supported[CAMERA_ID_MAX]; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/selfdrive/visiond/cameras/camera_qcom.c b/selfdrive/visiond/cameras/camera_qcom.c deleted file mode 100644 index ccaee8575fc2d4..00000000000000 --- a/selfdrive/visiond/cameras/camera_qcom.c +++ /dev/null @@ -1,2273 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include - -#include "msmb_isp.h" -#include "msmb_ispif.h" -#include "msmb_camera.h" -#include "msm_cam_sensor.h" - -#include "common/util.h" -#include "common/timing.h" -#include "common/swaglog.h" -#include "common/params.h" - -#include "cereal/gen/c/log.capnp.h" - -#include "sensor_i2c.h" - -#include "camera_qcom.h" - - -// enable this to run the camera at 60fps and sample every third frame -// supposed to reduce 33ms of lag, but no results -//#define HIGH_FPS - -#define CAMERA_MSG_AUTOEXPOSE 0 - -typedef struct CameraMsg { - int type; - int camera_num; - - float grey_frac; -} CameraMsg; - -extern volatile int do_exit; - -CameraInfo cameras_supported[CAMERA_ID_MAX] = { - [CAMERA_ID_IMX298] = { - .frame_width = 2328, - .frame_height = 1748, - .frame_stride = 2912, - .bayer = true, - .bayer_flip = 0, - .hdr = true - }, - [CAMERA_ID_IMX179] = { - .frame_width = 3280, - .frame_height = 2464, - .frame_stride = 4104, - .bayer = true, - .bayer_flip = 0, - .hdr = false - }, - [CAMERA_ID_S5K3P8SP] = { - .frame_width = 2304, - .frame_height = 1728, - .frame_stride = 2880, - .bayer = true, - .bayer_flip = 1, - .hdr = false - }, - [CAMERA_ID_OV8865] = { - .frame_width = 1632, - .frame_height = 1224, - .frame_stride = 2040, // seems right - .bayer = true, - .bayer_flip = 3, - .hdr = false - }, - // this exists to get the kernel to build for the LeEco in release - [CAMERA_ID_IMX298_FLIPPED] = { - .frame_width = 2328, - .frame_height = 1748, - .frame_stride = 2912, - .bayer = true, - .bayer_flip = 3, - .hdr = true - }, - [CAMERA_ID_OV10640] = { - .frame_width = 1280, - .frame_height = 1080, - .frame_stride = 2040, - .bayer = true, - .bayer_flip = 0, - .hdr = true - }, -}; - -static void camera_release_buffer(void* cookie, int buf_idx) { - CameraState *s = cookie; - // printf("camera_release_buffer %d\n", buf_idx); - s->ss[0].qbuf_info[buf_idx].dirty_buf = 1; - ioctl(s->isp_fd, VIDIOC_MSM_ISP_ENQUEUE_BUF, &s->ss[0].qbuf_info[buf_idx]); -} - -static void camera_init(CameraState *s, int camera_id, int camera_num, - uint32_t pixel_clock, uint32_t line_length_pclk, - unsigned int max_gain, unsigned int fps) { - memset(s, 0, sizeof(*s)); - - s->camera_num = camera_num; - s->camera_id = camera_id; - - assert(camera_id < ARRAYSIZE(cameras_supported)); - s->ci = cameras_supported[camera_id]; - assert(s->ci.frame_width != 0); - s->frame_size = s->ci.frame_height * s->ci.frame_stride; - - s->pixel_clock = pixel_clock; - s->line_length_pclk = line_length_pclk; - s->max_gain = max_gain; - s->fps = fps; - - zsock_t *ops_sock = zsock_new_push(">inproc://cameraops"); - assert(ops_sock); - s->ops_sock = zsock_resolve(ops_sock); - - tbuffer_init2(&s->camera_tb, FRAME_BUF_COUNT, "frame", - camera_release_buffer, s); - - pthread_mutex_init(&s->frame_info_lock, NULL); -} - - -int sensor_write_regs(CameraState *s, struct msm_camera_i2c_reg_array* arr, size_t size, int data_type) { - struct msm_camera_i2c_reg_setting out_settings = { - .reg_setting = arr, - .size = size, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .data_type = data_type, - .delay = 0, - }; - struct sensorb_cfg_data cfg_data = {0}; - cfg_data.cfgtype = CFG_WRITE_I2C_ARRAY; - cfg_data.cfg.setting = &out_settings; - return ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &cfg_data); -} - -static int imx298_apply_exposure(CameraState *s, int gain, int integ_lines, int frame_length) { - int err; - - int analog_gain = min(gain, 448); - - if (gain > 448) { - s->digital_gain = (512.0/(512-(gain))) / 8.0; - } else { - s->digital_gain = 1.0; - } - - //printf("%5d/%5d %5d %f\n", s->cur_integ_lines, s->cur_frame_length, analog_gain, s->digital_gain); - - int digital_gain = 0x100; - - float white_balance[] = {0.4609375, 1.0, 0.546875}; - //float white_balance[] = {1.0, 1.0, 1.0}; - - int digital_gain_gr = digital_gain / white_balance[1]; - int digital_gain_gb = digital_gain / white_balance[1]; - int digital_gain_r = digital_gain / white_balance[0]; - int digital_gain_b = digital_gain / white_balance[2]; - - struct msm_camera_i2c_reg_array reg_array[] = { - // REG_HOLD - {0x104,0x1,0}, - {0x3002,0x0,0}, // long autoexposure off - - // FRM_LENGTH - {0x340, frame_length >> 8, 0}, {0x341, frame_length & 0xff, 0}, - // INTEG_TIME aka coarse_int_time_addr aka shutter speed - {0x202, integ_lines >> 8, 0}, {0x203, integ_lines & 0xff,0}, - // global_gain_addr - // if you assume 1x gain is 32, 448 is 14x gain, aka 2^14=16384 - {0x204, analog_gain >> 8, 0}, {0x205, analog_gain & 0xff,0}, - - // digital gain for colors: gain_greenR, gain_red, gain_blue, gain_greenB - /*{0x20e, digital_gain_gr >> 8, 0}, {0x20f,digital_gain_gr & 0xFF,0}, - {0x210, digital_gain_r >> 8, 0}, {0x211,digital_gain_r & 0xFF,0}, - {0x212, digital_gain_b >> 8, 0}, {0x213,digital_gain_b & 0xFF,0}, - {0x214, digital_gain_gb >> 8, 0}, {0x215,digital_gain_gb & 0xFF,0},*/ - - // REG_HOLD - {0x104,0x0,0}, - }; - - err = sensor_write_regs(s, reg_array, ARRAYSIZE(reg_array), MSM_CAMERA_I2C_BYTE_DATA); - if (err != 0) { - LOGE("apply_exposure err %d", err); - } - return err; -} - -static inline int ov8865_get_coarse_gain(int gain) { - static const int gains[] = {0, 256, 384, 448, 480}; - int i; - - for (i = 1; i < ARRAYSIZE(gains); i++) { - if (gain >= gains[i - 1] && gain < gains[i]) - break; - } - - return i - 1; -} - -static int ov8865_apply_exposure(CameraState *s, int gain, int integ_lines, int frame_length) { - //printf("front camera: %d %d %d\n", gain, integ_lines, frame_length); - int err, gain_bitmap; - gain_bitmap = (1 << ov8865_get_coarse_gain(gain)) - 1; - integ_lines *= 16; // The exposure value in reg is in 16ths of a line - struct msm_camera_i2c_reg_array reg_array[] = { - //{0x104,0x1,0}, - - // FRM_LENGTH - {0x380e, frame_length >> 8, 0}, {0x380f, frame_length & 0xff, 0}, - // AEC EXPO - {0x3500, integ_lines >> 16, 0}, {0x3501, integ_lines >> 8, 0}, {0x3502, integ_lines & 0xff,0}, - // AEC MANUAL - {0x3503, 0x4, 0}, - // AEC GAIN - {0x3508, gain_bitmap, 0}, {0x3509, 0xf8, 0}, - - //{0x104,0x0,0}, - }; - err = sensor_write_regs(s, reg_array, ARRAYSIZE(reg_array), MSM_CAMERA_I2C_BYTE_DATA); - if (err != 0) { - LOGE("apply_exposure err %d", err); - } - return err; -} - -static int imx179_s5k3p8sp_apply_exposure(CameraState *s, int gain, int integ_lines, int frame_length) { - //printf("front camera: %d %d %d\n", gain, integ_lines, frame_length); - int err; - - if (gain > 448) { - s->digital_gain = (512.0/(512-(gain))) / 8.0; - } else { - s->digital_gain = 1.0; - } - - struct msm_camera_i2c_reg_array reg_array[] = { - {0x104,0x1,0}, - - // FRM_LENGTH - {0x340, frame_length >> 8, 0}, {0x341, frame_length & 0xff, 0}, - // coarse_int_time - {0x202, integ_lines >> 8, 0}, {0x203, integ_lines & 0xff,0}, - // global_gain - {0x204, gain >> 8, 0}, {0x205, gain & 0xff,0}, - - {0x104,0x0,0}, - }; - err = sensor_write_regs(s, reg_array, ARRAYSIZE(reg_array), MSM_CAMERA_I2C_BYTE_DATA); - if (err != 0) { - LOGE("apply_exposure err %d", err); - } - return err; -} - -void cameras_init(DualCameraState *s) { - memset(s, 0, sizeof(*s)); - - char project_name[1024] = {0}; - property_get("ro.boot.project_name", project_name, ""); - - char product_name[1024] = {0}; - property_get("ro.product.name", product_name, ""); - - if (strlen(project_name) == 0) { - LOGD("LePro 3 op system detected"); - s->device = DEVICE_LP3; - - // sensor is flipped in LP3 - // IMAGE_ORIENT = 3 - init_array_imx298[0].reg_data = 3; - cameras_supported[CAMERA_ID_IMX298].bayer_flip = 3; - } else if (strcmp(product_name, "OnePlus3") == 0 && strcmp(project_name, "15811") != 0) { - // no more OP3 support - s->device = DEVICE_OP3; - assert(false); - } else if (strcmp(product_name, "OnePlus3") == 0 && strcmp(project_name, "15811") == 0) { - // only OP3T support - s->device = DEVICE_OP3T; - } else { - assert(false); - } - - // 0 = ISO 100 - // 256 = ISO 200 - // 384 = ISO 400 - // 448 = ISO 800 - // 480 = ISO 1600 - // 496 = ISO 3200 - // 504 = ISO 6400, 8x digital gain - // 508 = ISO 12800, 16x digital gain - // 510 = ISO 25600, 32x digital gain - - camera_init(&s->rear, CAMERA_ID_IMX298, 0, - /*pixel_clock=*/600000000, /*line_length_pclk=*/5536, - /*max_gain=*/510, //0 (ISO 100)- 448 (ISO 800, max analog gain) - 511 (super noisy) -#ifdef HIGH_FPS - /*fps*/60 -#else - /*fps*/20 -#endif - ); - s->rear.apply_exposure = imx298_apply_exposure; - - if (s->device == DEVICE_OP3T) { - camera_init(&s->front, CAMERA_ID_S5K3P8SP, 1, - /*pixel_clock=*/561000000, /*line_length_pclk=*/5120, - /*max_gain=*/510, 10); - s->front.apply_exposure = imx179_s5k3p8sp_apply_exposure; - } else if (s->device == DEVICE_LP3) { - camera_init(&s->front, CAMERA_ID_OV8865, 1, - /*pixel_clock=*/251200000, /*line_length_pclk=*/7000, - /*max_gain=*/510, 10); - s->front.apply_exposure = ov8865_apply_exposure; - } else { - camera_init(&s->front, CAMERA_ID_IMX179, 1, - /*pixel_clock=*/251200000, /*line_length_pclk=*/3440, - /*max_gain=*/224, 20); - s->front.apply_exposure = imx179_s5k3p8sp_apply_exposure; - } - - // assume the device is upside-down (not anymore) - s->rear.transform = (mat3){{ - 1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 0.0, 0.0, 1.0, - }}; - - // probably wrong - s->front.transform = (mat3){{ - 1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 0.0, 0.0, 1.0, - }}; - - s->rear.device = s->device; - s->front.device = s->device; -} - -static void set_exposure(CameraState *s, float exposure_frac, float gain_frac) { - int err = 0; - - unsigned int frame_length = s->pixel_clock / s->line_length_pclk / s->fps; - - unsigned int gain = s->cur_gain; - unsigned int integ_lines = s->cur_integ_lines; - - if (exposure_frac >= 0) { - exposure_frac = clamp(exposure_frac, 2.0 / frame_length, 1.0); - integ_lines = frame_length * exposure_frac; - - // See page 79 of the datasheet, this is the max allowed (-1 for phase adjust) - integ_lines = min(integ_lines, frame_length-11); - } - - // done after exposure to not adjust it - if (s->using_pll) { - // can adjust frame length by up to +/- 1 - const int PHASE_DEADZONE = 20000; // 20 us - int phase_max = 1000000000 / s->fps; - int phase_diff = s->phase_actual - s->phase_request; - phase_diff = ((phase_diff + phase_max/2) % phase_max) - phase_max/2; - - if (phase_diff < -PHASE_DEADZONE) { - frame_length += 1; - } else if (phase_diff > PHASE_DEADZONE) { - frame_length -= 1; - } - } - - if (gain_frac >= 0) { - // ISO200 is minimum gain - gain_frac = clamp(gain_frac, 1.0/64, 1.0); - - // linearize gain response - // TODO: will be wrong for front camera - // 0.125 -> 448 - // 0.25 -> 480 - // 0.5 -> 496 - // 1.0 -> 504 - // 512 - 512/(128*gain_frac) - gain = (s->max_gain/510) * (512 - 512/(256*gain_frac)); - } - - if (gain != s->cur_gain - || integ_lines != s->cur_integ_lines - || frame_length != s->cur_frame_length) { - - if (s->apply_exposure) { - err = s->apply_exposure(s, gain, integ_lines, frame_length); - } - - if (err == 0) { - pthread_mutex_lock(&s->frame_info_lock); - s->cur_gain = gain; - s->cur_integ_lines = integ_lines; - s->cur_frame_length = frame_length; - pthread_mutex_unlock(&s->frame_info_lock); - } - } - - if (err == 0) { - s->cur_exposure_frac = exposure_frac; - s->cur_gain_frac = gain_frac; - } - - //LOGD("set exposure: %f %f - %d", exposure_frac, gain_frac, err); -} - -static void do_autoexposure(CameraState *s, float grey_frac) { - const float target_grey = 0.3; - - float new_exposure = s->cur_exposure_frac; - new_exposure *= pow(1.05, (target_grey - grey_frac) / 0.05 ); - //LOGD("diff %f: %f to %f", target_grey - grey_frac, s->cur_exposure_frac, new_exposure); - - float new_gain = s->cur_gain_frac; - if (new_exposure < 0.10) { - new_gain *= 0.95; - } else if (new_exposure > 0.40) { - new_gain *= 1.05; - } - - set_exposure(s, new_exposure, new_gain); -} - -void camera_autoexposure(CameraState *s, float grey_frac) { - CameraMsg msg = { - .type = CAMERA_MSG_AUTOEXPOSE, - .camera_num = s->camera_num, - .grey_frac = grey_frac, - }; - - zmq_send(s->ops_sock, &msg, sizeof(msg), ZMQ_DONTWAIT); -} - -static uint8_t* get_eeprom(int eeprom_fd, size_t *out_len) { - int err; - - struct msm_eeprom_cfg_data cfg = {0}; - cfg.cfgtype = CFG_EEPROM_GET_CAL_DATA; - err = ioctl(eeprom_fd, VIDIOC_MSM_EEPROM_CFG, &cfg); - assert(err >= 0); - - uint32_t num_bytes = cfg.cfg.get_data.num_bytes; - assert(num_bytes > 100); - - uint8_t* buffer = malloc(num_bytes); - assert(buffer); - memset(buffer, 0, num_bytes); - - cfg.cfgtype = CFG_EEPROM_READ_CAL_DATA; - cfg.cfg.read_data.num_bytes = num_bytes; - cfg.cfg.read_data.dbuffer = buffer; - err = ioctl(eeprom_fd, VIDIOC_MSM_EEPROM_CFG, &cfg); - assert(err >= 0); - - *out_len = num_bytes; - return buffer; -} - -static void imx298_ois_calibration(int ois_fd, uint8_t* eeprom) { - int err; - - const int ois_registers[][2] = { - // == SET_FADJ_PARAM() == (factory adjustment) - - // Set Hall Current DAC - {0x8230, *(uint16_t*)(eeprom+0x102)}, //_P_30_ADC_CH0 (CURDAT) - - // Set Hall PreAmp Offset - {0x8231, *(uint16_t*)(eeprom+0x104)}, //_P_31_ADC_CH1 (HALOFS_X) - {0x8232, *(uint16_t*)(eeprom+0x106)}, //_P_32_ADC_CH2 (HALOFS_Y) - - // Set Hall-X/Y PostAmp Offset - {0x841e, *(uint16_t*)(eeprom+0x108)}, //_M_X_H_ofs - {0x849e, *(uint16_t*)(eeprom+0x10a)}, //_M_Y_H_ofs - - // Set Residual Offset - {0x8239, *(uint16_t*)(eeprom+0x10c)}, //_P_39_Ch3_VAL_1 (PSTXOF) - {0x823b, *(uint16_t*)(eeprom+0x10e)}, //_P_3B_Ch3_VAL_3 (PSTYOF) - - // DIGITAL GYRO OFFSET - {0x8406, *(uint16_t*)(eeprom+0x110)}, //_M_Kgx00 - {0x8486, *(uint16_t*)(eeprom+0x112)}, //_M_Kgy00 - {0x846a, *(uint16_t*)(eeprom+0x120)}, //_M_TMP_X_ - {0x846b, *(uint16_t*)(eeprom+0x122)}, //_M_TMP_Y_ - - // HALLSENSE - // Set Hall Gain - {0x8446, *(uint16_t*)(eeprom+0x114)}, //_M_KgxHG - {0x84c6, *(uint16_t*)(eeprom+0x116)}, //_M_KgyHG - // Set Cross Talk Canceller - {0x8470, *(uint16_t*)(eeprom+0x124)}, //_M_KgxH0 - {0x8472, *(uint16_t*)(eeprom+0x126)}, //_M_KgyH0 - - // LOOPGAIN - {0x840f, *(uint16_t*)(eeprom+0x118)}, //_M_KgxG - {0x848f, *(uint16_t*)(eeprom+0x11a)}, //_M_KgyG - - // Position Servo ON ( OIS OFF ) - {0x847f, 0x0c0c}, //_M_EQCTL - }; - - - struct msm_ois_cfg_data cfg = {0}; - struct msm_camera_i2c_seq_reg_array ois_reg_settings[ARRAYSIZE(ois_registers)] = {{0}}; - for (int i=0; i> 8) & 0xff; - ois_reg_settings[i].reg_data_size = 2; - } - struct msm_camera_i2c_seq_reg_setting ois_reg_setting = { - .reg_setting = &ois_reg_settings[0], - .size = ARRAYSIZE(ois_reg_settings), - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .delay = 0, - }; - cfg.cfgtype = CFG_OIS_I2C_WRITE_SEQ_TABLE; - cfg.cfg.settings = &ois_reg_setting; - err = ioctl(ois_fd, VIDIOC_MSM_OIS_CFG, &cfg); - LOG("ois reg calibration: %d", err); -} - - - - -static void sensors_init(DualCameraState *s) { - int err; - - int sensorinit_fd = -1; - if (s->device == DEVICE_LP3) { - sensorinit_fd = open("/dev/v4l-subdev11", O_RDWR | O_NONBLOCK); - } else { - sensorinit_fd = open("/dev/v4l-subdev12", O_RDWR | O_NONBLOCK); - } - assert(sensorinit_fd >= 0); - - struct sensor_init_cfg_data sensor_init_cfg = {0}; - - // init rear sensor - - struct msm_camera_sensor_slave_info slave_info = {0}; - if (s->device == DEVICE_LP3) { - slave_info = (struct msm_camera_sensor_slave_info){ - .sensor_name = "imx298", - .eeprom_name = "sony_imx298", - .actuator_name = "dw9800w", - .ois_name = "", - .flash_name = "pmic", - .camera_id = 0, - .slave_addr = 32, - .i2c_freq_mode = 1, - .addr_type = 2, - .sensor_id_info = { - .sensor_id_reg_addr = 22, - .sensor_id = 664, - .sensor_id_mask = 0, - .module_id = 9, - .vcm_id = 6, - }, - .power_setting_array = { - .power_setting_a = { - { - .seq_type = 1, - .seq_val = 0, - .config_val = 0, - .delay = 1, - },{ - .seq_type = 2, - .seq_val = 2, - .config_val = 0, - .delay = 0, - },{ - .seq_type = 1, - .seq_val = 5, - .config_val = 2, - .delay = 0, - },{ - .seq_type = 2, - .seq_val = 1, - .config_val = 0, - .delay = 0, - },{ - .seq_type = 2, - .seq_val = 3, - .config_val = 0, - .delay = 1, - },{ - .seq_type = 0, - .seq_val = 0, - .config_val = 24000000, - .delay = 1, - },{ - .seq_type = 1, - .seq_val = 0, - .config_val = 2, - .delay = 10, - }, - }, - .size = 7, - .power_down_setting_a = { - { - .seq_type = 0, - .seq_val = 0, - .config_val = 0, - .delay = 1, - },{ - .seq_type = 1, - .seq_val = 0, - .config_val = 0, - .delay = 1, - },{ - .seq_type = 2, - .seq_val = 1, - .config_val = 0, - .delay = 0, - },{ - .seq_type = 1, - .seq_val = 5, - .config_val = 0, - .delay = 0, - },{ - .seq_type = 2, - .seq_val = 2, - .config_val = 0, - .delay = 0, - },{ - .seq_type = 2, - .seq_val = 3, - .config_val = 0, - .delay = 1, - }, - }, - .size_down = 6, - }, - .is_init_params_valid = 0, - .sensor_init_params = { - .modes_supported = 1, - .position = 0, - .sensor_mount_angle = 90, - }, - .output_format = 0, - }; - } else { - slave_info = (struct msm_camera_sensor_slave_info){ - .sensor_name = "imx298", - .eeprom_name = "sony_imx298", - .actuator_name = "rohm_bu63165gwl", - .ois_name = "rohm_bu63165gwl", - .camera_id = 0, - .slave_addr = 52, - .i2c_freq_mode = 2, - .addr_type = 2, - .sensor_id_info = { - .sensor_id_reg_addr = 22, - .sensor_id = 664, - .sensor_id_mask = 0, - }, - .power_setting_array = { - .power_setting_a = { - { - .seq_type = 1, - .seq_val = 0, - .config_val = 0, - .delay = 2, - },{ - .seq_type = 2, - .seq_val = 2, - .config_val = 0, - .delay = 2, - },{ - .seq_type = 2, - .seq_val = 0, - .config_val = 0, - .delay = 2, - },{ - .seq_type = 2, - .seq_val = 1, - .config_val = 0, - .delay = 2, - },{ - .seq_type = 1, - .seq_val = 6, - .config_val = 2, - .delay = 0, - },{ - .seq_type = 2, - .seq_val = 3, - .config_val = 0, - .delay = 5, - },{ - .seq_type = 2, - .seq_val = 4, - .config_val = 0, - .delay = 5, - },{ - .seq_type = 0, - .seq_val = 0, - .config_val = 24000000, - .delay = 2, - },{ - .seq_type = 1, - .seq_val = 0, - .config_val = 2, - .delay = 2, - }, - }, - .size = 9, - .power_down_setting_a = { - { - .seq_type = 1, - .seq_val = 0, - .config_val = 0, - .delay = 10, - },{ - .seq_type = 0, - .seq_val = 0, - .config_val = 0, - .delay = 1, - },{ - .seq_type = 2, - .seq_val = 4, - .config_val = 0, - .delay = 0, - },{ - .seq_type = 2, - .seq_val = 3, - .config_val = 0, - .delay = 1, - },{ - .seq_type = 1, - .seq_val = 6, - .config_val = 0, - .delay = 0, - },{ - .seq_type = 2, - .seq_val = 1, - .config_val = 0, - .delay = 0, - },{ - .seq_type = 2, - .seq_val = 0, - .config_val = 0, - .delay = 0, - },{ - .seq_type = 2, - .seq_val = 2, - .config_val = 0, - .delay = 0, - }, - }, - .size_down = 8, - }, - .is_init_params_valid = 0, - .sensor_init_params = { - .modes_supported = 1, - .position = 0, - .sensor_mount_angle = 360, - }, - .output_format = 0, - }; - } - slave_info.power_setting_array.power_setting = - (struct msm_sensor_power_setting *)&slave_info.power_setting_array.power_setting_a[0]; - slave_info.power_setting_array.power_down_setting = - (struct msm_sensor_power_setting *)&slave_info.power_setting_array.power_down_setting_a[0]; - sensor_init_cfg.cfgtype = CFG_SINIT_PROBE; - sensor_init_cfg.cfg.setting = &slave_info; - err = ioctl(sensorinit_fd, VIDIOC_MSM_SENSOR_INIT_CFG, &sensor_init_cfg); - LOG("sensor init cfg (rear): %d", err); - assert(err >= 0); - - - struct msm_camera_sensor_slave_info slave_info2 = {0}; - if (s->device == DEVICE_LP3) { - slave_info2 = (struct msm_camera_sensor_slave_info){ - .sensor_name = "ov8865_sunny", - .eeprom_name = "ov8865_plus", - .actuator_name = "", - .ois_name = "", - .flash_name = "", - .camera_id = 2, - .slave_addr = 108, - .i2c_freq_mode = 1, - .addr_type = 2, - .sensor_id_info = { - .sensor_id_reg_addr = 12299, - .sensor_id = 34917, - .sensor_id_mask = 0, - .module_id = 2, - .vcm_id = 0, - }, - .power_setting_array = { - .power_setting_a = { - { - .seq_type = 1, - .seq_val = 0, - .config_val = 0, - .delay = 5, - },{ - .seq_type = 2, - .seq_val = 1, - .config_val = 0, - .delay = 0, - },{ - .seq_type = 2, - .seq_val = 2, - .config_val = 0, - .delay = 0, - },{ - .seq_type = 2, - .seq_val = 0, - .config_val = 0, - .delay = 0, - },{ - .seq_type = 0, - .seq_val = 0, - .config_val = 24000000, - .delay = 1, - },{ - .seq_type = 1, - .seq_val = 0, - .config_val = 2, - .delay = 1, - }, - }, - .size = 6, - .power_down_setting_a = { - { - .seq_type = 1, - .seq_val = 0, - .config_val = 0, - .delay = 5, - },{ - .seq_type = 0, - .seq_val = 0, - .config_val = 0, - .delay = 1, - },{ - .seq_type = 2, - .seq_val = 0, - .config_val = 0, - .delay = 0, - },{ - .seq_type = 2, - .seq_val = 1, - .config_val = 0, - .delay = 0, - },{ - .seq_type = 2, - .seq_val = 2, - .config_val = 0, - .delay = 1, - }, - }, - .size_down = 5, - }, - .is_init_params_valid = 0, - .sensor_init_params = { - .modes_supported = 1, - .position = 1, - .sensor_mount_angle = 270, - }, - .output_format = 0, - }; - } else if (s->front.camera_id == CAMERA_ID_S5K3P8SP) { - // init front camera - slave_info2 = (struct msm_camera_sensor_slave_info){ - .sensor_name = "s5k3p8sp", - .eeprom_name = "s5k3p8sp_m24c64s", - .actuator_name = "", - .ois_name = "", - .camera_id = 1, - .slave_addr = 32, - .i2c_freq_mode = 1, - .addr_type = 2, - .sensor_id_info = { - .sensor_id_reg_addr = 0, - .sensor_id = 12552, - .sensor_id_mask = 0, - }, - .power_setting_array = { - .power_setting_a = { - { - .seq_type = 1, - .seq_val = 0, - .config_val = 0, - .delay = 1, - },{ - .seq_type = 2, - .seq_val = 2, - .config_val = 0, - .delay = 1, - },{ - .seq_type = 2, - .seq_val = 1, - .config_val = 0, - .delay = 1, - },{ - .seq_type = 2, - .seq_val = 0, - .config_val = 0, - .delay = 1, - },{ - .seq_type = 0, - .seq_val = 0, - .config_val = 24000000, - .delay = 1, - },{ - .seq_type = 1, - .seq_val = 0, - .config_val = 2, - .delay = 1, - }, - }, - .size = 6, - .power_down_setting_a = { - { - .seq_type = 0, - .seq_val = 0, - .config_val = 0, - .delay = 1, - },{ - .seq_type = 1, - .seq_val = 0, - .config_val = 0, - .delay = 1, - },{ - .seq_type = 2, - .seq_val = 0, - .config_val = 0, - .delay = 1, - },{ - .seq_type = 2, - .seq_val = 1, - .config_val = 0, - .delay = 1, - },{ - .seq_type = 2, - .seq_val = 2, - .config_val = 0, - .delay = 1, - }, - }, - .size_down = 5, - }, - .is_init_params_valid = 0, - .sensor_init_params = { - .modes_supported = 1, - .position = 1, - .sensor_mount_angle = 270, - }, - .output_format = 0, - }; - } else { - // init front camera - slave_info2 = (struct msm_camera_sensor_slave_info){ - .sensor_name = "imx179", - .eeprom_name = "sony_imx179", - .actuator_name = "", - .ois_name = "", - .camera_id = 1, - .slave_addr = 32, - .i2c_freq_mode = 1, - .addr_type = 2, - .sensor_id_info = { - .sensor_id_reg_addr = 2, - .sensor_id = 377, - .sensor_id_mask = 4095, - }, - .power_setting_array = { - .power_setting_a = { - { - .seq_type = 2, - .seq_val = 2, - .config_val = 0, - .delay = 0, - },{ - .seq_type = 2, - .seq_val = 1, - .config_val = 0, - .delay = 0, - },{ - .seq_type = 2, - .seq_val = 0, - .config_val = 0, - .delay = 0, - },{ - .seq_type = 1, - .seq_val = 0, - .config_val = 2, - .delay = 0, - },{ - .seq_type = 0, - .seq_val = 0, - .config_val = 24000000, - .delay = 0, - }, - }, - .size = 5, - .power_down_setting_a = { - { - .seq_type = 0, - .seq_val = 0, - .config_val = 0, - .delay = 0, - },{ - .seq_type = 1, - .seq_val = 0, - .config_val = 0, - .delay = 1, - },{ - .seq_type = 2, - .seq_val = 0, - .config_val = 0, - .delay = 2, - },{ - .seq_type = 2, - .seq_val = 1, - .config_val = 0, - .delay = 0, - },{ - .seq_type = 2, - .seq_val = 2, - .config_val = 0, - .delay = 0, - }, - }, - .size_down = 5, - }, - .is_init_params_valid = 0, - .sensor_init_params = { - .modes_supported = 1, - .position = 1, - .sensor_mount_angle = 270, - }, - .output_format = 0, - }; - } - slave_info2.power_setting_array.power_setting = - (struct msm_sensor_power_setting *)&slave_info2.power_setting_array.power_setting_a[0]; - slave_info2.power_setting_array.power_down_setting = - (struct msm_sensor_power_setting *)&slave_info2.power_setting_array.power_down_setting_a[0]; - sensor_init_cfg.cfgtype = CFG_SINIT_PROBE; - sensor_init_cfg.cfg.setting = &slave_info2; - err = ioctl(sensorinit_fd, VIDIOC_MSM_SENSOR_INIT_CFG, &sensor_init_cfg); - LOG("sensor init cfg (front): %d", err); - assert(err >= 0); -} - -static void camera_open(CameraState *s, bool rear) { - int err; - - struct sensorb_cfg_data sensorb_cfg_data = {0}; - struct csid_cfg_data csid_cfg_data = {0}; - struct csiphy_cfg_data csiphy_cfg_data = {0}; - struct msm_camera_csiphy_params csiphy_params = {0}; - struct msm_camera_csid_params csid_params = {0}; - struct msm_vfe_input_cfg input_cfg = {0}; - struct msm_vfe_axi_stream_update_cmd update_cmd = {0}; - struct v4l2_event_subscription sub = {0}; - struct ispif_cfg_data ispif_cfg_data = {0}; - struct msm_vfe_cfg_cmd_list cfg_cmd_list = {0}; - - struct msm_actuator_cfg_data actuator_cfg_data = {0}; - struct msm_ois_cfg_data ois_cfg_data = {0}; - - // open devices - if (rear) { - s->csid_fd = open("/dev/v4l-subdev3", O_RDWR | O_NONBLOCK); - assert(s->csid_fd >= 0); - s->csiphy_fd = open("/dev/v4l-subdev0", O_RDWR | O_NONBLOCK); - assert(s->csiphy_fd >= 0); - if (s->device == DEVICE_LP3) { - s->sensor_fd = open("/dev/v4l-subdev17", O_RDWR | O_NONBLOCK); - } else { - s->sensor_fd = open("/dev/v4l-subdev18", O_RDWR | O_NONBLOCK); - } - assert(s->sensor_fd >= 0); - if (s->device == DEVICE_LP3) { - s->isp_fd = open("/dev/v4l-subdev13", O_RDWR | O_NONBLOCK); - } else { - s->isp_fd = open("/dev/v4l-subdev14", O_RDWR | O_NONBLOCK); - } - assert(s->isp_fd >= 0); - s->eeprom_fd = open("/dev/v4l-subdev8", O_RDWR | O_NONBLOCK); - assert(s->eeprom_fd >= 0); - - s->actuator_fd = open("/dev/v4l-subdev7", O_RDWR | O_NONBLOCK); - assert(s->actuator_fd >= 0); - - if (s->device != DEVICE_LP3) { - s->ois_fd = open("/dev/v4l-subdev10", O_RDWR | O_NONBLOCK); - assert(s->ois_fd >= 0); - } - } else { - s->csid_fd = open("/dev/v4l-subdev5", O_RDWR | O_NONBLOCK); - assert(s->csid_fd >= 0); - s->csiphy_fd = open("/dev/v4l-subdev2", O_RDWR | O_NONBLOCK); - assert(s->csiphy_fd >= 0); - if (s->device == DEVICE_LP3) { - s->sensor_fd = open("/dev/v4l-subdev18", O_RDWR | O_NONBLOCK); - } else { - s->sensor_fd = open("/dev/v4l-subdev19", O_RDWR | O_NONBLOCK); - } - assert(s->sensor_fd >= 0); - if (s->device == DEVICE_LP3) { - s->isp_fd = open("/dev/v4l-subdev14", O_RDWR | O_NONBLOCK); - } else { - s->isp_fd = open("/dev/v4l-subdev15", O_RDWR | O_NONBLOCK); - } - assert(s->isp_fd >= 0); - s->eeprom_fd = open("/dev/v4l-subdev9", O_RDWR | O_NONBLOCK); - assert(s->eeprom_fd >= 0); - } - - // *** SHUTDOWN ALL *** - - // CSIPHY: release csiphy - struct msm_camera_csi_lane_params csi_lane_params = {0}; - csi_lane_params.csi_lane_mask = 0x1f; - csiphy_cfg_data.cfg.csi_lane_params = &csi_lane_params; - csiphy_cfg_data.cfgtype = CSIPHY_RELEASE; - err = ioctl(s->csiphy_fd, VIDIOC_MSM_CSIPHY_IO_CFG, &csiphy_cfg_data); - LOG("release csiphy: %d", err); - - // CSID: release csid - csid_cfg_data.cfgtype = CSID_RELEASE; - err = ioctl(s->csid_fd, VIDIOC_MSM_CSID_IO_CFG, &csid_cfg_data); - LOG("release csid: %d", err); - - // SENSOR: send power down - memset(&sensorb_cfg_data, 0, sizeof(sensorb_cfg_data)); - sensorb_cfg_data.cfgtype = CFG_POWER_DOWN; - err = ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &sensorb_cfg_data); - LOG("sensor power down: %d", err); - - if (rear && s->device != DEVICE_LP3) { - // ois powerdown - ois_cfg_data.cfgtype = CFG_OIS_POWERDOWN; - err = ioctl(s->ois_fd, VIDIOC_MSM_OIS_CFG, &ois_cfg_data); - LOG("ois powerdown: %d", err); - } - - // actuator powerdown - actuator_cfg_data.cfgtype = CFG_ACTUATOR_POWERDOWN; - err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data); - LOG("actuator powerdown: %d", err); - - // reset isp - // struct msm_vfe_axi_halt_cmd halt_cmd = { - // .stop_camif = 1, - // .overflow_detected = 1, - // .blocking_halt = 1, - // }; - // err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_AXI_HALT, &halt_cmd); - // printf("axi halt: %d\n", err); - - // struct msm_vfe_axi_reset_cmd reset_cmd = { - // .blocking = 1, - // .frame_id = 1, - // }; - // err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_AXI_RESET, &reset_cmd); - // printf("axi reset: %d\n", err); - - // struct msm_vfe_axi_restart_cmd restart_cmd = { - // .enable_camif = 1, - // }; - // err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_AXI_RESTART, &restart_cmd); - // printf("axi restart: %d\n", err); - - // **** GO GO GO **** - LOG("******************** GO GO GO ************************"); - - s->eeprom = get_eeprom(s->eeprom_fd, &s->eeprom_size); - - // printf("eeprom:\n"); - // for (int i=0; ieeprom_size; i++) { - // printf("%02x", s->eeprom[i]); - // } - // printf("\n"); - - // CSID: init csid - csid_cfg_data.cfgtype = CSID_INIT; - err = ioctl(s->csid_fd, VIDIOC_MSM_CSID_IO_CFG, &csid_cfg_data); - LOG("init csid: %d", err); - - // CSIPHY: init csiphy - memset(&csiphy_cfg_data, 0, sizeof(csiphy_cfg_data)); - csiphy_cfg_data.cfgtype = CSIPHY_INIT; - err = ioctl(s->csiphy_fd, VIDIOC_MSM_CSIPHY_IO_CFG, &csiphy_cfg_data); - LOG("init csiphy: %d", err); - - // SENSOR: stop stream - struct msm_camera_i2c_reg_setting stop_settings = { - .reg_setting = stop_reg_array, - .size = ARRAYSIZE(stop_reg_array), - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .data_type = MSM_CAMERA_I2C_BYTE_DATA, - .delay = 0 - }; - sensorb_cfg_data.cfgtype = CFG_SET_STOP_STREAM_SETTING; - sensorb_cfg_data.cfg.setting = &stop_settings; - err = ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &sensorb_cfg_data); - LOG("stop stream: %d", err); - - // SENSOR: send power up - memset(&sensorb_cfg_data, 0, sizeof(sensorb_cfg_data)); - sensorb_cfg_data.cfgtype = CFG_POWER_UP; - err = ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &sensorb_cfg_data); - LOG("sensor power up: %d", err); - - // **** configure the sensor **** - - // SENSOR: send i2c configuration - if (s->camera_id == CAMERA_ID_IMX298) { - err = sensor_write_regs(s, init_array_imx298, ARRAYSIZE(init_array_imx298), MSM_CAMERA_I2C_BYTE_DATA); - } else if (s->camera_id == CAMERA_ID_S5K3P8SP) { - err = sensor_write_regs(s, init_array_s5k3p8sp, ARRAYSIZE(init_array_s5k3p8sp), MSM_CAMERA_I2C_WORD_DATA); - } else if (s->camera_id == CAMERA_ID_IMX179) { - err = sensor_write_regs(s, init_array_imx179, ARRAYSIZE(init_array_imx179), MSM_CAMERA_I2C_BYTE_DATA); - } else if (s->camera_id == CAMERA_ID_OV8865) { - err = sensor_write_regs(s, init_array_ov8865, ARRAYSIZE(init_array_ov8865), MSM_CAMERA_I2C_BYTE_DATA); - } else { - assert(false); - } - LOG("sensor init i2c: %d", err); - - if (rear) { - // init the actuator - actuator_cfg_data.cfgtype = CFG_ACTUATOR_POWERUP; - err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data); - LOG("actuator powerup: %d", err); - - actuator_cfg_data.cfgtype = CFG_ACTUATOR_INIT; - err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data); - LOG("actuator init: %d", err); - - - // no OIS in LP3 - if (s->device != DEVICE_LP3) { - // see sony_imx298_eeprom_format_afdata in libmmcamera_sony_imx298_eeprom.so - const float far_margin = -0.28; - uint16_t macro_dac = *(uint16_t*)(s->eeprom + 0x24); - s->infinity_dac = *(uint16_t*)(s->eeprom + 0x26); - LOG("macro_dac: %d infinity_dac: %d", macro_dac, s->infinity_dac); - - int dac_range = macro_dac - s->infinity_dac; - s->infinity_dac += far_margin * dac_range; - - LOG(" -> macro_dac: %d infinity_dac: %d", macro_dac, s->infinity_dac); - - struct msm_actuator_reg_params_t actuator_reg_params[] = { - { - .reg_write_type = MSM_ACTUATOR_WRITE_DAC, - .hw_mask = 0, - .reg_addr = 240, - .hw_shift = 0, - .data_type = 10, - .addr_type = 4, - .reg_data = 0, - .delay = 0, - }, { - .reg_write_type = MSM_ACTUATOR_WRITE_DAC, - .hw_mask = 0, - .reg_addr = 241, - .hw_shift = 0, - .data_type = 10, - .addr_type = 4, - .reg_data = 0, - .delay = 0, - }, { - .reg_write_type = MSM_ACTUATOR_WRITE_DAC, - .hw_mask = 0, - .reg_addr = 242, - .hw_shift = 0, - .data_type = 10, - .addr_type = 4, - .reg_data = 0, - .delay = 0, - }, { - .reg_write_type = MSM_ACTUATOR_WRITE_DAC, - .hw_mask = 0, - .reg_addr = 243, - .hw_shift = 0, - .data_type = 10, - .addr_type = 4, - .reg_data = 0, - .delay = 0, - }, - }; - - //... - struct reg_settings_t actuator_init_settings[1] = {0}; - - struct region_params_t region_params[] = { - { - .step_bound = {512, 0,}, - .code_per_step = 118, - .qvalue = 128, - }, - }; - - actuator_cfg_data.cfgtype = CFG_SET_ACTUATOR_INFO; - actuator_cfg_data.cfg.set_info = (struct msm_actuator_set_info_t){ - .actuator_params = { - .act_type = ACTUATOR_VCM, - .reg_tbl_size = 4, - .data_size = 10, - .init_setting_size = 0, - .i2c_freq_mode = I2C_CUSTOM_MODE, - .i2c_addr = 28, - .i2c_addr_type = MSM_ACTUATOR_BYTE_ADDR, - .i2c_data_type = MSM_ACTUATOR_BYTE_DATA, - .reg_tbl_params = &actuator_reg_params[0], - .init_settings = &actuator_init_settings[0], - .park_lens = { - .damping_step = 1023, - .damping_delay = 15000, - .hw_params = 58404, - .max_step = 20, - } - }, - .af_tuning_params = { - .initial_code = s->infinity_dac, - .pwd_step = 0, - .region_size = 1, - .total_steps = 512, - .region_params = ®ion_params[0], - }, - }; - err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data); - LOG("actuator set info: %d", err); - - // power up ois - ois_cfg_data.cfgtype = CFG_OIS_POWERUP; - err = ioctl(s->ois_fd, VIDIOC_MSM_OIS_CFG, &ois_cfg_data); - LOG("ois powerup: %d", err); - - ois_cfg_data.cfgtype = CFG_OIS_INIT; - err = ioctl(s->ois_fd, VIDIOC_MSM_OIS_CFG, &ois_cfg_data); - LOG("ois init: %d", err); - - ois_cfg_data.cfgtype = CFG_OIS_CONTROL; - ois_cfg_data.cfg.set_info.ois_params = (struct msm_ois_params_t){ - // .data_size = 26312, - .setting_size = 120, - .i2c_addr = 28, - .i2c_freq_mode = I2C_CUSTOM_MODE, - // .i2c_addr_type = wtf - // .i2c_data_type = wtf - .settings = &ois_init_settings[0], - }; - err = ioctl(s->ois_fd, VIDIOC_MSM_OIS_CFG, &ois_cfg_data); - LOG("ois init settings: %d", err); - } else { - // leeco actuator - // from sniff - s->infinity_dac = 364; - - struct msm_actuator_reg_params_t actuator_reg_params[] = { - { - .reg_write_type = MSM_ACTUATOR_WRITE_DAC, - .hw_mask = 0, - .reg_addr = 3, - .hw_shift = 0, - .data_type = 9, - .addr_type = 4, - .reg_data = 0, - .delay = 0, - }, - }; - - struct reg_settings_t actuator_init_settings[] = { - { .reg_addr=2, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=1, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 0 }, - { .reg_addr=2, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=0, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 2 }, - { .reg_addr=2, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=2, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 2 }, - { .reg_addr=6, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=64, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 0 }, - { .reg_addr=7, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=113, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 0 }, - }; - - struct region_params_t region_params[] = { - { - .step_bound = {238, 0,}, - .code_per_step = 235, - .qvalue = 128, - }, - }; - - actuator_cfg_data.cfgtype = CFG_SET_ACTUATOR_INFO; - actuator_cfg_data.cfg.set_info = (struct msm_actuator_set_info_t){ - .actuator_params = { - .act_type = ACTUATOR_BIVCM, - .reg_tbl_size = 1, - .data_size = 10, - .init_setting_size = 5, - .i2c_freq_mode = I2C_STANDARD_MODE, - .i2c_addr = 24, - .i2c_addr_type = MSM_ACTUATOR_BYTE_ADDR, - .i2c_data_type = MSM_ACTUATOR_WORD_DATA, - .reg_tbl_params = &actuator_reg_params[0], - .init_settings = &actuator_init_settings[0], - .park_lens = { - .damping_step = 1023, - .damping_delay = 14000, - .hw_params = 11, - .max_step = 20, - } - }, - .af_tuning_params = { - .initial_code = s->infinity_dac, - .pwd_step = 0, - .region_size = 1, - .total_steps = 238, - .region_params = ®ion_params[0], - }, - }; - - err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data); - LOG("actuator set info: %d", err); - } - } - - if (s->camera_id == CAMERA_ID_IMX298) { - err = sensor_write_regs(s, mode_setting_array_imx298, ARRAYSIZE(mode_setting_array_imx298), MSM_CAMERA_I2C_BYTE_DATA); - LOG("sensor setup: %d", err); - } - - // CSIPHY: configure csiphy - if (s->camera_id == CAMERA_ID_IMX298) { - csiphy_params.lane_cnt = 4; - csiphy_params.settle_cnt = 14; - csiphy_params.lane_mask = 0x1f; - csiphy_params.csid_core = 0; - } else if (s->camera_id == CAMERA_ID_S5K3P8SP) { - csiphy_params.lane_cnt = 4; - csiphy_params.settle_cnt = 24; - csiphy_params.lane_mask = 0x1f; - csiphy_params.csid_core = 0; - } else if (s->camera_id == CAMERA_ID_IMX179) { - csiphy_params.lane_cnt = 4; - csiphy_params.settle_cnt = 11; - csiphy_params.lane_mask = 0x1f; - csiphy_params.csid_core = 2; - } else if (s->camera_id == CAMERA_ID_OV8865) { - // guess! - csiphy_params.lane_cnt = 4; - csiphy_params.settle_cnt = 24; - csiphy_params.lane_mask = 0x1f; - csiphy_params.csid_core = 2; - } - csiphy_cfg_data.cfgtype = CSIPHY_CFG; - csiphy_cfg_data.cfg.csiphy_params = &csiphy_params; - err = ioctl(s->csiphy_fd, VIDIOC_MSM_CSIPHY_IO_CFG, &csiphy_cfg_data); - LOG("csiphy configure: %d", err); - - // CSID: configure csid - csid_params.lane_cnt = 4; - csid_params.lane_assign = 0x4320; - if (rear) { - csid_params.phy_sel = 0; - } else { - csid_params.phy_sel = 2; - } - csid_params.lut_params.num_cid = rear ? 3 : 1; - -#define CSI_STATS 0x35 -#define CSI_PD 0x36 - - csid_params.lut_params.vc_cfg_a[0].cid = 0; - csid_params.lut_params.vc_cfg_a[0].dt = CSI_RAW10; - csid_params.lut_params.vc_cfg_a[0].decode_format = CSI_DECODE_10BIT; - csid_params.lut_params.vc_cfg_a[1].cid = 1; - csid_params.lut_params.vc_cfg_a[1].dt = CSI_PD; - csid_params.lut_params.vc_cfg_a[1].decode_format = CSI_DECODE_10BIT; - csid_params.lut_params.vc_cfg_a[2].cid = 2; - csid_params.lut_params.vc_cfg_a[2].dt = CSI_STATS; - csid_params.lut_params.vc_cfg_a[2].decode_format = CSI_DECODE_10BIT; - - csid_params.lut_params.vc_cfg[0] = &csid_params.lut_params.vc_cfg_a[0]; - csid_params.lut_params.vc_cfg[1] = &csid_params.lut_params.vc_cfg_a[1]; - csid_params.lut_params.vc_cfg[2] = &csid_params.lut_params.vc_cfg_a[2]; - - csid_cfg_data.cfgtype = CSID_CFG; - csid_cfg_data.cfg.csid_params = &csid_params; - err = ioctl(s->csid_fd, VIDIOC_MSM_CSID_IO_CFG, &csid_cfg_data); - LOG("csid configure: %d", err); - - // ISP: SMMU_ATTACH - struct msm_vfe_smmu_attach_cmd smmu_attach_cmd = { - .security_mode = 0, - .iommu_attach_mode = IOMMU_ATTACH - }; - err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_SMMU_ATTACH, &smmu_attach_cmd); - LOG("isp smmu attach: %d", err); - - // ******************* STREAM RAW ***************************** - - // configure QMET input - for (int i = 0; i < (rear ? 3 : 1); i++) { - StreamState *ss = &s->ss[i]; - - memset(&input_cfg, 0, sizeof(struct msm_vfe_input_cfg)); - input_cfg.input_src = VFE_RAW_0+i; - input_cfg.input_pix_clk = s->pixel_clock; - input_cfg.d.rdi_cfg.cid = i; - input_cfg.d.rdi_cfg.frame_based = 1; - err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_INPUT_CFG, &input_cfg); - LOG("configure input(%d): %d", i, err); - - // ISP: REQUEST_STREAM - ss->stream_req.axi_stream_handle = 0; - if (rear) { - ss->stream_req.session_id = 2; - ss->stream_req.stream_id = /*ISP_META_CHANNEL_BIT | */ISP_NATIVE_BUF_BIT | (1+i); - } else { - ss->stream_req.session_id = 3; - ss->stream_req.stream_id = ISP_NATIVE_BUF_BIT | 1; - } - - if (i == 0) { - ss->stream_req.output_format = v4l2_fourcc('R', 'G', '1', '0'); - } else { - ss->stream_req.output_format = v4l2_fourcc('Q', 'M', 'E', 'T'); - } - ss->stream_req.stream_src = RDI_INTF_0+i; - -#ifdef HIGH_FPS - if (rear) { - ss->stream_req.frame_skip_pattern = EVERY_3FRAME; - } -#endif - - ss->stream_req.frame_base = 1; - ss->stream_req.buf_divert = 1; //i == 0; - - // setup stream plane. doesn't even matter? - /*s->stream_req.plane_cfg[0].output_plane_format = Y_PLANE; - s->stream_req.plane_cfg[0].output_width = s->ci.frame_width; - s->stream_req.plane_cfg[0].output_height = s->ci.frame_height; - s->stream_req.plane_cfg[0].output_stride = s->ci.frame_width; - s->stream_req.plane_cfg[0].output_scan_lines = s->ci.frame_height; - s->stream_req.plane_cfg[0].rdi_cid = 0;*/ - - err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_REQUEST_STREAM, &ss->stream_req); - LOG("isp request stream: %d -> 0x%x", err, ss->stream_req.axi_stream_handle); - - // ISP: REQUEST_BUF - ss->buf_request.session_id = ss->stream_req.session_id; - ss->buf_request.stream_id = ss->stream_req.stream_id; - ss->buf_request.num_buf = FRAME_BUF_COUNT; - ss->buf_request.buf_type = ISP_PRIVATE_BUF; - ss->buf_request.handle = 0; - err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_REQUEST_BUF, &ss->buf_request); - LOG("isp request buf: %d", err); - LOG("got buf handle: 0x%x", ss->buf_request.handle); - - // ENQUEUE all buffers - for (int j = 0; j < ss->buf_request.num_buf; j++) { - ss->qbuf_info[j].handle = ss->buf_request.handle; - ss->qbuf_info[j].buf_idx = j; - ss->qbuf_info[j].buffer.num_planes = 1; - ss->qbuf_info[j].buffer.planes[0].addr = ss->bufs[j].fd; - ss->qbuf_info[j].buffer.planes[0].length = ss->bufs[j].len; - err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_ENQUEUE_BUF, &ss->qbuf_info[j]); - } - - // ISP: UPDATE_STREAM - update_cmd.num_streams = 1; - update_cmd.update_info[0].user_stream_id = ss->stream_req.stream_id; - update_cmd.update_info[0].stream_handle = ss->stream_req.axi_stream_handle; - update_cmd.update_type = UPDATE_STREAM_ADD_BUFQ; - err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_UPDATE_STREAM, &update_cmd); - LOG("isp update stream: %d", err); - } - - LOG("******** START STREAMS ********"); - - sub.id = 0; - sub.type = 0x1ff; - err = ioctl(s->isp_fd, VIDIOC_SUBSCRIBE_EVENT, &sub); - LOG("isp subscribe: %d", err); - - // ISP: START_STREAM - s->stream_cfg.cmd = START_STREAM; - s->stream_cfg.num_streams = rear ? 3 : 1; - for (int i = 0; i < s->stream_cfg.num_streams; i++) { - s->stream_cfg.stream_handle[i] = s->ss[i].stream_req.axi_stream_handle; - } - err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_CFG_STREAM, &s->stream_cfg); - LOG("isp start stream: %d", err); -} - - -static struct damping_params_t actuator_ringing_params = { - .damping_step = 1023, - .damping_delay = 15000, - .hw_params = 0x0000e422, -}; - -static void rear_start(CameraState *s) { - int err; - - struct msm_actuator_cfg_data actuator_cfg_data = {0}; - - set_exposure(s, 1.0, 1.0); - - err = sensor_write_regs(s, start_reg_array, ARRAYSIZE(start_reg_array), MSM_CAMERA_I2C_BYTE_DATA); - LOG("sensor start regs: %d", err); - - // focus on infinity assuming phone is perpendicular - int inf_step; - - if (s->device != DEVICE_LP3) { - imx298_ois_calibration(s->ois_fd, s->eeprom); - inf_step = 332 - s->infinity_dac; - - // initial guess - s->lens_true_pos = 300; - } else { - // default is OP3, this is for LeEco - actuator_ringing_params.damping_step = 1023; - actuator_ringing_params.damping_delay = 20000; - actuator_ringing_params.hw_params = 13; - - inf_step = 512 - s->infinity_dac; - - // initial guess - s->lens_true_pos = 400; - } - - // reset lens position - memset(&actuator_cfg_data, 0, sizeof(actuator_cfg_data)); - actuator_cfg_data.cfgtype = CFG_SET_POSITION; - actuator_cfg_data.cfg.setpos = (struct msm_actuator_set_position_t){ - .number_of_steps = 1, - .hw_params = (s->device != DEVICE_LP3) ? 0x0000e424 : 7, - .pos = {s->infinity_dac, 0}, - .delay = {0,} - }; - err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data); - LOG("actuator set pos: %d", err); - - // TODO: confirm this isn't needed - /*memset(&actuator_cfg_data, 0, sizeof(actuator_cfg_data)); - actuator_cfg_data.cfgtype = CFG_MOVE_FOCUS; - actuator_cfg_data.cfg.move = (struct msm_actuator_move_params_t){ - .dir = 0, - .sign_dir = 1, - .dest_step_pos = inf_step, - .num_steps = inf_step, - .curr_lens_pos = 0, - .ringing_params = &actuator_ringing_params, - }; - err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data); // should be ~332 at startup ? - LOG("init actuator move focus: %d", err);*/ - //actuator_cfg_data.cfg.move.curr_lens_pos; - - s->cur_lens_pos = 0; - s->cur_step_pos = inf_step; - - actuator_move(s, s->cur_lens_pos); - - LOG("init lens pos: %d", s->cur_lens_pos); -} - -void actuator_move(CameraState *s, uint16_t target) { - int err; - - int step = target - s->cur_lens_pos; - // LP3 moves only on even positions. TODO: use proper sensor params - if (s->device == DEVICE_LP3) { - step /= 2; - } - - int dest_step_pos = s->cur_step_pos + step; - dest_step_pos = clamp(dest_step_pos, 0, 255); - - struct msm_actuator_cfg_data actuator_cfg_data = {0}; - actuator_cfg_data.cfgtype = CFG_MOVE_FOCUS; - actuator_cfg_data.cfg.move = (struct msm_actuator_move_params_t){ - .dir = (step > 0) ? 0 : 1, - .sign_dir = (step > 0) ? 1 : -1, - .dest_step_pos = dest_step_pos, - .num_steps = abs(step), - .curr_lens_pos = s->cur_lens_pos, - .ringing_params = &actuator_ringing_params, - }; - err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data); - //LOGD("actuator move focus: %d", err); - - s->cur_step_pos = dest_step_pos; - s->cur_lens_pos = actuator_cfg_data.cfg.move.curr_lens_pos; - - //LOGD("step %d target: %d lens pos: %d", dest_step_pos, target, s->cur_lens_pos); -} - -static void parse_autofocus(CameraState *s, uint8_t *d) { - int good_count = 0; - int16_t max_focus = -32767; - int avg_focus = 0; - - /*printf("FOCUS: "); - for (int i = 0; i < 0x10; i++) { - printf("%2.2X ", d[i]); - }*/ - - for (int i = 0; i < NUM_FOCUS; i++) { - int doff = i*5+5; - s->confidence[i] = d[doff]; - int16_t focus_t = (d[doff+1] << 3) | (d[doff+2] >> 5); - if (focus_t >= 1024) focus_t = -(2048-focus_t); - s->focus[i] = focus_t; - //printf("%x->%d ", d[doff], focus_t); - if (s->confidence[i] > 0x20) { - good_count++; - max_focus = max(max_focus, s->focus[i]); - avg_focus += s->focus[i]; - } - } - - //printf("\n"); - if (good_count < 4) { - s->focus_err = nan(""); - return; - } - - avg_focus /= good_count; - - // outlier rejection - if (abs(avg_focus - max_focus) > 200) { - s->focus_err = nan(""); - return; - } - - s->focus_err = max_focus*1.0; -} - -static void do_autofocus(CameraState *s) { - // params for focus PI controller - const float focus_kp = 0.005; - - float err = s->focus_err; - float offset = 0; - float sag = (s->last_sag_acc_z/9.8) * 128; - - const int dac_up = s->device == DEVICE_LP3? 634:456; - const int dac_down = s->device == DEVICE_LP3? 366:224; - - if (!isnan(err)) { - // learn lens_true_pos - s->lens_true_pos -= err*focus_kp; - } - - // stay off the walls - s->lens_true_pos = clamp(s->lens_true_pos, dac_down, dac_up); - - int target = clamp(s->lens_true_pos - sag, dac_down, dac_up); - - /*char debug[4096]; - char *pdebug = debug; - pdebug += sprintf(pdebug, "focus "); - for (int i = 0; i < NUM_FOCUS; i++) pdebug += sprintf(pdebug, "%2x(%4d) ", s->confidence[i], s->focus[i]); - pdebug += sprintf(pdebug, " err: %7.2f offset: %6.2f sag: %6.2f lens_true_pos: %6.2f cur_lens_pos: %4d->%4d", err * focus_kp, offset, sag, s->lens_true_pos, s->cur_lens_pos, target); - LOGD(debug);*/ - - actuator_move(s, target); -} - - -static void front_start(CameraState *s) { - int err; - - set_exposure(s, 1.0, 1.0); - - err = sensor_write_regs(s, start_reg_array, ARRAYSIZE(start_reg_array), MSM_CAMERA_I2C_BYTE_DATA); - LOG("sensor start regs: %d", err); -} - - - -void cameras_open(DualCameraState *s, VisionBuf *camera_bufs_rear, VisionBuf *camera_bufs_focus, VisionBuf *camera_bufs_stats, VisionBuf *camera_bufs_front) { - int err; - - struct ispif_cfg_data ispif_cfg_data = {0}; - - struct msm_ispif_param_data ispif_params = {0}; - ispif_params.num = 4; - // rear camera - ispif_params.entries[0].vfe_intf = 0; - ispif_params.entries[0].intftype = RDI0; - ispif_params.entries[0].num_cids = 1; - ispif_params.entries[0].cids[0] = 0; - ispif_params.entries[0].csid = 0; - // front camera - ispif_params.entries[1].vfe_intf = 1; - ispif_params.entries[1].intftype = RDI0; - ispif_params.entries[1].num_cids = 1; - ispif_params.entries[1].cids[0] = 0; - ispif_params.entries[1].csid = 2; - // rear camera (focus) - ispif_params.entries[2].vfe_intf = 0; - ispif_params.entries[2].intftype = RDI1; - ispif_params.entries[2].num_cids = 1; - ispif_params.entries[2].cids[0] = 1; - ispif_params.entries[2].csid = 0; - // rear camera (stats, for AE) - ispif_params.entries[3].vfe_intf = 0; - ispif_params.entries[3].intftype = RDI2; - ispif_params.entries[3].num_cids = 1; - ispif_params.entries[3].cids[0] = 2; - ispif_params.entries[3].csid = 0; - - assert(camera_bufs_rear); - assert(camera_bufs_front); - - int msmcfg_fd = open("/dev/media0", O_RDWR | O_NONBLOCK); - assert(msmcfg_fd >= 0); - - sensors_init(s); - - int v4l_fd = open("/dev/video0", O_RDWR | O_NONBLOCK); - assert(v4l_fd >= 0); - - if (s->device == DEVICE_LP3) { - s->ispif_fd = open("/dev/v4l-subdev15", O_RDWR | O_NONBLOCK); - } else { - s->ispif_fd = open("/dev/v4l-subdev16", O_RDWR | O_NONBLOCK); - } - assert(s->ispif_fd >= 0); - - // ISPIF: stop - // memset(&ispif_cfg_data, 0, sizeof(ispif_cfg_data)); - // ispif_cfg_data.cfg_type = ISPIF_STOP_FRAME_BOUNDARY; - // ispif_cfg_data.params = ispif_params; - // err = ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data); - // LOG("ispif stop: %d", err); - - LOG("*** open front ***"); - s->front.ss[0].bufs = camera_bufs_front; - camera_open(&s->front, false); - - LOG("*** open rear ***"); - s->rear.ss[0].bufs = camera_bufs_rear; - s->rear.ss[1].bufs = camera_bufs_focus; - s->rear.ss[2].bufs = camera_bufs_stats; - camera_open(&s->rear, true); - - if (getenv("CAMERA_TEST")) { - cameras_close(s); - exit(0); - } - - // ISPIF: set vfe info - memset(&ispif_cfg_data, 0, sizeof(ispif_cfg_data)); - ispif_cfg_data.cfg_type = ISPIF_SET_VFE_INFO; - ispif_cfg_data.vfe_info.num_vfe = 2; - err = ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data); - LOG("ispif set vfe info: %d", err); - - // ISPIF: setup - memset(&ispif_cfg_data, 0, sizeof(ispif_cfg_data)); - ispif_cfg_data.cfg_type = ISPIF_INIT; - ispif_cfg_data.csid_version = 0x30050000; //CSID_VERSION_V35 - err = ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data); - LOG("ispif setup: %d", err); - - memset(&ispif_cfg_data, 0, sizeof(ispif_cfg_data)); - ispif_cfg_data.cfg_type = ISPIF_CFG; - ispif_cfg_data.params = ispif_params; - - err = ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data); - LOG("ispif cfg: %d", err); - - ispif_cfg_data.cfg_type = ISPIF_START_FRAME_BOUNDARY; - err = ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data); - LOG("ispif start_frame_boundary: %d", err); - - front_start(&s->front); - rear_start(&s->rear); -} - - -static void camera_close(CameraState *s) { - int err; - - tbuffer_stop(&s->camera_tb); - - // ISP: STOP_STREAM - s->stream_cfg.cmd = STOP_STREAM; - err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_CFG_STREAM, &s->stream_cfg); - LOG("isp stop stream: %d", err); - - for (int i = 0; i < 3; i++) { - StreamState *ss = &s->ss[i]; - if (ss->stream_req.axi_stream_handle != 0) { - err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_RELEASE_BUF, &ss->buf_request); - LOG("isp release buf: %d", err); - - struct msm_vfe_axi_stream_release_cmd stream_release = { - .stream_handle = ss->stream_req.axi_stream_handle, - }; - err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_RELEASE_STREAM, &stream_release); - LOG("isp release stream: %d", err); - } - } - - free(s->eeprom); -} - - -const char* get_isp_event_name(unsigned int type) { - switch (type) { - case ISP_EVENT_REG_UPDATE: return "ISP_EVENT_REG_UPDATE"; - case ISP_EVENT_EPOCH_0: return "ISP_EVENT_EPOCH_0"; - case ISP_EVENT_EPOCH_1: return "ISP_EVENT_EPOCH_1"; - case ISP_EVENT_START_ACK: return "ISP_EVENT_START_ACK"; - case ISP_EVENT_STOP_ACK: return "ISP_EVENT_STOP_ACK"; - case ISP_EVENT_IRQ_VIOLATION: return "ISP_EVENT_IRQ_VIOLATION"; - case ISP_EVENT_STATS_OVERFLOW: return "ISP_EVENT_STATS_OVERFLOW"; - case ISP_EVENT_ERROR: return "ISP_EVENT_ERROR"; - case ISP_EVENT_SOF: return "ISP_EVENT_SOF"; - case ISP_EVENT_EOF: return "ISP_EVENT_EOF"; - case ISP_EVENT_BUF_DONE: return "ISP_EVENT_BUF_DONE"; - case ISP_EVENT_BUF_DIVERT: return "ISP_EVENT_BUF_DIVERT"; - case ISP_EVENT_STATS_NOTIFY: return "ISP_EVENT_STATS_NOTIFY"; - case ISP_EVENT_COMP_STATS_NOTIFY: return "ISP_EVENT_COMP_STATS_NOTIFY"; - case ISP_EVENT_FE_READ_DONE: return "ISP_EVENT_FE_READ_DONE"; - case ISP_EVENT_IOMMU_P_FAULT: return "ISP_EVENT_IOMMU_P_FAULT"; - case ISP_EVENT_HW_FATAL_ERROR: return "ISP_EVENT_HW_FATAL_ERROR"; - case ISP_EVENT_PING_PONG_MISMATCH: return "ISP_EVENT_PING_PONG_MISMATCH"; - case ISP_EVENT_REG_UPDATE_MISSING: return "ISP_EVENT_REG_UPDATE_MISSING"; - case ISP_EVENT_BUF_FATAL_ERROR: return "ISP_EVENT_BUF_FATAL_ERROR"; - case ISP_EVENT_STREAM_UPDATE_DONE: return "ISP_EVENT_STREAM_UPDATE_DONE"; - default: return "unknown"; - } -} - -static FrameMetadata get_frame_metadata(CameraState *s, uint32_t frame_id) { - pthread_mutex_lock(&s->frame_info_lock); - for (int i=0; iframe_metadata[i].frame_id == frame_id) { - pthread_mutex_unlock(&s->frame_info_lock); - return s->frame_metadata[i]; - } - } - pthread_mutex_unlock(&s->frame_info_lock); - - // should never happen - return (FrameMetadata){ - .frame_id = -1, - }; -} - -static bool acceleration_from_sensor_sock(void* sock, float* vs) { - int err; - - zmq_msg_t msg; - err = zmq_msg_init(&msg); - assert(err == 0); - - err = zmq_msg_recv(&msg, sock, 0); - assert(err >= 0); - - struct capn ctx; - capn_init_mem(&ctx, zmq_msg_data(&msg), zmq_msg_size(&msg), 0); - - cereal_Event_ptr eventp; - eventp.p = capn_getp(capn_root(&ctx), 0, 1); - struct cereal_Event eventd; - cereal_read_Event(&eventd, eventp); - - bool ret = false; - - if (eventd.which == cereal_Event_sensorEvents) { - cereal_SensorEventData_list lst = eventd.sensorEvents; - int len = capn_len(lst); - for (int i=0; i= 0); - - struct capn ctx; - capn_init_mem(&ctx, zmq_msg_data(&msg), zmq_msg_size(&msg), 0); - - cereal_Event_ptr eventp; - eventp.p = capn_getp(capn_root(&ctx), 0, 1); - struct cereal_Event eventd; - cereal_read_Event(&eventd, eventp); - - bool ret = false; - - if (eventd.which == cereal_Event_liveLocationTiming) { - struct cereal_LiveLocationData lld; - cereal_read_LiveLocationData(&lld, eventd.liveLocationTiming); - - *mono_time = lld.fixMonoTime; - *vs = lld.timeOfWeek; - ret = true; - } - - capn_free(&ctx); - zmq_msg_close(&msg); - - return ret; -} - -static void ops_term() { - zsock_t *ops_sock = zsock_new_push(">inproc://cameraops"); - assert(ops_sock); - - CameraMsg msg = {.type = -1}; - zmq_send(zsock_resolve(ops_sock), &msg, sizeof(msg), ZMQ_DONTWAIT); - - zsock_destroy(&ops_sock); -} - -static void* ops_thread(void* arg) { - int err; - DualCameraState *s = (DualCameraState*)arg; - - set_thread_name("camera_settings"); - - zsock_t *cameraops = zsock_new_pull("@inproc://cameraops"); - assert(cameraops); - - zsock_t *sensor_sock = zsock_new_sub(">tcp://127.0.0.1:8003", ""); - assert(sensor_sock); - - zsock_t *livelocationtiming_sock = zsock_new_sub(">tcp://127.0.0.1:8049", ""); - assert(livelocationtiming_sock); - - zsock_t *terminate = zsock_new_sub(">inproc://terminate", ""); - assert(terminate); - - zpoller_t *poller = zpoller_new(cameraops, sensor_sock, livelocationtiming_sock, terminate, NULL); - assert(poller); - - while (!do_exit) { - - zsock_t *which = (zsock_t*)zpoller_wait(poller, -1); - if (which == terminate || which == NULL) { - break; - } - void* sockraw = zsock_resolve(which); - - if (which == cameraops) { - zmq_msg_t msg; - err = zmq_msg_init(&msg); - assert(err == 0); - - err = zmq_msg_recv(&msg, sockraw, 0); - assert(err >= 0); - - CameraMsg cmsg; - if (zmq_msg_size(&msg) == sizeof(cmsg)) { - memcpy(&cmsg, zmq_msg_data(&msg), zmq_msg_size(&msg)); - - //LOGD("cameraops %d", cmsg.type); - - if (cmsg.type == CAMERA_MSG_AUTOEXPOSE) { - if (cmsg.camera_num == 0) { - do_autoexposure(&s->rear, cmsg.grey_frac); - do_autofocus(&s->rear); - } else { - do_autoexposure(&s->front, cmsg.grey_frac); - } - } else if (cmsg.type == -1) { - break; - } - } - - zmq_msg_close(&msg); - - } else if (which == sensor_sock) { - float vs[3] = {0.0}; - bool got_accel = acceleration_from_sensor_sock(sockraw, vs); - - uint64_t ts = nanos_since_boot(); - if (got_accel && ts - s->rear.last_sag_ts > 10000000) { // 10 ms - s->rear.last_sag_ts = ts; - s->rear.last_sag_acc_z = -vs[2]; - } - } else if (which == livelocationtiming_sock) { - uint64_t mono_time; - double gps_time; - if (gps_time_from_timing_sock(sockraw, &mono_time, &gps_time)) { - s->rear.global_time_offset = (uint64_t)(gps_time*1e9) - mono_time; - //LOGW("%f %lld = %lld", gps_time, mono_time, s->rear.global_time_offset); - s->rear.phase_request = 10000000; - s->rear.using_pll = true; - } - } - } - - zpoller_destroy(&poller); - zsock_destroy(&cameraops); - zsock_destroy(&sensor_sock); - zsock_destroy(&terminate); - - return NULL; -} - -void cameras_run(DualCameraState *s) { - int err; - - pthread_t ops_thread_handle; - err = pthread_create(&ops_thread_handle, NULL, - ops_thread, s); - assert(err == 0); - - CameraState* cameras[2] = {&s->rear, &s->front}; - - while (!do_exit) { - struct pollfd fds[2] = {{0}}; - - fds[0].fd = cameras[0]->isp_fd; - fds[0].events = POLLPRI; - - fds[1].fd = cameras[1]->isp_fd; - fds[1].events = POLLPRI; - - int ret = poll(fds, ARRAYSIZE(fds), 1000); - if (ret <= 0) { - LOGE("poll failed (%d)", ret); - break; - } - - // process cameras - for (int i=0; i<2; i++) { - if (!fds[i].revents) continue; - - CameraState *c = cameras[i]; - - struct v4l2_event ev; - ret = ioctl(c->isp_fd, VIDIOC_DQEVENT, &ev); - struct msm_isp_event_data *isp_event_data = (struct msm_isp_event_data *)ev.u.data; - unsigned int event_type = ev.type; - - uint64_t timestamp = (isp_event_data->mono_timestamp.tv_sec*1000000000ULL - + isp_event_data->mono_timestamp.tv_usec*1000); - - int buf_idx = isp_event_data->u.buf_done.buf_idx; - int stream_id = isp_event_data->u.buf_done.stream_id; - int buffer = (stream_id&0xFFFF) - 1; - - uint64_t t = nanos_since_boot(); - - /*if (i == 1) { - printf("%10.2f: VIDIOC_DQEVENT: %d type:%X (%s)\n", t*1.0/1e6, ret, event_type, get_isp_event_name(event_type)); - }*/ - - // printf("%d: %s\n", i, get_isp_event_name(event_type)); - - switch (event_type) { - case ISP_EVENT_BUF_DIVERT: - - /*if (c->is_samsung) { - printf("write %d\n", c->frame_size); - FILE *f = fopen("/tmp/test", "wb"); - fwrite((void*)c->camera_bufs[i].addr, 1, c->frame_size, f); - fclose(f); - }*/ - //printf("divert: %d %d %d\n", i, buffer, buf_idx); - - if (buffer == 0) { - c->camera_bufs_metadata[buf_idx] = get_frame_metadata(c, isp_event_data->frame_id); - tbuffer_dispatch(&c->camera_tb, buf_idx); - } else { - uint8_t *d = c->ss[buffer].bufs[buf_idx].addr; - if (buffer == 1) { - parse_autofocus(c, d); - } - c->ss[buffer].qbuf_info[buf_idx].dirty_buf = 1; - ioctl(c->isp_fd, VIDIOC_MSM_ISP_ENQUEUE_BUF, &c->ss[buffer].qbuf_info[buf_idx]); - } - break; - case ISP_EVENT_EOF: - // printf("ISP_EVENT_EOF delta %f\n", (t-last_t)/1e6); - c->last_t = t; - - if (c->using_pll) { - int mod = ((int)1000000000 / c->fps); - c->phase_actual = (((timestamp + c->global_time_offset) % mod) + mod) % mod; - LOGD("phase is %12d request is %12d with offset %lld", c->phase_actual, c->phase_request, c->global_time_offset); - } - - pthread_mutex_lock(&c->frame_info_lock); - c->frame_metadata[c->frame_metadata_idx] = (FrameMetadata){ - .frame_id = isp_event_data->frame_id, - .timestamp_eof = timestamp, - .frame_length = c->cur_frame_length, - .integ_lines = c->cur_integ_lines, - .global_gain = c->cur_gain, - .lens_pos = c->cur_lens_pos, - .lens_sag = c->last_sag_acc_z, - .lens_err = c->focus_err, - .lens_true_pos = c->lens_true_pos, - }; - c->frame_metadata_idx = (c->frame_metadata_idx+1)%METADATA_BUF_COUNT; - pthread_mutex_unlock(&c->frame_info_lock); - - break; - case ISP_EVENT_ERROR: - LOGE("ISP_EVENT_ERROR! err type: 0x%08x", isp_event_data->u.error_info.err_type); - break; - } - } - } - - LOG(" ************** STOPPING **************"); - - ops_term(); - err = pthread_join(ops_thread_handle, NULL); - assert(err == 0); - - cameras_close(s); -} - -void cameras_close(DualCameraState *s) { - camera_close(&s->rear); - camera_close(&s->front); -} - diff --git a/selfdrive/visiond/cameras/camera_qcom.h b/selfdrive/visiond/cameras/camera_qcom.h deleted file mode 100644 index 0cc8f844a57477..00000000000000 --- a/selfdrive/visiond/cameras/camera_qcom.h +++ /dev/null @@ -1,138 +0,0 @@ -#ifndef CAMERA_H -#define CAMERA_H - -#include -#include -#include - -#include "msmb_isp.h" -#include "msmb_ispif.h" -#include "msmb_camera.h" -#include "msm_cam_sensor.h" - -#include "common/mat.h" -#include "common/visionbuf.h" -#include "common/buffering.h" - -#include "camera_common.h" - -#define FRAME_BUF_COUNT 4 -#define METADATA_BUF_COUNT 4 - -#define DEVICE_OP3 0 -#define DEVICE_OP3T 1 -#define DEVICE_LP3 2 - -#define NUM_FOCUS 8 - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct CameraState CameraState; - -typedef int (*camera_apply_exposure_func)(CameraState *s, int gain, int integ_lines, int frame_length); - -typedef struct StreamState { - struct msm_isp_buf_request buf_request; - struct msm_vfe_axi_stream_request_cmd stream_req; - struct msm_isp_qbuf_info qbuf_info[FRAME_BUF_COUNT]; - VisionBuf *bufs; -} StreamState; - -typedef struct CameraState { - int camera_num; - int camera_id; - CameraInfo ci; - int frame_size; - - int device; - - void* ops_sock; - - uint32_t pixel_clock; - uint32_t line_length_pclk; - unsigned int max_gain; - - // PLL to sync cameras in time - // assumes at least 1 FPS - bool using_pll; - int phase_actual; - int phase_request; - int64_t global_time_offset; - - int csid_fd; - int csiphy_fd; - int sensor_fd; - int isp_fd; - int eeprom_fd; - // rear only - int ois_fd, actuator_fd; - uint16_t infinity_dac; - - struct msm_vfe_axi_stream_cfg_cmd stream_cfg; - - size_t eeprom_size; - uint8_t *eeprom; - - // uint32_t camera_bufs_ids[FRAME_BUF_COUNT]; - FrameMetadata camera_bufs_metadata[FRAME_BUF_COUNT]; - TBuffer camera_tb; - - pthread_mutex_t frame_info_lock; - FrameMetadata frame_metadata[METADATA_BUF_COUNT]; - int frame_metadata_idx; - float cur_exposure_frac; - float cur_gain_frac; - int cur_gain; - int cur_frame_length; - int cur_integ_lines; - - float digital_gain; - - StreamState ss[3]; - - uint64_t last_t; - - camera_apply_exposure_func apply_exposure; - - int16_t focus[NUM_FOCUS]; - uint8_t confidence[NUM_FOCUS]; - - float focus_err; - - uint16_t cur_step_pos; - uint16_t cur_lens_pos; - uint64_t last_sag_ts; - float last_sag_acc_z; - float lens_true_pos; - - int fps; - - mat3 transform; -} CameraState; - - -typedef struct DualCameraState { - int device; - - int ispif_fd; - - CameraState rear; - CameraState front; -} DualCameraState; - -void cameras_init(DualCameraState *s); -void cameras_open(DualCameraState *s, VisionBuf *camera_bufs_rear, VisionBuf *camera_bufs_focus, VisionBuf *camera_bufs_stats, VisionBuf *camera_bufs_front); -void cameras_run(DualCameraState *s); -void cameras_close(DualCameraState *s); - -void camera_autoexposure(CameraState *s, float grey_frac); -void actuator_move(CameraState *s, uint16_t target); -int sensor_write_regs(CameraState *s, struct msm_camera_i2c_reg_array* arr, size_t size, int data_type); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif diff --git a/selfdrive/visiond/clutil.c b/selfdrive/visiond/clutil.c deleted file mode 100644 index 0040e4dd6af6ad..00000000000000 --- a/selfdrive/visiond/clutil.c +++ /dev/null @@ -1,418 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __APPLE__ -#include -#else -#include -#endif - -#include "common/util.h" - -#include "clutil.h" - -typedef struct CLUProgramIndex { - uint64_t index_hash; - const uint8_t* bin_data; - const uint8_t* bin_end; -} CLUProgramIndex; - -#ifdef CLU_NO_SRC -#include "clcache_bins.h" -#else -static const CLUProgramIndex clu_index[] = {}; -#endif - -void clu_init(void) { -#ifndef CLU_NO_SRC - mkdir("/tmp/clcache", 0777); - unlink("/tmp/clcache/index.cli"); -#endif -} - -cl_program cl_create_program_from_file(cl_context ctx, const char* path) { - char* src_buf = read_file(path, NULL); - assert(src_buf); - - int err = 0; - cl_program ret = clCreateProgramWithSource(ctx, 1, (const char**)&src_buf, NULL, &err); - assert(err == 0); - - free(src_buf); - - return ret; -} - -static char* get_version_string(cl_platform_id platform) { - size_t size = 0; - int err; - err = clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0, NULL, &size); - assert(err == 0); - char *str = malloc(size); - assert(str); - err = clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, str, NULL); - assert(err == 0); - return str; -} - -void cl_print_info(cl_platform_id platform, cl_device_id device) { - char str[4096]; - - clGetPlatformInfo(platform, CL_PLATFORM_VENDOR, sizeof(str), str, NULL); - printf("vendor: '%s'\n", str); - - char* version = get_version_string(platform); - printf("platform version: '%s'\n", version); - free(version); - - clGetPlatformInfo(platform, CL_PLATFORM_PROFILE, sizeof(str), str, NULL); - printf("profile: '%s'\n", str); - - clGetPlatformInfo(platform, CL_PLATFORM_EXTENSIONS, sizeof(str), str, NULL); - printf("extensions: '%s'\n", str); - - clGetDeviceInfo(device, CL_DEVICE_NAME, sizeof(str), str, NULL); - printf("name: '%s'\n", str); - - clGetDeviceInfo(device, CL_DEVICE_VERSION, sizeof(str), str, NULL); - printf("device version: '%s'\n", str); - - size_t sz; - clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(sz), &sz, NULL); - printf("max work group size: %u\n", sz); - - cl_device_type type; - clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(type), &type, NULL); - printf("type = 0x%04x = ", (unsigned int)type); - switch(type) { - case CL_DEVICE_TYPE_CPU: - printf("CL_DEVICE_TYPE_CPU\n"); - break; - case CL_DEVICE_TYPE_GPU: - printf("CL_DEVICE_TYPE_GPU\n"); - break; - case CL_DEVICE_TYPE_ACCELERATOR: - printf("CL_DEVICE_TYPE_ACCELERATOR\n"); - break; - default: - printf("Other...\n" ); - break; - } -} - -void cl_print_build_errors(cl_program program, cl_device_id device) { - cl_build_status status; - clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS, - sizeof(cl_build_status), &status, NULL); - - size_t log_size; - clGetProgramBuildInfo(program, device, - CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size); - - char* log = calloc(log_size+1, 1); - assert(log); - - clGetProgramBuildInfo(program, device, - CL_PROGRAM_BUILD_LOG, log_size+1, log, NULL); - - printf("build failed; status=%d, log:\n%s\n", - status, log); - - free(log); -} - -uint64_t clu_index_hash(const char* s) { - size_t sl = strlen(s); - assert(sl < 128); - uint64_t x = 0; - for (int i=127; i>=0; i--) { - x *= 65599ULL; - x += (uint8_t)s[i> 32); -} - -uint64_t clu_fnv_hash(const uint8_t *data, size_t len) { - /* 64 bit Fowler/Noll/Vo FNV-1a hash code */ - uint64_t hval = 0xcbf29ce484222325ULL; - const uint8_t *dp = data; - const uint8_t *de = data + len; - while (dp < de) { - hval ^= (uint64_t) *dp++; - hval += (hval << 1) + (hval << 4) + (hval << 5) + - (hval << 7) + (hval << 8) + (hval << 40); - } - - return hval; -} - -cl_program cl_cached_program_from_hash(cl_context ctx, cl_device_id device_id, uint64_t hash) { - int err; - - char cache_path[1024]; - snprintf(cache_path, sizeof(cache_path), "/tmp/clcache/%016" PRIx64 ".clb", hash); - - size_t bin_size; - uint8_t *bin = read_file(cache_path, &bin_size); - if (!bin) { - return NULL; - } - - cl_program prg = clCreateProgramWithBinary(ctx, 1, &device_id, &bin_size, (const uint8_t**)&bin, NULL, &err); - assert(err == 0); - - free(bin); - - err = clBuildProgram(prg, 1, &device_id, NULL, NULL, NULL); - assert(err == 0); - - return prg; -} - -static uint8_t* get_program_binary(cl_program prg, size_t *out_size) { - int err; - - cl_uint num_devices; - err = clGetProgramInfo(prg, CL_PROGRAM_NUM_DEVICES, sizeof(num_devices), &num_devices, NULL); - assert(err == 0); - assert(num_devices == 1); - - size_t binary_size = 0; - err = clGetProgramInfo(prg, CL_PROGRAM_BINARY_SIZES, sizeof(binary_size), &binary_size, NULL); - assert(err == 0); - assert(binary_size > 0); - - uint8_t *binary_buf = malloc(binary_size); - assert(binary_buf); - - uint8_t* bufs[1] = { binary_buf, }; - - err = clGetProgramInfo(prg, CL_PROGRAM_BINARIES, sizeof(bufs), &bufs, NULL); - assert(err == 0); - - *out_size = binary_size; - return binary_buf; -} - -cl_program cl_cached_program_from_string(cl_context ctx, cl_device_id device_id, - const char* src, const char* args, - uint64_t *out_hash) { - int err; - - cl_platform_id platform; - err = clGetDeviceInfo(device_id, CL_DEVICE_PLATFORM, sizeof(platform), &platform, NULL); - assert(err == 0); - - const char* platform_version = get_version_string(platform); - - const size_t hash_len = strlen(platform_version)+1+strlen(src)+1+strlen(args)+1; - char* hash_buf = malloc(hash_len); - assert(hash_buf); - memset(hash_buf, 0, hash_len); - snprintf(hash_buf, hash_len, "%s%c%s%c%s", platform_version, 1, src, 1, args); - free((void*)platform_version); - - uint64_t hash = clu_fnv_hash((uint8_t*)hash_buf, hash_len); - free(hash_buf); - - cl_program prg = NULL; -#ifndef CLU_NO_CACHE - prg = cl_cached_program_from_hash(ctx, device_id, hash); -#endif - if (prg == NULL) { - prg = clCreateProgramWithSource(ctx, 1, (const char**)&src, NULL, &err); - assert(err == 0); - - err = clBuildProgram(prg, 1, &device_id, args, NULL, NULL); - if (err != 0) { - cl_print_build_errors(prg, device_id); - } - assert(err == 0); - -#ifndef CLU_NO_CACHE - // write program binary to cache - - size_t binary_size; - uint8_t *binary_buf = get_program_binary(prg, &binary_size); - - char cache_path[1024]; - snprintf(cache_path, sizeof(cache_path), "/tmp/clcache/%016" PRIx64 ".clb", hash); - FILE* of = fopen(cache_path, "wb"); - assert(of); - fwrite(binary_buf, 1, binary_size, of); - fclose(of); - - free(binary_buf); -#endif - } - - if (out_hash) *out_hash = hash; - return prg; -} - -cl_program cl_cached_program_from_file(cl_context ctx, cl_device_id device_id, const char* path, const char* args, - uint64_t *out_hash) { - char* src_buf = read_file(path, NULL); - assert(src_buf); - cl_program ret = cl_cached_program_from_string(ctx, device_id, src_buf, args, out_hash); - free(src_buf); - return ret; -} - -static void add_index(uint64_t index_hash, uint64_t src_hash) { - FILE *f = fopen("/tmp/clcache/index.cli", "a"); - assert(f); - fprintf(f, "%016" PRIx64 " %016" PRIx64 "\n", index_hash, src_hash); - fclose(f); -} - - -cl_program cl_program_from_index(cl_context ctx, cl_device_id device_id, uint64_t index_hash) { - int err; - - int i; - for (i=0; i= ARRAYSIZE(clu_index)) { - assert(false); - } - - size_t bin_size = clu_index[i].bin_end - clu_index[i].bin_data; - const uint8_t *bin_data = clu_index[i].bin_data; - - cl_program prg = clCreateProgramWithBinary(ctx, 1, &device_id, &bin_size, (const uint8_t**)&bin_data, NULL, &err); - assert(err == 0); - - err = clBuildProgram(prg, 1, &device_id, NULL, NULL, NULL); - assert(err == 0); - - return prg; -} - -cl_program cl_index_program_from_string(cl_context ctx, cl_device_id device_id, - const char* src, const char* args, - uint64_t index_hash) { - uint64_t src_hash = 0; - cl_program ret = cl_cached_program_from_string(ctx, device_id, src, args, &src_hash); -#ifndef CLU_NO_CACHE - add_index(index_hash, src_hash); -#endif - return ret; -} - -cl_program cl_index_program_from_file(cl_context ctx, cl_device_id device_id, const char* path, const char* args, - uint64_t index_hash) { - uint64_t src_hash = 0; - cl_program ret = cl_cached_program_from_file(ctx, device_id, path, args, &src_hash); -#ifndef CLU_NO_CACHE - add_index(index_hash, src_hash); -#endif - return ret; -} - -/* - * Given a cl code and return a string represenation - */ -const char* cl_get_error_string(int err) { - switch (err) { - case 0: return "CL_SUCCESS"; - case -1: return "CL_DEVICE_NOT_FOUND"; - case -2: return "CL_DEVICE_NOT_AVAILABLE"; - case -3: return "CL_COMPILER_NOT_AVAILABLE"; - case -4: return "CL_MEM_OBJECT_ALLOCATION_FAILURE"; - case -5: return "CL_OUT_OF_RESOURCES"; - case -6: return "CL_OUT_OF_HOST_MEMORY"; - case -7: return "CL_PROFILING_INFO_NOT_AVAILABLE"; - case -8: return "CL_MEM_COPY_OVERLAP"; - case -9: return "CL_IMAGE_FORMAT_MISMATCH"; - case -10: return "CL_IMAGE_FORMAT_NOT_SUPPORTED"; - case -12: return "CL_MAP_FAILURE"; - case -13: return "CL_MISALIGNED_SUB_BUFFER_OFFSET"; - case -14: return "CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST"; - case -15: return "CL_COMPILE_PROGRAM_FAILURE"; - case -16: return "CL_LINKER_NOT_AVAILABLE"; - case -17: return "CL_LINK_PROGRAM_FAILURE"; - case -18: return "CL_DEVICE_PARTITION_FAILED"; - case -19: return "CL_KERNEL_ARG_INFO_NOT_AVAILABLE"; - case -30: return "CL_INVALID_VALUE"; - case -31: return "CL_INVALID_DEVICE_TYPE"; - case -32: return "CL_INVALID_PLATFORM"; - case -33: return "CL_INVALID_DEVICE"; - case -34: return "CL_INVALID_CONTEXT"; - case -35: return "CL_INVALID_QUEUE_PROPERTIES"; - case -36: return "CL_INVALID_COMMAND_QUEUE"; - case -37: return "CL_INVALID_HOST_PTR"; - case -38: return "CL_INVALID_MEM_OBJECT"; - case -39: return "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR"; - case -40: return "CL_INVALID_IMAGE_SIZE"; - case -41: return "CL_INVALID_SAMPLER"; - case -42: return "CL_INVALID_BINARY"; - case -43: return "CL_INVALID_BUILD_OPTIONS"; - case -44: return "CL_INVALID_PROGRAM"; - case -45: return "CL_INVALID_PROGRAM_EXECUTABLE"; - case -46: return "CL_INVALID_KERNEL_NAME"; - case -47: return "CL_INVALID_KERNEL_DEFINITION"; - case -48: return "CL_INVALID_KERNEL"; - case -49: return "CL_INVALID_ARG_INDEX"; - case -50: return "CL_INVALID_ARG_VALUE"; - case -51: return "CL_INVALID_ARG_SIZE"; - case -52: return "CL_INVALID_KERNEL_ARGS"; - case -53: return "CL_INVALID_WORK_DIMENSION"; - case -54: return "CL_INVALID_WORK_GROUP_SIZE"; - case -55: return "CL_INVALID_WORK_ITEM_SIZE"; - case -56: return "CL_INVALID_GLOBAL_OFFSET"; - case -57: return "CL_INVALID_EVENT_WAIT_LIST"; - case -58: return "CL_INVALID_EVENT"; - case -59: return "CL_INVALID_OPERATION"; - case -60: return "CL_INVALID_GL_OBJECT"; - case -61: return "CL_INVALID_BUFFER_SIZE"; - case -62: return "CL_INVALID_MIP_LEVEL"; - case -63: return "CL_INVALID_GLOBAL_WORK_SIZE"; - case -64: return "CL_INVALID_PROPERTY"; - case -65: return "CL_INVALID_IMAGE_DESCRIPTOR"; - case -66: return "CL_INVALID_COMPILER_OPTIONS"; - case -67: return "CL_INVALID_LINKER_OPTIONS"; - case -68: return "CL_INVALID_DEVICE_PARTITION_COUNT"; - case -69: return "CL_INVALID_PIPE_SIZE"; - case -70: return "CL_INVALID_DEVICE_QUEUE"; - case -71: return "CL_INVALID_SPEC_ID"; - case -72: return "CL_MAX_SIZE_RESTRICTION_EXCEEDED"; - case -1002: return "CL_INVALID_D3D10_DEVICE_KHR"; - case -1003: return "CL_INVALID_D3D10_RESOURCE_KHR"; - case -1004: return "CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHR"; - case -1005: return "CL_D3D10_RESOURCE_NOT_ACQUIRED_KHR"; - case -1006: return "CL_INVALID_D3D11_DEVICE_KHR"; - case -1007: return "CL_INVALID_D3D11_RESOURCE_KHR"; - case -1008: return "CL_D3D11_RESOURCE_ALREADY_ACQUIRED_KHR"; - case -1009: return "CL_D3D11_RESOURCE_NOT_ACQUIRED_KHR"; - case -1010: return "CL_INVALID_DX9_MEDIA_ADAPTER_KHR"; - case -1011: return "CL_INVALID_DX9_MEDIA_SURFACE_KHR"; - case -1012: return "CL_DX9_MEDIA_SURFACE_ALREADY_ACQUIRED_KHR"; - case -1013: return "CL_DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR"; - case -1093: return "CL_INVALID_EGL_OBJECT_KHR"; - case -1092: return "CL_EGL_RESOURCE_NOT_ACQUIRED_KHR"; - case -1001: return "CL_PLATFORM_NOT_FOUND_KHR"; - case -1057: return "CL_DEVICE_PARTITION_FAILED_EXT"; - case -1058: return "CL_INVALID_PARTITION_COUNT_EXT"; - case -1059: return "CL_INVALID_PARTITION_NAME_EXT"; - case -1094: return "CL_INVALID_ACCELERATOR_INTEL"; - case -1095: return "CL_INVALID_ACCELERATOR_TYPE_INTEL"; - case -1096: return "CL_INVALID_ACCELERATOR_DESCRIPTOR_INTEL"; - case -1097: return "CL_ACCELERATOR_TYPE_NOT_SUPPORTED_INTEL"; - case -1000: return "CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR"; - case -1098: return "CL_INVALID_VA_API_MEDIA_ADAPTER_INTEL"; - case -1099: return "CL_INVALID_VA_API_MEDIA_SURFACE_INTEL"; - case -1100: return "CL_VA_API_MEDIA_SURFACE_ALREADY_ACQUIRED_INTEL"; - case -1101: return "CL_VA_API_MEDIA_SURFACE_NOT_ACQUIRED_INTEL"; - default: return "CL_UNKNOWN_ERROR"; - } -} diff --git a/selfdrive/visiond/clutil.h b/selfdrive/visiond/clutil.h deleted file mode 100644 index b87961eacdfbf8..00000000000000 --- a/selfdrive/visiond/clutil.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef CLUTIL_H -#define CLUTIL_H - -#include -#include -#include - -#ifdef __APPLE__ -#include -#else -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -void clu_init(void); - -cl_program cl_create_program_from_file(cl_context ctx, const char* path); -void cl_print_info(cl_platform_id platform, cl_device_id device); -void cl_print_build_errors(cl_program program, cl_device_id device); -void cl_print_build_errors(cl_program program, cl_device_id device); - -cl_program cl_cached_program_from_hash(cl_context ctx, cl_device_id device_id, uint64_t hash); -cl_program cl_cached_program_from_string(cl_context ctx, cl_device_id device_id, - const char* src, const char* args, - uint64_t *out_hash); -cl_program cl_cached_program_from_file(cl_context ctx, cl_device_id device_id, const char* path, const char* args, - uint64_t *out_hash); - -cl_program cl_program_from_index(cl_context ctx, cl_device_id device_id, uint64_t index_hash); - -cl_program cl_index_program_from_string(cl_context ctx, cl_device_id device_id, - const char* src, const char* args, - uint64_t index_hash); -cl_program cl_index_program_from_file(cl_context ctx, cl_device_id device_id, const char* path, const char* args, - uint64_t index_hash); - -uint64_t clu_index_hash(const char *s); -uint64_t clu_fnv_hash(const uint8_t *data, size_t len); - -const char* cl_get_error_string(int err); - -static inline int cl_check_error(int err) { - if (err != 0) { - fprintf(stderr, "%s\n", cl_get_error_string(err)); - exit(1); - } - return err; -} - - -// // string hash macro. compiler, I'm so sorry. -#define CLU_H1(s,i,x) (x*65599ULL+(uint8_t)s[(i)>32))) - -#define CLU_STRINGIFY(x) #x -#define CLU_STRINGIFY2(x) CLU_STRINGIFY(x) -#define CLU_LINESTR CLU_STRINGIFY2(__LINE__) - -#ifdef CLU_NO_SRC - - #define CLU_LOAD_FROM_STRING(ctx, device_id, src, args) \ - cl_program_from_index(ctx, device_id, CLU_HASH("\1" __FILE__ "\1" CLU_LINESTR) ^ clu_fnv_hash((const uint8_t*)__func__, strlen(__func__)) ^ clu_fnv_hash((const uint8_t*)args, strlen(args))) - #define CLU_LOAD_FROM_FILE(ctx, device_id, path, args) \ - cl_program_from_index(ctx, device_id, CLU_HASH("\2" path) ^ clu_fnv_hash((const uint8_t*)args, strlen(args))) - -#else - - #define CLU_LOAD_FROM_STRING(ctx, device_id, src, args) \ - cl_index_program_from_string(ctx, device_id, src, args, clu_index_hash("\1" __FILE__ "\1" CLU_LINESTR) ^ clu_fnv_hash((const uint8_t*)__func__, strlen(__func__)) ^ clu_fnv_hash((const uint8_t*)args, strlen(args))) - #define CLU_LOAD_FROM_FILE(ctx, device_id, path, args) \ - cl_index_program_from_file(ctx, device_id, path, args, clu_index_hash("\2" path) ^ clu_fnv_hash((const uint8_t*)args, strlen(args))) - -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/selfdrive/visiond/constants.py b/selfdrive/visiond/constants.py deleted file mode 100644 index 56c4b76a3a2a9a..00000000000000 --- a/selfdrive/visiond/constants.py +++ /dev/null @@ -1,3 +0,0 @@ -MAX_DISTANCE = 140. -LANE_OFFSET = 1.8 -MAX_REL_V = 10. diff --git a/selfdrive/visiond/models/commonmodel.c b/selfdrive/visiond/models/commonmodel.c deleted file mode 100644 index 33aabd1cee59a6..00000000000000 --- a/selfdrive/visiond/models/commonmodel.c +++ /dev/null @@ -1,199 +0,0 @@ -#include "commonmodel.h" - -#include -#include "cereal/gen/c/log.capnp.h" -#include "common/mat.h" -#include "common/timing.h" - -void model_input_init(ModelInput* s, int width, int height, - cl_device_id device_id, cl_context context) { - int err; - s->device_id = device_id; - s->context = context; - - transform_init(&s->transform, context, device_id); - s->transformed_width = width; - s->transformed_height = height; - - s->transformed_y_cl = clCreateBuffer(s->context, CL_MEM_READ_WRITE, - s->transformed_width*s->transformed_height, NULL, &err); - assert(err == 0); - s->transformed_u_cl = clCreateBuffer(s->context, CL_MEM_READ_WRITE, - (s->transformed_width/2)*(s->transformed_height/2), NULL, &err); - assert(err == 0); - s->transformed_v_cl = clCreateBuffer(s->context, CL_MEM_READ_WRITE, - (s->transformed_width/2)*(s->transformed_height/2), NULL, &err); - assert(err == 0); - - s->net_input_size = ((width*height*3)/2)*sizeof(float); - s->net_input = clCreateBuffer(s->context, CL_MEM_READ_WRITE, - s->net_input_size, (void*)NULL, &err); - assert(err == 0); - - loadyuv_init(&s->loadyuv, context, device_id, s->transformed_width, s->transformed_height); -} - -float *model_input_prepare(ModelInput* s, cl_command_queue q, - cl_mem yuv_cl, int width, int height, - mat3 transform) { - int err; - int i = 0; - transform_queue(&s->transform, q, - yuv_cl, width, height, - s->transformed_y_cl, s->transformed_u_cl, s->transformed_v_cl, - s->transformed_width, s->transformed_height, - transform); - loadyuv_queue(&s->loadyuv, q, - s->transformed_y_cl, s->transformed_u_cl, s->transformed_v_cl, - s->net_input); - float *net_input_buf = (float *)clEnqueueMapBuffer(q, s->net_input, CL_TRUE, - CL_MAP_READ, 0, s->net_input_size, - 0, NULL, NULL, &err); - clFinish(q); - return net_input_buf; -} - -void model_input_free(ModelInput* s) { - transform_destroy(&s->transform); - loadyuv_destroy(&s->loadyuv); -} - - -float sigmoid(float input) { - return 1 / (1 + expf(-input)); -} - -float softplus(float input) { - return log1p(expf(input)); -} - -void softmax(const float* input, float* output, size_t len) { - float max_val = -FLT_MAX; - for(int i = 0; i < len; i++) { - const float v = input[i]; - if( v > max_val ) { - max_val = v; - } - } - - float denominator = 0; - for(int i = 0; i < len; i++) { - float const v = input[i]; - float const v_exp = expf(v - max_val); - denominator += v_exp; - output[i] = v_exp; - } - - const float inv_denominator = 1. / denominator; - for(int i = 0; i < len; i++) { - output[i] *= inv_denominator; - } - -} - - -static cereal_ModelData_PathData_ptr path_to_cereal(struct capn_segment *cs, const PathData data) { - capn_list32 poly_ptr = capn_new_list32(cs, POLYFIT_DEGREE); - for (int i=0; i - -#include "common/mat.h" -#include "common/modeldata.h" -#include "transforms/transform.h" -#include "transforms/loadyuv.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void softmax(const float* input, float* output, size_t len); -float softplus(float input); -float sigmoid(float input); - -typedef struct ModelInput { - cl_device_id device_id; - cl_context context; - - // input - Transform transform; - int transformed_width, transformed_height; - cl_mem transformed_y_cl, transformed_u_cl, transformed_v_cl; - LoadYUVState loadyuv; - cl_mem net_input; - size_t net_input_size; -} ModelInput; - -void model_input_init(ModelInput* s, int width, int height, - cl_device_id device_id, cl_context context); -float *model_input_prepare(ModelInput* s, cl_command_queue q, - cl_mem yuv_cl, int width, int height, - mat3 transform); -void model_input_free(ModelInput* s); - -void model_publish(void* sock, uint32_t frame_id, - const mat3 transform, const ModelData data); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/selfdrive/visiond/models/driving.cc b/selfdrive/visiond/models/driving.cc deleted file mode 100644 index 33b7ec10ff692d..00000000000000 --- a/selfdrive/visiond/models/driving.cc +++ /dev/null @@ -1,203 +0,0 @@ -#include -#include -#include -#include - -#ifdef QCOM -#include -#else -#include -#endif - -#include "common/timing.h" -#include "driving.h" - -#define MODEL_WIDTH 512 -#define MODEL_HEIGHT 256 -#define MODEL_NAME "driving_model_dlc" - -#define LEAD_MDN_N 5 // probs for 5 groups -#define MDN_VALS 4 // output xyva for each lead group -#define SELECTION 3 //output 3 group (lead now, in 2s and 6s) -#define MDN_GROUP_SIZE 11 -#define SPEED_BUCKETS 100 -#define OUTPUT_SIZE ((MODEL_PATH_DISTANCE*2) + (2*(MODEL_PATH_DISTANCE*2 + 1)) + MDN_GROUP_SIZE*LEAD_MDN_N + SELECTION) -#ifdef TEMPORAL - #define TEMPORAL_SIZE 512 -#else - #define TEMPORAL_SIZE 0 -#endif - -// #define DUMP_YUV - -Eigen::Matrix vander; - -void model_init(ModelState* s, cl_device_id device_id, cl_context context, int temporal) { - model_input_init(&s->in, MODEL_WIDTH, MODEL_HEIGHT, device_id, context); - const int output_size = OUTPUT_SIZE + TEMPORAL_SIZE; - s->output = (float*)malloc(output_size * sizeof(float)); - memset(s->output, 0, output_size * sizeof(float)); - s->m = new DefaultRunModel("../../models/driving_model.dlc", s->output, output_size); -#ifdef TEMPORAL - assert(temporal); - s->m->addRecurrent(&s->output[OUTPUT_SIZE], TEMPORAL_SIZE); -#endif - - // Build Vandermonde matrix - for(int i = 0; i < MODEL_PATH_DISTANCE; i++) { - for(int j = 0; j < POLYFIT_DEGREE; j++) { - vander(i, j) = pow(i, POLYFIT_DEGREE-j-1); - } - } -} - -ModelData model_eval_frame(ModelState* s, cl_command_queue q, - cl_mem yuv_cl, int width, int height, - mat3 transform, void* sock) { - struct { - float *path; - float *left_lane; - float *right_lane; - float *lead; - float *speed; - } net_outputs = {NULL}; - - //for (int i = 0; i < OUTPUT_SIZE + TEMPORAL_SIZE; i++) { printf("%f ", s->output[i]); } printf("\n"); - - float *net_input_buf = model_input_prepare(&s->in, q, yuv_cl, width, height, transform); - - #ifdef DUMP_YUV - FILE *dump_yuv_file = fopen("/sdcard/dump.yuv", "wb"); - fwrite(net_input_buf, MODEL_HEIGHT*MODEL_WIDTH*3/2, sizeof(float), dump_yuv_file); - fclose(dump_yuv_file); - assert(1==2); - #endif - - //printf("readinggggg \n"); - //FILE *f = fopen("goof_frame", "r"); - //fread(net_input_buf, sizeof(float), MODEL_HEIGHT*MODEL_WIDTH*3/2, f); - //fclose(f); - //sleep(1); - //printf("%i \n",OUTPUT_SIZE); - //printf("%i \n",MDN_GROUP_SIZE); - s->m->execute(net_input_buf); - - // net outputs - net_outputs.path = &s->output[0]; - net_outputs.left_lane = &s->output[MODEL_PATH_DISTANCE*2]; - net_outputs.right_lane = &s->output[MODEL_PATH_DISTANCE*2 + MODEL_PATH_DISTANCE*2 + 1]; - net_outputs.lead = &s->output[MODEL_PATH_DISTANCE*2 + (MODEL_PATH_DISTANCE*2 + 1)*2]; - //net_outputs.speed = &s->output[OUTPUT_SIZE - SPEED_BUCKETS]; - - ModelData model = {0}; - - for (int i=0; i net_outputs.lead[mdn_max_idx*MDN_GROUP_SIZE + 8]) { - mdn_max_idx = i; - } - } - model.lead.prob = sigmoid(net_outputs.lead[LEAD_MDN_N*MDN_GROUP_SIZE]); - model.lead.dist = net_outputs.lead[mdn_max_idx*MDN_GROUP_SIZE] * max_dist; - model.lead.std = softplus(net_outputs.lead[mdn_max_idx*MDN_GROUP_SIZE + MDN_VALS]) * max_dist; - model.lead.rel_y = net_outputs.lead[mdn_max_idx*MDN_GROUP_SIZE + 1]; - model.lead.rel_y_std = softplus(net_outputs.lead[mdn_max_idx*MDN_GROUP_SIZE + MDN_VALS + 1]); - model.lead.rel_v = net_outputs.lead[mdn_max_idx*MDN_GROUP_SIZE + 2] * max_rel_vel; - model.lead.rel_v_std = softplus(net_outputs.lead[mdn_max_idx*MDN_GROUP_SIZE + MDN_VALS + 2]) * max_rel_vel; - model.lead.rel_a = net_outputs.lead[mdn_max_idx*MDN_GROUP_SIZE + 3]; - model.lead.rel_a_std = softplus(net_outputs.lead[mdn_max_idx*MDN_GROUP_SIZE + MDN_VALS + 3]); - - // Find the distribution that corresponds to the lead in 2s - mdn_max_idx = 0; - for (int i=1; i net_outputs.lead[mdn_max_idx*MDN_GROUP_SIZE + 9]) { - mdn_max_idx = i; - } - } - model.lead_future.prob = sigmoid(net_outputs.lead[LEAD_MDN_N*MDN_GROUP_SIZE + 1]); - model.lead_future.dist = net_outputs.lead[mdn_max_idx*MDN_GROUP_SIZE] * max_dist; - model.lead_future.std = softplus(net_outputs.lead[mdn_max_idx*MDN_GROUP_SIZE + MDN_VALS]) * max_dist; - model.lead_future.rel_y = net_outputs.lead[mdn_max_idx*MDN_GROUP_SIZE + 1]; - model.lead_future.rel_y_std = softplus(net_outputs.lead[mdn_max_idx*MDN_GROUP_SIZE + MDN_VALS + 1]); - model.lead_future.rel_v = net_outputs.lead[mdn_max_idx*MDN_GROUP_SIZE + 2] * max_rel_vel; - model.lead_future.rel_v_std = softplus(net_outputs.lead[mdn_max_idx*MDN_GROUP_SIZE + MDN_VALS + 2]) * max_rel_vel; - model.lead_future.rel_a = net_outputs.lead[mdn_max_idx*MDN_GROUP_SIZE + 3]; - model.lead_future.rel_a_std = softplus(net_outputs.lead[mdn_max_idx*MDN_GROUP_SIZE + MDN_VALS + 3]); - - - // get speed percentiles numbers represent 5th, 15th, ... 95th percentile - for (int i=0; i < SPEED_PERCENTILES; i++) { - model.speed[i] = ((float) SPEED_BUCKETS)/2.0; - } - //float sum = 0; - //for (int idx = 0; idx < SPEED_BUCKETS; idx++) { - // sum += net_outputs.speed[idx]; - // int idx_percentile = (sum + .05) * SPEED_PERCENTILES; - // if (idx_percentile < SPEED_PERCENTILES ){ - // model.speed[idx_percentile] = ((float)idx)/2.0; - // } - //} - // make sure no percentiles are skipped - //for (int i=SPEED_PERCENTILES-1; i > 0; i--){ - // if (model.speed[i-1] > model.speed[i]){ - // model.speed[i-1] = model.speed[i]; - // } - //} - return model; -} - -void model_free(ModelState* s) { - free(s->output); - model_input_free(&s->in); - delete s->m; -} - -void poly_fit(float *in_pts, float *in_stds, float *out) { - // References to inputs - Eigen::Map > pts(in_pts, MODEL_PATH_DISTANCE); - Eigen::Map > std(in_stds, MODEL_PATH_DISTANCE); - Eigen::Map > p(out, POLYFIT_DEGREE); - - // Build Least Squares equations - Eigen::Matrix lhs = vander.array().colwise() / std.array(); - Eigen::Matrix rhs = pts.array() / std.array(); - - // Improve numerical stability - Eigen::Matrix scale = 1. / (lhs.array()*lhs.array()).sqrt().colwise().sum(); - lhs = lhs * scale.asDiagonal(); - - // Solve inplace - Eigen::ColPivHouseholderQR > qr(lhs); - p = qr.solve(rhs); - - // Apply scale to output - p = p.transpose() * scale.asDiagonal(); -} diff --git a/selfdrive/visiond/models/driving.h b/selfdrive/visiond/models/driving.h deleted file mode 100644 index 966cf69473c330..00000000000000 --- a/selfdrive/visiond/models/driving.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef MODEL_H -#define MODEL_H - -// gate this here -#define TEMPORAL - -#include "common/mat.h" -#include "common/modeldata.h" - -#include "commonmodel.h" -#include "runners/run.h" - -typedef struct ModelState { - ModelInput in; - float *output; - RunModel *m; -} ModelState; - -void model_init(ModelState* s, cl_device_id device_id, - cl_context context, int temporal); -ModelData model_eval_frame(ModelState* s, cl_command_queue q, - cl_mem yuv_cl, int width, int height, - mat3 transform, void* sock); -void model_free(ModelState* s); -void poly_fit(float *in_pts, float *in_stds, float *out); - -#endif diff --git a/selfdrive/visiond/models/monitoring.cc b/selfdrive/visiond/models/monitoring.cc deleted file mode 100644 index f6e47880fd5944..00000000000000 --- a/selfdrive/visiond/models/monitoring.cc +++ /dev/null @@ -1,55 +0,0 @@ -#include -#include "monitoring.h" -#include "common/mat.h" - -#define MODEL_WIDTH 320 -#define MODEL_HEIGHT 160 - -void monitoring_init(MonitoringState* s, cl_device_id device_id, cl_context context) { - model_input_init(&s->in, MODEL_WIDTH, MODEL_HEIGHT, device_id, context); - s->m = new SNPEModel("../../models/monitoring_model.dlc", (float*)&s->output, OUTPUT_SIZE); -} - -MonitoringResult monitoring_eval_frame(MonitoringState* s, cl_command_queue q, - cl_mem yuv_cl, int width, int height) { - const mat3 front_frame_from_scaled_frame = (mat3){{ - width/426.0f, 0.0, 0.0, - 0.0,height/320.0f, 0.0, - 0.0, 0.0, 1.0, - }}; - - const mat3 scaled_frame_from_cropped_frame = (mat3){{ - 1.0, 0.0, 426.0-160.0, - 0.0, 1.0, 0.0, - 0.0, 0.0, 1.0, - }}; - - const mat3 transpose = (mat3){{ - 0.0, 1.0, 0.0, - 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, - }}; - - const mat3 front_frame_from_cropped_frame = matmul3(front_frame_from_scaled_frame, scaled_frame_from_cropped_frame); - const mat3 front_frame_from_monitoring_frame = matmul3(front_frame_from_cropped_frame, transpose); - - float *net_input_buf = model_input_prepare(&s->in, q, yuv_cl, width, height, front_frame_from_monitoring_frame); - s->m->execute(net_input_buf); - - MonitoringResult ret = {0}; - memcpy(&ret.face_orientation, &s->output[0], sizeof ret.face_orientation); - memcpy(&ret.face_position, &s->output[3], sizeof ret.face_position); - memcpy(&ret.face_prob, &s->output[12], sizeof ret.face_prob); - memcpy(&ret.left_eye_prob, &s->output[21], sizeof ret.left_eye_prob); - memcpy(&ret.right_eye_prob, &s->output[30], sizeof ret.right_eye_prob); - memcpy(&ret.left_blink_prob, &s->output[31], sizeof ret.right_eye_prob); - memcpy(&ret.right_blink_prob, &s->output[32], sizeof ret.right_eye_prob); - return ret; -} - - -void monitoring_free(MonitoringState* s) { - model_input_free(&s->in); - delete s->m; -} - diff --git a/selfdrive/visiond/models/monitoring.h b/selfdrive/visiond/models/monitoring.h deleted file mode 100644 index 2be96825f876b4..00000000000000 --- a/selfdrive/visiond/models/monitoring.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef MONITORING_H -#define MONITORING_H - -#include "commonmodel.h" -#include "runners/run.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define OUTPUT_SIZE_DEPRECATED 8 -#define OUTPUT_SIZE 33 - -typedef struct MonitoringResult { - float descriptor_DEPRECATED[OUTPUT_SIZE_DEPRECATED - 1]; - float std_DEPRECATED; - - float face_orientation[3]; - float face_position[2]; - float face_prob; - float left_eye_prob; - float right_eye_prob; - float left_blink_prob; - float right_blink_prob; -} MonitoringResult; - -typedef struct MonitoringState { - ModelInput in; - RunModel *m; - float output[OUTPUT_SIZE]; -} MonitoringState; - -void monitoring_init(MonitoringState* s, cl_device_id device_id, cl_context context); -MonitoringResult monitoring_eval_frame(MonitoringState* s, cl_command_queue q, cl_mem yuv_cl, int width, int height); -void monitoring_free(MonitoringState* s); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/selfdrive/visiond/models/posenet.cc b/selfdrive/visiond/models/posenet.cc deleted file mode 100644 index d1c8d805441d54..00000000000000 --- a/selfdrive/visiond/models/posenet.cc +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include -#include "posenet.h" - -void posenet_init(PosenetState *s) { - s->input = (float*)malloc(2*200*532*sizeof(float)); - s->m = new DefaultRunModel("../../models/posenet.dlc", s->output, sizeof(s->output)/sizeof(float)); -} - -void posenet_push(PosenetState *s, uint8_t *yuv_ptr_y, int yuv_width) { - // move second frame to first frame - memmove(&s->input[0], &s->input[1], sizeof(float)*(200*532*2 - 1)); - - // fill posenet input - float a; - // posenet uses a half resolution cropped frame - // with upper left corner: [50, 237] and - // bottom right corner: [1114, 637] - // So the resulting crop is 532 X 200 - for (int y=237; y<637; y+=2) { - int yy = (y-237)/2; - for (int x = 50; x < 1114; x+=2) { - int xx = (x-50)/2; - a = 0; - a += yuv_ptr_y[yuv_width*(y+0) + (x+1)]; - a += yuv_ptr_y[yuv_width*(y+1) + (x+1)]; - a += yuv_ptr_y[yuv_width*(y+0) + (x+0)]; - a += yuv_ptr_y[yuv_width*(y+1) + (x+0)]; - // The posenet takes a normalized image input - // like the driving model so [0,255] is remapped - // to [-1,1] - s->input[(yy*532+xx)*2 + 1] = (a/512.0 - 1.0); - } - } -} - -void posenet_eval(PosenetState *s) { - s->m->execute(s->input); - - // fix stddevs - for (int i = 6; i < 12; i++) { - s->output[i] = log1p(exp(s->output[i])) + 1e-6; - } - // to radians - for (int i = 3; i < 6; i++) { - s->output[i] = M_PI * s->output[i] / 180.0; - } - // to radians - for (int i = 9; i < 12; i++) { - s->output[i] = M_PI * s->output[i] / 180.0; - } -} - -void posenet_free(PosenetState *s) { - delete s->m; - free(s->input); -} - diff --git a/selfdrive/visiond/models/posenet.h b/selfdrive/visiond/models/posenet.h deleted file mode 100644 index 2e6571a1d4b7e0..00000000000000 --- a/selfdrive/visiond/models/posenet.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef POSENET_H -#define POSENET_H - -#include -#include "runners/run.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct PosenetState { - float output[12]; - float *input; - RunModel *m; -} PosenetState; - -void posenet_init(PosenetState *s); -void posenet_push(PosenetState *s, uint8_t *yuv_ptr_y, int yuv_width); -void posenet_eval(PosenetState *s); -void posenet_free(PosenetState *s); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/selfdrive/visiond/runners/run.h b/selfdrive/visiond/runners/run.h deleted file mode 100644 index 049f06584509ee..00000000000000 --- a/selfdrive/visiond/runners/run.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef RUN_H -#define RUN_H - -#include "runmodel.h" -#include "snpemodel.h" - -#ifdef QCOM - #define DefaultRunModel SNPEModel -#else -#define DefaultRunModel SNPEModel - /* #include "tfmodel.h" */ - /* #define DefaultRunModel TFModel */ -#endif - -#endif diff --git a/selfdrive/visiond/runners/runmodel.h b/selfdrive/visiond/runners/runmodel.h deleted file mode 100644 index 245f4c8df2f953..00000000000000 --- a/selfdrive/visiond/runners/runmodel.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef RUNMODEL_H -#define RUNMODEL_H - -class RunModel { -public: - virtual void addRecurrent(float *state, int state_size) {} - virtual void execute(float *net_input_buf) {} -}; - -#endif - diff --git a/selfdrive/visiond/runners/snpemodel.cc b/selfdrive/visiond/runners/snpemodel.cc deleted file mode 100644 index 15b3bcc3178d54..00000000000000 --- a/selfdrive/visiond/runners/snpemodel.cc +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include -#include "common/util.h" -#include "snpemodel.h" - -void PrintErrorStringAndExit() { - const char* const errStr = zdl::DlSystem::getLastErrorString(); - std::cerr << zdl::DlSystem::getLastErrorString() << std::endl; - std::exit(EXIT_FAILURE); -} - -SNPEModel::SNPEModel(const char *path, float *output, size_t output_size) { -#ifdef QCOM - assert(zdl::SNPE::SNPEFactory::isRuntimeAvailable(zdl::DlSystem::Runtime_t::GPU)); -#endif - size_t model_size; - model_data = (uint8_t *)read_file(path, &model_size); - assert(model_data); - - // load model - std::unique_ptr container = zdl::DlContainer::IDlContainer::open(model_data, model_size); - if (!container) { PrintErrorStringAndExit(); } - printf("loaded model with size: %u\n", model_size); - - // create model runner - zdl::SNPE::SNPEBuilder snpeBuilder(container.get()); - while (!snpe) { -#ifdef QCOM - snpe = snpeBuilder.setOutputLayers({}) - .setRuntimeProcessor(zdl::DlSystem::Runtime_t::GPU) - .setUseUserSuppliedBuffers(true) - .setPerformanceProfile(zdl::DlSystem::PerformanceProfile_t::HIGH_PERFORMANCE) - .build(); -#else - snpe = snpeBuilder.setOutputLayers({}) - .setUseUserSuppliedBuffers(true) - .setPerformanceProfile(zdl::DlSystem::PerformanceProfile_t::HIGH_PERFORMANCE) - .build(); -#endif - if (!snpe) std::cerr << zdl::DlSystem::getLastErrorString() << std::endl; - } - - // get input and output names - const auto &strListi_opt = snpe->getInputTensorNames(); - if (!strListi_opt) throw std::runtime_error("Error obtaining Input tensor names"); - const auto &strListi = *strListi_opt; - //assert(strListi.size() == 1); - const char *input_tensor_name = strListi.at(0); - - const auto &strListo_opt = snpe->getOutputTensorNames(); - if (!strListo_opt) throw std::runtime_error("Error obtaining Output tensor names"); - const auto &strListo = *strListo_opt; - assert(strListo.size() == 1); - const char *output_tensor_name = strListo.at(0); - - printf("model: %s -> %s\n", input_tensor_name, output_tensor_name); - - zdl::DlSystem::UserBufferEncodingFloat userBufferEncodingFloat; - zdl::DlSystem::IUserBufferFactory& ubFactory = zdl::SNPE::SNPEFactory::getUserBufferFactory(); - - // create input buffer - { - const auto &inputDims_opt = snpe->getInputDimensions(input_tensor_name); - const zdl::DlSystem::TensorShape& bufferShape = *inputDims_opt; - std::vector strides(bufferShape.rank()); - strides[strides.size() - 1] = sizeof(float); - size_t product = 1; - for (size_t i = 0; i < bufferShape.rank(); i++) product *= bufferShape[i]; - size_t stride = strides[strides.size() - 1]; - for (size_t i = bufferShape.rank() - 1; i > 0; i--) { - stride *= bufferShape[i]; - strides[i-1] = stride; - } - printf("input product is %u\n", product); - inputBuffer = ubFactory.createUserBuffer(NULL, product*sizeof(float), strides, &userBufferEncodingFloat); - - inputMap.add(input_tensor_name, inputBuffer.get()); - } - - // create output buffer - { - std::vector outputStrides = {output_size * sizeof(float), sizeof(float)}; - outputBuffer = ubFactory.createUserBuffer(output, output_size * sizeof(float), outputStrides, &userBufferEncodingFloat); - outputMap.add(output_tensor_name, outputBuffer.get()); - } -} - -void SNPEModel::addRecurrent(float *state, int state_size) { - // get input and output names - const auto &strListi_opt = snpe->getInputTensorNames(); - if (!strListi_opt) throw std::runtime_error("Error obtaining Input tensor names"); - const auto &strListi = *strListi_opt; - const char *input_tensor_name = strListi.at(1); - printf("adding recurrent: %s\n", input_tensor_name); - - zdl::DlSystem::UserBufferEncodingFloat userBufferEncodingFloat; - zdl::DlSystem::IUserBufferFactory& ubFactory = zdl::SNPE::SNPEFactory::getUserBufferFactory(); - std::vector recurrentStrides = {state_size * sizeof(float), sizeof(float)}; - recurrentBuffer = ubFactory.createUserBuffer(state, state_size * sizeof(float), recurrentStrides, &userBufferEncodingFloat); - inputMap.add(input_tensor_name, recurrentBuffer.get()); -} - -void SNPEModel::execute(float *net_input_buf) { - assert(inputBuffer->setBufferAddress(net_input_buf)); - if (!snpe->execute(inputMap, outputMap)) { - PrintErrorStringAndExit(); - } -} - diff --git a/selfdrive/visiond/runners/snpemodel.h b/selfdrive/visiond/runners/snpemodel.h deleted file mode 100644 index 0a6e030f47b4b3..00000000000000 --- a/selfdrive/visiond/runners/snpemodel.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef SNPEMODEL_H -#define SNPEMODEL_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "runmodel.h" - -class SNPEModel : public RunModel { -public: - SNPEModel(const char *path, float *output, size_t output_size); - ~SNPEModel() { - if (model_data) free(model_data); - } - void addRecurrent(float *state, int state_size); - void execute(float *net_input_buf); -private: - uint8_t *model_data = NULL; - - // snpe model stuff - std::unique_ptr snpe; - - // snpe input stuff - zdl::DlSystem::UserBufferMap inputMap; - std::unique_ptr inputBuffer; - - // snpe output stuff - zdl::DlSystem::UserBufferMap outputMap; - std::unique_ptr outputBuffer; - float *output; - - // recurrent - std::unique_ptr recurrentBuffer; -}; - -#endif - diff --git a/selfdrive/visiond/transforms/loadyuv.c b/selfdrive/visiond/transforms/loadyuv.c deleted file mode 100644 index 2518145100a827..00000000000000 --- a/selfdrive/visiond/transforms/loadyuv.c +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include - -#include "clutil.h" - -#include "loadyuv.h" - -void loadyuv_init(LoadYUVState* s, cl_context ctx, cl_device_id device_id, int width, int height) { - int err = 0; - memset(s, 0, sizeof(*s)); - - s->width = width; - s->height = height; - - char args[1024]; - snprintf(args, sizeof(args), - "-cl-fast-relaxed-math -cl-denorms-are-zero " - "-DTRANSFORMED_WIDTH=%d -DTRANSFORMED_HEIGHT=%d", - width, height); - cl_program prg = CLU_LOAD_FROM_FILE(ctx, device_id, "transforms/loadyuv.cl", args); - - s->loadys_krnl = clCreateKernel(prg, "loadys", &err); - assert(err == 0); - s->loaduv_krnl = clCreateKernel(prg, "loaduv", &err); - assert(err == 0); - - // done with this - err = clReleaseProgram(prg); - assert(err == 0); -} - -void loadyuv_destroy(LoadYUVState* s) { - int err = 0; - - err = clReleaseKernel(s->loadys_krnl); - assert(err == 0); - err = clReleaseKernel(s->loaduv_krnl); - assert(err == 0); -} - -void loadyuv_queue(LoadYUVState* s, cl_command_queue q, - cl_mem y_cl, cl_mem u_cl, cl_mem v_cl, - cl_mem out_cl) { - int err = 0; - - err = clSetKernelArg(s->loadys_krnl, 0, sizeof(cl_mem), &y_cl); - assert(err == 0); - err = clSetKernelArg(s->loadys_krnl, 1, sizeof(cl_mem), &out_cl); - assert(err == 0); - - const size_t loadys_work_size = (s->width*s->height)/8; - err = clEnqueueNDRangeKernel(q, s->loadys_krnl, 1, NULL, - &loadys_work_size, NULL, 0, 0, NULL); - assert(err == 0); - - const size_t loaduv_work_size = ((s->width/2)*(s->height/2))/8; - cl_int loaduv_out_off = (s->width*s->height); - - err = clSetKernelArg(s->loaduv_krnl, 0, sizeof(cl_mem), &u_cl); - assert(err == 0); - err = clSetKernelArg(s->loaduv_krnl, 1, sizeof(cl_mem), &out_cl); - assert(err == 0); - err = clSetKernelArg(s->loaduv_krnl, 2, sizeof(cl_int), &loaduv_out_off); - assert(err == 0); - - err = clEnqueueNDRangeKernel(q, s->loaduv_krnl, 1, NULL, - &loaduv_work_size, NULL, 0, 0, NULL); - assert(err == 0); - - loaduv_out_off += (s->width/2)*(s->height/2); - - err = clSetKernelArg(s->loaduv_krnl, 0, sizeof(cl_mem), &v_cl); - assert(err == 0); - err = clSetKernelArg(s->loaduv_krnl, 1, sizeof(cl_mem), &out_cl); - assert(err == 0); - err = clSetKernelArg(s->loaduv_krnl, 2, sizeof(cl_int), &loaduv_out_off); - assert(err == 0); - - err = clEnqueueNDRangeKernel(q, s->loaduv_krnl, 1, NULL, - &loaduv_work_size, NULL, 0, 0, NULL); - assert(err == 0); -} diff --git a/selfdrive/visiond/transforms/loadyuv.h b/selfdrive/visiond/transforms/loadyuv.h deleted file mode 100644 index be7ea21282af3c..00000000000000 --- a/selfdrive/visiond/transforms/loadyuv.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef LOADYUV_H -#define LOADYUV_H - -#include -#include - -#ifdef __APPLE__ -#include -#else -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - int width, height; - cl_kernel loadys_krnl, loaduv_krnl; -} LoadYUVState; - -void loadyuv_init(LoadYUVState* s, cl_context ctx, cl_device_id device_id, int width, int height); - -void loadyuv_destroy(LoadYUVState* s); - -void loadyuv_queue(LoadYUVState* s, cl_command_queue q, - cl_mem y_cl, cl_mem u_cl, cl_mem v_cl, - cl_mem out_cl); - -#ifdef __cplusplus -} -#endif - -#endif // LOADYUV_H diff --git a/selfdrive/visiond/transforms/rgb_to_yuv.c b/selfdrive/visiond/transforms/rgb_to_yuv.c deleted file mode 100644 index 2626e6eebe765f..00000000000000 --- a/selfdrive/visiond/transforms/rgb_to_yuv.c +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include - -#include "clutil.h" - -#include "rgb_to_yuv.h" - -void rgb_to_yuv_init(RGBToYUVState* s, cl_context ctx, cl_device_id device_id, int width, int height, int rgb_stride) { - int err = 0; - memset(s, 0, sizeof(*s)); - assert(width % 2 == 0); - assert(height % 2 == 0); - s->width = width; - s->height = height; - char args[1024]; - snprintf(args, sizeof(args), - "-cl-fast-relaxed-math -cl-denorms-are-zero " -#ifdef CL_DEBUG - "-DCL_DEBUG " -#endif - "-DWIDTH=%d -DHEIGHT=%d -DUV_WIDTH=%d -DUV_HEIGHT=%d -DRGB_STRIDE=%d -DRGB_SIZE=%d", - width, height, width/ 2, height / 2, rgb_stride, width * height); - cl_program prg = CLU_LOAD_FROM_FILE(ctx, device_id, "transforms/rgb_to_yuv.cl", args); - - s->rgb_to_yuv_krnl = clCreateKernel(prg, "rgb_to_yuv", &err); - assert(err == 0); - // done with this - err = clReleaseProgram(prg); - assert(err == 0); -} - -void rgb_to_yuv_destroy(RGBToYUVState* s) { - int err = 0; - err = clReleaseKernel(s->rgb_to_yuv_krnl); - assert(err == 0); -} - -void rgb_to_yuv_queue(RGBToYUVState* s, cl_command_queue q, cl_mem rgb_cl, cl_mem yuv_cl) { - int err = 0; - err = clSetKernelArg(s->rgb_to_yuv_krnl, 0, sizeof(cl_mem), &rgb_cl); - assert(err == 0); - err = clSetKernelArg(s->rgb_to_yuv_krnl, 1, sizeof(cl_mem), &yuv_cl); - assert(err == 0); - const size_t work_size[2] = { - (size_t)(s->width + (s->width % 4 == 0 ? 0 : (4 - s->width % 4))) / 4, - (size_t)(s->height + (s->height % 4 == 0 ? 0 : (4 - s->height % 4))) / 4 - }; - cl_event event; - err = clEnqueueNDRangeKernel(q, s->rgb_to_yuv_krnl, 2, NULL, &work_size[0], NULL, 0, 0, &event); - assert(err == 0); - clWaitForEvents(1, &event); - clReleaseEvent(event); -} diff --git a/selfdrive/visiond/transforms/transform.c b/selfdrive/visiond/transforms/transform.c deleted file mode 100644 index 0b4150ddb27268..00000000000000 --- a/selfdrive/visiond/transforms/transform.c +++ /dev/null @@ -1,149 +0,0 @@ -#include -#include - -#include "clutil.h" - -#include "transform.h" - -void transform_init(Transform* s, cl_context ctx, cl_device_id device_id) { - int err = 0; - memset(s, 0, sizeof(*s)); - - cl_program prg = CLU_LOAD_FROM_FILE(ctx, device_id, "transforms/transform.cl", ""); - - s->krnl = clCreateKernel(prg, "warpPerspective", &err); - assert(err == 0); - - // done with this - err = clReleaseProgram(prg); - assert(err == 0); - - s->m_y_cl = clCreateBuffer(ctx, CL_MEM_READ_WRITE, 3*3*sizeof(float), NULL, &err); - assert(err == 0); - - s->m_uv_cl = clCreateBuffer(ctx, CL_MEM_READ_WRITE, 3*3*sizeof(float), NULL, &err); - assert(err == 0); -} - -void transform_destroy(Transform* s) { - int err = 0; - - err = clReleaseMemObject(s->m_y_cl); - assert(err == 0); - err = clReleaseMemObject(s->m_uv_cl); - assert(err == 0); - - err = clReleaseKernel(s->krnl); - assert(err == 0); -} - -void transform_queue(Transform* s, - cl_command_queue q, - cl_mem in_yuv, int in_width, int in_height, - cl_mem out_y, cl_mem out_u, cl_mem out_v, - int out_width, int out_height, - mat3 projection) { - int err = 0; - const int zero = 0; - - // sampled using pixel center origin - // (because thats how fastcv and opencv does it) - - mat3 projection_y = projection; - - // in and out uv is half the size of y. - mat3 projection_uv = transform_scale_buffer(projection, 0.5); - - err = clEnqueueWriteBuffer(q, s->m_y_cl, CL_TRUE, 0, 3*3*sizeof(float), (void*)projection_y.v, 0, NULL, NULL); - assert(err == 0); - err = clEnqueueWriteBuffer(q, s->m_uv_cl, CL_TRUE, 0, 3*3*sizeof(float), (void*)projection_uv.v, 0, NULL, NULL); - assert(err == 0); - - const int in_y_width = in_width; - const int in_y_height = in_height; - const int in_uv_width = in_width/2; - const int in_uv_height = in_height/2; - const int in_y_offset = 0; - const int in_u_offset = in_y_offset + in_y_width*in_y_height; - const int in_v_offset = in_u_offset + in_uv_width*in_uv_height; - - const int out_y_width = out_width; - const int out_y_height = out_height; - const int out_uv_width = out_width/2; - const int out_uv_height = out_height/2; - - err = clSetKernelArg(s->krnl, 0, sizeof(cl_mem), &in_yuv); - assert(err == 0); - - err = clSetKernelArg(s->krnl, 1, sizeof(cl_int), &in_y_width); - assert(err == 0); - err = clSetKernelArg(s->krnl, 2, sizeof(cl_int), &in_y_offset); - assert(err == 0); - err = clSetKernelArg(s->krnl, 3, sizeof(cl_int), &in_y_height); - assert(err == 0); - err = clSetKernelArg(s->krnl, 4, sizeof(cl_int), &in_y_width); - assert(err == 0); - - err = clSetKernelArg(s->krnl, 5, sizeof(cl_mem), &out_y); - assert(err == 0); - - err = clSetKernelArg(s->krnl, 6, sizeof(cl_int), &out_y_width); - assert(err == 0); - err = clSetKernelArg(s->krnl, 7, sizeof(cl_int), &zero); - assert(err == 0); - err = clSetKernelArg(s->krnl, 8, sizeof(cl_int), &out_y_height); - assert(err == 0); - err = clSetKernelArg(s->krnl, 9, sizeof(cl_int), &out_y_width); - assert(err == 0); - - err = clSetKernelArg(s->krnl, 10, sizeof(cl_mem), &s->m_y_cl); - assert(err == 0); - - const size_t work_size_y[2] = {out_y_width, out_y_height}; - - err = clEnqueueNDRangeKernel(q, s->krnl, 2, NULL, - (const size_t*)&work_size_y, NULL, 0, 0, NULL); - assert(err == 0); - - - const size_t work_size_uv[2] = {out_uv_width, out_uv_height}; - - err = clSetKernelArg(s->krnl, 1, sizeof(cl_int), &in_uv_width); - assert(err == 0); - err = clSetKernelArg(s->krnl, 2, sizeof(cl_int), &in_u_offset); - assert(err == 0); - err = clSetKernelArg(s->krnl, 3, sizeof(cl_int), &in_uv_height); - assert(err == 0); - err = clSetKernelArg(s->krnl, 4, sizeof(cl_int), &in_uv_width); - assert(err == 0); - - err = clSetKernelArg(s->krnl, 5, sizeof(cl_mem), &out_u); - assert(err == 0); - - err = clSetKernelArg(s->krnl, 6, sizeof(cl_int), &out_uv_width); - assert(err == 0); - err = clSetKernelArg(s->krnl, 7, sizeof(cl_int), &zero); - assert(err == 0); - err = clSetKernelArg(s->krnl, 8, sizeof(cl_int), &out_uv_height); - assert(err == 0); - err = clSetKernelArg(s->krnl, 9, sizeof(cl_int), &out_uv_width); - assert(err == 0); - - err = clSetKernelArg(s->krnl, 10, sizeof(cl_mem), &s->m_uv_cl); - assert(err == 0); - - err = clEnqueueNDRangeKernel(q, s->krnl, 2, NULL, - (const size_t*)&work_size_uv, NULL, 0, 0, NULL); - assert(err == 0); - - - err = clSetKernelArg(s->krnl, 2, sizeof(cl_int), &in_v_offset); - assert(err == 0); - err = clSetKernelArg(s->krnl, 5, sizeof(cl_mem), &out_v); - assert(err == 0); - - - err = clEnqueueNDRangeKernel(q, s->krnl, 2, NULL, - (const size_t*)&work_size_uv, NULL, 0, 0, NULL); - assert(err == 0); -} diff --git a/selfdrive/visiond/visiond.cc b/selfdrive/visiond/visiond.cc deleted file mode 100644 index a0cce70ab8da0d..00000000000000 --- a/selfdrive/visiond/visiond.cc +++ /dev/null @@ -1,1455 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifdef __APPLE__ -#include -#else -#include -#endif - -#include -#include -#include -#include - -#ifdef QCOM -#include -#else -#include -#endif - -#include "common/version.h" -#include "common/util.h" -#include "common/timing.h" -#include "common/mat.h" -#include "common/swaglog.h" -#include "common/visionipc.h" -#include "common/visionbuf.h" -#include "common/visionimg.h" -#include "common/buffering.h" - -#include "clutil.h" -#include "bufs.h" - -#ifdef QCOM -#include "cameras/camera_qcom.h" -#else -#include "cameras/camera_frame_stream.h" -#endif - - -// 3 models -#include "models/driving.h" -#include "models/monitoring.h" -#include "models/posenet.h" - -#include "transforms/rgb_to_yuv.h" - -#include "cereal/gen/cpp/log.capnp.h" - -#define M_PI 3.14159265358979323846 - -#define UI_BUF_COUNT 4 - -// #define DUMP_RGB - -//#define DEBUG_DRIVER_MONITOR - -// send net input on port 9000 -//#define SEND_NET_INPUT - -#define YUV_COUNT 40 -#define MAX_CLIENTS 5 - -#ifdef __APPLE__ -typedef void (*sighandler_t) (int); -#endif - -extern "C" { -volatile int do_exit = 0; -} - -namespace { - -struct VisionState; - -struct VisionClientState { - VisionState *s; - int fd; - pthread_t thread_handle; - bool running; -}; - -struct VisionClientStreamState { - bool subscribed; - int bufs_outstanding; - bool tb; - TBuffer* tbuffer; - PoolQueue* queue; -}; - -struct VisionState { - - int frame_width, frame_height; - int frame_stride; - int frame_size; - - int ion_fd; - - // cl state - cl_device_id device_id; - cl_context context; - - cl_program prg_debayer_rear; - cl_program prg_debayer_front; - cl_kernel krnl_debayer_rear; - cl_kernel krnl_debayer_front; - - // processing - TBuffer ui_tb; - TBuffer ui_front_tb; - - mat3 yuv_transform; - TBuffer *yuv_tb; - - // TODO: refactor for both cameras? - Pool yuv_pool; - VisionBuf yuv_ion[YUV_COUNT]; - cl_mem yuv_cl[YUV_COUNT]; - YUVBuf yuv_bufs[YUV_COUNT]; - FrameMetadata yuv_metas[YUV_COUNT]; - size_t yuv_buf_size; - int yuv_width, yuv_height; - RGBToYUVState rgb_to_yuv_state; - - // for front camera recording - Pool yuv_front_pool; - VisionBuf yuv_front_ion[YUV_COUNT]; - cl_mem yuv_front_cl[YUV_COUNT]; - YUVBuf yuv_front_bufs[YUV_COUNT]; - FrameMetadata yuv_front_metas[YUV_COUNT]; - size_t yuv_front_buf_size; - int yuv_front_width, yuv_front_height; - RGBToYUVState front_rgb_to_yuv_state; - - size_t rgb_buf_size; - int rgb_width, rgb_height, rgb_stride; - VisionBuf rgb_bufs[UI_BUF_COUNT]; - cl_mem rgb_bufs_cl[UI_BUF_COUNT]; - - size_t rgb_front_buf_size; - int rgb_front_width, rgb_front_height, rgb_front_stride; - VisionBuf rgb_front_bufs[UI_BUF_COUNT]; - cl_mem rgb_front_bufs_cl[UI_BUF_COUNT]; - - ModelState model; - ModelData model_bufs[UI_BUF_COUNT]; - - MonitoringState monitoring; - zsock_t *monitoring_sock; - void* monitoring_sock_raw; - - PosenetState posenet; - - // Protected by transform_lock. - bool run_model; - mat3 cur_transform; - pthread_mutex_t transform_lock; - - cl_mem camera_bufs_cl[FRAME_BUF_COUNT]; - VisionBuf camera_bufs[FRAME_BUF_COUNT]; - VisionBuf focus_bufs[FRAME_BUF_COUNT]; - VisionBuf stats_bufs[FRAME_BUF_COUNT]; - - cl_mem front_camera_bufs_cl[FRAME_BUF_COUNT]; - VisionBuf front_camera_bufs[FRAME_BUF_COUNT]; - - DualCameraState cameras; - - zsock_t *terminate_pub; - zsock_t *recorder_sock; - void* recorder_sock_raw; - - zsock_t *posenet_sock; - void* posenet_sock_raw; - - zsock_t *thumbnail_sock; - void* thumbnail_sock_raw; - - pthread_mutex_t clients_lock; - VisionClientState clients[MAX_CLIENTS]; - -}; - -void hexdump(uint8_t *d, int l) { - for (int i = 0; i < l; i++) { - if (i%0x10 == 0 && i != 0) printf("\n"); - printf("%02X ", d[i]); - } - printf("\n"); -} - -int mkpath(char* file_path, mode_t mode) { - assert(file_path && *file_path); - char* p; - for (p=strchr(file_path+1, '/'); p; p=strchr(p+1, '/')) { - *p='\0'; - if (mkdir(file_path, mode)==-1) { - if (errno!=EEXIST) { *p='/'; return -1; } - } - *p='/'; - } - return 0; -} - -////////// cl stuff - -cl_program build_debayer_program(VisionState *s, - int frame_width, int frame_height, int frame_stride, - int rgb_width, int rgb_height, int rgb_stride, - int bayer_flip, int hdr) { - assert(rgb_width == frame_width/2); - assert(rgb_height == frame_height/2); - - char args[4096]; - snprintf(args, sizeof(args), - "-cl-fast-relaxed-math -cl-denorms-are-zero " - "-DFRAME_WIDTH=%d -DFRAME_HEIGHT=%d -DFRAME_STRIDE=%d " - "-DRGB_WIDTH=%d -DRGB_HEIGHT=%d -DRGB_STRIDE=%d " - "-DBAYER_FLIP=%d -DHDR=%d", - frame_width, frame_height, frame_stride, - rgb_width, rgb_height, rgb_stride, - bayer_flip, hdr); - return CLU_LOAD_FROM_FILE(s->context, s->device_id, "cameras/debayer.cl", args); -} - -void cl_init(VisionState *s) { - int err; - cl_platform_id platform_id = NULL; - cl_uint num_devices; - cl_uint num_platforms; - - err = clGetPlatformIDs(1, &platform_id, &num_platforms); - assert(err == 0); - err = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_DEFAULT, 1, - &s->device_id, &num_devices); - assert(err == 0); - - cl_print_info(platform_id, s->device_id); - printf("\n"); - - s->context = clCreateContext(NULL, 1, &s->device_id, NULL, NULL, &err); - assert(err == 0); -} - -void cl_free(VisionState *s) { - int err; - - err = clReleaseContext(s->context); - assert(err == 0); -} - -void init_buffers(VisionState *s) { - int err; - - // allocate camera buffers - - for (int i=0; icamera_bufs[i] = visionbuf_allocate_cl(s->frame_size, s->device_id, s->context, - &s->camera_bufs_cl[i]); - // TODO: make lengths correct - s->focus_bufs[i] = visionbuf_allocate(0xb80); - s->stats_bufs[i] = visionbuf_allocate(0xb80); - } - - for (int i=0; ifront_camera_bufs[i] = visionbuf_allocate_cl(s->cameras.front.frame_size, - s->device_id, s->context, - &s->front_camera_bufs_cl[i]); - } - - // processing buffers - if (s->cameras.rear.ci.bayer) { - s->rgb_width = s->frame_width/2; - s->rgb_height = s->frame_height/2; - } else { - s->rgb_width = s->frame_width; - s->rgb_height = s->frame_height; - } - - for (int i=0; irgb_width, s->rgb_height, &s->rgb_bufs[i]); - s->rgb_bufs_cl[i] = visionbuf_to_cl(&s->rgb_bufs[i], s->device_id, s->context); - if (i == 0){ - s->rgb_stride = img.stride; - s->rgb_buf_size = img.size; - } - } - tbuffer_init(&s->ui_tb, UI_BUF_COUNT, "rgb"); - - //assert(s->cameras.front.ci.bayer); - s->rgb_front_width = s->cameras.front.ci.frame_width/2; - s->rgb_front_height = s->cameras.front.ci.frame_height/2; - - for (int i=0; irgb_front_width, s->rgb_front_height, &s->rgb_front_bufs[i]); - s->rgb_front_bufs_cl[i] = visionbuf_to_cl(&s->rgb_front_bufs[i], s->device_id, s->context); - if (i == 0){ - s->rgb_front_stride = img.stride; - s->rgb_front_buf_size = img.size; - } - } - tbuffer_init(&s->ui_front_tb, UI_BUF_COUNT, "frontrgb"); - - // yuv back for recording and orbd - pool_init(&s->yuv_pool, YUV_COUNT); - - s->yuv_tb = pool_get_tbuffer(&s->yuv_pool); //only for visionserver... - - s->yuv_width = s->rgb_width; - s->yuv_height = s->rgb_height; - s->yuv_buf_size = s->rgb_width * s->rgb_height * 3 / 2; - - for (int i=0; iyuv_ion[i] = visionbuf_allocate_cl(s->yuv_buf_size, s->device_id, s->context, &s->yuv_cl[i]); - s->yuv_bufs[i].y = (uint8_t*)s->yuv_ion[i].addr; - s->yuv_bufs[i].u = s->yuv_bufs[i].y + (s->yuv_width * s->yuv_height); - s->yuv_bufs[i].v = s->yuv_bufs[i].u + (s->yuv_width/2 * s->yuv_height/2); - } - - // yuv front for recording - pool_init(&s->yuv_front_pool, YUV_COUNT); - - s->yuv_front_width = s->rgb_front_width; - s->yuv_front_height = s->rgb_front_height; - s->yuv_front_buf_size = s->rgb_front_width * s->rgb_front_height * 3 / 2; - - for (int i=0; iyuv_front_ion[i] = visionbuf_allocate_cl(s->yuv_front_buf_size, s->device_id, s->context, &s->yuv_front_cl[i]); - s->yuv_front_bufs[i].y = (uint8_t*)s->yuv_front_ion[i].addr; - s->yuv_front_bufs[i].u = s->yuv_front_bufs[i].y + (s->yuv_front_width * s->yuv_front_height); - s->yuv_front_bufs[i].v = s->yuv_front_bufs[i].u + (s->yuv_front_width/2 * s->yuv_front_height/2); - } - - if (s->cameras.rear.ci.bayer) { - // debayering does a 2x downscale - s->yuv_transform = transform_scale_buffer(s->cameras.rear.transform, 0.5); - } else { - s->yuv_transform = s->cameras.rear.transform; - } - - if (s->cameras.rear.ci.bayer) { - s->prg_debayer_rear = build_debayer_program(s, s->cameras.rear.ci.frame_width, s->cameras.rear.ci.frame_height, - s->cameras.rear.ci.frame_stride, - s->rgb_width, s->rgb_height, s->rgb_stride, - s->cameras.rear.ci.bayer_flip, s->cameras.rear.ci.hdr); - s->krnl_debayer_rear = clCreateKernel(s->prg_debayer_rear, "debayer10", &err); - assert(err == 0); - } - - if (s->cameras.front.ci.bayer) { - s->prg_debayer_front = build_debayer_program(s, s->cameras.front.ci.frame_width, s->cameras.front.ci.frame_height, - s->cameras.front.ci.frame_stride, - s->rgb_front_width, s->rgb_front_height, s->rgb_front_stride, - s->cameras.front.ci.bayer_flip, s->cameras.front.ci.hdr); - - s->krnl_debayer_front = clCreateKernel(s->prg_debayer_front, "debayer10", &err); - assert(err == 0); - } - - rgb_to_yuv_init(&s->rgb_to_yuv_state, s->context, s->device_id, s->yuv_width, s->yuv_height, s->rgb_stride); - rgb_to_yuv_init(&s->front_rgb_to_yuv_state, s->context, s->device_id, s->yuv_front_width, s->yuv_front_height, s->rgb_front_stride); -} - -void free_buffers(VisionState *s) { - // free bufs - for (int i=0; icamera_bufs[i]); - visionbuf_free(&s->focus_bufs[i]); - visionbuf_free(&s->stats_bufs[i]); - } - - for (int i=0; ifront_camera_bufs[i]); - } - - for (int i=0; irgb_bufs[i]); - } - - for (int i=0; irgb_front_bufs[i]); - } - - for (int i=0; iyuv_ion[i]); - } -} - -void* visionserver_client_thread(void* arg) { - int err; - VisionClientState *client = (VisionClientState*)arg; - VisionState *s = client->s; - int fd = client->fd; - - set_thread_name("clientthread"); - - zsock_t *terminate = zsock_new_sub(">inproc://terminate", ""); - assert(terminate); - void* terminate_raw = zsock_resolve(terminate); - - VisionClientStreamState streams[VISION_STREAM_MAX] = {{0}}; - - LOG("client start fd %d\n", fd); - - while (true) { - zmq_pollitem_t polls[2+VISION_STREAM_MAX] = {{0}}; - polls[0].socket = terminate_raw; - polls[0].events = ZMQ_POLLIN; - polls[1].fd = fd; - polls[1].events = ZMQ_POLLIN; - - int poll_to_stream[2+VISION_STREAM_MAX] = {0}; - int num_polls = 2; - for (int i=0; i= 2) { - continue; - } - if (streams[i].tb) { - polls[num_polls].fd = tbuffer_efd(streams[i].tbuffer); - } else { - polls[num_polls].fd = poolq_efd(streams[i].queue); - } - poll_to_stream[num_polls] = i; - num_polls++; - } - int ret = zmq_poll(polls, num_polls, -1); - if (ret < 0) { - LOGE("poll failed (%d)", ret); - break; - } - if (polls[0].revents) { - break; - } else if (polls[1].revents) { - VisionPacket p; - err = vipc_recv(fd, &p); - // printf("recv %d\n", p.type); - if (err <= 0) { - break; - } else if (p.type == VIPC_STREAM_SUBSCRIBE) { - VisionStreamType stream_type = p.d.stream_sub.type; - VisionPacket rep = { - .type = VIPC_STREAM_BUFS, - .d = { .stream_bufs = { .type = stream_type }, }, - }; - - VisionClientStreamState *stream = &streams[stream_type]; - stream->tb = p.d.stream_sub.tbuffer; - - VisionStreamBufs *stream_bufs = &rep.d.stream_bufs; - if (stream_type == VISION_STREAM_RGB_BACK) { - stream_bufs->width = s->rgb_width; - stream_bufs->height = s->rgb_height; - stream_bufs->stride = s->rgb_stride; - stream_bufs->buf_len = s->rgb_bufs[0].len; - rep.num_fds = UI_BUF_COUNT; - for (int i=0; irgb_bufs[i].fd; - } - if (stream->tb) { - stream->tbuffer = &s->ui_tb; - } else { - assert(false); - } - } else if (stream_type == VISION_STREAM_RGB_FRONT) { - stream_bufs->width = s->rgb_front_width; - stream_bufs->height = s->rgb_front_height; - stream_bufs->stride = s->rgb_front_stride; - stream_bufs->buf_len = s->rgb_front_bufs[0].len; - rep.num_fds = UI_BUF_COUNT; - for (int i=0; irgb_front_bufs[i].fd; - } - if (stream->tb) { - stream->tbuffer = &s->ui_front_tb; - } else { - assert(false); - } - } else if (stream_type == VISION_STREAM_YUV) { - stream_bufs->width = s->yuv_width; - stream_bufs->height = s->yuv_height; - stream_bufs->stride = s->yuv_width; - stream_bufs->buf_len = s->yuv_buf_size; - rep.num_fds = YUV_COUNT; - for (int i=0; iyuv_ion[i].fd; - } - if (stream->tb) { - stream->tbuffer = s->yuv_tb; - } else { - stream->queue = pool_get_queue(&s->yuv_pool); - } - } else if (stream_type == VISION_STREAM_YUV_FRONT) { - stream_bufs->width = s->yuv_front_width; - stream_bufs->height = s->yuv_front_height; - stream_bufs->stride = s->yuv_front_width; - stream_bufs->buf_len = s->yuv_front_buf_size; - rep.num_fds = YUV_COUNT; - for (int i=0; iyuv_front_ion[i].fd; - } - if (stream->tb) { - assert(false); - } else { - stream->queue = pool_get_queue(&s->yuv_front_pool); - } - } else { - assert(false); - } - - if (stream_type == VISION_STREAM_RGB_BACK || - stream_type == VISION_STREAM_RGB_FRONT) { - stream_bufs->buf_info.ui_info = (VisionUIInfo){ - .transformed_width = s->model.in.transformed_width, - .transformed_height = s->model.in.transformed_height, - }; - } - vipc_send(fd, &rep); - streams[stream_type].subscribed = true; - } else if (p.type == VIPC_STREAM_RELEASE) { - // printf("client release f %d %d\n", p.d.stream_rel.type, p.d.stream_rel.idx); - int si = p.d.stream_rel.type; - assert(si < VISION_STREAM_MAX); - if (streams[si].tb) { - tbuffer_release(streams[si].tbuffer, p.d.stream_rel.idx); - } else { - poolq_release(streams[si].queue, p.d.stream_rel.idx); - } - streams[p.d.stream_rel.type].bufs_outstanding--; - } else { - assert(false); - } - } else { - int stream_i = VISION_STREAM_MAX; - for (int i=2; iyuv_metas[idx].frame_id; - rep.d.stream_acq.extra.timestamp_eof = s->yuv_metas[idx].timestamp_eof; - } else if (stream_i == VISION_STREAM_YUV_FRONT) { - rep.d.stream_acq.extra.frame_id = s->yuv_front_metas[idx].frame_id; - rep.d.stream_acq.extra.timestamp_eof = s->yuv_front_metas[idx].timestamp_eof; - } - vipc_send(fd, &rep); - } - } - } - - LOG("client end fd %d\n", fd); - - for (int i=0; iclients_lock); - client->running = false; - pthread_mutex_unlock(&s->clients_lock); - - return NULL; -} - -void* visionserver_thread(void* arg) { - int err; - VisionState *s = (VisionState*)arg; - - set_thread_name("visionserver"); - - zsock_t *terminate = zsock_new_sub(">inproc://terminate", ""); - assert(terminate); - void* terminate_raw = zsock_resolve(terminate); - - unlink(VIPC_SOCKET_PATH); - - int sock = socket(AF_UNIX, SOCK_SEQPACKET, 0); - struct sockaddr_un addr = { - .sun_family = AF_UNIX, - .sun_path = VIPC_SOCKET_PATH, - }; - err = bind(sock, (struct sockaddr *)&addr, sizeof(addr)); - assert(err == 0); - - err = listen(sock, 3); - assert(err == 0); - - // printf("waiting\n"); - - while (!do_exit) { - zmq_pollitem_t polls[2] = {{0}}; - polls[0].socket = terminate_raw; - polls[0].events = ZMQ_POLLIN; - polls[1].fd = sock; - polls[1].events = ZMQ_POLLIN; - - int ret = zmq_poll(polls, ARRAYSIZE(polls), -1); - if (ret < 0) { - LOGE("poll failed (%d)", ret); - break; - } - if (polls[0].revents) { - break; - } else if (!polls[1].revents) { - continue; - } - - int fd = accept(sock, NULL, NULL); - assert(fd >= 0); - - pthread_mutex_lock(&s->clients_lock); - - int client_idx = 0; - for (; client_idx < MAX_CLIENTS; client_idx++) { - if (!s->clients[client_idx].running) break; - } - - if (client_idx >= MAX_CLIENTS) { - LOG("ignoring visionserver connection, max clients connected"); - close(fd); - - pthread_mutex_unlock(&s->clients_lock); - continue; - } - - VisionClientState *client = &s->clients[client_idx]; - client->s = s; - client->fd = fd; - client->running = true; - - err = pthread_create(&client->thread_handle, NULL, - visionserver_client_thread, client); - assert(err == 0); - - pthread_mutex_unlock(&s->clients_lock); - } - - for (int i=0; iclients_lock); - bool running = s->clients[i].running; - pthread_mutex_unlock(&s->clients_lock); - if (running) { - err = pthread_join(s->clients[i].thread_handle, NULL); - assert(err == 0); - } - } - - close(sock); - zsock_destroy(&terminate); - - return NULL; -} - -void* monitoring_thread(void *arg) { - int err; - VisionState *s = (VisionState*)arg; - - set_thread_name("monitoring"); - - TBuffer *tb = pool_get_tbuffer(&s->yuv_front_pool); - - cl_command_queue q = clCreateCommandQueue(s->context, s->device_id, 0, &err); - assert(err == 0); - - double last = 0; - while (!do_exit) { - int buf_idx = tbuffer_acquire(tb); - if (buf_idx < 0) { - break; - } - - FrameMetadata frame_data = s->yuv_front_metas[buf_idx]; - - // only process every frame - if ((frame_data.frame_id % 1) == 0) { - - double t1 = millis_since_boot(); - - MonitoringResult res = monitoring_eval_frame(&s->monitoring, q, - s->yuv_front_cl[buf_idx], s->yuv_front_width, s->yuv_front_height); - - double t2 = millis_since_boot(); - - // send driver monitoring packet - { - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - - auto framed = event.initDriverMonitoring(); - framed.setFrameId(frame_data.frame_id); - - // junk 0s from legacy model - //kj::ArrayPtr descriptor_DEPRECATED(&res.descriptor_DEPRECATED[0], ARRAYSIZE(res.descriptor_DEPRECATED)); - //framed.setDescriptor(descriptor_DEPRECATED); - //framed.setStd(res.std_DEPRECATED); - // why not use this junk space for reporting inference time instead - // framed.setStdDEPRECATED(static_cast(t2-t1)); - - kj::ArrayPtr face_orientation(&res.face_orientation[0], ARRAYSIZE(res.face_orientation)); - kj::ArrayPtr face_position(&res.face_position[0], ARRAYSIZE(res.face_position)); - framed.setFaceOrientation(face_orientation); - framed.setFacePosition(face_position); - framed.setFaceProb(res.face_prob); - framed.setLeftEyeProb(res.left_eye_prob); - framed.setRightEyeProb(res.right_eye_prob); - framed.setLeftBlinkProb(res.left_blink_prob); - framed.setRightBlinkProb(res.right_blink_prob); - - - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - zmq_send(s->monitoring_sock_raw, bytes.begin(), bytes.size(), ZMQ_DONTWAIT); - } - - t2 = millis_since_boot(); - - //LOGD("monitoring process: %.2fms, from last %.2fms", t2-t1, t1-last); - last = t1; - } - - tbuffer_release(tb, buf_idx); - } - - return NULL; -} - -void* frontview_thread(void *arg) { - int err; - VisionState *s = (VisionState*)arg; - - set_thread_name("frontview"); - - cl_command_queue q = clCreateCommandQueue(s->context, s->device_id, 0, &err); - assert(err == 0); - - for (int cnt = 0; !do_exit; cnt++) { - int buf_idx = tbuffer_acquire(&s->cameras.front.camera_tb); - if (buf_idx < 0) { - break; - } - - int ui_idx = tbuffer_select(&s->ui_front_tb); - FrameMetadata frame_data = s->cameras.front.camera_bufs_metadata[buf_idx]; - - double t1 = millis_since_boot(); - - err = clSetKernelArg(s->krnl_debayer_front, 0, sizeof(cl_mem), &s->front_camera_bufs_cl[buf_idx]); - assert(err == 0); - err = clSetKernelArg(s->krnl_debayer_front, 1, sizeof(cl_mem), &s->rgb_front_bufs_cl[ui_idx]); - assert(err == 0); - float digital_gain = 1.0; - err = clSetKernelArg(s->krnl_debayer_front, 2, sizeof(float), &digital_gain); - assert(err == 0); - - cl_event debayer_event; - const size_t debayer_work_size = s->rgb_front_height; - const size_t debayer_local_work_size = 128; - err = clEnqueueNDRangeKernel(q, s->krnl_debayer_front, 1, NULL, - &debayer_work_size, &debayer_local_work_size, 0, 0, &debayer_event); - assert(err == 0); - clWaitForEvents(1, &debayer_event); - clReleaseEvent(debayer_event); - - tbuffer_release(&s->cameras.front.camera_tb, buf_idx); - - visionbuf_sync(&s->rgb_front_bufs[ui_idx], VISIONBUF_SYNC_FROM_DEVICE); - - // auto exposure - const uint8_t *bgr_front_ptr = (const uint8_t*)s->rgb_front_bufs[ui_idx].addr; -#ifndef DEBUG_DRIVER_MONITOR - if (cnt % 3 == 0) -#endif - { - // for driver autoexposure, use bottom right corner - const int y_start = s->rgb_front_height / 3; - const int y_end = s->rgb_front_height; - const int x_start = s->rgb_front_width * 2 / 3; - const int x_end = s->rgb_front_width; - - uint32_t lum_binning[256] = {0,}; - for (int y = y_start; y < y_end; ++y) { - for (int x = x_start; x < x_end; x += 2) { // every 2nd col - const uint8_t *pix = &bgr_front_ptr[y * s->rgb_front_stride + x * 3]; - unsigned int lum = (unsigned int)pix[0] + pix[1] + pix[2]; -#ifdef DEBUG_DRIVER_MONITOR - uint8_t *pix_rw = (uint8_t *)pix; - - // set all the autoexposure pixels to pure green (pixel format is bgr) - pix_rw[0] = pix_rw[2] = 0; - pix_rw[1] = 0xff; -#endif - lum_binning[std::min(lum / 3, 255u)]++; - } - } - const unsigned int lum_total = (y_end - y_start) * (x_end - x_start)/2; - unsigned int lum_cur = 0; - int lum_med = 0; - for (lum_med=0; lum_med<256; lum_med++) { - lum_cur += lum_binning[lum_med]; - if (lum_cur >= lum_total / 2) { - break; - } - } - camera_autoexposure(&s->cameras.front, lum_med / 256.0); - } - - // push YUV buffer - int yuv_idx = pool_select(&s->yuv_front_pool); - s->yuv_front_metas[yuv_idx] = frame_data; - - rgb_to_yuv_queue(&s->front_rgb_to_yuv_state, q, s->rgb_front_bufs_cl[ui_idx], s->yuv_front_cl[yuv_idx]); - visionbuf_sync(&s->yuv_front_ion[yuv_idx], VISIONBUF_SYNC_FROM_DEVICE); - s->yuv_front_metas[yuv_idx] = frame_data; - - // no reference required cause we don't use this in visiond - //pool_acquire(&s->yuv_front_pool, yuv_idx); - pool_push(&s->yuv_front_pool, yuv_idx); - //pool_release(&s->yuv_front_pool, yuv_idx); - - /*FILE *f = fopen("/tmp/test2", "wb"); - printf("%d %d\n", s->rgb_front_height, s->rgb_front_stride); - fwrite(bgr_front_ptr, 1, s->rgb_front_stride * s->rgb_front_height, f); - fclose(f);*/ - - tbuffer_dispatch(&s->ui_front_tb, ui_idx); - - double t2 = millis_since_boot(); - - //LOGD("front process: %.2fms", t2-t1); - } - - return NULL; -} - -void* processing_thread(void *arg) { - int err; - VisionState *s = (VisionState*)arg; - - set_thread_name("processing"); - - err = set_realtime_priority(1); - LOG("setpriority returns %d", err); - - // init cl stuff - const cl_queue_properties props[] = {0}; //CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_HIGH_KHR, 0}; - cl_command_queue q = clCreateCommandQueueWithProperties(s->context, s->device_id, props, &err); - assert(err == 0); - - zsock_t *model_sock = zsock_new_pub("@tcp://*:8009"); - assert(model_sock); - void *model_sock_raw = zsock_resolve(model_sock); - -#ifdef SEND_NET_INPUT - zsock_t *img_sock = zsock_new_pub("@tcp://*:9000"); - assert(img_sock); - void *img_sock_raw = zsock_resolve(img_sock); -#else - void *img_sock_raw = NULL; -#endif - -#ifdef DUMP_RGB - s->rgb_width = s->frame_width; - s->rgb_height = s->frame_height; - FILE *dump_rgb_file = fopen("/sdcard/dump.rgb", "wb"); -#endif - - // init the net - LOG("processing start!"); - - for (int cnt = 0; !do_exit; cnt++) { - int buf_idx = tbuffer_acquire(&s->cameras.rear.camera_tb); - // int buf_idx = camera_acquire_buffer(s); - if (buf_idx < 0) { - break; - } - - double t1 = millis_since_boot(); - - FrameMetadata frame_data = s->cameras.rear.camera_bufs_metadata[buf_idx]; - uint32_t frame_id = frame_data.frame_id; - - if (frame_id == -1) { - LOGE("no frame data? wtf"); - tbuffer_release(&s->cameras.rear.camera_tb, buf_idx); - continue; - } - - int ui_idx = tbuffer_select(&s->ui_tb); - int rgb_idx = ui_idx; - - cl_event debayer_event; - if (s->cameras.rear.ci.bayer) { - err = clSetKernelArg(s->krnl_debayer_rear, 0, sizeof(cl_mem), &s->camera_bufs_cl[buf_idx]); - cl_check_error(err); - err = clSetKernelArg(s->krnl_debayer_rear, 1, sizeof(cl_mem), &s->rgb_bufs_cl[rgb_idx]); - cl_check_error(err); - err = clSetKernelArg(s->krnl_debayer_rear, 2, sizeof(float), &s->cameras.rear.digital_gain); - assert(err == 0); - - const size_t debayer_work_size = s->rgb_height; // doesn't divide evenly, is this okay? - const size_t debayer_local_work_size = 128; - err = clEnqueueNDRangeKernel(q, s->krnl_debayer_rear, 1, NULL, - &debayer_work_size, &debayer_local_work_size, 0, 0, &debayer_event); - assert(err == 0); - } else { - assert(s->rgb_buf_size >= s->frame_size); - assert(s->rgb_stride == s->frame_stride); - err = clEnqueueCopyBuffer(q, s->camera_bufs_cl[buf_idx], s->rgb_bufs_cl[rgb_idx], - 0, 0, s->rgb_buf_size, 0, 0, &debayer_event); - assert(err == 0); - } - - clWaitForEvents(1, &debayer_event); - clReleaseEvent(debayer_event); - - tbuffer_release(&s->cameras.rear.camera_tb, buf_idx); - - visionbuf_sync(&s->rgb_bufs[rgb_idx], VISIONBUF_SYNC_FROM_DEVICE); - - - double t2 = millis_since_boot(); - - uint8_t *bgr_ptr = (uint8_t*)s->rgb_bufs[rgb_idx].addr; - -#ifdef DUMP_RGB - if (cnt % 20 == 0) { - fwrite(bgr_ptr, s->rgb_buf_size, 1, dump_rgb_file); - LOG("%d x %d", s->rgb_width, s->rgb_height); - assert(1==2); - } -#endif - - double yt1 = millis_since_boot(); - - int yuv_idx = pool_select(&s->yuv_pool); - - s->yuv_metas[yuv_idx] = frame_data; - - uint8_t* yuv_ptr_y = s->yuv_bufs[yuv_idx].y; - uint8_t* yuv_ptr_u = s->yuv_bufs[yuv_idx].u; - uint8_t* yuv_ptr_v = s->yuv_bufs[yuv_idx].v; - cl_mem yuv_cl = s->yuv_cl[yuv_idx]; - rgb_to_yuv_queue(&s->rgb_to_yuv_state, q, s->rgb_bufs_cl[rgb_idx], yuv_cl); - visionbuf_sync(&s->yuv_ion[yuv_idx], VISIONBUF_SYNC_FROM_DEVICE); - - double yt2 = millis_since_boot(); - // keep another reference around till were done processing - pool_acquire(&s->yuv_pool, yuv_idx); - - pool_push(&s->yuv_pool, yuv_idx); - - pthread_mutex_lock(&s->transform_lock); - mat3 transform = s->cur_transform; - const bool run_model_this_iter = s->run_model; - pthread_mutex_unlock(&s->transform_lock); - - double mt1 = 0, mt2 = 0; - if (run_model_this_iter) { - - mat3 model_transform = matmul3(s->yuv_transform, transform); - - mt1 = millis_since_boot(); - s->model_bufs[ui_idx] = - model_eval_frame(&s->model, q, yuv_cl, s->yuv_width, s->yuv_height, - model_transform, img_sock_raw); - mt2 = millis_since_boot(); - - model_publish(model_sock_raw, frame_id, model_transform, s->model_bufs[ui_idx]); - } - - - // send frame event - { - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - - auto framed = event.initFrame(); - framed.setFrameId(frame_data.frame_id); - framed.setEncodeId(cnt); - framed.setTimestampEof(frame_data.timestamp_eof); - framed.setFrameLength(frame_data.frame_length); - framed.setIntegLines(frame_data.integ_lines); - framed.setGlobalGain(frame_data.global_gain); - framed.setLensPos(frame_data.lens_pos); - framed.setLensSag(frame_data.lens_sag); - framed.setLensErr(frame_data.lens_err); - framed.setLensTruePos(frame_data.lens_true_pos); - - -#ifndef QCOM - framed.setImage(kj::arrayPtr((const uint8_t*)s->yuv_ion[yuv_idx].addr, s->yuv_buf_size)); -#endif - - kj::ArrayPtr transform_vs(&s->yuv_transform.v[0], 9); - framed.setTransform(transform_vs); - - if (s->recorder_sock_raw != NULL) { - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - zmq_send(s->recorder_sock_raw, bytes.begin(), bytes.size(), ZMQ_DONTWAIT); - } - } - - // push the frame to the posenet - // TODO: This doesn't always have to run - double pt1 = 0, pt2 = 0, pt3 = 0; - pt1 = millis_since_boot(); - posenet_push(&s->posenet, yuv_ptr_y, s->yuv_width); - pt2 = millis_since_boot(); - - // posenet runs every 5 - if (cnt % 5 == 0) { - posenet_eval(&s->posenet); - - // send posenet event - { - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - - auto posenetd = event.initCameraOdometry(); - kj::ArrayPtr trans_vs(&s->posenet.output[0], 3); - posenetd.setTrans(trans_vs); - kj::ArrayPtr rot_vs(&s->posenet.output[3], 3); - posenetd.setRot(rot_vs); - kj::ArrayPtr trans_std_vs(&s->posenet.output[6], 3); - posenetd.setTransStd(trans_std_vs); - kj::ArrayPtr rot_std_vs(&s->posenet.output[9], 3); - posenetd.setRotStd(rot_std_vs); - - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - zmq_send(s->posenet_sock_raw, bytes.begin(), bytes.size(), ZMQ_DONTWAIT); - } - pt3 = millis_since_boot(); - LOGD("pre: %.2fms | posenet: %.2fms", (pt2-pt1), (pt3-pt1)); - } - - // one thumbnail per 5 seconds (instead of %5 == 0 posenet) - if (cnt % 100 == 3) { - uint8_t* thumbnail_buffer = NULL; - uint64_t thumbnail_len = 0; - - unsigned char *row = (unsigned char *)malloc(s->rgb_width/2*3); - mt1 = millis_since_boot(); - - struct jpeg_compress_struct cinfo; - struct jpeg_error_mgr jerr; - - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_compress(&cinfo); - jpeg_mem_dest(&cinfo, &thumbnail_buffer, &thumbnail_len); - - cinfo.image_width = s->rgb_width / 2; - cinfo.image_height = s->rgb_height / 2; - cinfo.input_components = 3; - cinfo.in_color_space = JCS_RGB; - - jpeg_set_defaults(&cinfo); - jpeg_set_quality(&cinfo, 50, true); - jpeg_start_compress(&cinfo, true); - - JSAMPROW row_pointer[1]; - for (int i = 0; i < s->rgb_height; i+=2) { - for (int j = 0; j < s->rgb_width*3; j+=6) { - for (int k = 0; k < 3; k++) { - uint16_t dat = 0; - dat += bgr_ptr[s->rgb_stride*i + j + k]; - dat += bgr_ptr[s->rgb_stride*i + j+3 + k]; - dat += bgr_ptr[s->rgb_stride*(i+1) + j + k]; - dat += bgr_ptr[s->rgb_stride*(i+1) + j+3 + k]; - row[(j/2) + (2-k)] = dat/4; - } - } - row_pointer[0] = row; - jpeg_write_scanlines(&cinfo, row_pointer, 1); - } - free(row); - jpeg_finish_compress(&cinfo); - - mt2 = millis_since_boot(); - //printf("jpeg produced %lu bytes in %f\n", thumbnail_len, mt2-mt1); - - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - - auto thumbnaild = event.initThumbnail(); - thumbnaild.setFrameId(frame_data.frame_id); - thumbnaild.setTimestampEof(frame_data.timestamp_eof); - thumbnaild.setThumbnail(kj::arrayPtr((const uint8_t*)thumbnail_buffer, thumbnail_len)); - - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - zmq_send(s->thumbnail_sock_raw, bytes.begin(), bytes.size(), ZMQ_DONTWAIT); - - free(thumbnail_buffer); - } - - tbuffer_dispatch(&s->ui_tb, ui_idx); - - // auto exposure over big box - const int exposure_x = 290; - const int exposure_y = 282 + 40; - const int exposure_height = 314; - const int exposure_width = 560; - if (cnt % 3 == 0) { - // find median box luminance for AE - uint32_t lum_binning[256] = {0,}; - for (int y=0; yyuv_width) + exposure_x + x]; - lum_binning[lum]++; - } - } - const unsigned int lum_total = exposure_height * exposure_width; - unsigned int lum_cur = 0; - int lum_med = 0; - for (lum_med=0; lum_med<256; lum_med++) { - // shouldn't be any values less than 16 - yuv footroom - lum_cur += lum_binning[lum_med]; - if (lum_cur >= lum_total / 2) { - break; - } - } - // double avg = (double)acc / (big_box_width * big_box_height) - 16; - // printf("avg %d\n", lum_med); - - camera_autoexposure(&s->cameras.rear, lum_med / 256.0); - } - - pool_release(&s->yuv_pool, yuv_idx); - - // if (cnt%40 == 0) { - // FILE* of = fopen("/sdcard/tmp.yuv", "wb"); - // fwrite(transformed_ptr_y, 1, s->transformed_width*s->transformed_height, of); - // fwrite(transformed_ptr_u, 1, (s->transformed_width/2)*(s->transformed_height/2), of); - // fwrite(transformed_ptr_v, 1, (s->transformed_width/2)*(s->transformed_height/2), of); - // fclose(of); - // } - - double t5 = millis_since_boot(); - - LOGD("queued: %.2fms, yuv: %.2f, model: %.2fms | processing: %.3fms", - (t2-t1), (yt2-yt1), (mt2-mt1), (t5-t1)); - } - -#ifdef DUMP_RGB - fclose(dump_rgb_file); -#endif - - zsock_destroy(&model_sock); - - return NULL; -} - -void* live_thread(void *arg) { - int err; - VisionState *s = (VisionState*)arg; - - set_thread_name("live"); - - zsock_t *terminate = zsock_new_sub(">inproc://terminate", ""); - assert(terminate); - - zsock_t *liveCalibration_sock = zsock_new_sub(">tcp://127.0.0.1:8019", ""); - assert(liveCalibration_sock); - - zpoller_t *poller = zpoller_new(liveCalibration_sock, terminate, NULL); - assert(poller); - - /* - import numpy as np - from common.transformations.model import medmodel_frame_from_road_frame - medmodel_frame_from_ground = medmodel_frame_from_road_frame[:, (0, 1, 3)] - ground_from_medmodel_frame = np.linalg.inv(medmodel_frame_from_ground) - */ - Eigen::Matrix ground_from_medmodel_frame; - ground_from_medmodel_frame << - 0.00000000e+00, 0.00000000e+00, 1.00000000e+00, - -1.09890110e-03, 0.00000000e+00, 2.81318681e-01, - -1.84808520e-20, 9.00738606e-04,-4.28751576e-02; - - Eigen::Matrix eon_intrinsics; - eon_intrinsics << - 910.0, 0.0, 582.0, - 0.0, 910.0, 437.0, - 0.0, 0.0, 1.0; - - while (!do_exit) { - zsock_t *which = (zsock_t*)zpoller_wait(poller, -1); - if (which == terminate || which == NULL) { - break; - } - - zmq_msg_t msg; - err = zmq_msg_init(&msg); - assert(err == 0); - - err = zmq_msg_recv(&msg, zsock_resolve(which), 0); - assert(err >= 0); - size_t len = zmq_msg_size(&msg); - - // make copy due to alignment issues, will be freed on out of scope - auto amsg = kj::heapArray((len / sizeof(capnp::word)) + 1); - memcpy(amsg.begin(), (const uint8_t*)zmq_msg_data(&msg), len); - - // track camera frames to sync to encoder - capnp::FlatArrayMessageReader cmsg(amsg); - cereal::Event::Reader event = cmsg.getRoot(); - - if (event.isLiveCalibration()) { - pthread_mutex_lock(&s->transform_lock); - - auto extrinsic_matrix = event.getLiveCalibration().getExtrinsicMatrix(); - Eigen::Matrix extrinsic_matrix_eigen; - for (int i = 0; i < 4*3; i++){ - extrinsic_matrix_eigen(i / 4, i % 4) = extrinsic_matrix[i]; - } - - auto camera_frame_from_road_frame = eon_intrinsics * extrinsic_matrix_eigen; - Eigen::Matrix camera_frame_from_ground; - camera_frame_from_ground.col(0) = camera_frame_from_road_frame.col(0); - camera_frame_from_ground.col(1) = camera_frame_from_road_frame.col(1); - camera_frame_from_ground.col(2) = camera_frame_from_road_frame.col(3); - - auto warp_matrix = camera_frame_from_ground * ground_from_medmodel_frame; - - for (int i=0; i<3*3; i++) { - s->cur_transform.v[i] = warp_matrix(i / 3, i % 3); - } - - s->run_model = true; - pthread_mutex_unlock(&s->transform_lock); - } - - zmq_msg_close(&msg); - } - - zpoller_destroy(&poller); - zsock_destroy(&terminate); - - zsock_destroy(&liveCalibration_sock); - - return NULL; -} - -void set_do_exit(int sig) { - do_exit = 1; -} - -void party(VisionState *s, bool nomodel) { - int err; - - s->terminate_pub = zsock_new_pub("@inproc://terminate"); - assert(s->terminate_pub); - -#ifndef __APPLE__ - pthread_t visionserver_thread_handle; - err = pthread_create(&visionserver_thread_handle, NULL, - visionserver_thread, s); - assert(err == 0); -#endif - - pthread_t proc_thread_handle; - err = pthread_create(&proc_thread_handle, NULL, - processing_thread, s); - assert(err == 0); - -#ifdef QCOM - pthread_t frontview_thread_handle; - err = pthread_create(&frontview_thread_handle, NULL, - frontview_thread, s); - assert(err == 0); -#endif - - pthread_t monitoring_thread_handle; - err = pthread_create(&monitoring_thread_handle, NULL, monitoring_thread, s); - assert(err == 0); - - pthread_t live_thread_handle; - err = pthread_create(&live_thread_handle, NULL, - live_thread, s); - assert(err == 0); - - // priority for cameras - err = set_realtime_priority(1); - LOG("setpriority returns %d", err); - - cameras_run(&s->cameras); - - tbuffer_stop(&s->ui_tb); - tbuffer_stop(&s->ui_front_tb); - pool_stop(&s->yuv_pool); - pool_stop(&s->yuv_front_pool); - - zsock_signal(s->terminate_pub, 0); - -#ifdef QCOM - LOG("joining frontview_thread"); - err = pthread_join(frontview_thread_handle, NULL); - assert(err == 0); -#endif - -#ifndef __APPLE__ - LOG("joining visionserver_thread"); - err = pthread_join(visionserver_thread_handle, NULL); - assert(err == 0); -#endif - - LOG("joining proc_thread"); - err = pthread_join(proc_thread_handle, NULL); - assert(err == 0); - - LOG("joining live_thread"); - err = pthread_join(live_thread_handle, NULL); - assert(err == 0); - - zsock_destroy (&s->terminate_pub); -} - -} - -int main(int argc, char **argv) { - int err; - - zsys_handler_set(NULL); - signal(SIGINT, (sighandler_t)set_do_exit); - signal(SIGTERM, (sighandler_t)set_do_exit); - - // boringssl via curl via the calibration api can sometimes - // try to write to a closed socket. just ignore SIGPIPE - signal(SIGPIPE, SIG_IGN); - - bool test_run = false; - if (argc > 1 && strcmp(argv[1], "-t") == 0) { - // immediately tear everything down. useful for caching opencl - test_run = true; - } - - bool no_model = false; - if (argc > 1 && strcmp(argv[1], "--no-model") == 0) { - no_model = true; - } - - VisionState state = {0}; - VisionState *s = &state; - - clu_init(); - cl_init(s); - - model_init(&s->model, s->device_id, s->context, true); - monitoring_init(&s->monitoring, s->device_id, s->context); - posenet_init(&s->posenet); - - // s->zctx = zctx_shadow_zmq_ctx(zsys_init()); - - cameras_init(&s->cameras); - - s->frame_width = s->cameras.rear.ci.frame_width; - s->frame_height = s->cameras.rear.ci.frame_height; - s->frame_stride = s->cameras.rear.ci.frame_stride; - s->frame_size = s->cameras.rear.frame_size; - - // Do not run the model until we receive valid calibration. - s->run_model = false; - pthread_mutex_init(&s->transform_lock, NULL); - - init_buffers(s); - - #ifdef QCOM - s->recorder_sock = zsock_new_pub("@tcp://*:8002"); - assert(s->recorder_sock); - s->recorder_sock_raw = zsock_resolve(s->recorder_sock); - #endif - - s->monitoring_sock = zsock_new_pub("@tcp://*:8063"); - assert(s->monitoring_sock); - s->monitoring_sock_raw = zsock_resolve(s->monitoring_sock); - - s->posenet_sock = zsock_new_pub("@tcp://*:8066"); - assert(s->posenet_sock); - s->posenet_sock_raw = zsock_resolve(s->posenet_sock); - - s->thumbnail_sock = zsock_new_pub("@tcp://*:8069"); - assert(s->thumbnail_sock); - s->thumbnail_sock_raw = zsock_resolve(s->thumbnail_sock); - - cameras_open(&s->cameras, &s->camera_bufs[0], &s->focus_bufs[0], &s->stats_bufs[0], &s->front_camera_bufs[0]); - - if (test_run) { - do_exit = true; - } - party(s, no_model); - - zsock_destroy(&s->recorder_sock); - zsock_destroy(&s->monitoring_sock); - zsock_destroy(&s->posenet_sock); - zsock_destroy(&s->thumbnail_sock); - // zctx_destroy(&s->zctx); - - model_free(&s->model); - monitoring_free(&s->monitoring); - free_buffers(s); - - cl_free(s); - - return 0; -} diff --git a/site_scons/site_tools/cython.py b/site_scons/site_tools/cython.py new file mode 100644 index 00000000000000..45ba797c4572e7 --- /dev/null +++ b/site_scons/site_tools/cython.py @@ -0,0 +1,38 @@ +import SCons +from SCons.Action import Action + +cythonAction = Action("$CYTHONCOM") + +def create_builder(env): + try: + cython = env['BUILDERS']['Cython'] + except KeyError: + cython = SCons.Builder.Builder( + action = cythonAction, + emitter = {}, + suffix = cython_suffix_emitter, + single_source = 1 + ) + env['BUILDERS']['Cython'] = cython + return cython + +def cython_suffix_emitter(env, source): + return "$CYTHONCFILESUFFIX" + +def generate(env): + env["CYTHON"] = "cythonize" + env["CYTHONCOM"] = "$CYTHON $CYTHONFLAGS $SOURCE" + env["CYTHONCFILESUFFIX"] = ".cpp" + + c_file, _ = SCons.Tool.createCFileBuilders(env) + + c_file.suffix['.pyx'] = cython_suffix_emitter + c_file.add_action('.pyx', cythonAction) + + c_file.suffix['.py'] = cython_suffix_emitter + c_file.add_action('.py', cythonAction) + + create_builder(env) + +def exists(env): + return True
%s